{
  "version": 3,
  "sources": ["/cdn/shop/t/5/assets/urlar-utm-offer.js?nocache=1792113095283"],
  "sourcesContent": ["/**\n * \u00F9rlar \u2014 Repeat-buyer BOGO popup. Klaviyo emails land on the homepage with only UTMs:\n *  1. match utm_campaign against the offers in snippets/urlar-offer-popup.liquid\n *  2. attach the code to the cart straight away (Shopify holds it as \"not applicable\"\n *     until the qualifying items arrive), so even a closed popup still gets the deal\n *  3. open the popup; closing it leaves a bottom pill on every page until they claim it\n *  4. \"Add both\" posts the two picks as separate lines and opens the cart drawer\n * State lives in sessionStorage so the pill survives navigation and dies with the tab.\n */\n(function urlarUtmOffer() {\n  const cfgEl = document.getElementById('urlar-offer-config');\n  const dialog = document.getElementById('urlar-offer');\n  const pill = document.getElementById('urlar-offer-pill');\n  if (!cfgEl || !dialog || !pill) return;\n  const OFFERS = JSON.parse(cfgEl.textContent);\n\n  const store = {\n    get: (k) => { try { return sessionStorage.getItem(k); } catch (_) { return null; } },\n    set: (k, v) => { try { sessionStorage.setItem(k, v); } catch (_) { /* private mode */ } },\n  };\n\n  const campaign = (new URLSearchParams(location.search).get('utm_campaign') || '').toLowerCase();\n  let key = Object.keys(OFFERS).find((k) => campaign.includes(OFFERS[k].match));\n  if (key) {\n    // A different offer link replaces the old one: Shopify swaps the code (tested: /cart/update.js\n    // replaces, never stacks) and the popup shows again for the new offer.\n    if (store.get('urlar-offer') !== key) store.set('urlar-offer-seen', '');\n    store.set('urlar-offer', key);\n  } else key = store.get('urlar-offer');\n  if (!key || store.get('urlar-offer-claimed')) return;\n  const offer = OFFERS[key];\n\n  const post = (url, body) =>\n    fetch(url, {\n      method: 'POST',\n      headers: { 'Content-Type': 'application/json', 'X-Requested-With': 'XMLHttpRequest' },\n      body: JSON.stringify(body),\n    }).then((r) => r.json());\n\n  // 2. auto-apply, once per session\n  if (store.get('urlar-offer-applied') !== offer.code) {\n    post('/cart/update.js', { discount: offer.code })\n      .then(() => store.set('urlar-offer-applied', offer.code))\n      .catch(() => {});\n  }\n\n  // fill copy\n  dialog.querySelector('#urlar-offer-title').textContent = offer.title;\n  pill.querySelector('[data-pill-text]').textContent = offer.pill;\n  dialog.querySelectorAll('[data-tag]').forEach((el) => {\n    const isFree = el.dataset.tag === offer.free;\n    el.textContent = isFree ? 'Free' : '';\n    el.classList.toggle('is-free', isFree);\n  });\n\n  const money = (cents) => `$${(cents / 100).toFixed(2)}`;\n  const picked = (group) => dialog.querySelector(`[data-group=\"${group}\"] .is-on`);\n\n  function renderTotal() {\n    const paid = picked(offer.free === 'nose' ? 'mouth' : 'nose');\n    const free = picked(offer.free);\n    if (!paid || !free) return;\n    const paidPrice = Number(paid.dataset.price);\n    const freePrice = Number(free.dataset.price);\n    dialog.querySelector('[data-total=\"was\"]').textContent = money(paidPrice + freePrice);\n    dialog.querySelector('[data-total=\"now\"]').textContent = money(paidPrice);\n    const paidTag = dialog.querySelector(`[data-tag=\"${offer.free === 'nose' ? 'mouth' : 'nose'}\"]`);\n    if (paidTag) paidTag.textContent = money(paidPrice);\n    const nose = picked('nose');\n    const mouth = picked('mouth');\n    dialog.querySelector('[data-summary=\"nose\"]').textContent = nose.dataset.label;\n    dialog.querySelector('[data-summary=\"nose-sub\"]').textContent = nose.dataset.subtitle || '';\n    dialog.querySelector('[data-summary=\"mouth\"]').textContent = mouth.dataset.label;\n  }\n\n  dialog.querySelectorAll('[data-group]').forEach((group) => {\n    group.addEventListener('click', (e) => {\n      const btn = e.target.closest('.urlar-offer__pick');\n      if (!btn) return;\n      group.querySelectorAll('.urlar-offer__pick').forEach((b) => b.classList.remove('is-on'));\n      btn.classList.add('is-on');\n      renderTotal();\n    });\n  });\n  renderTotal();\n\n  // 3. open / minimise\n  const showPill = () => { pill.hidden = false; };\n  const open = () => {\n    pill.hidden = true;\n    if (typeof dialog.showModal === 'function') dialog.showModal();\n    else dialog.setAttribute('open', '');\n  };\n  dialog.addEventListener('close', showPill);\n  pill.addEventListener('click', open);\n\n  if (store.get('urlar-offer-seen')) showPill();\n  else { store.set('urlar-offer-seen', '1'); open(); }\n\n  // Pair already in the cart by any route (site buttons, AMP upsells, an earlier visit)?\n  // Then the offer is done: drop the pill and popup for the rest of the session.\n  const idsIn = (group) => [...dialog.querySelectorAll(`[data-group=\"${group}\"] [data-id]`)].map((b) => Number(b.dataset.id));\n  fetch('/cart.js', { headers: { 'X-Requested-With': 'XMLHttpRequest' } })\n    .then((r) => r.json())\n    .then((cart) => {\n      const inCart = new Set((cart.items || []).map((i) => i.variant_id));\n      const has = (group) => idsIn(group).some((id) => inCart.has(id));\n      if (has('nose') && has('mouth')) finish();\n    })\n    .catch(() => {});\n\n  function finish() {\n    store.set('urlar-offer-claimed', '1');\n    dialog.removeEventListener('close', showPill);\n    if (dialog.open) dialog.close();\n    pill.remove();\n  }\n\n  // 4. add both\n  const cta = dialog.querySelector('[data-add]');\n  const errorEl = dialog.querySelector('[data-error]');\n  cta.addEventListener('click', () => {\n    const items = ['nose', 'mouth'].map((g) => ({ id: Number(picked(g).dataset.id), quantity: 1 }));\n    const drawer = document.querySelector('cart-drawer');\n    const sections = drawer ? drawer.getSectionsToRender().map((s) => s.id) : [];\n    cta.setAttribute('aria-busy', 'true');\n    errorEl.hidden = true;\n    post('/cart/add.js', { items, sections, sections_url: location.pathname })\n      .then((res) => {\n        if (res.status) throw new Error(res.description || res.message || 'Could not add to cart');\n        finish();\n        // The store runs the Upsell by AMP cart; OPEN_CART re-fetches the cart and shows it.\n        if (window.AMP_API?.OPEN_CART) window.AMP_API.OPEN_CART();\n        else if (drawer) drawer.renderContents(res);\n        else location.href = '/cart';\n      })\n      .catch((err) => {\n        errorEl.textContent = err.message;\n        errorEl.hidden = false;\n      })\n      .finally(() => cta.removeAttribute('aria-busy'));\n  });\n})();\n"],
  "mappings": "CASC,UAAyB,CACxB,MAAM,MAAQ,SAAS,eAAe,oBAAoB,EACpD,OAAS,SAAS,eAAe,aAAa,EAC9C,KAAO,SAAS,eAAe,kBAAkB,EACvD,GAAI,CAAC,OAAS,CA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