"use strict";var e=require("react"),i=require("@gem-sdk/core"),n=require("../../../constants/index.js"),s=require("./useSellingPlanOptions.js"),u=require("../../../hooks/useSubscriptionSellingType.js");exports.useSubscriptionVisibility=({setting:r})=>{let l=i.useProductStore(e=>e.setSubscriptionSellingType),{isOneTime:t,subscriptionSellingType:S}=u.useSubscriptionSellingType(),o=s.useSellingPlanOptions(r),p=i.useProduct(),c=e.useMemo(()=>p?.requiresSellingPlan,[p?.requiresSellingPlan]),g=e.useMemo(()=>t?n.SubscriptionEnum.ONE_TIME:n.SubscriptionEnum.SUBSCRIPTION,[t]);e.useEffect(()=>{S||(r?.sellingType===n.SubscriptionEnum.ONE_TIME?l(n.SubscriptionEnum.ONE_TIME):l(r?.sellingType??n.SubscriptionEnum.SUBSCRIPTION))},[l,r?.sellingType,S]);let E=!c&&o&&o.length>0,T=r?.sellingType===n.SubscriptionEnum.SUBSCRIPTION&&(!o||0===o.length),b=r?.sellingType===n.SubscriptionEnum.ONE_TIME&&c,m=(!o||0===o.length)&&!c;return{selectedType:g,shouldShowRadio:E,isOneTimeHidden:b,requiresSellingPlan:c,isOnetimeOnly:m,hasNoSellingPlanOptions:T,setSubscriptionSellingType:l}};
