const isObject=o=>o&&"object"==typeof o&&!Array.isArray(o),getSerializedState=()=>{const o=document.querySelector('script[type="application/json"]#sc-store-data');if(!o)return{};try{const t=JSON.parse(o.textContent);if(isObject(t))return t;throw Error("Parsed state is not an object")}catch(o){console.error(o)}return{}},isProductVariantOptionSoldOut=(o,t,i,n)=>{var a,l,r,d,e;const s=o=>{var t;return(null!==(t=null==o?void 0:o.has_unlimited_stock)&&void 0!==t?t:null==n?void 0:n.has_unlimited_stock)?1/0:o.available_stock},v=o=>!!o.length&&Math.max(...o.map(s))<=0;return v(1===o?null===(r=(l=(null===(a=n.variants)||void 0===a?void 0:a.data)||[]).filter)||void 0===r?void 0:r.call(l,(o=>o.option_1===t)):2===o?((null===(d=n.variants)||void 0===d?void 0:d.data)||[]).filter((o=>(null==o?void 0:o.option_1)===i.option_1&&o.option_2===t)):((null===(e=n.variants)||void 0===e?void 0:e.data)||[]).filter((o=>(null==o?void 0:o.option_1)===i.option_1&&(null==o?void 0:o.option_2)===i.option_2&&o.option_3===t)))},isProductVariantOptionMissing=(o,t,i,n)=>{var a,l,r;return 1===o?!((null===(a=null==n?void 0:n.variants)||void 0===a?void 0:a.data)||[]).some((o=>o.option_1===t)):2===o?!((null===(l=null==n?void 0:n.variants)||void 0===l?void 0:l.data)||[]).some((o=>(null==o?void 0:o.option_1)===i.option_1&&o.option_2===t)):!((null===(r=null==n?void 0:n.variants)||void 0===r?void 0:r.data)||[]).some((o=>(null==o?void 0:o.option_1)===i.option_1&&(null==o?void 0:o.option_2)===i.option_2&&o.option_3===t))};export{isProductVariantOptionMissing as a,getSerializedState as g,isProductVariantOptionSoldOut as i};