{
  "version": 3,
  "sources": ["/cdn/shop/t/28/assets/recently-viewed.js?rwady_refresh=20260820_02"],
  "sourcesContent": ["if (!window.Maximize.loadedScript.includes(\"recently-viewed.js\")) {\n  window.Maximize.loadedScript.push(\"recently-viewed.js\");\n\n  requestAnimationFrame(() => {\n    document.addEventListener(\"alpine:init\", () => {\n      Alpine.store(\"xProductRecently\", {\n        show: false,\n        loading: true,\n        productsToShow: 0,\n        productsToShowMax: 10,\n        listRecentlyProducts: [],\n        init() {\n          let recentlyProductsStored = localStorage.getItem(\"recently-viewed\") ? localStorage.getItem(\"recently-viewed\") : \"[]\";\n          this.listRecentlyProducts = JSON.parse(recentlyProductsStored);\n          const recentlyViewedSection = document.getElementById(\"RecentlyViewedSection\")\n          if (recentlyViewedSection) {\n            this.productsToShow = recentlyViewedSection.dataset.productsToShow;\n          }\n        },\n        showProductRecently() {\n          if (this.listRecentlyProducts.length) {\n            this.show = true;\n          } else {\n            this.show = false;\n          }\n        },\n        setProduct(productViewed) {\n          if (this.listRecentlyProducts.length) {\n            let productList = this.listRecentlyProducts;\n            productList = [...productList.filter((p) => p !== productViewed)].filter((p, i) => i < this.productsToShowMax);\n            // need to confirm with BA logic recently viewed in quickview\n            if (productList.length === 0) {\n              this.show = false;\n            } else {\n              this.show = true;\n            }\n            let newData = [productViewed, ...productList];\n            localStorage.setItem(\"recently-viewed\", JSON.stringify(newData));\n          } else {\n            this.show = false;\n            localStorage.setItem(\"recently-viewed\", JSON.stringify([productViewed]));\n          }\n        },\n        getProductRecently(sectionId, productId) {\n          let products = this.listRecentlyProducts;\n          if (this.listRecentlyProducts.length) {\n            products = productId ? [...products.filter((p) => p !== productId)] : products;\n            // Keep the mobile two-card row complete. When the history only has\n            // one other item, use the current product as the second card.\n            if (productId && products.length < 2) {\n              products.push(productId);\n            }\n            products = products.slice(0, this.productsToShow);\n          } else {\n            return;\n          }\n\n          const el = document.querySelector(\"#RecentlyViewedSection .recently-viewed__content\");\n          let query = products.map((value) => \"id:\" + value).join(\" OR \");\n\n          if (!query) {\n            this.loading = false;\n            return;\n          }\n\n          const search_url = `${Shopify.routes.root}search?section_id=${sectionId}&type=product&q=${encodeURIComponent(query)}`;\n          fetch(search_url)\n            .then((response) => {\n              if (!response.ok) {\n                // In theme editor / before the section is persisted, the Section Rendering API\n                // can return 404 for this section_id. Bail quietly instead of logging an error.\n                return null;\n              }\n              return response.text();\n            })\n            .then(async (text) => {\n              if (!text) return;\n              const resultsElement = new DOMParser().parseFromString(text, \"text/html\").querySelector(\"#RecentlyViewedSection .recently-viewed__content\");\n              const requestedCount = Number(this.productsToShow) || 10;\n\n              if (resultsElement) {\n                const resultsTrack = resultsElement.querySelector('.slider-container');\n                const existingSlides = Array.from(resultsTrack?.querySelectorAll(':scope > [data-rwady-recent-product-id]') || []);\n\n                if (resultsTrack && existingSlides.length < requestedCount) {\n                  const usedIds = new Set(existingSlides.map((slide) => slide.dataset.rwadyRecentProductId));\n\n                  for (let page = 1; page <= 3 && usedIds.size < requestedCount; page += 1) {\n                    const fillUrl = `${Shopify.routes.root}search?section_id=${sectionId}&type=product&q=${encodeURIComponent('*')}&page=${page}`;\n                    const fillResponse = await fetch(fillUrl);\n                    if (!fillResponse.ok) continue;\n\n                    const fillText = await fillResponse.text();\n                    const fillTrack = new DOMParser()\n                      .parseFromString(fillText, 'text/html')\n                      .querySelector('#RecentlyViewedSection .recently-viewed__content .slider-container');\n\n                    Array.from(fillTrack?.querySelectorAll(':scope > [data-rwady-recent-product-id]') || []).some((slide) => {\n                      const candidateId = slide.dataset.rwadyRecentProductId;\n                      if (candidateId === String(productId) || usedIds.has(candidateId)) return false;\n\n                      usedIds.add(candidateId);\n                      resultsTrack.appendChild(slide.cloneNode(true));\n                      return usedIds.size >= requestedCount;\n                    });\n                  }\n                }\n              }\n\n              const resultsMarkup = resultsElement ? resultsElement.innerHTML : \"\";\n              el.innerHTML = resultsMarkup;\n              requestAnimationFrame(() => {\n                el.querySelectorAll('[data-deferred-card-image]').forEach((slide) => {\n                  window.Maximize?.hydrateDeferredCardImage?.(slide);\n                });\n                const track = el.querySelector('.slider-container');\n                if (track) {\n                  track.scrollTo({ left: 0, behavior: 'auto' });\n                  window.Maximize?.initRwadyShelfDrag?.(track);\n                }\n              });\n              document.dispatchEvent(new CustomEvent(`${ANIMATION_EVENT.revealItem}`));\n            })\n            .catch(() => {})\n            .finally(() => {\n              this.loading = false;\n            });\n        },\n        clearHistory() {\n          let result = confirm(\"Are you sure you want to clear your recently viewed products?\");\n          if (result === true) {\n            localStorage.removeItem(\"recently-viewed\");\n            this.show = false;\n          }\n        },\n      });\n    });\n  });\n}\n"],
  "mappings": "AAAK,OAAO,SAAS,aAAa,SAAS,oBAAoB,IAC7D,OAAO,SAAS,aAAa,KAAK,oBAAoB,EAEtD,sBAAsB,IAAM,CAC1B,SAAS,iBAAiB,cAAe,IAAM,CAC7C,OAAO,MAAM,mBAAoB,CAC/B,KAAM,GACN,QAAS,GACT,eAAgB,EAChB,kBAAmB,GACnB,qBAAsB,CAAC,EACvB,MAAO,CACL,IAAI,uBAAyB,aAAa,QAAQ,iBAAiB,EAAI,aAAa,QAAQ,iBAAiB,EAAI,KACjH,KAAK,qBAAuB,KAAK,MAAM,sBAAsB,EAC7D,MAAM,sBAAwB,SAAS,eAAe,uBAAuB,EACzE,wBACF,KAAK,eAAiB,sBAAsB,QAAQ,eAExD,EACA,qBAAsB,CAChB,KAAK,qBAAqB,OAC5B,KAAK,KAAO,GAEZ,KAAK,KAAO,EAEhB,EACA,WAAW,cAAe,CACxB,GAAI,KAAK,qBAAqB,OAAQ,CACpC,IAAI,YAAc,KAAK,qBACvB,YAAc,CAAC,GAAG,YAAY,OAAQ,GAAM,IAAM,aAAa,CAAC,EAAE,OAAO,CAAC,EAAG,IAAM,EAAI,KAAK,iBAAiB,EAEzG,YAAY,SAAW,EACzB,KAAK,KAAO,GAEZ,KAAK,KAAO,GAEd,IAAI,QAAU,CAAC,cAAe,GAAG,WAAW,EAC5C,aAAa,QAAQ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