strata-react 1.0.36 → 1.0.38

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.
@@ -1,3 +1,4 @@
1
+ import { default as L } from 'leaflet';
1
2
  import { LatLng } from '../lib/geo';
2
3
  import { MapMarker, MarkerKeyWords } from './markers';
3
4
  import * as React from "react";
@@ -139,5 +140,7 @@ export type RouteMapProps = {
139
140
  /** Layout only. The map is 16:9 and at least 16rem tall unless a height is given. */
140
141
  className?: string;
141
142
  };
143
+ /** @internal Exported for its test, not part of the package's API. */
144
+ export declare function coveringTiles(url: string, options: L.TileLayerOptions): L.TileLayer;
142
145
  /** A map of one or more routes with a position that moves along them, on tiles the app supplies, themed from its roles. Leaflet, behind `strata-react/map`. */
143
146
  export declare function RouteMap({ label, routes, tiles, position, positionLabel, positions, followId, follow, zoom, markers, onMarkerSelect, renderMarkerCard, markerKey, cursor: cursorProp, onViewChange, settle, reportAppMoves, view, picking, onPick, onPickCancel, pickBanner, selectedId, onSelect, colourScale, colourScaleLabel, formatValue, summary, units, scrollZoom, topEnd, bottomStart, className, }: RouteMapProps): React.JSX.Element;
package/dist/map.js CHANGED
@@ -407,6 +407,13 @@ function stepRuns(points, values, stepOf) {
407
407
  return runs;
408
408
  }
409
409
  var arrowHtml = (bearing, colour, halo) => `<svg width="26" height="26" viewBox="0 0 26 26" aria-hidden="true" style="transform: rotate(${bearing.toFixed(0)}deg)"><path d="M6 17 L13 9 L20 17" fill="none" stroke="${halo}" stroke-width="7" stroke-linecap="round" stroke-linejoin="round"/><path d="M6 17 L13 9 L20 17" fill="none" stroke="${colour}" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`;
410
+ /** @internal Exported for its test, not part of the package's API. */
411
+ function coveringTiles(url, options) {
412
+ return new (L.TileLayer.extend({ _getTiledPixelBounds(centre) {
413
+ const base = L.GridLayer.prototype._getTiledPixelBounds.call(this, centre);
414
+ return L.bounds(base.min.subtract([1, 1]), base.max.add([1, 1]));
415
+ } }))(url, options);
416
+ }
410
417
  /** A map of one or more routes with a position that moves along them, on tiles the app supplies, themed from its roles. Leaflet, behind `strata-react/map`. */
