{
  "version": 3,
  "sources": ["/cdn/shop/t/48/assets/sw-overlap.js?t=1789572023911"],
  "sourcesContent": ["/* =============================================================\n   SW OVERLAP  \u00B7  Everyday Chemist\n   Behaviour for sections/sw-overlap-scroll.liquid.\n\n   Marks every section above the marker as a sticky \"card\" and\n   keeps --sw-stack-h in sync with its real height. No scroll\n   handlers: the stacking itself is pure CSS position: sticky.\n   ============================================================= */\n(function () {\n  'use strict';\n\n  var MOBILE = window.matchMedia('(max-width: 749px)');\n  var instances = [];\n\n  function sectionsAround(holder) {\n    var before = [], after = [], el;\n    for (el = holder.previousElementSibling; el; el = el.previousElementSibling) {\n      if (el.classList.contains('shopify-section')) before.unshift(el);\n    }\n    for (el = holder.nextElementSibling; el; el = el.nextElementSibling) {\n      if (el.classList.contains('shopify-section')) after.push(el);\n    }\n    return { before: before, after: after };\n  }\n\n  // Sections pin just under the fixed header. The first one may start higher\n  // than that (a transparent homepage header lays over it), and a sticky `top`\n  // below its own starting point would push it down and open a gap behind the\n  // header. So it never pins lower than where it naturally starts.\n  function pinFirst(s) {\n    var prev = s.previousElementSibling;\n    var start = prev\n      ? prev.getBoundingClientRect().bottom\n      : s.parentElement.getBoundingClientRect().top + (parseFloat(getComputedStyle(s.parentElement).paddingTop) || 0);\n    start = Math.max(0, Math.round(start + window.scrollY));\n    var header = parseFloat(getComputedStyle(document.documentElement).getPropertyValue('--ec-header-height')) || 0;\n    if (start < header) s.style.setProperty('--sw-stack-top', start + 'px');\n    else s.style.removeProperty('--sw-stack-top');\n  }\n\n  function teardown(inst) {\n    if (inst.ro) inst.ro.disconnect();\n    inst.before.forEach(function (s) {\n      s.classList.remove('sw-stack');\n      s.style.removeProperty('--sw-stack-z');\n      s.style.removeProperty('--sw-stack-h');\n      s.style.removeProperty('--sw-stack-top');\n    });\n    inst.after.forEach(function (s) {\n      s.classList.remove('sw-stack-after');\n      s.style.removeProperty('--sw-stack-z');\n    });\n    if (inst.parent) inst.parent.classList.remove('sw-overlap-shadow');\n  }\n\n  function setup(marker) {\n    var holder = marker.closest('.shopify-section');\n    if (!holder || !holder.parentElement) return;\n\n    var around = sectionsAround(holder);\n    var inst = {\n      marker: marker,\n      parent: holder.parentElement,\n      before: around.before,\n      after: around.after,\n      ro: null\n    };\n\n    var measure = function (s) {\n      s.style.setProperty('--sw-stack-h', Math.ceil(s.getBoundingClientRect().height) + 'px');\n      if (s === inst.before[0]) pinFirst(s);\n    };\n\n    inst.apply = function () {\n      var on = MOBILE.matches ? marker.getAttribute('data-mobile') === 'true'\n                              : marker.getAttribute('data-desktop') === 'true';\n      if (inst.ro) { inst.ro.disconnect(); inst.ro = null; }\n\n      inst.before.forEach(function (s, i) {\n        s.classList.toggle('sw-stack', on);\n        if (on) { s.style.setProperty('--sw-stack-z', String(i + 1)); measure(s); }\n        else { s.style.removeProperty('--sw-stack-z'); s.style.removeProperty('--sw-stack-h'); s.style.removeProperty('--sw-stack-top'); }\n      });\n      inst.after.forEach(function (s) {\n        s.classList.toggle('sw-stack-after', on);\n        if (on) s.style.setProperty('--sw-stack-z', String(inst.before.length + 1));\n        else s.style.removeProperty('--sw-stack-z');\n      });\n      inst.parent.classList.toggle('sw-overlap-shadow', on && marker.getAttribute('data-shadow') === 'true');\n\n      if (on && 'ResizeObserver' in window) {\n        // Height changes (images loading, fonts, a tab switch, a resize) re-measure;\n        // writing a custom property does not change the size, so this cannot loop.\n        inst.ro = new ResizeObserver(function (entries) {\n          entries.forEach(function (e) { measure(e.target); });\n        });\n        inst.before.forEach(function (s) { inst.ro.observe(s); });\n      }\n    };\n\n    inst.apply();\n    instances.push(inst);\n  }\n\n  function boot() {\n    instances.forEach(teardown);\n    instances = [];\n    document.querySelectorAll('[data-sw-overlap]').forEach(setup);\n  }\n\n  // Fallback re-measure. ResizeObserver covers normal cases, but some browsers\n  // skip or delay its callbacks (background tabs, older iOS). Content that\n  // grows after an interaction (bundle slots filling, option panels, tabs)\n  // must never leave a stale height, or the section would pin early and its\n  // bottom edge would be covered before it was seen. Cheap: no scroll events.\n  var remeasureTimer = null;\n  function remeasureSoon() {\n    clearTimeout(remeasureTimer);\n    remeasureTimer = setTimeout(function () {\n      instances.forEach(function (inst) {\n        inst.before.forEach(function (s) {\n          if (s.classList.contains('sw-stack')) {\n            s.style.setProperty('--sw-stack-h', Math.ceil(s.getBoundingClientRect().height) + 'px');\n            if (s === inst.before[0]) pinFirst(s);\n          }\n        });\n      });\n    }, 120);\n  }\n  document.addEventListener('click', function () { remeasureSoon(); setTimeout(remeasureSoon, 500); }, { passive: true });\n  document.addEventListener('change', remeasureSoon, { passive: true });\n  function remeasureAfterLayout() { remeasureSoon(); setTimeout(remeasureSoon, 600); }\n  window.addEventListener('resize', remeasureAfterLayout, { passive: true });\n  window.addEventListener('orientationchange', remeasureAfterLayout, { passive: true });\n  window.addEventListener('load', remeasureSoon);\n  document.addEventListener('sw:variant', remeasureSoon);\n\n  function onBreakpoint() { instances.forEach(function (i) { i.apply(); }); remeasureAfterLayout(); }\n  if (MOBILE.addEventListener) MOBILE.addEventListener('change', onBreakpoint);\n  else if (MOBILE.addListener) MOBILE.addListener(onBreakpoint);\n\n  if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', boot);\n  else boot();\n\n  // Theme editor: sections are added, removed and re-ordered live.\n  ['shopify:section:load', 'shopify:section:unload', 'shopify:section:reorder'].forEach(function (evt) {\n    document.addEventListener(evt, function () { setTimeout(boot, 0); });\n  });\n})();\n"],
  "mappings": "CAQC,UAAY,CACX,aAEA,IAAI,OAAS,OAAO,WAAW,oBAAoB,EAC/C,UAAY,CAAC,EAEjB,SAAS,eAAe,OAAQ,CAC9B,IAAI,OAAS,CAAC,EAAG,MAAQ,CAAC,EAAG,GAC7B,IAAK,GAAK,OAAO,uBAAwB,GAAI,GAAK,GAAG,uBAC/C,GAAG,UAAU,SAAS,iBAAiB,GAAG,OAAO,QAAQ,EAAE,EAEjE,IAAK,GAAK,OAAO,mBAAoB,GAAI,GAAK,GAAG,mBAC3C,GAAG,UAAU,SAA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