import{r as e}from"./rolldown-runtime-DIIn1E2Q.js";import{D as t,Dt as n,Pt as r,Z as i}from"./vendor-vue-core-CvBSzfTV.js";import{t as a}from"./types-Bc3W4AWd.js";import{n as o}from"./vendor-i18n-B2MApQxA.js";import{t as s}from"./telemetry-B_FqZaK0.js";import{Jn as c,Un as l,Wn as u,i as d,t as f}from"./dialogService-Dp405gae.js";function useSubscriptionActions(){let e=f(),t=l(),r=c(),o=s(),{fetchStatus:d}=u(),p=n(!1);i(()=>{handleRefresh()});let handleAddApiCredits=()=>{e.showTopUpCreditsDialog()},handleMessageSupport=async()=>{try{p.value=!0,a&&o?.trackHelpResourceClicked({resource_type:`help_feedback`,is_external:!0,source:`subscription`}),await r.execute(`Comfy.ContactSupport`)}catch(e){console.error(`[useSubscriptionActions] Error contacting support:`,e)}finally{p.value=!1}},handleRefresh=async()=>{try{await Promise.all([t.fetchBalance(),d()])}catch(e){console.error(`[useSubscriptionActions] Error refreshing data:`,e)}},handleLearnMoreClick=()=>{window.open(`https://docs.comfy.org/get_started/cloud`,`_blank`)};return{isLoadingSupport:p,handleAddApiCredits,handleMessageSupport,handleRefresh,handleLearnMoreClick}}function formatBalance(e,t){return d({cents:e??0,locale:t,numberOptions:{minimumFractionDigits:0,maximumFractionDigits:0}})}function useSubscriptionCredits(){let e=u(),{locale:n}=o();return{totalCredits:t(()=>formatBalance(r(e.balance)?.amountMicros,n.value)),monthlyBonusCredits:t(()=>formatBalance(r(e.balance)?.cloudCreditBalanceMicros,n.value)),prepaidCredits:t(()=>formatBalance(r(e.balance)?.prepaidBalanceMicros,n.value)),isLoadingBalance:t(()=>r(e.isLoading))}}export{useSubscriptionActions as n,useSubscriptionCredits as t};
//# sourceMappingURL=useSubscriptionCredits-Bm8j3Sbf.js.map