@ksp-gonogo/ui-kit 1.0.0-rc.47 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{chunk-WR3644JL.js → chunk-FIYXARZ7.js} +381 -285
- package/dist/chunk-FIYXARZ7.js.map +1 -0
- package/dist/index.d.ts +129 -34
- package/dist/index.js +376 -178
- package/dist/index.js.map +1 -1
- package/dist/testing.js +1 -1
- package/dist/tokens.css +4 -0
- package/package.json +2 -2
- package/dist/chunk-WR3644JL.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/tone.ts","../src/CommandDelay/DelayRailContext.tsx","../src/store/createPanelStore.tsx","../src/store/createStore.ts","../src/kspTime.ts","../src/Text.tsx","../src/NullValue.tsx","../src/units.ts","../src/__generated__/unit-kinds.ts","../src/formatKspDate.ts","../src/formatDuration.ts","../src/SendStatus/describeSendStatus.ts","../src/SendStatus/predictedOutcome.ts","../src/CommandDelay/commandRefusalSentence.ts","../src/CommandDelay/commandFoundSentence.ts","../src/CommandDelay/commandLossSentence.ts","../src/CommandDelay/commandOutcomes.ts","../src/CommandButton/commandControl.tsx","../src/CommandButton/toggle.ts","../src/VisuallyHidden.tsx","../src/LiveRegion.tsx","../src/Tooltip.tsx","../src/focusRestore.ts","../src/FitLabelButton.tsx","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/shared/src/utils/mergeClasses.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/shared/src/utils/toKebabCase.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/shared/src/utils/toCamelCase.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/shared/src/utils/toPascalCase.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/defaultAttributes.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/shared/src/utils/hasA11yProp.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/context.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/Icon.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/createLucideIcon.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/arrow-down-to-line.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/arrow-down.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/arrow-left-right.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/arrow-left.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/arrow-right.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/arrow-up-to-line.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/arrow-up.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/bell.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/check.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/chevron-down.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/chevron-left.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/chevron-right.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/chevron-up.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/columns-2.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/computer.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/corner-down-left.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/database.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/file-text.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/grip.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/heart.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/history.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/house.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/info.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/joystick.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/layers.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/lightbulb-off.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/lightbulb.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/lock.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/maximize.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/menu.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/microscope.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/minimize.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/pause.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/pencil.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/play.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/plus.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/radio.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/rectangle-horizontal.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/rectangle-vertical.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/rotate-ccw.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/rotate-cw.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/rows-2.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/satellite-dish.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/satellite.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/settings.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/square.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/star.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/undo-2.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/volume-2.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/volume-x.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/wrench.ts","../../../node_modules/.pnpm/lucide-react@1.14.0_react@18.3.1/node_modules/lucide-react/src/icons/x.ts","../src/Icons.tsx","../src/reckoningMarkSpec.ts","../src/HeldMark.tsx","../src/ReservedText.tsx","../src/Button.tsx","../src/ButtonBody.tsx","../src/focusRing.ts","../src/buttonTip.tsx","../src/CommandButton/CommandedButton.tsx","../src/CommandDelay/railAnnouncer.ts","../src/PlainButton.tsx","../src/Form.tsx","../src/CommandButton/commandInput.tsx","../src/commandEdge.ts","../src/Stack.tsx","../src/scales.ts","../src/AugmentSettings.tsx","../src/augments.ts","../src/domainAvailability.tsx","../src/LockScope.tsx","../src/InactiveNotice.tsx","../src/lockQuantity.ts","../src/Section.tsx","../src/WidgetMetaContext.ts","../src/AugmentSlot.tsx","../src/status/streamStatusWord.ts","../src/readingCurrency.ts","../src/standsApart.ts","../src/Countdown.tsx","../src/useElementSize.ts","../src/CommandDelay/toInFlightListItems.ts","../src/CommandDelay/InFlightList.tsx","../src/inlineOverflow.tsx","../src/CommandDelay/focusBesideDismissed.ts","../src/CommandDelay/settle.ts","../src/status/severity.ts","../src/status/PanelStatusStore.tsx","../src/status/useStatusContribution.ts","../src/Badge.tsx","../src/fitBox.ts","../src/heldTone.ts","../src/magnitude.ts","../src/UnitSharedFormat.tsx","../src/Unit.tsx","../src/Cluster.tsx","../src/badgeFace.ts","../src/instrumentCurrency.tsx","../src/CommandDelay/railTags.ts","../src/CommandDelay/waveformPath.ts","../src/CommandDelay/ControlDelayStream.tsx","../src/CommandDelay/delayCurrency.ts","../src/CommandDelay/CommandDelay.tsx","../src/CommandDelay/commandFailedSentence.ts","../src/CommandDelay/commandUndeliveredSentence.ts","../src/CommandDelay/commandWarningSentence.ts","../src/CommandDelay/CommandList.tsx","../src/contributionsRead.tsx","../src/contributionsRuntime.tsx","../src/Dial.tsx","../src/FilterChip.tsx","../src/SearchBox.tsx","../src/useRowFilter.tsx","../src/FramedDisplay.tsx","../src/GraphNotice.tsx","../src/PanelBadges.tsx","../src/status/useStatusBreakdown.ts","../src/status/useStatusSummary.ts","../src/usePanelAsideSize.ts","../src/Panel.tsx","../src/CommandDelay/PanelDelayRail.tsx","../src/status/PanelStatusDot.tsx","../src/titleText.ts","../src/useFittedTitle.ts","../src/useScrollerMetric.ts","../src/LevelBars.tsx","../src/ToggleButton.tsx","../src/Sparkline.tsx","../src/widgetSize.ts","../src/TinyEssentials.tsx","../src/fillQuantity.ts","../src/useWidgetBadges.ts"],"sourcesContent":["import type { Tone } from \"@ksp-gonogo/sitrep-sdk\";\n\n/*\n * What colour a tone is depends on the job the colour does, so there is one\n * map per job and a caller picks the map by what it is drawing. Each value is\n * a role token from the theme, which the contrast gate holds to its grounds.\n */\n\n/**\n * A tone's text colour on a surface, or on its own muted ground. Each value is\n * a CSS variable string, for use in a style or a styled-components template.\n * Useful for colouring words so the operator reads a state without a label.\n * Used by {@link Readout} and {@link DataLine}.\n *\n * @category Theme\n */\nexport const TONE_TEXT: Readonly<Record<Tone, string>> = {\n neutral: \"var(--color-neutral-text)\",\n info: \"var(--color-info-text)\",\n go: \"var(--color-go-text)\",\n caution: \"var(--color-caution-text)\",\n warn: \"var(--color-warn-text)\",\n nogo: \"var(--color-nogo-text)\",\n offline: \"var(--color-offline-text)\",\n};\n\n/**\n * A tone standing alone: the colour of a dot, fill, edge or stroke with no\n * text of its own. Useful for drawing a state the operator reads by colour\n * alone, such as a status dot. Used by {@link StatusIndicator}.\n *\n * @category Theme\n */\nexport const TONE_MARK: Readonly<Record<Tone, string>> = {\n neutral: \"var(--color-neutral-mark)\",\n info: \"var(--color-info-mark)\",\n go: \"var(--color-go-mark)\",\n caution: \"var(--color-caution-mark)\",\n warn: \"var(--color-warn-mark)\",\n nogo: \"var(--color-nogo-mark)\",\n offline: \"var(--color-offline-mark)\",\n};\n\n/**\n * A tone as a fill that carries its own text, drawn in {@link TONE_ON_STATUS}.\n * Each value is a CSS variable string. Useful for drawing a state as a solid\n * chip the operator can see across the room. Used by {@link Button}.\n *\n * @category Theme\n */\nexport const TONE_STATUS: Readonly<Record<Tone, string>> = {\n neutral: \"var(--color-neutral-status)\",\n info: \"var(--color-info-status)\",\n go: \"var(--color-go-status)\",\n caution: \"var(--color-caution-status)\",\n warn: \"var(--color-warn-status)\",\n nogo: \"var(--color-nogo-status)\",\n offline: \"var(--color-offline-status)\",\n};\n\n/**\n * The text colour on a {@link TONE_STATUS} fill. Useful for keeping the words\n * on a filled state chip readable by the operator. Used by {@link Button}.\n *\n * @category Theme\n */\nexport const TONE_ON_STATUS: Readonly<Record<Tone, string>> = {\n neutral: \"var(--color-neutral-on-status)\",\n info: \"var(--color-info-on-status)\",\n go: \"var(--color-go-on-status)\",\n caution: \"var(--color-caution-on-status)\",\n warn: \"var(--color-warn-on-status)\",\n nogo: \"var(--color-nogo-on-status)\",\n offline: \"var(--color-offline-on-status)\",\n};\n\n/**\n * The word a screen reader hears for a tone that is announced rather than seen.\n * Useful for giving an operator who cannot see a colour its meaning in words.\n * Used by {@link Panel}'s status summary.\n *\n * @category Theme\n */\nexport const TONE_LABEL: Readonly<Record<Tone, string>> = {\n neutral: \"neutral\",\n info: \"info\",\n go: \"nominal\",\n caution: \"caution\",\n warn: \"warning\",\n nogo: \"critical\",\n offline: \"offline\",\n};\n\n/**\n * A box's edge in a tone: the tone's mark, except `neutral`, which has no\n * state to edge with and takes the decorative border. Useful for outlining a\n * box in the colour of the state it reports. Used by {@link Card}, {@link Notice}\n * and {@link StatusIndicator}.\n *\n * @category Theme\n */\nexport function toneEdge(tone: Tone): string {\n return tone === \"neutral\" ? \"var(--color-border-subtle)\" : TONE_MARK[tone];\n}\n\n/**\n * A box filled with a tone's status colour: the fill, its on-status text, and\n * the neutral text and every text level inside it redeclared to that on-status\n * text, so a word a child draws reads on the fill rather than in a grey made\n * for the panel. Useful for showing the operator a selected or highlighted row\n * in a state colour. Used by {@link Row}.\n */\nexport function statusFill(tone: Tone): string {\n const on = TONE_ON_STATUS[tone];\n return `\n background: ${TONE_STATUS[tone]};\n color: ${on};\n --color-neutral-text: ${on};\n --color-text-primary: ${on};\n --color-text-muted: ${on};\n --color-text-dim: ${on};\n --color-text-faint: ${on};\n`;\n}\n","import { RailRegistryContext } from \"@ksp-gonogo/sitrep-sdk/spine\";\nimport { type ReactNode, useSyncExternalStore } from \"react\";\nimport { createPanelStore } from \"../store/createPanelStore\";\nimport { createStore } from \"../store/createStore\";\nimport type { CommandDelayHandle } from \"./CommandDelay\";\n\n/**\n * One entry registered on a panel's delay rail: the handle plus an `id` that\n * stays the same for as long as the registering component is mounted. Useful\n * for listing the commands a widget has sent. Returned by\n * {@link useActiveHandles}.\n *\n * @category CommandDelay\n */\nexport interface CommandHandle extends CommandDelayHandle {\n /** Stable for the registering hook's whole mounted life. */\n id: string;\n}\n\n/**\n * A per-panel, off-tree registry of active command handles. `update` keeps a\n * registered handle current in place. The live data lives in the store, never\n * in a context value, so a registration change re-renders only the rail's\n * subscribers. Useful for holding the commands whose delay the operator sees on\n * a panel. Returned by {@link createDelayRailStore} and {@link useDelayRailStore}.\n */\nexport interface DelayRailStore {\n /** Add or replace a handle (keyed on `handle.id`). Returns its deregister function. */\n register(handle: CommandHandle): () => void;\n /** Update a registered handle's non-id fields in place (keyed on `id`). */\n update(id: string, next: Omit<CommandHandle, \"id\">): void;\n /** Subscribe to any change in the active handle set. Returns unsubscribe. */\n subscribe(onChange: () => void): () => void;\n /** The current active handles, insertion-ordered, referentially stable while unchanged. */\n getActiveHandles(): readonly CommandHandle[];\n}\n\n/**\n * Create an empty delay-rail store, for a caller that owns its lifetime and provides it through {@link DelayRailContext}.\n * Useful for a representation of the delay rail that owns its own store.\n *\n * @intent Published so a third party can own the lifetime of a rail store behind a representation of its own, as Console does.\n * @category CommandDelay\n */\nexport function createDelayRailStore(): DelayRailStore {\n const base = createStore<CommandHandle>();\n return {\n register: base.register,\n update: base.update,\n subscribe: base.subscribe,\n getActiveHandles: base.getSnapshot,\n };\n}\n\nconst DelayPanelStore = createPanelStore(createDelayRailStore);\n\n/**\n * Carries only the store handle, never the live registrations. `null` outside\n * a `Panel`, where `useRailEntry` and `useActiveHandles` degrade to no-ops.\n * Exported raw for a caller that owns the store's lifetime.\n * Useful for a representation of the delay rail that owns its own store.\n *\n * @intent Published so a third party can provide a rail store it owns to a representation of its own, as Console does.\n * @category CommandDelay\n */\nexport const DelayRailContext = DelayPanelStore.Context;\n\n/**\n * The delay-rail registry for one widget: it creates one delay-rail store,\n * holds it for its whole life, and every `useCommand` beneath it registers\n * there, so each command's outcome reaches the rail with nothing wired in the\n * widget. Useful for showing the operator the commands a widget has sent. Used\n * by the dashboard, which mounts one around every widget. A dev build throws on\n * a dispatch with none mounted.\n *\n * @category CommandDelay\n */\nexport function DelayRailProvider({ children }: { children?: ReactNode }) {\n return (\n <DelayPanelStore.Provider>\n <CommandRailBridge>{children}</CommandRailBridge>\n </DelayPanelStore.Provider>\n );\n}\n\nfunction CommandRailBridge({ children }: { children?: ReactNode }) {\n const store = DelayPanelStore.useStore();\n return (\n <RailRegistryContext.Provider value={store}>\n {children}\n </RailRegistryContext.Provider>\n );\n}\n\n/**\n * The nearest store, or `null` outside a `Panel`. Does not subscribe, so a registering widget does not re-render when a sibling registers.\n * Useful for registering a command with the panel's delay rail.\n *\n * @intent Published so a third party can build a representation of the rail of its own, as Console does.\n * @category CommandDelay\n */\nexport const useDelayRailStore = DelayPanelStore.useStore;\n\n// Stable no-store fallbacks: a fresh `[]` would make `useSyncExternalStore` loop.\nconst NO_SUBSCRIBE = (): (() => void) => () => {};\nconst NO_HANDLES: readonly CommandHandle[] = [];\nconst NO_HANDLES_SNAPSHOT = (): readonly CommandHandle[] => NO_HANDLES;\n\n/**\n * The panel's active command handles, or `[]` when the store is empty or there\n * is no store in the tree. A subscriber (`Panel.Delay`) re-renders only when\n * the active handle set changes.\n * Useful for listing the commands the operator still has in flight on one\n * panel.\n *\n * @intent Published so a third party can read the active handles to draw a representation of the rail of its own, as Console does.\n * @category CommandDelay\n */\nexport function useActiveHandles(): readonly CommandHandle[] {\n const store = useDelayRailStore();\n return useSyncExternalStore(\n store ? store.subscribe : NO_SUBSCRIBE,\n store ? store.getActiveHandles : NO_HANDLES_SNAPSHOT,\n store ? store.getActiveHandles : NO_HANDLES_SNAPSHOT,\n );\n}\n","import { createContext, type ReactNode, useContext, useRef } from \"react\";\n\n/**\n * A per-panel React context so both a widget body and the panel chrome reach\n * the same off-tree store, scoped to the nearest provider. Useful for sharing a\n * tile's reported state between a widget and its header. Used by the panel\n * status store.\n *\n * The provider creates one store and holds it for its whole life, so its\n * context value never changes identity; live data flows through the store's\n * own `subscribe`. `useStore` is `null` with no provider, which every reader\n * treats as a no-op. `Context` is returned raw for a caller that owns the\n * store's lifetime itself (a test injecting a pre-seeded store).\n */\nexport interface PanelStore<Store> {\n Context: React.Context<Store | null>;\n Provider: (props: { children?: ReactNode }) => ReactNode;\n useStore: () => Store | null;\n}\n\nexport function createPanelStore<Store>(\n create: () => Store,\n): PanelStore<Store> {\n const Context = createContext<Store | null>(null);\n\n function Provider({ children }: { children?: ReactNode }) {\n const storeRef = useRef<Store | null>(null);\n if (storeRef.current === null) storeRef.current = create();\n return (\n <Context.Provider value={storeRef.current}>{children}</Context.Provider>\n );\n }\n\n function useStore(): Store | null {\n return useContext(Context);\n }\n\n return { Context, Provider, useStore };\n}\n","/**\n * A generic, off-tree external store: an id-keyed set of entries with\n * `subscribe`/`getSnapshot`/`register`/`update`, a referentially stable\n * snapshot while unchanged, and insertion order. Useful for keeping the states\n * a dashboard tile reports where a change re-renders only the components that\n * read them. Used by the panel status store.\n *\n * The live data lives in the store and never in a React context value.\n */\nexport interface Store<Item extends { id: string }> {\n /** Add or replace an entry (keyed on `entry.id`). Returns its deregister function. */\n register(entry: Item): () => void;\n /**\n * Change an already-registered entry's non-id fields in place. A no-op when\n * the id is unknown, and a no-op (no notify, snapshot identity preserved)\n * when every field is shallow-equal to the current entry, so a value that\n * did not actually move does not hand `useSyncExternalStore` a fresh\n * snapshot.\n */\n update(id: string, next: Omit<Item, \"id\">): void;\n /** Subscribe to any change to the entry set. Returns unsubscribe. */\n subscribe(onChange: () => void): () => void;\n /** The entries, insertion-ordered, referentially stable while unchanged. */\n getSnapshot(): readonly Item[];\n}\n\n// Shared frozen empty snapshot so an empty store returns one stable identity (a fresh `[]` per call would loop `useSyncExternalStore`).\nconst EMPTY: readonly never[] = Object.freeze([]);\n\n/** Shallow-equal over `next`'s own keys against the current entry (id aside). */\nfunction unchanged<Item extends { id: string }>(\n current: Item,\n next: Omit<Item, \"id\">,\n): boolean {\n for (const key in next) {\n if (\n (current as Record<string, unknown>)[key] !==\n (next as Record<string, unknown>)[key]\n ) {\n return false;\n }\n }\n return true;\n}\n\nexport function createStore<Item extends { id: string }>(): Store<Item> {\n // Insertion order keeps a derived view's top-rank tie-break deterministic.\n const entries = new Map<string, Item>();\n const listeners = new Set<() => void>();\n\n let cached: readonly Item[] = EMPTY;\n let dirty = true;\n\n function emit() {\n dirty = true;\n for (const listener of listeners) listener();\n }\n\n // Which registration currently owns each id, so a registrant that has been replaced cannot deregister its replacement.\n const owners = new Map<string, object>();\n\n return {\n register(entry) {\n const owner = {};\n entries.set(entry.id, entry);\n owners.set(entry.id, owner);\n emit();\n return () => {\n if (owners.get(entry.id) !== owner) return;\n owners.delete(entry.id);\n if (entries.delete(entry.id)) emit();\n };\n },\n update(id, next) {\n const current = entries.get(id);\n if (!current || unchanged(current, next)) return;\n entries.set(id, { id, ...next } as Item);\n emit();\n },\n subscribe(onChange) {\n listeners.add(onChange);\n return () => {\n listeners.delete(onChange);\n };\n },\n getSnapshot() {\n if (dirty) {\n cached = entries.size === 0 ? EMPTY : Array.from(entries.values());\n dirty = false;\n }\n return cached;\n },\n };\n}\n","/**\n * The calendar the game is running, re-exported from the unit model. It lives\n * in `@ksp-gonogo/sitrep-sdk` because it decides the ratio of `d` to `s`, so\n * the formatters and `Value` arithmetic must both follow it.\n */\n\nexport {\n type KspCalendar,\n kspCalendar,\n kspYearDays,\n STOCK_KERBIN_CALENDAR,\n setKspCalendar,\n} from \"@ksp-gonogo/sitrep-sdk\";\n","import type { Tone } from \"@ksp-gonogo/sitrep-sdk\";\nimport type { HTMLAttributes, ReactNode } from \"react\";\nimport styled, { css } from \"styled-components\";\nimport { TONE_TEXT } from \"./tone\";\n\n/**\n * How far plain text recedes: `muted` for secondary text, `faint` the quietest\n * tier below it, for a readout that should recede, such as the number echoing\n * a value already drawn as a bar. Useful for letting the operator's eye pass over words that\n * support a figure. Taken by the `level` prop of {@link Text}.\n *\n * @category Typography\n */\nexport type TextLevel = \"muted\" | \"faint\";\n\n/**\n * The type-scale steps {@link Text}'s `size` accepts, smallest to largest:\n * `xs` for dense rows, `sm` for values, `base` for prose, `lg` for a headline\n * figure. Useful for sizing words so the operator can tell a label from a\n * value. Taken by the `size` prop of {@link Text}.\n *\n * @category Typography\n */\nexport type TextSize = \"xs\" | \"sm\" | \"base\" | \"lg\";\n\n/**\n * The font weights {@link Text}'s `weight` accepts: `regular` (400) and\n * `semibold` (600). Useful for marking the key figure in a line of words for\n * the operator. Taken by the `weight` prop of {@link Text}.\n *\n * @category Typography\n */\nexport type TextWeight = \"regular\" | \"semibold\";\n\n/**\n * Props for {@link Text}. Any other `span` attribute passes through. Useful for\n * colouring and sizing the words around a figure so the operator can tell a\n * label from a value. Taken by {@link Text}.\n *\n * @category Typography\n */\nexport interface TextProps extends HTMLAttributes<HTMLSpanElement> {\n /** The state the text shows. Defaults to `neutral`, the primary text colour. */\n tone?: Tone;\n /**\n * Recedes neutral text to a quieter tier. A text with a state keeps its\n * tone's colour, since a state is never dimmed away, so\n * `tone={alarm ? \"nogo\" : undefined} level=\"faint\"` reads faint until the\n * alarm.\n */\n level?: TextLevel;\n /** Adds `margin-left: 2px` so the value sits apart from a preceding label. */\n spaced?: boolean;\n /**\n * Font size, snapped to the type scale. Omit to inherit the ambient\n * font-size; set it for dense list or grid rows that need to stay off the\n * body-text size.\n */\n size?: TextSize;\n /** Font weight. Omit to inherit the ambient weight; set `semibold` to emphasise a key figure. */\n weight?: TextWeight;\n /** The text, or inline content such as a {@link Unit}. */\n children?: ReactNode;\n}\n\nconst LEVEL_COLOR: Record<TextLevel, string> = {\n muted: \"var(--color-text-muted)\",\n faint: \"var(--color-text-faint)\",\n};\n\n/**\n * Inline style declarations that recede every neutral word inside a box to the\n * faint text level, which still meets WCAG AA contrast on a panel. Useful for\n * quieting a block of words the operator should not act on, such as a figure\n * with no vessel behind it. Used by the landing status solution readouts. The\n * same declarations as {@link faintText}, for a `style` prop.\n *\n * It sets `color` and the neutral, primary, muted and dim text variables to\n * that faint colour, so nested kit text recedes with it. A word in a tone keeps\n * its tone. Keep opacity for marks that carry no text, since it drops words\n * below contrast.\n *\n * @category Typography\n */\nexport const FAINT_TEXT_STYLE: Readonly<Record<string, string>> = {\n color: LEVEL_COLOR.faint,\n \"--color-neutral-text\": LEVEL_COLOR.faint,\n \"--color-text-primary\": LEVEL_COLOR.faint,\n \"--color-text-muted\": LEVEL_COLOR.faint,\n \"--color-text-dim\": LEVEL_COLOR.faint,\n};\n\n/**\n * The same declarations as {@link FAINT_TEXT_STYLE}, written as\n * `property: value;` lines for a styled-components rule. Useful for quieting a\n * block of words in a styled rule. Used by the research and development styles.\n *\n * @category Typography\n */\nexport function faintText(): string {\n return Object.entries(FAINT_TEXT_STYLE)\n .map(([property, value]) => `${property}: ${value};`)\n .join(\"\\n\");\n}\n\nconst WEIGHT_STYLES = {\n regular: css`\n font-weight: 400;\n `,\n semibold: css`\n font-weight: 600;\n `,\n} as const;\n\nconst SIZE_STYLES = {\n xs: css`\n font-size: var(--font-size-compact);\n `,\n sm: css`\n font-size: var(--font-size-value);\n `,\n base: css`\n font-size: var(--font-size-prose);\n `,\n lg: css`\n font-size: var(--font-size-figure);\n `,\n} as const;\n\n/**\n * An inline `span` with a tone, level, size and weight. Useful for colouring\n * and sizing the words around a figure so the operator can tell a label from a\n * value. Used by the landing status altitude rail. Digits are always\n * tabular (`font-variant-numeric: tabular-nums`), so a changing number does\n * not jitter. It renders whatever it is given, with no magnitude, unit or\n * formatting of its own.\n *\n * {@link Unit} renders a quantity and its symbol; `Text` colours and sizes the\n * span around it. The two compose, and that is the normal case.\n *\n * @example\n * ```tsx\n * import { useTelemetry } from \"@ksp-gonogo/sitrep-sdk\";\n * import { Cluster, Text, Unit } from \"@ksp-gonogo/ui-kit\";\n *\n * function AltitudeLine() {\n * const flight = useTelemetry(\"vessel.flight\");\n * return (\n * <Cluster>\n * <Text level=\"muted\" size=\"xs\">Altitude</Text>\n * <Text weight=\"semibold\">\n * <Unit value={flight.altitudeAsl} />\n * </Text>\n * </Cluster>\n * );\n * }\n * ```\n *\n * @category Typography\n * @categoryDescription Typography\n * Text: the type levels, faint text, truncation, expandable text, subject\n * headings, visually hidden text, and the live region that announces a change.\n */\nexport function Text({\n tone = \"neutral\",\n level,\n spaced = false,\n size,\n weight,\n children,\n ...rest\n}: TextProps) {\n return (\n <Text__Root\n $color={\n tone === \"neutral\" && level !== undefined\n ? LEVEL_COLOR[level]\n : TONE_TEXT[tone]\n }\n $spaced={spaced}\n $size={size}\n $weight={weight}\n {...rest}\n >\n {children}\n </Text__Root>\n );\n}\n\nconst Text__Root = styled.span<{\n $color: string;\n $spaced: boolean;\n $size?: TextSize;\n $weight?: TextWeight;\n}>`\n font-variant-numeric: tabular-nums;\n color: ${({ $color }) => $color};\n ${({ $size }) => $size && SIZE_STYLES[$size]}\n ${({ $weight }) => $weight && WEIGHT_STYLES[$weight]}\n ${({ $spaced }) => $spaced && `margin-left: var(--gap-lead-figure);`}\n`;\n","import type { ReactNode } from \"react\";\nimport { Text } from \"./Text\";\n\n// styleguide-emdash.test.ts allows the em dash here and nowhere else.\n/**\n * The null token, the dash that means \"no value to show\": nothing has arrived\n * yet, or the game confirmed there is none. It does not say which, so a widget\n * that has to tell them apart reads the reading's `state` and says so in\n * words. Useful for showing the operator an empty figure wherever only a string\n * fits: a formatter's return value, a template fallback, an attribute value.\n * Used by the tape and the band instruments. For a bare JSX node use\n * {@link NullValue}. {@link Unit} already draws it for an absent value.\n *\n * @category Unit\n */\nexport const NULL_DISPLAY = \"—\";\n\n/**\n * The null token {@link NULL_DISPLAY} as muted text, so an empty figure reads\n * as having no value rather than as ordinary body text. Useful for showing the\n * operator that a field has nothing to show. Used by the control frame\n * settings. Where a wrapper already carries a placeholder look, interpolate\n * {@link NULL_DISPLAY} into it instead.\n *\n * @category Unit\n */\nexport function NullValue(): ReactNode {\n return <Text level=\"muted\">{NULL_DISPLAY}</Text>;\n}\n","import {\n calendarRatio,\n type DeclaredUnit,\n onUnitRegistered,\n type RegisteredUnit,\n type UnitDeclarations,\n type UnitRung,\n} from \"@ksp-gonogo/sitrep-sdk\";\nimport { GENERATED_UNIT_KINDS } from \"./__generated__/unit-kinds\";\nimport { formatKspDate } from \"./formatKspDate\";\n\n/** A symbol the generated first-party table carries, for the runtime lookups. */\ntype GeneratedUnit = keyof typeof GENERATED_UNIT_KINDS;\n\n/**\n * What the declaration says `Unit` measures, or `never` for a symbol nothing\n * declares. Useful for checking before the operator sees a figure that a\n * requested unit is a unit of the same quantity. Used by {@link FormatsFor} and\n * {@link PresentableAs}.\n *\n * A unit an Uplink merges into `UnitDeclarations` is treated the same as a\n * built-in one.\n *\n * @category Unit\n */\nexport type KindOfSymbol<Unit extends string> = Unit extends DeclaredUnit\n ? UnitDeclarations[Unit] extends { kind: infer Kind }\n ? Kind\n : never\n : never;\n\n/**\n * Every declared symbol that measures `Kind`. Useful for listing the units a\n * figure of one quantity may be pinned to. Used by {@link FormatsForKind}.\n *\n * @category Unit\n */\nexport type SymbolsOfKind<Kind> = {\n [Unit in DeclaredUnit]: KindOfSymbol<Unit> extends Kind ? Unit : never;\n}[DeclaredUnit];\n\n/**\n * The ladder `Unit` is declared on, or `never` for a unit that climbs none.\n * Useful for telling which units settle on one scale together, so every figure\n * in a group shows the same unit to the operator. Used by {@link LadderName}\n * and {@link KindOfGroup}.\n *\n * @category Unit\n */\nexport type LadderOfSymbol<Unit extends string> = Unit extends DeclaredUnit\n ? UnitDeclarations[Unit] extends {\n ladder: infer Ladder extends string;\n }\n ? Ladder\n : never\n : never;\n\n/**\n * Every symbol of kind `Kind` that exists only as a conversion target (`°C`),\n * which the declarations do not name but a conversion still reaches. Useful for\n * letting the operator read a figure in a unit such as degrees Celsius that is\n * never sent on the wire. A conversion whose source unit is itself undeclared\n * is skipped, so `°C→K` does not make every kind accept `K`. Used by\n * {@link PresentableAsKind}.\n *\n * @category Unit\n */\nexport type ConversionTargetsOfKind<Kind> = {\n [Conversion in keyof typeof CONVERSIONS]: Conversion extends `${infer Source}→${infer Target}`\n ? [KindOfSymbol<Source>] extends [never]\n ? never\n : [KindOfSymbol<Source>] extends [Kind]\n ? Target\n : never\n : never;\n}[keyof typeof CONVERSIONS];\n\n/**\n * Every unit that measures the same thing as `Unit`, which is exactly the set a\n * value in `Unit` may be re-expressed in. Useful for pinning the unit the\n * operator reads a figure in: `format=\"km/h\"` checks on a speed and fails on a\n * length. Used by the `format` prop of {@link Unit}.\n *\n * A unit an Uplink declares in `UnitDeclarations` widens the accepted set.\n *\n * A literal symbol nothing declares accepts no format at all, since there is no\n * kind to check the request against. Only a wide `string` accepts any string.\n *\n * @category Unit\n */\nexport type FormatsFor<Unit extends string> = string extends Unit\n ? string\n : FormatsForKind<KindOfSymbol<Unit>>;\n\n/**\n * {@link FormatsFor}, asked of the kind rather than of one of its units, for a\n * pin addressed to a whole group that has no single unit to check against.\n * Useful for pinning the unit a group of figures shares. Used by\n * {@link UnitSharedFormat}.\n *\n * @category Unit\n */\nexport type FormatsForKind<Kind> = SymbolsOfKind<Kind>;\n\n/**\n * Every unit a value in `Unit` may be shown as, which is every unit of its kind\n * plus the presentation-only ones the conversion table reaches. Useful for\n * showing the operator a figure in a familiar unit, such as degrees Celsius for\n * a temperature sent in kelvin. Used by the `as` prop of {@link Unit}.\n *\n * Wider than {@link FormatsFor} by exactly the symbols that are not on the\n * wire: `format` pins a rung, `as` re-expresses, so `°C` belongs only to `as`.\n * Both refuse a cross-kind request: `as=\"kg\"` on a length is an error.\n *\n * @category Unit\n */\nexport type PresentableAs<Unit extends string> = string extends Unit\n ? string\n : PresentableAsKind<KindOfSymbol<Unit>>;\n\n/**\n * {@link PresentableAs}, asked of the kind. See {@link FormatsForKind}. Used by\n * {@link UnitSharedFormat}.\n *\n * @category Unit\n */\nexport type PresentableAsKind<Kind> =\n | SymbolsOfKind<Kind>\n | ConversionTargetsOfKind<Kind>;\n\n/**\n * How many of the kind's base unit one of `symbol` is worth.\n *\n * The live calendar first, because `d`, `h`, `min` and `science/day` are sized\n * by the running game and codegen bakes stock Kerbin figures for all four.\n * Then the unit's declared ratio, then the rung's own divisor. The calendar\n * table is the SDK's, so a formatted duration and a computed one agree.\n */\nfunction ratioOf(symbol: string): number | undefined {\n const fromCalendar = calendarRatio(symbol);\n if (fromCalendar !== undefined) return fromCalendar;\n const declared = declarationOf(symbol);\n if (declared) return declared.ratio;\n const ladder = rungLadderOf(symbol);\n return ladder === undefined\n ? undefined\n : laddersByName[ladder]?.find((r) => r.symbol === symbol)?.per;\n}\n\nimport { formatDuration, formatIrlDuration } from \"./formatDuration\";\nimport { NULL_DISPLAY } from \"./NullValue\";\n\n/*\n * Unit-aware value formatting. The contract declares what a field IS (metres,\n * m/s, kelvin) and this decides how to SHOW it. The wire is canonical SI and\n * never pre-scaled, because a pre-scaled value cannot be graphed, diffed or\n * re-scaled by a consumer; scaling is a presentation decision.\n */\n\n/**\n * What a unit measures. The kind is what makes the system checkable: it says\n * `m` and `km` are interchangeable and `m` and `m/s` are not, and it selects\n * the ladder and the precision rule.\n *\n * A kind names a dimension, never a unit symbol: `length` is what `m` and `km`\n * measure, `planeAngle` is what `°` measures and `universalTime` is what `ut`\n * measures.\n *\n * @category Unit\n */\nexport type KnownQuantityKind =\n | \"length\"\n | \"speed\"\n | \"acceleration\"\n | \"mass\"\n | \"force\"\n | \"pressure\"\n | \"temperature\"\n | \"time\"\n // An INSTANT on the game's clock, not a length of it: render it with `<MissionDate>`, not `<Unit>`.\n | \"universalTime\"\n // Seconds by dimension but not a duration: a 320 s engine must not read \"5min 20s\".\n | \"specificImpulse\"\n // Wall-clock time, where a day is 24 hours rather than the game's 6.\n | \"irlTime\"\n | \"planeAngle\"\n | \"power\"\n // Data at rest (a file, a drive), bit-based like `dataRate` but not interchangeable with it.\n | \"data\"\n | \"dataRate\"\n | \"doseRate\"\n | \"irradiance\"\n | \"level\"\n | \"density\"\n // Kilograms per second, unlike `resourceFlow`, which counts in whatever the tank counts in.\n | \"massFlow\"\n | \"gravParameter\"\n | \"dimensionless\"\n | \"percent\"\n | \"scienceData\"\n | \"scienceRate\"\n | \"ratio\"\n /*\n * Non-dimensional kinds: \"this has no physical dimension\", unlike\n * `dimensionless` (a real measurement with no unit, Mach and TWR) and unlike\n * an absent unit (nobody said). They let the contract DECLARE non-quantities.\n */\n | \"area\"\n | \"volume\"\n | \"angularSpeed\"\n | \"funds\"\n | \"science\"\n | \"reputation\"\n // Currencies that FLOW: a rate wants a decimal where a balance does not.\n | \"fundsRate\"\n | \"reputationRate\"\n | \"count\"\n | \"id\"\n | \"resourceUnits\"\n | \"resourceFlow\"\n | \"text\"\n | \"flag\"\n | \"enum\"\n | \"n/a\";\n\n/**\n * A quantity kind, open to kinds this package has never heard of.\n *\n * The `string & {}` member lets a third-party Uplink introduce its own dimension\n * while the known kinds still autocomplete.\n *\n * @category Unit\n */\nexport type QuantityKind = KnownQuantityKind | (string & {});\n\n/**\n * One step of a unit's scale: a symbol (`m`, `km`, `Mm`) and the size, in the\n * base unit, from which a value is written in it. A kind's steps in order are\n * its ladder, and choosing a unit for a value is choosing its rung.\n *\n * @category Unit\n */\nexport type Rung = UnitRung;\n\n/**\n * Ladders, ascending, each in its kind's base unit. A dimension with no entry\n * never scales.\n *\n * Deliberately absent:\n * - `speed`, because delta-v and surface speed are read in m/s universally\n * - `temperature`, because kelvin has no prefix convention and Celsius is an\n * offset conversion (see `as`)\n * - `time`, which has its own composite formatter\n * - `gravParameter`, which uses scientific notation (see `SCIENTIFIC`)\n * - `planeAngle`, `ratio`, `dimensionless`, which have no magnitudes to climb\n */\nexport const LADDERS = {\n length: [\n { from: 0, symbol: \"m\", per: 1 },\n { from: 1e3, symbol: \"km\", per: 1e3 },\n { from: 1e6, symbol: \"Mm\", per: 1e6 },\n { from: 1e9, symbol: \"Gm\", per: 1e9 },\n // Out of reach in the stock system, kept so an outer-planets install does not stop at \"1500.0 Gm\".\n { from: 1e12, symbol: \"Tm\", per: 1e12 },\n ],\n // Every threshold and divisor is in KILOGRAMS, including the gram-based astronomical rungs (1 Yg is 1e21 kg).\n mass: [\n { from: 0, symbol: \"kg\", per: 1 },\n { from: 1e3, symbol: \"t\", per: 1e3 },\n { from: 1e6, symbol: \"kt\", per: 1e6 },\n { from: 1e9, symbol: \"Tg\", per: 1e9 },\n { from: 1e12, symbol: \"Pg\", per: 1e12 },\n { from: 1e15, symbol: \"Eg\", per: 1e15 },\n { from: 1e18, symbol: \"Zg\", per: 1e18 },\n { from: 1e21, symbol: \"Yg\", per: 1e21 },\n ],\n force: [\n { from: 0, symbol: \"N\", per: 1 },\n { from: 1e3, symbol: \"kN\", per: 1e3 },\n { from: 1e6, symbol: \"MN\", per: 1e6 },\n ],\n // Descends below the base unit: the upper atmosphere runs to fractions of a pascal.\n pressure: [\n { from: 0, symbol: \"mPa\", per: 1e-3 },\n { from: 1, symbol: \"Pa\", per: 1 },\n { from: 1e3, symbol: \"kPa\", per: 1e3 },\n { from: 1e6, symbol: \"MPa\", per: 1e6 },\n ],\n /*\n * Byte rungs on a BIT base, so a drive in MB and a link budget in bit/s are\n * commensurable. Decimal throughout (1 KB is 8e3 bit), matching `dataRate`;\n * the binary KiB family is deliberately absent. The `bit` rung keeps a\n * sub-byte reading from rendering as a fraction of a byte.\n */\n data: [\n { from: 0, symbol: \"bit\", per: 1 },\n { from: 8, symbol: \"B\", per: 8 },\n { from: 8e3, symbol: \"KB\", per: 8e3 },\n { from: 8e6, symbol: \"MB\", per: 8e6 },\n { from: 8e9, symbol: \"GB\", per: 8e9 },\n ],\n /**\n * The bit-rate rungs, decimal throughout and based in bit/s, matching `data`.\n */\n dataRate: [\n { from: 0, symbol: \"bit/s\", per: 1 },\n { from: 1e3, symbol: \"kbit/s\", per: 1e3 },\n { from: 1e6, symbol: \"Mbit/s\", per: 1e6 },\n { from: 1e9, symbol: \"Gbit/s\", per: 1e9 },\n ],\n // Based in watts although the wire declares kW; the MW rung covers reentry heat flux.\n power: [\n { from: 0, symbol: \"W\", per: 1 },\n { from: 1e3, symbol: \"kW\", per: 1e3 },\n { from: 1e6, symbol: \"MW\", per: 1e6 },\n { from: 1e9, symbol: \"GW\", per: 1e9 },\n ],\n // One always-on rung: dose rates arrive in rad/s and are conventionally read in rad/h.\n doseRate: [{ from: 0, symbol: \"rad/h\", per: 1 / 3600 }],\n // Based in kg/m³ with a gram rung beneath it: sea-level air is about one kilogram per cubic metre, and the upper atmosphere is read in grams.\n density: [\n { from: 0, symbol: \"g/m³\", per: 1e-3 },\n { from: 1, symbol: \"kg/m³\", per: 1 },\n ],\n} satisfies Record<string, readonly Rung[]>;\n\n/**\n * Every ladder by name: the first-party ones above and every one a\n * registration has supplied rungs for since.\n */\nconst laddersByName: Record<string, readonly Rung[]> = { ...LADDERS };\n\n/**\n * Every ladder (a kind's {@link Rung}s in order) a declared unit names, and\n * therefore every group that settles one unit together. A unit on none of them\n * is a group of its own: `m`, `km` and `Mm` are one group and `s` and `min`\n * are two. Useful for naming the group of figures that shows one unit to the\n * operator. Used by {@link UnitGroupKey}.\n *\n * @category Unit\n */\nexport type LadderName = {\n [Unit in DeclaredUnit]: LadderOfSymbol<Unit>;\n}[DeclaredUnit];\n\n/**\n * What a pin may be addressed to: one group, named the way the group is formed.\n * Useful for fixing the unit a group of figures shows to the operator. Used by\n * the `pins` of {@link UnitSharedFormat}.\n *\n * A unit on a ladder is named by the ladder, because every unit of it settles\n * together and `m`, `km` and `Mm` are one thing to pin. Everything else is named\n * by the unit, because nothing interconverts it with its siblings and a pin on\n * `s` says nothing about `min`. Keyed this way, a group is pinned at most once\n * by construction.\n *\n * @category Unit\n */\nexport type UnitGroupKey =\n | LadderName\n | {\n [Unit in DeclaredUnit]: [LadderOfSymbol<Unit>] extends [never]\n ? Unit\n : never;\n }[DeclaredUnit];\n\n/**\n * What the group named by `Group` measures, so a pin addressed to it can be\n * checked. Useful for refusing a pin whose unit does not measure the same\n * quantity as the group. Used by {@link UnitSharedFormat}.\n *\n * A ladder key measures whatever its units do; a unit key resolves through the\n * declarations the same way a lone `<Unit>` does.\n *\n * @category Unit\n */\nexport type KindOfGroup<Group extends UnitGroupKey> = Group extends LadderName\n ? {\n [Unit in DeclaredUnit]: [LadderOfSymbol<Unit>] extends [Group]\n ? [LadderOfSymbol<Unit>] extends [never]\n ? never\n : KindOfSymbol<Unit>\n : never;\n }[DeclaredUnit]\n : KindOfSymbol<Group>;\n\n/**\n * Kinds that render in scientific notation when nothing says otherwise: their\n * exponent is huge and has no conventional prefix.\n */\nconst SCIENTIFIC = new Set<string>([\"gravParameter\"]);\n\n/** Significant figures in a scientific mantissa, unless the caller overrides. */\nconst SCIENTIFIC_SIGNIFICANT = 4;\n\nconst SUPERSCRIPT: Record<string, string> = {\n \"0\": \"⁰\",\n \"1\": \"¹\",\n \"2\": \"²\",\n \"3\": \"³\",\n \"4\": \"⁴\",\n \"5\": \"⁵\",\n \"6\": \"⁶\",\n \"7\": \"⁷\",\n \"8\": \"⁸\",\n \"9\": \"⁹\",\n \"-\": \"⁻\",\n};\n\n/** `3.532×10¹²`, not `3.532e12`, as a plain string usable in an axis label or `aria-label`. */\nfunction toScientific(value: number, significant: number): string {\n if (value === 0) return \"0\";\n const exponent = Math.floor(Math.log10(Math.abs(value)));\n const mantissa = value / 10 ** exponent;\n // `significant` counts digits, and the mantissa always has exactly one before the point, so the rest are decimals.\n const digits = String(exponent)\n .split(\"\")\n .map((c) => SUPERSCRIPT[c] ?? c)\n .join(\"\");\n return `${mantissa.toFixed(Math.max(0, significant - 1))}×10${digits}`;\n}\n\n/** Standard gravity, the SI definition, which is also KSP's single global constant and Kerbin's surface gravity. */\nexport { STANDARD_GRAVITY } from \"@ksp-gonogo/sitrep-sdk\";\n\nimport { STANDARD_GRAVITY } from \"@ksp-gonogo/sitrep-sdk\";\n\n/**\n * Presentation conversions: what a value may be shown as, given what it is.\n *\n * Keyed source→target, `target = value / per + offset`, which covers the\n * offset conversions a ladder cannot. Only within a kind: `formatQuantity`\n * refuses a cross-kind conversion. `as const` is load-bearing, since\n * {@link PresentableAs} reads the pair keys.\n */\nconst CONVERSIONS = {\n \"K→°C\": { per: 1, offset: -273.15 },\n \"°C→K\": { per: 1, offset: 273.15 },\n \"m/s²→g\": { per: STANDARD_GRAVITY, offset: 0 },\n \"g→m/s²\": { per: 1 / STANDARD_GRAVITY, offset: 0 },\n \"rad→°\": { per: Math.PI / 180, offset: 0 },\n \"°→rad\": { per: 180 / Math.PI, offset: 0 },\n} as const satisfies Record<string, { per: number; offset: number }>;\n\n/** The same table, indexable by a key built at runtime. */\nconst CONVERSION_BY_PAIR: Record<string, { per: number; offset: number }> =\n CONVERSIONS;\n\n/**\n * How much precision a kind is read at, as decimal places on the scaled value.\n *\n * Per kind rather than per magnitude, so a readout holds a stable digit count\n * as the value moves.\n */\nconst DECIMALS: Record<string, number> = {\n length: 1,\n speed: 1,\n acceleration: 2,\n mass: 2,\n force: 1,\n pressure: 2,\n temperature: 0,\n time: 0,\n irlTime: 0,\n specificImpulse: 0,\n planeAngle: 2,\n density: 4,\n // A small RCS burn runs at a fraction of a kilogram a second, which must not round to zero.\n massFlow: 2,\n data: 1,\n dataRate: 1,\n power: 1,\n doseRate: 4,\n irradiance: 1,\n level: 1,\n dimensionless: 2,\n percent: 1,\n scienceData: 1,\n scienceRate: 1,\n ratio: 0,\n // A count is integral: \"3.00 crew\" is wrong in a way \"3.00 Mach\" is not.\n count: 0,\n id: 0,\n resourceUnits: 1,\n resourceFlow: 2,\n area: 1,\n volume: 1,\n angularSpeed: 0,\n funds: 0,\n science: 1,\n reputation: 1,\n // A reputation decaying by 0.11 a day rounds to nothing without decimals.\n fundsRate: 1,\n reputationRate: 2,\n};\n\n/**\n * What to show beside the number, when it differs from the token the wire\n * carries. The non-dimensional tokens name a category, not a symbol (\"12\n * count\" is not a readout), so they render with no symbol at all. `ratio` and\n * `time` carry extra behaviour and keep their own branches below.\n */\nconst DISPLAY_BY_KIND: Record<string, string> = {\n // Text fallbacks for the currency icons.\n funds: \"f\",\n science: \"sci\",\n reputation: \"rep\",\n // The wire token is `Mit`; the game writes \"mits\".\n scienceData: \"mits\",\n specificImpulse: \"s\",\n count: \"\",\n id: \"\",\n text: \"\",\n flag: \"\",\n enum: \"\",\n \"n/a\": \"\",\n};\n\n/**\n * What `registerUnit` taught the kit about each Uplink unit, layered over the\n * generated first-party table. Empty until an Uplink registers something.\n */\ninterface UnitFacts {\n readonly kind: QuantityKind;\n readonly ratio: number;\n readonly ladder?: string;\n}\n\nconst REGISTERED_UNITS: Record<string, UnitFacts> = {};\n\n/** The kind every ladder scales, by ladder name. */\nconst LADDER_KINDS: Record<string, QuantityKind> = Object.fromEntries(\n Object.keys(LADDERS).map((name) => [name, name]),\n);\n\n/** The declaration a symbol has, registered or first-party, if it has one. */\nfunction declarationOf(symbol: string): UnitFacts | undefined {\n return (\n REGISTERED_UNITS[symbol] ?? GENERATED_UNIT_KINDS[symbol as GeneratedUnit]\n );\n}\n\n/**\n * The ladder a symbol climbs within, by name.\n *\n * A declared unit climbs exactly the ladder its declaration names, and none if\n * it names none, matching `UnitGroupKey`. The ladder is declared rather than\n * taken from the kind because bits and bytes are both `data` and must never\n * interleave. An undeclared symbol is a rung and climbs the ladder listing it.\n */\nfunction ladderNameOf(symbol: string | undefined): string | undefined {\n if (symbol === undefined) return undefined;\n const declared = declarationOf(symbol);\n if (declared) return declared.ladder;\n return rungLadderOf(symbol);\n}\n\n/** The rungs a value climbs. A unit on no ladder never scales. */\nfunction ladderForUnit(unit: string | undefined): readonly Rung[] | undefined {\n const name = ladderNameOf(unit);\n return name === undefined ? undefined : laddersByName[name];\n}\n\n/**\n * The ladder each rung symbol belongs to, since a rung such as `Mbit/s` is not\n * a declared unit. Built lazily and rebuilt whenever a registration supplies a\n * ladder.\n */\nlet rungLadders: Record<string, string> | undefined;\n\nfunction rungLadderOf(symbol: string): string | undefined {\n if (rungLadders === undefined) {\n rungLadders = {};\n for (const [name, rungs] of Object.entries(laddersByName)) {\n for (const rung of rungs) {\n // First ladder wins, so a base symbol shared with the model keeps the model's answer rather than a ladder's.\n rungLadders[rung.symbol] ??= name;\n }\n }\n }\n return rungLadders[symbol];\n}\n\nfunction kindOfRung(symbol: string): QuantityKind | undefined {\n const name = rungLadderOf(symbol);\n return name === undefined ? undefined : LADDER_KINDS[name];\n}\n\n/** The kind of a presentation-only unit (`°C`), named only by the conversion table. */\nfunction kindOfConversion(symbol: string): QuantityKind | undefined {\n for (const pair of Object.keys(CONVERSIONS)) {\n const [from, to] = pair.split(\"\\u2192\");\n if (to === symbol) {\n return declarationOf(from)?.kind ?? kindOfRung(from);\n }\n }\n return undefined;\n}\n\n/**\n * What each displayed symbol is called, for the accessibility tree: a screen\n * reader announces `km` as \"kay em\" and `°` as nothing at all.\n *\n * Keyed on the displayed symbol rather than the wire token, so every rung and\n * every currency abbreviation has its own entry.\n */\nconst WORD_BY_SYMBOL: Record<string, string> = {\n m: \"metres\",\n km: \"kilometres\",\n Mm: \"megametres\",\n Gm: \"gigametres\",\n Tm: \"terametres\",\n kg: \"kilograms\",\n t: \"tonnes\",\n kt: \"kilotonnes\",\n Tg: \"teragrams\",\n Pg: \"petagrams\",\n Eg: \"exagrams\",\n Zg: \"zettagrams\",\n Yg: \"yottagrams\",\n N: \"newtons\",\n kN: \"kilonewtons\",\n MN: \"meganewtons\",\n mPa: \"millipascals\",\n Pa: \"pascals\",\n kPa: \"kilopascals\",\n MPa: \"megapascals\",\n W: \"watts\",\n kW: \"kilowatts\",\n MW: \"megawatts\",\n GW: \"gigawatts\",\n \"bit/s\": \"bits per second\",\n \"kbit/s\": \"kilobits per second\",\n \"Mbit/s\": \"megabits per second\",\n \"Gbit/s\": \"gigabits per second\",\n bit: \"bits\",\n B: \"bytes\",\n KB: \"kilobytes\",\n MB: \"megabytes\",\n GB: \"gigabytes\",\n \"m/s\": \"metres per second\",\n \"m/s\\u00B2\": \"metres per second squared\",\n g: \"gee\",\n rpm: \"revolutions per minute\",\n \"\\u00B0\": \"degrees\",\n \"\\u2032\": \"arcminutes\",\n \"\\u2033\": \"arcseconds\",\n rad: \"radians\",\n K: \"kelvin\",\n \"\\u00B0C\": \"degrees celsius\",\n s: \"seconds\",\n min: \"minutes\",\n h: \"hours\",\n dB: \"decibels\",\n \"rad/s\": \"radians per second\",\n \"W/m\\u00B2\": \"watts per square metre\",\n \"g/m\\u00B3\": \"grams per cubic metre\",\n \"kg/m\\u00B3\": \"kilograms per cubic metre\",\n \"m\\u00B3/s\\u00B2\": \"cubic metres per second squared\",\n \"m\\u00B2\": \"square metres\",\n \"m\\u00B3\": \"cubic metres\",\n \"%\": \"percent\",\n Mit: \"mits\",\n \"science/day\": \"science per day\",\n \"f/day\": \"funds per day\",\n \"rep/day\": \"reputation per day\",\n units: \"units\",\n \"units/s\": \"units per second\",\n f: \"funds\",\n sci: \"science\",\n rep: \"reputation\",\n};\n\n/**\n * What a displayed symbol is called, or undefined for one with no word (the\n * category kinds display as an empty string and have nothing to announce).\n */\nexport function wordForSymbol(symbol: string): string | undefined {\n const direct = WORD_BY_SYMBOL[symbol];\n if (direct !== undefined) return direct;\n const compound = splitCurrencyCompound(symbol);\n if (compound === undefined) return undefined;\n const head = WORD_BY_SYMBOL[compound.head];\n if (head === undefined) return undefined;\n // The denominator is singular (\"per megabyte\"), and a word ending in \"ius\" or \"is\" (\"celsius\") has no plural to drop.\n const rest = WORD_BY_SYMBOL[compound.rest]?.replace(/(?<![iu])s$/, \"\");\n return `${head} per ${rest ?? compound.rest}`;\n}\n\nfunction formatWhole(\n quantity: { magnitude: number; unit: string } | null | undefined,\n opts: FormatQuantityOptions,\n): FormattedQuantity {\n return formatQuantity(quantity?.magnitude, quantity?.unit, opts);\n}\n\n/**\n * A quantity as text for a screen reader: the value followed by the unit's\n * word, so an accessible name reads \"250.0 kilometres\" where the symbol would\n * be spoken as \"kay em\". Useful in the places that cannot take a node\n * (`aria-label`, `title`, an SVG `aria-valuetext`). Used by {@link Dial} and\n * {@link Meter} for their accessible values. To render a quantity, use\n * {@link Unit} or {@link writeQuantity}. Falls back to the symbol for a unit\n * with no word.\n *\n * @category Unit\n */\nexport function speakQuantity(\n quantity: { magnitude: number; unit: string } | null | undefined,\n opts: FormatQuantityOptions = {},\n): string {\n const { value: text, symbol } = formatWhole(quantity, opts);\n if (symbol === \"\") return text;\n return `${text} ${wordForSymbol(symbol) ?? symbol}`;\n}\n\n/**\n * The symbols written hard against the number: plane angle, because SI says so\n * (`22°`, but `22 °C`), and the currency marks, which are typography rather\n * than unit symbols (`42,500f`). Shared by `<Unit>` and `writeQuantity` so\n * both agree.\n */\nexport const ATTACHED_SYMBOLS: ReadonlySet<string> = new Set([\n \"°\",\n \"′\",\n \"″\",\n \"f\",\n \"sci\",\n \"rep\",\n]);\n\n/**\n * A quantity as it is written: the value and the unit's symbol, `250.0 km`.\n * Useful for showing the operator a figure in text a node cannot hold. Used by\n * {@link JogWheel} for its caret label and by {@link MissionDateField}.\n *\n * For visible text that cannot take a node: an SVG `<text>`, a canvas label, a\n * chart annotation measured before it is drawn. Anywhere a node fits, use\n * {@link Unit}; for an accessible name, {@link speakQuantity}.\n *\n * An ordinary space, not the thin space `<Unit>` sets, since a U+2009 is at\n * the mercy of the SVG or canvas renderer.\n *\n * @category Unit\n */\nexport function writeQuantity(\n quantity: { magnitude: number; unit: string } | null | undefined,\n opts: FormatQuantityOptions = {},\n): string {\n const { value: text, symbol } = formatWhole(quantity, opts);\n if (symbol === \"\") return text;\n return ATTACHED_SYMBOLS.has(symbol)\n ? `${text}${symbol}`\n : `${text} ${symbol}`;\n}\n\n/**\n * The symbol shown beside a value: the kind's display override if it has one,\n * otherwise the token itself.\n */\nexport function displaySymbol(\n unit: string,\n kind: QuantityKind | undefined,\n): string {\n const compound = splitCurrencyCompound(unit);\n if (compound !== undefined) return `${compound.head}/${compound.rest}`;\n return kind === undefined ? unit : (DISPLAY_BY_KIND[kind] ?? unit);\n}\n\n/** The currency names a compound token may start with, and the symbol each is drawn as (the glyph where it has one). */\nconst CURRENCY_HEAD: Record<string, string> = {\n science: \"sci\",\n funds: \"f\",\n reputation: \"rep\",\n sci: \"sci\",\n f: \"f\",\n rep: \"rep\",\n};\n\n/**\n * A compound unit whose numerator is a currency (`science/day`, `science/MB`),\n * split into the symbol that currency is drawn as and the rest of the token.\n * Undefined for any other token, including a bare currency.\n */\nexport function splitCurrencyCompound(\n token: string,\n): { head: string; rest: string } | undefined {\n const slash = token.indexOf(\"/\");\n if (slash <= 0) return undefined;\n const head = CURRENCY_HEAD[token.slice(0, slash)];\n return head === undefined\n ? undefined\n : { head, rest: token.slice(slash + 1) };\n}\n\n/**\n * What a unit symbol measures, or undefined for one we do not know: from its\n * declaration, then the ladder a rung belongs to, then the conversion that\n * names it.\n */\nexport function kindOfUnit(\n symbol: string | undefined,\n): QuantityKind | undefined {\n if (symbol === undefined) return undefined;\n return (\n declarationOf(symbol)?.kind ??\n kindOfRung(symbol) ??\n kindOfConversion(symbol)\n );\n}\n\nfunction sameRungs(a: readonly Rung[], b: readonly Rung[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (rung, i) =>\n rung.from === b[i].from &&\n rung.symbol === b[i].symbol &&\n rung.per === b[i].per,\n )\n );\n}\n\n/**\n * Applies what one `registerUnit` call says about how a unit reads, including\n * registrations made before this module loaded.\n *\n * Two registrations of one symbol must mean the same thing by it, and two of\n * one ladder must climb the same rungs, so a disagreement throws rather than\n * rendering by load order. Identical registrations are a no-op, so two Uplinks\n * can share a ladder.\n */\nfunction applyRegisteredUnit(unit: RegisteredUnit): void {\n const { symbol, kind, ratio, ladder, rungs } = unit;\n const prior = declarationOf(symbol);\n if (prior && (prior.kind !== kind || prior.ladder !== ladder)) {\n throw new Error(\n `Unit \"${symbol}\" is already declared as ${prior.kind}` +\n `${prior.ladder ? ` (ladder ${prior.ladder})` : \"\"} and cannot be ` +\n `registered as ${kind}${ladder ? ` (ladder ${ladder})` : \"\"}. ` +\n \"Two mods declaring the same symbol must mean the same thing by it: \" +\n \"a value would otherwise render differently depending on which loaded last.\",\n );\n }\n if (ladder !== undefined) {\n const ladderKind = LADDER_KINDS[ladder];\n if (ladderKind !== undefined && ladderKind !== kind) {\n throw new Error(\n `Unit \"${symbol}\" names the ${ladder} ladder, which scales ${ladderKind}, ` +\n `not ${kind}. Every unit on one ladder measures one kind.`,\n );\n }\n const existing = laddersByName[ladder];\n if (rungs !== undefined && existing && !sameRungs(existing, rungs)) {\n throw new Error(\n `The ${ladder} ladder already has rungs, and \"${symbol}\" registers ` +\n \"different ones. Two registrations of one ladder must climb the same rungs.\",\n );\n }\n LADDER_KINDS[ladder] = kind;\n if (rungs !== undefined && !existing) {\n laddersByName[ladder] = rungs;\n // A new ladder brings rung symbols the cached index does not hold.\n rungLadders = undefined;\n }\n }\n REGISTERED_UNITS[symbol] =\n ladder === undefined ? { kind, ratio } : { kind, ratio, ladder };\n if (unit.decimals !== undefined) DECIMALS[kind] = unit.decimals;\n if (unit.scientific) SCIENTIFIC.add(kind);\n if (unit.display !== undefined) DISPLAY_BY_KIND[kind] = unit.display;\n if (unit.word !== undefined) WORD_BY_SYMBOL[symbol] = unit.word;\n}\n\n/**\n * How a quantity is written: the unit to pin, the number of decimals, and the\n * scale to draw it against. Useful for fixing the unit and precision a figure\n * is shown to the operator at. Taken by {@link writeQuantity} and {@link Unit}.\n *\n * @category Unit\n */\nexport interface FormatQuantityOptions {\n /**\n * Pin the unit rather than letting the ladder choose, for where convention\n * beats magnitude (orbital velocity in km/s, a broadcast in km/h).\n *\n * Typed by kind, so `format=\"km/h\"` checks on a speed and is an error on a\n * length. Any unit of the same kind is accepted, including ones the ladder\n * would never pick.\n */\n format?: string;\n /**\n * `\"auto\"` climbs the kind's ladder (or uses the kind's default presentation,\n * such as scientific notation or a composite duration), `\"never\"` holds the\n * base unit and formats it as a plain number, `\"scientific\"` forces\n * scientific notation. `\"compact\"` is auto, except that a kind counted like\n * money writes ten thousand and over to three significant figures with a\n * magnitude suffix (`1.29Mf`), for a tile with no room for every digit.\n * Defaults to auto.\n */\n scale?: \"auto\" | \"never\" | \"scientific\" | \"compact\";\n /**\n * Show the value in a different unit of the same kind: `as: \"°C\"` on a kelvin\n * field, `as: \"g\"` on an m/s² one. A cross-kind request is refused and the\n * value renders in its true unit.\n */\n as?: string;\n /** Override the kind's decimal places. */\n decimals?: number;\n /**\n * The unit the last render settled on, read from the formatted quantity's\n * `rung`. A rung is one unit on the ladder a kind of quantity climbs as it\n * grows (`m`, then `km`, then `Mm`). Pass it back so a value hovering on the\n * boundary between two rungs does not flicker between them. Nothing keeps it\n * for you: {@link Unit} formats each render from its props alone, so a caller\n * that wants the steadiness holds the last rung and passes it here.\n */\n heldSymbol?: string;\n}\n\nexport interface FormattedQuantity {\n /** The scaled number, formatted. `NULL_DISPLAY` when there is no value. */\n value: string;\n /** The symbol to show beside it. Empty when the unit is unknown or bare. */\n symbol: string;\n /** The unit actually used, one rung of the kind's ladder (`m`, `km`, `Mm`), to feed back as `heldSymbol` on the next render. */\n rung: string;\n}\n\n/**\n * How far a value must fall below a rung's threshold before dropping back down,\n * so 999.6 m does not flicker between \"1.0 km\" and \"1000 m\".\n */\nconst HYSTERESIS = 0.05;\n\n/** The kinds counted like money: they group from a thousand, and their symbols attach (see ATTACHED_SYMBOLS). */\nconst COUNTED_LIKE_MONEY: ReadonlySet<string> = new Set([\n \"funds\",\n \"science\",\n \"reputation\",\n]);\n\n/** `useGrouping`'s string form and `signDisplay: \"negative\"` are ES2023 and the published package targets ES2022, so they are typed here and cast once. */\ninterface GroupingOptions\n extends Omit<Intl.NumberFormatOptions, \"useGrouping\" | \"signDisplay\"> {\n useGrouping?: \"always\" | \"auto\" | \"min2\" | boolean;\n signDisplay?: Intl.NumberFormatOptions[\"signDisplay\"] | \"negative\";\n}\n\n/**\n * The locale every quantity in the app is written in.\n *\n * `undefined` means the reader's own. Only a test pins it (to `en-GB`), so a\n * render is reproducible across machines.\n */\nlet locale: string | undefined;\n\n/**\n * Pin the locale every quantity is written in, or pass `undefined` to go back\n * to the reader's own. One call changes every readout at once. Useful for\n * writing every figure the operator reads in one locale.\n *\n * @category Unit\n */\nexport function setQuantityLocale(next: string | undefined): void {\n locale = next;\n formatters.clear();\n}\n\n/** Built `Intl.NumberFormat`s, cached because construction is expensive and this runs per readout per frame. */\nconst formatters = new Map<string, Intl.NumberFormat>();\n\nfunction numberFormat(decimals: number, money: boolean): Intl.NumberFormat {\n const key = `${locale ?? \"\"}|${decimals}|${money}`;\n let existing = formatters.get(key);\n if (existing === undefined) {\n const options: GroupingOptions = {\n minimumFractionDigits: decimals,\n maximumFractionDigits: decimals,\n // `min2` is SI's rule (`3200 K`, `12,400 m`); money always groups (`2,340f`).\n useGrouping: money ? \"always\" : \"min2\",\n // A reading that rounds to zero is written as zero, never \"-0\".\n signDisplay: \"negative\",\n };\n existing = new Intl.NumberFormat(\n locale,\n options as Intl.NumberFormatOptions,\n );\n formatters.set(key, existing);\n }\n return existing;\n}\n\n/** The smallest magnitude `scale: \"compact\"` shortens; below it every digit fits. */\nconst COMPACT_FROM = 1e4;\n\n/**\n * The magnitude suffixes `scale: \"compact\"` writes, ascending. Spelled out\n * rather than taken from `Intl`'s compact notation, whose suffixes vary by\n * locale and include a lowercase `m` that reads as metres beside a unit.\n */\nconst COMPACT_SUFFIXES = [\"\", \"k\", \"M\", \"G\", \"T\"] as const;\n\n/** A money-like count to three significant figures with its magnitude suffix: `1.29M`, `12.5k`. */\nfunction compact(value: number): string {\n let tier = Math.min(\n Math.floor(Math.log10(Math.abs(value)) / 3),\n COMPACT_SUFFIXES.length - 1,\n );\n const format = significantFormat();\n let digits = format.format(value / 1000 ** tier);\n // Three significant figures round 999,500 up to a fourth digit, so it is \"1M\", never \"1,000k\".\n if (\n tier < COMPACT_SUFFIXES.length - 1 &&\n Math.abs(value / 1000 ** tier) >= 999.5\n ) {\n tier += 1;\n digits = format.format(value / 1000 ** tier);\n }\n return `${digits}${COMPACT_SUFFIXES[tier]}`;\n}\n\nfunction significantFormat(): Intl.NumberFormat {\n const key = `${locale ?? \"\"}|significant3`;\n let existing = formatters.get(key);\n if (existing === undefined) {\n existing = new Intl.NumberFormat(locale, {\n maximumSignificantDigits: 3,\n });\n formatters.set(key, existing);\n }\n return existing;\n}\n\n/**\n * A fixed-precision number, grouped by the locale's separator rather than\n * SI's thin space, since `<Unit>` already puts a thin space before the symbol.\n */\nfunction fixed(value: number, decimals: number, kind?: string): string {\n return numberFormat(\n decimals,\n kind !== undefined && COUNTED_LIKE_MONEY.has(kind),\n ).format(value);\n}\n\n/**\n * Format a value for display, given the unit the contract declared for it.\n *\n * Returns the parts separately rather than a joined string, because callers\n * need them apart: a readout renders the number large and the symbol small, and\n * an axis wants the number alone with the symbol in the axis label.\n */\nexport function formatQuantity(\n value: number | null | undefined,\n unit: string | undefined,\n opts: FormatQuantityOptions = {},\n): FormattedQuantity {\n if (value === null || value === undefined || !Number.isFinite(value)) {\n return { value: NULL_DISPLAY, symbol: \"\", rung: unit ?? \"\" };\n }\n\n // The presentation unit applies first so ladder, precision and notation describe the unit shown; a cross-kind request is refused.\n if (opts.as !== undefined && opts.as !== unit && unit !== undefined) {\n const conversion = CONVERSION_BY_PAIR[`${unit}→${opts.as}`];\n if (conversion && kindOfUnit(opts.as) === kindOfUnit(unit)) {\n const { as: _as, ...rest } = opts;\n return formatQuantity(\n value / conversion.per + conversion.offset,\n opts.as,\n rest,\n );\n }\n }\n\n const kind = kindOfUnit(unit);\n\n /*\n * A pin is refused when the kinds differ or either ratio is unknown, rather\n * than inventing a conversion factor. Not gated on the format differing\n * from the unit: `format=\"m\"` on 12,400 m must still defeat the ladder.\n */\n if (opts.format !== undefined && unit !== undefined) {\n const from = ratioOf(unit);\n const to = ratioOf(opts.format);\n if (\n from !== undefined &&\n to !== undefined &&\n kindOfUnit(opts.format) === kind\n ) {\n const { format: _format, ...rest } = opts;\n return formatQuantity((value * from) / to, opts.format, {\n ...rest,\n scale: \"never\",\n });\n }\n }\n\n // A ratio is 0-1 and shown as a percentage; a percent token is already 0-100 and must not be multiplied again.\n if (kind === \"ratio\") {\n const decimals = opts.decimals ?? DECIMALS.ratio ?? 0;\n return { value: fixed(value * 100, decimals), symbol: \"%\", rung: \"%\" };\n }\n\n // An undeclared unit renders bare rather than guessed at, as does \"1\" (explicitly dimensionless).\n if (unit === undefined || unit === \"1\" || kind === undefined) {\n const decimals = opts.decimals ?? (kind ? DECIMALS[kind] : undefined);\n return {\n value: decimals === undefined ? String(value) : fixed(value, decimals),\n symbol:\n unit === undefined || unit === \"1\" ? \"\" : displaySymbol(unit, kind),\n rung: unit ?? \"\",\n };\n }\n\n // `\"never\"` opts out of the composite and scientific presentations as well as the ladder; the result is still grouped, so never parse it.\n if (opts.scale !== \"never\") {\n if (opts.scale === \"scientific\" || SCIENTIFIC.has(kind)) {\n return {\n value: toScientific(\n value,\n opts.decimals === undefined\n ? SCIENTIFIC_SIGNIFICANT\n : opts.decimals + 1,\n ),\n symbol: displaySymbol(unit, kind),\n rung: unit,\n };\n }\n\n /*\n * Durations interleave their parts with the number (\"2h 15m\"), so the\n * symbol is empty. The formatters take SECONDS, and `ratioOf` sizes `d`,\n * `h` and `min` by the calendar the game reported.\n */\n if (kind === \"time\") {\n return {\n value: formatDuration(value * (ratioOf(unit) ?? 1)),\n symbol: \"\",\n rung: \"s\",\n };\n }\n\n if (kind === \"irlTime\") {\n return {\n value: formatIrlDuration(value * (ratioOf(unit) ?? 1)),\n symbol: \"\",\n rung: \"irl:s\",\n };\n }\n\n // A universal time is an INSTANT: a date on the game's calendar, never a duration.\n if (kind === \"universalTime\") {\n return { value: formatKspDate(value), symbol: \"\", rung: \"ut\" };\n }\n }\n\n const ladder = opts.scale === \"never\" ? undefined : ladderForUnit(unit);\n const decimals = opts.decimals ?? DECIMALS[kind] ?? 2;\n\n if (\n !ladder &&\n opts.scale === \"compact\" &&\n COUNTED_LIKE_MONEY.has(kind) &&\n Math.abs(value) >= COMPACT_FROM\n ) {\n return {\n value: compact(value),\n symbol: displaySymbol(unit, kind),\n rung: unit,\n };\n }\n\n if (!ladder) {\n return {\n value: fixed(value, decimals, kind),\n symbol: displaySymbol(unit, kind),\n rung: unit,\n };\n }\n\n const base = toBase(value, ladder, unit);\n\n const magnitude = Math.abs(base);\n let chosen = ladder[0];\n for (const rung of ladder) {\n if (magnitude >= rung.from) chosen = rung;\n }\n\n // Only ever holds a HIGHER rung, so a value climbing past a boundary scales up promptly.\n if (opts.heldSymbol && opts.heldSymbol !== chosen.symbol) {\n const held = ladder.find((r) => r.symbol === opts.heldSymbol);\n if (\n held &&\n held.from > chosen.from &&\n magnitude >= held.from * (1 - HYSTERESIS)\n ) {\n chosen = held;\n }\n }\n\n const scaled = base / chosen.per;\n\n // A nonzero reading too small for the lowest rung's decimals goes scientific rather than rendering as zero.\n if (\n scaled !== 0 &&\n chosen === ladder[0] &&\n Math.abs(scaled) * 10 ** decimals < 0.5\n ) {\n return {\n value: toScientific(\n scaled,\n opts.decimals === undefined\n ? SCIENTIFIC_SIGNIFICANT\n : opts.decimals + 1,\n ),\n symbol: chosen.symbol,\n rung: chosen.symbol,\n };\n }\n\n return {\n value: fixed(scaled, decimals),\n symbol: chosen.symbol,\n rung: chosen.symbol,\n };\n}\n\n/**\n * A scale: one rung, settled once, and every mark printed against it. Useful\n * for giving the operator marks that read against one unit. Used by\n * {@link Tape}.\n *\n * For a moving-scale instrument (an altimeter strip, a chart axis): the marks\n * carry no symbol, the symbol is shown once at the head, and every mark sits\n * on the rung settled from the value that defines the scale, so a strip never\n * reads \"500 m\" three marks below \"1.0 km\".\n *\n * Not a general string formatter ({@link writeQuantity}, {@link Unit}), and not\n * for aligning a group of readouts with no known bound ({@link UnitSharedFormat}).\n *\n * @category Unit\n */\nexport interface QuantityScale {\n /** The unit every mark is printed in. */\n readonly rung: string;\n /**\n * The symbol for that rung, to show once beside the scale. Empty for a kind\n * that displays none, in which case the scale shows no header at all.\n */\n readonly symbol: string;\n /** One mark, as the bare number: {@link symbol} carries the unit for the whole scale. */\n mark(magnitude: number | null | undefined): string;\n}\n\n/**\n * Build a {@link QuantityScale} whose unit is the one `reference` is written\n * in, chosen from the kind's ladder of units (`m`, `km`, `Mm`) by its size, so\n * every mark reads against that one unit. Useful for giving the operator marks\n * that read against one unit. Used by\n * {@link Tape}.\n *\n * `reference` is the value that defines the scale rather than a value on it:\n * the top of an altimeter strip, an axis maximum. `opts.format` pins the rung\n * outright.\n *\n * @category Unit\n */\nexport function quantityScale(\n reference: { magnitude: number; unit: string } | null | undefined,\n opts: FormatQuantityOptions = {},\n): QuantityScale {\n const head = formatWhole(reference, opts);\n const unit = reference?.unit;\n return {\n rung: head.rung,\n symbol: head.symbol,\n mark: (magnitude) =>\n formatQuantity(magnitude, unit, { ...opts, format: head.rung }).value,\n };\n}\n\n/**\n * `value`, in the base unit of the ladder it climbs. KSP sends tonnes and kN,\n * so a field can arrive partway up its own ladder and must be normalised\n * before any magnitude comparison.\n */\nfunction toBase(\n value: number,\n ladder: readonly Rung[] | undefined,\n unit: string | undefined,\n): number {\n const declared = ladder?.find((r) => r.symbol === unit);\n return declared ? value * declared.per : value;\n}\n\n/** Where one reading sits on the ladder it climbs. */\nexport interface LadderPosition {\n /** How big it is in the ladder's base unit, absolute: the only figure comparable across rungs. */\n readonly base: number;\n /** The rung this reading alone would climb to, which is what a group votes with. */\n readonly rung: string;\n}\n\n/**\n * Where a reading sits on its ladder, for a caller settling one rung across\n * several readings: how they compare, and what each would choose alone.\n */\nexport function ladderPosition(\n magnitude: number,\n unit: string | undefined,\n): LadderPosition {\n const ladder = ladderForUnit(unit);\n return {\n base: Math.abs(toBase(magnitude, ladder, unit)),\n rung: formatQuantity(magnitude, unit).rung,\n };\n}\n\n/**\n * The set of rungs a unit may climb within, as a key: two readings can settle\n * on one rung exactly when they share this.\n *\n * Undefined for a unit that never climbs, deliberately: a duration, a mission\n * date and a scientific value report a `rung` nothing may be pinned to.\n *\n * Keyed by the ladder a unit declares, never by its kind, since bits and bytes\n * are both `data` and must never share rungs.\n */\nexport function unitScaleKey(unit: string | undefined): string | undefined {\n if (unit === undefined) return undefined;\n const kind = kindOfUnit(unit);\n if (kind === undefined || SCIENTIFIC.has(kind)) return undefined;\n if (ladderForUnit(unit) === undefined) return undefined;\n const name = ladderNameOf(unit);\n return name === undefined ? undefined : ladderGroupKey(name);\n}\n\n/** The key every unit on one ladder reports under. */\nfunction ladderGroupKey(ladder: string): string {\n return `ladder:${ladder}`;\n}\n\n/**\n * The group a reading settles its whole format with, as a key.\n *\n * Wider than {@link unitScaleKey}: a rung can only be settled among readings\n * that share a ladder, but a digit count can be settled among any readings\n * written alike. A unit on a ladder groups by the ladder (even one with no\n * rungs registered yet), and a unit on none groups by itself, never by kind.\n */\nexport function formatGroupKey(unit: string): string;\nexport function formatGroupKey(unit: string | undefined): string | undefined;\nexport function formatGroupKey(unit: string | undefined): string | undefined {\n if (unit === undefined) return undefined;\n const scale = unitScaleKey(unit);\n if (scale !== undefined) return scale;\n const declared = declarationOf(unit);\n return declared?.ladder === undefined\n ? `unit:${unit}`\n : ladderGroupKey(declared.ladder);\n}\n\n/**\n * The group a pin is addressed to, from the token a caller keyed it by.\n *\n * The mirror of {@link formatGroupKey}: a pin names its group outright, so a\n * ladder name is a key here and never there. An unknown token resolves as an\n * unladdered unit rather than throwing.\n */\nexport function pinGroupKey(token: string): string {\n return LADDER_KINDS[token] === undefined\n ? formatGroupKey(token)\n : ladderGroupKey(token);\n}\n\n/** The most digits a separating band may print beyond what the display prints by default. */\nconst MAX_SEPARATING_EXTRA_DECIMALS = 3;\n\n/** The most digits any separating band prints. */\nconst MAX_SEPARATING_DECIMALS = 6;\n\n/** One reading of a group, as the rules below compare them. */\nexport interface FormatMember {\n /** The reading, in the unit it arrived in. */\n readonly reading: number;\n /** The unit it arrived in, which need not be the one it is written at. */\n readonly unit: string;\n}\n\n/**\n * Where a reading sits on its own ladder in the ladder's base unit, signed for\n * ordering, unlike {@link ladderPosition}.\n */\nfunction baseMeasure(reading: number, unit: string): number {\n return toBase(reading, ladderForUnit(unit), unit);\n}\n\n/**\n * The digit count at which the readings of a group stop printing the same\n * thing as each other, or undefined to leave the kind's own default alone.\n *\n * A band of 6 700 km to 6 710 km lands on the megametre rung, where the\n * default prints both ends as `6.7 Mm`; this widens the digits until they\n * differ.\n *\n * - Only adjacent readings (sorted by base measure) are compared, since\n * rounding never reorders\n * - Equal readings are left alone\n * - It only ever widens: a coarser count can round two ends apart across a\n * boundary the interval never reaches (`47.471` to `47.529` as `47 - 48`)\n * - It widens by at most three digits past the default: ends closer than that\n * are a width the display cannot honestly show, and whether they round apart\n * would depend on where the noise falls\n */\nexport function separatingDecimals(\n members: readonly FormatMember[],\n opts: { format?: string; as?: string } = {},\n): number | undefined {\n if (members.length < 2) {\n return undefined;\n }\n const ordered = [...members].sort(\n (a, b) => baseMeasure(a.reading, a.unit) - baseMeasure(b.reading, b.unit),\n );\n const show = (member: FormatMember, decimals?: number) =>\n formatQuantity(\n member.reading,\n member.unit,\n decimals === undefined ? opts : { ...opts, decimals },\n );\n const separatesAt = (decimals?: number): boolean =>\n ordered.every((member, index) => {\n if (index === 0) return true;\n const previous = ordered[index - 1];\n if (\n baseMeasure(previous.reading, previous.unit) ===\n baseMeasure(member.reading, member.unit)\n ) {\n return true;\n }\n const a = show(previous, decimals);\n const b = show(member, decimals);\n return a.value !== b.value || a.rung !== b.rung;\n });\n if (separatesAt()) {\n return undefined;\n }\n\n /*\n * How many decimals the default prints, found by reproducing its string,\n * since counting digits cannot tell a decimal point from a grouping mark\n * under an arbitrary locale. Zero when nothing reproduces it.\n */\n const lowest = ordered[0];\n const printedByDefault = show(lowest).value;\n let from = 0;\n for (let decimals = 0; decimals <= MAX_SEPARATING_DECIMALS; decimals++) {\n if (show(lowest, decimals).value === printedByDefault) {\n from = decimals;\n break;\n }\n }\n const widest = Math.min(\n MAX_SEPARATING_DECIMALS,\n from + MAX_SEPARATING_EXTRA_DECIMALS,\n );\n for (let decimals = from; decimals <= widest; decimals++) {\n if (separatesAt(decimals)) {\n return decimals;\n }\n }\n // Readings that need more digits than the cap are noise-wide; they get the kind's default and read as one figure, as genuinely equal readings do.\n return undefined;\n}\n\n/**\n * Whether a group reads as one figure: every member comes out as the same text\n * at the format the group has settled on.\n *\n * A band asks this before drawing two ends, so it never prints\n * `65.3 km - 65.3 km`. It compares the rendered text rather than magnitudes,\n * so there is no tolerance to tune. Ask with the settled options, so the\n * figures compared are the ones that will be drawn.\n */\nexport function readsAsOneFigure(\n members: readonly (FormatMember | { magnitude: number; unit: string })[],\n opts: { format?: string; as?: string; decimals?: number } = {},\n): boolean {\n if (members.length < 2) {\n return false;\n }\n const shown = members.map((member) =>\n \"reading\" in member\n ? formatQuantity(member.reading, member.unit, opts)\n : formatWhole(member, opts),\n );\n const first = shown[0];\n return shown.every(\n (other) => other.value === first.value && other.rung === first.rung,\n );\n}\n\n// Last, so every table the registrations write to exists before the replay of the ones an Uplink made before this module loaded.\nonUnitRegistered(applyRegisteredUnit);\n","// This code was generated by scripts/gen-unit-kinds.mjs.\n// Changes to this file may cause incorrect behavior and will be lost if\n// the code is regenerated.\n//\n// A unit's KIND is a model fact, owned by mod/sitrep-sdk's UNIT_DEFINITIONS;\n// ui-kit reads it from here rather than keeping a copy of its own.\n//\n// Generated rather than imported so that packages/ui-kit keeps its zero\n// runtime dependencies. A token the contract declares but the model has no\n// unit for is a non-quantity, and its kind is the token itself.\n//\n// The ratio converts to the kind's BASE unit, which is what lets the format\n// prop re-express a value in any unit of the same kind without ui-kit\n// keeping conversion factors of its own.\n\n// The RUNTIME copy of what the SDK's UnitDeclarations states for first-party\n// units. The types read the declarations, never this table, so an Uplink's\n// declared unit is checked exactly as one of these is; unit-kinds.test-d.ts\n// holds the two to one another. `as const` keeps that comparison exact.\nexport const GENERATED_UNIT_KINDS = {\n \"%\": { kind: \"percent\", ratio: 0.01 },\n \"1\": { kind: \"dimensionless\", ratio: 1 },\n \"Eg\": { kind: \"mass\", ratio: 1000000000000000, ladder: \"mass\" },\n \"Gm\": { kind: \"length\", ratio: 1000000000, ladder: \"length\" },\n \"J\": { kind: \"energy\", ratio: 1 },\n \"J/s\": { kind: \"power\", ratio: 1, ladder: \"power\" },\n \"K\": { kind: \"temperature\", ratio: 1 },\n \"MN\": { kind: \"force\", ratio: 1000000, ladder: \"force\" },\n \"Mit\": { kind: \"scienceData\", ratio: 1 },\n \"Mm\": { kind: \"length\", ratio: 1000000, ladder: \"length\" },\n \"N\": { kind: \"force\", ratio: 1, ladder: \"force\" },\n \"N·m\": { kind: \"torque\", ratio: 1 },\n \"Pa\": { kind: \"pressure\", ratio: 1, ladder: \"pressure\" },\n \"Pg\": { kind: \"mass\", ratio: 1000000000000, ladder: \"mass\" },\n \"Tg\": { kind: \"mass\", ratio: 1000000000, ladder: \"mass\" },\n \"Tm\": { kind: \"length\", ratio: 1000000000000, ladder: \"length\" },\n \"W\": { kind: \"power\", ratio: 1, ladder: \"power\" },\n \"W/m²\": { kind: \"irradiance\", ratio: 1 },\n \"Yg\": { kind: \"mass\", ratio: 1e+21, ladder: \"mass\" },\n \"Zg\": { kind: \"mass\", ratio: 1000000000000000000, ladder: \"mass\" },\n \"bit\": { kind: \"data\", ratio: 1, ladder: \"data\" },\n \"bit/s\": { kind: \"dataRate\", ratio: 1, ladder: \"dataRate\" },\n \"count\": { kind: \"count\", ratio: 1 },\n \"d\": { kind: \"time\", ratio: 21600 },\n \"dB\": { kind: \"level\", ratio: 1 },\n \"enum\": { kind: \"enum\", ratio: 1 },\n \"f/day\": { kind: \"fundsRate\", ratio: 0.000046296296296296294 },\n \"flag\": { kind: \"flag\", ratio: 1 },\n \"funds\": { kind: \"funds\", ratio: 1 },\n \"g\": { kind: \"acceleration\", ratio: 9.80665 },\n \"g/m³\": { kind: \"density\", ratio: 0.001, ladder: \"density\" },\n \"h\": { kind: \"time\", ratio: 3600 },\n \"id\": { kind: \"id\", ratio: 1 },\n \"irl:d\": { kind: \"irlTime\", ratio: 86400 },\n \"irl:h\": { kind: \"irlTime\", ratio: 3600 },\n \"irl:min\": { kind: \"irlTime\", ratio: 60 },\n \"irl:s\": { kind: \"irlTime\", ratio: 1 },\n \"isp\": { kind: \"specificImpulse\", ratio: 1 },\n \"kN\": { kind: \"force\", ratio: 1000, ladder: \"force\" },\n \"kPa\": { kind: \"pressure\", ratio: 1000, ladder: \"pressure\" },\n \"kW\": { kind: \"power\", ratio: 1000, ladder: \"power\" },\n \"kg\": { kind: \"mass\", ratio: 1, ladder: \"mass\" },\n \"kg/m³\": { kind: \"density\", ratio: 1, ladder: \"density\" },\n \"kg/s\": { kind: \"massFlow\", ratio: 1 },\n \"km\": { kind: \"length\", ratio: 1000, ladder: \"length\" },\n \"km/h\": { kind: \"speed\", ratio: 0.2777777777777778 },\n \"km/s\": { kind: \"speed\", ratio: 1000 },\n \"kt\": { kind: \"mass\", ratio: 1000000, ladder: \"mass\" },\n \"m\": { kind: \"length\", ratio: 1, ladder: \"length\" },\n \"m/s\": { kind: \"speed\", ratio: 1 },\n \"m/s²\": { kind: \"acceleration\", ratio: 1 },\n \"mPa\": { kind: \"pressure\", ratio: 0.001, ladder: \"pressure\" },\n \"min\": { kind: \"time\", ratio: 60 },\n \"m²\": { kind: \"area\", ratio: 1 },\n \"m³\": { kind: \"volume\", ratio: 1 },\n \"m³/s²\": { kind: \"gravParameter\", ratio: 1 },\n \"n/a\": { kind: \"n/a\", ratio: 1 },\n \"rad\": { kind: \"planeAngle\", ratio: 1 },\n \"rad/h\": { kind: \"doseRate\", ratio: 0.0002777777777777778, ladder: \"doseRate\" },\n \"rad/s\": { kind: \"doseRate\", ratio: 1, ladder: \"doseRate\" },\n \"rad·s⁻¹\": { kind: \"angularSpeed\", ratio: 1 },\n \"ratio\": { kind: \"ratio\", ratio: 1 },\n \"rep\": { kind: \"reputation\", ratio: 1 },\n \"rep/day\": { kind: \"reputationRate\", ratio: 0.000046296296296296294 },\n \"rpm\": { kind: \"angularSpeed\", ratio: 0.10471975511965977 },\n \"s\": { kind: \"time\", ratio: 1 },\n \"science\": { kind: \"science\", ratio: 1 },\n \"science/day\": { kind: \"scienceRate\", ratio: 0.000046296296296296294 },\n \"t\": { kind: \"mass\", ratio: 1000, ladder: \"mass\" },\n \"text\": { kind: \"text\", ratio: 1 },\n \"units\": { kind: \"resourceUnits\", ratio: 1 },\n \"units/s\": { kind: \"resourceFlow\", ratio: 1 },\n \"ut\": { kind: \"universalTime\", ratio: 1 },\n \"y\": { kind: \"time\", ratio: 9201600 },\n \"°\": { kind: \"planeAngle\", ratio: 0.017453292519943295 },\n} as const;\n","import { kspCalendar } from \"./kspTime\";\nimport { NULL_DISPLAY } from \"./NullValue\";\n\nconst pad = (n: number) => String(n).padStart(2, \"0\");\n\n/**\n * A game universal time (UT, seconds) as a calendar date, in whichever of the\n * two calendars the running game has. Useful for showing the operator when a\n * vessel event happened or will happen, in the game's own dating. Used by\n * {@link MissionDate}.\n *\n * - No epoch (stock): `Y<year> D<day> HH:MM:SS`, 1-based, so UT 0 is\n * `Y1 D1 00:00:00`, as the game's own interface prints it\n * - An epoch: `14 Mar 1957 03:22:37`, the real instant that many seconds after\n * the anchor, which the mod reports only for a game with a real calendar.\n * The Gregorian calendar then governs, as the game's own formatter does\n *\n * The lengths and the anchor come from the calendar the game reported. A\n * negative UT is clamped to the epoch; a non-finite one, or one too large for\n * any real date, renders as `NULL_DISPLAY`.\n */\nexport function formatKspDate(ut: number): string {\n if (!Number.isFinite(ut)) return NULL_DISPLAY;\n\n // Read per call: the calendar arrives from the game after this module is imported.\n const {\n day: DAY,\n year: YEAR,\n hour: HOUR,\n minute: MINUTE,\n epochMs,\n } = kspCalendar();\n\n const clamped = Math.max(0, ut);\n\n if (epochMs !== undefined) {\n return formatRealDate(epochMs + clamped * 1000);\n }\n\n const year = Math.floor(clamped / YEAR) + 1;\n const yearRemainder = clamped % YEAR;\n\n const day = Math.floor(yearRemainder / DAY) + 1;\n const dayRemainder = yearRemainder % DAY;\n\n const hours = Math.floor(dayRemainder / HOUR);\n const minutes = Math.floor((dayRemainder % HOUR) / MINUTE);\n const seconds = Math.floor(dayRemainder % MINUTE);\n\n return `Y${year} D${day} ${pad(hours)}:${pad(minutes)}:${pad(seconds)}`;\n}\n\n/**\n * Month names in English rather than from `toLocaleDateString`, so dates do not\n * change shape by machine.\n */\nconst MONTHS = [\n \"Jan\",\n \"Feb\",\n \"Mar\",\n \"Apr\",\n \"May\",\n \"Jun\",\n \"Jul\",\n \"Aug\",\n \"Sep\",\n \"Oct\",\n \"Nov\",\n \"Dec\",\n];\n\n/**\n * A real instant as `14 Mar 1957 03:22:37`, read in UTC.\n *\n * UTC, not the viewer's zone, so two stations on one mission never read a day\n * apart.\n */\nfunction formatRealDate(ms: number): string {\n const at = new Date(ms);\n if (Number.isNaN(at.getTime())) return NULL_DISPLAY;\n\n const day = at.getUTCDate();\n const month = MONTHS[at.getUTCMonth()];\n const year = at.getUTCFullYear();\n const time = `${pad(at.getUTCHours())}:${pad(at.getUTCMinutes())}:${pad(\n at.getUTCSeconds(),\n )}`;\n\n return `${day} ${month} ${year} ${time}`;\n}\n","import { kspCalendar } from \"./kspTime\";\nimport { NULL_DISPLAY } from \"./NullValue\";\n\nconst SECOND = 1;\nconst MINUTE = 60 * SECOND;\nconst HOUR = 60 * MINUTE;\n\ninterface Tier {\n symbol: string;\n size: number;\n}\n\n/**\n * The game-time ladder, built per call rather than at module load, since the\n * calendar is whatever the running game reports and arrives after import.\n */\nfunction tiers(): readonly Tier[] {\n const calendar = kspCalendar();\n return [\n { symbol: \"y\", size: calendar.year },\n { symbol: \"d\", size: calendar.day },\n { symbol: \"h\", size: calendar.hour },\n // \"min\", not \"m\", which is the metre and reads as \"4M\" under an uppercasing badge.\n { symbol: \"min\", size: calendar.minute },\n { symbol: \"s\", size: SECOND },\n ];\n}\n\n/**\n * The unit symbols of the game-time duration scale (`y`, `d`, `h`, `min`, `s`),\n * the symbols of the `\"time\"` kind. Useful for checking that no other unit\n * symbol collides with one the operator reads in a duration. Used by the\n * symbol collision check inside the kit.\n */\nexport function durationTierSymbols(): readonly string[] {\n return tiers().map((tier) => tier.symbol);\n}\n\n/**\n * The same ladder on a real day, for durations measured by the clock on the\n * desk (how long ago a reading was seen, how long a recorder ran) rather than\n * by the game. Fixed, since wall-clock time is 24h regardless. No year rung.\n */\nconst IRL_TIERS: readonly Tier[] = [\n { symbol: \"d\", size: 24 * HOUR },\n { symbol: \"h\", size: HOUR },\n { symbol: \"min\", size: MINUTE },\n { symbol: \"s\", size: SECOND },\n];\n\n/**\n * The unit symbols of the real-time duration scale (`d`, `h`, `min`, `s`), the\n * symbols of the `\"irlTime\"` kind. Useful for checking that no other unit\n * symbol collides with one the operator reads in a real-time duration. The\n * game-time counterpart is `durationTierSymbols`.\n */\nexport function irlDurationTierSymbols(): readonly string[] {\n return IRL_TIERS.map((tier) => tier.symbol);\n}\n\nexport interface FormatDurationOptions {\n /** Below 1s, render milliseconds (`820 ms`, `0 ms`) instead of `0s`. Default false. */\n ms?: boolean;\n /**\n * Prefix a launch-clock sign: `T+` for a negative (already-elapsed/past)\n * value, `T−` for a positive-or-zero (future) value. Off by default.\n */\n sign?: boolean;\n}\n\n/**\n * A duration in game seconds as the largest two game-time units, space-separated\n * and suffixed (`45s`, `1min 20s`, `2h 15min`, `3d 4h`, `1y 200d`). The smaller\n * unit is shown only when it is non-zero (exactly 2h renders as `2h`). Useful\n * for showing the operator how long a vessel event takes or how long until it\n * happens, in the length of day and year the running game reports. Used by\n * {@link Countdown}.\n *\n * The smaller unit is truncated, not rounded, so a countdown never shows\n * progress that has not happened: `89.9` becomes `1min 29s`. Non-finite values\n * render as `NULL_DISPLAY`.\n */\nexport function formatDuration(\n seconds: number,\n opts: FormatDurationOptions = {},\n): string {\n return format(seconds, tiers(), opts);\n}\n\n/**\n * A duration in real seconds as the largest two real-time units, in the same\n * shape as `formatDuration` but with 24-hour days and no years. Useful\n * for showing the operator how long ago a reading was seen or how long a\n * recording ran, measured by the clock at the command centre rather than by the\n * game. Passing game seconds here, or real seconds to `formatDuration`,\n * misstates the duration by the ratio of the two day lengths.\n */\nexport function formatIrlDuration(\n seconds: number,\n opts: FormatDurationOptions = {},\n): string {\n return format(seconds, IRL_TIERS, opts);\n}\n\nfunction format(\n seconds: number,\n tiers: readonly Tier[],\n opts: FormatDurationOptions,\n): string {\n if (!Number.isFinite(seconds)) return NULL_DISPLAY;\n\n const { ms = false, sign = false } = opts;\n const signPrefix = sign ? (seconds < 0 ? \"T+\" : \"T−\") : \"\";\n const abs = Math.abs(seconds);\n\n if (abs < 1) {\n if (ms) {\n return `${signPrefix}${Math.round(abs * 1000)} ms`;\n }\n return `${signPrefix}0s`;\n }\n\n // Never a unit finer than seconds outside the `ms` path.\n const totalSeconds = Math.floor(abs);\n\n // Below the finest tier, the smallest rung is still the answer.\n const found = tiers.findIndex((tier) => totalSeconds >= tier.size);\n const majorIndex = found === -1 ? tiers.length - 1 : found;\n const major = tiers[majorIndex];\n const majorValue = Math.floor(totalSeconds / major.size);\n\n if (majorIndex === tiers.length - 1) {\n // Already at the finest tier (seconds): nothing smaller to pair with.\n return `${signPrefix}${majorValue}${major.symbol}`;\n }\n\n const minor = tiers[majorIndex + 1];\n const remainder = totalSeconds - majorValue * major.size;\n const minorValue = Math.floor(remainder / minor.size);\n\n if (minorValue === 0) {\n return `${signPrefix}${majorValue}${major.symbol}`;\n }\n return `${signPrefix}${majorValue}${major.symbol} ${minorValue}${minor.symbol}`;\n}\n\n/**\n * The time remaining until an event, as `formatDuration` text clamped at\n * zero: a negative value reads `0s`, and there is no sign prefix. Useful for\n * showing the operator how long until a command arrives or an event happens.\n */\nexport function formatCountdown(seconds: number): string {\n return formatDuration(Math.max(0, seconds));\n}\n","import type { SendStatus, Value } from \"@ksp-gonogo/sitrep-sdk\";\nimport { writeQuantity } from \"../units\";\n\nconst quantity = (seconds: Value<\"s\">) => writeQuantity(seconds);\n\n/** Every word the status can say, keyed by state, so a wording change is an edit here and nowhere else. */\nconst WORDS = {\n contact: {\n \"in-contact\": () => \"In contact\",\n \"loss-in\": (seconds: Value<\"s\">) => `LOS in ${quantity(seconds)}`,\n \"back-in\": (seconds: Value<\"s\">) =>\n `No contact, back in ${quantity(seconds)}`,\n none: (reason?: \"unpowered\") =>\n reason === \"unpowered\"\n ? \"No contact, no electric charge aboard\"\n : \"No contact\",\n },\n delay: {\n held: (seconds: Value<\"s\">) => `${quantity(seconds)} signal delay`,\n absent: () => \"no signal path\",\n },\n arrival: {\n expected: \"Expected to arrive\",\n \"likely-lost\": \"Likely lost\",\n },\n sends: {\n now: () => \"Sends now\",\n held: (until: Value<\"ut\">, arrives: Value<\"ut\"> | undefined) =>\n arrives === undefined\n ? `Held until ${writeQuantity(until)}`\n : `Held until ${writeQuantity(until)}, arrives ${writeQuantity(arrives)}`,\n },\n} as const;\n\n/**\n * A send status as the two lines a command control shows: the contact state\n * and the signal delay, then what the send does (sends now, held until a\n * stated time and arriving at another, or whether a message is expected to\n * arrive). Written for a tooltip or an accessible name. Used by\n * {@link Button} for its tooltip.\n *\n * @category CommandButton\n */\nexport function describeSendStatus(status: SendStatus): string {\n const { contact } = status;\n const first =\n contact.kind === \"loss-in\" || contact.kind === \"back-in\"\n ? WORDS.contact[contact.kind](contact.seconds)\n : contact.kind === \"none\"\n ? WORDS.contact.none(contact.reason)\n : WORDS.contact[contact.kind]();\n const delay =\n status.signalDelay === undefined\n ? WORDS.delay.absent()\n : WORDS.delay.held(status.signalDelay);\n const second =\n status.sends === \"now\" && status.arrival === \"expected\"\n ? WORDS.sends.now()\n : status.sends === \"held\" && status.heldUntilUt !== undefined\n ? WORDS.sends.held(status.heldUntilUt, status.arrivesUt)\n : WORDS.arrival[status.arrival];\n return `${first} · ${delay}\\n${second}`;\n}\n","import type { SendStatus } from \"@ksp-gonogo/sitrep-sdk\";\n\n/**\n * What a control predicts for an order sent now, as the outline its edge\n * wears: `held` for an order that waits for a predicted contact and will\n * arrive, `at-risk` for one expected to be lost or with no route. An order that\n * goes at once has no prediction to show. Useful for showing the operator the\n * predicted result at a glance, without a change in the control's size. Used by\n * {@link Button}, and by {@link Button} through its `predictedOutcome`\n * prop.\n *\n * @category CommandButton\n */\nexport type PredictedOutcome = \"held\" | \"at-risk\";\n\n/**\n * The predicted outcome of a send status: `held` while the order waits and is\n * expected to arrive, `at-risk` when it is expected to be lost or has no route,\n * and `undefined` for an order that goes at once or when nothing is known.\n * Used by {@link Button}.\n *\n * @category CommandButton\n */\nexport function predictedOutcomeOf(\n status: SendStatus | undefined,\n): PredictedOutcome | undefined {\n if (status === undefined) return undefined;\n if (status.arrival === \"likely-lost\") return \"at-risk\";\n return status.sends === \"held\" ? \"held\" : undefined;\n}\n","import {\n CommandErrorCode,\n commandRefusalSubject,\n describeErrorCode,\n type LimitBreach,\n} from \"@ksp-gonogo/sitrep-sdk\";\nimport { writeQuantity } from \"../units\";\nimport type { RailTags } from \"./railTags\";\n\n/**\n * One refused dispatch, as much of it as the sentence needs. The entries in\n * `useCommand`'s `refusals` satisfy it, and so does one built by hand. Taken by\n * {@link commandRefusalSentence} and {@link commandGateSentence}.\n * Useful for writing the sentence that tells the operator a command was\n * refused.\n *\n * @category CommandDelay\n */\nexport interface CommandRefusalLike {\n /** Why the command was refused, as one of the root codes every Uplink shares, such as\n * `CommandErrorCode.InsufficientFunds`, whose string value (the one on the\n * wire) is `\"insufficientFunds\"`. */\n errorCode: CommandErrorCode;\n /**\n * The refinement's id, when the refusal was more specific than its root\n * `errorCode`. A refinement is a narrower reason an Uplink declares under a\n * root code, such as a particular kind of `wrongState`; a client that does\n * not know it still reads the root. An Uplink declares one in C# with\n * `Refine` on the root `RefusalCode`, as `owner.name`.\n */\n reason?: string;\n /** The command id that was dispatched, e.g. `career.facility.upgrade`. */\n command?: string;\n /** The args it was dispatched with. */\n args?: unknown;\n /** The dispatch's own operator-facing description, when it carried one. */\n label?: string;\n /** The limit and the actual behind the reason, when the mod sent them. */\n breach?: LimitBreach;\n /**\n * The refusal in the game's own words, when the game gave any: a\n * strategy's own reason, a pre-flight check's warning title. Used in place\n * of the kit's own clause, since it arrives localised and follows the game.\n */\n detail?: string;\n}\n\n/**\n * A refusal a surface can render: the text's inputs plus the dispatch's own\n * `requestId`, which keys the box and is what `dismiss` takes. Used by the panel\n * delay rail and {@link CommandList}.\n *\n * @category CommandDelay\n */\nexport interface CommandRefusalEntry extends CommandRefusalLike {\n /** The dispatch's `requestId`, which keys the box and is what `dismiss` takes. */\n id: string;\n}\n\n/**\n * One refused dispatch as the rail renders it: the refusal itself, plus the two\n * things only the registering handle knows, its stable id and the command's\n * rail axes. Taken by {@link CommandList}.\n * Useful for telling the operator, on the panel's delay rail, which commands\n * were refused and why.\n *\n * @category CommandDelay\n */\nexport interface RailRefusal extends CommandRefusalEntry {\n /**\n * The command's three axes. Only the mark is read: a discrete command gets\n * its in-flight glyph tile, a continuous one its text label.\n */\n tags: RailTags;\n}\n\n/** A number as it is written beside its unit (`253,000f`, `16`), through `units.ts` so funds read the same everywhere. */\nfunction quantity(value: number, unit: string): string {\n return writeQuantity({ magnitude: value, unit });\n}\n\n/** The clause after the colon, or `null` when this arm needs numbers it did not get; never an invented \"0 of 0\". */\nfunction comparison(\n errorCode: CommandErrorCode,\n breach: LimitBreach,\n): string | null {\n const { limit, actual, unit } = breach;\n // `== null`: the wire writes an explicit JSON null for a breach with no numbers.\n if (limit == null || actual == null) return null;\n\n switch (errorCode) {\n case CommandErrorCode.LimitReached: {\n // Names the facility, since the operator's next move is at that building.\n const what = readableQuantity(breach.quantity);\n const counts = `${quantity(actual, unit)} of ${quantity(limit, unit)}`;\n return breach.facilityName\n ? `the ${breach.facilityName} holds ${counts} ${what}`\n : `it holds ${counts} ${what}`;\n }\n case CommandErrorCode.AlreadyAtMaximum:\n return `it is already at ${breach.quantity || \"level\"} ${quantity(actual, unit)} of ${quantity(limit, unit)}`;\n case CommandErrorCode.InsufficientFunds:\n // Actual is the price and Limit is the balance; the game's own readouts drop the fraction of funds.\n return `it costs ${quantity(Math.trunc(actual), unit)} and funds are ${quantity(Math.trunc(limit), unit)}`;\n case CommandErrorCode.InsufficientScience:\n return `it costs ${quantity(actual, unit)} and science is ${quantity(limit, unit)}`;\n default:\n return null;\n }\n}\n\n/** `activeCrew` -> `active crew`: a camelCase id inside a sentence reads as a leaked variable. */\nfunction readableQuantity(quantityId: string): string {\n return quantityId.replace(/([a-z0-9])([A-Z])/g, \"$1 $2\").toLowerCase();\n}\n\n/** The sentence a code was declared with, or `null` when nothing this client knows declares it. */\nfunction declaredSentence(id: string | undefined): string | null {\n return (id && describeErrorCode(id)?.sentence) || null;\n}\n\n/**\n * The game's own words as a mid-sentence clause: trimmed, trailing full stop\n * dropped. Case is never folded, which would damage KSP's proper nouns.\n */\nfunction said(detail: string | undefined): string | null {\n const trimmed = detail?.trim().replace(/\\.$/, \"\");\n return trimmed ? trimmed : null;\n}\n\n/**\n * The sentence shown to the operator when the game refuses a command:\n *\n * Hire Valentina Kerman refused: the Astronaut Complex holds 16 of 16 active crew.\n * Upgrade Launch Pad refused: it is already at tier 3 of 3.\n * Upgrade Launch Pad refused: it costs 253,000f and funds are 189,412f.\n *\n * The command and its args name the subject, the refusal code picks the\n * clause (a refinement's own sentence ahead of its root's), and the\n * `LimitBreach` supplies the numbers, written as {@link Unit} writes them.\n * Useful for telling the operator why the game refused a command. Used by\n * {@link Button} and {@link CommandList}, which show it when a command\n * of theirs is refused.\n *\n * Names are user-supplied and unbounded, so render the sentence where it can\n * wrap: truncating it cuts the numbers off the end.\n *\n * @category CommandDelay\n */\nexport function commandRefusalSentence(refusal: CommandRefusalLike): string {\n return sentence(refusal, \"refused\");\n}\n\n/**\n * What the operator reads when the game will refuse a command that has not been\n * pressed yet:\n *\n * Hire Valentina Kerman unavailable: the Astronaut Complex holds 16 of 16 active crew.\n * Recover unavailable: the craft is throttled up.\n *\n * The same clause as {@link commandRefusalSentence}, so a control never says\n * one thing before the press and another after. \"Unavailable\" because nothing\n * has been asked yet: a gate is a condition that holds. Useful for telling the\n * operator, before they press, why a command is unavailable. Used by\n * {@link Button}.\n *\n * @category CommandDelay\n */\nexport function commandGateSentence(gate: CommandRefusalLike): string {\n return sentence(gate, \"unavailable\");\n}\n\n/**\n * The sentence for a command the mod expects the game to refuse, which the\n * operator may still send: \"Upgrade Launch Pad likely to be refused: vessels are\n * on this facility: Kerbal X.\" Used by a command control for its tip.\n */\nexport function commandAdviceSentence(gate: CommandRefusalLike): string {\n return sentence(gate, \"likely to be refused\");\n}\n\nfunction sentence(refusal: CommandRefusalLike, verb: string): string {\n const subject = commandRefusalSubject(refusal);\n const clause =\n (refusal.breach ? comparison(refusal.errorCode, refusal.breach) : null) ??\n // What the game itself said, ahead of anything declared.\n said(refusal.detail) ??\n declaredSentence(refusal.reason) ??\n declaredSentence(refusal.errorCode) ??\n // An id nothing declares is not prose, but it beats a bare \"refused.\" with nothing after it.\n refusal.reason ??\n refusal.errorCode;\n return subject\n ? `${subject} ${verb}: ${clause}.`\n : `${verb.charAt(0).toUpperCase()}${verb.slice(1)}: ${clause}.`;\n}\n","import {\n type CommandErrorCode,\n commandRefusalSubject,\n type LimitBreach,\n} from \"@ksp-gonogo/sitrep-sdk\";\nimport { commandRefusalSentence } from \"./commandRefusalSentence\";\nimport type { RailTags } from \"./railTags\";\n\n/**\n * One dispatch that was called lost and then replied after all, as much of it\n * as the sentence needs. The entries in `useCommand`'s `founds` satisfy it,\n * and so does one built by hand. `outcome` is required: every sentence turns on\n * it. Taken by {@link commandFoundSentence}.\n * Useful for writing the sentence that tells the operator a command thought\n * lost did reply.\n *\n * @category CommandDelay\n */\nexport interface CommandFoundLike {\n /**\n * What the late reply turned out to say: the command executed, the game\n * refused it, or the machinery broke on the far side.\n */\n outcome: \"ran\" | \"refused\" | \"errored\";\n /** The command id that was dispatched, e.g. `vessel.control.setSas`. */\n command?: string;\n /** The args it was dispatched with. */\n args?: unknown;\n /** The dispatch's own operator-facing description, when it carried one. */\n label?: string;\n /** `outcome: \"refused\"` only: the game's typed reason. */\n errorCode?: CommandErrorCode;\n /** `outcome: \"refused\"` only: the refinement's id, when the refusal was more specific than `errorCode`. */\n reason?: string;\n /** `outcome: \"refused\"` only: the limit and the actual behind the reason. */\n breach?: LimitBreach;\n /** `outcome: \"refused\"` only: the refusal in the game's own words. */\n detail?: string;\n /** `outcome: \"errored\"` only: what broke, in the machinery's own words. */\n error?: { code: string; message: string };\n}\n\n/**\n * A found dispatch a surface can render: the text's inputs plus the dispatch's\n * `requestId`, which keys the box and is what `dismiss` takes. Used by the panel\n * delay rail and {@link CommandList}.\n *\n * @category CommandDelay\n */\nexport interface CommandFoundEntry extends CommandFoundLike {\n /** The dispatch's `requestId`, which keys the box and is what `dismiss` takes. */\n id: string;\n}\n\n/**\n * One found dispatch as the rail renders it, plus its command's rail axes.\n * Taken by {@link CommandList}.\n * Useful for telling the operator, on the panel's delay rail, which lost\n * commands replied after all.\n *\n * @category CommandDelay\n */\nexport interface RailFound extends CommandFoundEntry {\n /** The command's rail axes. */\n tags: RailTags;\n}\n\n/**\n * What the operator is told about a command they were told was lost, which then\n * replied: the action, then the outcome, then the reason. The row's own state\n * already says the reply was lost, so the sentence does not repeat it.\n *\n * - `ran`: `Hire Valentina Kerman ran.` If they re-sent it, it ran twice\n * - `refused`: `Hire Valentina Kerman was refused: the Astronaut Complex holds\n * 16 of 16 active crew.` The reason is the refusal composer's own words\n * - `errored`: `Hire Valentina Kerman failed: <reason>.` The machinery broke\n * over there; a retry may work\n *\n * Never \"confirmed\": the operator may already have re-sent it. No imperative:\n * the rail says what happened and lets the operator decide. Useful for telling\n * the operator how a command they were told was lost actually ended. Used by\n * {@link CommandList}, the panel delay rail and {@link Button}.\n *\n * @category CommandDelay\n */\nexport function commandFoundSentence(found: CommandFoundLike): string {\n const subject = commandRefusalSubject(found);\n const what = subject || found.command || \"The command\";\n if (found.outcome === \"refused\") {\n // The refusal composer, not a second table of reasons.\n const reason =\n found.errorCode === undefined\n ? \"\"\n : afterSubject(\n commandRefusalSentence({\n errorCode: found.errorCode,\n reason: found.reason,\n command: found.command,\n args: found.args,\n label: found.label,\n breach: found.breach,\n detail: found.detail,\n }),\n );\n return reason ? `${what} was refused: ${reason}` : `${what} was refused.`;\n }\n if (found.outcome === \"errored\") {\n const said = found.error?.message?.trim().replace(/\\.$/, \"\");\n return said ? `${what} failed: ${said}.` : `${what} failed.`;\n }\n return `${what} ran.`;\n}\n\n/**\n * `Hire Valentina Kerman refused: the Astronaut Complex holds 16 of 16 active\n * crew.` -> `the Astronaut Complex holds 16 of 16 active crew.`, since the found\n * sentence supplies its own subject and verb.\n */\nfunction afterSubject(sentence: string): string {\n const at = sentence.indexOf(\": \");\n return at === -1 ? sentence : sentence.slice(at + 2);\n}\n","import { commandRefusalSubject } from \"@ksp-gonogo/sitrep-sdk\";\nimport type { RailTags } from \"./railTags\";\n\n/**\n * One dispatch that got no reply, as much of it as the sentence needs. The\n * entries in `useCommand`'s `losses` satisfy it. Taken by\n * {@link commandLossSentence}.\n * Useful for writing the sentence that tells the operator a command got no\n * reply.\n *\n * @category CommandDelay\n */\nexport interface CommandLossLike {\n /** The command id that was dispatched, e.g. `vessel.control.setSas`. */\n command?: string;\n /** The args it was dispatched with. */\n args?: unknown;\n /** The dispatch's own operator-facing description, when it carried one. */\n label?: string;\n}\n\n/**\n * A loss a surface can render: the text's inputs plus the dispatch's\n * `requestId`, which keys the box and is what `dismiss` takes. Used by the panel\n * delay rail and {@link CommandList}.\n *\n * @category CommandDelay\n */\nexport interface CommandLossEntry extends CommandLossLike {\n /** The dispatch's `requestId`, which keys the box and is what `dismiss` takes. */\n id: string;\n}\n\n/**\n * One lost dispatch as the rail renders it, plus its command's rail axes. Taken\n * by {@link CommandList}.\n * Useful for telling the operator, on the panel's delay rail, which commands\n * got no reply.\n *\n * @category CommandDelay\n */\nexport interface RailLoss extends CommandLossEntry {\n /** The command's rail axes. */\n tags: RailTags;\n}\n\n/**\n * What the operator is told about a command that went quiet. \"May have run\":\n * a dropped command and a reply lost on the way back look the same to the\n * command centre, so pressing again may do the thing twice. Never \"refused\",\n * which is the game's verdict. Useful for telling the operator a command got no\n * reply and may still have run. Used by {@link CommandList}, the panel delay\n * rail and {@link Button}.\n *\n * @category CommandDelay\n */\nexport function commandLossSentence(loss: CommandLossLike): string {\n const subject = commandRefusalSubject(loss);\n const what = subject || loss.command || \"The command\";\n return `${what}: no reply. May have run.`;\n}\n","import type { CommandDelayHandle } from \"./CommandDelay\";\nimport type { InFlightCommandLike } from \"./toInFlightListItems\";\n\n/**\n * What became of a handle's dispatches, as the control that issued them echoes\n * it. Returned by {@link commandOutcomes}.\n * Useful for showing the operator, beside the control they pressed, what\n * became of its commands.\n *\n * @category CommandButton\n */\nexport interface CommandOutcomes {\n /**\n * This handle's own dispatches that went past their reply with no answer\n * (overdue or lost) and have an in-flight row. They may still have run.\n */\n unconfirmed: InFlightCommandLike[];\n /** True when any dispatch is unconfirmed, including a loss that never had a row. For a control's `data-unconfirmed` tint. */\n hasUnconfirmed: boolean;\n /** True when a dispatch never left this machine, or the mod answered it with a fault. For a control's `data-failed` tint. */\n hasFailure: boolean;\n /**\n * Clear an entry, the same dismiss the widget-top queue uses, so clearing on\n * the control clears it in the queue too.\n */\n dismiss: (id: string) => void;\n}\n\n/**\n * A handle's unanswered and undelivered dispatches plus the shared `dismiss`,\n * so the control that issued the command can echo what became of it while the\n * Panel rail stays the primary surface. An unanswered command may still run,\n * so it is unconfirmed and never counted as a failure. Useful for showing the\n * operator, beside the control they pressed, what became of the command. Used by\n * {@link Button} and the attitude controls of the navball.\n *\n * @category CommandButton\n */\nexport function commandOutcomes(handle: CommandDelayHandle): CommandOutcomes {\n const unconfirmed = handle.inFlight.filter(\n (c) => c.predictedPhase === \"overdue\" || c.predictedPhase === \"lost\",\n );\n return {\n unconfirmed,\n hasUnconfirmed: unconfirmed.length > 0 || (handle.losses?.length ?? 0) > 0,\n hasFailure:\n (handle.undelivered?.length ?? 0) > 0 ||\n (handle.failures?.length ?? 0) > 0,\n dismiss: handle.dismiss ?? (() => {}),\n };\n}\n","import {\n argsOf,\n type BoundCommand,\n type BoundCommandOptions,\n bindCommand,\n CommandErrorCode,\n type CommandStatus,\n classifyCommandRejection,\n runSet,\n type SendStatus,\n type UseCommandResult,\n type ValueCommand,\n} from \"@ksp-gonogo/sitrep-sdk\";\nimport { useWireTimelineEpoch } from \"@ksp-gonogo/sitrep-sdk/spine\";\nimport type { ButtonHTMLAttributes, ReactNode } from \"react\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\n/** How long a confirmed press keeps showing the state it asked for while the reading has not yet moved. */\nconst CONFIRMED_STATE_HOLD_MS = 5000;\n\nimport styled, { css, keyframes } from \"styled-components\";\nimport { Button__Body, type ButtonTone } from \"../Button\";\nimport type { CommandDelayHandle } from \"../CommandDelay/CommandDelay\";\nimport {\n type CommandFoundLike,\n commandFoundSentence,\n} from \"../CommandDelay/commandFoundSentence\";\nimport { commandLossSentence } from \"../CommandDelay/commandLossSentence\";\nimport { commandOutcomes } from \"../CommandDelay/commandOutcomes\";\nimport {\n type CommandRefusalLike,\n commandAdviceSentence,\n commandGateSentence,\n commandRefusalSentence,\n} from \"../CommandDelay/commandRefusalSentence\";\nimport { useRailAnnounces } from \"../CommandDelay/railAnnouncer\";\nimport { FitLabel } from \"../FitLabelButton\";\nimport { LiveRegion } from \"../LiveRegion\";\nimport { ReservedText } from \"../ReservedText\";\nimport type { ReckoningMarking } from \"../readingCurrency\";\nimport { describeSendStatus } from \"../SendStatus/describeSendStatus\";\nimport { predictedOutcomeOf } from \"../SendStatus/predictedOutcome\";\nimport { ToggleButton } from \"../ToggleButton\";\nimport { Tooltip } from \"../Tooltip\";\nimport {\n askedToggleValue,\n type CommandToggle,\n confirmationSentenceOf,\n pressOutstanding,\n shownToggleState,\n type ToggleState,\n toggleConfirmationOf,\n toggleMarking,\n} from \"./toggle\";\n\n/** The dispatch's args as text, for telling whether an armed control is still pointed at what was armed; `null` for args that cannot be written. */\nfunction argsKey(args: unknown): string | null {\n try {\n return JSON.stringify(args) ?? \"\";\n } catch {\n return null;\n }\n}\n\n/**\n * The words a command control shows as its tip while the stream to the mod is\n * down: that nothing can be sent. Useful for telling the operator why a command\n * control is dimmed with a dotted edge, and for a control of your own that follows the same\n * state. Used by {@link Button} and by the Action Group widget's toggle.\n *\n * @category CommandButton\n */\nexport const STREAM_DOWN_TIP = \"Not connected to the mod. Nothing can be sent\";\n\n/**\n * How long, in milliseconds, an armed {@link Button} waits for its\n * confirming press before it returns to rest. Used by {@link Button} and\n * {@link useCommandControl}.\n *\n * @category CommandButton\n */\nexport const ARM_TIMEOUT_MS = 4000;\n\n/**\n * How long, in milliseconds, a refusal stays on a command control before the\n * control returns to rest. Used by {@link Button} and\n * {@link useCommandControl}.\n *\n * @category CommandButton\n */\nexport const REFUSAL_TIMEOUT_MS = 8000;\n\n/**\n * The fewest milliseconds a {@link Button} reads \"SENT\" after a press,\n * so the press is seen to have gone however soon the mod answers it. Used by\n * {@link Button}, {@link useCommandControl} and the toggles of the\n * Navball and Action Group widgets.\n *\n * @category CommandButton\n */\nexport const SENT_FLASH_MS = 500;\nexport type {\n CommandToggle,\n ToggleState,\n} from \"./toggle\";\n\n/**\n * A command bound to arguments, as a control reads it: the handle it dispatches\n * on is the kit's structural handle.\n *\n * @category CommandButton\n */\n// biome-ignore lint/suspicious/noExplicitAny: a command of any reply type\nexport type BoundControlCommand<Args = unknown, Result = any> = BoundCommand<\n Args,\n Result,\n CommandButtonHandle<Result, Args>\n>;\n\n/** The word a command control shows while the mod has not answered the press. */\nexport const SENT_WORD = \"SENT\";\n\n/** The word a command control shows once the game has refused the press. */\nexport const REFUSED_WORD = \"Refused\";\n\n/** The word a command control shows when no reply came to the press. */\nexport const LOST_WORD = \"No reply\";\n\n/** The word a command control shows when a command it lost has since replied. */\nexport const FOUND_WORD = \"Found\";\n\n/**\n * What the mod says about a command before it is pressed: whether the game would\n * refuse it. Useful for darkening a control the operator cannot usefully press\n * and saying why. Declared structurally; `useCommand`'s `gate` satisfies it.\n * Read by {@link Button} through {@link CommandButtonHandle}.\n *\n * @category CommandButton\n */\nexport interface CommandGateLike extends CommandRefusalLike {\n /** The game evaluated this and said no. */\n blocked: boolean;\n /**\n * The mod could not evaluate this command's gates (the checks it runs\n * before a command is pressed) at all, as in a sandbox save, which has no\n * career to check against. The control is drawn as ordinary, not darkened, and carries\n * `data-gate` to say so.\n */\n undetermined?: boolean;\n}\n\n/**\n * What a command reply is known to be before you know which command produced\n * it: the result envelope, carrying the command's own value on `payload`. The\n * default {@link CommandButtonHandle} reply, so a reader cannot treat the\n * envelope as the payload; `payload` stays `unknown` until narrowed. Useful for\n * reading the game's answer to a command the operator sent. Taken by\n * {@link CommandButtonHandle}.\n *\n * @category CommandButton\n */\nexport interface CommandReplyLike {\n /** Whether the command ran. False pairs with the refusal the handle surfaces. */\n success: boolean;\n /** The command's own value, when it has one. `unknown` until the reader knows which command this is. */\n payload?: unknown;\n}\n\n/**\n * The command handle a {@link Button} dispatches on: the delay-rail handle plus a\n * way to send. Useful for connecting a control to a command so it can show the\n * operator what became of a press. Declared structurally; {@link useCommand}'s\n * return value satisfies it. Taken by {@link Button} and\n * {@link useCommandControl}.\n *\n * @category CommandButton\n */\nexport interface CommandButtonHandle<Result = CommandReplyLike, Args = unknown>\n extends CommandDelayHandle {\n // A method rather than a function-valued property, so strictFunctionTypes does not check typed args contravariantly and reject every typed handle.\n /**\n * Sends this command with no kit input drawing it, so nothing on screen shows\n * the operator that it was sent except the panel's delay rail. Useful for a\n * send that no kit input starts, such as a price query, a background sync or\n * typed text in a script terminal. Used by a script terminal and by the\n * maneuver planner when it removes a completed node.\n *\n * A control the operator presses takes the command through its `command` prop\n * instead: pass `with` or `toArgs` to a {@link Button}, a\n * {@link Slider} or another kit input, which then draws sent, refused and the\n * rest. A key or serial binding presses a {@link useCommandControl}.\n *\n * Resolves with the reply once the command has run. Rejects when the game\n * refuses it, and when no reply arrives by the expected time. A refusal or loss\n * from a call whose promise nobody awaits is still recorded in `refusals` or\n * `losses`.\n *\n * `opts.label` is a description of this dispatch to show the operator.\n * `opts.topic` addresses the command to one part or route on the craft, such\n * as one script terminal.\n *\n * `Result` carries the reply's real type to the `onConfirmed` option of\n * `with`; a handle from `useCommand(\"...\")` supplies it from the generated\n * command map.\n */\n dangerouslySendWithoutInput(\n args?: Args,\n opts?: { label?: string; topic?: string },\n ): Promise<Result>;\n /** This command with its arguments set, for an input's `command` prop. See `useCommand`. */\n with(\n args?: Args | (() => Args),\n options?: BoundCommandOptions<Args, Result>,\n ): BoundControlCommand<Args, Result>;\n /** This command with a way to turn an input's value into its arguments. See `useCommand`. */\n toArgs<Value>(\n toArgs: (value: Value) => Args | undefined,\n options?: BoundCommandOptions<Args, Result>,\n ): ValueCommand<Value, Args, Result, CommandButtonHandle<Result, Args>>;\n /**\n * Where the handle's latest dispatch stands, as `useCommand` reports it. The\n * control reads \"SENT\" until the mod answers the press (`accepted`, or the\n * reply for a command with no delay). Absent for a handle that cannot say,\n * which then shows \"SENT\" for {@link SENT_FLASH_MS} only.\n */\n status?: CommandStatus;\n /**\n * The standing gate verdict, when the mod publishes one for this command.\n * Absent means nothing is known in advance.\n */\n gate?: CommandGateLike;\n /**\n * The standing verdict for a call with these arguments, when the command's\n * gate depends on which item they name. `useCommand` supplies it; a control\n * that sends arguments reads it in preference to {@link gate}.\n */\n gateFor?(args: Args): CommandGateLike | undefined;\n /**\n * What an order sent now would do, from `useCommand`'s `sendStatus`. The\n * control writes it in its tooltip and, for a held order or one expected to be\n * lost, outlines its own edge (see {@link PredictedOutcome}). It never\n * blocks the press and never changes the control's size.\n */\n sendStatus?: SendStatus | undefined;\n /**\n * Whether the panel's command rail holds this handle and so speaks its\n * outcomes, as `useCommand` reports. Absent or `false`, the control says its\n * own outcomes itself, even beside a rail.\n */\n railed?: boolean;\n /**\n * The stream to the mod is down, so a press cannot be sent. The control is\n * drawn dimmed with a dotted edge and a press does nothing until the stream\n * returns; a command already in flight is not affected. `useCommand`\n * supplies it.\n */\n streamDown?: boolean;\n /**\n * Whether a blocked gate stops the press, as `useCommand` reports: true for\n * a command that takes no signal delay and for one whose verdict is held only\n * a few seconds. When this is false or absent the gate is advice: the control\n * says the command is likely to be refused and a press sends it, for the game\n * to decide on arrival.\n */\n gateStopsPress?: boolean;\n}\n\n/**\n * The standing verdict a control sending `args` draws itself from: the per-item\n * one when the handle can say, else the command's own. Used by\n * {@link useCommandControl}.\n *\n * @category CommandButton\n */\nexport function standingGate<Args>(\n handle: Pick<CommandButtonHandle<unknown, Args>, \"gate\" | \"gateFor\">,\n args: Args | undefined,\n): CommandGateLike | undefined {\n return handle.gateFor ? handle.gateFor(args as Args) : handle.gate;\n}\n\n/**\n * Where a {@link Button} is in the command lifecycle. Useful for telling\n * the operator whether a command is waiting, on its way, refused, lost or\n * found. Returned by {@link useCommandControl} as `phase`.\n *\n * - `idle`: at rest\n * - `armed`: the operator has asked, and is being asked to mean it. Only\n * reachable when the caller supplied a `confirmLabel`\n * - `sent`: pressed and not yet answered by the mod, for at least\n * {@link SENT_FLASH_MS}. The command's journey to the vessel and back is the\n * delay rail's to show, so the control is live again once the mod answers\n * - `refused`: the game evaluated it and said no. A retry changes nothing until\n * the situation does\n * - `lost`: nothing came back. Not `idle`, which would look like a confirmed\n * command, and not `refused`, because the game decided nothing and the\n * command may have executed\n * - `found`: this control lost a command, and that command has since replied.\n * Not a confirmation: the operator may already have re-sent it\n * - `blocked`: the control cannot be pressed and says why, either because the\n * game will refuse this and said so before anyone pressed, or because the\n * caller gave an `unavailable` reason. The control is dimmed but not\n * `disabled`: it carries `aria-disabled`, stays focusable, and a press sends\n * nothing. Only the game's own refusal is drawn with a dashed warning edge;\n * the caller's reason keeps a solid edge. A gate verdict is advice, sampled\n * and possibly a beat behind, and the game evaluates the dispatch again\n *\n * The stream to the mod being down is not a phase: it is `isOffline`, drawn\n * dimmed with a dotted edge whichever phase the control is in\n *\n * @category CommandButton\n */\nexport type CommandButtonPhase =\n | \"idle\"\n | \"armed\"\n | \"sent\"\n | \"refused\"\n | \"lost\"\n | \"found\"\n | \"blocked\";\n\n/**\n * The tones a {@link Button} can draw in: `neutral`, `go`, `warn` and\n * `nogo`, the same set as a plain {@link Button}. Set with the `tone` prop of\n * {@link Button}.\n * Useful for colouring a command button by how serious the command is for the\n * operator.\n *\n * @category CommandButton\n */\nexport type CommandButtonTone = ButtonTone;\n\n/**\n * The two sizes of {@link Button}: `sm` for a dense row and `md`, the\n * default. Set with its `size` prop.\n * Useful for fitting a command button into a dense row or a roomier form.\n *\n * @category CommandButton\n */\nexport type CommandButtonSize = \"sm\" | \"md\";\n\n/**\n * Options for {@link useCommandControl}: the command the control sends when\n * pressed, and the toggle state it shows.\n * Useful for building a command control with the same dispatch and confirm\n * behaviour as {@link Button}. Used by {@link Button}.\n *\n * @category CommandButton\n */\nexport interface UseCommandControlOptions<\n Result = CommandReplyLike,\n Args = unknown,\n> {\n /**\n * The command to send, made with `with` on a `useCommand` handle or with\n * `commandSet`. Its handle is the one the control draws its state from.\n */\n command: BoundControlCommand<Args, Result>;\n /** Makes the control a state toggle. */\n toggle?: CommandToggle<Args>;\n /**\n * Why the control cannot be pressed now, for what the command's own\n * declaration cannot know. It is drawn dimmed with this as its tip and a\n * press sends nothing. Null or absent when it can be pressed.\n */\n unavailable?: string | null;\n /**\n * Why the game is likely to refuse this command, from what the caller can\n * see and the command's own declaration cannot know. The control stays\n * pressable and the press is sent: the reason is shown as advice in its tip\n * and on its edge, and the game decides on arrival. Null or absent when\n * nothing says it will be refused.\n */\n advise?: string | null;\n}\n\n/**\n * What {@link useCommandControl} returns: the current phase, a flag per phase,\n * the composed sentences to show, and `press`. Useful for drawing a command\n * control that looks different from {@link Button}.\n *\n * @category CommandButton\n */\nexport interface CommandControlState<Args = unknown> {\n /** The current phase. `blocked` whenever the gate refuses or the caller gave a reason and no outcome or dispatch is standing. */\n phase: CommandButtonPhase;\n /** Pressed, and the mod has not yet answered the press. */\n isSent: boolean;\n /** Asking the operator to mean it. */\n isArmed: boolean;\n /** The game said no, and `refusalText` says what it said. */\n isRefused: boolean;\n /** Nothing came back. Not a verdict, and not the same as at rest. */\n isLost: boolean;\n /** A command this control lost has since replied. `foundText` says what the reply was. */\n isFound: boolean;\n /**\n * The game will refuse this command if it is pressed, and said so in advance,\n * from a verdict fresh enough to stop the press. A verdict held longer is\n * advice: see `isAdvised`.\n * `refusalText` carries the reason here too, so a caller renders one string\n * whichever side of the press it is on.\n */\n isBlocked: boolean;\n /**\n * The caller said the control cannot be pressed (`unavailable`, or a toggle's\n * own reason), as opposed to the game having said it will refuse the command.\n * It is true together with `isBlocked`, and `refusalText` carries the caller's\n * reason. A control draws the two differently: dimmed with a solid edge for the\n * caller's reason, and dimmed with a dashed warning edge for the game's.\n */\n isUnavailable: boolean;\n /**\n * The game is likely to refuse this command, by its gate or the caller's\n * `advise`, and a press sends it anyway. `adviceText` carries the reason. Never\n * true together with `isBlocked`.\n */\n isAdvised: boolean;\n /** The advice, composed (\"... likely to be refused: ...\"), or `null` when nothing says the game will refuse it. */\n adviceText: string | null;\n /** The command this control sends, with its handle: what a face reads the command's standing state from. */\n command: BoundControlCommand<Args>;\n /**\n * The composed sentence, or `null` when there is nothing to say: a refusal\n * once one has happened, else the standing gate reason.\n */\n refusalText: string | null;\n /**\n * What the recovered command turned out to have done, composed, or `null`\n * outside the `found` phase. Kept apart from `refusalText`, which is true at a\n * different moment.\n */\n foundText: string | null;\n /**\n * What is known about a command that got no reply, composed, or `null`\n * outside the `lost` phase: the sentence a `Button` given a command speaks for it.\n */\n lossText: string | null;\n /**\n * The stream to the mod is down and nothing is in flight, so a press sends\n * nothing. The control is drawn dimmed with a dotted edge and its tip says it\n * is not connected to the mod, whichever phase it is in.\n */\n isOffline: boolean;\n /**\n * What a state toggle shows: the state (the predicted opposite while the\n * command is modelled), the word to draw, the held or modelled mark, and the\n * sentence for what it is waiting on. Null for a control with no `toggle`.\n */\n toggleView: {\n shown: boolean | number | null | undefined;\n on: boolean;\n word: string;\n /** Every word the control can show, which it is sized to hold. */\n reserve: readonly string[];\n /** Why the control cannot be pressed now, or null when it can. */\n unavailable: string | null;\n /** What the press is waiting on: `sent`, `held`, `modelled`, or null once nothing is outstanding. */\n confirmation: \"sent\" | \"held\" | \"modelled\" | null;\n marking: ReckoningMarking | null;\n sentence: string | null;\n } | null;\n /**\n * Sends `command` as this control's own press: for a toggle that a bound\n * input drives to a state, such as \"SAS on\", which a later press then\n * inverts. Does nothing while the stream to the mod is down.\n */\n // A method rather than a function-valued property, so a control typed for one command's args still takes another's state.\n pressWith(command: BoundControlCommand<Args>): void;\n /** This handle has a dispatch with no reply (overdue or lost), for the `data-unconfirmed` tint. */\n hasUnconfirmed: boolean;\n /** This handle has a dispatch that never left, for the `data-failed` tint. */\n hasFailure: boolean;\n /**\n * The control was pressed. Advances the machine: arm, then dispatch; a press\n * is always sent, however many are outstanding; a press while refused, lost or found clears that\n * outcome; a press while blocked (a command the game will refuse by a fresh verdict, or\n * the caller's `unavailable`) dispatches nothing and shows the reason\n * instead. `armable` says whether there is a confirm step, which only the\n * caller knows.\n */\n press: (armable: boolean) => void;\n}\n\n/**\n * The {@link Button} lifecycle with no rendering attached, for a control\n * that looks different. The hook keeps the phase, the arm timeout and the\n * reply handling; the caller draws each phase and wires its own click to\n * `press`. A `Button` given a `command` is this hook plus the default rendering. Useful for\n * a control that must look different but still show the operator what became\n * of the command. Returns a {@link CommandControlState}.\n *\n * @example\n * ```tsx\n * import { useCommand } from \"@ksp-gonogo/sitrep-sdk\";\n * import { Button, useCommandControl } from \"@ksp-gonogo/ui-kit\";\n *\n * function RecoverButton() {\n * const recover = useCommand(\"ksp.recover\");\n * const control = useCommandControl({\n * command: recover.with(undefined, { label: \"Recover\" }),\n * });\n * // A bound key presses the same control with control.press(true).\n * return (\n * <Button command={control} confirmLabel=\"Confirm recover\">\n * Recover\n * </Button>\n * );\n * }\n * ```\n *\n * @category CommandButton\n */\nexport function useCommandControl<Result = CommandReplyLike, Args = unknown>({\n command,\n toggle,\n unavailable,\n advise,\n}: UseCommandControlOptions<Result, Args>): CommandControlState<Args> {\n const handle = command.handle;\n const args = command.members ? undefined : argsOf(command);\n const commandLabel = command.options.label;\n const [phase, setPhase] = useState<CommandButtonPhase>(\"idle\");\n const [refusal, setRefusal] = useState<CommandRefusalLike | null>(null);\n const [found, setFound] = useState<CommandFoundLike | null>(null);\n // Each dispatch restarts the flash; `awaiting` holds from the press until the control's own dispatch settles.\n const [flashing, setFlashing] = useState(false);\n const [flashSeq, setFlashSeq] = useState(0);\n const [awaiting, setAwaiting] = useState(false);\n // The send this control's own dispatch became, so another control's press on a shared handle is not read as this one's.\n const ownRequestRef = useRef<string | null>(null);\n\n const streamDown = handle.streamDown === true;\n const gate = standingGate(handle, args);\n // An undetermined gate is NOT a refusal and must not darken anything.\n /*\n * A prediction stops the press only when it is fresh enough to stand for the\n * game's answer: the command takes no signal delay, or its delay is a few\n * seconds. Past that the control advises and the press is sent.\n */\n const stopsOnGate = handle.gateStopsPress === true;\n const toggleBlocked =\n toggle?.unavailable ??\n unavailable ??\n (stopsOnGate && advise\n ? commandGateSentence({\n errorCode: CommandErrorCode.ModeUnavailable,\n detail: advise,\n label: commandLabel,\n args,\n })\n : null) ??\n null;\n const gateBlocks =\n (gate?.blocked === true && stopsOnGate) || toggleBlocked !== null;\n const gateAdvises =\n gate?.blocked === true && !stopsOnGate && toggleBlocked === null;\n\n // A late reply must not set state after unmount or overwrite a newer dispatch's outcome.\n const mountedRef = useRef(true);\n const dispatchSeqRef = useRef(0);\n useEffect(() => {\n mountedRef.current = true;\n return () => {\n mountedRef.current = false;\n };\n }, []);\n\n /*\n * A command THIS control lost, turning up answered. One handle often serves\n * many rows, so the phase is gated on `awaitingFoundRef` (set when this\n * control's own dispatch settled lost, and holding what that dispatch\n * carried so a found for another row's command is not taken as this one's).\n * Cleared when the outcome is cleared or times out and when a new dispatch\n * starts. Watched off the handle, because the dispatch promise already\n * rejected as lost and never settles again.\n */\n const founds = handle.founds;\n const awaitingFoundRef = useRef<{ args: unknown; label?: string } | null>(\n null,\n );\n const foundsSeenRef = useRef(founds?.length ?? 0);\n useEffect(() => {\n const count = founds?.length ?? 0;\n const grew = count > foundsSeenRef.current;\n foundsSeenRef.current = count;\n const latest = founds?.[count - 1];\n const awaiting = awaitingFoundRef.current;\n if (!grew || !latest || awaiting === null) return;\n const otherLabel =\n latest.label !== undefined &&\n latest.label !== \"\" &&\n awaiting.label !== undefined &&\n latest.label !== awaiting.label;\n const otherArgs =\n latest.args !== undefined &&\n awaiting.args !== undefined &&\n JSON.stringify(latest.args) !== JSON.stringify(awaiting.args);\n if (otherLabel || otherArgs) return;\n awaitingFoundRef.current = null;\n setFound(latest);\n setRefusal(null);\n setPhase(\"found\");\n }, [founds]);\n\n // Auto-disarm, so a forgotten arm does not sit live indefinitely.\n useEffect(() => {\n if (phase !== \"armed\") return;\n const id = setTimeout(() => setPhase(\"idle\"), ARM_TIMEOUT_MS);\n return () => clearTimeout(id);\n }, [phase]);\n\n // Let a refusal, a silence or a found be read, then return to rest.\n useEffect(() => {\n if (phase !== \"refused\" && phase !== \"lost\" && phase !== \"found\") return;\n const id = setTimeout(() => {\n setPhase(\"idle\");\n setRefusal(null);\n awaitingFoundRef.current = null;\n // The rail holds a found until dismissed; this is only the echo on the control.\n setFound(null);\n }, REFUSAL_TIMEOUT_MS);\n return () => clearTimeout(id);\n }, [phase]);\n\n // The press stays visible as SENT for at least the flash, however soon the mod answers.\n useEffect(() => {\n if (flashSeq === 0) return;\n const id = setTimeout(() => setFlashing(false), SENT_FLASH_MS);\n return () => clearTimeout(id);\n }, [flashSeq]);\n\n const dispatch = useCallback(\n (target: BoundControlCommand<Args, Result> = command) => {\n const sendArgs = target.members ? undefined : argsOf(target);\n const label = target.options.label;\n const seq = dispatchSeqRef.current + 1;\n dispatchSeqRef.current = seq;\n awaitingFoundRef.current = null;\n ownRequestRef.current = null;\n setPhase(\"idle\");\n setRefusal(null);\n setFlashing(true);\n setFlashSeq((n) => n + 1);\n setAwaiting(true);\n const settle = (\n next: CommandButtonPhase,\n reason: CommandRefusalLike | null,\n ) => {\n if (!mountedRef.current || dispatchSeqRef.current !== seq) return;\n setRefusal(reason);\n setPhase(next);\n setAwaiting(false);\n // An outcome is shown at once, not after the flash.\n if (next !== \"idle\") setFlashing(false);\n };\n const refusalOf = (\n rejection: Extract<\n ReturnType<typeof classifyCommandRejection>,\n { kind: \"refused\" }\n >,\n ): CommandRefusalLike => ({\n errorCode: rejection.errorCode,\n reason: rejection.reason,\n command: rejection.command,\n args: rejection.args,\n label: rejection.label ?? label,\n breach: rejection.breach,\n // The game's own words, which `commandRefusalSentence` prefers over its general clause.\n detail: rejection.detail,\n });\n const options = target.options;\n let sent: Promise<Result>;\n if (target.members) {\n // A member's refusal is told in the same sentence the control shows for its own.\n const members = target.members.map((m) => ({\n ...m,\n options: {\n ...m.options,\n onRejected: (error: unknown) => {\n m.options.onRejected?.(error);\n const rejection = classifyCommandRejection(error);\n if (rejection.kind === \"refused\") {\n m.options.onRefused?.(\n commandRefusalSentence({\n ...refusalOf(rejection),\n label: rejection.label ?? m.options.label,\n }),\n );\n }\n },\n },\n }));\n sent = runSet(members, target.set ?? {}).then((result) =>\n result.failed > 0\n ? Promise.reject(result.firstError)\n : (undefined as Result),\n );\n } else {\n options.before?.(sendArgs);\n sent = target.handle.dangerouslySendWithoutInput(\n sendArgs,\n label || options.topic ? { label, topic: options.topic } : undefined,\n ) as Promise<Result>;\n }\n sent.then(\n (result: Result) => {\n settle(\"idle\", null);\n options.onConfirmed?.(result);\n },\n (err: unknown) => {\n const rejection = classifyCommandRejection(err);\n if (!target.members) {\n options.onRejected?.(err);\n if (rejection.kind === \"refused\") {\n options.onRefused?.(commandRefusalSentence(refusalOf(rejection)));\n }\n }\n if (rejection.kind === \"lost\") {\n // From here on, a found landing on the handle is this control's.\n awaitingFoundRef.current = { args: sendArgs, label };\n settle(\"lost\", null);\n return;\n }\n if (rejection.kind !== \"refused\") {\n // A machinery failure is the rail's to report, not this control's.\n settle(\"idle\", null);\n return;\n }\n settle(\"refused\", refusalOf(rejection));\n },\n );\n },\n [command],\n );\n\n // The rail is the primary outcome surface; these tints only say WHICH control issued the command.\n const { hasUnconfirmed, hasFailure } = commandOutcomes(handle);\n\n /*\n * The mod answers a press with an acceptance (or its reply, for a command\n * with no delay). A handle with no status can only say it was just pressed.\n */\n const status: CommandStatus | undefined = handle.status;\n const unanswered =\n awaiting &&\n status?.phase === \"in-flight\" &&\n status.accepted !== true &&\n (ownRequestRef.current === null ||\n ownRequestRef.current === status.requestId);\n const sent = flashing || unanswered;\n useEffect(() => {\n if (\n awaiting &&\n ownRequestRef.current === null &&\n status?.phase === \"in-flight\"\n ) {\n ownRequestRef.current = status.requestId;\n }\n }, [awaiting, status]);\n\n const toggleRows = toggle\n ? handle.inFlight.filter(toggle.rows ?? (() => true))\n : [];\n const confirmation = toggle\n ? toggleConfirmationOf(\n sent,\n status,\n toggleRows,\n toggle.state,\n toggle.modelled,\n )\n : null;\n const modelledShown = toggle\n ? shownToggleState(\n toggle.state,\n confirmation,\n status,\n toggleRows,\n toggle.modelled,\n )\n : undefined;\n const wireEpoch = useWireTimelineEpoch();\n // While the latest press is outstanding the shown reading is still the old state, so the next press inverts the state that press asked for.\n const askedRef = useRef<boolean | undefined>(undefined);\n // The reading a press was made against: while a confirmed press has not moved it, the press still stands as the state asked for.\n const askedFromRef = useRef<ToggleState>(undefined);\n /*\n * The reply reaches the app before the frame that carries the new state, so a\n * confirmed press keeps showing the state it asked for until the reading\n * moves or this long has passed, instead of flashing the old state back.\n */\n const [heldPast, setHeldPast] = useState<string | null>(null);\n const heldRequestId = status?.phase === \"confirmed\" ? status.requestId : null;\n useEffect(() => {\n if (heldRequestId === null) return;\n const timer = setTimeout(\n () => setHeldPast(heldRequestId),\n CONFIRMED_STATE_HOLD_MS,\n );\n return () => clearTimeout(timer);\n }, [heldRequestId]);\n // The press whose asked state this control was already drawing as a prediction: only that one is held past its reply.\n const predictedForRef = useRef<string | null>(null);\n if (\n toggle !== undefined &&\n confirmation === \"modelled\" &&\n status !== undefined &&\n status.phase !== \"idle\" &&\n askedRef.current !== undefined &&\n modelledShown === askedRef.current\n ) {\n predictedForRef.current = status.requestId;\n }\n const holdsAsked =\n toggle !== undefined &&\n heldRequestId !== null &&\n predictedForRef.current === heldRequestId &&\n confirmation !== \"modelled\" &&\n heldRequestId !== null &&\n heldRequestId !== heldPast &&\n askedRef.current !== undefined &&\n toggle.state === askedFromRef.current;\n const shown = holdsAsked ? askedRef.current : modelledShown;\n const outstanding =\n pressOutstanding(status, handle.inFlight) ||\n (status?.phase === \"confirmed\" &&\n askedRef.current !== undefined &&\n toggle?.state === askedFromRef.current);\n const toggleBase =\n outstanding && askedRef.current !== undefined ? askedRef.current : shown;\n\n // Read at press time, so a second press before the next render inverts the state the first one asked for.\n const toggleBaseRef = useRef(toggleBase);\n toggleBaseRef.current = toggleBase;\n\n const press = useCallback(\n (armable: boolean) => {\n if (streamDown) return;\n // The game already said it will refuse this, so the press sends nothing; the reason is the control's tip.\n if (gateBlocks) return;\n // A state toggle sends the opposite of the state it shows, however many presses are outstanding and whatever became of an earlier one.\n if (toggle) {\n const sendArgs = toggle.args(toggleBaseRef.current);\n if (sendArgs === undefined) return;\n askedRef.current = askedToggleValue(sendArgs);\n askedFromRef.current = toggle.state;\n if (askedRef.current !== undefined) {\n toggleBaseRef.current = askedRef.current;\n }\n dispatch({ ...command, args: sendArgs });\n return;\n }\n // A press on an outcome clears it and starts the handshake over, rather than dispatching straight back.\n if (phase === \"refused\" || phase === \"lost\" || phase === \"found\") {\n setRefusal(null);\n setFound(null);\n awaitingFoundRef.current = null;\n setPhase(\"idle\");\n return;\n }\n if (armable) {\n // The confirm already went, so a press now would arm a second spend behind a face that reads SENT.\n if (sent) return;\n if (phase !== \"armed\") {\n armedForRef.current = argsKey(args);\n armedOnEpochRef.current = wireEpoch;\n setPhase(\"armed\");\n return;\n }\n }\n dispatch();\n },\n [\n phase,\n sent,\n streamDown,\n gateBlocks,\n dispatch,\n args,\n toggle,\n command,\n wireEpoch,\n ],\n );\n\n // One handle serves many rows, and a row keyed by position can be handed another item while armed; the confirming press must not send to it. A game load drops the confirm too, because what was armed against is gone.\n const armedForRef = useRef<string | null>(null);\n const armedOnEpochRef = useRef(wireEpoch);\n useEffect(() => {\n if (\n phase === \"armed\" &&\n (argsKey(args) !== armedForRef.current ||\n wireEpoch !== armedOnEpochRef.current)\n ) {\n setPhase(\"idle\");\n }\n }, [phase, args, wireEpoch]);\n\n // A real outcome outranks a standing gate, and a command already travelling is not stopped by a gate that shut behind it.\n const effectivePhase: CommandButtonPhase =\n phase === \"refused\" || phase === \"lost\" || phase === \"found\"\n ? phase\n : sent\n ? \"sent\"\n : gateBlocks\n ? \"blocked\"\n : phase;\n\n const adviceText =\n effectivePhase === \"blocked\" || toggleBlocked !== null\n ? null\n : gateAdvises && gate\n ? commandAdviceSentence({\n ...gate,\n label: gate.label ?? commandLabel,\n args: gate.args ?? args,\n })\n : advise\n ? commandAdviceSentence({\n errorCode: CommandErrorCode.ModeUnavailable,\n detail: advise,\n label: commandLabel,\n args,\n })\n : null;\n\n return {\n phase: effectivePhase,\n isSent: effectivePhase === \"sent\",\n isArmed: effectivePhase === \"armed\",\n isRefused: effectivePhase === \"refused\",\n isLost: effectivePhase === \"lost\",\n isFound: effectivePhase === \"found\",\n isBlocked: effectivePhase === \"blocked\",\n isOffline: streamDown && effectivePhase !== \"sent\",\n isUnavailable: toggleBlocked !== null,\n isAdvised: adviceText !== null,\n adviceText,\n command,\n refusalText: refusal\n ? commandRefusalSentence(refusal)\n : toggleBlocked !== null\n ? toggleBlocked\n : effectivePhase === \"blocked\" && gate\n ? // The mod's gate is per command, so the caller's label says which row went dark.\n commandGateSentence({\n ...gate,\n label: gate.label ?? commandLabel,\n args: gate.args ?? args,\n })\n : null,\n foundText: found ? commandFoundSentence(found) : null,\n lossText:\n effectivePhase === \"lost\"\n ? commandLossSentence({ args, label: commandLabel })\n : null,\n pressWith: (bound) => {\n if (streamDown) return;\n askedRef.current = askedToggleValue(argsOf(bound));\n askedFromRef.current = toggle?.state;\n dispatch(bound);\n },\n toggleView: toggle\n ? {\n shown,\n on: typeof shown === \"number\" ? shown > 0 : shown === true,\n word:\n confirmation === \"sent\"\n ? (toggle.sentWord ?? SENT_WORD)\n : toggle.word(shown),\n reserve: [...toggle.words, toggle.sentWord ?? SENT_WORD],\n confirmation,\n unavailable: toggleBlocked,\n marking: toggleMarking(\n toggle.name,\n confirmation,\n toggle.marking ?? null,\n ),\n sentence: confirmationSentenceOf(toggle.name, confirmation),\n }\n : null,\n hasUnconfirmed,\n hasFailure,\n press,\n };\n}\n","import type { CommandStatus } from \"@ksp-gonogo/sitrep-sdk\";\nimport type { InFlightCommandLike } from \"../CommandDelay/toInFlightListItems\";\nimport type { ReckoningMarking } from \"../readingCurrency\";\n\n/**\n * What a control that represents a state shows of the command that sets it,\n * while the state it shows is not yet the one the command sets: `sent` until\n * the mod answers the press, `held` while the route has a command for the\n * control waiting at a relay, whichever screen of the command centre sent it,\n * and `modelled` once a command is predicted to have reached the craft with\n * its reply still on its way back, when the control shows the state the\n * command sets, marked modelled. Null otherwise: where a command is on its way\n * is the delay rail's to show.\n */\nexport type ToggleConfirmation = \"held\" | \"sent\" | \"modelled\";\n\n/**\n * The state a toggle control reads from the vessel: a flag, a count (a stage\n * group reports one) or nothing yet, where nothing is a third state and not\n * off. Useful for showing the operator what a switch such as SAS or an action\n * group is set to, and for telling an unread switch from one that is off. Used\n * by {@link CommandToggle} and {@link Button}.\n *\n * @category CommandButton\n */\nexport type ToggleState = boolean | number | null | undefined;\n\n/**\n * The state variant of {@link Button}: the control shows a state, and a\n * press sends the command that sets the opposite. Useful for a switch the\n * operator flips under signal delay, such as SAS or an action group. Taken by\n * the `toggle` prop of {@link Button} and {@link useCommandControl}.\n *\n * @category CommandButton\n */\nexport interface CommandToggle<Args = unknown> {\n /** The state as the vessel last reported it, uncoerced: nothing yet is a third state, not off. */\n state: ToggleState;\n /** What the control is called in the sentences it speaks (\"RCS sent, not yet received\"). */\n name: string;\n /** The word the control shows for a state. */\n word: (shown: ToggleState) => string;\n /** Every word `word` can return, so the control keeps its size as the word changes. */\n words: readonly string[];\n /** The word shown in place of the state until the mod answers the press. Defaults to \"SENT\". */\n sentWord?: string;\n /** Which of the handle's in-flight rows are this control's, where one command serves several controls. Defaults to all of them. */\n rows?: (row: InFlightCommandLike) => boolean;\n /**\n * The args for a press that moves the control away from `base`, the state\n * the control shows (or, while an earlier press is outstanding, the state\n * that press asked for). Return undefined where there is nothing to send; null is a real argument, as for a command that takes none.\n */\n args: (base: ToggleState) => Args | undefined;\n /**\n * What an arrived command does to a state its args do not set outright, as a\n * stage command lowers the stage count. Without it only args carrying a\n * `state` or `enabled` flag are modelled.\n */\n modelled?: (state: ToggleState, args: unknown) => ToggleState;\n /**\n * Why the control cannot be pressed now, such as a game that refuses it or a\n * vessel that cannot be flown. The control is drawn dark with this as its\n * tip, and a press sends nothing. Null or absent when it can be pressed.\n */\n unavailable?: string | null;\n /** The mark the state's own reading wears, when it is held or late, which the control shows beside its own. */\n marking?: ReckoningMarking | null;\n}\n\n/** The rows of a toggle's command predicted to have reached the craft with their reply still on the way back, in the order they arrive. */\nfunction arrivedRows(\n status: CommandStatus | undefined,\n rows: readonly InFlightCommandLike[],\n): InFlightCommandLike[] {\n // A press whose reply is back is no longer modelled, though its row stays until the readings show it.\n const answered =\n status === undefined ||\n status.phase === \"in-flight\" ||\n status.phase === \"idle\"\n ? null\n : status.requestId;\n const arrivalOf = (row: InFlightCommandLike) =>\n (row.dispatchedAt ?? 0) + (row.oneWaySeconds ?? 0);\n return rows\n .filter(\n (row) =>\n row.id !== answered &&\n (row.predictedPhase === \"awaiting-reply\" ||\n row.predictedPhase === \"due\"),\n )\n .sort((a, b) => arrivalOf(a) - arrivalOf(b));\n}\n\n/**\n * The state the craft is expected to be in once every arrived command has run,\n * applied in arrival order to the state last received, or undefined where no\n * arrived command sets a state. A command carries its value in its args; one\n * with none known (another screen's, whose args do not cross the wire) is read\n * as a flip of the running state.\n */\nexport function modelledToggleState(\n reading: ToggleState,\n status: CommandStatus | undefined,\n rows: readonly InFlightCommandLike[],\n apply?: (state: ToggleState, args: unknown) => ToggleState,\n): ToggleState | undefined {\n let state = reading;\n let known = false;\n for (const row of arrivedRows(status, rows)) {\n /*\n * Another screen's args do not cross the wire. The centre's queue carries\n * the state it set as a number where the command sets one, and without it\n * the press can only be read as a flip of the running state.\n */\n if (row.args === undefined) {\n if (typeof row.commandedValue === \"number\") {\n state = row.commandedValue !== 0;\n known = true;\n continue;\n }\n if (typeof state === \"boolean\") {\n state = !state;\n known = true;\n }\n continue;\n }\n const asked = askedToggleValue(row.args);\n const next = asked !== undefined ? asked : apply?.(state, row.args);\n if (next === undefined) continue;\n known = true;\n state = next;\n }\n return known ? state : undefined;\n}\n\n/** The toggle's confirmation from its handle's status and in-flight rows. */\nexport function toggleConfirmationOf(\n sent: boolean,\n status: CommandStatus | undefined,\n rows: readonly InFlightCommandLike[],\n reading: ToggleState = undefined,\n apply?: (state: ToggleState, args: unknown) => ToggleState,\n): ToggleConfirmation | null {\n if (sent) return \"sent\";\n if (rows.some((row) => row.held === true)) return \"held\";\n return modelledToggleState(reading, status, rows, apply) === undefined\n ? null\n : \"modelled\";\n}\n\n/** The state a toggle shows: the state its arrived commands set, in arrival order, while its confirmation is `modelled`. */\nexport function shownToggleState(\n reading: ToggleState,\n confirmation: ToggleConfirmation | null,\n status?: CommandStatus,\n rows: readonly InFlightCommandLike[] = [],\n apply?: (state: ToggleState, args: unknown) => ToggleState,\n): ToggleState {\n if (confirmation !== \"modelled\") return reading;\n return modelledToggleState(reading, status, rows, apply) ?? reading;\n}\n\n/**\n * Whether the latest press of a toggle is still outstanding: not yet answered\n * by the craft, or answered and not yet shown by the readings. A press that was\n * refused, failed, lost or never left asked for nothing the control should\n * count on, even while its row waits to be dismissed.\n */\nexport function pressOutstanding(\n status: CommandStatus | undefined,\n rows: readonly InFlightCommandLike[],\n): boolean {\n if (status === undefined || status.phase === \"idle\") return false;\n if (status.phase === \"in-flight\") return true;\n if (status.phase !== \"confirmed\" && status.phase !== \"found\") return false;\n return rows.some((row) => row.id === status.requestId);\n}\n\n/** The state a toggle's args ask for, or undefined for args that set no state. */\nexport function askedToggleValue(args: unknown): boolean | undefined {\n if (args === null || typeof args !== \"object\") return undefined;\n const asked =\n \"state\" in args ? args.state : \"enabled\" in args ? args.enabled : undefined;\n return typeof asked === \"boolean\" ? asked : undefined;\n}\n\n/** What a toggle is waiting on, as a sentence for its tooltip and for a screen reader. */\nexport function confirmationSentenceOf(\n name: string,\n confirmation: ToggleConfirmation | null,\n): string | null {\n switch (confirmation) {\n case \"held\":\n return `${name} held until contact returns`;\n case \"sent\":\n return `${name} sent, not yet received`;\n case \"modelled\":\n return `${name} shown as predicted: the command should have reached the craft, and its reply is on its way back`;\n default:\n return null;\n }\n}\n\n/** The held or modelled mark for a toggle, joined with the mark its reading already wears; null when neither applies. */\nexport function toggleMarking(\n name: string,\n confirmation: ToggleConfirmation | null,\n existing: ReckoningMarking | null,\n): ReckoningMarking | null {\n if (confirmation !== \"held\" && confirmation !== \"modelled\") return existing;\n const caption = confirmationSentenceOf(name, confirmation) ?? \"\";\n return {\n kind: confirmation,\n caption: existing === null ? caption : `${existing.caption}. ${caption}`,\n };\n}\n","import styled from \"styled-components\";\n\n/**\n * Screen-reader-only content: visually removed but kept in the accessibility\n * tree. Useful for giving an operator who uses assistive technology what a\n * sighted operator reads from another channel (colour, a ticking number), such\n * as a discrete power-state word beside a colour-coded net-rate readout, or the\n * word a currency icon stands for. Used by the station radio indicator.\n *\n * Pair it with `role=\"status\" aria-live=\"polite\"` to announce a discrete state\n * change; keep a streaming value out of the live region so it does not flood\n * the screen reader every tick.\n *\n * @example\n * ```tsx\n * <span role=\"status\" aria-live=\"polite\">\n * <VisuallyHidden>{netRate < 0 ? \"Draining\" : \"Charging\"}</VisuallyHidden>\n * </span>\n * ```\n *\n * @category Typography\n */\nexport const VisuallyHidden = styled.span`\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n`;\n","import { createElement, type ReactNode } from \"react\";\nimport { VisuallyHidden } from \"./VisuallyHidden\";\n\n/**\n * Props of {@link LiveRegion}. Useful for setting the words announced to the\n * operator and whether they interrupt. Taken by {@link LiveRegion}.\n *\n * @category Typography\n */\nexport interface LiveRegionProps {\n /** The words to announce; leave empty until there is something to say. */\n children?: ReactNode;\n /** Names the region, for a region that also holds visible content. */\n \"aria-label\"?: string;\n /**\n * Keep the region off screen: an announcer, a bare `aria-live` region rather\n * than a `status`, for words whose visible form is drawn somewhere else.\n */\n visuallyHidden?: boolean;\n /**\n * Announce each addition on its own rather than re-reading the whole region.\n * For a region that collects entries (one per outcome), where a new entry\n * should not repeat every entry before it.\n */\n additionsOnly?: boolean;\n /**\n * Interrupt rather than announce: `aria-live=\"assertive\"`, and `role=\"alert\"`\n * where the region is on screen. Only for states that must interrupt\n * whatever the operator is doing, such as a mission abort, and nothing softer.\n */\n assertive?: boolean;\n /** The tag the region is drawn with: `span` to sit inside a line of text, `div` for a block. */\n as?: \"div\" | \"span\";\n /** The class `styled(LiveRegion)` passes in to style the region. */\n className?: string;\n}\n\n/**\n * A live region that is in the document before anything is said in it, so\n * screen-reader users hear the words put into it. Useful for telling the\n * operator the outcome of a command or a change of state without moving\n * focus. Used by {@link Notice} and {@link StreamStatusBadge}.\n *\n * Assistive tech announces changes to a region, so one inserted already holding\n * its message is often never announced. Mount this for as long as the thing it\n * reports on is on screen, and put the words in when there is something to say.\n *\n * Polite unless `assertive`, which interrupts and is kept for states that must\n * interrupt, such as a mission abort.\n *\n * @example Mounted with the control, empty until there is an outcome to say\n * ```tsx\n * import { Button, LiveRegion } from \"@ksp-gonogo/ui-kit\";\n * import { useState } from \"react\";\n *\n * function Deploy(props: { onDeploy: () => Promise<void> }) {\n * const [outcome, setOutcome] = useState(\"\");\n * const deploy = () =>\n * props.onDeploy().then(\n * () => setOutcome(\"Deployed\"),\n * () => setOutcome(\"Deploy refused\"),\n * );\n * return (\n * <>\n * <Button onClick={() => void deploy()}>Deploy</Button>\n * <LiveRegion>{outcome}</LiveRegion>\n * </>\n * );\n * }\n * ```\n *\n * @category Typography\n */\nexport function LiveRegion({\n children,\n \"aria-label\": ariaLabel,\n visuallyHidden = false,\n additionsOnly = false,\n assertive = false,\n as = \"span\",\n className,\n}: LiveRegionProps) {\n const visibleRole = assertive ? \"alert\" : \"status\";\n const props = {\n role: visuallyHidden ? undefined : visibleRole,\n \"aria-live\": assertive ? \"assertive\" : \"polite\",\n \"aria-atomic\": additionsOnly ? \"false\" : \"true\",\n \"aria-label\": ariaLabel,\n className,\n \"data-live-region\": \"\",\n } as const;\n return visuallyHidden ? (\n <VisuallyHidden as={as} {...props}>\n {children}\n </VisuallyHidden>\n ) : (\n createElement(as, props, children)\n );\n}\n","import {\n type CSSProperties,\n cloneElement,\n type FocusEvent,\n forwardRef,\n type ReactElement,\n type ReactNode,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport styled, { createGlobalStyle } from \"styled-components\";\nimport { FOCUS_RESTORE_ATTRIBUTE } from \"./focusRestore\";\n\n/** Where the tip sits, in viewport pixels: below its anchor, or above it where the anchor is low on the screen. */\ninterface Placement {\n top: number;\n left: number;\n above: boolean;\n anchorTop: number;\n}\n\n/** Anchors with less than this much viewport below them put their tip above. */\nconst ROOM_BELOW_PX = 120;\n\n/** An anchor with less than this much viewport above it puts its tip below, whatever its placement asks. */\nconst ROOM_ABOVE_PX = 48;\n\n/** How long the pointer rests on an anchor before its tip opens, so a pointer passing over controls on its way elsewhere opens none. */\nconst OPEN_DELAY_MS = 600;\n\n/** How long the pointer may spend crossing from an anchor to its tip before the tip closes. */\nconst CROSSING_MS = 120;\n\n/** The tips showing now, each with the element it describes, so a tip can give way to one on an element inside its own. */\nconst openTips = new Set<{ anchor: Element; close: () => void }>();\n\n/** A name or description reduced to its words, so punctuation cannot make two phrasings of one thing differ. */\nconst words = (text: string): string =>\n text\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \" \")\n .trim();\n\n/**\n * The handlers and data attribute to spread onto the element the tip describes.\n * Useful for opening a tip when the operator points at or focuses the element.\n * Returned as `anchor` by {@link useTooltip}.\n *\n * @category Floating\n */\nexport interface TooltipAnchorProps {\n /** Opens the tip once the pointer has rested on the element for about 0.6 seconds; a finger touching down does not open it. */\n onPointerEnter?: (event: {\n currentTarget: Element;\n pointerType?: string;\n }) => void;\n /** Closes the tip shortly after the pointer leaves, unless it moves onto the tip. */\n onPointerLeave?: () => void;\n /** Closes the tip on a mouse or pen press, so it never covers what is being pressed. A finger's press leaves it as it is. */\n onPointerDown?: (event: { pointerType?: string }) => void;\n /** Ends the press, so the next keyboard focus can open the tip again. A finger lifting off the anchor opens the tip, or closes it when it is already open. */\n onPointerUp?: (event: {\n currentTarget: Element;\n pointerType?: string;\n }) => void;\n /** Opens the tip on keyboard focus; the focus a press gives does not. */\n onFocus?: (event: FocusEvent<Element>) => void;\n /** Closes the tip when focus leaves, unless the pointer still holds it open. */\n onBlur?: () => void;\n /** The tip's text, on the element itself. Absent while there is no tip. */\n \"data-tooltip\"?: string;\n}\n\n/**\n * What {@link useTooltip} returns: props for the anchor, and the tip to render\n * beside it. Useful for explaining a control or figure to the operator in a tip\n * drawn where the caller chooses.\n *\n * @category Floating\n */\nexport interface UseTooltipResult {\n /** Props to spread on the element the tip belongs to. */\n anchor: TooltipAnchorProps;\n /** The tip itself, portalled to the document body; render it anywhere beside the anchor. */\n tip: ReactNode;\n}\n\n/**\n * The kit's tip for `text`: padded, rounded, drawn over everything, and\n * placed below its anchor inside the viewport, so a clipping or scrolling\n * ancestor never cuts it off. Useful for giving the operator the words behind\n * an icon or abbreviation when the tip needs its own placement. Used by the\n * communications addressee control. It opens once the pointer has rested on the anchor for about 0.6 seconds, or at once when\n * the anchor has keyboard focus, and closes on a press of the anchor, on Escape (from anywhere on the page), scroll or resize. On a touch screen a tap on the anchor opens it and a second tap on the anchor, a tap anywhere else, Escape or scroll closes it. The pointer can move onto the tip, which stays open while it is hovered and while its text is held or selected, so the operator can copy it.\n *\n * The tip is hidden from the accessibility tree, so the anchor must already\n * say the same thing to a screen reader (in its text, an `aria-label` or a\n * visually hidden span); {@link Tooltip} does this for any element. The\n * anchor must be focusable for the keyboard to open the tip. `null` or empty\n * text gives an inert anchor and no tip.\n *\n * @example\n * ```tsx\n * function Figure({ caption, children }: { caption: string | null; children: ReactNode }) {\n * const { anchor, tip } = useTooltip(caption);\n * return (\n * <span {...anchor}>\n * {children}\n * {caption && <VisuallyHidden>, {caption}</VisuallyHidden>}\n * {tip}\n * </span>\n * );\n * }\n * ```\n *\n * @category Floating\n */\nexport function useTooltip(text: string | null | undefined): UseTooltipResult {\n return useTooltipAt(text, \"below\");\n}\n\n/** {@link useTooltip} with a preferred side: `\"above\"` stands the tip over its anchor where there is room, so it covers nothing below the anchor. */\nfunction useTooltipAt(\n text: string | null | undefined,\n placement: \"below\" | \"above\",\n): UseTooltipResult {\n const [at, setAt] = useState<Placement | null>(null);\n const [hovered, setHovered] = useState(false);\n const [focused, setFocused] = useState(false);\n const [tipHovered, setTipHovered] = useState(false);\n // Set while the operator holds a press inside the tip or has text of it selected, so the tip stays to be read and copied.\n const [pinned, setPinned] = useState(false);\n // Set by a finger's tap on the anchor, which holds the tip open until a tap elsewhere.\n const [tapped, setTapped] = useState(false);\n const anchorRef = useRef<Element | null>(null);\n const placedOn = useRef<Element | null>(null);\n const tipRef = useRef<HTMLDivElement | null>(null);\n const holding = useRef(false);\n const pressed = useRef(false);\n const leaving = useRef<ReturnType<typeof setTimeout> | null>(null);\n const entering = useRef<ReturnType<typeof setTimeout> | null>(null);\n const shown = text != null && text !== \"\" ? text : null;\n const open =\n at !== null && (hovered || focused || tipHovered || pinned || tapped);\n const cancelLeave = useCallback(() => {\n if (leaving.current !== null) clearTimeout(leaving.current);\n leaving.current = null;\n if (entering.current !== null) clearTimeout(entering.current);\n entering.current = null;\n }, []);\n const close = useCallback(() => {\n cancelLeave();\n setAt(null);\n setHovered(false);\n setFocused(false);\n setTipHovered(false);\n setPinned(false);\n setTapped(false);\n holding.current = false;\n }, [cancelLeave]);\n\n // Only the innermost tip shows: a tip on a control inside a tipped cell replaces the cell's tip rather than sitting under it.\n useEffect(() => {\n const anchor = placedOn.current;\n if (!open || anchor === null) return;\n const entry = { anchor, close };\n for (const other of openTips) {\n if (other.anchor === anchor) continue;\n if (other.anchor.contains(anchor)) other.close();\n // Both opened in one batch, and the inner one's effect ran first.\n if (anchor.contains(other.anchor)) {\n close();\n return;\n }\n }\n openTips.add(entry);\n return () => {\n openTips.delete(entry);\n };\n }, [open, close]);\n\n // Lets go once the press is over and no text of the tip is selected any more.\n useEffect(() => {\n if (!pinned) return;\n const settle = () => {\n const selection = document.getSelection();\n const inTip =\n selection !== null &&\n !selection.isCollapsed &&\n tipRef.current?.contains(selection.anchorNode) === true;\n if (!holding.current && !inTip) setPinned(false);\n };\n const release = () => {\n holding.current = false;\n settle();\n };\n document.addEventListener(\"pointerup\", release);\n document.addEventListener(\"selectionchange\", settle);\n return () => {\n document.removeEventListener(\"pointerup\", release);\n document.removeEventListener(\"selectionchange\", settle);\n };\n }, [pinned]);\n\n // A finger's tap outside both the anchor and the tip dismisses a tapped tip.\n useEffect(() => {\n if (!tapped) return;\n const away = (event: PointerEvent) => {\n const target = event.target;\n if (!(target instanceof Node)) return;\n if (anchorRef.current?.contains(target)) return;\n if (tipRef.current?.contains(target)) return;\n close();\n };\n document.addEventListener(\"pointerdown\", away, true);\n return () => document.removeEventListener(\"pointerdown\", away, true);\n }, [tapped, close]);\n\n // The pointer gets a moment to cross onto the tip before the anchor's leave closes it.\n const leaveSoon = useCallback(() => {\n cancelLeave();\n leaving.current = setTimeout(() => {\n leaving.current = null;\n setHovered(false);\n setTipHovered(false);\n }, CROSSING_MS);\n }, [cancelLeave]);\n\n useEffect(() => cancelLeave, [cancelLeave]);\n\n // A tip placed once goes stale when the page under it moves.\n useEffect(() => {\n if (at === null) return;\n window.addEventListener(\"scroll\", close, true);\n window.addEventListener(\"resize\", close);\n return () => {\n window.removeEventListener(\"scroll\", close, true);\n window.removeEventListener(\"resize\", close);\n };\n }, [at, close]);\n\n /*\n * WCAG 1.4.13: Escape dismisses the tip wherever focus or the pointer is. It\n * listens in the capture phase on the document and stops the key there, so an\n * enclosing dialog's own Escape handler does not also close the dialog.\n */\n // Only while a tip is showing: an anchor whose text has gone has nothing to dismiss, and must not take the key from its own handler.\n useEffect(() => {\n if (!open || shown === null) return;\n const onKey = (event: globalThis.KeyboardEvent) => {\n if (event.key !== \"Escape\") return;\n event.stopPropagation();\n close();\n };\n document.addEventListener(\"keydown\", onKey, true);\n return () => document.removeEventListener(\"keydown\", onKey, true);\n }, [open, shown, close]);\n\n if (shown === null) return { anchor: {}, tip: null };\n\n const place = (element: Element) => {\n placedOn.current = element;\n const box = element.getBoundingClientRect();\n setAt({\n top: box.bottom,\n left: box.left,\n above:\n placement === \"above\"\n ? box.top >= ROOM_ABOVE_PX\n : window.innerHeight - box.bottom < ROOM_BELOW_PX,\n anchorTop: box.top,\n });\n };\n\n return {\n anchor: {\n \"data-tooltip\": shown,\n onPointerEnter: (event) => {\n if (event.pointerType === \"touch\") return;\n cancelLeave();\n const anchor = event.currentTarget;\n entering.current = setTimeout(() => {\n entering.current = null;\n place(anchor);\n setHovered(true);\n }, OPEN_DELAY_MS);\n },\n onPointerLeave: leaveSoon,\n onPointerDown: (event) => {\n pressed.current = true;\n if (event.pointerType === \"touch\") return;\n close();\n },\n onPointerUp: (event) => {\n pressed.current = false;\n if (event.pointerType !== \"touch\") return;\n if (tapped) {\n close();\n return;\n }\n anchorRef.current = event.currentTarget;\n place(event.currentTarget);\n setTapped(true);\n },\n onFocus: (event) => {\n // A pointer press focuses its target too; only keyboard focus opens the tip on its own.\n if (pressed.current) return;\n if (document.documentElement.hasAttribute(FOCUS_RESTORE_ATTRIBUTE))\n return;\n place(event.currentTarget);\n setFocused(true);\n },\n onBlur: () => {\n setFocused(false);\n if (!hovered && !tipHovered && !tapped) setAt(null);\n },\n },\n tip: open\n ? createPortal(\n <TipBody\n ref={tipRef}\n at={at}\n text={shown}\n onPress={() => {\n holding.current = true;\n setPinned(true);\n }}\n onPointerEnter={() => {\n cancelLeave();\n setTipHovered(true);\n }}\n onPointerLeave={leaveSoon}\n />,\n document.body,\n )\n : null,\n };\n}\n\nconst TipBody = forwardRef<\n HTMLDivElement,\n {\n at: Placement;\n text: string;\n onPress: () => void;\n onPointerEnter: () => void;\n onPointerLeave: () => void;\n }\n>(function TipBody({ at, text, onPress, onPointerEnter, onPointerLeave }, ref) {\n const position: CSSProperties = at.above\n ? { bottom: window.innerHeight - at.anchorTop }\n : { top: at.top };\n return (\n <Tooltip__Body\n ref={ref}\n aria-hidden=\"true\"\n data-tooltip-tip=\"\"\n data-above={at.above ? \"\" : undefined}\n onPointerEnter={onPointerEnter}\n onPointerLeave={onPointerLeave}\n // The tip is a React child of its anchor, so a press in it would otherwise reach the anchor's own handlers and close the tip, or click whatever the anchor sits in.\n onPointerDown={(event) => {\n event.stopPropagation();\n onPress();\n }}\n onPointerUp={(event) => event.stopPropagation()}\n onClick={(event) => event.stopPropagation()}\n style={\n {\n ...position,\n left: at.left,\n \"--tip-left\": `${at.left}px`,\n } as CSSProperties\n }\n >\n {text}\n </Tooltip__Body>\n );\n});\n\n/**\n * The props of {@link Tooltip}: the tip's text and the one element it\n * describes. Useful for explaining a control or figure to the operator without\n * taking room on the tile. Taken by {@link Tooltip}.\n *\n * @category Floating\n */\nexport interface TooltipProps {\n /** What the tip says. `null` or empty leaves the child untouched. */\n text: string | null | undefined;\n /** The one element the tip describes. It must forward its props to a DOM element. */\n children: ReactElement<Record<string, unknown>>;\n /**\n * Makes the child a tab stop, so the keyboard can reach a tip on an element\n * that is not a control (a readout, a badge). Leave it off on a button,\n * link or input, which is focusable already.\n */\n focusable?: boolean;\n /**\n * Whether the text is also given to assistive technology as the child's\n * `aria-description`. Defaults to `true`. Set `false` where the child already\n * says the same words in its own text, as a tab does whose tip only shows a\n * label that truncates, or where the child is hidden from assistive\n * technology.\n */\n announce?: boolean;\n /**\n * Which side of the child the tip stands on. Defaults to `\"below\"`. `\"above\"`\n * suits a child that sits over the content the tip would otherwise cover, such\n * as a tile's drag handle over its title; it falls back to below where the\n * child is too near the top of the screen to leave room.\n */\n placement?: \"below\" | \"above\";\n}\n\n/** The child's own handler, if it has one, then the tip's. */\nfunction joined<Args extends unknown[]>(\n own: unknown,\n ours: ((...args: Args) => void) | undefined,\n): (...args: Args) => void {\n return (...args) => {\n if (typeof own === \"function\") own(...args);\n ours?.(...args);\n };\n}\n\n/**\n * A tip for any element, in place of the browser's `title` attribute: themed,\n * opened by pointer or keyboard focus, dismissed by Escape, and announced as\n * the element's description. Useful for explaining a control or figure to the\n * operator without taking room on the tile. Used by the settings and alarms\n * buttons. The text is also set as the child's\n * `aria-description`, so a screen reader hears it without the tip being open\n * and no hidden text is added to the page. Where the child already carries the\n * same words in its `aria-label`, nothing is added.\n *\n * It adds no wrapper: the handlers are merged onto the child itself.\n *\n * @example\n * ```tsx\n * <Tooltip text=\"Saves the game, then flies the vessel you pick\">\n * <Button onClick={open}>Fly vessel</Button>\n * </Tooltip>\n * ```\n *\n * @category Floating\n */\nexport function Tooltip({\n text,\n children,\n focusable = false,\n announce = true,\n placement = \"below\",\n}: TooltipProps) {\n const { anchor, tip } = useTooltipAt(text, placement);\n // A fragment either way, so the child keeps its place in the tree, and its focus, when the text comes and goes.\n if (text == null || text === \"\") return <>{children}</>;\n\n const own = children.props;\n const label = own[\"aria-label\"];\n const named =\n !announce ||\n (typeof label === \"string\" && words(label).includes(words(text)));\n\n return (\n <>\n {cloneElement(children, {\n \"data-tooltip\": text,\n onPointerEnter: joined(own.onPointerEnter, anchor.onPointerEnter),\n onPointerLeave: joined(own.onPointerLeave, anchor.onPointerLeave),\n onPointerDown: joined(own.onPointerDown, anchor.onPointerDown),\n onPointerUp: joined(own.onPointerUp, anchor.onPointerUp),\n onFocus: joined(own.onFocus, anchor.onFocus),\n onBlur: joined(own.onBlur, anchor.onBlur),\n \"aria-description\": named ? own[\"aria-description\"] : text,\n tabIndex: focusable ? (own.tabIndex ?? 0) : own.tabIndex,\n })}\n {tip}\n {focusable && <TooltipFocusRing />}\n </>\n );\n}\n\n/** The kit focus ring for a non-control made focusable by {@link Tooltip}, in place of the browser default. */\nconst TooltipFocusRing = createGlobalStyle`\n [data-tooltip][tabindex]:not(button, a, input, select, textarea, summary):focus-visible {\n outline: 2px solid var(--color-focus);\n outline-offset: 2px;\n }\n`;\n\nconst Tooltip__Body = styled.div`\n position: fixed;\n z-index: var(--z-toast);\n margin-top: var(--offset-popover);\n max-width: min(18rem, calc(100vw - 2 * var(--offset-popover)));\n /* Pulled back inside the viewport when the anchor sits near its right edge. */\n translate: min(0px, calc(100vw - 100% - var(--offset-popover) - var(--tip-left, 0px)));\n padding: var(--inset-tooltip);\n background: var(--color-surface-raised);\n border: 1px solid var(--color-border-subtle);\n border-radius: var(--radius-floating);\n box-shadow: var(--shadow-popover-drop) rgba(0, 0, 0, 0.35);\n color: var(--color-text-primary);\n font-size: var(--font-size-caption);\n line-height: var(--line-height-body);\n letter-spacing: 0.02em;\n white-space: pre-line;\n user-select: text;\n cursor: text;\n\n &[data-above] {\n margin-top: 0;\n margin-bottom: var(--offset-popover);\n }\n`;\n","/** Set on the document element while a closing dialog hands focus back to the control that opened it. */\nexport const FOCUS_RESTORE_ATTRIBUTE = \"data-restoring-focus\";\n","import {\n type ComponentPropsWithoutRef,\n forwardRef,\n type ReactNode,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport styled from \"styled-components\";\n\n/**\n * Props for {@link FitLabelButton}. Any other `button` attribute passes\n * through; `children` is replaced by `label` and `icon`.\n * Useful for giving a control in a panel the operator can narrow a label and\n * an icon to fall back on. Used by {@link FitLabelButton}.\n *\n * @category Button\n */\nexport interface FitLabelButtonProps\n extends Omit<ComponentPropsWithoutRef<\"button\">, \"children\"> {\n /**\n * The button's word and its accessible name, in both states.\n */\n label: string;\n /** Shown in place of the label when the label does not fit. */\n icon: ReactNode;\n}\n\n/**\n * A `button` that shows its label while the label fits and its icon when it\n * does not. Useful for a control in a panel the operator can narrow. The switch\n * is measured against the button's own width and follows resizes. It is an\n * unstyled native button (`type=\"button\"` by default), so it has no border,\n * fill or padding until you give it some: style it with\n * `styled(FitLabelButton)` or wrap it as the layout needs.\n *\n * The accessible name is always `label`, carried in `aria-label` in both\n * states. Put anything explaining a disabled state in `title`, since it is the\n * only explanation left once the word is gone.\n *\n * @example\n * ```tsx\n * import { FitLabelButton, SettingsIcon } from \"@ksp-gonogo/ui-kit\";\n *\n * function SettingsButton(props: { onOpen: () => void }) {\n * return <FitLabelButton label=\"Settings\" icon={<SettingsIcon />} onClick={props.onOpen} />;\n * }\n * ```\n *\n * @category Button\n */\nexport const FitLabelButton = forwardRef<\n HTMLButtonElement,\n FitLabelButtonProps\n>(function FitLabelButton({ label, icon, type, ...rest }, ref) {\n return (\n <button ref={ref} type={type ?? \"button\"} aria-label={label} {...rest}>\n <FitLabel label={label} icon={icon} />\n </button>\n );\n});\n\n/**\n * The label-or-icon content of a {@link FitLabelButton}, for another control\n * that draws its own button and wants the same collapse. Used by\n * {@link FitLabelButton} and {@link Button}. It measures its parent's\n * content box, so the parent must be able to shrink below the label\n * (`min-width: 0`). Both states are `aria-hidden`: the parent carries the name.\n * Kit-internal, not on the barrel.\n */\nexport function FitLabel({ label, icon }: { label: string; icon: ReactNode }) {\n const contentRef = useRef<HTMLSpanElement | null>(null);\n const ghostRef = useRef<HTMLSpanElement | null>(null);\n const [fits, setFits] = useState(true);\n\n useLayoutEffect(() => {\n const content = contentRef.current;\n const ghost = ghostRef.current;\n if (!content || !ghost) return;\n const measure = () => {\n // The content span's clientWidth is the button's content box, padding excluded.\n setFits(ghost.scrollWidth <= content.clientWidth);\n };\n measure();\n if (typeof ResizeObserver === \"undefined\") return;\n const observer = new ResizeObserver(measure);\n observer.observe(content);\n observer.observe(ghost);\n return () => observer.disconnect();\n }, []);\n\n return (\n <FitLabelButton__Content ref={contentRef}>\n <FitLabelButton__Ghost ref={ghostRef} aria-hidden=\"true\">\n {label}\n </FitLabelButton__Ghost>\n {fits ? (\n <FitLabelButton__Label aria-hidden=\"true\">\n {label}\n </FitLabelButton__Label>\n ) : (\n <FitLabelButton__Icon aria-hidden=\"true\" data-fit-label-icon=\"\">\n {icon}\n </FitLabelButton__Icon>\n )}\n </FitLabelButton__Content>\n );\n}\n\nconst FitLabelButton__Content = styled.span`\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n /* Shrinks to what the parent allows, so an overlong label is detected rather than overflowing its cell. */\n min-width: 0;\n width: 100%;\n`;\n\n/** Measured, never seen, never read out. */\nconst FitLabelButton__Ghost = styled.span`\n position: absolute;\n left: 0;\n top: 0;\n visibility: hidden;\n pointer-events: none;\n white-space: nowrap;\n`;\n\nconst FitLabelButton__Label = styled.span`\n /* nowrap, so a label that does not fit overflows and the measurement stays honest. */\n white-space: nowrap;\n`;\n\nconst FitLabelButton__Icon = styled.span`\n display: inline-flex;\n align-items: center;\n justify-content: center;\n`;\n","/**\n * Merges classes into a single string\n *\n * @param {array} classes\n * @returns {string} A string of classes\n */\nexport const mergeClasses = <ClassType = string | undefined | null>(...classes: ClassType[]) =>\n classes\n .filter((className, index, array) => {\n return (\n Boolean(className) &&\n (className as string).trim() !== '' &&\n array.indexOf(className) === index\n );\n })\n .join(' ')\n .trim();\n","/**\n * Converts string to kebab case\n *\n * @param {string} string\n * @returns {string} A kebabized string\n */\nexport const toKebabCase = (string: string) =>\n string.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();\n","/**\n * Converts string to camel case\n *\n * @param {string} string\n * @returns {string} A camelized string\n */\nexport const toCamelCase = <T extends string>(string: T) =>\n string.replace(/^([A-Z])|[\\s-_]+(\\w)/g, (match, p1, p2) =>\n p2 ? p2.toUpperCase() : p1.toLowerCase(),\n );\n","import { CamelToPascal } from '../utility-types';\nimport { toCamelCase } from './toCamelCase';\n\n/**\n * Converts string to pascal case\n *\n * @param {string} string\n * @returns {string} A pascalized string\n */\nexport const toPascalCase = <T extends string>(string: T): CamelToPascal<T> => {\n const camelCase = toCamelCase(string);\n\n return (camelCase.charAt(0).toUpperCase() + camelCase.slice(1)) as CamelToPascal<T>;\n};\n","export default {\n xmlns: 'http://www.w3.org/2000/svg',\n width: 24,\n height: 24,\n viewBox: '0 0 24 24',\n fill: 'none',\n stroke: 'currentColor',\n strokeWidth: 2,\n strokeLinecap: 'round',\n strokeLinejoin: 'round',\n};\n","/**\n * Check if a component has an accessibility prop\n *\n * @param {object} props\n * @returns {boolean} Whether the component has an accessibility prop\n */\nexport const hasA11yProp = (props: Record<string, any>) => {\n for (const prop in props) {\n if (prop.startsWith('aria-') || prop === 'role' || prop === 'title') {\n return true;\n }\n }\n\n return false;\n};\n","'use client';\n\nimport { createContext, createElement, type ReactNode, useContext, useMemo } from 'react';\nimport { LucideProps } from './types';\n\ntype LucideConfig = {\n size: number;\n color: string;\n strokeWidth: number;\n absoluteStrokeWidth: boolean;\n className: string;\n};\n\nconst LucideContext = createContext<LucideProps>({});\n\ntype LucideProviderProps = {\n children: ReactNode;\n} & Partial<LucideConfig>;\n\nexport function LucideProvider({\n children,\n size,\n color,\n strokeWidth,\n absoluteStrokeWidth,\n className,\n}: LucideProviderProps) {\n const value = useMemo(\n () => ({\n size,\n color,\n strokeWidth,\n absoluteStrokeWidth,\n className,\n }),\n [size, color, strokeWidth, absoluteStrokeWidth, className],\n );\n\n return createElement(LucideContext.Provider, { value }, children);\n}\n\nexport const useLucideContext = () => useContext(LucideContext);\n","'use client';\n\nimport { createElement, forwardRef } from 'react';\nimport defaultAttributes from './defaultAttributes';\nimport { IconNode, LucideProps } from './types';\nimport { mergeClasses, hasA11yProp } from '@lucide/shared';\nimport { useLucideContext } from './context';\n\ninterface IconComponentProps extends LucideProps {\n iconNode: IconNode;\n}\n\n/**\n * Lucide icon component\n *\n * @component Icon\n * @param {object} props\n * @param {string} props.color - The color of the icon\n * @param {number} props.size - The size of the icon\n * @param {number} props.strokeWidth - The stroke width of the icon\n * @param {boolean} props.absoluteStrokeWidth - Whether to use absolute stroke width\n * @param {string} props.className - The class name of the icon\n * @param {IconNode} props.children - The children of the icon\n * @param {IconNode} props.iconNode - The icon node of the icon\n *\n * @returns {ForwardRefExoticComponent} LucideIcon\n */\nconst Icon = forwardRef<SVGSVGElement, IconComponentProps>(\n (\n { color, size, strokeWidth, absoluteStrokeWidth, className = '', children, iconNode, ...rest },\n ref,\n ) => {\n const {\n size: contextSize = 24,\n strokeWidth: contextStrokeWidth = 2,\n absoluteStrokeWidth: contextAbsoluteStrokeWidth = false,\n color: contextColor = 'currentColor',\n className: contextClass = '',\n } = useLucideContext() ?? {};\n\n const calculatedStrokeWidth =\n absoluteStrokeWidth ?? contextAbsoluteStrokeWidth\n ? (Number(strokeWidth ?? contextStrokeWidth) * 24) / Number(size ?? contextSize)\n : strokeWidth ?? contextStrokeWidth;\n\n return createElement(\n 'svg',\n {\n ref,\n ...defaultAttributes,\n width: size ?? contextSize ?? defaultAttributes.width,\n height: size ?? contextSize ?? defaultAttributes.height,\n stroke: color ?? contextColor,\n strokeWidth: calculatedStrokeWidth,\n className: mergeClasses('lucide', contextClass, className),\n ...(!children && !hasA11yProp(rest) && { 'aria-hidden': 'true' }),\n ...rest,\n },\n [\n ...iconNode.map(([tag, attrs]) => createElement(tag, attrs)),\n ...(Array.isArray(children) ? children : [children]),\n ],\n );\n },\n);\n\nexport default Icon;\n","import { createElement, forwardRef } from 'react';\nimport { mergeClasses, toKebabCase, toPascalCase } from '@lucide/shared';\nimport { IconNode, LucideProps } from './types';\nimport Icon from './Icon';\n\n/**\n * Create a Lucide icon component\n * @param {string} iconName\n * @param {array} iconNode\n * @returns {ForwardRefExoticComponent} LucideIcon\n */\nconst createLucideIcon = (iconName: string, iconNode: IconNode) => {\n const Component = forwardRef<SVGSVGElement, LucideProps>(({ className, ...props }, ref) =>\n createElement(Icon, {\n ref,\n iconNode,\n className: mergeClasses(\n `lucide-${toKebabCase(toPascalCase(iconName))}`,\n `lucide-${iconName}`,\n className,\n ),\n ...props,\n }),\n );\n\n Component.displayName = toPascalCase(iconName);\n\n return Component;\n};\n\nexport default createLucideIcon;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['path', { d: 'M12 17V3', key: '1cwfxf' }],\n ['path', { d: 'm6 11 6 6 6-6', key: '12ii2o' }],\n ['path', { d: 'M19 21H5', key: '150jfl' }],\n];\n\n/**\n * @component @name ArrowDownToLine\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/arrow-down-to-line\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst ArrowDownToLine = createLucideIcon('arrow-down-to-line', __iconNode);\n\nexport default ArrowDownToLine;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['path', { d: 'M12 5v14', key: 's699le' }],\n ['path', { d: 'm19 12-7 7-7-7', key: '1idqje' }],\n];\n\n/**\n * @component @name ArrowDown\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/arrow-down\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst ArrowDown = createLucideIcon('arrow-down', __iconNode);\n\nexport default ArrowDown;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['path', { d: 'M8 3 4 7l4 4', key: '9rb6wj' }],\n ['path', { d: 'M4 7h16', key: '6tx8e3' }],\n ['path', { d: 'm16 21 4-4-4-4', key: 'siv7j2' }],\n ['path', { d: 'M20 17H4', key: 'h6l3hr' }],\n];\n\n/**\n * @component @name ArrowLeftRight\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/arrow-left-right\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst ArrowLeftRight = createLucideIcon('arrow-left-right', __iconNode);\n\nexport default ArrowLeftRight;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['path', { d: 'm12 19-7-7 7-7', key: '1l729n' }],\n ['path', { d: 'M19 12H5', key: 'x3x0zl' }],\n];\n\n/**\n * @component @name ArrowLeft\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/arrow-left\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst ArrowLeft = createLucideIcon('arrow-left', __iconNode);\n\nexport default ArrowLeft;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['path', { d: 'M5 12h14', key: '1ays0h' }],\n ['path', { d: 'm12 5 7 7-7 7', key: 'xquz4c' }],\n];\n\n/**\n * @component @name ArrowRight\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/arrow-right\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst ArrowRight = createLucideIcon('arrow-right', __iconNode);\n\nexport default ArrowRight;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['path', { d: 'M5 3h14', key: '7usisc' }],\n ['path', { d: 'm18 13-6-6-6 6', key: '1kf1n9' }],\n ['path', { d: 'M12 7v14', key: '1akyts' }],\n];\n\n/**\n * @component @name ArrowUpToLine\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/arrow-up-to-line\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst ArrowUpToLine = createLucideIcon('arrow-up-to-line', __iconNode);\n\nexport default ArrowUpToLine;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['path', { d: 'm5 12 7-7 7 7', key: 'hav0vg' }],\n ['path', { d: 'M12 19V5', key: 'x0mq9r' }],\n];\n\n/**\n * @component @name ArrowUp\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/arrow-up\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst ArrowUp = createLucideIcon('arrow-up', __iconNode);\n\nexport default ArrowUp;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['path', { d: 'M10.268 21a2 2 0 0 0 3.464 0', key: 'vwvbt9' }],\n [\n 'path',\n {\n d: 'M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326',\n key: '11g9vi',\n },\n ],\n];\n\n/**\n * @component @name Bell\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/bell\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst Bell = createLucideIcon('bell', __iconNode);\n\nexport default Bell;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [['path', { d: 'M20 6 9 17l-5-5', key: '1gmf2c' }]];\n\n/**\n * @component @name Check\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/check\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst Check = createLucideIcon('check', __iconNode);\n\nexport default Check;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [['path', { d: 'm6 9 6 6 6-6', key: 'qrunsl' }]];\n\n/**\n * @component @name ChevronDown\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/chevron-down\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst ChevronDown = createLucideIcon('chevron-down', __iconNode);\n\nexport default ChevronDown;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [['path', { d: 'm15 18-6-6 6-6', key: '1wnfg3' }]];\n\n/**\n * @component @name ChevronLeft\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/chevron-left\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst ChevronLeft = createLucideIcon('chevron-left', __iconNode);\n\nexport default ChevronLeft;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [['path', { d: 'm9 18 6-6-6-6', key: 'mthhwq' }]];\n\n/**\n * @component @name ChevronRight\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/chevron-right\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst ChevronRight = createLucideIcon('chevron-right', __iconNode);\n\nexport default ChevronRight;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [['path', { d: 'm18 15-6-6-6 6', key: '153udz' }]];\n\n/**\n * @component @name ChevronUp\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/chevron-up\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst ChevronUp = createLucideIcon('chevron-up', __iconNode);\n\nexport default ChevronUp;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['rect', { width: '18', height: '18', x: '3', y: '3', rx: '2', key: 'afitv7' }],\n ['path', { d: 'M12 3v18', key: '108xh3' }],\n];\n\n/**\n * @component @name Columns2\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/columns-2\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst Columns2 = createLucideIcon('columns-2', __iconNode);\n\nexport default Columns2;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['rect', { width: '14', height: '8', x: '5', y: '2', rx: '2', key: 'wc9tft' }],\n ['rect', { width: '20', height: '8', x: '2', y: '14', rx: '2', key: 'w68u3i' }],\n ['path', { d: 'M6 18h2', key: 'rwmk9e' }],\n ['path', { d: 'M12 18h6', key: 'aqd8w3' }],\n];\n\n/**\n * @component @name Computer\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/computer\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst Computer = createLucideIcon('computer', __iconNode);\n\nexport default Computer;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['path', { d: 'M20 4v7a4 4 0 0 1-4 4H4', key: '6o5b7l' }],\n ['path', { d: 'm9 10-5 5 5 5', key: '1kshq7' }],\n];\n\n/**\n * @component @name CornerDownLeft\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/corner-down-left\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst CornerDownLeft = createLucideIcon('corner-down-left', __iconNode);\n\nexport default CornerDownLeft;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['ellipse', { cx: '12', cy: '5', rx: '9', ry: '3', key: 'msslwz' }],\n ['path', { d: 'M3 5V19A9 3 0 0 0 21 19V5', key: '1wlel7' }],\n ['path', { d: 'M3 12A9 3 0 0 0 21 12', key: 'mv7ke4' }],\n];\n\n/**\n * @component @name Database\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/database\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst Database = createLucideIcon('database', __iconNode);\n\nexport default Database;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n [\n 'path',\n {\n d: 'M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z',\n key: '1oefj6',\n },\n ],\n ['path', { d: 'M14 2v5a1 1 0 0 0 1 1h5', key: 'wfsgrz' }],\n ['path', { d: 'M10 9H8', key: 'b1mrlr' }],\n ['path', { d: 'M16 13H8', key: 't4e002' }],\n ['path', { d: 'M16 17H8', key: 'z1uh3a' }],\n];\n\n/**\n * @component @name FileText\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/file-text\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst FileText = createLucideIcon('file-text', __iconNode);\n\nexport default FileText;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['circle', { cx: '12', cy: '5', r: '1', key: 'gxeob9' }],\n ['circle', { cx: '19', cy: '5', r: '1', key: 'w8mnmm' }],\n ['circle', { cx: '5', cy: '5', r: '1', key: 'lttvr7' }],\n ['circle', { cx: '12', cy: '12', r: '1', key: '41hilf' }],\n ['circle', { cx: '19', cy: '12', r: '1', key: '1wjl8i' }],\n ['circle', { cx: '5', cy: '12', r: '1', key: '1pcz8c' }],\n ['circle', { cx: '12', cy: '19', r: '1', key: 'lyex9k' }],\n ['circle', { cx: '19', cy: '19', r: '1', key: 'shf9b7' }],\n ['circle', { cx: '5', cy: '19', r: '1', key: 'bfqh0e' }],\n];\n\n/**\n * @component @name Grip\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/grip\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst Grip = createLucideIcon('grip', __iconNode);\n\nexport default Grip;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n [\n 'path',\n {\n d: 'M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5',\n key: 'mvr1a0',\n },\n ],\n];\n\n/**\n * @component @name Heart\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/heart\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst Heart = createLucideIcon('heart', __iconNode);\n\nexport default Heart;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['path', { d: 'M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8', key: '1357e3' }],\n ['path', { d: 'M3 3v5h5', key: '1xhq8a' }],\n ['path', { d: 'M12 7v5l4 2', key: '1fdv2h' }],\n];\n\n/**\n * @component @name History\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/history\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst History = createLucideIcon('history', __iconNode);\n\nexport default History;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['path', { d: 'M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8', key: '5wwlr5' }],\n [\n 'path',\n {\n d: 'M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z',\n key: 'r6nss1',\n },\n ],\n];\n\n/**\n * @component @name House\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/house\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst House = createLucideIcon('house', __iconNode);\n\nexport default House;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['circle', { cx: '12', cy: '12', r: '10', key: '1mglay' }],\n ['path', { d: 'M12 16v-4', key: '1dtifu' }],\n ['path', { d: 'M12 8h.01', key: 'e9boi3' }],\n];\n\n/**\n * @component @name Info\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/info\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst Info = createLucideIcon('info', __iconNode);\n\nexport default Info;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n [\n 'path',\n {\n d: 'M21 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-2Z',\n key: 'jg2n2t',\n },\n ],\n ['path', { d: 'M6 15v-2', key: 'gd6mvg' }],\n ['path', { d: 'M12 15V9', key: '8c7uyn' }],\n ['circle', { cx: '12', cy: '6', r: '3', key: '1gm2ql' }],\n];\n\n/**\n * @component @name Joystick\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/joystick\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst Joystick = createLucideIcon('joystick', __iconNode);\n\nexport default Joystick;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n [\n 'path',\n {\n d: 'M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z',\n key: 'zw3jo',\n },\n ],\n [\n 'path',\n {\n d: 'M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12',\n key: '1wduqc',\n },\n ],\n [\n 'path',\n {\n d: 'M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17',\n key: 'kqbvx6',\n },\n ],\n];\n\n/**\n * @component @name Layers\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/layers\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst Layers = createLucideIcon('layers', __iconNode);\n\nexport default Layers;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['path', { d: 'M16.8 11.2c.8-.9 1.2-2 1.2-3.2a6 6 0 0 0-9.3-5', key: '1fkcox' }],\n ['path', { d: 'm2 2 20 20', key: '1ooewy' }],\n ['path', { d: 'M6.3 6.3a4.67 4.67 0 0 0 1.2 5.2c.7.7 1.3 1.5 1.5 2.5', key: '10m8kw' }],\n ['path', { d: 'M9 18h6', key: 'x1upvd' }],\n ['path', { d: 'M10 22h4', key: 'ceow96' }],\n];\n\n/**\n * @component @name LightbulbOff\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/lightbulb-off\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst LightbulbOff = createLucideIcon('lightbulb-off', __iconNode);\n\nexport default LightbulbOff;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n [\n 'path',\n {\n d: 'M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5',\n key: '1gvzjb',\n },\n ],\n ['path', { d: 'M9 18h6', key: 'x1upvd' }],\n ['path', { d: 'M10 22h4', key: 'ceow96' }],\n];\n\n/**\n * @component @name Lightbulb\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/lightbulb\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst Lightbulb = createLucideIcon('lightbulb', __iconNode);\n\nexport default Lightbulb;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['rect', { width: '18', height: '11', x: '3', y: '11', rx: '2', ry: '2', key: '1w4ew1' }],\n ['path', { d: 'M7 11V7a5 5 0 0 1 10 0v4', key: 'fwvmzm' }],\n];\n\n/**\n * @component @name Lock\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/lock\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst Lock = createLucideIcon('lock', __iconNode);\n\nexport default Lock;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['path', { d: 'M8 3H5a2 2 0 0 0-2 2v3', key: '1dcmit' }],\n ['path', { d: 'M21 8V5a2 2 0 0 0-2-2h-3', key: '1e4gt3' }],\n ['path', { d: 'M3 16v3a2 2 0 0 0 2 2h3', key: 'wsl5sc' }],\n ['path', { d: 'M16 21h3a2 2 0 0 0 2-2v-3', key: '18trek' }],\n];\n\n/**\n * @component @name Maximize\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/maximize\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst Maximize = createLucideIcon('maximize', __iconNode);\n\nexport default Maximize;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['path', { d: 'M4 5h16', key: '1tepv9' }],\n ['path', { d: 'M4 12h16', key: '1lakjw' }],\n ['path', { d: 'M4 19h16', key: '1djgab' }],\n];\n\n/**\n * @component @name Menu\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/menu\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst Menu = createLucideIcon('menu', __iconNode);\n\nexport default Menu;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['path', { d: 'M6 18h8', key: '1borvv' }],\n ['path', { d: 'M3 22h18', key: '8prr45' }],\n ['path', { d: 'M14 22a7 7 0 1 0 0-14h-1', key: '1jwaiy' }],\n ['path', { d: 'M9 14h2', key: '197e7h' }],\n ['path', { d: 'M9 12a2 2 0 0 1-2-2V6h6v4a2 2 0 0 1-2 2Z', key: '1bmzmy' }],\n ['path', { d: 'M12 6V3a1 1 0 0 0-1-1H9a1 1 0 0 0-1 1v3', key: '1drr47' }],\n];\n\n/**\n * @component @name Microscope\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/microscope\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst Microscope = createLucideIcon('microscope', __iconNode);\n\nexport default Microscope;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['path', { d: 'M8 3v3a2 2 0 0 1-2 2H3', key: 'hohbtr' }],\n ['path', { d: 'M21 8h-3a2 2 0 0 1-2-2V3', key: '5jw1f3' }],\n ['path', { d: 'M3 16h3a2 2 0 0 1 2 2v3', key: '198tvr' }],\n ['path', { d: 'M16 21v-3a2 2 0 0 1 2-2h3', key: 'ph8mxp' }],\n];\n\n/**\n * @component @name Minimize\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/minimize\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst Minimize = createLucideIcon('minimize', __iconNode);\n\nexport default Minimize;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['rect', { x: '14', y: '3', width: '5', height: '18', rx: '1', key: 'kaeet6' }],\n ['rect', { x: '5', y: '3', width: '5', height: '18', rx: '1', key: '1wsw3u' }],\n];\n\n/**\n * @component @name Pause\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/pause\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst Pause = createLucideIcon('pause', __iconNode);\n\nexport default Pause;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n [\n 'path',\n {\n d: 'M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z',\n key: '1a8usu',\n },\n ],\n ['path', { d: 'm15 5 4 4', key: '1mk7zo' }],\n];\n\n/**\n * @component @name Pencil\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/pencil\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst Pencil = createLucideIcon('pencil', __iconNode);\n\nexport default Pencil;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n [\n 'path',\n {\n d: 'M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z',\n key: '10ikf1',\n },\n ],\n];\n\n/**\n * @component @name Play\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/play\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst Play = createLucideIcon('play', __iconNode);\n\nexport default Play;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['path', { d: 'M5 12h14', key: '1ays0h' }],\n ['path', { d: 'M12 5v14', key: 's699le' }],\n];\n\n/**\n * @component @name Plus\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/plus\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst Plus = createLucideIcon('plus', __iconNode);\n\nexport default Plus;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['path', { d: 'M16.247 7.761a6 6 0 0 1 0 8.478', key: '1fwjs5' }],\n ['path', { d: 'M19.075 4.933a10 10 0 0 1 0 14.134', key: 'ehdyv1' }],\n ['path', { d: 'M4.925 19.067a10 10 0 0 1 0-14.134', key: '1q22gi' }],\n ['path', { d: 'M7.753 16.239a6 6 0 0 1 0-8.478', key: 'r2q7qm' }],\n ['circle', { cx: '12', cy: '12', r: '2', key: '1c9p78' }],\n];\n\n/**\n * @component @name Radio\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/radio\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst Radio = createLucideIcon('radio', __iconNode);\n\nexport default Radio;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['rect', { width: '20', height: '12', x: '2', y: '6', rx: '2', key: '9lu3g6' }],\n];\n\n/**\n * @component @name RectangleHorizontal\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/rectangle-horizontal\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst RectangleHorizontal = createLucideIcon('rectangle-horizontal', __iconNode);\n\nexport default RectangleHorizontal;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['rect', { width: '12', height: '20', x: '6', y: '2', rx: '2', key: '1oxtiu' }],\n];\n\n/**\n * @component @name RectangleVertical\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/rectangle-vertical\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst RectangleVertical = createLucideIcon('rectangle-vertical', __iconNode);\n\nexport default RectangleVertical;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['path', { d: 'M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8', key: '1357e3' }],\n ['path', { d: 'M3 3v5h5', key: '1xhq8a' }],\n];\n\n/**\n * @component @name RotateCcw\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/rotate-ccw\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst RotateCcw = createLucideIcon('rotate-ccw', __iconNode);\n\nexport default RotateCcw;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['path', { d: 'M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8', key: '1p45f6' }],\n ['path', { d: 'M21 3v5h-5', key: '1q7to0' }],\n];\n\n/**\n * @component @name RotateCw\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/rotate-cw\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst RotateCw = createLucideIcon('rotate-cw', __iconNode);\n\nexport default RotateCw;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['rect', { width: '18', height: '18', x: '3', y: '3', rx: '2', key: 'afitv7' }],\n ['path', { d: 'M3 12h18', key: '1i2n21' }],\n];\n\n/**\n * @component @name Rows2\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/rows-2\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst Rows2 = createLucideIcon('rows-2', __iconNode);\n\nexport default Rows2;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['path', { d: 'M4 10a7.31 7.31 0 0 0 10 10Z', key: '1fzpp3' }],\n ['path', { d: 'm9 15 3-3', key: '88sc13' }],\n ['path', { d: 'M17 13a6 6 0 0 0-6-6', key: '15cc6u' }],\n ['path', { d: 'M21 13A10 10 0 0 0 11 3', key: '11nf8s' }],\n];\n\n/**\n * @component @name SatelliteDish\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/satellite-dish\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst SatelliteDish = createLucideIcon('satellite-dish', __iconNode);\n\nexport default SatelliteDish;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n [\n 'path',\n {\n d: 'm13.5 6.5-3.148-3.148a1.205 1.205 0 0 0-1.704 0L6.352 5.648a1.205 1.205 0 0 0 0 1.704L9.5 10.5',\n key: 'dzhfyz',\n },\n ],\n ['path', { d: 'M16.5 7.5 19 5', key: '1ltcjm' }],\n [\n 'path',\n {\n d: 'm17.5 10.5 3.148 3.148a1.205 1.205 0 0 1 0 1.704l-2.296 2.296a1.205 1.205 0 0 1-1.704 0L13.5 14.5',\n key: 'nfoymv',\n },\n ],\n ['path', { d: 'M9 21a6 6 0 0 0-6-6', key: '1iajcf' }],\n [\n 'path',\n {\n d: 'M9.352 10.648a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l4.296-4.296a1.205 1.205 0 0 0 0-1.704l-2.296-2.296a1.205 1.205 0 0 0-1.704 0z',\n key: 'nv9zqy',\n },\n ],\n];\n\n/**\n * @component @name Satellite\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/satellite\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst Satellite = createLucideIcon('satellite', __iconNode);\n\nexport default Satellite;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n [\n 'path',\n {\n d: 'M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915',\n key: '1i5ecw',\n },\n ],\n ['circle', { cx: '12', cy: '12', r: '3', key: '1v7zrd' }],\n];\n\n/**\n * @component @name Settings\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/settings\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst Settings = createLucideIcon('settings', __iconNode);\n\nexport default Settings;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['rect', { width: '18', height: '18', x: '3', y: '3', rx: '2', key: 'afitv7' }],\n];\n\n/**\n * @component @name Square\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/square\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst Square = createLucideIcon('square', __iconNode);\n\nexport default Square;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n [\n 'path',\n {\n d: 'M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z',\n key: 'r04s7s',\n },\n ],\n];\n\n/**\n * @component @name Star\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/star\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst Star = createLucideIcon('star', __iconNode);\n\nexport default Star;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['path', { d: 'M9 14 4 9l5-5', key: '102s5s' }],\n ['path', { d: 'M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11', key: 'f3b9sd' }],\n];\n\n/**\n * @component @name Undo2\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/undo-2\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst Undo2 = createLucideIcon('undo-2', __iconNode);\n\nexport default Undo2;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n [\n 'path',\n {\n d: 'M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z',\n key: 'uqj9uw',\n },\n ],\n ['path', { d: 'M16 9a5 5 0 0 1 0 6', key: '1q6k2b' }],\n ['path', { d: 'M19.364 18.364a9 9 0 0 0 0-12.728', key: 'ijwkga' }],\n];\n\n/**\n * @component @name Volume2\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/volume-2\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst Volume2 = createLucideIcon('volume-2', __iconNode);\n\nexport default Volume2;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n [\n 'path',\n {\n d: 'M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z',\n key: 'uqj9uw',\n },\n ],\n ['line', { x1: '22', x2: '16', y1: '9', y2: '15', key: '1ewh16' }],\n ['line', { x1: '16', x2: '22', y1: '9', y2: '15', key: '5ykzw1' }],\n];\n\n/**\n * @component @name VolumeX\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/volume-x\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst VolumeX = createLucideIcon('volume-x', __iconNode);\n\nexport default VolumeX;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n [\n 'path',\n {\n d: 'M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z',\n key: '1ngwbx',\n },\n ],\n];\n\n/**\n * @component @name Wrench\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/wrench\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst Wrench = createLucideIcon('wrench', __iconNode);\n\nexport default Wrench;\n","import createLucideIcon from '../createLucideIcon';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [\n ['path', { d: 'M18 6 6 18', key: '1bl5f8' }],\n ['path', { d: 'm6 6 12 12', key: 'd8bk6v' }],\n];\n\n/**\n * @component @name X\n * @description Lucide SVG icon component, renders SVG Element with children.\n *\n * @preview  - https://lucide.dev/icons/x\n * @see https://lucide.dev/guide/packages/lucide-react - Documentation\n *\n * @param {Object} props - Lucide icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst X = createLucideIcon('x', __iconNode);\n\nexport default X;\n","import {\n ArrowDown,\n ArrowDownToLine,\n ArrowLeft,\n ArrowLeftRight,\n ArrowRight,\n ArrowUp,\n ArrowUpToLine,\n Bell,\n Check,\n ChevronDown,\n ChevronLeft,\n ChevronRight,\n ChevronUp,\n Columns2,\n Computer,\n CornerDownLeft,\n createLucideIcon,\n Database,\n FileText,\n Grip,\n Heart,\n History,\n Home,\n Info,\n Joystick,\n Layers,\n Lightbulb,\n LightbulbOff,\n Lock,\n type LucideProps,\n Maximize,\n Menu,\n Microscope,\n Minimize,\n Pause,\n Pencil,\n Play,\n Plus,\n Radio,\n RectangleHorizontal,\n RectangleVertical,\n RotateCcw,\n RotateCw,\n Rows2,\n Satellite,\n SatelliteDish,\n Settings,\n Square,\n Star,\n Undo2,\n Volume2,\n VolumeX,\n Wrench,\n X,\n} from \"lucide-react\";\nimport { forwardRef } from \"react\";\n\n/**\n * Props for every icon in the kit: the lucide-react SVG props plus `label`.\n * Useful for sizing, colouring and naming an icon so the operator can tell what\n * a control does at a glance. Taken by every icon in the kit, such as\n * {@link PlusIcon}.\n *\n * `size` defaults to the standalone icon size token, which grows a step on a\n * coarse pointer; pass a number (pixels) or any CSS length to override it.\n * `strokeWidth` defaults to 1.8 (2.4 on {@link PlusIcon}). `color` sets the\n * stroke and defaults to `currentColor`, so an icon takes its text colour;\n * `fill` fills the shape. Any other SVG attribute passes through, and the ref\n * reaches the `svg` element.\n *\n * @category Icons\n * @categoryDescription Icons\n * The icon set: each icon takes its text colour and the control size unless\n * told otherwise, and is hidden from assistive technology unless it is given a\n * label.\n */\nexport interface IconProps extends LucideProps {\n /**\n * The icon's accessible name. With one, the icon renders as `role=\"img\"`\n * named by it; without one it is decorative and hidden from assistive\n * technology, so the control it sits in must carry the name.\n */\n label?: string;\n}\n\nconst DEFAULT_SIZE = \"var(--icon-size-control)\";\n\n/**\n * The default size is `control`, the glyph inside a control the operator\n * presses; a glyph that is its own control (a Fab) is sized by that control.\n * An SVG `width`/`height` attribute does not take `var()`, so a string size\n * is written as CSS, where the token picks up the coarse-pointer step a bare\n * number cannot.\n */\nconst ICON_DEFAULTS: LucideProps = {\n strokeWidth: 1.8,\n \"aria-hidden\": true,\n};\n\nfunction makeIcon(\n Component: React.ComponentType<LucideProps>,\n extraDefaults?: LucideProps,\n) {\n const Wrapped = forwardRef<SVGSVGElement, IconProps>(\n ({ label, size = DEFAULT_SIZE, style, ...props }, ref) => {\n const sizing =\n typeof size === \"number\"\n ? { size, style }\n : { style: { width: size, height: size, ...style } };\n const naming = label\n ? { role: \"img\", \"aria-label\": label, \"aria-hidden\": false }\n : {};\n return (\n <Component\n {...ICON_DEFAULTS}\n {...extraDefaults}\n {...naming}\n {...props}\n {...sizing}\n ref={ref}\n />\n );\n },\n );\n Wrapped.displayName = Component.displayName ?? Component.name;\n return Wrapped;\n}\n\n/**\n * A three-by-three grid of dots. Useful for marking a handle the operator\n * drags to move something. Used by the dashboard's tile grab bar.\n *\n * @category Icons\n */\nexport const GripIcon = makeIcon(Grip);\n/**\n * A joystick on a base. Useful for marking the controls that map a game\n * controller or serial device to dashboard actions.\n *\n * @category Icons\n */\nexport const JoystickIcon = makeIcon(Joystick);\n/**\n * A clock face with a counter-clockwise arrow. Useful for marking past flights\n * or earlier messages. Used by the commcast message rows.\n *\n * @category Icons\n */\nexport const HistoryIcon = makeIcon(History);\n/**\n * A house. Useful for marking the operator's home command centre. Used by the\n * vantage control. It carries no name of its own, so give it a `label` or name\n * the control it sits in.\n *\n * @category Icons\n */\nexport const HomeIcon = makeIcon(Home);\n/**\n * A lowercase \"i\" in a circle. Useful for marking a control that opens further\n * detail for the operator. Used by the kerbal info popover and the commcast\n * message rows.\n *\n * @category Icons\n */\nexport const InfoIcon = makeIcon(Info);\n/**\n * A closed padlock. Useful for marking something this save has not unlocked\n * yet. Used by {@link LockMark}.\n *\n * @category Icons\n */\nexport const LockIcon = makeIcon(Lock);\n/**\n * A point with radio waves spreading on either side. Useful for showing the\n * operator a broadcast or a live connection. Used by the radio push-to-talk and\n * indicator controls and by the station link and connection buttons.\n *\n * @category Icons\n */\nexport const BroadcastIcon = makeIcon(Radio);\n/**\n * A speaker with sound waves. Useful for showing the operator that sound is on.\n * Used by the radio mute control. {@link MutedIcon} is its muted pair.\n *\n * @category Icons\n */\nexport const SpeakerIcon = makeIcon(Volume2);\n/**\n * A speaker crossed out. Useful for showing the operator that sound is muted.\n * Used by the radio mute control and the radio indicator. {@link SpeakerIcon}\n * is its audible pair.\n *\n * @category Icons\n */\nexport const MutedIcon = makeIcon(VolumeX);\n/**\n * A bell. Useful for marking an alarm or a notification. Used by the warp\n * control's next-alarm row, the alarms button and the contract objectives list.\n *\n * @category Icons\n */\nexport const BellIcon = makeIcon(Bell);\n/**\n * Stacked layers. Useful for marking the mission profiles the operator can\n * switch between. Used by the mission profiles button.\n *\n * @category Icons\n */\nexport const LayersIcon = makeIcon(Layers);\n/**\n * A cog. Useful for opening settings. Used by the settings button, the commcast\n * inbox and the dashboard widget gear menu.\n *\n * @category Icons\n */\nexport const SettingsIcon = makeIcon(Settings);\n/**\n * A satellite with solar panels. Useful for marking a satellite in a list the\n * operator reads.\n *\n * @category Icons\n */\nexport const SatelliteIcon = makeIcon(Satellite);\n/**\n * A dish antenna on a mast, pointing skyward. Useful for marking a ground\n * station or launch site on a map the operator reads. Used by the Ground Track\n * map's ground station markers.\n *\n * @category Icons\n */\nexport const GroundStationIcon = makeIcon(SatelliteDish);\n/**\n * Four corners pointing outward. Useful for the control that puts the dashboard\n * into fullscreen. Used by the fullscreen button.\n *\n * @category Icons\n */\nexport const FullscreenEnterIcon = makeIcon(Maximize);\n/**\n * Four corners pointing inward. Useful for the control that leaves fullscreen.\n * Used by the fullscreen button.\n *\n * @category Icons\n */\nexport const FullscreenExitIcon = makeIcon(Minimize);\n/**\n * A database cylinder. Useful for marking stored data.\n *\n * @category Icons\n */\nexport const DatabaseIcon = makeIcon(Database);\n/**\n * A desktop computer. Useful for marking a device or a processor.\n *\n * @category Icons\n */\nexport const ComputerIcon = makeIcon(Computer);\n/**\n * A page of text. Useful for marking diagnostics and logs.\n *\n * @category Icons\n */\nexport const DiagnosticsIcon = makeIcon(FileText);\n/**\n * A plus sign, drawn with a heavier 2.4 stroke than the other icons. Useful for\n * the control that adds an item. Used by the commcast inbox and thread views.\n *\n * @category Icons\n */\nexport const PlusIcon = makeIcon(Plus, { strokeWidth: 2.4 });\n\n/**\n * An X. Useful for the control that closes or dismisses something. Used by the\n * maneuver planner's node rows and armed triggers list, the research and development detail\n * panel and the pushed dashboard overlay.\n *\n * @category Icons\n */\nexport const CloseIcon = makeIcon(X);\n/**\n * A pencil. Useful for the control that edits an item. Used by the maneuver\n * planner's node rows.\n *\n * @category Icons\n */\nexport const PencilIcon = makeIcon(Pencil);\n/**\n * A check mark. Useful for confirming or marking something done. Used by the\n * space centre upgrade button and the research and development node facts.\n *\n * @category Icons\n */\nexport const CheckIcon = makeIcon(Check);\n/**\n * A five-pointed star. Useful for showing the operator a reputation amount.\n * Used by {@link Unit} as the reputation symbol.\n *\n * @category Icons\n */\nexport const StarIcon = makeIcon(Star);\n/**\n * A heart outline; pass `fill=\"currentColor\"` for a solid heart. Useful for\n * marking a favoured item.\n *\n * @category Icons\n */\nexport const HeartIcon = makeIcon(Heart);\n/**\n * Three horizontal lines. Useful for the control that opens a menu of\n * dashboard controls. Used by the dashboard menu button.\n *\n * @category Icons\n */\nexport const MenuIcon = makeIcon(Menu);\n/**\n * A microscope. Useful for showing the operator a science amount. Used by\n * {@link Unit} as the science symbol.\n *\n * @category Icons\n */\nexport const MicroscopeIcon = makeIcon(Microscope);\n/**\n * A right-pointing triangle. Useful for the control that starts or resumes\n * something. Used by the warp control and the alarm banner.\n *\n * @category Icons\n */\nexport const PlayIcon = makeIcon(Play);\n/**\n * Two vertical bars. Useful for the control that pauses something. Used by the\n * warp control.\n *\n * @category Icons\n */\nexport const PauseIcon = makeIcon(Pause);\n/**\n * A square. Useful for the control that stops something. Used by the alarm\n * banner.\n *\n * @category Icons\n */\nexport const StopIcon = makeIcon(Square);\n/**\n * An upward chevron. Useful for the control that collapses a section or steps\n * an item up. Used by the space centre upgrade button, the mobile dashboard and\n * the note rows.\n *\n * @category Icons\n */\nexport const ChevronUpIcon = makeIcon(ChevronUp);\n/**\n * A downward chevron. Useful for the control that expands a section or steps an\n * item down. Used by the vantage control, the mobile dashboard and the note\n * rows.\n *\n * @category Icons\n */\nexport const ChevronDownIcon = makeIcon(ChevronDown);\n/**\n * A left-pointing chevron. Useful for the control that goes back or to the\n * previous item.\n *\n * @category Icons\n */\nexport const ChevronLeftIcon = makeIcon(ChevronLeft);\n/**\n * A right-pointing chevron. Useful for the control that goes forward or to the\n * next item. Used by {@link Disclosure}.\n *\n * @category Icons\n */\nexport const ChevronRightIcon = makeIcon(ChevronRight);\n/**\n * A left-pointing arrow. Useful for the control that returns to the previous\n * view. Used by the commcast back button.\n *\n * @category Icons\n */\nexport const ArrowLeftIcon = makeIcon(ArrowLeft);\n/**\n * A two-way arrow. Useful for a control that moves something between two\n * places. Used by the fuel widget's transfer control and the crew move control.\n *\n * @category Icons\n */\nexport const ArrowLeftRightIcon = makeIcon(ArrowLeftRight);\n/**\n * An upward arrow. Useful for marking a rise or an upward direction.\n *\n * @category Icons\n */\nexport const ArrowUpIcon = makeIcon(ArrowUp);\n/**\n * A right-pointing arrow. Useful for marking a step from one state to the next.\n * Used by the maneuver planner's armed triggers list and the alarm banner.\n *\n * @category Icons\n */\nexport const ArrowRightIcon = makeIcon(ArrowRight);\n/**\n * A downward arrow. Useful for marking a fall or a downward direction.\n *\n * @category Icons\n */\nexport const ArrowDownIcon = makeIcon(ArrowDown);\n/**\n * An upward arrow meeting a line. Useful for the control that pushes a widget\n * up to another screen. Used by the dashboard widget controls.\n *\n * @category Icons\n */\nexport const PushUpIcon = makeIcon(ArrowUpToLine);\n/**\n * A downward arrow meeting a line, the opposite of {@link PushUpIcon}. Useful\n * for the control that recalls a widget that was pushed to another screen.\n * Used by the dashboard widget controls.\n *\n * @category Icons\n */\nexport const PullDownIcon = makeIcon(ArrowDownToLine);\n/**\n * A curved arrow turning back. Useful for the control that undoes a step, such\n * as the last layout change. Used by the layout history control.\n *\n * @category Icons\n */\nexport const RecallIcon = makeIcon(Undo2);\n/**\n * A circular arrow running clockwise. Useful for the control that turns a view\n * a step clockwise. Used by the Ship Map's view controls.\n *\n * @category Icons\n */\nexport const RotateClockwiseIcon = makeIcon(RotateCw);\n/**\n * A circular arrow running anticlockwise. Useful for the control that turns a\n * view a step anticlockwise. Used by the Ship Map's view controls.\n *\n * @category Icons\n */\nexport const RotateAnticlockwiseIcon = makeIcon(RotateCcw);\n/**\n * A rectangle split into two columns. Useful for the control that gives a tile\n * half the width. Used by the mobile dashboard's tile size controls.\n *\n * @category Icons\n */\nexport const HalfWidthIcon = makeIcon(Columns2);\n/**\n * A wide rectangle. Useful for the control that gives a tile the full width.\n * Used by the mobile dashboard's tile size controls.\n *\n * @category Icons\n */\nexport const FullWidthIcon = makeIcon(RectangleHorizontal);\n/**\n * A rectangle split into two rows. Useful for the control that gives a tile\n * half the height. Used by the mobile dashboard's tile size controls.\n *\n * @category Icons\n */\nexport const HalfHeightIcon = makeIcon(Rows2);\n/**\n * A tall rectangle. Useful for the control that gives a tile the full height.\n * Used by the mobile dashboard's tile size controls.\n *\n * @category Icons\n */\nexport const FullHeightIcon = makeIcon(RectangleVertical);\n/**\n * A return arrow (the symbol on the Enter key). Useful for the control that\n * commits what the operator composed locally, such as a console line or a\n * staged command. Used by {@link ComposerBar}. Use a different icon for\n * anything that fires on its own.\n *\n * Unnamed, it is decorative, so name the action on the control (for example\n * `sendLabel` on {@link ComposerBar}).\n *\n * @category Icons\n */\nexport const SendIcon = makeIcon(CornerDownLeft);\nconst SpaceHelmet = createLucideIcon(\"space-helmet\", [\n [\n \"path\",\n {\n d: \"M4 11a8 8 0 0 1 16 0v3a5 5 0 0 1-5 5H9a5 5 0 0 1-5-5z\",\n key: \"shell\",\n },\n ],\n [\n \"path\",\n { d: \"M10.5 8h3a3.5 3.5 0 0 1 0 7h-3a3.5 3.5 0 0 1 0-7z\", key: \"visor\" },\n ],\n [\"path\", { d: \"M8 19v2h8v-2\", key: \"neck\" }],\n]);\n\nconst SpaceHelmetVisorUp = createLucideIcon(\"space-helmet-visor-up\", [\n [\n \"path\",\n {\n d: \"M4 11a8 8 0 0 1 16 0v3a5 5 0 0 1-5 5H9a5 5 0 0 1-5-5z\",\n key: \"shell\",\n },\n ],\n [\"path\", { d: \"M8 7.5C9.5 5 14.5 5 16 7.5\", key: \"visor\" }],\n [\n \"circle\",\n { cx: \"12\", cy: \"12.5\", r: \"2\", fill: \"currentColor\", key: \"face\" },\n ],\n [\"path\", { d: \"M8 19v2h8v-2\", key: \"neck\" }],\n]);\n\n/**\n * A space helmet: a round shell with a round visor and a neck ring. Useful for\n * showing the operator whether a kerbal outside has a helmet on. Used by Crew\n * Status for each kerbal on EVA. Unnamed, it is decorative, so give it a\n * `label` that says the state.\n *\n * @category Icons\n */\nexport const HelmetIcon = makeIcon(SpaceHelmet);\n/**\n * A space helmet with its visor swung up, the kerbal's face showing under it.\n * Useful for showing the operator that a kerbal outside has the helmet on with\n * the visor raised. Used by Crew Status for each kerbal on EVA. Unnamed, it is\n * decorative, so give it a `label` that says the state. {@link HelmetIcon} is\n * its visor-down pair.\n *\n * @category Icons\n */\nexport const HelmetVisorUpIcon = makeIcon(SpaceHelmetVisorUp);\n/**\n * A wrench. Useful for showing the operator what a kerbal outside is carrying\n * in their kit. Used by Crew Status for each kerbal on EVA. Unnamed, it is\n * decorative, so give it a `label`.\n *\n * @category Icons\n */\nexport const KitIcon = makeIcon(Wrench);\n/**\n * A light bulb. Useful for the control that switches a kerbal's headlamp, and\n * for showing it on when drawn filled. Used by Crew Status for each kerbal on\n * EVA. Unnamed, it is decorative, so name the control it sits in.\n * {@link LampOffIcon} is its off pair.\n *\n * @category Icons\n */\nexport const LampIcon = makeIcon(Lightbulb);\n/**\n * A light bulb with a slash through it. Useful for showing a kerbal's headlamp\n * is off. Used by Crew Status for each kerbal on EVA. Unnamed, it is\n * decorative, so name the control it sits in. {@link LampIcon} is its on pair.\n *\n * @category Icons\n */\nexport const LampOffIcon = makeIcon(LightbulbOff);\n","/**\n * The one definition of how a figure that is not a reading of now is marked.\n * The DOM marks, the SVG tspans and the canvas painters all read it, so a\n * change of hue, shape or size happens here and nowhere else.\n */\n\n/**\n * Which mark a reckoned figure takes: `held` is the last observation kept past\n * its time, `modelled` is a figure a model carried to now. Useful for telling\n * the operator how a figure was arrived at. Taken by {@link ReckoningMarkSvg}\n * and {@link paintReckoningMark}.\n *\n * @category Unit\n */\nexport type ReckoningKind = \"held\" | \"modelled\";\n\n/**\n * What a figure is, for the purpose of marking it: `current` is a reading of\n * now, and the other two are the {@link ReckoningKind}s. Useful for choosing the\n * mark that tells the operator how current a figure is. Taken by\n * {@link ReckoningMark} and {@link Unit}.\n *\n * @category Unit\n */\nexport type MarkKind = \"current\" | ReckoningKind;\n\n/**\n * The stroke of a hollow mark, the form a mark takes for a figure that is of\n * something other than what its label names (`elsewhere`). Useful for drawing\n * the hollow marks the operator sees on such a figure. Used by\n * {@link ReckoningMark}.\n *\n * @category Unit\n */\nexport const HOLLOW_MARK_STROKE = \"max(0.075em, 1.25px)\";\n\n/**\n * The shape, hue and size of the mark for each kind. Useful for drawing the\n * marks that tell the operator a figure is held or modelled the same way in\n * every face. Used by {@link ReckoningMark} and {@link ReckoningMarkSvg}.\n *\n * `held` is a square in the warning hue; `modelled` is a triangle, point up, in\n * the modelled hue and about a pixel larger, so the two weigh alike at small\n * sizes.\n *\n * Each also has a hollow form, drawn where the figure is `elsewhere`: of\n * something other than what its label names. Hollow says that and nothing\n * else; the shape and the hue go on saying how current the figure is. A hollow\n * mark is drawn larger than its filled twin, at `hollowDomSize`. `current` has\n * only the hollow form, a ring: a current figure of the thing its label names\n * carries no mark at all.\n *\n * @category Unit\n */\nexport const RECKONING_MARK = {\n /** A reading of now: carries no mark of its own, only the hollow ring. */\n current: {\n /** The mark's shape, by name. */\n shape: \"ring\",\n /** The same shape as one text character, where the mark is drawn as text. */\n glyph: \"○\",\n /** The hue, as a CSS `var()` of the theme token. */\n color: \"var(--color-elsewhere-mark)\",\n /** The theme token's name, for a canvas painter that resolves it itself. */\n cssVar: \"--color-elsewhere-mark\",\n /** The hue to use where the token cannot be read. */\n fallback: \"rgb(170 156 255)\",\n /** The hollow form's size in the DOM, drawn for a figure of something other than what its label names. */\n hollowDomSize: \"max(calc(0.3em + 2px), 6px)\",\n /** The mark's radius on a canvas, in canvas pixels at 1x. */\n canvasRadius: 5,\n },\n /** The last observation kept past its time: a square in the warning hue. */\n held: {\n /** The mark's shape, by name. */\n shape: \"square\",\n /** The same shape as one text character, where the mark is drawn as text. */\n glyph: \"■\",\n /** The hue, as a CSS `var()` of the theme token. */\n color: \"var(--color-warn-mark)\",\n /** The theme token's name, for a canvas painter that resolves it itself. */\n cssVar: \"--color-warn-mark\",\n /** The hue to use where the token cannot be read. */\n fallback: \"rgb(217 161 59)\",\n /** The filled mark's side in the DOM, as a CSS length that follows the text size. */\n domSize: \"max(0.3em, 4px)\",\n /** The hollow form's size in the DOM, drawn for a figure of something other than what its label names. */\n hollowDomSize: \"max(calc(0.3em + 2px), 6px)\",\n /** The mark's radius on a canvas, in canvas pixels at 1x. */\n canvasRadius: 4,\n },\n /** A figure a model carried to now: a triangle, point up, in the modelled hue. */\n modelled: {\n /** The mark's shape, by name. */\n shape: \"triangle\",\n /** The same shape as one text character, where the mark is drawn as text. */\n glyph: \"▲\",\n /** The hue, as a CSS `var()` of the theme token. */\n color: \"var(--color-modelled-mark)\",\n /** The theme token's name, for a canvas painter that resolves it itself. */\n cssVar: \"--color-modelled-mark\",\n /** The hue to use where the token cannot be read. */\n fallback: \"rgb(138 180 248)\",\n /** The filled mark's side in the DOM, as a CSS length that follows the text size. */\n domSize: \"max(calc(0.3em + 1px), 5px)\",\n /** The hollow form's size in the DOM, drawn for a figure of something other than what its label names. */\n hollowDomSize: \"max(calc(0.3em + 3px), 7px)\",\n /** The mark's radius on a canvas, in canvas pixels at 1x. */\n canvasRadius: 5,\n },\n} as const;\n","/**\n * The mark a figure carries when it is no longer a reading of now. A held\n * figure takes a square at superscript height in the warning hue the panel badge is\n * painted from; a figure a model carried takes a blue triangle of the same\n * footprint, about a pixel larger so the two weigh alike. One spec, in\n * {@link RECKONING_MARK}, drives these DOM marks and the SVG and canvas faces.\n */\nimport type { HTMLAttributes, ReactNode } from \"react\";\nimport styled, { css } from \"styled-components\";\nimport {\n HOLLOW_MARK_STROKE,\n type MarkKind,\n RECKONING_MARK,\n} from \"./reckoningMarkSpec\";\nimport { useTooltip } from \"./Tooltip\";\nimport { VisuallyHidden } from \"./VisuallyHidden\";\n\nconst MARK_SIZE = RECKONING_MARK.held.domSize;\nconst MODELLED_MARK_SIZE = RECKONING_MARK.modelled.domSize;\n\n/**\n * The room a host holds at the end of its figure for the held square and the\n * gap before it. Useful for keeping a held figure's mark inside its own box\n * whatever clips or wraps around it. Used by `reservesMark`. It is a generated\n * box with no content: it adds nothing to the host's accessible name and\n * nothing to the clipboard.\n */\nexport const reservesHeldMark = css`\n &::after {\n content: \"\";\n display: inline-block;\n width: calc(${MARK_SIZE} + 0.14em);\n }\n`;\n\n/**\n * The room a host holds at the end of its figure for the modelled triangle,\n * whose box is slightly larger than the held square's. Useful for keeping a\n * modelled figure's mark inside its own box whatever clips or wraps around it.\n * Used by `reservesMark`.\n */\nexport const reservesModelledTriangle = css`\n &::after {\n content: \"\";\n display: inline-block;\n width: calc(${MODELLED_MARK_SIZE} + 0.14em);\n }\n`;\n\n/** The room a hollow mark of a kind needs: it is drawn larger than the filled one. */\nfunction reservesHollow(kind: MarkKind) {\n return css`\n &::after {\n content: \"\";\n display: inline-block;\n width: calc(${RECKONING_MARK[kind].hollowDomSize} + 0.14em);\n }\n `;\n}\n\n/**\n * The room a host holds at the end of its figure for the mark of a kind, hollow\n * where the figure is `elsewhere`. A current figure that is not `elsewhere`\n * carries no mark and reserves nothing. Useful for keeping the mark that tells\n * the operator a figure is held or modelled inside the figure's own box. Used\n * by {@link Unit}.\n */\nexport function reservesMark(kind: MarkKind, elsewhere = false) {\n if (elsewhere) return reservesHollow(kind);\n if (kind === \"current\") return null;\n return kind === \"modelled\" ? reservesModelledTriangle : reservesHeldMark;\n}\n\n/**\n * The square that marks a figure as held. It is absolutely positioned in the\n * room its host reserves at the end of the figure, at superscript height, so\n * the square is inside the host's box and the line never grows. Useful for\n * showing the operator that a figure has stopped updating. Used by\n * {@link ReckoningMark}.\n *\n * It needs a positioned container that reserves that room: use `HeldHost`, or\n * give a container of your own `position: relative`, `nowrap` and\n * `reservesHeldMark`.\n *\n * @category Unit\n */\nexport const HeldMark = styled.span`\n position: absolute;\n right: 0;\n top: 0;\n width: ${MARK_SIZE};\n height: ${MARK_SIZE};\n background: ${RECKONING_MARK.held.color};\n`;\n\n/**\n * The mark for a figure a model carried forward: a triangle, point up, in the\n * modelled hue, hung off its host as `HeldMark` is. Useful for showing the\n * operator that a figure is an estimate rather than a reading. Used by\n * {@link ReckoningMark}.\n *\n * @category Unit\n */\nexport const ModelledTriangle = styled.span`\n position: absolute;\n right: 0;\n top: 0;\n width: ${MODELLED_MARK_SIZE};\n height: ${MODELLED_MARK_SIZE};\n clip-path: polygon(50% 0, 100% 100%, 0 100%);\n background: ${RECKONING_MARK.modelled.color};\n`;\n\nconst hollowBox = (kind: MarkKind) => css`\n position: absolute;\n right: 0;\n top: 0;\n width: ${RECKONING_MARK[kind].hollowDomSize};\n height: ${RECKONING_MARK[kind].hollowDomSize};\n`;\n\n/** The ring: a figure measured now, of something other than its label names. */\nconst ElsewhereRing = styled.span`\n ${hollowBox(\"current\")}\n border: ${HOLLOW_MARK_STROKE} solid ${RECKONING_MARK.current.color};\n border-radius: var(--radius-circle);\n`;\n\n/** The held square emptied: a held figure of something other than its label names. */\nconst HollowSquare = styled.span`\n ${hollowBox(\"held\")}\n border: ${HOLLOW_MARK_STROKE} solid ${RECKONING_MARK.held.color};\n`;\n\n/** The modelled triangle emptied. The hole is cut from the fill, since a clipped box has no border to draw. */\nconst HollowTriangle = styled.span`\n ${hollowBox(\"modelled\")}\n --stroke: ${HOLLOW_MARK_STROKE};\n background: ${RECKONING_MARK.modelled.color};\n clip-path: polygon(\n 50% 0,\n 100% 100%,\n 0 100%,\n 50% 0,\n 50% calc(var(--stroke) * 2.4),\n calc(var(--stroke) * 1.9) calc(100% - var(--stroke)),\n calc(100% - var(--stroke) * 1.9) calc(100% - var(--stroke)),\n 50% calc(var(--stroke) * 2.4)\n );\n`;\n\nconst HOLLOW = {\n current: ElsewhereRing,\n held: HollowSquare,\n modelled: HollowTriangle,\n} as const;\n\n/**\n * The DOM mark for a kind, silent to a screen reader: the caption beside it is\n * what is spoken. Useful for showing the operator that a figure is held or\n * modelled. Used by {@link Unit} and {@link HeldFigure}.\n *\n * `elsewhere` draws the kind's hollow form, for a figure that is of something\n * other than what its label names: a ring for a current figure, the square or\n * the triangle emptied for a held or modelled one. A current figure that is not\n * `elsewhere` has no mark, and this draws nothing.\n *\n * @category Unit\n */\nexport function ReckoningMark({\n kind,\n elsewhere = false,\n}: {\n kind: MarkKind;\n elsewhere?: boolean;\n}) {\n if (kind === \"current\" && !elsewhere) return null;\n const Mark = elsewhere\n ? HOLLOW[kind]\n : kind === \"modelled\"\n ? ModelledTriangle\n : HeldMark;\n return (\n <Mark\n aria-hidden=\"true\"\n data-held-mark=\"\"\n data-reckoning-mark={kind}\n data-elsewhere={elsewhere ? \"\" : undefined}\n />\n );\n}\n\n/**\n * A positioned inline box that holds a figure and the mark at its end, for a\n * component that renders bare text and so has no box of its own. Useful for\n * placing the mark that tells the operator a figure is held or modelled. Used\n * by {@link HeldFigure} and by the meter's value pair.\n *\n * It does not wrap, so the figure and its mark stay on one line.\n *\n * @category Unit\n */\nexport const HeldHost = styled.span<{\n $kind?: MarkKind;\n $elsewhere?: boolean;\n}>`\n position: relative;\n white-space: nowrap;\n ${({ $kind, $elsewhere }) => reservesMark($kind ?? \"held\", $elsewhere)}\n`;\n\n/**\n * The props of {@link HeldFigure}.\n * Useful for showing the operator that a figure is held or modelled. Used by\n * {@link HeldFigure}.\n *\n * @category Unit\n */\nexport interface HeldFigureProps extends HTMLAttributes<HTMLSpanElement> {\n /** What the mark means in words: spoken after the figure, and shown on hover. */\n caption: string | null;\n /** Which mark: a held figure takes the square, a figure a model carried the triangle. `current` is a reading of now, which is marked only when it is `elsewhere`. Defaults to `held`. */\n kind?: MarkKind;\n /** The figure is of something other than what its label names, so its mark is drawn hollow: a ring for a current figure, the square or triangle emptied otherwise. */\n elsewhere?: boolean;\n /** The figure the mark follows. */\n children: ReactNode;\n}\n\n/**\n * A figure marked held or modelled, or as being of something other than its\n * label names: the mark for its `kind` (hollow where `elsewhere`), the caption\n * spoken after the figure, and the same caption in the kit's hover tip. Useful\n * for showing the operator that a figure is held. Used by the comm\n * signal view and the target picker rows.\n *\n * @category Unit\n */\nexport function HeldFigure({\n caption,\n kind = \"held\",\n elsewhere = false,\n children,\n ...rest\n}: HeldFigureProps) {\n const { anchor, tip } = useTooltip(caption);\n return (\n <HeldHost $kind={kind} $elsewhere={elsewhere} {...rest} {...anchor}>\n {children}\n <ReckoningMark kind={kind} elsewhere={elsewhere} />\n {caption !== null && (\n <VisuallyHidden data-unit-currency=\"\">, {caption}</VisuallyHidden>\n )}\n {tip}\n </HeldHost>\n );\n}\n","import styled from \"styled-components\";\n\nconst ReservedText__Stack = styled.span`\n display: inline-grid;\n justify-items: center;\n`;\n\nconst ReservedText__Shown = styled.span`\n grid-area: 1 / 1;\n`;\n\n/* Pseudo-element text, so the reserved words hold their width without being read aloud or found as text. */\nconst ReservedText__Reserve = styled.span`\n grid-area: 1 / 1;\n visibility: hidden;\n\n &::before {\n content: attr(data-word);\n }\n`;\n\n/**\n * Props for {@link ReservedText}.\n *\n * @category Typography\n */\nexport interface ReservedTextProps {\n /** The text drawn. */\n shown: string;\n /** Every text the place can show, `shown` among them or not; the box is as wide as the widest. */\n reserve: readonly string[];\n}\n\n/**\n * A short piece of text drawn in a box as wide as the widest of the texts its\n * place can show, so the place keeps its size as the text changes. Useful for\n * a control whose word changes as the operator uses it, such as a toggle that\n * reads `SENT` while its command is on the way, so nothing beside it moves.\n * Used by the Action Group widget's toggle.\n *\n * Only `shown` is text a screen reader or a text query finds: the reserved\n * texts take up room and nothing else.\n *\n * @example\n * ```tsx\n * import { ReservedText, ToggleButton } from \"@ksp-gonogo/ui-kit\";\n *\n * function LightToggle(props: { on: boolean; sent: boolean; press: () => void }) {\n * const word = props.sent ? \"SENT\" : props.on ? \"ON\" : \"OFF\";\n * return (\n * <ToggleButton pressed={props.on} onClick={props.press} aria-label=\"Toggle lights\">\n * <ReservedText shown={word} reserve={[\"ON\", \"OFF\", \"SENT\"]} />\n * </ToggleButton>\n * );\n * }\n * ```\n *\n * @category Typography\n */\nexport function ReservedText({ shown, reserve }: Readonly<ReservedTextProps>) {\n return (\n <ReservedText__Stack>\n {[...new Set(reserve)].map((word) => (\n <ReservedText__Reserve key={word} data-word={word} aria-hidden=\"true\" />\n ))}\n <ReservedText__Shown>{shown}</ReservedText__Shown>\n </ReservedText__Stack>\n );\n}\n","import type { Tone } from \"@ksp-gonogo/sitrep-sdk\";\nimport { type ButtonHTMLAttributes, forwardRef, type ReactNode } from \"react\";\nimport styled, { css } from \"styled-components\";\nimport { Button__Body, filledLook, IconButton__Body } from \"./ButtonBody\";\nimport {\n buttonTipText,\n reasonedDisabled,\n swallowPress,\n withButtonTip,\n} from \"./buttonTip\";\nimport {\n CommandedButton,\n type CommandedButtonProps,\n CommandedIconButton,\n CommandedIconToggle,\n type CommandedToggleProps,\n isControl,\n} from \"./CommandButton/CommandedButton\";\nimport { focusRing } from \"./focusRing\";\nimport { HeldFigure } from \"./HeldMark\";\nimport { PlainButton } from \"./PlainButton\";\nimport type { ReckoningMarking } from \"./readingCurrency\";\nimport type { PredictedOutcome } from \"./SendStatus/predictedOutcome\";\nimport { TONE_MARK, TONE_ON_STATUS, TONE_STATUS, TONE_TEXT } from \"./tone\";\n\n/**\n * How much a button asks to be pressed: `default` is the ordinary raised\n * control, `primary` the one commit action of a group, filled in its tone,\n * `ghost` the quiet secondary one beside it, and `text` no chrome at all, for\n * words that are themselves the control (a name that renames on click): it\n * takes its colour and type from the text around it. An underlined action\n * that reads as part of a sentence is a {@link TextButton} instead. Set with\n * the `variant` prop of {@link Button}.\n * Useful for telling the operator which control in a group is the main action\n * and which are secondary.\n *\n * @category Button\n */\nexport type ButtonVariant = \"default\" | \"primary\" | \"ghost\" | \"text\";\n\n/**\n * The state a button's action puts things in. `nogo` is the destructive tone,\n * `warn` an action that needs attention; `neutral` has no state. Useful for\n * telling the operator how serious pressing a button is. Set with the `tone`\n * prop of {@link Button}.\n *\n * @category Button\n */\nexport type ButtonTone = Extract<Tone, \"neutral\" | \"go\" | \"warn\" | \"nogo\">;\n\n/**\n * `sm` for dense rows, `md` otherwise; both sizes keep the kit's one control\n * height, and only the type and padding change. Set with the `size` prop of\n * {@link Button}.\n * Useful for fitting a button into a dense row or a roomier form.\n *\n * @category Button\n */\nexport type ButtonSize = \"sm\" | \"md\";\n\n/**\n * The props of {@link Button}: those of a plain button, or, when `command` is\n * set, those of a button that sends it.\n * Useful for describing a control the operator presses.\n *\n * @category Button\n */\nexport type ButtonProps = PlainButtonProps | CommandedButtonProps;\n\n/**\n * A native button's attributes, plus how prominent it is, what its action\n * does, how large it is and, for a toggle, whether it is pressed. Taken by\n * {@link Button} when it has no `command`.\n *\n * @category Button\n */\nexport type PlainButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {\n /** Set `command` to make the button send a command; see {@link CommandedButtonProps}. */\n command?: undefined;\n /** How prominent the button is. Defaults to `default`. */\n variant?: ButtonVariant;\n /**\n * What pressing the button does, as a status colour: `nogo` for a destructive\n * action, `warn` for one that needs attention. Defaults to `go` for a primary\n * button and `neutral` otherwise.\n */\n tone?: ButtonTone;\n /** Defaults to `md`. */\n size?: ButtonSize;\n /**\n * Makes the button a toggle: sets `aria-pressed` and, while true, draws the\n * one pressed look, filled in the tone's status colour. A pressed button\n * with no state of its own reads as on, so a neutral one fills in go.\n */\n pressed?: boolean;\n /**\n * The predicted result of pressing, drawn as a dashed edge in the button's own\n * border so its size does not change: `held` in the go colour with dashes, and\n * `at-risk` in the warning colour with the same dashes. It is drawn apart from the\n * keyboard focus ring, so both show at once, and a disabled button keeps its\n * disabled look. The tooltip says what the prediction is.\n */\n predictedOutcome?: PredictedOutcome;\n /**\n * Why the button is disabled, shown as its tip. With `disabled`, the button\n * is `aria-disabled` rather than natively disabled, so it keeps keyboard\n * focus and the tip can be reached; pressing it does nothing. A disabled\n * button with no reason says nothing about why, so give one wherever the\n * reason is known.\n */\n disabledReason?: string;\n /**\n * Marks the state the button shows as held or modelled, for a toggle whose\n * state comes from an old or late reading. The button stays pressable: the\n * label takes the kit's held mark, and the mark's words (hand it\n * {@link derivedMarking}, with what the press does added) are spoken after\n * the label and shown as its tip, so nothing is drawn beside it.\n */\n marked?: ReckoningMarking | null;\n};\n\n/**\n * The kit's button: one family whose `variant` says how prominent it is and\n * whose `tone` says what its action does. Useful for any action the operator\n * takes on this screen, such as saving a form or dismissing a banner. Used by\n * the source offline banner and the command block. Write the label in sentence\n * case; uppercase belongs to headings and state tokens. It takes no alignment\n * of its own: where it sits in a row is the caller's layout. The ref reaches\n * the `button` element. Its `type` is `\"button\"` unless the caller passes\n * `\"submit\"`, so a press inside a form submits nothing by default.\n *\n * Its content is a centred flex row, so an icon beside the word centres on it\n * rather than sitting on the text baseline.\n *\n * Given a `command`, it sends that command and shows what became of the press.\n * Every command control draws the same seven states:\n *\n * - rest: the label, with a `confirmLabel` it arms first and sends on the\n * second press\n * - sent: \"SENT\" until the mod answers the press\n * - refused: the label becomes \"Refused\" (`refusedLabel`) and the reason is the\n * tip and the accessible name\n * - no reply: the label becomes \"No reply\" (`lostLabel`), because the game\n * decided nothing and the command may have run\n * - unavailable: the reason the caller gave in `unavailable`, dimmed with a\n * solid edge; a press sends nothing\n * - stream down: not connected to the mod, dimmed with a dotted edge; a press\n * sends nothing\n * - blocked: the game has said it will refuse the command, dimmed with a dashed\n * warning edge; a press sends nothing and shows why\n *\n * The three dimmed states differ by edge, and the reason is each one's tip and\n * accessible description, read after the control's own name. A toggle keeps its on and off word in every state and shows\n * a refusal or a missing reply as a warning edge instead. Reach the same states\n * from your own markup with {@link useCommandControl}.\n *\n * @example\n * ```tsx\n * import { Button, CheckIcon, Cluster } from \"@ksp-gonogo/ui-kit\";\n *\n * function SaveBar(props: { onCancel: () => void; onSave: () => void }) {\n * return (\n * <Cluster justify=\"end\">\n * <Button variant=\"ghost\" onClick={props.onCancel}>Cancel</Button>\n * <Button variant=\"primary\" onClick={props.onSave}>\n * <CheckIcon />\n * Save\n * </Button>\n * </Cluster>\n * );\n * }\n * ```\n *\n * @category Button\n * @categoryDescription Button\n * Buttons for things that happen on this screen: plain, icon and text buttons,\n * toggles, groups, and a button that fits its label to the space it has. A\n * button that sends a command to the game is a {@link Button}.\n *\n * A button that is a glyph alone, or whose `aria-label` says more than its words\n * do, shows that name as a tip on hover and keyboard focus; a button whose words\n * are the whole story shows none. A disabled button given a `disabledReason`\n * shows the reason.\n */\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(\n function Button(props, ref) {\n if (props.command !== undefined) return <CommandedButton {...props} />;\n return <PlainButton ref={ref} {...props} />;\n },\n);\n/**\n * A subtle, underlined link-style `button` for a tertiary action inside copy\n * (such as \"Clear all\" in a list row). Useful for an action that should read as\n * part of the sentence around it. Used by the maneuver node list and the ship\n * diagram. It renders a native `button` and takes every prop that element does.\n * For a paired Cancel and Confirm row, use a ghost {@link Button} beside a\n * primary one. For words that are themselves the control and should keep the\n * surrounding text's colour and type, use a {@link Button} with\n * `variant=\"text\"` instead.\n *\n * @category Button\n */\nexport const TextButton = styled.button`\n background: none;\n border: none;\n color: var(--color-text-muted);\n font-size: var(--font-size-compact);\n font-family: inherit;\n cursor: pointer;\n padding: 0;\n text-decoration: underline;\n transition: color var(--duration-fast);\n\n @media (hover: hover) {\n &:hover {\n color: var(--color-text-primary);\n }\n }\n ${focusRing}\n &:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n }\n`;\n\n/**\n * Props for {@link IconButton}. Any other `button` attribute passes through.\n * Useful for giving a control that is a glyph alone its accessible name and\n * its press handler. Used by {@link IconButton}.\n *\n * @category Button\n */\nexport type IconButtonProps =\n | PlainIconButtonProps\n | (Omit<CommandedButtonProps, \"children\" | \"aria-label\" | \"tone\"> & {\n /** The glyph. */\n children: ReactNode;\n /** The control's name, which is also its tip. */\n \"aria-label\": string;\n })\n | (Omit<CommandedToggleProps, \"children\" | \"aria-label\"> & {\n /** The glyph, shown as it is and replaced by the kit's send arrow while the press is unanswered. */\n children: ReactNode;\n /** The control's name, which is also its tip. */\n \"aria-label\": string;\n });\n\n/**\n * Props for {@link IconButton} with no command. Any other `button` attribute\n * passes through. Useful for giving a control that is a glyph alone its\n * accessible name and its press handler.\n *\n * @category Button\n */\nexport type PlainIconButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {\n /** Set `command` to make the button send a command; give it `state` too if the command sets a value. */\n command?: undefined;\n /** Makes the button a toggle: sets `aria-pressed` and, while true, draws the pressed look. */\n pressed?: boolean;\n /** Why the button is disabled, shown as its tip. As for {@link Button}. */\n disabledReason?: string;\n};\n\n/**\n * An icon-only `button`: the glyph alone at rest, with a fill and an edge\n * drawn around it under the pointer. Useful for compact controls whose meaning\n * an icon carries, such as closing a panel. Used by the\n * maneuver node rows and the connection settings. Give it an `aria-label`,\n * since the icon inside is decorative; the name is also its tip, so a glyph is\n * never unexplained. As a toggle, with `pressed`, it sets\n * `aria-pressed` and takes the filled pressed look while pressed. The ref\n * reaches the `button` element. Under a coarse pointer it grows to a 44px touch\n * target.\n *\n * @example\n * ```tsx\n * import { CloseIcon, IconButton } from \"@ksp-gonogo/ui-kit\";\n *\n * function CloseButton(props: { onClose: () => void }) {\n * return (\n * <IconButton aria-label=\"Close\" onClick={props.onClose}>\n * <CloseIcon />\n * </IconButton>\n * );\n * }\n * ```\n *\n * @category Button\n */\nexport const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(\n function IconButton(props, ref) {\n if (props.command !== undefined) {\n const { command } = props;\n const sets =\n \"kind\" in command && command.kind === \"value\"\n ? true\n : isControl(command) && command.toggleView !== null;\n if (sets) {\n const { children, ...toggle } = props as CommandedToggleProps & {\n children: ReactNode;\n };\n return <CommandedIconToggle {...toggle} icon={children} />;\n }\n return <CommandedIconButton {...(props as CommandedButtonProps)} />;\n }\n const { pressed, disabledReason, command: _command, ...rest } = props;\n const reasoned = reasonedDisabled(rest.disabled, disabledReason);\n const tip = buttonTipText({\n label: rest[\"aria-label\"],\n children: rest.children,\n disabledReason: reasoned ? disabledReason : undefined,\n });\n const { disabled, onClick, ...passed } = rest;\n return withButtonTip(\n <IconButton__Body\n ref={ref}\n aria-pressed={pressed}\n {...passed}\n disabled={reasoned ? undefined : disabled}\n {...(reasoned ? { \"aria-disabled\": true } : {})}\n onClick={reasoned ? swallowPress : onClick}\n />,\n tip,\n reasoned,\n );\n },\n);\n\nexport { Button__Body, filledLook };\n","import styled, { css } from \"styled-components\";\nimport type { ButtonSize, ButtonTone, ButtonVariant } from \"./Button\";\nimport { focusRing } from \"./focusRing\";\nimport { TONE_MARK, TONE_ON_STATUS, TONE_STATUS, TONE_TEXT } from \"./tone\";\n\n/** The fill a pressed button takes: its tone's status fill, and go for a neutral one. */\nfunction pressedTone(tone: ButtonTone): Exclude<ButtonTone, \"neutral\"> {\n return tone === \"neutral\" ? \"go\" : tone;\n}\n\n/**\n * A button filled in a tone's status colour under its own text. Used by the\n * primary variant and by every pressed button.\n */\nexport const filledLook = (tone: ButtonTone) => css`\n background: ${TONE_STATUS[tone]};\n border-color: ${TONE_STATUS[tone]};\n color: ${TONE_ON_STATUS[tone]};\n`;\n\n/** A toned outline: the tone's words on the button's own ground, edged in its mark. */\nconst tonedOutline = (tone: Exclude<ButtonTone, \"neutral\">) => css`\n border-color: ${TONE_MARK[tone]};\n color: ${TONE_TEXT[tone]};\n`;\n\nconst VARIANT_LOOK = {\n default: css`\n background: var(--color-surface-raised);\n border-color: var(--color-border-strong);\n color: var(--color-text-primary);\n `,\n ghost: css`\n background: none;\n border-color: var(--color-border-strong);\n /* Clears 4.5:1 on the app background. */\n color: var(--color-text-muted);\n `,\n} as const;\n\n/* Words that are the control: the surrounding colour and type, with no box, so nothing but the focus ring says it is a button. */\nconst TEXT_LOOK = css`\n background: none;\n border: none;\n padding: 0;\n min-height: 0;\n font: inherit;\n color: inherit;\n text-align: inherit;\n justify-content: flex-start;\n\n /* No box to brighten, so the words underline under the pointer. */\n @media (hover: hover) {\n &:hover:not(:disabled) {\n text-decoration: underline;\n }\n }\n`;\n\n/* Words keep their place under a coarse pointer: the touch target grows, but no inset pushes the text off its line. */\nconst TEXT_TOUCH = css`\n @media (pointer: coarse) {\n padding: 0;\n }\n`;\n\nfunction variantLook(variant: ButtonVariant, tone: ButtonTone) {\n if (variant === \"text\") return TEXT_LOOK;\n if (variant === \"primary\") return filledLook(tone);\n if (tone === \"neutral\") return VARIANT_LOOK[variant];\n return css`\n ${VARIANT_LOOK[variant]}\n ${tonedOutline(tone)}\n `;\n}\n\n/* A filled button keeps its fill under the pointer; only an outlined one brightens its edge and words. */\nconst OUTLINE_HOVER = css`\n @media (hover: hover) {\n &:hover:not(:disabled):not([aria-disabled=\"true\"]) {\n border-color: var(--color-text-faint);\n color: var(--color-text-primary);\n }\n }\n`;\n\nconst SIZE_LOOK = {\n sm: css`\n font-size: var(--font-size-caption);\n padding: var(--inset-control-small);\n `,\n md: css`\n font-size: var(--font-size-compact);\n padding: var(--inset-control);\n `,\n} as const;\n\n/**\n * The styled `button` body that every kit control drawn as a button shares.\n * Used by {@link ToggleButton} and {@link Button}, which add only the\n * states of their own behaviour.\n */\nexport const Button__Body = styled.button<{\n $variant: ButtonVariant;\n $tone: ButtonTone;\n $size: ButtonSize;\n $pressed: boolean;\n}>`\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: var(--gap-glyph-control);\n border: 1px solid;\n border-radius: var(--radius-regular);\n font-family: inherit;\n font-weight: 600;\n /* The kit's one control height, with a flush line height so type size cannot change the box height. */\n min-height: var(--control-height);\n line-height: var(--line-height-flush);\n cursor: pointer;\n transition: background var(--duration-fast), border-color var(--duration-fast), color var(--duration-fast);\n\n ${({ $size }) => SIZE_LOOK[$size]}\n ${({ $variant, $tone }) => variantLook($variant, $tone)}\n ${({ $pressed, $tone }) => ($pressed ? filledLook(pressedTone($tone)) : \"\")}\n\n ${({ $variant, $pressed }) =>\n $variant === \"primary\" || $variant === \"text\" || $pressed\n ? \"\"\n : OUTLINE_HOVER}\n ${focusRing}\n &[data-held-button] {\n position: relative;\n }\n\n /* A command that was refused, got no reply or never left edges in the warning colour and leaves the state's own fill alone. */\n &[data-command-edge=\"warn\"] {\n border-color: var(--color-warn-mark);\n }\n /* The game said it will refuse the press: dimmed, with a dashed warning edge. */\n &[data-command-edge=\"blocked\"] {\n border-style: dashed;\n border-color: var(--color-warn-mark);\n opacity: 0.5;\n }\n /* The stream to the mod is down: nothing can be sent. Dimmed, with a dotted edge. */\n &[data-stream=\"down\"] {\n opacity: 0.5;\n border-style: dotted;\n }\n &:disabled,\n &[aria-disabled=\"true\"] {\n opacity: 0.4;\n cursor: not-allowed;\n }\n\n /* A predicted result changes the edge's line style and colour only, never its width, so the box stays the same size; both dashed because they are predictions, apart by colour and the tooltip. */\n &[data-predicted=\"held\"]:not(:disabled) {\n border-style: dashed;\n border-color: var(--color-go-mark);\n }\n &[data-predicted=\"at-risk\"]:not(:disabled) {\n border-style: dashed;\n /* Eased toward the ground so the amber is no louder than the go green beside it. */\n border-color: color-mix(\n in srgb,\n var(--color-warn-mark) 65%,\n var(--color-surface-raised)\n );\n }\n\n /* An unconfirmed command may still run and a failed one never left; both read in the warning tone. */\n &[data-unconfirmed=\"true\"],\n &[data-failed=\"true\"] {\n border-color: var(--color-warn-mark);\n color: var(--color-warn-text);\n background: color-mix(\n in srgb,\n var(--color-warn-mark) 18%,\n var(--color-surface-raised)\n );\n }\n\n @media (pointer: coarse) {\n min-height: var(--touch-target);\n /* Wider on both axes: min-height only covers the vertical target. */\n padding: ${({ $size }) =>\n $size === \"sm\"\n ? \"var(--inset-control-small-touch)\"\n : \"var(--inset-control-touch)\"};\n }\n\n ${({ $variant }) => ($variant === \"text\" ? TEXT_TOUCH : \"\")}\n`;\n\n/**\n * The glyph a {@link IconButton} draws: nothing around it at rest, a fill and an\n * edge together under the pointer, the go fill while pressed. The edge is an\n * inset shadow, so the box is the same size in every state.\n */\nexport const IconButton__Body = styled.button`\n background: none;\n border: none;\n cursor: pointer;\n color: var(--color-text-faint);\n font-size: var(--font-size-base);\n line-height: var(--line-height-flush);\n padding: var(--inset-glyph-button);\n border-radius: var(--radius-regular);\n transition: background var(--duration-fast), box-shadow var(--duration-fast), color var(--duration-fast);\n\n /* A target of at least 24 by 24 on a fine pointer, whatever size the caller draws the glyph at; a coarse pointer already gets the touch target. */\n @media (pointer: fine) {\n min-width: 24px;\n min-height: 24px;\n }\n\n @media (hover: hover) {\n &:hover:not(:disabled):not([aria-disabled=\"true\"]):not([aria-pressed=\"true\"]) {\n background: var(--color-surface-raised);\n box-shadow: inset 0 0 0 1px var(--color-border-strong);\n color: var(--color-text-primary);\n }\n }\n &:active:not(:disabled):not([aria-disabled=\"true\"]) {\n ${filledLook(\"go\")}\n }\n /* A command that was refused, got no reply or never left tints the glyph in the warning colour. */\n &[data-command-edge=\"warn\"] {\n color: var(--color-warn-text);\n }\n /* A pressed glyph has its fill, so the warning is an edge on the box, as on a box toggle. */\n &[aria-pressed=\"true\"][data-command-edge=\"warn\"] {\n outline-width: 2px;\n outline-style: solid;\n outline-color: var(--color-warn-mark);\n outline-offset: -2px;\n }\n /* The game said it will refuse the press: the glyph is dimmed in the warning colour, with a dashed outline. */\n &[data-command-edge=\"blocked\"] {\n color: var(--color-warn-mark);\n opacity: 0.5;\n outline-width: 1px;\n outline-style: dashed;\n outline-color: var(--color-warn-mark);\n }\n /* The stream to the mod is down: dimmed, with a dotted outline. */\n &[data-stream=\"down\"] {\n opacity: 0.5;\n outline-width: 1px;\n outline-style: dotted;\n outline-color: currentColor;\n }\n &[aria-pressed=\"true\"] {\n ${filledLook(\"go\")}\n }\n ${focusRing}\n &:disabled,\n &[aria-disabled=\"true\"] {\n opacity: 0.4;\n cursor: not-allowed;\n }\n @media (pointer: coarse) {\n min-width: var(--touch-target);\n min-height: var(--touch-target);\n display: inline-flex;\n align-items: center;\n justify-content: center;\n }\n`;\n","import { css } from \"styled-components\";\n\n/**\n * The keyboard focus ring. Useful for showing the operator which control has\n * keyboard focus. Used by the kit's interactive controls.\n *\n * The colour is `--color-focus`, not the same-valued `--color-accent-fg`, so\n * focus stays retunable on its own. Kit-internal, not on the barrel.\n */\nexport const focusRing = css`\n &:focus-visible {\n outline: 2px solid var(--color-focus);\n outline-offset: 2px;\n }\n`;\n\n/**\n * The same ring drawn inside the element's own edge, for a full-bleed control\n * whose parent clips it: a row, a tab, a rail segment, where a ring outside the\n * box would be clipped away. Useful for showing the operator which control has\n * keyboard focus when a parent clips the ordinary ring. Used by the action menu,\n * tabs and the data table.\n */\nexport const focusRingInset = css`\n &:focus-visible {\n outline: 2px solid var(--color-focus);\n outline-offset: -2px;\n }\n`;\n","import {\n Children,\n isValidElement,\n type MouseEvent,\n type ReactElement,\n type ReactNode,\n} from \"react\";\nimport { Tooltip } from \"./Tooltip\";\n\n/** The words a button's children show: its strings and numbers, through any element around them. An icon has none. */\nexport function visibleText(children: ReactNode): string {\n let text = \"\";\n Children.forEach(children, (child) => {\n if (typeof child === \"string\" || typeof child === \"number\") {\n text += String(child);\n return;\n }\n if (isValidElement<{ children?: ReactNode }>(child)) {\n text += visibleText(child.props.children);\n }\n });\n return text.replace(/\\s+/g, \" \").trim();\n}\n\n/**\n * What a button says in its tip, or `null` for none. A button that is a glyph\n * alone, or whose accessible name says more than its words do, tips its name;\n * a button whose words are the whole story tips nothing. A disabled button\n * given a reason tips the reason after its name, when it has one to add.\n */\nexport function buttonTipText({\n label,\n children,\n disabledReason,\n}: {\n label: string | undefined;\n children: ReactNode;\n disabledReason: string | undefined;\n}): string | null {\n return nameAndReason({ label, children, disabledReason });\n}\n\nfunction nameAndReason({\n label,\n children,\n disabledReason,\n}: {\n label: string | undefined;\n children: ReactNode;\n disabledReason: string | undefined;\n}): string | null {\n const name =\n label !== undefined && label !== \"\" && label !== visibleText(children)\n ? label\n : null;\n if (disabledReason !== undefined && disabledReason !== \"\") {\n return name === null ? disabledReason : `${name}: ${disabledReason}`;\n }\n return name;\n}\n\n/**\n * A button with `disabledReason` and `disabled` is `aria-disabled` rather than\n * natively disabled, so it keeps keyboard focus and the pointer events its tip\n * needs; its presses do nothing.\n */\nexport function reasonedDisabled(\n disabled: boolean | undefined,\n disabledReason: string | undefined,\n): boolean {\n return (\n disabled === true && disabledReason !== undefined && disabledReason !== \"\"\n );\n}\n\n/** A press on a button disabled with a reason is swallowed, and submits no form. */\nexport function swallowPress(event: MouseEvent<HTMLButtonElement>): void {\n event.preventDefault();\n event.stopPropagation();\n}\n\n/**\n * Wraps a button element in the tip it owes under {@link buttonTipText}, unless\n * an enclosing {@link Tooltip} has already handed it one (`data-tooltip`).\n */\nexport function withButtonTip(\n body: ReactElement<Record<string, unknown>>,\n tip: string | null,\n announce: boolean,\n): ReactElement {\n if (tip === null || body.props[\"data-tooltip\"] !== undefined) return body;\n return (\n <Tooltip text={tip} announce={announce}>\n {body}\n </Tooltip>\n );\n}\n","import {\n type AnyBoundCommand,\n argsOf,\n type BoundCommand,\n bindCommand,\n type UseCommandResult,\n type ValueCommand,\n} from \"@ksp-gonogo/sitrep-sdk\";\nimport type { ButtonHTMLAttributes, ReactNode } from \"react\";\nimport { useEffect } from \"react\";\nimport styled, { css, keyframes } from \"styled-components\";\nimport type { ButtonVariant } from \"../Button\";\nimport { Button__Body, IconButton__Body } from \"../ButtonBody\";\nimport { useRailAnnounces } from \"../CommandDelay/railAnnouncer\";\nimport { FitLabel } from \"../FitLabelButton\";\nimport { SendIcon } from \"../Icons\";\nimport { LiveRegion } from \"../LiveRegion\";\nimport { PlainButton } from \"../PlainButton\";\nimport { ReservedText } from \"../ReservedText\";\nimport type { ReckoningMarking } from \"../readingCurrency\";\nimport { describeSendStatus } from \"../SendStatus/describeSendStatus\";\nimport { predictedOutcomeOf } from \"../SendStatus/predictedOutcome\";\nimport { Tooltip } from \"../Tooltip\";\nimport {\n type BoundControlCommand,\n type CommandButtonHandle,\n type CommandButtonSize,\n type CommandButtonTone,\n type CommandControlState,\n FOUND_WORD,\n LOST_WORD,\n REFUSED_WORD,\n SENT_WORD,\n STREAM_DOWN_TIP,\n standingGate,\n useCommandControl,\n} from \"./commandControl\";\nimport type { CommandToggle, ToggleState } from \"./toggle\";\n\ntype NativeButtonProps = Omit<\n ButtonHTMLAttributes<HTMLButtonElement>,\n \"onClick\" | \"type\" | \"children\" | \"aria-pressed\" | \"title\" | \"disabled\"\n>;\n\n/**\n * What a command input takes in its `command` prop: a command made with `with`\n * or `commandSet`, a handle whose arguments are all optional (a press of the\n * command with no arguments), or the control of a {@link useCommandControl} that\n * a bound key or serial input presses too.\n *\n * @category CommandButton\n */\n// biome-ignore lint/suspicious/noExplicitAny: a control or handle of any command's argument and reply types\nexport type CommandInput =\n | AnyBoundCommand\n | CommandButtonHandle<any, any>\n | CommandControlState<any>;\n\n/** Whether `command` is a control already running its own hook, which a bound key may press as well. */\nexport function isControl<Command extends object>(\n command: Command,\n): command is Extract<Command, { press: unknown }> {\n return \"press\" in command && typeof command.press === \"function\";\n}\n\n/** The bound command a handle or bound command stands for. */\nfunction boundOf(\n command: AnyBoundCommand | CommandButtonHandle<unknown, unknown>,\n): BoundControlCommand {\n if (\"kind\" in command) return command;\n return bindCommand(command, undefined);\n}\n\n/**\n * Props for a {@link Button} given a command: the command it sends, its words\n * for each state and the confirm wording. Any other native button attribute is\n * passed through, except `onClick` and `disabled`, which the command decides.\n * Useful for naming the command a button sends and how the operator confirms it.\n * Taken by {@link Button} when it has a `command`.\n *\n * @category CommandButton\n */\nexport interface CommandedButtonProps extends NativeButtonProps {\n /** The command to send when the button is pressed. */\n command: CommandInput;\n /**\n * What the control says on hover and keyboard focus while it is at rest or\n * armed, in the kit's tip. An outcome's own sentence, the caller's\n * `unavailable` reason or the game's reason for refusing replaces it while\n * one stands. It is not the accessible name: give `aria-label` for that.\n */\n tip?: string;\n /** The resting label. */\n children: ReactNode;\n /**\n * Why the control cannot be pressed now, for what a command's own declaration\n * cannot know, such as a reading that has not arrived. The control is drawn\n * dimmed with a solid edge, apart from the dashed warning edge the game's own\n * refusal gets, with this as its tip and accessible description, and a press\n * sends nothing. Null or absent when it can be pressed. A control given as a\n * `useCommandControl` states its own.\n */\n unavailable?: string | null;\n /**\n * Why the game is likely to refuse this command, for what the command's own\n * declaration cannot know. The control stays pressable and a press is sent;\n * the reason is its tip and its edge shows the command may be refused, and the\n * game decides on arrival. Null or absent when nothing says it will be\n * refused. A control given as a `useCommandControl` states its own.\n */\n advise?: string | null;\n /**\n * The armed label. Supplying it makes this an arm-then-confirm control: the\n * first click puts it in the armed phase, the second dispatches, and an armed\n * control left alone returns to rest after {@link ARM_TIMEOUT_MS}. Omit it for\n * a control that dispatches on one click.\n *\n * Arm anything irreversible, and anything that spends career funds.\n */\n confirmLabel?: ReactNode;\n /** The word shown in place of the label after the game refuses the command. Defaults to \"Refused\". */\n refusedLabel?: ReactNode;\n /**\n * The word shown in place of the label after a dispatch got no reply.\n * Defaults to \"No reply\": not \"failed\" and not \"refused\", neither of which is\n * known.\n */\n lostLabel?: ReactNode;\n /**\n * The label for a command this control lost that has since replied.\n * Defaults to \"Found\", with the whole sentence on the accessible name and\n * title. Not \"Confirmed\": the operator was told to give up on it.\n */\n foundLabel?: ReactNode;\n /**\n * The accessible name while the control cannot be pressed, for a control whose\n * resting name would mislead then. Omit it and the accessible name stays the\n * control's own name, with the reason as its description, read after the name.\n */\n blockedAriaLabel?: string;\n /**\n * The armed phase's accessible name, for a control whose resting\n * `aria-label` says more than its visible word (\"Hire Desdin Kerman for\n * 30,000 funds\"). Omit it and the visible confirm wording is the accessible\n * name, never the resting label, since the next press means something\n * different.\n */\n confirmAriaLabel?: string;\n /** The sent phase's accessible name, for a control whose resting name says more than its visible word. Defaults to the command's label followed by \"sent, not yet received\". */\n sentAriaLabel?: string;\n /**\n * Whether this control's command is currently in effect, for a control that\n * represents state as well as acting on it: an activated strategy. Sets\n * `aria-pressed` and the pressed fill. Leave it undefined for a control that\n * only acts.\n */\n pressed?: boolean;\n /** How much the control asks to be pressed at rest. As for {@link Button}. */\n variant?: ButtonVariant;\n /**\n * The tone of the fill while `pressed`, and of the resting fill for a\n * `primary` control. Defaults to `neutral`.\n */\n tone?: CommandButtonTone;\n /**\n * Shown in place of the word when the word does not fit the control's width,\n * measured against the control itself and following resizes, for a control in\n * a narrow cell. The word stays the accessible name in both states. Needs a\n * plain-text label and, when set, `confirmLabel`.\n */\n icon?: ReactNode;\n /** Shown in place of the confirm word when it does not fit. Defaults to {@link CommandedButtonProps.icon}. */\n confirmIcon?: ReactNode;\n /**\n * Called with the control's press while a click on it would do something\n * (not while it is in flight) and with `null` when it would not, for a\n * caller that lets an input (a key, a gamepad button or a serial device\n * bound to this control) press it from elsewhere. The press takes no\n * arguments and does what a click does: with a `confirmLabel` the first\n * press arms and the second dispatches, and a control with none dispatches\n * at once.\n */\n onPressReady?: (press: (() => void) | null) => void;\n /** Defaults to `md`. */\n size?: CommandButtonSize;\n /** Tone for the armed phase. Defaults to `go`: confirm reads as commit. */\n confirmTone?: CommandButtonTone;\n}\n\n/**\n * A button given a command: it sends the command and shows what became of it,\n * at rest, armed (with a `confirmLabel`), sent, refused, lost (no reply came in\n * time), found (a lost command has since replied), or unable to be pressed\n * (unavailable for the caller's reason, stream down, or blocked by the game's\n * refusal, told apart by edge). Rendered by {@link Button} when it has a\n * `command`.\n */\nexport function CommandedButton(props: CommandedButtonProps) {\n const { command, unavailable, advise, ...rest } = props;\n if (isControl(command)) {\n return <CommandedButtonFace {...rest} control={command} />;\n }\n return (\n <OwnedCommandedButton\n {...rest}\n command={command}\n unavailable={unavailable}\n advise={advise}\n />\n );\n}\n\n/**\n * An icon button given a command: the glyph stands for the word, and the kit's\n * send arrow stands in for it while the press is unanswered, so the box keeps\n * its size. Rendered by {@link IconButton} when it has a `command`.\n */\nexport function CommandedIconButton(props: CommandedButtonProps) {\n const { command, unavailable, advise, ...rest } = props;\n if (isControl(command)) {\n return <CommandedButtonFace {...rest} glyph control={command} />;\n }\n return (\n <OwnedCommandedButton\n {...rest}\n glyph\n command={command}\n unavailable={unavailable}\n advise={advise}\n />\n );\n}\n\nfunction OwnedCommandedButton({\n command,\n unavailable,\n advise,\n ...rest\n}: Omit<CommandedButtonProps, \"command\"> & {\n command: BoundCommand | CommandButtonHandle<unknown, unknown>;\n glyph?: boolean;\n}) {\n const control = useCommandControl({\n command: boundOf(command),\n unavailable,\n advise,\n });\n return <CommandedButtonFace {...rest} control={control} />;\n}\n\nfunction CommandedButtonFace({\n control,\n glyph = false,\n children: label,\n confirmLabel,\n refusedLabel = REFUSED_WORD,\n lostLabel = LOST_WORD,\n foundLabel = FOUND_WORD,\n confirmAriaLabel,\n sentAriaLabel,\n blockedAriaLabel,\n pressed,\n variant = \"default\",\n tone = \"neutral\",\n icon,\n confirmIcon,\n onPressReady,\n size = \"md\",\n confirmTone = \"go\",\n tip,\n \"aria-label\": ariaLabel,\n ...rest\n}: Omit<CommandedButtonProps, \"command\" | \"unavailable\"> & {\n control: CommandControlState;\n /** Draws the button as an icon button does: the glyph alone at rest, edged and filled under the pointer. */\n glyph?: boolean;\n}) {\n const {\n phase,\n isSent,\n isArmed,\n isRefused,\n isLost,\n isFound,\n isBlocked,\n isUnavailable,\n isAdvised,\n adviceText,\n isOffline,\n refusalText,\n foundText,\n lossText,\n hasUnconfirmed,\n hasFailure,\n press,\n command,\n } = control;\n const handle = command.handle;\n const args = command.members ? undefined : argsOf(command);\n const commandLabel = command.options.label;\n\n const hasConfirmStep = confirmLabel !== undefined;\n const sentSentence = commandLabel\n ? `${commandLabel} sent, not yet received`\n : \"Sent, not yet received\";\n useEffect(() => {\n if (!onPressReady) return;\n onPressReady(() => press(hasConfirmStep));\n return () => onPressReady(null);\n }, [onPressReady, press, hasConfirmStep]);\n\n const resolveBody = (): ReactNode => {\n if (glyph) {\n if (isSent) return <SendIcon aria-hidden=\"true\" />;\n if (isArmed) return confirmIcon ?? icon ?? label;\n return label;\n }\n if (isSent) return SENT_WORD;\n if (isRefused) return refusedLabel;\n if (isLost) return lostLabel;\n if (isFound) return foundLabel;\n if (isArmed) return confirmLabel;\n return label;\n };\n const resolved = resolveBody();\n const fitWord = icon !== undefined && typeof resolved === \"string\";\n /* A word standing in for a label that cannot hold it (a node label, or a narrow cell) is held to one line and clipped, so it never wraps and grows the control. */\n const clipsWord =\n !glyph && !fitWord && typeof resolved === \"string\" && resolved !== label;\n const body = fitWord ? (\n <FitLabel label={resolved} icon={isArmed ? (confirmIcon ?? icon) : icon} />\n ) : clipsWord ? (\n <CommandButton__Word>{resolved}</CommandButton__Word>\n ) : (\n resolved\n );\n /*\n * A control keeps the width of its widest word (resting, confirm or SENT) in\n * every state, so pressing it never reflows the row it sits in. Only plain-text\n * labels can be measured this way; a node label sizes itself as before.\n */\n /* Every word the control can show in place of its label: the widest sets the width in every phase, so an outcome never resizes the control. */\n const words = [confirmLabel, SENT_WORD, refusedLabel, lostLabel, foundLabel];\n const reserve =\n !glyph &&\n icon === undefined &&\n typeof label === \"string\" &&\n words.every((w) => w === undefined || typeof w === \"string\");\n const widest = (words as (string | undefined)[])\n .filter((w): w is string => w !== undefined)\n .reduce((a, b) => (b.length > a.length ? b : a), SENT_WORD);\n\n // A mounted rail announces every outcome of the commands it holds, so this control's own region stays quiet beside one only when its handle is one of them.\n const railed = useRailAnnounces() && handle.railed === true;\n const outcome = railed\n ? null\n : isRefused\n ? refusalText\n : isLost\n ? lossText\n : isFound\n ? foundText\n : isSent\n ? sentSentence\n : null;\n\n const filled = pressed === true || isArmed || isRefused;\n const drawnTone = commandTone({\n restTone: variant === \"primary\" ? tone : \"neutral\",\n filled,\n isRefused,\n isFound,\n isArmed,\n confirmTone,\n tone,\n });\n\n /* The game's refusal in advance, apart from a reason the caller gave. */\n const gated = isBlocked && !isUnavailable;\n // A box button draws the game's refusal through its own blocked style, so only a glyph needs the attribute.\n const commandEdge = gated\n ? glyph\n ? \"blocked\"\n : undefined\n : isLost || (glyph && (isRefused || hasUnconfirmed || hasFailure))\n ? \"warn\"\n : undefined;\n const Body = glyph ? CommandGlyph__Body : CommandButton__Body;\n const sendStatus = handle.sendStatus;\n const restTip = [\n tip,\n adviceText,\n sendStatus === undefined ? null : describeSendStatus(sendStatus),\n ]\n .filter(Boolean)\n .join(\"\\n\");\n const tipText = isOffline\n ? [tip, STREAM_DOWN_TIP].filter(Boolean).join(\"\\n\")\n : restTip || undefined;\n\n return (\n <>\n <Tooltip\n text={\n foundText ??\n refusalText ??\n lossText ??\n (isSent ? sentSentence : tipText)\n }\n >\n <Body\n type=\"button\"\n data-command-edge={commandEdge}\n $tone={drawnTone}\n $variant={variant}\n $fit={fitWord}\n $size={size}\n $pressed={filled}\n $armed={isArmed}\n $blocked={gated}\n aria-pressed={pressed}\n // aria-disabled, not disabled, so the control keeps focus while the outcome lands on it and the tip can be reached.\n aria-disabled={isBlocked || isOffline || undefined}\n data-unconfirmed={hasUnconfirmed ? \"true\" : undefined}\n data-failed={hasFailure ? \"true\" : undefined}\n data-command-phase={phase}\n data-stream={isOffline ? \"down\" : undefined}\n data-predicted={\n gated\n ? undefined\n : (predictedOutcomeOf(sendStatus) ??\n (isAdvised ? \"at-risk\" : undefined))\n }\n // A diagnostic hook only: an undetermined gate renders as an ordinary control.\n data-gate={\n gated\n ? \"blocked\"\n : isAdvised\n ? \"advised\"\n : standingGate(handle, args)?.undetermined\n ? \"undetermined\"\n : undefined\n }\n /*\n * The accessible name tracks the phase: an outcome's full sentence while\n * it stands, and for armed and sent the visible wording rather than\n * the resting label, which describes a state the control has left.\n */\n aria-label={\n (isRefused\n ? (refusalText ?? undefined)\n : isLost\n ? (lossText ?? undefined)\n : isFound\n ? (foundText ?? ariaLabel)\n : isBlocked\n ? (blockedAriaLabel ?? ariaLabel)\n : isSent\n ? (sentAriaLabel ?? sentSentence)\n : isArmed\n ? confirmAriaLabel\n : ariaLabel) ?? (fitWord ? resolved : undefined)\n }\n onClick={() => press(confirmLabel !== undefined)}\n data-rest-label={reserve ? label : undefined}\n data-armed-label={reserve ? widest : undefined}\n {...rest}\n >\n {reserve ? <CommandButton__Face>{body}</CommandButton__Face> : body}\n </Body>\n </Tooltip>\n {/* Mounted with the control, so an outcome lands in a region assistive tech is already watching. */}\n <LiveRegion visuallyHidden>{outcome}</LiveRegion>\n </>\n );\n}\n\n/**\n * Props for a {@link ToggleButton} given a command: the command it sends, the\n * state it shows and what it is called. Any other native button attribute is\n * passed through, except `onClick` and `disabled`, which the command decides.\n * Useful for a switch the operator flips under signal delay, such as SAS or an\n * action group. A toggle keeps its on and off word in every state: a refusal or\n * a missing reply shows as a warning edge, the game's refusal in advance as a\n * dashed warning edge, and the stream to the mod being down as a dotted edge.\n * Taken by {@link ToggleButton} when it has a `command`.\n *\n * @category CommandButton\n */\nexport interface CommandedToggleProps extends NativeButtonProps {\n /**\n * The command a press sends, made with `toArgs` on a `useCommand` handle and\n * given `true` to switch on and `false` to switch off. Or the control of a\n * {@link useCommandControl} that was given a `toggle`, which a bound key or\n * serial input may press as well.\n */\n // biome-ignore lint/suspicious/noExplicitAny: a command of any argument and reply types\n command: ValueCommand<boolean, any, any> | CommandControlState<any>;\n /** The state as the vessel last reported it, uncoerced: nothing yet is a third state, not off. Not used with a control. */\n state?: ToggleState;\n /** What the control is called in the sentences it speaks (\"RCS sent, not yet received\"). Not used with a control. */\n name?: string;\n /**\n * Why the control cannot be pressed now. It is drawn dimmed with a solid edge\n * and this as its tip, and a press sends nothing. Null or absent when it can\n * be pressed. Not used with a control.\n */\n unavailable?: string | null;\n /**\n * Why the game is likely to refuse this command, for what the command's own\n * declaration cannot know. The control stays pressable and a press is sent;\n * the reason is its tip and its edge shows the command may be refused, and the\n * game decides on arrival. Null or absent when nothing says it will be\n * refused. Not used with a control.\n */\n advise?: string | null;\n /** The fill while on. Defaults to `go`. */\n tone?: \"go\" | \"nogo\" | \"warn\";\n /** Defaults to `md`. */\n size?: CommandButtonSize;\n /**\n * The word the control shows for a state, or a function of the state shown\n * that returns it. Not used with a control, which carries its own words.\n */\n children?: ReactNode | ((shown: ToggleState) => string);\n /** Stands in the word's place until the press is answered. \"SENT\" is still a word, since no icon says it. */\n icon?: ReactNode;\n /** What the control says on hover and keyboard focus. An outcome's own sentence replaces it while one stands. */\n tip?: string;\n /** The word shown in place of the state until the mod answers the press. Defaults to \"SENT\". Not used with a control. */\n sentWord?: string;\n /** Which of the handle's in-flight rows are this control's, where one command serves several controls. Not used with a control. */\n rows?: CommandToggle[\"rows\"];\n /** What an arrived command does to a state its args do not set outright. Not used with a control. */\n modelled?: CommandToggle[\"modelled\"];\n /** The mark the state's own reading wears, when it is held or late. Not used with a control. */\n marking?: ReckoningMarking | null;\n}\n\n/**\n * A toggle given a command: it shows the state the vessel reports, a press\n * sends the command that sets the opposite, and while that press is unanswered\n * it shows \"SENT\", then the state again, marked held while the command waits at\n * a relay and marked modelled while it is predicted to have arrived. A second\n * press is always sent. Rendered by {@link ToggleButton} when it has a\n * `command`.\n */\nexport function CommandedToggle(props: CommandedToggleProps) {\n const { command, ...rest } = props;\n if (isControl(command)) {\n return <CommandedToggleFace {...rest} control={command} />;\n }\n return <OwnedCommandedToggle {...rest} command={command} />;\n}\n\n/**\n * An icon toggle given a command: the glyph stands for the word until the press\n * is answered, and the kit's send arrow stands in for it meanwhile. Rendered by\n * {@link IconButton} when it has a `command` that sets a value.\n */\nexport function CommandedIconToggle(props: CommandedToggleProps) {\n const { command, ...rest } = props;\n if (isControl(command)) {\n return <CommandedToggleFace {...rest} glyph control={command} />;\n }\n return <OwnedCommandedToggle {...rest} glyph command={command} />;\n}\n\nfunction OwnedCommandedToggle({\n command,\n state,\n name,\n unavailable,\n advise,\n children,\n sentWord,\n rows,\n modelled,\n marking,\n glyph,\n ...rest\n}: Omit<CommandedToggleProps, \"command\"> & {\n glyph?: boolean;\n // biome-ignore lint/suspicious/noExplicitAny: a command of any argument and reply types\n command: ValueCommand<boolean, any, any>;\n}) {\n const wordOf = (shown: ToggleState): string =>\n typeof children === \"function\"\n ? children(shown)\n : typeof children === \"string\"\n ? children\n : \"\";\n const control = useCommandControl({\n command: {\n kind: \"bound\",\n handle: command.handle,\n args: undefined,\n options: command.options,\n },\n toggle: {\n state,\n name: name ?? \"\",\n word: wordOf,\n /* The on and off words only: the word for a state not yet read is a one-off the width is not held for. */\n words: [...new Set([wordOf(true), wordOf(false)])],\n sentWord,\n rows,\n modelled,\n marking,\n unavailable,\n // Nothing is sent while the state is unread: there is no opposite of it.\n args: (base) =>\n base === null || base === undefined\n ? undefined\n : command.toArgs(!(typeof base === \"number\" ? base > 0 : base)),\n },\n advise,\n });\n return <CommandedToggleFace {...rest} glyph={glyph} control={control} />;\n}\n\nfunction CommandedToggleFace({\n control,\n glyph = false,\n tone = \"go\",\n size = \"md\",\n icon,\n tip,\n \"aria-label\": ariaLabel,\n ...rest\n}: Omit<\n CommandedToggleProps,\n | \"command\"\n | \"state\"\n | \"name\"\n | \"unavailable\"\n | \"advise\"\n | \"children\"\n | \"sentWord\"\n | \"rows\"\n | \"modelled\"\n | \"marking\"\n> & { control: CommandControlState; glyph?: boolean }) {\n const {\n phase,\n isOffline,\n isRefused,\n isLost,\n isBlocked,\n isUnavailable,\n isAdvised,\n adviceText,\n refusalText,\n lossText,\n toggleView,\n hasUnconfirmed,\n hasFailure,\n press,\n } = control;\n if (!toggleView) return null;\n const { marking, sentence } = toggleView;\n // A held or modelled command's mark carries its own sentence, so the tip beside it stays free.\n const markCarriesIt =\n toggleView.confirmation === \"held\" ||\n toggleView.confirmation === \"modelled\";\n const toggleTip = isOffline\n ? STREAM_DOWN_TIP\n : (isBlocked && !isUnavailable) || isRefused\n ? refusalText\n : isLost\n ? lossText\n : ((markCarriesIt ? null : sentence) ??\n [tip, adviceText].filter(Boolean).join(\"\\n\")) ||\n undefined;\n /*\n * A refusal, a silence or an undelivered command edges the control in the\n * warning colour over the state's own fill, so \"on, and your press was\n * refused\" reads as both.\n */\n const warned = isRefused || isLost || hasUnconfirmed || hasFailure;\n /* The game said it will refuse the press: dimmed with a dashed warning edge, apart from a reason the caller gave. */\n const gated = isBlocked && !isUnavailable;\n const edge = gated ? \"blocked\" : warned ? \"warn\" : undefined;\n const cannotPress = toggleView.unavailable !== null || isBlocked;\n const cannotPressReason =\n toggleView.unavailable ?? (isBlocked ? refusalText : null);\n return (\n <>\n <Tooltip text={toggleTip}>\n {glyph ? (\n <IconButton__Body\n type=\"button\"\n aria-pressed={toggleView.on}\n aria-disabled={cannotPress || undefined}\n aria-label={ariaLabel}\n data-command-phase={phase}\n data-stream={isOffline ? \"down\" : undefined}\n data-command-edge={edge}\n data-predicted={isAdvised ? \"at-risk\" : undefined}\n onClick={() => press(false)}\n {...rest}\n >\n {toggleView.confirmation === \"sent\" ? (\n <SendIcon aria-hidden=\"true\" />\n ) : (\n icon\n )}\n </IconButton__Body>\n ) : (\n <PlainButton\n type=\"button\"\n size={size}\n tone={toggleView.on ? tone : undefined}\n pressed={toggleView.on}\n aria-pressed={toggleView.on}\n disabled={cannotPress || undefined}\n disabledReason={cannotPressReason ?? undefined}\n marked={marking}\n aria-label={ariaLabel}\n data-command-phase={phase}\n data-stream={isOffline ? \"down\" : undefined}\n data-command-edge={edge}\n data-predicted={isAdvised ? \"at-risk\" : undefined}\n onClick={() => press(false)}\n {...rest}\n >\n {/* An icon stands where the word would; SENT is still a word, since no icon says it. */}\n {icon !== undefined && toggleView.confirmation !== \"sent\" ? (\n icon\n ) : (\n <ReservedText\n shown={toggleView.word}\n reserve={toggleView.reserve}\n />\n )}\n </PlainButton>\n )}\n </Tooltip>\n {/* A held or modelled mark is spoken with the label, so only a press the mod has not answered is announced. */}\n <LiveRegion visuallyHidden>\n {markCarriesIt ? \"\" : (sentence ?? \"\")}\n </LiveRegion>\n </>\n );\n}\n\n/** The tone a command draws in: plain at rest, then the tone of the phase it is filled for. */\nfunction commandTone(p: {\n restTone: CommandButtonTone;\n filled: boolean;\n isRefused: boolean;\n isFound: boolean;\n isArmed: boolean;\n confirmTone: CommandButtonTone;\n tone: CommandButtonTone;\n}): CommandButtonTone {\n if (!p.filled) return p.restTone;\n if (p.isRefused) return \"warn\";\n // `found` reverses a warning, so it does not wear the warning's colour.\n if (p.isFound) return \"neutral\";\n if (p.isArmed) return p.confirmTone;\n return p.tone;\n}\n\nconst armedPulse = keyframes`\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.65; }\n`;\n\nconst CommandButton__Word = styled.span`\n display: block;\n min-width: 0;\n max-width: 100%;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n`;\n\nconst CommandButton__Face = styled.span`\n grid-area: 1 / 1;\n /* A face never grows past the button, so a word wider than the button is clipped inside it instead of spilling out. */\n min-width: 0;\n max-width: 100%;\n /* First in the cell's order, so the button's baseline is the face's and not an invisible sizer's. */\n order: -1;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: var(--gap-glyph);\n`;\n\n/* A command at rest is the quiet ghost; in effect, armed or refused it takes the one pressed fill. */\nconst CommandButton__Body = styled(Button__Body)<{\n $armed: boolean;\n $blocked: boolean;\n $fit: boolean;\n}>`\n letter-spacing: 0.04em;\n\n /* Shrinks below its word so the word can be measured and give way to the icon. */\n ${({ $fit }) => ($fit ? \"min-width: 0;\" : \"\")}\n\n ${({ $armed }) =>\n $armed &&\n css`\n @media (prefers-reduced-motion: no-preference) {\n animation: ${armedPulse} 1s var(--ease-emphasis) infinite;\n }\n `}\n\n &:disabled {\n opacity: 0.5;\n }\n\n /* Dimmed toward the muted text token rather than faded, so the refusal reason stays readable; the warn border says the game refused. */\n ${({ $blocked }) =>\n $blocked &&\n css`\n background: transparent;\n border-style: dashed;\n border-color: var(--color-warn-mark);\n color: var(--color-text-muted);\n cursor: help;\n\n @media (hover: hover) {\n &:hover:not(:disabled) {\n border-color: var(--color-warn-mark);\n color: var(--color-warn-text);\n }\n }\n `}\n\n /* Both labels sit invisibly in the one grid cell with the face, so the box is as wide as the wider of them. */\n &[data-rest-label] {\n display: inline-grid;\n justify-items: center;\n }\n &[data-rest-label]::before,\n &[data-rest-label]::after {\n grid-area: 1 / 1;\n visibility: hidden;\n height: 0;\n }\n &[data-rest-label]::before {\n content: attr(data-rest-label);\n }\n &[data-rest-label]::after {\n content: attr(data-armed-label);\n }\n`;\n\n/* A glyph under a command: dimmed while the game says it will refuse, and pulsing while armed. */\nconst CommandGlyph__Body = styled(IconButton__Body)<{\n $armed: boolean;\n $blocked: boolean;\n}>`\n ${({ $armed }) =>\n $armed &&\n css`\n @media (prefers-reduced-motion: no-preference) {\n animation: ${armedPulse} 1s var(--ease-emphasis) infinite;\n }\n `}\n ${({ $blocked }) =>\n $blocked &&\n css`\n opacity: 0.5;\n cursor: help;\n `}\n`;\n","import { useSyncExternalStore } from \"react\";\nimport { type DelayRailStore, useDelayRailStore } from \"./DelayRailContext\";\n\n/*\n * A panel's rail speaks every outcome of the commands registered on its store,\n * so a control on that store stays quiet rather than say it a second time. The\n * claim is per store and held only while a rail is mounted on it: a widget that\n * composes no rail still hears its own controls.\n */\nconst claims = new WeakMap<DelayRailStore, number>();\nconst listeners = new WeakMap<DelayRailStore, Set<() => void>>();\n\nfunction notify(store: DelayRailStore): void {\n for (const listener of listeners.get(store) ?? []) listener();\n}\n\nexport function claimRailAnnouncer(store: DelayRailStore): () => void {\n claims.set(store, (claims.get(store) ?? 0) + 1);\n notify(store);\n return () => {\n claims.set(store, (claims.get(store) ?? 1) - 1);\n notify(store);\n };\n}\n\nexport function useRailAnnounces(): boolean {\n const store = useDelayRailStore();\n return useSyncExternalStore(\n (onChange) => {\n if (!store) return () => {};\n const set = listeners.get(store) ?? new Set<() => void>();\n listeners.set(store, set);\n set.add(onChange);\n return () => set.delete(onChange);\n },\n () => store !== null && (claims.get(store) ?? 0) > 0,\n () => false,\n );\n}\n","import { forwardRef } from \"react\";\nimport styled from \"styled-components\";\nimport type { PlainButtonProps } from \"./Button\";\nimport { Button__Body } from \"./ButtonBody\";\nimport {\n buttonTipText,\n reasonedDisabled,\n swallowPress,\n withButtonTip,\n} from \"./buttonTip\";\nimport { HeldFigure } from \"./HeldMark\";\n\n/*\n * The held mark hangs off the button's corner and reserves no room, so a marked\n * button is the size of the same button unmarked and its label stays centred.\n */\nconst Button__Held = styled(HeldFigure)`\n position: static;\n\n &::after {\n content: none;\n }\n\n & > [data-held-mark] {\n top: 3px;\n right: 3px;\n }\n`;\n\n/**\n * The plain button: the kit's {@link Button} with no command. {@link Button}\n * draws this unless it is given a `command`, and a toggle given a command draws\n * it too.\n */\nexport const PlainButton = forwardRef<HTMLButtonElement, PlainButtonProps>(\n function Button(\n {\n variant = \"default\",\n tone,\n size = \"md\",\n pressed,\n predictedOutcome,\n disabledReason,\n marked,\n type = \"button\",\n ...rest\n },\n ref,\n ) {\n const reasoned = reasonedDisabled(rest.disabled, disabledReason);\n const tip = buttonTipText({\n label: rest[\"aria-label\"],\n children: rest.children,\n disabledReason: reasoned ? disabledReason : undefined,\n });\n const { disabled, onClick, children, ...passed } = rest;\n return withButtonTip(\n <Button__Body\n ref={ref}\n $variant={variant}\n $tone={tone ?? (variant === \"primary\" ? \"go\" : \"neutral\")}\n $size={size}\n $pressed={pressed === true}\n aria-pressed={pressed}\n data-predicted={predictedOutcome}\n data-held-button={marked ? \"\" : undefined}\n {...passed}\n disabled={reasoned ? undefined : disabled}\n {...(reasoned ? { \"aria-disabled\": true } : {})}\n onClick={reasoned ? swallowPress : onClick}\n // After the caller's own props, so a button that passed a type keeps the attribute where it always sat.\n type={type}\n >\n {marked ? (\n <Button__Held kind={marked.kind} caption={marked.caption}>\n {children}\n </Button__Held>\n ) : (\n children\n )}\n </Button__Body>,\n tip,\n reasoned,\n );\n },\n);\n","import type { ValueCommand } from \"@ksp-gonogo/sitrep-sdk\";\nimport {\n forwardRef,\n type ReactNode,\n type SelectHTMLAttributes,\n useEffect,\n useState,\n} from \"react\";\nimport styled, { css } from \"styled-components\";\nimport { useCommandInput } from \"./CommandButton/commandInput\";\nimport { commandEdge } from \"./commandEdge\";\nimport { focusRing } from \"./focusRing\";\nimport { LiveRegion } from \"./LiveRegion\";\nimport { Tooltip } from \"./Tooltip\";\n\n/**\n * A vertical form body, the root of a widget's config form. Each child is\n * usually a {@link Field} (label above control) or a {@link FieldRow} (label\n * beside control). Useful for laying out the settings the operator edits for\n * one widget. Used by the config forms of the graph, warp control and target\n * picker widgets.\n *\n * `$boxed` puts it on a panel surface with a border and its own padding, and\n * tightens the gap, since a boxed form is denser than a settings section. The\n * `$` prefix marks a styled-components transient prop: it styles the form and\n * is never passed on to the DOM element.\n *\n * @example\n * ```tsx\n * import {\n * ConfigForm,\n * Field,\n * FieldHint,\n * FieldLabel,\n * Input,\n * Select,\n * } from \"@ksp-gonogo/ui-kit\";\n * import { useState } from \"react\";\n *\n * function ActionGroupForm({\n * groups,\n * }: {\n * groups: ReadonlyArray<{ id: string; name: string }>;\n * }) {\n * const [groupId, setGroupId] = useState(groups[0]?.id ?? \"\");\n * const [label, setLabel] = useState(\"\");\n * return (\n * <ConfigForm>\n * <Field>\n * <FieldLabel htmlFor=\"ag-select\">Action Group</FieldLabel>\n * <Select\n * id=\"ag-select\"\n * value={groupId}\n * onChange={(e) => setGroupId(e.target.value)}\n * >\n * {groups.map((g) => (\n * <option key={g.id} value={g.id}>{g.name}</option>\n * ))}\n * </Select>\n * </Field>\n * <Field>\n * <FieldLabel htmlFor=\"ag-label\">Custom Label</FieldLabel>\n * <Input\n * id=\"ag-label\"\n * type=\"text\"\n * value={label}\n * onChange={(e) => setLabel(e.target.value)}\n * />\n * <FieldHint>Leave blank to use the action group name.</FieldHint>\n * </Field>\n * </ConfigForm>\n * );\n * }\n * ```\n *\n * @category Form\n * @categoryDescription Form\n * Controls for entering values: labelled fields with hints, inputs and selects,\n * a combobox, a date field on the game's calendar, a reference frame picker, a\n * jog wheel and read-only fields. A widget's config form is built from these.\n */\nexport const ConfigForm = styled.div<{\n /** Puts the form on a bordered panel surface with its own padding and a tighter gap. */\n $boxed?: boolean;\n}>`\n display: flex;\n flex-direction: column;\n gap: ${({ $boxed }) => ($boxed ? \"var(--gap-form-field-boxed)\" : \"var(--gap-form-field)\")};\n ${({ $boxed }) =>\n $boxed\n ? `\n background: var(--color-surface-panel);\n border: 1px solid var(--color-border-subtle);\n border-radius: var(--radius-regular);\n padding: var(--inset-form-box);\n`\n : \"\"}\n`;\n\n/**\n * One labelled control in a {@link ConfigForm}, stacked: {@link FieldLabel} on\n * top, the control below, an optional {@link FieldHint} under it. Useful for\n * any setting the operator edits. Used by the graph config form and the alarms\n * dialog. Tie the label to the control with `htmlFor` and `id`. For a single\n * line of text with no hint, prefer {@link TextField}, which does all of this\n * in one; build with `Field` and {@link Input} for a control it does not cover\n * or a field that needs a {@link FieldHint}.\n *\n * @example\n * ```tsx\n * import { Field, FieldHint, FieldLabel, Input } from \"@ksp-gonogo/ui-kit\";\n * import { useState } from \"react\";\n *\n * function GainField() {\n * const [gain, setGain] = useState(\"1\");\n * return (\n * <Field>\n * <FieldLabel htmlFor=\"gain\">Gain</FieldLabel>\n * <Input id=\"gain\" value={gain} onChange={(e) => setGain(e.target.value)} />\n * <FieldHint>Applied on the next frame.</FieldHint>\n * </Field>\n * );\n * }\n * ```\n *\n * @category Form\n */\nexport const Field = styled.div`\n display: flex;\n flex-direction: column;\n gap: var(--gap-field-label);\n`;\n\n/**\n * A labelled control laid out horizontally: label on the left, control on the\n * right, vertically centred. Useful for a compact setting such as a switch or a\n * short value. Used by the ground track widget's configuration form and the serial input\n * mapping tab. Pick {@link Field} instead when the control is wide, such as a\n * select or a text input, and wants the full width under its label.\n *\n * @example\n * ```tsx\n * import { ConfigForm, FieldLabel, FieldRow, Switch } from \"@ksp-gonogo/ui-kit\";\n * import { useState } from \"react\";\n *\n * function GridSetting() {\n * const [showGrid, setShowGrid] = useState(false);\n * return (\n * <ConfigForm>\n * <FieldRow>\n * <FieldLabel>Show grid</FieldLabel>\n * <Switch aria-label=\"Show grid\" checked={showGrid} onChange={setShowGrid} />\n * </FieldRow>\n * </ConfigForm>\n * );\n * }\n * ```\n *\n * @category Form\n */\nexport const FieldRow = styled.div`\n display: flex;\n align-items: center;\n gap: var(--gap-field-label-inline);\n`;\n\n/**\n * The label of a {@link Field} or {@link FieldRow}: a native `<label>` in small\n * uppercase caption type. Useful for naming a control to the operator and to a\n * screen reader. Used by the alarms dialog. Pass `htmlFor` to tie it to its\n * control.\n *\n * @category Form\n */\nexport const FieldLabel = styled.label`\n font-size: var(--font-size-caption);\n font-weight: 700;\n letter-spacing: 0.1em;\n text-transform: uppercase;\n color: var(--color-text-dim);\n`;\n\n/**\n * Small, faint help text under a control in a {@link Field}. Useful for telling\n * the operator what a value means or what range it accepts. Used by the alarms\n * dialog. Give it an `id` and point the control's `aria-describedby` at it when\n * it should be read with the control.\n *\n * @category Form\n */\nexport const FieldHint = styled.span`\n font-size: var(--font-size-compact);\n color: var(--color-text-faint);\n`;\n\n/**\n * A horizontal row of buttons at the foot of a form, vertically centred. Useful\n * for the save and cancel controls of a form the operator fills in. Used by the\n * connection settings and the log manager.\n *\n * @category Form\n */\nexport const FormActions = styled.div`\n display: flex;\n gap: var(--gap-control-row);\n align-items: center;\n`;\n\nconst inputBase = css`\n background: var(--color-surface-raised);\n border: 1px solid var(--color-border-strong);\n border-radius: var(--radius-regular);\n color: var(--color-text-primary);\n font-size: var(--font-size-compact);\n padding: var(--inset-field);\n\n &:focus {\n /* The accent border on the raised surface clears WCAG 1.4.11's 3:1. */\n border-color: var(--color-accent-fg);\n outline: none;\n }\n\n ${focusRing}\n\n /* The browser's own clear control ignores the theme; SearchBox draws the kit's. */\n &::-webkit-search-cancel-button {\n appearance: none;\n }\n\n @media (pointer: coarse) {\n min-height: var(--touch-target);\n padding: var(--inset-field-touch);\n /* 16px stops iOS Safari zooming on focus; a literal, because the threshold is absolute. */\n font-size: 16px;\n }\n`;\n\n/**\n * A native `<input>` in the kit's field style, full width, with a visible focus\n * ring and a 44px touch target on coarse pointers. Useful for a text or number\n * value the operator types. Used by the alarms dialog and the connection\n * settings.\n *\n * @category Form\n */\nexport const Input = styled.input`\n ${inputBase}\n width: 100%;\n ${commandEdge}\n &[data-command-phase] {\n /* Room for the word of a command inside the field, at its end. */\n padding-inline-end: 8ch;\n }\n`;\n\n/**\n * The props of a {@link Select} that sends a command: the value the vessel\n * reports, the command a choice sends, and why a choice cannot be made now.\n *\n * @category Form\n */\nexport interface CommandedSelectProps\n extends Omit<\n SelectHTMLAttributes<HTMLSelectElement>,\n \"value\" | \"onChange\" | \"disabled\" | \"children\"\n > {\n /** The command a choice sends, made with `toArgs` on a `useCommand` handle and given the chosen option's value. */\n // biome-ignore lint/suspicious/noExplicitAny: a command of any argument and reply types\n command: ValueCommand<string, any, any>;\n /** The value as the vessel last reported it. While a choice is unanswered the field shows the value asked for instead. */\n value: string;\n /** Why a choice cannot be made now. The field is drawn dimmed with this as its tip and a choice sends nothing. */\n unavailable?: string | null;\n /** The `<option>` elements to choose from. */\n children?: ReactNode;\n}\n\n/**\n * The props of a {@link Select} that changes a value the caller holds: a native\n * `<select>`'s own props.\n *\n * @category Form\n */\nexport type PlainSelectProps = SelectHTMLAttributes<HTMLSelectElement> & {\n command?: never;\n unavailable?: never;\n};\n\n/**\n * A native `<select>` in the kit's field style, full width. Given a `command`,\n * a choice sends it and a word inside the field says what became of it. Useful\n * for choosing one value from a short list. Used by the log manager. For a long\n * or searchable list, use {@link ComboboxListbox} with an {@link Input}.\n *\n * @category Form\n */\nexport const Select = forwardRef<\n HTMLSelectElement,\n PlainSelectProps | CommandedSelectProps\n>(function Select(props, ref) {\n if (props.command) {\n return (\n <CommandedSelect {...props} command={props.command} forwardedRef={ref} />\n );\n }\n return <SelectField ref={ref} {...props} />;\n});\n\nconst SelectField = styled.select`\n ${inputBase}\n width: 100%;\n appearance: none;\n /* The native arrow hugs the field's edge and cannot be inset, so the chevron is two gradient strokes drawn clear of it. */\n background-image:\n linear-gradient(45deg, transparent 50%, var(--color-text-muted) 50%),\n linear-gradient(135deg, var(--color-text-muted) 50%, transparent 50%);\n background-position:\n calc(100% - var(--offset-select-arrow-far)) 50%,\n calc(100% - var(--offset-select-arrow-near)) 50%;\n background-size:\n var(--size-select-arrow) var(--size-select-arrow),\n var(--size-select-arrow) var(--size-select-arrow);\n background-repeat: no-repeat;\n padding-inline-end: var(--inset-field-select-end);\n ${commandEdge}\n &[data-command-phase] {\n /* Room for the word inside the field, past the chevron. */\n padding-inline-end: calc(var(--inset-field-select-end) + 8ch);\n }\n\n @media (pointer: coarse) {\n padding-inline-end: var(--inset-field-select-end);\n }\n`;\n\n/* The word sits inside the field, clear of the chevron, so nothing moves. */\nconst FieldWord = styled.span`\n position: absolute;\n inset-block: 0;\n inset-inline-end: var(--inset-field-select-end);\n display: flex;\n align-items: center;\n pointer-events: none;\n font-size: var(--font-size-caption);\n color: var(--color-text-muted);\n letter-spacing: 0.08em;\n`;\n\nconst FieldBox = styled.div`\n position: relative;\n width: 100%;\n`;\n\nfunction CommandedSelect({\n command,\n value,\n unavailable,\n forwardedRef,\n children,\n ...rest\n}: CommandedSelectProps & {\n forwardedRef: React.ForwardedRef<HTMLSelectElement>;\n}) {\n const input = useCommandInput({ command, unavailable });\n // While a choice is unanswered the field shows what was asked.\n const [asked, setAsked] = useState<string | null>(null);\n const sent = input.control.isSent;\n useEffect(() => {\n if (!sent) setAsked(null);\n }, [sent]);\n return (\n <Tooltip text={input.tip}>\n <FieldBox>\n <SelectField\n {...rest}\n ref={forwardedRef}\n value={asked ?? value}\n {...input.edge}\n onChange={(e) => {\n if (input.inert) return;\n setAsked(e.target.value);\n input.send(e.target.value);\n }}\n >\n {children}\n </SelectField>\n <FieldWord aria-hidden=\"true\">{input.word}</FieldWord>\n <LiveRegion visuallyHidden>{input.announce}</LiveRegion>\n </FieldBox>\n </Tooltip>\n );\n}\n\n/**\n * A native `<textarea>` in the kit's field style, full width, resizable\n * vertically only. Useful for a multi-line value the operator types or pastes.\n * Used by the log manager and the serial calibration wizard.\n *\n * @category Form\n */\nexport const Textarea = styled.textarea`\n ${inputBase}\n width: 100%;\n resize: vertical;\n`;\n","import {\n type AnyBoundCommand,\n bindCommand,\n type ValueCommand,\n} from \"@ksp-gonogo/sitrep-sdk\";\nimport { useRailAnnounces } from \"../CommandDelay/railAnnouncer\";\nimport { describeSendStatus } from \"../SendStatus/describeSendStatus\";\nimport { predictedOutcomeOf } from \"../SendStatus/predictedOutcome\";\nimport {\n type BoundControlCommand,\n type CommandControlState,\n FOUND_WORD,\n LOST_WORD,\n REFUSED_WORD,\n SENT_WORD,\n STREAM_DOWN_TIP,\n useCommandControl,\n} from \"./commandControl\";\n\n/** The data attributes a command input wears so its edge shows what became of the command. */\nexport interface CommandEdgeAttributes {\n \"data-command-edge\"?: \"warn\" | \"blocked\";\n \"data-command-phase\": string;\n \"data-stream\"?: \"down\";\n \"data-predicted\"?: string;\n \"aria-disabled\"?: true;\n}\n\n/** What {@link useCommandInput} returns: the control, the word and tip to draw, and the attributes that carry the edge. */\nexport interface CommandInputState<Value> {\n /** The control underneath, for a face that needs a phase this state does not name. */\n control: CommandControlState;\n /** Sends the command with this value, unless the input is inert. */\n send: (value: Value) => void;\n /** The word the input draws in place of its figure while the press is unanswered or lost: \"SENT\", \"Refused\", \"No reply\" or \"Found\". Null at rest. */\n word: string | null;\n /** What the input says on hover and keyboard focus: the outcome or the reason it cannot be used, else the send status. Undefined when there is nothing to say. */\n tip: string | undefined;\n /** A press sends nothing now: the game will refuse it, the caller said it cannot be used, or the stream is down. */\n inert: boolean;\n /** The attributes that draw the edge. */\n edge: CommandEdgeAttributes;\n /** The outcome sentence for a live region, when this input's own region should speak it. */\n announce: string | null;\n}\n\n/**\n * The shared state of every command input other than a button: the phase of the\n * command it sends, the word for it, the tip and the edge. Used by the inputs of\n * the kit that take a `command` prop.\n */\nexport function useCommandInput<Value>({\n command,\n unavailable,\n advise,\n}: {\n // biome-ignore lint/suspicious/noExplicitAny: a value command of any argument and reply types\n command: ValueCommand<Value, any, any>;\n unavailable?: string | null;\n advise?: string | null;\n}): CommandInputState<Value> {\n const control = useCommandControl({\n command: {\n kind: \"bound\",\n handle: command.handle,\n args: undefined,\n options: command.options,\n },\n unavailable,\n advise,\n });\n const railSpeaks = useRailSpeaks(control);\n const inert =\n control.isBlocked ||\n control.isUnavailable ||\n control.isOffline ||\n unavailable != null;\n return inputState(\n control,\n inert,\n railSpeaks,\n (value) => {\n if (inert) return;\n const args = command.toArgs(value);\n if (args === undefined) return;\n control.pressWith(\n bindCommand(\n command.handle,\n args,\n command.options,\n ) as BoundControlCommand,\n );\n },\n unavailable ?? null,\n );\n}\n\n/**\n * The same state for an input that sends a command it already has the arguments\n * of, such as a row or a menu item.\n */\nexport function useBoundCommandInput({\n command,\n unavailable,\n advise,\n}: {\n command: AnyBoundCommand;\n unavailable?: string | null;\n advise?: string | null;\n}): CommandInputState<void> {\n const control = useCommandControl({ command, unavailable, advise });\n const railSpeaks = useRailSpeaks(control);\n const inert =\n control.isBlocked ||\n control.isUnavailable ||\n control.isOffline ||\n unavailable != null;\n return inputState(\n control,\n inert,\n railSpeaks,\n () => {\n if (inert) return;\n control.press(false);\n },\n unavailable ?? null,\n );\n}\n\nfunction inputState<Value>(\n control: CommandControlState,\n inert: boolean,\n railSpeaks: boolean,\n send: (value: Value) => void,\n unavailable: string | null,\n): CommandInputState<Value> {\n const handle = control.command.handle;\n const gated = control.isBlocked && !control.isUnavailable;\n const word = control.isSent\n ? SENT_WORD\n : control.isRefused\n ? REFUSED_WORD\n : control.isLost\n ? LOST_WORD\n : control.isFound\n ? FOUND_WORD\n : null;\n const sendStatus = handle.sendStatus;\n const restTip =\n sendStatus === undefined ? undefined : describeSendStatus(sendStatus);\n const outcome =\n control.foundText ??\n control.refusalText ??\n (control.isLost ? control.lossText : null);\n const tip =\n outcome ??\n (control.isSent\n ? \"Sent, not yet received\"\n : control.isOffline\n ? STREAM_DOWN_TIP\n : (unavailable ??\n ([control.adviceText, restTip].filter(Boolean).join(\"\\n\") ||\n undefined)));\n return {\n control,\n send,\n word,\n tip: tip ?? undefined,\n inert,\n edge: {\n \"data-command-edge\": gated\n ? \"blocked\"\n : control.isLost ||\n control.isRefused ||\n control.hasUnconfirmed ||\n control.hasFailure\n ? \"warn\"\n : undefined,\n \"data-command-phase\": control.phase,\n \"data-stream\": control.isOffline ? \"down\" : undefined,\n \"data-predicted\": gated\n ? undefined\n : (predictedOutcomeOf(sendStatus) ??\n (control.isAdvised ? \"at-risk\" : undefined)),\n \"aria-disabled\": inert ? true : undefined,\n },\n // A mounted rail that carries this command already speaks what became of it.\n announce: railSpeaks\n ? null\n : (outcome ?? (control.isSent ? \"Sent, not yet received\" : null)),\n };\n}\n\n/** Whether a rail on screen already speaks this input's outcomes, so the input's own region stays quiet. */\nexport function useRailSpeaks(control: CommandControlState): boolean {\n const mounted = useRailAnnounces();\n return mounted && control.command.handle.railed === true;\n}\n","import { css } from \"styled-components\";\n\n/**\n * The edge of a command input that shows what became of its command, for an\n * element that draws a border: warning colour after a refusal or no reply, a\n * dashed warning edge when the game will refuse the press, a dotted dim one\n * when the stream is down, and a dashed edge for a predicted result. Only the\n * line style and colour change, never the width, so the box keeps its size.\n */\nexport const commandEdge = css`\n &[data-command-edge=\"warn\"] {\n border-color: var(--color-warn-mark);\n }\n &[data-command-edge=\"blocked\"] {\n border-style: dashed;\n border-color: var(--color-warn-mark);\n opacity: 0.5;\n }\n &[data-stream=\"down\"] {\n opacity: 0.5;\n border-style: dotted;\n }\n &[data-predicted=\"held\"] {\n border-style: dashed;\n border-color: var(--color-go-mark);\n }\n &[data-predicted=\"at-risk\"] {\n border-style: dashed;\n border-color: color-mix(\n in srgb,\n var(--color-warn-mark) 65%,\n var(--color-surface-raised)\n );\n }\n &[aria-disabled=\"true\"] {\n cursor: not-allowed;\n }\n`;\n\n/**\n * The same edge for an element with no border of its own, a row or a slider's\n * track, drawn as an outline inside the box so its size and its neighbours never\n * move. Spelled with the longhands, since these are state edges and not focus rings.\n */\nexport const commandOutlineEdge = css`\n &[data-command-edge=\"warn\"] {\n outline-width: 1px;\n outline-style: solid;\n outline-color: var(--color-warn-mark);\n outline-offset: -1px;\n }\n &[data-command-edge=\"blocked\"] {\n outline-width: 1px;\n outline-style: dashed;\n outline-color: var(--color-warn-mark);\n outline-offset: -1px;\n opacity: 0.5;\n }\n &[data-stream=\"down\"] {\n opacity: 0.5;\n outline-width: 1px;\n outline-style: dotted;\n outline-color: currentColor;\n outline-offset: -1px;\n }\n &[data-predicted=\"held\"] {\n outline-width: 1px;\n outline-style: dashed;\n outline-color: var(--color-go-mark);\n outline-offset: -1px;\n }\n &[data-predicted=\"at-risk\"] {\n outline-width: 1px;\n outline-style: dashed;\n outline-color: color-mix(\n in srgb,\n var(--color-warn-mark) 65%,\n var(--color-surface-raised)\n );\n outline-offset: -1px;\n }\n &[aria-disabled=\"true\"] {\n cursor: not-allowed;\n }\n`;\n","import type { HTMLAttributes, ReactNode } from \"react\";\nimport styled from \"styled-components\";\nimport { GAP_VAR, type GapToken } from \"./scales\";\nimport type { StaticElement } from \"./staticElement\";\n\n/**\n * Props for {@link Stack}. Any other `div` attribute passes through. Useful for\n * stacking a widget's rows so the operator reads them in order. Taken by\n * {@link Stack}.\n *\n * @category Layout\n */\nexport interface StackProps extends HTMLAttributes<HTMLDivElement> {\n /**\n * Gap between children, one of the {@link GapToken} names. Omitted, the\n * stack takes the `related` gap of whatever container it sits in, so the\n * same stack is 8px on a panel and 6px inside a card. Set it only where this\n * stack decides the spacing of what it holds.\n */\n gap?: GapToken;\n /** Rendered tag. Defaults to `div`. */\n as?: StaticElement;\n /**\n * Take the remaining space in a flex parent and allow shrinking below the\n * content's natural height, so a scrolling region inside the stack scrolls\n * rather than growing the whole column.\n */\n fill?: boolean;\n /** The items, laid out top to bottom. */\n children?: ReactNode;\n}\n\n/**\n * A vertical flex column, the most common container shape in a widget body.\n * Children sit one above the other with the container's related gap between\n * them unless `gap` names another. Useful for stacking a widget's rows so the\n * operator reads them in order. Used by the space centre status and the\n * settings. A row that spans the container is a\n * {@link Cluster}; a compact run of badges or buttons that sits within a line is\n * an {@link Inline}.\n *\n * The layout primitives compose: a {@link Stack} of sections, a\n * {@link Cluster} for a label beside its controls, a {@link Grid} for a\n * label/value table, and a {@link Box} for an inset well.\n *\n * @example\n * `gap=\"section\"` sets the three blocks further apart than the default\n * `related` gap would.\n * ```tsx\n * import { Box, Button, Cluster, Grid, Inline, Stack, Text } from \"@ksp-gonogo/ui-kit\";\n *\n * function TargetBody(props: {\n * apoapsis: string;\n * periapsis: string;\n * notes: string;\n * onSet: () => void;\n * onClear: () => void;\n * }) {\n * return (\n * <Stack gap=\"section\">\n * <Cluster>\n * <Text>Target</Text>\n * <Inline>\n * <Button onClick={props.onSet}>Set</Button>\n * <Button onClick={props.onClear}>Clear</Button>\n * </Inline>\n * </Cluster>\n * <Grid cols=\"auto 1fr\" gap=\"label-value\" rowGap=\"readout-row\" align=\"baseline\">\n * <Text level=\"muted\">Apoapsis</Text>\n * <Text>{props.apoapsis}</Text>\n * <Text level=\"muted\">Periapsis</Text>\n * <Text>{props.periapsis}</Text>\n * </Grid>\n * <Box surface=\"sunken\" pad=\"surface\" radius=\"regular\">\n * {props.notes}\n * </Box>\n * </Stack>\n * );\n * }\n * ```\n *\n * @category Layout\n */\nexport function Stack({ gap, fill = false, children, ...rest }: StackProps) {\n return (\n <Stack__Root $gap={gap} $fill={fill} {...rest}>\n {children}\n </Stack__Root>\n );\n}\n\nconst Stack__Root = styled.div<{ $gap?: GapToken; $fill: boolean }>`\n display: flex;\n flex-direction: column;\n gap: ${({ $gap }) => ($gap ? GAP_VAR[$gap] : \"var(--gap-related)\")};\n ${({ $fill }) => ($fill ? \"flex: 1; min-height: 0;\" : \"\")}\n\n /* Rendered as a list it is still a layout box: the browser's own list indent, margin and bullets would shift and squeeze its rows. Zero specificity, so a caller's own rule still wins. */\n &:where(ul, ol) {\n margin: 0;\n padding: 0;\n list-style: none;\n }\n`;\n","/**\n * The spacing and corner names the layout primitives resolve a prop against.\n *\n * Each is a handle onto a semantic token in `tokens.css`, not a value of its\n * own, so a host restyles the kit by mounting a sheet rather than by passing a\n * scale in. That keeps geometry out of the theme contract: a theme supplies\n * colours, type and borders, and the kit brings its own spacing.\n */\n\n/**\n * The spacing names a layout primitive's `gap`, `rowGap` or `space` prop\n * accepts. Each names what the space is for, and resolves to the `--gap-*`\n * CSS variable of the same name. Useful for spacing a widget's content the same\n * way on every tile the operator reads. Taken by {@link Stack}, {@link Grid}\n * and the other layout primitives.\n *\n * - `related` and `section`: between related items, and between sections:\n * 8px and 16px on a panel, 6px and 12px inside a {@link Card}\n * - `related-comfortable` (8px), `related-compact` (6px), `related-dense`\n * (4px), `related-packed` (2px), `section-comfortable` (16px) and\n * `section-compact` (12px): the same two spacings at one fixed density,\n * whatever the container\n * - `rows` (2px): between stacked rows that carry their own padding\n * - `caption` (2px): under the line a caption belongs to\n * - `readout-row` (2px) and `label-value` (8px): between the rows and between\n * the columns of a label/value grid\n *\n * The pixel values are the default sheet's; a host that mounts its own sheet\n * may change them.\n *\n * @category Layout\n */\nexport type GapToken =\n | \"related\"\n | \"section\"\n | \"related-comfortable\"\n | \"related-compact\"\n | \"related-dense\"\n | \"related-packed\"\n | \"section-comfortable\"\n | \"section-compact\"\n | \"rows\"\n | \"caption\"\n | \"readout-row\"\n | \"label-value\";\n\nexport const GAP_VAR = {\n related: \"var(--gap-related)\",\n section: \"var(--gap-section)\",\n \"related-comfortable\": \"var(--gap-related-comfortable)\",\n \"related-compact\": \"var(--gap-related-compact)\",\n \"related-dense\": \"var(--gap-related-dense)\",\n \"related-packed\": \"var(--gap-related-packed)\",\n \"section-comfortable\": \"var(--gap-section-comfortable)\",\n \"section-compact\": \"var(--gap-section-compact)\",\n rows: \"var(--gap-rows)\",\n caption: \"var(--gap-caption)\",\n \"readout-row\": \"var(--gap-readout-row)\",\n \"label-value\": \"var(--gap-label-value)\",\n} as const satisfies Record<GapToken, string>;\n\n/**\n * The padding names {@link Box}'s `pad` prop accepts, each resolving to the\n * `--inset-*` CSS variable of the same name. Useful for padding a pill, a block\n * or a floating card the same way everywhere the operator sees one. Given here\n * as vertical then horizontal padding in the default sheet:\n *\n * - `chip` (1px 6px), `chip-roomy` (1px 8px) and `chip-readout` (2px 8px):\n * small pills\n * - `pill` (6px 12px): a stadium\n * - `surface` (6px 8px) and `surface-standalone` (10px 12px): a block's own\n * padding\n * - `popover` (8px all round): a floating card\n *\n * @category Layout\n */\nexport type InsetToken =\n | \"chip\"\n | \"chip-roomy\"\n | \"chip-readout\"\n | \"pill\"\n | \"surface\"\n | \"surface-standalone\"\n | \"popover\";\n\nexport const INSET_NAME = {\n chip: \"--inset-chip\",\n \"chip-roomy\": \"--inset-chip-roomy\",\n \"chip-readout\": \"--inset-chip-readout\",\n pill: \"--inset-pill\",\n surface: \"--inset-surface\",\n \"surface-standalone\": \"--inset-surface-standalone\",\n popover: \"--inset-popover\",\n} as const satisfies Record<InsetToken, `--inset-${string}`>;\n\n/**\n * The corner roundings a surface primitive accepts: `regular` for an ordinary\n * corner, `floating` for a corner on something floating above the app, and\n * `pill` for a stadium. Useful for rounding a surface the same way everywhere\n * the operator sees one. The corner of {@link FramedDisplay} belongs to it\n * alone, and `circle` is not a corner.\n */\nexport type RadiusToken = \"regular\" | \"floating\" | \"pill\";\n\nexport const RADIUS_VAR = {\n /** Every ordinary corner: controls, chips, rows, cells, cards, menus. */\n regular: \"var(--radius-regular)\",\n /** A box that sits above the app: a modal, a dialog, the FAB, the landing surface. */\n floating: \"var(--radius-floating)\",\n /** Fully rounded: chips, avatars, toggle knobs. */\n pill: \"var(--radius-pill)\",\n} as const satisfies Record<RadiusToken, string>;\n","import { createContext, type ReactNode, useContext, useMemo } from \"react\";\n\n/*\n * Augment settings are a framework capability: any augment may declare them,\n * the values live in the HOST WIDGET INSTANCE's config under\n * `augmentSettings[<augmentId>]`, the host provides once and any augment reads\n * with a hook, so segment slots stay propless.\n */\n\n/**\n * What {@link AugmentSettingsProvider} publishes: the widget instance's saved\n * augment settings and a writer for them.\n * Useful for letting an augment show and change what the operator chose for it\n * on one widget. Used by {@link AugmentSettingsProvider} and read by {@link\n * useAugmentSettings}.\n *\n * @category Extensions\n */\nexport interface AugmentSettingsContextValue {\n /**\n * The host widget instance's saved per-augment settings, keyed\n * `[augmentId][fieldKey]`: the same namespacing {@link getAugmentSettings} and\n * {@link AugmentSettingsPanel} use. `undefined` for a field nothing has saved yet,\n * so an augment falls back to its own declared `default`.\n */\n settings: Record<string, Record<string, unknown>> | undefined;\n /**\n * Persists one field of one augment's settings into the host widget\n * instance's own config, the same place the settings panel writes, so a\n * quick toggle in an `actions` augment and the settings panel always agree.\n */\n setAugmentSetting: (augmentId: string, key: string, value: unknown) => void;\n}\n\nconst AugmentSettingsContext =\n createContext<AugmentSettingsContextValue | null>(null);\n\n/**\n * The augment settings of a widget instance, stored in its config under\n * `augmentSettings[<augmentId>]`, published to the augments rendered inside it.\n * Useful for letting an augment read what the operator chose for it on this\n * widget. Used by the dashboard, which mounts one around every widget. Outside\n * the dashboard there is none, and {@link useAugmentSettings} reads empty\n * values.\n *\n * @category Extensions\n */\nexport function AugmentSettingsProvider({\n settings,\n setAugmentSetting,\n children,\n}: AugmentSettingsContextValue & { children?: ReactNode }) {\n const value = useMemo(\n () => ({ settings, setAugmentSetting }),\n [settings, setAugmentSetting],\n );\n return (\n <AugmentSettingsContext.Provider value={value}>\n {children}\n </AugmentSettingsContext.Provider>\n );\n}\n\n/**\n * One augment's own settings for the widget instance it is rendered in, plus a\n * writer scoped to that augment. Useful for an augment that lets the operator\n * tune it per widget. Pass the `id` the augment was registered with. A field\n * nothing has saved is missing from `values`, so fall back to the field's\n * declared `default`.\n *\n * Outside an {@link AugmentSettingsProvider} the values read empty and `set`\n * does nothing, the same as an operator having saved nothing.\n *\n * @example\n * ```tsx\n * function CompactToggle() {\n * const { values, set } = useAugmentSettings(\"example-cadence-section\");\n * const compact = values.compact === true;\n * return <Switch checked={compact} onChange={(v) => set(\"compact\", v)} label=\"Compact\" />;\n * }\n * ```\n *\n * @category Extensions\n */\nexport function useAugmentSettings(augmentId: string): {\n /** This augment's saved fields; empty when nothing has been saved. */\n values: Record<string, unknown>;\n /** Persists one of this augment's fields into the host widget's config. */\n set: (key: string, value: unknown) => void;\n} {\n const ctx = useContext(AugmentSettingsContext);\n const settings = ctx?.settings;\n const setAugmentSetting = ctx?.setAugmentSetting;\n return useMemo(\n () => ({\n values: settings?.[augmentId] ?? EMPTY_VALUES,\n set: (key: string, value: unknown) =>\n setAugmentSetting?.(augmentId, key, value),\n }),\n [settings, setAugmentSetting, augmentId],\n );\n}\n\n/**\n * The whole per-augment settings map for the current widget instance, keyed\n * `[augmentId][fieldKey]`, or `undefined` outside a provider or before\n * anything is saved. Useful for a widget reasoning across all its augments,\n * such as drawing its settings panel or showing only the layers the operator\n * switched on.\n *\n * @category Extensions\n */\nexport function useAllAugmentSettings():\n | Record<string, Record<string, unknown>>\n | undefined {\n return useContext(AugmentSettingsContext)?.settings;\n}\n\nconst EMPTY_VALUES: Record<string, unknown> = Object.freeze({});\n","import type {\n AugmentDefinition,\n NamespacedAugmentSettings,\n SlotProps,\n} from \"@ksp-gonogo/sitrep-sdk\";\nimport { hasHost, logger } from \"@ksp-gonogo/sitrep-sdk\";\nimport { assertSizeDelta } from \"@ksp-gonogo/sitrep-sdk/spine\";\nimport type { ComponentType } from \"react\";\n\n/*\n * Widgets expose named augment slots, any Uplink contributes a component into a\n * slot using only its own Topics, and the host composes. Two mutually unaware\n * mods binding the same slot both render, ordered by priority.\n *\n * Slot ids are typed by declaration merging into `SlotRegistry`, which maps\n * a slot id to the props it passes down. An undeclared slot id still compiles.\n * The seam is the sdk's, re-exported, so a merge into either package lands on\n * the same interface; declaring it in both would split slot ids across two\n * interfaces with nothing failing.\n */\nexport type {\n SlotId,\n SlotProps,\n SlotRegistry,\n} from \"@ksp-gonogo/sitrep-sdk\";\n\n/**\n * The standard augment segments every widget's {@link Panel} carries, each\n * mapped to the props its augments receive. A segment's slot id is\n * `\"<widget-id>.<segment>\"`. Both pass no props (`Record<string, never>`): an\n * augment reads its own Topics, and reads what the widget is focused on\n * through {@link useWidgetScope}. Useful for typing an augment that adds\n * content or controls to a widget's panel. Where each renders is under\n * Standard slots on {@link Panel}.\n *\n * @category Panel\n */\nexport interface AugmentSegmentRegistry {\n /** Body content after everything the widget draws, in the slot `\"<widget-id>.sections\"`. */\n sections: Record<string, never>;\n /** Controls in the widget's panel header, in the slot `\"<widget-id>.actions\"`. */\n actions: Record<string, never>;\n}\n\n/**\n * The props an augment bound to a standard segment receives, looked up in\n * {@link AugmentSegmentRegistry}: `Record<string, never>` for `sections` and\n * `actions`, and `never` for a name that is not a standard segment. Useful for typing the\n * props of an augment placed in a widget's `sections` or `actions` segment. Used\n * by {@link AugmentSlot} for a slot named by `segment`.\n *\n * @category Panel\n */\nexport type AugmentSegmentProps<Segment extends string> =\n Segment extends keyof AugmentSegmentRegistry\n ? AugmentSegmentRegistry[Segment]\n : never;\n\n/*\n * `AugmentSettingField` is one per-instance setting an augment contributes to\n * the host widget's settings panel, namespaced by augment id;\n * `NamespacedAugmentSettings` is one augment's block of them.\n */\n/**\n * Registration descriptor for an augment: a component bound into another\n * widget's slot. `Slot` is inferred from `augments`, so `component` is typed\n * against that slot's {@link SlotProps}.\n */\nexport type {\n AugmentDefinition,\n AugmentSettingField,\n NamespacedAugmentSettings,\n} from \"@ksp-gonogo/sitrep-sdk\";\n\n// `SlotProps<string>` would resolve to `never` for an undeclared slot, so the props are erased here and `Slot` is checked at the `registerAugment` call site instead.\n/**\n * An augment as the registry holds it, whatever slot it binds: an\n * `AugmentDefinition` whose component takes a loose props object. The lookup\n * functions ({@link getAugmentsForSlot}, {@link getAugments}) return this.\n * Useful for code that lists what Uplinks have added to a widget. Used by\n * {@link AugmentSlot} and {@link useAugmentAvailable}.\n *\n * @category Extensions\n */\nexport type AnyAugment = Omit<AugmentDefinition<string>, \"component\"> & {\n /** The augment's component, with its slot props erased to a plain record. */\n component: ComponentType<Record<string, unknown>>;\n};\n\n/**\n * The registry lives on `globalThis` under a string key so every loaded copy of\n * this package (an Uplink that inlines ui-kit loads a second) shares one state.\n */\nconst AUGMENT_REGISTRY_KEY = \"__GONOGO_AUGMENT_REGISTRY__\" as const;\n\ninterface AugmentRegistry {\n augments: Map<string, { def: AnyAugment; order: number }>;\n /** Registration order, so ties in `priority` sort deterministically. */\n counter: number;\n listeners: Set<() => void>;\n}\n\nfunction registry(): AugmentRegistry {\n const slot = globalThis as typeof globalThis & {\n [AUGMENT_REGISTRY_KEY]?: AugmentRegistry;\n };\n slot[AUGMENT_REGISTRY_KEY] ??= {\n augments: new Map(),\n counter: 0,\n listeners: new Set(),\n };\n return slot[AUGMENT_REGISTRY_KEY];\n}\n\n/**\n * Slot ids that no widget mounts any more, each mapped to the slot that\n * replaced it. {@link registerAugment} logs an error naming the replacement\n * when an augment binds one of these; the augment is stored but never renders.\n * A misspelled slot id is not detected at runtime. Useful for telling an\n * Uplink author that a slot they bind no longer exists and which slot to use\n * instead.\n *\n * @category Extensions\n */\nexport const RETIRED_SLOT_IDS: Readonly<Record<string, string>> = {\n \"distance-to-target.camera\": \"rendezvous.camera\",\n \"distance-to-target.overlay\": \"rendezvous.overlay\",\n \"targeting.camera\": \"rendezvous.camera\",\n \"targeting.overlay\": \"rendezvous.overlay\",\n \"astronaut-complex.training\": \"astronaut-complex.tab\",\n};\n\n/** Reports a retired slot id. Falls back to `console.error` without a host, because the sdk's `logger` throws when none is installed. */\nfunction reportIfSlotRetired(\n def: Pick<AugmentDefinition<string>, \"id\" | \"augments\" | \"owner\">,\n): void {\n const replacement = RETIRED_SLOT_IDS[def.augments];\n if (!replacement) return;\n const owner = def.owner ? `${def.owner.name} (${def.owner.id})` : \"unknown\";\n const message =\n `Augment \"${def.id}\" binds retired slot \"${def.augments}\", ` +\n `renamed to \"${replacement}\"; it will render nothing until updated. ` +\n `Registered by Uplink: ${owner}`;\n if (hasHost()) logger.error(message);\n else console.error(message);\n}\n\nfunction notifyAugmentChange(): void {\n for (const cb of registry().listeners) cb();\n}\n\n/**\n * Calls `cb` whenever an augment is registered or the registry is cleared.\n * Returns a function that unsubscribes. Useful for a widget that must redraw\n * when an Uplink adds content after the widget has mounted. Used by\n * {@link AugmentSlot} and by the ground track widget's base layer list.\n *\n * @category Extensions\n */\nexport function onAugmentsChange(cb: () => void): () => void {\n registry().listeners.add(cb);\n return () => {\n registry().listeners.delete(cb);\n };\n}\n\n/**\n * Registers an augment into a widget's slot. Call it at module load, like\n * `registerComponent`. Several augments may bind one slot; they all render,\n * ordered by `priority`. Registering an id again replaces the earlier augment.\n * `component` is typed against the slot's props in {@link SlotRegistry}.\n * Useful for adding content from an Uplink to a widget the operator already\n * has on the dashboard.\n *\n * An Uplink calls the `registerAugment` exported by `@ksp-gonogo/sitrep-sdk`,\n * which reaches this registry through the host. For binding a widget's\n * standard `sections` or `actions` slot, see {@link Panel}.\n *\n * @category Extensions\n */\nexport function registerAugment<Slot extends string>(\n def: AugmentDefinition<Slot>,\n): void {\n reportIfSlotRetired(def);\n assertSizeDelta(def.id, def.sizeDelta);\n const state = registry();\n state.augments.set(def.id, {\n // Erased through `unknown`: a merged `SlotProps<Slot>` is not bivariantly comparable to the erased form.\n def: def as unknown as AnyAugment,\n order: state.counter++,\n });\n notifyAugmentChange();\n}\n\n/**\n * Every augment bound to `slotName`, in render order: ascending `priority`\n * (default 0), ties in registration order. It includes augments whose\n * `requires` Domain is absent; {@link AugmentSlot} applies that gate when it\n * renders. Useful for a widget that needs to know what Uplinks add to a slot\n * before it draws. Used by {@link AugmentSlot} and by the ground track widget when it\n * paints its base layers.\n *\n * @category Extensions\n */\nexport function getAugmentsForSlot(slotName: string): AnyAugment[] {\n return Array.from(registry().augments.values())\n .filter((entry) => entry.def.augments === slotName)\n .sort((a, b) => {\n const pa = a.def.priority ?? 0;\n const pb = b.def.priority ?? 0;\n if (pa !== pb) return pa - pb;\n return a.order - b.order;\n })\n .map((entry) => entry.def);\n}\n\n/**\n * Every registered augment, in no particular order. Useful for listing what\n * Uplinks have added across all widgets. Used by the app's feeder that reports\n * which Domains an augment needs.\n *\n * @category Extensions\n */\nexport function getAugments(): AnyAugment[] {\n return Array.from(registry().augments.values()).map((entry) => entry.def);\n}\n\n/**\n * One settings block for each augment bound to `slotName` that declares\n * `settings`, in render order. The host widget's settings panel shows these\n * after its own settings; each block's `namespace` (the augment id) scopes its\n * fields in the widget instance's config. An Uplink that is not loaded adds no\n * block. Useful for showing the operator the settings Uplinks add to a widget.\n * Used by the ground track widget's configuration form, which hands the result to\n * {@link AugmentSettingsPanel}.\n *\n * @category Extensions\n */\nexport function getAugmentSettings(\n slotName: string,\n): NamespacedAugmentSettings[] {\n return getAugmentsForSlot(slotName)\n .filter((def) => def.settings && def.settings.length > 0)\n .map((def) => ({\n augmentId: def.id,\n namespace: def.id,\n fields: def.settings ?? [],\n }));\n}\n\n/**\n * Empties the augment registry and notifies subscribers. For tests only.\n *\n * @category Extensions\n */\nexport function clearAugments(): void {\n const state = registry();\n state.augments.clear();\n state.counter = 0;\n notifyAugmentChange();\n}\n","import { useSyncExternalStore } from \"react\";\nimport { createPanelStore } from \"./store/createPanelStore\";\n\n/*\n * The augment presence gate asks whether an augment's Domain is live. It reads\n * a ui-kit-owned store rather than telemetry, so ui-kit takes no spine\n * dependency; the host feeds `<domain>.available` into it. With no provider\n * mounted, a Domain nothing has announced is not available.\n */\n\n/**\n * A store of which Domains are present, keyed by Domain id (the value an\n * augment or contribution names in `requires`). Augment slots read it to decide\n * what to render, and re-render only when it changes. Useful for showing the\n * operator only the extensions whose Domains are present. Read by the augment\n * slots and fed by the app's augment availability feeder.\n *\n * @category Extensions\n */\nexport interface DomainAvailabilityStore {\n /** Marks a Domain available or unavailable. Does nothing, and notifies no one, when the value is unchanged. */\n setAvailable(domain: string, available: boolean): void;\n /** Whether `domain` has announced availability. `false` for an unknown Domain. */\n isAvailable(domain: string): boolean;\n /** Calls `onChange` on any availability change. Returns a function that unsubscribes. */\n subscribe(onChange: () => void): () => void;\n}\n\n/**\n * Creates an empty {@link DomainAvailabilityStore}, in which every Domain reads\n * as unavailable until marked otherwise. Useful for seeding which Domains are\n * present, so the operator sees the augments that need them, through\n * {@link DomainAvailabilityContext}.\n *\n * @category Extensions\n */\nexport function createDomainAvailabilityStore(): DomainAvailabilityStore {\n const availability = new Map<string, boolean>();\n const listeners = new Set<() => void>();\n return {\n setAvailable(domain, available) {\n // A feeder re-emitting the same presence wakes no reader.\n if (availability.get(domain) === available) return;\n availability.set(domain, available);\n for (const listener of listeners) listener();\n },\n isAvailable(domain) {\n return availability.get(domain) ?? false;\n },\n subscribe(onChange) {\n listeners.add(onChange);\n return () => {\n listeners.delete(onChange);\n };\n },\n };\n}\n\nconst DomainAvailabilityPanelStore = createPanelStore(\n createDomainAvailabilityStore,\n);\n\n/**\n * The React context holding the nearest {@link DomainAvailabilityStore}, or\n * `null`, in which case every Domain reads as unavailable. Provide a store\n * from {@link createDomainAvailabilityStore} through it to seed presence in a\n * test; otherwise use {@link DomainAvailabilityProvider}. Useful for showing\n * the operator only the augments whose Domain is present.\n *\n * @intent Published so a test can seed which Domains are present for the widget under test.\n * @category Extensions\n */\nexport const DomainAvailabilityContext = DomainAvailabilityPanelStore.Context;\n\n/**\n * Creates one {@link DomainAvailabilityStore} and provides it for as long as it\n * is mounted. Useful for letting widgets show or hide augments by whether the\n * Domain behind them is available. Used by the app, which mounts one near the\n * root and feeds it from each Domain's `<domain>.available` Topic.\n *\n * @category Extensions\n */\nexport const DomainAvailabilityProvider = DomainAvailabilityPanelStore.Provider;\n\n/**\n * The nearest {@link DomainAvailabilityStore}, or `null` outside a provider.\n * Useful for feeding which Domains are present into the store. Used by the\n * app's augment availability feeder.\n *\n * @category Extensions\n */\nexport const useDomainAvailabilityStore = DomainAvailabilityPanelStore.useStore;\n\n// Stable fallbacks for `useSyncExternalStore` with no provider in the tree.\nconst NO_SUBSCRIBE = (): (() => void) => () => {};\n\n/**\n * Whether `domain`'s Domain is currently available, read reactively from the\n * nearest {@link DomainAvailabilityStore}. `undefined`, a Domain nothing has\n * announced, and a tree with no store all read `false`. Useful for showing the\n * operator an augment only while its Domain is present. Used by\n * {@link AugmentSlot}.\n */\nexport function useDomainAvailable(domain: string | undefined): boolean {\n const store = useDomainAvailabilityStore();\n const snapshot = (): boolean =>\n store && domain ? store.isAvailable(domain) : false;\n return useSyncExternalStore(\n store ? store.subscribe : NO_SUBSCRIBE,\n snapshot,\n snapshot,\n );\n}\n","import {\n type CapabilityLock,\n LockScopeContext,\n lockSentence,\n useLockScope,\n} from \"@ksp-gonogo/sitrep-sdk/spine\";\nimport type { ReactElement, ReactNode } from \"react\";\nimport { InactiveNotice } from \"./InactiveNotice\";\nimport { writeLockQuantity } from \"./lockQuantity\";\n\n/**\n * What a locked {@link LockScope} hands its `fallback`: the sentence every lock\n * notice reads, and the locks behind it. Useful for telling the operator which\n * technology or building is still needed. Used by the guard that replaces a\n * widget whose required Topics are locked.\n *\n * @category Panel\n */\nexport interface LockSummary {\n /** \"Missing tech: Flight Control\", or a building's name such as \"Mission Control\". */\n reason: string;\n /** \"45 science to research\", or \"Needs level 2\". */\n hint?: string;\n /** Every lock the summary was made from. Each is `{ capability, missing, detail? }`: the capability that is locked, the unlocks it still needs, and a sentence for when it names none. */\n locks: readonly CapabilityLock[];\n}\n\n/**\n * Props for {@link LockScope}. Useful for telling the operator what is still\n * locked in place of a part of a widget that cannot work. Taken by\n * {@link LockScope}.\n *\n * @category Panel\n */\nexport interface LockScopeProps {\n /** The content the scope guards, drawn while nothing used inside it is locked. */\n children?: ReactNode;\n /**\n * What draws in place of `children` while something used inside the scope\n * is not unlocked in this save. Given a function, it is called with the\n * {@link LockSummary}. Defaults to a centred notice of the reason; `null`\n * draws nothing, for a scope that is an overlay or a badge.\n */\n fallback?: ReactNode | ((lock: LockSummary) => ReactNode);\n}\n\n/**\n * Marks a part of the tree that stands or falls together. When anything\n * inside it reads a Topic (with `useTelemetry` or `useStream`) or uses a\n * command (with `useCommand`) that this save has not unlocked (a technology\n * not yet researched, or a building not yet upgraded, in a career save), the\n * whole scope is replaced by its `fallback`. Useful for telling the operator\n * what is still locked instead of showing a part of a widget that cannot work.\n * Used by {@link Section} and {@link AugmentSlot}, and by the guard around a\n * widget's required Topics.\n *\n * The innermost scope wins, so a scope inside a section is replaced while the\n * section stays. It draws no element of its own. A {@link Section}, each\n * augment an {@link AugmentSlot} renders, and every widget as a whole are lock\n * scopes already; wrap anything else that should be replaced on its own.\n *\n * @category Panel\n */\nexport function LockScope({\n children,\n fallback,\n}: LockScopeProps): ReactElement {\n const { scope, locks } = useLockScope();\n if (locks.length > 0) {\n const summary: LockSummary = {\n ...lockSentence(locks, writeLockQuantity),\n locks,\n };\n const drawn =\n fallback === undefined ? (\n <InactiveNotice reason={summary} />\n ) : typeof fallback === \"function\" ? (\n fallback(summary)\n ) : (\n fallback\n );\n return <>{drawn}</>;\n }\n return (\n <LockScopeContext.Provider value={scope}>\n {children}\n </LockScopeContext.Provider>\n );\n}\n","import styled from \"styled-components\";\n\n/**\n * Why a panel or section has nothing to show: the reason as one line, or the\n * reason plus a hint at what would bring it back. Useful for telling the\n * operator why a part of the screen is empty and what would change that. Taken\n * by the `inactive` prop of {@link Panel} and {@link Section}.\n *\n * @category Panel\n */\nexport type PanelInactiveReason =\n | string\n | {\n /** Why the panel is inactive. */\n reason: string;\n /** What would make it active, drawn under the reason. */\n hint?: string;\n };\n\n/**\n * The body an inactive panel or section draws in place of its content: the\n * reason it is inactive, centred, with an optional hint under it at what would\n * bring it back. It is announced politely. Useful for telling the operator why\n * a part of the screen has nothing to show. Used by {@link Panel},\n * {@link Section} and {@link AugmentSlot}.\n *\n * @category Panel\n */\nexport function InactiveNotice({ reason }: { reason: PanelInactiveReason }) {\n const { reason: message, hint } =\n typeof reason === \"string\" ? { reason, hint: undefined } : reason;\n return (\n <InactiveNotice__Body role=\"status\" aria-live=\"polite\">\n <InactiveNotice__Reason>{message}</InactiveNotice__Reason>\n {hint !== undefined && (\n <InactiveNotice__Hint>{hint}</InactiveNotice__Hint>\n )}\n </InactiveNotice__Body>\n );\n}\n\nconst InactiveNotice__Body = styled.div`\n /* Never shrinks below its text: a centred box squeezed under its content spills it upward over the title. */\n flex: 0 0 auto;\n /* Held to the body's width, so a long word wraps inside the padding rather than widening the box past both edges. */\n max-width: 100%;\n min-width: 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: var(--gap-caption);\n text-align: center;\n padding: var(--inset-refusal);\n`;\n\nconst InactiveNotice__Reason = styled.div`\n max-width: 100%;\n overflow-wrap: break-word;\n color: var(--color-text-muted);\n font-size: var(--font-size-caption);\n font-weight: 600;\n letter-spacing: 0.1em;\n text-transform: uppercase;\n`;\n\nconst InactiveNotice__Hint = styled.div`\n max-width: 100%;\n overflow-wrap: break-word;\n color: var(--color-text-faint);\n font-size: var(--font-size-caption);\n letter-spacing: 0.04em;\n`;\n","import { writeQuantity } from \"./units\";\n\n/**\n * A quantity in a lock sentence (a science cost, a building level), written the\n * way the kit writes every other quantity. Useful for the lock text the\n * operator reads about what is still to be unlocked. Used by {@link LockMark}\n * and {@link LockScope}.\n */\nexport function writeLockQuantity(\n quantity: { magnitude: number; unit: string } | number,\n unit: string,\n): string {\n return writeQuantity(\n typeof quantity === \"number\" ? { magnitude: quantity, unit } : quantity,\n );\n}\n","import type { HTMLAttributes, ReactNode } from \"react\";\nimport styled from \"styled-components\";\nimport { InactiveNotice } from \"./InactiveNotice\";\nimport { LockScope } from \"./LockScope\";\nimport { Stack } from \"./Stack\";\nimport type { GapToken } from \"./scales\";\nimport type { StaticElement } from \"./staticElement\";\n\n/**\n * The attribute that marks a section spanning every column of a panel's section\n * grid. Used by {@link Section} to set it and by {@link Panel} to style it.\n */\nexport const SECTION_FULL_ATTR = \"data-section-full\";\n\n/**\n * The attribute that marks a section taking the panel body's leftover height.\n * Used by {@link Section} to set it and by {@link Panel} to style it.\n */\nexport const SECTION_FILL_ATTR = \"data-section-fill\";\n\n/**\n * Props for {@link Section}. Any other `div` attribute passes through, except\n * the HTML `title`, whose name is taken by the heading. Useful for grouping the\n * figures of a widget under a heading the operator can scan. Taken by\n * {@link Section}.\n *\n * @category Layout\n */\nexport interface SectionProps\n extends Omit<HTMLAttributes<HTMLDivElement>, \"title\"> {\n /** Rendered tag. Defaults to `div`. */\n as?: StaticElement;\n /** Gap between the section's children. Defaults to `rows`; a section of groups wants a wider one. */\n gap?: GapToken;\n /** The section's heading, rendered as a `SectionTitle` above its children. */\n title?: ReactNode;\n /** Tag for `title`. Defaults to `h4`, the level under a panel's own `h3`. */\n titleAs?: StaticElement;\n /**\n * Span every column of the panel's section grid rather than taking one, for a\n * summary strip or a table whose columns are already its own. Inert outside a\n * grid parent.\n */\n full?: boolean;\n /**\n * Take the panel body's leftover height rather than the section's natural\n * one, for a section that is a drawing (a map, a plot, a dial).\n *\n * A filling section is lifted out of the section grid (the columns a wide\n * panel lays its sections out in), so it always spans the panel's full\n * width; ordinary sections around it still form columns. Two filling sections\n * each keep their content height and share the leftover equally. Ignored\n * when the panel's `fitToSize` prop is set, and inert outside a panel body.\n */\n fill?: boolean;\n /** The section's content, under its title. */\n children?: ReactNode;\n}\n\n/**\n * A named group of rows inside a panel: a {@link Stack} at the `rows` gap,\n * headed by a {@link SectionTitle} when `title` is set. Useful for grouping the\n * figures of a widget under a heading the operator can scan. Used by the space\n * centre status and the maneuver planner. Inside a panel body,\n * `full` spans every column of the section grid and `fill` takes the body's\n * leftover height.\n *\n * A section is also a {@link LockScope}: when anything inside it reads a Topic\n * or uses a command this save has not unlocked (see {@link LockScope}), the\n * section keeps its title and shows what is missing in place of its content.\n *\n * @category Layout\n */\nexport function Section({\n children,\n gap = \"rows\",\n title,\n titleAs = \"h4\",\n full = false,\n fill = false,\n ...rest\n}: SectionProps) {\n const heading =\n title == null ? null : <SectionTitle as={titleAs}>{title}</SectionTitle>;\n const stackProps = {\n gap,\n [SECTION_FULL_ATTR]: full ? \"\" : undefined,\n [SECTION_FILL_ATTR]: fill ? \"\" : undefined,\n ...rest,\n };\n /* The scope wraps the Stack rather than sitting inside it, so the caller's\n children reach the Stack unwrapped: an element in between changes which DOM\n nodes React reuses as conditional children come and go. Not `Stack`'s own\n `fill` either: that is a zero basis, splitting the body evenly however\n little is in either section, where the body's rule divides only what is\n spare. */\n return (\n <LockScope\n fallback={(lock) => (\n <Stack {...stackProps}>\n {heading}\n <InactiveNotice reason={lock} />\n </Stack>\n )}\n >\n <Stack {...stackProps}>\n {heading}\n {children}\n </Stack>\n </LockScope>\n );\n}\n\n/**\n * The uppercase, tracked-out heading {@link Section} draws for its `title`,\n * usable on its own. Useful for headings outside a panel that should look like\n * a panel's. Used by the settings and alarms dialogs.\n *\n * Use `as=\"h3\"` (or another heading tag) for a real heading; `$rule` draws a\n * hairline under it. The `$` prefix marks a styled-components transient prop:\n * it styles the heading and is never passed on to the DOM element.\n *\n * @category Layout\n */\nexport const SectionTitle = styled.div<{\n /** Draws a hairline under the heading. */\n $rule?: boolean;\n}>`\n margin: 0;\n font-size: var(--font-size-value);\n font-weight: 700;\n letter-spacing: 0.1em;\n text-transform: uppercase;\n color: var(--color-text-muted);\n ${({ $rule }) =>\n $rule\n ? `\n padding-bottom: var(--gap-title-rule);\n border-bottom: 1px solid var(--color-border-subtle);\n`\n : \"\"}\n`;\n","import { createContext, useContext } from \"react\";\nimport type { ContributionSlotId } from \"./contributions\";\n\n/**\n * The identity and declared contribution slots of the widget the caller is\n * rendered inside. {@link ContributionsProvider} reads it to know which slots\n * to serve, and segment slots complete to `${componentId}.<segment>` from it.\n * Useful for letting an Uplink's additions reach the widget they were meant\n * for. Held by {@link WidgetMetaContext} and returned by {@link useWidgetMeta}.\n *\n * @category Extensions\n */\nexport interface WidgetMetaContextValue {\n /** The widget's registered component id. */\n componentId: string;\n /** The contribution slots the widget declares in its `contributionSlots`, or an empty list. */\n contributionSlots: readonly ContributionSlotId[];\n}\n\n/**\n * The context carrying {@link WidgetMetaContextValue} for the current widget,\n * `null` outside one. The dashboard provides it for every widget; a test\n * rendering a widget bare provides it to get the widget's slots working.\n * Provided by the dashboard around every widget.\n *\n * @intent Published so a test or a host of its own can give a widget the identity and slots the dashboard provides.\n * @category Extensions\n */\nexport const WidgetMetaContext = createContext<WidgetMetaContextValue | null>(\n null,\n);\n\n/**\n * The current widget's identity and declared contribution slots, or `null`\n * outside a {@link WidgetMetaContext} provider (a widget rendered bare, a panel\n * outside the dashboard). Useful for letting a part of a widget find the\n * contributions an Uplink added to it. Used by {@link useWidgetBadges}\n * and by the slots that serve an Uplink's additions.\n *\n * @category Extensions\n */\nexport function useWidgetMeta(): WidgetMetaContextValue | null {\n return useContext(WidgetMetaContext);\n}\n","import { type ReactElement, useSyncExternalStore } from \"react\";\nimport {\n type AnyAugment,\n type AugmentSegmentProps,\n getAugmentsForSlot,\n onAugmentsChange,\n type SlotProps,\n} from \"./augments\";\nimport {\n useDomainAvailabilityStore,\n useDomainAvailable,\n} from \"./domainAvailability\";\nimport { InactiveNotice } from \"./InactiveNotice\";\nimport { LockScope } from \"./LockScope\";\nimport { Section } from \"./Section\";\nimport { useWidgetMeta } from \"./WidgetMetaContext\";\n\n/**\n * Every augment bound to a slot, rendered in priority order as siblings in a\n * fragment. Useful for a widget that lets Uplinks add content without naming\n * them. Used by the astronaut complex panels. Augments registered after the\n * slot mounts appear when they register.\n *\n * `props` is required and passed to every augment, typed against the slot's\n * {@link SlotProps} entry: an overlay slot passes its parent's projection, for\n * example. Pass `{}` for a slot with no props.\n *\n * An augment declaring `requires: \"<domain>\"` renders only while the host\n * reports that Domain present; a held `<domain>.available` counts as present.\n *\n * Two forms, of which a call uses one:\n * - `name`: the full slot id (`\"power-systems.sections\"`), props typed\n * through {@link SlotRegistry}\n * - `segment`: only the segment (`\"overlay\"`), completed to\n * `${componentId}.<segment>` for the widget it renders in, props typed\n * through {@link AugmentSegmentProps}. Outside a widget it renders nothing\n *\n * @example\n * ```tsx\n * <AugmentSlot name=\"crew-status.row-badges\" props={{ crewName: kerbal.name, crewIndex: kerbal.index }} />\n * ```\n *\n * @category Extensions\n * @categoryDescription Extensions\n * The widget side of extension: placing a slot where Uplinks may draw, reading\n * the contributions handed to a widget, the settings an augment exposes, and\n * whether a Domain is present for an augment that needs one.\n */\nexport function AugmentSlot<Slot extends string>(\n args:\n | { name: Slot; props: SlotProps<Slot>; segment?: never }\n | { segment: Slot; props: AugmentSegmentProps<Slot>; name?: never },\n): ReactElement {\n // Read unconditionally for a stable hook order; only the `segment` form uses it.\n const meta = useWidgetMeta();\n const slotName =\n args.name ?? (meta ? `${meta.componentId}.${args.segment}` : undefined);\n\n const augments = useAugmentsFor(slotName);\n\n return (\n <>\n {augments.map((augment) => (\n <AugmentEntry\n key={augment.id}\n augment={augment}\n slotProps={args.props as Record<string, unknown>}\n asSection={slotName?.endsWith(\".sections\") === true}\n />\n ))}\n </>\n );\n}\n\nconst EMPTY_AUGMENTS: AnyAugment[] = [];\n\n/** Re-read on every registry change, so a slot mounted before an augment's module loads still picks it up. */\nfunction useAugmentsFor(slotName: string | undefined): AnyAugment[] {\n return useSyncExternalStore(\n onAugmentsChange,\n () => (slotName ? getAugmentsForSlotCached(slotName) : EMPTY_AUGMENTS),\n () => (slotName ? getAugmentsForSlotCached(slotName) : EMPTY_AUGMENTS),\n );\n}\n\n/**\n * Whether anything would render in the current widget's\n * `${componentId}.<segment>` slot, for a widget deciding whether to draw\n * chrome around it. Useful for showing the operator a panel section only when\n * an Uplink has something to put in it. Used by {@link Panel}. Counts only\n * augments whose `requires` Domain is present, so an Uplink whose mod is not\n * running changes no layout. False outside a widget.\n *\n * @category Extensions\n */\nexport function useWidgetSegmentBound(segment: string): boolean {\n const meta = useWidgetMeta();\n const slotName = meta ? `${meta.componentId}.${segment}` : undefined;\n return useAnyAvailable(useAugmentsFor(slotName));\n}\n\n/**\n * Whether anything would render in the slot with the full id `name`. Useful for\n * a widget affordance (a tab, a reserved cell) that should exist only when\n * something can fill it. Used by the astronaut complex view to show its augment\n * tab. Counts only augments whose `requires` Domain is present, so an Uplink\n * whose mod is not running changes no layout. Unlike\n * {@link useWidgetSegmentBound} it works outside a widget.\n *\n * @category Extensions\n */\nexport function useSlotBound(name: string): boolean {\n return useAnyAvailable(useAugmentsFor(name));\n}\n\nconst NO_SUBSCRIBE = (): (() => void) => () => {};\n\n/** Whether any of `augments` passes the same presence gate {@link AugmentEntry} applies, re-read as Domains announce. */\nfunction useAnyAvailable(augments: AnyAugment[]): boolean {\n const store = useDomainAvailabilityStore();\n const snapshot = (): boolean =>\n augments.some(\n (augment) =>\n !augment.requires || store?.isAvailable(augment.requires) === true,\n );\n return useSyncExternalStore(\n store ? store.subscribe : NO_SUBSCRIBE,\n snapshot,\n snapshot,\n );\n}\n\n/**\n * The `label` of the first available augment bound to the slot `name`, in\n * render order. Useful for a widget that needs a caption before it draws the\n * slot, such as a tab's label. Used by the astronaut complex view for its\n * augment tab. `undefined` while nothing is bound, nothing bound has its\n * `requires` Domain present, or the first available augment declares no label.\n * With several augments bound, only the first one's label is used, while\n * {@link AugmentSlot} renders them all together.\n *\n * @category Extensions\n */\nexport function useSlotLabel(name: string): string | undefined {\n const augments = useAugmentsFor(name);\n const store = useDomainAvailabilityStore();\n const snapshot = (): string | undefined =>\n augments.find(\n (augment) =>\n !augment.requires || store?.isAvailable(augment.requires) === true,\n )?.label;\n return useSyncExternalStore(\n store ? store.subscribe : NO_SUBSCRIBE,\n snapshot,\n snapshot,\n );\n}\n\n// useSyncExternalStore loops without a referentially stable snapshot, so each slot's list is memoised until the registry notifies.\nconst slotCache = new Map<string, AnyAugment[]>();\nlet cacheValid = false;\nonAugmentsChange(() => {\n cacheValid = false;\n slotCache.clear();\n});\nfunction getAugmentsForSlotCached(name: string): AnyAugment[] {\n if (!cacheValid) {\n slotCache.clear();\n cacheValid = true;\n }\n let cached = slotCache.get(name);\n if (cached === undefined) {\n cached = getAugmentsForSlot(name);\n slotCache.set(name, cached);\n }\n return cached;\n}\n\n/**\n * Whether `augment` declares no `requires`, or the host reports its Domain\n * present: the same check {@link AugmentSlot} makes before rendering it. Useful\n * for asking that question without rendering the augment, since an Uplink\n * client registers its augments whether or not its mod is running. Used by the\n * ground track widget's vanilla suppression check.\n *\n * @category Extensions\n */\nexport function useAugmentAvailable(augment: AnyAugment): boolean {\n // Called unconditionally for a stable hook order.\n const available = useDomainAvailable(augment.requires);\n return !augment.requires || available;\n}\n\n/**\n * One augment behind its gate, isolated so the gate hook's position is stable\n * as the registered set changes.\n *\n * Each augment is its own lock scope. An Uplink's section reads and commands\n * through hooks in its own body, which would otherwise claim against the host\n * widget's scope and take the whole host down for a capability only the\n * augment uses. A locked augment in a sections slot draws the missing unlock\n * under its label; anywhere else (an overlay, a badge) it draws nothing.\n */\nfunction AugmentEntry({\n augment,\n slotProps,\n asSection,\n}: {\n augment: AnyAugment;\n slotProps: Record<string, unknown>;\n asSection: boolean;\n}): ReactElement | null {\n if (!useAugmentAvailable(augment)) {\n return null;\n }\n\n const Component = augment.component;\n return (\n <LockScope\n fallback={\n asSection\n ? (lock) => (\n <Section title={augment.label}>\n <InactiveNotice reason={lock} />\n </Section>\n )\n : null\n }\n >\n <Component {...slotProps} />\n </LockScope>\n );\n}\n","import type { HeldGrade, StreamStatusValue } from \"@ksp-gonogo/sitrep-sdk\";\n\n/**\n * The operator's word for each reason a held reading stopped updating.\n *\n * Loading and no game say the game itself is the reason, which no craft or link can answer for. Blackout and recorded keep words of their own because they ask something\n * different of the operator: a blackout is waited out, and a recorded value is\n * exact for the instant it names. Only a Topic that simply went quiet is `HELD`.\n */\nconst HELD_GRADE_WORD: Readonly<Record<HeldGrade, string>> = {\n held: \"HELD\",\n disconnected: \"OFFLINE\",\n \"last-before-blackout\": \"BLACKOUT\",\n recorded: \"RECORDED\",\n loading: \"LOADING\",\n \"no-game\": \"NO GAME\",\n};\n\n/** Every word a held mark's caption can open with, one per grade. */\nexport const HELD_WORDS: readonly string[] = Object.values(HELD_GRADE_WORD);\n\nconst STREAM_STATUS_WORD: Readonly<Record<StreamStatusValue, string | null>> = {\n ...HELD_GRADE_WORD,\n live: null,\n resyncing: \"SYNCING\",\n absent: \"NO DATA\",\n};\n\n/**\n * The short word a badge or caption prints for a `StreamStatusValue`, or `null`\n * for `\"live\"`, which shows nothing. Useful for telling the operator in a word\n * why a figure is not a live reading. Used by {@link StreamStatusBadge} and\n * {@link Panel}.\n *\n * The words, exactly as returned (every one is upper case, and a badge draws\n * it as it stands):\n *\n * - `\"held\"`: `\"HELD\"`\n * - `\"disconnected\"`: `\"OFFLINE\"`\n * - `\"last-before-blackout\"`: `\"BLACKOUT\"`, the last value sent before a known\n * loss of signal (a blackout is a stretch when the craft's signal cannot\n * reach the command centre)\n * - `\"recorded\"`: `\"RECORDED\"`\n * - `\"loading\"`: `\"LOADING\"`\n * - `\"no-game\"`: `\"NO GAME\"`\n * - `\"resyncing\"`: `\"SYNCING\"`\n * - `\"absent\"`: `\"NO DATA\"`\n *\n * @category Badge\n */\nexport function formatStreamStatus(status: StreamStatusValue): string | null {\n return STREAM_STATUS_WORD[status];\n}\n\n/**\n * The word for a held reading's grade, the same word {@link formatStreamStatus}\n * gives the status of that name, or `HELD` when no grade is given, as for a\n * value combined from several readings. Useful for telling the operator in a\n * word why a figure is held. Used by {@link Badge} and the target picker's\n * rows.\n *\n * @category Badge\n */\nexport function heldWord(grade: HeldGrade | undefined): string {\n return HELD_GRADE_WORD[grade ?? \"held\"];\n}\n","/**\n * The number to draw, and the statement the reading makes about it.\n *\n * Shared by every primitive that draws a figure, so a `Reading` cannot mean one\n * thing on a readout and another on the instrument beside it.\n */\nimport {\n type HeldGrade,\n isDeterministicValue,\n isStaticValue,\n type Reading,\n type UncertaintyBand,\n type Value,\n} from \"@ksp-gonogo/sitrep-sdk\";\nimport { NULL_DISPLAY } from \"./NullValue\";\nimport type { ReckoningKind } from \"./reckoningMarkSpec\";\nimport { heldWord } from \"./status/streamStatusWord\";\nimport { formatQuantity } from \"./units\";\n\n/**\n * A quantity on its own, or the whole `Reading` it arrived in. Useful for\n * drawing a figure for the operator, with its held mark when the reading is\n * held. Taken by the figure props of the primitives that draw a figure, such as\n * {@link Unit} and {@link Meter}, so a call site holding a reading can fill a\n * readout, a bar and an instrument with the same thing.\n *\n * @category Unit\n */\nexport type UnitValue<Unit extends string = string> =\n | Value<Unit>\n | Reading<Value<Unit>>;\n\n/**\n * The number to draw and whether it is current. Useful for a primitive that\n * must show the operator a figure together with how current it is. Returned by\n * {@link resolveCurrency}.\n *\n * @category Unit\n */\nexport interface Resolved<Unit extends string> {\n /** The number to draw; null or undefined draws the null token. */\n shown: Value<Unit> | null | undefined;\n /** True when the number on screen is not a reading of now, so it takes a mark: `mark` says which. */\n held: boolean;\n /**\n * Which mark the figure takes: `held` for the last observation kept, `modelled`\n * for a figure a model carried. Null exactly when `held` is false.\n */\n mark: ReckoningKind | null;\n /**\n * Whether the number is a fact the contract declares static (one that never\n * changes, such as a body's radius), which is never\n * old and so is never marked held, whatever the reading's state.\n */\n isStatic: boolean;\n /**\n * Whether the number is exact at any instant: computed from fixed inputs and\n * the clock, as a figure between two bodies on fixed conics (orbits that never change) is. It moves, so\n * it is not static, and it is never a guess, so it takes no held or modelled\n * mark whatever the reading's state.\n */\n isDeterministic: boolean;\n /**\n * What the mark means in words: the grade where the reading names one, a\n * grade-neutral word where it does not, and the instant the number was last\n * a reading of now where that is readable. Said rather than shown, and null\n * only where nothing was marked.\n */\n caption: string | null;\n /**\n * The uncertainty band the reading's model publishes, as it arrived and not\n * yet narrowed to a unit; only a band in the shown value's unit applies.\n */\n band: UncertaintyBand | null;\n}\n\n/**\n * When the observation was made, on the game's own calendar, or null when the\n * reading carries no readable instant.\n *\n * Through `formatQuantity`, so a held number and a `<MissionDate>` beside it\n * print one spelling of a UT. A malformed instant gives null, since \"as of\"\n * followed by the null token is worse than the grade on its own.\n */\nfunction lastValidAt(asOfUt: Value<\"ut\"> | undefined): string | null {\n if (asOfUt === undefined) return null;\n const { value } = formatQuantity(asOfUt.magnitude, asOfUt.unit);\n return value === NULL_DISPLAY ? null : value;\n}\n\n/**\n * What the mark says in words: the grade, and how far back the number is from.\n * The dot shows it at a glance; this words it for the hover and the\n * accessibility tree.\n */\nfunction sayCurrency(caption: string, asOfUt: Value<\"ut\"> | undefined): string {\n const at = lastValidAt(asOfUt);\n return at === null ? caption : `${caption}, as of ${at}`;\n}\n\n/**\n * How a primitive reads a {@link Reading}: whether it draws the model's carried\n * figure in place of the observation. Useful for the primitives that show the\n * operator a figure and its currency. Taken by {@link resolveCurrency}.\n *\n * @category Unit\n */\nexport interface CurrencyOptions {\n /**\n * The consumer draws the reading's reckoning, where one is on offer, rather\n * than its observation: a countdown, or a figure a widget solves forward.\n * The modelled figure is then marked wherever it is not a reading of now,\n * which under signal delay includes a current reading carried forward to the\n * craft's own present (SCET, spacecraft event time: when the event happens\n * at the craft, rather than when its telemetry reaches the command centre).\n */\n readonly drawsReckoning?: boolean;\n}\n\n/**\n * The words that mark a current reading whose figure the model carried forward\n * by the signal delay to the vessel's own present: SCET, spacecraft event time.\n * Useful for telling the operator in words that a figure is an estimate. Used by\n * {@link ModelledAlongside}.\n *\n * @category Unit\n */\nexport const MODELLED_TO_SCET = \"modelled to SCET\";\n\n/**\n * What the model says a current reading's figure is at the instant it was\n * carried to, where that is later than the newest data received: the figure a\n * widget draws beside the observation with {@link ModelledAlongside}.\n * `undefined` everywhere else. Useful for showing the operator what a vessel's\n * state is estimated to be now. Used by {@link Countdown} and\n * {@link ModelledAlongside}.\n *\n * @category Unit\n */\nexport function modelledBeyondReceived<Payload>(\n reading: Reading<Payload> | null | undefined,\n): Payload | undefined {\n if (reading == null || reading.state !== \"observed\") return undefined;\n if (reading.value === undefined) return undefined;\n if (reading.reckoning.status !== \"available\") return undefined;\n if (!reading.reckoning.beyondReceived) return undefined;\n return reading.reckoning.modelled;\n}\n\n/** The mark and its words for a held reading's observation. */\nfunction heldCurrency<Unit extends string>(\n input: Reading<Value<Unit>>,\n): Omit<Resolved<Unit>, \"band\"> {\n /*\n * The mark follows the number, not the state: a held reading with no value\n * gets no dot. Whatever is marked gets words, including the ordinary\n * gradeless held reading a derived value produces.\n */\n if (isStaticValue(input.value) || isDeterministicValue(input.value)) {\n return {\n shown: input.value,\n held: false,\n mark: null,\n isStatic: isStaticValue(input.value),\n isDeterministic: isDeterministicValue(input.value),\n caption: null,\n };\n }\n return {\n shown: input.value,\n held: input.value !== undefined,\n mark: input.value !== undefined ? \"held\" : null,\n isStatic: false,\n isDeterministic: false,\n caption:\n input.value === undefined\n ? null\n : sayCurrency(heldWord(input.grade), input.asOfUt),\n };\n}\n\n/**\n * Splits a quantity or a reading into the number to draw and how current it is.\n * Useful for any primitive that shows the operator a figure and must mark it\n * when it is held. Used by {@link MissionDate}, the graph widget and the\n * panel's essentials.\n *\n * A bare `Value` (and `null`, and nothing at all) is current by construction.\n * A `Reading` in `observed` state is current, one in `held` state with a value\n * is marked held, and any other state yields `shown: null`. With\n * `drawsReckoning`, the reading's modelled figure is shown in place of the\n * observation where the model has one.\n *\n * @category Unit\n */\nexport function resolveCurrency<Unit extends string>(\n input: UnitValue<Unit> | null | undefined,\n options: CurrencyOptions = {},\n): Resolved<Unit> {\n // `in` throws on a primitive, and some callers hand over a raw magnitude.\n if (typeof input !== \"object\" || input === null || !(\"state\" in input)) {\n return {\n shown: input,\n held: false,\n mark: null,\n isStatic: isStaticValue(input),\n isDeterministic: isDeterministicValue(input),\n caption: null,\n band: null,\n };\n }\n // The band is orthogonal to the state: a live reading and a held one may each carry a model.\n const band =\n input.reckoning.status === \"available\"\n ? (input.reckoning.band ?? null)\n : null;\n if (\n options.drawsReckoning &&\n input.reckoning.status === \"available\" &&\n (input.state === \"observed\" || input.state === \"held\") &&\n // An exact figure needs no model to carry it, so it is never drawn as one.\n !isDeterministicValue(input.value)\n ) {\n const shown = input.reckoning.modelled;\n if (input.state === \"held\") {\n const held = heldCurrency(input);\n // The figure drawn is the model's, so it is marked as modelled, from the instant the observation stopped; with no observation behind it the model stands alone and says only that.\n const modelAlone = input.value === undefined;\n const marked = held.held || modelAlone;\n const said = held.caption ?? (modelAlone ? \"\" : null);\n return {\n ...held,\n shown,\n held: marked,\n mark: marked ? \"modelled\" : null,\n caption:\n said === null ? null : said === \"\" ? \"modelled\" : `${said}, modelled`,\n band,\n };\n }\n const carried = input.reckoning.beyondReceived;\n return {\n shown,\n held: carried,\n mark: carried ? \"modelled\" : null,\n isStatic: false,\n isDeterministic: false,\n caption: carried ? MODELLED_TO_SCET : null,\n band,\n };\n }\n if (input.state === \"observed\") {\n return {\n shown: input.value,\n held: false,\n mark: null,\n isStatic: isStaticValue(input.value),\n isDeterministic: isDeterministicValue(input.value),\n caption: null,\n band,\n };\n }\n if (input.state === \"held\") return { ...heldCurrency(input), band };\n // `null` rather than `undefined`, so the caller renders the null token rather than the symbol form.\n return {\n shown: null,\n held: false,\n mark: null,\n isStatic: false,\n isDeterministic: false,\n caption: null,\n band: null,\n };\n}\n\n/**\n * The attributes every figure-drawing primitive stamps on the element that\n * carries its figure: `data-figure` names it as a figure, `\"static\"` for a fact\n * the contract declares static and `\"deterministic\"` for one exact at any\n * instant, and `data-held` marks one that is not a reading of now. A render sweep reads the pair to find a held figure drawn as current.\n * No `data-figure` where there is no number to draw. Useful for checking that\n * the operator is never shown a held figure as current. Used by the primitives\n * that draw a figure, such as {@link Unit}, {@link Countdown} and\n * {@link MissionDate}.\n */\nexport function figureAttributes(resolved: {\n readonly shown: unknown;\n readonly held: boolean;\n readonly mark?: ReckoningKind | null;\n readonly isStatic: boolean;\n readonly isDeterministic?: boolean;\n}): {\n \"data-figure\": string | undefined;\n \"data-held\": \"\" | undefined;\n \"data-reckoned\": ReckoningKind | undefined;\n} {\n return {\n \"data-figure\":\n resolved.shown == null\n ? undefined\n : resolved.isStatic\n ? \"static\"\n : resolved.isDeterministic\n ? \"deterministic\"\n : \"\",\n \"data-held\": resolved.held ? \"\" : undefined,\n \"data-reckoned\": resolved.held ? (resolved.mark ?? \"held\") : undefined,\n };\n}\n\n/**\n * The mark a derived figure takes, and its words: what a widget hands\n * `<Unit marked>` for a number it computed from a reading's payload (an\n * apoapsis solved from an orbit) rather than read off a field. Useful for\n * showing the operator that a computed figure is held or modelled. Returned by\n * {@link derivedMarking} and {@link heldMarking}.\n *\n * @category Unit\n */\nexport interface ReckoningMarking {\n /** Which mark the figure takes: held or modelled. */\n kind: ReckoningKind;\n /** What the mark means in words, said to a screen reader and shown on hover rather than drawn. */\n caption: string;\n}\n\n/**\n * How a figure derived from this reading should be marked, or null where the\n * reading is a current observation of now. Useful for showing the operator that\n * a computed figure rests on a held or modelled reading. Used by the maneuver\n * planner's telemetry and the craft-on-orbit calculations.\n *\n * A current reading a model carried past the newest data received marks\n * `modelled`; a held one marks `held`, or `modelled` where a model carries it.\n * Use it for every displayed figure computed from a reading's payload, a plan's\n * included.\n *\n * @category Unit\n */\nexport function derivedMarking(\n /** The reading the figure was computed from. Null or undefined gives no mark. */\n reading: Reading<unknown> | null | undefined,\n /** The figure is carried by a model that the reading itself does not name, such as a position the map models from the orbit. */\n carried = false,\n): ReckoningMarking | null {\n if (reading == null) return null;\n if (reading.state === \"observed\") {\n return carried ||\n (reading.reckoning.status === \"available\" &&\n reading.reckoning.beyondReceived)\n ? { kind: \"modelled\", caption: MODELLED_TO_SCET }\n : null;\n }\n if (reading.state === \"held\") {\n const said = sayCurrency(heldWord(reading.grade), reading.asOfUt);\n return carried || reading.reckoning.status === \"available\"\n ? { kind: \"modelled\", caption: `${said}, modelled` }\n : { kind: \"held\", caption: said };\n }\n return null;\n}\n\n/**\n * How a figure is marked from a `held` field: the reading the figure was drawn\n * from, or just its grade, as a contributed entry or an augment slot's props\n * carry it. `null` unless that reading is held or modelled, so the reading can\n * be passed unconditionally. The same marking {@link derivedMarking} gives.\n * Useful for showing the operator that an entry contributed to a widget rests\n * on a held reading. Used by the comm signal widget and the ship map's part\n * tooltip.\n *\n * @category Unit\n */\nexport function heldMarking(\n held: HeldGrade | Reading<unknown> | undefined,\n): ReckoningMarking | null {\n if (held === undefined) return null;\n if (typeof held !== \"string\") return derivedMarking(held);\n return { kind: \"held\", caption: heldWord(held) };\n}\n\n/**\n * The held grade of a `held` field, for something drawn as a verdict (a tone,\n * a badge) rather than a figure: `undefined` unless the reading it names is\n * held. A held reading derived from several, which may carry no single grade,\n * reads as plain `\"held\"`. Useful for showing the operator that a verdict\n * rests on a held reading. Used by the crew status widget and the space centre\n * status widget.\n *\n * @category Unit\n */\nexport function heldGradeOf(\n held: HeldGrade | Reading<unknown> | undefined,\n): HeldGrade | undefined {\n if (held === undefined) return undefined;\n if (typeof held === \"string\") return held;\n return held.state === \"held\" ? (held.grade ?? \"held\") : undefined;\n}\n\n/**\n * A figure as the reading its `held` field says it came from: the figure\n * itself while that reading is current, and a held reading of it, dated by the\n * reading's `asOfUt` where it has one, while it is held. Hand the result to\n * any primitive that takes a {@link UnitValue}. Useful for showing the operator\n * a figure with its held mark. Used by the ship map's part tooltip.\n *\n * @category Unit\n */\nexport function heldFigureOf<Unit extends string>(\n figure: Value<Unit>,\n held: HeldGrade | Reading<unknown> | undefined,\n): UnitValue<Unit> {\n const grade = heldGradeOf(held);\n if (grade === undefined) return figure;\n return {\n state: \"held\",\n value: figure,\n grade,\n asOfUt: typeof held === \"object\" ? held.asOfUt : undefined,\n reckoning: { status: \"none\" },\n };\n}\n","import type { Value } from \"@ksp-gonogo/sitrep-sdk\";\nimport { type FormatQuantityOptions, writeQuantity } from \"./units\";\n\n/**\n * The precision a figure is drawn at, reduced to one test: whether two figures\n * come out as the same drawing. Useful for deciding whether a modelled figure\n * adds anything to the operator beside the observation. Taken by\n * {@link standsApart}.\n *\n * @category Unit\n */\nexport interface DrawnPrecision<Figure> {\n /** Whether `a` and `b` come out as the same drawing at this precision. */\n readsAsOne(a: Figure, b: Figure): boolean;\n}\n\n/**\n * A precision for figures drawn as text: two figures are one where `write`\n * gives them the same text. Useful for comparing a modelled and an observed\n * figure at the precision the operator reads. Used by {@link Unit} and\n * {@link ModelledAlongside}.\n *\n * @category Unit\n */\nexport function writtenAs<Figure>(\n write: (figure: Figure) => string,\n): DrawnPrecision<Figure> {\n return { readsAsOne: (a, b) => write(a) === write(b) };\n}\n\n/**\n * A precision for quantities drawn as {@link writeQuantity} writes them, which\n * is also how {@link Unit} draws them with the same options. Useful for\n * comparing a modelled and an observed quantity at the precision the operator\n * reads. Used by {@link ModelledAlongside}.\n *\n * @category Unit\n */\nexport function writtenQuantity<Unit extends string>(\n opts: FormatQuantityOptions = {},\n): DrawnPrecision<Value<Unit>> {\n return writtenAs((quantity) => writeQuantity(quantity, opts));\n}\n\n/**\n * How far apart two positions on an instrument's scale sit, as a fraction of\n * the whole scale, before they read as two: one percent, the finest step a\n * percentage readout writes. Useful for deciding when two positions the\n * operator reads on a dial or tape are the same. Used by\n * {@link placedOnScale}.\n *\n * @category Unit\n */\nexport const SCALE_TOLERANCE = 0.01;\n\n/**\n * A precision for figures placed on an instrument's scale: each figure is a\n * fraction of it, clamped to it first, and two read as one within one percent\n * of the scale. `wraps` measures the short way round a scale whose ends meet.\n * Useful for comparing positions the operator reads on a dial, tape or bar.\n * Used by {@link Meter}, {@link Dial} and {@link Tape}.\n *\n * @category Unit\n */\nexport function placedOnScale({\n wraps = false,\n}: {\n wraps?: boolean;\n} = {}): DrawnPrecision<number> {\n const onScale = (at: number): number =>\n wraps ? at - Math.floor(at) : Math.min(1, Math.max(0, at));\n return {\n readsAsOne(a, b) {\n const apart = Math.abs(onScale(a) - onScale(b));\n return (wraps ? Math.min(apart, 1 - apart) : apart) <= SCALE_TOLERANCE;\n },\n };\n}\n\n/**\n * Whether a model's figure stands apart from the observation at the precision\n * both are drawn, so drawing it says something the observation beside it does\n * not. Several figures, such as a band's two ends, stand apart where any one\n * does. Beside no observation at all, every figure stands apart. Useful for\n * keeping a modelled figure off the screen when it says nothing the operator\n * has not already read. Used by {@link ModelledAlongside}, {@link Meter} and\n * {@link Tape}.\n *\n * @category Unit\n */\nexport function standsApart<Figure>(\n observed: Figure | null | undefined,\n modelled: Figure | readonly Figure[],\n precision: DrawnPrecision<Figure>,\n): boolean {\n const figures: readonly Figure[] = Array.isArray(modelled)\n ? modelled\n : [modelled as Figure];\n if (observed === null || observed === undefined) return figures.length > 0;\n return figures.some((figure) => !precision.readsAsOne(observed, figure));\n}\n","import type { Reading, Value } from \"@ksp-gonogo/sitrep-sdk\";\nimport { formatDuration } from \"./formatDuration\";\nimport { HeldFigure } from \"./HeldMark\";\nimport { NULL_DISPLAY } from \"./NullValue\";\nimport {\n figureAttributes,\n MODELLED_TO_SCET,\n modelledBeyondReceived,\n resolveCurrency,\n} from \"./readingCurrency\";\nimport { standsApart, writtenAs } from \"./standsApart\";\n\n/**\n * Props for {@link Countdown}.\n * Useful for giving the clock the duration it shows the operator. Used by\n * {@link Countdown}.\n *\n * @category MissionDate\n */\nexport interface CountdownProps {\n /**\n * A duration in seconds: how long until, or how long since. A bare number is\n * accepted for client-computed durations.\n *\n * Not `Value<\"ut\">`: an instant is a type error here. Subtract the instant\n * the screen is showing, from `useViewUt`, to turn an instant into a\n * duration.\n */\n value: Value<\"s\"> | Reading<Value<\"s\">> | number | null | undefined;\n /**\n * Prefix the launch-clock sign: `T−` counting down to the event, `T+` once\n * it has passed. Off by default: a \"how long until\" readout is not a clock.\n */\n clock?: boolean;\n /**\n * Count the last second in milliseconds rather than showing `0s`, for a cue\n * the operator acts on, where `0s` for a whole second reads as stopped. Off by\n * default, where it would be false precision.\n */\n precise?: boolean;\n}\n\n/**\n * A duration drawn as a clock: `1m 20s`, or `T−1m 20s` on a launch clock.\n * Useful for showing the time left until an event. Used by\n * {@link InFlightList} for each command's arrival. A `Value<\"s\">` has three\n * renderers, chosen by what the value is:\n *\n * - {@link Unit} for a magnitude: a burn lasting 90 seconds\n * - `Countdown` for a clock, with the opt-in `T−` / `T+` prefix and\n * sub-second precision for a cue that would otherwise sit at `0s`\n * - {@link MissionDate} for an instant: a UT is not a length of time\n *\n * Handed a `Reading`, a countdown draws the model's reckoning where there is\n * one, so it keeps advancing while a model carries it, and freezes on the last\n * observation, with the held mark, otherwise. {@link Unit} does this only when\n * given `reckoned`. A current reading whose model reaches past the newest data\n * received draws the model's figure alone with the modelled mark, in the place\n * of the observation, so a countdown is always one figure wide. A model that\n * reads the same as the observation at the precision drawn leaves the\n * observation unmarked. An absent value renders\n * {@link NULL_DISPLAY}.\n *\n * @category MissionDate\n */\nexport function Countdown({\n value,\n clock = false,\n precise = false,\n}: CountdownProps) {\n // A bare number never carries currency, so it is split off before the resolver.\n const carried = typeof value === \"number\" ? undefined : value;\n const format = (duration: Value<\"s\"> | number) =>\n formatDuration(\n typeof duration === \"number\" ? duration : duration.magnitude,\n {\n ms: precise,\n sign: clock,\n },\n );\n const reading = carried != null && \"state\" in carried ? carried : undefined;\n const modelled = modelledBeyondReceived(reading);\n if (reading?.value !== undefined && modelled !== undefined) {\n if (!standsApart(reading.value, modelled, writtenAs(format))) {\n return <>{format(reading.value)}</>;\n }\n return (\n <HeldFigure\n data-held=\"\"\n kind=\"modelled\"\n caption={`${MODELLED_TO_SCET}, last received ${format(reading.value)}`}\n >\n {format(modelled)}\n </HeldFigure>\n );\n }\n const currency = resolveCurrency(carried, { drawsReckoning: true });\n const { shown, held, mark, caption } = currency;\n const drawn = typeof value === \"number\" ? value : shown;\n if (drawn === undefined || drawn === null) return NULL_DISPLAY;\n const text = format(drawn);\n const figure = figureAttributes({ ...currency, shown: drawn });\n if (!held) return <span data-figure={figure[\"data-figure\"]}>{text}</span>;\n return (\n <HeldFigure {...figure} kind={mark ?? \"held\"} caption={caption}>\n {text}\n </HeldFigure>\n );\n}\n","import { type RefObject, useEffect, useRef, useState } from \"react\";\n\n/**\n * Pixel dimensions of an observed element, rounded down to whole pixels.\n * Returned as `size` by {@link useElementSize}.\n *\n * @category Layout\n */\nexport interface ElementSize {\n /** Width in whole CSS pixels. */\n w: number;\n /** Height in whole CSS pixels. */\n h: number;\n}\n\n/**\n * Observe an element's content box and track its `{ w, h }` size. Useful for\n * choosing what a widget draws from the room the operator has given it. Used by\n * {@link Tabs} and {@link Panel}.\n *\n * Attach `ref` to the element to measure. Zero-size measurements are ignored\n * and the result is rounded down to whole pixels. The element may come and go,\n * or be swapped for another: whichever one `ref` holds after a render is the\n * one observed. Where there is no `ResizeObserver` (jsdom) the size stays at\n * `initial`.\n *\n * @param initial - Seed size used until the first non-zero measurement\n * @returns `{ ref, size }`: attach `ref` to the element to measure\n *\n * @example\n * ```tsx\n * function Chart() {\n * const { ref, size } = useElementSize<HTMLDivElement>({ w: 200, h: 120 });\n * return <div ref={ref}>{size.w > 300 ? <WideChart /> : <NarrowChart />}</div>;\n * }\n * ```\n *\n * @category Layout\n */\nexport function useElementSize<\n MeasuredElement extends HTMLElement = HTMLDivElement,\n>(\n initial: ElementSize,\n): { ref: RefObject<MeasuredElement>; size: ElementSize } {\n const ref = useRef<MeasuredElement>(null);\n const [size, setSize] = useState<ElementSize>(initial);\n const [observed, setObserved] = useState<MeasuredElement | null>(null);\n\n // After every render, so an element that mounts late or is replaced is picked up; only a different element re-renders.\n useEffect(() => {\n if (ref.current !== observed) setObserved(ref.current);\n });\n\n useEffect(() => {\n if (!observed || typeof ResizeObserver === \"undefined\") return;\n const ro = new ResizeObserver((entries) => {\n for (const e of entries) {\n if (e.contentRect.width > 0 && e.contentRect.height > 0) {\n setSize({\n w: Math.floor(e.contentRect.width),\n h: Math.floor(e.contentRect.height),\n });\n }\n }\n });\n ro.observe(observed);\n return () => ro.disconnect();\n }, [observed]);\n\n return { ref, size };\n}\n","import type { CommandHold, RailDirection } from \"@ksp-gonogo/sitrep-sdk\";\nimport type { InFlightListItem } from \"./InFlightList\";\n\n/**\n * The structural subset of an in-flight command that this mapping reads. Useful\n * for passing the commands a widget has sent to the display that shows the\n * operator what is still on its way. Taken by {@link toInFlightListItems}.\n *\n * @category CommandDelay\n */\nexport interface InFlightCommandLike {\n /** Stable for the entry's lifetime, so the list keeps its row as it moves. */\n id: string;\n /** The entry in the operator's words, such as \"SAS Prograde\". */\n label: string;\n /** The command id it was sent as. */\n command: string;\n /** Seconds until it reaches the far end; `null` when there is no path. */\n reachEtaSeconds: number | null;\n /** Seconds until its reply is expected back; `null` when there is no path, and always for an entry that expects no reply. */\n replyEtaSeconds: number | null;\n /** Where it is expected to be now. */\n predictedPhase: InFlightListItem[\"phase\"];\n /** The issuing button's own terse glyph (\"PRO\", \"RET\"). Defaults to an abbreviation of `label`. */\n glyph?: string;\n /** Which way the entry crosses the link. Absent reads as a command going up. */\n direction?: RailDirection;\n /** The one-way delay the entry was sent under, which places an entry with no reply leg. Absent or `null` for one sent with no route known. */\n oneWaySeconds?: number | null;\n /** When it was sent, as a UT, which orders a queue merged from several handles. */\n dispatchedAt?: number;\n /** What the command was sent with, where this screen sent it; absent for a command another screen sent. */\n args?: unknown;\n /** The value another screen's command sets, where the centre reports one: a switch's state as 1 or 0. */\n commandedValue?: number;\n /** True while the route holds the command at a relay, waiting for a link. */\n held?: boolean;\n /** Where a command held on its way out waits, which places it at the relay on the rail. */\n hold?: CommandHold;\n /**\n * Set on an entry that has just left. `confirmed` when it was answered: it is\n * drawn carrying on to the end of the rail over `settleSeconds`, then fading.\n * `failed` when it was refused, failed or dismissed: it is drawn fading where\n * it last was.\n */\n settling?: \"confirmed\" | \"failed\";\n /** How long a `confirmed` entry takes to reach the end of the rail, in seconds. */\n settleSeconds?: number;\n}\n\n/**\n * Fallback queue glyph: the significant word of the label, upper-cased and cut\n * to 4 chars (\"SAS Prograde\" -> \"PROG\"). An identity, never a status word.\n * Useful for labelling a command's tile in the operator's queue. Used by\n * {@link InFlightList} and {@link CommandList}.\n */\nexport function deriveGlyph(label: string): string {\n const words = label.trim().split(/\\s+/).filter(Boolean);\n const pick = words.length > 1 ? words[words.length - 1] : (words[0] ?? \"\");\n const letters = pick.replace(/[^a-zA-Z0-9]/g, \"\");\n return (letters || label).slice(0, 4).toUpperCase();\n}\n\n/**\n * Progress anchored by phase, for when the eta geometry is missing (overdue,\n * lost, zero delay, or a hand-built item). Used by {@link InFlightList}.\n */\nexport const PHASE_PROGRESS: Record<InFlightListItem[\"phase\"], number> = {\n \"in-transit\": 1 / 6,\n \"awaiting-reply\": 1 / 2,\n due: 2 / 3,\n overdue: 2 / 3,\n lost: 2 / 3,\n};\n\n/**\n * An entry's progress along the rail's three equal stages, each one one-way\n * delay long: 0 when sent, 1/3 when it reaches the far end, 2/3 when its reply\n * is due back. The last third is the confirmed stage, which an entry enters\n * only once it is answered (see `settling`), so an entry still unanswered\n * waits at 2/3, or at 1/3 when it expects no reply. Falls back to a phase\n * anchor when the delay or the reach eta is absent. Useful for showing the\n * operator how far a command has travelled.\n */\nexport function journeyProgress(item: InFlightCommandLike): number {\n const reach = item.reachEtaSeconds;\n if (item.hold && reach !== null && reach > 0)\n return outboundWithHold(item.hold);\n const t = oneWayOf(item);\n if (reach === null || t === null) return PHASE_PROGRESS[item.predictedPhase];\n // T is the reply leg (reply - reach), which holds even once reach goes negative, or the sent-under delay with no reply leg.\n const elapsed = t - reach;\n const wait = item.replyEtaSeconds === null ? 1 / 3 : 2 / 3;\n return Math.max(0, Math.min(wait, elapsed / (3 * t)));\n}\n\n/**\n * How long an entry answered now takes to cross the rest of the rail at the\n * pace it travelled, in seconds; 0 when its delay is unknown. Useful for\n * drawing an answered command on through the confirmed stage. Used by the\n * panel delay rail.\n */\nexport function secondsToRailEnd(item: InFlightCommandLike): number {\n const t = oneWayOf(item);\n if (t === null) return 0;\n return Math.max(0, (1 - journeyProgress(item)) * 3 * t);\n}\n\n/* The first third is the way out: a command held on the way is drawn where its hold says it is along it. */\nfunction outboundWithHold(hold: CommandHold): number {\n return Math.max(0, Math.min(1, hold.outbound)) / 3;\n}\n\n/** `T` from the reply leg when there is one, else from the delay the entry was sent under. */\nfunction oneWayOf(item: InFlightCommandLike): number | null {\n const reach = item.reachEtaSeconds;\n const reply = item.replyEtaSeconds;\n if (reach !== null && reply !== null && reply > reach) return reply - reach;\n if (reply === null && item.oneWaySeconds != null && item.oneWaySeconds > 0) {\n return item.oneWaySeconds;\n }\n return null;\n}\n\n/**\n * Maps a handle's in-flight commands (`useCommand().inFlight`) to\n * {@link InFlightListItem}s for {@link InFlightList}. While `in-transit` a row\n * counts down to the command reaching the vessel; after that, to the\n * acknowledgement coming back. `label` falls back to the command id. Useful for\n * showing the operator the commands a widget has sent and when each arrives.\n * Used by {@link CommandDelay}.\n *\n * @category CommandDelay\n */\nexport function toInFlightListItems(\n items: readonly InFlightCommandLike[],\n): InFlightListItem[] {\n return inSendOrder(items).map((item) => ({\n id: item.id,\n label: item.label || item.command,\n etaSeconds:\n item.predictedPhase === \"in-transit\"\n ? item.reachEtaSeconds\n : item.replyEtaSeconds,\n phase: item.predictedPhase,\n // An answered entry is drawn heading for the end, which it glides to over settleSeconds.\n progress: item.settling === \"confirmed\" ? 1 : journeyProgress(item),\n glyph: item.glyph ?? deriveGlyph(item.label || item.command),\n ...(item.held ? { held: true as const } : {}),\n ...(item.settling\n ? { settling: item.settling, settleSeconds: item.settleSeconds ?? 0 }\n : {}),\n ...(item.direction === \"telemetry\" ? { flow: \"inbound\" as const } : {}),\n }));\n}\n\n/** The entries in the order they were sent, an entry with no send time sorting ahead of every one that has one. */\nfunction inSendOrder(\n items: readonly InFlightCommandLike[],\n): readonly InFlightCommandLike[] {\n if (!items.some((i) => i.dispatchedAt !== undefined)) return items;\n return items\n .map((item, index) => ({ item, index }))\n .sort(\n (a, b) =>\n (a.item.dispatchedAt ?? Number.NEGATIVE_INFINITY) -\n (b.item.dispatchedAt ?? Number.NEGATIVE_INFINITY) ||\n a.index - b.index,\n )\n .map(({ item }) => item);\n}\n","import {\n currentMode,\n delayVisibility,\n useViewClockOptional,\n value,\n} from \"@ksp-gonogo/sitrep-sdk\";\nimport {\n type CSSProperties,\n type MouseEvent,\n type RefObject,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport styled, { css, keyframes } from \"styled-components\";\nimport { Countdown } from \"../Countdown\";\nimport { focusRingInset } from \"../focusRing\";\nimport { InlineOverflowGlow, useInlineOverflow } from \"../inlineOverflow\";\nimport { Tooltip } from \"../Tooltip\";\nimport { TONE_MARK, TONE_TEXT } from \"../tone\";\nimport { writeQuantity } from \"../units\";\nimport { useElementSize } from \"../useElementSize\";\nimport { focusBesideDismissed } from \"./focusBesideDismissed\";\nimport { SETTLE_FADE_MS } from \"./settle\";\nimport { deriveGlyph, PHASE_PROGRESS } from \"./toInFlightListItems\";\n\n/**\n * Which delay reading a console draws, or `none`. Returned by\n * {@link signalDelayPresentation}.\n */\nexport type SignalDelayPresentation = \"badge\" | \"strip\" | \"none\";\n\nexport interface SignalDelayPresentationInput {\n /**\n * One-way separation in seconds, `null` when there is no measurable path.\n * Neither `null` nor a measured zero gets a badge.\n */\n oneWaySeconds: number | null;\n /**\n * Whether this console can put something in the strip. A read-only viewer\n * gets neither reading at a long delay: no queue, and no cost it ever pays.\n */\n canQueue: boolean;\n /**\n * Force the badge whatever the magnitude, for a terminal in character mode:\n * every keystroke goes on its own, so the strip has nothing to list.\n */\n alwaysBadge?: boolean;\n}\n\n/**\n * Which one of the two delay readings a console shows, given the one-way delay\n * between the command centre and its vessel or device:\n *\n * - a badge is a standing readout of the delay, useful before anything\n * has been sent\n * - a strip ({@link InFlightList}) is one row per command in flight, useful\n * once something is out\n *\n * The two are mutually exclusive: drawn together they say the same number twice\n * in two shapes. The boundary is `currentMode`'s, the same one the engine uses\n * to stage a dispatch rather than send it live. Useful for showing the operator\n * one delay readout, not two. Used by {@link Console}.\n */\nexport function signalDelayPresentation({\n oneWaySeconds,\n canQueue,\n alwaysBadge = false,\n}: SignalDelayPresentationInput): SignalDelayPresentation {\n if (oneWaySeconds === null || delayVisibility(oneWaySeconds) !== \"shown\") {\n return \"none\";\n }\n if (alwaysBadge) return \"badge\";\n if (currentMode({ oneWaySeconds: value(\"s\", oneWaySeconds) }) === \"live\") {\n return \"badge\";\n }\n return canQueue ? \"strip\" : \"none\";\n}\n\n/**\n * Display shape for one delayed command. `etaSeconds` is the\n * caller's choice of clock (reach or reply); `null` renders as \"no ETA\" (an\n * `overdue` or `lost` entry, or `no-path` mode). Useful for showing the operator\n * one command that has left the command centre. Taken by {@link InFlightList}\n * and built by {@link toInFlightListItems}.\n *\n * @category CommandDelay\n */\nexport interface InFlightListItem {\n /** Identifies the command. */\n id: string;\n /** What the command is called in the list. */\n label: string;\n /** Seconds until it reaches the craft or is answered, or `null` for none. */\n etaSeconds: number | null;\n /** Where the command is on its way. */\n phase: \"in-transit\" | \"awaiting-reply\" | \"due\" | \"overdue\" | \"lost\";\n /**\n * How far the command is along the rail's three equal stages: 1/3 when it\n * reaches the craft, 2/3 when its reply is due, and 1 at the end of the\n * confirmed stage. The `variant=\"rail\"` mark and the `variant=\"expanded\"`\n * bar read it; without it they place the command by phase.\n */\n progress?: number;\n /**\n * The command's own terse glyph (\"PRO\", \"RET\", \"WARP\"), shown in the\n * `variant=\"expanded\"` queue square. Phase is conveyed by colour, never by\n * the glyph. Defaults to an abbreviation of `label`.\n */\n glyph?: string;\n /** Which way the entry crosses: `outbound` to the craft (the default), `inbound` home from it. */\n flow?: \"outbound\" | \"inbound\";\n /** True while the route holds the command at a relay: drawn still, in the held colour. */\n held?: true;\n /**\n * Set on a command that has just left. The `rail` and `expanded` variants\n * draw a `confirmed` one moving on to `progress` over `settleSeconds`, then\n * fading, and a `failed` one fading where it was, in the warning colour.\n * Every other variant leaves it out.\n */\n settling?: \"confirmed\" | \"failed\";\n /** How long a `confirmed` command takes to reach `progress`, in seconds. */\n settleSeconds?: number;\n}\n\n/**\n * How commands reach the vessel, as `useCommand`'s `delayMode` reports it:\n * `live` under the staged threshold, `staged` above it, `no-path` when nothing\n * is measurable. {@link InFlightList} writes it to its root's `data-mode` attribute, for\n * styling, and draws nothing different for it: each command already shows its\n * own phase and countdown, and under `no-path` it shows \"no ETA\".\n * Useful for styling the list of in-flight commands by how they reach the\n * vessel.\n *\n * @category CommandDelay\n */\nexport type InFlightListMode = \"live\" | \"staged\" | \"no-path\";\n\n/**\n * How much of each in-flight command {@link InFlightList} draws, by the room\n * it has. Independent of `mode`, which describes how commands reach the vessel.\n * Set with the `density` prop of {@link InFlightList}.\n * Useful for fitting the list of in-flight commands to a wide panel or a\n * narrow one.\n *\n * - `full`: arrow, label and countdown per command, one per line\n * - `compact`: arrow and countdown only; the label moves to the accessible\n * name and tooltip\n * - `badge`: one chip for the whole set, with the count and the nearest\n * arrival\n * - `auto` (the default): measures the rendered width and picks one of the\n * three\n *\n * @category CommandDelay\n */\nexport type InFlightListDensity = \"auto\" | \"full\" | \"compact\" | \"badge\";\n\n/**\n * Props for {@link InFlightList}: the commands in flight and how much of each to\n * draw.\n * Useful for choosing which in-flight commands the operator sees and how much\n * of each. Used by {@link InFlightList}.\n *\n * @category CommandDelay\n */\nexport interface InFlightListProps {\n /** The commands in flight; `toInFlightListItems(handle.inFlight)` builds them. */\n items: InFlightListItem[];\n /** The link's mode, written to `data-mode`. */\n mode?: InFlightListMode;\n /** Defaults to `auto`. */\n density?: InFlightListDensity;\n /**\n * `column` stacks the entries, `row` flows them. A queue under a button\n * group wants a column; one beside an action row wants a row. Row wraps, so\n * it degrades to several short lines rather than overflowing.\n */\n orientation?: \"column\" | \"row\";\n /** Accessible label for the list region. Defaults to \"In-flight commands\". */\n \"aria-label\"?: string;\n /**\n * `\"inline\"` (default) is the monospace row/badge list. `\"rail\"` is the\n * Panel rail's 16px strip: each command is a soft glow grazing the top edge,\n * sweeping left to right by journey progress. `\"expanded\"` is the pinned\n * detail: a queue square per command. `mode`, `density` and `orientation`\n * apply to `\"inline\"` only.\n */\n variant?: \"inline\" | \"rail\" | \"expanded\";\n /**\n * Clear an unanswered command (`overdue`/`lost`) from the shared delay queue.\n * When given, the `\"expanded\"` queue's unanswered squares become real clear buttons.\n * Applies to `\"expanded\"` only.\n */\n onDismiss?: (id: string) => void;\n}\n\nconst PHASE_ARROW: Record<InFlightListItem[\"phase\"], string> = {\n \"in-transit\": \"↑\",\n \"awaiting-reply\": \"↓\",\n due: \"↓\",\n overdue: \"!\",\n lost: \"?\",\n};\n\n/**\n * The word an entry with no countdown shows and speaks. A `lost` command got no\n * reply and may still have run, so it reads as unconfirmed, never as failed.\n */\nconst PHASE_WORD: Record<InFlightListItem[\"phase\"], string> = {\n \"in-transit\": \"in transit\",\n \"awaiting-reply\": \"awaiting reply\",\n due: \"due\",\n overdue: \"overdue\",\n lost: \"unconfirmed\",\n};\n\n/** An inbound entry in transit is coming down, whatever the phase table says a command does. */\nfunction arrowOf(item: InFlightListItem): string {\n if (item.flow === \"inbound\" && item.phase === \"in-transit\") return \"↓\";\n return PHASE_ARROW[item.phase];\n}\n\nconst ERROR_PHASES = new Set<InFlightListItem[\"phase\"]>([\"overdue\", \"lost\"]);\n\n/**\n * Width thresholds for `auto`, in px, set by what the content needs. `full`\n * needs arrow, countdown, gaps and padding plus about 100px of label room;\n * `compact` needs arrow plus countdown. Below that the set collapses to the\n * badge.\n */\nconst FULL_MIN_WIDTH = 180;\nconst COMPACT_MIN_WIDTH = 96;\n\n/**\n * The countdown a strip speaks, for the accessible name and a row's `title`.\n * Clamped at zero: a strip shows time remaining, never a negative duration.\n */\nfunction clampedCountdown(seconds: number): string {\n return writeQuantity(value(\"s\", Math.max(0, seconds)));\n}\n\nfunction nearestEta(items: InFlightListItem[]): number | null {\n let best: number | null = null;\n for (const item of items) {\n if (item.etaSeconds === null) continue;\n if (best === null || item.etaSeconds < best) best = item.etaSeconds;\n }\n return best;\n}\n\n/** Take the caller's figure again only on a change this large (seconds): its `etaSeconds` drifts by fractions on every re-render. */\nconst RESYNC_THRESHOLD_SECONDS = 1;\n\n/**\n * The seconds left before something arrives, counted down in game time from\n * the figure the caller passes. Useful for showing the operator the seconds\n * left before a command reaches the vessel. Used by {@link InFlightList}.\n *\n * It follows the game's clock: it stands still while the game is paused and\n * falls at the warp rate under time warp. The caller need not re-render for\n * it to move, and a new `etaSeconds` replaces the count once it differs from\n * the last one taken by a second or more. With no telemetry stream mounted\n * there is no game clock, and it returns `etaSeconds` unchanged.\n */\nexport function useCountdown(etaSeconds: number | null): number | null {\n const clock = useViewClockOptional();\n const clockRef = useRef(clock);\n clockRef.current = clock;\n const [value, setValue] = useState(etaSeconds);\n // The figure last taken from the caller, and the game time it was taken at.\n const seedRef = useRef({ eta: etaSeconds, ut: gameNow(clock) });\n\n useEffect(() => {\n const last = seedRef.current.eta;\n const jumped =\n (last === null) !== (etaSeconds === null) ||\n (last !== null &&\n etaSeconds !== null &&\n Math.abs(etaSeconds - last) >= RESYNC_THRESHOLD_SECONDS);\n if (jumped) {\n seedRef.current = { eta: etaSeconds, ut: gameNow(clockRef.current) };\n setValue(etaSeconds);\n }\n }, [etaSeconds]);\n\n /*\n * The interval is only what redraws the number once a second. What it draws\n * is read off the game clock each time, so wall time passing while game time\n * does not (a paused game) moves nothing. Mount-once and not keyed on\n * `etaSeconds`, which drifts every render and would never let a second pass.\n */\n useEffect(() => {\n const id = setInterval(() => {\n const { eta, ut } = seedRef.current;\n if (eta === null) return;\n const now = gameNow(clockRef.current);\n if (now === undefined) return;\n // The figure was taken before the clock had a time: count from the first time it gives.\n if (ut === undefined) {\n seedRef.current = { eta, ut: now };\n return;\n }\n setValue(Math.max(0, eta - (now - ut)));\n }, 1000);\n return () => clearInterval(id);\n }, []);\n\n return value;\n}\n\n/** The game's present in UT seconds, or `undefined` with no clock or before it has a time. */\nfunction gameNow(\n clock: ReturnType<typeof useViewClockOptional>,\n): number | undefined {\n const ut = clock?.utNowEstimate();\n return ut !== undefined && Number.isFinite(ut) ? ut : undefined;\n}\n\n/**\n * A list of in-flight commands: rows with per-entry countdowns and phase\n * styling. Useful for showing the operator which commands have left and when\n * each arrives. Used by {@link CommandDelay} and {@link Console}. Renders\n * nothing for an empty set. It has no data hooks; build its items from\n * `useCommand().inFlight` with {@link toInFlightListItems}.\n *\n * @category CommandDelay\n */\nexport function InFlightList({\n items: allItems,\n mode,\n density = \"auto\",\n orientation = \"column\",\n \"aria-label\": ariaLabel = \"In-flight commands\",\n variant = \"inline\",\n onDismiss,\n}: InFlightListProps) {\n // Seeded wide so `auto` only ever shrinks from the full form, never flashing a badge on mount.\n const { ref, size } = useElementSize({ w: 320, h: 0 });\n // Only the rail and the queue draw a command fading out; a list row or a count would read it as still out.\n const items =\n variant === \"rail\" || variant === \"expanded\"\n ? allItems\n : allItems.filter((item) => !item.settling);\n\n // The rail and expanded renderings bypass density entirely.\n if (variant === \"rail\") {\n if (items.length === 0) return null;\n return <InFlightRailStrip items={items} aria-label={ariaLabel} />;\n }\n if (variant === \"expanded\") {\n if (items.length === 0) return null;\n return (\n <InFlightQueue\n items={items}\n aria-label={ariaLabel}\n onDismiss={onDismiss}\n />\n );\n }\n\n const resolved: Exclude<InFlightListDensity, \"auto\"> =\n density !== \"auto\"\n ? density\n : size.w >= FULL_MIN_WIDTH\n ? \"full\"\n : size.w >= COMPACT_MIN_WIDTH\n ? \"compact\"\n : \"badge\";\n\n // The size hook keeps its last measurement across an empty render.\n if (items.length === 0) return null;\n\n if (resolved === \"badge\") {\n return (\n <InFlightBadge\n ref={ref}\n items={items}\n mode={mode}\n aria-label={ariaLabel}\n />\n );\n }\n\n return (\n <InFlightList__Root\n ref={ref}\n role=\"list\"\n aria-label={ariaLabel}\n data-mode={mode}\n data-density={resolved}\n $row={orientation === \"row\"}\n >\n {items.map((item) => (\n <InFlightRow\n key={item.id}\n item={item}\n $compact={resolved === \"compact\"}\n />\n ))}\n </InFlightList__Root>\n );\n}\n\n/*\n * Rail strip: each command is a bright dot with a soft halo, at x by how far\n * it is through its trip. It crosses the whole strip and sits at the right end\n * once its reply is due. A command that has just left fades where it last was\n * rather than vanishing. The dot rides the strip's top edge with its top two\n * thirds above it, so only its lower tip and halo show under the panel edge.\n */\nconst RAIL_DOT_PX = 8;\nconst RAIL_DOT_SHOWN = 1 / 3;\n\nfunction InFlightRailStrip({\n items,\n \"aria-label\": ariaLabel,\n}: {\n items: InFlightListItem[];\n \"aria-label\": string;\n}) {\n const live = items.filter((item) => !item.settling);\n return (\n <InFlightRailStrip__Track\n role=\"img\"\n aria-label={`${ariaLabel}: ${live.length} in flight`}\n >\n {items.map((item) => {\n const progress = Math.max(\n 0,\n Math.min(1, item.progress ?? PHASE_PROGRESS[item.phase]),\n );\n return (\n <InFlightRailStrip__Dot\n key={item.id}\n {...(item.settling\n ? { \"data-role\": \"settling\", \"data-settling\": item.settling }\n : {\n \"data-role\": \"glow\",\n \"data-phase\": item.phase,\n ...(item.held ? { \"data-held\": \"\" } : {}),\n })}\n $settling={item.settling}\n style={\n {\n \"--dot-colour\": markColour(item),\n \"--dot-progress\": progress,\n \"--settle-seconds\": item.settleSeconds ?? 0,\n } as CSSProperties\n }\n />\n );\n })}\n </InFlightRailStrip__Track>\n );\n}\n\n/** The whole queue as one chip: how many are out, and when the next one arrives. */\nconst InFlightBadge = function InFlightBadge({\n ref,\n items,\n mode,\n \"aria-label\": ariaLabel,\n}: {\n ref: RefObject<HTMLDivElement>;\n items: InFlightListItem[];\n mode?: InFlightListMode;\n \"aria-label\": string;\n}) {\n const countdown = useCountdown(nearestEta(items));\n const worst = items.some((i) => ERROR_PHASES.has(i.phase));\n const summary =\n countdown === null\n ? `${items.length} in flight`\n : `${items.length} in flight, next in ${clampedCountdown(countdown)}`;\n return (\n <Tooltip text={items.map((i) => i.label).join(\"\\n\")} focusable>\n <InFlightList__Root\n ref={ref}\n role=\"group\"\n aria-label={`${ariaLabel}: ${summary}`}\n data-mode={mode}\n data-density=\"badge\"\n $row={false}\n >\n <InFlightList__Row $phase={worst ? \"overdue\" : \"in-transit\"}>\n <InFlightList__Arrow aria-hidden=\"true\" $pulse={!worst}>\n ↑\n </InFlightList__Arrow>\n <InFlightList__Phase>\n {items.length}\n {countdown !== null && (\n <>\n {\" · \"}\n <Countdown value={Math.max(0, countdown)} />\n </>\n )}\n </InFlightList__Phase>\n </InFlightList__Row>\n </InFlightList__Root>\n </Tooltip>\n );\n};\n\nfunction InFlightRow({\n item,\n $compact,\n}: {\n item: InFlightListItem;\n $compact: boolean;\n}) {\n const countdown = useCountdown(item.etaSeconds);\n const isError = ERROR_PHASES.has(item.phase);\n const spoken =\n countdown === null\n ? `${item.label}, ${PHASE_WORD[item.phase]}`\n : `${item.label}, ${clampedCountdown(countdown)}`;\n return (\n // Compact drops the visible label, so the row carries it as its accessible name; `title` is only a convenience.\n <InFlightList__Row\n $phase={item.phase}\n role=\"listitem\"\n {...($compact ? { \"aria-label\": spoken, title: spoken } : {})}\n >\n <InFlightList__Arrow\n aria-hidden=\"true\"\n $pulse={!isError}\n $inherit={isError}\n >\n {arrowOf(item)}\n </InFlightList__Arrow>\n {!$compact && <InFlightList__Label>{item.label}</InFlightList__Label>}\n <InFlightList__Phase>\n {countdown === null ? (\n PHASE_WORD[item.phase]\n ) : (\n <Countdown value={Math.max(0, countdown)} />\n )}\n </InFlightList__Phase>\n </InFlightList__Row>\n );\n}\n\nconst settleOut = keyframes`\n from { opacity: 1; }\n to { opacity: 0; }\n`;\n\nconst InFlightRailStrip__Track = styled.div`\n position: relative;\n display: block;\n width: 100%;\n height: 16px;\n /* Clips the part of each dot above the strip, whatever box holds it. */\n overflow: hidden;\n`;\n\n/*\n * The opened rail's marks: whole dots, one lane per command, the first at the\n * middle of the height and each next one a lane below, then above, and so on.\n * Each drops in from the top edge, where the closed rail drew its tip.\n */\nconst LANE_GAP_PX = 14;\n\nfunction laneTop(index: number, count: number, height: number): number {\n const gap = Math.min(\n LANE_GAP_PX,\n (height - RAIL_DOT_PX) / Math.max(1, count),\n );\n const step = Math.ceil(index / 2) * (index % 2 === 1 ? 1 : -1);\n const centre = height / 2 + step * gap;\n return Math.max(0, Math.min(height - RAIL_DOT_PX, centre - RAIL_DOT_PX / 2));\n}\n\n/**\n * The commands on the opened delay rail, as whole dots in lanes down a box of\n * `height` pixels, placed along it as the closed rail's marks are. Used by the\n * panel delay rail.\n */\nexport function InFlightLanes({\n items,\n height,\n}: {\n items: InFlightListItem[];\n height: number;\n}) {\n return (\n <InFlightLanes__Box\n role=\"group\"\n aria-label=\"Commands on the rail\"\n style={{ height }}\n >\n {items.map((item, index) => {\n const progress = Math.max(\n 0,\n Math.min(1, item.progress ?? PHASE_PROGRESS[item.phase]),\n );\n // A dot names its command on hover, in the words its queue square uses.\n return (\n <Tooltip\n key={item.id}\n text={\n item.settling ? null : `${item.label}, ${PHASE_WORD[item.phase]}`\n }\n announce={false}\n focusable={!item.settling}\n >\n <InFlightRailStrip__Dot\n {...(item.settling\n ? {\n \"data-role\": \"settling\",\n \"data-settling\": item.settling,\n \"aria-hidden\": true,\n }\n : {\n role: \"img\",\n \"aria-label\": `${item.label}, ${PHASE_WORD[item.phase]}`,\n \"data-role\": \"glow\",\n \"data-phase\": item.phase,\n ...(item.held ? { \"data-held\": \"\" } : {}),\n })}\n data-lane={index}\n $settling={item.settling}\n $lane\n style={\n {\n \"--dot-colour\": markColour(item),\n \"--dot-progress\": progress,\n \"--settle-seconds\": item.settleSeconds ?? 0,\n \"--lane-top\": `${laneTop(index, items.length, height)}px`,\n } as CSSProperties\n }\n />\n </Tooltip>\n );\n })}\n </InFlightLanes__Box>\n );\n}\n\n/** A command's colour: the warning tone when held, unanswered or failed, so it is never invisible, the accent otherwise. */\nfunction markColour(item: InFlightListItem): string {\n // An answered command is confirmed, however late its reply came.\n if (item.settling === \"confirmed\") return \"var(--color-accent-fg)\";\n return item.held || item.settling === \"failed\" || ERROR_PHASES.has(item.phase)\n ? TONE_MARK.warn\n : \"var(--color-accent-fg)\";\n}\n\n/*\n * A confirmed command glides on to the end over its settle time, then fades; a\n * failed one fades where it is.\n */\nconst settleMotion = (settling: InFlightListItem[\"settling\"]) =>\n settling === \"confirmed\"\n ? css`\n transition: left var(--settle-time) var(--ease-linear);\n animation: ${settleOut} ${SETTLE_FADE_MS}ms var(--ease-standard) var(--settle-time) forwards;\n `\n : settling === \"failed\"\n ? css`\n animation: ${settleOut} ${SETTLE_FADE_MS}ms var(--ease-standard) forwards;\n `\n : null;\n\nconst dropIn = keyframes`\n from { top: ${-RAIL_DOT_PX * (1 - RAIL_DOT_SHOWN)}px; }\n to { top: var(--lane-top); }\n`;\n\nconst InFlightLanes__Box = styled.div`\n position: relative;\n width: 100%;\n overflow: hidden;\n`;\n\nconst InFlightRailStrip__Dot = styled.span<{\n $settling: InFlightListItem[\"settling\"];\n $lane?: boolean;\n}>`\n position: absolute;\n /* The settle time arrives as a bare count of seconds. */\n --settle-time: calc(var(--settle-seconds, 0) * 1000ms);\n top: ${-RAIL_DOT_PX * (1 - RAIL_DOT_SHOWN)}px;\n /* The dot's own width is kept inside the strip, so it is whole at both ends. */\n left: calc((100% - ${RAIL_DOT_PX}px) * var(--dot-progress));\n width: ${RAIL_DOT_PX}px;\n height: ${RAIL_DOT_PX}px;\n border-radius: var(--radius-circle);\n background: var(--dot-colour);\n box-shadow:\n 0 0 6px 2px color-mix(in srgb, var(--dot-colour) 60%, transparent),\n 0 0 14px 4px color-mix(in srgb, var(--dot-colour) 25%, transparent);\n\n ${({ $lane, $settling }) =>\n $lane &&\n css`\n top: var(--lane-top);\n /* A hover target a little larger than the dot, so its name is easy to find. */\n pointer-events: ${$settling ? \"none\" : \"auto\"};\n &::before {\n content: \"\";\n position: absolute;\n inset: -4px;\n }\n `}\n\n @media (prefers-reduced-motion: no-preference) {\n transition: left var(--duration-slow) var(--ease-linear);\n ${({ $settling }) => settleMotion($settling)}\n ${({ $lane, $settling }) =>\n $lane &&\n !$settling &&\n css`\n animation: ${dropIn} var(--duration-base) var(--ease-entrance);\n `}\n }\n`;\n\n/*\n * The expanded command queue: a SQUARE per command showing its own glyph,\n * never a status icon. Phase is colour, progress a thin bar, full when the\n * reply lands. One box for every command on the panel, which never grows the\n * widget: a queue longer than the box scrolls. A row in a wide box, a column\n * in a narrow one. An unanswered (lost or overdue) square is a clear button.\n */\nconst QUEUE_THICK = 54; // px\nconst QUEUE_BAR = 5;\nconst QUEUE_GAP = 3;\nconst QUEUE_SQUARE = QUEUE_THICK - 8 - QUEUE_BAR; // less border+padding and bar\nconst QUEUE_ROW_MIN = 60; // container width at/above which the queue runs as a row\n\nconst QUEUE_COLOUR: Record<InFlightListItem[\"phase\"], string> = {\n \"in-transit\": \"var(--color-accent-fg)\",\n \"awaiting-reply\": \"var(--color-accent-fg)\",\n due: \"var(--color-accent-fg)\",\n overdue: TONE_MARK.warn,\n lost: TONE_MARK.warn,\n};\n\nfunction InFlightQueue({\n items,\n \"aria-label\": ariaLabel,\n onDismiss,\n}: {\n items: InFlightListItem[];\n \"aria-label\": string;\n onDismiss?: (id: string) => void;\n}) {\n const [scroller, setScroller] = useState<HTMLDivElement | null>(null);\n const overflow = useInlineOverflow(scroller);\n // A row longer than its box scrolls sideways, and only then takes keyboard focus to be scrolled.\n const scrolls = overflow.left || overflow.right;\n return (\n <InFlightQueue__Box data-command-list=\"\">\n <InFlightQueue__Inner\n ref={setScroller}\n role=\"list\"\n aria-label={ariaLabel}\n {...(scrolls ? { tabIndex: 0, \"data-scrolls\": \"\" } : {})}\n >\n {items.map((item) => (\n <InFlightQueueCmd key={item.id} item={item} onDismiss={onDismiss} />\n ))}\n </InFlightQueue__Inner>\n <InlineOverflowGlow $position=\"left\" $visible={overflow.left} />\n <InlineOverflowGlow $position=\"right\" $visible={overflow.right} />\n </InFlightQueue__Box>\n );\n}\n\nfunction InFlightQueueCmd({\n item,\n onDismiss,\n}: {\n item: InFlightListItem;\n onDismiss?: (id: string) => void;\n}) {\n const glyph = item.glyph ?? deriveGlyph(item.label);\n const colour =\n item.settling === \"confirmed\"\n ? QUEUE_COLOUR[\"awaiting-reply\"]\n : item.held || item.settling === \"failed\"\n ? TONE_MARK.warn\n : QUEUE_COLOUR[item.phase];\n // The bar is full when the reply lands, at two thirds; the last third is the rail's confirmed stage.\n const progress = Math.max(\n 0,\n Math.min(1, (item.progress ?? PHASE_PROGRESS[item.phase]) * 1.5),\n );\n const dismissable =\n ERROR_PHASES.has(item.phase) && !!onDismiss && !item.settling;\n const spoken = `${item.label}, ${PHASE_WORD[item.phase]}`;\n return (\n <InFlightQueue__Cmd\n role=\"listitem\"\n aria-label={spoken}\n {...(item.settling\n ? { \"data-settling\": item.settling, \"aria-hidden\": true }\n : {\n \"data-phase\": item.phase,\n ...(item.held ? { \"data-held\": \"\" } : {}),\n })}\n $settling={item.settling}\n style={\n {\n color: colour,\n \"--settle-seconds\": item.settleSeconds ?? 0,\n } as CSSProperties\n }\n >\n <Tooltip\n text={dismissable ? `Dismiss ${item.label}` : spoken}\n announce={false}\n >\n <InFlightQueue__Sq\n as={dismissable ? \"button\" : \"div\"}\n {...(dismissable\n ? {\n type: \"button\" as const,\n \"data-dismiss\": \"\",\n onClick: (event: MouseEvent<HTMLElement>) => {\n focusBesideDismissed(event.currentTarget);\n onDismiss?.(item.id);\n },\n \"aria-label\": `Dismiss ${item.label}`,\n }\n : { \"aria-hidden\": true })}\n >\n <span className=\"glyph\" aria-hidden=\"true\">\n {glyph}\n </span>\n {dismissable && (\n <span className=\"dismiss\" aria-hidden=\"true\">\n ✕\n </span>\n )}\n </InFlightQueue__Sq>\n </Tooltip>\n <InFlightQueue__Bar>\n <span\n className=\"fill\"\n style={{ \"--fill-ratio\": progress } as CSSProperties}\n />\n </InFlightQueue__Bar>\n </InFlightQueue__Cmd>\n );\n}\n\nconst InFlightQueue__Box = styled.div.attrs({ role: \"group\" })`\n container-type: inline-size;\n /* Never shrinks in the rail's flex column, so a combined pinned rail shows the whole tile row. */\n flex: 0 0 auto;\n /* The row container the tiles sit in; its horizontal inset matches the standard content margin. */\n margin: var(--outset-command-strip);\n /* The inset equals (panel radius - tile radius), so the first tile's corner nests concentrically in the panel's. */\n --queue-panel-radius: calc(var(--radius-floating) * 2);\n --queue-tile-inset: calc(var(--queue-panel-radius) - var(--radius-regular));\n padding: var(--queue-tile-inset);\n height: calc(\n ${QUEUE_SQUARE}px + ${QUEUE_BAR}px + (var(--queue-tile-inset) * 2)\n );\n border-radius: var(--queue-panel-radius);\n background: color-mix(in srgb, var(--color-surface-raised) 68%, transparent);\n backdrop-filter: blur(6px);\n overflow: hidden;\n /* Holds the overflow glows over the row's edges. */\n position: relative;\n`;\n\n/* One row, one row high however many commands are in it; it scrolls sideways, its edge glows showing there is more. */\nconst InFlightQueue__Inner = styled.div`\n display: flex;\n flex-direction: row;\n /* Centred on the cross axis so both margins match; the main axis fills from the start, so a short queue reads as started. */\n align-items: center;\n justify-content: flex-start;\n gap: ${QUEUE_GAP}px;\n width: 100%;\n height: 100%;\n overflow-x: auto;\n overflow-y: hidden;\n /* Native scrollbar hidden: the edge glows show scroll state. */\n scrollbar-width: none;\n &::-webkit-scrollbar {\n display: none;\n }\n\n ${focusRingInset}\n`;\n\nconst InFlightQueue__Cmd = styled.div<{\n $settling: InFlightListItem[\"settling\"];\n}>`\n /* The settle time arrives as a bare count of seconds. */\n --settle-time: calc(var(--settle-seconds, 0) * 1000ms);\n display: flex;\n flex: 0 0 auto;\n flex-direction: row;\n min-width: 0;\n min-height: 0;\n\n @media (prefers-reduced-motion: no-preference) {\n ${({ $settling }) =>\n $settling === \"confirmed\"\n ? css`\n animation: ${settleOut} ${SETTLE_FADE_MS}ms var(--ease-standard)\n var(--settle-time) forwards;\n .fill {\n transition:\n height var(--settle-time) var(--ease-linear),\n width var(--settle-time) var(--ease-linear);\n }\n `\n : $settling === \"failed\"\n ? css`\n animation: ${settleOut} ${SETTLE_FADE_MS}ms var(--ease-standard) forwards;\n `\n : null}\n }\n\n @container (min-width: ${QUEUE_ROW_MIN}px) {\n flex-direction: column;\n }\n`;\n\nconst InFlightQueue__Sq = styled.div`\n --s: ${QUEUE_SQUARE}px;\n flex: 0 0 var(--s);\n width: var(--s);\n height: var(--s);\n align-self: center;\n position: relative;\n display: grid;\n place-items: center;\n margin: 0;\n padding: 0;\n appearance: none;\n font: inherit;\n font-size: var(--font-size-compact);\n font-weight: 700;\n color: currentColor;\n background: color-mix(in srgb, currentColor 10%, var(--color-surface-raised));\n border: 1px solid currentColor;\n border-right: 0;\n border-radius: var(--radius-regular) 0 0 var(--radius-regular);\n overflow: hidden;\n\n @container (min-width: ${QUEUE_ROW_MIN}px) {\n border-right: 1px solid currentColor;\n border-bottom: 0;\n border-radius: var(--radius-regular) var(--radius-regular) 0 0;\n }\n\n .glyph {\n position: absolute;\n inset: 0;\n display: grid;\n place-items: center;\n color: var(--color-text-primary);\n }\n .dismiss {\n position: absolute;\n inset: 0;\n display: grid;\n place-items: center;\n opacity: 0;\n background: color-mix(in srgb, currentColor 22%, var(--color-surface-sunken));\n }\n\n &:is(button) {\n cursor: pointer;\n }\n &:is(button):hover .dismiss,\n &:is(button):focus-visible .dismiss {\n opacity: 1;\n }\n &:is(button):hover .glyph,\n &:is(button):focus-visible .glyph {\n opacity: 0;\n }\n /* Not the kit's shared ring: every other part of the tile follows the phase colour through currentColor. */\n &:focus-visible {\n outline: 2px solid currentColor;\n outline-offset: 1px;\n }\n`;\n\nconst InFlightQueue__Bar = styled.div`\n --s: ${QUEUE_SQUARE}px;\n position: relative;\n flex: 0 0 ${QUEUE_BAR}px;\n width: ${QUEUE_BAR}px;\n height: var(--s);\n overflow: hidden;\n background: var(--color-surface-panel);\n border: 1px solid currentColor;\n border-radius: 0 var(--radius-regular) var(--radius-regular) 0;\n\n @container (min-width: ${QUEUE_ROW_MIN}px) {\n width: var(--s);\n height: ${QUEUE_BAR}px;\n border-radius: 0 0 var(--radius-regular) var(--radius-regular);\n }\n\n .fill {\n position: absolute;\n left: 0;\n right: 0;\n bottom: 0;\n height: calc(var(--fill-ratio, 0) * 100%);\n background: currentColor;\n }\n @container (min-width: ${QUEUE_ROW_MIN}px) {\n .fill {\n top: 0;\n bottom: 0;\n left: 0;\n right: auto;\n width: calc(var(--fill-ratio, 0) * 100%);\n height: auto;\n }\n }\n`;\n\nconst InFlightList__Root = styled.div<{ $row: boolean }>`\n flex: 0 0 auto;\n display: flex;\n flex-direction: ${({ $row }) => ($row ? \"row\" : \"column\")};\n flex-wrap: ${({ $row }) => ($row ? \"wrap\" : \"nowrap\")};\n column-gap: var(--gap-command-list-column);\n gap: var(--gap-command-list-row);\n padding: var(--inset-command-list);\n font-family: var(--font-family-mono);\n font-size: var(--font-size-compact);\n background: var(--color-surface-panel);\n border: 1px solid var(--color-border-subtle);\n border-radius: var(--radius-regular);\n`;\n\nconst PHASE_ROW_STYLES: Record<\n InFlightListItem[\"phase\"],\n ReturnType<typeof css>\n> = {\n \"in-transit\": css`\n color: var(--color-text-primary);\n `,\n \"awaiting-reply\": css`\n color: var(--color-text-muted);\n `,\n due: css`\n color: var(--color-text-muted);\n `,\n overdue: css`\n color: ${TONE_TEXT.warn};\n `,\n lost: css`\n color: ${TONE_TEXT.warn};\n `,\n};\n\nconst InFlightList__Row = styled.div<{ $phase: InFlightListItem[\"phase\"] }>`\n display: flex;\n align-items: baseline;\n gap: var(--gap-command-row);\n\n ${({ $phase }) => PHASE_ROW_STYLES[$phase]}\n`;\n\n/** `$inherit` draws the glyph in its row's colour, so an unanswered entry's mark carries its tone. */\nconst InFlightList__Arrow = styled.span<{\n $pulse: boolean;\n $inherit?: boolean;\n}>`\n flex: 0 0 auto;\n color: ${({ $inherit }) => ($inherit ? \"inherit\" : \"var(--color-accent-fg)\")};\n\n ${({ $pulse }) =>\n $pulse &&\n css`\n @media (prefers-reduced-motion: no-preference) {\n animation: in-flight-list-pulse 1.6s var(--ease-emphasis) infinite;\n }\n `}\n\n @keyframes in-flight-list-pulse {\n 50% {\n opacity: 0.35;\n }\n }\n`;\n\nconst InFlightList__Label = styled.span`\n flex: 1 1 auto;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n`;\n\nconst InFlightList__Phase = styled.span`\n flex: 0 0 auto;\n`;\n","import { useEffect, useRef, useState } from \"react\";\nimport styled from \"styled-components\";\n\nexport interface InlineOverflow {\n /** Content is scrolled past on the start edge. */\n left: boolean;\n /** Content remains beyond the end edge. */\n right: boolean;\n}\n\nconst NONE: InlineOverflow = { left: false, right: false };\n\n/**\n * Which inline edges of a horizontal scroller have content beyond them, kept\n * current across scrolling and across the scroller or its children resizing.\n * Useful for telling the operator that a strip of tabs or columns continues\n * past an edge. Used by {@link Tabs} and {@link DataTable}.\n */\nexport function useInlineOverflow(el: HTMLElement | null): InlineOverflow {\n const [overflow, setOverflow] = useState(NONE);\n // React's same-value bailout is not guaranteed with other work queued, so an unchanged measurement is filtered here.\n const last = useRef(NONE);\n\n useEffect(() => {\n if (!el) return;\n const update = () => {\n const left = el.scrollLeft > 1;\n const right = el.scrollLeft + el.clientWidth < el.scrollWidth - 1;\n if (last.current.left === left && last.current.right === right) return;\n last.current = { left, right };\n setOverflow(last.current);\n };\n\n update();\n el.addEventListener(\"scroll\", update, { passive: true });\n const ro =\n typeof ResizeObserver === \"undefined\" ? null : new ResizeObserver(update);\n ro?.observe(el);\n for (const child of Array.from(el.children)) ro?.observe(child);\n const mo = new MutationObserver(() => {\n for (const child of Array.from(el.children)) ro?.observe(child);\n update();\n });\n mo.observe(el, { childList: true });\n return () => {\n el.removeEventListener(\"scroll\", update);\n ro?.disconnect();\n mo.disconnect();\n };\n }, [el]);\n\n return overflow;\n}\n\n/**\n * The glow over a horizontal scroller's edge that says more content lies that\n * way. Useful for telling the operator that a strip of tabs or columns\n * continues past an edge. Used by {@link Tabs} and {@link DataTable}. At least the panel gutter wide, so a strip reaching the panel's edge\n * fades out across the gutter instead of stopping hard at the padding. Render\n * it after the scroller: it paints over it by document order.\n */\nexport const InlineOverflowGlow = styled.div<{\n $position: \"left\" | \"right\";\n $visible: boolean;\n}>`\n position: absolute;\n top: 0;\n bottom: 0;\n ${({ $position }) => ($position === \"left\" ? \"left: 0;\" : \"right: 0;\")}\n width: max(28px, var(--bleed-inline));\n pointer-events: none;\n opacity: ${({ $visible }) => ($visible ? 1 : 0)};\n transition: opacity var(--duration-base) var(--ease-standard);\n background: linear-gradient(\n to ${({ $position }) => ($position === \"left\" ? \"right\" : \"left\")},\n rgba(255, 255, 255, 0.12),\n rgba(255, 255, 255, 0) 100%\n );\n\n @media (prefers-reduced-motion: reduce) {\n transition: none;\n }\n`;\n","const FOCUSABLE =\n 'button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])';\n\n/*\n * A dismiss button removes itself, and with it the keyboard operator's place.\n * Called from its click, before the removal, it moves focus to the next\n * dismiss button in the same rail or list, else the previous one, else the\n * first control in the panel's body, else the body itself. The first two\n * survive the removal, so focus set now stays where it was put.\n */\nexport function focusBesideDismissed(from: HTMLElement): void {\n const scope = from.closest(\"[data-panel-rail-frame], [data-command-list]\");\n if (!scope) return;\n const dismissals = [...scope.querySelectorAll<HTMLElement>(\"[data-dismiss]\")];\n const at = dismissals.indexOf(from);\n const beside = dismissals[at + 1] ?? dismissals[at - 1];\n if (beside && beside !== from) {\n beside.focus();\n return;\n }\n const railFrame = scope.closest(\"[data-panel-rail-frame]\");\n const body = railFrame\n ? railFrame.parentElement?.querySelector<HTMLElement>(\"[data-panel-body]\")\n : scope.closest<HTMLElement>(\"[data-panel-body]\");\n if (!body) return;\n const first = [...body.querySelectorAll<HTMLElement>(FOCUSABLE)].find(\n (control) => control !== from,\n );\n if (first) {\n first.focus();\n return;\n }\n if (!body.hasAttribute(\"tabindex\")) body.setAttribute(\"tabindex\", \"-1\");\n body.focus();\n}\n","/** How long a command that has just left the delay rail is still drawn, fading where it last was. */\nexport const SETTLE_FADE_MS = 700;\n","import type { StreamStatusValue, Tone } from \"@ksp-gonogo/sitrep-sdk\";\n\n/**\n * The tones that take part in a panel's summary: every `Tone` but `neutral`,\n * which carries no state. From best to worst: `go`, `info`, `caution`, `warn`,\n * `nogo`, `offline`. Useful for ranking the states a panel reports so the\n * operator sees the worst. Taken by {@link StatusContribution} and\n * {@link Badge}.\n *\n * @category Panel\n */\nexport type Severity = Exclude<Tone, \"neutral\">;\n\n/**\n * Total order for the max-merge, best to worst.\n *\n * `info` sits above `go`, so an info contributor lights an otherwise quiet\n * panel. `offline` sits at the top: a nogo alarm cannot be trusted once the\n * data feeding it is gone.\n */\nconst RANK: Record<Severity, number> = {\n go: 0,\n info: 1,\n caution: 2,\n warn: 3,\n nogo: 4,\n offline: 5,\n};\n\nexport function severityRank(s: Severity): number {\n return RANK[s];\n}\n\n/**\n * The worst severity among `severities`, in the order `go`, `info`, `caution`,\n * `warn`, `nogo`, `offline` (worst). `go` for an empty list. Useful for\n * choosing the one status a panel shows the operator when several are\n * reported. Used by the panel status store.\n *\n * @category Panel\n */\nexport function worstSeverity(severities: readonly Severity[]): Severity {\n let worst: Severity = \"go\";\n for (const s of severities) {\n if (RANK[s] > RANK[worst]) worst = s;\n }\n return worst;\n}\n\n/**\n * The {@link Severity} a stream status reads as: `live` is `go`, `resyncing`\n * is `caution`, `recorded` is `info` (the reading is exact, for an earlier\n * instant), `held`, `last-before-blackout`, `loading` and `no-game` are `warn`,\n * and `disconnected` and `absent` are `offline`. Useful for colouring a stream\n * status the way the operator reads its severity. Used by\n * {@link StreamStatusBadge} and {@link Panel}.\n *\n * @category Panel\n */\nexport function severityFromStreamStatus(status: StreamStatusValue): Severity {\n switch (status) {\n case \"live\":\n return \"go\";\n case \"resyncing\":\n return \"caution\";\n case \"recorded\":\n return \"info\";\n case \"held\":\n case \"last-before-blackout\":\n case \"loading\":\n case \"no-game\":\n return \"warn\";\n case \"disconnected\":\n case \"absent\":\n return \"offline\";\n }\n}\n","import { createPanelStore } from \"../store/createPanelStore\";\nimport { createStore } from \"../store/createStore\";\nimport { type Severity, severityRank, worstSeverity } from \"./severity\";\n\n/**\n * One statement about a panel's state, as published to its\n * {@link PanelStatusStore}. Useful for letting the operator see the worst state\n * a widget reports in its header. A {@link Badge} with `report`, the panel's\n * stream status and the dashboard's alarms all publish this shape, and the\n * panel summarises them together. Taken by {@link useStatusContribution}.\n *\n * @category Panel\n */\nexport interface StatusContribution {\n /** Stable for the contributor's lifetime; a second contribution with the same id replaces the first. */\n id: string;\n /** How bad the state is. The worst across the panel wins its summary. */\n severity: Severity;\n /** Shown when this contribution wins the summary. */\n label: string;\n}\n\n/**\n * The contribution that wins a panel's summary: the worst severity, and the\n * earliest registered among equals. `id` is the winner's own contribution id,\n * so a caller already drawing that contribution (as a badge pill, say) can\n * skip drawing it twice. Useful for showing the operator one summary badge for\n * the panel. Returned by {@link useStatusSummary}.\n *\n * @category Panel\n */\nexport interface StatusSummary {\n /** The winning contribution's own {@link StatusContribution.id}. */\n id: string;\n /** The worst severity on the panel. */\n severity: Severity;\n /** The winning contribution's label, the words the summary badge shows. */\n label: string;\n}\n\n/**\n * One row of a panel's per-severity breakdown: how many contributions sit at\n * one severity. Two cautions are one `{ severity: \"caution\", count: 2 }` row;\n * severities are never folded into a worse one. Useful for drawing one status\n * dot per severity in a collapsed header. Returned by\n * {@link useStatusBreakdown}.\n *\n * @category Panel\n */\nexport interface StatusBreakdownEntry {\n /** The severity this row counts. */\n severity: Severity;\n /** How many contributions sit at it, never zero: a severity nobody reports has no row. */\n count: number;\n /** The words of the contributions at this severity, in registration order, with the empty ones left out. */\n labels: readonly string[];\n}\n\n/**\n * The store of {@link StatusContribution}s for one dashboard tile, from which\n * the panel draws its summary badge and the collapsed header's status dots.\n * Components publish with {@link useStatusContribution} and read with\n * {@link useStatusSummary} and {@link useStatusBreakdown}; a change re-renders only\n * those subscribers. Useful for telling the operator the state of a widget in\n * its header. Used by {@link Panel}.\n *\n * @category Panel\n */\nexport interface PanelStatusStore {\n /** Adds a contribution. Returns a function that removes it. */\n register(c: StatusContribution): () => void;\n /** Changes a registered contribution's severity and label in place. */\n update(id: string, next: Omit<StatusContribution, \"id\">): void;\n /** Calls `onChange` on any change to the contributions. Returns a function that unsubscribes. */\n subscribe(onChange: () => void): () => void;\n /** The winning contribution (see {@link StatusSummary}), or `null` when there are none. The same object is returned while the result is unchanged. */\n getSummary(): StatusSummary | null;\n /**\n * Per-severity counts, worst first, one row per severity present. The same\n * array is returned while the counts are unchanged.\n */\n getBreakdown(): readonly StatusBreakdownEntry[];\n}\n\n/** The worst contribution's own label, tie-broken by insertion order (the\n * earliest contribution at the worst rank wins, so the winning label cannot\n * flicker between two equal-severity contributors frame to frame). */\nfunction summarise(\n contributions: readonly StatusContribution[],\n): StatusSummary | null {\n if (contributions.length === 0) return null;\n const worst = worstSeverity(contributions.map((c) => c.severity));\n for (const c of contributions) {\n if (c.severity === worst) {\n return { id: c.id, severity: c.severity, label: c.label };\n }\n }\n return null; // unreachable: worst is drawn from the set\n}\n\n// Shared frozen empty so an empty store returns one stable identity (a fresh `[]` per call would loop useSyncExternalStore).\nconst EMPTY_BREAKDOWN: readonly StatusBreakdownEntry[] = Object.freeze([]);\n\n/** Per-severity counts, worst-first. Each distinct severity is its own row with\n * its own count; nothing is folded across tiers. */\nfunction breakdownOf(\n contributions: readonly StatusContribution[],\n): readonly StatusBreakdownEntry[] {\n if (contributions.length === 0) return EMPTY_BREAKDOWN;\n const rows = new Map<Severity, { count: number; labels: string[] }>();\n for (const c of contributions) {\n const row = rows.get(c.severity) ?? { count: 0, labels: [] };\n row.count += 1;\n if (c.label !== \"\") row.labels.push(c.label);\n rows.set(c.severity, row);\n }\n return Array.from(rows, ([severity, row]) => ({ severity, ...row })).sort(\n (a, b) => severityRank(b.severity) - severityRank(a.severity),\n );\n}\n\n/** Structural equality over the worst-first entries (same length, same\n * severity, count and labels at each index), so a change that leaves the\n * breakdown identical preserves the array's identity. */\nfunction breakdownEqual(\n a: readonly StatusBreakdownEntry[],\n b: readonly StatusBreakdownEntry[],\n): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (\n a[i].severity !== b[i].severity ||\n a[i].count !== b[i].count ||\n a[i].labels.length !== b[i].labels.length ||\n a[i].labels.some((label, j) => label !== b[i].labels[j])\n ) {\n return false;\n }\n }\n return true;\n}\n\nexport function createPanelStatusStore(): PanelStatusStore {\n const base = createStore<StatusContribution>();\n\n /*\n * Derived views are cached on the base snapshot's identity, and an equal\n * recomputed result keeps the previous object, so a losing contributor\n * moving never hands useSyncExternalStore a fresh summary.\n */\n let cachedSummary: StatusSummary | null = null;\n let cachedFrom: readonly StatusContribution[] | null = null;\n let cachedBreakdown: readonly StatusBreakdownEntry[] = EMPTY_BREAKDOWN;\n let cachedBreakdownFrom: readonly StatusContribution[] | null = null;\n\n return {\n register: base.register,\n update: base.update,\n subscribe: base.subscribe,\n getSummary() {\n const snapshot = base.getSnapshot();\n if (snapshot === cachedFrom) return cachedSummary;\n const next = summarise(snapshot);\n cachedFrom = snapshot;\n if (\n cachedSummary !== null &&\n next !== null &&\n cachedSummary.id === next.id &&\n cachedSummary.severity === next.severity &&\n cachedSummary.label === next.label\n ) {\n return cachedSummary; // identity preserved: same merged result\n }\n cachedSummary = next;\n return cachedSummary;\n },\n getBreakdown() {\n const snapshot = base.getSnapshot();\n if (snapshot === cachedBreakdownFrom) return cachedBreakdown;\n const next = breakdownOf(snapshot);\n cachedBreakdownFrom = snapshot;\n if (breakdownEqual(cachedBreakdown, next)) return cachedBreakdown;\n cachedBreakdown = next;\n return cachedBreakdown;\n },\n };\n}\n\n/**\n * The empty status breakdown, the same object every time. Useful for telling a\n * panel with nothing to report from one outside a dashboard tile. Used by\n * {@link useStatusBreakdown} when no provider is mounted.\n */\nexport const NO_STATUS_BREAKDOWN = EMPTY_BREAKDOWN;\n\nconst StatusPanelStore = createPanelStore(createPanelStatusStore);\n\n/**\n * Creates one {@link PanelStatusStore} and provides it for as long as it is\n * mounted, so the widget body and the tile's chrome share it. Useful for\n * showing the operator a tile's worst status in its header. The dashboard\n * mounts one per tile, so a widget does not mount this itself; it is for a\n * test or a harness that renders a {@link Panel} outside the dashboard.\n *\n * @category Panel\n */\nexport const PanelStatusStoreProvider = StatusPanelStore.Provider;\n\n/**\n * The nearest {@link PanelStatusStore}, or `null` outside a dashboard tile.\n * Useful for reading the states a tile reports. Used by the panel status hooks.\n * {@link Badge}'s `report` and {@link Panel} read it for you, so a widget\n * rarely calls this directly.\n *\n * @category Panel\n */\nexport const usePanelStatusStore = StatusPanelStore.useStore;\n","import { useEffect } from \"react\";\nimport {\n type StatusContribution,\n usePanelStatusStore,\n} from \"./PanelStatusStore\";\n\n/**\n * Publishes a contribution into the nearest {@link PanelStatusStore} for as\n * long as the calling component is mounted, so it counts toward the panel's\n * summary badge and status dots. Useful for letting a widget report a state to\n * the operator in its header. Used by a widget's essentials and by\n * {@link Badge}.\n *\n * - does nothing when there is no store above (a widget outside the dashboard)\n * - keyed on `c.id`: a changed severity or label updates the contribution in\n * place\n * - `null` contributes nothing, so the contribution can be passed\n * conditionally\n *\n * @example\n * ```tsx\n * function ThermalWatch({ overheating }: { overheating: boolean }) {\n * useStatusContribution(\n * overheating ? { id: \"thermal\", severity: \"warn\", label: \"Overheating\" } : null,\n * );\n * return null;\n * }\n * ```\n *\n * @category Panel\n */\nexport function useStatusContribution(c: StatusContribution | null): void {\n const store = usePanelStatusStore();\n const id = c?.id;\n const severity = c?.severity;\n const label = c?.label;\n\n // Keyed on identity only: the update effect below applies value changes in place.\n // biome-ignore lint/correctness/useExhaustiveDependencies: value changes are applied by the update effect, not by re-registering\n useEffect(() => {\n if (!store || id === undefined || severity === undefined) return;\n const deregister = store.register({ id, severity, label: label ?? \"\" });\n return deregister;\n }, [store, id]);\n\n useEffect(() => {\n if (!store || id === undefined || severity === undefined) return;\n store.update(id, { severity, label: label ?? \"\" });\n }, [store, id, severity, label]);\n}\n","import type { HeldGrade, Reading, Tone } from \"@ksp-gonogo/sitrep-sdk\";\nimport type { HTMLAttributes, ReactNode } from \"react\";\nimport styled, { css } from \"styled-components\";\nimport { fitBox } from \"./fitBox\";\nimport { heldTone } from \"./heldTone\";\nimport { heldGradeOf } from \"./readingCurrency\";\nimport { RECKONING_MARK } from \"./reckoningMarkSpec\";\nimport type { Severity } from \"./status/severity\";\nimport { heldWord } from \"./status/streamStatusWord\";\nimport { useStatusContribution } from \"./status/useStatusContribution\";\nimport { useTooltip } from \"./Tooltip\";\nimport { TONE_MARK, TONE_TEXT } from \"./tone\";\nimport { VisuallyHidden } from \"./VisuallyHidden\";\n\n/**\n * Badge text size: `sm` for dense rows and table cells, `md` (the default)\n * elsewhere. Set with the `size` prop of {@link Badge}.\n * Useful for fitting a badge into a dense table row or a roomier header.\n *\n * @category Badge\n */\nexport type BadgeSize = \"sm\" | \"md\";\n\n/**\n * Props for {@link Badge}: the label, its tone and its size. Any other `span`\n * attribute (`title`, `aria-label`) passes through to the pill.\n * Useful for labelling a state or a count in a tone the operator reads at a\n * glance. Used by {@link Badge}.\n *\n * @category Badge\n */\nexport interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {\n /**\n * The state the badge shows. Sets its colour and, with `report`, where it\n * ranks in the panel's summary. Omit it, or pass `neutral`, for a state with\n * no good or bad side (such as \"1 of 2 crew\"), which renders a grey chip and\n * never moves a panel summary.\n */\n tone?: Tone;\n /** Text size, `sm` or `md`. Absent, `md`. */\n size?: BadgeSize;\n /**\n * Announce this badge as a screen-reader live region (`role=\"status\"`). Use\n * for state that changes and the operator benefits from being told (a stream\n * going held, an alarm firing). Decorative badges leave it off so they do not\n * flood the accessibility tree.\n */\n live?: boolean;\n /**\n * When set, this badge registers itself into the nearest\n * {@link PanelStatusStore} as a contribution `{ id, severity, label }`, so the panel\n * can summarise it. `id` must be stable for the badge's lifetime. `label`\n * defaults to the badge's text content when `children` is a plain string; pass\n * it explicitly otherwise. A `go` badge with `report` still registers, but\n * any worse state in the panel wins the summary over it. Outside a panel\n * there is no store to register into, so `report` does nothing and the badge\n * draws as usual.\n */\n report?: { id: string; label?: string };\n /**\n * The reading the badge's state comes from, or that reading's held grade.\n * While it is held the badge keeps its words, takes its held tone (`go` and\n * `info` read `caution`, every other tone is kept) and carries the held\n * square on its top right corner; its panel summary takes the same tone. The\n * grade's word is spoken after the badge's words and shown on hover; a\n * caller that wraps a held badge in its own {@link Tooltip} names the grade\n * in that tooltip's text. A current reading, or none, changes nothing.\n */\n held?: HeldGrade | Reading<unknown>;\n /** The badge's words, drawn uppercase. */\n children: ReactNode;\n}\n\n/**\n * A compact uppercase pill that shows a state in one `Tone`: something that can\n * change while the operator watches, such as a connection, an alarm or \"1 of 2\n * crew\". Useful for telling the operator the state of a part, vessel or\n * connection at a glance. Used by the panel's summary badge and\n * {@link StreamStatusBadge}. A fixed property of the thing it labels, such as a\n * widget's kind or owner, is a {@link Tag} instead.\n *\n * A stateful tone (`info`, `go`, `caution`, `warn`, `nogo` or `offline`; `Tone`\n * has the full set and `Button` takes a narrower one) draws an outlined pill in\n * that tone's colour, with a glow that grows with severity. No tone, or\n * `neutral`, draws a grey chip, rounded like the rest, for a state with no good\n * or bad side.\n *\n * @example\n * ```tsx\n * <Badge tone=\"warn\" live report={{ id: \"fuel-low\" }}>\n * Fuel low\n * </Badge>\n * ```\n *\n * @category Badge\n * @categoryDescription Badge\n * Small marks that name a state: a badge in a tone, a status dot, and the\n * stream's connection status in words.\n */\nexport function Badge({\n tone: ownTone,\n size = \"md\",\n live = false,\n report,\n held,\n children,\n ...rest\n}: BadgeProps) {\n const grade = heldGradeOf(held);\n const tone = grade === undefined ? ownTone : heldTone(ownTone);\n const severity: Severity | undefined =\n tone === undefined || tone === \"neutral\" ? undefined : tone;\n const reportLabel =\n report?.label ?? (typeof children === \"string\" ? children : \"\");\n useStatusContribution(\n report\n ? {\n id: report.id,\n // A reporting badge with no state sits at the floor.\n severity: severity ?? \"go\",\n label: reportLabel,\n }\n : null,\n );\n\n const liveAttrs = live\n ? ({ role: \"status\", \"aria-live\": \"polite\" } as const)\n : {};\n const heldCaption = grade === undefined ? null : heldWord(grade);\n // A caller's Tooltip around the badge owns the hover, and must name the grade itself.\n const wrapped = Reflect.get(rest, \"data-tooltip\") !== undefined;\n const { anchor, tip } = useTooltip(wrapped ? null : heldCaption);\n\n return (\n <>\n <Badge__Body\n $severity={severity}\n $size={size}\n {...liveAttrs}\n {...anchor}\n {...rest}\n >\n {children}\n {heldCaption !== null && (\n <>\n <Badge__HeldMark aria-hidden=\"true\" data-held-mark=\"\" />\n <VisuallyHidden data-unit-currency=\"\">\n , {heldCaption}\n </VisuallyHidden>\n </>\n )}\n </Badge__Body>\n {tip}\n </>\n );\n}\n\n/** Solid grey for a state with no good or bad side. Distinct from `offline`, which is a real \"data absent\" reading. */\nconst DECORATIVE_STYLE = css`\n background: var(--color-surface-raised);\n border-color: var(--color-border-subtle);\n color: var(--color-text-muted);\n`;\n\n/**\n * A transparent pill with the tone's mark as its outline and its text as the\n * label, so a `go` badge reads as status rather than as a solid \"go\" button.\n * The glow scales with severity: none for `go` and `offline`, growing from\n * `info` to `nogo`.\n */\nconst SEVERITY_STYLES: Record<Severity, ReturnType<typeof css>> = {\n go: css`\n background: transparent;\n border-color: ${TONE_MARK.go};\n color: ${TONE_TEXT.go};\n `,\n info: css`\n background: transparent;\n border-color: ${TONE_MARK.info};\n color: ${TONE_TEXT.info};\n box-shadow: 0 0 4px 0 color-mix(in srgb, ${TONE_MARK.info} 40%, transparent);\n `,\n caution: css`\n background: transparent;\n border-color: ${TONE_MARK.caution};\n color: ${TONE_TEXT.caution};\n box-shadow: 0 0 5px 0 color-mix(in srgb, ${TONE_MARK.caution} 45%, transparent);\n `,\n warn: css`\n background: transparent;\n border-color: ${TONE_MARK.warn};\n color: ${TONE_TEXT.warn};\n box-shadow: 0 0 6px 1px color-mix(in srgb, ${TONE_MARK.warn} 55%, transparent);\n `,\n nogo: css`\n background: transparent;\n border-color: ${TONE_MARK.nogo};\n color: ${TONE_TEXT.nogo};\n box-shadow: 0 0 8px 2px color-mix(in srgb, ${TONE_MARK.nogo} 65%, transparent);\n `,\n // Data gone reads as faded, dimmer than a decorative chip, rather than alarming.\n offline: css`\n background: transparent;\n border-color: ${TONE_MARK.offline};\n color: ${TONE_TEXT.offline};\n `,\n};\n\nconst SIZE_STYLES = {\n sm: css`\n font-size: var(--font-size-caption);\n padding: var(--inset-chip);\n `,\n md: css`\n font-size: var(--font-size-compact);\n padding: var(--inset-chip-roomy);\n `,\n} as const;\n\nconst Badge__Body = styled.span<{\n $severity: Severity | undefined;\n $size: BadgeSize;\n}>`\n display: inline-block;\n position: relative;\n /* Sized by its own text, never stretched to a taller flex sibling. */\n align-self: center;\n ${fitBox(\"badge\")}\n border: 1px solid;\n font-weight: 600;\n letter-spacing: 0.08em;\n text-transform: uppercase;\n white-space: nowrap;\n\n border-radius: var(--radius-pill);\n\n ${({ $size }) => SIZE_STYLES[$size]}\n ${({ $severity }) =>\n $severity === undefined ? DECORATIVE_STYLE : SEVERITY_STYLES[$severity]}\n`;\n\n/** The held square, centred on the badge's top right corner so it sits on the border rather than among the words. */\nconst Badge__HeldMark = styled.span`\n position: absolute;\n top: 0;\n right: 0;\n width: ${RECKONING_MARK.held.domSize};\n height: ${RECKONING_MARK.held.domSize};\n transform: translate(45%, -45%);\n background: ${RECKONING_MARK.held.color};\n box-shadow: 0 0 0 1px var(--color-surface-panel);\n pointer-events: none;\n`;\n","import { css } from \"styled-components\";\n\n/**\n * Marks a box whose own edges are content, not decoration. Useful for having the\n * minimum-size audit report when a tile clips or pushes out a box the operator\n * needs to see whole. Used by {@link Badge}.\n *\n * The min-fit audit (`auditMinFit` in `@ksp-gonogo/uplink-tools`) reports text a\n * tile cuts off but not boxes, since many are drawn oversized on purpose. A box\n * carrying this is one whose shape is the affordance, so a clipped edge is\n * reported under `box-clipped` / `box-escapes-tile`.\n *\n * `name` is what a finding calls the box, so pick the primitive's own name. A\n * custom property rather than an attribute, so DOM snapshots are unaffected.\n */\nexport const fitBox = (name: string) => css`\n --fit-box: ${name};\n`;\n\n/**\n * Marks a box that paints over the scrolling content behind it. Useful for having\n * the minimum-size audit report a mask that hides more of a short body than the\n * operator can afford to lose. Used by the panel's scroll glow.\n *\n * A scroll glow is drawn at a fixed height, so on a short body it can mask more\n * than the overflow it advertises. `auditMinFit` reports that under\n * `masked-by-glow`, reading the depth from the element's computed gradient.\n *\n * `name` is what a finding calls the mask.\n */\nexport const fitMask = (name: string) => css`\n --fit-mask: ${name};\n`;\n","import type { Tone } from \"@ksp-gonogo/sitrep-sdk\";\n\n/**\n * The tone a badge takes while the reading behind it is held, from the tone it\n * has while live. A good state (`go`, `info`) reads `caution`, since a held\n * reading can no longer vouch for it. `caution`, `warn`, `nogo` and `offline`\n * keep their own tone, as a held bad state is no better for being held. A\n * neutral badge, or one with no tone, stays neutral.\n */\nexport function heldTone(tone: Tone | undefined): Tone | undefined {\n return tone === \"go\" || tone === \"info\" ? \"caution\" : tone;\n}\n","/**\n * The magnitude unwrap, re-exported from `@ksp-gonogo/sitrep-sdk`, where it\n * lives beside `Value` because ui-kit depends on the sdk and not the reverse.\n */\nexport {\n asQuantityish,\n magnitudeOf,\n magnitudeOr,\n type Quantityish,\n} from \"@ksp-gonogo/sitrep-sdk\";\n","import type { Value } from \"@ksp-gonogo/sitrep-sdk\";\nimport {\n createContext,\n type ReactElement,\n type ReactNode,\n useContext,\n useId,\n useLayoutEffect,\n useState,\n useSyncExternalStore,\n} from \"react\";\nimport { magnitudeOf } from \"./magnitude\";\nimport {\n type FormatQuantityOptions,\n type FormatsFor,\n type FormatsForKind,\n formatGroupKey,\n type KindOfGroup,\n type LadderPosition,\n ladderPosition,\n type PresentableAs,\n type PresentableAsKind,\n pinGroupKey,\n readsAsOneFigure,\n separatingDecimals,\n type UnitGroupKey,\n unitScaleKey,\n} from \"./units\";\n\n/**\n * What a group settles, and what every member inside it is written at. The fields are the formatter's own, so applying one is a spread.\n * Read from the enclosing {@link UnitSharedFormat} group by each {@link Unit} inside it, and applied by that Unit.\n *\n * An absent field is a group with no opinion: the member's own props fill it.\n *\n * @category Unit\n */\nexport interface SharedFormat {\n /** The rung every member is written at. */\n readonly format?: string;\n /** The unit every member is converted to, when the scope asked for one. */\n readonly as?: string;\n /** The digit count every member is written at. */\n readonly decimals?: number;\n}\n\n/** What one member hands over, and the whole of it. */\ninterface Report {\n /** Its reading, in the unit it arrived in. */\n readonly reading: number;\n readonly unit: string;\n /** Where it sits on the shared ladder, or undefined when its unit climbs nothing; such a member still reports for the digit count. */\n readonly position?: LadderPosition;\n}\n\n/**\n * What a scope pins for one group, typed by the unit it is addressed to: `of=\"m\" as=\"kg\"` is a compile error.\n * Useful for fixing the unit and digit count of a group of figures the operator\n * compares. Taken by the `format`, `as` and `decimals` props of\n * {@link UnitSharedFormat}.\n *\n * @category Unit\n */\nexport interface UnitPins<Unit extends string = string> {\n /** The rung every member of the group is written at. */\n format?: FormatsFor<Unit>;\n /** The unit every member of the group is shown in. */\n as?: PresentableAs<Unit>;\n /** The digit count every member of the group is written at. */\n decimals?: number;\n}\n\n/**\n * {@link UnitPins} addressed to a whole group, checked against what that group measures.\n * Useful for fixing the unit and digit count of one group inside a scope that\n * holds several. Held by each entry of {@link UnitPinsByGroup}.\n *\n * @category Unit\n */\nexport interface UnitGroupPins<Group extends UnitGroupKey> {\n /** The rung every member of the group is written at. */\n format?: FormatsForKind<KindOfGroup<Group>>;\n /** The unit every member of the group is shown in. */\n as?: PresentableAsKind<KindOfGroup<Group>>;\n /** The digit count every member of the group is written at. */\n decimals?: number;\n}\n\n/**\n * What each named group of a mixed scope is pinned to. Every entry is optional and a key that is not a group is a compile error. An Uplink's units reach this type by merging into `UnitDeclarations`.\n * Useful for fixing the unit of several kinds of figure at once. Taken by the\n * `pins` prop of {@link UnitSharedFormat}.\n *\n * @category Unit\n */\nexport type UnitPinsByGroup = {\n [Group in UnitGroupKey]?: UnitGroupPins<Group>;\n};\n\nconst NO_PINS: UnitPins = {};\n\n/** What a scope was asked for, as against what it settles. */\ninterface Policy {\n /** What each named group was pinned to, by its {@link formatGroupKey}. A missing key settles for itself. */\n readonly byKey: ReadonlyMap<string, UnitPins>;\n /** A pin that named no unit, which reaches every group in the scope. */\n readonly unaddressed: UnitPins | undefined;\n /** Widen digits until the members read apart. A property of the whole scope. */\n readonly separate: boolean;\n}\n\nconst NO_POLICY: Policy = {\n byKey: new Map(),\n unaddressed: undefined,\n separate: false,\n};\n\n/** Where every scope of one tree keeps what the whole tree shares. */\ninterface Root {\n /** Every scope of this tree, so a report in one can re-settle the others, sibling subtrees included. */\n readonly family: Set<Scope>;\n /** Subscribe to every settle in the tree. A bound function, never a method. */\n readonly subscribe: (listener: () => void) => () => void;\n /** Re-settle every scope for `key`, and notify once if anything moved. */\n readonly sweep: (key: string) => void;\n}\n\ninterface Scope {\n readonly root: Root;\n /** How far inside the tree this scope is: parents settle before children. */\n readonly depth: number;\n /** Put or drop one member's report under `key`. `undefined` drops it. */\n hold(key: string, id: string, report: Report | undefined): void;\n /** What `key` settled on, or undefined while the group has no opinion. */\n settled(key: string): SharedFormat | undefined;\n /** Whether `key`'s members all print as the same text at what it settled on. Kept apart from the format so the formatter is never handed a non-format field. */\n readsAsOneFigure(key: string): boolean;\n /** State what this scope was asked for. Its own props, never an answer. */\n setPolicy(next: Policy): void;\n /** Recompute this scope's answer for `key`. True when it moved. */\n resettle(key: string): boolean;\n /** Join the tree, or leave it once unmounted. Both halves, because strict mode runs a layout effect's cleanup and then its body again on one mount. */\n attach(): void;\n detach(): void;\n}\n\nfunction samePins(a: UnitPins | undefined, b: UnitPins | undefined): boolean {\n if (a === undefined || b === undefined) return a === b;\n return a.format === b.format && a.as === b.as && a.decimals === b.decimals;\n}\n\nfunction samePolicy(a: Policy, b: Policy): boolean {\n if (a.separate !== b.separate) return false;\n if (!samePins(a.unaddressed, b.unaddressed)) return false;\n if (a.byKey.size !== b.byKey.size) return false;\n for (const [key, pins] of a.byKey) {\n if (!samePins(pins, b.byKey.get(key))) return false;\n }\n return true;\n}\n\n/** The policy a scope's props amount to. {@link samePolicy} compares by field, so a fresh literal every render settles nothing extra. */\nfunction policyOf(\n of: string | undefined,\n pins: UnitPinsByToken | undefined,\n own: UnitPins,\n separate: boolean,\n): Policy {\n const byKey = new Map<string, UnitPins>();\n if (of !== undefined) byKey.set(formatGroupKey(of), own);\n for (const [token, pin] of Object.entries(pins ?? {})) {\n if (pin !== undefined) byKey.set(pinGroupKey(token), pin);\n }\n return {\n byKey,\n unaddressed: of === undefined && pins === undefined ? own : undefined,\n separate,\n };\n}\n\nfunction sameFormat(\n a: SharedFormat | undefined,\n b: SharedFormat | undefined,\n): boolean {\n if (a === undefined || b === undefined) return a === b;\n return a.format === b.format && a.as === b.as && a.decimals === b.decimals;\n}\n\nfunction sameReport(a: Report | undefined, b: Report): boolean {\n return (\n a !== undefined &&\n a.reading === b.reading &&\n a.unit === b.unit &&\n a.position?.base === b.position?.base &&\n a.position?.rung === b.position?.rung\n );\n}\n\nfunction createRoot(): Root {\n const family = new Set<Scope>();\n const listeners = new Set<() => void>();\n return {\n family,\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n sweep(key) {\n // Outermost first: a child's answer is built on its parent's.\n const ordered = [...family].sort((a, b) => a.depth - b.depth);\n let moved = false;\n for (const member of ordered) {\n if (member.resettle(key)) moved = true;\n }\n if (!moved) return;\n for (const listener of listeners) listener();\n },\n };\n}\n\nfunction createScope(parent: Scope | undefined): Scope {\n const held = new Map<string, Map<string, Report>>();\n const settled = new Map<string, SharedFormat>();\n const oneFigure = new Set<string>();\n const root = parent?.root ?? createRoot();\n let policy = NO_POLICY;\n\n /** The rung of the largest member, the one the group is a group about. */\n const ownRung = (members: Iterable<Report>): string | undefined => {\n let winner: LadderPosition | undefined;\n for (const member of members) {\n const position = member.position;\n if (position === undefined) continue;\n if (winner === undefined || position.base > winner.base)\n winner = position;\n }\n return winner?.rung;\n };\n\n const scope: Scope = {\n root,\n depth: parent === undefined ? 0 : parent.depth + 1,\n\n hold(key, id, report) {\n const forKey = held.get(key);\n if (report === undefined) {\n if (forKey !== undefined) {\n forKey.delete(id);\n if (forKey.size === 0) held.delete(key);\n }\n } else {\n if (sameReport(forKey?.get(id), report)) return;\n if (forKey === undefined) held.set(key, new Map([[id, report]]));\n else forKey.set(id, report);\n }\n // Up first, so the outermost scope holds every reading in the tree; only it sweeps, once, for the whole family.\n if (parent === undefined) root.sweep(key);\n else parent.hold(key, id, report);\n },\n\n settled: (key) => settled.get(key),\n\n readsAsOneFigure: (key) => oneFigure.has(key),\n\n setPolicy(next) {\n if (samePolicy(policy, next)) return;\n policy = next;\n // Every key, not only pinned ones: `separate` is scope-wide, and a pin moving off a key lets that key settle for itself again.\n for (const key of held.keys()) root.sweep(key);\n },\n\n resettle(key) {\n const members = [...(held.get(key)?.values() ?? [])];\n const inherited = parent?.settled(key);\n // An unaddressed pin applies only where no group was named.\n const pins = policy.byKey.get(key) ?? policy.unaddressed ?? NO_PINS;\n const format = pins.format ?? inherited?.format ?? ownRung(members);\n const as = pins.as ?? inherited?.as;\n const decimals =\n pins.decimals ??\n (policy.separate\n ? separatingDecimals(members, { format, as })\n : inherited?.decimals);\n const next =\n format === undefined && as === undefined && decimals === undefined\n ? undefined\n : {\n ...(format !== undefined && { format }),\n ...(as !== undefined && { as }),\n ...(decimals !== undefined && { decimals }),\n };\n // Asked after the ladder, about the figures that will actually be drawn, and only by a scope asked to `separate`.\n const oneFigureNow =\n policy.separate && readsAsOneFigure(members, { format, as, decimals });\n const oneFigureMoved = oneFigureNow !== oneFigure.has(key);\n if (oneFigureNow) oneFigure.add(key);\n else oneFigure.delete(key);\n if (sameFormat(settled.get(key), next)) return oneFigureMoved;\n if (next === undefined) settled.delete(key);\n else settled.set(key, next);\n return true;\n },\n\n attach() {\n root.family.add(scope);\n // Reports that arrived while detached, as strict mode's re-run of the children's effects does ahead of this one, settled nothing.\n for (const key of held.keys()) root.sweep(key);\n },\n\n detach() {\n root.family.delete(scope);\n },\n };\n\n root.family.add(scope);\n return scope;\n}\n\n/** The inert default: a `<Unit>` with no scope above it reports into this and hears nothing back. */\nconst NO_SCOPE: Scope = {\n root: { family: new Set(), subscribe: () => () => {}, sweep: () => {} },\n depth: 0,\n hold: () => {},\n settled: () => undefined,\n readsAsOneFigure: () => false,\n setPolicy: () => {},\n resettle: () => false,\n attach: () => {},\n detach: () => {},\n};\n\n// The scope's identity never changes, and answers reach members through `useSyncExternalStore`, so a settle never re-runs a member's report effect.\nconst ScopeContext = createContext<Scope>(NO_SCOPE);\n\n/**\n * Whether there is a real {@link UnitSharedFormat} above this point. Used by\n * {@link Unit}.\n *\n * Membership cannot be read off the shared-format hook: a group over a unit with no ladder (`rpm`) legitimately settles an empty format.\n */\nexport function useInSharedFormat(): boolean {\n return useContext(ScopeContext) !== NO_SCOPE;\n}\n\n/** What every spelling of the props below shares. */\ninterface UnitSharedFormatBaseProps {\n /** The tree whose figures share the format. */\n children?: ReactNode;\n /**\n * Widen the digit count until the members stop printing the same figure as each other. What an interval wants (6 700 km and 6 710 km both print `6.7 Mm` otherwise) and a column does not. Applies to the whole scope.\n */\n separate?: boolean;\n}\n\n/**\n * A scope that pins one kind. `of` names the unit the pins are addressed to and\n * types them: `of=\"m\"` makes `as` a length and `format` a rung on the length\n * ladder, and `of={v.unit}` needs no annotation. Useful for keeping the figures\n * the operator compares at one precision.\n *\n * Without `of` the pins are unaddressed: they reach every group and nothing checks them.\n * Taken by {@link UnitSharedFormat}.\n *\n * @category Unit\n */\nexport interface UnitSharedFormatProps<Unit extends string = string>\n extends UnitSharedFormatBaseProps,\n UnitPins<Unit> {\n /** The unit the pins below are addressed to. */\n of?: Unit;\n}\n\n/**\n * A scope that pins several groups, each keyed by name, so a group is pinned at\n * most once and one that needs nothing is simply absent: `pins={{ length: { as:\n * \"km\" }, mass: { as: \"t\" } }}`. Useful for keeping several groups of figures\n * the operator compares at one precision each.\n *\n * Each value is typed by its own key, so `{ length: { as: \"kg\" } }` is a compile error at that entry. A laddered kind is keyed by its kind; a unit that climbs nothing keys itself, so `s` and `min` stay separate groups. See {@link UnitGroupKey}. Taken by {@link UnitSharedFormat}.\n *\n * @category Unit\n */\nexport interface UnitSharedFormatMixedProps extends UnitSharedFormatBaseProps {\n /** What each named group is pinned to, checked against what it measures. */\n pins: UnitPinsByGroup;\n}\n\n/** The pin map with its keys erased, as the runtime reads it. */\ntype UnitPinsByToken = Readonly<Record<string, UnitPins | undefined>>;\n\n/** Both spellings at once, as the component body actually reads them. */\ninterface UnitSharedFormatAnyProps extends UnitSharedFormatBaseProps, UnitPins {\n of?: string;\n pins?: UnitPinsByToken;\n}\n\n/**\n * A group of quantities that settles one format per kind, so the whole group\n * reads as one instrument. Useful for letting the operator compare figures at\n * a glance, such as `999 m` beside `1000 m`. Used by a rotor tachometer widget.\n * It renders nothing of its own, so it can wrap a row, a cell, a table or a\n * widget body.\n *\n * Every `<Unit>` inside reports its value and is given back the settled format; outside a scope each value formats itself. The caller names no unit or digit count.\n *\n * - The unit is the one the largest member would choose (its {@link Rung}), since a group reads at the size of the thing it describes: `999 m` beside `1000 m` reads `1.0 km`, and a group that must tell its members apart says `separate`\n * - Grouping is per kind (per ladder family, else per unit), so metres settle with metres and kilograms with kilograms in one scope\n * - `format`, `as` and `decimals` pin what a group would otherwise settle. `of` addresses them to one group (`of=\"m\" as=\"km\"`), `pins` to several (`pins={{ length: { as: \"km\" }, mass: { as: \"t\" } }}`), and a pin that names no unit reaches every group unchecked\n * - Nested scopes compose: the unit comes from the outermost, the digit count from the nearest scope that asked for one. Two scopes side by side are two groups\n *\n * The settled format is applied before the first paint, so a reader never sees the members drawn apart.\n *\n * @example\n * ```tsx\n * import { Unit, UnitSharedFormat } from \"@ksp-gonogo/ui-kit\";\n *\n * // The names currentRpm, rpmLimit, low, high and rows stand for your own values and nodes.\n * // Current over limit, one rung, symbol drawn once: \"1234/2000 rpm\".\n * <UnitSharedFormat>\n * <Unit value={currentRpm} decimals={0} hideUnitInGroup />\n * /\n * <Unit value={rpmLimit} decimals={0} />\n * </UnitSharedFormat>\n *\n * // An interval whose ends must read apart.\n * <UnitSharedFormat separate>\n * <Unit value={low} /> to <Unit value={high} />\n * </UnitSharedFormat>\n *\n * // Every length in a table shown in km.\n * <UnitSharedFormat of=\"m\" as=\"km\">\n * {rows}\n * </UnitSharedFormat>\n * ```\n *\n * @category Unit\n */\nexport function UnitSharedFormat<Unit extends string = string>(\n props: UnitSharedFormatProps<Unit> | UnitSharedFormatMixedProps,\n): ReactElement;\nexport function UnitSharedFormat({\n children,\n of,\n pins,\n format,\n as,\n decimals,\n separate = false,\n}: UnitSharedFormatAnyProps): ReactElement {\n const enclosing = useContext(ScopeContext);\n // The inert default is not a parent: its root never sweeps.\n const [scope] = useState(() =>\n createScope(enclosing === NO_SCOPE ? undefined : enclosing),\n );\n useLayoutEffect(() => {\n scope.attach();\n return () => scope.detach();\n }, [scope]);\n // After the members' own effects, which React runs child-first, so the reports are in before the policy that reads them.\n useLayoutEffect(() => {\n scope.setPolicy(policyOf(of, pins, { format, as, decimals }, separate));\n }, [scope, of, pins, format, as, decimals, separate]);\n return (\n <ScopeContext.Provider value={scope}>{children}</ScopeContext.Provider>\n );\n}\n\n/**\n * Reports a quantity to the enclosing {@link UnitSharedFormat} and returns the\n * format its group settled on, or `undefined` when there is none. Useful for\n * writing a figure at the same format as the {@link Unit}s beside it. Used by\n * {@link Unit} and {@link Meter}.\n *\n * `<Unit>` calls this itself, and so do the kit's own readouts that cannot draw a `<Unit>` (SVG axis text, an `aria-valuetext`) but must be written at the same format as the `<Unit>`s beside them. It is internal to the kit and not exported from the package. A quantity whose caller already decided its presentation (`format`, `as`, a non-auto `scale`) neither reports nor hears back.\n */\nexport function useSharedFormat<Unit extends string = string>(\n value: Value<Unit> | null | undefined,\n opts: FormatQuantityOptions = {},\n): SharedFormat | undefined {\n const scope = useContext(ScopeContext);\n const id = useId();\n const reading = magnitudeOf(value);\n const unit: string | undefined = value?.unit;\n const decided =\n opts.format !== undefined ||\n opts.as !== undefined ||\n (opts.scale !== undefined && opts.scale !== \"auto\");\n const key = decided || reading === null ? undefined : formatGroupKey(unit);\n // Two numbers rather than the value, so the effect depends on the reading and not on an object that is fresh every render.\n const position =\n key === undefined ||\n reading === null ||\n unit === undefined ||\n unitScaleKey(unit) === undefined\n ? undefined\n : ladderPosition(reading, unit);\n const base = position?.base;\n const rung = position?.rung;\n\n useLayoutEffect(() => {\n if (key === undefined || reading === null || unit === undefined) return;\n scope.hold(key, id, {\n reading,\n unit,\n ...(base !== undefined &&\n rung !== undefined && { position: { base, rung } }),\n });\n return () => scope.hold(key, id, undefined);\n // The format this hook returns is deliberately absent from these deps: a report that depended on the answer would loop.\n }, [scope, id, key, reading, unit, base, rung]);\n\n return useSyncExternalStore(\n scope.root.subscribe,\n () => (key === undefined ? undefined : scope.settled(key)),\n () => undefined,\n );\n}\n\n/**\n * Whether the group this value belongs to reads as one figure at the format it\n * settled on. Only a scope asked to `separate` answers true. Useful for\n * deciding whether members of a group may be drawn apart. Used by {@link Band}.\n *\n * Read-only, unlike the shared-format hook: a caller that decides what to draw from this must keep reporting as before, or membership becomes a function of the verdict.\n */\nexport function useReadsAsOneFigure<Unit extends string = string>(\n value: Value<Unit> | null | undefined,\n opts: FormatQuantityOptions = {},\n): boolean {\n const scope = useContext(ScopeContext);\n const decided =\n opts.format !== undefined ||\n opts.as !== undefined ||\n (opts.scale !== undefined && opts.scale !== \"auto\");\n const key =\n decided ||\n magnitudeOf(value) === null ||\n value === null ||\n value === undefined\n ? undefined\n : formatGroupKey(value.unit);\n return useSyncExternalStore(\n scope.root.subscribe,\n () => (key === undefined ? false : scope.readsAsOneFigure(key)),\n () => false,\n );\n}\n","import {\n type BandKind,\n bandIn,\n type Reading,\n type UncertaintyBand,\n type Value,\n} from \"@ksp-gonogo/sitrep-sdk\";\nimport type { ReactNode } from \"react\";\nimport styled, { css } from \"styled-components\";\nimport { ReckoningMark, reservesMark } from \"./HeldMark\";\nimport { MicroscopeIcon, StarIcon } from \"./Icons\";\nimport type { ReckoningMarking } from \"./readingCurrency\";\nimport {\n figureAttributes,\n resolveCurrency,\n type UnitValue,\n} from \"./readingCurrency\";\nimport type { MarkKind } from \"./reckoningMarkSpec\";\nimport { standsApart, writtenAs } from \"./standsApart\";\nimport { Tooltip, useTooltip } from \"./Tooltip\";\nimport { useInSharedFormat, useSharedFormat } from \"./UnitSharedFormat\";\nimport {\n ATTACHED_SYMBOLS,\n displaySymbol,\n type FormatQuantityOptions,\n type FormatsFor,\n formatQuantity,\n kindOfUnit,\n type PresentableAs,\n readsAsOneFigure,\n speakQuantity,\n splitCurrencyCompound,\n wordForSymbol,\n} from \"./units\";\nimport { VisuallyHidden } from \"./VisuallyHidden\";\n\nconst ATTACHED = ATTACHED_SYMBOLS;\n\n/** Kinds shown as a glyph rather than text, keyed on the displayed symbol. Funds keeps its `f`, the game's own convention. */\nconst ICON_BY_SYMBOL = {\n sci: MicroscopeIcon,\n rep: StarIcon,\n} as const;\n\nconst Unit__Span = styled.span<{ $attached: boolean; $icon: boolean }>`\n /* Relative to the parent's font size with a floor; attached symbols keep full size, and icons take 0.9em so a thin stroke stays legible. */\n font-size: ${({ $attached, $icon }) =>\n $attached ? \"1em\" : $icon ? \"0.9em\" : \"max(0.72em, 10px)\"};\n /* No margin: the number-unit gap is a thin space character in the markup, so it survives copying. */\n /* \"m/s\" and \"kg/m³\" must never wrap mid-symbol. */\n white-space: nowrap;\n /* A unit must survive an uppercasing parent: m and M are metre and mega. */\n text-transform: none;\n /* A glyph centres on the digits beside it rather than sitting on their baseline; the offset is in em so it holds at every size. */\n ${({ $icon }) =>\n $icon\n ? \"display: inline-flex; align-items: center; vertical-align: -0.12em;\"\n : \"\"}\n`;\n\n// A held figure is relatively positioned and reserves the mark's room at its end, so the mark sits inside the box that a clipping edge cuts and a line never lands the mark alone.\nconst Unit__Quantity = styled.span<{\n $mark: MarkKind | null;\n $elsewhere?: boolean;\n}>`\n white-space: nowrap;\n ${({ $mark, $elsewhere }) =>\n $mark !== null\n ? css`\n position: relative;\n ${reservesMark($mark, $elsewhere)}\n `\n : \"\"}\n`;\n\n// Dimmer than the value but never smaller: a qualifier must recede without becoming unreadable.\nconst Unit__Interval = styled.span`\n color: var(--color-text-muted);\n white-space: nowrap;\n`;\n\n// The spoken staleness caption, excluded from selection so copying a readout does not pick it up.\nconst Unit__Currency = styled(VisuallyHidden)`\n user-select: none;\n`;\n\n// The spoken unit word, excluded from selection so copying \"12.4 km\" does not also yield \"kilometres\".\nconst Unit__Word = styled(VisuallyHidden)`\n user-select: none;\n`;\n\nexport type { UnitValue } from \"./readingCurrency\";\n\n/** U+2009 thin space. SI puts a space between a number and its unit. */\nconst THIN_SPACE = \"\\u2009\";\n\n/**\n * The model's interval, written against the figure on screen at the value's own rung, so it never prints as `1 km ± 25 m`.\n *\n * `±` is used only where the two half-widths agree to the precision shown and the band's value is the figure being drawn, since `±` reads as an offset from the number beside it. Otherwise the range form prints the model's own two ends.\n */\nfunction toInterval<UnitSymbol extends string>(\n shown: Value<UnitSymbol>,\n band: UncertaintyBand<UnitSymbol> | undefined,\n opts: FormatQuantityOptions,\n rung: string,\n): Interval | null {\n if (band === undefined) return null;\n const write = <OtherUnit extends string>(\n quantity: Value<OtherUnit>,\n ): string =>\n formatQuantity(quantity.magnitude, quantity.unit, {\n ...opts,\n format: rung,\n }).value;\n const width = (from: Value<UnitSymbol>, to: Value<UnitSymbol>): string =>\n write(to.minus(from));\n // Ends that print as the same text draw as one approximate figure, by the same test `<Band>` uses; an interval that stands nowhere apart from the figure on screen adds nothing.\n const oneFigure = readsAsOneFigure([band.lo, band.hi], {\n ...opts,\n format: rung,\n });\n if (!standsApart(shown, [band.lo, band.hi], writtenAs(write))) return null;\n const below = width(band.lo, band.value);\n const above = width(band.value, band.hi);\n // Half-widths that both write as zero, from ends that straddle a rounding boundary, claim nothing to read.\n const writesZero = (text: string): boolean =>\n /^[-+\\u2212]?[0.,\\s]*$/.test(text);\n if (!oneFigure && writesZero(below) && writesZero(above)) return null;\n const anchored = write(band.value) === write(shown);\n // The spoken ends carry the unit's word; the written ends carry no symbol because one `<UnitSymbol>` follows the pair.\n const spoken = { ...opts, format: rung };\n return {\n oneFigure,\n plusMinus: !oneFigure && anchored && below === above ? above : null,\n lo: write(band.lo),\n hi: write(band.hi),\n loSaid: speakQuantity(band.lo, spoken),\n hiSaid: speakQuantity(band.hi, spoken),\n kind: band.kind,\n };\n}\n\n/** The interval as it is written and as it is qualified. See {@link toInterval}. */\ninterface Interval {\n /** Whether both ends print as the same text, so only `lo` is drawn. */\n oneFigure: boolean;\n /** The half-width, where the short form is honest, and null where it is not. */\n plusMinus: string | null;\n /** The low end for the eye: no symbol, since the pair shares one. */\n lo: string;\n hi: string;\n /** The low end for the ear, with the unit's word rather than its symbol. */\n loSaid: string;\n hiSaid: string;\n kind: BandKind;\n}\n\n/** The hover text: the staleness sentence, the band's claim (plain containment, as a meter's is), or both. */\nfunction hover(\n caption: string | null,\n interval: Interval | null,\n): string | null {\n const said =\n interval === null\n ? null\n : `with bands at ${interval.loSaid} and ${interval.hiSaid}`;\n if (caption === null) return said;\n return said === null ? caption : `${caption}, ${said}`;\n}\n\n/**\n * Props for {@link Unit}. The formatter options it extends (`decimals`, `scale`\n * and the rest) apply to the number drawn. Useful for showing the operator a\n * quantity with its unit. Taken by {@link Unit}.\n *\n * @category Unit\n */\nexport interface UnitProps<UnitSymbol extends string = string>\n extends Omit<FormatQuantityOptions, \"format\" | \"as\"> {\n /**\n * The quantity to show; it carries its own unit. Absent or null renders the null token, so a read can be handed straight over without a gate; zero renders as zero.\n *\n * A whole {@link Reading} also draws whether the number is current.\n */\n value?: UnitValue<UnitSymbol> | null;\n /**\n * Pin the unit rather than letting the value's size choose it, where\n * convention calls for one: km/h on a launch broadcast, km/s in a technical\n * readout. Takes a registered unit of the value's kind.\n *\n * Validated against the value's kind: it checks on a speed and is a type error on a length.\n */\n format?: FormatsFor<UnitSymbol>;\n /**\n * Show the value in a different unit of the same kind: `as=\"°C\"` on a kelvin\n * field, `as=\"g\"` on an m/s² one. The contract says what the field is, this\n * says what the operator wants to read. Takes everything `format` takes and\n * also the presentation-only units of the kind, such as `°C`.\n *\n * Validated against the value's kind, as `format` is. A cross-kind request at runtime renders the value in its own unit.\n */\n as?: PresentableAs<UnitSymbol>;\n /**\n * Draw the number without its symbol, for a member of a group that prints the\n * symbol once at the end: `1234/2000 rpm` rather than `1234 rpm/2000 rpm`.\n *\n * Honoured only inside a `<UnitSharedFormat>`; on a lone `<Unit>` it does nothing, since a number with no unit near it is not a readout. The value still counts toward the unit the group settles on. The symbol is hidden from the accessibility tree as well as the screen.\n */\n hideUnitInGroup?: boolean;\n /**\n * Draw the reading's model in place of its observation, where the model has\n * one. The figure is always marked as modelled wherever it is not a reading\n * of now (a blue triangle, where a held figure takes the warning dot), so it\n * never passes for an observed one. For a figure a\n * person reads as the truth about now (a position, an altitude, a clock);\n * leave it off where the number is an input to a computation.\n */\n reckoned?: boolean;\n /**\n * The mark and words for a figure derived from a reading rather than read\n * off one (see {@link derivedMarking}), where `value` is a bare quantity that\n * carries none of its own. Ignored when `value` is a whole `Reading`.\n */\n marked?: ReckoningMarking | null;\n /**\n * Says the figure is of something other than what its label names (a\n * strength measured on another route), in the words given. The figure's mark\n * is then drawn hollow, a ring where the figure is a reading of now, and the\n * words follow whatever the figure already says about how current it is.\n */\n elsewhere?: string | null;\n /** A bare unit token, rendered as a symbol with no number. Used only when `value` is not passed; prefer passing a value. */\n children?: ReactNode;\n /** A class for the outer element, so a styled-component can extend it. */\n className?: string;\n}\n\n/** The symbol half: the glyph or icon, plus the word that replaces it in the accessibility tree. */\nfunction UnitSymbol({\n token,\n className,\n spaced,\n}: {\n token: string;\n className?: string;\n spaced: boolean;\n}) {\n const symbol = displaySymbol(token, kindOfUnit(token));\n\n // Category kinds (count, id, text, flag, enum, n/a) display as an empty string: they name what a field is, not a unit.\n if (symbol === \"\") return null;\n\n const word = wordForSymbol(symbol);\n // A currency over something (\"sci/day\") keeps its glyph and writes the rest as text after it.\n const compound = splitCurrencyCompound(symbol);\n const Glyph =\n ICON_BY_SYMBOL[(compound?.head ?? symbol) as keyof typeof ICON_BY_SYMBOL];\n const attached = ATTACHED.has(symbol);\n\n // The word replaces the symbol in the accessibility tree; a symbol with no word stays announced rather than the unit vanishing.\n const spoken = word !== undefined;\n\n return (\n <>\n {spaced && !attached ? THIN_SPACE : null}\n <Tooltip text={word} announce={false}>\n <Unit__Span\n $attached={attached}\n $icon={Glyph !== undefined}\n className={className}\n data-unit={token}\n >\n {Glyph ? (\n <>\n <Glyph size=\"1em\" />\n {compound && <span aria-hidden=\"true\">/{compound.rest}</span>}\n </>\n ) : spoken ? (\n <span aria-hidden=\"true\">{symbol}</span>\n ) : (\n symbol\n )}\n {spoken && <Unit__Word data-unit-word=\"\"> {word}</Unit__Word>}\n </Unit__Span>\n </Tooltip>\n </>\n );\n}\n\n/**\n * A quantity, rendered whole: `<Unit value={altitude} />`. The value carries\n * its own unit, so the call site names neither the unit nor the format. Useful\n * for showing the operator a figure with its unit, formatted the same way in\n * every widget. Used by the maneuver planner's burn rows and the settings.\n *\n * An absent or null value renders `NULL_DISPLAY`, never blank space, and a magnitude of zero keeps its zero.\n *\n * Handed a `Reading<Value<UnitSymbol>>`, it also draws whether the number is current, in three treatments:\n * - current (`observed`): drawn as a bare `Value` is, with no mark\n * - no number (`pending`, `unowned`, `absent`): the null token\n * - held (`held`, any grade): the last observation in full, marked by a square at superscript height in the warning hue, with the grade and the `asOfUt` instant on hover and in the spoken caption\n *\n * With `reckoned`, a reading with a model draws the model's figure and marks it modelled (a blue triangle) wherever it is not a reading of now.\n *\n * The mark is out of flow, so a column never reflows when a channel goes quiet, and it is not a live region: a widget that wants the change announced wraps its readout in `role=\"status\"`. Without `reckoned` it never draws a reckoned figure, so a modelled value never passes for an observed one; do not pull a figure out of a reading's reckoning and hand it to a plain `Unit`.\n *\n * A held reading whose model publishes an {@link UncertaintyBand} also shows the interval (`1 km ± 0.025 km`, `1 km (0.97 to 1.03 km)`, `1 km (~1.2 km)`). A current reading shows none, and a band in another unit draws nothing.\n *\n * The symbol is sized relative to the text around it (never below 10px) and takes its colour, so it needs no size or tone prop and keeps the value's tone at the value's contrast. A symbol that attaches to the number (`22°`, but `22 °C`) is set with no space and keeps full size: the plane-angle marks and the currency marks. Every symbol is replaced in the accessibility tree by its spoken word.\n *\n * `<Unit>` is the way to put a quantity on screen as a React node. Where only text is accepted (an SVG `<text>`, a tooltip, a canvas), write it with {@link writeQuantity} instead. Hand it the value as it arrived (SI, never pre-scaled) and let it choose the unit; pin one with `format` or convert with `as` only where convention calls for it.\n *\n * @example\n * ```tsx\n * import { useTelemetry, value } from \"@ksp-gonogo/sitrep-sdk\";\n * import { Stack, Unit } from \"@ksp-gonogo/ui-kit\";\n *\n * function Readouts(props: { bodyRadiusMetres: number }) {\n * const flight = useTelemetry(\"vessel.flight\");\n * // The first three are fields of a Topic, each a whole Reading, so each\n * // draws the held mark when the Topic goes quiet. The last is a bare\n * // number, wrapped with its SI unit.\n * return (\n * <Stack>\n * <Unit value={flight.altitudeAsl} />\n * <Unit value={flight.verticalSpeed} decimals={1} />\n * <Unit value={flight.surfaceSpeed} format=\"km/h\" />\n * <Unit value={value(\"m\", props.bodyRadiusMetres)} />\n * </Stack>\n * );\n * }\n * ```\n *\n * @category Unit\n * @categoryDescription Unit\n * A {@link Unit} puts a value with its unit on screen, formatted the same way\n * everywhere, and every number with a unit is drawn through one. Around it sit the marks for a figure that is held or modelled\n * instead of current, the bands for a figure known only within limits, the\n * null token for no value, and the helpers that write a quantity as text where\n * a node will not do.\n */\nexport function Unit<UnitSymbol extends string = string>({\n value,\n children,\n className,\n // Kept out of `opts`, which goes to the formatter: this is about drawing, not the number.\n hideUnitInGroup,\n reckoned,\n marked,\n elsewhere,\n ...opts\n}: UnitProps<UnitSymbol>) {\n const resolvedCurrency = resolveCurrency(value, { drawsReckoning: reckoned });\n // A bare quantity is current by construction, so a derived figure's mark comes from the caller.\n const currency =\n marked != null && !resolvedCurrency.held && resolvedCurrency.shown != null\n ? {\n ...resolvedCurrency,\n held: true,\n mark: marked.kind,\n caption: marked.caption,\n }\n : resolvedCurrency;\n const { shown, held, mark: ownMark, band } = currency;\n const hollow = elsewhere != null && elsewhere !== \"\" && shown != null;\n // A reading of now carries no mark of its own, and takes the ring where it is of something else.\n const mark: MarkKind | null = ownMark ?? (hollow ? \"current\" : null);\n const caption = hollow\n ? [currency.caption, elsewhere].filter(Boolean).join(\"; \")\n : currency.caption;\n /*\n * Reports to an enclosing `<UnitSharedFormat>` and returns the format the group settled on; inert with no scope above it.\n * A held member reports as a live one does, so a column's rung does not move when one cell stops updating.\n */\n const shared = useSharedFormat(shown, opts);\n\n // Membership, not `shared !== undefined`: a group over a unit with no ladder (`rpm`) settles nothing yet still hides the symbol.\n const inGroup = useInSharedFormat();\n const hideSymbol = hideUnitInGroup === true && inGroup;\n\n /*\n * The group's answer goes under this call site's own props, so a caller's pin wins.\n * Render `formatted.symbol`, never `formatted.rung`: a duration interleaves its parts into the value (\"2h 14m\") with an empty symbol while its rung is still \"s\".\n */\n const resolved = shared === undefined ? opts : { ...shared, ...opts };\n const formatted = formatQuantity(shown?.magnitude, shown?.unit, resolved);\n // Narrowed to the shown value's unit, never assumed: a band arrives keyed by a runtime path, and `bandIn` answers nothing rather than converting.\n const interval =\n shown == null || band === null || !held\n ? null\n : toInterval(shown, bandIn(band, shown.unit), resolved, formatted.rung);\n // The hover says in words what the mark says in shape, plus the instant and the band's claim.\n const { anchor, tip } = useTooltip(hover(caption, interval));\n\n if (value !== undefined || children === undefined) {\n return (\n <Unit__Quantity\n className={className}\n $mark={mark}\n $elsewhere={hollow}\n {...figureAttributes(currency)}\n {...anchor}\n >\n {formatted.value}\n {!hideSymbol && <UnitSymbol token={formatted.symbol} spaced />}\n {interval !== null && (\n <Unit__Interval data-unit-band=\"\">\n {interval.oneFigure ? (\n <>\n {\" (\"}\n {/* The approximate mark is silent; the word beside it is spoken. */}\n <span aria-hidden=\"true\">~</span>\n <Unit__Word data-unit-word=\"\">approximately </Unit__Word>\n {interval.lo}\n </>\n ) : interval.plusMinus === null ? (\n ` (${interval.lo} to ${interval.hi}`\n ) : (\n ` ± ${interval.plusMinus}`\n )}\n {/* A band is in the figure's unit, so its symbol hides with the main one. */}\n {!hideSymbol && <UnitSymbol token={formatted.symbol} spaced />}\n {interval.plusMinus === null ? \")\" : null}\n </Unit__Interval>\n )}\n {/* Silent: the caption below is what gets spoken, and the shape alone carries the meaning (WCAG 1.4.1). */}\n {mark !== null && <ReckoningMark kind={mark} elsewhere={hollow} />}\n {caption !== null && (\n <Unit__Currency data-unit-currency=\"\">, {caption}</Unit__Currency>\n )}\n {tip}\n </Unit__Quantity>\n );\n }\n\n // A non-string child cannot be looked up, so it renders as given.\n if (typeof children !== \"string\") {\n return (\n <Unit__Span $attached={false} $icon={false} className={className}>\n {children}\n </Unit__Span>\n );\n }\n\n return <UnitSymbol token={children} className={className} spaced={false} />;\n}\n","import { forwardRef, type HTMLAttributes, type ReactNode } from \"react\";\nimport styled from \"styled-components\";\nimport { GAP_VAR, type GapToken } from \"./scales\";\n\n/**\n * Horizontal distribution for {@link Cluster}: `between` pushes the first and\n * last children to the edges, the others pack children to one side or the\n * middle. Set with the `justify` prop of {@link Cluster}.\n * Useful for placing a row's controls at its ends, its start, its middle or\n * its end.\n *\n * @category Layout\n */\nexport type ClusterJustify = \"between\" | \"start\" | \"center\" | \"end\";\n\n/**\n * Vertical alignment of {@link Cluster}'s children. Set with its `align` prop.\n * Useful for lining up controls and readouts of different heights in one row.\n *\n * @category Layout\n */\nexport type ClusterAlign = \"center\" | \"start\" | \"baseline\";\n\n/**\n * Props for {@link Cluster}. Any other `div` attribute passes through, and the\n * ref reaches the root `div`.\n * Useful for setting the spacing, alignment and wrapping of a row of controls\n * or readouts. Used by {@link Cluster}.\n *\n * @category Layout\n */\nexport interface ClusterProps extends HTMLAttributes<HTMLDivElement> {\n /** `justify-content` shorthand. Defaults to `between`. */\n justify?: ClusterJustify;\n /**\n * `align-items` shorthand. Defaults to `center`; use `start` when one side\n * can be taller than the other, such as a label beside a wrapping control.\n */\n align?: ClusterAlign;\n /**\n * Gap between children, one of the {@link GapToken} names. Omitted, the row\n * takes the `related` gap of whatever container it sits in, so the same row\n * is 8px on a panel and 6px inside a card. Set it only where this row\n * decides the spacing of what it holds.\n */\n gap?: GapToken;\n /**\n * Let children wrap onto further lines. Off by default, so a row of controls\n * never silently turns into a ragged block; chip strips and tag lists opt in.\n */\n wrap?: boolean;\n /** The items, laid out in a row. */\n children?: ReactNode;\n}\n\nconst JUSTIFY_CONTENT: Record<ClusterJustify, string> = {\n between: \"space-between\",\n start: \"flex-start\",\n center: \"center\",\n end: \"flex-end\",\n};\n\nconst ALIGN_ITEMS: Record<ClusterAlign, string> = {\n center: \"center\",\n start: \"flex-start\",\n baseline: \"baseline\",\n};\n\n/**\n * A horizontal flex row, taking {@link ClusterProps}. Useful for laying out\n * controls or readouts side by side. Used by the settings panels. By default its children are vertically\n * centred and spread to both edges (`space-between`), and it carries\n * `min-width: 0` so a truncating child truncates instead of overflowing.\n * Children stay on one line unless `wrap` is set.\n *\n * @category Layout\n */\nexport const Cluster = forwardRef<HTMLDivElement, ClusterProps>(\n function Cluster(\n {\n justify = \"between\",\n align = \"center\",\n gap,\n wrap = false,\n children,\n ...rest\n },\n ref,\n ) {\n return (\n <Cluster__Root\n ref={ref}\n $justify={justify}\n $align={align}\n $gap={gap}\n $wrap={wrap}\n {...rest}\n >\n {children}\n </Cluster__Root>\n );\n },\n);\n\nconst Cluster__Root = styled.div<{\n $justify: ClusterJustify;\n $align: ClusterAlign;\n $gap?: GapToken;\n $wrap: boolean;\n}>`\n display: flex;\n align-items: ${({ $align }) => ALIGN_ITEMS[$align]};\n justify-content: ${({ $justify }) => JUSTIFY_CONTENT[$justify]};\n gap: ${({ $gap }) => ($gap ? GAP_VAR[$gap] : \"var(--gap-related)\")};\n ${({ $wrap }) => ($wrap ? \"flex-wrap: wrap;\" : \"\")}\n min-width: 0;\n`;\n","import type { BadgeEntry, HeldGrade, Tone } from \"@ksp-gonogo/sitrep-sdk\";\nimport { heldTone } from \"./heldTone\";\nimport { heldGradeOf } from \"./readingCurrency\";\nimport { heldWord } from \"./status/streamStatusWord\";\n\n/**\n * What a badge entry draws: its words, its tone, its tooltip and whether it is\n * held. Useful for telling the operator the state of a widget at a glance.\n * Returned by {@link badgeFace}.\n *\n * @category Badge\n */\nexport interface BadgeFace {\n /** The words the badge shows: the entry's own `label`, held or not. */\n label: string;\n /** The badge's tone: the entry's own, or its held tone while the entry is held. `undefined` draws it neutral. */\n tone: Tone | undefined;\n /** The hover text. `undefined` where there is none. */\n title: string | undefined;\n /** The held grade while the entry's reading is held, for the badge's `held` prop. Absent while it is current. */\n held?: HeldGrade;\n}\n\n/**\n * How a `BadgeEntry` reads once its `held` reading is taken into account. With\n * no held grade it returns the entry's own `label`, `tone` and `title`. With\n * one, the label stays, the tone becomes its held tone (`go` and `info` read\n * `caution`, every other tone is kept), the title names the grade\n * (`\"<label>: <word>\"`) unless the entry set its own, and `held` carries the\n * grade so the badge draws its held square. Useful for showing the operator a\n * widget's badge the same way the panel header does. Used by the panel header\n * and the screen header badges.\n *\n * @category Badge\n */\nexport function badgeFace(entry: BadgeEntry & { title?: string }): BadgeFace {\n const grade = heldGradeOf(entry.held);\n if (grade === undefined) {\n return { label: entry.label, tone: entry.tone, title: entry.title };\n }\n return {\n label: entry.label,\n tone: heldTone(entry.tone),\n title: entry.title ?? `${entry.label}: ${heldWord(grade)}`,\n held: grade,\n };\n}\n","/**\n * What an instrument draws when its figure is a reading rather than a bare\n * quantity: the held mark, the model's two bounds, and the sentence a\n * screen reader hears.\n *\n * The vocabulary is `<Unit>`'s and `<Meter>`'s, in SVG: the held square is a tspan and\n * the bound is a line, with the same hue, shape and wording.\n */\nimport type { ReactNode } from \"react\";\nimport { RECKONING_MARK, type ReckoningKind } from \"./reckoningMarkSpec\";\n\n/** How tall a lining digit stands above its baseline, and how far the mark's glyph does, each as a share of its own font size. */\nconst DIGIT_HEIGHT_EM = 0.72;\nconst GLYPH_TOP_EM = 0.76;\n\n/**\n * The held mark, as an instrument can draw it: a superscript tspan in the\n * readout's warning hue. Useful for showing the operator that an instrument's\n * figure is held at its last observation. Used by {@link Tape},\n * {@link Dial} and {@link ControlDelayStream}.\n *\n * It is a shape that is present or absent, so nothing rests on telling amber\n * from grey. It is silent to a screen reader: the instrument says it through\n * {@link sayHeld}.\n *\n * Give `figureSize`, the font size of the figure it follows, wherever the\n * figure is much larger than the mark: the mark is then raised until its top\n * meets the top of the figure's digits. Without it the mark is raised by half\n * its own height, which is superscript only beside text of about its own size.\n *\n * @category Unit\n */\nexport function InstrumentHeldMark({\n size,\n kind = \"held\",\n figureSize,\n}: {\n size: number;\n kind?: ReckoningKind;\n figureSize?: number;\n}) {\n return (\n <tspan\n // Raised, so it reads as a mark on the figure rather than another figure.\n dy={\n figureSize === undefined\n ? -size * 0.55\n : -(figureSize * DIGIT_HEIGHT_EM - size * GLYPH_TOP_EM)\n }\n fontSize={size}\n fill={RECKONING_MARK[kind].color}\n data-held-mark=\"\"\n data-reckoning-mark={kind}\n >\n {RECKONING_MARK[kind].glyph}\n </tspan>\n );\n}\n\n/**\n * One end of the model's interval, drawn across the instrument's own track.\n * Useful for showing the operator the limits a modelled figure is known\n * within. Used by {@link Tape} and {@link Dial}.\n *\n * Two marks are drawn for an interval, never a shaded area, as on\n * {@link Meter}. The caller owns the geometry; what is shared is how it looks.\n *\n * @category Unit\n */\nexport function InstrumentBound({\n end,\n x1,\n y1,\n x2,\n y2,\n}: {\n end: \"lo\" | \"hi\";\n x1: number;\n y1: number;\n x2: number;\n y2: number;\n}) {\n return (\n <line\n data-bound={end}\n x1={x1}\n y1={y1}\n x2={x2}\n y2={y2}\n stroke=\"var(--color-text-primary)\"\n strokeWidth={2}\n opacity={0.62}\n pointerEvents=\"none\"\n />\n );\n}\n\n/**\n * The accessible name with the held or modelled mark's words after it.\n * Nothing is appended when the figure is current. Useful for telling an\n * operator who uses a screen reader that a figure is held or modelled. Used by\n * {@link Tape} and the space centre status.\n *\n * @category Unit\n */\nexport function sayHeld(name: string, caption: string | null): string {\n return caption === null ? name : `${name}, ${caption}`;\n}\n\n/**\n * The attribute that marks an element whose accessible name ends with a\n * {@link sayHeld} caption. Spread it on the element that carries that name.\n * Useful for letting a test or a checker find the names that carry a held or\n * modelled caption. Used by {@link Tape} and {@link Dial}.\n *\n * @category Unit\n */\nexport function heldNameMarker(caption: string | null): {\n \"data-currency-in-name\"?: \"\";\n} {\n return caption === null ? {} : { \"data-currency-in-name\": \"\" };\n}\n\n/**\n * What an instrument shows in place of a needle when the reading carries no\n * number at all. Useful for telling the operator there is no figure to read,\n * where a needle parked at the bottom of the scale would claim one. Used by\n * {@link Tape}.\n *\n * @category Unit\n */\nexport function InstrumentNoFigure({\n x,\n y,\n size,\n children,\n}: {\n x: number;\n y: number;\n size: number;\n children: ReactNode;\n}) {\n return (\n <text\n x={x}\n y={y}\n textAnchor=\"middle\"\n fontSize={size}\n fill=\"var(--color-text-muted)\"\n >\n {children}\n </text>\n );\n}\n","/**\n * How the rail draws an entry, given what the entry says it is.\n *\n * The three axes and the derivations that fill them in live in the SDK\n * (`@ksp-gonogo/sitrep-sdk`'s `rail-tags.ts`), because they are read off what\n * the mod declares. This file is the other half: one accessor per axis, and a\n * table saying which combination each renderer draws.\n *\n * | direction | kind | delivery | a real example | drawn by |\n * |-----------|------------|------------------|---------------------------------|--------------------|\n * | command | event | acked | staging, an action group | `in-flight-row` |\n * | command | discrete | acked | a mode held until changed | `in-flight-row` |\n * | command | continuous | acked | fly-by-wire, ack = the readback | `continuous-strip` |\n * | telemetry | continuous | fire-and-forget | radio voice | `continuous-strip` |\n * | telemetry | event | fire-and-forget | a science result sent home | `in-flight-row` |\n * | telemetry | discrete | fire-and-forget | a state reported as it changes | `in-flight-row` |\n *\n * The table names a renderer (a component). Which mark it draws follows from\n * the data: both continuous rows share one strip, lines for a value against a\n * readback, a trace for an amplitude history.\n *\n * A combination with no renderer reads as `null`, `unrepresentedRailTags()`\n * names it, and an entry carrying it is reported rather than silently omitted\n * or drawn wrongly. A new row costs an entry here plus the renderer it names.\n *\n * Each axis drives exactly one visual property.\n */\n\nimport type {\n RailDelivery,\n RailDirection,\n RailTags,\n SampleKind,\n} from \"@ksp-gonogo/sitrep-sdk\";\nimport { hasHost, logger } from \"@ksp-gonogo/sitrep-sdk\";\n\nexport type {\n RailDelivery,\n RailDirection,\n RailTags,\n} from \"@ksp-gonogo/sitrep-sdk\";\n\n/**\n * The kind axis, and only it: `ribbon` for a span lying along the rail (a\n * continuous entry), `dot` for a point travelling it (a discrete entry or an\n * event). Useful for choosing how the operator sees an entry on the delay rail.\n * Used by {@link CommandList} and the panel delay rail.\n */\nexport function railMark(tags: RailTags): \"dot\" | \"ribbon\" {\n return tags.kind === \"continuous\" ? \"ribbon\" : \"dot\";\n}\n\n/**\n * The delivery axis, and only it: whether anything is drawn coming back from the\n * vessel. Useful for showing the operator a return trace only for an entry that\n * has a reply. Used by {@link ControlDelayStream}.\n */\nexport function railDrawsReturnLeg(tags: RailTags): boolean {\n return tags.delivery === \"acked\";\n}\n\n/**\n * The direction axis, and only it: which way along the rail the entry runs.\n * Useful for showing whether the operator is looking at an order leaving or\n * news arriving. Used by {@link ControlDelayStream}.\n */\nexport function railFlow(tags: RailTags): \"outbound\" | \"inbound\" {\n return tags.direction === \"command\" ? \"outbound\" : \"inbound\";\n}\n\n/**\n * The direction axis, and only it, as a theme token name (no `var()` wrapper):\n * accent for orders leaving, info for news arriving. Useful for colouring an\n * entry by its direction. Used by {@link ControlDelayStream}.\n */\nexport function railToneToken(tags: RailTags): string {\n return tags.direction === \"command\"\n ? \"--color-accent-fg\"\n : \"--color-info-mark\";\n}\n\n/** Every value of each axis, in the order the table above reads. */\nconst DIRECTIONS: readonly RailDirection[] = [\"command\", \"telemetry\"];\nconst KINDS: readonly SampleKind[] = [\"event\", \"discrete\", \"continuous\"];\nconst DELIVERIES: readonly RailDelivery[] = [\"acked\", \"fire-and-forget\"];\n\n/**\n * One combination of the three axes, spelled `direction/kind/delivery`. Useful\n * for keying an entry on the delay rail. Returned by {@link railTagKey}.\n */\nexport type RailTagKey = `${RailDirection}/${SampleKind}/${RailDelivery}`;\n\n/**\n * A handle's three rail axes as one `direction/kind/delivery` string, e.g.\n * `command/event/acked`. Useful for keying an entry on the delay rail. Used by\n * {@link CommandDelay} and {@link ControlDelayStream}.\n *\n * @intent Published so a representation of the rail of a third party can key its entries by the same tag combination the kit does.\n * @category CommandDelay\n */\nexport function railTagKey(tags: RailTags): RailTagKey {\n return `${tags.direction}/${tags.kind}/${tags.delivery}`;\n}\n\n/**\n * What actually draws an entry. Two components, and there are only two:\n *\n * - `in-flight-row`: a row in `InFlightList`, the queue of points crossing the delay\n * - `continuous-strip`: `ControlDelayStream`, the three-zone graph, whichever\n * mark the entry's data calls for inside it\n *\n * Returned by {@link railRendererFor}.\n */\nexport type RailRenderer = \"in-flight-row\" | \"continuous-strip\";\n\n/** Which renderer draws which combination. `Partial`: an absent combination has no renderer, never a fallback. */\nconst RAIL_RENDERERS: Partial<Record<RailTagKey, RailRenderer>> = {\n \"command/event/acked\": \"in-flight-row\",\n \"command/discrete/acked\": \"in-flight-row\",\n \"command/continuous/acked\": \"continuous-strip\",\n \"telemetry/continuous/fire-and-forget\": \"continuous-strip\",\n \"telemetry/event/fire-and-forget\": \"in-flight-row\",\n \"telemetry/discrete/fire-and-forget\": \"in-flight-row\",\n};\n\n/**\n * The renderer for an entry, or `null` when nothing draws that combination. A\n * caller handed `null` reports it ({@link reportUnrepresentedRail}) rather than\n * rendering nothing quietly. Useful for choosing which display shows the\n * operator an entry. Used by {@link CommandDelay} and {@link ControlDelayStream}.\n */\nexport function railRendererFor(tags: RailTags): RailRenderer | null {\n return RAIL_RENDERERS[railTagKey(tags)] ?? null;\n}\n\n/**\n * Every combination of the three axes, twelve in all. Useful for checking that\n * each combination is either drawn or reported.\n */\nexport function allRailTags(): RailTags[] {\n const out: RailTags[] = [];\n for (const direction of DIRECTIONS)\n for (const kind of KINDS)\n for (const delivery of DELIVERIES)\n out.push({ direction, kind, delivery });\n return out;\n}\n\n/**\n * The combinations nothing can draw. Useful for checking which entries would\n * never reach the operator's screen.\n */\nexport function unrepresentedRailTags(): RailTags[] {\n return allRailTags().filter((tags) => railRendererFor(tags) === null);\n}\n\n/** Combinations already reported, keyed by combination rather than entry, so a frame-rate re-render says it once. */\nconst reportedUnrepresented = new Set<RailTagKey>();\n\n/**\n * Reports that an entry declared something the rail cannot draw, naming the\n * combination and who declared it. Never throws, so the widget survives. Falls\n * back to `console.error` without a host, because the sdk's `logger` throws\n * when none is installed. Useful for surfacing an entry the operator would\n * otherwise not see. Used by {@link CommandDelay} and {@link ControlDelayStream}.\n */\nexport function reportUnrepresentedRail(tags: RailTags, who: string): void {\n const key = railTagKey(tags);\n if (reportedUnrepresented.has(key)) return;\n reportedUnrepresented.add(key);\n const message =\n `Delay rail entry \"${who}\" is tagged ${key}, and no renderer draws that ` +\n `combination, so it will not appear on the rail. Declare a renderer for it ` +\n `in ui-kit's railTags.ts, or correct the entry's tags.`;\n if (hasHost()) logger.error(message);\n else console.error(message);\n}\n\n/** Test-only: forget what has been reported. Not on the published barrel. */\nexport function resetUnrepresentedRailReports(): void {\n reportedUnrepresented.clear();\n}\n","/**\n * The ribbon mark's geometry: a continuous entry's amplitude history as an open\n * waveform trace, in its own 16-unit-tall box. A pure module, so the drawing can\n * be asserted directly.\n */\n\n/**\n * The height of the ribbon mark's own coordinate box (100 wide by 16 tall),\n * scaled by the caller into whatever band it has. Used by\n * {@link ControlDelayStream}.\n */\nexport const WAVE_VB_H = 16;\n/**\n * The centre line of the ribbon mark's box, in box units. Useful for reading a\n * drawn waveform against its centre line.\n *\n * @intent Published so a caller can read the trace waveformPath draws back against its centre line.\n * @category CommandDelay\n */\nexport const WAVE_MID_Y = WAVE_VB_H / 2;\n/**\n * How far a full-scale sample reaches either side of the centre line, in box\n * units. It is short because the rail is a thin band. Useful for reading a drawn\n * waveform back as an amplitude.\n *\n * @intent Published so a caller can read the trace waveformPath draws back as an amplitude.\n * @category CommandDelay\n */\nexport const WAVE_HALF_H = 5.5;\n/**\n * The nominal distance between turning points (half a period), in box units.\n * Fixed in the drawing rather than taken from the capture rate, so the trace\n * reads as a wave at any capture density rather than a solid hatch or a flat\n * line.\n */\nconst WAVE_STEP = 2;\n\nconst clamp01 = (v: number): number =>\n !Number.isFinite(v) ? 0 : v < 0 ? 0 : v > 1 ? 1 : v;\n\n/**\n * How far along the rail the drawn trace reaches: one signal delay out at most,\n * and only as far as there is history. A measurement, not a drawing choice:\n * samples older than the span have arrived and are dropped. Useful for showing\n * the operator only the audio still on its way to the vessel. Used by\n * {@link ControlDelayStream}.\n */\nexport function waveformExtentX(\n amplitudes: { readonly length: number },\n spanSamples: number,\n boundaryX: number,\n): number {\n if (!(spanSamples > 0)) return 0;\n return (\n (Math.min(amplitudes.length - 1, spanSamples) / spanSamples) * boundaryX\n );\n}\n\n/**\n * How many turning points the trace is entitled to: the tighter of the drawing\n * pitch (`WAVE_STEP`) and the samples the gap holds. A trace may be coarse; it\n * may not invent turning points it has no samples for. The resolution limit is\n * floored at two segments, since one cannot cross the centre line.\n */\nfunction waveformSteps(\n amplitudes: readonly number[],\n spanSamples: number,\n extentX: number,\n): number {\n const resolvable = Math.min(amplitudes.length, spanSamples);\n return Math.min(\n Math.max(1, Math.ceil(extentX / WAVE_STEP)),\n Math.max(2, Math.round(resolvable)),\n );\n}\n\n/**\n * Turn a newest-last amplitude ring into an open waveform trace crossing the\n * band's centre, each turning point's height a sample's amplitude, at a fixed\n * pitch so the period stays visible. Silence is a flat line down the middle:\n * the key is open and nobody is speaking. Useful for showing the operator a\n * voice transmission still on its way. Used by {@link ControlDelayStream}.\n *\n * Each sample is drawn at its age, where that audio is on its way to the\n * vessel, so a short history draws a trace that stops short of the boundary.\n * Keep a longer history to fill it.\n *\n * @category CommandDelay\n */\nexport function waveformPath(\n amplitudes: readonly number[],\n spanSamples: number,\n boundaryX: number,\n): string {\n if (amplitudes.length === 0) return \"\";\n const extentX = waveformExtentX(amplitudes, spanSamples, boundaryX);\n // A trace of no length is a single vertex, not empty: a key that has just opened IS a crossing.\n if (!(extentX > 0)) return `M0.00,${WAVE_MID_Y.toFixed(2)}`;\n const steps = waveformSteps(amplitudes, spanSamples, extentX);\n /*\n * Each turning point is the LOUDEST sample of the stretch of audio it stands\n * for, not the one sample at its centre. The trace has far fewer points than\n * the ring has samples, and reading one sample per point would let a syllable\n * fall between two of them and vanish from the picture.\n */\n const agesPerStep = (extentX / boundaryX) * (spanSamples / steps);\n const newest = amplitudes.length - 1;\n const points: string[] = [];\n for (let k = 0; k <= steps; k++) {\n const x = Math.min((k / steps) * extentX, extentX);\n const from = Math.max(0, Math.round((k - 0.5) * agesPerStep));\n const to = Math.min(newest, Math.round((k + 0.5) * agesPerStep));\n let a = 0;\n for (let age = from; age <= Math.max(from, to); age++) {\n a = Math.max(a, clamp01(amplitudes[newest - Math.min(age, newest)]));\n }\n const dy = (k % 2 === 0 ? -1 : 1) * a * WAVE_HALF_H;\n points.push(`${x.toFixed(2)},${(WAVE_MID_Y + dy).toFixed(2)}`);\n }\n return `M${points.join(\" L\")}`;\n}\n\n/**\n * One block of audio as the lowest and highest sample it held, each scaled to\n * -1..1 against the edge of the band. Useful for drawing the wave itself\n * instead of how loud it was. Taken by {@link waveformBand}.\n *\n * @category CommandDelay\n */\nexport interface WaveBlock {\n /** The lowest sample of the block, -1 to 0. */\n lo: number;\n /** The highest sample of the block, 0 to 1. */\n hi: number;\n}\n\n/** The horizontal width of one column of the filled wave, in box units: about two screen pixels on the rail. */\nconst WAVE_COLUMN = 0.25;\n\n/**\n * Turn a newest-last ring of per-block lowest and highest samples into a filled\n * band, the way an audio editor draws a zoomed-out track: one column for each\n * slice of audio, from that slice's lowest sample to its highest. A pause is a\n * line along the centre; an attack and a decay are as steep as the voice made\n * them. Each column is placed where its audio is in the gap, by the same rule\n * as {@link waveformPath}. Useful for showing the operator the voice itself\n * crossing the gap. Used by {@link ControlDelayStream}.\n *\n * Returns the closed outline to fill, and `\"\"` for a ring with fewer than two\n * blocks, which has no width to draw.\n *\n * @category CommandDelay\n */\nexport function waveformBand(\n blocks: readonly WaveBlock[],\n spanSamples: number,\n boundaryX: number,\n): string {\n const extentX = waveformExtentX(blocks, spanSamples, boundaryX);\n if (!(extentX > 0)) return \"\";\n const newest = blocks.length - 1;\n const columns = Math.max(\n 1,\n Math.min(\n Math.round(Math.min(blocks.length, spanSamples)),\n Math.ceil(extentX / WAVE_COLUMN),\n ),\n );\n const agesPerColumn = (extentX / boundaryX) * (spanSamples / columns);\n const top: string[] = [];\n const bottom: string[] = [];\n for (let c = 0; c < columns; c++) {\n const from = Math.max(0, Math.round(c * agesPerColumn));\n const to = Math.min(\n newest,\n Math.max(from, Math.round((c + 1) * agesPerColumn) - 1),\n );\n let lo = 0;\n let hi = 0;\n for (let age = from; age <= to; age++) {\n const block = blocks[newest - age];\n if (!block) continue;\n if (Number.isFinite(block.lo)) lo = Math.min(lo, Math.max(-1, block.lo));\n if (Number.isFinite(block.hi)) hi = Math.max(hi, Math.min(1, block.hi));\n }\n const x0 = (c / columns) * extentX;\n const x1 = ((c + 1) / columns) * extentX;\n const yTop = (WAVE_MID_Y - hi * WAVE_HALF_H).toFixed(2);\n const yBottom = (WAVE_MID_Y - lo * WAVE_HALF_H).toFixed(2);\n top.push(`${x0.toFixed(2)},${yTop}`, `${x1.toFixed(2)},${yTop}`);\n // The lower edge runs back the way the upper one came, so the outline is one simple loop.\n bottom.unshift(\n `${x1.toFixed(2)},${yBottom}`,\n `${x0.toFixed(2)},${yBottom}`,\n );\n }\n return `M${top.join(\" L\")} L${bottom.join(\" L\")} Z`;\n}\n","import { type Reading, type Value, value } from \"@ksp-gonogo/sitrep-sdk\";\nimport { Fragment, useId } from \"react\";\nimport styled from \"styled-components\";\nimport {\n heldNameMarker,\n InstrumentHeldMark,\n sayHeld,\n} from \"../instrumentCurrency\";\nimport { resolveCurrency } from \"../readingCurrency\";\nimport { useTooltip } from \"../Tooltip\";\nimport { Unit } from \"../Unit\";\nimport { writeQuantity } from \"../units\";\nimport { withDelayCurrency } from \"./delayCurrency\";\nimport {\n type RailTags,\n railDrawsReturnLeg,\n railFlow,\n railRendererFor,\n railTagKey,\n railToneToken,\n reportUnrepresentedRail,\n} from \"./railTags\";\nimport {\n WAVE_MID_Y,\n WAVE_VB_H,\n type WaveBlock,\n waveformBand,\n waveformExtentX,\n waveformPath,\n} from \"./waveformPath\";\n\n/**\n * One sample on a control axis's trace in {@link ControlDelayStream}: a\n * commanded value at a moment. Useful for showing the operator how a held\n * control, such as a throttle, has moved. Carried by {@link ControlStreamDatum}.\n *\n * @category CommandDelay\n */\nexport interface ControlStreamSample {\n /** Seconds since issue: 0 = now (left), increasing rightward. */\n age: number;\n /** Value in the shared 0..1 band. */\n value: number;\n}\n\n/**\n * One control axis drawn by {@link ControlDelayStream}: what is still on its\n * way to the vessel, what has come back, and the value commanded now. Useful\n * for showing the operator how a held control, such as a throttle, compares with\n * what the vessel reports. Taken by {@link ControlDelayStream}.\n *\n * @category CommandDelay\n */\nexport interface ControlStreamDatum {\n /** Identifies the axis. */\n id: string;\n /** The axis's name, e.g. \"Throttle\". */\n label: string;\n /** One-way delay in seconds; the strip spans three times this. Below {@link STREAM_MIN_DELAY_SECONDS}, or `null`, nothing is drawn. */\n oneWaySeconds: number | null;\n /** Commanded values still on their way to the craft. */\n inTransit: ControlStreamSample[];\n /** Values the craft has confirmed back. */\n echo: ControlStreamSample[];\n /** `null` while nothing has been commanded on the axis. */\n current: number | null;\n /**\n * What this entry is on the three axes, in full, and not optional. A control\n * axis gets them from `railTagsForControlAxis(writeCommand)`. A\n * `fire-and-forget` entry gets the outgoing zone only, since nothing comes\n * back to draw.\n */\n tags: RailTags;\n}\n\n/**\n * One continuous transmission on its way from the command centre to a vessel,\n * such as the operator's voice: its loudness per chunk, with no value and no\n * echo back. Useful for showing how far a transmission has travelled. Used by\n * {@link ControlDelayStream}, which draws it as the ribbon mark in the\n * outgoing zone. A {@link ControlStreamDatum} carries a commanded value and\n * its echo instead.\n *\n * @category CommandDelay\n */\nexport interface ControlRibbonDatum {\n /** Identifies the ribbon. */\n id: string;\n /** What the ribbon is, in a sentence, e.g. \"Your transmission crossing to Odyssey\". */\n label: string;\n /** One-way delay seconds, read the same way a stream datum's is. */\n oneWaySeconds: number | null;\n /**\n * The amplitude history, one value per sample in 0..1, newest last. Each\n * sample is drawn at its age, so a history shorter than the trip draws a\n * trace that stops short; keep a longer history to fill it.\n */\n amplitudes: readonly number[];\n /**\n * The lowest and highest sample of each block of `amplitudes`, from the same\n * audio, newest last. When present the ribbon is drawn as the wave itself, a\n * filled band from each slice's lowest sample to its highest, and\n * `amplitudes` is not drawn; absent, the ribbon is drawn from `amplitudes`\n * alone as a loudness trace.\n */\n wave?: readonly WaveBlock[];\n /**\n * How many samples span the signal delay. Defaults to the whole\n * array. Fractional below one and never floored: a short signal delay can be\n * a fraction of a single sample.\n */\n spanSamples?: number;\n /**\n * What this entry is on the three axes, in full, and not optional. A\n * producer builds them with {@link railTagsForTelemetry}, passing its\n * sample kind.\n */\n tags: RailTags;\n}\n\n/**\n * The three sizes of {@link ControlDelayStream}. Set with the `variant` prop;\n * see {@link ControlDelayStreamProps.variant}.\n * Useful for fitting the control delay stream into a line of text, the delay\n * rail or a widget body.\n *\n * @category CommandDelay\n */\nexport type ControlDelayStreamVariant = \"inline\" | \"rail\" | \"expanded\";\n\n/**\n * Props for {@link ControlDelayStream}: the control axes and ribbons to draw,\n * and the one-way delay between the command centre and the vessel.\n * Useful for choosing which control axes the operator sees travelling to the\n * vessel and the delay they travel over. Used by {@link ControlDelayStream}.\n *\n * @category CommandDelay\n */\nexport interface ControlDelayStreamProps {\n /** All of a widget's local control axes on one graph. */\n streams: ControlStreamDatum[];\n /**\n * Continuous entries with no readback, drawn as ribbons in the outgoing zone\n * of the same graph, with nothing past the first boundary.\n */\n ribbons?: ControlRibbonDatum[];\n /** Accessible label for the graph. Defaults to \"Controls in flight\". */\n \"aria-label\"?: string;\n /**\n * `\"inline\"` (default, 40px) is the in-widget rendering; `\"rail\"` (16px, no\n * labels) is the collapsed drag-bar strip; `\"expanded\"` is the full-bleed,\n * taller graph with zone labels, a legend and a readout.\n */\n variant?: ControlDelayStreamVariant;\n /**\n * The one-way delay as the reading it arrived in, so the T and 2T figures\n * draw held while `comms.delay` is quiet. Omitted, they draw as current.\n */\n delayReading?: Reading<Value<\"s\">> | null;\n}\n\n/**\n * The one-way delay, in seconds, under which {@link ControlDelayStream} draws no\n * command streams. Ribbons draw at any positive delay. Useful for deciding\n * whether the operator sees a stream at a given delay. Read by\n * {@link ControlDelayStream}.\n *\n * @intent Published so a representation of the rail of a third party can agree with ControlDelayStream on when streams are drawn.\n * @category CommandDelay\n */\nexport const STREAM_MIN_DELAY_SECONDS = 0.05;\n\n/**\n * Whether a one-way delay is a real, positive figure. A ribbon draws at any\n * such delay, however short, because the zone it crosses is scaled to the\n * delay and the trace is sized by the audio, not by the gap; only a delay that\n * is exactly zero or unknown has nothing to cross. Used by the rail to decide\n * whether to mount around a ribbon.\n */\nexport function hasRealDelay(\n oneWay: number | null | undefined,\n): oneWay is number {\n return typeof oneWay === \"number\" && Number.isFinite(oneWay) && oneWay > 0;\n}\nconst DEVIATION_EPSILON = 0.02;\n/**\n * How far either side of its predicted moment a reading may be matched to the\n * command, in seconds: a reading comes home on the telemetry's own cadence, up\n * to a report interval after the round trip, so across a change it can still\n * show the value before it.\n */\nconst READING_LATENESS_SECONDS = 1.5;\n/** How close to the rail's far end the oldest command must be for the history to count as running past it: a little over one 10 Hz sample. */\nconst HISTORY_EDGE_SECONDS = 0.25;\n\n/** Soft distinct hues, in axis order (throttle, pitch, yaw, roll, ...). Wraps past four. */\nconst STREAM_TOKENS = [\n \"--color-data-1\",\n \"--color-data-2\",\n \"--color-data-3\",\n \"--color-data-4\",\n] as const;\n\n// viewBox units. Short height by design. Padding keeps strokes off the edges.\nconst VB_W = 100;\nconst VB_H = 30;\nconst PAD_X = 1.5;\nconst PAD_T = 2;\nconst PAD_B = 4;\nconst PLOT_H = VB_H - PAD_T - PAD_B;\n\nconst xAt = (age: number, span: number, padX: number): number =>\n padX + (span <= 0 ? 0 : Math.min(1, age / span)) * (VB_W - padX * 2);\nconst yAt = (value: number): number =>\n PAD_T + (1 - Math.max(0, Math.min(1, value))) * PLOT_H;\n\n/** The stroke inset, which only the in-widget inline variant keeps. */\nconst padXFor = (variant: ControlDelayStreamVariant): number =>\n variant === \"inline\" ? PAD_X : 0;\n\n/**\n * Where the first divider (T, one signal delay) sits for a ribbon, in the\n * graph's viewBox x units (100 wide): a third of the plot. It never moves with\n * delivery; delivery only decides whether anything is drawn past it. Useful for\n * placing a transmission's divider where the operator expects it. Used by\n * {@link ControlDelayStream}.\n *\n * @intent Published so a representation of the rail of a third party can place its divider where ControlDelayStream places the T.\n * @category CommandDelay\n */\nexport function ribbonBoundaryX(\n variant: ControlDelayStreamVariant = \"inline\",\n): number {\n const padX = padXFor(variant);\n return (VB_W - padX * 2) / 3;\n}\n\n/**\n * An entry whose declared combination nothing draws: zero ink, an addressable\n * marker (`data-rail-unrepresented`), and one report per combination through\n * {@link reportUnrepresentedRail}. Reported in render, not an effect, because a\n * static render runs no effects; the reporter is idempotent.\n */\nfunction UnrepresentedRailEntry({\n tags,\n who,\n}: {\n tags: RailTags;\n who: string;\n}) {\n reportUnrepresentedRail(tags, who);\n return <g data-rail-unrepresented={railTagKey(tags)} data-rail-entry={who} />;\n}\n\nfunction polyline(points: { x: number; y: number }[]): string {\n return points\n .map((p, i) => `${i === 0 ? \"M\" : \"L\"}${p.x.toFixed(2)},${p.y.toFixed(2)}`)\n .join(\" \");\n}\n\n/**\n * Clip the confirmed-echo line so it begins exactly at the 2T divider: nothing\n * is confirmed before it arrives, so earlier samples drop and an interpolated\n * vertex lands on the divider.\n */\nfunction clipToConfirmed(\n echo: ControlStreamSample[],\n boundaryAge: number,\n): ControlStreamSample[] {\n if (echo.length === 0 || echo[0].age >= boundaryAge) return echo;\n const after = echo.findIndex((s) => s.age >= boundaryAge);\n if (after === -1) return []; // nothing confirmed yet\n const before = echo[after - 1];\n const first = echo[after];\n const span = first.age - before.age || 1;\n const t = (boundaryAge - before.age) / span;\n const value = before.value + t * (first.value - before.value);\n return [{ age: boundaryAge, value }, ...echo.slice(after)];\n}\n\n/**\n * Clip a line so it ends exactly at the outgoing-stage boundary (`oneWay`, the\n * same value the T divider is drawn from), the mirror of `clipToConfirmed`.\n *\n * What a `fire-and-forget` entry gets for its solid leg. An interpolated vertex\n * is placed on the boundary itself so the line's end lands on the divider rather\n * than short of or past it; what happens immediately past the divider is\n * {@link OUTGOING_TAIL}'s business, and it is not this line.\n */\nfunction clipToOutgoing(\n samples: ControlStreamSample[],\n boundaryAge: number,\n): ControlStreamSample[] {\n if (samples.length === 0) return samples;\n const last = samples[samples.length - 1];\n if (last.age <= boundaryAge) return samples;\n const after = samples.findIndex((s) => s.age > boundaryAge);\n const kept = samples.slice(0, after);\n const first = samples[after];\n const before = kept[kept.length - 1];\n if (!before) return [{ age: boundaryAge, value: first.value }];\n const span = first.age - before.age || 1;\n const t = (boundaryAge - before.age) / span;\n return [\n ...kept,\n {\n age: boundaryAge,\n value: before.value + t * (first.value - before.value),\n },\n ];\n}\n\n/**\n * How far past the T divider a fire-and-forget leg trails off, as a fraction of\n * one signal delay. A sample past the boundary has arrived, so the trace fades\n * rather than stopping dead; short enough to read as an ending, not a second\n * leg.\n */\nconst OUTGOING_TAIL = 0.25;\n\n/**\n * Commanded value interpolated at `age` (local copy; ui-kit imports no model).\n * `null` past the oldest sample: nothing had been commanded that long ago, so a\n * readback at that age has no command to differ from.\n */\nfunction commandedAt(\n inTransit: ControlStreamSample[],\n age: number,\n): number | null {\n if (inTransit.length === 0) return null;\n const first = inTransit[0];\n const last = inTransit[inTransit.length - 1];\n if (age <= first.age) return first.value;\n if (age > last.age) return null;\n if (age === last.age) return last.value;\n for (let i = 1; i < inTransit.length; i++) {\n const b = inTransit[i];\n if (age <= b.age) {\n const a = inTransit[i - 1];\n const t = (age - a.age) / (b.age - a.age || 1);\n return a.value + t * (b.value - a.value);\n }\n }\n return last.value;\n}\n\n/**\n * The confirmed readings split into runs that agree with the command and runs\n * that do not, by index into `echo`. Neighbouring runs share their boundary\n * reading, so the line is drawn unbroken. A reading agrees when it lies within\n * the range the command took in the {@link READING_LATENESS_SECONDS} either\n * side of its moment. One whose allowance reaches back before the first\n * command on the rail always agrees, since what the craft was told then is\n * unknown.\n */\nfunction offCommandRuns(\n echo: readonly ControlStreamSample[],\n inTransit: ControlStreamSample[],\n span: number,\n): { from: number; to: number; off: boolean }[] {\n // History reaching the rail's far end was cut there, and its oldest value held before it.\n const heldPastRail =\n inTransit.length > 0 &&\n inTransit[inTransit.length - 1].age >= span - HISTORY_EDGE_SECONDS;\n const off = echo.map((s) => {\n if (commandedAt(inTransit, s.age) === null) return false;\n let lo = Number.POSITIVE_INFINITY;\n let hi = Number.NEGATIVE_INFINITY;\n const take = (v: number | null) => {\n if (v === null) return;\n lo = Math.min(lo, v);\n hi = Math.max(hi, v);\n };\n const from = s.age - READING_LATENESS_SECONDS;\n const to = s.age + READING_LATENESS_SECONDS;\n let before = commandedAt(inTransit, to);\n if (before === null) {\n if (!heldPastRail) return false;\n before = inTransit[inTransit.length - 1].value;\n }\n take(commandedAt(inTransit, from));\n take(before);\n for (const c of inTransit) if (c.age > from && c.age < to) take(c.value);\n return s.value < lo - DEVIATION_EPSILON || s.value > hi + DEVIATION_EPSILON;\n });\n const runs: { from: number; to: number; off: boolean }[] = [];\n let from = 0;\n for (let i = 1; i <= off.length; i++) {\n if (i < off.length && off[i] === off[from]) continue;\n runs.push({ from, to: Math.min(i, off.length - 1), off: off[from] });\n from = i;\n }\n return runs;\n}\n\nfunction StreamPaths({\n stream,\n span,\n index,\n padX,\n oneT,\n twoT,\n}: {\n stream: ControlStreamDatum;\n span: number;\n index: number;\n padX: number;\n /** The T stage boundary age, where a fire-and-forget entry's leg out ends. */\n oneT: number;\n /** The 2T stage boundary age, the same value the 2T divider is drawn from. */\n twoT: number;\n}) {\n const token = STREAM_TOKENS[index % STREAM_TOKENS.length];\n const colour = `var(${token})`;\n // Per-instance ids: `url(#id)` resolves to the first match in the document, so a shared literal lets one instance's gradient win for both.\n const uid = useId();\n const gradId = `cds-ramp-${uid}-${index}`;\n const fillId = `cds-fill-${uid}-${index}`;\n const tailId = `cds-tail-${uid}-${index}`;\n /*\n * Whether this strip draws the entry at all comes from the renderer table. A\n * combination nothing draws is REPORTED, ahead of the geometry so an empty\n * buffer is reported too.\n */\n const renderer = railRendererFor(stream.tags);\n if (renderer !== \"continuous-strip\") {\n return renderer === null ? (\n <UnrepresentedRailEntry tags={stream.tags} who={stream.id} />\n ) : null;\n }\n /*\n * DELIVERY alone decides this. Acked, the line runs the whole strip against\n * its confirmed echo; fire-and-forget, it gets the leg out plus the short\n * dissolving tail, and no return leg. The dividers never move.\n */\n const returnLeg = railDrawsReturnLeg(stream.tags);\n const outgoing = returnLeg\n ? stream.inTransit\n : clipToOutgoing(stream.inTransit, oneT);\n const cmd = outgoing.map((s) => ({\n x: xAt(s.age, span, padX),\n y: yAt(s.value),\n }));\n if (cmd.length === 0) return null;\n /*\n * The fire-and-forget tail: the segment between T and the tail's end, built\n * from the two existing clips so it starts on the vertex the solid leg ends\n * on. No sample moves; every vertex keeps the x its own age gives it.\n */\n const tail = returnLeg\n ? []\n : clipToOutgoing(\n clipToConfirmed(stream.inTransit, oneT),\n oneT * (1 + OUTGOING_TAIL),\n );\n const tailPts = tail.map((s) => ({\n x: xAt(s.age, span, padX),\n y: yAt(s.value),\n }));\n // A gradient with no extent paints one flat colour, so a zero-width tail is not drawn.\n const drawsTail =\n tailPts.length > 1 && tailPts[tailPts.length - 1].x > tailPts[0].x;\n\n // Low-alpha glow under the commanded line, fading downward.\n const areaPath = `${polyline(cmd)} L${cmd[cmd.length - 1].x.toFixed(2)},${(PAD_T + PLOT_H).toFixed(2)} L${cmd[0].x.toFixed(2)},${(PAD_T + PLOT_H).toFixed(2)} Z`;\n\n const confirmedEcho = returnLeg ? clipToConfirmed(stream.echo, twoT) : [];\n const echoPts = confirmedEcho.map((s) => ({\n x: xAt(s.age, span, padX),\n y: yAt(s.value),\n }));\n const expectedPts = confirmedEcho.map((s) => ({\n x: xAt(s.age, span, padX),\n y: yAt(commandedAt(stream.inTransit, s.age) ?? s.value),\n }));\n const runs = offCommandRuns(confirmedEcho, stream.inTransit, span);\n /*\n * The readings older than anything this screen commanded have no commanded\n * line above them to carry the glow, so they carry it themselves from where\n * the commanded shading ends.\n */\n const shadeFrom = outgoing[outgoing.length - 1].age;\n const shadeStart = commandedAt(confirmedEcho, shadeFrom);\n const shade = confirmedEcho.filter((s) => s.age > shadeFrom);\n const shadePts = (\n shadeStart === null || shade.length === 0\n ? shade\n : [{ age: shadeFrom, value: shadeStart }, ...shade]\n ).map((s) => ({ x: xAt(s.age, span, padX), y: yAt(s.value) }));\n const shadePath =\n shadePts.length > 1\n ? `${polyline(shadePts)} L${shadePts[shadePts.length - 1].x.toFixed(2)},${(PAD_T + PLOT_H).toFixed(2)} L${shadePts[0].x.toFixed(2)},${(PAD_T + PLOT_H).toFixed(2)} Z`\n : null;\n return (\n <g data-stream-group={stream.id} data-return-leg={returnLeg}>\n <defs>\n {/*\n Confidence ramp: muted left (least known) to clear right, kept faint\n so the rail reads as texture. In user space over the line's own run,\n because a flat line's box has no height and an objectBoundingBox ramp\n would not paint it.\n */}\n <linearGradient\n id={gradId}\n gradientUnits=\"userSpaceOnUse\"\n x1={cmd[0].x}\n y1=\"0\"\n x2={Math.max(cmd[cmd.length - 1].x, cmd[0].x + 1)}\n y2=\"0\"\n >\n <stop offset=\"0\" stopColor={colour} stopOpacity=\"0.10\" />\n <stop offset=\"1\" stopColor={colour} stopOpacity=\"0.40\" />\n </linearGradient>\n <linearGradient id={fillId} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n <stop offset=\"0\" stopColor={colour} stopOpacity=\"0.22\" />\n <stop offset=\"1\" stopColor={colour} stopOpacity=\"0\" />\n </linearGradient>\n {/*\n The tail's dissolve starts at the ramp's right-hand alpha. In user\n space, because a flat line's bounding box has no height and an\n objectBoundingBox ramp would not paint it.\n */}\n {drawsTail && (\n <linearGradient\n id={tailId}\n gradientUnits=\"userSpaceOnUse\"\n x1={tailPts[0].x}\n y1=\"0\"\n x2={tailPts[tailPts.length - 1].x}\n y2=\"0\"\n >\n <stop offset=\"0\" stopColor={colour} stopOpacity=\"0.40\" />\n <stop offset=\"1\" stopColor={colour} stopOpacity=\"0\" />\n </linearGradient>\n )}\n </defs>\n <path\n data-role=\"area\"\n d={areaPath}\n fill={`url(#${fillId})`}\n stroke=\"none\"\n />\n {shadePath && (\n <path\n data-role=\"echo-area\"\n d={shadePath}\n fill={`url(#${fillId})`}\n stroke=\"none\"\n />\n )}\n <path\n data-role=\"commanded\"\n data-stream={stream.id}\n d={polyline(cmd)}\n fill=\"none\"\n stroke={`url(#${gradId})`}\n strokeWidth=\"0.8\"\n strokeLinejoin=\"round\"\n strokeLinecap=\"round\"\n />\n {drawsTail && (\n <path\n data-role=\"commanded-tail\"\n data-stream={stream.id}\n d={polyline(tailPts)}\n fill=\"none\"\n stroke={`url(#${tailId})`}\n strokeWidth=\"0.8\"\n strokeLinejoin=\"round\"\n strokeLinecap=\"round\"\n />\n )}\n {runs.map((run) =>\n run.off ? (\n <Fragment key={run.from}>\n <path\n data-role=\"deviation-actual\"\n data-stream={stream.id}\n data-deviation=\"true\"\n d={polyline(echoPts.slice(run.from, run.to + 1))}\n fill=\"none\"\n stroke=\"var(--color-warn-mark)\"\n strokeWidth=\"1\"\n strokeLinecap=\"round\"\n />\n <path\n data-role=\"deviation-expected\"\n data-stream={stream.id}\n d={polyline(expectedPts.slice(run.from, run.to + 1))}\n fill=\"none\"\n stroke={colour}\n strokeWidth=\"0.8\"\n strokeDasharray=\"2 1.5\"\n />\n </Fragment>\n ) : (\n run.to > run.from && (\n <path\n key={run.from}\n data-role=\"echo\"\n data-stream={stream.id}\n d={polyline(echoPts.slice(run.from, run.to + 1))}\n fill=\"none\"\n stroke={colour}\n strokeWidth=\"0.8\"\n strokeLinecap=\"round\"\n />\n )\n ),\n )}\n </g>\n );\n}\n\n/**\n * The ribbon mark: one continuous entry's amplitude history, lying along one\n * zone of the strip. Each axis lands on one property:\n *\n * - Continuity puts it on this strip at all; a discrete datum draws nothing\n * - Direction places it and picks its tone: a command lies in the outgoing zone\n * in the accent tone, telemetry lies in the confirmed zone, past the second\n * divider, in the info tone\n * - Delivery decides only whether a return leg is drawn, which a ribbon has no\n * use for\n *\n * Drawn in the waveform's own 16-unit box and scaled into the plot band.\n */\nfunction RibbonMark({\n ribbon,\n padX,\n}: {\n ribbon: ControlRibbonDatum;\n padX: number;\n}) {\n // Per-instance, since `url(#id)` resolves to the first match in the document.\n const fadeId = `cds-ribbon-fade-${useId()}`;\n const tags = ribbon.tags;\n // The same renderer table `StreamPaths` asks.\n const renderer = railRendererFor(tags);\n if (renderer !== \"continuous-strip\") {\n return renderer === null ? (\n <UnrepresentedRailEntry tags={tags} who={ribbon.id} />\n ) : null;\n }\n\n const boundaryX = (VB_W - padX * 2) / 3;\n const wave = ribbon.wave;\n const samples = wave ?? ribbon.amplitudes;\n const span = ribbon.spanSamples ?? samples.length;\n // The wave itself when the producer kept it, else the loudness trace.\n const band = wave !== undefined ? waveformBand(wave, span, boundaryX) : \"\";\n const path =\n wave !== undefined\n ? band\n : waveformPath(ribbon.amplitudes, span, boundaryX);\n // A ribbon with nothing in it is not a crossing.\n if (path === \"\" && !(wave !== undefined && wave.length > 0)) return null;\n\n // The fade spans the trace's own length, at least a unit so the gradient has extent.\n const fadeX = Math.max(\n waveformExtentX(wave ?? ribbon.amplitudes, span, boundaryX),\n 1,\n );\n const tone = `var(${railToneToken(tags)})`;\n // What arrives lies past the second divider, where what has been confirmed is drawn.\n const outbound = railFlow(tags) === \"outbound\";\n const zoneStartX = outbound ? 0 : 2 * boundaryX;\n\n return (\n <g\n data-ribbon-group={ribbon.id}\n data-ribbon-zone={zoneStartX === 0 ? \"outgoing\" : \"confirmed\"}\n // The waveform's 16-unit box mapped onto the plot band.\n transform={`translate(${padX + zoneStartX} ${PAD_T}) scale(1 ${PLOT_H / WAVE_VB_H})`}\n >\n <defs>\n {/* The fade runs the way the entry does, in user space so a flat passage still paints. */}\n <linearGradient\n id={fadeId}\n gradientUnits=\"userSpaceOnUse\"\n x1={outbound ? 0 : fadeX}\n y1=\"0\"\n x2={outbound ? fadeX : 0}\n y2=\"0\"\n >\n {/* Nearer full strength than a filled ribbon would carry: a hairline\n trace at 0.55 is most of the way to invisible where a broad fill at\n the same value still read. */}\n <stop offset=\"0\" stopColor={tone} stopOpacity=\"0.9\" />\n <stop offset=\"1\" stopColor={tone} stopOpacity=\"0.1\" />\n </linearGradient>\n </defs>\n {/* Stroked in SCREEN units: the box is stretched to the widget's width\n AND scaled vertically into the band, so a scaled stroke would come out\n several times thicker across than it is tall and the near-vertical\n parts of the trace would fatten into a blob. */}\n {wave !== undefined ? (\n <>\n {/* Silence is a line along the centre, and the wave stands on it. */}\n <line\n data-role=\"ribbon-axis\"\n x1=\"0\"\n x2={fadeX}\n y1={WAVE_MID_Y}\n y2={WAVE_MID_Y}\n stroke={`url(#${fadeId})`}\n strokeWidth=\"1\"\n vectorEffect=\"non-scaling-stroke\"\n />\n {band !== \"\" && (\n <path\n data-role=\"ribbon\"\n data-ribbon={ribbon.id}\n d={band}\n fill={`url(#${fadeId})`}\n stroke=\"none\"\n />\n )}\n </>\n ) : (\n <path\n data-role=\"ribbon\"\n data-ribbon={ribbon.id}\n d={path}\n fill=\"none\"\n stroke={`url(#${fadeId})`}\n strokeWidth=\"1\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n vectorEffect=\"non-scaling-stroke\"\n />\n )}\n </g>\n );\n}\n\n/**\n * A three-zone sparkline for all of a widget's control axes, the continuous\n * sibling of {@link InFlightList}. Now is on the left and age to the right; the\n * outgoing, echo and confirmed zones are split by dividers at T and 2T; a\n * muted-to-clear confidence ramp; deviation in the confirmed zone is drawn as\n * the expected path dashed plus the actual path in the warning token; zone and\n * delay labels show on hover. Useful for showing the operator that a held\n * control, such as a throttle or a voice transmission, takes effect after the\n * one-way delay, and whether the vessel answered as expected. Used by the radio\n * push-to-talk control. Renders `null` when the one-way delay is zero or\n * unknown, and draws no command streams under {@link STREAM_MIN_DELAY_SECONDS};\n * a ribbon draws at any positive delay. It reads nothing itself: everything\n * comes in through props.\n *\n * A continuous entry with no readback (the operator's voice) is drawn as a\n * ribbon in the outgoing zone of the same graph. Delivery only decides whether\n * anything is drawn past the first boundary; it never moves a boundary or picks\n * a different picture.\n *\n * @category CommandDelay\n */\nexport function ControlDelayStream({\n streams,\n ribbons = [],\n \"aria-label\": ariaLabel = \"Controls in flight\",\n variant = \"inline\",\n delayReading,\n}: ControlDelayStreamProps) {\n // Every entry crosses the same gap, so the first one that knows its light-time serves the strip.\n const first = [...streams, ...ribbons].find((e) => e.oneWaySeconds !== null);\n const oneWay = first?.oneWaySeconds ?? null;\n if (!first || !hasRealDelay(oneWay)) return null;\n return (\n <DelayBand\n oneWay={oneWay}\n streams={streams}\n ribbons={ribbons}\n ariaLabel={ariaLabel}\n variant={variant}\n delayReading={delayReading}\n />\n );\n}\n\n/**\n * The graph the strip is drawn on: its T and 2T marks and, opened, the zone\n * labels under it. With no streams or ribbons it is the empty graph, which is\n * what the opened rail draws over a command press.\n */\nexport function DelayBand({\n oneWay,\n streams = [],\n ribbons = [],\n ariaLabel = \"Controls in flight\",\n variant,\n delayReading,\n}: {\n oneWay: number;\n streams?: ControlDelayStreamProps[\"streams\"];\n ribbons?: NonNullable<ControlDelayStreamProps[\"ribbons\"]>;\n ariaLabel?: string;\n variant: ControlDelayStreamVariant;\n delayReading?: ControlDelayStreamProps[\"delayReading\"];\n}) {\n // Before the early return, so the hook runs unconditionally.\n const dividerFadeId = `cds-divfade-${useId()}`;\n const delayHeld = delayReading?.state === \"held\";\n const delayCaption = delayHeld\n ? resolveCurrency(delayReading ?? null).caption\n : null;\n const { anchor, tip } = useTooltip(delayCaption);\n const drawStreams = oneWay >= STREAM_MIN_DELAY_SECONDS;\n if (!drawStreams && ribbons.length === 0) return null;\n\n const span = 3 * oneWay;\n // Computed once and shared by the dividers and the line clips, so a line changes appearance only on a divider.\n const oneT = oneWay;\n const twoT = 2 * oneWay;\n const padX = padXFor(variant);\n const divX1 = xAt(oneT, span, padX);\n const divX2 = xAt(twoT, span, padX);\n /*\n * Nothing commanded yet: the zone labels show without hover, so an empty\n * strip does not read as missing data. The box itself never hides, so the\n * surface does not move under the operator's hands.\n */\n const quiet =\n streams.every((s) => s.inTransit.length === 0 && s.echo.length === 0) &&\n ribbons.every((r) => r.amplitudes.length === 0);\n\n return (\n <ControlDelayStream__Root\n data-oneway={oneWay}\n data-variant={variant}\n $variant={variant}\n {...anchor}\n >\n <ControlDelayStream__Svg\n $variant={variant}\n $quiet={quiet}\n role=\"img\"\n aria-label={sayHeld(ariaLabel, delayCaption)}\n {...heldNameMarker(delayCaption)}\n viewBox={`0 0 ${VB_W} ${VB_H}`}\n preserveAspectRatio=\"none\"\n >\n <defs>\n {/* The dividers fade downward, matching the under-line shading. */}\n <linearGradient\n id={dividerFadeId}\n gradientUnits=\"userSpaceOnUse\"\n x1=\"0\"\n y1={PAD_T}\n x2=\"0\"\n y2={PAD_T + PLOT_H}\n >\n <stop\n offset=\"0\"\n stopColor=\"var(--color-border-subtle)\"\n stopOpacity=\"0.9\"\n />\n <stop\n offset=\"1\"\n stopColor=\"var(--color-border-subtle)\"\n stopOpacity=\"0\"\n />\n </linearGradient>\n </defs>\n {(drawStreams ? streams : []).map((s, i) => (\n <StreamPaths\n key={s.id}\n stream={s}\n span={span}\n index={i}\n padX={padX}\n oneT={oneT}\n twoT={twoT}\n />\n ))}\n {ribbons.map((r) => (\n <RibbonMark key={r.id} ribbon={r} padX={padX} />\n ))}\n <line\n data-divider=\"t\"\n x1={divX1}\n x2={divX1}\n y1={PAD_T}\n y2={PAD_T + PLOT_H}\n stroke={`url(#${dividerFadeId})`}\n strokeWidth=\"0.4\"\n />\n <line\n data-divider=\"2t\"\n x1={divX2}\n x2={divX2}\n y1={PAD_T}\n y2={PAD_T + PLOT_H}\n stroke={`url(#${dividerFadeId})`}\n strokeWidth=\"0.4\"\n />\n {/* Hover-only labels, inline variant only; the svg's own aria-label carries the accessible name. */}\n {variant === \"inline\" && (\n <g data-role=\"hover-labels\">\n <text x={divX1} y={PAD_T - 0.4} textAnchor=\"middle\" fontSize=\"2\">\n {writeQuantity(value(\"s\", oneWay), { decimals: 1 })}\n {delayHeld && <InstrumentHeldMark size={1.2} />}\n </text>\n <text x={divX2} y={PAD_T - 0.4} textAnchor=\"middle\" fontSize=\"2\">\n {writeQuantity(value(\"s\", 2 * oneWay), { decimals: 1 })}\n {delayHeld && <InstrumentHeldMark size={1.2} />}\n </text>\n <text\n x={xAt(oneWay / 2, span, padX)}\n y={VB_H - 0.6}\n textAnchor=\"middle\"\n fontSize=\"2\"\n >\n outgoing\n </text>\n <text\n x={xAt(1.5 * oneWay, span, padX)}\n y={VB_H - 0.6}\n textAnchor=\"middle\"\n fontSize=\"2\"\n >\n echo\n </text>\n <text\n x={xAt(2.5 * oneWay, span, padX)}\n y={VB_H - 0.6}\n textAnchor=\"middle\"\n fontSize=\"2\"\n >\n confirmed\n </text>\n </g>\n )}\n </ControlDelayStream__Svg>\n {variant === \"expanded\" && (\n <>\n {/* HTML zone labels under the graph, with the T and 2T boundary times. */}\n <ControlDelayStream__Zones aria-hidden=\"true\">\n <span>\n outgoing <b>0</b>\n </span>\n <span>\n echo{\" \"}\n <b>\n <Unit\n value={withDelayCurrency(value(\"s\", oneWay), delayReading)}\n decimals={1}\n />\n </b>\n </span>\n <span>\n confirmed{\" \"}\n <b>\n <Unit\n value={withDelayCurrency(\n value(\"s\", 2 * oneWay),\n delayReading,\n )}\n decimals={1}\n />\n </b>\n </span>\n </ControlDelayStream__Zones>\n <ControlDelayStream__Legend aria-hidden=\"true\">\n {(drawStreams ? streams : []).map((s, i) => (\n <span key={s.id}>\n <i\n style={{\n background: `var(${STREAM_TOKENS[i % STREAM_TOKENS.length]})`,\n }}\n />\n {s.label}\n </span>\n ))}\n {ribbons.map((r) => (\n <span key={r.id} data-role=\"legend-ribbon\">\n <i\n style={{\n background: `var(${railToneToken(r.tags)})`,\n }}\n />\n {r.label}\n </span>\n ))}\n {/* Ribbons have no commanded path to deviate from. */}\n {drawStreams && streams.length > 0 && (\n <span data-role=\"legend-deviation\">\n <i style={{ background: \"var(--color-warn-mark)\" }} />\n off-command\n </span>\n )}\n </ControlDelayStream__Legend>\n </>\n )}\n {tip}\n </ControlDelayStream__Root>\n );\n}\n\nconst ControlDelayStream__Root = styled.div<{\n $variant: \"inline\" | \"rail\" | \"expanded\";\n}>`\n flex: 0 0 auto;\n width: 100%;\n ${({ $variant }) =>\n $variant === \"expanded\" &&\n \"display: flex; flex-direction: column; gap: var(--gap-delay-stream);\"}\n`;\n\nconst ControlDelayStream__Svg = styled.svg<{\n $variant: \"inline\" | \"rail\" | \"expanded\";\n $quiet?: boolean;\n}>`\n display: block;\n width: 100%;\n /* The rail height is the band the Panel reserves, not a size the graph chose. */\n height: ${({ $variant }) =>\n $variant === \"rail\"\n ? \"var(--panel-rail-band)\"\n : $variant === \"expanded\"\n ? \"86px\"\n : \"40px\"};\n\n /* Strokes are scaled by 30/16 against the stretched 30-unit viewBox, so the trace is a real pixel wide in the band. */\n ${({ $variant }) =>\n $variant === \"rail\"\n ? `[data-role=\"commanded\"],\n [data-role=\"echo\"],\n [data-role=\"deviation-expected\"] { stroke-width: 1.5; }\n [data-role=\"deviation-actual\"] { stroke-width: 1.88; }`\n : \"\"}\n\n\n /* The closed strip is too thin to carry the marks; they stay in the drawing so the lines still change appearance at them. */\n ${({ $variant }) =>\n $variant === \"rail\" ? `[data-divider] { display: none; }` : \"\"}\n\n [data-role=\"hover-labels\"] {\n opacity: ${({ $quiet }) => ($quiet ? 1 : 0)};\n fill: var(--color-text-muted);\n font-family: var(--font-family-mono);\n }\n &:hover [data-role=\"hover-labels\"] {\n opacity: 1;\n }\n`;\n\nconst ControlDelayStream__Zones = styled.div`\n display: flex;\n justify-content: space-between;\n /* The graph stays full-bleed; the zone labels inset to the standard content margin. */\n margin: 0 var(--gutter-panel);\n font-size: var(--font-size-caption);\n color: var(--color-text-muted);\n letter-spacing: 0.06em;\n\n b {\n color: var(--color-text-dim);\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n }\n`;\n\nconst ControlDelayStream__Legend = styled.div`\n display: flex;\n flex-wrap: wrap;\n gap: var(--gap-legend);\n /* The legend sits at the standard content margin, with bottom room since the pinned rail has no padding. */\n margin: var(--outset-delay-legend);\n font-size: var(--font-size-caption);\n color: var(--color-text-muted);\n letter-spacing: 0.06em;\n\n span {\n display: inline-flex;\n align-items: center;\n gap: var(--gap-glyph);\n }\n i {\n display: inline-block;\n width: 10px;\n height: 2px;\n }\n`;\n","import type { Reading, Value } from \"@ksp-gonogo/sitrep-sdk\";\nimport type { UnitValue } from \"../readingCurrency\";\n\n/**\n * A figure worked out from the one-way delay (the delay itself, twice it),\n * carrying the delay reading's currency, so a `comms.delay` that has gone\n * quiet draws every figure derived from it held. Useful for showing the\n * operator a delay figure that is marked held while the delay reading is. Used\n * by {@link ControlDelayStream} and {@link SignalDelayBadge}.\n */\nexport function withDelayCurrency(\n figure: Value<\"s\">,\n delay: Reading<Value<\"s\">> | null | undefined,\n): UnitValue<\"s\"> {\n if (delay?.state !== \"held\") return figure;\n return { ...delay, value: figure };\n}\n","import type { Reading, Value } from \"@ksp-gonogo/sitrep-sdk\";\nimport {\n ControlDelayStream,\n type ControlRibbonDatum,\n type ControlStreamDatum,\n hasRealDelay,\n} from \"./ControlDelayStream\";\nimport type { CommandFailedEntry } from \"./commandFailedSentence\";\nimport type { CommandFoundEntry } from \"./commandFoundSentence\";\nimport type { CommandLossEntry } from \"./commandLossSentence\";\nimport type { CommandRefusalEntry } from \"./commandRefusalSentence\";\nimport type { CommandUndeliveredEntry } from \"./commandUndeliveredSentence\";\nimport type { CommandWarningEntry } from \"./commandWarningSentence\";\nimport {\n InFlightList,\n type InFlightListDensity,\n type InFlightListMode,\n} from \"./InFlightList\";\nimport {\n type RailTags,\n railRendererFor,\n railTagKey,\n reportUnrepresentedRail,\n} from \"./railTags\";\nimport {\n type InFlightCommandLike,\n toInFlightListItems,\n} from \"./toInFlightListItems\";\n\n/**\n * What {@link CommandDelay} and the Panel delay rail (the strip at the top of a\n * panel showing commands still crossing to the craft) read from a command: its\n * in-flight rows, its delay, and what became of its dispatches. Declared\n * structurally; {@link useCommand}'s return value satisfies it.\n * Useful for drawing the delay display for a command without depending on how\n * the command is sent.\n *\n * @category CommandDelay\n */\nexport interface CommandDelayHandle {\n /**\n * Discrete in-flight rows. Empty for a pure stream handle, and always empty\n * once `effectiveDelaySeconds` is 0 (nothing is ever in flight instantly).\n */\n inFlight: InFlightCommandLike[];\n /**\n * What this entry is on the delay rail's three axes, in full. `direction`\n * is `command` for something leaving the command centre or `telemetry` for\n * something arriving from the vessel. `kind` is `event` or `discrete` for one\n * point in time, or `continuous` for a span. `delivery` is `acked` when the\n * vessel confirms receipt, `answered` when it replies with a result, or\n * `fire-and-forget` when nothing comes back. The delay rail is the strip a\n * panel draws above its header to show what is crossing the signal delay. The renderer follows\n * from these, so no consumer branches on what kind of command this is. A\n * command handle gets them from {@link useCommand}; a producer that is not a\n * command (an open microphone) states them with {@link railTagsForTelemetry}.\n */\n tags: RailTags;\n /**\n * The command's effective one-way delay under its selected vantage. `0`\n * means nothing to visualise, so `<CommandDelay>` draws null (an instant\n * command still mounts it). `null` means the delay is unknown, which also\n * draws nothing but is not a claim of instant arrival.\n */\n effectiveDelaySeconds: number | null;\n /**\n * The one-way delay as the reading it arrived in (`useCommand`'s\n * `delayReading`), so the delay figures the rail draws are held while\n * `comms.delay` is quiet. Omitted, they draw as current.\n */\n delayReading?: Reading<Value<\"s\">> | null;\n /**\n * Stream buffers for a continuous handle (the in-transit + confirmed-echo\n * samples `ControlDelayStream` draws). Ignored by the discrete queue.\n */\n streams?: ControlStreamDatum[];\n /**\n * Ribbon buffers: a continuous entry with amplitude history and no readback,\n * drawn in the rail's outgoing zone. Carried alongside `streams`, so a widget\n * with both a control axis and an open microphone gets one graph.\n */\n ribbons?: ControlRibbonDatum[];\n /**\n * What the rail should call this handle's graph, when \"Delay detail\" is not\n * what it is. A voice ribbon names the transmission it is drawing; a control\n * axis is happy with the default.\n */\n \"aria-label\"?: string;\n /**\n * Dispatches from this command the game refused, until dismissed. Rendered by\n * the Panel rail under both queues, never by `<CommandDelay>`: a refusal is\n * terminal and has nothing to do with delay.\n */\n refusals?: CommandRefusalEntry[];\n /**\n * Dispatches from this command that got \"NO ANSWER\", until dismissed. Rendered\n * by the Panel rail, since a loss can have no in-flight entry at all. Apart\n * from `refusals` because a loss carries no verdict: the command may have\n * executed.\n */\n losses?: CommandLossEntry[];\n /**\n * Dispatches from this command that were called lost and then replied after\n * all, until dismissed. An entry here has left `losses`: the same dispatch at\n * a later moment, never two boxes at once.\n */\n founds?: CommandFoundEntry[];\n /**\n * Dispatches from this command that never left this machine, until dismissed:\n * the command did not run. An entry here has left `losses`, as with `founds`.\n */\n undelivered?: CommandUndeliveredEntry[];\n /**\n * Dispatches from this command the mod answered with a fault in place of a\n * reply, until dismissed: it expired or was cancelled on its way, or a game\n * load undid it. Each carries the fault's code, which says which.\n */\n failures?: CommandFailedEntry[];\n /**\n * Dispatches from this command the mod accepted with a warning, while they\n * are on their way, such as a continuous input it will drop where it would\n * have to wait.\n */\n warnings?: CommandWarningEntry[];\n /**\n * Clear a dead command (`overdue`/`lost`) from this handle's shared delay\n * queue, both in the widget-top queue and on the issuing control. When\n * present, the expanded queue's failed squares become clear buttons.\n */\n dismiss?: (id: string) => void;\n}\n\n/**\n * Props for {@link CommandDelay}. Pass `handle` or `handles`.\n * Useful for choosing which commands the delay display shows, one handle or\n * several. Used by {@link CommandDelay}.\n *\n * @category CommandDelay\n */\nexport interface CommandDelayProps {\n /** A single command handle. Sugar for `handles={[handle]}`. */\n handle?: CommandDelayHandle;\n /**\n * Several command handles drawn as one merged list, for a widget whose\n * controls send more than one command (e.g. a maneuver planner's\n * add/update/remove). Their discrete in-flight rows are concatenated into a\n * single `InFlightList`.\n */\n handles?: CommandDelayHandle[];\n /**\n * Accessible label for the rendered region. Left undefined, each branch\n * keeps its own default (\"In-flight commands\" / \"Controls in flight\").\n */\n \"aria-label\"?: string;\n /** Discrete-branch passthrough to `InFlightList`. Ignored for stream. */\n mode?: InFlightListMode;\n /** Discrete-branch passthrough to `InFlightList`. Ignored for stream. */\n density?: InFlightListDensity;\n /** Discrete-branch passthrough to `InFlightList`. Ignored for stream. */\n orientation?: \"column\" | \"row\";\n /**\n * `\"inline\"` (default) is the in-body rendering. `\"rail\"` (collapsed strip)\n * and `\"expanded\"` (grown detail) are what the Panel-owned rail passes,\n * forwarded to whichever child branch renders.\n */\n variant?: \"inline\" | \"rail\" | \"expanded\";\n}\n\n/**\n * What each delayed command is doing between the command centre and its vessel\n * or device. It draws nothing at zero or unknown delay, the continuous\n * {@link ControlDelayStream} for a single stream command, or the discrete\n * {@link InFlightList} (merged across handles) otherwise, so a widget gets the\n * right delay display with no branching of its own. Useful for showing the\n * operator that a command has been sent and has not yet arrived. Used by the\n * panel delay rail, and by a widget that draws the same display in its body.\n *\n * On the dashboard every `useCommand` handle already reaches its `Panel`'s\n * delay rail; render this for the same display inside the widget body.\n *\n * @example\n * ```tsx\n * const setTarget = useCommand(\"vessel.target.set\");\n * const clearTarget = useCommand(\"vessel.target.clear\");\n *\n * <CommandDelay handles={[setTarget, clearTarget]} orientation=\"row\" />\n * ```\n *\n * @category CommandDelay\n * @categoryDescription CommandDelay\n * A command on its way to the vessel, drawn inside a widget body: the list of commands\n * in flight, the continuous stream for a held control, command groups, and the\n * sentence for a command that failed. The panel's delay rail already shows the\n * same commands above the widget.\n */\nexport function CommandDelay({\n handle,\n handles,\n \"aria-label\": ariaLabel,\n mode,\n density,\n orientation,\n variant = \"inline\",\n}: Readonly<CommandDelayProps>) {\n const all = handles ?? (handle ? [handle] : []);\n\n /*\n * Which child draws a lone handle comes from the renderer table. Both\n * continuous forms land on the ONE graph. Never branch on delivery here:\n * whether a return leg is drawn is a decision inside the graph.\n */\n const lone = all.length === 1 ? all[0] : null;\n const loneRenderer = lone ? railRendererFor(lone.tags) : null;\n if (lone && loneRenderer === null) {\n return (\n <UnrepresentedRailHandle tags={lone.tags} who={lone[\"aria-label\"]} />\n );\n }\n if (lone && loneRenderer !== \"in-flight-row\") {\n const streamHandle = lone;\n // An unknown delay draws nothing, as an instant one does.\n const delay = streamHandle.effectiveDelaySeconds;\n if (!hasRealDelay(delay)) return null;\n return (\n <ControlDelayStream\n streams={streamHandle.streams ?? []}\n ribbons={streamHandle.ribbons ?? []}\n delayReading={streamHandle.delayReading}\n aria-label={ariaLabel ?? streamHandle[\"aria-label\"]}\n variant={variant}\n />\n );\n }\n\n /*\n * Discrete: merge every handle's in-flight rows. Not gated on\n * `effectiveDelaySeconds`, which a widget may not carry; an instant command\n * simply has no `inFlight` rows and `InFlightList` self-blanks.\n */\n const items = toInFlightListItems(all.flatMap((h) => h.inFlight));\n // A dismiss routes to the handle that owns the command.\n const canDismiss = all.some((h) => h.dismiss);\n const onDismiss = canDismiss\n ? (id: string) =>\n all.find((h) => h.inFlight.some((c) => c.id === id))?.dismiss?.(id)\n : undefined;\n return (\n <InFlightList\n items={items}\n aria-label={ariaLabel}\n mode={mode}\n density={density}\n orientation={orientation}\n variant={variant}\n onDismiss={onDismiss}\n />\n );\n}\n\n/**\n * A handle whose declared combination nothing draws, reported and left as a\n * `hidden` marker (`data-rail-unrepresented`) a probe can find. Never a\n * fallback to the discrete list, which would look right and be wrong.\n */\nfunction UnrepresentedRailHandle({\n tags,\n who,\n}: {\n tags: RailTags;\n who?: string;\n}) {\n const named = who ?? \"unnamed handle\";\n reportUnrepresentedRail(tags, named);\n return <span hidden data-rail-unrepresented={railTagKey(tags)} />;\n}\n","import {\n commandRefusalSubject,\n describeErrorCode,\n} from \"@ksp-gonogo/sitrep-sdk\";\nimport type { CommandLossLike } from \"./commandLossSentence\";\nimport type { RailTags } from \"./railTags\";\n\n/**\n * One dispatch that failed with an error rather than an answer: the fields of\n * {@link CommandLossLike}, plus the fault it was answered with. Taken by\n * {@link commandFailedSentence}.\n * Useful for writing the sentence that tells the operator a command was\n * answered with a fault.\n *\n * @category CommandDelay\n */\nexport interface CommandFailedLike extends CommandLossLike {\n /** The fault the dispatch was answered with, a `FaultCode` id, when one came back. */\n code?: string;\n}\n\n/**\n * A failed dispatch a surface can render: the text's inputs plus the dispatch's\n * `requestId`, which keys the box and is what `dismiss` takes. Used by the\n * panel delay rail and {@link CommandList}.\n *\n * @category CommandDelay\n */\nexport interface CommandFailedEntry extends CommandFailedLike {\n /** The dispatch's `requestId`, which keys the box and is what `dismiss` takes. */\n id: string;\n}\n\n/**\n * One failed dispatch as the rail renders it, plus its command's rail axes.\n * Taken by {@link CommandList}.\n * Useful for telling the operator, on the panel's delay rail, which commands\n * failed and why.\n *\n * @category CommandDelay\n */\nexport interface RailFailed extends CommandFailedEntry {\n /** The command's rail axes. */\n tags: RailTags;\n}\n\n/**\n * What the operator is told about a command that came back with a fault in\n * place of an answer. A fault the code table declares is said in its own\n * sentence, since the mod has said what became of the command: it expired, was\n * cancelled, or a game load undid it. Anything else, the machinery breaking\n * or the client going away while it waited, gets no verdict. Never \"refused\",\n * which is the game's verdict, and it does not quote the error's own message.\n * Useful for telling the operator what became of a command that got a fault\n * instead of an answer. Used by {@link CommandList}, the panel delay rail and\n * the maneuver planner.\n *\n * @category CommandDelay\n */\nexport function commandFailedSentence(failed: CommandFailedLike): string {\n const subject = commandRefusalSubject(failed);\n const what = subject || failed.command || \"The command\";\n const said =\n failed.code === undefined ? undefined : describeErrorCode(failed.code);\n return said?.kind === \"fault\"\n ? `${what}: failed, ${said.sentence}.`\n : `${what}: failed, with no verdict from the game.`;\n}\n","import { commandRefusalSubject } from \"@ksp-gonogo/sitrep-sdk\";\nimport type {\n CommandLossEntry,\n CommandLossLike,\n RailLoss,\n} from \"./commandLossSentence\";\n\n/**\n * One dispatch that never left this machine. It has the same fields as\n * {@link CommandLossLike}. Taken by {@link commandUndeliveredSentence}.\n * Useful for writing the sentence that tells the operator a command never left\n * this machine.\n *\n * @category CommandDelay\n */\nexport type CommandUndeliveredLike = CommandLossLike;\n\n/**\n * An undelivered dispatch a surface can render: the text's inputs plus the\n * dispatch's `requestId`, which keys the box and is what `dismiss` takes. Used\n * by the panel delay rail and {@link CommandList}.\n *\n * @category CommandDelay\n */\nexport type CommandUndeliveredEntry = CommandLossEntry;\n\n/**\n * One undelivered dispatch as the rail renders it, plus its command's rail\n * axes. Taken by {@link CommandList}.\n * Useful for telling the operator, on the panel's delay rail, which commands\n * never left this machine.\n *\n * @category CommandDelay\n */\nexport type RailUndelivered = RailLoss;\n\n/**\n * What the operator is told about a command that never went out: it did not\n * run, so it is safe to re-send. It never says \"lost\", which means the\n * opposite (\"may have run\"), and does not quote the connection's own error.\n * Useful for telling the operator a command never reached the vessel and can be\n * sent again. Used by {@link CommandList}, the panel delay rail and the\n * maneuver planner.\n *\n * @category CommandDelay\n */\nexport function commandUndeliveredSentence(\n undelivered: CommandUndeliveredLike,\n): string {\n const subject = commandRefusalSubject(undelivered);\n const what = subject || undelivered.command || \"The command\";\n return `${what}: never sent. Safe to re-send.`;\n}\n","import { commandRefusalSubject } from \"@ksp-gonogo/sitrep-sdk\";\nimport type { CommandLossLike } from \"./commandLossSentence\";\nimport type { RailTags } from \"./railTags\";\n\n/**\n * One dispatch the mod accepted with a warning, still on its way: the fields of\n * {@link CommandLossLike}, plus what the mod said. Taken by\n * {@link commandWarningSentence}.\n * Useful for writing the sentence that tells the operator a command in flight\n * is likely to be lost.\n *\n * @category CommandDelay\n */\nexport interface CommandWarningLike extends CommandLossLike {\n /** What the mod said of the command, as a sentence. */\n warning: string;\n}\n\n/**\n * A warned dispatch a surface can render: the text's inputs plus the\n * dispatch's `requestId`, which keys the box. Used by the panel delay rail and\n * {@link CommandList}.\n *\n * @category CommandDelay\n */\nexport interface CommandWarningEntry extends CommandWarningLike {\n /** The dispatch's `requestId`, which keys the box. */\n id: string;\n}\n\n/**\n * One warned dispatch as the rail renders it, plus its command's rail axes.\n * Taken by {@link CommandList}.\n * Useful for telling the operator, on the panel's delay rail, which commands in\n * flight the mod warned about and what it said.\n *\n * @category CommandDelay\n */\nexport interface RailWarning extends CommandWarningEntry {\n /** The command's rail axes. */\n tags: RailTags;\n}\n\n/**\n * What the operator is told about a command the mod accepted with a warning:\n * the command, then the mod's own sentence. Useful for showing the operator\n * that a command still on its way, such as a throttle input, is likely to be\n * dropped. Used by {@link CommandList} and the panel delay rail.\n *\n * @category CommandDelay\n */\nexport function commandWarningSentence(warned: CommandWarningLike): string {\n const subject = commandRefusalSubject(warned);\n const what = subject || warned.command || \"The command\";\n return `${what}: ${warned.warning}`;\n}\n","import { commandRefusalSubject, type Tone } from \"@ksp-gonogo/sitrep-sdk\";\nimport styled, { css } from \"styled-components\";\nimport { IconButton } from \"../Button\";\nimport { focusRing } from \"../focusRing\";\nimport { LiveRegion } from \"../LiveRegion\";\nimport { TONE_MARK, TONE_TEXT } from \"../tone\";\nimport {\n commandFailedSentence,\n type RailFailed,\n} from \"./commandFailedSentence\";\nimport { commandFoundSentence, type RailFound } from \"./commandFoundSentence\";\nimport { commandLossSentence, type RailLoss } from \"./commandLossSentence\";\nimport {\n commandRefusalSentence,\n type RailRefusal,\n} from \"./commandRefusalSentence\";\nimport {\n commandUndeliveredSentence,\n type RailUndelivered,\n} from \"./commandUndeliveredSentence\";\nimport {\n commandWarningSentence,\n type RailWarning,\n} from \"./commandWarningSentence\";\nimport { focusBesideDismissed } from \"./focusBesideDismissed\";\nimport { railMark } from \"./railTags\";\nimport { deriveGlyph } from \"./toInFlightListItems\";\n\n/**\n * What became of the dispatches a {@link CommandList} draws:\n *\n * - `refused`: the game said no, and why\n * - `lost`: no reply came, so the command may have run\n * - `undelivered`: it never left this machine, so a re-send repeats nothing\n * - `found`: a lost dispatch replied after all\n * - `failed`: the machinery broke, so there is no verdict either way\n * - `warned`: still on its way, and the mod said it is likely to be lost\n *\n * Useful for telling the operator which kind of outcome a box reports. Used by\n * {@link CommandList} to choose a box's tone and wording.\n *\n * @category CommandDelay\n */\nexport type CommandListKind =\n | \"refused\"\n | \"lost\"\n | \"undelivered\"\n | \"found\"\n | \"failed\"\n | \"warned\";\n\ninterface CommandListCommonProps {\n /** Clear one entry by its `id`. Omit it and the boxes carry no clear control rather than an inert one. */\n onDismiss?: (id: string) => void;\n /**\n * Announce each entry as it arrives (the default), as a polite live region\n * that stays mounted while empty. Off only where something else already\n * announces these outcomes, as the delay rail does; the list is then a plain\n * `role=\"list\"` that draws nothing when empty.\n */\n live?: boolean;\n /** Names the list for assistive tech. Each kind has its own default. */\n \"aria-label\"?: string;\n}\n\n/**\n * Props for {@link CommandList}: the entries it draws, keyed by what became of\n * them. Each entry carries its dispatch's `requestId` as `id` and its command's rail axes as\n * `tags`; only the axes' mark is read, so a discrete command gets its\n * in-flight glyph tile and a continuous one its name in words.\n * Useful for choosing which kind of outcome the operator reads about and the\n * dispatches it covers. Used by {@link CommandList}.\n *\n * @category CommandDelay\n */\nexport type CommandListProps = CommandListCommonProps &\n (\n | {\n /** The commands that were refused. */\n kind: \"refused\";\n /** The refused commands, one box each. */\n entries: readonly RailRefusal[];\n }\n | {\n /** The commands that were lost with no answer. */\n kind: \"lost\";\n /** The lost commands, one box each. */\n entries: readonly RailLoss[];\n }\n | {\n /** The commands that never left. */\n kind: \"undelivered\";\n /** The undelivered commands, one box each. */\n entries: readonly RailUndelivered[];\n }\n | {\n /** The lost commands that answered after all. */\n kind: \"found\";\n /** The found commands, one box each. */\n entries: readonly RailFound[];\n }\n | {\n /** The commands that came back with a fault. */\n kind: \"failed\";\n /** The failed commands, one box each. */\n entries: readonly RailFailed[];\n }\n | {\n /** The commands in flight the mod warned about. */\n kind: \"warned\";\n /** The warned commands, one box each. */\n entries: readonly RailWarning[];\n }\n );\n\n/** One box as drawn: the kind's sentence and gesture already composed. */\ninterface CommandListBox {\n id: string;\n subject: string;\n sentence: string;\n dismissLabel: string;\n tags: RailRefusal[\"tags\"];\n}\n\nconst DEFAULT_LABEL: Record<CommandListKind, string> = {\n refused: \"Refused commands\",\n lost: \"Commands with no reply\",\n undelivered: \"Commands that were never sent\",\n found: \"Unconfirmed commands that answered\",\n failed: \"Commands that failed\",\n warned: \"Commands likely to be lost\",\n};\n\n/** What the clear control names when a dispatch has no subject to name. */\nconst FALLBACK_DISMISS: Record<CommandListKind, string> = {\n refused: \"refusal\",\n lost: \"unconfirmed command\",\n undelivered: \"unsent command\",\n found: \"found command\",\n failed: \"failed command\",\n warned: \"warned command\",\n};\n\nfunction sentenceOf(props: CommandListProps, index: number): string {\n if (props.kind === \"refused\")\n return commandRefusalSentence(props.entries[index]);\n if (props.kind === \"found\") return commandFoundSentence(props.entries[index]);\n if (props.kind === \"failed\") {\n return commandFailedSentence(props.entries[index]);\n }\n if (props.kind === \"warned\") {\n return commandWarningSentence(props.entries[index]);\n }\n if (props.kind === \"undelivered\") {\n return commandUndeliveredSentence(props.entries[index]);\n }\n return commandLossSentence(props.entries[index]);\n}\n\nfunction boxesOf(props: CommandListProps): CommandListBox[] {\n return props.entries.map((entry, index) => {\n const subject = commandRefusalSubject(entry);\n return {\n id: entry.id,\n subject: subject || entry.command || \"\",\n sentence: sentenceOf(props, index),\n dismissLabel: `Dismiss ${subject || FALLBACK_DISMISS[props.kind]}`,\n tags: entry.tags,\n };\n });\n}\n\n/**\n * Outcome boxes for dispatches of one {@link CommandListKind}: one box per\n * dispatch, with the command's identity and the whole sentence of what became\n * of it. Useful for telling the operator which commands were refused, lost,\n * found again or failed, and why, and which still on their way the mod warned\n * about. Used by the panel delay rail, under its\n * queues, and by the maneuver planner's armed triggers list. The sentence wraps\n * and is never truncated, since names are unbounded and the numbers sit at the\n * end. A `found` is drawn in the notice tone, every other kind in the warning\n * tone.\n *\n * The sentences are {@link commandRefusalSentence},\n * {@link commandLossSentence}, {@link commandUndeliveredSentence},\n * {@link commandFoundSentence}, {@link commandFailedSentence} and\n * {@link commandWarningSentence}, so a surface\n * that states the same outcome elsewhere can say it in the same words.\n *\n * @example\n * ```tsx\n * <CommandList\n * kind=\"lost\"\n * live={false}\n * entries={losses.map((loss) => ({\n * ...loss,\n * tags: railTagsForCommand(loss.command ?? \"\"),\n * }))}\n * onDismiss={(id) => setLosses((all) => all.filter((l) => l.id !== id))}\n * />\n * ```\n *\n * @category CommandDelay\n */\nexport function CommandList(props: Readonly<CommandListProps>) {\n const { kind, onDismiss, live = true } = props;\n const ariaLabel = props[\"aria-label\"] ?? DEFAULT_LABEL[kind];\n const tone: OutcomeTone = kind === \"found\" ? \"info\" : \"warn\";\n if (!live && props.entries.length === 0) return null;\n const boxes = boxesOf(props).map((box) => (\n <CommandList__Box\n key={box.id}\n role={live ? undefined : \"listitem\"}\n $tone={tone}\n >\n {railMark(box.tags) === \"ribbon\" ? (\n <CommandList__Label $tone={tone}>{box.subject}</CommandList__Label>\n ) : (\n <CommandList__Glyph aria-hidden=\"true\" $tone={tone}>\n {deriveGlyph(box.subject)}\n </CommandList__Glyph>\n )}\n <CommandList__Text>{box.sentence}</CommandList__Text>\n {onDismiss && (\n <IconButton\n type=\"button\"\n data-dismiss=\"\"\n onClick={(event) => {\n focusBesideDismissed(event.currentTarget);\n onDismiss(box.id);\n }}\n aria-label={box.dismissLabel}\n >\n ✕\n </IconButton>\n )}\n </CommandList__Box>\n ));\n // A live list stays mounted while empty so assistive tech is already watching when the first outcome arrives.\n if (live) {\n return (\n <CommandList__Region\n forwardedAs=\"div\"\n aria-label={ariaLabel}\n data-command-list=\"\"\n additionsOnly\n >\n {boxes}\n </CommandList__Region>\n );\n }\n return (\n <CommandList__Root role=\"list\" aria-label={ariaLabel} data-command-list=\"\">\n {boxes}\n </CommandList__Root>\n );\n}\n\nconst outcomeListLayout = css`\n display: flex;\n flex: 0 0 auto;\n flex-direction: column;\n gap: var(--gap-message-stack);\n /* Matches the queue container's inset, so the boxes line up with the tiles above. */\n margin: var(--outset-command-strip);\n`;\n\nconst CommandList__Root = styled.div`\n ${outcomeListLayout}\n`;\n\nconst CommandList__Region = styled(LiveRegion)`\n ${outcomeListLayout}\n &:empty {\n margin: 0;\n }\n`;\n\n/** `warn` for an outcome that did not happen (a refusal, a loss), `info` for one that did after all (a found). */\ntype OutcomeTone = Extract<Tone, \"warn\" | \"info\">;\n\nconst CommandList__Box = styled.div<{ $tone: OutcomeTone }>`\n display: flex;\n align-items: flex-start;\n gap: var(--gap-glyph-box);\n padding: var(--inset-surface);\n border: 1px solid ${({ $tone }) => TONE_MARK[$tone]};\n border-radius: var(--radius-regular);\n background: ${({ $tone }) =>\n `color-mix(in srgb, ${TONE_MARK[$tone]} 18%, var(--color-surface-raised))`};\n color: var(--color-text-primary);\n text-align: left;\n`;\n\n/** The same glyph the command's tile carries in the in-flight queue, so a dead command is recognisable. */\nconst CommandList__Glyph = styled.span<{ $tone: OutcomeTone }>`\n flex: 0 0 auto;\n display: grid;\n place-items: center;\n min-width: 34px;\n padding: var(--inset-glyph);\n align-self: stretch;\n font-size: var(--font-size-xs);\n font-weight: 700;\n color: ${({ $tone }) => TONE_TEXT[$tone]};\n border: 1px solid ${({ $tone }) => TONE_MARK[$tone]};\n border-radius: var(--radius-regular);\n background: ${({ $tone }) =>\n `color-mix(in srgb, ${TONE_MARK[$tone]} 14%, var(--color-surface-raised))`};\n`;\n\n/** A stream command's name in words, since it has no queue tile to echo. */\nconst CommandList__Label = styled.span<{ $tone: OutcomeTone }>`\n flex: 0 0 auto;\n align-self: center;\n font-size: var(--font-size-compact);\n font-weight: 700;\n color: ${({ $tone }) => TONE_TEXT[$tone]};\n`;\n\nconst CommandList__Text = styled.span`\n flex: 1 1 auto;\n min-width: 0;\n font-size: var(--font-size-compact);\n line-height: var(--line-height-body);\n /* Wraps, never truncates: the numbers are at the end of the sentence. */\n overflow-wrap: anywhere;\n`;\n","import { useCallback, useSyncExternalStore } from \"react\";\nimport type {\n ComponentSlotRegistry,\n ComponentSlotSegment,\n Contributed,\n ContributionEntry,\n ContributionSlotId,\n} from \"./contributions\";\nimport { createPanelStore } from \"./store/createPanelStore\";\nimport { createStore, type Store } from \"./store/createStore\";\nimport { useWidgetMeta } from \"./WidgetMetaContext\";\n\n/*\n * The contribution READ seam: the per-widget store plus the hooks that read\n * it, spine-free. The WRITE half (the per-frame aggregation that pulls\n * telemetry) mounts this same `ContributionsPanelStore` and writes into it.\n */\n\n/**\n * One slot's row in a widget's contribution store: the full slot id and the\n * entries its contributions produced, in render order. Useful for showing the\n * operator what Uplinks contribute to a widget. Held in the store behind\n * {@link useContributions}.\n *\n * @category Extensions\n */\nexport interface ContributionSlotEntry {\n /** The full slot id, such as `\"crew-status.badges\"`. */\n id: string;\n // A primitive contribution cannot carry a provenance stamp and is stored verbatim, hence the loose type.\n /** The entries, each stamped with its contribution id and owner when it is an object. */\n entries: readonly unknown[];\n}\n\nconst EMPTY_ENTRIES: readonly unknown[] = Object.freeze([]);\n\n/**\n * The bare slot names that complete to `${componentId}.<segment>`. Useful for\n * telling a standard widget slot from a slot id declared in full. Used by the\n * contributions provider and by the size accounting of a widget's slots.\n */\nexport const COMPONENT_SLOT_SEGMENTS = [\n \"badges\",\n \"filters\",\n \"meters\",\n] as const satisfies readonly ComponentSlotSegment[];\n\ntype _EverySegmentListed =\n ComponentSlotSegment extends (typeof COMPONENT_SLOT_SEGMENTS)[number]\n ? true\n : never;\nconst _everySegmentListed: _EverySegmentListed = true;\nvoid _everySegmentListed;\n\n/**\n * The standard contribution segments every widget carries: `badges`. An\n * Uplink fills any widget's header badges, which the operator sees beside the\n * widget's title, by contributing to\n * `\"<widget-id>.badges\"` with its handle's `registerContribution`, without the\n * widget declaring the slot. `compute` returns {@link BadgeEntry} items. How\n * the panel draws them, and a whole example, are under Standard slots on\n * {@link Panel}.\n *\n * @category Panel\n */\nexport const FRAMEWORK_CONTRIBUTION_SEGMENTS = [\n \"badges\",\n] as const satisfies readonly ComponentSlotSegment[];\n\nconst EMPTY_SLOT_ENTRIES: readonly ContributionSlotEntry[] = Object.freeze([]);\n\n/**\n * The per-widget store of contribution entries, one {@link ContributionSlotEntry}\n * per slot. Useful for showing the operator what Uplinks contribute to a\n * widget. {@link ContributionsProvider} mounts and fills it; the read hooks\n * ({@link useContributions}, {@link useContributionsBySlotId}) read it. A\n * widget reads through those hooks rather than the store.\n *\n * @intent Published so a test, or a host of its own, can mount the per-widget contribution store a widget reads through useContributions.\n * @category Extensions\n */\nexport const ContributionsPanelStore = createPanelStore<\n Store<ContributionSlotEntry>\n>(() => createStore<ContributionSlotEntry>());\n\n/** The single subscription point: one `useSyncExternalStore` for the whole store, however many slots are read. */\nfunction useAllContributionSlots(): readonly ContributionSlotEntry[] {\n const store = ContributionsPanelStore.useStore();\n const subscribe = useCallback(\n (onChange: () => void) => (store ? store.subscribe(onChange) : () => {}),\n [store],\n );\n const getSnapshot = useCallback(\n (): readonly ContributionSlotEntry[] =>\n store ? store.getSnapshot() : EMPTY_SLOT_ENTRIES,\n [store],\n );\n return useSyncExternalStore(subscribe, getSnapshot);\n}\n\n/**\n * The entries contributed to the slot with the full id `slot`, untyped. Empty\n * when nothing contributes or no contribution store is mounted. Useful for\n * showing the operator what Uplinks add to a slot whose id is built at runtime.\n * Used by {@link StatContributions}. Prefer {@link useContributions}, which\n * types the entries from the slot's declaration.\n *\n * @category Extensions\n */\nexport function useContributionsBySlotId(slot: string): readonly unknown[] {\n const snapshot = useAllContributionSlots();\n return snapshot.find((e) => e.id === slot)?.entries ?? EMPTY_ENTRIES;\n}\n\n/**\n * The entries contributed to a slot, for a widget to draw. Useful for showing\n * the operator what Uplinks add to a widget, such as header badges. Used by the\n * dashboard grid and the screen header badges. Three call shapes:\n *\n * - a full slot id declared in `ContributionRegistry` (`\"ship-map.part-meters\"`):\n * its entries, typed and stamped with `contributionId` and `owner`\n * - a component segment (`\"badges\"`, `\"filters\"`, `\"meters\"`): completed to\n * `${componentId}.<segment>` for the widget it is called in, typed from\n * `ComponentSlotRegistry`\n * - an array of full slot ids: an object keyed by slot id\n *\n * Only the highest `priority` band of contributions to a slot is present.\n * Without a {@link WidgetMetaContext} and a {@link ContributionsProvider}\n * above the caller it returns empty lists. The dashboard and the test render\n * helpers mount both; a test rendering a widget bare must mount them too.\n *\n * @example\n * ```tsx\n * function ContributedBadges() {\n * const badges = useContributions(\"badges\");\n * return badges.map((b) => (\n * <Badge key={b.id} tone={b.tone}>\n * {b.label}\n * </Badge>\n * ));\n * }\n * ```\n *\n * @category Extensions\n */\nexport function useContributions<Slot extends ContributionSlotId>(\n slot: Slot,\n): readonly Contributed<ContributionEntry<Slot>>[];\n// A reusable component writes only the segment (\"filters\"), completed from `useWidgetMeta()` and typed via `ComponentSlotRegistry`.\nexport function useContributions<Segment extends ComponentSlotSegment>(\n segment: Segment,\n): readonly ComponentSlotRegistry[Segment][];\n// An array of full slot ids.\nexport function useContributions<\n const Slots extends readonly ContributionSlotId[],\n>(\n slots: Slots,\n): { [Slot in Slots[number]]: readonly Contributed<ContributionEntry<Slot>>[] };\nexport function useContributions(\n slotOrSlots: string | readonly string[],\n): unknown {\n const meta = useWidgetMeta();\n const snapshot = useAllContributionSlots();\n /*\n * A declared SEGMENT is completed to `${componentId}.${segment}`; anything\n * else is used as-is. The test is membership of `COMPONENT_SLOT_SEGMENTS`,\n * not the absence of a dot, since an undotted slot id can be app-wide.\n */\n const isSegment = (slot: string): boolean =>\n (COMPONENT_SLOT_SEGMENTS as readonly string[]).includes(slot);\n const complete = (slot: string): string =>\n meta && isSegment(slot) ? `${meta.componentId}.${slot}` : slot;\n const read = (slot: string): readonly unknown[] =>\n snapshot.find((e) => e.id === complete(slot))?.entries ?? EMPTY_ENTRIES;\n\n if (typeof slotOrSlots === \"string\") return read(slotOrSlots);\n return Object.fromEntries(slotOrSlots.map((slot) => [slot, read(slot)]));\n}\n","import {\n type AnyContribution,\n hasHost,\n logger,\n type ModSettingsModel,\n observedAt,\n PerfBudget,\n type TopicCurrency,\n type TopicId,\n topicReading,\n type Value,\n withoutReckoning,\n} from \"@ksp-gonogo/sitrep-sdk\";\nimport {\n type FrameToken,\n getContributionsForSlot,\n modSettingsTopic,\n onContributionsChange,\n type ProcessorHandle,\n processorRuntimeFor,\n readModSetting,\n runContributionCompute,\n subscribeTopicRead,\n useTelemetryClientOptional,\n useTelemetryStoreOptional,\n} from \"@ksp-gonogo/sitrep-sdk/spine\";\nimport {\n type ReactElement,\n type ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useSyncExternalStore,\n} from \"react\";\nimport {\n COMPONENT_SLOT_SEGMENTS,\n type ContributionSlotEntry,\n ContributionsPanelStore,\n useContributions,\n useContributionsBySlotId,\n} from \"./contributionsRead\";\nimport {\n type DomainAvailabilityStore,\n useDomainAvailabilityStore,\n} from \"./domainAvailability\";\nimport type { Store } from \"./store/createStore\";\nimport { useWidgetMeta } from \"./WidgetMetaContext\";\n\n/*\n * The contribution WRITE seam: the per-frame aggregation that pulls each\n * contribution's telemetry deps and fans the computed entries into the\n * per-widget `ContributionsPanelStore` the read hooks share.\n */\n\n/*\n * One PerfBudget per slot id, created lazily since slot ids are open-ended. It\n * counts entry sets that actually MOVED, not aggregation passes, which run on\n * every animation frame; 30 is about 3x the wire sample rate.\n */\nconst slotBudgets = new Map<string, PerfBudget>();\nfunction getSlotPerfBudget(slot: string): PerfBudget {\n let budget = slotBudgets.get(slot);\n if (!budget) {\n budget = new PerfBudget({\n name: `Contributions \"${slot}\" entries recomputed/sec`,\n threshold: 30,\n windowMs: 1000,\n unit: \"recomputes\",\n });\n slotBudgets.set(slot, budget);\n }\n return budget;\n}\n\n// What a declared Topic reads as while no store exists to sample it: the same never-arrived reading a widget gets with no provider mounted, shared so the snapshot keeps its identity.\nconst NEVER_ARRIVED: Currency = topicReading<never>({\n state: \"pending\",\n reckoning: { status: \"none\" },\n});\n\n// Stable empty snapshot with no `TelemetryProvider`: a fresh `{}` would make `useSyncExternalStore` see a change every render.\nconst EMPTY_TOPIC_VALUES: Readonly<Record<string, unknown>> = Object.freeze({});\n\n// Memoised per slot, since useSyncExternalStore needs a referentially stable snapshot between changes.\nconst slotCache = new Map<string, AnyContribution[]>();\nlet cacheValid = false;\nonContributionsChange(() => {\n cacheValid = false;\n slotCache.clear();\n});\nfunction getContributionsForSlotCached(slot: string): AnyContribution[] {\n if (!cacheValid) {\n slotCache.clear();\n cacheValid = true;\n }\n let cached = slotCache.get(slot);\n if (cached === undefined) {\n cached = getContributionsForSlot(slot);\n slotCache.set(slot, cached);\n }\n return cached;\n}\n\n/**\n * True when the two entries carry the same value: the same reference, or two\n * objects shallow-equal over their own keys. Reference equality alone would\n * never hold, since the aggregation stamps provenance onto a fresh row every\n * frame. Shallow, because the rows are flat.\n */\nfunction entryUnchanged(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) return true;\n if (typeof a !== \"object\" || typeof b !== \"object\") return false;\n if (a === null || b === null) return false;\n if (Array.isArray(a) !== Array.isArray(b)) return false;\n const aKeys = Object.keys(a);\n if (aKeys.length !== Object.keys(b).length) return false;\n for (const key of aKeys) {\n if (\n !Object.is(\n (a as Record<string, unknown>)[key],\n (b as Record<string, unknown>)[key],\n )\n ) {\n return false;\n }\n }\n return true;\n}\n\n/** Element-wise: true when every entry holds the same value as before. */\nfunction entriesUnchanged(\n a: readonly unknown[],\n b: readonly unknown[],\n): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (!entryUnchanged(a[i], b[i])) return false;\n }\n return true;\n}\n\nfunction shallowEqualValues(\n a: Record<string, unknown>,\n b: Record<string, unknown>,\n): boolean {\n const keys = Object.keys(a);\n if (keys.length !== Object.keys(b).length) return false;\n return keys.every((k) => Object.hasOwn(b, k) && Object.is(a[k], b[k]));\n}\n\n/** A Topic's reading as a contribution's `compute` receives it. */\ntype Currency = TopicCurrency<unknown, { readonly status: \"none\" }>;\n\n/**\n * A Topic's reading as a contribution receives it: with its forward model\n * removed, and the previous object kept while the state, value, instant and\n * grade are unchanged. Used by {@link ContributionsProvider} when it hands\n * readings to contributions.\n *\n * A modelled reading is a new object on every frame the view time moves, so\n * handing one over whole would re-run every contribution reading a modelled\n * Topic at frame rate, and rebuild its entries each time, whether or not\n * anything it draws moved.\n */\nexport function contributionReading(\n previous: Currency | undefined,\n next: Currency,\n): Currency {\n if (previous === undefined || previous === next) return next;\n const sameCurrency =\n previous.state === next.state &&\n Object.is(\n \"value\" in previous ? previous.value : undefined,\n \"value\" in next ? next.value : undefined,\n ) &&\n sameInstant(observedAt(previous), observedAt(next)) &&\n (previous.state === \"held\" ? previous.grade : undefined) ===\n (next.state === \"held\" ? next.grade : undefined);\n return sameCurrency ? previous : next;\n}\n\nfunction sameInstant(\n a: Value<\"ut\"> | undefined,\n b: Value<\"ut\"> | undefined,\n): boolean {\n if (a === undefined || b === undefined) return a === b;\n return a.equals(b);\n}\n\ninterface ModSettingRef {\n readonly uplink: string;\n readonly key: string;\n}\n\nfunction isModSettingDep(dep: object): dep is { modSetting: ModSettingRef } {\n return \"modSetting\" in dep;\n}\n\n/** The key a setting dep's value arrives under in `compute`'s argument. */\nfunction modSettingKey(ref: ModSettingRef): string {\n return `settings.${ref.uplink}.${ref.key}`;\n}\n\n/** The topics a contribution declared, which it may read through any seam unreported. */\nfunction declaredTopicsOf(def: AnyContribution): ReadonlySet<string> {\n const topics = new Set<string>();\n for (const d of def.deps ?? []) {\n if (typeof d === \"string\") {\n topics.add(d);\n continue;\n }\n if (isModSettingDep(d)) {\n topics.add(modSettingKey(d.modSetting));\n }\n }\n if (def.requires) topics.add(`${def.requires}.available`);\n return topics;\n}\n\n/**\n * One slot's aggregation pipeline: bulk-reads the union of every gated-in\n * contribution's `deps` once per frame, calls each `compute()` in a plain loop\n * (no hooks, so the registered set may change freely), isolates a throwing\n * contribution, and writes the result under this slot's key. Its own\n * component, so each slot's hooks have a stable position.\n */\nfunction SlotAggregator({\n slot,\n store,\n}: {\n slot: string;\n store: Store<ContributionSlotEntry>;\n}) {\n const contribs = useSyncExternalStore(\n onContributionsChange,\n () => getContributionsForSlotCached(slot),\n () => getContributionsForSlotCached(slot),\n );\n\n const unionDeps = useMemo(() => {\n const topics = new Set<TopicId>();\n const processors = new Map<string, ProcessorHandle<unknown>>();\n const settings = new Map<string, ModSettingRef>();\n for (const c of contribs) {\n for (const d of c.deps ?? []) {\n if (typeof d === \"string\") {\n topics.add(d as TopicId);\n continue;\n }\n if (isModSettingDep(d)) {\n settings.set(modSettingKey(d.modSetting), d.modSetting);\n continue;\n }\n processors.set(d.id, d);\n }\n }\n return {\n topics: Array.from(topics),\n processors: Array.from(processors.values()),\n settings: Array.from(settings.entries()),\n };\n }, [contribs]);\n\n const client = useTelemetryClientOptional();\n const telemetryStore = useTelemetryStoreOptional();\n const processorRuntime = telemetryStore\n ? processorRuntimeFor(telemetryStore)\n : undefined;\n\n // Processor freshness rides the same frame boundary as the Topic reads, so no per-processor subscription is needed.\n useEffect(() => {\n if (!processorRuntime) return;\n const deactivates = unionDeps.processors.map((p) =>\n processorRuntime.activate(p.id),\n );\n return () => {\n for (const d of deactivates) d();\n };\n }, [processorRuntime, unionDeps.processors]);\n\n const subscribe = useCallback(\n (onChange: () => void) => {\n if (!client || !telemetryStore) return () => {};\n // Through the shared read seam, which also holds up each dep's reckoner inputs.\n const settingsTopics = new Set(\n unionDeps.settings.map(([, ref]) => modSettingsTopic(ref.uplink)),\n );\n const unsubscribeInputs = [...unionDeps.topics, ...settingsTopics].map(\n (topic) => subscribeTopicRead(client, telemetryStore, topic),\n );\n const unsubscribeFrame = telemetryStore.subscribeFrame(() => {\n // Evaluate Processors BEFORE notifying React: this listener can fire before the evaluator's shared one. Idempotent.\n if (unionDeps.processors.length > 0) processorRuntime?.evaluateActive();\n onChange();\n });\n return () => {\n unsubscribeFrame();\n for (const u of unsubscribeInputs) u();\n };\n },\n [client, telemetryStore, processorRuntime, unionDeps],\n );\n\n // Keyed on the `FrameToken`, which is stable for a whole frame, so re-reads within one frame return the identical object.\n const topicCacheRef = useRef<{\n token: FrameToken;\n values: Record<string, unknown>;\n } | null>(null);\n // The readings last handed to `compute`, by Topic, so an unchanged one keeps its identity.\n const readingsRef = useRef(new Map<string, Currency>());\n\n // Without a store every declared Topic has not arrived; a settings or processor dep has no such reading and stays absent.\n const withoutStoreValues = useMemo((): Record<string, unknown> => {\n if (unionDeps.topics.length === 0) return EMPTY_TOPIC_VALUES;\n return Object.fromEntries(\n unionDeps.topics.map((topic) => [topic, NEVER_ARRIVED]),\n );\n }, [unionDeps]);\n\n const getSnapshot = useCallback((): Record<string, unknown> => {\n if (!telemetryStore) return withoutStoreValues;\n if (\n unionDeps.topics.length === 0 &&\n unionDeps.processors.length === 0 &&\n unionDeps.settings.length === 0\n ) {\n return EMPTY_TOPIC_VALUES;\n }\n const token = telemetryStore.currentFrame();\n const cached = topicCacheRef.current;\n if (cached && cached.token === token) return cached.values;\n const values: Record<string, unknown> = {};\n for (const topic of unionDeps.topics) {\n const reading = contributionReading(\n readingsRef.current.get(topic),\n withoutReckoning(telemetryStore.sampleReading(topic, token)),\n );\n readingsRef.current.set(topic, reading);\n values[topic] = reading;\n }\n for (const p of unionDeps.processors) {\n values[p.id] = processorRuntime?.value(p.id);\n }\n for (const [key, ref] of unionDeps.settings) {\n const point = telemetryStore.sample<ModSettingsModel | null>(\n modSettingsTopic(ref.uplink),\n token,\n );\n values[key] = point ? readModSetting(point.payload, ref.key) : undefined;\n }\n /*\n * A frame arrives every animation tick whether or not anything moved, so\n * the previous object is kept while its contents are unchanged. Work that\n * must advance with the clock belongs in a processor.\n */\n const next =\n cached && shallowEqualValues(cached.values, values)\n ? cached.values\n : values;\n topicCacheRef.current = { token, values: next };\n return next;\n }, [telemetryStore, processorRuntime, unionDeps, withoutStoreValues]);\n\n const topicValues = useSyncExternalStore(subscribe, getSnapshot);\n // The host's presence store, the same one an augment's `requires` reads, so both gates follow one rule.\n const availability = useDomainAvailabilityStore();\n const presence = useSyncExternalStore(\n availability ? availability.subscribe : NO_AVAILABILITY_SUBSCRIBE,\n () => presenceKey(contribs, availability),\n () => presenceKey(contribs, availability),\n );\n const budget = useMemo(() => getSlotPerfBudget(slot), [slot]);\n const deregisterRef = useRef<(() => void) | null>(null);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: `presence` is an intentional trigger, since the store keeps its identity when a Domain comes or goes.\n useEffect(() => {\n const collected: unknown[] = [];\n for (const def of contribs) {\n if (def.requires && !availability?.isAvailable(def.requires)) continue;\n try {\n const result = runContributionCompute(\n def.id,\n declaredTopicsOf(def),\n () => def.compute(topicValues),\n );\n if (result) {\n for (const entry of result) {\n if (entry !== null && typeof entry === \"object\") {\n collected.push({\n ...entry,\n contributionId: def.id,\n owner: def.owner,\n });\n } else {\n // A primitive contribution cannot carry the provenance stamp, so it is stored verbatim.\n collected.push(entry);\n }\n }\n }\n } catch (err) {\n reportContributionThrew(def.id, err);\n }\n }\n const current = store.getSnapshot().find((e) => e.id === slot);\n if (current && entriesUnchanged(current.entries, collected)) return;\n // After the guard, so one record is one entry set that genuinely moved.\n budget.record();\n store.update(slot, { entries: collected });\n // update() returns early on an unknown id, so the first write registers.\n if (!current) {\n deregisterRef.current = store.register({ id: slot, entries: collected });\n }\n }, [contribs, topicValues, slot, store, budget, availability, presence]);\n\n // The aggregator is keyed by its slot, so unmounting is the slot leaving the list; its entries go with it so a reader never sees what nothing is computing.\n useEffect(\n () => () => {\n deregisterRef.current?.();\n deregisterRef.current = null;\n },\n [],\n );\n\n return null;\n}\n\nconst NO_AVAILABILITY_SUBSCRIBE = (): (() => void) => () => {};\n\n/** Which of these contributions' Domains are present, as a string, so a presence change re-runs them and nothing else does. */\nfunction presenceKey(\n contribs: readonly AnyContribution[],\n availability: DomainAvailabilityStore | null,\n): string {\n return contribs\n .map((c) =>\n c.requires && availability?.isAvailable(c.requires) ? c.requires : \"\",\n )\n .join(\"|\");\n}\n\n/**\n * A contribution threw, which is an Uplink author's bug and must never be\n * silent. Falls back to `console.error` without a host, because the sdk's\n * `logger` throws when none is installed.\n */\nfunction reportContributionThrew(id: string, err: unknown): void {\n const error = err instanceof Error ? err : new Error(String(err));\n const message = `Contribution \"${id}\" threw; skipped`;\n if (hasHost()) logger.error(message, error);\n else console.error(message, error);\n}\n\n/**\n * Runs the registered contributions for the tree below it and stores their\n * entries for {@link useContributions} to read. Useful for showing the operator\n * what Uplinks add to a widget or to the screen header. Used by the dashboard\n * grid and the screen header badges. Inside a widget it serves the\n * widget's declared `contributionSlots` plus the component segments\n * (`badges`, `filters`, `meters`) completed to `${componentId}.<segment>`.\n * `slots` names the full slot ids to serve instead, for a surface that is not\n * a widget, such as the screen header's `app.header-badges`. The dashboard\n * mounts one per widget.\n *\n * @category Extensions\n */\nexport function ContributionsProvider({\n slots,\n children,\n}: {\n slots?: readonly string[];\n children?: ReactNode;\n}): ReactElement {\n return (\n <ContributionsPanelStore.Provider>\n <ContributionsAggregation slots={slots}>\n {children}\n </ContributionsAggregation>\n </ContributionsPanelStore.Provider>\n );\n}\n\n/*\n * The framework-universal segments (`COMPONENT_SLOT_SEGMENTS`, shared with the\n * read half) are aggregated for EVERY widget on top of what it declared, so a\n * component owning one gets its contributions with nothing written by the\n * host. Only something every widget has belongs here; any other slot is\n * declared by the widget that hosts it.\n */\nfunction ContributionsAggregation({\n slots: named,\n children,\n}: {\n slots?: readonly string[];\n children?: ReactNode;\n}) {\n const meta = useWidgetMeta();\n const store = ContributionsPanelStore.useStore();\n const slots = useMemo(() => {\n if (named) return named;\n const declared = meta?.contributionSlots ?? [];\n if (!meta) return declared;\n const merged = [...declared];\n for (const segment of COMPONENT_SLOT_SEGMENTS) {\n const slot = `${meta.componentId}.${segment}`;\n if (!merged.includes(slot as never)) merged.push(slot as never);\n }\n return merged;\n }, [meta, named]);\n\n if (!store) return <>{children}</>;\n\n return (\n <>\n {slots.map((slot) => (\n <SlotAggregator key={slot} slot={slot} store={store} />\n ))}\n {children}\n </>\n );\n}\n\nexport { useContributions, useContributionsBySlotId };\n","import { bandIn, type Value } from \"@ksp-gonogo/sitrep-sdk\";\nimport styled from \"styled-components\";\nimport {\n heldNameMarker,\n InstrumentBound,\n InstrumentHeldMark,\n sayHeld,\n} from \"./instrumentCurrency\";\nimport { NULL_DISPLAY } from \"./NullValue\";\nimport {\n figureAttributes,\n resolveCurrency,\n type UnitValue,\n} from \"./readingCurrency\";\nimport { placedOnScale, standsApart } from \"./standsApart\";\nimport { useTooltip } from \"./Tooltip\";\nimport { type FormatsFor, speakQuantity, writeQuantity } from \"./units\";\n\n/**\n * A coloured segment of a {@link Dial}'s arc, in the dial's own unit. Useful for\n * showing the operator which part of a scale is safe or dangerous. Taken in the\n * dial's `zones`.\n *\n * @category Gauge\n */\nexport interface DialZone<Unit extends string = string> {\n /** Lower bound of the coloured arc segment. */\n from: Value<Unit>;\n /** Upper bound of the coloured arc segment. */\n to: Value<Unit>;\n /** The segment's colour: any CSS colour, such as a theme `var()`. */\n color: string;\n}\n\n/**\n * A tick mark on a {@link Dial}'s face, with an optional label beside it. Useful\n * for letting the operator read a value off the scale. Taken in the dial's\n * `ticks`.\n *\n * @category Gauge\n */\nexport interface DialTick<Unit extends string = string> {\n /** Value at which to draw the tick. */\n value: Value<Unit>;\n /** Optional short label (e.g. \"N\", \"E\"). */\n label?: string;\n}\n\n/**\n * Props for {@link Dial}: the value, the scale it sweeps, and its zones and\n * ticks.\n * Useful for giving the operator a round gauge of a value against its scale.\n * Used by {@link Dial}.\n *\n * @category Gauge\n */\nexport interface DialProps<Unit extends string = string> {\n /** Current value: the needle position, or the whole reading it arrived in. */\n value: UnitValue<Unit>;\n /** The value at `startAngle`. */\n min: Value<Unit>;\n /** The value at `startAngle + sweep`. */\n max: Value<Unit>;\n /**\n * Drawn width in pixels. The SVG scales down to a narrower slot rather than\n * clipping.\n *\n * @defaultValue `120`\n */\n width?: number;\n /**\n * Drawn height in pixels.\n *\n * @defaultValue `120`\n */\n height?: number;\n /**\n * Degrees clockwise from up where `min` sits.\n *\n * @defaultValue `0`, the top\n */\n startAngle?: number;\n /**\n * Degrees swept from `min` to `max`.\n *\n * @defaultValue `360`, a full circle\n */\n sweep?: number;\n /**\n * Treat the value as wrapping (compass): value is taken modulo the range.\n * Without it a value outside `min..max` pins the needle at the nearer end.\n */\n wrap?: boolean;\n /** Coloured arc segments. */\n zones?: ReadonlyArray<DialZone<Unit>>;\n /** Tick marks around the face. */\n ticks?: ReadonlyArray<DialTick<Unit>>;\n /**\n * Pin the rung the centre readout is written at, for the cases where\n * convention beats magnitude. Absent, the value's own kind decides.\n */\n format?: FormatsFor<Unit>;\n /** Centre label override. Defaults to the value, written with its unit. */\n valueLabel?: string;\n /**\n * Draws a half-circle face with the figure under the hub, the instrument\n * layout for a gauge whose figure is the point: the arc is raised to the top\n * of the box and a strip is reserved under it for the figure. `regular` and\n * `large` set the figure's size. Absent, the figure sits in the centre of\n * the face. Honoured only for a face that sweeps 180° or less.\n */\n readout?: \"regular\" | \"large\";\n /** Needle colour. Defaults to `var(--color-text-primary)`. */\n needleColor?: string;\n /** Arc track colour. Defaults to `var(--color-border-subtle)`. */\n trackColor?: string;\n /** Accessible name naming what the dial measures; the value is spoken as `aria-valuetext`. */\n \"aria-label\": string;\n}\n\nconst TRACK_THICKNESS = 6;\nconst HUB_RADIUS = 3;\n\n/** The half-circle layout's face: a thicker track and hub, and the figure's size with its baseline below the hub (the strip reserved under the arc). */\nconst RAISED = { track: 8, hub: 4, needle: 0.92 } as const;\nconst READOUT = {\n regular: { size: 16, drop: 18 },\n large: { size: 24, drop: 32 },\n} as const;\n\n/** Point on a circle of radius `r`, `angleDeg` clockwise from up (12 o'clock). */\nfunction pointAt(\n cx: number,\n cy: number,\n r: number,\n angleDeg: number,\n): { x: number; y: number } {\n const a = (angleDeg * Math.PI) / 180;\n return { x: cx + r * Math.sin(a), y: cy - r * Math.cos(a) };\n}\n\nfunction arcPath(\n cx: number,\n cy: number,\n r: number,\n a0: number,\n a1: number,\n): string {\n const p0 = pointAt(cx, cy, r, a0);\n const p1 = pointAt(cx, cy, r, a1);\n const delta = a1 - a0;\n const largeArc = Math.abs(delta) > 180 ? 1 : 0;\n const sweepFlag = delta >= 0 ? 1 : 0;\n return `M ${p0.x.toFixed(2)} ${p0.y.toFixed(2)} A ${r} ${r} 0 ${largeArc} ${sweepFlag} ${p1.x.toFixed(2)} ${p1.y.toFixed(2)}`;\n}\n\n/**\n * A round instrument whose needle sweeps a configurable arc (by default a full\n * 360° compass), so it can show a heading that wraps as well as a bounded\n * value. With `readout`, a half-circle face puts its figure under the hub.\n * Useful for showing the operator a value against a scale at a glance. Used by\n * the thrust-to-weight ratio widget.\n *\n * Angles are degrees clockwise from 12 o'clock (up is 0°), as on a compass.\n * `startAngle` places `min`; `sweep` is the span from `min` to `max`.\n *\n * The whole axis is one kind: `value`, `min`, `max`, every zone bound and\n * every tick are `Value<Unit>` of the same unit, and the centre readout writes\n * that unit itself. Handed a whole `Reading`, a held figure is marked as held\n * and the {@link UncertaintyBand} of a figure a model carried forward (see\n * {@link TopicReckoning}) puts two bounds on the arc.\n *\n * The dial is a `role=\"meter\"` with the value as `aria-valuetext`. With no\n * value it draws no needle and is announced as an image naming the missing\n * value.\n *\n * @example A heading compass\n * ```tsx\n * import { useTelemetry, value } from \"@ksp-gonogo/sitrep-sdk\";\n * import { Dial } from \"@ksp-gonogo/ui-kit\";\n *\n * function HeadingCompass() {\n * const attitude = useTelemetry(\"vessel.attitude\");\n * return (\n * <Dial\n * value={attitude.heading}\n * min={value(\"°\", 0)}\n * max={value(\"°\", 360)}\n * wrap\n * ticks={[\n * { value: value(\"°\", 0), label: \"N\" },\n * { value: value(\"°\", 90), label: \"E\" },\n * { value: value(\"°\", 180), label: \"S\" },\n * { value: value(\"°\", 270), label: \"W\" },\n * ]}\n * aria-label=\"Heading\"\n * />\n * );\n * }\n * ```\n *\n * @category Gauge\n * @categoryDescription Gauge\n * Instruments for a value against a scale: a dial and a tape, each with ticks\n * and coloured zones.\n */\nexport function Dial<Unit extends string = string>({\n value,\n min,\n max,\n width = 120,\n height = 120,\n startAngle = 0,\n sweep = 360,\n wrap = false,\n zones,\n ticks,\n valueLabel,\n readout,\n format,\n needleColor = \"var(--color-text-primary)\",\n trackColor = \"var(--color-border-subtle)\",\n \"aria-label\": ariaLabel,\n}: Readonly<DialProps<Unit>>) {\n const resolved = resolveCurrency(value);\n const { shown, held, caption, band } = resolved;\n const { anchor, tip } = useTooltip(caption);\n\n // The axis, unwrapped once into the face's angular geometry; every figure a reader sees goes back out through the unit layer.\n // A present but non-finite magnitude is no figure at all, the same as a null reading.\n const current = shown?.magnitude ?? Number.NaN;\n const finite = Number.isFinite(current) ? shown : null;\n const axisMin = min.magnitude;\n const axisMax = max.magnitude;\n const span = axisMax - axisMin;\n const safe = Number.isFinite(current) ? current : axisMin;\n const display =\n span > 0\n ? wrap\n ? axisMin + ((((safe - axisMin) % span) + span) % span)\n : Math.max(axisMin, Math.min(axisMax, safe))\n : axisMin;\n // No number, no needle. A compass wraps its figure onto the axis; every other face writes the reading as it is and only pins the needle.\n const hasFigure = finite != null;\n const face =\n finite == null\n ? null\n : { magnitude: wrap ? display : current, unit: finite.unit };\n // An SVG `<text>` cannot contain a `<span>`, so this uses `writeQuantity`, with `speakQuantity` for `aria-valuetext`.\n const centreLabel =\n valueLabel ?? (face === null ? null : writeQuantity(face, { format }));\n const spoken = face === null ? NULL_DISPLAY : speakQuantity(face, { format });\n // The model's interval, narrowed to the figure's own unit.\n const interval =\n finite == null || band === null\n ? null\n : (bandIn(band, finite.unit) ?? null);\n\n const raised = readout !== undefined && sweep <= 180;\n const trackThickness = raised ? RAISED.track : TRACK_THICKNESS;\n const hubRadius = raised ? RAISED.hub : HUB_RADIUS;\n const figure = readout === undefined ? null : READOUT[readout];\n const cx = width / 2;\n // Raised: the hub sits on the arc's base line, with the figure's strip below it.\n const r =\n raised && figure !== null\n ? Math.min(\n (width - trackThickness) / 2,\n height - trackThickness - figure.drop,\n )\n : Math.min(width, height) / 2 - trackThickness - 2;\n const cy = raised ? r + trackThickness / 2 : height / 2;\n\n const angleOf = (v: number): number => {\n const t = span > 0 ? (v - axisMin) / span : 0;\n return startAngle + t * sweep;\n };\n\n /*\n * Onto the axis (clamped in the algebra, so another rung of the same kind\n * converts before it compares), then onto the face. Zone order and emptiness\n * are decided on quantities, since angles would flip under a negative sweep.\n */\n const onAxis = (q: Value<Unit>): Value<Unit> => q.max(min).min(max);\n const onFace = (q: Value<Unit>): number => angleOf(q.magnitude);\n\n // Compared as fractions of the sweep, from the angles the marks are drawn at.\n const onSweep = (angle: number): number =>\n sweep !== 0 ? (angle - startAngle) / sweep : 0;\n const drawnInterval =\n interval !== null &&\n standsApart(\n onSweep(angleOf(display)),\n [\n onSweep(onFace(onAxis(interval.lo))),\n onSweep(onFace(onAxis(interval.hi))),\n ],\n placedOnScale({ wraps: wrap }),\n )\n ? interval\n : null;\n\n const isFullCircle = sweep >= 360;\n const needle = pointAt(\n cx,\n cy,\n r * (raised ? RAISED.needle : 0.88),\n angleOf(display),\n );\n\n return (\n <Dial__Meter\n {...figureAttributes(resolved)}\n {...anchor}\n {...(hasFigure\n ? {\n role: \"meter\",\n \"aria-label\": sayHeld(ariaLabel, caption),\n ...heldNameMarker(caption),\n \"aria-valuenow\": display,\n \"aria-valuemin\": axisMin,\n \"aria-valuemax\": axisMax,\n \"aria-valuetext\": spoken,\n }\n : {\n /* With no value to state, the face is an image rather than a meter at its minimum. */\n role: \"img\",\n \"aria-label\": sayHeld(`${ariaLabel}: ${spoken}`, caption),\n ...heldNameMarker(caption),\n })}\n >\n <svg\n width={width}\n height={height}\n viewBox={`0 0 ${width} ${height}`}\n aria-hidden=\"true\"\n style={{\n display: \"block\",\n fontFamily: \"var(--font-family-mono)\",\n maxWidth: \"100%\",\n height: \"auto\",\n // The raised figure's line box runs a few pixels past the viewBox; its glyphs sit inside it.\n overflow: raised ? \"visible\" : undefined,\n }}\n >\n {r > 0 &&\n (isFullCircle ? (\n <circle\n cx={cx}\n cy={cy}\n r={r}\n fill=\"none\"\n stroke={trackColor}\n strokeWidth={trackThickness}\n />\n ) : (\n <path\n d={arcPath(cx, cy, r, startAngle, startAngle + sweep)}\n fill=\"none\"\n stroke={trackColor}\n strokeWidth={trackThickness}\n strokeLinecap=\"round\"\n />\n ))}\n\n {/* The track's rounded ends take the colour of the zone that reaches them, so a zoned arc has no grey cap. */}\n {r > 0 &&\n !isFullCircle &&\n zones?.flatMap((z) => {\n const lo = onAxis(z.from.min(z.to));\n const hi = onAxis(z.from.max(z.to));\n if (!hi.greaterThan(lo)) return [];\n return [\n // Clamped onto the axis already, so \"not past the end\" is \"at the end\".\n lo.greaterThan(min) ? null : startAngle,\n max.greaterThan(hi) ? null : startAngle + sweep,\n ].flatMap((angle) => {\n if (angle === null) return [];\n const end = pointAt(cx, cy, r, angle);\n return [\n <circle\n key={`cap-${z.color}-${angle}`}\n data-dial-cap=\"\"\n cx={end.x}\n cy={end.y}\n r={trackThickness / 2}\n fill={z.color}\n />,\n ];\n });\n })}\n\n {r > 0 &&\n zones?.map((z) => {\n const lo = onAxis(z.from.min(z.to));\n const hi = onAxis(z.from.max(z.to));\n if (!hi.greaterThan(lo)) return null;\n return (\n <path\n key={`zone-${z.color}-${onFace(lo)}-${onFace(hi)}`}\n d={arcPath(cx, cy, r, onFace(lo), onFace(hi))}\n fill=\"none\"\n stroke={z.color}\n strokeWidth={trackThickness}\n strokeLinecap=\"butt\"\n />\n );\n })}\n\n {r > 0 &&\n ticks?.map((tk) => {\n const at = tk.value.magnitude;\n const a = angleOf(at);\n const outer = pointAt(cx, cy, r, a);\n const inner = pointAt(cx, cy, r - trackThickness, a);\n const labelPt = pointAt(cx, cy, r - trackThickness - 8, a);\n return (\n <g key={`tick-${at}-${tk.label ?? \"\"}`}>\n <line\n x1={inner.x}\n y1={inner.y}\n x2={outer.x}\n y2={outer.y}\n stroke=\"var(--color-text-faint)\"\n strokeWidth={1}\n />\n {tk.label && (\n <text\n x={labelPt.x}\n y={labelPt.y}\n textAnchor=\"middle\"\n dominantBaseline=\"middle\"\n fontSize={9}\n fill=\"var(--color-text-faint)\"\n >\n {tk.label}\n </text>\n )}\n </g>\n );\n })}\n\n {r > 0 &&\n drawnInterval !== null &&\n ([\"lo\", \"hi\"] as const).map((end) => {\n const a = onFace(onAxis(drawnInterval[end]));\n const inner = pointAt(cx, cy, r - trackThickness / 2, a);\n const outer = pointAt(cx, cy, r + trackThickness / 2, a);\n return (\n <InstrumentBound\n key={end}\n end={end}\n x1={inner.x}\n y1={inner.y}\n x2={outer.x}\n y2={outer.y}\n />\n );\n })}\n\n {r > 0 && hasFigure && (\n <>\n <line\n x1={cx}\n y1={cy}\n x2={needle.x}\n y2={needle.y}\n stroke={needleColor}\n strokeWidth={2}\n strokeLinecap=\"round\"\n />\n <circle cx={cx} cy={cy} r={hubRadius} fill={needleColor} />\n </>\n )}\n\n <text\n x={cx}\n y={raised && figure !== null ? cy + figure.drop : cy + r * 0.55}\n textAnchor=\"middle\"\n fontSize={raised && figure !== null ? figure.size : 13}\n fontWeight={raised ? undefined : \"bold\"}\n fill={\n centreLabel === null\n ? \"var(--color-text-muted)\"\n : \"var(--color-text-primary)\"\n }\n >\n {centreLabel ?? NULL_DISPLAY}\n {held && centreLabel !== null && (\n <InstrumentHeldMark\n size={raised ? 7 : 6}\n figureSize={raised && figure !== null ? figure.size : 13}\n />\n )}\n </text>\n </svg>\n {tip}\n </Dial__Meter>\n );\n}\n\nconst Dial__Meter = styled.div`\n display: block;\n max-width: 100%;\n`;\n","import styled from \"styled-components\";\nimport { fitBox } from \"./fitBox\";\nimport { focusRing } from \"./focusRing\";\n\n/**\n * Props for {@link FilterChip}: its label, whether it is selected, an optional\n * count and the toggle handler.\n * Useful for letting the operator switch one filter term on or off. Used by\n * {@link FilterChip}.\n *\n * @category FilterList\n */\nexport interface FilterChipProps {\n /** The chip's text, which is also its accessible name. */\n label: string;\n /** Whether the filter is on. Drives `aria-pressed` and the filled look. */\n selected: boolean;\n /** An optional count drawn after the label, such as how many rows the filter matches. */\n count?: number;\n /** Called on press; flip `selected` here. */\n onToggle: () => void;\n}\n\n/**\n * A pill-shaped toggle `button` for one filter term, with `aria-pressed`\n * following `selected` and an optional count after the label. Useful for\n * letting the operator switch one filter term on or off. Used by\n * {@link useRowFilter} for each contributed term, and by research and development. Use it\n * directly for a filter row of your own.\n *\n * @example\n * ```tsx\n * import { useState } from \"react\";\n * import { Cluster, FilterChip } from \"@ksp-gonogo/ui-kit\";\n *\n * const BODIES = [\"Kerbin\", \"Mun\", \"Minmus\"] as const;\n *\n * function BodyFilter({ countFor }: { countFor: (body: string) => number }) {\n * const [shown, setShown] = useState<ReadonlySet<string>>(new Set());\n * const toggle = (body: string) =>\n * setShown((prev) => {\n * const next = new Set(prev);\n * if (!next.delete(body)) next.add(body);\n * return next;\n * });\n * return (\n * <Cluster justify=\"start\" wrap role=\"group\" aria-label=\"Filters\">\n * {BODIES.map((body) => (\n * <FilterChip\n * key={body}\n * label={body}\n * selected={shown.has(body)}\n * count={countFor(body)}\n * onToggle={() => toggle(body)}\n * />\n * ))}\n * </Cluster>\n * );\n * }\n * ```\n *\n * @category FilterList\n */\nexport function FilterChip({\n label,\n selected,\n count,\n onToggle,\n}: FilterChipProps) {\n return (\n <ChipButton\n type=\"button\"\n $selected={selected}\n onClick={onToggle}\n aria-pressed={selected}\n >\n <span>{label}</span>\n {count !== undefined && <Count>{count}</Count>}\n </ChipButton>\n );\n}\n\nconst ChipButton = styled.button<{ $selected: boolean }>`\n ${fitBox(\"chip\")}\n display: inline-flex;\n align-items: center;\n gap: var(--gap-glyph-control);\n padding: var(--inset-control-small);\n /* --radius-pill keeps the stadium shape through a padding change. */\n border-radius: var(--radius-pill);\n font-size: var(--font-size-compact);\n font-weight: 600;\n /* Sentence case: a real toggle button rather than a Badge, and its label is not the kit's to shout. */\n cursor: pointer;\n transition:\n background var(--duration-fast),\n border-color var(--duration-fast),\n color var(--duration-fast);\n\n background: ${({ $selected }) =>\n $selected ? \"var(--color-accent-fg)\" : \"transparent\"};\n color: ${({ $selected }) =>\n $selected ? \"var(--color-text-inverse)\" : \"var(--color-text-dim)\"};\n border: 1px solid\n ${({ $selected }) =>\n $selected ? \"var(--color-accent-fg)\" : \"var(--color-border-subtle)\"};\n\n &:hover {\n border-color: var(--color-accent-fg);\n color: ${({ $selected }) =>\n $selected ? \"var(--color-text-inverse)\" : \"var(--color-text-primary)\"};\n }\n\n ${focusRing}\n\n @media (pointer: coarse) {\n min-height: var(--touch-target);\n }\n`;\n\nconst Count = styled.span`\n font-variant-numeric: tabular-nums;\n font-size: var(--font-size-caption);\n opacity: 0.75;\n`;\n","import { type InputHTMLAttributes, useRef } from \"react\";\nimport styled from \"styled-components\";\nimport { IconButton } from \"./Button\";\nimport { Input } from \"./Form\";\nimport { CloseIcon } from \"./Icons\";\n\n/**\n * The props of {@link SearchBox}. Useful for letting the operator narrow a long\n * list by typing. Taken by {@link SearchBox}.\n *\n * @category Form\n */\nexport interface SearchBoxProps\n extends Omit<\n InputHTMLAttributes<HTMLInputElement>,\n \"type\" | \"value\" | \"onChange\"\n > {\n /** The text in the box. */\n value: string;\n /** Called with the new text on each keystroke, and with `\"\"` when cleared. */\n onChange: (next: string) => void;\n /** The clear control's accessible name. Defaults to \"Clear search\". */\n clearLabel?: string;\n}\n\n/**\n * A search box with the kit's own clear control, shown while there is text to\n * clear. Clearing hands focus back to the field. Useful for letting the\n * operator narrow a long list by typing. Used by the target picker.\n *\n * @category Form\n */\nexport function SearchBox({\n value,\n onChange,\n clearLabel = \"Clear search\",\n className,\n ...rest\n}: Readonly<SearchBoxProps>) {\n const field = useRef<HTMLInputElement>(null);\n return (\n <SearchBox__Root className={className}>\n <SearchBox__Field\n {...rest}\n ref={field}\n type=\"search\"\n value={value}\n onChange={(event) => onChange(event.target.value)}\n />\n {value !== \"\" && (\n <SearchBox__ClearSlot>\n <IconButton\n type=\"button\"\n aria-label={clearLabel}\n onClick={() => {\n onChange(\"\");\n field.current?.focus();\n }}\n >\n <CloseIcon size=\"var(--icon-size-control)\" />\n </IconButton>\n </SearchBox__ClearSlot>\n )}\n </SearchBox__Root>\n );\n}\n\nconst SearchBox__Root = styled.div`\n position: relative;\n display: flex;\n align-items: center;\n`;\n\nconst SearchBox__Field = styled(Input)`\n && {\n padding-right: var(--inset-field-clearable-end);\n }\n`;\n\nconst SearchBox__ClearSlot = styled.span`\n position: absolute;\n right: 0;\n display: inline-flex;\n`;\n","import { type ReactNode, useId, useState } from \"react\";\nimport { Cluster } from \"./Cluster\";\nimport type {\n ComponentSlotRegistry,\n ComponentSlotSegment,\n} from \"./contributions\";\nimport { useContributions } from \"./contributionsRead\";\nimport { FilterChip } from \"./FilterChip\";\nimport { Field, FieldLabel } from \"./Form\";\nimport { SearchBox } from \"./SearchBox\";\nimport { Stack } from \"./Stack\";\n\n/**\n * A filter made by {@link useRowFilter}. Useful for narrowing a list to the\n * rows the operator typed or toggled. Test each row with `matches`. Its\n * control (a search box, then the contributed toggles under it) is not part of this object:\n * it renders above the list it narrows when the filter is passed to\n * {@link FilterRegion} or to `Panel`'s `panelFilter`.\n *\n * @category FilterList\n */\nexport interface RowFilter {\n /** True when the row's search text contains every selected term and the typed text. */\n matches: (searchText: string) => boolean;\n /** Whether anything is narrowing the list right now, for empty-state copy. */\n active: boolean;\n}\n\n/**\n * A declared segment whose contributions are plain search terms. `badges`, for\n * one, contributes a `BadgeEntry`, which cannot be substring-matched. Taken by\n * the `segment` option of {@link useRowFilter}.\n */\nexport type TermSegment = {\n [Segment in ComponentSlotSegment]: ComponentSlotRegistry[Segment] extends string\n ? Segment\n : never;\n}[ComponentSlotSegment];\n\n/**\n * Options for {@link useRowFilter}. Useful for describing the rows and terms\n * the operator filters by. Taken by {@link useRowFilter}.\n *\n * @category FilterList\n */\nexport interface UseRowFilterOptions {\n /**\n * The contribution segment to pull toggle terms from. Defaults to the\n * universal `filters`; override it only for a declared segment of your own\n * whose entries are search terms.\n */\n segment?: TermSegment;\n /** Accessible name for the search box. Defaults to \"Search\". */\n label?: string;\n /** Placeholder in the search box. Defaults to \"Filter...\". */\n placeholder?: string;\n}\n\n/**\n * The filter behind {@link FilterList}, for a host that renders its own rows,\n * such as a table that must keep its columns. Useful for letting the operator\n * narrow a list by typing or by toggling terms. Used by the experiments and\n * science data widgets.\n *\n * Selected toggle terms and the typed text all have to match: each is a\n * case-insensitive substring of the row's search text. Nothing selected and\n * nothing typed matches everything, and `active` is then false. The toggle\n * terms come from the widget's contributions, each term listed once. Place the\n * filter's control by passing the result to {@link FilterRegion} around the\n * list, or to `Panel`'s `panelFilter` for a filter over the whole body.\n *\n * @example\n * ```tsx\n * import {\n * EmptyState,\n * FilterRegion,\n * Stack,\n * Text,\n * useRowFilter,\n * } from \"@ksp-gonogo/ui-kit\";\n *\n * interface Subject {\n * id: string;\n * title: string;\n * biome: string;\n * }\n *\n * function SubjectList({ subjects }: { subjects: readonly Subject[] }) {\n * const filter = useRowFilter({ placeholder: \"Filter subjects...\" });\n * const shown = subjects.filter((s) =>\n * filter.matches(`${s.title} ${s.biome}`),\n * );\n *\n * return (\n * <FilterRegion filter={filter} fill>\n * {shown.length > 0 ? (\n * <Stack>\n * {shown.map((s) => (\n * <Text key={s.id}>{s.title}</Text>\n * ))}\n * </Stack>\n * ) : (\n * <EmptyState>\n * {filter.active ? \"Nothing matches the filter\" : \"No subjects yet\"}\n * </EmptyState>\n * )}\n * </FilterRegion>\n * );\n * }\n * ```\n *\n * @category FilterList\n */\nexport function useRowFilter({\n segment = \"filters\",\n label = \"Search\",\n placeholder = \"Filter...\",\n}: UseRowFilterOptions = {}): RowFilter {\n const terms = useContributions(segment);\n // Distinct terms, in contribution order: two providers can land the same word, and a doubled toggle is just noise.\n const uniqueTerms = [...new Set(terms)];\n\n const [selected, setSelected] = useState<ReadonlySet<string>>(\n () => new Set(),\n );\n const [typed, setTyped] = useState(\"\");\n const searchId = useId();\n\n const toggle = (term: string) => {\n setSelected((prev) => {\n const next = new Set(prev);\n if (next.has(term)) next.delete(term);\n else next.add(term);\n return next;\n });\n };\n\n const needles = [...selected, typed]\n .filter((s) => s.length > 0)\n .map((s) => s.toLowerCase());\n\n const control = (\n <Stack gap=\"related-packed\">\n <Field>\n <FieldLabel htmlFor={searchId}>{label}</FieldLabel>\n <SearchBox\n id={searchId}\n value={typed}\n placeholder={placeholder}\n onChange={setTyped}\n />\n </Field>\n {uniqueTerms.length > 0 && (\n <Cluster\n justify=\"start\"\n gap=\"related-packed\"\n wrap\n role=\"group\"\n aria-label=\"Filters\"\n >\n {uniqueTerms.map((term) => (\n <FilterChip\n key={term}\n label={term}\n selected={selected.has(term)}\n onToggle={() => toggle(term)}\n />\n ))}\n </Cluster>\n )}\n </Stack>\n );\n\n const filter: RowFilter = {\n matches: (searchText: string) => {\n const haystack = searchText.toLowerCase();\n return needles.every((needle) => haystack.includes(needle));\n },\n active: needles.length > 0,\n };\n CONTROLS.set(filter, control);\n return filter;\n}\n\nconst CONTROLS = new WeakMap<RowFilter, ReactNode>();\n\n/**\n * The control of a filter made by {@link useRowFilter}, which the operator\n * types into or toggles. Used by {@link Panel} and {@link FilterRegion}, which\n * place it.\n */\nexport function filterControlOf(filter: RowFilter): ReactNode {\n return CONTROLS.get(filter) ?? null;\n}\n\n/**\n * The props of {@link FilterRegion}. Useful for placing the filter control the\n * operator types into above a list. Taken by {@link FilterRegion}.\n *\n * @category FilterList\n */\nexport interface FilterRegionProps {\n /** The filter from {@link useRowFilter} whose control is drawn. */\n filter: RowFilter;\n /** The list the filter narrows, drawn under its control. */\n children?: ReactNode;\n /** Take the remaining height, for a region whose list scrolls. */\n fill?: boolean;\n}\n\n/**\n * A filtered list with its filter control above it: the way to place a\n * {@link useRowFilter} control inside a widget body. Useful for letting the\n * operator narrow a list. Used by the science data widget's tabs. It does not filter the\n * children itself; filter them with the same `filter.matches`.\n *\n * @category FilterList\n */\nexport function FilterRegion({\n filter,\n children,\n fill = false,\n}: FilterRegionProps) {\n return (\n <Stack gap=\"related-dense\" fill={fill}>\n {filterControlOf(filter)}\n {children}\n </Stack>\n );\n}\n","import type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport styled from \"styled-components\";\nimport { useElementSize } from \"./useElementSize\";\n\n/**\n * The tone of an {@link EdgeCue}: `accent` for a port or mark that is lined up,\n * `warn` for one that is not. Useful for telling the operator, by colour alone,\n * whether what left the frame is where it should be. Used by {@link EdgeCue}.\n *\n * @category Layout\n */\nexport type EdgeCueTone = \"accent\" | \"warn\";\n\nconst EDGE_CUE_FILL: Readonly<Record<EdgeCueTone, string>> = {\n accent: \"var(--color-accent-fg)\",\n warn: \"var(--color-warn-mark)\",\n};\n\n/**\n * An arc of a circular frame's border lit in a tone, growing outward from\n * the border by a share of its full reach. Useful for telling the operator\n * that something drawn inside the frame has gone past its edge, and which way:\n * the lit arc sits at the direction it left by and thickens as it goes further.\n * Passed to the `edgeCue` prop of {@link FramedDisplay}, which draws it on a\n * `\"circle\"` frame and ignores it on any other.\n *\n * @category Layout\n */\nexport interface EdgeCue {\n /** The direction of the arc's middle, in degrees turning counter-clockwise from the frame's right-hand point, so 90 is straight up. */\n angle: number;\n /** The arc's tone: `accent` lights it in the app's accent, `warn` in the warning mark. */\n tone: EdgeCueTone;\n /** How far the arc has grown outward from the border, from 0 (a lit border) to 1 (its full reach). Outside that range it is held to it. */\n grow: number;\n /** The arc's length in degrees. Defaults to 90. */\n span?: number;\n}\n\n/**\n * Props for {@link FramedDisplay}. Any other `div` attribute passes through.\n * Useful for giving a diagram, plot or map a visible edge. Used by {@link\n * FramedDisplay}.\n *\n * @category Layout\n */\nexport interface FramedDisplayProps extends ComponentPropsWithoutRef<\"div\"> {\n /** The drawing the frame surrounds. */\n children?: ReactNode;\n /**\n * Adds an inner gutter between the frame and its contents, for content that\n * carries no margin of its own.\n */\n padded?: boolean;\n /**\n * A small label inlaid over the frame's top-left corner, naming the visual\n * (which frame a drawing is in, what a gauge reads) on the drawing itself.\n * Prefer it to a caption element beside the frame: a panel whose body holds\n * only this frame gives it a thinner inset when narrow, and a caption beside\n * it would cost that. The caption sets its own type (caption size, muted\n * colour), so pass bare text rather than a sized `Text`. Omitted, nothing is\n * drawn.\n */\n caption?: ReactNode;\n /**\n * A single line inlaid over the frame's bottom-left corner: a note or\n * status about what is drawn (an axis warning, a data age). Set on the same\n * opaque backing as `caption`; its colour is the caller's, so a warning can\n * pass a toned `Text`. Omitted, nothing is drawn.\n */\n footer?: ReactNode;\n /**\n * The frame's outline. `\"rounded\"`, the default, is the rounded rectangle\n * that fills the room it is given. `\"circle\"` is a disc: the caller gives it\n * one side (a `width`, or a `height`) and it keeps the other equal, so the\n * disc is as large as the room that side allows. A circle draws no `strip`,\n * and its `caption` and `footer` sit centred on the top and bottom edges\n * instead of in the corners, which the circle cuts away.\n */\n shape?: FramedDisplayShape;\n /**\n * Lights an arc of the border, or several, in a tone, each growing outward\n * from the border; see {@link EdgeCue}. Drawn only on `shape=\"circle\"`. The\n * frame's own contents are still cut to the disc; the arcs are drawn outside\n * it, over the border and the room just beyond, so give the frame that room\n * in its layout. Omitted, nothing is drawn and the frame is laid out as it\n * was. An empty list also draws nothing but keeps the contents cut to the\n * disc, so a cue that comes and goes does not remount them.\n */\n edgeCue?: EdgeCue | readonly EdgeCue[];\n /**\n * A band along the frame's bottom edge, inside the same border, for a trend\n * of the figure drawn above it. It is never padded: its content runs to the\n * frame's inner edges, while `padded` insets only the drawing above. Size\n * the content to the band (it takes three tenths of the frame's height,\n * within a minimum and a maximum) rather than giving the band a height. Omitted, the\n * frame is the one drawing.\n */\n strip?: ReactNode;\n}\n\n/**\n * The outline of a {@link FramedDisplay}: a rounded rectangle or a circle.\n * Useful for choosing how a drawing is cut, such as a magnifier view that\n * reads as a lens. Taken by the `shape` prop of {@link FramedDisplay}.\n *\n * @category Layout\n */\nexport type FramedDisplayShape = \"rounded\" | \"circle\";\n\nconst STRIP_MIN_PX = 24;\nconst STRIP_MAX_PX = 96;\n\n/**\n * A bordered, sunken box for visual content (SVG diagrams, canvases, maps,\n * gauges) inside an ordinary padded panel body, so readouts beside it keep the\n * standard inset and the diagram has a visible edge. Useful for giving the\n * operator's diagram or plot a clear boundary. Used by the graph and docking\n * HUD widgets. A direct `svg` or `canvas` child fills the frame.\n *\n * It does not scroll or size itself: the caller decides how much room the\n * visual gets. It grows with `flex: 1`, so a tall flex sibling squeezes it;\n * overlay a control on the frame instead of placing it beside. The visual fills\n * to the rounded edge unless `padded`. A drawing and its trend share one frame\n * through `strip`. With `shape=\"circle\"` it is a disc cut from a square the\n * caller sizes by one side.\n *\n * @category Layout\n */\nexport function FramedDisplay({\n children,\n padded,\n caption,\n footer,\n strip,\n shape = \"rounded\",\n edgeCue,\n ...rest\n}: FramedDisplayProps) {\n const circle = shape === \"circle\";\n const cues = !circle || edgeCue === undefined ? [] : [edgeCue].flat();\n const hasStrip =\n !circle && strip !== undefined && strip !== null && strip !== false;\n return (\n <FramedDisplay__Box\n $padded={padded && !hasStrip}\n $stacked={hasStrip}\n $circle={circle}\n $cued={cues.length > 0}\n data-shape={circle ? \"circle\" : undefined}\n {...rest}\n >\n {hasStrip ? (\n <>\n <FramedDisplay__Main $padded={padded}>{children}</FramedDisplay__Main>\n <FramedDisplay__Strip data-framed-display-strip=\"\">\n {strip}\n </FramedDisplay__Strip>\n </>\n ) : circle && edgeCue !== undefined ? (\n <FramedDisplay__Clip>{children}</FramedDisplay__Clip>\n ) : (\n children\n )}\n {/* After the contents, so the arcs paint over them without a z-index. */}\n {cues.length > 0 && <FramedDisplay__Cues cues={cues} />}\n {caption !== undefined && caption !== null && (\n <FramedDisplay__Caption>{caption}</FramedDisplay__Caption>\n )}\n {footer !== undefined && footer !== null && (\n <FramedDisplay__Footer>{footer}</FramedDisplay__Footer>\n )}\n </FramedDisplay__Box>\n );\n}\n\nconst FramedDisplay__Box = styled.div<{\n $padded?: boolean;\n $stacked?: boolean;\n $circle?: boolean;\n $cued?: boolean;\n}>`\n position: relative;\n display: flex;\n flex-direction: ${({ $stacked }) => ($stacked ? \"column\" : \"row\")};\n min-height: 0;\n min-width: 0;\n /* Sunken: the visual sits inside the panel surface rather than floating on it. */\n background: var(--color-surface-sunken);\n border: 1px solid var(--color-border-subtle);\n /* The container answers with a corner proportioned to the box, so a frame never needs to know its own size. */\n border-radius: ${({ $circle }) =>\n $circle ? \"50%\" : \"var(--radius-display-frame)\"};\n /* A cued circle clips its contents in a layer of its own, so the cue can grow outward past the border. */\n overflow: ${({ $cued }) => ($cued ? \"visible\" : \"hidden\")};\n padding: ${({ $padded }) => ($padded ? \"var(--inset-framed-display)\" : \"0\")};\n ${({ $circle }) =>\n $circle ? \"aspect-ratio: 1 / 1; flex: none; align-self: center;\" : \"\"}\n\n /* A child SVG or canvas fills the frame instead of its intrinsic 300x150. */\n & > svg,\n & > canvas {\n display: block;\n width: 100%;\n height: 100%;\n }\n`;\n\n/** A cued circle's contents, cut to the disc inside the border. */\nconst FramedDisplay__Clip = styled.div`\n position: relative;\n flex: 1;\n display: flex;\n min-height: 0;\n min-width: 0;\n border-radius: var(--radius-circle);\n overflow: hidden;\n\n & > svg,\n & > canvas {\n display: block;\n width: 100%;\n height: 100%;\n }\n`;\n\n/** Where the cue's arcs sit: the room beyond the border, in percent of the frame's side. */\nconst CUE_ROOM = 12;\n/** The arc's thickness when it first lights and at full reach, in widths of the frame's own border. */\nconst CUE_MIN_BORDERS = 1;\nconst CUE_MAX_BORDERS = 3;\n/** The frame's own border, pixels. */\nconst FRAME_BORDER_PX = 1;\n/** The size of one border in a frame of 200 px, before the cue has been measured. */\nconst DEFAULT_BORDER_UNITS = (100 * FRAME_BORDER_PX) / 200;\n\nconst toRad = (deg: number) => (deg * Math.PI) / 180;\n\n/**\n * The path of one arc, as an annular sector in a 100-unit square with the\n * border on the circle of radius 50. `borderUnits` is the frame's border in\n * those units, which the arc's thickness is a multiple of.\n */\nexport function edgeCuePath(\n cue: EdgeCue,\n borderUnits = DEFAULT_BORDER_UNITS,\n): string {\n const span = Math.min(Math.max(cue.span ?? 90, 1), 359);\n const grow = Math.min(\n Math.max(Number.isFinite(cue.grow) ? cue.grow : 0, 0),\n 1,\n );\n const inner = 50;\n const borders = CUE_MIN_BORDERS + (CUE_MAX_BORDERS - CUE_MIN_BORDERS) * grow;\n const outer = 50 + borders * borderUnits;\n const a0 = toRad(cue.angle - span / 2);\n const a1 = toRad(cue.angle + span / 2);\n const at = (r: number, a: number) =>\n `${(50 + r * Math.cos(a)).toFixed(3)} ${(50 - r * Math.sin(a)).toFixed(3)}`;\n const large = span > 180 ? 1 : 0;\n // Counter-clockwise on screen is the sweep flag 0 with y down: out along the outer edge, back along the inner.\n return `M${at(inner, a0)}A${inner} ${inner} 0 ${large} 0 ${at(inner, a1)}L${at(outer, a1)}A${outer} ${outer} 0 ${large} 1 ${at(outer, a0)}Z`;\n}\n\nfunction FramedDisplay__Cues({ cues }: { cues: readonly EdgeCue[] }) {\n // The layer is wider than the frame by the room on each side; one border is a pixel of it.\n const { ref, size } = useElementSize<HTMLDivElement>({\n w: 100 + 2 * CUE_ROOM,\n h: 100 + 2 * CUE_ROOM,\n });\n const unitsPerPx = (100 + 2 * CUE_ROOM) / Math.max(size.w, 1);\n const borderUnits = FRAME_BORDER_PX * unitsPerPx;\n return (\n <div\n ref={ref}\n aria-hidden=\"true\"\n style={{\n position: \"absolute\",\n left: `${-CUE_ROOM}%`,\n top: `${-CUE_ROOM}%`,\n width: `${100 + 2 * CUE_ROOM}%`,\n height: `${100 + 2 * CUE_ROOM}%`,\n pointerEvents: \"none\",\n }}\n >\n <svg\n aria-hidden=\"true\"\n data-edge-cues=\"\"\n viewBox={`${-CUE_ROOM} ${-CUE_ROOM} ${100 + 2 * CUE_ROOM} ${100 + 2 * CUE_ROOM}`}\n style={{\n display: \"block\",\n width: \"100%\",\n height: \"100%\",\n overflow: \"visible\",\n }}\n >\n {cues.map((cue) => (\n <path\n key={`${cue.angle}-${cue.tone}`}\n data-edge-cue=\"\"\n d={edgeCuePath(cue, borderUnits)}\n fill={EDGE_CUE_FILL[cue.tone]}\n />\n ))}\n </svg>\n </div>\n );\n}\n\n/** The drawing above a strip: it takes the height the strip leaves, and carries the frame's gutter itself so the strip stays flush. */\nconst FramedDisplay__Main = styled.div<{ $padded?: boolean }>`\n flex: 7 1 0;\n display: flex;\n min-height: 0;\n min-width: 0;\n padding: ${({ $padded }) => ($padded ? \"var(--inset-framed-display)\" : \"0\")};\n\n & > svg,\n & > canvas {\n display: block;\n width: 100%;\n height: 100%;\n }\n`;\n\n/**\n * Three parts in ten of the frame's height, floored so a trend stays legible\n * in a short frame and capped so it never outgrows the drawing it sits under.\n * A grow share, not a percentage height: a percentage does not resolve inside\n * a frame that is itself a stretched flex item, and the band then sizes to its\n * content.\n */\nconst FramedDisplay__Strip = styled.div`\n flex: 3 1 0;\n display: flex;\n min-height: ${STRIP_MIN_PX}px;\n max-height: ${STRIP_MAX_PX}px;\n min-width: 0;\n overflow: hidden;\n`;\n\n/*\n * An opaque backing in the frame's own surface, not a translucent scrim:\n * muted text over a scrim that lets a pale drawing through falls under 4.5:1.\n * Padded like GraphNotice's overlay pill, but pinned to the\n * frame's top-left rather than its bottom-left.\n *\n * Local sibling ordering inside this frame's own stacking context (the\n * caption over the drawing it labels), not app-global chrome, so the literal\n * z-index stays off the app's named rungs.\n */\nconst FramedDisplay__Caption = styled.div`\n position: absolute;\n top: var(--offset-frame-caption-top);\n left: var(--offset-frame-caption-left);\n z-index: 1;\n padding: var(--inset-notice-pill);\n border-radius: var(--radius-regular);\n /* The smallest rung, flush, so the label covers as little of the drawing as it can. */\n font-size: var(--font-size-caption);\n line-height: var(--line-height-flush);\n color: var(--color-text-muted);\n background: var(--color-surface-sunken);\n pointer-events: none;\n\n /* A circle cuts the corners away, so its labels sit on the vertical axis. */\n [data-shape=\"circle\"] > & {\n left: 50%;\n transform: translateX(-50%);\n }\n`;\n\n/** The caption's twin on the bottom edge: same backing and type, mirrored offsets. */\nconst FramedDisplay__Footer = styled(FramedDisplay__Caption)`\n top: auto;\n bottom: var(--offset-frame-footer-bottom);\n left: var(--offset-frame-footer-left);\n`;\n","import type { HTMLAttributes, ReactNode } from \"react\";\nimport styled, { css } from \"styled-components\";\nimport { RADIUS_VAR } from \"./scales\";\n\n/**\n * Where a {@link GraphNotice} sits relative to its graph: `\"overlay\"` over the\n * graph's bottom-left corner, `\"center\"` over its middle, `\"inline\"` as a row\n * below it, `\"beside\"` as a column to its right. Useful for keeping a notice\n * from covering what the operator is reading on the graph. Returned by\n * {@link placeGraphNotice} and taken by {@link GraphNotice}.\n *\n * @category LineGraph\n */\nexport type GraphNoticePlacement = \"overlay\" | \"center\" | \"inline\" | \"beside\";\n\n/**\n * The measured space a graph and its notice share, and whether the plot draws\n * anything a notice could cover. Useful for choosing where a notice sits\n * without hiding the operator's data. Taken by {@link placeGraphNotice}.\n *\n * @category LineGraph\n */\nexport interface GraphNoticeSpace {\n /** Width of the area the graph and its notice share, in CSS pixels. */\n width: number;\n /** Height of that area, in CSS pixels. */\n height: number;\n /** The plot draws a trace, a curve or a layer, so an overlay would sit on data. */\n plotHasData: boolean;\n}\n\n/** Smallest empty plot that still has room for a pill laid over it. */\nconst OVERLAY_MIN = { width: 160, height: 72 } as const;\n\n/** A shared area at least this many times wider than tall puts the notice at the side, where a row below would take a large share of its height. */\nconst BESIDE_ASPECT = 2.5;\n\n/** Narrowest shared area where a side column leaves the plot a usable width. */\nconst BESIDE_MIN_WIDTH = 420;\n\n/**\n * The placement for a graph's notice, decided from the measured space the graph\n * and notice share. Useful for keeping a degraded-state message from covering\n * the operator's data. Used by the graph widget.\n *\n * An empty plot with room takes it over its middle, since nothing is underneath\n * to cover. Otherwise it goes beside a wide, short graph, where a row below\n * would cost the plot a large share of its height, and below everything else.\n *\n * @category LineGraph\n */\nexport function placeGraphNotice({\n width,\n height,\n plotHasData,\n}: GraphNoticeSpace): GraphNoticePlacement {\n if (\n !plotHasData &&\n width >= OVERLAY_MIN.width &&\n height >= OVERLAY_MIN.height\n ) {\n return \"center\";\n }\n if (width >= BESIDE_MIN_WIDTH && width >= height * BESIDE_ASPECT) {\n return \"beside\";\n }\n return \"inline\";\n}\n\n/**\n * Props for {@link GraphNotice}.\n * Useful for telling the operator why a graph is incomplete. Used by {@link\n * GraphNotice}.\n *\n * @category LineGraph\n */\nexport interface GraphNoticeProps extends HTMLAttributes<HTMLDivElement> {\n /** The notice's words. */\n children?: ReactNode;\n /**\n * `overlay` pins the pill to the bottom-left corner over the graph (pair with\n * a `position: relative` ancestor); `center` pins it to the\n * middle of that ancestor instead. `inline` sits as a flow\n * row below the graph, where an overlay would cover labels the caller draws\n * under it.\n * `beside` sits as a flex column to its right. {@link placeGraphNotice}\n * picks one from measured space.\n */\n placement: GraphNoticePlacement;\n}\n\nconst PLACEMENT_STYLES = {\n overlay: css`\n position: absolute;\n bottom: var(--offset-graph-notice-bottom);\n left: var(--offset-graph-notice-left);\n `,\n center: css`\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n max-width: 90%;\n text-align: center;\n `,\n inline: css`\n flex: 0 0 auto;\n align-self: flex-start;\n max-width: 100%;\n margin-top: var(--gap-sub-readout);\n `,\n beside: css`\n flex: 0 1 30%;\n align-self: flex-start;\n max-width: 40%;\n `,\n} as const;\n\n/**\n * A faint degraded-state pill for a graph widget (\"no reference data\", \"unknown\n * body\"). Useful for telling the operator why a graph is incomplete without\n * hiding the plot. Used by the graph widget. It sets `pointer-events: none`, so\n * it never intercepts the graph's clicks, and `role=\"status\"` by default;\n * override via `role`.\n *\n * @example Over a graph in a `position: relative` container\n * ```tsx\n * <div style={{ position: \"relative\" }}>\n * <Graph series={series} xDomain={[0, 600]} aria-label=\"Altitude trend\" />\n * {series.length === 0 && (\n * <GraphNotice placement=\"overlay\">no reference data</GraphNotice>\n * )}\n * </div>\n * ```\n *\n * @category LineGraph\n */\nexport function GraphNotice({\n placement,\n role = \"status\",\n children,\n ...rest\n}: GraphNoticeProps) {\n return (\n <GraphNotice__Root $placement={placement} role={role} {...rest}>\n {children}\n </GraphNotice__Root>\n );\n}\n\nconst GraphNotice__Root = styled.div<{ $placement: GraphNoticePlacement }>`\n font-size: var(--font-size-compact);\n color: var(--color-text-faint);\n /* No surface token is translucent, so this scrim stays a raw value. */\n background: rgba(0, 0, 0, 0.7);\n padding: var(--inset-notice-pill);\n border-radius: ${RADIUS_VAR.regular};\n pointer-events: none;\n\n ${({ $placement }) => PLACEMENT_STYLES[$placement]}\n`;\n","import type { BadgeEntry } from \"@ksp-gonogo/sitrep-sdk\";\nimport { createContext, type ReactNode, useContext } from \"react\";\n\n// `BadgeEntry`, the entry type of every widget's `${componentId}.badges` slot, is declared in the sdk.\nexport type { BadgeEntry };\n\nconst PanelBadgesCtx = createContext<readonly BadgeEntry[] | null>(null);\n\n/**\n * Supplies the badges contributed to the current widget's\n * `${componentId}.badges` slot to the {@link Panel} inside it, which draws\n * them after its own `panelBadges`. The dashboard mounts it for every widget,\n * fed by {@link useWidgetBadges}; a widget never mounts it itself. Useful for\n * showing the operator the badges an Uplink adds to a widget it did not write.\n *\n * @category Panel\n */\nexport function PanelBadgesProvider({\n badges,\n children,\n}: {\n badges: readonly BadgeEntry[];\n children?: ReactNode;\n}) {\n return (\n <PanelBadgesCtx.Provider value={badges}>{children}</PanelBadgesCtx.Provider>\n );\n}\n\n/**\n * The badges contributed to the current widget's `${componentId}.badges` slot,\n * or `null` outside a dashboard. Useful for drawing those badges in a panel\n * header. Used by {@link Panel}.\n */\nexport function usePanelBadgesContext(): readonly BadgeEntry[] | null {\n return useContext(PanelBadgesCtx);\n}\n","import { useSyncExternalStore } from \"react\";\nimport {\n NO_STATUS_BREAKDOWN,\n type StatusBreakdownEntry,\n usePanelStatusStore,\n} from \"./PanelStatusStore\";\n\n// `getSnapshot` must return a referentially stable value or useSyncExternalStore loops.\nconst NO_SUBSCRIBE = (): (() => void) => () => {};\nconst EMPTY_BREAKDOWN_SNAPSHOT = (): readonly StatusBreakdownEntry[] =>\n NO_STATUS_BREAKDOWN;\n\n/**\n * The panel's per-severity status counts, worst first, one row per severity\n * present, or an empty list when nothing has contributed or there is no\n * {@link PanelStatusStore} above. Useful for drawing one status dot per severity\n * in the collapsed header the operator sees on a narrow tile. Used by\n * {@link Panel}.\n *\n * @category Panel\n */\nexport function useStatusBreakdown(): readonly StatusBreakdownEntry[] {\n const store = usePanelStatusStore();\n return useSyncExternalStore(\n store ? store.subscribe : NO_SUBSCRIBE,\n store ? store.getBreakdown : EMPTY_BREAKDOWN_SNAPSHOT,\n store ? store.getBreakdown : EMPTY_BREAKDOWN_SNAPSHOT,\n );\n}\n","import { useSyncExternalStore } from \"react\";\nimport { type StatusSummary, usePanelStatusStore } from \"./PanelStatusStore\";\n\n// Module-level so the no-store subscribe and snapshot functions keep one identity.\nconst NO_SUBSCRIBE = (): (() => void) => () => {};\nconst NULL_SUMMARY = (): StatusSummary | null => null;\n\n/**\n * The panel's winning status contribution (see {@link StatusSummary}), or\n * `null` when nothing has contributed or there is no {@link PanelStatusStore}\n * above. Useful for drawing the one summary badge the operator reads in a\n * panel's header. Used by {@link Panel}. Re-renders only when the winner\n * changes.\n *\n * @category Panel\n */\nexport function useStatusSummary(): StatusSummary | null {\n const store = usePanelStatusStore();\n return useSyncExternalStore(\n store ? store.subscribe : NO_SUBSCRIBE,\n store ? store.getSummary : NULL_SUMMARY,\n store ? store.getSummary : NULL_SUMMARY,\n );\n}\n","import {\n createContext,\n type RefObject,\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\n\n/**\n * How a panel header's aside is currently drawn: `full`, inline beside the\n * title, or `collapsed`, behind the status dots and the toggle that opens it.\n * Returned by {@link usePanelAsideSize}. Useful for drawing a panel's aside\n * differently once it collapses.\n *\n * @category Panel\n */\nexport type PanelAsideSize = \"full\" | \"collapsed\";\n\n/**\n * How much spare room the full aside needs, once collapsed, before it\n * re-expands. Collapsing reacts the instant content stops fitting; without this\n * margin a panel sitting exactly at the boundary flips on every measurement.\n */\nconst REEXPAND_MARGIN_PX = 24;\n\n/**\n * Whether the aside should be collapsed, given the row's available width and\n * the width the title and aside need side by side. The two directions have\n * different thresholds (see `REEXPAND_MARGIN_PX`). Useful for keeping the\n * operator's header aside from flickering between inline and collapsed. Used by\n * {@link Panel}'s header.\n *\n * A `0` (unmeasured) width holds the previous state rather than deciding\n * anything.\n *\n * `previousNeededWidth` is what the content needed on the last measurement. The\n * dead band guards against the room moving under unchanged content; once the\n * content itself changes width it is a new question, answered with no margin,\n * so an aside that collapsed for a badge that has since gone re-expands.\n *\n * `roomHasNarrowed` says whether the row has been narrower than it was at any\n * point since the aside collapsed. A boundary can only be flipped across by\n * room that moves both ways, so a row that has only grown is also answered\n * with no margin: a tile still easing out to its width as its aside arrives\n * collapses a hair short of a fit, and would otherwise stay collapsed at rest\n * with room for it.\n */\nexport function nextAsideCollapsed(\n prevCollapsed: boolean,\n availableWidth: number,\n neededWidth: number,\n previousNeededWidth?: number,\n roomHasNarrowed = true,\n): boolean {\n if (availableWidth <= 0 || neededWidth <= 0) return prevCollapsed;\n const contentChanged =\n previousNeededWidth !== undefined &&\n previousNeededWidth > 0 &&\n previousNeededWidth !== neededWidth;\n return prevCollapsed && !contentChanged && roomHasNarrowed\n ? !(availableWidth > neededWidth + REEXPAND_MARGIN_PX)\n : neededWidth > availableWidth;\n}\n\n/**\n * An element's natural (unconstrained) rendered width, measured off a clone.\n *\n * The live title and aside sit in a flex chain whose shrink-to-fit can resolve\n * far short of the content's real size exactly when the row runs out of room,\n * and a collapsed aside is laid out as the floating box, not the row. The clone\n * goes in beside the live element so it inherits the same font and contextual\n * selectors; `restyle` restates the aside's inline layout.\n *\n * `text`, when given, replaces the clone's content before measuring. The title\n * element's own live text can already be `useFittedTitle`'s compacted form\n * (the two hooks share no state), and measuring that would ask \"does the short\n * form fit\" instead of \"does the aside need to give the FULL form room\",\n * so a title that had already been shortened would report itself small enough\n * that the aside never collapsed to let it grow back.\n *\n * Inserted and removed in one synchronous call so nothing observes the clone.\n * Returns `0`, which `nextAsideCollapsed` treats as unmeasured, where nothing\n * is laid out (jsdom).\n */\nfunction measureNaturalElementWidth(\n el: HTMLElement | null,\n restyle: Partial<CSSStyleDeclaration> = {},\n text?: string,\n): number {\n const parent = el?.parentNode;\n if (!el || !parent) return 0;\n const clone = el.cloneNode(true) as HTMLElement;\n if (text !== undefined) clone.textContent = text;\n Object.assign(clone.style, {\n position: \"absolute\",\n visibility: \"hidden\",\n pointerEvents: \"none\",\n top: \"0\",\n left: \"0\",\n width: \"max-content\",\n minWidth: \"0\",\n maxWidth: \"none\",\n ...restyle,\n });\n clone.setAttribute(\"aria-hidden\", \"true\");\n parent.insertBefore(clone, el.nextSibling);\n const width = clone.getBoundingClientRect().width;\n parent.removeChild(clone);\n return width;\n}\n\n/**\n * The aside's inline layout, restated on its clone: while collapsed and open,\n * the live element is a padded, bordered column floating under the summary.\n */\nconst ASIDE_INLINE: Partial<CSSStyleDeclaration> = {\n flexDirection: \"row\",\n flexWrap: \"nowrap\",\n padding: \"0\",\n border: \"0\",\n};\n\n/** A computed length, or 0 for one that is not a plain number (jsdom). */\nfunction px(value: string): number {\n return Number.parseFloat(value) || 0;\n}\n\n/**\n * The measured-fit collapse `Panel.Header` runs to decide whether its aside\n * belongs inline or behind the dots and expand box. Useful for keeping an\n * aside visible to the operator whenever it fits. Used by {@link Panel}'s\n * header.\n *\n * `rowRef` is the header row: its content width is the room available.\n * `titleRef` is the rendered `Panel.Title`, and `asideRef` the\n * `[data-panel-aside-full]` box. What the two need side by side is the title's\n * natural width, the row's gap, the aside box's horizontal padding, and the\n * aside's natural width.\n *\n * `fullTitle`, when given, is measured in place of whatever text is currently\n * live in `titleRef`. `Panel.Title` runs its own, separate fit (`useFittedTitle`)\n * and may already be showing a compacted form; measuring that would ask\n * whether the short form fits rather than whether the aside must give way for\n * the full one, and a title that had already shortened would then report\n * itself small enough that the aside never collapsed, locking the short form\n * in for good.\n *\n * Content changes are read from a `MutationObserver`'s pending records after\n * each render rather than by comparing the `title` and `aside` nodes, which are\n * new on every render and would force a layout each time.\n */\nexport function useHeaderAsideFit(\n rowRef: RefObject<HTMLElement | null>,\n titleRef: RefObject<HTMLElement | null>,\n asideRef: RefObject<HTMLElement | null>,\n fullTitle?: string,\n): boolean {\n const [collapsed, setCollapsed] = useState(false);\n const collapsedRef = useRef(collapsed);\n collapsedRef.current = collapsed;\n const neededRef = useRef<number | undefined>(undefined);\n const availableRef = useRef<number | undefined>(undefined);\n const narrowedRef = useRef(false);\n const fullTitleRef = useRef(fullTitle);\n fullTitleRef.current = fullTitle;\n\n const recompute = useCallback(() => {\n const row = rowRef.current;\n if (!row) return;\n const rowStyle = getComputedStyle(row);\n const available =\n row.getBoundingClientRect().width -\n px(rowStyle.paddingLeft) -\n px(rowStyle.paddingRight);\n const title = measureNaturalElementWidth(\n titleRef.current,\n {},\n fullTitleRef.current,\n );\n const aside = measureNaturalElementWidth(asideRef.current, ASIDE_INLINE);\n const asideBox = asideRef.current?.closest<HTMLElement>(\n \"[data-panel-aside-expand]\",\n )?.parentElement;\n const asideBoxStyle = asideBox ? getComputedStyle(asideBox) : null;\n const needed =\n title === 0 || aside === 0\n ? title + aside\n : title +\n px(rowStyle.columnGap) +\n px(asideBoxStyle?.paddingLeft ?? \"\") +\n px(asideBoxStyle?.paddingRight ?? \"\") +\n aside;\n const was = collapsedRef.current;\n // An unmeasured row (a tile not laid out) is not a narrower one.\n const narrowed =\n available > 0 &&\n availableRef.current !== undefined &&\n available < availableRef.current;\n if (was && narrowed) narrowedRef.current = true;\n const next = nextAsideCollapsed(\n was,\n available,\n needed,\n neededRef.current,\n narrowedRef.current,\n );\n // A collapse the narrowing row caused starts out with the margin, and any other starts without it.\n if (next !== was) narrowedRef.current = next && narrowed;\n if (available > 0) availableRef.current = available;\n if (needed > 0) neededRef.current = needed;\n if (next !== collapsedRef.current) {\n collapsedRef.current = next;\n setCollapsed(next);\n }\n }, [rowRef, titleRef, asideRef]);\n\n const watched = useRef<{\n title: HTMLElement | null;\n aside: HTMLElement | null;\n observer: MutationObserver | null;\n }>({ title: null, aside: null, observer: null });\n\n // Runs after every render, and measures only when the elements were swapped or something inside them changed.\n useLayoutEffect(() => {\n const title = titleRef.current;\n const aside = asideRef.current;\n const w = watched.current;\n if (w.observer === null || w.title !== title || w.aside !== aside) {\n w.observer?.disconnect();\n w.title = title;\n w.aside = aside;\n w.observer =\n typeof MutationObserver === \"undefined\"\n ? null\n : new MutationObserver(() => recompute());\n for (const el of [title, aside]) {\n if (el) {\n w.observer?.observe(el, {\n subtree: true,\n childList: true,\n characterData: true,\n attributes: true,\n });\n }\n }\n recompute();\n return;\n }\n if (w.observer.takeRecords().length > 0) recompute();\n });\n\n useEffect(() => {\n const w = watched.current;\n return () => {\n w.observer?.disconnect();\n w.observer = null;\n };\n }, []);\n\n useEffect(() => {\n const row = rowRef.current;\n if (!row || typeof ResizeObserver === \"undefined\") return;\n const ro = new ResizeObserver(() => recompute());\n ro.observe(row);\n if (asideRef.current) ro.observe(asideRef.current);\n return () => ro.disconnect();\n }, [rowRef, asideRef, recompute]);\n\n return collapsed;\n}\n\nconst PanelAsideSizeContext = createContext<PanelAsideSize>(\"full\");\n\n/**\n * Carries `Panel.Header`'s collapse decision down to content inside\n * `panelAside`, so the content and the header agree on which state the aside\n * is in. Used by {@link Panel}'s header and read by {@link usePanelAsideSize}.\n */\nexport const PanelAsideSizeProvider = PanelAsideSizeContext.Provider;\n\n/**\n * Whether the panel header's aside is drawn `full` or `collapsed`, for content\n * inside `panelAside` that draws differently in each. The header decides and\n * this reads that decision, so the content always agrees with it. `full`\n * outside a `Panel.Header`. Useful for drawing a panel's aside differently once\n * it collapses.\n *\n * @category Panel\n */\nexport function usePanelAsideSize(): PanelAsideSize {\n return useContext(PanelAsideSizeContext);\n}\n","import type { StreamStatusValue } from \"@ksp-gonogo/sitrep-sdk\";\nimport {\n Children,\n type ComponentPropsWithoutRef,\n createContext,\n Fragment,\n forwardRef,\n isValidElement,\n type ReactElement,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useId,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport styled, { css } from \"styled-components\";\nimport { AugmentSlot, useWidgetSegmentBound } from \"./AugmentSlot\";\nimport { Badge } from \"./Badge\";\nimport { type BadgeFace, badgeFace } from \"./badgeFace\";\nimport { PanelDelayRail } from \"./CommandDelay/PanelDelayRail\";\nimport { FramedDisplay } from \"./FramedDisplay\";\nimport { fitBox, fitMask } from \"./fitBox\";\nimport { focusRing, focusRingInset } from \"./focusRing\";\nimport { GraphNotice } from \"./GraphNotice\";\nimport { gridToPixels } from \"./gridUnits\";\nimport { InactiveNotice, type PanelInactiveReason } from \"./InactiveNotice\";\nimport { LiveRegion } from \"./LiveRegion\";\nimport { type BadgeEntry, usePanelBadgesContext } from \"./PanelBadges\";\nimport { SECTION_FILL_ATTR, SECTION_FULL_ATTR, Section } from \"./Section\";\nimport { PanelStatusDot } from \"./status/PanelStatusDot\";\nimport type {\n StatusBreakdownEntry,\n StatusSummary,\n} from \"./status/PanelStatusStore\";\nimport {\n type Severity,\n severityFromStreamStatus,\n severityRank,\n} from \"./status/severity\";\nimport { formatStreamStatus, heldWord } from \"./status/streamStatusWord\";\nimport { useStatusBreakdown } from \"./status/useStatusBreakdown\";\nimport { useStatusContribution } from \"./status/useStatusContribution\";\nimport { useStatusSummary } from \"./status/useStatusSummary\";\nimport { Tooltip, useTooltip } from \"./Tooltip\";\nimport { titleText } from \"./titleText\";\nimport { TONE_LABEL } from \"./tone\";\nimport { useElementSize } from \"./useElementSize\";\nimport { useFittedTitle } from \"./useFittedTitle\";\nimport { PanelAsideSizeProvider, useHeaderAsideFit } from \"./usePanelAsideSize\";\nimport { filterControlOf, type RowFilter } from \"./useRowFilter\";\nimport { useKeyboardScrollable, useScrollerMetric } from \"./useScrollerMetric\";\nimport { VisuallyHidden } from \"./VisuallyHidden\";\n\ninterface PanelContextValue {\n scroller: HTMLElement | null;\n registerScroller: (el: HTMLElement | null) => void;\n}\n\nconst PanelCtx = createContext<PanelContextValue | null>(null);\n\n/**\n * The link between a panel's scrolling body and its edge glow: `Panel.Body`\n * registers the element that scrolls and `Panel.Glow` draws from it, whatever\n * their nesting order. Useful for a widget that builds its own panel from\n * `Panel` parts and still wants the operator to see which edge has more to\n * scroll to. Used by {@link Panel}; a hand-composed panel mounts it around both\n * parts.\n */\nexport function PanelContextProvider({ children }: { children?: ReactNode }) {\n const [scroller, setScroller] = useState<HTMLElement | null>(null);\n const value = useMemo(\n () => ({ scroller, registerScroller: setScroller }),\n [scroller],\n );\n return <PanelCtx.Provider value={value}>{children}</PanelCtx.Provider>;\n}\n\n/**\n * The per-panel providers a {@link Panel} mounts around its parts. Useful for\n * a widget that composes its own panel from `Panel` parts and needs the same\n * providers. Used by {@link Panel}.\n *\n * The delay-rail store is not here: a widget's commands register above the\n * `<Panel>` it returns, so that store is provided above the widget.\n */\nexport function PanelProviders({ children }: { children?: ReactNode }) {\n return <PanelContextProvider>{children}</PanelContextProvider>;\n}\n\n/**\n * What a `Section fill` resolves to inside the box that owns the leftover\n * height. A content basis (not `flex: 1`) lets two filling sections keep their\n * own heights and split only the spare room. It still shrinks, so a drawing\n * sized from a ResizeObserver can give room back, but only down to a floor: a\n * zero minimum let the sections around it squeeze its scroller to nothing, and\n * the body scrolls past the floor instead.\n */\nconst SECTION_FILL_RULE = `\n & > [${SECTION_FILL_ATTR}] {\n flex: 1 1 auto;\n min-height: var(--size-section-fill-floor);\n }\n`;\n\nexport const PanelContainer = styled.div<{\n $railTravels?: boolean;\n $hoverTitle?: boolean;\n}>`\n /* Chrome only: border, surface and clip. The inset is Panel.Body's and the glow is Panel.Glow's. */\n background: var(--color-surface-panel);\n /* A size container, so the popped-open aside sizes itself in cqw against the panel's width. */\n container-type: inline-size;\n border: 1px solid var(--color-border-subtle);\n border-radius: var(--radius-regular);\n /* Top only: the delay rail's band, reserved on every widget so a command in flight never pushes the title down. Sides and bottom stay zero so visual content can reach the chrome. */\n padding: var(--panel-rail-band) 0 0;\n /* When the rail travels with the header, the band is the sticky unit's first row instead. */\n ${({ $railTravels }) => ($railTravels ? \"padding-top: 0;\" : \"\")}\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n gap: 0;\n overflow: hidden;\n /* A hoverTitle panel is itself the tab stop, and the grid cell clips an outset ring, so the ring is drawn inside the edge. */\n ${({ $hoverTitle }) => ($hoverTitle ? \"position: relative;\" : \"\")}\n ${({ $hoverTitle }) => ($hoverTitle ? focusRingInset : \"\")}\n /* A hand-composed panel can put sections straight in here, so this box owns the leftover height. */\n ${SECTION_FILL_RULE}\n`;\n\nconst PanelTitle__Box = styled.h3`\n margin: 0;\n /* No top inset: PanelHeader__Row carries it, so the header pays for it once. */\n padding: var(--inset-panel-header);\n ${titleText}\n /* Flush, so the all-caps glyphs centre on the box the row aligns the aside against. */\n line-height: var(--line-height-flush);\n /* One line always: a wrapped title would push the aside down. */\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n`;\n\n/**\n * Props for `Panel.Title`, the heading of a panel, which shows the operator the\n * widget's name. Other `h3` attributes pass through. Taken by `Panel.Title` on\n * {@link Panel}. Useful for naming a widget on the operator's dashboard.\n *\n * @category Panel\n */\nexport interface PanelTitleProps\n extends Omit<ComponentPropsWithoutRef<\"h3\">, \"title\"> {\n /**\n * Shorter forms of this title, longest first, for tiles the full one will not\n * fit in.\n *\n * The widest form that fits the box is drawn. When a shorter form is\n * showing, the full title stays the accessible name and the hover tooltip.\n */\n compact?: string | readonly string[];\n}\n\n/**\n * A panel's title, drawn in the longest of its forms that fits the tile. When a\n * shorter form shows, the full title stays the accessible name and the hover\n * text. Useful for keeping the operator's heading for a widget readable at every\n * tile size. Used by {@link Panel} as `Panel.Title`.\n */\nexport const PanelTitle = forwardRef<HTMLHeadingElement, PanelTitleProps>(\n function PanelTitle({ compact, children, ...rest }, forwarded) {\n const own = useRef<HTMLHeadingElement | null>(null);\n // Candidates are measured by substituting their text into a clone, so only a string title can be compacted.\n const full = typeof children === \"string\" ? children : \"\";\n const forms =\n compact === undefined || full === \"\"\n ? EMPTY_COMPACT\n : typeof compact === \"string\"\n ? [compact]\n : compact;\n const { index, compacted } = useFittedTitle(own, full, forms);\n return (\n <Tooltip text={compacted ? full : undefined}>\n <PanelTitle__Box\n {...rest}\n ref={(node: HTMLHeadingElement | null) => {\n own.current = node;\n if (typeof forwarded === \"function\") {\n forwarded(node);\n return;\n }\n if (forwarded) forwarded.current = node;\n }}\n aria-label={compacted ? full : undefined}\n >\n {index === 0 ? children : forms[index - 1]}\n </PanelTitle__Box>\n </Tooltip>\n );\n },\n);\n\n/** Stable, so a title with no compact forms does not hand the fit hook a fresh array each render. */\nconst EMPTY_COMPACT: readonly string[] = [];\n\nconst PanelHeader__Row = styled.div`\n padding-top: var(--inset-panel-header-top);\n display: flex;\n /* Centred, which levels the collapsed dots and chevron on the single-line title. */\n align-items: center;\n justify-content: space-between;\n gap: var(--gap-panel-header);\n min-width: 0;\n /* Wraps so PanelToolbar's full basis starts its own line; the aside never wraps, because the title column absorbs the pressure first. */\n flex-wrap: wrap;\n /* Never shrink, or a short tile's body would overprint the title. */\n flex-shrink: 0;\n`;\n\nconst PanelHeader__Titles = styled.div`\n min-width: 0;\n /* A zero basis, so a long title shrinks beside the aside instead of wrapping it onto a second line; useFittedTitle measures the room this leaves. */\n flex-grow: 1;\n flex-shrink: 1;\n flex-basis: 0;\n display: flex;\n align-items: center;\n & > h3 {\n flex: 1 1 auto;\n min-width: 0;\n }\n`;\n\n/**\n * An invisible, zero-width badge beside the title, so the row is always as\n * tall as a badge and one arriving in the aside fills height that was already\n * there. Its line is a generated space, so the panel's text content stays the\n * widget's own.\n */\nconst PanelHeader__Strut = styled.span`\n display: flex;\n flex: 0 0 0;\n width: 0;\n overflow: hidden;\n visibility: hidden;\n & > *::before {\n content: \"\\\\00a0\";\n }\n`;\n\nconst PanelHeader__Aside = styled.div`\n display: flex;\n align-items: center;\n gap: var(--gap-panel-aside);\n /* Never grows or wraps: an aside that stops fitting collapses to the dots. */\n justify-content: flex-end;\n flex-shrink: 0;\n /* Mirrors PanelTitle's inset so the badges line up with the title. */\n padding: var(--inset-panel-header);\n`;\n\n/**\n * The aside's collapse box. While the aside fits it shows inline; once\n * `$collapsed` is true it swaps to the per-severity status dots plus a chevron,\n * and the full aside (badges and controls) floats open on toggle. `$collapsed`\n * is a measured fit from `useHeaderAsideFit`, not a width breakpoint, so a\n * short title keeps its aside on a narrow panel.\n */\nconst PanelAsideExpand = styled.details<{ $collapsed?: boolean }>`\n position: relative;\n margin: 0;\n display: flex;\n align-items: center;\n /* Drops the ::details-content box, which otherwise breaks this element's shrink-to-fit sizing. */\n &::details-content {\n display: contents;\n }\n /* Exactly its content wide: the inline aside, or the dots summary once collapsed. */\n flex: 0 0 auto;\n\n & > summary {\n /* Wide default: no collapsed affordance, the aside just shows inline. */\n display: none;\n align-items: center;\n gap: var(--gap-panel-aside);\n list-style: none;\n cursor: pointer;\n /* Lands the dots on the title's cap band rather than its line box centre. */\n transform: translateY(-1px);\n /* Panel sets no foreground, so the currentColor chevron needs one. */\n color: var(--color-text-dim);\n }\n & > summary {\n ${focusRing}\n }\n & > summary::-webkit-details-marker {\n display: none;\n }\n & > summary [data-panel-aside-chevron] {\n /* A CSS caret, not an icon, so the header stays out of every widget's SVG queries. Points down closed. */\n flex: 0 0 auto;\n width: 6px;\n height: 6px;\n /* Extra space before the chevron only: the rotated box's corner eats into the gap. */\n margin-left: var(--gap-panel-aside);\n border-right: 1.5px solid currentColor;\n border-bottom: 1.5px solid currentColor;\n /* The rotation leaves the ink centroid 1.4px low; the lift centres it on the dots. */\n transform: translateY(-1.4px) rotate(45deg);\n transition: transform var(--duration-base) var(--ease-standard);\n }\n &[open] > summary [data-panel-aside-chevron] {\n /* Points up when open; the centroid moves above centre, so the lift flips sign. */\n transform: translateY(1.4px) rotate(225deg);\n }\n\n & > [data-panel-aside-full] {\n /* Wide default: the full aside shows inline whatever the [open] state. */\n display: flex;\n align-items: center;\n justify-content: flex-end;\n gap: var(--gap-panel-aside);\n flex-wrap: wrap;\n min-width: 0;\n }\n\n ${({ $collapsed }) =>\n $collapsed &&\n css`\n & > summary {\n display: inline-flex;\n }\n /* Hidden rather than display: none, so useHeaderAsideFit's clone measurement sees it as it sees the inline state. */\n &:not([open]):not([data-hovering]) > [data-panel-aside-full] {\n position: absolute;\n top: 0;\n right: 0;\n visibility: hidden;\n pointer-events: none;\n }\n /* Collapsed and open, or held open by the pointer: floats over the body so its controls do not reflow the panel. */\n &[open] > [data-panel-aside-full],\n &[data-hovering] > [data-panel-aside-full] {\n position: absolute;\n top: calc(100% + var(--offset-popover));\n right: 0;\n /* Widget-internal stacking above the header, off the app-global z ladder. */\n z-index: 3;\n flex-direction: column;\n align-items: stretch;\n justify-content: flex-start;\n flex-wrap: nowrap;\n /* A real floor so a control has room, capped at the panel width. */\n min-width: min(14rem, 90cqw);\n max-width: 90cqw;\n padding: var(--inset-popover);\n background: var(--color-surface-panel);\n border: 1px solid var(--color-border-subtle);\n border-radius: var(--radius-regular);\n box-shadow: var(--shadow-popover-drop)\n rgba(0, 0, 0, 0.35);\n }\n `}\n`;\n\n/** How long the pointer may spend crossing from the summary to the floating menu before the menu closes. */\nconst MENU_CROSSING_MS = 120;\n\n/** Every contributor's words under its severity, worst first, or `null` where there are none to say. */\nfunction describeBreakdown(\n breakdown: readonly StatusBreakdownEntry[],\n): string | null {\n const lines = breakdown.map((e) =>\n e.labels.length === 0\n ? `${e.count} ${TONE_LABEL[e.severity]}`\n : `${TONE_LABEL[e.severity]}: ${e.labels.join(\", \")}`,\n );\n return lines.length === 0 ? null : lines.join(\"\\n\");\n}\n\n/**\n * The row at the top of a panel: its title and an optional right-hand aside.\n * Useful for keeping a widget's controls and badges beside its title in a wide\n * tile and its status in view in a narrow one. Used by {@link Panel} as\n * `Panel.Header`.\n *\n * When the title and aside no longer fit side by side, the aside collapses to\n * the panel's per-severity status dots (worst first) plus a chevron, and the\n * full aside floats open on toggle. A hand-composed header gets this too.\n */\nexport function PanelHeader({\n title,\n compactTitle,\n aside,\n toolbar,\n ...rest\n}: Omit<ComponentPropsWithoutRef<\"div\">, \"title\"> & {\n title?: ReactNode;\n /** Shorter forms of `title`, longest first. See {@link PanelTitleProps}. */\n compactTitle?: string | readonly string[];\n aside?: ReactNode;\n /**\n * A row of controls on its own line below the title. See `Panel.Toolbar`.\n */\n toolbar?: ReactNode;\n}) {\n const breakdown = useStatusBreakdown();\n\n // `rowRef` is the room available to title and aside together; `titleRef` and `asideFullRef` are what they need. jsdom never measures, so it always sees the wide default.\n const rowRef = useRef<HTMLDivElement>(null);\n const titleRef = useRef<HTMLHeadingElement>(null);\n const asideFullRef = useRef<HTMLDivElement>(null);\n const collapsed = useHeaderAsideFit(\n rowRef,\n titleRef,\n asideFullRef,\n typeof title === \"string\" ? title : undefined,\n );\n\n /**\n * The `<details>` is a disclosure only while collapsed. Inline it is forced\n * open, so assistive tech is never told that badges on screen are hidden\n * behind a trigger that does not exist. Leaving the collapsed state drops the\n * operator's open choice, so a panel that narrows again starts closed.\n */\n const [openWhileCollapsed, setOpenWhileCollapsed] = useState(false);\n /*\n * The pointer holds the menu open without touching `open`, so what a screen\n * reader is told about the disclosure follows a press or a key and never a\n * hover. A touch never sets it: a tap pins the menu through the summary.\n */\n const [hovering, setHovering] = useState(false);\n const leaveTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n const expandRef = useRef<HTMLDetailsElement>(null);\n const summaryRef = useRef<HTMLElement>(null);\n const cancelLeave = useCallback(() => {\n if (leaveTimer.current !== null) clearTimeout(leaveTimer.current);\n leaveTimer.current = null;\n }, []);\n useEffect(() => {\n if (!collapsed) {\n setOpenWhileCollapsed(false);\n setHovering(false);\n }\n }, [collapsed]);\n useEffect(() => cancelLeave, [cancelLeave]);\n\n const menuShown = collapsed && (openWhileCollapsed || hovering);\n useEffect(() => {\n if (!menuShown) return;\n const onKey = (event: globalThis.KeyboardEvent) => {\n if (event.key !== \"Escape\") return;\n // Focus elsewhere, such as in a dialog opened over the panel, owns the key.\n if (!expandRef.current?.contains(document.activeElement)) return;\n event.stopPropagation();\n cancelLeave();\n setHovering(false);\n setOpenWhileCollapsed(false);\n summaryRef.current?.focus();\n };\n const onPress = (event: PointerEvent) => {\n if (expandRef.current?.contains(event.target as Node)) return;\n cancelLeave();\n setHovering(false);\n setOpenWhileCollapsed(false);\n };\n document.addEventListener(\"keydown\", onKey, true);\n document.addEventListener(\"pointerdown\", onPress, true);\n return () => {\n document.removeEventListener(\"keydown\", onKey, true);\n document.removeEventListener(\"pointerdown\", onPress, true);\n };\n }, [menuShown, cancelLeave]);\n\n /*\n * The summary's words for keyboard focus, and for a menu that is not showing:\n * while the menu is up it shows each badge with its own tip, so the summary's\n * tip steps aside rather than make two surfaces for one thing. The pointer\n * never opens it, the menu is what a hover opens.\n */\n const description = collapsed ? describeBreakdown(breakdown) : null;\n const { anchor: summaryTip, tip: summaryTipBody } = useTooltip(\n menuShown ? null : description,\n );\n\n return (\n /* `data-panel-header` is a stable targeting hook. */\n <PanelHeader__Row ref={rowRef} data-panel-header=\"\" {...rest}>\n <PanelHeader__Titles>\n {title !== undefined && (\n <PanelTitle ref={titleRef} compact={compactTitle}>\n {title}\n </PanelTitle>\n )}\n <PanelHeader__Strut aria-hidden=\"true\">\n <Badge>{null}</Badge>\n </PanelHeader__Strut>\n </PanelHeader__Titles>\n {aside !== undefined && (\n <PanelHeader__Aside>\n {/* A native `<details>` carries an implicit `role=\"group\"`, so an aside's own `getByRole(\"group\")` query must scope to its subtree. */}\n <PanelAsideExpand\n ref={expandRef}\n data-panel-aside-expand=\"\"\n data-hovering={collapsed && hovering ? \"\" : undefined}\n $collapsed={collapsed}\n open={collapsed ? openWhileCollapsed : true}\n onToggle={(e) => {\n // The forced-open inline state is not an operator choice.\n if (!collapsed) return;\n setOpenWhileCollapsed(e.currentTarget.open);\n // The press that closes a pinned menu must not leave the hover holding it open.\n if (!e.currentTarget.open) setHovering(false);\n }}\n onPointerEnter={(e) => {\n if (!collapsed || e.pointerType === \"touch\") return;\n cancelLeave();\n setHovering(true);\n }}\n onPointerLeave={(e) => {\n if (e.pointerType === \"touch\") return;\n cancelLeave();\n leaveTimer.current = setTimeout(() => {\n leaveTimer.current = null;\n setHovering(false);\n }, MENU_CROSSING_MS);\n }}\n >\n {/* biome-ignore lint/a11y/noStaticElementInteractions: a summary is natively interactive, which the rule does not know */}\n <summary\n ref={summaryRef}\n data-tooltip={summaryTip[\"data-tooltip\"]}\n onPointerDown={summaryTip.onPointerDown}\n onPointerUp={summaryTip.onPointerUp}\n onFocus={summaryTip.onFocus}\n onBlur={summaryTip.onBlur}\n aria-description={description ?? undefined}\n aria-label={\n breakdown.length === 0\n ? \"Panel status and controls\"\n : `${breakdown\n .map((e) => `${e.count} ${TONE_LABEL[e.severity]}`)\n .join(\", \")}. Panel status and controls`\n }\n >\n {breakdown.map((e) => (\n <PanelStatusDot\n key={e.severity}\n severity={e.severity}\n count={e.count}\n />\n ))}\n <span data-panel-aside-chevron=\"\" aria-hidden=\"true\" />\n </summary>\n {summaryTipBody}\n <PanelAsideSizeProvider value={collapsed ? \"collapsed\" : \"full\"}>\n <div data-panel-aside-full=\"\" ref={asideFullRef}>\n {aside}\n </div>\n </PanelAsideSizeProvider>\n </PanelAsideExpand>\n </PanelHeader__Aside>\n )}\n {toolbar !== undefined && <PanelToolbar>{toolbar}</PanelToolbar>}\n </PanelHeader__Row>\n );\n}\n\n/**\n * A full-width row of controls under the header, pinned like the header and\n * outside the scrolling body. Useful for keeping layer pickers or series\n * toggles in reach of the operator while the body scrolls. Used as\n * `Panel.Toolbar` on {@link Panel}.\n *\n * `panelAside` is the small slot beside the title (a chip, a badge, one\n * select); a toolbar is for controls that are a row in their own right, such as\n * a map's layer pickers or a graph's series toggles. It wraps rather than\n * scrolls, so a narrow tile gets a taller toolbar.\n */\nexport const PanelToolbar = styled.div`\n ${fitBox(\"panel-toolbar\")}\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n gap: var(--gap-control-row);\n padding: var(--inset-panel-toolbar);\n min-width: 0;\n /* Never shrink, or a short tile squeezes the controls away. */\n flex-shrink: 0;\n /* A full basis, so the toolbar always takes its own line in the wrapping header row. */\n flex-basis: 100%;\n width: 100%;\n /* Opaque: the sticky header's scroll glow only masks its top strip, so a tall toolbar would let scrolled rows draw through it. */\n background: var(--color-surface-panel);\n`;\n\n/** How far the scroll glow reaches in from the edge of a scroller. */\nconst SCROLL_GLOW_REACH = \"44px\";\n\n/*\n * A scroller keeps its glow's reach clear at both ends when it brings a\n * control into view, so a button reached by focus, find or a scripted click\n * lands above the fade and never beneath it.\n */\nconst SCROLL_CLEAR_OF_GLOW = `scroll-padding-block: ${SCROLL_GLOW_REACH};`;\n\n/**\n * A panel body is the default density tier, and re-declares both steppable gap\n * names so a panel nested inside a compact `Card` does not inherit the card's\n * density.\n */\nconst PanelBody__Box = styled.div<{\n $fitToSize?: boolean;\n $loneFrame?: boolean;\n $hoverTitle?: boolean;\n}>`\n --gap-related: var(--gap-related-comfortable);\n --gap-section: var(--gap-section-comfortable);\n --bleed-inline: var(--gutter-panel);\n /* The body's side and bottom inset; a lone framed drawing steps this down under a narrow container. */\n --panel-body-gutter: var(--gutter-panel);\n --panel-body-bottom: var(--inset-panel-bottom);\n\n flex: 1;\n min-height: 0;\n display: flex;\n flex-direction: column;\n gap: var(--gap-related);\n /* Longhands, because jsdom drops a shorthand made of var() calls. */\n padding-top: var(--inset-panel-top);\n padding-right: var(--panel-body-gutter);\n padding-bottom: var(--panel-body-bottom);\n padding-left: var(--panel-body-gutter);\n /* Body is the scroller, so the inset sits inside the scrolling box and never clips overflow. */\n overflow: auto;\n ${SCROLL_CLEAR_OF_GLOW}\n ${focusRingInset}\n /* The glow shows scroll state, so the native bar is hidden. */\n scrollbar-width: none;\n -ms-overflow-style: none;\n &::-webkit-scrollbar {\n width: 0;\n height: 0;\n display: none;\n }\n /* Fit-to-size never scrolls, and centres only once measurement says the content fits: Firefox clips safe center while reporting support for it. */\n ${({ $fitToSize }) => ($fitToSize ? \"flex: 1; overflow: hidden;\" : \"\")}\n ${({ $loneFrame }) =>\n $loneFrame\n ? `@container (width < ${LONE_FRAME_BREAKPOINT}) {\n --panel-body-gutter: var(--inset-tiny);\n --panel-body-bottom: var(--inset-tiny);\n }`\n : \"\"}\n /* The title row is out of flow entirely (see PanelHoverTop), so the body\n takes the same thin inset a lone framed drawing gets under a narrow\n container, unconditionally: a hoverTitle panel is always that narrow. */\n ${({ $hoverTitle }) =>\n $hoverTitle\n ? `--panel-body-gutter: var(--inset-tiny);\n --panel-body-bottom: var(--inset-tiny);`\n : \"\"}\n ${SECTION_FILL_RULE}\n /* A lone drawing is the whole body, so nothing squeezes it and it keeps giving room back. */\n ${({ $loneFrame }) =>\n $loneFrame\n ? `& > [${SECTION_FILL_ATTR}] {\n min-height: 0;\n }`\n : \"\"}\n`;\n\n/**\n * The panel width below which a lone framed drawing takes the thin inset.\n * Under it the standard gutters cost such a drawing 15 to 35 percent of its\n * area; above it about 10.\n */\nconst LONE_FRAME_BREAKPOINT = \"25rem\";\n\n/**\n * The inset, scrolling content box of a panel. Useful for holding a widget's\n * rows and sections so the operator can scroll them under the pinned header.\n * Used by {@link Panel} as `Panel.Body`, which registers it with the panel\n * context so `Panel.Glow` can observe it without reaching into the tree.\n */\nexport function PanelBody({\n children,\n fitToSize,\n loneFrame,\n hoverTitle,\n ...rest\n}: ComponentPropsWithoutRef<\"div\"> & {\n fitToSize?: boolean;\n /** The body is one framed drawing and nothing else. See `Panel`'s `sections`. */\n loneFrame?: boolean;\n /** The title row is out of flow; see `Panel`'s `hoverTitle`. */\n hoverTitle?: boolean;\n}) {\n const ctx = useContext(PanelCtx);\n const register = ctx?.registerScroller;\n const [scroller, setScroller] = useState<HTMLDivElement | null>(null);\n const ref = useCallback(\n (el: HTMLDivElement | null) => {\n register?.(el);\n setScroller(el);\n },\n [register],\n );\n const tabIndex = useKeyboardScrollable(scroller);\n return (\n /* `data-panel-body` is a stable targeting hook for the scroller's visible height. */\n <PanelBody__Box\n ref={ref}\n tabIndex={tabIndex}\n data-panel-body=\"\"\n $fitToSize={fitToSize}\n $loneFrame={loneFrame}\n data-panel-lone-frame={loneFrame ? \"\" : undefined}\n $hoverTitle={hoverTitle}\n {...rest}\n >\n {children}\n </PanelBody__Box>\n );\n}\n\n/**\n * The default narrowest a section column may be before the panel stops offering\n * a second one: two columns in a panel about 470px wide. A string so a widget\n * can pass `100%` to opt out of columns entirely.\n */\nconst DEFAULT_SECTION_MIN_WIDTH = \"13rem\";\n\n/**\n * Where the wide-layout decision lives: `auto-fit` + `minmax` takes as many\n * columns of at least `$min` as the panel's width allows, so sections flow\n * across a landscape tile and stack in a portrait one.\n *\n * `min($min, 100%)` keeps a narrow tile stacking instead of scrolling sideways.\n * The `max(..., 1/N of the panel)` floor makes more than N tracks impossible,\n * because a track a full-width section spans is not collapsed by `auto-fit`.\n */\nconst PanelSections__Grid = styled.div<{ $min: string; $columns: number }>`\n display: grid;\n grid-template-columns: repeat(\n auto-fit,\n minmax(\n max(\n min(${({ $min }) => $min}, 100%),\n ${({ $columns }) =>\n `calc((100% - ${$columns - 1} * var(--gap-panel-columns)) / ${$columns})`}\n ),\n 1fr\n )\n );\n /* Wider between columns than rows: a column gap has no section title doing the separating. */\n gap: var(--gap-panel-sections) var(--gap-panel-columns);\n /* Natural heights, so a short section beside a tall one does not read as an empty box. */\n align-items: start;\n & > [${SECTION_FULL_ATTR}] {\n grid-column: 1 / -1;\n }\n /* A grid opened only to carry the augment slot, with nothing bound, takes no gap above it: a filling section reaches the body's bottom inset. */\n &:empty {\n display: none;\n }\n`;\n\n/**\n * The tiny-tile layout: fills every pixel between the header's foot and the\n * panel's clip edge and centres the widget's content in it, but only while\n * measurement says the content fits. Wraps the children alone, so the header\n * is neither centred nor measured.\n */\nfunction PanelFitBody({\n children,\n hoverTitle,\n}: {\n children?: ReactNode;\n hoverTitle?: boolean;\n}) {\n const outerRef = useRef<HTMLDivElement | null>(null);\n const innerRef = useRef<HTMLDivElement | null>(null);\n const fits = useContentFits(outerRef, innerRef);\n return (\n <PanelBody__FitOuter ref={outerRef} $fits={fits} data-panel-fit-body=\"\">\n <PanelBody__FitContent\n ref={innerRef}\n $fits={fits}\n $hoverTitle={hoverTitle}\n data-panel-fit-shifted={fits && hoverTitle ? \"\" : undefined}\n >\n {children}\n </PanelBody__FitContent>\n </PanelBody__FitOuter>\n );\n}\n\nconst PanelBody__FitOuter = styled.div<{ $fits?: boolean }>`\n flex: 1;\n min-height: 0;\n /* Takes back the body's gap above and its bottom inset, so the box is all the room a tiny tile has and centring is measured against it. Reads the body's own custom property rather than the raw token, so a stepped-down bottom inset (loneFrame, hoverTitle) is taken back by exactly as much. */\n margin-top: calc(-1 * var(--gap-related));\n margin-bottom: calc(-1 * var(--panel-body-bottom));\n display: flex;\n flex-direction: column;\n /* Never clips: the body owns the real boundary. */\n ${({ $fits }) =>\n $fits ? \"justify-content: center;\" : \"justify-content: flex-start;\"}\n`;\n\nconst PanelBody__FitContent = styled.div<{\n $fits?: boolean;\n $hoverTitle?: boolean;\n}>`\n display: flex;\n flex-direction: column;\n align-items: center;\n /* Aligned like its box: centring here would push overflowing content up under the header. */\n ${({ $fits }) =>\n $fits ? \"justify-content: center;\" : \"justify-content: flex-start;\"}\n /* The delay rail band above still reserves its own strip on a hoverTitle\n panel (see PanelProps.hoverTitle), so the box this centres within is\n shorter at the top than the panel actually is, by the band's own height.\n Centred content would read as sitting low by half of it, the same way it\n would if the box below a real header were centred on the whole panel\n instead of the room under that header. The band has no visible header to\n read as the reason, so the shift here is what keeps the figure reading as\n centred on the panel while the box itself stays exactly what fitToSize's\n own docs promise: never clipped, and unaffected while the content does\n not fit.\n\n The flex centring above absorbs half of any margin change into its own\n free-space split (a flex item's centred position moves by m/2 for a\n margin-top of m, not m), so the full band's height is what actually\n buys the half-band visual shift this needs. */\n ${({ $fits, $hoverTitle }) =>\n $fits && $hoverTitle\n ? \"margin-top: calc(-1 * var(--panel-rail-band));\"\n : \"\"}\n gap: var(--gap-tiny-content);\n min-height: 0;\n /* A query container, so a tiny presentation sizes its headline in cqw against the tile rather than the viewport. */\n container-type: inline-size;\n`;\n\n/**\n * Whether the content currently fits its box, so a tiny tile centres only\n * when centring cannot push the first line up under the header. Measured\n * because Firefox clips `safe center` in practice. True when there is nothing\n * to measure.\n */\nfunction useContentFits(\n boxRef: { current: HTMLElement | null },\n contentRef: { current: HTMLElement | null },\n): boolean {\n const [fits, setFits] = useState(true);\n useLayoutEffect(() => {\n const box = boxRef.current;\n const content = contentRef.current;\n if (!box || !content) return;\n const measure = () => {\n setFits(contentFits(contentExtent(content), box.clientHeight));\n };\n measure();\n if (typeof ResizeObserver === \"undefined\") return;\n /* The content box is squeezed to the box, so it stops resizing once its\n children outgrow it. Each child is observed as well, and a child added\n later is picked up as it arrives. */\n const observer = new ResizeObserver(measure);\n const observeAll = () => {\n observer.observe(box);\n observer.observe(content);\n for (const child of Array.from(content.children)) observer.observe(child);\n };\n observeAll();\n const children = new MutationObserver(() => {\n observeAll();\n measure();\n });\n children.observe(content, { childList: true });\n return () => {\n observer.disconnect();\n children.disconnect();\n };\n }, [boxRef, contentRef]);\n return fits;\n}\n\n/**\n * How tall the content is, whatever its box does: from the top of its first\n * child to the bottom of its last. The box itself is squeezed to the room left\n * under the header and its children overflow it, so its own height says\n * nothing once they no longer fit, and its scroll height counts only the half\n * of a centred overflow that went downwards.\n */\nfunction contentExtent(content: HTMLElement): number {\n const rects = Array.from(content.children, (child) =>\n child.getBoundingClientRect(),\n );\n if (rects.length === 0) return content.scrollHeight;\n return (\n Math.max(...rects.map((r) => r.bottom)) -\n Math.min(...rects.map((r) => r.top))\n );\n}\n\n/**\n * Whether content of `content` height, centred in a box `box` tall, stays\n * inside it. The box already runs from the header's foot to the clip edge, so\n * there is no room past either end to overflow into. Useful for deciding when\n * centred content must scroll instead. Used by the panel body in {@link Panel}.\n */\nexport function contentFits(content: number, box: number): boolean {\n return content <= box;\n}\n\nconst ScrollAreaRoot = styled.div<{\n $framed?: boolean;\n $maxHeight?: string;\n}>`\n position: relative;\n display: flex;\n flex-direction: column;\n /* Fills the flex-column parent so the inner scroller engages rather than spilling past the panel edge. */\n flex: 1;\n min-height: 0;\n /* Out to the panel's edges, its content back on the column, so a strip inside that bleeds is not clipped by this scroller. */\n margin-inline: calc(-1 * var(--bleed-inline));\n /* A frame owns its edge and its inset, so the glow meets the border and no caller padding can come between them. */\n ${({ $framed, $maxHeight }) =>\n $framed\n ? `\n flex: 0 1 auto;\n margin-inline: 0;\n --bleed-inline: var(--gap-related);\n border: 1px solid var(--color-border-subtle);\n border-radius: var(--radius-regular);\n overflow: hidden;\n max-height: ${$maxHeight ?? \"16rem\"};\n `\n : \"\"}\n`;\n\n/**\n * Inner scroll element. Carries a stable `data-scroll-area-inner` attribute so\n * a `styled(ScrollArea)` can target it to lay out the scrolling children.\n */\nconst ScrollAreaInner = styled.div`\n flex: 1;\n min-height: 0;\n overflow: auto;\n padding-inline: var(--bleed-inline);\n ${SCROLL_CLEAR_OF_GLOW}\n ${focusRingInset}\n /* The glow indicators show scroll state, so the native bar is hidden. */\n scrollbar-width: none;\n -ms-overflow-style: none;\n &::-webkit-scrollbar {\n width: 0;\n height: 0;\n display: none;\n }\n`;\n\nconst ScrollOverflowGlow = styled.div<{\n $position: \"top\" | \"bottom\";\n $visible: boolean;\n}>`\n position: absolute;\n /* Flush with the scroller's edges: the body's inset is inside the scroller, so nothing pads this. */\n left: 0;\n right: 0;\n ${({ $position }) => ($position === \"top\" ? \"top: 0;\" : \"bottom: 0;\")}\n /* The box both layers fade within; each sets its own reach in its gradient stops. */\n height: ${SCROLL_GLOW_REACH};\n /* The audit reads the mask depth from the gradient stops, not from this height. */\n ${fitMask(\"panel-scroll-glow\")}\n pointer-events: none;\n opacity: ${({ $visible }) => ($visible ? 1 : 0)};\n transition: opacity var(--duration-base) var(--ease-standard);\n /* A light affordance tint over a fully opaque panel-colour mask; only an opaque mask keeps scrolled content from ghosting through the sticky title. */\n background:\n linear-gradient(\n ${({ $position }) => ($position === \"top\" ? \"to bottom\" : \"to top\")},\n color-mix(\n in srgb,\n color-mix(in srgb, var(--color-surface-panel), white 20%) 55%,\n transparent\n ),\n transparent 40%\n ),\n linear-gradient(\n ${({ $position }) => ($position === \"top\" ? \"to bottom\" : \"to top\")},\n var(--color-surface-panel) 0%,\n var(--color-surface-panel) 27%,\n transparent 50%\n );\n /* Widget-internal stacking, off the app-global z ladder so it never lifts over dashboard chrome. */\n z-index: 1;\n\n @media (prefers-reduced-motion: reduce) {\n transition: none;\n }\n`;\n\n/**\n * Props for {@link ScrollArea}: any `div` attribute, and whether the region\n * draws its own bounded frame. Useful for keeping a list the operator scrolls\n * inside a box of its own within a form. Taken by {@link ScrollArea}.\n *\n * @category Panel\n */\nexport interface ScrollAreaProps extends ComponentPropsWithoutRef<\"div\"> {\n /**\n * Draws a border around the region and keeps its content inset inside that\n * border, so the scroll glow always reaches the edge. Without it, the region\n * fills a padded parent such as a panel body.\n */\n framed?: boolean;\n /** CSS length for the tallest a `framed` region grows before it scrolls. Defaults to `16rem`. Ignored unless `framed`. */\n maxHeight?: string;\n}\n\n/**\n * A scrolling region with a glow at the top and bottom edges while there is\n * content to scroll to. A panel body already scrolls and glows; use this for a\n * second scrolling region inside a widget (a sidebar list, a terminal log).\n * Useful for showing the operator that a list continues past its edge. Used by\n * the target picker's list. Its native scrollbar is hidden, and it takes\n * keyboard focus when its content overflows so it can be scrolled from the\n * keyboard.\n *\n * The ref is forwarded to the inner scroll element; `className` and other\n * `div` attributes go to the outer root. A `styled(ScrollArea)` can reach the\n * inner element through its `data-scroll-area-inner` attribute.\n *\n * @category Panel\n */\nexport const ScrollArea = forwardRef<HTMLDivElement, ScrollAreaProps>(\n function ScrollArea({ children, framed, maxHeight, ...rest }, ref) {\n const innerRef = useRef<HTMLDivElement | null>(null);\n const [inner, setInner] = useState<HTMLDivElement | null>(null);\n const attachInner = useCallback((el: HTMLDivElement | null) => {\n innerRef.current = el;\n setInner(el);\n }, []);\n\n useImperativeHandle(ref, () => innerRef.current as HTMLDivElement);\n\n const overflow = useScrollerMetric(\n inner,\n scrollOverflow,\n sameOverflow,\n NO_OVERFLOW,\n );\n const innerTabIndex = useKeyboardScrollable(inner);\n\n return (\n <ScrollAreaRoot {...rest} $framed={framed} $maxHeight={maxHeight}>\n <ScrollAreaInner\n ref={attachInner}\n tabIndex={innerTabIndex}\n data-scroll-area-inner=\"\"\n >\n {children}\n </ScrollAreaInner>\n <ScrollOverflowGlow $position=\"top\" $visible={overflow.top} />\n <ScrollOverflowGlow $position=\"bottom\" $visible={overflow.bottom} />\n </ScrollAreaRoot>\n );\n },\n);\n\n/**\n * Where a panel's sidebar sits relative to the body, in logical terms: `end` is\n * the right edge in LTR and the left in RTL, and the bottom when the sidebar\n * sits under the body. Useful for choosing which side the detail pane the\n * operator reads sits on. The sidebar side of {@link Panel} defaults to `end`,\n * and the sidebar always follows the body in the DOM, whichever side it is\n * drawn on.\n *\n * @category Panel\n */\nexport type PanelSidebarSide = \"start\" | \"end\";\n\n/**\n * Where a panel's sidebar sits relative to the body: `auto` puts it beside the\n * body in a tile at least as wide as it is tall and under it otherwise, `beside`\n * keeps it beside the body in a tile of any shape for as long as the body keeps\n * at least the sidebar's width, and `below` always puts it under the body.\n * Useful for a widget whose sidebar reads best as a column next to its drawing\n * on a tall tile. The placement of {@link Panel} defaults to `auto`.\n *\n * @category Panel\n */\nexport type PanelSidebarPlacement = \"auto\" | \"beside\" | \"below\";\n\n/** Sidebar beside the body (inline) or under it (block). Derived, never passed. */\ntype PanelSidebarAxis = \"inline\" | \"block\";\n\n/** Resolve a `px` or `rem` length to pixels; undefined for any other unit. */\nfunction resolveCssLength(value: string): number | undefined {\n const n = Number.parseFloat(value);\n if (!Number.isFinite(n)) return undefined;\n if (value.endsWith(\"px\")) return n;\n if (value.endsWith(\"rem\")) {\n const root =\n typeof document === \"undefined\"\n ? 16\n : Number.parseFloat(\n getComputedStyle(document.documentElement).fontSize || \"16\",\n );\n return n * (Number.isFinite(root) ? root : 16);\n }\n return undefined;\n}\n\n// A column beside the body wants an absolute width; a strip under it competes for the tile's height, so it takes a share.\nconst SIDEBAR_INLINE_SIZE = \"14rem\";\n/** Grid rows a sidebar under the body takes, whatever it holds, so it is the same height in every widget and its content can never grow it. */\nconst SIDEBAR_BLOCK_ROWS = 5;\n/** The cap that keeps a very short tile's body the larger share. */\nconst SIDEBAR_BLOCK_MAX_SHARE = \"45%\";\nconst SIDEBAR_BLOCK_SIZE = `min(${gridToPixels(1, SIDEBAR_BLOCK_ROWS).pxH}px, ${SIDEBAR_BLOCK_MAX_SHARE})`;\n\nfunction sidebarTracks(side: \"start\" | \"end\", size: string): string {\n return side === \"start\"\n ? `minmax(0, ${size}) minmax(0, 1fr)`\n : `minmax(0, 1fr) minmax(0, ${size})`;\n}\n\nconst PanelSplit__Box = styled.div<{\n $axis: PanelSidebarAxis;\n $side: \"start\" | \"end\";\n $size: string;\n $railBand?: boolean;\n}>`\n flex: 1;\n min-height: 0;\n min-width: 0;\n display: grid;\n gap: 0;\n /* Every track is minmax(0, ...), or a sidebar with its own ScrollArea floors at its content and is clipped instead of scrolling. */\n ${({ $axis, $side, $size }) =>\n $axis === \"inline\"\n ? `grid-template-columns: ${sidebarTracks($side, $size)};\n grid-template-rows: minmax(0, 1fr);`\n : `grid-template-columns: minmax(0, 1fr);\n grid-template-rows: ${sidebarTracks($side, $size)};`}\n\n /* Visual placement only: the sidebar always follows the body in the DOM, so reading and tab order never depend on its side. */\n ${({ $side }) =>\n $side === \"start\" ? \"& > [data-panel-sidebar] { order: -1; }\" : \"\"}\n\n /* The sidebar gets the rail band when the rail travels with the header, since only the body's scroller holds it. Under the body it is nowhere near the header, so it takes none. */\n ${({ $railBand, $axis, $side }) =>\n $railBand && !($axis === \"block\" && $side === \"end\")\n ? `& > [data-panel-sidebar] {\n padding-block-start: var(--panel-rail-band);\n }`\n : \"\"}\n\n /* Under the body the sidebar follows the body's own bottom inset, so it takes a small top inset rather than the panel's. */\n ${({ $axis, $side }) =>\n $axis === \"block\" && $side === \"end\"\n ? `& > [data-panel-sidebar] > * > [data-scroll-area-inner] {\n padding-top: var(--inset-panel-sidebar-under);\n }`\n : \"\"}\n\n /* On the inline axis the sidebar gives back its inset on the edge facing the body, which already pays one. */\n ${({ $axis, $side }) =>\n $axis === \"inline\"\n ? /* Child combinators the whole way down, so a ScrollArea the sidebar's\n own CONTENT carries keeps its own padding. */\n `& > [data-panel-sidebar] > * > [data-scroll-area-inner] {\n padding-inline-${$side === \"start\" ? \"end\" : \"start\"}: 0;\n }`\n : \"\"}\n`;\n\n/**\n * Props for the grid that holds a panel's body and sidebar. {@link Panel}\n * draws this grid itself when `panelSidebar` is set, taking `sidebarSide` and\n * `sidebarSize` as `side` and `size`.\n *\n * @category Panel\n */\ninterface PanelSplitProps extends ComponentPropsWithoutRef<\"div\"> {\n /** Which edge the sidebar sits against. See {@link PanelSidebarSide}. Defaults to `end`. */\n side?: PanelSidebarSide;\n /**\n * Size of the sidebar track: a width on the inline axis, a height on the\n * block axis. Defaults to `14rem`, and to a fixed five grid rows under the\n * body (capped at 45% of a very short tile), so the body takes the rest and\n * content never grows the sidebar. Overflow scrolls inside it.\n */\n size?: string;\n /** Where the sidebar sits relative to the body. See {@link PanelSidebarPlacement}. Defaults to `auto`. */\n placement?: PanelSidebarPlacement;\n /** Gives the sidebar a top inset matching the delay rail's band, which the body track holds inside its scroller. */\n railBand?: boolean;\n}\n\n/**\n * The grid that holds `Panel.Body` and `Panel.Sidebar`, placing the sidebar\n * beside the body in a wide tile and below it in a tall one. Useful for\n * showing the operator a detail pane next to the drawing it annotates without\n * the drawing resizing when the layout flips. Used by {@link Panel}, which\n * places the body and the sidebar in it.\n */\nexport function PanelSplit({\n side = \"end\",\n size,\n placement = \"auto\",\n railBand,\n children,\n ...rest\n}: PanelSplitProps) {\n // Seeded square, so an unmeasured panel gets the side-by-side arrangement.\n /*\n * The axis is measured on this box, whose size does not change when the grid\n * flips axes; measuring the body instead would oscillate. A container query\n * would impose size containment on a box that must hand its height down.\n */\n const { ref, size: measured } = useElementSize<HTMLDivElement>({\n w: 1,\n h: 1,\n });\n /*\n * The inline axis also needs absolute room: the body must keep at least as\n * much width as the sidebar takes, or the sidebar goes under. Applied only\n * once measured, so the 1x1 seed does not read as \"no room\".\n */\n const sidebarInline = resolveCssLength(size ?? SIDEBAR_INLINE_SIZE);\n const roomBeside =\n measured.w <= 1 ||\n sidebarInline === undefined ||\n measured.w >= sidebarInline * 2;\n const axis: PanelSidebarAxis =\n placement === \"below\"\n ? \"block\"\n : (placement === \"beside\" || measured.w >= measured.h) && roomBeside\n ? \"inline\"\n : \"block\";\n\n const resolvedSize =\n size ?? (axis === \"inline\" ? SIDEBAR_INLINE_SIZE : SIDEBAR_BLOCK_SIZE);\n return (\n /* `data-panel-split` is a stable targeting hook carrying the resolved axis. */\n <PanelSplit__Box\n ref={ref}\n data-panel-split={axis}\n $axis={axis}\n $side={side}\n $size={resolvedSize}\n $railBand={railBand}\n {...rest}\n >\n {children}\n </PanelSplit__Box>\n );\n}\n\n/** The sidebar's scroller. The inset goes inside it, since padding outside a scroller clips what scrolls under it. */\nconst PanelSidebar__Scroll = styled(ScrollArea)`\n /* Longhands, because jsdom drops a shorthand made of var() calls. */\n & > [data-scroll-area-inner] {\n padding-top: var(--inset-panel-top);\n padding-right: var(--gutter-panel);\n padding-bottom: var(--inset-panel-bottom);\n padding-left: var(--gutter-panel);\n }\n`;\n\nconst PanelSidebar__Box = styled.div`\n display: flex;\n flex-direction: column;\n /* Grid items floor at min-content, which would let the ScrollArea grow the track instead of scrolling. */\n min-width: 0;\n min-height: 0;\n`;\n\n/**\n * Secondary content beside or below the body: an almanac for the diagram, a\n * legend for the plot, a detail pane for the selected row. Useful for giving\n * the operator context beside a drawing without covering it. Used as\n * `Panel.Sidebar` on {@link Panel}.\n *\n * It has its own {@link ScrollArea} and sits outside `Panel.Body`, so\n * scrolling it does not scroll the drawing it annotates. It is padded like the\n * body, except on the edge it shares with the body.\n */\nexport function PanelSidebar({\n children,\n ...rest\n}: ComponentPropsWithoutRef<\"div\">) {\n return (\n <PanelSidebar__Box data-panel-sidebar=\"\" {...rest}>\n <PanelSidebar__Scroll>{children}</PanelSidebar__Scroll>\n </PanelSidebar__Box>\n );\n}\n\ninterface ScrollOverflow {\n top: boolean;\n bottom: boolean;\n}\n\nconst NO_OVERFLOW: ScrollOverflow = { top: false, bottom: false };\n\n/** Whether there is more to scroll to above and below the current position. */\nfunction scrollOverflow(el: HTMLElement): ScrollOverflow {\n return {\n top: el.scrollTop > 1,\n bottom: el.scrollTop + el.clientHeight < el.scrollHeight - 1,\n };\n}\n\nfunction sameOverflow(a: ScrollOverflow, b: ScrollOverflow): boolean {\n return a.top === b.top && a.bottom === b.bottom;\n}\n\nconst PanelGlow__Root = styled.div`\n position: relative;\n display: flex;\n flex-direction: column;\n flex: 1;\n min-height: 0;\n`;\n\n/**\n * The glow at the top and bottom edge of a panel body that has more to scroll\n * to. Useful for telling the operator that content continues past an edge.\n * Used by {@link Panel} as `Panel.Glow`.\n *\n * It does not scroll: it decorates whatever does, found through the panel\n * context, so it can wrap the body or sit beside it.\n */\nexport function PanelGlow({\n children,\n railBandAbove,\n ...rest\n}: ComponentPropsWithoutRef<\"div\"> & {\n /** The scroller's first row is the sticky unit holding the delay rail's band, which draws the top glow itself, so this one shows only the bottom glow. */\n railBandAbove?: boolean;\n}) {\n const ctx = useContext(PanelCtx);\n const el = ctx?.scroller ?? null;\n\n useEffect(() => {\n if (!ctx && process.env.NODE_ENV !== \"production\") {\n // Without a context this renders correctly and does nothing, so say so.\n console.warn(\n \"Panel.Glow rendered outside a Panel.Context, so it has no scroller \" +\n \"to observe and will never show. Wrap it in Panel.Context (or use \" +\n \"Panel, which does).\",\n );\n }\n }, [ctx]);\n\n const overflow = useScrollerMetric(\n el,\n scrollOverflow,\n sameOverflow,\n NO_OVERFLOW,\n );\n\n return (\n <PanelGlow__Root {...rest}>\n {children}\n <ScrollOverflowGlow\n $position=\"top\"\n $visible={overflow.top && !railBandAbove}\n />\n <ScrollOverflowGlow $position=\"bottom\" $visible={overflow.bottom} />\n </PanelGlow__Root>\n );\n}\n\nexport type { PanelInactiveReason } from \"./InactiveNotice\";\n\n/**\n * Props for {@link Panel}. Any other `div` attribute passes through to the\n * panel's container. Useful for giving a widget the same title, status and\n * scrolling behaviour as every other on the operator's dashboard. Taken by\n * {@link Panel}.\n *\n * @category Panel\n */\nexport interface PanelProps extends ComponentPropsWithoutRef<\"div\"> {\n /**\n * The panel's heading. With it set, the panel draws its own header and pads\n * its body. It is not `title`: that is the HTML tooltip attribute, which\n * goes through to the panel's element like any other.\n */\n panelTitle?: ReactNode;\n /**\n * Why this panel has nothing to show and is off entirely: the header stays,\n * the body, sidebar, footer and trend give way to the reason. A string, or\n * `{ reason, hint }` for a second line saying what would bring it back.\n * Reserve it for a widget that has decided there is nothing to present at\n * all; any other emptiness (an empty list, a section awaiting data) stays\n * the widget's own.\n */\n inactive?: PanelInactiveReason;\n /**\n * The panel's body, as one or more sections: the preferred way to give a\n * panel content. Each entry is normally a {@link Section}; Panel owns how\n * they flow, down one column in a portrait tile and across two or three in a\n * landscape one. A single node is fine, and a conditional `null` entry does\n * not render.\n *\n * A widget that is wholly a drawing (a map, a globe) passes one\n * `<Section fill>` holding it. A bare boolean is a type error: for a section\n * that is sometimes absent, pass `null` in its place, as in\n * `cond ? <Section /> : null`.\n */\n sections?: Exclude<ReactNode, boolean> | readonly ReactNode[];\n /**\n * Narrowest a section column may be before the panel stops offering a\n * second one. Defaults to `13rem` (208px at the default font size), which gives two\n * columns in a panel about 470px wide.\n *\n * Raise it for a widget whose sections carry long rows and read badly at the\n * default width; set it to `100%` for one that should never columnise at all.\n */\n sectionMinWidth?: string;\n /**\n * Shorter forms of `panelTitle`, longest first, for tiles the full one will\n * not fit in, including the widget's own `minSize`. See\n * {@link PanelTitleProps.compact}.\n */\n compactTitle?: string | readonly string[];\n /**\n * Content for the right of the header row, beside the stream-status badge:\n * state chips, a small control such as a select or a show/hide button. An\n * Uplink's badges need nothing here: they are contributions to the widget's\n * `badges` slot, which the header draws itself. Keep it small: anything that wants real\n * layout belongs in the body or a hand-composed `Panel.Header`.\n */\n panelAside?: ReactNode;\n /**\n * The widget's own state badges (paused, no signal, full), drawn as standard\n * pills in the header aside ahead of the badges contributed to the widget's\n * `${componentId}.badges` slot. A contributed badge sharing an id with one of\n * these is dropped. Badges render alongside whatever `panelAside` supplies.\n */\n panelBadges?: readonly PanelBadge[];\n /**\n * This panel's own stream status, shown as a badge in the header aside and\n * announced when it changes. `live` shows nothing, and `\"none\"` suppresses\n * the badge.\n *\n * The dashboard sets the blackout grades itself, from the widget's declared\n * channels (the Topics it reads). A blackout is a stretch when the craft's\n * signal cannot reach the command centre: the last value sent before it is\n * graded `last-before-blackout`, and a value the craft sent once contact came\n * back is graded `recorded`. Every grade is listed on\n * {@link StreamStatusValue}. Any other grade shows only when set here, so set\n * it for a panel that reads one specific Topic. It is merged, worst first,\n * with the dashboard's status and with the state of every {@link Badge} given\n * a `report` prop.\n */\n panelStatus?: StreamStatusValue | \"none\";\n /**\n * A full-width row of controls under the header, pinned outside the\n * scrolling body. For widgets whose controls are a row in their own right\n * (a map's layer pickers, a graph's series toggles); a single chip or select\n * belongs in `panelAside` instead. Drawn in a `Panel.Toolbar`.\n */\n panelToolbar?: ReactNode;\n /**\n * A filter from {@link useRowFilter} over the whole body. Its control is\n * pinned in the toolbar row under the header, so it stays above the list it\n * narrows while the body scrolls. For a filter over one list among others,\n * wrap that list in a {@link FilterRegion} instead.\n */\n panelFilter?: RowFilter;\n /**\n * Lays the content out for a small tile: centred in the room under the\n * header while it fits, top-aligned when it does not.\n *\n * It overrides `fill` on a section: with this set, every section stays an\n * ordinary grid item.\n */\n fitToSize?: boolean;\n /**\n * The tiny tile's header: the title row leaves the flow and the content\n * centres on the whole panel. The title stays an accessible heading, hidden\n * visually and drawn as a small pill top-left while the panel is hovered or\n * focused. The panel itself becomes a tab stop, named by that heading. The\n * header aside (badges, the status summary) stays drawn, pinned top-right,\n * and the delay rail keeps its strip above the content.\n */\n hoverTitle?: boolean;\n /**\n * A pinned strip at the very bottom of the panel, outside the scrolling\n * body: the one readout an operator must never have to scroll for (a power\n * meter, a mission clock). It has its own top border and stays put while the\n * body scrolls. Keep it to a single row; anything taller belongs in the body\n * or a sidebar.\n */\n panelFooter?: ReactNode;\n /**\n * A trend across the panel's whole bottom edge, with no inset and on the\n * panel's own surface: the sparkline under a small readout. Handed the\n * strip's measured size, since a sparkline draws to fixed pixels.\n */\n panelTrend?: (size: { w: number; h: number }) => ReactNode;\n /**\n * Secondary content beside or below the body, in its own scrolling region:\n * an almanac for a diagram, a legend for a plot, a detail pane for the\n * selected row.\n *\n * It scrolls on its own, apart from the body, so scrolling it never moves\n * what it annotates. Unset, the panel has no sidebar.\n */\n panelSidebar?: ReactNode;\n /**\n * Which edge the sidebar sits against, logically. See {@link PanelSidebarSide}.\n * Defaults to `end`.\n */\n sidebarSide?: PanelSidebarSide;\n /**\n * Where the sidebar sits relative to the body. See {@link PanelSidebarPlacement}.\n * Defaults to `auto`.\n */\n sidebarPlacement?: PanelSidebarPlacement;\n /**\n * Size of the sidebar track: a width when it sits beside the body, a height\n * when it sits under it. Defaults to `14rem`, and to a fixed five grid rows\n * under the body.\n */\n sidebarSize?: string;\n}\n\n/**\n * A widget's own header badge: a standard badge entry, optionally with a\n * tooltip saying why it shows. Useful for showing the operator a state of the\n * widget beside its title. Passed in the `panelBadges` prop of {@link Panel}.\n *\n * @category Panel\n */\nexport interface PanelBadge extends BadgeEntry {\n /** Tooltip text saying why the badge shows. */\n title?: string;\n}\n\n/** The widget's own badges first, then the contributed ones whose ids it does not already use. */\nfunction mergeBadges(\n own: readonly PanelBadge[] | undefined,\n contributed: readonly BadgeEntry[] | null,\n): readonly PanelBadge[] {\n if (own === undefined || own.length === 0) return contributed ?? [];\n if (contributed === null || contributed.length === 0) return own;\n const taken = new Set(own.map((b) => b.id));\n return [...own, ...contributed.filter((b) => !taken.has(b.id))];\n}\n\n/**\n * The standard augment segments {@link Panel} mounts for every widget:\n * `sections` and `actions`. Useful for an Uplink author checking which segment\n * names every widget already has, so as not to declare the same slot again. An\n * Uplink binds `\"<widget-id>.sections\"` or\n * `\"<widget-id>.actions\"` with `registerAugment` for any widget, whether or\n * not the widget declares slots of its own. Neither passes props (see\n * {@link AugmentSegmentRegistry}). Where each renders is under Standard slots\n * on {@link Panel}.\n *\n * @category Panel\n */\nexport const FRAMEWORK_AUGMENT_SEGMENTS = [\"sections\", \"actions\"] as const;\n\nconst NO_SEGMENT_PROPS: Record<string, never> = Object.freeze({});\n\n/**\n * The winning status contribution, rendered as the header aside badge. It\n * pulses once when its severity changes, then settles (reduced-motion\n * guarded). The panel's own status region announces the change, not this badge.\n */\nfunction PanelSummaryBadge({ summary }: { summary: StatusSummary }) {\n /*\n * Every severity change restarts the one-shot pulse by alternating between\n * two identical keyframe names, which a browser treats as a new animation.\n * A label-only change does not pulse.\n */\n const prevSeverity = useRef(summary.severity);\n const [pulseCount, setPulseCount] = useState(0);\n useEffect(() => {\n if (prevSeverity.current !== summary.severity) {\n prevSeverity.current = summary.severity;\n setPulseCount((k) => k + 1);\n }\n }, [summary.severity]);\n const description = describeBreakdown(useStatusBreakdown());\n return (\n <PanelSummaryBadge__Pulse $pulse={pulseCount}>\n <Tooltip text={description} focusable>\n <Badge tone={summary.severity} size=\"sm\">\n {summary.label}\n </Badge>\n </Tooltip>\n </PanelSummaryBadge__Pulse>\n );\n}\n\nconst PanelSummaryBadge__Pulse = styled.span<{ $pulse: number }>`\n display: inline-flex;\n ${({ $pulse }) =>\n $pulse > 0 &&\n css`\n @media (prefers-reduced-motion: no-preference) {\n animation: ${$pulse % 2 === 0 ? \"panel-status-pulse\" : \"panel-status-pulse-b\"}\n var(--duration-slow) var(--ease-emphasis);\n }\n `}\n @keyframes panel-status-pulse-b {\n 0% {\n transform: scale(1);\n }\n 35% {\n transform: scale(1.14);\n }\n 100% {\n transform: scale(1);\n }\n }\n @keyframes panel-status-pulse {\n 0% {\n transform: scale(1);\n }\n 35% {\n transform: scale(1.14);\n }\n 100% {\n transform: scale(1);\n }\n }\n`;\n\n/**\n * The strip pinned to the bottom of a panel, which `panelFooter` renders\n * into. Useful for keeping a total or summary in view under a scrolling body.\n * Used as `Panel.Footer` on {@link Panel}. It never scrolls or shrinks, and\n * shares the body's side padding so its content lines up with the rows above it.\n */\nexport const PanelFooter = styled.div`\n flex-shrink: 0;\n border-top: 1px solid var(--color-border-subtle);\n padding: var(--inset-panel-footer);\n background: var(--color-surface-panel);\n`;\n\n/**\n * The delay rail and the header, as one sticky unit at the top of the body\n * scroller, so the rail always sits on the header.\n */\nconst PanelStickyTop = styled.div`\n position: sticky;\n /* Reach the scroller's true top edge, cancelling the body's own top inset. */\n top: calc(-1 * var(--inset-panel-top));\n z-index: 2;\n /* Cancel the body's inset so the unit spans the full panel width. */\n margin: calc(-1 * var(--inset-panel-top)) calc(-1 * var(--panel-body-gutter))\n 0;\n display: flex;\n flex-direction: column;\n /* Never shrink, or a short tile crushes the band and the title. */\n flex-shrink: 0;\n /* Opaque: the scroll glow only masks the first strip of the header, so rows scrolled under a taller title would show through. */\n background: var(--color-surface-panel);\n\n /* The band is this unit's own first row, so the rail frame does not pull up into container padding. */\n & > [data-panel-rail-frame] {\n margin-top: 0;\n /* The unit's backing is the opaque surface and the glow sits on it, so the band shows the glow with the rail drawn over it. */\n background: transparent;\n }\n\n /* A tiny tile's centred content is pulled up into the rail band's strip and cannot scroll under it, so an opaque backing would only clip the figure's top. */\n &:has(+ [data-panel-fit-body] [data-panel-fit-shifted]) {\n background: transparent;\n }\n\n /* The top glow is the first background layer while the body is scrolled, over the opaque surface and under the rail and header; capped at the unit's height so a short unit never masks rows below it. */\n &[data-panel-glow-top] {\n background:\n linear-gradient(\n to bottom,\n color-mix(\n in srgb,\n color-mix(in srgb, var(--color-surface-panel), white 20%) 55%,\n transparent\n ),\n transparent 40%\n )\n top / 100% min(44px, 100%) no-repeat,\n linear-gradient(\n to bottom,\n var(--color-surface-panel) 0%,\n var(--color-surface-panel) 27%,\n transparent 50%\n )\n top / 100% min(44px, 100%) no-repeat,\n var(--color-surface-panel);\n }\n\n /* Rows scrolling under the header fade out at its lower edge, where the eye meets them, instead of being cut off hard. */\n &[data-panel-glow-top]::after {\n content: \"\";\n position: absolute;\n left: 0;\n right: 0;\n top: 100%;\n height: 20px;\n pointer-events: none;\n background: linear-gradient(\n to bottom,\n var(--color-surface-panel),\n transparent\n );\n }\n`;\n\n/** The sticky unit, marked while the body has content above to scroll back to so its top glow shows. */\nfunction PanelStickyUnit({ children }: { children: ReactNode }) {\n const ctx = useContext(PanelCtx);\n const overflow = useScrollerMetric(\n ctx?.scroller ?? null,\n scrollOverflow,\n sameOverflow,\n NO_OVERFLOW,\n );\n return (\n <PanelStickyTop\n data-panel-sticky-top=\"\"\n data-panel-glow-top={overflow.top ? \"\" : undefined}\n >\n {children}\n </PanelStickyTop>\n );\n}\n\n/** The full-bleed strip `panelTrend` draws into, measured so the trend can be drawn to its pixels. */\nfunction PanelTrend({\n render,\n}: {\n render: (size: { w: number; h: number }) => ReactNode;\n}) {\n const { ref, size } = useElementSize<HTMLDivElement>({ w: 0, h: 0 });\n return (\n <PanelTrend__Strip ref={ref} data-panel-trend=\"\">\n {size.w > 0 && size.h > 0 && render(size)}\n </PanelTrend__Strip>\n );\n}\n\nconst PanelTrend__Strip = styled.div`\n flex: 0 0 var(--size-panel-trend);\n height: var(--size-panel-trend);\n min-width: 0;\n overflow: hidden;\n`;\n\n/* A filter control takes the toolbar row's whole width, so its search box is not squeezed beside other controls. */\nconst PanelFilterSlot = styled.div`\n flex: 1 1 100%;\n min-width: 0;\n`;\n\n/* The standard header inside the sticky unit. The unit's negative margins cancel the body's inset for the header alone. */\nconst PanelStickyHeader = styled(PanelHeader)`\n /* The rail band above is this header's top inset. */\n padding-top: 0;\n /* The one header that reads over scrolled content gets a title a notch brighter than the dim chrome token. */\n & h3 {\n color: color-mix(\n in srgb,\n var(--color-text-dim),\n var(--color-text-primary) 45%\n );\n }\n`;\n\n/**\n * The tiny tile's title-and-aside strip, out of flow above the centred\n * content: the title pill at the start, the aside pushed to the end. Empty\n * itself, so the whole panel stays clickable under it; only its children\n * re-enable pointer events.\n */\nconst PanelHoverTop = styled.div`\n position: absolute;\n top: var(--inset-tiny);\n left: var(--inset-tiny);\n right: var(--inset-tiny);\n /* Above the panel's own content (PanelGlow, trend, footer), local sibling ordering inside this panel's own stacking context. Not app-global chrome, so no named z rung. */\n z-index: 3;\n display: flex;\n align-items: flex-start;\n gap: var(--gap-panel-aside);\n pointer-events: none;\n`;\n\n/**\n * The tiny tile's title: an accessible heading at rest, sr-only through\n * `VisuallyHidden`, drawn as a pill hugging its text on hover or focus. Keyed\n * on `:focus` rather than `:focus-visible`, so a tap reveals it too.\n */\nconst PanelHoverTitlePill = styled(VisuallyHidden)`\n margin: 0;\n ${titleText}\n font-size: var(--font-size-caption);\n line-height: var(--line-height-flush);\n max-width: 100%;\n text-overflow: ellipsis;\n ${PanelContainer}:hover &,\n ${PanelContainer}:focus & {\n position: static;\n width: auto;\n height: auto;\n clip: auto;\n background: var(--color-surface-raised);\n border: 1px solid var(--color-border-strong);\n border-radius: var(--radius-pill);\n padding: var(--inset-chip);\n }\n`;\n\n/** What a header badge says in the panel's summary: its words, and the held grade's word while it is held. */\nfunction summaryLabel(face: BadgeFace): string {\n return face.held === undefined\n ? face.label\n : `${face.label}: ${heldWord(face.held)}`;\n}\n\n/** The most severe stateful badge, for a tree with no status store to summarise them. */\nfunction worstBadge(\n badges: readonly PanelBadge[],\n): { severity: Severity; label: string } | null {\n let worst: { severity: Severity; label: string } | null = null;\n for (const entry of badges) {\n const face = badgeFace(entry);\n const { tone } = face;\n if (tone === undefined || tone === \"neutral\") continue;\n if (worst === null || severityRank(tone) > severityRank(worst.severity)) {\n worst = { severity: tone, label: summaryLabel(face) };\n }\n }\n return worst;\n}\n\n/**\n * Publishes a header badge's state to the status store without drawing it, for\n * a header that shows state as a dot. A neutral badge carries no state.\n */\nfunction PanelBadgeReports({ badges }: { badges: readonly PanelBadge[] }) {\n return (\n <>\n {badges.map((b) => (\n <PanelBadgeReport key={b.id} entry={b} />\n ))}\n </>\n );\n}\n\nfunction PanelBadgeReport({ entry }: { entry: PanelBadge }) {\n const face = badgeFace(entry);\n const { tone } = face;\n useStatusContribution(\n tone === undefined || tone === \"neutral\"\n ? null\n : { id: entry.id, severity: tone, label: summaryLabel(face) },\n );\n return null;\n}\n\n/** The tiny tile's whole status: the worst severity as a dot that never expands, its words in the tooltip. */\nfunction PanelHoverStatus({\n summary,\n announcement,\n}: {\n summary: { severity: Severity; label: string };\n /** Interrupts to say a no-go state, empty otherwise: a dot says nothing the ear can catch. */\n announcement: string | undefined;\n}) {\n return (\n <>\n <Tooltip text={summary.label} focusable>\n <PanelHoverStatus__Hit>\n <PanelStatusDot severity={summary.severity} />\n </PanelHoverStatus__Hit>\n </Tooltip>\n {/* Mounted with the dot, whatever the state, so the first no-go is a change to a region already watched. */}\n <LiveRegion visuallyHidden assertive>\n {announcement}\n </LiveRegion>\n </>\n );\n}\n\nconst PanelHoverStatus__Hit = styled.span`\n display: inline-flex;\n align-items: center;\n padding: var(--inset-chip);\n`;\n\n/** The tiny tile's aside, pinned top-right and always visible: unlike the pill it needs no reveal. */\nconst PanelHoverAside = styled.div`\n margin-left: auto;\n display: flex;\n align-items: center;\n gap: var(--gap-panel-aside);\n pointer-events: auto;\n`;\n\n/**\n * `useId()`'s output is not scoped to the component that calls it: React\n * allocates from one sequence across the whole render, so a call added here\n * unconditionally shifts every other widget's own `useId()`-derived strings\n * downstream of it (Navball's SVG clip path is one, generated deep inside a\n * widget that never sets `hoverTitle` at all). Two component identities,\n * chosen by the stable `hoverTitle` prop before either renders, keep the\n * call scoped to the panels that actually draw a tiny header; every other\n * panel's own ids are untouched.\n */\nfunction PanelRoot(props: PanelProps): ReactElement {\n return props.hoverTitle ? (\n <PanelRootWithHoverTitle {...props} />\n ) : (\n <PanelRootImpl {...props} hoverTitleId={undefined} />\n );\n}\n\nfunction PanelRootWithHoverTitle(props: PanelProps): ReactElement {\n const hoverTitleId = useId();\n return <PanelRootImpl {...props} hoverTitleId={hoverTitleId} />;\n}\n\nfunction PanelRootImpl({\n panelTitle,\n compactTitle,\n panelAside,\n panelBadges,\n panelStatus,\n panelToolbar,\n panelFilter,\n panelFooter,\n panelTrend,\n inactive,\n fitToSize,\n hoverTitle,\n hoverTitleId,\n panelSidebar,\n sidebarSide,\n sidebarSize,\n sidebarPlacement,\n sections,\n sectionMinWidth = DEFAULT_SECTION_MIN_WIDTH,\n children,\n ...rest\n}: PanelProps & { hoverTitleId: string | undefined }): ReactElement {\n const contextBadges = usePanelBadgesContext();\n // Asked as a boolean first, because an aside that exists at all is a padded box.\n const hasActionAugments = useWidgetSegmentBound(\"actions\");\n const hasSectionAugments = useWidgetSegmentBound(\"sections\");\n const badges = mergeBadges(panelBadges, contextBadges);\n const badgePills =\n badges.length === 0\n ? null\n : badges.map((b) => {\n const face = badgeFace(b);\n const { label, tone, title } = face;\n return (\n <Tooltip key={b.id} text={title} focusable>\n <Badge\n tone={tone}\n held={face.held}\n /* A decorative chip stays out of the collapsed header's dot summary. */\n report={\n tone === undefined || tone === \"neutral\"\n ? undefined\n : { id: b.id, label: summaryLabel(face) }\n }\n >\n {label}\n </Badge>\n </Tooltip>\n );\n });\n const toolbar =\n panelFilter === undefined ? (\n panelToolbar\n ) : (\n <>\n {panelToolbar}\n <PanelFilterSlot>{filterControlOf(panelFilter)}</PanelFilterSlot>\n </>\n );\n /*\n * The header status merges alarms, `report` badges and the stream status\n * into one summary through the per-item status store. The stream half is the\n * widget's own `panelStatus`: \"absent\" means opposite things per topic, so\n * the host derives only the per-subject blackout grades.\n */\n const status = panelStatus ?? null;\n // A healthy stream contributes nothing, so it never draws a green pill.\n const streamStatus: StreamStatusValue | null =\n status !== null && status !== \"none\" && status !== \"live\" ? status : null;\n useStatusContribution(\n streamStatus\n ? {\n id: \"stream\",\n severity: severityFromStreamStatus(streamStatus),\n label: formatStreamStatus(streamStatus) ?? \"\",\n }\n : null,\n );\n const summary = useStatusSummary();\n /* A badge that already draws its own pill must not also win the summary, or its label shows twice. */\n const summaryDuplicatesABadgePill =\n summary !== null && badges.some((b) => b.id === summary.id);\n\n // With no status store in the tree, fall back to the stream badge.\n const streamLabel =\n streamStatus === null ? null : formatStreamStatus(streamStatus);\n const statusBadge = summaryDuplicatesABadgePill ? null : summary !== null ? (\n <PanelSummaryBadge summary={summary} />\n ) : streamStatus === null || streamLabel === null ? null : (\n <Tooltip text={`Telemetry stream: ${streamLabel}`} focusable>\n <Badge tone={severityFromStreamStatus(streamStatus)} size=\"sm\">\n {streamLabel}\n </Badge>\n </Tooltip>\n );\n /* Prefixed with a plain title, so a change is heard as belonging to a widget. */\n const statusLabel = summary?.label ?? streamLabel;\n const statusAnnouncement =\n statusLabel === null || statusLabel === \"\"\n ? \"\"\n : typeof panelTitle === \"string\"\n ? `${panelTitle}: ${statusLabel}`\n : `Status: ${statusLabel}`;\n // `undefined`, not `null`: a null child would still render the padded aside box.\n const aside =\n panelAside === undefined &&\n statusBadge === null &&\n badgePills === null &&\n !hasActionAugments ? undefined : (\n <>\n {panelAside}\n {/* Controls come ahead of the readout badges. */}\n {hasActionAugments && (\n <AugmentSlot segment=\"actions\" props={NO_SEGMENT_PROPS} />\n )}\n {badgePills}\n {statusBadge}\n </>\n );\n\n /*\n * The tiny tile's header carries state as ONE dot at the worst severity, with\n * the words in its tooltip, never as pills: a pill is as wide as its word and\n * would crowd the tile. The badges still publish to the status store, so the\n * dot knows about them.\n */\n const tinySummary =\n summary ??\n worstBadge(badges) ??\n (streamStatus === null || streamLabel === null\n ? null\n : {\n severity: severityFromStreamStatus(streamStatus),\n label: streamLabel,\n });\n const tinyAnnouncement =\n tinySummary?.severity !== \"nogo\"\n ? undefined\n : typeof panelTitle === \"string\"\n ? `${panelTitle}: ${tinySummary.label}`\n : `Status: ${tinySummary.label}`;\n const tinyAside =\n panelAside === undefined && tinySummary === null && !hasActionAugments ? (\n badges.length === 0 ? undefined : (\n <PanelBadgeReports badges={badges} />\n )\n ) : (\n <>\n {panelAside}\n {hasActionAugments && (\n <AugmentSlot segment=\"actions\" props={NO_SEGMENT_PROPS} />\n )}\n <PanelBadgeReports badges={badges} />\n {tinySummary !== null && (\n <PanelHoverStatus\n summary={tinySummary}\n announcement={tinyAnnouncement}\n />\n )}\n </>\n );\n\n /*\n * With sections, the universal `sections` augment segment moves inside the\n * grid, so an Uplink's section flows into a column beside the host's own.\n * `AugmentSlot` renders a fragment, so each bound augment is its own grid item.\n */\n const isInactive = inactive !== undefined;\n const sectionNodes = isInactive\n ? []\n : Children.toArray(sections as ReactNode);\n const hasSections = sectionNodes.length > 0;\n /* The body is one framed drawing and nothing else: no hand-composed children,\n no bound sections augment (it would add content beside the frame), not\n fitToSize, and the one section is a filling one holding only a frame. */\n const loneFrame =\n children === undefined &&\n !hasSectionAugments &&\n !fitToSize &&\n sectionNodes.length === 1 &&\n holdsOnlyAFrame(sectionNodes[0]);\n /*\n * A filling section is lifted out of the grid into the body, the box that\n * knows the leftover height, since no grid row can be named for it. The\n * ordinary sections either side become grids of their own, keeping authored\n * order. Off under `fitToSize`.\n */\n const runs: { fill: boolean; nodes: ReactNode[] }[] = [];\n for (const node of sectionNodes) {\n const fill =\n !fitToSize &&\n isValidElement<{ fill?: boolean }>(node) &&\n node.props.fill === true;\n const open = runs.at(-1);\n if (!fill && open !== undefined && !open.fill) open.nodes.push(node);\n else runs.push({ fill, nodes: [node] });\n }\n /* The universal segment lands in the last grid; a body whose every section fills gets one opened for it. */\n if (hasSections && !runs.some((run) => !run.fill)) {\n runs.push({ fill: false, nodes: [] });\n }\n const augmentRun = runs.reduce((last, run, i) => (run.fill ? last : i), -1);\n /* How many sections take a column, which floors the grid's track width. */\n const flowingIn = (nodes: ReactNode[]) =>\n Math.max(\n 1,\n nodes.filter(\n (node) =>\n !(\n isValidElement<{ full?: boolean }>(node) && node.props.full === true\n ),\n ).length,\n );\n const sectionRuns: ReactNode[] = [];\n for (const run of runs) {\n const index = sectionRuns.length;\n if (run.fill) {\n /* A filling section is never coalesced, so its run is exactly one node. */\n sectionRuns.push(run.nodes[0]);\n continue;\n }\n sectionRuns.push(\n <PanelSections__Grid\n key={`sections-${index}`}\n $min={sectionMinWidth}\n $columns={flowingIn(run.nodes)}\n >\n {run.nodes}\n {index === augmentRun && (\n <AugmentSlot segment=\"sections\" props={NO_SEGMENT_PROPS} />\n )}\n </PanelSections__Grid>,\n );\n }\n const content = isInactive ? (\n <InactiveNotice reason={inactive} />\n ) : !hasSections ? (\n children\n ) : (\n <>\n {children}\n {sectionRuns}\n </>\n );\n\n const body = (\n <PanelBody\n fitToSize={fitToSize}\n loneFrame={loneFrame}\n hoverTitle={hoverTitle}\n >\n <PanelStickyUnit>\n <PanelDelayRail tiny={hoverTitle} />\n {!hoverTitle && (\n <PanelStickyHeader\n title={panelTitle}\n compactTitle={compactTitle}\n aside={aside}\n toolbar={toolbar}\n />\n )}\n </PanelStickyUnit>\n {fitToSize ? (\n <PanelFitBody hoverTitle={hoverTitle}>{content}</PanelFitBody>\n ) : (\n content\n )}\n {!hasSections && !isInactive && (\n <AugmentSlot segment=\"sections\" props={NO_SEGMENT_PROPS} />\n )}\n </PanelBody>\n );\n\n return (\n <PanelProviders>\n <PanelContainer\n $railTravels\n $hoverTitle={hoverTitle}\n {...(hoverTitle\n ? {\n tabIndex: 0,\n role: \"group\",\n \"aria-labelledby\": hoverTitleId,\n \"data-tiny-panel\": \"\",\n }\n : {})}\n {...rest}\n >\n <PanelGlow railBandAbove>\n {panelSidebar === undefined || isInactive ? (\n body\n ) : (\n <PanelSplit\n side={sidebarSide}\n size={sidebarSize}\n placement={sidebarPlacement}\n railBand\n >\n {body}\n {/* After the body in the DOM; `sidebarSide` moves it visually only. */}\n <PanelSidebar>{panelSidebar}</PanelSidebar>\n </PanelSplit>\n )}\n </PanelGlow>\n {!isInactive && panelTrend !== undefined && (\n <PanelTrend render={panelTrend} />\n )}\n {!isInactive && panelFooter !== undefined && (\n <PanelFooter>{panelFooter}</PanelFooter>\n )}\n {hoverTitle && (\n <PanelHoverTop data-panel-hover-title=\"\">\n <PanelHoverTitlePill as=\"h3\" id={hoverTitleId}>\n {panelTitle}\n </PanelHoverTitlePill>\n {tinyAside !== undefined && (\n <PanelHoverAside>{tinyAside}</PanelHoverAside>\n )}\n </PanelHoverTop>\n )}\n {/* Mounted empty, so the first status is a change to a region already watched; outside the aside, so collapsing does not unmount it. */}\n <LiveRegion visuallyHidden>\n {hoverTitle && tinyAnnouncement !== undefined\n ? \"\"\n : statusAnnouncement}\n </LiveRegion>\n </PanelContainer>\n </PanelProviders>\n );\n}\n\n/**\n * Whether a section is a filling `Section` whose whole content is one\n * `FramedDisplay` (and any `GraphNotice` beside it), reached through plain elements and fragments that each hold\n * only the next.\n */\nfunction holdsOnlyAFrame(section: ReactNode): boolean {\n if (!isValidElement<{ fill?: boolean; children?: ReactNode }>(section)) {\n return false;\n }\n if (section.type !== Section || section.props.fill !== true) return false;\n let node: ReactNode = section.props.children;\n for (;;) {\n // A graph's notice sits beside or under its frame, and a frame with its notice is still the one drawing.\n const only = Children.toArray(node).filter(\n (child) => !(isValidElement(child) && child.type === GraphNotice),\n );\n if (only.length !== 1) return false;\n const [child] = only;\n if (!isValidElement<{ children?: ReactNode }>(child)) return false;\n if (child.type === FramedDisplay) return true;\n if (child.type !== Fragment && typeof child.type !== \"string\") return false;\n node = child.props.children;\n }\n}\n\n/**\n * The frame every widget draws in: a bordered surface with a pinned header\n * (title plus a right-hand aside of controls and badges), a scrolling body\n * with a glow at whichever edge has more to scroll to, and optional toolbar,\n * sidebar, trend strip and footer. Give it content through `sections`: each\n * entry is normally a {@link Section}, and the panel flows them down one\n * column in a portrait tile and across two or three in a landscape one. A\n * `Section fill` takes the height left over. The panel also reserves a strip\n * above the header for the delay rail, which shows this widget's commands in\n * flight.\n *\n * Useful for giving the operator the same title, status and scrolling\n * behaviour on every widget. Used by the widgets of the built-in library.\n *\n * The header aside holds, in order, `panelAside`, the `actions` augments,\n * the badges (the widget's own `panelBadges`, then contributed ones), and a\n * status badge for the worst of the panel's reported states. When the title\n * and aside no longer fit side by side, the aside collapses to one status dot\n * per severity plus a toggle that opens it.\n *\n * ## Standard slots\n *\n * Every widget drawn in a `Panel` carries three extension slots without\n * declaring them, each named `${componentId}.<segment>` after the widget's\n * registered id (`\"crew-status.badges\"`, for example):\n *\n * - `${componentId}.sections`: an augment slot, bound with `registerAugment`.\n * Each augment renders after everything the widget draws in its body; when\n * the widget passes `sections`, each augment is its own item in the last\n * section grid, so returning a {@link Section} flows it into a column\n * beside the widget's own. Its component gets no props. The widget does not\n * place it: `Panel` does\n * - `${componentId}.actions`: an augment slot for controls in the header\n * aside, after `panelAside` and before the badges. Its component gets no\n * props. Nothing is reserved for it while nothing is bound\n * - `${componentId}.badges`: a contribution slot, filled with an Uplink\n * handle's `registerContribution`, whose `compute` returns `BadgeEntry`\n * items (`id`, `label`, `tone`, and an optional `held` grade). The panel\n * draws them after the widget's own `panelBadges`, dropping any whose id the\n * widget already uses. A held entry shows its grade's word in place of its\n * label (see {@link badgeFace}), and any entry with a tone other than\n * `neutral` also feeds the panel's status summary\n *\n * An augment in `sections` or `actions` renders only while the Domain named in\n * its `requires` is present, and a badge contribution computes only while its\n * `requires` Domain is present, so an Uplink whose mod is not running leaves\n * the widget unchanged. An augment reads its own Topics; for what the widget\n * is focused on, it reads the widget's scope with `useWidgetScope`. The\n * segment lists are {@link FRAMEWORK_AUGMENT_SEGMENTS} and\n * {@link FRAMEWORK_CONTRIBUTION_SEGMENTS}.\n *\n * ## Parts\n *\n * `Panel` is built entirely from these parts and draws nothing they do not, so\n * a widget can compose a variant by hand from them:\n *\n * - `Panel.Container`: the bordered frame\n * - `Panel.Context`: the provider that links the body's scroller to the glow;\n * it takes no props but `children`\n * - `Panel.Delay`: the delay rail above the header\n * - `Panel.Header`: the title and its aside on one row, collapsing the aside\n * to status dots when they no longer fit\n * - `Panel.Title`: the title, in the longest form that fits (see\n * {@link PanelTitleProps})\n * - `Panel.Toolbar`: a full-width row of controls under the header, outside\n * the scrolling body\n * - `Panel.Glow`: the glow at whichever edge of the body has more to scroll to\n * - `Panel.Body`: the scrolling, inset content box\n * - `Panel.Section`: the same {@link Section} a `sections` entry is\n * - `Panel.Sidebar`: secondary content beside or below the body, scrolling on\n * its own\n * - `Panel.Footer`: the strip pinned to the bottom, which `panelFooter`\n * renders into\n *\n * @example\n * A typical widget body:\n * ```tsx\n * <Panel\n * panelTitle=\"Fuel Status\"\n * compactTitle=\"Fuel\"\n * panelBadges={lowFuel ? [{ id: \"low\", label: \"Low\", tone: \"warn\" }] : undefined}\n * panelFooter={\n * <Text>\n * Total <Unit value={total} />\n * </Text>\n * }\n * sections={[\n * <Section key=\"stages\" title=\"Stages\">\n * <StageList stages={stages} />\n * </Section>,\n * <Section key=\"tanks\" title=\"Tanks\">\n * <TankList tanks={tanks} />\n * </Section>,\n * ]}\n * />\n * ```\n *\n * @example\n * An Uplink adding a section and a header badge to another widget through its\n * standard slots:\n * ```tsx\n * import {\n * defineUplinkClient,\n * registerAugment,\n * useTelemetry,\n * type Value,\n * } from \"@ksp-gonogo/sitrep-sdk\";\n * import { Section, Text, Unit } from \"@ksp-gonogo/ui-kit\";\n *\n * // In a real Uplink this block is in `src/topics.ts`, with the payload type\n * // `uplink-tools codegen` writes from the contract; it is spelled out here so\n * // the example stands alone.\n * declare module \"@ksp-gonogo/sitrep-sdk\" {\n * interface TopicPayloadMap {\n * \"example.heartbeat\": { ut: Value<\"ut\"> };\n * }\n * }\n *\n * export const EXAMPLE = defineUplinkClient({\n * id: \"example\",\n * version: \"0.0.1\",\n * name: \"Example\",\n * description: \"Shows an example section in a widget panel.\",\n * });\n *\n * function CadenceSection() {\n * const heartbeat = useTelemetry(\"example.heartbeat\");\n * // A held heartbeat is still drawn: `Unit` marks the figure as held.\n * if (heartbeat.state !== \"observed\" && heartbeat.state !== \"held\") return null;\n * return (\n * <Section title=\"Example\">\n * <Text>\n * Last beat at UT <Unit value={heartbeat.ut} />\n * </Text>\n * </Section>\n * );\n * }\n *\n * registerAugment({\n * id: \"example-cadence-section\",\n * augments: \"space-center-status.sections\",\n * channels: [\"example.heartbeat\"],\n * component: CadenceSection,\n * owner: EXAMPLE,\n * });\n *\n * EXAMPLE.registerContribution({\n * id: \"cadence-badge\",\n * contributes: \"space-center-status.badges\",\n * deps: [\"example.heartbeat\"],\n * // A held heartbeat still draws the badge, carrying its reading so the panel shows it as held.\n * compute: (topics) => {\n * const heartbeat = topics[\"example.heartbeat\"];\n * return heartbeat.state === \"observed\" || heartbeat.state === \"held\"\n * ? [\n * {\n * id: \"cadence\",\n * label: \"Publishing\",\n * tone: \"info\" as const,\n * held: heartbeat,\n * },\n * ]\n * : null;\n * },\n * });\n * ```\n *\n * @category Panel\n * @categoryDescription Panel\n * The frame every widget draws in and what hangs off it: the title, aside and\n * badges, sections and scrolling, the states a widget reports, and the lock\n * marks for what the save has not unlocked. Every widget starts from a\n * {@link Panel}.\n */\nexport const Panel = Object.assign(PanelRoot, {\n Context: PanelContextProvider,\n Delay: PanelDelayRail,\n Container: PanelContainer,\n Header: PanelHeader,\n Toolbar: PanelToolbar,\n Footer: PanelFooter,\n Title: PanelTitle,\n Glow: PanelGlow,\n Body: PanelBody,\n Section,\n Sidebar: PanelSidebar,\n});\n","import { useEffect, useId, useRef, useState } from \"react\";\nimport styled, { css } from \"styled-components\";\nimport { focusRingInset } from \"../focusRing\";\nimport { LiveRegion } from \"../LiveRegion\";\nimport { Tooltip } from \"../Tooltip\";\nimport { TONE_TEXT } from \"../tone\";\nimport { CommandDelay } from \"./CommandDelay\";\nimport { CommandList } from \"./CommandList\";\nimport {\n DelayBand,\n hasRealDelay,\n STREAM_MIN_DELAY_SECONDS,\n} from \"./ControlDelayStream\";\nimport {\n commandFailedSentence,\n type RailFailed,\n} from \"./commandFailedSentence\";\nimport { commandFoundSentence, type RailFound } from \"./commandFoundSentence\";\nimport { commandLossSentence, type RailLoss } from \"./commandLossSentence\";\nimport {\n commandRefusalSentence,\n type RailRefusal,\n} from \"./commandRefusalSentence\";\nimport {\n commandUndeliveredSentence,\n type RailUndelivered,\n} from \"./commandUndeliveredSentence\";\nimport {\n commandWarningSentence,\n type RailWarning,\n} from \"./commandWarningSentence\";\nimport {\n type CommandHandle,\n useActiveHandles,\n useDelayRailStore,\n} from \"./DelayRailContext\";\nimport { InFlightLanes } from \"./InFlightList\";\nimport { claimRailAnnouncer } from \"./railAnnouncer\";\nimport { railMark } from \"./railTags\";\nimport { SETTLE_FADE_MS } from \"./settle\";\nimport {\n type InFlightCommandLike,\n secondsToRailEnd,\n toInFlightListItems,\n} from \"./toInFlightListItems\";\n\n/**\n * Whether a handle's `CommandDelay` would draw anything, mirroring its own\n * null decision: a continuous handle needs real delay and buffers, a discrete\n * one needs in-flight rows. An idle handle stays registered but draws no rail\n * chrome.\n */\n/*\n * One row per command across the panel's handles: a command another screen\n * sent is found by every handle of its command, and one handle's own dispatch\n * by every other handle of the same command, all under the same id.\n */\nfunction withoutRepeatedRows(\n handles: readonly CommandHandle[],\n): CommandHandle[] {\n const seen = new Set<string>();\n return handles.map((handle) => {\n const rows = handle.inFlight.filter((row) => {\n if (seen.has(row.id)) return false;\n seen.add(row.id);\n return true;\n });\n return rows.length === handle.inFlight.length\n ? handle\n : { ...handle, inFlight: rows };\n });\n}\n\n/*\n * One command's outcome reaches every handle of its command on the panel: the\n * one that sent it from its own reply, and the others from the centre's\n * report. It is drawn once.\n */\nfunction firstOfEachId<Item extends { id: string }>(list: Item[]): Item[] {\n const seen = new Set<string>();\n return list.filter((item) => {\n if (seen.has(item.id)) return false;\n seen.add(item.id);\n return true;\n });\n}\n\n/*\n * A warning names its command and says one thing, and a continuous input\n * carries the same one on every dispatch, so each is drawn once.\n */\nfunction distinctWarnings(handles: readonly CommandHandle[]): RailWarning[] {\n const byText = new Map<string, RailWarning>();\n for (const handle of handles) {\n for (const warned of handle.warnings ?? []) {\n const key = `${warned.command}\\u0000${warned.label}\\u0000${warned.warning}`;\n if (!byText.has(key)) {\n byText.set(key, { ...warned, id: key, tags: handle.tags });\n }\n }\n }\n return [...byText.values()];\n}\n\ninterface DepartedRow {\n handleId: string;\n row: InFlightCommandLike;\n}\n\nconst NO_DEPARTED: ReadonlyMap<string, DepartedRow> = new Map();\n\nconst UNANSWERED_PHASES = new Set([\"overdue\", \"lost\"]);\n\n/** The ids of every command a handle reports refused, failed or never sent, and of every late one that ran. */\nfunction outcomeIds(handles: readonly CommandHandle[]): {\n failed: Set<string>;\n ran: Set<string>;\n} {\n const failed = new Set<string>();\n const ran = new Set<string>();\n for (const h of handles) {\n for (const r of h.refusals ?? []) failed.add(r.id);\n for (const f of h.failures ?? []) failed.add(f.id);\n for (const u of h.undelivered ?? []) failed.add(u.id);\n for (const f of h.founds ?? [])\n (f.outcome === \"ran\" ? ran : failed).add(f.id);\n }\n return { failed, ran };\n}\n\n/*\n * A command that leaves the rail is drawn a while longer so its mark never just\n * vanishes. Answered, it carries on through the confirmed stage to the end of\n * the rail at the pace it travelled, then fades. Refused, failed, or dismissed\n * while unanswered, it fades where it was. Kept here rather than in the strip\n * because a handle with no rows left is not drawn at all.\n */\nfunction useSettlingRows(handles: readonly CommandHandle[]): CommandHandle[] {\n const current = new Map<string, DepartedRow>();\n for (const handle of handles) {\n for (const row of handle.inFlight) {\n if (!row.settling) current.set(row.id, { handleId: handle.id, row });\n }\n }\n const { failed, ran } = outcomeIds(handles);\n const [state, setState] = useState<{\n last: ReadonlyMap<string, DepartedRow>;\n settling: ReadonlyMap<string, DepartedRow>;\n }>({ last: NO_DEPARTED, settling: NO_DEPARTED });\n /*\n * Worked out while rendering, not after: a row that left and came back a\n * render later would be a new mark, which starts where it ends up rather\n * than moving there.\n */\n const gone = [...state.last].filter(([id]) => !current.has(id));\n const rowsChanged =\n gone.length > 0 ||\n current.size !== state.last.size ||\n [...current].some(([id, d]) => state.last.get(id)?.row !== d.row);\n if (rowsChanged) {\n const departed = gone.map(([id, d]): [string, DepartedRow] => {\n const kind =\n failed.has(id) ||\n (UNANSWERED_PHASES.has(d.row.predictedPhase) && !ran.has(id))\n ? (\"failed\" as const)\n : (\"confirmed\" as const);\n const settleSeconds = kind === \"confirmed\" ? secondsToRailEnd(d.row) : 0;\n return [id, { ...d, row: { ...d.row, settling: kind, settleSeconds } }];\n });\n setState({\n last: current,\n settling:\n departed.length === 0\n ? state.settling\n : new Map([...state.settling, ...departed]),\n });\n }\n const timersRef = useRef(new Map<string, ReturnType<typeof setTimeout>>());\n useEffect(() => {\n const timers = timersRef.current;\n for (const [id, d] of state.settling) {\n if (timers.has(id)) continue;\n const timer = setTimeout(\n () => {\n timers.delete(id);\n setState((prev) => {\n const next = new Map(prev.settling);\n next.delete(id);\n return { ...prev, settling: next };\n });\n },\n (d.row.settleSeconds ?? 0) * 1000 + SETTLE_FADE_MS,\n );\n timers.set(id, timer);\n }\n }, [state.settling]);\n useEffect(() => {\n const timers = timersRef.current;\n return () => {\n for (const timer of timers.values()) clearTimeout(timer);\n };\n }, []);\n if (state.settling.size === 0) return handles as CommandHandle[];\n return handles.map((handle) => {\n const departed = [...state.settling.values()]\n .filter((d) => d.handleId === handle.id && !current.has(d.row.id))\n // An outcome can land a render after its row left, and turns the row it answers.\n .map((d) =>\n d.row.settling === \"confirmed\" && failed.has(d.row.id)\n ? { ...d.row, settling: \"failed\" as const, settleSeconds: 0 }\n : d.row.settling === \"failed\" && ran.has(d.row.id)\n ? {\n ...d.row,\n settling: \"confirmed\" as const,\n settleSeconds: secondsToRailEnd(d.row),\n }\n : d.row,\n );\n return departed.length === 0\n ? handle\n : { ...handle, inFlight: [...handle.inFlight, ...departed] };\n });\n}\n\nfunction handleHasContent(handle: CommandHandle): boolean {\n if (railMark(handle.tags) === \"ribbon\") {\n const delay = handle.effectiveDelaySeconds;\n const ribbons = handle.ribbons?.length ?? 0;\n const streams = handle.streams?.length ?? 0;\n // CommandDelay's own rule, so a delay it draws nothing for never mounts an empty strip.\n if (!hasRealDelay(delay)) return false;\n // The graph's own rule, so the rail never mounts around nothing: streams need its floor, ribbons do not.\n return (\n ribbons > 0 || ((delay ?? 0) >= STREAM_MIN_DELAY_SECONDS && streams > 0)\n );\n }\n return handle.inFlight.length > 0;\n}\n\n/**\n * The panel's delay rail: a strip along the top edge that shows each command\n * the widget has sent, through {@link CommandDelay}, reading them from the\n * nearest {@link DelayRailContext}. Useful for showing the operator which\n * commands are on their way, and which were refused or lost. Used by\n * {@link Panel}.\n *\n * Every panel reserves the strip whether or not it has a command to show, so\n * a command going out never moves the widget. `Panel` draws it itself; in a\n * hand-composed panel, make it the container's first child.\n *\n * Collapsed, the rail sits in normal flow inside the band and moves nothing.\n * It is a disclosure: a native `<button>` laid over the strip controls the\n * detail beside it. Activating it (Esc collapses) pins the rail, and pinning\n * grows it: each command switches to its `expanded` view and the title and\n * body are pushed down. Opened while the body is already scrolled, it extends\n * over the content instead, so the scroll position is kept. `aria-expanded`\n * carries the pin; hover is a transient preview that says nothing to assistive\n * tech. Pinned, the detail takes its own clicks and only the collapse hint\n * toggles.\n *\n * The strip is empty unless a command is in flight, refused, unanswered,\n * found, never sent, answered with a fault, or accepted with a warning. A\n * command in flight is drawn whichever screen of the command centre sent it.\n *\n * `tiny` is for a tiny panel with no header: the empty strip draws no\n * background, so it does not cover the panel's focus ring.\n */\nexport function PanelDelayRail({ tiny }: { tiny?: boolean } = {}) {\n const handles = useActiveHandles();\n const store = useDelayRailStore();\n useEffect(() => (store ? claimRailAnnouncer(store) : undefined), [store]);\n const visible = withoutRepeatedRows(useSettlingRows(handles)).filter(\n handleHasContent,\n );\n const warnings = distinctWarnings(handles);\n // Outcomes come from EVERY registered handle: a settled command has nothing in flight, so `handleHasContent` would hide it.\n const refusals: RailRefusal[] = firstOfEachId(\n handles.flatMap((h) =>\n (h.refusals ?? []).map((r) => ({ ...r, tags: h.tags })),\n ),\n );\n const losses: RailLoss[] = firstOfEachId(\n handles.flatMap((h) =>\n (h.losses ?? []).map((l) => ({ ...l, tags: h.tags })),\n ),\n );\n // A found answers an unconfirmed command, so it is never counted with the failures.\n const founds: RailFound[] = firstOfEachId(\n handles.flatMap((h) =>\n (h.founds ?? []).map((f) => ({ ...f, tags: h.tags })),\n ),\n );\n // An undelivered command provably did not run, so it counts with the failures.\n const undelivered: RailUndelivered[] = firstOfEachId(\n handles.flatMap((h) =>\n (h.undelivered ?? []).map((u) => ({ ...u, tags: h.tags })),\n ),\n );\n // The mod said what became of each of these, and none of them ran.\n const failures: RailFailed[] = firstOfEachId(\n handles.flatMap((h) =>\n (h.failures ?? []).map((f) => ({ ...f, tags: h.tags })),\n ),\n );\n // A loss may still have run, so it is counted as unconfirmed and never as failed.\n const failedCount = refusals.length + undelivered.length + failures.length;\n const hasContent =\n visible.length > 0 ||\n failedCount > 0 ||\n losses.length > 0 ||\n founds.length > 0 ||\n warnings.length > 0;\n const [pinned, setPinned] = useState(false);\n // Hover preview is React state, not CSS `:hover`, so one flag decides both the height and which view each command draws.\n const [previewing, setPreviewing] = useState(false);\n /*\n * An un-pin click wins over a pointer still resting on the rail. Cleared on\n * the next real `mouseenter`, not on leave: collapsing under a stationary\n * pointer dispatches no `mouseleave`.\n */\n const [suppressHoverPreview, setSuppressHoverPreview] = useState(false);\n const grown = pinned || (previewing && !suppressHoverPreview);\n // With nothing left to show the rail unmounts, so a pin or preview left set would grow the next command's rail before anyone asked.\n useEffect(() => {\n if (hasContent) return;\n setPinned(false);\n setPreviewing(false);\n setSuppressHoverPreview(false);\n }, [hasContent]);\n const detailId = useId();\n\n // Growing the rail moves the title and body by ordinary flow; there is no height to measure or publish.\n\n // Continuous on top, discrete underneath, each keeping its own order.\n const ordered = [\n ...visible.filter((h) => railMark(h.tags) === \"ribbon\"),\n ...visible.filter((h) => railMark(h.tags) !== \"ribbon\"),\n ];\n const hasGraph = visible.some((h) => railMark(h.tags) === \"ribbon\");\n const discrete = ordered.filter((h) => railMark(h.tags) !== \"ribbon\");\n // Opened with no graph of its own, the rail draws the empty graph, so its marks and zone labels read as they do over a stream.\n const bandDelay =\n visible.find((h) => hasRealDelay(h.effectiveDelaySeconds))\n ?.effectiveDelaySeconds ?? null;\n const drawsBand =\n grown &&\n !hasGraph &&\n hasRealDelay(bandDelay) &&\n bandDelay >= STREAM_MIN_DELAY_SECONDS;\n const strip = toInFlightListItems(\n visible\n .filter((h) => railMark(h.tags) !== \"ribbon\")\n .flatMap((h) => h.inFlight),\n );\n\n // Each dismiss routes to the handle that owns the outcome; absent when no handle can dismiss.\n const canDismissRefusal = handles.some(\n (h) => h.dismiss && (h.refusals?.length ?? 0) > 0,\n );\n const dismissRefusal = canDismissRefusal\n ? (id: string) => {\n // Every handle holding it, since each draws the same command.\n for (const h of handles) {\n if (h.refusals?.some((r) => r.id === id)) h.dismiss?.(id);\n }\n }\n : undefined;\n const canDismissLoss = handles.some(\n (h) => h.dismiss && (h.losses?.length ?? 0) > 0,\n );\n const dismissLoss = canDismissLoss\n ? (id: string) =>\n handles.find((h) => h.losses?.some((l) => l.id === id))?.dismiss?.(id)\n : undefined;\n const canDismissUndelivered = handles.some(\n (h) => h.dismiss && (h.undelivered?.length ?? 0) > 0,\n );\n const dismissUndelivered = canDismissUndelivered\n ? (id: string) =>\n handles\n .find((h) => h.undelivered?.some((u) => u.id === id))\n ?.dismiss?.(id)\n : undefined;\n const canDismissFailure = handles.some(\n (h) => h.dismiss && (h.failures?.length ?? 0) > 0,\n );\n const dismissFailure = canDismissFailure\n ? (id: string) => {\n for (const h of handles) {\n if (h.failures?.some((f) => f.id === id)) h.dismiss?.(id);\n }\n }\n : undefined;\n const canDismissFound = handles.some(\n (h) => h.dismiss && (h.founds?.length ?? 0) > 0,\n );\n const dismissFound = canDismissFound\n ? (id: string) => {\n for (const h of handles) {\n if (h.founds?.some((f) => f.id === id)) h.dismiss?.(id);\n }\n }\n : undefined;\n\n return (\n // An EMPTY band carries only its own marker, since every widget renders it.\n <PanelDelayRail__Frame\n data-panel-rail-frame=\"\"\n $tiny={tiny}\n $hasContent={hasContent}\n /* The frame holds the grown lists as well as the strip, so the pointer moving from the strip onto a list never leaves the area that keeps the preview open. */\n onMouseEnter={() => {\n setSuppressHoverPreview(false);\n setPreviewing(true);\n }}\n onMouseLeave={() => setPreviewing(false)}\n >\n {/*\n The rail's one announcer, outside the toggle. Mounted once a command\n registers, before any outcome exists, so the first outcome lands in a\n region assistive tech is already watching.\n */}\n {handles.length > 0 && (\n <LiveRegion visuallyHidden additionsOnly>\n {refusals.map((r) => (\n <span key={`refusal:${r.id}`}>{commandRefusalSentence(r)} </span>\n ))}\n {losses.map((l) => (\n <span key={`loss:${l.id}`}>{commandLossSentence(l)} </span>\n ))}\n {undelivered.map((u) => (\n <span key={`undelivered:${u.id}`}>\n {commandUndeliveredSentence(u)}{\" \"}\n </span>\n ))}\n {failures.map((f) => (\n <span key={`failure:${f.id}`}>{commandFailedSentence(f)} </span>\n ))}\n {founds.map((f) => (\n <span key={`found:${f.id}`}>{commandFoundSentence(f)} </span>\n ))}\n {warnings.map((w) => (\n <span key={`warning:${w.id}`}>{commandWarningSentence(w)}</span>\n ))}\n </LiveRegion>\n )}\n {/* Nothing to draw leaves the band standing EMPTY: the strip is the panel's, not the traffic's. */}\n {!hasContent ? null : (\n <PanelDelayRail__Rail\n data-panel-rail=\"\"\n data-grown={grown}\n data-pinned={pinned}\n data-suppress-hover={suppressHoverPreview}\n onKeyDown={(e) => {\n if (e.key === \"Escape\" && pinned) {\n e.stopPropagation();\n setPinned(false);\n // As with the un-pin click, a resting pointer must not hold the preview open.\n setSuppressHoverPreview(true);\n }\n }}\n >\n {/* Opened with no graph to share, the marks come down into a band of their own, first in the rail. Each names its command on hover and on focus. */}\n {grown && strip.length > 0 && !hasGraph && !drawsBand && (\n <PanelDelayRail__GrownStrip>\n <InFlightLanes items={strip} height={LANES_HEIGHT_PX} />\n </PanelDelayRail__GrownStrip>\n )}\n {/* Closed, the marks are tips too small to point at, so the rail's button names the commands in flight; hovering opens the rail, where each mark names its own. */}\n <Tooltip\n text={\n !grown && strip.length > 0\n ? `In flight: ${strip\n .filter((i) => !i.settling)\n .map((i) => i.label)\n .join(\", \")}`\n : null\n }\n >\n <PanelDelayRail__Toggle\n type=\"button\"\n aria-expanded={pinned}\n aria-controls={detailId}\n aria-label=\"Signal-delay detail\"\n onClick={() => {\n setPinned((p) => {\n const next = !p;\n if (!next) setSuppressHoverPreview(true);\n return next;\n });\n }}\n >\n {/* Hidden rather than unmounted: a node leaving from under a resting pointer reads to React as the pointer entering the rail. */}\n <PanelDelayRail__CollapseHint aria-hidden=\"true\" hidden={!grown}>\n ▲\n </PanelDelayRail__CollapseHint>\n </PanelDelayRail__Toggle>\n </Tooltip>\n <PanelDelayRail__Detail id={detailId} data-panel-rail-detail=\"\">\n {drawsBand && bandDelay !== null && (\n <DelayBand\n oneWay={bandDelay}\n variant=\"expanded\"\n ariaLabel=\"Delay detail\"\n />\n )}\n {ordered\n .filter((h) => !grown || railMark(h.tags) === \"ribbon\")\n .map((h) => (\n <CommandDelay\n key={h.id}\n handle={h}\n variant={grown ? \"expanded\" : \"rail\"}\n // A handle that names its own graph keeps that name at both heights.\n aria-label={\n h[\"aria-label\"] ?? (grown ? \"Delay detail\" : undefined)\n }\n />\n ))}\n {/* Opened, every command of every handle is one queue, one box. */}\n {grown && discrete.length > 0 && (\n <CommandDelay\n key=\"queue\"\n handles={discrete}\n variant=\"expanded\"\n aria-label=\"Commands in flight\"\n />\n )}\n {!grown &&\n (failedCount > 0 ||\n losses.length > 0 ||\n founds.length > 0 ||\n warnings.length > 0) && (\n // One run for every count, since they share the band's single grid cell.\n <PanelDelayRail__Summaries>\n {failedCount > 0 && (\n <PanelDelayRail__WarnSummary>\n {failedCount === 1\n ? \"1 command failed\"\n : `${failedCount} commands failed`}\n </PanelDelayRail__WarnSummary>\n )}\n {losses.length > 0 && (\n <PanelDelayRail__WarnSummary>\n {losses.length === 1\n ? \"1 command unconfirmed\"\n : `${losses.length} commands unconfirmed`}\n </PanelDelayRail__WarnSummary>\n )}\n {warnings.length > 0 && (\n <PanelDelayRail__WarnSummary>\n {warnings.length === 1\n ? \"1 warning\"\n : `${warnings.length} warnings`}\n </PanelDelayRail__WarnSummary>\n )}\n {founds.length > 0 && (\n <PanelDelayRail__FoundSummary>\n {founds.length === 1\n ? \"1 unconfirmed command answered\"\n : `${founds.length} unconfirmed commands answered`}\n </PanelDelayRail__FoundSummary>\n )}\n </PanelDelayRail__Summaries>\n )}\n </PanelDelayRail__Detail>\n {/* Opened over a graph, the marks lie on it; last in the rail, so they paint over the graph and the rail's button. */}\n {grown && strip.length > 0 && (hasGraph || drawsBand) && (\n <PanelDelayRail__GrownStrip data-over-graph=\"true\">\n <InFlightLanes items={strip} height={GRAPH_HEIGHT_PX} />\n </PanelDelayRail__GrownStrip>\n )}\n </PanelDelayRail__Rail>\n )}\n {/* Outside the rail, so the grown lists push the panel down rather than share the rail's grid cell. */}\n {grown && warnings.length > 0 && (\n <CommandList kind=\"warned\" entries={warnings} live={false} />\n )}\n {grown && refusals.length > 0 && (\n <CommandList\n kind=\"refused\"\n entries={refusals}\n onDismiss={dismissRefusal}\n live={false}\n />\n )}\n {grown && losses.length > 0 && (\n <CommandList\n kind=\"lost\"\n entries={losses}\n onDismiss={dismissLoss}\n live={false}\n />\n )}\n {grown && undelivered.length > 0 && (\n <CommandList\n kind=\"undelivered\"\n entries={undelivered}\n onDismiss={dismissUndelivered}\n live={false}\n />\n )}\n {grown && failures.length > 0 && (\n <CommandList\n kind=\"failed\"\n entries={failures}\n onDismiss={dismissFailure}\n live={false}\n />\n )}\n {/* Last, so reading down the rail meets the silence and then its answer. */}\n {grown && founds.length > 0 && (\n <CommandList\n kind=\"found\"\n entries={founds}\n onDismiss={dismissFound}\n live={false}\n />\n )}\n </PanelDelayRail__Frame>\n );\n}\n\n/**\n * The rail's box: exactly the band tall when collapsed, pushing the header and\n * body down by every pixel it grows past it. The band is permanent, so a\n * command arriving never moves a watching widget's content. The negative top\n * margin pulls it into `PanelContainer`'s top inset in the container placement;\n * `PanelStickyTop` gives it back inside the sticky unit.\n */\nconst PanelDelayRail__Frame = styled.div<{\n $tiny?: boolean;\n $hasContent?: boolean;\n}>`\n /* Never shrinks below its content: the grown rail keeps its full height and the body gives up the difference. */\n flex: 0 0 auto;\n /* Fully opaque so content scrolling under the rail never ghosts through: except a tiny panel's empty band, which paints nothing so the panel's own focus ring stays visible behind it. */\n background: ${({ $tiny, $hasContent }) =>\n $tiny && !$hasContent ? \"transparent\" : \"var(--color-surface-panel)\"};\n /* Up into the container's top inset, the band; both read --panel-rail-band, so they cannot drift. */\n margin-top: calc(-1 * var(--panel-rail-band));\n min-height: var(--panel-rail-band);\n`;\n\n/**\n * The rail, filling the reserved band. Collapsed, every handle overlays in one\n * grid cell capped at the band's height. Grown (hover or pin), it becomes a\n * flex column that outgrows the band and pushes the title and body down.\n */\nconst grownRail = css`\n display: flex;\n flex-direction: column;\n gap: var(--gap-delay-rail);\n /* A generous cap the grown content fits inside; the visible height settles at the content height. */\n max-height: 800px;\n /* Full-bleed, so the stream graph spans the widget edge to edge; each child owns its own inset. */\n padding: 0;\n\n & > *,\n & > [data-panel-rail-detail] > * {\n grid-area: auto;\n }\n`;\n\nconst PanelDelayRail__Rail = styled.div`\n width: 100%;\n margin: 0;\n padding: 0;\n position: relative;\n\n /* Height follows min(content, max-height), so animating max-height opens and collapses the rail (auto is not animatable). */\n display: grid;\n height: auto;\n /* The band, and nothing over it: the strip a widget reserves is the strip the rail fills. */\n max-height: var(--panel-rail-band);\n overflow: hidden;\n transition: max-height var(--duration-slow) var(--ease-standard);\n\n & > *,\n & > [data-panel-rail-detail] > * {\n grid-area: 1 / 1;\n }\n\n &:not([data-pinned=\"true\"]) > [data-panel-rail-detail] > * {\n pointer-events: none;\n }\n\n @media (prefers-reduced-motion: reduce) {\n transition: none;\n }\n\n /* Open (pinned or hover preview) grows past the band, driven by React state because the published height must be the grown one only. */\n &[data-grown=\"true\"] {\n ${grownRail}\n }\n`;\n\n/**\n * The disclosure button, laid over the whole rail with no chrome of its own, so\n * the strip is one click target and the focus ring traces the rail's edge.\n * Pinned, it lets pointer events through to the detail and takes a click only\n * on its collapse hint.\n */\nconst PanelDelayRail__Toggle = styled.button`\n appearance: none;\n position: absolute;\n inset: 0;\n border: 0;\n margin: 0;\n padding: 0;\n background: transparent;\n color: inherit;\n font: inherit;\n cursor: pointer;\n\n ${focusRingInset}\n\n &[aria-expanded=\"true\"] {\n pointer-events: none;\n }\n\n`;\n\n/** The opened graph's height, which the lanes share. */\nconst GRAPH_HEIGHT_PX = 86;\n/** The lanes' own band, where there is no graph to share. */\nconst LANES_HEIGHT_PX = 40;\n\n/** The opened rail's command marks: over the graph at the top of the rail, or a band of their own in flow. */\nconst PanelDelayRail__GrownStrip = styled.div`\n pointer-events: none;\n\n &[data-over-graph=\"true\"] {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n }\n`;\n\n/**\n * The detail the toggle controls. It generates no box, so each command stays\n * a direct grid or flex item of the rail and lays out exactly as a child of it.\n */\nconst PanelDelayRail__Detail = styled.div`\n display: contents;\n`;\n\n/**\n * The collapsed strip's failure count: only the count, since a sentence cannot\n * fit the band. Not a live region; the rail's own announcer reads each outcome.\n */\nconst PanelDelayRail__WarnSummary = styled.span`\n color: ${TONE_TEXT.warn};\n`;\n\n/** The end-aligned run both collapsed-strip counts sit in. */\nconst PanelDelayRail__Summaries = styled.span`\n align-self: center;\n justify-self: end;\n display: flex;\n gap: var(--gap-rail-summaries);\n padding: 0 var(--gutter-panel);\n font-size: var(--font-size-compact);\n /* Flush, so single-line chrome text fits the reserved band on a coarse pointer too. */\n line-height: var(--line-height-flush);\n font-weight: 700;\n letter-spacing: 0.04em;\n white-space: nowrap;\n pointer-events: none;\n`;\n\n/** The collapsed strip's found count, in the notice colour because it says the opposite of the failure count. */\nconst PanelDelayRail__FoundSummary = styled.span`\n color: var(--color-info-text);\n`;\n\n/**\n * The grown rail's sighted cue that it collapses; `aria-expanded` carries it\n * for assistive tech. Pinned, it is the rail's one click target, reaching past\n * the glyph.\n */\nconst PanelDelayRail__CollapseHint = styled.span`\n position: absolute;\n top: var(--offset-rail-hint);\n right: var(--gutter-panel);\n font-size: var(--font-size-caption);\n color: var(--color-text-muted);\n letter-spacing: 0.06em;\n text-transform: uppercase;\n pointer-events: auto;\n cursor: pointer;\n z-index: 1;\n\n &::before {\n content: \"\";\n position: absolute;\n inset: calc(-1 * var(--outset-rail-hint-target));\n }\n`;\n","import styled from \"styled-components\";\nimport { TONE_LABEL, TONE_MARK, TONE_ON_STATUS, TONE_STATUS } from \"../tone\";\nimport type { Severity } from \"./severity\";\n\nexport interface PanelStatusDotProps {\n severity: Severity;\n /**\n * How many contributors sit at this severity. The number is shown inside the\n * dot only when greater than 1; a single contributor is just the coloured dot.\n * Defaults to 1.\n */\n count?: number;\n}\n\n/**\n * One per-severity status dot for a {@link Panel}'s collapsed header. Useful\n * for telling the operator the worst states a panel reports when its title and\n * aside no longer fit side by side. Used by {@link Panel}.\n *\n * The dot is a small coloured disc carrying the count when more than one\n * contributor sits at that severity, growing sideways into a pill when the\n * count takes more than one digit.\n *\n * It carries `role=\"img\"` and an accessible name (\"warning\", \"3 caution\")\n * rather than being hidden: in a collapsed header the dot row is the status\n * display, so a screen reader must reach it.\n */\nexport function PanelStatusDot({ severity, count = 1 }: PanelStatusDotProps) {\n const withCount = count > 1;\n return (\n <PanelStatusDot__Root\n data-panel-status-dot=\"\"\n data-severity={severity}\n role=\"img\"\n aria-label={\n withCount ? `${count} ${TONE_LABEL[severity]}` : TONE_LABEL[severity]\n }\n $mark={TONE_MARK[severity]}\n $digits={withCount ? String(count).length : 1}\n >\n {withCount && (\n <PanelStatusDot__Count\n $fill={TONE_STATUS[severity]}\n $ink={TONE_ON_STATUS[severity]}\n >\n <PanelStatusDot__Digits aria-hidden=\"true\">\n <text x=\"50%\" y=\"50%\" dy=\"0.365em\" textAnchor=\"middle\">\n {count}\n </text>\n </PanelStatusDot__Digits>\n </PanelStatusDot__Count>\n )}\n </PanelStatusDot__Root>\n );\n}\n\n// Sized to the panel title's cap-height, not its font-size, so the dot sits inside the title's text line.\nconst DOT_DIAMETER = \"8px\";\n\nconst PanelStatusDot__Root = styled.span<{\n $mark: string;\n $digits: number;\n}>`\n position: relative;\n flex: 0 0 auto;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n /* One fixed diameter whether or not a count is shown; the count is out of flow, so it cannot affect this box's size. */\n height: ${DOT_DIAMETER};\n /* The count's own size, so the width below can be counted in its digits. Digits this size are six pixels tall, which centre in the eight-pixel dot on whole pixels; at seven they are five, and one engine places the baseline half a pixel above or below the middle. */\n font-size: 8px;\n /* More than one digit grows the dot sideways into a pill, keeping its height and its place on the title's line. */\n width: ${({ $digits }) =>\n $digits > 1 ? `calc(${$digits}ch + 4px)` : DOT_DIAMETER};\n border-radius: ${({ $digits }) =>\n $digits > 1 ? \"var(--radius-pill)\" : \"var(--radius-circle)\"};\n background: ${({ $mark }) => $mark};\n /* A rim in a lighter tint of the dot's own fill plus a glow bloom, so the dot reads as a lit indicator. */\n box-shadow:\n 0 0 0 1px color-mix(in srgb, ${({ $mark }) => $mark} 78%, white),\n 0 0 4px 1px ${({ $mark }) => $mark};\n`;\n\n/* A lone dot is a mark; one carrying its count is a status fill under its own text, so the count paints that fill over the whole dot. */\nconst PanelStatusDot__Count = styled.span<{ $fill: string; $ink: string }>`\n /* Out of flow, centred over the fixed parent box with no say over its size. */\n position: absolute;\n inset: 0;\n border-radius: inherit;\n background: ${({ $fill }) => $fill};\n display: flex;\n align-items: center;\n justify-content: center;\n pointer-events: none;\n color: ${({ $ink }) => $ink};\n /* Below the --font-size-2xs floor, which would not fit the 8px dot. */\n font-size: inherit;\n font-variant-numeric: tabular-nums;\n font-weight: 700;\n line-height: var(--line-height-flush);\n`;\n\n/*\n * The count is SVG text, not a text node: HTML text places its glyph origin on a device pixel\n * independently of where the dot's box snaps, so a dot at a fractional position in a header drew\n * its digits up to a pixel off centre. SVG text is placed from the same box. The half-cap-height\n * shift (0.365em, the digits' cap height of 0.73em halved) puts the digits' middle on the dot's.\n */\nconst PanelStatusDot__Digits = styled.svg`\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n overflow: visible;\n fill: currentColor;\n`;\n","import { css } from \"styled-components\";\n\n/**\n * The one treatment for a container's own name: a panel's header and a modal's\n * title. It takes the value size, since a title names its container rather than\n * annotating something beside it, and keeps the uppercase, tracked, dim family\n * that gives the chrome its character.\n */\nexport const titleText = css`\n font-size: var(--font-size-value);\n font-weight: 600;\n letter-spacing: 0.15em;\n text-transform: uppercase;\n color: var(--color-text-dim);\n`;\n","import {\n type RefObject,\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\n\n/**\n * Room to spare a longer form needs before it wins back. Without it a box\n * sitting exactly on the boundary alternates forever, because showing the\n * longer form is what makes it not fit.\n */\nconst RELENGTHEN_MARGIN_PX = 12;\n\n/**\n * One candidate's natural width, measured on an isolated clone of `el` with its\n * text replaced, so the font and spacing are the real ones and a flex-squeezed\n * live box cannot report its squeezed width.\n *\n * Every candidate carries its own text, the full form included: reading the\n * live element back after a shortening would measure the short text as the\n * full form's width and oscillate.\n */\nfunction measureCandidateWidth(el: HTMLElement | null, text: string): number {\n if (!el || typeof document === \"undefined\") return 0;\n const clone = el.cloneNode(true) as HTMLElement;\n clone.textContent = text;\n clone.style.position = \"fixed\";\n clone.style.visibility = \"hidden\";\n clone.style.pointerEvents = \"none\";\n clone.style.left = \"-99999px\";\n clone.style.top = \"-99999px\";\n // The live element truncates within its column; the clone must report the width the text wants.\n clone.style.width = \"max-content\";\n clone.style.maxWidth = \"none\";\n document.body.appendChild(clone);\n const width = clone.getBoundingClientRect().width;\n document.body.removeChild(clone);\n return width;\n}\n\n/**\n * Which candidate fits, as an index into a longest-first list. Useful for\n * showing the operator the longest title form that fits a small tile. Used by\n * {@link useFittedTitle}.\n *\n * Anything unmeasured (a zero available width, or a first candidate that\n * measured zero) holds index 0, the full form: shortening a title on a\n * measurement that never happened is worse than leaving it long.\n */\nexport function fittedTitleIndex(\n previous: number,\n available: number,\n widths: readonly number[],\n): number {\n if (available <= 0 || widths.length === 0 || widths[0] <= 0) return 0;\n for (let i = 0; i < widths.length; i++) {\n // Growing back to a form longer than the current one has to clear the margin; shrinking to this one, or staying put, does not.\n const room = i < previous ? available - RELENGTHEN_MARGIN_PX : available;\n if (widths[i] <= room) return i;\n }\n return widths.length - 1;\n}\n\n/**\n * The title form to render, given the full one and any shorter alternatives,\n * chosen by measuring the box. Useful for showing the operator the longest\n * title that fits a small tile. Used by the title of {@link Panel}.\n *\n * `compact` is longest-first, so \"ORBIT VIEW\" then \"OVIEW\" then \"OV\" is a full\n * title of `ORBIT VIEW` with `compact={[\"OVIEW\", \"OV\"]}`. The returned\n * `compacted` flag is what earns the full name an `aria-label` and a tooltip: a\n * screen reader hearing \"KSC\" has lost something a sighted operator only gave\n * up because the tile is small.\n */\nexport function useFittedTitle(\n titleRef: RefObject<HTMLElement | null>,\n full: string,\n compact: readonly string[],\n): { index: number; compacted: boolean } {\n const [index, setIndex] = useState(0);\n const indexRef = useRef(index);\n indexRef.current = index;\n\n // `compact` is a fresh array on most renders, so its contents are the key, joined on a newline because a short title may contain spaces.\n const key = [full, ...compact].join(\"\\n\");\n\n const recompute = useCallback(() => {\n const el = titleRef.current;\n const forms = key.split(\"\\n\");\n if (!el || forms.length < 2) {\n if (indexRef.current !== 0) {\n indexRef.current = 0;\n setIndex(0);\n }\n return;\n }\n const widths = forms.map((text) => measureCandidateWidth(el, text));\n const next = fittedTitleIndex(indexRef.current, el.clientWidth, widths);\n if (next !== indexRef.current) {\n indexRef.current = next;\n setIndex(next);\n }\n }, [titleRef, key]);\n\n // A changed title moves no box a ResizeObserver would see, so it recomputes through `recompute`'s identity.\n useLayoutEffect(() => {\n recompute();\n }, [recompute]);\n\n useEffect(() => {\n const el = titleRef.current;\n if (!el || typeof ResizeObserver === \"undefined\") return;\n const ro = new ResizeObserver(() => recompute());\n ro.observe(el);\n return () => ro.disconnect();\n }, [titleRef, recompute]);\n\n return { index, compacted: index > 0 };\n}\n","import { useEffect, useRef, useState } from \"react\";\n\n/**\n * Observe the registered scroller and derive a value from it, recomputed on\n * scroll and on any size or child-list change to the scroller. Useful for\n * showing the operator that more content lies beyond the visible edge. Used by\n * {@link Panel}, {@link Disclosure} and the kit's data table. Drivable in jsdom\n * by dispatching a `scroll` event.\n */\nexport function useScrollerMetric<Metric>(\n el: HTMLElement | null,\n compute: (el: HTMLElement) => Metric,\n isEqual: (a: Metric, b: Metric) => boolean,\n initial: Metric,\n): Metric {\n const [value, setValue] = useState<Metric>(initial);\n // Latest closures without re-subscribing: the effect keys off `el` alone.\n const computeRef = useRef(compute);\n computeRef.current = compute;\n const equalRef = useRef(isEqual);\n equalRef.current = isEqual;\n const valueRef = useRef(value);\n valueRef.current = value;\n\n useEffect(() => {\n if (!el) return;\n // Held beside the state so an unchanged reading never reaches `setValue`: a subtree observer fires often, and a no-op set still schedules a render.\n let last = valueRef.current;\n const update = () => {\n const next = computeRef.current(el);\n if (equalRef.current(last, next)) return;\n last = next;\n setValue(next);\n };\n update();\n el.addEventListener(\"scroll\", update, { passive: true });\n const ro = new ResizeObserver(update);\n ro.observe(el);\n for (const child of Array.from(el.children)) ro.observe(child);\n let frame: number | undefined;\n const mo = new MutationObserver((records) => {\n if (records.some((r) => r.type === \"childList\")) {\n for (const child of Array.from(el.children)) ro.observe(child);\n update();\n return;\n }\n // A style change deep inside can resize content past the scroller's edge; checked once a frame, since an animated descendant restyles every frame.\n if (frame === undefined)\n frame = requestAnimationFrame(() => {\n frame = undefined;\n update();\n });\n });\n // The subtree, because content can overflow the scroller from a descendant without any observed box changing size.\n mo.observe(el, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: [\"style\"],\n });\n return () => {\n el.removeEventListener(\"scroll\", update);\n ro.disconnect();\n mo.disconnect();\n if (frame !== undefined) cancelAnimationFrame(frame);\n };\n }, [el]);\n\n return value;\n}\n\n/**\n * Whether a scroller's content runs past its box on either axis. Useful for\n * deciding whether the operator needs a scroll cue.\n */\nexport function overflowsBox(el: HTMLElement): boolean {\n return el.scrollHeight > el.clientHeight || el.scrollWidth > el.clientWidth;\n}\n\n/**\n * The `tabIndex` a scroll body takes: 0 while its content overflows, so it can\n * be scrolled from the keyboard in WebKit, which never focuses a scroller on\n * its own; none while everything fits, so a body with nothing to scroll adds\n * no tab stop. Useful for letting an operator who uses the keyboard scroll a\n * body. Used by {@link Panel}, {@link Disclosure} and the kit's data table.\n */\nexport function useKeyboardScrollable(el: HTMLElement | null): 0 | undefined {\n const overflows = useScrollerMetric(el, overflowsBox, Object.is, false);\n return overflows ? 0 : undefined;\n}\n","import type { Tone } from \"@ksp-gonogo/sitrep-sdk\";\nimport styled from \"styled-components\";\nimport { TONE_MARK } from \"./tone\";\n\n/**\n * Props for {@link LevelBars}. Useful for setting how many bars show the\n * operator a level. Taken by {@link LevelBars}.\n *\n * @category Meter\n */\nexport interface LevelBarsProps {\n /** How many bars are lit, or null when there is nothing to judge by. Zero is a reading, and draws every bar unlit. */\n lit: number | null;\n /** How many bars the glyph has. */\n of: number;\n /**\n * Colour of the lit bars.\n *\n * @defaultValue `\"neutral\"`\n */\n tone?: Tone;\n /** What the glyph measures, spoken before the count: \"Signal\" reads \"Signal 3 of 4\". */\n label?: string;\n}\n\n/**\n * A stepped level glyph, bars rising left to right with `lit` of them filled,\n * as in a signal-strength indicator. Useful for showing the operator a level\n * such as the strength of the signal between a vessel and the command centre\n * at a glance. Used by {@link TinyEssentials} for an essential that declares a\n * level.\n *\n * It is sized in em, so it scales with the figure it stands beside.\n *\n * @category Meter\n */\nexport function LevelBars({\n lit,\n of,\n tone = \"neutral\",\n label,\n}: LevelBarsProps) {\n const count = lit === null ? \"unknown\" : `${lit} of ${of}`;\n return (\n <LevelBars__Root\n role=\"img\"\n aria-label={label === undefined ? count : `${label} ${count}`}\n data-level-bars=\"\"\n >\n {Array.from({ length: of }, (_, index) => (\n <LevelBars__Bar\n // biome-ignore lint/suspicious/noArrayIndexKey: a bar is its position\n key={index}\n $fill={lit !== null && index < lit ? TONE_MARK[tone] : null}\n $height={(index + 1) / of}\n />\n ))}\n </LevelBars__Root>\n );\n}\n\nconst LevelBars__Root = styled.span`\n display: inline-flex;\n align-items: flex-end;\n gap: var(--gap-signal-bars);\n height: 0.8em;\n flex: none;\n`;\n\nconst LevelBars__Bar = styled.span<{ $fill: string | null; $height: number }>`\n width: 0.22em;\n height: ${({ $height }) => `${Math.round($height * 100)}%`};\n background: ${({ $fill }) => $fill ?? \"transparent\"};\n border: 1px solid ${({ $fill }) => $fill ?? \"var(--color-border-subtle)\"};\n`;\n","import type { Tone } from \"@ksp-gonogo/sitrep-sdk\";\nimport type { ButtonHTMLAttributes } from \"react\";\nimport { forwardRef } from \"react\";\nimport { Button } from \"./Button\";\nimport {\n CommandedToggle,\n type CommandedToggleProps,\n} from \"./CommandButton/CommandedButton\";\nimport type { ReckoningMarking } from \"./readingCurrency\";\n\n/**\n * The fill a pressed {@link ToggleButton} takes: `go`, or `nogo` / `warn` when\n * being on is destructive or needs attention. Useful for telling the operator\n * at a glance how serious an active option is. Taken by the `tone` prop of\n * {@link ToggleButton}.\n *\n * @category Button\n */\nexport type ToggleButtonTone = Extract<Tone, \"go\" | \"nogo\" | \"warn\">;\n\n/**\n * The size of a {@link ToggleButton}, the same steps as {@link ButtonSize}.\n * Taken by the `size` prop of {@link ToggleButton}.\n *\n * @category Button\n */\nexport type ToggleButtonSize = \"sm\" | \"md\";\n\n/**\n * Props for {@link ToggleButton}. Any other `button` attribute passes through.\n * Useful for showing the operator which of several peer options is on. Taken by\n * {@link ToggleButton}.\n *\n * @category Button\n */\nexport type ToggleButtonProps = PlainToggleButtonProps | CommandedToggleProps;\n\n/**\n * Props for {@link ToggleButton} with no command: a native button's attributes\n * and whether it is pressed. Any other `button` attribute passes through.\n *\n * @category Button\n */\nexport type PlainToggleButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {\n /** Set `command` to make the toggle send a command; see {@link CommandedToggleProps}. */\n command?: undefined;\n /** Whether the toggle is on. Drives `aria-pressed` and the filled look. Defaults to `false`. */\n pressed?: boolean;\n /** The fill while pressed. Defaults to `go`. */\n tone?: ToggleButtonTone;\n /** Defaults to `md`. */\n size?: ToggleButtonSize;\n /** Why the toggle is disabled, shown as its tip. As for {@link Button}. */\n disabledReason?: string;\n /** Marks the state shown as held or modelled; the button stays pressable. As for {@link Button}. */\n marked?: ReckoningMarking | null;\n};\n\n/**\n * A two-state toggle: a real `<button>` whose `aria-pressed` follows `pressed`,\n * for controls that switch between on and off (mode pickers, filter toggles,\n * rate pickers). It draws as a {@link Button}, filled in `tone` while pressed\n * and plain while not. Useful for showing the operator which of several peer\n * options is on. Used by the station radio push-to-talk and mute controls.\n *\n * ToggleButton or {@link Switch}? They are different ARIA patterns:\n *\n * - ToggleButton is a button whose label is the thing being chosen, usually\n * one of several peers (warp rates, a filter row, a view mode). Pressing it\n * acts, and `aria-pressed` says which peer is on\n * - `Switch` is a single boolean setting with a label beside it, rendered as a\n * checkbox with a track and thumb. It configures rather than acts\n *\n * If the control sits in a row of alternatives, it is a ToggleButton. If it\n * sits in a settings list next to its own label, it is a Switch.\n *\n * @example\n * ```tsx\n * import { Inline, ToggleButton } from \"@ksp-gonogo/ui-kit\";\n *\n * const RATES = [1, 2, 3, 4] as const;\n *\n * function RatePicker(props: {\n * current: number;\n * setRate: (rate: number) => void;\n * }) {\n * return (\n * <Inline>\n * {RATES.map((rate) => (\n * <ToggleButton\n * key={rate}\n * size=\"sm\"\n * pressed={rate === props.current}\n * onClick={() => props.setRate(rate)}\n * >\n * {rate}x\n * </ToggleButton>\n * ))}\n * </Inline>\n * );\n * }\n * ```\n *\n * @category Button\n */\nexport const ToggleButton = forwardRef<HTMLButtonElement, ToggleButtonProps>(\n function ToggleButton(props, ref) {\n if (props.command !== undefined) return <CommandedToggle {...props} />;\n const {\n pressed = false,\n tone = \"go\",\n size = \"md\",\n type = \"button\",\n \"aria-pressed\": ariaPressed,\n command: _command,\n ...rest\n } = props;\n return (\n <Button\n ref={ref}\n type={type}\n /* The tone colours the pressed fill only; an inactive toggle is a plain button. */\n tone={pressed ? tone : undefined}\n size={size}\n pressed={pressed}\n aria-pressed={ariaPressed ?? pressed}\n {...rest}\n />\n );\n },\n);\n","import { useId, useMemo } from \"react\";\n\n/** Linear scale from an input domain to an output range; a zero-width domain maps to the middle of the range. */\nfunction makeScale(\n domainMin: number,\n domainMax: number,\n rangeMin: number,\n rangeMax: number,\n): (v: number) => number {\n const span = domainMax - domainMin;\n if (span === 0) {\n const mid = (rangeMin + rangeMax) / 2;\n return () => mid;\n }\n return (v) => rangeMin + ((v - domainMin) / span) * (rangeMax - rangeMin);\n}\n\n/** SVG path through the samples, in order. */\nfunction buildPath(\n ts: number[],\n vs: number[],\n scaleX: (v: number) => number,\n scaleY: (v: number) => number,\n): string {\n return ts\n .map(\n (t, i) =>\n `${i === 0 ? \"M\" : \"L\"}${scaleX(t).toFixed(2)},${scaleY(vs[i]).toFixed(2)}`,\n )\n .join(\" \");\n}\n\n/**\n * Props for {@link Sparkline}. Useful for drawing a small trend where a figure\n * sits. Taken by {@link Sparkline}.\n *\n * @category LineGraph\n */\nexport interface SparklineProps {\n /** The samples, oldest to newest; a flat series still draws a visible band. */\n values: ReadonlyArray<number>;\n /** The drawn width in pixels. */\n width: number;\n /** The drawn height in pixels. */\n height: number;\n /** Stroke colour. Defaults to `var(--color-text-primary)`. */\n color?: string;\n /** Stroke width in pixels. Defaults to 1.5. */\n strokeWidth?: number;\n /** Pin the Y range; otherwise auto-scaled. Useful for \"0..max-throttle\" gauges. */\n yDomain?: [number, number];\n /** Render a faint baseline at y=0 if 0 falls within the visible range. */\n showZeroBaseline?: boolean;\n /** The faint fill under the line; set false inside a chip that has its own background. */\n background?: boolean;\n /** ARIA label for screen readers. Defaults to \"Trend sparkline\". */\n \"aria-label\"?: string;\n}\n\n/**\n * An inline trendline over the samples it is given, with no axes or labels,\n * drawn to the pixel size it is handed. Useful for showing the operator which\n * way a figure has been moving in the last few minutes. Used by the tiny form\n * of a widget whose essential carries a `trend`, and by the small readouts\n * that draw a trend under their figure.\n *\n * @category LineGraph\n */\nexport function Sparkline({\n values,\n width,\n height,\n color = \"var(--color-text-primary)\",\n strokeWidth = 1.5,\n yDomain,\n showZeroBaseline = false,\n background = true,\n \"aria-label\": ariaLabel = \"Trend sparkline\",\n}: Readonly<SparklineProps>) {\n // A stray NaN would collapse the auto-domain.\n const finite = useMemo(\n () => values.filter((v) => Number.isFinite(v)) as number[],\n [values],\n );\n\n // useId's colons are not valid inside an SVG url(#id) reference.\n const fillId = `sparkline-fill-${useId().replace(/:/g, \"\")}`;\n\n const domain = useMemo<[number, number]>(() => {\n if (yDomain) return yDomain;\n if (finite.length === 0) return [0, 1];\n let min = finite[0];\n let max = finite[0];\n for (const v of finite) {\n if (v < min) min = v;\n if (v > max) max = v;\n }\n if (min === max) {\n const pad = Math.abs(min) > 0 ? Math.abs(min) * 0.01 : 1;\n return [min - pad, max + pad];\n }\n return [min, max];\n }, [yDomain, finite]);\n\n if (width <= 0 || height <= 0 || finite.length < 2) {\n return (\n <svg\n width={Math.max(0, width)}\n height={Math.max(0, height)}\n role=\"img\"\n aria-label={ariaLabel}\n style={{ display: \"block\" }}\n >\n <title>{ariaLabel}</title>\n </svg>\n );\n }\n\n // Half a stroke width of padding keeps the extreme points from being clipped by the SVG box.\n const padY = strokeWidth / 2;\n const xs = finite.map((_, i) => i);\n const scaleX = makeScale(0, finite.length - 1, 0, width);\n const scaleY = makeScale(domain[0], domain[1], height - padY, padY);\n const d = buildPath(xs, finite, scaleX, scaleY);\n const dFill = `${d} L ${width},${height} L 0,${height} Z`;\n\n const showBaseline = showZeroBaseline && domain[0] <= 0 && domain[1] >= 0;\n const zeroY = showBaseline ? scaleY(0) : null;\n\n return (\n <svg\n width={width}\n height={height}\n role=\"img\"\n aria-label={ariaLabel}\n style={{ display: \"block\" }}\n >\n <title>{ariaLabel}</title>\n {background && (\n <defs>\n <linearGradient id={fillId} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n <stop offset=\"0%\" stopColor={color} stopOpacity=\"0.25\" />\n <stop offset=\"100%\" stopColor={color} stopOpacity=\"0.02\" />\n </linearGradient>\n </defs>\n )}\n {showBaseline && zeroY !== null && (\n <line\n x1={0}\n y1={zeroY}\n x2={width}\n y2={zeroY}\n stroke=\"var(--color-border-subtle)\"\n strokeWidth={1}\n />\n )}\n {background && <path d={dFill} fill={`url(#${fillId})`} stroke=\"none\" />}\n <path\n d={d}\n stroke={color}\n strokeWidth={strokeWidth}\n fill=\"none\"\n strokeLinejoin=\"round\"\n strokeLinecap=\"round\"\n />\n </svg>\n );\n}\n","/**\n * How much room a widget tile has, derived from its `w` and `h` grid units by\n * {@link getSizeBucket} so every widget uses the same boundaries.\n *\n * - `tiny`: a single-glance status or one key readout; under 5 columns wide or\n * 4 rows tall\n * - `small`: essential numbers, minimal chrome; under 8 columns wide or 7 rows\n * tall\n * - `normal`: the full widget UI\n *\n * A widget that declares a tiny mode is drawn by the kit in `tiny`; every other\n * bucket, and every bucket of a widget without one, is the widget's own to lay\n * out. Useful for deciding how much detail to show the operator in a tile.\n * Returned by {@link getSizeBucket}, which a graph and an action group widget\n * call.\n *\n * @category Layout\n */\nexport type SizeBucket = \"tiny\" | \"small\" | \"normal\";\n\nexport { TINY_SIZE } from \"@ksp-gonogo/sitrep-sdk\";\n\n/**\n * A tile narrower or shorter than this is `tiny`. Useful for judging whether\n * the operator sees a widget's tiny form. Used by {@link getSizeBucket} and the\n * kit's tiny form.\n *\n * @category Layout\n */\nexport const TINY_BELOW = {\n /** Width in grid columns: a tile under 5 columns wide is `tiny`. */\n w: 5,\n /** Height in grid rows: a tile under 4 rows tall is `tiny`. */\n h: 4,\n} as const;\nconst SMALL_W = 8;\nconst SMALL_H = 7;\n\n/**\n * The {@link SizeBucket} a `w` by `h` tile falls in: `tiny` below\n * {@link TINY_BELOW} on either axis, `small` below 8 columns wide or 7 rows tall, `normal`\n * otherwise. Returns `normal` while either dimension is `undefined`. Useful for\n * choosing how much a widget shows the operator at the tile's size. Used by the\n * graph and action group widgets.\n *\n * This is the bucket by size alone, for a widget arranging its own body.\n * Whether the dashboard draws a widget's tiny form in place of that body is a\n * different question with the widget's own `minSize` in it: ask `showsTiny`.\n *\n * @category Layout\n */\nexport function getSizeBucket(\n w: number | undefined,\n h: number | undefined,\n): SizeBucket {\n // Missing dims (e.g. before the grid has measured), assume normal so the first paint isn't a flash of compact UI.\n if (w === undefined || h === undefined) return \"normal\";\n if (w < TINY_BELOW.w || h < TINY_BELOW.h) return \"tiny\";\n if (w < SMALL_W || h < SMALL_H) return \"small\";\n return \"normal\";\n}\n\n/**\n * The orientation of a widget tile, independent of its {@link SizeBucket}: a\n * tile can be `tiny` and `landscape`, or `normal` and `portrait`. The bucket\n * says how much chrome to show; the shape says which way to flow it.\n *\n * - `portrait`: tall and narrow. Stack content in one column and dock any\n * secondary panel or legend below the primary content\n * - `landscape`: wide and short. Flow content into columns or place a\n * secondary panel beside the primary content\n * - `square`: neither axis dominates; the default near-1:1 layout, and the\n * value before the grid has measured the tile\n *\n * Useful for choosing which way a widget flows its content in the operator's\n * tile. Returned by {@link getWidgetShape}.\n *\n * @category Layout\n */\nexport type WidgetShape = \"portrait\" | \"landscape\" | \"square\";\n\n/**\n * A tile's {@link WidgetShape} and the aspect ratio it was read from. Useful\n * for sizing a widget's columns continuously rather than in three steps.\n * Returned by {@link getWidgetShape}.\n *\n * @category Layout\n */\nexport interface WidgetShapeInfo {\n /** Whether the tile is tall, wide or roughly square. */\n shape: WidgetShape;\n /**\n * Raw grid aspect ratio, `w / h`. > 1 is wider-than-tall, < 1 is\n * taller-than-wide, exactly 1 is square. Provided for widgets that want a\n * continuous signal (e.g. an interpolated gap or column count) rather than\n * the coarse three-way enum. `1` when dims are missing.\n */\n aspect: number;\n}\n\n/**\n * Landscape begins once a widget is this many times wider than it is tall.\n *\n * The render harness's two aspect-extreme modes are deliberately log-symmetric\n * around 1:1: `portrait-5x18` has aspect ≈ 0.28 and `landscape-18x5` ≈ 3.6,\n * and log(0.28) ≈ −1.27 mirrors log(3.6) ≈ +1.28. So we center the square band\n * on aspect = 1 and derive the portrait cutoff as the reciprocal of this one\n * constant: a single named threshold, no second magic number.\n *\n * The value (1.6) is picked to sit *above* the near-square auto-modes so they\n * stay `square` and take the unchanged single-column path, but well below the\n * 3.6 landscape extreme so that genuinely wide boxes reflow:\n *\n * - `default-5x7` → aspect 0.71 → square (between 0.625 and 1.6)\n * - `mobile-9x8` → aspect 1.125 → square (between 0.625 and 1.6)\n * - `landscape-18x5` → aspect 3.6 → landscape (≥ 1.6)\n * - `portrait-5x18` → aspect 0.28 → portrait (≤ 0.625 = 1/1.6)\n *\n * Boundaries are inclusive of the cutoff (`>=` / `<=`) so a box sitting exactly\n * on the threshold commits to the reflow rather than dithering at square.\n */\nconst LANDSCAPE_ASPECT = 1.6;\nconst PORTRAIT_ASPECT = 1 / LANDSCAPE_ASPECT; // ≈ 0.625\n\n/**\n * The {@link WidgetShape} of a `w` by `h` tile, with its aspect ratio.\n * `landscape` from an aspect of 1.6 up, `portrait` at 1/1.6 (0.625) and below,\n * `square` between. Returns `square` with aspect `1` while either dimension is\n * `undefined` or `h` is 0. Useful for flowing a widget's content to suit the\n * operator's tile. Used by the fuel status and power systems widgets.\n *\n * @category Layout\n */\nexport function getWidgetShape(\n w: number | undefined,\n h: number | undefined,\n): WidgetShapeInfo {\n // Missing dims (e.g. before the grid has measured), assume `square`, the\n // neutral no-reflow default. The size-bucket analogue is `normal`: pick the\n // value that doesn't flash a divergent layout on first paint. Returning\n // `landscape` here would briefly show a multi-column layout before measure.\n if (w === undefined || h === undefined || h === 0) {\n return { shape: \"square\", aspect: 1 };\n }\n const aspect = w / h;\n if (aspect >= LANDSCAPE_ASPECT) return { shape: \"landscape\", aspect };\n if (aspect <= PORTRAIT_ASPECT) return { shape: \"portrait\", aspect };\n return { shape: \"square\", aspect };\n}\n","import type {\n ComponentDefinition,\n TinyEssential,\n TinyGauge,\n Tone,\n Value,\n} from \"@ksp-gonogo/sitrep-sdk\";\nimport { Fragment, useLayoutEffect, useRef, useState } from \"react\";\nimport styled, { css } from \"styled-components\";\nimport { Dial } from \"./Dial\";\nimport { fillFraction } from \"./fillQuantity\";\nimport { HeldFigure } from \"./HeldMark\";\nimport { LevelBars } from \"./LevelBars\";\nimport { LiveRegion } from \"./LiveRegion\";\nimport { Panel } from \"./Panel\";\nimport { resolveCurrency } from \"./readingCurrency\";\nimport { Section } from \"./Section\";\nimport { Sparkline } from \"./Sparkline\";\nimport { ToggleButton } from \"./ToggleButton\";\nimport { Tooltip } from \"./Tooltip\";\nimport { TONE_MARK, TONE_TEXT } from \"./tone\";\nimport { Unit } from \"./Unit\";\nimport { writeQuantity } from \"./units\";\nimport { VisuallyHidden } from \"./VisuallyHidden\";\nimport { TINY_BELOW, TINY_SIZE } from \"./widgetSize\";\n\n/**\n * Props for {@link TinyEssentials}: a widget's tiny heading and its essentials.\n * Useful for keeping the operator's most important figures in view when a tile\n * is tiny. Taken by {@link TinyEssentials}.\n *\n * @category TinyEssentials\n */\nexport interface TinyEssentialsProps {\n /** A short name for the widget, drawn with its figures. */\n title: string;\n /** The figures the widget cannot do without, in the order drawn. */\n essentials: readonly TinyEssential[];\n /** Draws every figure as a row of equal weight, in shared columns, with no large first figure. */\n equalRows?: boolean;\n}\n\n/**\n * The form every widget with a tiny mode takes at the tiny size, drawn in a\n * {@link Panel} with `hoverTitle` and `fitToSize`: its short heading over its\n * essential values, the first drawn large and the rest as label and figure\n * rows under it. Useful for keeping the operator's most important figures\n * readable in the smallest tile. Used by the dashboard grid in place of a\n * widget's own body when the tile is tiny. A state word stands in a figure's\n * place and is announced through the tile's one polite live region, or, while\n * its essential declares it urgent, through an assertive one that interrupts.\n *\n * Rows are drawn in order while they fit the tile and the ones that do not\n * are dropped from the end, so every figure the tile shows is whole. A dropped\n * row stays in the accessibility tree, in a screen-reader-only block after the\n * drawn ones.\n *\n * @category TinyEssentials\n * @categoryDescription TinyEssentials\n * A widget's tiny form: the essential values it keeps at the smallest tile\n * size, drawn the same way for every widget.\n */\nexport function TinyEssentials({\n title,\n essentials,\n equalRows = false,\n}: TinyEssentialsProps) {\n const hero = equalRows ? undefined : essentials[0];\n const rest = equalRows ? essentials : essentials.slice(1);\n const { rowsRef, drawn } = useRowsThatFit(rest);\n const mayInterrupt = essentials.some((e) => e.urgent !== undefined);\n // A lone figure named like the tile already has its caption in the heading.\n const heroNamedByTitle =\n hero !== undefined &&\n rest.length === 0 &&\n hero.label.toUpperCase() === title.toUpperCase();\n const arcGauge =\n hero?.value != null && hero.gauge?.style === \"arc\" ? hero.gauge : undefined;\n const arcHero = arcGauge !== undefined;\n return (\n <Panel\n panelTitle={title}\n fitToSize\n hoverTitle\n panelTrend={\n hero?.trend === undefined\n ? undefined\n : ({ w, h }) => (\n <Sparkline\n values={hero.trend ?? []}\n width={w}\n height={h}\n aria-label={`${hero.label} trend`}\n />\n )\n }\n sections={\n <Section full>\n <LiveRegion visuallyHidden>\n {spokenWords(essentials.filter((e) => e.urgent !== true))}\n </LiveRegion>\n {mayInterrupt && (\n <LiveRegion visuallyHidden assertive additionsOnly>\n {urgentWords(essentials).map((said) => (\n <Fragment key={said}>{`${said}. `}</Fragment>\n ))}\n </LiveRegion>\n )}\n {hero !== undefined && (\n <TinyEssentials__Hero data-tiny-essential=\"\">\n {heroNamedByTitle || arcHero ? (\n <VisuallyHidden as=\"dt\">{hero.label}</VisuallyHidden>\n ) : (\n <TinyEssentials__Label>{hero.label}</TinyEssentials__Label>\n )}\n {hero.value != null && arcGauge !== undefined ? (\n <ArcGauge essential={hero} gauge={arcGauge} />\n ) : hero.gauge === undefined ? (\n <TinyEssentials__HeroFigure $tone={hero.tone ?? \"neutral\"}>\n <EssentialFigure essential={hero} />\n </TinyEssentials__HeroFigure>\n ) : (\n <TinyEssentials__GaugedFigure $tone={hero.tone ?? \"neutral\"}>\n <TinyEssentials__FigureLine>\n <EssentialFigure essential={hero} />\n </TinyEssentials__FigureLine>\n <CompactGauge essential={hero} gauge={hero.gauge} />\n </TinyEssentials__GaugedFigure>\n )}\n </TinyEssentials__Hero>\n )}\n {rest.length > 0 && (\n <TinyEssentials__Rows ref={rowsRef} $equal={equalRows}>\n {rest.slice(0, drawn).map((essential) => (\n <TinyEssentials__Row\n key={essential.label}\n data-tiny-essential=\"\"\n $equal={equalRows}\n >\n <TinyEssentials__Label>\n {essential.label}\n </TinyEssentials__Label>\n <TinyEssentials__RowFigure\n $tone={essential.tone ?? \"neutral\"}\n >\n <EssentialFigure essential={essential} />\n </TinyEssentials__RowFigure>\n </TinyEssentials__Row>\n ))}\n {rest.slice(drawn).map((essential) => (\n <VisuallyHidden as=\"div\" key={essential.label}>\n <dt>{essential.label}</dt>\n <dd>\n {essential.control === undefined ? (\n <EssentialFigure essential={essential} />\n ) : (\n essential.control.label\n )}\n </dd>\n </VisuallyHidden>\n ))}\n </TinyEssentials__Rows>\n )}\n </Section>\n }\n />\n );\n}\n\n/**\n * How many of the rows are drawn: every one that fits the fit body's box under\n * the hero, in order. Starts from all of them whenever the box resizes or a\n * figure changes, and drops one per layout pass until the content fits, so a\n * tile that grows gets its rows back.\n */\nfunction useRowsThatFit(rows: readonly TinyEssential[]) {\n const rowsRef = useRef<HTMLDListElement | null>(null);\n const [drawn, setDrawn] = useState(rows.length);\n const [pass, setPass] = useState(0);\n const figures = rows\n .map((row) => `${row.label}\\u0000${row.word ?? figureKey(row.value)}`)\n .join(\"\\u0001\");\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: a new figure or a resized box starts the count again.\n useLayoutEffect(() => {\n setDrawn(rows.length);\n }, [figures, pass, rows.length]);\n\n useLayoutEffect(() => {\n const box = rowsRef.current?.closest(\"[data-panel-fit-body]\");\n const content = box?.firstElementChild;\n if (!box || !content || drawn === 0) return;\n if (extentOf(content) > box.clientHeight) setDrawn(drawn - 1);\n });\n\n useLayoutEffect(() => {\n const box = rowsRef.current?.closest(\"[data-panel-fit-body]\");\n if (!box || typeof ResizeObserver === \"undefined\") return;\n let seen = box.clientHeight;\n const observer = new ResizeObserver(() => {\n if (box.clientHeight === seen) return;\n seen = box.clientHeight;\n setPass((n) => n + 1);\n });\n observer.observe(box);\n return () => observer.disconnect();\n }, []);\n\n return { rowsRef, drawn };\n}\n\n/** Enough of a figure to tell when it changed, whatever shape it came in. */\nfunction figureKey(value: TinyEssential[\"value\"]): string {\n try {\n return JSON.stringify(value) ?? \"\";\n } catch {\n return String(value);\n }\n}\n\n/** From the top of the content's first drawn child to the bottom of its last, descending into the section it is wrapped in. */\nfunction extentOf(content: Element): number {\n const tops: number[] = [];\n const bottoms: number[] = [];\n for (const el of Array.from(\n content.querySelectorAll(\"[data-tiny-essential]\"),\n )) {\n const r = el.getBoundingClientRect();\n tops.push(r.top);\n bottoms.push(r.bottom);\n }\n if (tops.length === 0) return 0;\n return Math.max(...bottoms) - Math.min(...tops);\n}\n\nfunction EssentialFigure({ essential }: { essential: TinyEssential }) {\n const { control } = essential;\n if (control?.command !== undefined) {\n return (\n <ToggleButton\n size=\"sm\"\n command={control.command}\n state={control.active}\n name={control.title}\n unavailable={control.disabled ? (control.hint ?? control.title) : null}\n tip={control.hint ?? control.title}\n aria-label={control.title}\n >\n {() => control.label}\n </ToggleButton>\n );\n }\n if (control !== undefined) {\n return (\n <Tooltip text={control.hint ?? control.title}>\n <ToggleButton\n size=\"sm\"\n pressed={control.active}\n disabled={control.disabled}\n onClick={control.onPress}\n marked={\n control.held === undefined\n ? null\n : { kind: \"held\", caption: control.held }\n }\n aria-label={control.title}\n >\n {control.label}\n </ToggleButton>\n </Tooltip>\n );\n }\n return (\n <>\n {essential.level !== undefined && (\n <LevelBars\n lit={essential.level.lit}\n of={essential.level.of}\n tone={essential.tone}\n label={essential.label}\n />\n )}\n {essential.word !== undefined ? (\n essential.word\n ) : (\n <EssentialReading essential={essential} />\n )}\n </>\n );\n}\n\n/** A figure that rounds to zero drawn as zero, without its sign. A held or modelled reading keeps its own kind and words: only its figure is replaced. */\nfunction asZero(\n value: TinyEssential[\"value\"],\n shown: NonNullable<ReturnType<typeof resolveCurrency>[\"shown\"]>,\n): TinyEssential[\"value\"] {\n if (typeof value === \"object\" && value !== null && \"state\" in value) {\n return { ...value, value: shown.abs() };\n }\n return shown.abs();\n}\n\n/**\n * The figure, with the mark the widget states for it. The Reading goes to\n * `<Unit>` whole, so a held or modelled one keeps its own kind and words, and\n * `elsewhere` empties whichever mark that gives. A kind the widget states for\n * a reading of now is drawn around the figure.\n */\nfunction EssentialReading({ essential }: { essential: TinyEssential }) {\n const { mark, value, decimals } = essential;\n const { held, shown } = resolveCurrency(value);\n // Only a signed figure is read for its sign, so a figure handed over bare is drawn as it came.\n const finite = essential.signed === true && shown?.isFinite() === true;\n // A figure that rounds to zero draws as zero, so \"-0\" never sits beside \"+0\".\n const roundsToZero =\n finite &&\n decimals !== undefined &&\n Math.abs(shown.valueOf()) < 0.5 * 10 ** -decimals;\n const plus = finite && (roundsToZero || !shown.isNegative()) ? \"+\" : \"\";\n const drawn = roundsToZero ? asZero(value, shown) : value;\n const figure = (\n <>\n {plus}\n <Unit\n value={drawn}\n decimals={decimals}\n scale=\"compact\"\n elsewhere={\n mark?.elsewhere === true && (held || mark.kind === undefined)\n ? mark.caption\n : undefined\n }\n />\n </>\n );\n if (mark === undefined || held || mark.kind === undefined) return figure;\n return (\n <HeldFigure\n kind={mark.kind}\n elsewhere={mark.elsewhere}\n caption={mark.caption}\n >\n {figure}\n </HeldFigure>\n );\n}\n\n/**\n * A thin bar under the hero figure: the scale's bands as a dim track, and a\n * fill over it from the foot of the scale to the value. The figure carries the\n * number, so the drawing is hidden from the accessibility tree. A held\n * reading dims the fill, as a held meter does; no value draws the bands\n * alone.\n */\nfunction CompactGauge({\n essential,\n gauge,\n}: {\n essential: TinyEssential;\n gauge: TinyGauge;\n}) {\n const { shown, held } = resolveCurrency(essential.value);\n // Clamped in the algebra, so a bound on another rung of the same kind converts before it compares.\n const at = (q: Value): number =>\n fillFraction({\n amount: q.max(gauge.min).min(gauge.max).minus(gauge.min),\n capacity: gauge.max.minus(gauge.min),\n }) ?? 0;\n const share = shown == null ? null : at(shown);\n return (\n <TinyEssentials__Gauge\n aria-hidden=\"true\"\n data-tiny-gauge=\"\"\n data-held={held ? \"\" : undefined}\n viewBox=\"0 0 100 1\"\n preserveAspectRatio=\"none\"\n >\n {(gauge.bands ?? []).map((band) => (\n <rect\n key={`${at(band.from)}-${at(band.to)}`}\n x={at(band.from) * 100}\n y={0}\n width={(at(band.to) - at(band.from)) * 100}\n height={1}\n fill={TONE_MARK[band.tone]}\n opacity={0.35}\n />\n ))}\n {share !== null && (\n <rect\n data-tiny-gauge-fill=\"\"\n x={0}\n y={0}\n width={share * 100}\n height={1}\n fill={TONE_MARK[essential.tone ?? \"neutral\"]}\n opacity={held ? 0.55 : 1}\n />\n )}\n </TinyEssentials__Gauge>\n );\n}\n\n/**\n * The scale as a half-circle dial with the figure under its hub, drawn in the\n * largest arc the tile's room allows. The dial carries the figure and its held\n * mark itself, so no separate figure is drawn.\n */\nfunction ArcGauge({\n essential,\n gauge,\n}: {\n essential: TinyEssential;\n gauge: TinyGauge;\n}) {\n const { ref, room } = useFitRoom();\n const width = Math.min(room.w, ARC_MAX_W);\n const height = Math.min(\n room.h - ARC_EDGE_CLEARANCE,\n Math.round(width / 2) + ARC_FIGURE_H,\n );\n const shown = essential.value;\n if (shown == null) return null;\n const spoken = resolveCurrency(shown).shown;\n return (\n <TinyEssentials__ArcBox ref={ref}>\n <Dial\n startAngle={-90}\n sweep={180}\n value={shown}\n min={gauge.min}\n max={gauge.max}\n zones={(gauge.bands ?? []).map((band) => ({\n from: band.from,\n to: band.to,\n color: TONE_MARK[band.tone],\n }))}\n width={width}\n height={height}\n readout=\"large\"\n aria-label={\n spoken == null\n ? essential.label\n : `${essential.label} ${writeQuantity(spoken)}`\n }\n />\n </TinyEssentials__ArcBox>\n );\n}\n\n/**\n * The room the tile's fit body gives its content, worked out from the panel\n * body around it: the fit body's own box is as tall as what it holds, so it\n * cannot be asked. The fit body takes back the body's gap above and its bottom\n * inset, and those are added to the body's content box. Starts at a default\n * size where there is no panel body or no ResizeObserver.\n */\nfunction useFitRoom() {\n const ref = useRef<HTMLElement | null>(null);\n const [room, setRoom] = useState({ w: 200, h: 110 });\n useLayoutEffect(() => {\n const fit = ref.current?.closest(\"[data-panel-fit-body]\");\n const body = fit?.closest(\"[data-panel-body]\");\n if (!fit || !body || typeof ResizeObserver === \"undefined\") return;\n const measure = () => {\n const box = getComputedStyle(body);\n const taken = getComputedStyle(fit);\n const w =\n body.clientWidth -\n Number.parseFloat(box.paddingLeft) -\n Number.parseFloat(box.paddingRight);\n const h =\n body.clientHeight -\n Number.parseFloat(box.paddingTop) -\n Number.parseFloat(box.paddingBottom) -\n Number.parseFloat(taken.marginTop) -\n Number.parseFloat(taken.marginBottom);\n if (w > 0 && h > 0) setRoom({ w: Math.floor(w), h: Math.floor(h) });\n };\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(body);\n return () => observer.disconnect();\n }, []);\n return { ref, room };\n}\n\n/** The widest arc drawn, past which a roomy tile gains blank margin rather than a larger dial. */\nconst ARC_MAX_W = 280;\n\n/** Left under the dial, because the fit box reaches the panel's border and the figure's descenders would touch it. */\nconst ARC_EDGE_CLEARANCE = 16;\n\n/** What the dial needs under its arc's base line: half the track, the drop to its large figure, and the figure's descent. */\nconst ARC_FIGURE_H = 40;\n\n/** Every state word on the tile with its label, the only thing the tile says aloud. */\nfunction spokenWords(essentials: readonly TinyEssential[]): string {\n return essentials\n .filter((e) => e.word !== undefined)\n .map((e) => `${e.label} ${e.word}`)\n .join(\", \");\n}\n\n/**\n * Each urgent word with its label, one text node apiece and no element, so the\n * region is as hidden as the polite one. The assertive region reads only what\n * is added to it, so a word is said when it turns urgent or changes while\n * urgent, and an unchanged one is not said again on the next render.\n */\nfunction urgentWords(essentials: readonly TinyEssential[]): string[] {\n return essentials\n .filter((e) => e.urgent === true && e.word !== undefined)\n .map((e) => `${e.label} ${e.word}`);\n}\n\n/**\n * Whether a widget shows its tiny form in a `w` by `h` tile (in grid units):\n * true for a widget with a tiny mode when the tile is narrower or shorter than\n * its `minSize`, where its own body stops fitting, or than {@link TINY_BELOW}\n * when it sets none. False for a widget without a tiny mode, and while either\n * dimension is unmeasured, so the widget's own body shows. Useful for deciding\n * whether the operator sees a widget's tiny form or its full body. Used by the\n * dashboard grid.\n *\n * @category TinyEssentials\n */\nexport function showsTiny(\n def: Pick<ComponentDefinition, \"tiny\" | \"minSize\">,\n w: number | undefined,\n h: number | undefined,\n): boolean {\n if (def.tiny === undefined || w === undefined || h === undefined) {\n return false;\n }\n const floor = def.minSize ?? TINY_BELOW;\n return w < floor.w || h < floor.h;\n}\n\n/**\n * The smallest tile, in grid units, the dashboard lets a widget be resized to:\n * the kit-wide {@link TINY_SIZE} for a widget with a tiny mode, its `minSize`\n * for one without, and `undefined` when that sets none. Useful for stopping\n * the operator from resizing a widget below the size at which it is readable.\n * Used by the dashboard's layout normalisation.\n *\n * @category TinyEssentials\n */\nexport function gridFloor(\n def: Pick<ComponentDefinition, \"tiny\" | \"minSize\">,\n): { w: number; h: number } | undefined {\n return def.tiny !== undefined ? TINY_SIZE : def.minSize;\n}\n\n/* The label comes first for the reader and sits under the figure for the eye. */\nconst TinyEssentials__Hero = styled.dl`\n display: flex;\n flex-direction: column-reverse;\n align-items: center;\n gap: var(--gap-tiny-content);\n margin: 0;\n min-width: 0;\n`;\n\nconst TinyEssentials__HeroFigure = styled.dd<{ $tone: Tone }>`\n display: inline-flex;\n align-items: baseline;\n gap: var(--gap-figure-parts);\n margin: 0;\n /* Sized against the tile, which the fit body makes a query container. */\n font-size: clamp(\n var(--font-size-lg),\n 20cqw,\n calc(var(--font-size-lg) * 2)\n );\n font-weight: 700;\n line-height: var(--line-height-tight);\n font-variant-numeric: tabular-nums;\n white-space: nowrap;\n color: ${({ $tone }) => TONE_TEXT[$tone]};\n`;\n\n/* Flush, so the figure and the bar under it fit the tile's content box, which is shorter than one tight figure line plus a gap. */\nconst TinyEssentials__GaugedFigure = styled(TinyEssentials__HeroFigure)`\n flex-direction: column;\n align-items: stretch;\n gap: var(--gap-caption);\n line-height: var(--line-height-flush);\n`;\n\nconst TinyEssentials__FigureLine = styled.span`\n display: inline-flex;\n align-items: baseline;\n justify-content: center;\n gap: var(--gap-figure-parts);\n`;\n\n/* The box is out of flow, so the dial drawn in it can never grow the slot it is measured from. */\nconst TinyEssentials__ArcBox = styled.dd`\n display: flex;\n align-items: center;\n justify-content: center;\n margin: 0;\n`;\n\nconst TinyEssentials__Gauge = styled.svg`\n display: block;\n width: 100%;\n height: var(--size-tiny-gauge);\n`;\n\nconst TinyEssentials__Label = styled.dt`\n font-size: var(--font-size-caption);\n letter-spacing: 0.1em;\n text-transform: uppercase;\n color: var(--color-text-muted);\n white-space: nowrap;\n`;\n\n/* Equal rows share two columns spread across the tile, labels left and figures right, so a changing figure never moves a label. */\nconst TinyEssentials__Rows = styled.dl<{ $equal: boolean }>`\n ${({ $equal }) =>\n $equal\n ? css`\n display: grid;\n grid-template-columns: auto auto;\n justify-content: space-between;\n /* The section around the rows shrinks to its content, so the rows take the tile's width from the fit body, which is the query container. */\n min-width: 100cqw;\n align-items: baseline;\n column-gap: var(--gap-label-value-tight);\n row-gap: var(--gap-related-packed);\n `\n : css`\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: var(--gap-row-wrap);\n `}\n margin: 0;\n max-width: 100%;\n`;\n\n/* A row too wide for the tile drops its figure under its label rather than spilling past the edges. */\nconst TinyEssentials__Row = styled.div<{ $equal: boolean }>`\n ${({ $equal }) =>\n $equal\n ? css`\n display: grid;\n grid-template-columns: subgrid;\n grid-column: 1 / -1;\n align-items: baseline;\n white-space: nowrap;\n `\n : css`\n display: flex;\n flex-wrap: wrap;\n justify-content: center;\n align-items: baseline;\n column-gap: var(--gap-label-value-tight);\n `}\n max-width: 100%;\n`;\n\nconst TinyEssentials__RowFigure = styled.dd<{ $tone: Tone }>`\n display: inline-flex;\n justify-content: flex-end;\n align-items: baseline;\n gap: var(--gap-figure-parts);\n margin: 0;\n font-size: var(--font-size-value);\n font-weight: 700;\n font-variant-numeric: tabular-nums;\n white-space: nowrap;\n color: ${({ $tone }) => TONE_TEXT[$tone]};\n`;\n","import type { Value } from \"@ksp-gonogo/sitrep-sdk\";\n\n/**\n * How much there is, and what that is a fraction of, for {@link TinyEssentials}.\n * Both halves are the same kind of quantity, which the types enforce, and the\n * kit divides them itself. Useful for giving a gauge both the amount in a tank\n * and its capacity. Taken by the helper that divides one by the other.\n *\n * @category Unit\n */\nexport interface FillQuantity<Unit extends string = string> {\n /** How much there is now. */\n amount: Value<Unit>;\n /** The full tank: what `amount` is read as a fraction of. */\n capacity: Value<Unit>;\n}\n\n/**\n * The pair, as the 0..1 a track is drawn from. `dividedBy` makes the quotient\n * dimensionless. A capacity of zero is no tank at all, so it yields `null`.\n * Useful for drawing how full a tank or store is. Used by {@link TinyEssentials}.\n *\n * @category Unit\n */\nexport function fillFraction<Unit extends string>(\n pair: FillQuantity<Unit> | null,\n): number | null {\n if (pair === null) return null;\n if (!pair.capacity.isPositive()) return null;\n return pair.amount.dividedBy(pair.capacity).magnitude;\n}\n","import type { BadgeEntry, Contributed } from \"@ksp-gonogo/sitrep-sdk\";\nimport { useContributionsBySlotId } from \"./contributionsRead\";\nimport { useWidgetMeta } from \"./WidgetMetaContext\";\n\n/**\n * The entries contributed to the current widget's standard\n * `${componentId}.badges` slot, each stamped with its contribution id and\n * owner. Useful for showing the operator the badges an Uplink adds to a widget\n * it did not write. Empty outside a widget or without a\n * {@link ContributionsProvider}.\n * The dashboard reads this for each widget and hands it to\n * {@link PanelBadgesProvider}; a widget drawn in a {@link Panel} gets the\n * badges without calling it.\n *\n * @category Panel\n */\nexport function useWidgetBadges(): readonly Contributed<BadgeEntry>[] {\n const meta = useWidgetMeta();\n const slot = meta ? `${meta.componentId}.badges` : \"\";\n return useContributionsBySlotId(slot) as readonly Contributed<BadgeEntry>[];\n}\n"],"mappings":";;;;;AAgBO,IAAM,YAA4C;AAAA,EACvD,SAAS;AAAA,EACT,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,SAAS;AAAA,EACT,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS;AACX;AASO,IAAM,YAA4C;AAAA,EACvD,SAAS;AAAA,EACT,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,SAAS;AAAA,EACT,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS;AACX;AASO,IAAM,cAA8C;AAAA,EACzD,SAAS;AAAA,EACT,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,SAAS;AAAA,EACT,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS;AACX;AAQO,IAAM,iBAAiD;AAAA,EAC5D,SAAS;AAAA,EACT,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,SAAS;AAAA,EACT,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS;AACX;AASO,IAAM,aAA6C;AAAA,EACxD,SAAS;AAAA,EACT,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,SAAS;AAAA,EACT,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS;AACX;AAUO,SAAS,SAAS,MAAoB;AAC3C,SAAO,SAAS,YAAY,+BAA+B,UAAU,IAAI;AAC3E;AASO,SAAS,WAAW,MAAoB;AAC7C,QAAM,KAAK,eAAe,IAAI;AAC9B,SAAO;AAAA,gBACO,YAAY,IAAI,CAAC;AAAA,WACtB,EAAE;AAAA,0BACa,EAAE;AAAA,0BACF,EAAE;AAAA,wBACJ,EAAE;AAAA,sBACJ,EAAE;AAAA,wBACA,EAAE;AAAA;AAE1B;;;AC3HA,SAAS,2BAA2B;AACpC,SAAy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;AAAA;AAAA;AAOtE,IAAM,6BAA6BA,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAQ1C,IAAM,yBAAyBA,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAOtC,IAAM,wBAAwBA,SAAO;AAAA;AAAA;AAAA;AAAA;AAMrC,IAAM,wBAAwBA,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASrC,IAAM,uBAAuBA,SAAO;AAAA,IAChC,CAAC,EAAE,OAAO,MACV,SACIC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAUAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAKC;AAAA;AAAA;AAAA;AAMT,IAAM,sBAAsBD,SAAO;AAAA,IAC/B,CAAC,EAAE,OAAO,MACV,SACIC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAOAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAMC;AAAA;AAAA;AAIT,IAAM,4BAA4BD,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,WAU9B,CAAC,EAAE,MAAM,MAAM,UAAU,KAAK,CAAC;AAAA;;;AElpBnC,SAAS,kBAAsD;AACpE,QAAM,OAAO,cAAc;AAC3B,QAAM,OAAO,OAAO,GAAG,KAAK,WAAW,YAAY;AACnD,SAAO,yBAAyB,IAAI;AACtC;","names":["listeners","jsx","jsx","value","jsx","HOUR","MINUTE","tiers","STANDARD_GRAVITY","value","quantity","format","decimals","quantity","value","commandRefusalSubject","commandRefusalSubject","said","sentence","commandRefusalSubject","CommandErrorCode","useRef","useRef","CommandErrorCode","awaiting","sent","styled","jsx","useCallback","useEffect","useRef","useState","styled","jsx","useState","useRef","useCallback","useEffect","TipBody","styled","forwardRef","useRef","useState","styled","jsx","jsxs","FitLabelButton","createContext","useContext","forwardRef","createElement","forwardRef","createElement","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","forwardRef","jsx","styled","css","jsx","jsxs","css","styled","styled","jsx","jsxs","forwardRef","styled","styled","css","css","css","styled","jsx","argsOf","bindCommand","useEffect","styled","css","useSyncExternalStore","useSyncExternalStore","forwardRef","styled","jsx","styled","forwardRef","Fragment","jsx","jsxs","bindCommand","argsOf","useEffect","words","commandEdge","sentence","styled","css","jsx","Button","forwardRef","styled","IconButton","forwardRef","useEffect","useState","styled","css","bindCommand","value","bindCommand","css","jsx","jsxs","styled","css","forwardRef","Select","value","useState","useEffect","styled","jsx","styled","createContext","useContext","useMemo","jsx","value","useSyncExternalStore","listeners","NO_SUBSCRIBE","useSyncExternalStore","styled","jsx","jsxs","quantity","Fragment","jsx","styled","jsx","jsxs","styled","createContext","useContext","useSyncExternalStore","Fragment","jsx","useSyncExternalStore","NO_SUBSCRIBE","value","said","quantity","Fragment","jsx","value","format","useEffect","useRef","useState","words","useEffect","useRef","useState","styled","css","keyframes","useEffect","useRef","useState","styled","Fragment","jsx","jsxs","useRef","value","useState","useEffect","InFlightBadge","keyframes","styled","css","useEffect","useEffect","styled","css","css","Fragment","jsx","jsxs","css","SIZE_STYLES","styled","createContext","useContext","useLayoutEffect","useState","useSyncExternalStore","jsx","listeners","format","createContext","useContext","useState","useLayoutEffect","value","useSyncExternalStore","styled","css","Fragment","jsx","jsxs","styled","css","quantity","said","value","forwardRef","styled","jsx","forwardRef","Cluster","styled","jsx","hasHost","logger","hasHost","logger","value","Fragment","useId","styled","Fragment","jsx","jsxs","value","from","useId","styled","jsx","commandRefusalSubject","describeErrorCode","said","commandRefusalSubject","commandRefusalSubject","commandRefusalSubject","styled","css","jsx","jsxs","commandRefusalSubject","css","styled","useCallback","useSyncExternalStore","useCallback","useSyncExternalStore","hasHost","logger","useCallback","useEffect","useMemo","useRef","useSyncExternalStore","Fragment","jsx","jsxs","slotCache","cacheValid","useSyncExternalStore","useMemo","useEffect","useCallback","useRef","hasHost","logger","bandIn","styled","Fragment","jsx","jsxs","value","format","bandIn","styled","styled","jsx","jsxs","styled","useRef","styled","jsx","jsxs","value","useRef","styled","useId","useState","jsx","jsxs","useState","useId","styled","Fragment","jsx","jsxs","styled","styled","css","jsx","css","styled","createContext","useContext","jsx","useSyncExternalStore","NO_SUBSCRIBE","useSyncExternalStore","useSyncExternalStore","NO_SUBSCRIBE","useSyncExternalStore","createContext","useCallback","useContext","useEffect","useLayoutEffect","useRef","useState","value","Children","createContext","Fragment","forwardRef","isValidElement","useCallback","useContext","useEffect","useId","useLayoutEffect","useMemo","useRef","useState","styled","css","useEffect","useId","useRef","useState","styled","css","jsx","jsxs","useState","useRef","useEffect","useId","styled","css","styled","jsx","styled","css","useCallback","useEffect","useLayoutEffect","useRef","useState","compact","useEffect","useRef","useState","value","Fragment","jsx","jsxs","createContext","useState","value","useMemo","styled","forwardRef","PanelTitle","compact","useRef","css","useCallback","useEffect","useContext","useLayoutEffect","ScrollArea","useId","Children","isValidElement","child","styled","jsx","styled","forwardRef","jsx","forwardRef","ToggleButton","Button","useId","useMemo","jsx","jsxs","pad","Fragment","useLayoutEffect","useRef","useState","styled","css","Fragment","jsx","jsxs","said","useRef","useState","useLayoutEffect","value","styled","css"]}
|