PageSourceSearch

https://www.lovisa.co.uk/cdn/shop/t/811/assets/gwp-app.js?v=71632465002533409541789977862

js lovisa.co.uk collected 2026-09-26 13:25:32 UTC 5,522 bytes, 2 lines download raw bytes

1window.theme=window.theme||{},window.theme.gwp_status="loading",window.theme.gwpExistingHandles=async function(handles){var unique=Array.from(new Set((handles||[]).filter(Boolean)));if(!unique.length)return unique;try{var known={},toQuery=[];unique.forEach(function(h){var cached=null;try{cached=sessionStorage.getItem("gwp_exists_"+String(h).toLowerCase())}catch{}cached==="1"?known[String(h).toLowerCase()]=!0:toQuery.push(h)});for(var root=window.Shopify&&window.Shopify.routes&&window.Shopify.routes.root||"/",i=0;i<toQuery.length;i+=20){var chunk=toQuery.slice(i,i+20),res=await fetch(root+"search?view=gwp-probe&q="+encodeURIComponent(chunk.join(",")));if(!res.ok)return unique;var json;try{json=JSON.parse(await res.text())}catch{return unique}if(!json||typeof json.q!="string"||json.q.indexOf(String(chunk[0]))===-1||!Array.isArray(json.found))return unique;json.found.forEach(function(h){var key=String(h).toLowerCase();known[key]=!0;try{sessionStorage.setItem("gwp_exists_"+key,"1")}catch{}})}return unique.filter(function(h){return known[String(h).toLowerCase()]})}catch{return unique}};async function buildCompleteGwpObject(){cleanExpiredGwpCache();const rawEl=document.getElementById("gwp-json");if(!rawEl)return window.theme.gwp_status="loaded",!1;let raw;try{raw=JSON.parse(rawEl.textContent)}catch(e){return console.error("Invalid JSON",e),window.theme.gwp_status="loaded",!1}window.theme.giftWithPurchase={enabled:raw.gwpSettings?.enabled||!1,productsExcluded:(raw.gwpSettings?.productsExcluded||[]).map(p=>p.handle),multiQualificationEnabled:raw.gwpSettings?.multiQualificationEnabled||!1,multiEnabled:raw.gwpSettings?.multiEnabled||!1,heading:raw.gwpSettings?.heading||"",description:raw.gwpSettings?.description||"",promotionTitle:raw.gwpSettings?.promotionTitle||"",addToCart:"Add to bag",offers:[]};const offers=raw.offers||[],filteredOffers=[];for(const offer of offers){if(offer?.discount?.status!=="ACTIVE")continue;const configRaw=offer?.configurationField?.nodes?.[0]?.value,configId=offer?.configurationField?.nodes?.[0]?.id;if(!configRaw)continue;const config=JSON.parse(configRaw);if(console.log("config",config),config.enableGWPConfig==!1)continue;const rawHandles=(config.gwpProducts||[]).map(p=>p.handle),handles=window.theme.gwpExistingHandles?await window.theme.gwpExistingHandles(rawHandles):rawHandles,filterdProducts=(await Promise.all(handles.map(async handle=>{const key2=`gwp_product_${handle}`,cached=sessionStorage.getItem(key2);if(cached)try{const parsed=JSON.parse(cached),now=Date.now();if(parsed.expiresAt>now&&parsed.data&&parsed.data.available)return parsed.data;sessionStorage.removeItem(key2)}catch{sessionStorage.removeItem(key2)}try{const data=await(await fetch(`/products/${handle}.js`)).json();return data&&data.available?(sessionStorage.setItem(key2,JSON.stringify({data,expiresAt:Date.now()+120*1e3})),data):null}catch{return console.warn(`Failed to fetch product for handle: ${handle}`),null}}))).filter(Boolean);if(!filterdProducts.length)continue;for(var uniqueProducts=[],seenIds={},i=0;i<filterdProducts.length;i++){var product=filterdProducts[i];seenIds[product.id]||(seenIds[product.id]=!0,uniqueProducts.push(product))}for(var expandedProducts=[],i=0;i<uniqueProducts.length;i++){var product=uniqueProducts[i];if(product.variants&&product.variants.length)for(var j=0;j<product.variants.length;j++){var variant=product.variants[j],productCopy={};for(var key in product)product.hasOwnProperty(key)&&(productCopy[key]=product[key]);productCopy.variants=[variant],productCopy.selectedVariant=variant,productCopy.selectedVariantId=variant.id,expandedProducts.push(productCopy)}else expandedProducts.push(product)}let blockId=configId.replace("gid://shopify/Metafield/","blockId-");const offerObj={gwpOfferId:offer?.discount?.discountId,heading:config.heading,gwpOfferName:config.gwpOfferName,autoAddGwp:config.autoAddGwp,gwpBlockId:config.gwpBlockId||blockId,enableRule1:config.enableRule1,gwpProducts:handles,maxProducts:Number(config.maxFreeProducts)||1,gwpProductsDetailed:expandedProducts},rules=["rule1","rule2","rule3"];for(const ruleKey of rules){const rule=config[ruleKey]||{},enabled=config[`enable${ruleKey.charAt(0).toUpperCase()+ruleKey.slice(1)}`];let threshold=rule.threshold?rule.thresholdType=="amount"?rule.threshold*100:rule.threshold:0,maxThreshold=rule.maxThreshold?rule.thresholdType=="amount"?rule.maxThreshold*100:rule.maxThreshold:"";enabled&&(threshold>0||maxThreshold)?(offerObj[`enable${ruleKey.charAt(0).toUpperCase()+ruleKey.slice(1)}`]=!0,offerObj[ruleKey]={thresholdType:rule.thresholdType||"",threshold,maxThreshold:maxThreshold||"",collection:rule.collection?.handle||"",collectionProducts:rule.collectionProducts||[],tieThresholdToCollection:!!rule.collection}):offerObj[`enable${ruleKey.charAt(0).toUpperCase()+ruleKey.slice(1)}`]=!1}filteredOffers.push(offerObj)}return filteredOffers.length>
11&&filteredOffers.forEach(offer=>{["rule1","rule2","rule3"].forEach(ruleKey=>{offer[ruleKey]&&(offer[ruleKey].tieThresholdToCollection=!1)})}),window.theme.giftWithPurchase.offers=filteredOffers,window.theme.gwp_status="loaded",window.theme.giftWithPurchase}function cleanExpiredGwpCache(){const now=Date.now();Object.keys(sessionStorage).forEach(key=>{if(key.startsWith("gwp_product_"))try{JSON.parse(sessionStorage.getItem(key)).expiresAt<now&&sessionStorage.removeItem(key)}catch{sessionStorage.removeItem(key)}})}buildCompleteGwpObject();
2//# sourceMappingURL=/cdn/shop/t/811/assets/gwp-app.js.map?v=71632465002533409541789977862

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.