411
418
  function RouteMap({ label, routes, tiles, position = null, positionLabel = "Current position", positions, followId, follow = false, zoom, markers, onMarkerSelect, renderMarkerCard, markerKey, cursor: cursorProp, onViewChange, settle = 250, reportAppMoves = false, view, picking = false, onPick, onPickCancel, pickBanner, selectedId = null, onSelect, colourScale, colourScaleLabel, formatValue = plain, summary, units = "metric", scrollZoom = false, topEnd, bottomStart, className }) {
412
419
  const { scheme } = useColorScheme();
@@ -532,7 +539,7 @@ function RouteMap({ label, routes, tiles, position = null, positionLabel = "Curr
532
539
  ]);
533
540
  React.useEffect(() => {
534
541
  if (!map) return;
535
- const layer = L.tileLayer(source.url, {
542
+ const layer = coveringTiles(source.url, {
536
543
  attribution: source.attribution,
537
544
  subdomains: source.subdomains ?? "abc",
538
545
  minZoom: source.minZoom,
package/dist/map.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"map.js","names":["Tooltip","AriaButton","_Fragment"],"sources":["../src/map/map-styles.ts","../src/map/fan.ts","../src/map/markers.tsx","../src/map/route-map.tsx"],"sourcesContent":["import leafletCss from \"leaflet/dist/leaflet.css?inline\";\n\n// Leaflet draws with its own stylesheet (panes, tiles, controls positioned by class), which an app\n// would otherwise have to import beside strata-react's. That is an install step a component must\n// not need (CLAUDE.md, \"Imports decide the peers\"), so the map puts it in the page itself, once,\n// followed by the few rules that make Leaflet's own parts (zoom buttons, attribution, tooltips)\n// read as the app: its roles, its control height, its radius. The dark treatment is here too, in\n// one place: a map without dark tiles is turned to the dark scheme with a filter, which is a\n// fallback, not a design (an app with a dark tile set passes it as `tiles.dark`).\nconst strata = `\n.strata-map .leaflet-container { background: var(--surface-sunken); color: var(--foreground); font: inherit; }\n.strata-map .leaflet-container:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }\n.strata-map .leaflet-bar { border: 1px solid var(--border); border-radius: var(--radius-control, 4px); box-shadow: none; overflow: hidden; }\n.strata-map .leaflet-bar a { background: var(--background); color: var(--foreground); border-bottom: 1px solid var(--border); width: var(--control-h, 2.5rem); height: var(--control-h, 2.5rem); line-height: var(--control-h, 2.5rem); }\n.strata-map .leaflet-control-zoom-in, .strata-map .leaflet-control-zoom-out { font: inherit; font-size: 1.25rem; font-weight: 600; }\n.strata-map .leaflet-bar a:last-child { border-bottom: 0; }\n.strata-map .leaflet-bar a:hover, .strata-map .leaflet-bar a:focus-visible { background: var(--muted); }\n.strata-map .leaflet-bar a.leaflet-disabled { color: var(--muted-foreground); background: var(--background); cursor: not-allowed; }\n.strata-map .leaflet-control-attribution { background: color-mix(in oklab, var(--background) 85%, transparent); color: var(--muted-foreground); font-size: 0.75rem; }\n.strata-map .leaflet-control-attribution a { color: inherit; text-decoration: underline; }\n.strata-map .leaflet-tooltip { background: var(--background); color: var(--foreground); border: 1px solid var(--border); border-radius: var(--radius-control, 4px); box-shadow: none; font: inherit; font-size: 0.8125rem; padding: 0.125rem 0.375rem; }\n.strata-map .leaflet-tooltip::before { display: none; }\n.strata-map[data-dark-treatment] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9); }\n.strata-map .strata-map-arrow { background: none; border: 0; }\n.strata-map .strata-map-marker, .strata-map .strata-map-crosshair { background: none; border: 0; display: grid; place-items: center; }\n.strata-map .strata-map-reset { display: grid; place-items: center; }\n.strata-map .strata-map-picking, .strata-map .strata-map-picking .leaflet-interactive { cursor: crosshair; }\n`;\n\nlet installed = false;\n\n/** Puts Leaflet's stylesheet and the token overrides in the document head, once. */\nexport function installMapStyles() {\n if (installed || typeof document === \"undefined\") return;\n installed = true;\n const el = document.createElement(\"style\");\n el.setAttribute(\"data-strata-map\", \"\");\n el.textContent = leafletCss + strata;\n document.head.appendChild(el);\n}\n","// Markers that would sit on top of each other are moved apart in a small fan (strata-react issue #181).\n// Pure maths on pixel positions, no map and no DOM, so the rule can be tested and so a frame is the\n// same everywhere. The positions are in the map's *world* pixels at the current zoom (not the screen's),\n// so panning never changes the result, only zooming does, and zooming in is what settles the fan.\n//\n// Rules: markers within `gap` pixels of each other, directly or through a chain of neighbours\n// (single linkage), form one group. A group of two to six goes on one circle just wide enough that\n// neighbours are `gap` apart; a larger group fills rings of radius gap, 2 gap, 3 gap… each holding as\n// many as fit, so forty markers on one spot make a tidy rosette, not one huge circle. The first marker\n// of a group (input order) goes straight up and the rest follow clockwise: the same input always gives the\n// same output. A lone marker does not move.\n\n/** A marker's true place in world pixels. */\nexport type FanInput = { id: string; x: number; y: number };\n/** Where it is drawn; `fanned` is true when that is not its true place (draw a leader line back). */\nexport type FanOutput = { id: string; x: number; y: number; fanned: boolean };\n\n/** Move apart markers closer than `gap` pixels. Output is in input order. */\nexport function fanOut(items: readonly FanInput[], gap = 26): FanOutput[] {\n const parent = items.map((_, i) => i);\n const find = (i: number): number => (parent[i] === i ? i : (parent[i] = find(parent[i])));\n // A grid of `gap`-sized cells, so each marker is compared with its neighbours and not with all 500.\n const cells = new Map<string, number[]>();\n const key = (cx: number, cy: number) => `${cx},${cy}`;\n items.forEach((p, i) => {\n const [cx, cy] = [Math.floor(p.x / gap), Math.floor(p.y / gap)];\n for (let dx = -1; dx <= 1; dx++)\n for (let dy = -1; dy <= 1; dy++)\n for (const j of cells.get(key(cx + dx, cy + dy)) ?? []) {\n if (Math.hypot(items[j].x - p.x, items[j].y - p.y) < gap) parent[find(i)] = find(j);\n }\n const own = cells.get(key(cx, cy));\n if (own) own.push(i);\n else cells.set(key(cx, cy), [i]);\n });\n const groups = new Map<number, number[]>();\n items.forEach((_, i) => {\n const r = find(i);\n const g = groups.get(r);\n if (g) g.push(i);\n else groups.set(r, [i]);\n });\n const out: FanOutput[] = items.map((p) => ({ id: p.id, x: p.x, y: p.y, fanned: false }));\n for (const members of groups.values()) {\n const n = members.length;\n if (n < 2) continue;\n const cx = members.reduce((s, i) => s + items[i].x, 0) / n;\n const cy = members.reduce((s, i) => s + items[i].y, 0) / n;\n const place = (i: number, radius: number, angle: number) => {\n out[i] = { id: items[i].id, x: cx + radius * Math.sin(angle), y: cy - radius * Math.cos(angle), fanned: true };\n };\n if (n <= 6) {\n const radius = gap / (2 * Math.sin(Math.PI / n));\n members.forEach((i, k) => place(i, radius, (2 * Math.PI * k) / n));\n } else {\n let k = 0;\n for (let ring = 1; k < n; ring++) {\n const radius = ring * gap;\n const fit = Math.max(1, Math.floor((2 * Math.PI * radius) / gap));\n const here = Math.min(fit, n - k);\n for (let m = 0; m < here; m++) place(members[k + m], radius, (2 * Math.PI * m) / here);\n k += here;\n }\n }\n }\n return out;\n}\n","import * as React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport L from \"leaflet\";\nimport { Button as AriaButton } from \"react-aria-components\";\nimport { cn } from \"../lib/utils\";\nimport { geo, type LatLng } from \"../lib/geo\";\nimport { Tooltip } from \"../components/tooltip\";\nimport { fanOut } from \"./fan\";\n\n// Item markers on a map (strata-react issue #181, from strata-360's race map: a marker for every clip at\n// the middle of its stretch of track, the stretch drawn heavier, overlapping markers fanned apart, a card\n// on hover, a click that opens the clip). What is decided here and why:\n//\n// - **Each marker is a real control.** A React Aria `Button` portalled into the DOM node of a Leaflet\n// marker (a `divIcon` whose `html` is that node), so Leaflet keeps it where the map puts it while React\n// owns what it is: named by its label, pressed with a click, Enter or Space, a `Tooltip` on hover and\n// focus. Not Leaflet's popup, which is not a Strata surface and not reachable the same way.\n// - **One tab stop for all of them**, arrows (and Home and End) between them, in the order the app gave:\n// forty markers must not be forty tab stops. The map's own keyboard stays: the markers are a roving\n// group inside it, and the app's list of items beside the map is still the full keyboard path.\n// - **Only what is near the screen is drawn.** Each time the view settles the markers within the view\n// (plus a margin, so a fan is not cut at the edge) are laid out and the rest are not in the DOM, so 500\n// markers cost what the visible ones cost.\n// - **The fan is a pure function of the zoom** (`fanOut`, fan.ts): in world pixels, so panning never moves\n// it and zooming in settles it; a leader line joins each fanned marker to its true place.\n// - **States are shapes as well as colour**: a plain circle, a ringed larger one for selected, a diamond for\n// highlighted by the app (the newest draft's choice). The key names each one that is on the map.\n//\n// Checked: React Aria has no map part; `Button` and the Strata `Tooltip` are used as they are.\n\n/** The words the key uses for each marker state. */\nexport type MarkerKeyWords = { marker?: string; selected?: string; highlighted?: string };\n\n/** An item on the map: a place, or a stretch of a route (drawn heavier, the marker at its middle). */\nexport type MapMarker = {\n /** Stable between renders. */\n id: string;\n /** A place, or a stretch of a route between two distances along it (metres). */\n at: LatLng | { routeId: string; from: number; to: number };\n /** Its name: the button's accessible name and the card's default words. */\n label: string;\n selected?: boolean;\n /** Marked by the app (a diamond): the newest draft's choice, a flagged item. */\n highlighted?: boolean;\n /** Any CSS colour, normally a role; overrides the state's. */\n colour?: string;\n};\n\n/** A marker with where it really is and where it is drawn. */\nexport type Placed = { marker: MapMarker; at: LatLng; shown: LatLng; fanned: boolean };\n\nconst alongCache = new WeakMap<readonly LatLng[], number[]>();\n/** The running distance at each point of a route, kept per route array so a long route is walked once. */\nexport function alongOf(points: readonly LatLng[]): number[] {\n let a = alongCache.get(points);\n if (!a) {\n a = geo.cumulative(points);\n alongCache.set(points, a);\n }\n return a;\n}\n\n/** Where a marker really is: its place, or the middle of its stretch. Null when its route is not on the map. */\nexport function markerPlace(m: MapMarker, routes: readonly { id: string; points: readonly LatLng[] }[]): LatLng | null {\n if (Array.isArray(m.at)) return m.at as LatLng;\n const at = m.at as { routeId: string; from: number; to: number };\n const route = routes.find((r) => r.id === at.routeId);\n return route ? geo.pointAlong(route.points, (at.from + at.to) / 2, alongOf(route.points)) : null;\n}\n\n/** The markers near the view, with the overlapping ones fanned apart for this zoom. */\nexport function placeMarkers(map: L.Map, markers: readonly MapMarker[], routes: readonly { id: string; points: readonly LatLng[] }[]): Placed[] {\n const near = map.getBounds().pad(0.25);\n const zoom = map.getZoom();\n const here: { marker: MapMarker; at: LatLng }[] = [];\n for (const marker of markers) {\n const at = markerPlace(marker, routes);\n if (at && near.contains([at[0], at[1]])) here.push({ marker, at });\n }\n const fanned = fanOut(here.map((h) => ({ id: h.marker.id, ...map.project([h.at[0], h.at[1]], zoom) })));\n return here.map((h, i) => {\n const f = fanned[i];\n const shown = f.fanned ? map.unproject([f.x, f.y], zoom) : null;\n return { marker: h.marker, at: h.at, shown: shown ? ([shown.lat, shown.lng] as LatLng) : h.at, fanned: f.fanned };\n });\n}\n\nconst state = (m: MapMarker) => (m.highlighted ? \"highlighted\" : m.selected ? \"selected\" : \"marker\");\n\ntype PinProps = {\n map: L.Map;\n placed: Placed;\n active: boolean;\n onActivate: (id: string) => void;\n onMove: (id: string, to: \"next\" | \"previous\" | \"first\" | \"last\") => void;\n register: (id: string, el: HTMLElement | null) => void;\n onSelect?: (id: string) => void;\n card?: (m: MapMarker) => React.ReactNode;\n};\n\n/** One marker: a Leaflet marker holding a node that React fills with a labelled button. */\nfunction Pin({ map, placed, active, onActivate, onMove, register, onSelect, card }: PinProps) {\n const { marker, shown } = placed;\n const host = React.useMemo(() => {\n const el = document.createElement(\"div\");\n el.className = \"strata-map-pin\";\n return el;\n }, []);\n const layer = React.useRef<L.Marker | null>(null);\n React.useEffect(() => {\n const m = L.marker([shown[0], shown[1]], { icon: L.divIcon({ className: \"strata-map-marker\", html: host, iconSize: [28, 28], iconAnchor: [14, 14] }), interactive: false, keyboard: false }).addTo(map);\n layer.current = m;\n return () => {\n layer.current = null;\n m.remove();\n };\n // Made once per pin; where it is and how high it sits are updated below.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [map, host]);\n React.useEffect(() => {\n layer.current?.setLatLng([shown[0], shown[1]]);\n }, [shown]);\n React.useEffect(() => {\n layer.current?.setZIndexOffset(marker.selected ? 1000 : marker.highlighted ? 500 : 0);\n }, [marker.selected, marker.highlighted]);\n const kind = state(marker);\n const swatch = marker.colour ?? (kind === \"highlighted\" ? \"var(--success)\" : kind === \"selected\" ? \"var(--foreground)\" : \"var(--primary)\");\n return createPortal(\n <Tooltip label={card ? card(marker) : marker.label} side=\"top\">\n <AriaButton\n ref={(el) => register(marker.id, el)}\n aria-label={marker.label}\n aria-pressed={marker.selected ?? false}\n excludeFromTabOrder={!active}\n onFocus={() => onActivate(marker.id)}\n onPress={() => onSelect?.(marker.id)}\n onKeyDown={(e) => {\n const to = e.key === \"ArrowRight\" || e.key === \"ArrowDown\" ? \"next\" : e.key === \"ArrowLeft\" || e.key === \"ArrowUp\" ? \"previous\" : e.key === \"Home\" ? \"first\" : e.key === \"End\" ? \"last\" : null;\n if (!to) return;\n e.preventDefault();\n e.stopPropagation();\n onMove(marker.id, to);\n }}\n className=\"pointer-events-auto grid size-7 cursor-pointer place-items-center rounded-pill outline-offset-1 focus-visible:outline-2 focus-visible:outline-ring\"\n >\n <Shape kind={kind} colour={swatch} />\n </AriaButton>\n </Tooltip>,\n host,\n );\n}\n\n/** The drawn shape of a marker state: a circle, a ringed larger circle, a diamond. Shapes carry the meaning as colour does. */\nfunction Shape({ kind, colour }: { kind: \"marker\" | \"selected\" | \"highlighted\"; colour: string }) {\n return (\n <span\n aria-hidden\n className={cn(\"block border-2 border-background\", kind === \"highlighted\" ? \"size-3.5 rotate-45 rounded-sm\" : \"rounded-pill\", kind === \"selected\" ? \"size-4 ring-2 ring-foreground\" : kind === \"marker\" ? \"size-3.5\" : \"\")}\n style={{ background: colour }}\n />\n );\n}\n\ntype LayerProps = {\n map: L.Map;\n placed: readonly Placed[];\n onSelect?: (id: string) => void;\n card?: (m: MapMarker) => React.ReactNode;\n};\n\n/** The pins for the markers near the view, as one roving group: one tab stop, arrows between them. */\nexport function MarkerLayer({ map, placed, onSelect, card }: LayerProps) {\n const [activeId, setActiveId] = React.useState<string | null>(null);\n const els = React.useRef(new Map<string, HTMLElement>());\n const ids = placed.map((p) => p.marker.id);\n const active = activeId !== null && ids.includes(activeId) ? activeId : (ids[0] ?? null);\n const register = React.useCallback((id: string, el: HTMLElement | null) => {\n if (el) els.current.set(id, el);\n else els.current.delete(id);\n }, []);\n const move = (id: string, to: \"next\" | \"previous\" | \"first\" | \"last\") => {\n const i = ids.indexOf(id);\n const next = to === \"first\" ? 0 : to === \"last\" ? ids.length - 1 : Math.min(ids.length - 1, Math.max(0, i + (to === \"next\" ? 1 : -1)));\n setActiveId(ids[next]);\n els.current.get(ids[next])?.focus();\n };\n return (\n <>\n {placed.map((p) => (\n <Pin key={p.marker.id} map={map} placed={p} active={p.marker.id === active} onActivate={setActiveId} onMove={move} register={register} onSelect={onSelect} card={card} />\n ))}\n </>\n );\n}\n\n/** The key to the marker states that are on the map, each with its shape and its words. */\nexport function MarkerKey({ markers, words }: { markers: readonly MapMarker[]; words?: MarkerKeyWords }) {\n const kinds = ([\"marker\", \"selected\", \"highlighted\"] as const).filter((k) => markers.some((m) => state(m) === k));\n const text = { marker: words?.marker ?? \"Item\", selected: words?.selected ?? \"Selected\", highlighted: words?.highlighted ?? \"Highlighted\" };\n if (!kinds.length) return null;\n return (\n <div className=\"rounded-control border border-border bg-background px-2 py-1.5 type-caption text-foreground\">\n <ul className=\"grid gap-0.5\">\n {kinds.map((k) => (\n <li key={k} className=\"flex items-center gap-2\">\n <span className=\"grid size-4 place-items-center\">\n <Shape kind={k} colour={k === \"highlighted\" ? \"var(--success)\" : k === \"selected\" ? \"var(--foreground)\" : \"var(--primary)\"} />\n </span>\n {text[k]}\n </li>\n ))}\n </ul>\n </div>\n );\n}\n","import * as React from \"react\";\nimport L from \"leaflet\";\nimport { useColorScheme } from \"../components/theme\";\nimport { cn } from \"../lib/utils\";\nimport { format } from \"../lib/format\";\nimport { geo, type LatLng } from \"../lib/geo\";\nimport { installMapStyles } from \"./map-styles\";\nimport { useSharedCursor } from \"../components/cursor\";\nimport { MarkerKey, MarkerLayer, alongOf, placeMarkers, type MapMarker, type MarkerKeyWords } from \"./markers\";\n\n// A themed map of routes with a position that moves along them (strata-react issue #80, from\n// strata-vid's MapPanel and jonathanburnhams.com's activity maps). It is behind its own entry,\n// `strata-react/map`, because Leaflet is heavy and an app that draws no maps should not install it:\n// Leaflet is an optional peer and nothing in the main entry imports it.\n//\n// Leaflet, without react-leaflet (Jonathan's choice, 2026-11-12). react-leaflet binds every layer to\n// a React element, so a position that moves sixty times a second re-renders the route elements\n// beside it; here the map is made once, the routes are one effect that runs only when the routes\n// change, and the position is another that calls `setLatLng` on one marker. A position update\n// touches nothing else: no route is redrawn, none is recreated.\n//\n// What the app supplies, and what the component decides:\n// - Tiles are the app's (`tiles.light`, `tiles.dark`, each with the attribution its provider\n// requires, shown on the map). A dark scheme uses `tiles.dark` when there is one, else the light\n// tiles under a filter (see map-styles.ts); the choice follows the colour scheme.\n// - Colours are roles. A route's colour is any CSS colour (`var(--chart-2)`, `var(--info)`), resolved\n// against the map's own element so SVG strokes, which Leaflet writes as attributes, get a real\n// colour that follows the scheme. Routes default to the chart palette in order.\n// - Colour by value (`values` on a route plus `colourScale`) follows LineChart's rules (§3.8): the\n// colour is a fact of the subject, steps are the app's, and a key names them (`colourScaleLabel`\n// and the step thresholds through `formatValue`) so colour is never the only cue. Runs of one\n// step are drawn as one line, so a long route is a few polylines, not thousands.\n// - One route is the common case: it gets direction chevrons and start and finish marks (a loop is\n// one mark) by default; with several routes those are off unless a route asks.\n// - Fit-to-content happens on first show and when the set of routes changes, not when a route's\n// points are replaced by the same ids, so a person who has zoomed is not thrown back.\n// - Overlay slots, `topEnd` and `bottomStart`, sit where Leaflet puts nothing (it uses the top\n// start for zoom and the bottom end for attribution), so an app's own control or figure never\n// covers a required notice.\n//\n// Keyboard and screen readers. Leaflet's container is a focus stop: arrows pan, + and − zoom. It is\n// named by `label` and described by a text alternative that says what is drawn (each route, its\n// length, whether it is a loop, and how far along the position is), written from the data or given\n// as `summary`. Hovering a route or a mark is a bonus; its facts are in that text. Choosing a route\n// is `onSelect`, and a screen that lets a person choose one lists its routes beside the map (a\n// pointer click on a line has no keyboard equivalent inside Leaflet's SVG, so the list is the path).\n//\n// Map as picture content (issue #161, from strata-vid, where a route inset is composed over footage and\n// must look the same on every frame as in an export drawn on a canvas). Three additions, none of which\n// changes a page map: `zoom` sets the zoom from outside (any number, so an animation is a prop that\n// changes every frame; unset keeps fit-to-routes), `follow=\"centre\"` holds the view on a position at that\n// zoom, and `positions` draws several moving positions, each tied to a route and drawn in its colour.\n// Centred follow pans to a whole-pixel view worked out from the position and zoom alone (`centre`), with\n// no animation: Leaflet's own centred pan truncates each step, so where the view ended up would depend\n// on the path it took; this depends only on the position and zoom, which is what makes frame N the same\n// picture however it was reached. A `reset` would give the same view but empties the tile layer on every\n// call, which flickers at one update per frame.\n// Fractional zoom needs `zoomSnap: 0`, which is set only while `zoom` is controlled, so a page map still\n// snaps to half steps. Each marker is one `L.CircleMarker` kept by id and moved with `setLatLng`.\n//\n// The map as an instrument, not only a picture (strata-react issues #181, #182, #184):\n// - `markers`: items on the route as controls with cards, fanned apart (markers.tsx).\n// - `onViewChange`: the visible bounds and zoom, once when movement settles (debounced `settle` ms), and\n// not for a move the app made through its own props (`zoom`, `view`, `follow`, the first fit), which it\n// already knows about: every move the component makes itself runs inside `silently`, and Leaflet's events\n// are synchronous with animation off, so the flag cannot leak. `reportAppMoves` turns that off.\n// - `view` restores a saved view; the person's own moves go out through `onViewChange`. A reset control\n// in Leaflet's own control group fits the routes again (or sets the zoom, when one is controlled).\n// - `picking` + `onPick`: choose a place. Pointer: a click. Keyboard: arrows move a crosshair (Shift for\n// bigger steps), Enter chooses, Escape asks to cancel; Leaflet's own arrow handling is switched off for\n// the time, since both would move. The result is announced with the nearest route, how far along it and\n// how far off (`geo.snap`). Route lines stop taking clicks while picking, or a pick near the route would\n// select the route instead. A click when not picking does nothing new.\n// - `cursor`: joins a `CursorScope` (cursor.tsx). The scope's unit here is metres along one route; a\n// pointer near the route (within 24 px of it) writes the distance of the nearest point on it, and\n// another member's distance is drawn as a ring on the route. Never drawn back at its own writer.\n//\n// No animation: zoom, fade and inertia are off, because a map is panned all the time and a tile\n// fade makes a screenshot depend on timing (character by frequency, and strata-visual).\n//\n// Checked: React Aria has no map or geographic part. Leaflet's own keyboard handler and focus are\n// kept as they are.\n\n/** A source of map tiles: a URL template the app's provider documents, and the attribution it requires. */\nexport type TileSource = {\n /** `https://tiles.example.com/{z}/{x}/{y}.png`; `{s}` and `{r}` work as in Leaflet. */\n url: string;\n /** What the provider requires shown (HTML allowed: \"© OpenStreetMap contributors\"). */\n attribution: string;\n subdomains?: string;\n minZoom?: number;\n maxZoom?: number;\n};\n\n/** One route on the map. */\nexport type MapRoute = {\n id: string;\n /** Its name, in the text alternative and on hover (\"Wednesday run\"). */\n label: string;\n points: readonly LatLng[];\n /** Any CSS colour, normally a role (`var(--chart-2)`). Default: the chart palette in order. */\n colour?: string;\n /** Line width in pixels. Default 4. */\n weight?: number;\n /** One value per point, coloured by `colourScale` (speed, elevation, heart rate). */\n values?: readonly number[];\n /** Direction chevrons along the line: true for five, or a count. Default on for a single route. */\n arrows?: boolean | number;\n /** Start and finish marks. Default on for a single route. */\n ends?: boolean;\n};\n\n/** One moving position, for a map with more than one (two runners on the same loop). */\nexport type MapPosition = {\n /** Stable between renders: the marker is kept by it and moved, never recreated. */\n id: string;\n /** Where it is now; null hides it. */\n at: LatLng | null;\n /** What it is called in the text alternative (\"Runner A\"). */\n label: string;\n /** The route it travels. Its marker takes that route's colour and the text alternative says how far along it is. */\n routeId?: string;\n /** Any CSS colour, normally a role. Overrides the route's. Default: the route's colour, else the theme's primary. */\n colour?: string;\n};\n\n/** The view the map settled on. */\nexport type MapView = { bounds: [LatLng, LatLng]; zoom: number; center: LatLng };\n\n/** The route nearest a picked place. */\nexport type PickNearest = {\n routeId: string;\n /** The leg of the route (its first point's index) the place is nearest. */\n index: number;\n /** How far the place is from the route, in metres. */\n distanceM: number;\n /** How far along the route the nearest point is, in metres. */\n alongM: number;\n /** The nearest point on the route. */\n position: LatLng;\n};\n\nexport type RouteMapProps = {\n /** Names the map (\"Route of Wednesday's run\"). */\n label: string;\n /** Keep this array stable between renders (state or `useMemo`): the routes are redrawn when it changes, which a moving position must not cause. */\n routes: readonly MapRoute[];\n tiles: { light: TileSource; dark?: TileSource };\n /** Where the moving thing is now. Moved without redrawing any route; null for none. */\n position?: LatLng | null;\n /** What the position is called in the text alternative. Default \"Current position\". */\n positionLabel?: string;\n /** More moving positions, each in its route's colour and named in the text alternative. Moved without redrawing any route; `position` may be used beside them. */\n positions?: readonly MapPosition[];\n /** Which position `follow` tracks: a `positions` id. Default `position`, else the first of `positions` that is shown. */\n followId?: string;\n /** `true` pans only when the position leaves the inner 80% of the view; `\"centre\"` keeps it exactly in the centre on every update, with no animation (a frame is deterministic), at `zoom` when that is set, else the zoom the map has. */\n follow?: boolean | \"centre\";\n /** The zoom level, any number (12, 14.5): it may change every frame without redrawing routes. Unset, the map fits its routes and the person zooms. */\n zoom?: number;\n /** Items on the map: places, or stretches of a route. Keep the array stable between renders. */\n markers?: readonly MapMarker[];\n /** A marker was pressed (click, Enter or Space). */\n onMarkerSelect?: (id: string) => void;\n /** The words shown beside a marker on hover and focus (as `Tooltip`; not interactive). Default its label. */\n renderMarkerCard?: (marker: MapMarker) => React.ReactNode;\n /** The words of the marker key; `false` leaves the key out. */\n markerKey?: MarkerKeyWords | false;\n /** Join the nearest `CursorScope`: a pointer near a route puts its distance along it in every member, and another member's distance shows as a ring on the route. `{ routeId }` picks the route (default the first). */\n cursor?: boolean | { routeId?: string };\n /** The view settled after the person moved or zoomed it: bounds, zoom and centre. Not called for moves the app caused through props. */\n onViewChange?: (view: MapView) => void;\n /** Milliseconds the view must be still before `onViewChange`. Default 250. */\n settle?: number;\n /** Also call `onViewChange` for moves the app caused through props (the first fit, `zoom`, `view`, `follow`). */\n reportAppMoves?: boolean;\n /** A view to show: centre and zoom, as a saved view or the app's own. The person can still move away from it; set it again to go back. Wins over fitting the routes. */\n view?: { center: LatLng; zoom: number };\n /** Choose a place on the map. While set, a click or Enter picks and route lines do not take clicks. */\n picking?: boolean;\n /** A place was chosen, with the nearest route to it when there is one. */\n onPick?: (at: LatLng, info: { nearest: PickNearest | null }) => void;\n /** Escape was pressed while picking: the app turns `picking` off. */\n onPickCancel?: () => void;\n /** The banner for pick mode (\"Click the map to set the point; Escape cancels\"), shown top centre. */\n pickBanner?: React.ReactNode;\n /** The route drawn heavier, with the others lighter. */\n selectedId?: string | null;\n /** A route line was pressed. Give the app's own list of routes the same action for the keyboard. */\n onSelect?: (id: string) => void;\n /** Step colours for routes that have `values`: a step starts at `at` and runs to the next. */\n colourScale?: readonly { at: number; colour: string }[];\n /** What the colours mean, written in the key (\"Speed\"). */\n colourScaleLabel?: string;\n /** Writes a value in the key and the text alternative (\"12 km/h\"). Default the plain number. */\n formatValue?: (value: number) => string;\n /** Replaces the generated text alternative. */\n summary?: string;\n /** Units for lengths in the generated text. Default metric. */\n units?: \"metric\" | \"imperial\";\n /** Wheel zoom. Off by default so the page still scrolls past the map. */\n scrollZoom?: boolean;\n /** An app control or figure in the top end corner (Leaflet leaves it free). */\n topEnd?: React.ReactNode;\n /** An app legend or figure in the bottom start corner, below the colour key when there is one. */\n bottomStart?: React.ReactNode;\n /** Layout only. The map is 16:9 and at least 16rem tall unless a height is given. */\n className?: string;\n};\n\n/** The smallest and largest value, without spreading the array (a long recording passes the engine's argument limit). */\nfunction extent(values: readonly number[]): [number, number] {\n let lo = Infinity;\n let hi = -Infinity;\n for (const v of values) {\n if (v < lo) lo = v;\n if (v > hi) hi = v;\n }\n return [lo, hi];\n}\n\nconst tuple = (p: LatLng): L.LatLngTuple => [p[0], p[1]];\nconst plain = (v: number) => String(v);\n\n/** `value`, sampled once a second (a throttle, not a debounce: a value that changes every frame still comes through): for text a screen reader may read, which must not change sixty times a second. */\nfunction useSlow<T>(value: T, ms = 1000): T {\n const [slow, setSlow] = React.useState(value);\n const latest = React.useRef(value);\n latest.current = value;\n React.useEffect(() => {\n const id = window.setInterval(() => setSlow(latest.current), ms);\n return () => window.clearInterval(id);\n }, [ms]);\n return slow;\n}\n\n/** How many moves of the map the component itself is making right now (see `onViewChange`). */\nconst quiet = new WeakMap<L.Map, number>();\n/** Run a move the component makes itself, so `onViewChange` does not report it. Leaflet's events are synchronous with animation off. */\nfunction silently<T>(map: L.Map, fn: () => T): T {\n quiet.set(map, (quiet.get(map) ?? 0) + 1);\n try {\n return fn();\n } finally {\n quiet.set(map, (quiet.get(map) ?? 1) - 1);\n }\n}\n\n/** The route nearest a place, by distance from it to the route (not to a vertex). */\nfunction nearestRoute(routes: readonly MapRoute[], at: LatLng): PickNearest | null {\n let best: PickNearest | null = null;\n for (const r of routes) {\n const s = geo.snap(r.points, at, alongOf(r.points));\n if (s && (!best || s.offset < best.distanceM)) best = { routeId: r.id, index: s.index, distanceM: s.offset, alongM: s.metres, position: s.position };\n }\n return best;\n}\n\nconst RESET_ICON = '<svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M2 6V2h4M10 2h4v4M14 10v4h-4M6 14H2v-4\"/></svg>';\nconst CROSS_ICON = '<svg width=\"32\" height=\"32\" viewBox=\"0 0 32 32\" aria-hidden=\"true\" fill=\"none\" stroke-linecap=\"round\"><path d=\"M16 4v24M4 16h24\" stroke=\"var(--background)\" stroke-width=\"5\"/><path d=\"M16 4v24M4 16h24\" stroke=\"var(--foreground)\" stroke-width=\"2\"/></svg>';\n\n/** Leaflet's control group gets a reset: fit the routes again. A link with a button role, as Leaflet's own zoom buttons are. */\nfunction resetControl(onReset: () => void): L.Control {\n const control = new L.Control({ position: \"topleft\" });\n control.onAdd = () => {\n const bar = L.DomUtil.create(\"div\", \"leaflet-bar leaflet-control\");\n const a = L.DomUtil.create(\"a\", \"strata-map-reset\", bar);\n a.href = \"#\";\n a.setAttribute(\"role\", \"button\");\n a.setAttribute(\"aria-label\", \"Reset view\");\n a.title = \"Reset view\";\n a.innerHTML = RESET_ICON;\n L.DomEvent.disableClickPropagation(bar);\n L.DomEvent.on(a, \"click\", (e) => {\n L.DomEvent.preventDefault(e);\n onReset();\n });\n L.DomEvent.on(a, \"keydown\", (e) => {\n if ((e as KeyboardEvent).key === \" \") {\n L.DomEvent.preventDefault(e);\n onReset();\n }\n });\n return bar;\n };\n return control;\n}\n\n/** Put the routes in view (or, with a zoom set, centre the routes at it). */\nfunction showRoutes(map: L.Map, routes: readonly MapRoute[], zoom: number | undefined) {\n const box = geo.bounds(routes.flatMap((r) => r.points));\n if (!box) return false;\n if (zoom !== undefined) map.setView([(box[0][0] + box[1][0]) / 2, (box[0][1] + box[1][1]) / 2], zoom, { animate: false });\n else map.fitBounds([tuple(box[0]), tuple(box[1])], { padding: [24, 24], animate: false, maxZoom: 17 });\n return true;\n}\n\nconst SINGLE = \"\\u0000position\";\nconst PALETTE = [1, 2, 3, 4, 5].map((n) => `var(--chart-${n})`);\n\n/**\n * Put `target` in the exact middle of the view at zoom `z`, with no animation and without throwing the\n * loaded tiles away. A zoom change goes through `setView` (Leaflet redraws its tiles then anyway). The\n * position is then set by panning to a whole-pixel top-left worked out from the target and the zoom\n * alone, so where the view ends up does not depend on the path taken (Leaflet's own centred pan\n * truncates each step and drifts); a `reset` would be exact too but empties the tile layer on every\n * call, which flickers when the position changes every frame.\n */\nfunction centre(map: L.Map, target: LatLng, z: number) {\n silently(map, () => {\n if (map.getZoom() !== z) map.setView(tuple(target), z, { animate: false });\n const want = map.project(tuple(target), z).subtract(map.getSize().divideBy(2)).round();\n const have = map.getPixelBounds().min!.round();\n const move = want.subtract(have);\n if (move.x || move.y) map.panBy(move, { animate: false, noMoveStart: true });\n });\n}\n\n/** The colour a CSS value (a `var()`, a role) resolves to on `el`, so an SVG attribute gets a real one. Falls back to the value itself. */\nfunction resolveColour(el: HTMLElement, value: string): string {\n const probe = document.createElement(\"span\");\n probe.style.color = value;\n el.appendChild(probe);\n const resolved = getComputedStyle(probe).color;\n probe.remove();\n return resolved || value;\n}\n\n/** Indices where a run of one step ends, so a coloured route is a few polylines. */\nfunction stepRuns(points: readonly LatLng[], values: readonly number[], stepOf: (v: number) => number) {\n const runs: { from: number; to: number; step: number }[] = [];\n for (let i = 1; i < points.length; i++) {\n const step = stepOf(((values[i - 1] ?? 0) + (values[i] ?? 0)) / 2);\n const last = runs[runs.length - 1];\n if (last && last.step === step) last.to = i;\n else runs.push({ from: i - 1, to: i, step });\n }\n return runs;\n}\n\nconst arrowHtml = (bearing: number, colour: string, halo: string) =>\n `<svg width=\"26\" height=\"26\" viewBox=\"0 0 26 26\" aria-hidden=\"true\" style=\"transform: rotate(${bearing.toFixed(0)}deg)\">` +\n `<path d=\"M6 17 L13 9 L20 17\" fill=\"none\" stroke=\"${halo}\" stroke-width=\"7\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>` +\n `<path d=\"M6 17 L13 9 L20 17\" fill=\"none\" stroke=\"${colour}\" stroke-width=\"3.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>`;\n\n/** A map of one or more routes with a position that moves along them, on tiles the app supplies, themed from its roles. Leaflet, behind `strata-react/map`. */\nexport function RouteMap({\n label,\n routes,\n tiles,\n position = null,\n positionLabel = \"Current position\",\n positions,\n followId,\n follow = false,\n zoom,\n markers,\n onMarkerSelect,\n renderMarkerCard,\n markerKey,\n cursor: cursorProp,\n onViewChange,\n settle = 250,\n reportAppMoves = false,\n view,\n picking = false,\n onPick,\n onPickCancel,\n pickBanner,\n selectedId = null,\n onSelect,\n colourScale,\n colourScaleLabel,\n formatValue = plain,\n summary,\n units = \"metric\",\n scrollZoom = false,\n topEnd,\n bottomStart,\n className,\n}: RouteMapProps) {\n const { scheme } = useColorScheme();\n const host = React.useRef<HTMLDivElement>(null);\n const root = React.useRef<HTMLDivElement>(null);\n const [map, setMap] = React.useState<L.Map | null>(null);\n const summaryId = React.useId();\n const latest = React.useRef({ onSelect, onViewChange, reportAppMoves, settle, picking, onPick, onPickCancel, routes, units, view, zoom });\n latest.current = { onSelect, onViewChange, reportAppMoves, settle, picking, onPick, onPickCancel, routes, units, view, zoom };\n const [announced, setAnnounced] = React.useState(\"\");\n // True once the map has a view (the first fit has happened): before that Leaflet cannot say what is near.\n const [ready, setReady] = React.useState(false);\n const selectable = Boolean(onSelect);\n // One marker per position, by id, with the style last applied so a moving marker is not restyled every frame.\n const posMarkers = React.useRef(new Map<string, { marker: L.CircleMarker; style: string }>());\n\n const darkTiles = scheme === \"dark\" ? tiles.dark : undefined;\n const source = darkTiles ?? tiles.light;\n const treated = scheme === \"dark\" && !tiles.dark;\n const stops = React.useMemo(() => (colourScale ? [...colourScale].sort((a, b) => a.at - b.at) : []), [colourScale]);\n\n // The map, made once. Its container is Leaflet's; React owns only the wrapper around it.\n React.useEffect(() => {\n installMapStyles();\n const el = host.current;\n if (!el) return;\n const m = L.map(el, { scrollWheelZoom: scrollZoom, fadeAnimation: false, zoomAnimation: false, markerZoomAnimation: false, inertia: false, attributionControl: false, zoomSnap: 0.5 });\n L.control.attribution({ prefix: '<a href=\"https://leafletjs.com\">Leaflet</a>' }).addTo(m);\n el.setAttribute(\"aria-roledescription\", \"map\");\n // Leaflet follows the window, not its container; a pane that resizes (a Workspace split) needs the same.\n const ro = new ResizeObserver(() => m.invalidateSize({ animate: false }));\n ro.observe(el);\n setMap(m);\n return () => {\n ro.disconnect();\n posMarkers.current.clear();\n m.remove();\n setMap(null);\n setReady(false);\n };\n // The wheel setting is applied below, so the map is not rebuilt for it.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n React.useEffect(() => {\n if (!map) return;\n if (scrollZoom) map.scrollWheelZoom.enable();\n else map.scrollWheelZoom.disable();\n }, [map, scrollZoom]);\n\n // A zoom set from outside is any number; Leaflet snaps to `zoomSnap`, so it is 0 while zoom is controlled.\n const zoomed = zoom !== undefined;\n React.useEffect(() => {\n if (map) map.options.zoomSnap = zoomed ? 0 : 0.5;\n }, [map, zoomed]);\n\n // Every position on the map, the single `position` first: what is spoken, drawn and followed.\n const all = React.useMemo<MapPosition[]>(() => [...(position ? [{ id: SINGLE, at: position, label: positionLabel }] : []), ...(positions ?? [])], [position, positionLabel, positions]);\n\n // The text alternative: written from the data unless the app gives one. The position is in it, but\n // it is not a live region: a position that moves many times a second must not be announced.\n const spoken = useSlow(all);\n const text = React.useMemo(() => {\n if (summary) return summary;\n if (!routes.length) return \"No routes to show.\";\n const parts = routes.map((r) => {\n const along = geo.cumulative(r.points);\n const total = along[along.length - 1] ?? 0;\n const ends = geo.ends(r.points);\n const shape = ends?.loop ? \", a loop\" : \"\";\n let here = \"\";\n // A position tied to another route is not on this one; one tied to no route is described along each.\n for (const p of spoken) {\n if (!p.at || !r.points.length || (p.routeId !== undefined && p.routeId !== r.id && routes.some((o) => o.id === p.routeId))) continue;\n here += ` ${p.label}: ${format.distance(along[geo.nearest(r.points, p.at)] ?? 0, units)} along.`;\n }\n let range = \"\";\n if (stops.length && r.values?.length) range = ` ${colourScaleLabel ?? \"Value\"} from ${formatValue(extent(r.values)[0])} to ${formatValue(extent(r.values)[1])}.`;\n return `${r.label}: ${format.distance(total, units)}${shape}.${range}${here}`;\n });\n const items = markers?.length ? ` ${markers.length === 1 ? \"One marker\" : `${markers.length} markers`}${markers.some((m) => m.selected) ? `, selected: ${markers.filter((m) => m.selected).map((m) => m.label).join(\", \")}` : \"\"}.` : \"\";\n return `Map with ${routes.length === 1 ? \"one route\" : `${routes.length} routes`}. ${parts.join(\" \")}${items}`;\n }, [summary, routes, spoken, units, stops.length, colourScaleLabel, formatValue, markers]);\n\n React.useEffect(() => {\n if (!map) return;\n const c = map.getContainer();\n c.setAttribute(\"aria-label\", label);\n c.setAttribute(\"aria-describedby\", summaryId);\n }, [map, label, summaryId]);\n\n // Tiles: the light set, or the dark one in the dark scheme.\n React.useEffect(() => {\n if (!map) return;\n const layer = L.tileLayer(source.url, { attribution: source.attribution, subdomains: source.subdomains ?? \"abc\", minZoom: source.minZoom, maxZoom: source.maxZoom ?? 19, keepBuffer: 1 });\n layer.addTo(map);\n return () => void layer.remove();\n }, [map, source.url, source.attribution, source.subdomains, source.minZoom, source.maxZoom]);\n\n // The routes: redrawn when the routes, the scheme (colours resolve differently), the selection or\n // the scale change, and never for a position update.\n React.useEffect(() => {\n if (!map) return;\n const group = L.featureGroup().addTo(map);\n const el = map.getContainer();\n const halo = resolveColour(el, \"var(--background)\");\n const single = routes.length === 1;\n const stepOf = (v: number) => {\n let at = 0;\n stops.forEach((s, i) => {\n if (s.at <= v) at = i;\n });\n return at;\n };\n routes.forEach((route, index) => {\n if (route.points.length < 2) return;\n const base = resolveColour(el, route.colour ?? PALETTE[index % PALETTE.length]);\n const selected = route.id === selectedId;\n const dim = selectedId !== null && !selected;\n const weight = (route.weight ?? 4) + (selected ? 2 : 0);\n const style = { weight, opacity: dim ? 0.55 : 1, lineCap: \"round\" as const, lineJoin: \"round\" as const, interactive: selectable && !picking, bubblingMouseEvents: false };\n const lines: L.Polyline[] = [];\n if (stops.length && route.values?.length) {\n for (const run of stepRuns(route.points, route.values, stepOf)) {\n lines.push(L.polyline(route.points.slice(run.from, run.to + 1).map(tuple), { ...style, color: resolveColour(el, stops[run.step].colour) }));\n }\n } else {\n lines.push(L.polyline(route.points.map(tuple), { ...style, color: base }));\n }\n for (const line of lines) {\n line.bindTooltip(route.label, { sticky: true });\n line.on(\"click\", () => latest.current.onSelect?.(route.id));\n line.addTo(group);\n }\n const chevrons = route.arrows === undefined ? (single ? 5 : 0) : route.arrows === true ? 5 : route.arrows === false ? 0 : route.arrows;\n if (chevrons > 0) {\n for (const a of geo.arrows(route.points, chevrons)) {\n L.marker(tuple(a.position), {\n interactive: false,\n keyboard: false,\n icon: L.divIcon({ className: \"strata-map-arrow\", iconSize: [26, 26], iconAnchor: [13, 13], html: arrowHtml(a.bearing, base, halo) }),\n }).addTo(group);\n }\n }\n if (route.ends ?? single) {\n const ends = geo.ends(route.points);\n if (ends) {\n const success = resolveColour(el, \"var(--success)\");\n const danger = resolveColour(el, \"var(--danger)\");\n const mark = (at: LatLng, text: string, options: L.CircleMarkerOptions) => L.circleMarker(tuple(at), { radius: 7, interactive: true, bubblingMouseEvents: false, ...options }).bindTooltip(text).addTo(group);\n // Shapes carry the meaning as well as colour: a filled start, a ringed finish, one of each for a loop.\n if (ends.loop) mark(ends.start, `${route.label}: start and finish`, { color: danger, weight: 3, fillColor: success, fillOpacity: 1 });\n else {\n mark(ends.finish, `${route.label}: finish`, { color: danger, weight: 3, fillColor: halo, fillOpacity: 1 });\n mark(ends.start, `${route.label}: start`, { color: halo, weight: 2, fillColor: success, fillOpacity: 1 });\n }\n }\n }\n });\n // Redrawn routes are new layers: keep the positions above them.\n for (const { marker } of posMarkers.current.values()) marker.bringToFront();\n return () => void group.remove();\n }, [map, routes, scheme, selectedId, stops, selectable, picking]);\n\n // The position a followed view is held on: read by the fit (a map shown for the first time starts\n // centred on it) and by the position effect.\n const target = React.useMemo(() => {\n if (!follow) return null;\n const shown = all.filter((p) => p.at);\n return (followId ? shown.find((p) => p.id === followId) : shown[0])?.at ?? null;\n }, [all, follow, followId]);\n const latestView = React.useRef({ target, zoom, centred: follow === \"centre\" });\n latestView.current = { target, zoom, centred: follow === \"centre\" };\n\n // Fit to the routes when the map first has a size and whenever the set of routes changes. With a\n // zoom set there is nothing to fit: the view is placed at that zoom, on the followed position when\n // the map is centred on one, else on the middle of the routes.\n const routeKey = routes.map((r) => r.id).join(\"\\n\");\n const fitted = React.useRef<string | null>(null);\n React.useEffect(() => {\n if (!map) return;\n const fit = () => {\n const size = map.getSize();\n if (fitted.current === routeKey || size.x === 0 || size.y === 0) return;\n if (!geo.bounds(routes.flatMap((r) => r.points)) && !latest.current.view) return;\n fitted.current = routeKey;\n const v = latestView.current;\n setReady(true);\n // A given view wins, then a set zoom (on the followed position, or the routes' middle), then the routes.\n silently(map, () => {\n if (latest.current.view) map.setView(tuple(latest.current.view.center), latest.current.view.zoom, { animate: false });\n else if (v.zoom !== undefined && v.centred && v.target) map.setView(tuple(v.target), v.zoom, { animate: false });\n else showRoutes(map, latest.current.routes, v.zoom);\n });\n };\n fit();\n map.on(\"resize\", fit);\n return () => void map.off(\"resize\", fit);\n // `routes` is read when the key says the set changed; a new array of the same ids does not refit.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [map, routeKey]);\n\n // A zoom that changes after the first view (an animation) moves the zoom about the view's centre.\n React.useEffect(() => {\n if (map && zoom !== undefined && fitted.current !== null && map.getZoom() !== zoom) silently(map, () => map.setZoom(zoom, { animate: false }));\n }, [map, zoom]);\n\n // The positions: one marker each, kept by id and moved with `setLatLng`. No route is touched.\n React.useEffect(() => {\n if (!map) return;\n const el = map.getContainer();\n const live = posMarkers.current;\n const seen = new Set<string>();\n for (const p of all) {\n if (!p.at) continue;\n seen.add(p.id);\n let entry = live.get(p.id);\n if (!entry) {\n entry = { marker: L.circleMarker(tuple(p.at), { radius: 8, weight: 3, fillOpacity: 1, interactive: false }).addTo(map), style: \"\" };\n live.set(p.id, entry);\n } else entry.marker.setLatLng(tuple(p.at));\n const index = routes.findIndex((r) => r.id === p.routeId);\n const spec = p.colour ?? (index >= 0 ? (routes[index].colour ?? PALETTE[index % PALETTE.length]) : \"var(--primary)\");\n const style = `${scheme}|${spec}`;\n if (entry.style !== style) {\n entry.style = style;\n entry.marker.setStyle({ color: resolveColour(el, \"var(--background)\"), fillColor: resolveColour(el, spec) });\n }\n }\n for (const [id, entry] of live) {\n if (seen.has(id)) continue;\n entry.marker.remove();\n live.delete(id);\n }\n if (!target) return;\n if (follow === \"centre\") {\n // Before the first fit with no zoom set there is no zoom to hold; the fit places the view.\n const z = zoom ?? (fitted.current === null ? undefined : map.getZoom());\n if (z !== undefined) centre(map, target, z);\n } else if (!map.getBounds().pad(-0.2).contains(tuple(target))) silently(map, () => map.panTo(tuple(target), { animate: false }));\n }, [map, all, routes, scheme, follow, target, zoom]);\n\n // The reset control: fit the routes again, as the person's own move (so it is reported).\n React.useEffect(() => {\n if (!map) return;\n const control = resetControl(() => {\n const view = latest.current.view;\n if (view) map.setView(tuple(view.center), view.zoom, { animate: false });\n else showRoutes(map, latest.current.routes, latest.current.zoom);\n });\n control.addTo(map);\n return () => void control.remove();\n }, [map]);\n\n // The view, reported once it settles: the person's moves, not the app's own (unless asked).\n React.useEffect(() => {\n if (!map) return;\n let timer: number | undefined;\n const send = () => {\n timer = undefined;\n const b = map.getBounds();\n const c = map.getCenter();\n latest.current.onViewChange?.({ bounds: [[b.getSouth(), b.getWest()], [b.getNorth(), b.getEast()]], zoom: map.getZoom(), center: [c.lat, c.lng] });\n };\n const moved = () => {\n if (!latest.current.onViewChange) return;\n if (!latest.current.reportAppMoves && (quiet.get(map) ?? 0) > 0) return;\n window.clearTimeout(timer);\n timer = window.setTimeout(send, latest.current.settle);\n };\n map.on(\"moveend zoomend\", moved);\n // The first fit ran before this listener was there: with `reportAppMoves`, it is reported too.\n if (fitted.current !== null && latest.current.reportAppMoves) moved();\n return () => {\n map.off(\"moveend zoomend\", moved);\n window.clearTimeout(timer);\n };\n }, [map]);\n\n // A view the app sets (a saved one): the map goes there when it changes, silently.\n const [viewLat, viewLng, viewZoom] = view ? [view.center[0], view.center[1], view.zoom] : [null, null, null];\n React.useEffect(() => {\n if (!map || viewLat === null || viewLng === null || viewZoom === null || fitted.current === null) return;\n const c = map.getCenter();\n if (map.getZoom() === viewZoom && Math.abs(c.lat - viewLat) < 1e-7 && Math.abs(c.lng - viewLng) < 1e-7) return;\n silently(map, () => map.setView([viewLat, viewLng], viewZoom, { animate: false }));\n }, [map, viewLat, viewLng, viewZoom]);\n\n // The shared cursor: metres along one route.\n const shared = useSharedCursor();\n const cursorOn = Boolean(cursorProp) && shared !== null;\n const cursorRouteId = typeof cursorProp === \"object\" && cursorProp.routeId ? cursorProp.routeId : routes[0]?.id;\n const cursorRoute = routes.find((r) => r.id === cursorRouteId) ?? null;\n const setPointer = shared?.setPointer;\n React.useEffect(() => {\n if (!map || !cursorOn || !cursorRoute || !setPointer) return;\n const along = alongOf(cursorRoute.points);\n const onMove = (e: L.LeafletMouseEvent) => {\n if (latest.current.picking) return;\n const snap = geo.snap(cursorRoute.points, [e.latlng.lat, e.latlng.lng], along);\n if (!snap) return;\n const apart = map.latLngToContainerPoint(e.latlng).distanceTo(map.latLngToContainerPoint(tuple(snap.position)));\n setPointer(apart <= 24 ? snap.metres : null);\n };\n const onOut = () => setPointer(null);\n map.on(\"mousemove\", onMove);\n map.on(\"mouseout\", onOut);\n return () => {\n map.off(\"mousemove\", onMove);\n map.off(\"mouseout\", onOut);\n setPointer(null);\n };\n }, [map, cursorOn, cursorRoute, setPointer]);\n const otherAlong = cursorOn ? (shared?.other ?? null) : null;\n const ring = React.useRef<L.CircleMarker | null>(null);\n React.useEffect(() => {\n if (!map) return;\n const at = otherAlong !== null && cursorRoute ? geo.pointAlong(cursorRoute.points, otherAlong, alongOf(cursorRoute.points)) : null;\n if (!at) {\n ring.current?.remove();\n ring.current = null;\n return;\n }\n if (!ring.current) {\n const el = map.getContainer();\n ring.current = L.circleMarker(tuple(at), { radius: 9, weight: 3, fillOpacity: 0, interactive: false, color: resolveColour(el, \"var(--foreground)\") }).addTo(map);\n } else ring.current.setLatLng(tuple(at));\n }, [map, otherAlong, cursorRoute]);\n React.useEffect(() => () => void (ring.current = null), [map]);\n\n // Item markers: those near the view, laid out again each time it settles.\n const [tick, setTick] = React.useState(0);\n React.useEffect(() => {\n if (!map || !markers?.length) return;\n const again = () => setTick((t) => t + 1);\n map.on(\"moveend zoomend resize\", again);\n return () => void map.off(\"moveend zoomend resize\", again);\n }, [map, markers?.length]);\n const placed = React.useMemo(() => (map && ready && markers?.length ? placeMarkers(map, markers, routes) : []), [map, ready, markers, routes, tick]);\n // A stretch is its route's part drawn heavier, and a fanned marker has a leader line back to its true place.\n React.useEffect(() => {\n if (!map || !markers?.length) return;\n const group = L.featureGroup().addTo(map);\n const el = map.getContainer();\n for (const m of markers) {\n if (Array.isArray(m.at)) continue;\n const at = m.at as { routeId: string; from: number; to: number };\n const index = routes.findIndex((r) => r.id === at.routeId);\n if (index < 0) continue;\n const route = routes[index];\n const part = geo.slice(route.points, at.from, at.to, alongOf(route.points));\n if (part.length < 2) continue;\n const colour = m.colour ?? (m.highlighted ? \"var(--success)\" : m.selected ? \"var(--foreground)\" : (route.colour ?? PALETTE[index % PALETTE.length]));\n L.polyline(part.map(tuple), { color: resolveColour(el, colour), weight: (route.weight ?? 4) + (m.selected ? 5 : 3), opacity: m.selected ? 1 : 0.8, lineCap: \"round\", interactive: false }).addTo(group);\n }\n for (const p of placed) if (p.fanned) L.polyline([tuple(p.at), tuple(p.shown)], { color: resolveColour(el, \"var(--muted-foreground)\"), weight: 1, dashArray: \"2 3\", interactive: false }).addTo(group);\n for (const { marker } of posMarkers.current.values()) marker.bringToFront();\n return () => void group.remove();\n }, [map, markers, routes, placed, scheme]);\n\n // Choosing a place.\n React.useEffect(() => {\n if (!map || !picking) return;\n const el = map.getContainer();\n el.classList.add(\"strata-map-picking\");\n map.keyboard.disable();\n setAnnounced(\"Choose a place on the map. Arrow keys move the crosshair, Shift for bigger steps, Enter chooses, Escape cancels.\");\n let cross: L.Marker | null = null;\n const showCross = (at: L.LatLng) => {\n if (!cross) cross = L.marker(at, { interactive: false, keyboard: false, icon: L.divIcon({ className: \"strata-map-crosshair\", html: CROSS_ICON, iconSize: [32, 32], iconAnchor: [16, 16] }) }).addTo(map);\n else cross.setLatLng(at);\n };\n const choose = (ll: L.LatLng) => {\n const at: LatLng = [ll.lat, ll.lng];\n const nearest = nearestRoute(latest.current.routes, at);\n const route = nearest ? latest.current.routes.find((r) => r.id === nearest.routeId) : undefined;\n setAnnounced(`Picked ${at[0].toFixed(5)}, ${at[1].toFixed(5)}.${nearest && route ? ` Nearest: ${route.label}, ${format.distance(nearest.alongM, latest.current.units)} along, ${format.distance(nearest.distanceM, latest.current.units)} from the route.` : \"\"}`);\n latest.current.onPick?.(at, { nearest });\n };\n const onClick = (e: L.LeafletMouseEvent) => {\n cross?.remove();\n cross = null;\n choose(e.latlng);\n };\n const onKey = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") {\n e.preventDefault();\n e.stopPropagation();\n latest.current.onPickCancel?.();\n return;\n }\n if (e.key === \"Enter\") {\n e.preventDefault();\n e.stopPropagation();\n choose(cross ? cross.getLatLng() : map.getCenter());\n return;\n }\n const step = e.shiftKey ? 50 : 10;\n const d = ({ ArrowLeft: [-step, 0], ArrowRight: [step, 0], ArrowUp: [0, -step], ArrowDown: [0, step] } as Record<string, [number, number]>)[e.key];\n if (!d) return;\n e.preventDefault();\n e.stopPropagation();\n const from = map.latLngToContainerPoint(cross ? cross.getLatLng() : map.getCenter());\n let to = from.add(d);\n const size = map.getSize();\n // Past the edge, the map moves and the crosshair stays at the edge.\n const inside = L.point(Math.min(Math.max(to.x, 16), size.x - 16), Math.min(Math.max(to.y, 16), size.y - 16));\n if (!inside.equals(to)) {\n map.panBy(to.subtract(inside), { animate: false });\n to = inside;\n }\n showCross(map.containerPointToLatLng(to));\n };\n map.on(\"click\", onClick);\n el.addEventListener(\"keydown\", onKey);\n return () => {\n map.off(\"click\", onClick);\n el.removeEventListener(\"keydown\", onKey);\n cross?.remove();\n el.classList.remove(\"strata-map-picking\");\n map.keyboard.enable();\n };\n }, [map, picking]);\n\n return (\n <div ref={root} data-dark-treatment={treated ? \"\" : undefined} className={cn(\"strata-map relative isolate aspect-video min-h-64 overflow-hidden rounded-surface border border-border\", className)}>\n <div ref={host} className=\"size-full\" />\n <p id={summaryId} className=\"sr-only\">\n {text}\n </p>\n <p role=\"status\" aria-live=\"polite\" className=\"sr-only\">\n {announced}\n </p>\n {map && placed.length > 0 && <MarkerLayer map={map} placed={placed} onSelect={onMarkerSelect} card={renderMarkerCard} />}\n {topEnd && <div className=\"absolute top-2 right-2 z-1000\">{topEnd}</div>}\n {picking && pickBanner && <div className=\"absolute top-2 left-1/2 z-1000 max-w-[60%] -translate-x-1/2\">{pickBanner}</div>}\n {(stops.length > 0 || bottomStart || (markers?.length && markerKey !== false)) && (\n <div className=\"absolute bottom-6 left-2 z-1000 grid max-w-[60%] gap-2\">\n {stops.length > 0 && <ColourKey stops={stops} label={colourScaleLabel} formatValue={formatValue} />}\n {markers && markers.length > 0 && markerKey !== false && <MarkerKey markers={markers} words={markerKey} />}\n {bottomStart}\n </div>\n )}\n </div>\n );\n}\n\n/** The key to a colour scale: its name, then each step with where it starts, so colour is never the only cue. */\nfunction ColourKey({ stops, label, formatValue }: { stops: readonly { at: number; colour: string }[]; label?: string; formatValue: (v: number) => string }) {\n return (\n <div className=\"rounded-control border border-border bg-background px-2 py-1.5 type-caption text-foreground\">\n {label && <p className=\"font-medium\">{label}</p>}\n <ul className=\"grid gap-0.5\">\n {stops.map((s) => (\n <li key={s.at} className=\"flex items-center gap-2 tabular-nums\">\n <svg width=\"20\" height=\"4\" aria-hidden>\n <line x1=\"0\" x2=\"20\" y1=\"2\" y2=\"2\" stroke={s.colour} strokeWidth={4} strokeLinecap=\"round\" />\n </svg>\n <span>{`From ${formatValue(s.at)}`}</span>\n </li>\n ))}\n </ul>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;AASA,IAAM,SAAS;;;;;;;;;;;;;;;;;;;AAoBf,IAAI,YAAY;;AAGhB,SAAgB,mBAAmB;CACjC,IAAI,aAAa,OAAO,aAAa,aAAa;CAClD,YAAY;CACZ,MAAM,KAAK,SAAS,cAAc,OAAO;CACzC,GAAG,aAAa,mBAAmB,EAAE;CACrC,GAAG,cAAc,aAAa;CAC9B,SAAS,KAAK,YAAY,EAAE;AAC9B;;;ACrBA,SAAgB,OAAO,OAA4B,MAAM,IAAiB;CACxE,MAAM,SAAS,MAAM,KAAK,GAAG,MAAM,CAAC;CACpC,MAAM,QAAQ,MAAuB,OAAO,OAAO,IAAI,IAAK,OAAO,KAAK,KAAK,OAAO,EAAE;CAEtF,MAAM,wBAAQ,IAAI,IAAsB;CACxC,MAAM,OAAO,IAAY,OAAe,GAAG,GAAG,GAAG;CACjD,MAAM,SAAS,GAAG,MAAM;EACtB,MAAM,CAAC,IAAI,MAAM,CAAC,KAAK,MAAM,EAAE,IAAI,GAAG,GAAG,KAAK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AM,IAAG;MAAI,IAAG;MAAK,IAAG;MAAI,IAAG;MAAI,QAAQ,EAAE;MAAQ,aAAa;MAAG,eAAc;KAAS,CAAA;IACzF,CAAA,GACL,oBAAC,QAAD,EAAA,UAAO,QAAQ,YAAY,EAAE,EAAE,IAAU,CAAA,CACvC;GALK,GAAA,EAAE,EAKP,CACL;EACC,CAAA,CACD;;AAET"}
1
+ {"version":3,"file":"map.js","names":["Tooltip","AriaButton","_Fragment"],"sources":["../src/map/map-styles.ts","../src/map/fan.ts","../src/map/markers.tsx","../src/map/route-map.tsx"],"sourcesContent":["import leafletCss from \"leaflet/dist/leaflet.css?inline\";\n\n// Leaflet draws with its own stylesheet (panes, tiles, controls positioned by class), which an app\n// would otherwise have to import beside strata-react's. That is an install step a component must\n// not need (CLAUDE.md, \"Imports decide the peers\"), so the map puts it in the page itself, once,\n// followed by the few rules that make Leaflet's own parts (zoom buttons, attribution, tooltips)\n// read as the app: its roles, its control height, its radius. The dark treatment is here too, in\n// one place: a map without dark tiles is turned to the dark scheme with a filter, which is a\n// fallback, not a design (an app with a dark tile set passes it as `tiles.dark`).\nconst strata = `\n.strata-map .leaflet-container { background: var(--surface-sunken); color: var(--foreground); font: inherit; }\n.strata-map .leaflet-container:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }\n.strata-map .leaflet-bar { border: 1px solid var(--border); border-radius: var(--radius-control, 4px); box-shadow: none; overflow: hidden; }\n.strata-map .leaflet-bar a { background: var(--background); color: var(--foreground); border-bottom: 1px solid var(--border); width: var(--control-h, 2.5rem); height: var(--control-h, 2.5rem); line-height: var(--control-h, 2.5rem); }\n.strata-map .leaflet-control-zoom-in, .strata-map .leaflet-control-zoom-out { font: inherit; font-size: 1.25rem; font-weight: 600; }\n.strata-map .leaflet-bar a:last-child { border-bottom: 0; }\n.strata-map .leaflet-bar a:hover, .strata-map .leaflet-bar a:focus-visible { background: var(--muted); }\n.strata-map .leaflet-bar a.leaflet-disabled { color: var(--muted-foreground); background: var(--background); cursor: not-allowed; }\n.strata-map .leaflet-control-attribution { background: color-mix(in oklab, var(--background) 85%, transparent); color: var(--muted-foreground); font-size: 0.75rem; }\n.strata-map .leaflet-control-attribution a { color: inherit; text-decoration: underline; }\n.strata-map .leaflet-tooltip { background: var(--background); color: var(--foreground); border: 1px solid var(--border); border-radius: var(--radius-control, 4px); box-shadow: none; font: inherit; font-size: 0.8125rem; padding: 0.125rem 0.375rem; }\n.strata-map .leaflet-tooltip::before { display: none; }\n.strata-map[data-dark-treatment] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9); }\n.strata-map .strata-map-arrow { background: none; border: 0; }\n.strata-map .strata-map-marker, .strata-map .strata-map-crosshair { background: none; border: 0; display: grid; place-items: center; }\n.strata-map .strata-map-reset { display: grid; place-items: center; }\n.strata-map .strata-map-picking, .strata-map .strata-map-picking .leaflet-interactive { cursor: crosshair; }\n`;\n\nlet installed = false;\n\n/** Puts Leaflet's stylesheet and the token overrides in the document head, once. */\nexport function installMapStyles() {\n if (installed || typeof document === \"undefined\") return;\n installed = true;\n const el = document.createElement(\"style\");\n el.setAttribute(\"data-strata-map\", \"\");\n el.textContent = leafletCss + strata;\n document.head.appendChild(el);\n}\n","// Markers that would sit on top of each other are moved apart in a small fan (strata-react issue #181).\n// Pure maths on pixel positions, no map and no DOM, so the rule can be tested and so a frame is the\n// same everywhere. The positions are in the map's *world* pixels at the current zoom (not the screen's),\n// so panning never changes the result, only zooming does, and zooming in is what settles the fan.\n//\n// Rules: markers within `gap` pixels of each other, directly or through a chain of neighbours\n// (single linkage), form one group. A group of two to six goes on one circle just wide enough that\n// neighbours are `gap` apart; a larger group fills rings of radius gap, 2 gap, 3 gap… each holding as\n// many as fit, so forty markers on one spot make a tidy rosette, not one huge circle. The first marker\n// of a group (input order) goes straight up and the rest follow clockwise: the same input always gives the\n// same output. A lone marker does not move.\n\n/** A marker's true place in world pixels. */\nexport type FanInput = { id: string; x: number; y: number };\n/** Where it is drawn; `fanned` is true when that is not its true place (draw a leader line back). */\nexport type FanOutput = { id: string; x: number; y: number; fanned: boolean };\n\n/** Move apart markers closer than `gap` pixels. Output is in input order. */\nexport function fanOut(items: readonly FanInput[], gap = 26): FanOutput[] {\n const parent = items.map((_, i) => i);\n const find = (i: number): number => (parent[i] === i ? i : (parent[i] = find(parent[i])));\n // A grid of `gap`-sized cells, so each marker is compared with its neighbours and not with all 500.\n const cells = new Map<string, number[]>();\n const key = (cx: number, cy: number) => `${cx},${cy}`;\n items.forEach((p, i) => {\n const [cx, cy] = [Math.floor(p.x / gap), Math.floor(p.y / gap)];\n for (let dx = -1; dx <= 1; dx++)\n for (let dy = -1; dy <= 1; dy++)\n for (const j of cells.get(key(cx + dx, cy + dy)) ?? []) {\n if (Math.hypot(items[j].x - p.x, items[j].y - p.y) < gap) parent[find(i)] = find(j);\n }\n const own = cells.get(key(cx, cy));\n if (own) own.push(i);\n else cells.set(key(cx, cy), [i]);\n });\n const groups = new Map<number, number[]>();\n items.forEach((_, i) => {\n const r = find(i);\n const g = groups.get(r);\n if (g) g.push(i);\n else groups.set(r, [i]);\n });\n const out: FanOutput[] = items.map((p) => ({ id: p.id, x: p.x, y: p.y, fanned: false }));\n for (const members of groups.values()) {\n const n = members.length;\n if (n < 2) continue;\n const cx = members.reduce((s, i) => s + items[i].x, 0) / n;\n const cy = members.reduce((s, i) => s + items[i].y, 0) / n;\n const place = (i: number, radius: number, angle: number) => {\n out[i] = { id: items[i].id, x: cx + radius * Math.sin(angle), y: cy - radius * Math.cos(angle), fanned: true };\n };\n if (n <= 6) {\n const radius = gap / (2 * Math.sin(Math.PI / n));\n members.forEach((i, k) => place(i, radius, (2 * Math.PI * k) / n));\n } else {\n let k = 0;\n for (let ring = 1; k < n; ring++) {\n const radius = ring * gap;\n const fit = Math.max(1, Math.floor((2 * Math.PI * radius) / gap));\n const here = Math.min(fit, n - k);\n for (let m = 0; m < here; m++) place(members[k + m], radius, (2 * Math.PI * m) / here);\n k += here;\n }\n }\n }\n return out;\n}\n","import * as React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport L from \"leaflet\";\nimport { Button as AriaButton } from \"react-aria-components\";\nimport { cn } from \"../lib/utils\";\nimport { geo, type LatLng } from \"../lib/geo\";\nimport { Tooltip } from \"../components/tooltip\";\nimport { fanOut } from \"./fan\";\n\n// Item markers on a map (strata-react issue #181, from strata-360's race map: a marker for every clip at\n// the middle of its stretch of track, the stretch drawn heavier, overlapping markers fanned apart, a card\n// on hover, a click that opens the clip). What is decided here and why:\n//\n// - **Each marker is a real control.** A React Aria `Button` portalled into the DOM node of a Leaflet\n// marker (a `divIcon` whose `html` is that node), so Leaflet keeps it where the map puts it while React\n// owns what it is: named by its label, pressed with a click, Enter or Space, a `Tooltip` on hover and\n// focus. Not Leaflet's popup, which is not a Strata surface and not reachable the same way.\n// - **One tab stop for all of them**, arrows (and Home and End) between them, in the order the app gave:\n// forty markers must not be forty tab stops. The map's own keyboard stays: the markers are a roving\n// group inside it, and the app's list of items beside the map is still the full keyboard path.\n// - **Only what is near the screen is drawn.** Each time the view settles the markers within the view\n// (plus a margin, so a fan is not cut at the edge) are laid out and the rest are not in the DOM, so 500\n// markers cost what the visible ones cost.\n// - **The fan is a pure function of the zoom** (`fanOut`, fan.ts): in world pixels, so panning never moves\n// it and zooming in settles it; a leader line joins each fanned marker to its true place.\n// - **States are shapes as well as colour**: a plain circle, a ringed larger one for selected, a diamond for\n// highlighted by the app (the newest draft's choice). The key names each one that is on the map.\n//\n// Checked: React Aria has no map part; `Button` and the Strata `Tooltip` are used as they are.\n\n/** The words the key uses for each marker state. */\nexport type MarkerKeyWords = { marker?: string; selected?: string; highlighted?: string };\n\n/** An item on the map: a place, or a stretch of a route (drawn heavier, the marker at its middle). */\nexport type MapMarker = {\n /** Stable between renders. */\n id: string;\n /** A place, or a stretch of a route between two distances along it (metres). */\n at: LatLng | { routeId: string; from: number; to: number };\n /** Its name: the button's accessible name and the card's default words. */\n label: string;\n selected?: boolean;\n /** Marked by the app (a diamond): the newest draft's choice, a flagged item. */\n highlighted?: boolean;\n /** Any CSS colour, normally a role; overrides the state's. */\n colour?: string;\n};\n\n/** A marker with where it really is and where it is drawn. */\nexport type Placed = { marker: MapMarker; at: LatLng; shown: LatLng; fanned: boolean };\n\nconst alongCache = new WeakMap<readonly LatLng[], number[]>();\n/** The running distance at each point of a route, kept per route array so a long route is walked once. */\nexport function alongOf(points: readonly LatLng[]): number[] {\n let a = alongCache.get(points);\n if (!a) {\n a = geo.cumulative(points);\n alongCache.set(points, a);\n }\n return a;\n}\n\n/** Where a marker really is: its place, or the middle of its stretch. Null when its route is not on the map. */\nexport function markerPlace(m: MapMarker, routes: readonly { id: string; points: readonly LatLng[] }[]): LatLng | null {\n if (Array.isArray(m.at)) return m.at as LatLng;\n const at = m.at as { routeId: string; from: number; to: number };\n const route = routes.find((r) => r.id === at.routeId);\n return route ? geo.pointAlong(route.points, (at.from + at.to) / 2, alongOf(route.points)) : null;\n}\n\n/** The markers near the view, with the overlapping ones fanned apart for this zoom. */\nexport function placeMarkers(map: L.Map, markers: readonly MapMarker[], routes: readonly { id: string; points: readonly LatLng[] }[]): Placed[] {\n const near = map.getBounds().pad(0.25);\n const zoom = map.getZoom();\n const here: { marker: MapMarker; at: LatLng }[] = [];\n for (const marker of markers) {\n const at = markerPlace(marker, routes);\n if (at && near.contains([at[0], at[1]])) here.push({ marker, at });\n }\n const fanned = fanOut(here.map((h) => ({ id: h.marker.id, ...map.project([h.at[0], h.at[1]], zoom) })));\n return here.map((h, i) => {\n const f = fanned[i];\n const shown = f.fanned ? map.unproject([f.x, f.y], zoom) : null;\n return { marker: h.marker, at: h.at, shown: shown ? ([shown.lat, shown.lng] as LatLng) : h.at, fanned: f.fanned };\n });\n}\n\nconst state = (m: MapMarker) => (m.highlighted ? \"highlighted\" : m.selected ? \"selected\" : \"marker\");\n\ntype PinProps = {\n map: L.Map;\n placed: Placed;\n active: boolean;\n onActivate: (id: string) => void;\n onMove: (id: string, to: \"next\" | \"previous\" | \"first\" | \"last\") => void;\n register: (id: string, el: HTMLElement | null) => void;\n onSelect?: (id: string) => void;\n card?: (m: MapMarker) => React.ReactNode;\n};\n\n/** One marker: a Leaflet marker holding a node that React fills with a labelled button. */\nfunction Pin({ map, placed, active, onActivate, onMove, register, onSelect, card }: PinProps) {\n const { marker, shown } = placed;\n const host = React.useMemo(() => {\n const el = document.createElement(\"div\");\n el.className = \"strata-map-pin\";\n return el;\n }, []);\n const layer = React.useRef<L.Marker | null>(null);\n React.useEffect(() => {\n const m = L.marker([shown[0], shown[1]], { icon: L.divIcon({ className: \"strata-map-marker\", html: host, iconSize: [28, 28], iconAnchor: [14, 14] }), interactive: false, keyboard: false }).addTo(map);\n layer.current = m;\n return () => {\n layer.current = null;\n m.remove();\n };\n // Made once per pin; where it is and how high it sits are updated below.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [map, host]);\n React.useEffect(() => {\n layer.current?.setLatLng([shown[0], shown[1]]);\n }, [shown]);\n React.useEffect(() => {\n layer.current?.setZIndexOffset(marker.selected ? 1000 : marker.highlighted ? 500 : 0);\n }, [marker.selected, marker.highlighted]);\n const kind = state(marker);\n const swatch = marker.colour ?? (kind === \"highlighted\" ? \"var(--success)\" : kind === \"selected\" ? \"var(--foreground)\" : \"var(--primary)\");\n return createPortal(\n <Tooltip label={card ? card(marker) : marker.label} side=\"top\">\n <AriaButton\n ref={(el) => register(marker.id, el)}\n aria-label={marker.label}\n aria-pressed={marker.selected ?? false}\n excludeFromTabOrder={!active}\n onFocus={() => onActivate(marker.id)}\n onPress={() => onSelect?.(marker.id)}\n onKeyDown={(e) => {\n const to = e.key === \"ArrowRight\" || e.key === \"ArrowDown\" ? \"next\" : e.key === \"ArrowLeft\" || e.key === \"ArrowUp\" ? \"previous\" : e.key === \"Home\" ? \"first\" : e.key === \"End\" ? \"last\" : null;\n if (!to) return;\n e.preventDefault();\n e.stopPropagation();\n onMove(marker.id, to);\n }}\n className=\"pointer-events-auto grid size-7 cursor-pointer place-items-center rounded-pill outline-offset-1 focus-visible:outline-2 focus-visible:outline-ring\"\n >\n <Shape kind={kind} colour={swatch} />\n </AriaButton>\n </Tooltip>,\n host,\n );\n}\n\n/** The drawn shape of a marker state: a circle, a ringed larger circle, a diamond. Shapes carry the meaning as colour does. */\nfunction Shape({ kind, colour }: { kind: \"marker\" | \"selected\" | \"highlighted\"; colour: string }) {\n return (\n <span\n aria-hidden\n className={cn(\"block border-2 border-background\", kind === \"highlighted\" ? \"size-3.5 rotate-45 rounded-sm\" : \"rounded-pill\", kind === \"selected\" ? \"size-4 ring-2 ring-foreground\" : kind === \"marker\" ? \"size-3.5\" : \"\")}\n style={{ background: colour }}\n />\n );\n}\n\ntype LayerProps = {\n map: L.Map;\n placed: readonly Placed[];\n onSelect?: (id: string) => void;\n card?: (m: MapMarker) => React.ReactNode;\n};\n\n/** The pins for the markers near the view, as one roving group: one tab stop, arrows between them. */\nexport function MarkerLayer({ map, placed, onSelect, card }: LayerProps) {\n const [activeId, setActiveId] = React.useState<string | null>(null);\n const els = React.useRef(new Map<string, HTMLElement>());\n const ids = placed.map((p) => p.marker.id);\n const active = activeId !== null && ids.includes(activeId) ? activeId : (ids[0] ?? null);\n const register = React.useCallback((id: string, el: HTMLElement | null) => {\n if (el) els.current.set(id, el);\n else els.current.delete(id);\n }, []);\n const move = (id: string, to: \"next\" | \"previous\" | \"first\" | \"last\") => {\n const i = ids.indexOf(id);\n const next = to === \"first\" ? 0 : to === \"last\" ? ids.length - 1 : Math.min(ids.length - 1, Math.max(0, i + (to === \"next\" ? 1 : -1)));\n setActiveId(ids[next]);\n els.current.get(ids[next])?.focus();\n };\n return (\n <>\n {placed.map((p) => (\n <Pin key={p.marker.id} map={map} placed={p} active={p.marker.id === active} onActivate={setActiveId} onMove={move} register={register} onSelect={onSelect} card={card} />\n ))}\n </>\n );\n}\n\n/** The key to the marker states that are on the map, each with its shape and its words. */\nexport function MarkerKey({ markers, words }: { markers: readonly MapMarker[]; words?: MarkerKeyWords }) {\n const kinds = ([\"marker\", \"selected\", \"highlighted\"] as const).filter((k) => markers.some((m) => state(m) === k));\n const text = { marker: words?.marker ?? \"Item\", selected: words?.selected ?? \"Selected\", highlighted: words?.highlighted ?? \"Highlighted\" };\n if (!kinds.length) return null;\n return (\n <div className=\"rounded-control border border-border bg-background px-2 py-1.5 type-caption text-foreground\">\n <ul className=\"grid gap-0.5\">\n {kinds.map((k) => (\n <li key={k} className=\"flex items-center gap-2\">\n <span className=\"grid size-4 place-items-center\">\n <Shape kind={k} colour={k === \"highlighted\" ? \"var(--success)\" : k === \"selected\" ? \"var(--foreground)\" : \"var(--primary)\"} />\n </span>\n {text[k]}\n </li>\n ))}\n </ul>\n </div>\n );\n}\n","import * as React from \"react\";\nimport L from \"leaflet\";\nimport { useColorScheme } from \"../components/theme\";\nimport { cn } from \"../lib/utils\";\nimport { format } from \"../lib/format\";\nimport { geo, type LatLng } from \"../lib/geo\";\nimport { installMapStyles } from \"./map-styles\";\nimport { useSharedCursor } from \"../components/cursor\";\nimport { MarkerKey, MarkerLayer, alongOf, placeMarkers, type MapMarker, type MarkerKeyWords } from \"./markers\";\n\n// A themed map of routes with a position that moves along them (strata-react issue #80, from\n// strata-vid's MapPanel and jonathanburnhams.com's activity maps). It is behind its own entry,\n// `strata-react/map`, because Leaflet is heavy and an app that draws no maps should not install it:\n// Leaflet is an optional peer and nothing in the main entry imports it.\n//\n// Leaflet, without react-leaflet (Jonathan's choice, 2026-11-12). react-leaflet binds every layer to\n// a React element, so a position that moves sixty times a second re-renders the route elements\n// beside it; here the map is made once, the routes are one effect that runs only when the routes\n// change, and the position is another that calls `setLatLng` on one marker. A position update\n// touches nothing else: no route is redrawn, none is recreated.\n//\n// What the app supplies, and what the component decides:\n// - Tiles are the app's (`tiles.light`, `tiles.dark`, each with the attribution its provider\n// requires, shown on the map). A dark scheme uses `tiles.dark` when there is one, else the light\n// tiles under a filter (see map-styles.ts); the choice follows the colour scheme.\n// - Colours are roles. A route's colour is any CSS colour (`var(--chart-2)`, `var(--info)`), resolved\n// against the map's own element so SVG strokes, which Leaflet writes as attributes, get a real\n// colour that follows the scheme. Routes default to the chart palette in order.\n// - Colour by value (`values` on a route plus `colourScale`) follows LineChart's rules (§3.8): the\n// colour is a fact of the subject, steps are the app's, and a key names them (`colourScaleLabel`\n// and the step thresholds through `formatValue`) so colour is never the only cue. Runs of one\n// step are drawn as one line, so a long route is a few polylines, not thousands.\n// - One route is the common case: it gets direction chevrons and start and finish marks (a loop is\n// one mark) by default; with several routes those are off unless a route asks.\n// - Fit-to-content happens on first show and when the set of routes changes, not when a route's\n// points are replaced by the same ids, so a person who has zoomed is not thrown back.\n// - Overlay slots, `topEnd` and `bottomStart`, sit where Leaflet puts nothing (it uses the top\n// start for zoom and the bottom end for attribution), so an app's own control or figure never\n// covers a required notice.\n//\n// Keyboard and screen readers. Leaflet's container is a focus stop: arrows pan, + and − zoom. It is\n// named by `label` and described by a text alternative that says what is drawn (each route, its\n// length, whether it is a loop, and how far along the position is), written from the data or given\n// as `summary`. Hovering a route or a mark is a bonus; its facts are in that text. Choosing a route\n// is `onSelect`, and a screen that lets a person choose one lists its routes beside the map (a\n// pointer click on a line has no keyboard equivalent inside Leaflet's SVG, so the list is the path).\n//\n// Map as picture content (issue #161, from strata-vid, where a route inset is composed over footage and\n// must look the same on every frame as in an export drawn on a canvas). Three additions, none of which\n// changes a page map: `zoom` sets the zoom from outside (any number, so an animation is a prop that\n// changes every frame; unset keeps fit-to-routes), `follow=\"centre\"` holds the view on a position at that\n// zoom, and `positions` draws several moving positions, each tied to a route and drawn in its colour.\n// Centred follow pans to a whole-pixel view worked out from the position and zoom alone (`centre`), with\n// no animation: Leaflet's own centred pan truncates each step, so where the view ended up would depend\n// on the path it took; this depends only on the position and zoom, which is what makes frame N the same\n// picture however it was reached. A `reset` would give the same view but empties the tile layer on every\n// call, which flickers at one update per frame.\n// Fractional zoom needs `zoomSnap: 0`, which is set only while `zoom` is controlled, so a page map still\n// snaps to half steps. Each marker is one `L.CircleMarker` kept by id and moved with `setLatLng`.\n//\n// The map as an instrument, not only a picture (strata-react issues #181, #182, #184):\n// - `markers`: items on the route as controls with cards, fanned apart (markers.tsx).\n// - `onViewChange`: the visible bounds and zoom, once when movement settles (debounced `settle` ms), and\n// not for a move the app made through its own props (`zoom`, `view`, `follow`, the first fit), which it\n// already knows about: every move the component makes itself runs inside `silently`, and Leaflet's events\n// are synchronous with animation off, so the flag cannot leak. `reportAppMoves` turns that off.\n// - `view` restores a saved view; the person's own moves go out through `onViewChange`. A reset control\n// in Leaflet's own control group fits the routes again (or sets the zoom, when one is controlled).\n// - `picking` + `onPick`: choose a place. Pointer: a click. Keyboard: arrows move a crosshair (Shift for\n// bigger steps), Enter chooses, Escape asks to cancel; Leaflet's own arrow handling is switched off for\n// the time, since both would move. The result is announced with the nearest route, how far along it and\n// how far off (`geo.snap`). Route lines stop taking clicks while picking, or a pick near the route would\n// select the route instead. A click when not picking does nothing new.\n// - `cursor`: joins a `CursorScope` (cursor.tsx). The scope's unit here is metres along one route; a\n// pointer near the route (within 24 px of it) writes the distance of the nearest point on it, and\n// another member's distance is drawn as a ring on the route. Never drawn back at its own writer.\n//\n// No animation: zoom, fade and inertia are off, because a map is panned all the time and a tile\n// fade makes a screenshot depend on timing (character by frequency, and strata-visual).\n//\n// Checked: React Aria has no map or geographic part. Leaflet's own keyboard handler and focus are\n// kept as they are.\n\n/** A source of map tiles: a URL template the app's provider documents, and the attribution it requires. */\nexport type TileSource = {\n /** `https://tiles.example.com/{z}/{x}/{y}.png`; `{s}` and `{r}` work as in Leaflet. */\n url: string;\n /** What the provider requires shown (HTML allowed: \"© OpenStreetMap contributors\"). */\n attribution: string;\n subdomains?: string;\n minZoom?: number;\n maxZoom?: number;\n};\n\n/** One route on the map. */\nexport type MapRoute = {\n id: string;\n /** Its name, in the text alternative and on hover (\"Wednesday run\"). */\n label: string;\n points: readonly LatLng[];\n /** Any CSS colour, normally a role (`var(--chart-2)`). Default: the chart palette in order. */\n colour?: string;\n /** Line width in pixels. Default 4. */\n weight?: number;\n /** One value per point, coloured by `colourScale` (speed, elevation, heart rate). */\n values?: readonly number[];\n /** Direction chevrons along the line: true for five, or a count. Default on for a single route. */\n arrows?: boolean | number;\n /** Start and finish marks. Default on for a single route. */\n ends?: boolean;\n};\n\n/** One moving position, for a map with more than one (two runners on the same loop). */\nexport type MapPosition = {\n /** Stable between renders: the marker is kept by it and moved, never recreated. */\n id: string;\n /** Where it is now; null hides it. */\n at: LatLng | null;\n /** What it is called in the text alternative (\"Runner A\"). */\n label: string;\n /** The route it travels. Its marker takes that route's colour and the text alternative says how far along it is. */\n routeId?: string;\n /** Any CSS colour, normally a role. Overrides the route's. Default: the route's colour, else the theme's primary. */\n colour?: string;\n};\n\n/** The view the map settled on. */\nexport type MapView = { bounds: [LatLng, LatLng]; zoom: number; center: LatLng };\n\n/** The route nearest a picked place. */\nexport type PickNearest = {\n routeId: string;\n /** The leg of the route (its first point's index) the place is nearest. */\n index: number;\n /** How far the place is from the route, in metres. */\n distanceM: number;\n /** How far along the route the nearest point is, in metres. */\n alongM: number;\n /** The nearest point on the route. */\n position: LatLng;\n};\n\nexport type RouteMapProps = {\n /** Names the map (\"Route of Wednesday's run\"). */\n label: string;\n /** Keep this array stable between renders (state or `useMemo`): the routes are redrawn when it changes, which a moving position must not cause. */\n routes: readonly MapRoute[];\n tiles: { light: TileSource; dark?: TileSource };\n /** Where the moving thing is now. Moved without redrawing any route; null for none. */\n position?: LatLng | null;\n /** What the position is called in the text alternative. Default \"Current position\". */\n positionLabel?: string;\n /** More moving positions, each in its route's colour and named in the text alternative. Moved without redrawing any route; `position` may be used beside them. */\n positions?: readonly MapPosition[];\n /** Which position `follow` tracks: a `positions` id. Default `position`, else the first of `positions` that is shown. */\n followId?: string;\n /** `true` pans only when the position leaves the inner 80% of the view; `\"centre\"` keeps it exactly in the centre on every update, with no animation (a frame is deterministic), at `zoom` when that is set, else the zoom the map has. */\n follow?: boolean | \"centre\";\n /** The zoom level, any number (12, 14.5): it may change every frame without redrawing routes. Unset, the map fits its routes and the person zooms. */\n zoom?: number;\n /** Items on the map: places, or stretches of a route. Keep the array stable between renders. */\n markers?: readonly MapMarker[];\n /** A marker was pressed (click, Enter or Space). */\n onMarkerSelect?: (id: string) => void;\n /** The words shown beside a marker on hover and focus (as `Tooltip`; not interactive). Default its label. */\n renderMarkerCard?: (marker: MapMarker) => React.ReactNode;\n /** The words of the marker key; `false` leaves the key out. */\n markerKey?: MarkerKeyWords | false;\n /** Join the nearest `CursorScope`: a pointer near a route puts its distance along it in every member, and another member's distance shows as a ring on the route. `{ routeId }` picks the route (default the first). */\n cursor?: boolean | { routeId?: string };\n /** The view settled after the person moved or zoomed it: bounds, zoom and centre. Not called for moves the app caused through props. */\n onViewChange?: (view: MapView) => void;\n /** Milliseconds the view must be still before `onViewChange`. Default 250. */\n settle?: number;\n /** Also call `onViewChange` for moves the app caused through props (the first fit, `zoom`, `view`, `follow`). */\n reportAppMoves?: boolean;\n /** A view to show: centre and zoom, as a saved view or the app's own. The person can still move away from it; set it again to go back. Wins over fitting the routes. */\n view?: { center: LatLng; zoom: number };\n /** Choose a place on the map. While set, a click or Enter picks and route lines do not take clicks. */\n picking?: boolean;\n /** A place was chosen, with the nearest route to it when there is one. */\n onPick?: (at: LatLng, info: { nearest: PickNearest | null }) => void;\n /** Escape was pressed while picking: the app turns `picking` off. */\n onPickCancel?: () => void;\n /** The banner for pick mode (\"Click the map to set the point; Escape cancels\"), shown top centre. */\n pickBanner?: React.ReactNode;\n /** The route drawn heavier, with the others lighter. */\n selectedId?: string | null;\n /** A route line was pressed. Give the app's own list of routes the same action for the keyboard. */\n onSelect?: (id: string) => void;\n /** Step colours for routes that have `values`: a step starts at `at` and runs to the next. */\n colourScale?: readonly { at: number; colour: string }[];\n /** What the colours mean, written in the key (\"Speed\"). */\n colourScaleLabel?: string;\n /** Writes a value in the key and the text alternative (\"12 km/h\"). Default the plain number. */\n formatValue?: (value: number) => string;\n /** Replaces the generated text alternative. */\n summary?: string;\n /** Units for lengths in the generated text. Default metric. */\n units?: \"metric\" | \"imperial\";\n /** Wheel zoom. Off by default so the page still scrolls past the map. */\n scrollZoom?: boolean;\n /** An app control or figure in the top end corner (Leaflet leaves it free). */\n topEnd?: React.ReactNode;\n /** An app legend or figure in the bottom start corner, below the colour key when there is one. */\n bottomStart?: React.ReactNode;\n /** Layout only. The map is 16:9 and at least 16rem tall unless a height is given. */\n className?: string;\n};\n\n/** The smallest and largest value, without spreading the array (a long recording passes the engine's argument limit). */\nfunction extent(values: readonly number[]): [number, number] {\n let lo = Infinity;\n let hi = -Infinity;\n for (const v of values) {\n if (v < lo) lo = v;\n if (v > hi) hi = v;\n }\n return [lo, hi];\n}\n\nconst tuple = (p: LatLng): L.LatLngTuple => [p[0], p[1]];\nconst plain = (v: number) => String(v);\n\n/** `value`, sampled once a second (a throttle, not a debounce: a value that changes every frame still comes through): for text a screen reader may read, which must not change sixty times a second. */\nfunction useSlow<T>(value: T, ms = 1000): T {\n const [slow, setSlow] = React.useState(value);\n const latest = React.useRef(value);\n latest.current = value;\n React.useEffect(() => {\n const id = window.setInterval(() => setSlow(latest.current), ms);\n return () => window.clearInterval(id);\n }, [ms]);\n return slow;\n}\n\n/** How many moves of the map the component itself is making right now (see `onViewChange`). */\nconst quiet = new WeakMap<L.Map, number>();\n/** Run a move the component makes itself, so `onViewChange` does not report it. Leaflet's events are synchronous with animation off. */\nfunction silently<T>(map: L.Map, fn: () => T): T {\n quiet.set(map, (quiet.get(map) ?? 0) + 1);\n try {\n return fn();\n } finally {\n quiet.set(map, (quiet.get(map) ?? 1) - 1);\n }\n}\n\n/** The route nearest a place, by distance from it to the route (not to a vertex). */\nfunction nearestRoute(routes: readonly MapRoute[], at: LatLng): PickNearest | null {\n let best: PickNearest | null = null;\n for (const r of routes) {\n const s = geo.snap(r.points, at, alongOf(r.points));\n if (s && (!best || s.offset < best.distanceM)) best = { routeId: r.id, index: s.index, distanceM: s.offset, alongM: s.metres, position: s.position };\n }\n return best;\n}\n\nconst RESET_ICON = '<svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M2 6V2h4M10 2h4v4M14 10v4h-4M6 14H2v-4\"/></svg>';\nconst CROSS_ICON = '<svg width=\"32\" height=\"32\" viewBox=\"0 0 32 32\" aria-hidden=\"true\" fill=\"none\" stroke-linecap=\"round\"><path d=\"M16 4v24M4 16h24\" stroke=\"var(--background)\" stroke-width=\"5\"/><path d=\"M16 4v24M4 16h24\" stroke=\"var(--foreground)\" stroke-width=\"2\"/></svg>';\n\n/** Leaflet's control group gets a reset: fit the routes again. A link with a button role, as Leaflet's own zoom buttons are. */\nfunction resetControl(onReset: () => void): L.Control {\n const control = new L.Control({ position: \"topleft\" });\n control.onAdd = () => {\n const bar = L.DomUtil.create(\"div\", \"leaflet-bar leaflet-control\");\n const a = L.DomUtil.create(\"a\", \"strata-map-reset\", bar);\n a.href = \"#\";\n a.setAttribute(\"role\", \"button\");\n a.setAttribute(\"aria-label\", \"Reset view\");\n a.title = \"Reset view\";\n a.innerHTML = RESET_ICON;\n L.DomEvent.disableClickPropagation(bar);\n L.DomEvent.on(a, \"click\", (e) => {\n L.DomEvent.preventDefault(e);\n onReset();\n });\n L.DomEvent.on(a, \"keydown\", (e) => {\n if ((e as KeyboardEvent).key === \" \") {\n L.DomEvent.preventDefault(e);\n onReset();\n }\n });\n return bar;\n };\n return control;\n}\n\n/** Put the routes in view (or, with a zoom set, centre the routes at it). */\nfunction showRoutes(map: L.Map, routes: readonly MapRoute[], zoom: number | undefined) {\n const box = geo.bounds(routes.flatMap((r) => r.points));\n if (!box) return false;\n if (zoom !== undefined) map.setView([(box[0][0] + box[1][0]) / 2, (box[0][1] + box[1][1]) / 2], zoom, { animate: false });\n else map.fitBounds([tuple(box[0]), tuple(box[1])], { padding: [24, 24], animate: false, maxZoom: 17 });\n return true;\n}\n\nconst SINGLE = \"\\u0000position\";\nconst PALETTE = [1, 2, 3, 4, 5].map((n) => `var(--chart-${n})`);\n\n/**\n * Put `target` in the exact middle of the view at zoom `z`, with no animation and without throwing the\n * loaded tiles away. A zoom change goes through `setView` (Leaflet redraws its tiles then anyway). The\n * position is then set by panning to a whole-pixel top-left worked out from the target and the zoom\n * alone, so where the view ends up does not depend on the path taken (Leaflet's own centred pan\n * truncates each step and drifts); a `reset` would be exact too but empties the tile layer on every\n * call, which flickers when the position changes every frame.\n */\nfunction centre(map: L.Map, target: LatLng, z: number) {\n silently(map, () => {\n if (map.getZoom() !== z) map.setView(tuple(target), z, { animate: false });\n const want = map.project(tuple(target), z).subtract(map.getSize().divideBy(2)).round();\n const have = map.getPixelBounds().min!.round();\n const move = want.subtract(have);\n if (move.x || move.y) map.panBy(move, { animate: false, noMoveStart: true });\n });\n}\n\n/** The colour a CSS value (a `var()`, a role) resolves to on `el`, so an SVG attribute gets a real one. Falls back to the value itself. */\nfunction resolveColour(el: HTMLElement, value: string): string {\n const probe = document.createElement(\"span\");\n probe.style.color = value;\n el.appendChild(probe);\n const resolved = getComputedStyle(probe).color;\n probe.remove();\n return resolved || value;\n}\n\n/** Indices where a run of one step ends, so a coloured route is a few polylines. */\nfunction stepRuns(points: readonly LatLng[], values: readonly number[], stepOf: (v: number) => number) {\n const runs: { from: number; to: number; step: number }[] = [];\n for (let i = 1; i < points.length; i++) {\n const step = stepOf(((values[i - 1] ?? 0) + (values[i] ?? 0)) / 2);\n const last = runs[runs.length - 1];\n if (last && last.step === step) last.to = i;\n else runs.push({ from: i - 1, to: i, step });\n }\n return runs;\n}\n\nconst arrowHtml = (bearing: number, colour: string, halo: string) =>\n `<svg width=\"26\" height=\"26\" viewBox=\"0 0 26 26\" aria-hidden=\"true\" style=\"transform: rotate(${bearing.toFixed(0)}deg)\">` +\n `<path d=\"M6 17 L13 9 L20 17\" fill=\"none\" stroke=\"${halo}\" stroke-width=\"7\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>` +\n `<path d=\"M6 17 L13 9 L20 17\" fill=\"none\" stroke=\"${colour}\" stroke-width=\"3.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>`;\n\n\n// A tile layer that always covers the whole container. Leaflet 1.9.4 picks the tiles to load from\n// `floor(centre) ± size / 2` (`GridLayer._getTiledPixelBounds`) but places the map pane at\n// `round(centre - size / 2)`, so when the two differ by a pixel the last pixel column of the map has no\n// tile under it. The centre is a whole pixel plus or minus the float noise of projecting it back from the\n// pane's position, so `floor` lands a pixel low about half the time, and whether a stray tile from an\n// earlier view happens to cover that column (`keepBuffer` keeps them) depends on the path the view took:\n// the same map at the same view could be drawn two ways. A visual shot of a centred follow differed by\n// that one column in about one run in two under load.\n// One pixel more on every side makes the tiles under the container depend on the view alone. The method\n// is Leaflet's private one; a test fails if a Leaflet update removes it.\n/** @internal Exported for its test, not part of the package's API. */\nexport function coveringTiles(url: string, options: L.TileLayerOptions): L.TileLayer {\n const Covering = L.TileLayer.extend({\n _getTiledPixelBounds(this: L.TileLayer, centre: L.LatLng): L.Bounds {\n const base = (L.GridLayer.prototype as unknown as { _getTiledPixelBounds(c: L.LatLng): L.Bounds })._getTiledPixelBounds.call(this, centre);\n return L.bounds(base.min!.subtract([1, 1]), base.max!.add([1, 1]));\n },\n });\n return new (Covering as unknown as new (u: string, o: L.TileLayerOptions) => L.TileLayer)(url, options);\n}\n\n/** A map of one or more routes with a position that moves along them, on tiles the app supplies, themed from its roles. Leaflet, behind `strata-react/map`. */\nexport function RouteMap({\n label,\n routes,\n tiles,\n position = null,\n positionLabel = \"Current position\",\n positions,\n followId,\n follow = false,\n zoom,\n markers,\n onMarkerSelect,\n renderMarkerCard,\n markerKey,\n cursor: cursorProp,\n onViewChange,\n settle = 250,\n reportAppMoves = false,\n view,\n picking = false,\n onPick,\n onPickCancel,\n pickBanner,\n selectedId = null,\n onSelect,\n colourScale,\n colourScaleLabel,\n formatValue = plain,\n summary,\n units = \"metric\",\n scrollZoom = false,\n topEnd,\n bottomStart,\n className,\n}: RouteMapProps) {\n const { scheme } = useColorScheme();\n const host = React.useRef<HTMLDivElement>(null);\n const root = React.useRef<HTMLDivElement>(null);\n const [map, setMap] = React.useState<L.Map | null>(null);\n const summaryId = React.useId();\n const latest = React.useRef({ onSelect, onViewChange, reportAppMoves, settle, picking, onPick, onPickCancel, routes, units, view, zoom });\n latest.current = { onSelect, onViewChange, reportAppMoves, settle, picking, onPick, onPickCancel, routes, units, view, zoom };\n const [announced, setAnnounced] = React.useState(\"\");\n // True once the map has a view (the first fit has happened): before that Leaflet cannot say what is near.\n const [ready, setReady] = React.useState(false);\n const selectable = Boolean(onSelect);\n // One marker per position, by id, with the style last applied so a moving marker is not restyled every frame.\n const posMarkers = React.useRef(new Map<string, { marker: L.CircleMarker; style: string }>());\n\n const darkTiles = scheme === \"dark\" ? tiles.dark : undefined;\n const source = darkTiles ?? tiles.light;\n const treated = scheme === \"dark\" && !tiles.dark;\n const stops = React.useMemo(() => (colourScale ? [...colourScale].sort((a, b) => a.at - b.at) : []), [colourScale]);\n\n // The map, made once. Its container is Leaflet's; React owns only the wrapper around it.\n React.useEffect(() => {\n installMapStyles();\n const el = host.current;\n if (!el) return;\n const m = L.map(el, { scrollWheelZoom: scrollZoom, fadeAnimation: false, zoomAnimation: false, markerZoomAnimation: false, inertia: false, attributionControl: false, zoomSnap: 0.5 });\n L.control.attribution({ prefix: '<a href=\"https://leafletjs.com\">Leaflet</a>' }).addTo(m);\n el.setAttribute(\"aria-roledescription\", \"map\");\n // Leaflet follows the window, not its container; a pane that resizes (a Workspace split) needs the same.\n const ro = new ResizeObserver(() => m.invalidateSize({ animate: false }));\n ro.observe(el);\n setMap(m);\n return () => {\n ro.disconnect();\n posMarkers.current.clear();\n m.remove();\n setMap(null);\n setReady(false);\n };\n // The wheel setting is applied below, so the map is not rebuilt for it.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n React.useEffect(() => {\n if (!map) return;\n if (scrollZoom) map.scrollWheelZoom.enable();\n else map.scrollWheelZoom.disable();\n }, [map, scrollZoom]);\n\n // A zoom set from outside is any number; Leaflet snaps to `zoomSnap`, so it is 0 while zoom is controlled.\n const zoomed = zoom !== undefined;\n React.useEffect(() => {\n if (map) map.options.zoomSnap = zoomed ? 0 : 0.5;\n }, [map, zoomed]);\n\n // Every position on the map, the single `position` first: what is spoken, drawn and followed.\n const all = React.useMemo<MapPosition[]>(() => [...(position ? [{ id: SINGLE, at: position, label: positionLabel }] : []), ...(positions ?? [])], [position, positionLabel, positions]);\n\n // The text alternative: written from the data unless the app gives one. The position is in it, but\n // it is not a live region: a position that moves many times a second must not be announced.\n const spoken = useSlow(all);\n const text = React.useMemo(() => {\n if (summary) return summary;\n if (!routes.length) return \"No routes to show.\";\n const parts = routes.map((r) => {\n const along = geo.cumulative(r.points);\n const total = along[along.length - 1] ?? 0;\n const ends = geo.ends(r.points);\n const shape = ends?.loop ? \", a loop\" : \"\";\n let here = \"\";\n // A position tied to another route is not on this one; one tied to no route is described along each.\n for (const p of spoken) {\n if (!p.at || !r.points.length || (p.routeId !== undefined && p.routeId !== r.id && routes.some((o) => o.id === p.routeId))) continue;\n here += ` ${p.label}: ${format.distance(along[geo.nearest(r.points, p.at)] ?? 0, units)} along.`;\n }\n let range = \"\";\n if (stops.length && r.values?.length) range = ` ${colourScaleLabel ?? \"Value\"} from ${formatValue(extent(r.values)[0])} to ${formatValue(extent(r.values)[1])}.`;\n return `${r.label}: ${format.distance(total, units)}${shape}.${range}${here}`;\n });\n const items = markers?.length ? ` ${markers.length === 1 ? \"One marker\" : `${markers.length} markers`}${markers.some((m) => m.selected) ? `, selected: ${markers.filter((m) => m.selected).map((m) => m.label).join(\", \")}` : \"\"}.` : \"\";\n return `Map with ${routes.length === 1 ? \"one route\" : `${routes.length} routes`}. ${parts.join(\" \")}${items}`;\n }, [summary, routes, spoken, units, stops.length, colourScaleLabel, formatValue, markers]);\n\n React.useEffect(() => {\n if (!map) return;\n const c = map.getContainer();\n c.setAttribute(\"aria-label\", label);\n c.setAttribute(\"aria-describedby\", summaryId);\n }, [map, label, summaryId]);\n\n // Tiles: the light set, or the dark one in the dark scheme.\n React.useEffect(() => {\n if (!map) return;\n const layer = coveringTiles(source.url, { attribution: source.attribution, subdomains: source.subdomains ?? \"abc\", minZoom: source.minZoom, maxZoom: source.maxZoom ?? 19, keepBuffer: 1 });\n layer.addTo(map);\n return () => void layer.remove();\n }, [map, source.url, source.attribution, source.subdomains, source.minZoom, source.maxZoom]);\n\n // The routes: redrawn when the routes, the scheme (colours resolve differently), the selection or\n // the scale change, and never for a position update.\n React.useEffect(() => {\n if (!map) return;\n const group = L.featureGroup().addTo(map);\n const el = map.getContainer();\n const halo = resolveColour(el, \"var(--background)\");\n const single = routes.length === 1;\n const stepOf = (v: number) => {\n let at = 0;\n stops.forEach((s, i) => {\n if (s.at <= v) at = i;\n });\n return at;\n };\n routes.forEach((route, index) => {\n if (route.points.length < 2) return;\n const base = resolveColour(el, route.colour ?? PALETTE[index % PALETTE.length]);\n const selected = route.id === selectedId;\n const dim = selectedId !== null && !selected;\n const weight = (route.weight ?? 4) + (selected ? 2 : 0);\n const style = { weight, opacity: dim ? 0.55 : 1, lineCap: \"round\" as const, lineJoin: \"round\" as const, interactive: selectable && !picking, bubblingMouseEvents: false };\n const lines: L.Polyline[] = [];\n if (stops.length && route.values?.length) {\n for (const run of stepRuns(route.points, route.values, stepOf)) {\n lines.push(L.polyline(route.points.slice(run.from, run.to + 1).map(tuple), { ...style, color: resolveColour(el, stops[run.step].colour) }));\n }\n } else {\n lines.push(L.polyline(route.points.map(tuple), { ...style, color: base }));\n }\n for (const line of lines) {\n line.bindTooltip(route.label, { sticky: true });\n line.on(\"click\", () => latest.current.onSelect?.(route.id));\n line.addTo(group);\n }\n const chevrons = route.arrows === undefined ? (single ? 5 : 0) : route.arrows === true ? 5 : route.arrows === false ? 0 : route.arrows;\n if (chevrons > 0) {\n for (const a of geo.arrows(route.points, chevrons)) {\n L.marker(tuple(a.position), {\n interactive: false,\n keyboard: false,\n icon: L.divIcon({ className: \"strata-map-arrow\", iconSize: [26, 26], iconAnchor: [13, 13], html: arrowHtml(a.bearing, base, halo) }),\n }).addTo(group);\n }\n }\n if (route.ends ?? single) {\n const ends = geo.ends(route.points);\n if (ends) {\n const success = resolveColour(el, \"var(--success)\");\n const danger = resolveColour(el, \"var(--danger)\");\n const mark = (at: LatLng, text: string, options: L.CircleMarkerOptions) => L.circleMarker(tuple(at), { radius: 7, interactive: true, bubblingMouseEvents: false, ...options }).bindTooltip(text).addTo(group);\n // Shapes carry the meaning as well as colour: a filled start, a ringed finish, one of each for a loop.\n if (ends.loop) mark(ends.start, `${route.label}: start and finish`, { color: danger, weight: 3, fillColor: success, fillOpacity: 1 });\n else {\n mark(ends.finish, `${route.label}: finish`, { color: danger, weight: 3, fillColor: halo, fillOpacity: 1 });\n mark(ends.start, `${route.label}: start`, { color: halo, weight: 2, fillColor: success, fillOpacity: 1 });\n }\n }\n }\n });\n // Redrawn routes are new layers: keep the positions above them.\n for (const { marker } of posMarkers.current.values()) marker.bringToFront();\n return () => void group.remove();\n }, [map, routes, scheme, selectedId, stops, selectable, picking]);\n\n // The position a followed view is held on: read by the fit (a map shown for the first time starts\n // centred on it) and by the position effect.\n const target = React.useMemo(() => {\n if (!follow) return null;\n const shown = all.filter((p) => p.at);\n return (followId ? shown.find((p) => p.id === followId) : shown[0])?.at ?? null;\n }, [all, follow, followId]);\n const latestView = React.useRef({ target, zoom, centred: follow === \"centre\" });\n latestView.current = { target, zoom, centred: follow === \"centre\" };\n\n // Fit to the routes when the map first has a size and whenever the set of routes changes. With a\n // zoom set there is nothing to fit: the view is placed at that zoom, on the followed position when\n // the map is centred on one, else on the middle of the routes.\n const routeKey = routes.map((r) => r.id).join(\"\\n\");\n const fitted = React.useRef<string | null>(null);\n React.useEffect(() => {\n if (!map) return;\n const fit = () => {\n const size = map.getSize();\n if (fitted.current === routeKey || size.x === 0 || size.y === 0) return;\n if (!geo.bounds(routes.flatMap((r) => r.points)) && !latest.current.view) return;\n fitted.current = routeKey;\n const v = latestView.current;\n setReady(true);\n // A given view wins, then a set zoom (on the followed position, or the routes' middle), then the routes.\n silently(map, () => {\n if (latest.current.view) map.setView(tuple(latest.current.view.center), latest.current.view.zoom, { animate: false });\n else if (v.zoom !== undefined && v.centred && v.target) map.setView(tuple(v.target), v.zoom, { animate: false });\n else showRoutes(map, latest.current.routes, v.zoom);\n });\n };\n fit();\n map.on(\"resize\", fit);\n return () => void map.off(\"resize\", fit);\n // `routes` is read when the key says the set changed; a new array of the same ids does not refit.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [map, routeKey]);\n\n // A zoom that changes after the first view (an animation) moves the zoom about the view's centre.\n React.useEffect(() => {\n if (map && zoom !== undefined && fitted.current !== null && map.getZoom() !== zoom) silently(map, () => map.setZoom(zoom, { animate: false }));\n }, [map, zoom]);\n\n // The positions: one marker each, kept by id and moved with `setLatLng`. No route is touched.\n React.useEffect(() => {\n if (!map) return;\n const el = map.getContainer();\n const live = posMarkers.current;\n const seen = new Set<string>();\n for (const p of all) {\n if (!p.at) continue;\n seen.add(p.id);\n let entry = live.get(p.id);\n if (!entry) {\n entry = { marker: L.circleMarker(tuple(p.at), { radius: 8, weight: 3, fillOpacity: 1, interactive: false }).addTo(map), style: \"\" };\n live.set(p.id, entry);\n } else entry.marker.setLatLng(tuple(p.at));\n const index = routes.findIndex((r) => r.id === p.routeId);\n const spec = p.colour ?? (index >= 0 ? (routes[index].colour ?? PALETTE[index % PALETTE.length]) : \"var(--primary)\");\n const style = `${scheme}|${spec}`;\n if (entry.style !== style) {\n entry.style = style;\n entry.marker.setStyle({ color: resolveColour(el, \"var(--background)\"), fillColor: resolveColour(el, spec) });\n }\n }\n for (const [id, entry] of live) {\n if (seen.has(id)) continue;\n entry.marker.remove();\n live.delete(id);\n }\n if (!target) return;\n if (follow === \"centre\") {\n // Before the first fit with no zoom set there is no zoom to hold; the fit places the view.\n const z = zoom ?? (fitted.current === null ? undefined : map.getZoom());\n if (z !== undefined) centre(map, target, z);\n } else if (!map.getBounds().pad(-0.2).contains(tuple(target))) silently(map, () => map.panTo(tuple(target), { animate: false }));\n }, [map, all, routes, scheme, follow, target, zoom]);\n\n // The reset control: fit the routes again, as the person's own move (so it is reported).\n React.useEffect(() => {\n if (!map) return;\n const control = resetControl(() => {\n const view = latest.current.view;\n if (view) map.setView(tuple(view.center), view.zoom, { animate: false });\n else showRoutes(map, latest.current.routes, latest.current.zoom);\n });\n control.addTo(map);\n return () => void control.remove();\n }, [map]);\n\n // The view, reported once it settles: the person's moves, not the app's own (unless asked).\n React.useEffect(() => {\n if (!map) return;\n let timer: number | undefined;\n const send = () => {\n timer = undefined;\n const b = map.getBounds();\n const c = map.getCenter();\n latest.current.onViewChange?.({ bounds: [[b.getSouth(), b.getWest()], [b.getNorth(), b.getEast()]], zoom: map.getZoom(), center: [c.lat, c.lng] });\n };\n const moved = () => {\n if (!latest.current.onViewChange) return;\n if (!latest.current.reportAppMoves && (quiet.get(map) ?? 0) > 0) return;\n window.clearTimeout(timer);\n timer = window.setTimeout(send, latest.current.settle);\n };\n map.on(\"moveend zoomend\", moved);\n // The first fit ran before this listener was there: with `reportAppMoves`, it is reported too.\n if (fitted.current !== null && latest.current.reportAppMoves) moved();\n return () => {\n map.off(\"moveend zoomend\", moved);\n window.clearTimeout(timer);\n };\n }, [map]);\n\n // A view the app sets (a saved one): the map goes there when it changes, silently.\n const [viewLat, viewLng, viewZoom] = view ? [view.center[0], view.center[1], view.zoom] : [null, null, null];\n React.useEffect(() => {\n if (!map || viewLat === null || viewLng === null || viewZoom === null || fitted.current === null) return;\n const c = map.getCenter();\n if (map.getZoom() === viewZoom && Math.abs(c.lat - viewLat) < 1e-7 && Math.abs(c.lng - viewLng) < 1e-7) return;\n silently(map, () => map.setView([viewLat, viewLng], viewZoom, { animate: false }));\n }, [map, viewLat, viewLng, viewZoom]);\n\n // The shared cursor: metres along one route.\n const shared = useSharedCursor();\n const cursorOn = Boolean(cursorProp) && shared !== null;\n const cursorRouteId = typeof cursorProp === \"object\" && cursorProp.routeId ? cursorProp.routeId : routes[0]?.id;\n const cursorRoute = routes.find((r) => r.id === cursorRouteId) ?? null;\n const setPointer = shared?.setPointer;\n React.useEffect(() => {\n if (!map || !cursorOn || !cursorRoute || !setPointer) return;\n const along = alongOf(cursorRoute.points);\n const onMove = (e: L.LeafletMouseEvent) => {\n if (latest.current.picking) return;\n const snap = geo.snap(cursorRoute.points, [e.latlng.lat, e.latlng.lng], along);\n if (!snap) return;\n const apart = map.latLngToContainerPoint(e.latlng).distanceTo(map.latLngToContainerPoint(tuple(snap.position)));\n setPointer(apart <= 24 ? snap.metres : null);\n };\n const onOut = () => setPointer(null);\n map.on(\"mousemove\", onMove);\n map.on(\"mouseout\", onOut);\n return () => {\n map.off(\"mousemove\", onMove);\n map.off(\"mouseout\", onOut);\n setPointer(null);\n };\n }, [map, cursorOn, cursorRoute, setPointer]);\n const otherAlong = cursorOn ? (shared?.other ?? null) : null;\n const ring = React.useRef<L.CircleMarker | null>(null);\n React.useEffect(() => {\n if (!map) return;\n const at = otherAlong !== null && cursorRoute ? geo.pointAlong(cursorRoute.points, otherAlong, alongOf(cursorRoute.points)) : null;\n if (!at) {\n ring.current?.remove();\n ring.current = null;\n return;\n }\n if (!ring.current) {\n const el = map.getContainer();\n ring.current = L.circleMarker(tuple(at), { radius: 9, weight: 3, fillOpacity: 0, interactive: false, color: resolveColour(el, \"var(--foreground)\") }).addTo(map);\n } else ring.current.setLatLng(tuple(at));\n }, [map, otherAlong, cursorRoute]);\n React.useEffect(() => () => void (ring.current = null), [map]);\n\n // Item markers: those near the view, laid out again each time it settles.\n const [tick, setTick] = React.useState(0);\n React.useEffect(() => {\n if (!map || !markers?.length) return;\n const again = () => setTick((t) => t + 1);\n map.on(\"moveend zoomend resize\", again);\n return () => void map.off(\"moveend zoomend resize\", again);\n }, [map, markers?.length]);\n const placed = React.useMemo(() => (map && ready && markers?.length ? placeMarkers(map, markers, routes) : []), [map, ready, markers, routes, tick]);\n // A stretch is its route's part drawn heavier, and a fanned marker has a leader line back to its true place.\n React.useEffect(() => {\n if (!map || !markers?.length) return;\n const group = L.featureGroup().addTo(map);\n const el = map.getContainer();\n for (const m of markers) {\n if (Array.isArray(m.at)) continue;\n const at = m.at as { routeId: string; from: number; to: number };\n const index = routes.findIndex((r) => r.id === at.routeId);\n if (index < 0) continue;\n const route = routes[index];\n const part = geo.slice(route.points, at.from, at.to, alongOf(route.points));\n if (part.length < 2) continue;\n const colour = m.colour ?? (m.highlighted ? \"var(--success)\" : m.selected ? \"var(--foreground)\" : (route.colour ?? PALETTE[index % PALETTE.length]));\n L.polyline(part.map(tuple), { color: resolveColour(el, colour), weight: (route.weight ?? 4) + (m.selected ? 5 : 3), opacity: m.selected ? 1 : 0.8, lineCap: \"round\", interactive: false }).addTo(group);\n }\n for (const p of placed) if (p.fanned) L.polyline([tuple(p.at), tuple(p.shown)], { color: resolveColour(el, \"var(--muted-foreground)\"), weight: 1, dashArray: \"2 3\", interactive: false }).addTo(group);\n for (const { marker } of posMarkers.current.values()) marker.bringToFront();\n return () => void group.remove();\n }, [map, markers, routes, placed, scheme]);\n\n // Choosing a place.\n React.useEffect(() => {\n if (!map || !picking) return;\n const el = map.getContainer();\n el.classList.add(\"strata-map-picking\");\n map.keyboard.disable();\n setAnnounced(\"Choose a place on the map. Arrow keys move the crosshair, Shift for bigger steps, Enter chooses, Escape cancels.\");\n let cross: L.Marker | null = null;\n const showCross = (at: L.LatLng) => {\n if (!cross) cross = L.marker(at, { interactive: false, keyboard: false, icon: L.divIcon({ className: \"strata-map-crosshair\", html: CROSS_ICON, iconSize: [32, 32], iconAnchor: [16, 16] }) }).addTo(map);\n else cross.setLatLng(at);\n };\n const choose = (ll: L.LatLng) => {\n const at: LatLng = [ll.lat, ll.lng];\n const nearest = nearestRoute(latest.current.routes, at);\n const route = nearest ? latest.current.routes.find((r) => r.id === nearest.routeId) : undefined;\n setAnnounced(`Picked ${at[0].toFixed(5)}, ${at[1].toFixed(5)}.${nearest && route ? ` Nearest: ${route.label}, ${format.distance(nearest.alongM, latest.current.units)} along, ${format.distance(nearest.distanceM, latest.current.units)} from the route.` : \"\"}`);\n latest.current.onPick?.(at, { nearest });\n };\n const onClick = (e: L.LeafletMouseEvent) => {\n cross?.remove();\n cross = null;\n choose(e.latlng);\n };\n const onKey = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") {\n e.preventDefault();\n e.stopPropagation();\n latest.current.onPickCancel?.();\n return;\n }\n if (e.key === \"Enter\") {\n e.preventDefault();\n e.stopPropagation();\n choose(cross ? cross.getLatLng() : map.getCenter());\n return;\n }\n const step = e.shiftKey ? 50 : 10;\n const d = ({ ArrowLeft: [-step, 0], ArrowRight: [step, 0], ArrowUp: [0, -step], ArrowDown: [0, step] } as Record<string, [number, number]>)[e.key];\n if (!d) return;\n e.preventDefault();\n e.stopPropagation();\n const from = map.latLngToContainerPoint(cross ? cross.getLatLng() : map.getCenter());\n let to = from.add(d);\n const size = map.getSize();\n // Past the edge, the map moves and the crosshair stays at the edge.\n const inside = L.point(Math.min(Math.max(to.x, 16), size.x - 16), Math.min(Math.max(to.y, 16), size.y - 16));\n if (!inside.equals(to)) {\n map.panBy(to.subtract(inside), { animate: false });\n to = inside;\n }\n showCross(map.containerPointToLatLng(to));\n };\n map.on(\"click\", onClick);\n el.addEventListener(\"keydown\", onKey);\n return () => {\n map.off(\"click\", onClick);\n el.removeEventListener(\"keydown\", onKey);\n cross?.remove();\n el.classList.remove(\"strata-map-picking\");\n map.keyboard.enable();\n };\n }, [map, picking]);\n\n return (\n <div ref={root} data-dark-treatment={treated ? \"\" : undefined} className={cn(\"strata-map relative isolate aspect-video min-h-64 overflow-hidden rounded-surface border border-border\", className)}>\n <div ref={host} className=\"size-full\" />\n <p id={summaryId} className=\"sr-only\">\n {text}\n </p>\n <p role=\"status\" aria-live=\"polite\" className=\"sr-only\">\n {announced}\n </p>\n {map && placed.length > 0 && <MarkerLayer map={map} placed={placed} onSelect={onMarkerSelect} card={renderMarkerCard} />}\n {topEnd && <div className=\"absolute top-2 right-2 z-1000\">{topEnd}</div>}\n {picking && pickBanner && <div className=\"absolute top-2 left-1/2 z-1000 max-w-[60%] -translate-x-1/2\">{pickBanner}</div>}\n {(stops.length > 0 || bottomStart || (markers?.length && markerKey !== false)) && (\n <div className=\"absolute bottom-6 left-2 z-1000 grid max-w-[60%] gap-2\">\n {stops.length > 0 && <ColourKey stops={stops} label={colourScaleLabel} formatValue={formatValue} />}\n {markers && markers.length > 0 && markerKey !== false && <MarkerKey markers={markers} words={markerKey} />}\n {bottomStart}\n </div>\n )}\n </div>\n );\n}\n\n/** The key to a colour scale: its name, then each step with where it starts, so colour is never the only cue. */\nfunction ColourKey({ stops, label, formatValue }: { stops: readonly { at: number; colour: string }[]; label?: string; formatValue: (v: number) => string }) {\n return (\n <div className=\"rounded-control border border-border bg-background px-2 py-1.5 type-caption text-foreground\">\n {label && <p className=\"font-medium\">{label}</p>}\n <ul className=\"grid gap-0.5\">\n {stops.map((s) => (\n <li key={s.at} className=\"flex items-center gap-2 tabular-nums\">\n <svg width=\"20\" height=\"4\" aria-hidden>\n <line x1=\"0\" x2=\"20\" y1=\"2\" y2=\"2\" stroke={s.colour} strokeWidth={4} strokeLinecap=\"round\" />\n </svg>\n <span>{`From ${formatValue(s.at)}`}</span>\n </li>\n ))}\n </ul>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;AASA,IAAM,SAAS;;;;;;;;;;;;;;;;;;;AAoBf,IAAI,YAAY;;AAGhB,SAAgB,mBAAmB;CACjC,IAAI,aAAa,OAAO,aAAa,aAAa;CAClD,YAAY;CACZ,MAAM,KAAK,SAAS,cAAc,OAAO;CACzC,GAAG,aAAa,mBAAmB,EAAE;CACrC,GAAG,cAAc,aAAa;CAC9B,SAAS,KAAK,YAAY,EAAE;AAC9B;;;ACrBA,S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AAC,OAAD;IAAK,WAAU;IAA+D,UAAA;GAAgB,CAAA;IACtH,MAAM,SAAS,KAAK,eAAgB,SAAS,UAAU,cAAc,UACrE,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA;KACG,MAAM,SAAS,KAAK,oBAAC,WAAD;MAAkB;MAAO,OAAO;MAA+B;KAAc,CAAA;KACjG,WAAW,QAAQ,SAAS,KAAK,cAAc,SAAS,oBAAC,WAAD;MAAoB;MAAS,OAAO;KAAY,CAAA;KACxG;IACE;;EAEJ;;AAET;;AAGA,SAAS,UAAU,EAAE,OAAO,OAAO,eAAyH;CAC1J,OACE,qBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACG,SAAS,oBAAC,KAAD;GAAG,WAAU;GAAe,UAAA;EAAS,CAAA,GAC/C,oBAAC,MAAD;GAAI,WAAU;GACX,UAAA,MAAM,KAAK,MACV,qBAAC,MAAD;IAAe,WAAU;IAAzB,UAAA,CACE,oBAAC,OAAD;KAAK,OAAM;KAAK,QAAO;KAAI,eAAA;KACzB,UAAA,oBAAC,QAAD;MAAM,IAAG;MAAI,IAAG;MAAK,IAAG;MAAI,IAAG;MAAI,QAAQ,EAAE;MAAQ,aAAa;MAAG,eAAc;KAAS,CAAA;IACzF,CAAA,GACL,oBAAC,QAAD,EAAA,UAAO,QAAQ,YAAY,EAAE,EAAE,IAAU,CAAA,CACvC;GALK,GAAA,EAAE,EAKP,CACL;EACC,CAAA,CACD;;AAET"}
@@ -7,7 +7,7 @@ import { CircleCheck, Info, TriangleAlert, X } from "lucide-react";
7
7
  import { jsx, jsxs } from "react/jsx-runtime";
8
8
  import { QueryClient, QueryClientProvider, useQuery } from "@tanstack/react-query";
9
9
  // src/components/button.tsx
10
- var buttonVariants = cva("inline-flex max-w-full shrink-0 cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-control type-label transition-state press disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0", {
10
+ var buttonVariants = cva("inline-flex max-w-full shrink-0 cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-control type-label transition-state press disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-(--control-icon) [&_svg]:shrink-0", {
11
11
  variants: {
12
12
  variant: {
13
13
  default: "bg-primary text-primary-foreground hover:bg-primary-10",
@@ -18,8 +18,8 @@ var buttonVariants = cva("inline-flex max-w-full shrink-0 cursor-pointer items-c
18
18
  link: "h-auto px-0 text-primary-11 underline underline-offset-4 hover:text-primary-12"
19
19
  },
20
20
  size: {
21
- default: "h-(--control-h) px-4",
22
- sm: "h-(--control-h-sm) px-3",
21
+ default: "h-(--control-h) px-(--control-px)",
22
+ sm: "h-(--control-h-sm) px-(--control-px-sm)",
23
23
  icon: "size-(--control-h)",
24
24
  "icon-sm": "size-(--control-h-sm)"
25
25
  }
@@ -324,4 +324,4 @@ async function fetchJson(input, init, { readError = readErrorBody } = {}) {
324
324
  }
325
325
  export { IconButton as _, toLoad as a, toast as c, describeActionError as d, describeHttpError as f, Button$1 as g, overlaySurface as h, staleOf as i, toastTimeout as l, readErrorBody as m, createQueryClient as n, useLoad as o, fieldErrorsOf as p, fetchJson as r, StrataToastRegion as s, StrataQueryProvider as t, HttpError as u, RowAction as v, buttonVariants as y };
326
326
 
327
- //# sourceMappingURL=query-BJcxJLhh.js.map
327
+ //# sourceMappingURL=query-CJ1pSPiC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-CJ1pSPiC.js","names":["Button","AriaButton","Tooltip","ToastQueue","ToastRegion","AriaToast","ToastContent","Button","AriaButton"],"sources":["../src/components/button.tsx","../src/lib/overlay.ts","../src/lib/errors.ts","../src/components/toast.tsx","../src/query/index.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { Button as AriaButton, type PressEvent } from \"react-aria-components\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport type { IconComponent } from \"../lib/icon\";\nimport { cn } from \"../lib/utils\";\nimport type { ControlSize } from \"../lib/control\";\nimport { Tooltip } from \"./tooltip\";\n\n// Variant names are shadcn's, so copied code and agents' prior knowledge still work. Two things\n// differ on purpose:\n// 1. The default variant is `outline`, not the filled accent. A bare <Button> is the restrained\n// one; the accent (`variant=\"default\"`) has to be asked for, once per view. Generated app screens\n// put the accent on every button; 12 of 23 real product screens had no filled primary at all.\n// 2. Heights come from --control-h, shared with Input and NativeSelect, so density changes move\n// every control together.\n// 3. React Aria is the primitives layer (CLAUDE.md, \"The stack\"): behaviour and accessibility come\n// from it, the look from our tokens. `asChild`/`Slot` is gone; a button that navigates is a link.\n// 4. `press`: the button gives 2% under a click or a finger, over 100ms. Buttons are used tens of\n// times a day, so that is all the motion they get (character.md, the frequency budget).\nexport const buttonVariants = cva(\n \"inline-flex max-w-full shrink-0 cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-control type-label transition-state press disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-(--control-icon) [&_svg]:shrink-0\",\n {\n variants: {\n variant: {\n default: \"bg-primary text-primary-foreground hover:bg-primary-10\",\n outline: \"border border-input bg-background text-foreground hover:bg-muted\",\n secondary: \"bg-muted text-foreground hover:bg-neutral-4\",\n ghost: \"text-foreground hover:bg-muted\",\n destructive: \"bg-destructive text-destructive-foreground hover:bg-danger\",\n link: \"h-auto px-0 text-primary-11 underline underline-offset-4 hover:text-primary-12\",\n },\n size: {\n default: \"h-(--control-h) px-(--control-px)\",\n sm: \"h-(--control-h-sm) px-(--control-px-sm)\",\n icon: \"size-(--control-h)\",\n \"icon-sm\": \"size-(--control-h-sm)\",\n },\n },\n defaultVariants: { variant: \"outline\", size: \"default\" },\n },\n);\n\nexport type ButtonProps = Omit<React.ComponentProps<\"button\">, \"className\" | \"style\"> &\n VariantProps<typeof buttonVariants> & {\n className?: string;\n /** React Aria's press event (mouse, touch, pen and keyboard alike). `onClick` also works. */\n onPress?: (event: PressEvent) => void;\n };\n\n/**\n * A button with shadcn's variant names, built on React Aria's `Button` (press handling that behaves\n * the same for mouse, touch, pen and keyboard, focus-visible and hover state). The default variant is\n * `outline`; ask for the filled accent (`variant=\"default\"`) once per view. `type` defaults to `button`.\n * `onClick` and `disabled` are the DOM names and keep working; `onPress` is also accepted.\n */\nexport function Button({ className, variant, size, type = \"button\", disabled, children, ...props }: ButtonProps) {\n // data-variant says which variant was drawn, so a test can check \"one filled button per view\"\n // without reading class names (strata-react issue #48, `filledButtons` in strata-react/testing).\n return (\n <AriaButton\n type={type}\n isDisabled={disabled}\n data-variant={variant ?? \"outline\"}\n className={cn(buttonVariants({ variant, size }), className)}\n {...(props as object)}\n >\n {/* A text label that cannot fit its column is cut with an ellipsis, not drawn past the button (issue #116). */}\n {typeof children === \"string\" ? <span className=\"min-w-0 truncate\">{children}</span> : children}\n </AriaButton>\n );\n}\n\n// An icon-only button cannot be written without a name: `label` is required by the type, becomes\n// the accessible name and is shown as a `Tooltip` on hover and keyboard focus, so the name and the\n// visible hint come from one string and cannot drift. This makes the most common generated\n// accessibility defect (an unlabelled icon button) a compile error instead of an audit finding.\nexport type IconButtonProps = Omit<ButtonProps, \"size\" | \"children\" | \"aria-label\"> & {\n /** `sm` is --control-h-sm, the height of a small `Toggle` or `Button`, for a toolbar or property row. Default --control-h. */\n size?: ControlSize;\n icon: IconComponent;\n label: string;\n /** Shown after the label in its tooltip, muted: \"Ctrl+Z\". */\n hint?: React.ReactNode;\n};\n\n/** An icon-only button. `label` is required and becomes the accessible name and the tooltip (hover and keyboard focus); `hint` adds a muted aside to it, such as a shortcut. */\nexport function IconButton({ icon: Icon, label, hint, variant = \"ghost\", size = \"default\", ...props }: IconButtonProps) {\n return (\n <Tooltip label={label} hint={hint}>\n <Button size={size === \"sm\" ? \"icon-sm\" : \"icon\"} variant={variant} aria-label={label} {...props}>\n <Icon aria-hidden />\n </Button>\n </Tooltip>\n );\n}\n\n// A row action says what it does in the row (\"Withdraw\") and whom it does it to in its name\n// (\"Withdraw Tom Ellery\"): a table of eight \"Withdraw\" buttons is eight identical names in a\n// screen reader's list of controls. The name is an aria-label that starts with the visible verb,\n// so it meets WCAG 2.5.3 (label in name) and voice control still finds it by \"Withdraw\". Visually\n// hidden suffix text is not used: a hidden span joined to the verb did not form a name with its\n// space in dom-testing-library (strata-react issue #11). Ghost and small, one per row, shown only\n// on the rows where it applies; an icon-only row action is an `IconButton` whose `label` names the\n// row the same way. It keeps the row's pitch: rows with and without the action are the same height.\nexport type RowActionProps = Omit<ButtonProps, \"children\" | \"aria-label\"> & {\n /** The visible verb, sentence case: \"Withdraw\", \"Remove\". */\n label: string;\n /** What the row is, as a person would say it: \"Tom Ellery\", \"Moonbeam\". Completes the accessible name. */\n subject: string;\n icon?: IconComponent;\n};\n\n/** A small ghost action for one table row: shows `label`, and is named \"`label` `subject`\" so every row's action has its own name. */\nexport function RowAction({ label, subject, icon: Icon, variant = \"ghost\", size = \"sm\", className, ...props }: RowActionProps) {\n // -my-1.5 lets the 32px button sit in the 20px line of a table row, inside the row's padding, so\n // rows with an action keep the same pitch as rows without one.\n return (\n <Button variant={variant} size={size} aria-label={`${label} ${subject}`} className={cn(\"-my-1.5\", className)} {...props}>\n {Icon && <Icon aria-hidden />}\n {label}\n </Button>\n );\n}\n","// The look every floating surface shares (Dialog, Popover, and later Menu and Toast): the popover\n// role pair, an overlay radius, one hairline and the one shadow that exists for what floats\n// (components.md §3.11). One string, so a menu and a popover cannot drift apart.\nexport const overlaySurface =\n \"rounded-overlay border border-border bg-popover text-popover-foreground shadow-overlay enter-overlay\";\n","// Errors, described for a person. Anything that fails in front of someone (a load in DataView, an\n// action in AsyncButton) says what happened in a sentence, in the product's words, not the\n// developer's: `HttpError`'s own message (\"409 Conflict from /api/bookings\") is for logs. Loads\n// and actions share HttpError's status sentences, so the same failure reads the same everywhere,\n// and differ only in what is true afterwards: a failed load changed nothing, while a failed action\n// may have reached the server, so its sentence does not promise that.\n//\n// A server's own reason beats the status text (strata-react issue #42, from python-app-template).\n// FastAPI and most JSON APIs say why a 4xx happened in the body (`{\"detail\": \"the data folder must\n// be an absolute path\"}`), and a client that drops it has to repeat every server rule to show the\n// person anything better than \"Bad Request\", which drifts and cannot cover rules only the server\n// can check. So `fetchJson` reads an error response's body, `HttpError` keeps it with the reason\n// and any per-field messages found in it, and the sentences below use the reason for a 4xx.\n// Per-field messages (FastAPI's 422 `detail: [{loc, msg}]`) are keyed by field name, so\n// `useAsyncAction`'s `fieldErrors` can put each under its `Field`, never in a toast. A 5xx body is\n// not shown: it is usually a stack trace or a proxy's HTML page, and is kept on `body` for logs.\n\n/** What `readErrorBody` finds in an error response: the server's sentence, and messages per field. */\nexport type ErrorBody = {\n /** Why the server refused, in its own words. */\n reason?: string;\n /** Messages for individual fields, keyed by field name (`\"name\"`, `\"address.city\"`). */\n fields?: Record<string, string>;\n};\n\n/** Thrown by `fetchJson` on a non-2xx response; carries the status, the response body and the server's reason for `describeHttpError` and `describeActionError`. */\nexport class HttpError extends Error {\n /** The server's sentence for why it refused, from the body (`detail`, `message`, `error`), if it gave one. */\n readonly reason?: string;\n /** Messages for individual fields from the body (FastAPI's 422 `detail: [{loc, msg}]`), keyed by field name. Empty when there are none. */\n readonly fieldErrors: Readonly<Record<string, string>>;\n\n constructor(\n readonly status: number,\n readonly statusText: string,\n readonly url: string,\n /** The response body: parsed JSON when it was JSON, else its text; undefined when empty. */\n readonly body?: unknown,\n found: ErrorBody = readErrorBody(body),\n ) {\n super(`${status} ${statusText} from ${url}`);\n this.name = \"HttpError\";\n this.reason = found.reason;\n this.fieldErrors = found.fields ?? {};\n }\n}\n\nconst text = (value: unknown) => (typeof value === \"string\" && value.trim() ? value.trim() : undefined);\n\n/** A field name from a FastAPI/pydantic `loc`: the path after where it came from (`[\"body\", \"address\", \"city\"]` is `\"address.city\"`). */\nfunction fieldName(loc: unknown) {\n if (!Array.isArray(loc)) return undefined;\n const path = loc.map(String);\n if ([\"body\", \"query\", \"path\", \"header\", \"cookie\", \"form\"].includes(path[0]) && path.length > 1) path.shift();\n return path.join(\".\") || undefined;\n}\n\n/**\n * The default reading of an error body, for the shapes most JSON APIs use: `{ detail: \"…\" }`\n * (FastAPI), `{ message: \"…\" }`, `{ error: \"…\" }` or `{ error: { message: \"…\" } }` for the reason,\n * and FastAPI's validation list `{ detail: [{ loc, msg }] }` for per-field messages. A short\n * plain-text body (not HTML) is taken as the reason too. Pass your own to `fetchJson` for other APIs.\n */\nexport function readErrorBody(body: unknown): ErrorBody {\n if (typeof body === \"string\") {\n const t = text(body);\n return t && t.length <= 300 && !t.startsWith(\"<\") ? { reason: t } : {};\n }\n if (!body || typeof body !== \"object\") return {};\n const b = body as Record<string, unknown>;\n if (Array.isArray(b.detail)) {\n const fields: Record<string, string> = {};\n for (const item of b.detail as unknown[]) {\n const entry = item as { loc?: unknown; msg?: unknown } | null;\n const name = fieldName(entry?.loc);\n const msg = text(entry?.msg);\n if (name && msg && !fields[name]) fields[name] = msg;\n }\n return { fields };\n }\n const nested = b.error && typeof b.error === \"object\" ? text((b.error as Record<string, unknown>).message) : undefined;\n return { reason: text(b.detail) ?? text(b.message) ?? text(b.error) ?? nested };\n}\n\n/** Writes an error for a person: what happened, in a sentence. A product passes its own words. */\nexport type DescribeError = (error: unknown) => string;\n\n/** A sentence ends once: \"…absolute path\" and \"…absolute path.\" both end in one full stop. */\nconst sentence = (s: string) => (/[.!?…]$/.test(s) ? s : `${s}.`);\n\nfunction refused(error: HttpError) {\n if (error.reason) return `The request was refused: ${sentence(error.reason)}`;\n if (Object.keys(error.fieldErrors).length) return \"The request was refused: check the fields marked.\";\n return `The request was refused (${error.status}): ${error.statusText || \"no reason given\"}.`;\n}\n\n/** The default `DescribeError` for loads: the HTTP status in a sentence (with the server's reason for a 4xx), else the error's message, else a plain fallback. */\nexport const describeHttpError: DescribeError = (error) =>\n error instanceof HttpError\n ? error.status >= 500\n ? `The server could not answer (${error.status}). Nothing was changed.`\n : refused(error)\n : error instanceof Error && error.message\n ? error.message\n : \"The data could not be loaded. Nothing was changed.\";\n\n/** The default for `useAsyncAction`: the HTTP status in a sentence (with the server's reason for a 4xx), else the thrown Error's message, else undefined (the retry label alone). */\nexport const describeActionError = (error: unknown): string | undefined =>\n error instanceof HttpError\n ? error.status >= 500\n ? `The server could not answer (${error.status}).`\n : refused(error)\n : error instanceof Error && error.message\n ? error.message\n : undefined;\n\n/** Messages for individual fields carried by what was thrown: an `HttpError`'s `fieldErrors`, else none. */\nexport function fieldErrorsOf(error: unknown): Readonly<Record<string, string>> {\n return error instanceof HttpError ? error.fieldErrors : {};\n}\n","import { UNSTABLE_Toast as AriaToast, UNSTABLE_ToastContent as ToastContent, UNSTABLE_ToastQueue as ToastQueue, UNSTABLE_ToastRegion as ToastRegion, Button as AriaButton, Text } from \"react-aria-components\";\nimport { CircleCheck, Info, TriangleAlert, X } from \"lucide-react\";\nimport { Button } from \"./button\";\nimport { cn } from \"../lib/utils\";\nimport { overlaySurface } from \"../lib/overlay\";\n\n// A toast confirms background work that finished (\"Export finished\", \"3 pieces synced\"). It is a\n// polite live region; it never carries an error a person must act on, which goes inline as an\n// `Alert` with its recovery (components.md §3.13, patterns.md §7), so there is no danger tone:\n// the type refuses it. `warning` is for a fact worth a glance (\"Kiln 2 is 40 min behind\").\n//\n// Rules the component owns so an app does not have to:\n// - One region, once, at the app root (`ToastRegion`), on the `layer-bar` layer: bottom end of the\n// window on a wide screen, the top on a phone, so it does not sit on the undo bar or cover the\n// focused control. It is a labelled landmark the keyboard reaches with F6 (React Aria).\n// - It stays long enough to read: 5 s plus 40 ms a character, up to 15 s, at least 8 s with an\n// action. The timer pauses while the pointer or focus is on it. There is always a dismiss control.\n// - At most one action, a button (\"Open file\"); content is words, not a form.\n// - Announcements are React Aria's: the toast's text is read when it appears and not again.\n// - The queue is module-level, so `toast.show()` works from a mutation's `onSuccess` outside any\n// component; `toast.clear()` empties it for a test. React Aria marks its toast API unstable; it\n// is used only here, behind this small surface, so a change upstream stays in this file.\n// Toasts are rare and brief, so they get the overlay entrance and nothing else (character.md §3).\n\n/** What a toast says. */\nexport type ToastContentProps = {\n /** What finished, past tense, in the product's words: \"Export finished\". */\n title: string;\n /** One more sentence: what and where (\"run.mp4, 2:31 at 1080p, in your Downloads folder.\"). */\n description?: string;\n /** `info` by default. There is no danger tone: an error the person must act on is an `Alert`. */\n tone?: \"info\" | \"success\" | \"warning\";\n /** One action beside the words. */\n action?: { label: string; onPress: () => void };\n /** Milliseconds before it goes. Defaults to enough to read the words. */\n timeout?: number;\n};\n\nconst queue = new ToastQueue<ToastContentProps>({ maxVisibleToasts: 3 });\n\n/** Milliseconds a toast stays: 5 s plus 40 ms a character, to at most 15 s, and at least 8 s with an action. */\nexport function toastTimeout(content: Pick<ToastContentProps, \"title\" | \"description\" | \"action\" | \"timeout\">): number {\n if (content.timeout !== undefined) return content.timeout;\n const chars = content.title.length + (content.description?.length ?? 0) + (content.action?.label.length ?? 0);\n return Math.max(content.action ? 8000 : 0, Math.min(15000, 5000 + 40 * chars));\n}\n\n/** The toast queue: `toast.show({ title })` from anywhere; `toast.close(key)`; `toast.clear()`. */\nexport const toast = {\n /** Shows a toast and returns its key. */\n show(content: ToastContentProps): string {\n return queue.add(content, { timeout: toastTimeout(content) });\n },\n close(key: string) {\n queue.close(key);\n },\n clear() {\n queue.clear();\n },\n};\n\nconst marks = { info: { icon: Info, color: \"text-info\" }, success: { icon: CircleCheck, color: \"text-success\" }, warning: { icon: TriangleAlert, color: \"text-warning\" } } as const;\n\n/** Props for `ToastRegion`. */\nexport type StrataToastRegionProps = {\n /** Names the landmark. Default \"Notifications\". */\n label?: string;\n className?: string;\n};\n\n/** The one place toasts appear. Render it once at the app root. A labelled landmark (F6), polite, above panes and the undo bar. */\nexport function StrataToastRegion({ label = \"Notifications\", className }: StrataToastRegionProps) {\n return (\n <ToastRegion\n queue={queue}\n aria-label={label}\n className={cn(\"layer-bar fixed inset-x-4 top-4 grid justify-items-end gap-2 outline-none sm:inset-x-auto sm:top-auto sm:right-4 sm:bottom-4\", className)}\n >\n {({ toast: t }) => (\n <AriaToast\n toast={t}\n className={cn(\"flex w-full max-w-sm items-start gap-3 p-3 outline-none focus-visible:outline-2 focus-visible:outline-ring\", overlaySurface)}\n >\n {(() => {\n const { icon: Icon, color } = marks[t.content.tone ?? \"info\"];\n return <Icon aria-hidden className={cn(\"mt-0.5 size-4 shrink-0\", color)} />;\n })()}\n <ToastContent className=\"grid min-w-0 flex-1 gap-0.5\">\n <Text slot=\"title\" className=\"type-label\">\n {t.content.title}\n </Text>\n {t.content.description && <Text slot=\"description\" className=\"type-body-sm text-muted-foreground\">{t.content.description}</Text>}\n </ToastContent>\n {t.content.action && (\n <Button size=\"sm\" onPress={() => { t.content.action?.onPress(); queue.close(t.key); }}>\n {t.content.action.label}\n </Button>\n )}\n <AriaButton slot=\"close\" aria-label=\"Dismiss\" className=\"grid size-6 shrink-0 cursor-pointer place-items-center rounded-control text-muted-foreground transition-state hover:bg-muted hover:text-foreground\">\n <X aria-hidden className=\"size-4\" />\n </AriaButton>\n </AriaToast>\n )}\n </ToastRegion>\n );\n}\n","import * as React from \"react\";\nimport {\n QueryClient,\n QueryClientProvider,\n useQuery,\n type QueryKey,\n type UseQueryOptions,\n type UseQueryResult,\n} from \"@tanstack/react-query\";\nimport type { Load, Stale } from \"../components/data-view\";\nimport { HttpError, describeHttpError, readErrorBody, type DescribeError, type ErrorBody } from \"../lib/errors\";\n\nexport { HttpError, describeHttpError, readErrorBody, type DescribeError, type ErrorBody };\n\n// Data loading, the Strata way: TanStack Query fetches and caches, and every view of the result\n// goes through DataView, which takes a Load<T>. `toLoad` is the one bridge between them, so a\n// screen never re-derives loading/error/ready from a query's flags and never forgets one.\n//\n// Opinions in createQueryClient: one retry (a second failure is real and the person should see\n// it with a \"Try again\"), 30 s stale time (dashboards are read many times a minute but change\n// over minutes), and no refetch on window focus (a table that reorders itself while someone reads\n// it is worse than one that is 30 s old). Override per query when the data says otherwise.\n\n/** A QueryClient with Strata's defaults: one retry, 30 s stale time, no refetch on window focus. */\nexport function createQueryClient(overrides?: ConstructorParameters<typeof QueryClient>[0]) {\n return new QueryClient({\n ...overrides,\n defaultOptions: {\n ...overrides?.defaultOptions,\n queries: { retry: 1, staleTime: 30_000, refetchOnWindowFocus: false, ...overrides?.defaultOptions?.queries },\n },\n });\n}\n\n/** Provides a query client (Strata's defaults unless one is passed) to the app. */\nexport function StrataQueryProvider({ client, children }: { client?: QueryClient; children: React.ReactNode }) {\n const [fallback] = React.useState(() => client ?? createQueryClient());\n return <QueryClientProvider client={client ?? fallback}>{children}</QueryClientProvider>;\n}\n\n/**\n * Turns a TanStack query result into the `Load<T>` that `DataView` takes; errors are described for a person by `describe`.\n * A refetch that fails after data arrived stays `ready`, with `stale` saying why and when the data was read.\n */\nexport function toLoad<T>(query: UseQueryResult<T>, describe: DescribeError = describeHttpError): Load<T> {\n if (query.status === \"success\") return { status: \"ready\", data: query.data };\n // TanStack keeps the last good data when a refetch fails and sets status \"error\" (isRefetchError).\n // That is old data, not no data: keep it on screen and say how old it is.\n if (query.status === \"error\" && query.data !== undefined) return { status: \"ready\", data: query.data, stale: staleOf(query, describe) };\n if (query.status === \"error\") return { status: \"error\", message: describe(query.error), retry: () => void query.refetch() };\n return { status: \"loading\" };\n}\n\n/** The `Stale` of a query whose refetch failed after a good read. Shared by `toLoad` and `useInfiniteLoad`. */\nexport function staleOf(\n query: { error: unknown; dataUpdatedAt: number; isFetching: boolean; refetch: () => unknown },\n describe: DescribeError = describeHttpError,\n): Stale {\n return { message: describe(query.error), readAt: new Date(query.dataUpdatedAt), retry: () => void query.refetch(), retrying: query.isFetching };\n}\n\n/** `useQuery`, returned as a `Load<T>` for `DataView`. */\nexport function useLoad<T, K extends QueryKey = QueryKey>(\n options: UseQueryOptions<T, Error, T, K> & { describeError?: DescribeError },\n): Load<T> {\n const { describeError, ...rest } = options;\n return toLoad(useQuery(rest), describeError);\n}\n\n/** Options for `fetchJson` beyond `fetch`'s own. */\nexport type FetchJsonOptions = {\n /** Finds the server's reason and per-field messages in an error body. Default `readErrorBody` (FastAPI's `detail`, `message`, `error`). */\n readError?: (body: unknown) => ErrorBody;\n};\n\n/**\n * fetch() that throws an HttpError on a non-2xx response and parses JSON: the queryFn default, and the usual commit for a write.\n * A 204 or empty body resolves to undefined. An error response's body is read onto the HttpError (`body`, `reason`, `fieldErrors`).\n */\nexport async function fetchJson<T>(input: string | URL, init?: RequestInit, { readError = readErrorBody }: FetchJsonOptions = {}): Promise<T> {\n // Headers, tuple arrays and plain objects are all valid HeadersInit; normalise before adding the\n // default so a caller's Authorization (or their own Accept) is never dropped.\n const headers = new Headers(init?.headers);\n if (!headers.has(\"Accept\")) headers.set(\"Accept\", \"application/json\");\n const res = await fetch(input, { ...init, headers });\n if (!res.ok) {\n // The body is read as text and parsed only when it parses: a proxy's HTML 502 page or an empty\n // body must still throw the HttpError, never a JSON SyntaxError in its place.\n const raw = await res.text().catch(() => \"\");\n let body: unknown = raw || undefined;\n try {\n if (raw) body = JSON.parse(raw);\n } catch {\n // Not JSON: keep the text.\n }\n throw new HttpError(res.status, res.statusText, String(input), body, readError(body));\n }\n // Writes (DELETE, a PUT that returns nothing) answer 204 or an empty body; that is success, not a\n // JSON parse error.\n const text = res.status === 204 ? \"\" : await res.text();\n return (text ? JSON.parse(text) : undefined) as T;\n}\n\nexport { useInfiniteLoad, type InfiniteLoad, type InfiniteLoadOptions, type More } from \"./infinite\";\nexport { useJob, type Job, type JobOptions } from \"./job\";\n"],"mappings":";;;;;;;;;AAmBA,IAAa,iBAAiB,IAC5B,oRACA;CACE,UAAU;EACR,SAAS;GACP,SAAS;GACT,SAAS;GACT,WAAW;GACX,OAAO;GACP,aAAa;GACb,MAAM;EACR;EACA,MAAM;GACJ,SAAS;GACT,IAAI;GACJ,MAAM;GACN,WAAW;EACb;CACF;CACA,iBAAiB;EAAE,SAAS;EAAW,MAAM;CAAU;AACzD,CACF;;;;;;;AAeA,SAAgBA,SAAO,EAAE,WAAW,SAAS,MAAM,OAAO,UAAU,UAAU,UAAU,GAAG,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