{
  "version": 3,
  "sources": ["/cdn/shop/t/24/assets/component-cart-drawer.js"],
  "sourcesContent": ["/******/ (() => { // webpackBootstrap\n/******/ \t\"use strict\";\n/******/ \tvar __webpack_modules__ = ({\n\n/***/ 5669:\n/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {\n\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   A: () => (/* binding */ GlobalDrawer)\n/* harmony export */ });\nclass GlobalDrawer extends HTMLElement {\n  constructor() {\n    super();\n    this.closeElements = this.querySelectorAll('[data-drawer-close]');\n    this.openDrawer = this.openDrawer.bind(this);\n    this.closeDrawer = this.closeDrawer.bind(this);\n    this.closeAllDrawers = this.closeAllDrawers.bind(this);\n    this.handleResize = this.handleResize.bind(this);\n  }\n\n  connectedCallback() {\n    window.wetheme.webcomponentRegistry.register({key: 'component-drawer'});\n    window.eventBus.on('close:all:drawers', this.closeAllDrawers);\n    this.closeElements.forEach((element) => {\n      element.addEventListener('click', this.closeDrawer);\n    });\n\n    if (window.Shopify.designMode) {\n      window.addEventListener('resize', this.handleResize);\n    }\n  }\n\n  openDrawer() {\n    window.eventBus.emit('close:all:drawers', this); // Close all other global drawers before opening this one\n    this.setAttribute('aria-hidden', 'false');\n    document.body.classList.add('js-drawer-open'); // Lock scroll\n    this.addEventListener('transitionend', this.handleTransitionEnd);\n    // Emit event when drawer opens\n    window.eventBus.emit('drawer:opened', this);\n  }\n\n  closeDrawer() {\n    this.setAttribute('aria-hidden', 'true');\n    document.body.classList.remove('js-drawer-open'); // Unlock scroll\n    this.removeEventListener('transitionend', this.handleTransitionEnd);\n    // Emit event when drawer closes\n    window.eventBus.emit('drawer:closed', this);\n  }\n\n  closeAllDrawers(e) {\n    if (e === this) return; // Only close other drawers not this one\n    this.closeDrawer();\n  }\n\n  handleTransitionEnd(e) {\n    // Trap focus once drawer is fully open\n    if (e.target === this) {\n      this.trapFocus();\n    }\n  }\n\n  trapFocus() {\n    const focusableElements = this.querySelectorAll('button, [href], input:not([type=\"hidden\"]), select, textarea, [tabindex]:not([tabindex=\"-1\"])');\n    const firstFocusableElement = focusableElements[0];\n    const lastFocusableElement = focusableElements[focusableElements.length - 1];\n    firstFocusableElement.focus();\n    this.addEventListener('keydown', (e) => {\n      if (e.key === 'Tab') {\n        if (e.shiftKey) {\n          if (document.activeElement === firstFocusableElement) {\n            lastFocusableElement.focus();\n            e.preventDefault();\n          }\n        } else {\n          if (document.activeElement === lastFocusableElement) {\n            firstFocusableElement.focus();\n            e.preventDefault();\n          }\n        }\n      }\n    });\n  }\n\n  handleResize() {\n    this.classList.add('disable-transitions');\n    setTimeout(() => {\n      this.classList.remove('disable-transitions');\n    }, 500);\n  }\n\n  disconnectedCallback() {\n    if (window.Shopify.designMode) {\n      window.removeEventListener('resize', this.handleResize);\n    }\n  }\n}\n\n/***/ })\n\n/******/ \t});\n/************************************************************************/\n/******/ \t// The module cache\n/******/ \tvar __webpack_module_cache__ = {};\n/******/ \t\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/ \t\t// Check if module is in cache\n/******/ \t\tvar cachedModule = __webpack_module_cache__[moduleId];\n/******/ \t\tif (cachedModule !== undefined) {\n/******/ \t\t\treturn cachedModule.exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = __webpack_module_cache__[moduleId] = {\n/******/ \t\t\t// no module.id needed\n/******/ \t\t\t// no module.loaded needed\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/ \t\n/******/ \t\t// Execute the module function\n/******/ \t\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n/******/ \t\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/ \t\n/************************************************************************/\n/******/ \t/* webpack/runtime/define property getters */\n/******/ \t(() => {\n/******/ \t\t// define getter functions for harmony exports\n/******/ \t\t__webpack_require__.d = (exports, definition) => {\n/******/ \t\t\tfor(var key in definition) {\n/******/ \t\t\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n/******/ \t\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n/******/ \t\t\t\t}\n/******/ \t\t\t}\n/******/ \t\t};\n/******/ \t})();\n/******/ \t\n/******/ \t/* webpack/runtime/hasOwnProperty shorthand */\n/******/ \t(() => {\n/******/ \t\t__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))\n/******/ \t})();\n/******/ \t\n/************************************************************************/\nvar __webpack_exports__ = {};\n/* harmony import */ var _global_drawer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5669);\n\n\nclass CartDrawer extends _global_drawer__WEBPACK_IMPORTED_MODULE_0__/* [\"default\"] */ .A {\n  constructor() {\n    super();\n    this.dynamicContentIds = [\n      'cart-header',\n      'cart-body',\n      'cart-footer'\n    ];\n    this.scrollElement = this.querySelector('[data-cart-scroll-element]');\n    this.handleCartOpen = this.handleCartOpen.bind(this);\n    this.handleCartUpdate = this.handleCartUpdate.bind(this);\n    this.handleCartRender = this.handleCartRender.bind(this);\n  }\n\n  connectedCallback() {\n    super.connectedCallback();\n    window.wetheme.webcomponentRegistry.register({key: 'component-cart-drawer'});\n    window.eventBus.on('open:cart:drawer', this.handleCartOpen);\n    window.eventBus.on('update:cart:drawer', this.handleCartUpdate);\n    window.eventBus.on('render:cart:drawer', this.handleCartRender);\n  }\n\n  handleCartOpen(e) {\n    /* ===== Scroll to top of the cart if necessary ===== */\n    if (e?.scrollToTop && this.scrollElement) {\n      this.scrollElement.scrollTo(0, 0);\n    }\n\n    /* ===== Open the drawer ===== */\n    this.openDrawer();\n  }\n\n  handleCartUpdate(e) {\n    if (!e) return;\n    if (e.sections?.['cart-drawer']) {\n      this.renderCartDrawer(e.sections['cart-drawer']);\n    }\n  }\n\n  renderCartDrawer(html) {\n    /* ===== Re-render cart drawer with updated content ===== */\n    this.dynamicContentIds.forEach((id) => {\n      const selector = `[data-cart-dynamic-content=\"${id}\"]`;\n      const updatedContent = this.getContent(html, selector);\n      const targetElement = this.querySelector(selector);\n      if (targetElement) {\n        targetElement.innerHTML = updatedContent;\n      }\n    });\n    this.trapFocus();\n  }\n\n  async handleCartRender() {\n    /* ===== Fetch cart drawer using section rendering API (rather than bundled section rendering) - needed when adding more products to the cart than are in stock ===== */\n    try {\n      const response = await fetch(window.Shopify.routes.root + \"?sections=cart-drawer\");\n      const responseJson = await response.json();\n      if (responseJson?.['cart-drawer']) {\n        this.renderCartDrawer(responseJson['cart-drawer']);\n      }\n    } catch (error) {\n      console.error(`Failed to fetch cart drawer:`, error);\n    }\n  }\n\n  getContent(html, selector) {\n    return new DOMParser().parseFromString(html, 'text/html').querySelector(selector)?.innerHTML;\n  }\n}\n\ncustomElements.define('cart-drawer', CartDrawer);\n/******/ })()\n;"],
  "mappings": "CAAU,IAAM,CACN,aACA,IAAI,oBAAuB,CAE/B,MACC,CAAC,wBAAyBA,qBAAqBC,uBAAwB,CAEzDA,qBAAoB,EAAED,qBAAqB,CACzC,EAAG,IAAqB,YAC1B,CAAC,EACtB,MAAM,qBAAqB,WAAY,CACrC,aAAc,CACZ,MAAM,EACN,KAAK,cAAgB,KAAK,iBAAiB,qBAAqB,EAChE,KAAK,WAAa,KAAK,WAAW,KAAK,IAAI,EAC3C,KAAK,YAAc,KAAK,YAAY,KAAK,IAAI,EAC7C,KAAK,gBAAkB,KAAK,gBAAgB,KAAK,IAAI,EACrD,KAAK,aAAe,KAAK,aAAa,KAAK,IAAI,CACjD,CAEA,mBAAoB,CAClB,OAAO,QAAQ,qBAAqB,SAAS,CAAC,IAAK,kBAAkB,CAAC,EACtE,OAAO,SAAS,GAAG,oBAAqB,KAAK,eAAe,EAC5D,KAAK,cAAc,QAAS,SAAY,CACtC,QAAQ,iBAAiB,QAAS,KAAK,WAAW,CACpD,CAAC,EAEG,OAAO,QAAQ,YACjB,OAAO,iBAAiB,SAAU,KAAK,YAAY,CAEvD,CAEA,YAAa,CACX,O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