{
  "version": 3,
  "sources": ["/cdn/shop/t/31/assets/cart.js?version=5.0"],
  "sourcesContent": ["class CartRemoveButton extends HTMLElement {\n  constructor() {\n    super();\n\n    this.addEventListener('click', (event) => {\n      event.preventDefault();\n      const cartItems = this.closest('cart-items') || this.closest('cart-drawer-items');\n      cartItems.updateQuantity(this.dataset.index, 0);\n    });\n  }\n}\n\ncustomElements.define('cart-remove-button', CartRemoveButton);\n\nclass CartItems extends HTMLElement {\n  constructor() {\n    super();\n    this.lineItemStatusElement = document.getElementById('shopping-cart-line-item-status') || document.getElementById('CartDrawer-LineItemStatus');\n\n    const debouncedOnChange = debounce((event) => {\n      this.onChange(event);\n    }, ON_CHANGE_DEBOUNCE_TIMER);\n\n    this.addEventListener('change', debouncedOnChange.bind(this));\n  }\n\n  cartUpdateUnsubscriber = undefined;\n\n  connectedCallback() {\n    this.cartUpdateUnsubscriber = subscribe(PUB_SUB_EVENTS.cartUpdate, (event) => {\n      if (event.source === 'cart-items') {\n        return;\n      }\n      this.onCartUpdate();\n    });\n  }\n\n  disconnectedCallback() {\n    if (this.cartUpdateUnsubscriber) {\n      this.cartUpdateUnsubscriber();\n    }\n  }\n\n  onChange(event) {\n    this.updateQuantity(event.target.dataset.index, event.target.value, document.activeElement.getAttribute('name'));\n  }\n\n  onCartUpdate() {\n    fetch('/cart?section_id=main-cart-items')\n      .then((response) => response.text())\n      .then((responseText) => {\n        const html = new DOMParser().parseFromString(responseText, 'text/html');\n        const sourceQty = html.querySelector('cart-items');\n        this.innerHTML = sourceQty.innerHTML;\n      })\n      .catch(e => {\n        console.error(e);\n      });\n  }\n\n  getSectionsToRender() {\n    return [\n      {\n        id: 'main-cart-items',\n        section: document.getElementById('main-cart-items').dataset.id,\n        selector: '.js-contents'\n      },\n      {\n        id: 'cart-icon-bubble',\n        section: 'cart-icon-bubble',\n        selector: '.shopify-section'\n      },\n      {\n        id: 'cart-live-region-text',\n        section: 'cart-live-region-text',\n        selector: '.shopify-section'\n      },\n      {\n        id: 'main-cart-footer',\n        section: document.getElementById('main-cart-footer').dataset.id,\n        selector: '.js-contents'\n      }\n    ];\n  }\n\n  updateQuantity(line, quantity, name) {\n    this.enableLoading(line);\n\n    const body = JSON.stringify({\n      line,\n      quantity,\n      sections: this.getSectionsToRender().map((section) => section.section),\n      sections_url: window.location.pathname\n    });\n\n    fetch(`${routes.cart_change_url}`, { ...fetchConfig(), ...{ body } })\n      .then((response) => {\n        return response.text();\n      })\n      .then((state) => {\n        const parsedState = JSON.parse(state);\n        const quantityElement = document.getElementById(`Quantity-${line}`) || document.getElementById(`Drawer-quantity-${line}`);\n        const items = document.querySelectorAll('.cart-item');\n\n        if (parsedState.errors) {\n          quantityElement.value = quantityElement.getAttribute('value');\n          this.updateLiveRegions(line, parsedState.errors);\n          return;\n        }\n\n        this.classList.toggle('is-empty', parsedState.item_count === 0);\n        const cartDrawerWrapper = document.querySelector('cart-drawer');\n        const cartFooter = document.getElementById('main-cart-footer');\n\n        if (cartFooter) cartFooter.classList.toggle('is-empty', parsedState.item_count === 0);\n        if (cartDrawerWrapper) cartDrawerWrapper.classList.toggle('is-empty', parsedState.item_count === 0);\n\n        this.getSectionsToRender().forEach((section => {\n          const elementToReplace = \n            document.getElementById(section.id).querySelector(section.selector) || document.getElementById(section.id);\n          elementToReplace.innerHTML = \n            this.getSectionInnerHTML(parsedState.sections[section.section], section.selector);\n        }));\n        const updatedValue = parsedState.items[line - 1] ? parsedState.items[line - 1].quantity : undefined;\n        let message = '';\n        if (items.length === parsedState.items.length && updatedValue !== parseInt(quantityElement.value)) {\n          if (typeof updatedValue === 'undefined') {\n            message = window.cartStrings.error;\n          } else {\n            message = window.cartStrings.quantityError.replace('[quantity]', updatedValue);\n          }\n        }\n        this.updateLiveRegions(line, message);\n\n        const lineItem = document.getElementById(`CartItem-${line}`) || document.getElementById(`CartDrawer-Item-${line}`);\n        if (lineItem && lineItem.querySelector(`[name=\"${name}\"]`)) {\n          cartDrawerWrapper ? trapFocus(cartDrawerWrapper, lineItem.querySelector(`[name=\"${name}\"]`)) : lineItem.querySelector(`[name=\"${name}\"]`).focus();\n        } else if (parsedState.item_count === 0 && cartDrawerWrapper) {\n          trapFocus(cartDrawerWrapper.querySelector('.drawer__inner-empty'), cartDrawerWrapper.querySelector('a'))\n        } else if (document.querySelector('.cart-item') && cartDrawerWrapper) {\n          trapFocus(cartDrawerWrapper, document.querySelector('.cart-item__name'))\n        }\n        publish(PUB_SUB_EVENTS.cartUpdate, {source: 'cart-items'});\n      }).catch(() => {\n        this.querySelectorAll('.loading-overlay').forEach((overlay) => overlay.classList.add('hidden'));\n        const errors = document.getElementById('cart-errors') || document.getElementById('CartDrawer-CartErrors');\n        errors.textContent = window.cartStrings.error;\n      })\n      .finally(() => {\n        this.disableLoading(line);\n      });\n  }\n\n  updateLiveRegions(line, message) {\n    const lineItemError = document.getElementById(`Line-item-error-${line}`) || document.getElementById(`CartDrawer-LineItemError-${line}`);\n    if (lineItemError) lineItemError.querySelector('.cart-item__error-text').innerHTML = message;\n\n    this.lineItemStatusElement.setAttribute('aria-hidden', true);\n\n    const cartStatus = document.getElementById('cart-live-region-text') || document.getElementById('CartDrawer-LiveRegionText');\n    cartStatus.setAttribute('aria-hidden', false);\n\n    setTimeout(() => {\n      cartStatus.setAttribute('aria-hidden', true);\n    }, 1000);\n  }\n\n  getSectionInnerHTML(html, selector) {\n    return new DOMParser()\n      .parseFromString(html, 'text/html')\n      .querySelector(selector).innerHTML;\n  }\n\n  enableLoading(line) {\n    const mainCartItems = document.getElementById('main-cart-items') || document.getElementById('CartDrawer-CartItems');\n    mainCartItems.classList.add('cart__items--disabled');\n\n    const cartItemElements = this.querySelectorAll(`#CartItem-${line} .loading-overlay`);\n    const cartDrawerItemElements = this.querySelectorAll(`#CartDrawer-Item-${line} .loading-overlay`);\n\n    [...cartItemElements, ...cartDrawerItemElements].forEach((overlay) => overlay.classList.remove('hidden'));\n\n    document.activeElement.blur();\n    this.lineItemStatusElement.setAttribute('aria-hidden', false);\n  }\n\n  disableLoading(line) {\n    const mainCartItems = document.getElementById('main-cart-items') || document.getElementById('CartDrawer-CartItems');\n    mainCartItems.classList.remove('cart__items--disabled');\n\n    const cartItemElements = this.querySelectorAll(`#CartItem-${line} .loading-overlay`);\n    const cartDrawerItemElements = this.querySelectorAll(`#CartDrawer-Item-${line} .loading-overlay`);\n\n    cartItemElements.forEach((overlay) => overlay.classList.add('hidden'));\n    cartDrawerItemElements.forEach((overlay) => overlay.classList.add('hidden'));\n  }\n}\n\ncustomElements.define('cart-items', CartItems);\n\nif (!customElements.get('cart-note')) {\n  customElements.define('cart-note', class CartNote extends HTMLElement {\n      constructor() {\n        super();\n\n      this.addEventListener('change', debounce((event) => {\n            const body = JSON.stringify({ note: event.target.value });\n            fetch(`${routes.cart_update_url}`, { ...fetchConfig(), ...{ body } });\n      }, ON_CHANGE_DEBOUNCE_TIMER))\n      }\n  });\n};\n"],
  "mappings": "AAAA,MAAM,yBAAyB,WAAY,CACzC,aAAc,CACZ,MAAM,EAEN,KAAK,iBAAiB,QAAU,OAAU,CACxC,MAAM,eAAe,GACH,KAAK,QAAQ,YAAY,GAAK,KAAK,QAAQ,mBAAmB,GACtE,eAAe,KAAK,QAAQ,MAAO,CAAC,CAChD,CAAC,CACH,CACF,CAEA,eAAe,OAAO,qBAAsB,gBAAgB,EAE5D,MAAM,kBAAkB,WAAY,CAClC,aAAc,CACZ,MAAM,EACN,KAAK,sBAAwB,SAAS,eAAe,gCAAgC,GAAK,SAAS,eAAe,2BAA2B,EAE7I,MAAM,kBAAoB,SAAU,OAAU,CAC5C,KAAK,SAAS,KAAK,CACrB,EAAG,wBAAwB,EAE3B,KAAK,iBAAiB,SAAU,kBAAkB,KAAK,IAAI,CAAC,CAC9D,CAEA,uBAAyB,OAEzB,mBAAoB,CAClB,KAAK,uBAAyB,UAAU,eAAe,WAAa,OAAU,CACxE,MAAM,SAAW,cAGrB,KAAK,aAAa,CACpB,CAAC,CACH,CAEA,sBAAuB,CACjB,KAAK,w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