semiotic 3.8.3 → 3.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +9 -9
- package/README.md +40 -39
- package/ai/examples.md +1 -1
- package/ai/schema.json +2726 -300
- package/ai/surface-manifest.json +1 -1
- package/ai/system-prompt.md +1 -1
- package/dist/chunk-chunk-2JGJ5GUG.module.min.js +0 -1
- package/dist/chunk-chunk-3ILKBVVQ.module.min.js +1 -0
- package/dist/{chunk-chunk-XQYVEKEJ.module.min.js → chunk-chunk-6TPGFL7M.module.min.js} +1 -1
- package/dist/{chunk-chunk-VVCA3DB7.module.min.js → chunk-chunk-7ALTGHK6.module.min.js} +1 -1
- package/dist/chunk-chunk-7KZJUTKP.module.min.js +2 -0
- package/dist/chunk-chunk-7RYBCTK5.module.min.js +1 -0
- package/dist/chunk-chunk-ACLDBMRH.module.min.js +2 -0
- package/dist/{chunk-chunk-AZJUDQRM.module.min.js → chunk-chunk-AQPQN2HH.module.min.js} +1 -1
- package/dist/chunk-chunk-ASKSE5F5.module.min.js +1 -0
- package/dist/chunk-chunk-AVBI6GDT.module.min.js +1 -0
- package/dist/chunk-chunk-B3DRZPBK.module.min.js +2 -0
- package/dist/chunk-chunk-BFHUYEOS.module.min.js +2 -0
- package/dist/chunk-chunk-C4YA6TDR.module.min.js +1 -0
- package/dist/chunk-chunk-C57LR3YG.module.min.js +1 -0
- package/dist/chunk-chunk-F5V4UIE6.module.min.js +2 -0
- package/dist/chunk-chunk-F7WFPD4O.module.min.js +2 -0
- package/dist/{chunk-chunk-SANERMIZ.module.min.js → chunk-chunk-FBGHXL72.module.min.js} +1 -1
- package/dist/chunk-chunk-FP44FHFO.module.min.js +2 -0
- package/dist/chunk-chunk-HKXUAEPJ.module.min.js +2 -0
- package/dist/chunk-chunk-ICEXPNDC.module.min.js +2 -0
- package/dist/chunk-chunk-IY7RYD4S.module.min.js +1 -0
- package/dist/{chunk-chunk-7FW6EGLP.module.min.js → chunk-chunk-JDXT6ORT.module.min.js} +1 -1
- package/dist/chunk-chunk-JMVEIZXP.module.min.js +1 -0
- package/dist/chunk-chunk-KHCOJMGK.module.min.js +1 -0
- package/dist/{chunk-chunk-OQTLSTGI.module.min.js → chunk-chunk-KQ546MKE.module.min.js} +1 -1
- package/dist/chunk-chunk-LQBSXO7K.module.min.js +2 -0
- package/dist/chunk-chunk-LRIFN2HK.module.min.js +1 -0
- package/dist/chunk-chunk-MFHF4J2Z.module.min.js +1 -0
- package/dist/{chunk-chunk-JNCHKRIR.module.min.js → chunk-chunk-N6VKKF3A.module.min.js} +1 -1
- package/dist/chunk-chunk-NEVE562N.module.min.js +1 -0
- package/dist/chunk-chunk-NKZ75IM5.module.min.js +2 -0
- package/dist/chunk-chunk-PLIDPQNG.module.min.js +2 -0
- package/dist/{chunk-chunk-FYY2ACNJ.module.min.js → chunk-chunk-PRDGLMJT.module.min.js} +1 -1
- package/dist/chunk-chunk-QGZGZI4X.module.min.js +1 -0
- package/dist/chunk-chunk-RP7WTID5.module.min.js +1 -0
- package/dist/chunk-chunk-S7KLNUO6.module.min.js +1 -0
- package/dist/chunk-chunk-SR4ZXOWR.module.min.js +2 -0
- package/dist/chunk-chunk-ZOAQDIJO.module.min.js +1 -0
- package/dist/chunk-minimapBrushOverlay-JU57U7NM.module.min.js +2 -0
- package/dist/chunk-scatterplotMatrixBrushOverlay-SDIZSN66.module.min.js +2 -0
- package/dist/chunk-statisticalOverlays-QGDLRUHX.module.min.js +1 -0
- package/dist/chunk-statisticalOverlays-T77OKLDY.module.min.js +1 -0
- package/dist/components/ChartContainer.d.ts +2 -2
- package/dist/components/ai/chartCapabilityTypes.d.ts +5 -0
- package/dist/components/charts/geo/ChoroplethMap.d.ts +2 -0
- package/dist/components/charts/geo/DistanceCartogram.d.ts +7 -3
- package/dist/components/charts/geo/FlowMap.d.ts +4 -0
- package/dist/components/charts/geo/ProportionalSymbolMap.d.ts +3 -1
- package/dist/components/charts/physics/CollisionSwarmChart.d.ts +6 -1
- package/dist/components/charts/physics/GaltonBoardChart.d.ts +6 -1
- package/dist/components/charts/physics/gauntletChartProps.d.ts +7 -1
- package/dist/components/charts/physics/gauntletChrome.d.ts +2 -1
- package/dist/components/charts/physics/gauntletPhysics.d.ts +19 -4
- package/dist/components/charts/physics/gauntletRuntime.d.ts +3 -0
- package/dist/components/charts/physics/physicsHocUtils.d.ts +12 -0
- package/dist/components/charts/shared/chartMode.d.ts +8 -0
- package/dist/components/charts/shared/chartSpecCore.d.ts +2 -2
- package/dist/components/charts/shared/hatchPattern.d.ts +8 -3
- package/dist/components/charts/shared/lineSeriesSsr.d.ts +55 -0
- package/dist/components/charts/shared/types.d.ts +2 -2
- package/dist/components/charts/shared/validateProps.d.ts +1 -1
- package/dist/components/charts/xy/AreaChart.d.ts +10 -0
- package/dist/components/charts/xy/minimapBrushOverlay.d.ts +17 -0
- package/dist/components/charts/xy/minimapBrushOverlayLazy.d.ts +4 -0
- package/dist/components/charts/xy/scatterplotMatrixBrushOverlay.d.ts +8 -0
- package/dist/components/charts/xy/scatterplotMatrixBrushOverlayLazy.d.ts +3 -0
- package/dist/components/realtime/types.d.ts +5 -0
- package/dist/components/recipes/gridObservatory.d.ts +176 -0
- package/dist/components/recipes/recipeChrome.d.ts +24 -0
- package/dist/components/recipes/sequenceLayout.d.ts +139 -0
- package/dist/components/semiotic-recipes-core.d.ts +6 -2
- package/dist/components/server/staticAnnotations.d.ts +3 -1
- package/dist/components/stream/SceneToSVG.d.ts +6 -6
- package/dist/components/stream/SceneToSVGOrdinal.d.ts +12 -0
- package/dist/components/stream/networkFramePaint.d.ts +2 -0
- package/dist/components/stream/physics/PhysicsPipelineStore.d.ts +18 -2
- package/dist/components/stream/physics/physicsBodyCanvas.d.ts +7 -0
- package/dist/components/stream/physics/physicsPipelineEviction.d.ts +15 -0
- package/dist/components/stream/physics/physicsPipelineObservations.d.ts +1 -1
- package/dist/components/stream/physics/physicsPipelineQuiescence.d.ts +20 -0
- package/dist/components/stream/sceneToSVGShared.d.ts +30 -1
- package/dist/components/stream/types.d.ts +4 -0
- package/dist/components/stream/useHydration.d.ts +7 -1
- package/dist/components/stream/xySceneBuilders/candlestickScene.d.ts +1 -1
- package/dist/forceLayoutWorker.js +1 -1
- package/dist/geo.min.js +1 -1
- package/dist/geo.module.min.js +1 -1
- package/dist/network.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/physics.min.js +1 -1
- package/dist/physics.module.min.js +1 -1
- package/dist/physicsWorker.js +1 -1
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/rough.min.js +1 -1
- package/dist/rough.module.min.js +1 -1
- package/dist/semiotic-ai-core.min.js +1 -1
- package/dist/semiotic-ai-core.module.min.js +1 -1
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-experimental.min.js +1 -1
- package/dist/semiotic-experimental.module.min.js +1 -1
- package/dist/semiotic-realtime-core.min.js +1 -1
- package/dist/semiotic-realtime-core.module.min.js +1 -1
- package/dist/semiotic-recipes-core.d.ts +6 -2
- package/dist/semiotic-recipes-core.min.js +1 -1
- package/dist/semiotic-recipes-core.module.min.js +1 -1
- package/dist/semiotic-recipes.min.js +1 -1
- package/dist/semiotic-recipes.module.min.js +1 -1
- package/dist/semiotic-server-edge.min.js +1 -1
- package/dist/semiotic-server-edge.module.min.js +1 -1
- package/dist/semiotic-server-node.min.js +1 -1
- package/dist/semiotic-server-node.module.min.js +1 -1
- package/dist/semiotic-utils-core.min.js +1 -1
- package/dist/semiotic-utils-core.module.min.js +1 -1
- package/dist/semiotic-utils.min.js +1 -1
- package/dist/semiotic-utils.module.min.js +1 -1
- package/dist/semiotic-value.module.min.js +1 -1
- package/dist/semiotic.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +3 -2
- package/dist/chunk-chunk-255KDHW5.module.min.js +0 -1
- package/dist/chunk-chunk-2CCFBTQC.module.min.js +0 -2
- package/dist/chunk-chunk-2RXP3FS3.module.min.js +0 -1
- package/dist/chunk-chunk-2WVCH4PL.module.min.js +0 -1
- package/dist/chunk-chunk-4TMZXLCR.module.min.js +0 -1
- package/dist/chunk-chunk-5APBQXZA.module.min.js +0 -1
- package/dist/chunk-chunk-6HSGDMTA.module.min.js +0 -2
- package/dist/chunk-chunk-7OEOSCBP.module.min.js +0 -1
- package/dist/chunk-chunk-A63CTACR.module.min.js +0 -2
- package/dist/chunk-chunk-B6V35LMY.module.min.js +0 -2
- package/dist/chunk-chunk-BOSVL645.module.min.js +0 -2
- package/dist/chunk-chunk-CP3EN6KZ.module.min.js +0 -1
- package/dist/chunk-chunk-F25UA5HT.module.min.js +0 -1
- package/dist/chunk-chunk-FRIO6MCV.module.min.js +0 -1
- package/dist/chunk-chunk-GWSWSPXN.module.min.js +0 -1
- package/dist/chunk-chunk-I6C3KR5H.module.min.js +0 -2
- package/dist/chunk-chunk-IP2UE74X.module.min.js +0 -1
- package/dist/chunk-chunk-J3ELI22J.module.min.js +0 -1
- package/dist/chunk-chunk-J5RL6GXU.module.min.js +0 -2
- package/dist/chunk-chunk-L3H6DQCR.module.min.js +0 -2
- package/dist/chunk-chunk-M337NY6L.module.min.js +0 -1
- package/dist/chunk-chunk-M7VYYHCE.module.min.js +0 -2
- package/dist/chunk-chunk-MC35ILYP.module.min.js +0 -2
- package/dist/chunk-chunk-N72SWNBV.module.min.js +0 -1
- package/dist/chunk-chunk-OBQRFTIL.module.min.js +0 -2
- package/dist/chunk-chunk-QRIBHZYW.module.min.js +0 -1
- package/dist/chunk-chunk-SA3D43RA.module.min.js +0 -2
- package/dist/chunk-chunk-UHSZEB74.module.min.js +0 -1
- package/dist/chunk-chunk-Y6AXCRVO.module.min.js +0 -1
- package/dist/chunk-chunk-ZCNBUZPL.module.min.js +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{validateNetworkData as e,validateObjectData as t}from"./chunk-chunk-JCG72SGW.module.min.js";import{mergeShapeStyle as o,useCustomChartScaffold as n,useFrameImperativeHandle as i,useResolvedSelection as r}from"./chunk-chunk-PLIDPQNG.module.min.js";import{StreamNetworkFrame_default as s,buildRibbonGeometry as a}from"./chunk-chunk-LQBSXO7K.module.min.js";import{buildBaseMetadataProps as l,buildCustomBehaviorProps as c}from"./chunk-chunk-F7WFPD4O.module.min.js";import{mulberry32 as d}from"./chunk-chunk-SIRIJ3DY.module.min.js";import{composeStyleRules as m,makeNodeRuleContext as h}from"./chunk-chunk-EMO5NUGE.module.min.js";import{COLOR_SCHEMES as g,DEFAULT_COLORS as u,DEFAULT_SELECTION_OPACITY as p,DEPTH_PALETTE_COLORS as f,filterSparseArray as b,getColor as y,normalizeTooltip as v,resolveAxisFreeMarginDefaults as k,resolveCategoricalPalette as S,resolveDefaultFill as w,resolveMobileInteraction as C,useChartLegendAndMargin as T,useChartMode as I,useChartSelection as A,useColorScale as M,useLegendInteraction as H,useThemeCategorical as x}from"./chunk-chunk-BFHUYEOS.module.min.js";import{getMin as B}from"./chunk-chunk-JJ2OOIET.module.min.js";import{ChartError as N,SafeRender as O,renderEmptyState as D,renderLoadingState as P}from"./chunk-chunk-ACLDBMRH.module.min.js";import{forwardRef as L,useMemo as E}from"react";import{jsx as W}from"react/jsx-runtime";var R=L(function(e,t){const{nodes:o,edges:i,layout:r,layoutConfig:a,onLayoutError:d,nodeIDAccessor:m="id",sourceAccessor:h="source",targetAccessor:g="target",margin:u,className:p,colorBy:f,colorScheme:y,selection:v,linkedHover:k,onObservation:S,onClick:w,chartId:T,annotations:I,autoPlaceAnnotations:M,frameProps:H={}}=e,{frameRef:x,resolved:B,normalizedMargin:N}=n({imperativeRef:t,imperativeVariant:"network",margin:u,width:e.width,height:e.height,enableHover:e.enableHover,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,mode:e.mode,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),L=E(()=>b(o),[o]),R=E(()=>b(i),[i]),F=E(()=>void 0===o&&void 0===i?void 0:[...L,...R],[i,o,R,L]),z=C(e.mobileInteraction,{mode:e.mode,width:B.width,mobileSemantics:e.mobileSemantics}),{customHoverBehavior:j,customClickBehavior:$,activeSelectionHook:_}=A({selection:v,linkedHover:k,fallbackFields:"string"==typeof f?[f]:[],onObservation:S,onClick:w,chartType:"NetworkCustomChart",chartId:T,colorByField:"string"==typeof f?f:void 0,mobileInteraction:z}),G=E(()=>_?.isActive?{isActive:!0,predicate:_.predicate}:null,[_?.isActive,_?.predicate]),{width:q,height:X,enableHover:J,title:Y,description:K,summary:Q,accessibleTable:U}=B,Z=P(e.loading,q,X,e.loadingContent),V=Z?null:D(F,q,X,e.emptyContent);if(Z||V)return Z||V;const ee={chartType:"force",...null!=o&&{nodes:L},...null!=i&&{edges:R},customNetworkLayout:r,layoutConfig:a,onLayoutError:d,nodeIDAccessor:m,sourceAccessor:h,targetAccessor:g,colorBy:f,colorScheme:y,size:[q,X],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:N,enableHover:J,...l({title:Y,description:K,summary:Q,accessibleTable:U,className:p,animate:e.animate,autoPlaceAnnotations:M}),...c({linkedHover:k,selection:v,onObservation:S,onClick:w,mobileInteraction:z,customHoverBehavior:j,customClickBehavior:$,linkedHoverInClickPredicate:!1}),layoutSelection:G,...null!=I&&{annotations:I},...H};return W(O,{componentName:"NetworkCustomChart",width:q,height:X,children:W(s,{ref:x,...ee})})});R.displayName="NetworkCustomChart";import{useMemo as F,forwardRef as z,useRef as j}from"react";import{useMemo as $}from"react";function _(e,t){if(!e)return[];const o=[],n=e=>{o.push(e);const i="function"==typeof t?t(e):e[t];i&&Array.isArray(i)&&i.forEach(n)};return n(e),o}function G(e,t,o,n){if(e&&e.length>0)return e;const i=new Set;return t.forEach(e=>{const t="function"==typeof o?o(e):e[o],r="function"==typeof n?n(e):e[n];i.add(t),i.add(r)}),Array.from(i).map(e=>({id:e}))}function q(e){return"function"==typeof e?e:t=>t[e]||1}function X({edgeColorBy:e,colorBy:t,colorScale:o,nodeStyleFn:n,edgeOpacity:i,baseStyle:r={}}){return s=>{const a={fillOpacity:i,...r};if("function"==typeof e)a.fill=e(s);else if("source"===e){const e="object"==typeof s.source?s.source:null;t&&e?a.fill=y(e.data||e,t,o):e&&(a.fill=n(e,e.index).fill)}else if("target"===e){const e="object"==typeof s.target?s.target:null;t&&e?a.fill=y(e.data||e,t,o):e&&(a.fill=n(e,e.index).fill)}else"gradient"===e&&(a.fill="#999",a.fillOpacity=.7*i);return a}}function J(e){const{nodes:t,edges:o,inferNodes:n=!0,sourceAccessor:i="source",targetAccessor:r="target",colorBy:s,colorScheme:a,showLegend:l,legendPosition:c,legendInteraction:d,selection:m,linkedHover:h,onObservation:g,onClick:p,mobileInteraction:f,mobileSemantics:y,chartType:v,chartId:k,marginDefaults:w,userMargin:I,width:B,height:N,loading:O,loadingContent:L,emptyContent:E,emptyDataKey:W="edges"}=e,R=$(()=>b(o),[o]),F=$(()=>b(t),[t]),z=P(O,B,N,L),j=z?null:D("nodes"===W?void 0===t?void 0:F:void 0===o?void 0:R,B,N,E),_=$(()=>n?G(F,R,i,r):F,[n,F,R,i,r]),q=M(_,s,a),X=x(),J=$(()=>Array.isArray(a)&&a.length>0?a:[...S(a,X,u)],[a,X]),Y=$(()=>{if(!s)return[];const e=new Set;for(const t of _){const o="function"==typeof s?s(t):t[s];null!=o&&e.add(o+"")}return Array.from(e)},[_,s]),K=H(d,s,Y),{legend:Q,margin:U,legendPosition:Z}=T({data:_,colorBy:s,colorScale:q,showLegend:l,legendPosition:c,userMargin:I,defaults:w,categories:Y}),V=$(()=>C(f,{width:B,mobileSemantics:y}),[f,B,y]),ee=A({selection:m,linkedHover:h,fallbackFields:s?["string"==typeof s?s:""]:[],unwrapData:!0,onObservation:g,onClick:p,mobileInteraction:V,chartType:v,chartId:k}),{customHoverBehavior:te,customClickBehavior:oe,activeSelectionHook:ne,hoverSelectionHook:ie,crosshairSourceId:re}=ee;return{safeNodes:_,safeEdges:R,colorScale:q,effectivePalette:J,themeCategorical:X,allCategories:Y,legendState:K,legend:Q,margin:U,legendPosition:Z,mobileInteraction:V,customHoverBehavior:te,customClickBehavior:oe,activeSelectionHook:ne,hoverSelectionHook:ie,crosshairSourceId:re,loadingEl:z,emptyEl:j}}import{jsx as Y}from"react/jsx-runtime";var K=z(function(t,n){const r=j(null);i(n,{variant:"network",frameRef:r});const a=I(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLegend:t.showLegend,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,responsiveRules:t.responsiveRules},{width:600,height:600}),{nodes:l,edges:d,margin:g,className:u,nodeIdAccessor:p,nodeIDAccessor:f,sourceAccessor:b="source",targetAccessor:k="target",nodeLabel:S,colorBy:C,colorScheme:T,styleRules:A,nodeSize:M=8,nodeSizeRange:H=[5,20],edgeWidth:x=1,edgeColor:B="#999",edgeOpacity:D=.6,iterations:P=300,forceStrength:L=.1,layoutExecution:E="auto",layoutLoadingContent:W,onLayoutStateChange:R,tooltip:z,frameProps:$={},onObservation:_,onClick:G,chartId:q,selection:X,linkedHover:K,loading:Q,loadingContent:U,emptyContent:Z,legendInteraction:V,legendPosition:ee,stroke:te,strokeWidth:oe,opacity:ne}=t,ie=p??f??"id",{width:re,height:se,enableHover:ae,showLegend:le,showLabels:ce=!1,title:de,description:me,summary:he,accessibleTable:ge}=a,ue=J({nodes:l,edges:d,inferNodes:!1,nodeIdAccessor:ie,sourceAccessor:b,targetAccessor:k,colorBy:C,colorScheme:T,showLegend:le,legendPosition:ee,legendInteraction:V,selection:X,linkedHover:K,onObservation:_,onClick:G,mobileInteraction:a.mobileInteraction,mobileSemantics:a.mobileSemantics,chartType:"ForceDirectedGraph",chartId:q,marginDefaults:a.marginDefaults,userMargin:g,width:re,height:se,loading:Q,loadingContent:U,emptyContent:Z,emptyDataKey:"nodes"}),pe=F(()=>new Map,[]),fe=F(()=>e=>{const t={};return t.fill=C?y(e.data||e,C,ue.colorScale):w(void 0,ue.themeCategorical,T,void 0,pe),"number"==typeof M&&(t.r=M),t},[C,ue.colorScale,M,ue.themeCategorical,T,pe]),be=F(()=>h(C,"number"==typeof M?void 0:M),[C,M]),ye=F(()=>o(m(fe,A,be,e=>e.data||e),{stroke:te,strokeWidth:oe,opacity:ne}),[fe,A,be,te,oe,ne]),ve=F(()=>e=>{const t=e.data||e;let o;if("number"==typeof x)o=x;else if("function"==typeof x)o=x(t);else{const e=t[x],n="number"==typeof e?e:Number(e);o=Number.isFinite(n)&&n>0?n:1}return{stroke:B,strokeWidth:o,opacity:D}},[x,B,D]),ke=F(()=>o(ve,{stroke:te,strokeWidth:oe,opacity:ne}),[ve,te,oe,ne]),Se=F(()=>{if(ce&&S)return"function"==typeof S?S:e=>e.data?.[S]??e[S]??e.id},[ce,S]),we=e({componentName:"ForceDirectedGraph",nodes:l,edges:d,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:ie}});return we?Y(N,{componentName:"ForceDirectedGraph",message:we,width:re,height:se}):ue.loadingEl?ue.loadingEl:ue.emptyEl?ue.emptyEl:Y(O,{componentName:"ForceDirectedGraph",width:re,height:se,children:Y(s,{ref:r,chartType:"force",...null!=l&&{nodes:ue.safeNodes},...null!=d&&{edges:ue.safeEdges},size:[re,se],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ue.margin,nodeIDAccessor:ie,sourceAccessor:b,targetAccessor:k,iterations:P,forceStrength:L,layoutExecution:E,layoutLoadingContent:W,onLayoutStateChange:R,nodeStyle:ye,edgeStyle:ke,colorBy:C,colorScheme:ue.effectivePalette,nodeSize:M,nodeSizeRange:H,nodeLabel:Se,showLabels:ce,enableHover:ae,tooltipContent:!1===z?()=>null:v(z)||void 0,...c({linkedHover:K,selection:X,onObservation:_,onClick:G,mobileInteraction:ue.mobileInteraction,customHoverBehavior:ue.customHoverBehavior,customClickBehavior:ue.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:ue.legend,legendPosition:ue.legendPosition,...V&&"none"!==V&&{legendHoverBehavior:ue.legendState.onLegendHover,legendClickBehavior:ue.legendState.onLegendClick,legendHighlightedCategory:ue.legendState.highlightedCategory,legendIsolatedCategories:ue.legendState.isolatedCategories},className:u,title:de,description:me,summary:he,accessibleTable:ge,...null!=t.animate&&{animate:t.animate},...$})})});K.displayName="ForceDirectedGraph";import{useMemo as Q,forwardRef as U,useRef as Z}from"react";import{jsx as V}from"react/jsx-runtime";var ee=U(function(t,n){const r=Z(null);i(n,{variant:"network",frameRef:r,overrides:{getData:()=>r.current?.getTopology()?.edges?.map(e=>e.data)??[]}});const a=I(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,responsiveRules:t.responsiveRules},{width:600,height:600}),{nodes:l,edges:d,margin:p,className:f,sourceAccessor:b="source",targetAccessor:k="target",valueAccessor:S="value",nodeIdAccessor:C="id",colorBy:T,colorScheme:A,styleRules:M,edgeColorBy:H="source",padAngle:x=.01,groupWidth:B=20,sortGroups:D,nodeLabel:P,edgeOpacity:L=.5,tooltip:E,frameProps:W={},onObservation:R,onClick:F,chartId:z,selection:j,linkedHover:$,loading:_,loadingContent:G,emptyContent:q,legendInteraction:Y,stroke:K,strokeWidth:U,opacity:ee}=t,{width:te,height:oe,enableHover:ne,showLabels:ie=!0,title:re,description:se,summary:ae,accessibleTable:le}=a,ce=J({nodes:l,edges:d,inferNodes:!0,nodeIdAccessor:C,sourceAccessor:b,targetAccessor:k,colorBy:T,colorScheme:A,showLegend:!1,legendInteraction:Y,selection:j,linkedHover:$,onObservation:R,onClick:F,mobileInteraction:a.mobileInteraction,mobileSemantics:a.mobileSemantics,chartType:"ChordDiagram",chartId:z,marginDefaults:a.marginDefaults,userMargin:p,width:te,height:oe,loading:_,loadingContent:G,emptyContent:q}),de=Q(()=>new Map,[]),me=Q(()=>new Map,[]),he=ce.safeNodes.length>0,ge=Q(()=>{if(he)return(e,t)=>{const o={stroke:"black",strokeWidth:1};if(T)o.fill=y(e.data||e,T,ce.colorScale);else{const n=Array.isArray(A)?A:g[A]||u,i=Array.isArray(n)?n:u,r=(e.id??e.data?.[C]??"")+"";me.has(r)||me.set(r,me.size);const s=e.index??t??me.get(r);o.fill=i[s%i.length]}return o}},[he,T,ce.colorScale,A,C,me]),ue=Q(()=>h(T),[T]),pe=Q(()=>{if(ge||M&&M.length>0)return o(m(ge,M,ue,e=>e.data||e),{stroke:K,strokeWidth:U,opacity:ee})},[ge,M,ue,K,U,ee]),fe=Q(()=>{if(he)return X({edgeColorBy:H,colorBy:T,colorScale:ce.colorScale,nodeStyleFn:pe||(e=>({fill:w(void 0,ce.themeCategorical,A,void 0,de)})),edgeOpacity:L,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:L}})},[he,H,T,ce.colorScale,pe,L,ce.themeCategorical,A,de]),be=Q(()=>fe?o(fe,{stroke:K,strokeWidth:U,opacity:ee}):void 0,[fe,K,U,ee]),ye=Q(()=>{if(!ie)return;const e=P||C;return"function"==typeof e?e:t=>t.data?.[e]??t[e]??t.id},[ie,P,C]),ve=e({componentName:"ChordDiagram",edges:d,edgesRequired:!0});return ve?V(N,{componentName:"ChordDiagram",message:ve,width:te,height:oe}):ce.loadingEl?ce.loadingEl:ce.emptyEl?ce.emptyEl:V(O,{componentName:"ChordDiagram",width:te,height:oe,children:V(s,{ref:r,chartType:"chord",...ce.safeNodes.length>0&&{nodes:ce.safeNodes},...null!=d&&{edges:ce.safeEdges},size:[te,oe],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ce.margin,nodeIDAccessor:C,sourceAccessor:b,targetAccessor:k,valueAccessor:S,padAngle:x,groupWidth:B,sortGroups:D,nodeStyle:pe,edgeStyle:be,colorBy:T,colorScheme:ce.effectivePalette,edgeColorBy:H,edgeOpacity:L,nodeLabel:ye,showLabels:ie,enableHover:ne,tooltipContent:!1===E?()=>null:v(E)||void 0,...c({linkedHover:$,selection:j,onObservation:R,onClick:F,mobileInteraction:ce.mobileInteraction,customHoverBehavior:ce.customHoverBehavior,customClickBehavior:ce.customClickBehavior,linkedHoverInClickPredicate:!1}),...Y&&"none"!==Y&&{legendHoverBehavior:ce.legendState.onLegendHover,legendClickBehavior:ce.legendState.onLegendClick,legendHighlightedCategory:ce.legendState.highlightedCategory,legendIsolatedCategories:ce.legendState.isolatedCategories},className:f,title:re,description:se,summary:ae,accessibleTable:le,...null!=t.animate&&{animate:t.animate},...W})})});ee.displayName="ChordDiagram";import{useMemo as te,forwardRef as oe,useRef as ne}from"react";import{jsx as ie}from"react/jsx-runtime";var re=oe(function(t,n){const r=ne(null);i(n,{variant:"network",frameRef:r,overrides:{getData:()=>r.current?.getTopology()?.edges?.map(e=>e.data)??[]}});const a=I(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,responsiveRules:t.responsiveRules},{width:800,height:600}),{nodes:l,edges:d,margin:g,className:u,sourceAccessor:p="source",targetAccessor:f="target",valueAccessor:b="value",nodeIdAccessor:k="id",colorBy:S,colorScheme:C,styleRules:T,edgeColorBy:A="source",orientation:M="horizontal",nodeAlign:H="justify",nodePaddingRatio:x=.05,nodeWidth:B=15,nodeLabel:D,edgeOpacity:P=.5,edgeSort:L,tooltip:E,frameProps:W={},onObservation:R,onClick:F,chartId:z,selection:j,linkedHover:$,loading:_,loadingContent:G,emptyContent:q,showLegend:Y,legendPosition:K,legendInteraction:Q,stroke:U,strokeWidth:Z,opacity:V}=t,{width:ee,height:oe,enableHover:re,showLabels:se=!0,title:ae,description:le,summary:ce,accessibleTable:de}=a,me=J({nodes:l,edges:d,inferNodes:!0,nodeIdAccessor:k,sourceAccessor:p,targetAccessor:f,colorBy:S,colorScheme:C,showLegend:Y,legendPosition:K,legendInteraction:Q,selection:j,linkedHover:$,onObservation:R,onClick:F,mobileInteraction:a.mobileInteraction,mobileSemantics:a.mobileSemantics,chartType:"SankeyDiagram",chartId:z,marginDefaults:a.marginDefaults,userMargin:g,width:ee,height:oe,loading:_,loadingContent:G,emptyContent:q}),he=te(()=>new Map,[]),ge=te(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=S?y(e.data||e,S,me.colorScale):w(void 0,me.themeCategorical,C,void 0,he),t},[S,me.colorScale,me.themeCategorical,C,he]),ue=te(()=>h(S,b),[S,b]),pe=te(()=>o(m(ge,T,ue,e=>e.data||e),{stroke:U,strokeWidth:Z,opacity:V}),[ge,T,ue,U,Z,V]),fe=te(()=>X({edgeColorBy:A,colorBy:S,colorScale:me.colorScale,nodeStyleFn:pe,edgeOpacity:P,baseStyle:{stroke:"none",strokeWidth:0}}),[A,S,me.colorScale,pe,P]),be=te(()=>o(fe,{stroke:U,strokeWidth:Z,opacity:V}),[fe,U,Z,V]),ye=te(()=>{if(!se)return;const e=D||k;return"function"==typeof e?e:t=>t.data?.[e]??t[e]??t.id},[se,D,k]),ve=e({componentName:"SankeyDiagram",edges:d,edgesRequired:!0});return ve?ie(N,{componentName:"SankeyDiagram",message:ve,width:ee,height:oe}):me.loadingEl?me.loadingEl:me.emptyEl?me.emptyEl:ie(O,{componentName:"SankeyDiagram",width:ee,height:oe,children:ie(s,{ref:r,chartType:"sankey",...me.safeNodes.length>0&&{nodes:me.safeNodes},...null!=d&&{edges:me.safeEdges},size:[ee,oe],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:me.margin,nodeIDAccessor:k,sourceAccessor:p,targetAccessor:f,valueAccessor:b,orientation:M,nodeAlign:H,nodePaddingRatio:x,nodeWidth:B,nodeStyle:pe,edgeStyle:be,colorBy:S,colorScheme:me.effectivePalette,edgeColorBy:A,edgeOpacity:P,edgeSort:L,nodeLabel:ye,showLabels:se,enableHover:re,tooltipContent:!1===E?()=>null:v(E)||void 0,...c({linkedHover:$,selection:j,onObservation:R,onClick:F,mobileInteraction:me.mobileInteraction,customHoverBehavior:me.customHoverBehavior,customClickBehavior:me.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:me.legend,legendPosition:me.legendPosition,...Q&&"none"!==Q&&{legendHoverBehavior:me.legendState.onLegendHover,legendClickBehavior:me.legendState.onLegendClick,legendHighlightedCategory:me.legendState.highlightedCategory,legendIsolatedCategories:me.legendState.isolatedCategories},className:u,title:ae,description:le,summary:ce,accessibleTable:de,...null!=t.animate&&{animate:t.animate},...W})})});function se(e,t,o){const n=[],i=new Set(e.map(e=>e.id)),r=Array.isArray(o)&&2===o.length,s=r&&Number.isFinite(o[0])&&Number.isFinite(o[1]);r&&s&&s&&o[1]>=o[0]||n.push({kind:"invalid-domain"});for(const t of e)null!=t.xExtent&&(Array.isArray(t.xExtent)&&2===t.xExtent.length&&Number.isFinite(t.xExtent[0])&&Number.isFinite(t.xExtent[1])&&t.xExtent[1]>=t.xExtent[0]||n.push({kind:"invalid-node-time",id:t.id}));for(const e of t)i.has(e.source)||n.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),i.has(e.target)||n.push({kind:"missing-node",id:e.id,endpoint:"target",nodeId:e.target}),Number.isFinite(e.startTime)&&Number.isFinite(e.endTime)?(Number.isFinite(e.value)&&e.value>0||n.push({kind:"invalid-value",id:e.id}),e.endTime>e.startTime||n.push({kind:"backward-edge",id:e.id,source:e.source,target:e.target})):n.push({kind:"invalid-edge-time",id:e.id});return n}function ae(e){return"invalid-node-time"===e.kind?`node ${e.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===e.kind?`edge ${e.id} has an invalid startTime or endTime`:"invalid-domain"===e.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===e.kind?`edge ${e.id} must have a positive finite value`:"missing-node"===e.kind?`edge ${e.id} references missing ${e.endpoint} node "${e.nodeId}"`:"backward-edge"===e.kind?`edge ${e.id} (${e.source}->${e.target}) ends before it starts`:e.kind}function le(e,t,o){const n=t.incoming[e.id],i=t.outgoing[e.id],r=[];for(const e of n)r.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:o.get(e.id).targetSide});for(const e of i)r.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:o.get(e.id).sourceSide});const s={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},a=()=>{r.sort((e,t)=>e.time-t.time||(s[e.kind]??99)-(s[t.kind]??99))},l=r.length?B(r.map(e=>e.time)):null,c=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,d=null!=c?c-1:null!=l&&Number.isFinite(l)?l-1:null,m=[...new Set(r.map(e=>e.time))].sort((e,t)=>e-t),h=new Map;for(let e=1;m.length>e;e++)h.set(m[e],m[e-1]);const g=e=>{const t=h.get(e);return null!=t?(t+e)/2:null!=d?d:e};a();const u=[];let p=0,f=0;for(const e of r)if("out"===e.kind){const t=Math.abs(e.delta);let o=t-("top"===e.side?p:f);if(o>0){const t="top"===e.side?"bot":"top",n=Math.min(o,"top"===t?p:f);if(n>0){const i=g(e.time);u.push({time:i,delta:-n,kind:"transfer-out",side:t}),u.push({time:i,delta:+n,kind:"transfer-in",side:e.side}),"top"===t?p-=n:f-=n,"top"===e.side?p+=n:f+=n,o-=n}o>0&&null!==d&&(u.push({time:d,delta:+o,kind:"create",side:e.side}),"top"===e.side?p+=o:f+=o)}"top"===e.side?p-=t:f-=t}else if("in"===e.kind){const t=Math.abs(e.delta);"top"===e.side?p+=t:f+=t}r.push(...u),a();let b=0,y=0,v=0,k=0,S=0;const w=[],C=new Map;for(const e of r){if(w.push({t:e.time,topMass:b,botMass:y}),("in"===e.kind||"out"===e.kind)&&e.edge){const t="top"===e.side?b:y;C.set(e.edge.id,{side:e.side,time:e.time,sideMassBefore:t,sideMassAfter:t+e.delta,kind:e.kind,value:Math.abs(e.delta)})}"top"===e.side?b+=e.delta:y+=e.delta,b+y>v&&(v=b+y),b>k&&(k=b),y>S&&(S=y),w.push({t:e.time,topMass:b,botMass:y})}const T=[];let I=0;for(;w.length>I;){let e=I;for(;w.length>e+1&&w[e+1].t===w[I].t;)e++;T.push(w[I]);for(let t=I+1;e>=t;t++){const e=T[T.length-1];w[t].topMass===e.topMass&&w[t].botMass===e.botMass||T.push(w[t])}I=e+1}const A=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null;let M=null;for(const e of i)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===M||M>e.systemInTime)&&(M=e.systemInTime);let H=null;for(const e of n)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===H||e.systemOutTime>H)&&(H=e.systemOutTime);if(T.length>0){const e=T[T.length-1],t=Math.max(null!=A?A:-1/0,null!=H?H:-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&T.push({t:t,topMass:e.topMass,botMass:e.botMass});const o=T[0],n=Math.min(null!=c?c:1/0,null!=M?M:1/0);Number.isFinite(n)&&o.t>n&&o.topMass+o.botMass>0&&T.unshift({t:n,topMass:o.topMass,botMass:o.botMass})}return{samples:T,peak:v,topPeak:k,botPeak:S,localAttachments:C}}function ce(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function de(e,t){return e.map(e=>({t:ce(e.t,t),topMass:e.topMass,botMass:e.botMass}))}function me(e,t,o){const n=e.value*o;if("out"===e.kind){const i=e.sideMassBefore*o;if("top"===e.side){const e=t-i;return[e,e+n]}const r=t+i;return[r-n,r]}const i=e.sideMassAfter*o;if("top"===e.side){const e=t-i;return[e,e+n]}const r=t+i;return[r-n,r]}function he(e,t){let o=0;for(let n=0;t.length>n;n++)for(let i=n+1;t.length>i;i++){const r=t[n],s=t[i];r.source!==s.source&&r.target!==s.target&&r.source!==s.target&&r.target!==s.source&&(Math.min(r.endTime,s.endTime)>Math.max(r.startTime,s.startTime)&&e[s.source]>e[r.source]!=e[s.target]>e[r.target]&&o++)}return o}function ge(e,t){let o=0;for(const n of t)o+=Math.abs(e[n.source]-e[n.target])*(n.value||1);return o}function ue(e,t){return 1e3*he(e,t)+ge(e,t)}function pe(e,t){return{slots:e.map(e=>({peak:{...e.peak},occupants:e.occupants.slice()})),map:{...t}}}function fe(e,t,o){e.length>8||o.length>40?(function(e,t,o,n=6){const i=e.length;if(1>=i)return;let r=pe(e,t),s=ue(t,o);for(let a=0;n>a;a++){const n=Array(i).fill(0),a=Array(i).fill(0);for(const e of o){const o=t[e.source],i=t[e.target];n[o]+=i*(e.value||1),a[o]+=e.value||1,n[i]+=o*(e.value||1),a[i]+=e.value||1}const l=Array.from({length:i},(e,t)=>t).sort((e,t)=>(a[e]>0?n[e]/a[e]:e)-(a[t]>0?n[t]/a[t]:t)),c=l.map(t=>e[t]),d=new Map;l.forEach((e,t)=>d.set(e,t));for(const e of Object.keys(t))t[e]=d.get(t[e]);e.length=0;for(const t of c)e.push(t);const m=ue(t,o);if(s>m)s=m,r=pe(e,t);else if(m===s)break}!function(e,t,o){e.length=0;for(const t of o.slots)e.push(t);for(const e of Object.keys(t))delete t[e];for(const e of Object.keys(o.map))t[e]=o.map[e]}(e,t,r)}(e,t,o,6),function(e,t,o,n=6){const i=e.length;if(1>=i)return;let r=ue(t,o);for(let s=0;n>s;s++){let n=!1;for(let s=0;i-1>s;s++){const i=e[s];e[s]=e[s+1],e[s+1]=i;for(const e of Object.keys(t))t[e]===s?t[e]=s+1:t[e]===s+1&&(t[e]=s);const a=ue(t,o);if(r>a)r=a,n=!0;else{const o=e[s];e[s]=e[s+1],e[s+1]=o;for(const e of Object.keys(t))t[e]===s?t[e]=s+1:t[e]===s+1&&(t[e]=s)}}if(!n)break}}(e,t,o,6)):function(e,t,o){const n=e.length;if(1>=n)return;const i={...t},r=Object.keys(i),s=Array.from({length:n},(e,t)=>t),a=s.slice(),l={...i};let c=s.slice(),d=1/0;const m=()=>{for(const e of r)l[e]=a[i[e]];const e=ue(l,o);d>e&&(d=e,c=s.slice())},h=(e,t)=>{const o=s[e],n=s[t];s[e]=n,s[t]=o,a[o]=t,a[n]=e};m();const g=Array(n).fill(0);let u=0;for(;n>u;)u>g[u]?(h(u%2==0?0:g[u],u),m(),g[u]++,u=0):(g[u]=0,u++);const p=c.map(t=>e[t]),f=new Map;c.forEach((e,t)=>f.set(e,t));for(const e of Object.keys(t))t[e]=f.get(t[e]);e.length=0;for(const t of p)e.push(t)}(e,t,o)}function be(e,t,o,n,i){const{plotH:r,padding:s,valueScale:a,packing:l,laneOrder:c,lifetimeMode:d="full"}=i,m={},h={};for(const t of e)m[t.id]=o[t.id].topPeak||0,h[t.id]=o[t.id].botPeak||0;const g="half"===d,u={};for(const t of e){const e=Array.isArray(t.xExtent)?t.xExtent[0]:null,o=Array.isArray(t.xExtent)?t.xExtent[1]:null;let i=null!=e&&Number.isFinite(e)?e:1/0,r=null!=o&&Number.isFinite(o)?o:-1/0;for(const e of n.outgoing[t.id]){i>e.startTime&&(i=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&i>e.systemInTime&&(i=e.systemInTime);const t=g?(e.startTime+e.endTime)/2:e.endTime;t>r&&(r=t)}for(const e of n.incoming[t.id]){const t=g?(e.startTime+e.endTime)/2:e.startTime;i>t&&(i=t),e.endTime>r&&(r=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>r&&(r=e.systemOutTime)}u[t.id]={start:Number.isFinite(i)?i:null,end:Number.isFinite(r)?r:null}}const p={},f=[];if("reuse"===l){const o=new Map;for(const t of e)o.set(t.id,0);const i=new Map;for(const t of e)i.set(t.id,0);for(const e of t)i.set(e.target,(i.get(e.target)??0)+1);const r=[];for(const t of e)0===(i.get(t.id)??0)&&r.push(t.id);for(;r.length;){const e=r.shift();for(const t of n.outgoing[e]??[]){const n=(o.get(e)??0)+1;n>(o.get(t.target)??0)&&o.set(t.target,n),i.set(t.target,i.get(t.target)-1),0===i.get(t.target)&&r.push(t.target)}}const s=[...e].filter(e=>null!==u[e.id].start).sort((e,t)=>{const n=o.get(e.id)??0,i=o.get(t.id)??0;return n!==i?n-i:u[e.id].start-u[t.id].start}),a=e.filter(e=>null===u[e.id].start);for(const e of[...s,...a]){const t=u[e.id];let o=-1;for(let e=0;f.length>e;e++){const n=f[e].occupants[f[e].occupants.length-1];if(null===t.start||void 0===n||t.start>=n.end){o=e;break}}-1===o&&(f.push({occupants:[],peak:{topPeak:0,botPeak:0}}),o=f.length-1),f[o].occupants.push({id:e.id,end:t?.end??-1/0}),f[o].peak.topPeak=Math.max(f[o].peak.topPeak,m[e.id]),f[o].peak.botPeak=Math.max(f[o].peak.botPeak,h[e.id]),p[e.id]=o}}else e.forEach((e,t)=>{f.push({occupants:[{id:e.id,end:u[e.id]?.end??-1/0}],peak:{topPeak:m[e.id],botPeak:h[e.id]}}),p[e.id]=t});let b=null,y=null,v=null,k=null;const S=()=>{b=he(p,t),v=ge(p,t)},w=()=>{y=he(p,t),k=ge(p,t)};"crossing-min"===c?(S(),fe(f,p,t),w()):"inside-out"===c?(S(),function(e,t){const o=e.length;if(1>=o)return;const n=e=>e.peak.topPeak+e.peak.botPeak,i=e.map((e,t)=>({slot:e,idx:t})).sort((e,t)=>n(t.slot)-n(e.slot)),r=Array(o),s=Math.floor((o-1)/2);r[s]=i[0].idx;let a=s-1,l=s+1;for(let e=1;i.length>e;e++)e%2==1&&o>l||0>a?r[l++]=i[e].idx:r[a--]=i[e].idx;const c=r.map(t=>e[t]),d=new Map;r.forEach((e,t)=>d.set(e,t));for(const e of Object.keys(t))t[e]=d.get(t[e]);e.length=0;for(const t of c)e.push(t)}(f,p),w()):"crossing-min+inside-out"===c&&(S(),fe(f,p,t),function(e,t,o){const n=e.length;if(1>=n)return;const i=e.map(e=>{return{slot:e,size:(t=e,t.peak.topPeak+t.peak.botPeak)};var t}).sort((e,t)=>t.size-e.size),r=Math.floor((n-1)/2);let s=ue(t,o);for(const{slot:a}of i){const i=e.indexOf(a);if(0>i)continue;const l=r;if(i===l)continue;const c=e[i];e.splice(i,1),e.splice(l,0,c);const d=new Map;for(let e=0;n>e;e++)d.set(e,e);if(l>i){for(let e=i+1;l>=e;e++)d.set(e,e-1);d.set(i,l)}else{for(let e=l;i>e;e++)d.set(e,e+1);d.set(i,l)}for(const e of Object.keys(t))t[e]=d.get(t[e]);const m=ue(t,o);if(m>s){const o=e[l];e.splice(l,1),e.splice(i,0,o);const r=new Map;for(let e=0;n>e;e++)r.set(e,e);if(i>l){for(let e=l+1;i>=e;e++)r.set(e,e-1);r.set(l,i)}else{for(let e=i;l>e;e++)r.set(e,e+1);r.set(l,i)}for(const e of Object.keys(t))t[e]=r.get(t[e])}else s=m}}(f,p,t),w());const C=f.map(e=>{const t=new Map;for(const n of e.occupants){const e=o[n.id];if(e)for(const o of e.samples){const e=t.get(o.t)||{top:0,bot:0};t.set(o.t,{top:Math.max(e.top,o.topMass),bot:Math.max(e.bot,o.botMass)})}}return[...t.entries()].sort((e,t)=>e[0]-t[0])}),T=(e,t)=>{let o={top:0,bot:0};for(const[n,i]of e){if(n>t)break;o=i}return o},I=[];for(let e=0;f.length-1>e;e++){const t=C[e],o=C[e+1],n=new Set([...t.map(e=>e[0]),...o.map(e=>e[0])]);let i=0;for(const e of n){const n=T(t,e),r=T(o,e);n.bot+r.top>i&&(i=n.bot+r.top)}I.push(i)}const A=[];let M=s+(f[0]?.peak.topPeak??0)*a;f.length>0&&A.push(M);for(let e=1;f.length>e;e++)M+=I[e-1]*a+s,A.push(M);if(f.length>0&&(M+=f[f.length-1].peak.botPeak*a+s),M>r){const e=r/M;for(let t=0;A.length>t;t++)A[t]*=e}const H=0===f.length?0:f[0].peak.topPeak+I.reduce((e,t)=>e+t,0)+f[f.length-1].peak.botPeak,x={};for(const t of e)x[t.id]=A[p[t.id]];return{effectiveSlotsHeight:H,centerlines:x,laneLifetime:u,slots:f,slotByNode:p,slotCenter:A,crossingsBefore:b,crossingsAfter:y,lengthBefore:v,lengthAfter:k}}re.displayName="SankeyDiagram";import{useMemo as ye,useState as ve,useRef as ke,useCallback as Se}from"react";import{scaleTime as we}from"d3-scale";import{forwardRef as Ce}from"react";var Te=e=>{const{bands:t=[],ribbons:o=[],showLabels:n=!0}=e.config,i=[];for(const e of o)i.push({type:"bezier",pathD:e.pathD,...e.bezier&&{bezierCache:e.bezier},style:{fill:e.fill,opacity:e.opacity,stroke:"none"},datum:{__kind:"ribbon",data:e.rawDatum,id:e.id}});for(const e of t)if(e.gradientStubs)for(let t=0;e.gradientStubs.length>t;t++){const o=e.gradientStubs[t];i.push({type:"bezier",pathD:o.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:o.x0,x1:o.x1,from:o.from,to:o.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${t}`}})}for(const e of t)i.push({type:"bezier",pathD:e.pathD,style:{...e.gradientStubs&&e.gradientStubs.length>0?{fill:"none"}:{fill:e.fill,fillOpacity:.86},stroke:e.stroke??e.fill,strokeWidth:e.strokeWidth??.5},datum:{__kind:"band",data:e.rawDatum,id:e.id}});const r=n?t.map(e=>({x:e.labelX,y:e.labelY,text:e.labelText,anchor:"end",baseline:"middle",fontSize:11,fontWeight:600})):[];return{sceneNodes:t.map(e=>({type:"circle",id:e.id,cx:-1e4,cy:-1e4,r:0,style:{fill:e.fill},datum:{__kind:"band",data:e.rawDatum,id:e.id}})),sceneEdges:i,labels:r}};function Ie(e){return"object"==typeof e&&null!==e&&"__kind"in e&&("band"===e.__kind||"ribbon"===e.__kind)}import{Fragment as Ae,jsx as Me,jsxs as He}from"react/jsx-runtime";function xe(e){return null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime()}function Be(e,t){return"function"==typeof e?e(t):t[e]}var Ne=Ce(function(e,t){const{nodes:o,edges:n,domain:r,axisTicks:l=[],nodeIdAccessor:c="id",sourceAccessor:d="source",targetAccessor:m="target",valueAccessor:h="value",startTimeAccessor:g="startTime",endTimeAccessor:u="endTime",systemInTimeAccessor:p,systemOutTimeAccessor:f,xExtentAccessor:k="xExtent",edgeIdAccessor:S="id",colorBy:w,colorScheme:C,showLegend:T,legendPosition:I="right",pairing:A="temporal",packing:M="reuse",laneOrder:H="crossing-min",ribbonLane:x="both",lifetimeMode:B="half",showLaneRails:N=!1,showQualityReadout:O=!1,showLabels:D=!0,width:P=600,height:L=400,margin:E,title:W,description:R,summary:F,accessibleTable:z,responsiveWidth:j,responsiveHeight:$,loading:_,loadingContent:q,emptyContent:X,edgeOpacity:Y=.35,timeFormat:K,valueFormat:Q,tooltip:U,enableHover:Z=!0,onObservation:V,onClick:ee,showParticles:te=!1,particleStyle:oe,chartId:ne,frameProps:ie={}}=e,[re,he]=ve([]),[ge,ue]=ve([]),pe=ke(re),fe=ke(ge);pe.current=re,fe.current=ge;const Ce=Se(e=>{pe.current=e,he(e)},[]),Ne=Se(e=>{fe.current=e,ue(e)},[]),Oe=void 0!==n,De=b(Oe?n:re),Pe=ye(()=>{const e=b(o??[]),t=ge;if(0===e.length&&0===t.length)return G([],De,d,m);const n=new Set,i=[];for(const t of e){const e=Be(c,t)+"";n.has(e)||(n.add(e),i.push(t))}for(const e of t){const t=Be(c,e)+"";n.has(t)||(n.add(t),i.push(e))}const r=G([],De,d,m);for(const e of r)n.has(e.id)||(n.add(e.id),i.push(e));return i},[o,ge,De,c,d,m]),Le=ke(null),Ee=Se((e,t)=>{const o=Be(S,e);return null!=o?o+"":`${Be(d,e)}-${Be(m,e)}-${t}`},[S,d,m]),We=Se(e=>{if(null==e)return!1;const t=e;return null!=Be(d,t)&&null!=Be(m,t)},[d,m]);i(t,{variant:"network",frameRef:Le,overrides:{push(e){if(We(e)){if(Oe)return void console.warn("ProcessSankey.push: edge ignored — `edges` prop is controlled.");Ce([...pe.current,e])}else Ne([...fe.current,e])},pushMany(e){const t=[],o=[];for(const n of e)We(n)?t.push(n):o.push(n);t.length>0&&(Oe?console.warn("ProcessSankey.pushMany: edges ignored — `edges` prop is controlled."):Ce([...pe.current,...t])),o.length>0&&Ne([...fe.current,...o])},remove(e){const t=new Set(Array.isArray(e)?e:[e]),o=[];if(!Oe){const e=pe.current,n=[];for(let i=0;e.length>i;i++){const r=e[i];t.has(Ee(r,i))?o.push(r):n.push(r)}n.length!==e.length&&Ce(n)}const n=fe.current,i=[];for(const e of n){const n=Be(c,e)+"";t.has(n)?o.push(e):i.push(e)}return i.length!==n.length&&Ne(i),o},update(e,t){const o=new Set(Array.isArray(e)?e:[e]),n=[];if(!Oe){let e=!1;const i=pe.current.map((i,r)=>o.has(Ee(i,r))?(n.push(i),e=!0,t(i)):i);e&&Ce(i)}let i=!1;const r=fe.current.map(e=>{const r=Be(c,e)+"";return o.has(r)?(n.push(e),i=!0,t(e)):e});return i&&Ne(r),n},clear(){Oe||Ce([]),Ne([]),Le.current?.clear()},getData:()=>De??[],getScales:()=>null}});const Re=Ee,Fe=Se(e=>Be(c,e)+"",[c]),{nodes:ze,edges:je,domain:$e,rawNodeById:_e,rawEdgeById:Ge}=ye(()=>{const e=(Pe??[]).map(e=>{const t={id:Fe(e),__raw:e},o=k?Be(k,e):null;if(Array.isArray(o)&&2===o.length){const e=xe(o[0]),n=xe(o[1]);Number.isFinite(e)&&Number.isFinite(n)&&(t.xExtent=[e,n])}return t}),t=(De??[]).map((e,t)=>{const o={id:Re(e,t),source:Be(d,e)+"",target:Be(m,e)+"",value:Number(Be(h,e)),startTime:xe(Be(g,e)),endTime:xe(Be(u,e)),__raw:e};if(p){const t=xe(Be(p,e));Number.isFinite(t)&&(o.systemInTime=t)}if(f){const t=xe(Be(f,e));Number.isFinite(t)&&(o.systemOutTime=t)}return o}),o=[xe(r[0]),xe(r[1])],n=new Map;for(const t of e)null!=t.__raw&&n.set(t.id,t.__raw);const i=new Map;for(const e of t)null!=e.__raw&&i.set(e.id,e.__raw);return{nodes:e,edges:t,domain:o,rawNodeById:n,rawEdgeById:i}},[Pe,De,r,Fe,Re,k,d,m,h,g,u,p,f]),qe=J({nodes:Pe,edges:De,inferNodes:!1,nodeIdAccessor:c,sourceAccessor:d,targetAccessor:m,colorBy:w,colorScheme:C,showLegend:!1,legendPosition:I,selection:void 0,linkedHover:void 0,onObservation:V,onClick:ee,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,chartType:"ProcessSankey",chartId:ne,marginDefaults:{top:30,right:80,bottom:40,left:80},userMargin:E,width:P,height:L,loading:_,loadingContent:q,emptyContent:X}),Xe=(T??!!w)&&!!w,Je=Se(e=>null!=E&&("number"==typeof E||null!=E[e]),[E]),Ye=ye(()=>{const e={...qe.margin};return Xe&&("right"===I&&!Je("right")&&140>e.right?e.right=140:"bottom"===I&&!Je("bottom")&&80>e.bottom&&(e.bottom=80)),e},[qe.margin,Xe,I,Je]),Ke=P-Ye.left-Ye.right,Qe=L-Ye.top-Ye.bottom,Ue=ye(()=>se(ze,je,$e),[ze,je,$e]),Ze=ye(()=>Ue.length>0?null:function(e,t,o){const{plotH:n,pairing:i="temporal",packing:r="reuse",laneOrder:s="crossing-min",lifetimeMode:a="half"}=o,l=function(e,t){const o={},n={};for(const t of e)o[t.id]=[],n[t.id]=[];for(const e of t)n[e.source]&&n[e.source].push(e),o[e.target]&&o[e.target].push(e);return{incoming:o,outgoing:n}}(e,t),c=function(e,t,o,n="value"){const i="temporal"===n?(e,t)=>e.endTime-t.endTime:(e,t)=>t.value-e.value,r="temporal"===n?(e,t)=>e.startTime-t.startTime:(e,t)=>t.value-e.value,s=new Map;for(const e of t)s.set(e.id,{});const a=(e,t)=>{const o=new Map;for(const n of e){const e=n[t];o.has(e)||o.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const i=o.get(e);i.edges.push(n),i.total+=n.value,i.earliestStart=Math.min(i.earliestStart,n.startTime),i.latestEnd=Math.max(i.latestEnd,n.endTime)}const s=[...o.values()];s.sort("temporal"===n?(e,o)=>"target"===t?e.earliestStart-o.earliestStart:e.latestEnd-o.latestEnd:(e,t)=>t.total-e.total);for(const e of s)e.edges.sort("target"===t?r:i);return s};for(const t of e){const e=o.outgoing[t.id],n=o.incoming[t.id];if(0===n.length)a(e,"target").forEach((e,t)=>{const o=t%2==0?"top":"bot";for(const t of e.edges)s.get(t.id).sourceSide=o});else if(0===e.length)a(n,"source").forEach((e,t)=>{const o=t%2==0?"top":"bot";for(const t of e.edges)s.get(t.id).targetSide=o});else{const t=a(n,"source"),o=a(e,"target"),i=Math.max(t.length,o.length);for(let e=0;i>e;e++){const n=e%2==0?"top":"bot";if(t[e])for(const o of t[e].edges)s.get(o.id).targetSide=n;if(o[e])for(const t of o[e].edges)s.get(t.id).sourceSide=n}}}return s}(e,t,l,i);let d={};for(const t of e)d[t.id]=le(t,l,c);const m=be(e,t,d,l,{plotH:n,padding:12,valueScale:1,packing:r,laneOrder:s,lifetimeMode:a}),h=new Set;for(const e of t){const t=m.slotByNode[e.source],o=m.slotByNode[e.target];if(void 0===t||void 0===o)continue;const n=c.get(e.id);t!==o?t>o?(n.sourceSide="top",n.targetSide="bot"):(n.sourceSide="bot",n.targetSide="top"):(h.add(e.id),n.sourceSide="bot",n.targetSide="bot")}for(const t of e){const e=l.outgoing[t.id],o=l.incoming[t.id],n=new Set(e.map(e=>c.get(e.id).sourceSide)),i=new Set(o.map(e=>c.get(e.id).targetSide));if(1===n.size&&o.length>0){const e=[...n][0];for(const t of o)m.slotByNode[t.source]===m.slotByNode[t.target]&&(c.get(t.id).targetSide=e)}if(1===i.size&&e.length>0){const t=[...i][0];for(const o of e)m.slotByNode[o.source]===m.slotByNode[o.target]&&(c.get(o.id).sourceSide=t)}}for(const t of e){const e=l.incoming[t.id],o=l.outgoing[t.id];if(0===e.length||0===o.length)continue;const n=()=>{const t={inTop:0,inBot:0,outTop:0,outBot:0};for(const o of e)"top"===c.get(o.id).targetSide?t.inTop+=o.value:t.inBot+=o.value;for(const e of o)"top"===c.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},i=(e,t)=>{const i=n(),r="top"===e?i.outTop-i.inTop:i.outBot-i.inBot,s="top"===t?i.inTop-i.outTop:i.inBot-i.outBot;if(0>=r||0>=s)return!1;const a=Math.min(r,s),l=o.filter(t=>!h.has(t.id)&&c.get(t.id).sourceSide===e&&a>=t.value).sort((e,t)=>t.value-e.value);return 0!==l.length&&(c.get(l[0].id).sourceSide=t,!0)};let r=o.length+1;for(;r-- >0&&(i("top","bot")||i("bot","top")););}d={};for(const t of e)d[t.id]=le(t,l,c);const g=be(e,t,d,l,{plotH:n,padding:12,valueScale:1,packing:r,laneOrder:s,lifetimeMode:a}),u=g.effectiveSlotsHeight??g.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),p=Math.min(12,.35*n/Math.max(g.slots.length+1,1)),f=u>0?Math.max(0,(n-p*(g.slots.length+1))/u):1,b=be(e,t,d,l,{plotH:n,padding:p,valueScale:f,packing:r,laneOrder:s,lifetimeMode:a});return{nodeData:d,sides:c,valueScale:f,padding:p,compressedPadding:12>p,centerlines:b.centerlines,laneLifetime:b.laneLifetime,slots:b.slots,slotByNode:b.slotByNode,crossingsBefore:b.crossingsBefore,crossingsAfter:b.crossingsAfter,lengthBefore:b.lengthBefore,lengthAfter:b.lengthAfter}}(ze,je,{plotH:Qe,pairing:A,packing:M,laneOrder:H,lifetimeMode:B}),[Ue,ze,je,Qe,A,M,H,B]),Ve=ye(()=>we().domain($e).range([0,Ke]),[$e,Ke]),et=Se((e,t)=>{if(w&&Pe){const t=_e.get(e);if(t)return y(t,w,qe.colorScale)}return qe.effectivePalette[t%qe.effectivePalette.length]||"#475569"},[w,Pe,_e,qe.colorScale,qe.effectivePalette]),tt=ye(()=>{const e=new Map;return ze.forEach((t,o)=>e.set(t.id,o)),e},[ze]),ot=ye(()=>{if(!Ze)return{bands:[],ribbons:[]};const{centerlines:e,nodeData:t,valueScale:o}=Ze,n=[],i=[];return ze.forEach((i,r)=>{const s=t[i.id];if(!s||0===s.samples.length)return;const a=function(e,t,o,n,i){if(0===e.length)return null;const r=de(e,i),s=e=>t-r[e].topMass*o,a=e=>t+r[e].botMass*o;let l=`M${n(r[0].t)},${s(0)}`;for(let e=1;r.length>e;e++)l+=` L${n(r[e].t)},${s(e)}`;l+=` L${n(r[r.length-1].t)},${a(r.length-1)}`;for(let e=r.length-2;e>=0;e--)l+=` L${n(r[e].t)},${a(e)}`;return l+" Z"}(s.samples,e[i.id],o,Ve,$e);if(!a)return;const l=de(s.samples,$e),c=l.find(e=>e.topMass+e.botMass>0)||l[0],d=e[i.id]+(c.botMass-c.topMass)*o/2,m=et(i.id,r),h=_e.get(i.id)??i,g=function(e,t,o,n,i){const r=o.nodeData[e];if(!r||0===r.samples.length)return[];const s=o.valueScale,a=o.centerlines[e],l=de(r.samples,i),c=l.find(e=>e.topMass+e.botMass>0)||l[0],d=[...l].reverse().find(e=>e.topMass+e.botMass>0)||l[l.length-1],m=n(c.t),h=n(d.t),g=e=>n(ce(e,i)),u=[],p=(e,t,o,n)=>`M${e},${t} L${o},${t} L${o},${n} L${e},${n} Z`;for(const o of t){if(o.source===e&&null!=o.systemInTime&&Number.isFinite(o.systemInTime)){const e=r.localAttachments.get(o.id);if(e&&"out"===e.kind&&o.startTime>o.systemInTime){const t=g(o.systemInTime),n=g(o.startTime),i=t-20,r=Math.max(m,i);if(n>r){const[o,l]=me(e,a,s);u.push({pathD:p(r,o,n,l),x0:i,x1:t,from:0,to:1})}}}if(o.target===e&&null!=o.systemOutTime&&Number.isFinite(o.systemOutTime)){const e=r.localAttachments.get(o.id);if(e&&"in"===e.kind&&o.systemOutTime>o.endTime){const t=g(o.systemOutTime),n=g(o.endTime),i=t+20,r=Math.min(h,i);if(r>n){const[o,l]=me(e,a,s);u.push({pathD:p(n,o,r,l),x0:t,x1:i,from:1,to:0})}}}}return u}(i.id,je,Ze,Ve,$e);n.push({id:i.id,pathD:a,fill:m,stroke:m,strokeWidth:.5,...g.length>0&&{gradientStubs:g},rawDatum:h,labelX:Ve(c.t)-4,labelY:d,labelText:i.id})}),je.forEach(n=>{const r=t[n.source]?.localAttachments.get(n.id),s=t[n.target]?.localAttachments.get(n.id);if(!r||!s)return;const l=tt.get(n.source)??0,c=et(n.source,l),d=function(e,t,o,n,i,r,s,a){const l=i,c=e=>a?Math.max(a[0],Math.min(a[1],e)):e,d=r(c(e.time)),m=r(c(o.time)),h=e.value*l,g=o.value*l,u=e.sideMassBefore*l,p=o.sideMassAfter*l;let f,b,y,v;"top"===e.side?(f=t-u,b=f+h):(b=t+u,f=b-h),"top"===o.side?(y=n-p,v=y+g):(v=n+p,y=v-g);const k="source"===s?d+.85*(m-d):"target"===s?d+.15*(m-d):(d+m)/2;return{sx:d,sTop:f,sBot:b,tx:m,tTop:y,tBot:v,cp1X:k,cp2X:k}}(r,e[n.source],s,e[n.target],o,Ve,x,$e),{pathD:m,bezier:h}=a(d),g=Ge.get(n.id)??n;i.push({id:n.id,pathD:m,fill:c,opacity:Y,rawDatum:g,bezier:h})}),{bands:n,ribbons:i}},[Ze,ze,je,Ve,$e,et,_e,Ge,x,Y,tt]),nt=ye(()=>({bands:ot.bands,ribbons:ot.ribbons,showLabels:D}),[ot,D]),it=ye(()=>{if(!Xe||!w)return;const e=new Map;(Pe??[]).forEach((t,o)=>{const n=Be(w,t),i=null==n?"":n+"";i&&!e.has(i)&&e.set(i,{label:i,color:et(Fe(t),o)})});const t=Array.from(e.values());return 0!==t.length?{legendGroups:[{type:"fill",label:"",items:t,styleFn:e=>{const t=e.color||"#333";return{fill:t,stroke:t}}}]}:void 0},[Xe,w,Pe,et,Fe]),rt=ye(()=>!1!==U&&Z?void 0===U||!0===U?null:v(U)||null:null,[U,Z]),st=Se(e=>K?K(new Date(e)):Number.isFinite(e)?1e10>Math.abs(e)?Number.isInteger(e)?e+"":e.toFixed(2):new Date(e).toISOString().slice(0,10):"",[K]),at=Se(e=>Q?Q(e):e+"",[Q]),lt=Se(e=>{if(!e||!e.data)return null;const t=e.data;if(!Ie(t))return null;const o=t.data;if(rt)return rt(o);if("band"===t.__kind){const e=t.id,o=Ze?function(e){if(!e)return[];const t=new Set,o=[];for(const n of e.samples){const e=n.topMass+n.botMass,i=`${n.t}:${e}`;t.has(i)||(t.add(i),o.push({t:n.t,total:e}))}return o}(Ze.nodeData[e]):[],n=5,i=o.length>n?o.length:null,r=function(e,t=5){if(t>=e.length)return e.slice();const o=[...e].sort((e,t)=>e.total-t.total),n=o.length-1,i=[{...o[0],mark:"min"},{...o[Math.floor(.25*n)],mark:"q25"},{...o[Math.floor(.5*n)],mark:"median"},{...o[Math.floor(.75*n)],mark:"q75"},{...o[n],mark:"max"}],r=new Set,s=[];for(const e of i)r.has(e.t)||(r.add(e.t),s.push(e));return s.sort((e,t)=>e.t-t.t)}(o,n);return He("div",{style:{minWidth:160},children:[Me("div",{style:{fontWeight:600,marginBottom:4},children:e}),r.length>0&&He("table",{style:{borderCollapse:"collapse",fontSize:11,width:"100%"},children:[Me("thead",{children:He("tr",{style:{opacity:.6},children:[Me("th",{style:{textAlign:"left",fontWeight:500,paddingRight:8},children:"Time"}),Me("th",{style:{textAlign:"right",fontWeight:500},children:"Mass"}),null!=i&&Me("th",{})]})}),Me("tbody",{children:r.map((e,t)=>He("tr",{children:[Me("td",{style:{paddingRight:8},children:st(e.t)}),Me("td",{style:{textAlign:"right"},children:at(e.total)}),null!=i&&Me("td",{style:{textAlign:"right",paddingLeft:8,opacity:.55},children:e.mark})]},t))})]}),null!=i&&He("div",{style:{marginTop:4,fontSize:10,opacity:.55},children:["showing ",r.length," of ",i," samples"]})]})}const n=o,i=Be(d,n),r=Be(m,n),s=Be(h,n),a=Be(g,n),l=Be(u,n);return He("div",{style:{minWidth:160},children:[He("div",{style:{fontWeight:600,marginBottom:4},children:[i+""," → ",r+""]}),He("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",columnGap:8,fontSize:11},children:[null!=s&&He(Ae,{children:[Me("span",{style:{opacity:.6},children:"value"}),Me("span",{style:{textAlign:"right"},children:at(Number(s))})]}),null!=a&&He(Ae,{children:[Me("span",{style:{opacity:.6},children:"start"}),Me("span",{style:{textAlign:"right"},children:st(xe(a))})]}),null!=l&&He(Ae,{children:[Me("span",{style:{opacity:.6},children:"end"}),Me("span",{style:{textAlign:"right"},children:st(xe(l))})]})]})]})},[Ze,rt,st,at,d,m,h,g,u]),ct=ye(()=>{if(!Ze)return null;const{centerlines:e,laneLifetime:t,nodeData:o,valueScale:n,compressedPadding:i,crossingsBefore:r,crossingsAfter:s,lengthBefore:a,lengthAfter:c}=Ze;let d=null,m=null;for(const e of ze){const o=t[e.id];if(!o||null===o.start||null===o.end)continue;const n=Ve(o.start),i=Ve(o.end);(null===d||d>n)&&(d=n),(null===m||i>m)&&(m=i)}const h=e=>Math.max(0,Math.min(Ke,e)),g=h(d??0),u=Math.max(g,h(m??Ke));return He("g",{children:[O&&null!==(s??null)&&He("text",{x:Ke,y:-12,fontSize:10,fill:"#94a3b8",textAnchor:"end",children:["crossings: ",r," → ",s," ","edge length: ",Math.round(a)," → ",Math.round(c)]}),i&&Me("text",{x:Ke,y:2,fontSize:10,fill:"#94a3b8",textAnchor:"end",children:"dense layout: lane gaps compressed"}),l.map((e,t)=>{const o=Ve(xe(e.date));return g-.5>o||o>u+.5?null:Me("line",{x1:o,y1:0,x2:o,y2:Qe,stroke:"#94a3b8",strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+t)}),N&&ze.map((i,r)=>{const s=t[i.id];if(!s||null===s.start)return null;const a=o[i.id],l=a?{topPeak:a.topPeak,botPeak:a.botPeak}:{topPeak:0,botPeak:0},c=e[i.id]+(l.botPeak-l.topPeak)*n/2,d=Ve(s.start),m=Ve(s.end),h=et(i.id,r);return He("g",{children:[Me("line",{x1:d,y1:c,x2:m,y2:c,stroke:h,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),Me("line",{x1:d,y1:c-4,x2:d,y2:c+4,stroke:h,strokeOpacity:.5}),Me("line",{x1:m,y1:c-4,x2:m,y2:c+4,stroke:h,strokeOpacity:.5})]},"lane-"+i.id)}),Me("line",{x1:g,y1:Qe+4,x2:u,y2:Qe+4,stroke:"#94a3b8"}),l.map((e,t)=>{const o=xe(e.date),n=Ve(o);if(g-.5>n||n>u+.5)return null;const i=null!=e.label?e.label:K?K(new Date(o)):"";return He("g",{transform:`translate(${n},${Qe+4})`,children:[Me("line",{y2:6,stroke:"#94a3b8"}),Me("text",{y:20,textAnchor:"middle",fontSize:11,fill:"#475569",children:i})]},t)})]})},[Ze,l,Ve,Ke,Qe,N,ze,et,O,K]),dt=ye(()=>(Pe??[]).map(e=>({id:Fe(e),data:e})),[Pe,Fe]),mt=ye(()=>{const e=new Map;for(const t of ot.ribbons)t.bezier&&e.set(t.id,t.bezier);return e},[ot]),ht=ye(()=>(De??[]).map((e,t)=>{const o=Re(e,t),n=Number(Be(h,e));return{id:o,source:Be(d,e)+"",target:Be(m,e)+"",value:Number.isFinite(n)?n:0,bezier:mt.get(o),data:e}}),[De,Re,d,m,h,mt]),gt=qe.loadingEl,ut=qe.emptyEl;return Ue.length>0?He("svg",{width:P,height:L,role:"img","aria-label":W??"Process Sankey validation failed",children:[Me("text",{x:20,y:30,fontSize:13,fontWeight:600,fill:"var(--semiotic-danger, #dc2626)",children:"ProcessSankey: data invalid"}),Ue.map((e,t)=>Me("text",{x:20,y:56+18*t,fontSize:12,fill:"#64748b",children:"• "+ae(e)},t))]}):gt||ut||Me(s,{ref:Le,chartType:"force",nodes:dt,edges:ht,customNetworkLayout:Te,layoutConfig:nt,size:[P,L],responsiveWidth:j,responsiveHeight:$,margin:Ye,title:W,description:R??"Temporal process flow with lifetime-bounded node lanes, mass bands, and value-scaled ribbons.",summary:F,accessibleTable:z,enableHover:Z,tooltipContent:!1===U?()=>null:lt,backgroundGraphics:ct,showParticles:te,particleStyle:oe,legend:it,legendPosition:I,onObservation:V,...ee&&{customClickBehavior:e=>{if(!e||!e.data||!ee)return;const t=e.data;Ie(t)&&ee(t.data,{x:e.x,y:e.y})}},chartId:ne,colorScheme:Array.isArray(C)?C:void 0,...ie})});Ne.displayName="ProcessSankey";import{useMemo as Oe}from"react";import{jsx as De}from"react/jsx-runtime";function Pe(e){const n=I(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:i,margin:r,className:a,layout:l="tree",orientation:d="vertical",childrenAccessor:m="children",valueAccessor:h="value",nodeIdAccessor:g="name",colorBy:u,colorScheme:p,colorByDepth:b=!1,edgeStyle:k="curve",nodeLabel:S,nodeSize:C=5,tooltip:T,frameProps:A={},onObservation:M,onClick:H,chartId:x,selection:B,linkedHover:D,loading:P,loadingContent:L,legendInteraction:E,stroke:W,strokeWidth:R,opacity:F}=e,{width:z,height:j,enableHover:$,showLabels:G=!0,title:X,description:Y,summary:K,accessibleTable:Q}=n,U=J({nodes:Oe(()=>_(i??null,m),[i,m]),edges:void 0,inferNodes:!1,colorBy:b?void 0:u,colorScheme:p,showLegend:!1,legendInteraction:E,selection:B,linkedHover:D,onObservation:M,onClick:H,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"TreeDiagram",chartId:x,marginDefaults:n.marginDefaults,userMargin:r,width:z,height:j,loading:P,loadingContent:L}),Z=Oe(()=>new Map,[]),V=Oe(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=b?f[(e.depth||0)%f.length]:u?y(e.data||e,u,U.colorScale):w(void 0,U.themeCategorical,p,void 0,Z),t},[u,b,U.colorScale,U.themeCategorical,p,Z]),ee=Oe(()=>o(V,{stroke:W,strokeWidth:R,opacity:F}),[V,W,R,F]),te=Oe(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),oe=Oe(()=>o(te,{stroke:W,strokeWidth:R,opacity:F}),[te,W,R,F]),ne=Oe(()=>{if("treemap"===l||"circlepack"===l||"partition"===l)return q(h)},[l,h]),ie=t({componentName:"TreeDiagram",data:i});return ie?De(N,{componentName:"TreeDiagram",message:ie,width:z,height:j}):U.loadingEl?U.loadingEl:De(O,{componentName:"TreeDiagram",width:z,height:j,children:De(s,{chartType:l,...null!=i&&{data:i},size:[z,j],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:U.margin,nodeIDAccessor:g,childrenAccessor:m,hierarchySum:ne,treeOrientation:d,edgeType:k,nodeStyle:ee,edgeStyle:oe,colorBy:u,colorScheme:U.effectivePalette,colorByDepth:b,nodeSize:C,nodeLabel:G?S||g:void 0,showLabels:G,enableHover:$,tooltipContent:!1===T?()=>null:v(T)||void 0,...c({linkedHover:D,selection:B,onObservation:M,onClick:H,mobileInteraction:U.mobileInteraction,customHoverBehavior:U.customHoverBehavior,customClickBehavior:U.customClickBehavior,linkedHoverInClickPredicate:!1}),...E&&"none"!==E&&{legendHoverBehavior:U.legendState.onLegendHover,legendClickBehavior:U.legendState.onLegendClick,legendHighlightedCategory:U.legendState.highlightedCategory,legendIsolatedCategories:U.legendState.isolatedCategories},className:a,title:X,description:Y,summary:K,accessibleTable:Q,...null!=e.animate&&{animate:e.animate},...A})})}Pe.displayName="TreeDiagram";import{useMemo as Le,useCallback as Ee}from"react";import{jsx as We}from"react/jsx-runtime";function Re(e){const n=I(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,linkedHover:e.linkedHover,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:i,margin:a,className:l,childrenAccessor:d="children",valueAccessor:m="value",nodeIdAccessor:h="name",colorBy:g,colorScheme:u,colorByDepth:b=!1,labelMode:k="leaf",nodeLabel:S,padding:C=4,paddingTop:T,nodeStyle:A,tooltip:M,frameProps:H={},selection:x,linkedHover:B,onObservation:D,onClick:P,chartId:L,loading:E,loadingContent:W,legendInteraction:R,stroke:F,strokeWidth:z,opacity:j}=e,{nodeStyle:$,...G}=H,{width:X,height:Y,enableHover:K,showLabels:Q=!0,title:U,description:Z,summary:V,accessibleTable:ee}=n,te=J({nodes:Le(()=>_(i??null,d),[i,d]),edges:void 0,inferNodes:!1,colorBy:b?void 0:g,colorScheme:u,showLegend:!1,legendInteraction:R,selection:x,linkedHover:B,onObservation:D,onClick:P,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"Treemap",chartId:L,marginDefaults:n.marginDefaults,userMargin:a,width:X,height:Y,loading:E,loadingContent:W}),oe=r(x),ne=te.customHoverBehavior,ie=Ee(e=>{if(!e)return ne(null);const t=e.data||e;ne({data:t?.data||t})},[ne]),re=Le(()=>new Map,[]),se=Le(()=>e=>{const t={stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8};return t.fill=b?f[(e.depth||0)%f.length]:g?y(e.data||e,g,te.colorScale):w(void 0,te.themeCategorical,u,void 0,re),t},[g,b,te.colorScale,te.themeCategorical,u,re]),ae=Le(()=>A||$?e=>({...se(e),...$?$(e)??{}:{},...A?A(e)??{}:{}}):se,[se,A,$]),le=Le(()=>o(ae,{stroke:F,strokeWidth:z,opacity:j}),[ae,F,z,j]),ce=Le(()=>te.activeSelectionHook?e=>{const t={...le(e)};if(te.activeSelectionHook.isActive)if(te.activeSelectionHook.predicate(e.data||e))oe?.selectedStyle&&Object.assign(t,oe.selectedStyle);else{const e=oe?.unselectedOpacity??p;t.opacity=e,t.fillOpacity=e,t.strokeOpacity=e,oe?.unselectedStyle&&Object.assign(t,oe.unselectedStyle)}return t}:le,[le,te.activeSelectionHook,oe]),de=Le(()=>q(m),[m]),me=void 0!==T?T:!Q||"parent"!==k&&"all"!==k?void 0:18,he=t({componentName:"Treemap",data:i});return he?We(N,{componentName:"Treemap",message:he,width:X,height:Y}):te.loadingEl?te.loadingEl:We(O,{componentName:"Treemap",width:X,height:Y,children:We(s,{chartType:"treemap",...null!=i&&{data:i},size:[X,Y],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:te.margin,nodeIDAccessor:h,childrenAccessor:d,hierarchySum:de,padding:C,paddingTop:me,nodeStyle:ce,colorBy:g,colorScheme:te.effectivePalette,colorByDepth:b,nodeLabel:Q?S||h:void 0,showLabels:Q,labelMode:k,enableHover:K,tooltipContent:!1===M?()=>null:v(M)||void 0,...c({linkedHover:B,selection:x,onObservation:D,onClick:P,mobileInteraction:te.mobileInteraction,customHoverBehavior:ie,customClickBehavior:te.customClickBehavior,linkedHoverInClickPredicate:!1}),...R&&"none"!==R&&{legendHoverBehavior:te.legendState.onLegendHover,legendClickBehavior:te.legendState.onLegendClick,legendHighlightedCategory:te.legendState.highlightedCategory,legendIsolatedCategories:te.legendState.isolatedCategories},className:l,title:U,description:Z,summary:V,accessibleTable:ee,...null!=e.animate&&{animate:e.animate},...G})})}Re.displayName="Treemap";import{useMemo as Fe}from"react";import{jsx as ze}from"react/jsx-runtime";function je(e){const n=I(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:i,margin:r,className:a,childrenAccessor:l="children",valueAccessor:d="value",nodeIdAccessor:m="name",colorBy:h,colorScheme:g,colorByDepth:u=!1,nodeLabel:p,circleOpacity:b=.7,padding:k=4,tooltip:S,frameProps:C={},onObservation:T,onClick:A,chartId:M,selection:H,linkedHover:x,loading:B,loadingContent:D,legendInteraction:P,stroke:L,strokeWidth:E,opacity:W}=e,{width:R,height:F,enableHover:z,showLabels:j=!0,title:$,description:G,summary:X,accessibleTable:Y}=n,K=J({nodes:Fe(()=>_(i??null,l),[i,l]),edges:void 0,inferNodes:!1,colorBy:u?void 0:h,colorScheme:g,showLegend:!1,legendInteraction:P,selection:H,linkedHover:x,onObservation:T,onClick:A,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"CirclePack",chartId:M,marginDefaults:n.marginDefaults,userMargin:r,width:R,height:F,loading:B,loadingContent:D}),Q=Fe(()=>new Map,[]),U=Fe(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:b};return t.fill=u?f[(e.depth||0)%f.length]:h?y(e.data||e,h,K.colorScale):w(void 0,K.themeCategorical,g,void 0,Q),t},[h,u,K.colorScale,b,K.themeCategorical,g,Q]),Z=Fe(()=>o(U,{stroke:L,strokeWidth:E,opacity:W}),[U,L,E,W]),V=Fe(()=>q(d),[d]),ee=t({componentName:"CirclePack",data:i});return ee?ze(N,{componentName:"CirclePack",message:ee,width:R,height:F}):K.loadingEl?K.loadingEl:ze(O,{componentName:"CirclePack",width:R,height:F,children:ze(s,{chartType:"circlepack",...null!=i&&{data:i},size:[R,F],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:K.margin,nodeIDAccessor:m,childrenAccessor:l,hierarchySum:V,padding:k,nodeStyle:Z,colorBy:h,colorScheme:K.effectivePalette,colorByDepth:u,nodeLabel:j?p||m:void 0,showLabels:j,enableHover:z,tooltipContent:!1===S?()=>null:v(S)||void 0,...c({linkedHover:x,selection:H,onObservation:T,onClick:A,mobileInteraction:K.mobileInteraction,customHoverBehavior:K.customHoverBehavior,customClickBehavior:K.customClickBehavior,linkedHoverInClickPredicate:!1}),...P&&"none"!==P&&{legendHoverBehavior:K.legendState.onLegendHover,legendClickBehavior:K.legendState.onLegendClick,legendHighlightedCategory:K.legendState.highlightedCategory,legendIsolatedCategories:K.legendState.isolatedCategories},className:a,title:$,description:G,summary:X,accessibleTable:Y,...null!=e.animate&&{animate:e.animate},...C})})}je.displayName="CirclePack";import{useMemo as $e}from"react";import{jsx as _e}from"react/jsx-runtime";var Ge=f;function qe(e){const n=I(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:i,margin:r,className:a,childrenAccessor:l="children",nodeIdAccessor:d="name",colorBy:m,colorScheme:h,colorByDepth:p=!1,orbitMode:f="flat",orbitSize:b=2.95,speed:S=.25,revolution:C,revolutionStyle:T,eccentricity:A=1,showRings:M=!0,nodeRadius:H=6,showLabels:x=!1,animated:B=!0,tooltip:D,foregroundGraphics:P,annotations:L,frameProps:E={},onObservation:W,onClick:R,chartId:F,selection:z,linkedHover:j,loading:$,loadingContent:G,stroke:q,strokeWidth:X,opacity:Y}=e,{width:K,height:Q,enableHover:U,title:Z,description:V,summary:ee,accessibleTable:te}=n,oe=J({nodes:$e(()=>_(i,l),[i,l]),edges:void 0,inferNodes:!1,colorBy:p?void 0:m,colorScheme:h,showLegend:!1,legendInteraction:void 0,selection:z,linkedHover:j,onObservation:W,onClick:R,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"OrbitDiagram",chartId:F,marginDefaults:k(n),userMargin:r,width:K,height:Q,loading:$,loadingContent:G}),ne=$e(()=>new Map,[]),{colorScale:ie,customClickBehavior:re,customHoverBehavior:se,themeCategorical:ae}=oe,le=$e(()=>{if(Array.isArray(h))return h;const e=g[h];return Array.isArray(e)?e:u},[h]),ce=$e(()=>e=>{const t={stroke:"#fff",strokeWidth:1},o=0===(e.depth??0);return t.fill=p?o?le[0]:Ge[(e.depth||0)%Ge.length]:m?y(e.data||e,m,ie):w(void 0,ae,h,void 0,ne),t.opacity=o?1:.85,t},[m,p,ie,le,ae,h,ne]),de=$e(()=>o(ce,{stroke:q,strokeWidth:X,opacity:Y}),[ce,q,X,Y]),me=$e(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),he=$e(()=>e=>{se(e&&e.data&&void 0!==e.data.data?{...e,data:e.data.data}:e)},[se]),ge=$e(()=>e=>{re(e&&e.data&&void 0!==e.data.data?{...e,data:e.data.data}:e)},[re]),ue=t({componentName:"OrbitDiagram",data:i});return ue?_e(N,{componentName:"OrbitDiagram",message:ue,width:K,height:Q}):oe.loadingEl?oe.loadingEl:_e(O,{componentName:"OrbitDiagram",width:K,height:Q,children:_e(s,{chartType:"orbit",...null!=i&&{data:i},size:[K,Q],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:oe.margin,nodeIDAccessor:d,childrenAccessor:l,nodeStyle:de,edgeStyle:me,colorBy:m,colorScheme:oe.effectivePalette,colorByDepth:p,nodeSize:H,nodeLabel:x?d:void 0,showLabels:x,enableHover:!B&&U,tooltipContent:B?void 0:!1===D?()=>null:v(D)||void 0,...c({linkedHover:j,selection:z,onObservation:W,onClick:R,mobileInteraction:oe.mobileInteraction,customHoverBehavior:he,customClickBehavior:ge,linkedHoverInClickPredicate:!1}),foregroundGraphics:P,annotations:L,className:a,title:Z,description:V,summary:ee,orbitMode:f,orbitSize:b,orbitSpeed:S,orbitRevolution:C,orbitRevolutionStyle:T,orbitEccentricity:A,orbitShowRings:M,orbitAnimated:B,accessibleTable:te,...null!=e.animate&&{animate:e.animate},...E})})}qe.displayName="OrbitDiagram";import{forceCenter as Xe,forceCollide as Je,forceLink as Ye,forceManyBody as Ke,forceSimulation as Qe,forceX as Ue,forceY as Ze}from"d3-force";function Ve(e,t,o={}){const n=o.iterations??260,i=o.repulsion??5200,r=o.linkDistance??165,s=o.linkStrength??.045,a=o.centerStrength??.018,l=o.damping??.84,c=o.nodeRadius??12,m=o.nodePadding??3,h=o.inset??.06,g=d(o.seed??1),u=new Map;for(const t of e)u.set(t.id,0);for(const e of t)u.set(e.source,(u.get(e.source)??0)+1),u.set(e.target,(u.get(e.target)??0)+1);const p=500,f=e.map(e=>({id:e.id,data:e,x:200+600*g(),y:200+600*g()})),b=new Set(e.map(e=>e.id)),y=t.filter(e=>b.has(e.source)&&b.has(e.target)).map(e=>({source:e.source,target:e.target}));if(n>0){const e=Qe(f).randomSource(g).alphaDecay(1-Math.pow(.001,1/n)).velocityDecay(Math.max(0,Math.min(1,1-l))).force("charge",Ke().strength(e=>{const t=u.get(e.id)??0;return 2.5*-Math.sqrt(i)*Math.sqrt(t+1)})).force("collide",Je(e=>(e=>"function"==typeof c?c(e.data):c)(e)+m).strength(.9).iterations(2)).force("center",Xe(p,p).strength(.8)).force("x",Ue(p).strength(a)).force("y",Ze(p).strength(a));y.length>0&&e.force("link",Ye(y).id(e=>e.id).distance(r).strength(e=>{const t="string"==typeof e.target?e.target:e.target.id,o=Math.max(1,Math.min(u.get("string"==typeof e.source?e.source:e.source.id)??1,u.get(t)??1));return s/.045/o})),e.stop();for(let t=0;n>t;t+=1)e.tick()}let v=1/0,k=1/0,S=-1/0,w=-1/0;for(const e of f){const t=e.x??p,o=e.y??p;v>t&&(v=t),k>o&&(k=o),t>S&&(S=t),o>w&&(w=o)}const C=S-v,T=w-k,I={};for(const e of f)I[e.id]={x:0===C?.5:h+((e.x??p)-v)/C*(1-2*h),y:0===T?.5:h+((e.y??p)-k)/T*(1-2*h)};return I}export{R as NetworkCustomChart,K as ForceDirectedGraph,ee as ChordDiagram,re as SankeyDiagram,se as validateProcessSankey,ae as formatProcessSankeyIssue,Ne as ProcessSankey,Pe as TreeDiagram,Re as Treemap,je as CirclePack,qe as OrbitDiagram,Ve as forceLayout};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{STREAMING_PALETTE as e,createColorScale as t,filterSparseArray as r,getCrosshairProps as o,resolveMobileInteraction as n,useCategoryColors as a,useChartLegendAndMargin as i,useChartMode as l,useChartSelection as c,useColorScale as u,useLegendInteraction as s,useThemeCategorical as g}from"./chunk-chunk-BFHUYEOS.module.min.js";import{useThemeSelector as d}from"./chunk-chunk-WCX6U47H.module.min.js";import{renderEmptyState as m,renderLoadingState as h}from"./chunk-chunk-ACLDBMRH.module.min.js";import{useMemo as p}from"react";function y(e){const t=d(e=>e.theme.colors.selectionOpacity);return p(()=>{if(void 0!==e||void 0!==t)return{name:e?.name??"",...e,unselectedOpacity:e?.unselectedOpacity??t}},[e,t])}import{useCallback as f,useMemo as v,useState as b}from"react";function L(l){const{data:d,rawData:p,colorBy:L,colorScheme:k,legendInteraction:C,legendPosition:S,selection:H,linkedHover:w,fallbackFields:B,unwrapData:D=!1,onObservation:M,chartType:I,chartId:F,showLegend:R,legend:A,userMargin:P,marginDefaults:O,onClick:T,hoverHighlight:x,mobileInteraction:W,mobileSemantics:j,loading:z,loadingContent:G,emptyContent:N,width:U,height:_}=l,E=void 0===p,V=v(()=>r(d),[d]),[X,Y]=b([]),q=f(e=>{Y(t=>t.length===e.length&&t.every((t,r)=>t===e[r])?t:e)},[]),J="string"==typeof l.colorBy?l.colorBy:void 0,K=v(()=>n(W,{width:U,mobileSemantics:j}),[W,U,j]),{activeSelectionHook:Q,hoverSelectionHook:Z,customHoverBehavior:$,customClickBehavior:ee,crosshairSourceId:te}=c({selection:H,linkedHover:w,fallbackFields:B,unwrapData:D,onObservation:M,chartType:I,chartId:F,onClick:T,hoverHighlight:x,colorByField:J,mobileInteraction:K}),re=o(w,te),oe=u(V,L,k),ne=v(()=>{if(!L)return[];const e=new Set;for(const t of V){const r="function"==typeof L?L(t):t[L];null!=r&&e.add(r+"")}return Array.from(e)},[V,L]),ae=v(()=>E&&X.length>0?X:ne,[E,X,ne]),ie=s(C,L,ae),le=v(()=>Z||(ie.legendSelectionHook?ie.legendSelectionHook:Q),[Z,ie.legendSelectionHook,Q]),ce=y(H),ue=g(),se=a(),ge=v(()=>{if(oe)return oe;if(!L||0===ae.length)return;const r=Array.isArray(k)&&k.length>0||"string"==typeof k&&k.length>0?k:ue&&ue.length>0?ue:e,o="__streamCat",n=ae.map(e=>({[o]:e})),a=t(n,o,r);return e=>se?.[e]||a(e)||"#999"},[oe,L,ae,k,ue,se]),{legend:de,margin:me,legendPosition:he}=i({data:V,colorBy:L,colorScale:ge,showLegend:R,legendPosition:S,userMargin:P,defaults:O,categories:ae,additionalLegend:A}),pe=v(()=>{const e={};return de&&(e.legend=de,e.legendPosition=he),C&&"none"!==C&&(e.legendHoverBehavior=ie.onLegendHover,e.legendClickBehavior=ie.onLegendClick,e.legendHighlightedCategory=ie.highlightedCategory,e.legendIsolatedCategories=ie.isolatedCategories),E&&L&&(e.legendCategoryAccessor=L,e.onCategoriesChange=q),e},[de,he,C,ie.onLegendHover,ie.onLegendClick,ie.highlightedCategory,ie.isolatedCategories,E,L,q]),ye=Array.isArray(p)?r(p):p,fe=h(z,U,_,G),ve=fe?null:m(ye,U,_,N);return{data:V,colorScale:oe,allCategories:ae,legendState:ie,effectiveSelectionHook:le,activeSelectionHook:Q,customHoverBehavior:$,customClickBehavior:ee,mobileInteraction:K,legend:de,margin:me,legendPosition:he,earlyReturn:fe||ve||null,legendBehaviorProps:pe,crosshairProps:re,resolvedSelection:ce}}import{useImperativeHandle as k,useRef as C}from"react";function S(e,t){const{variant:r,frameRef:o,overrides:n}=t,a=C(n);a.current=n,k(e,()=>{const e=function(e,t){if("xy"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>e.current?.remove(t)??[],update:(t,r)=>e.current?.update(t,r)??[],replace:t=>e.current?.replace?.(t),clear:()=>e.current?.clear(),getData:()=>e.current?.getData()??[],getScales:()=>e.current?.getScales()??null,getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}if("network"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>{const r=Array.isArray(t)?t:[t],o=e.current?.getTopology()?.nodes??[],n=[];for(const t of r){const r=o.find(e=>e.id===t);r&&n.push({...r.data??{},id:t}),e.current?.removeNode(t)}return n},update:(t,r)=>(Array.isArray(t)?t:[t]).flatMap(t=>{const o=e.current?.updateNode(t,r);return o?[{...o,id:t}]:[]}),clear:()=>e.current?.clear(),getData:()=>e.current?.getTopology()?.nodes?.map(e=>e.data)??[],getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}if("geo-points"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>e.current?.removePoint(t)??[],update:(t,r)=>{const o=e.current?.removePoint(t)??[];for(const t of o)e.current?.push(r(t));return o},clear:()=>e.current?.clear(),getData:()=>e.current?.getData()??[],getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}const r=t;return{push:e=>r.current?.pushLine(e),pushMany:e=>r.current?.pushManyLines(e),remove:e=>r.current?.removeLine(e)??[],update:(e,t)=>{const o=r.current?.removeLine(e)??[];for(const e of o)r.current?.pushLine(t(e));return o},clear:()=>r.current?.clear(),getData:()=>r.current?.getLines()??[],getCustomLayout:()=>r.current?.getCustomLayout?.()??null,getLayoutFailure:()=>r.current?.getLayoutFailure?.()??null}}(r,o);return new Proxy(e,{get(e,t,r){if("string"==typeof t){const e=a.current?.[t];if("function"==typeof e)return e}return Reflect.get(e,t,r)},has:(e,t)=>!("string"!=typeof t||!a.current||!(t in a.current))||Reflect.has(e,t)})},[])}function H(e,t){if(!function(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}(t))return e??((...e)=>({}));const r={};return void 0!==t.stroke&&(r.stroke=t.stroke),void 0!==t.strokeWidth&&(r.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(r.opacity=t.opacity),e?(...t)=>({...e(...t)||{},...r}):(...e)=>({...r})}function w(e){if(null==e)return;if("number"==typeof e)return{top:e,right:e,bottom:e,left:e};const t={};return"number"==typeof e.top&&(t.top=e.top),"number"==typeof e.right&&(t.right=e.right),"number"==typeof e.bottom&&(t.bottom=e.bottom),"number"==typeof e.left&&(t.left=e.left),t}import{useMemo as B,useRef as D}from"react";function M(e){const t=D(null);return S(e.imperativeRef,{variant:e.imperativeVariant,frameRef:t}),{frameRef:t,resolved:l(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),normalizedMargin:B(()=>w(e.margin),[e.margin])}}function I(e){const t=M(e),{resolved:r,normalizedMargin:o}=t,n=L({data:e.data??[],rawData:e.data,colorBy:e.colorBy,colorScheme:e.colorScheme,legendInteraction:void 0,selection:e.selection,linkedHover:e.linkedHover,fallbackFields:"string"==typeof e.colorBy?[e.colorBy]:[],unwrapData:e.unwrapData,onObservation:e.onObservation,onClick:e.onClick,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,chartType:e.chartTypeLabel,chartId:e.chartId,showLegend:r.showLegend,legend:e.legend,userMargin:o,marginDefaults:r.marginDefaults,loading:e.loading,loadingContent:e.loadingContent,emptyContent:e.emptyContent,width:r.width,height:r.height});return{...t,safeData:n.data,setup:n,earlyReturn:n.earlyReturn}}export{y as useResolvedSelection,L as useChartSetup,S as useFrameImperativeHandle,H as mergeShapeStyle,w as normalizePartialMargin,M as useCustomChartScaffold,I as useCustomChartSetup};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{SafeRender as e,useWasHydratingFromSSR as t}from"./chunk-chunk-ZCNBUZPL.module.min.js";import{useReducedMotion as i}from"./chunk-chunk-YHNZCPOZ.module.min.js";function n(e,t={}){if("function"==typeof e)return e;const i=t.locale??"en-US";if("currency"===e){const e=t.precision??2,n=new Intl.NumberFormat(i,{style:"currency",currency:t.currency??"USD",maximumFractionDigits:e,minimumFractionDigits:e});return e=>n.format(e)}if("percent"===e){const e=new Intl.NumberFormat(i,{style:"percent",maximumFractionDigits:t.precision??1,minimumFractionDigits:0});return t=>e.format(t)}if("compact"===e){const e=new Intl.NumberFormat(i,{notation:"compact",maximumFractionDigits:t.precision??1,minimumFractionDigits:0});return t=>e.format(t)}if("duration"===e)return e=>r(e);const n=new Intl.NumberFormat(i,{notation:t.notation??"standard",maximumFractionDigits:t.precision??0,minimumFractionDigits:0});return e=>n.format(e)}function r(e){if(!Number.isFinite(e))return e+"";const t=0>e?"-":"",i=Math.abs(e);if(1e3>i)return`${t}${Math.round(i)}ms`;const n=i/1e3;if(60>n)return`${t}${r=n,Math.round(100*r)/100+""}s`;var r;const a=n/60;if(60>a){const e=Math.floor(a),i=Math.round(n-60*e);return 0===i?`${t}${e}m`:`${t}${e}m ${i}s`}const l=a/60;if(24>l){const e=Math.floor(l),i=Math.round(a-60*e);return 0===i?`${t}${e}h`:`${t}${e}h ${i}m`}const o=Math.floor(l/24),s=Math.round(l-24*o);return 0===s?`${t}${o}d`:`${t}${o}d ${s}h`}function a(e,t,i){return`${t??""}${e}${i??""}`}function l(e,t){return Number.isFinite(e)?0===e?t(0):`${e>0?"+":"−"}${t(Math.abs(e))}`:""}function o(e,t,i="en-US",n=1){if(!Number.isFinite(e)||!Number.isFinite(t))return null;if(0===e)return null;const r=(t-e)/Math.abs(e);return new Intl.NumberFormat(i,{style:"percent",maximumFractionDigits:n,minimumFractionDigits:0,signDisplay:"exceptZero"}).format(r)}function s(e,t){if(!t||0===t.length)return null;if(!Number.isFinite(e))return null;const i=t.filter(e=>Number.isFinite(e.at)||e.at===-1/0).slice().sort((e,t)=>e.at-t.at);let n=null;for(const t of i){if(t.at>e)break;n=t}return n}function u(e,t){return t||("neutral"===e?"var(--semiotic-text, currentColor)":`var(--semiotic-${e}, currentColor)`)}function c(e,t){const i=t.padding??1;if(0===e.length)return{line:"",area:"",points:[]};if(1===e.length){const e=t.width/2,i=t.height/2;return{line:`M${e},${i}`,area:"",points:[{x:e,y:i}]}}const n=t.yMin??e.reduce((e,t)=>Number.isFinite(t)&&e>t?t:e,1/0),r=(t.yMax??e.reduce((e,t)=>Number.isFinite(t)&&t>e?t:e,-1/0))-n||1,a=Math.max(0,t.width-2*i),l=Math.max(0,t.height-2*i),o=1===e.length?0:a/(e.length-1),s=[];let u="";for(let t=0;e.length>t;t++){const a=e[t];if(!Number.isFinite(a))continue;const c=i+t*o,m=i+l-(a-n)/r*l;u+=`${0===s.length?"M":"L"}${c.toFixed(2)},${m.toFixed(2)}`,s.push({x:c,y:m})}if(0===s.length)return{line:"",area:"",points:[]};const c=s[0],m=i+l;return{line:u,area:`${u} L${s[s.length-1].x.toFixed(2)},${m.toFixed(2)} L${c.x.toFixed(2)},${m.toFixed(2)} Z`,points:s}}import{forwardRef as m,useCallback as d,useEffect as h,useImperativeHandle as b,useMemo as p,useRef as f,useState as g}from"react";import{useMemo as v}from"react";import{Fragment as y,jsx as x,jsxs as N}from"react/jsx-runtime";var w={tile:{width:280,height:184,align:"start",labelSize:13,captionSize:11,valueSize:40,deltaSize:13,padding:{top:14,right:16,bottom:14,left:16},background:"var(--semiotic-surface, transparent)",border:!0,showHeader:!0,showDelta:!0,showTrend:!0,showChart:!0,chartSize:44},presentation:{width:540,height:320,align:"center",labelSize:18,captionSize:14,valueSize:96,deltaSize:18,padding:{top:32,right:32,bottom:32,left:32},background:"var(--semiotic-surface, transparent)",border:!0,showHeader:!0,showDelta:!0,showTrend:!0,showChart:!0,chartSize:80},inline:{width:void 0,height:void 0,align:"inherit",labelSize:0,captionSize:0,valueSize:0,deltaSize:0,padding:{top:0,right:0,bottom:0,left:0},background:"transparent",border:!1,showHeader:!1,showDelta:!0,showTrend:!1,showChart:!1,chartSize:0},thumbnail:{width:96,height:56,align:"center",labelSize:0,captionSize:0,valueSize:22,deltaSize:0,padding:{top:4,right:6,bottom:4,left:6},background:"transparent",border:!1,showHeader:!1,showDelta:!1,showTrend:!1,showChart:!1,chartSize:0}};function F(e,t,i){return void 0===e?i:"function"==typeof e?e(t):e}function S(e){return"positive"===e?"var(--semiotic-success, currentColor)":"negative"===e?"var(--semiotic-danger, currentColor)":"var(--semiotic-text-secondary, currentColor)"}function $(e){return"positive"===e?"▲":"negative"===e?"▼":"■"}var _=m((r,o)=>{const{value:c,label:m,caption:_,format:z,locale:D,currency:C,precision:I,prefix:k,suffix:L,unit:T,comparison:j,target:B,delta:H,deltaFormat:V,showDeltaPercent:P,direction:W,sentiment:Z,thresholds:U,windowSize:R=60,mode:A="tile",align:q,width:E,height:O,padding:Y,emphasis:X,color:G,background:J,borderColor:K,borderRadius:Q,className:ee,style:te,animate:ie,stalenessThreshold:ne,staleLabel:re,headerSlot:ae,valueSlot:le,deltaSlot:oe,trendSlot:se,chartSlot:ue,chartSize:ce,footerSlot:me,onClick:de,onObservation:he,chartId:be,description:pe,summary:fe,loading:ge,loadingContent:ve,emptyContent:ye}=r,xe=w[A]??w.tile,Ne=q??xe.align,we=E??xe.width,Fe=O??xe.height,Se=i(),$e=t(),[_e,ze]=g([]),[De,Me]=g(null),[Ce,Ie]=g(null),[ke,Le]=g(null),Te=f([]),je=f(null),Be=f(c);h(()=>{Be.current=c},[c]);const He=f(R);h(()=>{He.current=R},[R]);const Ve=d(e=>{const t="number"==typeof e?{value:e,time:Date.now()}:{time:Date.now(),...e},i="number"==typeof t.time?t.time:t.time instanceof Date?t.time.getTime():Date.now();return{...t,time:i}},[]),Pe=d(e=>{if(0===e.length)return;const t=He.current,i=e.map(Ve);let n=Te.current.concat(i);n.length>t&&(n=n.slice(n.length-t)),Te.current=n;const r=i[i.length-1];je.current=r.value,ze(n),Me(r.value);for(let e=i.length-1;e>=0;e--){const t=i[e].comparison;if(null!=t){Ie(t);break}}Le(r.time)},[Ve]),We=d(e=>Pe([e]),[Pe]);b(o,()=>({push:e=>We(e),pushMany:e=>Pe(e),clear:()=>{Te.current=[],je.current=null,ze([]),Me(null),Ie(null),Le(null)},getValue:()=>je.current??(Number.isFinite(Be.current)?Be.current:null),getData:()=>Te.current.slice()}),[We,Pe]);const Ze=De??c,Ue=null==Ze||"number"!=typeof Ze||!Number.isFinite(Ze),Re=p(()=>n(z??"number",{locale:D,currency:C,precision:I}),[z,D,C,I]),Ae=p(()=>n(V??z??"number",{locale:D,currency:C,precision:null==V&&null==z?0:I}),[V,z,D,C,I]),qe=ie??!1,Ee=("object"!=typeof qe||!1!==qe.intro)&&!!qe,Oe=Number.isFinite(Ze)?Ze:0,Ye=function(e,t,i,n=e){const[r,a]=g(()=>n),l=f(n),o=f(null),s=f(e),u=f(0),c=!!t,m="object"==typeof t?t.duration:void 0,d="number"==typeof m&&Number.isFinite(m)?Math.max(0,m):300,b="object"==typeof t&&"linear"===t.easing?"linear":"ease-out",p=f(e);return h(()=>{const t=e=>{l.current=e,a(e)};if(!Number.isFinite(e))return void t(e);if(!c||i)return void t(e);if(0===d)return void t(e);s.current=l.current,p.current=e,u.current="undefined"!=typeof performance?performance.now():Date.now();const n="linear"===b?e=>e:e=>1-Math.pow(1-e,3),r=e=>{const i=Math.min(1,(e-u.current)/d),a=n(i);t(s.current+(p.current-s.current)*a),1>i?o.current=requestAnimationFrame(r):(o.current=null,t(p.current))};return o.current=requestAnimationFrame(r),()=>{null!=o.current&&cancelAnimationFrame(o.current),o.current=null}},[c,d,b,i,e]),r}(Oe,qe,Se,f(!Ee||Se||$e?Oe:0).current),Xe=qe?Ye:Number.isFinite(Ze)?Ze:0,Ge=p(()=>s(Number.isFinite(Ze)?Ze:NaN,U),[Ze,U]),Je=Ge?Ge.level:"neutral",Ke=G??u(Je,Ge?.color),Qe=Ce??j?.value??null,et=null!=H?H:null!=Qe&&Number.isFinite(Ze)?Ze-Qe:null,tt=function(e,t,i){if(i&&"auto"!==i)return i;if(null==e||0===e||!Number.isFinite(e))return"neutral";const n=t??"higher-is-better";return"neutral"===n?"neutral":("higher-is-better"===n?e>0:0>e)?"positive":"negative"}(et,j?.direction??B?.direction??W,Z),it=null!=et&&Number.isFinite(et)?l(et,Ae):null,nt=p(()=>new Intl.NumberFormat(D??"en-US",{style:"percent",maximumFractionDigits:1,minimumFractionDigits:0,signDisplay:"exceptZero"}),[D]),rt=null!=Qe&&Number.isFinite(Ze)&&(P??1)&&0!==Qe?nt.format((Ze-Qe)/Math.abs(Qe)):null,at=function({target:e,value:t,format:i,locale:r,currency:a,precision:l}){const o=v(()=>new Intl.NumberFormat(r??"en-US",{style:"percent",maximumFractionDigits:0}),[r]),s=v(()=>n(e?.format??i??"number",{locale:r,currency:a,precision:l}),[e?.format,i,r,a,l]);return v(()=>{if(!e||!Number.isFinite(e.value))return null;const i="number"==typeof t&&Number.isFinite(t)&&0!==e.value?o.format(t/e.value):null,n=s(e.value);return{label:e.label,percent:i,formattedValue:n,text:i?e.label?`${i} of ${e.label} (${n})`:`${i} of ${n}`:e.label?`target ${e.label} (${n})`:"target "+n}},[e,t,s,o])}({target:B,value:Ze,format:z,locale:D,currency:C,precision:I}),lt=at?.percent??null,ot=at?.text??null,st=function(e,t){const[i,n]=g(!1);return h(()=>{if(!t||null==e)return void n(!1);const i=()=>{n(Date.now()-e>=t)};i();const r=setInterval(i,Math.max(250,Math.floor(t/4)));return()=>clearInterval(r)},[e,t]),i}(ke,ne),ut=Number.isFinite(Xe)?a(Re(Xe),k,L):"",ct={value:Ue?null:Ze,formattedValue:ut,level:Je,color:Ke,delta:et,deltaFormatted:it,deltaPercent:rt,sentiment:tt,isStale:st,pushBuffer:_e},mt=pe??function(e){const t=[];if(e.label&&t.push(e.label+":"),t.push(e.unit?`${e.formattedValue} ${e.unit}`:e.formattedValue),e.deltaFormatted){const i=e.delta,n=null!=i&&Number.isFinite(i)&&0!==i?i>0?"up":"down":"change";t.push(`${n} ${e.deltaFormatted}${e.deltaPercent?` (${e.deltaPercent})`:""}${e.comparisonLabel?" from "+e.comparisonLabel:""}`)}return e.targetText&&t.push(e.targetText),e.thresholdLabel&&t.push(e.thresholdLabel),e.stale&&t.push(e.staleLabel??"stale"),t.join(", ")}({label:m,formattedValue:Number.isFinite(Ze)?a(Re(Ze),k,L):"",unit:T,comparisonLabel:j?.label,delta:et,deltaFormatted:it,deltaPercent:rt,targetText:ot,thresholdLabel:Ge?.label,stale:st,staleLabel:re}),dt="number"==typeof Y?{top:Y,right:Y,bottom:Y,left:Y}:{...xe.padding,...Y??{}},ht="end"===Ne?"flex-end":"center"===Ne?"center":"start"===Ne?"flex-start":"inherit",bt={position:"relative",boxSizing:"border-box",width:we,height:Fe,padding:`${dt.top}px ${dt.right}px ${dt.bottom}px ${dt.left}px`,background:J??xe.background,border:xe.border?"1px solid "+(K??"var(--semiotic-border, #e2e2e2)"):void 0,borderRadius:"number"==typeof Q?Q+"px":Q??"var(--semiotic-border-radius, 8px)",display:"inline"===A?"inline-flex":"flex",flexDirection:"column",alignItems:"inherit"===ht?void 0:ht,textAlign:Ne,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",color:"var(--semiotic-text, #111)",opacity:st?.55:1,transition:"opacity 240ms ease-out",gridColumn:"primary"===X?"span 2":void 0,cursor:de?"pointer":void 0,...te},pt=d(e=>{const t=e.currentTarget.getBoundingClientRect(),i=e.clientX-t.left,n=e.clientY-t.top,r={value:Ue?NaN:Ze,level:Je,delta:et};de&&de(r,{x:i,y:n}),he&&he({type:"click",datum:r,x:i,y:n,chartType:"BigNumber",chartId:be,timestamp:Date.now()})},[de,he,be,Ue,Ze,Je,et]),ft="inline"===A?"span":"div",gt=["semiotic-bignumber","semiotic-bignumber--mode-"+A,"semiotic-bignumber--level-"+Je,"semiotic-bignumber--sentiment-"+tt,st?"semiotic-bignumber--stale":null,ee].filter(Boolean).join(" "),vt="positive"===tt?"up":"negative"===tt?"down":"flat";if(ge){const e="number"==typeof we?we:280,t="number"==typeof Fe?Fe:160;return x(ft,{role:"status","aria-live":"polite","aria-busy":"true",className:gt+" semiotic-bignumber--loading",style:{...bt,opacity:1},children:ve??x(M,{width:e,height:t,mode:A})})}return Ue?!1===ye?null:x(ft,{role:"status","aria-label":m?m+": no value":"no value",className:gt+" semiotic-bignumber--empty",style:{...bt,color:"var(--semiotic-text-secondary, #666)",fontSize:13,alignItems:"center",justifyContent:"center"},children:ye??"—"}):x(e,{componentName:"BigNumber",width:"number"==typeof we?we:280,height:"number"==typeof Fe?Fe:160,children:N(ft,{role:"group","aria-label":mt,"data-chart":"BigNumber","data-mode":A,"data-level":Je,"data-stale":st?"true":void 0,"data-sentiment":tt,className:gt,style:bt,onClick:de||he?pt:void 0,children:[xe.showHeader&&(m||_||ae)?x("div",{className:"semiotic-bignumber__header",style:{display:"flex",flexDirection:"column",gap:2,marginBottom:6,paddingRight:xe.showChart&&null!=ue?(ce??xe.chartSize)+8:0},children:F(ae,ct,N(y,{children:[m?x("span",{className:"semiotic-bignumber__label",style:{fontSize:xe.labelSize,color:"var(--semiotic-text-secondary, #6b7280)",fontWeight:500,letterSpacing:.2},children:m}):null,_?x("span",{className:"semiotic-bignumber__caption",style:{fontSize:xe.captionSize,color:"var(--semiotic-text-secondary, #9ca3af)"},children:_}):null]}))}):null,F(le,ct,N(ft,{className:"semiotic-bignumber__value semiotic-bignumber__value--"+Je,style:{display:"inline"===A?"inline-flex":"flex",alignItems:"baseline",gap:6,fontVariantNumeric:"tabular-nums",fontWeight:600,color:Ke,fontSize:xe.valueSize||void 0,lineHeight:1.05},children:[x("span",{className:"semiotic-bignumber__value-text",children:ut}),T?x("span",{className:"semiotic-bignumber__unit",style:{fontSize:xe.valueSize?Math.max(11,Math.round(.32*xe.valueSize)):"0.75em",color:"var(--semiotic-text-secondary, #9ca3af)",fontWeight:500},children:T}):null]})),xe.showDelta&&(it||at||j)?x(ft,{className:"semiotic-bignumber__delta semiotic-bignumber__delta--"+vt,style:{display:"inline"===A?"inline-flex":"flex",flexWrap:"wrap",gap:8,alignItems:"baseline",marginTop:"inline"===A?0:6,fontSize:xe.deltaSize||void 0,color:"var(--semiotic-text-secondary, #6b7280)"},children:F(oe,ct,N(y,{children:[it?N("span",{className:"semiotic-bignumber__delta-row semiotic-bignumber__delta-row--"+vt,style:{display:"inline-flex",alignItems:"center",gap:4,color:S(tt),fontWeight:600},children:[x("span",{"aria-hidden":"true",className:"semiotic-bignumber__arrow semiotic-bignumber__arrow--"+vt,children:$(tt)}),x("span",{className:"semiotic-bignumber__delta-amount",children:it}),rt?N("span",{className:"semiotic-bignumber__delta-percent",style:{fontWeight:500},children:["(",rt,")"]}):null]}):null,j?.label?x("span",{className:"semiotic-bignumber__comparison-label",children:j.label}):null,at?N("span",{className:"semiotic-bignumber__target",style:{display:"inline-flex",alignItems:"baseline",gap:4},children:[it||j?.label?x("span",{"aria-hidden":"true",className:"semiotic-bignumber__separator",children:"·"}):null,x("span",{className:"semiotic-bignumber__target-percent",style:{fontWeight:500,color:"var(--semiotic-text, #111)"},children:lt}),N("span",{className:"semiotic-bignumber__target-value",children:["of ",at.formattedValue,at.label?" "+at.label:""]})]}):null]}))}):null,xe.showChart&&null!=ue?x("div",{className:"semiotic-bignumber__chart",style:{position:"absolute",top:dt.top,right:dt.right,width:ce??xe.chartSize,height:ce??xe.chartSize,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none"},children:x("div",{style:{pointerEvents:"auto",lineHeight:0},children:F(ue,ct,null)})}):null,xe.showTrend&&null!=se?x("div",{className:"semiotic-bignumber__trend",style:{position:"absolute",left:dt.left,right:dt.right,bottom:dt.bottom+(null!=me?28:0)},children:F(se,ct,null)}):null,null!=me?x(ft,{className:"semiotic-bignumber__footer",style:{position:"absolute",left:dt.left,right:dt.right,bottom:dt.bottom,fontSize:xe.deltaSize||void 0,color:"var(--semiotic-text-secondary, #9ca3af)"},children:F(me,ct,null)}):null,fe?x("span",{style:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0},children:fe}):null]})})});_.displayName="BigNumber";var z=_,D=z;function M(e){const t=Math.floor(.45*e.width),i=Math.floor(.6*e.width),n=(e,t)=>x("div",{style:{width:e,height:t,background:"var(--semiotic-border, #e0e0e0)",borderRadius:4,opacity:.55}});return N("div",{style:{display:"flex",flexDirection:"column",gap:10,justifyContent:"center",width:"100%",height:"100%"},children:["thumbnail"!==e.mode&&"inline"!==e.mode?n(t,10):null,n(i,"presentation"===e.mode?48:28),"tile"===e.mode||"presentation"===e.mode?n(Math.floor(.35*e.width),8):null]})}export{n as buildFormatter,r as formatDuration,l as formatSignedDelta,o as formatDeltaPercent,s as resolveThreshold,u as colorForLevel,c as buildSparklinePath,z as BigNumber,D as BigNumber_default};
|
|
2
|
+
import{SafeRender as e,useWasHydratingFromSSR as t}from"./chunk-chunk-ACLDBMRH.module.min.js";import{useReducedMotion as i}from"./chunk-chunk-YHNZCPOZ.module.min.js";function n(e,t={}){if("function"==typeof e)return e;const i=t.locale??"en-US";if("currency"===e){const e=t.precision??2,n=new Intl.NumberFormat(i,{style:"currency",currency:t.currency??"USD",maximumFractionDigits:e,minimumFractionDigits:e});return e=>n.format(e)}if("percent"===e){const e=new Intl.NumberFormat(i,{style:"percent",maximumFractionDigits:t.precision??1,minimumFractionDigits:0});return t=>e.format(t)}if("compact"===e){const e=new Intl.NumberFormat(i,{notation:"compact",maximumFractionDigits:t.precision??1,minimumFractionDigits:0});return t=>e.format(t)}if("duration"===e)return e=>r(e);const n=new Intl.NumberFormat(i,{notation:t.notation??"standard",maximumFractionDigits:t.precision??0,minimumFractionDigits:0});return e=>n.format(e)}function r(e){if(!Number.isFinite(e))return e+"";const t=0>e?"-":"",i=Math.abs(e);if(1e3>i)return`${t}${Math.round(i)}ms`;const n=i/1e3;if(60>n)return`${t}${r=n,Math.round(100*r)/100+""}s`;var r;const a=n/60;if(60>a){const e=Math.floor(a),i=Math.round(n-60*e);return 0===i?`${t}${e}m`:`${t}${e}m ${i}s`}const l=a/60;if(24>l){const e=Math.floor(l),i=Math.round(a-60*e);return 0===i?`${t}${e}h`:`${t}${e}h ${i}m`}const o=Math.floor(l/24),s=Math.round(l-24*o);return 0===s?`${t}${o}d`:`${t}${o}d ${s}h`}function a(e,t,i){return`${t??""}${e}${i??""}`}function l(e,t){return Number.isFinite(e)?0===e?t(0):`${e>0?"+":"−"}${t(Math.abs(e))}`:""}function o(e,t,i="en-US",n=1){if(!Number.isFinite(e)||!Number.isFinite(t))return null;if(0===e)return null;const r=(t-e)/Math.abs(e);return new Intl.NumberFormat(i,{style:"percent",maximumFractionDigits:n,minimumFractionDigits:0,signDisplay:"exceptZero"}).format(r)}function s(e,t){if(!t||0===t.length)return null;if(!Number.isFinite(e))return null;const i=t.filter(e=>Number.isFinite(e.at)||e.at===-1/0).slice().sort((e,t)=>e.at-t.at);let n=null;for(const t of i){if(t.at>e)break;n=t}return n}function u(e,t){return t||("neutral"===e?"var(--semiotic-text, currentColor)":`var(--semiotic-${e}, currentColor)`)}function c(e,t){const i=t.padding??1;if(0===e.length)return{line:"",area:"",points:[]};if(1===e.length){const e=t.width/2,i=t.height/2;return{line:`M${e},${i}`,area:"",points:[{x:e,y:i}]}}const n=t.yMin??e.reduce((e,t)=>Number.isFinite(t)&&e>t?t:e,1/0),r=(t.yMax??e.reduce((e,t)=>Number.isFinite(t)&&t>e?t:e,-1/0))-n||1,a=Math.max(0,t.width-2*i),l=Math.max(0,t.height-2*i),o=1===e.length?0:a/(e.length-1),s=[];let u="";for(let t=0;e.length>t;t++){const a=e[t];if(!Number.isFinite(a))continue;const c=i+t*o,m=i+l-(a-n)/r*l;u+=`${0===s.length?"M":"L"}${c.toFixed(2)},${m.toFixed(2)}`,s.push({x:c,y:m})}if(0===s.length)return{line:"",area:"",points:[]};const c=s[0],m=i+l;return{line:u,area:`${u} L${s[s.length-1].x.toFixed(2)},${m.toFixed(2)} L${c.x.toFixed(2)},${m.toFixed(2)} Z`,points:s}}import{forwardRef as m,useCallback as d,useEffect as h,useImperativeHandle as b,useMemo as p,useRef as f,useState as g}from"react";import{useMemo as v}from"react";import{Fragment as y,jsx as x,jsxs as w}from"react/jsx-runtime";var N={tile:{width:280,height:184,align:"start",labelSize:13,captionSize:11,valueSize:40,deltaSize:13,padding:{top:14,right:16,bottom:14,left:16},background:"var(--semiotic-surface, transparent)",border:!0,showHeader:!0,showDelta:!0,showTrend:!0,showChart:!0,chartSize:44},presentation:{width:540,height:320,align:"center",labelSize:18,captionSize:14,valueSize:96,deltaSize:18,padding:{top:32,right:32,bottom:32,left:32},background:"var(--semiotic-surface, transparent)",border:!0,showHeader:!0,showDelta:!0,showTrend:!0,showChart:!0,chartSize:80},inline:{width:void 0,height:void 0,align:"inherit",labelSize:0,captionSize:0,valueSize:0,deltaSize:0,padding:{top:0,right:0,bottom:0,left:0},background:"transparent",border:!1,showHeader:!1,showDelta:!0,showTrend:!1,showChart:!1,chartSize:0},thumbnail:{width:96,height:56,align:"center",labelSize:0,captionSize:0,valueSize:22,deltaSize:0,padding:{top:4,right:6,bottom:4,left:6},background:"transparent",border:!1,showHeader:!1,showDelta:!1,showTrend:!1,showChart:!1,chartSize:0}};function F(e,t,i){return void 0===e?i:"function"==typeof e?e(t):e}function S(e){return"positive"===e?"var(--semiotic-success, currentColor)":"negative"===e?"var(--semiotic-danger, currentColor)":"var(--semiotic-text-secondary, currentColor)"}function $(e){return"positive"===e?"▲":"negative"===e?"▼":"■"}var _=m((r,o)=>{const{value:c,label:m,caption:_,format:z,locale:D,currency:C,precision:I,prefix:k,suffix:L,unit:T,comparison:j,target:B,delta:H,deltaFormat:V,showDeltaPercent:W,direction:P,sentiment:R,thresholds:A,windowSize:U=60,mode:Z="tile",align:q,width:E,height:O,padding:Y,emphasis:X,color:G,background:J,borderColor:K,borderRadius:Q,className:ee,style:te,animate:ie,stalenessThreshold:ne,staleLabel:re,headerSlot:ae,valueSlot:le,deltaSlot:oe,trendSlot:se,chartSlot:ue,chartSize:ce,footerSlot:me,onClick:de,onObservation:he,chartId:be,description:pe,summary:fe,loading:ge,loadingContent:ve,emptyContent:ye}=r,xe=N[Z]??N.tile,we=q??xe.align,Ne=E??xe.width,Fe=O??xe.height,Se=i(),$e=t(),[_e,ze]=g([]),[De,Me]=g(null),[Ce,Ie]=g(null),[ke,Le]=g(null),Te=f([]),je=f(null),Be=f(c);h(()=>{Be.current=c},[c]);const He=f(U);h(()=>{He.current=U},[U]);const Ve=d(e=>{const t="number"==typeof e?{value:e,time:Date.now()}:{time:Date.now(),...e},i="number"==typeof t.time?t.time:t.time instanceof Date?t.time.getTime():Date.now();return{...t,time:i}},[]),We=d(e=>{if(0===e.length)return;const t=He.current,i=e.map(Ve);let n=Te.current.concat(i);n.length>t&&(n=n.slice(n.length-t)),Te.current=n;const r=i[i.length-1];je.current=r.value,ze(n),Me(r.value);for(let e=i.length-1;e>=0;e--){const t=i[e].comparison;if(null!=t){Ie(t);break}}Le(r.time)},[Ve]),Pe=d(e=>We([e]),[We]);b(o,()=>({push:e=>Pe(e),pushMany:e=>We(e),clear:()=>{Te.current=[],je.current=null,ze([]),Me(null),Ie(null),Le(null)},getValue:()=>je.current??(Number.isFinite(Be.current)?Be.current:null),getData:()=>Te.current.slice()}),[Pe,We]);const Re=De??c,Ae=null==Re||"number"!=typeof Re||!Number.isFinite(Re),Ue=p(()=>n(z??"number",{locale:D,currency:C,precision:I}),[z,D,C,I]),Ze=p(()=>n(V??z??"number",{locale:D,currency:C,precision:null==V&&null==z?0:I}),[V,z,D,C,I]),qe=ie??!1,Ee=("object"!=typeof qe||!1!==qe.intro)&&!!qe,Oe=Number.isFinite(Re)?Re:0,Ye=function(e,t,i,n=e){const[r,a]=g(()=>n),l=f(n),o=f(null),s=f(e),u=f(0),c=!!t,m="object"==typeof t?t.duration:void 0,d="number"==typeof m&&Number.isFinite(m)?Math.max(0,m):300,b="object"==typeof t&&"linear"===t.easing?"linear":"ease-out",p=f(e);return h(()=>{const t=e=>{l.current=e,a(e)};if(!Number.isFinite(e))return void t(e);if(!c||i)return void t(e);if(0===d)return void t(e);s.current=l.current,p.current=e,u.current="undefined"!=typeof performance?performance.now():Date.now();const n="linear"===b?e=>e:e=>1-Math.pow(1-e,3),r=e=>{const i=Math.min(1,(e-u.current)/d),a=n(i);t(s.current+(p.current-s.current)*a),1>i?o.current=requestAnimationFrame(r):(o.current=null,t(p.current))};return o.current=requestAnimationFrame(r),()=>{null!=o.current&&cancelAnimationFrame(o.current),o.current=null}},[c,d,b,i,e]),r}(Oe,qe,Se,f(!Ee||Se||$e?Oe:0).current),Xe=qe?Ye:Number.isFinite(Re)?Re:0,Ge=p(()=>s(Number.isFinite(Re)?Re:NaN,A),[Re,A]),Je=Ge?Ge.level:"neutral",Ke=G??u(Je,Ge?.color),Qe=Ce??j?.value??null,et=null!=H?H:null!=Qe&&Number.isFinite(Re)?Re-Qe:null,tt=function(e,t,i){if(i&&"auto"!==i)return i;if(null==e||0===e||!Number.isFinite(e))return"neutral";const n=t??"higher-is-better";return"neutral"===n?"neutral":("higher-is-better"===n?e>0:0>e)?"positive":"negative"}(et,j?.direction??B?.direction??P,R),it=null!=et&&Number.isFinite(et)?l(et,Ze):null,nt=p(()=>new Intl.NumberFormat(D??"en-US",{style:"percent",maximumFractionDigits:1,minimumFractionDigits:0,signDisplay:"exceptZero"}),[D]),rt=null!=Qe&&Number.isFinite(Re)&&(W??1)&&0!==Qe?nt.format((Re-Qe)/Math.abs(Qe)):null,at=function({target:e,value:t,format:i,locale:r,currency:a,precision:l}){const o=v(()=>new Intl.NumberFormat(r??"en-US",{style:"percent",maximumFractionDigits:0}),[r]),s=v(()=>n(e?.format??i??"number",{locale:r,currency:a,precision:l}),[e?.format,i,r,a,l]);return v(()=>{if(!e||!Number.isFinite(e.value))return null;const i="number"==typeof t&&Number.isFinite(t)&&0!==e.value?o.format(t/e.value):null,n=s(e.value);return{label:e.label,percent:i,formattedValue:n,text:i?e.label?`${i} of ${e.label} (${n})`:`${i} of ${n}`:e.label?`target ${e.label} (${n})`:"target "+n}},[e,t,s,o])}({target:B,value:Re,format:z,locale:D,currency:C,precision:I}),lt=at?.percent??null,ot=at?.text??null,st=function(e,t){const[i,n]=g(!1);return h(()=>{if(!t||null==e)return void n(!1);const i=()=>{n(Date.now()-e>=t)};i();const r=setInterval(i,Math.max(250,Math.floor(t/4)));return()=>clearInterval(r)},[e,t]),i}(ke,ne),ut=Number.isFinite(Xe)?a(Ue(Xe),k,L):"",ct={value:Ae?null:Re,formattedValue:ut,level:Je,color:Ke,delta:et,deltaFormatted:it,deltaPercent:rt,sentiment:tt,isStale:st,pushBuffer:_e},mt=pe??function(e){const t=[];if(e.label&&t.push(e.label+":"),t.push(e.unit?`${e.formattedValue} ${e.unit}`:e.formattedValue),e.deltaFormatted){const i=e.delta,n=null!=i&&Number.isFinite(i)&&0!==i?i>0?"up":"down":"change";t.push(`${n} ${e.deltaFormatted}${e.deltaPercent?` (${e.deltaPercent})`:""}${e.comparisonLabel?" from "+e.comparisonLabel:""}`)}return e.targetText&&t.push(e.targetText),e.thresholdLabel&&t.push(e.thresholdLabel),e.stale&&t.push(e.staleLabel??"stale"),t.join(", ")}({label:m,formattedValue:Number.isFinite(Re)?a(Ue(Re),k,L):"",unit:T,comparisonLabel:j?.label,delta:et,deltaFormatted:it,deltaPercent:rt,targetText:ot,thresholdLabel:Ge?.label,stale:st,staleLabel:re}),dt="number"==typeof Y?{top:Y,right:Y,bottom:Y,left:Y}:{...xe.padding,...Y??{}},ht="end"===we?"flex-end":"center"===we?"center":"start"===we?"flex-start":"inherit",bt={position:"relative",boxSizing:"border-box",width:Ne,height:Fe,padding:`${dt.top}px ${dt.right}px ${dt.bottom}px ${dt.left}px`,background:J??xe.background,border:xe.border?"1px solid "+(K??"var(--semiotic-border, #e2e2e2)"):void 0,borderRadius:"number"==typeof Q?Q+"px":Q??"var(--semiotic-border-radius, 8px)",display:"inline"===Z?"inline-flex":"flex",flexDirection:"column",alignItems:"inherit"===ht?void 0:ht,textAlign:we,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",color:"var(--semiotic-text, #111)",opacity:st?.55:1,transition:"opacity 240ms ease-out",gridColumn:"primary"===X?"span 2":void 0,cursor:de?"pointer":void 0,...te},pt=d(e=>{const t=e.currentTarget.getBoundingClientRect(),i=e.clientX-t.left,n=e.clientY-t.top,r={value:Ae?NaN:Re,level:Je,delta:et};de&&de(r,{x:i,y:n}),he&&he({type:"click",datum:r,x:i,y:n,chartType:"BigNumber",chartId:be,timestamp:Date.now()})},[de,he,be,Ae,Re,Je,et]),ft="inline"===Z?"span":"div",gt=["semiotic-bignumber","semiotic-bignumber--mode-"+Z,"semiotic-bignumber--level-"+Je,"semiotic-bignumber--sentiment-"+tt,st?"semiotic-bignumber--stale":null,ee].filter(Boolean).join(" "),vt="positive"===tt?"up":"negative"===tt?"down":"flat";if(ge){const e="number"==typeof Ne?Ne:280,t="number"==typeof Fe?Fe:160;return x(ft,{role:"status","aria-live":"polite","aria-busy":"true",className:gt+" semiotic-bignumber--loading",style:{...bt,opacity:1},children:ve??x(M,{width:e,height:t,mode:Z})})}return Ae?!1===ye?null:x(ft,{role:"status","aria-label":m?m+": no value":"no value",className:gt+" semiotic-bignumber--empty",style:{...bt,color:"var(--semiotic-text-secondary, #666)",fontSize:13,alignItems:"center",justifyContent:"center"},children:ye??"—"}):x(e,{componentName:"BigNumber",width:"number"==typeof Ne?Ne:280,height:"number"==typeof Fe?Fe:160,children:w(ft,{role:"group","aria-label":mt,"data-chart":"BigNumber","data-mode":Z,"data-level":Je,"data-stale":st?"true":void 0,"data-sentiment":tt,className:gt,style:bt,onClick:de||he?pt:void 0,children:[xe.showHeader&&(m||_||ae)?x("div",{className:"semiotic-bignumber__header",style:{display:"flex",flexDirection:"column",gap:2,marginBottom:6,paddingRight:xe.showChart&&null!=ue?(ce??xe.chartSize)+8:0},children:F(ae,ct,w(y,{children:[m?x("span",{className:"semiotic-bignumber__label",style:{fontSize:xe.labelSize,color:"var(--semiotic-text-secondary, #6b7280)",fontWeight:500,letterSpacing:.2},children:m}):null,_?x("span",{className:"semiotic-bignumber__caption",style:{fontSize:xe.captionSize,color:"var(--semiotic-text-secondary, #9ca3af)"},children:_}):null]}))}):null,F(le,ct,w(ft,{className:"semiotic-bignumber__value semiotic-bignumber__value--"+Je,style:{display:"inline"===Z?"inline-flex":"flex",alignItems:"baseline",gap:6,fontVariantNumeric:"tabular-nums",fontWeight:600,color:Ke,fontSize:xe.valueSize||void 0,lineHeight:1.05},children:[x("span",{className:"semiotic-bignumber__value-text",children:ut}),T?x("span",{className:"semiotic-bignumber__unit",style:{fontSize:xe.valueSize?Math.max(11,Math.round(.32*xe.valueSize)):"0.75em",color:"var(--semiotic-text-secondary, #9ca3af)",fontWeight:500},children:T}):null]})),xe.showDelta&&(it||at||j)?x(ft,{className:"semiotic-bignumber__delta semiotic-bignumber__delta--"+vt,style:{display:"inline"===Z?"inline-flex":"flex",flexWrap:"wrap",gap:8,alignItems:"baseline",marginTop:"inline"===Z?0:6,fontSize:xe.deltaSize||void 0,color:"var(--semiotic-text-secondary, #6b7280)"},children:F(oe,ct,w(y,{children:[it?w("span",{className:"semiotic-bignumber__delta-row semiotic-bignumber__delta-row--"+vt,style:{display:"inline-flex",alignItems:"center",gap:4,color:S(tt),fontWeight:600},children:[x("span",{"aria-hidden":"true",className:"semiotic-bignumber__arrow semiotic-bignumber__arrow--"+vt,children:$(tt)}),x("span",{className:"semiotic-bignumber__delta-amount",children:it}),rt?w("span",{className:"semiotic-bignumber__delta-percent",style:{fontWeight:500},children:["(",rt,")"]}):null]}):null,j?.label?x("span",{className:"semiotic-bignumber__comparison-label",children:j.label}):null,at?w("span",{className:"semiotic-bignumber__target",style:{display:"inline-flex",alignItems:"baseline",gap:4},children:[it||j?.label?x("span",{"aria-hidden":"true",className:"semiotic-bignumber__separator",children:"·"}):null,x("span",{className:"semiotic-bignumber__target-percent",style:{fontWeight:500,color:"var(--semiotic-text, #111)"},children:lt}),w("span",{className:"semiotic-bignumber__target-value",children:["of ",at.formattedValue,at.label?" "+at.label:""]})]}):null]}))}):null,xe.showChart&&null!=ue?x("div",{className:"semiotic-bignumber__chart",style:{position:"absolute",top:dt.top,right:dt.right,width:ce??xe.chartSize,height:ce??xe.chartSize,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none"},children:x("div",{style:{pointerEvents:"auto",lineHeight:0},children:F(ue,ct,null)})}):null,xe.showTrend&&null!=se?x("div",{className:"semiotic-bignumber__trend",style:{position:"absolute",left:dt.left,right:dt.right,bottom:dt.bottom+(null!=me?28:0)},children:F(se,ct,null)}):null,null!=me?x(ft,{className:"semiotic-bignumber__footer",style:{position:"absolute",left:dt.left,right:dt.right,bottom:dt.bottom,fontSize:xe.deltaSize||void 0,color:"var(--semiotic-text-secondary, #9ca3af)"},children:F(me,ct,null)}):null,fe?x("span",{style:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0},children:fe}):null]})})});_.displayName="BigNumber";var z=_,D=z;function M(e){const t=Math.floor(.45*e.width),i=Math.floor(.6*e.width),n=(e,t)=>x("div",{style:{width:e,height:t,background:"var(--semiotic-border, #e0e0e0)",borderRadius:4,opacity:.55}});return w("div",{style:{display:"flex",flexDirection:"column",gap:10,justifyContent:"center",width:"100%",height:"100%"},children:["thumbnail"!==e.mode&&"inline"!==e.mode?n(t,10):null,n(i,"presentation"===e.mode?48:28),"tile"===e.mode||"presentation"===e.mode?n(Math.floor(.35*e.width),8):null]})}export{n as buildFormatter,r as formatDuration,l as formatSignedDelta,o as formatDeltaPercent,s as resolveThreshold,u as colorForLevel,c as buildSparklinePath,z as BigNumber,D as BigNumber_default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LayoutCache as t,createSafeDatum as e,datumFromFields as n,dimFor as o,forceLayout as r,generateTokens as i,groupBy as a,layoutTokenGrid as s,makeShade as c,normalizeTokenEncoding as l,readField as u,resolveAccessor as h,signatureKey as d,stableGlyphId as f,unwrapDatum as m}from"./chunk-chunk-2CXCXRB4.module.min.js";import{canUseForceWorker as p,runForceLayoutWorker as y,shouldUseForceWorker as g}from"./chunk-chunk-ZOAQDIJO.module.min.js";import{collidersFromPlotBounds as x,collidersFromXScaleBins as b,sedimentHeightfield as w}from"./chunk-chunk-LRIFN2HK.module.min.js";import{mulberry32 as M}from"./chunk-chunk-SIRIJ3DY.module.min.js";import{useCustomLayoutSelection as v}from"./chunk-chunk-C4YA6TDR.module.min.js";import{SYMBOL_SEQUENCE as k,symbolExtent as $,symbolPathString as A}from"./chunk-chunk-5RKXZQ2P.module.min.js";import{isNoteAnnotation as S}from"./chunk-chunk-U66USBWU.module.min.js";var C=t=>{const n=t.config,o=n.rows??10,r=n.columns??10,i=n.gutter??2,a=o*r;if(0>=o||0>=r||0>=a)return{nodes:[]};const{plot:s}=t.dimensions;if(0>=s.width||0>=s.height)return{nodes:[]};const c=(s.width-i*(r-1))/r,l=(s.height-i*(o-1))/o;if(0>=c||0>=l)return{nodes:[]};const u=(null==(h=n.categoryAccessor)?null:"function"==typeof h?h:t=>t[h])??(()=>"_default");var h;const d=function(t){return null==t?null:"function"==typeof t?t:e=>Number(e[t])}(n.valueAccessor)??(()=>1),f=new Map,m=[];for(const e of t.data){const t=u(e)+"",n=Number(d(e)),o=Number.isFinite(n)?Math.max(0,n):0;f.has(t)||m.push(t),f.set(t,(f.get(t)??0)+o)}const p=Array.from(f.values()).reduce((t,e)=>t+e,0);if(0>=p)return{nodes:[]};let y;if(n.categoryOrder&&n.categoryOrder.length>0){const t=new Set,e=[];for(const o of n.categoryOrder)f.has(o)&&!t.has(o)&&(t.add(o),e.push(o));y=[...e,...m.filter(e=>!t.has(e))]}else y=m;if(0===y.length)return{nodes:[]};const g=y.map(t=>({cat:t,exact:(f.get(t)??0)/p*a})).map(t=>({...t,count:Math.floor(t.exact)})),x=g.reduce((t,e)=>t+e.count,0),b=g.map((t,e)=>({i:e,rem:t.exact-t.count})).sort((t,e)=>e.rem-t.rem);for(let t=0;a-x>t;t++)g[b[t%b.length].i].count+=1;const w="string"==typeof n.categoryAccessor?n.categoryAccessor:"category",M="string"==typeof n.valueAccessor?n.valueAccessor:"value",v=(t,n,o)=>e(e=>{e("category",t),e("value",f.get(t)??0),e("share",(f.get(t)??0)/p),"category"!==w&&e(w,t),"value"!==M&&e(M,f.get(t)??0),e("cells",o),e("_waffleCategory",t),e("_waffleIndex",n)}),k=[];let $=0;for(const e of g){const n=t.resolveColor(e.cat);for(let t=0;e.count>t;t++)k.push({type:"rect",x:s.x+$%r*(c+i),y:s.y+(o-1-Math.floor($/r))*(l+i),w:c,h:l,style:{fill:n,stroke:"none"},datum:v(e.cat,$,e.count),group:e.cat,_transitionKey:`waffle-${e.cat}-${t}`}),$++}return{nodes:k}};function z(t,e,n){const o=Math.max(0,Math.floor(n?.minPerCategory??0)),r=t.reduce((t,e)=>t+Math.max(0,e.weight),0);if(0>=e||0>=r)return t.map(t=>({...t,exact:0,cells:0,remainder:0}));const i=t.map(t=>{const n=Math.max(0,t.weight)/r*e;return{...t,exact:n,cells:Math.max(o,Math.floor(n)),remainder:n-Math.floor(n)}});let a=i.reduce((t,e)=>t+e.cells,0);for(;a>e;){const t=i.filter(t=>t.cells>o).sort((t,e)=>e.cells-t.cells||t.remainder-e.remainder||t.key.localeCompare(e.key))[0];if(!t)break;t.cells--,a--}const s=[...i].sort((t,e)=>e.remainder-t.remainder||e.weight-t.weight||t.key.localeCompare(e.key));for(let t=0;e>a;t++)s[t%s.length].cells++,a++;return i}var I="#334155",N="#f8fafc",L="#cbd5e1",W={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"}]},F={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}]},T={viewBox:[40,40],anchor:[.5,.5],parts:[{d:"M23 1L7 23h10l-3 16 19-25H22z",fill:"color"}]},E={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"}]},R="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",P={viewBox:[18,40],anchor:[.5,1],parts:[{d:R,fill:"color",stroke:"color",strokeWidth:1.4}]},O={server:W,chip:F,bolt:T,bus:E,person:P},D="var(--semiotic-primary, #4e79a7)",j="var(--semiotic-border, #d1d5db)";function B(t){return"object"==typeof t&&null!==t&&"tokens"in t&&"encoding"in t}function H(t,e,n){return"function"==typeof t?t(e)??n:t??n}function Y(t,e){return"function"==typeof t?t(e):t}function V(t){return t.sample??t.value??t.index}var X=new Set(k);function q(t,e){return void 0!==e.datum?H(e.datum,t,null):t.datum??null}function G(t,e){return{fill:!1!==t.highlighted?"scenario"===t.range?H(e.rangeColor,t,"var(--semiotic-secondary, #9ca3af)"):H(e.color,t,D):H(e.inactiveColor,t,j),stroke:"none",...Y(e.style,t)??{}}}function K(t,e){const n=Y(e.pointId,t)??(e.idPrefix?`${e.idPrefix}-${"scenario"===t.range?"range-":""}${t.index}`:void 0);return{datum:q(t,e),accessibleDatum:Y(e.accessibleDatum,t),accessibility:Y(e.accessibility,t),pointId:n,_transitionKey:n}}function _({input:t,encoding:e,options:n={}}){if(!B(t)&&!e)throw Error("tokenLayer requires an encoding when input is not a TokenSet.");const o=B(t)?{...t,encoding:l(t.encoding)}:i(t,e),r=function(t,e){const n=e.includeRange&&t.rangeTokens?[...t.tokens,...t.rangeTokens]:t.tokens;if(e.positionToken)return function(t,e){const n=e.positionToken;return n?t.map((e,o)=>{const r=n(e,o,t);return{...e,x:r.x,y:r.y,row:r.row??o,column:r.column??0}}):[]}(n,e);const o=e.layout??t.encoding.layout??"grid";if("quantile-strip"===o)return function(t,e){if(0===t.length)return[];const n=e.x??0,o=e.y??0,r=e.cellHeight??("number"==typeof e.tokenSize?e.tokenSize:12),i=e.gutter??2,a=Math.max(1,Math.floor(e.rows??1)),s=t.map(V),c=Math.min(...s),l=Math.max(...s)-c||1;return t.map((s,u)=>{const h=V(s),d=u%a,f=e.valueToX?e.valueToX(h,s):n+(h-c)/l*(e.width??12*Math.max(1,t.length-1)),m=e.valueToY?e.valueToY(h,s):o+d*(r+i);return{...s,x:f,y:m,row:d,column:u}})}(n,e);if("dotplot"===o)return function(t,e){if(0===t.length)return[];const n=e.x??0,o=e.y??0,r="number"==typeof e.tokenSize?e.tokenSize:12,i=e.gutter??2,a=e.cellWidth??r+i,s=e.cellHeight??r+i,c=t.map(V),l=Math.min(...c),u=Math.max(...c)-l||1,h=new Map;return t.map(r=>{const i=V(r),c=e.valueToX?e.valueToX(i,r):n+(i-l)/u*(e.width??Math.max(1,t.length-1)*a),d=Math.round((c-n)/Math.max(1,a)),f=h.get(d)??0;h.set(d,f+1);const m=e.valueToY?e.valueToY(i,r):o+f*s;return{...r,x:n+d*a,y:m,row:f,column:d}})}(n,e);if("bar-segment"===o){if(!e.valueToX)throw Error('tokenLayer layout "bar-segment" requires valueToX and optionally valueToY.');return function(t,e){if(!e.valueToX)return[];const n=e.y??0,o=e.cellHeight??("number"==typeof e.tokenSize?e.tokenSize:12),r=e.anchor??[.5,.5];return t.map((t,i)=>{const a=Number.isFinite(t.start)?t.start:V(t),s=(a+(Number.isFinite(t.end)?t.end:a+t.value))/2,c=e.valueToY?e.valueToY(s,t):n+r[1]*o;return{...t,x:e.valueToX(s,t),y:c,row:0,column:i}})}(n,e)}if("beeswarm"===o||"small-multiple"===o)throw 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 e.tokenSize?e.tokenSize:void 0,i=e.cellWidth??r??12,a=e.cellHeight??r??i,c="row"===o?Math.max(1,n.length):"column"===o||"stack"===o?1:"waffle"===o&&"fixed-denominator"===t.encoding.countStrategy&&100===t.denominator?10:function(t,e,n){if(e.columns)return e.columns;if(e.width&&n>0){const t=e.gutter??2;return Math.max(1,Math.floor((e.width+t)/(n+t)))}return t.length>0?Math.ceil(Math.sqrt(t.length)):1}(n,e,i);return s(n,{...e,columns:c,cellWidth:i,cellHeight:a})}(o,n).filter(t=>!n.include||n.include(t));return{tokenSet:o,positionedTokens:r,nodes:r.map(t=>function(t,e,n){if("dot"===n.tokenType)return function(t,e){const n=H(e.tokenSize,t,12);return{type:"point",x:t.x,y:t.y,r:H(e.radius,t,n/2),style:G(t,e),...K(t,e)}}(t,e);const o=Y(e.glyph,t)??function(t){if(t)return O[t]}(n.icon);if(o)return function(t,e,n){const o=G(t,n),r=H(n.tokenSize,t,12);return{type:"glyph",x:t.x,y:t.y,size:r,glyph:e,color:(o.fill??D)+"",accent:H(n.accent,t,"var(--semiotic-bg, #ffffff)"),fraction:1>t.fraction?t.fraction:void 0,fractionStart:t.startFraction>0?t.startFraction:void 0,fractionDirection:H(n.fractionDirection,t,"horizontal"),ghostColor:1>t.fraction?Y(n.ghostColor,t)??j:void 0,rotation:Y(n.rotation,t),style:o,...K(t,n)}}(t,o,e);const r=(i=n.icon)&&X.has(i)?i:void 0;var i;return function(t,e){const n=H(e.tokenSize,t,12);return{type:"symbol",x:t.x,y:t.y,size:Math.PI*Math.max(1,n/2)**2,symbolType:H(e.symbolType,t,"circle"),path:Y(e.symbolPath,t),rotation:Y(e.rotation,t),style:G(t,e),...K(t,e)}}(t,r&&null==e.symbolType?{...e,symbolType:r}:e)}(t,n,o.encoding))}}import{interpolateRgb as U}from"d3-interpolate";var Z=864e5,Q=t=>{const e=t.config,{plot:n}=t.dimensions;if(0>=n.width||0>=n.height)return{nodes:[]};const o=t=>{const n="function"==typeof e.dateAccessor?e.dateAccessor(t):t[e.dateAccessor];return n instanceof Date?n:new Date(n)},r=t=>{const n="function"==typeof e.valueAccessor?e.valueAccessor(t):t[e.valueAccessor];return Number(n)},i=new Map;let a=null;for(const e of t.data){const t=o(e);if(!isFinite(t.getTime()))continue;null==a&&(a=t.getUTCFullYear());const n=J(t),s=r(e);i.set(n,(i.get(n)??0)+(Number.isFinite(s)?s:0))}const s=e.year??a??(new Date).getUTCFullYear();let c=1/0,l=-1/0;for(const t of i.values())c>t&&(c=t),t>l&&(l=t);c===1/0&&(c=0,l=0);const[u,h]=e.colorRamp??[t.theme.semantic.surface??"#ebedf0",t.theme.semantic.primary??"#216e39"],d=t=>{if(l===c)return u;const e=(t-c)/(l-c);return U(u,h)(e)},f=e.gutter??2,m=e.labelInset??0,p=Math.min((n.width-m-53*f)/54,(n.height-6*f)/7);if(0>=p)return{nodes:[]};const y=new Date(Date.UTC(s,0,1)),g=y.getUTCDay(),x=new Date(y.getTime()-g*Z),b=[];for(let t=0;54>t;t++)for(let e=0;7>e;e++){const o=new Date(x.getTime()+(7*t+e)*Z);if(o.getUTCFullYear()!==s)continue;const r=J(o),a=i.get(r),c=null==a?u:d(a);b.push({type:"rect",x:n.x+m+t*(p+f),y:n.y+e*(p+f),w:p,h:p,style:{fill:c,stroke:"none"},datum:{date:o,value:a??0}})}return{nodes:b}};function J(t){return`${t.getUTCFullYear()}-${tt(t.getUTCMonth()+1)}-${tt(t.getUTCDate())}`}function tt(t){return 10>t?"0"+t:t+""}import{jsx as et,jsxs as nt}from"react/jsx-runtime";var ot={resource:32,city:64},rt=["#739b58","#83a964","#668d52","#8baa68"],it={land:"#78985c",ocean:"#4d8192",forest:"#4f7c4b",grassland:"#8eaa68",cropland:"#a6a568",wetland:"#668f79",urban:"#8d8a72",scrub:"#9b9665",bare:"#aa906a",snow:"#d8ddcf"},at={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"},st=new Set(["city","culture","monument","faith","nature","knowledge","defense","arena","transport"]);function ct(t,e){if("function"==typeof t)return t;const n=t??e;return t=>t[n]}function lt(t,e,n){return[111.32*(t-n.lon)*Math.cos((e+n.lat)/2*(Math.PI/180)),110.574*(e-n.lat)]}function ut(t){const e=Math.max(3,Math.round(t??5));return e%2==0?e+1:e}function ht(t){return st.has(t)?t:"monument"}function dt(t,e){const n=ut(e.gridSize),o=Math.max(1,e.gridRadiusKm??75),r=2*o/n,i=Math.floor(n/2),a=ct(e.idAccessor,"id"),s=ct(e.nameAccessor,"name"),c=ct(e.longitudeAccessor,"lon"),l=ct(e.latitudeAccessor,"lat"),u=ct(e.kindAccessor,"kind"),h=e.candidatePriorityAccessor?ct(e.candidatePriorityAccessor,"priority"):()=>0,d=new Map;let f=null;for(const m of t){const t=Number(c(m)),p=Number(l(m));if(!Number.isFinite(t)||!Number.isFinite(p))continue;const y=(a(m)??`${t},${p}`)+"",g=(s(m)??y)+"",x=ht(u(m)),[b,w]=lt(t,p,e.center);if(Math.abs(b)>o||Math.abs(w)>o)continue;const M=Math.min(n-1,Math.max(0,Math.floor((b+o)/r))),v=Math.min(n-1,Math.max(0,Math.floor((o-w)/r))),k=(M+.5)*r-o,$=o-(v+.5)*r,A={...m,id:y,name:g,kind:x,lon:t,lat:p,distanceKm:Math.sqrt(b*b+w*w),row:v,column:M,cellDistanceSq:(b-k)**2+(w-$)**2,candidatePriority:Number(h(m))||0};(null!=e.centerId&&y===e.centerId||!f&&"city"===x||!f&&v===i&&M===i)&&(f=A);const S=`${v}:${M}`,C=d.get(S)??[];C.push(A),d.set(S,C)}const m=new Map;f&&m.set("city",1);const p=[];for(let t=0;n>t;t++)for(let e=0;n>e;e++){const n=`tile-${t}-${e}`,a=(e+.5)*r-o,s=o-(t+.5)*r;let c,l;if(t===i&&e===i&&f){c=f;const n=(d.get(`${t}:${e}`)??[]).filter(t=>t.id!==f?.id).sort((t,e)=>t.candidatePriority-e.candidatePriority||t.cellDistanceSq-e.cellDistanceSq||t.name.localeCompare(e.name));l=[f,...n]}else{const n=(d.get(`${t}:${e}`)??[]).filter(t=>t.id!==f?.id);n.sort((t,e)=>{const n=t.candidatePriority-e.candidatePriority;if(0!==n)return n;const o=m.get(t.kind)??0,i=m.get(e.kind)??0,a=r*r*.35;return t.cellDistanceSq+o*a-(e.cellDistanceSq+i*a)||t.name.localeCompare(e.name)}),c=n[0]??null,l=n}c&&m.set(c.kind,(m.get(c.kind)??0)+1),p.push({id:n,row:t,column:e,centerXKm:a,centerYKm:s,terrainIndex:Math.abs((17*t+31*e)%rt.length),landmark:c,landmarks:l})}return p}var ft=t=>{const e=ut(t.config.gridSize),n=Math.max(20,t.config.tileWidth??80),o=Math.max(10,t.config.tileHeight??40),r=t.config.terrainColors?.length?t.config.terrainColors:rt,i=t.dimensions.width/2,a=(t.dimensions.height-e*o)/2+o/2,s=dt(t.points,t.config).map(t=>({...t,x:i+n/2*(t.column-t.row),y:a+(t.column+t.row)*(o/2)}));return{nodes:s.map(e=>{const i=t.config.terrainByCell?.[e.id],a="string"==typeof i?{kind:i}:i,s="city"===e.landmark?.kind?"urban":a?.kind??"land",c=a?.fill??t.config.terrainPalette?.[s]??it[s],l=e.landmark?{...e.landmark,gridRow:e.row,gridColumn:e.column,cellId:e.id,terrainKind:s,terrainCoverage:a?.coverage,features:e.landmarks,featureCount:e.landmarks.length}:{id:e.id,name:at[s],kind:"terrain",terrainKind:s,terrainCoverage:a?.coverage,gridRow:e.row,gridColumn:e.column,cellId:e.id,features:[],featureCount:0};return{type:"geoarea",pathData:(u=e.x,h=e.y,d=n,f=o,`M${u},${h-f/2}L${u+d/2},${h}L${u},${h+f/2}L${u-d/2},${h}Z`),centroid:[e.x,e.y],bounds:[[e.x-n/2,e.y-o/2],[e.x+n/2,e.y+o/2]],screenArea:n*o/2,style:{fill:a||"urban"===s?c:r[e.terrainIndex%r.length],stroke:"ocean"===s?"#315d6c":t.config.tileStroke??"#314934",strokeWidth:1},datum:l,group:e.landmark?.kind??s,interactive:!0};var u,h,d,f}),overlays:et(mt,{tiles:s,tileWidth:n,tileHeight:o,sprites:t.config.sprites,resourceSize:t.config.resourceSpriteSize??32,citySize:t.config.citySpriteSize??64,showCityLabel:!1!==t.config.showCityLabel}),restyle:(t,e)=>e?.isActive&&t.datum&&"terrain"!==t.datum.kind?{fillOpacity:e.predicate(t.datum)?1:.28}:{fillOpacity:1}}};function mt({tiles:t,tileWidth:e,tileHeight:n,sprites:o,resourceSize:r,citySize:i,showCityLabel:a}){const s=v(),c=t.filter(t=>t.landmark).sort((t,e)=>t.y-e.y||t.x-e.x);return nt("g",{"aria-hidden":"true",pointerEvents:"none",children:[c.map(t=>{const a=t.landmark,c="city"===a.kind?i:r,l=t.y+n/2,u=s.isActive&&!s.predicate(a)?.28:1;return nt("g",{opacity:u,children:[et("ellipse",{cx:t.x,cy:t.y+.15*n,rx:.28*c,ry:.1*c,fill:"#17251d",opacity:.32}),et(xt,{kind:a.kind,href:o?.[a.kind],x:t.x-c/2,y:l-c,size:c}),t.landmarks.length>1&&et(pt,{x:t.x+.3*e,y:t.y-.19*n,count:t.landmarks.length-1,tileHeight:n})]},a.id)}),a&&c.filter(t=>"city"===t.landmark?.kind).map(t=>{const e=t.landmark.name.toUpperCase(),o=Math.max(56,6.4*e.length+14);return nt("g",{transform:`translate(${t.x},${t.y+.72*n})`,children:[et("rect",{x:-o/2,y:-7,width:o,height:14,rx:1,fill:"#17251d",opacity:.92}),et("text",{textAnchor:"middle",dominantBaseline:"central",fill:"#f5edcf",fontFamily:"monospace",fontSize:9,fontWeight:700,letterSpacing:.8,children:e})]},t.landmark.id+"-label")})]})}function pt({x:t,y:e,count:n,tileHeight:o}){const r=Math.max(10,Math.min(15,.34*o)),i="+"+n,a=Math.max(r,i.length*r*.58);return nt("g",{transform:`translate(${t},${e})`,children:[et("rect",{x:-a/2,y:-r/2,width:a,height:r,rx:1,fill:"#17251d",stroke:"#f0d36d",strokeWidth:1}),et("text",{textAnchor:"middle",dominantBaseline:"central",fill:"#f5edcf",fontFamily:"monospace",fontSize:Math.max(7,.62*r),fontWeight:700,children:i})]})}var yt={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"]},gt={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"}};function xt({kind:t,href:e,x:n,y:o,size:r}){if(e)return et("image",{href:e,x:n,y:o,width:r,height:r,preserveAspectRatio:"xMidYMax meet",style:{imageRendering:"pixelated"}});const i=gt[t];return et("svg",{x:n,y:o,width:r,height:r,viewBox:"0 0 8 8",shapeRendering:"crispEdges",children:yt[t].flatMap((t,e)=>[...t].map((t,n)=>"."===t?null:et("rect",{x:n,y:e,width:1,height:1,fill:i[t]},`${e}-${n}`)))})}var bt=t=>{const e=t.config,n=e.nodeWidth??80,o=e.nodeHeight??30,r=e.orientation??"vertical",i=e.edgeCurve??"curved",a=!1!==e.showLabels,s=e.labelAccessor??"id",c="function"==typeof s?s:t=>u(t,s,t.id??"")+"",l=new Map,h=[],d=[],f=t=>{const e=t.data??{};return{x:"number"==typeof e.x?e.x:t.x,y:"number"==typeof e.y?e.y:t.y,w:("number"==typeof e.width?e.width:t.width)??n,h:("number"==typeof e.height?e.height:t.height)??o}};for(const n of t.nodes){const{x:o,y:r,w:i,h:s}=f(n);null!=o&&null!=r&&(l.set(n.id,{x:o,y:r,w:i,h:s}),h.push({type:"rect",x:o-i/2,y:r-s/2,w:i,h:s,style:{fill:e.nodeFill??t.resolveColor(n.id),stroke:`var(--semiotic-surface, ${t.theme.semantic.surface??"#fff"})`,strokeWidth:1.5},datum:n,id:n.id,label:c(n)+""}),a&&d.push({x:o,y:r,text:c(n)+"",anchor:"middle",baseline:"middle",fontSize:11}))}const m=[];for(const e of t.edges){const n="string"==typeof e.target?e.target:e.target.id,o=l.get("string"==typeof e.source?e.source:e.source.id),a=l.get(n);if(!o||!a)continue;const s="vertical"===r?{x:o.x,y:o.y+o.h/2}:{x:o.x+o.w/2,y:o.y},c="vertical"===r?{x:a.x,y:a.y-a.h/2}:{x:a.x-a.w/2,y:a.y};if("line"===i)m.push({type:"line",x1:s.x,y1:s.y,x2:c.x,y2:c.y,style:{stroke:`var(--semiotic-border, ${t.theme.semantic.border??"#999"})`,strokeWidth:1},datum:e});else{const n=(s.y+c.y)/2,o=(s.x+c.x)/2;m.push({type:"curved",pathD:"vertical"===r?`M${s.x},${s.y} C${s.x},${n} ${c.x},${n} ${c.x},${c.y}`:`M${s.x},${s.y} C${o},${s.y} ${o},${c.y} ${c.x},${c.y}`,style:{stroke:`var(--semiotic-border, ${t.theme.semantic.border??"#999"})`,strokeWidth:1,fill:"none"},datum:e})}}return{sceneNodes:h,sceneEdges:m,labels:d}},wt=t=>{const e=t.config,n=e.nodeWidth??100,o=e.nodeHeight??36,r=e.edgeStyle??"polyline",i=!1!==e.showLabels,a=e.labelAccessor??"label",s="function"==typeof a?a:t=>u(t,a,t.id??"")+"",c=new Map,l=[],h=[],d=t=>{const e=t.data??{};return{x:"number"==typeof e.x?e.x:t.x,y:"number"==typeof e.y?e.y:t.y,w:("number"==typeof e.width?e.width:t.width)??n,h:("number"==typeof e.height?e.height:t.height)??o}};for(const n of t.nodes){const{x:o,y:r,w:a,h:u}=d(n);null!=o&&null!=r&&(c.set(n.id,{x:o,y:r,w:a,h:u}),l.push({type:"rect",x:o-a/2,y:r-u/2,w:a,h:u,style:{fill:e.nodeFill??t.resolveColor(n.id),stroke:`var(--semiotic-border, ${t.theme.semantic.border??"#888"})`,strokeWidth:1.5},datum:n,id:n.id,label:s(n)+""}),i&&h.push({x:o,y:r,text:s(n)+"",anchor:"middle",baseline:"middle",fontSize:11}))}const f=e.edgeStroke??`var(--semiotic-border, ${t.theme.semantic.border??"#666"})`,m=[];for(const e of t.edges){const t="string"==typeof e.target?e.target:e.target.id,n=c.get("string"==typeof e.source?e.source:e.source.id),o=c.get(t);if(!n||!o)continue;const i=e.data??{},a=Array.isArray(i.points)?i.points:e.points;if(a&&a.length>=2)if("smooth"!==r||3>a.length){const t="M"+a.map(t=>`${t.x},${t.y}`).join(" L ");m.push({type:"curved",pathD:t,style:{stroke:f,strokeWidth:1,fill:"none"},datum:e})}else{let t=`M${a[0].x},${a[0].y}`;for(let e=1;a.length-1>e;e++)t+=` Q${a[e].x},${a[e].y} ${(a[e].x+a[e+1].x)/2},${(a[e].y+a[e+1].y)/2}`;const n=a[a.length-1];t+=` T${n.x},${n.y}`,m.push({type:"curved",pathD:t,style:{stroke:f,strokeWidth:1,fill:"none"},datum:e})}else m.push({type:"line",x1:n.x,y1:n.y,x2:o.x,y2:o.y,style:{stroke:f,strokeWidth:1},datum:e})}return{sceneNodes:l,sceneEdges:m,labels:h}};import{jsx as Mt,jsxs as vt}from"react/jsx-runtime";var kt={"topic-source":"#1f7a8c","topic-sink":"#b4451f","topic-bridge":"#4b5a82",processor:"#34344a",unknown:"#5a5a6a"},$t={internal:"var(--semiotic-border, #6b6b7d)","cross-subtopology":"var(--semiotic-info, #6a8caf)","topic-bridge":"var(--semiotic-secondary, #8b78c4)",back:"var(--semiotic-danger, #e0556b)"};function At(t){return Array.isArray(t)?t.map((t,e)=>"string"==typeof t?{storeName:t,slotIndex:e}:{storeName:(t.storeName??"")+"",slotIndex:t.slotIndex??e}):[]}var St=t=>{const e=t.config||{},n=t.dimensions.plot,o=e.layerAccessor??"x",r=e.rowAccessor??"y",i=e.partitionAccessor??"partition",a=e.semanticAccessor??"semantic",s=e.labelAccessor??"label",c=e.storesAccessor??"stores",l=e.backEdgeAccessor??"isBackEdge",h=e.edgeTypeAccessor??"edgeType",d={...kt,...e.partitionColors},f={...$t,...e.edgeColors},m=e.accentColor??"var(--semiotic-focus, #ffcc33)",p=e.borderColor??"var(--semiotic-border, #555)",y=e.dimOpacity??.14,g=e.edgeOpacity??.5,x=e.edgeWidth??1.25,b=e.backEdgeWidth??e.edgeWidth??1.5,w=!1!==e.showStoreChips,M=e.storeChipColor??"var(--semiotic-info, #6a8caf)";let v=e.layerCount,k=e.maxLayerSize;if(null==v||null==k){let e=0;const n=new Map;for(const r of t.nodes){const t=Math.round(Number(u(r,o,0)));e=Math.max(e,t),n.set(t,(n.get(t)??0)+1)}v=v??e+1,k=k??Math.max(1,...n.values())}const $=n.width/Math.max(1,v),A=n.height/Math.max(1,k);let S=Math.min(e.nodeWidth??172,Math.max(8,$-(e.minGapX??26))),C=Math.min(e.nodeHeight??54,Math.max(8,A-(e.minGapY??18)));const z=e.lod&&"auto"!==e.lod?e.lod:16>S?"dot":48>S?"icon":108>S?"compact":"full";if("dot"===z){const t=Math.min(S,C,11);S=t,C=t}const I=Math.max(1,n.width-S),N=Math.max(1,n.height-C),L=Math.max(1,k-1),W=t=>n.x+S/2+(v>1?t/(v-1):.5)*I,F=t=>n.y+C/2+(t+L/2)/L*N,T=e.reachableIds?new Set(e.reachableIds):null,E=e.selectedId??null,R=t.selection,P=new Map,O=new Map,D=[],j=[];for(const e of t.nodes){const t=e.id,n=Number(u(e,o,0)),l=Number(u(e,r,0)),h=u(e,i,"processor")+"",f=u(e,a,"processor")+"",g=u(e,s,t)+"",x=At(u(e,c,[])),b=e.data??e,w=W(n),M=F(l);P.set(t,{cx:w,cy:M});const v=T?T.has(t):null,k=R?.isActive?R.predicate(b):null,$=null!==v?!v:null!==k&&!k;O.set(t,$);const A=null!=E&&t===E,I=$&&!A?y:1,N=d[h]??d.unknown;"dot"===z?D.push({type:"circle",cx:w,cy:M,r:S/2,style:{fill:N,opacity:I,stroke:A?m:"transparent",strokeWidth:A?2:0},datum:e,id:t,label:g}):(D.push({type:"rect",x:w-S/2,y:M-C/2,w:S,h:C,style:{fill:N,opacity:I,stroke:A?m:p,strokeWidth:A?3:1},datum:e,id:t,label:g}),j.push({id:t,cx:w,cy:M,partition:h,semantic:f,label:g,stores:x,opacity:I,selected:A,node:b}))}const B=[];for(const e of t.edges){const t="string"==typeof e.source?e.source:e.source.id,n="string"==typeof e.target?e.target:e.target.id,o=P.get(t),r=P.get(n);if(!o||!r)continue;const i=!!u(e,l,!1),a=u(e,h,"internal")+"",s=O.get(t)||O.get(n)?Math.min(g,1.4*y):g,c=i?f.back:f[a]??f.internal;let d;if(i){const t=o.cx,e=o.cy+C/2,n=r.cx,i=r.cy+C/2,a=Math.max(48,.28*Math.abs(t-n))+C;d=`M${t},${e} C${t},${e+a} ${n},${i+a} ${n},${i}`}else{const t=o.cx+S/2,e=o.cy,n=r.cx-S/2,i=r.cy,a=(t+n)/2;d=`M${t},${e} C${a},${e} ${a},${i} ${n},${i}`}const m={type:"curved",pathD:d,style:{stroke:c,strokeWidth:i?b:x,fill:"none",opacity:s,...i?{strokeDasharray:"5 4",strokeLinecap:"round"}:{}},datum:e};B.push(m)}const H=0===j.length?null:Mt("g",{className:"lineage-dag-glyphs",children:j.map(t=>function(t,e){const{w:n,h:o,lod:r}=e,i="icon"===r?Math.min(n,o):Math.min(o-14,26),a="icon"===r?0:8+i+8,s=null!=e.renderIcon?e.renderIcon({semantic:t.semantic,partition:t.partition,size:i,color:e.partColors[t.partition]??e.partColors.unknown??"#5a5a6a",node:t.node}):function(t,e,n){const o=e.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"}[t]??"PR";return vt("g",{children:[Mt("rect",{width:n,height:n,rx:4,fill:"rgba(255,255,255,0.08)",stroke:"rgba(255,255,255,0.18)"}),Mt("text",{x:n/2,y:n/2+.5,textAnchor:"middle",dominantBaseline:"middle",fontSize:.42*n,fontWeight:700,fill:"var(--semiotic-text, #fff)",children:o})]})}(t.semantic,t.partition,i),c="full"===r,l="icon"!==r,u="full"===r&&e.showChips&&t.stores.length>0;return vt("g",{transform:`translate(${t.cx-n/2}, ${t.cy-o/2})`,opacity:t.opacity,style:{pointerEvents:"none"},children:[Mt("g",{transform:`translate(${"icon"===r?(n-i)/2:8}, ${(o-i)/2})`,children:s}),l&&Mt("foreignObject",{x:a,y:c?o/2-12:o/2-9,width:Math.max(8,n-a-8),height:18,style:{pointerEvents:"none"},children:Mt("div",{title:t.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:t.label})}),c&&Mt("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:e.typeLabel?e.typeLabel({semantic:t.semantic,partition:t.partition,node:t.node}):t.partition.startsWith("topic")?"topic":t.semantic}),u&&t.stores.map((t,n)=>Mt("rect",{x:a+15*n,y:o-10,width:12,height:5,rx:1.5,fill:e.chipColor,children:Mt("title",{children:t.storeName})},t.storeName+n))]},t.id)}(t,{w:S,h:C,lod:z,partColors:d,chipColor:M,showChips:w,renderIcon:e.renderIcon,typeLabel:e.typeLabel}))});return{sceneNodes:D,sceneEdges:B,overlays:H}};import{jsx as Ct,jsxs as zt}from"react/jsx-runtime";function It(t,e){return t.length>e?t.slice(0,Math.max(1,e-1))+"…":t}var Nt={rect:"process",round:"process",stadium:"terminal",subroutine:"subprocess",cylinder:"database",circle:"connector",diamond:"decision",hexagon:"preparation",flag:"process"};function Lt(t,e,n,o,r,i,a,s){const c=e-o/2,l=n-r/2,u={fill:i,stroke:a,strokeWidth:s};switch(t){case"diamond":return Ct("polygon",{points:`${e},${l} ${e+o/2},${n} ${e},${n+r/2} ${c},${n}`,...u});case"circle":return Ct("circle",{cx:e,cy:n,r:Math.min(o,r)/2,...u});case"stadium":case"round":return Ct("rect",{x:c,y:l,width:o,height:r,rx:"stadium"===t?r/2:8,ry:"stadium"===t?r/2:8,...u});case"hexagon":{const t=Math.min(.18*o,16);return Ct("polygon",{points:`${c+t},${l} ${e+o/2-t},${l} ${e+o/2},${n} ${e+o/2-t},${n+r/2} ${c+t},${n+r/2} ${c},${n}`,...u})}case"cylinder":{const t=Math.min(.16*r,8),e=`M${c},${l+t} a${o/2},${t} 0 0 1 ${o},0`;return zt("g",{children:[Ct("path",{d:`M${c},${l+t} a${o/2},${t} 0 0 0 ${o},0 v${r-2*t} a${o/2},${t} 0 0 1 ${-o},0 z`,...u}),Ct("path",{d:e,fill:"none",stroke:a,strokeWidth:s})]})}case"subroutine":{const t=Math.min(8,.08*o);return zt("g",{children:[Ct("rect",{x:c,y:l,width:o,height:r,rx:3,...u}),Ct("line",{x1:c+t,y1:l,x2:c+t,y2:l+r,stroke:a,strokeWidth:s}),Ct("line",{x1:c+o-t,y1:l,x2:c+o-t,y2:l+r,stroke:a,strokeWidth:s})]})}default:return Ct("rect",{x:c,y:l,width:o,height:r,rx:4,...u})}}var Wt=t=>{const e=t.config||{},n=t.dimensions.plot,o=e.direction??"TD",r="LR"===o||"RL"===o,i="BT"===o||"RL"===o,a=e.layerAccessor??"layer",s=e.rowAccessor??"row",c=e.labelAccessor??"label",l=e.shapeAccessor??"shape",h=e.edgeLabelAccessor??"label",d=e.nodeFill??"var(--semiotic-surface, #20242d)",f=e.nodeStroke??"var(--semiotic-border, #5a6573)",m=e.textColor??"var(--semiotic-text, #e6e6e6)",p=e.edgeColor??"var(--semiotic-text-secondary, #9aa0a6)",y=e.accentColor??"var(--semiotic-warning, #d49a00)";if(0===t.nodes.length)return{sceneNodes:[],overlays:null};const g=new Map;let x=0;for(const e of t.nodes){const t=Math.round(Number(u(e,a,0)));x=Math.max(x,t);const n=g.get(t)||[];n.push(e),g.set(t,n)}const b=x+1;let w=1;for(const t of g.values())t.sort((t,e)=>Number(u(t,s,0))-Number(u(e,s,0))),w=Math.max(w,t.length);const M=r?n.width:n.height,v=r?n.height:n.width,k=M/b,$=v/(w+1),A=Math.max(44,Math.min(e.nodeWidth??150,r?k-36:.92*$)),S=Math.max(26,Math.min(e.nodeHeight??46,r?.7*$:.5*k)),C=(r?A:S)/2+6,z=Math.max(1,M-2*C),I=t=>(r?n.x:n.y)+C+(b>1?(i?b-1-t:t)/(b-1)*z:z/2),N=new Map,L=[],W=[];for(const[t,e]of g)e.forEach((o,i)=>{const a=I(t),s=(r?n.y:n.x)+(i+1)/(e.length+1)*v,h=r?a:s,p=r?s:a,g=u(o,l,"rect")+"",x=u(o,c,o.id)+"";N.set(o.id,{cx:h,cy:p,shape:g}),L.push({type:"rect",x:h-A/2,y:p-S/2,w:A,h:S,style:{fill:"transparent",stroke:"transparent"},datum:{id:o.id,name:x,type:Nt[g]??"process",shape:g},id:o.id,label:x}),W.push(zt("g",{children:[Lt(g,h,p,A,S,d,"diamond"===g?y:f,1.5),Ct("text",{x:h,y:p,textAnchor:"middle",dominantBaseline:"central",fontSize:13,fill:m,style:{pointerEvents:"none"},children:It(x,Math.max(4,Math.floor((A-12)/7)))})]},"n-"+o.id))});const F=[];return t.edges.forEach((t,e)=>{const n="string"==typeof t.target?t.target:t.target.id,o=N.get("string"==typeof t.source?t.source:t.source.id),i=N.get(n);if(!o||!i)return;const a=r?o.cx+A/2:o.cx,s=r?o.cy:o.cy+S/2,c=r?i.cx-A/2:i.cx,l=r?i.cy:i.cy-S/2,d=r?`M${a},${s} C${(a+c)/2},${s} ${(a+c)/2},${l} ${c},${l}`:`M${a},${s} C${a},${(s+l)/2} ${c},${(s+l)/2} ${c},${l}`,y=Math.atan2(l-s,c-a),g=c-9*Math.cos(y),x=l-9*Math.sin(y),b=4.5*-Math.sin(y),w=4.5*Math.cos(y),M=`${c},${l} ${g+b},${x+w} ${g-b},${x-w}`,v=u(t,h,void 0),k=(a+c)/2,$=(s+l)/2;F.push(zt("g",{children:[Ct("path",{d:d,fill:"none",stroke:p,strokeWidth:1.4}),Ct("polygon",{points:M,fill:p}),"string"==typeof v&&v.length>0&&zt("g",{children:[Ct("rect",{x:k-6.5*v.length/2-4,y:$-9,width:6.5*v.length+8,height:18,rx:3,fill:"var(--semiotic-bg, #11151c)",stroke:f,strokeWidth:.75}),Ct("text",{x:k,y:$,textAnchor:"middle",dominantBaseline:"central",fontSize:11,fill:m,style:{pointerEvents:"none"},children:v})]})]},"e-"+e))}),{sceneNodes:L,overlays:zt("g",{className:"mermaid-dag",children:[F,W]})}};import{jsx as Ft,jsxs as Tt}from"react/jsx-runtime";function Et(t){return Ft("rect",{className:t.className,x:t.x,y:t.y,width:Math.max(0,t.width),height:Math.max(0,t.height),rx:t.radius??10,ry:t.radius??10,fill:t.fill??"none",stroke:t.stroke,strokeWidth:t.strokeWidth??1.5,strokeDasharray:t.strokeDasharray,opacity:t.opacity??.6,style:{pointerEvents:"none"}},t.keyId)}function Rt(t,e=0){let n=1/0,o=1/0,r=-1/0,i=-1/0;for(const e of t){const t=e.r??0;n>e.x-t&&(n=e.x-t),e.x+t>r&&(r=e.x+t),o>e.y-t&&(o=e.y-t),e.y+t>i&&(i=e.y+t)}return Number.isFinite(n)?{x:n-e,y:o-e,width:r-n+2*e,height:i-o+2*e}:null}function Pt(t,e=0){if(!t.length)return null;const n="number"==typeof e?e:e.x??0,o="number"==typeof e?e:e.y??0;let r=1/0,i=1/0,a=-1/0,s=-1/0;for(const e of t){if(!Number.isFinite(e.x)||!Number.isFinite(e.y))continue;if(!Number.isFinite(e.width)||!Number.isFinite(e.height))continue;const t=Math.max(0,e.width),n=Math.max(0,e.height);r>e.x&&(r=e.x),i>e.y&&(i=e.y),e.x+t>a&&(a=e.x+t),e.y+n>s&&(s=e.y+n)}return Number.isFinite(r)?{x:r-n,y:i-o,width:a-r+2*n,height:s-i+2*o}:null}function Ot(t){const e=t.fontSize??12;return null!=t.maxWidth&&t.text.length*e*.56>t.maxWidth?null:Ft("text",{className:t.className,x:t.x,y:t.y,textAnchor:t.anchor??"middle",dominantBaseline:t.baseline??"middle",fontSize:e,fontWeight:t.fontWeight,fill:t.color,style:{pointerEvents:"none"},children:t.text},t.keyId)}function Dt(t){const e=t.spacing??8;return{def:Ft("pattern",{id:t.id,width:e,height:e,patternUnits:"userSpaceOnUse",patternTransform:`rotate(${t.angle??45})`,children:Ft("line",{x1:0,y1:0,x2:0,y2:e,stroke:t.color??"currentColor",strokeWidth:t.strokeWidth??1,opacity:t.opacity??.5})},t.id),fill:`url(#${t.id})`}}function jt(t){const e=t.orient??"bottom",n="bottom"===e||"top"===e,o=t.offset??0,r=t.tickLength??6,i=t.gridLength??0,a=t.labelGap??4,s=t.fontSize??11,c=t.color??"var(--semiotic-text-secondary, #888)",l=t.gridColor??c,u=t.format??(t=>t+""),h="top"===e||"left"===e?-1:1,d=t.ticks.length-1,f=t.ticks.map((f,m)=>{const p=t.scale(f),y=o+h*r,g=o-h*i,x=y+h*a;let b;b=t.labelAnchor?t.labelAnchor:n?t.edgeAnchor&&0===m?"start":t.edgeAnchor&&m===d?"end":"middle":"left"===e?"end":"start";const w=n?"top"===e?"auto":"hanging":"middle",M=n?{x:p,y:x}:{x:x,y:p};return Tt("g",{children:[(r>0||i>0)&&Ft("line",{...n?{x1:p,x2:p,y1:y,y2:g}:{x1:y,x2:g,y1:p,y2:p},stroke:i>0?l:c,strokeWidth:1,strokeDasharray:i>0?t.gridDasharray:void 0,opacity:i>0?.7:1}),Ft("text",{x:M.x,y:M.y,textAnchor:b,dominantBaseline:w,fontSize:s,fontWeight:t.fontWeight,fill:c,children:u(f)})]},`tick-${f}-${m}`)});return Ft("g",{className:t.className,style:{pointerEvents:"none"},children:f},t.keyId)}function Bt(t){const e=t.stroke??"var(--semiotic-text, #f4f4f8)",n=t.strokeWidth??1,o=t.markRadius??0,r=t.labelX-t.markX,i=t.labelY-t.markY,a=Math.hypot(r,i)||1,s=t.markX+r/a*o,c=t.markY+i/a*o;let l;return l="elbow"===t.connector?`M${s},${c} L${s},${t.labelY} L${t.labelX},${t.labelY}`:"curve"===t.connector?`M${s},${c} Q${(s+t.labelX)/2},${c} ${t.labelX},${t.labelY}`:`M${s},${c} L${t.labelX},${t.labelY}`,Tt("g",{className:t.className,style:{pointerEvents:"none"},children:[o>0&&Ft("circle",{cx:t.markX,cy:t.markY,r:o,fill:"none",stroke:e,strokeWidth:n}),Ft("path",{d:l,fill:"none",stroke:e,strokeWidth:n}),Ft("text",{x:t.labelX,y:t.labelY,textAnchor:t.labelAnchor??"middle",dominantBaseline:t.labelBaseline??"hanging",fontSize:t.fontSize??11,fontWeight:t.fontWeight,fill:t.color??e,children:t.label})]},t.keyId)}import{jsx as Ht,jsxs as Yt}from"react/jsx-runtime";var Vt=new t(12);function Xt(t){if(null==t)return NaN;if("number"==typeof t)return t;if(t instanceof Date)return t.getTime();const e=t+"",n=Number(e);if(!Number.isNaN(n)&&""!==e.trim())return n;const o=Date.parse(e);return Number.isNaN(o)?NaN:o}function qt(t,e,n){return e>t?e:t>n?n:t}var Gt=t=>{const e=t.config||{},n=t.dimensions.plot,r=e.columnAccessor??"column",i=e.rowAccessor??"row",s=e.sizeAccessor,l=e.colorAccessor,h=e.symbolAccessor,f=e.shadeAccessor,m=e.markerAccessor,p=e.iconAccessor,y=e.defaultSymbol??"circle",[g,x]=e.sizeRange??[2,8],b=e.shadeStrength??.72,w=e.shadeReverse??!1,M=e.rowMode??"banded",v=e.cellSizing??"proportional",S=e.proportionExponent??1,C=e.columnGap??16,z=e.rowGap??12,I=e.packPadding??1,N=e.iterations??12,L=!1!==e.showEnclosures,W=!1!==e.showColumnHeaders,F=!1!==e.showRowLabels,T=W?e.headerHeight??26:0,E=F?e.labelWidth??66:0,R=e.callouts&&e.callouts.length>0?e.footerHeight??30:0,P=n.x+E,O=n.y+T,D=Math.max(1,n.width-E),j=Math.max(1,n.height-T-R),B=[];for(const e of t.nodes){const t=e.data??e;B.push({id:e.id,col:u(e,r,"—")+"",row:u(e,i,"—")+"",sizeVal:s?Number(u(e,s,1)):1,colorKey:l?u(e,l,"")+"":"",symVal:h?u(e,h,"")+"":"",shadeVal:f?Xt(u(e,f,null)):NaN,marker:!!m&&!!u(e,m,!1),iconVal:p?u(e,p,"")+"":"",datum:t,size:0,packR:0,baseShape:"circle",iconShape:null})}if(0===B.length)return{sceneNodes:[]};let H=1/0,Y=-1/0;if(s)for(const t of B)Number.isFinite(t.sizeVal)&&(H>t.sizeVal&&(H=t.sizeVal),t.sizeVal>Y&&(Y=t.sizeVal));e.sizeDomain&&([H,Y]=e.sizeDomain),Number.isFinite(H)&&Number.isFinite(Y)||(H=0,Y=1);const V=t=>{if(H>=Y)return(g+x)/2;const e=Math.sqrt(qt((t-H)/(Y-H),0,1));return g+e*(x-g)};let X=1/0,q=-1/0;if(f)for(const t of B)Number.isFinite(t.shadeVal)&&(X>t.shadeVal&&(X=t.shadeVal),t.shadeVal>q&&(q=t.shadeVal));e.shadeDomain&&([X,q]=e.shadeDomain);const G=t=>{if(!f||!Number.isFinite(t)||X>=q)return.5;const e=qt((t-X)/(q-X),0,1);return w?1-e:e},K=e.colorMap,_=new Map,U=(e,n)=>{let o=_.get(e);if(!o){const n=K&&K[e]||t.resolveColor(e);o=c(n,b),_.set(e,o)}return o(n)},Z=new Map;if(e.symbolMap)for(const[t,n]of Object.entries(e.symbolMap))Z.set(t,n);let Q=0;const J=e.iconMap,tt=t=>p&&J&&J[t]?J[t]:null,et=t=>p?"circle":(t=>{if(!h)return y;let e=Z.get(t);return e||(e=k[Q%k.length],Q++,Z.set(t,e)),e})(t.symVal),nt=e.maxAreaFraction??.4;let ot=0;const rt=Array(B.length),it=Array(B.length);for(let t=0;B.length>t;t++){const e=B[t],n=V(e.sizeVal);rt[t]=n,e.baseShape=et(e),e.iconShape=tt(e.iconVal);const o=$(e.baseShape,Math.PI*n*n);it[t]=o,ot+=Math.PI*o*o}const at=nt*D*j,st=ot>at?Math.sqrt(at/ot):1;for(let t=0;B.length>t;t++){const e=B[t],n=rt[t]*st;e.size=Math.PI*n*n,e.packR=it[t]*st}const ct=new Map,lt=new Map;for(const t of B)ct.set(t.col,(ct.get(t.col)??0)+1),lt.set(t.row,(lt.get(t.row)??0)+1);const ut=e.columnOrder?.filter(t=>ct.has(t))??[...ct.keys()].sort((t,e)=>(ct.get(e)??0)-(ct.get(t)??0)),ht=e.rowOrder?.filter(t=>lt.has(t))??[...lt.keys()].sort((t,e)=>(lt.get(e)??0)-(lt.get(t)??0)),dt=d([Math.round(n.x),Math.round(n.y),Math.round(n.width),Math.round(n.height),T,E,R,M,v,S,C,z,I,N,g,x,H,Y,nt,ut.join(","),ht.join(","),B.length,_t(B)]),ft=Vt.getOrCompute(dt,()=>function(t,e){const n=new Map;for(const e of t){let t=n.get(e.col);t||(t=[],n.set(e.col,t)),t.push(e)}const o=e.columnOrder.filter(t=>n.has(t)),r=Math.max(1,e.innerW-e.columnGap*Math.max(0,o.length-1)),i=e.proportionExponent,s=o.map(t=>Math.pow(n.get(t).length,i)),c=s.reduce((t,e)=>t+e,0)||1,l=t=>"uniform"===e.cellSizing?r/o.length:s[t]/c*r,u=new Map,h=[];let d=e.innerX;for(let t=0;o.length>t;t++)h.push({col:o[t],x:d,w:l(t)}),d+=l(t)+e.columnGap;let f=1;const m=new Map,p=[],y=(t,e,n,o)=>{let r=m.get(t);r||(r={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},m.set(t,r)),r.minX>e-o&&(r.minX=e-o),e+o>r.maxX&&(r.maxX=e+o),r.minY>n-o&&(r.minY=n-o),n+o>r.maxY&&(r.maxY=n+o)},g=(t,n,o,r,i,a)=>{const s=t.map(t=>({id:t.id,r:t.packR})),c=function(t,e,n,o,r,i,a,s){const c=e+o/2,l=n+r/2,u=new Map,h=t.length;if(0===h)return u;if(1===h)return u.set(t[0].id,{px:c,py:l}),u;const d=function(t){let e=t>>>0||1;return()=>(e=Math.imul(e,1664525)+1013904223>>>0,e/4294967296)}(s),f=new Float64Array(h);let m=0;for(let e=0;h>e;e++)f[e]=t[e].r+i,f[e]>m&&(m=f[e]);const p=Math.max(1,Math.round(Math.sqrt(h*o/Math.max(1,r)))),y=new Float64Array(h),g=new Float64Array(h),x=o/p,b=r/Math.ceil(h/p);for(let t=0;h>t;t++){const o=t%p,r=Math.floor(t/p);y[t]=e+(o+.3+.4*d())*x,g[t]=n+(r+.3+.4*d())*b}const w=Math.max(0,Math.min(a,14)),M=Math.max(1,2*m),v=new Map,k=Math.max(1,Math.ceil(o/M)+3),$=(t,e)=>(e+1)*k+(t+1);for(let t=0;w>t;t++){v.clear();for(let t=0;h>t;t++){const o=$(Math.floor((y[t]-e)/M),Math.floor((g[t]-n)/M)),r=v.get(o);r?r.push(t):v.set(o,[t])}for(let t=0;h>t;t++){const o=Math.floor((y[t]-e)/M),r=Math.floor((g[t]-n)/M);for(let e=-1;1>=e;e++)for(let n=-1;1>=n;n++){const i=v.get($(o+e,r+n));if(i)for(let e=0;i.length>e;e++){const n=i[e];if(t>=n)continue;let o=y[n]-y[t],r=g[n]-g[t];const a=f[t]+f[n],s=o*o+r*r;if(a*a>s)if(s>1e-9){const e=Math.sqrt(s),i=(a-e)/2;o/=e,r/=e,y[t]-=o*i,g[t]-=r*i,y[n]+=o*i,g[n]+=r*i}else{const e=2.39996323*t;y[t]+=Math.cos(e)*f[t],g[t]+=Math.sin(e)*f[t]}}}}for(let t=0;h>t;t++){const i=f[t],a=e+i,s=e+o-i,u=n+i,h=n+r-i;y[t]=s>a?qt(y[t],a,s):c,g[t]=h>u?qt(g[t],u,h):l}}for(let e=0;h>e;e++)u.set(t[e].id,{px:y[e],py:g[e]});return u}(s,n,o,r,i,e.packPadding,e.iterations,f++);let l=1/0,h=1/0,d=-1/0,m=-1/0;for(const t of s){const e=c.get(t.id);u.set(t.id,{px:e.px,py:e.py}),y(a,e.px,e.py,t.r),l>e.px-t.r&&(l=e.px-t.r),e.px+t.r>d&&(d=e.px+t.r),h>e.py-t.r&&(h=e.py-t.r),e.py+t.r>m&&(m=e.py+t.r)}return Number.isFinite(l)?{x:l-Kt,y:h-Kt,w:d-l+2*Kt,h:m-h+2*Kt}:null};if("banded"===e.rowMode){const r=new Map;for(const e of t)r.set(e.row,(r.get(e.row)??0)+1);const s=e.rowOrder.filter(t=>r.has(t)),c=Math.max(1,e.innerH-e.rowGap*Math.max(0,s.length-1)),l=s.map(t=>Math.pow(r.get(t),i)),d=l.reduce((t,e)=>t+e,0)||1,f=new Map;let p=e.innerY+e.innerH;for(let t=0;s.length>t;t++){const n="uniform"===e.cellSizing?c/s.length:l[t]/d*c,o=p-n;f.set(s[t],{y:o,h:n}),p=o-e.rowGap}o.forEach((t,e)=>{const o=a(n.get(t),t=>t.row);for(const t of s){const n=o.get(t),r=f.get(t);n&&r&&g(n,h[e].x,r.y,h[e].w,r.h,t)}});const y=[],x=new Map;for(const t of s){const e=f.get(t);x.set(t,e.y+e.h/2);const n=m.get(t);n&&Number.isFinite(n.minX)&&y.push({x:n.minX-Kt,y:n.minY-Kt,w:n.maxX-n.minX+2*Kt,h:n.maxY-n.minY+2*Kt})}return{positions:u,enclosures:y,colBands:h,rowLabelY:x}}const x=new Map;o.forEach((t,o)=>{const r=a(n.get(t),t=>t.row),s=e.rowOrder.filter(t=>r.has(t)),c=Math.max(1,e.innerH-e.rowGap*Math.max(0,s.length-1)),l=s.map(t=>Math.pow(r.get(t).length,i)),u=l.reduce((t,e)=>t+e,0)||1;let d=e.innerY+e.innerH;s.forEach((t,n)=>{const i="uniform"===e.cellSizing?c/s.length:l[n]/u*c,a=d-i,f=g(r.get(t),h[o].x,a,h[o].w,i,t);if(f){p.push(f);const e=x.get(t)??{sum:0,n:0};e.sum+=f.y+f.h/2,e.n+=1,x.set(t,e)}d=a-e.rowGap})});const b=new Map;for(const[t,e]of x)b.set(t,e.sum/e.n);return{positions:u,enclosures:p,colBands:h,rowLabelY:b}}(B,{columnOrder:ut,rowOrder:ht,innerX:P,innerY:O,innerW:D,innerH:j,rowMode:M,cellSizing:v,proportionExponent:S,columnGap:C,rowGap:z,packPadding:I,iterations:N})),mt=t.selection,pt=mt?.isActive?mt.predicate:null,yt=e.highlight??null,gt=e.dimOpacity??.16,xt=e.markStroke,bt=e.markStrokeWidth??0,wt=e.markerColor??"#ffffff",Mt=e.iconColor??"rgba(255,255,255,0.92)",vt=e.iconStrokeWidth??1,kt=e.iconScale??.72,$t=[],At=[],St=[];for(const t of B){const e=ft.positions.get(t.id);if(!e)continue;const n=o(t.datum,{highlight:yt,predicate:pt,dimOpacity:gt}),r={type:"symbol",cx:e.px,cy:e.py,size:t.size,symbolType:t.baseShape,style:{fill:U(t.colorKey,G(t.shadeVal)),opacity:n,...xt?{stroke:xt,strokeWidth:bt}:{}},datum:t.datum,id:t.id,label:t.id+""};if($t.push(r),t.iconShape){const o=Math.sqrt(t.size/Math.PI)*kt,r=$(t.iconShape,100);St.push({x:e.px,y:e.py,size:r>0?o/r*100*(o/r):Math.PI*o*o,shape:t.iconShape,opacity:n})}t.marker&&n>gt+.001&&At.push({x:e.px,y:e.py,r:Math.max(1,.4*Math.sqrt(t.size/Math.PI))})}const Ct=[];if(e.callouts&&e.callouts.length>0){const t=e.calloutColor??"var(--semiotic-text, #f4f4f8)",o=n.y+n.height-(R>0?.45*R:9),r=[];for(let t=0;e.callouts.length>t;t++){const n=e.callouts[t],o=B.find(t=>t.datum[n.field]+""==n.value+"");if(!o)continue;const i=ft.positions.get(o.id);i&&r.push({c:n,ci:t,px:i.px,py:i.py,markR:Math.sqrt(o.size/Math.PI)})}const i=r.filter(t=>null==t.c.at).sort((t,e)=>t.px-e.px),a=new Map;i.forEach((t,e)=>{a.set(t.ci,P+(e+.5)/i.length*D)});for(const e of r){const r=e.c;let i=a.get(e.ci)??e.px,s=o;const c=r.connector??(a.has(e.ci)?"elbow":"straight");"object"==typeof r.at&&r.at?(i=r.at.x,s=r.at.y):"number"==typeof r.at&&(s=n.y+r.at*n.height),Ct.push({keyId:"callout-"+e.ci,markX:e.px,markY:e.py,labelX:i,labelY:s,label:r.label,connector:c,markRadius:Math.max(e.markR+3,7),stroke:t,color:t,fontSize:11,labelAnchor:"middle",labelBaseline:"auto"})}}const zt=function(t,e){const n=e.columnLabel??(t=>t),o=e.rowLabel??(t=>t);return Yt("g",{className:"packed-cluster-matrix-chrome",style:{pointerEvents:"none"},children:[e.showEnclosures&&t.enclosures.map((t,n)=>Et({keyId:"enc-"+n,x:t.x,y:t.y,width:t.w,height:t.h,radius:e.enclosureRadius,stroke:e.enclosureColor,strokeWidth:e.enclosureWidth,opacity:e.enclosureOpacity})),e.iconMarks.length>0&&Ht("g",{className:"packed-cluster-matrix-icons",children:e.iconMarks.map((t,n)=>Ht("path",{d:A(t.shape,t.size),transform:`translate(${t.x},${t.y})`,fill:"none",stroke:e.iconColor,strokeWidth:e.iconStrokeWidth,opacity:t.opacity},"ic-"+n))}),e.markerDots.length>0&&Ht("g",{className:"packed-cluster-matrix-markers",children:e.markerDots.map((t,n)=>Ht("circle",{cx:t.x,cy:t.y,r:t.r,fill:e.markerColor},"mk-"+n))}),e.showColumnHeaders&&t.colBands.map((t,o)=>Ot({keyId:"col-"+o,text:n(t.col),x:t.x+t.w/2,y:e.headerY,anchor:"middle",fontSize:e.headerFontSize,fontWeight:700,color:e.headerColor})),e.showRowLabels&&[...t.rowLabelY].map(([t,n])=>Ot({keyId:"row-"+t,text:o(t),x:e.labelX,y:n,anchor:"end",fontSize:e.labelFontSize,fontWeight:600,color:e.labelColor})),e.callouts.map(t=>Bt(t))]})}(ft,{markerDots:At,markerColor:wt,iconMarks:St,iconColor:Mt,iconStrokeWidth:vt,callouts:Ct,plot:n,showEnclosures:L,showColumnHeaders:W,showRowLabels:F,enclosureColor:e.enclosureColor??"var(--semiotic-text, #f4f4f8)",enclosureRadius:e.enclosureRadius??9,enclosureOpacity:e.enclosureOpacity??.5,enclosureWidth:e.enclosureWidth??1.5,headerColor:e.headerColor??"var(--semiotic-text, #f4f4f8)",labelColor:e.labelColor??"var(--semiotic-text-secondary, #b9b9c8)",headerFontSize:e.headerFontSize??13,labelFontSize:e.labelFontSize??11,headerY:n.y+.62*T,labelX:n.x+E-10,columnLabel:e.columnLabel,rowLabel:e.rowLabel});return{sceneNodes:$t,overlays:zt}},Kt=4;function _t(t){let e=2166136261;const n=t=>{for(let n=0;t.length>n;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619)};for(const o of t)n(o.id),n(o.col),n(o.row),e^=Math.round(8*o.packR),e=Math.imul(e,16777619);return(e>>>0).toString(36)}import*as Ut from"react";var Zt=t=>{const n=t.config,{plot:o}=t.dimensions;if(0>=o.width||0>=o.height)return{nodes:[]};const r=h(n.categoryAccessor),i=h(n.stackBy),a=t=>{const e="function"==typeof n.valueAccessor?n.valueAccessor(t):t[n.valueAccessor],o=Number(e);return Number.isFinite(o)&&o>0?o:0},s=n.gutter??2,c="string"==typeof n.categoryAccessor?n.categoryAccessor:"category",l="string"==typeof n.stackBy?n.stackBy:"stack",u="string"==typeof n.valueAccessor?n.valueAccessor:"value",d=(t,n,o)=>e(e=>{e("category",t),e("stack",n),e("value",o),"category"!==c&&e(c,t),"stack"!==l&&e(l,n),"value"!==u&&e(u,o)}),f=!1!==n.showCategoryLabels,m=Math.max(0,o.height-(n.labelPadding??(f?22:0))),p=[],y=new Map,g=[],x=new Set,b=new Map;for(const e of t.data){const t=r(e)+"",n=i(e)+"",o=a(e);y.has(t)||(p.push(t),y.set(t,0),b.set(t,new Map)),x.has(n)||(x.add(n),g.push(n)),y.set(t,(y.get(t)??0)+o);const s=b.get(t);s.set(n,(s.get(n)??0)+o)}const w=n.categoryOrder?Qt(n.categoryOrder,p,t=>y.has(t)):p,M=n.stackOrder?Qt(n.stackOrder,g,()=>!0):g,v=w.reduce((t,e)=>t+(y.get(e)??0),0);if(0>=v)return{nodes:[]};const k=Math.max(0,o.width-s*Math.max(0,w.length-1)),$=[],A=[];let S=o.x;for(const e of w){const n=y.get(e)??0,r=n/v*k;if(0>=r)continue;A.push({cat:e,x:S,w:r});const i=b.get(e);let a=o.y;for(const o of M){const s=i.get(o)??0;if(0>=s)continue;const c=s/n*m;$.push({type:"rect",x:S,y:a,w:r,h:c,style:{fill:t.resolveColor(o),stroke:"none"},datum:d(e,o,s),group:o}),a+=c}S+=r+s}return{nodes:$,overlays:f&&A.length>0?function(t,e,n){const o=t.map((t,o)=>Ot({keyId:"marimekko-label-"+o,text:t.cat,x:t.x+t.w/2,y:e+12,anchor:"middle",baseline:"auto",maxWidth:t.w-4,fontSize:12,color:n}));return Ut.createElement(Ut.Fragment,null,...o)}(A,o.y+m+4,`var(--semiotic-text, ${t.theme.semantic.text??"currentColor"})`):null}};function Qt(t,e,n){const o=new Set,r=[];for(const e of t)n(e)&&!o.has(e)&&(o.add(e),r.push(e));for(const t of e)o.has(t)||r.push(t);return r}import*as Jt from"react";var te=t=>{const n=t.config,{plot:o}=t.dimensions;if(0>=o.width||0>=o.height||0===t.data.length)return{nodes:[]};const r=n.rowHeight??28,i=n.rowGap??12,a=!1!==n.showLabels,s=a?n.labelWidth??120:0,c=!1!==n.showTicks,l=c?14:0,u=n.tickFormat??(t=>t.toLocaleString()),d=o.x+s,f=Math.max(0,o.width-s);if(0>=f)return{nodes:[]};const m=h(n.categoryAccessor),p=t=>{const e=Number(t);return Number.isFinite(e)&&e>0?e:0},y=t=>p("function"==typeof n.valueAccessor?n.valueAccessor(t):t[n.valueAccessor]),g=t=>p("function"==typeof n.targetAccessor?n.targetAccessor(t):t[n.targetAccessor]),x=t=>{const e="function"==typeof n.rangesAccessor?n.rangesAccessor(t):t[n.rangesAccessor];return Array.isArray(e)?e.map(p).sort((t,e)=>t-e):[]},b="string"==typeof n.categoryAccessor?n.categoryAccessor:"metric",w="string"==typeof n.valueAccessor?n.valueAccessor:"value",M="string"==typeof n.targetAccessor?n.targetAccessor:"target",v=n.actualColor??t.theme.semantic.primary??"#3b6cb1",k=t.theme.semantic.text??"currentColor",$=n.targetColor??`var(--semiotic-text, ${k})`,A=[`var(--semiotic-surface, ${t.theme.semantic.surface??"#e8eaed"})`,`var(--semiotic-grid, ${t.theme.semantic.grid??"#cdd1d6"})`,`var(--semiotic-border, ${t.theme.semantic.border??"#a3a8af"})`],S=`var(--semiotic-text, ${k})`,C=`var(--semiotic-text-secondary, ${t.theme.semantic.textSecondary??"#888"})`,z=[],I=[];for(let n=0;t.data.length>n;n++){const a=t.data[n],s=x(a),c=y(a),u=g(a),h=Math.max(c,u,...s.length?s:[0]);if(0>=h)continue;const p=o.y+n*(r+i+l);if(p+r+l>o.y+o.height)break;I.push({yTop:p,label:m(a),actual:c,target:u,maxVal:h});const k=t=>d+t/h*f,S=m(a),C=t=>e(e=>{e("metric",S),"metric"!==b&&e(b,S),t(e)});let N=d;for(let t=0;s.length>t;t++){const e=k(s[t]),n=e-N;n>0&&z.push({type:"rect",x:N,y:p,w:n,h:r,style:{fill:A[Math.min(t,A.length-1)],stroke:"none"},datum:C(e=>{e("range",t),e("rangeValue",s[t]),e("kind","range")}),group:"range-"+t}),N=e}const L=Math.max(6,Math.floor(.45*r));z.push({type:"rect",x:d,y:p+(r-L)/2,w:k(c)-d,h:L,style:{fill:v,stroke:"none"},datum:C(t=>{t("value",c),t("kind","actual"),"value"!==w&&t(w,c)}),group:"actual"});const W=3,F=Math.floor(.8*r);z.push({type:"rect",x:k(u)-W/2,y:p+(r-F)/2,w:W,h:F,style:{fill:$,stroke:"none"},datum:C(t=>{t("target",u),t("kind","target"),"target"!==M&&t(M,u)}),group:"target"})}const N=[];for(let t=0;I.length>t;t++){const e=I[t];if(a&&N.push(Ot({keyId:"bullet-label-"+t,text:e.label,x:o.x+s-8,y:e.yTop+r/2,anchor:"end",baseline:"middle",fontSize:13,fontWeight:500,color:S})),c){const n=5,o=e.yTop+r+2;for(let r=0;n>r;r++){const i=e.maxVal*r/(n-1),a=d+i/e.maxVal*f;N.push(Jt.createElement("line",{key:`bullet-tick-${t}-${r}`,x1:a,x2:a,y1:o,y2:o+3,stroke:C,strokeWidth:1}),Ot({keyId:`bullet-ticktext-${t}-${r}`,text:u(i),x:a,y:o+12,anchor:0===r?"start":r===n-1?"end":"middle",baseline:"auto",fontSize:10,color:C}))}}}return{nodes:z,overlays:N.length>0?Jt.createElement(Jt.Fragment,null,...N):null}};import*as ee from"react";import{scaleLinear as ne}from"d3-scale";var oe=t=>{const e=t.config,{plot:n}=t.dimensions,r=e.fields??[];if(2>r.length||0>=n.width||0>=n.height)return{nodes:[]};if(0===t.data.length)return{nodes:[]};const i={};for(const n of r){if(e.domains?.[n]){i[n]=e.domains[n];continue}let o=1/0,r=-1/0;for(const e of t.data){const t=Number(e[n]);Number.isFinite(t)&&(o>t&&(o=t),t>r&&(r=t))}i[n]=Number.isFinite(o)&&Number.isFinite(r)&&o!==r?[o,r]:[0,1]}const a=!1!==e.showAxes,s=a?e.axisLabelPadding??24:8,c=a?18:8,l=r.map(t=>ne().domain(i[t]).range([n.y+n.height-c,n.y+s])),u=r.map((t,e)=>1===r.length?n.x+n.width/2:n.x+e/(r.length-1)*n.width),h=e.colorBy?"function"==typeof e.colorBy?e.colorBy:t=>(t[e.colorBy]??"")+"":null,d=e.opacity??.45,f=e.strokeWidth??1.25,m=t.theme.semantic.primary??"#3b6cb1",p=e.dimmedOpacity??.08,y=e.highlightFn,g=[],x=[];for(const n of t.data){const i=h?t.resolveColor(h(n)+""):m,a=!y||y(n),s=o(n,{predicate:y,baseOpacity:d,dimOpacity:p,brighten:.4}),c=a?x:g;for(let t=0;r.length-1>t;t++){const e=Number(n[r[t]]),o=Number(n[r[t+1]]);if(!Number.isFinite(e)||!Number.isFinite(o))continue;const h={type:"connector",x1:u[t],y1:l[t](e),x2:u[t+1],y2:l[t+1](o),style:{stroke:i,strokeWidth:y&&a?f+.75:f,opacity:s,fill:"none"},datum:n};c.push(h)}if(e.showPoints)for(let t=0;r.length>t;t++){const e=Number(n[r[t]]);if(!Number.isFinite(e))continue;const o={type:"point",x:u[t],y:l[t](e),r:2.5,style:{fill:i,stroke:"none",opacity:Math.min(1,s+.3)},datum:n};c.push(o)}}let b=null;if(a){const o=`var(--semiotic-border, ${t.theme.semantic.border??"#aaa"})`,a=`var(--semiotic-text, ${t.theme.semantic.text??"currentColor"})`,h=`var(--semiotic-text-secondary, ${t.theme.semantic.textSecondary??"#888"})`,d=n.y+s,f=n.y+n.height-c,m=[];for(let t=0;r.length>t;t++){const c=r[t],p=u[t],y=e.tickFormat?.[c]??(t=>t.toLocaleString());m.push(ee.createElement("line",{key:"pc-axis-line-"+t,x1:p,x2:p,y1:d,y2:f,stroke:o,strokeWidth:1})),m.push(Ot({keyId:"pc-axis-label-"+t,text:c,x:p,y:n.y+s-8,anchor:"middle",baseline:"auto",fontSize:12,fontWeight:600,color:a}));const[g,x]=i[c],b=5;for(let e=0;b>e;e++){const n=g+(x-g)*e/(b-1),r=l[t](n);m.push(ee.createElement("line",{key:`pc-tick-${t}-${e}`,x1:p-3,x2:p+3,y1:r,y2:r,stroke:o,strokeWidth:1}),Ot({keyId:`pc-ticktext-${t}-${e}`,text:y(n),x:p+6,y:r+3,anchor:"start",baseline:"auto",fontSize:10,color:h}))}}b=ee.createElement(ee.Fragment,null,...m)}return{nodes:g.concat(x),overlays:b}};import{jsx as re,jsxs as ie}from"react/jsx-runtime";var ae=1.75,se="#222222";function ce(t,e){return t.topRadius+(e-t.height)/t.height*(t.topRadius-t.bottomRadius)}function le(t,e){return function(t,e,n){return Math.PI*n/3*(t*t+t*e+e*e)}(ce(t,e),t.bottomRadius,e)}function ue(t,e){const n=(t.topRadius+t.bottomRadius)/2,o=Math.PI*n*n;let r=e/o,i=e-le(t,r),a=0;for(;100>a&&Math.abs(i)>1e-4;)r+=i/o,i=e-le(t,r),a++;return r}function he(t,e){const n=43758.5453*Math.sin(12.9898*t+78.233);return 2*(n-Math.floor(n)-.5)*e}function de(t,e){if(e>t||2*e>t)return[{x:0,y:0}];const n=[],o=t=>{let r=Math.floor(2*Math.PI*t/(2*e));1>r&&(r=1);const i=0*t,a=Math.hypot(1*t-t*Math.cos(2*Math.PI/r),i-t*Math.sin(2*Math.PI/r));2*e>a&&r>1&&r--;for(let e=0;r>e;e++)n.push({x:t*Math.cos(2*e*Math.PI/r),y:t*Math.sin(2*e*Math.PI/r)});const s=t-2*e;e>s?t>2*e&&n.push({x:0,y:0}):o(s)};return o(t-e),n}function fe(t,e,n){const o=[];let r=n,i=0;for(;r>0&&60>i;){const n=e*(1+2*i),a=de(ce(t,n),e),s=a.length-r,c=s>1?a.slice(Math.floor(s/2),Math.floor(s/2)+r):a,l=t.height-n;if(c.forEach((t,e)=>{o.push({x:t.x+he(97*i+e,.15),z:l+he(31*i+e,.05)})}),r-=c.length,i++,0===c.length)break}return{pearls:o,layers:i}}function me(t,e,n,o){if(0>=o)return[];const r=function(t,e,n){let o=n,r=0;for(;o>0&&60>r;){const n=ce(t,e+.875*(1+2*r));o-=Math.max(1,Math.floor(2*n/ae)),r++}return r}(t,e,o),i=Math.max(e,n-r*ae)+.875,a=[];let s=0;for(let e=0;r>e&&o>s;e++){const n=i+ae*e,r=ce(t,n),c=Math.max(1,Math.floor(2*r/ae)),l=(2*r-c*ae)/(c+1),u=-r+l,h=t.height-n-.875-.1;for(let t=0;c>t&&o>s;t++)a.push({cx:u+(l+ae)*t+.875,cy:h+.875,rotation:he(53*e+t,10)}),s++}return a}function pe(t,e){const n=Number(t);return Number.isFinite(n)?n:e}var ye=t=>{const e=t.config,{plot:o}=t.dimensions;if(0>=o.width||0>=o.height)return{nodes:[]};const r=h(e.categoryAccessor??"name"),i=h(e.teaVolumeAccessor??"teaVolume"),a=h(e.bobaVolumeAccessor??"bobaVolume"),s=h(e.iceVolumeAccessor??"iceVolume"),c=h(e.cupHeightAccessor??"cupHeight"),l=h(e.cupTopRadiusAccessor??"cupTopRadius"),u=h(e.cupBottomRadiusAccessor??"cupBottomRadius"),d=h(e.bobaRadiusAccessor??"bobaRadius"),m=e.cupWidthRatio??.82,p=t.scales.o,y=p.bandwidth(),g=Math.max(1,o.height-26-8),x=o.y+8,b=[],w=[];for(const e of t.data){const o=r(e)+"",h=p(o);if(null==h)continue;const M={height:pe(c(e),15.5),topRadius:pe(l(e),4.75),bottomRadius:pe(u(e),3.75)},v=pe(d(e),.6),k=Math.max(0,pe(i(e),450)),$=Math.max(0,pe(a(e),110)),A=Math.max(0,pe(s(e),135)),S=Math.PI*v*v,C=Math.floor($/S),z=C*S,I=Math.floor(A/5.359375),N=I*ae*ae*ae,L=k+z+N,W=ue(M,L),F=Math.min(M.height,Math.max(0,W)),T=ce(M,F),{pearls:E,layers:R}=fe(M,v,C),P=F,O=me(M,R*v*2,P,I),D=M.height-20.32,j=Math.min(0,D),B=Math.min(y*m/(2*(M.topRadius+1)),g/(M.height-j)),H=h+y/2,Y=t=>H+t*B,V=t=>x+(t-j)*B,X=Y(-(M.topRadius+1)),q=Y(M.topRadius+1),G=V(j),K=V(M.height),_=n({name:o,teaVolume:k,bobaVolume:Math.round(z),iceVolume:Math.round(N),totalVolume:Math.round(L),numBobas:C,numIce:I,kind:"boba cup"});b.push({type:"rect",x:X,y:G,w:Math.max(1,q-X),h:Math.max(1,K-G),style:{fill:"rgba(0,0,0,0)",stroke:"none"},datum:_,group:o,_transitionKey:"boba-"+f(o)});const U=M.height-P,Z=f(o),Q=t.resolveColor(o);w.push(ie("g",{children:[k>0?re("path",{d:`M${Y(-T)},${V(U)} L${Y(-M.bottomRadius)},${V(M.height)} L${Y(M.bottomRadius)},${V(M.height)} L${Y(T)},${V(U)} z`,fill:"#D2B799"}):null,E.map((t,e)=>re("circle",{cx:Y(t.x),cy:V(t.z),r:v*B,fill:"#222222",opacity:.5},"p-"+e)),O.map((t,e)=>re("rect",{x:Y(t.cx)-.95*ae*B/2,y:V(t.cy)-.95*ae*B/2,width:.95*ae*B,height:.95*ae*B,rx:2,fill:"#a5f2f3",opacity:.85,transform:`rotate(${t.rotation} ${Y(t.cx)} ${V(t.cy)})`},"i-"+e)),re("path",{d:`M${Y(-M.topRadius)},${V(0)} L${Y(-M.bottomRadius)},${V(M.height)} L${Y(M.bottomRadius)},${V(M.height)} L${Y(M.topRadius)},${V(0)}`,fill:"none",stroke:se,strokeWidth:2.5}),re("line",{x1:Y(-(M.topRadius+1)),y1:V(0),x2:Y(M.topRadius+1),y2:V(0),stroke:se,strokeWidth:3,strokeLinecap:"round"}),k>0?re("path",{d:`M${Y(-.635)},${V(D)} L${Y(-.635)},${V(M.height-.4)} L${Y(.635)},${V(M.height-1.27-.4)} L${Y(.635)},${V(D)} z`,fill:"#4F91CB",stroke:se,strokeWidth:1,opacity:.78}):null,re("text",{x:H,y:K+16,textAnchor:"middle",fontSize:12,fontWeight:600,fill:"var(--semiotic-text, #333)",children:o}),re("text",{x:H,y:K+30,textAnchor:"middle",fontSize:10,fill:Q,children:`${C} pearls · ${Math.round(L)} cm³`})]},"boba-"+Z))}return{nodes:b,overlays:re("g",{className:"semiotic-boba",style:{pointerEvents:"none"},children:w})}},ge=["naturalGas","coal","nuclear","hydro","wind","solar","other"],xe={naturalGas:"Natural gas",coal:"Coal",nuclear:"Nuclear",hydro:"Hydro",wind:"Wind",solar:"Solar",other:"Other"},be={tight:5,watch:12,comfortable:20};function we(t,e=0){return"number"==typeof t&&Number.isFinite(t)?t:e}function Me(t,e={}){const n=e.fuels??ge,o=!0===e.includeZero,r=[];for(const e of t)if(e&&"number"==typeof e.t)for(const t of n){const n=we(e.fuels?.[t]);(o||n>0)&&r.push({t:e.t,fuel:t,fuelLabel:xe[t],mw:n,ba:e.ba})}return r}function ve(t){const e=[];for(const n of t){if(!n||"number"!=typeof n.t)continue;const t=we(n.demandMw),o=n.forecastMw;"number"==typeof o&&Number.isFinite(o)&&e.push({t:n.t,a:t,b:o,demandMw:t,forecastMw:o,errorMw:t-o,ba:n.ba})}return e}function ke(t){const e=we(t.demand);if(0>=e)return 0;const n=we(t.capacityOrNetGen),o=we(t.interchange);return(n+(0>o?-o:0)-e)/e*100}function $e(t){return t.filter(t=>t&&"number"==typeof t.t).map(t=>{const e=we(t.demandMw),n=we(t.netGenMw),o=ke({demand:e,capacityOrNetGen:n,interchange:t.interchangeMw});return{t:t.t,ba:t.ba,reserveMarginPct:o,netLoadMw:e,demandMw:e,netGenMw:n}})}function Ae(t={},e={}){const{watch:n,comfortable:o}={...be,...t},r=e.field,i=r?{field:r}:{},a=e.tightHatch??{type:"hatch",background:"var(--semiotic-danger, #c2410c)",stroke:"rgba(255, 240, 200, 0.55)",spacing:5,angle:-35,lineWidth:1.25,lineOpacity:.9};return[{id:"reserve-comfortable",label:`Comfortable (≥ ${o}%)`,when:{...i,gte:o},style:{fill:e.comfortableFill??"var(--semiotic-success, #16a34a)",fillOpacity:.85}},{id:"reserve-watch",label:`Watch (< ${o}%, ≥ ${n}%)`,when:{...i,lt:o,gte:n},style:{fill:e.watchFill??"var(--semiotic-warning, #d97706)",fillOpacity:.9}},{id:"reserve-tight",label:`Tight (< ${n}%)`,when:{...i,lt:n},style:{fill:a,stroke:e.tightFill??"var(--semiotic-danger, #c2410c)",strokeWidth:1,fillOpacity:1}}]}function Se(t={}){const{tight:e,watch:n,comfortable:o}={...be,...t};return[{type:"band",y0:-50,y1:e,label:"Tight",color:"var(--semiotic-danger, #c2410c)",fillOpacity:.12,emphasis:"secondary"},{type:"band",y0:e,y1:n,label:"Watch",color:"var(--semiotic-warning, #d97706)",fillOpacity:.1,emphasis:"secondary"},{type:"band",y0:n,y1:Math.max(o+30,40),label:"Headroom",color:"var(--semiotic-success, #16a34a)",fillOpacity:.06,emphasis:"secondary"}]}function Ce(t,e){if(!t.length)return null;const n=[...t].filter(t=>t&&"number"==typeof t.t).sort((t,e)=>t.t-e.t);if(!n.length)return null;let o=n[n.length-1];if("number"==typeof e&&Number.isFinite(e)){const t=n.filter(t=>e>=t.t);o=t.length?t[t.length-1]:n[0]}const r=we(o.demandMw),i=we(o.netGenMw),a="number"==typeof o.forecastMw&&Number.isFinite(o.forecastMw)?o.forecastMw:null,s=ke({demand:r,capacityOrNetGen:i,interchange:o.interchangeMw}),c={};let l=null,u=0,h=0;for(const t of ge){const e=we(o.fuels?.[t]);e>0&&(h+=e,c[t]=e,e>u&&(u=e,l=t))}if(h>0)for(const t of Object.keys(c))c[t]=c[t]/h;return{t:o.t,ba:o.ba,demandMw:r,forecastMw:a,forecastErrorMw:null==a?null:r-a,netGenMw:i,reserveMarginPct:s,topFuel:l,topFuelShare:h>0?u/h:0,topFuelMw:u,fuelShares:c}}function ze(t,e={}){const n=e.now??Date.now(),o=e.author??"system",r=e.source??"authored-scenario";return t.map(t=>{const e=(t.start+t.end)/2,i=new Date(t.start).toISOString();return{type:"x-band",x0:t.start,x1:t.end,label:t.label,color:"outage"===t.kind?"var(--semiotic-danger)":"var(--semiotic-warning)",fillOpacity:.12,emphasis:"secondary",x:e,y:t.y??t.value,note:t.note,provenance:{author:o,authorKind:"system",source:r,basis:"rule",confidence:.85,createdAt:i,stableId:t.id,dataVersion:t.start+""},lifecycle:{status:"accepted",ttlHint:t.ttlHint??"P14D",anchor:"fixed"},_eventKind:t.kind,_createdAtMs:t.start,_nowMs:n}})}function Ie(t,e=12){return[...t].filter(t=>Number.isFinite(t.reserveMarginPct)).sort((t,e)=>t.reserveMarginPct-e.reserveMarginPct).slice(0,Math.max(0,e))}function Ne(t,e=0){return Number.isFinite(t)?t.toLocaleString(void 0,{maximumFractionDigits:e,minimumFractionDigits:e})+" MW":"—"}function Le(t,e=1){return Number.isFinite(t)?`${t>0?"+":""}${t.toFixed(e)}%`:"—"}import*as We from"react";function Fe(t,e){if("function"==typeof t)return t;const n=t??e;return t=>Number(t[n])}function Te(t,e={}){const n=Fe(e.start,"start"),o=Fe(e.end,"end"),r=!1===e.sort?t.slice():t.slice().sort((t,e)=>n(t)-n(e)||o(e)-o(t)),i=[];return{packed:r.map(t=>{const e=n(t);let r=i.findIndex(t=>e>=t);return-1===r&&(r=i.length),i[r]=o(t),{item:t,track:r}}),trackCount:Math.max(1,i.length)}}function Ee(t,e){const n=Fe(e.start,"start"),o=Fe(e.end,"end"),[r,i]=e.domain,a=e.step??1,s="half-open"===e.bounds,c=[];for(let e=r;i>=e;e+=a){let r=0;for(const i of t){const t=n(i),a=o(i);t>e||(s?e>=a:e>a)||r++}c.push({value:e,count:r})}return c}function Re(t){return"function"==typeof t?t:e=>e[t]}var Pe=t=>{const e=t.config,{plot:n}=t.dimensions;if(0>=n.width||0>=n.height||0===t.data.length||!e?.domain)return{nodes:[]};const o=Re(e.laneAccessor),r=Re(e.startAccessor),i=Re(e.endAccessor),a=e.idAccessor?Re(e.idAccessor):null,s=e.unit??0,c=e.barGap??1.5,l=Math.max(0,e.minBarWidth??2),u=e.minBarHeight??3.5,h=e.maxBarHeight??10,d=e.lanePadding??7,f=e.cornerRadius??2,m=e.bottomInset??0,p=e.color??((e,n)=>t.resolveColor(n)),[y,g]=e.domain,x=g-y||1,b=t=>n.x+(t-y)/x*n.width,w=t.scales?.o?.domain?.()??[],M=e.lanes??(w.length>0?w:[...new Set(t.data.map(o))]),v=Math.max(0,n.height-m)/Math.max(1,M.length),k=t=>b(r(t)),$=t=>Math.max(k(t)+l,b(i(t)+s)),A=[];M.forEach((e,r)=>{const i=n.y+r*v,s=t.data.filter(t=>o(t)===e);if(0===s.length)return;const{packed:l,trackCount:m}=Te(s,{start:k,end:$}),y=new Map,g=new Map;for(const{item:t,track:e}of l){const n=g.get(e);n?n.push(t):g.set(e,[t])}for(const t of g.values()){t.sort((t,e)=>k(t)-k(e));for(let e=0;t.length-1>e;e++)y.set(t[e],k(t[e+1]))}const x=(v-2*d)/m,b=Math.min(h,Math.max(Math.min(u,x),x-c));for(const{item:t,track:n}of l){const o=k(t),r=y.get(t),s=$(t)-o;A.push({type:"rect",x:o,y:i+d+n*x,w:void 0!==r&&o+s>r-1?Math.max(1,r-1-o):s,h:b,cornerRadii:f>0?{tl:f,tr:f,br:f,bl:f}:void 0,style:{fill:p(t,e),stroke:"none"},datum:t,group:e,_transitionKey:a?a(t)+"":void 0})}});const S=`var(--semiotic-text, ${t.theme.semantic.text??"#1a1a1a"})`,C=`var(--semiotic-text-secondary, ${t.theme.semantic.textSecondary??"#888"})`,z=`var(--semiotic-border, ${t.theme.semantic.border??"#94a3b8"})`,I=[];(e.periods??[]).forEach((t,e)=>{const o=b(t.start),r=Math.max(1,b(t.end+s)-o);I.push(We.createElement("rect",{key:"period-"+e,x:o,y:n.y,width:r,height:n.height,fill:z,opacity:e%2==0?.06:.025,pointerEvents:"none"})),t.name&&I.push(Ot({keyId:"period-label-"+e,text:t.name,x:o+4,y:n.y+12,anchor:"start",baseline:"hanging",fontSize:13,fontWeight:700,color:C}))});const N=!1!==e.showLaneLabels,L=e.laneLabelGap??12;if(M.forEach((t,e)=>{const o=n.y+e*v;I.push(We.createElement("line",{key:"lane-sep-"+e,x1:n.x,x2:n.x+n.width,y1:o,y2:o,stroke:z,opacity:.45})),N&&I.push(Ot({keyId:"lane-label-"+e,text:t,x:n.x-L,y:o+v/2,anchor:"end",baseline:"middle",fontSize:12,fontWeight:600,color:S}))}),!1!==e.showAxis){const t=e.axisTicks??Array.from({length:8},(t,e)=>Math.round(y+e/7*x));I.push(jt({keyId:"interval-axis",scale:b,ticks:t,orient:"top",offset:n.y,tickLength:0,gridLength:n.height,gridDasharray:"3 5",edgeAnchor:!0,format:e.tickFormat,color:C}))}return{nodes:A,overlays:We.createElement(We.Fragment,null,...I)}};function Oe(t,e,n){const o=n?.orientation??"vertical",r=n?.bend??0,i=n?.minAlong??18,a=(t,e)=>(t+e)/2;if("vertical"===o){if(i>Math.abs(e.y-t.y)){const n=t.x>e.x?-1:1,o=a(t.x,e.x)+n*(22+Math.abs(r));return`M${t.x},${t.y} Q${o},${a(t.y,e.y)} ${e.x},${e.y}`}const n=a(t.y,e.y)+r;return`M${t.x},${t.y} C${t.x},${n} ${e.x},${n} ${e.x},${e.y}`}if(i>Math.abs(e.x-t.x)){const n=t.y>e.y?-1:1,o=a(t.y,e.y)+n*(22+Math.abs(r));return`M${t.x},${t.y} Q${a(t.x,e.x)},${o} ${e.x},${e.y}`}const s=a(t.x,e.x)+r;return`M${t.x},${t.y} C${s},${t.y} ${s},${e.y} ${e.x},${e.y}`}function De(t,e,n){if("vertical"===(n?.orientation??"vertical")){const n=(t.y+e.y)/2;return`M${t.x},${t.y} L${t.x},${n} L${e.x},${n} L${e.x},${e.y}`}const o=(t.x+e.x)/2;return`M${t.x},${t.y} L${o},${t.y} L${o},${e.y} L${e.x},${e.y}`}function je(t,e,n){if("vertical"===(n?.orientation??"vertical")){const n=e.cy>=t.cy;return{from:{x:t.cx,y:t.cy+(n?t.height/2:-t.height/2)},to:{x:e.cx,y:e.cy+(n?-e.height/2:e.height/2)}}}const o=e.cx>=t.cx;return{from:{x:t.cx+(o?t.width/2:-t.width/2),y:t.cy},to:{x:e.cx+(o?-e.width/2:e.width/2),y:e.cy}}}function Be(t,e){const n=e?.spread??5;return e?.modulo&&e.modulo>0?(t%e.modulo-(e.modulo-1)/2)*n:(t-((e?.count??1)-1)/2)*n}function He(t,e){const n=1-e,o=n*n*n,r=3*n*n*e,i=3*n*e*e,a=e*e*e;return{x:o*t.p0.x+r*t.p1.x+i*t.p2.x+a*t.p3.x,y:o*t.p0.y+r*t.p1.y+i*t.p2.y+a*t.p3.y}}function Ye(t,e){const n=1-e,o=3*n*n,r=6*n*e,i=3*e*e;return{x:o*(t.p1.x-t.p0.x)+r*(t.p2.x-t.p1.x)+i*(t.p3.x-t.p2.x),y:o*(t.p1.y-t.p0.y)+r*(t.p2.y-t.p1.y)+i*(t.p3.y-t.p2.y)}}function Ve(t){return`M${t.p0.x},${t.p0.y} C${t.p1.x},${t.p1.y} ${t.p2.x},${t.p2.y} ${t.p3.x},${t.p3.y}`}function Xe(t,e){const n=e?.axis??"x",o=e?.padding??0,r=e?.strength??.5,i="x"===n?"y":"x",a="x"===n?"width":"height",s="x"===n?"height":"width",c=new Map;for(const e of t)c.set(e.id,0);for(let e=0;t.length>e;e++)for(let l=e+1;t.length>l;l++){const u=t[e],h=t[l];if(Math.abs(u[i]-h[i])>(u[s]+h[s])/2+o)continue;const d=h[n]-u[n]||(h.id>u.id?-.5:.5),f=(u[a]+h[a])/2+o-Math.abs(d);if(0>=f)continue;const m=f*r*Math.sign(d);c.set(u.id,(c.get(u.id)??0)-m),c.set(h.id,(c.get(h.id)??0)+m)}return c}var qe={width:60,height:34};function Ge(t,e){if("function"==typeof t)return t;const n=t??e;return t=>u(t,n,void 0)}function Ke(t,e,n,o){const r=o.fixedAxis??"y",i=t=>Ge(o.sourceAccessor,"source")(t)+"",a=t=>Ge(o.targetAccessor,"target")(t)+"",s=o.size??(()=>qe),c=o.iterations??180,l=o.attraction??.012,u=o.anchorStrength??.003,h=o.collisionStrength??.12,d=o.collisionPadding??15,f=o.edgePadding??42,p=o.fixedPadding??16,y=o.damping??.72,g=o.spread??1,[x,b]=o.fixedDomain,w=b-x||1,M=("y"===r?n.y:n.x)+p,v=("y"===r?n.y+n.height:n.x+n.width)-p,k=("y"===r?n.x:n.y)+f,$=("y"===r?n.x+n.width:n.y+n.height)-f,A=Math.max(1,$-k),S=t.map(t=>{const e=m(t)??t,n=(r=t,Ge(o.idAccessor,"id")(r)+"");var r;const{width:i,height:a}=s(e),c=(t=>Number(Ge(o.fixedAccessor,"fixed")(t)))(t),l=k+function(t){let e=2166136261;for(let n=0;t.length>n;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return(e>>>0)/4294967295}(n)*A;return{data:e,id:n,width:i,height:a,fixedValue:c,fixed:(u=c,M+(u-x)/w*(v-M)),free:l,anchor:l};var u}),C=new Map(S.map(t=>[t.id,t])),z=t=>"y"===r?t.width:t.height;for(let t=0;c>t;t++){const t=new Map;for(const e of S)t.set(e.id,0);for(const n of e){const e=C.get(i(n)),o=C.get(a(n));if(!e||!o)continue;const r=(o.free-e.free)*l;t.set(e.id,(t.get(e.id)??0)+r),t.set(o.id,(t.get(o.id)??0)-r)}for(const e of S)t.set(e.id,(t.get(e.id)??0)+(e.anchor-e.free)*u);const n=Xe(S.map(t=>({id:t.id,x:"y"===r?t.free:t.fixed,y:"y"===r?t.fixed:t.free,width:t.width,height:t.height})),{axis:"y"===r?"x":"y",padding:d,strength:h});for(const e of S)t.set(e.id,(t.get(e.id)??0)+(n.get(e.id)??0));for(const e of S){e.free+=(t.get(e.id)??0)*y;const n=z(e)/2;e.free=Math.max(k+n,Math.min($-n,e.free))}}if(1!==g){const t=(k+$)/2;for(const e of S){const n=z(e)/2;e.free=Math.max(k+n,Math.min($-n,t+(e.free-t)*g))}}const I=S.map(t=>({data:t.data,id:t.id,x:"y"===r?t.free:t.fixed,y:"y"===r?t.fixed:t.free,width:t.width,height:t.height,fixedValue:t.fixedValue}));return{positioned:I,byId:new Map(I.map(t=>[t.id,t]))}}var _e=t=>{const{plot:e}=t.dimensions;if(0>=e.width||0>=e.height||0===t.nodes.length||!t.config?.fixedDomain)return{sceneNodes:[]};const n=t.config.fixedAxis??"y",{positioned:o,byId:r}=Ke(t.nodes,t.edges,e,t.config),i=o.map(e=>({type:"rect",x:e.x-e.width/2,y:e.y-e.height/2,w:e.width,h:e.height,style:{fill:t.resolveColor(e.id),stroke:"none"},datum:e.data,id:e.id,label:e.id})),a=[];t.edges.forEach((e,o)=>{const i=r.get((s=e,("function"==typeof t.config.sourceAccessor?t.config.sourceAccessor(s):u(s,t.config.sourceAccessor??"source",void 0))+""));var s;const c=r.get((e=>("function"==typeof t.config.targetAccessor?t.config.targetAccessor(e):u(e,t.config.targetAccessor??"target",void 0))+"")(e));if(!i||!c)return;const{from:l,to:h}=je({cx:i.x,cy:i.y,width:i.width,height:i.height},{cx:c.x,cy:c.y,width:c.width,height:c.height},{orientation:"y"===n?"vertical":"horizontal"});a.push({type:"curved",pathD:Oe(l,h,{orientation:"y"===n?"vertical":"horizontal",bend:Be(o,{modulo:5,spread:5})}),style:{stroke:"var(--semiotic-border, #888)",fill:"none",strokeWidth:1.4},datum:m(e)??e})});const s=o.map(t=>({x:t.x,y:t.y,text:t.id}));return{sceneNodes:i,sceneEdges:a,labels:s}},Ue={fill:"rgba(0,0,0,0)",stroke:"rgba(0,0,0,0)",opacity:0},Ze=8;function Qe(t){return null==t?void 0:t+""}function Je(t){const e=Qe(t.id);return{type:"point",x:t.x,y:t.y,r:t.r??8,style:{...Ue},datum:t.datum,pointId:e,_transitionKey:e}}function tn(t){return Je(t)}function en(t){const[[e,n],[o,r]]=t.bounds;return{type:"geoarea",pathData:t.pathData,centroid:t.centroid,bounds:t.bounds,screenArea:t.screenArea??Math.abs((o-e)*(r-n)),style:{...Ue},datum:t.datum,group:t.group,interactive:!0}}function nn(t){return{type:"rect",x:t.x,y:t.y,w:t.width,h:t.height,style:{...Ue},datum:t.datum,group:t.group,_transitionKey:Qe(t.id)}}function on(t){const e=Qe(t.id);return"width"in t&&"height"in t?{type:"rect",x:t.x,y:t.y,w:t.width,h:t.height,style:{...Ue},datum:t.datum,id:e,label:t.label}:{type:"circle",cx:t.x,cy:t.y,r:t.r??8,style:{...Ue},datum:t.datum,id:e,label:t.label}}function rn(t,e,n={}){const{coord:o,step:r=1,equals:i=Object.is,truthyOnly:a=!1}=n,s=[],c=e=>o?o(t[e],e):e,l=(t,e,n)=>{t.endIndex=e,t.count=e-t.startIndex+1,t.end=o?null==n||c(n)-c(e)>r?c(e)+r:c(n):e+1,s.push(t)};let u=null;for(let n=0;t.length>n;n++){const s=e(t[n],n);if(a&&!s){u&&(l(u,u.endIndex,n),u=null);continue}const h=!o||0>=n||c(n)-c(n-1)<=r;u&&h&&i(u.value,s)?u.endIndex=n:(u&&l(u,u.endIndex,n),u={value:s,start:c(n),end:c(n),count:1,startIndex:n,endIndex:n})}return u&&l(u,u.endIndex,null),s}var an=rn;function sn(t,e,n=0){return e>0?((t-n)%e+e)%e+n:t}function cn(t,e,n){if(0>=n)return e-t;let o=(e-t)%n;return o>n/2?o-=n:-n/2>o&&(o+=n),o}function ln(t,e,n){return e>n?t>=e||n>=t:t>=e&&n>=t}function un(t,e,n,o){return n>o?[...t.filter(t=>e(t)>=n),...t.filter(t=>e(t)<=o)]:t.filter(t=>ln(e(t),n,o))}function hn(t,e){const n=Math.max(0,e.width),o=e.y,r=Math.min(74,Math.max(34,.08*n)),i=e.paddingLeft??r,a=t.length>1?Math.max(0,n-i-(e.paddingRight??r))/(t.length-1):0,s=new Map;return t.forEach((t,e)=>{s.set(t.id,{id:t.id,x:i+a*e,y:o,index:e})}),s}function dn(t,e){const n=Math.max(0,e.width),o=e.y,r=Math.min(74,Math.max(34,.08*n)),i=e.paddingLeft??r,a=e.paddingRight??r,s=e.gap??8,c=!1!==e.distribute,l=e.estimateWidth??(t=>fn(t.label??t.id)),u=t.map((t,e)=>Math.max(1,l(t,e))),h=u.reduce((t,e)=>t+e,0)+s*Math.max(0,t.length-1),d=Math.max(0,n-i-a),f=c&&t.length>1?Math.max(0,d-h)/(t.length-1):0,m=new Map;let p=i;return c||1!==t.length||(p=i+Math.max(0,(d-u[0])/2)),t.forEach((t,e)=>{const n=u[e];m.set(t.id,{id:t.id,x:p+n/2,y:o,index:e,width:n}),p+=n+s+f}),m}function fn(t,e=38,n=7.4,o=20){return Math.max(e,((t??"")+"").length*n+o)}function mn(t){const e=t.map(t=>{const e=Math.min(t.a,t.b),n=Math.max(t.a,t.b);return{span:t,a:e,b:n,width:n-e}}).sort((t,e)=>t.width-e.width||t.a-e.a),n=[],o=e.map(t=>{let e=n.findIndex(e=>t.a>=e);return 0>e?(e=n.length,n.push(t.b)):n[e]=t.b,{span:t.span,level:e}}),r=o.reduce((t,e)=>Math.max(t,e.level),0);return{packed:o,maxLevel:r,levelCount:o.length?r+1:1}}function pn(t){const e=t.labelRoom??18,n=Math.max(48,t.baselineY-t.ceilingY-28),o=Math.max(1,t.levelCount),r=Math.min(42,Math.max(26,.18*n)),i=Math.max(24,n-r-e);return{arcLift:r,levelStep:Math.min(72,Math.max(28,o>1?i/Math.max(1,o-1):i))}}function yn(t,e,n,o,r={}){const i=n-(r.footLift??26);return`M${t} ${i}Q${(t+e)/2} ${o} ${e} ${i}`}function gn(t,e,n){return t-n.arcLift-e*n.levelStep}function xn(t,e=bn){if(!t.length)return{shared:[],exclusive:[]};if(1===t.length)return{shared:[...t[0]],exclusive:[[]]};const n=t.map(t=>new Set(t.map(t=>e(t)))),o=new Set;for(const t of n[0])n.every(e=>e.has(t))&&o.add(t);const r=[],i=new Set;for(const n of t[0]){const t=e(n);o.has(t)&&!i.has(t)&&(r.push(n),i.add(t))}return{shared:r,exclusive:t.map(t=>t.filter(t=>!o.has(e(t))))}}function bn(t){return null==t||"object"!=typeof t?t+"":null!=t.id?t.id+"":`${(t.sourceTokenId??t.source)+""}|${(t.targetTokenId??t.target)+""}|${(t.relation??t.label??"")+""}`}var wn=2*Math.PI;function Mn(t,e,n){const o=n?.center?.x??0,r=n?.center?.y??0;return{x:o+Math.sin(t)*e,y:r-Math.cos(t)*e}}function vn(t,e,n){return(Math.atan2(t-(n?.center?.x??0),-(e-(n?.center?.y??0)))+wn)%wn}function kn(t,e){const[n,o]=t,r=o-n||1,i=e?.startAngle??0,a=e?.endAngle??wn;return t=>i+(t-n)/r*(a-i)}function $n(t,e){const[n,o]=t,[r,i]=e,a=o-n||1;return t=>r+(t-n)/a*(i-r)}function An(t,e,n,o,r){const i=r?.center,a=(t,e)=>{const{x:n,y:o}=Mn(t,e,{center:i});return`${Sn(n)},${Sn(o)}`},s=Math.max(0,n),c=Math.max(s,o),l=Math.abs(e-t),u=t>e?0:1;if(l>=wn-1e-6){const t=i?.x??0,e=i?.y??0,n=`${Sn(t)},${Sn(e-c)}`,o=`${Sn(t)},${Sn(e+c)}`;let r=`M${n} A${Sn(c)},${Sn(c)} 0 1 1 ${o} A${Sn(c)},${Sn(c)} 0 1 1 ${n} Z`;if(s>0){const n=`${Sn(t)},${Sn(e-s)}`,o=`${Sn(t)},${Sn(e+s)}`;r+=` M${n} A${Sn(s)},${Sn(s)} 0 1 0 ${o} A${Sn(s)},${Sn(s)} 0 1 0 ${n} Z`}return r}const h=l>Math.PI?1:0,d=a(t,c),f=a(e,c);if(0>=s){const t=i?.x??0,e=i?.y??0;return`M${Sn(t)},${Sn(e)} L${d} A${Sn(c)},${Sn(c)} 0 ${h} ${u} ${f} Z`}const m=a(e,s),p=a(t,s);return`M${d} A${Sn(c)},${Sn(c)} 0 ${h} ${u} ${f} L${m} A${Sn(s)},${Sn(s)} 0 ${h} ${1===u?0:1} ${p} Z`}function Sn(t){return Math.round(1e3*t)/1e3}function Cn(t,e){return{x:t.x+e.x,y:t.y+e.y}}function zn(t,e){return{x:t.x-e.x,y:t.y-e.y}}function In(t,e){return{x:t.x*e,y:t.y*e}}function Nn(t){return Math.hypot(t.x,t.y)}function Ln(t){const e=Nn(t)||1;return{x:t.x/e,y:t.y/e}}import{jsx as Wn,jsxs as Fn}from"react/jsx-runtime";var Tn="var(--semiotic-text, currentColor)";function En(t,e){const n=$(t,100);return n>0?e/n*100*(e/n):Math.PI*e*e}function Rn(t){const e=[],n=t.colorMap?Object.entries(t.colorMap):t.keys?t.keys.map(e=>[e,t.color?t.color(e):void 0]):[];if(n.length>0){const o=t.colorType??"fill",r=n.map(([t,e])=>({label:t,color:e}));e.push({type:o,label:t.colorLabel??"",items:r,styleFn:"line"===o?t=>({stroke:t.color??Tn,strokeWidth:2,fill:"none"}):t=>({fill:t.color??Tn,stroke:t.color??Tn})})}if(t.symbolMap&&Object.keys(t.symbolMap).length>0){const n=t.symbolColor??Tn,o=Object.entries(t.symbolMap).map(([t,e])=>({label:t,shape:e,color:n}));e.push({label:t.symbolLabel??"",items:o,styleFn:()=>({}),type:t=>{const e=t.shape;return Wn("path",{d:A(e,En(e,7)),transform:"translate(8,8)",fill:t.color??n})}})}if(t.sizeStops&&t.sizeStops.length>0&&t.sizeRadius){const n=t.sizeRadius,o=t.sizeFormat??(t=>t+""),r=t.sizeColor??Tn,i=t.sizeStops.map(t=>({label:o(t),r:Math.max(.5,n(t)),color:r}));e.push({label:t.sizeLabel??"",items:i,styleFn:()=>({}),type:t=>Wn("circle",{cx:8,cy:8,r:t.r,fill:t.color??r})})}return e}function Pn(t){const e=t.orientation??"vertical",n=t.swatchSize??14,o=t.gap??8,r=t.labelGap??6,i=t.fontSize??12,a=t.color??"var(--semiotic-text-secondary, #888)",s=n+o;let c=0;const l=[];return t.entries.forEach((t,u)=>{l.push(Fn("g",{transform:`translate(${"vertical"===e?0:c},${"vertical"===e?c:0})`,children:[On(t,n,t.color??t.line??a,a),Wn("text",{x:n+r,y:n/2,dominantBaseline:"middle",fontSize:i,fill:a,children:t.label})]},"legend-"+u)),c+="vertical"===e?s:n+r+t.label.length*i*.58+o+8}),Wn("g",{className:t.className,transform:`translate(${t.x},${t.y})`,style:{pointerEvents:"none"},children:l},t.keyId)}function On(t,e,n,o){if(t.shape){const o=En(t.shape,e/2-1);return Wn("path",{d:A(t.shape,o),transform:`translate(${e/2},${e/2})`,fill:n})}if(t.hatch){const n=t.color??o;return Fn("g",{children:[Wn("svg",{width:e,height:e,style:{overflow:"hidden"},children:[-e,-e/2,0,e/2].map((t,o)=>Wn("line",{x1:t,y1:e,x2:t+e,y2:0,stroke:n,strokeWidth:1,opacity:.7},o))}),Wn("rect",{width:e,height:e,fill:"none",stroke:n,strokeWidth:1,opacity:.5,rx:2})]})}return Wn("rect",t.line?{y:e/2-1.5,width:e,height:3,rx:1.5,fill:t.line}:{width:e,height:e,rx:2,fill:n})}var Dn=new Set(["rows"]);function jn(t){const e=t,n=[Vn(e,["datum","data"]),Vn(e,["datum"]),Vn(e,["data","data"]),Vn(e,["data"]),Vn(e,["node","datum","data"]),Vn(e,["node","datum"]),t];for(const t of n){if(!Xn(t))continue;const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||"function"==typeof o||(e[n]=o);if(Object.keys(e).length>0)return e}return null}function Bn(t,e={}){const n=jn(t);if(!n)return[];const o=new Set(Dn);if(e.excludeKeys)for(const t of e.excludeKeys)o.add(t);const r=[];for(const[t,i]of Object.entries(n))if((e.includeInternal||!t.startsWith("_"))&&!o.has(t)&&(e.includeEmpty||null!=i&&""!==i)&&"function"!=typeof i&&(r.push({key:t,label:Yn(t,e.labels),value:i,formatted:e.valueFormat?e.valueFormat(i,t,n):Hn(i)}),r.length>=(e.maxEntries??8)))break;return r}function Hn(t){if(null==t)return"";if(t instanceof Date)return t.toISOString();if("number"==typeof t)return Number.isInteger(t)?t+"":t.toLocaleString(void 0,{maximumFractionDigits:2});if("boolean"==typeof t)return t?"true":"false";if(Array.isArray(t))return t.length+" items";if("object"==typeof t)try{return JSON.stringify(t)}catch{return t+""}return t+""}function Yn(t,e){return"function"==typeof e?e(t):e&&e[t]?e[t]:t}function Vn(t,e){let n=t;for(const t of e){if(!Xn(n))return;n=n[t]}return n}function Xn(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function qn(t,e){const n=new Map;for(const e of t)n.set(e.id,new Set);for(const t of e)n.has(t.source)||n.set(t.source,new Set),n.has(t.target)||n.set(t.target,new Set),n.get(t.source).add(t.target),n.get(t.target).add(t.source);return n}function Gn(t,e){const n={};for(const e of t)n[e.id]=0;for(const t of e)n[t.source]=(n[t.source]||0)+1,n[t.target]=(n[t.target]||0)+1;return n}function Kn(t,e){const n={[e]:0},o=[e];let r=0;for(;o.length>r;){const e=o[r];r+=1;for(const r of t.get(e)||[])void 0===n[r]&&(n[r]=n[e]+1,o.push(r))}return n}function _n(t,e,n,o){if(n===o)return n?[n]:[];const r=qn(t,e),i={[n]:null},a=[n];let s=0;for(;a.length>s;){const t=a[s];if(s+=1,t===o)break;for(const e of r.get(t)||[])void 0===i[e]&&(i[e]=t,a.push(e))}if(void 0===i[o])return[];const c=[];let l=o;for(;null!=l;)c.unshift(l),l=i[l];return c}function Un(t,e,n,o=1){const r=qn(t,e);if(!r.has(n))return new Set;const i=Kn(r,n),a=new Set;for(const t in i)i[t]>o||a.add(t);return a}function Zn(t,e){const n=qn(t,e),o={};for(const e of t)o[e.id]=0;for(const e of t.map(t=>t.id)){const r=[],i={},a={},s={};for(const e of t)i[e.id]=[],a[e.id]=0,s[e.id]=-1;a[e]=1,s[e]=0;const c=[e];let l=0;for(;c.length>l;){const t=c[l];l+=1,r.push(t);for(const e of n.get(t)||[])0>s[e]&&(s[e]=s[t]+1,c.push(e)),s[e]===s[t]+1&&(a[e]+=a[t],i[e].push(t))}const u={};for(const e of t)u[e.id]=0;for(;r.length;){const t=r.pop();for(const e of i[t])u[e]+=a[e]/a[t]*(1+u[t]);t!==e&&(o[t]+=u[t])}}for(const t in o)o[t]/=2;return o}function Qn(t,e){const n=qn(t,e),o={};for(const e of t){const t=Kn(n,e.id);let r=0,i=0;for(const e in t)r+=t[e],i+=1;o[e.id]=r>0?(i-1)/r:0}return o}function Jn(t,e){const n=qn(t,e),o={};for(const e of t){const t=[...n.get(e.id)||[]],r=t.length;if(2>r){o[e.id]=0;continue}let i=0;for(let e=0;t.length>e;e+=1)for(let o=e+1;t.length>o;o+=1)n.get(t[e])?.has(t[o])&&(i+=1);o[e.id]=2*i/(r*(r-1))}return o}function to(t){let e=0;for(const n in t)t[n]>e&&(e=t[n]);const n={};for(const o in t)n[o]=e>0?t[o]/e:0;return n}function eo(t,e,n,o={}){const r=qn(t,e),i={};for(const e of t)i[e.id]=Kn(r,e.id);let a=o.minHops??4,s=o.startThreshold??.08;const c=o.maxThreshold??.2,l=new Set;let u=0;for(;0===l.size&&40>u;){for(let e=0;t.length>e;e+=1)for(let o=e+1;t.length>o;o+=1){const r=t[e].id,c=t[o].id,u=n[r],h=n[c];if(!u||!h)continue;const d=u.x-h.x,f=u.y-h.y;(void 0===i[r][c]?1/0:i[r][c])>=a&&s>Math.sqrt(d*d+f*f)&&(l.add(r),l.add(c))}0===l.size&&(s+=.02,s>c&&(s=o.startThreshold??.08,a=Math.max(2,a-1))),u+=1}return{problemIds:l,threshold:s,minHops:a}}async function no(t,e,n={}){const{execution:o="auto",signal:i,workerThreshold:a,nodeRadius:s,...c}=n,l=c.iterations??260;if(!p()||!g(o,t.length,e.length,l,a))return r(t,e,{...c,nodeRadius:s});const u={kind:"normalized",nodes:t.map(t=>({...t})),edges:e.map(t=>({...t})),options:c,nodeRadii:"function"==typeof s?Object.fromEntries(t.map(t=>[t.id,s(t)])):null==s?void 0:Object.fromEntries(t.map(t=>[t.id,s]))};try{return(await y(u,i)).positions}catch(n){if("AbortError"===n?.name)throw n;return r(t,e,{...c,nodeRadius:s})}}var oo=[.1,.5,.9],ro=1e6;function io(t){const e="number"==typeof t?t:"string"==typeof t&&t.trim()?Number(t):NaN;return Number.isFinite(e)?e:null}function ao(t,e,n,o,r){return"function"==typeof o?o(t,e,n):function(t,e){let n=t;for(const t of e.split(".")){if(null==n||"object"!=typeof n)return;n=n[t]}return n}(t,o??r)}function so(t){const e=Number(t.toFixed(12));return Object.is(e,-0)?0:e}function co(t,e,n,o){const r=t.flatMap((t,r)=>{const i=io(ao(t,r,e,n,"time")),a=io(ao(t,r,e,o,"value"));return null==i||null==a?[]:[{time:so(i),value:a,index:r}]});r.sort((t,e)=>t.time-e.time||t.index-e.index);const i=[];for(const t of r){const e=i[i.length-1];e?.time===t.time?e.value=t.value:i.push({time:t.time,value:t.value})}return i}function lo(t,e,n,o){if(!t.length)return null;const r=t[0],i=t[t.length-1];if(r.time>e)return"clamp"===o?r.value:null;if(e>i.time)return"clamp"===o?i.value:null;const a=function(t,e){let n=0,o=t.length;for(;o>n;){const r=n+o>>>1;e>t[r].time?n=r+1:o=r}return n}(t,e),s=t[a];if(s?.time===e)return s.value;const c=t[Math.max(0,a-1)];return"step"!==n&&s&&s.time!==c.time?c.value+(e-c.time)/(s.time-c.time)*(s.value-c.value):c.value}function uo(t,e){if(1===t.length)return t[0];const n=(t.length-1)*e,o=Math.floor(n),r=Math.ceil(n);return o===r?t[o]:t[o]+(t[r]-t[o])*(n-o)}function ho(t){const e=t.interpolation??"step",n=t.outsideDomain??"omit",o=function(t){const e=(t??oo).map(t=>{const e=io(t);if(null==e||0>e||e>1)throw new RangeError("physicsReferenceEnvelope quantiles must be finite values from 0 to 1; received "+t);return so(e)});return Array.from(new Set(e)).sort((t,e)=>t-e)}(t.quantiles),r=function(t){if(Array.isArray(t)){if(t.length>ro)throw new RangeError("physicsReferenceEnvelope sampleAt exceeds 1000000 points");return Array.from(new Set(t.map(io).filter(t=>null!=t).map(so))).sort((t,e)=>t-e)}const e=t,n=io(e.start),o=io(e.end),r=io(e.step);if(null==n||null==o||null==r||0>=r||n>o)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>ro)throw new RangeError("physicsReferenceEnvelope sampleAt exceeds 1000000 points");const a=[],s=1e-10*Math.max(1,Math.abs(o),Math.abs(n));for(let t=0;i>t;t+=1){const e=n+t*r;if(e>o+s)break;a.push(so(Math.min(e,o)))}if(a.length&&s>=Math.abs(a[a.length-1]-o)||a.push(so(o)),a.length>ro)throw new RangeError("physicsReferenceEnvelope sampleAt exceeds 1000000 points");return Array.from(new Set(a)).sort((t,e)=>t-e)}(t.sampleAt),i=t.runs.map(e=>co(e.samples,e.id,t.timeAccessor,t.valueAccessor));return{points:r.map(t=>{const r=i.map(o=>lo(o,t,e,n)).filter(t=>null!=t).sort((t,e)=>t-e),a={};for(const t of o)a[t]=r.length?uo(r,t):null;return{time:t,count:r.length,min:r.length?r[0]:null,max:r.length?r[r.length-1]:null,median:r.length?uo(r,.5):null,quantiles:a}}),quantiles:o,interpolation:e,outsideDomain:n,runCount:t.runs.length}}function fo(t,e){return t.quantiles.length?"lower"===e?t.quantiles[0]:t.quantiles[t.quantiles.length-1]:"lower"===e?"min":"max"}function mo(t,e){if("min"===e||"median"===e||"max"===e)return t[e];const n=io(e);if(null==n||0>n||n>1)throw new RangeError("comparePhysicsTrace quantile selectors must be from 0 to 1; received "+e);const o=so(n);if(!Object.prototype.hasOwnProperty.call(t.quantiles,o))throw Error(`comparePhysicsTrace could not find quantile ${o} in the reference envelope`);return t.quantiles[o]??null}function po(t,e,n){return e>t?"below":t>n?"above":"inside"}function yo(t,e){const n=Math.max(0,e.time-t.time);if(0>=n||null==t.value||null==t.lower||null==t.upper||null==e.value||null==e.lower||null==e.upper)return{below:0,inside:0,above:0,observed:0};const o=t.value-t.lower,r=e.value-e.lower,i=t.value-t.upper,a=e.value-e.upper,s=[0,1];for(const[t,e]of[[o,r],[i,a]])(0>t&&e>0||t>0&&0>e)&&s.push(-t/(e-t));s.sort((t,e)=>t-e);let c=0,l=0,u=0;for(let o=0;s.length-1>o;o+=1){const r=s[o],i=s[o+1];if(r>=i)continue;const a=(r+i)/2,h=(i-r)*n,d=po(t.value+(e.value-t.value)*a,t.lower+(e.lower-t.lower)*a,t.upper+(e.upper-t.upper)*a);"below"===d?c+=h:"above"===d?u+=h:l+=h}return{below:c,inside:l,above:u,observed:n}}function go(t,e,n={}){const o=n.interpolation??e.interpolation,r=n.outsideDomain??e.outsideDomain,i=co(t,n.traceId??"trace",n.timeAccessor,n.valueAccessor),a=n.lower??fo(e,"lower"),s=n.upper??fo(e,"upper"),c=e.points.map(t=>{const e=lo(i,t.time,o,r),n=mo(t,a),c=mo(t,s);if(null!=n&&null!=c&&n>c)throw new RangeError("comparePhysicsTrace lower band exceeds upper band at time "+t.time);return{time:t.time,value:e,lower:n,upper:c,status:null==e||null==n||null==c?"unobserved":po(e,n,c)}});let l=0,u=0,h=0,d=0,f=null,m=0,p=null;for(const t of c){if("below"===t.status?l+=1:"inside"===t.status?u+=1:"above"===t.status&&(h+=1),null==t.value||null==t.lower||null==t.upper)continue;const e=Math.max(0,t.value-t.upper),n=Math.max(0,t.lower-t.value);e>d&&(d=e,f=t.time),n>m&&(m=n,p=t.time)}let y=0,g=0,x=0,b=0;for(let t=0;c.length-1>t;t+=1){const e=c[t],n=c[t+1],r=Math.max(0,n.time-e.time);if(r>0){if("linear"===o){const t=yo(e,n);y+=t.below,g+=t.inside,x+=t.above,b+=t.observed;continue}"unobserved"!==e.status&&(b+=r,"below"===e.status?y+=r:"above"===e.status?x+=r:g+=r)}}const w=c[0]?.time,M=c[c.length-1]?.time,v=null==w||null==M?0:Math.max(0,M-w);return{points:c,sampleCount:c.length,observedSamples:l+u+h,belowSamples:l,insideSamples:u,aboveSamples:h,totalDuration:v,observedDuration:b,unobservedDuration:Math.max(0,v-b),belowDuration:y,insideDuration:g,aboveDuration:x,peakExcess:d,peakExcessAt:f,peakDeficit:m,peakDeficitAt:p}}function xo(t){return{id:t,furthestStageIndex:-1,visitedStageIds:[],visitsByStage:{},firstEnteredAt:{},lastEnteredAt:{},regressionCount:0}}function bo(t){const e=Array.from(new Set(t.bodyIds??[]));return{stages:t.stages.map(t=>({...t})),bodyIds:e,entities:Object.fromEntries(e.map(t=>[t,xo(t)]))}}function wo(t,e,n={}){if("region-enter"!==e.type)return t;const o=function(t,e){const n=e.stageId?.(t);if(n)return n;const o=t.region.metadata;if(o&&"object"==typeof o){const t=o.stageId;if("string"==typeof t)return t}return t.region.id}(e,n),r=t.stages.findIndex(t=>t.id===o);if(0>r)return t;const i=n.entityId?.(e)??e.bodyId;if(!i)return t;const a=t.entities[i]??xo(i),s=a.currentStageId?t.stages.findIndex(t=>t.id===a.currentStageId):-1,c=!a.visitedStageIds.includes(o),l=Number(e.observation.timestamp),u=Number.isFinite(l)?l:0,h={...a,currentStageId:o,furthestStageId:r>a.furthestStageIndex?o:a.furthestStageId,furthestStageIndex:Math.max(a.furthestStageIndex,r),visitedStageIds:c?[...a.visitedStageIds,o]:a.visitedStageIds,visitsByStage:{...a.visitsByStage,[o]:(a.visitsByStage[o]??0)+1},firstEnteredAt:c?{...a.firstEnteredAt,[o]:u}:a.firstEnteredAt,lastEnteredAt:{...a.lastEnteredAt,[o]:u},regressionCount:s>=0&&s>r?a.regressionCount+1:a.regressionCount};return{...t,bodyIds:t.bodyIds.includes(i)?t.bodyIds:[...t.bodyIds,i],entities:{...t.entities,[i]:h}}}function Mo(t){const e=t.bodyIds.map(e=>t.entities[e]??xo(e)),n=e.length;let o=n;return t.stages.map((t,r)=>{const i=e.filter(t=>t.furthestStageIndex>=r).length,a=e.filter(e=>e.visitedStageIds.includes(t.id)).length,s=e.reduce((e,n)=>e+(n.visitsByStage[t.id]??0),0),c={id:t.id,label:t.label??t.id,reached:i,entered:a,total:n,conversion:n>0?i/n:0,fromPrevious:o>0?i/o:0,dropoff:Math.max(0,o-i),visits:s,repeatVisits:Math.max(0,s-a)};return o=i,c})}import{Fragment as vo,jsx as ko,jsxs as $o}from"react/jsx-runtime";var Ao={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"}};function So(t,e,n){return Math.max(e,Math.min(n,t))}function Co(t){return 6.2*t.length}function zo(t,e){const n=t.trim();if(e>=n.length)return n;if(1>=e)return n.slice(0,1);const o=n.split(/\s+/).filter(Boolean).map(t=>t[0]).join("").toUpperCase();return o.length>1&&e>=o.length?o:e>3?n.slice(0,Math.max(1,e-2))+"..":n.slice(0,e).toUpperCase()}function Io(t,e,n="auto"){const o=Math.max(1,Math.floor(e/6.2)),r="compact"===n?zo(t,o):"full"===n?t:Co(t)>e?zo(t,o):t;return{text:r,textLength:Co(r)>e?Math.max(4,e):void 0}}function No(t,e={}){const{showFlowSpine:n=!0,showStageCounts:o=!0,showCapacityBadges:r=!0,showGroupSockets:i=!0,stageLabelMode:a="auto",outlineStages:s=!1,testId:c="process-flow-chrome"}=e,{width:l,height:u,left:h,right:d,topY:f,bottomY:m,midY:p,stages:y,groups:g=[]}=t,x=m-f;return $o("svg",{"aria-hidden":"true","data-testid":c,"data-outline-stages":s?"true":void 0,width:l,height:u,viewBox:`0 0 ${l} ${u}`,style:{position:"absolute",inset:0,pointerEvents:"none"},className:["semiotic-process-chrome",s?"semiotic-process-chrome--outline-stages":null].filter(Boolean).join(" "),children:[ko("defs",{children:$o("linearGradient",{id:"semiotic-process-floor",x1:"0",x2:"0",y1:"0",y2:"1",children:[ko("stop",{offset:"0%",stopColor:"var(--semiotic-process-floor, var(--semiotic-bg, #0f172a))",stopOpacity:"0.2"}),ko("stop",{offset:"100%",stopColor:"var(--semiotic-process-lane, var(--semiotic-surface, #1e293b))",stopOpacity:"0.55"})]})}),ko("rect",{x:0,y:0,width:l,height:u,fill:"url(#semiotic-process-floor)"}),ko("rect",{x:h-6,y:f-8,width:d-h+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?ko("line",{x1:h+8,x2:d-8,y1:p,y2:p,stroke:"var(--semiotic-process-border, var(--semiotic-border, #475569))",strokeWidth:2,strokeDasharray:"6 8",opacity:.55}):null,y.map((t,e)=>{const n=function(t){return t.absorb?"absorb":t.portalTarget?"portal":null!=t.capacity?"capacity":"flow"}(t),i=Ao[n],c=Math.max(12,t.width-8),l=So(c-8,22,88),h=Io(t.label,Math.max(8,l-10),a),d="none"!==a&&c-8>=22,g=function(t){if(null!=t.capacity){const e=null!=t.queueDepth?" · q "+t.queueDepth:"";return t.capacityLabel?`${t.capacityLabel}${e}`:`cap ${Number.isInteger(t.capacity)?t.capacity+"":t.capacity.toFixed(1)}${e}`}return t.absorb?"absorb":t.portalTarget?"portal":"flow"}(t),b=Io(g,Math.max(16,c-10),"auto"),w=r&&!1!==t.showBadge&&c>=32,M=null!=t.count?`n=${t.count}${null!=t.processed?" done "+t.processed:""}`:"",v=Io(M,Math.max(16,c-8),"auto"),k=Math.max(30,f-15),$=k-13;return $o("g",{"data-stage":t.id,"data-role":n,children:[ko("rect",{className:"semiotic-process-chrome__stage-bay",x:t.x0+4,y:f+6,width:c,height:x-12,rx:10,fill:s?"none":i.fill,stroke:i.stroke,strokeWidth:s?1.85:"flow"===n?1:1.6}),y.length-1>e?ko("polygon",{points:`${t.x1-2},${p-7} ${t.x1+8},${p} ${t.x1-2},${p+7}`,fill:i.accent,opacity:.85}):null,d?$o(vo,{children:[ko("rect",{className:"semiotic-process-chrome__stage-label-bg",x:t.x-l/2,y:$,width:l,height:18,rx:9,fill:"var(--semiotic-bg, #0f172a)",fillOpacity:.75,stroke:i.stroke}),$o("text",{x:t.x,y:k,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:[ko("title",{children:t.label}),h.text]})]}):null,w?$o("text",{x:t.x,y:f+22,textAnchor:"middle",fill:"var(--semiotic-process-muted, var(--semiotic-text-secondary, #94a3b8))",fontSize:9,fontWeight:700,textLength:b.textLength,lengthAdjust:b.textLength?"spacingAndGlyphs":void 0,children:[ko("title",{children:g}),b.text]}):null,o&&null!=t.count?$o("text",{x:t.x,y:Math.min(u-8,m+16),textAnchor:"middle",fill:"var(--semiotic-process-text, var(--semiotic-text, #e2e8f0))",fontSize:11,fontWeight:800,textLength:v.textLength,lengthAdjust:v.textLength?"spacingAndGlyphs":void 0,children:[ko("title",{children:M}),v.text]}):null]},t.id)}),i?g.map((t,e)=>{const n=t.total??0,o=t.absorbed??0,r=t.complete??(n>0&&o>=n),i=!r&&n>0&&o/n>=.75,a=r?"rgba(52, 211, 153, 0.35)":i?"rgba(251, 191, 36, 0.28)":"rgba(15, 23, 42, 0.75)",s=r?"#34d399":i?"#fbbf24":"var(--semiotic-border, #64748b)",c=n>0?`${o}/${n}${r?" shipped":i?" almost":""}`:"feature "+(e+1),l=So(Math.max(54,Co(t.label)+18,Co(c)+16),54,104),u=Io(t.label,l-12,"auto"),h=Io(c,l-12,"auto");return $o("g",{"data-group":t.id,children:[ko("rect",{x:t.x-l/2,y:t.y-22,width:l,height:44,rx:10,fill:a,stroke:s,strokeWidth:1.5}),$o("text",{x:t.x,y:t.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:[ko("title",{children:t.label}),u.text]}),$o("text",{x:t.x,y:t.y+12,textAnchor:"middle",fill:s,fontSize:9,fontWeight:700,textLength:h.textLength,lengthAdjust:h.textLength?"spacingAndGlyphs":void 0,children:[ko("title",{children:c}),h.text]})]},t.id)}):null]})}function Lo(t){const e="number"==typeof t?t:"string"==typeof t&&t.trim()?Number(t):NaN;return Number.isFinite(e)?e:null}function Wo(t,e,n,o){const r="function"==typeof t?t(e,n):t;return Number.isFinite(r)?Number(r):o}function Fo(t,e,n){return Lo(t[e])??n}function To(t,e){return"number"==typeof t?t:t?.[e]??0}function Eo(t){const{band:e,idPrefix:n,plot:o,projection:r}=t,{includeBoundaryWalls:i=!0,includeInteriorWalls:a=!0,wallThickness:s=4}=e,c=function(t){const e=t.bandwidth??t.scale.bandwidth?.()??0,n=new Set;for(const o of t.values){const r=t.scale(o);Number.isFinite(r)&&(n.add(Number(r)),n.add(Number(r)+e))}return Array.from(n).sort((t,e)=>t-e)}(e);if(2>c.length)return[];const l=i?c.length-1:c.length-2,u=[];for(let t=i?0:1;l>=t;t+=1){if(!a&&t>0&&c.length-1>t)continue;const e=c[t];u.push({id:`${n}-wall-${t}`,shape:"x"===r?{type:"aabb",x:e,y:o.y+o.height/2,width:s,height:o.height}:{type:"aabb",x:o.x+o.width/2,y:e,width:o.width,height:s}})}return u}function Ro(t){const{plot:e,idPrefix:n="physics-scale",bounds:o={},xBins:r,xBands:i,yBands:a}=t,s=[];if(!1!==o&&s.push(...x(e,{idPrefix:n,...o})),r){const{idPrefix:t,yTop:o,yBottom:i,...a}=r;s.push(...b({...a,idPrefix:t??n+"-xbin",yTop:o??e.y,yBottom:i??e.y+e.height}))}return i&&s.push(...Eo({band:i,idPrefix:i.idPrefix??n+"-xband",plot:e,projection:"x"})),a&&s.push(...Eo({band:a,idPrefix:a.idPrefix??n+"-yband",plot:e,projection:"y"})),s}function Po(t){const{plot:e,rows:n,columns:o=n+1,pegRadius:r=3,idPrefix:i="galton-peg",yStart:a=e.y+.18*e.height,yEnd:s=e.y+.58*e.height,stagger:c=!0,restitution:l=.2,friction:u=.04}=t,h=Math.max(0,Math.floor(n)),d=Math.max(1,Math.floor(o));if(0===h)return[];const f=h>1?(s-a)/(h-1):0,m=e.width/d,p=[];for(let t=0;h>t;t+=1){const n=c&&t%2==1?m/2:0;for(let o=0;d>o;o+=1){const s=e.x+m*(o+.5)+n;e.x+r>s||s>e.x+e.width-r||p.push({id:`${i}-${t}-${o}`,shape:{type:"aabb",x:s,y:a+t*f,width:2*r,height:2*r},restitution:l,friction:u})}}return p}function Oo(t,e={}){const{idPrefix:n="physics-token",radius:o=5,shape:r,mass:i,vx:a,vy:s,spawnAt:c,seed:l=1,jitter:u,datum:h}=e,d=M(l),f=To(u,"x"),m=To(u,"y");return t.map((t,l)=>{const u=Wo(e.x,t,l,Fo(t,"x",0)),p=Wo(e.y,t,l,Fo(t,"y",0)),y=Wo(o,t,l,5),g="function"==typeof r?r(t,l):r??{type:"circle",radius:y};return{id:`${n}-${t.index??l}`,x:u+(d()-.5)*f,y:p+(d()-.5)*m,vx:Wo(a,t,l,0),vy:Wo(s,t,l,0),mass:Wo(i,t,l,1),spawnAt:Wo(c,t,l,void 0),shape:g,datum:h?h(t,l):t.datum??t}}).map(t=>{if(Number.isFinite(t.spawnAt))return t;const{spawnAt:e,...n}=t;return n})}function Do(t,e={}){const{idPrefix:n="sediment",collider:o=!0,colliderThickness:r=1,restitution:i=.05,friction:a=.2,...s}=e,c=w(t,s),l=o?c.filter(t=>t.height>0).map(t=>({id:`${n}-${t.binId}`,shape:{type:"aabb",x:t.x+t.width/2,y:t.y+r/2,width:t.width,height:r},restitution:i,friction:a})):[];return{columns:c,colliders:l}}function jo(t,e={}){const{timeAccessor:n="arrivalTime",timeScale:o=1,startAt:r=0,rebase:i=!0,sort:a=!0}=e,s=t.map((t,e)=>({spawn:t,time:function(t,e,n){return Lo("function"==typeof n?n(t,e):t[n]??t.datum?.[n])}(t,e,n)??t.spawnAt??e})),c=s.length?Math.min(...s.map(t=>t.time)):0;return{initialSpawns:s.map(({spawn:t,time:e})=>({...t,spawnAt:r+(i?e-c:e)})).sort((t,e)=>a?(t.spawnAt??0)-(e.spawnAt??0):0),initialSpawnPacing:{pacing:"arrival",startAt:r,timeAccessor:"spawnAt",timeScale:o}}}function Bo(t,e,n="group"){const o=Gn(t,e),r=t=>"function"==typeof n?n(t):t[n]??0;return t.slice().sort((t,e)=>{const n=r(t),i=r(e);return i>n?-1:n>i?1:(o[e.id]||0)-(o[t.id]||0)}).map(t=>t.id)}function Ho(t,e={}){const n=e.baseline??.62,o=e.inset??.06,r={},i=t.length;return t.forEach((t,e)=>{r[t]={x:i>1?o+e/(i-1)*(1-2*o):.5,y:n}}),r}function Yo(t,e,n=.55){return`M${t.x},${t.y} Q${(t.x+e.x)/2},${t.y-Math.abs(e.x-t.x)*n} ${e.x},${e.y}`}function Vo(t,e={}){const n=e.radius??.42,o=e.center?.x??.5,r=e.center?.y??.5,i=e.startAngle??0,a={},s=t.length;return t.forEach((t,e)=>{const c=i+e/s*Math.PI*2-Math.PI/2;a[t]={x:o+Math.cos(c)*n,y:r+Math.sin(c)*n}}),a}function Xo(t,e,n={}){const o=(n.order??Bo(t,e,n.groupAccessor??"group")).slice(),r=new Map(o.map((t,e)=>[t,e])),i=new Map;for(const t of e){if(!r.has(t.source)||!r.has(t.target)||t.source===t.target)continue;const e=t.target>t.source?`${t.source}\0${t.target}`:`${t.target}\0${t.source}`;i.set(e,(i.get(e)||0)+(t.value??1))}const a=[];let s=0;for(const[t,e]of i){const[n,o]=t.split("\0"),i=r.get(n),c=r.get(o);e>s&&(s=e),a.push({row:i,col:c,source:n,target:o,value:e}),a.push({row:c,col:i,source:o,target:n,value:e})}return{order:o,cells:a,size:o.length,maxValue:s}}function qo(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}function Go(t){if("string"!=typeof t)return;const e=t.trim();return e.length?e:void 0}function Ko(t,e){const n=qo(t.note)?t.note:void 0;return e?Go(t.mobileText)||Go(t.shortText)||Go(t.label)||Go(n?.mobileText)||Go(n?.shortText)||Go(n?.label)||Go(n?.title):Go(t.label)||Go(t.mobileText)||Go(t.shortText)||Go(n?.label)||Go(n?.title)}function _o(t,e,n){const o=function(t,e,n){if(!n)return;const o="function"==typeof n?n(t,e):t[n];return"number"==typeof o&&Number.isFinite(o)?o:void 0}(t,e,n.priorityAccessor);if(void 0!==o)return o;let r=1e3-e;const i=((t.emphasis??"")+"").toLowerCase();"primary"!==i&&"critical"!==i||(r+=1e4),"secondary"===i&&(r-=1e3),"high"===t.priority&&(r+=5e3),"low"===t.priority&&(r-=1500),"number"==typeof t.priority&&(r+=100*t.priority);const a=qo(t.provenance)?t.provenance:void 0;"number"==typeof a?.confidence&&(r+=100*a.confidence);const s=qo(t.lifecycle)?t.lifecycle:void 0,c=((s?.freshness??"")+"").toLowerCase();return"expired"!==c&&"stale"!==c||(r-=3e3),r}function Uo(t,e){if(!e)return t;const n=Ko(t,!0);return n&&"string"==typeof t.label?{...t,label:n}:t}function Zo(t,e={}){const n=Array.isArray(t)?t.filter(qo):[],o=e.active??(null==e.width||(e.breakpoint??480)>=e.width),r=e.strategy??"hybrid",i=!1!==e.preferShortText,a=!1!==e.preservePrimary,s=Math.max(0,e.maxPlotAnnotations??e.maxAnnotations??("callout-list"===r?1:2)),c=Math.max(0,e.minPlotAnnotations??e.minVisible??1);if(!o||"plot"===r)return{active:o,strategy:r,budget:n.length,visible:i?n.map(t=>Uo(t,i)):n,deferred:[],calloutList:[],hidden:[]};const l=[],u=n.map((t,n)=>({annotation:t,index:n,priority:_o(t,n,e)})).filter(t=>!!S(t.annotation)||(l.push(t.annotation),!1)).sort((t,e)=>e.priority-t.priority),h=a?u.filter(t=>"primary"===((t.annotation.emphasis??"")+"").toLowerCase()):[],d=new Set(h.map(t=>t.index)),f=u.filter(t=>!d.has(t.index)),m=[...h,...f].slice(0,Math.max(s,c)),p=new Set(m.map(t=>t.index)),y=u.filter(t=>!p.has(t.index)),g=[...l,...m.sort((t,e)=>t.index-e.index).map(t=>Uo(t.annotation,i))],x=y.sort((t,e)=>t.index-e.index).map(t=>t.annotation),b=Math.max(0,e.maxCalloutItems??6),w=y.filter(t=>!e.calloutFilter||e.calloutFilter(t.annotation,t.index)).map(t=>function(t,e,n,o){const r=Ko(t,o);if(!r)return null;const i=Go(t.id)||Go(t.key)||Go(t.pointId)||"annotation-"+(e+1),a=qo(t.provenance)?Go(t.provenance.source)||Go(t.provenance.authorKind):void 0;return{id:i,label:r,shortLabel:Go(t.shortText),pointId:t.pointId,emphasis:"string"==typeof t.emphasis?t.emphasis:void 0,source:a,priority:n,annotation:t}}(t.annotation,t.index,t.priority,i)).filter(t=>!!t).slice(0,b),M=new Set(w.map(t=>t.annotation)),v=x.filter(t=>!M.has(t));return{active:o,strategy:r,budget:s,visible:g,deferred:x,calloutList:w,hidden:v}}function Qo(t){return"dense"===t.density?.75:"compact"===t.density?.9:1}function Jo(t,e){const n=!1!==e.keepAxes,o=!1===e.directLabel?12:28;return"ordinal"===t?{top:12,right:o,bottom:n?44:12,left:n?48:12}:"geo"===t||"network"===t?{top:12,right:12,bottom:12,left:12}:{top:12,right:o,bottom:n?42:14,left:n?44:14}}function tr(t,e,n,o={}){const r={...n},i={mode:!1===e.mode?void 0:"mobile",...r,margin:Jo(t,e),...o},a=Object.fromEntries(Object.entries(r).filter(([,t])=>void 0!==t)),s=Object.fromEntries(Object.entries(i).filter(([,t])=>void 0!==t)),c=function(t,e){const n=e.targetSize??44,o=[],r=e.standardControls,i=t=>!0===r||"all"===r||r===t||Array.isArray(r)&&r.includes(t);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:`${t}-${e.transformProfile??"overview"}-mobile-recipe`,supportsResponsiveLayout:!0,breakpoints:[320,360,390,430,e.breakpoint??480,768],maxAnnotations:e.maxAnnotations??2,minimumHitTarget:n,summary:e.summary??!0,interaction:{primary:"tap",hoverFallback:"tap-to-lock",targetSize:n,...o.length>0&&{alternatives:o}},labels:{strategy:!1===e.directLabel?"compact":"direct",minFontSize:12}}}(t,e),l=function(t){return{tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:t.targetSize??44,snap:t.snap??"nearestDatum",brushHandleSize:t.targetSize??44,standardControls:t.standardControls??!1}}(e);return{family:t,props:a,responsiveRules:[{id:t+"-mobile",description:`Apply Semiotic's mobile ${t} recipe at phone width.`,when:{maxWidth:e.breakpoint??480},transform:{...s,mobileInteraction:l,mobileSemantics:c}}],mobileInteraction:l,mobileSemantics:c}}function er(t={}){const e=Qo(t);return tr("line",t,{showLegend:t.showLegend??!1,directLabel:t.directLabel??!0,lineWidth:"inspect"===t.transformProfile?3:Math.max(1.5,2.5*e),showPoints:"inspect"===t.transformProfile,autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:t.maxAnnotations??2,maxCalloutItems:t.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:t.keepAxes??!0,axisExtent:"exact"})}function nr(t={}){const e=Qo(t);return tr("area",t,{showLegend:t.showLegend??!1,showPoints:!1,areaOpacity:"compare"===t.transformProfile?.55:.42,lineWidth:Math.max(1.25,2*e),autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:t.maxAnnotations??2,maxCalloutItems:t.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:t.keepAxes??!0,axisExtent:"exact"})}function or(t={}){return tr("ordinal",t,{showLegend:t.showLegend??!1,showCategoryTicks:t.keepAxes??!0,sort:"compare"===t.transformProfile?"desc":void 0},{showAxes:t.keepAxes??!0,axisExtent:"exact"})}function rr(t={}){const e=Qo(t);return tr("scatter",t,{showLegend:t.showLegend??!1,pointRadius:Math.max(4,Math.round((t.targetSize??44)/8*e)),hoverRadius:Math.ceil((t.targetSize??44)/2),pointOpacity:"dense"===t.density?.42:.68,autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:t.maxAnnotations??1,maxCalloutItems:t.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:t.keepAxes??!0,axisExtent:"exact"})}function ir(t={}){const e=Qo(t);return tr("network",t,{showLegend:t.showLegend??!1,nodeSizeRange:[Math.max(4,Math.round(6*e)),Math.max(12,Math.round((t.targetSize??44)/2*e))],showLabels:"inspect"===t.transformProfile,edgeOpacity:"dense"===t.density?.28:.44})}function ar(t={}){return tr("geo",t,{showLegend:t.showLegend??!1})}function sr(t={}){return tr("small-multiple",t,{mobileColumns:t.mobileColumns??1,tabletColumns:t.tabletColumns??2,chartHeight:t.chartHeight??180,sharedExtent:!0})}function cr(t,e={}){switch(t){case"line":return er(e);case"area":return nr(e);case"ordinal":return or(e);case"scatter":return rr(e);case"network":return ir(e);case"geo":return ar(e);case"small-multiple":return sr(e)}}function lr(t={}){const e=t.controls??["range-inputs","chip-filter","clear"];return{mobileInteraction:{enabled:!0,targetSize:t.targetSize??44,tapToSelect:!0,tapToLockTooltip:!0,standardControls:"brush"},mobileSemantics:{interaction:{primary:"filter",alternatives:e,summary:t.summary??"Expose brushable ranges through touch-sized controls in addition to drag gestures."}},controls:e}}export{C as waffleLayout,z as allocateCells,I as isotypeInk,N as isotypePaper,L as isotypeGhost,W as isotypeServerGlyph,F as isotypeChipGlyph,T as isotypeBoltGlyph,E as isotypeBusGlyph,R as isotypePersonPath,P as isotypePersonGlyph,O as isotypeNetworkGlyphs,_ as tokenLayer,Q as calendarLayout,ot as DEFAULT_ISOMETRIC_SPRITE_SIZES,dt as selectIsometricLandmarks,ft as isometricLandmarkLayout,bt as flextreeLayout,wt as dagreLayout,St as lineageDagLayout,Wt as mermaidDagLayout,Et as roundedEnclosure,Rt as boundsOf,Pt as hullFromBoxes,Ot as bandLabel,Dt as hatchFill,jt as linearAxis,Bt as markCallout,Gt as packedClusterMatrix,Zt as marimekkoLayout,te as bulletLayout,oe as parallelCoordinatesLayout,ye as bobaLayout,ge as GRID_FUEL_KEYS,xe as GRID_FUEL_LABELS,Me as stackFuelSeries,ve as demandForecastRows,ke as reserveMarginPct,$e as reserveSeries,Ae as thresholdBandsForReserve,Se as reserveAnnotationBands,Ce as summarizeOperatingPoint,ze as gridEventAnnotations,Ie as tightestHours,Ne as formatMw,Le as formatReservePct,Te as packIntervals,Ee as activeCountOverDomain,Pe as intervalLanesLayout,Oe as curvedEdgePath,De as orthogonalEdgePath,je as boxEdgeAnchors,Be as fanOutBend,He as cubicPoint,Ye as cubicTangent,Ve as cubicPath,Xe as rectCollide,Ke as axisFixedForcePositions,_e as axisFixedForceLayout,Ze as DEFAULT_HIT_RADIUS,Je as hitTargetPoint,tn as geoHitTarget,en as geoAreaHitTarget,nn as hitTargetRect,on as networkHitTarget,rn as runs,an as runLengthEncode,sn as wrapValue,cn as shortestArcDelta,ln as cyclicRangeContains,un as selectCyclicRange,hn as layoutSequence,dn as layoutChipStrip,fn as estimateLabelWidth,mn as packSpanLevels,pn as scaleArcBand,yn as spanArcPath,gn as spanArcPeakY,xn as partitionSharedEdges,wn as TAU,Mn as polarToXY,vn as xyToAngle,kn as angleScale,$n as radiusScale,An as ringArcPath,Cn as addPoints,zn as subtractPoints,In as scalePoint,Nn as pointMagnitude,Ln as normalizePoint,Rn as legendGroupsFrom,Pn as legendSwatches,jn as extractTooltipDatum,Bn as buildTooltipEntries,Hn as formatTooltipValue,qn as buildAdjacency,Gn as degree,Kn as bfsDistances,_n as shortestPath,Un as egoNetwork,Zn as betweenness,Qn as closeness,Jn as clustering,to as normalizeScores,eo as proximityProblem,no as forceLayoutAsync,ho as physicsReferenceEnvelope,go as comparePhysicsTrace,bo as createProcessJourneyLedger,wo as updateProcessJourney,Mo as processJourneyRows,No as processChrome,Ro as collidersFromScales,Po as galtonPegs,Oo as spawnFromTokens,Do as sedimentBake,jo as arrivalReplay,Bo as orderByGroupDegree,Ho as arcLayout,Yo as arcPath,Vo as circularLayout,Xo as adjacencyMatrix,Zo as mobileAnnotationStrategy,er as mobileLineChartRecipe,nr as mobileAreaChartRecipe,or as mobileOrdinalChartRecipe,rr as mobileScatterplotRecipe,ir as mobileNetworkChartRecipe,ar as mobileGeoChartRecipe,sr as mobileSmallMultipleRecipe,cr as mobileChartFamilyRecipe,lr as mobileBrushAlternatives};
|