{
  "version": 3,
  "sources": ["/cdn/shop/t/1/assets/volume-pricing-info.js?v=94479640769665442661787334881"],
  "sourcesContent": ["import { Component } from '@theme/component';\n\n/**\n * Displays volume pricing information in a popover.\n * Shows quantity rules and pricing tiers with the current tier highlighted.\n * Positioning and hover behavior is handled by the parent anchored-popover-component.\n *\n * @typedef {Object} VolumePricingInfoRefs\n * @property {HTMLElement} popover - The popover element\n *\n * @extends {Component<VolumePricingInfoRefs>}\n */\nclass VolumePricingInfoComponent extends Component {\n  /**\n   * Ensures the parent anchored-popover-component refs are refreshed after connection,\n   */\n  connectedCallback() {\n    super.connectedCallback();\n    const anchoredPopover = this.closest('anchored-popover-component');\n    if (anchoredPopover instanceof Component && anchoredPopover.isConnected) {\n      try {\n        anchoredPopover.updatedCallback();\n      } catch (error) {\n        Promise.resolve().then(() => {\n          if (anchoredPopover.isConnected) {\n            try {\n              anchoredPopover.updatedCallback();\n            } catch (e) {}\n          }\n        });\n      }\n    }\n  }\n\n  /**\n   * Ensures the parent anchored-popover-component refs are refreshed immediately,\n   */\n  updatedCallback() {\n    super.updatedCallback();\n    const anchoredPopover = this.closest('anchored-popover-component');\n    if (anchoredPopover instanceof Component) {\n      anchoredPopover.updatedCallback();\n    }\n  }\n\n  /**\n   * Updates the highlighted price tier based on current quantity\n   * @param {number} quantity - The current quantity\n   */\n  updateActiveTier(quantity) {\n    const anchoredPopover = this.closest('anchored-popover-component');\n    const popover = anchoredPopover instanceof Component ? anchoredPopover.refs?.popover : null;\n    const rows = popover?.querySelectorAll('.volume-pricing-info__row[data-quantity]');\n    if (!rows) return;\n\n    let activeTier = null;\n    for (const row of rows) {\n      row.classList.remove('volume-pricing-info__row--active');\n      if (row instanceof HTMLElement && quantity >= parseInt(row.dataset.quantity || '0')) {\n        activeTier = row;\n      }\n    }\n    activeTier?.classList.add('volume-pricing-info__row--active');\n  }\n}\n\nif (!customElements.get('volume-pricing-info')) {\n  customElements.define('volume-pricing-info', VolumePricingInfoComponent);\n}\n"],
  "mappings": "AAAA,OAAS,cAAiB,mBAY1B,MAAM,mCAAmC,SAAU,CAIjD,mBAAoB,CAClB,MAAM,kBAAkB,EACxB,MAAM,gBAAkB,KAAK,QAAQ,4BAA4B,EACjE,GAAI,2BAA2B,WAAa,gBAAgB,YAC1D,GAAI,CACF,gBAAgB,gBAAgB,CAClC,MAAgB,CACd,QAAQ,QAAQ,EAAE,KAAK,IAAM,CAC3B,GAAI,gBAAgB,YAClB,GAAI,CACF,gBAAgB,gBAAgB,CAClC,MAAY,CAAC,CAEjB,CAAC,CACH,CAEJ,CAKA,iBAAkB,CAChB,MAAM,gBAAgB,EACtB,MAAM,gBAAkB,KAAK,QAAQ,4BAA4B,EAC7D,2BAA2B,WAC7B,gBAAgB,gBAAgB,CAEpC,CAMA,iBAAiB,SAAU,CACzB,MAAM,gBAAkB,KAAK,QAAQ,4BAA4B,EAE3D,MADU,2BAA2B,UAAY,gBAAgB,MAAM,QAAU,OACjE,iBAAiB,0CAA0C,EACjF,GAAI,CAAC,KAAM,OAEX,IAAI,WAAa,KACjB,UAAW,OAAO,KAChB,IAAI,UAAU,OAAO,kCAAkC,EACnD,eAAe,aAAe,UAAY,SAAS,IAAI,QAAQ,UAAY,GAAG,IAChF,WAAa,KAGjB,YAAY,UAAU,IAAI,kCAAkC,CAC9D,CACF,CAEK,eAAe,IAAI,qBAAqB,GAC3C,eAAe,OAAO,sBAAuB,0BAA0B",
  "names": []
}
