{
  "version": 3,
  "sources": ["/cdn/shop/t/6/assets/header-drawer.js?v=121243031541024704371790720035"],
  "sourcesContent": ["import { Component } from '@theme/component';\nimport { trapFocus, removeTrapFocus } from '@theme/focus';\nimport { onAnimationEnd, removeWillChangeOnAnimationEnd } from '@theme/utilities';\n\n/**\n * A custom element that manages the main menu drawer.\n *\n * @typedef {object} Refs\n * @property {HTMLDetailsElement} details - The details element.\n * @property {HTMLDivElement} menuDrawer - The slideable drawer panel containing the menu.\n *\n * @extends {Component<Refs>}\n */\nclass HeaderDrawer extends Component {\n  requiredRefs = ['details', 'menuDrawer'];\n\n  connectedCallback() {\n    super.connectedCallback();\n\n    this.addEventListener('keyup', this.#onKeyUp);\n    this.#setupAnimatedElementListeners();\n  }\n\n  disconnectedCallback() {\n    super.disconnectedCallback();\n    this.removeEventListener('keyup', this.#onKeyUp);\n  }\n\n  /**\n   * Close the main menu drawer when the Escape key is pressed\n   * @param {KeyboardEvent} event\n   */\n  #onKeyUp = (event) => {\n    if (event.key !== 'Escape') return;\n\n    this.#close(this.#getDetailsElement(event));\n  };\n\n  /**\n   * @returns {boolean} Whether the main menu drawer is open\n   */\n  get isOpen() {\n    return this.refs.details.hasAttribute('open');\n  }\n\n  /**\n   * Get the closest details element to the event target\n   * @param {Event | undefined} event\n   * @returns {HTMLDetailsElement}\n   */\n  #getDetailsElement(event) {\n    if (!(event?.target instanceof Element)) return this.refs.details;\n\n    return event.target.closest('details') ?? this.refs.details;\n  }\n\n  /**\n   * Toggle the main menu drawer\n   */\n  toggle() {\n    return this.isOpen ? this.close() : this.open();\n  }\n\n  /**\n   * Open the closest drawer or the main menu drawer\n   * @param {string} [target]\n   * @param {Event} [event]\n   */\n  open(target, event) {\n    const details = this.#getDetailsElement(event);\n    const summary = details.querySelector('summary');\n\n    if (!summary) return;\n\n    summary.setAttribute('aria-expanded', 'true');\n\n    this.preventInitialAccordionAnimations(details);\n    requestAnimationFrame(() => {\n      details.classList.add('menu-open');\n\n      if (target) {\n        this.refs.menuDrawer.classList.add('menu-drawer--has-submenu-opened');\n      }\n\n      // Wait for the drawer animation to complete before trapping focus\n      const drawer = details.querySelector('.menu-drawer, .menu-drawer__submenu');\n      onAnimationEnd(drawer || details, () => trapFocus(details), { subtree: false });\n    });\n  }\n\n  /**\n   * Go back or close the main menu drawer\n   * @param {Event} [event]\n   */\n  back(event) {\n    this.#close(this.#getDetailsElement(event));\n  }\n\n  /**\n   * Close the main menu drawer\n   */\n  close() {\n    this.#close(this.refs.details);\n  }\n\n  /**\n   * Close the closest menu or submenu that is open\n   *\n   * @param {HTMLDetailsElement} details\n   */\n  #close(details) {\n    const summary = details.querySelector('summary');\n\n    if (!summary) return;\n\n    summary.setAttribute('aria-expanded', 'false');\n    details.classList.remove('menu-open');\n    this.refs.menuDrawer.classList.remove('menu-drawer--has-submenu-opened');\n\n    // Wait for the .menu-drawer element's transition, not the entire details subtree\n    // This avoids waiting for child accordion/resource-card animations which can cause issues on Firefox\n    const drawer = details.querySelector('.menu-drawer, .menu-drawer__submenu');\n\n    onAnimationEnd(\n      drawer || details,\n      () => {\n        reset(details);\n        if (details === this.refs.details) {\n          removeTrapFocus();\n          const openDetails = this.querySelectorAll('details[open]:not(accordion-custom > details)');\n          openDetails.forEach(reset);\n        } else {\n          trapFocus(this.refs.details);\n        }\n      },\n      { subtree: false }\n    );\n  }\n\n  /**\n   * Attach animationend event listeners to all animated elements to remove will-change after animation\n   * to remove the stacking context and allow submenus to be positioned correctly\n   */\n  #setupAnimatedElementListeners() {\n    const allAnimated = this.querySelectorAll('.menu-drawer__animated-element');\n    allAnimated.forEach((element) => {\n      element.addEventListener('animationend', removeWillChangeOnAnimationEnd);\n    });\n  }\n\n  /**\n   * Temporarily disables accordion animations to prevent unwanted transitions when the drawer opens.\n   * Adds a no-animation class to accordion content elements, then removes it after 100ms to\n   * re-enable animations for user interactions.\n   * @param {HTMLDetailsElement} details - The details element containing the accordions\n   */\n  preventInitialAccordionAnimations(details) {\n    const content = details.querySelectorAll('accordion-custom .details-content');\n\n    content.forEach((element) => {\n      if (element instanceof HTMLElement) {\n        element.classList.add('details-content--no-animation');\n      }\n    });\n    setTimeout(() => {\n      content.forEach((element) => {\n        if (element instanceof HTMLElement) {\n          element.classList.remove('details-content--no-animation');\n        }\n      });\n    }, 100);\n  }\n}\n\nif (!customElements.get('header-drawer')) {\n  customElements.define('header-drawer', HeaderDrawer);\n}\n\n/**\n * Reset an open details element to its original state\n *\n * @param {HTMLDetailsElement} element\n */\nfunction reset(element) {\n  element.classList.remove('menu-open');\n  element.removeAttribute('open');\n  element.querySelector('summary')?.setAttribute('aria-expanded', 'false');\n}\n"],
  "mappings": "AAAA,OAAS,cAAiB,mBAC1B,OAAS,UAAW,oBAAuB,eAC3C,OAAS,eAAgB,mCAAsC,mBAW/D,MAAM,qBAAqB,SAAU,CACnC,aAAe,CAAC,UAAW,YAAY,EAEvC,mBAAoB,CAClB,MAAM,kBAAkB,EAExB,KAAK,iBAAiB,QAAS,KAAK,QAAQ,EAC5C,KAAK,+BAA+B,CACtC,CAEA,sBAAuB,CACrB,MAAM,qBAAqB,EAC3B,KAAK,oBAAoB,QAAS,KAAK,QAAQ,CACjD,CAMA,SAAY,OAAU,CAChB,MAAM,MAAQ,UAElB,KAAK,OAAO,KAAK,mBAAmB,KAAK,CAAC,CAC5C,EAKA,IAAI,QAAS,CACX,OAAO,KAAK,KAAK,QAAQ,aAAa,MAAM,CAC9C,CAOA,mBAAmB,MAAO,CACxB,OAAM,OAAO,kBAAkB,QAExB,MAAM,OAAO,QAAQ,SAAS,GAAK,KAAK,KAAK,QAFJ,KAAK,KAAK,OAG5D,CAKA,QAAS,CACP,OAAO,KAAK,OAAS,KAAK,MAAM,EAAI,KAAK,KAAK,CAChD,CAOA,KAAK,OAAQ,MAAO,CAClB,MAAM,QAAU,KAAK,mBAAmB,KAAK,EACvC,QAAU,QAAQ,cAAc,SAAS,EAE1C,UAEL,QAAQ,aAAa,gBAAiB,MAAM,EAE5C,KAAK,kCAA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