import{r as e}from"./rolldown-runtime-DIIn1E2Q.js";import{D as t,Ft as n,Ot as r,Z as i}from"./vendor-vue-core-IZuWV8u3.js";import{t as a}from"./types-Bc3W4AWd.js";import{n as o}from"./vendor-i18n-NwyZMF0q.js";import{t as s}from"./telemetry-B10ff63e.js";import{Sr as c,_r as l,ht as u,t as d,vr as f}from"./dialogService-J-k0CeI4.js";function useSubscriptionActions(){let e=d(),t=l(),n=c(),o=s(),{fetchStatus:u}=f(),p=r(!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 n.execute(`Comfy.ContactSupport`)}catch(e){console.error(`[useSubscriptionActions] Error contacting support:`,e)}finally{p.value=!1}},handleRefresh=async()=>{try{await Promise.all([t.fetchBalance(),u()])}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 u({cents:e??0,locale:t,numberOptions:{minimumFractionDigits:0,maximumFractionDigits:0}})}function useSubscriptionCredits(){let e=f(),{locale:r}=o();return{totalCredits:t(()=>formatBalance(n(e.balance)?.amountMicros,r.value)),monthlyBonusCredits:t(()=>formatBalance(n(e.balance)?.cloudCreditBalanceMicros,r.value)),prepaidCredits:t(()=>formatBalance(n(e.balance)?.prepaidBalanceMicros,r.value)),isLoadingBalance:t(()=>n(e.isLoading))}}export{useSubscriptionActions as n,useSubscriptionCredits as t};
//# sourceMappingURL=useSubscriptionCredits-BbuyFbNI.js.map