PageSourceSearch

https://gir.co/cdn/shop/t/295/assets/sweeps-cart.js?v=178385969480927569141790974467

js gir.co collected 2026-10-03 19:45:42 UTC 11,825 bytes, 20 lines download raw bytes

1(function(){const config=window.sweepsCartConfig;if(!config||window.SweepsCart)return;const tiers=(config.tiers||[]).slice().sort((a,b)=>a.spend-b.spend),SECTION_ID="sweeps-cart-data",TIERS_ANCHOR=".upez__shop_progress_pristine",HEADER_SELECTOR=".sticky.top-0",FOOTER_SELECTOR=".sticky.bottom-0",LINE_ROW_SELECTOR="[data-product-handle][data-line-price]",PRODUCT_TITLE_SELECTOR=".upnova-product-title",PRODUCT_BADGE_SECTION="sweeps-product-badge",CART_URL_PATTERN=/\/cart(?:\/(add|change|update|clear))?\.js(?:on)?$/;let data=null,cartSignature=null,refreshTimer=null,placeScheduled=!1;const productBadges=new Map;let badgeStyles="";const tiersElement=createElement("ss-tiers"),totalElement=createElement("ss-cart-total"),TICKET_ICON='<svg viewBox="0 0 24 24" width="16" height="16" aria-hidden="true"><path d="M3 8a2 2 0 0 0 2-2h14a2 2 0 0 0 2 2v2a2 2 0 0 0 0 4v2a2 2 0 0 0-2 2H5a2 2 0 0 0-2-2v-2a2 2 0 0 0 0-4V8z" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/><path d="M14 7v10" stroke="currentColor" stroke-width="1.6" stroke-dasharray="1.5 2"/></svg>',STYLES=`
2    .ss-tiers, .ss-cart-total { --ss-brand: ${config.accent||"#0F4C81"}; font-family: inherit; }
3    .ss-tiers { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 0; padding: 8px 16px 10px; font-size: 13px; font-weight: 500; line-height: 1.3; text-align: center; color: var(--ss-brand); }
4    .ss-tiers svg { flex: 0 0 auto; }
5    .ss-tiers strong { font-weight: 700; }
6    .ss-cart-total { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 12px 16px 0; font-size: 14px; font-weight: 600; color: var(--ss-brand); }
7    .ss-cart-total__note { font-size: 12px; font-weight: 500; opacity: .8; }
8    .ss-line-entries { margin-top: 6px; }
9    .ss-line-entries .ss-banner-wrapper--card-min { margin-left: 0; }
10    .ss-line-entries .ss-banner-wrapper--card-min .ss-banner { column-gap: 10px; }
11    .ss-line-entries .ss-banner-wrapper--card-min .ss-banner-count { margin-left: 12px; }
12    .ss-line-entries .ss-banner-wrapper--card-min .ss-banner-multiplier { align-self: stretch; display: flex; align-items: center; padding: 0 12px; }
13    .ss-line-entries .ss-banner-count { padding: 6px 0; }
14    .ss-upsell-entries { margin-top: 4px; min-width: 0; }
15    .ss-upsell-entries .ss-banner-wrapper--card-min { margin-left: 0; }
16    .ss-upsell-entries .ss-banner-wrapper--card-min .ss-banner { column-gap: 8px; }
17    .ss-upsell-entries .ss-banner-wrapper--card-min .ss-banner-count { margin-left: 10px; padding: 5px 0; font-size: 11px; }
18    .ss-upsell-entries .ss-banner-wrapper--card-min .ss-banner-multiplier { align-self: stretch; display: flex; align-items: center; padding: 0 10px; font-size: 11px; }
19  `;function createElement(className){const element=document.createElement("div");return element.className=className,element.hidden=!0,element}function getRoot(){const host=document.getElementById("upezCart");return host&&host.shadowRoot}function formatMoney(cents,currency){const amount=cents/100;try{return new Intl.NumberFormat(void 0,{style:"currency",currency:currency||"USD",minimumFractionDigits:Number.isInteger(amount)?0:2,maximumFractionDigits:2}).format(amount)}catch{return"$"+amount.toFixed(2)}}function formatEntries(entries){return Number(entries).toLocaleString("en-US")}function thresholdCents(tier){const rate=parseFloat(window.Shopify&&Shopify.currency&&Shopify.currency.rate)||1;return Math.round(tier.spend*100*rate)}function reachedTierIndex(){let reached=-1;return tiers.forEach((tier,i)=>{data.totalPrice>=thresholdCents(tier)&&(reached=i)}),reached}function escapeHtml(text){const div=document.createElement("div");return div.textContent=text,div.innerHTML}function renderTiers(){if(!tiers.length||!data||!data.itemCount){tiersElement.hidden=!0;return}const total=data.totalPrice,thresholds=tiers.map(thresholdCents),nextIndex=thresholds.findIndex(cents=>total<cents),complete=nextIndex===-1,entries="+"+formatEntries(tiers[complete?tiers.length-1:nextIndex].entries),template=complete?config.textComplete:config.textProgress,amount=complete?"":formatMoney(thresholds[nextIndex]-total,data.currency);tiersElement.hidden=!1,tiersElement.setAttribute("role","status"),tiersElement.innerHTML=TICKET_ICON+"<span>"+escapeHtml(template).replace("[amount]",`<strong>${escapeHtml(amount)}</strong>`).replace("[entries]",`<strong>${escapeHtml(entries)}</strong>`)+"</span>"}function renderTotal(){if(!config.showEntries||!data||!data.itemCount){totalElement.hidden=!0;return}
19const reached=tiers.length?reachedTierIndex():-1,tierBonus=reached===-1?0:tiers[reached].entries,total=data.totalEntries+tierBonus;if(!total){totalElement.hidden=!0;return}totalElement.hidden=!1,totalElement.setAttribute("role","status"),totalElement.innerHTML=`<span>${config.totalLabel}`+(tierBonus?` <span class="ss-cart-total__note">(incl. +${formatEntries(tierBonus)} bonus)</span>`:"")+`</span><span>${formatEntries(total)}</span>`}function ensureStyles(root){let style=root.getElementById("ss-cart-styles");style||(style=document.createElement("style"),style.id="ss-cart-styles",root.appendChild(style));const css=STYLES+badgeStyles;style.textContent!==css&&(style.textContent=css)}function placeLineBadges(root){const rows=root.querySelectorAll(LINE_ROW_SELECTOR),lines=config.showEntries&&data?data.lines.slice():[];rows.forEach(row=>{const candidates=lines.filter(line2=>line2.handle===row.dataset.productHandle),line=candidates.find(l=>l.linePrice===row.dataset.linePrice)||candidates[0];line&&lines.splice(lines.indexOf(line),1);const info=row.children[1]||row,existing=row.querySelector(".ss-line-entries");if(!line){existing&&existing.remove();return}if(existing&&existing.dataset.key===line.key&&existing.dataset.version===String(data.version))return;existing&&existing.remove();const badge=document.createElement("div");badge.className="ss-line-entries",badge.dataset.key=line.key,badge.dataset.version=String(data.version),badge.innerHTML=line.html,info.appendChild(badge)})}function place(){const root=getRoot();if(!root)return;ensureStyles(root);const anchor=root.querySelector(TIERS_ANCHOR);if(anchor)anchor.nextElementSibling!==tiersElement&&anchor.after(tiersElement);else{const header=root.querySelector(HEADER_SELECTOR);header&&tiersElement.parentNode!==header&&header.appendChild(tiersElement)}const footer=root.querySelector(FOOTER_SELECTOR);footer&&footer.firstElementChild!==totalElement&&footer.prepend(totalElement),placeLineBadges(root),placeUpsellBadges(root)}function schedulePlace(){placeScheduled||(placeScheduled=!0,requestAnimationFrame(()=>{placeScheduled=!1,place()}))}function routesRoot(){return window.Shopify&&Shopify.routes&&Shopify.routes.root||"/"}function loadProductBadge(handle){if(!productBadges.has(handle)){const request=fetch(`${routesRoot()}products/${encodeURIComponent(handle)}?sections=${PRODUCT_BADGE_SECTION}`).then(response=>response.ok?response.json():{}).then(sections=>{const container=new DOMParser().parseFromString(sections[PRODUCT_BADGE_SECTION]||"","text/html").getElementById(PRODUCT_BADGE_SECTION),style=container&&container.querySelector("style");style&&!badgeStyles&&(badgeStyles=style.textContent),container&&container.querySelectorAll("style").forEach(el=>el.remove()),productBadges.set(handle,container?container.innerHTML.trim():""),schedulePlace()}).catch(()=>productBadges.set(handle,""));productBadges.set(handle,request)}const badge=productBadges.get(handle);return typeof badge=="string"?badge:null}function parseMoneyCents(text){const digits=text.replace(/[^\d.,]/g,"");if(!digits)return 0;const normalized=digits.replace(/[.,](?=\d{3}(?:\D|$))/g,"").replace(",",".");return Math.round(parseFloat(normalized)*100)||0}function findPrice(title){let card=title;for(let i=0;i<5&&card.parentElement&&!/\d/.test(card.textContent.replace(title.textContent,""));i++)card=card.parentElement;return[...card.querySelectorAll("*")].find(el=>!el.children.length&&el!==title&&/^\D{0,4}\s?\d[\d.,\s]*\D{0,4}$/.test(el.textContent.trim())&&getComputedStyle(el).textDecorationLine!=="line-through")}function placeUpsellBadges(root){root.querySelectorAll(PRODUCT_TITLE_SELECTOR).forEach(title=>{if(title.closest(LINE_ROW_SELECTOR))return;const handle=((title.getAttribute("href")||"").split("?")[0].match(/\/products\/([^/]+)/)||[])[1],price=handle&&findPrice(title);if(!price)return;const priceRow=price.parentElement,container=priceRow.parentElement,target=getComputedStyle(container).flexDirection==="row"?container:priceRow,existing=target.nextElementSibling&&target.nextElementSibling.classList.contains("ss-upsell-entries")?target.nextElementSibling:null,cents=parseMoneyCents(price.textContent),html=config.showEntries&&cents>0?loadProductBadge(handle):"";if(!html){existing&&existing.remove();return}if(existing&&existing.dataset.handle===handle&&existing.dataset.price===String(cents))return;const badge=existing||document.createElement("div");badge.className="ss-upsell-entries",badge.dataset.handle=handle,badge.dataset.price=String(cents),badge.innerHTML=html,window.SharedSweeps&&SharedSweeps.update(badge,cents);const lead=badge.querySelector(".ss-banner-lead");lead&&lead.remove(),existing||target.after(badge)})}function parseSection(html){const container=new DOMParser().parseFromString(html,"text/html").getElementById(SECTION_ID);if(!container)return null;const firstStyle=container.querySelector("style");return firstStyle&&!badgeStyles&&(badgeStyles=firstStyle.textContent),container.querySelectorAll("style").forEach(style=>style.remove()),{version:(data?data.version:0)+1,totalPrice:parseInt(container.dataset.totalPrice,10)||0,itemCount:parseInt(container.dataset.itemCount,10)||0,currency:container.dataset.currency,totalEntries:parseInt(container.querySelector("[data-total-entries]").dataset.totalEntries,10)||0,lines:[...container.querySelectorAll("[data-line]")].map(line=>({key:line.dataset.key,handle:line.dataset.handle,linePrice:line.dataset.linePrice,html:line.innerHTML}))}}function refresh(){clearTimeout(refreshTimer),refreshTimer=setTimeout(()=>{fetch(`${routesRoot()}cart?sections=${SECTION_ID}`).then(response=>response.json()).then(sections=>{const next=parseSection(sections[SECTION_ID]||"");next&&(data=next,renderTiers(),renderTotal(),place())}).catch(()=>{})},150)}function handleCartJson(cart){if(!cart||!Array.isArray(cart.items))return;const signature=cart.total_price+"|"+cart.items.map(item=>`${item.key}:${item.quantity}:${item.final_line_price}`).join(",");signature!==cartSignature&&(cartSignature=signature,refresh())}function handleCartResponse(url,readJson){let path;try{path=new URL(url,window.location.origin).pathname}catch{return}const match=path.match(CART_URL_PATTERN);
19if(match){if(match[1]==="add"){cartSignature=null,refresh();return}readJson().then(handleCartJson,()=>{})}}const originalFetch=window.fetch;window.fetch=function(input){const url=typeof input=="string"?input:input&&input.url;return originalFetch.apply(this,arguments).then(response=>(url&&response.ok&&handleCartResponse(url,()=>response.clone().json()),response))};const originalOpen=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(method,url){return this.addEventListener("load",()=>{this.status>=200&&this.status<300&&handleCartResponse(String(url),()=>Promise.resolve(JSON.parse(this.responseText)))}),originalOpen.apply(this,arguments)};function watchUpez(){const root=getRoot();return root?(new MutationObserver(schedulePlace).observe(root,{childList:!0,subtree:!0,characterData:!0}),place(),!0):!1}if(!watchUpez()){let attempts=0;const poll=setInterval(()=>{(watchUpez()||++attempts>60)&&clearInterval(poll)},500)}refresh(),window.SweepsCart={refresh}})();
20//# sourceMappingURL=/cdn/shop/t/295/assets/sweeps-cart.js.map?v=178385969480927569141790974467

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.