dsh-cost-meter 1.9.2 → 1.9.4
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.
- package/README.md +9 -8
- package/README.zh-CN.md +9 -8
- package/docs/display-settings.md +15 -1
- package/docs/opendesign-billing.md +99 -93
- package/docs/performance-2026-10-18.json +1703 -1703
- package/docs/performance-2026-10-18.md +58 -58
- package/docs/update-notes-1.9.3.md +19 -0
- package/docs/update-notes-1.9.4.md +71 -0
- package/lib/client.codex.js +1 -1
- package/lib/client.display.js +2 -2
- package/lib/client.js +5 -5
- package/lib/client.peak.js +3 -0
- package/lib/client.pricing.js +14 -11
- package/lib/client.statistics.js +6 -5
- package/lib/codex-subscription-compat.js +23 -2
- package/lib/index.js +46 -28
- package/lib/model-statistics.js +34 -0
- package/lib/opendesign.js +16 -5
- package/lib/store.js +22 -5
- package/lib/typert.host.js +1063 -1058
- package/package.json +4 -2
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({id:"dsh-cost-meter",chunk:"client.peak.js",factory:O=>{const U=O("react"),{createElement:e,useState:b,useEffect:I,useRef:_,Fragment:C}=U,G=`.cm-peak-progress{--peak-color:var(--dsw-alias-state-business-primary);min-width:0;padding:10px 2px 8px;display:flex;flex-direction:column;gap:7px;font-size:12px;line-height:1.35;font-variant-numeric:tabular-nums}.cm-peak-progress.peak{--peak-color:#ff9800}.cm-peak-progress-head,.cm-peak-progress-meta{display:flex;align-items:center;justify-content:space-between;gap:10px;min-width:0}.cm-peak-progress-phase{display:inline-flex;align-items:center;gap:6px;color:var(--peak-color);font-weight:600;white-space:nowrap}.cm-peak-progress-phase i{width:6px;height:6px;border-radius:50%;background:var(--peak-color);flex:none}.cm-peak-progress-time{font-size:11px;color:var(--dsw-alias-label-secondary);text-align:right;overflow-wrap:anywhere}.cm-peak-progress-track{height:6px;border-radius:99px;background:color-mix(in srgb,var(--peak-color) 12%,var(--dsw-alias-bg-layer-3));overflow:hidden;position:relative;width:100%}.cm-peak-progress-fill{height:100%;display:block;background:var(--peak-color);border-radius:inherit;position:relative}.cm-peak-progress-fill:after{content:"";position:absolute;right:2px;top:2px;width:2px;height:2px;background:#fff;border-radius:50%;opacity:.85}.cm-peak-progress-meta{font-size:10px;color:var(--dsw-alias-label-tertiary);gap:8px}.cm-peak-progress-meta span:last-child{text-align:right;color:var(--dsw-alias-label-secondary)}.cm-peak-progress.variant-simple{padding:2px 0;gap:3px;font-size:11px;line-height:14px}.cm-peak-progress.variant-simple .cm-peak-progress-time{font-size:10px;line-height:14px;white-space:nowrap}.cm-peak-progress.variant-simple .cm-peak-progress-track{height:4px}.cm-peak-progress.variant-simple .cm-peak-progress-meta{justify-content:flex-end;font-size:10px;line-height:12px}.cm-peak-progress.variant-simple .cm-peak-progress-phase{gap:5px}.cm-peak-progress.variant-compact{padding:2px 0;gap:7px;flex-direction:row;align-items:center;font-size:11px;line-height:16px;white-space:nowrap}.cm-peak-progress.variant-compact .cm-peak-progress-phase{gap:4px;flex:none}.cm-peak-progress.variant-compact .cm-peak-progress-phase i{width:5px;height:5px}.cm-peak-progress.variant-compact .cm-peak-progress-track{flex:1;min-width:20px;width:auto;height:4px}.cm-peak-progress.variant-compact .cm-peak-progress-time{flex:none;font-size:10px;line-height:16px;white-space:nowrap}.variant-simple .cm-peak-progress-fill:after,.variant-compact .cm-peak-progress-fill:after{top:1px;right:1px}.cm-footer-stack.simple>.cm-peak-progress{padding-left:10px;padding-right:10px;margin:0}.cm-peak-progress.rail{align-items:center;padding:4px 0;gap:4px}.cm-peak-progress.rail .cm-peak-progress-track{width:6px;height:42px;display:flex;align-items:flex-end}.cm-peak-progress.rail .cm-peak-progress-fill{width:100%}.cm-peak-progress-rail-label{font-size:10px;white-space:nowrap;color:var(--peak-color)}.cm-peak-intro{width:min(520px,94vw);max-height:88vh;max-height:88dvh}.cm-peak-intro .cm-stat-dialog-body{display:flex;flex-direction:column;gap:16px}.cm-peak-intro-description{margin:0;font-size:13px;line-height:1.7;color:var(--dsw-alias-label-secondary)}.cm-peak-intro-field{display:flex;gap:14px;align-items:center;font-size:12px}.cm-peak-intro-field .cm-input{flex:1;min-width:0}.cm-peak-intro-previews{display:flex;flex-direction:column;gap:10px}.cm-peak-intro-sample{padding:10px 12px;border:1px solid var(--dsw-alias-border-l1);border-radius:10px;background:var(--dsw-specific-sidebar-fill,var(--dsw-alias-bg-layer-1))}.cm-peak-intro-label{display:block;margin-bottom:4px;font-size:11px;color:var(--dsw-alias-label-tertiary)}.cm-peak-intro-note{margin:0;font-size:11px;line-height:1.7;color:var(--dsw-alias-label-tertiary)}.cm-peak-intro .cm-buttons{justify-content:flex-end;margin:0}.cm-peak-intro .cm-peak-progress.variant-full{padding:5px 0 1px}@media(max-width:480px){.cm-peak-intro .cm-stat-dialog-body{padding:14px;gap:12px}.cm-peak-intro-field{gap:8px}}
|
|
2
|
+
`,B="dsh-cost-meter:peak-progress-intro-v1",j=new Set;let H=!1,P=null;const K=()=>{if(H)return!0;try{return window.localStorage.getItem(B)==="1"}catch{return!1}},R=()=>{H=!0;try{window.localStorage.setItem(B,"1")}catch{}for(const L of j)L(!0)};function Y(L){const{peakView:V,peakPhaseAt:J,phaseLabelKeys:Q,countdownText:X,resolveLocale:E,makeT:$,Tooltip:ee}=L;let y=document.getElementById("dsh-cost-meter-peak-style");y||(y=document.createElement("style"),y.id="dsh-cost-meter-peak-style",document.head.appendChild(y)),y.textContent=G;function ae(t,c){const l=V(t,c);if(!l)return null;let n=l.prevAtMs;for(let i=0;i<16;i++){const m=J(n-1,t.peakWindows,t.peakHolidays);if(!m||m.inPeak!==l.inPeak||m.prevAtMs>=n)break;n=m.prevAtMs}const N=Math.max(0,Math.min(100,(c-n)/Math.max(1,l.nextAtMs-n)*100)),d=E(t)==="en"?"en":"zh-CN",g=i=>new Intl.DateTimeFormat(d,{timeZone:"Asia/Shanghai",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).format(i),a=i=>new Intl.DateTimeFormat("en-CA",{timeZone:"Asia/Shanghai",year:"numeric",month:"2-digit",day:"2-digit"}).format(i),o=i=>a(i)===a(c)?g(i):new Intl.DateTimeFormat(d,{timeZone:"Asia/Shanghai",...l.holiday||Math.abs(i-c)>=7*864e5?{month:"numeric",day:"numeric"}:{weekday:"short"}}).format(i)+" "+g(i);return{...l,start:n,progress:N,startText:o(n),switchTime:o(l.nextAtMs)}}function Z({config:t,t:c,now:l,rail:n=!1}){const[N,d]=b(Date.now());I(()=>{if(l!==void 0)return;let M;const z=()=>{if(window.clearTimeout(M),document.hidden)return;const A=Date.now(),ie=V(t,A);d(A),M=window.setTimeout(z,Math.max(100,Math.min(3e4,(ie?.nextAtMs??A+3e4)-A)))};return z(),document.addEventListener("visibilitychange",z),()=>{window.clearTimeout(M),document.removeEventListener("visibilitychange",z)}},[l,t.peakWindows,t.peakHolidays]);const g=l??N,a=ae(t,g);if(!a)return null;const o=E(t)==="en",i=Q(a),m=c(a.nextIntoPeak?"peakShort":"offPeakShort"),S=Math.max(1,Math.ceil((a.nextAtMs-g)/6e4)),h=Math.floor(S/1440),u=Math.floor(S%1440/60),s=S%60,q=h>0?o?h+"d "+u+"h"+(s?" "+s+"m":""):h+"天"+(u?u+"小时":"")+(s?s+"分":""):X(a,g,c),v=o?(h?h+"d ":"")+(u?u+"h ":"")+(s?s+"m":""):(h?h+"天":"")+(u?u+"时":"")+(s?s+"分":""),k=(o?"In ":"剩余 ")+q,x=a.switchTime+(o?" · ":" 转")+m,F=a.startText+" — "+a.switchTime,r=[c(i.notice),(o?"Beijing time · ":"北京时间 · ")+F,k+" · "+x,(o?"Elapsed ":"本时段已过 ")+a.progress.toFixed(1)+"%"].join(`
|
|
3
|
+
`),p=t.peakTimeDisplay??"both",f=t.peakProgressVariant??(t.sidebarSimple?"simple":t.sidebarStyle==="compact"?"compact":"full"),T=a.holiday?o?"Holiday · off-peak":"节假日 · 全天谷价":a.weekend?o?"Weekend · off-peak":"周末 · 全天谷价":c(i.short),w=a.holiday?o?"Holiday":"假日":a.weekend?o?"Weekend":"周末":c(i.short),W=M=>e("span",{className:"cm-peak-progress-phase"},e("i",{"aria-hidden":!0}),M),D=e("div",{className:"cm-peak-progress-track",role:"progressbar","aria-label":o?"Current pricing period elapsed":"当前计价时段已过进度","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(a.progress*10)/10,"aria-valuetext":r},e("span",{className:"cm-peak-progress-fill",style:{[n?"height":"width"]:a.progress+"%"}})),se=p==="countdown"?v:p==="switch"?a.switchTime+" → "+m:a.switchTime+" · "+v,re=n?e(C,null,D,e("span",{className:"cm-peak-progress-rail-label"},w)):f==="compact"?e(C,null,W(w),D,e("span",{className:"cm-peak-progress-time"},se)):f==="simple"?e(C,null,e("div",{className:"cm-peak-progress-head"},W(a.holiday||a.weekend?w+(o?" · off-peak":"谷价"):w),e("span",{className:"cm-peak-progress-time"},p==="switch"?x:k)),D,p==="both"?e("div",{className:"cm-peak-progress-meta"},e("span",null,x)):null):e(C,null,e("div",{className:"cm-peak-progress-head"},W(T),e("span",{className:"cm-peak-progress-time"},p==="switch"?x:k)),D,p==="both"?e("div",{className:"cm-peak-progress-meta"},e("span",null,a.startText+(o?" start":" 开始")),e("span",null,x)):null);return e(ee,{portal:!0,label:r,side:"right",delayMs:300},e("div",{"data-cm-display":"peak",title:r,className:"cm-peak-progress "+(a.inPeak?"peak":"off")+(n?" rail":" variant-"+f),"data-variant":f,"data-progress":a.progress,"data-switch-at":a.nextAtMs},re))}function te({config:t,api:c}){const l=_(null),n=_(!1),[N,d]=b(K),[g,a]=b(!1),[o,i]=b(!1),[m,S]=b(t.peakTimeDisplay??"both"),[h]=b(Date.now),u=E(t)==="en",s=(r,p)=>u?p:r,v=t.peakEnabled===!0&&t.peakNotice!==!1&&t.peakProgressPromptSeen!==!0&&t.peakWindows?.length>0&&!N;if(I(()=>(j.add(d),()=>j.delete(d)),[]),I(()=>{if(!v)return;const r={},p=document.activeElement,f=l.current,T=new MutationObserver(()=>w()),w=()=>{P||K()||document.querySelector("dialog[open], .cm-qguide")||(P=r,T.disconnect(),f?.showModal())};return T.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["open"]}),w(),()=>{T.disconnect(),P===r&&(P=null,f?.close(),p?.isConnected&&p.focus?.())}},[v]),!v)return null;const k=()=>{R(),d(!0),Promise.resolve().then(()=>c.updateConfig({peakProgressPromptSeen:!0})).catch(()=>{})},x=async()=>{if(!n.current){n.current=!0,a(!0),i(!1);try{const r=await c.updateConfig({peakStyle:"progress",peakTimeDisplay:m,peakProgressPromptSeen:!0});if(r?.config?.peakStyle!=="progress"||r.config.peakTimeDisplay!==m)throw new Error("save failed");R(),d(!0)}catch{i(!0)}finally{n.current=!1,a(!1)}}},F={...t,peakEnabled:!0,peakNotice:!0,peakEffectiveAt:"",peakTimeDisplay:m};return e("dialog",{ref:l,className:"cm-stat-dialog cm-peak-intro","aria-label":s("峰谷时段新增进度条","New peak-period progress bar"),onCancel:r=>{r.preventDefault(),k()}},e("header",{className:"cm-stat-dialog-head"},e("strong",null,s("峰谷时段新增进度条","New peak-period progress bar")),e("button",{type:"button",className:"cm-btn","aria-label":s("关闭","Close"),onClick:k},"×")),e("div",{className:"cm-stat-dialog-body"},e("p",{className:"cm-peak-intro-description"},s("显示时段进度、剩余时长和切换时间。简洁两行,紧凑单行;周末和节假日也能看清下一次切换。","See time progress, time remaining and the next switch. Simple uses two lines; compact uses one, including weekends and holidays.")),e("label",{className:"cm-peak-intro-field"},s("显示时间","Time display"),e("select",{className:"cm-input",value:m,onChange:r=>S(r.target.value)},...[["both",s("倒计时 + 切换时间","Countdown + switch time")],["countdown",s("只看倒计时","Countdown")],["switch",s("只看切换时间","Switch time")]].map(([r,p])=>e("option",{key:r,value:r},p)))),e("div",{className:"cm-peak-intro-previews","aria-label":s("当前时段预览","Current period preview")},...[["full",s("标准","Standard")],["simple",s("简洁 · 两行","Simple · two lines")],["compact",s("紧凑 · 单行","Compact · one line")]].map(([r,p])=>e("section",{key:r,className:"cm-peak-intro-sample"},e("span",{className:"cm-peak-intro-label"},p),e(Z,{config:{...F,peakProgressVariant:r},t:$(E(t)),now:h})))),e("p",{className:"cm-peak-intro-note"},s("按北京时间显示,不改变计价。以后可在“显示”中切换,原样式仍保留。","Uses Beijing time and does not change billing. Switch styles later in Display; the existing styles remain available.")),o?e("p",{className:"cm-msg err",role:"alert"},s("保存失败,请重试;也可以先关闭预览。","Could not save. Retry or close the preview.")):null,e("div",{className:"cm-buttons"},e("button",{type:"button",className:"cm-btn",onClick:k},s("保留原样","Keep current style")),e("button",{type:"button",className:"cm-btn primary",disabled:g,onClick:x},g?s("正在保存…","Saving…"):s("使用进度条","Use progress bar")))))}return t=>e(t.view==="guide"?te:Z,t)}return{mount:Y}}});
|
package/lib/client.pricing.js
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
window.__ModuleLoader__.load({id:"dsh-cost-meter",chunk:"client.pricing.js",factory:ne=>{const{createElement:e,Fragment:be,useState:M,useEffect:te,useLayoutEffect:le,useMemo:V,useRef:ae,useId:xe}=ne("react");let re=null;try{re=ne("react-dom")?.createPortal??null}catch{}const we=["at","before","after","days","sessions","skipped"],ie=t=>["deepseek-official:deepseek-web-search","deepseek-official:deepseek-web-fetch"].includes(t),Z={parse:t=>{if(!Array.isArray(t)||!t.every(o=>we.every(O=>Number.isFinite(o?.[O])&&o[O]>=0)&&(o.model===void 0||typeof o.model=="string")))throw new Error("Invalid recalculation history");return t}},oe={parse:t=>{if(typeof t?.ok!="boolean"||typeof t?.message!="string")throw new Error("Invalid recalculation result");return t}},ce={parse:t=>{if(typeof t!="boolean")throw new Error("Expected confirmation");return t}},me={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}},de={parse:t=>{if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Invalid price catalog");return t}},X=(t,o)=>({mode:"strict",typeSymbol:"dsh-cost-meter#"+t,schema:o,create:()=>o}),pe={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:X("PriceCatalog",de)},{id:"dsh-cost-meter#costMeter/getRepricingHistory",service:"costMeter",namespace:"costMeter",method:"getRepricingHistory",invocation:{kind:"direct"},parameters:[],result:X("RepricingHistory",Z)},{id:"dsh-cost-meter#costMeter/repriceHistory",service:"costMeter",namespace:"costMeter",method:"repriceHistory",invocation:{kind:"direct"},parameters:[{name:"confirmed",wire:"confirmed",source:"json",codec:X("RepricingConfirmation",ce)}],result:X("FetchPricesResult",oe)},{id:"dsh-cost-meter#costMeter/repriceModelHistory",service:"costMeter",namespace:"costMeter",method:"repriceModelHistory",invocation:{kind:"direct"},parameters:[{name:"confirmed",wire:"confirmed",source:"json",codec:X("RepricingConfirmation",ce)},{name:"model",wire:"model",source:"json",codec:X("RepricingModel",me)}],result:X("FetchPricesResult",oe)}]},ye=t=>(t.label+" "+t.value).toLowerCase();function se({options:t,value:o,placeholder:O,label:u,ariaLabel:h,locale:d,onChange:l}){const y=d==="en",k=xe(),g=k+"-list",[R,N]=M(""),[p,$]=M(!1),[x,w]=M(0),[C,s]=M(null),f=ae(null),A=ae(null),n=ae(null),m=t.find(i=>i.value===o),P=R.toLowerCase().trim().split(/\s+/).filter(Boolean),j=V(()=>t.map(i=>({option:i,search:ye(i)})),[t]),D=i=>{const b=i.toLowerCase().trim().split(/\s+/).filter(Boolean);return b.length?j.filter(_=>b.every(E=>_.search.includes(E))).map(_=>_.option):t},c=D(R),L=m&&!c.includes(m)?[m,...c]:c,T=Math.max(0,Math.min(x,L.length-1)),F=()=>{$(!1),N("")},q=()=>{p||(s(null),N(""),w(Math.max(0,L.findIndex(i=>i.value===o))),$(!0))},r=i=>{i&&(i.value!==o&&l(i.value),F())},z=()=>{if(p&&R){N(""),w(0);return}o&&l(""),F()};le(()=>{if(!p||typeof document>"u")return;const i=A.current,b=typeof window>"u"?null:window,_=()=>{const E=i?.getBoundingClientRect?.();if(!E||!b)return;const J=b.innerHeight,a=12,v=J-E.bottom-a,S=E.top-a,B=v<180&&S>v,I=Math.max(60,B?S:v),H=Math.max(0,Math.min(280,I,J-a*2)),K=Math.max(a,Math.min(B?E.top-H-6:E.bottom+6,J-H-a));s(Q=>Q&&Q.left===E.left&&Q.top===K&&Q.width===E.width&&Q.maxHeight===H?Q:{left:E.left,top:K,width:E.width,maxHeight:H})};if(_(),typeof b?.addEventListener=="function")return b.addEventListener("scroll",_,!0),b.addEventListener("resize",_),()=>{b.removeEventListener("scroll",_,!0),b.removeEventListener("resize",_)}},[p]),te(()=>{if(!p||typeof document>"u"||typeof document.addEventListener!="function")return;const i=b=>{f.current?.contains?.(b.target)||n.current?.contains?.(b.target)||F()};return document.addEventListener("pointerdown",i,!0),()=>document.removeEventListener("pointerdown",i,!0)},[p]),le(()=>{!p||!C||n.current?.querySelector?.('[data-active="true"]')?.scrollIntoView?.({block:"nearest"})},[p,T,C,R]);const U=i=>k+"-opt-"+i,G=P.length?c.length?y?`${c.length} matches`:`${c.length} 个结果`:L.length?y?"No matches · showing the current choice":"没有匹配的模型 · 下面是当前选择":y?"No matches":"没有匹配的模型":null,Y=p?e("div",{ref:n,className:"cm-combo-panel",style:C??{visibility:"hidden"}},L.length?e("div",{className:"cm-combo-list",id:g,role:"listbox","aria-label":u},L.map((i,b)=>e("button",{key:i.value,id:U(b),type:"button",role:"option",className:"cm-combo-option"+(b===T?" active":""),"data-active":String(b===T),"aria-selected":String(i.value===o),onMouseEnter:()=>w(b),onMouseDown:_=>_.preventDefault(),onClick:()=>r(i)},i.label))):null,G?e("p",{className:"cm-combo-note",role:"status"},G):null):null;return e("div",{ref:f,className:"cm-price-search cm-combo"},e("div",{className:"cm-combo-control"},e("input",{ref:A,type:"search",className:"cm-input cm-combo-input",autoComplete:"off",value:p?R:m?.label??"",role:"combobox","aria-expanded":String(p),"aria-autocomplete":"list","aria-controls":p&&L.length?g:void 0,"aria-activedescendant":p&&L.length?U(T):void 0,"aria-label":h??u+(y?" · Price model":" · 价格模型"),placeholder:p&&m?m.label:O,onFocus:q,onClick:()=>{p||q()},onChange:i=>{const b=i.target.value,_=!p&&m&&b.startsWith(m.label)?b.slice(m.label.length):b,E=D(_);N(_),$(!0),w(m&&E.length>0&&!E.includes(m)?1:0)},onKeyDown:i=>{if(!i.nativeEvent?.isComposing){if(i.key==="Escape"){if(i.preventDefault(),!p)return;F(),i.stopPropagation();return}if(i.key==="ArrowDown"||i.key==="ArrowUp"){if(i.preventDefault(),!p){q();return}w(Math.max(0,Math.min(L.length-1,T+(i.key==="ArrowDown"?1:-1))));return}if(i.key==="Enter"&&p&&L[T]){i.preventDefault(),r(L[T]);return}i.key==="Tab"&&F()}}}),o||R?e("button",{type:"button",className:"cm-combo-clear","aria-label":(y?"Clear ":"清空 ")+u,onMouseDown:i=>i.preventDefault(),onClick:z},"×"):null,e("button",{type:"button",className:"cm-combo-caret",tabIndex:-1,"aria-hidden":"true",onMouseDown:i=>i.preventDefault(),onClick:()=>{p?F():(A.current?.focus?.(),q())}},"▾")),Y&&re?re(Y,document.body):Y)}function ue({state:t,draft:o,setDraft:O,locale:u,rpc:h}){const[d,l]=M(!1),[y,k]=M(null),[g,R]=M(""),[N,p]=M(""),[$,x]=M(0),w=t.config.prices.currency??"USD",C=u==="en";te(()=>{if(!d)return;let n=!0;return k(null),p(""),R(""),h("getPriceCatalog").then(m=>{n&&k(m)},m=>{n&&p(String(m.message??m))}),()=>{n=!1}},[d,w,$,h]);const s=[];for(const[n,m]of Object.entries(y??{}))for(const P of Object.values(m))for(const[j,D]of Object.entries(P))!(n==="deepseek"?o?.prices.models[j]:o?.prices.providers?.[n]?.models?.[j])&&!D.unpriced&&s.push({value:n+":"+j,label:n+" · "+j,provider:n,id:j,entry:D});const f=s.find(n=>n.value===g),A=()=>{if(!f||!o)return;const{provider:n,id:m,entry:P}=f,j=JSON.parse(JSON.stringify(P)),D=o.prices;O({...o,prices:n==="deepseek"?{...D,models:{...D.models,[m]:j}}:{...D,providers:{...D.providers,[n]:{...D.providers?.[n],models:{...D.providers?.[n]?.models,[m]:j}}}}}),R("")};return e("div",{className:"cm-restore-prices"},e("button",{type:"button",className:"cm-btn small","aria-expanded":d,onClick:()=>l(n=>!n)},d?C?"Close restore":"收起恢复入口":C?"Restore bundled model":"恢复内置模型"),d?e("div",{className:"cm-collapse-body"},N?e("div",{role:"alert",className:"cm-err"},N,e("button",{type:"button",className:"cm-btn small",onClick:()=>x(n=>n+1)},C?"Retry":"重试")):y===null?e("p",{role:"status",className:"cm-hint"},C?"Loading prices…":"读取价格…"):s.length?e(be,null,e(se,{options:s,value:f?g:"",placeholder:C?"Select a model":"选择模型",label:C?"Restore model":"恢复模型",locale:u,onChange:R}),e("button",{type:"button",className:"cm-btn small",disabled:!f,onClick:A},C?"Restore":"恢复")):e("p",{className:"cm-hint"},C?"All bundled models are mounted.":"内置模型均已挂载。")):null)}function ve({value:t,label:o,locale:O,onChange:u,t:h,priceEditor:d}){const l=O==="en",{PriceInput:y,priceFactor:k,setPriceFactor:g,multiplierOptions:R}=d,N=[["cacheMiss",l?"Input · cache miss":"输入 · 未命中缓存"],["cacheHit",l?"Cached input":"缓存读取"],["output",l?"Output":"输出"],["cacheWrite",l?"Cache write":"缓存写入"],["reasoning",l?"Separate reasoning":"单独推理费用"]],p=(x,w,C)=>{const s={...t};w===null?delete s[x]:s[x]=w,g(s,"base."+x,C),u(s)},$=([x,w])=>e("label",{key:x},w,e("span",{className:"cm-custom-amount"},e("span",{"aria-hidden":!0},t.currency==="CNY"?"¥":"$"),e(y,{entry:t,value:t[x]??null,path:"base."+x,t:h,emptyMode:["cacheWrite","reasoning"].includes(x)?"clear":"ignore",label:o+" · "+w,placeholder:x==="cacheWrite"?l?"Same as cached input":"跟随缓存读取":x==="reasoning"?l?"Included in output":"含在输出中":"0",onCommit:(C,s)=>p(x,C,s)})));return e("fieldset",{className:"cm-custom-price","aria-label":o+(l?" · Custom price":" · 自定义价格")},e("legend",null,l?"Custom price · per 1M tokens":"自定义价格 · 每百万 Token"),e("div",{className:"cm-custom-head"},e("span",null,l?"Only this channel and model":"仅用于此渠道的这个模型"),e("label",null,l?"Currency":"币种",e("select",{className:"cm-input",value:t.currency,onChange:x=>u({...t,currency:x.target.value})},e("option",{value:"USD"},l?"USD · US dollar":"USD · 美元"),e("option",{value:"CNY"},l?"CNY · Yuan":"CNY · 人民币")))),e("div",{className:"cm-custom-grid"},...N.slice(0,3).map($)),R(t,h,x=>u({...t,separateMultipliers:x,multipliers:{}})),e("div",{className:"cm-custom-effective",role:"status"},e("div",{className:"cm-effective-heading"},e("span",null,l?"Effective prices":"实际单价"),e("small",null,l?"Price × multiplier / 1M tokens":"单价 × 倍率 / 百万 Token")),e("div",{className:"cm-effective-grid"},...N.slice(0,3).map(([x,w])=>e("div",{key:x},e("span",null,w),e("strong",null,(t.currency==="CNY"?"¥":"$")+Number((t[x]*k(t,"base."+x)).toPrecision(8)).toLocaleString(l?"en-US":"zh-CN",{maximumFractionDigits:8})))))),e("details",{className:"cm-custom-more"},e("summary",null,l?"More billing fields":"更多计费项"),e("div",{className:"cm-custom-grid"},...N.slice(3).map($)),e("p",{className:"cm-hint"},l?"Leave reasoning blank when it is included in output. Leave cache write blank to use the cached input rate.":"推理已包含在输出中时无需另填。缓存写入留空则使用缓存读取价格。")),e("p",{className:"cm-hint"},l?"Enter or leave a field to save. Switching the price source keeps your custom values.":"回车或离开输入框后保存;切换价格来源会保留已填的自定义价格。"))}function ge({entry:t,currency:o,priceEditor:O,locale:u,local:h=!1}){const d=u==="en",l=t?O?.priceAt?.(t)??t:null;return e("span",{className:"cm-rate-summary"},...[["cacheMiss","input",d?"Input":"输入"],["cacheHit","cachedInput",d?"Cached input":"缓存读取"],["output","output",d?"Output":"输出"]].map(([k,g,R])=>{const N=h?0:l?.unpriced?null:l?.[k]??l?.[g],p=N==null?null:N*(O?.priceFactor?.(l??{},"base."+k)??1);return e("span",{key:k,className:"cm-rate-item"},e("span",null,R),e("strong",null,p===null?"—":(o==="CNY"?"¥":"$")+Number(p.toPrecision(8)).toLocaleString(d?"en-US":"zh-CN",{maximumFractionDigits:8})))}))}function Ne({state:t,draft:o,setDraft:O,t:u,locale:h,resolveClientPrice:d,prettyProviderKey:l,setField:y,priceEditor:k}){const[g,R]=M(""),[N,p]=M(24),[$,x]=M(null),[w,C]=M({}),s=h==="en",f=t.config,A=o?.priceOverrides??f.priceOverrides??{},n=o?.priceMatchDismissed??f.priceMatchDismissed??[],m=o?.prices??f.prices,P=t.today.byProviderModel??{},j=o?.priceMatch??f.priceMatch,D=V(()=>({prices:m,priceMatch:j}),[m,j]),c=V(()=>Object.keys(P).filter(a=>{if(ie(a)||n.includes(a)||A[a]!==void 0)return!1;const v=a.indexOf(":"),S=(v>0?a.slice(0,v):"deepseek").toLowerCase(),B=v>0?a.slice(v+1):a;return d(S,B,D).matched!==!0}),[P,n,A,D,d]),L=[...new Set([...c,...Object.keys(A)])].filter(a=>!n.includes(a)&&!ie(a)),T=t.month?.byProviderModel??{},F=V(()=>Object.keys(T).filter(a=>{if(ie(a)||n.includes(a)||A[a]!==void 0)return!1;const v=a.indexOf(":"),S=(v>0?a.slice(0,v):"deepseek").toLowerCase(),B=v>0?a.slice(v+1):a;return d(S,B,D).matched===!0}).sort(),[T,n,A,D,d]),q=V(()=>[{value:"deepseek:__default__",label:u("overrideTargetDefault")},...Object.keys(m.models??{}).map(a=>({value:"deepseek:"+a,label:"DeepSeek · "+a})),...Object.entries(m.providers??{}).flatMap(([a,v])=>Object.keys(v?.models??{}).map(S=>({value:a+":"+S,label:a+" · "+S})))],[m.models,m.providers,h,u]),r=(a,v)=>{if(o===null)return;const S={...o.priceOverrides??{}};if(v===""?delete S[a]:S[a]=v,v==="__custom__"&&!m.custom?.[a]){const B=a.indexOf(":"),I=d(a.slice(0,B),a.slice(B+1),{...f,...o}),H=I.entry??{},K={currency:I.currency??"USD",billingMode:"flat",...k?.priceMultiplierSettings(H),cacheMiss:H.cacheMiss??H.input??0,cacheHit:H.cacheHit??H.cachedInput??H.cacheMiss??H.input??0,output:H.output??0,...H.cacheWrite!==void 0?{cacheWrite:H.cacheWrite}:{},...H.reasoning!==void 0?{reasoning:H.reasoning}:{}};O({...o,priceOverrides:S,prices:{...m,custom:{...m.custom,[a]:K}}})}else O({...o,priceOverrides:S})},z=a=>{if(o===null)return;const v={...o.priceOverrides??{}};delete v[a],O({...o,priceOverrides:v,priceMatchDismissed:[...new Set([...n,a])]})},U=g.trim().toLowerCase().split(/\s+/).filter(Boolean),G=a=>a.filter(v=>U.every(S=>l(v).toLowerCase().includes(S))),Y=G(L),i=G(F),b=Y.length+i.length,_=Y.slice(0,N),E=i.slice(0,Math.max(0,N-_.length)),J=(a,v)=>{const S=l(a),B=S.indexOf(":"),I=A[a],H=$===a,K=w[a]??(I==="__custom__"?"custom":I==="__local__"?"local":I?"catalog":"auto"),Q=a.indexOf(":"),ee=d(Q>0?a.slice(0,Q):"deepseek",Q>0?a.slice(Q+1):a,{...f,...o}),fe=W=>{C({...w,[a]:W}),W!=="catalog"&&r(a,W==="custom"?"__custom__":W==="local"?"__local__":"")},_e=v?s?"Automatic":"自动匹配":I==="__custom__"?s?"Custom price":"自定义价格":I==="__local__"?s?"Local · free":"本地 · 零费用":I?s?"Price table":"指定价格表":s?"Needs a price":"待设置价格";return e("div",{key:a,className:"cm-match-row"},e("div",{className:"cm-model-head"},e("div",{className:"cm-model-identity",title:S},e("span",{className:"cm-model-provider"},B>0?S.slice(0,B):"DeepSeek"),e("strong",null,B>0?S.slice(B+1):S)),e("span",{className:"cm-model-badge"+(!v&&!I?" needs-price":"")},_e),e("button",{type:"button",className:"cm-btn small cm-model-edit","aria-expanded":H,"aria-label":S+(s?" · Set price":" · 设置价格"),onClick:()=>x(H?null:a)},H?s?"Collapse":"收起":s?"Set price":"设置价格")),e("div",{className:"cm-model-current"},e("span",{className:"cm-note"},(s?"Base reference rates · ":"基础参考单价 · ")+(ee.currency??"USD")+(s?" / 1M tokens · multipliers included":" / 百万 Token · 已含倍率")),e(ge,{entry:ee.entry,currency:ee.currency,priceEditor:k,locale:h,local:I==="__local__"})),H?e("div",{className:"cm-model-editor"},e("div",{className:"cm-source-choices",role:"group","aria-label":s?"Price source":"价格来源"},...[["auto","自动匹配","Automatic"],["catalog","价格表","Price table"],["custom","自定义","Custom"],["local","本地","Local"]].map(([W,Se,ze])=>e("button",{key:W,type:"button",className:"cm-source-choice"+(K===W?" active":""),"aria-pressed":K===W,onClick:()=>fe(W)},s?ze:Se))),K==="catalog"?e("div",{className:"cm-model-source"},e("span",null,s?"Select a reference model":"选择参考模型"),e(se,{value:I&&!I.startsWith("__")?I:"",options:q,placeholder:s?"Choose a price table entry":"选择价格表条目",label:S,locale:h,onChange:W=>{W?r(a,W):fe("auto")}}),!I||I.startsWith("__")?e("p",{className:"cm-note"},s?"Current pricing stays in effect until you choose an entry.":"选定条目后生效,选择前仍使用原价格。"):null):null,K==="custom"&&I==="__custom__"&&m.custom?.[a]?e(ve,{value:m.custom[a],label:S,locale:h,t:u,priceEditor:k,onChange:W=>O({...o,prices:{...m,custom:{...m.custom,[a]:W}}})}):null,K==="auto"?e("p",{className:"cm-source-explanation"},ee.matched?s?"The model uses its automatically matched reference price.":"已自动匹配参考价格,后续调用按该价格计费。":s?"No exact price found. Choose a table entry or enter a custom quote.":"尚未命中参考价格,可选择价格表条目或填写自定义价格。"):null,K==="local"?e("p",{className:"cm-source-explanation"},s?"Tokens are tracked; new calls have zero API cost.":"保留 Token 统计,后续调用的 API 费用记为 0。"):null,v?null:e("button",{type:"button",className:"cm-model-dismiss",title:u("removePriceMatchHint"),onClick:()=>z(a)},u("overrideRemove"))):null)};return e("div",{className:"cm-model-matching"},e("div",{className:"cm-pricing-intro"},e("h3",{className:"cm-h"},s?"Set prices by channel and model":"按渠道和模型设置价格"),e("p",{className:"cm-note"},s?"Review current rates. Open a model to change its price source or enter a custom quote.":"先看当前单价,点“设置价格”后选择来源或填写这个渠道的价格。")),e("div",{className:"cm-model-toolbar"},e("input",{type:"search",className:"cm-input",value:g,placeholder:s?"Find a model or channel…":"查找模型或渠道…","aria-label":s?"Find configured models":"查找已用模型",onChange:a=>{R(a.target.value),p(24)},onKeyDown:a=>{a.key==="Escape"&&(R(""),p(24),a.stopPropagation())}}),e("span",{className:"cm-note",role:"status"},s?`${b} models`:`${b} 个模型`)),_.length?e("section",{className:"cm-model-group"},e("h4",{className:"cm-pricing-group-title"},u("unmatchedTitle"),e("span",null,Y.length)),..._.map(a=>J(a,!1))):null,E.length?e("section",{className:"cm-model-group"},e("h4",{className:"cm-pricing-group-title"},u("matchedTitle"),e("span",null,i.length)),...E.map(a=>J(a,!0))):null,b===0?e("p",{className:"cm-pricing-empty"},g?s?"No models found. Try another keyword.":"没有找到模型,试试其他关键词。":s?"Models appear here after their first call.":"调用过的模型会显示在这里,之后可按渠道设置价格。"):null,b>N?e("button",{type:"button",className:"cm-btn",onClick:()=>p(a=>a+24)},s?`Show more · ${b-N} remaining`:`显示更多 · 还有 ${b-N} 个`):null,n.length>0?e("button",{type:"button",className:"cm-btn small",onClick:()=>y("priceMatchDismissed",[])},u("restorePriceMatches",{count:n.length})):null,e("details",{className:"cm-pricing-rules"},e("summary",null,s?"Automatic matching rules":"自动匹配规则"),e("label",{className:"cm-field"},e("span",null,u("priceMatchLabel")),e("select",{className:"cm-input",value:o?.priceMatch==="exact"?"exact":"auto",onChange:a=>y("priceMatch",a.target.value)},e("option",{value:"auto"},u("priceMatchAuto")),e("option",{value:"exact"},u("priceMatchExact")))),e("p",{className:"cm-note"},u("priceMatchNote"))))}function he({open:t,className:o}){return e("svg",{className:"cm-pricing-chevron "+o+(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 Ce({state:t,draft:o,setDraft:O,t:u,locale:h,rpc:d,renderEditor:l,vendorLabels:y,priceEditor:k}){const g=h==="en",[R,N]=M(""),[p,$]=M(""),[x,w]=M({}),[C,s]=M({}),[f,A]=M(null),[n,m]=M(""),P=o?.prices??t.config.prices,j=V(()=>({...P.providers,deepseek:{models:{...P.models,__default__:P.default}}}),[P.models,P.default,P.providers]),D=Object.keys(j).filter(r=>Object.keys(j[r]?.models??{}).length).sort((r,z)=>r===z?0:r==="deepseek"?-1:z==="deepseek"?1:r.localeCompare(z)),c=R.toLowerCase().trim().split(/\s+/).filter(Boolean),L=D.filter(r=>!p||p===r).map(r=>({id:r,ids:Object.keys(j[r].models).filter(z=>c.every(U=>(r+" "+(y[r]??"")+" "+(z==="__default__"?u("defaultModelId"):z)).toLowerCase().includes(U))).sort((z,U)=>z===U?0:z==="__default__"?1:U==="__default__"?-1:z.localeCompare(U))})).filter(r=>r.ids.length),T=L.reduce((r,z)=>r+z.ids.length,0),F=r=>{N(r),s({}),w({})},q=()=>{const r=n.trim().toLowerCase();!o||!/^[a-z0-9_.-]+$/.test(r)||Object.hasOwn(P.models,r)||(O({...o,prices:{...P,models:{...P.models,[r]:{cacheHit:0,cacheMiss:0,output:0}}}}),m(""),$("deepseek"),N(r),w(z=>({...z,deepseek:!0})),A("deepseek:"+r))};return e("div",{className:"cm-reference-prices"},e("p",{className:"cm-note"},g?"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:R,"aria-label":g?"Search mounted prices":"搜索已挂载价格",placeholder:g?"Search models or providers…":"搜索模型或厂商…",onChange:r=>F(r.target.value),onKeyDown:r=>{r.key==="Escape"&&(F(""),r.stopPropagation())}}),e("select",{className:"cm-input",value:p,"aria-label":g?"Filter price provider":"筛选价格厂商",onChange:r=>{$(r.target.value),s({}),w({})}},e("option",{value:""},g?"All providers":"全部厂商"),...D.map(r=>e("option",{key:r,value:r},y[r]??r))),e("span",{className:"cm-note",role:"status"},g?`${T} models`:`${T} 个模型`)),...L.map(({id:r,ids:z})=>{const U=x[r]??(r==="deepseek"||c.length>0||p===r),G=r==="deepseek"?P.currency??"USD":"USD",Y=C[r]??16;return e("section",{key:r,className:"cm-catalog-group"},e("button",{type:"button",className:"cm-catalog-vendor cm-vendor-toggle","aria-expanded":U,onClick:()=>w(i=>({...i,[r]:!U}))},e("span",null,e(he,{className:"cm-catalog-caret",open:U}),y[r]??r,e("small",null,z.length)),e("span",{className:"cm-catalog-unit"},G+(g?" / 1M tokens":" / 百万 Token"))),U?e("div",{className:"cm-catalog-list"},e("div",{className:"cm-catalog-columns","aria-hidden":!0},...[g?"Model":"模型",g?"Input":"输入",g?"Cached input":"缓存读取",g?"Output":"输出",""].map((i,b)=>e("span",{key:b},i))),...z.slice(0,Y).map(i=>{const b=r+":"+i,_=j[r].models[i],E=f===b,J=i==="__default__"?u("defaultModelId"):i,a=_?.peak||_?.offPeak?g?"Peak / off-peak":"含峰谷价格":_?.longContext?g?"Long context":"含长上下文档位":_?.cny?g?"USD + CNY":"美元 / 人民币":null;return e("div",{key:b,className:"cm-catalog-entry"+(E?" editing":"")},e("button",{type:"button",className:"cm-catalog-model","aria-label":J+(g?" · Edit price":" · 编辑价格"),"aria-expanded":E,onClick:()=>A(E?null:b)},e("span",{className:"cm-catalog-model-name"},e("strong",null,J),a?e("small",null,a):null),e(ge,{entry:_,currency:G,priceEditor:k,locale:h}),e(he,{className:"cm-catalog-edit-caret",open:E})),E?e("div",{className:"cm-catalog-editor"},l(r,i,_)):null)}),z.length>Y?e("button",{type:"button",className:"cm-catalog-more",onClick:()=>s(i=>({...i,[r]:Y+16}))},g?`Show more · ${z.length-Y} remaining`:`显示更多 · 还有 ${z.length-Y} 个`):null):null)}),T===0?e("p",{className:"cm-pricing-empty"},g?"No matching models.":"没有找到匹配的模型。"):null,e("details",{className:"cm-pricing-rules"},e("summary",null,g?"Pricing notes":"计价说明"),e("p",{className:"cm-note"},u("priceTableNote"))),e("details",{className:"cm-catalog-manage"},e("summary",null,g?"Add or restore models":"添加与恢复模型"),e("div",{className:"cm-catalog-add"},e("input",{className:"cm-input",value:n,"aria-label":u("newModelPlaceholder"),placeholder:u("newModelPlaceholder"),onChange:r=>m(r.target.value),onKeyDown:r=>{r.key==="Enter"&&(r.preventDefault(),q())}}),e("button",{type:"button",className:"cm-btn small",disabled:!/^[a-z0-9_.-]+$/.test(n.trim().toLowerCase())||Object.hasOwn(P.models,n.trim().toLowerCase()),onClick:q},u("addModel"))),e(ue,{state:t,draft:o,setDraft:O,locale:h,rpc:d})))}function Me({state:t,locale:o,formatMoneyUsd:O,api:u,rpc:h,disabled:d}){const[l,y]=M(!1),[k,g]=M(!1),[R,N]=M(""),[p,$]=M([]),[x,w]=M(""),[C,s]=M(""),f=o==="en",A=(c,L)=>{const T=t.config.currency==="CNY"?"Cny":t.config.currency==="EUR"?"Eur":"",F=T&&c[L+T],q=Number(t.config.exchangeRate);return O(typeof F=="number"&&q>0?F/q:c[L],t.config)},n=f?"All models":"全部模型",m=V(()=>[...new Set([t.today,t.month,...t.history??[]].flatMap(c=>Object.keys(c?.byProviderModel??{})))].filter(c=>c.indexOf(":")>0).sort(),[t.today,t.month,t.history]),P=V(()=>[{value:"",label:n},...m.map(c=>({value:c,label:c}))],[m,n]),j=()=>h("getRepricingHistory").then(c=>{$(Z.parse(c)),w("")}).catch(c=>w(String(c.message??c)));te(()=>{let c=!0;return h("getRepricingHistory").then(L=>{c&&$(Z.parse(L))},L=>{c&&w(String(L.message??L))}),()=>{c=!1}},[h]);const D=async()=>{if(!(!l||k||d)){g(!0),w(""),N("");try{const c=C?await h("repriceModelHistory",!0,C):await h("repriceHistory",!0);if(!c.ok)throw new Error(c.message);N(c.message),y(!1),await j(),await u.reload()}catch(c){w(String(c.message??c))}finally{g(!1)}}};return e("section",{className:"cm-repricing"},e("h3",{className:"cm-h"},f?"Historical pricing":"历史费用"),e("p",{className:"cm-note"},f?"Rate changes apply to new calls. Recorded historical rates remain fixed.":"修改价格只影响后续调用,历史费用沿用原价格。"),e("div",{className:"cm-repricing-scope"},e("label",null,f?"Recalculation scope":"重算范围"),e(se,{options:P,value:C,locale:o,label:f?"Choose channel and model":"选择渠道与模型",ariaLabel:f?"Choose channel and model":"选择渠道与模型",placeholder:f?"Search historical models":"搜索历史渠道或模型",onChange:c=>{k||(s(c),y(!1),N(""))}}),e("p",{className:"cm-hint"},C?f?"Only this channel/model changes. Other models and original exchange rates remain unchanged.":"仅重算此渠道下的这个模型,其他模型及原调用汇率保持不变。":f?"Choose a single channel/model to limit the recalculation.":"可选择单个渠道模型,缩小重算范围。")),l?e("div",{className:"cm-repricing-warning",role:"alert",onKeyDown:c=>{c.key==="Escape"&&!k&&(y(!1),c.stopPropagation())}},e("strong",null,(C||n)+(f?" · Historical amounts will change":" · 将修改历史费用")),e("p",null,f?"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:k,onClick:()=>y(!1)},f?"Cancel":"取消"),e("button",{type:"button",className:"cm-btn danger",disabled:k||d,onClick:D},k?f?"Recalculating…":"正在重算…":f?"Confirm recalculation":"确认重算"))):e("button",{type:"button",className:"cm-btn",disabled:d||k,onClick:()=>y(!0)},C?f?"Recalculate this model":"重算此模型的历史费用":f?"Recalculate history at current rates":"按当前价格重算历史"),R?e("p",{role:"status",className:"cm-note"},R):null,x?e("p",{role:"alert",className:"cm-err"},x):null,p.length?e("details",{className:"cm-repricing-history"},e("summary",null,f?"Recalculation records · original amounts retained":"重算记录 · 原金额已保留"),e("div",{className:"cm-stat-scroll"},e("table",{className:"cm-stat-table"},e("thead",null,e("tr",null,...(f?["Time","Scope","Before","After","Session/day records"]:["重算时间","范围","原金额","重算后","会话日期记录"]).map(c=>e("th",{key:c,scope:"col"},c)))),e("tbody",null,...p.map(c=>e("tr",{key:c.at},e("td",null,new Date(c.at).toLocaleString(o)),e("td",null,c.model||n),e("td",null,A(c,"before")),e("td",null,A(c,"after")),e("td",null,c.sessions))))))):null)}async function ke(t){const o=await t.get("remote").$mount(pe);t.effect(()=>()=>o(),"cost-meter: pricing settings contribution");const O=t.get("remote.costMeter"),u=async(d,...l)=>{(d==="repriceHistory"||d==="repriceModelHistory")&&ce.parse(l[0]),d==="repriceModelHistory"&&me.parse(l[1]);const y=await O[d](...l);if(y?.ok!==!0)throw new Error(y?.error?.message??"Pricing request failed");return(d==="getPriceCatalog"?de:d==="getRepricingHistory"?Z:oe).parse(y.value)},h=document.createElement("style");return h.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}",h.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)}",h.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}",h.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(h),h.textContent+=`
|
|
2
|
-
.cm-model-matching{display:grid;gap:
|
|
1
|
+
window.__ModuleLoader__.load({id:"dsh-cost-meter",chunk:"client.pricing.js",factory:le=>{const{createElement:e,Fragment:fe,useState:S,useEffect:re,useLayoutEffect:ie,useMemo:G,useRef:ee,useId:be}=le("react");let oe=null;try{oe=le("react-dom")?.createPortal??null}catch{}const xe=["at","before","after","days","sessions","skipped"],we=a=>["deepseek-official:deepseek-web-search","deepseek-official:deepseek-web-fetch"].includes(a),ae={parse:a=>{if(!Array.isArray(a)||!a.every(o=>xe.every(P=>Number.isFinite(o?.[P])&&o[P]>=0)&&(o.model===void 0||typeof o.model=="string")))throw new Error("Invalid recalculation history");return a}},ce={parse:a=>{if(typeof a?.ok!="boolean"||typeof a?.message!="string")throw new Error("Invalid recalculation result");return a}},se={parse:a=>{if(typeof a!="boolean")throw new Error("Expected confirmation");return a}},me={parse:a=>{if(typeof a!="string"||a.length>2048||a.indexOf(":")<=0||a.endsWith(":")||/[\r\n]/.test(a))throw new Error("Expected channel/model");return a}},de={parse:a=>{if(!a||typeof a!="object"||Array.isArray(a))throw new Error("Invalid price catalog");return a}},X=(a,o)=>({mode:"strict",typeSymbol:"dsh-cost-meter#"+a,schema:o,create:()=>o}),pe={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:X("PriceCatalog",de)},{id:"dsh-cost-meter#costMeter/getRepricingHistory",service:"costMeter",namespace:"costMeter",method:"getRepricingHistory",invocation:{kind:"direct"},parameters:[],result:X("RepricingHistory",ae)},{id:"dsh-cost-meter#costMeter/repriceHistory",service:"costMeter",namespace:"costMeter",method:"repriceHistory",invocation:{kind:"direct"},parameters:[{name:"confirmed",wire:"confirmed",source:"json",codec:X("RepricingConfirmation",se)}],result:X("FetchPricesResult",ce)},{id:"dsh-cost-meter#costMeter/repriceModelHistory",service:"costMeter",namespace:"costMeter",method:"repriceModelHistory",invocation:{kind:"direct"},parameters:[{name:"confirmed",wire:"confirmed",source:"json",codec:X("RepricingConfirmation",se)},{name:"model",wire:"model",source:"json",codec:X("RepricingModel",me)}],result:X("FetchPricesResult",ce)}]},ye=a=>(a.label+" "+a.value).toLowerCase();function ne({options:a,value:o,placeholder:P,label:h,ariaLabel:g,locale:p,onChange:n}){const N=p==="en",z=be(),u=z+"-list",[D,_]=S(""),[d,A]=S(!1),[x,w]=S(0),[k,E]=S(null),f=ee(null),s=ee(null),l=ee(null),b=a.find(i=>i.value===o),O=D.toLowerCase().trim().split(/\s+/).filter(Boolean),y=G(()=>a.map(i=>({option:i,search:ye(i)})),[a]),R=i=>{const v=i.toLowerCase().trim().split(/\s+/).filter(Boolean);return v.length?y.filter(t=>v.every(m=>t.search.includes(m))).map(t=>t.option):a},c=R(D),L=b&&!c.includes(b)?[b,...c]:c,T=Math.max(0,Math.min(x,L.length-1)),F=()=>{A(!1),_("")},B=()=>{d||(E(null),_(""),w(Math.max(0,L.findIndex(i=>i.value===o))),A(!0))},r=i=>{i&&(i.value!==o&&n(i.value),F())},j=()=>{if(d&&D){_(""),w(0);return}o&&n(""),F()};ie(()=>{if(!d||typeof document>"u")return;const i=s.current,v=typeof window>"u"?null:window,t=()=>{const m=i?.getBoundingClientRect?.();if(!m||!v)return;const I=v.innerHeight,M=12,W=I-m.bottom-M,H=m.top-M,Y=W<180&&H>W,Z=Math.max(60,Y?H:W),Q=Math.max(0,Math.min(280,Z,I-M*2)),te=Math.max(M,Math.min(Y?m.top-Q-6:m.bottom+6,I-Q-M));E(q=>q&&q.left===m.left&&q.top===te&&q.width===m.width&&q.maxHeight===Q?q:{left:m.left,top:te,width:m.width,maxHeight:Q})};if(t(),typeof v?.addEventListener=="function")return v.addEventListener("scroll",t,!0),v.addEventListener("resize",t),()=>{v.removeEventListener("scroll",t,!0),v.removeEventListener("resize",t)}},[d]),re(()=>{if(!d||typeof document>"u"||typeof document.addEventListener!="function")return;const i=v=>{f.current?.contains?.(v.target)||l.current?.contains?.(v.target)||F()};return document.addEventListener("pointerdown",i,!0),()=>document.removeEventListener("pointerdown",i,!0)},[d]),ie(()=>{!d||!k||l.current?.querySelector?.('[data-active="true"]')?.scrollIntoView?.({block:"nearest"})},[d,T,k,D]);const U=i=>z+"-opt-"+i,K=O.length?c.length?N?`${c.length} matches`:`${c.length} 个结果`:L.length?N?"No matches · showing the current choice":"没有匹配的模型 · 下面是当前选择":N?"No matches":"没有匹配的模型":null,$=d?e("div",{ref:l,className:"cm-combo-panel",style:k??{visibility:"hidden"}},L.length?e("div",{className:"cm-combo-list",id:u,role:"listbox","aria-label":h},L.map((i,v)=>e("button",{key:i.value,id:U(v),type:"button",role:"option",className:"cm-combo-option"+(v===T?" active":""),"data-active":String(v===T),"aria-selected":String(i.value===o),onMouseEnter:()=>w(v),onMouseDown:t=>t.preventDefault(),onClick:()=>r(i)},i.label))):null,K?e("p",{className:"cm-combo-note",role:"status"},K):null):null;return e("div",{ref:f,className:"cm-price-search cm-combo"},e("div",{className:"cm-combo-control"},e("input",{ref:s,type:"search",className:"cm-input cm-combo-input",autoComplete:"off",value:d?D:b?.label??"",role:"combobox","aria-expanded":String(d),"aria-autocomplete":"list","aria-controls":d&&L.length?u:void 0,"aria-activedescendant":d&&L.length?U(T):void 0,"aria-label":g??h+(N?" · Price model":" · 价格模型"),placeholder:d&&b?b.label:P,onFocus:B,onClick:()=>{d||B()},onChange:i=>{const v=i.target.value,t=!d&&b&&v.startsWith(b.label)?v.slice(b.label.length):v,m=R(t);_(t),A(!0),w(b&&m.length>0&&!m.includes(b)?1:0)},onKeyDown:i=>{if(!i.nativeEvent?.isComposing){if(i.key==="Escape"){if(i.preventDefault(),!d)return;F(),i.stopPropagation();return}if(i.key==="ArrowDown"||i.key==="ArrowUp"){if(i.preventDefault(),!d){B();return}w(Math.max(0,Math.min(L.length-1,T+(i.key==="ArrowDown"?1:-1))));return}if(i.key==="Enter"&&d&&L[T]){i.preventDefault(),r(L[T]);return}i.key==="Tab"&&F()}}}),o||D?e("button",{type:"button",className:"cm-combo-clear","aria-label":(N?"Clear ":"清空 ")+h,onMouseDown:i=>i.preventDefault(),onClick:j},"×"):null,e("button",{type:"button",className:"cm-combo-caret",tabIndex:-1,"aria-hidden":"true",onMouseDown:i=>i.preventDefault(),onClick:()=>{d?F():(s.current?.focus?.(),B())}},"▾")),$&&oe?oe($,document.body):$)}function ue({state:a,draft:o,setDraft:P,locale:h,rpc:g}){const[p,n]=S(!1),[N,z]=S(null),[u,D]=S(""),[_,d]=S(""),[A,x]=S(0),w=a.config.prices.currency??"USD",k=h==="en";re(()=>{if(!p)return;let l=!0;return z(null),d(""),D(""),g("getPriceCatalog").then(b=>{l&&z(b)},b=>{l&&d(String(b.message??b))}),()=>{l=!1}},[p,w,A,g]);const E=[];for(const[l,b]of Object.entries(N??{}))for(const O of Object.values(b))for(const[y,R]of Object.entries(O))!(l==="deepseek"?o?.prices.models[y]:o?.prices.providers?.[l]?.models?.[y])&&!R.unpriced&&E.push({value:l+":"+y,label:l+" · "+y,provider:l,id:y,entry:R});const f=E.find(l=>l.value===u),s=()=>{if(!f||!o)return;const{provider:l,id:b,entry:O}=f,y=JSON.parse(JSON.stringify(O)),R=o.prices;P({...o,prices:l==="deepseek"?{...R,models:{...R.models,[b]:y}}:{...R,providers:{...R.providers,[l]:{...R.providers?.[l],models:{...R.providers?.[l]?.models,[b]:y}}}}}),D("")};return e("div",{className:"cm-restore-prices"},e("button",{type:"button",className:"cm-btn small","aria-expanded":p,onClick:()=>n(l=>!l)},p?k?"Close restore":"收起恢复入口":k?"Restore bundled model":"恢复内置模型"),p?e("div",{className:"cm-collapse-body"},_?e("div",{role:"alert",className:"cm-err"},_,e("button",{type:"button",className:"cm-btn small",onClick:()=>x(l=>l+1)},k?"Retry":"重试")):N===null?e("p",{role:"status",className:"cm-hint"},k?"Loading prices…":"读取价格…"):E.length?e(fe,null,e(ne,{options:E,value:f?u:"",placeholder:k?"Select a model":"选择模型",label:k?"Restore model":"恢复模型",locale:h,onChange:D}),e("button",{type:"button",className:"cm-btn small",disabled:!f,onClick:s},k?"Restore":"恢复")):e("p",{className:"cm-hint"},k?"All bundled models are mounted.":"内置模型均已挂载。")):null)}function ve({value:a,label:o,locale:P,onChange:h,t:g,priceEditor:p}){const n=P==="en",{PriceInput:N,priceFactor:z,setPriceFactor:u,multiplierOptions:D}=p,_=[["cacheMiss",n?"Input · cache miss":"输入 · 未命中缓存"],["cacheHit",n?"Cached input":"缓存读取"],["output",n?"Output":"输出"],["cacheWrite",n?"Cache write":"缓存写入"],["reasoning",n?"Separate reasoning":"单独推理费用"]],d=(x,w,k)=>{const E={...a};w===null?delete E[x]:E[x]=w,u(E,"base."+x,k),h(E)},A=([x,w])=>e("label",{key:x},w,e("span",{className:"cm-custom-amount"},e("span",{"aria-hidden":!0},a.currency==="CNY"?"¥":"$"),e(N,{entry:a,value:a[x]??null,path:"base."+x,t:g,emptyMode:["cacheWrite","reasoning"].includes(x)?"clear":"ignore",label:o+" · "+w,placeholder:x==="cacheWrite"?n?"Same as cached input":"跟随缓存读取":x==="reasoning"?n?"Included in output":"含在输出中":"0",onCommit:(k,E)=>d(x,k,E)})));return e("fieldset",{className:"cm-custom-price","aria-label":o+(n?" · Custom price":" · 自定义价格")},e("legend",null,n?"Custom price · per 1M tokens":"自定义价格 · 每百万 Token"),e("div",{className:"cm-custom-head"},e("span",null,n?"Only this channel and model":"仅用于此渠道的这个模型"),e("label",null,n?"Currency":"币种",e("select",{className:"cm-input",value:a.currency,onChange:x=>h({...a,currency:x.target.value})},e("option",{value:"USD"},n?"USD · US dollar":"USD · 美元"),e("option",{value:"CNY"},n?"CNY · Yuan":"CNY · 人民币")))),e("div",{className:"cm-custom-grid"},..._.slice(0,3).map(A)),D(a,g,x=>h({...a,separateMultipliers:x,multipliers:{}})),e("div",{className:"cm-custom-effective",role:"status"},e("div",{className:"cm-effective-heading"},e("span",null,n?"Effective prices":"实际单价"),e("small",null,n?"Price × multiplier / 1M tokens":"单价 × 倍率 / 百万 Token")),e("div",{className:"cm-effective-grid"},..._.slice(0,3).map(([x,w])=>e("div",{key:x},e("span",null,w),e("strong",null,(a.currency==="CNY"?"¥":"$")+Number((a[x]*z(a,"base."+x)).toPrecision(8)).toLocaleString(n?"en-US":"zh-CN",{maximumFractionDigits:8})))))),e("details",{className:"cm-custom-more"},e("summary",null,n?"More billing fields":"更多计费项"),e("div",{className:"cm-custom-grid"},..._.slice(3).map(A)),e("p",{className:"cm-hint"},n?"Leave reasoning blank when it is included in output. Leave cache write blank to use the cached input rate.":"推理已包含在输出中时无需另填。缓存写入留空则使用缓存读取价格。")),e("p",{className:"cm-hint"},n?"Enter or leave a field to save. Switching the price source keeps your custom values.":"回车或离开输入框后保存;切换价格来源会保留已填的自定义价格。"))}function ge({entry:a,currency:o,priceEditor:P,locale:h,local:g=!1}){const p=h==="en",n=a?P?.priceAt?.(a)??a:null;return e("span",{className:"cm-rate-summary"},...[["cacheMiss","input",p?"Input":"输入"],["cacheHit","cachedInput",p?"Cached input":"缓存读取"],["output","output",p?"Output":"输出"]].map(([z,u,D])=>{const _=g?0:n?.unpriced?null:n?.[z]??n?.[u],d=_==null?null:_*(P?.priceFactor?.(n??{},"base."+z)??1);return e("span",{key:z,className:"cm-rate-item"},e("span",null,D),e("strong",null,d===null?"—":(o==="CNY"?"¥":"$")+Number(d.toPrecision(8)).toLocaleString(p?"en-US":"zh-CN",{maximumFractionDigits:8})))}))}function Ne({state:a,draft:o,setDraft:P,t:h,locale:g,resolveClientPrice:p,prettyProviderKey:n,setField:N,priceEditor:z}){const[u,D]=S(""),[_,d]=S(24),[A,x]=S(null),[w,k]=S({}),E=ee(new Map),f=ee(null),s=g==="en",l=a.config,b=o?.priceOverrides??l.priceOverrides??{},O=o?.priceMatchDismissed??l.priceMatchDismissed??[],y=o?.prices??l.prices,R=o?.modelStatistics??l.modelStatistics??{},c=[["today","今日费用","Today"],["summary","月度与累计","Monthly / all-time"],["budget","预算","Budget"]],L=G(()=>({...a.total?.byProviderModel,...a.month?.byProviderModel,...a.today?.byProviderModel,...Object.fromEntries(Object.keys(R).map(t=>[t,null]))}),[a.total?.byProviderModel,a.month?.byProviderModel,a.today?.byProviderModel,R]),T=G(()=>[...new Set([...Object.keys(L),...Object.keys(b)])].filter(t=>!O.includes(t)&&!we(t)).sort(),[L,b,O]);ie(()=>{const t=E.current.get(f.current)?.querySelector(".cm-custom-price");t&&(f.current=null,t.scrollIntoView({block:"start",inline:"nearest"}),t.querySelector("input")?.focus({preventScroll:!0}))},[y,w]);const F=G(()=>[{value:"deepseek:__default__",label:h("overrideTargetDefault")},...Object.keys(y.models??{}).map(t=>({value:"deepseek:"+t,label:"DeepSeek · "+t})),...Object.entries(y.providers??{}).flatMap(([t,m])=>Object.keys(m?.models??{}).map(I=>({value:t+":"+I,label:t+" · "+I})))],[y.models,y.providers,g,h]),B=(t,m)=>{if(o===null)return;const I={...o.priceOverrides??{}};if(m===""?delete I[t]:I[t]=m,m==="__custom__"&&!y.custom?.[t]){const M=t.indexOf(":"),W=p(t.slice(0,M),t.slice(M+1),{...l,...o}),H=W.entry??{},Y={currency:W.currency??"USD",billingMode:"flat",...z?.priceMultiplierSettings(H),cacheMiss:H.cacheMiss??H.input??0,cacheHit:H.cacheHit??H.cachedInput??H.cacheMiss??H.input??0,output:H.output??0,...H.cacheWrite!==void 0?{cacheWrite:H.cacheWrite}:{},...H.reasoning!==void 0?{reasoning:H.reasoning}:{}};P({...o,priceOverrides:I,prices:{...y,custom:{...y.custom,[t]:Y}}})}else P({...o,priceOverrides:I})},r=t=>{if(o===null)return;const m={...o.priceOverrides??{}};delete m[t],P({...o,priceOverrides:m,priceMatchDismissed:[...new Set([...O,t])]})},j=u.trim().toLowerCase().split(/\s+/).filter(Boolean),K=(t=>t.filter(m=>j.every(I=>n(m).toLowerCase().includes(I))))(T),$=K.length,i=K.slice(0,_),v=t=>{const m=n(t),I=m.indexOf(":"),M=b[t],W=A===t,H=w[t]??(M==="__custom__"?"custom":M==="__local__"?"local":M?"catalog":"auto"),Y=t.indexOf(":"),Z=p(Y>0?t.slice(0,Y):"deepseek",Y>0?t.slice(Y+1):t,{...l,...o}),Q=!M&&Z.matched===!0,te=C=>{C==="custom"&&(f.current=t),k({...w,[t]:C}),C!=="catalog"&&B(t,C==="custom"?"__custom__":C==="local"?"__local__":"")},q=c.filter(([C])=>R[t]?.[C]!==!1),_e=(C,V)=>{if(!o)return;const J={...R,[t]:{today:!0,summary:!0,budget:!0,...R[t],[C]:V}};Object.values(J[t]).every(Boolean)&&delete J[t],P({...o,modelStatistics:J})},Se=Q?s?"Automatic":"自动匹配":M==="__custom__"?s?"Custom price":"自定义价格":M==="__local__"?s?"Local · free":"本地 · 零费用":M?s?"Price table":"指定价格表":s?"Needs a price":"待设置价格";return e("div",{key:t,className:"cm-match-row","data-model-key":t,"data-open":W,ref:C=>{C?E.current.set(t,C):E.current.delete(t)}},e("div",{className:"cm-model-head"},e("div",{className:"cm-model-identity",title:m},e("strong",null,I>0?m.slice(I+1):m),e("span",{className:"cm-model-meta"},e("span",{className:"cm-model-provider"},I>0?m.slice(0,I):"DeepSeek"),e("span",{className:"cm-model-badge"+(!Q&&!M?" needs-price":"")},Se))),e("div",{className:"cm-model-current",title:s?"Effective rates per 1M tokens, including multipliers":"每百万 Token 实际单价,已含倍率"},e(ge,{entry:Z.entry,currency:Z.currency,priceEditor:z,locale:g,local:M==="__local__"})),e("button",{type:"button",className:"cm-btn small cm-model-edit","aria-expanded":W,"aria-label":m+(s?" · Set price":" · 设置价格"),onClick:()=>x(W?null:t)},W?s?"Collapse":"收起":s?"Set price":"设置价格")),e("details",{className:"cm-model-statistics","data-model-statistics":t},e("summary",null,s?"Include in statistics":"计入统计",q.length===3?null:e("span",{className:"cm-note"},q.map(([,C,V])=>s?V:C).join(" · ")||(s?"None":"均不计入"))),e("div",{className:"cm-model-statistics-options"},...c.map(([C,V,J])=>e("label",{key:C,className:"cm-check"},e("input",{type:"checkbox",checked:R[t]?.[C]!==!1,"aria-label":m+" · "+(s?J:V),onChange:ze=>_e(C,ze.target.checked)}),s?J:V)))),W?e("div",{className:"cm-model-editor"},e("div",{className:"cm-source-choices",role:"group","aria-label":s?"Price source":"价格来源"},...[["auto","自动匹配","Automatic"],["catalog","价格表","Price table"],["custom","自定义","Custom"],["local","本地","Local"]].map(([C,V,J])=>e("button",{key:C,type:"button",className:"cm-source-choice"+(H===C?" active":""),"aria-pressed":H===C,onClick:()=>te(C)},s?J:V))),H==="catalog"?e("div",{className:"cm-model-source"},e("span",null,s?"Select a reference model":"选择参考模型"),e(ne,{value:M&&!M.startsWith("__")?M:"",options:F,placeholder:s?"Choose a price table entry":"选择价格表条目",label:m,locale:g,onChange:C=>{C?B(t,C):te("auto")}}),!M||M.startsWith("__")?e("p",{className:"cm-note"},s?"Current pricing stays in effect until you choose an entry.":"选定条目后生效,选择前仍使用原价格。"):null):null,H==="custom"&&M==="__custom__"&&y.custom?.[t]?e(ve,{value:y.custom[t],label:m,locale:g,t:h,priceEditor:z,onChange:C=>P({...o,prices:{...y,custom:{...y.custom,[t]:C}}})}):null,H==="auto"?e("p",{className:"cm-source-explanation"},Z.matched?s?"The model uses its automatically matched reference price.":"已自动匹配参考价格,后续调用按该价格计费。":s?"No exact price found. Choose a table entry or enter a custom quote.":"尚未命中参考价格,可选择价格表条目或填写自定义价格。"):null,H==="local"?e("p",{className:"cm-source-explanation"},s?"Tokens are tracked; new calls have zero API cost.":"保留 Token 统计,后续调用的 API 费用记为 0。"):null,Q?null:e("button",{type:"button",className:"cm-model-dismiss",title:h("removePriceMatchHint"),onClick:()=>r(t)},h("overrideRemove"))):null)};return e("div",{className:"cm-model-matching"},e("div",{className:"cm-model-toolbar"},e("input",{type:"search",className:"cm-input",value:u,placeholder:s?"Find a model or channel…":"查找模型或渠道…","aria-label":s?"Find configured models":"查找已用模型",onChange:t=>{D(t.target.value),d(24)},onKeyDown:t=>{t.key==="Escape"&&(D(""),d(24),t.stopPropagation())}}),e("span",{className:"cm-note",role:"status"},s?`${$} models`:`${$} 个模型`)),i.length?e("div",{className:"cm-model-list"},e("div",{className:"cm-model-columns","aria-hidden":!0},e("span",null,s?"Model / channel":"模型 / 渠道"),e("span",{className:"cm-rate-summary"},...[s?"Input":"输入",s?"Cached input":"缓存读取",s?"Output":"输出"].map(t=>e("span",{key:t},t))),e("span",{title:s?"Per 1M tokens":"每百万 Token"},"/ 1M tok")),...i.map(v)):null,$===0?e("p",{className:"cm-pricing-empty"},u?s?"No models found. Try another keyword.":"没有找到模型,试试其他关键词。":s?"Models appear here after their first call.":"调用过的模型会显示在这里,之后可按渠道设置价格。"):null,$>_?e("button",{type:"button",className:"cm-btn",onClick:()=>d(t=>t+24)},s?`Show more · ${$-_} remaining`:`显示更多 · 还有 ${$-_} 个`):null,O.length>0?e("button",{type:"button",className:"cm-btn small",onClick:()=>N("priceMatchDismissed",[])},h("restorePriceMatches",{count:O.length})):null,e("details",{className:"cm-pricing-rules"},e("summary",null,s?"Automatic matching rules":"自动匹配规则"),e("label",{className:"cm-field"},e("span",null,h("priceMatchLabel")),e("select",{className:"cm-input",value:o?.priceMatch==="exact"?"exact":"auto",onChange:t=>N("priceMatch",t.target.value)},e("option",{value:"auto"},h("priceMatchAuto")),e("option",{value:"exact"},h("priceMatchExact")))),e("p",{className:"cm-note"},h("priceMatchNote"))))}function he({open:a,className:o}){return e("svg",{className:"cm-pricing-chevron "+o+(a?" 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 Ce({state:a,draft:o,setDraft:P,t:h,locale:g,rpc:p,renderEditor:n,vendorLabels:N,priceEditor:z}){const u=g==="en",[D,_]=S(""),[d,A]=S(""),[x,w]=S({}),[k,E]=S({}),[f,s]=S(null),[l,b]=S(""),O=o?.prices??a.config.prices,y=G(()=>({...O.providers,deepseek:{models:{...O.models,__default__:O.default}}}),[O.models,O.default,O.providers]),R=Object.keys(y).filter(r=>Object.keys(y[r]?.models??{}).length).sort((r,j)=>r===j?0:r==="deepseek"?-1:j==="deepseek"?1:r.localeCompare(j)),c=D.toLowerCase().trim().split(/\s+/).filter(Boolean),L=R.filter(r=>!d||d===r).map(r=>({id:r,ids:Object.keys(y[r].models).filter(j=>c.every(U=>(r+" "+(N[r]??"")+" "+(j==="__default__"?h("defaultModelId"):j)).toLowerCase().includes(U))).sort((j,U)=>j===U?0:j==="__default__"?1:U==="__default__"?-1:j.localeCompare(U))})).filter(r=>r.ids.length),T=L.reduce((r,j)=>r+j.ids.length,0),F=r=>{_(r),E({}),w({})},B=()=>{const r=l.trim().toLowerCase();!o||!/^[a-z0-9_.-]+$/.test(r)||Object.hasOwn(O.models,r)||(P({...o,prices:{...O,models:{...O.models,[r]:{cacheHit:0,cacheMiss:0,output:0}}}}),b(""),A("deepseek"),_(r),w(j=>({...j,deepseek:!0})),s("deepseek:"+r))};return e("div",{className:"cm-reference-prices"},e("p",{className:"cm-note"},u?"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:D,"aria-label":u?"Search mounted prices":"搜索已挂载价格",placeholder:u?"Search models or providers…":"搜索模型或厂商…",onChange:r=>F(r.target.value),onKeyDown:r=>{r.key==="Escape"&&(F(""),r.stopPropagation())}}),e("select",{className:"cm-input",value:d,"aria-label":u?"Filter price provider":"筛选价格厂商",onChange:r=>{A(r.target.value),E({}),w({})}},e("option",{value:""},u?"All providers":"全部厂商"),...R.map(r=>e("option",{key:r,value:r},N[r]??r))),e("span",{className:"cm-note",role:"status"},u?`${T} models`:`${T} 个模型`)),...L.map(({id:r,ids:j})=>{const U=x[r]??(r==="deepseek"||c.length>0||d===r),K=r==="deepseek"?O.currency??"USD":"USD",$=k[r]??16;return e("section",{key:r,className:"cm-catalog-group"},e("button",{type:"button",className:"cm-catalog-vendor cm-vendor-toggle","aria-expanded":U,onClick:()=>w(i=>({...i,[r]:!U}))},e("span",null,e(he,{className:"cm-catalog-caret",open:U}),N[r]??r,e("small",null,j.length)),e("span",{className:"cm-catalog-unit"},K+(u?" / 1M tokens":" / 百万 Token"))),U?e("div",{className:"cm-catalog-list"},e("div",{className:"cm-catalog-columns","aria-hidden":!0},...[u?"Model":"模型",u?"Input":"输入",u?"Cached input":"缓存读取",u?"Output":"输出",""].map((i,v)=>e("span",{key:v},i))),...j.slice(0,$).map(i=>{const v=r+":"+i,t=y[r].models[i],m=f===v,I=i==="__default__"?h("defaultModelId"):i,M=t?.peak||t?.offPeak?u?"Peak / off-peak":"含峰谷价格":t?.longContext?u?"Long context":"含长上下文档位":t?.cny?u?"USD + CNY":"美元 / 人民币":null;return e("div",{key:v,className:"cm-catalog-entry"+(m?" editing":"")},e("button",{type:"button",className:"cm-catalog-model","aria-label":I+(u?" · Edit price":" · 编辑价格"),"aria-expanded":m,onClick:()=>s(m?null:v)},e("span",{className:"cm-catalog-model-name"},e("strong",null,I),M?e("small",null,M):null),e(ge,{entry:t,currency:K,priceEditor:z,locale:g}),e(he,{className:"cm-catalog-edit-caret",open:m})),m?e("div",{className:"cm-catalog-editor"},n(r,i,t)):null)}),j.length>$?e("button",{type:"button",className:"cm-catalog-more",onClick:()=>E(i=>({...i,[r]:$+16}))},u?`Show more · ${j.length-$} remaining`:`显示更多 · 还有 ${j.length-$} 个`):null):null)}),T===0?e("p",{className:"cm-pricing-empty"},u?"No matching models.":"没有找到匹配的模型。"):null,e("details",{className:"cm-pricing-rules"},e("summary",null,u?"Pricing notes":"计价说明"),e("p",{className:"cm-note"},h("priceTableNote"))),e("details",{className:"cm-catalog-manage"},e("summary",null,u?"Add or restore models":"添加与恢复模型"),e("div",{className:"cm-catalog-add"},e("input",{className:"cm-input",value:l,"aria-label":h("newModelPlaceholder"),placeholder:h("newModelPlaceholder"),onChange:r=>b(r.target.value),onKeyDown:r=>{r.key==="Enter"&&(r.preventDefault(),B())}}),e("button",{type:"button",className:"cm-btn small",disabled:!/^[a-z0-9_.-]+$/.test(l.trim().toLowerCase())||Object.hasOwn(O.models,l.trim().toLowerCase()),onClick:B},h("addModel"))),e(ue,{state:a,draft:o,setDraft:P,locale:g,rpc:p})))}function ke({state:a,locale:o,formatMoneyUsd:P,api:h,rpc:g,disabled:p}){const[n,N]=S(!1),[z,u]=S(!1),[D,_]=S(""),[d,A]=S([]),[x,w]=S(""),[k,E]=S(""),f=o==="en",s=(c,L)=>{const T=a.config.currency==="CNY"?"Cny":a.config.currency==="EUR"?"Eur":"",F=T&&c[L+T],B=Number(a.config.exchangeRate);return P(typeof F=="number"&&B>0?F/B:c[L],a.config)},l=f?"All models":"全部模型",b=G(()=>[...new Set([a.today,a.month,...a.history??[]].flatMap(c=>Object.keys(c?.byProviderModel??{})))].filter(c=>c.indexOf(":")>0).sort(),[a.today,a.month,a.history]),O=G(()=>[{value:"",label:l},...b.map(c=>({value:c,label:c}))],[b,l]),y=()=>g("getRepricingHistory").then(c=>{A(ae.parse(c)),w("")}).catch(c=>w(String(c.message??c)));re(()=>{let c=!0;return g("getRepricingHistory").then(L=>{c&&A(ae.parse(L))},L=>{c&&w(String(L.message??L))}),()=>{c=!1}},[g]);const R=async()=>{if(!(!n||z||p)){u(!0),w(""),_("");try{const c=k?await g("repriceModelHistory",!0,k):await g("repriceHistory",!0);if(!c.ok)throw new Error(c.message);_(c.message),N(!1),await y(),await h.reload()}catch(c){w(String(c.message??c))}finally{u(!1)}}};return e("section",{className:"cm-repricing"},e("h3",{className:"cm-h"},f?"Historical pricing":"历史费用"),e("p",{className:"cm-note"},f?"Rate changes apply to new calls. Recorded historical rates remain fixed.":"修改价格只影响后续调用,历史费用沿用原价格。"),e("div",{className:"cm-repricing-scope"},e("label",null,f?"Recalculation scope":"重算范围"),e(ne,{options:O,value:k,locale:o,label:f?"Choose channel and model":"选择渠道与模型",ariaLabel:f?"Choose channel and model":"选择渠道与模型",placeholder:f?"Search historical models":"搜索历史渠道或模型",onChange:c=>{z||(E(c),N(!1),_(""))}}),e("p",{className:"cm-hint"},k?f?"Only this channel/model changes. Other models and original exchange rates remain unchanged.":"仅重算此渠道下的这个模型,其他模型及原调用汇率保持不变。":f?"Choose a single channel/model to limit the recalculation.":"可选择单个渠道模型,缩小重算范围。")),n?e("div",{className:"cm-repricing-warning",role:"alert",onKeyDown:c=>{c.key==="Escape"&&!z&&(N(!1),c.stopPropagation())}},e("strong",null,(k||l)+(f?" · Historical amounts will change":" · 将修改历史费用")),e("p",null,f?"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:z,onClick:()=>N(!1)},f?"Cancel":"取消"),e("button",{type:"button",className:"cm-btn danger",disabled:z||p,onClick:R},z?f?"Recalculating…":"正在重算…":f?"Confirm recalculation":"确认重算"))):e("button",{type:"button",className:"cm-btn",disabled:p||z,onClick:()=>N(!0)},k?f?"Recalculate this model":"重算此模型的历史费用":f?"Recalculate history at current rates":"按当前价格重算历史"),D?e("p",{role:"status",className:"cm-note"},D):null,x?e("p",{role:"alert",className:"cm-err"},x):null,d.length?e("details",{className:"cm-repricing-history"},e("summary",null,f?"Recalculation records · original amounts retained":"重算记录 · 原金额已保留"),e("div",{className:"cm-stat-scroll"},e("table",{className:"cm-stat-table"},e("thead",null,e("tr",null,...(f?["Time","Scope","Before","After","Session/day records"]:["重算时间","范围","原金额","重算后","会话日期记录"]).map(c=>e("th",{key:c,scope:"col"},c)))),e("tbody",null,...d.map(c=>e("tr",{key:c.at},e("td",null,new Date(c.at).toLocaleString(o)),e("td",null,c.model||l),e("td",null,s(c,"before")),e("td",null,s(c,"after")),e("td",null,c.sessions))))))):null)}async function Me(a){const o=await a.get("remote").$mount(pe);a.effect(()=>()=>o(),"cost-meter: pricing settings contribution");const P=a.get("remote.costMeter"),h=async(p,...n)=>{(p==="repriceHistory"||p==="repriceModelHistory")&&se.parse(n[0]),p==="repriceModelHistory"&&me.parse(n[1]);const N=await P[p](...n);if(N?.ok!==!0)throw new Error(N?.error?.message??"Pricing request failed");return(p==="getPriceCatalog"?de:p==="getRepricingHistory"?ae:ce).parse(N.value)},g=document.createElement("style");return g.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}",g.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)}",g.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}",g.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(g),g.textContent+=`
|
|
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}
|
|
5
5
|
.cm-model-group{display:grid;gap:12px;min-width:0}.cm-pricing-group-title{margin:0;display:flex;align-items:center;gap:8px;font-weight:500;font-size:12px;color:var(--dsw-alias-label-secondary)}.cm-pricing-group-title>span{font-size:11px;color:var(--dsw-alias-label-tertiary)}
|
|
6
|
-
.cm-model-matching .cm-match-row{display:grid;gap:
|
|
7
|
-
.cm-model-
|
|
8
|
-
.cm-model-
|
|
6
|
+
.cm-model-list{border:1px solid var(--dsw-alias-border-l1);border-radius:10px;min-width:0}.cm-model-matching .cm-match-row{display:grid;gap:3px;padding:8px 12px;border:0;border-bottom:1px solid var(--dsw-alias-border-l1);border-radius:0;background:transparent;min-width:0}.cm-model-list .cm-match-row:last-child{border-bottom:0}.cm-model-list .cm-match-row[data-open=true]{background:var(--dsw-alias-bg-layer-1)}
|
|
7
|
+
.cm-model-statistics{font-size:11px;min-width:0;color:var(--dsw-alias-label-secondary)}.cm-model-statistics>summary{cursor:pointer;line-height:1.6;width:fit-content}.cm-model-statistics>summary>span{margin-left:8px}.cm-model-statistics-options{display:flex;flex-wrap:wrap;gap:8px 16px;padding:8px 0 3px}.cm-model-statistics-options .cm-check{display:flex;align-items:center;gap:6px;margin:0}.cm-model-statistics-options input{accent-color:var(--dsw-alias-state-business-primary)}
|
|
8
|
+
.cm-model-head,.cm-model-columns{display:grid;grid-template-columns:minmax(0,1fr) minmax(240px,1fr) 72px;align-items:center;gap:12px;min-width:0}.cm-model-columns{padding:8px 12px;border-bottom:1px solid var(--dsw-alias-border-l1);font-size:11px;color:var(--dsw-alias-label-tertiary)}.cm-model-columns>span:last-child{text-align:right;white-space:nowrap}.cm-model-identity{display:grid;gap:2px;min-width:0}.cm-model-identity strong{font-size:13px;font-weight:500;line-height:1.45;overflow-wrap:anywhere}.cm-model-meta{display:flex;align-items:center;flex-wrap:wrap;gap:4px 8px}.cm-model-provider{font-size:11px;color:var(--dsw-alias-label-tertiary)}
|
|
9
|
+
.cm-model-badge{font-size:10px;color:var(--dsw-alias-label-secondary);white-space:nowrap}.cm-model-badge.needs-price{color:var(--dsw-alias-state-business-primary)}.cm-model-head>.cm-btn{font-size:12px;padding:4px 8px;justify-self:end}
|
|
9
10
|
.cm-model-source{display:grid;gap:7px;min-width:0}.cm-model-source>span{font-size:12px;color:var(--dsw-alias-label-secondary)}.cm-model-source .cm-price-search{grid-template-columns:repeat(auto-fit,minmax(min(220px,100%),1fr));gap:8px}.cm-model-source .cm-price-search>small{grid-column:1/-1}.cm-model-source .cm-input{box-sizing:border-box;padding:8px 10px}
|
|
10
11
|
.cm-pricing-rules{padding:14px 0 0;border-top:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary);font-size:12px}.cm-pricing-rules summary{cursor:pointer}.cm-pricing-rules .cm-field{margin:12px 0;max-width:360px}.cm-pricing-rules .cm-note{line-height:1.65}
|
|
11
12
|
.cm-pricing-empty{margin:0;padding:32px 16px;text-align:center;color:var(--dsw-alias-label-tertiary);border:1px dashed var(--dsw-alias-border-l1);border-radius:12px;font-size:13px}
|
|
12
|
-
.cm-model-matching .cm-custom-price{margin:0;padding:14px;background:var(--dsw-alias-bg-base);gap:
|
|
13
|
+
.cm-model-matching .cm-custom-price{margin:0;padding:14px;background:var(--dsw-alias-bg-base);gap:12px;scroll-margin-block-start:12px}.cm-custom-head{flex-wrap:wrap}.cm-custom-head>span{flex:1;min-width:160px}.cm-custom-grid{grid-template-columns:repeat(auto-fit,minmax(min(150px,100%),1fr))}.cm-custom-price .cm-input{max-width:none;box-sizing:border-box;padding-top:8px;padding-bottom:8px}.cm-custom-price .cm-custom-amount input{padding-inline-start:28px}.cm-custom-price .cm-price-multiplier{align-items:center;gap:8px}.cm-custom-price .cm-price-multiplier label{display:inline-flex;align-items:center;gap:6px}.cm-custom-price .cm-price-multiplier input{width:auto;min-width:0}.cm-custom-price .cm-hint{font-size:11px;color:var(--dsw-alias-label-tertiary)}
|
|
13
14
|
.cm-custom-effective{display:grid;gap:12px;padding:12px;background:var(--dsw-alias-bg-layer-1);border-radius:8px;font-size:12px;font-variant-numeric:tabular-nums}.cm-effective-heading{display:flex;justify-content:space-between;gap:6px;flex-wrap:wrap}.cm-effective-heading>span{font-weight:500}.cm-effective-heading small,.cm-effective-grid span{color:var(--dsw-alias-label-tertiary);font-size:11px}.cm-effective-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}.cm-effective-grid>div{display:grid;gap:5px;min-width:0}.cm-effective-grid strong{font-size:14px;font-weight:600;overflow-wrap:anywhere}
|
|
14
15
|
.cm-pricing-page .cm-price-card{min-width:0;container:cm-price-editor / inline-size}.cm-pricing-page .cm-price-row{min-width:0}.cm-pricing-page .cm-price-row input{max-width:none;font-variant-numeric:tabular-nums}.cm-pricing-catalog .cm-catalog-vendor{margin-top:8px}
|
|
15
|
-
@media(max-width:480px){.cm-model-matching .cm-match-row{padding:
|
|
16
|
-
`,
|
|
17
|
-
.cm-model-current{
|
|
16
|
+
@media(max-width:480px){.cm-model-matching .cm-match-row{padding:8px 10px}.cm-model-matching .cm-custom-price{padding:10px}.cm-custom-more .cm-custom-grid{grid-template-columns:1fr}.cm-effective-grid{gap:8px}.cm-model-identity{flex-basis:100%}}
|
|
17
|
+
`,g.textContent+=`
|
|
18
|
+
.cm-model-current{min-width:0}
|
|
18
19
|
.cm-rate-summary{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;min-width:0;font-variant-numeric:tabular-nums}.cm-rate-item{display:grid;gap:4px;min-width:0}.cm-rate-item>span{font-size:11px;color:var(--dsw-alias-label-tertiary)}.cm-rate-item>strong{font-size:14px;font-weight:500;color:var(--dsw-alias-label-primary);overflow-wrap:anywhere}
|
|
19
|
-
.cm-model-
|
|
20
|
+
.cm-model-list .cm-rate-summary{grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}.cm-model-list .cm-rate-item{gap:0}.cm-model-list .cm-rate-item>span{position:absolute;width:1px;height:1px;clip-path:inset(50%);overflow:hidden}.cm-model-list .cm-rate-item>strong{font-size:13px}
|
|
21
|
+
@container cm-models (max-width:640px){.cm-model-columns{display:none}.cm-model-head{grid-template-columns:minmax(0,1fr) 72px;gap:7px 12px}.cm-model-head>.cm-btn{grid-column:2;grid-row:1}.cm-model-current{grid-column:1/-1;grid-row:2}.cm-model-list .cm-rate-item{gap:1px}.cm-model-list .cm-rate-item>span{position:static;width:auto;height:auto;clip-path:none;overflow:visible;font-size:10px}.cm-model-list .cm-rate-item>strong{font-size:12px}}
|
|
22
|
+
.cm-model-editor{display:grid;gap:10px;padding-top:10px;border-top:1px solid var(--dsw-alias-border-l1);min-width:0}.cm-source-choices{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px}.cm-source-choice{font:inherit;font-size:12px;padding:9px 4px;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-secondary);cursor:pointer}.cm-source-choice.active{color:var(--dsw-alias-state-business-primary);border-color:var(--dsw-alias-state-business-primary);font-weight:600}.cm-source-choice:focus-visible,.cm-model-edit:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:2px}.cm-source-explanation{font-size:12px;line-height:1.7;margin:0;color:var(--dsw-alias-label-secondary)}.cm-model-dismiss{justify-self:start;font:inherit;font-size:11px;border:0;padding:0;background:none;color:var(--dsw-alias-label-tertiary);cursor:pointer}.cm-model-dismiss:hover{color:var(--dsw-alias-state-danger-primary,#cf4e4e)}
|
|
20
23
|
.cm-reference-prices{display:grid;gap:16px;min-width:0}.cm-reference-prices>.cm-note{line-height:1.7}.cm-catalog-toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:10px}.cm-catalog-toolbar>.cm-input{min-width:0;box-sizing:border-box;padding:8px 10px}.cm-catalog-toolbar>input{flex:1 1 220px}.cm-catalog-toolbar>select{flex:0 1 180px;max-width:100%}.cm-catalog-toolbar>.cm-note{white-space:nowrap;margin-inline-start:auto}
|
|
21
24
|
.cm-catalog-group{border:1px solid var(--dsw-alias-border-l1);border-radius:12px;overflow:hidden;min-width:0;container:cm-price-list / inline-size}.cm-reference-prices .cm-catalog-vendor{width:100%;margin:0;border:0;border-radius:0;padding:13px 16px;font:inherit;font-size:13px;font-weight:600;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-1);box-sizing:border-box;text-align:start}.cm-catalog-vendor>span:first-child{display:flex;align-items:center;gap:9px;min-width:0}.cm-catalog-vendor small{font-size:11px;color:var(--dsw-alias-label-tertiary);font-weight:400}.cm-pricing-chevron{display:block;flex:none;color:var(--dsw-alias-label-tertiary);transition:transform .15s ease}.cm-pricing-chevron.is-open{transform:rotate(90deg)}@media(prefers-reduced-motion:reduce){.cm-pricing-chevron{transition:none}}.cm-catalog-unit{font-size:11px;font-weight:400;color:var(--dsw-alias-label-tertiary);white-space:nowrap}.cm-catalog-list{border-top:1px solid var(--dsw-alias-border-l1)}
|
|
22
25
|
.cm-catalog-columns,.cm-catalog-model{display:grid;grid-template-columns:minmax(0,1fr) repeat(3,minmax(74px,.35fr)) 14px;gap:14px;align-items:center;padding:12px 16px;box-sizing:border-box;min-width:0}.cm-catalog-columns{font-size:11px;color:var(--dsw-alias-label-tertiary);background:var(--dsw-alias-bg-base)}.cm-catalog-model{position:relative;width:100%;font:inherit;text-align:start;border:0;background:transparent;color:var(--dsw-alias-label-primary);cursor:pointer}.cm-catalog-entry{border-top:1px solid var(--dsw-alias-border-l1)}.cm-catalog-model:hover{background:var(--dsw-alias-bg-hover,var(--dsw-alias-bg-layer-1))}.cm-catalog-model:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:-2px}.cm-catalog-entry.editing{background:var(--dsw-alias-bg-layer-1)}.cm-catalog-model-name{display:grid;gap:4px;min-width:0}.cm-catalog-model-name>strong{font-size:13px;font-weight:500;line-height:1.6;overflow-wrap:anywhere}.cm-catalog-model-name>small{font-size:11px;color:var(--dsw-alias-label-tertiary)}.cm-catalog-model .cm-rate-summary{display:contents}.cm-catalog-model .cm-rate-item>span{display:none}.cm-catalog-model .cm-rate-item>strong{font-size:13px}.cm-catalog-editor{padding:0 14px 14px}.cm-catalog-more{font:inherit;font-size:12px;color:var(--dsw-alias-state-business-primary);cursor:pointer;width:100%;padding:12px;border:0;border-top:1px solid var(--dsw-alias-border-l1);background:none}
|
|
@@ -24,4 +27,4 @@ window.__ModuleLoader__.load({id:"dsh-cost-meter",chunk:"client.pricing.js",fact
|
|
|
24
27
|
@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}}
|
|
25
28
|
@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}}
|
|
26
29
|
@media(max-width:480px){.cm-source-choices{grid-template-columns:repeat(2,minmax(0,1fr))}.cm-catalog-toolbar>select{flex:1 1 140px}}
|
|
27
|
-
`,
|
|
30
|
+
`,g.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(""),a.effect(()=>()=>g.remove(),"cost-meter: pricing settings styles"),p=>p.mode==="matching"?e(Ne,p):e(p.mode==="catalog"?Ce:p.mode==="restore"?ue:ke,{...p,rpc:h})}return{mount:Me,CONTRIBUTION:pe}}});
|