{
  "version": 3,
  "sources": ["/cdn/shop/t/226/assets/btk-style-swatches.js?cb=1"],
  "sourcesContent": ["/**\n * btk-style-swatches.js - on-demand door-swatch loader\n * ----------------------------------------------------------------\n * window.BTKStyleSwatchesReady() -> Promise, resolves once every style's\n * doorSwatches map is populated on window.BTKStyleData.\n *\n * WHY THIS EXISTS (measured 2026-08-17): the swatch map used to be inlined into\n * the BTKStyleData block in sections/header.liquid, i.e. on EVERY page of the\n * site - 159KB, and 703 image_url calls that dominated a 2.32s homepage render.\n * Only three surfaces read it (kitchen-styles listing, search results,\n * predictive search) and all three need it in response to a user action, not at\n * page load. So it now comes from /cart?view=swatches and is cached for the\n * session.\n *\n * It MERGES the result onto BTKStyleData[handle].doorSwatches - the shape the\n * data had when it was inline - so every existing reader keeps working with no\n * change beyond awaiting this first. `name` and `collectionHandle` stay inline\n * in the header because the 3D thumbnail bootstrap and the planner read\n * collectionHandle synchronously at boot.\n */\nwindow.BTKStyleSwatchesReady = (function () {\n  const CACHE_KEY = 'btk_style_swatches_v1';\n  let promise = null;\n\n  function merge(map) {\n    if (!map || !window.BTKStyleData) return;\n    Object.keys(map).forEach(function (handle) {\n      const entry = window.BTKStyleData[handle];\n      if (entry) entry.doorSwatches = map[handle] || {};\n    });\n  }\n\n  function alreadyLoaded() {\n    const d = window.BTKStyleData;\n    if (!d) return false;\n    // Inline data (or a previous merge) is present if ANY style has swatches.\n    return Object.keys(d).some(function (h) {\n      const s = d[h] && d[h].doorSwatches;\n      return s && Object.keys(s).length > 0;\n    });\n  }\n\n  function run() {\n    if (alreadyLoaded()) return Promise.resolve();\n\n    let cached = null;\n    try { cached = JSON.parse(sessionStorage.getItem(CACHE_KEY) || 'null'); } catch (e) {}\n    if (cached) { merge(cached); return Promise.resolve(); }\n\n    return fetch('/cart?view=swatches', { credentials: 'same-origin' })\n      .then(function (r) {\n        if (!r.ok) throw new Error('swatch fetch ' + r.status);\n        return r.text();\n      })\n      .then(function (text) {\n        // Sandbox-eval: this endpoint sets its own global and must not be able\n        // to touch anything else on the page.\n        const sandbox = {};\n        try { (new Function('window', text))(sandbox); } catch (e) { return; }\n        const map = sandbox.BTKStyleSwatches;\n        if (!map) return;\n        try { sessionStorage.setItem(CACHE_KEY, JSON.stringify(map)); } catch (e) {}\n        merge(map);\n      })\n      .catch(function (e) {\n        // Swatches are decorative - a failure means colour chips render without\n        // an image, never a broken page. Reset so a later call can retry.\n        console.warn('[BTK] door swatches unavailable:', e);\n        promise = null;\n      });\n  }\n\n  return function ensureStyleSwatches() {\n    if (!promise) promise = run();\n    return promise;\n  };\n})();\n"],
  "mappings": "AAoBA,OAAO,uBAAyB,UAAY,CAC1C,MAAM,UAAY,wBAClB,IAAI,QAAU,KAEd,SAAS,MAAM,IAAK,CACd,CAAC,KAAO,CAAC,OAAO,cACpB,OAAO,KAAK,GAAG,EAAE,QAAQ,SAAU,OAAQ,CACzC,MAAM,MAAQ,OAAO,aAAa,MAAM,EACpC,QAAO,MAAM,aAAe,IAAI,MAAM,GAAK,CAAC,EAClD,CAAC,CACH,CAEA,SAAS,eAAgB,CACvB,MAAM,EAAI,OAAO,aACjB,OAAK,EAEE,OAAO,KAAK,CAAC,EAAE,KAAK,SAAU,EAAG,CACtC,MAAM,EAAI,EAAE,CAAC,GAAK,EAAE,CAAC,EAAE,aACvB,OAAO,GAAK,OAAO,KAAK,CAAC,EAAE,OAAS,CACtC,CAAC,EALc,EAMjB,CAEA,SAAS,KAAM,CACb,GAAI,cAAc,EAAG,OAAO,QAAQ,QAAQ,EAE5C,IAAI,OAAS,KACb,GAAI,CAAE,OAAS,KAAK,MAAM,eAAe,QAAQ,SAAS,GAAK,MAAM,CAAG,MAAY,CAAC,CACrF,OAAI,QAAU,MAAM,MAAM,EAAU,QAAQ,QAAQ,GAE7C,MAAM,sBAAuB,CAAE,YAAa,aAAc,CAAC,EAC/D,KAAK,SAAU,EAAG,CACjB,GAAI,CAAC,EAAE,GAAI,MAAM,IAAI,MAAM,gBAAkB,EAAE,MAAM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