{
  "version": 3,
  "sources": ["/cdn/shop/t/2/assets/cart-drawer.js?id=993154%2540"],
  "sourcesContent": ["import { DialogComponent, DialogOpenEvent } from '@theme/dialog';\nimport { CartAddEvent } from '@theme/events';\n\n/**\n * A custom element that manages a cart drawer.\n *\n * @typedef {object} Refs\n * @property {HTMLDialogElement} dialog - The dialog element.\n *\n * @extends {DialogComponent}\n */\nclass CartDrawerComponent extends DialogComponent {\n  /** @type {number} */\n  #summaryThreshold = 0.5;\n\n  connectedCallback() {\n    super.connectedCallback();\n    document.addEventListener(CartAddEvent.eventName, this.#handleCartAdd);\n    this.addEventListener(DialogOpenEvent.eventName, this.#updateStickyState);\n  }\n\n  disconnectedCallback() {\n    super.disconnectedCallback();\n    document.removeEventListener(CartAddEvent.eventName, this.#handleCartAdd);\n    this.removeEventListener(DialogOpenEvent.eventName, this.#updateStickyState);\n  }\n\n  #handleCartAdd = () => {\n    if (this.hasAttribute('auto-open')) {\n      this.showDialog();\n    }\n  };\n\n  open() {\n    this.showDialog();\n\n    /**\n     * Close cart drawer when installments CTA is clicked to avoid overlapping dialogs\n     */\n    customElements.whenDefined('shopify-payment-terms').then(() => {\n      const installmentsContent = document.querySelector('shopify-payment-terms')?.shadowRoot;\n      const cta = installmentsContent?.querySelector('#shopify-installments-cta');\n      cta?.addEventListener('click', this.closeDialog, { once: true });\n    });\n  }\n\n  close() {\n    this.closeDialog();\n  }\n\n  #updateStickyState() {\n    const { dialog } = /** @type {Refs} */ (this.refs);\n    if (!dialog) return;\n\n    // Refs do not cross nested `*-component` boundaries (e.g., `cart-items-component`), so we query within the dialog.\n    const content = dialog.querySelector('.cart-drawer__content');\n    const summary = dialog.querySelector('.cart-drawer__summary');\n\n    if (!content || !summary) {\n      // Ensure the dialog doesn't get stuck in \"unsticky\" mode when summary disappears (e.g., empty cart).\n      dialog.setAttribute('cart-summary-sticky', 'false');\n      return;\n    }\n\n    const drawerHeight = dialog.getBoundingClientRect().height;\n    const summaryHeight = summary.getBoundingClientRect().height;\n    const ratio = summaryHeight / drawerHeight;\n    dialog.setAttribute('cart-summary-sticky', ratio > this.#summaryThreshold ? 'false' : 'true');\n  }\n}\n\nif (!customElements.get('cart-drawer-component')) {\n  customElements.define('cart-drawer-component', CartDrawerComponent);\n}\n"],
  "mappings": "AAAA,OAAS,gBAAiB,oBAAuB,gBACjD,OAAS,iBAAoB,gBAU7B,MAAM,4BAA4B,eAAgB,CAEhD,kBAAoB,GAEpB,mBAAoB,CAClB,MAAM,kBAAkB,EACxB,SAAS,iBAAiB,aAAa,UAAW,KAAK,cAAc,EACrE,KAAK,iBAAiB,gBAAgB,UAAW,KAAK,kBAAkB,CAC1E,CAEA,sBAAuB,CACrB,MAAM,qBAAqB,EAC3B,SAAS,oBAAoB,aAAa,UAAW,KAAK,cAAc,EACxE,KAAK,oBAAoB,gBAAgB,UAAW,KAAK,kBAAkB,CAC7E,CAEA,eAAiB,IAAM,CACjB,KAAK,aAAa,WAAW,GAC/B,KAAK,WAAW,CAEpB,EAEA,MAAO,CACL,KAAK,WAAW,EAKhB,eAAe,YAAY,uBAAuB,EAAE,KAAK,IAAM,CACjC,SAAS,cAAc,uBAAuB,GAAG,YAC5C,cAAc,2BAA2B,GACrE,iBAAiB,QAAS,KAAK,YAAa,CAAE,KAAM,EAAK,CAAC,CACjE,CAAC,CACH,CAEA,OAAQ,CACN,KAAK,YAAY,CACnB,CAEA,oBAAqB,CACnB,KAAM,CAAE,MAAO,EAAyB,KAAK,KAC7C,GAAI,CAAC,OAAQ,OAGb,MAAM,QAAU,OAAO,cAAc,uBAAuB,EACtD,QAAU,OAAO,cAAc,uBAAuB,EAE5D,GAAI,CAAC,SAAW,CAAC,QAAS,CAExB,OAAO,aAAa,sBAAuB,OAAO,EAClD,MACF,CAEA,MAAM,aAAe,OAAO,sBAAsB,EAAE,OAE9C,MADgB,QAAQ,sBAAsB,EAAE,OACxB,aAC9B,OAAO,aAAa,sBAAuB,MAAQ,KAAK,kBAAoB,QAAU,MAAM,CAC9F,CACF,CAEK,eAAe,IAAI,uBAAuB,GAC7C,eAAe,OAAO,wBAAyB,mBAAmB",
  "names": []
}
