PageSourceSearch

https://git-hub-new-api.hf.space/static/js/async/3478.72b62bdd11.js

js git-hub-new-api.hf.space collected 2026-10-03 16:54:04 UTC 89,266 bytes, 5 lines download raw bytes

1/*! LICENSE: 3478.72b62bdd11.js.LICENSE.txt */
2"use strict";(self.rspackChunknewapi_web=self.rspackChunknewapi_web||[]).push([[3478],{41593(e,t,a){a.d(t,{},{M:[{maxDomainLength:10,scheme:["#1664FF","#1AC6FF","#FF8A00","#3CC780","#7442D4","#FFC400","#304D77","#B48DEB","#009488","#FF7DDA"]},{scheme:["#1664FF","#B2CFFF","#1AC6FF","#94EFFF","#FF8A00","#FFCE7A","#3CC780","#B9EDCD","#7442D4","#DDC5FA","#FFC400","#FAE878","#304D77","#8B959E","#B48DEB","#EFE3FF","#009488","#59BAA8","#FF7DDA","#FFCFEE"]}]})},22593(e,t,a){var s=a(63228);async function n(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return(await s.FH.get(t?"/api/data":"/api/data/self",{params:e})).data}async function l(e){return(await s.FH.get("/api/data/users",{params:e})).data}async function r(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return(await s.FH.get(t?"/api/data/flow":"/api/data/flow/self",{params:e})).data}async function i(){return(await s.FH.get("/api/uptime/status")).data}a.d(t,{fh:()=>i,l0:()=>n,o8:()=>r,x9:()=>l})},35756(e,t,a){a.d(t,{},{J_:"data_export_default_time",R4:{start_timestamp:void 0,end_timestamp:void 0,time_granularity:"hour",username:""},Rc:[{value:"bar",labelKey:"Bar Chart"},{value:"area",labelKey:"Area Chart"}],W1:[{label:"Hour",value:"hour"},{label:"Day",value:"day"},{label:"Week",value:"week"}],Z9:[{value:"trend",labelKey:"Call Trend"},{value:"proportion",labelKey:"Call Count Distribution"},{value:"top",labelKey:"Call Count Ranking"}],dV:"dashboard_models_chart_preferences",f2:{consumptionDistributionChart:"bar",modelAnalyticsChart:"trend",defaultTimeRangeDays:1,defaultTimeGranularity:"hour"},jX:[{label:"1 Day",days:1},{label:"7 Days",days:7},{label:"14 Days",days:14},{label:"29 Days",days:29}],l0:{hour:1,day:7,week:30}})},25319(e,t,a){a.d(t,{w:()=>h,R:()=>p});var s=a(59832);let n=(0,a(40946).A)("coins",[["path",{d:"M13.744 17.736a6 6 0 1 1-7.48-7.48",key:"bq4yh3"}],["path",{d:"M15 6h1v4",key:"11y1tn"}],["path",{d:"m6.134 14.768.866-.5 2 3.464",key:"17snzx"}],["circle",{cx:"16",cy:"8",r:"6",key:"14bfc9"}]]);var l=a(58550),r=a(37417),i=a(8585),o=a(77565),d=a(90895),c=a(67519),u=a(89077),m=a(29427);function h(){let{t:e}=(0,u.Bd)();return[{key:"count",title:e("Total Count"),description:e("Statistical count"),icon:s.A,iconTone:"info",getValue:e=>e?.rpm??0},{key:"quota",title:e("Total Quota"),description:e("Statistical quota"),icon:n,iconTone:"success",getValue:e=>e?.quota??0},{key:"tokens",title:e("Total Tokens"),description:e("Statistical tokens"),icon:l.A,iconTone:"chart-4",getValue:e=>e?.tpm??0},{key:"avgRpm",title:e("Average RPM"),description:e("Requests per minute"),icon:r.A,iconTone:"chart-2",getValue:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return(0,m.Z)(e?.rpm??0,t)}},{key:"avgTpm",title:e("Average TPM"),description:e("Tokens per minute"),icon:i.A,iconTone:"warning",getValue:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return(0,m.Z)(e?.tpm??0,t)}}]}function p(e){let{t}=(0,u.Bd)();return[{key:"todayUsage",title:t("Last 24h usage"),value:e.todayUsageDisplay,description:e.currencyEnabled?`${t("Consumed in the last 24 hours")} (${e.currencyLabel})`:t("Consumed in the last 24 hours"),icon:o.A},{key:"usage",title:t("Historical Usage"),value:e.usedDisplay,description:e.currencyEnabled?`${t("Total consumed")} (${e.currencyLabel})`:t("Total consumed quota"),icon:d.A},{key:"requests",title:t("Request Count"),value:e.requestCountDisplay,description:t("Total requests made"),icon:c.A}]}},29427(e,t,a){a.d(t,{vR:()=>Q,pB:()=>m,Rc:()=>X,DK:()=>h,yG:()=>et,Hl:()=>r,$N:()=>Y,Cq:()=>J,JL:()=>u,UL:()=>D,_B:()=>ea,a2:()=>d,so:()=>i,Mg:()=>v,$I:()=>y,Z:()=>ee,g0:()=>c,U5:()=>o});var s=a(35756),n=a(80295);function l(e){return"hour"===e||"day"===e||"week"===e}function r(e){let t={};for(let[a,s]of Object.entries(e))if(null!=s){if("string"==typeof s){let e=s.trim();e&&(t[a]=e);continue}t[a]=s}return t}function i(e){return e||d().defaultTimeGranularity}function o(e){"u">typeof window&&(c({...d(),defaultTimeGranularity:e}),localStorage.setItem(s.J_,e))}function d(){if("u"<typeof window)return s.f2;let e={...s.f2,defaultTimeGranularity:function(){if("u"<typeof window)return"hour";let e=localStorage.getItem(s.J_);return l(e)?e:"hour"}()};try{var t,a,n;let r=localStorage.getItem(s.dV);if(!r)return e;let i=JSON.parse(r);return{consumptionDistributionChart:(t=i.consumptionDistributionChart,"bar"===t||"area"===t)?i.consumptionDistributionChart:e.consumptionDistributionChart,modelAnalyticsChart:(a=i.modelAnalyticsChart,"trend"===a||"proportion"===a||"top"===a)?i.modelAnalyticsChart:e.modelAnalyticsChart,defaultTimeRangeDays:(n=i.defaultTimeRangeDays,s.jX.some(e=>e.days===n))?i.defaultTimeRangeDays:e.defaultTimeRangeDays,defaultTimeGranularity:l(i.defaultTimeGranularity)?i.defaultTimeGranularity:e.defaultTimeGranularity}}catch{return e}}function c(e){"u">typeof window&&localStorage.setItem(s.dV,JSON.stringify(e))}function u(e){return e?s.l0[i(e)]:d().defaultTimeRangeDays}function m(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:d(),{start:t,end:a}=(0,n.fj)(e.defaultTimeRangeDays);return{...s.R4,start_timestamp:t,end_timestamp:a,time_granularity:e.defaultTimeGranularity}}
2function h(e,t){return{...e,default_time:i(t?.time_granularity),...t?.username&&{username:t.username}}}var p=a(41593),x=a(78373);function g(e){return(p.M.find(t=>!t.maxDomainLength||e<=t.maxDomainLength)??p.M[p.M.length-1]).scheme.filter(e=>"string"==typeof e)}function f(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4,{config:a,meta:s}=(0,x.cw)();if("tokens"===s.kind)return e.toLocaleString();let n=e/a.quotaPerUnit,l="exchangeRate"in s?s.exchangeRate:1,r="symbol"in s?s.symbol:"$",i=n*l,o=i.toFixed(t);return 0===parseFloat(o)&&e>0&&i>0?r+Math.pow(10,-t).toFixed(t):r+o}function v(e){let t,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"day",s=arguments.length>2?arguments[2]:void 0,l=arguments.length>3?arguments[3]:void 0,r=s??(e=>e),i=r("Other"),o=e=>Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(e),d=e=>f(e,4),c=e=>"Other"===e||e===i,u=e=>{let t=e?.collapseOverflow??!0;return e=>{let a=e.filter(e=>!c(e.key)),s=e.filter(e=>c(e.key));a.sort((e,t)=>(Number(t.value)||0)-(Number(e.value)||0)),e=[...a,...s];let n=0;for(let t=0;t<e.length;t++){let a=Number(e[t].value)||0;e[t].datum&&e[t].datum?.TimeSum&&(n=Number(e[t].datum?.TimeSum)||n),e[t].value=d(a)}return t&&e.length>15&&(e=[...a.slice(0,15),{key:i,value:d([...a.slice(15),...s].reduce((e,t)=>e+(t.datum&&Number(t.datum?.rawQuota)||0),0)),hasShape:!0,shapeType:"square",shapeFill:C,shapeStroke:C,shapeSize:8}]),e.unshift({key:r("Total:"),value:d(n)}),e}};if(!e||0===e.length)return{spec_pie:{type:"pie",data:[{id:"id0",values:[]}],outerRadius:.8,innerRadius:.5,padAngle:.6,valueField:"value",categoryField:"type",title:{visible:!0,text:r("Call Count Distribution"),subtext:r("No data available")},legends:{visible:!1},label:{visible:!1},tooltip:{mark:{content:[]}}},spec_line:{type:"bar",data:[{id:"barData",values:[]}],xField:"Time",yField:"Usage",seriesField:"Model",stack:!0,legends:{visible:!0,selectMode:"single"}},spec_area:{type:"area",data:[{id:"areaData",values:[]}],xField:"Time",yField:"Usage",seriesField:"Model",stack:!0,legends:{visible:!0,selectMode:"single"}},spec_model_line:{type:"area",data:[{id:"lineData",values:[]}],xField:"Time",yField:"Count",seriesField:"Model",legends:{visible:!0,selectMode:"single"},title:{visible:!0,text:r("Call Trend")}},spec_rank_bar:{type:"bar",data:[{id:"rankData",values:[]}],xField:"Model",yField:"Count",seriesField:"Model",legends:{visible:!0,selectMode:"single"},title:{visible:!0,text:r("Call Count Ranking")}},totalQuotaDisplay:f(0,2),totalCountDisplay:o(0)};let{config:m}=(0,x.cw)(),h=m.quotaPerUnit,p=new Map,v=new Map;e.forEach(e=>{let t=Number(e.created_at),s=(0,n.Hc)(t,a),l=e.model_name||"Unknown",r=Number(e.quota)||0,i=Number(e.count)||0,o=Number(e.token_used)||0;p.has(s)||p.set(s,new Map);let d=p.get(s),c=d.get(l)||{quota:0,count:0,tokens:0};d.set(l,{quota:c.quota+r,count:c.count+i,tokens:c.tokens+o});let u=v.get(l)||{quota:0,count:0,tokens:0};v.set(l,{quota:u.quota+r,count:u.count+i,tokens:u.tokens+o})});let b=Array.from(v.keys()),y=Array.from(p.keys()).sort(),j=[...b].sort(),k=Array.from(new Set([...j,i])),N=g(k.length),w=N[k.indexOf(i)],C="string"==typeof w?w:"#FF8A00",_={type:"ordinal",domain:k,range:N},A=(t=>{if(t.length>=7)return t;let s=Math.max(...e.map(e=>Number(e.created_at)||0)),l="week"===a?604800:"day"===a?86400:3600;return Array.from({length:7},(e,t)=>(0,n.Hc)(s-(6-t)*l,a))})(y),F=Array.from(v.values()).reduce((e,t)=>e+(Number(t.count)||0),0),M=Array.from(v.values()).reduce((e,t)=>e+(Number(t.quota)||0),0),q=Array.from(v.entries()).map(e=>{let[t,a]=e;return{type:t,value:Number(a.count)||0}}).sort((e,t)=>t.value-e.value),T=[];A.forEach(e=>{let t=j.map(t=>{let a=p.get(e)?.get(t),s=Number(a?.quota)||0,n=s?s/h:0;return{Time:e,Model:t,rawQuota:s,Usage:n?Number(n.toFixed(4)):0,TimeSum:0}}),a=t.reduce((e,t)=>e+t.rawQuota,0);t.sort((e,t)=>t.rawQuota-e.rawQuota),t=t.map(e=>({...e,TimeSum:a})),T.push(...t)}),T.sort((e,t)=>e.Time.localeCompare(t.Time));let S=new Set(Array.from(v.entries()).map(e=>{let[t,a]=e;return{Model:t,Quota:Number(a.quota)||0}}).sort((e,t)=>t.Quota-e.Quota).slice(0,15).map(e=>e.Model)),$=[];
2A.forEach(e=>{let t=new Map,a=p.get(e),s=0;for(let[n,l]of(j.forEach(e=>{let n=a?.get(e),l=Number(n?.quota)||0,r=l?l/h:0,o=r?Number(r.toFixed(4)):0;s+=l;let d=S.has(e)?e:i,c=t.get(d)||{rawQuota:0,usage:0};t.set(d,{rawQuota:c.rawQuota+l,usage:Number((c.usage+o).toFixed(4))})}),t))$.push({Time:e,Model:n,rawQuota:l.rawQuota,Usage:l.usage,TimeSum:s})}),$.sort((e,t)=>e.Time.localeCompare(t.Time));let z=Array.from(v.entries()).map(e=>{let[t,a]=e;return{Model:t,Count:Number(a.count)||0}}).sort((e,t)=>t.Count-e.Count),D=z.slice(0,20).map(e=>e.Model),R=z.slice(20).map(e=>e.Model),L=[];A.forEach(e=>{let t=D.map(t=>{let a=p.get(e)?.get(t);return{Time:e,Model:t,Count:Number(a?.count)||0}});if(R.length>0){let a=R.reduce((t,a)=>{let s=p.get(e)?.get(a);return t+(Number(s?.count)||0)},0);t.push({Time:e,Model:i,Count:a})}L.push(...t)}),L.sort((e,t)=>e.Time.localeCompare(t.Time));let K=Array.from(v.entries()).map(e=>{let[t,a]=e;return{Model:t,Count:Number(a.count)||0}}).sort((e,t)=>t.Count-e.Count);return t=K.length>20?[...K.slice(0,20),{Model:i,Count:K.slice(20).reduce((e,t)=>e+t.Count,0)}]:K,{spec_pie:{type:"pie",data:[{id:"id0",values:q}],outerRadius:.8,innerRadius:.5,padAngle:.6,valueField:"value",categoryField:"type",pie:{style:null==l?{}:{cornerRadius:l},state:{hover:{outerRadius:.85,stroke:"#000",lineWidth:1},selected:{outerRadius:.85,stroke:"#000",lineWidth:1}}},title:{visible:!0,text:r("Call Count Distribution")},legends:{visible:!0,orient:"left"},label:{visible:!0},color:_,tooltip:{mark:{content:[{key:e=>e?.type,value:e=>o(Number(e?.value)||0)}]}},background:{fill:"transparent"},animation:!0},spec_line:{type:"bar",data:[{id:"barData",values:T}],xField:"Time",yField:"Usage",seriesField:"Model",stack:!0,legends:{visible:!0,selectMode:"single"},color:_,bar:{state:{hover:{stroke:"#000",lineWidth:1}}},tooltip:{mark:{content:[{key:e=>e?.Model,value:e=>d(Number(e?.rawQuota)||0)}]},dimension:{content:[{key:e=>e?.Model,value:e=>Number(e?.rawQuota)||0}],updateContent:u()}},background:{fill:"transparent"},animation:!0},spec_area:{type:"area",data:[{id:"areaData",values:$}],xField:"Time",yField:"Usage",seriesField:"Model",stack:!1,legends:{visible:!0,selectMode:"single"},color:_,tooltip:{mark:{content:[{key:e=>e?.Model,value:e=>d(Number(e?.rawQuota)||0)}]},dimension:{content:[{key:e=>e?.Model,value:e=>Number(e?.rawQuota)||0}],updateContent:u({collapseOverflow:!1})}},area:{style:{fillOpacity:.08,curveType:"monotone"}},line:{style:{lineWidth:2,curveType:"monotone"}},point:{visible:!1},background:{fill:"transparent"},animation:!0},spec_model_line:{type:"area",data:[{id:"lineData",values:L}],xField:"Time",yField:"Count",seriesField:"Model",stack:!1,legends:{visible:!0,selectMode:"single"},color:_,title:{visible:!0,text:r("Call Trend")},tooltip:{mark:{content:[{key:e=>e?.Model,value:e=>o(Number(e?.Count)||0)}]},dimension:{content:[{key:e=>e?.Model,value:e=>Number(e?.Count)||0}],updateContent:e=>{let t=e.filter(e=>!c(e.key)),a=e.filter(e=>c(e.key));t.sort((e,t)=>(Number(t.value)||0)-(Number(e.value)||0)),e=[...t,...a];let s=0;for(let t=0;t<e.length;t++){let a=Number(e[t].value)||0;s+=a,e[t].value=o(a)}return e.unshift({key:r("Total:"),value:o(s)}),e}}},area:{style:{fillOpacity:.08,curveType:"monotone"}},line:{style:{lineWidth:2,curveType:"monotone"}},point:{visible:!1},background:{fill:"transparent"},animation:!0},spec_rank_bar:{type:"bar",data:[{id:"rankData",values:t}],xField:"Model",yField:"Count",seriesField:"Model",legends:{visible:!0,selectMode:"single"},color:_,title:{visible:!0,text:r("Call Count Ranking")},bar:{state:{hover:{stroke:"#000",lineWidth:1}}},tooltip:{mark:{content:[{key:e=>e?.Model,value:e=>o(Number(e?.Count)||0)}]}},background:{fill:"transparent"},animation:!0},totalQuotaDisplay:f(M,2),totalCountDisplay:o(F)}}let b=["#5B8FF9","#5AD8A6","#F6BD16","#E8684A","#6DC8EC","#9270CA","#FF9D4D","#269A99","#FF99C3","#5D7092"];function y(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"day",a=arguments.length>2?arguments[2]:void 0,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:10,l=a??(e=>e),{config:r}=(0,x.cw)(),i=r.quotaPerUnit,o=e=>f(e,2),d={spec_user_rank:{type:"bar",data:[{id:"userRankData",values:[]}],xField:"rawQuota",yField:"User",seriesField:"User",direction:"horizontal",title:{visible:!0,text:l("User Consumption Ranking"),subtext:l("No data available")},legends:{visible:!1},color:{type:"ordinal",range:b},background:{fill:"transparent"}},spec_user_trend:{type:"area",data:[{id:"userTrendData",values:[]}],xField:"Time",yField:"rawQuota",seriesField:"User",title:{visible:!0,text:l("User Consumption Trend"),subtext:l("No data available")},legends:{visible:!0,selectMode:"single"},color:{type:"ordinal",range:b},point:{visible:!1},background:{fill:"transparent"}}};if(!e||0===e.length)return d;let c=new Map;
2e.forEach(e=>{let t=e.username||"unknown",a=c.get(t)||0;c.set(t,a+(Number(e.quota)||0))});let u=Array.from(c.entries()).sort((e,t)=>t[1]-e[1]),m=u.slice(0,s).map(e=>{let[t]=e;return t}),h=new Set(m),p=u.slice(0,s).reduce((e,t)=>{let[,a]=t;return e+a},0),g=u.slice(0,s).map(e=>{let[t,a]=e;return{User:t,rawQuota:a,Usage:Number((a/i).toFixed(4))}}),v=m.reduce((e,t,a)=>(e[t]=b[a%b.length],e),{}),y=new Map,j=new Set;e.forEach(e=>{let a=Number(e.created_at),s=(0,n.Hc)(a,t);j.add(s);let l=e.username||"unknown";if(!h.has(l))return;y.has(s)||y.set(s,new Map);let r=y.get(s);r.set(l,(r.get(l)||0)+(Number(e.quota)||0))});let k=Array.from(j).sort(),N=[];return k.forEach(e=>{m.forEach(t=>{let a=y.get(e)?.get(t)||0;N.push({Time:e,User:t,rawQuota:a,Usage:Number((a/i).toFixed(4))})})}),{spec_user_rank:{type:"bar",data:[{id:"userRankData",values:g}],xField:"rawQuota",yField:"User",seriesField:"User",direction:"horizontal",title:{visible:!0,text:l("User Consumption Ranking"),subtext:`${l("Total:")} ${o(p)}`},legends:{visible:!1},bar:{state:{hover:{stroke:"#000",lineWidth:1}}},label:{visible:!0,position:"outside",formatMethod:e=>o(e),style:{fontSize:11}},axes:[{orient:"left",type:"band"},{orient:"bottom",type:"linear",visible:!1}],tooltip:{mark:{content:[{key:e=>e?.User,value:e=>o(Number(e?.rawQuota)||0)}],updateContent:e=>{for(let t=0;t<e.length;t++){let a=e[t].datum?.rawQuota,s=void 0===a?e[t].value:Number(a);e[t].value=o(Number(s)||0)}return e}}},color:{specified:v},background:{fill:"transparent"},animation:!0},spec_user_trend:{type:"area",data:[{id:"userTrendData",values:N}],xField:"Time",yField:"rawQuota",seriesField:"User",stack:!1,title:{visible:!0,text:l("User Consumption Trend"),subtext:`${l("Total:")} ${o(p)}`},legends:{visible:!0,selectMode:"single"},axes:[{orient:"bottom",type:"band"},{orient:"left",type:"linear",label:{formatMethod:e=>o(e)}}],tooltip:{mark:{content:[{key:e=>e?.User,value:e=>o(Number(e?.rawQuota)||0)}]},dimension:{content:[{key:e=>e?.User,value:e=>Number(e?.rawQuota)||0}],updateContent:e=>{e.sort((e,t)=>(Number(t.value)||0)-(Number(e.value)||0));let t=0;for(let a=0;a<e.length;a++){let s=Number(e[a].value)||0;t+=s,e[a].value=o(s)}return e.unshift({key:l("Total:"),value:o(t)}),e}}},area:{style:{fillOpacity:.15,curveType:"monotone"}},line:{style:{lineWidth:2,curveType:"monotone"}},point:{visible:!1},color:{specified:v},background:{fill:"transparent"},animation:!0}}}let j={},k={quota:"Quota",tokens:"Tokens",requests:"Requests",share:"Share"},N="#1664FF",w=new Set(["user","node","token","group","model","channel"]),C={user:"user:__other__",node:"node:__other__",token:"token:__other__",group:"group:__other__",model:"model:__other__",channel:"channel:__other__"},_={user:"Other users",node:"Other nodes",token:"Other tokens",group:"Other groups",model:"Other models",channel:"Other channels"},A=new Set(["user","node","token","group","channel"]),F=new Set(Object.values(C));function M(e){let t=Number(e);return Number.isFinite(t)?t:0}function q(e){return{quota:M(e.quota),tokens:M(e.token_used),requests:M(e.count)}}function T(e,t){return"requests"===t?e.requests:"tokens"===t?e.tokens:e.quota}function S(e){let t=M(e.user_id);return{id:t>0?`user:${t}`:`user:${e.username||"unknown"}`,label:e.username||(t>0?`user-${t}`:"Unknown User"),kind:"user"}}let $={user:S,node:function(e){let t=e.node_name||"default-node";return{id:`node:${t}`,label:t,kind:"node"}},token:function(e,t){var a,s;let n=M(e.token_id);return{id:n>0?`token:${n}`:`token:${e.token_name||"unknown"}`,label:e.token_name||(a=n,s=t,a<=0?"Unknown Token":s.deletedTokenLabel?.(a)??`token-${a}`),kind:"token"}},group:function(e){let t=e.use_group||"unknown";return{id:`group:${t}`,label:t,kind:"group"}},model:function(e){let t=e.model_name||"unknown";return{id:`model:${t}`,label:e.model_name||"Unknown Model",kind:"model"}},channel:function(e){let t=M(e.channel_id);return{id:t>0?`channel:${t}`:`channel:${e.channel_name||"unknown"}`,label:e.channel_name||(t>0?`channel-${t}`:"Unknown"),kind:"channel"}}},z={root:["user","node","token","group","model","channel"],admin:["user","group","model","channel"],user:["token","group","model"]};function D(e){return z[e]??z.user}function R(e,t){let a=D(e);if(!t)return a;let s=new Set(t),n=a.filter(e=>s.has(e));return n.length>=2?n:a}function L(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:j;return t.map(t=>$[t](e,a))}function K(e,t){let a=t&&t.length>0?t:g(e+1);return 0===a.length?N:a[e%a.length]??N}function U(e,t){let a=new Map,s=[...new Set(e)],n=function(e,t){if(t&&t.length>0)return t;let a=g(e);return a.length>0?a:[N]}(s.length,t);
2return s.forEach((e,t)=>{a.set(e,K(t,n))}),a}function E(e,t,a,s){let n=function(e,t){let a=new Set(t),s=new Map;for(let t of e??[]){if(!a.has(t.kind))continue;let e=s.get(t.kind)??new Set;e.add(t.id),s.set(t.kind,e)}return s}(t,a);return 0===n.size?e:e.filter(e=>(function(e,t){if(0===t.size)return!0;let a=new Map;for(let t of e){let e=a.get(t.kind)??new Set;e.add(t.id),a.set(t.kind,e)}for(let[e,s]of t){let t=a.get(e);if(!t)return!1;let n=!1;for(let e of s)if(t.has(e)){n=!0;break}if(!n)return!1}return!0})(L(e,a,s),n))}function I(e,t){return t.value-e.value||e.label.localeCompare(t.label)}function B(e){return`${e.source}\u0000${e.target}`}function O(e,t){return Number(e.dimmed)-Number(t.dimmed)||Number(t.highlighted)-Number(e.highlighted)||t.value-e.value||B(e).localeCompare(B(t))}function H(e,t){let a=t?.get(e.kind);return!a||a.has(e.id)}function P(e){return Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(e)}function Q(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"quota",a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=a.role??"user",n=a.colorPalette,l={deletedTokenLabel:a.deletedTokenLabel},r=R(s,a.visibleStages),i=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=new Set(t.selectedUsers??[]);return 0===a.size?e:e.filter(e=>a.has(S(e).id))}(e,a),o=E(i,a.selectedNodes,r,l);return{summary:o.reduce((e,t)=>{let a=q(t);return e.quota+=a.quota,e.tokens+=a.tokens,e.requests+=a.requests,e},{quota:0,tokens:0,requests:0}),flow:function(e,t,a,s,n){let l=arguments.length>5&&void 0!==arguments[5]?arguments[5]:j,r=arguments.length>6&&void 0!==arguments[6]?arguments[6]:{},i=R(a,n),o=function(e,t,a,s,n){if(!s)return;let l=new Map;for(let e of a)l.set(e,new Map);for(let s of e){let e=T(q(s),t);for(let t of L(s,a,n)){let a=l.get(t.kind);if(!a)continue;let s=a.get(t.id)??{node:t,value:0};s.value+=e,a.set(t.id,s)}}let r=new Map;for(let[e,t]of l){let a=[...t.values()].sort((e,t)=>t.value-e.value||e.node.label.localeCompare(t.node.label)||e.node.id.localeCompare(t.node.id)).slice(0,s).map(e=>e.node.id);r.set(e,new Set(a))}return r}(e,t,i,function(e){if(void 0===e)return;let t=Math.floor(e);return Number.isFinite(t)&&t>0?t:void 0}(r.topNodeLimit),l),d=r.overflowMode??"aggregate",c=[];for(let t of e){let e=function(e,t,a,s){return t&&e.some(e=>!H(e,t))?"hide"!==a?e.map(e=>{var a;return H(e,t)?e:(a=e.kind,{id:C[a],label:s?.(a)??_[a],kind:a})}):void 0:e}(L(t,i,l),o,d,r.otherNodeLabel);e&&c.push({path:e,metrics:q(t)})}let u=new Map,m=new Map,h=U(c.map(e=>e.path[0]?.id).filter(e=>!!e).sort((e,t)=>e.localeCompare(t)),s);for(let e of c){let{path:a,metrics:n}=e,l=a[0];if(!l)continue;let r=h.get(l.id)??K(0,s);for(let e of a)!function(e,t,a,s,n,l){let r=e.get(t.id)??{id:t.id,label:t.label,kind:t.kind,value:0,requests:0,quota:0,tokens:0,color:n,colorKey:l};r.value+=T(a,s),r.requests+=a.requests,r.quota+=a.quota,r.tokens+=a.tokens,e.set(t.id,r)}(u,e,n,t,r,l.id);for(let e=0;e<a.length-1;e++){let s=a[e],i=a[e+1];s&&i&&function(e,t,a,s,n,l,r){let i=`${t.id}\u0000${a.id}`,o=e.get(i)??{source:t.id,target:a.id,value:0,requests:0,quota:0,tokens:0,sourceLabel:t.label,targetLabel:a.label,color:l,linkColor:l,linkAlpha:1,hoverColor:l,colorKey:r,share:0};o.value+=T(s,n),o.requests+=s.requests,o.quota+=s.quota,o.tokens+=s.tokens,e.set(i,o)}(m,s,i,n,t,r,l.id)}}r.maskSensitive&&function(e,t){let a=new Map;for(let t of e.values()){var s;if(!A.has(t.kind)||F.has(t.id))continue;let e=0===(s=t.label).length?s:"••••";t.label=e,a.set(t.id,e)}if(0!==a.size)for(let e of t.values()){let t=a.get(e.source);void 0!==t&&(e.sourceLabel=t);let s=a.get(e.target);void 0!==s&&(e.targetLabel=s)}}(u,m),function(e,t,a){if(a){for(let t of e)t.highlighted=a.nodes.has(t.id),t.dimmed=!t.highlighted;for(let e of t){let t=a.links.has(B(e));e.highlighted=t,e.dimmed=!t}}}(u.values(),m.values(),function(e,t,a,s){if(!(t&&s.includes(t.kind))&&!a)return;let n=e=>{if(a){for(let t=0;t<e.length-1;t++)if(e[t]?.id===a.source&&e[t+1]?.id===a.target)return!0;return!1}return!!t&&e.some(e=>e.kind===t.kind&&e.id===t.id)},l=new Set,r=new Set;for(let t of e){let{path:e}=t;if(n(e)){for(let t of e)l.add(t.id);for(let t=0;t<e.length-1;t++){let a=e[t],s=e[t+1];a&&s&&r.add(`${a.id}\u0000${s.id}`)}}}if(0!==l.size)return{nodes:l,links:r}}(c,r.activeNode,r.activeLink,i));let p=[...m.values()].sort((e,t)=>
2e.source.localeCompare(t.source)||e.target.localeCompare(t.target)),x=new Set(c.map(e=>e.path[0]?.id).filter(e=>!!e)),g=p.filter(e=>x.has(e.source)).reduce((e,t)=>e+t.value,0);for(let e of p)e.share=g>0?e.value/g:0;let f=new Map;for(let e of p){let t=f.get(e.source)??[];t.push(e),f.set(e.source,t)}for(let e of f.values()){let t=[...e].sort((e,t)=>t.value-e.value||B(e).localeCompare(B(t))),a=Math.max(t.length-1,1);t.forEach((e,s)=>{let n=1===t.length?.34:.24+s/a*.2,l=function(e,t){let a=e.trim(),s=a.startsWith("#")?a.slice(1):a;if(!/^[0-9a-f]{6}$/i.test(s))return{color:a,alpha:t};let n=Number.parseInt(s,16);return{color:`rgba(${n>>16&255}, ${n>>8&255}, ${255&n}, ${t.toFixed(2)})`,alpha:1}}(e.color,n);e.linkColor=l.color,e.linkAlpha=l.alpha,e.hoverColor=e.color})}return{nodes:[...u.values()].sort(I),links:p}}(o,t,s,n,a.visibleStages,l,{topNodeLimit:a.topNodeLimit,overflowMode:a.overflowMode,otherNodeLabel:a.otherNodeLabel,activeNode:a.activeNode,activeLink:a.activeLink,maskSensitive:a.maskSensitive}),filterOptions:{users:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"quota",a=arguments.length>2?arguments[2]:void 0,s=new Map,n=U(e.map(e=>S(e).id).sort((e,t)=>e.localeCompare(t)),a);for(let l of e){let e=S(l);if(!l.user_id&&!l.username)continue;let r=T(q(l),t),i=s.get(e.id)??{label:e.label,value:0,color:n.get(e.id)??K(0,a)};i.value+=r,s.set(e.id,i)}return[...s.entries()].map(e=>{let[t,a]=e;return{value:t,label:a.label,valueLabel:P(a.value),valueRaw:a.value,color:a.color}}).sort((e,t)=>t.valueRaw-e.valueRaw||e.label.localeCompare(t.label))}(e,t,n),nodes:function(e,t,a,s,n,l,r){let i=R(a,s),o=new Map(i.map((e,t)=>[e,t])),d=new Set;for(let t of e)for(let e of L(t,i,l))d.add(e.id);let c=U([...d].sort((e,t)=>e.localeCompare(t)),n),u=[];for(let a of i){let s=new Map;for(let n of E(e,function(e,t){let a=(e??[]).filter(e=>e.kind!==t);return a.length>0?a:void 0}(r,a),i,l)){var m;let e=T(q(n),t),r=$[a](n,l),i=(m={kind:r.kind,id:r.id},`${m.kind}\u0000${m.id}`),o=s.get(i)??{node:r,value:0};o.value+=e,s.set(i,o)}for(let e of s.values())u.push({kind:e.node.kind,value:e.node.id,label:e.node.label,valueLabel:P(e.value),valueRaw:e.value,color:c.get(e.node.id)??K(0,n)})}return u.sort((e,t)=>(o.get(e.kind)??0)-(o.get(t.kind)??0)||t.valueRaw-e.valueRaw||e.label.localeCompare(t.label)||e.value.localeCompare(t.value))}(i,t,s,a.visibleStages,n,l,a.selectedNodes)}}}function W(e){return e&&"object"==typeof e?e:void 0}function V(e,t){let a;return void 0!==e[t]?e[t]:(Array.isArray(a=e.datum)?W(a[M(e.depth)])??W(a[0])??e:W(a)??e)[t]}function G(e,t){return!0===V(e,t)}function J(e,t){let a=W(e);return a?V(a,t):void 0}function Z(e){return void 0!==V(e,"source")&&void 0!==V(e,"target")}function Y(e){var t;let a=W(e);if(!a||Z(a))return;let s=J(a,"key"),n=J(a,"kind");if(("string"==typeof s||"number"==typeof s)&&"string"==typeof(t=n)&&w.has(t))return{kind:n,id:String(s)}}function X(e,t){let a,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:P,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:k;return{type:"sankey",data:[{id:"flow",values:[{nodes:e.nodes.map(e=>({key:e.id,name:e.label,rawLabel:e.label,kind:e.kind,value:e.value,requests:e.requests,quota:e.quota,tokens:e.tokens,color:e.color,colorKey:e.colorKey,highlighted:e.highlighted,dimmed:e.dimmed})),links:e.links.filter(e=>e.value>0).sort(O).map((e,t)=>{let a=1e5+t;return e.highlighted?a=1e6+t:e.dimmed&&(a=t),{source:e.source,target:e.target,linkKey:B(e),sourceLabel:e.sourceLabel,targetLabel:e.targetLabel,value:e.value,requests:e.requests,quota:e.quota,tokens:e.tokens,color:e.color,linkColor:e.linkColor,linkAlpha:e.linkAlpha,hoverColor:e.hoverColor,colorKey:e.colorKey,share:e.share,highlighted:e.highlighted,dimmed:e.dimmed,zIndex:a}})}]}],categoryField:"name",sourceField:"source",targetField:"target",valueField:"value",nodeKey:"key",direction:"horizontal",nodeAlign:"justify",crossNodeAlign:"middle",linkSortBy:(e,t)=>M(t.value)-M(e.value)||`${e.source??""}\u0000${e.target??""}`.localeCompare(`${t.source??""}\u0000${t.target??""}`)||M(e.index)-M(t.index),nodeGap:14,nodeWidth:16,minLinkHeight:2,minNodeHeight:8,title:{visible:!1,text:t},legends:{visible:!1},label:{visible:!0,position:"outside",limit:220,interactive:!1,style:{fill:"#475569",fontSize:11,fontWeight:600}},node:{interactive:!0,style:{fill:e=>String(V(e,"color")??K(0)),fillOpacity:e=>G(e,"dimmed")?.18:G(e,"highlighted")?1:.92,stroke:e=>
2G(e,"highlighted")?"rgba(15, 23, 42, 0.74)":"rgba(148, 163, 184, 0.45)",lineWidth:e=>G(e,"highlighted")?1.5:1,cursor:"pointer",pickMode:"accurate"},state:{hover:{fillOpacity:1,stroke:"rgba(15, 23, 42, 0.68)",lineWidth:1.5},selected:{fillOpacity:1,stroke:"rgba(15, 23, 42, 0.68)",lineWidth:1.5},blur:{fillOpacity:.22}}},link:{interactive:!0,style:{fill:e=>String(V(e,"linkColor")??V(e,"color")??K(0)),fillOpacity:e=>G(e,"dimmed")?.08:G(e,"highlighted")?.86:M(V(e,"linkAlpha"))||1,cursor:"pointer",pickMode:"accurate",boundsMode:"accurate",zIndex:e=>{let t=V(e,"zIndex");return void 0!==t?M(t):1e9-M(V(e,"value"))}},state:{hover:{fill:e=>String(V(e,"hoverColor")??V(e,"color")??K(0)),fillOpacity:.9},selected:{fill:e=>String(V(e,"hoverColor")??V(e,"color")??K(0)),fillOpacity:.9},blur:{fillOpacity:.22}}},emphasis:{enable:!1},tooltip:{trigger:"hover",activeType:"mark",dimension:{visible:!1},group:{visible:!1},mark:{checkOverlap:!0,positionMode:"pointer",visible:e=>Z(e)||void 0!==V(e,"key"),title:{value:e=>{let t=V(e,"source"),a=V(e,"target");if(t&&a){let s=V(e,"sourceLabel"),n=V(e,"targetLabel");return`${s??t} -> ${n??a}`}return`${V(e,"name")??V(e,"rawLabel")??""}`}},content:(a=(e,t)=>P(M(V(e,t))),[{key:n.quota,value:e=>s(M(V(e,"quota")))},{key:n.tokens,value:e=>a(e,"tokens")},{key:n.requests,value:e=>a(e,"requests")},{key:n.share,value:e=>`${(100*M(V(e,"share"))).toFixed(1)}%`,visible:e=>M(V(e,"share"))>0}])}},background:{fill:"transparent"},animation:!1}}function ee(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3,s=e/t;if(isNaN(s)||!isFinite(s))return 0;let n=Math.pow(10,a);return Math.round(s*n)/n}function et(e){return e.reduce((e,t)=>({totalQuota:e.totalQuota+(Number(t.quota)||0),totalCount:e.totalCount+(Number(t.count)||0),totalTokens:e.totalTokens+(Number(t.token_used)||0)}),{totalQuota:0,totalCount:0,totalTokens:0})}function ea(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:60;if(!e)return"";let a=e.replace(/<[^>]*>/g,"").replace(/[#*_]/g,"").trim();return a.length>t?a.substring(0,t)+"...":a}},10879(e,t,a){var s=a(63228);async function n(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:24;return(await s.FH.get("/api/perf-metrics/summary",{params:{hours:e}})).data}async function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:24;return(await s.FH.get("/api/perf-metrics",{params:{model:e,hours:t}})).data}a.d(t,{J:()=>l,R:()=>n})},79072(e,t,a){function s(e){return!Number.isFinite(e)||e<=0?"—":e>=1e3?`${(e/1e3).toFixed(1)}K t/s`:`${e.toFixed(e<10?2:1)} t/s`}function n(e){return!Number.isFinite(e)||e<=0?"—":e>=1e3?`${(e/1e3).toFixed(2)}s`:`${Math.round(e)}ms`}function l(e){return Number.isFinite(e)?`${e.toFixed(2)}%`:"—"}function r(e){return Number.isFinite(e)?e>=100?"excellent":e>=90?"good":e>=70?"warning":"critical":"unknown"}let i={excellent:"text-emerald-600 dark:text-emerald-400",good:"text-emerald-500 dark:text-emerald-300",warning:"text-amber-600 dark:text-amber-400",critical:"text-red-600 dark:text-red-400",unknown:"text-muted-foreground"},o={excellent:"bg-emerald-500",good:"bg-emerald-400",warning:"bg-amber-500",critical:"bg-red-500",unknown:"bg-muted-foreground"},d={excellent:"#10b981",good:"#34d399",warning:"#f59e0b",critical:"#ef4444",unknown:"#9ca3af"};function c(e){return i[r(e)]}function u(e){return o[r(e)]}function m(e){return d[r(e)]}a.d(t,{Fm:()=>l,NA:()=>c,NY:()=>u,Y5:()=>s,YL:()=>n,tN:()=>m})},11653(e,t,a){a.r(t),a.d(t,{component:()=>tj});var s=a(79015),n=a(28585),l=a(72473),r=a(71451),i=a(6487),o=a(65311),d=a(89077),c=a(51571),u=a(71304),m=a(73178),h=a(93539),p=a(60106),x=a(52909),g=a(48041),f=a(47801),v=a(65965),b=a(53286),y=a(88743),j=a(31155),k=a(62978),N=a(50010),w=a(35756);function C(e){let{t}=(0,d.Bd)(),[a,n]=(0,o.useState)(!1),[l,r]=(0,o.useState)(e.preferences);return(0,s.jsxs)(j.l,{open:a,onOpenChange:t=>{t&&r(e.preferences),n(t)},trigger:(0,s.jsxs)(m.$,{variant:"outline",size:"sm",children:[(0,s.jsx)(b.A,{className:"mr-2 h-4 w-4"}),t("Preferences")]}),title:t("Model Analytics Defaults"),description:t("Set default ranges and charts for model analytics."),contentClassName:"sm:max-w-md",contentHeight:"auto",bodyClassName:"grid gap-3",footer:(0,s.jsxs)(m.$,{onClick:()=>{e.onPreferencesChange(l),n(!1)},type:"button",children:[(0,s.jsx)(y.A,{className:"mr-2 h-4 w-4"}),t("Save Preferences")]}),children:[(0,s.jsxs)("div",{className:"grid gap-1.5",children:[(0,s.jsx)(k.J,{htmlFor:"default-time-range",children:t("Default range")}),(0,s.jsxs)(N.l6,{items:[...w.jX.map(e=>({value:String(e.days),label:t(e.label)}))],value:String(l.defaultTimeRangeDays),onValueChange:e=>r(t=>({...t,defaultTimeRangeDays:Number(e)})),children:[(0,s.jsx)(N.bq,{id:"default-time-range",children:(0,s.jsx)(N.yv,{placeholder:t("Select default range")})}),(0,s.jsx)(N.gC,{alignItemWithTrigger:!1,children:(0,s.jsx)(N.s3,{children:w.jX.map(e=>(0,s.jsx)(N.eb,{value:String(e.days),children:t(e.label)},e.days))})})]})]}),(0,s.jsxs)("div",{className:"grid gap-1.5",children:[(0,s.jsx)(k.J,{htmlFor:"default-time-granularity",children:t("Default time granularity")}),(0,s.jsxs)(N.l6,{items:[...w.W1.map(e=>({value:e.value,label:t(e.label)}))],value:l.defaultTimeGranularity,onValueChange:e=>r(t=>({...t,defaultTimeGranularity:e})),children:[(0,s.jsx)(N.bq,{id:"default-time-granularity",children:(0,s.jsx)(N.yv,{placeholder:t("Select time granularity")})}),(0,s.jsx)(N.gC,{alignItemWithTrigger:!1,children:(0,s.jsx)(N.s3,{children:w.W1.map(e=>(0,s.jsx)(N.eb,{value:e.value,children:t(e.label)},e.value))})})]})]}),(0,s.jsxs)("div",{className:"grid gap-1.5",children:[(0,s.jsx)(k.J,{htmlFor:"consumption-distribution-chart",children:t("Default consumption chart")}),(0,s.jsxs)(N.l6,{items:[...w.Rc.map(e=>({value:e.value,label:t(e.labelKey)}))],value:l.consumptionDistributionChart,onValueChange:e=>r(t=>({...t,consumptionDistributionChart:e})),children:[(0,s.jsx)(N.bq,{id:"consumption-distribution-chart",children:(0,s.jsx)(N.yv,{placeholder:t("Select default chart")})}),(0,s.jsx)(N.gC,{alignItemWithTrigger:!1,children:(0,s.jsx)(N.s3,{children:w.Rc.map(e=>(0,s.jsx)(N.eb,{value:e.value,children:t(e.labelKey)},e.value))})})]})]}),(0,s.jsxs)("div",{className:"grid gap-1.5",children:[(0,s.jsx)(k.J,{htmlFor:"model-analytics-chart",children:t("Default model call chart")}),(0,s.jsxs)(N.l6,{items:[...w.Z9.map(e=>({value:e.value,label:t(e.labelKey)}))],value:l.modelAnalyticsChart,onValueChange:e=>r(t=>({...t,modelAnalyticsChart:e})),children:[(0,s.jsx)(N.bq,{id:"model-analytics-chart",children:(0,s.jsx)(N.yv,{placeholder:t("Select default chart")})}),(0,s.jsx)(N.gC,{alignItemWithTrigger:!1,children:(0,s.jsx)(N.s3,{children:w.Z9.map(e=>(0,s.jsx)(N.eb,{value:e.value,children:t(e.labelKey)},e.value))})})]})]})]})}var _=a(99348),A=a(62711),F=a(50460),M=a(40946);let q=(0,M.A)("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);var T=a(77296),S=a(62724),$=a(68603),z=a(29427),D=a(80295);function R(e){let t=e?.start_timestamp,a=e?.end_timestamp;if(!t||!a)return null;let s=Math.round((a.getTime()-t.getTime())/864e5);return w.jX.some(e=>e.days===s)?s:null}let L=e=>{let{label:t}=e;return(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("div",{className:"absolute inset-0 flex items-center",children:(0,s.jsx)("span",{className:"w-full border-t"})}),(0,s.jsx)("div",{className:"relative flex justify-center text-xs uppercase",children:(0,s.jsx)("span",{className:"bg-background text-muted-foreground px-2",children:t})})]})};function K(e){let{t}=(0,d.Bd)(),a=(0,v.n)(e=>e.auth.user),n=a?.role&&a.role>=10,[l,r]=(0,o.useState)(!1),[i,c]=(0,o.useState)(()=>e.currentFilters??(0,z.pB)(e.preferences)),[u,h]=(0,o.useState)(()=>R(e.currentFilters)),p=(e,t)=>{c(a=>({...a,[e]:t})),("start_timestamp"===e||"end_timestamp"===e)&&h(null)};return(0,s.jsx)(j.l,{open:l,onOpenChange:t=>{if(t){let t=e.currentFilters??(0,z.pB)(e.preferences);c(t),h(R(t))}r(t)},trigger:(0,s.jsxs)(m.$,{variant:"outline",size:"sm",children:[(0,s.jsx)(_.A,{className:"mr-2 h-4 w-4"}),t("Filter")]}),title:t(e.titleKey??"Model Analytics Filters"),description:t(e.descriptionKey??"Filter the model analytics view by time range and user."),contentClassName:"max-sm:h-dvh max-sm:w-screen max-sm:max-w-none max-sm:rounded-none max-sm:p-4 sm:max-w-lg",contentHeight:"min(48vh, 460px)",footerClassName:"grid grid-cols-2 gap-2 sm:flex",footer
2:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(m.$,{onClick:()=>{let t=e.preferences.defaultTimeRangeDays,{start:a,end:s}=(0,D.fj)(t);c({...(0,z.pB)(e.preferences),start_timestamp:a,end_timestamp:s}),h(t),e.onReset(),r(!1)},variant:"outline",type:"button",children:[(0,s.jsx)(A.A,{className:"mr-2 h-4 w-4"}),t("Reset")]}),(0,s.jsxs)(m.$,{onClick:()=>{e.onFilterChange((0,z.Hl)(i)),r(!1)},type:"submit",children:[(0,s.jsx)(F.A,{className:"mr-2 h-4 w-4"}),t("Apply Filters")]})]}),children:(0,s.jsx)($.F,{className:"h-full pr-3 sm:pr-4",children:(0,s.jsxs)("div",{className:"grid gap-2.5 py-2",children:[(0,s.jsxs)("div",{className:"grid gap-2",children:[(0,s.jsxs)(k.J,{className:"flex items-center gap-2",children:[(0,s.jsx)(q,{className:"h-4 w-4"}),t("Quick Range")]}),(0,s.jsx)("div",{className:"grid grid-cols-2 gap-2 sm:flex",children:w.jX.map(e=>(0,s.jsx)(m.$,{type:"button",size:"sm",variant:u===e.days?"default":"outline",onClick:()=>(e=>{let{start:t,end:a}=(0,D.fj)(e);c(s=>({...s,start_timestamp:t,end_timestamp:a,time_granularity:e<=1?"hour":e>=29?"week":"day"})),h(e)})(e.days),className:(0,f.cn)("flex-1",u===e.days&&"ring-ring ring-2 ring-offset-2"),children:t(e.label)},e.days))})]}),(0,s.jsx)(L,{label:t("Custom Time Range")}),(0,s.jsxs)("div",{className:"grid gap-2.5",children:[(0,s.jsxs)("div",{className:"grid gap-2",children:[(0,s.jsx)(k.J,{htmlFor:"start_timestamp",children:t("Start Time")}),(0,s.jsx)(T.K,{value:i.start_timestamp,onChange:e=>p("start_timestamp",e||void 0),placeholder:t("Select start time")})]}),(0,s.jsxs)("div",{className:"grid gap-2",children:[(0,s.jsx)(k.J,{htmlFor:"end_timestamp",children:t("End Time")}),(0,s.jsx)(T.K,{value:i.end_timestamp,onChange:e=>p("end_timestamp",e||void 0),placeholder:t("Select end time")})]})]}),(0,s.jsx)(L,{label:t("Chart Settings")}),(0,s.jsxs)("div",{className:"grid gap-2",children:[(0,s.jsx)(k.J,{htmlFor:"time_granularity",children:t("Time Granularity")}),(0,s.jsxs)(N.l6,{items:[...w.W1.map(e=>({value:e.value,label:t(e.label)}))],value:i.time_granularity,onValueChange:e=>p("time_granularity",e),children:[(0,s.jsx)(N.bq,{children:(0,s.jsx)(N.yv,{placeholder:t("Select time granularity")})}),(0,s.jsx)(N.gC,{alignItemWithTrigger:!1,children:(0,s.jsx)(N.s3,{children:w.W1.map(e=>(0,s.jsx)(N.eb,{value:e.value,children:t(e.label)},e.value))})})]})]}),n&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(L,{label:t("Admin Only")}),(0,s.jsxs)("div",{className:"grid gap-2",children:[(0,s.jsx)(k.J,{htmlFor:"username",children:t("Username")}),(0,s.jsx)(S.p,{id:"username",placeholder:t("Filter by username"),value:i.username,onChange:e=>p("username",e.target.value)})]})]})]})})})}var U=a(43866),E=a(30661),I=a(70556),B=a(65316),O=a(9278);let H=(0,M.A)("square-terminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]);var P=a(70367),Q=a(68758),W=a(10854);let V=(0,M.A)("radio-tower",[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]]);var G=a(14398),J=a(68328),Z=a(26464),Y=a(32115),X=a(58026),ee=a(13093),et=a(53926),ea=a(34883),es=a(84500),en=a(26028),el=a(98847),er=a(27759),ei=a(95871),eo=a(63228),ed=a(80428),ec=a(43303);function eu(e,t){let{status:a,loading:s}=(0,ec.s)();return{items:!!a&&!1!==a[e]&&a?.[t]||[],loading:s}}function em(){return eu("api_info_enabled","api_info")}var eh=a(71042),ep=a(49646);function ex(e){let t=(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("div",{className:"text-sm font-semibold",children:e.title}),null!=e.description&&(0,s.jsx)("div",{className:"text-muted-foreground text-xs",children:e.description})]});return(0,s.jsx)("div",{className:"border-b px-4 py-3 sm:px-5",children:null!=e.actions?(0,s.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[t,e.actions]}):t})}function eg(e){let{t}
2=(0,d.Bd)(),a=e.emptyMessage??t("No data available"),n=e.height??"h-64",l=(0,f.cn)("overflow-hidden rounded-2xl border bg-card shadow-xs",e.className);return e.loading?(0,s.jsxs)("div",{className:l,children:[(0,s.jsx)(ex,{title:e.title,description:e.description}),(0,s.jsx)("div",{className:(0,f.cn)("p-4 sm:p-5",e.contentClassName),children:(0,s.jsx)(h.E,{className:`w-full ${n}`})})]}):e.empty?(0,s.jsxs)("div",{className:l,children:[(0,s.jsx)(ex,{title:e.title,description:e.description}),(0,s.jsx)("div",{className:(0,f.cn)("text-muted-foreground flex items-center justify-center px-4 text-sm",n,e.contentClassName),children:a})]}):(0,s.jsxs)("div",{className:l,children:[(0,s.jsx)(ex,{title:e.title,description:e.description,actions:e.headerActions}),(0,s.jsx)("div",{className:(0,f.cn)("p-4 sm:p-5",e.contentClassName),children:e.children})]})}var ef=a(93375);function ev(e){let{open:t,onOpenChange:a,announcement:n}=e,{t:l}=(0,d.Bd)();return(0,s.jsx)(j.l,{open:t,onOpenChange:a,title:l("Announcement Details"),description:n?.publishDate?`${l("Published:")} ${(0,D.Ah)(new Date(n.publishDate))}`:void 0,contentClassName:"sm:max-w-lg",contentHeight:"auto",bodyClassName:"space-y-4",children:(0,s.jsx)($.F,{className:"max-h-[min(58vh,520px)] pr-4",children:(0,s.jsxs)("div",{className:"space-y-4",children:[n?.content&&(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"mb-2 font-medium",children:l("Content")}),(0,s.jsx)(ef.K,{breaks:!0,content:n.content})]}),n?.extra&&(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"mb-2 font-medium",children:l("Additional Information")}),(0,s.jsx)(ef.K,{breaks:!0,content:n.extra,className:"text-muted-foreground"})]})]})})})}let eb=(0,o.memo)(function(e){return(0,s.jsx)("span",{className:(0,f.cn)("mt-1.5 inline-block size-2 shrink-0 rounded-full",(0,ep.zv)(e.type))})});function ey(){let{t:e}=(0,d.Bd)(),{items:t,loading:a}=eu("announcements_enabled","announcements"),[n,l]=(0,o.useState)(null),[r,i]=(0,o.useState)(!1);return(0,s.jsxs)(eg,{title:(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsx)(el.f,{tone:"warning",size:"sm",children:(0,s.jsx)(eh.A,{})}),e("Announcements")]}),description:e("Latest platform updates and notices"),loading:a,empty:!t.length,emptyMessage:e("No announcements at this time"),height:"h-72",contentClassName:"p-0",children:[(0,s.jsx)($.F,{className:"h-72",children:(0,s.jsx)("div",{children:t.map((a,n)=>{let r=a.id??`announcement-${n}`;return(0,s.jsx)("button",{type:"button",onClick:()=>{l(a),i(!0)},className:(0,f.cn)("group hover:bg-muted/40 w-full px-3 py-3 text-left transition-colors sm:px-5 sm:py-3.5",n<t.length-1&&"border-border/60 border-b"),children:(0,s.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,s.jsx)(eb,{type:a.type}),(0,s.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[(0,s.jsx)("p",{className:"line-clamp-1 text-sm font-medium",children:(0,z._B)(a.content)}),(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[a.publishDate&&(0,s.jsx)("time",{className:"text-muted-foreground/60 text-xs",children:(0,D.Ah)(new Date(a.publishDate))}),(0,s.jsx)("span",{className:"text-muted-foreground/40 text-xs opacity-0 transition-opacity group-hover:opacity-100",children:e("Click for details")})]})]})]})},r)})})}),(0,s.jsx)(ev,{open:r,onOpenChange:i,announcement:n})]})}var ej=a(49979);async function ek(e){try{let t=performance.now();await fetch(e,{method:"HEAD",mode:"no-cors",cache:"no-cache"});let a=performance.now();return{latency:Math.round(a-t),testing:!1,error:!1}}catch(e){return{latency:null,testing:!1,error:!0}}}var eN=a(8585),ew=a(37417),eC=a(5238),e_=a(20143),eA=a(32483);function eF(e){var t;let{t:a}=(0,d.Bd)(),n=e.item,l=e.status;return(0,s.jsxs)("div",{className:"group hover:bg-muted/40 flex items-center justify-between gap-2 px-3 py-2.5 transition-colors sm:gap-3 sm:px-5 sm:py-3",children:[(0,s.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-2 sm:gap-3",children:[(0,s.jsx)("span",{className:(0,f.cn)("inline-block size-2 shrink-0 rounded-full",(0,ep.Hl)(n.color))}),(0,s.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[(0,s.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,s.jsx)("span",{className:"font-mono text-sm font-semibold",children:n.route}
2),(0,s.jsx)("span",{className:"text-muted-foreground/60 hidden truncate text-xs md:inline",children:n.description})]}),(0,s.jsx)("span",{className:"text-muted-foreground/40 truncate font-mono text-xs",children:n.url})]})]}),(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,s.jsxs)("div",{className:"flex items-center",children:[l.testing&&(0,s.jsx)(eA.Wh,{label:a("Testing..."),variant:"warning",className:"animate-pulse",copyable:!1}),null!==l.latency&&!l.testing&&(0,s.jsx)(eA.Wh,{variant:"success",label:`${l.latency}${a("ms")}`,className:(0,f.cn)("font-mono font-medium",(t=l.latency)<200?"text-green-600 dark:text-green-400":t<500?"text-yellow-600 dark:text-yellow-400":"text-red-600 dark:text-red-400"),copyable:!1}),l.error&&(0,s.jsx)(eA.Wh,{label:a("N/A"),variant:"neutral",copyable:!1})]}),(0,s.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,s.jsx)(m.$,{variant:"ghost",size:"sm",onClick:()=>e.onTest(n.url),disabled:l.testing,className:"size-7 p-0",title:a("Test Latency"),children:(0,s.jsx)(eN.A,{className:(0,f.cn)("size-3.5",l.testing&&"animate-pulse")})}),(0,s.jsx)(m.$,{variant:"ghost",size:"sm",onClick:()=>{let e,t;return e=encodeURIComponent(n.url),t=`https://www.tcptest.cn/http/${e}`,void window.open(t,"_blank","noopener,noreferrer")},className:"hidden size-7 p-0 sm:inline-flex",title:a("External Speed Test"),children:(0,s.jsx)(ew.A,{className:"size-3.5"})}),(0,s.jsx)(e_.i,{value:n.url,variant:"ghost",size:"sm",className:"size-7 p-0",iconClassName:"size-3.5",tooltip:a("Copy URL"),"aria-label":a("Copy URL")}),(0,s.jsx)(m.$,{variant:"ghost",size:"sm",className:"hidden size-7 p-0 sm:inline-flex",title:a("Open in New Tab"),render:(0,s.jsx)("a",{href:n.url,target:"_blank",rel:"noreferrer"}),children:(0,s.jsx)(eC.A,{className:"size-3.5"})})]})]})]})}function eM(){let{t:e}=(0,d.Bd)(),{items:t,loading:a}=em(),[n,l]=(0,o.useState)({}),r=(0,o.useCallback)(async e=>{l(t=>({...t,[e]:{latency:null,testing:!0,error:!1}}));let t=await ek(e);l(a=>({...a,[e]:t}))},[]);return(0,s.jsx)(eg,{title:(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsx)(el.f,{tone:"info",size:"sm",children:(0,s.jsx)(ej.A,{})}),e("API Info")]}),description:e("Configured routes and latency checks"),loading:a,empty:!t.length,emptyMessage:e("No API routes configured"),height:"h-72",contentClassName:"p-0",children:(0,s.jsx)($.F,{className:"h-72",children:(0,s.jsx)("div",{children:t.map((e,a)=>(0,s.jsx)("div",{className:a<t.length-1?"border-border/60 border-b":"",children:(0,s.jsx)(eF,{item:e,status:n[e.url]||{latency:null,testing:!1,error:!1},onTest:r})},e.url))})})})}var eq=a(92265),eT=a(11314),eS=a(48121);function e$(){let{t:e}=(0,d.Bd)(),{items:t,loading:a}=eu("faq_enabled","faq");return(0,s.jsx)(eg,{title:(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsx)(el.f,{tone:"chart-4",size:"sm",children:(0,s.jsx)(eq.A,{})}),e("FAQ")]}),description:e("Answers for common access and billing questions"),loading:a,empty:!t.length,emptyMessage:e("No FAQ entries available"),height:"h-80",contentClassName:"p-0",children:(0,s.jsx)($.F,{className:"h-80",children:(0,s.jsx)(eT.nD,{className:"w-full px-4 sm:px-5",children:t.map((e,t)=>{let a=e.id??`faq-${t}`,n=`item-${a}`;return(0,s.jsxs)(eT.As,{value:n,className:"border-border/60",children:[(0,s.jsx)(eT.$m,{className:"text-start hover:no-underline",children:(0,s.jsx)(eS.o,{className:"text-sm leading-relaxed font-semibold",children:e.question})}),(0,s.jsx)(eT.ub,{children:(0,s.jsx)(eS.o,{className:"text-muted-foreground/60 text-sm",children:e.answer})})]},a)})})})})}var ez=a(85052),eD=a(10879),eR=a(79072);function eL(e,t,a){let s=0,n=0;for(let l of e){let e=Number(l[t]);a(e)&&(s+=e,n++)}return n>0?s/n:NaN}function eK(){let{t:e}=(0,d.Bd)(),t=(0,U.I)({queryKey:["perf-metrics-summary",24],queryFn:()=>(0,eD.R)(24),staleTime:6e4,retry:!1}),a=(0,o.useMemo)(()=>t.data?.data.models??[],[t.data]),n=(0,o.useMemo)(()=>({avgLatencyMs:Math.round(eL(a,"avg_latency_ms",e=>Number.isFinite(e)&&e>0)),avgTps:eL(a,"avg_tps",e=>Number.isFinite(e)&&e>0),successRate:eL(a,"success_rate",Number.isFinite)}),[a]),l=(0,o.useMemo)(()=>a.slice(0,6),[a]),r=t.isLoading,i=a.length>0;return(0,s.jsxs)("section",{className:"bg-card h-full overflow-hidden rounded-2xl border shadow-xs",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 border-b px-4 py-3 sm:px-5",children:[(0,s.jsx)(el.f,{tone:"success",size:"sm",children:(0,s.jsx)(ez.A,{})}),(0,s.jsx)("h3",{className:"text-sm font-semibold",children:e("Performance health")}),(0,s.jsx)("span",{className:"text-muted-foreground ml-auto text-xs",children:e("Performance metrics for the last 24 hours")})]}),(0,s.jsxs)("div",{className:"space-y-3 p-4 sm:p-5",children:[(0,s.jsxs)("div",{className:"grid grid-cols-3 gap-2",children:[(0,s.jsx)(eU,{icon:ez.A,label:e("Success rate"),value:(0,eR.Fm)(n.successRate),loading:r,valueClassName:(0,eR.NA)(n.successRate),tone:"success"}),(0,s.jsx)(eU,{icon:Y.A,label:e("Average latency"),value:(0,eR.YL)(n.avgLatencyMs),loading:r,tone:"warning"}),(0,s.jsx)(eU,{icon:ew.A,label:e("Throughput"),value:(0,eR.Y5)(n.avgTps),loading:r,tone:"info"})]}),r?(0,s.jsx)("div",{className:"space-y-1",children:["success","latency","throughput"].map(e=>(0,s.jsx)(h.E,{className:"h-5 w-full rounded"},e))}):i&&(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"text-muted-foreground mb-1 block text-[11px] font-medium",children:e("Top models by traffic")}),(0,s.jsx)("div",{className:"grid grid-cols-1 gap-x-4 sm:grid-cols-2",children:l.map(e=>(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded px-1.5 py-1",children:[(0,s.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-[11px]",children:e.model_name}),(0,s.jsxs)("span",{className:"inline-flex shrink-0 items-center gap-1",children:[(0,s.jsx)("span",{className:(0,f.cn)("size-1.5 rounded-full",(0,eR.NY)(e.success_rate)),"aria-hidden":"true"}),(0,s.jsx)("span",{className:(0,f.cn)("font-mono text-[11px] font-semibold tabular-nums",(0,eR.NA)(e.success_rate)),children:(0,eR.Fm)(e.success_rate)})]})]},e.model_name))})]})]})]})}function eU(e){let t=e.icon;return(0,s.jsxs)("div",{className:"bg-muted/40 rounded-xl px-3 py-2.5",children:[(0,s.jsxs)("div",{className:"text-muted-foreground flex items-center gap-1.5 text-[11px] font-medium",children:[(0,s.jsx)(el.f,{tone:e.tone,size:"xs",children:(0,s.jsx)(t,{})}),(0,s.jsx)("span",{className:"truncate",children:e.label})]}),e.loading?(0,s.jsx)(h.E,{className:"mt-1.5 h-5 w-16"}):(0,s.jsx)("div",{className:(0,f.cn)("mt-1.5 font-mono text-sm font-semibold tabular-nums",e.valueClassName),children:e.value})]})}var eE=a(77565),eI=a(28276),eB=a(22593),eO=a(25319),eH=a(78373),eP=a(77577);let eQ={"accent-1":"from-overview-accent-1/80 via-overview-accent-1/45 to-overview-accent-1/5 dark:from-overview-accent-1/70 dark:via-overview-accent-1/30","accent-2":"from-overview-accent-2/80 via-overview-accent-2/45 to-overview-accent-2/5 dark:from-overview-accent-2/70 dark:via-overview-accent-2/30","accent-3":"from-overview-accent-3/80 via-overview-accent-3/45 to-overview-accent-3/5 dark:from-overview-accent-3/70 dark:via-overview-accent-3/30"},eW={"accent-1":"text-overview-accent-1","accent-2":"text-overview-accent-2","accent-3":"text-overview-accent-3"},eV={"accent-1":"chart-1","accent-2":"chart-2","accent-3":"chart-3"},eG={default:"text-foreground",muted:"text-muted-foreground",success:"text-success",warning:"text-warning",destructive:"text-destructive"};function eJ(e){let t=(0,o.useId)(),a=`stat-card-line-${t.replaceAll(":","")}`,n=function(e){if(!e?.length)return null;let t=e.map(e=>Math.max(0,Number(e)||0)),a=Math.max(...t),s=Math.min(...t),n=a-s,l=t.map((e,l)=>{let r=1===t.length?80:l/(t.length-1)*160,i=0;return n>0?i=(e-s)/n:a>0&&(i=.5),{x:r,y:33-30*i}}),r=l.map((e,t)=>`${0===t?"M":"L"} ${e.x} ${e.y}`).join(" "),i=l.at(0),o=l.at(-1);return i&&o?{areaPath:`${r} L ${o.x} 36 L ${i.x} 36 Z`,linePath:r}:null}(e.values);return n?(0,s.jsx)("div",{className:(0,f.cn)("relative h-8 overflow-hidden rounded-lg",eW[e.tone]),"aria-hidden":"true",children:(0,s.jsxs)("svg",{viewBox:"0 0 160 36",preserveAspectRatio:"none",className:"size-full",children:[(0,s.jsx)("defs",{children:(0,s.jsxs)("linearGradient",{id:a,x1:"0",x2:"0",y1:"0",y2:"1",children:[(0,s.jsx)("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:"0.24"}),(0,s.jsx)("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:"0"})]})}),(0,s.jsx)("path",{d:n.areaPath,fill:`url(#${a})`}),(0,s.jsx)("path",{d:n.linePath,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2.25",vectorEffect:"non-scaling-stroke"})]})}):(0,s.jsx)("div",{className:"h-8","aria-hidden":"true"})}function eZ(e){let t=function(e){if(!e?.length)return[];let t=e.map(e=>Math.max(0,Number(e)||0)),a=Math.max(...t);return a<=0?t.map((e,t)=>({position:t,height:0})):t.map((e,t)=>({position:t,height:Math.max(8,e/a*100)}))}(e.values);return(0,s.jsx)("div",{className:"flex h-8 items-end gap-1","aria-hidden":"true",children:t.map(t=>(0,s.jsx)("span",{className:(0,f.cn)("flex-1 rounded-t-sm bg-linear-to-t",t.height<=0&&"opacity-20",eQ[e.tone]),style:{height:`${t.height}%`}},t.position))})}function eY(e){return(0,s.jsx)("div",{className:"grid grid-cols-2 gap-2",children:e.details.map(e=>(0,s.jsxs)("div",{className:"bg-muted/40 rounded-lg border border-transparent px-2.5 py-2",children:[(0,s.jsx)("div",{className:"text-muted-foreground truncate text-[11px] leading-none font-medium",children:e.label}),(0,s.jsx)("div",{className:(0,f.cn)("mt-1.5 truncate text-xs font-semibold tabular-nums",eG[e.tone??"default"]),title:e.value,children:e.value})]},e.label))})}function eX(e){let t,a,n=e.icon,l=e.tone??"accent-3",r=e.iconTone??eV[l],i=e.sparklineVariant??"bars";return t=e.loading?(0,s.jsxs)("div",{className:(0,f.cn)("flex flex-col",e.compactMobile?"gap-1":"gap-1.5"),children:[(0,s.jsx)(h.E,{className:"h-5 w-16 sm:h-7 sm:w-24"}),(0,s.jsx)(h.E,{className:(0,f.cn)("h-3 w-24 sm:h-3.5 sm:w-32",e.compactMobile&&"hidden sm:block")})]}):e.error?(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("div",{className:"text-muted-foreground mt-0.5 font-mono text-base font-bold tracking-tight break-all tabular-nums sm:text-2xl",children:"--"}
2),(0,s.jsx)("p",{className:(0,f.cn)("text-muted-foreground/60 line-clamp-1 text-[11px] sm:text-xs",e.compactMobile&&"hidden sm:block"),children:e.description})]}):(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("div",{className:"text-foreground font-mono text-base font-semibold tracking-tight break-all tabular-nums sm:text-2xl",children:e.value}),(0,s.jsx)("p",{className:(0,f.cn)("text-muted-foreground/60 line-clamp-1 text-[11px] leading-relaxed sm:text-xs",e.compactMobile&&"hidden sm:block"),children:e.description})]}),a=e.details?.length?(0,s.jsx)(eY,{details:e.details}):"line"===i?(0,s.jsx)(eJ,{values:e.sparkline,tone:l}):(0,s.jsx)(eZ,{values:e.sparkline,tone:l}),(0,s.jsxs)("div",{className:(0,f.cn)("group flex flex-col justify-between sm:min-h-32 sm:gap-3",e.compactMobile?"gap-1":"gap-1.5"),children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-1",children:[(0,s.jsxs)("div",{className:"text-muted-foreground flex items-center gap-1 text-[11px] font-medium sm:gap-2 sm:text-xs",children:[(0,s.jsx)(el.f,{tone:r,size:"stat",className:(0,f.cn)(e.compactMobile&&"size-4 rounded-sm [&>svg]:size-2.5 sm:size-7 sm:rounded-md sm:[&>svg]:size-3.5"),children:(0,s.jsx)(n,{})}),(0,s.jsx)("span",{className:"line-clamp-1 leading-snug sm:line-clamp-2",children:e.title})]}),e.action&&(0,s.jsx)("div",{className:"shrink-0",children:e.action})]}),t,(0,s.jsx)("div",{className:"hidden sm:block",children:a})]})}function e0(e,t){if(e<=0||t<=0)return null;let a=e/t;return Number.isFinite(a)?a:null}let e1={healthy:{dotClass:"bg-success",labelKey:"Healthy"},caution:{dotClass:"bg-warning",labelKey:"Low balance"},critical:{dotClass:"bg-destructive",labelKey:"Balance depleted"}};function e2(){let e,{t}=(0,d.Bd)(),a=(0,v.n)(e=>e.auth.user),{status:n,loading:l}=(0,ec.s)(),r=(0,o.useMemo)(()=>(0,D.GW)(1),[]),i=Number(a?.quota??0),c=Number(a?.used_quota??0),h=Number(a?.request_count??0),p=(0,U.I)({queryKey:["dashboard","overview","summary-sparklines",r.start_timestamp,r.end_timestamp],queryFn:async()=>(0,eB.l0)({start_timestamp:r.start_timestamp,end_timestamp:r.end_timestamp,default_time:"hour"}),staleTime:6e4}),x=(0,o.useMemo)(()=>({usedDisplay:(0,eP.eN)(c),requestCountDisplay:(0,eP.ZV)(h)}),[h,c]),g=(0,eH.zj)(),b="boolean"==typeof n?.display_in_currency?!!n.display_in_currency:void 0,y=void 0!==b?b:g,j=y?(0,eH.yz)():"Tokens",k=(0,o.useMemo)(()=>(function(e,t,a,s){let n=Array.from({length:12},()=>0),l=Array.from({length:12},()=>0);for(let t of e){var r;let e=(r=Number(t.created_at)||a,s<=a?0:Math.min(11,Math.max(0,Math.floor((r-a)/(s-a)*12))));n[e]+=Number(t.quota)||0,l[e]+=Number(t.count)||0}let i=t,o=Array.from({length:12},()=>0);for(let e=11;e>=0;e--)o[e]=Math.max(0,i),i+=n[e];return{balance:o,usage:n,requests:l}})(p.data?.data??[],i,r.start_timestamp,r.end_timestamp),[i,r.end_timestamp,r.start_timestamp,p.data?.data]),N=(0,o.useMemo)(()=>(p.data?.data??[]).reduce((e,t)=>e+(Number(t.quota)||0),0),[p.data?.data]),w=function(e,t){if(e<=0)return"critical";let a=e0(e,t);return null!==a&&a<3?"caution":"healthy"}(i,N),C=e1[w],_=e0(i,N),A=(0,eP.eN)(N);e=null!==_?_<1?t("Less than 1 day left"):_>999?`999+ ${t("days")}`:`~${(0,eP.ZV)(Math.floor(_))} ${t("days")}`:t(i<=0?"Balance depleted":"No recent usage");let F=(0,eO.R)({...x,todayUsageDisplay:A,currencyEnabled:y,currencyLabel:j}).map((e,t)=>{var a;return{key:e.key,title:e.title,value:e.value,desc:e.description,icon:e.icon,tone:["accent-1","accent-2","accent-3"][t]??"accent-3",sparkline:"todayUsage"===e.key?k.usage:(a=e.key,"usage"===a?k.usage:"requests"===a?k.requests:void 0),sparklineVariant:"line"}});return(0,s.jsx)("div",{className:"bg-card overflow-hidden rounded-2xl border shadow-xs",children:(0,s.jsxs)("div",{className:"grid xl:grid-cols-[minmax(0,1fr)_19rem]",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2.5 p-3 sm:gap-3 sm:p-5",children:[(0,s.jsx)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold sm:text-base",children:t("Usage at a glance")}),(0,s.jsx)("p",{className:"text-muted-foreground text-xs sm:text-sm",children:t("Monitor balance, usage, and request volume")})]})}),(0,s.jsx)(u.JX,{className:"grid grid-cols-3 gap-1.5 sm:gap-3",children:F.map(e=>(0,s.jsx)(u.Tc,{className:"bg-background/60 rounded-lg border px-2 py-1.5 sm:rounded-xl sm:p-3",children:(0,s.jsx)(eX,{title:e.title,value:e.value,description:e.desc,icon:e.icon,tone:e.tone,sparkline:e.sparkline,sparklineVariant:e.sparklineVariant,loading:l,compactMobile:!0})},e.key))})]}),(0,s.jsxs)("div",{className:"flex flex-col justify-between gap-3 border-t bg-[linear-gradient(135deg,color-mix(in_oklch,var(--overview-accent-2)_12%,var(--background))_0%,color-mix(in_oklch,oklch(0.82_0.04_155)_8%,var(--background))_48%,color-mix(in_oklch,var(--overview-accent-1)_7%,var(--background))_100%)] p-3 sm:gap-4 sm:p-5 xl:border-t-0 xl:border-l",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:gap-3",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-muted-foreground text-xs font-medium",children:t("Credit remaining")}),(0,s.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:(0,f.cn)("size-1.5 rounded-full",C.dotClass),"aria-hidden":"true"}),(0,s.jsx)("span",{className:"text-muted-foreground text-[11px] font-medium",children:t(C.labelKey)})]})]}),(0,s.jsx)("div",{className:"font-mono text-xl font-semibold tracking-tight sm:text-2xl",children:(0,eP.eN)(i)}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,s.jsxs)("div",{className:"bg-background/60 rounded-lg px-2.5 py-2",children:[(0,s.jsxs)("div",{className:"text-muted-foreground flex items-center gap-1 text-[11px] leading-none font-medium",children:[(0,s.jsx)(eE.A,{className:"size-3 shrink-0","aria-hidden":"true"}),(0,s.jsx)("span",{className:"truncate",children:t("Last 24h usage")})]}),(0,s.jsx)("div",{className:"text-foreground mt-1.5 truncate text-xs font-semibold tabular-nums",children:(0,eP.eN)(N)})]}),(0,s.jsxs)("div",{className:"bg-background/60 rounded-lg px-2.5 py-2",children:[(0,s.jsxs)("div",{className:"text-muted-foreground flex items-center gap-1 text-[11px] leading-none font-medium",children:[null!==_&&_<3?(0,s.jsx)(eI.A,{className:"size-3 shrink-0","aria-hidden":"true"}):(0,s.jsx)(Z.A,{className:"size-3 shrink-0","aria-hidden":"true"}),(0,s.jsx)("span",{className:"truncate",children:t("Runway")})]}),(0,s.jsx)("div",{className:(0,f.cn)("mt-1.5 truncate text-xs font-semibold tabular-nums","critical"===w&&"text-destructive","caution"===w&&"text-warning"),children:e})]})]})]}),(0,s.jsxs)(m.$,{className:"justify-between",render:(0,s.jsx)(E.N_,{to:"/wallet"}),children:[(0,s.jsx)("span",{children:t("Wallet")}
2),(0,s.jsx)(O.A,{"data-icon":"inline-end"})]})]})]})})}var e5=a(67519);let e4=(0,M.A)("rotate-cw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]),e3={1:"bg-emerald-500",0:"bg-red-500",2:"bg-amber-500",3:"bg-blue-500"},e6=(0,o.memo)(function(e){let t=e3[e.status]??"bg-muted-foreground/40";return(0,s.jsx)("span",{className:(0,f.cn)("inline-block size-2 rounded-full",t)})});function e8(){let{t:e}=(0,d.Bd)(),[t,a]=(0,o.useState)([]),[n,l]=(0,o.useState)(!0),[r,i]=(0,o.useState)(!1);return(0,o.useEffect)(()=>{let e=new AbortController;return(0,eB.fh)().then(t=>{e.signal.aborted||a(t?.data||[])}).catch(()=>{e.signal.aborted||a([])}).finally(()=>{e.signal.aborted||l(!1)}),()=>{e.abort()}},[]),(0,s.jsx)(eg,{title:(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsx)(el.f,{tone:"success",size:"sm",children:(0,s.jsx)(e5.A,{})}),e("Uptime")]}),description:e("Grouped monitor status from Uptime Kuma"),loading:n,empty:!t.length,emptyMessage:e("No uptime monitoring configured"),height:"h-80",contentClassName:"p-0",headerActions:(0,s.jsx)(m.$,{variant:"ghost",size:"sm",onClick:()=>{let e=new AbortController;i(!0),(0,eB.fh)().then(t=>{e.signal.aborted||a(t?.data||[])}).catch(()=>{e.signal.aborted||a([])}).finally(()=>{e.signal.aborted||i(!1)})},disabled:r,className:"size-7 p-0",children:(0,s.jsx)(e4,{className:(0,f.cn)("size-3.5",r&&"animate-spin"),"aria-label":e("Refresh")})}),children:(0,s.jsx)($.F,{className:"h-80",children:(0,s.jsx)("div",{children:t.map((e,a)=>(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"bg-muted/30 border-border/60 border-b px-3 py-2 sm:px-5",children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("h4",{className:"text-muted-foreground text-xs font-semibold tracking-wider uppercase",children:e.categoryName}),(0,s.jsx)("span",{className:"text-muted-foreground/40 font-mono text-xs tabular-nums",children:e.monitors?.length||0})]})}),e.monitors?.map((n,l)=>(0,s.jsxs)("div",{className:(0,f.cn)("hover:bg-muted/40 flex items-center justify-between gap-2 px-3 py-2 transition-colors sm:px-5 sm:py-2.5",l<(e.monitors?.length||0)-1&&"border-border/40 border-b",a<t.length-1&&l===(e.monitors?.length||0)-1&&"border-border/60 border-b"),children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-2.5",children:[(0,s.jsx)(e6,{status:n.status}),(0,s.jsx)("span",{className:"truncate text-sm",children:n.name}),n.group&&(0,s.jsxs)("span",{className:"text-muted-foreground/40 shrink-0 text-xs",children:["(",n.group,")"]})]}),(0,s.jsxs)("span",{className:"text-foreground shrink-0 font-mono text-sm font-semibold tabular-nums",children:[((n.uptime??0)*100).toFixed(2),"%"]})]},n.name))]},e.categoryName))})})})}let e7="dashboard_overview_setup_guide_expanded";function e9(e){return`curl ${e.endpoint} \\
3  -H "Content-Type: application/json" \\
4  -H "Authorization: Bearer ${e.apiKey}" \\
5  -d '{"model":"${e.model}","messages":[{"role":"user","content":"Say hello in one sentence."}]}'`}function te(e){return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:(0,f.cn)("pointer-events-none absolute inset-0 bg-[radial-gradient(ellipse_48%_120%_at_78%_0%,color-mix(in_oklch,var(--overview-accent-1)_14%,transparent)_0%,transparent_62%),linear-gradient(112deg,color-mix(in_oklch,var(--card)_94%,var(--overview-accent-2)_6%)_0%,color-mix(in_oklch,var(--card)_94%,var(--overview-accent-3)_6%)_48%,color-mix(in_oklch,var(--background)_90%,var(--overview-accent-1)_10%)_100%)] dark:opacity-60",e.compact?"[mask-image:linear-gradient(90deg,black_0%,black_48%,transparent_74%)] opacity-55":"opacity-85"),"aria-hidden":"true"}),(0,s.jsx)("div",{className:(0,f.cn)("text-foreground/5 dark:text-foreground/8 pointer-events-none absolute inset-y-0 right-0 hidden overflow-hidden font-mono sm:block",e.compact?"w-1/2 opacity-45":"w-[58%] opacity-75"),"aria-hidden":"true",children:(0,s.jsx)("pre",{className:(0,f.cn)("absolute right-3 [mask-image:linear-gradient(90deg,transparent_0%,black_30%,black_82%,transparent_100%)] text-right tracking-[0.38em] whitespace-pre",e.compact?"-top-6 text-[9px] leading-4":"top-1 text-[11px] leading-5"),children:"const request = await client.responses.create({\n  model: 'gpt-4.1-mini',\n  input: 'Start routing traffic',\n})\n\nif (request.output_text) {\n  console.log(request.output_text)\n}"})}),(0,s.jsx)("div",{className:"from-background/35 to-background/70 dark:from-background/20 dark:to-background/80 pointer-events-none absolute inset-0 bg-linear-to-b via-trans
5parent","aria-hidden":"true"})]})}function tt(e){let t=e.step.icon,a=e.step.completed?I.A:B.A;return(0,s.jsxs)("li",{className:"relative flex gap-3 pb-2.5 last:pb-0",children:[!e.isLast&&(0,s.jsx)("span",{className:"bg-border absolute top-9 bottom-0 left-4 w-px","aria-hidden":"true"}),(0,s.jsx)("span",{className:(0,f.cn)("bg-background relative z-10 flex size-8 shrink-0 items-center justify-center rounded-lg border shadow-xs",e.step.completed&&"border-success/30 bg-success/10"),children:(0,s.jsx)(a,{className:e.step.completed?"text-success size-4":"size-4","aria-hidden":"true"})}),(0,s.jsxs)(E.N_,{to:e.step.to,className:"bg-background/70 hover:bg-muted/50 focus-visible:ring-ring flex min-w-0 flex-1 items-center justify-between gap-3 rounded-xl border px-3 py-2.5 text-left shadow-xs transition-colors outline-none focus-visible:ring-2",children:[(0,s.jsxs)("span",{className:"flex min-w-0 items-start gap-2.5",children:[(0,s.jsx)("span",{className:"bg-muted mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-lg",children:(0,s.jsx)(t,{className:"size-3.5","aria-hidden":"true"})}),(0,s.jsxs)("span",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,s.jsxs)("span",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,s.jsxs)("span",{className:"text-muted-foreground font-mono text-xs tabular-nums",children:[e.index+1,"."]}),(0,s.jsx)("span",{className:"truncate",children:e.step.title})]}),(0,s.jsx)("span",{className:"text-muted-foreground line-clamp-1 text-xs",children:e.step.description})]})]}),(0,s.jsx)(O.A,{className:"text-muted-foreground size-4 shrink-0","aria-hidden":"true"})]})]})}function ta(e){let{t}=(0,d.Bd)(),a=(0,ea.I)(),[n,l]=(0,o.useState)(!1),{copyToClipboard:r}=(0,ei.C)({notify:!1}),i=e9({endpoint:e.example.endpoint,apiKey:e.example.displayKey,model:e.example.model}).split("\n"),c=async()=>{if(e.example.keyId&&!n){l(!0);try{let a=await (0,er.$8)(e.example.keyId),s=a.success&&a.data?.key?a.data.key:"";if(!s)return void en.oR.error(a.message||t("Failed to copy to clipboard"));let n=e9({endpoint:e.example.endpoint,apiKey:`sk-${s}`,model:e.example.model});await r(n)?en.oR.success(t("Copied to clipboard")):en.oR.error(t("Failed to copy to clipboard"))}finally{l(!1)}}};return(0,s.jsxs)(es.PY1.div,{initial:!a&&{opacity:0,y:10,scale:.98},animate:a?void 0:{opacity:1,y:0,scale:1},transition:ed.fI.slow,className:"bg-background/75 relative overflow-hidden rounded-2xl border p-3 shadow-sm backdrop-blur",children:[!a&&(0,s.jsx)(es.PY1.div,{className:"via-foreground/30 pointer-events-none absolute inset-x-0 top-0 h-px bg-linear-to-r from-transparent to-transparent",animate:{x:["-100%","100%"]},transition:{duration:3.2,repeat:1/0,ease:"easeInOut"},"aria-hidden":"true"}),(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3 border-b pb-3",children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,s.jsx)(el.f,{tone:"info",children:(0,s.jsx)(H,{})}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("div",{className:"truncate text-sm font-medium",children:t("First API request")}),(0,s.jsx)("div",{className:"text-muted-foreground truncate text-xs",children:e.example.ready?e.example.keyName:t("Create an API key to unlock the real request")})]})]}),e.example.ready?(0,s.jsxs)(m.$,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:n,onClick:c,"aria-label":t("Copy ready-to-run curl"),children:[(0,s.jsx)(P.A,{"data-icon":"inline-start"}),n?t("Loading"):t("Copy")]}):(0,s.jsx)(m.$,{size:"sm",variant:"outline",render:(0,s.jsx)(E.N_,{to:"/keys"}),children:t("Create API Key")})]}
5),(0,s.jsxs)("div",{className:"bg-foreground/[0.035] my-3 rounded-xl p-3 font-mono text-xs",children:[(0,s.jsxs)("div",{className:"mb-2 flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"bg-destructive size-2 rounded-full"}),(0,s.jsx)("span",{className:"bg-warning size-2 rounded-full"}),(0,s.jsx)("span",{className:"bg-success size-2 rounded-full"})]}),(0,s.jsx)("div",{className:"flex flex-col gap-1 overflow-hidden",children:i.map(e=>(0,s.jsx)("code",{className:"text-muted-foreground truncate",title:e,children:e},e))})]}),(0,s.jsx)("div",{className:"grid gap-2",children:e.signals.map(e=>{let t=e.icon;return(0,s.jsxs)("div",{className:"bg-muted/40 flex items-center justify-between gap-3 rounded-xl px-3 py-2",children:[(0,s.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,s.jsx)(el.f,{tone:e.tone,size:"xs",children:(0,s.jsx)(t,{})}),(0,s.jsx)("span",{className:"truncate text-xs font-medium",children:e.label})]}),(0,s.jsx)("span",{className:"text-muted-foreground shrink-0 text-xs",children:e.value})]},e.label)})})]})}function ts(e){let t=e.action.icon;return(0,s.jsxs)(m.$,{variant:"outline",className:"h-auto justify-start rounded-xl px-3 py-3 text-left",render:(0,s.jsx)(E.N_,{to:e.action.to}),children:[(0,s.jsx)("span",{className:"bg-muted flex size-9 shrink-0 items-center justify-center rounded-lg",children:(0,s.jsx)(t,{className:"size-4","aria-hidden":"true"})}),(0,s.jsxs)("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[(0,s.jsx)("span",{className:"truncate text-sm font-medium",children:e.action.title}),(0,s.jsx)("span",{className:"text-muted-foreground line-clamp-2 text-xs leading-relaxed",children:e.action.description})]})]})}function tn(e){let t=e.action.icon;return(0,s.jsxs)(m.$,{variant:"outline",size:"sm",className:"bg-background/70 h-8 min-w-24 gap-1.5 px-2.5",render:(0,s.jsx)(E.N_,{to:e.action.to}),children:[(0,s.jsx)(t,{"data-icon":"inline-start"}),(0,s.jsx)("span",{children:e.action.title})]})}function tl(){let{t:e}=(0,d.Bd)(),t=(0,v.n)(e=>e.auth.user),{items:a}=em(),{apiInfo:n,announcements:l,faq:r,uptimeKuma:i}=function(){let{status:e}=(0,ec.s)(),t=!!e;return{apiInfo:t&&e?.api_info_enabled!==!1,announcements:t&&e?.announcements_enabled!==!1,faq:t&&e?.faq_enabled!==!1,uptimeKuma:t&&e?.uptime_kuma_enabled!==!1}}(),[c,h]=(0,o.useState)(()=>(function(){if("u"<typeof window)return null;let e=window.localStorage.getItem(e7);return"expanded"===e||"collapsed"!==e&&null})()),p=Number(t?.request_count??0),x=Number(t?.quota??0),b=Number(t?.used_quota??0),y=!!(t?.role&&t.role>=g.z7.ADMIN),j=(0,U.I)({queryKey:["dashboard","overview","api-keys"],queryFn:async()=>{let e=await (0,er.PX)({p:1,size:10});return e.success?e.data?.items??[]:[]},staleTime:6e4}),k=(0,U.I)({queryKey:["dashboard","overview","user-models"],queryFn:async()=>{let e=await (0,eo.QK)();return e.success?e.data??[]:[]},staleTime:3e5}),N=(0,o.useMemo)(()=>{var e;return(e=j.data??[]).find(e=>1===e.status)??e[0]??null},[j.data]),w=(0,o.useMemo)(()=>[{title:e("Create API Key"),description:e("Create a key for your app or service"),to:"/keys",icon:Q.A,completed:!!N},{title:e("Add credits"),description:e("Keep enough balance before production traffic"),to:"/wallet",icon:W.A,completed:x>0||b>0},{title:e("Send a request"),description:e("Verify routing with Playground or your client"),to:"/playground",icon:H,completed:p>0}],[N,x,p,e,b]),C=(0,o.useMemo)(()=>[{title:e("API Keys"),description:e("Create a key for your app or service"),to:"/keys",icon:Q.A},{title:e("Channels"),description:e("Configure upstream providers and routing."),to:"/channels",icon:V,adminOnly:!0},{title:e("Usage Logs"),description:e("Inspect requests, errors, and billing details"),to:"/usage-logs",icon:G.A},{title:e("Pricing"),description:e("Review model rates before scaling traffic"),to:"/pricing",icon:J.A}],[e]),_=(0,o.useMemo)(()=>C.filter(e=>!e.adminOnly||y),[y,C]),A=(0,o.useMemo)(()=>[{label:e("Route active"),value:a.length>0?e("Online"):e("Current domain"),icon:V,tone:"info"},{label:e("Auth configured"),value:N?e("Secured"):e("Needs API key"),icon:Z.A,tone:"success"},{label:e("Model selected"),value:k.data?.[0]??e("Loading"),icon:Y.A,tone:"chart-4"}],[a.length,k.data,N,e]),F=(0,o.useMemo)(()=>{var t;let s=function(e){let t=`${"u"<typeof window?"":window.location.origin}/v1/chat/completions`,a=e?.trim();if(!a)return t;let s=a.replace(/\/+$/,"");return s.endsWith("/v1/chat/completions")?s:s.endsWith("/v1")?`${s}/chat/completions`:`${s}/v1/chat/completions`}(a[0]?.url),n=k.data?.[0]??"gpt-4o-mini",l=N?.name??e("No API key yet"),r=!!(N?.id&&n);return{endpoint:s,model:n,keyName:l,keyId:N?.id,displayKey:N&&(t=`sk-${N.key}`)?t.length<=14?t:`${t.slice(0,7)}...${t.slice(-4)}`:"sk-...",ready:r}},[a,k.data,N,e]),M=w.filter(e=>e.completed).length,q=M===w.length,T=j.isFetched&&!!t,S=c??(T&&!q),$=y||n||l||r,z=$||i,D=()=>{let e=!S;h(e),"u">typeof window&&window.localStorage.setItem(e7,e?"expanded":"collapsed")};return(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[S?(0,s.jsxs)(u.nD,{className:"grid items-stretch gap-4 xl:grid-cols-[minmax(0,1fr)_22rem]",children:[(0,s.jsx)(u.Hd,{className:"bg-card h-full overflow-hidden rounded-2xl border shadow-xs",children:(0,s.jsxs)("div",{className:"relative h-full overflow-hidden p-4 sm:p-5",children:[(0,s.jsx)(te,{}),(0,s.jsxs)("div",{className:"relative grid gap-5 lg:grid-cols-[minmax(0,1fr)_21rem]",children:[(0,s.jsxs)("div",{className:"flex min-w-0 flex-col gap-5",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"flex max-w-2xl flex-col gap-1",children:[(0,s.jsxs)("div",{className:"text-muted-foreground flex items-center gap-2 text-xs font-medium tracking-wider up
5percase",children:[(0,s.jsx)(X.A,{className:"size-3.5","aria-hidden":"true"}),e("Get started")]}),(0,s.jsx)("h3",{className:"text-xl font-semibold tracking-tight sm:text-2xl",children:e("Build on your API gateway in minutes")}),(0,s.jsx)("p",{className:"text-muted-foreground max-w-xl text-sm leading-relaxed",children:e("A focused home for keys, balance, routing, and service health.")})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsxs)(m.$,{variant:"outline",size:"sm",onClick:D,children:[(0,s.jsx)(ee.A,{"data-icon":"inline-start"}),e("Hide setup guide")]}),(0,s.jsxs)(m.$,{size:"sm",render:(0,s.jsx)(E.N_,{to:"/keys"}),children:[(0,s.jsx)(Q.A,{"data-icon":"inline-start"}),e("Create API Key")]})]})]}),(0,s.jsx)("ol",{className:"bg-background/45 rounded-2xl border p-2 backdrop-blur",children:w.map((e,t)=>(0,s.jsx)(tt,{step:e,index:t,isLast:t===w.length-1},e.title))})]}),(0,s.jsx)(ta,{example:F,signals:A})]})]})}),(0,s.jsx)(u.Hd,{className:"bg-card h-full rounded-2xl border p-4 shadow-xs sm:p-5",children:(0,s.jsxs)("div",{className:"flex h-full flex-col gap-4",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("div",{className:"text-muted-foreground text-xs font-medium tracking-wider uppercase",children:e("Recommended actions")}),(0,s.jsx)("h3",{className:"text-lg font-semibold tracking-tight",children:e("Keep the platform ready")})]}),(0,s.jsx)("div",{className:"grid gap-2",children:_.map(e=>(0,s.jsx)(ts,{action:e},e.title))})]})})]}):(0,s.jsx)(u.nD,{children:(0,s.jsx)(u.Hd,{className:"bg-card overflow-hidden rounded-2xl border shadow-xs",children:(0,s.jsxs)("div",{className:"relative overflow-hidden px-4 py-3 sm:px-5",children:[(0,s.jsx)(te,{compact:!0}),(0,s.jsxs)("div",{className:"relative flex flex-wrap items-center justify-between gap-3",children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,s.jsx)("span",{className:"bg-background/70 flex size-9 shrink-0 items-center justify-center rounded-xl border shadow-xs",children:(0,s.jsx)(I.A,{className:"text-success size-4","aria-hidden":"true"})}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("h3",{className:"truncate text-sm font-semibold",children:q?e("Setup guide complete"):e("Setup guide")}),(0,s.jsx)("span",{className:"text-muted-foreground bg-background/60 rounded-md border px-2 py-0.5 text-xs",children:e("Setup progress: {{completed}}/{{total}}",{completed:M,total:w.length})})]}),(0,s.jsx)("p",{className:"text-muted-foreground line-clamp-1 text-xs",children:q?e("Your setup guide is collapsed so usage stays in focus."):e("Setup guide is collapsed. Expand it anytime.")})]})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[_.map(e=>(0,s.jsx)(tn,{action:e},e.title)),(0,s.jsxs)(m.$,{variant:"outline",size:"sm",className:"bg-background/70 h-8 min-w-28",onClick:D,children:[(0,s.jsx)(et.A,{"data-icon":"inline-start"}),e("Show setup guide")]})]})]})]})})}),(0,s.jsx)(e2,{}),z&&(0,s.jsxs)(u.nD,{className:(0,f.cn)("grid grid-cols-1 gap-4",$&&i&&"xl:grid-cols-[minmax(0,1fr)_22rem]"),children:[$&&(0,s.jsxs)("div",{className:(0,f.cn)("grid min-w-0 grid-cols-1 gap-4",(n||l||r)&&"lg:grid-cols-2"),children:[y&&(0,s.jsx)(u.Hd,{className:"lg:col-span-2",children:(0,s.jsx)(eK,{})}),n&&(0,s.jsx)(u.Hd,{children:(0,s.jsx)(eM,{})}),l&&(0,s.jsx)(u.Hd,{children:(0,s.jsx)(ey,{})}),r&&(0,s.jsx)(u.Hd,{children:(0,s.jsx)(e$,{})})]}),i&&(0,s.jsx)(u.Hd,{children:(0,s.jsx)(e8,{})})]})]})}var tr=a(24308);let ti=(0,n.GY)("/_authenticated/dashboard/$section"),to=["count","quota","tokens","average-rpm","average-tpm"],td=["success-rate","average-latency","throughput"],tc=["primary-model","secondary-model"],tu=(0,o.lazy)(()=>a.e(525).then(a.bind(a,22700)).then(e=>({default:e.LogStatCards}))),tm=(0,o.lazy)(()=>Promise.all([a.e(6956),a.e(6841)]).then(a.bind(a,67184)).then(e=>({default:e.ModelCharts}))),th=(0,o.lazy)(()=>Promise.all([a.e(6956),a.e(6481)]).then(a.bind(a,78712)).then(e=>({default:e.ConsumptionDistributionChart}))),tp=(0,o.lazy)(()=>a.e(4182).then(a.bind(a,95797)).then(e=>({default:e.PerformanceOverview}))),tx=(0,o.lazy)(()=>Promise.all([a.e(6956),a.e(9335)]).then(a.bind(a,3818)).then(e=>({default:e.UserCharts}))),tg=(0,o.lazy)(()=>Promise.all([a.e(8984),a.e(6956),a.e(9082)]).then(a.bind(a,97953)).then(e=>
5({default:e.FlowCharts})));function tf(){return(0,s.jsx)("div",{className:"overflow-hidden rounded-lg border",children:(0,s.jsx)("div",{className:"divide-border/60 grid grid-cols-2 divide-x sm:grid-cols-3 lg:grid-cols-5",children:to.map((e,t)=>(0,s.jsxs)("div",{className:(0,f.cn)("px-2.5 py-1.5 sm:px-5 sm:py-4",t===to.length-1&&"col-span-2 sm:col-span-1"),children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[(0,s.jsx)(h.E,{className:"size-4 rounded-sm sm:size-7 sm:rounded-md"}),(0,s.jsx)(h.E,{className:"h-4 w-16"})]}),(0,s.jsx)(h.E,{className:"mt-1 h-5 w-16 sm:mt-2 sm:h-7 sm:w-20"}),(0,s.jsx)(h.E,{className:"mt-1 hidden h-3.5 w-28 md:block"})]},e))})})}function tv(){return(0,s.jsxs)("div",{className:"overflow-hidden rounded-lg border",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between border-b px-4 py-3 sm:px-5",children:[(0,s.jsx)(h.E,{className:"h-5 w-32"}),(0,s.jsx)(h.E,{className:"h-8 w-72"})]}),(0,s.jsx)("div",{className:"h-96 p-2",children:(0,s.jsx)(h.E,{className:"h-full w-full"})})]})}function tb(){return(0,s.jsx)("div",{className:"overflow-hidden rounded-lg border",children:(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-x-6 gap-y-2 px-4 py-3 sm:px-5",children:[(0,s.jsx)("div",{className:"flex items-center gap-2",children:(0,s.jsx)(h.E,{className:"h-4 w-24"})}),td.map(e=>(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsx)(h.E,{className:"h-3 w-14"}),(0,s.jsx)(h.E,{className:"h-4 w-16"})]},e)),(0,s.jsx)("div",{className:"ml-auto flex items-center gap-2",children:tc.map(e=>(0,s.jsx)(h.E,{className:"h-5 w-28 rounded-full"},e))})]})})}let ty={overview:{titleKey:"Overview"},models:{titleKey:"Model Call Analytics"},flow:{titleKey:"Flow"},users:{titleKey:"User Analytics"}},tj=function(){let{t:e}=(0,d.Bd)(),t=(0,l.Z)(),a=ti.useParams(),n=(0,v.n)(e=>e.auth.user?.role),h=a.section??tr.$F,[f,b]=(0,o.useState)([]),[y,j]=(0,o.useState)(!1),[k,N]=(0,o.useState)(()=>(0,z.a2)()),[w,_]=(0,o.useState)(()=>(0,z.pB)((0,z.a2)())),[A,F]=(0,o.useState)(()=>{let e=(0,z.so)();return{timeGranularity:e,selectedRange:(0,z.JL)(e),topUserLimit:10}}),[M,q]=(0,o.useState)(!0),T=(0,o.useCallback)(e=>{_(e)},[]),S=(0,o.useCallback)(()=>{_((0,z.pB)(k))},[k]),$=(0,o.useCallback)((e,t)=>{b(e),j(t)},[]),D=(0,o.useCallback)(e=>{N(e),_((0,z.pB)(e)),(0,z.g0)(e)},[]),R=ty[h]??ty.overview,L=!!(n&&n>=g.z7.ADMIN),U=(0,o.useMemo)(()=>tr.qB.filter(e=>"overview"!==e&&("users"!==e||L)),[L]),E=(0,o.useCallback)(e=>{t({to:"/dashboard/$section",params:{section:e}})},[t]),I="overview"!==h&&U.length>1,B="models"===h?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(C,{preferences:k,onPreferencesChange:D}),(0,s.jsx)(K,{preferences:k,currentFilters:w,onFilterChange:T,onReset:S})]}):null,O="flow"===h?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(x.m_,{children:[(0,s.jsx)(x.k$,{render:(0,s.jsx)(m.$,{variant:"ghost",size:"icon",onClick:()=>q(e=>!e),"aria-label":M?e("Hide sensitive data"):e("Show sensitive data"),className:"text-muted-foreground hover:text-foreground size-8"}),children:M?(0,s.jsx)(r.A,{}):(0,s.jsx)(i.A,{})}),(0,s.jsx)(x.ZI,{children:M?e("Hide sensitive data"):e("Show sensitive data")})]}),(0,s.jsx)(K,{preferences:k,currentFilters:w,onFilterChange:T,onReset:S,titleKey:"Flow Filters",descriptionKey:"Filter the traffic flow view by time range and user."})]}):null,H=B??O;return(0,s.jsxs)(c.Ni,{children:[(0,s.jsx)(c.Ni.Title,{children:e(R.titleKey)}),(0,s.jsx)(c.Ni.Content,{children:(0,s.jsxs)("div",{className:"space-y-3 sm:space-y-4",children:["overview"!==h&&(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-1.5 sm:gap-2",children:[I?(0,s.jsx)(p.tU,{value:h,onValueChange:E,children:(0,s.jsx)(p.j7,{className:"max-w-full flex-wrap justify-start group-data-horizontal/tabs:h-auto",children:U.map(t=>(0,s.jsx)(p.Xi,{value:t,children:e(ty[t].titleKey)},t))})}):(0,s.jsx)("div",{}),null!=H&&(0,s.jsx)("div",{className:"flex shrink-0 flex-wrap items-center gap-1.5 sm:gap-2",children:H})]}),"overview"===h&&(0,s.jsx)(tl,{}),"models"===h&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(u._A,{children:(0,s.jsx)(o.Suspense,{fallback:(0,s.jsx)(tf,{}),children:(0,s.jsx)(tu,{filters:w,onDataUpdate:$})})}),L&&(0,s.jsx)(u._A,{delay:.05,children:(0,s.jsx)(o.Suspense,{fallback:(0,s.jsx)(tb,{}),children:(0,s.jsx)(tp,{})})}),(0,s.jsx)(u._A,{delay:.1,children:(0,s.jsx)(o.Suspense,{fallback:(0,s.jsx)(tv,{}),children:(0,s.jsx)(th,{data:f,loading:y,defaultChartType:k.consumptionDistributionChart,timeGranularity:w.time_granularity||"hour"})})}),(0,s.jsx)(u._A,{delay:.15,children:(0,s.jsx)(o.Suspense,{fallback:(0,s.jsx)(tv,{}),children:(0,s.jsx)(tm,{data:f,loading:y,defaultChartTab:k.modelAnalyticsChart,timeGranularity:w.time_granularity||"hour"})})})]}),"users"===h&&(0,s.jsx)(u._A,{children:(0,s.jsx)(o.Suspense,{fallback:(0,s.jsx)(tv,{}),children:(0,s.jsx)(tx,{filters:A,onFiltersChange:F})})}
5),"flow"===h&&(0,s.jsx)(u._A,{children:(0,s.jsx)(o.Suspense,{fallback:(0,s.jsx)(tv,{}),children:(0,s.jsx)(tg,{filters:w,sensitiveVisible:M})})})]})})]})}},68328(e,t,a){let s=(0,a(40946).A)("book-open",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);a.d(t,{},{A:s})},65316(e,t,a){let s=(0,a(40946).A)("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);a.d(t,{},{A:s})},77565(e,t,a){let s=(0,a(40946).A)("flame",[["path",{d:"M12 3q1 4 4 6.5t3 5.5a1 1 0 0 1-14 0 5 5 0 0 1 1-3 1 1 0 0 0 5 0c0-2-1.5-3-1.5-5q0-2 2.5-4",key:"1slcih"}]]);a.d(t,{},{A:s})},99348(e,t,a){let s=(0,a(40946).A)("funnel",[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]]);a.d(t,{},{A:s})},37417(e,t,a){let s=(0,a(40946).A)("gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);a.d(t,{},{A:s})},59832(e,t,a){let s=(0,a(40946).A)("hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);a.d(t,{},{A:s})},85052(e,t,a){let s=(0,a(40946).A)("heart-pulse",[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5",key:"mvr1a0"}],["path",{d:"M3.22 13H9.5l.5-1 2 4.5 2-7 1.5 3.5h5.27",key:"auskq0"}]]);a.d(t,{},{A:s})},68758(e,t,a){let s=(0,a(40946).A)("key-round",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);a.d(t,{},{A:s})},58550(e,t,a){let s=(0,a(40946).A)("layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]);a.d(t,{},{A:s})},58026(e,t,a){let s=(0,a(40946).A)("list-checks",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}]]);a.d(t,{},{A:s})},49979(e,t,a){let s=(0,a(40946).A)("route",[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15",key:"1d8sl"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]]);a.d(t,{},{A:s})},53286(e,t,a){let s=(0,a(40946).A)("settings-2",[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);a.d(t,{},{A:s})},26464(e,t,a){let s=(0,a(40946).A)("shield-check",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);a.d(t,{},{A:s})},32115(e,t,a){let s=(0,a(40946).A)("timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);a.d(t,{},{A:s})},28276(e,t,a){let s=(0,a(40946).A)("trending-down",[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]]);a.d(t,{},{A:s})},90895(e,t,a){let s=(0,a(40946).A)("trending-up",[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]]);a.d(t,{},{A:s})},8585(e,t,a){let s=(0,a(40946).A)("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);a.d(t,{},{A:s})}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.