{
  "version": 3,
  "sources": ["/cdn/shop/t/60/assets/sap-commerce-discount-codes.js?cb=s128live"],
  "sourcesContent": ["(() => {\n  if (window.sapCommerceCodes) return;\n  window.sapCommerceCodes = true;\n  customElements.whenDefined('cart-discount-code').then(() => {\n    const prototype = customElements.get('cart-discount-code').prototype;\n    const nativeCodes = prototype.existingDiscounts;\n    const nativeUpdate = prototype.updateCartContent;\n    const nativeMount = prototype.mountComponent;\n    const announced = new WeakSet();\n    // A rejected code: the input is marked invalid and described by the error, and the error is spoken through a live region that is always on the page.\n    const announce = component => {\n      if (announced.has(component) || !component.hasAttribute('data-sap-real-codes')) return;\n      const error = component.querySelector('[data-cart-discount-error]'), input = component.querySelector('[data-cart-discount-code-input]'), live = component.querySelector('[data-sap-discount-live]'), form = component.querySelector('[data-cart-discount-code-form]');\n      if (!error || !input || !live) return;\n      announced.add(component);\n      const sync = () => {\n        const shown = !error.classList.contains('hidden');\n        if (shown) { input.setAttribute('aria-invalid', 'true'); input.setAttribute('aria-describedby', error.id); live.textContent = ''; requestAnimationFrame(() => { live.textContent = error.textContent.trim(); }); }\n        else { input.removeAttribute('aria-invalid'); input.removeAttribute('aria-describedby'); live.textContent = ''; }\n      };\n      new MutationObserver(sync).observe(error, { attributes: true, attributeFilter: ['class'] });\n      form?.addEventListener('submit', () => error.classList.add('hidden'), true);\n      sync();\n    };\n    // U4 fix 6 (ST-26): Shopify keeps a code on the cart after it stops applying (HELLOPEACE20 after Upgrade on the Full System), but Liquid\n    // does not give the theme cart.discount_codes. Read it from Shopify's own cart JSON, once per render, and show each such code as a removable\n    // chip with the refusal line the snippet already wrote (announce() then marks the field and speaks it). Codes Liquid already drew are left alone.\n    let reading = null;\n    const cartCodes = () => reading ||= fetch((window.Shopify?.routes?.root || '/') + 'cart.js', { headers: { Accept: 'application/json' } })\n      .then(response => response.ok ? response.json() : null)\n      .then(cart => Array.isArray(cart?.discount_codes) ? cart.discount_codes : [])\n      .catch(() => [])\n      .finally(() => setTimeout(() => { reading = null; }, 0));\n    const markRefused = component => {\n      if (!component.hasAttribute('data-sap-real-codes')) return;\n      cartCodes().then(codes => {\n        const template = component.querySelector('template[data-sap-refused-chip]'), list = component.querySelector('.cart-discount-code__applied-codes'), error = component.querySelector('[data-cart-discount-error]');\n        if (!component.isConnected || !template || !list || !error) return;\n        const drawn = new Set([...component.querySelectorAll('[data-sap-entered-code][data-discount-code]')].map(node => node.dataset.discountCode.trim().toUpperCase()));\n        const refused = codes.filter(entry => entry?.applicable === false && typeof entry.code === 'string' && entry.code.trim() && !drawn.has(entry.code.trim().toUpperCase()));\n        if (!refused.length) return;\n        refused.forEach(entry => {\n          const code = entry.code.trim(), chip = template.content.firstElementChild.cloneNode(true), remove = chip.querySelector('[data-remove-discount]');\n          chip.dataset.discountCode = code;\n          chip.querySelector('[data-sap-code-name]').textContent = code;\n          remove.setAttribute('data-remove-discount', code);\n          remove.setAttribute('aria-label', remove.getAttribute('aria-label').replace('__SAP_CODE__', code));\n          if (typeof component.addListener === 'function') component.addListener(remove, 'click', component.removeDiscount);\n          else remove.addEventListener('click', component.removeDiscount);\n          list.append(chip);\n        });\n        list.classList.remove('hidden');\n        error.classList.remove('hidden');\n      });\n    };\n    prototype.mountComponent = function () { const result = nativeMount?.call(this); announce(this); markRefused(this); return result; };\n    document.querySelectorAll('cart-discount-code').forEach(component => { announce(component); markRefused(component); });\n    prototype.existingDiscounts = function () {\n      if (!this.hasAttribute('data-sap-real-codes')) return nativeCodes.call(this);\n      return [...new Set([...this.querySelectorAll('[data-sap-entered-code][data-discount-code]')].map(node => node.dataset.discountCode.trim()).filter(Boolean))];\n    };\n    // Post-launch P2-1: a code change on /cart swaps in a new cart-page element (Aurora's own updateCartContent does the same). The header\n    // <cart-count> badges subscribe to the cart page's update-nodes event once, when they mount, so they kept listening to the old element and a\n    // later item removal left the old count showing. Point every badge at the cart page now on screen, once each.\n    const relinkCounts = () => {\n      const cart = document.querySelector('cart-page');\n      if (!cart || typeof cart.on !== 'function') return;\n      const listening = cart.events?.['update-nodes'] || [];\n      document.querySelectorAll('cart-count').forEach(count => {\n        if (typeof count.handleCartUpdate === 'function' && !listening.includes(count.handleCartUpdate)) cart.on('update-nodes', count.handleCartUpdate);\n      });\n    };\n    prototype.updateCartContent = function (html) {\n      if (!this.hasAttribute('data-sap-real-codes')) { const result = nativeUpdate.call(this, html); relinkCounts(); return result; }\n      let root = this.cart;\n      if (root.matches('cart-page')) {\n        const replacement = new DOMParser().parseFromString(html, 'text/html').querySelector('cart-page');\n        if (!replacement) return;\n        root.replaceWith(replacement);\n        root = replacement;\n        relinkCounts();\n      } else {\n        const replacement = root.getTemplateContent(new DOMParser().parseFromString(html, 'text/html'));\n        if (!replacement) return;\n        root.lastDrawerBody = replacement;\n        root.emit('update-nodes', { node: replacement });\n        root.updateEmptyStatus();\n      }\n      requestAnimationFrame(() => document.dispatchEvent(new CustomEvent('sap:bag-promo-updated', { detail: { root } })));\n    };\n  });\n})();\n"],
  "mappings": "AACM,OAAO,mBACX,OAAO,iBAAmB,GAC1B,eAAe,YAAY,oBAAoB,EAAE,KAAK,IAAM,CAC1D,MAAM,UAAY,eAAe,IAAI,oBAAoB,EAAE,UACrD,YAAc,UAAU,kBACxB,aAAe,UAAU,kBACzB,YAAc,UAAU,eACxB,UAAY,IAAI,QAEhB,SAAW,WAAa,CAC5B,GAAI,UAAU,IAAI,SAAS,GAAK,CAAC,UAAU,aAAa,qBAAqB,EAAG,OAChF,MAAM,MAAQ,UAAU,cAAc,4BAA4B,EAAG,MAAQ,UAAU,cAAc,iCAAiC,EAAG,KAAO,UAAU,cAAc,0BAA0B,EAAG,KAAO,UAAU,cAAc,gCAAgC,EACpQ,GAAI,CAAC,OAAS,CAAC,OAAS,CAAC,KAAM,OAC/B,UAAU,IAAI,SAAS,EACvB,MAAM,KAAO,IAAM,CACH,CAAC,MAAM,UAAU,SAAS,QAAQ,GACnC,MAAM,aAAa,eAAgB,MAAM,EAAG,MAAM,aAAa,mBAAoB,MAAM,EAAE,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