{
  "version": 3,
  "sources": ["explorer_core.js"],
  "sourcesContent": ["/*\n * static/js/explorer_core.js \u2014 the GPX Explorer's arithmetic and glue\n * (SNOW-1540, SNOW-1545).\n *\n * gpx.snowdesk.info draws one uploaded track on Snowdesk's basemap, with its\n * profile under it. Everything here is reused from the trip page rather than\n * written again: the route is drawn by `route_drawing_core.js` and\n * `route_legs_core.js`, the profile by `route_profile.js`. This module holds\n * only what the explorer adds to them, as pure functions or DOM wiring jsdom\n * can observe, so it is tested in tests/js/test_explorer_core.js.\n * `explorer.js` owns MapLibre and htmx and calls in here.\n *\n * ## Leg colours at every zoom\n *\n * The shared drawing turns a route's leg cores transparent from\n * ROUTE_SLOPE_MINZOOM (z14), and draws its slope classes there instead \u2014\n * but only for a feature whose `sampled` property is true\n * (`legCoreOpacity`). The explorer draws a track, not a terrain reading, so\n * every feature it builds carries `sampled: false` and its slope-segment\n * collection is empty: the legs keep their slate and fuchsia at every zoom,\n * and the core needs no option for it. The `slope` record still reaches\n * the profile, which indexes by it.\n *\n * ## The supported area\n *\n * The map never zooms out past Snowdesk's supported area (`max_bounds` in\n * the payload, `SUPPORTED_AREA_BOUNDS` on the server, `MAX_BOUNDS` in\n * map.js). A track outside it is still drawn, so the bounds the map is held\n * to are the area grown to take the track in (`maxBoundsFor`).\n *\n * ## Selecting a leg (Hugo's mockup, 23 Nov 2026)\n *\n * The page reads the day as legs: lifts, climbs and descents. A recorded\n * day's lift rides are drawn as the map page draws them \u2014\n * `route_lifts_core.js`'s `liftCollection` into the drawing's own lift\n * layers. Stops are neither drawn nor selectable.\n *\n * A tap on the profile (`bindProfilePick`) gives a segment index, and\n * `legAtSegment` the leg it falls in; a tap on the map gives the nearest\n * stretch of the line (`nearestSegment`, within `MAP_PICK_TOLERANCE_PX`),\n * and `legAtLineSegment` its leg. Either goes to one `createLegSelection`: a second\n * tap on the selected leg clears it. A selection is highlighted on both\n * (`highlightRow`: its `point_from`..`point_to` stretch of the line, and a\n * band over its `from`..`to` segments). On the map, as on the profile and\n * the timeline, the selected leg keeps its kind's colour, drawn wider on a\n * white edge, and the rest of the route fades (`fadeRoute`, Hugo, 24 Nov).\n * Its card is shown under the\n * profile (`showLegCard`). The camera never moves. From the keyboard the\n * profile takes focus and the arrow keys move leg by leg\n * (`bindProfileKeys`); Escape clears.\n *\n * ## Exports (frozen `self.pwaExplorerCore`)\n *\n *   ROUTE_PREFIX, HIGHLIGHT_SOURCE, MARK_COLOUR, LEG_COLOURS, MAP_PICK_TOLERANCE_PX\n *   SWAPPED_ERROR_STATUSES       \u2014 the upload's statuses that carry a fragment\n *   readPayload(doc, id)         \u2192 the parsed json_script payload, or null\n *   fitBoundsFor(bounds)         \u2192 [[w, s], [e, n]], or null\n *   maxBoundsFor(area, bounds)   \u2192 the area, grown to take in the track\n *   drawingCollection(feature)   \u2192 the route, as the drawing reads it\n *   drawingSourceData(feature)   \u2192 the five sources' data, `sampled: false`\n *   installRoute(map, feature)   \u2192 adds the sources and the drawing's layers\n *   collapseAttribution(map)     \u2192 starts the map's credits folded away\n *   nextDropState(state, event)  \u2192 the drop zone's next state\n *   dropLabel(state, strings)    \u2192 its label\n *   keepsFile(status)            \u2192 whether the input keeps its file (SNOW-1542)\n *   liftSourceData(feature)      \u2192 the rides and stations (SNOW-1545)\n *   highlightData(feature, row)  \u2192 a leg's stretch of the line\n *   highlightRow(map, view, feature, row) \u2192 highlights both, or clears\n *   fadeRoute(map, faded)        \u2192 fades the route under a selection, or restores it\n *   scaledOpacity(value, factor) \u2192 an opacity, or its expression, scaled\n *   legAtSegment(rows, index)    \u2192 the leg under a profile segment\n *   legAtLineSegment(rows, i)    \u2192 the leg a stretch of the line falls in\n *   nearestSegment(points, tap, tolerance) \u2192 the stretch nearest a tap\n *   createLegSelection(onChange) \u2192 the one selected leg\n *   showLegCard(root, index)     \u2192 shows a leg's card, or the hint\n *   bindProfilePick(view, lane, onIndex) \u2192 a tap on the profile\n *   stepLeg(rows, current, step) \u2192 the leg the arrow keys move to\n *   bindProfileKeys(lane, rows, selection, label) \u2192 the keyboard's way to the legs\n *   saveFile(file, doc)          \u2192 saves the file the browser holds\n *   showCard(root, target)       \u2192 shows a leg's or a stop's card, or the hint\n *   leaderPaths(x, height)       \u2192 the leader band's curved outline and edges\n *   blockAt(blocks, t)           \u2192 the timeline block at a second of the day\n *   positionAt(block, t)         \u2192 where on the profile and the line it is\n *   pointOnLine(coordinates, v)  \u2192 the [lon, lat] at a fractional vertex\n *   markData(point)              \u2192 the map's playhead or stop mark\n *   elapsedLabel(seconds)        \u2192 \"02h19m\", time since the start beside Play\n *   clockLabel(clockS, offsetS)  \u2192 \"12:38\"\n *   timelineTicks(clockS, totalS, step) \u2192 the hour ticks under the timeline\n *   drawTimeline(svg, blocks, totalS, layout) \u2192 the timeline's blocks, drawn\n *   timelineLayout(blocks, totalS, stopW) \u2192 each block's x and width, by the\n *                                  clock or with the stops squeezed\n *   squeezedStopWidth(barPx)     \u2192 a squeezed stop's width, in viewBox units\n *   mixLayout(from, to, f)       \u2192 a layout part way between two\n *   placeTimeline(rects, layout) \u2192 moves the drawn blocks to a layout\n *   timelineX(layout, blocks, t) \u2192 where a second of the day falls on the bar\n *   skipStop(blocks, t)          \u2192 a second in a stop moved on to its end\n *   movingSeconds(blocks, t)     \u2192 the legs' seconds up to a second of the day\n *   clockAtMoving(blocks, m)     \u2192 the second of the day at a moving time\n *   lastLegEnd(blocks)           \u2192 where the day's last leg ends\n *   createPlayback(options)      \u2192 the day played in PLAY_MS\n *   nextMinLeg(current, step)    \u2192 the staff \"Smallest leg\" control's next value\n *   trimWindow(rows, blocks, startedAt, current, end) \u2192 the window left once\n *                                  the first or last leg goes (SNOW-1560)\n *   trimKeep(action, index, count) \u2192 the legs an edit in the leg's \u22EF menu keeps\n *   keepWindow(rows, blocks, startedAt, current, keepFrom, keepTo) \u2192 the\n *                                  window those legs span\n *   createTrim(fields)           \u2192 the trim's state, its Undo and its fields\n *   bindFreshFile(input, onFresh) \u2192 tells a newly chosen file from a re-post\n *   confirmStartAgain(message)   \u2192 whether the visitor confirms Start again\n *   movesFocus(event)            \u2192 whether a key press is keyboard navigation\n *\n * ## Trimming the first or last leg (SNOW-1560)\n *\n * \"Remove from the route\" on the first or last leg's card cuts the day to\n * the window of time the other legs span (`trimWindow`): from the start\n * of the second leg's first block, or to the end of the second-to-last\n * leg's last block. The timeline's seconds count from the drawn file's\n * own start (`payload.started_at`), which a trim moves, so the window is\n * worked out afresh from each result and the side not being cut is kept\n * from the window before. `createTrim` holds the window and the legs\n * taken off each end, with an Undo stack of whole states, and writes\n * them to the drop zone form's hidden `trim_*` fields; the page then\n * posts the file again. A file chosen afresh clears it\n * (`bindFreshFile`), and so does Start again.\n *\n * ## Isolating a leg (Hugo, 24 Nov 2026)\n *\n * The leg's \u22EF menu offers more than one leg at a time: the first or last\n * leg's \"Delete this leg\" and \"Delete all other legs\", and a middle leg's\n * \"Delete previous legs\" and \"Delete subsequent legs\". Each keeps one run\n * of legs (`trimKeep`), so the route is always cut from its ends and stays\n * one piece; `keepWindow` turns that run into a window of time, and\n * `createTrim().cut` takes however many legs it drops off each end in one\n * step, so one Undo puts them all back.\n *\n * ## Skip stops (Hugo, 24 Nov 2026)\n *\n * The toggle beside Play squeezes every stop on the timeline to a sliver\n * about SQUEEZED_STOP_PX wide and widens the legs to fill the bar\n * (`timelineLayout` with a stop width), so the day without its stops shows\n * before Play. The clock ticks follow the legs (`timelineTicks`' `at`).\n * Play then runs the legs back to back (`skipStop`), the head crossing the\n * bar in PLAY_MS as before, and the readout counts moving time\n * (`movingSeconds`) to match the squeezed bar.\n */\n\n// @ts-check\n\n(function () {\n  'use strict';\n\n  /** The prefix the shared drawing names the explorer's sources with. */\n  const ROUTE_PREFIX = 'explorer-route';\n\n  /** SNOW-1545: the source a selected leg's highlight is drawn from. */\n  const HIGHLIGHT_SOURCE = 'explorer-route-highlight';\n\n  /** The white edge a selected leg is drawn on, under HIGHLIGHT_SOURCE. */\n  const HIGHLIGHT_HALO = HIGHLIGHT_SOURCE + '-halo';\n\n  /** Mirrors `--color-text-1`: the ink of the playhead's dot and a stop's mark. */\n  const MARK_COLOUR = '#1a1916';\n\n  /**\n   * Each kind's colour, as the drawing paints its legs and lifts: a selected\n   * leg is drawn in its own (Hugo, 24 Nov 2026). Mirrors `--color-route-lift`,\n   * `--color-route-rail-climb` and `--color-route-rail-descent`.\n   */\n  const LEG_COLOURS = Object.freeze({ lift: '#0d9488', climb: '#64748b', descent: '#c026d3' });\n\n  /** How strongly the rest of the route shows while a leg is selected. */\n  const FADE_OPACITY = 0.3;\n\n  /** The opacity paint properties a faded layer scales, by layer type. */\n  const FADED_PAINT = Object.freeze({\n    line: ['line-opacity'],\n    circle: ['circle-opacity', 'circle-stroke-opacity'],\n  });\n\n  /** Each map's opacities from before the fade: [layer id, property, value]. */\n  const unfaded = new WeakMap();\n\n  /** The source the playhead's dot, or a selected stop's mark, is drawn from. */\n  const MARK_SOURCE = 'explorer-route-mark';\n\n  /** The layers the selection draws itself, which never fade. */\n  const DAY_LAYER_IDS = [HIGHLIGHT_HALO, HIGHLIGHT_SOURCE, MARK_SOURCE];\n\n  /** How long Play takes over the whole day, in milliseconds. */\n  const PLAY_MS = 30000;\n\n  /** How near a tap on the map must land to a leg's line, in pixels. */\n  const MAP_PICK_TOLERANCE_PX = 16;\n\n  /**\n   * The upload's failures, each of which answers with the error fragment\n   * (apps/explorer/views.py): no file or not a GPX file, too large, too\n   * many at once. htmx swaps no 4xx by default.\n   */\n  const SWAPPED_ERROR_STATUSES = Object.freeze([400, 413, 429]);\n\n  /**\n   * The landing's backdrop: a still, blurred view over Verbier behind the\n   * drop zone, before any file is drawn. The example day is skied there.\n   */\n  const BACKDROP_VIEW = Object.freeze({ center: Object.freeze([7.2286, 46.0963]), zoom: 12.2 });\n\n  /**\n   * @typedef {{type: string, features: Array<any>}} FeatureCollection\n   * @typedef {'idle'|'over'|'busy'} DropState\n   * @typedef {'dragenter'|'dragleave'|'drop'|'request'|'settle'} DropEvent\n   */\n\n  /** @returns {FeatureCollection} */\n  function empty() {\n    return { type: 'FeatureCollection', features: [] };\n  }\n\n  /**\n   * Read and parse a json_script payload.\n   *\n   * @param {Document} doc\n   * @param {string} id The element's id.\n   * @returns {?Object<string, any>} The payload, or null.\n   */\n  function readPayload(doc, id) {\n    const el = doc.getElementById(id);\n    if (!el) return null;\n    try {\n      const parsed = JSON.parse(el.textContent || 'null');\n      return parsed && typeof parsed === 'object' ? parsed : null;\n    } catch (_err) {\n      return null;\n    }\n  }\n\n  /**\n   * Whether a value is a flat bbox of four finite numbers.\n   *\n   * @param {any} bounds\n   * @returns {boolean}\n   */\n  function isBbox(bounds) {\n    return Array.isArray(bounds) && bounds.length === 4\n      && bounds.every((value) => typeof value === 'number' && isFinite(value));\n  }\n\n  /**\n   * Reshape a flat `[w, s, e, n]` bbox into the nested pair MapLibre takes.\n   *\n   * @param {any} bounds\n   * @returns {?Array<Array<number>>}\n   */\n  function fitBoundsFor(bounds) {\n    if (!isBbox(bounds)) return null;\n    return [[bounds[0], bounds[1]], [bounds[2], bounds[3]]];\n  }\n\n  /**\n   * The bounds the map is held to: the supported area, grown to take in\n   * the track when it leaves it, so a track outside is still drawn.\n   *\n   * @param {any} area The supported area, `[w, s, e, n]`.\n   * @param {any} bounds The track's, `[w, s, e, n]`.\n   * @returns {?Array<Array<number>>} Nested, or null without an area.\n   */\n  function maxBoundsFor(area, bounds) {\n    if (!isBbox(area)) return null;\n    if (!isBbox(bounds)) return fitBoundsFor(area);\n    return [\n      [Math.min(area[0], bounds[0]), Math.min(area[1], bounds[1])],\n      [Math.max(area[2], bounds[2]), Math.max(area[3], bounds[3])],\n    ];\n  }\n\n  /**\n   * The route as the drawing reads it: its `slope` left off, so no slope\n   * segment is cut from it, and `sampled: false`.\n   *\n   * @param {?Object<string, any>} feature The payload's route Feature.\n   * @returns {FeatureCollection}\n   */\n  function drawingCollection(feature) {\n    const coordinates = feature && feature.geometry && feature.geometry.coordinates;\n    if (!Array.isArray(coordinates) || coordinates.length < 2) return empty();\n    const properties = Object.assign({}, (feature && feature.properties) || {});\n    delete properties.slope;\n    properties.sampled = false;\n    return {\n      type: 'FeatureCollection',\n      features: [Object.assign({}, feature, { properties: properties })],\n    };\n  }\n\n  /**\n   * Mark every feature of a collection `sampled: false`.\n   *\n   * @param {FeatureCollection} collection\n   * @returns {FeatureCollection}\n   */\n  function unsampled(collection) {\n    return {\n      type: 'FeatureCollection',\n      features: (collection.features || []).map((feature) => Object.assign({}, feature, {\n        properties: Object.assign({}, feature.properties || {}, { sampled: false }),\n      })),\n    };\n  }\n\n  /**\n   * The five sources' data, from the shared drawing, for the explorer:\n   * every feature `sampled: false` and no slope segments, so the legs keep\n   * their colours at every zoom.\n   *\n   * @param {?Object<string, any>} feature The payload's route Feature.\n   * @returns {{route: FeatureCollection, legs: FeatureCollection,\n   *   slopes: FeatureCollection, transitions: FeatureCollection,\n   *   endpoints: FeatureCollection}}\n   */\n  function drawingSourceData(feature) {\n    const drawing = self.pwaRouteDrawingCore;\n    const collection = drawingCollection(feature);\n    const data = drawing ? drawing.sourceData(collection) : {\n      route: collection, legs: empty(), slopes: empty(), transitions: empty(), endpoints: empty(),\n    };\n    return {\n      route: unsampled(data.route),\n      legs: unsampled(data.legs),\n      slopes: empty(),\n      transitions: unsampled(data.transitions),\n      endpoints: unsampled(data.endpoints),\n    };\n  }\n\n  /**\n   * Add the route's sources and the shared drawing's layers to a map.\n   *\n   * The drawing's own `install` builds its sources from the collection;\n   * the explorer hands it the data instead, so the slope segments stay\n   * empty. Idempotent, guarded on the route source.\n   *\n   * @param {any} map A MapLibre map.\n   * @param {?Object<string, any>} feature The payload's route Feature.\n   * @returns {?Object<string, string>} The source ids, or null without the drawing.\n   */\n  function installRoute(map, feature) {\n    const drawing = self.pwaRouteDrawingCore;\n    if (!drawing) return null;\n    // SNOW-1545: a `lifts` source too, so the drawing adds its lift layers.\n    const sources = Object.assign({}, drawing.sourceIds(ROUTE_PREFIX), {\n      lifts: ROUTE_PREFIX + '-lifts',\n    });\n    if (map.getSource(sources.route)) return sources;\n    drawing.ensureMarkerImages(map);\n    const data = Object.assign({}, drawingSourceData(feature), {\n      lifts: liftSourceData(feature),\n    });\n    for (const key of /** @type {Array<'route'|'legs'|'slopes'|'transitions'|'endpoints'|'lifts'>} */ (Object.keys(data))) {\n      map.addSource(sources[key], { type: 'geojson', data: data[key] });\n    }\n    const options = {\n      prefix: ROUTE_PREFIX,\n      sources: sources,\n      textFont: drawing.styleTextFont(map.getStyle ? map.getStyle() : null),\n    };\n    // Hugo's mockup (23 Nov 2026): the legs alone. The drawing's\n    // changeover dots and their labels are left out; the start and the\n    // finish stay.\n    const marks = drawing.markLayers(options).filter(\n      (/** @type {{source?: string}} */ layer) => layer.source !== sources.transitions,\n    );\n    for (const layer of drawing.lineLayers(options).concat(marks)) {\n      map.addLayer(layer);\n    }\n    map.addSource(HIGHLIGHT_SOURCE, { type: 'geojson', data: empty() });\n    map.addSource(MARK_SOURCE, { type: 'geojson', data: empty() });\n    for (const layer of dayLayers()) map.addLayer(layer);\n    return sources;\n  }\n\n  /**\n   * The selected leg's highlight over the drawing's layers: the leg in its\n   * kind's colour, solid and wider than the route, on a white edge.\n   *\n   * @returns {Array<Object<string, any>>}\n   */\n  function dayLayers() {\n    const layout = { 'line-cap': 'round', 'line-join': 'round' };\n    return [\n      {\n        id: HIGHLIGHT_HALO,\n        type: 'line',\n        source: HIGHLIGHT_SOURCE,\n        layout: layout,\n        paint: {\n          'line-color': '#ffffff',\n          'line-width': ['interpolate', ['linear'], ['zoom'], 6, 8, 12, 11, 16, 15],\n        },\n      },\n      {\n        id: HIGHLIGHT_SOURCE,\n        type: 'line',\n        source: HIGHLIGHT_SOURCE,\n        layout: layout,\n        paint: {\n          'line-color': [\n            'match', ['get', 'kind'],\n            'lift', LEG_COLOURS.lift,\n            'climb', LEG_COLOURS.climb,\n            LEG_COLOURS.descent,\n          ],\n          'line-width': ['interpolate', ['linear'], ['zoom'], 6, 4, 12, 6, 16, 9],\n        },\n      },\n      {\n        // The playhead, or a selected stop: a solid ink dot ringed in\n        // white, unlike the drawing's hollow start and finish marks.\n        id: MARK_SOURCE,\n        type: 'circle',\n        source: MARK_SOURCE,\n        paint: {\n          'circle-radius': 7,\n          'circle-color': MARK_COLOUR,\n          'circle-stroke-color': '#ffffff',\n          'circle-stroke-width': 3,\n        },\n      },\n    ];\n  }\n\n  /**\n   * A recorded day's lift rides and their stations, as the map page draws\n   * them (`route_lifts_core.js`'s `liftCollection`, SNOW-1545).\n   *\n   * @param {?Object<string, any>} feature The payload's route Feature.\n   * @returns {FeatureCollection}\n   */\n  function liftSourceData(feature) {\n    const lifts = self.pwaRouteLiftsCore;\n    if (!lifts || !feature) return empty();\n    return lifts.liftCollection({ type: 'FeatureCollection', features: [feature] });\n  }\n\n  /**\n   * What a leg highlights on the map (SNOW-1545): its stretch of the\n   * line, `coordinates[point_from..point_to]`. A stop highlights nothing.\n   *\n   * @param {?Object<string, any>} feature The payload's route Feature.\n   * @param {?Object<string, any>} row A payload `breakdown` row; null clears.\n   * @returns {FeatureCollection}\n   */\n  function highlightData(feature, row) {\n    if (!row || row.kind === 'stop') return empty();\n    const coordinates = (feature && feature.geometry && feature.geometry.coordinates) || [];\n    const first = row.point_from;\n    const last = row.point_to;\n    if (!Number.isInteger(first) || !Number.isInteger(last) || first < 0) return empty();\n    const line = coordinates.slice(first, last + 1);\n    if (line.length < 2) return empty();\n    return {\n      type: 'FeatureCollection',\n      features: [{\n        type: 'Feature',\n        geometry: { type: 'LineString', coordinates: line },\n        properties: { kind: row.kind },\n      }],\n    };\n  }\n\n  /**\n   * Highlight one leg on the map and the profile, or clear both with a\n   * null row (SNOW-1545).\n   *\n   * The leg's stretch of the line goes in the highlight source and its\n   * segments are banded on the profile. The camera never\n   * moves: the whole route stays on screen, and only the visitor zooms\n   * (Hugo, 23 Nov).\n   *\n   * @param {any} map A MapLibre map, or null before it has loaded.\n   * @param {?{highlight: function(Object): void, clearHighlight: function(): void}} view\n   *   The profile view, or null.\n   * @param {?Object<string, any>} feature The payload's route Feature.\n   * @param {?Object<string, any>} row A payload `breakdown` row; null clears.\n   */\n  function highlightRow(map, view, feature, row) {\n    if (view) {\n      if (!row) view.clearHighlight();\n      else view.highlight({ from: row.from, to: row.to, kind: row.kind });\n    }\n    const source = map && map.getSource(HIGHLIGHT_SOURCE);\n    if (!source) return;\n    source.setData(highlightData(feature, row));\n    fadeRoute(map, Boolean(row));\n  }\n\n  /**\n   * An opacity scaled by `factor`: a number, or the numeric outputs of a\n   * `step`, `case` or `interpolate` expression, whose zoom input must stay\n   * at the top level. Unset is MapLibre's default of 1; any other\n   * expression is returned as it is.\n   *\n   * @param {any} value The paint property's value.\n   * @param {number} factor The scale.\n   * @returns {any}\n   */\n  function scaledOpacity(value, factor) {\n    if (value === undefined || value === null) return factor;\n    if (typeof value === 'number') return value * factor;\n    if (!Array.isArray(value)) return value;\n    const out = value.slice();\n    const scale = (/** @type {number} */ i) => { out[i] = scaledOpacity(out[i], factor); };\n    if (out[0] === 'step') {\n      for (let i = 2; i < out.length; i += 2) scale(i);\n    } else if (out[0] === 'case') {\n      for (let i = 2; i < out.length - 1; i += 2) scale(i);\n      scale(out.length - 1);\n    } else if (out[0] === 'interpolate') {\n      for (let i = 4; i < out.length; i += 2) scale(i);\n    }\n    return out;\n  }\n\n  /**\n   * Fade the route's own layers while a leg is selected, or put back the\n   * opacities they had before (Hugo, 24 Nov 2026: one rule on the map, the\n   * profile and the timeline). The selection's layers never fade.\n   *\n   * @param {any} map A MapLibre map, or null.\n   * @param {boolean} faded Whether a leg is selected.\n   */\n  function fadeRoute(map, faded) {\n    if (!map || typeof map.getStyle !== 'function') return;\n    const saved = unfaded.get(map);\n    if (!faded) {\n      if (!saved) return;\n      for (const [id, property, value] of saved) {\n        if (map.getLayer(id)) map.setPaintProperty(id, property, value);\n      }\n      unfaded.delete(map);\n      return;\n    }\n    if (saved) return;\n    const style = map.getStyle();\n    /** @type {Array<[string, string, any]>} */\n    const before = [];\n    for (const layer of (style && style.layers) || []) {\n      if (!layer.id.startsWith(ROUTE_PREFIX) || DAY_LAYER_IDS.includes(layer.id)) continue;\n      for (const property of FADED_PAINT[/** @type {'line'|'circle'} */ (layer.type)] || []) {\n        const value = map.getPaintProperty(layer.id, property);\n        before.push([layer.id, property, value]);\n        map.setPaintProperty(layer.id, property, scaledOpacity(value, FADE_OPACITY));\n      }\n    }\n    unfaded.set(map, before);\n  }\n\n  /**\n   * The options the backdrop map is built with: the Verbier view, and no\n   * way to move it or to tab to it. It is scenery: the drop zone is the\n   * page.\n   *\n   * @param {HTMLElement} container The `[data-explorer-backdrop]` element.\n   * @param {string|Object} style The resolved basemap style.\n   * @returns {Object} MapLibre `Map` options.\n   */\n  function backdropOptions(container, style) {\n    return {\n      container: container,\n      style: style,\n      center: BACKDROP_VIEW.center.slice(),\n      zoom: BACKDROP_VIEW.zoom,\n      interactive: false,\n      keyboard: false,\n      attributionControl: { compact: true },\n      fadeDuration: 0,\n    };\n  }\n\n  /**\n   * Start a map's compact attribution folded to its \u24D8 (Hugo, 23 Nov 2026:\n   * open, it covered the map and did not look as if it could be hidden).\n   *\n   * MapLibre opens a compact attribution the first time it has credits to\n   * show, once a source's metadata arrives, and folds it on the first drag.\n   * This folds it as soon as it opens, the way that drag does, and then lets\n   * go, so a tap on the \u24D8 still opens it.\n   *\n   * @param {{getContainer: function(): HTMLElement, on: function(string, Function): void, off: function(string, Function): void}} map\n   */\n  function collapseAttribution(map) {\n    var container = map.getContainer();\n    function fold() {\n      var credits = container.querySelector('.maplibregl-ctrl-attrib.maplibregl-compact');\n      if (!credits) return;\n      credits.classList.remove('maplibregl-compact-show');\n      map.off('styledata', fold);\n      map.off('sourcedata', fold);\n    }\n    map.on('styledata', fold);\n    map.on('sourcedata', fold);\n    fold();\n  }\n\n  /**\n   * The drop zone's next state.\n   *\n   * Idle until a file is dragged over it; back to idle when it leaves;\n   * busy from the drop (or a chosen file's request) until htmx settles.\n   * A drag over a busy zone does not change it.\n   *\n   * @param {DropState} state\n   * @param {DropEvent} event\n   * @returns {DropState}\n   */\n  function nextDropState(state, event) {\n    if (event === 'request' || event === 'drop') return 'busy';\n    if (event === 'settle') return 'idle';\n    if (state === 'busy') return 'busy';\n    if (event === 'dragenter') return 'over';\n    return 'idle';\n  }\n\n  /**\n   * The drop zone's label in a state.\n   *\n   * @param {DropState} state\n   * @param {Object<string, string>} strings The explorer's strings.\n   * @returns {string}\n   */\n  function dropLabel(state, strings) {\n    return strings['drop-' + state] || strings['drop-idle'] || '';\n  }\n\n  /**\n   * Whether the file input keeps its file once an upload has answered\n   * (SNOW-1542).\n   *\n   * A drawn result's \"Open this route in Snowdesk\" submits the drop zone's\n   * own form, so the file must still be on the input. After a failure there\n   * is no such button, and the input is cleared so the same file chosen\n   * again still fires `change` and posts.\n   *\n   * @param {?number|undefined} status The upload's HTTP status.\n   * @returns {boolean} True for a drawn result (200).\n   */\n  function keepsFile(status) {\n    return status === 200;\n  }\n\n  /**\n   * The leg a profile segment falls in, or null.\n   *\n   * @param {Array<Object<string, any>>} rows The payload's `breakdown`.\n   * @param {?number} index A profile segment index (`view.indexAt`).\n   * @returns {?Object<string, any>} The lift, climb or descent row.\n   */\n  function legAtSegment(rows, index) {\n    if (!Number.isInteger(index)) return null;\n    const at = /** @type {number} */ (index);\n    return rows.find((row) => row && row.kind !== 'stop' && row.from <= at && at <= row.to) || null;\n  }\n\n  /**\n   * The leg a stretch of the map's line falls in, or null: the segment\n   * from vertex `i` to vertex `i + 1`, inside a row's\n   * `point_from`..`point_to`.\n   *\n   * @param {Array<Object<string, any>>} rows The payload's `breakdown`.\n   * @param {?number} i The segment's first vertex.\n   * @returns {?Object<string, any>} The lift, climb or descent row.\n   */\n  function legAtLineSegment(rows, i) {\n    if (!Number.isInteger(i)) return null;\n    const at = /** @type {number} */ (i);\n    return rows.find(\n      (row) => row && row.kind !== 'stop' && row.point_from <= at && at < row.point_to,\n    ) || null;\n  }\n\n  /**\n   * The segment of the line nearest a tap, by its first vertex, or null\n   * when none passes within `tolerance` pixels. Measured to the segment,\n   * not its ends: a lift is one long straight segment between stations.\n   *\n   * @param {Array<{x: number, y: number}>} points The line's vertices,\n   *   projected to the map's pixels, in order.\n   * @param {{x: number, y: number}} tap Where the tap landed.\n   * @param {number} tolerance How far off the line a tap may land.\n   * @returns {?number} The segment's first vertex.\n   */\n  function nearestSegment(points, tap, tolerance) {\n    let best = null;\n    let bestDistance = tolerance * tolerance;\n    for (let i = 0; i + 1 < points.length; i += 1) {\n      const a = points[i];\n      const b = points[i + 1];\n      const dx = b.x - a.x;\n      const dy = b.y - a.y;\n      const length = dx * dx + dy * dy;\n      const t = length > 0\n        ? Math.max(0, Math.min(1, ((tap.x - a.x) * dx + (tap.y - a.y) * dy) / length))\n        : 0;\n      const ex = a.x + t * dx - tap.x;\n      const ey = a.y + t * dy - tap.y;\n      const distance = ex * ex + ey * ey;\n      if (distance <= bestDistance) {\n        best = i;\n        bestDistance = distance;\n      }\n    }\n    return best;\n  }\n\n  /**\n   * The page's one selected leg: `select` picks a row, or clears it when\n   * it is the one already selected, and `clear` drops it. Each change is\n   * passed to `onChange`, the row or null.\n   *\n   * @param {function(?Object<string, any>): void} onChange\n   * @returns {{select: function(?Object<string, any>): void, clear: function(): void, current: function(): ?Object<string, any>}}\n   */\n  function createLegSelection(onChange) {\n    /** @type {?Object<string, any>} */\n    let current = null;\n    return {\n      select(row) {\n        const next = row && row !== current ? row : null;\n        if (next === current) return;\n        current = next;\n        onChange(current);\n      },\n      clear() {\n        if (!current) return;\n        current = null;\n        onChange(null);\n      },\n      current() {\n        return current;\n      },\n    };\n  }\n\n  /**\n   * Show one leg's card under the profile and hide the others, or show the\n   * hint with none.\n   *\n   * @param {ParentNode} root The `[data-explorer-legs]` element.\n   * @param {?number} index The row's place in the payload's `breakdown`.\n   */\n  function showLegCard(root, index) {\n    showCard(root, index === null ? null : { leg: index });\n  }\n\n\n  /**\n   * Wire a tap on the profile to the leg under it: a click on the lane\n   * passes the segment there to `onIndex`.\n   *\n   * @param {{indexAt: function(number): ?number}} view A `pwaRouteProfile` view.\n   * @param {Element} lane The view's lane.\n   * @param {function(?number): void} onIndex\n   * @returns {function(): void} Unbinds the lane.\n   */\n  function bindProfilePick(view, lane, onIndex) {\n    /** @param {Event} event */\n    function onClick(event) {\n      onIndex(view.indexAt(/** @type {MouseEvent} */ (event).clientX));\n    }\n    lane.addEventListener('click', onClick);\n    /** @type {HTMLElement} */ (lane).style.cursor = 'pointer';\n    return () => lane.removeEventListener('click', onClick);\n  }\n\n  /**\n   * The leg the arrow keys move to from the selected one: the next lift,\n   * climb or descent for `+1`, the previous for `-1`, the first or last\n   * when none is selected. Stops are skipped.\n   *\n   * @param {Array<Object<string, any>>} rows The payload's `breakdown`.\n   * @param {?Object<string, any>} current The selected row, or null.\n   * @param {number} step +1 or -1.\n   * @returns {?Object<string, any>} The row to select, or null with no legs.\n   */\n  function stepLeg(rows, current, step) {\n    const legs = rows.filter((row) => row && row.kind !== 'stop');\n    if (!legs.length) return null;\n    const at = current ? legs.indexOf(current) : -1;\n    if (at === -1) return step > 0 ? legs[0] : legs[legs.length - 1];\n    return legs[Math.min(legs.length - 1, Math.max(0, at + step))];\n  }\n\n  /**\n   * Make the profile's lane the keyboard's way to the legs: it takes\n   * focus, the arrow keys move the selection leg by leg, and Escape\n   * clears it. The leg's card is announced as it changes.\n   *\n   * @param {Element} lane The profile view's lane.\n   * @param {Array<Object<string, any>>} rows The payload's `breakdown`.\n   * @param {{select: function(?Object<string, any>): void, clear: function(): void, current: function(): ?Object<string, any>}} selection\n   * @param {string} label The lane's accessible name, from the page's strings.\n   * @returns {function(): void} Unbinds the lane.\n   */\n  function bindProfileKeys(lane, rows, selection, label) {\n    lane.setAttribute('tabindex', '0');\n    if (label) lane.setAttribute('aria-label', label);\n    /** @param {Event} event */\n    function onKey(event) {\n      const key = /** @type {KeyboardEvent} */ (event).key;\n      if (key === 'Escape') {\n        selection.clear();\n        return;\n      }\n      const step = key === 'ArrowRight' || key === 'ArrowDown' ? 1\n        : key === 'ArrowLeft' || key === 'ArrowUp' ? -1 : 0;\n      if (!step) return;\n      event.preventDefault();\n      const next = stepLeg(rows, selection.current(), step);\n      if (next && next !== selection.current()) selection.select(next);\n    }\n    lane.addEventListener('keydown', onKey);\n    return () => lane.removeEventListener('keydown', onKey);\n  }\n\n  /**\n   * Save a file the browser holds, under its own name. Nothing is sent:\n   * the link points at an object URL, released once it is followed.\n   *\n   * @param {?Blob & {name?: string}} file The file input's file.\n   * @param {Document} doc\n   * @returns {boolean} False when there was no file to save.\n   */\n  function saveFile(file, doc) {\n    if (!file) return false;\n    const url = URL.createObjectURL(file);\n    const link = doc.createElement('a');\n    link.href = url;\n    link.download = file.name || 'route.gpx';\n    doc.body.appendChild(link);\n    link.click();\n    link.remove();\n    setTimeout(() => URL.revokeObjectURL(url), 0);\n    return true;\n  }\n\n  /**\n   * Show one leg's or one stop's card and hide the others, or show the\n   * hint with neither.\n   *\n   * @param {ParentNode} root The `[data-explorer-legs]` element.\n   * @param {?{leg?: number, stop?: number}} target A `breakdown` index as\n   *   `leg`, a timeline block index as `stop`, or null.\n   */\n  function showCard(root, target) {\n    let shown = false;\n    /** @type {Array<[string, 'leg' | 'stop']>} */\n    const kinds = [\n      ['data-leg-card', 'leg'],\n      ['data-stop-card', 'stop'],\n    ];\n    for (const [attr, key] of kinds) {\n      const index = target ? target[key] : undefined;\n      const want = Number.isInteger(index) ? String(index) : null;\n      root.querySelectorAll('[' + attr + ']').forEach((card) => {\n        const match = want !== null && card.getAttribute(attr) === want;\n        /** @type {HTMLElement} */ (card).hidden = !match;\n        if (match) shown = true;\n      });\n    }\n    const hint = /** @type {?HTMLElement} */ (root.querySelector('[data-explorer-leg-hint]'));\n    if (hint) hint.hidden = shown;\n  }\n\n  /**\n   * The leader band's outline and its two edges as SVG paths, each edge an\n   * S-curve from the profile down to the timeline (Hugo, 24 Nov 2026: the\n   * curved band reads better than straight lines). Both ends of a curve\n   * leave vertically, so the band meets the profile and the bar square on.\n   *\n   * @param {Array<number>} x The band's x positions, 0 to 1000: the top's\n   *   left and right, then the bottom's left and right.\n   * @param {number} height The leader's height in its viewBox.\n   * @returns {{band: string, edges: Array<string>}} Path data.\n   */\n  function leaderPaths(x, height) {\n    const mid = height / 2;\n    /** @param {number|string} top @param {number|string} bottom */\n    const down = (top, bottom) => 'C' + top + ' ' + mid + ' ' + bottom + ' ' + mid + ' ' + bottom + ' ' + height;\n    /** @param {number|string} bottom @param {number|string} top */\n    const up = (bottom, top) => 'C' + bottom + ' ' + mid + ' ' + top + ' ' + mid + ' ' + top + ' 0';\n    return {\n      band: 'M' + x[0] + ' 0 L' + x[1] + ' 0 ' + down(x[1], x[3]) + ' L' + x[2] + ' ' + height + ' ' + up(x[2], x[0]) + ' Z',\n      edges: [\n        'M' + x[0] + ' 0 ' + down(x[0], x[2]),\n        'M' + x[1] + ' 0 ' + down(x[1], x[3]),\n      ],\n    };\n  }\n\n  /**\n   * The band from a leg's stretch on the profile down to its blocks on the\n   * timeline (Hugo, 23 Nov 2026: leader lines for the selected leg only).\n   *\n   * The profile spreads its segments evenly across its width\n   * (route_rail_core.js `legSpan`), so a leg's top edge is its segments'\n   * share of `sampleCount`; the bottom edge runs from its first block's\n   * start to its last block's end, in the day's seconds.\n   *\n   * @param {?{from: number, to: number}} row The selected leg, or null.\n   * @param {number} leg Its index in the breakdown.\n   * @param {Array<{start_s: number, duration_s: number, leg: ?number}>} blocks\n   * @param {number} sampleCount The profile's segments.\n   * @param {number} totalS The day's length, seconds.\n   * @param {function(number): number} [at] Where a second of the day falls\n   *   on the bar, 0 to 1, as the timeline is laid out; by the clock if left out.\n   * @returns {?{top: Array<number>, bottom: Array<number>}} Fractions of the\n   *   width, 0 to 1; null with no leg, no blocks of it or no scale.\n   */\n  function leaderBand(row, leg, blocks, sampleCount, totalS, at) {\n    if (!row || !(sampleCount > 0) || !(totalS > 0)) return null;\n    var mine = (blocks || []).filter(function (block) { return block.leg === leg; });\n    if (!mine.length) return null;\n    var start = Math.min.apply(null, mine.map(function (b) { return b.start_s; }));\n    var end = Math.max.apply(null, mine.map(function (b) { return b.start_s + b.duration_s; }));\n    /** @param {number} n */\n    var clamp = function (n) { return Math.min(Math.max(n, 0), 1); };\n    return {\n      top: [clamp(row.from / sampleCount), clamp((row.to + 1) / sampleCount)],\n      bottom: at ? [clamp(at(start)), clamp(at(end))] : [clamp(start / totalS), clamp(end / totalS)],\n    };\n  }\n\n  /**\n   * The timeline block under a second of the day: the last whose start is\n   * at or before it.\n   *\n   * @param {Array<{start_s: number, duration_s: number}>} blocks\n   * @param {number} t Seconds since the day's start.\n   * @returns {number} The block's index; -1 with no blocks.\n   */\n  function blockAt(blocks, t) {\n    if (!blocks.length) return -1;\n    for (let i = 0; i < blocks.length; i++) {\n      if (t < blocks[i].start_s + blocks[i].duration_s) return i;\n    }\n    return blocks.length - 1;\n  }\n\n  /**\n   * Where a block is at a second of the day, assuming an even pace through\n   * it: a fractional profile segment and a fractional line vertex. A stop\n   * stays where it is.\n   *\n   * @param {{kind: string, start_s: number, duration_s: number, from: number, to: number, point_from: number, point_to: number}} block\n   * @param {number} t Seconds since the day's start.\n   * @returns {{segment: number, vertex: number}}\n   */\n  function positionAt(block, t) {\n    if (block.kind === 'stop' || block.duration_s <= 0) {\n      return { segment: block.from, vertex: block.point_from };\n    }\n    const f = Math.min(Math.max((t - block.start_s) / block.duration_s, 0), 1);\n    return {\n      segment: block.from + f * (block.to - block.from),\n      vertex: block.point_from + f * (block.point_to - block.point_from),\n    };\n  }\n\n  /**\n   * The point a fractional vertex index falls on, between its two vertices.\n   *\n   * @param {Array<Array<number>>} coordinates The route's coordinates.\n   * @param {number} vertex A fractional index into them.\n   * @returns {?Array<number>} `[lon, lat]`, or null off the line.\n   */\n  function pointOnLine(coordinates, vertex) {\n    if (!coordinates.length || !(vertex >= 0)) return null;\n    const i = Math.min(Math.floor(vertex), coordinates.length - 1);\n    const j = Math.min(i + 1, coordinates.length - 1);\n    const f = vertex - i;\n    return [\n      coordinates[i][0] + (coordinates[j][0] - coordinates[i][0]) * f,\n      coordinates[i][1] + (coordinates[j][1] - coordinates[i][1]) * f,\n    ];\n  }\n\n  /**\n   * The map's mark: one point, or none.\n   *\n   * @param {?Array<number>} point `[lon, lat]`, or null to clear.\n   * @returns {FeatureCollection}\n   */\n  function markData(point) {\n    if (!point) return empty();\n    return {\n      type: 'FeatureCollection',\n      features: [{ type: 'Feature', geometry: { type: 'Point', coordinates: point }, properties: {} }],\n    };\n  }\n\n  /**\n   * Time since the day's start, as the readout beside Play shows it:\n   * hours and minutes, both two digits, so in the fixed-width face the\n   * readout never changes width during Play (Hugo, 24 Nov 2026: seconds\n   * are pointless and made it jump).\n   *\n   * @param {number} seconds\n   * @returns {string} \"HHhMMm\", such as \"01h33m\".\n   */\n  function elapsedLabel(seconds) {\n    const total = Math.floor(Math.max(seconds, 0));\n    const pad = (/** @type {number} */ n) => String(n).padStart(2, '0');\n    return pad(Math.floor(total / 3600)) + 'h' + pad(Math.floor(total / 60) % 60) + 'm';\n  }\n\n  /**\n   * A time of day, a number of seconds after the day's local start.\n   *\n   * @param {number} clockS The start, in seconds past local midnight.\n   * @param {number} offsetS Seconds after the start.\n   * @returns {string} \"H:MM\".\n   */\n  function clockLabel(clockS, offsetS) {\n    const minutes = Math.round((clockS + offsetS) / 60);\n    return (Math.floor(minutes / 60) % 24) + ':' + String(minutes % 60).padStart(2, '0');\n  }\n\n  /**\n   * The timeline's ticks: the start, each whole hour (or every other one,\n   * on a narrow screen) clear of the two ends, and the end.\n   *\n   * @param {number} clockS The start, in seconds past local midnight.\n   * @param {number} totalS The day's length.\n   * @param {number} stepH Hours between ticks: 1, or 2 when narrow.\n   * @param {function(number): number} [at] Where a second after the start\n   *   falls on the bar, 0 to 1; by the clock if left out. With the stops\n   *   squeezed, a tick too close to the one before it is dropped too.\n   * @returns {Array<{at: number, label: string}>} `at` is a share of the bar, 0 to 1.\n   */\n  function timelineTicks(clockS, totalS, stepH, at) {\n    if (!(totalS > 0)) return [];\n    const place = at || ((/** @type {number} */ offset) => offset / totalS);\n    const clear = 0.06 * stepH;\n    const ticks = [{ at: 0, label: clockLabel(clockS, 0) }];\n    let last = 0;\n    for (let h = Math.ceil(clockS / 3600); h * 3600 < clockS + totalS; h++) {\n      if (h % stepH) continue;\n      const offset = h * 3600 - clockS;\n      const x = place(offset);\n      if (x > clear && 1 - x > clear && x - last >= clear) {\n        ticks.push({ at: x, label: clockLabel(clockS, offset) });\n        last = x;\n      }\n    }\n    ticks.push({ at: 1, label: clockLabel(clockS, totalS) });\n    return ticks;\n  }\n\n  /** The gap between two blocks on the timeline, in its viewBox units. */\n  const BLOCK_GAP = 1.5;\n\n  /**\n   * A squeezed stop's drawn width, in pixels (Hugo, 24 Nov 2026: \"down to\n   * a single pixel (ish)\").\n   */\n  const SQUEEZED_STOP_PX = 2;\n\n  /**\n   * A squeezed stop's width in the timeline's 1000-wide viewBox, gap\n   * included, for a bar `barPx` wide on screen.\n   *\n   * @param {number} barPx The bar's width on screen.\n   * @returns {number} Viewbox units.\n   */\n  function squeezedStopWidth(barPx) {\n    return (SQUEEZED_STOP_PX * 1000) / (barPx > 0 ? barPx : 1000) + BLOCK_GAP;\n  }\n\n  /**\n   * Each block's place on the timeline, 0 to 1000. By the clock with no\n   * `stopW`; with one, every stop is `stopW` wide and the legs share the\n   * rest by their seconds (Skip stops). A day with no legs, or too many\n   * stops to fit, stays by the clock.\n   *\n   * @param {Array<{kind: string, start_s: number, duration_s: number}>} blocks\n   * @param {number} totalS The day's length.\n   * @param {?number} [stopW] A squeezed stop's width, or null.\n   * @returns {Array<{x: number, w: number}>} In the blocks' order.\n   */\n  function timelineLayout(blocks, totalS, stopW) {\n    let moving = 0;\n    let stops = 0;\n    blocks.forEach((block) => {\n      if (block.kind === 'stop') stops++;\n      else moving += block.duration_s;\n    });\n    const width = stopW && stopW > 0 ? stopW : 0;\n    const room = 1000 - stops * width;\n    if (!width || !(moving > 0) || !(room > 0)) {\n      const scale = totalS > 0 ? 1000 / totalS : 0;\n      return blocks.map((block) => ({ x: block.start_s * scale, w: block.duration_s * scale }));\n    }\n    let x = 0;\n    return blocks.map((block) => {\n      const w = block.kind === 'stop' ? width : (block.duration_s * room) / moving;\n      const place = { x: x, w: w };\n      x += w;\n      return place;\n    });\n  }\n\n  /**\n   * A layout part way from one to another, for the squeeze's animation.\n   *\n   * @param {Array<{x: number, w: number}>} from\n   * @param {Array<{x: number, w: number}>} to\n   * @param {number} f 0 is `from`, 1 is `to`.\n   * @returns {Array<{x: number, w: number}>}\n   */\n  function mixLayout(from, to, f) {\n    return from.map((a, i) => ({ x: a.x + (to[i].x - a.x) * f, w: a.w + (to[i].w - a.w) * f }));\n  }\n\n  /**\n   * Move the drawn blocks to a layout, each a little narrower than its\n   * place so a gap shows between two.\n   *\n   * @param {Array<Element>} rects The blocks' rects, as `drawTimeline` drew them.\n   * @param {Array<{x: number, w: number}>} layout\n   */\n  function placeTimeline(rects, layout) {\n    rects.forEach((rect, i) => {\n      rect.setAttribute('x', layout[i].x.toFixed(2));\n      rect.setAttribute('width', Math.max(layout[i].w - BLOCK_GAP, 1.5).toFixed(2));\n    });\n  }\n\n  /**\n   * Where a second of the day falls on the bar, 0 to 1000, in a layout: in\n   * its block, at its share of the block's seconds.\n   *\n   * @param {Array<{x: number, w: number}>} layout\n   * @param {Array<{start_s: number, duration_s: number}>} blocks\n   * @param {number} t Seconds since the day's start.\n   * @returns {number}\n   */\n  function timelineX(layout, blocks, t) {\n    const i = blockAt(blocks, t);\n    if (i < 0) return 0;\n    const block = blocks[i];\n    const f = block.duration_s > 0 ? Math.min(Math.max((t - block.start_s) / block.duration_s, 0), 1) : 0;\n    return layout[i].x + f * layout[i].w;\n  }\n\n  /**\n   * A second of the day with the stops skipped: one inside a stop moves on\n   * to the stop's end, the next leg's start.\n   *\n   * @param {Array<{kind: string, start_s: number, duration_s: number}>} blocks\n   * @param {number} t Seconds since the day's start.\n   * @returns {number}\n   */\n  function skipStop(blocks, t) {\n    let next = t;\n    for (let i = blockAt(blocks, next); i >= 0 && i < blocks.length; i++) {\n      const block = blocks[i];\n      const end = block.start_s + block.duration_s;\n      if (block.kind !== 'stop' || next >= end) break;\n      next = end;\n    }\n    return next;\n  }\n\n  /**\n   * The legs' seconds from the day's start up to `t`: the time the readout\n   * counts while the stops are skipped.\n   *\n   * @param {Array<{kind: string, start_s: number, duration_s: number}>} blocks\n   * @param {number} t Seconds since the day's start.\n   * @returns {number}\n   */\n  function movingSeconds(blocks, t) {\n    return blocks.reduce((sum, block) => {\n      if (block.kind === 'stop') return sum;\n      return sum + Math.min(Math.max(t - block.start_s, 0), block.duration_s);\n    }, 0);\n  }\n\n  /**\n   * The second of the day at which the legs have run `moving` seconds: in\n   * the leg that holds it, so a moving time at a stop's start falls at the\n   * next leg's start. Null once the legs are done.\n   *\n   * @param {Array<{kind: string, start_s: number, duration_s: number}>} blocks\n   * @param {number} moving The legs' seconds since the day's start.\n   * @returns {?number}\n   */\n  function clockAtMoving(blocks, moving) {\n    let sum = 0;\n    for (const block of blocks) {\n      if (block.kind === 'stop') continue;\n      if (moving < sum + block.duration_s) return block.start_s + Math.max(moving - sum, 0);\n      sum += block.duration_s;\n    }\n    return null;\n  }\n\n  /**\n   * Where the day's last leg ends, in seconds since its start: the end of\n   * Play with the stops skipped, ahead of any stop the day ends in.\n   *\n   * @param {Array<{kind: string, start_s: number, duration_s: number}>} blocks\n   * @returns {number} 0 with no legs.\n   */\n  function lastLegEnd(blocks) {\n    let end = 0;\n    blocks.forEach((block) => {\n      if (block.kind !== 'stop') end = Math.max(end, block.start_s + block.duration_s);\n    });\n    return end;\n  }\n\n  /**\n   * Draw the timeline's blocks into its SVG (a 1000-wide viewBox): a leg in\n   * its colour, a stop hatched (`.explorer-timeline-block`, main.css), at\n   * their places in `layout`, or by the clock.\n   *\n   * @param {Element} svg The `[data-explorer-timeline-bar]` element.\n   * @param {Array<{kind: string, start_s: number, duration_s: number}>} blocks\n   * @param {number} totalS The day's length.\n   * @param {Array<{x: number, w: number}>} [layout] From `timelineLayout`.\n   * @returns {Array<Element>} The block rects, in the blocks' order.\n   */\n  function drawTimeline(svg, blocks, totalS, layout) {\n    const ns = 'http://www.w3.org/2000/svg';\n    svg.querySelectorAll('[data-timeline-block]').forEach((el) => el.remove());\n    const rects = blocks.map((block, i) => {\n      const rect = svg.ownerDocument.createElementNS(ns, 'rect');\n      const stop = block.kind === 'stop';\n      rect.setAttribute('y', stop ? '4' : '0');\n      rect.setAttribute('height', stop ? '22' : '30');\n      rect.setAttribute('rx', '2');\n      rect.setAttribute('class', 'explorer-timeline-block');\n      rect.setAttribute('data-kind', block.kind);\n      rect.setAttribute('data-timeline-block', String(i));\n      svg.appendChild(rect);\n      return rect;\n    });\n    placeTimeline(rects, layout || timelineLayout(blocks, totalS, null));\n    return rects;\n  }\n\n  /**\n   * The day played back, `totalS` seconds in `playMs` milliseconds, one\n   * frame at a time. Play from the end starts again; the end pauses.\n   *\n   * `step`, if given, works out each frame's second from the last one and\n   * the milliseconds between them, in place of the even `totalS / playMs`:\n   * Skip stops paces the legs alone and jumps each stop.\n   *\n   * @param {{totalS: number, playMs?: number, onFrame: function(number): void,\n   *   onState?: function(boolean): void, raf?: function(FrameRequestCallback): number,\n   *   cancel?: function(number): void, step?: function(number, number): number}} options\n   * @returns {{play: function(): void, pause: function(): void, toggle: function(): void,\n   *   playing: function(): boolean, reset: function(): void, time: function(): number,\n   *   seek: function(number): void}}\n   */\n  function createPlayback(options) {\n    const raf = options.raf || ((cb) => requestAnimationFrame(cb));\n    const cancel = options.cancel || ((id) => cancelAnimationFrame(id));\n    const rate = options.totalS / (options.playMs || PLAY_MS);\n    const step = options.step || ((/** @type {number} */ at, /** @type {number} */ ms) => at + ms * rate);\n    let t = 0;\n    let playing = false;\n    /** @type {?number} */\n    let last = null;\n    let frameId = 0;\n    /** @param {number} now */\n    function frame(now) {\n      if (!playing) return;\n      t = Math.min(step(t, last === null ? 0 : now - last), options.totalS);\n      last = now;\n      options.onFrame(t);\n      if (t >= options.totalS) {\n        pause();\n        return;\n      }\n      frameId = raf(frame);\n    }\n    function play() {\n      if (playing) return;\n      if (t >= options.totalS) t = 0;\n      playing = true;\n      last = null;\n      if (options.onState) options.onState(true);\n      frameId = raf(frame);\n    }\n    function pause() {\n      if (!playing) return;\n      playing = false;\n      cancel(frameId);\n      if (options.onState) options.onState(false);\n    }\n    return {\n      play: play,\n      pause: pause,\n      toggle() {\n        if (playing) pause();\n        else play();\n      },\n      playing() {\n        return playing;\n      },\n      reset() {\n        pause();\n        t = 0;\n      },\n      time() {\n        return t;\n      },\n      /** @param {number} at */\n      seek(at) {\n        t = Math.min(Math.max(at, 0), options.totalS);\n      },\n    };\n  }\n\n  /** The largest smallest-leg height the control asks for, as the server's MIN_LEG_MAX_M. */\n  var MIN_LEG_MAX_M = 500;\n\n  /**\n   * The staff \"Smallest leg\" control's next value (Hugo, 23 Nov 2026): one\n   * step on, never below 0 or above MIN_LEG_MAX_M.\n   *\n   * @param {number} current The height now, in metres.\n   * @param {number} step The button's step, such as 5 or -5.\n   * @returns {number} The next height, a whole number of metres.\n   */\n  function nextMinLeg(current, step) {\n    var next = Math.round((Number(current) || 0) + step);\n    return Math.min(Math.max(next, 0), MIN_LEG_MAX_M);\n  }\n\n  /**\n   * @typedef {{start_s: number, duration_s: number, leg: ?number}} TimelineBlock\n   * @typedef {{from: ?string, to: ?string}} TrimSpan\n   * @typedef {{from: ?string, to: ?string, startLegs: number, endLegs: number}} TrimState\n   */\n\n  /**\n   * The window of time left once the day's first or last leg is removed\n   * (SNOW-1560).\n   *\n   * @param {Array<Object>} rows The payload's `breakdown`: the legs.\n   * @param {Array<TimelineBlock>} blocks The payload's timeline blocks,\n   *   each with its leg's index in `rows` (null for a stop).\n   * @param {?string} startedAt The payload's `started_at`, which the\n   *   blocks' seconds count from.\n   * @param {?TrimSpan} current The window in force, or null: its other\n   *   side is kept.\n   * @param {'start'|'end'} end Which end's leg goes.\n   * @returns {?{from: string, to: string}} The next window, as ISO\n   *   instants; null with one leg left, no timeline or no start.\n   */\n  function trimWindow(rows, blocks, startedAt, current, end) {\n    const count = Array.isArray(rows) ? rows.length : 0;\n    if (end === 'start') return keepWindow(rows, blocks, startedAt, current, 1, count - 1);\n    if (end === 'end') return keepWindow(rows, blocks, startedAt, current, 0, count - 2);\n    return null;\n  }\n\n  /**\n   * The run of legs an edit in the leg's \u22EF menu keeps (Hugo, 24 Nov\n   * 2026). Every edit cuts from the ends, so what is left is one piece.\n   *\n   * @param {string} action \"self\" (the first or last leg goes), \"others\"\n   *   (every other leg goes), \"before\" (the legs before it go) or \"after\"\n   *   (the legs after it go).\n   * @param {number} index The leg's place in the breakdown.\n   * @param {number} count How many legs the day has.\n   * @returns {?{from: number, to: number}} The first and last legs kept;\n   *   null for an edit that keeps nothing, removes nothing, or would cut\n   *   the middle out of the day.\n   */\n  function trimKeep(action, index, count) {\n    if (!Number.isInteger(index) || !Number.isInteger(count)) return null;\n    if (count < 2 || index < 0 || index >= count) return null;\n    const last = count - 1;\n    /** @type {?{from: number, to: number}} */\n    let keep = null;\n    if (action === 'self' && index === 0) keep = { from: 1, to: last };\n    else if (action === 'self' && index === last) keep = { from: 0, to: last - 1 };\n    else if (action === 'others') keep = { from: index, to: index };\n    else if (action === 'before') keep = { from: index, to: last };\n    else if (action === 'after') keep = { from: 0, to: index };\n    if (!keep || (keep.from === 0 && keep.to === last)) return null;\n    return keep;\n  }\n\n  /**\n   * The window of time a run of legs spans (Hugo, 24 Nov 2026): from the\n   * first kept leg's first block to the last kept leg's last block. An\n   * end that is not cut keeps the window in force there, or the day's own\n   * start or end.\n   *\n   * @param {Array<Object>} rows The payload's `breakdown`: the legs.\n   * @param {Array<TimelineBlock>} blocks The payload's timeline blocks.\n   * @param {?string} startedAt The payload's `started_at`.\n   * @param {?TrimSpan} current The window in force, or null.\n   * @param {number} keepFrom The first leg kept, an index in `rows`.\n   * @param {number} keepTo The last leg kept.\n   * @returns {?{from: string, to: string}} The window, as ISO instants;\n   *   null when the run is not a strict part of the day, or there is no\n   *   timeline or no start.\n   */\n  function keepWindow(rows, blocks, startedAt, current, keepFrom, keepTo) {\n    if (!Array.isArray(rows) || rows.length < 2) return null;\n    if (!Number.isInteger(keepFrom) || !Number.isInteger(keepTo)) return null;\n    if (keepFrom < 0 || keepTo >= rows.length || keepFrom > keepTo) return null;\n    if (keepFrom === 0 && keepTo === rows.length - 1) return null;\n    if (!Array.isArray(blocks) || !blocks.length || !startedAt) return null;\n    const t0 = Date.parse(startedAt);\n    if (!Number.isFinite(t0)) return null;\n    /** @param {number} s */\n    const at = (s) => new Date(t0 + s * 1000).toISOString();\n    const kept = blocks.filter((block) => block.leg !== null && block.leg !== undefined\n      && /** @type {number} */ (block.leg) >= keepFrom\n      && /** @type {number} */ (block.leg) <= keepTo);\n    if (!kept.length) return null;\n    const last = blocks[blocks.length - 1];\n    const final = kept[kept.length - 1];\n    return {\n      from: keepFrom > 0\n        ? at(kept[0].start_s)\n        : (current && current.from) || at(blocks[0].start_s),\n      to: keepTo < rows.length - 1\n        ? at(final.start_s + final.duration_s)\n        : (current && current.to) || at(last.start_s + last.duration_s),\n    };\n  }\n\n  /** @returns {TrimState} */\n  function untrimmed() {\n    return { from: null, to: null, startLegs: 0, endLegs: 0 };\n  }\n\n  /**\n   * The trim's state (SNOW-1560): the window, the legs taken off each\n   * end, and an Undo stack of whole states, written to the drop zone\n   * form's hidden fields on every change.\n   *\n   * @param {{from?: ?HTMLInputElement, to?: ?HTMLInputElement, startLegs?: ?HTMLInputElement, endLegs?: ?HTMLInputElement}} fields\n   */\n  function createTrim(fields) {\n    let state = untrimmed();\n    /** @type {Array<TrimState>} */\n    let stack = [];\n\n    function isTrimmed() {\n      return state.startLegs + state.endLegs > 0;\n    }\n\n    function write() {\n      const on = isTrimmed();\n      /** @type {Array<[keyof TrimState, string]>} */\n      const values = [\n        ['from', on ? state.from || '' : ''],\n        ['to', on ? state.to || '' : ''],\n        ['startLegs', on ? String(state.startLegs) : ''],\n        ['endLegs', on ? String(state.endLegs) : ''],\n      ];\n      for (const [key, value] of values) {\n        const field = fields[key];\n        if (field) field.value = value;\n      }\n    }\n\n    return {\n      /**\n       * Take one more leg off an end, to the window `trimWindow` gave.\n       *\n       * @param {?{from: string, to: string}} next The window.\n       * @param {'start'|'end'} end Which end.\n       * @returns {boolean} False, and nothing changed, with no window.\n       */\n      remove(next, end) {\n        if (end !== 'start' && end !== 'end') return false;\n        return this.cut(next, end === 'start' ? 1 : 0, end === 'end' ? 1 : 0);\n      },\n      /**\n       * Take any number of legs off either end in one step, to the window\n       * `keepWindow` gave (Hugo, 24 Nov 2026): one Undo puts them all back.\n       *\n       * @param {?{from: string, to: string}} next The window.\n       * @param {number} startLegs Legs taken off the start.\n       * @param {number} endLegs Legs taken off the end.\n       * @returns {boolean} False, and nothing changed, with no window or\n       *   no leg taken off.\n       */\n      cut(next, startLegs, endLegs) {\n        if (!next || !Number.isInteger(startLegs) || !Number.isInteger(endLegs)) return false;\n        if (startLegs < 0 || endLegs < 0 || startLegs + endLegs === 0) return false;\n        stack.push(state);\n        state = {\n          from: next.from,\n          to: next.to,\n          startLegs: state.startLegs + startLegs,\n          endLegs: state.endLegs + endLegs,\n        };\n        write();\n        return true;\n      },\n      /**\n       * Put the last removed leg back.\n       *\n       * @returns {boolean} False with nothing to undo.\n       */\n      undo() {\n        const previous = stack.pop();\n        if (!previous) return false;\n        state = previous;\n        write();\n        return true;\n      },\n      /** Forget the trim and its Undo, and empty the fields. */\n      clear() {\n        state = untrimmed();\n        stack = [];\n        write();\n      },\n      /** @returns {TrimState} A copy of the state in force. */\n      state() {\n        return Object.assign({}, state);\n      },\n      isTrimmed: isTrimmed,\n    };\n  }\n\n  /**\n   * Tell a file the visitor chose from the page posting the same file\n   * again (SNOW-1560): a new file must not inherit the last one's trim.\n   *\n   * @param {HTMLInputElement} input The drop zone's file input.\n   * @param {function(): void} onFresh Called on a change the page did not make.\n   * @returns {{repost: function(): void, unbind: function(): void}} `repost`\n   *   posts the file again, through the form's `change`, without onFresh.\n   */\n  function bindFreshFile(input, onFresh) {\n    let reposting = false;\n    const onChange = () => {\n      if (!reposting) onFresh();\n    };\n    input.addEventListener('change', onChange);\n    return {\n      repost() {\n        reposting = true;\n        try {\n          input.dispatchEvent(new Event('change', { bubbles: true }));\n        } finally {\n          reposting = false;\n        }\n      },\n      unbind() {\n        input.removeEventListener('change', onChange);\n      },\n    };\n  }\n\n  /**\n   * Ask, with the browser's own dialog, before Start again clears the\n   * day (Hugo, 24 Nov 2026): it throws away the file on the page and any\n   * trim, which only the visitor's copy can bring back.\n   *\n   * @param {string} message The dialog's text.\n   * @returns {boolean} True to go ahead; also true where the browser has\n   *   no `confirm` to ask with.\n   */\n  function confirmStartAgain(message) {\n    if (typeof self.confirm !== 'function') return true;\n    return self.confirm(message);\n  }\n\n  /** The keys that move about the page, and so show the focus ring. */\n  const FOCUS_KEYS = new Set(['Tab', 'ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Home', 'End']);\n\n  /**\n   * Whether a key press is the keyboard moving about the page, so the\n   * profile's focus ring should show (Hugo, 24 Nov 2026). A shortcut\n   * held with Cmd, Ctrl or Alt, such as a screenshot's, is not.\n   *\n   * @param {KeyboardEvent} event\n   * @returns {boolean}\n   */\n  function movesFocus(event) {\n    if (event.metaKey || event.ctrlKey || event.altKey) return false;\n    return FOCUS_KEYS.has(event.key);\n  }\n\n  self.pwaExplorerCore = Object.freeze({\n    ROUTE_PREFIX: ROUTE_PREFIX,\n    MAP_PICK_TOLERANCE_PX: MAP_PICK_TOLERANCE_PX,\n    SWAPPED_ERROR_STATUSES: SWAPPED_ERROR_STATUSES,\n    BACKDROP_VIEW: BACKDROP_VIEW,\n    backdropOptions: backdropOptions,\n    collapseAttribution: collapseAttribution,\n    readPayload: readPayload,\n    fitBoundsFor: fitBoundsFor,\n    maxBoundsFor: maxBoundsFor,\n    drawingCollection: drawingCollection,\n    drawingSourceData: drawingSourceData,\n    installRoute: installRoute,\n    nextDropState: nextDropState,\n    dropLabel: dropLabel,\n    keepsFile: keepsFile,\n    HIGHLIGHT_SOURCE: HIGHLIGHT_SOURCE,\n    HIGHLIGHT_HALO: HIGHLIGHT_HALO,\n    MARK_COLOUR: MARK_COLOUR,\n    LEG_COLOURS: LEG_COLOURS,\n    FADE_OPACITY: FADE_OPACITY,\n    fadeRoute: fadeRoute,\n    scaledOpacity: scaledOpacity,\n    liftSourceData: liftSourceData,\n    highlightData: highlightData,\n    highlightRow: highlightRow,\n    legAtSegment: legAtSegment,\n    legAtLineSegment: legAtLineSegment,\n    nearestSegment: nearestSegment,\n    createLegSelection: createLegSelection,\n    showLegCard: showLegCard,\n    bindProfilePick: bindProfilePick,\n    stepLeg: stepLeg,\n    bindProfileKeys: bindProfileKeys,\n    saveFile: saveFile,\n    MARK_SOURCE: MARK_SOURCE,\n    PLAY_MS: PLAY_MS,\n    showCard: showCard,\n    blockAt: blockAt,\n    leaderBand: leaderBand,\n    leaderPaths: leaderPaths,\n    positionAt: positionAt,\n    pointOnLine: pointOnLine,\n    markData: markData,\n    elapsedLabel: elapsedLabel,\n    clockLabel: clockLabel,\n    timelineTicks: timelineTicks,\n    drawTimeline: drawTimeline,\n    SQUEEZED_STOP_PX: SQUEEZED_STOP_PX,\n    squeezedStopWidth: squeezedStopWidth,\n    timelineLayout: timelineLayout,\n    mixLayout: mixLayout,\n    placeTimeline: placeTimeline,\n    timelineX: timelineX,\n    skipStop: skipStop,\n    movingSeconds: movingSeconds,\n    clockAtMoving: clockAtMoving,\n    lastLegEnd: lastLegEnd,\n    createPlayback: createPlayback,\n    MIN_LEG_MAX_M: MIN_LEG_MAX_M,\n    nextMinLeg: nextMinLeg,\n    trimWindow: trimWindow,\n    trimKeep: trimKeep,\n    keepWindow: keepWindow,\n    createTrim: createTrim,\n    bindFreshFile: bindFreshFile,\n    confirmStartAgain: confirmStartAgain,\n    movesFocus: movesFocus,\n  });\n})();\n"],
  "mappings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ACV,aAAcE,GACd,WAAYI,EACZ,cAAeI,GACf,aAAc8B,GACd,iBAAkBtB,EAClB,kBAAmBC,GACnB,eAAgBE,EAChB,UAAWO,GACX,cAAeG,EACf,UAAWG,GACX,SAAUC,GACV,cAAeC,GACf,cAAeE,GACf,WAAYC,GACZ,eAAgBK,GAChB,cAAeY,EACf,WAAYC,GACZ,WAAYC,GACZ,SAAUI,GACV,WAAYD,EACZ,WAAYW,GACZ,cAAeW,GACf,kBAAmBI,GACnB,WAAYG,EACd,CAAC,CACH,GAAG",
  "names": ["ROUTE_PREFIX", "HIGHLIGHT_SOURCE", "HIGHLIGHT_HALO", "MARK_COLOUR", "LEG_COLOURS", "FADE_OPACITY", "FADED_PAINT", "unfaded", "MARK_SOURCE", "DAY_LAYER_IDS", "PLAY_MS", "MAP_PICK_TOLERANCE_PX", "SWAPPED_ERROR_STATUSES", "BACKDROP_VIEW", "empty", "readPayload", "doc", "id", "el", "parsed", "isBbox", "bounds", "value", "fitBoundsFor", "maxBoundsFor", "area", "drawingCollection", "feature", "coordinates", "properties", "unsampled", "collection", "drawingSourceData", "drawing", "data", "installRoute", "map", "sources", "liftSourceData", "key", "options", "marks", "layer", "dayLayers", "layout", "lifts", "highlightData", "row", "first", "last", "line", "highlightRow", "view", "source", "fadeRoute", "scaledOpacity", "factor", "out", "scale", "faded", "saved", "property", "style", "before", "backdropOptions", "container", "collapseAttribution", "fold", "credits", "nextDropState", "state", "event", "dropLabel", "strings", "keepsFile", "status", "legAtSegment", "rows", "index", "at", "legAtLineSegment", "i", "nearestSegment", "points", "tap", "tolerance", "best", "bestDistance", "a", "b", "dx", "dy", "length", "t", "ex", "ey", "distance", "createLegSelection", "onChange", "current", "next", "showLegCard", "root", "showCard", "bindProfilePick", "lane", "onIndex", "onClick", "stepLeg", "step", "legs", "bindProfileKeys", "selection", "label", "onKey", "saveFile", "file", "url", "link", "target", "shown", "kinds", "attr", "want", "card", "match", "hint", "leaderPaths", "x", "height", "mid", "down", "top", "bottom", "up", "leaderBand", "leg", "blocks", "sampleCount", "totalS", "mine", "block", "start", "end", "clamp", "n", "blockAt", "positionAt", "f", "pointOnLine", "vertex", "j", "markData", "point", "elapsedLabel", "seconds", "total", "pad", "clockLabel", "clockS", "offsetS", "minutes", "timelineTicks", "stepH", "place", "offset", "clear", "ticks", "h", "BLOCK_GAP", "SQUEEZED_STOP_PX", "squeezedStopWidth", "barPx", "timelineLayout", "stopW", "moving", "stops", "width", "room", "w", "mixLayout", "from", "to", "placeTimeline", "rects", "rect", "timelineX", "skipStop", "movingSeconds", "sum", "clockAtMoving", "lastLegEnd", "drawTimeline", "svg", "ns", "stop", "createPlayback", "raf", "cb", "cancel", "rate", "ms", "playing", "frameId", "frame", "now", "pause", "play", "MIN_LEG_MAX_M", "nextMinLeg", "trimWindow", "startedAt", "count", "keepWindow", "trimKeep", "action", "keep", "keepFrom", "keepTo", "t0", "s", "kept", "final", "untrimmed", "createTrim", "fields", "stack", "isTrimmed", "write", "on", "values", "field", "startLegs", "endLegs", "previous", "bindFreshFile", "input", "onFresh", "reposting", "confirmStartAgain", "message", "FOCUS_KEYS", "movesFocus"]
}
