import*as t from"@wordpress/interactivity";var e={d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)};const n=(i={getContext:()=>t.getContext,getElement:()=>t.getElement,store:()=>t.store},s={},e.d(s,i),s),o="I acknowledge that using a private store means my plugin will inevitably break on the next store release.",{state:a}=(0,n.store)("woocommerce/products",{},{lock:o}),r=(0,n.store)("woocommerce/add-to-cart-with-options",{},{lock:o});var i,s;(0,n.store)("woocommerce/add-to-cart-with-options-quantity-selector",{state:{get allowsQuantityChange(){const t=a.productInContext;return!t||t.is_in_stock&&!t.sold_individually},get allowsDecrease(){const{quantity:t}=r.state,e=a.productInContext;if(!e)return!0;const{id:o,add_to_cart:i}=e,s=t[o]||0,{allowZero:u}=(0,n.getContext)();return u&&s>0||s-i.multiple_of>=i.minimum},get allowsIncrease(){const{quantity:t}=r.state,e=a.productInContext;if(!e)return!0;const{id:n,add_to_cart:o}=e;return(t[n]||0)+o.multiple_of<=o.maximum},get inputQuantity(){const t=a.productInContext;if(!t)return 0;const e=r.state.quantity?.[t.id];return void 0===e?0:e}},actions:{increaseQuantity:()=>{const{inputElement:t}=(0,n.getContext)();if(!(t instanceof HTMLInputElement))return;const e=a.productInContext;if(!e)return;const o=Number(t.value)||0,{id:i,add_to_cart:s}=e,{minimum:u,maximum:c,multiple_of:l}=s,m=Math.max(u,Math.min(c,o+l));r.actions.setQuantity(i,m)},decreaseQuantity:()=>{const{allowZero:t,inputElement:e}=(0,n.getContext)();if(!(e instanceof HTMLInputElement))return;const o=a.productInContext;if(!o)return;const i=Number(e.value)||0,{id:s,add_to_cart:u}=o,{minimum:c,maximum:l,multiple_of:m}=u;let d=i-m;d=t&&d<c&&i===c?0:Math.min(l,Math.max(c,d)),d!==i&&r.actions.setQuantity(s,d)},handleQuantityBlur:()=>{const{allowZero:t,inputElement:e}=(0,n.getContext)(),o=a.productInContext;if(!o)return;const{id:i,add_to_cart:s}=o,u=Number.isNaN(e?.valueAsNumber);if(t&&(u||0===e?.valueAsNumber))return void r.actions.setQuantity(i,0);const c=e?.valueAsNumber??NaN,l=!isNaN(c)&&c>0?c:s.minimum;r.actions.setQuantity(i,l)},handleQuantityCheckboxChange:()=>{const t=(0,n.getElement)();if(!(t.ref instanceof HTMLInputElement))return;const e=a.productInContext;e&&r.actions.setQuantity(e.id,t.ref.checked?1:0)}},callbacks:{storeInputElementRef:()=>{const{ref:t}=(0,n.getElement)();if(t){const e=(0,n.getContext)(),o=t.querySelector(".qty");e.inputElement=o}}}},{lock:o});