dsh-cost-meter 1.9.39 → 1.9.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- window.__ModuleLoader__.load({id:"dsh-cost-meter",chunk:"client.settings-overview.js",factory:B=>{const{createElement:t,Fragment:Q}=B("react");function C({state:i,snapshot:m,helpers:s,resolveLocale:P,formatMoneyUsd:T,formatTokens:N}){const o=i?.config??{activeLocale:m?.locale},h=P(o),n=s.makeT(h),g=(e,c)=>h==="en"?c:e,v=s.useCodexQuota(o.codexQuotaEnabled===!0,o.codexQuotaSource);if(!i)return t("div",{className:"cm-section",role:m?.error?"alert":"status"},m?.error||n(m?.status==="loading"?"readingLedger":"ledgerUnavailable"));const f=(e,c,l)=>t("section",{key:e,className:"cm-budget","data-overview-source":e},t("h3",{className:"cm-h"},c),l),d=e=>t("p",{className:"cm-note"},e),W=e=>e?.fetchedAt>0?d(n("goQuotaFetchedAt",{time:new Date(e.fetchedAt).toLocaleString(h==="en"?"en-US":"zh-CN")})):null,w=(e,c)=>t(Q,null,["ok","partial"].includes(e?.status)?c:t("p",{className:e?.status==="error"?"cm-err":"cm-note",role:e?.status==="error"?"alert":void 0},e?.message||n("codingPlanNotQueried")),["ok","partial"].includes(e?.status)&&e.message?d(e.message):null,W(e)),p=(e,c)=>{const l=(s.codingPlanWindowEntries?s.codingPlanWindowEntries(e,c):Object.entries(e??{})).filter(([,a])=>a!=null);return l.length?t("div",{className:"cm-go-list"},l.map(([a,u])=>s.quotaWindowRow(n,(u.label||s.codingPlanWindowLabel(a==="five"?"5h":a,n))+(typeof u.percent=="number"?g(" · 剩余"," · remaining"):""),u,"remaining",!1,a))):d(n("codingPlanNotQueried"))},r=[];if(o.balance?.display!=="off"&&o.hideOfficialBalance!==!0){const e=i.balance;r.push(f("balance",n("accountBalance"),w(e,t("div",{className:"cm-card-value cm-num"},e?.totalBalance==null?"—":s.formatBalanceMoney(e.totalBalance,o,e.currency)))))}if(o.goQuota?.enabled!==!1&&o.goQuota?.display!=="off"){const e=i.goQuota;r.push(f("go",n("goQuotaTitle"),w(e,p({[n("goWindowRolling")]:e?.rolling,[n("goWindowWeekly")]:e?.weekly,[n("goWindowMonthly")]:e?.monthly}))))}o.codexQuotaEnabled===!0&&r.push(f("codex",n("codexQuotaTitle"),w(v,p(v.windows))));for(const{id:e,labelKey:c}of s.CODING_PLAN_ROWS){const l=o.codingPlans?.[e],a=i.codingPlans?.[e];l?.enabled===!0&&l.display!=="off"&&r.push(f(e,n(c),w(a,p(a?.windows,e))))}(o.customBalances?.length?o.customBalances:o.customBalance?[o.customBalance]:[]).forEach((e,c)=>{if(!e.enabled||e.display==="off")return;const l=i.customBalances?.find(a=>a.index===c)??(c===0&&!i.customBalances?.length?i.customBalance:null);r.push(f("custom-"+c,h==="en"&&e.labelEn||e.label||n("customBalanceTitle"),w(l,t("div",{className:"cm-card-value cm-num"},l?.remaining==null?"—":s.formatCustomBalanceMoney(l.remaining,o,l,e)))))});for(const e of o.gatewayQuotas?.sources??[]){if(!e.enabled||e.display==="off")continue;const c=i.gatewayQuotas?.find(a=>a.id===e.id),l=(a,u)=>a?t("p",{key:u,className:"cm-note cm-num"},(a.label||a.unit||"Credits")+" · "+g("剩余 ","Remaining ")+(a.remaining??"—")+" / "+(a.limit??"—")):null;r.push(f("gateway-"+e.id,e.label||e.id,w(c,c?.accounts?.length?c.accounts.map((a,u)=>t("div",{key:a.id||u},t("h4",{className:"cm-h"},a.label||a.provider),a.message?d(a.message):null,p(Object.fromEntries((a.windows??[]).map((b,y)=>[b.id||y,b]))),l(a.credits),(a.credits?.packages??[]).map((b,y)=>l(b,b.id||y)))):d(n("gatewaySourceNoAccounts")))))}return t("div",{className:"cm-section","data-settings-overview":!0},d(g("费用和额度随当前数据更新。调整配置请前往「插件 → 费用计量」。","Costs and quotas update with the current data. Configure them in Plugins → Cost meter.")),m?.error?t("p",{className:"cm-err",role:"alert"},n("ledgerReadFailed",{message:m.error})):null,t("div",{className:"cm-overview-grid"},t("div",{className:"cm-cards",style:{"--cm-overview-count":o.hideTodayCost===!0?2:3}},[["today","cardToday"],["month","cardMonth"],["total","cardTotal"]].filter(([e])=>e!=="today"||o.hideTodayCost!==!0).map(([e,c])=>{const l=i[e];return t(s.Card,{key:e,title:n(c),value:T(s.displayCostOf(l,o),o),sub:n("callsTokens",{calls:l.calls,input:N(l.input),cache:N(l.cacheRead+l.cacheWrite),output:N(l.output)})})}))),d(n("cardsFootnote")),d(n("cardsTogglePlanTotal")+": "+g(o.showTotalWithPlan?"已开启":"已关闭",o.showTotalWithPlan?"On":"Off")),o.budget?.enabled&&o.hideBudget!==!0?t(s.BudgetBoxContent,{state:i,wide:!0}):null,t("h3",{className:"cm-h"},g("余额与额度","Balances and quotas")),r.length?t("div",{className:"cm-quota-list"},r):d(g("尚未启用余额或额度来源。","No balance or quota sources enabled.")),t(s.UsagePanel,{state:i,t:n,locale:h}),t("h3",{className:"cm-h"},n("todaySessions")),t(s.TodaySessions,{state:i}))}return{mount:()=>C}}});
1
+ window.__ModuleLoader__.load({id:"dsh-cost-meter",chunk:"client.settings-overview.js",factory:B=>{const{createElement:o,Fragment:Q}=B("react");function C({state:i,snapshot:m,helpers:s,resolveLocale:P,formatMoneyUsd:T,formatTokens:N}){const t=i?.config??{activeLocale:m?.locale},b=P(t),l=s.makeT(b),g=(e,c)=>b==="en"?c:e,v=s.useCodexQuota(t.codexQuotaEnabled===!0,t.codexQuotaSource);if(!i)return o("div",{className:"cm-section",role:m?.error?"alert":"status"},m?.error||l(m?.status==="loading"?"readingLedger":"ledgerUnavailable"));const f=(e,c,n)=>o("section",{key:e,className:"cm-budget","data-overview-source":e},o("h3",{className:"cm-h"},c),n),d=e=>o("p",{className:"cm-note"},e),W=e=>e?.fetchedAt>0?d(l("goQuotaFetchedAt",{time:new Date(e.fetchedAt).toLocaleString(b==="en"?"en-US":"zh-CN")})):null,w=(e,c)=>o(Q,null,["ok","partial"].includes(e?.status)?c:o("p",{className:e?.status==="error"?"cm-err":"cm-note",role:e?.status==="error"?"alert":void 0},e?.message||l("codingPlanNotQueried")),["ok","partial"].includes(e?.status)&&e.message?d(e.message):null,W(e)),p=(e,c)=>{const n=(s.codingPlanWindowEntries?s.codingPlanWindowEntries(e,c):Object.entries(e??{})).filter(([,a])=>a!=null);return n.length?o("div",{className:"cm-go-list"},n.map(([a,u])=>s.quotaWindowRow(l,(u.label||s.codingPlanWindowLabel(a==="five"?"5h":a,l))+(typeof u.percent=="number"?g(" · 剩余"," · remaining"):""),u,"remaining",!1,a))):d(l("codingPlanNotQueried"))},r=[];if(t.balance?.display!=="off"&&t.hideOfficialBalance!==!0){const e=i.balance;r.push(f("balance",l("accountBalance"),w(e,o("div",{className:"cm-card-value cm-num"},e?.totalBalance==null?"—":s.formatBalanceMoney(e.totalBalance,t,e.currency)))))}if(t.goQuota?.enabled!==!1&&t.goQuota?.display!=="off"){const e=i.goQuota;r.push(f("go",l("goQuotaTitle"),w(e,p({[l("goWindowRolling")]:e?.rolling,[l("goWindowWeekly")]:e?.weekly,[l("goWindowMonthly")]:e?.monthly}))))}t.codexQuotaEnabled===!0&&r.push(f("codex",l("codexQuotaTitle"),w(v,p(v.windows))));for(const{id:e,labelKey:c}of s.CODING_PLAN_ROWS){const n=t.codingPlans?.[e],a=i.codingPlans?.[e];n?.enabled===!0&&n.display!=="off"&&r.push(f(e,l(c),w(a,p(a?.windows,e))))}(t.customBalances?.length?t.customBalances:t.customBalance?[t.customBalance]:[]).forEach((e,c)=>{if(!e.enabled||e.display==="off")return;const n=i.customBalances?.find(a=>a.index===c)??(c===0&&!i.customBalances?.length?i.customBalance:null);r.push(f("custom-"+c,b==="en"&&e.labelEn||e.label||l("customBalanceTitle"),w(n,o("div",{className:"cm-card-value cm-num"},n?.remaining==null?"—":s.formatCustomBalanceMoney(n.remaining,t,n,e)))))});for(const e of t.gatewayQuotas?.sources??[]){if(!e.enabled||e.display==="off")continue;const c=i.gatewayQuotas?.find(a=>a.id===e.id),n=(a,u)=>a?o("p",{key:u,className:"cm-note cm-num"},(a.label||a.unit||"Credits")+" · "+g("剩余 ","Remaining ")+(a.remaining??"—")+" / "+(a.limit??"—")):null;r.push(f("gateway-"+e.id,e.label||e.id,w(c,c?.accounts?.length?c.accounts.map((a,u)=>o("div",{key:a.id||u},o("h4",{className:"cm-h"},a.label||a.provider),a.message?d(a.message):null,p(Object.fromEntries((a.windows??[]).map((h,y)=>[h.id||y,h]))),n(a.credits),(a.credits?.packages??[]).map((h,y)=>n(h,h.id||y)))):d(l("gatewaySourceNoAccounts")))))}return o("div",{className:"cm-section","data-settings-overview":!0},d(g("费用和额度随当前数据更新。调整配置请前往「插件 → 费用计量」。","Costs and quotas update with the current data. Configure them in Plugins → Cost meter.")),m?.error?o("p",{className:"cm-err",role:"alert"},l("ledgerReadFailed",{message:m.error})):null,o("div",{className:"cm-overview-grid"},o("div",{className:"cm-cards",style:{"--cm-overview-count":t.hideTodayCost===!0?2:3}},[["today","cardToday"],["month","cardMonth"],["total","cardTotal"]].filter(([e])=>e!=="today"||t.hideTodayCost!==!0).map(([e,c])=>{const n=i[e];return o(s.Card,{key:e,title:l(c),value:T(s.displayCostOf(n,t),t),sub:l("callsTokens",{calls:n.calls,input:N(n.input),cache:N(n.cacheRead+n.cacheWrite),output:N(n.output)})})}))),d(l("cardsFootnote")),o(s.BillingAccuracyNote,{state:i}),d(l("cardsTogglePlanTotal")+": "+g(t.showTotalWithPlan?"已开启":"已关闭",t.showTotalWithPlan?"On":"Off")),t.budget?.enabled&&t.hideBudget!==!0?o(s.BudgetBoxContent,{state:i,wide:!0}):null,o("h3",{className:"cm-h"},g("余额与额度","Balances and quotas")),r.length?o("div",{className:"cm-quota-list"},r):d(g("尚未启用余额或额度来源。","No balance or quota sources enabled.")),o(s.UsagePanel,{state:i,t:l,locale:b}),o("h3",{className:"cm-h"},l("todaySessions")),o(s.TodaySessions,{state:i}))}return{mount:()=>C}}});