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-CpHGo1Sd.js";import{t as s}from"./telemetry-B10ff63e.js";import{Ti as c,Ui as l,Wi as u,bi as d,nn as f,t as p,xi as m}from"./dialogService-DeXt-oC-.js";function useSubscriptionActions(){let e=p(),t=d(),n=c(),o=s(),{fetchStatus:l}=m(),u=r(!1);i(()=>{handleRefresh()});let handleAddApiCredits=()=>{e.showTopUpCreditsDialog()},handleMessageSupport=async()=>{try{u.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{u.value=!1}},handleRefresh=async()=>{try{await Promise.all([t.fetchBalance(),l()])}catch(e){console.error(`[useSubscriptionActions] Error refreshing data:`,e)}},handleLearnMoreClick=()=>{window.open(`https://docs.comfy.org/get_started/cloud`,`_blank`)};return{isLoadingSupport:u,handleAddApiCredits,handleMessageSupport,handleRefresh,handleLearnMoreClick}}function formatBalance(e,t){return f({cents:e??0,locale:t,numberOptions:{minimumFractionDigits:0,maximumFractionDigits:0}})}function useSubscriptionCredits(){let e=m(),{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))}}function getCommonTierBenefits(e,t,n){let r=[],i=e===`free`;if(i){let i=l(e);i!==null&&r.push({key:`monthlyCredits`,type:`metric`,value:n(i),label:t(`subscription.monthlyCreditsLabel`)})}return r.push({key:`maxDuration`,type:`metric`,value:t(`subscription.maxDuration.${e}`),label:t(`subscription.maxDurationLabel`)}),r.push({key:`gpu`,type:`feature`,label:t(`subscription.gpuLabel`)}),i||r.push({key:`addCredits`,type:`feature`,label:t(`subscription.addCreditsLabel`)}),u(e).customLoRAs&&r.push({key:`customLoRAs`,type:`feature`,label:t(`subscription.customLoRAsLabel`)}),r}export{useSubscriptionCredits as n,useSubscriptionActions as r,getCommonTierBenefits as t};
//# sourceMappingURL=tierBenefits-DGyLMDUx.js.map