{
  "version": 3,
  "sources": ["/cdn/shop/t/1064/assets/nt-back-nav-fix.js?auto=format%2Ccompress"],
  "sourcesContent": ["/* ===========================================================================\n   nt-back-nav-fix.js \u2014 Back-button behaviour for the legacy by-size PDPs.\n\n   WHY THIS FILE EXISTS\n   The by-size v4 engine (assets/bysize-v4.js \u2014 /products/dtf-transfers,\n   /products/custom-stickers) does not have the Back-button problems the\n   legacy `bySize` engine has. Not because it fixes them, but because of two\n   structural differences. This file gives the legacy pages the same two\n   properties, without touching the ~400KB section files (which exceed\n   Shopify's Asset API size limit and cannot be pushed) or the engine files\n   (~300-400KB each, shared by a dozen templates).\n\n   WHAT v4 DOES DIFFERENTLY (measured 2026-08-19, live, real add-to-cart)\n\n   1. v4 never leaves a full-page overlay up across the navigation.\n      dev/bysize-v4/src/cart.js:426 disables the button and calls\n      `location.href = '/cart'`. No `.loadingScreen__`. The legacy engine\n      prepends one (pdp_transferBySize.js:6114 and friends) and deliberately\n      leaves it up so it covers the redirect, with removal scheduled 8s later\n      (pdp_transferBySize.js:2081) \u2014 a timer the navigation cancels. On a\n      bfcache restore that frozen overlay comes back and nothing removes it.\n\n   2. v4 never writes `?variant=` into its history entry.\n      sections/by-size-v4.liquid renders no <product-variants> element, so\n      component-product-form.js `updateURL()` (:399) never runs. The legacy\n      sections do render it, and `updateURL` does\n      `history.replaceState(url + '?variant=<id>')` \u2014 REPLACING the entry the\n      customer returns to with a URL that has never been fetched. Back then\n      cannot use the back/forward HTTP cache and re-renders the whole\n      document from origin.\n\n        spangle, Back after add-to-cart, before:  364KB from origin,\n                                                  responseEnd 1523ms, DCL 8240ms\n        same page with this fix's behaviour:      0KB, TTFB 5ms,\n                                                  responseEnd 78ms, DCL 5683ms\n        dtf by-size-v4 (v4 engine, for scale):    0KB, TTFB 11ms, DCL 2153ms\n\n      Note the residual gap to v4 is page WEIGHT (the legacy page loads ~343\n      subresources before DCL), not caching. This file removes the origin\n      round-trip; it does not make the legacy page as light as v4.\n\n   SCOPE: Back-button behaviour only. It deliberately does NOT touch how long\n   the loader shows during the add-to-cart redirect itself \u2014 that window is\n   /cart's own render time, and hiding the overlay early would expose the\n   product page mid-navigation and invite a double-add.\n   =========================================================================== */\n(function () {\n  'use strict';\n\n  if (window.__ntBackNavFix) return;\n  window.__ntBackNavFix = true;\n\n  /* -----------------------------------------------------------------------\n     1. bfcache restore \u2014 tear down the pre-navigation overlay state.\n\n     Same guard that already ships in assets/bySize.js:1 and\n     assets/bySize_popular.js:1; those two engines have had it for a while,\n     every other legacy engine has none. `processing-second-upload` is\n     included because it hides the cart sidebar and site overlay\n     (assets/theme.css:4559) \u2014 restored with the page, it leaves the customer\n     unable to see their cart.\n\n     Only fires on `e.persisted`. On browsers that refuse bfcache for these\n     pages (Chrome does: the document is served `Cache-Control: no-store`)\n     this is a no-op; Safari is far more permissive, which is where the\n     stuck loader is actually reported.\n     -------------------------------------------------------------------- */\n  window.addEventListener('pageshow', function (e) {\n    if (!e.persisted) return;\n    try {\n      document.querySelectorAll('.loadingScreen__').forEach(function (el) {\n        el.remove();\n      });\n      document.body.classList.remove('hide-loader');\n      document.body.classList.remove('processing-second-upload');\n    } catch (_) {\n      /* never block a restore */\n    }\n  });\n\n  /* -----------------------------------------------------------------------\n     2. Keep the history entry on a URL the browser can serve from cache.\n\n     Two independent mechanisms, because the first depends on script order\n     and the second does not:\n\n     (a) `data-no-history` is component-product-form.js's own documented\n         opt-out (:92, also used by sections/featured-product.liquid:50 and\n         snippets/quick-buy.liquid:52). Setting it suppresses future\n         `updateURL()` writes. On by-size products the variant is DERIVED\n         from the size rows \u2014 the customer never picks one \u2014 so the param\n         carries no user value.\n\n     (b) If a write already happened before this file ran, (a) is too late.\n         So immediately before the add-to-cart navigation, put the entry back\n         on the canonical URL. Capture phase, so it runs ahead of the\n         engine's own bubble-phase handler.\n\n     Only the `variant` key is removed. Other params are left alone \u2014 the\n     engines read `?file=`, `?ordertype=` and friends as deep links.\n     -------------------------------------------------------------------- */\n  function suppressVariantHistoryWrites() {\n    try {\n      document\n        .querySelectorAll('product-variants[data-main-product-variants]')\n        .forEach(function (el) {\n          el.setAttribute('data-no-history', '');\n        });\n    } catch (_) {\n      /* never block boot */\n    }\n  }\n\n  function restoreCanonicalEntry() {\n    try {\n      var u = new URL(window.location.href);\n      if (!u.searchParams.has('variant')) return;\n      u.searchParams.delete('variant');\n      var next = u.pathname + (u.search || '') + (u.hash || '');\n      window.history.replaceState(window.history.state, '', next);\n    } catch (_) {\n      /* a failed tidy-up must never block the add */\n    }\n  }\n\n  suppressVariantHistoryWrites();\n\n  /* The element can be upgraded/re-rendered after this file runs (the engine\n     rebuilds size rows on upload), so re-apply on the add-to-cart click too. */\n  document.addEventListener(\n    'click',\n    function (e) {\n      var t = e.target;\n      if (!t || !t.closest) return;\n      if (\n        !t.closest(\n          '.addToCartGroupItems, .add-to-cart[data-main-product-add-to-cart], .basic_link'\n        )\n      ) {\n        return;\n      }\n      suppressVariantHistoryWrites();\n      restoreCanonicalEntry();\n    },\n    true\n  );\n})();\n"],
  "mappings": "CA8CC,UAAY,CACX,aAEA,GAAI,OAAO,eAAgB,OAC3B,OAAO,eAAiB,GAiBxB,OAAO,iBAAiB,WAAY,SAAU,EAAG,CAC/C,GAAK,EAAE,UACP,GAAI,CACF,SAAS,iBAAiB,kBAAkB,EAAE,QAAQ,SAAU,GAAI,CAClE,GAAG,OAAO,CACZ,CAAC,EACD,SAAS,KAAK,UAAU,OAAO,aAAa,EAC5C,SAAS,KAAK,UAAU,OAAO,0BAA0B,CAC3D,OAAS,EAAG,CAEZ,CACF,CAAC,EAuBD,SAAS,8BAA+B,CACtC,GAAI,CACF,SACG,iBAAiB,8CAA8C,EAC/D,QAAQ,SAAU,GAAI,CACrB,GAAG,aAAa,kBAAmB,EAAE,CACvC,CAAC,CACL,OAAS,EAAG,CAEZ,CACF,CAEA,SAAS,uBAAwB,CAC/B,GAAI,CACF,IAAI,EAAI,IAAI,IAAI,OAAO,SAAS,IAAI,EACpC,GAAI,CAAC,EAAE,aAAa,IAAI,SAAS,EAAG,OACpC,EAAE,aAAa,OAAO,SAAS,EAC/B,IAAI,KAAO,EAAE,UAAY,EAAE,QAAU,KAAO,EAAE,MAAQ,IACtD,OAAO,QAAQ,aAAa,OAAO,QAAQ,MAAO,GAAI,IAAI,CAC5D,OAAS,EAAG,CAEZ,CACF,CAEA,6BAA6B,EAI7B,SAAS,iBACP,QACA,SAAU,EAAG,CACX,IAAI,EAAI,EAAE,OACN,CAAC,GAAK,CAAC,EAAE,SAEV,EAAE,QACD,gFACF,IAIF,6BAA6B,EAC7B,sBAAsB,EACxB,EACA,EACF,CACF,GAAG",
  "names": []
}
