import*as e from"@wordpress/interactivity";var t={9965:()=>{},438:e=>{e.exports=import("@wordpress/interactivity-router")}},o={};function r(e){var i=o[e];if(void 0!==i)return i.exports;var n=o[e]={exports:{}};return t[e](n,n.exports,r),n.exports}r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);const i=(c={getContext:()=>e.getContext,getElement:()=>e.getElement,store:()=>e.store},l={},r.d(l,c),l),n=(e,{bubbles:t=!1,cancelable:o=!1,element:r,detail:i={}})=>{if(!CustomEvent)return;r||(r=document.body);const n=new CustomEvent(e,{bubbles:t,cancelable:o,detail:i});r.dispatchEvent(n)},s=e=>{n("wc-blocks_product_list_rendered",{bubbles:!0,cancelable:!0,detail:e})};var c,l;r(9965);const{state:a}=(0,i.store)("woocommerce/products",{},{lock:"I acknowledge that using a private store means my plugin will inevitably break on the next store release."});function d(){return"rtl"===document.documentElement?.dir}function u(e){return null!==e&&e instanceof window.HTMLAnchorElement&&!!e.href&&(!e.target||"_self"===e.target)&&e.origin===window.location.origin}const b=(e,t)=>{if(!e)return{isDisabledPrevious:!0,isDisabledNext:!0};const{scrollWidth:o,clientWidth:r}=e;return d()?{isDisabledPrevious:t>-5,isDisabledNext:t<=r-o+5}:{isDisabledPrevious:t<5,isDisabledNext:t>=o-r-5}},f=e=>{const{ref:t}=(0,i.getElement)(),o=t?.closest(".wp-block-woocommerce-product-collection"),r=o?.querySelector(".wc-block-product-template");if(!r)return;const n=o?.clientWidth,s=n?.9*n:400,c=d()?-1:1;r?.scrollBy({left:c*("left"===e?-s:s),behavior:"smooth"});const l=(0,i.getContext)(),{scrollLeft:a}=r,u="left"===e?a-c*s:a+c*s,{isDisabledPrevious:f,isDisabledNext:v}=b(r,u);l.isDisabledPrevious=f,l.isDisabledNext=v},v=e=>{"ArrowRight"===e.code&&(e.preventDefault(),f("right")),"ArrowLeft"===e.code&&(e.preventDefault(),f("left"))};(0,i.store)("woocommerce/product-collection",{actions:{*navigate(e){const{ref:t}=(0,i.getElement)();if(u(t)&&function(e){return!(0!==e.button||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey||e.defaultPrevented)}(e)){e.preventDefault();const o=(0,i.getContext)(),n=t.closest("[data-wp-router-region]")?.getAttribute("data-wp-router-region"),{actions:c}=yield Promise.resolve().then(r.bind(r,438));yield c.navigate(t.href),o.isPrefetchNextOrPreviousLink=t.href;const l=document.querySelector(`[data-wp-router-region=${n}] .wc-block-product-template .wc-block-product a`);l?.focus(),s({collection:o.collection})}},*prefetchOnHover(){const{ref:e}=(0,i.getElement)();if(u(e)){const{actions:t}=yield Promise.resolve().then(r.bind(r,438));yield t.prefetch(e.href)}},*viewProduct(){const{collection:e}=(0,i.getContext)(),t=a.productInContext?.id;t&&n("wc-blocks_viewed_product",{bubbles:!0,cancelable:!0,detail:{collection:e,productId:t}})},onClickPrevious:()=>{f("left")},onClickNext:()=>{f("right")},onKeyDownPrevious:e=>{v(e)},onKeyDownNext:e=>{v(e)},watchScroll:()=>{const e=(0,i.getContext)(),{ref:t}=(0,i.getElement)();if(t){const{isDisabledPrevious:o,isDisabledNext:r}=b(t,t.scrollLeft);e.isDisabledPrevious=o,e.isDisabledNext=r}}},callbacks:{*prefetch(){const{ref:e}=(0,i.getElement)(),t=(0,i.getContext)();if(u(e)&&t.isPrefetchNextOrPreviousLink){const{actions:t}=yield Promise.resolve().then(r.bind(r,438));yield t.prefetch(e.href)}},*onRender(){const{collection:e}=(0,i.getContext)();s({collection:e})},initResizeObserver:()=>{const e=(0,i.getElement)()?.ref;if(!e)return;const t=(0,i.getContext)();new ResizeObserver(()=>{const o=e.scrollWidth>e.clientWidth;t.hideNextPreviousButtons=!o}).observe(e)}}},{lock:!0});