import{useProductStore as e,usePageStore as r,useProduct as t,useVariants as n}from"@gem-sdk/core";import{useMemo as s}from"react";import{checkDefaultVariant as i}from"../../../product/helpers/product.js";import{useBuyerConsentChecked as o}from"../../buyer-consent/hooks/useBuyerConsentChecked.js";import{useSubscriptionSellingType as l}from"./useSubscriptionSellingType.js";let u=()=>{let{checked:u}=o(),p=e(e=>e.selectedOptions),{isOneTime:c}=l(),m=r(e=>e.getSubscriptionVisible()),d=t(),g=n(),f=s(()=>{let e=!m?.[d?.id??""]?.length;if(u||c||e)return!1;let r=!!d?.sellingPlanGroups?.length||!!d?.variants?.edges.find(e=>!!e.node?.sellingPlanGroups?.length);if(!r||!p)return!1;let t=i(d);if(!t){let e=g.find(e=>e?.selectedOptions.every(e=>p[e.name??""]===e.value)),r=!!e?.sellingPlanGroups?.length;return r}return!0},[p,c,u,d,g]);return{isDisableAccept:f}};export{u as useSubscriptionConsentCheck};
