import{useProduct as o}from"@gem-sdk/core";import{createStyle as s,createClass as t}from"@gem-sdk/system";import{useRef as e,useId as i}from"react";import{SubscriptionEnum as r}from"../../../constants/index.js";import{getWrapperClasses as n,getContainerClasses as l}from"../common/classes.js";import{getSubscriptionStyles as m,getSubscriptionWrapperStyles as p}from"../common/styles.js";import{extractProductID as u}from"../../../../../helpers.js";import{useSellingPlanChange as c}from"./useSellingPlanChange.js";import{useSellingPlanOptions as a}from"./useSellingPlanOptions.js";import{useSellingSubscription as S}from"./useSellingSubscription.js";import{useSubscriptionVisibility as d}from"./useSubscriptionVisibility.js";import{useDynamicProduct as f}from"../../../hooks/useDynamicProduct.js";import{useCheckProductsSubscriptionExistence as g}from"./useCheckProductsSubscriptionExistence.js";let DEFAULT_DIRECTION="ltr",useProductSubscriptionContentData=({setting:I,styles:b,builderProps:T})=>{let j=o(),{defaultValue:P,selectedSellingPlan:y,setSelectedSellingPlan:E}=S(I),O=a(I),{selectedValue:h,handleSellingPlanChange:N}=c({defaultValue:P,selectedSellingPlan:y,setSelectedSellingPlan:E,sellingPlanOptions:O}),C=e(null),D=i(),k=d({setting:I}),R=s(m(b)),U=s(p(b?.align)),_=t(n()),x=t(l()),M=`product-subscription-${u(j?.baseID??"")}`,B=u(j?.baseID??""),$=`subscription-type-selection-${D}`,w=I?.sellingType===r.ONE_TIME,A=I?.sellingType===r.SUBSCRIPTION,F=w?r.ONE_TIME:r.SUBSCRIPTION,{isDynamicProduct:L}=f(),{sellingTitleDirection:V,sellingTitleOneTimeDirection:q}=b??{},v=F===r.ONE_TIME?q??"ltr":V??"ltr";g({productId:j?.id,elementUid:T?.uid,isSubscription:A,hasNoSellingPlanOptions:k.hasNoSellingPlanOptions,isDynamicProduct:L});let z=o=>{k.shouldShowRadio&&k.selectedType!==o&&k.setSubscriptionSellingType(o)};return{componentRef:C,componentId:M,wrapperClasses:_,subscriptionWrapperStyles:U,visibility:k,productId:B,renderType:F,radioGroupName:$,direction:v,containerClasses:x,subscriptionStyles:R,selectedValue:h,sellingPlanOptions:O,handleSellingPlanChange:N,onSelectType:z,isDynamicProduct:L}};export{useProductSubscriptionContentData};
