import{r as e}from"./rolldown-runtime-DCMCV6zW.js";import{D as t,Dt as n,Pt as r,Z as i}from"./vendor-vue-core-X6q-rGJs.js";import{t as a}from"./types-DW97iHDr.js";import{n as o}from"./vendor-i18n-B5g6Drzm.js";import{t as s}from"./telemetry-KciZP3tz.js";import{dt as c,hr as l,ln as u,t as d,vn as f}from"./dialogService-Cqui0UMO.js";function useSubscriptionActions(){let e=d(),t=f(),r=l(),o=s(),{fetchStatus:c}=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(),c()])}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 c({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-DQgFoSVF.js.map