1import{C as a}from"./chunk-component-DORLE3-o.js";import{V as l}from"./chunk-variant-Cy08cDxQ.js";class c extends a{#e;#s;#n=new Map;connectedCallback(){super.connectedCallback(),this.refs.lightbox?.addEventListener("click",this.#a),this.refs.lightbox?.addEventListener("close",this.#c),this.refs.lightbox?.addEventListener("keydown",this.#l),this.#f(),this.#m(),this.#b(),document.addEventListener(l,this.#d)}disconnectedCallback(){super.disconnectedCallback(),this.refs.lightbox?.removeEventListener("click",this.#a),this.refs.lightbox?.removeEventListener("close",this.#c),this.refs.lightbox?.removeEventListener("keydown",this.#l),this.#s?.disconnect(),this.#e?.disconnect(),this.#h(),document.removeEventListener(l,this.#d)}openLightbox(e){const t=e.target,s=this.refs.lightbox;if(!(t instanceof HTMLElement)||!s)return;const o=Number(t.closest("[data-zoom-index]")?.dataset.zoomIndex);s.showModal(),this.#u(),this.#t(Number.isFinite(o)?o:0,"instant")}toggleMagnify(){const e=this.refs.zoomStage;e&&this.#i(!e.classList.contains("is-magnified"))}prevZoom(){this.#r(-1)}nextZoom(){this.#r(1)}#r(e){const t=this.refs.zoomSlide?.length??0;t<2||this.#t((this.#o()+e+t)%t,"smooth")}showZoom(e){const t=e.target;if(!(t instanceof HTMLElement))return;const s=Number(t.closest("[data-zoom-index]")?.dataset.zoomIndex);Number.isFinite(s)&&this.#t(s,"smooth")}closeLightbox(){this.refs.lightbox?.close()}#t(e,t){const s=this.refs.zoomSlide?.[e],o=this.refs.zoomStage;!s||!o||(this.#i(!1),o.scrollTo({top:s.offsetTop,left:s.offsetLeft,behavior:t}))}#f(){const e=this.refs.zoomSlide,t=this.refs.zoomStage;if(!(!e?.length||!t)){this.#s=new IntersectionObserver(s=>{for(const o of s){if(!o.isIntersecting)continue;const i=Number(o.target.dataset.zoomIndex);this.#g(Number.isFinite(i)?i:0)}},{root:t,rootMargin:"-45%",threshold:0});for(const s of e)this.#s.observe(s)}}#g(e){const t=this.refs.zoomThumb??[];for(const[o,i]of(this.refs.zoomSlide??[]).entries())i.toggleAttribute("data-current",o===e);for(const[o,i]of t.entries())i.setAttribute("aria-current",String(o===e));t[e]?.scrollIntoView({block:"nearest"});const s=this.refs.zoomCount;if(s){const o=s.dataset.i18nCounter??"@@ / ##";s.textContent=o.replace("@@",String(e+1)).replace("##",String(t.length))}}#o(){const e=this.refs.zoomThumb?.findIndex(t=>t.getAttribute("aria-current")==="true")??-1;return e<0?0:e}#l=e=>{const t=this.refs.zoomSlide?.length??0;if(t<2)return;const s=this.#o();let o;if(e.key==="ArrowDown"||e.key==="ArrowRight")o=(s+1)%t;else if(e.key==="ArrowUp"||e.key==="ArrowLeft")o=(s-1+t)%t;else return;e.preventDefault(),this.#t(o,"smooth")};#m(){const e=this.refs.video;if(e?.length&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches){this.#e=new IntersectionObserver(t=>{for(const s of t){const o=s.target;s.isIntersecting?o.play().catch(()=>{}):o.pause()}},{threshold:.5});for(const t of e)this.#e.observe(t)}}#a=e=>{const{target:t}=e;if(t===this.refs.lightbox){this.closeLightbox();return}t instanceof HTMLElement&&t.classList.contains("pdpGallery__zoomImg")&&(window.matchMedia("(hover: hover)").matches?this.closeLightbox():this.toggleMagnify())};#c=()=>{this.#h(),this.#i(!1)};#i(e){const t=this.refs.zoomStage;if(t?.classList.toggle("is-magnified",e),this.refs.zoomMagnify?.setAttribute("aria-pressed",String(e)),!t)return;if(e){t.scrollLeft=(t.scrollWidth-t.clientWidth)/2,t.scrollTop=(t.scrollHeight-t.clientHeight)/2;return}const s=this.refs.zoomSlide?.[this.#o()];s&&t.scrollTo({top:s.offsetTop,left:s.offsetLeft})}#u(){document.documentElement.style.overflow="hidden"}#h(){document.documentElement.style.overflow=""}#b(){const e=this.querySelector("script[data-stock-json]");if(e?.textContent)try{const t=JSON.parse(e.textContent);for(const s of t)this.#n.set(s.id,{available:s.available,quantity:s.quantity})}catch(t){console.error(t)}}#d=e=>{const t=this.refs.stockBadge;if(!t)return;const s=e.detail,o=s&&this.#n.get(s.id);if(!o)return;const i=Number(this.dataset.lowInventoryThreshold)||0;let n="",r=!1;o.available?o.quantity>0&&o.quantity<=i&&(n=t.dataset.lowInventoryLabel??"",r=!0):n=t.dataset.soldOutLabel??"",t.hidden=n==="",t.textContent=n,t.classList.toggle("pdpGallery__stockBadge--low",r)}}customElements.get("pdp-gallery")||customElements.define("pdp-gallery",c);
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.