"use strict";function _typeof(e){return(_typeof=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e2){return typeof e2}:function(e2){return e2&&typeof Symbol=="function"&&e2.constructor===Symbol&&e2!==Symbol.prototype?"symbol":typeof e2})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;rMath.abs(r)&&(0i?.classList.remove("is-active")),f?.classList.add("is-active")}),this.querySelector(".slider-button--prev")),e=(e&&e.addEventListener("click",function(e2){e2.preventDefault(),t2.dirty=!0,plusSlides(t2,-1)}),e.addEventListener("keydown",function(e2){(e2.key==="Enter"||e2.key==" ")&&(e2.preventDefault(),t2.dirty=!0,plusSlides(t2,-1))}),e.addEventListener("blur",function(e2){e2.preventDefault(),l?.forEach(i=>i?.classList.remove("is-active")),f?.classList.add("is-active")}),this.querySelector(".card-product-slider")),r=this.closest(".card__media");e&&1o.length&&(slideIndexNumber=1),e<1&&(slideIndexNumber=o.length),n=0;n{func.apply(this,args)},delay)}}new ResizeObserver(debounce(()=>{setTimeout(()=>{swatchContainer.clientWidth!=0?this.init(swatchContainer,swathitem,hidecountbtn,countnum):setTimeout(()=>{this.init(swatchContainer,swathitem,hidecountbtn,countnum)},200)},200)},200)).observe(swatchContainer)}init(swatchContainer,swathitem,hidecountbtn,countnum){const containerWidth=swatchContainer.clientWidth;if(Array.from(swathitem).reduce((total,swatch)=>total+swatch.offsetWidth+4,0)>containerWidth){let hidedefaultshownum=this.calculateSwatches(containerWidth,swathitem[0].offsetWidth+4),showcolorcount=swathitem.length-hidedefaultshownum;swatchContainer.style.width=containerWidth,hidecountbtn.classList.remove("hidden"),countnum.textContent="+"+showcolorcount,countnum.setAttribute("more-swatch-count",hidedefaultshownum),countnum.setAttribute("hide-swatch-count",showcolorcount),swathitem.forEach((item,index)=>{index>=hidedefaultshownum&&item.classList.add("d-none")})}}onshowOriginColor(event){const elElement=event.currentTarget,elPrent=elElement.closest(".item-swatch");let hidecountbtn=elPrent.querySelector(".over-swatch-btn");elElement.classList.add("d-none"),hidecountbtn.classList.remove("d-none"),elPrent.style.left="0";var hideitem=elPrent.querySelectorAll(".s-item.d-block");for(const item of hideitem)item.classList.remove("d-block")}calculateSwatches(containerWidth,swatchWidth){let containerUseWidth=containerWidth-swatchWidth;return Math.floor(containerUseWidth/swatchWidth)}onShowMoreColor(event){const elElement=event.currentTarget,elPrent=elElement.closest(".item-swatch"),index=elElement.querySelector(".more-swatch").getAttribute("more-swatch-count"),elPrent_toLeft=Number(index*34);let backleftbtn=elPrent.querySelector(".backtoleft");if(backleftbtn)var newLi=backleftbtn;else{var newLi=document.createElement("li");newLi.className="backtoleft",newLi.innerHTML=` `}const targetLI=elPrent.querySelector(`li:nth-child(${index})`);targetLI.parentNode.insertBefore(newLi,targetLI.nextSibling);let hideitem=elElement.closest(".item-swatch").querySelectorAll(".s-item.d-none");for(const item of hideitem)item.classList.add("d-block");elElement.classList.add("d-none"),newLi.classList.remove("d-none"),elPrent.style.left=`-${elPrent_toLeft}px`,newLi.addEventListener("click",event2=>{this.onshowOriginColor(event2)})}onClicktoCoverImage2(event){const labelElement=event.currentTarget.nextElementSibling;labelElement&&labelElement.querySelector(".swatch").click()}onClicktoCoverImage(event){const elElement=event.currentTarget,imgSrc=elElement.getAttribute("data-img"),target_img=elElement.closest(".card-wrapper").querySelector(".first-img img"),target_img_src=target_img.getAttribute("src");elElement.setAttribute("tabindex",0),target_img_src!=imgSrc?(target_img.setAttribute("src",imgSrc),target_img.setAttribute("srcset",imgSrc),console.log("Updated img src to:",imgSrc)):console.log("No img element found.");const siblings=elElement.closest(".item-swatch").querySelectorAll(".swatch");for(const sibling of siblings)sibling!==elElement&&sibling.setAttribute("tabindex","-1")}onHovertoCoverImage(event){const elElement=event.currentTarget;event.type=="mouseenter"&&elElement.click()}onkeydownSwatch(event){const elElement=event.currentTarget,index=parseInt(elElement.getAttribute("data-valueindex")),totalSize=parseInt(elElement.closest(".item-swatch").getAttribute("data-count"));let nextIndex=index+1,prevIndex=index-1;if(nextIndex>totalSize&&(nextIndex=1),prevIndex<=0&&(prevIndex=totalSize),(event.key==="Enter"||event.key==" ")&&this.click(),event.key==="ArrowRight"||event.key==="ArrowDown"){const nextLabel=elElement.closest(".item-swatch").querySelector(`.swatch[data-valueindex='${nextIndex}']`);nextLabel&&(nextLabel.focus(),nextLabel.click(),nextLabel.addEventListener("click",this.onClicktoCoverImage.bind(this)))}if(event.key==="ArrowLeft"||event.key==="ArrowUp"){const prevLabel=elElement.closest(".item-swatch").querySelector(`.swatch[data-valueindex='${prevIndex}']`);prevLabel&&(prevLabel.focus(),prevLabel.click(),prevLabel.addEventListener("click",this.onClicktoCoverImage.bind(this)))}}}customElements.define("color-change-component",ColorChangeComponent); //# sourceMappingURL=/cdn/shop/t/106/assets/component-card-product-slider.js.map?v=149611913543897251851752133283