dsh-cost-meter 1.9.76 → 1.9.78

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
- ;(function(e){const S=window.__ModuleLoader__,H=S[Symbol.for("@dsh-plugin/dsh-loader:load-wrap")];return(e.id==="dsh-cost-meter"&&S.load===H?.ours&&typeof H.original=="function"?H.original:S.load).call(S,e)})({id:"dsh-cost-meter",chunk:"client.plan-settings.js",factory:ne=>{const{createElement:e,useState:S,useEffect:H,useRef:te,Fragment:R}=ne("react"),J={kimi:{checkedAt:"2026-10-28",sourceUrl:"https://www.kimi.com/code/docs/kimi-code/membership.html",tiers:["Go","Plus","Pro","Max","Ultra"],legacyTiers:["Andante","Moderato","Allegretto","Vivace"],models:["k3.1-pro","k3.1-pro-highspeed","k3","k3-256k","kimi-for-coding","kimi-for-coding-highspeed"],zh:"新套餐:Go、Plus、Pro、Max、Ultra。Plus 起提供 Kimi Code,Pro 起提供高速版和 1M 上下文。新套餐使用 5 小时窗口及月总额度;老套餐保留周窗口。",en:"Current tiers: Go, Plus, Pro, Max and Ultra. Kimi Code starts at Plus; Pro adds Highspeed and 1M context. New plans use a 5-hour window and monthly total; legacy plans retain weekly limits."},minimax:{checkedAt:"2026-10-28",sourceUrl:"https://platform.minimax.io/docs/m-plan/intro",tiers:["Go","Explore","Build"],legacyTiers:["Plus","Max","Ultra"],models:["MiniMax-M3.1-Flash"],zh:"M Plan:Go、Explore、Build,均包含 M3.1 Flash;Explore、Build 另含 H3 视频。原 Token Plan 的 Plus、Max、Ultra 保留。使用现有 MiniMax 查询凭据。",en:"M Plan: Go, Explore and Build, all including M3.1 Flash. Explore and Build also include H3 video. Legacy Token Plan Plus, Max and Ultra remain. Uses the existing MiniMax quota credential."},go:{checkedAt:"2026-10-28",sourceUrl:"https://opencode.ai/v2/docs/console/go/",tiers:["Go","Go Plus"],models:["kimi-k3.1-pro","minimax-m3.1-flash","step-5-preview","gemini-4-argon","beam-free","iceman-contributor-free"],zh:"Go 为 $10/月,Go Plus 为 $40/月。新增 Kimi K3.1 Pro、MiniMax M3.1 Flash 等模型,各模型使用独立的月度额度标准。",en:"Go costs $10/month; Go Plus costs $40/month. Includes Kimi K3.1 Pro, MiniMax M3.1 Flash and other additions, with model-specific monthly allowances."},"tencent-token":{checkedAt:"2026-10-28",sourceUrl:"https://cloud.tencent.com/document/product/1823/130060",tiers:["Lite","Standard","Pro","Max"],products:["Token Plan","Hy Token Plan"],zh:"腾讯通用 Token Plan 与 Hy Token Plan 共用 API Key 和请求地址,按模型从对应套餐扣减积分。当前支持套餐归属统计。",en:"Tencent Token Plan and Hy Token Plan share an API key and endpoints; credits are deducted from the applicable plan for each model. Plan classification is supported."}};return{mount(ie){const{useQuotaRefresh:Q,miniMaxWindowsOf:Y,MiniMaxPlanCard:re,barDirectionOf:z,quotaWindowRow:ue,codingPlanWindowLabel:de,codingPlanWindowEntries:me,numInput:le,CredentialField:se,QuotaCard:oe,resolveLocale:L,formatMoneyUsd:ce,formatBalanceMoney:pe,quotaPlacementValue:ge,quotaPlacementPatch:be,quotaPlacementOptions:he,displayOptions:fe,BalanceBar:ye,segmentsForCustomBalance:ve,customBalanceUnitOf:Ne,customBalanceDetailText:$,formatCustomBalanceMoney:Ce,resolveCustomBalanceLabel:ke}=ie;function we(w){const{state:u,api:P,t:a,entry:n,index:h,canRemove:l,onPatch:f,onRemove:N}=w,T=n.adapter==="aliyun",o=n.adapter==="tokenrhythm",r=n.adapter==="openai-credits",A=T||o||r,[c,p]=S(!1),q=()=>({headers:JSON.stringify(n.request?.headers??{},null,2),extract:JSON.stringify(n.extract??{},null,2),body:typeof n.request?.body=="string"?n.request.body:JSON.stringify(n.request?.body,null,2)??""}),[M,O]=S(q),[B,I]=S(()=>(n.allowedHosts??[]).join(", ")),[U,x]=S({}),C=te(!1),y=u.config,k=(Array.isArray(u.customBalances)?u.customBalances:[]).find(t=>t.index===h)??null,i=n.enabled===!0,v=()=>{p(t=>!t)};H(()=>{c&&!C.current&&(O(q()),I((n.allowedHosts??[]).join(", ")),x({})),C.current=c},[c]);const g=(t,m)=>f({[t]:m}),K=(t,m)=>f({request:{...n.request??{},[t]:m}}),G=T?["ALIBABA_CLOUD_ACCESS_KEY_ID","ALIBABA_CLOUD_ACCESS_KEY_SECRET","ALIBABA_CLOUD_SECURITY_TOKEN"]:o?["TOKENRHYTHM_COOKIE"]:r?["DSH_OPENAI_COST_ADMIN_KEY"]:[...new Set(Object.values(n.request?.headers??{}).flatMap(t=>typeof t=="string"?[...t.matchAll(/\{\{\s*([A-Za-z_][A-Za-z0-9_]*)\s*\}\}/g)].map(m=>m[1]):[]))],Z=(t,m)=>{O(b=>({...b,[t]:m}));try{const b=t==="body",E=b&&!m.trim()?void 0:JSON.parse(m);if(!b&&(E===null||typeof E!="object"||Array.isArray(E)))throw new Error("invalid");if(t==="headers"&&Object.values(E).some(D=>typeof D!="string"))throw new Error("invalid");x(D=>({...D,[t]:""})),t==="extract"?g(t,E):K(t,b?E===void 0?void 0:m:E)}catch{x(b=>({...b,[t]:a("customBalanceInvalidJson")}))}},j=(t,m,b,E)=>!A&&e("div",{className:"cm-field",style:{gridColumn:"1 / -1"}},e("label",null,a(m)),E&&e("span",{className:"cm-hint"},a(E)),e("textarea",{className:"cm-input",rows:b,value:M[t],onChange:D=>Z(t,D.target.value)}),U[t]?e("span",{className:"cm-hint err"},U[t]):null),X=t=>{I(t);const m=t.split(/[\s,;]+/).map(b=>b.trim()).filter(b=>b.length>0);g("allowedHosts",m)},[_,ee,ae]=Q(a,()=>(y.customBalances??[])[h]?.enabled!==!0?Promise.resolve({ok:!1,message:a("quotaEnableFirst")}):P.refreshCustomBalance(h)),s=k!==null&&k.status==="ok"?r?e("div",{className:"cm-bal-line"},$(k,y,a,u,y.customBalances?.[h]??n)):e(R,null,y.balance?.showProgressBar===!0&&!o?e("div",{className:"cm-budget",style:{marginTop:"8px"}},e(ye,{segments:ve(u,y,k,n),direction:z(y,"balance")}),e("div",{className:"cm-bal-line"},$(k,y,a,u,n))):e("div",{className:"cm-bal-line"},T?$(k,y,a,u,n):a("customBalanceRemaining",{amount:Ce(k.remaining,y,k,n)}))):k!==null&&k.status==="error"?e("div",{className:"cm-bal-line err"},k.message||a("unknownError")):e("div",{className:"cm-bal-line"},k?.message||a("balanceNotQueried")),d=e(R,null,e("p",{className:"cm-note"},a(r?"openAiCreditNote":o?"tokenRhythmBalanceNote":T?"aliyunBalanceNote":"customBalanceConfigNote")),!o&&!r&&e("label",{className:"cm-check"},e("input",{type:"checkbox",checked:n.convertToDisplayCurrency===!0,disabled:Ne(y,k,n)!=="USD",onChange:t=>g("convertToDisplayCurrency",t.target.checked)}),a("customBalanceConvert")),!o&&!r&&e("p",{className:"cm-note"},a("customBalanceConvertNote")),e("div",{className:"cm-grid"},r?e(R,null,e("label",{className:"cm-field"},a("openAiCreditAmount"),e("input",{className:"cm-input",type:"number",min:0,step:"0.01",value:n.grantAmount||"",onChange:t=>g("grantAmount",t.target.valueAsNumber||0)})),...[["grantStart","openAiCreditStart"],["grantExpiry","openAiCreditExpiry"]].map(([t,m])=>e("label",{className:"cm-field",key:t},a(m),e("input",{className:"cm-input",type:"date",value:n[t]??"",onChange:b=>g(t,b.target.value)}))),e("a",{href:n.dashboardUrl,target:"_blank",rel:"noopener noreferrer"},a("openAiCreditBilling"))):[["label","customBalanceLabelZh"],["labelEn","customBalanceLabelEn"]].map(([t,m])=>e("div",{key:t,className:"cm-field"},e("label",null,a(m)),e("input",{className:"cm-input",value:n[t]??"",onChange:b=>g(t,b.target.value)}))),!r&&e("label",{className:"cm-field"},e("span",null,L(y)==="en"?"Dashboard link (optional)":"跳转链接(可选)"),e("input",{className:"cm-input",type:"url","aria-label":L(y)==="en"?"Dashboard link":"跳转链接",value:n.dashboardUrl??"",placeholder:"https://example.com/account",onChange:t=>g("dashboardUrl",t.target.value)})),!A&&e("div",{className:"cm-field"},e("label",null,a("customBalanceUnitLabel")),e("select",{className:"cm-input",value:["CNY","EUR","CREDITS"].includes(n.unit)?n.unit:"USD",onChange:t=>g("unit",t.target.value)},e("option",{value:"USD"},"USD ($)"),e("option",{value:"CNY"},"CNY (¥)"),e("option",{value:"EUR"},"EUR (€)"),e("option",{value:"CREDITS"},"CREDITS"))),e("div",{className:"cm-field"},e("label",null,a("customBalanceDisplayLabel")),e("select",{className:"cm-input",value:n.display??"both",onChange:t=>g("display",t.target.value)},...fe(a))),e("div",{className:"cm-field"},e("label",null,a("customBalanceRefreshInterval")),le({value:n.refreshMinutes??15},t=>g("refreshMinutes",Math.min(1440,Math.max(1,Math.floor(t)))))),!A&&e("div",{className:"cm-field"},e("label",null,a("customBalanceMethod")),e("select",{className:"cm-input",value:n.request?.method??"GET",onChange:t=>K("method",t.target.value)},e("option",{value:"GET"},"GET"),e("option",{value:"POST"},"POST"))),!A&&e("div",{className:"cm-field",style:{gridColumn:"1 / -1"}},e("label",null,a("customBalanceUrl")),e("input",{className:"cm-input",value:n.request?.url??"",placeholder:"/plugins/dsh-workbuddy-connect/status",onChange:t=>K("url",t.target.value)}),e("span",{className:"cm-hint"},a("customBalanceUrlHint"))),j("headers","customBalanceHeaders",5,"customBalanceHeadersVarNote"),!["GET","HEAD"].includes((n.request?.method??"GET").toUpperCase())&&j("body","customBalanceBody",5,"customBalanceBodyNote"),e("div",{className:"cm-field",style:{gridColumn:"1 / -1"}},e("label",null,r?"OpenAI Admin API Key":o?"Token Rhythm Cookie":a("customBalanceCredentialsTitle")),G.length>0?e(R,null,!A&&e("span",{className:"cm-hint"},a("customBalanceCredentialsHint")),G.map(t=>e(se,{key:"cb-var-"+t,target:"customVar:"+t,configured:(u.customVarStatus?.[t]?.configured??!1)===!0,source:u.customVarStatus?.[t]?.source??"",t:a,api:P,placeholder:r?"sk-admin-…":o?"tr_session=…":"{{"+t+"}}"}))):e("span",{className:"cm-hint"},a("customBalanceNoPlaceholders"))),!A&&e("div",{className:"cm-field",style:{gridColumn:"1 / -1"}},e("label",null,a("customBalanceAllowedHosts")),e("input",{className:"cm-input",value:B,placeholder:"api.example.com, relay.example.org",onChange:t=>X(t.target.value)}),e("span",{className:"cm-hint"},a("customBalanceAllowedHostsHint"))),!A&&e("label",{className:"cm-check",style:{gridColumn:"1 / -1"}},e("input",{type:"checkbox",checked:n.allowInsecureHttp===!0,onChange:t=>g("allowInsecureHttp",t.target.checked)}),a("customBalanceHttp")),j("extract","customBalanceExtract",8)));return e(oe,{name:`#${h+1} · `+(ke(n,L(y))||a("customBalanceTitle")),enabled:i,saved:JSON.stringify(n)===JSON.stringify(y.customBalances?.[h])?y.customBalances[h]:null,busy:_,open:c,statusNode:s,configNode:d,errorMsg:ee,onToggle:t=>g("enabled",t),onRefresh:ae,onRemove:l?N:null,onToggleOpen:v,t:a})}function V(w){const{state:u,draft:P,setDraft:a,target:n,api:h}=w,l=(i,v)=>L(u.config)==="en"?v:i,f=n.replace(/\.(ak|sk)$/,""),N=f==="balance"?l("当前账号","Current account"):l("查询并显示的账号","Account to query and display"),T=(P??u.config).queryAccounts??{},o=T[f]??{selected:"default",accounts:[]},r=u.config.queryAccounts?.[f]?.selected??"default",[A,c]=S(""),[p,q]=S(!1),[M,O]=S(""),B=o.accounts.find(i=>i.id===o.selected),[I,U]=S(B?.label??"");H(()=>U(B?.label??""),[B?.id,B?.label]);const x=r!==o.selected||P===null||p,C=i=>a({...P,queryAccounts:{...T,[f]:i}}),y=()=>{const i=A.trim();if(!i||o.accounts.length>=10||x)return;if(o.accounts.some(g=>g.label.toLowerCase()===i.toLowerCase())){O(l("账号名称已存在","Account name already exists"));return}const v=crypto.randomUUID();C({selected:v,accounts:[...o.accounts,{id:v,label:i}]}),c(""),O("")},F=()=>{const i=I.trim();if(!(!i||x||!B)){if(o.accounts.some(v=>v.id!==B.id&&v.label.toLowerCase()===i.toLowerCase())){O(l("账号名称已存在","Account name already exists"));return}C({...o,accounts:o.accounts.map(v=>v.id===B.id?{...v,label:i}:v)}),O("")}},k=async()=>{if(!(x||o.selected==="default")){q(!0),O("");try{const i=f==="codingPlans.volcengine"?[f+".ak",f+".sk"]:[f];for(const g of i)await h.clearCredential(g+"@"+o.selected);const v=o.accounts.filter(g=>g.id!==o.selected);C({selected:f==="balance"?v[0]?.id??"default":"default",accounts:v})}catch(i){O(String(i?.message??i))}finally{q(!1)}}};return e("div",{"data-query-account":n},n.endsWith(".sk")?null:e("div",{className:"cm-field"},e("label",null,N,e("select",{className:"cm-input","aria-label":N,value:o.selected,disabled:p||P===null,onChange:i=>C({...o,selected:i.target.value})},e("option",{value:"default"},l("默认账号(现有配置)","Default account (existing configuration)")),...o.accounts.map(i=>e("option",{key:i.id,value:i.id},i.label)))),e("div",{className:"cm-buttons"},e("input",{className:"cm-input",type:"text",value:A,maxLength:64,autoComplete:"off","aria-label":l("新账号名称","New account name"),placeholder:l("如:工作账号","e.g. Work account"),disabled:x,onChange:i=>c(i.target.value),style:{minWidth:0,flex:1}}),e("button",{className:"cm-btn small",type:"button",disabled:x||!A.trim()||o.accounts.length>=10,onClick:y},l("添加账号","Add account")),o.selected!=="default"?e("button",{className:"cm-btn small",type:"button",disabled:x,onClick:k},l("移除账号","Remove account")):null),B?e("div",{className:"cm-buttons"},e("input",{className:"cm-input",value:I,maxLength:64,"aria-label":l("账号名称","Account name"),disabled:x,onChange:i=>U(i.target.value),style:{minWidth:0,flex:1}}),e("button",{className:"cm-btn small",type:"button",disabled:x||!I.trim()||I.trim()===B.label,onClick:F},l("保存名称","Save name"))):null,f==="balance"&&u.balanceAccounts?.length?e("div",{className:"cm-scroll","data-balance-accounts":!0},...u.balanceAccounts.map(i=>e("div",{key:i.id,style:{display:"flex",gap:10,alignItems:"center",padding:"8px 10px"}},e("span",{style:{flex:1,minWidth:0,overflowWrap:"anywhere"}},i.label),e("span",{className:"cm-num",title:i.message||void 0},i.status==="ok"?pe(i.totalBalance,u.config,i.currency):l("查询失败","Query failed")),e("button",{className:"cm-btn small",type:"button",disabled:x||i.id===o.selected,onClick:()=>C({...o,selected:i.id})},i.id===o.selected?l("当前","Current"):l("切换","Use"))))):null,M?e("p",{role:"alert",className:"cm-msg err"},M):null),e(se,{...w,key:n+"@"+o.selected,target:n+"@"+o.selected,disabled:w.disabled||x,configured:!x&&w.configured}))}function Pe({live:w,config:u,setPlan:P,state:a}){const n=(c,p)=>L(a.config)==="en"?p:c,h=w.workbuddy,l=h?.accounts??[],f=u.accountScope??"current",N=new Set(u.accountIds??[]),T=l.filter(c=>f==="all"||(f==="current"?c.current:N.has(c.id))),o=c=>typeof c=="number"&&Number.isFinite(c)?c.toLocaleString(void 0,{maximumFractionDigits:4}):"—",r=c=>T.length&&T.every(p=>typeof p[c]=="number")?T.reduce((p,q)=>p+q[c],0):null,A=c=>Object.entries(c?.byProviderModel??{}).reduce((p,[q,M])=>/^(workbuddy|workbuddy-ai|workbuddy-global|workbuddy-subscription|xdpool|xdpool-global):/.test(q)?p+(M.cost??0):p,0);return e("section",{className:"cm-workbuddy-accounts",style:{minWidth:0}},e("div",{className:"cm-field"},e("label",null,n("积分来源","Credit source")),e("select",{className:"cm-input","aria-label":n("积分来源","Credit source"),value:u.accountSource??"auto",onChange:c=>P("accountSource",c.target.value)},...[["auto",n("自动识别","Automatic")],["connect",n("WorkBuddy 连接插件","WorkBuddy connectors")],["xdpool","dsh-xdpool"]].map(([c,p])=>e("option",{value:c,key:c},p))),e("p",{className:"cm-note"},n("自动识别优先读取连接插件的账号列表,其次读取 XD Pool。两者同时使用时可指定来源。","Automatic uses connector accounts first, then XD Pool. Select a source when using both."))),e("div",{className:"cm-field"},e("label",null,n("统计账号","Accounts to include")),e("select",{className:"cm-input","aria-label":n("统计账号","Accounts to include"),value:f,onChange:c=>P("accountScope",c.target.value)},...[["current",n("当前账号(各区域)","Current account per region")],["all",n("全部账号","All accounts")],["selected",n("勾选账号","Select accounts")]].map(([c,p])=>e("option",{value:c,key:c},p)))),h?.incomplete?e("p",{className:"cm-note",role:"status"},n("部分区域查询失败,当前汇总不完整。","Some regions could not be queried; totals are incomplete.")):null,h?.historyUnavailable?e("p",{className:"cm-note",role:"status"},n("历史统计暂时无法读取,原记录已保留;余额仍可查看。","History is unavailable and has been preserved; balances are still available.")):null,l.length?e("div",{style:{maxHeight:260,overflow:"auto",border:"1px solid var(--dsw-alias-border-l1)",borderRadius:8}},...l.map((c,p)=>e("label",{key:c.id,style:{display:"flex",alignItems:"center",gap:8,padding:"8px 10px",minWidth:0}},e("input",{type:"checkbox",checked:f==="all"||(f==="current"?c.current:N.has(c.id)),disabled:f!=="selected","aria-label":c.name||n("账号 ","Account ")+(p+1),onChange:q=>{const M=new Set(N);q.target.checked?M.add(c.id):M.delete(c.id),P("accountIds",[...M])}}),e("span",{style:{flex:1,minWidth:0,overflowWrap:"anywhere"}},c.name||n("账号 ","Account ")+(p+1),e("small",{style:{display:"block",opacity:.65}},c.region==="cn"?n("国内","CN"):n("国际","Global"))),e("span",{style:{textAlign:"right",flexShrink:0}},o(c.remaining),e("small",{style:{display:"block",opacity:.65}},n("今日减少 ","Decrease today ")+o(c.observedToday)))))):e("p",{className:"cm-note"},n("刷新后显示账号。旧连接插件未提供账号列表时,仍可查看当前账号积分。","Refresh to load accounts. Older connectors can still show current credits without an account list.")),e("div",{style:{display:"grid",gridTemplateColumns:"repeat(2,minmax(0,1fr))",gap:8,marginTop:10}},...[["remaining",n("剩余积分","Credits remaining")],["observedToday",n("今日观测减少","Observed decrease today")],["observedWeek",n("近 7 天观测减少","Observed decrease, 7 days")],["observedTotal",n("启用以来观测减少","Observed decrease since enabled")]].map(([c,p])=>e("div",{key:c,style:{padding:8,borderRadius:6,background:"var(--dsw-alias-bg-layer-1)",minWidth:0,overflowWrap:"anywhere"}},e("small",null,p),e("strong",{style:{display:"block"}},o(h?.incomplete?null:r(c)))))),e("p",{className:"cm-note"},n("从首次成功查询开始记录;充值或赠送不计为减少,积分过期可能计入减少。不是官方扣费账单,积分不折算成人民币。","Recorded from the first successful query. Grants are not decreases; expiry may be. This is not an official charge statement and credits are not converted to currency.")),e("p",{className:"cm-note"},n("全部 WorkBuddy 调用 API 等值:今日 ","API-equivalent value of all WorkBuddy calls: today ")+ce(A(a.today),a.config)+n(";累计 ","; total ")+ce(A(a.total),a.config)+n("。调用记录没有账号标识,此项不随账号筛选。",". Call records have no account identifiers; this value is not filtered by account.")))}function Ae(w){const{state:u,api:P,t:a,draft:n,setDraft:h,planId:l,labelKey:f}=w,N=u.config,T=u.codingPlans??{},o=n?.codingPlans?.[l]??N.codingPlans?.[l]??{},r=T[l]??{status:"off",message:"",fetchedAt:0,windows:{}},A=o.enabled===!0,[c,p]=S(w.targeted===!0),q=l==="qwen"&&N.codingPlans?.qwen?.quotaSource==="bailian"&&o.quotaSource==="bailian"&&r.quotaSource==="bailian"&&r.loginRequired===!0,[M,O,B]=Q(a,()=>q?P.loginCodingPlan(l):P.refreshCodingPlan(l)),[I,U,x]=Q(a,()=>P.loginOpenDesign()),C=(s,d)=>{if(n===null)return;const t=n.codingPlans??N.codingPlans??{};h({...n,codingPlans:{...t,[l]:{...t[l]??{},[s]:d}}})},[y,F]=S(""),[k,i]=S({}),v=s=>s?.rates!==null&&typeof s?.rates=="object"&&!Array.isArray(s.rates)?s.rates:{},g=["input","cachedInput","output"],K=s=>k[s]??v(o)[s]??{},G=s=>g.every(d=>Number.isFinite(Number(s[d]))&&Number(s[d])>0),Z=(s,d,t)=>{if(n===null)return;const m={...K(s),[d]:String(t)};i(W=>({...W,[s]:m}));const b=g.every(W=>String(m[W]??"").trim()==="");if(!b&&!G(m))return;const E=n.codingPlans??N.codingPlans??{},D={...(E.qwen??{}).rates??{}};b?delete D[s]:D[s]=Object.fromEntries(g.map(W=>[W,Number(m[W])])),h({...n,codingPlans:{...E,qwen:{...E.qwen??{},rates:D}}})},j=s=>{n!==null&&i(d=>({...d,[s]:d[s]??v(o)[s]??{}}))},X=s=>{if(n===null)return;i(m=>{const b={...m};return delete b[s],b});const d=n.codingPlans??N.codingPlans??{},t={...(d.qwen??{}).rates??{}};delete t[s],h({...n,codingPlans:{...d,qwen:{...d.qwen??{},rates:t}}})},_=r.windows!==null&&typeof r.windows=="object"?r.windows:{},ee=A===!1?e("p",{className:"cm-note"},L(u.config)==="en"?"Disabled. Enable it to query this vendor's coding plan quota on the refresh interval and show it here.":"未启用。开启后将按刷新间隔查询该厂商的 coding plan 额度并显示在这里。"):r.status==="ok"?e("div",{className:"cm-go-list"},r.message?e("p",{className:"cm-note"},r.message):null,Object.keys(_).length>0?l==="minimax"&&(Y(_).five!=null||Y(_).seven!=null)?e(re,{five:Y(_).five,seven:Y(_).seven,fetchedAt:r.fetchedAt,t:a,wide:!0,direction:z(N,"plan")}):me(_,l).map(([s,d])=>ue(a,de(s,a),d,z(N,"plan"),!1,s)):e("div",{className:"cm-bal-line"},a("codingPlanNotQueried")),e("div",{className:"cm-go-time"},a("goQuotaFetchedAt",{time:r.fetchedAt>0?new Date(r.fetchedAt).toLocaleTimeString():"—"}))):r.status==="error"?e("div",{className:"cm-bal-line err"},r.message||a("unknownError")):r.status==="loading"?e("div",{className:"cm-bal-line"},a("refreshing")):r.status==="off"&&r.message?e("p",{className:"cm-note"},r.message):e("div",{className:"cm-bal-line"},a("codingPlanNotQueried")),ae=e(R,null,J[l]?e("p",{className:"cm-note","data-cm-plan-catalog":l},J[l][L(u.config)==="en"?"en":"zh"]," ",e("a",{href:J[l].sourceUrl,target:"_blank",rel:"noopener noreferrer",style:{whiteSpace:"nowrap"}},L(u.config)==="en"?"Plan details":"套餐详情")):null,l==="opendesign"?e("div",{className:"cm-field"},e("label",null,a("opendesignWorkspace")),e("input",{className:"cm-input","aria-label":a("opendesignWorkspace"),value:o.workspaceId??"",onChange:s=>C("workspaceId",s.target.value)}),e("p",{className:"cm-note"},a("opendesignNote"))):null,l==="opendesign"?e("div",{className:"cm-field"},e("button",{type:"button",className:"cm-btn small","data-cm-action":"opendesign-login",disabled:I,onClick:x},a(I?"loggingIn":"opendesignLogin")),U?e("p",{className:"cm-note"},U.text):null):null,l==="factory"?e(R,null,e("div",{className:"cm-field"},e("label",null,a("factoryPool")),e("select",{className:"cm-input","aria-label":a("factoryPool"),value:o.factoryPool??"standard",onChange:s=>C("factoryPool",s.target.value)},e("option",{value:"standard"},"Standard"),e("option",{value:"core"},"Droid Core"),e("option",{value:"both"},a("factoryPoolBoth")))),e("div",{className:"cm-field"},e("label",null,a("factoryOrg")),e("input",{className:"cm-input","aria-label":a("factoryOrg"),value:o.orgId??"",onChange:s=>C("orgId",s.target.value)}))):null,l==="minimax"?e("div",{className:"cm-field"},e("label",null,a("minimaxOrigin")),e("input",{className:"cm-input",type:"url",value:o.baseUrl??"",placeholder:"https://www.minimax.cn","aria-label":a("minimaxOrigin"),onChange:s=>C("baseUrl",s.target.value)}),e("p",{className:"cm-note"},a("minimaxOriginNote"))):null,l==="qwen"?e("div",{className:"cm-field"},e("label",null,a("qwenSource")),e("select",{className:"cm-input",value:o.quotaSource??"local",onChange:s=>C("quotaSource",s.target.value)},e("option",{value:"local"},a("qwenSourceLocal")),e("option",{value:"cli"},a("qwenSourceCli")),e("option",{value:"bailian"},a("qwenSourceBailian"))),e("p",{className:"cm-note"},a(o.quotaSource==="bailian"?"qwenBailianNote":"qwenCliNote"))):null,e("div",{className:"cm-field"},e("label",null,a("codingPlanDisplayLabel")),e("select",{className:"cm-input","aria-label":a("codingPlanDisplayLabel"),value:ge(o,(n??N).quotaStrip,"plans"),onChange:s=>{if(n===null)return;const d=n.codingPlans??N.codingPlans??{};h({...n,codingPlans:{...d,[l]:{...o,...be(s.target.value)}}})}},...he(a)),e("span",{className:"cm-hint"},L(u.config)==="en"?"Choose the sidebar, settings, the area above the input box, or a combination. Individual placement overrides strip defaults.":"可单独选择侧栏、设置页或输入框上方,也可同时显示。单家位置优先于横条默认设置。")),l!=="scnet"&&(l!=="qwen"||(o.quotaSource??"local")!=="local")?e("div",{className:"cm-field"},e("label",null,a("codingPlanRefreshIntervalLabel")),le({value:typeof o.refreshMinutes=="number"&&Number.isFinite(o.refreshMinutes)&&o.refreshMinutes>0?o.refreshMinutes:15},s=>{C("refreshMinutes",Math.min(1440,Math.max(1,Math.floor(s))))})):null,l==="scnet"||l==="qwen"&&(o.quotaSource??"local")==="local"?e(R,null,e("div",{className:"cm-field"},e("label",null,a(l==="qwen"?"qwenPlanCreditsLabel":"scnetPlanCreditsLabel")),e("input",{className:"cm-input",type:"number",min:"1",step:"1000",value:typeof o.planCredits=="number"&&Number.isFinite(o.planCredits)&&o.planCredits>0?o.planCredits:l==="qwen"?5e5:24e4,onChange:s=>{const d=Number(s.target.value);Number.isFinite(d)&&d>0&&C("planCredits",Math.floor(d))}})),e("div",{className:"cm-field"},e("label",null,a(l==="qwen"?"qwenPlanStartLabel":"scnetPlanStartLabel")),e("input",{className:"cm-input",type:"date",value:typeof o.planStart=="string"?o.planStart:"",onChange:s=>C("planStart",s.target.value)})),l==="qwen"?e(R,null,e("div",{className:"cm-field"},e("label",null,a("qwenRatesLabel"))),[...new Set([...Object.keys(v(o)),...Object.keys(k)])].sort().map(s=>e("div",{key:s,className:"cm-match-row"},e("span",{style:{minWidth:"120px"}},s),g.map(d=>e("input",{key:d,className:"cm-input narrow",type:"number",min:"0",step:"0.1",value:K(s)[d]??"",placeholder:a("qwenRate_"+d),"aria-label":s+" · "+a("qwenRate_"+d),onChange:t=>{const m=t.target.value;Z(s,d,m)}})),e("button",{className:"cm-btn small",onClick:()=>X(s)},a("overrideRemove")),s in k&&!G(K(s))?e("span",{className:"cm-note"},a("qwenRateDraftNote")):null)),e("div",{className:"cm-buttons"},e("input",{className:"cm-input narrow",type:"text",placeholder:a("qwenRatesModelPlaceholder"),value:y,onChange:s=>F(s.target.value)}),e("button",{className:"cm-btn small",onClick:()=>{const s=y.trim();s.length!==0&&(j(s),F(""))},disabled:y.trim().length===0},a("qwenRatesAdd")))):null,e("p",{className:"cm-note"},a(l==="qwen"?"qwenLocalNote":"scnetLocalNote"))):l==="qwen"?null:l==="volcengine"?e(R,null,e("div",{className:"cm-field"},e("label",null,a("volcengineAccessKeyIdLabel"))),e(V,{state:u,draft:n,setDraft:h,target:"codingPlans.volcengine.ak",configured:r.keyConfigured===!0,source:r.keySource,t:a,api:P,placeholder:a("volcengineAccessKeyPlaceholder")}),e("div",{className:"cm-field"},e("label",null,a("volcengineSecretAccessKeyLabel"))),e(V,{state:u,draft:n,setDraft:h,target:"codingPlans.volcengine.sk",configured:r.keyConfigured===!0,source:r.keySource,t:a,api:P,placeholder:a("volcengineSecretPlaceholder")}),e("p",{className:"cm-note"},L(u.config)==="en"?"Volcano Ark needs AK/SK, ArkReadOnlyAccess and BillingCenterReadOnlyAccess. Enter credentials or export VOLC_ACCESSKEY/VOLC_SECRETKEY. Only open.volcengineapi.com is contacted.":"火山方舟需 AK/SK、ArkReadOnlyAccess 和 BillingCenterReadOnlyAccess;可填凭据或导出 VOLC_ACCESSKEY/VOLC_SECRETKEY。只连接 open.volcengineapi.com。")):l==="workbuddy"?e(R,null,e("p",{className:"cm-note"},a("wbH")),e(Pe,{live:r,config:o,setPlan:C,state:u})):e(R,null,e("div",{className:"cm-field"},e("label",null,l==="baidu-coding"?"Cookie (console.bce.baidu.com)":l==="mimo"?"Cookie (platform.xiaomimimo.com)":l==="factory"?"Factory Token":l==="opendesign"?"OpenDesign Cookie / Control Key":a(l==="zai"?"zaiPlanKeyLabel":"codingPlanKeyLabel"))),e(V,{state:u,draft:n,setDraft:h,target:"codingPlans."+l,configured:r.keyConfigured===!0,source:r.keySource,t:a,api:P,placeholder:l==="baidu-coding"?"BAIDU_QIANFAN_COOKIE":l==="mimo"?"api-platform_serviceToken=…; userId=…":l==="factory"?"FACTORY_API_KEY":l==="opendesign"?"Cookie: name=value; … / vela_ctrl_…":"sk-…"}),l==="baidu-coding"?e("p",{className:"cm-note"},L(u.config)==="en"?"Sign in at console.bce.baidu.com, open Token Plan → browser Network → tokenPlanPersonal/resource, and copy the full Cookie request header. Supports Personal credits and Tokens; excludes add-on packs. API keys cannot query quotas.":"登录 console.bce.baidu.com,打开 Token Plan 页面,在浏览器网络面板找到 tokenPlanPersonal/resource,复制完整 Cookie 请求头。支持个人版积分制与 Token 制套餐,不含加油包;API Key 不用于额度查询。"):null));return e(oe,{planId:l,targeted:w.targeted,name:a(f),enabled:A,saved:N.codingPlans?.[l],busy:M,open:c,errorMsg:O?.text===r.message?null:O,statusNode:ee,configNode:ae,onToggle:s=>C("enabled",s),onRefresh:B,onLogin:B,loginRequired:q,onToggleOpen:()=>p(s=>!s),t:a})}return w=>w.mode==="credential"?e(V,w):w.mode==="custom-balance"?e(we,w):e(Ae,w)}}}});
1
+ ;(function(e){const w=window.__ModuleLoader__,G=w[Symbol.for("@dsh-plugin/dsh-loader:load-wrap")];return(e.id==="dsh-cost-meter"&&w.load===G?.ours&&typeof G.original=="function"?G.original:w.load).call(w,e)})({id:"dsh-cost-meter",chunk:"client.plan-settings.js",factory:le=>{const{createElement:e,useState:w,useEffect:G,useRef:se,Fragment:O}=le("react"),X={kimi:{checkedAt:"2026-10-28",sourceUrl:"https://www.kimi.com/code/docs/kimi-code/membership.html",tiers:["Go","Plus","Pro","Max","Ultra"],legacyTiers:["Andante","Moderato","Allegretto","Vivace"],models:["k3.1-pro","k3.1-pro-highspeed","k3","k3-256k","kimi-for-coding","kimi-for-coding-highspeed"],zh:"新套餐:Go、Plus、Pro、Max、Ultra。Plus 起提供 Kimi Code,Pro 起提供高速版和 1M 上下文。新套餐使用 5 小时窗口及月总额度;老套餐保留周窗口。",en:"Current tiers: Go, Plus, Pro, Max and Ultra. Kimi Code starts at Plus; Pro adds Highspeed and 1M context. New plans use a 5-hour window and monthly total; legacy plans retain weekly limits."},minimax:{checkedAt:"2026-10-28",sourceUrl:"https://platform.minimax.io/docs/m-plan/intro",tiers:["Go","Explore","Build"],legacyTiers:["Plus","Max","Ultra"],models:["MiniMax-M3.1-Flash"],zh:"M Plan:Go、Explore、Build,均包含 M3.1 Flash;Explore、Build 另含 H3 视频。原 Token Plan 的 Plus、Max、Ultra 保留。使用现有 MiniMax 查询凭据。",en:"M Plan: Go, Explore and Build, all including M3.1 Flash. Explore and Build also include H3 video. Legacy Token Plan Plus, Max and Ultra remain. Uses the existing MiniMax quota credential."},go:{checkedAt:"2026-10-28",sourceUrl:"https://opencode.ai/v2/docs/console/go/",tiers:["Go","Go Plus"],models:["kimi-k3.1-pro","minimax-m3.1-flash","step-5-preview","gemini-4-argon","beam-free","iceman-contributor-free"],zh:"Go 为 $10/月,Go Plus 为 $40/月。新增 Kimi K3.1 Pro、MiniMax M3.1 Flash 等模型,各模型使用独立的月度额度标准。",en:"Go costs $10/month; Go Plus costs $40/month. Includes Kimi K3.1 Pro, MiniMax M3.1 Flash and other additions, with model-specific monthly allowances."},"tencent-token":{checkedAt:"2026-10-28",sourceUrl:"https://cloud.tencent.com/document/product/1823/130060",tiers:["Lite","Standard","Pro","Max"],products:["Token Plan","Hy Token Plan"],zh:"腾讯通用 Token Plan 与 Hy Token Plan 共用 API Key 和请求地址,按模型从对应套餐扣减积分。当前支持套餐归属统计。",en:"Tencent Token Plan and Hy Token Plan share an API key and endpoints; credits are deducted from the applicable plan for each model. Plan classification is supported."}};return{mount(ue){const{useQuotaRefresh:ee,miniMaxWindowsOf:Q,MiniMaxPlanCard:de,barDirectionOf:ae,quotaWindowRow:me,codingPlanWindowLabel:pe,codingPlanWindowEntries:ge,numInput:oe,CredentialField:ce,QuotaCard:ie,resolveLocale:q,formatMoneyUsd:re,formatBalanceMoney:be,quotaPlacementValue:he,quotaPlacementPatch:fe,quotaPlacementOptions:ye,displayOptions:ve,BalanceBar:Ne,segmentsForCustomBalance:ke,customBalanceUnitOf:Ce,customBalanceDetailText:ne,formatCustomBalanceMoney:we,resolveCustomBalanceLabel:Pe}=ue;function Ae(f){const{state:u,api:C,t:a,entry:n,index:y,canRemove:s,onPatch:h,onRemove:N}=f,B=n.adapter==="aliyun",o=n.adapter==="tokenrhythm",r=n.adapter==="openai-credits",T=n.adapter==="fireworks",i=B||o||r,[m,E]=w(!1),M=()=>({headers:JSON.stringify(n.request?.headers??{},null,2),extract:JSON.stringify(n.extract??{},null,2),body:typeof n.request?.body=="string"?n.request.body:JSON.stringify(n.request?.body,null,2)??""}),[R,A]=w(M),[D,U]=w(()=>(n.channels??[]).join(", ")),[S,v]=w(()=>(n.allowedHosts??[]).join(", ")),[_,K]=w({}),F=se(!1),c=u.config,p=(Array.isArray(u.customBalances)?u.customBalances:[]).find(t=>t.index===y)??null,j=n.enabled===!0,$=()=>{E(t=>!t)};G(()=>{m&&!F.current&&(U((n.channels??[]).join(", ")),A(M()),v((n.allowedHosts??[]).join(", ")),K({})),F.current=m},[m]);const x=(t,g)=>h({[t]:g}),Y=(t,g)=>h({request:{...n.request??{},[t]:g}}),Z=B?["ALIBABA_CLOUD_ACCESS_KEY_ID","ALIBABA_CLOUD_ACCESS_KEY_SECRET","ALIBABA_CLOUD_SECURITY_TOKEN"]:o?["TOKENRHYTHM_COOKIE"]:r?["DSH_OPENAI_COST_ADMIN_KEY"]:[...new Set(Object.values(n.request?.headers??{}).flatMap(t=>typeof t=="string"?[...t.matchAll(/\{\{\s*([A-Za-z_][A-Za-z0-9_]*)\s*\}\}/g)].map(g=>g[1]):[]))],H=(t,g)=>{A(b=>({...b,[t]:g}));try{const b=t==="body",I=b&&!g.trim()?void 0:JSON.parse(g);if(!b&&(I===null||typeof I!="object"||Array.isArray(I)))throw new Error("invalid");if(t==="headers"&&Object.values(I).some(V=>typeof V!="string"))throw new Error("invalid");K(V=>({...V,[t]:""})),t==="extract"?x(t,I):Y(t,b?I===void 0?void 0:g:I)}catch{K(b=>({...b,[t]:a("customBalanceInvalidJson")}))}},J=(t,g,b,I)=>!i&&e("div",{className:"cm-field",style:{gridColumn:"1 / -1"}},e("label",null,a(g)),I&&e("span",{className:"cm-hint"},a(I)),e("textarea",{className:"cm-input",rows:b,value:R[t],onChange:V=>H(t,V.target.value)}),_[t]?e("span",{className:"cm-hint err"},_[t]):null),te=t=>{v(t);const g=t.split(/[\s,;]+/).map(b=>b.trim()).filter(b=>b.length>0);x("allowedHosts",g)},[l,d,L]=ee(a,()=>(c.customBalances??[])[y]?.enabled!==!0?Promise.resolve({ok:!1,message:a("quotaEnableFirst")}):C.refreshCustomBalance(y)),P=p!==null&&p.status==="ok"?r?e("div",{className:"cm-bal-line"},ne(p,c,a,u,c.customBalances?.[y]??n)):e(O,null,c.balance?.showProgressBar===!0&&!o?e("div",{className:"cm-budget",style:{marginTop:"8px"}},e(Ne,{segments:ke(u,c,p,n),direction:ae(c,"balance")}),e("div",{className:"cm-bal-line"},ne(p,c,a,u,n))):e("div",{className:"cm-bal-line"},B?ne(p,c,a,u,n):a("customBalanceRemaining",{amount:we(p.remaining,c,p,n)}))):p!==null&&p.status==="error"?e("div",{className:"cm-bal-line err"},p.message||a("unknownError")):e("div",{className:"cm-bal-line"},p?.message||a("balanceNotQueried")),W=e(O,null,e("p",{className:"cm-note"},a(r?"openAiCreditNote":o?"tokenRhythmBalanceNote":B?"aliyunBalanceNote":"customBalanceConfigNote")),T&&e("p",{className:"cm-note"},q(c)==="en"?"Fireworks documents usage costs. For remaining credit, enter your trusted HTTPS balance endpoint, its hostname and the JSON field containing the balance. You can also check your account in the billing console.":"Fireworks 公开接口提供账单用量。查询剩余余额请填写可信的 HTTPS 余额接口、对应主机名和余额字段,也可前往账单控制台查看。"," ",e("a",{href:"https://app.fireworks.ai/account/billing",target:"_blank",rel:"noopener noreferrer"},"Fireworks.ai ↗")),!o&&!r&&e("label",{className:"cm-check"},e("input",{type:"checkbox",checked:n.convertToDisplayCurrency===!0,disabled:Ce(c,p,n)!=="USD",onChange:t=>x("convertToDisplayCurrency",t.target.checked)}),a("customBalanceConvert")),!o&&!r&&e("p",{className:"cm-note"},a("customBalanceConvertNote")),e("div",{className:"cm-grid"},r?e(O,null,e("label",{className:"cm-field"},a("openAiCreditAmount"),e("input",{className:"cm-input",type:"number",min:0,step:"0.01",value:n.grantAmount||"",onChange:t=>x("grantAmount",t.target.valueAsNumber||0)})),...[["grantStart","openAiCreditStart"],["grantExpiry","openAiCreditExpiry"]].map(([t,g])=>e("label",{className:"cm-field",key:t},a(g),e("input",{className:"cm-input",type:"date",value:n[t]??"",onChange:b=>x(t,b.target.value)}))),e("a",{href:n.dashboardUrl,target:"_blank",rel:"noopener noreferrer"},a("openAiCreditBilling"))):[["label","customBalanceLabelZh"],["labelEn","customBalanceLabelEn"]].map(([t,g])=>e("div",{key:t,className:"cm-field"},e("label",null,a(g)),e("input",{className:"cm-input",value:n[t]??"",onChange:b=>x(t,b.target.value)}))),!o&&!r&&e("label",{className:"cm-field"},q(c)==="en"?"Providers for today’s spend (optional)":"当日已用的归属渠道(可选)",e("input",{className:"cm-input",value:D,placeholder:"cc-switch-apikey-fun",onChange:t=>{const g=t.target.value;U(g),x("channels",g.split(/[\s,,]+/).filter(Boolean))}})),!r&&e("label",{className:"cm-field"},e("span",null,q(c)==="en"?"Dashboard link (optional)":"跳转链接(可选)"),e("input",{className:"cm-input",type:"url","aria-label":q(c)==="en"?"Dashboard link":"跳转链接",value:n.dashboardUrl??"",placeholder:"https://example.com/account",onChange:t=>x("dashboardUrl",t.target.value)})),!i&&e("div",{className:"cm-field"},e("label",null,a("customBalanceUnitLabel")),e("select",{className:"cm-input",value:["CNY","EUR","CREDITS"].includes(n.unit)?n.unit:"USD",onChange:t=>x("unit",t.target.value)},e("option",{value:"USD"},"USD ($)"),e("option",{value:"CNY"},"CNY (¥)"),e("option",{value:"EUR"},"EUR (€)"),e("option",{value:"CREDITS"},"CREDITS"))),e("div",{className:"cm-field"},e("label",null,a("customBalanceDisplayLabel")),e("select",{className:"cm-input",value:n.display??"both",onChange:t=>x("display",t.target.value)},...ve(a))),e("div",{className:"cm-field"},e("label",null,a("customBalanceRefreshInterval")),oe({value:n.refreshMinutes??15},t=>x("refreshMinutes",Math.min(1440,Math.max(1,Math.floor(t)))))),!i&&e("div",{className:"cm-field"},e("label",null,a("customBalanceMethod")),e("select",{className:"cm-input",value:n.request?.method??"GET",onChange:t=>Y("method",t.target.value)},e("option",{value:"GET"},"GET"),e("option",{value:"POST"},"POST"))),!i&&e("div",{className:"cm-field",style:{gridColumn:"1 / -1"}},e("label",null,a("customBalanceUrl")),e("input",{className:"cm-input",value:n.request?.url??"",placeholder:T?"https://…":"/plugins/dsh-workbuddy-connect/status",onChange:t=>Y("url",t.target.value)}),e("span",{className:"cm-hint"},a("customBalanceUrlHint"))),J("headers","customBalanceHeaders",5,"customBalanceHeadersVarNote"),!["GET","HEAD"].includes((n.request?.method??"GET").toUpperCase())&&J("body","customBalanceBody",5,"customBalanceBodyNote"),e("div",{className:"cm-field",style:{gridColumn:"1 / -1"}},e("label",null,r?"OpenAI Admin API Key":o?"Token Rhythm Cookie":a("customBalanceCredentialsTitle")),Z.length>0?e(O,null,!i&&e("span",{className:"cm-hint"},a("customBalanceCredentialsHint")),Z.map(t=>e(ce,{key:"cb-var-"+t,target:"customVar:"+t,configured:(u.customVarStatus?.[t]?.configured??!1)===!0,source:u.customVarStatus?.[t]?.source??"",t:a,api:C,placeholder:r?"sk-admin-…":o?"tr_session=…":"{{"+t+"}}"}))):e("span",{className:"cm-hint"},a("customBalanceNoPlaceholders"))),!i&&e("div",{className:"cm-field",style:{gridColumn:"1 / -1"}},e("label",null,a("customBalanceAllowedHosts")),e("input",{className:"cm-input",value:S,placeholder:"api.example.com, relay.example.org",onChange:t=>te(t.target.value)}),e("span",{className:"cm-hint"},a("customBalanceAllowedHostsHint"))),!i&&!T&&e("label",{className:"cm-check",style:{gridColumn:"1 / -1"}},e("input",{type:"checkbox",checked:n.allowInsecureHttp===!0,onChange:t=>x("allowInsecureHttp",t.target.checked)}),a("customBalanceHttp")),J("extract","customBalanceExtract",8)));return e(ie,{display:f.sidebarHidden?"settings":n.display,onSidebar:t=>h({display:t},t==="both"),name:`#${y+1} · `+(Pe(n,q(c))||a("customBalanceTitle")),enabled:j,saved:JSON.stringify(n)===JSON.stringify(c.customBalances?.[y])?c.customBalances[y]:null,busy:l,open:m,statusNode:e(O,null,P,p?.status==="ok"&&p.fetchedAt>0&&e("span",{className:"cm-hint"},a("gatewaySourceFetchedAt",{time:new Date(p.fetchedAt).toLocaleString()}))),configNode:W,errorMsg:d,onToggle:t=>x("enabled",t),onRefresh:L,onRemove:s?N:null,onToggleOpen:$,t:a})}function z(f){const{state:u,draft:C,setDraft:a,target:n,api:y}=f,s=(c,k)=>q(u.config)==="en"?k:c,h=n.replace(/\.(ak|sk)$/,""),N=h==="balance"?s("当前账号","Current account"):s("查询并显示的账号","Account to query and display"),B=(C??u.config).queryAccounts??{},o=B[h]??{selected:"default",accounts:[]},r=u.config.queryAccounts?.[h]?.selected??"default",[T,i]=w(""),[m,E]=w(!1),[M,R]=w(""),A=o.accounts.find(c=>c.id===o.selected),[D,U]=w(A?.label??"");G(()=>U(A?.label??""),[A?.id,A?.label]);const S=r!==o.selected||C===null||m,v=c=>a({...C,queryAccounts:{...B,[h]:c}}),_=()=>{const c=T.trim();if(!c||o.accounts.length>=10||S)return;if(o.accounts.some(p=>p.label.toLowerCase()===c.toLowerCase())){R(s("账号名称已存在","Account name already exists"));return}const k=crypto.randomUUID();v({selected:k,accounts:[...o.accounts,{id:k,label:c}]}),i(""),R("")},K=()=>{const c=D.trim();if(!(!c||S||!A)){if(o.accounts.some(k=>k.id!==A.id&&k.label.toLowerCase()===c.toLowerCase())){R(s("账号名称已存在","Account name already exists"));return}v({...o,accounts:o.accounts.map(k=>k.id===A.id?{...k,label:c}:k)}),R("")}},F=async()=>{if(!(S||o.selected==="default")){E(!0),R("");try{const c=h==="codingPlans.volcengine"?[h+".ak",h+".sk"]:[h];for(const p of c)await y.clearCredential(p+"@"+o.selected);const k=o.accounts.filter(p=>p.id!==o.selected);v({selected:h==="balance"?k[0]?.id??"default":"default",accounts:k})}catch(c){R(String(c?.message??c))}finally{E(!1)}}};return e("div",{"data-query-account":n},n.endsWith(".sk")?null:e("div",{className:"cm-field"},e("label",null,N,e("select",{className:"cm-input","aria-label":N,value:o.selected,disabled:m||C===null,onChange:c=>v({...o,selected:c.target.value})},e("option",{value:"default"},s("默认账号(现有配置)","Default account (existing configuration)")),...o.accounts.map(c=>e("option",{key:c.id,value:c.id},c.label)))),e("div",{className:"cm-buttons"},e("input",{className:"cm-input",type:"text",value:T,maxLength:64,autoComplete:"off","aria-label":s("新账号名称","New account name"),placeholder:s("如:工作账号","e.g. Work account"),disabled:S,onChange:c=>i(c.target.value),style:{minWidth:0,flex:1}}),e("button",{className:"cm-btn small",type:"button",disabled:S||!T.trim()||o.accounts.length>=10,onClick:_},s("添加账号","Add account")),o.selected!=="default"?e("button",{className:"cm-btn small",type:"button",disabled:S,onClick:F},s("移除账号","Remove account")):null),A?e("div",{className:"cm-buttons"},e("input",{className:"cm-input",value:D,maxLength:64,"aria-label":s("账号名称","Account name"),disabled:S,onChange:c=>U(c.target.value),style:{minWidth:0,flex:1}}),e("button",{className:"cm-btn small",type:"button",disabled:S||!D.trim()||D.trim()===A.label,onClick:K},s("保存名称","Save name"))):null,h==="balance"&&u.balanceAccounts?.length?e("div",{className:"cm-scroll","data-balance-accounts":!0},...u.balanceAccounts.map(c=>e("div",{key:c.id,style:{display:"flex",gap:10,alignItems:"center",padding:"8px 10px"}},e("span",{style:{flex:1,minWidth:0,overflowWrap:"anywhere"}},c.label),e("span",{className:"cm-num",title:c.message||void 0},c.status==="ok"?be(c.totalBalance,u.config,c.currency):s("查询失败","Query failed")),e("button",{className:"cm-btn small",type:"button",disabled:S||c.id===o.selected,onClick:()=>v({...o,selected:c.id})},c.id===o.selected?s("当前","Current"):s("切换","Use"))))):null,M?e("p",{role:"alert",className:"cm-msg err"},M):null),e(ce,{...f,key:n+"@"+o.selected,target:n+"@"+o.selected,disabled:f.disabled||S,configured:!S&&f.configured}))}function Se({live:f,config:u,setPlan:C,state:a}){const n=(i,m)=>q(a.config)==="en"?m:i,y=f.workbuddy,s=y?.accounts??[],h=u.accountScope??"current",N=new Set(u.accountIds??[]),B=s.filter(i=>h==="all"||(h==="current"?i.current:N.has(i.id))),o=i=>typeof i=="number"&&Number.isFinite(i)?i.toLocaleString(void 0,{maximumFractionDigits:4}):"—",r=i=>B.length&&B.every(m=>typeof m[i]=="number")?B.reduce((m,E)=>m+E[i],0):null,T=i=>Object.entries(i?.byProviderModel??{}).reduce((m,[E,M])=>/^(workbuddy|workbuddy-ai|workbuddy-global|workbuddy-subscription|xdpool|xdpool-global):/.test(E)?m+(M.cost??0):m,0);return e("section",{className:"cm-workbuddy-accounts",style:{minWidth:0}},e("div",{className:"cm-field"},e("label",null,n("积分来源","Credit source")),e("select",{className:"cm-input","aria-label":n("积分来源","Credit source"),value:u.accountSource??"auto",onChange:i=>C("accountSource",i.target.value)},...[["auto",n("自动识别","Automatic")],["connect",n("WorkBuddy 连接插件","WorkBuddy connectors")],["xdpool","dsh-xdpool"]].map(([i,m])=>e("option",{value:i,key:i},m))),e("p",{className:"cm-note"},n("自动识别优先读取连接插件的账号列表,其次读取 XD Pool。两者同时使用时可指定来源。","Automatic uses connector accounts first, then XD Pool. Select a source when using both."))),e("div",{className:"cm-field"},e("label",null,n("统计账号","Accounts to include")),e("select",{className:"cm-input","aria-label":n("统计账号","Accounts to include"),value:h,onChange:i=>C("accountScope",i.target.value)},...[["current",n("当前账号(各区域)","Current account per region")],["all",n("全部账号","All accounts")],["selected",n("勾选账号","Select accounts")]].map(([i,m])=>e("option",{value:i,key:i},m)))),y?.incomplete?e("p",{className:"cm-note",role:"status"},n("部分区域查询失败,当前汇总不完整。","Some regions could not be queried; totals are incomplete.")):null,y?.historyUnavailable?e("p",{className:"cm-note",role:"status"},n("历史统计暂时无法读取,原记录已保留;余额仍可查看。","History is unavailable and has been preserved; balances are still available.")):null,s.length?e("div",{style:{maxHeight:260,overflow:"auto",border:"1px solid var(--dsw-alias-border-l1)",borderRadius:8}},...s.map((i,m)=>e("label",{key:i.id,style:{display:"flex",alignItems:"center",gap:8,padding:"8px 10px",minWidth:0}},e("input",{type:"checkbox",checked:h==="all"||(h==="current"?i.current:N.has(i.id)),disabled:h!=="selected","aria-label":i.name||n("账号 ","Account ")+(m+1),onChange:E=>{const M=new Set(N);E.target.checked?M.add(i.id):M.delete(i.id),C("accountIds",[...M])}}),e("span",{style:{flex:1,minWidth:0,overflowWrap:"anywhere"}},i.name||n("账号 ","Account ")+(m+1),e("small",{style:{display:"block",opacity:.65}},i.region==="cn"?n("国内","CN"):n("国际","Global"))),e("span",{style:{textAlign:"right",flexShrink:0}},o(i.remaining),e("small",{style:{display:"block",opacity:.65}},n("今日减少 ","Decrease today ")+o(i.observedToday)))))):e("p",{className:"cm-note"},n("刷新后显示账号。旧连接插件未提供账号列表时,仍可查看当前账号积分。","Refresh to load accounts. Older connectors can still show current credits without an account list.")),e("div",{style:{display:"grid",gridTemplateColumns:"repeat(2,minmax(0,1fr))",gap:8,marginTop:10}},...[["remaining",n("剩余积分","Credits remaining")],["observedToday",n("今日观测减少","Observed decrease today")],["observedWeek",n("近 7 天观测减少","Observed decrease, 7 days")],["observedTotal",n("启用以来观测减少","Observed decrease since enabled")]].map(([i,m])=>e("div",{key:i,style:{padding:8,borderRadius:6,background:"var(--dsw-alias-bg-layer-1)",minWidth:0,overflowWrap:"anywhere"}},e("small",null,m),e("strong",{style:{display:"block"}},o(y?.incomplete?null:r(i)))))),e("p",{className:"cm-note"},n("从首次成功查询开始记录;充值或赠送不计为减少,积分过期可能计入减少。不是官方扣费账单,积分不折算成人民币。","Recorded from the first successful query. Grants are not decreases; expiry may be. This is not an official charge statement and credits are not converted to currency.")),e("p",{className:"cm-note"},n("全部 WorkBuddy 调用 API 等值:今日 ","API-equivalent value of all WorkBuddy calls: today ")+re(T(a.today),a.config)+n(";累计 ","; total ")+re(T(a.total),a.config)+n("。调用记录没有账号标识,此项不随账号筛选。",". Call records have no account identifiers; this value is not filtered by account.")))}function xe(f){const{state:u,api:C,t:a,draft:n,setDraft:y,planId:s,labelKey:h}=f,N=u.config,B=u.codingPlans??{},o=n?.codingPlans?.[s]??N.codingPlans?.[s]??{},r=B[s]??{status:"off",message:"",fetchedAt:0,windows:{}},T=o.enabled===!0,[i,m]=w(f.targeted===!0),E=s==="qwen"&&N.codingPlans?.qwen?.quotaSource==="bailian"&&o.quotaSource==="bailian"&&r.quotaSource==="bailian"&&r.loginRequired===!0,[M,R,A]=ee(a,()=>E?C.loginCodingPlan(s):C.refreshCodingPlan(s)),[D,U,S]=ee(a,()=>C.loginOpenDesign()),v=(l,d)=>{if(n===null)return;const L=n.codingPlans??N.codingPlans??{},P={...L[s]??{},[l]:d};l==="display"&&(P.sidebarAfterSuccess=!1),l==="enabled"&&d&&P.sidebarAfterSuccess===void 0&&(P.display??"settings")==="settings"&&(P.display="both",P.sidebarAfterSuccess=!0),y({...n,codingPlans:{...L,[s]:P}})},[_,K]=w(""),[F,c]=w({}),k=l=>l?.rates!==null&&typeof l?.rates=="object"&&!Array.isArray(l.rates)?l.rates:{},p=["input","cachedInput","output"],j=l=>F[l]??k(o)[l]??{},$=l=>p.every(d=>Number.isFinite(Number(l[d]))&&Number(l[d])>0),x=(l,d,L)=>{if(n===null)return;const P={...j(l),[d]:String(L)};c(b=>({...b,[l]:P}));const W=p.every(b=>String(P[b]??"").trim()==="");if(!W&&!$(P))return;const t=n.codingPlans??N.codingPlans??{},g={...(t.qwen??{}).rates??{}};W?delete g[l]:g[l]=Object.fromEntries(p.map(b=>[b,Number(P[b])])),y({...n,codingPlans:{...t,qwen:{...t.qwen??{},rates:g}}})},Y=l=>{n!==null&&c(d=>({...d,[l]:d[l]??k(o)[l]??{}}))},Z=l=>{if(n===null)return;c(P=>{const W={...P};return delete W[l],W});const d=n.codingPlans??N.codingPlans??{},L={...(d.qwen??{}).rates??{}};delete L[l],y({...n,codingPlans:{...d,qwen:{...d.qwen??{},rates:L}}})},H=r.windows!==null&&typeof r.windows=="object"?r.windows:{},J=T===!1?e("p",{className:"cm-note"},q(u.config)==="en"?"Disabled. Enable it to query this vendor's coding plan quota on the refresh interval and show it here.":"未启用。开启后将按刷新间隔查询该厂商的 coding plan 额度并显示在这里。"):r.status==="ok"?e("div",{className:"cm-go-list"},r.message?e("p",{className:"cm-note"},r.message):null,Object.keys(H).length>0?s==="minimax"&&(Q(H).five!=null||Q(H).seven!=null)?e(de,{five:Q(H).five,seven:Q(H).seven,fetchedAt:r.fetchedAt,t:a,wide:!0,direction:ae(N,"plan")}):ge(H,s).map(([l,d])=>me(a,pe(l,a),d,ae(N,"plan"),!1,l)):e("div",{className:"cm-bal-line"},a("codingPlanNotQueried")),e("div",{className:"cm-go-time"},a("goQuotaFetchedAt",{time:r.fetchedAt>0?new Date(r.fetchedAt).toLocaleTimeString():"—"}))):r.status==="error"?e("div",{className:"cm-bal-line err"},r.message||a("unknownError")):r.status==="loading"?e("div",{className:"cm-bal-line"},a("refreshing")):r.status==="off"&&r.message?e("p",{className:"cm-note"},r.message):e("div",{className:"cm-bal-line"},a("codingPlanNotQueried")),te=e(O,null,X[s]?e("p",{className:"cm-note","data-cm-plan-catalog":s},X[s][q(u.config)==="en"?"en":"zh"]," ",e("a",{href:X[s].sourceUrl,target:"_blank",rel:"noopener noreferrer",style:{whiteSpace:"nowrap"}},q(u.config)==="en"?"Plan details":"套餐详情")):null,s==="opendesign"?e("div",{className:"cm-field"},e("label",null,a("opendesignWorkspace")),e("input",{className:"cm-input","aria-label":a("opendesignWorkspace"),value:o.workspaceId??"",onChange:l=>v("workspaceId",l.target.value)}),e("p",{className:"cm-note"},a("opendesignNote"))):null,s==="opendesign"?e("div",{className:"cm-field"},e("button",{type:"button",className:"cm-btn small","data-cm-action":"opendesign-login",disabled:D,onClick:S},a(D?"loggingIn":"opendesignLogin")),U?e("p",{className:"cm-note"},U.text):null):null,s==="factory"?e(O,null,e("div",{className:"cm-field"},e("label",null,a("factoryPool")),e("select",{className:"cm-input","aria-label":a("factoryPool"),value:o.factoryPool??"standard",onChange:l=>v("factoryPool",l.target.value)},e("option",{value:"standard"},"Standard"),e("option",{value:"core"},"Droid Core"),e("option",{value:"both"},a("factoryPoolBoth")))),e("div",{className:"cm-field"},e("label",null,a("factoryOrg")),e("input",{className:"cm-input","aria-label":a("factoryOrg"),value:o.orgId??"",onChange:l=>v("orgId",l.target.value)}))):null,s==="minimax"?e("div",{className:"cm-field"},e("label",null,a("minimaxOrigin")),e("input",{className:"cm-input",type:"url",value:o.baseUrl??"",placeholder:"https://www.minimax.cn","aria-label":a("minimaxOrigin"),onChange:l=>v("baseUrl",l.target.value)}),e("p",{className:"cm-note"},a("minimaxOriginNote"))):null,s==="qwen"?e("div",{className:"cm-field"},e("label",null,a("qwenSource")),e("select",{className:"cm-input",value:o.quotaSource??"local",onChange:l=>v("quotaSource",l.target.value)},e("option",{value:"local"},a("qwenSourceLocal")),e("option",{value:"cli"},a("qwenSourceCli")),e("option",{value:"bailian"},a("qwenSourceBailian"))),e("p",{className:"cm-note"},a(o.quotaSource==="bailian"?"qwenBailianNote":"qwenCliNote"))):null,e("div",{className:"cm-field"},e("label",null,a("codingPlanDisplayLabel")),e("select",{className:"cm-input","aria-label":a("codingPlanDisplayLabel"),value:he(o,(n??N).quotaStrip,"plans"),onChange:l=>{if(n===null)return;const d=n.codingPlans??N.codingPlans??{};y({...n,codingPlans:{...d,[s]:{...o,sidebarAfterSuccess:!1,...fe(l.target.value)}}})}},...ye(a)),e("span",{className:"cm-hint"},q(u.config)==="en"?"Choose the sidebar, settings, the area above the input box, or a combination. Individual placement overrides strip defaults.":"可单独选择侧栏、设置页或输入框上方,也可同时显示。单家位置优先于横条默认设置。")),s!=="scnet"&&(s!=="qwen"||(o.quotaSource??"local")!=="local")?e("div",{className:"cm-field"},e("label",null,a("codingPlanRefreshIntervalLabel")),oe({value:typeof o.refreshMinutes=="number"&&Number.isFinite(o.refreshMinutes)&&o.refreshMinutes>0?o.refreshMinutes:15},l=>{v("refreshMinutes",Math.min(1440,Math.max(1,Math.floor(l))))})):null,s==="scnet"||s==="qwen"&&(o.quotaSource??"local")==="local"?e(O,null,e("div",{className:"cm-field"},e("label",null,a(s==="qwen"?"qwenPlanCreditsLabel":"scnetPlanCreditsLabel")),e("input",{className:"cm-input",type:"number",min:"1",step:"1000",value:typeof o.planCredits=="number"&&Number.isFinite(o.planCredits)&&o.planCredits>0?o.planCredits:s==="qwen"?5e5:24e4,onChange:l=>{const d=Number(l.target.value);Number.isFinite(d)&&d>0&&v("planCredits",Math.floor(d))}})),e("div",{className:"cm-field"},e("label",null,a(s==="qwen"?"qwenPlanStartLabel":"scnetPlanStartLabel")),e("input",{className:"cm-input",type:"date",value:typeof o.planStart=="string"?o.planStart:"",onChange:l=>v("planStart",l.target.value)})),s==="qwen"?e(O,null,e("div",{className:"cm-field"},e("label",null,a("qwenRatesLabel"))),[...new Set([...Object.keys(k(o)),...Object.keys(F)])].sort().map(l=>e("div",{key:l,className:"cm-match-row"},e("span",{style:{minWidth:"120px"}},l),p.map(d=>e("input",{key:d,className:"cm-input narrow",type:"number",min:"0",step:"0.1",value:j(l)[d]??"",placeholder:a("qwenRate_"+d),"aria-label":l+" · "+a("qwenRate_"+d),onChange:L=>{const P=L.target.value;x(l,d,P)}})),e("button",{className:"cm-btn small",onClick:()=>Z(l)},a("overrideRemove")),l in F&&!$(j(l))?e("span",{className:"cm-note"},a("qwenRateDraftNote")):null)),e("div",{className:"cm-buttons"},e("input",{className:"cm-input narrow",type:"text",placeholder:a("qwenRatesModelPlaceholder"),value:_,onChange:l=>K(l.target.value)}),e("button",{className:"cm-btn small",onClick:()=>{const l=_.trim();l.length!==0&&(Y(l),K(""))},disabled:_.trim().length===0},a("qwenRatesAdd")))):null,e("p",{className:"cm-note"},a(s==="qwen"?"qwenLocalNote":"scnetLocalNote"))):s==="qwen"?null:s==="volcengine"?e(O,null,e("div",{className:"cm-field"},e("label",null,a("volcengineAccessKeyIdLabel"))),e(z,{state:u,draft:n,setDraft:y,target:"codingPlans.volcengine.ak",configured:r.keyConfigured===!0,source:r.keySource,t:a,api:C,placeholder:a("volcengineAccessKeyPlaceholder")}),e("div",{className:"cm-field"},e("label",null,a("volcengineSecretAccessKeyLabel"))),e(z,{state:u,draft:n,setDraft:y,target:"codingPlans.volcengine.sk",configured:r.keyConfigured===!0,source:r.keySource,t:a,api:C,placeholder:a("volcengineSecretPlaceholder")}),e("p",{className:"cm-note"},q(u.config)==="en"?"Volcano Ark needs AK/SK, ArkReadOnlyAccess and BillingCenterReadOnlyAccess. Enter credentials or export VOLC_ACCESSKEY/VOLC_SECRETKEY. Only open.volcengineapi.com is contacted.":"火山方舟需 AK/SK、ArkReadOnlyAccess 和 BillingCenterReadOnlyAccess;可填凭据或导出 VOLC_ACCESSKEY/VOLC_SECRETKEY。只连接 open.volcengineapi.com。")):s==="workbuddy"?e(O,null,e("p",{className:"cm-note"},a("wbH")),e(Se,{live:r,config:o,setPlan:v,state:u})):e(O,null,e("div",{className:"cm-field"},e("label",null,s==="baidu-coding"?"Cookie (console.bce.baidu.com)":s==="mimo"?"Cookie (platform.xiaomimimo.com)":s==="factory"?"Factory Token":s==="opendesign"?"OpenDesign Cookie / Control Key":a(s==="zai"?"zaiPlanKeyLabel":"codingPlanKeyLabel"))),e(z,{state:u,draft:n,setDraft:y,target:"codingPlans."+s,configured:r.keyConfigured===!0,source:r.keySource,t:a,api:C,placeholder:s==="baidu-coding"?"BAIDU_QIANFAN_COOKIE":s==="mimo"?"api-platform_serviceToken=…; userId=…":s==="factory"?"FACTORY_API_KEY":s==="opendesign"?"Cookie: name=value; … / vela_ctrl_…":"sk-…"}),s==="baidu-coding"?e("p",{className:"cm-note"},q(u.config)==="en"?"Sign in at console.bce.baidu.com, open Token Plan → browser Network → tokenPlanPersonal/resource, and copy the full Cookie request header. Supports Personal credits and Tokens; excludes add-on packs. API keys cannot query quotas.":"登录 console.bce.baidu.com,打开 Token Plan 页面,在浏览器网络面板找到 tokenPlanPersonal/resource,复制完整 Cookie 请求头。支持个人版积分制与 Token 制套餐,不含加油包;API Key 不用于额度查询。"):null));return e(ie,{display:o.display,onSidebar:l=>v("display",l),planId:s,targeted:f.targeted,name:a(h),enabled:T,saved:N.codingPlans?.[s],busy:M,open:i,errorMsg:R?.text===r.message?null:R,statusNode:J,configNode:te,onToggle:l=>v("enabled",l),onRefresh:A,onLogin:A,loginRequired:E,onToggleOpen:()=>m(l=>!l),t:a})}return f=>f.mode==="add-fireworks"?e("button",{type:"button",className:"cm-btn small",disabled:f.disabled,onClick:()=>f.onAdd({adapter:"fireworks",enabled:!1,label:"Fireworks.ai",labelEn:"Fireworks.ai",unit:"USD",display:"both",refreshMinutes:15,dashboardUrl:"https://app.fireworks.ai/account/billing",channels:["fireworks"],allowedHosts:["api.fireworks.ai"],request:{url:"",method:"GET",headers:{Authorization:"Bearer {{FIREWORKS_API_KEY}}"}},extract:{remaining:"balance"}})},"+ Fireworks.ai"):f.mode==="credential"?e(z,f):f.mode==="custom-balance"?e(Ae,f):e(xe,f)}}}});
@@ -1,4 +1,4 @@
1
- ;(function(oe){const Z=window.__ModuleLoader__,re=Z[Symbol.for("@dsh-plugin/dsh-loader:load-wrap")];return(oe.id==="dsh-cost-meter"&&Z.load===re?.ours&&typeof re.original=="function"?re.original:Z.load).call(Z,oe)})({id:"dsh-cost-meter",chunk:"client.pricing.js",factory:de=>{function oe(t){if(t==="auto")return!0;if(typeof t!="string"||!t||t.length>100||/^[+-]/.test(t))return!1;try{return new Intl.DateTimeFormat("en",{timeZone:t}),!0}catch{return!1}}function Z(t){if(t?.peakTimeZone!=="auto"&&oe(t?.peakTimeZone))return t.peakTimeZone;try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function re(t){let a=[];try{a=Intl.supportedValuesOf("timeZone")}catch{}return[...new Set(["UTC",Z({}),Z(t),"Asia/Shanghai","Asia/Tokyo","Asia/Kolkata","Asia/Kathmandu","Europe/London","Europe/Berlin","America/New_York","America/Los_Angeles","Australia/Sydney",...a])].sort()}function ye(t,a,r,p){const i=new Date(p),n=Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),i.getUTCDate()),x=new Intl.DateTimeFormat(r,{timeZone:Z(a),weekday:"short",hour:"2-digit",minute:"2-digit",hourCycle:"h23"});return(t??[]).map(o=>x.format(n+o.start*36e5)+"–"+x.format(n+(o.end<=o.start?o.end+24:o.end)*36e5)).join(", ")}function Te({config:t,onChange:a,locale:r}){const p=r==="en",i=Z(t);return e("label",{className:"cm-field","data-display-option":"peak-timezone"},e("span",null,p?"Peak display timezone":"峰谷显示时区"),e("select",{className:"cm-input",value:t.peakTimeZone??"auto",onChange:n=>a(n.target.value),"aria-label":p?"Peak display timezone":"峰谷显示时区"},e("option",{value:"auto"},(p?"System timezone · ":"跟随系统 · ")+Z({})),...re(t).map(n=>e("option",{key:n,value:n},n))),e("span",{className:"cm-hint"},(p?"Displaying in ":"当前显示:")+i+(p?". Daylight saving adjusts automatically. Provider billing periods stay unchanged.":"。自动处理夏令时,厂商计费时段保持不变。")))}const{createElement:e,Fragment:pe,useState:A,useEffect:ie,useLayoutEffect:ue,useMemo:J,useRef:ne,useId:ze}=de("react");let ge=null;try{ge=de("react-dom")?.createPortal??null}catch{}const De=["at","before","after","days","sessions","skipped"],Ee=t=>typeof t?.sessionId=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(t.date)&&typeof t.model=="string"&&["usage","ledgerModelMissing","logModelMissing","dayModelMissing","logMissing"].includes(t.reason)&&Array.isArray(t.fields)&&t.fields.every(a=>["input","output","cacheRead","cacheWrite","reasoning","calls"].includes(a?.field)&&Number.isFinite(a.ledger)&&a.ledger>=0&&Number.isFinite(a.log)&&a.log>=0),Ie=t=>["deepseek-official:deepseek-web-search","deepseek-official:deepseek-web-fetch","deepseek-official:deepseek-search-api","deepseek-official:deepseek-fetch-api","deepseek-official:deepseek-search-server"].includes(t),ce={parse:t=>{if(!Array.isArray(t)||!t.every(a=>De.every(r=>Number.isFinite(a?.[r])&&a[r]>=0)&&(a.model===void 0||typeof a.model=="string")&&(a.skippedDetails===void 0||Array.isArray(a.skippedDetails)&&a.skippedDetails.every(Ee))))throw new Error("Invalid recalculation history");return t}},he={parse:t=>{if(typeof t?.ok!="boolean"||typeof t?.message!="string")throw new Error("Invalid recalculation result");return t}},fe={parse:t=>{if(typeof t!="boolean")throw new Error("Expected confirmation");return t}},ve={parse:t=>{if(typeof t!="string"||t.length>2048||t.indexOf(":")<=0||t.endsWith(":")||/[\r\n]/.test(t))throw new Error("Expected channel/model");return t}},we={parse:t=>{if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Invalid price catalog");return t}},ee=(t,a)=>({mode:"strict",typeSymbol:"dsh-cost-meter#"+t,schema:a,create:()=>a}),ke={package:"dsh-cost-meter-pricing",face:"host",descriptors:[{id:"dsh-cost-meter#costMeter/getPriceCatalog",service:"costMeter",namespace:"costMeter",method:"getPriceCatalog",invocation:{kind:"direct"},parameters:[],result:ee("PriceCatalog",we)},{id:"dsh-cost-meter#costMeter/getRepricingHistory",service:"costMeter",namespace:"costMeter",method:"getRepricingHistory",invocation:{kind:"direct"},parameters:[],result:ee("RepricingHistory",ce)},{id:"dsh-cost-meter#costMeter/repriceHistory",service:"costMeter",namespace:"costMeter",method:"repriceHistory",invocation:{kind:"direct"},parameters:[{name:"confirmed",wire:"confirmed",source:"json",codec:ee("RepricingConfirmation",fe)}],result:ee("FetchPricesResult",he)},{id:"dsh-cost-meter#costMeter/repriceModelHistory",service:"costMeter",namespace:"costMeter",method:"repriceModelHistory",invocation:{kind:"direct"},parameters:[{name:"confirmed",wire:"confirmed",source:"json",codec:ee("RepricingConfirmation",fe)},{name:"model",wire:"model",source:"json",codec:ee("RepricingModel",ve)}],result:ee("FetchPricesResult",he)}]},Le=t=>(t.label+" "+t.value).toLowerCase();function le({options:t,value:a,placeholder:r,label:p,ariaLabel:i,locale:n,onChange:x}){const o=n==="en",g=ze(),l=g+"-list",[c,s]=A(""),[h,w]=A(!1),[u,f]=A(0),[d,M]=A(null),N=ne(null),k=ne(null),C=ne(null),T=t.find(v=>v.value===a),O=c.toLowerCase().trim().split(/\s+/).filter(Boolean),_=J(()=>t.map(v=>({option:v,search:Le(v)})),[t]),U=v=>{const P=v.toLowerCase().trim().split(/\s+/).filter(Boolean);return P.length?_.filter(I=>P.every(H=>I.search.includes(H))).map(I=>I.option):t},W=U(c),B=T&&!W.includes(T)?[T,...W]:W,y=Math.max(0,Math.min(u,B.length-1)),D=()=>{w(!1),s("")},Y=()=>{h||(M(null),s(""),f(Math.max(0,B.findIndex(v=>v.value===a))),w(!0))},b=v=>{v&&(v.value!==a&&x(v.value),D())},E=()=>{if(h&&c){s(""),f(0);return}a&&x(""),D()};ue(()=>{if(!h||typeof document>"u")return;const v=k.current,P=typeof window>"u"?null:window,I=()=>{const H=v?.getBoundingClientRect?.();if(!H||!P)return;const m=P.innerHeight,S=12,j=m-H.bottom-S,L=H.top-S,q=j<180&&L>j,R=Math.max(60,q?L:j),$=Math.max(0,Math.min(280,R,m-S*2)),ae=Math.max(S,Math.min(q?H.top-$-6:H.bottom+6,m-$-S));M(V=>V&&V.left===H.left&&V.top===ae&&V.width===H.width&&V.maxHeight===$?V:{left:H.left,top:ae,width:H.width,maxHeight:$})};if(I(),typeof P?.addEventListener=="function")return P.addEventListener("scroll",I,!0),P.addEventListener("resize",I),()=>{P.removeEventListener("scroll",I,!0),P.removeEventListener("resize",I)}},[h]),ie(()=>{if(!h||typeof document>"u"||typeof document.addEventListener!="function")return;const v=P=>{N.current?.contains?.(P.target)||C.current?.contains?.(P.target)||D()};return document.addEventListener("pointerdown",v,!0),()=>document.removeEventListener("pointerdown",v,!0)},[h]),ue(()=>{!h||!d||C.current?.querySelector?.('[data-active="true"]')?.scrollIntoView?.({block:"nearest"})},[h,y,d,c]);const F=v=>g+"-opt-"+v,Q=O.length?W.length?o?`${W.length} matches`:`${W.length} 个结果`:B.length?o?"No matches · showing the current choice":"没有匹配的模型 · 下面是当前选择":o?"No matches":"没有匹配的模型":null,K=h?e("div",{ref:C,className:"cm-combo-panel",style:d??{visibility:"hidden"}},B.length?e("div",{className:"cm-combo-list",id:l,role:"listbox","aria-label":p},B.map((v,P)=>e("button",{key:v.value,id:F(P),type:"button",role:"option",className:"cm-combo-option"+(P===y?" active":""),"data-active":String(P===y),"aria-selected":String(v.value===a),onMouseEnter:()=>f(P),onMouseDown:I=>I.preventDefault(),onClick:()=>b(v)},v.label))):null,Q?e("p",{className:"cm-combo-note",role:"status"},Q):null):null;return e("div",{ref:N,className:"cm-price-search cm-combo"},e("div",{className:"cm-combo-control"},e("input",{ref:k,type:"search",className:"cm-input cm-combo-input",autoComplete:"off",value:h?c:T?.label??"",role:"combobox","aria-expanded":String(h),"aria-autocomplete":"list","aria-controls":h&&B.length?l:void 0,"aria-activedescendant":h&&B.length?F(y):void 0,"aria-label":i??p+(o?" · Price model":" · 价格模型"),placeholder:h&&T?T.label:r,onFocus:Y,onClick:()=>{h||Y()},onChange:v=>{const P=v.target.value,I=!h&&T&&P.startsWith(T.label)?P.slice(T.label.length):P,H=U(I);s(I),w(!0),f(T&&H.length>0&&!H.includes(T)?1:0)},onKeyDown:v=>{if(!v.nativeEvent?.isComposing){if(v.key==="Escape"){if(v.preventDefault(),!h)return;D(),v.stopPropagation();return}if(v.key==="ArrowDown"||v.key==="ArrowUp"){if(v.preventDefault(),!h){Y();return}f(Math.max(0,Math.min(B.length-1,y+(v.key==="ArrowDown"?1:-1))));return}if(v.key==="Enter"&&h&&B[y]){v.preventDefault(),b(B[y]);return}v.key==="Tab"&&D()}}}),a||c?e("button",{type:"button",className:"cm-combo-clear","aria-label":(o?"Clear ":"清空 ")+p,onMouseDown:v=>v.preventDefault(),onClick:E},"×"):null,e("button",{type:"button",className:"cm-combo-caret",tabIndex:-1,"aria-hidden":"true",onMouseDown:v=>v.preventDefault(),onClick:()=>{h?D():(k.current?.focus?.(),Y())}},"▾")),K&&ge?ge(K,document.body):K)}function Ne({state:t,draft:a,setDraft:r,locale:p,rpc:i}){const[n,x]=A(!1),[o,g]=A(null),[l,c]=A(""),[s,h]=A(""),[w,u]=A(0),f=t.config.prices.currency??"USD",d=p==="en";ie(()=>{if(!n)return;let C=!0;return g(null),h(""),c(""),i("getPriceCatalog").then(T=>{C&&g(T)},T=>{C&&h(String(T.message??T))}),()=>{C=!1}},[n,f,w,i]);const M=[];for(const[C,T]of Object.entries(o??{}))for(const O of Object.values(T))for(const[_,U]of Object.entries(O))!(C==="deepseek"?a?.prices.models[_]:a?.prices.providers?.[C]?.models?.[_])&&!U.unpriced&&M.push({value:C+":"+_,label:C+" · "+_,provider:C,id:_,entry:U});const N=M.find(C=>C.value===l),k=()=>{if(!N||!a)return;const{provider:C,id:T,entry:O}=N,_=JSON.parse(JSON.stringify(O)),U=a.prices;r({...a,prices:C==="deepseek"?{...U,models:{...U.models,[T]:_}}:{...U,providers:{...U.providers,[C]:{...U.providers?.[C],models:{...U.providers?.[C]?.models,[T]:_}}}}}),c("")};return e("div",{className:"cm-restore-prices"},e("button",{type:"button",className:"cm-btn small","aria-expanded":n,onClick:()=>x(C=>!C)},n?d?"Close restore":"收起恢复入口":d?"Restore bundled model":"恢复内置模型"),n?e("div",{className:"cm-collapse-body"},s?e("div",{role:"alert",className:"cm-err"},s,e("button",{type:"button",className:"cm-btn small",onClick:()=>u(C=>C+1)},d?"Retry":"重试")):o===null?e("p",{role:"status",className:"cm-hint"},d?"Loading prices…":"读取价格…"):M.length?e(pe,null,e(le,{options:M,value:N?l:"",placeholder:d?"Select a model":"选择模型",label:d?"Restore model":"恢复模型",locale:p,onChange:c}),e("button",{type:"button",className:"cm-btn small",disabled:!N,onClick:k},d?"Restore":"恢复")):e("p",{className:"cm-hint"},d?"All bundled models are mounted.":"内置模型均已挂载。")):null)}function Re(t){const{state:a,draft:r,setDraft:p,t:i}=t,{peakPhaseAt:n,resolveLocale:x,peakNoticeEl:o}=t.peakHelpers,g=a.config,l=(d,M)=>{r!==null&&p({...r,[d]:M})},c=r===null?g:{...g,...r},s=x(c)==="en"?"en":"zh-CN",h=Z(c),w=d=>Number.isFinite(Date.parse(d))?new Intl.DateTimeFormat(s,{timeZone:h,dateStyle:"medium",timeStyle:"short"}).format(Date.parse(d)):i("unknown"),u=(()=>{if(c.peakEnabled!==!0)return i("peakOff");const d=Date.parse(c.peakEffectiveAt||""),M=Date.now();if(Number.isFinite(d)&&M<d)return i("peakNotEffective",{time:w(c.peakEffectiveAt)});const N=c.peakWindows??[],k=n(M,N,c.peakHolidays);return k===null?i("offPeakActive"):k.holiday===!0?i("holidayAllOffPeak"):k.weekend===!0?i("weekendAllOffPeak"):k.inPeak?i("peakActive"):i("offPeakActive")})(),f=(c.peakWindows?.length??0)>0?i("peakSummary",{windows:ye(c.peakWindows,c,s,Date.now()),zone:h,time:w(c.peakEffectiveAt),status:u}):i("noPeakWindows",{status:u});return e("div",{className:"cm-budget"},e(Te,{config:c,locale:s,onChange:d=>l("peakTimeZone",d)}),e("div",{className:"cm-budget-head"},e("h3",{className:"cm-h"},i("peakPanelTitle")),e("label",{className:"cm-check"},e("input",{type:"checkbox",checked:r?.peakEnabled!==!1,onChange:d=>l("peakEnabled",d.target.checked)}),e("span",null,i("peakEnabledLabel")))),e("div",{className:"cm-grid"},e("div",{className:"cm-field"},e("label",{className:"cm-check"},e("input",{type:"checkbox",checked:r?.peakNotice!==!1,onChange:d=>l("peakNotice",d.target.checked)}),e("span",null,i("peakNoticeLabel")))),e("div",{className:"cm-field"},e("label",null,i("peakStyleLabel")),e("select",{className:"cm-input",value:r?.peakStyle??"compact",onChange:d=>l("peakStyle",d.target.value)},e("option",{value:"progress"},x(r)==="en"?"Time progress":"时间进度条"),e("option",{value:"compact"},i("peakStyleCompact")),e("option",{value:"classic"},i("peakStyleClassic"))))),e("div",{className:"cm-grid"},e("div",{className:"cm-field"},e("label",{className:"cm-check"},e("input",{type:"checkbox",checked:r?.peakAlertEnabled!==!1,onChange:d=>l("peakAlertEnabled",d.target.checked)}),e("span",null,i("peakAlertLabel")))),e("div",{className:"cm-field"},e("label",null,i("peakAlertAheadLabel")),e("input",{className:"cm-input narrow",type:"number",min:"1",max:"30",step:"1",value:String(typeof r?.peakAlertAhead=="number"&&Number.isFinite(r.peakAlertAhead)&&r.peakAlertAhead>=1&&r.peakAlertAhead<=30?r.peakAlertAhead:2),onChange:d=>{const M=Number(d.target.value);Number.isInteger(M)&&M>=1&&M<=30&&l("peakAlertAhead",M)}})),e("div",{className:"cm-field"},e("label",null,i("peakAlertTargetLabel")),e("select",{className:"cm-input",value:r?.peakAlertTarget==="peak"||r?.peakAlertTarget==="offpeak"?r.peakAlertTarget:"both",onChange:d=>l("peakAlertTarget",d.target.value)},e("option",{value:"both"},i("peakAlertTargetBoth")),e("option",{value:"peak"},i("peakAlertTargetPeak")),e("option",{value:"offpeak"},i("peakAlertTargetOffPeak"))))),e("div",{className:"cm-grid"},e("div",{className:"cm-field"},e("label",null,i("peakAlertPositionLabel")),e("select",{className:"cm-input",value:r?.peakAlertPosition==="center"?"center":"corner",onChange:d=>l("peakAlertPosition",d.target.value)},e("option",{value:"corner"},i("peakAlertPositionCorner")),e("option",{value:"center"},i("peakAlertPositionCenter")))),e("div",{className:"cm-field"},e("label",{className:"cm-check"},e("input",{type:"checkbox",checked:r?.peakAlertWebNotify===!0,onChange:d=>{l("peakAlertWebNotify",d.target.checked),d.target.checked&&window.Notification&&Notification.permission==="default"&&Promise.resolve(Notification.requestPermission()).catch(()=>{})}}),e("span",null,i("peakAlertWebNotifyLabel"))),e("p",{className:"cm-hint"},i("peakAlertWebNotifyHint")))),e("div",{className:"cm-field"},e("label",null,i("peakAlertPreviewLabel")),e("div",{className:"cm-row"},e("button",{className:"cm-btn",onClick:()=>window.cmPeakAlertPreview?.("peak")},i("peakAlertPreviewPeak")),e("button",{className:"cm-btn",onClick:()=>window.cmPeakAlertPreview?.("offpeak")},i("peakAlertPreviewOffPeak")))),e("div",{className:"cm-peak-preview"},r?.peakEnabled!==!1&&r?.peakNotice!==!1?o(a,c,i):e("p",{className:"cm-hint"},i("peakNoticeHiddenHint"))),e("p",{className:"cm-hint"},f),e("div",{className:"cm-field"},e("label",null,i("peakHolidaysLabel")),e("input",{className:"cm-input",defaultValue:(c.peakHolidays??[]).join(", "),onBlur:d=>l("peakHolidays",d.target.value.split(/[,,\s]+/).filter(Boolean))})),e("p",{className:"cm-hint"},i("weekendRuleNote")))}function Ce({value:t,onChange:a,locale:r,defaults:p=[]}){const i=r==="en",n=t.peakWindows,x=w=>w.map(u=>u.start+"-"+u.end).join(", "),[o,g]=A(()=>x(n??p)),[l,c]=A("");ie(()=>g(x(n??p)),[JSON.stringify(n),JSON.stringify(p)]);const s=(w,u)=>{const f={...t};u===void 0?delete f[w]:f[w]=u,a(f)},h=()=>{const u=(o.trim()?o.split(/[,,]/).map(f=>f.trim()):[]).map(f=>{const d=f.match(/^(\d+(?:\.\d+)?)\s*-\s*(\d+(?:\.\d+)?)$/);return d?{start:Number(d[1]),end:Number(d[2])}:null});if(u.length>24||u.some(f=>!f||f.start>=24||f.end>24||f.start===f.end)){c(i?"Use UTC hours, e.g. 1-4, 6-10 or 22-2.":"填写 UTC 小时,例如 1-4, 6-10,跨午夜可填 22-2。");return}c(""),s("peakWindows",u)};return e("fieldset",{className:"cm-peak-schedule"},e("legend",null,i?"Peak schedule":"峰谷时段"),e("label",{className:"cm-check"},e("input",{type:"checkbox",checked:n!==void 0,onChange:w=>{c(""),s("peakWindows",w.target.checked?structuredClone(p):void 0)}}),i?"Override peak hours":"自定义峰时段"),n!==void 0?e("label",{className:"cm-field"},i?"Peak hours (UTC)":"峰时段(UTC)",e("input",{className:"cm-input",value:o,onChange:w=>g(w.target.value),onBlur:h,onKeyDown:w=>{w.key==="Enter"&&(w.preventDefault(),h())}})):null,e("label",{className:"cm-field"},i?"Calendar":"日历规则",e("select",{className:"cm-input","aria-label":i?"Calendar":"日历规则",value:t.peakSchedule??"",onChange:w=>s("peakSchedule",w.target.value||void 0)},...[["","沿用上级/渠道默认","Inherit channel/default"],["daily","每天","Every day"],["deepseek","北京时间工作日","Beijing weekdays"],["utc-weekdays","UTC 工作日","UTC weekdays"],["ollama","Ollama Cloud","Ollama Cloud"],["volcengine","火山方舟","Volcano Ark"]].map(([w,u,f])=>e("option",{key:w,value:w},i?f:u)))),e("label",{className:"cm-field"},i?"Holidays":"节假日",e("select",{className:"cm-input","aria-label":i?"Holidays":"节假日",value:t.peakHolidays===null?"none":Array.isArray(t.peakHolidays)?"custom":"inherit",onChange:w=>s("peakHolidays",w.target.value==="none"?null:w.target.value==="custom"?[]:void 0)},e("option",{value:"inherit"},i?"Inherit":"沿用上级/渠道默认"),e("option",{value:"none"},i?"No holiday table":"不使用节假日表"),e("option",{value:"custom"},i?"Custom dates":"自定义日期"))),Array.isArray(t.peakHolidays)?e("label",{className:"cm-field"},i?"Off-peak Beijing dates":"全天谷价日期(北京时间)",e("input",{className:"cm-input",key:JSON.stringify(t.peakHolidays),defaultValue:t.peakHolidays.join(", "),placeholder:"2026-11-01, 2026-11-02",onBlur:w=>{const u=w.target.value.split(/[,,\s]+/).filter(Boolean);if(u.length>366||u.some(f=>!/^\d{4}-\d{2}-\d{2}$/.test(f)||!Number.isFinite(Date.parse(f+"T00:00:00Z"))||new Date(f+"T00:00:00Z").toISOString().slice(0,10)!==f)){c(i?"Use valid YYYY-MM-DD dates.":"请填写有效的 YYYY-MM-DD 日期。");return}c(""),s("peakHolidays",[...new Set(u)].sort())}})):null,l?e("p",{className:"cm-err",role:"alert"},l):null,e("p",{className:"cm-hint"},i?"Hours use UTC; Beijing time is UTC + 8. Windows include the start and exclude the end. Empty hours mean all off-peak. Model settings override channel settings.":"小时采用 UTC,北京时间减 8 小时后填写。包含起点、不含终点,时段留空表示全天谷价。模型设置优先于渠道设置。"))}const te=["cacheMiss","cacheHit","output","cacheWrite","reasoning"],se=(t,a)=>t?.[a]??(a==="cacheMiss"?t?.input:a==="cacheHit"?t?.cachedInput??t?.cacheRead??t?.cacheMiss??t?.input:void 0)??null,me=(t,a,r,p)=>({...t,separateMultipliers:!0,multipliers:{...t.separateMultipliers?t.multipliers:{},...Object.fromEntries(r.map(i=>[a+"."+i,p]))}});function Me({value:t,label:a,locale:r,rates:p,disabled:i=!1,onCommit:n}){const x=t==null?"":String(t),[o,g]=A(x),[l,c]=A(!1),s=ne(!1);ie(()=>{s.current||g(x)},[x]);const h=()=>{s.current=!1,c(!1),g(x)},w=()=>{if(!s.current)return;if(!o.trim()){h();return}const u=Number(o);if(!Number.isFinite(u)||u<0||p.some(f=>f!=null&&!Number.isFinite(f*u))){c(!0);return}s.current=!1,c(!1),g(String(u)),n(u)};return e("input",{className:"cm-input cm-factor-input",type:"number",min:0,step:"any",value:o,disabled:i,"aria-label":a,"aria-invalid":l,placeholder:r==="en"?"Mixed":"各项不同",title:l?r==="en"?"Enter a finite, non-negative multiplier.":"请输入有效的非负倍率。":a,onChange:u=>{s.current=!0,c(!1),g(u.target.value)},onBlur:w,onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),w()),u.key==="Escape"&&(u.stopPropagation(),h())}})}function be({value:t,tier:a,title:r,locale:p,priceEditor:i,onChange:n}){const x=te.map(c=>i.priceFactor(t,a+"."+c)),o=x.every(c=>c===x[0])?x[0]:null,g=r+(p==="en"?" · Set all multipliers":" · 统一设置倍率"),l=[t,...t.rateHistory??[]].flatMap(c=>te.map(s=>se(a==="base"?c:c[a],s)));return e("label",{className:"cm-tier-multiplier"},p==="en"?"Set all multipliers":"统一设置倍率",e(Me,{value:o,label:g,locale:p,rates:l,onCommit:c=>n(me(t,a,te,c))}))}function xe({value:t,tier:a="base",field:r,title:p,label:i,locale:n,currency:x,priceEditor:o,t:g,onChange:l}){const c=a==="base"?t:t[a],s=se(c,r),h=a+"."+r,w=r==="cacheWrite"||r==="reasoning",u=o.priceFactor(t,h),f=(d,M)=>{const N={...c};d===null?delete N[r]:N[r]=d,r==="cacheMiss"&&delete N.input,r==="cacheHit"&&(delete N.cachedInput,delete N.cacheRead);const k=a==="base"?N:{...t,[a]:N};l(M===void 0?k:me(k,a,[r],M))};return e("div",{className:"cm-rate-field"},e("span",null,p),e("div",{className:"cm-rate-input"},e("span",{className:"cm-custom-amount"},e("span",{"aria-hidden":!0},x==="CNY"?"¥":"$"),e(o.PriceInput,{value:s,entry:t,path:h,plain:!0,t:g,label:i,emptyMode:w?"clear":"ignore",placeholder:r==="cacheWrite"?n==="en"?"Cached input rate":"跟随缓存读取":r==="reasoning"?n==="en"?"Included in output":"含在输出中":"0",onCommit:f})),e("span",{className:"cm-rate-times","aria-hidden":!0},"×"),e(Me,{value:u,label:i+(n==="en"?" · Multiplier":" · 倍率"),locale:n,rates:[s],disabled:s==null,onCommit:d=>l(me(t,a,[r],d))})))}function Se({value:t,onChange:a,locale:r,defaults:p,t:i,priceEditor:n,label:x="",currency:o=t.currency}){const g=r==="en",l=t.billingMode==="deepseek-peak"||!!(t.peak||t.offPeak),c=Object.fromEntries(te.map((s,h)=>[s,se(t,s)??(h<3?0:null)]).filter(([,s])=>s!==null));return e("details",{className:"cm-custom-more"},e("summary",null,g?"Peak / off-peak pricing":"峰谷价格与时段"),e("label",{className:"cm-check"},e("input",{type:"checkbox",checked:l,onChange:s=>{const h={...t,billingMode:s.target.checked?"deepseek-peak":"flat"};if(s.target.checked){h.multipliers={...t.separateMultipliers?t.multipliers:{}},h.separateMultipliers=!0;for(const w of["peak","offPeak"])if(!t[w]){h[w]={...c};for(const u of te)h.multipliers[w+"."+u]=n.priceFactor(t,"base."+u)}}else delete h.peak,delete h.offPeak;a(h)}}),g?"Enable peak / off-peak prices":"启用峰谷价格"),l?e(pe,null,...["peak","offPeak"].map(s=>{const h=s==="peak"?g?"Peak":"峰价":g?"Off-peak":"谷价";return e("fieldset",{key:s,"data-price-tier":s},e("legend",null,h),e(be,{value:t,tier:s,title:x+" · "+h,locale:r,priceEditor:n,onChange:a}),e("div",{className:"cm-custom-grid"},...[["cacheMiss","输入","Input"],["cacheHit","缓存读取","Cached input"],["output","输出","Output"],["cacheWrite","缓存写入","Cache write"],["reasoning","单独推理","Reasoning"]].map(([w,u,f])=>e(xe,{key:w,value:t,tier:s,field:w,title:g?f:u,label:x+" · "+h+" · "+(g?f:u),locale:r,currency:o,priceEditor:n,t:i,onChange:a}))))}),e(Ce,{value:t,onChange:a,locale:r,defaults:p})):null)}function He({state:t,draft:a,setDraft:r,locale:p}){const i=p==="en",n=a??t.config,[x,o]=A("deepseek"),g=x.trim().toLowerCase().replace(/^llm-/,""),l=n.prices?.providers?.[g]??{models:{}},c=[...new Set(["deepseek",...Object.keys(n.prices?.providers??{}),...Object.keys(t.today?.byProviderModel??{}).map(s=>s.split(":")[0])])].sort();return e("details",{className:"cm-provider-schedules"},e("summary",null,i?"Channel peak schedules":"按渠道设置峰谷时段"),e("label",{className:"cm-field"},i?"Provider ID":"渠道 ID",e("input",{className:"cm-input",list:"cm-peak-providers",value:x,onChange:s=>o(s.target.value)})),e("datalist",{id:"cm-peak-providers"},...c.map(s=>e("option",{key:s,value:s}))),/^[a-z0-9][a-z0-9_.-]{0,99}$/.test(g)&&!["constructor","prototype","__proto__"].includes(g)?e(Ce,{key:g,value:l,locale:p,defaults:g==="ollama-cloud"?[{start:12,end:18}]:n.peakWindows,onChange:s=>r({...n,prices:{...n.prices,providers:{...n.prices.providers,[g]:s}}})}):null,e("p",{className:"cm-hint"},i?"Use the channel ID from model pricing. Applies to peak-enabled models and is retained when official prices sync.":"填写模型定价中显示的渠道 ID。规则用于已启用峰谷价格的模型,同步官方价格时会保留。"))}function je({value:t,locale:a,onChange:r}){const[p,i]=A(String(t)),[n,x]=A(!1);ie(()=>{i(String(t)),x(!1)},[t]);const o=()=>{const l=Number(p);if(!p.trim()||!Number.isSafeInteger(l)||l<=0){x(!0);return}x(!1),r(l)},g=a==="en"?"Input Token threshold":"输入 Token 阈值";return e("label",{className:"cm-field"},g,e("input",{className:"cm-input",type:"number",min:1,step:1,value:p,"aria-label":g,"aria-invalid":n,title:n?a==="en"?"Enter a positive integer.":"请输入正整数。":g,onChange:l=>{i(l.target.value),x(!1)},onBlur:o,onKeyDown:l=>{l.key==="Enter"&&(l.preventDefault(),o()),l.key==="Escape"&&(l.stopPropagation(),i(String(t)),x(!1))}}))}function Ue({value:t,label:a,locale:r,onChange:p,t:i,priceEditor:n,fields:x}){const o=r==="en",g=t.longContext,l=o?"Long context":"长上下文";return e("fieldset",{className:"cm-long-context"},e("legend",null,l),e("label",{className:"cm-check"},e("input",{type:"checkbox",checked:!!g,onChange:c=>{const s={...t};if(c.target.checked){if(s.longContext={aboveInputTokens:272e3,...Object.fromEntries(te.map(h=>[h,se(t,h)]).filter(([,h])=>h!=null))},t.separateMultipliers)for(const h of te)Object.assign(s,me(s,"longContext",[h],n.priceFactor(t,"base."+h)))}else delete s.longContext;p(s)}}),o?"Enable long-context prices":"启用长上下文价格"),g?e(pe,null,e(je,{value:g.aboveInputTokens,locale:r,onChange:c=>p({...t,longContext:{...g,aboveInputTokens:c}})}),e("p",{className:"cm-hint"},o?"Applies when input plus cache read/write exceeds this threshold.":"输入与缓存读写 Token 合计超过阈值时使用。"),e(be,{value:t,tier:"longContext",title:a+" · "+l,locale:r,priceEditor:n,onChange:p}),e("div",{className:"cm-custom-grid"},...x.map(([c,s])=>e(xe,{key:c,value:t,tier:"longContext",field:c,title:s,label:a+" · "+l+" · "+s,locale:r,currency:t.currency,priceEditor:n,t:i,onChange:p})))):null)}function We({value:t,label:a,locale:r,onChange:p,t:i,priceEditor:n,templates:x}){const o=r==="en",[g,l]=A(null),c=g?.price??t,s=d=>g?l({...g,price:d}):p(d),{priceFactor:h}=n,w=[["cacheMiss",o?"Input · cache miss":"输入 · 未命中缓存"],["cacheHit",o?"Cached input":"缓存读取"],["output",o?"Output":"输出"],["cacheWrite",o?"Cache write":"缓存写入"],["reasoning",o?"Separate reasoning":"单独推理费用"]],u=([d,M])=>e(xe,{key:d,value:c,field:d,title:M,label:a+" · "+M,locale:r,currency:c.currency,priceEditor:n,t:i,onChange:s}),f=[["base",o?"Base":"基础价"],...["peak","offPeak"].filter(d=>c[d]).map(d=>[d,d==="peak"?o?"Peak":"峰价":o?"Off-peak":"谷价"]),...c.longContext?[["longContext",o?"Long context":"长上下文"]]:[]];return e("fieldset",{className:"cm-custom-price","aria-label":a+(o?" · Custom price":" · 自定义价格")},e("legend",null,o?"Custom price · per 1M tokens":"自定义价格 · 每百万 Token"),x.length?e("div",{className:"cm-field"},e("span",null,o?"Use an existing model as a template":"以现有模型为模板"),e(le,{value:g?.key??"",options:x,label:o?"Price template":"价格模板",placeholder:o?"Select a custom price":"选择已配置自定义价格的模型",locale:r,onChange:d=>{const M=x.find(N=>N.value===d);l(M?{key:d,price:structuredClone(M.price)}:null)}}),g?e("div",{className:"cm-buttons"},e("button",{type:"button",className:"cm-btn small",onClick:()=>{p(g.price),l(null)}},o?"Save copied price":"保存复制的价格"),e("button",{type:"button",className:"cm-btn small",onClick:()=>l(null)},o?"Cancel":"取消")):null):null,e("div",{className:"cm-custom-head"},e("span",null,o?"Only this channel and model":"仅用于此渠道的这个模型"),e("label",null,o?"Currency":"币种",e("select",{className:"cm-input",value:c.currency,onChange:d=>s({...c,currency:d.target.value})},e("option",{value:"USD"},o?"USD · US dollar":"USD · 美元"),e("option",{value:"CNY"},o?"CNY · Yuan":"CNY · 人民币")))),e(be,{value:c,tier:"base",title:a+(o?" · Base":" · 基础价"),locale:r,priceEditor:n,onChange:s}),e("div",{className:"cm-custom-grid"},...w.slice(0,3).map(u)),e(Se,{value:c,onChange:s,locale:r,t:i,priceEditor:n,label:a,defaults:[{start:1,end:4},{start:6,end:10}]}),e("div",{className:"cm-custom-effective",role:"status"},e("div",{className:"cm-effective-heading"},e("span",null,o?"Effective prices":"实际单价"),e("small",null,o?"Price × multiplier / 1M tokens":"单价 × 倍率 / 百万 Token")),...f.map(([d,M])=>e("div",{key:d,className:"cm-effective-tier","data-effective-tier":d},f.length>1?e("span",null,M):null,e("div",{className:"cm-effective-grid"},...w.slice(0,3).map(([N,k])=>e("div",{key:N},e("span",null,k),e("strong",null,(c.currency==="CNY"?"¥":"$")+Number((se(d==="base"?c:c[d],N)*h(c,d+"."+N)).toPrecision(8)).toLocaleString(o?"en-US":"zh-CN",{maximumFractionDigits:8})))))))),e("details",{className:"cm-custom-more"},e("summary",null,o?"More billing fields":"更多计费项"),e("div",{className:"cm-custom-grid"},...w.slice(3).map(u)),e(Ue,{value:c,label:a,locale:r,onChange:s,t:i,priceEditor:n,fields:w}),e("p",{className:"cm-hint"},o?"Leave reasoning blank when it is included in output. Leave cache write blank to use the cached input rate.":"推理已包含在输出中时无需另填。缓存写入留空则使用缓存读取价格。")),e("p",{className:"cm-hint"},g?o?"Edit the copied values, then save to apply them to this model.":"可继续调整复制的数值,保存后应用到当前模型。":o?"Enter or leave a field to save. Switching the price source keeps your custom values.":"回车或离开输入框后保存;切换价格来源会保留已填的自定义价格。"))}function Pe({entry:t,currency:a,priceEditor:r,locale:p,local:i=!1}){const n=p==="en",x=t?r?.priceAt?.(t)??t:null;return e("span",{className:"cm-rate-summary"},...[["cacheMiss","input",n?"Input":"输入"],["cacheHit","cachedInput",n?"Cached input":"缓存读取"],["output","output",n?"Output":"输出"]].map(([g,l,c])=>{const s=i?0:x?.unpriced?null:x?.[g]??x?.[l],h=s==null?null:s*(r?.priceFactor?.(x??{},"base."+g)??1);return e("span",{key:g,className:"cm-rate-item"},e("span",null,c),e("strong",null,h===null?"—":(a==="CNY"?"¥":"$")+Number(h.toPrecision(8)).toLocaleString(n?"en-US":"zh-CN",{maximumFractionDigits:8})))}))}function Be({state:t,draft:a,setDraft:r,locale:p}){if(t.ourFreeModel?.enabled!==!0)return null;const i=p==="en",n=a?.priceOverrides??t.config.priceOverrides??{},x=["our-free-model:*","our-free-model-region:*"],o=x.every(g=>n[g]==="__free__");return e("section",{className:"cm-free-model","aria-label":"dsh-our-free-model"},e("label",{className:"cm-check"},e("input",{type:"checkbox",role:"switch",checked:o,onChange:g=>{if(!a)return;const l={...n};for(const c of x)g.target.checked?l[c]="__free__":l[c]==="__free__"&&delete l[c];r({...a,priceOverrides:l})}}),e("span",null,i?"Count dsh-our-free-model calls as free":"dsh-our-free-model 调用按免费计算")),e("p",{className:"cm-hint"},i?"Future calls through this plugin cost 0; tokens are still counted. Historical costs and other providers stay unchanged.":"仅此插件后续调用记为免费,Token 照常统计;历史费用和其他渠道不变。"))}function Fe({state:t,draft:a,setDraft:r,t:p,locale:i,resolveClientPrice:n,prettyProviderKey:x,setField:o,priceEditor:g}){const[l,c]=A(""),[s,h]=A(24),[w,u]=A(null),[f,d]=A({}),M=ne(new Map),N=ne(null),k=i==="en",C=t.config,T=a?.priceOverrides??C.priceOverrides??{},O=a?.priceMatchDismissed??C.priceMatchDismissed??[],_=a?.prices??C.prices,U=J(()=>Object.entries(_.custom??{}).filter(([,m])=>m&&!m.unpriced).map(([m,S])=>({value:m,label:x(m),price:S})).sort((m,S)=>m.label.localeCompare(S.label)),[_.custom,x]),W=a?.modelStatistics??C.modelStatistics??{},B=[["today","今日费用","Today"],["summary","月度与累计","Monthly / all-time"],["budget","预算","Budget"]],y=J(()=>({...t.total?.byProviderModel,...t.month?.byProviderModel,...t.today?.byProviderModel,...Object.fromEntries(Object.keys(W).map(m=>[m,null]))}),[t.total?.byProviderModel,t.month?.byProviderModel,t.today?.byProviderModel,W]),D=t.modelDirectory,Y=J(()=>[...new Set([...Object.keys(y),...Object.keys(T)])].filter(m=>{if(O.includes(m)||Ie(m)||["our-free-model:*","our-free-model-region:*"].includes(m))return!1;if(!Array.isArray(D?.providers))return!0;const S=m.slice(0,m.indexOf(":"));return D.providers.includes(S)&&!D.missingModels?.includes(m)}).sort(),[y,T,O,D]);ue(()=>{const m=M.current.get(N.current)?.querySelector(".cm-custom-price");m&&(N.current=null,m.scrollIntoView({block:"start",inline:"nearest"}),m.querySelector("input")?.focus({preventScroll:!0}))},[_,f]);const b=J(()=>[{value:"deepseek:__default__",label:p("overrideTargetDefault")},...Object.keys(_.models??{}).map(m=>({value:"deepseek:"+m,label:"DeepSeek · "+m})),...Object.entries(_.providers??{}).flatMap(([m,S])=>Object.keys(S?.models??{}).map(j=>({value:m+":"+j,label:m+" · "+j})))],[_.models,_.providers,i,p]),E=(m,S)=>{if(a===null)return;const j={...a.priceOverrides??{}};if(S===""?delete j[m]:j[m]=S,S==="__custom__"&&!_.custom?.[m]){const L=m.indexOf(":"),q=n(m.slice(0,L),m.slice(L+1),{...C,...a}),R=q.entry??{},$={...R,currency:q.currency??"USD",billingMode:R.billingMode==="deepseek-peak"?"deepseek-peak":"flat",...g?.priceMultiplierSettings(R),cacheMiss:R.cacheMiss??R.input??0,cacheHit:R.cacheHit??R.cachedInput??R.cacheMiss??R.input??0,output:R.output??0,...R.cacheWrite!==void 0?{cacheWrite:R.cacheWrite}:{},...R.reasoning!==void 0?{reasoning:R.reasoning}:{}};delete $.unpriced,r({...a,priceOverrides:j,prices:{..._,custom:{..._.custom,[m]:$}}})}else r({...a,priceOverrides:j})},F=m=>{if(a===null)return;const S={...a.priceOverrides??{}};delete S[m],r({...a,priceOverrides:S,priceMatchDismissed:[...new Set([...O,m])]})},Q=l.trim().toLowerCase().split(/\s+/).filter(Boolean),v=(m=>m.filter(S=>Q.every(j=>(S+" "+x(S)).toLowerCase().includes(j))))(Y),P=v.length,I=v.slice(0,s),H=m=>{const S=x(m),j=S.indexOf(":"),L=T[m],q=w===m,R=f[m]??(L==="__custom__"?"custom":L==="__local__"?"local":L?"catalog":"auto"),$=m.indexOf(":"),ae=n($>0?m.slice(0,$):"deepseek",$>0?m.slice($+1):m,{...C,...a}),V=!L&&ae.matched===!0,_e=z=>{z==="custom"&&(N.current=m),d({...f,[m]:z}),z!=="catalog"&&E(m,z==="custom"?"__custom__":z==="local"?"__local__":"")},Oe=B.filter(([z])=>W[m]?.[z]!==!1),Je=(z,G)=>{if(!a)return;const X={...W,[m]:{today:!0,summary:!0,budget:!0,...W[m],[z]:G}};Object.values(X[m]).every(Boolean)&&delete X[m],r({...a,modelStatistics:X})},Qe=V?k?"Automatic":"自动匹配":L==="__custom__"?k?"Custom price":"自定义价格":L==="__local__"?k?"Local · free":"本地 · 零费用":L?k?"Price table":"指定价格表":k?"Needs a price":"待设置价格";return e("div",{key:m,className:"cm-match-row","data-model-key":m,"data-open":q,ref:z=>{z?M.current.set(m,z):M.current.delete(m)}},e("div",{className:"cm-model-head"},e("div",{className:"cm-model-identity",title:S},e("strong",null,j>0?S.slice(j+1):S),e("span",{className:"cm-model-meta"},e("span",{className:"cm-model-provider"},j>0?S.slice(0,j):"DeepSeek"),e("span",{className:"cm-model-badge"+(!V&&!L?" needs-price":"")},Qe))),e("div",{className:"cm-model-current",title:k?"Effective rates per 1M tokens, including multipliers":"每百万 Token 实际单价,已含倍率"},e(Pe,{entry:ae.entry,currency:ae.currency,priceEditor:g,locale:i,local:L==="__local__"})),e("button",{type:"button",className:"cm-btn small cm-model-edit","aria-expanded":q,"aria-label":S+(k?" · Set price":" · 设置价格"),onClick:()=>u(q?null:m)},q?k?"Collapse":"收起":k?"Set price":"设置价格")),e("details",{className:"cm-model-statistics","data-model-statistics":m},e("summary",null,k?"Include in statistics":"计入统计",Oe.length===3?null:e("span",{className:"cm-note"},Oe.map(([,z,G])=>k?G:z).join(" · ")||(k?"None":"均不计入"))),e("div",{className:"cm-model-statistics-options"},...B.map(([z,G,X])=>e("label",{key:z,className:"cm-check"},e("input",{type:"checkbox",checked:W[m]?.[z]!==!1,"aria-label":S+" · "+(k?X:G),onChange:Ge=>Je(z,Ge.target.checked)}),k?X:G)))),q?e("div",{className:"cm-model-editor"},e("div",{className:"cm-source-choices",role:"group","aria-label":k?"Price source":"价格来源"},...[["auto","自动匹配","Automatic"],["catalog","价格表","Price table"],["custom","自定义","Custom"],["local","本地","Local"]].map(([z,G,X])=>e("button",{key:z,type:"button",className:"cm-source-choice"+(R===z?" active":""),"aria-pressed":R===z,onClick:()=>_e(z)},k?X:G))),R==="catalog"?e("div",{className:"cm-model-source"},e("span",null,k?"Select a reference model":"选择参考模型"),e(le,{value:L&&!L.startsWith("__")?L:"",options:b,placeholder:k?"Choose a price table entry":"选择价格表条目",label:S,locale:i,onChange:z=>{z?E(m,z):_e("auto")}}),!L||L.startsWith("__")?e("p",{className:"cm-note"},k?"Current pricing stays in effect until you choose an entry.":"选定条目后生效,选择前仍使用原价格。"):null):null,R==="custom"&&L==="__custom__"&&_.custom?.[m]?e(We,{value:_.custom[m],label:S,locale:i,t:p,priceEditor:g,templates:U.filter(z=>z.value!==m),onChange:z=>r({...a,prices:{..._,custom:{..._.custom,[m]:z}}})}):null,R==="auto"?e("p",{className:"cm-source-explanation"},ae.matched?k?"The model uses its automatically matched reference price.":"已自动匹配参考价格,后续调用按该价格计费。":k?"No exact price found. Choose a table entry or enter a custom quote.":"尚未命中参考价格,可选择价格表条目或填写自定义价格。"):null,R==="local"?e("p",{className:"cm-source-explanation"},k?"Tokens are tracked; new calls have zero API cost.":"保留 Token 统计,后续调用的 API 费用记为 0。"):null,V?null:e("button",{type:"button",className:"cm-model-dismiss",title:p("removePriceMatchHint"),onClick:()=>F(m)},p("overrideRemove"))):null)};return e("div",{className:"cm-model-matching"},e(Be,{state:t,draft:a,setDraft:r,locale:i}),e("div",{className:"cm-model-toolbar"},e("input",{type:"search",className:"cm-input",value:l,placeholder:k?"Find a model or channel…":"查找模型或渠道…","aria-label":k?"Find configured models":"查找已用模型",onChange:m=>{c(m.target.value),h(24)},onKeyDown:m=>{m.key==="Escape"&&(c(""),h(24),m.stopPropagation())}}),e("span",{className:"cm-note",role:"status"},k?`${P} models`:`${P} 个模型`)),I.length?e("div",{className:"cm-model-list"},e("div",{className:"cm-model-columns","aria-hidden":!0},e("span",null,k?"Model / channel":"模型 / 渠道"),e("span",{className:"cm-rate-summary"},...[k?"Input":"输入",k?"Cached input":"缓存读取",k?"Output":"输出"].map(m=>e("span",{key:m},m))),e("span",{title:k?"Per 1M tokens":"每百万 Token"},"/ 1M tok")),...I.map(H)):null,P===0?e("p",{className:"cm-pricing-empty"},l?k?"No models found. Try another keyword.":"没有找到模型,试试其他关键词。":k?"Models appear here after their first call.":"调用过的模型会显示在这里,之后可按渠道设置价格。"):null,P>s?e("button",{type:"button",className:"cm-btn",onClick:()=>h(m=>m+24)},k?`Show more · ${P-s} remaining`:`显示更多 · 还有 ${P-s} 个`):null,O.length>0?e("button",{type:"button",className:"cm-btn small",onClick:()=>o("priceMatchDismissed",[])},p("restorePriceMatches",{count:O.length})):null,e("details",{className:"cm-pricing-rules"},e("summary",null,k?"Automatic matching rules":"自动匹配规则"),e("label",{className:"cm-field"},e("span",null,p("priceMatchLabel")),e("select",{className:"cm-input",value:a?.priceMatch==="exact"?"exact":"auto",onChange:m=>o("priceMatch",m.target.value)},e("option",{value:"auto"},p("priceMatchAuto")),e("option",{value:"exact"},p("priceMatchExact")))),e("p",{className:"cm-note"},p("priceMatchNote"))))}function Ae({open:t,className:a}){return e("svg",{className:"cm-pricing-chevron "+a+(t?" is-open":""),width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0},e("path",{d:"m9 5 7 7-7 7"}))}function Ye({state:t,draft:a,setDraft:r,t:p,locale:i,rpc:n,renderEditor:x,vendorLabels:o,priceEditor:g}){const l=i==="en",[c,s]=A(""),[h,w]=A(""),[u,f]=A({}),[d,M]=A({}),[N,k]=A(null),[C,T]=A(""),O=a?.prices??t.config.prices,_=J(()=>({...O.providers,deepseek:{models:{...O.models,__default__:O.default}}}),[O.models,O.default,O.providers]),U=Object.keys(_).filter(b=>Object.keys(_[b]?.models??{}).length).sort((b,E)=>b===E?0:b==="deepseek"?-1:E==="deepseek"?1:b.localeCompare(E)),W=c.toLowerCase().trim().split(/\s+/).filter(Boolean),B=U.filter(b=>!h||h===b).map(b=>({id:b,ids:Object.keys(_[b].models).filter(E=>W.every(F=>(b+" "+(o[b]??"")+" "+(E==="__default__"?p("defaultModelId"):E)).toLowerCase().includes(F))).sort((E,F)=>E===F?0:E==="__default__"?1:F==="__default__"?-1:E.localeCompare(F))})).filter(b=>b.ids.length),y=B.reduce((b,E)=>b+E.ids.length,0),D=b=>{s(b),M({}),f({})},Y=()=>{const b=C.trim().toLowerCase();!a||!/^[a-z0-9_.-]+$/.test(b)||Object.hasOwn(O.models,b)||(r({...a,prices:{...O,models:{...O.models,[b]:{cacheHit:0,cacheMiss:0,output:0}}}}),T(""),w("deepseek"),s(b),f(E=>({...E,deepseek:!0})),k("deepseek:"+b))};return e("div",{className:"cm-reference-prices"},e("p",{className:"cm-note"},l?"Base rates include multipliers. Open a model to edit rates, currencies and peak/off-peak tiers.":"列表展示含倍率的基础单价。点开模型可编辑币种、单价和峰谷档位。"),e("div",{className:"cm-catalog-toolbar"},e("input",{type:"search",className:"cm-input",value:c,"aria-label":l?"Search mounted prices":"搜索已挂载价格",placeholder:l?"Search models or providers…":"搜索模型或厂商…",onChange:b=>D(b.target.value),onKeyDown:b=>{b.key==="Escape"&&(D(""),b.stopPropagation())}}),e("select",{className:"cm-input",value:h,"aria-label":l?"Filter price provider":"筛选价格厂商",onChange:b=>{w(b.target.value),M({}),f({})}},e("option",{value:""},l?"All providers":"全部厂商"),...U.map(b=>e("option",{key:b,value:b},o[b]??b))),e("span",{className:"cm-note",role:"status"},l?`${y} models`:`${y} 个模型`)),...B.map(({id:b,ids:E})=>{const F=u[b]??(b==="deepseek"||W.length>0||h===b),Q=b==="deepseek"?O.currency??"USD":"USD",K=d[b]??16;return e("section",{key:b,className:"cm-catalog-group"},e("button",{type:"button",className:"cm-catalog-vendor cm-vendor-toggle","aria-expanded":F,onClick:()=>f(v=>({...v,[b]:!F}))},e("span",null,e(Ae,{className:"cm-catalog-caret",open:F}),o[b]??b,e("small",null,E.length)),e("span",{className:"cm-catalog-unit"},Q+(l?" / 1M tokens":" / 百万 Token"))),F?e("div",{className:"cm-catalog-list"},e("div",{className:"cm-catalog-columns","aria-hidden":!0},...[l?"Model":"模型",l?"Input":"输入",l?"Cached input":"缓存读取",l?"Output":"输出",""].map((v,P)=>e("span",{key:P},v))),...E.slice(0,K).map(v=>{const P=b+":"+v,I=_[b].models[v],H=N===P,m=v==="__default__"?p("defaultModelId"):v,S=I?.peak||I?.offPeak?l?"Peak / off-peak":"含峰谷价格":I?.longContext?l?"Long context":"含长上下文档位":I?.cny?l?"USD + CNY":"美元 / 人民币":null;return e("div",{key:P,className:"cm-catalog-entry"+(H?" editing":"")},e("button",{type:"button",className:"cm-catalog-model","aria-label":m+(l?" · Edit price":" · 编辑价格"),"aria-expanded":H,onClick:()=>k(H?null:P)},e("span",{className:"cm-catalog-model-name"},e("strong",null,m),S?e("small",null,S):null),e(Pe,{entry:I,currency:Q,priceEditor:g,locale:i}),e(Ae,{className:"cm-catalog-edit-caret",open:H})),H?e("div",{className:"cm-catalog-editor"},x(b,v,I),e(Se,{value:I,locale:i,t:p,priceEditor:g,label:m,currency:Q,defaults:O.providers?.[b]?.peakWindows??a.peakWindows,onChange:j=>{const L=b==="deepseek"?{...O,...v==="__default__"?{default:j}:{models:{...O.models,[v]:j}}}:{...O,providers:{...O.providers,[b]:{...O.providers[b],models:{...O.providers[b].models,[v]:j}}}};r({...a,prices:L})}})):null)}),E.length>K?e("button",{type:"button",className:"cm-catalog-more",onClick:()=>M(v=>({...v,[b]:K+16}))},l?`Show more · ${E.length-K} remaining`:`显示更多 · 还有 ${E.length-K} 个`):null):null)}),y===0?e("p",{className:"cm-pricing-empty"},l?"No matching models.":"没有找到匹配的模型。"):null,e("details",{className:"cm-pricing-rules"},e("summary",null,l?"Pricing notes":"计价说明"),e("p",{className:"cm-note"},p("priceTableNote"))),e("details",{className:"cm-catalog-manage"},e("summary",null,l?"Add or restore models":"添加与恢复模型"),e("div",{className:"cm-catalog-add"},e("input",{className:"cm-input",value:C,"aria-label":p("newModelPlaceholder"),placeholder:p("newModelPlaceholder"),onChange:b=>T(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),Y())}}),e("button",{type:"button",className:"cm-btn small",disabled:!/^[a-z0-9_.-]+$/.test(C.trim().toLowerCase())||Object.hasOwn(O.models,C.trim().toLowerCase()),onClick:Y},p("addModel"))),e(Ne,{state:t,draft:a,setDraft:r,locale:i,rpc:n})))}function $e({state:t,locale:a,formatMoneyUsd:r,api:p,rpc:i,disabled:n}){const[x,o]=A(!1),[g,l]=A(!1),[c,s]=A(""),[h,w]=A([]),[u,f]=A(""),[d,M]=A(""),N=a==="en",k=(y,D)=>{const Y=t.config.currency==="CNY"?"Cny":t.config.currency==="EUR"?"Eur":"",b=Y&&y[D+Y],E=Number(t.config.exchangeRate);return r(typeof b=="number"&&E>0?b/E:y[D],t.config)},C=N?"All models":"全部模型",T=N?{usage:"Usage differs",ledgerModelMissing:"Model missing from ledger",logModelMissing:"Model missing from logs",dayModelMissing:"Model missing from daily totals",logMissing:"No replayable logs"}:{usage:"用量不一致",ledgerModelMissing:"账本缺少此模型",logModelMissing:"日志缺少此模型",dayModelMissing:"当日汇总缺少此模型",logMissing:"无可回放日志"},O=y=>y.skippedDetails?.length?e("details",{key:y.at,className:"cm-repricing-skipped"},e("summary",null,new Date(y.at).toLocaleString(a)+" · "+y.skipped+(N?" unchanged":" 条未重算")),e("ul",null,...y.skippedDetails.map((D,Y)=>e("li",{key:Y},e("div",null,[D.sessionId,D.date,D.model].filter(Boolean).join(" · ")),e("div",null,T[D.reason]),...D.fields.map(b=>e("div",{key:b.field},`${b.field}: ${N?"ledger":"账本"} ${b.ledger} − ${N?"log":"日志"} ${b.log} = ${b.ledger-b.log}`)))))):null,_=J(()=>[...new Set([t.today,t.month,...t.history??[]].flatMap(y=>Object.keys(y?.byProviderModel??{})))].filter(y=>y.indexOf(":")>0).sort(),[t.today,t.month,t.history]),U=J(()=>[{value:"",label:C},..._.map(y=>({value:y,label:y}))],[_,C]),W=()=>i("getRepricingHistory").then(y=>{w(ce.parse(y)),f("")}).catch(y=>f(String(y.message??y)));ie(()=>{let y=!0;return i("getRepricingHistory").then(D=>{y&&w(ce.parse(D))},D=>{y&&f(String(D.message??D))}),()=>{y=!1}},[i]);const B=async()=>{if(!(!x||g||n)){l(!0),f(""),s("");try{const y=d?await i("repriceModelHistory",!0,d):await i("repriceHistory",!0);if(!y.ok)throw new Error(y.message);s(y.message),o(!1),await W(),await p.reload()}catch(y){f(String(y.message??y))}finally{l(!1)}}};return e("section",{className:"cm-repricing"},e("h3",{className:"cm-h"},N?"Historical pricing":"历史费用"),e("p",{className:"cm-note"},N?"Rate changes apply to new calls. Recorded historical rates remain fixed.":"修改价格只影响后续调用,历史费用沿用原价格。"),e("div",{className:"cm-repricing-scope"},e("label",null,N?"Recalculation scope":"重算范围"),e(le,{options:U,value:d,locale:a,label:N?"Choose channel and model":"选择渠道与模型",ariaLabel:N?"Choose channel and model":"选择渠道与模型",placeholder:N?"Search historical models":"搜索历史渠道或模型",onChange:y=>{g||(M(y),o(!1),s(""))}}),e("p",{className:"cm-hint"},d?N?"Only this channel/model changes. Other models and original exchange rates remain unchanged.":"仅重算此渠道下的这个模型,其他模型及原调用汇率保持不变。":N?"Choose a single channel/model to limit the recalculation.":"可选择单个渠道模型,缩小重算范围。")),x?e("div",{className:"cm-repricing-warning",role:"alert",onKeyDown:y=>{y.key==="Escape"&&!g&&(o(!1),y.stopPropagation())}},e("strong",null,(d||C)+(N?" · Historical amounts will change":" · 将修改历史费用")),e("p",null,N?"Recalculate retained calls using current rates and replace their amounts in statistics. Original amounts, price versions and a full ledger backup are kept. Records with incomplete logs are unchanged.":"确认后,将按当前价格重新计算保留的历史调用,并更新统计金额。原金额、原价格版本和完整账本备份都会保留;日志不完整的记录不改。"),e("div",{className:"cm-buttons"},e("button",{type:"button",className:"cm-btn",disabled:g,onClick:()=>o(!1)},N?"Cancel":"取消"),e("button",{type:"button",className:"cm-btn danger",disabled:g||n,onClick:B},g?N?"Recalculating…":"正在重算…":N?"Confirm recalculation":"确认重算"))):e("button",{type:"button",className:"cm-btn",disabled:n||g,onClick:()=>o(!0)},d?N?"Recalculate this model":"重算此模型的历史费用":N?"Recalculate history at current rates":"按当前价格重算历史"),c?e("p",{role:"status",className:"cm-note"},c):null,u?e("p",{role:"alert",className:"cm-err"},u):null,h.length?e("details",{className:"cm-repricing-history"},e("summary",null,N?"Recalculation records · original amounts retained":"重算记录 · 原金额已保留"),e("div",{className:"cm-stat-scroll"},e("table",{className:"cm-stat-table"},e("thead",null,e("tr",null,...(N?["Time","Scope","Before","After","Session/day records"]:["重算时间","范围","原金额","重算后","会话日期记录"]).map(y=>e("th",{key:y,scope:"col"},y)))),e("tbody",null,...h.map(y=>e("tr",{key:y.at},e("td",null,new Date(y.at).toLocaleString(a)),e("td",null,y.model||C),e("td",null,k(y,"before")),e("td",null,k(y,"after")),e("td",null,y.sessions)))))),...h.map(O)):null)}function Ze({state:t,draft:a,setDraft:r,locale:p}){const i=a??t.config,n=(s,h)=>p==="en"?h:s,x=Object.keys(t.total?.byProviderModel??{}).filter(s=>s.indexOf(":")>0).map(s=>s.slice(0,s.indexOf(":"))),o=[...new Set([...x,...Object.keys(i.planBilling?.providers??{})])],[g,l]=A(x[0]??"go"),c=o.includes(g)?g:o[0]??"go";return e("section",{className:"cm-budget","data-provider-billing":!0},e("h3",{className:"cm-h"},n("渠道计费方式","Channel billing")),e("div",{className:"cm-grid"},e("label",{className:"cm-field"},e("span",null,n("渠道","Channel")),e("select",{className:"cm-input","aria-label":n("计费渠道","Billing channel"),value:c,onChange:s=>l(s.target.value)},o.map(s=>e("option",{value:s,key:s},s==="go"?"OpenCode Go (go)":s)))),e("label",{className:"cm-field"},e("span",null,n("计费方式","Billing type")),e("select",{className:"cm-input","aria-label":n("渠道计费方式","Channel billing type"),value:i.planBilling?.providers?.[c]??"auto",disabled:a==null,onChange:s=>r({...i,planBilling:{...i.planBilling,providers:{...i.planBilling?.providers,[c]:s.target.value}}})},[["auto",n("自动","Automatic")],["plan",n("Plan 订阅","Plan subscription")],["api",n("API 按量","Metered API")]].map(([s,h])=>e("option",{value:s,key:s},h))))),e("p",{className:"cm-note"},n("适用于该渠道的所有模型,模型单独设置优先。修改后更新历史 API/Plan 归属,保留 Token 和 API 等值金额。额度查询开关单独控制。","Applies to all models on this channel; model overrides take priority. Changes update historical API/Plan classification while preserving tokens and API-equivalent amounts. Quota queries are controlled separately.")))}function qe({state:t,t:a,formatMoneyUsd:r,formatTokens:p,helpers:i}){const{Card:n,displayCostOf:x}=i,o=t.externalUsage;if(!o)return null;const g=t.config,l=u=>r(x(u,g),g),c=u=>a("callsTokens",{calls:u.calls,input:p(u.input),cache:p(u.cacheRead+u.cacheWrite),output:p(u.output)}),s=(u,f)=>({calls:u.calls+f.calls,input:u.input+f.input,output:u.output+f.output,cacheRead:u.cacheRead+f.cacheRead,cacheWrite:u.cacheWrite+f.cacheWrite,cost:x(u,g)+f.cost,apiCost:x(u,g)+f.cost}),h=(u,f)=>e("tr",{key:u},e("td",null,u),e("td",{className:"num"},String(f.calls)),e("td",{className:"num"},p(f.input)),e("td",{className:"num"},p(f.cacheRead+f.cacheWrite)),e("td",{className:"num"},p(f.output)),e("td",{className:"num"},l(f))),w=u=>e("div",{className:"cm-scroll"},e("table",{className:"cm-table"},e("thead",null,e("tr",null,e("th",null,a("colDate")),...["colCalls","colInTok","colCacheTok","colOutTok","colCost"].map(f=>e("th",{className:"num"},a(f))))),e("tbody",null,u)));return e("section",{className:"cm-budget"},e("h3",{className:"cm-h"},a("externalUsage")),o.stale?e("p",{className:"cm-note"},a("externalStale")):null,e("div",{className:"cm-cards"},["today","month","total"].map((u,f)=>{const d=s(t[u],o.combined[u]);return e(n,{key:u,title:a("combinedUsage")+" · "+a(["cardToday","cardMonth","cardTotal"][f]),value:l(d),sub:c(d)})})),...o.sources.map(u=>e("details",{key:u.source},e("summary",null,u.source+" · "+a("cardToday")+" "+l(u.today)+" · "+a("cardMonth")+" "+l(u.month)+" · "+c(u.today)),w(["today","month","total"].map((f,d)=>h(a(["cardToday","cardMonth","cardTotal"][d]),u[f]))),e("p",{className:"cm-note"},a("externalHistory")),w(u.history.map(f=>h(f.date,f))))))}function Ke({state:t,onPrices:a}){const r=t.config,p=(r.locale==="auto"?r.activeLocale:r.locale)==="en",i=(o,g)=>p?g:o,n=r.prices?.currency==="CNY"?"CNY":"USD",x=r.currency==="CNY"&&n==="USD";return e("details",{className:"cm-note","data-billing-check":!0,open:x||void 0},e("summary",null,i("计费核对","Check billing")),e("p",null,i("当前 DeepSeek 价表:","Active DeepSeek price table: ")+n+i(";显示币种:","; display currency: ")+r.currency),x?e("p",{"data-billing-currency-mismatch":!0},i("当前金额由美元单价换算,美元价 × 汇率不等于官网人民币报价。按人民币账单核对时,请选择人民币官方价并同步;只切换显示币种不会更换价表。","Amounts currently convert USD rates. USD rates × exchange rate differ from official CNY prices. To compare with a CNY bill, select CNY official prices and sync them; changing the display currency does not change the price table.")):null,r.pricingCurrency!==n?e("p",null,i("所选同步币种尚未生效,当前仍使用 ","The selected sync currency is not active yet; billing still uses ")+n):null,e("p",null,i("金额口径:","Cost basis: ")+i(r.showTotalWithPlan?"含套餐 API 等值,不等于账户扣款。":"API 费用;套餐等值已排除。",r.showTotalWithPlan?"Includes subscription API-equivalent costs, not account deductions.":"API costs; subscription equivalents are excluded.")),e("p",null,i("核对时使用同一账户、渠道和时段;费用明细可查看每次调用的缓存、输出、费率和搜索请求费。自定义价格、倍率与历史价表也会影响金额。","Compare the same account, provider and time range. Cost details show each call’s cache, output, rates and search request fees. Custom prices, multipliers and historical rates also affect totals.")),a?e("button",{type:"button",className:"cm-btn small",onClick:a},i("查看并同步官方价表","Review and sync official prices")):null)}async function Ve(t){const a=await t.get("remote").$mount(ke);t.effect(()=>()=>a(),"cost-meter: pricing settings contribution");const r=t.get("remote.costMeter"),p=async(n,...x)=>{(n==="repriceHistory"||n==="repriceModelHistory")&&fe.parse(x[0]),n==="repriceModelHistory"&&ve.parse(x[1]);const o=await r[n](...x);if(o?.ok!==!0)throw new Error(o?.error?.message??"Pricing request failed");return(n==="getPriceCatalog"?we:n==="getRepricingHistory"?ce:he).parse(o.value)},i=document.createElement("style");return i.textContent=".cm-repricing-scope{display:grid;gap:8px;max-width:620px;margin:16px 0}.cm-repricing-scope>label{font-size:13px;color:var(--dsw-alias-label-secondary)}.cm-repricing-scope .cm-hint{margin:0;line-height:1.6}",i.textContent+=".cm-price-search{display:grid;gap:6px;min-width:0}.cm-price-search small{color:var(--dsw-alias-label-tertiary)}.cm-price-search select,.cm-price-search input{width:100%;min-width:0}.cm-repricing-warning{padding:12px;border:1px solid var(--dsw-alias-state-warn-primary,#c58a25);border-radius:10px;background:var(--dsw-alias-bg-layer-1)}.cm-repricing-warning p{margin:8px 0 12px;line-height:1.6}.cm-repricing-history{margin-top:12px}.cm-repricing-history table{width:100%;text-align:left;font-variant-numeric:tabular-nums}.cm-repricing-history td,.cm-repricing-history th{padding:8px;border-bottom:1px solid var(--dsw-alias-border-l1)}",i.textContent+=".cm-repricing-history .cm-stat-scroll{overflow-x:auto;max-width:100%}.cm-repricing-history table{min-width:560px}.cm-repricing-history th{white-space:nowrap}.cm-repricing-history td:nth-child(2){min-width:150px;max-width:260px;overflow-wrap:anywhere}",i.textContent+=".cm-repricing-skipped{margin-top:12px;overflow-wrap:anywhere}.cm-repricing-skipped summary{cursor:pointer}.cm-repricing-skipped ul{padding-left:18px}.cm-repricing-skipped li+li{margin-top:12px}",i.textContent+=".cm-pricing-page .cm-free-model{margin:0 0 12px;padding:10px 12px;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;background:transparent}.cm-pricing-page .cm-free-model>.cm-check{display:flex;align-items:center;gap:8px;margin:0;font-size:12px;line-height:20px;color:var(--dsw-alias-label-primary)}.cm-pricing-page .cm-free-model input{flex:none;width:16px;height:16px;margin:0;accent-color:var(--dsw-alias-state-business-primary)}.cm-pricing-page .cm-free-model>.cm-hint{display:block;margin:4px 0 0 24px;font-size:11px;line-height:1.5}",i.textContent+=".cm-provider-schedules{margin:12px 0}.cm-provider-schedules>.cm-field{max-width:360px;margin:12px 0}.cm-peak-schedule,.cm-custom-more fieldset{min-width:0;margin:12px 0;padding:12px;border:1px solid var(--dsw-alias-border-l1);border-radius:8px}.cm-peak-schedule{display:grid;gap:12px}.cm-custom-more .cm-check{display:flex;align-items:center;gap:8px;margin:12px 0}.cm-custom-more .cm-check input{width:auto;flex:none;margin:0}.cm-peak-schedule legend{font-size:12px}.cm-peak-schedule .cm-hint{margin:0;line-height:1.6}",i.textContent+=".cm-custom-price{grid-column:1/-1;display:grid;gap:14px;margin:4px 0 12px;padding:16px;border:1px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-lg,12px);background:var(--dsw-alias-bg-layer-1);min-width:0}.cm-custom-price legend{padding:0 6px;font-weight:500;font-size:13px}.cm-custom-price label{display:grid;gap:7px;font-size:12px;min-width:0;color:var(--dsw-alias-label-secondary)}.cm-custom-price .cm-input{width:100%;min-width:0}.cm-custom-head{display:flex;justify-content:space-between;align-items:center;gap:12px;color:var(--dsw-alias-label-secondary);font-size:12px}.cm-custom-head label{display:flex;align-items:center;gap:8px}.cm-custom-head select{width:auto!important}.cm-custom-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}.cm-custom-amount{position:relative;display:block}.cm-custom-amount>span{position:absolute;inset-inline-start:11px;top:50%;transform:translateY(-50%);pointer-events:none;color:var(--dsw-alias-label-tertiary)}.cm-custom-amount input{padding-inline-start:28px}.cm-custom-more summary{cursor:pointer;font-size:12px;color:var(--dsw-alias-label-secondary)}.cm-custom-more .cm-custom-grid{grid-template-columns:repeat(2,minmax(0,1fr));margin:12px 0 8px}.cm-custom-price p{margin:0;line-height:1.6}@media(max-width:700px){.cm-custom-grid{grid-template-columns:1fr}.cm-custom-head{flex-wrap:wrap}}",document.head.appendChild(i),i.textContent+=`
1
+ ;(function(oe){const q=window.__ModuleLoader__,re=q[Symbol.for("@dsh-plugin/dsh-loader:load-wrap")];return(oe.id==="dsh-cost-meter"&&q.load===re?.ours&&typeof re.original=="function"?re.original:q.load).call(q,oe)})({id:"dsh-cost-meter",chunk:"client.pricing.js",factory:de=>{function oe(t){if(t==="auto")return!0;if(typeof t!="string"||!t||t.length>100||/^[+-]/.test(t))return!1;try{return new Intl.DateTimeFormat("en",{timeZone:t}),!0}catch{return!1}}function q(t){if(t?.peakTimeZone!=="auto"&&oe(t?.peakTimeZone))return t.peakTimeZone;try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function re(t){let a=[];try{a=Intl.supportedValuesOf("timeZone")}catch{}return[...new Set(["UTC",q({}),q(t),"Asia/Shanghai","Asia/Tokyo","Asia/Kolkata","Asia/Kathmandu","Europe/London","Europe/Berlin","America/New_York","America/Los_Angeles","Australia/Sydney",...a])].sort()}function ye(t,a,r,p){const i=new Date(p),n=Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),i.getUTCDate()),x=new Intl.DateTimeFormat(r,{timeZone:q(a),weekday:"short",hour:"2-digit",minute:"2-digit",hourCycle:"h23"});return(t??[]).map(o=>x.format(n+o.start*36e5)+"–"+x.format(n+(o.end<=o.start?o.end+24:o.end)*36e5)).join(", ")}function Te({config:t,onChange:a,locale:r}){const p=r==="en",i=q(t);return e("label",{className:"cm-field","data-display-option":"peak-timezone"},e("span",null,p?"Peak display timezone":"峰谷显示时区"),e("select",{className:"cm-input",value:t.peakTimeZone??"auto",onChange:n=>a(n.target.value),"aria-label":p?"Peak display timezone":"峰谷显示时区"},e("option",{value:"auto"},(p?"System timezone · ":"跟随系统 · ")+q({})),...re(t).map(n=>e("option",{key:n,value:n},n))),e("span",{className:"cm-hint"},(p?"Displaying in ":"当前显示:")+i+(p?". Daylight saving adjusts automatically. Provider billing periods stay unchanged.":"。自动处理夏令时,厂商计费时段保持不变。")))}const{createElement:e,Fragment:pe,useState:A,useEffect:ie,useLayoutEffect:ue,useMemo:V,useRef:ne,useId:ze}=de("react");let ge=null;try{ge=de("react-dom")?.createPortal??null}catch{}const De=["at","before","after","days","sessions","skipped"],Ee=t=>typeof t?.sessionId=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(t.date)&&typeof t.model=="string"&&["usage","auxiliaryUsage","dynamicQuote","ledgerModelMissing","logModelMissing","dayModelMissing","logMissing"].includes(t.reason)&&Array.isArray(t.fields)&&t.fields.every(a=>["input","output","cacheRead","cacheWrite","reasoning","calls"].includes(a?.field)&&Number.isFinite(a.ledger)&&a.ledger>=0&&Number.isFinite(a.log)&&a.log>=0),Ie=t=>["deepseek-official:deepseek-web-search","deepseek-official:deepseek-web-fetch","deepseek-official:deepseek-search-api","deepseek-official:deepseek-fetch-api","deepseek-official:deepseek-search-server"].includes(t),ce={parse:t=>{if(!Array.isArray(t)||!t.every(a=>De.every(r=>Number.isFinite(a?.[r])&&a[r]>=0)&&(a.model===void 0||typeof a.model=="string")&&(a.skippedDetails===void 0||Array.isArray(a.skippedDetails)&&a.skippedDetails.every(Ee))))throw new Error("Invalid recalculation history");return t}},he={parse:t=>{if(typeof t?.ok!="boolean"||typeof t?.message!="string")throw new Error("Invalid recalculation result");return t}},fe={parse:t=>{if(typeof t!="boolean")throw new Error("Expected confirmation");return t}},ve={parse:t=>{if(typeof t!="string"||t.length>2048||t.indexOf(":")<=0||t.endsWith(":")||/[\r\n]/.test(t))throw new Error("Expected channel/model");return t}},we={parse:t=>{if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Invalid price catalog");return t}},ee=(t,a)=>({mode:"strict",typeSymbol:"dsh-cost-meter#"+t,schema:a,create:()=>a}),ke={package:"dsh-cost-meter-pricing",face:"host",descriptors:[{id:"dsh-cost-meter#costMeter/getPriceCatalog",service:"costMeter",namespace:"costMeter",method:"getPriceCatalog",invocation:{kind:"direct"},parameters:[],result:ee("PriceCatalog",we)},{id:"dsh-cost-meter#costMeter/getRepricingHistory",service:"costMeter",namespace:"costMeter",method:"getRepricingHistory",invocation:{kind:"direct"},parameters:[],result:ee("RepricingHistory",ce)},{id:"dsh-cost-meter#costMeter/repriceHistory",service:"costMeter",namespace:"costMeter",method:"repriceHistory",invocation:{kind:"direct"},parameters:[{name:"confirmed",wire:"confirmed",source:"json",codec:ee("RepricingConfirmation",fe)}],result:ee("FetchPricesResult",he)},{id:"dsh-cost-meter#costMeter/repriceModelHistory",service:"costMeter",namespace:"costMeter",method:"repriceModelHistory",invocation:{kind:"direct"},parameters:[{name:"confirmed",wire:"confirmed",source:"json",codec:ee("RepricingConfirmation",fe)},{name:"model",wire:"model",source:"json",codec:ee("RepricingModel",ve)}],result:ee("FetchPricesResult",he)}]},Le=t=>(t.label+" "+t.value).toLowerCase();function le({options:t,value:a,placeholder:r,label:p,ariaLabel:i,locale:n,onChange:x}){const o=n==="en",g=ze(),l=g+"-list",[c,s]=A(""),[h,w]=A(!1),[u,f]=A(0),[d,M]=A(null),N=ne(null),k=ne(null),C=ne(null),T=t.find(v=>v.value===a),O=c.toLowerCase().trim().split(/\s+/).filter(Boolean),_=V(()=>t.map(v=>({option:v,search:Le(v)})),[t]),U=v=>{const P=v.toLowerCase().trim().split(/\s+/).filter(Boolean);return P.length?_.filter(I=>P.every(H=>I.search.includes(H))).map(I=>I.option):t},W=U(c),B=T&&!W.includes(T)?[T,...W]:W,y=Math.max(0,Math.min(u,B.length-1)),D=()=>{w(!1),s("")},Y=()=>{h||(M(null),s(""),f(Math.max(0,B.findIndex(v=>v.value===a))),w(!0))},b=v=>{v&&(v.value!==a&&x(v.value),D())},E=()=>{if(h&&c){s(""),f(0);return}a&&x(""),D()};ue(()=>{if(!h||typeof document>"u")return;const v=k.current,P=typeof window>"u"?null:window,I=()=>{const H=v?.getBoundingClientRect?.();if(!H||!P)return;const m=P.innerHeight,S=12,j=m-H.bottom-S,L=H.top-S,Z=j<180&&L>j,R=Math.max(60,Z?L:j),$=Math.max(0,Math.min(280,R,m-S*2)),ae=Math.max(S,Math.min(Z?H.top-$-6:H.bottom+6,m-$-S));M(Q=>Q&&Q.left===H.left&&Q.top===ae&&Q.width===H.width&&Q.maxHeight===$?Q:{left:H.left,top:ae,width:H.width,maxHeight:$})};if(I(),typeof P?.addEventListener=="function")return P.addEventListener("scroll",I,!0),P.addEventListener("resize",I),()=>{P.removeEventListener("scroll",I,!0),P.removeEventListener("resize",I)}},[h]),ie(()=>{if(!h||typeof document>"u"||typeof document.addEventListener!="function")return;const v=P=>{N.current?.contains?.(P.target)||C.current?.contains?.(P.target)||D()};return document.addEventListener("pointerdown",v,!0),()=>document.removeEventListener("pointerdown",v,!0)},[h]),ue(()=>{!h||!d||C.current?.querySelector?.('[data-active="true"]')?.scrollIntoView?.({block:"nearest"})},[h,y,d,c]);const F=v=>g+"-opt-"+v,J=O.length?W.length?o?`${W.length} matches`:`${W.length} 个结果`:B.length?o?"No matches · showing the current choice":"没有匹配的模型 · 下面是当前选择":o?"No matches":"没有匹配的模型":null,K=h?e("div",{ref:C,className:"cm-combo-panel",style:d??{visibility:"hidden"}},B.length?e("div",{className:"cm-combo-list",id:l,role:"listbox","aria-label":p},B.map((v,P)=>e("button",{key:v.value,id:F(P),type:"button",role:"option",className:"cm-combo-option"+(P===y?" active":""),"data-active":String(P===y),"aria-selected":String(v.value===a),onMouseEnter:()=>f(P),onMouseDown:I=>I.preventDefault(),onClick:()=>b(v)},v.label))):null,J?e("p",{className:"cm-combo-note",role:"status"},J):null):null;return e("div",{ref:N,className:"cm-price-search cm-combo"},e("div",{className:"cm-combo-control"},e("input",{ref:k,type:"search",className:"cm-input cm-combo-input",autoComplete:"off",value:h?c:T?.label??"",role:"combobox","aria-expanded":String(h),"aria-autocomplete":"list","aria-controls":h&&B.length?l:void 0,"aria-activedescendant":h&&B.length?F(y):void 0,"aria-label":i??p+(o?" · Price model":" · 价格模型"),placeholder:h&&T?T.label:r,onFocus:Y,onClick:()=>{h||Y()},onChange:v=>{const P=v.target.value,I=!h&&T&&P.startsWith(T.label)?P.slice(T.label.length):P,H=U(I);s(I),w(!0),f(T&&H.length>0&&!H.includes(T)?1:0)},onKeyDown:v=>{if(!v.nativeEvent?.isComposing){if(v.key==="Escape"){if(v.preventDefault(),!h)return;D(),v.stopPropagation();return}if(v.key==="ArrowDown"||v.key==="ArrowUp"){if(v.preventDefault(),!h){Y();return}f(Math.max(0,Math.min(B.length-1,y+(v.key==="ArrowDown"?1:-1))));return}if(v.key==="Enter"&&h&&B[y]){v.preventDefault(),b(B[y]);return}v.key==="Tab"&&D()}}}),a||c?e("button",{type:"button",className:"cm-combo-clear","aria-label":(o?"Clear ":"清空 ")+p,onMouseDown:v=>v.preventDefault(),onClick:E},"×"):null,e("button",{type:"button",className:"cm-combo-caret",tabIndex:-1,"aria-hidden":"true",onMouseDown:v=>v.preventDefault(),onClick:()=>{h?D():(k.current?.focus?.(),Y())}},"▾")),K&&ge?ge(K,document.body):K)}function Ne({state:t,draft:a,setDraft:r,locale:p,rpc:i}){const[n,x]=A(!1),[o,g]=A(null),[l,c]=A(""),[s,h]=A(""),[w,u]=A(0),f=t.config.prices.currency??"USD",d=p==="en";ie(()=>{if(!n)return;let C=!0;return g(null),h(""),c(""),i("getPriceCatalog").then(T=>{C&&g(T)},T=>{C&&h(String(T.message??T))}),()=>{C=!1}},[n,f,w,i]);const M=[];for(const[C,T]of Object.entries(o??{}))for(const O of Object.values(T))for(const[_,U]of Object.entries(O))!(C==="deepseek"?a?.prices.models[_]:a?.prices.providers?.[C]?.models?.[_])&&!U.unpriced&&M.push({value:C+":"+_,label:C+" · "+_,provider:C,id:_,entry:U});const N=M.find(C=>C.value===l),k=()=>{if(!N||!a)return;const{provider:C,id:T,entry:O}=N,_=JSON.parse(JSON.stringify(O)),U=a.prices;r({...a,prices:C==="deepseek"?{...U,models:{...U.models,[T]:_}}:{...U,providers:{...U.providers,[C]:{...U.providers?.[C],models:{...U.providers?.[C]?.models,[T]:_}}}}}),c("")};return e("div",{className:"cm-restore-prices"},e("button",{type:"button",className:"cm-btn small","aria-expanded":n,onClick:()=>x(C=>!C)},n?d?"Close restore":"收起恢复入口":d?"Restore bundled model":"恢复内置模型"),n?e("div",{className:"cm-collapse-body"},s?e("div",{role:"alert",className:"cm-err"},s,e("button",{type:"button",className:"cm-btn small",onClick:()=>u(C=>C+1)},d?"Retry":"重试")):o===null?e("p",{role:"status",className:"cm-hint"},d?"Loading prices…":"读取价格…"):M.length?e(pe,null,e(le,{options:M,value:N?l:"",placeholder:d?"Select a model":"选择模型",label:d?"Restore model":"恢复模型",locale:p,onChange:c}),e("button",{type:"button",className:"cm-btn small",disabled:!N,onClick:k},d?"Restore":"恢复")):e("p",{className:"cm-hint"},d?"All bundled models are mounted.":"内置模型均已挂载。")):null)}function Re(t){const{state:a,draft:r,setDraft:p,t:i}=t,{peakPhaseAt:n,resolveLocale:x,peakNoticeEl:o}=t.peakHelpers,g=a.config,l=(d,M)=>{r!==null&&p({...r,[d]:M})},c=r===null?g:{...g,...r},s=x(c)==="en"?"en":"zh-CN",h=q(c),w=d=>Number.isFinite(Date.parse(d))?new Intl.DateTimeFormat(s,{timeZone:h,dateStyle:"medium",timeStyle:"short"}).format(Date.parse(d)):i("unknown"),u=(()=>{if(c.peakEnabled!==!0)return i("peakOff");const d=Date.parse(c.peakEffectiveAt||""),M=Date.now();if(Number.isFinite(d)&&M<d)return i("peakNotEffective",{time:w(c.peakEffectiveAt)});const N=c.peakWindows??[],k=n(M,N,c.peakHolidays);return k===null?i("offPeakActive"):k.holiday===!0?i("holidayAllOffPeak"):k.weekend===!0?i("weekendAllOffPeak"):k.inPeak?i("peakActive"):i("offPeakActive")})(),f=(c.peakWindows?.length??0)>0?i("peakSummary",{windows:ye(c.peakWindows,c,s,Date.now()),zone:h,time:w(c.peakEffectiveAt),status:u}):i("noPeakWindows",{status:u});return e("div",{className:"cm-budget"},e(Te,{config:c,locale:s,onChange:d=>l("peakTimeZone",d)}),e("div",{className:"cm-budget-head"},e("h3",{className:"cm-h"},i("peakPanelTitle")),e("label",{className:"cm-check"},e("input",{type:"checkbox",checked:r?.peakEnabled!==!1,onChange:d=>l("peakEnabled",d.target.checked)}),e("span",null,i("peakEnabledLabel")))),e("div",{className:"cm-grid"},e("div",{className:"cm-field"},e("label",{className:"cm-check"},e("input",{type:"checkbox",checked:r?.peakNotice!==!1,onChange:d=>l("peakNotice",d.target.checked)}),e("span",null,i("peakNoticeLabel")))),e("div",{className:"cm-field"},e("label",null,i("peakStyleLabel")),e("select",{className:"cm-input",value:r?.peakStyle??"compact",onChange:d=>l("peakStyle",d.target.value)},e("option",{value:"progress"},x(r)==="en"?"Time progress":"时间进度条"),e("option",{value:"compact"},i("peakStyleCompact")),e("option",{value:"classic"},i("peakStyleClassic"))))),e("div",{className:"cm-grid"},e("div",{className:"cm-field"},e("label",{className:"cm-check"},e("input",{type:"checkbox",checked:r?.peakAlertEnabled!==!1,onChange:d=>l("peakAlertEnabled",d.target.checked)}),e("span",null,i("peakAlertLabel")))),e("div",{className:"cm-field"},e("label",null,i("peakAlertAheadLabel")),e("input",{className:"cm-input narrow",type:"number",min:"1",max:"30",step:"1",value:String(typeof r?.peakAlertAhead=="number"&&Number.isFinite(r.peakAlertAhead)&&r.peakAlertAhead>=1&&r.peakAlertAhead<=30?r.peakAlertAhead:2),onChange:d=>{const M=Number(d.target.value);Number.isInteger(M)&&M>=1&&M<=30&&l("peakAlertAhead",M)}})),e("div",{className:"cm-field"},e("label",null,i("peakAlertTargetLabel")),e("select",{className:"cm-input",value:r?.peakAlertTarget==="peak"||r?.peakAlertTarget==="offpeak"?r.peakAlertTarget:"both",onChange:d=>l("peakAlertTarget",d.target.value)},e("option",{value:"both"},i("peakAlertTargetBoth")),e("option",{value:"peak"},i("peakAlertTargetPeak")),e("option",{value:"offpeak"},i("peakAlertTargetOffPeak"))))),e("div",{className:"cm-grid"},e("div",{className:"cm-field"},e("label",null,i("peakAlertPositionLabel")),e("select",{className:"cm-input",value:r?.peakAlertPosition==="center"?"center":"corner",onChange:d=>l("peakAlertPosition",d.target.value)},e("option",{value:"corner"},i("peakAlertPositionCorner")),e("option",{value:"center"},i("peakAlertPositionCenter")))),e("div",{className:"cm-field"},e("label",{className:"cm-check"},e("input",{type:"checkbox",checked:r?.peakAlertWebNotify===!0,onChange:d=>{l("peakAlertWebNotify",d.target.checked),d.target.checked&&window.Notification&&Notification.permission==="default"&&Promise.resolve(Notification.requestPermission()).catch(()=>{})}}),e("span",null,i("peakAlertWebNotifyLabel"))),e("p",{className:"cm-hint"},i("peakAlertWebNotifyHint")))),e("div",{className:"cm-field"},e("label",null,i("peakAlertPreviewLabel")),e("div",{className:"cm-row"},e("button",{className:"cm-btn",onClick:()=>window.cmPeakAlertPreview?.("peak")},i("peakAlertPreviewPeak")),e("button",{className:"cm-btn",onClick:()=>window.cmPeakAlertPreview?.("offpeak")},i("peakAlertPreviewOffPeak")))),e("div",{className:"cm-peak-preview"},r?.peakEnabled!==!1&&r?.peakNotice!==!1?o(a,c,i):e("p",{className:"cm-hint"},i("peakNoticeHiddenHint"))),e("p",{className:"cm-hint"},f),e("div",{className:"cm-field"},e("label",null,i("peakHolidaysLabel")),e("input",{className:"cm-input",defaultValue:(c.peakHolidays??[]).join(", "),onBlur:d=>l("peakHolidays",d.target.value.split(/[,,\s]+/).filter(Boolean))})),e("p",{className:"cm-hint"},i("weekendRuleNote")))}function Ce({value:t,onChange:a,locale:r,defaults:p=[]}){const i=r==="en",n=t.peakWindows,x=w=>w.map(u=>u.start+"-"+u.end).join(", "),[o,g]=A(()=>x(n??p)),[l,c]=A("");ie(()=>g(x(n??p)),[JSON.stringify(n),JSON.stringify(p)]);const s=(w,u)=>{const f={...t};u===void 0?delete f[w]:f[w]=u,a(f)},h=()=>{const u=(o.trim()?o.split(/[,,]/).map(f=>f.trim()):[]).map(f=>{const d=f.match(/^(\d+(?:\.\d+)?)\s*-\s*(\d+(?:\.\d+)?)$/);return d?{start:Number(d[1]),end:Number(d[2])}:null});if(u.length>24||u.some(f=>!f||f.start>=24||f.end>24||f.start===f.end)){c(i?"Use UTC hours, e.g. 1-4, 6-10 or 22-2.":"填写 UTC 小时,例如 1-4, 6-10,跨午夜可填 22-2。");return}c(""),s("peakWindows",u)};return e("fieldset",{className:"cm-peak-schedule"},e("legend",null,i?"Peak schedule":"峰谷时段"),e("label",{className:"cm-check"},e("input",{type:"checkbox",checked:n!==void 0,onChange:w=>{c(""),s("peakWindows",w.target.checked?structuredClone(p):void 0)}}),i?"Override peak hours":"自定义峰时段"),n!==void 0?e("label",{className:"cm-field"},i?"Peak hours (UTC)":"峰时段(UTC)",e("input",{className:"cm-input",value:o,onChange:w=>g(w.target.value),onBlur:h,onKeyDown:w=>{w.key==="Enter"&&(w.preventDefault(),h())}})):null,e("label",{className:"cm-field"},i?"Calendar":"日历规则",e("select",{className:"cm-input","aria-label":i?"Calendar":"日历规则",value:t.peakSchedule??"",onChange:w=>s("peakSchedule",w.target.value||void 0)},...[["","沿用上级/渠道默认","Inherit channel/default"],["daily","每天","Every day"],["deepseek","北京时间工作日","Beijing weekdays"],["utc-weekdays","UTC 工作日","UTC weekdays"],["ollama","Ollama Cloud","Ollama Cloud"],["volcengine","火山方舟","Volcano Ark"]].map(([w,u,f])=>e("option",{key:w,value:w},i?f:u)))),e("label",{className:"cm-field"},i?"Holidays":"节假日",e("select",{className:"cm-input","aria-label":i?"Holidays":"节假日",value:t.peakHolidays===null?"none":Array.isArray(t.peakHolidays)?"custom":"inherit",onChange:w=>s("peakHolidays",w.target.value==="none"?null:w.target.value==="custom"?[]:void 0)},e("option",{value:"inherit"},i?"Inherit":"沿用上级/渠道默认"),e("option",{value:"none"},i?"No holiday table":"不使用节假日表"),e("option",{value:"custom"},i?"Custom dates":"自定义日期"))),Array.isArray(t.peakHolidays)?e("label",{className:"cm-field"},i?"Off-peak Beijing dates":"全天谷价日期(北京时间)",e("input",{className:"cm-input",key:JSON.stringify(t.peakHolidays),defaultValue:t.peakHolidays.join(", "),placeholder:"2026-11-01, 2026-11-02",onBlur:w=>{const u=w.target.value.split(/[,,\s]+/).filter(Boolean);if(u.length>366||u.some(f=>!/^\d{4}-\d{2}-\d{2}$/.test(f)||!Number.isFinite(Date.parse(f+"T00:00:00Z"))||new Date(f+"T00:00:00Z").toISOString().slice(0,10)!==f)){c(i?"Use valid YYYY-MM-DD dates.":"请填写有效的 YYYY-MM-DD 日期。");return}c(""),s("peakHolidays",[...new Set(u)].sort())}})):null,l?e("p",{className:"cm-err",role:"alert"},l):null,e("p",{className:"cm-hint"},i?"Hours use UTC; Beijing time is UTC + 8. Windows include the start and exclude the end. Empty hours mean all off-peak. Model settings override channel settings.":"小时采用 UTC,北京时间减 8 小时后填写。包含起点、不含终点,时段留空表示全天谷价。模型设置优先于渠道设置。"))}const te=["cacheMiss","cacheHit","output","cacheWrite","reasoning"],se=(t,a)=>t?.[a]??(a==="cacheMiss"?t?.input:a==="cacheHit"?t?.cachedInput??t?.cacheRead??t?.cacheMiss??t?.input:void 0)??null,me=(t,a,r,p)=>({...t,separateMultipliers:!0,multipliers:{...t.separateMultipliers?t.multipliers:{},...Object.fromEntries(r.map(i=>[a+"."+i,p]))}});function Me({value:t,label:a,locale:r,rates:p,disabled:i=!1,onCommit:n}){const x=t==null?"":String(t),[o,g]=A(x),[l,c]=A(!1),s=ne(!1);ie(()=>{s.current||g(x)},[x]);const h=()=>{s.current=!1,c(!1),g(x)},w=()=>{if(!s.current)return;if(!o.trim()){h();return}const u=Number(o);if(!Number.isFinite(u)||u<0||p.some(f=>f!=null&&!Number.isFinite(f*u))){c(!0);return}s.current=!1,c(!1),g(String(u)),n(u)};return e("input",{className:"cm-input cm-factor-input",type:"number",min:0,step:"any",value:o,disabled:i,"aria-label":a,"aria-invalid":l,placeholder:r==="en"?"Mixed":"各项不同",title:l?r==="en"?"Enter a finite, non-negative multiplier.":"请输入有效的非负倍率。":a,onChange:u=>{s.current=!0,c(!1),g(u.target.value)},onBlur:w,onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),w()),u.key==="Escape"&&(u.stopPropagation(),h())}})}function be({value:t,tier:a,title:r,locale:p,priceEditor:i,onChange:n}){const x=te.map(c=>i.priceFactor(t,a+"."+c)),o=x.every(c=>c===x[0])?x[0]:null,g=r+(p==="en"?" · Set all multipliers":" · 统一设置倍率"),l=[t,...t.rateHistory??[]].flatMap(c=>te.map(s=>se(a==="base"?c:c[a],s)));return e("label",{className:"cm-tier-multiplier"},p==="en"?"Set all multipliers":"统一设置倍率",e(Me,{value:o,label:g,locale:p,rates:l,onCommit:c=>n(me(t,a,te,c))}))}function xe({value:t,tier:a="base",field:r,title:p,label:i,locale:n,currency:x,priceEditor:o,t:g,onChange:l}){const c=a==="base"?t:t[a],s=se(c,r),h=a+"."+r,w=r==="cacheWrite"||r==="reasoning",u=o.priceFactor(t,h),f=(d,M)=>{const N={...c};d===null?delete N[r]:N[r]=d,r==="cacheMiss"&&delete N.input,r==="cacheHit"&&(delete N.cachedInput,delete N.cacheRead);const k=a==="base"?N:{...t,[a]:N};l(M===void 0?k:me(k,a,[r],M))};return e("div",{className:"cm-rate-field"},e("span",null,p),e("div",{className:"cm-rate-input"},e("span",{className:"cm-custom-amount"},e("span",{"aria-hidden":!0},x==="CNY"?"¥":"$"),e(o.PriceInput,{value:s,entry:t,path:h,plain:!0,t:g,label:i,emptyMode:w?"clear":"ignore",placeholder:r==="cacheWrite"?n==="en"?"Cached input rate":"跟随缓存读取":r==="reasoning"?n==="en"?"Included in output":"含在输出中":"0",onCommit:f})),e("span",{className:"cm-rate-times","aria-hidden":!0},"×"),e(Me,{value:u,label:i+(n==="en"?" · Multiplier":" · 倍率"),locale:n,rates:[s],disabled:s==null,onCommit:d=>l(me(t,a,[r],d))})))}function Se({value:t,onChange:a,locale:r,defaults:p,t:i,priceEditor:n,label:x="",currency:o=t.currency}){const g=r==="en",l=t.billingMode==="deepseek-peak"||!!(t.peak||t.offPeak),c=Object.fromEntries(te.map((s,h)=>[s,se(t,s)??(h<3?0:null)]).filter(([,s])=>s!==null));return e("details",{className:"cm-custom-more"},e("summary",null,g?"Peak / off-peak pricing":"峰谷价格与时段"),e("label",{className:"cm-check"},e("input",{type:"checkbox",checked:l,onChange:s=>{const h={...t,billingMode:s.target.checked?"deepseek-peak":"flat"};if(s.target.checked){h.multipliers={...t.separateMultipliers?t.multipliers:{}},h.separateMultipliers=!0;for(const w of["peak","offPeak"])if(!t[w]){h[w]={...c};for(const u of te)h.multipliers[w+"."+u]=n.priceFactor(t,"base."+u)}}else delete h.peak,delete h.offPeak;a(h)}}),g?"Enable peak / off-peak prices":"启用峰谷价格"),l?e(pe,null,...["peak","offPeak"].map(s=>{const h=s==="peak"?g?"Peak":"峰价":g?"Off-peak":"谷价";return e("fieldset",{key:s,"data-price-tier":s},e("legend",null,h),e(be,{value:t,tier:s,title:x+" · "+h,locale:r,priceEditor:n,onChange:a}),e("div",{className:"cm-custom-grid"},...[["cacheMiss","输入","Input"],["cacheHit","缓存读取","Cached input"],["output","输出","Output"],["cacheWrite","缓存写入","Cache write"],["reasoning","单独推理","Reasoning"]].map(([w,u,f])=>e(xe,{key:w,value:t,tier:s,field:w,title:g?f:u,label:x+" · "+h+" · "+(g?f:u),locale:r,currency:o,priceEditor:n,t:i,onChange:a}))))}),e(Ce,{value:t,onChange:a,locale:r,defaults:p})):null)}function He({state:t,draft:a,setDraft:r,locale:p}){const i=p==="en",n=a??t.config,[x,o]=A("deepseek"),g=x.trim().toLowerCase().replace(/^llm-/,""),l=n.prices?.providers?.[g]??{models:{}},c=[...new Set(["deepseek",...Object.keys(n.prices?.providers??{}),...Object.keys(t.today?.byProviderModel??{}).map(s=>s.split(":")[0])])].sort();return e("details",{className:"cm-provider-schedules"},e("summary",null,i?"Channel peak schedules":"按渠道设置峰谷时段"),e("label",{className:"cm-field"},i?"Provider ID":"渠道 ID",e("input",{className:"cm-input",list:"cm-peak-providers",value:x,onChange:s=>o(s.target.value)})),e("datalist",{id:"cm-peak-providers"},...c.map(s=>e("option",{key:s,value:s}))),/^[a-z0-9][a-z0-9_.-]{0,99}$/.test(g)&&!["constructor","prototype","__proto__"].includes(g)?e(Ce,{key:g,value:l,locale:p,defaults:g==="ollama-cloud"?[{start:12,end:18}]:n.peakWindows,onChange:s=>r({...n,prices:{...n.prices,providers:{...n.prices.providers,[g]:s}}})}):null,e("p",{className:"cm-hint"},i?"Use the channel ID from model pricing. Applies to peak-enabled models and is retained when official prices sync.":"填写模型定价中显示的渠道 ID。规则用于已启用峰谷价格的模型,同步官方价格时会保留。"))}function je({value:t,locale:a,onChange:r}){const[p,i]=A(String(t)),[n,x]=A(!1);ie(()=>{i(String(t)),x(!1)},[t]);const o=()=>{const l=Number(p);if(!p.trim()||!Number.isSafeInteger(l)||l<=0){x(!0);return}x(!1),r(l)},g=a==="en"?"Input Token threshold":"输入 Token 阈值";return e("label",{className:"cm-field"},g,e("input",{className:"cm-input",type:"number",min:1,step:1,value:p,"aria-label":g,"aria-invalid":n,title:n?a==="en"?"Enter a positive integer.":"请输入正整数。":g,onChange:l=>{i(l.target.value),x(!1)},onBlur:o,onKeyDown:l=>{l.key==="Enter"&&(l.preventDefault(),o()),l.key==="Escape"&&(l.stopPropagation(),i(String(t)),x(!1))}}))}function Ue({value:t,label:a,locale:r,onChange:p,t:i,priceEditor:n,fields:x}){const o=r==="en",g=t.longContext,l=o?"Long context":"长上下文";return e("fieldset",{className:"cm-long-context"},e("legend",null,l),e("label",{className:"cm-check"},e("input",{type:"checkbox",checked:!!g,onChange:c=>{const s={...t};if(c.target.checked){if(s.longContext={aboveInputTokens:272e3,...Object.fromEntries(te.map(h=>[h,se(t,h)]).filter(([,h])=>h!=null))},t.separateMultipliers)for(const h of te)Object.assign(s,me(s,"longContext",[h],n.priceFactor(t,"base."+h)))}else delete s.longContext;p(s)}}),o?"Enable long-context prices":"启用长上下文价格"),g?e(pe,null,e(je,{value:g.aboveInputTokens,locale:r,onChange:c=>p({...t,longContext:{...g,aboveInputTokens:c}})}),e("p",{className:"cm-hint"},o?"Applies when input plus cache read/write exceeds this threshold.":"输入与缓存读写 Token 合计超过阈值时使用。"),e(be,{value:t,tier:"longContext",title:a+" · "+l,locale:r,priceEditor:n,onChange:p}),e("div",{className:"cm-custom-grid"},...x.map(([c,s])=>e(xe,{key:c,value:t,tier:"longContext",field:c,title:s,label:a+" · "+l+" · "+s,locale:r,currency:t.currency,priceEditor:n,t:i,onChange:p})))):null)}function We({value:t,label:a,locale:r,onChange:p,t:i,priceEditor:n,templates:x}){const o=r==="en",[g,l]=A(null),c=g?.price??t,s=d=>g?l({...g,price:d}):p(d),{priceFactor:h}=n,w=[["cacheMiss",o?"Input · cache miss":"输入 · 未命中缓存"],["cacheHit",o?"Cached input":"缓存读取"],["output",o?"Output":"输出"],["cacheWrite",o?"Cache write":"缓存写入"],["reasoning",o?"Separate reasoning":"单独推理费用"]],u=([d,M])=>e(xe,{key:d,value:c,field:d,title:M,label:a+" · "+M,locale:r,currency:c.currency,priceEditor:n,t:i,onChange:s}),f=[["base",o?"Base":"基础价"],...["peak","offPeak"].filter(d=>c[d]).map(d=>[d,d==="peak"?o?"Peak":"峰价":o?"Off-peak":"谷价"]),...c.longContext?[["longContext",o?"Long context":"长上下文"]]:[]];return e("fieldset",{className:"cm-custom-price","aria-label":a+(o?" · Custom price":" · 自定义价格")},e("legend",null,o?"Custom price · per 1M tokens":"自定义价格 · 每百万 Token"),x.length?e("div",{className:"cm-field"},e("span",null,o?"Use an existing model as a template":"以现有模型为模板"),e(le,{value:g?.key??"",options:x,label:o?"Price template":"价格模板",placeholder:o?"Select a custom price":"选择已配置自定义价格的模型",locale:r,onChange:d=>{const M=x.find(N=>N.value===d);l(M?{key:d,price:structuredClone(M.price)}:null)}}),g?e("div",{className:"cm-buttons"},e("button",{type:"button",className:"cm-btn small",onClick:()=>{p(g.price),l(null)}},o?"Save copied price":"保存复制的价格"),e("button",{type:"button",className:"cm-btn small",onClick:()=>l(null)},o?"Cancel":"取消")):null):null,e("div",{className:"cm-custom-head"},e("span",null,o?"Only this channel and model":"仅用于此渠道的这个模型"),e("label",null,o?"Currency":"币种",e("select",{className:"cm-input",value:c.currency,onChange:d=>s({...c,currency:d.target.value})},e("option",{value:"USD"},o?"USD · US dollar":"USD · 美元"),e("option",{value:"CNY"},o?"CNY · Yuan":"CNY · 人民币")))),e(be,{value:c,tier:"base",title:a+(o?" · Base":" · 基础价"),locale:r,priceEditor:n,onChange:s}),e("div",{className:"cm-custom-grid"},...w.slice(0,3).map(u)),e(Se,{value:c,onChange:s,locale:r,t:i,priceEditor:n,label:a,defaults:[{start:1,end:4},{start:6,end:10}]}),e("div",{className:"cm-custom-effective",role:"status"},e("div",{className:"cm-effective-heading"},e("span",null,o?"Effective prices":"实际单价"),e("small",null,o?"Price × multiplier / 1M tokens":"单价 × 倍率 / 百万 Token")),...f.map(([d,M])=>e("div",{key:d,className:"cm-effective-tier","data-effective-tier":d},f.length>1?e("span",null,M):null,e("div",{className:"cm-effective-grid"},...w.slice(0,3).map(([N,k])=>e("div",{key:N},e("span",null,k),e("strong",null,(c.currency==="CNY"?"¥":"$")+Number((se(d==="base"?c:c[d],N)*h(c,d+"."+N)).toPrecision(8)).toLocaleString(o?"en-US":"zh-CN",{maximumFractionDigits:8})))))))),e("details",{className:"cm-custom-more"},e("summary",null,o?"More billing fields":"更多计费项"),e("div",{className:"cm-custom-grid"},...w.slice(3).map(u)),e(Ue,{value:c,label:a,locale:r,onChange:s,t:i,priceEditor:n,fields:w}),e("p",{className:"cm-hint"},o?"Leave reasoning blank when it is included in output. Leave cache write blank to use the cached input rate.":"推理已包含在输出中时无需另填。缓存写入留空则使用缓存读取价格。")),e("p",{className:"cm-hint"},g?o?"Edit the copied values, then save to apply them to this model.":"可继续调整复制的数值,保存后应用到当前模型。":o?"Enter or leave a field to save. Switching the price source keeps your custom values.":"回车或离开输入框后保存;切换价格来源会保留已填的自定义价格。"))}function Pe({entry:t,currency:a,priceEditor:r,locale:p,local:i=!1}){const n=p==="en",x=t?r?.priceAt?.(t)??t:null;return e("span",{className:"cm-rate-summary"},...[["cacheMiss","input",n?"Input":"输入"],["cacheHit","cachedInput",n?"Cached input":"缓存读取"],["output","output",n?"Output":"输出"]].map(([g,l,c])=>{const s=i?0:x?.unpriced?null:x?.[g]??x?.[l],h=s==null?null:s*(r?.priceFactor?.(x??{},"base."+g)??1);return e("span",{key:g,className:"cm-rate-item"},e("span",null,c),e("strong",null,h===null?"—":(a==="CNY"?"¥":"$")+Number(h.toPrecision(8)).toLocaleString(n?"en-US":"zh-CN",{maximumFractionDigits:8})))}))}function Be({state:t,draft:a,setDraft:r,locale:p}){if(t.ourFreeModel?.enabled!==!0)return null;const i=p==="en",n=a?.priceOverrides??t.config.priceOverrides??{},x=["our-free-model:*","our-free-model-region:*"],o=x.every(g=>n[g]==="__free__");return e("section",{className:"cm-free-model","aria-label":"dsh-our-free-model"},e("label",{className:"cm-check"},e("input",{type:"checkbox",role:"switch",checked:o,onChange:g=>{if(!a)return;const l={...n};for(const c of x)g.target.checked?l[c]="__free__":l[c]==="__free__"&&delete l[c];r({...a,priceOverrides:l})}}),e("span",null,i?"Count dsh-our-free-model calls as free":"dsh-our-free-model 调用按免费计算")),e("p",{className:"cm-hint"},i?"Future calls through this plugin cost 0; tokens are still counted. Historical costs and other providers stay unchanged.":"仅此插件后续调用记为免费,Token 照常统计;历史费用和其他渠道不变。"))}function Fe({state:t,draft:a,setDraft:r,t:p,locale:i,resolveClientPrice:n,prettyProviderKey:x,setField:o,priceEditor:g}){const[l,c]=A(""),[s,h]=A(24),[w,u]=A(null),[f,d]=A({}),M=ne(new Map),N=ne(null),k=i==="en",C=t.config,T=a?.priceOverrides??C.priceOverrides??{},O=a?.priceMatchDismissed??C.priceMatchDismissed??[],_=a?.prices??C.prices,U=V(()=>Object.entries(_.custom??{}).filter(([,m])=>m&&!m.unpriced).map(([m,S])=>({value:m,label:x(m),price:S})).sort((m,S)=>m.label.localeCompare(S.label)),[_.custom,x]),W=a?.modelStatistics??C.modelStatistics??{},B=[["today","今日费用","Today"],["summary","月度与累计","Monthly / all-time"],["budget","预算","Budget"]],y=V(()=>({...t.total?.byProviderModel,...t.month?.byProviderModel,...t.today?.byProviderModel,...Object.fromEntries(Object.keys(W).map(m=>[m,null]))}),[t.total?.byProviderModel,t.month?.byProviderModel,t.today?.byProviderModel,W]),D=t.modelDirectory,Y=V(()=>[...new Set([...Object.keys(y),...Object.keys(T)])].filter(m=>{if(O.includes(m)||Ie(m)||["our-free-model:*","our-free-model-region:*"].includes(m))return!1;if(!Array.isArray(D?.providers))return!0;const S=m.slice(0,m.indexOf(":"));return D.providers.includes(S)&&!D.missingModels?.includes(m)}).sort(),[y,T,O,D]);ue(()=>{const m=M.current.get(N.current)?.querySelector(".cm-custom-price");m&&(N.current=null,m.scrollIntoView({block:"start",inline:"nearest"}),m.querySelector("input")?.focus({preventScroll:!0}))},[_,f]);const b=V(()=>[{value:"deepseek:__default__",label:p("overrideTargetDefault")},...Object.keys(_.models??{}).map(m=>({value:"deepseek:"+m,label:"DeepSeek · "+m})),...Object.entries(_.providers??{}).flatMap(([m,S])=>Object.keys(S?.models??{}).map(j=>({value:m+":"+j,label:m+" · "+j})))],[_.models,_.providers,i,p]),E=(m,S)=>{if(a===null)return;const j={...a.priceOverrides??{}};if(S===""?delete j[m]:j[m]=S,S==="__custom__"&&!_.custom?.[m]){const L=m.indexOf(":"),Z=n(m.slice(0,L),m.slice(L+1),{...C,...a}),R=Z.entry??{},$={...R,currency:Z.currency??"USD",billingMode:R.billingMode==="deepseek-peak"?"deepseek-peak":"flat",...g?.priceMultiplierSettings(R),cacheMiss:R.cacheMiss??R.input??0,cacheHit:R.cacheHit??R.cachedInput??R.cacheMiss??R.input??0,output:R.output??0,...R.cacheWrite!==void 0?{cacheWrite:R.cacheWrite}:{},...R.reasoning!==void 0?{reasoning:R.reasoning}:{}};delete $.unpriced,r({...a,priceOverrides:j,prices:{..._,custom:{..._.custom,[m]:$}}})}else r({...a,priceOverrides:j})},F=m=>{if(a===null)return;const S={...a.priceOverrides??{}};delete S[m],r({...a,priceOverrides:S,priceMatchDismissed:[...new Set([...O,m])]})},J=l.trim().toLowerCase().split(/\s+/).filter(Boolean),v=(m=>m.filter(S=>J.every(j=>(S+" "+x(S)).toLowerCase().includes(j))))(Y),P=v.length,I=v.slice(0,s),H=m=>{const S=x(m),j=S.indexOf(":"),L=T[m],Z=w===m,R=f[m]??(L==="__custom__"?"custom":L==="__local__"?"local":L?"catalog":"auto"),$=m.indexOf(":"),ae=n($>0?m.slice(0,$):"deepseek",$>0?m.slice($+1):m,{...C,...a}),Q=!L&&ae.matched===!0,_e=z=>{z==="custom"&&(N.current=m),d({...f,[m]:z}),z!=="catalog"&&E(m,z==="custom"?"__custom__":z==="local"?"__local__":"")},Oe=B.filter(([z])=>W[m]?.[z]!==!1),Ve=(z,G)=>{if(!a)return;const X={...W,[m]:{today:!0,summary:!0,budget:!0,...W[m],[z]:G}};Object.values(X[m]).every(Boolean)&&delete X[m],r({...a,modelStatistics:X})},Je=Q?k?"Automatic":"自动匹配":L==="__custom__"?k?"Custom price":"自定义价格":L==="__local__"?k?"Local · free":"本地 · 零费用":L?k?"Price table":"指定价格表":k?"Needs a price":"待设置价格";return e("div",{key:m,className:"cm-match-row","data-model-key":m,"data-open":Z,ref:z=>{z?M.current.set(m,z):M.current.delete(m)}},e("div",{className:"cm-model-head"},e("div",{className:"cm-model-identity",title:S},e("strong",null,j>0?S.slice(j+1):S),e("span",{className:"cm-model-meta"},e("span",{className:"cm-model-provider"},j>0?S.slice(0,j):"DeepSeek"),e("span",{className:"cm-model-badge"+(!Q&&!L?" needs-price":"")},Je))),e("div",{className:"cm-model-current",title:k?"Effective rates per 1M tokens, including multipliers":"每百万 Token 实际单价,已含倍率"},e(Pe,{entry:ae.entry,currency:ae.currency,priceEditor:g,locale:i,local:L==="__local__"})),e("button",{type:"button",className:"cm-btn small cm-model-edit","aria-expanded":Z,"aria-label":S+(k?" · Set price":" · 设置价格"),onClick:()=>u(Z?null:m)},Z?k?"Collapse":"收起":k?"Set price":"设置价格")),e("details",{className:"cm-model-statistics","data-model-statistics":m},e("summary",null,k?"Include in statistics":"计入统计",Oe.length===3?null:e("span",{className:"cm-note"},Oe.map(([,z,G])=>k?G:z).join(" · ")||(k?"None":"均不计入"))),e("div",{className:"cm-model-statistics-options"},...B.map(([z,G,X])=>e("label",{key:z,className:"cm-check"},e("input",{type:"checkbox",checked:W[m]?.[z]!==!1,"aria-label":S+" · "+(k?X:G),onChange:Ge=>Ve(z,Ge.target.checked)}),k?X:G)))),Z?e("div",{className:"cm-model-editor"},e("div",{className:"cm-source-choices",role:"group","aria-label":k?"Price source":"价格来源"},...[["auto","自动匹配","Automatic"],["catalog","价格表","Price table"],["custom","自定义","Custom"],["local","本地","Local"]].map(([z,G,X])=>e("button",{key:z,type:"button",className:"cm-source-choice"+(R===z?" active":""),"aria-pressed":R===z,onClick:()=>_e(z)},k?X:G))),R==="catalog"?e("div",{className:"cm-model-source"},e("span",null,k?"Select a reference model":"选择参考模型"),e(le,{value:L&&!L.startsWith("__")?L:"",options:b,placeholder:k?"Choose a price table entry":"选择价格表条目",label:S,locale:i,onChange:z=>{z?E(m,z):_e("auto")}}),!L||L.startsWith("__")?e("p",{className:"cm-note"},k?"Current pricing stays in effect until you choose an entry.":"选定条目后生效,选择前仍使用原价格。"):null):null,R==="custom"&&L==="__custom__"&&_.custom?.[m]?e(We,{value:_.custom[m],label:S,locale:i,t:p,priceEditor:g,templates:U.filter(z=>z.value!==m),onChange:z=>r({...a,prices:{..._,custom:{..._.custom,[m]:z}}})}):null,R==="auto"?e("p",{className:"cm-source-explanation"},ae.matched?k?"The model uses its automatically matched reference price.":"已自动匹配参考价格,后续调用按该价格计费。":k?"No exact price found. Choose a table entry or enter a custom quote.":"尚未命中参考价格,可选择价格表条目或填写自定义价格。"):null,R==="local"?e("p",{className:"cm-source-explanation"},k?"Tokens are tracked; new calls have zero API cost.":"保留 Token 统计,后续调用的 API 费用记为 0。"):null,Q?null:e("button",{type:"button",className:"cm-model-dismiss",title:p("removePriceMatchHint"),onClick:()=>F(m)},p("overrideRemove"))):null)};return e("div",{className:"cm-model-matching"},e(Be,{state:t,draft:a,setDraft:r,locale:i}),e("div",{className:"cm-model-toolbar"},e("input",{type:"search",className:"cm-input",value:l,placeholder:k?"Find a model or channel…":"查找模型或渠道…","aria-label":k?"Find configured models":"查找已用模型",onChange:m=>{c(m.target.value),h(24)},onKeyDown:m=>{m.key==="Escape"&&(c(""),h(24),m.stopPropagation())}}),e("span",{className:"cm-note",role:"status"},k?`${P} models`:`${P} 个模型`)),I.length?e("div",{className:"cm-model-list"},e("div",{className:"cm-model-columns","aria-hidden":!0},e("span",null,k?"Model / channel":"模型 / 渠道"),e("span",{className:"cm-rate-summary"},...[k?"Input":"输入",k?"Cached input":"缓存读取",k?"Output":"输出"].map(m=>e("span",{key:m},m))),e("span",{title:k?"Per 1M tokens":"每百万 Token"},"/ 1M tok")),...I.map(H)):null,P===0?e("p",{className:"cm-pricing-empty"},l?k?"No models found. Try another keyword.":"没有找到模型,试试其他关键词。":k?"Models appear here after their first call.":"调用过的模型会显示在这里,之后可按渠道设置价格。"):null,P>s?e("button",{type:"button",className:"cm-btn",onClick:()=>h(m=>m+24)},k?`Show more · ${P-s} remaining`:`显示更多 · 还有 ${P-s} 个`):null,O.length>0?e("button",{type:"button",className:"cm-btn small",onClick:()=>o("priceMatchDismissed",[])},p("restorePriceMatches",{count:O.length})):null,e("details",{className:"cm-pricing-rules"},e("summary",null,k?"Automatic matching rules":"自动匹配规则"),e("label",{className:"cm-field"},e("span",null,p("priceMatchLabel")),e("select",{className:"cm-input",value:a?.priceMatch==="exact"?"exact":"auto",onChange:m=>o("priceMatch",m.target.value)},e("option",{value:"auto"},p("priceMatchAuto")),e("option",{value:"exact"},p("priceMatchExact")))),e("p",{className:"cm-note"},p("priceMatchNote"))))}function Ae({open:t,className:a}){return e("svg",{className:"cm-pricing-chevron "+a+(t?" is-open":""),width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0},e("path",{d:"m9 5 7 7-7 7"}))}function Ye({state:t,draft:a,setDraft:r,t:p,locale:i,rpc:n,renderEditor:x,vendorLabels:o,priceEditor:g}){const l=i==="en",[c,s]=A(""),[h,w]=A(""),[u,f]=A({}),[d,M]=A({}),[N,k]=A(null),[C,T]=A(""),O=a?.prices??t.config.prices,_=V(()=>({...O.providers,deepseek:{models:{...O.models,__default__:O.default}}}),[O.models,O.default,O.providers]),U=Object.keys(_).filter(b=>Object.keys(_[b]?.models??{}).length).sort((b,E)=>b===E?0:b==="deepseek"?-1:E==="deepseek"?1:b.localeCompare(E)),W=c.toLowerCase().trim().split(/\s+/).filter(Boolean),B=U.filter(b=>!h||h===b).map(b=>({id:b,ids:Object.keys(_[b].models).filter(E=>W.every(F=>(b+" "+(o[b]??"")+" "+(E==="__default__"?p("defaultModelId"):E)).toLowerCase().includes(F))).sort((E,F)=>E===F?0:E==="__default__"?1:F==="__default__"?-1:E.localeCompare(F))})).filter(b=>b.ids.length),y=B.reduce((b,E)=>b+E.ids.length,0),D=b=>{s(b),M({}),f({})},Y=()=>{const b=C.trim().toLowerCase();!a||!/^[a-z0-9_.-]+$/.test(b)||Object.hasOwn(O.models,b)||(r({...a,prices:{...O,models:{...O.models,[b]:{cacheHit:0,cacheMiss:0,output:0}}}}),T(""),w("deepseek"),s(b),f(E=>({...E,deepseek:!0})),k("deepseek:"+b))};return e("div",{className:"cm-reference-prices"},e("p",{className:"cm-note"},l?"Base rates include multipliers. Open a model to edit rates, currencies and peak/off-peak tiers.":"列表展示含倍率的基础单价。点开模型可编辑币种、单价和峰谷档位。"),e("div",{className:"cm-catalog-toolbar"},e("input",{type:"search",className:"cm-input",value:c,"aria-label":l?"Search mounted prices":"搜索已挂载价格",placeholder:l?"Search models or providers…":"搜索模型或厂商…",onChange:b=>D(b.target.value),onKeyDown:b=>{b.key==="Escape"&&(D(""),b.stopPropagation())}}),e("select",{className:"cm-input",value:h,"aria-label":l?"Filter price provider":"筛选价格厂商",onChange:b=>{w(b.target.value),M({}),f({})}},e("option",{value:""},l?"All providers":"全部厂商"),...U.map(b=>e("option",{key:b,value:b},o[b]??b))),e("span",{className:"cm-note",role:"status"},l?`${y} models`:`${y} 个模型`)),...B.map(({id:b,ids:E})=>{const F=u[b]??(b==="deepseek"||W.length>0||h===b),J=b==="deepseek"?O.currency??"USD":"USD",K=d[b]??16;return e("section",{key:b,className:"cm-catalog-group"},e("button",{type:"button",className:"cm-catalog-vendor cm-vendor-toggle","aria-expanded":F,onClick:()=>f(v=>({...v,[b]:!F}))},e("span",null,e(Ae,{className:"cm-catalog-caret",open:F}),o[b]??b,e("small",null,E.length)),e("span",{className:"cm-catalog-unit"},J+(l?" / 1M tokens":" / 百万 Token"))),F?e("div",{className:"cm-catalog-list"},e("div",{className:"cm-catalog-columns","aria-hidden":!0},...[l?"Model":"模型",l?"Input":"输入",l?"Cached input":"缓存读取",l?"Output":"输出",""].map((v,P)=>e("span",{key:P},v))),...E.slice(0,K).map(v=>{const P=b+":"+v,I=_[b].models[v],H=N===P,m=v==="__default__"?p("defaultModelId"):v,S=I?.peak||I?.offPeak?l?"Peak / off-peak":"含峰谷价格":I?.longContext?l?"Long context":"含长上下文档位":I?.cny?l?"USD + CNY":"美元 / 人民币":null;return e("div",{key:P,className:"cm-catalog-entry"+(H?" editing":"")},e("button",{type:"button",className:"cm-catalog-model","aria-label":m+(l?" · Edit price":" · 编辑价格"),"aria-expanded":H,onClick:()=>k(H?null:P)},e("span",{className:"cm-catalog-model-name"},e("strong",null,m),S?e("small",null,S):null),e(Pe,{entry:I,currency:J,priceEditor:g,locale:i}),e(Ae,{className:"cm-catalog-edit-caret",open:H})),H?e("div",{className:"cm-catalog-editor"},x(b,v,I),e(Se,{value:I,locale:i,t:p,priceEditor:g,label:m,currency:J,defaults:O.providers?.[b]?.peakWindows??a.peakWindows,onChange:j=>{const L=b==="deepseek"?{...O,...v==="__default__"?{default:j}:{models:{...O.models,[v]:j}}}:{...O,providers:{...O.providers,[b]:{...O.providers[b],models:{...O.providers[b].models,[v]:j}}}};r({...a,prices:L})}})):null)}),E.length>K?e("button",{type:"button",className:"cm-catalog-more",onClick:()=>M(v=>({...v,[b]:K+16}))},l?`Show more · ${E.length-K} remaining`:`显示更多 · 还有 ${E.length-K} 个`):null):null)}),y===0?e("p",{className:"cm-pricing-empty"},l?"No matching models.":"没有找到匹配的模型。"):null,e("details",{className:"cm-pricing-rules"},e("summary",null,l?"Pricing notes":"计价说明"),e("p",{className:"cm-note"},p("priceTableNote"))),e("details",{className:"cm-catalog-manage"},e("summary",null,l?"Add or restore models":"添加与恢复模型"),e("div",{className:"cm-catalog-add"},e("input",{className:"cm-input",value:C,"aria-label":p("newModelPlaceholder"),placeholder:p("newModelPlaceholder"),onChange:b=>T(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),Y())}}),e("button",{type:"button",className:"cm-btn small",disabled:!/^[a-z0-9_.-]+$/.test(C.trim().toLowerCase())||Object.hasOwn(O.models,C.trim().toLowerCase()),onClick:Y},p("addModel"))),e(Ne,{state:t,draft:a,setDraft:r,locale:i,rpc:n})))}function $e({state:t,locale:a,formatMoneyUsd:r,api:p,rpc:i,disabled:n}){const[x,o]=A(!1),[g,l]=A(!1),[c,s]=A(""),[h,w]=A([]),[u,f]=A(""),[d,M]=A(""),N=a==="en",k=(y,D)=>{const Y=t.config.currency==="CNY"?"Cny":t.config.currency==="EUR"?"Eur":"",b=Y&&y[D+Y],E=Number(t.config.exchangeRate);return r(typeof b=="number"&&E>0?b/E:y[D],t.config)},C=N?"All models":"全部模型",T=N?{dynamicQuote:"Recorded dynamic quote",auxiliaryUsage:"Missing per-call usage for title or retry requests",usage:"Usage differs",ledgerModelMissing:"Model missing from ledger",logModelMissing:"Model missing from logs",dayModelMissing:"Model missing from daily totals",logMissing:"No replayable logs"}:{dynamicQuote:"保留已入账的动态报价",auxiliaryUsage:"标题或重试请求缺少逐次用量,无法确定费用",usage:"用量不一致",ledgerModelMissing:"账本缺少此模型",logModelMissing:"日志缺少此模型",dayModelMissing:"当日汇总缺少此模型",logMissing:"无可回放日志"},O=y=>y.skippedDetails?.length?e("details",{key:y.at,className:"cm-repricing-skipped"},e("summary",null,new Date(y.at).toLocaleString(a)+" · "+y.skipped+(N?" unchanged":" 条未重算")),e("ul",null,...y.skippedDetails.map((D,Y)=>e("li",{key:Y},e("div",null,[D.sessionId,D.date,D.model].filter(Boolean).join(" · ")),e("div",null,T[D.reason]),...D.fields.map(b=>e("div",{key:b.field},`${b.field}: ${N?"ledger":"账本"} ${b.ledger} − ${N?"log":"日志"} ${b.log} = ${b.ledger-b.log}`)))))):null,_=V(()=>[...new Set([t.today,t.month,...t.history??[]].flatMap(y=>Object.keys(y?.byProviderModel??{})))].filter(y=>y.indexOf(":")>0).sort(),[t.today,t.month,t.history]),U=V(()=>[{value:"",label:C},..._.map(y=>({value:y,label:y}))],[_,C]),W=()=>i("getRepricingHistory").then(y=>{w(ce.parse(y)),f("")}).catch(y=>f(String(y.message??y)));ie(()=>{let y=!0;return i("getRepricingHistory").then(D=>{y&&w(ce.parse(D))},D=>{y&&f(String(D.message??D))}),()=>{y=!1}},[i]);const B=async()=>{if(!(!x||g||n)){l(!0),f(""),s("");try{const y=d?await i("repriceModelHistory",!0,d):await i("repriceHistory",!0);if(!y.ok)throw new Error(y.message);s(y.message),o(!1),await W(),await p.reload()}catch(y){f(String(y.message??y))}finally{l(!1)}}};return e("section",{className:"cm-repricing"},e("h3",{className:"cm-h"},N?"Historical pricing":"历史费用"),e("p",{className:"cm-note"},N?"Rate changes apply to new calls. Recorded historical rates remain fixed.":"修改价格只影响后续调用,历史费用沿用原价格。"),e("div",{className:"cm-repricing-scope"},e("label",null,N?"Recalculation scope":"重算范围"),e(le,{options:U,value:d,locale:a,label:N?"Choose channel and model":"选择渠道与模型",ariaLabel:N?"Choose channel and model":"选择渠道与模型",placeholder:N?"Search historical models":"搜索历史渠道或模型",onChange:y=>{g||(M(y),o(!1),s(""))}}),e("p",{className:"cm-hint"},d?N?"Only this channel/model changes. Other models and original exchange rates remain unchanged.":"仅重算此渠道下的这个模型,其他模型及原调用汇率保持不变。":N?"Choose a single channel/model to limit the recalculation.":"可选择单个渠道模型,缩小重算范围。")),x?e("div",{className:"cm-repricing-warning",role:"alert",onKeyDown:y=>{y.key==="Escape"&&!g&&(o(!1),y.stopPropagation())}},e("strong",null,(d||C)+(N?" · Historical amounts will change":" · 将修改历史费用")),e("p",null,N?"Recalculate retained calls using current rates and replace their amounts in statistics. Original amounts, price versions and a full ledger backup are kept. Records with incomplete logs are unchanged.":"确认后,将按当前价格重新计算保留的历史调用,并更新统计金额。原金额、原价格版本和完整账本备份都会保留;日志不完整的记录不改。"),e("div",{className:"cm-buttons"},e("button",{type:"button",className:"cm-btn",disabled:g,onClick:()=>o(!1)},N?"Cancel":"取消"),e("button",{type:"button",className:"cm-btn danger",disabled:g||n,onClick:B},g?N?"Recalculating…":"正在重算…":N?"Confirm recalculation":"确认重算"))):e("button",{type:"button",className:"cm-btn",disabled:n||g,onClick:()=>o(!0)},d?N?"Recalculate this model":"重算此模型的历史费用":N?"Recalculate history at current rates":"按当前价格重算历史"),c?e("p",{role:"status",className:"cm-note"},c):null,u?e("p",{role:"alert",className:"cm-err"},u):null,h.length?e("details",{className:"cm-repricing-history"},e("summary",null,N?"Recalculation records · original amounts retained":"重算记录 · 原金额已保留"),e("div",{className:"cm-stat-scroll"},e("table",{className:"cm-stat-table"},e("thead",null,e("tr",null,...(N?["Time","Scope","Before","After","Session/day records"]:["重算时间","范围","原金额","重算后","会话日期记录"]).map(y=>e("th",{key:y,scope:"col"},y)))),e("tbody",null,...h.map(y=>e("tr",{key:y.at},e("td",null,new Date(y.at).toLocaleString(a)),e("td",null,y.model||C),e("td",null,k(y,"before")),e("td",null,k(y,"after")),e("td",null,y.sessions)))))),...h.map(O)):null)}function qe({state:t,draft:a,setDraft:r,locale:p}){const i=a??t.config,n=(s,h)=>p==="en"?h:s,x=Object.keys(t.total?.byProviderModel??{}).filter(s=>s.indexOf(":")>0).map(s=>s.slice(0,s.indexOf(":"))),o=[...new Set([...x,...Object.keys(i.planBilling?.providers??{})])],[g,l]=A(x[0]??"go"),c=o.includes(g)?g:o[0]??"go";return e("section",{className:"cm-budget","data-provider-billing":!0},e("h3",{className:"cm-h"},n("渠道计费方式","Channel billing")),e("div",{className:"cm-grid"},e("label",{className:"cm-field"},e("span",null,n("渠道","Channel")),e("select",{className:"cm-input","aria-label":n("计费渠道","Billing channel"),value:c,onChange:s=>l(s.target.value)},o.map(s=>e("option",{value:s,key:s},s==="go"?"OpenCode Go (go)":s)))),e("label",{className:"cm-field"},e("span",null,n("计费方式","Billing type")),e("select",{className:"cm-input","aria-label":n("渠道计费方式","Channel billing type"),value:i.planBilling?.providers?.[c]??"auto",disabled:a==null,onChange:s=>r({...i,planBilling:{...i.planBilling,providers:{...i.planBilling?.providers,[c]:s.target.value}}})},[["auto",n("自动","Automatic")],["plan",n("Plan 订阅","Plan subscription")],["api",n("API 按量","Metered API")]].map(([s,h])=>e("option",{value:s,key:s},h))))),e("p",{className:"cm-note"},n("适用于该渠道的所有模型,模型单独设置优先。修改后更新历史 API/Plan 归属,保留 Token 和 API 等值金额。额度查询开关单独控制。","Applies to all models on this channel; model overrides take priority. Changes update historical API/Plan classification while preserving tokens and API-equivalent amounts. Quota queries are controlled separately.")))}function Ze({state:t,t:a,formatMoneyUsd:r,formatTokens:p,helpers:i}){const{Card:n,displayCostOf:x}=i,o=t.externalUsage;if(!o)return null;const g=t.config,l=u=>r(x(u,g),g),c=u=>a("callsTokens",{calls:u.calls,input:p(u.input),cache:p(u.cacheRead+u.cacheWrite),output:p(u.output)}),s=(u,f)=>({calls:u.calls+f.calls,input:u.input+f.input,output:u.output+f.output,cacheRead:u.cacheRead+f.cacheRead,cacheWrite:u.cacheWrite+f.cacheWrite,cost:x(u,g)+f.cost,apiCost:x(u,g)+f.cost}),h=(u,f)=>e("tr",{key:u},e("td",null,u),e("td",{className:"num"},String(f.calls)),e("td",{className:"num"},p(f.input)),e("td",{className:"num"},p(f.cacheRead+f.cacheWrite)),e("td",{className:"num"},p(f.output)),e("td",{className:"num"},l(f))),w=u=>e("div",{className:"cm-scroll"},e("table",{className:"cm-table"},e("thead",null,e("tr",null,e("th",null,a("colDate")),...["colCalls","colInTok","colCacheTok","colOutTok","colCost"].map(f=>e("th",{className:"num"},a(f))))),e("tbody",null,u)));return e("section",{className:"cm-budget"},e("h3",{className:"cm-h"},a("externalUsage")),o.stale?e("p",{className:"cm-note"},a("externalStale")):null,e("div",{className:"cm-cards"},["today","month","total"].map((u,f)=>{const d=s(t[u],o.combined[u]);return e(n,{key:u,title:a("combinedUsage")+" · "+a(["cardToday","cardMonth","cardTotal"][f]),value:l(d),sub:c(d)})})),...o.sources.map(u=>e("details",{key:u.source},e("summary",null,u.source+" · "+a("cardToday")+" "+l(u.today)+" · "+a("cardMonth")+" "+l(u.month)+" · "+c(u.today)),w(["today","month","total"].map((f,d)=>h(a(["cardToday","cardMonth","cardTotal"][d]),u[f]))),e("p",{className:"cm-note"},a("externalHistory")),w(u.history.map(f=>h(f.date,f))))))}function Ke({state:t,onPrices:a}){const r=t.config,p=(r.locale==="auto"?r.activeLocale:r.locale)==="en",i=(o,g)=>p?g:o,n=r.prices?.currency==="CNY"?"CNY":"USD",x=r.currency==="CNY"&&n==="USD";return e("details",{className:"cm-note","data-billing-check":!0,open:x||void 0},e("summary",null,i("计费核对","Check billing")),e("p",null,i("当前 DeepSeek 价表:","Active DeepSeek price table: ")+n+i(";显示币种:","; display currency: ")+r.currency),x?e("p",{"data-billing-currency-mismatch":!0},i("当前金额由美元单价换算,美元价 × 汇率不等于官网人民币报价。按人民币账单核对时,请选择人民币官方价并同步;只切换显示币种不会更换价表。","Amounts currently convert USD rates. USD rates × exchange rate differ from official CNY prices. To compare with a CNY bill, select CNY official prices and sync them; changing the display currency does not change the price table.")):null,r.pricingCurrency!==n?e("p",null,i("所选同步币种尚未生效,当前仍使用 ","The selected sync currency is not active yet; billing still uses ")+n):null,e("p",null,i("金额口径:","Cost basis: ")+i(r.showTotalWithPlan?"含套餐 API 等值,不等于账户扣款。":"API 费用;套餐等值已排除。",r.showTotalWithPlan?"Includes subscription API-equivalent costs, not account deductions.":"API costs; subscription equivalents are excluded.")),e("p",null,i("核对时使用同一账户、渠道和时段;费用明细可查看每次调用的缓存、输出、费率和搜索请求费。自定义价格、倍率与历史价表也会影响金额。","Compare the same account, provider and time range. Cost details show each call’s cache, output, rates and search request fees. Custom prices, multipliers and historical rates also affect totals.")),a?e("button",{type:"button",className:"cm-btn small",onClick:a},i("查看并同步官方价表","Review and sync official prices")):null)}async function Qe(t){const a=await t.get("remote").$mount(ke);t.effect(()=>()=>a(),"cost-meter: pricing settings contribution");const r=t.get("remote.costMeter"),p=async(n,...x)=>{(n==="repriceHistory"||n==="repriceModelHistory")&&fe.parse(x[0]),n==="repriceModelHistory"&&ve.parse(x[1]);const o=await r[n](...x);if(o?.ok!==!0)throw new Error(o?.error?.message??"Pricing request failed");return(n==="getPriceCatalog"?we:n==="getRepricingHistory"?ce:he).parse(o.value)},i=document.createElement("style");return i.textContent=".cm-repricing-scope{display:grid;gap:8px;max-width:620px;margin:16px 0}.cm-repricing-scope>label{font-size:13px;color:var(--dsw-alias-label-secondary)}.cm-repricing-scope .cm-hint{margin:0;line-height:1.6}",i.textContent+=".cm-price-search{display:grid;gap:6px;min-width:0}.cm-price-search small{color:var(--dsw-alias-label-tertiary)}.cm-price-search select,.cm-price-search input{width:100%;min-width:0}.cm-repricing-warning{padding:12px;border:1px solid var(--dsw-alias-state-warn-primary,#c58a25);border-radius:10px;background:var(--dsw-alias-bg-layer-1)}.cm-repricing-warning p{margin:8px 0 12px;line-height:1.6}.cm-repricing-history{margin-top:12px}.cm-repricing-history table{width:100%;text-align:left;font-variant-numeric:tabular-nums}.cm-repricing-history td,.cm-repricing-history th{padding:8px;border-bottom:1px solid var(--dsw-alias-border-l1)}",i.textContent+=".cm-repricing-history .cm-stat-scroll{overflow-x:auto;max-width:100%}.cm-repricing-history table{min-width:560px}.cm-repricing-history th{white-space:nowrap}.cm-repricing-history td:nth-child(2){min-width:150px;max-width:260px;overflow-wrap:anywhere}",i.textContent+=".cm-repricing-skipped{margin-top:12px;overflow-wrap:anywhere}.cm-repricing-skipped summary{cursor:pointer}.cm-repricing-skipped ul{padding-left:18px}.cm-repricing-skipped li+li{margin-top:12px}",i.textContent+=".cm-pricing-page .cm-free-model{margin:0 0 12px;padding:10px 12px;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;background:transparent}.cm-pricing-page .cm-free-model>.cm-check{display:flex;align-items:center;gap:8px;margin:0;font-size:12px;line-height:20px;color:var(--dsw-alias-label-primary)}.cm-pricing-page .cm-free-model input{flex:none;width:16px;height:16px;margin:0;accent-color:var(--dsw-alias-state-business-primary)}.cm-pricing-page .cm-free-model>.cm-hint{display:block;margin:4px 0 0 24px;font-size:11px;line-height:1.5}",i.textContent+=".cm-provider-schedules{margin:12px 0}.cm-provider-schedules>.cm-field{max-width:360px;margin:12px 0}.cm-peak-schedule,.cm-custom-more fieldset{min-width:0;margin:12px 0;padding:12px;border:1px solid var(--dsw-alias-border-l1);border-radius:8px}.cm-peak-schedule{display:grid;gap:12px}.cm-custom-more .cm-check{display:flex;align-items:center;gap:8px;margin:12px 0}.cm-custom-more .cm-check input{width:auto;flex:none;margin:0}.cm-peak-schedule legend{font-size:12px}.cm-peak-schedule .cm-hint{margin:0;line-height:1.6}",i.textContent+=".cm-custom-price{grid-column:1/-1;display:grid;gap:14px;margin:4px 0 12px;padding:16px;border:1px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-lg,12px);background:var(--dsw-alias-bg-layer-1);min-width:0}.cm-custom-price legend{padding:0 6px;font-weight:500;font-size:13px}.cm-custom-price label{display:grid;gap:7px;font-size:12px;min-width:0;color:var(--dsw-alias-label-secondary)}.cm-custom-price .cm-input{width:100%;min-width:0}.cm-custom-head{display:flex;justify-content:space-between;align-items:center;gap:12px;color:var(--dsw-alias-label-secondary);font-size:12px}.cm-custom-head label{display:flex;align-items:center;gap:8px}.cm-custom-head select{width:auto!important}.cm-custom-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}.cm-custom-amount{position:relative;display:block}.cm-custom-amount>span{position:absolute;inset-inline-start:11px;top:50%;transform:translateY(-50%);pointer-events:none;color:var(--dsw-alias-label-tertiary)}.cm-custom-amount input{padding-inline-start:28px}.cm-custom-more summary{cursor:pointer;font-size:12px;color:var(--dsw-alias-label-secondary)}.cm-custom-more .cm-custom-grid{grid-template-columns:repeat(2,minmax(0,1fr));margin:12px 0 8px}.cm-custom-price p{margin:0;line-height:1.6}@media(max-width:700px){.cm-custom-grid{grid-template-columns:1fr}.cm-custom-head{flex-wrap:wrap}}",document.head.appendChild(i),i.textContent+=`
2
2
  .cm-model-matching{display:grid;gap:12px;min-width:0;container:cm-models / inline-size;overflow-anchor:none}
3
3
  .cm-pricing-intro{display:grid;gap:6px}.cm-pricing-intro p{line-height:1.65}
4
4
  .cm-model-toolbar{display:flex;align-items:center;gap:12px}.cm-model-toolbar>.cm-input{flex:1;width:100%;min-width:0;box-sizing:border-box}.cm-model-toolbar>.cm-note{white-space:nowrap}
@@ -28,4 +28,4 @@
28
28
  @container cm-price-list (max-width:560px){.cm-catalog-columns{display:none}.cm-catalog-model{grid-template-columns:repeat(3,minmax(0,1fr));gap:14px}.cm-catalog-model-name{grid-column:1/-1;padding-inline-end:20px}.cm-catalog-model .cm-rate-item>span{display:block}.cm-catalog-edit-caret{position:absolute;inset-inline-end:16px;top:12px}.cm-catalog-unit{font-size:10px}.cm-catalog-editor{padding:0 10px 10px}}
29
29
  @container cm-price-editor (max-width:520px){.cm-price-row.cm-price-columns{display:none}.cm-price-row:not(.cm-price-columns){grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;padding:10px;border:1px solid var(--dsw-alias-border-l1);border-radius:8px}.cm-price-row>span:first-child{grid-column:1/-1;font-weight:600;color:var(--dsw-alias-label-secondary)}.cm-price-cell>.cm-price-cell-label{display:block;font-size:11px;line-height:1.5}}
30
30
  @media(max-width:480px){.cm-source-choices{grid-template-columns:repeat(2,minmax(0,1fr))}.cm-catalog-toolbar>select{flex:1 1 140px}}
31
- `,i.textContent+=[".cm-price-search{display:block;min-width:0}",".cm-combo-control{position:relative;display:flex;align-items:center;min-width:0}",".cm-combo .cm-input{width:100%;min-width:0;padding-right:46px;text-overflow:ellipsis}",".cm-combo .cm-combo-input::-webkit-search-cancel-button{display:none}",".cm-combo-clear,.cm-combo-caret{position:absolute;display:flex;align-items:center;justify-content:center;width:18px;height:18px;padding:0;border:0;background:transparent;color:var(--dsw-alias-label-tertiary);line-height:1;cursor:pointer}",".cm-combo-clear{right:26px;border-radius:50%;font-size:14px}",".cm-combo-clear:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.14));color:var(--dsw-alias-label-primary)}",".cm-combo-caret{right:6px;font-size:10px}",".cm-combo-panel{position:fixed;z-index:10000;display:flex;flex-direction:column;gap:2px;box-sizing:border-box;padding:4px;border-radius:12px;background:var(--cm-opaque-base,#fff);background:rgb(from var(--dsw-alias-bg-layer-2,var(--dsw-alias-bg-base,#fff)) r g b / 1);box-shadow:var(--dsw-elevation-panel,0 3px 8px rgba(0,0,0,.06),0 0 16px rgba(0,0,0,.04))}",".cm-combo-list{display:flex;flex-direction:column;gap:2px;min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin}",".cm-combo-option{flex:none;font:inherit;font-size:12px;line-height:1.5;text-align:left;padding:6px 8px;border:0;border-radius:6px;background:transparent;color:var(--dsw-alias-label-primary);cursor:pointer;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}",".cm-combo-option.active{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.14))}",'.cm-combo-option[aria-selected="true"]{color:var(--dsw-alias-state-business-primary);font-weight:600}',".cm-combo-note{margin:0;padding:4px 8px;font-size:10px;color:var(--dsw-alias-label-tertiary)}",".cm-match-row .cm-combo{flex:1;min-width:160px}",".cm-repricing-warning{padding:12px;border:1px solid var(--dsw-alias-state-warn-primary,#c58a25);border-radius:10px;background:var(--dsw-alias-bg-layer-1)}.cm-repricing-warning p{margin:8px 0 12px;line-height:1.6}.cm-repricing-history{margin-top:12px}.cm-repricing-history table{width:100%;text-align:left;font-variant-numeric:tabular-nums}.cm-repricing-history td,.cm-repricing-history th{padding:8px;border-bottom:1px solid var(--dsw-alias-border-l1)}",'@media (max-width:1023px){.cm-custom-grid,.cm-effective-grid,.cm-rate-summary{grid-template-columns:1fr}.cm-model-toolbar,.cm-custom-head,.cm-catalog-toolbar{flex-wrap:wrap}.cm-repricing-history table{min-width:480px}.cm-model-matching .cm-match-row{padding:8px 10px}}body[data-dsh-pocket-layout="mobile"] .cm-custom-grid{grid-template-columns:1fr}body[data-dsh-pocket-layout="mobile"] .cm-rate-summary{grid-template-columns:1fr}'].join(""),t.effect(()=>()=>i.remove(),"cost-meter: pricing settings styles"),n=>n.mode==="external"?e(qe,n):n.mode==="check"?e(Ke,n):n.mode==="peak-settings"?e(Re,n):n.mode==="schedule"?e(He,n):n.mode==="billing"?e(Ze,n):n.mode==="matching"?e(Fe,n):e(n.mode==="catalog"?Ye:n.mode==="restore"?Ne:$e,{...n,rpc:p})}return{mount:Ve,CONTRIBUTION:ke}}});
31
+ `,i.textContent+=[".cm-price-search{display:block;min-width:0}",".cm-combo-control{position:relative;display:flex;align-items:center;min-width:0}",".cm-combo .cm-input{width:100%;min-width:0;padding-right:46px;text-overflow:ellipsis}",".cm-combo .cm-combo-input::-webkit-search-cancel-button{display:none}",".cm-combo-clear,.cm-combo-caret{position:absolute;display:flex;align-items:center;justify-content:center;width:18px;height:18px;padding:0;border:0;background:transparent;color:var(--dsw-alias-label-tertiary);line-height:1;cursor:pointer}",".cm-combo-clear{right:26px;border-radius:50%;font-size:14px}",".cm-combo-clear:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.14));color:var(--dsw-alias-label-primary)}",".cm-combo-caret{right:6px;font-size:10px}",".cm-combo-panel{position:fixed;z-index:10000;display:flex;flex-direction:column;gap:2px;box-sizing:border-box;padding:4px;border-radius:12px;background:var(--cm-opaque-base,#fff);background:rgb(from var(--dsw-alias-bg-layer-2,var(--dsw-alias-bg-base,#fff)) r g b / 1);box-shadow:var(--dsw-elevation-panel,0 3px 8px rgba(0,0,0,.06),0 0 16px rgba(0,0,0,.04))}",".cm-combo-list{display:flex;flex-direction:column;gap:2px;min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin}",".cm-combo-option{flex:none;font:inherit;font-size:12px;line-height:1.5;text-align:left;padding:6px 8px;border:0;border-radius:6px;background:transparent;color:var(--dsw-alias-label-primary);cursor:pointer;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}",".cm-combo-option.active{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.14))}",'.cm-combo-option[aria-selected="true"]{color:var(--dsw-alias-state-business-primary);font-weight:600}',".cm-combo-note{margin:0;padding:4px 8px;font-size:10px;color:var(--dsw-alias-label-tertiary)}",".cm-match-row .cm-combo{flex:1;min-width:160px}",".cm-repricing-warning{padding:12px;border:1px solid var(--dsw-alias-state-warn-primary,#c58a25);border-radius:10px;background:var(--dsw-alias-bg-layer-1)}.cm-repricing-warning p{margin:8px 0 12px;line-height:1.6}.cm-repricing-history{margin-top:12px}.cm-repricing-history table{width:100%;text-align:left;font-variant-numeric:tabular-nums}.cm-repricing-history td,.cm-repricing-history th{padding:8px;border-bottom:1px solid var(--dsw-alias-border-l1)}",'@media (max-width:1023px){.cm-custom-grid,.cm-effective-grid,.cm-rate-summary{grid-template-columns:1fr}.cm-model-toolbar,.cm-custom-head,.cm-catalog-toolbar{flex-wrap:wrap}.cm-repricing-history table{min-width:480px}.cm-model-matching .cm-match-row{padding:8px 10px}}body[data-dsh-pocket-layout="mobile"] .cm-custom-grid{grid-template-columns:1fr}body[data-dsh-pocket-layout="mobile"] .cm-rate-summary{grid-template-columns:1fr}'].join(""),t.effect(()=>()=>i.remove(),"cost-meter: pricing settings styles"),n=>n.mode==="external"?e(Ze,n):n.mode==="check"?e(Ke,n):n.mode==="peak-settings"?e(Re,n):n.mode==="schedule"?e(He,n):n.mode==="billing"?e(qe,n):n.mode==="matching"?e(Fe,n):e(n.mode==="catalog"?Ye:n.mode==="restore"?Ne:$e,{...n,rpc:p})}return{mount:Qe,CONTRIBUTION:ke}}});
@@ -40,6 +40,7 @@ import { queryBaiduTokenPlan, BAIDU_TOKEN_PLAN_URL } from './baidu-token-plan.js
40
40
  import { createHash, createHmac } from 'node:crypto'
41
41
 
42
42
  import { fetchWithRetry, readJsonBounded } from './net.js'
43
+ import { balanceNumber } from './balance-expression.js'
43
44
  import { queryFactoryQuota, FACTORY_QUOTA_URL } from './factory-quota.js'
44
45
  import { queryOpenDesignQuota, OPENDESIGN_API } from './opendesign.js'
45
46
  import { fetchWorkBuddyConnectCredits, fetchWorkBuddyCredits, isWorkBuddyTokenExpired, resolveWorkBuddyCredential, workbuddyBillingBase } from './workbuddy.js'
@@ -479,19 +480,14 @@ export function parseMiniMaxRemains(data) {
479
480
 
480
481
  /**
481
482
  * 解析 Kimi / Moonshot 余额响应(GET https://api.moonshot.cn/v1/users/me/balance)。
482
- * 官方返回形如 { available_balance: <分> }(人民币分),兼容 cached/total 变体与元单位形态。
483
- * 输出文本窗口(余额无总量,不适合百分比进度条)。
483
+ * 官方 data.available_balance 的单位是人民币元。文本窗口只保留金额,界面负责翻译标签。
484
484
  */
485
485
  export function parseKimiBalance(data) {
486
486
  if (data === null || typeof data !== 'object') return null
487
- const raw = data.available_balance ?? data.balance ?? data.cash_balance ?? data.data?.available_balance
488
- const n = Number(raw)
487
+ const raw = data.data?.available_balance ?? data.available_balance ?? data.balance ?? data.cash_balance
488
+ const n = balanceNumber(raw)
489
489
  if (!Number.isFinite(n) || n < 0) return null
490
- // 官方单位为人民币分;数值 <100 视为已是元(兼容变体)。
491
- const cny = n >= 100 ? n / 100 : n
492
- const text = '余额 ¥' + (Math.round(cny * 100) / 100).toFixed(2)
493
- const win = textWindowOf(text)
494
- return win === null ? null : { balance: win }
490
+ return { balance: textWindowOf('¥' + n.toFixed(2)) }
495
491
  }
496
492
 
497
493
  /**