window.getStampedPhotos=(productId,widgetKey)=>new Promise(resolve=>{const url=`https://stamped.io/api/widget/reviews?type=instagram-feed&productId=${productId}&take=100&apiKey=${widgetKey}&storeUrl=birdygrace.myshopify.com`;fetch(url,{method:"GET",crossDomain:!0,headers:{Accept:"application/json","Content-Type":"application/json"}}).then(res=>res.json()).then(json=>{const arr=[];json.data.forEach(image=>{arr.push({src:image.imageUrl,caption:image.mediaText,products:image.tags,user:image.username,timestamp:image.dateCreated})}),resolve(arr)}).catch(err=>{console.error(`error:${err}`),resolve({error:"There was an error fetching the instagram stamped content that powers See It In The Wild"})})});const buildSeeItInTheWild=()=>{const seeItInTheWild=document.getElementById("see-it-in-the-wild"),carouselContent=seeItInTheWild?.querySelector("#see-it-in-the-wild-content"),carouselLeftButton=seeItInTheWild?.querySelector(".carousel-left"),carouselRightButton=seeItInTheWild?.querySelector(".carousel-right");getStampedPhotos(carouselContent.dataset.gallery,stampedKey).then(data=>{data.length>0&&(document.getElementById("see-it-in-the-wild").style.display="block"),data.length<4&&(carouselContent.classList.add("w-auto"),carouselContent.classList.add("justify-center"),carouselContent.classList.remove("w-max"),carouselLeftButton.classList.add("hidden"),carouselLeftButton.classList.remove("fine-block"),carouselRightButton.classList.add("hidden"),carouselRightButton.classList.remove("fine-block"));let elements="";data.forEach((item,index)=>{if(index<30){let prev="null",next="null";index!==0&&(prev=`home-insta-object-${index-1}`),index<30&&index!==data.length-1&&(next=`home-insta-object-${index+1}`),elements+=`
`}}),carouselContent.innerHTML=elements,document.querySelectorAll(".insta-image").forEach(insta=>{insta.addEventListener("click",showInsta)})})};
//# sourceMappingURL=/cdn/shop/t/2918/assets/product--see-it-in-the-wild.js.map