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