{
  "version": 3,
  "sources": ["/cdn/shop/t/5/assets/mega-menu.js?cb=643"],
  "sourcesContent": ["/* Position + animate the header mega-menu dropdowns.\n\n   Positioning: the panel drops below the whole (possibly two-row) nav via CSS\n   (top:100%); align() sets its left so it lines up under the trigger you opened \u2014\n   or, when the panel is too wide to sit there, centers it on the trigger so a wide\n   menu like \"Other TCG\" reads as a balanced, centered block.\n\n   Close: a native <details> stops painting its content the instant it closes, so we\n   fade the panel out first, then actually close it.\n\n   Everything is wired with document-level *capture* delegation rather than\n   per-element listeners, so it keeps working no matter when the header section\n   renders or re-renders (the earlier per-element version silently missed the live\n   elements). Note: the <details> 'toggle' event does not bubble, but capture-phase\n   listeners on the document still receive it on the way down to the target. */\n(function () {\n  var GUTTER = 16;\n  var MENU_SEL = '.header__inline-menu details.mega-menu';\n\n  function align(details) {\n    var content = details.querySelector('.mega-menu__content');\n    var summary = details.querySelector('summary');\n    var nav = details.closest('.header__inline-menu');\n    if (!content || !summary || !nav) return;\n    var vw = window.innerWidth;\n    var navRect = nav.getBoundingClientRect();\n    var sumRect = summary.getBoundingClientRect();\n    var width = content.getBoundingClientRect().width || content.offsetWidth || 400;\n    // First choice: line the panel's left edge up under the trigger.\n    var left = sumRect.left - navRect.left;\n    // If the panel is too wide to sit under the trigger (it would run off the right\n    // edge), don't jam it against the edge \u2014 center it on the trigger instead.\n    if (navRect.left + left + width > vw - GUTTER) {\n      var abs = sumRect.left + sumRect.width / 2 - width / 2; // center on the trigger\n      abs = Math.max(GUTTER, Math.min(abs, vw - GUTTER - width)); // keep on screen\n      left = abs - navRect.left;\n    }\n    if (navRect.left + left < GUTTER) left = GUTTER - navRect.left;\n    // use !important so it beats the CSS `left: 0 !important` fallback\n    content.style.setProperty('left', left + 'px', 'important');\n  }\n\n  function scheduleAlign(details) {\n    // two frames so the panel has laid out its columns, plus a late backup for\n    // wide panels whose width settles a beat after opening\n    requestAnimationFrame(function () {\n      requestAnimationFrame(function () { align(details); });\n    });\n    setTimeout(function () { if (details.open) align(details); }, 90);\n  }\n\n  function closestMenu(node) {\n    return node && node.closest ? node.closest(MENU_SEL) : null;\n  }\n\n  // Open: the <details> fires a (non-bubbling) 'toggle' \u2014 catch it in the capture\n  // phase at the document so it fires regardless of header render timing.\n  document.addEventListener('toggle', function (e) {\n    var d = e.target;\n    if (d && d.matches && d.matches(MENU_SEL) && d.open) scheduleAlign(d);\n  }, true);\n\n  // Close: fade the panel out first, then actually close it.\n  document.addEventListener('click', function (e) {\n    var summary = e.target.closest ? e.target.closest(MENU_SEL + ' > summary') : null;\n    if (!summary) return;\n    var d = summary.parentElement;\n    if (d.dataset.closing) {\n      // a close animation is mid-flight \u2014 swallow further clicks so the native\n      // <details> can't snap shut without the fade\n      e.preventDefault();\n      e.stopImmediatePropagation();\n      return;\n    }\n    if (d.open) {\n      e.preventDefault();\n      e.stopImmediatePropagation();\n      d.dataset.closing = '1';\n      var content = d.querySelector('.mega-menu__content');\n      if (content) content.classList.add('is-closing');\n      setTimeout(function () {\n        if (content) content.classList.remove('is-closing');\n        d.open = false;\n        delete d.dataset.closing;\n      }, 300);\n    }\n  }, true);\n\n  window.addEventListener('resize', function () {\n    Array.prototype.forEach.call(document.querySelectorAll(MENU_SEL + '[open]'), align);\n  });\n\n  // Align any menu already open at load.\n  function initialAlign() {\n    Array.prototype.forEach.call(document.querySelectorAll(MENU_SEL + '[open]'), scheduleAlign);\n  }\n  if (document.readyState !== 'loading') initialAlign();\n  else document.addEventListener('DOMContentLoaded', initialAlign);\n})();\n\n/* Nav dividers: the CSS draws a hairline BEFORE each item in the header nav and the\n   footer Shop links, but only on items marked .nav-divide \u2014 items that CONTINUE a\n   visual row. Both lists wrap responsively, so without this the first item of a\n   wrapped row would start with a stray floating divider. Fail-safe by design: if\n   this never runs, there are simply no dividers (never a wrong one). */\n(function () {\n  var LISTS = [\n    '.header__inline-menu > ul',\n    '.footer-block--menu ul.footer-block__details-content',\n  ];\n  function markList(ul) {\n    var prevTop = null;\n    Array.prototype.forEach.call(ul.children, function (li) {\n      var top = li.getBoundingClientRect().top;\n      // divider only when this item sits on the same row as the previous one.\n      // Tolerance, not equality: sub-pixel layout can put same-row items ~1px\n      // apart (seen live in the footer), while a real row jump is 40px+.\n      li.classList.toggle('nav-divide', prevTop !== null && Math.abs(top - prevTop) < 10);\n      prevTop = top;\n    });\n  }\n  function markRows() {\n    LISTS.forEach(function (sel) {\n      Array.prototype.forEach.call(document.querySelectorAll(sel), markList);\n    });\n  }\n  var t;\n  window.addEventListener('resize', function () {\n    clearTimeout(t);\n    t = setTimeout(markRows, 80);\n  });\n  // fonts can reflow the nav (and change where rows wrap) after DOMContentLoaded\n  if (document.fonts && document.fonts.ready && document.fonts.ready.then) {\n    document.fonts.ready.then(markRows).catch(function () {});\n  }\n  if (document.readyState !== 'loading') markRows();\n  else document.addEventListener('DOMContentLoaded', markRows);\n})();\n"],
  "mappings": "CAeC,UAAY,CACX,IAAI,OAAS,GACT,SAAW,yCAEf,SAAS,MAAM,QAAS,CACtB,IAAI,QAAU,QAAQ,cAAc,qBAAqB,EACrD,QAAU,QAAQ,cAAc,SAAS,EACzC,IAAM,QAAQ,QAAQ,sBAAsB,EAChD,GAAI,GAAC,SAAW,CAAC,SAAW,CAAC,KAC7B,KAAI,GAAK,OAAO,WACZ,QAAU,IAAI,sBAAsB,EACpC,QAAU,QAAQ,sBAAsB,EACxC,MAAQ,QAAQ,sBAAsB,EAAE,OAAS,QAAQ,aAAe,IAExE,KAAO,QAAQ,KAAO,QAAQ,KAGlC,GAAI,QAAQ,KAAO,KAAO,MAAQ,GAAK,OAAQ,CAC7C,IAAI,IAAM,QAAQ,KAAO,QAAQ,MAAQ,EAAI,MAAQ,EACrD,IAAM,KAAK,IAAI,OAAQ,KAAK,IAAI,IAAK,GAAK,OAAS,KAAK,CAAC,EACzD,KAAO,IAAM,QAAQ,IACvB,CACI,QAAQ,KAAO,KAAO,SAAQ,KAAO,OAAS,QAAQ,MAE1D,QAAQ,MAAM,YAAY,OAAQ,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