import"./rolldown-runtime-DIIn1E2Q.js";import{D as e,It as t,Z as n,kt as r}from"./vendor-vue-core-DO0afONr.js";import{t as i}from"./types-DPJvCrdo.js";import{n as a}from"./vendor-i18n-JbyM4Qz7.js";import{t as o}from"./telemetry-B-mZAUOK.js";import{Ei as s,Gi as c,Si as l,Wi as u,nn as d,t as f,xi as p}from"./dialogService-Cm1GEBK8.js";function useSubscriptionActions(){let e=f(),t=p(),a=s(),c=o(),{fetchStatus:u}=l(),d=r(!1);n(()=>{handleRefresh()});let handleAddApiCredits=()=>{e.showTopUpCreditsDialog()},handleMessageSupport=async()=>{try{d.value=!0,i&&c?.trackHelpResourceClicked({resource_type:`help_feedback`,is_external:!0,source:`subscription`}),await a.execute(`Comfy.ContactSupport`)}catch(e){console.error(`[useSubscriptionActions] Error contacting support:`,e)}finally{d.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:d,handleAddApiCredits,handleMessageSupport,handleRefresh,handleLearnMoreClick}}function formatBalance(e,t){return d({cents:e??0,locale:t,numberOptions:{minimumFractionDigits:0,maximumFractionDigits:0}})}function useSubscriptionCredits(){let n=l(),{locale:r}=a();return{totalCredits:e(()=>formatBalance(t(n.balance)?.amountMicros,r.value)),monthlyBonusCredits:e(()=>formatBalance(t(n.balance)?.cloudCreditBalanceMicros,r.value)),prepaidCredits:e(()=>formatBalance(t(n.balance)?.prepaidBalanceMicros,r.value)),isLoadingBalance:e(()=>t(n.isLoading))}}function getCommonTierBenefits(e,t,n){let r=[],i=e===`free`;if(i){let i=u(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`)}),c(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-D5L7Ff5T.js.map