{"webLayers":[{"_id":"6a58fd87506ce395f0c822db","date_filter":{"enabled":false,"from_date":null,"to_date":null},"trigger":{"include_pages":[{"type":"any"}],"exclude_pages":null},"smart_trigger":null,"device_target":{"type":"any"},"frequency":"always","uses_personalization":true,"data":"","variables_target":null,"page_vars":[]},{"_id":"6a59378f8cd1443346288d53","date_filter":{"enabled":false,"from_date":null,"to_date":null},"trigger":{"include_pages":[{"type":"any"}],"exclude_pages":null},"smart_trigger":null,"device_target":{"type":"any"},"frequency":"always","uses_personalization":true,"data":"","variables_target":null,"page_vars":[]},{"_id":"6a59666025a93bae73d77655","date_filter":{"enabled":false,"from_date":null,"to_date":null},"trigger":{"include_pages":[{"type":"any"}],"exclude_pages":null},"smart_trigger":null,"device_target":{"type":"any"},"frequency":"always","uses_personalization":true,"data":"","variables_target":null,"page_vars":[]},{"_id":"6a5966c0983e2c6f4f362327","date_filter":{"enabled":false,"from_date":null,"to_date":null},"trigger":{"include_pages":[{"type":"any"}],"exclude_pages":null},"smart_trigger":null,"device_target":{"type":"any"},"frequency":"always","uses_personalization":true,"data":"","variables_target":null,"page_vars":[]},{"_id":"6a5966e090b11119fd67d6b5","date_filter":{"enabled":false,"from_date":null,"to_date":null},"trigger":{"include_pages":[{"type":"any"}],"exclude_pages":null},"smart_trigger":null,"device_target":{"type":"any"},"frequency":"always","uses_personalization":true,"data":"","variables_target":null,"page_vars":[]},{"_id":"6a5966fa40d1bd27c1f7dcc3","date_filter":{"enabled":false,"from_date":null,"to_date":null},"trigger":{"include_pages":[{"type":"any"}],"exclude_pages":null},"smart_trigger":null,"device_target":{"type":"any"},"frequency":"always","uses_personalization":true,"data":"","variables_target":null,"page_vars":[]},{"_id":"6a5a2c3186cbd918873e96ed","date_filter":{"enabled":false,"from_date":null,"to_date":null},"trigger":{"include_pages":[{"type":"any"}],"exclude_pages":null},"smart_trigger":null,"device_target":{"type":"any"},"frequency":"always","uses_personalization":true,"data":"","variables_target":null,"page_vars":[]},{"_id":"6a7cc14e44a9533151f2330e","date_filter":{"enabled":false,"from_date":null,"to_date":null},"trigger":{"include_pages":[{"type":"any"}],"exclude_pages":[{"url":"checkout","type":"contains"},{"url":"survey","type":"contains"},{"url":"-qr","type":"contains"},{"url":"/pages/friends","type":"contains"},{"url":"/pages/refer","type":"contains"},{"url":"/cart","type":"contains"}]},"smart_trigger":null,"device_target":{"type":"any"},"frequency":"once_per_visit","uses_personalization":true,"data":"","variables_target":null,"page_vars":[]},{"_id":"6a95da5d1aaedd72f303008d","date_filter":{"enabled":false,"from_date":null,"to_date":null},"trigger":{"include_pages":[{"type":"any"}],"exclude_pages":[{"url":"checkout","type":"contains"},{"url":"survey","type":"contains"},{"url":"-qr","type":"contains"},{"url":"/pages/friends","type":"contains"},{"url":"/pages/refer","type":"contains"}]},"smart_trigger":null,"device_target":{"type":"any"},"frequency":"once_per_visit","uses_personalization":true,"data":"","variables_target":null,"page_vars":[]},{"_id":"6a95dc7c21c7bcbe01940ac7","date_filter":{"enabled":false,"from_date":null,"to_date":null},"trigger":{"include_pages":[{"type":"any"}],"exclude_pages":[{"url":"checkout","type":"contains"},{"url":"survey","type":"contains"},{"url":"-qr","type":"contains"},{"url":"/pages/friends","type":"contains"},{"url":"/pages/refer","type":"contains"}]},"smart_trigger":null,"device_target":{"type":"any"},"frequency":"once_per_visit","uses_personalization":true,"data":"","variables_target":null,"page_vars":[]}],"experiments":[],"constantManagedTags":[{"uses_overlay":false,"type":"js","parametrized_definition":"(function () {\n  const url = new URL(window.location.href);\n\n  if (!/\\/cart\\/?$/.test(url.pathname)) return;\n  if (url.searchParams.get(\"br_restore\") !== \"1\") return;\n  if (window.__brCartRestoreRunning) return;\n\n  const rawItems = url.searchParams.get(\"items\");\n  if (!rawItems) return;\n\n  window.__brCartRestoreRunning = true;\n\n  let overlay = null;\n  let overlayTimer = null;\n\n  function showOverlay() {\n    if (overlay) return;\n\n    overlay = document.createElement(\"div\");\n    overlay.setAttribute(\"role\", \"status\");\n    overlay.setAttribute(\"aria-live\", \"polite\");\n    overlay.style.cssText = [\n      \"position:fixed\",\n      \"inset:0\",\n      \"z-index:2147483647\",\n      \"background:#fff\",\n      \"display:flex\",\n      \"align-items:center\",\n      \"justify-content:center\",\n      \"padding:24px\",\n      \"box-sizing:border-box\",\n      \"text-align:center\",\n      \"font-family:Arial,sans-serif\",\n      \"color:#435965\"\n    ].join(\";\");\n\n    const message = document.createElement(\"div\");\n\n    const title = document.createElement(\"div\");\n    title.textContent = \"Restoring your cart…\";\n    title.style.cssText = \"font-size:24px;margin-bottom:12px;\";\n\n    const subtitle = document.createElement(\"div\");\n    subtitle.textContent =\n      \"Please wait while we bring back your saved items.\";\n    subtitle.style.cssText = \"font-size:16px;line-height:1.5;\";\n\n    message.appendChild(title);\n    message.appendChild(subtitle);\n    overlay.appendChild(message);\n    (document.body || document.documentElement).appendChild(overlay);\n  }\n\n  const root =\n    (window.Shopify \u0026\u0026\n      window.Shopify.routes \u0026\u0026\n      window.Shopify.routes.root) || \"/\";\n\n  const controller = new AbortController();\n  const timeout = window.setTimeout(function () {\n    controller.abort();\n  }, 20000);\n\n  async function request(path, options) {\n    const response = await fetch(root + path, {\n      credentials: \"same-origin\",\n      ...options,\n      signal: controller.signal\n    });\n\n    const data = await response.json();\n\n    if (!response.ok) {\n      throw new Error(data.description || \"Cart request failed.\");\n    }\n\n    return data;\n  }\n\n  async function restore() {\n    const desired = new Map();\n\n    for (const pair of rawItems.split(\",\")) {\n      const match = /^(\\d+):([1-9]\\d*)$/.exec(pair);\n      if (!match) throw new Error(\"Invalid restoration link.\");\n\n      const quantity = Number(match[2]);\n\n      if (!Number.isSafeInteger(quantity)) {\n        throw new Error(\"Invalid quantity.\");\n      }\n\n      desired.set(\n        match[1],\n        Math.max(desired.get(match[1]) || 0, quantity)\n      );\n    }\n\n    // Show the message if checking the cart takes longer than 100ms.\n    overlayTimer = window.setTimeout(showOverlay, 100);\n\n    const cart = await request(\"cart.js\");\n    const existing = new Map();\n    const counts = new Map();\n\n    for (const item of cart.items) {\n      const id = String(item.variant_id);\n      existing.set(id, (existing.get(id) || 0) + item.quantity);\n      counts.set(id, (counts.get(id) || 0) + 1);\n    }\n\n    const updates = {};\n\n    for (const [id, quantity] of desired) {\n      const current = existing.get(id) || 0;\n\n      if (quantity \u003e current) {\n        if ((counts.get(id) || 0) \u003e 1) {\n          throw new Error(\"This cart requires a specific line update.\");\n        }\n\n        updates[id] = quantity;\n      }\n    }\n\n    window.clearTimeout(overlayTimer);\n\n    url.searchParams.delete(\"br_restore\");\n    url.searchParams.delete(\"items\");\n\n    if (Object.keys(updates).length === 0) {\n      window.clearTimeout(timeout);\n\n      // Clean the URL without reloading an already-correct cart.\n      window.history.replaceState(\n        window.history.state,\n        \"\",\n        url.toString()\n      );\n\n      if (overlay) overlay.remove();\n\n      window.__brCartRestoreRunning = false;\n      return;\n    }\n\n    // An update is needed; show the message until navigation.\n    showOverlay();\n\n    await request(\"cart/update.js\", {\n      method: \"POST\",\n      headers: { \"Content-Type\": \"application/json\" },\n      body: JSON.stringify({ updates })\n    });\n\n    window.clearTimeout(timeout);\n    window.location.replace(url.toString());\n  }\n\n  restore().catch(function (error) {\n    window.clearTimeout(timeout);\n    window.clearTimeout(overlayTimer);\n\n    if (overlay) overlay.remove();\n    window.__brCartRestoreRunning = false;\n\n    console.error(\"Bloomreach cart restoration:\", error);\n\n    window.alert(\n      \"We couldn't fully restore your saved cart. \" +\n      \"Please refresh the page and check your items before checkout.\"\n    );\n  });\n})();","trigger":{"include_pages":[{"url":"br_restore=1","type":"contains"}],"exclude_pages":null},"_id":"6ae36d2b58f51382857eaf58"}],"vars":{"data":[]}}