{
  "version": 3,
  "sources": ["map_compass.js"],
  "sourcesContent": ["// @ts-check\n/*\n * static/js/map_compass.js \u2014 the map's compass (SNOW-1449; any map since\n * SNOW-1543).\n *\n * The roundel directly under the zoom roundel at the top of the bottom-left\n * stack (public/partials/_map_compass.html), for every reader and in both\n * views, flat and 3-D. It is always shown, north-up or not, so the reader\n * always knows which way the map faces; a map turned by a two-finger twist\n * or a right-drag otherwise gives no sign that it has turned, nor a way back\n * that does not take the same gesture. (SNOW-1449 hid it at north; Hugo\n * asked for it always, 6 Nov 2026.)\n *\n * The needle points north, so it turns against the map's bearing, on every\n * `rotate`. A press eases the map back to north and leaves the tilt alone,\n * so a 3-D view stays tilted. At north a press is harmless: the ease has\n * nowhere to go.\n *\n * Publishes `self.pwaMapCompass.attach(map, button)`, which binds one\n * compass to one map and returns its detach. The GPX Explorer calls it on\n * each map it draws (static/js/explorer.js, SNOW-1543).\n *\n * LOAD ORDER: on /map/ it also attaches at parse time, to the map it reads\n * from window.snowdeskMapState, so it loads after map.js; outside the map\n * bundle's contiguous run (nothing in the bundle reads it), after\n * map_zoom_control.js, whose roundel it sits under. A page with no\n * #map-compass at parse time (the explorer's, until a result is drawn) is\n * left alone.\n */\n(function mapCompassInit() {\n  'use strict';\n\n  const EASE_MS = 400;\n\n  /**\n   * Bind a compass to a map: the needle follows the bearing, and a press\n   * turns the map back to north.\n   *\n   * @param {any} map A MapLibre map.\n   * @param {HTMLElement} button The compass's `<button>`.\n   * @returns {() => void} Removes both listeners.\n   */\n  function attach(map, button) {\n    const needle = /** @type {?SVGElement} */ (button.querySelector('[data-compass-needle]'));\n\n    /** Turn the needle against the map's bearing, so it points north. */\n    const render = () => {\n      if (needle) needle.style.transform = `rotate(${-map.getBearing()}deg)`;\n    };\n\n    const onClick = () => {\n      map.easeTo({ bearing: 0, duration: EASE_MS });\n    };\n\n    map.on('rotate', render);\n    render();\n    button.addEventListener('click', onClick);\n\n    return () => {\n      map.off('rotate', render);\n      button.removeEventListener('click', onClick);\n    };\n  }\n\n  self.pwaMapCompass = Object.freeze({ attach });\n\n  const button = document.getElementById('map-compass');\n  if (!button) return;\n  const state = window.snowdeskMapState;\n  const map = state ? state.map : null;\n  if (map) attach(map, button);\n})();\n"],
  "mappings": "CA6BC,UAA0B,CACzB,aAYA,SAASA,EAAOC,EAAKC,EAAQ,CAC3B,MAAMC,EAAqCD,EAAO,cAAc,uBAAuB,EAGjFE,EAAS,IAAM,CACfD,IAAQA,EAAO,MAAM,UAAY,UAAU,CAACF,EAAI,WAAW,CAAC,OAClE,EAEMI,EAAU,IAAM,CACpBJ,EAAI,OAAO,CAAE,QAAS,EAAG,SAAU,GAAQ,CAAC,CAC9C,EAEA,OAAAA,EAAI,GAAG,SAAUG,CAAM,EACvBA,EAAO,EACPF,EAAO,iBAAiB,QAASG,CAAO,EAEjC,IAAM,CACXJ,EAAI,IAAI,SAAUG,CAAM,EACxBF,EAAO,oBAAoB,QAASG,CAAO,CAC7C,CACF,CAEA,KAAK,cAAgB,OAAO,OAAO,CAAE,OAAAL,CAAO,CAAC,EAE7C,MAAME,EAAS,SAAS,eAAe,aAAa,EACpD,GAAI,CAACA,EAAQ,OACb,MAAMI,EAAQ,OAAO,iBACfL,EAAMK,EAAQA,EAAM,IAAM,KAC5BL,GAAKD,EAAOC,EAAKC,CAAM,CAC7B,GAAG",
  "names": ["attach", "map", "button", "needle", "render", "onClick", "state"]
}
