PageSourceSearch

https://www.emamaco.com/cdn/shop/t/43/assets/pdp-ugc-strip.js?v=35232033370388807161789561657

js emamaco.com collected 2026-10-10 02:33:35 UTC 37,541 bytes, 2 lines download raw bytes

1(function(){var container=document.getElementById("pdp-gallery");if(!container)return;var TN=container.getAttribute("data-tenant")||"",productHandle=container.getAttribute("data-handle")||"",productId=container.getAttribute("data-product-id")||"",productName=container.getAttribute("data-product-name")||"",_origHandle=productHandle,_origProductId=productId,_origProductName=productName,CDN="https://"+TN+".myshopishop.com",track=document.getElementById("pdp-ugc-track"),tabsEl=document.getElementById("pdp-person-tabs");if(!track||!tabsEl)return;var _ugcCache={},_productImgCache={},_preloadQueue=[],_preloading=!1,activeTab="product",tabButtons=container.querySelectorAll(".pdp-tab"),tabProduct=document.getElementById("pdp-tab-product"),tabUgc=document.getElementById("pdp-tab-ugc"),tabPopular=document.getElementById("pdp-tab-popular"),popularTrack=document.getElementById("pdp-popular-track"),tabBar=document.getElementById("pdp-gallery-tabs"),_hasUgc=!1;function switchTab(tab){activeTab=tab,tabProduct&&(tabProduct.style.display="block"),tabUgc&&(tabUgc.style.display="none"),tabPopular&&(tabPopular.style.display="none")}function _showTabBar(){_hasUgc=!0}function _hideTabBar(){_hasUgc=!1}tabButtons.forEach(function(b){b.addEventListener("click",function(){switchTab(b.getAttribute("data-tab"))})});var productTrack=document.getElementById("pdp-product-track"),dots=container.querySelectorAll(".pdp-dot");if(productTrack&&dots.length>1){dots.forEach(function(dot){dot.addEventListener("click",function(){var idx=parseInt(dot.getAttribute("data-idx"),10),child=productTrack.children[idx];child&&productTrack.scrollTo({left:child.offsetLeft,behavior:"smooth"})})});var scrollTimer=null;productTrack.addEventListener("scroll",function(){scrollTimer&&clearTimeout(scrollTimer),scrollTimer=setTimeout(function(){var sl=productTrack.scrollLeft,w=productTrack.offsetWidth,idx=Math.round(sl/w);dots.forEach(function(d,i){d.style.background=i===idx?"#1f2937":"#d1d5db"})},60)})}function ru(u){return u?u.startsWith("http")?u:CDN+(u.startsWith("/")?"":"/")+u:""}var PACK_HANDLES=["7-8-mat-pocket-leggings-black","emama-longline-crop","shorts-mat-pocket-black","pregnancy-recovery-emama-7-8-leggings-pockets","pregnancy-recovery-emama-shorts-pockets"],PACK_NAMES={"7-8-mat-pocket-leggings-black":"7/8 Maternity Leggings + Pockets","emama-longline-crop":"Nursing Crop","shorts-mat-pocket-black":"Maternity Shorts + Pockets","pregnancy-recovery-emama-7-8-leggings-pockets":"7/8 Recovery Leggings + Pockets","pregnancy-recovery-emama-shorts-pockets":"Recovery Shorts + Pockets"},STAGE_LABELS={t1:"in her 1st trimester",t2:"in her 2nd trimester",t3:"in her 3rd trimester",p:"post partum",k:"living her mum life"},STAGE_ORDER=["t1","t2","t3","p","k"],SIZE_ORDER=["XXS","XS","S","M","L","XL","XXL","3XL","4XL"],allUgc=[],personGroups={},personOrder=[],activePerson=null,soundOn=!1,selectedSize=null,ugcLoaded=!1;function parseSizes(str){return str?str.split(",").map(function(s){return s.trim().toUpperCase()}).filter(Boolean):[]}function getItemSizes(item){var b=parseSizes(item.bottoms),t=parseSizes(item.tops);return b.length?b:t}function sizeDistance(a,b){var ai=SIZE_ORDER.indexOf(a.toUpperCase()),bi=SIZE_ORDER.indexOf(b.toUpperCase());return ai<0||bi<0?999:Math.abs(ai-bi)}function smallestSizeIdx(sizes){for(var best=999,i=0;i<sizes.length;i++){var idx=SIZE_ORDER.indexOf(sizes[i]);idx>=0&&idx<best&&(best=idx)}return best}function sortBySize(items,targetSize){if(!targetSize)return items;var target=targetSize.toUpperCase();return items.slice().sort(function(a,b){var aSizes=getItemSizes(a),bSizes=getItemSizes(b),aExact=aSizes.indexOf(target)>=0?0:1,bExact=bSizes.indexOf(target)>=0?0:1;if(aExact!==bExact)return aExact-bExact;for(var aDist=999,bDist=999,i=0;i<aSizes.length;i++){var d=sizeDistance(aSizes[i],target);d<aDist&&(aDist=d)}for(var i=0;i<bSizes.length;i++){var d=sizeDistance(bSizes[i],target);d<bDist&&(bDist=d)}return aDist!==bDist?aDist-bDist:smallestSizeIdx(aSizes)-smallestSizeIdx(bSizes)})}function bestSize(item){var sizes=getItemSizes(item),target=readSelectedSize();if(sizes.length){if(!target)return sizes[0];for(var i=0;i<sizes.length;i++)if(sizes[i]===target)return sizes[i];for(var best=sizes[0],bestD=sizeDistance(sizes[0],target),i=1;i<sizes.length;i++){var d=sizeDistance(sizes[i],target);d<bestD&&(best=sizes[i],bestD=d)}return best}return target}var productCache={},productCacheLoading={};function fetchProductData(handle,cb){if(productCache[handle]){cb(productCache[handle]);return}if(productCacheLoading[handle]){productCacheLoading[handle].push(cb);return}productCacheLoading[handle]=[cb],fetch("/products/"+handle+".js").then(function(r){return r.json()}).then(function(data){productCache[handle]=data;var cbs=productCacheLoading[handle]||[];
1delete productCacheLoading[handle],cbs.forEach(function(fn){fn(data)})}).catch(function(){delete productCacheLoading[handle]})}function prefetchProducts(items){var seen={};items.forEach(function(it){it.products&&it.products.forEach(function(p){p.handle&&!seen[p.handle]&&(seen[p.handle]=!0,fetchProductData(p.handle,function(){}))})})}function getVariantId(handle,size){var data=productCache[handle];if(!data||!data.variants)return null;for(var sz=size.toUpperCase(),i=0;i<data.variants.length;i++){var v=data.variants[i];if(v.available&&v.title.toUpperCase()===sz)return v.id}return null}function readSelectedSize(){var sel=document.querySelector("#size-buttons button.selected");if(sel){var txt=sel.textContent.trim(),match=txt.match(/^([A-Z0-9]+)/i);if(match)return match[1].toUpperCase()}return null}function stageText(item){return item.trimester&&STAGE_LABELS[item.trimester]?STAGE_LABELS[item.trimester]:item.stage==="m"?"in her pregnancy":item.stage==="p"?STAGE_LABELS.p:item.stage==="k"?STAGE_LABELS.k:""}function cleanTitle(title){return title?title.replace(/\s*[-\u2013]?\s*FINAL SALE.*/i,"").trim():""}function isTopProduct(name){var n=(name||"").toLowerCase();return n.indexOf("crop")>=0||n.indexOf("nursing")>=0||n.indexOf("bra")>=0||n.indexOf("top")>=0}function sizeForProduct(item,prodName){var target=readSelectedSize(),useTop=isTopProduct(prodName),tagged=parseSizes(useTop?item.tops:item.bottoms);if(tagged.length||(tagged=parseSizes(useTop?item.bottoms:item.tops)),tagged.length){if(!target)return tagged[0];for(var i=0;i<tagged.length;i++)if(tagged[i]===target)return tagged[i];for(var best=tagged[0],bestD=sizeDistance(tagged[0],target),i=1;i<tagged.length;i++){var d=sizeDistance(tagged[i],target);d<bestD&&(best=tagged[i],bestD=d)}return best}return target}function productLines(item){if(!item.products||!item.products.length)return[];var all=[],seen={};item.products.forEach(function(prod){var name=PACK_NAMES[prod.handle]||cleanTitle(prod.title);if(!(!name||seen[name])){seen[name]=!0;var isTop=isTopProduct(name);all.push({name:name,handle:prod.handle,isTop:isTop})}});for(var bottom=null,top=null,i=0;i<all.length;i++)all[i].handle===productHandle&&(all[i].isTop?top=all[i]:bottom=all[i]);for(var i=0;i<all.length;i++)!bottom&&!all[i].isTop&&(bottom=all[i]),!top&&all[i].isTop&&(top=all[i]);var lines=[];return bottom&&lines.push(bottom),top&&lines.push(top),lines}function buildInfoHtml(item){var h='<div style="padding:8px 10px;background:#111;font-size:11px;color:rgba(255,255,255,0.8);line-height:1.5;">',intro="this is <strong>@"+(item.handle||"unknown")+"</strong>",stage=stageText(item);stage&&(intro+=" "+stage),h+="<div>"+intro+"</div>";var prods=productLines(item);return prods.length&&(h+='<div style="margin-top:3px;">she\u2019s wearing:</div>',prods.forEach(function(p,i){var prefix=i>0?"& ":"";h+="<div>"+prefix+p.name+"</div>";var sz=sizeForProduct(item,p.name);if(sz){var atcBadge="";if(p.handle){var vid=getVariantId(p.handle,sz);vid&&(atcBadge=' <span class="ugc-atc-btn" data-variant-id="'+vid+'" style="display:inline-block;font-size:8px;font-weight:700;text-transform:uppercase;background:#E8846C;color:#fff;padding:2px 6px;margin-left:4px;cursor:pointer;">add to cart</span>')}h+='<div style="color:rgba(255,255,255,0.5);">size '+sz+atcBadge+"</div>"}})),h+="</div>",h}function buildCardHtml(it){var isV=it.type==="reel"||it.type==="video",h='<div style="background:#000;overflow:hidden;position:relative;">';return isV?h+='<video src="'+ru(it.url)+'" poster="'+ru(it.posterUrl||"")+'" playsinline loop muted preload="metadata" style="width:100%;aspect-ratio:3/4;object-fit:cover;display:block;"></video>':h+='<img src="'+ru(it.url)+'" style="width:100%;aspect-ratio:3/4;object-fit:cover;display:block;" loading="lazy">',h+="</div>",h+=buildInfoHtml(it),h}function addSoundBtn(el){el.querySelectorAll("video").forEach(function(vid){if(!vid.parentElement.querySelector(".pdp-sound-btn")){vid.muted=!soundOn;var btn=document.createElement("button");btn.className="pdp-sound-btn",btn.type="button",btn.style.cssText="position:absolute;bottom:10px;right:10px;width:32px;height:32px;border-radius:50%;background:rgba(0,0,0,0.6);border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;z-index:5;",btn.innerHTML=soundOn?"\uD83D\uDD0A":"\uD83D\uDD07",btn.addEventListener("click",function(e){e.stopPropagation(),soundOn=!soundOn,document.querySelectorAll("video").forEach(function(v){v!==vid&&(v.muted=!0)}),vid.muted=!soundOn,document.querySelectorAll(".pdp-sound-btn").forEach(function(b){b.innerHTML=soundOn?"\uD83D\uDD0A":"\uD83D\uDD07"})}),vid.parentElement.appendChild(btn)}})}function wireAtcButtons(parent){parent.querySelectorAll(".ugc-atc-btn").forEach(function(btn
1){btn.addEventListener("click",function(e){e.stopPropagation();var vid=btn.getAttribute("data-variant-id");if(vid){btn.textContent="adding...";var emProps={_em_source:"pdp_ugc",_em_atc_type:"ugc_single",_em_pack_qty:"1",_em_size:(typeof selectedSize!="undefined"?selectedSize:"")||"",_em_parent_handle:(typeof activePerson!="undefined"?activePerson:"")||"",_em_component_handle:btn.getAttribute("data-product-handle")||""};fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({id:Number(vid),quantity:1,properties:emProps})}).then(function(){btn.textContent="added!",btn.style.background="#3D9A8B",setTimeout(function(){btn.textContent="add to cart",btn.style.background="#E8846C"},2e3)}).catch(function(){btn.textContent="add to cart"})}})})}function renderPerson(handle){activePerson=handle,track.innerHTML="",tabsEl.querySelectorAll("button").forEach(function(b){var isActive=b.getAttribute("data-handle")===handle;b.style.background=isActive?"#1f2937":"#f3f4f6",b.style.color=isActive?"#fff":"#6b7280"});var items=(personGroups[handle]||[]).slice();selectedSize=readSelectedSize(),selectedSize?items=sortBySize(items,selectedSize):items.sort(function(a,b){var aK=a.trimester||(a.stage==="p"?"p":a.stage==="k"?"k":"z"),bK=b.trimester||(b.stage==="p"?"p":b.stage==="k"?"k":"z");return STAGE_ORDER.indexOf(aK)-STAGE_ORDER.indexOf(bK)}),items.forEach(function(it){var card=document.createElement("div");card.style.cssText="flex:0 0 85%;max-width:85%;scroll-snap-align:start;overflow:hidden;background:#000;cursor:pointer;",card.innerHTML=buildCardHtml(it),addSoundBtn(card),wireAtcButtons(card),card.addEventListener("click",function(e){e.target.closest(".pdp-sound-btn")||e.target.closest(".ugc-atc-btn")||openModal(allUgc,it.id)});var vid=card.querySelector("video");vid&&"IntersectionObserver"in window&&new IntersectionObserver(function(entries){var v=entries[0].target;if(entries[0].isIntersecting){track.querySelectorAll("video").forEach(function(ov){if(ov!==v)try{ov.pause()}catch(ex){}});try{v.play()}catch(ex){}}else try{v.pause()}catch(ex){}},{threshold:.5}).observe(vid),track.appendChild(card)})}function onPdpSizeChange(){var newSize=readSelectedSize();newSize!==selectedSize&&activePerson&&(selectedSize=newSize,renderPerson(activePerson))}function updateUgcTabBadge(count){var ugcTab=container.querySelector('[data-tab="ugc"]');ugcTab&&(ugcTab.textContent=count>0?"As Seen on Social Media ("+count+")":"As Seen on Social Media")}var _stripItemsPromise=null;function loadStripFromMap(){return _stripItemsPromise||(_stripItemsPromise=new Promise(function(resolve){function build(){var m=window.__cmMap;if(!m||!m.byProduct||!m.media)return resolve([]);for(var ids=m.byProduct[productHandle]||[],out=[],i=0;i<ids.length&&out.length<100;i++){var e=m.media[ids[i]];e&&out.push({id:Number(ids[i]),url:e.url,posterUrl:e.poster||null,type:e.type,handle:e.handle||null,stage:e.stage||null,trimester:e.trimester||null,tops:e.tops||null,bottoms:e.bottoms||null,sourcePrefix:e.sourcePrefix||null})}resolve(out)}if(window.__cmMap)return build();if(window.__cm&&typeof window.__cm.then=="function")return window.__cm.then(build).catch(function(){resolve([])});resolve([])}),_stripItemsPromise)}function loadStrip(){loadStripFromMap().then(function(items){if(_ugcCache[productHandle]=_ugcCache[productHandle]||{items:[],popularItems:[]},!items.length||(allUgc=items,ugcLoaded=!0,prefetchProducts(items),updateUgcTabBadge(items.length),items.forEach(function(it){it.handle&&(personGroups[it.handle]||(personGroups[it.handle]=[],personOrder.push(it.handle)),personGroups[it.handle].push(it))}),!personOrder.length))return;tabsEl.innerHTML="",personOrder.forEach(function(handle){var btn=document.createElement("button");btn.type="button",btn.setAttribute("data-handle",handle),btn.textContent="@"+handle,btn.style.cssText="flex-shrink:0;padding:6px 12px;font-size:12px;font-weight:600;border:none;cursor:pointer;font-family:system-ui,-apple-system,sans-serif;transition:all 0.15s;background:#f3f4f6;color:#6b7280;",btn.addEventListener("click",function(){renderPerson(handle)}),tabsEl.appendChild(btn)});var fadeL=document.getElementById("pdp-fade-left"),fadeR=document.getElementById("pdp-fade-right");function updateFades(){if(!(!fadeL||!fadeR)){var sl=tabsEl.scrollLeft,maxScroll=tabsEl.scrollWidth-tabsEl.clientWidth;fadeL.style.display=sl>4?"block":"none",fadeR.style.display=maxScroll-sl>4?"block":"none"}}tabsEl.addEventListener("scroll",updateFades),setTimeout(updateFades,100),renderPerson(personOrder[0]),setTimeout(function(){activePerson&&renderPerson(activePerson),updateFades()},800);var sizeRow=document.getElementById("size-buttons");sizeRow&&sizeRow.addEventListener("click",function(){setTimeout(onPdpSizeChange,50)})}).catch(function(){})}var savedScrollY=0;function lockBody(){savedScrollY=window.scrollY,document.body.style.position="fixed",document.body.style.top="-"+savedScrollY+"px",document.body.style.left="0",document.body.style.right="0",document.body.style.overflow="hidden"}function unlockBody(){document.body.style.position="",document.body.style.top="",document.body.style.left="",document.body.style.right="",document.body.style.overflow="",window.scrollTo(0,savedScrollY)}function openModal(items,focusId){if(window.openUgcModal){window.openUgcModal(items,focusId);return}lockBody();var el=document.createElement("div");el.style.cssText="position:fixed;inset:0;z-index:99999;background:#000;display:flex;flex-direction:column;";for(var ci=0,i=0;i<items.length;i++)if(items[i].id===focusId){ci=i;break}function closeModal(){unlockBody(),el.remove()}function render(){var h='<div style="position:sticky;top:0;z-index:10;display:flex;justify-content:flex-end;padding:12px 16px;background:rgba(0,0,0,0.8);"><button id="pdp-mx" style="color:white;background:none;border:none;font-size:20px;cursor:pointer;">\u2715</button></div>';h+='<div style="flex:1;overflow-y:auto;">';var groups={},order=[];
1items.forEach(function(it){var key=it.handle||"_"+it.id;groups[key]||(groups[key]=[],order.push(key)),groups[key].push(it)});var focusedHandle=items[ci]?items[ci].handle:null;focusedHandle&&order.indexOf(focusedHandle)>0&&(order.splice(order.indexOf(focusedHandle),1),order.unshift(focusedHandle)),order.forEach(function(handle){var pItems=groups[handle],sz=readSelectedSize();sz?pItems=sortBySize(pItems,sz):pItems=pItems.slice().sort(function(a,b){var aK=a.trimester||(a.stage==="p"?"p":a.stage==="k"?"k":"z"),bK=b.trimester||(b.stage==="p"?"p":b.stage==="k"?"k":"z");return STAGE_ORDER.indexOf(aK)-STAGE_ORDER.indexOf(bK)}),h+='<div style="padding:12px 16px 6px;font-size:14px;font-weight:700;color:white;">@'+handle+"</div>",h+='<div style="display:flex;gap:2px;overflow-x:auto;scroll-snap-type:x mandatory;-webkit-overflow-scrolling:touch;scrollbar-width:none;padding:0 0 12px 0;">',pItems.forEach(function(it){h+='<div style="flex:0 0 85%;max-width:85%;scroll-snap-align:start;overflow:hidden;background:#000;">'+buildCardHtml(it)+"</div>"}),h+="</div>"}),h+="</div>",el.innerHTML=h,el.querySelector("#pdp-mx").addEventListener("click",closeModal),wireAtcButtons(el)}document.body.appendChild(el),render()}loadStrip();var KNOWN_TOP_HANDLES=["hannahpolites","belle_lucia","skye.wheatley","tayla.broad","yasminscottofficial","dominiqueletoullec","katrinagorry10","marianneknerr","tahny89","bybrittanynoonan","laurenkvickers","coach_amandajane"];function loadPopularSimple(){popularTrack&&loadStripFromMap().then(function(stripItems){if(stripItems.length){var items=stripItems.slice();items.sort(function(a,b){var aVid=a.type==="reel"||a.type==="video"?0:1,bVid=b.type==="reel"||b.type==="video"?0:1;if(aVid!==bVid)return aVid-bVid;var aIdx=KNOWN_TOP_HANDLES.indexOf(a.handle),bIdx=KNOWN_TOP_HANDLES.indexOf(b.handle);return aIdx<0&&(aIdx=999),bIdx<0&&(bIdx=999),aIdx-bIdx});for(var seen={},top=[],i=0;i<items.length&&top.length<10;i++){var h=items[i].handle;h&&seen[h]||(h&&(seen[h]=!0),top.push(items[i]))}top.length&&(popularTrack.innerHTML="",top.forEach(function(it){var isV=it.type==="reel"||it.type==="video",url=ru(it.url),poster=ru(it.posterUrl||""),card=document.createElement("div");card.style.cssText="flex:0 0 85%;max-width:85%;scroll-snap-align:start;overflow:hidden;background:#000;position:relative;cursor:pointer;";var media;isV?(media='<video src="'+url+'" poster="'+poster+'" playsinline loop muted preload="metadata" style="width:100%;aspect-ratio:3/4;object-fit:cover;display:block;"></video>',poster&&(media+='<img class="pdp-poster-overlay" src="'+poster+'" style="position:absolute;top:0;left:0;width:100%;height:100%;object-fit:cover;display:block;pointer-events:none;transition:opacity 0.15s linear;">')):media='<img src="'+url+'" style="width:100%;aspect-ratio:3/4;object-fit:cover;display:block;" loading="lazy">';var overlay='<div style="position:absolute;bottom:12px;left:12px;right:12px;color:white;text-shadow:0 1px 4px rgba(0,0,0,0.7);font-family:system-ui,-apple-system,sans-serif;">';overlay+='<div style="font-size:15px;font-weight:700;">@'+(it.handle||"")+"</div>";var sl=stageText(it);sl&&(overlay+='<div style="font-size:12px;margin-top:2px;">'+sl+"</div>");var wearSize=parseSizes(it.tops).length?parseSizes(it.tops)[0]:parseSizes(it.bottoms).length?parseSizes(it.bottoms)[0]:"";wearSize&&(overlay+='<div style="font-size:12px;margin-top:2px;">wears size '+wearSize+"</div>"),overlay+="</div>",card.innerHTML=media+overlay,addSoundBtn(card);var _vid=card.querySelector("video"),_ov=card.querySelector(".pdp-poster-overlay");_vid&&_ov&&(_vid.addEventListener("playing",function(){_ov.style.opacity="0"}),_vid.addEventListener("pause",function(){_ov.style.opacity="1"})),card.addEventListener("click",function(e){e.target.closest(".pdp-sound-btn")||openModal(allUgc.length?allUgc:top,it.id)}),popularTrack.appendChild(card)}),"IntersectionObserver"in window&&popularTrack.querySelectorAll("video").forEach(function(vid){new IntersectionObserver(function(entries){if(entries[0].isIntersecting){popularTrack.querySelectorAll("video").forEach(function(ov){if(ov!==entries[0].target)try{ov.pause()}catch(e){}});try{entries[0].target.play()}catch(e){}}else try{entries[0].target.pause()}catch(e){}},{threshold:.5}).observe(vid)}),_showTabBar(),switchTab(_mappedAllGeneric(productHandle)?"product":"popular"),window.__pdpGalRebuild&&window.__pdpGalRebuild(stripItems))}}).catch(function(){})}function _mappedAllGeneric(handle){try{var m=window.__cmMap;if(!m||!m.byProduct||!m.media)return!1;var ids=m.byProduct[handle]||[];if(!ids.length)return!1;if(!m.__shareCount){var sc={};Object.keys(m.byProduct).forEach(function(h){(m.byProduct[h]||[]).forEac
1h(function(id){sc[id]=(sc[id]||0)+1})}),m.__shareCount=sc}for(var i=0;i<ids.length;i++)if((m.__shareCount[ids[i]]||0)<4)return!1;return!0}catch(e){return!1}}loadPopularSimple(),(function(){var origTrack=document.getElementById("pdp-product-track");if(origTrack){var imgs=[];origTrack.querySelectorAll("img").forEach(function(img){imgs.push(img.src)}),_productImgCache[_origHandle]={images:imgs,id:_origProductId}}})();function _rebuildProductPhotos(handle){var filter=window.__pdpColourFilter,cached=_productImgCache[handle],images=filter&&filter.length?filter:cached&&cached.images;if(!(!images||!images.length)){var trackEl=document.getElementById("pdp-product-track");trackEl&&(trackEl.innerHTML="",images.forEach(function(src,i){var div=document.createElement("div");div.style.cssText="";var img=document.createElement("img");img.src=src,img.alt="",img.style.cssText="width:100%;aspect-ratio:3/4;object-fit:cover;display:block;",img.loading=i===0?"eager":"lazy",div.appendChild(img),trackEl.appendChild(div)}),window.__pdpGalRebuild&&window.__pdpGalRebuild())}}window.pdpGalleryShowImages=function(srcs,switchToProduct){if(window.__pdpColourFilter=srcs&&srcs.length?srcs:null,!!window.__pdpColourFilter&&(_rebuildProductPhotos(productHandle||_origHandle),switchToProduct))try{switchTab("product")}catch(e){}};function _rebuildUgcFromCache(handle){var cached=_ugcCache[handle],emptyEl=document.getElementById("pdp-ugc-empty");if(!cached||!cached.items||!cached.items.length){track.innerHTML="",tabsEl.innerHTML="",emptyEl&&(emptyEl.style.display=""),updateUgcTabBadge(0);return}emptyEl&&(emptyEl.style.display="none"),allUgc=cached.items,ugcLoaded=!0,personGroups={},personOrder=[],activePerson=null,cached.items.forEach(function(it){it.handle&&(personGroups[it.handle]||(personGroups[it.handle]=[],personOrder.push(it.handle)),personGroups[it.handle].push(it))}),updateUgcTabBadge(cached.items.length),personOrder.length&&(tabsEl.innerHTML="",personOrder.forEach(function(h){var btn=document.createElement("button");btn.type="button",btn.setAttribute("data-handle",h),btn.textContent="@"+h,btn.style.cssText="flex-shrink:0;padding:6px 12px;font-size:12px;font-weight:600;border:none;cursor:pointer;font-family:system-ui,-apple-system,sans-serif;transition:all 0.15s;background:#f3f4f6;color:#6b7280;",btn.addEventListener("click",function(){renderPerson(h)}),tabsEl.appendChild(btn)}),renderPerson(personOrder[0]),prefetchProducts(cached.items),setTimeout(function(){activePerson&&renderPerson(activePerson)},800))}function _rebuildPopularFromCache(handle){var cached=_ugcCache[handle];if(popularTrack){if(!cached||!cached.popularItems||!cached.popularItems.length)return popularTrack.innerHTML="",!1;var top=cached.popularItems;return popularTrack.innerHTML="",top.forEach(function(it){var isV=it.type==="reel"||it.type==="video",url=ru(it.url),poster=ru(it.posterUrl||""),card=document.createElement("div");card.style.cssText="flex:0 0 85%;max-width:85%;scroll-snap-align:start;overflow:hidden;background:#000;position:relative;cursor:pointer;";var media;isV?media='<video src="'+url+'" poster="'+poster+'" playsinline loop muted preload="metadata" style="width:100%;aspect-ratio:3/4;object-fit:cover;display:block;"></video>':media='<img src="'+url+'" style="width:100%;aspect-ratio:3/4;object-fit:cover;display:block;" loading="lazy">';var overlay='<div style="position:absolute;bottom:12px;left:12px;right:12px;color:white;text-shadow:0 1px 4px rgba(0,0,0,0.7);font-family:system-ui,-apple-system,sans-serif;">';overlay+='<div style="font-size:15px;font-weight:700;">@'+(it.handle||"")+"</div>";var sl=stageText(it);sl&&(overlay+='<div style="font-size:12px;margin-top:2px;">'+sl+"</div>");var wearSize=parseSizes(it.tops).length?parseSizes(it.tops)[0]:parseSizes(it.bottoms).length?parseSizes(it.bottoms)[0]:"";wearSize&&(overlay+='<div style="font-size:12px;margin-top:2px;">wears size '+wearSize+"</div>"),overlay+="</div>",card.innerHTML=media+overlay,addSoundBtn(card),card.addEventListener("click",function(e){e.target.closest(".pdp-sound-btn")||openModal(allUgc.length?allUgc:top,it.i
1d)}),popularTrack.appendChild(card)}),"IntersectionObserver"in window&&popularTrack.querySelectorAll("video").forEach(function(vid){new IntersectionObserver(function(entries){if(entries[0].isIntersecting){popularTrack.querySelectorAll("video").forEach(function(ov){if(ov!==entries[0].target)try{ov.pause()}catch(e){}});try{entries[0].target.play()}catch(e){}}else try{entries[0].target.pause()}catch(e){}},{threshold:.5}).observe(vid)}),!0}}function _doSwap(handle){_rebuildProductPhotos(handle),_rebuildUgcFromCache(handle);var hasPopular=_rebuildPopularFromCache(handle);if(hasPopular?(_showTabBar(),switchTab(_mappedAllGeneric(handle)?"product":"popular")):(_hideTabBar(),tabProduct&&(tabProduct.style.display=""),tabPopular&&(tabPopular.style.display="none"),tabUgc.style.display="none"),window.__pdpGalRebuild){var _c=_ugcCache[handle];window.__pdpGalRebuild(_c&&_c.items||[])}}window.pdpGallerySwap=function(handle){handle||(handle=_origHandle),productHandle=handle;var cached=_productImgCache[handle];cached?(productId=cached.id,container.setAttribute("data-handle",handle),container.setAttribute("data-product-id",cached.id),_doSwap(handle)):_fetchAndCacheProduct(handle).then(function(){var c=_productImgCache[handle];return c&&(productId=c.id,container.setAttribute("data-handle",handle),container.setAttribute("data-product-id",c.id)),_fetchAndCacheUgc(handle)}).then(function(){_doSwap(handle)})};function _fetchAndCacheProduct(handle){return _productImgCache[handle]?Promise.resolve():fetch("/products/"+handle+".js").then(function(r){return r.json()}).then(function(data){var imgs=[];data.images&&data.images.forEach(function(img){var sized=img.replace(/\.([a-z]+)\?/,"_800x.$1?");img.indexOf("width=")>=0?sized=img:sized=img+(img.indexOf("?")>=0?"&":"?")+"width=800",imgs.push(sized)}),_productImgCache[handle]={images:imgs,id:String(data.id)}}).catch(function(){})}function _fetchUgcFromMap(handle){function build(){var m=window.__cmMap;if(!m||!m.byProduct||!m.media)return[];for(var ids=m.byProduct[handle]||[],out=[],i=0;i<ids.length&&out.length<100;i++){var e=m.media[ids[i]];e&&out.push({id:Number(ids[i]),url:e.url,posterUrl:e.poster||null,type:e.type,handle:e.handle||null,stage:e.stage||null,trimester:e.trimester||null,tops:e.tops||null,bottoms:e.bottoms||null,sourcePrefix:e.sourcePrefix||null})}return out}return window.__cmMap?Promise.resolve(build()):window.__cm&&typeof window.__cm.then=="function"?window.__cm.then(build).catch(function(){return[]}):Promise.resolve([])}function _fetchAndCacheUgc(handle){if(_ugcCache[handle])return Promise.resolve();var cached=_productImgCache[handle];return cached?_fetchUgcFromMap(handle).then(function(items){if(!items.length){_ugcCache[handle]={items:[],popularItems:[]};return}for(var sorted=items.slice().sort(function(a,b){var aVid=a.type==="reel"||a.type==="video"?0:1,bVid=b.type==="reel"||b.type==="video"?0:1;if(aVid!==bVid)return aVid-bVid;var aIdx=KNOWN_TOP_HANDLES.indexOf(a.handle),bIdx=KNOWN_TOP_HANDLES.indexOf(b.handle);return aIdx<0&&(aIdx=999),bIdx<0&&(bIdx=999),aIdx-bIdx}),seen={},top=[],i=0;i<sorted.length&&top.length<10;i++){var h=sorted[i].handle;h&&seen[h]||(h&&(seen[h]=!0),top.push(sorted[i]))}_ugcCache[handle]={items:items,popularItems:top}}).catch(function(){_ugcCache[handle]={items:[],popularItems:[]}}):Promise.resolve()}function _preloadNext(){if(!_preloadQueue.length){_preloading=!1;return}var handle=_preloadQueue.shift();_fetchAndCacheProduct(handle).then(function(){return _fetchAndCacheUgc(handle)}).then(function(){setTimeout(_preloadNext,100)})}window._v2GalleryPreload=function(handles){handles.forEach(function(h){h!==_origHandle&&_preloadQueue.indexOf(h)<0&&!_productImgCache[h]&&_preloadQueue.push(h)}),_preloading||(_preloading=!0,_preloadNext())};var _origLoadStripDone=!1,_origStripInterval=setInterval(function(){if((ugcLoaded||_origLoadStripDone)&&(clearInterval(_origStripInterval),_origLoadStripDone=!0,!_ugcCache[_origHandle])){for(var sorted=allUgc.slice().sort(function(a,b){var aVid=a.type==="reel"||a.type==="video"?0:1,bVid=b.type==="reel"||b.type==="video"?0:1;if(aVid!==bVid)return aVid-bVid;var aIdx=KNOWN_TOP_HANDLES.indexOf(a.handle),bIdx=KNOWN_TOP_HANDLES.indexOf(b.handle);return aIdx<0&&(aIdx=999),bIdx<0&&(bIdx=999),aIdx-bIdx}),seen={},top=[],i=0;i<sorted.length&&top.length<10;i++){var h=sorted[i].handle;h&&seen[h]||(h&&(seen[h]=!0),top.push(sorted[i]))}_ugcCache[_origHandle]={items:allUgc,popularItems:top}}},500);(function(){var main=document.getElementById("pdp-product-track"),railP=document.getElementById("pdp-rail-product"),railS=document.getElementById("pdp-rail-social"),railSWrap=document.getElementById("pdp-rail-social-wrap");if(!main||!railP||!railS)return;
1var socialItems=[],productCount=0;function isVid(it){return!!it&&(it.type==="reel"||it.type==="video")}function thumb(u,w){return u?u.indexOf("/cdn/shop/")<0&&u.indexOf("cdn.shopify.com/s/files/")<0?u:/[?&]width=\d+/.test(u)?u.replace(/([?&])width=\d+/,"$1width="+w):u+(u.indexOf("?")>=0?"&":"?")+"width="+w:""}function orderItems(all){var items=(all||[]).slice();items.sort(function(a,b){var aV=isVid(a)?0:1,bV=isVid(b)?0:1;if(aV!==bV)return aV-bV;var ai=KNOWN_TOP_HANDLES.indexOf(a.handle);ai<0&&(ai=999);var bi=KNOWN_TOP_HANDLES.indexOf(b.handle);return bi<0&&(bi=999),ai-bi});var seen={},top=[],rest=[];return items.forEach(function(it){var h=it.handle;top.length<10&&!(h&&seen[h])?(h&&(seen[h]=!0),top.push(it)):rest.push(it)}),top.concat(rest)}function clearAppended(){[].slice.call(main.children).forEach(function(k){k.getAttribute&&k.getAttribute("data-ugc-card")==="1"&&main.removeChild(k)})}function appendSocialToMain(items){clearAppended(),items.forEach(function(it){var card=document.createElement("div");card.setAttribute("data-ugc-card","1"),card.style.cssText="overflow:hidden;background:#000;position:relative;cursor:pointer;";var url=ru(it.url),poster=ru(it.posterUrl||""),media;isVid(it)?(media='<video src="'+url+'" poster="'+poster+'" playsinline loop muted preload="none" style="width:100%;aspect-ratio:3/4;object-fit:cover;display:block;"></video>',poster&&(media+='<img class="pdp-poster-overlay" src="'+poster+'" style="position:absolute;top:0;left:0;width:100%;height:100%;object-fit:cover;display:block;pointer-events:none;transition:opacity .15s linear;">')):media='<img src="'+thumb(url,900)+'" style="width:100%;aspect-ratio:3/4;object-fit:cover;display:block;" loading="lazy">';var ov='<div style="position:absolute;bottom:12px;left:12px;right:12px;color:#fff;text-shadow:0 1px 4px rgba(0,0,0,.7);font-family:system-ui,-apple-system,sans-serif;">';ov+='<div style="font-size:15px;font-weight:700;">@'+(it.handle||"")+"</div>";var sl=stageText(it);sl&&(ov+='<div style="font-size:12px;margin-top:2px;">'+sl+"</div>"),ov+="</div>",card.innerHTML=media+ov,addSoundBtn(card);var v=card.querySelector("video"),o=card.querySelector(".pdp-poster-overlay");v&&o&&(v.addEventListener("playing",function(){o.style.opacity="0"}),v.addEventListener("pause",function(){o.style.opacity="1"})),card.addEventListener("click",function(e){e.target.closest&&e.target.closest(".pdp-sound-btn")||openModal(allUgc.length?allUgc:items,it.id)}),main.appendChild(card)})}function tileEl(src,idx,video){var b=document.createElement("button");b.type="button",b.className="pdp-rail-tile",b.setAttribute("data-main-idx",String(idx)),video&&b.setAttribute("data-video","1");var im=document.createElement("img");return im.src=src,im.alt="",im.loading="lazy",b.appendChild(im),b}function buildRailP(){railP.innerHTML="";var n=0;[].slice.call(main.children).forEach(function(c){if(!(c.getAttribute&&c.getAttribute("data-ugc-card")==="1")){var img=c.querySelector&&c.querySelector("img");img&&(railP.appendChild(tileEl(thumb(img.src,160),n,!1)),n++)}}
1),productCount=n,railP.style.display=n>1?"":"none"}function buildRailS(items){if(railS.innerHTML="",!items.length){railSWrap&&(railSWrap.style.display="none");return}items.forEach(function(it,i){railS.appendChild(tileEl(thumb(ru(it.posterUrl||it.url),160),productCount+i,isVid(it)))}),railSWrap&&(railSWrap.style.display="block")}function arrowsFor(rail){return[].slice.call(document.querySelectorAll('.pdp-rail-arrow[data-rail="'+(rail===railP?"product":"social")+'"]'))}function updateArrows(rail){if(rail){var vertical=rail===railP,size=vertical?rail.clientHeight:rail.clientWidth,extent=vertical?rail.scrollHeight:rail.scrollWidth,pos=vertical?rail.scrollTop:rail.scrollLeft,overflows=extent>size+4;arrowsFor(rail).forEach(function(btn){var dir=Number(btn.getAttribute("data-dir")),atEnd=dir<0?pos<=4:pos>=extent-size-4;btn.hidden=!overflows||atEnd})}}function nudge(rail,dir){var vertical=rail===railP,step=(vertical?rail.clientHeight:rail.clientWidth)*.8,opts=vertical?{top:dir*step,behavior:"smooth"}:{left:dir*step,behavior:"smooth"};try{rail.scrollBy(opts)}catch(e){vertical?rail.scrollTop+=dir*step:rail.scrollLeft+=dir*step}}if(document.addEventListener("click",function(e){var btn=e.target.closest&&e.target.closest(".pdp-rail-arrow");if(btn){e.preventDefault(),e.stopPropagation();var rail=btn.getAttribute("data-rail")==="product"?railP:railS;rail&&nudge(rail,Number(btn.getAttribute("data-dir")))}}),[railP,railS].forEach(function(rail){rail&&rail.addEventListener("scroll",function(){updateArrows(rail)},{passive:!0})}),window.ResizeObserver)try{new ResizeObserver(function(){updateArrows(railP),updateArrows(railS)}).observe(main)}catch(e){}var MAX_TILE_VIDEOS=4,liveTiles=[],tileIO=null;function tileDowngrade(tile){var it=tile.__item;if(it){var im=document.createElement("img");im.src=thumb(ru(it.posterUrl||it.url),160),im.alt="",im.loading="lazy",tile.innerHTML="",tile.appendChild(im),tile.__live=!1;var i=liveTiles.indexOf(tile);i>=0&&liveTiles.splice(i,1)}}function tileUpgrade(tile){var it=tile.__item;if(!(!it||tile.__live)){var v=document.createElement("video");v.src=ru(it.url),v.muted=!0,v.loop=!0,v.playsInline=!0,v.preload="auto",v.setAttribute("playsinline",""),v.setAttribute("muted",""),v.poster=thumb(ru(it.posterUrl||""),160),tile.innerHTML="",tile.appendChild(v),tile.__live=!0,liveTiles.push(tile);try{v.play()}catch(e){}}}function tileReconcile(rail){var tiles=rail.querySelectorAll('.pdp-rail-tile[data-video="1"]'),i;for(i=0;i<tiles.length;i++)tiles[i].__live&&!tiles[i].__vis&&tileDowngrade(tiles[i]);for(i=0;i<tiles.length&&liveTiles.length<MAX_TILE_VIDEOS;i++)tiles[i].__vis&&!tiles[i].__live&&tileUpgrade(tiles[i])}function wireTileVideos(rail,lookup){if(tileIO&&(tileIO.disconnect(),tileIO=null),liveTiles=[],"IntersectionObserver"in window){var tiles=rail.querySelectorAll('.pdp-rail-tile[data-video="1"]');if(tiles.length){tileIO=new IntersectionObserver(function(entries){entries.forEach(function(en){en.target.__vis=en.isIntersecting}),tileReconcile(rail)},{threshold:.4});for(var i=0;i<tiles.length;i++)tiles[i].__item=lookup(Number(tiles[i].getAttribute("data-main-idx"))),tiles[i].__live=!1,tiles[i].__vis=!1,tileIO.observe(tiles[i])}}}function centreIndex(){var kids=main.children;if(!kids.length)return 0;for(var mid=main.scrollLeft+main.clientWidth/2,best=0,bd=1/0,i=0;i<kids.length;i++){var d=Math.abs(kids[i].offsetLeft+kids[i].offsetWidth/2-mid);d<bd&&(bd=d,best=i)}return best}function keepVisible(tile){var p=tile.parentNode;if(p===railP){var t=tile.offsetTop,b=t+tile.offsetHeight;t<p.scrollTop?p.scrollTop=t:b>p.scrollTop+p.clientHeight&&(p.scrollTop=b-p.clientHeight)}else{var l=tile.offsetLeft,r=l+tile.offsetWidth;l<p.scrollLeft?p.scrollLeft=l:r>p.scrollLeft+p.clientWidth&&(p.scrollLeft=r-p.clientWidth)}}function highlight(idx){[railP,railS].forEach(function(rail){for(var tiles=rail.querySelectorAll(".pdp-rail-tile"),i=0;i<tiles.length;i++)Number(tiles[i].getAttribute("data-main-idx"))===idx?tiles[i].getAttribute("aria-current")!=="true"&&(tiles[i].setAttribute("aria-current","true"),keepVisible(tiles[i])):tiles[i].removeAttribute("aria-current")})}function playCentre(idx){for(var kids=main.children,i=0;i<kids.length;i++){var v=kids[i].querySelector&&kids[i].querySelector("video");if(v)if(i===idx)try{v.preload="auto",v.muted=!soundOn,v.play()}catch(e){}else try{v.muted=!0,v.pause()}catch(e){}}
1[railP,railS].forEach(function(rail){rail&&rail.querySelectorAll("video").forEach(function(v2){v2.muted=!0})})}function onTileClick(e){var t=e.target.closest&&e.target.closest(".pdp-rail-tile");if(t){var i=Number(t.getAttribute("data-main-idx"))||0,card=main.children[i];if(card){try{main.scrollTo({left:card.offsetLeft,behavior:"smooth"})}catch(err){main.scrollLeft=card.offsetLeft}highlight(i)}}}railP.addEventListener("click",onTileClick),railS.addEventListener("click",onTileClick);var pending=null;main.addEventListener("scroll",function(){pending||(pending=requestAnimationFrame(function(){pending=null;var i=centreIndex();highlight(i),playCentre(i)}))},{passive:!0}),window.__pdpGalRebuild=function(items){items&&(socialItems=orderItems(items)),buildRailP(),appendSocialToMain(socialItems),buildRailS(socialItems),wireTileVideos(railS,function(idx){return socialItems[idx-productCount]});var i=centreIndex();highlight(i),playCentre(i),updateArrows(railP),updateArrows(railS)},window.__pdpGalRebuild()})()})();
2//# sourceMappingURL=/cdn/shop/t/43/assets/pdp-ugc-strip.js.map?v=35232033370388807161789561657

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.