{
  "version": 3,
  "sources": ["csrf_cookie.js"],
  "sourcesContent": ["// @ts-check\n/*\n * static/js/csrf_cookie.js \u2014 the CSRF token from Django's cookie (SNOW-1541).\n *\n * Seven scripts post with an ``X-CSRFToken`` header and each read Django's\n * ``csrftoken`` cookie by name. SNOW-1541 renamed the cookie \u2014 it is\n * ``snowdesk_csrftoken`` in production, shared across snowdesk.info, and\n * staging's is named apart \u2014 so the name is the server's to say. Both shells\n * render it as ``<meta name=\"csrf-cookie-name\">`` (the ``csrf_cookie_name``\n * context processor), and this module is the one reader of it.\n *\n *   - ``token()`` \u2014 the cookie's value, decoded, or '' when there is none.\n *\n * The meta tag and the cookie are both read at call time, not at load: the\n * token rotates when the reader signs in, and a script may ask before or\n * after that. Without the tag it falls back to Django's ``csrftoken``.\n *\n * Loaded first among the deferred scripts in ``public/base.html`` and\n * ``explorer/base.html``, so it precedes every caller wherever their tags\n * sit. Holds no state and touches nothing but ``document``.\n */\n(function () {\n  'use strict';\n\n  /** Django's own name, used when the page does not name the cookie. */\n  const DEFAULT_NAME = 'csrftoken';\n\n  /**\n   * The CSRF cookie's name, as the page's meta tag gives it.\n   *\n   * @returns {string}\n   */\n  function cookieName() {\n    const meta = document.querySelector('meta[name=\"csrf-cookie-name\"]');\n    const name = meta ? (meta.getAttribute('content') || '').trim() : '';\n    return name || DEFAULT_NAME;\n  }\n\n  /**\n   * Decode a cookie value, or return it as it is when it is not encoded.\n   *\n   * @param {string} value\n   * @returns {string}\n   */\n  function decode(value) {\n    try {\n      return decodeURIComponent(value);\n    } catch (_err) {\n      return value;\n    }\n  }\n\n  /**\n   * The CSRF token: the named cookie's value, or '' when it is absent.\n   *\n   * The cookies are split by hand rather than matched by a pattern built\n   * from the name, so no character in a name needs escaping.\n   *\n   * @returns {string}\n   */\n  function token() {\n    const name = cookieName();\n    const pairs = document.cookie ? document.cookie.split(';') : [];\n    for (const pair of pairs) {\n      const at = pair.indexOf('=');\n      if (at < 0) continue;\n      if (pair.slice(0, at).trim() === name) return decode(pair.slice(at + 1).trim());\n    }\n    return '';\n  }\n\n  self.pwaCsrf = Object.freeze({ token: token });\n})();\n"],
  "mappings": "CAqBC,UAAY,CACX,aAGA,MAAMA,EAAe,YAOrB,SAASC,GAAa,CACpB,MAAMC,EAAO,SAAS,cAAc,+BAA+B,EAEnE,OADaA,GAAQA,EAAK,aAAa,SAAS,GAAK,IAAI,KAAK,EAAI,KACnDF,CACjB,CAQA,SAASG,EAAOC,EAAO,CACrB,GAAI,CACF,OAAO,mBAAmBA,CAAK,CACjC,MAAe,CACb,OAAOA,CACT,CACF,CAUA,SAASC,GAAQ,CACf,MAAMC,EAAOL,EAAW,EAClBM,EAAQ,SAAS,OAAS,SAAS,OAAO,MAAM,GAAG,EAAI,CAAC,EAC9D,UAAWC,KAAQD,EAAO,CACxB,MAAME,EAAKD,EAAK,QAAQ,GAAG,EAC3B,GAAI,EAAAC,EAAK,IACLD,EAAK,MAAM,EAAGC,CAAE,EAAE,KAAK,IAAMH,EAAM,OAAOH,EAAOK,EAAK,MAAMC,EAAK,CAAC,EAAE,KAAK,CAAC,CAChF,CACA,MAAO,EACT,CAEA,KAAK,QAAU,OAAO,OAAO,CAAE,MAAOJ,CAAM,CAAC,CAC/C,GAAG",
  "names": ["DEFAULT_NAME", "cookieName", "meta", "decode", "value", "token", "name", "pairs", "pair", "at"]
}
