{
  "version": 3,
  "sources": ["/cdn/shop/t/1064/assets/nt-bgr-upsell-tabs.js?auto=format%2Ccompress"],
  "sourcesContent": ["/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n * nt-upsell-tabs.js \u2014 tab controller for the inline tabbed blanks upsell on\n * by-size-v4 PDPs (snippets/by-size-blanks-tabs.liquid).\n *\n * Lightness: no tab renders eagerly. The ACTIVE tab is fetched (once) on the page's\n * own post-upload signal \u2014 the `bsv4:file-uploaded` document event, or a page that\n * loads already-uploaded (data-state=\"uploaded\" on the .bsv4 root). Other tabs load\n * only when clicked. Each tab's cards come from the Section Rendering API\n * (/collections/<handle>?section_id=nt-upsell-tab); once injected we init only that tab (never the whole page).\n * No product/cart\n * logic here.\n *\n * Reveal is NOT handled here \u2014 the wrapper lives inside .bsv4-only-uploaded, which\n * the page shows only at data-state=\"uploaded\".\n * \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n(function () {\n  \"use strict\";\n\n  function activateScripts(container) {\n    var scripts = container.querySelectorAll(\"script\");\n    for (var i = 0; i < scripts.length; i++) {\n      var old = scripts[i];\n      var el = document.createElement(\"script\");\n      if (old.src) { el.src = old.src; } else { el.textContent = old.textContent; }\n      for (var a = 0; a < old.attributes.length; a++) {\n        var attr = old.attributes[a];\n        if (attr.name !== \"src\") el.setAttribute(attr.name, attr.value);\n      }\n      old.parentNode.replaceChild(el, old);\n    }\n  }\n\n  // Call a set of engine refresh fns (each reveals + lays out ONE grt-upsell-block).\n  // grt-upsell-block pushes its own fn to window.__grtUpsellAfterUploadFns; calling\n  // just the one(s) for a given tab avoids window.refreshGRTUpsellBlocks(), which\n  // re-inits (force-rebuilds) EVERY swiper on the page and flashes the visible tab.\n  function callFns(fns) {\n    if (!fns || !fns.length) return;\n    requestAnimationFrame(function () {\n      for (var i = 0; i < fns.length; i++) { try { fns[i]({ trigger: \"nt-tab\" }); } catch (e) {} }\n    });\n  }\n\n  function initRoot(root) {\n    if (root.__ntBlankTabsInit) return;\n    root.__ntBlankTabsInit = true;\n\n    var fetches = {};\n    // The engine fn(s) registered before this controller ran belong to the eager\n    // first tab (the only grt-upsell-block on the page at load).\n    var eagerFns = (window.__grtUpsellAfterUploadFns || []).slice();\n\n    // Init exactly one panel's grt-upsell-block, once, using its own fn(s).\n    function initPanel(panel, fns) {\n      if (!panel || panel.__ntInited) return;\n      panel.__ntInited = true;\n      callFns(fns || panel.__ntRefreshFns);\n    }\n\n    function panelFor(tab) {\n      return root.querySelector('.nt-blank-tabs__panel[data-tab=\"' + tab + '\"]');\n    }\n\n    function activeTab() {\n      var b = root.querySelector(\".nt-blank-tabs__tab--active\");\n      if (b) return b.getAttribute(\"data-tab\");\n      var p = root.querySelector(\".nt-blank-tabs__panel\");\n      return p ? p.getAttribute(\"data-tab\") : null;\n    }\n\n    // Fetch a tab's cards on demand (the skeleton is already showing in the panel).\n    // showNow inits the swiper once injected \u2014 always true here since we only fetch a\n    // tab when it's the one being shown.\n    function fetchTab(tab, showNow) {\n      if (fetches[tab]) return fetches[tab];\n      var panel = panelFor(tab);\n      if (!panel || panel.getAttribute(\"data-loaded\") === \"true\") return Promise.resolve();\n      var url = panel.getAttribute(\"data-fetch-url\");\n      if (!url) return Promise.resolve();\n      fetches[tab] = fetch(url, { cache: \"no-store\" })\n        .then(function (r) { return r.text(); })\n        .then(function (html) {\n          var before = (window.__grtUpsellAfterUploadFns || []).length;\n          panel.innerHTML = html;\n          panel.setAttribute(\"data-loaded\", \"true\");\n          activateScripts(panel);\n          // The block's inline script just registered its refresh fn \u2014 capture it\n          // for this panel so we can init only this tab, never the whole page.\n          panel.__ntRefreshFns = (window.__grtUpsellAfterUploadFns || []).slice(before);\n          if (showNow) initPanel(panel);\n        })\n        .catch(function () { delete fetches[tab]; });\n      return fetches[tab];\n    }\n\n    function switchTab(tab) {\n      if (!tab) return;\n      var panels = root.querySelectorAll(\".nt-blank-tabs__panel\");\n      for (var i = 0; i < panels.length; i++) {\n        panels[i].style.display = panels[i].getAttribute(\"data-tab\") === tab ? \"\" : \"none\";\n      }\n      var tabs = root.querySelectorAll(\".nt-blank-tabs__tab\");\n      for (var j = 0; j < tabs.length; j++) {\n        var on = tabs[j].getAttribute(\"data-tab\") === tab;\n        tabs[j].classList.toggle(\"nt-blank-tabs__tab--active\", on);\n        tabs[j].setAttribute(\"aria-selected\", String(on));\n      }\n      var p = panelFor(tab);\n      if (!p) return;\n      // Not loaded yet \u2192 fetch + init on arrival. Prefetched-but-not-inited \u2192 init\n      // now (first show). Already inited \u2192 nothing (no re-init = no flash).\n      if (p.getAttribute(\"data-loaded\") === \"false\") fetchTab(tab, true);\n      else initPanel(p);\n    }\n\n    root.addEventListener(\"click\", function (e) {\n      var btn = e.target.closest ? e.target.closest(\".nt-blank-tabs__tab\") : null;\n      if (btn && root.contains(btn)) switchTab(btn.getAttribute(\"data-tab\"));\n    });\n\n    // \u2500\u2500 On the page's post-upload signal: reveal the active (eager) tab \u2500\u2500\n    // Only the first tab loads up front; every other tab loads on click and shows its\n    // skeleton while fetching (deliberately NOT prefetched, so the loading state is\n    // visible and the skeleton\u2192cards swap is seamless \u2014 same height, no shift).\n    // Reveal the eager first tab via its own fn (initPanel), not the global refresh,\n    // to avoid re-initialising other blocks.\n    var loaded = false;\n    function loadActive() {\n      if (loaded) return;\n      loaded = true;\n      var tab = activeTab();\n      var p = panelFor(tab);\n      if (p && p.getAttribute(\"data-loaded\") === \"false\") fetchTab(tab, true);\n      else initPanel(p, eagerFns);\n    }\n\n    var bsv4 = root.closest ? root.closest(\".bsv4\") : null;\n    function isUploaded() {\n      return bsv4 ? bsv4.getAttribute(\"data-state\") === \"uploaded\" : true;\n    }\n\n    if (isUploaded()) {\n      loadActive(); // page loaded already-uploaded (bfcache / return visit)\n    }\n    document.addEventListener(\"bsv4:file-uploaded\", loadActive);\n    if (bsv4) {\n      var mo = new MutationObserver(function () {\n        if (isUploaded()) { loadActive(); mo.disconnect(); }\n      });\n      mo.observe(bsv4, { attributes: true, attributeFilter: [\"data-state\"] });\n    }\n  }\n\n  function initAll() {\n    var roots = document.querySelectorAll(\"[data-nt-blank-tabs]\");\n    for (var i = 0; i < roots.length; i++) initRoot(roots[i]);\n  }\n\n  if (document.readyState === \"loading\") {\n    document.addEventListener(\"DOMContentLoaded\", initAll);\n  } else {\n    initAll();\n  }\n  document.addEventListener(\"shopify:section:load\", initAll);\n})();\n"],
  "mappings": "CAeC,UAAY,CACX,aAEA,SAAS,gBAAgB,UAAW,CAElC,QADI,QAAU,UAAU,iBAAiB,QAAQ,EACxC,EAAI,EAAG,EAAI,QAAQ,OAAQ,IAAK,CACvC,IAAI,IAAM,QAAQ,CAAC,EACf,GAAK,SAAS,cAAc,QAAQ,EACpC,IAAI,IAAO,GAAG,IAAM,IAAI,IAAc,GAAG,YAAc,IAAI,YAC/D,QAAS,EAAI,EAAG,EAAI,IAAI,WAAW,OAAQ,IAAK,CAC9C,IAAI,K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