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