"use strict";var React=require("react"),core=require("@gem-sdk/core"),getPrice=require("../helpers/product-price-breakdown/getPrice.js");const useRecurringSubtotal=()=>{let e=core.useCurrentVariant(),r=core.useProduct(),i=core.useProductStore(e=>e.selectedSellingPlan),{quantity:t}=core.useQuantity(),l=e?.sellingPlanGroups,u=core.convertDecimalToNumber(e?.price)??0,c=React.useMemo(()=>{if(!i)return null;let t=e?.sellingPlanGroups??r?.sellingPlanGroups??[];for(let e of t)if(e?.sellingPlans){for(let r of e.sellingPlans)if(r?.baseID===i)return r}return null},[JSON.stringify(l),i]),n=JSON.stringify(c?.pricingPolicies),o=JSON.stringify(c?.billingPolicy),s=c?.baseID,a=React.useMemo(()=>{if(!s||!e||u<=0||!c)return 0;let r=getPrice.calculateRecurringPrice({variantPrice:u,pricingPolicies:c.pricingPolicies}),i=r*(t||1);return parseFloat(core.shopifyPriceRounding(i,2))},[n,u,t,s]),g=React.useMemo(()=>{if(!s||!c)return null;let e=c.deliveryPolicy;return getPrice.formatInterval({deliveryPolicy:e})},[o,s]),P=core.useFormatMoney(Math.max(a,0),!1),f=React.useMemo(()=>s&&g?`${P} ${g}`:null,[s,g,P]);return f};exports.useRecurringSubtotal=useRecurringSubtotal;
