dsh-all-usage 1.2.0 → 1.2.1

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/lib/client.js CHANGED
@@ -1 +1 @@
1
- window.__ModuleLoader__.load({id:"dsh-all-usage",factory:e=>{var t={},a=t;Object.defineProperty(a,Symbol.toStringTag,{value:"Module"});const n=e("react"),r="1.2.0";function i(e){return String(e).padStart(2,"0")}let l="none";function o(){l="none";try{const e="undefined"==typeof localStorage?null:localStorage.getItem("dsh-all-usage:topInset");if(null!==e&&""!==e){const t=Number(e);if(Number.isFinite(t)&&t>=0)return l="stored",Math.round(t)}}catch(e){}try{const e="undefined"==typeof document?null:document.documentElement;if(null!==e&&e.hasAttribute("data-windows-titlebar")){const t=Number.parseFloat(window.getComputedStyle(e).getPropertyValue("--dsh-windows-titlebar-height"));return l="titlebar-marker",Number.isFinite(t)&&t>0?Math.round(t):40}}catch(e){}try{const e="undefined"==typeof navigator?void 0:navigator.windowControlsOverlay;if(null!=e&&!0===e.visible){const t=e.getTitlebarAreaRect();if(null!=t&&Number.isFinite(t.height)&&t.height>0)return l="overlay",Math.round(t.height)}}catch(e){}const e="undefined"==typeof navigator?"":String(navigator.userAgent||"");return/Electron/i.test(e)?(l="electron-ua",40):/QtWebEngine/i.test(e)?(l="qtwebengine-ua",40):0}function s(){try{const e="undefined"==typeof navigator?void 0:navigator.windowControlsOverlay;let t="none";null!=e&&(t=!0===e.visible?String((e.getTitlebarAreaRect()||{}).height):"hidden");const a="undefined"==typeof navigator?"":String(navigator.userAgent||"").slice(0,180),n=e=>{try{const t=document.querySelector(e);if(null===t)return"none";const a=t.getBoundingClientRect();return[a.top,a.left,a.width,a.height].map(e=>Math.round(e)).join("/")}catch(e){return"none"}},r="undefined"==typeof document?null:document.documentElement,i=null!==r&&r.hasAttribute("data-windows-titlebar")?String(window.getComputedStyle(r).getPropertyValue("--dsh-windows-titlebar-height")).trim()||"set":"none",s="undefined"==typeof window?"":Math.round(window.innerWidth)+"x"+Math.round(window.innerHeight),c="ua="+encodeURIComponent(a)+"&wco="+encodeURIComponent(t)+"&inset="+String(o())+"&src="+encodeURIComponent(l)+"&tb="+encodeURIComponent(i)+"&vp="+encodeURIComponent(s)+"&modal="+encodeURIComponent(n(".uh-side-modal"))+"&dlg="+encodeURIComponent(n(".uh-side-dialog"))+"&head="+encodeURIComponent(n(".uh-side-dialog-head"))+"&close="+encodeURIComponent(n(".uh-close-button"));fetch("/api/all-usage/client-env?"+c,{headers:{accept:"application/json"}}).catch(()=>{})}catch(e){}}function c(e,t){const a=t?e.getUTCFullYear():e.getFullYear(),n=t?e.getUTCMonth():e.getMonth(),r=t?e.getUTCDate():e.getDate();return a+"-"+i(n+1)+"-"+i(r)}function u(e,t,a){return a?new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t)):new Date(e.getFullYear(),e.getMonth(),e.getDate()+t)}function d(e,t){if("string"!=typeof e||!/^\d{4}-\d{2}-\d{2}$/.test(e))return!1;const a=Number(e.slice(0,4)),n=Number(e.slice(5,7)),r=Number(e.slice(8,10)),i=t?new Date(Date.UTC(a,n-1,r)):new Date(a,n-1,r);return Number.isFinite(i.getTime())&&c(i,t)===e}function p(e,t){if(null===e||"object"!=typeof e)return null;const a=e.start,n=e.end;return!d(a,t)||!d(n,t)||a>n?null:{start:a,end:n}}function m(e,t){let a=t;if(Array.isArray(e))for(const n of e)n&&d(n.date,!0)&&n.date<=t&&n.date<a&&(a=n.date);return{min:a,max:t}}function h(){let e=0;return{next:()=>(e+=1,e),isCurrent:t=>t===e}}function g(e){if(null===e||"object"!=typeof e)return null;const t="string"==typeof e.instanceId?e.instanceId:"",a="number"==typeof e.revision&&Number.isFinite(e.revision)?e.revision:null;return""===t||null===a?null:t+":"+a}function b(e,t,a){const n=e&&"object"==typeof e?e[t]:void 0;return"number"==typeof n&&Number.isFinite(n)?n:a}function f(e){return null!==e&&"object"==typeof e&&["dataRevision","metadataRevision","scanRevision","pricingRevision"].every(t=>null!==b(e,t,null))}function y(e){if(null===e||"object"!=typeof e||"string"!=typeof e.instanceId||""===e.instanceId)return null;if("string"==typeof e.queryRevision&&""!==e.queryRevision)return e.instanceId+":"+e.queryRevision;const t=b(e,"dataRevision",b(e,"revision",null)),a=b(e,"pricingRevision",0);return null===t?null:e.instanceId+":"+t+":"+a}function x(e){return String(Math.round(10*e)/10)}function v(e){return"number"==typeof e&&Number.isFinite(e)?e<1e3?String(e):e<1e6?x(e/1e3)+"k":e<1e9?x(e/1e6)+"M":x(e/1e9)+"B":"0"}function w(e,t){return"number"==typeof e&&Number.isFinite(e)?Math.round(e).toLocaleString("en"===t?"en-US":"zh-CN"):"0"}function k(e,t){const a=e+t;return a<=0?0:t/a*100}s();const E={edit:{path:"M12.2 3.4l2.4 2.4M4 16l2.8-.6L15 7.2a1.7 1.7 0 0 0-2.4-2.4L4.4 13z"},export:{path:"M12 3v11M8 7l4-4 4 4M5 13v5h14v-5"},refresh:{path:"M19 9a7 7 0 1 0 1.1 5.2M19 4v5h-5"},close:{path:"M6 6l12 12M18 6L6 18"},chart:{path:"M4 19V5M4 19h16M7 15l3-4 3 2 5-7"},list:{path:"M6 6h12M6 12h12M6 18h12",circle:{cx:3.5,cy:6,r:1.2}},cache:{path:"M12 4l7 4-7 4-7-4 7-4zM5 12l7 4 7-4M5 16l7 4 7-4"},wallet:{path:"M4 7.5A2.5 2.5 0 0 1 6.5 5H18v14H6.5A2.5 2.5 0 0 1 4 16.5zM4 8h14M14 13h.01"},clock:{path:"M12 6v6l4 2M20 12a8 8 0 1 1-16 0 8 8 0 0 1 16 0z"},folder:{path:"M3.5 7.5h6l2 2h9v8.5a2 2 0 0 1-2 2h-13a2 2 0 0 1-2-2z"},language:{path:"M4 12h16M12 4c2.1 2.2 3.2 4.9 3.2 8S14.1 17.8 12 20M12 4C9.9 6.2 8.8 8.9 8.8 12s1.1 5.8 3.2 8",circle:{cx:12,cy:12,r:8}},chevron:{path:"M7 10l5 5 5-5"},check:{path:"M5 12.5l4.2 4.1L19 7.3"},plus:{path:"M12 5v14M5 12h14"},calendar:{path:"M6 4v3M18 4v3M4 9h16M5 6h14a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1z"}};function N(e){const t=e.size||16,a={fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"},r=void 0===e.name?"chart":e.name,i=void 0===E[r]?E.chart:E[r],l=[];return void 0!==i.path&&l.push(n.createElement("path",{key:"p",d:i.path,...a})),void 0!==i.circle&&l.push(n.createElement("circle",{key:"c",cx:i.circle.cx,cy:i.circle.cy,r:i.circle.r,...a})),n.createElement("svg",{className:"uh-line-icon "+(e.className||""),width:t,height:t,viewBox:"0 0 24 24","aria-hidden":!0},l)}const C=[{key:"deepseek",label:"DeepSeek",providers:["deepseek","deepseek-official"],prefixes:["deepseek-","deepseek"],exact:[],href:"/api/all-usage/icon?key=deepseek&v=1.2.0"},{key:"openai",label:"OpenAI",providers:["openai","azure-openai"],prefixes:["gpt-","o1-","o3-","o4-","o5-","codex-","gpt"],exact:["o1","o3","o4","o5"],href:"/api/all-usage/icon?key=openai&v=1.2.0"},{key:"claude",label:"Anthropic Claude",providers:["anthropic"],prefixes:["claude-","claude"],exact:[],href:"/api/all-usage/icon?key=claude&v=1.2.0"},{key:"gemini",label:"Google Gemini",providers:["google","google-vertex","vertex"],prefixes:["gemini-","gemma-","gemma","gemini"],exact:[],href:"/api/all-usage/icon?key=gemini&v=1.2.0"},{key:"meta",label:"Meta Llama",providers:["meta","meta-llama"],prefixes:["llama-","meta-llama","llama"],exact:[],href:"/api/all-usage/icon?key=meta&v=1.2.0"},{key:"zhipu",label:"Zhipu GLM",providers:["zhipu","zhipuai","zai","bigmodel"],prefixes:["glm-","chatglm-","glm","chatglm"],exact:[],href:"/api/all-usage/icon?key=zhipu&v=1.2.0"},{key:"grok",label:"xAI Grok",providers:["xai"],prefixes:["grok-","grok"],exact:["grok"],href:"/api/all-usage/icon?key=grok&v=1.2.0"},{key:"qwen",label:"Qwen",providers:["qwen","alibaba","dashscope","bailian"],prefixes:["qwen","qwq-","qvq-"],exact:[],href:"/api/all-usage/icon?key=qwen&v=1.2.0"},{key:"doubao",label:"Doubao",providers:["doubao","bytedance","volcengine","ark"],prefixes:["doubao-","doubao"],exact:[],href:"/api/all-usage/icon?key=doubao&v=1.2.0"},{key:"kimi",label:"Moonshot Kimi",providers:["moonshot","moonshotai"],prefixes:["kimi-","moonshot-","kimi","moonshot"],exact:["kimi"],href:"/api/all-usage/icon?key=kimi&v=1.2.0"},{key:"minimax",label:"MiniMax",providers:["minimax"],prefixes:["minimax-","abab","minimax"],exact:[],href:"/api/all-usage/icon?key=minimax&v=1.2.0"},{key:"mistral",label:"Mistral",providers:["mistral","mistralai"],prefixes:["mistral-","mistralai-","magistral-","codestral-","devstral-","ministral-","pixtral-","mixtral-","open-mistral-","open-mixtral-"],exact:[],href:"/api/all-usage/icon?key=mistral&v=1.2.0"},{key:"nemotron",label:"NVIDIA",providers:["nvidia","nvidia-nim"],prefixes:["nemotron"],exact:[],href:"/api/all-usage/icon?key=nemotron&v=1.2.0"},{key:"cohere",label:"Cohere",providers:["cohere"],prefixes:["command-","north-","c4ai-"],exact:[],href:"/api/all-usage/icon?key=cohere&v=1.2.0"},{key:"nova",label:"Amazon Nova",providers:["amazon","amazon-bedrock","bedrock","aws-bedrock"],prefixes:["nova-","amazon.nova-"],exact:[],href:"/api/all-usage/icon?key=nova&v=1.2.0"},{key:"phi",label:"Microsoft",providers:["microsoft","azure","azure-ai","azure-cognitive-services"],prefixes:["phi-","microsoft/"],exact:[],href:"/api/all-usage/icon?key=phi&v=1.2.0"},{key:"sonar",label:"Perplexity",providers:["perplexity","perplexity-ai"],prefixes:["sonar"],exact:[],href:"/api/all-usage/icon?key=sonar&v=1.2.0"},{key:"ernie",label:"Baidu ERNIE",providers:["baidu","qianfan","baiducloud"],prefixes:["ernie-","wenxin"],exact:[],href:"/api/all-usage/icon?key=ernie&v=1.2.0"},{key:"hunyuan",label:"Tencent Hunyuan",providers:["hunyuan"],prefixes:["hunyuan-","hy3","hy4"],exact:[],href:"/api/all-usage/icon?key=hunyuan&v=1.2.0"},{key:"tencent",label:"Tencent",providers:["tencent","tencentcloud","tencent-hunyuan"],prefixes:[],exact:[],href:"/api/all-usage/icon?key=tencent&v=1.2.0"},{key:"stepfun",label:"StepFun",providers:["stepfun","step"],prefixes:["step-","stepfun-"],exact:[],href:"/api/all-usage/icon?key=stepfun&v=1.2.0"},{key:"baichuan",label:"Baichuan",providers:["baichuan"],prefixes:["baichuan"],exact:[],href:"/api/all-usage/icon?key=baichuan&v=1.2.0"},{key:"sensenova",label:"SenseNova",providers:["sensenova","sensetime"],prefixes:["sensenova","sensechat"],exact:[],href:"/api/all-usage/icon?key=sensenova&v=1.2.0"},{key:"internlm",label:"InternLM",providers:["internlm","shanghai-ai-lab"],prefixes:["internlm","intern-lm"],exact:[],href:"/api/all-usage/icon?key=internlm&v=1.2.0"},{key:"longcat",label:"LongCat",providers:["longcat","meituan"],prefixes:["longcat"],exact:[],href:"/api/all-usage/icon?key=longcat&v=1.2.0"},{key:"jamba",label:"AI21",providers:["ai21","ai21-labs"],prefixes:["jamba"],exact:[],href:"/api/all-usage/icon?key=jamba&v=1.2.0"},{key:"granite",label:"IBM Granite",providers:["ibm","ibm-granite","watsonx"],prefixes:["granite-"],exact:[],href:"/api/all-usage/icon?key=granite&v=1.2.0"},{key:"solar",label:"Upstage",providers:["upstage"],prefixes:["solar-"],exact:[],href:"/api/all-usage/icon?key=solar&v=1.2.0"},{key:"lfm",label:"Liquid AI",providers:["liquid","liquid-ai"],prefixes:["lfm-"],exact:[],href:"/api/all-usage/icon?key=lfm&v=1.2.0"},{key:"olmo",label:"Ai2",providers:["ai2","allenai"],prefixes:["olmo","molmo"],exact:[],href:"/api/all-usage/icon?key=olmo&v=1.2.0"},{key:"bge",label:"BAAI",providers:["baai","bge"],prefixes:["bge-"],exact:[],href:"/api/all-usage/icon?key=bge&v=1.2.0"},{key:"voyage",label:"Voyage AI",providers:["voyage","voyageai"],prefixes:["voyage-"],exact:[],href:"/api/all-usage/icon?key=voyage&v=1.2.0"},{key:"bytedance",label:"ByteDance Seed",providers:["bytedance","seed","volcengine","ark"],prefixes:["seed-","seed1-","seed2-"],exact:[],href:"/api/all-usage/icon?key=bytedance&v=1.2.0"},{key:"kling",label:"Kling",providers:["kling","kuaishou"],prefixes:["kling"],exact:[],href:"/api/all-usage/icon?key=kling&v=1.2.0"},{key:"skywork",label:"Skywork",providers:["skywork"],prefixes:["skywork"],exact:[],href:"/api/all-usage/icon?key=skywork&v=1.2.0"},{key:"mimo",label:"Xiaomi MiMo",providers:["xiaomimimo","xiaomi","mimo"],prefixes:["mimo-"],exact:[],href:"/api/all-usage/icon?key=mimo&v=1.2.0"},{key:"aion",label:"Aion Labs",providers:["aion-labs","aionlabs"],prefixes:["aion-"],exact:[],href:"/api/all-usage/icon?key=aion&v=1.2.0"},{key:"nous",label:"Nous Research",providers:["nousresearch","nous","nous-research"],prefixes:["nous-","hermes-3","hermes-4"],exact:[],href:"/api/all-usage/icon?key=nous&v=1.2.0"},{key:"falcon",label:"TII Falcon",providers:["tii","falcon","tii-uae"],prefixes:["falcon-"],exact:[],href:"/api/all-usage/icon?key=falcon&v=1.2.0"},{key:"aleph",label:"Aleph Alpha",providers:["aleph-alpha","alephalpha"],prefixes:["aleph-","pharia-"],exact:[],href:"/api/all-usage/icon?key=aleph&v=1.2.0"},{key:"yandex",label:"Yandex",providers:["yandex","yandex-cloud"],prefixes:["yandex-","yandexgpt"],exact:[],href:"/api/all-usage/icon?key=yandex&v=1.2.0"},{key:"arctic",label:"Snowflake",providers:["snowflake"],prefixes:["snowflake-","arctic-"],exact:[],href:"/api/all-usage/icon?key=arctic&v=1.2.0"},{key:"iflytek",label:"iFlytek Spark",providers:["iflytek","iflytekcloud","spark"],prefixes:["spark-","generalv"],exact:[],href:"/api/all-usage/icon?key=iflytek&v=1.2.0"}],M=Array.isArray(C)?C:[],S=new Map(M.map(e=>[e.key,e])),A=new Map;function z(e){const t=String(e??"").trim(),a=t.lastIndexOf("/");if(a<=0||a>=t.length-1)return t;const n=t.slice(0,a);if(!/^[a-z0-9][a-z0-9._-]*$/i.test(n))return t;const r=t.slice(a+1).trim();return""===r?t:r}function T(e){const t="string"==typeof e?e.trim().toLowerCase():"";if(""===t)return null;for(const e of M)if(e.providers.includes(t))return e;return null}function I(e,t){if(""===t||!e.startsWith(t))return!1;if(e.length===t.length)return!0;if(/[-_.:\/]$/.test(t))return!0;const a=e.charAt(t.length);return"-"===a||"_"===a||"."===a||":"===a||"/"===a||/[a-z]$/.test(t)&&/[0-9]/.test(a)}const R=["openai","google","anthropic","databricks","azure","azure-ai","microsoft","amazon","cohere","mistral","deepseek","qwen","moonshot","zhipu","bytedance","nvidia","ibm","ai21","upstage","voyage","baai","ai2","liquid","sensenova","internlm","longcat","stepfun","baichuan","tencent","kling","skywork","duo-chat","bedrock","vertex"];function j(e){for(const t of M)if(t.exact.includes(e))return t;let t=null,a=0;for(const n of M)for(const r of n.prefixes)I(e,r)&&r.length>a&&(t=n,a=r.length);return t}function D(e){const t=function(e){if("string"!=typeof e)return"";let t=e.trim().toLowerCase();const a=t.lastIndexOf("/");return a>=0&&(t=t.slice(a+1)),t.split(":")[0].replace(/@/g,"-").trim()}(e);if(""===t)return null;for(const e of function(e){const t=[e];let a=e.indexOf(".");for(;a>0&&a<e.length-3;){const n=e.slice(a+1);n.length>=3&&t.push(n),a=e.indexOf(".",a+1)}for(const a of R){if(!e.startsWith(a+"-"))continue;const n=e.slice(a.length+1).replace(/^[-_.]+/,"");n.length>=3&&t.push(n)}return t}(t)){const t=j(e);if(null!==t)return t}return null}function F(e){if(0===M.length||null===e||"object"!=typeof e)return null;const t="string"==typeof e.actualModel?e.actualModel:"",a="string"==typeof e.requestedModel?e.requestedModel:"",n="string"==typeof e.model?e.model:"",r="string"==typeof e.provider?e.provider:"",i=t+"\0"+a+"\0"+n+"\0"+r;if(A.has(i))return A.get(i);const l=n.includes(" / ")?n.slice(n.indexOf(" / ")+3):n;let o=D(""!==t?t:a);if(null===o&&""===t&&""===a){const e=T(r),t=D(l);o=null===e||null!==t&&t!==e?t:e}return A.size>=2e3&&A.clear(),A.set(i,o),o}function U(e){if(!Array.isArray(e)||0===e.length)return null;let t=null;for(const a of e){const e=F(a);if(null===e)return null;if(null===t)t=e;else if(t!==e)return null}return t}function W(e,t){if("en"===t||"number"!=typeof e||!Number.isFinite(e)||e<1e4)return"";const a=e>=1e8?e/1e8:e/1e4,n=Math.round(1e3*a)/1e3;return String(n)+(e>=1e8?"亿":"万")}function O(e,t,a){const r=W(t,a);return n.createElement(n.Fragment,null,e,r?n.createElement("span",{className:"uh-unit"},r):null)}function L(e,t,a,n){if(null==t)return"—";const r="CNY"===e?"¥":"USD"===e?"$":e+" ",i=Number.isFinite(n)?n:4;return r+t.toLocaleString("en"===a?"en-US":"zh-CN",{minimumFractionDigits:i,maximumFractionDigits:i})}function P(e){const t=("number"==typeof e?String(e):"string"==typeof e?e.trim().toLowerCase():"").match(/^(\d+)(?:\.(\d+))?(?:e([+-]?\d+))?$/);if(!t)return{digits:0n,scale:0};let a=(t[1]||"")+(t[2]||""),n=(t[2]||"").length-(t[3]?Number(t[3]):0);for(n<0&&(a+="0".repeat(-n),n=0),n>a.length&&(a="0".repeat(n-a.length+1)+a);n>0&&a.length>1&&a.endsWith("0");)a=a.slice(0,-1),n-=1;return{digits:BigInt(a.replace(/^0+(?=\d)/,"")||"0"),scale:n}}function K(e){const t=P(e);if(0n===t.digits)return"0";const a=t.digits.toString();if(0===t.scale)return a;const n=a.padStart(t.scale+1,"0"),r=n.length-t.scale;return n.slice(0,r)+"."+n.slice(r)}function q(e,t){const a=P(e),n=P(t),r=Math.max(a.scale,n.scale);return K((a.digits*10n**BigInt(r-a.scale)+n.digits*10n**BigInt(r-n.scale)).toString()+(r>0?"e-"+r:""))}function B(){return{currency:"USD",input:"0",output:"0",cacheRead:"0",cacheWrite:"0",baseTotal:"0",total:"0",pricedCalls:0,unpricedCalls:0,ambiguousCalls:0,unsupportedCalls:0}}function H(e){const t=e&&e.cost&&"object"==typeof e.cost?e.cost:e&&"object"==typeof e?e:{},a={currency:"USD",input:"0",output:"0",cacheRead:"0",cacheWrite:"0",baseTotal:"0",total:"0",pricedCalls:0,unpricedCalls:0,ambiguousCalls:0,unsupportedCalls:0};if(a.currency="string"==typeof t.currency&&""!==t.currency?t.currency:"USD",t.breakdown&&"object"==typeof t.breakdown)return"priced"===t.status?(a.input=K(t.breakdown.input),a.output=K(t.breakdown.output),a.cacheRead=K(t.breakdown.cacheRead),a.cacheWrite=K(t.breakdown.cacheWrite),a.baseTotal=K(t.baseTotal),a.total=K(t.total),a.pricedCalls=1):"ambiguous"===t.status?a.ambiguousCalls=1:"unsupported"===t.status?a.unsupportedCalls=1:a.unpricedCalls=1,a;for(const e of["input","output","cacheRead","cacheWrite","baseTotal","total"])a[e]=K(t[e]);for(const e of["pricedCalls","unpricedCalls","ambiguousCalls","unsupportedCalls"])a[e]=Number.isFinite(t[e])?t[e]:0;return a}function Y(e,t){const a=H(t);for(const t of["input","output","cacheRead","cacheWrite","baseTotal","total"])e[t]=q(e[t],a[t]);return e.pricedCalls+=a.pricedCalls,e.unpricedCalls+=a.unpricedCalls,e.ambiguousCalls+=a.ambiguousCalls,e.unsupportedCalls+=a.unsupportedCalls,e}function V(e,t){const a=H(e);if(a.pricedCalls<=0)return"—";const n=Number(a.total);return Number.isFinite(n)?L(a.currency,n,t):a.currency+" "+a.total}function J(e,t){const a=e&&e.cost&&"object"==typeof e.cost?e.cost:{},n=[];return a.pricingPolicyId&&n.push(a.pricingPolicyId),"UTC"===a.pricingTimezone&&Number.isFinite(a.pricingAt)&&n.push(("en"===t?"at ":"计费时刻 ")+new Date(a.pricingAt).toISOString().slice(0,16).replace("T"," ")+" UTC"),n.length>0?n.join(" · "):null}function G(e){const t=e&&e.config&&"object"==typeof e.config?e.config:{},a=t.sync&&"object"==typeof t.sync?t.sync:{};return{sync:{autoEnabled:!0===a.autoEnabled,intervalMs:Number.isFinite(a.intervalMs)?a.intervalMs:216e5},providerAliases:t.providerAliases&&"object"==typeof t.providerAliases?Object.assign({},t.providerAliases):{},mappings:Array.isArray(t.mappings)?t.mappings.map(e=>Object.assign({},e)):[],overrides:Array.isArray(t.overrides)?t.overrides.map(e=>Object.assign({},e,{tiers:Array.isArray(e.tiers)?e.tiers.map(e=>Object.assign({},e)):[]})):[]}}function $(e){const t=new Map,a=e&&Array.isArray(e.tierSchedules)?e.tierSchedules:[];for(const e of a)e&&"string"==typeof e.id&&Array.isArray(e.tiers)&&t.set(e.id,e.tiers);return e&&Array.isArray(e.usedModels)?e.usedModels.map(e=>{const a=e&&"string"==typeof e.tierScheduleId?t.get(e.tierScheduleId):null,n=Array.isArray(a)?a:e&&Array.isArray(e.tiers)?e.tiers:[];return Object.assign({},e,{tiers:n.map(e=>Object.assign({},e))})}):[]}function _(e,t){const a=G(t);if(null===e||"object"!=typeof e)return a;const n=G({config:e});return Object.assign({},a,{providerAliases:n.providerAliases,mappings:n.mappings,overrides:n.overrides})}function X(e,t){const a={priced:["已计价","priced"],unpriced:["未计价","unpriced"],ambiguous:["待确认","ambiguous"],unsupported:["不支持","unsupported"]},n=a[e]||a.unpriced;return"en"===t?n[1]:n[0]}function Z(e,t){const a={fresh:["Fresh:输入 + 缓存读写","Fresh: input + cache read/write"],total:["Total:输入已含缓存","Total: input already includes cache"],legacy:["Legacy:输入 + 缓存写","Legacy: input + cache write"]},n=a[e]||a.fresh;return"en"===t?n[1]:n[0]}function Q(e,t,a){const n=Array.isArray(e)?e:[];if(t<0)return n.length>0?"≤ "+w(n[0].size,a):"en"===a?"All contexts":"全部上下文";const r=n[t];if(!r)return"";const i="> "+w(r.size,a),l=n[t+1];return l?i+("en"===a?" and ≤ ":" 且 ≤ ")+w(l.size,a):i}function ee(e){const t=String(e??"").trim().toLowerCase();if(""===t||t.length>128)return!1;const a=t.match(/^(\d+)(?:\.(\d+))?(?:e([+-]?\d+))?$/);if(!a)return!1;const n=a[3]?Number(a[3]):0;if(!Number.isSafeInteger(n)||Math.abs(n)>24)return!1;let r=(a[1]||"")+(a[2]||""),i=(a[2]||"").length-n;return r=r.replace(/^0+(?=\d)/,""),i<0&&(r+="0".repeat(-i),i=0),i>r.length&&(r="0".repeat(i-r.length+1)+r),r.length<=40}function te(e,t){const a=Number(e&&e.size);return!(!e||"context"!==e.type||!Number.isSafeInteger(a)||a<=t||a>1e9)&&["input","output","cacheRead","cacheWrite"].every(t=>ee(e[t]))}function ae(e){return null==e||""===e?"0":String(e)}function ne(e,t){const a={input:["输入 / 1M","Input / 1M"],output:["输出 / 1M","Output / 1M"],cacheRead:["缓存读 / 1M","Cache read / 1M"],cacheWrite:["缓存写 / 1M","Cache write / 1M"]},n=a[e]||a.input;return"en"===t?n[1]:n[0]}function re(e){const t=null!==e&&"object"==typeof e?e:{};return String(t.providerId||"").trim().toLowerCase()+"|"+String(t.modelId||"").trim().toLowerCase()}function ie(e,t){const a=Array.isArray(e)?e:[],n=re(t);for(let e=0;e<a.length;e+=1){const t=a[e];if(null!==t&&"object"==typeof t&&re({providerId:t.providerId,modelId:t.modelId})===n)return e}return-1}function le(e,t){const a=Array.isArray(e)?e:[],n=String(t||"").trim();if(""===n)return-1;for(let e=0;e<a.length;e+=1){const t=a[e];if(null!==t&&"object"==typeof t&&String(t.identityKey||t.usageIdentityKey||"").trim()===n)return e}return-1}const oe=new WeakMap;function se(e,t,a){const n=null!==e&&"object"==typeof e?e:{sync:{},mappings:[],overrides:[]},r=Array.isArray(n.overrides)?n.overrides.map(e=>Object.assign({},e)):[];let i=ie(r,t.basis);if(i<0){const e=null!==t.rates&&"object"==typeof t.rates?t.rates:{},a=Array.isArray(t.tiers)?t.tiers.map(e=>Object.assign({},e)):[];r.push({providerId:t.basis.providerId||"",modelId:t.basis.modelId,displayName:t.model||t.basis.modelId,input:ae(e.input),output:ae(e.output),cacheRead:ae(e.cacheRead),cacheWrite:ae(e.cacheWrite),tiered:a.length>0,tiers:a}),i=r.length-1}return r[i]=Object.assign({},r[i],a),Object.assign({},n,{overrides:r})}function ce(e){const t=String(e??"").trim().match(/^([0-9]{1,2}):([0-9]{1,2})$/);if(null===t)return null;const a=Number(t[1]),n=Number(t[2]);if(!Number.isInteger(a)||!Number.isInteger(n)||n<0||n>59)return null;const r=60*a+n;return r<0||r>1440?null:r}function ue(e){const t=Number(e);return!Number.isFinite(t)||t<0||t>1440?"":String(Math.floor(t/60)).padStart(2,"0")+":"+String(t%60).padStart(2,"0")}function de(e){return"en"===e?0:480}function pe(e,t){const a=Number.isFinite(t)?Math.trunc(t):0;if(0===a||!Array.isArray(e))return e;const n=[];for(const t of e){const e=new Map;for(const n of t.windows){const r=n.endMinute+a;let i=n.startMinute+a;for(;i<r;){const a=Math.floor(i/1440),n=i-1440*a,l=Math.min(r-1440*a,1440),o=t.weekdays.map(e=>((e+a)%7+7)%7).sort((e,t)=>e-t),s=o.join(",");let c=e.get(s);void 0===c&&(c={weekdays:o,windows:[]},e.set(s,c)),c.windows.push({startMinute:n,endMinute:l}),i+=l-n}}let r=0;for(const a of e.values())a.windows.sort((e,t)=>e.startMinute-t.startMinute),n.push({id:1===e.size?t.id:t.id+"-"+(r+1),weekdays:a.weekdays,windows:a.windows,rates:t.rates}),r+=1}return n}function me(e,t=0){const a=String(e??"").trim();if(""===a)return 0;const n=a.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/);if(null===n)return null;const r=Number(n[1]),i=Number(n[2]),l=Number(n[3]),o=Date.UTC(r,i-1,l),s=new Date(o);return s.getUTCFullYear()!==r||s.getUTCMonth()!==i-1||s.getUTCDate()!==l?null:o-6e4*(Number.isFinite(t)?Math.trunc(t):0)}function he(e,t=0){const a=Number(e);if(!Number.isFinite(a)||a<=0)return"";const n=Number.isFinite(t)?Math.trunc(t):0;return new Date(a+6e4*n).toISOString().slice(0,10)}function ge(e){const t=String(e??""),a=[],n=new Set;for(const e of t.split("\n")){const t=e.trim();if(""===t)continue;const r=t.split("..");if(r.length>2)return null;const i=r[0].trim(),l=2===r.length?r[1].trim():i;if(""===i||""===l)return null;const o=me(i),s=me(l);if(null===o||null===s||o>s)return null;const c=Math.round((s-o)/864e5)+1;if(c>366||n.size+c>400)return null;for(let e=0;e<c;e+=1){const t=new Date(o+864e5*e).toISOString().slice(0,10);n.has(t)||(n.add(t),a.push(t))}}return a.sort(),a}function be(e,t=0){const a=null!=e&&Array.isArray(e.policies)?e.policies:[],n=a.length>0&&null!==a[0]&&"object"==typeof a[0]?a[0]:null;if(null===n)return null;const r=pe(Array.isArray(n.rules)?n.rules:[],t);return 0===r.length?null:{policyId:"string"==typeof n.policyId&&""!==n.policyId?n.policyId:"custom-peak",effectiveFromText:he(n.effectiveFrom,t),holidaysEnabled:Array.isArray(n.holidays)&&n.holidays.length>0,holidaysText:Array.isArray(n.holidays)?n.holidays.join("\n"):"",holidaysSourceText:"string"==typeof n.holidaysSource?n.holidaysSource:"",rules:r.map((e,t)=>({id:"string"==typeof e.id&&""!==e.id?e.id:"peak-"+(t+1),weekdays:Array.isArray(e.weekdays)?e.weekdays.slice().sort((e,t)=>e-t):[],windows:(Array.isArray(e.windows)?e.windows:[]).map(e=>({start:ue(e.startMinute),end:ue(e.endMinute)})),rates:{input:ae(null!==e.rates&&void 0!==e.rates?e.rates.input:""),output:ae(null!==e.rates&&void 0!==e.rates?e.rates.output:""),cacheRead:ae(null!==e.rates&&void 0!==e.rates?e.rates.cacheRead:""),cacheWrite:ae(null!==e.rates&&void 0!==e.rates?e.rates.cacheWrite:"")}}))}}function fe(e,t=0){const a=null!==e&&"object"==typeof e?e:{},n=Number.isFinite(t)?Math.trunc(t):0;return{policyId:"custom-peak",effectiveFromText:"",holidaysEnabled:!1,holidaysText:"",holidaysSourceText:"",rules:[{id:"peak-1",weekdays:[1,2,3,4,5],windows:[{start:ue(60+n),end:ue(240+n)}],rates:{input:ae(a.input),output:ae(a.output),cacheRead:ae(a.cacheRead),cacheWrite:ae(a.cacheWrite)}}]}}function ye(e){return null===e||"object"!=typeof e?null:{policyId:String(void 0===e.policyId?"":e.policyId),effectiveFromText:String(void 0===e.effectiveFromText?"":e.effectiveFromText),holidaysEnabled:!0===e.holidaysEnabled,holidaysText:String(void 0===e.holidaysText||null===e.holidaysText?"":e.holidaysText),holidaysSourceText:String(void 0===e.holidaysSourceText||null===e.holidaysSourceText?"":e.holidaysSourceText),rules:(Array.isArray(e.rules)?e.rules:[]).map((e,t)=>({id:"string"==typeof e.id&&""!==e.id?e.id:"peak-"+(t+1),weekdays:(Array.isArray(e.weekdays)?e.weekdays:[]).map(Number),windows:(Array.isArray(e.windows)?e.windows:[]).map(e=>({start:String(void 0===e.start?"":e.start),end:String(void 0===e.end?"":e.end)})),rates:{input:String(void 0===e.rates||null===e.rates||void 0===e.rates.input?"":e.rates.input),output:String(void 0===e.rates||null===e.rates||void 0===e.rates.output?"":e.rates.output),cacheRead:String(void 0===e.rates||null===e.rates||void 0===e.rates.cacheRead?"":e.rates.cacheRead),cacheWrite:String(void 0===e.rates||null===e.rates||void 0===e.rates.cacheWrite?"":e.rates.cacheWrite)}}))}}function xe(e,t,a){const n=ye(e);return null===n||void 0===n.rules[t]||(n.rules[t]=Object.assign({},n.rules[t],a)),n}function ve(e,t,a){return xe(e,t,{windows:a})}function we(e,t=0){const a=me(null!==e&&"object"==typeof e?e.effectiveFromText:"",t),n=pe((null!==e&&"object"==typeof e&&Array.isArray(e.rules)?e.rules:[]).map((e,t)=>({id:"string"==typeof e.id&&""!==e.id?e.id:"peak-"+(t+1),weekdays:(Array.isArray(e.weekdays)?e.weekdays:[]).slice().sort((e,t)=>e-t),windows:(Array.isArray(e.windows)?e.windows:[]).map(e=>({startMinute:ce(e.start),endMinute:ce(e.end)})),rates:{input:ae(null!==e.rates&&void 0!==e.rates?e.rates.input:""),output:ae(null!==e.rates&&void 0!==e.rates?e.rates.output:""),cacheRead:ae(null!==e.rates&&void 0!==e.rates?e.rates.cacheRead:""),cacheWrite:ae(null!==e.rates&&void 0!==e.rates?e.rates.cacheWrite:"")}})),-t);return{policies:[{policyId:String(null!==e&&"object"==typeof e&&void 0!==e.policyId?e.policyId:"").trim(),timezone:"UTC",effectiveFrom:null===a?0:a,effectiveUntil:null,defaultPlan:null,holidays:null!==e&&"object"==typeof e&&!0===e.holidaysEnabled&&ge(e.holidaysText)||[],holidaysSource:null!==e&&"object"==typeof e?String(void 0===e.holidaysSourceText||null===e.holidaysSourceText?"":e.holidaysSourceText).trim().slice(0,512):"",rules:n}]}}function ke(e){if(null===e||"object"!=typeof e)return"temporal";const t=String(void 0===e.policyId?"":e.policyId).trim();if(""===t||t.length>128)return"temporal";if(null===me(e.effectiveFromText))return"temporal";if(!0===e.holidaysEnabled&&null===ge(e.holidaysText))return"temporal";const a=Array.isArray(e.rules)?e.rules:[];if(0===a.length||a.length>16)return"temporal";const n=new Map;for(const e of a){const t=Array.isArray(e.weekdays)?e.weekdays.map(Number):[];if(0===t.length||t.some(e=>!Number.isInteger(e)||e<0||e>6))return"temporal";const a=Array.isArray(e.windows)?e.windows:[];if(0===a.length||a.length>16)return"temporal";for(const e of a){const a=ce(e.start),r=ce(e.end);if(null===a||null===r||r<=a)return"temporal";for(const e of t){const t=void 0===n.get(e)?[]:n.get(e);t.push({start:a,end:r}),n.set(e,t)}}if(!["input","output","cacheRead","cacheWrite"].every(t=>ee(null!==e.rates&&void 0!==e.rates?e.rates[t]:"")))return"temporal"}for(const e of n.values()){e.sort((e,t)=>e.start-t.start);for(let t=1;t<e.length;t+=1)if(e[t].start<e[t-1].end)return"temporal"}return""}function Ee(e){const t=String(e||"").trim();return t.includes(" / ")?t:function(e){return String(e||"").trim().toLowerCase().replace(/^.*\//,"").split(":")[0]}(t)}function Ne(e,t){const a=e.split("-"),n="en"===t,r=n?new Date(Date.UTC(Number(a[0]),Number(a[1])-1,Number(a[2]))):new Date(Number(a[0]),Number(a[1])-1,Number(a[2])),i=n?r.getUTCMonth():r.getMonth(),l=n?r.getUTCDay():r.getDay();if("en"===t){const e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][l];return["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][i]+" "+Number(a[2])+", "+a[0]+" ("+e+", UTC)"}const o=["周日","周一","周二","周三","周四","周五","周六"][l];return a[0]+"年"+Number(a[1])+"月"+Number(a[2])+"日 "+o}function Ce(e){if(null==e)return null;const t=Number(e.input||0)+Number(e.output||0)+Number(e.cacheRead||0)+Number(e.cacheWrite||0)+Number(e.reasoning||0);return Number.isFinite(t)?t:null}function Me(e,t,a){if("en"===a){const a=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][t];return 0===t?e+" "+a:a}return 0===t?e+"年1月":t+1+"月"}function Se(e){return e>=10?4:e>=6?3:e>=3?2:e>=1?1:0}const Ae=[20,45,70,96];function ze(e){return e<=0?"var(--dsw-alias-bg-layer-2)":"color-mix(in srgb, #0969da "+Ae[e-1]+"%, var(--dsw-alias-bg-layer-2))"}function Te(e){return"hsl("+137*e%360+", 70%, 55%)"}const Ie={"30d":5,"90d":13,"12m":53},Re=["30d","90d","12m"],je="12m";function De(e){return Re.includes(e)?e:je}function Fe(e,t,a,n){const r=a&&Array.isArray(e&&e.byDayUtc)?e.byDayUtc:Array.isArray(e&&e.byDay)?e.byDay:[],i=c(new Date,a);if("custom"===t){const e=p(n,a);return null===e?null:{start:e.start,end:e.end}}if("today"===t)return{start:i,end:i};if("7d"===t)return{start:c(u(new Date,-6,a),a),end:i};if("30d"===t)return{start:c(u(new Date,-29,a),a),end:i};if("90d"===t)return{start:c(u(new Date,-89,a),a),end:i};const l=m(r,i);return{start:l.min,end:l.max}}function Ue(e){return null===e?"":JSON.stringify({start:e.start,end:e.end,utc:!0===e.utc,workspaceId:e.workspaceId||null,provider:e.provider||null,modelKey:e.modelKey||null})}function We(e){const t=e&&e.tokens&&"object"==typeof e.tokens?e.tokens:e||{};return{input:Number.isFinite(t.input)?t.input:0,output:Number.isFinite(t.output)?t.output:0,cacheRead:Number.isFinite(t.cacheRead)?t.cacheRead:0,cacheWrite:Number.isFinite(t.cacheWrite)?t.cacheWrite:0,reasoning:Number.isFinite(t.reasoning)?t.reasoning:0}}function Oe(e,t,a){const n=e.split("-").map(Number);return c(a?new Date(Date.UTC(n[0],n[1]-1,n[2]+t)):new Date(n[0],n[1]-1,n[2]+t),a)}const Le=[{days:3,unit:"static"},{days:4,unit:"static"},{days:7,unit:"week",stride:1},{days:10,unit:"static"},{days:14,unit:"week",stride:2},{days:21,unit:"week",stride:3},{days:30,unit:"static"},{days:61,unit:"static"},{days:91,unit:"static"},{days:182,unit:"static"},{days:365,unit:"static"}];function Pe(e,t,a){return e&&Number.isFinite(e.time)?function(e,t,a){const n=a?{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}:{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1};return"en"===t&&(n.timeZone="UTC"),new Date(e).toLocaleString("en"===t?"en-US":"zh-CN",n)}(e.time,t,a):e&&"string"==typeof e.date?a?Ne(e.date,t):e.date.slice(5):""}function Ke(e){const t=e&&e.bucket&&"object"==typeof e.bucket?e.bucket:null;return null!==t&&t.days>1&&"string"==typeof t.end}function qe(e,t){return e&&Number.isFinite(e.time)?String(e.time):e&&"string"==typeof e.date?e.date:String(t)}function Be(e){return e&&"string"==typeof e.date?e.date:""}function He(e,t,a){const n="string"==typeof e.actualModel&&""!==e.actualModel?e.actualModel:"string"==typeof e.requestedModel&&""!==e.requestedModel?e.requestedModel:"",r="string"==typeof e.model&&""!==e.model?e.model:a,i=r.indexOf(" / "),l=("string"==typeof e.provider&&""!==e.provider?e.provider:"")||(i>0?r.slice(0,i):t),o=l!==t?l+" / ":"",s=""!==n?r:""!==o&&r.startsWith(o)?r.slice(o.length):i>0?r.slice(i+3):r;return{provider:l,model:Ee(n||s)||a}}function Ye(e,t){const[a,r]=n.useState({value:0,done:!1});return n.useEffect(()=>{if("number"!=typeof e||!Number.isFinite(e)||e<=0)return void r({value:0,done:!1});if(a.done)return void r({value:e,done:!0});const n=Date.now(),i=t.interval(()=>{const t=Math.min(1,(Date.now()-n)/700),a=1-Math.pow(1-t,3);t>=1?(i(),r({value:e,done:!0})):r({value:Math.round(e*a),done:!1})},32);return i},[e]),a.value}function Ve(e){if(!Array.isArray(e)||0===e.length)return"";if(1===e.length)return"M"+e[0].x.toFixed(2)+" "+e[0].y.toFixed(2);const t=[];for(let a=0;a<e.length-1;a+=1){const n=e[a+1].x-e[a].x;t.push(0===n?0:(e[a+1].y-e[a].y)/n)}const a=new Array(e.length).fill(0);a[0]=t[0],a[e.length-1]=t[t.length-1];for(let n=1;n<e.length-1;n+=1){const e=t[n-1],r=t[n];a[n]=e*r<=0?0:(e+r)/2}for(let e=0;e<t.length;e+=1){if(0===t[e]){a[e]=0,a[e+1]=0;continue}const n=a[e]/t[e],r=a[e+1]/t[e],i=n*n+r*r;if(i>9){const l=3/Math.sqrt(i);a[e]=l*n*t[e],a[e+1]=l*r*t[e]}}let n="M"+e[0].x.toFixed(2)+" "+e[0].y.toFixed(2);for(let t=0;t<e.length-1;t+=1){const r=e[t+1].x-e[t].x,i=e[t].x+r/3,l=e[t].y+a[t]*r/3,o=e[t+1].x-r/3,s=e[t+1].y-a[t+1]*r/3;n+=" C"+i.toFixed(2)+" "+l.toFixed(2)+" "+o.toFixed(2)+" "+s.toFixed(2)+" "+e[t+1].x.toFixed(2)+" "+e[t+1].y.toFixed(2)}return n}function Je(e){if(!Array.isArray(e)||e.length<2)return 1;let t=0;for(let a=1;a<e.length;a+=1){const n=e[a].x-e[a-1].x,r=e[a].y-e[a-1].y;t+=Math.sqrt(n*n+r*r)}return Math.max(1,Math.ceil(1.35*t+2))}const Ge=["#0a84ff","#30d158","#bf5af2","#ff9f0a","#ff375f","#64d2ff"],$e={total:"#f4c542",input:"#5aa9ff",cacheRead:"#44d483",cacheWrite:"#d98bff",output:"#ff8c66",reasoning:"#aab4c4"},_e={total:.2,input:.16,cacheRead:.18,cacheWrite:.14,output:.16,reasoning:.1};function Xe(e,t){const a=W(e,t);return""!==a?a:v(e)}function Ze(e,t){return Xe(e,t)+("en"===t?" tokens":" Token")}function Qe(e,t,a,n,r){const i=Math.max(0,r-n),l=n=>({x:e+a*Math.cos(n),y:t+a*Math.sin(n)}),o=l(n);if(i>=2*Math.PI-1e-4){const e=l(n+Math.PI);return"M"+o.x.toFixed(2)+" "+o.y.toFixed(2)+" A"+a+" "+a+" 0 1 1 "+e.x.toFixed(2)+" "+e.y.toFixed(2)+" A"+a+" "+a+" 0 1 1 "+o.x.toFixed(2)+" "+o.y.toFixed(2)}const s=l(r);return"M"+o.x.toFixed(2)+" "+o.y.toFixed(2)+" A"+a+" "+a+" 0 "+(i>Math.PI?1:0)+" 1 "+s.x.toFixed(2)+" "+s.y.toFixed(2)}const et=n.memo(function(e){const t="en"===e.language?"en":"zh",[a,r]=n.useState(null),i=n.useRef(null),l=n.useRef(null),o=n.useRef(null),s=n.useRef(null),c=n.useMemo(()=>function(e,t,a=5){const n=Math.max(1,Number.isInteger(a)?a:5),r=(Array.isArray(e)?e:[]).map((e,t)=>({label:e&&void 0!==e.label?String(e.label):"",value:Number(e&&e.value),color:e&&"string"==typeof e.color&&""!==e.color?e.color:Ge[t%Ge.length],iconKey:e&&void 0!==e.iconKey?e.iconKey:void 0,cost:H(e)})).filter(e=>""!==e.label&&Number.isFinite(e.value)&&e.value>0).sort((e,t)=>t.value-e.value),i=r.reduce((e,t)=>e+t.value,0);if(i<=0)return{total:0,segments:[]};const l=r.slice(0,n),o=r.slice(n),s=o.reduce((e,t)=>e+t.value,0);if(s>0){const e={currency:"USD",input:"0",output:"0",cacheRead:"0",cacheWrite:"0",baseTotal:"0",total:"0",pricedCalls:0,unpricedCalls:0,ambiguousCalls:0,unsupportedCalls:0};for(const t of o)Y(e,t.cost);l.push({label:t+" ("+(r.length-n)+")",value:s,color:"#b8c2cf",iconKey:null,cost:e,other:!0})}let c=-Math.PI/2;return{total:i,segments:l.map((e,t)=>{const a=e.value/i*Math.PI*2,n=l.length>1?Math.min(.018,a/3):0,r=c+n,o=c+a-n;return c+=a,{...e,index:t,percentage:e.value/i*100,startAngle:o<=r?c-a:r,endAngle:o<=r?c:o}})}}(e.items,"en"===t?"Other":"其他"),[e.items,t]),u=null===a?null:c.segments[a]||null,d=e=>(e>=10?Math.round(e):Math.round(10*e)/10)+"%",p=n.useCallback(()=>{o.current=null,null!==s.current&&(window.clearTimeout(s.current),s.current=null);const e=i.current,t=l.current;if(null!==e&&null!==t){if(t.fixed)e.style.left=t.left+"px",e.style.top=t.top+"px";else{const a=t.visual?.getBoundingClientRect();if(!a)return;const n=198,r=82;e.style.left=Math.max(8,Math.min(Math.max(8,a.width-n),t.x-a.left+14))+"px",e.style.top=Math.max(8,Math.min(Math.max(8,a.height-r),t.y-a.top+14))+"px"}e.style.visibility="visible"}},[]),m=n.useCallback(e=>{l.current=e,null===o.current&&(o.current=window.requestAnimationFrame(p),s.current=window.setTimeout(()=>{null!==o.current&&(window.cancelAnimationFrame(o.current),p())},80))},[p]),h=n.useCallback(e=>{m({x:e.clientX,y:e.clientY,visual:e.currentTarget.ownerSVGElement?.parentElement})},[m]),g=n.useCallback(()=>{r(null),l.current=null},[]);return n.useEffect(()=>()=>{null!==o.current&&window.cancelAnimationFrame(o.current),null!==s.current&&window.clearTimeout(s.current)},[]),n.useEffect(()=>{null!==a&&null!==l.current&&null===o.current&&(o.current=window.requestAnimationFrame(p))},[a,p]),c.total<=0?null:n.createElement("div",{className:"uh-donut-chart","aria-label":e.title},n.createElement("div",{className:"uh-donut-title"},n.createElement(N,{name:e.icon||"chart",size:16}),e.title),n.createElement("div",{className:"uh-donut-layout"},n.createElement("div",{className:"uh-donut-visual"},n.createElement("svg",{className:"uh-donut-svg",viewBox:"0 0 260 260",role:"img","aria-label":e.title+" "+Ze(c.total,t)},n.createElement("circle",{cx:130,cy:130,r:77.5,className:"uh-donut-track",fill:"none",stroke:"var(--dsw-alias-bg-layer-2)",strokeWidth:33}),c.segments.map(e=>n.createElement("path",{key:"donut-"+e.index,d:Qe(130,130,77.5,e.startAngle,e.endAngle),className:"uh-donut-segment"+(a===e.index?" uh-active":""),fill:"none",stroke:e.color,strokeWidth:33,strokeLinecap:"butt",strokeLinejoin:"round",pathLength:1,style:{animationDelay:90*e.index+"ms"},tabIndex:0,"aria-label":e.label+" "+Ze(e.value,t)+" "+d(e.percentage)+" "+V(e.cost,t),onMouseEnter:t=>{r(e.index),h(t)},onMouseMove:h,onMouseLeave:g,onFocus:()=>{r(e.index),m({fixed:!0,left:12,top:12})},onBlur:g}))),u?n.createElement("div",{ref:i,className:"uh-donut-tooltip",style:{visibility:"hidden"}},n.createElement("span",{className:"uh-donut-dot",style:{background:u.color}}),void 0===u.iconKey||null===u.iconKey?null:n.createElement(st,{iconKey:u.iconKey,size:15}),n.createElement("div",{},n.createElement("strong",{},u.label),n.createElement("span",{},Ze(u.value,t)+" · "+d(u.percentage)),n.createElement("span",{className:"uh-donut-tooltip-cost"},V(u.cost,t)))):null,n.createElement("div",{className:"uh-donut-center"},n.createElement("strong",{},Xe(c.total,t)),n.createElement("span",{},"en"===t?"tokens":"Token"))),n.createElement("div",{className:"uh-donut-legend",role:"list"},c.segments.map(e=>n.createElement("div",{key:"legend-"+e.index,className:"uh-donut-legend-row",role:"listitem"},n.createElement("span",{className:"uh-donut-legend-mark"},n.createElement("span",{className:"uh-donut-dot",style:{background:e.color}}),void 0===e.iconKey||null===e.iconKey?null:n.createElement(st,{iconKey:e.iconKey,size:16,showTitle:!0})),n.createElement("div",{className:"uh-donut-legend-copy"},n.createElement("strong",{title:e.label},e.label)),n.createElement("div",{className:"uh-donut-legend-metrics"},n.createElement("span",{},Ze(e.value,t)),n.createElement("span",{className:"uh-donut-cost"},V(e.cost,t))),n.createElement("strong",{className:"uh-donut-percent"},d(e.percentage)))))))});function tt(e,t){return{total:"en"===t?"Total":"总处理",input:"en"===t?"Input":"输入",cacheRead:"en"===t?"Cache hits":"缓存命中",cacheWrite:"en"===t?"Cache writes":"缓存写入",output:"en"===t?"Output":"输出",reasoning:"en"===t?"Reasoning":"推理"}[e]||e}const at=n.memo(function(e){const t="en"===e.language?"en":"zh",a=(e,a)=>"en"===t?a:e,r=Array.isArray(e.rows)?e.rows:[],i=Array.isArray(e.visible)&&e.visible.length>0?e.visible:["total"],[l,o]=n.useState(null),[s,c]=n.useState(null),u=280,d=n.useMemo(()=>function(e,t,a=900,n=250){const r=Array.isArray(t)&&t.length>0?t:["total"],i={left:46,right:14,top:14,bottom:30},l=Math.max(1,a-i.left-i.right),o=Math.max(1,n-i.top-i.bottom),s=(Array.isArray(e)?e:[]).flatMap(e=>r.map(t=>"total"===t?e.total:e.tokens[t]||0)),c=Math.max(1,...s),u={};for(const t of r)u[t]=(Array.isArray(e)?e:[]).map((a,n)=>({x:i.left+(e.length>1?n*l/(e.length-1):l/2),y:i.top+o-("total"===t?a.total:a.tokens[t]||0)/c*o,value:"total"===t?a.total:a.tokens[t]||0}));return{width:a,height:n,padding:i,max:c,points:u}}(r,i,900,u),[r,i]),p=$e,m=_e,h=u-d.padding.bottom,g=n.useMemo(()=>{const e={};for(const t of i){const a=d.points[t]||[],n=Ve(a);e[t]={line:n,area:0===a.length?"":n+" L"+a[a.length-1].x.toFixed(2)+" "+h+" L"+a[0].x.toFixed(2)+" "+h+" Z",length:Je(a)}}return e},[d,i,h]),b=n.useMemo(()=>r.length<=1?[0]:Array.from(new Set([0,Math.floor((r.length-1)/4),Math.floor((r.length-1)/2),Math.floor(3*(r.length-1)/4),r.length-1])),[r]),f=!e.loading&&!e.error&&r.length>0,y=r.length>0&&Number.isFinite(r[0].time),x=!y&&r.length>0&&Ke(r[0]),w=x&&"day"!==r[0].bucket.granularity?function(e,t){const a=e&&e[0]&&e[0].bucket?e[0].bucket:null;if(null===a)return"";const n=function(e){const t=new Map;for(const a of Array.isArray(e)?e:[]){const e=a&&a.bucket&&Number.isFinite(a.bucket.days)?a.bucket.days:0;e<=0||t.set(e,(t.get(e)||0)+1)}let a=0,n=0;for(const[e,r]of t)(r>n||r===n&&e>a)&&(a=e,n=r);return a}(e);if("week"===a.granularity){const e=Math.max(1,Math.round(n/7));return e<=1?"en"===t?"Weekly":"按周汇总":"en"===t?"Every "+e+" weeks":"每 "+e+" 周汇总"}return n<=1?"en"===t?"Daily":"按天汇总":n<28?("en"===t?"Every ":"每 ")+n+("en"===t?" days":" 天汇总"):n<300?"en"===t?"Monthly":"按月汇总":"en"===t?"Yearly":"按年汇总"}(r,t):"",k=n.useCallback((e,a)=>Ke(e)?function(e,t,a){const n=Pe(e,t,a);return a?n+" – "+Ne(e.bucket.end,t):n}(e,t,a):Pe(e,t,a),[t]),E=y?a("每小时 Token 使用趋势,选择小时查看当天请求日志","Hourly Token usage trend; select an hour to view request logs"):a("每日 Token 使用趋势,选择日期查看请求日志","Daily Token usage trend; select a date to view request logs"),C=(null===l||r[l],null===l?null:(d.points[i[0]]||[])[l]||null),M=null===s?null:r[s]||null,S=null===s?null:(d.points[i[0]]||[])[s]||null,A=null!==l&&null!==M&&null!==S,z=null!==S&&S.x>612?" uh-left":" uh-right",T=null===S?void 0:{left:(S.x/900*100).toFixed(2)+"%",top:Math.max(23,Math.min(77,S.y/u*100)).toFixed(2)+"%"},I=e=>{o(e),c(e)},R=e.loading?n.createElement("div",{className:"uh-trend-stage uh-trend-loading",role:"status","aria-label":a("正在加载趋势","Loading trend")},n.createElement("span",{className:"uh-trend-spinner","aria-hidden":!0})):e.error?n.createElement("div",{className:"uh-trend-stage uh-trend-message",role:"alert"},e.error):0===r.length?n.createElement("div",{className:"uh-trend-stage uh-trend-message"},a("该范围内暂无趋势数据","No trend data in this range")):n.createElement("div",{className:"uh-trend-chart-wrap"},n.createElement("svg",{className:"uh-trend-svg",viewBox:"0 0 900 "+u,role:"group","aria-label":E},[0,.5,1].map(e=>n.createElement(n.Fragment,{key:e},n.createElement("line",{x1:d.padding.left,x2:900-d.padding.right,y1:d.padding.top+(u-d.padding.top-d.padding.bottom)*e,y2:d.padding.top+(u-d.padding.top-d.padding.bottom)*e,className:"uh-trend-grid"}),n.createElement("text",{x:d.padding.left-7,y:d.padding.top+(u-d.padding.top-d.padding.bottom)*e+4,className:"uh-trend-axis-label",textAnchor:"end"},v(Math.round(d.max*(1-e)))))),n.createElement("defs",{},i.map(e=>n.createElement("linearGradient",{key:e,id:"uh-trend-gradient-"+e,x1:"0",y1:"0",x2:"0",y2:"1"},n.createElement("stop",{offset:"4%",stopColor:p[e]||"#9aa4b2",stopOpacity:m[e]||.12}),n.createElement("stop",{offset:"96%",stopColor:p[e]||"#9aa4b2",stopOpacity:0})))),i.map((e,t)=>{const a=g[e]?g[e].area:"";return""===a?null:n.createElement("path",{key:"area-"+e,d:a,className:"uh-trend-area","data-series":e,fill:"url(#uh-trend-gradient-"+e+")",style:{animationDelay:80+80*t+"ms"}})}),i.map(e=>n.createElement("path",{key:"line-base-"+e,d:g[e]?g[e].line:"",className:"uh-trend-line","data-series":e,stroke:p[e]||"#9aa4b2"})),i.map((e,t)=>{d.points[e];const a=g[e]?g[e].length:0;return n.createElement("path",{key:"line-draw-"+e,d:g[e]?g[e].line:"",className:"uh-trend-line-draw","data-series":e,stroke:p[e]||"#9aa4b2",style:{"--uh-draw-length":a+"px",animationDelay:90*t+"ms"}})}),i.map(e=>{const t=d.points[e]||[];if(1!==t.length)return null;const a=t[0];return n.createElement("circle",{key:"single-point-"+e,cx:a.x,cy:a.y,r:4,className:"uh-trend-point",fill:p[e]||"#9aa4b2"})}),null!==l&&C?n.createElement(n.Fragment,{key:"hover-"+l},n.createElement("line",{x1:C.x,x2:C.x,y1:d.padding.top,y2:h,className:"uh-trend-cursor"}),i.map(e=>{const t=(d.points[e]||[])[l];return t?n.createElement("circle",{key:e,cx:t.x,cy:t.y,r:4,className:"uh-trend-point",fill:p[e]||"#9aa4b2"}):null})):null,r.map((a,r)=>{const l=(d.points[i[0]]||[])[r];if(!l)return null;const s=(d.points[i[0]]||[])[r+1],c=s?Math.max(8,s.x-l.x):r>0?Math.max(8,l.x-(d.points[i[0]]||[])[r-1].x):24;return n.createElement("rect",{key:qe(a,r),x:Math.max(d.padding.left,l.x-c/2),y:d.padding.top,width:c,height:u-d.padding.top-d.padding.bottom,className:"uh-trend-hit",tabIndex:x?-1:0,role:x?"img":"button","aria-label":k(a,!0)+" "+tt("total",t)+" "+v(a.total),onMouseEnter:()=>I(r),onMouseLeave:()=>o(null),onFocus:()=>I(r),onBlur:()=>o(null),onKeyDown:t=>{x||"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),"function"==typeof e.onPointClick&&e.onPointClick(Be(a)))},onClick:()=>{x||"function"==typeof e.onPointClick&&e.onPointClick(Be(a))}})}),b.map(e=>{const t=(d.points[i[0]]||[])[e],a=r[e];return t&&a?n.createElement("text",{key:qe(a,e),x:t.x,y:272,className:"uh-trend-axis-label",textAnchor:0===e?"start":e===r.length-1?"end":"middle"},k(a,!1)):null})),M&&S?n.createElement("div",{className:"uh-trend-tooltip"+z+(A?" uh-visible":""),style:T,"aria-hidden":!A},n.createElement("strong",{className:"uh-trend-tooltip-title"},k(M,!0)),i.map(e=>n.createElement("div",{key:e,className:"uh-trend-tooltip-row",style:{color:p[e]||"#9aa4b2"}},n.createElement("span",{className:"uh-trend-dot",style:{background:p[e]||"#9aa4b2"}}),n.createElement("span",{className:"uh-trend-tooltip-label"},tt(e,t)),n.createElement("strong",{className:"uh-trend-tooltip-value"},v(function(e,t){return"total"===t?e.total:e.tokens&&Number.isFinite(e.tokens[t])?e.tokens[t]:0}(M,e)))))):null);return n.createElement("div",{className:"uh-panel uh-trend-panel"},n.createElement("div",{className:"uh-trend-head"},n.createElement("div",{},n.createElement("h3",{className:"uh-tbl-title uh-title-with-icon"},n.createElement(N,{name:"chart",size:16}),a("Token 使用趋势","Token Usage Trend")),n.createElement("div",{className:"uh-note"},(e.rangeLabel||"")+(x?(e.rangeLabel?" · ":"")+w:""))),f?n.createElement("div",{className:"uh-note"},x?a("区间较长,每点为一个周期","Long range summarised: one point per period"):a("点击数据点查看当日明细","Click a point to inspect that day")):null),R,f?n.createElement("div",{className:"uh-trend-legend"},["total","input","cacheRead","cacheWrite","output","reasoning"].map(a=>n.createElement("button",{key:a,type:"button",className:"uh-trend-legend-item"+(i.includes(a)?" uh-on":""),onClick:()=>(t=>{"function"==typeof e.onToggle&&e.onToggle(t)})(a),"aria-pressed":i.includes(a)},n.createElement("span",{className:"uh-trend-dot",style:{background:p[a]||"#9aa4b2"}}),tt(a,t)))):null)}),nt=n.memo(function(e){const t="en"===e.language?"en":"zh",a=e.day,r=n.useMemo(()=>(a&&Array.isArray(a.perWorkspace)?a.perWorkspace:[]).slice().sort((e,t)=>t.turns-e.turns),[a]),i=void 0===a?null:We(a),l=null!==i&&i.input+i.output+i.cacheRead>0?"en"===t?"Tokens: Input "+v(i.input)+" · Cache hits "+v(i.cacheRead)+" · Output "+v(i.output):"Token:输入 "+v(i.input)+" · 缓存命中 "+v(i.cacheRead)+" · 输出 "+v(i.output):"";return n.createElement("div",{ref:e.tooltipRef,className:"uh-tip",style:{left:0,top:0,visibility:"hidden"}},n.createElement("div",{className:"uh-tip-date"},Ne(e.date,t)),void 0!==a&&a.turns>0?r.map(a=>n.createElement("div",{key:a.workspaceId,className:"uh-tip-row",onClick:()=>e.onWorkspaceSelect(a.workspaceId)},n.createElement("span",{className:"uh-dot",style:{background:Te(e.workspaceIndexes.get(a.workspaceId)||0)}}),n.createElement("span",{},e.workspaceTitles.get(a.workspaceId)||("en"===t?"Unknown workspace":"未知工作区")),n.createElement("span",{className:"uh-n"},"en"===t?a.turns+" uses":a.turns+" 次"))):n.createElement("div",{className:"uh-empty",style:{padding:"6px 0"}},"en"===t?"No usage records for this day":"这一天没有使用记录"),""!==l?n.createElement("div",{className:"uh-tip-tokens"},l):null)}),rt=n.memo(function(e){const t="en"===e.language?"en":"zh",a=(e,a)=>"en"===t?a:e,r=Array.isArray(e.workspaces)?e.workspaces:[],i=Array.isArray(e.rows)?e.rows:[],l=e.workspaceId||null,[o,s]=n.useState(null),d=n.useRef(null),p=n.useRef(null),m=n.useRef({x:0,y:0}),h=n.useRef(null),g=n.useRef(null),b=n.useRef(e.onDateClick),f=n.useRef(e.onWorkspaceSelect);b.current=e.onDateClick,f.current=e.onWorkspaceSelect;const y=(x=e.span,Ie[De(x)]);var x;const v=y<Ie[je]?34*y+3*(y-1)+"px":null,w={minWidth:13*y+"px"},k={gridTemplateColumns:"repeat("+y+", minmax(10px, 1fr))",minWidth:13*y+"px"};null!==v&&(w.maxWidth=v,k.maxWidth=v);const E=n.useMemo(()=>function(e,t,a,n){const r=Number.isSafeInteger(n)&&n>0&&n<=53?n:Ie[je],i=String(e||"").split("-").map(Number),l=t?new Date(Date.UTC(i[0],i[1]-1,i[2])):new Date(i[0],i[1]-1,i[2]),o=t?l.getUTCDay():l.getDay(),s=u(l,-o,t),d=u(s,7*-(r-1),t),p=[];for(let e=0;e<7*r;e+=1){const a=u(d,e,t);p.push({date:c(a,t),month:t?a.getUTCMonth():a.getMonth(),year:t?a.getUTCFullYear():a.getFullYear()})}const m=[];for(let e=0;e<r;e+=1){const t=p[7*e],n=e>0?p[7*(e-1)]:null;null!==n&&t.month===n.month||m.push({left:100*e/r+"%",text:Me(t.year,t.month,a)})}return{cells:p,months:m,weekdays:"en"===a?["","Mon","","Wed","","Fri",""]:["","周一","","周三","","周五",""]}}(e.todayKey,!0===e.utc,t,y),[e.todayKey,e.utc,t,y]),C=n.useMemo(()=>{const e=new Map;for(const t of i)t&&"string"==typeof t.date&&e.set(t.date,t);return e},[i]),M=n.useMemo(()=>{const t=new Map,n=new Map,i=e.aliases&&"object"==typeof e.aliases?e.aliases:{};return r.forEach((e,r)=>{const l=i[e.id],o=!0===e.retiredBucket,s=o?a("已删除","Deleted"):"string"==typeof l&&""!==l?l:e.title||a("未知工作区","Unknown workspace");t.set(e.id,!0!==e.deleted||o?s:s+a("(已删除)"," (deleted)")),n.set(e.id,r)}),{titles:t,indexes:n}},[r,e.aliases,t]),S=n.useCallback(()=>{h.current=null,null!==g.current&&(window.clearTimeout(g.current),g.current=null);const e=p.current;if(null===e)return;const t=m.current,a="undefined"==typeof window?1280:window.innerWidth;e.style.left=t.x+14+"px",e.style.top=t.y+12+"px",e.style.transform=t.x>.65*a?"translateX(calc(-100% - 28px))":"none",e.style.visibility="visible"},[]),A=n.useCallback((e,t)=>{m.current={x:e,y:t},null===h.current&&(h.current=window.requestAnimationFrame(S),g.current=window.setTimeout(()=>{null!==h.current&&(window.cancelAnimationFrame(h.current),S())},80))},[S]);n.useEffect(()=>()=>{null!==h.current&&window.cancelAnimationFrame(h.current),null!==g.current&&window.clearTimeout(g.current)},[]),n.useEffect(()=>{null!==o&&null===h.current&&(h.current=window.requestAnimationFrame(S))},[o,S]);const z=n.useCallback((e,t)=>{d.current!==e&&(d.current=e,s(e)),A(t.clientX,t.clientY)},[A]),T=n.useRef([]),I=n.useCallback(e=>{const t=T.current,a=null==t?void 0:t[e];if(null!=a&&"function"==typeof a.focus){for(const e of t)null!=e&&(e.tabIndex=-1);a.tabIndex=0,a.focus()}},[]),R=n.useCallback((e,t)=>{const a=null==t||"function"!=typeof t.getBoundingClientRect?null:t.getBoundingClientRect();z(e,{clientX:null===a?0:a.left+a.width/2,clientY:null===a?0:a.top})},[z]),j=n.useCallback((e,t,a)=>{const n=e.key;if("Enter"===n||" "===n||"Spacebar"===n){e.preventDefault();const t=null===e.currentTarget?"":e.currentTarget.getAttribute("data-date");return void("function"==typeof b.current&&"string"==typeof t&&b.current(t))}const r="ArrowRight"===n?t+1:"ArrowLeft"===n?t-1:"ArrowDown"===n?t+7:"ArrowUp"===n?t-7:"Home"===n?0:"End"===n?a-1:null;null!==r&&(e.preventDefault(),r<0||r>=a||I(r))},[I]),D=n.useCallback(e=>{A(e.clientX,e.clientY)},[A]),F=n.useCallback(()=>{d.current=null,s(null)},[]),U=n.useCallback(e=>{"function"==typeof f.current&&f.current(e),F()},[F]),W=n.useMemo(()=>{const t=E.cells.map(e=>e.date);if(t.indexOf(e.todayKey)>=0)return e.todayKey;for(let e=t.length-1;e>=0;e-=1)if(C.has(t[e]))return t[e];return t.length>0?t[0]:null},[E.cells,C,e.todayKey]),O=E.cells.length,L=n.useMemo(()=>E.cells.map((a,r)=>{const i=C.get(a.date);let o=0;if(void 0!==i)if(!0===e.queryUsable||null===l)o=i.turns;else{const e=Array.isArray(i.perWorkspace)?i.perWorkspace.find(e=>e.workspaceId===l):void 0;void 0!==e&&(o=e.turns)}const s=null!==l&&void 0!==i&&i.turns>0&&0===o,c=function(e,t,a){const n=Ne(e,a),r=Number.isFinite(t)&&t>0?t:0;return"en"===a?n+": "+(r>0?r+" uses":"no usage"):n+":"+(r>0?r+" 次使用":"无使用记录")}(a.date,o,t),u={background:ze(Se(o)),opacity:s?.22:1,animationDelay:r%25*6+"ms"};return a.date!==e.todayKey||function(){try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch(e){return!1}}()||(u.animation="uh-cell-in .45s ease both, uh-glow 3s ease-in-out .7s infinite"),n.createElement("div",{key:a.date,className:"uh-cell",style:u,role:"button","data-date":a.date,"aria-label":c,tabIndex:a.date===W?0:-1,ref:e=>{T.current[r]=e},onMouseEnter:e=>z(a.date,e),onMouseMove:D,onMouseLeave:F,onFocus:e=>R(a.date,e.currentTarget),onBlur:F,onKeyDown:e=>j(e,r,O),onClick:()=>{"function"==typeof b.current&&b.current(a.date)}})}),[E.cells,C,e.queryUsable,e.todayKey,l,z,D,F,R,j,W,O,t]),P=null===o?void 0:C.get(o);return n.createElement("div",{className:"uh-panel"},n.createElement("div",{className:"uh-section-title"},n.createElement(N,{name:"calendar",size:16}),a("使用热力图","Usage Heatmap")),n.createElement("div",{className:"uh-hm-head"},n.createElement("div",{className:"uh-chips"},r.map((e,t)=>n.createElement("button",{key:e.id,className:"uh-chip"+(l===e.id?" uh-on":""),onClick:()=>U(e.id),title:e.path||(!0===e.retiredBucket?a("已删除","Deleted"):"")},n.createElement("span",{className:"uh-dot",style:{background:Te(t)}}),n.createElement("span",{className:"uh-chip-title"},M.titles.get(e.id))))),n.createElement("div",{className:"uh-hm-tools"},n.createElement("div",{className:"uh-range uh-heatmap-spans",role:"group","aria-label":a("热力图范围","Heatmap span")},Re.map(t=>n.createElement("button",{key:t,type:"button",className:De(e.span)===t?"uh-on":"","aria-pressed":De(e.span)===t,title:"30d"===t?a("最近 30 天(格子更大)","Last 30 days (larger cells)"):"90d"===t?a("最近 90 天","Last 90 days"):a("最近 12 个月","Last 12 months"),onClick:()=>{"function"==typeof e.onSpanChange&&e.onSpanChange(t)}},"30d"===t?a("30 天","30 days"):"90d"===t?a("90 天","90 days"):a("12 个月","12 months")))),n.createElement("div",{className:"uh-legend","aria-hidden":!0},n.createElement("span",{},a("少","Less")),[0,1,2,3,4].map(e=>n.createElement("span",{key:e,className:"uh-cell",style:{background:ze(e)}})),n.createElement("span",{},a("多","More"))))),n.createElement("div",{className:"uh-hm-scroll"},n.createElement("div",{className:"uh-months",style:w},E.months.map((e,t)=>n.createElement("span",{key:t,style:{left:e.left}},e.text))),n.createElement("div",{className:"uh-hm-body"},n.createElement("div",{className:"uh-wdays"},E.weekdays.map((e,t)=>n.createElement("span",{key:t},e))),n.createElement("div",{className:"uh-grid",style:k,role:"group","aria-label":a("使用热力图日历:方向键浏览,回车查看当日明细","Usage heatmap calendar: arrow keys to browse, Enter for the day detail")},L))),n.createElement("div",{className:"uh-note",style:{marginTop:10}},a("口径:每完成一个回合点亮一次(含子代理会话);悬停查看按工作区明细,点击工作区可筛选热力图与明细表;键盘可用方向键浏览、回车查看当日明细。日期按本地时区。","Methodology: one cell lights up for each completed turn, including subagent sessions. Hover to view workspace details; click a workspace to filter the heatmap and detail tables. English dates and day boundaries use UTC.")),null!==o?n.createElement(nt,{date:o,day:P,language:t,tooltipRef:p,workspaceTitles:M.titles,workspaceIndexes:M.indexes,onWorkspaceSelect:U}):null)});function it(e,t){return Number(e&&e.values&&e.values[t])||0}const lt=n.memo(function(e){return e.render()},(e,t)=>e.revision===t.revision),ot=n.memo(function(e){return e.render(e.view)},function(e,t){return e===t||e.busy===t.busy&&e.language===t.language&&e.openSection===t.openSection&&e.searchText===t.searchText&&e.searchOpen===t.searchOpen&&e.searchOptions===t.searchOptions&&e.temporalDraft===t.temporalDraft&&e.temporalPlan===t.temporalPlan&&e.holidayStatus===t.holidayStatus&&e.holidayLoading===t.holidayLoading&&(a=e.view,n=t.view,a===n||null!=a&&null!=n&&a.key===n.key&&a.model===n.model&&a.status===n.status&&a.reason===n.reason&&a.source===n.source&&a.mapped===n.mapped&&a.usageBacked===n.usageBacked&&a.mappable===n.mappable&&a.pricingModel===n.pricingModel&&a.providerId===n.providerId&&a.tiered===n.tiered&&a.tierCount===n.tierCount&&a.tieredInvalid===n.tieredInvalid&&a.multiplier===n.multiplier&&a.inputTokenSemantics===n.inputTokenSemantics&&a.temporalExplicit===n.temporalExplicit&&a.temporalBuiltin===n.temporalBuiltin&&a.temporalConfigInvalid===n.temporalConfigInvalid&&a.temporalRulesUnavailable===n.temporalRulesUnavailable&&a.temporalPolicyId===n.temporalPolicyId&&a.temporalRuleCount===n.temporalRuleCount&&a.overrideIndex===n.overrideIndex&&a.mappingIndex===n.mappingIndex&&function(e,t){return e===t||null!=e&&null!=t&&e.input===t.input&&e.output===t.output&&e.cacheRead===t.cacheRead&&e.cacheWrite===t.cacheWrite}(a.rates,n.rates)&&function(e,t){if(e===t)return!0;const a=Array.isArray(e)?e:[],n=Array.isArray(t)?t:[];if(a.length!==n.length)return!1;for(let e=0;e<a.length;e+=1){const t=a[e],r=n[e];if(t!==r){if(null==t||null==r)return!1;if(t.size!==r.size||t.input!==r.input||t.output!==r.output||t.cacheRead!==r.cacheRead||t.cacheWrite!==r.cacheWrite)return!1}}return!0}(a.tiers,n.tiers)&&re(a.basis)===re(n.basis));var a,n}),st=n.memo(function(e){const t=Number.isFinite(e.size)?e.size:18,a=null===e.iconKey?null:void 0!==e.iconKey?S.get(e.iconKey)||null:F(e.row),r=null===a?"":a.key+"\0"+a.href,[i,l]=n.useState(null),o={width:t,height:t,minWidth:t};if(null===a||null!==i&&i===r)return n.createElement("span",{className:"uh-model-icon uh-model-icon-fallback"+(e.className?" "+e.className:""),style:o,"aria-hidden":!0},n.createElement(N,{name:"cache",size:t}));const s=!0===e.showTitle;return n.createElement("span",{className:"uh-model-icon"+(e.className?" "+e.className:""),style:o,...s?{}:{"aria-hidden":!0}},n.createElement("img",{key:r,src:a.href,alt:s?a.label:"",title:s?a.label:void 0,width:t,height:t,loading:"lazy",decoding:"async",draggable:!1,onError:()=>l(r)}))}),ct=n.memo(function(e){const t="en"===e.language?"en":"zh",a=(e,a)=>"en"===t?a:e,r=Array.isArray(e.rows)?e.rows:[],i=n.useMemo(()=>r.find(t=>t.id===e.selectedId)||r[0]||null,[r,e.selectedId]),l=n.useRef(null),o=()=>{!0!==e.hasMore||e.loading||"function"==typeof e.onLoadMore&&e.onLoadMore()};n.useEffect(()=>{const t=l.current;null!==t&&(!0!==e.hasMore||e.loading||t.scrollHeight<=t.clientHeight+4&&o())},[r,e.hasMore,e.loading]);const s=e=>e&&"ledger-recovery"===e.materialization?a("账本恢复","Ledger recovery"):e&&"ledger-reuse"===e.materialization?a("账本复用","Ledger reuse"):e&&"scan"===e.materialization?a("扫描","Scan"):e&&"live"===e.materialization?a("实时","Live"):a("未知","Unknown"),c=(e,a)=>e&&Number.isFinite(e.time)?new Date(e.time).toLocaleString("en"===t?"en-US":"zh-CN","en"===t?a?{timeZone:"UTC"}:{timeZone:"UTC",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}:a?void 0:{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"—",u=t=>{"function"==typeof e.onSelect&&e.onSelect(t)};return n.createElement("div",{className:"uh-panel uh-records-panel",ref:e.panelRef,style:{display:e.visible?"block":"none"}},n.createElement("div",{className:"uh-records-head"},n.createElement("div",{},n.createElement("h3",{className:"uh-tbl-title uh-title-with-icon"},n.createElement(N,{name:"list",size:16}),a("请求日志","Request Logs")),n.createElement("div",{className:"uh-note"},e.scopeLabel+(e.scopeUtc?" · UTC":""))),n.createElement("div",{className:"uh-actions"},e.loading?n.createElement("span",{className:"uh-query-note"},a("同步中…","Refreshing…")):null,n.createElement("button",{type:"button",className:"uh-refresh",title:a("导出当前日志","Export current logs"),onClick:e.onExport,disabled:e.exporting||!e.scopeAvailable},n.createElement(N,{name:"export",size:13}),e.exporting?a("导出中…","Exporting…"):a("导出日志","Export logs")))),""!==e.error?n.createElement("div",{className:"uh-records-error",role:"alert"},"stale"===e.error?a("数据已更新,正在重新加载日志…","Data changed; reloading logs…"):"audit-export"===e.error?a("日志导出失败","Unable to export logs"):a("日志加载失败,请重试","Unable to load logs")):null,n.createElement("div",{className:"uh-records-note"},a("按时间倒序显示可审计的 Token 调用;选择一行查看 turn / step 和完整 Token 分桶。","Token calls are newest first; select a row to inspect its turn / step and token buckets.")),0!==r.length||e.loading?n.createElement("div",{className:"uh-records-scroll",ref:l,onScroll:e=>{const t=e.currentTarget;t.scrollTop+t.clientHeight>=t.scrollHeight-120&&o()}},n.createElement("div",{className:"uh-record-grid uh-record-header"},n.createElement("div",{},a("时间","Time")),n.createElement("div",{},a("Provider / 模型","Provider / Model")),n.createElement("div",{className:"uh-record-num"},"turn / step"),n.createElement("div",{className:"uh-record-num"},a("输入","Input")),n.createElement("div",{className:"uh-record-num"},a("缓存命中","Cache read")),n.createElement("div",{className:"uh-record-num"},a("缓存写入","Cache write")),n.createElement("div",{className:"uh-record-num"},a("输出","Output")),n.createElement("div",{className:"uh-record-num"},a("成本","Cost")),n.createElement("div",{},a("来源","Source"))),r.map(e=>n.createElement("div",{key:e.id,className:"uh-record-grid uh-record-row"+(i&&i.id===e.id?" uh-on":""),role:"button",tabIndex:0,"aria-pressed":i&&i.id===e.id,onClick:()=>u(e.id),onKeyDown:t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),u(e.id))}},n.createElement("div",{className:"uh-record-time"},c(e,!1)),n.createElement("div",{className:"uh-record-model",title:e.model||""},n.createElement("span",{className:"uh-model-label"},n.createElement(st,{row:e,size:16}),n.createElement("span",{className:"uh-model-text"},e.model||a("未知模型","Unknown model"))),e.requestedModel&&e.actualModel&&e.requestedModel!==e.actualModel?n.createElement("small",{},e.requestedModel+" → "+e.actualModel):null),n.createElement("div",{className:"uh-record-num"},(null===e.turn||void 0===e.turn?"—":e.turn)+" / "+(null===e.step||void 0===e.step?"—":e.step)),n.createElement("div",{className:"uh-record-num"},v(it(e,"input"))),n.createElement("div",{className:"uh-record-num"},v(it(e,"cacheRead"))),n.createElement("div",{className:"uh-record-num"},v(it(e,"cacheWrite"))),n.createElement("div",{className:"uh-record-num"},v(it(e,"output"))),n.createElement("div",{className:"uh-record-num uh-cost-num"},V(e,t),!e.cost||"peak"!==e.cost.pricingBand&&"off-peak"!==e.cost.pricingBand?null:n.createElement("small",{className:"uh-record-band-badge"},"peak"===e.cost.pricingBand?"en"===t?"Peak":"峰":"en"===t?"OFF":"谷")),n.createElement("div",{className:"uh-record-source"},s(e))))):n.createElement("div",{className:"uh-empty"},a("当前范围没有可审计的 Token 调用","No auditable Token calls in this scope")),n.createElement("div",{className:"uh-records-footer"},n.createElement("span",{className:"uh-note"},r.length>0?e.hasMore?a("已显示 "+r.length+" 条,继续加载可查看更多",r.length+" shown; load more for additional records"):a("共显示 "+r.length+" 条",r.length+" records shown"):""),e.hasMore?n.createElement("button",{type:"button",className:"uh-refresh",onClick:e.onLoadMore,disabled:e.loading},e.loading?a("加载中…","Loading…"):a("加载更多","Load more")):null),i?n.createElement("div",{className:"uh-record-detail"},n.createElement("div",{className:"uh-record-detail-head"},n.createElement("strong",{},a("选中调用","Selected call")),n.createElement("span",{className:"uh-note"},c(i,!0))),n.createElement("div",{className:"uh-record-detail-meta"},n.createElement("span",{className:"uh-model-label"},n.createElement(st,{row:i,size:16,showTitle:!0}),n.createElement("span",{},(i.provider||a("未知供应商","Unknown provider"))+" / "+(i.actualModel||i.requestedModel||i.model||a("未知模型","Unknown model")))),n.createElement("span",{},"turn "+(null===i.turn||void 0===i.turn?"—":i.turn)+" · step "+(null===i.step||void 0===i.step?"—":i.step)),n.createElement("span",{},a("来源:","Source: ")+s(i)),n.createElement("span",{},a("计价模型:","Pricing model: ")+(i.cost&&i.cost.pricingModel?i.cost.pricingModel:a("未计价","unpriced"))),n.createElement("span",{className:"uh-record-band "+(i.cost&&i.cost.pricingBand?"uh-record-band-"+i.cost.pricingBand:"")},a("计费档位:","Billing band: ")+function(e,t){const a=e&&e.cost&&"object"==typeof e.cost?e.cost:{};return"peak"===a.pricingBand?"en"===t?"Peak":"峰时":"off-peak"===a.pricingBand?!0===a.pricingHoliday?"en"===t?"Holiday off-peak":"节假日谷时":"en"===t?"Off-peak":"谷时":"route-not-official"===a.temporalExemptReason?"en"===t?"static (non-first-party)":"静态价(非官方直连)":"no-temporal-profile"===a.temporalExemptReason?"en"===t?"static (no band plan)":"静态价(无峰谷计划)":"—"}(i,t)),null!==J(i,t)?n.createElement("span",{className:"uh-record-band",title:i.cost&&i.cost.pricingPolicyHash||""},a("计费计划:","Plan: ")+J(i,t)):null),n.createElement("div",{className:"uh-record-token-strip"},["input","cacheRead","cacheWrite","output","reasoning"].map(e=>n.createElement("div",{key:e},n.createElement("span",{},"cacheRead"===e?a("缓存命中","Cache read"):"cacheWrite"===e?a("缓存写入","Cache write"):"reasoning"===e?a("推理","Reasoning"):"input"===e?a("输入","Input"):a("输出","Output")),n.createElement("strong",{},v(it(i,e))))),n.createElement("div",{className:"uh-record-token-total"},n.createElement("span",{},a("总处理","Total")),n.createElement("strong",{},v(it(d=i,"input")+it(d,"cacheRead")+it(d,"cacheWrite")+it(d,"output")+it(d,"reasoning")))),n.createElement("div",{className:"uh-record-token-total"},n.createElement("span",{},a("成本","Cost")),n.createElement("strong",{},V(i,t))))):null);var d},function(e,t){return e.visible===t.visible&&e.scopeLabel===t.scopeLabel&&e.scopeUtc===t.scopeUtc&&e.scopeAvailable===t.scopeAvailable&&e.loading===t.loading&&e.exporting===t.exporting&&e.error===t.error&&e.rows===t.rows&&e.selectedId===t.selectedId&&e.hasMore===t.hasMore&&e.language===t.language&&e.actionKey===t.actionKey}),ut=n.memo(function(e){const t=Array.isArray(e.options)?e.options:[],a=void 0===e.value||null===e.value?"":String(e.value),r=t.find(e=>String(e.value)===a),[i,l]=n.useState(!1),o=n.useRef(null),s=n.useRef(null);n.useEffect(()=>{i&&null!==s.current&&"function"==typeof s.current.scrollIntoView&&s.current.scrollIntoView({block:"nearest",inline:"nearest"})},[i]),n.useEffect(()=>{if(!i||"undefined"==typeof document)return;const e=e=>{o.current&&!o.current.contains(e.target)&&l(!1)};return document.addEventListener("pointerdown",e),()=>document.removeEventListener("pointerdown",e)},[i]);const c=t=>{const a=null==t||void 0===t.iconKey||null===t.iconKey?null:t.iconKey;return null===a?n.createElement(N,{name:e.icon||"chart",size:14}):n.createElement(st,{iconKey:a,size:14})};return n.createElement("div",{className:"uh-language-menu uh-filter-menu"+(e.className?" "+e.className:"")+(i?" uh-open":""),ref:o,onKeyDown:e=>{"Escape"===e.key&&i&&(e.preventDefault(),e.stopPropagation(),l(!1))}},n.createElement("button",{type:"button",className:"uh-language-trigger uh-filter-trigger"+(i?" uh-open":""),title:r?r.label:e.label,"aria-label":e.ariaLabel||e.label,"aria-haspopup":"listbox","aria-expanded":i,onClick:()=>l(e=>!e)},c(r),n.createElement("span",{className:"uh-filter-label"},r?r.label:e.label),n.createElement(N,{name:"chevron",size:13,className:"uh-language-caret"})),i?n.createElement("div",{className:"uh-language-options uh-filter-options",role:"listbox","aria-label":e.ariaLabel||e.label},t.map(t=>{const r=String(t.value),i=r===a;return n.createElement("button",{key:r,type:"button",role:"option","aria-selected":i,ref:i?s:void 0,className:"uh-language-option"+(i?" uh-on":""),onClick:()=>{return t=r,"function"==typeof e.onChange&&e.onChange(t),void l(!1);var t}},c(t),n.createElement("span",{className:"uh-filter-option-label"},t.label),i?n.createElement(N,{name:"check",size:14,className:"uh-language-option-check"}):null)})):null)}),dt="dsh-all-usage/styles.css";if("undefined"!=typeof document){let e=document.querySelector("style[data-plugin-css="+JSON.stringify(dt)+"]");null===e&&(e=document.createElement("style"),e.dataset.plugin="dsh-all-usage",e.dataset.pluginCss=dt,document.head.appendChild(e)),e.textContent='\n.uh-page { display:flex; flex-direction:column; gap:14px; padding:2px 2px 28px; font-family:inherit; }\n.uh-head { position:relative; z-index:20; display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }\n.uh-title { margin:0; font-size:15px; font-weight:600; color:var(--dsw-alias-label-primary); }\n.uh-title-wrap { display:flex; align-items:center; gap:10px; flex-wrap:wrap; min-width:0; }\n/* Version chip: the running version plus the registry verdict, clickable to the repo. */\n.uh-version { display:inline-flex; align-items:center; gap:6px; border:1px solid var(--dsw-alias-border-l1); background:transparent; color:var(--dsw-alias-label-secondary); border-radius:999px; padding:2px 9px; font:inherit; font-size:12px; cursor:pointer; transition:background-color .15s ease, border-color .15s ease, color .15s ease; }\n.uh-version:hover { background:var(--dsw-alias-bg-layer-1); color:var(--dsw-alias-label-primary); }\n.uh-version-number { font-variant-numeric:tabular-nums; }\n.uh-version-status { color:var(--dsw-alias-label-tertiary, var(--dsw-alias-label-secondary)); }\n.uh-version-outdated { border-color:color-mix(in srgb, var(--dsw-alias-brand-primary) 55%, transparent); color:var(--dsw-alias-brand-primary); }\n.uh-version-outdated .uh-version-status { color:inherit; font-weight:600; }\n.uh-actions { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }\n.uh-language-menu, .uh-filter-menu { position:relative; z-index:12; }\n.uh-filter-menu { flex:0 1 auto; min-width:0; }\n.uh-filter-workspace { width:180px; }\n.uh-filter-provider { width:180px; }\n.uh-filter-model { width:260px; }\n.uh-filter-menu.uh-open { z-index:14; }\n.uh-language-trigger { display:inline-flex; align-items:center; gap:6px; min-height:30px; padding:4px 9px 4px 10px; border:1px solid transparent; border-radius:15px; background:color-mix(in srgb, var(--dsw-alias-label-primary) 7%, var(--dsw-alias-bg-layer-1)); color:var(--dsw-alias-label-primary); font:inherit; font-size:12px; font-weight:600; line-height:1; cursor:pointer; transition:border-color .15s ease, background-color .15s ease, transform .1s ease; }\n.uh-filter-trigger { width:100%; min-width:0; justify-content:flex-start; }\n.uh-language-trigger:hover, .uh-language-trigger.uh-open { border-color:color-mix(in srgb, var(--dsw-alias-brand-primary) 58%, var(--dsw-alias-border-l2)); background:color-mix(in srgb, var(--dsw-alias-brand-primary) 13%, var(--dsw-alias-bg-layer-1)); }\n.uh-language-trigger:active { transform:scale(.96); }\n.uh-language-label { min-width:26px; text-align:left; }\n.uh-filter-label { min-width:0; flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; text-align:left; }\n.uh-language-caret { color:var(--dsw-alias-label-secondary); transition:transform .18s ease; }\n.uh-language-trigger.uh-open .uh-language-caret { transform:rotate(180deg); }\n.uh-language-menu.uh-open { z-index:30; }\n.uh-language-options { position:absolute; top:calc(100% + 7px); right:0; min-width:142px; padding:5px; border:1px solid var(--dsw-alias-border-l2); border-radius:12px; background:var(--dsw-alias-bg-layer-1); box-shadow:0 14px 28px color-mix(in srgb, #000 24%, transparent); animation:uh-menu-in .16s ease both; }\n.uh-filter-options { left:0; right:auto; min-width:100%; max-width:300px; }\n.uh-language-option { display:flex; align-items:center; gap:8px; width:100%; min-height:32px; padding:6px 8px; border:0; border-radius:8px; background:transparent; color:var(--dsw-alias-label-primary); font:inherit; font-size:12px; text-align:left; cursor:pointer; transition:background-color .14s ease, color .14s ease; }\n.uh-filter-option-label { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }\n.uh-language-option:hover, .uh-language-option:focus-visible { background:color-mix(in srgb, var(--dsw-alias-brand-primary) 14%, var(--dsw-alias-bg-layer-2)); outline:0; }\n.uh-language-option.uh-on { background:color-mix(in srgb, var(--dsw-alias-brand-primary) 19%, var(--dsw-alias-bg-layer-2)); color:var(--dsw-alias-label-primary); font-weight:600; }\n.uh-language-option-check { margin-left:auto; color:var(--dsw-alias-brand-primary); }\n/* Provider and model lists grow with the ledger; the menu scrolls inside itself\n instead of running past the bottom of the window. */\n.uh-filter-options { max-height:min(60vh, 420px); overflow-y:auto; overscroll-behavior:contain; }\n.uh-range { display:inline-flex; border:1px solid var(--dsw-alias-border-l2); border-radius:8px; overflow:hidden; }\n.uh-range button { border:0; background:transparent; color:var(--dsw-alias-label-secondary); padding:4px 12px; font-size:12px; cursor:pointer; font-family:inherit; transition:background-color .15s ease, color .15s ease; }\n.uh-range button + button { border-left:1px solid var(--dsw-alias-border-l2); }\n.uh-range button.uh-on { background:color-mix(in srgb, var(--dsw-alias-brand-primary) 20%, var(--dsw-alias-bg-layer-2)); color:var(--dsw-alias-label-primary); font-weight:600; }\n.uh-custom-range { display:grid; grid-template-columns:minmax(180px, 1fr) auto auto; gap:10px 14px; align-items:end; padding:12px; border:1px solid var(--dsw-alias-border-l1); border-radius:10px; background:var(--dsw-alias-bg-layer-1); }\n.uh-custom-range-meta { min-width:0; }\n.uh-custom-range-title { display:flex; align-items:center; gap:7px; color:var(--dsw-alias-label-primary); font-size:13px; font-weight:600; }\n.uh-custom-range-note { margin-top:3px; color:var(--dsw-alias-label-secondary); font-size:11px; line-height:1.45; }\n.uh-custom-range-fields { display:grid; grid-template-columns:repeat(2, minmax(136px, 1fr)); gap:8px; }\n.uh-custom-range-field { display:flex; flex-direction:column; gap:4px; color:var(--dsw-alias-label-secondary); font-size:11px; }\n.uh-custom-range-field input { min-width:0; min-height:30px; border:1px solid var(--dsw-alias-border-l2); border-radius:6px; padding:3px 7px; background:var(--dsw-alias-bg-base); color:var(--dsw-alias-label-primary); font:inherit; font-size:12px; outline:none; }\n.uh-custom-range-field input:focus { border-color:var(--dsw-alias-brand-primary); }\n.uh-custom-range-actions { display:flex; gap:6px; }\n.uh-custom-range-cancel, .uh-custom-range-apply { min-height:30px; border-radius:6px; padding:4px 10px; font:inherit; font-size:12px; cursor:pointer; }\n.uh-custom-range-cancel { border:1px solid var(--dsw-alias-border-l2); background:transparent; color:var(--dsw-alias-label-primary); }\n.uh-custom-range-apply { border:1px solid var(--dsw-alias-brand-primary); background:color-mix(in srgb, var(--dsw-alias-brand-primary) 16%, transparent); color:var(--dsw-alias-label-primary); }\n.uh-custom-range-apply:disabled { opacity:.48; cursor:not-allowed; }\n.uh-custom-range-error { grid-column:1 / -1; color:#d92d20; font-size:12px; }\n.uh-refresh { border:1px solid var(--dsw-alias-border-l2); background:var(--dsw-alias-bg-layer-1); color:var(--dsw-alias-label-primary); border-radius:8px; padding:4px 12px; font-size:12px; cursor:pointer; font-family:inherit; transition:border-color .15s ease, color .15s ease, transform .1s ease; }\n.uh-refresh:hover { border-color:var(--dsw-alias-brand-primary); }\n.uh-refresh:active, .uh-chip:active, .uh-range button:active { transform:scale(.96); }\n.uh-alias-panel-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:10px; font-size:13px; font-weight:600; color:var(--dsw-alias-label-primary); }\n.uh-alias-close { border:0; background:transparent; color:var(--dsw-alias-label-secondary); font-size:12px; cursor:pointer; font-family:inherit; padding:0; transition:color .15s ease; }\n.uh-alias-close:hover { color:var(--dsw-alias-brand-primary); }\n.uh-alias-list { display:grid; grid-template-columns:repeat(auto-fill, minmax(250px, 1fr)); gap:8px 16px; max-height:240px; overflow-y:auto; }\n.uh-alias-item { display:flex; align-items:center; gap:8px; min-width:0; }\n.uh-alias-folder { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:11px; color:var(--dsw-alias-label-secondary); }\n.uh-alias-input { flex:none; width:150px; border:1px solid var(--dsw-alias-border-l2); background:var(--dsw-alias-bg-base); color:var(--dsw-alias-label-primary); border-radius:6px; padding:3px 8px; font-size:12px; font-family:inherit; outline:none; transition:border-color .15s ease; }\n.uh-alias-input:focus { border-color:var(--dsw-alias-brand-primary); }\n.uh-alias-panel-foot { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-top:10px; padding-top:10px; border-top:1px solid var(--dsw-alias-border-l1); }\n.uh-alias-ok { border:1px solid var(--dsw-alias-brand-primary); background:color-mix(in srgb, var(--dsw-alias-brand-primary) 16%, transparent); color:var(--dsw-alias-label-primary); border-radius:6px; font-size:12px; padding:3px 12px; cursor:pointer; font-family:inherit; flex:none; transition:transform .1s ease; }\n.uh-alias-ok:active { transform:scale(.96); }\n.uh-anim-panel { animation:uh-panel-in .28s ease both; }\n.uh-pricing-panel { display:flex; flex-direction:column; gap:12px; }\n.uh-pricing-head, .uh-pricing-toolbar, .uh-pricing-foot { display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; }\n.uh-pricing-note { color:var(--dsw-alias-label-secondary); font-size:12px; line-height:1.55; }\n.uh-pricing-toolbar { padding:10px 0; border-top:1px solid var(--dsw-alias-border-l1); border-bottom:1px solid var(--dsw-alias-border-l1); }\n.uh-pricing-switch { display:inline-flex; align-items:center; gap:7px; color:var(--dsw-alias-label-primary); font-size:12px; }\n.uh-pricing-section { display:flex; flex-direction:column; gap:8px; }\n.uh-pricing-table-wrap { max-height:392px; overflow-x:hidden; overflow-y:scroll; scrollbar-gutter:stable; scrollbar-width:auto; scrollbar-color:#707780 #1d1f22; border:1px solid var(--dsw-alias-border-l1); border-radius:8px; background:var(--dsw-alias-bg-layer-2); }\n.uh-pricing-model-table { width:100%; min-width:1080px; border-collapse:collapse; table-layout:fixed; font-size:11px; }\n.uh-pricing-model-table th, .uh-pricing-model-table td { min-width:0; padding:8px 9px; border-bottom:1px solid var(--dsw-alias-border-l1); text-align:left; vertical-align:middle; }\n.uh-pricing-model-table th { position:sticky; top:0; z-index:40; color:var(--dsw-alias-label-secondary); background:var(--dsw-alias-bg-layer-2); font-weight:650; white-space:nowrap; }\n.uh-pricing-model-table th:nth-child(1) { width:24%; }\n.uh-pricing-model-table th:nth-child(2) { width:84px; }\n.uh-pricing-model-table th:nth-child(3) { width:20%; }\n.uh-pricing-model-table th:nth-child(4) { width:96px; }\n.uh-pricing-model-table th:nth-child(n+5) { width:100px; text-align:right; }\n.uh-pricing-model-table td:nth-child(n+5) { text-align:right; }\n.uh-pricing-model-table tbody tr:last-child td { border-bottom:0; }\n.uh-pricing-model-table tbody tr:not(.uh-pricing-tier-row):hover { background:color-mix(in srgb, var(--dsw-alias-bg-layer-1) 65%, transparent); }\n.uh-pricing-model-name, .uh-pricing-model-target { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--dsw-alias-label-primary); }\n.uh-pricing-model-rate { color:var(--dsw-alias-label-secondary); font-variant-numeric:tabular-nums; white-space:nowrap; }\n.uh-pricing-status, .uh-pricing-tier-badge { display:inline-flex; justify-content:center; padding:3px 6px; border-radius:6px; font-size:10px; font-weight:650; white-space:nowrap; }\n.uh-pricing-status-priced { color:#157347; background:color-mix(in srgb, #30d158 22%, transparent); }\n.uh-pricing-status-unpriced, .uh-pricing-status-ambiguous, .uh-pricing-status-unsupported { color:#9a5b00; background:color-mix(in srgb, #ff9f0a 20%, transparent); }\n.uh-pricing-tier-badge { color:var(--dsw-alias-brand-primary); background:color-mix(in srgb, var(--dsw-alias-brand-primary) 15%, transparent); }\n.uh-pricing-tier-badge.uh-flat { color:var(--dsw-alias-label-secondary); background:var(--dsw-alias-bg-layer-1); }\n.uh-pricing-tier-row > td { padding:0 9px 8px; background:color-mix(in srgb, var(--dsw-alias-bg-layer-1) 36%, transparent); }\n.uh-pricing-tier-details > summary { display:inline-flex; align-items:center; gap:6px; min-height:28px; color:var(--dsw-alias-label-secondary); cursor:pointer; list-style:none; font-size:11px; }\n.uh-pricing-tier-details > summary::-webkit-details-marker { display:none; }\n.uh-pricing-tier-caret { transition:transform .15s ease; }\n.uh-pricing-tier-details[open] .uh-pricing-tier-caret { transform:rotate(180deg); }\n.uh-pricing-tier-context { margin-left:6px; color:var(--dsw-alias-label-tertiary, var(--dsw-alias-label-secondary)); }\n.uh-pricing-tier-table { width:100%; margin:2px 0 5px; border:1px solid var(--dsw-alias-border-l1); border-radius:6px; border-collapse:separate; border-spacing:0; overflow:hidden; table-layout:fixed; background:var(--dsw-alias-bg-base); }\n.uh-pricing-tier-table th, .uh-pricing-tier-table td { position:static; width:auto !important; padding:6px 8px; border-bottom:1px solid var(--dsw-alias-border-l1); text-align:right !important; background:transparent; font-size:10px; }\n.uh-pricing-tier-table th:first-child, .uh-pricing-tier-table td:first-child { width:30% !important; text-align:left !important; }\n.uh-pricing-tier-table tbody tr:last-child td { border-bottom:0; }\n.uh-pricing-tier-table tbody tr:hover { background:color-mix(in srgb, var(--dsw-alias-brand-primary) 6%, transparent); }\n.uh-pricing-model-search { position:relative; z-index:2; min-width:0; display:flex; align-items:center; gap:6px; }\n.uh-pricing-model-search .uh-pricing-model-search-input { flex:1 1 auto; width:auto; }\n.uh-pricing-clear-mapping { flex:none; white-space:nowrap; }\n.uh-pricing-model-search:focus-within { z-index:30; }\n.uh-pricing-model-search-input { box-sizing:border-box; width:100%; min-width:0; min-height:30px; border:1px solid var(--dsw-alias-border-l2); border-radius:6px; padding:4px 7px; background:var(--dsw-alias-bg-base); color:var(--dsw-alias-label-primary); font:inherit; font-size:11px; outline:none; }\n.uh-pricing-model-search-input:focus { border-color:var(--dsw-alias-brand-primary); }\n.uh-pricing-model-options { top:calc(100% + 7px); left:0; right:auto; width:100%; min-width:280px; max-height:240px; overflow-y:auto; z-index:40; }\n.uh-pricing-model-option { align-items:flex-start; }\n.uh-pricing-model-option-name { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }\n.uh-pricing-model-option-id { margin-left:auto; padding-left:10px; color:var(--dsw-alias-label-secondary); font-size:10px; white-space:nowrap; }\n.uh-pricing-edit-row { display:grid; grid-template-columns:minmax(240px,1.2fr) minmax(260px,1.3fr) minmax(78px,.45fr) 32px; gap:10px; align-items:center; min-width:650px; }\n.uh-pricing-price-row { grid-template-columns:repeat(5,minmax(108px,1fr)) 32px; min-width:650px; }\n.uh-pricing-price-head { display:grid; grid-template-columns:repeat(5,minmax(108px,1fr)) 32px; gap:10px; align-items:center; min-width:650px; color:var(--dsw-alias-label-secondary); font-size:10px; }\n.uh-pricing-price-head span { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }\n.uh-pricing-edit-row input, .uh-pricing-tier-edit-row input { box-sizing:border-box; min-width:0; min-height:30px; border:1px solid var(--dsw-alias-border-l2); border-radius:6px; padding:4px 7px; background:var(--dsw-alias-bg-base); color:var(--dsw-alias-label-primary); font:inherit; font-size:11px; outline:none; }\n.uh-pricing-edit-row input:focus, .uh-pricing-tier-edit-row input:focus { border-color:var(--dsw-alias-brand-primary); }\n.uh-pricing-edit-row .uh-refresh, .uh-pricing-tier-edit-row .uh-refresh { min-height:30px; padding:0; }\n.uh-pricing-overrides { display:flex; flex-direction:column; min-width:760px; }\n.uh-pricing-override { display:flex; flex-direction:column; gap:8px; padding:10px 0; border-bottom:1px solid var(--dsw-alias-border-l1); }\n.uh-pricing-override:last-child { border-bottom:0; }\n.uh-pricing-tier-editor { margin-left:10px; padding-left:12px; border-left:2px solid color-mix(in srgb, var(--dsw-alias-brand-primary) 34%, var(--dsw-alias-border-l1)); }\n.uh-pricing-tier-editor-head { display:flex; align-items:center; justify-content:space-between; gap:10px; min-height:30px; }\n.uh-pricing-tier-editor-title { display:flex; align-items:baseline; gap:8px; min-width:0; }\n.uh-pricing-tier-editor-title strong { font-size:11px; }\n.uh-pricing-tier-editor-title span { color:var(--dsw-alias-label-secondary); font-size:10px; }\n.uh-pricing-tier-edit-head, .uh-pricing-tier-edit-row { display:grid; grid-template-columns:minmax(120px,.85fr) repeat(4,minmax(72px,1fr)) 30px; gap:10px; align-items:center; min-width:0; }\n.uh-pricing-tier-edit-head { margin:5px 0; color:var(--dsw-alias-label-secondary); font-size:10px; }\n.uh-pricing-tier-edit-row { margin-top:7px; }\n.uh-pricing-tier-edit-row.uh-invalid input { border-color:var(--dsw-alias-warning, #a55b00); }\n.uh-pricing-tier-empty { padding:5px 0; color:var(--dsw-alias-label-secondary); font-size:10px; }\n.uh-pricing-error { color:var(--dsw-alias-warning, #a55b00); font-size:12px; line-height:1.45; }\n.uh-pricing-foot { padding-top:4px; }\n\n.uh-pricing-table-note { color:var(--dsw-alias-label-secondary); font-size:11px; line-height:1.5; }\n.uh-pricing-price-table { width:100%; min-width:0; }\n.uh-pricing-price-table th:nth-child(1) { width:20%; }\n.uh-pricing-price-table th:nth-child(2) { width:24%; }\n.uh-pricing-price-table th:nth-child(3), .uh-pricing-price-table th:nth-child(4), .uh-pricing-price-table th:nth-child(5), .uh-pricing-price-table th:nth-child(6) { width:11%; }\n.uh-pricing-price-table th:nth-child(7) { width:12%; }\n.uh-pricing-table-wrap .uh-pricing-price-table th, .uh-pricing-table-wrap .uh-pricing-price-table td { text-align:left; }\n.uh-pricing-price-table th, .uh-pricing-price-table td { padding:8px 8px; }\n.uh-pricing-price-table td { vertical-align:top; }\n.uh-pricing-row-flags { display:flex; align-items:center; flex-wrap:wrap; gap:4px; margin-top:5px; }\n.uh-pricing-flag { padding:2px 6px; border-radius:999px; background:var(--dsw-alias-bg-layer-1); color:var(--dsw-alias-label-secondary); font-size:10px; white-space:nowrap; }\n.uh-pricing-configured-row { background:color-mix(in srgb, var(--dsw-alias-bg-layer-1) 42%, transparent); }\n/* Unknown usage (the host did not label the row) is not the same verdict as\n "no ledger usage", so it must not read like one. */\n.uh-pricing-unknown-row { background:color-mix(in srgb, var(--dsw-alias-bg-layer-1) 24%, transparent); }\n.uh-pricing-flag-unknown { border-style:dashed; opacity:.75; }\n.uh-pricing-rate-input { box-sizing:border-box; width:100%; min-width:0; min-height:30px; border:1px solid var(--dsw-alias-border-l2); border-radius:6px; padding:4px 7px; background:var(--dsw-alias-bg-base); color:var(--dsw-alias-label-primary); font:inherit; font-size:11px; font-variant-numeric:tabular-nums; outline:none; }\n.uh-pricing-rate-input:focus { border-color:var(--dsw-alias-brand-primary); }\n.uh-pricing-map-cell { display:flex; flex-direction:column; gap:6px; }\n.uh-pricing-map-sub { display:flex; align-items:center; flex-wrap:wrap; gap:8px; }\n.uh-pricing-map-field { display:inline-flex; align-items:center; gap:5px; color:var(--dsw-alias-label-secondary); font-size:10px; }\n.uh-pricing-map-field input, .uh-pricing-map-field select { box-sizing:border-box; min-height:26px; border:1px solid var(--dsw-alias-border-l2); border-radius:6px; padding:2px 6px; background:var(--dsw-alias-bg-base); color:var(--dsw-alias-label-primary); font:inherit; font-size:11px; outline:none; }\n.uh-pricing-map-field input { width:70px; }\n.uh-pricing-link { border:0; background:transparent; color:var(--dsw-alias-brand-primary); font:inherit; font-size:11px; cursor:pointer; padding:2px 0; text-decoration:underline; }\n.uh-pricing-link:disabled { color:var(--dsw-alias-label-secondary); cursor:default; text-decoration:none; }\n.uh-pricing-chip { min-height:28px; padding:3px 9px; border:1px solid var(--dsw-alias-border-l2); border-radius:999px; background:var(--dsw-alias-bg-base); color:var(--dsw-alias-label-secondary); font:inherit; font-size:10px; cursor:pointer; white-space:nowrap; }\n.uh-pricing-chip.uh-on, .uh-pricing-chip.uh-strong { border-color:var(--dsw-alias-brand-primary); color:var(--dsw-alias-label-primary); background:color-mix(in srgb, var(--dsw-alias-brand-primary) 12%, transparent); }\n.uh-pricing-row-actions { display:flex; align-items:center; flex-wrap:wrap; gap:5px; white-space:nowrap; }\n.uh-pricing-editor-row > td { padding:0 9px 10px; background:color-mix(in srgb, var(--dsw-alias-bg-layer-1) 36%, transparent); }\n.uh-pricing-editor { display:flex; flex-direction:column; gap:10px; min-width:0; overflow-x:auto; }\n.uh-pricing-editor-foot { display:flex; justify-content:flex-end; }\n.uh-pricing-temporal-fields { display:flex; align-items:flex-end; flex-wrap:wrap; gap:10px; margin-top:6px; }\n.uh-pricing-temporal-fields label { display:inline-flex; flex-direction:column; gap:4px; color:var(--dsw-alias-label-secondary); font-size:10px; }\n.uh-pricing-temporal-fields input { box-sizing:border-box; min-height:28px; border:1px solid var(--dsw-alias-border-l2); border-radius:6px; padding:3px 7px; background:var(--dsw-alias-bg-base); color:var(--dsw-alias-label-primary); font:inherit; font-size:11px; outline:none; }\n.uh-pricing-temporal-fields input:focus { border-color:var(--dsw-alias-brand-primary); }\n.uh-pricing-temporal-rule { margin-top:8px; padding:8px 10px; border:1px solid var(--dsw-alias-border-l1); border-radius:8px; background:var(--dsw-alias-bg-base); }\n.uh-pricing-temporal-rule-head { display:flex; align-items:center; flex-wrap:wrap; gap:8px; }\n.uh-pricing-temporal-rule-name { color:var(--dsw-alias-label-secondary); font-size:10px; font-variant-numeric:tabular-nums; }\n.uh-pricing-weekdays { display:inline-flex; gap:3px; }\n.uh-pricing-weekday { width:26px; height:26px; border:1px solid var(--dsw-alias-border-l2); border-radius:6px; background:var(--dsw-alias-bg-base); color:var(--dsw-alias-label-secondary); font:inherit; font-size:10px; cursor:pointer; }\n.uh-pricing-weekday.uh-on { border-color:var(--dsw-alias-brand-primary); color:var(--dsw-alias-label-primary); background:color-mix(in srgb, var(--dsw-alias-brand-primary) 14%, transparent); }\n.uh-pricing-temporal-windows { display:flex; align-items:center; flex-wrap:wrap; gap:7px; margin-top:7px; }\n.uh-pricing-temporal-window { display:inline-flex; align-items:center; gap:5px; }\n.uh-pricing-time-input { box-sizing:border-box; width:66px; min-height:28px; border:1px solid var(--dsw-alias-border-l2); border-radius:6px; padding:3px 6px; background:var(--dsw-alias-bg-base); color:var(--dsw-alias-label-primary); font:inherit; font-size:11px; font-variant-numeric:tabular-nums; text-align:center; outline:none; }\n.uh-pricing-time-input:focus { border-color:var(--dsw-alias-brand-primary); }\n.uh-pricing-time-sep { color:var(--dsw-alias-label-secondary); }\n.uh-pricing-temporal-rates { display:flex; flex-wrap:wrap; gap:9px; margin-top:8px; }\n.uh-pricing-temporal-rate { display:inline-flex; align-items:center; gap:5px; color:var(--dsw-alias-label-secondary); font-size:10px; }\n.uh-pricing-temporal-rate input { box-sizing:border-box; width:86px; min-height:28px; border:1px solid var(--dsw-alias-border-l2); border-radius:6px; padding:3px 7px; background:var(--dsw-alias-bg-base); color:var(--dsw-alias-label-primary); font:inherit; font-size:11px; font-variant-numeric:tabular-nums; outline:none; }\n.uh-pricing-temporal-foot { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-top:8px; }\n.uh-pricing-temporal-holidays { display:flex; flex-direction:column; gap:6px; margin-top:8px; padding:8px 10px; border:1px solid var(--dsw-alias-border-l1); border-radius:8px; background:var(--dsw-alias-bg-base); }\n.uh-pricing-holiday-load { display:flex; align-items:center; flex-wrap:wrap; gap:8px; }\n.uh-pricing-holiday-load input[type=\'number\'] { box-sizing:border-box; width:82px; min-height:28px; border:1px solid var(--dsw-alias-border-l2); border-radius:6px; padding:3px 7px; background:var(--dsw-alias-bg-base); color:var(--dsw-alias-label-primary); font:inherit; font-size:11px; outline:none; }\n.uh-pricing-holiday-input { box-sizing:border-box; width:100%; min-height:74px; resize:vertical; border:1px solid var(--dsw-alias-border-l2); border-radius:6px; padding:6px 8px; background:var(--dsw-alias-bg-base); color:var(--dsw-alias-label-primary); font:inherit; font-size:11px; font-variant-numeric:tabular-nums; outline:none; }\n.uh-pricing-holiday-input:focus { border-color:var(--dsw-alias-brand-primary); }\n.uh-pricing-warning { margin-top:7px; padding:7px 9px; border-radius:7px; border:1px solid color-mix(in srgb, var(--dsw-alias-warning, #d9822b) 40%, var(--dsw-alias-border-l1)); color:var(--dsw-alias-warning, #a55b00); font-size:11px; line-height:1.45; }\n@media (max-width:640px) {\n .uh-pricing-table-wrap { overflow-x:auto; }\n .uh-pricing-price-table { min-width:820px; }\n .uh-pricing-map-cell { min-width:170px; }\n}\n\n.uh-cost-num { color:var(--dsw-alias-label-primary); }\n.uh-progress { font-size:12px; color:var(--dsw-alias-label-secondary); display:flex; align-items:center; gap:10px; }\n.uh-sync-health { margin-top:8px; padding:8px 12px; display:flex; align-items:center; flex-wrap:wrap; gap:6px; border:1px solid var(--dsw-alias-border-l1); border-radius:10px; color:var(--dsw-alias-label-secondary); background:var(--dsw-alias-bg-layer-1); font-size:11px; line-height:1.45; }\n.uh-sync-health.uh-stale { color:var(--dsw-alias-warning, #a55b00); border-color:color-mix(in srgb, var(--dsw-alias-warning, #d9822b) 45%, var(--dsw-alias-border-l1)); }\n.uh-sync-retry { border:0; background:transparent; color:inherit; font:inherit; text-decoration:underline; cursor:pointer; padding:0 2px; }\n.uh-trend-panel { min-height:300px; animation:uh-panel-in .38s ease both; }\n.uh-trend-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; margin-bottom:10px; }\n.uh-trend-chart-wrap { position:relative; min-height:250px; width:100%; overflow:hidden; }\n.uh-trend-stage { display:grid; place-items:center; min-height:250px; width:100%; }\n.uh-trend-message { color:var(--dsw-alias-label-secondary); font-size:12px; }\n.uh-trend-spinner { width:24px; height:24px; border:2px solid color-mix(in srgb, var(--dsw-alias-brand-primary) 22%, var(--dsw-alias-border-l2)); border-top-color:var(--dsw-alias-brand-primary); border-radius:50%; animation:uh-spinner-turn .78s linear infinite; }\n.uh-trend-svg { display:block; width:100%; height:auto; min-height:220px; }\n.uh-trend-grid { stroke:var(--dsw-alias-border-l1); stroke-width:1; stroke-dasharray:3 4; opacity:.8; }\n.uh-trend-cursor { stroke:var(--dsw-alias-label-secondary); stroke-width:1; stroke-dasharray:3 4; opacity:.65; pointer-events:none; }\n.uh-trend-point { stroke:var(--dsw-alias-bg-layer-1); stroke-width:2; vector-effect:non-scaling-stroke; pointer-events:none; }\n.uh-trend-axis-label { fill:var(--dsw-alias-label-secondary); font-size:11px; font-family:inherit; }\n.uh-trend-line { fill:none; stroke-width:2.2; vector-effect:non-scaling-stroke; stroke-linecap:round; stroke-linejoin:round; opacity:.22; }\n.uh-trend-line-draw { fill:none; stroke-width:2.2; vector-effect:non-scaling-stroke; stroke-linecap:round; stroke-linejoin:round; stroke-dasharray:var(--uh-draw-length); stroke-dashoffset:var(--uh-draw-length); opacity:.96; pointer-events:none; animation:uh-trend-draw .95s cubic-bezier(.22,.61,.36,1) both; }\n.uh-trend-area { opacity:1; animation:uh-trend-fill .8s ease; }\n.uh-trend-hit { fill:transparent; cursor:crosshair; outline:none; }\n.uh-trend-hit:focus { fill:color-mix(in srgb, var(--dsw-alias-brand-primary) 10%, transparent); outline:1px solid var(--dsw-alias-brand-primary); outline-offset:2px; }\n.uh-trend-tooltip { position:absolute; z-index:4; min-width:166px; padding:10px 11px; border:1px solid color-mix(in srgb, var(--dsw-alias-border-l2) 88%, transparent); border-radius:8px; background:color-mix(in srgb, var(--dsw-alias-bg-layer-1) 94%, transparent); box-shadow:0 10px 24px rgba(0,0,0,.22); backdrop-filter:blur(10px); color:var(--dsw-alias-label-primary); font-size:12px; line-height:1.45; pointer-events:none; opacity:0; visibility:hidden; transform:translate(14px,-50%) scale(.985); transform-origin:left center; transition:left .16s cubic-bezier(.22,.61,.36,1), top .16s cubic-bezier(.22,.61,.36,1), opacity .12s ease, transform .16s cubic-bezier(.22,.61,.36,1), visibility 0s linear .16s; }\n.uh-trend-tooltip.uh-left { transform:translate(calc(-100% - 14px),-50%) scale(.985); transform-origin:right center; }\n.uh-trend-tooltip.uh-visible { opacity:1; visibility:visible; transform:translate(14px,-50%) scale(1); transition-delay:0s; }\n.uh-trend-tooltip.uh-left.uh-visible { transform:translate(calc(-100% - 14px),-50%) scale(1); }\n.uh-trend-tooltip-title { display:block; margin-bottom:6px; color:var(--dsw-alias-label-primary); font-size:12px; font-weight:650; }\n.uh-trend-tooltip-row { display:grid; grid-template-columns:8px minmax(0,1fr) auto; align-items:center; gap:7px; min-width:0; margin-top:3px; font-size:11px; }\n.uh-trend-tooltip-row .uh-trend-dot { width:8px; height:8px; margin:0; }\n.uh-trend-tooltip-label { overflow:hidden; font-weight:600; text-overflow:ellipsis; white-space:nowrap; }\n.uh-trend-tooltip-value { color:inherit; font-weight:600; font-variant-numeric:tabular-nums; white-space:nowrap; }\n.uh-trend-dot { display:inline-block; width:7px; height:7px; margin-right:5px; border-radius:50%; vertical-align:1px; }\n.uh-trend-legend { display:flex; flex-wrap:wrap; gap:5px 8px; margin-top:5px; }\n.uh-trend-legend-item { display:inline-flex; align-items:center; gap:3px; border:0; border-radius:7px; padding:3px 6px; background:transparent; color:var(--dsw-alias-label-secondary); font:inherit; font-size:11px; cursor:pointer; transition:color .15s ease; }\n.uh-trend-legend-item:hover { background:var(--dsw-alias-bg-layer-2); color:var(--dsw-alias-label-primary); }\n.uh-trend-legend-item.uh-on { background:var(--dsw-alias-interactive-bg-hover); color:var(--dsw-alias-label-primary); }\n.uh-filter-bar { position:relative; z-index:10; display:flex; align-items:center; flex-wrap:wrap; gap:7px; }\n.uh-filter-clear { border:0; background:transparent; color:var(--dsw-alias-label-secondary); font:inherit; font-size:11px; cursor:pointer; text-decoration:underline; }\n.uh-query-note { color:var(--dsw-alias-label-secondary); font-size:11px; }\n.uh-detail-tabs { display:flex; align-items:center; flex-wrap:wrap; gap:4px; padding:4px; border:1px solid var(--dsw-alias-border-l1); border-radius:9px; background:color-mix(in srgb, var(--dsw-alias-bg-layer-2) 58%, transparent); }\n.uh-detail-tab { display:inline-flex; align-items:center; gap:6px; min-height:32px; padding:5px 11px; border:0; border-radius:7px; background:transparent; color:var(--dsw-alias-label-secondary); font:inherit; font-size:12px; cursor:pointer; transition:background-color .15s ease, color .15s ease, transform .12s ease; }\n.uh-detail-tab:hover { color:var(--dsw-alias-label-primary); background:var(--dsw-alias-bg-layer-2); }\n.uh-detail-tab.uh-on { color:var(--dsw-alias-label-primary); background:var(--dsw-alias-bg-layer-1); box-shadow:0 1px 3px rgba(0,0,0,.14); }\n.uh-records-panel { animation:uh-panel-in .28s ease both; }\n.uh-records-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; margin-bottom:7px; }\n.uh-records-note { margin:8px 0 10px; color:var(--dsw-alias-label-secondary); font-size:11px; line-height:1.45; }\n.uh-records-error { margin:7px 0; color:var(--dsw-alias-warning, #a55b00); font-size:11px; }\n/* The log scrolls inside its own box (and pulls the next page as it nears the end),\n so a long history never pushes the rest of the panel off the screen. */\n.uh-records-scroll { max-height:min(62vh, 560px); overflow:auto; overscroll-behavior:contain; border:1px solid var(--dsw-alias-border-l1); border-radius:8px; }\n.uh-record-grid { display:grid; grid-template-columns:112px minmax(190px,1.45fr) 78px repeat(4,minmax(76px,.72fr)) 96px 82px; gap:0; min-width:900px; align-items:center; }\n.uh-record-grid > div { min-width:0; padding:8px 7px; border-bottom:1px solid var(--dsw-alias-border-l1); font-size:11px; }\n.uh-record-header { color:var(--dsw-alias-label-secondary); background:var(--dsw-alias-bg-layer-2); font-weight:600; }\n.uh-record-header > div { white-space:nowrap; }\n.uh-record-row { color:var(--dsw-alias-label-primary); cursor:pointer; outline:none; transition:background-color .14s ease, box-shadow .14s ease; }\n.uh-record-row:hover { background:color-mix(in srgb, var(--dsw-alias-bg-layer-2) 68%, transparent); }\n.uh-record-row.uh-on { background:color-mix(in srgb, var(--dsw-alias-brand-primary) 10%, var(--dsw-alias-bg-layer-1)); box-shadow:inset 3px 0 var(--dsw-alias-brand-primary); }\n.uh-record-row:focus-visible { box-shadow:inset 0 0 0 1px var(--dsw-alias-brand-primary); }\n.uh-record-row:last-child > div { border-bottom:0; }\n.uh-record-time, .uh-record-num { color:var(--dsw-alias-label-secondary); font-variant-numeric:tabular-nums; white-space:nowrap; }\n.uh-record-num { text-align:right; }\n.uh-model-icon { display:inline-flex; align-items:center; justify-content:center; flex:none; vertical-align:middle; }\n.uh-model-icon img { display:block; width:100%; height:100%; object-fit:contain; }\n.uh-model-icon-fallback { color:var(--dsw-alias-label-tertiary, var(--dsw-alias-label-secondary)); opacity:.85; }\n.uh-model-label { display:flex; align-items:center; gap:7px; min-width:0; }\n.uh-model-label .uh-model-text { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0; }\n.uh-record-model { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-weight:550; }\n.uh-record-model small { display:block; overflow:hidden; color:var(--dsw-alias-label-secondary); font-size:10px; font-weight:400; text-overflow:ellipsis; white-space:nowrap; }\n.uh-record-source { color:var(--dsw-alias-label-secondary); white-space:nowrap; }\n.uh-record-band { white-space:nowrap; }\n.uh-record-band-badge { margin-left:6px; color:var(--dsw-alias-label-secondary); font-size:10px; }\n.uh-record-band-peak { color:var(--dsw-alias-warning, #a55b00); font-weight:600; }\n.uh-record-band-off-peak { color:#2e7d32; }\n.uh-records-footer { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-top:9px; }\n.uh-record-detail { margin-top:12px; padding:10px 11px; border-top:1px solid var(--dsw-alias-border-l2); background:color-mix(in srgb, var(--dsw-alias-bg-layer-2) 42%, transparent); animation:uh-detail-in .24s ease both; }\n.uh-record-detail-head, .uh-record-detail-meta { display:flex; align-items:center; flex-wrap:wrap; gap:7px 14px; }\n.uh-record-detail-head { justify-content:space-between; margin-bottom:5px; color:var(--dsw-alias-label-primary); font-size:12px; }\n.uh-record-detail-meta { color:var(--dsw-alias-label-secondary); font-size:11px; }\n.uh-record-token-strip { display:grid; grid-template-columns:repeat(5,minmax(72px,1fr)) repeat(2,minmax(82px,1.1fr)); gap:6px; margin-top:9px; }\n.uh-record-token-strip > div { display:flex; flex-direction:column; gap:2px; min-width:0; padding:6px 7px; border-radius:6px; background:var(--dsw-alias-bg-layer-2); }\n.uh-record-token-strip span { color:var(--dsw-alias-label-secondary); font-size:10px; }\n.uh-record-token-strip strong { color:var(--dsw-alias-label-primary); font-size:12px; font-variant-numeric:tabular-nums; }\n.uh-record-token-total { border:1px solid color-mix(in srgb, var(--dsw-alias-brand-primary) 38%, var(--dsw-alias-border-l1)) !important; }\n@keyframes uh-detail-in { from { opacity:0; transform:translateY(-4px); } to { opacity:1; transform:translateY(0); } }\n@media (max-width:640px) {\n .uh-trend-head { flex-direction:column; }\n .uh-filter-menu { flex:1 1 130px; width:auto; }\n .uh-filter-trigger { max-width:100%; }\n .uh-trend-tooltip { min-width:116px; }\n .uh-records-head { flex-direction:column; }\n .uh-record-token-strip { grid-template-columns:repeat(2,minmax(0,1fr)); }\n .uh-record-token-total { grid-column:1 / -1; }\n .uh-pricing-head { align-items:flex-start; }\n .uh-pricing-toolbar { align-items:flex-start; }\n .uh-pricing-edit-row { grid-template-columns:minmax(0,1fr) 36px; min-width:0; width:100%; }\n .uh-pricing-edit-row > .uh-pricing-model-search,\n .uh-pricing-price-row > input { grid-column:1 / -1; }\n .uh-pricing-edit-row > input[type=\'number\'] { grid-column:1; }\n .uh-pricing-edit-row > .uh-icon-button { grid-column:2; }\n .uh-pricing-price-head { display:none; }\n .uh-pricing-overrides { min-width:0; width:100%; }\n .uh-pricing-override { min-width:0; }\n .uh-pricing-price-row { grid-template-columns:minmax(0,1fr) 36px; min-width:0; }\n .uh-pricing-price-row > input[type=\'number\'] { grid-column:1 / -1; }\n .uh-pricing-tier-editor { margin-left:0; padding-left:0; border-left:0; }\n .uh-pricing-tier-editor-head { align-items:flex-start; flex-wrap:wrap; }\n .uh-pricing-tier-editor-title { flex-direction:column; gap:2px; }\n .uh-pricing-tier-edit-head { display:none; }\n .uh-pricing-tier-edit-row { grid-template-columns:minmax(0,1fr) 36px; min-width:0; padding:8px; border:1px solid var(--dsw-alias-border-l1); border-radius:6px; }\n .uh-pricing-tier-edit-row > input { grid-column:1 / -1; }\n .uh-pricing-tier-edit-row > .uh-icon-button { grid-column:2; }\n .uh-pricing-tier-context { display:block; margin:2px 0 0; }\n}\n.uh-bar { flex:1; height:6px; border-radius:3px; background:var(--dsw-alias-bg-layer-2); overflow:hidden; max-width:340px; }\n.uh-fill { height:100%; background:var(--dsw-alias-brand-primary); border-radius:3px; transition:width .3s ease; }\n.uh-cards { display:grid; grid-template-columns:repeat(auto-fit, minmax(200px, 1fr)); gap:10px; }\n.uh-card { background:var(--dsw-alias-bg-layer-1); border:1px solid var(--dsw-alias-border-l1); border-radius:12px; padding:12px 14px; display:flex; flex-direction:column; gap:6px; min-height:86px; animation:uh-card-in .45s ease both; transition:transform .18s ease, border-color .18s ease, box-shadow .18s ease; }\n.uh-card:hover { transform:translateY(-2px); border-color:var(--dsw-alias-border-l2); box-shadow:0 6px 18px rgba(0,0,0,.10); }\n.uh-card-label { font-size:12px; color:var(--dsw-alias-label-secondary); }\n.uh-card-value { font-size:20px; font-weight:650; color:var(--dsw-alias-label-primary); line-height:1.2; }\n.uh-card-sub { font-size:11px; color:var(--dsw-alias-label-secondary); line-height:1.55; }\n.uh-wsbars { display:flex; flex-direction:column; gap:3px; margin-top:2px; }\n.uh-wsbar { display:flex; flex-direction:column; gap:1px; cursor:pointer; padding:1px 6px; margin:0 -6px; border-radius:8px; transition:background-color .15s ease; }\n.uh-wsbar:hover { background:var(--dsw-alias-bg-layer-2); }\n.uh-wsbar.uh-sel { outline:1px solid var(--dsw-alias-brand-primary); }\n.uh-wsbar-top { display:flex; align-items:center; gap:6px; min-width:0; }\n.uh-wsbar-title { font-size:12px; color:var(--dsw-alias-label-primary); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; flex:1; min-width:0; }\n.uh-wsbar-num { font-size:11px; font-variant-numeric:tabular-nums; color:var(--dsw-alias-label-secondary); flex:none; }\n.uh-panel { background:var(--dsw-alias-bg-layer-1); border:1px solid var(--dsw-alias-border-l1); border-radius:12px; padding:14px; }\n.uh-hm-head { display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; margin-bottom:10px; }\n.uh-chips { display:flex; flex-wrap:wrap; gap:6px; }\n.uh-hm-tools { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }\n.uh-heatmap-spans button { white-space:nowrap; }\n.uh-chip { display:inline-flex; align-items:center; gap:6px; border:1px solid var(--dsw-alias-border-l2); background:transparent; color:var(--dsw-alias-label-primary); border-radius:999px; padding:2px 10px; font-size:11px; cursor:pointer; font-family:inherit; max-width:190px; transition:border-color .15s ease, background-color .15s ease, color .15s ease, transform .1s ease; }\n.uh-chip .uh-chip-title { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }\n.uh-chip.uh-on { border-color:var(--dsw-alias-brand-primary); background:color-mix(in srgb, var(--dsw-alias-brand-primary) 14%, transparent); }\n.uh-dot { width:8px; height:8px; border-radius:50%; flex:none; }\n.uh-legend { display:flex; align-items:center; gap:4px; font-size:11px; color:var(--dsw-alias-label-secondary); }\n.uh-legend .uh-cell { width:10px; height:10px; border-radius:2px; animation:none; }\n.uh-hm-scroll { overflow-x:auto; padding-bottom:2px; }\n.uh-months { position:relative; height:16px; margin-left:30px; width:calc(100% - 30px); min-width:686px; font-size:10px; color:var(--dsw-alias-label-secondary); }\n.uh-months span { position:absolute; top:0; }\n.uh-hm-body { display:flex; gap:6px; min-width:0; }\n.uh-wdays { display:grid; grid-template-rows:repeat(7,10px); gap:3px; font-size:10px; color:var(--dsw-alias-label-secondary); text-align:right; width:24px; }\n.uh-wdays span { line-height:10px; }\n.uh-grid { flex:1 1 auto; min-width:686px; display:grid; grid-auto-flow:column; grid-template-columns:repeat(53,minmax(10px,1fr)); grid-template-rows:repeat(7,minmax(10px,auto)); gap:3px; }\n.uh-cell { width:100%; height:auto; min-width:10px; aspect-ratio:1; border-radius:2px; background:var(--dsw-alias-bg-layer-2); animation:uh-cell-in .45s ease both; transition:transform .12s ease, box-shadow .12s ease; }\n.uh-cell:hover { transform:scale(1.35); box-shadow:0 1px 6px rgba(0,0,0,.28); position:relative; z-index:2; }\n.uh-tip { position:fixed; z-index:1200; background:var(--dsw-alias-bg-overlay); border:1px solid var(--dsw-alias-border-l2); border-radius:10px; padding:10px 12px; box-shadow:0 8px 24px rgba(0,0,0,.18); pointer-events:auto; min-width:200px; max-width:290px; animation:uh-tip-in .16s ease both; }\n.uh-tip-date { font-size:12px; font-weight:600; color:var(--dsw-alias-label-primary); margin-bottom:6px; }\n.uh-tip-row { display:flex; align-items:center; gap:6px; font-size:12px; color:var(--dsw-alias-label-primary); padding:3px 6px; margin:0 -6px; border-radius:6px; cursor:pointer; transition:background-color .12s ease; }\n.uh-tip-row:hover { background:color-mix(in srgb, var(--dsw-alias-brand-primary) 12%, transparent); }\n.uh-tip-row .uh-n { margin-left:auto; font-variant-numeric:tabular-nums; color:var(--dsw-alias-label-secondary); }\n.uh-tip-tokens { font-size:11px; color:var(--dsw-alias-label-secondary); margin-top:6px; border-top:1px solid var(--dsw-alias-border-l1); padding-top:6px; }\n.uh-tbl-title { font-size:13px; font-weight:600; color:var(--dsw-alias-label-primary); margin:0 0 10px; }\n.uh-tbl-scroll { overflow-x:auto; }\n.uh-hrow, .uh-row { display:grid; grid-template-columns:minmax(160px,2.2fr) .7fr .9fr .9fr .9fr .9fr 1.1fr .9fr .8fr 1fr; gap:8px; align-items:center; min-width:900px; padding:7px 10px; border-radius:8px; font-size:12px; }\n.uh-model-hrow, .uh-model-row { display:grid; grid-template-columns:minmax(190px,2.2fr) .7fr .9fr .9fr .9fr .9fr 1.1fr .9fr .8fr; gap:8px; align-items:center; min-width:860px; padding:7px 10px; border-radius:8px; font-size:12px; }\n.uh-hrow { color:var(--dsw-alias-label-secondary); font-size:11px; }\n.uh-row { cursor:pointer; border:1px solid transparent; transition:background-color .15s ease, border-color .15s ease; }\n.uh-row:hover { background:var(--dsw-alias-bg-layer-2); }\n.uh-row.uh-sel { border-color:var(--dsw-alias-brand-primary); }\n.uh-num { text-align:right; font-variant-numeric:tabular-nums; color:var(--dsw-alias-label-primary); }\n.uh-hrow .uh-num { color:var(--dsw-alias-label-secondary); }\n.uh-ws-title { color:var(--dsw-alias-label-primary); font-weight:550; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }\n.uh-row-title-wrap { min-width:0; }\n.uh-ws-path { color:var(--dsw-alias-label-secondary); font-size:11px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }\n.uh-barwrap { height:5px; border-radius:3px; background:var(--dsw-alias-bg-layer-2); overflow:hidden; margin-top:3px; }\n.uh-barwrap.uh-bar-thin { height:3px; margin-top:1px; }\n.uh-barfill { height:100%; border-radius:3px; transform-origin:left center; animation:uh-bar-grow .7s cubic-bezier(.22,.61,.36,1) both; transition:width .5s cubic-bezier(.22,.61,.36,1); }\n.uh-empty { color:var(--dsw-alias-label-secondary); font-size:12px; text-align:center; padding:26px 0; }\n.uh-note { font-size:11px; color:var(--dsw-alias-label-secondary); line-height:1.6; }\n.uh-side-entry { width:100%; border:0; background:transparent; color:var(--dsw-alias-label-secondary); border-radius:8px; min-height:36px; padding:7px 10px; display:flex; align-items:center; gap:9px; font:inherit; font-size:13px; cursor:pointer; text-align:left; }\n.uh-side-entry:hover { background:var(--dsw-alias-interactive-bg-hover); color:var(--dsw-alias-label-primary); }\n.uh-side-entry-icon { width:18px; text-align:center; flex:none; font-size:15px; }\n.uh-side-entry-label { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }\n.uh-boundary-fallback { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:12px; min-height:360px; padding:24px; border:1px solid var(--dsw-alias-border-l1); border-radius:12px; background:var(--dsw-alias-bg-layer-1); text-align:center; }\n.uh-boundary-title { color:var(--dsw-alias-label-primary); font-size:15px; font-weight:650; }\n.uh-boundary-note { max-width:420px; color:var(--dsw-alias-label-secondary); font-size:12px; line-height:1.6; }\n.uh-side-modal { position:fixed; inset:var(--uh-top-inset, 0px) 0 0 0; z-index:1100; background:color-mix(in srgb, #000 44%, transparent); display:flex; align-items:stretch; justify-content:center; padding:26px; }\n.uh-side-dialog { width:min(1120px, 100%); overflow-x:hidden; overflow-y:scroll; scrollbar-gutter:stable; scrollbar-width:auto; scrollbar-color:#707780 #1d1f22; background:var(--dsw-alias-bg-base); border:1px solid var(--dsw-alias-border-l2); border-radius:14px; box-shadow:0 18px 52px rgba(0,0,0,.35); padding:18px; }\n.uh-side-dialog::-webkit-scrollbar, .uh-pricing-table-wrap::-webkit-scrollbar { width:12px; height:12px; }\n.uh-side-dialog::-webkit-scrollbar-track, .uh-pricing-table-wrap::-webkit-scrollbar-track { background:#1d1f22; border-left:1px solid #363a40; }\n.uh-side-dialog::-webkit-scrollbar-thumb, .uh-pricing-table-wrap::-webkit-scrollbar-thumb { background:#707780; border:3px solid #1d1f22; border-radius:6px; }\n.uh-side-dialog::-webkit-scrollbar-thumb:hover, .uh-pricing-table-wrap::-webkit-scrollbar-thumb:hover { background:#9aa1aa; }\n.uh-side-dialog-head { display:flex; justify-content:flex-end; margin-bottom:8px; }\n@media (max-width: 640px) { .uh-side-modal { padding:0; } .uh-side-dialog { border-radius:0; border:0; padding:14px; } }\n/* iOS-style dashboard: grouped surfaces, tactile controls, and an elevated sheet. */\n.uh-page { gap:18px; max-width:1160px; margin:0 auto; padding:12px 2px 34px; font-family:-apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif; }\n.uh-head { position:sticky; top:-18px; z-index:20; margin:0 -2px; padding:18px 2px 14px; background:color-mix(in srgb, var(--dsw-alias-bg-base) 88%, transparent); backdrop-filter:blur(18px) saturate(150%); border-bottom:1px solid color-mix(in srgb, var(--dsw-alias-border-l1) 76%, transparent); }\n.uh-title { font-size:22px; line-height:1.2; font-weight:700; letter-spacing:0; }\n.uh-actions { gap:8px; }\n.uh-range { padding:2px; gap:2px; border:0; border-radius:9px; background:color-mix(in srgb, var(--dsw-alias-label-primary) 10%, transparent); overflow:visible; }\n.uh-range button, .uh-range button + button { min-height:28px; border:0; border-radius:7px; padding:4px 10px; }\n.uh-range button.uh-on { background:var(--dsw-alias-bg-layer-1); box-shadow:0 1px 3px rgba(0,0,0,.16); }\n.uh-refresh { min-height:30px; border:0; border-radius:15px; padding:5px 12px; display:inline-flex; align-items:center; justify-content:center; gap:6px; background:color-mix(in srgb, var(--dsw-alias-brand-primary) 14%, var(--dsw-alias-bg-layer-1)); color:var(--dsw-alias-brand-primary); font-weight:600; }\n.uh-line-icon { flex:none; }\n.uh-icon-button { width:30px; padding:0; }\n.uh-refresh:hover { border:0; background:color-mix(in srgb, var(--dsw-alias-brand-primary) 22%, var(--dsw-alias-bg-layer-1)); }\n.uh-progress { padding:10px 12px; background:color-mix(in srgb, var(--dsw-alias-brand-primary) 9%, var(--dsw-alias-bg-layer-1)); border:0; border-radius:12px; }\n.uh-cards { grid-template-columns:repeat(auto-fit, minmax(180px, 1fr)); gap:10px; border:0; border-radius:0; overflow:visible; background:transparent; }\n.uh-card { min-height:84px; padding:12px 14px; gap:4px; border:0; border-radius:18px; background:var(--dsw-alias-bg-layer-1); box-shadow:0 1px 2px rgba(0,0,0,.07), 0 8px 22px rgba(0,0,0,.05); animation:none; }\n.uh-card:first-child { border:0; background:color-mix(in srgb, #0a84ff 15%, var(--dsw-alias-bg-layer-1)); }\n.uh-card:nth-child(2) { background:color-mix(in srgb, #30d158 13%, var(--dsw-alias-bg-layer-1)); }\n.uh-card:nth-child(3) { background:color-mix(in srgb, #ff9f0a 14%, var(--dsw-alias-bg-layer-1)); }\n.uh-card:hover { transform:translateY(-2px); box-shadow:0 12px 28px rgba(0,0,0,.12); }\n.uh-card-label { display:flex; align-items:center; gap:6px; font-size:12px; font-weight:600; letter-spacing:0; }\n.uh-ios-summary-label, .uh-section-title, .uh-title-with-icon { display:flex; align-items:center; gap:7px; }\n.uh-section-title { margin-bottom:12px; color:var(--dsw-alias-label-primary); font-size:14px; font-weight:650; }\n/* Raise the complete reading scale without changing the data grid geometry. */\n.uh-page { font-size:14px; }\n.uh-range button, .uh-refresh { font-size:13px; }\n.uh-card-label, .uh-ios-summary-label { font-size:13px; }\n.uh-card-sub, .uh-ios-summary-caption, .uh-note { font-size:12px; }\n.uh-hrow, .uh-row, .uh-model-hrow, .uh-model-row { font-size:13px; }\n.uh-tbl-title { font-size:15px; }\n.uh-num { font-variant-numeric:tabular-nums; }\n.uh-card-value { font-size:23px; font-weight:700; letter-spacing:0; }\n.uh-card-sub { font-size:11px; line-height:1.25; }\n.uh-panel { padding:16px; border:0; border-radius:18px; background:var(--dsw-alias-bg-layer-1); box-shadow:0 1px 2px rgba(0,0,0,.06), 0 6px 18px rgba(0,0,0,.04); }\n.uh-hm-head { margin-bottom:12px; }\n.uh-chip { border:0; border-radius:14px; padding:5px 10px; background:color-mix(in srgb, var(--dsw-alias-label-primary) 7%, transparent); }\n.uh-chip.uh-on { border:0; background:color-mix(in srgb, var(--dsw-alias-brand-primary) 18%, transparent); color:var(--dsw-alias-brand-primary); }\n.uh-hrow, .uh-row, .uh-model-hrow, .uh-model-row { border-radius:10px; }\n.uh-hrow, .uh-model-hrow { position:sticky; top:66px; z-index:2; background:var(--dsw-alias-bg-layer-1); border-bottom:1px solid var(--dsw-alias-border-l1); }\n.uh-row, .uh-model-row { padding-top:9px; padding-bottom:9px; }\n.uh-row:nth-child(even) { background:color-mix(in srgb, var(--dsw-alias-bg-layer-2) 52%, transparent); }\n.uh-side-entry { min-height:40px; border:0; border-radius:12px; padding:8px 10px; background:color-mix(in srgb, var(--dsw-alias-brand-primary) 9%, transparent); color:var(--dsw-alias-brand-primary); font-weight:600; }\n.uh-side-entry:hover { border:0; background:color-mix(in srgb, var(--dsw-alias-brand-primary) 17%, transparent); }\n.uh-side-entry-icon { color:var(--dsw-alias-brand-primary); font-weight:700; }\n.uh-side-modal { align-items:flex-end; padding:0; background:rgba(0,0,0,.34); backdrop-filter:blur(8px); }\n.uh-side-dialog { width:min(1260px, 100%); max-height:calc(100vh - var(--uh-top-inset, 0px) - 44px); border:0; border-radius:24px 24px 0 0; padding:22px 24px 28px; background:color-mix(in srgb, var(--dsw-alias-bg-base) 94%, transparent); box-shadow:0 -10px 44px rgba(0,0,0,.25); }\n.uh-side-dialog-head { position:sticky; top:-22px; z-index:8; justify-content:center; height:22px; margin:-22px -24px 8px; padding:8px 24px; background:color-mix(in srgb, var(--dsw-alias-bg-base) 94%, transparent); border:0; }\n.uh-side-dialog-head::before { content:""; width:36px; height:5px; border-radius:3px; background:color-mix(in srgb, var(--dsw-alias-label-primary) 24%, transparent); }\n.uh-side-dialog-head .uh-refresh { position:absolute; right:20px; top:7px; min-height:28px; background:transparent; }\n.uh-close-button { width:30px; padding:0; font-size:22px; line-height:1; color:var(--dsw-alias-label-secondary); }\n.uh-close-button:hover { color:var(--dsw-alias-label-primary); background:color-mix(in srgb, var(--dsw-alias-label-primary) 10%, transparent); }\n@media (max-width:640px) { .uh-page { gap:14px; padding-bottom:20px; } .uh-head { position:static; padding:4px 0 10px; } .uh-title { font-size:20px; } .uh-custom-range { grid-template-columns:1fr; align-items:stretch; } .uh-custom-range-fields { grid-template-columns:repeat(2, minmax(0, 1fr)); } .uh-custom-range-actions { justify-content:flex-end; } .uh-side-dialog { max-height:calc(100vh - 8px); border-radius:20px 20px 0 0; padding:18px 14px 24px; } .uh-side-dialog-head { top:-18px; margin:-18px -14px 8px; padding:7px 14px; } .uh-card-value { font-size:22px; } }\n/* Navigation separates the dashboard into three focused iOS-style surfaces. */\n.uh-ios-tabs { display:grid; grid-template-columns:repeat(3, 1fr); gap:4px; padding:4px; border-radius:14px; background:color-mix(in srgb, var(--dsw-alias-label-primary) 9%, transparent); }\n.uh-ios-tab { min-height:32px; border:0; border-radius:10px; background:transparent; color:var(--dsw-alias-label-secondary); font:inherit; font-size:13px; font-weight:600; cursor:pointer; }\n.uh-ios-tab.uh-on { color:var(--dsw-alias-label-primary); background:var(--dsw-alias-bg-layer-1); box-shadow:0 1px 4px rgba(0,0,0,.16); }\n.uh-ios-summary { display:flex; flex-direction:column; gap:12px; background:transparent; box-shadow:none; }\n.uh-ios-summary-hero { display:grid; grid-template-columns:minmax(0,1fr) minmax(320px,.48fr); min-height:142px; padding:20px 22px; border:1px solid var(--dsw-alias-border-l1); border-radius:18px; background:var(--dsw-alias-bg-layer-1); box-shadow:0 1px 2px rgba(0,0,0,.06), 0 8px 22px rgba(0,0,0,.06); }\n.uh-ios-summary-total { min-width:0; min-height:0; padding:0; border-radius:0; display:flex; align-items:center; justify-content:flex-start; gap:16px; background:transparent; box-shadow:none; }\n.uh-ios-summary-total-icon { display:grid; place-items:center; flex:none; width:54px; height:54px; border-radius:16px; background:color-mix(in srgb,#0a84ff 18%,var(--dsw-alias-bg-layer-2)); color:#0a84ff; }\n.uh-ios-summary-total-copy { min-width:0; }\n.uh-ios-summary-label { font-size:13px; font-weight:600; color:var(--dsw-alias-label-secondary); }\n.uh-ios-summary-total .uh-ios-summary-label { font-size:14px; }\n.uh-ios-summary-value { margin-top:7px; font-size:40px; line-height:1; font-weight:750; letter-spacing:0; color:var(--dsw-alias-label-primary); }\n.uh-unit { margin-left:6px; color:var(--dsw-alias-label-secondary); font-size:.4em; font-weight:650; white-space:nowrap; vertical-align:baseline; }\n.uh-wsbar-num .uh-unit { font-size:.78em; margin-left:3px; }\n.uh-ios-summary-caption { margin-top:8px; font-size:12px; color:var(--dsw-alias-label-secondary); }\n.uh-ios-summary-meta { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); align-items:center; min-width:0; gap:0; padding:0 0 0 22px; border-left:1px solid var(--dsw-alias-border-l1); background:transparent; font-size:12px; color:var(--dsw-alias-label-secondary); }\n.uh-ios-summary-meta-stat { min-width:0; padding:4px 22px; }\n.uh-ios-summary-meta-stat + .uh-ios-summary-meta-stat { border-left:1px solid var(--dsw-alias-border-l1); }\n.uh-ios-summary-meta-label { display:flex; align-items:center; gap:7px; color:var(--dsw-alias-label-secondary); font-size:12px; font-weight:600; white-space:nowrap; }\n.uh-ios-summary-meta-value { margin-top:7px; color:var(--dsw-alias-label-primary); font-size:24px; line-height:1; font-weight:700; font-variant-numeric:tabular-nums; white-space:nowrap; }\n.uh-ios-summary-meta-cost .uh-ios-summary-meta-value { color:#30d158; }\n.uh-ios-summary-meta-caption { margin-top:7px; color:var(--dsw-alias-label-secondary); font-size:11px; white-space:nowrap; }\n.uh-ios-metrics { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:8px; }\n.uh-ios-metric { min-width:0; min-height:80px; padding:10px 13px; border:1px solid var(--dsw-alias-border-l1); border-radius:14px; display:flex; flex-direction:column; justify-content:center; gap:6px; background:var(--dsw-alias-bg-layer-1); box-shadow:0 1px 2px rgba(0,0,0,.06), 0 8px 20px rgba(0,0,0,.05); animation:uh-card-in .35s ease both; }\n.uh-ios-metrics > .uh-card { min-width:0; min-height:96px; padding:9px 13px; gap:2px; border:0; border-radius:14px; }\n.uh-ios-metrics > .uh-card .uh-card-value { min-width:0; font-size:20px; line-height:1.2; font-weight:700; white-space:nowrap; }\n.uh-ios-metrics > .uh-card .uh-card-sub { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }\n.uh-ios-metrics > .uh-card:nth-child(-n+3) { justify-content:center; }\n.uh-ios-metric-label { display:flex; align-items:center; gap:8px; min-width:0; color:var(--dsw-alias-label-secondary); font-size:13px; font-weight:600; white-space:nowrap; }\n.uh-ios-metric-label .uh-line-icon { flex:none; }\n.uh-ios-metric-value { min-width:0; color:var(--dsw-alias-label-primary); font-size:22px; line-height:1.05; font-weight:700; font-variant-numeric:tabular-nums; white-space:nowrap; }\n.uh-ios-metric-input { background:color-mix(in srgb,#0a84ff 11%,var(--dsw-alias-bg-layer-1)); }\n.uh-ios-metric-input .uh-line-icon { color:#0a84ff; }\n.uh-ios-metric-output { background:color-mix(in srgb,#bf5af2 10%,var(--dsw-alias-bg-layer-1)); }\n.uh-ios-metric-output .uh-line-icon { color:#bf5af2; }\n.uh-ios-metric-write { background:color-mix(in srgb,#ff9f0a 11%,var(--dsw-alias-bg-layer-1)); }\n.uh-ios-metric-write .uh-line-icon { color:#ff9f0a; }\n.uh-ios-metric-read { background:color-mix(in srgb,#30d158 11%,var(--dsw-alias-bg-layer-1)); }\n.uh-ios-metric-read .uh-line-icon { color:#30d158; }\n.uh-ios-metric-rate { background:var(--dsw-alias-bg-layer-1); }\n.uh-ios-metric-rate .uh-line-icon { color:#30d158; }\n.uh-ios-metric-rate-head { display:flex; align-items:baseline; justify-content:space-between; gap:8px; min-width:0; }\n.uh-ios-metric-rate-value { flex:none; color:#30d158; font-size:20px; line-height:1; font-weight:700; font-variant-numeric:tabular-nums; }\n.uh-ios-metric-rate-detail { min-width:0; overflow:hidden; color:var(--dsw-alias-label-secondary); font-size:12px; line-height:1.2; font-weight:600; font-variant-numeric:tabular-nums; text-overflow:ellipsis; white-space:nowrap; }\n.uh-ios-metric-bar { height:5px; border-radius:3px; background:var(--dsw-alias-bg-layer-2); overflow:hidden; }\n.uh-ios-metric-fill { height:100%; border-radius:inherit; background:#30d158; transition:width .35s ease; }\n.uh-token-semantics { display:flex; align-items:flex-start; gap:8px; padding:10px 12px; border-radius:12px; background:color-mix(in srgb, var(--dsw-alias-brand-primary) 8%, var(--dsw-alias-bg-layer-1)); color:var(--dsw-alias-label-secondary); font-size:12px; line-height:1.55; }\n.uh-token-semantics .uh-line-icon { margin-top:1px; color:var(--dsw-alias-brand-primary); }\n.uh-ios-list-panel { min-height:360px; }\n.uh-donut-chart { margin:0 0 18px; }\n.uh-donut-title { display:flex; align-items:center; gap:7px; margin-bottom:12px; color:var(--dsw-alias-label-primary); font-size:14px; font-weight:650; }\n.uh-donut-layout { display:grid; grid-template-columns:minmax(220px,300px) minmax(0,1fr); gap:24px; align-items:center; }\n.uh-donut-visual { position:relative; width:min(100%,280px); aspect-ratio:1; margin:0 auto; }\n.uh-donut-svg { display:block; width:100%; height:100%; overflow:visible; }\n.uh-donut-track { opacity:.78; }\n.uh-donut-segment { fill:none; stroke-dasharray:1; stroke-dashoffset:1; animation:uh-donut-draw .95s cubic-bezier(.22,.61,.36,1) both; cursor:pointer; outline:none; transition:filter .15s ease, opacity .15s ease; }\n.uh-donut-segment:hover, .uh-donut-segment:focus-visible, .uh-donut-segment.uh-active { filter:brightness(1.12); }\n.uh-donut-tooltip { position:absolute; top:0; left:0; z-index:3; display:flex; align-items:flex-start; gap:8px; max-width:190px; padding:9px 10px; border:1px solid var(--dsw-alias-border-l2); border-radius:8px; background:color-mix(in srgb, var(--dsw-alias-bg-base) 94%, transparent); box-shadow:0 10px 24px rgba(0,0,0,.22); backdrop-filter:blur(10px); color:var(--dsw-alias-label-primary); pointer-events:none; font-size:12px; line-height:1.4; transition:left .12s cubic-bezier(.22,.61,.36,1), top .12s cubic-bezier(.22,.61,.36,1); }\n.uh-donut-tooltip > div { min-width:0; display:flex; flex-direction:column; gap:4px; }\n.uh-donut-tooltip strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:12px; }\n.uh-donut-tooltip span:not(.uh-donut-dot):not(.uh-model-icon) { color:var(--dsw-alias-label-secondary); font-size:11px; }\n.uh-donut-tooltip-cost { color:var(--dsw-alias-label-primary) !important; font-variant-numeric:tabular-nums; }\n.uh-donut-center { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; pointer-events:none; }\n.uh-donut-center strong { color:var(--dsw-alias-label-primary); font-size:28px; line-height:1; font-weight:750; font-variant-numeric:tabular-nums; }\n.uh-donut-center span { margin-top:5px; color:var(--dsw-alias-label-secondary); font-size:13px; }\n.uh-donut-legend { min-width:0; }\n.uh-donut-legend-row { display:grid; grid-template-columns:36px minmax(180px,1fr) minmax(250px,.8fr) 54px; gap:10px; align-items:center; min-height:58px; padding:8px 0; border-bottom:1px solid color-mix(in srgb, var(--dsw-alias-border-l1) 78%, transparent); }\n.uh-donut-legend-row:last-child { border-bottom:0; }\n.uh-donut-dot { width:12px; height:12px; border-radius:50%; }\n.uh-donut-legend-mark { display:flex; align-items:center; gap:8px; min-width:0; }\n.uh-donut-legend-copy { min-width:0; display:flex; flex-direction:column; gap:5px; }\n.uh-donut-legend-copy strong { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--dsw-alias-label-primary); font-size:13px; font-weight:650; }\n.uh-donut-legend-metrics { display:grid; grid-template-columns:minmax(120px,1fr) minmax(92px,auto); align-items:center; gap:14px; min-width:0; }\n.uh-donut-legend-metrics span { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--dsw-alias-label-secondary); font-size:12px; font-variant-numeric:tabular-nums; text-align:right; }\n.uh-donut-legend-metrics .uh-donut-cost { color:var(--dsw-alias-label-secondary); font-size:12px; }\n.uh-donut-percent { min-width:48px; color:var(--dsw-alias-label-secondary); font-size:12px; font-variant-numeric:tabular-nums; text-align:right; }\n/* Each detail table owns its scrolling and sticky header; sections must not overlap in the page scroll. */\n.uh-tbl-scroll { max-height:360px; overflow:auto; border-radius:12px; background:color-mix(in srgb, var(--dsw-alias-bg-layer-2) 55%, transparent); }\n.uh-hrow, .uh-model-hrow { position:sticky; top:0; z-index:3; border-bottom:1px solid var(--dsw-alias-border-l1); box-shadow:0 1px 0 color-mix(in srgb, var(--dsw-alias-bg-base) 70%, transparent); }\n.uh-row, .uh-model-row { min-height:48px; border-bottom:1px solid color-mix(in srgb, var(--dsw-alias-border-l1) 72%, transparent); }\n.uh-row:last-child, .uh-model-row:last-child { border-bottom:0; }\n@media (max-width:640px) { .uh-tbl-scroll { max-height:300px; border-radius:10px; } }\n@media (max-width:640px) { .uh-hm-body { min-width:720px; } .uh-donut-legend-row { grid-template-columns:36px minmax(0,1fr) 48px; gap:8px; } .uh-donut-legend-copy { grid-column:2; grid-row:1; } .uh-donut-legend-metrics { grid-column:2 / -1; grid-row:2; grid-template-columns:minmax(0,1fr) minmax(0,auto); gap:8px; } .uh-donut-percent { grid-column:3; grid-row:1; } .uh-ios-summary-hero { grid-template-columns:1fr; min-height:0; gap:18px; padding:18px; } .uh-ios-summary-total { align-items:flex-start; } .uh-ios-summary-meta { grid-template-columns:repeat(2,minmax(0,1fr)); padding:16px 0 0; border-left:0; border-top:1px solid var(--dsw-alias-border-l1); } .uh-ios-summary-meta-stat { padding:0 12px; } .uh-ios-summary-meta-stat:first-child { padding-left:0; } .uh-ios-summary-meta-stat:last-child { padding-right:0; } .uh-ios-summary-value { font-size:31px; } .uh-ios-metrics { grid-template-columns:repeat(2,minmax(0,1fr)); } .uh-ios-metric:last-child { grid-column:1 / -1; } .uh-ios-metric-value { font-size:24px; } .uh-donut-layout { grid-template-columns:1fr; gap:12px; } .uh-donut-visual { width:min(100%,250px); } }\n@keyframes uh-cell-in { from { opacity:0; transform:scale(.4); } to { opacity:1; transform:scale(1); } }\n@keyframes uh-glow { 0% { box-shadow:0 0 0 0 rgba(9,105,218,.5); } 70% { box-shadow:0 0 0 5px rgba(9,105,218,0); } 100% { box-shadow:0 0 0 0 rgba(9,105,218,0); } }\n@keyframes uh-card-in { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }\n@keyframes uh-bar-grow { from { transform:scaleX(0); } to { transform:scaleX(1); } }\n@keyframes uh-panel-in { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:translateY(0); } }\n@keyframes uh-trend-draw { from { stroke-dashoffset:var(--uh-draw-length); opacity:.2; } to { stroke-dashoffset:0; opacity:1; } }\n@keyframes uh-trend-fill { from { opacity:0; } to { opacity:1; } }\n@keyframes uh-donut-draw { from { stroke-dashoffset:1; opacity:.25; } to { stroke-dashoffset:0; opacity:1; } }\n@keyframes uh-spinner-turn { to { transform:rotate(360deg); } }\n@keyframes uh-menu-in { from { opacity:0; transform:translateY(-4px) scale(.97); } to { opacity:1; transform:translateY(0) scale(1); } }\n@keyframes uh-tip-in { from { opacity:0; } to { opacity:1; } }\n@media (prefers-reduced-motion: reduce) {\n .uh-cell, .uh-card, .uh-ios-metric, .uh-barfill, .uh-anim-panel, .uh-trend-panel, .uh-trend-line-draw, .uh-trend-area, .uh-trend-point, .uh-trend-spinner, .uh-donut-segment, .uh-records-panel, .uh-record-detail, .uh-tip, .uh-language-options { animation:none !important; stroke-dashoffset:0 !important; opacity:1 !important; }\n .uh-card, .uh-cell, .uh-ios-metric-fill, .uh-barfill, .uh-fill, .uh-refresh, .uh-chip, .uh-row, .uh-tip-row, .uh-trend-tooltip, .uh-language-trigger, .uh-language-caret, .uh-language-option { transition:none !important; }\n}\n'}const pt=()=>fetch("/api/all-usage"+(()=>{try{return"en"===window.localStorage.getItem(ft)?"?utc=1":"?utc=0"}catch(e){return""}})(),{headers:{accept:"application/json"}}).then(e=>{if(!e.ok)throw new Error("HTTP "+e.status);return e.json()}),mt=e=>fetch("/api/all-usage/version"+(!0===e?"?force=1":""),{headers:{accept:"application/json"}}).then(e=>{if(!e.ok){const t=new Error("HTTP "+e.status);throw t.status=e.status,t}return e.json()}),ht=(e,t,a)=>{const n=new URLSearchParams({start:e.start,end:e.end,utc:e.utc?"1":"0",limit:String(a||100)});return e.workspaceId&&n.set("workspaceId",e.workspaceId),e.provider&&n.set("provider",e.provider),e.modelKey&&n.set("modelKey",e.modelKey),t&&n.set("cursor",t),fetch("/api/all-usage/records?"+n.toString(),{headers:{accept:"application/json"}}).then(e=>{if(!e.ok){const t=new Error("HTTP "+e.status);throw t.status=e.status,t}return e.json()})},gt=()=>fetch("/api/all-usage/pricing",{headers:{accept:"application/json"}}).then(e=>{if(!e.ok)throw new Error("HTTP "+e.status);return e.json()}),bt=(e,t,a)=>fetch("/api/all-usage/pricing",{method:"POST",headers:{"content-type":"application/json","x-all-usage-request-token":a},body:JSON.stringify({pricing:e,backfill:!0===t})}).then(e=>{if(!e.ok){const t=new Error("HTTP "+e.status);throw t.status=e.status,t}return e.json()}),ft="dsh-all-usage.language";function yt(){try{return"en"===window.localStorage.getItem(ft)?"en":"zh"}catch(e){return"zh"}}const xt="dsh-all-usage.ui-state";function vt(){try{const e=window.localStorage.getItem(xt),t=e?JSON.parse(e):{};if(null===t||"object"!=typeof t||Array.isArray(t))return{};const a={};return["logs","model","workspace"].includes(t.detailView)&&(a.detailView=t.detailView),["route","model","provider"].includes(t.modelView)&&(a.modelView=t.modelView),["today","7d","30d","90d","all"].includes(t.range)&&(a.range=t.range),Re.includes(t.heatmapSpan)&&(a.heatmapSpan=t.heatmapSpan),"boolean"==typeof t.pricingAutoSync&&(a.pricingAutoSync=t.pricingAutoSync),a}catch(e){return{}}}function wt(e){try{const t=vt();window.localStorage.setItem(xt,JSON.stringify(Object.assign({},t,e)))}catch(e){}}function kt(e){const t=e.timerCtx,a="en"===e.language?"en":"zh",i=(e,t)=>"en"===a?t:e,l="en"===a,o=n.useRef(null);null===o.current&&(o.current=vt());const s=o.current,b=new Date,x=c(b,l),[E,C]=n.useState(null),[M,S]=n.useState(null),[A,I]=n.useState(""),[R,j]=n.useState(0),[D,W]=n.useState(null),[P,K]=n.useState(()=>s.range||"today"),[q,J]=n.useState(()=>De(s.heatmapSpan)),[ce,ue]=n.useState(null),[pe,he]=n.useState(""),[Ee,Ne]=n.useState({start:"",end:""}),[Me,Se]=n.useState({start:"",end:""}),[Ae,ze]=n.useState(!1),[Ie,Re]=n.useState(()=>s.modelView||"route"),[je,Pe]=n.useState(null),[Ke,qe]=n.useState(null),[Be,Ve]=n.useState(null),[Je,$e]=n.useState(null),[_e,Xe]=n.useState(""),[Ze,Qe]=n.useState(!1),[tt,nt]=n.useState(""),[dt,ft]=n.useState(["total","input","cacheRead","output"]),[yt,xt]=n.useState(()=>s.detailView||"logs"),[kt,Et]=n.useState(null),[Nt,Ct]=n.useState(null),[Mt,St]=n.useState([]),[At,zt]=n.useState(null),[Tt,It]=n.useState(!1),[Rt,jt]=n.useState(0),[Dt,Ft]=n.useState(!1),[Ut,Wt]=n.useState(!1),[Ot,Lt]=n.useState(""),[Pt,Kt]=n.useState(!1),[qt,Bt]=n.useState({}),[Ht,Yt]=n.useState(!1),[Vt,Jt]=n.useState(null),[Gt,$t]=n.useState(null),[_t,Xt]=n.useState(!1),[Zt,Qt]=n.useState(!1),[ea,ta]=n.useState(!1),[aa,na]=n.useState(!1),[ra,ia]=n.useState(""),[la,oa]=n.useState({}),[sa,ca]=n.useState({}),[ua,da]=n.useState(null),[pa,ma]=n.useState({}),[ha,ga]=n.useState(null),[ba,fa]=n.useState({});n.useEffect(()=>{fa({})},[a]);const[ya,xa]=n.useState(()=>(new Date).getFullYear()),[va,wa]=n.useState(!1),[ka,Ea]=n.useState(""),Na=n.useRef({}),Ca=n.useRef(0),Ma=n.useRef({}),Sa=n.useRef(!1),Aa=n.useRef(()=>{}),za=n.useRef(()=>{}),Ta=()=>{Ca.current+=1;const e=Ma.current;for(const t of Object.keys(e))clearTimeout(e[t]);Ma.current={},Na.current={},oa({}),ca({})},[Ia,Ra]=n.useState(!1),ja=n.useRef(null),Da=n.useRef(null),Fa=n.useRef(null);null===Fa.current&&(Fa.current=h());const Ua=n.useRef(null);null===Ua.current&&(Ua.current=h());const Wa=n.useRef(null);null===Wa.current&&(Wa.current=h());const Oa=n.useRef(null);null===Oa.current&&(Oa.current=h());const La=n.useRef(null);null===La.current&&(La.current=h());const Pa=n.useRef(null);null===Pa.current&&(Pa.current=h());const Ka=Fa.current,qa=Ua.current,Ba=Wa.current,Ha=Oa.current,Ya=La.current,Va=Pa.current,Ja=n.useRef(()=>{}),Ga=n.useRef(""),$a=n.useCallback(()=>{if(!Sa.current||Zt||ea||aa)return;const e=Va.next();Xt(!0),gt().then(t=>{if(Va.isCurrent(e)){if(!t||"object"!=typeof t||!t.config)return ia("load"),void Xt(!1);Ta(),Jt(t),$t(e=>_(e,t)),ia(""),Xt(!1)}},()=>{Va.isCurrent(e)&&(ia("load"),Xt(!1))})},[Zt,ea,aa]);n.useEffect(()=>{Aa.current=$a});n.useEffect(()=>{wt({detailView:yt})},[yt]),n.useEffect(()=>{wt({modelView:Ie})},[Ie]),n.useEffect(()=>{"custom"!==P&&wt({range:P})},[P]),n.useEffect(()=>{wt({heatmapSpan:q})},[q]),n.useEffect(()=>{let e=!0;const t=t=>mt(t).then(t=>{e&&(ue(t),he(""))},t=>{e&&he(!t||401!==t.status&&404!==t.status?"failed":"endpoint")});return za.current=()=>t(!1),t(!1),()=>{e=!1,za.current=()=>{}}},[]);const _a=n.useMemo(()=>null===E?null:function(e,t,a,n,r,i,l){const o=Fe(e,t,a,n);return null===o?null:{start:o.start,end:o.end,utc:!0===a,workspaceId:r||null,provider:i||null,modelKey:l||null}}(E,P,l,Ee,je,Ke,Be),[E,P,l,Ee.start,Ee.end,je,Ke,Be]),Xa=Ue(_a),Za=y(null!==M&&"object"==typeof M?M:E),Qa=null!==kt&&kt.baseKey===Xa?kt.scope:_a,en=Ue(Qa),tn=n.useRef(Xa);n.useEffect(()=>{tn.current!==Xa&&(tn.current=Xa,Et(null),Ct(null))},[Xa]),n.useEffect(()=>{let e=!0,a=!1,n="",r=null,i=0,l=0,o=null;const s=()=>{null!==o&&(clearTimeout(o),o=null)},c=t=>{if(""===n)return;const a=Ba.next();((e,t)=>fetch("/api/all-usage/balance"+(e?"?force=1":""),{headers:{accept:"application/json","x-all-usage-request-token":t}}).then(e=>{if(!e.ok)throw new Error("HTTP "+e.status);return e.json()}))(!0===t,n).then(t=>{e&&Ba.isCurrent(a)&&t&&W(t)},()=>{})},u=t=>{if(!e||null!==o)return;const a="full"===t?i+=1:l+=1;o=setTimeout(()=>{o=null,e&&("full"===t?d():p())},function(e){const t=Math.max(1,Math.min(4,"number"==typeof e&&Number.isFinite(e)?e:1));return 5e3*Math.pow(2,t-1)}(a))},d=()=>{qa.next();const t=Ka.next();pt().then(l=>{if(!e||!Ka.isCurrent(t))return;if(null===l||"object"!=typeof l)return I("full"),void u("full");const o=null!==r&&"string"==typeof r.pluginVersion?r.pluginVersion:"";r=l,l.scan&&(a=!!l.scan.done);const d="string"==typeof l.pluginVersion?l.pluginVersion:"";""!==d&&d!==o&&za.current();const p="string"==typeof l.requestToken?l.requestToken:"",m=""!==p&&p!==n;n=p,""!==p&&(Ga.current=p),i=0,s(),I(""),j(Date.now()),S(l),C(l),m&&c(!1)},()=>{e&&Ka.isCurrent(t)&&(I("full"),u("full"))})},p=()=>{if(null===r)return void d();const t=qa.next();fetch("/api/all-usage/status",{headers:{accept:"application/json"}}).then(e=>{if(!e.ok)throw new Error("HTTP "+e.status);return e.json()}).then(n=>{if(!e||!qa.isCurrent(t))return;if(null===n||"object"!=typeof n)return I("status"),void u("status");l=0;const i=function(e,t){if(null===e||"object"!=typeof e||null===t||"object"!=typeof t)return"full";if("string"!=typeof e.instanceId||"string"!=typeof t.instanceId||""===e.instanceId||e.instanceId!==t.instanceId)return"full";const a="string"==typeof e.capabilityId?e.capabilityId:"",n="string"==typeof t.capabilityId?t.capabilityId:"";if(""!==a&&a!==n)return"full";if(f(e)&&f(t)){if(e.metadataRevision!==t.metadataRevision)return"full";if(e.pricingRevision!==t.pricingRevision)return"full";if(e.dataRevision!==t.dataRevision)return"query";const a=e.scan,n=t.scan;return e.scanRevision!==t.scanRevision||a&&n&&!!a.done!=!!n.done?"status":"none"}const r=g(e),i=g(t);if(null===r||null===i||r!==i)return"full";const l=e.scan,o=t.scan;return l&&o&&!!l.done!=!!o.done?"full":"none"}(n,r);if(n.scan&&(a=!!n.scan.done),"full"===i)return"number"==typeof n.pricingRevision&&"number"==typeof r.pricingRevision&&n.pricingRevision!==r.pricingRevision&&Aa.current(),void d();r=Object.assign({},r,n),S(n),s(),I("")},()=>{e&&qa.isCurrent(t)&&(I("status"),u("status"))})};d();const m=t.interval(()=>{a||null!==o||p()},2e3),h=t.interval(()=>{a&&null===o&&p()},15e3),b=t.interval(()=>{c(!1)},6e4);return Ja.current=()=>{s(),i=0,l=0,d(),c(!0)},()=>{e=!1,s(),m(),h(),b();for(const e of Object.values(Ma.current))clearTimeout(e);Ma.current={}}},[]),n.useEffect(()=>{if(!Ia||"undefined"==typeof document)return;const e=e=>{ja.current&&!ja.current.contains(e.target)&&Ra(!1)};return document.addEventListener("pointerdown",e),()=>document.removeEventListener("pointerdown",e)},[Ia]),n.useEffect(()=>{if(null===_a||""===Xa)return;const e=Ha.next(),t=Za;Qe(!0),nt(""),(e=>{const t=new URLSearchParams({start:e.start,end:e.end,utc:e.utc?"1":"0"});return e.workspaceId&&t.set("workspaceId",e.workspaceId),e.provider&&t.set("provider",e.provider),e.modelKey&&t.set("modelKey",e.modelKey),fetch("/api/all-usage/query?"+t.toString(),{headers:{accept:"application/json"}}).then(e=>{if(!e.ok)throw new Error("HTTP "+e.status);return e.json()})})(_a).then(a=>{if(Ha.isCurrent(e)){if(null===a||"object"!=typeof a||null===t||y(a)!==t)return nt("stale"),void Qe(!1);$e(a),Xe(Xa),Qe(!1),nt("")}},()=>{Ha.isCurrent(e)&&(Qe(!1),nt("query"))})},[Xa,Za]);const an=n.useCallback(e=>{null!==e&&""!==Xa&&(Et({baseKey:Xa,scope:{...e}}),xt("logs"),Ct(null),Lt(""))},[Xa]),nn=n.useRef(null);nn.current=_a;const rn=n.useCallback(e=>{const t=nn.current;null!==t&&"string"==typeof e&&an({...t,start:e,end:e})},[an]),ln="logs"===yt&&null!==Qa&&""!==en;n.useEffect(()=>{if(!ln)return Ya.next(),void Ft(!1);const e=Ya.next(),t=Za;return Ft(!0),Lt(""),zt(null),It(!1),ht(Qa,null,20).then(a=>{if(Ya.isCurrent(e)){if(null===a||"object"!=typeof a||!Array.isArray(a.items))return Lt("audit"),void Ft(!1);if(null===t||y(a)!==t)return Lt("stale"),void Ft(!1);St(a.items),Ct(e=>a.items.some(t=>t&&t.id===e)?e:a.items[0]?a.items[0].id:null),zt(a.nextCursor||null),It(!0===a.hasMore),Ft(!1),Lt("")}},t=>{if(Ya.isCurrent(e)){if(t&&409===t.status)return Ft(!1),Lt("stale"),void jt(e=>e+1);Ft(!1),Lt("audit")}}),()=>{Ya.next()}},[en,yt,Za,Rt]),n.useEffect(()=>{null!==kt&&"logs"===yt&&null!==Da.current&&Da.current.scrollIntoView({behavior:"smooth",block:"start"})},[kt&&Ue(kt.scope),yt]);const on=n.useCallback(()=>{Ja.current(),mt(!0).then(e=>{e&&(ue(e),he(""))},e=>he(!e||401!==e.status&&404!==e.status?"failed":"endpoint"))},[]),sn=n.useCallback(e=>{Pe(t=>t===e?null:e)},[]),cn=n.useCallback(()=>{Pe(null),qe(null),Ve(null)},[]),un=n.useCallback(e=>{qe(e||null)},[]),dn=n.useCallback(e=>{Ve(e||null)},[]),pn=n.useMemo(()=>l&&Array.isArray(E&&E.byDayUtc)?E.byDayUtc:Array.isArray(E&&E.byDay)?E.byDay:[],[E,l]),mn=m(pn,x).min,hn=p(Ee,l),gn=function(e,t,a,n){return null!==e&&"object"==typeof e&&d(e.start,n)&&d(e.end,n)?e.start>e.end?"order":e.start<t||e.end>a?"bounds":"":"invalid"}(Me,mn,x,l),bn=n.useCallback(e=>{J(De(e))},[]),fn=null!==Je&&_e===Xa,yn=fn&&null!==Za&&y(Je)===Za,xn=fn&&(yn||""===tt),vn=null===hn?"":hn.start+":"+hn.end,wn=n.useMemo(()=>function(e,t,a,n){const r={totals:{turns:0,calls:0,sessions:0,input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,cost:{currency:"USD",input:"0",output:"0",cacheRead:"0",cacheWrite:"0",baseTotal:"0",total:"0",pricedCalls:0,unpricedCalls:0,ambiguousCalls:0,unsupportedCalls:0}},perWs:[],perModel:[]};if(null===e)return r;if("all"===t)return{totals:e.totals,perWs:e.perWorkspace,perModel:e.perModel||[]};const i=a&&Array.isArray(e.byDayUtc)?e.byDayUtc:Array.isArray(e.byDay)?e.byDay:[];let l,o=null;if("custom"===t){const e=p(n,a);if(null===e)return r;l=e.start,o=e.end}else l=c("today"===t?new Date:u(new Date,"7d"===t?-6:"30d"===t?-29:-89,a),a);const s={turns:0,calls:0,sessions:0,input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,cost:{currency:"USD",input:"0",output:"0",cacheRead:"0",cacheWrite:"0",baseTotal:"0",total:"0",pricedCalls:0,unpricedCalls:0,ambiguousCalls:0,unsupportedCalls:0}},d=new Map,m=new Map,h=new Set;for(const e of i){if(e.date<l||null!==o&&e.date>o)continue;const t=Array.isArray(e.sessionIds)?e.sessionIds:[];for(const e of t)h.add(e);s.turns+=e.turns,s.input+=e.tokens.input,s.output+=e.tokens.output,s.cacheRead+=e.tokens.cacheRead,s.cacheWrite+=e.tokens.cacheWrite,s.reasoning+=e.tokens.reasoning,Y(s.cost,e.cost);for(const t of e.byWorkspace){let e=d.get(t.workspaceId);void 0===e&&(e={workspaceId:t.workspaceId,turns:0,input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,cost:B()},d.set(t.workspaceId,e)),e.input+=t.input,e.output+=t.output,e.cacheRead+=t.cacheRead,e.cacheWrite+=t.cacheWrite,e.reasoning+=t.reasoning,Y(e.cost,t.cost)}for(const t of e.perWorkspace){let e=d.get(t.workspaceId);void 0===e&&(e={workspaceId:t.workspaceId,turns:0,input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,cost:B()},d.set(t.workspaceId,e)),e.turns+=t.turns}for(const t of e.byModel||[]){const e=t.identityKey||t.model;let a=m.get(e);void 0===a&&(a={...t,calls:0,input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,cost:B()},m.set(e,a)),a.calls+=t.calls,a.input+=t.input,a.output+=t.output,a.cacheRead+=t.cacheRead,a.cacheWrite+=t.cacheWrite,a.reasoning+=t.reasoning,s.calls+=Number.isFinite(t.calls)?t.calls:0,Y(a.cost,t.cost)}}return s.sessions=h.size,{totals:s,perWs:Array.from(d.values()),perModel:Array.from(m.values())}}(E,P,l,hn),[E,P,l,vn]),kn=n.useMemo(()=>function(e,t,a){if(!0===a)return!0;if(null==e||null==t)return!0;const n=Ce(e.totals),r=Ce(t.totals);return null===n||null===r||(0===r?0===n:Math.abs(n-r)<=Math.max(.05*r,2e5))}(yn?Je:null,wn,null!==je||null!==Ke||null!==Be),[yn,Je,wn,je,Ke,Be]),En=xn&&kn,Nn=En&&Array.isArray(Je.daily)?Je.daily:pn,Cn=En&&Array.isArray(Je.heatmap)?Je.heatmap:pn,Mn=n.useMemo(()=>En?{totals:Je.totals,perWs:Je.perWorkspace||[],perModel:Je.perModel||[]}:wn,[En,Je,wn]),Sn=Ye(Mn.totals.input+Mn.totals.output+Mn.totals.cacheRead+Mn.totals.cacheWrite+Mn.totals.reasoning,t),An=(Ye(Math.round(10*k(Mn.totals.input,Mn.totals.cacheRead)),t),null!==Ke||null!==Be),zn=function(e){if(null==e)return 0;const t=Number(e.pricedCalls||0)+Number(e.unpricedCalls||0)+Number(e.ambiguousCalls||0)+Number(e.unsupportedCalls||0);return Number.isFinite(t)&&t>0?t:0}(Mn.totals.cost),Tn=zn>0?zn:Number.isFinite(Mn.totals.calls)&&Mn.totals.calls>0?Mn.totals.calls:Mn.totals.turns,In=Ye(An?Tn:Mn.totals.turns,t),Rn=Ye(Tn,t),jn=e=>e.input+e.output+e.cacheRead+e.cacheWrite+e.reasoning,Dn=n.useMemo(()=>(Array.isArray(Mn.perWs)?Mn.perWs:[]).slice().sort((e,t)=>jn(t)-jn(e)),[Mn.perWs]),Fn=n.useMemo(()=>function(e,t,a,n){if("route"===t)return e.slice();const r=new Map,i=new Map;for(const l of e){const e=He(l,a,n),o="model"===t?e.model:e.provider;let s=r.get(o);void 0===s&&(s={model:o,provider:"provider"===t?o:e.provider,calls:0,input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,cost:B()},r.set(o,s),i.set(o,[])),i.get(o).push(l),s.calls+=l.calls,s.input+=l.input,s.output+=l.output,s.cacheRead+=l.cacheRead,s.cacheWrite+=l.cacheWrite,s.reasoning+=l.reasoning,Y(s.cost,l.cost)}for(const[e,a]of r){const n="provider"===t?T(e):U(i.get(e));a.iconKey=null===n?null:n.key}return Array.from(r.values())}(Mn.perModel||[],Ie,i("未知供应商","Unknown provider"),i("未知模型","Unknown model")).sort((e,t)=>jn(t)-jn(e)),[Mn.perModel,Ie,a]),Un=E&&Array.isArray(E.workspaces)?E.workspaces:[],Wn=E&&E.aliases&&"object"==typeof E.aliases?E.aliases:{},On=n.useMemo(()=>{const e=Array.isArray(wn.perModel)?wn.perModel.filter(e=>e&&"object"==typeof e):[],t=Array.from(new Set(e.map(e=>"string"==typeof e.provider&&""!==e.provider?e.provider:null).filter(e=>null!==e))).sort(),n=e=>{const n="string"==typeof e.actualModel&&""!==e.actualModel?e.actualModel:"string"==typeof e.requestedModel&&""!==e.requestedModel?e.requestedModel:null;if(null!==n)return z(n);const r="string"==typeof e.model&&""!==e.model?e.model:"en"===a?"Unknown model":"未知模型",i=r.indexOf(" / "),l=i>0?r.slice(0,i):"";return z(i>0&&t.includes(l)?r.slice(i+3):r)},r=new Map;for(const t of e.map(n)){if(""===t)continue;const e=t.toLowerCase();r.has(e)?t===t.toLowerCase()&&r.set(e,t):r.set(e,t)}const i=Array.from(r.values()).sort((e,t)=>e.localeCompare(t)).map(e=>({value:e,label:z(e)})),l=new Map((Array.isArray(wn.perWs)?wn.perWs:[]).map(e=>[e.workspaceId,e])),o=Un.filter(e=>{return void 0!==(t=l.get(e.id))&&(Number(t.turns)>0||Number(t.calls)>0||Number(t.input)>0||Number(t.output)>0||Number(t.cacheRead)>0||Number(t.cacheWrite)>0||Number(t.reasoning)>0);var t});return{providerOptions:t,modelOptions:i,rangeWorkspaceOptions:o,rangeWorkspaceIds:new Set(o.map(e=>e.id))}},[wn.perModel,wn.perWs,Un,a]),{providerOptions:Ln,modelOptions:Pn,rangeWorkspaceOptions:Kn,rangeWorkspaceIds:qn}=On,Bn=n.useMemo(()=>{const e=new Map,t=new Map;return Un.forEach((a,n)=>{e.set(a.id,a),t.set(a.id,n)}),{byId:e,indexes:t}},[Un]),Hn=Bn.byId,Yn=Bn.indexes,Vn=n.useCallback(e=>{const t=Wn[e],n=Hn.get(e);if(void 0!==n&&!0===n.retiredBucket)return"en"===a?"Deleted":"已删除";const r="string"==typeof t&&""!==t?t:n&&n.title?n.title:"en"===a?"Unknown workspace":"未知工作区";return void 0!==n&&!0===n.deleted?r+("en"===a?" (deleted)":"(已删除)"):r},[Wn,Hn,a]),Jn=n.useMemo(()=>[{value:"",label:"en"===a?"All workspaces":"全部工作区"}].concat(Kn.map(e=>({value:e.id,label:Vn(e.id)}))),[Kn,Vn,a]),Gn=n.useMemo(()=>[{value:"",label:"en"===a?"All providers":"全部供应商"}].concat(Ln.map(e=>({value:e,label:e}))),[Ln,a]),$n=n.useMemo(()=>[{value:"",label:"en"===a?"All models":"全部模型"}].concat(Pn.map(e=>({value:e.value,label:e.label,iconKey:(()=>{const t=F({actualModel:e.value,requestedModel:e.value});return null===t?null:t.key})()}))),[Pn,a]),_n=n.useMemo(()=>{const e=new Map;for(const t of pn)e.set(t.date,t);return e},[pn]),Xn=n.useMemo(()=>function(e,t){const a=new Date;let n=0;for(let r=0;r<371;r++){const i=u(a,-r,t),l=e.get(c(i,t));if(void 0!==l&&l.turns>0)n+=1;else if(r>0)break}let r=0,i=0;for(let n=0;n<371;n++){const l=u(a,-n,t),o=e.get(c(l,t));void 0!==o&&o.turns>0?(i+=1,i>r&&(r=i)):i=0}return{streak:n,best:r}}(_n,l),[_n,l,x]),Zn=E&&E.pricing&&"object"==typeof E.pricing?E.pricing:{},Qn=Vt&&"object"==typeof Vt?Vt:Zn,er=n.useMemo(()=>Ht?function(e,t,a){const n=null!==e&&"object"==typeof e?e:{},r=function(e){if(null===e||"object"!=typeof e)return $(e);const t=oe.get(e);if(void 0!==t)return t;const a=$(e);return oe.set(e,a),a}(n),i=new Map;for(const e of Array.isArray(n.temporalSchedules)?n.temporalSchedules:[])null!==e&&"object"==typeof e&&"string"==typeof e.id&&Array.isArray(e.policies)&&i.set(e.id,e.policies);const l=null!==t&&"object"==typeof t&&Array.isArray(t.mappings)?t.mappings:[],o=null!==t&&"object"==typeof t&&Array.isArray(t.overrides)?t.overrides:[],s=null!==a&&"object"==typeof a?a:{},c=new Map;for(let e=0;e<l.length;e+=1){const t=l[e];if(null===t||"object"!=typeof t)continue;const a=String(t.identityKey||t.usageIdentityKey||"").trim();""===a||c.has(a)||c.set(a,e)}const u=new Map;for(let e=0;e<o.length;e+=1){const t=o[e];if(null===t||"object"!=typeof t)continue;const a=re({providerId:t.providerId,modelId:t.modelId});u.has(a)||u.set(a,e)}return r.map(e=>{const t=function(e){if(null===e||"object"!=typeof e)return"";const t="string"==typeof e.identityKey?e.identityKey.trim():"";if(""!==t)return t;const a=e.pricingModel||e.actualModel||e.requestedModel||e.model||"";return"price|"+String(e.providerId||"").trim().toLowerCase()+"|"+String(a).trim().toLowerCase()}(e),a="string"==typeof e.identityKey?e.identityKey.trim():"",n=""!==a&&c.has(a)?c.get(a):-1,r=n>=0?l[n]:null,d=null!==r&&""!==String(r.catalogModelId||"").trim(),p=function(e,t){const a=null!==t&&"object"==typeof t&&"string"==typeof t.catalogModelId?t.catalogModelId.trim():"";if(""!==a)return{providerId:String(t.catalogProviderId||"").trim().toLowerCase(),modelId:a};const n=null!==e&&"object"==typeof e&&"priced"===e.status&&"string"==typeof e.pricingModel&&""!==e.pricingModel.trim(),r=n?e.pricingModel:null!==e&&"object"==typeof e?e.actualModel||e.requestedModel||e.pricingModel||e.model:"";return{providerId:n?String(e.providerId||"").trim().toLowerCase():"",modelId:String(r||"").trim()}}(e,r),m=re(p),h=u.has(m)?u.get(m):-1,g=h>=0?o[h]:null,b=d&&null!==s[t]&&"object"==typeof s[t]?s[t]:null,f=null!==b&&null!==b.rates&&"object"==typeof b.rates?b:null,y=null!=g?{input:g.input,output:g.output,cacheRead:g.cacheRead,cacheWrite:g.cacheWrite}:null!==f?{input:f.rates.input,output:f.rates.output,cacheRead:f.rates.cacheRead,cacheWrite:f.rates.cacheWrite}:null!==e.rates&&"object"==typeof e.rates?{input:e.rates.input,output:e.rates.output,cacheRead:e.rates.cacheRead,cacheWrite:e.rates.cacheWrite}:null,x=Array.isArray(e.tiers)?e.tiers.map(e=>Object.assign({},e)):[],v=null!=g&&Array.isArray(g.tiers)?g.tiers.map(e=>Object.assign({},e)):null!==f?[]:x,w=null!=g?!0===g.tiered&&v.length>0:null!==f?!0===f.tiered:!0===e.tiered,k=null!=g?v.length:null!==f?Number.isFinite(Number(f.tierCount))?Number(f.tierCount):0:Number.isFinite(Number(e.tierCount))?Number(e.tierCount):v.length,E="string"==typeof e.temporalScheduleId?i.get(e.temporalScheduleId):null,N=null!=g&&void 0!==g.temporalPricing?g.temporalPricing:Array.isArray(E)?{policies:E}:null,C=null!=N&&Array.isArray(N.policies)?N.policies.reduce((e,t)=>e+(null!==t&&Array.isArray(t.rules)?t.rules.length:0),0):0,M=null!=g&&void 0!==g.temporalPricing,S="string"==typeof e.temporalPolicyId?e.temporalPolicyId:"",A="official"===e.temporalRoute||"mapped"===e.temporalRoute,z=null===N&&A&&""!==S;return{key:t,row:e,identityKey:"string"==typeof e.identityKey?e.identityKey:"",usageBacked:!0===e.usageBacked||!1!==e.usageBacked&&null,model:"string"==typeof e.model?e.model:"",status:"string"==typeof e.status?e.status:"unpriced",reason:"string"==typeof e.reason?e.reason:"",mapped:d,mapping:r,mappingIndex:n,basis:p,overrideIndex:h,override:g,source:null!=g?"manual":"string"==typeof e.source?e.source:"none",rates:y,tiers:v,tiered:w,tierCount:k,tieredInvalid:!0===e.tieredInvalid,multiplier:null!==r&&void 0!==r.multiplier?String(r.multiplier):"1",inputTokenSemantics:null!==r&&"string"==typeof r.inputTokenSemantics?r.inputTokenSemantics:"fresh",pricingModel:d?String(r.catalogModelId):"string"==typeof e.pricingModel?e.pricingModel:"",providerId:p.providerId,temporalPlan:void 0===N?null:N,temporalRuleCount:C,temporalPolicyId:S,temporalRoute:"string"==typeof e.temporalRoute?e.temporalRoute:"",temporalRulesUnavailable:z,temporalExplicit:!!M||!0===e.temporalExplicit,temporalBuiltin:!M&&(z||!0===e.temporalBuiltin),temporalConfigInvalid:!0===e.temporalConfigInvalid||null!=g&&!0===g.temporalPricingInvalid,targetPreview:b,mappable:"string"==typeof e.identityKey&&""!==e.identityKey.trim()}})}(Qn,Gt,pa):[],[Ht,Qn,Gt,pa]),tr=n.useMemo(()=>{const e=null!==_a?{start:_a.start,end:_a.end}:Fe(E,P,l,hn),t=null!==_a&&_a.start===_a.end&&Je&&Array.isArray(Je.hourly)&&Je.hourly.length>0?function(e,t,a){const n=null!=t&&Array.isArray(t.byDay)?t.byDay.find(e=>e.date===a):void 0,r=void 0===n?null:Ce(n.tokens);if(null===r)return[];let i=0;for(const t of e)i+=Ce(t.tokens)||0;return i<=0?[]:Math.abs(i-r)<=Math.max(.05*r,2e5)?e:[]}(Je.hourly,E,_a.start):[],a=t.length>0?function(e,t){const a=[];for(const n of Array.isArray(e)?e:[]){if(null===n||"object"!=typeof n)continue;const e=Number.isFinite(n.time)?n.time:"string"==typeof n.date?Date.parse(n.date):NaN;if(!Number.isFinite(e))continue;const r=We(n);a.push({date:c(new Date(e),t),time:e,turns:Number.isFinite(n.turns)?n.turns:0,calls:Number.isFinite(n.calls)?n.calls:0,sessions:Number.isFinite(n.sessions)?n.sessions:0,tokens:r,cost:H(n),total:r.input+r.output+r.cacheRead+r.cacheWrite+r.reasoning})}return a.sort((e,t)=>e.time-t.time)}(t,l):[];return a.length>0?a:function(e,t,a,n){if(null===t||"object"!=typeof t)return[];const r=n&&Number.isFinite(n.maxPoints)?n.maxPoints:180,i=new Map((Array.isArray(e)?e:[]).filter(e=>e&&"string"==typeof e.date).map(e=>[e.date,e])),l=t.start.split("-").map(Number),o=t.end.split("-").map(Number),s=a?new Date(Date.UTC(l[0],l[1]-1,l[2])):new Date(l[0],l[1]-1,l[2]),u=a?new Date(Date.UTC(o[0],o[1]-1,o[2])):new Date(o[0],o[1]-1,o[2]),d=function(e,t){if(!Number.isFinite(e)||e<=t)return null;const a=Le[Le.length-1];for(let a=0;a<Le.length-1;a+=1)if(Math.ceil(e/Le[a].days)<=t)return Le[a];return a}(Math.round((u.getTime()-s.getTime())/864e5),r);if(null===d){const e=[];for(;s.getTime()<=u.getTime();){const t=c(s,a),n=i.get(t),r=We(n);e.push({date:t,turns:n&&Number.isFinite(n.turns)?n.turns:0,calls:n&&Number.isFinite(n.calls)?n.calls:0,sessions:n&&Number.isFinite(n.sessions)?n.sessions:0,tokens:r,cost:H(n),total:r.input+r.output+r.cacheRead+r.cacheWrite+r.reasoning,bucket:{start:t,end:t,days:1,granularity:"day"}}),a?s.setUTCDate(s.getUTCDate()+1):s.setDate(s.getDate()+1)}return e}return function(e,t,a,n,r){const i=[];let l=t;for(;l<=a;){let t;if("week"===r.unit){const e=l.split("-").map(Number),a=n?new Date(Date.UTC(e[0],e[1]-1,e[2])).getUTCDay():new Date(e[0],e[1]-1,e[2]).getDay();t=Oe(l,7*r.stride-(1===a?0:(a+6)%7),n)}else t=Oe(l,r.days,n);const o=Oe(t,-1,n),s=o>a?a:o,c={input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0},u=B();let d=0,p=0,m=0,h=0,g=0,b=l;for(;b<=s;){const t=e.get(b),a=We(t);d+=t&&Number.isFinite(t.turns)?t.turns:0,p+=t&&Number.isFinite(t.calls)?t.calls:0,m+=t&&Number.isFinite(t.sessions)?t.sessions:0,c.input+=a.input,c.output+=a.output,c.cacheRead+=a.cacheRead,c.cacheWrite+=a.cacheWrite,c.reasoning+=a.reasoning,h+=a.input+a.output+a.cacheRead+a.cacheWrite+a.reasoning,Y(u,t),g+=1,b=Oe(b,1,n)}if(i.push({date:l,turns:d,calls:p,sessions:m,tokens:c,cost:u,total:h,bucket:{start:l,end:s,days:g,granularity:"week"===r.unit?"week":"static"}}),s>=a)break;l=Oe(s,1,n)}return i}(i,t.start,t.end,a,d)}(En&&Je&&Array.isArray(Je.daily)?Je.daily:pn,e,l)},[_a,En,Je,pn,E,P,l,vn]),ar=En&&Je?Xa+":"+(y(Je)||"query"):Xa,nr=n.useMemo(()=>({}),[Ht,Gt,_t,Zt,ea,aa,ra,Qn,Zn,er,ha,ba,sa,ua,la,E,a]),rr=n.useMemo(()=>Fn.map((e,t)=>({label:e.model,value:jn(e),cost:e.cost,color:Ge[t%Ge.length],iconKey:"route"===Ie?(()=>{const t=F(e);return null===t?null:t.key})():void 0===e.iconKey?null:e.iconKey})),[Fn,Ie]),ir=n.useMemo(()=>Dn.map((e,t)=>({label:Vn(e.workspaceId),value:jn(e),cost:e.cost,color:Ge[t%Ge.length]})),[Dn,Vn]),lr=n.useCallback(e=>{ft(t=>t.includes(e)?t.length<=1?t:t.filter(t=>t!==e):t.concat(e))},[]);if(n.useEffect(()=>{null===je||qn.has(je)||Pe(null),null===Ke||Ln.includes(Ke)||qe(null),null===Be||Pn.some(e=>e.value===Be)||Ve(null)},[je,Ke,Be,qn,Ln,Pn]),null===E){const e=""!==A;return n.createElement("div",{className:"uh-page"},n.createElement("div",{className:"uh-panel"},n.createElement("div",{className:"uh-empty"},e?i("无法加载用量统计。请重试。","Unable to load usage statistics. Please retry."):i("正在加载用量统计…","Loading usage statistics…")),e?n.createElement("div",{style:{textAlign:"center"}},n.createElement("button",{className:"uh-refresh",onClick:on},n.createElement(N,{name:"refresh",size:14}),i("重试","Retry"))):null))}const or=null!==M&&"object"==typeof M?M:E,sr=or&&or.scan?or.scan:E.scan||{done:!0,started:!0,scanned:0,total:0,failed:0},cr=or&&or.sync?or.sync:E.sync||{},ur=Nn,dr=(e,t,a)=>{const n=Ga.current;return""===n?(a(null),Promise.resolve()):e(n).then(t,r=>null===r||"object"!=typeof r||403!==r.status?(a(r),Promise.resolve()):pt().then(i=>{const l=null!==i&&"object"==typeof i&&"string"==typeof i.requestToken?i.requestToken:"";if(""!==l&&l!==n)return Ga.current=l,e(l).then(t,()=>{a(r)});a(r)},()=>{a(r)}))},pr=(e,t)=>{""!==Ga.current&&dr(a=>{return n=e,r=String(void 0===t?"":t).trim(),fetch("/api/all-usage/alias",{method:"POST",headers:{"content-type":"application/json","x-all-usage-request-token":a},body:JSON.stringify({workspaceId:n,alias:r})}).then(e=>{if(!e.ok)throw new Error("HTTP "+e.status);return e.json()});var n,r},e=>{e&&e.ok&&e.aliases&&C(t=>null===t?t:Object.assign({},t,{aliases:e.aliases}))},()=>{})},mr=()=>{oa({}),ca({}),da(null),ma({}),ga(null),fa({}),Ea("")},hr=()=>{Zt||ea||aa||(Ta(),Va.next(),Xt(!1),Yt(!1),Sa.current=!1,mr(),ia(""))},gr=()=>{const e=Va.next();Jt(null),$t(null),Xt(!0),mr(),Ta(),ia(""),Yt(!0),Sa.current=!0,Kt(!1),gt().then(t=>{if(!Va.isCurrent(e))return;if(!t||"object"!=typeof t||!t.config)return void ia("load");const a=G(t);Jt(t),$t(a)},()=>{Va.isCurrent(e)&&ia("load")}).finally(()=>{Va.isCurrent(e)&&Xt(!1)})},br=e=>{if(null===Gt||Zt||ea||aa)return;const t=function(e,t){const a=e&&Array.isArray(e.mappings)?e.mappings:[];for(const e of a){if(!e||""===String(e.identityKey||e.usageIdentityKey||e.model||"").trim()||""===String(e.catalogModelId||"").trim())return"mapping";if(!["fresh","total","legacy"].includes(e.inputTokenSemantics||"fresh")||!ee(void 0===e.multiplier?"1":e.multiplier))return"mapping"}const n=e&&Array.isArray(e.overrides)?e.overrides:[];for(const e of n){if(!e||""===String(e.modelId||"").trim())return"override";if(!["input","output","cacheRead","cacheWrite"].every(t=>ee(e[t])))return"override";let t=0;const a=Array.isArray(e.tiers)?e.tiers:[];if(a.length>32)return"tier";for(const e of a){if(!te(e,t))return"tier";t=Number(e.size)}if(!0===e.tiered&&0===a.length)return"tier"}const r=null!=t&&"object"==typeof t?t:{};for(const e of Object.keys(r))if(""!==ke(r[e]))return"temporal";return""}(Gt,ba);if(""!==t)return void ia(t);if(function(e){try{return JSON.stringify({pricing:e}).length>204800}catch(e){return!0}}(Gt))return void ia("too-large");if(""===Ga.current)return void ia("token");const a=Va.next();Qt(!0),ia(""),dr(t=>bt(Gt,e,t),e=>{Va.isCurrent(a)&&(e&&!0===e.ok&&e.pricing?(C(t=>null===t?t:Object.assign({},t,{pricing:e.pricing})),Jt(e.pricing),$t(G(e.pricing)),mr(),hr(),Ja.current()):ia("save"))},e=>{Va.isCurrent(a)&&ia(e&&403===e.status?"stale":"save")}).finally(()=>Qt(!1))},fr=()=>{Zt||ea||aa||(""!==Ga.current?(ta(!0),ia(""),dr(e=>fetch("/api/all-usage/pricing/sync",{method:"POST",headers:{"content-type":"application/json","x-all-usage-request-token":e},body:"{}"}).then(e=>{if(!e.ok){const t=new Error("HTTP "+e.status);throw t.status=e.status,t}return e.json()}),e=>{e&&!0===e.ok&&e.pricing?(Ta(),C(t=>null===t?t:Object.assign({},t,{pricing:e.pricing})),Jt(e.pricing),$t(t=>_(t,e.pricing)),oa({}),ca({}),da(null),ma({}),fa({}),Ja.current()):ia("sync")},e=>{ia(e&&403===e.status?"stale":"sync")}).finally(()=>ta(!1))):ia("token"))},yr=(e,t,a)=>{$t(n=>null===n?n:function(e,t,a,n){if(null===e||"object"!=typeof e)return e;const r=le(e.mappings,t.identityKey);if(r<0)return e;const i=e.mappings.slice(),l={};return l[a]=n,i[r]=Object.assign({},i[r],l),Object.assign({},e,{mappings:i})}(n,e,t,a)),ia("")},xr=(e,t,a,n)=>{const r=function(e,t,a,n){const r=Array.isArray(e)?e.map(e=>Object.assign({},e)):[];if(void 0===r[t])return r;const i={};return i[a]=n,r[t]=Object.assign({},r[t],i),r}(e.tiers,t,a,n);$t(t=>null===t?t:se(t,e,{tiered:r.length>0,tiers:r})),ia("")},vr=(e,t)=>{fa(a=>Object.assign({},a,{[e.key]:t})),""===ke(t)&&$t(n=>null===n?n:se(n,e,{temporalPricing:we(t,de(a)),temporalPricingInvalid:void 0})),ia("")},wr=e=>{const t=be(e.temporalPlan,de(a))||fe(e.rates,de(a));vr(e,t)},kr=(e,t)=>{const n=e.key+"|"+t;ga(e=>e===n?null:n),"temporal"===t&&fa(t=>{if(void 0!==t[e.key])return t;const n=be(e.temporalPlan,de(a));return null===n?t:Object.assign({},t,{[e.key]:n})}),ia("")},Er=()=>ga(null),Nr=Mn.totals.input+Mn.totals.output+Mn.totals.cacheRead+Mn.totals.cacheWrite+Mn.totals.reasoning,Cr=k(Mn.totals.input,Mn.totals.cacheRead),Mr=(H(Mn.totals),V(Mn.totals,a)),Sr=function(e,t){const a=H(e);if(a.pricedCalls>0&&0===a.unpricedCalls&&0===a.ambiguousCalls&&0===a.unsupportedCalls)return"en"===t?a.pricedCalls+" priced":a.pricedCalls+" 次已计价";const n=a.unpricedCalls+a.ambiguousCalls+a.unsupportedCalls;return n>0?"en"===t?n+" unpriced":n+" 次未计价":"en"===t?"No pricing":"暂无价格"}(Mn.totals,a);let Ar="—",zr=i("查询中…","Checking…");if(null!=D)if("missing-key"===D.status)Ar=i("未配置","Not configured"),zr=i("在 设置 → 模型 中填写 DeepSeek API Key 后可见","Available after you enter a DeepSeek API key in Settings → Models");else if("unavailable"===D.status)Ar=i("不可用","Unavailable"),zr=D.message||i("DeepSeek 接口返回余额不可用","The DeepSeek API reported that balance information is unavailable");else if("error"===D.status){Ar=i("查询失败","Lookup failed");const e=D.detail?"en"===a?" ("+String(D.detail).slice(0,90)+")":"("+String(D.detail).slice(0,90)+")":"";zr=(D.message||"")+e+i(" 点“刷新”重试"," Click Refresh to try again")}else if("ok"===D.status&&Array.isArray(D.currencies)&&D.currencies.length>0){const e=D.currencies,t=e.find(e=>"CNY"===e.currency)||e[0],n=e.filter(e=>e!==t);Ar=L(t.currency,t.total,a,2);let r=null!==t.total?i("赠送 ","Granted ")+L(t.currency,t.granted,a,2)+" · "+i("充值 ","Top-up ")+L(t.currency,t.toppedUp,a,2):"";n.length>0&&(r+=(r?" | ":"")+n.map(e=>L(e.currency,e.total,a)).join(" ")),zr=r}else Ar=i("无数据","No data"),zr="";const Tr=(e,t,a,r,i,l)=>n.createElement("div",{className:"uh-card",style:{animationDelay:70*r+"ms"}},n.createElement("div",{className:"uh-card-label"},l?n.createElement(st,{iconKey:l,size:15,showTitle:!0}):i?n.createElement(N,{name:i,size:14}):null,e),n.createElement("div",{className:"uh-card-value"},t),n.createElement("div",{className:"uh-card-sub"},a)),Ir=n.createElement("div",{className:"uh-ios-metric uh-ios-metric-rate",style:{animationDelay:"280ms"}},n.createElement("div",{className:"uh-ios-metric-rate-head"},n.createElement("div",{className:"uh-ios-metric-label"},n.createElement(N,{name:"cache",size:18}),i("缓存命中率","Cache Hit Rate")),n.createElement("div",{className:"uh-ios-metric-rate-value"},Cr.toFixed(1)+"%")),n.createElement("div",{className:"uh-ios-metric-bar"},n.createElement("div",{className:"uh-ios-metric-fill",style:{width:Math.max(0,Math.min(100,Cr))+"%"}})),n.createElement("div",{className:"uh-ios-metric-rate-detail"},"en"===a?"Context reused "+v(Mn.totals.cacheRead)+" tokens":"复用上下文 "+v(Mn.totals.cacheRead)+" Token")),Rr=Dn.length>0?jn(Dn[0]):0,jr=Dn.slice(0,2).map(e=>{const t=jn(e),r=Yn.get(e.workspaceId),i=Te(void 0===r?0:r),l=je===e.workspaceId;return n.createElement("div",{key:e.workspaceId,className:"uh-wsbar"+(l?" uh-sel":""),onClick:()=>sn(e.workspaceId)},n.createElement("div",{className:"uh-wsbar-top"},n.createElement("span",{className:"uh-dot",style:{background:i}}),n.createElement("span",{className:"uh-wsbar-title"},Vn(e.workspaceId)),n.createElement("span",{className:"uh-wsbar-num"},O(v(t),t,a))),n.createElement("div",{className:"uh-barwrap uh-bar-thin"},n.createElement("div",{className:"uh-barfill",style:{width:Rr>0?Math.max(2,t/Rr*100)+"%":"0%",background:i}})))}),Dr=n.createElement("div",{className:"uh-card",style:{animationDelay:"210ms"}},n.createElement("div",{className:"uh-card-label"},n.createElement(N,{name:"folder",size:14}),i("各工作区总处理量","Total Tokens Processed by Workspace")),0===Dn.length?n.createElement("div",{className:"uh-empty",style:{padding:"8px 0"}},i("暂无数据","No data yet")):n.createElement("div",{className:"uh-wsbars"},jr,Dn.length>2?n.createElement("div",{className:"uh-card-sub"},"en"===a?"See the details table for the other "+(Dn.length-2)+" workspaces":"其余 "+(Dn.length-2)+" 个工作区见明细表"):null)),Fr=Dn.map(e=>{const t=Hn.get(e.workspaceId),r="string"==typeof Wn[e.workspaceId]?Wn[e.workspaceId]:"",l=t?t.title:i("未知工作区","Unknown workspace"),o=t?t.path:"",s=""!==r?r:l,c=""!==r?l+" · "+o:o,u=jn(e),d=k(e.input,e.cacheRead),p=Yn.get(e.workspaceId),m=Te(void 0===p?0:p),h=je===e.workspaceId;return n.createElement("div",{key:e.workspaceId,className:"uh-row"+(h?" uh-sel":""),onClick:()=>sn(e.workspaceId)},n.createElement("div",{className:"uh-row-title-wrap"},n.createElement("div",{className:"uh-ws-title"},s),n.createElement("div",{className:"uh-ws-path"},c)),n.createElement("div",{className:"uh-num"},v(e.turns)),n.createElement("div",{className:"uh-num"},v(e.input)),n.createElement("div",{className:"uh-num"},v(e.cacheRead)),n.createElement("div",{className:"uh-num"},v(e.output)),n.createElement("div",{className:"uh-num"},v(e.reasoning)),n.createElement("div",{},n.createElement("div",{className:"uh-num"},v(u)),n.createElement("div",{className:"uh-barwrap"},n.createElement("div",{className:"uh-barfill",style:{width:Rr>0?Math.max(2,u/Rr*100)+"%":"0%",background:m}}))),n.createElement("div",{className:"uh-num uh-cost-num"},V(e,a)),n.createElement("div",{className:"uh-num"},d.toFixed(1)+"%"),n.createElement("div",{className:"uh-num"},Rr>0?(u/Rr*100).toFixed(0)+"%":"0%"))}),Ur="route"===Ie?i("混合查看","Combined View"):"model"===Ie?i("按模型合并","Grouped by Model"):i("按供应商汇总","Grouped by Provider"),Wr="route"===Ie?i("供应商 / 模型","Provider / Model"):"model"===Ie?i("模型","Model"):i("供应商","Provider"),Or="model"!==yt||0===Fn.length?null:n.createElement(et,{key:"model-donut-"+yt+":"+Xa+":"+(Za||"query")+":"+Ie,title:"provider"===Ie?i("供应商用量","Provider Usage"):i("模型用量","Model Usage"),icon:"chart",language:a,items:rr}),Lr="workspace"!==yt||0===Dn.length?null:n.createElement(et,{key:"workspace-donut-"+yt+":"+Xa+":"+(Za||"query"),title:i("工作区用量","Workspace Usage"),icon:"folder",language:a,items:ir}),Pr="model"===yt?Fn.map(e=>{const t=jn(e),r=k(e.input,e.cacheRead);return n.createElement("div",{key:e.identityKey||e.model,className:"uh-model-row uh-row"},n.createElement("div",{className:"uh-row-title-wrap"},n.createElement("div",{className:"uh-ws-title uh-model-label",title:e.model},n.createElement(st,{iconKey:e.iconKey,row:e,size:18,showTitle:!0}),n.createElement("span",{className:"uh-model-text"},e.model))),n.createElement("div",{className:"uh-num"},v(e.calls)),n.createElement("div",{className:"uh-num"},v(e.input)),n.createElement("div",{className:"uh-num"},v(e.cacheRead)),n.createElement("div",{className:"uh-num"},v(e.output)),n.createElement("div",{className:"uh-num"},v(e.reasoning)),n.createElement("div",{className:"uh-num"},v(t)),n.createElement("div",{className:"uh-num uh-cost-num"},V(e,a)),n.createElement("div",{className:"uh-num"},r.toFixed(1)+"%"))}):[],Kr=Pt?n.createElement("div",{className:"uh-panel uh-anim-panel"},n.createElement("div",{className:"uh-alias-panel-head"},n.createElement("span",{},i("工作区别名","Workspace Aliases")),n.createElement("button",{className:"uh-alias-close",onClick:()=>Kt(!1)},i("关闭","Close"))),0===Un.length?n.createElement("div",{className:"uh-empty",style:{padding:"10px 0"}},i("暂无工作区","No workspaces yet")):n.createElement("div",{className:"uh-alias-list"},Un.map((e,t)=>n.createElement("div",{key:e.id,className:"uh-alias-item"},n.createElement("span",{className:"uh-dot",style:{background:Te(t)}}),n.createElement("span",{className:"uh-alias-folder",title:e.path||e.id},(!0===e.retiredBucket?i("已删除","Deleted"):e.title||e.path||e.id)+(!0===e.deleted&&!0!==e.retiredBucket?i("(已删除)"," (deleted)"):"")),n.createElement("input",{className:"uh-alias-input",value:void 0!==qt[e.id]?qt[e.id]:"",placeholder:i("项目别名","Project alias"),onChange:t=>Bt(a=>Object.assign({},a,{[e.id]:t.target.value})),onKeyDown:t=>{"Enter"===t.key&&pr(e.id,t.target.value)}})))),n.createElement("div",{className:"uh-alias-panel-foot"},n.createElement("span",{className:"uh-note"},i("回车保存单个;清空别名还原文件夹名","Press Enter to save one; clear an alias to restore the folder name")),n.createElement("button",{className:"uh-alias-ok",onClick:()=>{for(const e of Object.keys(qt)){const t="string"==typeof Wn[e]?Wn[e]:"";qt[e]!==t&&pr(e,qt[e])}Kt(!1)}},i("全部保存","Save All")))):null,qr=Qn.sync&&"object"==typeof Qn.sync?Qn.sync:{},Br=Zt||ea||aa,Hr="en"===a?["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]:["日","一","二","三","四","五","六"],Yr=er.filter(e=>!1===e.usageBacked).length,Vr=er.filter(e=>null===e.usageBacked).length,Jr="string"==typeof or.pluginVersion?or.pluginVersion:"",Gr=""!==Jr&&Jr!==r,$r=!Array.isArray(Qn.usedModels),_r=e=>{if(!0===e.temporalConfigInvalid)return i("时段异常","Peak invalid");if(!0===e.temporalRulesUnavailable)return i("峰谷计划 ","peak plan ")+e.temporalPolicyId;const t=!0===e.temporalExplicit?e.temporalRuleCount>0?i("自定义 ","custom ")+e.temporalRuleCount+i(" 条规则"," rules"):i("自定义规则","custom rules"):!0===e.temporalBuiltin?i("内置 DeepSeek 峰谷表","built-in DeepSeek peak table"):null;return null===t?i("未启用","not enabled"):"official"!==e.temporalRoute&&"mapped"!==e.temporalRoute?t+i("(该行非官方直连,暂按静态价;映射到官方条目后生效)"," (reseller route: static pricing until this row is mapped to the official entry)"):t},Xr=(e,t)=>n.createElement("td",{className:"uh-pricing-rate-cell"},((e,t)=>n.createElement("input",{type:"number",min:"0",step:"any",className:"uh-pricing-rate-input","aria-label":ne(t,a)+" · "+(e.model||e.pricingModel||""),title:i("价格单位为 USD / 1M Token","Price per 1M tokens in USD"),value:null!==e.rates&&void 0!==e.rates[t]?e.rates[t]:"",disabled:Br,onChange:a=>((e,t,a)=>{$t(n=>null===n?n:function(e,t,a,n){const r={};return r[a]=n,se(e,t,r)}(n,e,t,a)),ia("")})(e,t,a.target.value)}))(e,t)),Zr=e=>{const t=void 0!==ba[e.key]?ba[e.key]:be(e.temporalPlan,de(a)),r=null==t?"":ke(t),l=n.createElement("div",{className:"uh-pricing-tier-editor-head"},n.createElement("div",{className:"uh-pricing-tier-editor-title"},n.createElement("strong",{},i("分时段计费(北京时间 UTC+8)","Time-of-day pricing (UTC)")),n.createElement("span",{},!0===e.temporalExplicit?i("自定义规则","Custom rules"):!0===e.temporalRulesUnavailable?i("峰谷计划 ","Peak plan ")+e.temporalPolicyId:!0===e.temporalBuiltin?i("当前使用内置 DeepSeek 峰谷表","Using the built-in DeepSeek peak table"):i("未启用时段规则","No time-of-day rules"))),n.createElement("div",{className:"uh-actions"},!0===e.temporalBuiltin&&!0!==e.temporalExplicit?n.createElement("button",{type:"button",className:"uh-refresh",disabled:Br,onClick:()=>wr(e)},!0===e.temporalRulesUnavailable?i("改为自定义规则","Replace with custom rules"):i("复制内置表并自定义","Copy built-in table")):null,!0===e.temporalExplicit?n.createElement("button",{type:"button",className:"uh-refresh",disabled:Br,onClick:()=>(e=>{fa(t=>{const a=Object.assign({},t);return delete a[e.key],a}),e.overrideIndex<0||($t(t=>null===t?t:se(t,e,{temporalPricing:void 0,temporalPricingInvalid:void 0})),ia(""))})(e)},!0===e.temporalBuiltin?i("恢复内置","Restore built-in"):i("清除时段规则","Remove rules")):null,!0!==e.temporalBuiltin&&!0!==e.temporalExplicit?n.createElement("button",{type:"button",className:"uh-refresh",disabled:Br,onClick:()=>wr(e)},n.createElement(N,{name:"plus",size:13}),i("启用分时计费","Enable time-of-day pricing")):null));if(null==t)return n.createElement("div",{className:"uh-pricing-tier-editor uh-pricing-temporal-editor"},l,n.createElement("div",{className:"uh-pricing-tier-empty"},!0===e.temporalRulesUnavailable?i("该行已启用峰谷计划(","This row already uses a peak plan (")+e.temporalPolicyId+i("),但运行中的宿主尚未提供规则内容;重启 DSH 后即可查看与编辑。","), but the running host does not expose its rules yet; restart DSH to view and edit them."):i("未启用时段规则:所有请求都使用该行基础价。","No time-of-day rules: every request uses the row base rates.")));const o=me(t.effectiveFromText,de(a)),s=!0===t.holidaysEnabled?ge(t.holidaysText):null,c=t.rules.map((r,l)=>{const o=r.windows.map((a,o)=>n.createElement("div",{key:o,className:"uh-pricing-temporal-window"},n.createElement("input",{type:"text",className:"uh-pricing-time-input",placeholder:"HH:MM","aria-label":i("开始时间","Start time"),value:a.start,disabled:Br,onChange:a=>vr(e,ve(t,l,r.windows.map((e,t)=>t===o?{start:a.target.value,end:e.end}:e)))}),n.createElement("span",{className:"uh-pricing-time-sep"},"–"),n.createElement("input",{type:"text",className:"uh-pricing-time-input",placeholder:"HH:MM","aria-label":i("结束时间","End time"),value:a.end,disabled:Br,onChange:a=>vr(e,ve(t,l,r.windows.map((e,t)=>t===o?{start:e.start,end:a.target.value}:e)))}),r.windows.length>1?n.createElement("button",{type:"button",className:"uh-refresh uh-icon-button",title:i("删除时段","Remove window"),"aria-label":i("删除时段","Remove window"),disabled:Br,onClick:()=>vr(e,ve(t,l,r.windows.filter((e,t)=>t!==o)))},n.createElement(N,{name:"close",size:13})):null));return n.createElement("div",{key:r.id+":"+l,className:"uh-pricing-temporal-rule"},n.createElement("div",{className:"uh-pricing-temporal-rule-head"},n.createElement("span",{className:"uh-pricing-temporal-rule-name"},r.id),n.createElement("div",{className:"uh-pricing-weekdays"},Hr.map((a,i)=>n.createElement("button",{key:i,type:"button",className:"uh-pricing-weekday"+(r.weekdays.includes(i)?" uh-on":""),"aria-pressed":r.weekdays.includes(i),disabled:Br,onClick:()=>vr(e,function(e,t,a){const n=ye(e);if(null===n||void 0===n.rules[t])return n;const r=n.rules[t],i=Number(a);return r.weekdays=(r.weekdays.includes(i)?r.weekdays.filter(e=>e!==i):r.weekdays.concat([i])).sort((e,t)=>e-t),n}(t,l,i))},a))),n.createElement("button",{type:"button",className:"uh-refresh uh-icon-button",disabled:Br||t.rules.length<=1,title:i("删除规则","Remove rule"),"aria-label":i("删除规则","Remove rule"),onClick:()=>vr(e,function(e,t){const a=ye(e);return null===a||a.rules.length<=1||(a.rules=a.rules.filter((e,a)=>a!==t)),a}(t,l))},n.createElement(N,{name:"close",size:14}))),n.createElement("div",{className:"uh-pricing-temporal-windows"},o,r.windows.length<16?n.createElement("button",{type:"button",className:"uh-pricing-link",disabled:Br,onClick:()=>vr(e,ve(t,l,r.windows.concat([{start:"06:00",end:"10:00"}])))},i("添加时段","Add window")):null),n.createElement("div",{className:"uh-pricing-temporal-rates"},["input","output","cacheRead","cacheWrite"].map(o=>n.createElement("label",{key:o,className:"uh-pricing-temporal-rate"},n.createElement("span",{},i("峰时·","Peak ·")+ne(o,a).split(" / ")[0]),n.createElement("input",{type:"number",min:"0",step:"any",value:r.rates[o],disabled:Br,onChange:a=>vr(e,function(e,t,a){return xe(e,t,{rates:a})}(t,l,Object.assign({},r.rates,{[o]:a.target.value})))})))))});return n.createElement("div",{className:"uh-pricing-tier-editor uh-pricing-temporal-editor"},l,n.createElement("div",{className:"uh-pricing-tier-empty"},i("谷时段(未命中规则)使用该行基础价,峰时段使用规则费率;周几与时间均为 UTC。","Off-peak (no rule match) uses the row base rates, peak uses the rule rates. Weekdays and times are UTC.")),n.createElement("div",{className:"uh-pricing-temporal-fields"},n.createElement("label",{},n.createElement("span",{},i("策略 ID","Policy ID")),n.createElement("input",{type:"text",value:t.policyId,disabled:Br,onChange:a=>vr(e,Object.assign(ye(t),{policyId:a.target.value}))})),n.createElement("label",{},n.createElement("span",{},i("生效起点(北京时间,留空 = 全部历史)","Effective from (UTC, empty = all history)")),n.createElement("input",{type:"date",value:t.effectiveFromText,disabled:Br,onChange:a=>vr(e,Object.assign(ye(t),{effectiveFromText:a.target.value}))}))),null!==o&&o>0?n.createElement("div",{className:"uh-pricing-warning"},i("该时刻之前的用量没有可用档位,会失败关闭为未计价。","Usage before this instant has no applicable band and fails closed as unpriced.")):null,n.createElement("div",{className:"uh-pricing-temporal-holidays"},n.createElement("label",{className:"uh-pricing-switch"},n.createElement("input",{type:"checkbox",checked:!0===t.holidaysEnabled,disabled:Br,onChange:a=>vr(e,Object.assign(ye(t),{holidaysEnabled:a.target.checked}))}),n.createElement("span",{},i("中国法定节假日全天按谷时计价","Chinese statutory holidays price as off-peak all day"))),!0===t.holidaysEnabled?n.createElement(n.Fragment,null,n.createElement("div",{className:"uh-pricing-tier-empty"},i("每行一个日期(YYYY-MM-DD),支持区间写法 2026-10-01..2026-10-07。按北京时间(UTC+8)日历日判定;调休上班日不会被自动识别,需要你自己从列表里去掉。","One date per line (YYYY-MM-DD); ranges such as 2026-10-01..2026-10-07 are expanded. Days follow the China Standard Time (UTC+8) calendar; swapped-in working weekends are not detected, so remove them yourself.")),n.createElement("textarea",{className:"uh-pricing-holiday-input",rows:4,spellCheck:!1,disabled:Br,placeholder:"2026-10-01\n2026-10-02","aria-label":i("法定节假日日期","Statutory holiday dates"),value:t.holidaysText,onChange:a=>vr(e,Object.assign(ye(t),{holidaysText:a.target.value}))}),null===s?n.createElement("span",{className:"uh-pricing-error"},i("日期格式无效:请使用 YYYY-MM-DD,或 start..end 区间","Invalid dates: use YYYY-MM-DD, or a start..end range")):n.createElement("span",{className:"uh-pricing-tier-empty"},i("已解析 ","parsed ")+s.length+i(" 天节假日"," holiday days")),n.createElement("div",{className:"uh-pricing-holiday-load"},n.createElement("label",{className:"uh-pricing-map-field"},n.createElement("span",{},i("年份","Year")),n.createElement("input",{type:"number",min:"2000",max:"2100",step:"1",value:ya,disabled:Br||va,"aria-label":i("要载入的年份","Year to load"),onChange:e=>xa(Number(e.target.value))})),n.createElement("button",{type:"button",className:"uh-refresh",disabled:Br||va,onClick:()=>(e=>{if(!0===va)return;if(""===Ga.current)return void Ea(i("当前进程令牌不可用,请刷新看板","The process capability is unavailable; refresh the dashboard"));const t=Number(ya);!Number.isSafeInteger(t)||t<2e3||t>2100?Ea(i("年份无效(2000–2100)","Invalid year (2000-2100)")):(wa(!0),Ea(""),dr(e=>((e,t)=>fetch("/api/all-usage/pricing/holidays",{method:"POST",headers:{"content-type":"application/json","x-all-usage-request-token":t},body:JSON.stringify({year:e,backfill:!1})}).then(e=>e.json().catch(()=>({ok:!1,message:"bad-response"})).then(t=>null!==t&&"object"==typeof t?t:{ok:!1,message:"HTTP "+e.status})))(t,e),t=>{if(null===t||"object"!=typeof t||!0!==t.ok||!Array.isArray(t.dates)){const e=t&&"object"==typeof t&&"string"==typeof t.message&&""!==t.message?t.message:"unavailable";return void Ea(i("抓取失败:","Fetch failed: ")+e)}const n=void 0!==ba[e.key]?ba[e.key]:be(e.temporalPlan,de(a))||fe(e.rates,de(a)),r=function(e,t){const a=ge(e),n=null===a?[]:a.slice(),r=new Set(n);for(const e of Array.isArray(t)?t:[]){const t=String(e??"").trim();""===t||r.has(t)||(r.add(t),n.push(t))}return n.sort(),0===n.length?"":n.join("\n")}(n.holidaysText,t.dates),l=Number(t.fetchedAt),o="string"==typeof t.paperUrl&&""!==t.paperUrl?t.paperUrl:String(t.sourceUrl||""),s=Number.isFinite(l)&&l>0?new Date(l).toISOString().slice(0,16).replace("T"," "):"",c=Object.assign(ye(n),{holidaysEnabled:!0,holidaysText:r,holidaysSourceText:(o+(""===s?"":" · "+s)+(!0===t.cached?" · cached":"")).slice(0,512)});Ea(i("已载入 ","Loaded ")+t.dates.length+i(" 天"," days")+(!0===t.cached?i("(缓存)"," (cached)"):"")),vr(e,c)},()=>{Ea(i("抓取失败:网络不可用","Fetch failed: network unavailable"))}).finally(()=>wa(!1)))})(e)},n.createElement(N,{name:"refresh",size:13}),va?i("抓取中…","Fetching…"):i("从公开日历载入","Load from public calendar")),""!==ka?n.createElement("span",{className:"uh-pricing-tier-empty"},ka):null),""!==t.holidaysSourceText?n.createElement("span",{className:"uh-pricing-tier-empty",title:t.holidaysSourceText},i("来源:","Source: ")+t.holidaysSourceText):null):null),c,n.createElement("div",{className:"uh-pricing-temporal-foot"},t.rules.length<16?n.createElement("button",{type:"button",className:"uh-refresh",disabled:Br,onClick:()=>vr(e,function(e){const t=ye(e);if(null===t||t.rules.length>=16)return t;const a=t.rules.length>0?t.rules[t.rules.length-1]:null;return t.rules.push({id:"peak-"+(t.rules.length+1),weekdays:null!==a?a.weekdays.slice(0,1):[1,2,3,4,5],windows:[{start:"06:00",end:"10:00"}],rates:null!==a?Object.assign({},a.rates):{input:"",output:"",cacheRead:"",cacheWrite:""}}),t}(t))},n.createElement(N,{name:"plus",size:13}),i("添加规则","Add rule")):null,""!==r?n.createElement("span",{className:"uh-pricing-error"},i("时段规则尚未完成,保存前需修正。","The rules are incomplete; fix them before saving.")):null))},Qr=e=>{const t=null!==ha&&0===ha.indexOf(e.key+"|")?ha.slice(e.key.length+1):"";return n.createElement("div",{className:"uh-pricing-editor"},"tiers"===t?(e=>{const t=e.tiers;let r=0;const l=t.map((l,o)=>{const s=te(l,r),c=Number(null!=l&&void 0!==l.size?l.size:NaN);return Number.isSafeInteger(c)&&(r=c),n.createElement("div",{key:o,className:"uh-pricing-tier-edit-row"+(s?"":" uh-invalid")},n.createElement("input",{type:"number",min:"1",max:"1000000000",step:"1",placeholder:i("阈值 Token","Token threshold"),title:i("本档覆盖范围:","This band covers ")+Q(t,o,a),"aria-label":i("上下文阈值 Token","Context threshold tokens"),value:null==l||void 0===l.size?"":l.size,disabled:Br,onChange:t=>xr(e,o,"size",t.target.value)}),["input","output","cacheRead","cacheWrite"].map(t=>n.createElement("input",{key:t,type:"number",min:"0",step:"any",placeholder:ne(t,a),"aria-label":i("档位","Band")+" "+ne(t,a),value:null==l||void 0===l[t]?"":l[t],disabled:Br,onChange:a=>xr(e,o,t,a.target.value)})),n.createElement("button",{type:"button",className:"uh-refresh uh-icon-button",title:i("删除费率档位","Remove rate band"),"aria-label":i("删除费率档位","Remove rate band"),disabled:Br,onClick:()=>((e,t)=>{const a=function(e,t){return(Array.isArray(e)?e:[]).filter((e,a)=>a!==t).map(e=>Object.assign({},e))}(e.tiers,t);$t(t=>null===t?t:se(t,e,{tiered:a.length>0,tiers:a})),ia("")})(e,o)},n.createElement(N,{name:"close",size:14})))});return n.createElement("div",{className:"uh-pricing-tier-editor"},n.createElement("div",{className:"uh-pricing-tier-editor-head"},n.createElement("div",{className:"uh-pricing-tier-editor-title"},n.createElement("strong",{},i("上下文费率档位","Context rate bands")),n.createElement("span",{},i("输入上下文超过阈值后,整次请求使用该档四项费率","Above a threshold, all four rates apply to the whole request"))),n.createElement("button",{type:"button",className:"uh-refresh",disabled:Br||t.length>=32,title:t.length>=32?i("每个模型最多 32 个档位","Maximum 32 bands per model"):i("添加上下文费率档位","Add context rate band"),onClick:()=>(e=>{const t=function(e,t){const a=Array.isArray(e)?e.map(e=>Object.assign({},e)):[];if(a.length>=32)return a;const n=a.length>0?a[a.length-1]:null,r=null!==n&&Number.isFinite(Number(n.size))?Number(n.size):1e5,i=null!==n?n:null!==t&&"object"==typeof t?t:{};return a.push({type:"context",size:Math.min(1e9,r+1e5),input:ae(i.input),output:ae(i.output),cacheRead:ae(i.cacheRead),cacheWrite:ae(i.cacheWrite)}),a}(e.tiers,e.rates);$t(a=>null===a?a:se(a,e,{tiered:t.length>0,tiers:t})),ia("")})(e)},n.createElement(N,{name:"plus",size:13}),i("添加档位","Add band"))),0===t.length?n.createElement("div",{className:"uh-pricing-tier-empty"},i("未配置档位,所有上下文使用基础费率。","No bands configured; base rates apply to every context.")):n.createElement(n.Fragment,null,n.createElement("div",{className:"uh-pricing-tier-edit-head"},n.createElement("span",{},i("超过 Token","Above tokens")),n.createElement("span",{},i("输入 / 1M","Input / 1M")),n.createElement("span",{},i("输出 / 1M","Output / 1M")),n.createElement("span",{},i("缓存读 / 1M","Cache read / 1M")),n.createElement("span",{},i("缓存写 / 1M","Cache write / 1M")),n.createElement("span",{},"")),l))})(e):null,"temporal"===t?Zr(e):null,n.createElement("div",{className:"uh-pricing-editor-foot"},n.createElement("button",{type:"button",className:"uh-pricing-link",onClick:Er},i("收起","Collapse"))))},ei=e=>sa[e.key],ti=e=>{const t=null!==ha&&0===ha.indexOf(e.key+"|")?ha:null,r=ei(e),l=Array.isArray(la[e.key])?la[e.key]:[];return n.createElement(n.Fragment,{key:e.key},n.createElement("tr",{className:"uh-pricing-model-row"+(!0===e.usageBacked?"":!1===e.usageBacked?" uh-pricing-configured-row":" uh-pricing-unknown-row")},n.createElement("td",{className:"uh-pricing-model-name"},n.createElement("span",{className:"uh-model-label",title:e.model},n.createElement(st,{row:e.row,size:16}),n.createElement("span",{className:"uh-model-text"},e.model||i("未知模型","Unknown model"))),n.createElement("div",{className:"uh-pricing-row-flags"},n.createElement("span",{className:"uh-pricing-status uh-pricing-status-"+e.status,title:e.reason||""},X(e.status,a)),n.createElement("span",{className:"uh-pricing-tier-badge uh-flat"},(e=>!0===e.temporalConfigInvalid?i("时段配置异常","Peak plan invalid"):!0===e.tieredInvalid?i("档位异常","Bands invalid"):"manual"===e.source?i("手工价","Manual"):!0===e.temporalExplicit?i("自定义峰谷","Custom peak"):!0===e.temporalBuiltin?i("内置峰谷","Built-in peak"):"priced"===e.status?i("目录价","Catalog"):X(e.status,a))(e)),e.mapped?n.createElement("span",{className:"uh-pricing-flag"},i("已映射","Mapped")):null,!0===e.usageBacked?null:!1===e.usageBacked?n.createElement("span",{className:"uh-pricing-flag"},i("账本无用量","No ledger usage")):n.createElement("span",{className:"uh-pricing-flag uh-pricing-flag-unknown",title:i("宿主未在模型清单里标注账本用量(通常是宿主插件版本较旧);这不代表没有用量","The host did not label ledger usage for this row (usually an older host plugin); it does not mean the row has none")},i("用量未知","Usage unknown")))),n.createElement("td",{className:"uh-pricing-map-cell"},n.createElement("div",{className:"uh-pricing-model-search"},n.createElement("input",{type:"text",className:"uh-pricing-model-search-input",placeholder:!0===e.mappable?i("输入官方模型 ID 检索","Type an official model ID"):i("该行不是账本路线","Not a ledger route"),value:void 0!==r?r:e.pricingModel||"",disabled:Br||!0!==e.mappable,"aria-label":i("官方模型 ID","Official model ID"),"aria-autocomplete":"list",onFocus:t=>{if(!0!==e.mappable||!0===Br)return;da(e.key);const a=t.target;if(null!=a&&"function"==typeof a.select){try{a.select()}catch(e){}"function"==typeof requestAnimationFrame&&requestAnimationFrame(()=>{try{a.select()}catch(e){}})}},onBlur:()=>setTimeout(()=>{da(t=>t===e.key?null:t),ca(t=>{const a=Object.assign({},t);return delete a[e.key],a})},140),onKeyDown:e=>{"Escape"===e.key&&da(null)},onChange:t=>((e,t)=>{const a=e.key,n=Ca.current;ca(e=>Object.assign({},e,{[a]:t})),da(a);const r=Ma.current[a];void 0!==r&&(clearTimeout(r),delete Ma.current[a]);const i=(Na.current[a]||0)+1;if(Na.current[a]=i,""===String(t||"").trim())return void oa(e=>Object.assign({},e,{[a]:[]}));const l=setTimeout(()=>{delete Ma.current[a],(e=>{const t=new URLSearchParams({q:String(e||"").slice(0,120),limit:"30"});return fetch("/api/all-usage/pricing/models?"+t.toString(),{headers:{accept:"application/json"}}).then(e=>{if(!e.ok)throw new Error("HTTP "+e.status);return e.json()})})(t).then(e=>{Ca.current===n&&Na.current[a]===i&&oa(t=>Object.assign({},t,{[a]:Array.isArray(e&&e.items)?e.items:[]}))},()=>{Ca.current===n&&Na.current[a]===i&&oa(e=>Object.assign({},e,{[a]:[]}))})},180);Ma.current[a]=l})(e,t.target.value)}),ua===e.key&&l.length>0?n.createElement("div",{className:"uh-language-options uh-pricing-model-options",role:"listbox","aria-label":i("官方模型匹配结果","Official model matches")},l.map(t=>n.createElement("button",{key:t.value,type:"button",role:"option",className:"uh-language-option uh-pricing-model-option",onMouseDown:e=>e.preventDefault(),onClick:()=>((e,t)=>{if(!t||"string"!=typeof t.value)return;const a=Ma.current[e.key];void 0!==a&&(clearTimeout(a),delete Ma.current[e.key]),Na.current[e.key]=(Na.current[e.key]||0)+1,$t(a=>null===a?a:function(e,t,a){const n=null!==e&&"object"==typeof e?e:{sync:{},mappings:[],overrides:[]};if(!0!==t.mappable||null==a||"string"!=typeof a.value)return n;const r=Array.isArray(n.mappings)?n.mappings.map(e=>Object.assign({},e)):[],i=le(r,t.identityKey),l={identityKey:t.identityKey,provider:null!==t.row&&"object"==typeof t.row&&"string"==typeof t.row.provider?t.row.provider:"",model:null!==t.row&&"object"==typeof t.row&&(t.row.actualModel||t.row.requestedModel)||"",catalogProviderId:"string"==typeof a.providerId?a.providerId:"",catalogModelId:a.value};return i<0?r.push(Object.assign({inputTokenSemantics:"fresh",multiplier:"1"},l)):r[i]=Object.assign({},r[i],l),Object.assign({},n,{mappings:r})}(a,e,t)),ma(a=>Object.assign({},a,{[e.key]:t})),ca(a=>Object.assign({},a,{[e.key]:t.label||t.value})),da(null),ia("")})(e,t)},n.createElement(N,{name:"list",size:14}),n.createElement("span",{className:"uh-pricing-model-option-name"},t.label||t.value),n.createElement("span",{className:"uh-pricing-model-option-id"},t.value+(!0===t.tiered?" · "+i("分层 ","tiered ")+t.tierCount:"")+(!0===t.builtinTemporal?" · "+i("峰谷","peak"):""))))):null,e.mapped?n.createElement("button",{type:"button",className:"uh-pricing-link uh-pricing-clear-mapping",disabled:Br,title:i("删除该行的官方模型映射,回到按模型自动匹配","Remove this row mapping and fall back to automatic model matching"),onClick:()=>(e=>{$t(t=>null===t?t:function(e,t){if(null===e||"object"!=typeof e)return e;const a=le(e.mappings,t);if(a<0)return e;const n=e.mappings.slice();return n.splice(a,1),Object.assign({},e,{mappings:n})}(t,e.identityKey)),ma(t=>{const a=Object.assign({},t);return delete a[e.key],a}),ca(t=>{const a=Object.assign({},t);return delete a[e.key],a}),ia("")})(e)},i("清除映射","Clear mapping")):null),n.createElement("div",{className:"uh-pricing-map-sub"},n.createElement("label",{className:"uh-pricing-map-field"},n.createElement("span",{},i("倍率","Multiplier")),n.createElement("input",{type:"number",min:"0",step:"any",value:e.multiplier,disabled:Br||!0!==e.mapped,title:!0===e.mapped?i("成本倍率,只作用于最终总价","Cost multiplier; applied to the final total only"):i("设置映射后生效","Effective after a mapping is set"),"aria-label":i("成本倍率","Cost multiplier"),onChange:t=>yr(e,"multiplier",t.target.value)})),n.createElement("label",{className:"uh-pricing-map-field"},n.createElement("span",{},i("输入口径","Input semantics")),n.createElement("select",{value:e.inputTokenSemantics,disabled:Br||!0!==e.mapped,"aria-label":i("输入口径","Input semantics"),title:Z(e.inputTokenSemantics,a),onChange:t=>yr(e,"inputTokenSemantics",t.target.value)},n.createElement("option",{value:"fresh"},"Fresh"),n.createElement("option",{value:"total"},"Total"),n.createElement("option",{value:"legacy"},"Legacy"))))),Xr(e,"input"),Xr(e,"output"),Xr(e,"cacheRead"),Xr(e,"cacheWrite"),n.createElement("td",{className:"uh-pricing-row-actions"},n.createElement("button",{type:"button",className:"uh-pricing-chip"+(null!==t&&"tiers"===t.slice(e.key.length+1)?" uh-on":"")+(e.tierCount>0?" uh-strong":""),disabled:Br,title:e.tierCount>0?i("上下文分层:已配置 ","Context tiers: ")+e.tierCount+i(" 个档位"," bands"):i("上下文分层:未配置,所有上下文使用基础费率","Context tiers: none, base rates apply to every context"),onClick:()=>kr(e,"tiers")},i("上下文分层","Context tiers")),n.createElement("button",{type:"button",className:"uh-pricing-chip"+(null!==t&&"temporal"===t.slice(e.key.length+1)?" uh-on":"")+(!0===e.temporalBuiltin||!0===e.temporalExplicit?" uh-strong":""),disabled:Br,title:i("时间分层:","Time tiers: ")+_r(e),onClick:()=>kr(e,"temporal")},i("时间分层","Time tiers")),"manual"===e.source?n.createElement("button",{type:"button",className:"uh-pricing-link",disabled:Br,title:i("删除手工价,回落到目录价或内置峰谷","Remove the manual price and fall back to the catalog or the built-in peak table"),onClick:()=>(e=>{$t(t=>null===t?t:function(e,t){if(null===e||"object"!=typeof e)return e;const a=ie(e.overrides,t);if(a<0)return e;const n=e.overrides.slice();return n.splice(a,1),Object.assign({},e,{overrides:n})}(t,e.basis)),fa(t=>{const a=Object.assign({},t);return delete a[e.key],a}),ia("")})(e)},i("恢复默认","Reset")):null)),null===t?null:n.createElement("tr",{className:"uh-pricing-editor-row"},n.createElement("td",{colSpan:7},Qr(e))))},ai=Ht?n.createElement(lt,{revision:nr,render:()=>{return null!==Gt?n.createElement("div",{className:"uh-panel uh-pricing-panel uh-anim-panel"},n.createElement("div",{className:"uh-pricing-head"},n.createElement("div",{className:"uh-title-with-icon"},n.createElement(N,{name:"wallet",size:16}),n.createElement("strong",{},i("成本统计设置","Cost Statistics"))),n.createElement("button",{type:"button",className:"uh-refresh uh-icon-button",title:i("关闭成本设置","Close cost settings"),"aria-label":i("关闭成本设置","Close cost settings"),disabled:Br,onClick:hr},n.createElement(N,{name:"close",size:16}))),n.createElement("div",{className:"uh-pricing-note"},i("价格单位为 USD / 1M Token。直接改价格框即创建或更新手工价(同一官方模型的所有行共享同一价格);「官方模型」列选定映射后该行自动改用官方目录价;「档位」配置上下文费率档,「分时计费」配置 UTC 峰谷规则。","Prices are USD per 1M tokens. Editing a price box creates or updates a manual price (every row priced from the same official model shares it). Picking an official model in the mapping column switches the row to the catalog price. Bands add context-dependent rates; Time-of-day adds UTC peak rules.")),n.createElement("div",{className:"uh-pricing-toolbar"},n.createElement("label",{className:"uh-pricing-switch"},n.createElement("input",{type:"checkbox",checked:!0===Gt.sync.autoEnabled,disabled:Br,onChange:e=>(e=>{if(null===Gt||aa||Zt||ea)return;const t=!0===e,a=Gt.sync&&!0===Gt.sync.autoEnabled;if($t(e=>null===e?e:Object.assign({},e,{sync:Object.assign({},e.sync,{autoEnabled:t})})),wt({pricingAutoSync:t}),""===Ga.current)return $t(e=>null===e?e:Object.assign({},e,{sync:Object.assign({},e.sync,{autoEnabled:a})})),wt({pricingAutoSync:a}),void ia("token");const n=e=>{$t(e=>null===e?e:Object.assign({},e,{sync:Object.assign({},e.sync,{autoEnabled:a})})),wt({pricingAutoSync:a}),ia(e)};na(!0),ia(""),dr(e=>bt({sync:{autoEnabled:t}},!1,e),e=>{if(!e||!0!==e.ok||!e.pricing)return void n("save");const t=e.pricing.sync&&!0===e.pricing.sync.autoEnabled;C(t=>null===t?t:Object.assign({},t,{pricing:e.pricing})),Jt(e.pricing),$t(a=>null===a?a:Object.assign({},a,{sync:Object.assign({},a.sync,{autoEnabled:t,intervalMs:e.pricing.sync&&e.pricing.sync.intervalMs})})),wt({pricingAutoSync:t})},e=>n(e&&403===e.status?"stale":"save")).finally(()=>na(!1))})(e.target.checked)}),n.createElement("span",{},i("启用 6 小时自动同步","Enable 6-hour automatic sync"))),n.createElement("span",{className:"uh-note"},aa?i("保存中…","Saving…"):qr.lastSuccessAt>0?i("上次成功:","Last success: ")+new Date(qr.lastSuccessAt).toLocaleString():i("尚未同步","Not synced yet")),n.createElement("button",{type:"button",className:"uh-refresh",onClick:fr,disabled:Br},n.createElement(N,{name:"refresh",size:14}),ea?i("同步中…","Syncing…"):i("立即同步","Sync now"))),qr.lastError?n.createElement("div",{className:"uh-pricing-error",role:"alert"},i("上次同步失败:","Last sync failed: ")+qr.lastError):null,Gr?n.createElement("div",{className:"uh-pricing-error",role:"status"},i("宿主插件 v","Host plugin v")+Jr+i(" 与当前页面 v"," and this page v")+r+i(" 不一致:DSH 只在启动时加载插件,请重启 DSH 让新版本生效(本面板正按旧宿主的数据降级显示)"," differ: DSH imports the plugin only at startup, so restart DSH for the new version (this panel is showing the older host payload)")):null,$r?n.createElement("div",{className:"uh-pricing-error",role:"status"},i("宿主未提供模型清单(插件版本较旧):无法列出账本模型;请重启 DSH 后重新打开本面板","The host sent no model list (older plugin): the ledger models cannot be listed; restart DSH and reopen this panel")):null,n.createElement("div",{className:"uh-pricing-table-note"},i("共 ","")+er.length+i(" 个模型"," models")+(Yr>0?i("("," (")+Yr+i(" 项仅存在于配置中,账本暂无用量)"," configured rows have no ledger usage)"):"")+(Vr>0?i("(其中 "," (")+Vr+i(" 项用量未知:宿主未标注账本用量)"," rows have unknown usage: the host did not label ledger usage)"):"")+(er.length>=500?i(" · 已达 500 行上限"," · capped at 500 rows"):"")),n.createElement("div",{className:"uh-pricing-table-wrap"},n.createElement("table",{className:"uh-pricing-model-table uh-pricing-price-table"},n.createElement("thead",{},n.createElement("tr",{},n.createElement("th",{scope:"col"},i("模型","Model")),n.createElement("th",{scope:"col"},i("官方模型 / 映射","Official model / mapping")),n.createElement("th",{scope:"col"},i("输入 / 1M","Input / 1M")),n.createElement("th",{scope:"col"},i("输出 / 1M","Output / 1M")),n.createElement("th",{scope:"col"},i("缓存读 / 1M","Cache read / 1M")),n.createElement("th",{scope:"col"},i("缓存写 / 1M","Cache write / 1M")),n.createElement("th",{scope:"col"},i("操作","Actions")))),n.createElement("tbody",{},0===er.length?n.createElement("tr",{},n.createElement("td",{colSpan:7},n.createElement("div",{className:"uh-empty",style:{padding:"12px 0"}},i("暂无模型用量","No model usage yet")))):er.map(e=>n.createElement(ot,{key:e.key,view:e,busy:Br,language:a,openSection:null!==ha&&0===ha.indexOf(e.key+"|")?ha:null,searchText:void 0===ei(e)?null:ei(e),searchOpen:ua===e.key,searchOptions:Array.isArray(la[e.key])?la[e.key]:null,temporalDraft:void 0===ba[e.key]?null:ba[e.key],temporalPlan:e.temporalPlan,holidayStatus:ka,holidayLoading:va,render:ti}))))),""!==ra?n.createElement("div",{className:"uh-pricing-error",role:"alert"},"stale"===(e=ra)?i("写入被拒绝:进程令牌已失效,自动重取令牌后仍失败,请刷新看板","Write rejected: the process capability had rotated and the automatic retry still failed; refresh the dashboard"):"forbidden"===e?i("写入被拒绝:权限校验未通过(也可能是进程令牌已失效),请刷新看板后重试","Write rejected: the permission check failed (a stale process capability is also possible); refresh the dashboard and retry"):"token"===e?i("当前进程令牌不可用,请刷新看板","The process capability is unavailable; refresh the dashboard"):"load"===e?i("完整费率设置加载失败","Full pricing settings could not be loaded"):"sync"===e?i("models.dev 同步失败,已保留上次成功目录和未保存编辑","models.dev sync failed; the last good catalog and unsaved edits were kept"):"mapping"===e?i("模型映射无效:请选择官方模型并填写有效倍率","Invalid mapping: pick an official model and enter a valid multiplier"):"tier"===e?i("费率档位无效:最多 32 档;阈值必须为递增的正整数,四项费率必须完整且非负","Invalid rate bands: maximum 32; thresholds must be increasing positive integers and all four rates must be complete and non-negative"):"temporal"===e?i("分时计费无效:需要策略 ID,每规则至少一个周几与一个时段,时间格式 HH:MM 且结束大于开始,同周几的时段不得重叠,四项费率必须完整","Invalid time-of-day rules: a policy ID, at least one weekday and window per rule, HH:MM times with the end after the start, no overlapping windows on the same weekday, and all four rates filled in"):"override"===e?i("价格无效:请填写完整的非负基础费率","Invalid price: enter all non-negative base rates"):"too-large"===e?i("成本设置过大,无法保存:请精简档位或时段规则","The cost settings are too large to save: trim bands or peak rules"):i("成本设置保存失败,请检查输入","Cost settings could not be saved; check the inputs")):null,n.createElement("div",{className:"uh-pricing-foot"},n.createElement("span",{className:"uh-note"},i("保存只影响未计价调用与之后的调用,已有正成本不会重算;改动时段规则会按新政策重新对账该模型历史。","Saving affects unpriced and future calls only; existing positive costs are never recalculated. Changing a peak plan reconciles that model history against the new rules.")),n.createElement("div",{className:"uh-actions"},n.createElement("button",{type:"button",className:"uh-refresh",disabled:Br,onClick:hr},i("取消","Cancel")),n.createElement("button",{type:"button",className:"uh-refresh",disabled:Br,onClick:()=>br(!1)},Zt?i("保存中…","Saving…"):i("保存","Save")),n.createElement("button",{type:"button",className:"uh-refresh uh-pricing-backfill",disabled:Br,onClick:()=>br(!0)},i("保存并回填","Save and backfill"))))):n.createElement("div",{className:"uh-panel uh-pricing-panel uh-anim-panel"},n.createElement("div",{className:"uh-pricing-head"},n.createElement("div",{className:"uh-title-with-icon"},n.createElement(N,{name:"wallet",size:16}),n.createElement("strong",{},i("成本统计设置","Cost Statistics"))),n.createElement("button",{type:"button",className:"uh-refresh uh-icon-button",title:i("关闭成本设置","Close cost settings"),"aria-label":i("关闭成本设置","Close cost settings"),disabled:Br,onClick:hr},n.createElement(N,{name:"close",size:16}))),_t?n.createElement("div",{className:"uh-empty",role:"status",style:{display:"flex",alignItems:"center",justifyContent:"center",gap:10}},n.createElement("span",{className:"uh-trend-spinner","aria-hidden":!0}),n.createElement("span",{},i("正在加载完整费率设置…","Loading full pricing settings…"))):n.createElement("div",{className:"uh-empty",role:"alert"},n.createElement("div",{},i("完整费率设置加载失败","Full pricing settings could not be loaded")),n.createElement("button",{type:"button",className:"uh-refresh",style:{marginTop:10},onClick:gr},n.createElement(N,{name:"refresh",size:14}),i("重试","Retry"))));var e}}):null,ni=function(e,t){const a=null!==t&&"object"==typeof t?t:{},n="string"==typeof a.current&&""!==a.current?a.current:"string"==typeof e?e:"",r="string"==typeof a.latest&&""!==a.latest?a.latest:null,i="outdated"===a.status||"latest"===a.status?a.status:"unknown",l=Number(a.checkedAt);return{current:n,latest:r,status:null===r?"unknown":i,checkedAt:Number.isFinite(l)&&l>0?l:null,sourceUrl:"string"==typeof a.sourceUrl?a.sourceUrl:"",error:"string"==typeof a.error?a.error:""}}(null!==E&&"string"==typeof E.pluginVersion?E.pluginVersion:r,ce),ri="latest"===ni.status?i("已是最新","Up to date"):"outdated"===ni.status&&null!==ni.latest?i("最新 v","Latest v")+ni.latest:"",ii=i("当前版本 v","Running version v")+ni.current+("latest"===ni.status?i("\n已是最新版本","\nThis is the newest release"):"")+("outdated"===ni.status&&null!==ni.latest?i("\n最新版本 v","\nNewest release v")+ni.latest:"")+("unknown"===ni.status&&"endpoint"===pe?i("\n宿主尚未提供版本检查(运行中的插件较早):重启 DSH 后可用","\nThe host does not provide the version check yet (an older plugin is running): restart DSH"):"unknown"===ni.status?i("\n尚未确认是否有新版本","\nWhether a newer release exists is not confirmed"):"")+(null!==ni.checkedAt?i("\n检查时间:","\nChecked: ")+new Date(ni.checkedAt).toLocaleString():"")+(""!==ni.error?i("\n版本检查失败:","\nVersion check failed: ")+ni.error:"")+i("\n点击打开 GitHub 仓库","\nClick to open the GitHub repository"),li=n.createElement("button",{type:"button",className:"uh-version"+("outdated"===ni.status?" uh-version-outdated":""),title:ii,"aria-label":ii,onClick:()=>{try{window.open("https://github.com/ParticleLight/dsh-all-usage","_blank","noopener,noreferrer")}catch(e){}}},n.createElement("span",{className:"uh-version-number"},"v"+ni.current),""===ri?null:n.createElement("span",{className:"uh-version-status"},ri)),oi="custom"===P&&null!==hn?"en"===a?hn.start+" to "+hn.end+" (UTC)":hn.start+" 至 "+hn.end:"today"===P?i("今日","Today"):"7d"===P?i("近 7 天","Last 7 Days"):"30d"===P?i("近 30 天","Last 30 Days"):"90d"===P?i("近 90 天","Last 90 Days"):i("全部","All Time"),si=function(e,t,a){if("custom"!==e)return e;const n=p(t,a);return null===n?"custom":"custom-"+n.start+"-to-"+n.end}(P,hn,l),ci="invalid"===gn?i("请选择有效的开始日期和结束日期","Choose valid start and end dates"):"order"===gn?i("结束日期不能早于开始日期","End date must be on or after the start date"):"bounds"===gn?i("可选范围为 "+mn+" 至 "+x,"Choose a date from "+mn+" to "+x):"",ui=Ae?n.createElement("div",{className:"uh-custom-range",role:"group","aria-label":i("自定义时间范围","Custom date range")},n.createElement("div",{className:"uh-custom-range-meta"},n.createElement("div",{className:"uh-custom-range-title"},n.createElement(N,{name:"calendar",size:15}),i("自定义时间范围","Custom date range")),n.createElement("div",{className:"uh-custom-range-note"},i("可查看全部可扫描历史日数据;中文按本地日期,English 按 UTC。热力图可切换最近 30 天 / 90 天 / 12 个月。","All available historical daily data can be selected. Chinese uses local dates; English uses UTC. The heatmap switches between the last 30 days, 90 days and 12 months."))),n.createElement("div",{className:"uh-custom-range-fields"},n.createElement("label",{className:"uh-custom-range-field"},n.createElement("span",{},i("开始日期","Start date")),n.createElement("input",{type:"date",value:Me.start,min:mn,max:x,onChange:e=>Se(t=>Object.assign({},t,{start:e.target.value}))})),n.createElement("label",{className:"uh-custom-range-field"},n.createElement("span",{},i("结束日期","End date")),n.createElement("input",{type:"date",value:Me.end,min:mn,max:x,onChange:e=>Se(t=>Object.assign({},t,{end:e.target.value}))}))),n.createElement("div",{className:"uh-custom-range-actions"},n.createElement("button",{type:"button",className:"uh-custom-range-cancel",onClick:()=>ze(!1)},i("取消","Cancel")),n.createElement("button",{type:"button",className:"uh-custom-range-apply",disabled:""!==gn,onClick:()=>{if(""!==gn)return;const e=p(Me,l);null!==e&&(Ne(e),K("custom"),ze(!1))}},i("应用","Apply"))),""!==ci?n.createElement("div",{className:"uh-custom-range-error",role:"alert"},ci):null):null,di=n.createElement(at,{key:ar,rows:tr,visible:dt,language:a,rangeLabel:oi,loading:Ze&&!yn,error:""===tt||"stale"===tt||En?"":i("趋势数据加载失败","Trend data unavailable"),onToggle:lr,onPointClick:rn}),pi=null===Qa?oi:Qa.start===Qa.end?Qa.start:Qa.start+" → "+Qa.end,mi=n.createElement(ct,{visible:"logs"===yt,panelRef:Da,scopeLabel:pi,scopeUtc:!(!Qa||!Qa.utc),scopeAvailable:null!==Qa,loading:Dt,exporting:Ut,error:Ot,rows:Mt,selectedId:Nt,hasMore:Tt,language:a,actionKey:en+":"+(Za||"")+":"+(At||""),onExport:async()=>{if("logs"!==yt||null===Qa||Ut)return;const e=Za;Wt(!0),Lt("");try{let t=null;const a=[];for(let n=0;n<50;n+=1){const n=await ht(Qa,t,200);if(null===n||"object"!=typeof n||!Array.isArray(n.items)||null===e||y(n)!==e)throw new Error("audit export stale");if(a.push(...n.items),!n.hasMore||!n.nextCursor)break;t=n.nextCursor}const n=e=>'"'+String(e??"").replace(/"/g,'""')+'"',r=e=>e.map(n).join(","),l=[i("时间","Time"),i("日期","Date"),i("Provider","Provider"),i("请求模型","Requested model"),i("实际模型","Actual model"),i("显示模型","Display model"),"turn","step","seq",i("输入","Input"),i("缓存命中","Cache read"),i("缓存写入","Cache write"),i("输出","Output"),i("推理","Reasoning"),i("成本","Cost"),i("计价状态","Cost status"),i("计价模型","Pricing model"),i("计费档位","Billing band"),i("计费时刻(UTC)","Billing time (UTC)"),i("计费时间来源","Billing time source"),i("计费策略","Billing policy"),i("策略哈希","Policy hash"),i("来源","Source")],o=[r([i("DSH 用量明细导出","DSH Usage Audit Export")]),r([i("范围","Scope"),Qa.start+" → "+Qa.end]),r([i("时区","Timezone"),Qa.utc?"UTC":i("本地","Local")]),r(l)];for(const e of a)o.push(r([e.time,e.date,e.provider,e.requestedModel,e.actualModel,e.model,e.turn,e.step,e.seq,it(e,"input"),it(e,"cacheRead"),it(e,"cacheWrite"),it(e,"output"),it(e,"reasoning"),e.cost&&"priced"===e.cost.status?e.cost.total:"",e.cost&&e.cost.status?e.cost.status:"unpriced",e.cost&&e.cost.pricingModel?e.cost.pricingModel:"",e.cost&&e.cost.pricingBand?e.cost.pricingBand:"",e.cost&&Number.isFinite(e.cost.pricingAt)?new Date(e.cost.pricingAt).toISOString():"",e.cost&&e.cost.pricingTimeSource?e.cost.pricingTimeSource:"",e.cost&&e.cost.pricingPolicyId?e.cost.pricingPolicyId:"",e.cost&&e.cost.pricingPolicyHash?e.cost.pricingPolicyHash:"",e.materialization||"unknown"]));const s=new Blob(["\ufeff"+o.join("\r\n")],{type:"text/csv;charset=utf-8"}),c=URL.createObjectURL(s),u=document.createElement("a");u.href=c,u.download="dsh-all-usage-audit-"+Qa.start+"-to-"+Qa.end+".csv",document.body.appendChild(u),u.click(),u.remove(),URL.revokeObjectURL(c)}catch(e){Lt("audit-export")}finally{Wt(!1)}},onLoadMore:()=>{if("logs"!==yt||null===Qa||null===At||Dt)return;const e=Ya.next(),t=Za;Ft(!0),ht(Qa,At,20).then(a=>{if(Ya.isCurrent(e)){if(null===a||"object"!=typeof a||!Array.isArray(a.items)||null===t||y(a)!==t)return Lt("stale"),Ft(!1),void jt(e=>e+1);St(e=>e.concat(a.items)),zt(a.nextCursor||null),It(!0===a.hasMore&&a.items.length>0),Ft(!1),Lt("")}},t=>{if(Ya.isCurrent(e)){if(t&&409===t.status)return Ft(!1),zt(null),It(!1),Lt("stale"),void jt(e=>e+1);Ft(!1),Lt("audit")}})},onSelect:Ct}),hi=!sr.done,gi=sr.total>0?Math.min(100,Math.round(sr.scanned/sr.total*100)):40,bi=sr.done&&0===ur.length&&0===Mn.totals.turns&&0===Mn.totals.calls,fi="number"==typeof cr.lastCompletedAt&&cr.lastCompletedAt>0?new Date(cr.lastCompletedAt).toLocaleString("en"===a?"en-US":"zh-CN"):"",yi=R>0?new Date(R).toLocaleString("en"===a?"en-US":"zh-CN"):"",xi=""===fi?void 0:"en"===a?"Historical scan completed "+fi:"历史扫描完成于 "+fi,vi="en"===a?(""!==yi?"Updated "+yi:hi?"Refreshing data":"Update state pending")+" · "+(cr.sessionsSkippedByRevision||0)+" revision reused · "+(cr.sessionsRead||0)+" read"+((cr.sessionsRestoredFromLedger||0)>0?" · "+cr.sessionsRestoredFromLedger+" ledger restored":"")+((cr.sessionsFailed||0)>0?" · "+cr.sessionsFailed+" failed":"")+" · "+(!0===cr.persistenceSnapshotsAvailable?"revision optimization on":"full-read fallback"):(""!==yi?"已更新 "+yi:hi?"正在更新数据":"数据更新准备中")+" · revision 复用 "+(cr.sessionsSkippedByRevision||0)+" · 实际读取 "+(cr.sessionsRead||0)+((cr.sessionsRestoredFromLedger||0)>0?" · 账本恢复 "+cr.sessionsRestoredFromLedger:"")+((cr.sessionsFailed||0)>0?" · 失败 "+cr.sessionsFailed:"")+" · "+(!0===cr.persistenceSnapshotsAvailable?"免读优化已启用":"全量读取回退"),wi=""===A?"":"en"===a?"Usage data may be stale"+(""!==yi?"; last full update "+yi:""):"用量数据可能已过期"+(""!==yi?";上次完整更新 "+yi:"");return n.createElement("div",{className:"uh-page"},n.createElement("div",{className:"uh-head"},n.createElement("div",{className:"uh-title-wrap"},n.createElement("h2",{className:"uh-title"},i("用量统计","Usage Statistics")),li),n.createElement("div",{className:"uh-actions"},n.createElement("button",{className:"uh-refresh",title:i("管理工作区别名","Manage workspace aliases"),onClick:()=>{Pt?Kt(!1):(()=>{const e={};Un.forEach(t=>{e[t.id]="string"==typeof Wn[t.id]?Wn[t.id]:""}),Bt(e),Kt(!0)})()}},n.createElement(N,{name:"edit",size:14}),i("工作区别名","Workspace Aliases")),n.createElement("button",{className:"uh-refresh",title:i("配置模型价格与同步","Configure model prices and sync"),disabled:Zt||ea||aa,onClick:()=>{Ht?hr():gr()}},n.createElement(N,{name:"wallet",size:14}),i("成本设置","Cost Settings")),n.createElement("div",{className:"uh-language-menu"+(Ia?" uh-open":""),ref:ja,onKeyDown:e=>{"Escape"===e.key&&(e.preventDefault(),Ra(!1))}},n.createElement("button",{type:"button",className:"uh-language-trigger"+(Ia?" uh-open":""),title:i("切换界面语言","Change interface language"),"aria-label":i("界面语言","Interface language"),"aria-haspopup":"menu","aria-expanded":Ia,onClick:()=>Ra(e=>!e)},n.createElement(N,{name:"language",size:14}),n.createElement("span",{className:"uh-language-label"},"en"===a?"English":"中文"),n.createElement(N,{name:"chevron",size:13,className:"uh-language-caret"})),Ia?n.createElement("div",{className:"uh-language-options",role:"menu","aria-label":i("界面语言","Interface language")},[["zh","中文"],["en","English"]].map(t=>n.createElement("button",{key:t[0],type:"button",role:"menuitemradio","aria-checked":a===t[0],className:"uh-language-option"+(a===t[0]?" uh-on":""),onClick:()=>((t=>{"function"==typeof e.onLanguageChange&&e.onLanguageChange("en"===t?"en":"zh")})(t[0]),void Ra(!1))},n.createElement(N,{name:"language",size:14}),n.createElement("span",{},t[1]),a===t[0]?n.createElement(N,{name:"check",size:14,className:"uh-language-option-check"}):null))):null),n.createElement("div",{className:"uh-range"},["today","7d","30d","90d","all","custom"].map(e=>n.createElement("button",{key:e,type:"button",className:P===e?"uh-on":"",title:"custom"===e&&"custom"===P?oi:void 0,onClick:()=>{"custom"===e?(()=>{const e=p(Ee,l),t=c(u(b,-89,l),l);Se(e||{start:t<mn?mn:t,end:x}),ze(!0)})():(K(e),ze(!1))}},"today"===e?i("今日","Today"):"7d"===e?i("近 7 天","Last 7 Days"):"30d"===e?i("近 30 天","Last 30 Days"):"90d"===e?i("近 90 天","Last 90 Days"):"all"===e?i("全部","All Time"):i("自定义","Custom")))),n.createElement("button",{className:"uh-refresh",title:i("导出当前时间范围与模型查看模式的 CSV 数据","Export CSV data for the current time range and model view"),onClick:()=>{const e=e=>'"'+String(e??"").replace(/"/g,'""')+'"',t=t=>t.map(e).join(","),n=e=>e.input+e.output+e.cacheRead+e.cacheWrite+e.reasoning,r=[i("输入 Token","Input Tokens"),i("缓存命中 Token","Cache-Hit Tokens"),i("缓存写入 Token","Cache-Write Tokens"),i("输出 Token","Output Tokens"),i("推理 Token","Reasoning Tokens"),i("总处理 Token","Total Tokens Processed"),i("成本","Cost"),i("缓存命中率","Cache Hit Rate")],o=[t([i("DSH 用量统计导出","DSH Usage Statistics Export")]),t([i("导出时间","Exported At"),l?(new Date).toLocaleString("en-US",{timeZone:"UTC",timeZoneName:"short"}):(new Date).toLocaleString("zh-CN")]),t([i("时间范围","Time Range"),oi]),t([i("时区","Timezone"),l?"UTC":i("本地","Local")]),t([i("工作区筛选","Workspace Filter"),je||i("全部","All")]),t([i("供应商筛选","Provider Filter"),Ke||i("全部","All")]),t([i("模型筛选","Model Filter"),null===Be?i("全部","All"):z(Be)]),t([i("统计 revision","Stats Revision"),E.revision||""]),t([i("模型查看模式","Model View Mode"),Ur]),"",t([i("汇总","Summary")]),t([i("回合","Turns"),i("会话","Sessions"),...r]),t([Mn.totals.turns,Mn.totals.sessions,Mn.totals.input,Mn.totals.cacheRead,Mn.totals.cacheWrite,Mn.totals.output,Mn.totals.reasoning,n(Mn.totals),V(Mn.totals,a),k(Mn.totals.input,Mn.totals.cacheRead).toFixed(2)+"%"]),"",t([i("模型用量明细","Model Usage Details")]),t([Wr,i("调用","Calls"),...r]),...Fn.map(e=>t([e.model,e.calls,e.input,e.cacheRead,e.cacheWrite,e.output,e.reasoning,n(e),V(e,a),k(e.input,e.cacheRead).toFixed(2)+"%"])),"",t([i("工作区明细","Workspace Details")]),t([i("工作区","Workspace"),i("路径","Path"),i("回合","Turns"),...r]),...Dn.map(e=>{const r=Hn.get(e.workspaceId);return t([Vn(e.workspaceId),r?r.path:"",e.turns,e.input,e.cacheRead,e.cacheWrite,e.output,e.reasoning,n(e),V(e,a),k(e.input,e.cacheRead).toFixed(2)+"%"])})],s=new Blob(["\ufeff"+o.join("\r\n")],{type:"text/csv;charset=utf-8"}),u=URL.createObjectURL(s),d=document.createElement("a");d.href=u,d.download="dsh-all-usage-"+si+"-"+Ie+"-"+c(new Date,l)+".csv",document.body.appendChild(d),d.click(),d.remove(),URL.revokeObjectURL(u)}},n.createElement(N,{name:"export",size:14}),i("导出数据","Export Data")),n.createElement("button",{className:"uh-refresh uh-icon-button",title:i("刷新统计数据","Refresh usage statistics"),"aria-label":i("刷新统计数据","Refresh usage statistics"),onClick:on},n.createElement(N,{name:"refresh",size:16})))),n.createElement("div",{className:"uh-filter-bar",role:"group","aria-label":i("统一筛选","Unified filters")},n.createElement(ut,{label:i("全部工作区","All workspaces"),ariaLabel:i("工作区筛选","Workspace filter"),className:"uh-filter-workspace",icon:"folder",value:je||"",options:Jn,onChange:e=>Pe(e||null)}),n.createElement(ut,{label:i("全部供应商","All providers"),ariaLabel:i("供应商筛选","Provider filter"),className:"uh-filter-provider",icon:"chart",value:Ke||"",options:Gn,onChange:e=>un(e)}),n.createElement(ut,{label:i("全部模型","All models"),ariaLabel:i("模型筛选","Model filter"),className:"uh-filter-model",icon:"cache",value:Be||"",options:$n,onChange:e=>dn(e)}),null!==je||null!==Ke||null!==Be?n.createElement("button",{type:"button",className:"uh-filter-clear",onClick:cn},i("清除筛选","Clear filters")):null,Ze?n.createElement("span",{className:"uh-query-note"},i("正在更新筛选结果…","Updating filtered data…")):null,""!==tt&&"stale"!==tt?n.createElement("span",{className:"uh-query-note",role:"alert"},i("筛选结果加载失败","Filtered data unavailable")):null),Pt?Kr:null,ai,ui,hi?n.createElement("div",{className:"uh-progress"},n.createElement("span",{},"en"===a?"Scanning historical sessions: "+sr.scanned+" / "+sr.total+(sr.failed>0?" ("+sr.failed+" failed to read)":""):"正在统计历史会话 "+sr.scanned+" / "+sr.total+(sr.failed>0?"("+sr.failed+" 个读取失败)":"")),n.createElement("div",{className:"uh-bar"},n.createElement("div",{className:"uh-fill",style:{width:gi+"%"}}))):null,n.createElement("div",{className:"uh-sync-health"+(""!==wi?" uh-stale":""),title:""!==wi?void 0:xi},n.createElement(N,{name:""!==wi?"refresh":"clock",size:14}),n.createElement("span",{},""!==wi?wi:vi),""!==wi?n.createElement("button",{className:"uh-sync-retry",onClick:on},i("重试","Retry")):null),bi?n.createElement("div",{className:"uh-panel"},n.createElement("div",{className:"uh-empty"},i("还没有使用记录。开始对话后,这里会点亮。","No usage recorded yet. This area will light up after you start a conversation."))):n.createElement(n.Fragment,null,n.createElement(n.Fragment,null,n.createElement("div",{className:"uh-ios-summary"},n.createElement("div",{className:"uh-ios-summary-hero"},n.createElement("div",{className:"uh-ios-summary-total"},n.createElement("div",{className:"uh-ios-summary-total-icon"},n.createElement(N,{name:"chart",size:24})),n.createElement("div",{className:"uh-ios-summary-total-copy"},n.createElement("div",{className:"uh-ios-summary-label"},i("总处理 Token","Total Tokens Processed")),n.createElement("div",{className:"uh-ios-summary-value"},O(v(Sn),Nr,a)),n.createElement("div",{className:"uh-ios-summary-caption"},"en"===a?oi+" · "+v(In)+(An?" calls":" uses")+" · includes cache reads/writes and reasoning":oi+" · "+v(In)+(An?" 次调用":" 次使用")+" · 含缓存读写与推理"))),n.createElement("div",{className:"uh-ios-summary-meta"},n.createElement("div",{className:"uh-ios-summary-meta-stat"},n.createElement("div",{className:"uh-ios-summary-meta-label"},n.createElement(N,{name:"chart",size:16}),i("总请求数","Total Requests")),n.createElement("div",{className:"uh-ios-summary-meta-value"},w(Rn,a))),n.createElement("div",{className:"uh-ios-summary-meta-stat uh-ios-summary-meta-cost"},n.createElement("div",{className:"uh-ios-summary-meta-label"},n.createElement(N,{name:"wallet",size:16}),i("估算成本","Estimated Cost")),n.createElement("div",{className:"uh-ios-summary-meta-value"},Mr),n.createElement("div",{className:"uh-ios-summary-meta-caption"},Sr)))),n.createElement("div",{className:"uh-ios-metrics"},Tr(i("DeepSeek 账户余额","DeepSeek Account Balance"),Ar,zr,0,"wallet","deepseek"),Tr(An?i("匹配调用次数","Matching Calls"):i("总使用次数","Total Uses"),v(In),"all"!==P||An?"en"===a?(An?"Calls in ":"Turns in ")+oi:oi+(An?"内的调用数":"内的回合数"):"en"===a?Mn.totals.sessions+" sessions":Mn.totals.sessions+" 个会话",1,"chart"),Tr(i("连续使用","Current Streak"),"en"===a?Xn.streak+" days":Xn.streak+" 天","en"===a?"Longest streak: "+Xn.best+" days":"最长连续 "+Xn.best+" 天",2,"clock"),Dr,Ir)),n.createElement("div",{className:"uh-token-semantics"},n.createElement(N,{name:"cache",size:16}),i("总处理 Token = 输入 + 输出 + 缓存读写 + 推理。缓存命中代表复用上下文,不等于新生成 Token 或实际费用。成本按事件发生时刻与官方价目估算,不等同于供应商账单。","Total tokens processed = input + output + cache reads/writes + reasoning. Cache hits represent reused context; they are not newly generated tokens or actual cost. Costs are estimated at event time from official price lists and do not equal the provider invoice.")),di,n.createElement(rt,{rows:Cn,workspaces:Un,aliases:Wn,workspaceId:je,queryUsable:En,todayKey:x,utc:l,language:a,span:q,onSpanChange:bn,onWorkspaceSelect:sn,onDateClick:rn}),n.createElement("div",{className:"uh-detail-tabs",role:"tablist","aria-label":i("用量明细视图","Usage detail views")},[["logs",i("请求日志","Request Logs"),"list"],["model",i("模型统计","Model Stats"),"chart"],["workspace",i("工作区统计","Workspace Stats"),"folder"]].map(e=>n.createElement("button",{key:e[0],type:"button",role:"tab","aria-selected":yt===e[0],className:"uh-detail-tab"+(yt===e[0]?" uh-on":""),onClick:()=>xt(e[0])},n.createElement(N,{name:e[2],size:14}),e[1]))),mi),"model"===yt?n.createElement("div",{className:"uh-panel uh-ios-list-panel"},n.createElement("div",{className:"uh-hm-head"},n.createElement("h3",{className:"uh-tbl-title uh-title-with-icon",style:{margin:0}},n.createElement(N,{name:"chart",size:16}),"en"===a?"Model Usage Details ("+oi+")":"模型用量明细("+oi+")"),n.createElement("div",{className:"uh-range"},[["route",i("混合查看","Combined View")],["model",i("按模型","By Model")],["provider",i("按供应商","By Provider")]].map(e=>n.createElement("button",{key:e[0],className:Ie===e[0]?"uh-on":"",onClick:()=>Re(e[0])},e[1])))),0===Fn.length?n.createElement("div",{className:"uh-empty"},i("尚无带模型路由信息的用量记录","No usage records with model-routing information yet")):n.createElement(n.Fragment,null,Or,n.createElement("div",{className:"uh-tbl-scroll"},n.createElement("div",{className:"uh-model-hrow uh-hrow"},n.createElement("div",{},Wr),n.createElement("div",{className:"uh-num"},i("调用","Calls")),n.createElement("div",{className:"uh-num"},i("输入","Input")),n.createElement("div",{className:"uh-num"},i("缓存命中","Cache Hits")),n.createElement("div",{className:"uh-num"},i("输出","Output")),n.createElement("div",{className:"uh-num"},i("推理","Reasoning")),n.createElement("div",{className:"uh-num"},i("总处理","Total Processed")),n.createElement("div",{className:"uh-num"},i("成本","Cost")),n.createElement("div",{className:"uh-num"},i("命中率","Hit Rate"))),Pr)),n.createElement("div",{className:"uh-note",style:{marginTop:10}},"en"===a?Ur+": Combined View distinguishes “Provider / Model”; By Model merges identically named models across providers; By Provider aggregates all of a provider’s models. Historical records without routing information are grouped as “Unknown.”":Ur+":混合查看按“供应商 / 模型”区分;按模型会跨供应商合并同名模型;按供应商则汇总其全部模型。缺少路由信息的历史记录会归为“未知”。")):null,"workspace"===yt?n.createElement("div",{className:"uh-panel uh-ios-list-panel"},n.createElement("h3",{className:"uh-tbl-title uh-title-with-icon"},n.createElement(N,{name:"folder",size:16}),"en"===a?"Workspace Details ("+oi+")":"工作区明细("+oi+")"),0===Dn.length?n.createElement("div",{className:"uh-empty"},i("该时间范围内没有使用记录","No usage records in this time range")):n.createElement(n.Fragment,null,Lr,n.createElement("div",{className:"uh-tbl-scroll"},n.createElement("div",{className:"uh-hrow"},n.createElement("div",{},i("工作区","Workspace")),n.createElement("div",{className:"uh-num"},i("回合","Turns")),n.createElement("div",{className:"uh-num"},i("输入","Input")),n.createElement("div",{className:"uh-num"},i("缓存命中","Cache Hits")),n.createElement("div",{className:"uh-num"},i("输出","Output")),n.createElement("div",{className:"uh-num"},i("推理","Reasoning")),n.createElement("div",{className:"uh-num"},i("总处理","Total Processed")),n.createElement("div",{className:"uh-num"},i("成本","Cost")),n.createElement("div",{className:"uh-num"},i("命中率","Hit Rate")),n.createElement("div",{className:"uh-num"},i("占比","Share"))),Fr))):null))}class Et extends n.Component{constructor(e){super(e),this.state={error:null,resetKey:e.resetKey}}static getDerivedStateFromError(e){return{error:e}}componentDidUpdate(e){e.resetKey!==this.props.resetKey&&null!==this.state.error&&this.setState({error:null,resetKey:this.props.resetKey})}render(){return null!==this.state.error?this.props.fallback(this.state.error):this.props.children}}function Nt(e){const[t,a]=n.useState(!1),[r,i]=n.useState(0),[l,c]=n.useState(yt),u=(e,t)=>"en"===l?t:e,d=o();return n.useEffect(()=>{if(!t)return;s();const e=e=>{"Escape"===e.key&&a(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[t]),n.createElement(n.Fragment,null,n.createElement("button",{type:"button",className:"uh-side-entry",title:u("用量统计","Usage Statistics"),"aria-label":u("用量统计","Usage Statistics"),onClick:()=>a(!0)},n.createElement("span",{className:"uh-side-entry-icon"},n.createElement(N,{name:"chart",size:17})),e.wide?n.createElement("span",{className:"uh-side-entry-label"},u("用量统计","Usage Statistics")):null),t?n.createElement("div",{className:"uh-side-modal",role:"presentation",style:d>0?{"--uh-top-inset":d+"px"}:void 0,onMouseDown:e=>{e.target===e.currentTarget&&a(!1)}},n.createElement("div",{className:"uh-side-dialog",role:"dialog","aria-modal":!0,"aria-label":u("用量统计","Usage Statistics")},n.createElement("div",{className:"uh-side-dialog-head"},n.createElement("button",{className:"uh-refresh uh-close-button",type:"button",title:u("关闭用量统计","Close Usage Statistics"),"aria-label":u("关闭用量统计","Close Usage Statistics"),onClick:()=>a(!1)},n.createElement(N,{name:"close",size:18}))),n.createElement(Et,{resetKey:r,fallback:()=>n.createElement("div",{className:"uh-boundary-fallback",role:"alert"},n.createElement("div",{className:"uh-boundary-title"},u("用量统计暂时无法显示","Usage statistics is temporarily unavailable")),n.createElement("div",{className:"uh-boundary-note"},u("当前范围加载失败,入口仍然可用。","The selected range failed to render; the sidebar entry is still available.")),n.createElement("div",{className:"uh-actions"},n.createElement("button",{type:"button",className:"uh-refresh",onClick:()=>i(e=>e+1)},n.createElement(N,{name:"refresh",size:14}),u("重试","Retry")),n.createElement("button",{type:"button",className:"uh-refresh",onClick:()=>a(!1)},n.createElement(N,{name:"close",size:14}),u("关闭","Close"))))},n.createElement(kt,{timerCtx:e.timerCtx,language:l,onLanguageChange:e=>{const t="en"===e?"en":"zh";c(t),function(e){try{window.localStorage.setItem(ft,e)}catch(e){}}(t)}})))):null)}return a.inject=["timer","slots"],a.apply=e=>{const t=e.get("slots"),a=e.get("timer");void 0!==t&&void 0!==a&&t.inject("sidebar.footer.action",()=>t.register({name:"sidebar.footer.action",id:"all-usage",order:10},e=>n.createElement(Nt,{wide:e.wide,timerCtx:a})))},t}});
1
+ window.__ModuleLoader__.load({id:"dsh-all-usage",factory:e=>{var t={},a=t;Object.defineProperty(a,Symbol.toStringTag,{value:"Module"});const n=e("react");let r=null;try{r=e("react-dom")||null}catch(e){r=null}const i="1.2.1";function l(e){return String(e).padStart(2,"0")}let o="none";function s(){o="none";try{const e="undefined"==typeof localStorage?null:localStorage.getItem("dsh-all-usage:topInset");if(null!==e&&""!==e){const t=Number(e);if(Number.isFinite(t)&&t>=0)return o="stored",Math.round(t)}}catch(e){}try{const e="undefined"==typeof document?null:document.documentElement;if(null!==e&&e.hasAttribute("data-windows-titlebar")){const t=Number.parseFloat(window.getComputedStyle(e).getPropertyValue("--dsh-windows-titlebar-height"));return o="titlebar-marker",Number.isFinite(t)&&t>0?Math.round(t):40}}catch(e){}try{const e="undefined"==typeof navigator?void 0:navigator.windowControlsOverlay;if(null!=e&&!0===e.visible){const t=e.getTitlebarAreaRect();if(null!=t&&Number.isFinite(t.height)&&t.height>0)return o="overlay",Math.round(t.height)}}catch(e){}const e="undefined"==typeof navigator?"":String(navigator.userAgent||"");return/Electron/i.test(e)?(o="electron-ua",40):/QtWebEngine/i.test(e)?(o="qtwebengine-ua",40):0}function c(){try{const e="undefined"==typeof navigator?void 0:navigator.windowControlsOverlay;let t="none";null!=e&&(t=!0===e.visible?String((e.getTitlebarAreaRect()||{}).height):"hidden");const a="undefined"==typeof navigator?"":String(navigator.userAgent||"").slice(0,180),n=e=>{try{const t=document.querySelector(e);if(null===t)return"none";const a=t.getBoundingClientRect();return[a.top,a.left,a.width,a.height].map(e=>Math.round(e)).join("/")}catch(e){return"none"}},r="undefined"==typeof document?null:document.documentElement,i=null!==r&&r.hasAttribute("data-windows-titlebar")?String(window.getComputedStyle(r).getPropertyValue("--dsh-windows-titlebar-height")).trim()||"set":"none",l="undefined"==typeof window?"":Math.round(window.innerWidth)+"x"+Math.round(window.innerHeight),c="ua="+encodeURIComponent(a)+"&wco="+encodeURIComponent(t)+"&inset="+String(s())+"&src="+encodeURIComponent(o)+"&tb="+encodeURIComponent(i)+"&vp="+encodeURIComponent(l)+"&modal="+encodeURIComponent(n(".uh-side-modal"))+"&dlg="+encodeURIComponent(n(".uh-side-dialog"))+"&head="+encodeURIComponent(n(".uh-side-dialog-head"))+"&close="+encodeURIComponent(n(".uh-close-button"));fetch("/api/all-usage/client-env?"+c,{headers:{accept:"application/json"}}).catch(()=>{})}catch(e){}}function u(e,t){const a=t?e.getUTCFullYear():e.getFullYear(),n=t?e.getUTCMonth():e.getMonth(),r=t?e.getUTCDate():e.getDate();return a+"-"+l(n+1)+"-"+l(r)}function d(e,t,a){return a?new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t)):new Date(e.getFullYear(),e.getMonth(),e.getDate()+t)}function p(e,t){if("string"!=typeof e||!/^\d{4}-\d{2}-\d{2}$/.test(e))return!1;const a=Number(e.slice(0,4)),n=Number(e.slice(5,7)),r=Number(e.slice(8,10)),i=t?new Date(Date.UTC(a,n-1,r)):new Date(a,n-1,r);return Number.isFinite(i.getTime())&&u(i,t)===e}function m(e,t){if(null===e||"object"!=typeof e)return null;const a=e.start,n=e.end;return!p(a,t)||!p(n,t)||a>n?null:{start:a,end:n}}function h(e,t){let a=t;if(Array.isArray(e))for(const n of e)n&&p(n.date,!0)&&n.date<=t&&n.date<a&&(a=n.date);return{min:a,max:t}}function g(){let e=0;return{next:()=>(e+=1,e),isCurrent:t=>t===e}}function b(e){if(null===e||"object"!=typeof e)return null;const t="string"==typeof e.instanceId?e.instanceId:"",a="number"==typeof e.revision&&Number.isFinite(e.revision)?e.revision:null;return""===t||null===a?null:t+":"+a}function f(e,t,a){const n=e&&"object"==typeof e?e[t]:void 0;return"number"==typeof n&&Number.isFinite(n)?n:a}function y(e){return null!==e&&"object"==typeof e&&["dataRevision","metadataRevision","scanRevision","pricingRevision"].every(t=>null!==f(e,t,null))}function x(e){if(null===e||"object"!=typeof e||"string"!=typeof e.instanceId||""===e.instanceId)return null;if("string"==typeof e.queryRevision&&""!==e.queryRevision)return e.instanceId+":"+e.queryRevision;const t=f(e,"dataRevision",f(e,"revision",null)),a=f(e,"pricingRevision",0);return null===t?null:e.instanceId+":"+t+":"+a}function v(e){return String(Math.round(10*e)/10)}function w(e){return"number"==typeof e&&Number.isFinite(e)?e<1e3?String(e):e<1e6?v(e/1e3)+"k":e<1e9?v(e/1e6)+"M":v(e/1e9)+"B":"0"}function k(e,t){return"number"==typeof e&&Number.isFinite(e)?Math.round(e).toLocaleString("en"===t?"en-US":"zh-CN"):"0"}function E(e,t){const a=e+t;return a<=0?0:t/a*100}c();const N={edit:{path:"M12.2 3.4l2.4 2.4M4 16l2.8-.6L15 7.2a1.7 1.7 0 0 0-2.4-2.4L4.4 13z"},export:{path:"M12 3v11M8 7l4-4 4 4M5 13v5h14v-5"},refresh:{path:"M19 9a7 7 0 1 0 1.1 5.2M19 4v5h-5"},close:{path:"M6 6l12 12M18 6L6 18"},chart:{path:"M4 19V5M4 19h16M7 15l3-4 3 2 5-7"},list:{path:"M6 6h12M6 12h12M6 18h12",circle:{cx:3.5,cy:6,r:1.2}},cache:{path:"M12 4l7 4-7 4-7-4 7-4zM5 12l7 4 7-4M5 16l7 4 7-4"},wallet:{path:"M4 7.5A2.5 2.5 0 0 1 6.5 5H18v14H6.5A2.5 2.5 0 0 1 4 16.5zM4 8h14M14 13h.01"},clock:{path:"M12 6v6l4 2M20 12a8 8 0 1 1-16 0 8 8 0 0 1 16 0z"},folder:{path:"M3.5 7.5h6l2 2h9v8.5a2 2 0 0 1-2 2h-13a2 2 0 0 1-2-2z"},language:{path:"M4 12h16M12 4c2.1 2.2 3.2 4.9 3.2 8S14.1 17.8 12 20M12 4C9.9 6.2 8.8 8.9 8.8 12s1.1 5.8 3.2 8",circle:{cx:12,cy:12,r:8}},chevron:{path:"M7 10l5 5 5-5"},check:{path:"M5 12.5l4.2 4.1L19 7.3"},plus:{path:"M12 5v14M5 12h14"},calendar:{path:"M6 4v3M18 4v3M4 9h16M5 6h14a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1z"}};function C(e){const t=e.size||16,a={fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"},r=void 0===e.name?"chart":e.name,i=void 0===N[r]?N.chart:N[r],l=[];return void 0!==i.path&&l.push(n.createElement("path",{key:"p",d:i.path,...a})),void 0!==i.circle&&l.push(n.createElement("circle",{key:"c",cx:i.circle.cx,cy:i.circle.cy,r:i.circle.r,...a})),n.createElement("svg",{className:"uh-line-icon "+(e.className||""),width:t,height:t,viewBox:"0 0 24 24","aria-hidden":!0},l)}const M=[{key:"deepseek",label:"DeepSeek",providers:["deepseek","deepseek-official"],prefixes:["deepseek-","deepseek"],exact:[],href:"/api/all-usage/icon?key=deepseek&v=1.2.1"},{key:"openai",label:"OpenAI",providers:["openai","azure-openai"],prefixes:["gpt-","o1-","o3-","o4-","o5-","codex-","gpt"],exact:["o1","o3","o4","o5"],href:"/api/all-usage/icon?key=openai&v=1.2.1"},{key:"claude",label:"Anthropic Claude",providers:["anthropic"],prefixes:["claude-","claude"],exact:[],href:"/api/all-usage/icon?key=claude&v=1.2.1"},{key:"gemini",label:"Google Gemini",providers:["google","google-vertex","vertex"],prefixes:["gemini-","gemma-","gemma","gemini"],exact:[],href:"/api/all-usage/icon?key=gemini&v=1.2.1"},{key:"meta",label:"Meta Llama",providers:["meta","meta-llama"],prefixes:["llama-","meta-llama","llama"],exact:[],href:"/api/all-usage/icon?key=meta&v=1.2.1"},{key:"zhipu",label:"Zhipu GLM",providers:["zhipu","zhipuai","zai","bigmodel"],prefixes:["glm-","chatglm-","glm","chatglm"],exact:[],href:"/api/all-usage/icon?key=zhipu&v=1.2.1"},{key:"grok",label:"xAI Grok",providers:["xai"],prefixes:["grok-","grok"],exact:["grok"],href:"/api/all-usage/icon?key=grok&v=1.2.1"},{key:"qwen",label:"Qwen",providers:["qwen","alibaba","dashscope","bailian"],prefixes:["qwen","qwq-","qvq-"],exact:[],href:"/api/all-usage/icon?key=qwen&v=1.2.1"},{key:"doubao",label:"Doubao",providers:["doubao","bytedance","volcengine","ark"],prefixes:["doubao-","doubao"],exact:[],href:"/api/all-usage/icon?key=doubao&v=1.2.1"},{key:"kimi",label:"Moonshot Kimi",providers:["moonshot","moonshotai"],prefixes:["kimi-","moonshot-","kimi","moonshot"],exact:["kimi"],href:"/api/all-usage/icon?key=kimi&v=1.2.1"},{key:"minimax",label:"MiniMax",providers:["minimax"],prefixes:["minimax-","abab","minimax"],exact:[],href:"/api/all-usage/icon?key=minimax&v=1.2.1"},{key:"mistral",label:"Mistral",providers:["mistral","mistralai"],prefixes:["mistral-","mistralai-","magistral-","codestral-","devstral-","ministral-","pixtral-","mixtral-","open-mistral-","open-mixtral-"],exact:[],href:"/api/all-usage/icon?key=mistral&v=1.2.1"},{key:"nemotron",label:"NVIDIA",providers:["nvidia","nvidia-nim"],prefixes:["nemotron"],exact:[],href:"/api/all-usage/icon?key=nemotron&v=1.2.1"},{key:"cohere",label:"Cohere",providers:["cohere"],prefixes:["command-","north-","c4ai-"],exact:[],href:"/api/all-usage/icon?key=cohere&v=1.2.1"},{key:"nova",label:"Amazon Nova",providers:["amazon","amazon-bedrock","bedrock","aws-bedrock"],prefixes:["nova-","amazon.nova-"],exact:[],href:"/api/all-usage/icon?key=nova&v=1.2.1"},{key:"phi",label:"Microsoft",providers:["microsoft","azure","azure-ai","azure-cognitive-services"],prefixes:["phi-","microsoft/"],exact:[],href:"/api/all-usage/icon?key=phi&v=1.2.1"},{key:"sonar",label:"Perplexity",providers:["perplexity","perplexity-ai"],prefixes:["sonar"],exact:[],href:"/api/all-usage/icon?key=sonar&v=1.2.1"},{key:"ernie",label:"Baidu ERNIE",providers:["baidu","qianfan","baiducloud"],prefixes:["ernie-","wenxin"],exact:[],href:"/api/all-usage/icon?key=ernie&v=1.2.1"},{key:"hunyuan",label:"Tencent Hunyuan",providers:["hunyuan"],prefixes:["hunyuan-","hy3","hy4"],exact:[],href:"/api/all-usage/icon?key=hunyuan&v=1.2.1"},{key:"tencent",label:"Tencent",providers:["tencent","tencentcloud","tencent-hunyuan"],prefixes:[],exact:[],href:"/api/all-usage/icon?key=tencent&v=1.2.1"},{key:"stepfun",label:"StepFun",providers:["stepfun","step"],prefixes:["step-","stepfun-"],exact:[],href:"/api/all-usage/icon?key=stepfun&v=1.2.1"},{key:"baichuan",label:"Baichuan",providers:["baichuan"],prefixes:["baichuan"],exact:[],href:"/api/all-usage/icon?key=baichuan&v=1.2.1"},{key:"sensenova",label:"SenseNova",providers:["sensenova","sensetime"],prefixes:["sensenova","sensechat"],exact:[],href:"/api/all-usage/icon?key=sensenova&v=1.2.1"},{key:"internlm",label:"InternLM",providers:["internlm","shanghai-ai-lab"],prefixes:["internlm","intern-lm"],exact:[],href:"/api/all-usage/icon?key=internlm&v=1.2.1"},{key:"longcat",label:"LongCat",providers:["longcat","meituan"],prefixes:["longcat"],exact:[],href:"/api/all-usage/icon?key=longcat&v=1.2.1"},{key:"jamba",label:"AI21",providers:["ai21","ai21-labs"],prefixes:["jamba"],exact:[],href:"/api/all-usage/icon?key=jamba&v=1.2.1"},{key:"granite",label:"IBM Granite",providers:["ibm","ibm-granite","watsonx"],prefixes:["granite-"],exact:[],href:"/api/all-usage/icon?key=granite&v=1.2.1"},{key:"solar",label:"Upstage",providers:["upstage"],prefixes:["solar-"],exact:[],href:"/api/all-usage/icon?key=solar&v=1.2.1"},{key:"lfm",label:"Liquid AI",providers:["liquid","liquid-ai"],prefixes:["lfm-"],exact:[],href:"/api/all-usage/icon?key=lfm&v=1.2.1"},{key:"olmo",label:"Ai2",providers:["ai2","allenai"],prefixes:["olmo","molmo"],exact:[],href:"/api/all-usage/icon?key=olmo&v=1.2.1"},{key:"bge",label:"BAAI",providers:["baai","bge"],prefixes:["bge-"],exact:[],href:"/api/all-usage/icon?key=bge&v=1.2.1"},{key:"voyage",label:"Voyage AI",providers:["voyage","voyageai"],prefixes:["voyage-"],exact:[],href:"/api/all-usage/icon?key=voyage&v=1.2.1"},{key:"bytedance",label:"ByteDance Seed",providers:["bytedance","seed","volcengine","ark"],prefixes:["seed-","seed1-","seed2-"],exact:[],href:"/api/all-usage/icon?key=bytedance&v=1.2.1"},{key:"kling",label:"Kling",providers:["kling","kuaishou"],prefixes:["kling"],exact:[],href:"/api/all-usage/icon?key=kling&v=1.2.1"},{key:"skywork",label:"Skywork",providers:["skywork"],prefixes:["skywork"],exact:[],href:"/api/all-usage/icon?key=skywork&v=1.2.1"},{key:"mimo",label:"Xiaomi MiMo",providers:["xiaomimimo","xiaomi","mimo"],prefixes:["mimo-"],exact:[],href:"/api/all-usage/icon?key=mimo&v=1.2.1"},{key:"aion",label:"Aion Labs",providers:["aion-labs","aionlabs"],prefixes:["aion-"],exact:[],href:"/api/all-usage/icon?key=aion&v=1.2.1"},{key:"nous",label:"Nous Research",providers:["nousresearch","nous","nous-research"],prefixes:["nous-","hermes-3","hermes-4"],exact:[],href:"/api/all-usage/icon?key=nous&v=1.2.1"},{key:"falcon",label:"TII Falcon",providers:["tii","falcon","tii-uae"],prefixes:["falcon-"],exact:[],href:"/api/all-usage/icon?key=falcon&v=1.2.1"},{key:"aleph",label:"Aleph Alpha",providers:["aleph-alpha","alephalpha"],prefixes:["aleph-","pharia-"],exact:[],href:"/api/all-usage/icon?key=aleph&v=1.2.1"},{key:"yandex",label:"Yandex",providers:["yandex","yandex-cloud"],prefixes:["yandex-","yandexgpt"],exact:[],href:"/api/all-usage/icon?key=yandex&v=1.2.1"},{key:"arctic",label:"Snowflake",providers:["snowflake"],prefixes:["snowflake-","arctic-"],exact:[],href:"/api/all-usage/icon?key=arctic&v=1.2.1"},{key:"iflytek",label:"iFlytek Spark",providers:["iflytek","iflytekcloud","spark"],prefixes:["spark-","generalv"],exact:[],href:"/api/all-usage/icon?key=iflytek&v=1.2.1"}],S=Array.isArray(M)?M:[],A=new Map(S.map(e=>[e.key,e])),z=new Map;function T(e){const t=String(e??"").trim(),a=t.lastIndexOf("/");if(a<=0||a>=t.length-1)return t;const n=t.slice(0,a);if(!/^[a-z0-9][a-z0-9._-]*$/i.test(n))return t;const r=t.slice(a+1).trim();return""===r?t:r}function I(e){const t="string"==typeof e?e.trim().toLowerCase():"";if(""===t)return null;for(const e of S)if(e.providers.includes(t))return e;return null}function R(e,t){if(""===t||!e.startsWith(t))return!1;if(e.length===t.length)return!0;if(/[-_.:\/]$/.test(t))return!0;const a=e.charAt(t.length);return"-"===a||"_"===a||"."===a||":"===a||"/"===a||/[a-z]$/.test(t)&&/[0-9]/.test(a)}const j=["openai","google","anthropic","databricks","azure","azure-ai","microsoft","amazon","cohere","mistral","deepseek","qwen","moonshot","zhipu","bytedance","nvidia","ibm","ai21","upstage","voyage","baai","ai2","liquid","sensenova","internlm","longcat","stepfun","baichuan","tencent","kling","skywork","duo-chat","bedrock","vertex"];function D(e){for(const t of S)if(t.exact.includes(e))return t;let t=null,a=0;for(const n of S)for(const r of n.prefixes)R(e,r)&&r.length>a&&(t=n,a=r.length);return t}function U(e){const t=function(e){if("string"!=typeof e)return"";let t=e.trim().toLowerCase();const a=t.lastIndexOf("/");return a>=0&&(t=t.slice(a+1)),t.split(":")[0].replace(/@/g,"-").trim()}(e);if(""===t)return null;for(const e of function(e){const t=[e];let a=e.indexOf(".");for(;a>0&&a<e.length-3;){const n=e.slice(a+1);n.length>=3&&t.push(n),a=e.indexOf(".",a+1)}for(const a of j){if(!e.startsWith(a+"-"))continue;const n=e.slice(a.length+1).replace(/^[-_.]+/,"");n.length>=3&&t.push(n)}return t}(t)){const t=D(e);if(null!==t)return t}return null}function F(e){if(0===S.length||null===e||"object"!=typeof e)return null;const t="string"==typeof e.actualModel?e.actualModel:"",a="string"==typeof e.requestedModel?e.requestedModel:"",n="string"==typeof e.model?e.model:"",r="string"==typeof e.provider?e.provider:"",i=t+"\0"+a+"\0"+n+"\0"+r;if(z.has(i))return z.get(i);const l=n.includes(" / ")?n.slice(n.indexOf(" / ")+3):n;let o=U(""!==t?t:a);if(null===o&&""===t&&""===a){const e=I(r),t=U(l);o=null===e||null!==t&&t!==e?t:e}return z.size>=2e3&&z.clear(),z.set(i,o),o}function W(e){if(!Array.isArray(e)||0===e.length)return null;let t=null;for(const a of e){const e=F(a);if(null===e)return null;if(null===t)t=e;else if(t!==e)return null}return t}function O(e,t){if("en"===t||"number"!=typeof e||!Number.isFinite(e)||e<1e4)return"";const a=e>=1e8?e/1e8:e/1e4,n=Math.round(1e3*a)/1e3;return String(n)+(e>=1e8?"亿":"万")}function L(e,t,a){const r=O(t,a);return n.createElement(n.Fragment,null,e,r?n.createElement("span",{className:"uh-unit"},r):null)}function P(e,t,a,n){if(null==t)return"—";const r="CNY"===e?"¥":"USD"===e?"$":e+" ",i=Number.isFinite(n)?n:4;return r+t.toLocaleString("en"===a?"en-US":"zh-CN",{minimumFractionDigits:i,maximumFractionDigits:i})}function K(e){const t=("number"==typeof e?String(e):"string"==typeof e?e.trim().toLowerCase():"").match(/^(\d+)(?:\.(\d+))?(?:e([+-]?\d+))?$/);if(!t)return{digits:0n,scale:0};let a=(t[1]||"")+(t[2]||""),n=(t[2]||"").length-(t[3]?Number(t[3]):0);for(n<0&&(a+="0".repeat(-n),n=0),n>a.length&&(a="0".repeat(n-a.length+1)+a);n>0&&a.length>1&&a.endsWith("0");)a=a.slice(0,-1),n-=1;return{digits:BigInt(a.replace(/^0+(?=\d)/,"")||"0"),scale:n}}function q(e){const t=K(e);if(0n===t.digits)return"0";const a=t.digits.toString();if(0===t.scale)return a;const n=a.padStart(t.scale+1,"0"),r=n.length-t.scale;return n.slice(0,r)+"."+n.slice(r)}function B(e,t){const a=K(e),n=K(t),r=Math.max(a.scale,n.scale);return q((a.digits*10n**BigInt(r-a.scale)+n.digits*10n**BigInt(r-n.scale)).toString()+(r>0?"e-"+r:""))}function H(){return{currency:"USD",input:"0",output:"0",cacheRead:"0",cacheWrite:"0",baseTotal:"0",total:"0",pricedCalls:0,unpricedCalls:0,ambiguousCalls:0,unsupportedCalls:0}}function Y(e){const t=e&&e.cost&&"object"==typeof e.cost?e.cost:e&&"object"==typeof e?e:{},a={currency:"USD",input:"0",output:"0",cacheRead:"0",cacheWrite:"0",baseTotal:"0",total:"0",pricedCalls:0,unpricedCalls:0,ambiguousCalls:0,unsupportedCalls:0};if(a.currency="string"==typeof t.currency&&""!==t.currency?t.currency:"USD",t.breakdown&&"object"==typeof t.breakdown)return"priced"===t.status?(a.input=q(t.breakdown.input),a.output=q(t.breakdown.output),a.cacheRead=q(t.breakdown.cacheRead),a.cacheWrite=q(t.breakdown.cacheWrite),a.baseTotal=q(t.baseTotal),a.total=q(t.total),a.pricedCalls=1):"ambiguous"===t.status?a.ambiguousCalls=1:"unsupported"===t.status?a.unsupportedCalls=1:a.unpricedCalls=1,a;for(const e of["input","output","cacheRead","cacheWrite","baseTotal","total"])a[e]=q(t[e]);for(const e of["pricedCalls","unpricedCalls","ambiguousCalls","unsupportedCalls"])a[e]=Number.isFinite(t[e])?t[e]:0;return a}function V(e,t){const a=Y(t);for(const t of["input","output","cacheRead","cacheWrite","baseTotal","total"])e[t]=B(e[t],a[t]);return e.pricedCalls+=a.pricedCalls,e.unpricedCalls+=a.unpricedCalls,e.ambiguousCalls+=a.ambiguousCalls,e.unsupportedCalls+=a.unsupportedCalls,e}function J(e,t){const a=Y(e);if(a.pricedCalls<=0)return"—";const n=Number(a.total);return Number.isFinite(n)?P(a.currency,n,t):a.currency+" "+a.total}function G(e,t){const a=e&&e.cost&&"object"==typeof e.cost?e.cost:{},n=[];return a.pricingPolicyId&&n.push(a.pricingPolicyId),"UTC"===a.pricingTimezone&&Number.isFinite(a.pricingAt)&&n.push(("en"===t?"at ":"计费时刻 ")+new Date(a.pricingAt).toISOString().slice(0,16).replace("T"," ")+" UTC"),n.length>0?n.join(" · "):null}function $(e){const t=e&&e.config&&"object"==typeof e.config?e.config:{},a=t.sync&&"object"==typeof t.sync?t.sync:{};return{sync:{autoEnabled:!0===a.autoEnabled,intervalMs:Number.isFinite(a.intervalMs)?a.intervalMs:216e5},providerAliases:t.providerAliases&&"object"==typeof t.providerAliases?Object.assign({},t.providerAliases):{},mappings:Array.isArray(t.mappings)?t.mappings.map(e=>Object.assign({},e)):[],overrides:Array.isArray(t.overrides)?t.overrides.map(e=>Object.assign({},e,{tiers:Array.isArray(e.tiers)?e.tiers.map(e=>Object.assign({},e)):[]})):[]}}function _(e){const t=new Map,a=e&&Array.isArray(e.tierSchedules)?e.tierSchedules:[];for(const e of a)e&&"string"==typeof e.id&&Array.isArray(e.tiers)&&t.set(e.id,e.tiers);return e&&Array.isArray(e.usedModels)?e.usedModels.map(e=>{const a=e&&"string"==typeof e.tierScheduleId?t.get(e.tierScheduleId):null,n=Array.isArray(a)?a:e&&Array.isArray(e.tiers)?e.tiers:[];return Object.assign({},e,{tiers:n.map(e=>Object.assign({},e))})}):[]}function X(e,t){const a=$(t);if(null===e||"object"!=typeof e)return a;const n=$({config:e});return Object.assign({},a,{providerAliases:n.providerAliases,mappings:n.mappings,overrides:n.overrides})}function Z(e,t){const a={priced:["已计价","priced"],unpriced:["未计价","unpriced"],ambiguous:["待确认","ambiguous"],unsupported:["不支持","unsupported"]},n=a[e]||a.unpriced;return"en"===t?n[1]:n[0]}function Q(e,t){const a={fresh:["Fresh:输入 + 缓存读写","Fresh: input + cache read/write"],total:["Total:输入已含缓存","Total: input already includes cache"],legacy:["Legacy:输入 + 缓存写","Legacy: input + cache write"]},n=a[e]||a.fresh;return"en"===t?n[1]:n[0]}function ee(e,t,a){const n=Array.isArray(e)?e:[];if(t<0)return n.length>0?"≤ "+k(n[0].size,a):"en"===a?"All contexts":"全部上下文";const r=n[t];if(!r)return"";const i="> "+k(r.size,a),l=n[t+1];return l?i+("en"===a?" and ≤ ":" 且 ≤ ")+k(l.size,a):i}function te(e){const t=String(e??"").trim().toLowerCase();if(""===t||t.length>128)return!1;const a=t.match(/^(\d+)(?:\.(\d+))?(?:e([+-]?\d+))?$/);if(!a)return!1;const n=a[3]?Number(a[3]):0;if(!Number.isSafeInteger(n)||Math.abs(n)>24)return!1;let r=(a[1]||"")+(a[2]||""),i=(a[2]||"").length-n;return r=r.replace(/^0+(?=\d)/,""),i<0&&(r+="0".repeat(-i),i=0),i>r.length&&(r="0".repeat(i-r.length+1)+r),r.length<=40}function ae(e,t){const a=Number(e&&e.size);return!(!e||"context"!==e.type||!Number.isSafeInteger(a)||a<=t||a>1e9)&&["input","output","cacheRead","cacheWrite"].every(t=>te(e[t]))}function ne(e){return null==e||""===e?"0":String(e)}function re(e,t){const a={input:["输入 / 1M","Input / 1M"],output:["输出 / 1M","Output / 1M"],cacheRead:["缓存读 / 1M","Cache read / 1M"],cacheWrite:["缓存写 / 1M","Cache write / 1M"]},n=a[e]||a.input;return"en"===t?n[1]:n[0]}function ie(e){const t=null!==e&&"object"==typeof e?e:{};return String(t.providerId||"").trim().toLowerCase()+"|"+String(t.modelId||"").trim().toLowerCase()}function le(e,t){const a=Array.isArray(e)?e:[],n=ie(t);for(let e=0;e<a.length;e+=1){const t=a[e];if(null!==t&&"object"==typeof t&&ie({providerId:t.providerId,modelId:t.modelId})===n)return e}return-1}function oe(e,t){const a=Array.isArray(e)?e:[],n=String(t||"").trim();if(""===n)return-1;for(let e=0;e<a.length;e+=1){const t=a[e];if(null!==t&&"object"==typeof t&&String(t.identityKey||t.usageIdentityKey||"").trim()===n)return e}return-1}const se=new WeakMap;function ce(e,t,a){const n=null!==e&&"object"==typeof e?e:{sync:{},mappings:[],overrides:[]},r=Array.isArray(n.overrides)?n.overrides.map(e=>Object.assign({},e)):[];let i=le(r,t.basis);if(i<0){const e=null!==t.rates&&"object"==typeof t.rates?t.rates:{},a=Array.isArray(t.tiers)?t.tiers.map(e=>Object.assign({},e)):[];r.push({providerId:t.basis.providerId||"",modelId:t.basis.modelId,displayName:t.model||t.basis.modelId,input:ne(e.input),output:ne(e.output),cacheRead:ne(e.cacheRead),cacheWrite:ne(e.cacheWrite),tiered:a.length>0,tiers:a}),i=r.length-1}return r[i]=Object.assign({},r[i],a),Object.assign({},n,{overrides:r})}function ue(e){const t=String(e??"").trim().match(/^([0-9]{1,2}):([0-9]{1,2})$/);if(null===t)return null;const a=Number(t[1]),n=Number(t[2]);if(!Number.isInteger(a)||!Number.isInteger(n)||n<0||n>59)return null;const r=60*a+n;return r<0||r>1440?null:r}function de(e){const t=Number(e);return!Number.isFinite(t)||t<0||t>1440?"":String(Math.floor(t/60)).padStart(2,"0")+":"+String(t%60).padStart(2,"0")}function pe(e){return"en"===e?0:480}function me(e,t){const a=Number.isFinite(t)?Math.trunc(t):0;if(0===a||!Array.isArray(e))return e;const n=[];for(const t of e){const e=new Map;for(const n of t.windows){const r=n.endMinute+a;let i=n.startMinute+a;for(;i<r;){const a=Math.floor(i/1440),n=i-1440*a,l=Math.min(r-1440*a,1440),o=t.weekdays.map(e=>((e+a)%7+7)%7).sort((e,t)=>e-t),s=o.join(",");let c=e.get(s);void 0===c&&(c={weekdays:o,windows:[]},e.set(s,c)),c.windows.push({startMinute:n,endMinute:l}),i+=l-n}}let r=0;for(const a of e.values())a.windows.sort((e,t)=>e.startMinute-t.startMinute),n.push({id:1===e.size?t.id:t.id+"-"+(r+1),weekdays:a.weekdays,windows:a.windows,rates:t.rates}),r+=1}return n}function he(e,t=0){const a=String(e??"").trim();if(""===a)return 0;const n=a.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/);if(null===n)return null;const r=Number(n[1]),i=Number(n[2]),l=Number(n[3]),o=Date.UTC(r,i-1,l),s=new Date(o);return s.getUTCFullYear()!==r||s.getUTCMonth()!==i-1||s.getUTCDate()!==l?null:o-6e4*(Number.isFinite(t)?Math.trunc(t):0)}function ge(e,t=0){const a=Number(e);if(!Number.isFinite(a)||a<=0)return"";const n=Number.isFinite(t)?Math.trunc(t):0;return new Date(a+6e4*n).toISOString().slice(0,10)}function be(e){const t=String(e??""),a=[],n=new Set;for(const e of t.split("\n")){const t=e.trim();if(""===t)continue;const r=t.split("..");if(r.length>2)return null;const i=r[0].trim(),l=2===r.length?r[1].trim():i;if(""===i||""===l)return null;const o=he(i),s=he(l);if(null===o||null===s||o>s)return null;const c=Math.round((s-o)/864e5)+1;if(c>366||n.size+c>400)return null;for(let e=0;e<c;e+=1){const t=new Date(o+864e5*e).toISOString().slice(0,10);n.has(t)||(n.add(t),a.push(t))}}return a.sort(),a}function fe(e,t=0){const a=null!=e&&Array.isArray(e.policies)?e.policies:[],n=a.length>0&&null!==a[0]&&"object"==typeof a[0]?a[0]:null;if(null===n)return null;const r=me(Array.isArray(n.rules)?n.rules:[],t);return 0===r.length?null:{policyId:"string"==typeof n.policyId&&""!==n.policyId?n.policyId:"custom-peak",effectiveFromText:ge(n.effectiveFrom,t),holidaysEnabled:Array.isArray(n.holidays)&&n.holidays.length>0,holidaysText:Array.isArray(n.holidays)?n.holidays.join("\n"):"",holidaysSourceText:"string"==typeof n.holidaysSource?n.holidaysSource:"",rules:r.map((e,t)=>({id:"string"==typeof e.id&&""!==e.id?e.id:"peak-"+(t+1),weekdays:Array.isArray(e.weekdays)?e.weekdays.slice().sort((e,t)=>e-t):[],windows:(Array.isArray(e.windows)?e.windows:[]).map(e=>({start:de(e.startMinute),end:de(e.endMinute)})),rates:{input:ne(null!==e.rates&&void 0!==e.rates?e.rates.input:""),output:ne(null!==e.rates&&void 0!==e.rates?e.rates.output:""),cacheRead:ne(null!==e.rates&&void 0!==e.rates?e.rates.cacheRead:""),cacheWrite:ne(null!==e.rates&&void 0!==e.rates?e.rates.cacheWrite:"")}}))}}function ye(e,t=0){const a=null!==e&&"object"==typeof e?e:{},n=Number.isFinite(t)?Math.trunc(t):0;return{policyId:"custom-peak",effectiveFromText:"",holidaysEnabled:!1,holidaysText:"",holidaysSourceText:"",rules:[{id:"peak-1",weekdays:[1,2,3,4,5],windows:[{start:de(60+n),end:de(240+n)}],rates:{input:ne(a.input),output:ne(a.output),cacheRead:ne(a.cacheRead),cacheWrite:ne(a.cacheWrite)}}]}}function xe(e){return null===e||"object"!=typeof e?null:{policyId:String(void 0===e.policyId?"":e.policyId),effectiveFromText:String(void 0===e.effectiveFromText?"":e.effectiveFromText),holidaysEnabled:!0===e.holidaysEnabled,holidaysText:String(void 0===e.holidaysText||null===e.holidaysText?"":e.holidaysText),holidaysSourceText:String(void 0===e.holidaysSourceText||null===e.holidaysSourceText?"":e.holidaysSourceText),rules:(Array.isArray(e.rules)?e.rules:[]).map((e,t)=>({id:"string"==typeof e.id&&""!==e.id?e.id:"peak-"+(t+1),weekdays:(Array.isArray(e.weekdays)?e.weekdays:[]).map(Number),windows:(Array.isArray(e.windows)?e.windows:[]).map(e=>({start:String(void 0===e.start?"":e.start),end:String(void 0===e.end?"":e.end)})),rates:{input:String(void 0===e.rates||null===e.rates||void 0===e.rates.input?"":e.rates.input),output:String(void 0===e.rates||null===e.rates||void 0===e.rates.output?"":e.rates.output),cacheRead:String(void 0===e.rates||null===e.rates||void 0===e.rates.cacheRead?"":e.rates.cacheRead),cacheWrite:String(void 0===e.rates||null===e.rates||void 0===e.rates.cacheWrite?"":e.rates.cacheWrite)}}))}}function ve(e,t,a){const n=xe(e);return null===n||void 0===n.rules[t]||(n.rules[t]=Object.assign({},n.rules[t],a)),n}function we(e,t,a){return ve(e,t,{windows:a})}function ke(e,t=0){const a=he(null!==e&&"object"==typeof e?e.effectiveFromText:"",t),n=me((null!==e&&"object"==typeof e&&Array.isArray(e.rules)?e.rules:[]).map((e,t)=>({id:"string"==typeof e.id&&""!==e.id?e.id:"peak-"+(t+1),weekdays:(Array.isArray(e.weekdays)?e.weekdays:[]).slice().sort((e,t)=>e-t),windows:(Array.isArray(e.windows)?e.windows:[]).map(e=>({startMinute:ue(e.start),endMinute:ue(e.end)})),rates:{input:ne(null!==e.rates&&void 0!==e.rates?e.rates.input:""),output:ne(null!==e.rates&&void 0!==e.rates?e.rates.output:""),cacheRead:ne(null!==e.rates&&void 0!==e.rates?e.rates.cacheRead:""),cacheWrite:ne(null!==e.rates&&void 0!==e.rates?e.rates.cacheWrite:"")}})),-t);return{policies:[{policyId:String(null!==e&&"object"==typeof e&&void 0!==e.policyId?e.policyId:"").trim(),timezone:"UTC",effectiveFrom:null===a?0:a,effectiveUntil:null,defaultPlan:null,holidays:null!==e&&"object"==typeof e&&!0===e.holidaysEnabled&&be(e.holidaysText)||[],holidaysSource:null!==e&&"object"==typeof e?String(void 0===e.holidaysSourceText||null===e.holidaysSourceText?"":e.holidaysSourceText).trim().slice(0,512):"",rules:n}]}}function Ee(e){if(null===e||"object"!=typeof e)return"temporal";const t=String(void 0===e.policyId?"":e.policyId).trim();if(""===t||t.length>128)return"temporal";if(null===he(e.effectiveFromText))return"temporal";if(!0===e.holidaysEnabled&&null===be(e.holidaysText))return"temporal";const a=Array.isArray(e.rules)?e.rules:[];if(0===a.length||a.length>16)return"temporal";const n=new Map;for(const e of a){const t=Array.isArray(e.weekdays)?e.weekdays.map(Number):[];if(0===t.length||t.some(e=>!Number.isInteger(e)||e<0||e>6))return"temporal";const a=Array.isArray(e.windows)?e.windows:[];if(0===a.length||a.length>16)return"temporal";for(const e of a){const a=ue(e.start),r=ue(e.end);if(null===a||null===r||r<=a)return"temporal";for(const e of t){const t=void 0===n.get(e)?[]:n.get(e);t.push({start:a,end:r}),n.set(e,t)}}if(!["input","output","cacheRead","cacheWrite"].every(t=>te(null!==e.rates&&void 0!==e.rates?e.rates[t]:"")))return"temporal"}for(const e of n.values()){e.sort((e,t)=>e.start-t.start);for(let t=1;t<e.length;t+=1)if(e[t].start<e[t-1].end)return"temporal"}return""}function Ne(e){const t=String(e||"").trim();return t.includes(" / ")?t:function(e){return String(e||"").trim().toLowerCase().replace(/^.*\//,"").split(":")[0]}(t)}function Ce(e,t){const a=e.split("-"),n="en"===t,r=n?new Date(Date.UTC(Number(a[0]),Number(a[1])-1,Number(a[2]))):new Date(Number(a[0]),Number(a[1])-1,Number(a[2])),i=n?r.getUTCMonth():r.getMonth(),l=n?r.getUTCDay():r.getDay();if("en"===t){const e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][l];return["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][i]+" "+Number(a[2])+", "+a[0]+" ("+e+", UTC)"}const o=["周日","周一","周二","周三","周四","周五","周六"][l];return a[0]+"年"+Number(a[1])+"月"+Number(a[2])+"日 "+o}function Me(e){if(null==e)return null;const t=Number(e.input||0)+Number(e.output||0)+Number(e.cacheRead||0)+Number(e.cacheWrite||0)+Number(e.reasoning||0);return Number.isFinite(t)?t:null}function Se(e,t,a){if("en"===a){const a=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][t];return 0===t?e+" "+a:a}return 0===t?e+"年1月":t+1+"月"}function Ae(e){return e>=10?4:e>=6?3:e>=3?2:e>=1?1:0}const ze=[20,45,70,96];function Te(e){return e<=0?"var(--dsw-alias-bg-layer-2)":"color-mix(in srgb, #0969da "+ze[e-1]+"%, var(--dsw-alias-bg-layer-2))"}function Ie(e){return"hsl("+137*e%360+", 70%, 55%)"}const Re={"30d":5,"90d":13,"12m":53},je=["30d","90d","12m"],De="12m";function Ue(e){return je.includes(e)?e:De}function Fe(e,t,a,n){const r=a&&Array.isArray(e&&e.byDayUtc)?e.byDayUtc:Array.isArray(e&&e.byDay)?e.byDay:[],i=u(new Date,a);if("custom"===t){const e=m(n,a);return null===e?null:{start:e.start,end:e.end}}if("today"===t)return{start:i,end:i};if("7d"===t)return{start:u(d(new Date,-6,a),a),end:i};if("30d"===t)return{start:u(d(new Date,-29,a),a),end:i};if("90d"===t)return{start:u(d(new Date,-89,a),a),end:i};const l=h(r,i);return{start:l.min,end:l.max}}function We(e){return null===e?"":JSON.stringify({start:e.start,end:e.end,utc:!0===e.utc,workspaceId:e.workspaceId||null,provider:e.provider||null,modelKey:e.modelKey||null})}function Oe(e){const t=e&&e.tokens&&"object"==typeof e.tokens?e.tokens:e||{};return{input:Number.isFinite(t.input)?t.input:0,output:Number.isFinite(t.output)?t.output:0,cacheRead:Number.isFinite(t.cacheRead)?t.cacheRead:0,cacheWrite:Number.isFinite(t.cacheWrite)?t.cacheWrite:0,reasoning:Number.isFinite(t.reasoning)?t.reasoning:0}}function Le(e,t,a){const n=e.split("-").map(Number);return u(a?new Date(Date.UTC(n[0],n[1]-1,n[2]+t)):new Date(n[0],n[1]-1,n[2]+t),a)}const Pe=[{days:3,unit:"static"},{days:4,unit:"static"},{days:7,unit:"week",stride:1},{days:10,unit:"static"},{days:14,unit:"week",stride:2},{days:21,unit:"week",stride:3},{days:30,unit:"static"},{days:61,unit:"static"},{days:91,unit:"static"},{days:182,unit:"static"},{days:365,unit:"static"}];function Ke(e,t,a){return e&&Number.isFinite(e.time)?function(e,t,a){const n=a?{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}:{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1};return"en"===t&&(n.timeZone="UTC"),new Date(e).toLocaleString("en"===t?"en-US":"zh-CN",n)}(e.time,t,a):e&&"string"==typeof e.date?a?Ce(e.date,t):e.date.slice(5):""}function qe(e){const t=e&&e.bucket&&"object"==typeof e.bucket?e.bucket:null;return null!==t&&t.days>1&&"string"==typeof t.end}function Be(e,t){return e&&Number.isFinite(e.time)?String(e.time):e&&"string"==typeof e.date?e.date:String(t)}function He(e){return e&&"string"==typeof e.date?e.date:""}function Ye(e,t,a){const n="string"==typeof e.actualModel&&""!==e.actualModel?e.actualModel:"string"==typeof e.requestedModel&&""!==e.requestedModel?e.requestedModel:"",r="string"==typeof e.model&&""!==e.model?e.model:a,i=r.indexOf(" / "),l=("string"==typeof e.provider&&""!==e.provider?e.provider:"")||(i>0?r.slice(0,i):t),o=l!==t?l+" / ":"",s=""!==n?r:""!==o&&r.startsWith(o)?r.slice(o.length):i>0?r.slice(i+3):r;return{provider:l,model:Ne(n||s)||a}}function Ve(e,t){const[a,r]=n.useState({value:0,done:!1});return n.useEffect(()=>{if("number"!=typeof e||!Number.isFinite(e)||e<=0)return void r({value:0,done:!1});if(a.done)return void r({value:e,done:!0});const n=Date.now(),i=t.interval(()=>{const t=Math.min(1,(Date.now()-n)/700),a=1-Math.pow(1-t,3);t>=1?(i(),r({value:e,done:!0})):r({value:Math.round(e*a),done:!1})},32);return i},[e]),a.value}function Je(e){if(!Array.isArray(e)||0===e.length)return"";if(1===e.length)return"M"+e[0].x.toFixed(2)+" "+e[0].y.toFixed(2);const t=[];for(let a=0;a<e.length-1;a+=1){const n=e[a+1].x-e[a].x;t.push(0===n?0:(e[a+1].y-e[a].y)/n)}const a=new Array(e.length).fill(0);a[0]=t[0],a[e.length-1]=t[t.length-1];for(let n=1;n<e.length-1;n+=1){const e=t[n-1],r=t[n];a[n]=e*r<=0?0:(e+r)/2}for(let e=0;e<t.length;e+=1){if(0===t[e]){a[e]=0,a[e+1]=0;continue}const n=a[e]/t[e],r=a[e+1]/t[e],i=n*n+r*r;if(i>9){const l=3/Math.sqrt(i);a[e]=l*n*t[e],a[e+1]=l*r*t[e]}}let n="M"+e[0].x.toFixed(2)+" "+e[0].y.toFixed(2);for(let t=0;t<e.length-1;t+=1){const r=e[t+1].x-e[t].x,i=e[t].x+r/3,l=e[t].y+a[t]*r/3,o=e[t+1].x-r/3,s=e[t+1].y-a[t+1]*r/3;n+=" C"+i.toFixed(2)+" "+l.toFixed(2)+" "+o.toFixed(2)+" "+s.toFixed(2)+" "+e[t+1].x.toFixed(2)+" "+e[t+1].y.toFixed(2)}return n}function Ge(e){if(!Array.isArray(e)||e.length<2)return 1;let t=0;for(let a=1;a<e.length;a+=1){const n=e[a].x-e[a-1].x,r=e[a].y-e[a-1].y;t+=Math.sqrt(n*n+r*r)}return Math.max(1,Math.ceil(1.35*t+2))}const $e=["#0a84ff","#30d158","#bf5af2","#ff9f0a","#ff375f","#64d2ff"],_e={total:"#f4c542",input:"#5aa9ff",cacheRead:"#44d483",cacheWrite:"#d98bff",output:"#ff8c66",reasoning:"#aab4c4"},Xe={total:.2,input:.16,cacheRead:.18,cacheWrite:.14,output:.16,reasoning:.1};function Ze(e,t){const a=O(e,t);return""!==a?a:w(e)}function Qe(e,t){return Ze(e,t)+("en"===t?" tokens":" Token")}function et(e,t,a,n,r){const i=Math.max(0,r-n),l=n=>({x:e+a*Math.cos(n),y:t+a*Math.sin(n)}),o=l(n);if(i>=2*Math.PI-1e-4){const e=l(n+Math.PI);return"M"+o.x.toFixed(2)+" "+o.y.toFixed(2)+" A"+a+" "+a+" 0 1 1 "+e.x.toFixed(2)+" "+e.y.toFixed(2)+" A"+a+" "+a+" 0 1 1 "+o.x.toFixed(2)+" "+o.y.toFixed(2)}const s=l(r);return"M"+o.x.toFixed(2)+" "+o.y.toFixed(2)+" A"+a+" "+a+" 0 "+(i>Math.PI?1:0)+" 1 "+s.x.toFixed(2)+" "+s.y.toFixed(2)}const tt=n.memo(function(e){const t="en"===e.language?"en":"zh",[a,r]=n.useState(null),i=n.useRef(null),l=n.useRef(null),o=n.useRef(null),s=n.useRef(null),c=n.useMemo(()=>function(e,t,a=5){const n=Math.max(1,Number.isInteger(a)?a:5),r=(Array.isArray(e)?e:[]).map((e,t)=>({label:e&&void 0!==e.label?String(e.label):"",value:Number(e&&e.value),color:e&&"string"==typeof e.color&&""!==e.color?e.color:$e[t%$e.length],iconKey:e&&void 0!==e.iconKey?e.iconKey:void 0,cost:Y(e)})).filter(e=>""!==e.label&&Number.isFinite(e.value)&&e.value>0).sort((e,t)=>t.value-e.value),i=r.reduce((e,t)=>e+t.value,0);if(i<=0)return{total:0,segments:[]};const l=r.slice(0,n),o=r.slice(n),s=o.reduce((e,t)=>e+t.value,0);if(s>0){const e={currency:"USD",input:"0",output:"0",cacheRead:"0",cacheWrite:"0",baseTotal:"0",total:"0",pricedCalls:0,unpricedCalls:0,ambiguousCalls:0,unsupportedCalls:0};for(const t of o)V(e,t.cost);l.push({label:t+" ("+(r.length-n)+")",value:s,color:"#b8c2cf",iconKey:null,cost:e,other:!0})}let c=-Math.PI/2;return{total:i,segments:l.map((e,t)=>{const a=e.value/i*Math.PI*2,n=l.length>1?Math.min(.018,a/3):0,r=c+n,o=c+a-n;return c+=a,{...e,index:t,percentage:e.value/i*100,startAngle:o<=r?c-a:r,endAngle:o<=r?c:o}})}}(e.items,"en"===t?"Other":"其他"),[e.items,t]),u=null===a?null:c.segments[a]||null,d=e=>(e>=10?Math.round(e):Math.round(10*e)/10)+"%",p=n.useCallback(()=>{o.current=null,null!==s.current&&(window.clearTimeout(s.current),s.current=null);const e=i.current,t=l.current;if(null!==e&&null!==t){if(t.fixed)e.style.left=t.left+"px",e.style.top=t.top+"px";else{const a=t.visual?.getBoundingClientRect();if(!a)return;const n=198,r=82;e.style.left=Math.max(8,Math.min(Math.max(8,a.width-n),t.x-a.left+14))+"px",e.style.top=Math.max(8,Math.min(Math.max(8,a.height-r),t.y-a.top+14))+"px"}e.style.visibility="visible"}},[]),m=n.useCallback(e=>{l.current=e,null===o.current&&(o.current=window.requestAnimationFrame(p),s.current=window.setTimeout(()=>{null!==o.current&&(window.cancelAnimationFrame(o.current),p())},80))},[p]),h=n.useCallback(e=>{m({x:e.clientX,y:e.clientY,visual:e.currentTarget.ownerSVGElement?.parentElement})},[m]),g=n.useCallback(()=>{r(null),l.current=null},[]);return n.useEffect(()=>()=>{null!==o.current&&window.cancelAnimationFrame(o.current),null!==s.current&&window.clearTimeout(s.current)},[]),n.useEffect(()=>{null!==a&&null!==l.current&&null===o.current&&(o.current=window.requestAnimationFrame(p))},[a,p]),c.total<=0?null:n.createElement("div",{className:"uh-donut-chart","aria-label":e.title},n.createElement("div",{className:"uh-donut-title"},n.createElement(C,{name:e.icon||"chart",size:16}),e.title),n.createElement("div",{className:"uh-donut-layout"},n.createElement("div",{className:"uh-donut-visual"},n.createElement("svg",{className:"uh-donut-svg",viewBox:"0 0 260 260",role:"img","aria-label":e.title+" "+Qe(c.total,t)},n.createElement("circle",{cx:130,cy:130,r:77.5,className:"uh-donut-track",fill:"none",stroke:"var(--dsw-alias-bg-layer-2)",strokeWidth:33}),c.segments.map(e=>n.createElement("path",{key:"donut-"+e.index,d:et(130,130,77.5,e.startAngle,e.endAngle),className:"uh-donut-segment"+(a===e.index?" uh-active":""),fill:"none",stroke:e.color,strokeWidth:33,strokeLinecap:"butt",strokeLinejoin:"round",pathLength:1,style:{animationDelay:90*e.index+"ms"},tabIndex:0,"aria-label":e.label+" "+Qe(e.value,t)+" "+d(e.percentage)+" "+J(e.cost,t),onMouseEnter:t=>{r(e.index),h(t)},onMouseMove:h,onMouseLeave:g,onFocus:()=>{r(e.index),m({fixed:!0,left:12,top:12})},onBlur:g}))),u?n.createElement("div",{ref:i,className:"uh-donut-tooltip",style:{visibility:"hidden"}},n.createElement("span",{className:"uh-donut-dot",style:{background:u.color}}),void 0===u.iconKey||null===u.iconKey?null:n.createElement(ct,{iconKey:u.iconKey,size:15}),n.createElement("div",{},n.createElement("strong",{},u.label),n.createElement("span",{},Qe(u.value,t)+" · "+d(u.percentage)),n.createElement("span",{className:"uh-donut-tooltip-cost"},J(u.cost,t)))):null,n.createElement("div",{className:"uh-donut-center"},n.createElement("strong",{},Ze(c.total,t)),n.createElement("span",{},"en"===t?"tokens":"Token"))),n.createElement("div",{className:"uh-donut-legend",role:"list"},c.segments.map(e=>n.createElement("div",{key:"legend-"+e.index,className:"uh-donut-legend-row",role:"listitem"},n.createElement("span",{className:"uh-donut-legend-mark"},n.createElement("span",{className:"uh-donut-dot",style:{background:e.color}}),void 0===e.iconKey||null===e.iconKey?null:n.createElement(ct,{iconKey:e.iconKey,size:16,showTitle:!0})),n.createElement("div",{className:"uh-donut-legend-copy"},n.createElement("strong",{title:e.label},e.label)),n.createElement("div",{className:"uh-donut-legend-metrics"},n.createElement("span",{},Qe(e.value,t)),n.createElement("span",{className:"uh-donut-cost"},J(e.cost,t))),n.createElement("strong",{className:"uh-donut-percent"},d(e.percentage)))))))});function at(e,t){return{total:"en"===t?"Total":"总处理",input:"en"===t?"Input":"输入",cacheRead:"en"===t?"Cache hits":"缓存命中",cacheWrite:"en"===t?"Cache writes":"缓存写入",output:"en"===t?"Output":"输出",reasoning:"en"===t?"Reasoning":"推理"}[e]||e}const nt=n.memo(function(e){const t="en"===e.language?"en":"zh",a=(e,a)=>"en"===t?a:e,r=Array.isArray(e.rows)?e.rows:[],i=Array.isArray(e.visible)&&e.visible.length>0?e.visible:["total"],[l,o]=n.useState(null),[s,c]=n.useState(null),u=280,d=n.useMemo(()=>function(e,t,a=900,n=250){const r=Array.isArray(t)&&t.length>0?t:["total"],i={left:46,right:14,top:14,bottom:30},l=Math.max(1,a-i.left-i.right),o=Math.max(1,n-i.top-i.bottom),s=(Array.isArray(e)?e:[]).flatMap(e=>r.map(t=>"total"===t?e.total:e.tokens[t]||0)),c=Math.max(1,...s),u={};for(const t of r)u[t]=(Array.isArray(e)?e:[]).map((a,n)=>({x:i.left+(e.length>1?n*l/(e.length-1):l/2),y:i.top+o-("total"===t?a.total:a.tokens[t]||0)/c*o,value:"total"===t?a.total:a.tokens[t]||0}));return{width:a,height:n,padding:i,max:c,points:u}}(r,i,900,u),[r,i]),p=_e,m=Xe,h=u-d.padding.bottom,g=n.useMemo(()=>{const e={};for(const t of i){const a=d.points[t]||[],n=Je(a);e[t]={line:n,area:0===a.length?"":n+" L"+a[a.length-1].x.toFixed(2)+" "+h+" L"+a[0].x.toFixed(2)+" "+h+" Z",length:Ge(a)}}return e},[d,i,h]),b=n.useMemo(()=>r.length<=1?[0]:Array.from(new Set([0,Math.floor((r.length-1)/4),Math.floor((r.length-1)/2),Math.floor(3*(r.length-1)/4),r.length-1])),[r]),f=!e.loading&&!e.error&&r.length>0,y=r.length>0&&Number.isFinite(r[0].time),x=!y&&r.length>0&&qe(r[0]),v=x&&"day"!==r[0].bucket.granularity?function(e,t){const a=e&&e[0]&&e[0].bucket?e[0].bucket:null;if(null===a)return"";const n=function(e){const t=new Map;for(const a of Array.isArray(e)?e:[]){const e=a&&a.bucket&&Number.isFinite(a.bucket.days)?a.bucket.days:0;e<=0||t.set(e,(t.get(e)||0)+1)}let a=0,n=0;for(const[e,r]of t)(r>n||r===n&&e>a)&&(a=e,n=r);return a}(e);if("week"===a.granularity){const e=Math.max(1,Math.round(n/7));return e<=1?"en"===t?"Weekly":"按周汇总":"en"===t?"Every "+e+" weeks":"每 "+e+" 周汇总"}return n<=1?"en"===t?"Daily":"按天汇总":n<28?("en"===t?"Every ":"每 ")+n+("en"===t?" days":" 天汇总"):n<300?"en"===t?"Monthly":"按月汇总":"en"===t?"Yearly":"按年汇总"}(r,t):"",k=n.useCallback((e,a)=>qe(e)?function(e,t,a){const n=Ke(e,t,a);return a?n+" – "+Ce(e.bucket.end,t):n}(e,t,a):Ke(e,t,a),[t]),E=y?a("每小时 Token 使用趋势,选择小时查看当天请求日志","Hourly Token usage trend; select an hour to view request logs"):a("每日 Token 使用趋势,选择日期查看请求日志","Daily Token usage trend; select a date to view request logs"),N=(null===l||r[l],null===l?null:(d.points[i[0]]||[])[l]||null),M=null===s?null:r[s]||null,S=null===s?null:(d.points[i[0]]||[])[s]||null,A=null!==l&&null!==M&&null!==S,z=null!==S&&S.x>612?" uh-left":" uh-right",T=null===S?void 0:{left:(S.x/900*100).toFixed(2)+"%",top:Math.max(23,Math.min(77,S.y/u*100)).toFixed(2)+"%"},I=e=>{o(e),c(e)},R=e.loading?n.createElement("div",{className:"uh-trend-stage uh-trend-loading",role:"status","aria-label":a("正在加载趋势","Loading trend")},n.createElement("span",{className:"uh-trend-spinner","aria-hidden":!0})):e.error?n.createElement("div",{className:"uh-trend-stage uh-trend-message",role:"alert"},e.error):0===r.length?n.createElement("div",{className:"uh-trend-stage uh-trend-message"},a("该范围内暂无趋势数据","No trend data in this range")):n.createElement("div",{className:"uh-trend-chart-wrap"},n.createElement("svg",{className:"uh-trend-svg",viewBox:"0 0 900 "+u,role:"group","aria-label":E},[0,.5,1].map(e=>n.createElement(n.Fragment,{key:e},n.createElement("line",{x1:d.padding.left,x2:900-d.padding.right,y1:d.padding.top+(u-d.padding.top-d.padding.bottom)*e,y2:d.padding.top+(u-d.padding.top-d.padding.bottom)*e,className:"uh-trend-grid"}),n.createElement("text",{x:d.padding.left-7,y:d.padding.top+(u-d.padding.top-d.padding.bottom)*e+4,className:"uh-trend-axis-label",textAnchor:"end"},w(Math.round(d.max*(1-e)))))),n.createElement("defs",{},i.map(e=>n.createElement("linearGradient",{key:e,id:"uh-trend-gradient-"+e,x1:"0",y1:"0",x2:"0",y2:"1"},n.createElement("stop",{offset:"4%",stopColor:p[e]||"#9aa4b2",stopOpacity:m[e]||.12}),n.createElement("stop",{offset:"96%",stopColor:p[e]||"#9aa4b2",stopOpacity:0})))),i.map((e,t)=>{const a=g[e]?g[e].area:"";return""===a?null:n.createElement("path",{key:"area-"+e,d:a,className:"uh-trend-area","data-series":e,fill:"url(#uh-trend-gradient-"+e+")",style:{animationDelay:80+80*t+"ms"}})}),i.map(e=>n.createElement("path",{key:"line-base-"+e,d:g[e]?g[e].line:"",className:"uh-trend-line","data-series":e,stroke:p[e]||"#9aa4b2"})),i.map((e,t)=>{d.points[e];const a=g[e]?g[e].length:0;return n.createElement("path",{key:"line-draw-"+e,d:g[e]?g[e].line:"",className:"uh-trend-line-draw","data-series":e,stroke:p[e]||"#9aa4b2",style:{"--uh-draw-length":a+"px",animationDelay:90*t+"ms"}})}),i.map(e=>{const t=d.points[e]||[];if(1!==t.length)return null;const a=t[0];return n.createElement("circle",{key:"single-point-"+e,cx:a.x,cy:a.y,r:4,className:"uh-trend-point",fill:p[e]||"#9aa4b2"})}),null!==l&&N?n.createElement(n.Fragment,{key:"hover-"+l},n.createElement("line",{x1:N.x,x2:N.x,y1:d.padding.top,y2:h,className:"uh-trend-cursor"}),i.map(e=>{const t=(d.points[e]||[])[l];return t?n.createElement("circle",{key:e,cx:t.x,cy:t.y,r:4,className:"uh-trend-point",fill:p[e]||"#9aa4b2"}):null})):null,r.map((a,r)=>{const l=(d.points[i[0]]||[])[r];if(!l)return null;const s=(d.points[i[0]]||[])[r+1],c=s?Math.max(8,s.x-l.x):r>0?Math.max(8,l.x-(d.points[i[0]]||[])[r-1].x):24;return n.createElement("rect",{key:Be(a,r),x:Math.max(d.padding.left,l.x-c/2),y:d.padding.top,width:c,height:u-d.padding.top-d.padding.bottom,className:"uh-trend-hit",tabIndex:x?-1:0,role:x?"img":"button","aria-label":k(a,!0)+" "+at("total",t)+" "+w(a.total),onMouseEnter:()=>I(r),onMouseLeave:()=>o(null),onFocus:()=>I(r),onBlur:()=>o(null),onKeyDown:t=>{x||"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),"function"==typeof e.onPointClick&&e.onPointClick(He(a)))},onClick:()=>{x||"function"==typeof e.onPointClick&&e.onPointClick(He(a))}})}),b.map(e=>{const t=(d.points[i[0]]||[])[e],a=r[e];return t&&a?n.createElement("text",{key:Be(a,e),x:t.x,y:272,className:"uh-trend-axis-label",textAnchor:0===e?"start":e===r.length-1?"end":"middle"},k(a,!1)):null})),M&&S?n.createElement("div",{className:"uh-trend-tooltip"+z+(A?" uh-visible":""),style:T,"aria-hidden":!A},n.createElement("strong",{className:"uh-trend-tooltip-title"},k(M,!0)),i.map(e=>n.createElement("div",{key:e,className:"uh-trend-tooltip-row",style:{color:p[e]||"#9aa4b2"}},n.createElement("span",{className:"uh-trend-dot",style:{background:p[e]||"#9aa4b2"}}),n.createElement("span",{className:"uh-trend-tooltip-label"},at(e,t)),n.createElement("strong",{className:"uh-trend-tooltip-value"},w(function(e,t){return"total"===t?e.total:e.tokens&&Number.isFinite(e.tokens[t])?e.tokens[t]:0}(M,e)))))):null);return n.createElement("div",{className:"uh-panel uh-trend-panel"},n.createElement("div",{className:"uh-trend-head"},n.createElement("div",{},n.createElement("h3",{className:"uh-tbl-title uh-title-with-icon"},n.createElement(C,{name:"chart",size:16}),a("Token 使用趋势","Token Usage Trend")),n.createElement("div",{className:"uh-note"},(e.rangeLabel||"")+(x?(e.rangeLabel?" · ":"")+v:""))),f?n.createElement("div",{className:"uh-note"},x?a("区间较长,每点为一个周期","Long range summarised: one point per period"):a("点击数据点查看当日明细","Click a point to inspect that day")):null),R,f?n.createElement("div",{className:"uh-trend-legend"},["total","input","cacheRead","cacheWrite","output","reasoning"].map(a=>n.createElement("button",{key:a,type:"button",className:"uh-trend-legend-item"+(i.includes(a)?" uh-on":""),onClick:()=>(t=>{"function"==typeof e.onToggle&&e.onToggle(t)})(a),"aria-pressed":i.includes(a)},n.createElement("span",{className:"uh-trend-dot",style:{background:p[a]||"#9aa4b2"}}),at(a,t)))):null)}),rt=n.memo(function(e){const t="en"===e.language?"en":"zh",a=e.day,r=n.useMemo(()=>(a&&Array.isArray(a.perWorkspace)?a.perWorkspace:[]).slice().sort((e,t)=>t.turns-e.turns),[a]),i=void 0===a?null:Oe(a),l=null!==i&&i.input+i.output+i.cacheRead>0?"en"===t?"Tokens: Input "+w(i.input)+" · Cache hits "+w(i.cacheRead)+" · Output "+w(i.output):"Token:输入 "+w(i.input)+" · 缓存命中 "+w(i.cacheRead)+" · 输出 "+w(i.output):"";return n.createElement("div",{ref:e.tooltipRef,className:"uh-tip",style:{left:0,top:0,visibility:"hidden"}},n.createElement("div",{className:"uh-tip-date"},Ce(e.date,t)),void 0!==a&&a.turns>0?r.map(a=>n.createElement("div",{key:a.workspaceId,className:"uh-tip-row",onClick:()=>e.onWorkspaceSelect(a.workspaceId)},n.createElement("span",{className:"uh-dot",style:{background:Ie(e.workspaceIndexes.get(a.workspaceId)||0)}}),n.createElement("span",{},e.workspaceTitles.get(a.workspaceId)||("en"===t?"Unknown workspace":"未知工作区")),n.createElement("span",{className:"uh-n"},"en"===t?a.turns+" uses":a.turns+" 次"))):n.createElement("div",{className:"uh-empty",style:{padding:"6px 0"}},"en"===t?"No usage records for this day":"这一天没有使用记录"),""!==l?n.createElement("div",{className:"uh-tip-tokens"},l):null)}),it=n.memo(function(e){const t="en"===e.language?"en":"zh",a=(e,a)=>"en"===t?a:e,r=Array.isArray(e.workspaces)?e.workspaces:[],i=Array.isArray(e.rows)?e.rows:[],l=e.workspaceId||null,[o,s]=n.useState(null),c=n.useRef(null),p=n.useRef(null),m=n.useRef({x:0,y:0}),h=n.useRef(null),g=n.useRef(null),b=n.useRef(e.onDateClick),f=n.useRef(e.onWorkspaceSelect);b.current=e.onDateClick,f.current=e.onWorkspaceSelect;const y=(x=e.span,Re[Ue(x)]);var x;const v=y<Re[De]?34*y+3*(y-1)+"px":null,w={minWidth:13*y+"px"},k={gridTemplateColumns:"repeat("+y+", minmax(10px, 1fr))",minWidth:13*y+"px"};null!==v&&(w.maxWidth=v,k.maxWidth=v);const E=n.useMemo(()=>function(e,t,a,n){const r=Number.isSafeInteger(n)&&n>0&&n<=53?n:Re[De],i=String(e||"").split("-").map(Number),l=t?new Date(Date.UTC(i[0],i[1]-1,i[2])):new Date(i[0],i[1]-1,i[2]),o=t?l.getUTCDay():l.getDay(),s=d(l,-o,t),c=d(s,7*-(r-1),t),p=[];for(let e=0;e<7*r;e+=1){const a=d(c,e,t);p.push({date:u(a,t),month:t?a.getUTCMonth():a.getMonth(),year:t?a.getUTCFullYear():a.getFullYear()})}const m=[];for(let e=0;e<r;e+=1){const t=p[7*e],n=e>0?p[7*(e-1)]:null;null!==n&&t.month===n.month||m.push({left:100*e/r+"%",text:Se(t.year,t.month,a)})}return{cells:p,months:m,weekdays:"en"===a?["","Mon","","Wed","","Fri",""]:["","周一","","周三","","周五",""]}}(e.todayKey,!0===e.utc,t,y),[e.todayKey,e.utc,t,y]),N=n.useMemo(()=>{const e=new Map;for(const t of i)t&&"string"==typeof t.date&&e.set(t.date,t);return e},[i]),M=n.useMemo(()=>{const t=new Map,n=new Map,i=e.aliases&&"object"==typeof e.aliases?e.aliases:{};return r.forEach((e,r)=>{const l=i[e.id],o=!0===e.retiredBucket,s=o?a("已删除","Deleted"):"string"==typeof l&&""!==l?l:e.title||a("未知工作区","Unknown workspace");t.set(e.id,!0!==e.deleted||o?s:s+a("(已删除)"," (deleted)")),n.set(e.id,r)}),{titles:t,indexes:n}},[r,e.aliases,t]),S=n.useCallback(()=>{h.current=null,null!==g.current&&(window.clearTimeout(g.current),g.current=null);const e=p.current;if(null===e)return;const t=m.current,a="undefined"==typeof window?1280:window.innerWidth;e.style.left=t.x+14+"px",e.style.top=t.y+12+"px",e.style.transform=t.x>.65*a?"translateX(calc(-100% - 28px))":"none",e.style.visibility="visible"},[]),A=n.useCallback((e,t)=>{m.current={x:e,y:t},null===h.current&&(h.current=window.requestAnimationFrame(S),g.current=window.setTimeout(()=>{null!==h.current&&(window.cancelAnimationFrame(h.current),S())},80))},[S]);n.useEffect(()=>()=>{null!==h.current&&window.cancelAnimationFrame(h.current),null!==g.current&&window.clearTimeout(g.current)},[]),n.useEffect(()=>{null!==o&&null===h.current&&(h.current=window.requestAnimationFrame(S))},[o,S]);const z=n.useCallback((e,t)=>{c.current!==e&&(c.current=e,s(e)),A(t.clientX,t.clientY)},[A]),T=n.useRef([]),I=n.useCallback(e=>{const t=T.current,a=null==t?void 0:t[e];if(null!=a&&"function"==typeof a.focus){for(const e of t)null!=e&&(e.tabIndex=-1);a.tabIndex=0,a.focus()}},[]),R=n.useCallback((e,t)=>{const a=null==t||"function"!=typeof t.getBoundingClientRect?null:t.getBoundingClientRect();z(e,{clientX:null===a?0:a.left+a.width/2,clientY:null===a?0:a.top})},[z]),j=n.useCallback((e,t,a)=>{const n=e.key;if("Enter"===n||" "===n||"Spacebar"===n){e.preventDefault();const t=null===e.currentTarget?"":e.currentTarget.getAttribute("data-date");return void("function"==typeof b.current&&"string"==typeof t&&b.current(t))}const r="ArrowRight"===n?t+1:"ArrowLeft"===n?t-1:"ArrowDown"===n?t+7:"ArrowUp"===n?t-7:"Home"===n?0:"End"===n?a-1:null;null!==r&&(e.preventDefault(),r<0||r>=a||I(r))},[I]),D=n.useCallback(e=>{A(e.clientX,e.clientY)},[A]),U=n.useCallback(()=>{c.current=null,s(null)},[]),F=n.useCallback(e=>{"function"==typeof f.current&&f.current(e),U()},[U]),W=n.useMemo(()=>{const t=E.cells.map(e=>e.date);if(t.indexOf(e.todayKey)>=0)return e.todayKey;for(let e=t.length-1;e>=0;e-=1)if(N.has(t[e]))return t[e];return t.length>0?t[0]:null},[E.cells,N,e.todayKey]),O=E.cells.length,L=n.useMemo(()=>E.cells.map((a,r)=>{const i=N.get(a.date);let o=0;if(void 0!==i)if(!0===e.queryUsable||null===l)o=i.turns;else{const e=Array.isArray(i.perWorkspace)?i.perWorkspace.find(e=>e.workspaceId===l):void 0;void 0!==e&&(o=e.turns)}const s=null!==l&&void 0!==i&&i.turns>0&&0===o,c=function(e,t,a){const n=Ce(e,a),r=Number.isFinite(t)&&t>0?t:0;return"en"===a?n+": "+(r>0?r+" uses":"no usage"):n+":"+(r>0?r+" 次使用":"无使用记录")}(a.date,o,t),u={background:Te(Ae(o)),opacity:s?.22:1,animationDelay:r%25*6+"ms"};return a.date!==e.todayKey||function(){try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch(e){return!1}}()||(u.animation="uh-cell-in .45s ease both, uh-glow 3s ease-in-out .7s infinite"),n.createElement("div",{key:a.date,className:"uh-cell",style:u,role:"button","data-date":a.date,"aria-label":c,tabIndex:a.date===W?0:-1,ref:e=>{T.current[r]=e},onMouseEnter:e=>z(a.date,e),onMouseMove:D,onMouseLeave:U,onFocus:e=>R(a.date,e.currentTarget),onBlur:U,onKeyDown:e=>j(e,r,O),onClick:()=>{"function"==typeof b.current&&b.current(a.date)}})}),[E.cells,N,e.queryUsable,e.todayKey,l,z,D,U,R,j,W,O,t]),P=null===o?void 0:N.get(o);return n.createElement("div",{className:"uh-panel"},n.createElement("div",{className:"uh-section-title"},n.createElement(C,{name:"calendar",size:16}),a("使用热力图","Usage Heatmap")),n.createElement("div",{className:"uh-hm-head"},n.createElement("div",{className:"uh-chips"},r.map((e,t)=>n.createElement("button",{key:e.id,className:"uh-chip"+(l===e.id?" uh-on":""),onClick:()=>F(e.id),title:e.path||(!0===e.retiredBucket?a("已删除","Deleted"):"")},n.createElement("span",{className:"uh-dot",style:{background:Ie(t)}}),n.createElement("span",{className:"uh-chip-title"},M.titles.get(e.id))))),n.createElement("div",{className:"uh-hm-tools"},n.createElement("div",{className:"uh-range uh-heatmap-spans",role:"group","aria-label":a("热力图范围","Heatmap span")},je.map(t=>n.createElement("button",{key:t,type:"button",className:Ue(e.span)===t?"uh-on":"","aria-pressed":Ue(e.span)===t,title:"30d"===t?a("最近 30 天(格子更大)","Last 30 days (larger cells)"):"90d"===t?a("最近 90 天","Last 90 days"):a("最近 12 个月","Last 12 months"),onClick:()=>{"function"==typeof e.onSpanChange&&e.onSpanChange(t)}},"30d"===t?a("30 天","30 days"):"90d"===t?a("90 天","90 days"):a("12 个月","12 months")))),n.createElement("div",{className:"uh-legend","aria-hidden":!0},n.createElement("span",{},a("少","Less")),[0,1,2,3,4].map(e=>n.createElement("span",{key:e,className:"uh-cell",style:{background:Te(e)}})),n.createElement("span",{},a("多","More"))))),n.createElement("div",{className:"uh-hm-scroll"},n.createElement("div",{className:"uh-months",style:w},E.months.map((e,t)=>n.createElement("span",{key:t,style:{left:e.left}},e.text))),n.createElement("div",{className:"uh-hm-body"},n.createElement("div",{className:"uh-wdays"},E.weekdays.map((e,t)=>n.createElement("span",{key:t},e))),n.createElement("div",{className:"uh-grid",style:k,role:"group","aria-label":a("使用热力图日历:方向键浏览,回车查看当日明细","Usage heatmap calendar: arrow keys to browse, Enter for the day detail")},L))),n.createElement("div",{className:"uh-note",style:{marginTop:10}},a("口径:每完成一个回合点亮一次(含子代理会话);悬停查看按工作区明细,点击工作区可筛选热力图与明细表;键盘可用方向键浏览、回车查看当日明细。日期按本地时区。","Methodology: one cell lights up for each completed turn, including subagent sessions. Hover to view workspace details; click a workspace to filter the heatmap and detail tables. English dates and day boundaries use UTC.")),null!==o?n.createElement(rt,{date:o,day:P,language:t,tooltipRef:p,workspaceTitles:M.titles,workspaceIndexes:M.indexes,onWorkspaceSelect:F}):null)});function lt(e,t){return Number(e&&e.values&&e.values[t])||0}const ot=n.memo(function(e){return e.render()},(e,t)=>e.revision===t.revision),st=n.memo(function(e){return e.render(e.view)},function(e,t){return e===t||e.busy===t.busy&&e.language===t.language&&e.openSection===t.openSection&&e.searchText===t.searchText&&e.searchOpen===t.searchOpen&&e.searchOptions===t.searchOptions&&e.temporalDraft===t.temporalDraft&&e.temporalPlan===t.temporalPlan&&e.holidayStatus===t.holidayStatus&&e.holidayLoading===t.holidayLoading&&(a=e.view,n=t.view,a===n||null!=a&&null!=n&&a.key===n.key&&a.model===n.model&&a.status===n.status&&a.reason===n.reason&&a.source===n.source&&a.mapped===n.mapped&&a.usageBacked===n.usageBacked&&a.mappable===n.mappable&&a.pricingModel===n.pricingModel&&a.providerId===n.providerId&&a.tiered===n.tiered&&a.tierCount===n.tierCount&&a.tieredInvalid===n.tieredInvalid&&a.multiplier===n.multiplier&&a.inputTokenSemantics===n.inputTokenSemantics&&a.temporalExplicit===n.temporalExplicit&&a.temporalBuiltin===n.temporalBuiltin&&a.temporalConfigInvalid===n.temporalConfigInvalid&&a.temporalRulesUnavailable===n.temporalRulesUnavailable&&a.temporalPolicyId===n.temporalPolicyId&&a.temporalRuleCount===n.temporalRuleCount&&a.overrideIndex===n.overrideIndex&&a.mappingIndex===n.mappingIndex&&function(e,t){return e===t||null!=e&&null!=t&&e.input===t.input&&e.output===t.output&&e.cacheRead===t.cacheRead&&e.cacheWrite===t.cacheWrite}(a.rates,n.rates)&&function(e,t){if(e===t)return!0;const a=Array.isArray(e)?e:[],n=Array.isArray(t)?t:[];if(a.length!==n.length)return!1;for(let e=0;e<a.length;e+=1){const t=a[e],r=n[e];if(t!==r){if(null==t||null==r)return!1;if(t.size!==r.size||t.input!==r.input||t.output!==r.output||t.cacheRead!==r.cacheRead||t.cacheWrite!==r.cacheWrite)return!1}}return!0}(a.tiers,n.tiers)&&ie(a.basis)===ie(n.basis));var a,n}),ct=n.memo(function(e){const t=Number.isFinite(e.size)?e.size:18,a=null===e.iconKey?null:void 0!==e.iconKey?A.get(e.iconKey)||null:F(e.row),r=null===a?"":a.key+"\0"+a.href,[i,l]=n.useState(null),o={width:t,height:t,minWidth:t};if(null===a||null!==i&&i===r)return n.createElement("span",{className:"uh-model-icon uh-model-icon-fallback"+(e.className?" "+e.className:""),style:o,"aria-hidden":!0},n.createElement(C,{name:"cache",size:t}));const s=!0===e.showTitle;return n.createElement("span",{className:"uh-model-icon"+(e.className?" "+e.className:""),style:o,...s?{}:{"aria-hidden":!0}},n.createElement("img",{key:r,src:a.href,alt:s?a.label:"",title:s?a.label:void 0,width:t,height:t,loading:"lazy",decoding:"async",draggable:!1,onError:()=>l(r)}))}),ut=n.memo(function(e){const t="en"===e.language?"en":"zh",a=(e,a)=>"en"===t?a:e,r=Array.isArray(e.rows)?e.rows:[],i=n.useMemo(()=>r.find(t=>t.id===e.selectedId)||r[0]||null,[r,e.selectedId]),l=n.useRef(null),o=()=>{!0!==e.hasMore||e.loading||"function"==typeof e.onLoadMore&&e.onLoadMore()};n.useEffect(()=>{const t=l.current;null!==t&&(!0!==e.hasMore||e.loading||t.scrollHeight<=t.clientHeight+4&&o())},[r,e.hasMore,e.loading]);const s=e=>e&&"ledger-recovery"===e.materialization?a("账本恢复","Ledger recovery"):e&&"ledger-reuse"===e.materialization?a("账本复用","Ledger reuse"):e&&"scan"===e.materialization?a("扫描","Scan"):e&&"live"===e.materialization?a("实时","Live"):a("未知","Unknown"),c=(e,a)=>e&&Number.isFinite(e.time)?new Date(e.time).toLocaleString("en"===t?"en-US":"zh-CN","en"===t?a?{timeZone:"UTC"}:{timeZone:"UTC",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}:a?void 0:{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"—",u=t=>{"function"==typeof e.onSelect&&e.onSelect(t)};return n.createElement("div",{className:"uh-panel uh-records-panel",ref:e.panelRef,style:{display:e.visible?"block":"none"}},n.createElement("div",{className:"uh-records-head"},n.createElement("div",{},n.createElement("h3",{className:"uh-tbl-title uh-title-with-icon"},n.createElement(C,{name:"list",size:16}),a("请求日志","Request Logs")),n.createElement("div",{className:"uh-note"},e.scopeLabel+(e.scopeUtc?" · UTC":""))),n.createElement("div",{className:"uh-actions"},e.loading?n.createElement("span",{className:"uh-query-note"},a("同步中…","Refreshing…")):null,n.createElement("button",{type:"button",className:"uh-refresh",title:a("导出当前日志","Export current logs"),onClick:e.onExport,disabled:e.exporting||!e.scopeAvailable},n.createElement(C,{name:"export",size:13}),e.exporting?a("导出中…","Exporting…"):a("导出日志","Export logs")))),""!==e.error?n.createElement("div",{className:"uh-records-error",role:"alert"},"stale"===e.error?a("数据已更新,正在重新加载日志…","Data changed; reloading logs…"):"audit-export"===e.error?a("日志导出失败","Unable to export logs"):a("日志加载失败,请重试","Unable to load logs")):null,n.createElement("div",{className:"uh-records-note"},a("按时间倒序显示可审计的 Token 调用;选择一行查看 turn / step 和完整 Token 分桶。","Token calls are newest first; select a row to inspect its turn / step and token buckets.")),0!==r.length||e.loading?n.createElement("div",{className:"uh-records-scroll",ref:l,onScroll:e=>{const t=e.currentTarget;t.scrollTop+t.clientHeight>=t.scrollHeight-120&&o()}},n.createElement("div",{className:"uh-record-grid uh-record-header"},n.createElement("div",{},a("时间","Time")),n.createElement("div",{},a("Provider / 模型","Provider / Model")),n.createElement("div",{className:"uh-record-num"},"turn / step"),n.createElement("div",{className:"uh-record-num"},a("输入","Input")),n.createElement("div",{className:"uh-record-num"},a("缓存命中","Cache read")),n.createElement("div",{className:"uh-record-num"},a("缓存写入","Cache write")),n.createElement("div",{className:"uh-record-num"},a("输出","Output")),n.createElement("div",{className:"uh-record-num"},a("成本","Cost")),n.createElement("div",{},a("来源","Source"))),r.map(e=>n.createElement("div",{key:e.id,className:"uh-record-grid uh-record-row"+(i&&i.id===e.id?" uh-on":""),role:"button",tabIndex:0,"aria-pressed":i&&i.id===e.id,onClick:()=>u(e.id),onKeyDown:t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),u(e.id))}},n.createElement("div",{className:"uh-record-time"},c(e,!1)),n.createElement("div",{className:"uh-record-model",title:e.model||""},n.createElement("span",{className:"uh-model-label"},n.createElement(ct,{row:e,size:16}),n.createElement("span",{className:"uh-model-text"},e.model||a("未知模型","Unknown model"))),e.requestedModel&&e.actualModel&&e.requestedModel!==e.actualModel?n.createElement("small",{},e.requestedModel+" → "+e.actualModel):null),n.createElement("div",{className:"uh-record-num"},(null===e.turn||void 0===e.turn?"—":e.turn)+" / "+(null===e.step||void 0===e.step?"—":e.step)),n.createElement("div",{className:"uh-record-num"},w(lt(e,"input"))),n.createElement("div",{className:"uh-record-num"},w(lt(e,"cacheRead"))),n.createElement("div",{className:"uh-record-num"},w(lt(e,"cacheWrite"))),n.createElement("div",{className:"uh-record-num"},w(lt(e,"output"))),n.createElement("div",{className:"uh-record-num uh-cost-num"},J(e,t),!e.cost||"peak"!==e.cost.pricingBand&&"off-peak"!==e.cost.pricingBand?null:n.createElement("small",{className:"uh-record-band-badge"},"peak"===e.cost.pricingBand?"en"===t?"Peak":"峰":"en"===t?"OFF":"谷")),n.createElement("div",{className:"uh-record-source"},s(e))))):n.createElement("div",{className:"uh-empty"},a("当前范围没有可审计的 Token 调用","No auditable Token calls in this scope")),n.createElement("div",{className:"uh-records-footer"},n.createElement("span",{className:"uh-note"},r.length>0?e.hasMore?a("已显示 "+r.length+" 条,继续加载可查看更多",r.length+" shown; load more for additional records"):a("共显示 "+r.length+" 条",r.length+" records shown"):""),e.hasMore?n.createElement("button",{type:"button",className:"uh-refresh",onClick:e.onLoadMore,disabled:e.loading},e.loading?a("加载中…","Loading…"):a("加载更多","Load more")):null),i?n.createElement("div",{className:"uh-record-detail"},n.createElement("div",{className:"uh-record-detail-head"},n.createElement("strong",{},a("选中调用","Selected call")),n.createElement("span",{className:"uh-note"},c(i,!0))),n.createElement("div",{className:"uh-record-detail-meta"},n.createElement("span",{className:"uh-model-label"},n.createElement(ct,{row:i,size:16,showTitle:!0}),n.createElement("span",{},(i.provider||a("未知供应商","Unknown provider"))+" / "+(i.actualModel||i.requestedModel||i.model||a("未知模型","Unknown model")))),n.createElement("span",{},"turn "+(null===i.turn||void 0===i.turn?"—":i.turn)+" · step "+(null===i.step||void 0===i.step?"—":i.step)),n.createElement("span",{},a("来源:","Source: ")+s(i)),n.createElement("span",{},a("计价模型:","Pricing model: ")+(i.cost&&i.cost.pricingModel?i.cost.pricingModel:a("未计价","unpriced"))),n.createElement("span",{className:"uh-record-band "+(i.cost&&i.cost.pricingBand?"uh-record-band-"+i.cost.pricingBand:"")},a("计费档位:","Billing band: ")+function(e,t){const a=e&&e.cost&&"object"==typeof e.cost?e.cost:{};return"peak"===a.pricingBand?"en"===t?"Peak":"峰时":"off-peak"===a.pricingBand?!0===a.pricingHoliday?"en"===t?"Holiday off-peak":"节假日谷时":"en"===t?"Off-peak":"谷时":"route-not-official"===a.temporalExemptReason?"en"===t?"static (non-first-party)":"静态价(非官方直连)":"no-temporal-profile"===a.temporalExemptReason?"en"===t?"static (no band plan)":"静态价(无峰谷计划)":"—"}(i,t)),null!==G(i,t)?n.createElement("span",{className:"uh-record-band",title:i.cost&&i.cost.pricingPolicyHash||""},a("计费计划:","Plan: ")+G(i,t)):null),n.createElement("div",{className:"uh-record-token-strip"},["input","cacheRead","cacheWrite","output","reasoning"].map(e=>n.createElement("div",{key:e},n.createElement("span",{},"cacheRead"===e?a("缓存命中","Cache read"):"cacheWrite"===e?a("缓存写入","Cache write"):"reasoning"===e?a("推理","Reasoning"):"input"===e?a("输入","Input"):a("输出","Output")),n.createElement("strong",{},w(lt(i,e))))),n.createElement("div",{className:"uh-record-token-total"},n.createElement("span",{},a("总处理","Total")),n.createElement("strong",{},w(lt(d=i,"input")+lt(d,"cacheRead")+lt(d,"cacheWrite")+lt(d,"output")+lt(d,"reasoning")))),n.createElement("div",{className:"uh-record-token-total"},n.createElement("span",{},a("成本","Cost")),n.createElement("strong",{},J(i,t))))):null);var d},function(e,t){return e.visible===t.visible&&e.scopeLabel===t.scopeLabel&&e.scopeUtc===t.scopeUtc&&e.scopeAvailable===t.scopeAvailable&&e.loading===t.loading&&e.exporting===t.exporting&&e.error===t.error&&e.rows===t.rows&&e.selectedId===t.selectedId&&e.hasMore===t.hasMore&&e.language===t.language&&e.actionKey===t.actionKey}),dt=n.memo(function(e){const t=Array.isArray(e.options)?e.options:[],a=void 0===e.value||null===e.value?"":String(e.value),r=t.find(e=>String(e.value)===a),[i,l]=n.useState(!1),o=n.useRef(null),s=n.useRef(null);n.useEffect(()=>{i&&null!==s.current&&"function"==typeof s.current.scrollIntoView&&s.current.scrollIntoView({block:"nearest",inline:"nearest"})},[i]),n.useEffect(()=>{if(!i||"undefined"==typeof document)return;const e=e=>{o.current&&!o.current.contains(e.target)&&l(!1)};return document.addEventListener("pointerdown",e),()=>document.removeEventListener("pointerdown",e)},[i]);const c=t=>{const a=null==t||void 0===t.iconKey||null===t.iconKey?null:t.iconKey;return null===a?n.createElement(C,{name:e.icon||"chart",size:14}):n.createElement(ct,{iconKey:a,size:14})};return n.createElement("div",{className:"uh-language-menu uh-filter-menu"+(e.className?" "+e.className:"")+(i?" uh-open":""),ref:o,onKeyDown:e=>{"Escape"===e.key&&i&&(e.preventDefault(),e.stopPropagation(),l(!1))}},n.createElement("button",{type:"button",className:"uh-language-trigger uh-filter-trigger"+(i?" uh-open":""),title:r?r.label:e.label,"aria-label":e.ariaLabel||e.label,"aria-haspopup":"listbox","aria-expanded":i,onClick:()=>l(e=>!e)},c(r),n.createElement("span",{className:"uh-filter-label"},r?r.label:e.label),n.createElement(C,{name:"chevron",size:13,className:"uh-language-caret"})),i?n.createElement("div",{className:"uh-language-options uh-filter-options",role:"listbox","aria-label":e.ariaLabel||e.label},t.map(t=>{const r=String(t.value),i=r===a;return n.createElement("button",{key:r,type:"button",role:"option","aria-selected":i,ref:i?s:void 0,className:"uh-language-option"+(i?" uh-on":""),onClick:()=>{return t=r,"function"==typeof e.onChange&&e.onChange(t),void l(!1);var t}},c(t),n.createElement("span",{className:"uh-filter-option-label"},t.label),i?n.createElement(C,{name:"check",size:14,className:"uh-language-option-check"}):null)})):null)}),pt="dsh-all-usage/styles.css";if("undefined"!=typeof document){let e=document.querySelector("style[data-plugin-css="+JSON.stringify(pt)+"]");null===e&&(e=document.createElement("style"),e.dataset.plugin="dsh-all-usage",e.dataset.pluginCss=pt,document.head.appendChild(e)),e.textContent='\n.uh-page { display:flex; flex-direction:column; gap:14px; padding:2px 2px 28px; font-family:inherit; }\n.uh-head { position:relative; z-index:20; display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }\n.uh-title { margin:0; font-size:15px; font-weight:600; color:var(--dsw-alias-label-primary); }\n.uh-title-wrap { display:flex; align-items:center; gap:10px; flex-wrap:wrap; min-width:0; }\n/* Version chip: the running version plus the registry verdict, clickable to the repo. */\n.uh-version { display:inline-flex; align-items:center; gap:6px; border:1px solid var(--dsw-alias-border-l1); background:transparent; color:var(--dsw-alias-label-secondary); border-radius:999px; padding:2px 9px; font:inherit; font-size:12px; cursor:pointer; transition:background-color .15s ease, border-color .15s ease, color .15s ease; }\n.uh-version:hover { background:var(--dsw-alias-bg-layer-1); color:var(--dsw-alias-label-primary); }\n.uh-version-number { font-variant-numeric:tabular-nums; }\n.uh-version-status { color:var(--dsw-alias-label-tertiary, var(--dsw-alias-label-secondary)); }\n.uh-version-outdated { border-color:color-mix(in srgb, var(--dsw-alias-brand-primary) 55%, transparent); color:var(--dsw-alias-brand-primary); }\n.uh-version-outdated .uh-version-status { color:inherit; font-weight:600; }\n.uh-actions { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }\n.uh-language-menu, .uh-filter-menu { position:relative; z-index:12; }\n.uh-filter-menu { flex:0 1 auto; min-width:0; }\n.uh-filter-workspace { width:180px; }\n.uh-filter-provider { width:180px; }\n.uh-filter-model { width:260px; }\n.uh-filter-menu.uh-open { z-index:14; }\n.uh-language-trigger { display:inline-flex; align-items:center; gap:6px; min-height:30px; padding:4px 9px 4px 10px; border:1px solid transparent; border-radius:15px; background:color-mix(in srgb, var(--dsw-alias-label-primary) 7%, var(--dsw-alias-bg-layer-1)); color:var(--dsw-alias-label-primary); font:inherit; font-size:12px; font-weight:600; line-height:1; cursor:pointer; transition:border-color .15s ease, background-color .15s ease, transform .1s ease; }\n.uh-filter-trigger { width:100%; min-width:0; justify-content:flex-start; }\n.uh-language-trigger:hover, .uh-language-trigger.uh-open { border-color:color-mix(in srgb, var(--dsw-alias-brand-primary) 58%, var(--dsw-alias-border-l2)); background:color-mix(in srgb, var(--dsw-alias-brand-primary) 13%, var(--dsw-alias-bg-layer-1)); }\n.uh-language-trigger:active { transform:scale(.96); }\n.uh-language-label { min-width:26px; text-align:left; }\n.uh-filter-label { min-width:0; flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; text-align:left; }\n.uh-language-caret { color:var(--dsw-alias-label-secondary); transition:transform .18s ease; }\n.uh-language-trigger.uh-open .uh-language-caret { transform:rotate(180deg); }\n.uh-language-menu.uh-open { z-index:30; }\n.uh-language-options { position:absolute; top:calc(100% + 7px); right:0; min-width:142px; padding:5px; border:1px solid var(--dsw-alias-border-l2); border-radius:12px; background:var(--dsw-alias-bg-layer-1); box-shadow:0 14px 28px color-mix(in srgb, #000 24%, transparent); animation:uh-menu-in .16s ease both; }\n.uh-filter-options { left:0; right:auto; min-width:100%; max-width:300px; }\n.uh-language-option { display:flex; align-items:center; gap:8px; width:100%; min-height:32px; padding:6px 8px; border:0; border-radius:8px; background:transparent; color:var(--dsw-alias-label-primary); font:inherit; font-size:12px; text-align:left; cursor:pointer; transition:background-color .14s ease, color .14s ease; }\n.uh-filter-option-label { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }\n.uh-language-option:hover, .uh-language-option:focus-visible { background:color-mix(in srgb, var(--dsw-alias-brand-primary) 14%, var(--dsw-alias-bg-layer-2)); outline:0; }\n.uh-language-option.uh-on { background:color-mix(in srgb, var(--dsw-alias-brand-primary) 19%, var(--dsw-alias-bg-layer-2)); color:var(--dsw-alias-label-primary); font-weight:600; }\n.uh-language-option-check { margin-left:auto; color:var(--dsw-alias-brand-primary); }\n/* Provider and model lists grow with the ledger; the menu scrolls inside itself\n instead of running past the bottom of the window. */\n.uh-filter-options { max-height:min(60vh, 420px); overflow-y:auto; overscroll-behavior:contain; }\n.uh-range { display:inline-flex; border:1px solid var(--dsw-alias-border-l2); border-radius:8px; overflow:hidden; }\n.uh-range button { border:0; background:transparent; color:var(--dsw-alias-label-secondary); padding:4px 12px; font-size:12px; cursor:pointer; font-family:inherit; transition:background-color .15s ease, color .15s ease; }\n.uh-range button + button { border-left:1px solid var(--dsw-alias-border-l2); }\n.uh-range button.uh-on { background:color-mix(in srgb, var(--dsw-alias-brand-primary) 20%, var(--dsw-alias-bg-layer-2)); color:var(--dsw-alias-label-primary); font-weight:600; }\n.uh-custom-range { display:grid; grid-template-columns:minmax(180px, 1fr) auto auto; gap:10px 14px; align-items:end; padding:12px; border:1px solid var(--dsw-alias-border-l1); border-radius:10px; background:var(--dsw-alias-bg-layer-1); }\n.uh-custom-range-meta { min-width:0; }\n.uh-custom-range-title { display:flex; align-items:center; gap:7px; color:var(--dsw-alias-label-primary); font-size:13px; font-weight:600; }\n.uh-custom-range-note { margin-top:3px; color:var(--dsw-alias-label-secondary); font-size:11px; line-height:1.45; }\n.uh-custom-range-fields { display:grid; grid-template-columns:repeat(2, minmax(136px, 1fr)); gap:8px; }\n.uh-custom-range-field { display:flex; flex-direction:column; gap:4px; color:var(--dsw-alias-label-secondary); font-size:11px; }\n.uh-custom-range-field input { min-width:0; min-height:30px; border:1px solid var(--dsw-alias-border-l2); border-radius:6px; padding:3px 7px; background:var(--dsw-alias-bg-base); color:var(--dsw-alias-label-primary); font:inherit; font-size:12px; outline:none; }\n.uh-custom-range-field input:focus { border-color:var(--dsw-alias-brand-primary); }\n.uh-custom-range-actions { display:flex; gap:6px; }\n.uh-custom-range-cancel, .uh-custom-range-apply { min-height:30px; border-radius:6px; padding:4px 10px; font:inherit; font-size:12px; cursor:pointer; }\n.uh-custom-range-cancel { border:1px solid var(--dsw-alias-border-l2); background:transparent; color:var(--dsw-alias-label-primary); }\n.uh-custom-range-apply { border:1px solid var(--dsw-alias-brand-primary); background:color-mix(in srgb, var(--dsw-alias-brand-primary) 16%, transparent); color:var(--dsw-alias-label-primary); }\n.uh-custom-range-apply:disabled { opacity:.48; cursor:not-allowed; }\n.uh-custom-range-error { grid-column:1 / -1; color:#d92d20; font-size:12px; }\n.uh-refresh { border:1px solid var(--dsw-alias-border-l2); background:var(--dsw-alias-bg-layer-1); color:var(--dsw-alias-label-primary); border-radius:8px; padding:4px 12px; font-size:12px; cursor:pointer; font-family:inherit; transition:border-color .15s ease, color .15s ease, transform .1s ease; }\n.uh-refresh:hover { border-color:var(--dsw-alias-brand-primary); }\n.uh-refresh:active, .uh-chip:active, .uh-range button:active { transform:scale(.96); }\n.uh-alias-panel-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:10px; font-size:13px; font-weight:600; color:var(--dsw-alias-label-primary); }\n.uh-alias-close { border:0; background:transparent; color:var(--dsw-alias-label-secondary); font-size:12px; cursor:pointer; font-family:inherit; padding:0; transition:color .15s ease; }\n.uh-alias-close:hover { color:var(--dsw-alias-brand-primary); }\n.uh-alias-list { display:grid; grid-template-columns:repeat(auto-fill, minmax(250px, 1fr)); gap:8px 16px; max-height:240px; overflow-y:auto; }\n.uh-alias-item { display:flex; align-items:center; gap:8px; min-width:0; }\n.uh-alias-folder { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:11px; color:var(--dsw-alias-label-secondary); }\n.uh-alias-input { flex:none; width:150px; border:1px solid var(--dsw-alias-border-l2); background:var(--dsw-alias-bg-base); color:var(--dsw-alias-label-primary); border-radius:6px; padding:3px 8px; font-size:12px; font-family:inherit; outline:none; transition:border-color .15s ease; }\n.uh-alias-input:focus { border-color:var(--dsw-alias-brand-primary); }\n.uh-alias-panel-foot { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-top:10px; padding-top:10px; border-top:1px solid var(--dsw-alias-border-l1); }\n.uh-alias-ok { border:1px solid var(--dsw-alias-brand-primary); background:color-mix(in srgb, var(--dsw-alias-brand-primary) 16%, transparent); color:var(--dsw-alias-label-primary); border-radius:6px; font-size:12px; padding:3px 12px; cursor:pointer; font-family:inherit; flex:none; transition:transform .1s ease; }\n.uh-alias-ok:active { transform:scale(.96); }\n.uh-anim-panel { animation:uh-panel-in .28s ease both; }\n.uh-pricing-panel { display:flex; flex-direction:column; gap:12px; }\n.uh-pricing-head, .uh-pricing-toolbar, .uh-pricing-foot { display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; }\n.uh-pricing-note { color:var(--dsw-alias-label-secondary); font-size:12px; line-height:1.55; }\n.uh-pricing-toolbar { padding:10px 0; border-top:1px solid var(--dsw-alias-border-l1); border-bottom:1px solid var(--dsw-alias-border-l1); }\n.uh-pricing-switch { display:inline-flex; align-items:center; gap:7px; color:var(--dsw-alias-label-primary); font-size:12px; }\n.uh-pricing-section { display:flex; flex-direction:column; gap:8px; }\n.uh-pricing-table-wrap { max-height:392px; overflow-x:hidden; overflow-y:scroll; scrollbar-gutter:stable; scrollbar-width:auto; scrollbar-color:#707780 #1d1f22; border:1px solid var(--dsw-alias-border-l1); border-radius:8px; background:var(--dsw-alias-bg-layer-2); }\n.uh-pricing-model-table { width:100%; min-width:1080px; border-collapse:collapse; table-layout:fixed; font-size:11px; }\n.uh-pricing-model-table th, .uh-pricing-model-table td { min-width:0; padding:8px 9px; border-bottom:1px solid var(--dsw-alias-border-l1); text-align:left; vertical-align:middle; }\n.uh-pricing-model-table th { position:sticky; top:0; z-index:40; color:var(--dsw-alias-label-secondary); background:var(--dsw-alias-bg-layer-2); font-weight:650; white-space:nowrap; }\n.uh-pricing-model-table th:nth-child(1) { width:24%; }\n.uh-pricing-model-table th:nth-child(2) { width:84px; }\n.uh-pricing-model-table th:nth-child(3) { width:20%; }\n.uh-pricing-model-table th:nth-child(4) { width:96px; }\n.uh-pricing-model-table th:nth-child(n+5) { width:100px; text-align:right; }\n.uh-pricing-model-table td:nth-child(n+5) { text-align:right; }\n.uh-pricing-model-table tbody tr:last-child td { border-bottom:0; }\n.uh-pricing-model-table tbody tr:not(.uh-pricing-tier-row):hover { background:color-mix(in srgb, var(--dsw-alias-bg-layer-1) 65%, transparent); }\n.uh-pricing-model-name, .uh-pricing-model-target { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--dsw-alias-label-primary); }\n.uh-pricing-model-rate { color:var(--dsw-alias-label-secondary); font-variant-numeric:tabular-nums; white-space:nowrap; }\n.uh-pricing-status, .uh-pricing-tier-badge { display:inline-flex; justify-content:center; padding:3px 6px; border-radius:6px; font-size:10px; font-weight:650; white-space:nowrap; }\n.uh-pricing-status-priced { color:#157347; background:color-mix(in srgb, #30d158 22%, transparent); }\n.uh-pricing-status-unpriced, .uh-pricing-status-ambiguous, .uh-pricing-status-unsupported { color:#9a5b00; background:color-mix(in srgb, #ff9f0a 20%, transparent); }\n.uh-pricing-tier-badge { color:var(--dsw-alias-brand-primary); background:color-mix(in srgb, var(--dsw-alias-brand-primary) 15%, transparent); }\n.uh-pricing-tier-badge.uh-flat { color:var(--dsw-alias-label-secondary); background:var(--dsw-alias-bg-layer-1); }\n.uh-pricing-tier-row > td { padding:0 9px 8px; background:color-mix(in srgb, var(--dsw-alias-bg-layer-1) 36%, transparent); }\n.uh-pricing-tier-details > summary { display:inline-flex; align-items:center; gap:6px; min-height:28px; color:var(--dsw-alias-label-secondary); cursor:pointer; list-style:none; font-size:11px; }\n.uh-pricing-tier-details > summary::-webkit-details-marker { display:none; }\n.uh-pricing-tier-caret { transition:transform .15s ease; }\n.uh-pricing-tier-details[open] .uh-pricing-tier-caret { transform:rotate(180deg); }\n.uh-pricing-tier-context { margin-left:6px; color:var(--dsw-alias-label-tertiary, var(--dsw-alias-label-secondary)); }\n.uh-pricing-tier-table { width:100%; margin:2px 0 5px; border:1px solid var(--dsw-alias-border-l1); border-radius:6px; border-collapse:separate; border-spacing:0; overflow:hidden; table-layout:fixed; background:var(--dsw-alias-bg-base); }\n.uh-pricing-tier-table th, .uh-pricing-tier-table td { position:static; width:auto !important; padding:6px 8px; border-bottom:1px solid var(--dsw-alias-border-l1); text-align:right !important; background:transparent; font-size:10px; }\n.uh-pricing-tier-table th:first-child, .uh-pricing-tier-table td:first-child { width:30% !important; text-align:left !important; }\n.uh-pricing-tier-table tbody tr:last-child td { border-bottom:0; }\n.uh-pricing-tier-table tbody tr:hover { background:color-mix(in srgb, var(--dsw-alias-brand-primary) 6%, transparent); }\n.uh-pricing-model-search { position:relative; z-index:2; min-width:0; display:flex; align-items:center; gap:6px; }\n.uh-pricing-model-search .uh-pricing-model-search-input { flex:1 1 auto; width:auto; }\n.uh-pricing-clear-mapping { flex:none; white-space:nowrap; }\n.uh-pricing-model-search:focus-within { z-index:30; }\n.uh-pricing-model-search-input { box-sizing:border-box; width:100%; min-width:0; min-height:30px; border:1px solid var(--dsw-alias-border-l2); border-radius:6px; padding:4px 7px; background:var(--dsw-alias-bg-base); color:var(--dsw-alias-label-primary); font:inherit; font-size:11px; outline:none; }\n.uh-pricing-model-search-input:focus { border-color:var(--dsw-alias-brand-primary); }\n.uh-pricing-model-options { top:calc(100% + 7px); left:0; right:auto; width:100%; min-width:280px; max-height:240px; overflow-y:auto; z-index:40; }\n.uh-pricing-model-option { align-items:flex-start; }\n.uh-pricing-model-option-name { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }\n.uh-pricing-model-option-id { margin-left:auto; padding-left:10px; color:var(--dsw-alias-label-secondary); font-size:10px; white-space:nowrap; }\n.uh-pricing-edit-row { display:grid; grid-template-columns:minmax(240px,1.2fr) minmax(260px,1.3fr) minmax(78px,.45fr) 32px; gap:10px; align-items:center; min-width:650px; }\n.uh-pricing-price-row { grid-template-columns:repeat(5,minmax(108px,1fr)) 32px; min-width:650px; }\n.uh-pricing-price-head { display:grid; grid-template-columns:repeat(5,minmax(108px,1fr)) 32px; gap:10px; align-items:center; min-width:650px; color:var(--dsw-alias-label-secondary); font-size:10px; }\n.uh-pricing-price-head span { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }\n.uh-pricing-edit-row input, .uh-pricing-tier-edit-row input { box-sizing:border-box; min-width:0; min-height:30px; border:1px solid var(--dsw-alias-border-l2); border-radius:6px; padding:4px 7px; background:var(--dsw-alias-bg-base); color:var(--dsw-alias-label-primary); font:inherit; font-size:11px; outline:none; }\n.uh-pricing-edit-row input:focus, .uh-pricing-tier-edit-row input:focus { border-color:var(--dsw-alias-brand-primary); }\n.uh-pricing-edit-row .uh-refresh, .uh-pricing-tier-edit-row .uh-refresh { min-height:30px; padding:0; }\n.uh-pricing-overrides { display:flex; flex-direction:column; min-width:760px; }\n.uh-pricing-override { display:flex; flex-direction:column; gap:8px; padding:10px 0; border-bottom:1px solid var(--dsw-alias-border-l1); }\n.uh-pricing-override:last-child { border-bottom:0; }\n.uh-pricing-tier-editor { margin-left:10px; padding-left:12px; border-left:2px solid color-mix(in srgb, var(--dsw-alias-brand-primary) 34%, var(--dsw-alias-border-l1)); }\n.uh-pricing-tier-editor-head { display:flex; align-items:center; justify-content:space-between; gap:10px; min-height:30px; }\n.uh-pricing-tier-editor-title { display:flex; align-items:baseline; gap:8px; min-width:0; }\n.uh-pricing-tier-editor-title strong { font-size:11px; }\n.uh-pricing-tier-editor-title span { color:var(--dsw-alias-label-secondary); font-size:10px; }\n.uh-pricing-tier-edit-head, .uh-pricing-tier-edit-row { display:grid; grid-template-columns:minmax(120px,.85fr) repeat(4,minmax(72px,1fr)) 30px; gap:10px; align-items:center; min-width:0; }\n.uh-pricing-tier-edit-head { margin:5px 0; color:var(--dsw-alias-label-secondary); font-size:10px; }\n.uh-pricing-tier-edit-row { margin-top:7px; }\n.uh-pricing-tier-edit-row.uh-invalid input { border-color:var(--dsw-alias-warning, #a55b00); }\n.uh-pricing-tier-empty { padding:5px 0; color:var(--dsw-alias-label-secondary); font-size:10px; }\n.uh-pricing-error { color:var(--dsw-alias-warning, #a55b00); font-size:12px; line-height:1.45; }\n.uh-pricing-foot { padding-top:4px; }\n\n.uh-pricing-table-note { color:var(--dsw-alias-label-secondary); font-size:11px; line-height:1.5; }\n.uh-pricing-price-table { width:100%; min-width:0; }\n.uh-pricing-price-table th:nth-child(1) { width:20%; }\n.uh-pricing-price-table th:nth-child(2) { width:24%; }\n.uh-pricing-price-table th:nth-child(3), .uh-pricing-price-table th:nth-child(4), .uh-pricing-price-table th:nth-child(5), .uh-pricing-price-table th:nth-child(6) { width:11%; }\n.uh-pricing-price-table th:nth-child(7) { width:12%; }\n.uh-pricing-table-wrap .uh-pricing-price-table th, .uh-pricing-table-wrap .uh-pricing-price-table td { text-align:left; }\n.uh-pricing-price-table th, .uh-pricing-price-table td { padding:8px 8px; }\n.uh-pricing-price-table td { vertical-align:top; }\n.uh-pricing-row-flags { display:flex; align-items:center; flex-wrap:wrap; gap:4px; margin-top:5px; }\n.uh-pricing-flag { padding:2px 6px; border-radius:999px; background:var(--dsw-alias-bg-layer-1); color:var(--dsw-alias-label-secondary); font-size:10px; white-space:nowrap; }\n.uh-pricing-configured-row { background:color-mix(in srgb, var(--dsw-alias-bg-layer-1) 42%, transparent); }\n/* Unknown usage (the host did not label the row) is not the same verdict as\n "no ledger usage", so it must not read like one. */\n.uh-pricing-unknown-row { background:color-mix(in srgb, var(--dsw-alias-bg-layer-1) 24%, transparent); }\n.uh-pricing-flag-unknown { border-style:dashed; opacity:.75; }\n.uh-pricing-rate-input { box-sizing:border-box; width:100%; min-width:0; min-height:30px; border:1px solid var(--dsw-alias-border-l2); border-radius:6px; padding:4px 7px; background:var(--dsw-alias-bg-base); color:var(--dsw-alias-label-primary); font:inherit; font-size:11px; font-variant-numeric:tabular-nums; outline:none; }\n.uh-pricing-rate-input:focus { border-color:var(--dsw-alias-brand-primary); }\n.uh-pricing-map-cell { display:flex; flex-direction:column; gap:6px; }\n.uh-pricing-map-sub { display:flex; align-items:center; flex-wrap:wrap; gap:8px; }\n.uh-pricing-map-field { display:inline-flex; align-items:center; gap:5px; color:var(--dsw-alias-label-secondary); font-size:10px; }\n.uh-pricing-map-field input, .uh-pricing-map-field select { box-sizing:border-box; min-height:26px; border:1px solid var(--dsw-alias-border-l2); border-radius:6px; padding:2px 6px; background:var(--dsw-alias-bg-base); color:var(--dsw-alias-label-primary); font:inherit; font-size:11px; outline:none; }\n.uh-pricing-map-field input { width:70px; }\n.uh-pricing-link { border:0; background:transparent; color:var(--dsw-alias-brand-primary); font:inherit; font-size:11px; cursor:pointer; padding:2px 0; text-decoration:underline; }\n.uh-pricing-link:disabled { color:var(--dsw-alias-label-secondary); cursor:default; text-decoration:none; }\n.uh-pricing-chip { min-height:28px; padding:3px 9px; border:1px solid var(--dsw-alias-border-l2); border-radius:999px; background:var(--dsw-alias-bg-base); color:var(--dsw-alias-label-secondary); font:inherit; font-size:10px; cursor:pointer; white-space:nowrap; }\n.uh-pricing-chip.uh-on, .uh-pricing-chip.uh-strong { border-color:var(--dsw-alias-brand-primary); color:var(--dsw-alias-label-primary); background:color-mix(in srgb, var(--dsw-alias-brand-primary) 12%, transparent); }\n.uh-pricing-row-actions { display:flex; align-items:center; flex-wrap:wrap; gap:5px; white-space:nowrap; }\n.uh-pricing-editor-row > td { padding:0 9px 10px; background:color-mix(in srgb, var(--dsw-alias-bg-layer-1) 36%, transparent); }\n.uh-pricing-editor { display:flex; flex-direction:column; gap:10px; min-width:0; overflow-x:auto; }\n.uh-pricing-editor-foot { display:flex; justify-content:flex-end; }\n.uh-pricing-temporal-fields { display:flex; align-items:flex-end; flex-wrap:wrap; gap:10px; margin-top:6px; }\n.uh-pricing-temporal-fields label { display:inline-flex; flex-direction:column; gap:4px; color:var(--dsw-alias-label-secondary); font-size:10px; }\n.uh-pricing-temporal-fields input { box-sizing:border-box; min-height:28px; border:1px solid var(--dsw-alias-border-l2); border-radius:6px; padding:3px 7px; background:var(--dsw-alias-bg-base); color:var(--dsw-alias-label-primary); font:inherit; font-size:11px; outline:none; }\n.uh-pricing-temporal-fields input:focus { border-color:var(--dsw-alias-brand-primary); }\n.uh-pricing-temporal-rule { margin-top:8px; padding:8px 10px; border:1px solid var(--dsw-alias-border-l1); border-radius:8px; background:var(--dsw-alias-bg-base); }\n.uh-pricing-temporal-rule-head { display:flex; align-items:center; flex-wrap:wrap; gap:8px; }\n.uh-pricing-temporal-rule-name { color:var(--dsw-alias-label-secondary); font-size:10px; font-variant-numeric:tabular-nums; }\n.uh-pricing-weekdays { display:inline-flex; gap:3px; }\n.uh-pricing-weekday { width:26px; height:26px; border:1px solid var(--dsw-alias-border-l2); border-radius:6px; background:var(--dsw-alias-bg-base); color:var(--dsw-alias-label-secondary); font:inherit; font-size:10px; cursor:pointer; }\n.uh-pricing-weekday.uh-on { border-color:var(--dsw-alias-brand-primary); color:var(--dsw-alias-label-primary); background:color-mix(in srgb, var(--dsw-alias-brand-primary) 14%, transparent); }\n.uh-pricing-temporal-windows { display:flex; align-items:center; flex-wrap:wrap; gap:7px; margin-top:7px; }\n.uh-pricing-temporal-window { display:inline-flex; align-items:center; gap:5px; }\n.uh-pricing-time-input { box-sizing:border-box; width:66px; min-height:28px; border:1px solid var(--dsw-alias-border-l2); border-radius:6px; padding:3px 6px; background:var(--dsw-alias-bg-base); color:var(--dsw-alias-label-primary); font:inherit; font-size:11px; font-variant-numeric:tabular-nums; text-align:center; outline:none; }\n.uh-pricing-time-input:focus { border-color:var(--dsw-alias-brand-primary); }\n.uh-pricing-time-sep { color:var(--dsw-alias-label-secondary); }\n.uh-pricing-temporal-rates { display:flex; flex-wrap:wrap; gap:9px; margin-top:8px; }\n.uh-pricing-temporal-rate { display:inline-flex; align-items:center; gap:5px; color:var(--dsw-alias-label-secondary); font-size:10px; }\n.uh-pricing-temporal-rate input { box-sizing:border-box; width:86px; min-height:28px; border:1px solid var(--dsw-alias-border-l2); border-radius:6px; padding:3px 7px; background:var(--dsw-alias-bg-base); color:var(--dsw-alias-label-primary); font:inherit; font-size:11px; font-variant-numeric:tabular-nums; outline:none; }\n.uh-pricing-temporal-foot { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-top:8px; }\n.uh-pricing-temporal-holidays { display:flex; flex-direction:column; gap:6px; margin-top:8px; padding:8px 10px; border:1px solid var(--dsw-alias-border-l1); border-radius:8px; background:var(--dsw-alias-bg-base); }\n.uh-pricing-holiday-load { display:flex; align-items:center; flex-wrap:wrap; gap:8px; }\n.uh-pricing-holiday-load input[type=\'number\'] { box-sizing:border-box; width:82px; min-height:28px; border:1px solid var(--dsw-alias-border-l2); border-radius:6px; padding:3px 7px; background:var(--dsw-alias-bg-base); color:var(--dsw-alias-label-primary); font:inherit; font-size:11px; outline:none; }\n.uh-pricing-holiday-input { box-sizing:border-box; width:100%; min-height:74px; resize:vertical; border:1px solid var(--dsw-alias-border-l2); border-radius:6px; padding:6px 8px; background:var(--dsw-alias-bg-base); color:var(--dsw-alias-label-primary); font:inherit; font-size:11px; font-variant-numeric:tabular-nums; outline:none; }\n.uh-pricing-holiday-input:focus { border-color:var(--dsw-alias-brand-primary); }\n.uh-pricing-warning { margin-top:7px; padding:7px 9px; border-radius:7px; border:1px solid color-mix(in srgb, var(--dsw-alias-warning, #d9822b) 40%, var(--dsw-alias-border-l1)); color:var(--dsw-alias-warning, #a55b00); font-size:11px; line-height:1.45; }\n@media (max-width:640px) {\n .uh-pricing-table-wrap { overflow-x:auto; }\n .uh-pricing-price-table { min-width:820px; }\n .uh-pricing-map-cell { min-width:170px; }\n}\n\n.uh-cost-num { color:var(--dsw-alias-label-primary); }\n.uh-progress { font-size:12px; color:var(--dsw-alias-label-secondary); display:flex; align-items:center; gap:10px; }\n.uh-sync-health { margin-top:8px; padding:8px 12px; display:flex; align-items:center; flex-wrap:wrap; gap:6px; border:1px solid var(--dsw-alias-border-l1); border-radius:10px; color:var(--dsw-alias-label-secondary); background:var(--dsw-alias-bg-layer-1); font-size:11px; line-height:1.45; }\n.uh-sync-health.uh-stale { color:var(--dsw-alias-warning, #a55b00); border-color:color-mix(in srgb, var(--dsw-alias-warning, #d9822b) 45%, var(--dsw-alias-border-l1)); }\n.uh-sync-retry { border:0; background:transparent; color:inherit; font:inherit; text-decoration:underline; cursor:pointer; padding:0 2px; }\n.uh-trend-panel { min-height:300px; animation:uh-panel-in .38s ease both; }\n.uh-trend-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; margin-bottom:10px; }\n.uh-trend-chart-wrap { position:relative; min-height:250px; width:100%; overflow:hidden; }\n.uh-trend-stage { display:grid; place-items:center; min-height:250px; width:100%; }\n.uh-trend-message { color:var(--dsw-alias-label-secondary); font-size:12px; }\n.uh-trend-spinner { width:24px; height:24px; border:2px solid color-mix(in srgb, var(--dsw-alias-brand-primary) 22%, var(--dsw-alias-border-l2)); border-top-color:var(--dsw-alias-brand-primary); border-radius:50%; animation:uh-spinner-turn .78s linear infinite; }\n.uh-trend-svg { display:block; width:100%; height:auto; min-height:220px; }\n.uh-trend-grid { stroke:var(--dsw-alias-border-l1); stroke-width:1; stroke-dasharray:3 4; opacity:.8; }\n.uh-trend-cursor { stroke:var(--dsw-alias-label-secondary); stroke-width:1; stroke-dasharray:3 4; opacity:.65; pointer-events:none; }\n.uh-trend-point { stroke:var(--dsw-alias-bg-layer-1); stroke-width:2; vector-effect:non-scaling-stroke; pointer-events:none; }\n.uh-trend-axis-label { fill:var(--dsw-alias-label-secondary); font-size:11px; font-family:inherit; }\n.uh-trend-line { fill:none; stroke-width:2.2; vector-effect:non-scaling-stroke; stroke-linecap:round; stroke-linejoin:round; opacity:.22; }\n.uh-trend-line-draw { fill:none; stroke-width:2.2; vector-effect:non-scaling-stroke; stroke-linecap:round; stroke-linejoin:round; stroke-dasharray:var(--uh-draw-length); stroke-dashoffset:var(--uh-draw-length); opacity:.96; pointer-events:none; animation:uh-trend-draw .95s cubic-bezier(.22,.61,.36,1) both; }\n.uh-trend-area { opacity:1; animation:uh-trend-fill .8s ease; }\n.uh-trend-hit { fill:transparent; cursor:crosshair; outline:none; }\n.uh-trend-hit:focus { fill:color-mix(in srgb, var(--dsw-alias-brand-primary) 10%, transparent); outline:1px solid var(--dsw-alias-brand-primary); outline-offset:2px; }\n.uh-trend-tooltip { position:absolute; z-index:4; min-width:166px; padding:10px 11px; border:1px solid color-mix(in srgb, var(--dsw-alias-border-l2) 88%, transparent); border-radius:8px; background:color-mix(in srgb, var(--dsw-alias-bg-layer-1) 94%, transparent); box-shadow:0 10px 24px rgba(0,0,0,.22); backdrop-filter:blur(10px); color:var(--dsw-alias-label-primary); font-size:12px; line-height:1.45; pointer-events:none; opacity:0; visibility:hidden; transform:translate(14px,-50%) scale(.985); transform-origin:left center; transition:left .16s cubic-bezier(.22,.61,.36,1), top .16s cubic-bezier(.22,.61,.36,1), opacity .12s ease, transform .16s cubic-bezier(.22,.61,.36,1), visibility 0s linear .16s; }\n.uh-trend-tooltip.uh-left { transform:translate(calc(-100% - 14px),-50%) scale(.985); transform-origin:right center; }\n.uh-trend-tooltip.uh-visible { opacity:1; visibility:visible; transform:translate(14px,-50%) scale(1); transition-delay:0s; }\n.uh-trend-tooltip.uh-left.uh-visible { transform:translate(calc(-100% - 14px),-50%) scale(1); }\n.uh-trend-tooltip-title { display:block; margin-bottom:6px; color:var(--dsw-alias-label-primary); font-size:12px; font-weight:650; }\n.uh-trend-tooltip-row { display:grid; grid-template-columns:8px minmax(0,1fr) auto; align-items:center; gap:7px; min-width:0; margin-top:3px; font-size:11px; }\n.uh-trend-tooltip-row .uh-trend-dot { width:8px; height:8px; margin:0; }\n.uh-trend-tooltip-label { overflow:hidden; font-weight:600; text-overflow:ellipsis; white-space:nowrap; }\n.uh-trend-tooltip-value { color:inherit; font-weight:600; font-variant-numeric:tabular-nums; white-space:nowrap; }\n.uh-trend-dot { display:inline-block; width:7px; height:7px; margin-right:5px; border-radius:50%; vertical-align:1px; }\n.uh-trend-legend { display:flex; flex-wrap:wrap; gap:5px 8px; margin-top:5px; }\n.uh-trend-legend-item { display:inline-flex; align-items:center; gap:3px; border:0; border-radius:7px; padding:3px 6px; background:transparent; color:var(--dsw-alias-label-secondary); font:inherit; font-size:11px; cursor:pointer; transition:color .15s ease; }\n.uh-trend-legend-item:hover { background:var(--dsw-alias-bg-layer-2); color:var(--dsw-alias-label-primary); }\n.uh-trend-legend-item.uh-on { background:var(--dsw-alias-interactive-bg-hover); color:var(--dsw-alias-label-primary); }\n.uh-filter-bar { position:relative; z-index:10; display:flex; align-items:center; flex-wrap:wrap; gap:7px; }\n.uh-filter-clear { border:0; background:transparent; color:var(--dsw-alias-label-secondary); font:inherit; font-size:11px; cursor:pointer; text-decoration:underline; }\n.uh-query-note { color:var(--dsw-alias-label-secondary); font-size:11px; }\n.uh-detail-tabs { display:flex; align-items:center; flex-wrap:wrap; gap:4px; padding:4px; border:1px solid var(--dsw-alias-border-l1); border-radius:9px; background:color-mix(in srgb, var(--dsw-alias-bg-layer-2) 58%, transparent); }\n.uh-detail-tab { display:inline-flex; align-items:center; gap:6px; min-height:32px; padding:5px 11px; border:0; border-radius:7px; background:transparent; color:var(--dsw-alias-label-secondary); font:inherit; font-size:12px; cursor:pointer; transition:background-color .15s ease, color .15s ease, transform .12s ease; }\n.uh-detail-tab:hover { color:var(--dsw-alias-label-primary); background:var(--dsw-alias-bg-layer-2); }\n.uh-detail-tab.uh-on { color:var(--dsw-alias-label-primary); background:var(--dsw-alias-bg-layer-1); box-shadow:0 1px 3px rgba(0,0,0,.14); }\n.uh-records-panel { animation:uh-panel-in .28s ease both; }\n.uh-records-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; margin-bottom:7px; }\n.uh-records-note { margin:8px 0 10px; color:var(--dsw-alias-label-secondary); font-size:11px; line-height:1.45; }\n.uh-records-error { margin:7px 0; color:var(--dsw-alias-warning, #a55b00); font-size:11px; }\n/* The log scrolls inside its own box (and pulls the next page as it nears the end),\n so a long history never pushes the rest of the panel off the screen. */\n.uh-records-scroll { max-height:min(62vh, 560px); overflow:auto; overscroll-behavior:contain; border:1px solid var(--dsw-alias-border-l1); border-radius:8px; }\n.uh-record-grid { display:grid; grid-template-columns:112px minmax(190px,1.45fr) 78px repeat(4,minmax(76px,.72fr)) 96px 82px; gap:0; min-width:900px; align-items:center; }\n.uh-record-grid > div { min-width:0; padding:8px 7px; border-bottom:1px solid var(--dsw-alias-border-l1); font-size:11px; }\n.uh-record-header { color:var(--dsw-alias-label-secondary); background:var(--dsw-alias-bg-layer-2); font-weight:600; }\n.uh-record-header > div { white-space:nowrap; }\n.uh-record-row { color:var(--dsw-alias-label-primary); cursor:pointer; outline:none; transition:background-color .14s ease, box-shadow .14s ease; }\n.uh-record-row:hover { background:color-mix(in srgb, var(--dsw-alias-bg-layer-2) 68%, transparent); }\n.uh-record-row.uh-on { background:color-mix(in srgb, var(--dsw-alias-brand-primary) 10%, var(--dsw-alias-bg-layer-1)); box-shadow:inset 3px 0 var(--dsw-alias-brand-primary); }\n.uh-record-row:focus-visible { box-shadow:inset 0 0 0 1px var(--dsw-alias-brand-primary); }\n.uh-record-row:last-child > div { border-bottom:0; }\n.uh-record-time, .uh-record-num { color:var(--dsw-alias-label-secondary); font-variant-numeric:tabular-nums; white-space:nowrap; }\n.uh-record-num { text-align:right; }\n.uh-model-icon { display:inline-flex; align-items:center; justify-content:center; flex:none; vertical-align:middle; }\n.uh-model-icon img { display:block; width:100%; height:100%; object-fit:contain; }\n.uh-model-icon-fallback { color:var(--dsw-alias-label-tertiary, var(--dsw-alias-label-secondary)); opacity:.85; }\n.uh-model-label { display:flex; align-items:center; gap:7px; min-width:0; }\n.uh-model-label .uh-model-text { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0; }\n.uh-record-model { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-weight:550; }\n.uh-record-model small { display:block; overflow:hidden; color:var(--dsw-alias-label-secondary); font-size:10px; font-weight:400; text-overflow:ellipsis; white-space:nowrap; }\n.uh-record-source { color:var(--dsw-alias-label-secondary); white-space:nowrap; }\n.uh-record-band { white-space:nowrap; }\n.uh-record-band-badge { margin-left:6px; color:var(--dsw-alias-label-secondary); font-size:10px; }\n.uh-record-band-peak { color:var(--dsw-alias-warning, #a55b00); font-weight:600; }\n.uh-record-band-off-peak { color:#2e7d32; }\n.uh-records-footer { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-top:9px; }\n.uh-record-detail { margin-top:12px; padding:10px 11px; border-top:1px solid var(--dsw-alias-border-l2); background:color-mix(in srgb, var(--dsw-alias-bg-layer-2) 42%, transparent); animation:uh-detail-in .24s ease both; }\n.uh-record-detail-head, .uh-record-detail-meta { display:flex; align-items:center; flex-wrap:wrap; gap:7px 14px; }\n.uh-record-detail-head { justify-content:space-between; margin-bottom:5px; color:var(--dsw-alias-label-primary); font-size:12px; }\n.uh-record-detail-meta { color:var(--dsw-alias-label-secondary); font-size:11px; }\n.uh-record-token-strip { display:grid; grid-template-columns:repeat(5,minmax(72px,1fr)) repeat(2,minmax(82px,1.1fr)); gap:6px; margin-top:9px; }\n.uh-record-token-strip > div { display:flex; flex-direction:column; gap:2px; min-width:0; padding:6px 7px; border-radius:6px; background:var(--dsw-alias-bg-layer-2); }\n.uh-record-token-strip span { color:var(--dsw-alias-label-secondary); font-size:10px; }\n.uh-record-token-strip strong { color:var(--dsw-alias-label-primary); font-size:12px; font-variant-numeric:tabular-nums; }\n.uh-record-token-total { border:1px solid color-mix(in srgb, var(--dsw-alias-brand-primary) 38%, var(--dsw-alias-border-l1)) !important; }\n@keyframes uh-detail-in { from { opacity:0; transform:translateY(-4px); } to { opacity:1; transform:translateY(0); } }\n@media (max-width:640px) {\n .uh-trend-head { flex-direction:column; }\n .uh-filter-menu { flex:1 1 130px; width:auto; }\n .uh-filter-trigger { max-width:100%; }\n .uh-trend-tooltip { min-width:116px; }\n .uh-records-head { flex-direction:column; }\n .uh-record-token-strip { grid-template-columns:repeat(2,minmax(0,1fr)); }\n .uh-record-token-total { grid-column:1 / -1; }\n .uh-pricing-head { align-items:flex-start; }\n .uh-pricing-toolbar { align-items:flex-start; }\n .uh-pricing-edit-row { grid-template-columns:minmax(0,1fr) 36px; min-width:0; width:100%; }\n .uh-pricing-edit-row > .uh-pricing-model-search,\n .uh-pricing-price-row > input { grid-column:1 / -1; }\n .uh-pricing-edit-row > input[type=\'number\'] { grid-column:1; }\n .uh-pricing-edit-row > .uh-icon-button { grid-column:2; }\n .uh-pricing-price-head { display:none; }\n .uh-pricing-overrides { min-width:0; width:100%; }\n .uh-pricing-override { min-width:0; }\n .uh-pricing-price-row { grid-template-columns:minmax(0,1fr) 36px; min-width:0; }\n .uh-pricing-price-row > input[type=\'number\'] { grid-column:1 / -1; }\n .uh-pricing-tier-editor { margin-left:0; padding-left:0; border-left:0; }\n .uh-pricing-tier-editor-head { align-items:flex-start; flex-wrap:wrap; }\n .uh-pricing-tier-editor-title { flex-direction:column; gap:2px; }\n .uh-pricing-tier-edit-head { display:none; }\n .uh-pricing-tier-edit-row { grid-template-columns:minmax(0,1fr) 36px; min-width:0; padding:8px; border:1px solid var(--dsw-alias-border-l1); border-radius:6px; }\n .uh-pricing-tier-edit-row > input { grid-column:1 / -1; }\n .uh-pricing-tier-edit-row > .uh-icon-button { grid-column:2; }\n .uh-pricing-tier-context { display:block; margin:2px 0 0; }\n}\n.uh-bar { flex:1; height:6px; border-radius:3px; background:var(--dsw-alias-bg-layer-2); overflow:hidden; max-width:340px; }\n.uh-fill { height:100%; background:var(--dsw-alias-brand-primary); border-radius:3px; transition:width .3s ease; }\n.uh-cards { display:grid; grid-template-columns:repeat(auto-fit, minmax(200px, 1fr)); gap:10px; }\n.uh-card { background:var(--dsw-alias-bg-layer-1); border:1px solid var(--dsw-alias-border-l1); border-radius:12px; padding:12px 14px; display:flex; flex-direction:column; gap:6px; min-height:86px; animation:uh-card-in .45s ease both; transition:transform .18s ease, border-color .18s ease, box-shadow .18s ease; }\n.uh-card:hover { transform:translateY(-2px); border-color:var(--dsw-alias-border-l2); box-shadow:0 6px 18px rgba(0,0,0,.10); }\n.uh-card-label { font-size:12px; color:var(--dsw-alias-label-secondary); }\n.uh-card-value { font-size:20px; font-weight:650; color:var(--dsw-alias-label-primary); line-height:1.2; }\n.uh-card-sub { font-size:11px; color:var(--dsw-alias-label-secondary); line-height:1.55; }\n.uh-wsbars { display:flex; flex-direction:column; gap:3px; margin-top:2px; }\n.uh-wsbar { display:flex; flex-direction:column; gap:1px; cursor:pointer; padding:1px 6px; margin:0 -6px; border-radius:8px; transition:background-color .15s ease; }\n.uh-wsbar:hover { background:var(--dsw-alias-bg-layer-2); }\n.uh-wsbar.uh-sel { outline:1px solid var(--dsw-alias-brand-primary); }\n.uh-wsbar-top { display:flex; align-items:center; gap:6px; min-width:0; }\n.uh-wsbar-title { font-size:12px; color:var(--dsw-alias-label-primary); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; flex:1; min-width:0; }\n.uh-wsbar-num { font-size:11px; font-variant-numeric:tabular-nums; color:var(--dsw-alias-label-secondary); flex:none; }\n.uh-panel { background:var(--dsw-alias-bg-layer-1); border:1px solid var(--dsw-alias-border-l1); border-radius:12px; padding:14px; }\n.uh-hm-head { display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; margin-bottom:10px; }\n.uh-chips { display:flex; flex-wrap:wrap; gap:6px; }\n.uh-hm-tools { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }\n.uh-heatmap-spans button { white-space:nowrap; }\n.uh-chip { display:inline-flex; align-items:center; gap:6px; border:1px solid var(--dsw-alias-border-l2); background:transparent; color:var(--dsw-alias-label-primary); border-radius:999px; padding:2px 10px; font-size:11px; cursor:pointer; font-family:inherit; max-width:190px; transition:border-color .15s ease, background-color .15s ease, color .15s ease, transform .1s ease; }\n.uh-chip .uh-chip-title { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }\n.uh-chip.uh-on { border-color:var(--dsw-alias-brand-primary); background:color-mix(in srgb, var(--dsw-alias-brand-primary) 14%, transparent); }\n.uh-dot { width:8px; height:8px; border-radius:50%; flex:none; }\n.uh-legend { display:flex; align-items:center; gap:4px; font-size:11px; color:var(--dsw-alias-label-secondary); }\n.uh-legend .uh-cell { width:10px; height:10px; border-radius:2px; animation:none; }\n.uh-hm-scroll { overflow-x:auto; padding-bottom:2px; }\n.uh-months { position:relative; height:16px; margin-left:30px; width:calc(100% - 30px); min-width:686px; font-size:10px; color:var(--dsw-alias-label-secondary); }\n.uh-months span { position:absolute; top:0; }\n.uh-hm-body { display:flex; gap:6px; min-width:0; }\n.uh-wdays { display:grid; grid-template-rows:repeat(7,10px); gap:3px; font-size:10px; color:var(--dsw-alias-label-secondary); text-align:right; width:24px; }\n.uh-wdays span { line-height:10px; }\n.uh-grid { flex:1 1 auto; min-width:686px; display:grid; grid-auto-flow:column; grid-template-columns:repeat(53,minmax(10px,1fr)); grid-template-rows:repeat(7,minmax(10px,auto)); gap:3px; }\n.uh-cell { width:100%; height:auto; min-width:10px; aspect-ratio:1; border-radius:2px; background:var(--dsw-alias-bg-layer-2); animation:uh-cell-in .45s ease both; transition:transform .12s ease, box-shadow .12s ease; }\n.uh-cell:hover { transform:scale(1.35); box-shadow:0 1px 6px rgba(0,0,0,.28); position:relative; z-index:2; }\n.uh-tip { position:fixed; z-index:1200; background:var(--dsw-alias-bg-overlay); border:1px solid var(--dsw-alias-border-l2); border-radius:10px; padding:10px 12px; box-shadow:0 8px 24px rgba(0,0,0,.18); pointer-events:auto; min-width:200px; max-width:290px; animation:uh-tip-in .16s ease both; }\n.uh-tip-date { font-size:12px; font-weight:600; color:var(--dsw-alias-label-primary); margin-bottom:6px; }\n.uh-tip-row { display:flex; align-items:center; gap:6px; font-size:12px; color:var(--dsw-alias-label-primary); padding:3px 6px; margin:0 -6px; border-radius:6px; cursor:pointer; transition:background-color .12s ease; }\n.uh-tip-row:hover { background:color-mix(in srgb, var(--dsw-alias-brand-primary) 12%, transparent); }\n.uh-tip-row .uh-n { margin-left:auto; font-variant-numeric:tabular-nums; color:var(--dsw-alias-label-secondary); }\n.uh-tip-tokens { font-size:11px; color:var(--dsw-alias-label-secondary); margin-top:6px; border-top:1px solid var(--dsw-alias-border-l1); padding-top:6px; }\n.uh-tbl-title { font-size:13px; font-weight:600; color:var(--dsw-alias-label-primary); margin:0 0 10px; }\n.uh-tbl-scroll { overflow-x:auto; }\n.uh-hrow, .uh-row { display:grid; grid-template-columns:minmax(160px,2.2fr) .7fr .9fr .9fr .9fr .9fr 1.1fr .9fr .8fr 1fr; gap:8px; align-items:center; min-width:900px; padding:7px 10px; border-radius:8px; font-size:12px; }\n.uh-model-hrow, .uh-model-row { display:grid; grid-template-columns:minmax(190px,2.2fr) .7fr .9fr .9fr .9fr .9fr 1.1fr .9fr .8fr; gap:8px; align-items:center; min-width:860px; padding:7px 10px; border-radius:8px; font-size:12px; }\n.uh-hrow { color:var(--dsw-alias-label-secondary); font-size:11px; }\n.uh-row { cursor:pointer; border:1px solid transparent; transition:background-color .15s ease, border-color .15s ease; }\n.uh-row:hover { background:var(--dsw-alias-bg-layer-2); }\n.uh-row.uh-sel { border-color:var(--dsw-alias-brand-primary); }\n.uh-num { text-align:right; font-variant-numeric:tabular-nums; color:var(--dsw-alias-label-primary); }\n.uh-hrow .uh-num { color:var(--dsw-alias-label-secondary); }\n.uh-ws-title { color:var(--dsw-alias-label-primary); font-weight:550; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }\n.uh-row-title-wrap { min-width:0; }\n.uh-ws-path { color:var(--dsw-alias-label-secondary); font-size:11px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }\n.uh-barwrap { height:5px; border-radius:3px; background:var(--dsw-alias-bg-layer-2); overflow:hidden; margin-top:3px; }\n.uh-barwrap.uh-bar-thin { height:3px; margin-top:1px; }\n.uh-barfill { height:100%; border-radius:3px; transform-origin:left center; animation:uh-bar-grow .7s cubic-bezier(.22,.61,.36,1) both; transition:width .5s cubic-bezier(.22,.61,.36,1); }\n.uh-empty { color:var(--dsw-alias-label-secondary); font-size:12px; text-align:center; padding:26px 0; }\n.uh-note { font-size:11px; color:var(--dsw-alias-label-secondary); line-height:1.6; }\n.uh-side-entry { width:100%; border:0; background:transparent; color:var(--dsw-alias-label-secondary); border-radius:8px; min-height:36px; padding:7px 10px; display:flex; align-items:center; gap:9px; font:inherit; font-size:13px; cursor:pointer; text-align:left; }\n.uh-side-entry:hover { background:var(--dsw-alias-interactive-bg-hover); color:var(--dsw-alias-label-primary); }\n.uh-side-entry-icon { width:18px; text-align:center; flex:none; font-size:15px; }\n.uh-side-entry-label { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }\n.uh-boundary-fallback { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:12px; min-height:360px; padding:24px; border:1px solid var(--dsw-alias-border-l1); border-radius:12px; background:var(--dsw-alias-bg-layer-1); text-align:center; }\n.uh-boundary-title { color:var(--dsw-alias-label-primary); font-size:15px; font-weight:650; }\n.uh-boundary-note { max-width:420px; color:var(--dsw-alias-label-secondary); font-size:12px; line-height:1.6; }\n.uh-side-modal { position:fixed; inset:var(--uh-top-inset, 0px) 0 0 0; z-index:1100; background:color-mix(in srgb, #000 44%, transparent); display:flex; align-items:stretch; justify-content:center; padding:26px; }\n.uh-side-dialog { width:min(1120px, 100%); overflow-x:hidden; overflow-y:scroll; scrollbar-gutter:stable; scrollbar-width:auto; scrollbar-color:#707780 #1d1f22; background:var(--dsw-alias-bg-layer-1, #1a1c20); border:1px solid var(--dsw-alias-border-l2); border-radius:14px; box-shadow:0 18px 52px rgba(0,0,0,.35); padding:18px; }\n.uh-side-dialog::-webkit-scrollbar, .uh-pricing-table-wrap::-webkit-scrollbar { width:12px; height:12px; }\n.uh-side-dialog::-webkit-scrollbar-track, .uh-pricing-table-wrap::-webkit-scrollbar-track { background:#1d1f22; border-left:1px solid #363a40; }\n.uh-side-dialog::-webkit-scrollbar-thumb, .uh-pricing-table-wrap::-webkit-scrollbar-thumb { background:#707780; border:3px solid #1d1f22; border-radius:6px; }\n.uh-side-dialog::-webkit-scrollbar-thumb:hover, .uh-pricing-table-wrap::-webkit-scrollbar-thumb:hover { background:#9aa1aa; }\n.uh-side-dialog-head { display:flex; justify-content:flex-end; margin-bottom:8px; }\n@media (max-width: 640px) { .uh-side-modal { padding:0; } .uh-side-dialog { border-radius:0; border:0; padding:14px; } }\n/* iOS-style dashboard: grouped surfaces, tactile controls, and an elevated sheet. */\n.uh-page { gap:18px; max-width:1160px; margin:0 auto; padding:12px 2px 34px; font-family:-apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif; }\n.uh-head { position:sticky; top:-18px; z-index:20; margin:0 -2px; padding:18px 2px 14px; background:linear-gradient(color-mix(in srgb, var(--dsw-alias-bg-base) 88%, transparent), color-mix(in srgb, var(--dsw-alias-bg-base) 88%, transparent)), var(--dsw-alias-bg-layer-1, #1a1c20); backdrop-filter:blur(18px) saturate(150%); border-bottom:1px solid color-mix(in srgb, var(--dsw-alias-border-l1) 76%, transparent); }\n.uh-title { font-size:22px; line-height:1.2; font-weight:700; letter-spacing:0; }\n.uh-actions { gap:8px; }\n.uh-range { padding:2px; gap:2px; border:0; border-radius:9px; background:color-mix(in srgb, var(--dsw-alias-label-primary) 10%, transparent); overflow:visible; }\n.uh-range button, .uh-range button + button { min-height:28px; border:0; border-radius:7px; padding:4px 10px; }\n.uh-range button.uh-on { background:var(--dsw-alias-bg-layer-1); box-shadow:0 1px 3px rgba(0,0,0,.16); }\n.uh-refresh { min-height:30px; border:0; border-radius:15px; padding:5px 12px; display:inline-flex; align-items:center; justify-content:center; gap:6px; background:color-mix(in srgb, var(--dsw-alias-brand-primary) 14%, var(--dsw-alias-bg-layer-1)); color:var(--dsw-alias-brand-primary); font-weight:600; }\n.uh-line-icon { flex:none; }\n.uh-icon-button { width:30px; padding:0; }\n.uh-refresh:hover { border:0; background:color-mix(in srgb, var(--dsw-alias-brand-primary) 22%, var(--dsw-alias-bg-layer-1)); }\n.uh-progress { padding:10px 12px; background:color-mix(in srgb, var(--dsw-alias-brand-primary) 9%, var(--dsw-alias-bg-layer-1)); border:0; border-radius:12px; }\n.uh-cards { grid-template-columns:repeat(auto-fit, minmax(180px, 1fr)); gap:10px; border:0; border-radius:0; overflow:visible; background:transparent; }\n.uh-card { min-height:84px; padding:12px 14px; gap:4px; border:0; border-radius:18px; background:var(--dsw-alias-bg-layer-1); box-shadow:0 1px 2px rgba(0,0,0,.07), 0 8px 22px rgba(0,0,0,.05); animation:none; }\n.uh-card:first-child { border:0; background:color-mix(in srgb, #0a84ff 15%, var(--dsw-alias-bg-layer-1)); }\n.uh-card:nth-child(2) { background:color-mix(in srgb, #30d158 13%, var(--dsw-alias-bg-layer-1)); }\n.uh-card:nth-child(3) { background:color-mix(in srgb, #ff9f0a 14%, var(--dsw-alias-bg-layer-1)); }\n.uh-card:hover { transform:translateY(-2px); box-shadow:0 12px 28px rgba(0,0,0,.12); }\n.uh-card-label { display:flex; align-items:center; gap:6px; font-size:12px; font-weight:600; letter-spacing:0; }\n.uh-ios-summary-label, .uh-section-title, .uh-title-with-icon { display:flex; align-items:center; gap:7px; }\n.uh-section-title { margin-bottom:12px; color:var(--dsw-alias-label-primary); font-size:14px; font-weight:650; }\n/* Raise the complete reading scale without changing the data grid geometry. */\n.uh-page { font-size:14px; }\n.uh-range button, .uh-refresh { font-size:13px; }\n.uh-card-label, .uh-ios-summary-label { font-size:13px; }\n.uh-card-sub, .uh-ios-summary-caption, .uh-note { font-size:12px; }\n.uh-hrow, .uh-row, .uh-model-hrow, .uh-model-row { font-size:13px; }\n.uh-tbl-title { font-size:15px; }\n.uh-num { font-variant-numeric:tabular-nums; }\n.uh-card-value { font-size:23px; font-weight:700; letter-spacing:0; }\n.uh-card-sub { font-size:11px; line-height:1.25; }\n.uh-panel { padding:16px; border:0; border-radius:18px; background:var(--dsw-alias-bg-layer-1); box-shadow:0 1px 2px rgba(0,0,0,.06), 0 6px 18px rgba(0,0,0,.04); }\n.uh-hm-head { margin-bottom:12px; }\n.uh-chip { border:0; border-radius:14px; padding:5px 10px; background:color-mix(in srgb, var(--dsw-alias-label-primary) 7%, transparent); }\n.uh-chip.uh-on { border:0; background:color-mix(in srgb, var(--dsw-alias-brand-primary) 18%, transparent); color:var(--dsw-alias-brand-primary); }\n.uh-hrow, .uh-row, .uh-model-hrow, .uh-model-row { border-radius:10px; }\n.uh-hrow, .uh-model-hrow { position:sticky; top:66px; z-index:2; background:var(--dsw-alias-bg-layer-1); border-bottom:1px solid var(--dsw-alias-border-l1); }\n.uh-row, .uh-model-row { padding-top:9px; padding-bottom:9px; }\n.uh-row:nth-child(even) { background:color-mix(in srgb, var(--dsw-alias-bg-layer-2) 52%, transparent); }\n/* The sidebar entry follows the host\'s row style (transparent at rest, hover from\n the host token) instead of a permanent brand tint: a painted resting background\n reads as "already hovered" next to the other sidebar rows. */\n.uh-side-modal { align-items:flex-end; padding:0; background:rgba(0,0,0,.34); backdrop-filter:blur(8px); }\n.uh-side-dialog { width:min(1260px, 100%); max-height:calc(100vh - var(--uh-top-inset, 0px) - 44px); border:0; border-radius:24px 24px 0 0; padding:22px 24px 28px; background:linear-gradient(color-mix(in srgb, var(--dsw-alias-bg-base) 94%, transparent), color-mix(in srgb, var(--dsw-alias-bg-base) 94%, transparent)), var(--dsw-alias-bg-layer-1, #1a1c20); box-shadow:0 -10px 44px rgba(0,0,0,.25); }\n.uh-side-dialog-head { position:sticky; top:-22px; z-index:8; justify-content:center; height:22px; margin:-22px -24px 8px; padding:8px 24px; background:linear-gradient(color-mix(in srgb, var(--dsw-alias-bg-base) 94%, transparent), color-mix(in srgb, var(--dsw-alias-bg-base) 94%, transparent)), var(--dsw-alias-bg-layer-1, #1a1c20); border:0; }\n.uh-side-dialog-head::before { content:""; width:36px; height:5px; border-radius:3px; background:color-mix(in srgb, var(--dsw-alias-label-primary) 24%, transparent); }\n.uh-side-dialog-head .uh-refresh { position:absolute; right:20px; top:7px; min-height:28px; background:transparent; }\n.uh-close-button { width:30px; padding:0; font-size:22px; line-height:1; color:var(--dsw-alias-label-secondary); }\n.uh-close-button:hover { color:var(--dsw-alias-label-primary); background:color-mix(in srgb, var(--dsw-alias-label-primary) 10%, transparent); }\n@media (max-width:640px) { .uh-page { gap:14px; padding-bottom:20px; } .uh-head { position:static; padding:4px 0 10px; } .uh-title { font-size:20px; } .uh-custom-range { grid-template-columns:1fr; align-items:stretch; } .uh-custom-range-fields { grid-template-columns:repeat(2, minmax(0, 1fr)); } .uh-custom-range-actions { justify-content:flex-end; } .uh-side-dialog { max-height:calc(100vh - 8px); border-radius:20px 20px 0 0; padding:18px 14px 24px; } .uh-side-dialog-head { top:-18px; margin:-18px -14px 8px; padding:7px 14px; } .uh-card-value { font-size:22px; } }\n/* Navigation separates the dashboard into three focused iOS-style surfaces. */\n.uh-ios-tabs { display:grid; grid-template-columns:repeat(3, 1fr); gap:4px; padding:4px; border-radius:14px; background:color-mix(in srgb, var(--dsw-alias-label-primary) 9%, transparent); }\n.uh-ios-tab { min-height:32px; border:0; border-radius:10px; background:transparent; color:var(--dsw-alias-label-secondary); font:inherit; font-size:13px; font-weight:600; cursor:pointer; }\n.uh-ios-tab.uh-on { color:var(--dsw-alias-label-primary); background:var(--dsw-alias-bg-layer-1); box-shadow:0 1px 4px rgba(0,0,0,.16); }\n.uh-ios-summary { display:flex; flex-direction:column; gap:12px; background:transparent; box-shadow:none; }\n.uh-ios-summary-hero { display:grid; grid-template-columns:minmax(0,1fr) minmax(320px,.48fr); min-height:142px; padding:20px 22px; border:1px solid var(--dsw-alias-border-l1); border-radius:18px; background:var(--dsw-alias-bg-layer-1); box-shadow:0 1px 2px rgba(0,0,0,.06), 0 8px 22px rgba(0,0,0,.06); }\n.uh-ios-summary-total { min-width:0; min-height:0; padding:0; border-radius:0; display:flex; align-items:center; justify-content:flex-start; gap:16px; background:transparent; box-shadow:none; }\n.uh-ios-summary-total-icon { display:grid; place-items:center; flex:none; width:54px; height:54px; border-radius:16px; background:color-mix(in srgb,#0a84ff 18%,var(--dsw-alias-bg-layer-2)); color:#0a84ff; }\n.uh-ios-summary-total-copy { min-width:0; }\n.uh-ios-summary-label { font-size:13px; font-weight:600; color:var(--dsw-alias-label-secondary); }\n.uh-ios-summary-total .uh-ios-summary-label { font-size:14px; }\n.uh-ios-summary-value { margin-top:7px; font-size:40px; line-height:1; font-weight:750; letter-spacing:0; color:var(--dsw-alias-label-primary); }\n.uh-unit { margin-left:6px; color:var(--dsw-alias-label-secondary); font-size:.4em; font-weight:650; white-space:nowrap; vertical-align:baseline; }\n.uh-wsbar-num .uh-unit { font-size:.78em; margin-left:3px; }\n.uh-ios-summary-caption { margin-top:8px; font-size:12px; color:var(--dsw-alias-label-secondary); }\n.uh-ios-summary-meta { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); align-items:center; min-width:0; gap:0; padding:0 0 0 22px; border-left:1px solid var(--dsw-alias-border-l1); background:transparent; font-size:12px; color:var(--dsw-alias-label-secondary); }\n.uh-ios-summary-meta-stat { min-width:0; padding:4px 22px; }\n.uh-ios-summary-meta-stat + .uh-ios-summary-meta-stat { border-left:1px solid var(--dsw-alias-border-l1); }\n.uh-ios-summary-meta-label { display:flex; align-items:center; gap:7px; color:var(--dsw-alias-label-secondary); font-size:12px; font-weight:600; white-space:nowrap; }\n.uh-ios-summary-meta-value { margin-top:7px; color:var(--dsw-alias-label-primary); font-size:24px; line-height:1; font-weight:700; font-variant-numeric:tabular-nums; white-space:nowrap; }\n.uh-ios-summary-meta-cost .uh-ios-summary-meta-value { color:#30d158; }\n.uh-ios-summary-meta-caption { margin-top:7px; color:var(--dsw-alias-label-secondary); font-size:11px; white-space:nowrap; }\n.uh-ios-metrics { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:8px; }\n.uh-ios-metric { min-width:0; min-height:80px; padding:10px 13px; border:1px solid var(--dsw-alias-border-l1); border-radius:14px; display:flex; flex-direction:column; justify-content:center; gap:6px; background:var(--dsw-alias-bg-layer-1); box-shadow:0 1px 2px rgba(0,0,0,.06), 0 8px 20px rgba(0,0,0,.05); animation:uh-card-in .35s ease both; }\n.uh-ios-metrics > .uh-card { min-width:0; min-height:96px; padding:9px 13px; gap:2px; border:0; border-radius:14px; }\n.uh-ios-metrics > .uh-card .uh-card-value { min-width:0; font-size:20px; line-height:1.2; font-weight:700; white-space:nowrap; }\n.uh-ios-metrics > .uh-card .uh-card-sub { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }\n.uh-ios-metrics > .uh-card:nth-child(-n+3) { justify-content:center; }\n.uh-ios-metric-label { display:flex; align-items:center; gap:8px; min-width:0; color:var(--dsw-alias-label-secondary); font-size:13px; font-weight:600; white-space:nowrap; }\n.uh-ios-metric-label .uh-line-icon { flex:none; }\n.uh-ios-metric-value { min-width:0; color:var(--dsw-alias-label-primary); font-size:22px; line-height:1.05; font-weight:700; font-variant-numeric:tabular-nums; white-space:nowrap; }\n.uh-ios-metric-input { background:color-mix(in srgb,#0a84ff 11%,var(--dsw-alias-bg-layer-1)); }\n.uh-ios-metric-input .uh-line-icon { color:#0a84ff; }\n.uh-ios-metric-output { background:color-mix(in srgb,#bf5af2 10%,var(--dsw-alias-bg-layer-1)); }\n.uh-ios-metric-output .uh-line-icon { color:#bf5af2; }\n.uh-ios-metric-write { background:color-mix(in srgb,#ff9f0a 11%,var(--dsw-alias-bg-layer-1)); }\n.uh-ios-metric-write .uh-line-icon { color:#ff9f0a; }\n.uh-ios-metric-read { background:color-mix(in srgb,#30d158 11%,var(--dsw-alias-bg-layer-1)); }\n.uh-ios-metric-read .uh-line-icon { color:#30d158; }\n.uh-ios-metric-rate { background:var(--dsw-alias-bg-layer-1); }\n.uh-ios-metric-rate .uh-line-icon { color:#30d158; }\n.uh-ios-metric-rate-head { display:flex; align-items:baseline; justify-content:space-between; gap:8px; min-width:0; }\n.uh-ios-metric-rate-value { flex:none; color:#30d158; font-size:20px; line-height:1; font-weight:700; font-variant-numeric:tabular-nums; }\n.uh-ios-metric-rate-detail { min-width:0; overflow:hidden; color:var(--dsw-alias-label-secondary); font-size:12px; line-height:1.2; font-weight:600; font-variant-numeric:tabular-nums; text-overflow:ellipsis; white-space:nowrap; }\n.uh-ios-metric-bar { height:5px; border-radius:3px; background:var(--dsw-alias-bg-layer-2); overflow:hidden; }\n.uh-ios-metric-fill { height:100%; border-radius:inherit; background:#30d158; transition:width .35s ease; }\n.uh-token-semantics { display:flex; align-items:flex-start; gap:8px; padding:10px 12px; border-radius:12px; background:color-mix(in srgb, var(--dsw-alias-brand-primary) 8%, var(--dsw-alias-bg-layer-1)); color:var(--dsw-alias-label-secondary); font-size:12px; line-height:1.55; }\n.uh-token-semantics .uh-line-icon { margin-top:1px; color:var(--dsw-alias-brand-primary); }\n.uh-ios-list-panel { min-height:360px; }\n.uh-donut-chart { margin:0 0 18px; }\n.uh-donut-title { display:flex; align-items:center; gap:7px; margin-bottom:12px; color:var(--dsw-alias-label-primary); font-size:14px; font-weight:650; }\n.uh-donut-layout { display:grid; grid-template-columns:minmax(220px,300px) minmax(0,1fr); gap:24px; align-items:center; }\n.uh-donut-visual { position:relative; width:min(100%,280px); aspect-ratio:1; margin:0 auto; }\n.uh-donut-svg { display:block; width:100%; height:100%; overflow:visible; }\n.uh-donut-track { opacity:.78; }\n.uh-donut-segment { fill:none; stroke-dasharray:1; stroke-dashoffset:1; animation:uh-donut-draw .95s cubic-bezier(.22,.61,.36,1) both; cursor:pointer; outline:none; transition:filter .15s ease, opacity .15s ease; }\n.uh-donut-segment:hover, .uh-donut-segment:focus-visible, .uh-donut-segment.uh-active { filter:brightness(1.12); }\n.uh-donut-tooltip { position:absolute; top:0; left:0; z-index:3; display:flex; align-items:flex-start; gap:8px; max-width:190px; padding:9px 10px; border:1px solid var(--dsw-alias-border-l2); border-radius:8px; background:linear-gradient(color-mix(in srgb, var(--dsw-alias-bg-base) 94%, transparent), color-mix(in srgb, var(--dsw-alias-bg-base) 94%, transparent)), var(--dsw-alias-bg-layer-1, #1a1c20); box-shadow:0 10px 24px rgba(0,0,0,.22); backdrop-filter:blur(10px); color:var(--dsw-alias-label-primary); pointer-events:none; font-size:12px; line-height:1.4; transition:left .12s cubic-bezier(.22,.61,.36,1), top .12s cubic-bezier(.22,.61,.36,1); }\n.uh-donut-tooltip > div { min-width:0; display:flex; flex-direction:column; gap:4px; }\n.uh-donut-tooltip strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:12px; }\n.uh-donut-tooltip span:not(.uh-donut-dot):not(.uh-model-icon) { color:var(--dsw-alias-label-secondary); font-size:11px; }\n.uh-donut-tooltip-cost { color:var(--dsw-alias-label-primary) !important; font-variant-numeric:tabular-nums; }\n.uh-donut-center { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; pointer-events:none; }\n.uh-donut-center strong { color:var(--dsw-alias-label-primary); font-size:28px; line-height:1; font-weight:750; font-variant-numeric:tabular-nums; }\n.uh-donut-center span { margin-top:5px; color:var(--dsw-alias-label-secondary); font-size:13px; }\n.uh-donut-legend { min-width:0; }\n.uh-donut-legend-row { display:grid; grid-template-columns:36px minmax(180px,1fr) minmax(250px,.8fr) 54px; gap:10px; align-items:center; min-height:58px; padding:8px 0; border-bottom:1px solid color-mix(in srgb, var(--dsw-alias-border-l1) 78%, transparent); }\n.uh-donut-legend-row:last-child { border-bottom:0; }\n.uh-donut-dot { width:12px; height:12px; border-radius:50%; }\n.uh-donut-legend-mark { display:flex; align-items:center; gap:8px; min-width:0; }\n.uh-donut-legend-copy { min-width:0; display:flex; flex-direction:column; gap:5px; }\n.uh-donut-legend-copy strong { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--dsw-alias-label-primary); font-size:13px; font-weight:650; }\n.uh-donut-legend-metrics { display:grid; grid-template-columns:minmax(120px,1fr) minmax(92px,auto); align-items:center; gap:14px; min-width:0; }\n.uh-donut-legend-metrics span { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--dsw-alias-label-secondary); font-size:12px; font-variant-numeric:tabular-nums; text-align:right; }\n.uh-donut-legend-metrics .uh-donut-cost { color:var(--dsw-alias-label-secondary); font-size:12px; }\n.uh-donut-percent { min-width:48px; color:var(--dsw-alias-label-secondary); font-size:12px; font-variant-numeric:tabular-nums; text-align:right; }\n/* Each detail table owns its scrolling and sticky header; sections must not overlap in the page scroll. */\n.uh-tbl-scroll { max-height:360px; overflow:auto; border-radius:12px; background:color-mix(in srgb, var(--dsw-alias-bg-layer-2) 55%, transparent); }\n.uh-hrow, .uh-model-hrow { position:sticky; top:0; z-index:3; border-bottom:1px solid var(--dsw-alias-border-l1); box-shadow:0 1px 0 color-mix(in srgb, var(--dsw-alias-bg-base) 70%, transparent); }\n.uh-row, .uh-model-row { min-height:48px; border-bottom:1px solid color-mix(in srgb, var(--dsw-alias-border-l1) 72%, transparent); }\n.uh-row:last-child, .uh-model-row:last-child { border-bottom:0; }\n@media (max-width:640px) { .uh-tbl-scroll { max-height:300px; border-radius:10px; } }\n@media (max-width:640px) { .uh-hm-body { min-width:720px; } .uh-donut-legend-row { grid-template-columns:36px minmax(0,1fr) 48px; gap:8px; } .uh-donut-legend-copy { grid-column:2; grid-row:1; } .uh-donut-legend-metrics { grid-column:2 / -1; grid-row:2; grid-template-columns:minmax(0,1fr) minmax(0,auto); gap:8px; } .uh-donut-percent { grid-column:3; grid-row:1; } .uh-ios-summary-hero { grid-template-columns:1fr; min-height:0; gap:18px; padding:18px; } .uh-ios-summary-total { align-items:flex-start; } .uh-ios-summary-meta { grid-template-columns:repeat(2,minmax(0,1fr)); padding:16px 0 0; border-left:0; border-top:1px solid var(--dsw-alias-border-l1); } .uh-ios-summary-meta-stat { padding:0 12px; } .uh-ios-summary-meta-stat:first-child { padding-left:0; } .uh-ios-summary-meta-stat:last-child { padding-right:0; } .uh-ios-summary-value { font-size:31px; } .uh-ios-metrics { grid-template-columns:repeat(2,minmax(0,1fr)); } .uh-ios-metric:last-child { grid-column:1 / -1; } .uh-ios-metric-value { font-size:24px; } .uh-donut-layout { grid-template-columns:1fr; gap:12px; } .uh-donut-visual { width:min(100%,250px); } }\n@keyframes uh-cell-in { from { opacity:0; transform:scale(.4); } to { opacity:1; transform:scale(1); } }\n@keyframes uh-glow { 0% { box-shadow:0 0 0 0 rgba(9,105,218,.5); } 70% { box-shadow:0 0 0 5px rgba(9,105,218,0); } 100% { box-shadow:0 0 0 0 rgba(9,105,218,0); } }\n@keyframes uh-card-in { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }\n@keyframes uh-bar-grow { from { transform:scaleX(0); } to { transform:scaleX(1); } }\n@keyframes uh-panel-in { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:translateY(0); } }\n@keyframes uh-trend-draw { from { stroke-dashoffset:var(--uh-draw-length); opacity:.2; } to { stroke-dashoffset:0; opacity:1; } }\n@keyframes uh-trend-fill { from { opacity:0; } to { opacity:1; } }\n@keyframes uh-donut-draw { from { stroke-dashoffset:1; opacity:.25; } to { stroke-dashoffset:0; opacity:1; } }\n@keyframes uh-spinner-turn { to { transform:rotate(360deg); } }\n@keyframes uh-menu-in { from { opacity:0; transform:translateY(-4px) scale(.97); } to { opacity:1; transform:translateY(0) scale(1); } }\n@keyframes uh-tip-in { from { opacity:0; } to { opacity:1; } }\n@media (prefers-reduced-motion: reduce) {\n .uh-cell, .uh-card, .uh-ios-metric, .uh-barfill, .uh-anim-panel, .uh-trend-panel, .uh-trend-line-draw, .uh-trend-area, .uh-trend-point, .uh-trend-spinner, .uh-donut-segment, .uh-records-panel, .uh-record-detail, .uh-tip, .uh-language-options { animation:none !important; stroke-dashoffset:0 !important; opacity:1 !important; }\n .uh-card, .uh-cell, .uh-ios-metric-fill, .uh-barfill, .uh-fill, .uh-refresh, .uh-chip, .uh-row, .uh-tip-row, .uh-trend-tooltip, .uh-language-trigger, .uh-language-caret, .uh-language-option { transition:none !important; }\n}\n'}const mt=()=>fetch("/api/all-usage"+(()=>{try{return"en"===kt()?"?utc=1":"?utc=0"}catch(e){return""}})(),{headers:{accept:"application/json"}}).then(e=>{if(!e.ok)throw new Error("HTTP "+e.status);return e.json()}),ht=e=>fetch("/api/all-usage/version"+(!0===e?"?force=1":""),{headers:{accept:"application/json"}}).then(e=>{if(!e.ok){const t=new Error("HTTP "+e.status);throw t.status=e.status,t}return e.json()}),gt=(e,t,a)=>{const n=new URLSearchParams({start:e.start,end:e.end,utc:e.utc?"1":"0",limit:String(a||100)});return e.workspaceId&&n.set("workspaceId",e.workspaceId),e.provider&&n.set("provider",e.provider),e.modelKey&&n.set("modelKey",e.modelKey),t&&n.set("cursor",t),fetch("/api/all-usage/records?"+n.toString(),{headers:{accept:"application/json"}}).then(e=>{if(!e.ok){const t=new Error("HTTP "+e.status);throw t.status=e.status,t}return e.json()})},bt=()=>fetch("/api/all-usage/pricing",{headers:{accept:"application/json"}}).then(e=>{if(!e.ok)throw new Error("HTTP "+e.status);return e.json()}),ft=(e,t,a)=>fetch("/api/all-usage/pricing",{method:"POST",headers:{"content-type":"application/json","x-all-usage-request-token":a},body:JSON.stringify({pricing:e,backfill:!0===t})}).then(e=>{if(!e.ok){const t=new Error("HTTP "+e.status);throw t.status=e.status,t}return e.json()}),yt="dsh-all-usage.language",xt="dsh-all-usage.language.chosen";let vt,wt=null;function kt(){const e=function(){try{if("1"!==window.localStorage.getItem(xt))return null;const e=window.localStorage.getItem(yt);return"en"===e?"en":"zh"===e?"zh":null}catch(e){return null}}();return null!==e?e:function(){if(void 0!==vt)return vt;vt=null;try{const e=null!==wt&&"function"==typeof wt.get?wt.get("locale"):void 0;if(null!=e){const t="function"==typeof e.getLocale?e.getLocale():"function"==typeof e.getSnapshot?e.getSnapshot():null;vt=function(e){const t=String(e??"").toLowerCase();return""===t?null:0===t.indexOf("zh")?"zh":"en"}(null!==t&&"object"==typeof t?t.active:void 0)}}catch(e){}return vt}()??function(){try{const e="undefined"==typeof navigator?"":String(navigator.language||"");if(/^zh/i.test(e))return"zh";if(/^en/i.test(e))return"en"}catch(e){}return"en"}()}const Et="dsh-all-usage.ui-state";function Nt(){try{const e=window.localStorage.getItem(Et),t=e?JSON.parse(e):{};if(null===t||"object"!=typeof t||Array.isArray(t))return{};const a={};return["logs","model","workspace"].includes(t.detailView)&&(a.detailView=t.detailView),["route","model","provider"].includes(t.modelView)&&(a.modelView=t.modelView),["today","7d","30d","90d","all"].includes(t.range)&&(a.range=t.range),je.includes(t.heatmapSpan)&&(a.heatmapSpan=t.heatmapSpan),"boolean"==typeof t.pricingAutoSync&&(a.pricingAutoSync=t.pricingAutoSync),a}catch(e){return{}}}function Ct(e){try{const t=Nt();window.localStorage.setItem(Et,JSON.stringify(Object.assign({},t,e)))}catch(e){}}function Mt(e){const t=e.timerCtx,a="en"===e.language?"en":"zh",r=(e,t)=>"en"===a?t:e,l="en"===a,o=n.useRef(null);null===o.current&&(o.current=Nt());const s=o.current,c=new Date,f=u(c,l),[v,N]=n.useState(null),[M,S]=n.useState(null),[A,z]=n.useState(""),[R,j]=n.useState(0),[D,U]=n.useState(null),[O,K]=n.useState(()=>s.range||"today"),[q,B]=n.useState(()=>Ue(s.heatmapSpan)),[G,ue]=n.useState(null),[de,me]=n.useState(""),[ge,Ne]=n.useState({start:"",end:""}),[Ce,Se]=n.useState({start:"",end:""}),[Ae,ze]=n.useState(!1),[Te,Re]=n.useState(()=>s.modelView||"route"),[je,De]=n.useState(null),[Ke,qe]=n.useState(null),[Be,He]=n.useState(null),[Je,Ge]=n.useState(null),[_e,Xe]=n.useState(""),[Ze,Qe]=n.useState(!1),[et,at]=n.useState(""),[rt,pt]=n.useState(["total","input","cacheRead","output"]),[yt,xt]=n.useState(()=>s.detailView||"logs"),[vt,wt]=n.useState(null),[kt,Et]=n.useState(null),[Mt,St]=n.useState([]),[At,zt]=n.useState(null),[Tt,It]=n.useState(!1),[Rt,jt]=n.useState(0),[Dt,Ut]=n.useState(!1),[Ft,Wt]=n.useState(!1),[Ot,Lt]=n.useState(""),[Pt,Kt]=n.useState(!1),[qt,Bt]=n.useState({}),[Ht,Yt]=n.useState(!1),[Vt,Jt]=n.useState(null),[Gt,$t]=n.useState(null),[_t,Xt]=n.useState(!1),[Zt,Qt]=n.useState(!1),[ea,ta]=n.useState(!1),[aa,na]=n.useState(!1),[ra,ia]=n.useState(""),[la,oa]=n.useState({}),[sa,ca]=n.useState({}),[ua,da]=n.useState(null),[pa,ma]=n.useState({}),[ha,ga]=n.useState(null),[ba,fa]=n.useState({});n.useEffect(()=>{fa({})},[a]);const[ya,xa]=n.useState(()=>(new Date).getFullYear()),[va,wa]=n.useState(!1),[ka,Ea]=n.useState(""),Na=n.useRef({}),Ca=n.useRef(0),Ma=n.useRef({}),Sa=n.useRef(!1),Aa=n.useRef(()=>{}),za=n.useRef(()=>{}),Ta=()=>{Ca.current+=1;const e=Ma.current;for(const t of Object.keys(e))clearTimeout(e[t]);Ma.current={},Na.current={},oa({}),ca({})},[Ia,Ra]=n.useState(!1),ja=n.useRef(null),Da=n.useRef(null),Ua=n.useRef(null);null===Ua.current&&(Ua.current=g());const Fa=n.useRef(null);null===Fa.current&&(Fa.current=g());const Wa=n.useRef(null);null===Wa.current&&(Wa.current=g());const Oa=n.useRef(null);null===Oa.current&&(Oa.current=g());const La=n.useRef(null);null===La.current&&(La.current=g());const Pa=n.useRef(null);null===Pa.current&&(Pa.current=g());const Ka=Ua.current,qa=Fa.current,Ba=Wa.current,Ha=Oa.current,Ya=La.current,Va=Pa.current,Ja=n.useRef(()=>{}),Ga=n.useRef(()=>{}),$a=n.useRef(""),_a=n.useCallback(()=>{if(!Sa.current||Zt||ea||aa)return;const e=Va.next();Xt(!0),bt().then(t=>{if(Va.isCurrent(e)){if(!t||"object"!=typeof t||!t.config)return ia("load"),void Xt(!1);Ta(),Jt(t),$t(e=>X(e,t)),ia(""),Xt(!1)}},()=>{Va.isCurrent(e)&&(ia("load"),Xt(!1))})},[Zt,ea,aa]);n.useEffect(()=>{Aa.current=_a});n.useEffect(()=>{Ct({detailView:yt})},[yt]),n.useEffect(()=>{Ct({modelView:Te})},[Te]),n.useEffect(()=>{"custom"!==O&&Ct({range:O})},[O]),n.useEffect(()=>{Ct({heatmapSpan:q})},[q]),n.useEffect(()=>{let e=!0;const t=t=>ht(t).then(t=>{e&&(ue(t),me(""))},t=>{e&&me(!t||401!==t.status&&404!==t.status?"failed":"endpoint")});return za.current=()=>t(!1),t(!1),()=>{e=!1,za.current=()=>{}}},[]);const Xa=n.useMemo(()=>null===v?null:function(e,t,a,n,r,i,l){const o=Fe(e,t,a,n);return null===o?null:{start:o.start,end:o.end,utc:!0===a,workspaceId:r||null,provider:i||null,modelKey:l||null}}(v,O,l,ge,je,Ke,Be),[v,O,l,ge.start,ge.end,je,Ke,Be]),Za=We(Xa),Qa=x(null!==M&&"object"==typeof M?M:v),en=null!==vt&&vt.baseKey===Za?vt.scope:Xa,tn=We(en),an=n.useRef(Za);n.useEffect(()=>{an.current!==Za&&(an.current=Za,wt(null),Et(null))},[Za]),n.useEffect(()=>{let e=!0,a=!1,n="",r=null,i=0,l=0,o=null;const s=()=>{null!==o&&(clearTimeout(o),o=null)},c=t=>{if(""===n)return;const a=Ba.next();((e,t)=>fetch("/api/all-usage/balance"+(e?"?force=1":""),{headers:{accept:"application/json","x-all-usage-request-token":t}}).then(e=>{if(!e.ok)throw new Error("HTTP "+e.status);return e.json()}))(!0===t,n).then(t=>{e&&Ba.isCurrent(a)&&t&&U(t)},()=>{})},u=t=>{if(!e||null!==o)return;const a="full"===t?i+=1:l+=1;o=setTimeout(()=>{o=null,e&&("full"===t?d():p())},function(e){const t=Math.max(1,Math.min(4,"number"==typeof e&&Number.isFinite(e)?e:1));return 5e3*Math.pow(2,t-1)}(a))},d=()=>{qa.next();const t=Ka.next();mt().then(l=>{if(!e||!Ka.isCurrent(t))return;if(null===l||"object"!=typeof l)return z("full"),void u("full");const o=null!==r&&"string"==typeof r.pluginVersion?r.pluginVersion:"";r=l,l.scan&&(a=!!l.scan.done);const d="string"==typeof l.pluginVersion?l.pluginVersion:"";""!==d&&d!==o&&za.current();const p="string"==typeof l.requestToken?l.requestToken:"",m=""!==p&&p!==n;n=p,""!==p&&($a.current=p),i=0,s(),z(""),j(Date.now()),S(l),N(l),m&&c(!1)},()=>{e&&Ka.isCurrent(t)&&(z("full"),u("full"))})},p=()=>{if(null===r)return void d();const t=qa.next();fetch("/api/all-usage/status",{headers:{accept:"application/json"}}).then(e=>{if(!e.ok)throw new Error("HTTP "+e.status);return e.json()}).then(n=>{if(!e||!qa.isCurrent(t))return;if(null===n||"object"!=typeof n)return z("status"),void u("status");l=0;const i=function(e,t){if(null===e||"object"!=typeof e||null===t||"object"!=typeof t)return"full";if("string"!=typeof e.instanceId||"string"!=typeof t.instanceId||""===e.instanceId||e.instanceId!==t.instanceId)return"full";const a="string"==typeof e.capabilityId?e.capabilityId:"",n="string"==typeof t.capabilityId?t.capabilityId:"";if(""!==a&&a!==n)return"full";if(y(e)&&y(t)){if(e.metadataRevision!==t.metadataRevision)return"full";if(e.pricingRevision!==t.pricingRevision)return"full";if(e.dataRevision!==t.dataRevision)return"query";const a=e.scan,n=t.scan;return e.scanRevision!==t.scanRevision||a&&n&&!!a.done!=!!n.done?"status":"none"}const r=b(e),i=b(t);if(null===r||null===i||r!==i)return"full";const l=e.scan,o=t.scan;return l&&o&&!!l.done!=!!o.done?"full":"none"}(n,r);if(n.scan&&(a=!!n.scan.done),"full"===i)return"number"==typeof n.pricingRevision&&"number"==typeof r.pricingRevision&&n.pricingRevision!==r.pricingRevision&&Aa.current(),void d();r=Object.assign({},r,n),S(n),s(),z("")},()=>{e&&qa.isCurrent(t)&&(z("status"),u("status"))})};d();const m=t.interval(()=>{a||null!==o||p()},2e3),h=t.interval(()=>{a&&null===o&&p()},15e3),g=t.interval(()=>{c(!1)},6e4);return Ja.current=()=>{s(),i=0,l=0,d(),c(!0)},Ga.current=d,()=>{e=!1,s(),m(),h(),g();for(const e of Object.values(Ma.current))clearTimeout(e);Ma.current={}}},[]);const nn=n.useRef(l);n.useEffect(()=>{nn.current!==l&&(nn.current=l,Ga.current())},[l]),n.useEffect(()=>{if(!Ia||"undefined"==typeof document)return;const e=e=>{ja.current&&!ja.current.contains(e.target)&&Ra(!1)};return document.addEventListener("pointerdown",e),()=>document.removeEventListener("pointerdown",e)},[Ia]),n.useEffect(()=>{if(null===Xa||""===Za)return;const e=Ha.next(),t=Qa;Qe(!0),at(""),(e=>{const t=new URLSearchParams({start:e.start,end:e.end,utc:e.utc?"1":"0"});return e.workspaceId&&t.set("workspaceId",e.workspaceId),e.provider&&t.set("provider",e.provider),e.modelKey&&t.set("modelKey",e.modelKey),fetch("/api/all-usage/query?"+t.toString(),{headers:{accept:"application/json"}}).then(e=>{if(!e.ok)throw new Error("HTTP "+e.status);return e.json()})})(Xa).then(a=>{if(Ha.isCurrent(e)){if(null===a||"object"!=typeof a||null===t||x(a)!==t)return at("stale"),void Qe(!1);Ge(a),Xe(Za),Qe(!1),at("")}},()=>{Ha.isCurrent(e)&&(Qe(!1),at("query"))})},[Za,Qa]);const rn=n.useCallback(e=>{null!==e&&""!==Za&&(wt({baseKey:Za,scope:{...e}}),xt("logs"),Et(null),Lt(""))},[Za]),ln=n.useRef(null);ln.current=Xa;const on=n.useCallback(e=>{const t=ln.current;null!==t&&"string"==typeof e&&rn({...t,start:e,end:e})},[rn]),sn="logs"===yt&&null!==en&&""!==tn;n.useEffect(()=>{if(!sn)return Ya.next(),void Ut(!1);const e=Ya.next(),t=Qa;return Ut(!0),Lt(""),zt(null),It(!1),gt(en,null,20).then(a=>{if(Ya.isCurrent(e)){if(null===a||"object"!=typeof a||!Array.isArray(a.items))return Lt("audit"),void Ut(!1);if(null===t||x(a)!==t)return Lt("stale"),void Ut(!1);St(a.items),Et(e=>a.items.some(t=>t&&t.id===e)?e:a.items[0]?a.items[0].id:null),zt(a.nextCursor||null),It(!0===a.hasMore),Ut(!1),Lt("")}},t=>{if(Ya.isCurrent(e)){if(t&&409===t.status)return Ut(!1),Lt("stale"),void jt(e=>e+1);Ut(!1),Lt("audit")}}),()=>{Ya.next()}},[tn,yt,Qa,Rt]),n.useEffect(()=>{null!==vt&&"logs"===yt&&null!==Da.current&&Da.current.scrollIntoView({behavior:"smooth",block:"start"})},[vt&&We(vt.scope),yt]);const cn=n.useCallback(()=>{Ja.current(),ht(!0).then(e=>{e&&(ue(e),me(""))},e=>me(!e||401!==e.status&&404!==e.status?"failed":"endpoint"))},[]),un=n.useCallback(e=>{De(t=>t===e?null:e)},[]),dn=n.useCallback(()=>{De(null),qe(null),He(null)},[]),pn=n.useCallback(e=>{qe(e||null)},[]),mn=n.useCallback(e=>{He(e||null)},[]),hn=n.useMemo(()=>l&&Array.isArray(v&&v.byDayUtc)?v.byDayUtc:Array.isArray(v&&v.byDay)?v.byDay:[],[v,l]),gn=h(hn,f).min,bn=m(ge,l),fn=function(e,t,a,n){return null!==e&&"object"==typeof e&&p(e.start,n)&&p(e.end,n)?e.start>e.end?"order":e.start<t||e.end>a?"bounds":"":"invalid"}(Ce,gn,f,l),yn=n.useCallback(e=>{B(Ue(e))},[]),xn=null!==Je&&_e===Za,vn=xn&&null!==Qa&&x(Je)===Qa,wn=xn&&(vn||""===et),kn=null===bn?"":bn.start+":"+bn.end,En=n.useMemo(()=>function(e,t,a,n){const r={totals:{turns:0,calls:0,sessions:0,input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,cost:{currency:"USD",input:"0",output:"0",cacheRead:"0",cacheWrite:"0",baseTotal:"0",total:"0",pricedCalls:0,unpricedCalls:0,ambiguousCalls:0,unsupportedCalls:0}},perWs:[],perModel:[]};if(null===e)return r;if("all"===t)return{totals:e.totals,perWs:e.perWorkspace,perModel:e.perModel||[]};const i=a&&Array.isArray(e.byDayUtc)?e.byDayUtc:Array.isArray(e.byDay)?e.byDay:[];let l,o=null;if("custom"===t){const e=m(n,a);if(null===e)return r;l=e.start,o=e.end}else l=u("today"===t?new Date:d(new Date,"7d"===t?-6:"30d"===t?-29:-89,a),a);const s={turns:0,calls:0,sessions:0,input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,cost:{currency:"USD",input:"0",output:"0",cacheRead:"0",cacheWrite:"0",baseTotal:"0",total:"0",pricedCalls:0,unpricedCalls:0,ambiguousCalls:0,unsupportedCalls:0}},c=new Map,p=new Map,h=new Set;for(const e of i){if(e.date<l||null!==o&&e.date>o)continue;const t=Array.isArray(e.sessionIds)?e.sessionIds:[];for(const e of t)h.add(e);s.turns+=e.turns,s.input+=e.tokens.input,s.output+=e.tokens.output,s.cacheRead+=e.tokens.cacheRead,s.cacheWrite+=e.tokens.cacheWrite,s.reasoning+=e.tokens.reasoning,V(s.cost,e.cost);for(const t of e.byWorkspace){let e=c.get(t.workspaceId);void 0===e&&(e={workspaceId:t.workspaceId,turns:0,input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,cost:H()},c.set(t.workspaceId,e)),e.input+=t.input,e.output+=t.output,e.cacheRead+=t.cacheRead,e.cacheWrite+=t.cacheWrite,e.reasoning+=t.reasoning,V(e.cost,t.cost)}for(const t of e.perWorkspace){let e=c.get(t.workspaceId);void 0===e&&(e={workspaceId:t.workspaceId,turns:0,input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,cost:H()},c.set(t.workspaceId,e)),e.turns+=t.turns}for(const t of e.byModel||[]){const e=t.identityKey||t.model;let a=p.get(e);void 0===a&&(a={...t,calls:0,input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,cost:H()},p.set(e,a)),a.calls+=t.calls,a.input+=t.input,a.output+=t.output,a.cacheRead+=t.cacheRead,a.cacheWrite+=t.cacheWrite,a.reasoning+=t.reasoning,s.calls+=Number.isFinite(t.calls)?t.calls:0,V(a.cost,t.cost)}}return s.sessions=h.size,{totals:s,perWs:Array.from(c.values()),perModel:Array.from(p.values())}}(v,O,l,bn),[v,O,l,kn]),Nn=n.useMemo(()=>function(e,t,a){if(!0===a)return!0;if(null==e||null==t)return!0;const n=Me(e.totals),r=Me(t.totals);return null===n||null===r||(0===r?0===n:Math.abs(n-r)<=Math.max(.05*r,2e5))}(vn?Je:null,En,null!==je||null!==Ke||null!==Be),[vn,Je,En,je,Ke,Be]),Cn=wn&&Nn,Mn=Cn&&Array.isArray(Je.daily)?Je.daily:hn,Sn=Cn&&Array.isArray(Je.heatmap)?Je.heatmap:hn,An=n.useMemo(()=>Cn?{totals:Je.totals,perWs:Je.perWorkspace||[],perModel:Je.perModel||[]}:En,[Cn,Je,En]),zn=Ve(An.totals.input+An.totals.output+An.totals.cacheRead+An.totals.cacheWrite+An.totals.reasoning,t),Tn=(Ve(Math.round(10*E(An.totals.input,An.totals.cacheRead)),t),null!==Ke||null!==Be),In=function(e){if(null==e)return 0;const t=Number(e.pricedCalls||0)+Number(e.unpricedCalls||0)+Number(e.ambiguousCalls||0)+Number(e.unsupportedCalls||0);return Number.isFinite(t)&&t>0?t:0}(An.totals.cost),Rn=In>0?In:Number.isFinite(An.totals.calls)&&An.totals.calls>0?An.totals.calls:An.totals.turns,jn=Ve(Tn?Rn:An.totals.turns,t),Dn=Ve(Rn,t),Un=e=>e.input+e.output+e.cacheRead+e.cacheWrite+e.reasoning,Fn=n.useMemo(()=>(Array.isArray(An.perWs)?An.perWs:[]).slice().sort((e,t)=>Un(t)-Un(e)),[An.perWs]),Wn=n.useMemo(()=>function(e,t,a,n){if("route"===t)return e.slice();const r=new Map,i=new Map;for(const l of e){const e=Ye(l,a,n),o="model"===t?e.model:e.provider;let s=r.get(o);void 0===s&&(s={model:o,provider:"provider"===t?o:e.provider,calls:0,input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,cost:H()},r.set(o,s),i.set(o,[])),i.get(o).push(l),s.calls+=l.calls,s.input+=l.input,s.output+=l.output,s.cacheRead+=l.cacheRead,s.cacheWrite+=l.cacheWrite,s.reasoning+=l.reasoning,V(s.cost,l.cost)}for(const[e,a]of r){const n="provider"===t?I(e):W(i.get(e));a.iconKey=null===n?null:n.key}return Array.from(r.values())}(An.perModel||[],Te,r("未知供应商","Unknown provider"),r("未知模型","Unknown model")).sort((e,t)=>Un(t)-Un(e)),[An.perModel,Te,a]),On=v&&Array.isArray(v.workspaces)?v.workspaces:[],Ln=v&&v.aliases&&"object"==typeof v.aliases?v.aliases:{},Pn=n.useMemo(()=>{const e=Array.isArray(En.perModel)?En.perModel.filter(e=>e&&"object"==typeof e):[],t=Array.from(new Set(e.map(e=>"string"==typeof e.provider&&""!==e.provider?e.provider:null).filter(e=>null!==e))).sort(),n=e=>{const n="string"==typeof e.actualModel&&""!==e.actualModel?e.actualModel:"string"==typeof e.requestedModel&&""!==e.requestedModel?e.requestedModel:null;if(null!==n)return T(n);const r="string"==typeof e.model&&""!==e.model?e.model:"en"===a?"Unknown model":"未知模型",i=r.indexOf(" / "),l=i>0?r.slice(0,i):"";return T(i>0&&t.includes(l)?r.slice(i+3):r)},r=new Map;for(const t of e.map(n)){if(""===t)continue;const e=t.toLowerCase();r.has(e)?t===t.toLowerCase()&&r.set(e,t):r.set(e,t)}const i=Array.from(r.values()).sort((e,t)=>e.localeCompare(t)).map(e=>({value:e,label:T(e)})),l=new Map((Array.isArray(En.perWs)?En.perWs:[]).map(e=>[e.workspaceId,e])),o=On.filter(e=>{return void 0!==(t=l.get(e.id))&&(Number(t.turns)>0||Number(t.calls)>0||Number(t.input)>0||Number(t.output)>0||Number(t.cacheRead)>0||Number(t.cacheWrite)>0||Number(t.reasoning)>0);var t});return{providerOptions:t,modelOptions:i,rangeWorkspaceOptions:o,rangeWorkspaceIds:new Set(o.map(e=>e.id))}},[En.perModel,En.perWs,On,a]),{providerOptions:Kn,modelOptions:qn,rangeWorkspaceOptions:Bn,rangeWorkspaceIds:Hn}=Pn,Yn=n.useMemo(()=>{const e=new Map,t=new Map;return On.forEach((a,n)=>{e.set(a.id,a),t.set(a.id,n)}),{byId:e,indexes:t}},[On]),Vn=Yn.byId,Jn=Yn.indexes,Gn=n.useCallback(e=>{const t=Ln[e],n=Vn.get(e);if(void 0!==n&&!0===n.retiredBucket)return"en"===a?"Deleted":"已删除";const r="string"==typeof t&&""!==t?t:n&&n.title?n.title:"en"===a?"Unknown workspace":"未知工作区";return void 0!==n&&!0===n.deleted?r+("en"===a?" (deleted)":"(已删除)"):r},[Ln,Vn,a]),$n=n.useMemo(()=>[{value:"",label:"en"===a?"All workspaces":"全部工作区"}].concat(Bn.map(e=>({value:e.id,label:Gn(e.id)}))),[Bn,Gn,a]),_n=n.useMemo(()=>[{value:"",label:"en"===a?"All providers":"全部供应商"}].concat(Kn.map(e=>({value:e,label:e}))),[Kn,a]),Xn=n.useMemo(()=>[{value:"",label:"en"===a?"All models":"全部模型"}].concat(qn.map(e=>({value:e.value,label:e.label,iconKey:(()=>{const t=F({actualModel:e.value,requestedModel:e.value});return null===t?null:t.key})()}))),[qn,a]),Zn=n.useMemo(()=>{const e=new Map;for(const t of hn)e.set(t.date,t);return e},[hn]),Qn=n.useMemo(()=>function(e,t){const a=new Date;let n=0;for(let r=0;r<371;r++){const i=d(a,-r,t),l=e.get(u(i,t));if(void 0!==l&&l.turns>0)n+=1;else if(r>0)break}let r=0,i=0;for(let n=0;n<371;n++){const l=d(a,-n,t),o=e.get(u(l,t));void 0!==o&&o.turns>0?(i+=1,i>r&&(r=i)):i=0}return{streak:n,best:r}}(Zn,l),[Zn,l,f]),er=v&&v.pricing&&"object"==typeof v.pricing?v.pricing:{},tr=Vt&&"object"==typeof Vt?Vt:er,ar=n.useMemo(()=>Ht?function(e,t,a){const n=null!==e&&"object"==typeof e?e:{},r=function(e){if(null===e||"object"!=typeof e)return _(e);const t=se.get(e);if(void 0!==t)return t;const a=_(e);return se.set(e,a),a}(n),i=new Map;for(const e of Array.isArray(n.temporalSchedules)?n.temporalSchedules:[])null!==e&&"object"==typeof e&&"string"==typeof e.id&&Array.isArray(e.policies)&&i.set(e.id,e.policies);const l=null!==t&&"object"==typeof t&&Array.isArray(t.mappings)?t.mappings:[],o=null!==t&&"object"==typeof t&&Array.isArray(t.overrides)?t.overrides:[],s=null!==a&&"object"==typeof a?a:{},c=new Map;for(let e=0;e<l.length;e+=1){const t=l[e];if(null===t||"object"!=typeof t)continue;const a=String(t.identityKey||t.usageIdentityKey||"").trim();""===a||c.has(a)||c.set(a,e)}const u=new Map;for(let e=0;e<o.length;e+=1){const t=o[e];if(null===t||"object"!=typeof t)continue;const a=ie({providerId:t.providerId,modelId:t.modelId});u.has(a)||u.set(a,e)}return r.map(e=>{const t=function(e){if(null===e||"object"!=typeof e)return"";const t="string"==typeof e.identityKey?e.identityKey.trim():"";if(""!==t)return t;const a=e.pricingModel||e.actualModel||e.requestedModel||e.model||"";return"price|"+String(e.providerId||"").trim().toLowerCase()+"|"+String(a).trim().toLowerCase()}(e),a="string"==typeof e.identityKey?e.identityKey.trim():"",n=""!==a&&c.has(a)?c.get(a):-1,r=n>=0?l[n]:null,d=null!==r&&""!==String(r.catalogModelId||"").trim(),p=function(e,t){const a=null!==t&&"object"==typeof t&&"string"==typeof t.catalogModelId?t.catalogModelId.trim():"";if(""!==a)return{providerId:String(t.catalogProviderId||"").trim().toLowerCase(),modelId:a};const n=null!==e&&"object"==typeof e&&"priced"===e.status&&"string"==typeof e.pricingModel&&""!==e.pricingModel.trim(),r=n?e.pricingModel:null!==e&&"object"==typeof e?e.actualModel||e.requestedModel||e.pricingModel||e.model:"";return{providerId:n?String(e.providerId||"").trim().toLowerCase():"",modelId:String(r||"").trim()}}(e,r),m=ie(p),h=u.has(m)?u.get(m):-1,g=h>=0?o[h]:null,b=d&&null!==s[t]&&"object"==typeof s[t]?s[t]:null,f=null!==b&&null!==b.rates&&"object"==typeof b.rates?b:null,y=null!=g?{input:g.input,output:g.output,cacheRead:g.cacheRead,cacheWrite:g.cacheWrite}:null!==f?{input:f.rates.input,output:f.rates.output,cacheRead:f.rates.cacheRead,cacheWrite:f.rates.cacheWrite}:null!==e.rates&&"object"==typeof e.rates?{input:e.rates.input,output:e.rates.output,cacheRead:e.rates.cacheRead,cacheWrite:e.rates.cacheWrite}:null,x=Array.isArray(e.tiers)?e.tiers.map(e=>Object.assign({},e)):[],v=null!=g&&Array.isArray(g.tiers)?g.tiers.map(e=>Object.assign({},e)):null!==f?[]:x,w=null!=g?!0===g.tiered&&v.length>0:null!==f?!0===f.tiered:!0===e.tiered,k=null!=g?v.length:null!==f?Number.isFinite(Number(f.tierCount))?Number(f.tierCount):0:Number.isFinite(Number(e.tierCount))?Number(e.tierCount):v.length,E="string"==typeof e.temporalScheduleId?i.get(e.temporalScheduleId):null,N=null!=g&&void 0!==g.temporalPricing?g.temporalPricing:Array.isArray(E)?{policies:E}:null,C=null!=N&&Array.isArray(N.policies)?N.policies.reduce((e,t)=>e+(null!==t&&Array.isArray(t.rules)?t.rules.length:0),0):0,M=null!=g&&void 0!==g.temporalPricing,S="string"==typeof e.temporalPolicyId?e.temporalPolicyId:"",A="official"===e.temporalRoute||"mapped"===e.temporalRoute,z=null===N&&A&&""!==S;return{key:t,row:e,identityKey:"string"==typeof e.identityKey?e.identityKey:"",usageBacked:!0===e.usageBacked||!1!==e.usageBacked&&null,model:"string"==typeof e.model?e.model:"",status:"string"==typeof e.status?e.status:"unpriced",reason:"string"==typeof e.reason?e.reason:"",mapped:d,mapping:r,mappingIndex:n,basis:p,overrideIndex:h,override:g,source:null!=g?"manual":"string"==typeof e.source?e.source:"none",rates:y,tiers:v,tiered:w,tierCount:k,tieredInvalid:!0===e.tieredInvalid,multiplier:null!==r&&void 0!==r.multiplier?String(r.multiplier):"1",inputTokenSemantics:null!==r&&"string"==typeof r.inputTokenSemantics?r.inputTokenSemantics:"fresh",pricingModel:d?String(r.catalogModelId):"string"==typeof e.pricingModel?e.pricingModel:"",providerId:p.providerId,temporalPlan:void 0===N?null:N,temporalRuleCount:C,temporalPolicyId:S,temporalRoute:"string"==typeof e.temporalRoute?e.temporalRoute:"",temporalRulesUnavailable:z,temporalExplicit:!!M||!0===e.temporalExplicit,temporalBuiltin:!M&&(z||!0===e.temporalBuiltin),temporalConfigInvalid:!0===e.temporalConfigInvalid||null!=g&&!0===g.temporalPricingInvalid,targetPreview:b,mappable:"string"==typeof e.identityKey&&""!==e.identityKey.trim()}})}(tr,Gt,pa):[],[Ht,tr,Gt,pa]),nr=n.useMemo(()=>{const e=null!==Xa?{start:Xa.start,end:Xa.end}:Fe(v,O,l,bn),t=null!==Xa&&Xa.start===Xa.end&&Je&&Array.isArray(Je.hourly)&&Je.hourly.length>0?function(e,t,a,n){const r=null==t?null:!0===n?Array.isArray(t.byDayUtc)?t.byDayUtc:[]:Array.isArray(t.byDay)?t.byDay:[],i=null===r?void 0:r.find(e=>e.date===a),l=void 0===i?null:Me(i.tokens);if(null===l)return[];let o=0;for(const t of e)o+=Me(t.tokens)||0;return o<=0?[]:Math.abs(o-l)<=Math.max(.05*l,2e5)?e:[]}(Je.hourly,v,Xa.start,l):[],a=t.length>0?function(e,t){const a=[];for(const n of Array.isArray(e)?e:[]){if(null===n||"object"!=typeof n)continue;const e=Number.isFinite(n.time)?n.time:"string"==typeof n.date?Date.parse(n.date):NaN;if(!Number.isFinite(e))continue;const r=Oe(n);a.push({date:u(new Date(e),t),time:e,turns:Number.isFinite(n.turns)?n.turns:0,calls:Number.isFinite(n.calls)?n.calls:0,sessions:Number.isFinite(n.sessions)?n.sessions:0,tokens:r,cost:Y(n),total:r.input+r.output+r.cacheRead+r.cacheWrite+r.reasoning})}return a.sort((e,t)=>e.time-t.time)}(t,l):[];return a.length>0?a:function(e,t,a,n){if(null===t||"object"!=typeof t)return[];const r=n&&Number.isFinite(n.maxPoints)?n.maxPoints:180,i=new Map((Array.isArray(e)?e:[]).filter(e=>e&&"string"==typeof e.date).map(e=>[e.date,e])),l=t.start.split("-").map(Number),o=t.end.split("-").map(Number),s=a?new Date(Date.UTC(l[0],l[1]-1,l[2])):new Date(l[0],l[1]-1,l[2]),c=a?new Date(Date.UTC(o[0],o[1]-1,o[2])):new Date(o[0],o[1]-1,o[2]),d=function(e,t){if(!Number.isFinite(e)||e<=t)return null;const a=Pe[Pe.length-1];for(let a=0;a<Pe.length-1;a+=1)if(Math.ceil(e/Pe[a].days)<=t)return Pe[a];return a}(Math.round((c.getTime()-s.getTime())/864e5),r);if(null===d){const e=[];for(;s.getTime()<=c.getTime();){const t=u(s,a),n=i.get(t),r=Oe(n);e.push({date:t,turns:n&&Number.isFinite(n.turns)?n.turns:0,calls:n&&Number.isFinite(n.calls)?n.calls:0,sessions:n&&Number.isFinite(n.sessions)?n.sessions:0,tokens:r,cost:Y(n),total:r.input+r.output+r.cacheRead+r.cacheWrite+r.reasoning,bucket:{start:t,end:t,days:1,granularity:"day"}}),a?s.setUTCDate(s.getUTCDate()+1):s.setDate(s.getDate()+1)}return e}return function(e,t,a,n,r){const i=[];let l=t;for(;l<=a;){let t;if("week"===r.unit){const e=l.split("-").map(Number),a=n?new Date(Date.UTC(e[0],e[1]-1,e[2])).getUTCDay():new Date(e[0],e[1]-1,e[2]).getDay();t=Le(l,7*r.stride-(1===a?0:(a+6)%7),n)}else t=Le(l,r.days,n);const o=Le(t,-1,n),s=o>a?a:o,c={input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0},u=H();let d=0,p=0,m=0,h=0,g=0,b=l;for(;b<=s;){const t=e.get(b),a=Oe(t);d+=t&&Number.isFinite(t.turns)?t.turns:0,p+=t&&Number.isFinite(t.calls)?t.calls:0,m+=t&&Number.isFinite(t.sessions)?t.sessions:0,c.input+=a.input,c.output+=a.output,c.cacheRead+=a.cacheRead,c.cacheWrite+=a.cacheWrite,c.reasoning+=a.reasoning,h+=a.input+a.output+a.cacheRead+a.cacheWrite+a.reasoning,V(u,t),g+=1,b=Le(b,1,n)}if(i.push({date:l,turns:d,calls:p,sessions:m,tokens:c,cost:u,total:h,bucket:{start:l,end:s,days:g,granularity:"week"===r.unit?"week":"static"}}),s>=a)break;l=Le(s,1,n)}return i}(i,t.start,t.end,a,d)}(Cn&&Je&&Array.isArray(Je.daily)?Je.daily:hn,e,l)},[Xa,Cn,Je,hn,v,O,l,kn]),rr=Cn&&Je?Za+":"+(x(Je)||"query"):Za,ir=n.useMemo(()=>({}),[Ht,Gt,_t,Zt,ea,aa,ra,tr,er,ar,ha,ba,sa,ua,la,v,a]),lr=n.useMemo(()=>Wn.map((e,t)=>({label:e.model,value:Un(e),cost:e.cost,color:$e[t%$e.length],iconKey:"route"===Te?(()=>{const t=F(e);return null===t?null:t.key})():void 0===e.iconKey?null:e.iconKey})),[Wn,Te]),or=n.useMemo(()=>Fn.map((e,t)=>({label:Gn(e.workspaceId),value:Un(e),cost:e.cost,color:$e[t%$e.length]})),[Fn,Gn]),sr=n.useCallback(e=>{pt(t=>t.includes(e)?t.length<=1?t:t.filter(t=>t!==e):t.concat(e))},[]);if(n.useEffect(()=>{null===je||Hn.has(je)||De(null),null===Ke||Kn.includes(Ke)||qe(null),null===Be||qn.some(e=>e.value===Be)||He(null)},[je,Ke,Be,Hn,Kn,qn]),null===v){const e=""!==A;return n.createElement("div",{className:"uh-page"},n.createElement("div",{className:"uh-panel"},n.createElement("div",{className:"uh-empty"},e?r("无法加载用量统计。请重试。","Unable to load usage statistics. Please retry."):r("正在加载用量统计…","Loading usage statistics…")),e?n.createElement("div",{style:{textAlign:"center"}},n.createElement("button",{className:"uh-refresh",onClick:cn},n.createElement(C,{name:"refresh",size:14}),r("重试","Retry"))):null))}const cr=null!==M&&"object"==typeof M?M:v,ur=cr&&cr.scan?cr.scan:v.scan||{done:!0,started:!0,scanned:0,total:0,failed:0},dr=cr&&cr.sync?cr.sync:v.sync||{},pr=Mn,mr=(e,t,a)=>{const n=$a.current;return""===n?(a(null),Promise.resolve()):e(n).then(t,r=>null===r||"object"!=typeof r||403!==r.status?(a(r),Promise.resolve()):mt().then(i=>{const l=null!==i&&"object"==typeof i&&"string"==typeof i.requestToken?i.requestToken:"";if(""!==l&&l!==n)return $a.current=l,e(l).then(t,()=>{a(r)});a(r)},()=>{a(r)}))},hr=(e,t)=>{""!==$a.current&&mr(a=>{return n=e,r=String(void 0===t?"":t).trim(),fetch("/api/all-usage/alias",{method:"POST",headers:{"content-type":"application/json","x-all-usage-request-token":a},body:JSON.stringify({workspaceId:n,alias:r})}).then(e=>{if(!e.ok)throw new Error("HTTP "+e.status);return e.json()});var n,r},e=>{e&&e.ok&&e.aliases&&N(t=>null===t?t:Object.assign({},t,{aliases:e.aliases}))},()=>{})},gr=()=>{oa({}),ca({}),da(null),ma({}),ga(null),fa({}),Ea("")},br=()=>{Zt||ea||aa||(Ta(),Va.next(),Xt(!1),Yt(!1),Sa.current=!1,gr(),ia(""))},fr=()=>{const e=Va.next();Jt(null),$t(null),Xt(!0),gr(),Ta(),ia(""),Yt(!0),Sa.current=!0,Kt(!1),bt().then(t=>{if(!Va.isCurrent(e))return;if(!t||"object"!=typeof t||!t.config)return void ia("load");const a=$(t);Jt(t),$t(a)},()=>{Va.isCurrent(e)&&ia("load")}).finally(()=>{Va.isCurrent(e)&&Xt(!1)})},yr=e=>{if(null===Gt||Zt||ea||aa)return;const t=function(e,t){const a=e&&Array.isArray(e.mappings)?e.mappings:[];for(const e of a){if(!e||""===String(e.identityKey||e.usageIdentityKey||e.model||"").trim()||""===String(e.catalogModelId||"").trim())return"mapping";if(!["fresh","total","legacy"].includes(e.inputTokenSemantics||"fresh")||!te(void 0===e.multiplier?"1":e.multiplier))return"mapping"}const n=e&&Array.isArray(e.overrides)?e.overrides:[];for(const e of n){if(!e||""===String(e.modelId||"").trim())return"override";if(!["input","output","cacheRead","cacheWrite"].every(t=>te(e[t])))return"override";let t=0;const a=Array.isArray(e.tiers)?e.tiers:[];if(a.length>32)return"tier";for(const e of a){if(!ae(e,t))return"tier";t=Number(e.size)}if(!0===e.tiered&&0===a.length)return"tier"}const r=null!=t&&"object"==typeof t?t:{};for(const e of Object.keys(r))if(""!==Ee(r[e]))return"temporal";return""}(Gt,ba);if(""!==t)return void ia(t);if(function(e){try{return JSON.stringify({pricing:e}).length>204800}catch(e){return!0}}(Gt))return void ia("too-large");if(""===$a.current)return void ia("token");const a=Va.next();Qt(!0),ia(""),mr(t=>ft(Gt,e,t),e=>{Va.isCurrent(a)&&(e&&!0===e.ok&&e.pricing?(N(t=>null===t?t:Object.assign({},t,{pricing:e.pricing})),Jt(e.pricing),$t($(e.pricing)),gr(),br(),Ja.current()):ia("save"))},e=>{Va.isCurrent(a)&&ia(e&&403===e.status?"stale":"save")}).finally(()=>Qt(!1))},xr=()=>{Zt||ea||aa||(""!==$a.current?(ta(!0),ia(""),mr(e=>fetch("/api/all-usage/pricing/sync",{method:"POST",headers:{"content-type":"application/json","x-all-usage-request-token":e},body:"{}"}).then(e=>{if(!e.ok){const t=new Error("HTTP "+e.status);throw t.status=e.status,t}return e.json()}),e=>{e&&!0===e.ok&&e.pricing?(Ta(),N(t=>null===t?t:Object.assign({},t,{pricing:e.pricing})),Jt(e.pricing),$t(t=>X(t,e.pricing)),oa({}),ca({}),da(null),ma({}),fa({}),Ja.current()):ia("sync")},e=>{ia(e&&403===e.status?"stale":"sync")}).finally(()=>ta(!1))):ia("token"))},vr=(e,t,a)=>{$t(n=>null===n?n:function(e,t,a,n){if(null===e||"object"!=typeof e)return e;const r=oe(e.mappings,t.identityKey);if(r<0)return e;const i=e.mappings.slice(),l={};return l[a]=n,i[r]=Object.assign({},i[r],l),Object.assign({},e,{mappings:i})}(n,e,t,a)),ia("")},wr=(e,t,a,n)=>{const r=function(e,t,a,n){const r=Array.isArray(e)?e.map(e=>Object.assign({},e)):[];if(void 0===r[t])return r;const i={};return i[a]=n,r[t]=Object.assign({},r[t],i),r}(e.tiers,t,a,n);$t(t=>null===t?t:ce(t,e,{tiered:r.length>0,tiers:r})),ia("")},kr=(e,t)=>{fa(a=>Object.assign({},a,{[e.key]:t})),""===Ee(t)&&$t(n=>null===n?n:ce(n,e,{temporalPricing:ke(t,pe(a)),temporalPricingInvalid:void 0})),ia("")},Er=e=>{const t=fe(e.temporalPlan,pe(a))||ye(e.rates,pe(a));kr(e,t)},Nr=(e,t)=>{const n=e.key+"|"+t;ga(e=>e===n?null:n),"temporal"===t&&fa(t=>{if(void 0!==t[e.key])return t;const n=fe(e.temporalPlan,pe(a));return null===n?t:Object.assign({},t,{[e.key]:n})}),ia("")},Cr=()=>ga(null),Mr=An.totals.input+An.totals.output+An.totals.cacheRead+An.totals.cacheWrite+An.totals.reasoning,Sr=E(An.totals.input,An.totals.cacheRead),Ar=(Y(An.totals),J(An.totals,a)),zr=function(e,t){const a=Y(e);if(a.pricedCalls>0&&0===a.unpricedCalls&&0===a.ambiguousCalls&&0===a.unsupportedCalls)return"en"===t?a.pricedCalls+" priced":a.pricedCalls+" 次已计价";const n=a.unpricedCalls+a.ambiguousCalls+a.unsupportedCalls;return n>0?"en"===t?n+" unpriced":n+" 次未计价":"en"===t?"No pricing":"暂无价格"}(An.totals,a);let Tr="—",Ir=r("查询中…","Checking…");if(null!=D)if("missing-key"===D.status)Tr=r("未配置","Not configured"),Ir=r("在 设置 → 模型 中填写 DeepSeek API Key 后可见","Available after you enter a DeepSeek API key in Settings → Models");else if("unavailable"===D.status)Tr=r("不可用","Unavailable"),Ir=D.message||r("DeepSeek 接口返回余额不可用","The DeepSeek API reported that balance information is unavailable");else if("error"===D.status){Tr=r("查询失败","Lookup failed");const e=D.detail?"en"===a?" ("+String(D.detail).slice(0,90)+")":"("+String(D.detail).slice(0,90)+")":"";Ir=(D.message||"")+e+r(" 点“刷新”重试"," Click Refresh to try again")}else if("ok"===D.status&&Array.isArray(D.currencies)&&D.currencies.length>0){const e=D.currencies,t=e.find(e=>"CNY"===e.currency)||e[0],n=e.filter(e=>e!==t);Tr=P(t.currency,t.total,a,2);let i=null!==t.total?r("赠送 ","Granted ")+P(t.currency,t.granted,a,2)+" · "+r("充值 ","Top-up ")+P(t.currency,t.toppedUp,a,2):"";n.length>0&&(i+=(i?" | ":"")+n.map(e=>P(e.currency,e.total,a)).join(" ")),Ir=i}else Tr=r("无数据","No data"),Ir="";const Rr=(e,t,a,r,i,l)=>n.createElement("div",{className:"uh-card",style:{animationDelay:70*r+"ms"}},n.createElement("div",{className:"uh-card-label"},l?n.createElement(ct,{iconKey:l,size:15,showTitle:!0}):i?n.createElement(C,{name:i,size:14}):null,e),n.createElement("div",{className:"uh-card-value"},t),n.createElement("div",{className:"uh-card-sub"},a)),jr=n.createElement("div",{className:"uh-ios-metric uh-ios-metric-rate",style:{animationDelay:"280ms"}},n.createElement("div",{className:"uh-ios-metric-rate-head"},n.createElement("div",{className:"uh-ios-metric-label"},n.createElement(C,{name:"cache",size:18}),r("缓存命中率","Cache Hit Rate")),n.createElement("div",{className:"uh-ios-metric-rate-value"},Sr.toFixed(1)+"%")),n.createElement("div",{className:"uh-ios-metric-bar"},n.createElement("div",{className:"uh-ios-metric-fill",style:{width:Math.max(0,Math.min(100,Sr))+"%"}})),n.createElement("div",{className:"uh-ios-metric-rate-detail"},"en"===a?"Context reused "+w(An.totals.cacheRead)+" tokens":"复用上下文 "+w(An.totals.cacheRead)+" Token")),Dr=Fn.length>0?Un(Fn[0]):0,Ur=Fn.slice(0,2).map(e=>{const t=Un(e),r=Jn.get(e.workspaceId),i=Ie(void 0===r?0:r),l=je===e.workspaceId;return n.createElement("div",{key:e.workspaceId,className:"uh-wsbar"+(l?" uh-sel":""),onClick:()=>un(e.workspaceId)},n.createElement("div",{className:"uh-wsbar-top"},n.createElement("span",{className:"uh-dot",style:{background:i}}),n.createElement("span",{className:"uh-wsbar-title"},Gn(e.workspaceId)),n.createElement("span",{className:"uh-wsbar-num"},L(w(t),t,a))),n.createElement("div",{className:"uh-barwrap uh-bar-thin"},n.createElement("div",{className:"uh-barfill",style:{width:Dr>0?Math.max(2,t/Dr*100)+"%":"0%",background:i}})))}),Fr=n.createElement("div",{className:"uh-card",style:{animationDelay:"210ms"}},n.createElement("div",{className:"uh-card-label"},n.createElement(C,{name:"folder",size:14}),r("各工作区总处理量","Total Tokens Processed by Workspace")),0===Fn.length?n.createElement("div",{className:"uh-empty",style:{padding:"8px 0"}},r("暂无数据","No data yet")):n.createElement("div",{className:"uh-wsbars"},Ur,Fn.length>2?n.createElement("div",{className:"uh-card-sub"},"en"===a?"See the details table for the other "+(Fn.length-2)+" workspaces":"其余 "+(Fn.length-2)+" 个工作区见明细表"):null)),Wr=Fn.map(e=>{const t=Vn.get(e.workspaceId),i="string"==typeof Ln[e.workspaceId]?Ln[e.workspaceId]:"",l=t?t.title:r("未知工作区","Unknown workspace"),o=t?t.path:"",s=""!==i?i:l,c=""!==i?l+" · "+o:o,u=Un(e),d=E(e.input,e.cacheRead),p=Jn.get(e.workspaceId),m=Ie(void 0===p?0:p),h=je===e.workspaceId;return n.createElement("div",{key:e.workspaceId,className:"uh-row"+(h?" uh-sel":""),onClick:()=>un(e.workspaceId)},n.createElement("div",{className:"uh-row-title-wrap"},n.createElement("div",{className:"uh-ws-title"},s),n.createElement("div",{className:"uh-ws-path"},c)),n.createElement("div",{className:"uh-num"},w(e.turns)),n.createElement("div",{className:"uh-num"},w(e.input)),n.createElement("div",{className:"uh-num"},w(e.cacheRead)),n.createElement("div",{className:"uh-num"},w(e.output)),n.createElement("div",{className:"uh-num"},w(e.reasoning)),n.createElement("div",{},n.createElement("div",{className:"uh-num"},w(u)),n.createElement("div",{className:"uh-barwrap"},n.createElement("div",{className:"uh-barfill",style:{width:Dr>0?Math.max(2,u/Dr*100)+"%":"0%",background:m}}))),n.createElement("div",{className:"uh-num uh-cost-num"},J(e,a)),n.createElement("div",{className:"uh-num"},d.toFixed(1)+"%"),n.createElement("div",{className:"uh-num"},Dr>0?(u/Dr*100).toFixed(0)+"%":"0%"))}),Or="route"===Te?r("混合查看","Combined View"):"model"===Te?r("按模型合并","Grouped by Model"):r("按供应商汇总","Grouped by Provider"),Lr="route"===Te?r("供应商 / 模型","Provider / Model"):"model"===Te?r("模型","Model"):r("供应商","Provider"),Pr="model"!==yt||0===Wn.length?null:n.createElement(tt,{key:"model-donut-"+yt+":"+Za+":"+(Qa||"query")+":"+Te,title:"provider"===Te?r("供应商用量","Provider Usage"):r("模型用量","Model Usage"),icon:"chart",language:a,items:lr}),Kr="workspace"!==yt||0===Fn.length?null:n.createElement(tt,{key:"workspace-donut-"+yt+":"+Za+":"+(Qa||"query"),title:r("工作区用量","Workspace Usage"),icon:"folder",language:a,items:or}),qr="model"===yt?Wn.map(e=>{const t=Un(e),r=E(e.input,e.cacheRead);return n.createElement("div",{key:e.identityKey||e.model,className:"uh-model-row uh-row"},n.createElement("div",{className:"uh-row-title-wrap"},n.createElement("div",{className:"uh-ws-title uh-model-label",title:e.model},n.createElement(ct,{iconKey:e.iconKey,row:e,size:18,showTitle:!0}),n.createElement("span",{className:"uh-model-text"},e.model))),n.createElement("div",{className:"uh-num"},w(e.calls)),n.createElement("div",{className:"uh-num"},w(e.input)),n.createElement("div",{className:"uh-num"},w(e.cacheRead)),n.createElement("div",{className:"uh-num"},w(e.output)),n.createElement("div",{className:"uh-num"},w(e.reasoning)),n.createElement("div",{className:"uh-num"},w(t)),n.createElement("div",{className:"uh-num uh-cost-num"},J(e,a)),n.createElement("div",{className:"uh-num"},r.toFixed(1)+"%"))}):[],Br=Pt?n.createElement("div",{className:"uh-panel uh-anim-panel"},n.createElement("div",{className:"uh-alias-panel-head"},n.createElement("span",{},r("工作区别名","Workspace Aliases")),n.createElement("button",{className:"uh-alias-close",onClick:()=>Kt(!1)},r("关闭","Close"))),0===On.length?n.createElement("div",{className:"uh-empty",style:{padding:"10px 0"}},r("暂无工作区","No workspaces yet")):n.createElement("div",{className:"uh-alias-list"},On.map((e,t)=>n.createElement("div",{key:e.id,className:"uh-alias-item"},n.createElement("span",{className:"uh-dot",style:{background:Ie(t)}}),n.createElement("span",{className:"uh-alias-folder",title:e.path||e.id},(!0===e.retiredBucket?r("已删除","Deleted"):e.title||e.path||e.id)+(!0===e.deleted&&!0!==e.retiredBucket?r("(已删除)"," (deleted)"):"")),n.createElement("input",{className:"uh-alias-input",value:void 0!==qt[e.id]?qt[e.id]:"",placeholder:r("项目别名","Project alias"),onChange:t=>Bt(a=>Object.assign({},a,{[e.id]:t.target.value})),onKeyDown:t=>{"Enter"===t.key&&hr(e.id,t.target.value)}})))),n.createElement("div",{className:"uh-alias-panel-foot"},n.createElement("span",{className:"uh-note"},r("回车保存单个;清空别名还原文件夹名","Press Enter to save one; clear an alias to restore the folder name")),n.createElement("button",{className:"uh-alias-ok",onClick:()=>{for(const e of Object.keys(qt)){const t="string"==typeof Ln[e]?Ln[e]:"";qt[e]!==t&&hr(e,qt[e])}Kt(!1)}},r("全部保存","Save All")))):null,Hr=tr.sync&&"object"==typeof tr.sync?tr.sync:{},Yr=Zt||ea||aa,Vr="en"===a?["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]:["日","一","二","三","四","五","六"],Jr=ar.filter(e=>!1===e.usageBacked).length,Gr=ar.filter(e=>null===e.usageBacked).length,$r="string"==typeof cr.pluginVersion?cr.pluginVersion:"",_r=""!==$r&&$r!==i,Xr=!Array.isArray(tr.usedModels),Zr=e=>{if(!0===e.temporalConfigInvalid)return r("时段异常","Peak invalid");if(!0===e.temporalRulesUnavailable)return r("峰谷计划 ","peak plan ")+e.temporalPolicyId;const t=!0===e.temporalExplicit?e.temporalRuleCount>0?r("自定义 ","custom ")+e.temporalRuleCount+r(" 条规则"," rules"):r("自定义规则","custom rules"):!0===e.temporalBuiltin?r("内置 DeepSeek 峰谷表","built-in DeepSeek peak table"):null;return null===t?r("未启用","not enabled"):"official"!==e.temporalRoute&&"mapped"!==e.temporalRoute?t+r("(该行非官方直连,暂按静态价;映射到官方条目后生效)"," (reseller route: static pricing until this row is mapped to the official entry)"):t},Qr=(e,t)=>n.createElement("td",{className:"uh-pricing-rate-cell"},((e,t)=>n.createElement("input",{type:"number",min:"0",step:"any",className:"uh-pricing-rate-input","aria-label":re(t,a)+" · "+(e.model||e.pricingModel||""),title:r("价格单位为 USD / 1M Token","Price per 1M tokens in USD"),value:null!==e.rates&&void 0!==e.rates[t]?e.rates[t]:"",disabled:Yr,onChange:a=>((e,t,a)=>{$t(n=>null===n?n:function(e,t,a,n){const r={};return r[a]=n,ce(e,t,r)}(n,e,t,a)),ia("")})(e,t,a.target.value)}))(e,t)),ei=e=>{const t=void 0!==ba[e.key]?ba[e.key]:fe(e.temporalPlan,pe(a)),i=null==t?"":Ee(t),l=n.createElement("div",{className:"uh-pricing-tier-editor-head"},n.createElement("div",{className:"uh-pricing-tier-editor-title"},n.createElement("strong",{},r("分时段计费(北京时间 UTC+8)","Time-of-day pricing (UTC)")),n.createElement("span",{},!0===e.temporalExplicit?r("自定义规则","Custom rules"):!0===e.temporalRulesUnavailable?r("峰谷计划 ","Peak plan ")+e.temporalPolicyId:!0===e.temporalBuiltin?r("当前使用内置 DeepSeek 峰谷表","Using the built-in DeepSeek peak table"):r("未启用时段规则","No time-of-day rules"))),n.createElement("div",{className:"uh-actions"},!0===e.temporalBuiltin&&!0!==e.temporalExplicit?n.createElement("button",{type:"button",className:"uh-refresh",disabled:Yr,onClick:()=>Er(e)},!0===e.temporalRulesUnavailable?r("改为自定义规则","Replace with custom rules"):r("复制内置表并自定义","Copy built-in table")):null,!0===e.temporalExplicit?n.createElement("button",{type:"button",className:"uh-refresh",disabled:Yr,onClick:()=>(e=>{fa(t=>{const a=Object.assign({},t);return delete a[e.key],a}),e.overrideIndex<0||($t(t=>null===t?t:ce(t,e,{temporalPricing:void 0,temporalPricingInvalid:void 0})),ia(""))})(e)},!0===e.temporalBuiltin?r("恢复内置","Restore built-in"):r("清除时段规则","Remove rules")):null,!0!==e.temporalBuiltin&&!0!==e.temporalExplicit?n.createElement("button",{type:"button",className:"uh-refresh",disabled:Yr,onClick:()=>Er(e)},n.createElement(C,{name:"plus",size:13}),r("启用分时计费","Enable time-of-day pricing")):null));if(null==t)return n.createElement("div",{className:"uh-pricing-tier-editor uh-pricing-temporal-editor"},l,n.createElement("div",{className:"uh-pricing-tier-empty"},!0===e.temporalRulesUnavailable?r("该行已启用峰谷计划(","This row already uses a peak plan (")+e.temporalPolicyId+r("),但运行中的宿主尚未提供规则内容;重启 DSH 后即可查看与编辑。","), but the running host does not expose its rules yet; restart DSH to view and edit them."):r("未启用时段规则:所有请求都使用该行基础价。","No time-of-day rules: every request uses the row base rates.")));const o=he(t.effectiveFromText,pe(a)),s=!0===t.holidaysEnabled?be(t.holidaysText):null,c=t.rules.map((i,l)=>{const o=i.windows.map((a,o)=>n.createElement("div",{key:o,className:"uh-pricing-temporal-window"},n.createElement("input",{type:"text",className:"uh-pricing-time-input",placeholder:"HH:MM","aria-label":r("开始时间","Start time"),value:a.start,disabled:Yr,onChange:a=>kr(e,we(t,l,i.windows.map((e,t)=>t===o?{start:a.target.value,end:e.end}:e)))}),n.createElement("span",{className:"uh-pricing-time-sep"},"–"),n.createElement("input",{type:"text",className:"uh-pricing-time-input",placeholder:"HH:MM","aria-label":r("结束时间","End time"),value:a.end,disabled:Yr,onChange:a=>kr(e,we(t,l,i.windows.map((e,t)=>t===o?{start:e.start,end:a.target.value}:e)))}),i.windows.length>1?n.createElement("button",{type:"button",className:"uh-refresh uh-icon-button",title:r("删除时段","Remove window"),"aria-label":r("删除时段","Remove window"),disabled:Yr,onClick:()=>kr(e,we(t,l,i.windows.filter((e,t)=>t!==o)))},n.createElement(C,{name:"close",size:13})):null));return n.createElement("div",{key:i.id+":"+l,className:"uh-pricing-temporal-rule"},n.createElement("div",{className:"uh-pricing-temporal-rule-head"},n.createElement("span",{className:"uh-pricing-temporal-rule-name"},i.id),n.createElement("div",{className:"uh-pricing-weekdays"},Vr.map((a,r)=>n.createElement("button",{key:r,type:"button",className:"uh-pricing-weekday"+(i.weekdays.includes(r)?" uh-on":""),"aria-pressed":i.weekdays.includes(r),disabled:Yr,onClick:()=>kr(e,function(e,t,a){const n=xe(e);if(null===n||void 0===n.rules[t])return n;const r=n.rules[t],i=Number(a);return r.weekdays=(r.weekdays.includes(i)?r.weekdays.filter(e=>e!==i):r.weekdays.concat([i])).sort((e,t)=>e-t),n}(t,l,r))},a))),n.createElement("button",{type:"button",className:"uh-refresh uh-icon-button",disabled:Yr||t.rules.length<=1,title:r("删除规则","Remove rule"),"aria-label":r("删除规则","Remove rule"),onClick:()=>kr(e,function(e,t){const a=xe(e);return null===a||a.rules.length<=1||(a.rules=a.rules.filter((e,a)=>a!==t)),a}(t,l))},n.createElement(C,{name:"close",size:14}))),n.createElement("div",{className:"uh-pricing-temporal-windows"},o,i.windows.length<16?n.createElement("button",{type:"button",className:"uh-pricing-link",disabled:Yr,onClick:()=>kr(e,we(t,l,i.windows.concat([{start:"06:00",end:"10:00"}])))},r("添加时段","Add window")):null),n.createElement("div",{className:"uh-pricing-temporal-rates"},["input","output","cacheRead","cacheWrite"].map(o=>n.createElement("label",{key:o,className:"uh-pricing-temporal-rate"},n.createElement("span",{},r("峰时·","Peak ·")+re(o,a).split(" / ")[0]),n.createElement("input",{type:"number",min:"0",step:"any",value:i.rates[o],disabled:Yr,onChange:a=>kr(e,function(e,t,a){return ve(e,t,{rates:a})}(t,l,Object.assign({},i.rates,{[o]:a.target.value})))})))))});return n.createElement("div",{className:"uh-pricing-tier-editor uh-pricing-temporal-editor"},l,n.createElement("div",{className:"uh-pricing-tier-empty"},r("谷时段(未命中规则)使用该行基础价,峰时段使用规则费率;周几与时间均为 UTC。","Off-peak (no rule match) uses the row base rates, peak uses the rule rates. Weekdays and times are UTC.")),n.createElement("div",{className:"uh-pricing-temporal-fields"},n.createElement("label",{},n.createElement("span",{},r("策略 ID","Policy ID")),n.createElement("input",{type:"text",value:t.policyId,disabled:Yr,onChange:a=>kr(e,Object.assign(xe(t),{policyId:a.target.value}))})),n.createElement("label",{},n.createElement("span",{},r("生效起点(北京时间,留空 = 全部历史)","Effective from (UTC, empty = all history)")),n.createElement("input",{type:"date",value:t.effectiveFromText,disabled:Yr,onChange:a=>kr(e,Object.assign(xe(t),{effectiveFromText:a.target.value}))}))),null!==o&&o>0?n.createElement("div",{className:"uh-pricing-warning"},r("该时刻之前的用量没有可用档位,会失败关闭为未计价。","Usage before this instant has no applicable band and fails closed as unpriced.")):null,n.createElement("div",{className:"uh-pricing-temporal-holidays"},n.createElement("label",{className:"uh-pricing-switch"},n.createElement("input",{type:"checkbox",checked:!0===t.holidaysEnabled,disabled:Yr,onChange:a=>kr(e,Object.assign(xe(t),{holidaysEnabled:a.target.checked}))}),n.createElement("span",{},r("中国法定节假日全天按谷时计价","Chinese statutory holidays price as off-peak all day"))),!0===t.holidaysEnabled?n.createElement(n.Fragment,null,n.createElement("div",{className:"uh-pricing-tier-empty"},r("每行一个日期(YYYY-MM-DD),支持区间写法 2026-10-01..2026-10-07。按北京时间(UTC+8)日历日判定;调休上班日不会被自动识别,需要你自己从列表里去掉。","One date per line (YYYY-MM-DD); ranges such as 2026-10-01..2026-10-07 are expanded. Days follow the China Standard Time (UTC+8) calendar; swapped-in working weekends are not detected, so remove them yourself.")),n.createElement("textarea",{className:"uh-pricing-holiday-input",rows:4,spellCheck:!1,disabled:Yr,placeholder:"2026-10-01\n2026-10-02","aria-label":r("法定节假日日期","Statutory holiday dates"),value:t.holidaysText,onChange:a=>kr(e,Object.assign(xe(t),{holidaysText:a.target.value}))}),null===s?n.createElement("span",{className:"uh-pricing-error"},r("日期格式无效:请使用 YYYY-MM-DD,或 start..end 区间","Invalid dates: use YYYY-MM-DD, or a start..end range")):n.createElement("span",{className:"uh-pricing-tier-empty"},r("已解析 ","parsed ")+s.length+r(" 天节假日"," holiday days")),n.createElement("div",{className:"uh-pricing-holiday-load"},n.createElement("label",{className:"uh-pricing-map-field"},n.createElement("span",{},r("年份","Year")),n.createElement("input",{type:"number",min:"2000",max:"2100",step:"1",value:ya,disabled:Yr||va,"aria-label":r("要载入的年份","Year to load"),onChange:e=>xa(Number(e.target.value))})),n.createElement("button",{type:"button",className:"uh-refresh",disabled:Yr||va,onClick:()=>(e=>{if(!0===va)return;if(""===$a.current)return void Ea(r("当前进程令牌不可用,请刷新看板","The process capability is unavailable; refresh the dashboard"));const t=Number(ya);!Number.isSafeInteger(t)||t<2e3||t>2100?Ea(r("年份无效(2000–2100)","Invalid year (2000-2100)")):(wa(!0),Ea(""),mr(e=>((e,t)=>fetch("/api/all-usage/pricing/holidays",{method:"POST",headers:{"content-type":"application/json","x-all-usage-request-token":t},body:JSON.stringify({year:e,backfill:!1})}).then(e=>e.json().catch(()=>({ok:!1,message:"bad-response"})).then(t=>null!==t&&"object"==typeof t?t:{ok:!1,message:"HTTP "+e.status})))(t,e),t=>{if(null===t||"object"!=typeof t||!0!==t.ok||!Array.isArray(t.dates)){const e=t&&"object"==typeof t&&"string"==typeof t.message&&""!==t.message?t.message:"unavailable";return void Ea(r("抓取失败:","Fetch failed: ")+e)}const n=void 0!==ba[e.key]?ba[e.key]:fe(e.temporalPlan,pe(a))||ye(e.rates,pe(a)),i=function(e,t){const a=be(e),n=null===a?[]:a.slice(),r=new Set(n);for(const e of Array.isArray(t)?t:[]){const t=String(e??"").trim();""===t||r.has(t)||(r.add(t),n.push(t))}return n.sort(),0===n.length?"":n.join("\n")}(n.holidaysText,t.dates),l=Number(t.fetchedAt),o="string"==typeof t.paperUrl&&""!==t.paperUrl?t.paperUrl:String(t.sourceUrl||""),s=Number.isFinite(l)&&l>0?new Date(l).toISOString().slice(0,16).replace("T"," "):"",c=Object.assign(xe(n),{holidaysEnabled:!0,holidaysText:i,holidaysSourceText:(o+(""===s?"":" · "+s)+(!0===t.cached?" · cached":"")).slice(0,512)});Ea(r("已载入 ","Loaded ")+t.dates.length+r(" 天"," days")+(!0===t.cached?r("(缓存)"," (cached)"):"")),kr(e,c)},()=>{Ea(r("抓取失败:网络不可用","Fetch failed: network unavailable"))}).finally(()=>wa(!1)))})(e)},n.createElement(C,{name:"refresh",size:13}),va?r("抓取中…","Fetching…"):r("从公开日历载入","Load from public calendar")),""!==ka?n.createElement("span",{className:"uh-pricing-tier-empty"},ka):null),""!==t.holidaysSourceText?n.createElement("span",{className:"uh-pricing-tier-empty",title:t.holidaysSourceText},r("来源:","Source: ")+t.holidaysSourceText):null):null),c,n.createElement("div",{className:"uh-pricing-temporal-foot"},t.rules.length<16?n.createElement("button",{type:"button",className:"uh-refresh",disabled:Yr,onClick:()=>kr(e,function(e){const t=xe(e);if(null===t||t.rules.length>=16)return t;const a=t.rules.length>0?t.rules[t.rules.length-1]:null;return t.rules.push({id:"peak-"+(t.rules.length+1),weekdays:null!==a?a.weekdays.slice(0,1):[1,2,3,4,5],windows:[{start:"06:00",end:"10:00"}],rates:null!==a?Object.assign({},a.rates):{input:"",output:"",cacheRead:"",cacheWrite:""}}),t}(t))},n.createElement(C,{name:"plus",size:13}),r("添加规则","Add rule")):null,""!==i?n.createElement("span",{className:"uh-pricing-error"},r("时段规则尚未完成,保存前需修正。","The rules are incomplete; fix them before saving.")):null))},ti=e=>{const t=null!==ha&&0===ha.indexOf(e.key+"|")?ha.slice(e.key.length+1):"";return n.createElement("div",{className:"uh-pricing-editor"},"tiers"===t?(e=>{const t=e.tiers;let i=0;const l=t.map((l,o)=>{const s=ae(l,i),c=Number(null!=l&&void 0!==l.size?l.size:NaN);return Number.isSafeInteger(c)&&(i=c),n.createElement("div",{key:o,className:"uh-pricing-tier-edit-row"+(s?"":" uh-invalid")},n.createElement("input",{type:"number",min:"1",max:"1000000000",step:"1",placeholder:r("阈值 Token","Token threshold"),title:r("本档覆盖范围:","This band covers ")+ee(t,o,a),"aria-label":r("上下文阈值 Token","Context threshold tokens"),value:null==l||void 0===l.size?"":l.size,disabled:Yr,onChange:t=>wr(e,o,"size",t.target.value)}),["input","output","cacheRead","cacheWrite"].map(t=>n.createElement("input",{key:t,type:"number",min:"0",step:"any",placeholder:re(t,a),"aria-label":r("档位","Band")+" "+re(t,a),value:null==l||void 0===l[t]?"":l[t],disabled:Yr,onChange:a=>wr(e,o,t,a.target.value)})),n.createElement("button",{type:"button",className:"uh-refresh uh-icon-button",title:r("删除费率档位","Remove rate band"),"aria-label":r("删除费率档位","Remove rate band"),disabled:Yr,onClick:()=>((e,t)=>{const a=function(e,t){return(Array.isArray(e)?e:[]).filter((e,a)=>a!==t).map(e=>Object.assign({},e))}(e.tiers,t);$t(t=>null===t?t:ce(t,e,{tiered:a.length>0,tiers:a})),ia("")})(e,o)},n.createElement(C,{name:"close",size:14})))});return n.createElement("div",{className:"uh-pricing-tier-editor"},n.createElement("div",{className:"uh-pricing-tier-editor-head"},n.createElement("div",{className:"uh-pricing-tier-editor-title"},n.createElement("strong",{},r("上下文费率档位","Context rate bands")),n.createElement("span",{},r("输入上下文超过阈值后,整次请求使用该档四项费率","Above a threshold, all four rates apply to the whole request"))),n.createElement("button",{type:"button",className:"uh-refresh",disabled:Yr||t.length>=32,title:t.length>=32?r("每个模型最多 32 个档位","Maximum 32 bands per model"):r("添加上下文费率档位","Add context rate band"),onClick:()=>(e=>{const t=function(e,t){const a=Array.isArray(e)?e.map(e=>Object.assign({},e)):[];if(a.length>=32)return a;const n=a.length>0?a[a.length-1]:null,r=null!==n&&Number.isFinite(Number(n.size))?Number(n.size):1e5,i=null!==n?n:null!==t&&"object"==typeof t?t:{};return a.push({type:"context",size:Math.min(1e9,r+1e5),input:ne(i.input),output:ne(i.output),cacheRead:ne(i.cacheRead),cacheWrite:ne(i.cacheWrite)}),a}(e.tiers,e.rates);$t(a=>null===a?a:ce(a,e,{tiered:t.length>0,tiers:t})),ia("")})(e)},n.createElement(C,{name:"plus",size:13}),r("添加档位","Add band"))),0===t.length?n.createElement("div",{className:"uh-pricing-tier-empty"},r("未配置档位,所有上下文使用基础费率。","No bands configured; base rates apply to every context.")):n.createElement(n.Fragment,null,n.createElement("div",{className:"uh-pricing-tier-edit-head"},n.createElement("span",{},r("超过 Token","Above tokens")),n.createElement("span",{},r("输入 / 1M","Input / 1M")),n.createElement("span",{},r("输出 / 1M","Output / 1M")),n.createElement("span",{},r("缓存读 / 1M","Cache read / 1M")),n.createElement("span",{},r("缓存写 / 1M","Cache write / 1M")),n.createElement("span",{},"")),l))})(e):null,"temporal"===t?ei(e):null,n.createElement("div",{className:"uh-pricing-editor-foot"},n.createElement("button",{type:"button",className:"uh-pricing-link",onClick:Cr},r("收起","Collapse"))))},ai=e=>sa[e.key],ni=e=>{const t=null!==ha&&0===ha.indexOf(e.key+"|")?ha:null,i=ai(e),l=Array.isArray(la[e.key])?la[e.key]:[];return n.createElement(n.Fragment,{key:e.key},n.createElement("tr",{className:"uh-pricing-model-row"+(!0===e.usageBacked?"":!1===e.usageBacked?" uh-pricing-configured-row":" uh-pricing-unknown-row")},n.createElement("td",{className:"uh-pricing-model-name"},n.createElement("span",{className:"uh-model-label",title:e.model},n.createElement(ct,{row:e.row,size:16}),n.createElement("span",{className:"uh-model-text"},e.model||r("未知模型","Unknown model"))),n.createElement("div",{className:"uh-pricing-row-flags"},n.createElement("span",{className:"uh-pricing-status uh-pricing-status-"+e.status,title:e.reason||""},Z(e.status,a)),n.createElement("span",{className:"uh-pricing-tier-badge uh-flat"},(e=>!0===e.temporalConfigInvalid?r("时段配置异常","Peak plan invalid"):!0===e.tieredInvalid?r("档位异常","Bands invalid"):"manual"===e.source?r("手工价","Manual"):!0===e.temporalExplicit?r("自定义峰谷","Custom peak"):!0===e.temporalBuiltin?r("内置峰谷","Built-in peak"):"priced"===e.status?r("目录价","Catalog"):Z(e.status,a))(e)),e.mapped?n.createElement("span",{className:"uh-pricing-flag"},r("已映射","Mapped")):null,!0===e.usageBacked?null:!1===e.usageBacked?n.createElement("span",{className:"uh-pricing-flag"},r("账本无用量","No ledger usage")):n.createElement("span",{className:"uh-pricing-flag uh-pricing-flag-unknown",title:r("宿主未在模型清单里标注账本用量(通常是宿主插件版本较旧);这不代表没有用量","The host did not label ledger usage for this row (usually an older host plugin); it does not mean the row has none")},r("用量未知","Usage unknown")))),n.createElement("td",{className:"uh-pricing-map-cell"},n.createElement("div",{className:"uh-pricing-model-search"},n.createElement("input",{type:"text",className:"uh-pricing-model-search-input",placeholder:!0===e.mappable?r("输入官方模型 ID 检索","Type an official model ID"):r("该行不是账本路线","Not a ledger route"),value:void 0!==i?i:e.pricingModel||"",disabled:Yr||!0!==e.mappable,"aria-label":r("官方模型 ID","Official model ID"),"aria-autocomplete":"list",onFocus:t=>{if(!0!==e.mappable||!0===Yr)return;da(e.key);const a=t.target;if(null!=a&&"function"==typeof a.select){try{a.select()}catch(e){}"function"==typeof requestAnimationFrame&&requestAnimationFrame(()=>{try{a.select()}catch(e){}})}},onBlur:()=>setTimeout(()=>{da(t=>t===e.key?null:t),ca(t=>{const a=Object.assign({},t);return delete a[e.key],a})},140),onKeyDown:e=>{"Escape"===e.key&&da(null)},onChange:t=>((e,t)=>{const a=e.key,n=Ca.current;ca(e=>Object.assign({},e,{[a]:t})),da(a);const r=Ma.current[a];void 0!==r&&(clearTimeout(r),delete Ma.current[a]);const i=(Na.current[a]||0)+1;if(Na.current[a]=i,""===String(t||"").trim())return void oa(e=>Object.assign({},e,{[a]:[]}));const l=setTimeout(()=>{delete Ma.current[a],(e=>{const t=new URLSearchParams({q:String(e||"").slice(0,120),limit:"30"});return fetch("/api/all-usage/pricing/models?"+t.toString(),{headers:{accept:"application/json"}}).then(e=>{if(!e.ok)throw new Error("HTTP "+e.status);return e.json()})})(t).then(e=>{Ca.current===n&&Na.current[a]===i&&oa(t=>Object.assign({},t,{[a]:Array.isArray(e&&e.items)?e.items:[]}))},()=>{Ca.current===n&&Na.current[a]===i&&oa(e=>Object.assign({},e,{[a]:[]}))})},180);Ma.current[a]=l})(e,t.target.value)}),ua===e.key&&l.length>0?n.createElement("div",{className:"uh-language-options uh-pricing-model-options",role:"listbox","aria-label":r("官方模型匹配结果","Official model matches")},l.map(t=>n.createElement("button",{key:t.value,type:"button",role:"option",className:"uh-language-option uh-pricing-model-option",onMouseDown:e=>e.preventDefault(),onClick:()=>((e,t)=>{if(!t||"string"!=typeof t.value)return;const a=Ma.current[e.key];void 0!==a&&(clearTimeout(a),delete Ma.current[e.key]),Na.current[e.key]=(Na.current[e.key]||0)+1,$t(a=>null===a?a:function(e,t,a){const n=null!==e&&"object"==typeof e?e:{sync:{},mappings:[],overrides:[]};if(!0!==t.mappable||null==a||"string"!=typeof a.value)return n;const r=Array.isArray(n.mappings)?n.mappings.map(e=>Object.assign({},e)):[],i=oe(r,t.identityKey),l={identityKey:t.identityKey,provider:null!==t.row&&"object"==typeof t.row&&"string"==typeof t.row.provider?t.row.provider:"",model:null!==t.row&&"object"==typeof t.row&&(t.row.actualModel||t.row.requestedModel)||"",catalogProviderId:"string"==typeof a.providerId?a.providerId:"",catalogModelId:a.value};return i<0?r.push(Object.assign({inputTokenSemantics:"fresh",multiplier:"1"},l)):r[i]=Object.assign({},r[i],l),Object.assign({},n,{mappings:r})}(a,e,t)),ma(a=>Object.assign({},a,{[e.key]:t})),ca(a=>Object.assign({},a,{[e.key]:t.label||t.value})),da(null),ia("")})(e,t)},n.createElement(C,{name:"list",size:14}),n.createElement("span",{className:"uh-pricing-model-option-name"},t.label||t.value),n.createElement("span",{className:"uh-pricing-model-option-id"},t.value+(!0===t.tiered?" · "+r("分层 ","tiered ")+t.tierCount:"")+(!0===t.builtinTemporal?" · "+r("峰谷","peak"):""))))):null,e.mapped?n.createElement("button",{type:"button",className:"uh-pricing-link uh-pricing-clear-mapping",disabled:Yr,title:r("删除该行的官方模型映射,回到按模型自动匹配","Remove this row mapping and fall back to automatic model matching"),onClick:()=>(e=>{$t(t=>null===t?t:function(e,t){if(null===e||"object"!=typeof e)return e;const a=oe(e.mappings,t);if(a<0)return e;const n=e.mappings.slice();return n.splice(a,1),Object.assign({},e,{mappings:n})}(t,e.identityKey)),ma(t=>{const a=Object.assign({},t);return delete a[e.key],a}),ca(t=>{const a=Object.assign({},t);return delete a[e.key],a}),ia("")})(e)},r("清除映射","Clear mapping")):null),n.createElement("div",{className:"uh-pricing-map-sub"},n.createElement("label",{className:"uh-pricing-map-field"},n.createElement("span",{},r("倍率","Multiplier")),n.createElement("input",{type:"number",min:"0",step:"any",value:e.multiplier,disabled:Yr||!0!==e.mapped,title:!0===e.mapped?r("成本倍率,只作用于最终总价","Cost multiplier; applied to the final total only"):r("设置映射后生效","Effective after a mapping is set"),"aria-label":r("成本倍率","Cost multiplier"),onChange:t=>vr(e,"multiplier",t.target.value)})),n.createElement("label",{className:"uh-pricing-map-field"},n.createElement("span",{},r("输入口径","Input semantics")),n.createElement("select",{value:e.inputTokenSemantics,disabled:Yr||!0!==e.mapped,"aria-label":r("输入口径","Input semantics"),title:Q(e.inputTokenSemantics,a),onChange:t=>vr(e,"inputTokenSemantics",t.target.value)},n.createElement("option",{value:"fresh"},"Fresh"),n.createElement("option",{value:"total"},"Total"),n.createElement("option",{value:"legacy"},"Legacy"))))),Qr(e,"input"),Qr(e,"output"),Qr(e,"cacheRead"),Qr(e,"cacheWrite"),n.createElement("td",{className:"uh-pricing-row-actions"},n.createElement("button",{type:"button",className:"uh-pricing-chip"+(null!==t&&"tiers"===t.slice(e.key.length+1)?" uh-on":"")+(e.tierCount>0?" uh-strong":""),disabled:Yr,title:e.tierCount>0?r("上下文分层:已配置 ","Context tiers: ")+e.tierCount+r(" 个档位"," bands"):r("上下文分层:未配置,所有上下文使用基础费率","Context tiers: none, base rates apply to every context"),onClick:()=>Nr(e,"tiers")},r("上下文分层","Context tiers")),n.createElement("button",{type:"button",className:"uh-pricing-chip"+(null!==t&&"temporal"===t.slice(e.key.length+1)?" uh-on":"")+(!0===e.temporalBuiltin||!0===e.temporalExplicit?" uh-strong":""),disabled:Yr,title:r("时间分层:","Time tiers: ")+Zr(e),onClick:()=>Nr(e,"temporal")},r("时间分层","Time tiers")),"manual"===e.source?n.createElement("button",{type:"button",className:"uh-pricing-link",disabled:Yr,title:r("删除手工价,回落到目录价或内置峰谷","Remove the manual price and fall back to the catalog or the built-in peak table"),onClick:()=>(e=>{$t(t=>null===t?t:function(e,t){if(null===e||"object"!=typeof e)return e;const a=le(e.overrides,t);if(a<0)return e;const n=e.overrides.slice();return n.splice(a,1),Object.assign({},e,{overrides:n})}(t,e.basis)),fa(t=>{const a=Object.assign({},t);return delete a[e.key],a}),ia("")})(e)},r("恢复默认","Reset")):null)),null===t?null:n.createElement("tr",{className:"uh-pricing-editor-row"},n.createElement("td",{colSpan:7},ti(e))))},ri=Ht?n.createElement(ot,{revision:ir,render:()=>{return null!==Gt?n.createElement("div",{className:"uh-panel uh-pricing-panel uh-anim-panel"},n.createElement("div",{className:"uh-pricing-head"},n.createElement("div",{className:"uh-title-with-icon"},n.createElement(C,{name:"wallet",size:16}),n.createElement("strong",{},r("成本统计设置","Cost Statistics"))),n.createElement("button",{type:"button",className:"uh-refresh uh-icon-button",title:r("关闭成本设置","Close cost settings"),"aria-label":r("关闭成本设置","Close cost settings"),disabled:Yr,onClick:br},n.createElement(C,{name:"close",size:16}))),n.createElement("div",{className:"uh-pricing-note"},r("价格单位为 USD / 1M Token。直接改价格框即创建或更新手工价(同一官方模型的所有行共享同一价格);「官方模型」列选定映射后该行自动改用官方目录价;「档位」配置上下文费率档,「分时计费」配置 UTC 峰谷规则。","Prices are USD per 1M tokens. Editing a price box creates or updates a manual price (every row priced from the same official model shares it). Picking an official model in the mapping column switches the row to the catalog price. Bands add context-dependent rates; Time-of-day adds UTC peak rules.")),n.createElement("div",{className:"uh-pricing-toolbar"},n.createElement("label",{className:"uh-pricing-switch"},n.createElement("input",{type:"checkbox",checked:!0===Gt.sync.autoEnabled,disabled:Yr,onChange:e=>(e=>{if(null===Gt||aa||Zt||ea)return;const t=!0===e,a=Gt.sync&&!0===Gt.sync.autoEnabled;if($t(e=>null===e?e:Object.assign({},e,{sync:Object.assign({},e.sync,{autoEnabled:t})})),Ct({pricingAutoSync:t}),""===$a.current)return $t(e=>null===e?e:Object.assign({},e,{sync:Object.assign({},e.sync,{autoEnabled:a})})),Ct({pricingAutoSync:a}),void ia("token");const n=e=>{$t(e=>null===e?e:Object.assign({},e,{sync:Object.assign({},e.sync,{autoEnabled:a})})),Ct({pricingAutoSync:a}),ia(e)};na(!0),ia(""),mr(e=>ft({sync:{autoEnabled:t}},!1,e),e=>{if(!e||!0!==e.ok||!e.pricing)return void n("save");const t=e.pricing.sync&&!0===e.pricing.sync.autoEnabled;N(t=>null===t?t:Object.assign({},t,{pricing:e.pricing})),Jt(e.pricing),$t(a=>null===a?a:Object.assign({},a,{sync:Object.assign({},a.sync,{autoEnabled:t,intervalMs:e.pricing.sync&&e.pricing.sync.intervalMs})})),Ct({pricingAutoSync:t})},e=>n(e&&403===e.status?"stale":"save")).finally(()=>na(!1))})(e.target.checked)}),n.createElement("span",{},r("启用 6 小时自动同步","Enable 6-hour automatic sync"))),n.createElement("span",{className:"uh-note"},aa?r("保存中…","Saving…"):Hr.lastSuccessAt>0?r("上次成功:","Last success: ")+new Date(Hr.lastSuccessAt).toLocaleString():r("尚未同步","Not synced yet")),n.createElement("button",{type:"button",className:"uh-refresh",onClick:xr,disabled:Yr},n.createElement(C,{name:"refresh",size:14}),ea?r("同步中…","Syncing…"):r("立即同步","Sync now"))),Hr.lastError?n.createElement("div",{className:"uh-pricing-error",role:"alert"},r("上次同步失败:","Last sync failed: ")+Hr.lastError):null,_r?n.createElement("div",{className:"uh-pricing-error",role:"status"},r("宿主插件 v","Host plugin v")+$r+r(" 与当前页面 v"," and this page v")+i+r(" 不一致:DSH 只在启动时加载插件,请重启 DSH 让新版本生效(本面板正按旧宿主的数据降级显示)"," differ: DSH imports the plugin only at startup, so restart DSH for the new version (this panel is showing the older host payload)")):null,Xr?n.createElement("div",{className:"uh-pricing-error",role:"status"},r("宿主未提供模型清单(插件版本较旧):无法列出账本模型;请重启 DSH 后重新打开本面板","The host sent no model list (older plugin): the ledger models cannot be listed; restart DSH and reopen this panel")):null,n.createElement("div",{className:"uh-pricing-table-note"},r("共 ","")+ar.length+r(" 个模型"," models")+(Jr>0?r("("," (")+Jr+r(" 项仅存在于配置中,账本暂无用量)"," configured rows have no ledger usage)"):"")+(Gr>0?r("(其中 "," (")+Gr+r(" 项用量未知:宿主未标注账本用量)"," rows have unknown usage: the host did not label ledger usage)"):"")+(ar.length>=500?r(" · 已达 500 行上限"," · capped at 500 rows"):"")),n.createElement("div",{className:"uh-pricing-table-wrap"},n.createElement("table",{className:"uh-pricing-model-table uh-pricing-price-table"},n.createElement("thead",{},n.createElement("tr",{},n.createElement("th",{scope:"col"},r("模型","Model")),n.createElement("th",{scope:"col"},r("官方模型 / 映射","Official model / mapping")),n.createElement("th",{scope:"col"},r("输入 / 1M","Input / 1M")),n.createElement("th",{scope:"col"},r("输出 / 1M","Output / 1M")),n.createElement("th",{scope:"col"},r("缓存读 / 1M","Cache read / 1M")),n.createElement("th",{scope:"col"},r("缓存写 / 1M","Cache write / 1M")),n.createElement("th",{scope:"col"},r("操作","Actions")))),n.createElement("tbody",{},0===ar.length?n.createElement("tr",{},n.createElement("td",{colSpan:7},n.createElement("div",{className:"uh-empty",style:{padding:"12px 0"}},r("暂无模型用量","No model usage yet")))):ar.map(e=>n.createElement(st,{key:e.key,view:e,busy:Yr,language:a,openSection:null!==ha&&0===ha.indexOf(e.key+"|")?ha:null,searchText:void 0===ai(e)?null:ai(e),searchOpen:ua===e.key,searchOptions:Array.isArray(la[e.key])?la[e.key]:null,temporalDraft:void 0===ba[e.key]?null:ba[e.key],temporalPlan:e.temporalPlan,holidayStatus:ka,holidayLoading:va,render:ni}))))),""!==ra?n.createElement("div",{className:"uh-pricing-error",role:"alert"},"stale"===(e=ra)?r("写入被拒绝:进程令牌已失效,自动重取令牌后仍失败,请刷新看板","Write rejected: the process capability had rotated and the automatic retry still failed; refresh the dashboard"):"forbidden"===e?r("写入被拒绝:权限校验未通过(也可能是进程令牌已失效),请刷新看板后重试","Write rejected: the permission check failed (a stale process capability is also possible); refresh the dashboard and retry"):"token"===e?r("当前进程令牌不可用,请刷新看板","The process capability is unavailable; refresh the dashboard"):"load"===e?r("完整费率设置加载失败","Full pricing settings could not be loaded"):"sync"===e?r("models.dev 同步失败,已保留上次成功目录和未保存编辑","models.dev sync failed; the last good catalog and unsaved edits were kept"):"mapping"===e?r("模型映射无效:请选择官方模型并填写有效倍率","Invalid mapping: pick an official model and enter a valid multiplier"):"tier"===e?r("费率档位无效:最多 32 档;阈值必须为递增的正整数,四项费率必须完整且非负","Invalid rate bands: maximum 32; thresholds must be increasing positive integers and all four rates must be complete and non-negative"):"temporal"===e?r("分时计费无效:需要策略 ID,每规则至少一个周几与一个时段,时间格式 HH:MM 且结束大于开始,同周几的时段不得重叠,四项费率必须完整","Invalid time-of-day rules: a policy ID, at least one weekday and window per rule, HH:MM times with the end after the start, no overlapping windows on the same weekday, and all four rates filled in"):"override"===e?r("价格无效:请填写完整的非负基础费率","Invalid price: enter all non-negative base rates"):"too-large"===e?r("成本设置过大,无法保存:请精简档位或时段规则","The cost settings are too large to save: trim bands or peak rules"):r("成本设置保存失败,请检查输入","Cost settings could not be saved; check the inputs")):null,n.createElement("div",{className:"uh-pricing-foot"},n.createElement("span",{className:"uh-note"},r("保存只影响未计价调用与之后的调用,已有正成本不会重算;改动时段规则会按新政策重新对账该模型历史。","Saving affects unpriced and future calls only; existing positive costs are never recalculated. Changing a peak plan reconciles that model history against the new rules.")),n.createElement("div",{className:"uh-actions"},n.createElement("button",{type:"button",className:"uh-refresh",disabled:Yr,onClick:br},r("取消","Cancel")),n.createElement("button",{type:"button",className:"uh-refresh",disabled:Yr,onClick:()=>yr(!1)},Zt?r("保存中…","Saving…"):r("保存","Save")),n.createElement("button",{type:"button",className:"uh-refresh uh-pricing-backfill",disabled:Yr,onClick:()=>yr(!0)},r("保存并回填","Save and backfill"))))):n.createElement("div",{className:"uh-panel uh-pricing-panel uh-anim-panel"},n.createElement("div",{className:"uh-pricing-head"},n.createElement("div",{className:"uh-title-with-icon"},n.createElement(C,{name:"wallet",size:16}),n.createElement("strong",{},r("成本统计设置","Cost Statistics"))),n.createElement("button",{type:"button",className:"uh-refresh uh-icon-button",title:r("关闭成本设置","Close cost settings"),"aria-label":r("关闭成本设置","Close cost settings"),disabled:Yr,onClick:br},n.createElement(C,{name:"close",size:16}))),_t?n.createElement("div",{className:"uh-empty",role:"status",style:{display:"flex",alignItems:"center",justifyContent:"center",gap:10}},n.createElement("span",{className:"uh-trend-spinner","aria-hidden":!0}),n.createElement("span",{},r("正在加载完整费率设置…","Loading full pricing settings…"))):n.createElement("div",{className:"uh-empty",role:"alert"},n.createElement("div",{},r("完整费率设置加载失败","Full pricing settings could not be loaded")),n.createElement("button",{type:"button",className:"uh-refresh",style:{marginTop:10},onClick:fr},n.createElement(C,{name:"refresh",size:14}),r("重试","Retry"))));var e}}):null,ii=function(e,t){const a=null!==t&&"object"==typeof t?t:{},n="string"==typeof a.current&&""!==a.current?a.current:"string"==typeof e?e:"",r="string"==typeof a.latest&&""!==a.latest?a.latest:null,i="outdated"===a.status||"latest"===a.status?a.status:"unknown",l=Number(a.checkedAt);return{current:n,latest:r,status:null===r?"unknown":i,checkedAt:Number.isFinite(l)&&l>0?l:null,sourceUrl:"string"==typeof a.sourceUrl?a.sourceUrl:"",error:"string"==typeof a.error?a.error:""}}(null!==v&&"string"==typeof v.pluginVersion?v.pluginVersion:i,G),li="latest"===ii.status?r("已是最新","Up to date"):"outdated"===ii.status&&null!==ii.latest?r("最新 v","Latest v")+ii.latest:"",oi=r("当前版本 v","Running version v")+ii.current+("latest"===ii.status?r("\n已是最新版本","\nThis is the newest release"):"")+("outdated"===ii.status&&null!==ii.latest?r("\n最新版本 v","\nNewest release v")+ii.latest:"")+("unknown"===ii.status&&"endpoint"===de?r("\n宿主尚未提供版本检查(运行中的插件较早):重启 DSH 后可用","\nThe host does not provide the version check yet (an older plugin is running): restart DSH"):"unknown"===ii.status?r("\n尚未确认是否有新版本","\nWhether a newer release exists is not confirmed"):"")+(null!==ii.checkedAt?r("\n检查时间:","\nChecked: ")+new Date(ii.checkedAt).toLocaleString():"")+(""!==ii.error?r("\n版本检查失败:","\nVersion check failed: ")+ii.error:"")+r("\n点击打开 GitHub 仓库","\nClick to open the GitHub repository"),si=n.createElement("button",{type:"button",className:"uh-version"+("outdated"===ii.status?" uh-version-outdated":""),title:oi,"aria-label":oi,onClick:()=>{try{window.open("https://github.com/ParticleLight/dsh-all-usage","_blank","noopener,noreferrer")}catch(e){}}},n.createElement("span",{className:"uh-version-number"},"v"+ii.current),""===li?null:n.createElement("span",{className:"uh-version-status"},li)),ci="custom"===O&&null!==bn?"en"===a?bn.start+" to "+bn.end+" (UTC)":bn.start+" 至 "+bn.end:"today"===O?r("今日","Today"):"7d"===O?r("近 7 天","Last 7 Days"):"30d"===O?r("近 30 天","Last 30 Days"):"90d"===O?r("近 90 天","Last 90 Days"):r("全部","All Time"),ui=function(e,t,a){if("custom"!==e)return e;const n=m(t,a);return null===n?"custom":"custom-"+n.start+"-to-"+n.end}(O,bn,l),di="invalid"===fn?r("请选择有效的开始日期和结束日期","Choose valid start and end dates"):"order"===fn?r("结束日期不能早于开始日期","End date must be on or after the start date"):"bounds"===fn?r("可选范围为 "+gn+" 至 "+f,"Choose a date from "+gn+" to "+f):"",pi=Ae?n.createElement("div",{className:"uh-custom-range",role:"group","aria-label":r("自定义时间范围","Custom date range")},n.createElement("div",{className:"uh-custom-range-meta"},n.createElement("div",{className:"uh-custom-range-title"},n.createElement(C,{name:"calendar",size:15}),r("自定义时间范围","Custom date range")),n.createElement("div",{className:"uh-custom-range-note"},r("可查看全部可扫描历史日数据;中文按本地日期,English 按 UTC。热力图可切换最近 30 天 / 90 天 / 12 个月。","All available historical daily data can be selected. Chinese uses local dates; English uses UTC. The heatmap switches between the last 30 days, 90 days and 12 months."))),n.createElement("div",{className:"uh-custom-range-fields"},n.createElement("label",{className:"uh-custom-range-field"},n.createElement("span",{},r("开始日期","Start date")),n.createElement("input",{type:"date",value:Ce.start,min:gn,max:f,onChange:e=>Se(t=>Object.assign({},t,{start:e.target.value}))})),n.createElement("label",{className:"uh-custom-range-field"},n.createElement("span",{},r("结束日期","End date")),n.createElement("input",{type:"date",value:Ce.end,min:gn,max:f,onChange:e=>Se(t=>Object.assign({},t,{end:e.target.value}))}))),n.createElement("div",{className:"uh-custom-range-actions"},n.createElement("button",{type:"button",className:"uh-custom-range-cancel",onClick:()=>ze(!1)},r("取消","Cancel")),n.createElement("button",{type:"button",className:"uh-custom-range-apply",disabled:""!==fn,onClick:()=>{if(""!==fn)return;const e=m(Ce,l);null!==e&&(Ne(e),K("custom"),ze(!1))}},r("应用","Apply"))),""!==di?n.createElement("div",{className:"uh-custom-range-error",role:"alert"},di):null):null,mi=n.createElement(nt,{key:rr,rows:nr,visible:rt,language:a,rangeLabel:ci,loading:Ze&&!vn,error:""===et||"stale"===et||Cn?"":r("趋势数据加载失败","Trend data unavailable"),onToggle:sr,onPointClick:on}),hi=null===en?ci:en.start===en.end?en.start:en.start+" → "+en.end,gi=n.createElement(ut,{visible:"logs"===yt,panelRef:Da,scopeLabel:hi,scopeUtc:!(!en||!en.utc),scopeAvailable:null!==en,loading:Dt,exporting:Ft,error:Ot,rows:Mt,selectedId:kt,hasMore:Tt,language:a,actionKey:tn+":"+(Qa||"")+":"+(At||""),onExport:async()=>{if("logs"!==yt||null===en||Ft)return;const e=Qa;Wt(!0),Lt("");try{let t=null;const a=[];for(let n=0;n<50;n+=1){const n=await gt(en,t,200);if(null===n||"object"!=typeof n||!Array.isArray(n.items)||null===e||x(n)!==e)throw new Error("audit export stale");if(a.push(...n.items),!n.hasMore||!n.nextCursor)break;t=n.nextCursor}const n=e=>'"'+String(e??"").replace(/"/g,'""')+'"',i=e=>e.map(n).join(","),l=[r("时间","Time"),r("日期","Date"),r("Provider","Provider"),r("请求模型","Requested model"),r("实际模型","Actual model"),r("显示模型","Display model"),"turn","step","seq",r("输入","Input"),r("缓存命中","Cache read"),r("缓存写入","Cache write"),r("输出","Output"),r("推理","Reasoning"),r("成本","Cost"),r("计价状态","Cost status"),r("计价模型","Pricing model"),r("计费档位","Billing band"),r("计费时刻(UTC)","Billing time (UTC)"),r("计费时间来源","Billing time source"),r("计费策略","Billing policy"),r("策略哈希","Policy hash"),r("来源","Source")],o=[i([r("DSH 用量明细导出","DSH Usage Audit Export")]),i([r("范围","Scope"),en.start+" → "+en.end]),i([r("时区","Timezone"),en.utc?"UTC":r("本地","Local")]),i(l)];for(const e of a)o.push(i([e.time,e.date,e.provider,e.requestedModel,e.actualModel,e.model,e.turn,e.step,e.seq,lt(e,"input"),lt(e,"cacheRead"),lt(e,"cacheWrite"),lt(e,"output"),lt(e,"reasoning"),e.cost&&"priced"===e.cost.status?e.cost.total:"",e.cost&&e.cost.status?e.cost.status:"unpriced",e.cost&&e.cost.pricingModel?e.cost.pricingModel:"",e.cost&&e.cost.pricingBand?e.cost.pricingBand:"",e.cost&&Number.isFinite(e.cost.pricingAt)?new Date(e.cost.pricingAt).toISOString():"",e.cost&&e.cost.pricingTimeSource?e.cost.pricingTimeSource:"",e.cost&&e.cost.pricingPolicyId?e.cost.pricingPolicyId:"",e.cost&&e.cost.pricingPolicyHash?e.cost.pricingPolicyHash:"",e.materialization||"unknown"]));const s=new Blob(["\ufeff"+o.join("\r\n")],{type:"text/csv;charset=utf-8"}),c=URL.createObjectURL(s),u=document.createElement("a");u.href=c,u.download="dsh-all-usage-audit-"+en.start+"-to-"+en.end+".csv",document.body.appendChild(u),u.click(),u.remove(),URL.revokeObjectURL(c)}catch(e){Lt("audit-export")}finally{Wt(!1)}},onLoadMore:()=>{if("logs"!==yt||null===en||null===At||Dt)return;const e=Ya.next(),t=Qa;Ut(!0),gt(en,At,20).then(a=>{if(Ya.isCurrent(e)){if(null===a||"object"!=typeof a||!Array.isArray(a.items)||null===t||x(a)!==t)return Lt("stale"),Ut(!1),void jt(e=>e+1);St(e=>e.concat(a.items)),zt(a.nextCursor||null),It(!0===a.hasMore&&a.items.length>0),Ut(!1),Lt("")}},t=>{if(Ya.isCurrent(e)){if(t&&409===t.status)return Ut(!1),zt(null),It(!1),Lt("stale"),void jt(e=>e+1);Ut(!1),Lt("audit")}})},onSelect:Et}),bi=!ur.done,fi=ur.total>0?Math.min(100,Math.round(ur.scanned/ur.total*100)):40,yi=ur.done&&0===pr.length&&0===An.totals.turns&&0===An.totals.calls,xi="number"==typeof dr.lastCompletedAt&&dr.lastCompletedAt>0?new Date(dr.lastCompletedAt).toLocaleString("en"===a?"en-US":"zh-CN"):"",vi=R>0?new Date(R).toLocaleString("en"===a?"en-US":"zh-CN"):"",wi=""===xi?void 0:"en"===a?"Historical scan completed "+xi:"历史扫描完成于 "+xi,ki="en"===a?(""!==vi?"Updated "+vi:bi?"Refreshing data":"Update state pending")+" · "+(dr.sessionsSkippedByRevision||0)+" revision reused · "+(dr.sessionsRead||0)+" read"+((dr.sessionsRestoredFromLedger||0)>0?" · "+dr.sessionsRestoredFromLedger+" ledger restored":"")+((dr.sessionsFailed||0)>0?" · "+dr.sessionsFailed+" failed":"")+" · "+(!0===dr.persistenceSnapshotsAvailable?"revision optimization on":"full-read fallback"):(""!==vi?"已更新 "+vi:bi?"正在更新数据":"数据更新准备中")+" · revision 复用 "+(dr.sessionsSkippedByRevision||0)+" · 实际读取 "+(dr.sessionsRead||0)+((dr.sessionsRestoredFromLedger||0)>0?" · 账本恢复 "+dr.sessionsRestoredFromLedger:"")+((dr.sessionsFailed||0)>0?" · 失败 "+dr.sessionsFailed:"")+" · "+(!0===dr.persistenceSnapshotsAvailable?"免读优化已启用":"全量读取回退"),Ei=""===A?"":"en"===a?"Usage data may be stale"+(""!==vi?"; last full update "+vi:""):"用量数据可能已过期"+(""!==vi?";上次完整更新 "+vi:"");return n.createElement("div",{className:"uh-page"},n.createElement("div",{className:"uh-head"},n.createElement("div",{className:"uh-title-wrap"},n.createElement("h2",{className:"uh-title"},r("用量统计","Usage Statistics")),si),n.createElement("div",{className:"uh-actions"},n.createElement("button",{className:"uh-refresh",title:r("管理工作区别名","Manage workspace aliases"),onClick:()=>{Pt?Kt(!1):(()=>{const e={};On.forEach(t=>{e[t.id]="string"==typeof Ln[t.id]?Ln[t.id]:""}),Bt(e),Kt(!0)})()}},n.createElement(C,{name:"edit",size:14}),r("工作区别名","Workspace Aliases")),n.createElement("button",{className:"uh-refresh",title:r("配置模型价格与同步","Configure model prices and sync"),disabled:Zt||ea||aa,onClick:()=>{Ht?br():fr()}},n.createElement(C,{name:"wallet",size:14}),r("成本设置","Cost Settings")),n.createElement("div",{className:"uh-language-menu"+(Ia?" uh-open":""),ref:ja,onKeyDown:e=>{"Escape"===e.key&&(e.preventDefault(),Ra(!1))}},n.createElement("button",{type:"button",className:"uh-language-trigger"+(Ia?" uh-open":""),title:r("切换界面语言","Change interface language"),"aria-label":r("界面语言","Interface language"),"aria-haspopup":"menu","aria-expanded":Ia,onClick:()=>Ra(e=>!e)},n.createElement(C,{name:"language",size:14}),n.createElement("span",{className:"uh-language-label"},"en"===a?"English":"中文"),n.createElement(C,{name:"chevron",size:13,className:"uh-language-caret"})),Ia?n.createElement("div",{className:"uh-language-options",role:"menu","aria-label":r("界面语言","Interface language")},[["zh","中文"],["en","English"]].map(t=>n.createElement("button",{key:t[0],type:"button",role:"menuitemradio","aria-checked":a===t[0],className:"uh-language-option"+(a===t[0]?" uh-on":""),onClick:()=>((t=>{"function"==typeof e.onLanguageChange&&e.onLanguageChange("en"===t?"en":"zh")})(t[0]),void Ra(!1))},n.createElement(C,{name:"language",size:14}),n.createElement("span",{},t[1]),a===t[0]?n.createElement(C,{name:"check",size:14,className:"uh-language-option-check"}):null))):null),n.createElement("div",{className:"uh-range"},["today","7d","30d","90d","all","custom"].map(e=>n.createElement("button",{key:e,type:"button",className:O===e?"uh-on":"",title:"custom"===e&&"custom"===O?ci:void 0,onClick:()=>{"custom"===e?(()=>{const e=m(ge,l),t=u(d(c,-89,l),l);Se(e||{start:t<gn?gn:t,end:f}),ze(!0)})():(K(e),ze(!1))}},"today"===e?r("今日","Today"):"7d"===e?r("近 7 天","Last 7 Days"):"30d"===e?r("近 30 天","Last 30 Days"):"90d"===e?r("近 90 天","Last 90 Days"):"all"===e?r("全部","All Time"):r("自定义","Custom")))),n.createElement("button",{className:"uh-refresh",title:r("导出当前时间范围与模型查看模式的 CSV 数据","Export CSV data for the current time range and model view"),onClick:()=>{const e=e=>'"'+String(e??"").replace(/"/g,'""')+'"',t=t=>t.map(e).join(","),n=e=>e.input+e.output+e.cacheRead+e.cacheWrite+e.reasoning,i=[r("输入 Token","Input Tokens"),r("缓存命中 Token","Cache-Hit Tokens"),r("缓存写入 Token","Cache-Write Tokens"),r("输出 Token","Output Tokens"),r("推理 Token","Reasoning Tokens"),r("总处理 Token","Total Tokens Processed"),r("成本","Cost"),r("缓存命中率","Cache Hit Rate")],o=[t([r("DSH 用量统计导出","DSH Usage Statistics Export")]),t([r("导出时间","Exported At"),l?(new Date).toLocaleString("en-US",{timeZone:"UTC",timeZoneName:"short"}):(new Date).toLocaleString("zh-CN")]),t([r("时间范围","Time Range"),ci]),t([r("时区","Timezone"),l?"UTC":r("本地","Local")]),t([r("工作区筛选","Workspace Filter"),je||r("全部","All")]),t([r("供应商筛选","Provider Filter"),Ke||r("全部","All")]),t([r("模型筛选","Model Filter"),null===Be?r("全部","All"):T(Be)]),t([r("统计 revision","Stats Revision"),v.revision||""]),t([r("模型查看模式","Model View Mode"),Or]),"",t([r("汇总","Summary")]),t([r("回合","Turns"),r("会话","Sessions"),...i]),t([An.totals.turns,An.totals.sessions,An.totals.input,An.totals.cacheRead,An.totals.cacheWrite,An.totals.output,An.totals.reasoning,n(An.totals),J(An.totals,a),E(An.totals.input,An.totals.cacheRead).toFixed(2)+"%"]),"",t([r("模型用量明细","Model Usage Details")]),t([Lr,r("调用","Calls"),...i]),...Wn.map(e=>t([e.model,e.calls,e.input,e.cacheRead,e.cacheWrite,e.output,e.reasoning,n(e),J(e,a),E(e.input,e.cacheRead).toFixed(2)+"%"])),"",t([r("工作区明细","Workspace Details")]),t([r("工作区","Workspace"),r("路径","Path"),r("回合","Turns"),...i]),...Fn.map(e=>{const r=Vn.get(e.workspaceId);return t([Gn(e.workspaceId),r?r.path:"",e.turns,e.input,e.cacheRead,e.cacheWrite,e.output,e.reasoning,n(e),J(e,a),E(e.input,e.cacheRead).toFixed(2)+"%"])})],s=new Blob(["\ufeff"+o.join("\r\n")],{type:"text/csv;charset=utf-8"}),c=URL.createObjectURL(s),d=document.createElement("a");d.href=c,d.download="dsh-all-usage-"+ui+"-"+Te+"-"+u(new Date,l)+".csv",document.body.appendChild(d),d.click(),d.remove(),URL.revokeObjectURL(c)}},n.createElement(C,{name:"export",size:14}),r("导出数据","Export Data")),n.createElement("button",{className:"uh-refresh uh-icon-button",title:r("刷新统计数据","Refresh usage statistics"),"aria-label":r("刷新统计数据","Refresh usage statistics"),onClick:cn},n.createElement(C,{name:"refresh",size:16})))),n.createElement("div",{className:"uh-filter-bar",role:"group","aria-label":r("统一筛选","Unified filters")},n.createElement(dt,{label:r("全部工作区","All workspaces"),ariaLabel:r("工作区筛选","Workspace filter"),className:"uh-filter-workspace",icon:"folder",value:je||"",options:$n,onChange:e=>De(e||null)}),n.createElement(dt,{label:r("全部供应商","All providers"),ariaLabel:r("供应商筛选","Provider filter"),className:"uh-filter-provider",icon:"chart",value:Ke||"",options:_n,onChange:e=>pn(e)}),n.createElement(dt,{label:r("全部模型","All models"),ariaLabel:r("模型筛选","Model filter"),className:"uh-filter-model",icon:"cache",value:Be||"",options:Xn,onChange:e=>mn(e)}),null!==je||null!==Ke||null!==Be?n.createElement("button",{type:"button",className:"uh-filter-clear",onClick:dn},r("清除筛选","Clear filters")):null,Ze?n.createElement("span",{className:"uh-query-note"},r("正在更新筛选结果…","Updating filtered data…")):null,""!==et&&"stale"!==et?n.createElement("span",{className:"uh-query-note",role:"alert"},r("筛选结果加载失败","Filtered data unavailable")):null),Pt?Br:null,ri,pi,bi?n.createElement("div",{className:"uh-progress"},n.createElement("span",{},"en"===a?"Scanning historical sessions: "+ur.scanned+" / "+ur.total+(ur.failed>0?" ("+ur.failed+" failed to read)":""):"正在统计历史会话 "+ur.scanned+" / "+ur.total+(ur.failed>0?"("+ur.failed+" 个读取失败)":"")),n.createElement("div",{className:"uh-bar"},n.createElement("div",{className:"uh-fill",style:{width:fi+"%"}}))):null,n.createElement("div",{className:"uh-sync-health"+(""!==Ei?" uh-stale":""),title:""!==Ei?void 0:wi},n.createElement(C,{name:""!==Ei?"refresh":"clock",size:14}),n.createElement("span",{},""!==Ei?Ei:ki),""!==Ei?n.createElement("button",{className:"uh-sync-retry",onClick:cn},r("重试","Retry")):null),yi?n.createElement("div",{className:"uh-panel"},n.createElement("div",{className:"uh-empty"},r("还没有使用记录。开始对话后,这里会点亮。","No usage recorded yet. This area will light up after you start a conversation."))):n.createElement(n.Fragment,null,n.createElement(n.Fragment,null,n.createElement("div",{className:"uh-ios-summary"},n.createElement("div",{className:"uh-ios-summary-hero"},n.createElement("div",{className:"uh-ios-summary-total"},n.createElement("div",{className:"uh-ios-summary-total-icon"},n.createElement(C,{name:"chart",size:24})),n.createElement("div",{className:"uh-ios-summary-total-copy"},n.createElement("div",{className:"uh-ios-summary-label"},r("总处理 Token","Total Tokens Processed")),n.createElement("div",{className:"uh-ios-summary-value"},L(w(zn),Mr,a)),n.createElement("div",{className:"uh-ios-summary-caption"},"en"===a?ci+" · "+w(jn)+(Tn?" calls":" uses")+" · includes cache reads/writes and reasoning":ci+" · "+w(jn)+(Tn?" 次调用":" 次使用")+" · 含缓存读写与推理"))),n.createElement("div",{className:"uh-ios-summary-meta"},n.createElement("div",{className:"uh-ios-summary-meta-stat"},n.createElement("div",{className:"uh-ios-summary-meta-label"},n.createElement(C,{name:"chart",size:16}),r("总请求数","Total Requests")),n.createElement("div",{className:"uh-ios-summary-meta-value"},k(Dn,a))),n.createElement("div",{className:"uh-ios-summary-meta-stat uh-ios-summary-meta-cost"},n.createElement("div",{className:"uh-ios-summary-meta-label"},n.createElement(C,{name:"wallet",size:16}),r("估算成本","Estimated Cost")),n.createElement("div",{className:"uh-ios-summary-meta-value"},Ar),n.createElement("div",{className:"uh-ios-summary-meta-caption"},zr)))),n.createElement("div",{className:"uh-ios-metrics"},Rr(r("DeepSeek 账户余额","DeepSeek Account Balance"),Tr,Ir,0,"wallet","deepseek"),Rr(Tn?r("匹配调用次数","Matching Calls"):r("总使用次数","Total Uses"),w(jn),"all"!==O||Tn?"en"===a?(Tn?"Calls in ":"Turns in ")+ci:ci+(Tn?"内的调用数":"内的回合数"):"en"===a?An.totals.sessions+" sessions":An.totals.sessions+" 个会话",1,"chart"),Rr(r("连续使用","Current Streak"),"en"===a?Qn.streak+" days":Qn.streak+" 天","en"===a?"Longest streak: "+Qn.best+" days":"最长连续 "+Qn.best+" 天",2,"clock"),Fr,jr)),n.createElement("div",{className:"uh-token-semantics"},n.createElement(C,{name:"cache",size:16}),r("总处理 Token = 输入 + 输出 + 缓存读写 + 推理。缓存命中代表复用上下文,不等于新生成 Token 或实际费用。成本按事件发生时刻与官方价目估算,不等同于供应商账单。","Total tokens processed = input + output + cache reads/writes + reasoning. Cache hits represent reused context; they are not newly generated tokens or actual cost. Costs are estimated at event time from official price lists and do not equal the provider invoice.")),mi,n.createElement(it,{rows:Sn,workspaces:On,aliases:Ln,workspaceId:je,queryUsable:Cn,todayKey:f,utc:l,language:a,span:q,onSpanChange:yn,onWorkspaceSelect:un,onDateClick:on}),n.createElement("div",{className:"uh-detail-tabs",role:"tablist","aria-label":r("用量明细视图","Usage detail views")},[["logs",r("请求日志","Request Logs"),"list"],["model",r("模型统计","Model Stats"),"chart"],["workspace",r("工作区统计","Workspace Stats"),"folder"]].map(e=>n.createElement("button",{key:e[0],type:"button",role:"tab","aria-selected":yt===e[0],className:"uh-detail-tab"+(yt===e[0]?" uh-on":""),onClick:()=>xt(e[0])},n.createElement(C,{name:e[2],size:14}),e[1]))),gi),"model"===yt?n.createElement("div",{className:"uh-panel uh-ios-list-panel"},n.createElement("div",{className:"uh-hm-head"},n.createElement("h3",{className:"uh-tbl-title uh-title-with-icon",style:{margin:0}},n.createElement(C,{name:"chart",size:16}),"en"===a?"Model Usage Details ("+ci+")":"模型用量明细("+ci+")"),n.createElement("div",{className:"uh-range"},[["route",r("混合查看","Combined View")],["model",r("按模型","By Model")],["provider",r("按供应商","By Provider")]].map(e=>n.createElement("button",{key:e[0],className:Te===e[0]?"uh-on":"",onClick:()=>Re(e[0])},e[1])))),0===Wn.length?n.createElement("div",{className:"uh-empty"},r("尚无带模型路由信息的用量记录","No usage records with model-routing information yet")):n.createElement(n.Fragment,null,Pr,n.createElement("div",{className:"uh-tbl-scroll"},n.createElement("div",{className:"uh-model-hrow uh-hrow"},n.createElement("div",{},Lr),n.createElement("div",{className:"uh-num"},r("调用","Calls")),n.createElement("div",{className:"uh-num"},r("输入","Input")),n.createElement("div",{className:"uh-num"},r("缓存命中","Cache Hits")),n.createElement("div",{className:"uh-num"},r("输出","Output")),n.createElement("div",{className:"uh-num"},r("推理","Reasoning")),n.createElement("div",{className:"uh-num"},r("总处理","Total Processed")),n.createElement("div",{className:"uh-num"},r("成本","Cost")),n.createElement("div",{className:"uh-num"},r("命中率","Hit Rate"))),qr)),n.createElement("div",{className:"uh-note",style:{marginTop:10}},"en"===a?Or+": Combined View distinguishes “Provider / Model”; By Model merges identically named models across providers; By Provider aggregates all of a provider’s models. Historical records without routing information are grouped as “Unknown.”":Or+":混合查看按“供应商 / 模型”区分;按模型会跨供应商合并同名模型;按供应商则汇总其全部模型。缺少路由信息的历史记录会归为“未知”。")):null,"workspace"===yt?n.createElement("div",{className:"uh-panel uh-ios-list-panel"},n.createElement("h3",{className:"uh-tbl-title uh-title-with-icon"},n.createElement(C,{name:"folder",size:16}),"en"===a?"Workspace Details ("+ci+")":"工作区明细("+ci+")"),0===Fn.length?n.createElement("div",{className:"uh-empty"},r("该时间范围内没有使用记录","No usage records in this time range")):n.createElement(n.Fragment,null,Kr,n.createElement("div",{className:"uh-tbl-scroll"},n.createElement("div",{className:"uh-hrow"},n.createElement("div",{},r("工作区","Workspace")),n.createElement("div",{className:"uh-num"},r("回合","Turns")),n.createElement("div",{className:"uh-num"},r("输入","Input")),n.createElement("div",{className:"uh-num"},r("缓存命中","Cache Hits")),n.createElement("div",{className:"uh-num"},r("输出","Output")),n.createElement("div",{className:"uh-num"},r("推理","Reasoning")),n.createElement("div",{className:"uh-num"},r("总处理","Total Processed")),n.createElement("div",{className:"uh-num"},r("成本","Cost")),n.createElement("div",{className:"uh-num"},r("命中率","Hit Rate")),n.createElement("div",{className:"uh-num"},r("占比","Share"))),Wr))):null))}class St extends n.Component{constructor(e){super(e),this.state={error:null,resetKey:e.resetKey}}static getDerivedStateFromError(e){return{error:e}}componentDidUpdate(e){e.resetKey!==this.props.resetKey&&null!==this.state.error&&this.setState({error:null,resetKey:this.props.resetKey})}render(){return null!==this.state.error?this.props.fallback(this.state.error):this.props.children}}function At(e){const[t,a]=n.useState(!1),[i,l]=n.useState(0),[o,u]=n.useState(kt),d=(e,t)=>"en"===o?t:e,p=s();n.useEffect(()=>{if(!t)return;c();const e=e=>{"Escape"===e.key&&a(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[t]);const m=null!=r&&"function"==typeof r.createPortal&&"undefined"!=typeof document&&null!==document&&null!==document.body&&void 0!==document.body?document.body:null,h=t?n.createElement("div",{className:"uh-side-modal",role:"presentation",style:p>0?{"--uh-top-inset":p+"px"}:void 0,onMouseDown:e=>{e.target===e.currentTarget&&a(!1)}},n.createElement("div",{className:"uh-side-dialog",role:"dialog","aria-modal":!0,"aria-label":d("用量统计","Usage Statistics")},n.createElement("div",{className:"uh-side-dialog-head"},n.createElement("button",{className:"uh-refresh uh-close-button",type:"button",title:d("关闭用量统计","Close Usage Statistics"),"aria-label":d("关闭用量统计","Close Usage Statistics"),onClick:()=>a(!1)},n.createElement(C,{name:"close",size:18}))),n.createElement(St,{resetKey:i,fallback:()=>n.createElement("div",{className:"uh-boundary-fallback",role:"alert"},n.createElement("div",{className:"uh-boundary-title"},d("用量统计暂时无法显示","Usage statistics is temporarily unavailable")),n.createElement("div",{className:"uh-boundary-note"},d("当前范围加载失败,入口仍然可用。","The selected range failed to render; the sidebar entry is still available.")),n.createElement("div",{className:"uh-actions"},n.createElement("button",{type:"button",className:"uh-refresh",onClick:()=>l(e=>e+1)},n.createElement(C,{name:"refresh",size:14}),d("重试","Retry")),n.createElement("button",{type:"button",className:"uh-refresh",onClick:()=>a(!1)},n.createElement(C,{name:"close",size:14}),d("关闭","Close"))))},n.createElement(Mt,{timerCtx:e.timerCtx,language:o,onLanguageChange:e=>{const t="en"===e?"en":"zh";u(t),function(e){try{window.localStorage.setItem(yt,e),window.localStorage.setItem(xt,"1")}catch(e){}}(t)}})))):null;return n.createElement(n.Fragment,null,n.createElement("button",{type:"button",className:"uh-side-entry",title:d("用量统计","Usage Statistics"),"aria-label":d("用量统计","Usage Statistics"),onClick:()=>a(!0)},n.createElement("span",{className:"uh-side-entry-icon"},n.createElement(C,{name:"chart",size:17})),e.wide?n.createElement("span",{className:"uh-side-entry-label"},d("用量统计","Usage Statistics")):null),null===h||null===m?h:r.createPortal(h,m))}return a.inject=["timer","slots"],a.apply=e=>{const t=e.get("slots"),a=e.get("timer");void 0!==t&&void 0!==a&&(wt=e,t.inject("sidebar.footer.action",()=>t.register({name:"sidebar.footer.action",id:"all-usage",order:10},e=>n.createElement(At,{wide:e.wide,timerCtx:a}))))},t}});