{
  "version": 3,
  "sources": ["map_3d_flight.js"],
  "sourcesContent": ["// @ts-check\n/*\n * static/js/map_3d_flight.js \u2014 a 3D fly-past on /map/ (SNOW-1466).\n *\n * Loaded after map_view_3d.js, for a reader in the map_3d flag\n * (public/map.html). It flies the camera along a route through /map/'s own\n * 3D view, one frame at a time, so the promo video's recorder\n * (bin/record-3d-flyby) can screenshot each frame once its tiles are in\n * (docs/decisions/a-fly-past-is-rendered-frame-by-frame.md). The path\n * itself is map_3d_flight_core.js; this is only the part that needs a map.\n *\n * Publishes window.pwaMap3dFlight:\n *\n *   load(geojson, options = {}) \u2014 builds the flight from the first\n *     LineString or MultiLineString in a Feature, FeatureCollection or\n *     bare geometry, with options.flight merged over the feature's\n *     properties.flight as the core's options. Enters 3D through\n *     window.pwaMapView.beginTest(), which saves the camera and the view and\n *     rests the watchdog, and throws if 3D cannot be entered here, naming\n *     canTest()'s reason. Adds the `map-3d-flight` source and its casing,\n *     line and head layers on top, in the route colours\n *     window.pwaRouteDrawingCore publishes. options.chrome = false sets\n *     body.map-recording, which lays the map over the whole page with no\n *     controls (src/css/main.css); the default leaves the page alone.\n *   frame(t) \u2014 draws the frame t of the way through (0..1) and resolves\n *     with its phase once the map is idle with every tile loaded (or every\n *     tile has stayed loaded for QUIET_MS, for a camera where MapLibre\n *     never goes idle), jumping\n *     a second time if MapLibre moved the camera to keep it out of ground\n *     whose height had not loaded yet. If that\n *     has not happened within FRAME_CAP_MS (or load's options.capMs, which\n *     the recorder raises for software rendering) it rejects, so a half-loaded\n *     frame cannot reach a video. A reveal frame fits the route's bounds\n *     with map.cameraForBounds at the core's pitch and bearing, and blends\n *     the centre and zoom towards that by the frame's fit weight.\n *   unload() \u2014 removes the layers and the source, clears map-recording\n *     and puts the view and camera back (pwaMapView.endTest()).\n *\n * SNOW-1549 adds a live flight beside the recorder's, to measure how well a\n * device keeps up with one (docs/research/live-3d-flight/README.md). The\n * recorder's load / frame / unload are unchanged.\n *\n *   play({seconds, preload}) \u2014 plays the loaded flight in real time: each\n *     animation frame takes its t from map_3d_flight_play_core.js's clock\n *     (seconds defaults to the flight's own), draws the line every\n *     LINE_EVERY_N frames and jumps the camera to cameraFor(frame), with\n *     thawElevation first. It never waits for tiles and never jumps twice:\n *     a frame drawn with tiles missing is what it measures. Re-enters 3D\n *     through pwaMapView.beginTest() after a stop. With preload it first\n *     eases the camera over the route at the follow zoom and pitch, one\n *     stop per vector tile the line crosses, waiting at each for its tiles,\n *     so MapLibre's own cache holds them before the flight starts. The\n *     whole preload gives up after PRELOAD_DEADLINE_MS and the flight\n *     starts anyway, with preloadTimedOut in its stats; a preload that\n *     throws ends the flight with reason `failed` and the error.\n *     Resolves with stats() once the flight stops.\n *   stop({reason}) \u2014 ends a playing flight: the loop and its listeners go,\n *     and pwaMapView.endTest({keepCamera: true}) leaves the camera where it\n *     is. Only a mousedown, touchstart or wheel on the map's canvas\n *     container, or Escape, stops it early (reason `user`); the end stops\n *     it with reason `end`. Each stop records one `map 3d.flight` line in\n *     window.pwaDebugLog with stats().\n *   stats() \u2014 the flight's figures so far: frames drawn; the median and\n *     p95 frame time, by map_3d_core.frameStats over every animation-frame\n *     interval of the flight, all four phases; the share of follow-phase\n *     frames only drawn while !map.areTilesLoaded(); whether it preloaded,\n *     the preload's tile count and time, and whether it timed out.\n *\n * THE LINK. `/map/?fly=verbier` (and `&preload=1`) plays one lift and one\n * run from the Verbier lift-served day (static/flyby/verbier-one-run.geojson,\n * 8.2 km) once the map has loaded, for as long as\n * pwaMap3dFlightPlayCore.secondsFromLength gives its length (about 30 s). It needs the debug log (the debug_log flag),\n * where the figures land: without window.pwaDebugLog it warns in the\n * console and does not fly; with recording off it turns it on and records\n * a `3d.flight.recording` line saying so. A device canTest() refuses gets a\n * `3d.flight.refused` line with the reason, and no flight. The script loads\n * only for the map_3d flag, so outside it the link does nothing. It plays\n * under prefers-reduced-motion too: it is a staff measurement.\n *\n * The page shows no words of its own, so nothing here is translated.\n */\n(function map3dFlightInit() {\n  'use strict';\n\n  const core = self.pwaMap3dFlightCore;\n  const playCore = self.pwaMap3dFlightPlayCore;\n  const mapState = window.snowdeskMapState;\n  const map = mapState ? mapState.map : null;\n  if (!core || !map) return;\n  /** The script tag, for the fixture's URL the page stamps on it. */\n  const script = /** @type {?HTMLScriptElement} */ (document.currentScript);\n\n  /** The flight's source and its layers, bottom to top. */\n  const SOURCE_ID = 'map-3d-flight';\n  const LAYER_IDS = Object.freeze(['map-3d-flight-casing', 'map-3d-flight-line', 'map-3d-flight-head']);\n  /** How long a frame may take to settle before it fails. */\n  const FRAME_CAP_MS = 60000;\n  /**\n   * A frame whose tiles have all stayed in this long has settled, though\n   * the map never goes idle (settled()); checked this often.\n   */\n  const QUIET_MS = 500;\n  const QUIET_POLL_MS = 250;\n  /** Room left round the route when the reveal fits it, in CSS pixels. */\n  const REVEAL_PADDING = 120;\n  /** The body class a recording sets. */\n  const RECORDING_CLASS = 'map-recording';\n  /** A live flight sets the drawn line's data every this many frames. */\n  const LINE_EVERY_N = 1;\n  /** The routes `?fly=` names, as the data attribute holding each URL. */\n  const LINK_ROUTES = Object.freeze({ verbier: 'flyVerbier' });\n  /** Where the Verbier route is when the page stamps no URL on the script. */\n  const VERBIER_FALLBACK_URL = '/static/flyby/verbier-one-run.geojson';\n  /** How long the preload waits at one stop for its tiles. */\n  const PRELOAD_STOP_CAP_MS = 15000;\n  /** How long the whole preload may take before the flight starts anyway. */\n  const PRELOAD_DEADLINE_MS = 30000;\n  /** How long one preload ease takes, and how often a stop checks its tiles. */\n  const PRELOAD_EASE_MS = 300;\n  const PRELOAD_POLL_MS = 100;\n\n  /** @type {any} The flight loaded now, if one is. */\n  let flight = null;\n  /** @type {any} The source's data for the last frame drawn. */\n  let lastData = null;\n  /** How long a frame may take to settle for this flight. */\n  let capMs = FRAME_CAP_MS;\n  /** Whether the map is in pwaMapView's test for the flight now. */\n  let inTest = false;\n  /**\n   * The live flight playing now, if one is.\n   *\n   * @type {?{\n   *   clock: any, raf: number, lastNow: ?number, intervals: number[],\n   *   frames: number, followFrames: number, followMissing: number,\n   *   preloaded: boolean, preloadTiles: number, preloadMs: number,\n   *   preloadTimedOut: boolean,\n   *   seconds: number, playing: boolean, finish: (stats: any) => void,\n   * }}\n   */\n  let live = null;\n  /** The figures of the last live flight, once it has stopped. */\n  let lastStats = /** @type {any} */ (null);\n\n  /**\n   * The first line in a GeoJSON object, as {coords, properties}.\n   *\n   * @param {any} geojson\n   * @returns {{coords: any, properties: any} | null}\n   */\n  function firstLine(geojson) {\n    if (!geojson || typeof geojson !== 'object') return null;\n    if (geojson.type === 'FeatureCollection') {\n      for (const feature of geojson.features || []) {\n        const found = firstLine(feature);\n        if (found) return found;\n      }\n      return null;\n    }\n    if (geojson.type === 'Feature') {\n      const found = firstLine(geojson.geometry);\n      return found ? { coords: found.coords, properties: geojson.properties || {} } : null;\n    }\n    if (geojson.type === 'LineString' || geojson.type === 'MultiLineString') {\n      return { coords: geojson.coordinates, properties: {} };\n    }\n    return null;\n  }\n\n  /** The route colours, from the module that owns them. */\n  function colours() {\n    const routeCore = /** @type {any} */ (window).pwaRouteDrawingCore;\n    if (!routeCore) throw new Error('pwaRouteDrawingCore is not loaded');\n    return { line: routeCore.ROUTE_LINE_COLOUR, casing: routeCore.ROUTE_CASING_COLOUR };\n  }\n\n  /** Take the flight's layers and source off the map, if they are there. */\n  function removeLayers() {\n    for (const id of [...LAYER_IDS].reverse()) if (map.getLayer(id)) map.removeLayer(id);\n    if (map.getSource(SOURCE_ID)) map.removeSource(SOURCE_ID);\n  }\n\n  /** Put the flight's source and layers on the map, on top. */\n  function addLayers() {\n    removeLayers();\n    const { line, casing } = colours();\n    map.addSource(SOURCE_ID, { type: 'geojson', data: { type: 'FeatureCollection', features: [] } });\n    const isLine = ['==', ['geometry-type'], 'LineString'];\n    map.addLayer({\n      id: LAYER_IDS[0], type: 'line', source: SOURCE_ID, filter: isLine,\n      layout: { 'line-cap': 'round', 'line-join': 'round' },\n      paint: { 'line-color': casing, 'line-width': 9, 'line-opacity': 0.8 },\n    });\n    map.addLayer({\n      id: LAYER_IDS[1], type: 'line', source: SOURCE_ID, filter: isLine,\n      layout: { 'line-cap': 'round', 'line-join': 'round' },\n      paint: { 'line-color': line, 'line-width': 5.5 },\n    });\n    map.addLayer({\n      id: LAYER_IDS[2], type: 'circle', source: SOURCE_ID, filter: ['==', ['geometry-type'], 'Point'],\n      paint: {\n        'circle-radius': 7,\n        'circle-color': line,\n        'circle-stroke-color': '#ffffff',\n        'circle-stroke-width': 3,\n        'circle-pitch-alignment': 'map',\n      },\n    });\n  }\n\n  /**\n   * Put the layers back if a setStyle took them, and draw the last frame's\n   * data. Entering 3D from another basemap swaps the style after load()\n   * has added the layers, and the swap wipes them (SNOW-1466).\n   */\n  function draw() {\n    if (!flight) return;\n    if (!map.getSource(SOURCE_ID)) {\n      try {\n        addLayers();\n      } catch (_err) {\n        // The new style is still loading; its style.load draws again.\n        return;\n      }\n    }\n    const source = map.getSource(SOURCE_ID);\n    if (source && lastData) source.setData(lastData);\n  }\n\n  /**\n   * The source's data for a frame: the drawn line, if there is one, and the head.\n   *\n   * @param {any} frame\n   */\n  function frameData(frame) {\n    const features = [];\n    if (frame.drawn.length >= 2) {\n      features.push({ type: 'Feature', properties: {}, geometry: { type: 'LineString', coordinates: frame.drawn } });\n    }\n    features.push({ type: 'Feature', properties: {}, geometry: { type: 'Point', coordinates: frame.head } });\n    return { type: 'FeatureCollection', features };\n  }\n\n  /**\n   * The camera to jump to for a frame: the core's, or in the reveal its\n   * blend towards the fitted bounds.\n   *\n   * @param {any} frame\n   * @returns {{center: [number, number], zoom: number, pitch: number, bearing: number}}\n   */\n  function cameraFor(frame) {\n    const cam = frame.camera;\n    if (!frame.fit || frame.fit.weight <= 0) return cam;\n    const fitted = map.cameraForBounds(frame.fit.bounds, {\n      padding: REVEAL_PADDING, pitch: cam.pitch, bearing: cam.bearing,\n    });\n    if (!fitted) return cam;\n    const c = fitted.center;\n    const centre = Array.isArray(c) ? c : [c.lng, c.lat];\n    const w = frame.fit.weight;\n    return {\n      center: [cam.center[0] + (centre[0] - cam.center[0]) * w, cam.center[1] + (centre[1] - cam.center[1]) * w],\n      zoom: cam.zoom + (fitted.zoom - cam.zoom) * w,\n      pitch: cam.pitch,\n      bearing: cam.bearing,\n    };\n  }\n\n  /**\n   * Let MapLibre read the centre's height again.\n   *\n   * MapLibre 4.7 sets `_elevationFreeze` when a camera ease starts over\n   * terrain and clears it only at the end of an ease asked to freeze, or of a\n   * gesture. After any other ease over terrain (the page's own camera\n   * moves) it stays set, so the centre keeps the height it had then, and a\n   * jump to the route draws the camera at that height: under the mountain,\n   * the ground streaked and the sky missing. A reader's first drag clears\n   * it; a recording makes none.\n   * The property is MapLibre's own, so this is checked against the vendored\n   * version (static/js/maplibre-gl.min.js) and does nothing if it is gone.\n   */\n  function thawElevation() {\n    const internal = /** @type {any} */ (map);\n    if (internal._elevationFreeze === true) internal._elevationFreeze = false;\n  }\n\n  /**\n   * Whether the map's pitch or zoom is not the camera it was sent to.\n   *\n   * @param {{zoom: number, pitch: number}} camera\n   * @returns {boolean}\n   */\n  function drifted(camera) {\n    return Math.abs(map.getPitch() - camera.pitch) > 0.01 || Math.abs(map.getZoom() - camera.zoom) > 0.001;\n  }\n\n  /**\n   * Whether every source in the style has all its tiles in.\n   *\n   * @returns {boolean}\n   */\n  function tilesIn() {\n    const style = map.getStyle();\n    const ids = Object.keys((style && style.sources) || {});\n    return ids.every((id) => map.isSourceLoaded(id)) && map.areTilesLoaded();\n  }\n\n  /**\n   * What a frame that has not settled is still waiting for, for its error:\n   * the sources with tiles still loading, then the map's own state.\n   *\n   * @param {{renders: number, idles: number}} seen Events since the jump.\n   * @returns {string}\n   */\n  function waitingOn(seen) {\n    const style = map.getStyle();\n    const loading = Object.keys((style && style.sources) || {}).filter((id) => !map.isSourceLoaded(id));\n    const state = `loaded=${map.loaded()} moving=${map.isMoving()} tiles=${map.areTilesLoaded()}`\n      + ` renders=${seen.renders} idles=${seen.idles}`;\n    if (loading.length) return `tiles still loading: ${loading.join(', ')}; ${state}`;\n    return `every source loaded; ${state}`;\n  }\n\n  /**\n   * Resolve once the map has drawn the frame with every tile loaded; reject\n   * after the cap.\n   *\n   * Settled means an idle with every tile loaded, or every tile staying\n   * loaded for QUIET_MS, checked every QUIET_POLL_MS whatever the map is\n   * doing. MapLibre fires idle only once a render leaves nothing to do, and\n   * at some cameras over terrain it never gets there, so idle never comes\n   * (frame 349 of the Breithorn, 7 Nov 2026, on a Mac GPU and under\n   * SwiftShader alike). The tiles are what a frame waits for; a label still\n   * fading is not worth failing the run. The wait starts only after a\n   * render since the jump, the one that asks for the new camera's tiles,\n   * and every tile load asks for another, so a frame whose tiles have been\n   * in for QUIET_MS has been drawn with them.\n   *\n   * @param {number} t For the error.\n   * @returns {Promise<void>}\n   */\n  function settled(t) {\n    return new Promise((resolve, reject) => {\n      let done = false;\n      let quietSince = 0;\n      const seen = { renders: 0, idles: 0 };\n      /** @param {Error} [error] */\n      const finish = (error) => {\n        if (done) return;\n        done = true;\n        clearTimeout(timer);\n        clearInterval(poll);\n        map.off('idle', onIdle);\n        map.off('render', onRender);\n        if (error) reject(error);\n        else resolve();\n      };\n      const timer = setTimeout(() => {\n        finish(new Error(`frame t=${t} not settled after ${capMs / 1000} s (${waitingOn(seen)})`));\n      }, capMs);\n      const poll = setInterval(() => {\n        // Until the map has drawn once since the jump it has not asked for\n        // the new camera's tiles, so the old ones would count as in.\n        if (!seen.renders || !tilesIn()) {\n          quietSince = 0;\n          return;\n        }\n        if (!quietSince) quietSince = Date.now();\n        else if (Date.now() - quietSince >= QUIET_MS) finish();\n      }, QUIET_POLL_MS);\n      const onIdle = () => {\n        seen.idles += 1;\n        if (map.areTilesLoaded()) finish();\n      };\n      const onRender = () => {\n        seen.renders += 1;\n      };\n      map.on('idle', onIdle);\n      map.on('render', onRender);\n      map.triggerRepaint();\n    });\n  }\n\n  /**\n   * Enter pwaMapView's test for the flight, unless the map is in it already.\n   * Throws, naming canTest()'s reason, if 3D cannot be entered here.\n   */\n  function enterTest() {\n    const view = /** @type {any} */ (window).pwaMapView;\n    if (!view) throw new Error('3D is not available here: no 3D view on this page');\n    if (inTest) return;\n    if (!view.beginTest()) {\n      const why = view.canTest();\n      throw new Error(`3D is not available here: ${(why && why.reason) || 'the view would not enter 3D'}`);\n    }\n    inTest = true;\n  }\n\n  /**\n   * Load a route to fly.\n   *\n   * @param {any} geojson\n   * @param {{chrome?: boolean, flight?: any, capMs?: number}} [options]\n   * @returns {{length: number, phases: readonly string[]}}\n   */\n  function load(geojson, options = {}) {\n    const line = firstLine(geojson);\n    if (!line) throw new Error('No LineString or MultiLineString to fly');\n    // The caller's options go over the route's own, so a recorder's\n    // seconds do not drop the route's camera settings.\n    const built = core.buildFlight(line.coords, { ...(line.properties.flight || {}), ...(options.flight || {}) });\n    enterTest();\n    flight = built;\n    capMs = options.capMs && options.capMs > 0 ? options.capMs : FRAME_CAP_MS;\n    addLayers();\n    if (options.chrome === false) {\n      document.body.classList.add(RECORDING_CLASS);\n      map.resize();\n    } else if (document.body.classList.contains(RECORDING_CLASS)) {\n      document.body.classList.remove(RECORDING_CLASS);\n      map.resize();\n    }\n    return { length: built.length, phases: core.PHASES };\n  }\n\n  /**\n   * Draw the frame t of the way through, once its tiles are in.\n   *\n   * @param {number} t\n   * @returns {Promise<{phase: string}>}\n   */\n  async function frame(t) {\n    if (!flight) throw new Error('No flight loaded');\n    const f = core.flightFrame(flight, t);\n    lastData = frameData(f);\n    draw();\n    const camera = cameraFor(f);\n    thawElevation();\n    map.jumpTo(camera);\n    await settled(t);\n    // A basemap swap that landed while this frame settled took the line\n    // with it; draw it again on the new style before the screenshot.\n    if (!map.getSource(SOURCE_ID)) {\n      draw();\n      await settled(t);\n    }\n    // MapLibre keeps the camera out of the ground by lowering its pitch and\n    // zoom, judged against the centre's height at the jump. After a long\n    // jump that height is the old centre's, or 0 before its tile is in, so\n    // the camera can be pushed down. Once settled the height is right, and\n    // the same jump lands where it should (SNOW-1466).\n    if (drifted(camera)) {\n      map.jumpTo(camera);\n      await settled(t);\n    }\n    return { phase: f.phase };\n  }\n\n  /** Take the flight off the map and put the view and camera back. */\n  function unload() {\n    // A flight playing still is ended with the view and camera put back,\n    // as unload always does.\n    if (live) halt('unload', {});\n    removeLayers();\n    if (document.body.classList.contains(RECORDING_CLASS)) {\n      document.body.classList.remove(RECORDING_CLASS);\n      map.resize();\n    }\n    if (flight) {\n      flight = null;\n      lastData = null;\n      const view = /** @type {any} */ (window).pwaMapView;\n      if (view && inTest) view.endTest({});\n      inTest = false;\n    }\n  }\n\n  // ---- The live flight (SNOW-1549) ----------------------------------------\n\n  /**\n   * The XYZ tile holding a point at a zoom.\n   *\n   * @param {[number, number]} point\n   * @param {number} z\n   * @returns {{z: number, x: number, y: number}}\n   */\n  function tileOf(point, z) {\n    const n = 2 ** z;\n    const lat = Math.max(-85, Math.min(85, point[1])) * Math.PI / 180;\n    const x = Math.min(n - 1, Math.max(0, Math.floor(((point[0] + 180) / 360) * n)));\n    const y = Math.min(n - 1, Math.max(0, Math.floor(((1 - Math.asinh(Math.tan(lat)) / Math.PI) / 2) * n)));\n    return { z, x, y };\n  }\n\n  /**\n   * The preload's plan: one stop per vector tile the densified line crosses\n   * at the follow zoom, in route order, and the vector and elevation tiles\n   * the route needs there.\n   *\n   * @returns {{stops: Array<[number, number]>, tiles: number}}\n   */\n  function preloadPlan() {\n    const zoom = Math.round(flight.options.follow.zoom);\n    const core3d = /** @type {any} */ (self).pwaMap3dCore;\n    const vector = new Set();\n    const dem = new Set();\n    /** @type {Array<[number, number]>} */\n    const stops = [];\n    for (const point of flight.points) {\n      const tile = tileOf(point, zoom);\n      const key = `${tile.z}/${tile.x}/${tile.y}`;\n      if (vector.has(key)) continue;\n      vector.add(key);\n      stops.push(point);\n      const demTiles = core3d && core3d.prefetchDemTiles\n        ? core3d.prefetchDemTiles({ lng: point[0], lat: point[1] }, zoom)\n        : [];\n      for (const d of demTiles) dem.add(`${d.z}/${d.x}/${d.y}`);\n    }\n    return { stops, tiles: vector.size + dem.size };\n  }\n\n  /**\n   * Resolve once the map has every tile in, or after the stop's cap or the\n   * preload's deadline, whichever comes first.\n   *\n   * @param {() => boolean} cancelled\n   * @param {number} deadline The preload's deadline, as Date.now().\n   * @returns {Promise<void>}\n   */\n  function tilesSettled(cancelled, deadline) {\n    return new Promise((resolve) => {\n      const until = Math.min(Date.now() + PRELOAD_STOP_CAP_MS, deadline);\n      const check = () => {\n        if (cancelled() || map.areTilesLoaded() || Date.now() >= until) resolve();\n        else setTimeout(check, PRELOAD_POLL_MS);\n      };\n      check();\n    });\n  }\n\n  /**\n   * Ease the camera to one preload stop and resolve when it gets there.\n   *\n   * @param {[number, number]} point\n   * @returns {Promise<void>}\n   */\n  function easeToStop(point) {\n    return new Promise((resolve) => {\n      // An ease the map never finishes (one a gesture took over) still\n      // moves the preload on.\n      const timer = setTimeout(resolve, PRELOAD_EASE_MS * 4);\n      map.once('moveend', () => {\n        clearTimeout(timer);\n        resolve();\n      });\n      // essential: MapLibre skips the ease under prefers-reduced-motion\n      // otherwise; this is a staff measurement.\n      map.easeTo({\n        center: point,\n        zoom: flight.options.follow.zoom,\n        pitch: flight.options.follow.pitch,\n        duration: PRELOAD_EASE_MS,\n        essential: true,\n      });\n    });\n  }\n\n  /**\n   * Warm MapLibre's tile cache along the route before the flight starts.\n   *\n   * @param {NonNullable<typeof live>} run\n   * @returns {Promise<void>}\n   */\n  async function preloadRoute(run) {\n    const started = Date.now();\n    const deadline = started + PRELOAD_DEADLINE_MS;\n    const plan = preloadPlan();\n    run.preloadTiles = plan.tiles;\n    const cancelled = () => !run.playing;\n    for (const point of plan.stops) {\n      if (cancelled()) return;\n      if (Date.now() >= deadline) {\n        run.preloadTimedOut = true;\n        break;\n      }\n      thawElevation();\n      await easeToStop(point);\n      await tilesSettled(cancelled, deadline);\n    }\n    // Tiles still loading at the deadline count as a timeout too.\n    if (!run.preloadTimedOut && Date.now() >= deadline && !map.areTilesLoaded()) run.preloadTimedOut = true;\n    run.preloadMs = Date.now() - started;\n  }\n\n  /** @param {Event} _event A touch on the map. */\n  function onTouch(_event) {\n    stop({ reason: 'user' });\n  }\n\n  /** @param {KeyboardEvent} event */\n  function onKey(event) {\n    if (event.key === 'Escape') stop({ reason: 'user' });\n  }\n\n  /** The events on the map's canvas container that stop a live flight. */\n  const STOP_EVENTS = Object.freeze(['mousedown', 'touchstart', 'wheel']);\n\n  function addStopListeners() {\n    const container = map.getCanvasContainer();\n    for (const type of STOP_EVENTS) container.addEventListener(type, onTouch, { passive: true });\n    document.addEventListener('keydown', onKey);\n  }\n\n  function removeStopListeners() {\n    const container = map.getCanvasContainer();\n    for (const type of STOP_EVENTS) container.removeEventListener(type, onTouch);\n    document.removeEventListener('keydown', onKey);\n  }\n\n  /**\n   * One animation frame of a live flight.\n   *\n   * @param {number} now\n   */\n  function tick(now) {\n    const run = live;\n    if (!run || !run.playing) return;\n    if (run.lastNow !== null && now > run.lastNow) run.intervals.push(now - run.lastNow);\n    run.lastNow = now;\n    const t = run.clock.tick(now);\n    const f = core.flightFrame(flight, t);\n    const end = run.clock.done();\n    if (run.frames % LINE_EVERY_N === 0 || end) {\n      lastData = frameData(f);\n      draw();\n    }\n    thawElevation();\n    map.jumpTo(cameraFor(f));\n    run.frames += 1;\n    if (f.phase === 'follow') {\n      run.followFrames += 1;\n      if (!map.areTilesLoaded()) run.followMissing += 1;\n    }\n    if (end) {\n      stop({ reason: 'end' });\n      return;\n    }\n    run.raf = window.requestAnimationFrame(tick);\n  }\n\n  /**\n   * The live flight's figures: the one playing, or else the last one.\n   *\n   * medianMs and p95Ms are map_3d_core.frameStats over every\n   * animation-frame interval of the flight, in all four phases; popInShare\n   * is over the follow-phase frames only, the share drawn while\n   * !map.areTilesLoaded().\n   *\n   * @returns {any}\n   */\n  function stats() {\n    const run = live;\n    if (!run) return lastStats;\n    const core3d = /** @type {any} */ (self).pwaMap3dCore;\n    const timed = core3d && core3d.frameStats ? core3d.frameStats(run.intervals) : null;\n    return {\n      seconds: run.seconds,\n      frames: run.frames,\n      medianMs: timed ? timed.medianMs : null,\n      p95Ms: timed ? timed.p95Ms : null,\n      followFrames: run.followFrames,\n      popInShare: run.followFrames ? Math.round((run.followMissing / run.followFrames) * 1000) / 1000 : 0,\n      preloaded: run.preloaded,\n      preloadTiles: run.preloadTiles,\n      preloadMs: run.preloadMs,\n      preloadTimedOut: run.preloadTimedOut,\n    };\n  }\n\n  /**\n   * Play the loaded flight in real time.\n   *\n   * @param {{seconds?: number, preload?: boolean}} [options]\n   * @returns {Promise<any>} The flight's stats() once it stops.\n   */\n  function play(options = {}) {\n    if (!flight) throw new Error('No flight loaded');\n    if (live) throw new Error('A flight is playing already');\n    if (!playCore) throw new Error('pwaMap3dFlightPlayCore is not loaded');\n    enterTest();\n    const seconds = options.seconds && options.seconds > 0 ? options.seconds : flight.options.seconds;\n    return new Promise((resolve) => {\n      const run = {\n        clock: playCore.createClock({ seconds }),\n        raf: 0,\n        lastNow: /** @type {?number} */ (null),\n        intervals: /** @type {number[]} */ ([]),\n        frames: 0,\n        followFrames: 0,\n        followMissing: 0,\n        preloaded: !!options.preload,\n        preloadTiles: 0,\n        preloadMs: 0,\n        preloadTimedOut: false,\n        seconds,\n        playing: true,\n        finish: resolve,\n      };\n      live = run;\n      lastStats = null;\n      addStopListeners();\n      const start = () => {\n        if (live === run && run.playing) run.raf = window.requestAnimationFrame(tick);\n      };\n      if (options.preload) {\n        preloadRoute(run).then(start, (err) => {\n          if (live === run) halt('failed', { keepCamera: true }, { error: String(err) });\n        });\n      }\n      else start();\n    });\n  }\n\n  /**\n   * Stop the live flight, leaving the camera where it is.\n   *\n   * @param {{reason?: string}} [options]\n   * @returns {any} The flight's stats(), or null when none was playing.\n   */\n  function stop(options = {}) {\n    return halt(options.reason || 'stop', { keepCamera: true });\n  }\n\n  /**\n   * End the live flight and the test it runs in, record its line and\n   * resolve play()'s promise.\n   *\n   * @param {string} reason\n   * @param {{keepCamera?: boolean}} ending What endTest is told.\n   * @param {Record<string, unknown>} [extra] More for the line, such as an error.\n   * @returns {any}\n   */\n  function halt(reason, ending, extra = {}) {\n    const run = live;\n    if (!run || !run.playing) return null;\n    run.playing = false;\n    window.cancelAnimationFrame(run.raf);\n    removeStopListeners();\n    // A preload ease is MapLibre's own animation, not the flight's frame:\n    // stop it too, or the camera drifts on after the flight has stopped.\n    if (map && typeof map.stop === 'function') map.stop();\n    const result = { reason, ...stats(), ...extra };\n    live = null;\n    lastStats = result;\n    if (inTest) {\n      inTest = false;\n      const view = /** @type {any} */ (window).pwaMapView;\n      if (view) view.endTest(ending);\n    }\n    const log = /** @type {any} */ (window).pwaDebugLog;\n    if (log) log.record('map', '3d.flight', result);\n    run.finish(result);\n    return result;\n  }\n\n  /**\n   * Play the flight a `?fly=` link names, for the debug log to hold its\n   * figures.\n   *\n   * @param {string} name\n   * @param {boolean} preload\n   * @returns {Promise<void>}\n   */\n  async function flyFromLink(name, preload) {\n    const key = /** @type {Record<string, string>} */ (LINK_ROUTES)[name];\n    if (!key) {\n      console.warn(`3D flight: no route called ${name}`);\n      return;\n    }\n    const log = /** @type {any} */ (window).pwaDebugLog;\n    if (!log) {\n      console.warn('3D flight: not flown, as its figures need the debug log (the debug_log flag)');\n      return;\n    }\n    if (!log.on) {\n      log.setEnabled(true);\n      log.record('map', '3d.flight.recording', { turnedOn: true, by: 'fly link' });\n    }\n    const view = /** @type {any} */ (window).pwaMapView;\n    const why = view ? view.canTest() : { ok: false, reason: 'no 3D view on this page' };\n    if (!why.ok) {\n      log.record('map', '3d.flight.refused', { route: name, reason: why.reason });\n      return;\n    }\n    const url = (script && script.dataset[key]) || VERBIER_FALLBACK_URL;\n    try {\n      const response = await fetch(url, { credentials: 'same-origin' });\n      if (!response.ok) throw new Error(`${url} answered ${response.status}`);\n      const geojson = await response.json();\n      const line = firstLine(geojson);\n      // The length sets the duration, and the duration the bearing table,\n      // so the line is measured before the flight is built for real.\n      const seconds = playCore.secondsFromLength(line ? core.buildFlight(line.coords).length : 0);\n      load(geojson, { flight: { seconds } });\n      await play({ seconds, preload });\n    } catch (err) {\n      log.record('map', '3d.flight.failed', { route: name, error: String(err) });\n      console.warn('3D flight: could not fly', err);\n    }\n  }\n\n  map.on('style.load', draw);\n\n  const params = new URLSearchParams(location.search);\n  const fly = params.get('fly');\n  if (fly) {\n    const preload = params.get('preload') === '1';\n    const loaded = typeof map.loaded !== 'function' || map.loaded();\n    if (loaded) flyFromLink(fly, preload);\n    else map.once('load', () => { flyFromLink(fly, preload); });\n  }\n\n  window.pwaMap3dFlight = Object.freeze({\n    load, frame, unload, play, stop, stats, FRAME_CAP_MS, QUIET_MS, LINE_EVERY_N,\n  });\n})();\n"],
  "mappings": "CAiFC,UAA2B,CAC1B,aAEA,MAAMA,EAAO,KAAK,mBACZC,EAAW,KAAK,uBAChBC,EAAW,OAAO,iBAClBC,EAAMD,EAAWA,EAAS,IAAM,KACtC,GAAI,CAACF,GAAQ,CAACG,EAAK,OAEnB,MAAMC,EAA4C,SAAS,cAGrDC,EAAY,gBACZC,EAAY,OAAO,OAAO,CAAC,uBAAwB,qBAAsB,oBAAoB,CAAC,EAE9FC,EAAe,IAKfC,EAAW,IACXC,EAAgB,IAEhBC,EAAiB,IAEjBC,EAAkB,gBAElBC,EAAe,EAEfC,EAAc,OAAO,OAAO,CAAE,QAAS,YAAa,CAAC,EAErDC,GAAuB,wCAEvBC,GAAsB,KAEtBC,GAAsB,IAEtBC,EAAkB,IAClBC,GAAkB,IAGxB,IAAIC,EAAS,KAETC,EAAW,KAEXC,EAAQd,EAERe,EAAS,GAYTC,EAAO,KAEPC,EAAgC,KAQpC,SAASC,EAAUC,EAAS,CAC1B,GAAI,CAACA,GAAW,OAAOA,GAAY,SAAU,OAAO,KACpD,GAAIA,EAAQ,OAAS,oBAAqB,CACxC,UAAWC,KAAWD,EAAQ,UAAY,CAAC,EAAG,CAC5C,MAAME,EAAQH,EAAUE,CAAO,EAC/B,GAAIC,EAA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CACpC,KAAA3D,EAAM,MAAAjC,GAAO,OAAAqC,GAAQ,KAAA4C,EAAM,KAAAb,EAAM,MAAAW,EAAO,aAAAhH,EAAc,SAAAC,EAAU,aAAAI,CAClE,CAAC,CACH,GAAG",
  "names": ["core", "playCore", "mapState", "map", "script", "SOURCE_ID", "LAYER_IDS", "FRAME_CAP_MS", "QUIET_MS", "QUIET_POLL_MS", "REVEAL_PADDING", "RECORDING_CLASS", "LINE_EVERY_N", "LINK_ROUTES", "VERBIER_FALLBACK_URL", "PRELOAD_STOP_CAP_MS", "PRELOAD_DEADLINE_MS", "PRELOAD_EASE_MS", "PRELOAD_POLL_MS", "flight", "lastData", "capMs", "inTest", "live", "lastStats", "firstLine", "geojson", "feature", "found", "colours", "routeCore", "removeLayers", "id", "addLayers", "line", "casing", "isLine", "draw", "source", "frameData", "frame", "features", "cameraFor", "cam", "fitted", "c", "centre", "w", "thawElevation", "internal", "drifted", "camera", "tilesIn", "style", "waitingOn", "seen", "loading", "state", "settled", "t", "resolve", "reject", "done", "quietSince", "finish", "error", "timer", "poll", "onIdle", "onRender", "enterTest", "view", "why", "load", "options", "built", "f", "unload", "halt", "tileOf", "point", "z", "n", "lat", "x", "y", "preloadPlan", "zoom", "core3d", "vector", "dem", "stops", "tile", "key", "demTiles", "d", "tilesSettled", "cancelled", "deadline", "until", "check", "easeToStop", "preloadRoute", "run", "started", "plan", "onTouch", "_event", "stop", "onKey", "event", "STOP_EVENTS", "addStopListeners", "container", "type", "removeStopListeners", "tick", "now", "end", "stats", "timed", "play", "seconds", "start", "err", "reason", "ending", "extra", "result", "log", "flyFromLink", "name", "preload", "url", "response", "params", "fly"]
}
