{
  "version": 3,
  "sources": ["route_point_card.js"],
  "sourcesContent": ["/*\n * static/js/route_point_card.js \u2014 the point header's DOM half: fills\n * templates/includes/_route_point_card.html for the open route's cursor\n * (SNOW-1064; a header of the route panel since SNOW-1068).\n *\n * The rail attaches the header when a route opens (route_rail.js's `open`)\n * and detaches it when the route closes. While attached it follows the\n * route cursor (route_cursor_core.js): with no index it shows UNLIT \u2014 the\n * wheel with nothing lit, a dash on each line, the clear button disabled \u2014\n * and with one it shows that segment's wheel and words (2026-10-18: it\n * sits under the profile now, the route sheet's HALF state on a phone,\n * rather than in the route title's place). Every surface that places a point\n * already writes the cursor: a tap on the route's line (map.js) and a tap\n * on the profile (route_rail.js). Nothing here is placement.\n *\n * The per-route arrays \u2014 each segment's path and gradient \u2014 are worked out\n * once on attach, so a cursor move is one lookup and one redraw. All the\n * arithmetic and the words are route_point_card_core.js's; all the copy is\n * the partial's strings template.\n *\n * CLEARING THE POINT is a press on the wheel (2026-10-02): the wheel sits\n * in a button (`[data-route-point-card-clear]`) that sets the cursor's\n * index to null, which takes this header back to unlit.\n * Escape does the same (route_rail.js). The panel's \u00D7 closes the route.\n *\n * Depends on i18n_strings.js, route_slope_core.js, aspect_wheel_core.js\n * and route_point_card_core.js, loaded before it.\n *\n * Publishes (frozen `window.pwaRoutePointCard`):\n *\n *   attach({cursor, slope, coordinates, profile, sampleCount})\n *              \u2014 follow one route's cursor, showing the header for a point\n *   detach()   \u2014 stop following and show the header unlit\n *   element    \u2014 the header itself\n */\n\n(function routePointCardInit() {\n  'use strict';\n\n  var card = document.getElementById('route-point-card');\n  if (!card) return;\n\n  /** The wheel's size in the header, CSS px: the mockup's. */\n  var WHEEL_SIZE = 48;\n\n  // Server-translated copy; the literals are the English fallback (see\n  // static/js/i18n_strings.js).\n  var STRINGS = self.pwaStrings.read('route-point-card-strings-template', {\n    label: \"Skier's track: %(headline)s; Terrain slope: %(ground)s\",\n    join: '%(before)s \u00B7 %(after)s',\n    'label-join': '%(before)s, %(after)s',\n    'compass-0': 'N',\n    'compass-1': 'NE',\n    'compass-2': 'E',\n    'compass-3': 'SE',\n    'compass-4': 'S',\n    'compass-5': 'SW',\n    'compass-6': 'W',\n    'compass-7': 'NW',\n    'heading-pair': '%(first)s \u2192 %(second)s',\n    'label-heading-pair': '%(first)s to %(second)s',\n    'kind-ascent': 'Ascent',\n    'kind-descent': 'Descent',\n    'kind-traverse': 'Traverse',\n    'kind-fall-line': 'Fall line',\n    'headline-level': 'Level',\n    'headline-no-height': 'No height data',\n    'with-band': '%(text)s \u00B7 %(band)s',\n    'label-with-band': '%(text)s, %(band)s',\n    'band-under': 'under %(high)s\u00B0',\n    'band-range': '%(low)s\u2013%(high)s\u00B0',\n    'band-over': '%(low)s\u00B0+',\n    'label-band-under': 'under %(high)s degrees',\n    'label-band-range': '%(low)s to %(high)s degrees',\n    'label-band-over': '%(low)s degrees or more',\n    'ground-flat': 'Flat',\n    'ground-moderate': 'Moderate',\n    'ground-steep': 'Steep',\n    'ground-very-steep': 'Very steep',\n    'ground-extremely-steep': 'Extremely steep',\n    empty: '\u2013',\n    'ground-unknown': 'No terrain data',\n    'ground-falling-left': \"%(ground)s, falling skier's left\",\n    'ground-falling-right': \"%(ground)s, falling skier's right\",\n    'ground-falling-left-then-right': \"%(ground)s, falling skier's left, then right\",\n    'ground-falling-right-then-left': \"%(ground)s, falling skier's right, then left\",\n  });\n\n  var wheelEl = card.querySelector('[data-route-point-card-wheel]');\n  var clearEl = card.querySelector('[data-route-point-card-clear]');\n  var headlineEl = card.querySelector('[data-route-point-card-headline]');\n  var groundEl = card.querySelector('[data-route-point-card-ground]');\n\n  /** The open route's cursor, or null while detached. */\n  var cursor = null;\n  /** Removes the header's subscription to `cursor`. */\n  var unsubscribe = null;\n  /** The open route's arrays, worked out once on attach. */\n  var route = null;\n\n  /**\n   * Draw the wheel into the header.\n   *\n   * @param {*} state The wheel's state.\n   * @param {string} label Its accessible name.\n   */\n  function drawWheel(state, label) {\n    var wheel = self.pwaAspectWheelCore;\n    if (!wheel || !wheelEl) return;\n    wheelEl.innerHTML = wheel.aspectWheelSvg({ size: WHEEL_SIZE, state: state, label: label });\n  }\n\n  /**\n   * The wheel with nothing lit: no heading, flat ground, no gradient. Flat\n   * rather than \"none\" because \"none\" fills the outer ring grey, which\n   * reads as missing terrain data rather than no point.\n   */\n  var UNLIT_STATE = Object.freeze({ track: [], gradeDeg: null, prev: null, next: null, terrain: { kind: 'flat' } });\n\n  /** Show the header unlit: no point is placed. */\n  function clear() {\n    drawWheel(UNLIT_STATE, '');\n    headlineEl.textContent = STRINGS.empty;\n    groundEl.textContent = STRINGS.empty;\n    if (clearEl) /** @type {HTMLButtonElement} */ (clearEl).disabled = true;\n  }\n\n  /**\n   * Bring the header in line with the cursor: shown and filled for a\n   * point, hidden without one.\n   *\n   * @param {?{index: ?number}} state The cursor's state.\n   */\n  function paint(state) {\n    var core = self.pwaRoutePointCardCore;\n    var index = state ? state.index : null;\n    if (!core || !route || typeof index !== 'number') {\n      clear();\n      return;\n    }\n    var words = core.reading({\n      index: index,\n      paths: route.paths,\n      gradients: route.gradients,\n      angles: route.angles,\n      aspects: route.aspects,\n    }, STRINGS);\n    if (words.state) drawWheel(words.state, words.label);\n    headlineEl.textContent = words.headline;\n    groundEl.textContent = words.ground;\n    if (clearEl) /** @type {HTMLButtonElement} */ (clearEl).disabled = false;\n  }\n\n  /**\n   * Follow one route's cursor.\n   *\n   * @param {{cursor: *, slope: *, coordinates: *, profile: *,\n   *   sampleCount: number}} options What the rail opened the route with.\n   */\n  function attach(options) {\n    detach();\n    if (!options || !options.cursor) return;\n    var slopeCore = self.pwaRouteSlopeCore;\n    var core = self.pwaRoutePointCardCore;\n    var slope = options.slope && typeof options.slope === 'object' ? options.slope : null;\n    route = {\n      paths: slopeCore && slope ? slopeCore.segmentPaths(slope, options.coordinates) : [],\n      gradients: core\n        ? core.segmentGradients(\n          options.profile,\n          options.sampleCount,\n          slope ? core.boundaryDistances(slope, options.coordinates) : null,\n        )\n        : [],\n      angles: slope && Array.isArray(slope.angles) ? slope.angles : [],\n      // Undefined, not [], when the payload predates SNOW-976: the wheel\n      // and the words tell \"no aspect data\" from \"flat\" by its absence.\n      aspects: slope ? slope.aspects : undefined,\n    };\n    cursor = options.cursor;\n    unsubscribe = cursor.subscribe(paint);\n    paint(cursor.state());\n  }\n\n  /** Stop following the cursor and show the header unlit. */\n  function detach() {\n    if (unsubscribe) unsubscribe();\n    unsubscribe = null;\n    cursor = null;\n    route = null;\n    clear();\n  }\n\n  if (clearEl) {\n    clearEl.addEventListener('click', function () {\n      if (cursor) cursor.setIndex(null);\n    });\n  }\n\n  clear();\n\n  window.pwaRoutePointCard = Object.freeze({\n    attach: attach,\n    detach: detach,\n    element: card,\n  });\n}());\n"],
  "mappings": "CAoCC,UAA8B,CAC7B,aAEA,IAAIA,EAAO,SAAS,eAAe,kBAAkB,EACrD,GAAI,CAACA,EAAM,OAGX,IAAIC,EAAa,GAIbC,EAAU,KAAK,WAAW,KAAK,oCAAqC,CACtE,MAAO,yDACP,KAAM,4BACN,aAAc,wBACd,YAAa,IACb,YAAa,KACb,YAAa,IACb,YAAa,KACb,YAAa,IACb,YAAa,KACb,YAAa,IACb,YAAa,KACb,eAAgB,8BAChB,qBAAsB,0BACtB,cAAe,SACf,eAAgB,UAChB,gBAAiB,WACjB,iBAAkB,YAClB,iBAAkB,QAClB,qBAAsB,iBACtB,YAAa,yBACb,kBAAmB,qBACnB,aAAc,qBACd,aAAc,4BACd,YAAa,eACb,mBAAoB,yBACpB,mBAAoB,8BACpB,kBAAmB,0BACnB,cAAe,OACf,kBAAmB,WACnB,eAAgB,QAChB,oBAAqB,aACrB,yBAA0B,kBAC1B,MAAO,SACP,iBAAkB,kBAClB,sBAAuB,mCACvB,uBAAwB,oCACxB,iCAAkC,+CAClC,iCAAkC,8CACpC,CAAC,EAEGC,EAAUH,EAAK,cAAc,+BAA+B,EAC5DI,EAAUJ,EAAK,cAAc,+BAA+B,EAC5DK,EAAaL,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,EAAQ,WAAW,EAAI,CAAC,EAClF,UAAWJ,EACPA,EAAK,iBACLI,EAAQ,QACRA,EAAQ,YACRG,EAAQP,EAAK,kBAAkBO,EAAOH,EAAQ,WAAW,EAAI,IAC/D,EACE,CAAC,EACL,OAAQG,GAAS,MAAM,QAAQA,EAAM,MAAM,EAAIA,EAAM,OAAS,CAAC,EAG/D,QAASA,EAAQA,EAAM,QAAU,MACnC,EACAjB,EAASc,EAAQ,OACjBb,EAAcD,EAAO,UAAUS,CAAK,EACpCA,EAAMT,EAAO,MAAM,CAAC,EACtB,CAGA,SAASe,GAAS,CACZd,GAAaA,EAAY,EAC7BA,EAAc,KACdD,EAAS,KACTE,EAAQ,KACRM,EAAM,CACR,CAEIX,GACFA,EAAQ,iBAAiB,QAAS,UAAY,CACxCG,GAAQA,EAAO,SAAS,IAAI,CAClC,CAAC,EAGHQ,EAAM,EAEN,OAAO,kBAAoB,OAAO,OAAO,CACvC,OAAQK,EACR,OAAQE,EACR,QAAStB,CACX,CAAC,CACH,GAAE",
  "names": ["card", "WHEEL_SIZE", "STRINGS", "wheelEl", "clearEl", "headlineEl", "groundEl", "cursor", "unsubscribe", "route", "drawWheel", "state", "label", "wheel", "UNLIT_STATE", "clear", "paint", "core", "index", "words", "attach", "options", "detach", "slopeCore", "slope"]
}
