1import{d as X,j as p,a8 as bt,J as n,N as Z,Q as e,L as l,Y as at,Z as ht,r as v,w as K,S as H,K as t,_ as vt,M as h,a1 as B,P as I,a2 as q,v as d,$ as f,aj as xt,a9 as _t,a5 as ft,a as kt,B as $t,f as P,F as b,U as E,a4 as wt,R as j,O as St}from"./vendor-vue-C9I4HdhY.js";import{_ as Ct,N as ot,y as Mt,H as At,Q as Nt,R as Tt,I as Vt}from"./index-Cc-ERo76.js";import{k as lt,c as rt,l as Dt,m as Ut}from"./api-BNZ8zfZ2.js";import{m as D,f as S,k as Bt,n as It,o as O,p as nt,h as Rt,C as W,N as zt,a as U,t as dt,b as F,j as Et,i as G}from"./format-8IQ09-yI.js";import{_ as Ot}from"./AssistantsTabBar.vue_vue_type_script_setup_true_lang-Ce7ZnYtQ.js";import"./vendor-moment-DSem4xRw.js";import"./vendor-editor-markdown-BjRGdLHa.js";import"./vendor-charts-CVpKHQhc.js";import"./vendor-i18n-BYicniCH.js";import"./vendor-motion-yh3LNOre.js";import"./ReceiptPercentIcon-DK6e4laC.js";import"./FunnelIcon-BT1wfWNS.js";const Lt={key:0,class:"flex h-64 items-center justify-center text-sm text-gray-400 dark:text-gray-500"},Pt=X({__name:"UsageDailySpendChart",props:{days:{},assistants:{},colors:{}},setup(N){const k=N,R=p(()=>k.assistants[0]?.cost?.currency??"USD"),T=p(()=>k.days.some(u=>D(u.total)>0)),$=p(()=>k.assistants.map(u=>({name:u.name,data:k.days.map(g=>({x:new Date(`${g.date}T00:00:00`).getTime(),y:D(g.items.find(w=>w.assistant_id===u.assistant_id)?.cost)}))}))),C=p(()=>({chart:{type:"bar",stacked:!0,toolbar:{show:!1},zoom:{enabled:!1},animations:{enabled:!1},background:"transparent",fontFamily:"inherit"},plotOptions:{bar:{columnWidth:"70%",borderRadius:2,borderRadiusApplication:"end",borderRadiusWhenStacked:"last"}},dataLabels:{enabled:!1},colors:k.assistants.map(u=>k.colors.get(u.assistant_id??`removed-${u.name}`)??"#6366f1"),xaxis:{type:"datetime",labels:{format:"MMM dd",style:{colors:"#9ca3af",fontSize:"11px"}},axisBorder:{show:!1},axisTicks:{show:!1},tooltip:{enabled:!1}},yaxis:{min:0,forceNiceScale:!0,tickAmount:2,labels:{style:{colors:"#9ca3af",fontSize:"11px"},formatter:u=>S({amount:String(u),currency:R.value})}},grid:{borderColor:"rgba(156,163,175,0.2)",strokeDashArray:3,xaxis:{lines:{show:!1}},padding:{left:4,right:4}},tooltip:{shared:!0,intersect:!1,x:{format:"dd MMM yyyy"},y:{formatter:u=>S({amount:String(u),currency:R.value},{precise:u>0&&u<.01})}},legend:{show:!0,position:"bottom",horizontalAlign:"left",fontSize:"12px",labels:{colors:"#6b7280"},markers:{size:5,shape:"square"}},stroke:{width:0}}));return(u,g)=>{const w=bt("apexchart");return T.value?(l(),Z(w,{key:1,type:"bar",height:"280",options:C.value,series:$.value},null,8,["options","series"])):(l(),n("div",Lt,e(u.$t("No spend in this period")),1))}}}),jt={for:"ai-budget-amount",class:"block text-sm font-medium text-gray-900 dark:text-white"},Ft={class:"mt-2 flex items-center gap-2"},qt={key:0,class:"mt-1.5 text-xs text-gray-500 dark:text-gray-400"},Yt={for:"ai-budget-thresholds",class:"block text-sm font-medium text-gray-900 dark:text-white"},Gt={class:"mt-1.5 text-xs text-gray-500 dark:text-gray-400"},Ht={class:"mt-1 text-xs text-amber-600 dark:text-amber-400"},Qt={class:"flex items-center gap-2.5 text-sm font-medium text-gray-900 dark:text-white"},Wt={class:"mt-2 flex items-center gap-2"},Jt=["disabled"],Kt={class:"text-sm text-gray-500"},Xt={class:"mt-1.5 text-xs text-gray-500 dark:text-gray-400"},Zt={key:0,class:"text-sm text-red-600 dark:text-red-400"},te={key:1,class:"rounded-md bg-red-50 p-3 text-sm text-red-700 dark:bg-red-500/10 dark:text-red-400"},ee={class:"flex items-center gap-2 border-t border-gray-200 pt-4 dark:border-gray-700"},se=["disabled"],ae={class:"ml-auto flex gap-2"},oe=["disabled"],J="block w-full rounded-md bg-white px-3 py-2 text-sm text-gray-900 outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600 disabled:bg-gray-50 disabled:text-gray-400 dark:bg-white/5 dark:text-white dark:outline-white/10",le=X({__name:"AiBudgetDrawer",props:at({budget:{}},{modelValue:{type:Boolean,default:!1},modelModifiers:{}}),emits:at(["saved"],["update:modelValue"]),setup(N,{emit:k}){const R=N,T=k,$=ht(N,"modelValue"),C=v(""),u=v(""),g=v(!1),w=v(100),y=v(!1),m=v(!1),M=v(null);K($,i=>{if(!i)return;const c=R.budget;C.value=c?.amount?.amount??"",u.value=(c?.alert_thresholds_pct??[50,80]).join(", "),g.value=c?c.pause_all_at_pct!=null:!0,w.value=c?.pause_all_at_pct??100,M.value=null});const r=p(()=>Bt(u.value,100)),A=p(()=>
1{if(!(Number(C.value)>0))return"Budget amount must be greater than 0.";if(r.value.error)return r.value.error;if(g.value){const i=Number(w.value);if(!Number.isInteger(i)||i<1||i>1e3)return"Pause threshold must be a whole number between 1 and 1000."}return null});async function L(){if(!A.value){y.value=!0,M.value=null;try{const i=await lt({amount:{amount:Number(C.value).toFixed(2),currency:"USD"},alert_thresholds_pct:r.value.values,pause_all_at_pct:g.value?Number(w.value):null});T("saved",i),ot("Budget saved","Your monthly AI budget was updated."),$.value=!1}catch(i){M.value=rt(i,"Could not save the budget.")}finally{y.value=!1}}}async function z(){m.value=!0,M.value=null;try{await lt({amount:null}),T("saved",null),ot("Budget removed","Your monthly AI budget was removed."),$.value=!1}catch(i){M.value=rt(i,"Could not remove the budget.")}finally{m.value=!1}}return(i,c)=>(l(),Z(Ct,{modelValue:$.value,"onUpdate:modelValue":c[5]||(c[5]=x=>$.value=x),label:i.$t("Monthly AI budget"),description:i.$t("An account-wide budget for all AI assistants, reset every calendar month."),"drawer-width":"max-w-lg"},{default:H(()=>[t("form",{class:"space-y-6",onSubmit:vt(L,["prevent"])},[t("div",null,[t("label",jt,e(i.$t("Budget per month")),1),t("div",Ft,[c[6]||(c[6]=t("span",{class:"text-sm text-gray-500"},"$",-1)),B(t("input",{id:"ai-budget-amount","onUpdate:modelValue":c[0]||(c[0]=x=>C.value=x),type:"number",min:"0.01",step:"0.01",class:I(J),placeholder:"400.00"},null,512),[[q,C.value]]),c[7]||(c[7]=t("span",{class:"text-sm text-gray-500"},"USD",-1))]),N.budget?(l(),n("p",qt,e(d(S)(N.budget.spent))+" "+e(i.$t("spent so far this month.")),1)):h("",!0)]),t("div",null,[t("label",Yt,e(i.$t("Alert thresholds (% of budget)")),1),B(t("input",{id:"ai-budget-thresholds","onUpdate:modelValue":c[1]||(c[1]=x=>u.value=x),type:"text",class:I([J,"mt-2"]),placeholder:"50, 80"},null,2),[[q,u.value]]),t("p",Gt,e(i.$t("Up to 5 values between 1 and 100, separated by commas.")),1),t("p",Ht,e(i.$t("Alert settings are saved now; alert emails will start soon.")),1)]),t("div",null,[t("label",Qt,[B(t("input",{"onUpdate:modelValue":c[2]||(c[2]=x=>g.value=x),type:"checkbox",class:"size-4 rounded border-gray-300 text-indigo-600"},null,512),[[xt,g.value]]),f(" "+e(i.$t("Pause all assistants at")),1)]),t("div",Wt,[B(t("input",{"onUpdate:modelValue":c[3]||(c[3]=x=>w.value=x),type:"number",min:"1",max:"1000",step:"1",disabled:!g.value,class:I([J,"w-28"])},null,10,Jt),[[q,w.value,void 0,{number:!0}]]),t("span",Kt,e(i.$t("% of the budget")),1)]),t("p",Xt,e(i.$t("Once reached, every assistant refuses new runs until next month or until you raise the budget.")),1)]),A.value?(l(),n("p",Zt,e(i.$t(A.value)),1)):h("",!0),M.value?(l(),n("div",te,e(M.value),1)):h("",!0),t("div",ee,[N.budget?(l(),n("button",{key:0,type:"button",disabled:m.value||y.value,class:"text-sm font-semibold text-red-600 hover:text-red-500 disabled:opacity-50 dark:text-red-400",onClick:z},e(m.value?i.$t("Removingâ¦"):i.$t("Remove budget")),9,se)):h("",!0),t("div",ae,[t("button",{type:"button",class:"rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50 dark:bg-white/10 dark:text-white dark:ring-white/10",onClick:c[4]||(c[4]=x=>$.value=!1)},e(i.$t("Cancel")),1),t("button",{type:"submit",disabled:y.value||m.value||!!A.value,class:"rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 disabled:opacity-50"},e(y.value?i.$t("Savingâ¦"):i.$t("Save budget")),9,oe)])])],32)]),_:1},8,["modelValue","label","description"]))}}),re={class:"min-h-full bg-gray-50 dark:bg-gray-950"},ne=["aria-label"],de=["value"],ie=["max"],ue=["min"],ce={key:0,class:"text-xs text-red-600 dark:text-red-400"},ge=["disabled"],pe=["title"],ye=["title"],me={class:"space-y-6 px-4 py-8 sm:px-6 lg:px-8"},be={key:0,class:"grid grid-cols-1 gap-4 lg:grid-cols-3"},he={key:1,class:"rounded-xl border border-gray-200 bg-white p-10 text-center dark:border-gray-700 dark:bg-gray-900"},ve={class:"text-sm text-gray-600 dark:text-gray-300"},xe={class:"rounded-xl border border-gray-200 bg-white p-5 dark:border-gray-700 dark:bg-gray-900"},_e={class:"text-sm text-gray-500 dark:text-gray-400"},fe={class:"mt-2 text-3xl font-bold tabular-nums text-gray-900 dark:text-white"},ke={class:"mt-4 flex items-center gap-2 rounded-lg border border-gray-200 bg-gray-50 px-3 py-2.5 text-sm text-gray-600 dark:border-gray-700 dark:bg-gray-800/50 dark:text-gray-300"},$e={class:"flex-1"},we=["title"],Se={class:"rounded-xl border border-gray-200 bg-white p-5 dark:border-gray-700 dark:bg-gray-900"},Ce={class:"flex items-center justify-between"},Me={class:"text-sm text-gray-500 dark:text-gray-400"},Ae=["disabled","title"],Ne={class:"mt-2 text-3xl font-bold tabular-nums text-gray-900 dark:text-white"},Te={class:"text-sm font-normal text-gray-500 dark:text-gray-400"},Ve={class:"relative mt-4 h-2 rounded-full bg-gray-100 dark:bg-gray-800"},De={class:"mt-3 text-xs text-gray-500 dark:text-gray-400"},Ue={class:"mt-3 text-xs text-gray-500 dark:text-gray-400"},Be={class:"rounded-xl border border-gray-200 bg-white p-5 dark:border-gray-700 dark:bg-gray-900"},Ie={class:"text-sm text-gray-500 dark:text-gray-400"},Re={class:"mt-2 text-3xl font-bold tabular-nums text-gray-900 dark:text-white"},ze={class:"text-sm font-normal text-gray-500 dark:text-gray-400"},Ee={class:"mt-4 flex h-2 overflow-hidden rounded-full bg-indigo-200 dark:bg-indigo-500/30"},Oe={class:"mt-3 flex gap-4 text-xs text-gray-500 dark:text-gray-400"},Le={class:"flex items-center gap-1.5"},Pe={class:"flex items-center gap-1.5"},je={key:1,class:"mt-2 text-xs text-gray-500 dark:text-gray-400"}
1,Fe={class:"grid grid-cols-1 gap-6 xl:grid-cols-3"},qe={class:"rounded-xl border border-gray-200 bg-white p-5 xl:col-span-2 dark:border-gray-700 dark:bg-gray-900"},Ye={class:"flex items-center justify-between"},Ge={class:"text-sm font-semibold text-gray-900 dark:text-white"},He={class:"text-xs text-gray-500 dark:text-gray-400"},Qe={class:"rounded-xl border border-gray-200 bg-white p-5 dark:border-gray-700 dark:bg-gray-900"},We={class:"text-sm font-semibold text-gray-900 dark:text-white"},Je={class:"mt-3 max-h-72 overflow-y-auto"},Ke={class:"min-w-full text-sm"},Xe={class:"sticky top-0 bg-white dark:bg-gray-900"},Ze={class:"text-xs uppercase tracking-wide text-gray-500 dark:text-gray-400"},ts={class:"py-2 text-left font-semibold"},es={class:"py-2 text-right font-semibold"},ss={class:"py-2 text-right font-semibold"},as={class:"divide-y divide-gray-100 dark:divide-gray-800"},os={class:"py-2.5 pr-2 font-medium text-gray-900 dark:text-white"},ls={class:"py-2.5 text-right tabular-nums text-gray-700 dark:text-gray-300"},rs={class:"py-2.5 text-right tabular-nums text-gray-700 dark:text-gray-300"},ns={key:1,colspan:"2",class:"py-2.5 text-right text-xs text-gray-400 dark:text-gray-500"},ds={key:0},is={class:"mt-4 space-y-1 border-t border-gray-100 pt-3 text-xs text-gray-500 dark:border-gray-800 dark:text-gray-400"},us={class:"font-semibold text-gray-700 dark:text-gray-200"},cs={class:"overflow-hidden rounded-xl border border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-900"},gs={class:"flex items-center justify-between px-5 py-4"},ps={class:"text-sm font-semibold text-gray-900 dark:text-white"},ys={class:"text-xs text-gray-500 dark:text-gray-400"},ms={class:"overflow-x-auto"},bs={class:"min-w-full divide-y divide-gray-200 dark:divide-gray-700"},hs={class:"bg-gray-50 dark:bg-gray-800/50"},vs={class:"text-xs uppercase tracking-wide text-gray-500 dark:text-gray-400"},xs={class:"px-5 py-3 text-left font-semibold"},_s={class:"px-3 py-3 text-left font-semibold"},fs={class:"px-3 py-3 text-right font-semibold"},ks={class:"px-3 py-3 text-right font-semibold"},$s={class:"px-3 py-3 text-right font-semibold"},ws={class:"px-3 py-3 text-right font-semibold"},Ss={class:"px-5 py-3 text-left font-semibold"},Cs={class:"divide-y divide-gray-100 dark:divide-gray-800"},Ms={class:"px-5 py-3"},As={class:"px-3 py-3 text-gray-700 dark:text-gray-300"},Ns={class:"px-3 py-3 text-right tabular-nums text-gray-700 dark:text-gray-300"},Ts={key:0,class:"block text-xs text-red-600 dark:text-red-400"},Vs={class:"px-3 py-3 text-right tabular-nums text-gray-700 dark:text-gray-300"},Ds={class:"px-3 py-3 text-right tabular-nums text-gray-700 dark:text-gray-300"},Us={class:"px-3 py-3 text-right font-semibold tabular-nums text-gray-900 dark:text-white"},Bs={class:"px-5 py-3"},Is={class:"flex items-center gap-3"},Rs={class:"h-1.5 w-36 overflow-hidden rounded-full bg-gray-100 dark:bg-gray-800"},zs={class:"w-12 text-right text-xs tabular-nums text-gray-500 dark:text-gray-400"},Es={key:0},Os={colspan:"7",class:"px-5 py-10 text-center text-sm text-gray-500 dark:text-gray-400"},Ls={key:0,class:"bg-gray-50 text-sm font-semibold text-gray-900 dark:bg-gray-800/50 dark:text-white"},Ps={class:"px-5 py-3",colspan:"2"},js={class:"px-3 py-3 text-right tabular-nums"},Fs={class:"px-3 py-3 text-right tabular-nums"},qs={class:"px-3 py-3 text-right tabular-nums"},Ys={class:"px-3 py-3 text-right tabular-nums"},Gs=366,it="rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50 disabled:cursor-not-allowed disabled:text-gray-400 dark:bg-white/10 dark:text-white dark:ring-white/10 dark:hover:bg-white/20 dark:disabled:text-gray-500",la=X({__name:"usage",setup(N){const k=_t(),R=ft(),T=Mt(),$=Symbol("ai-assistants-usage"),C=[{key:"7d",label:"Last 7 days",days:7},{key:"30d",label:"Last 30 days",days:30},{key:"90d",label:"Last 90 days",days:90},{key:"month",label:"This month",days:0},{key:"custom",label:"Custom range",days:0}];function u(s){const o=new Date;if(s==="month")return{from:G(new Date(o.getFullYear(),o.getMonth(),1)),to:G(o)};const a=C.find(mt=>mt.key===s);return a?.days?{from:G(new Date(o.getTime()-(a.days-1)*864e5)),to:G(o)}:null}
1const g=v(k.query.range||"30d"),w=u(g.value)??{from:k.query.from||"",to:k.query.to||""},y=v(w.from||u("30d").from),m=v(w.to||u("30d").to),M=p(()=>(new Date(m.value).getTime()-new Date(y.value).getTime())/864e5+1>Gs);K(g,s=>{const o=u(s);o&&(y.value=o.from,m.value=o.to)});const r=v(null),A=v(!1),L=v(!1),z=v(!1);async function i(){if(!(!y.value||!m.value||M.value)){A.value=!0,L.value=!1;try{r.value=await Dt(y.value,m.value)}catch{L.value=!0}finally{A.value=!1}}}K([y,m],()=>{R.replace({query:g.value==="custom"?{range:"custom",from:y.value,to:m.value}:{range:g.value==="30d"?void 0:g.value}}),i()});async function c(){z.value=!0;try{await Ut(y.value,m.value)}catch{Vt("Export failed","Could not download the usage CSV.")}finally{z.value=!1}}const x=p(()=>It((r.value?.by_assistant??[]).map(s=>({id:s.assistant_id??`removed-${s.name}`,appearance:s.appearance})))),tt=p(()=>{const s=r.value?.period;if(!s)return"";const o=a=>new Date(`${a.slice(0,10)}T00:00:00`).toLocaleDateString("en-GB",{day:"numeric",month:"short"});return`${o(s.from)} â ${o(s.to)}`}),V=p(()=>O(r.value?.totals?.tokens)),ut=p(()=>V.value?nt(V.value.input,V.value.total||V.value.input+V.value.output):0),_=p(()=>r.value?.budget??null),et=p(()=>!!r.value?.permissions?.can_manage),Q=v(!1);function ct(s){r.value&&(r.value={...r.value,budget:s})}const gt=p(()=>_.value?nt(D(_.value.spent),D(_.value.amount)):0),st=p(()=>(r.value?.price_list?.models??[]).slice().sort((s,o)=>D(s.input_per_1m)-D(o.input_per_1m))),pt=p(()=>Rt(r.value?.price_list?.rules)),Y=p(()=>{const s=r.value?.by_assistant??[];return{runs:r.value?.totals?.runs??s.reduce((o,a)=>o+a.runs,0),input:s.reduce((o,a)=>o+(O(a.tokens)?.input??0),0),output:s.reduce((o,a)=>o+(O(a.tokens)?.output??0),0),cost:r.value?.totals?.cost}});function yt(s){return D(s.input_per_1m)>0||D(s.output_per_1m)>0}return kt(()=>{T.set($,{title:"AI Assistants",icon:At,gradient:"linear-gradient(135deg, #4338ca, #6366f1)",breadcrumbs:[{label:"AI Assistants",to:"/ai/assistants"},{label:"Usage & Billing"}]}),T.setRefresh($,i),i()}),$t(()=>T.clear($)),(s,o)=>(l(),n("div",re,[P(Ot,null,{left:H(()=>[B(t("select",{"onUpdate:modelValue":o[0]||(o[0]=a=>g.value=a),class:"rounded-md bg-white py-1.5 pr-8 pl-3 text-sm font-medium text-gray-700 outline-1 -outline-offset-1 outline-gray-300 dark:bg-white/5 dark:text-gray-200 dark:outline-white/10","aria-label":s.$t("Period")},[(l(),n(b,null,E(C,a=>t("option",{key:a.key,value:a.key},e(s.$t(a.label)),9,de)),64))],8,ne),[[wt,g.value]]),g.value==="custom"?(l(),n(b,{key:0},[B(t("input",{"onUpdate:modelValue":o[1]||(o[1]=a=>y.value=a),type:"date",max:m.value,class:"rounded-md bg-white px-2 py-1.5 text-sm text-gray-700 outline-1 -outline-offset-1 outline-gray-300 dark:bg-white/5 dark:text-gray-200 dark:outline-white/10"},null,8,ie),[[q,y.value]]),o[5]||(o[5]=t("span",{class:"text-gray-400"},"â",-1)),B(t("input",{"onUpdate:modelValue":o[2]||(o[2]=a=>m.value=a),type:"date",min:y.value,class:"rounded-md bg-white px-2 py-1.5 text-sm text-gray-700 outline-1 -outline-offset-1 outline-gray-300 dark:bg-white/5 dark:text-gray-200 dark:outline-white/10"},null,8,ue),[[q,m.value]]),M.value?(l(),n("span",ce,e(s.$t("Maximum range is 366 days")),1)):h("",!0)],64)):h("",!0)]),default:H(()=>[t("button",{type:"button",class:I(it),disabled:z.value||!r.value,onClick:c},e(z.value?s.$t("Exportingâ¦"):s.$t("Export CSV")),9,ge),t("button",{type:"button",class:I(it),disabled:"",title:s.$t(d(W))},e(s.$t("Invoices")),9,pe),t("button",{type:"button",disabled:"",title:s.$t(d(W)),class:"inline-flex cursor-not-allowed items-center gap-1.5 rounded-md bg-indigo-600/50 px-3 py-2 text-sm font-semibold text-white shadow-sm"},[P(d(Nt),{class:"size-4"}),f(" "+e(s.$t("Top up credits")),1)],8,ye)]),_:1}),t("div",me,[A.value&&!r.value?(l(),n("div",be,[(l(),n(b,null,E(3,a=>t("div",{key:a,class:"h-36 animate-pulse rounded-xl bg-gray-200/70 dark:bg-gray-800"})),64))])):L.value&&!r.value?(l(),n("div",he,[t("p",ve,e(s.$t("Could not load AI usage.")),1),t("button",{type:"button",class:"mt-3 text-sm font-semibold text-indigo-600 hover:text-indigo-500 dark:text-indigo-400",onClick:i}
1,e(s.$t("Try again")),1)])):r.value?(l(),n(b,{key:2},[t("div",{class:I(["grid grid-cols-1 gap-4 lg:grid-cols-3",{"opacity-60 transition-opacity":A.value}])},[t("div",xe,[t("p",_e,e(s.$t("AI credit balance")),1),t("p",fe,e(r.value.credit_account?d(S)(r.value.credit_account.balance):"â"),1),t("div",ke,[P(d(Tt),{class:"size-4 shrink-0"}),t("span",$e,[r.value.credit_account?.auto_topup?(l(),n(b,{key:0},[f(e(s.$t("Auto top-up on: add"))+" "+e(d(S)(r.value.credit_account.auto_topup.amount))+" "+e(s.$t("when balance drops below"))+" "+e(d(S)(r.value.credit_account.auto_topup.threshold)),1)],64)):(l(),n(b,{key:1},[f(e(s.$t("Auto top-up is off")),1)],64))]),t("button",{type:"button",disabled:"",class:"cursor-not-allowed text-sm font-medium text-gray-400 dark:text-gray-500",title:s.$t(d(W))},e(s.$t("Edit")),9,we)])]),t("div",Se,[t("div",Ce,[t("p",Me,e(s.$t("Monthly AI budget")),1),t("button",{type:"button",disabled:!et.value,class:"text-sm font-medium text-indigo-600 hover:text-indigo-500 disabled:cursor-not-allowed disabled:text-gray-400 dark:text-indigo-400 dark:disabled:text-gray-500",title:et.value?void 0:s.$t(d(zt)),onClick:o[3]||(o[3]=a=>Q.value=!0)},e(_.value?s.$t("Edit"):s.$t("Set budget")),9,Ae)]),_.value?(l(),n(b,{key:0},[t("p",Ne,[f(e(d(S)(_.value.spent))+" ",1),t("span",Te,e(s.$t("of"))+" "+e(d(S)(_.value.amount)),1)]),t("div",Ve,[t("div",{class:"h-full rounded-full bg-indigo-600",style:j({width:`${gt.value}%`})},null,4),(l(!0),n(b,null,E(_.value.alert_thresholds_pct,a=>(l(),n("span",{key:a,class:"absolute -top-1 h-4 w-0.5 bg-gray-400",style:j({left:`${a}%`})},null,4))),128))]),t("p",De,[_.value.alert_thresholds_pct?.length?(l(),n(b,{key:0},[f(e(s.$t("Alerts at"))+" "+e(_.value.alert_thresholds_pct.map(a=>`${a}%`).join(" and ")),1)],64)):h("",!0),_.value.pause_all_at_pct!=null?(l(),n(b,{key:1},[f(" · "+e(s.$t("all assistants pause at"))+" "+e(_.value.pause_all_at_pct)+"%",1)],64)):h("",!0)])],64)):(l(),n(b,{key:1},[o[6]||(o[6]=t("p",{class:"mt-2 text-3xl font-bold text-gray-300 dark:text-gray-600"},"â",-1)),t("p",Ue,e(s.$t("No monthly budget set. Spending is limited only by your credit balance and per-assistant caps.")),1)],64))]),t("div",Be,[t("p",Ie,e(s.$t("Tokens used")),1),t("p",Re,[f(e(d(U)(d(dt)(r.value.totals.tokens)))+" ",1),t("span",ze,e(d(F)(r.value.totals.runs))+" "+e(s.$t("runs")),1)]),V.value?(l(),n(b,{key:0},[t("div",Ee,[t("div",{class:"h-full bg-indigo-600",style:j({width:`${ut.value}%`})},null,4)]),t("div",Oe,[t("span",Le,[o[7]||(o[7]=t("span",{class:"size-2 rounded-sm bg-indigo-600"},null,-1)),f(e(s.$t("Input"))+" "+e(d(U)(V.value.input)),1)]),t("span",Pe,[o[8]||(o[8]=t("span",{class:"size-2 rounded-sm bg-indigo-200 dark:bg-indigo-500/30"},null,-1)),f(e(s.$t("Output"))+" "+e(d(U)(V.value.output)),1)])])],64)):h("",!0),r.value.totals.failed_runs?(l(),n("p",je,e(d(F)(r.value.totals.failed_runs))+" "+e(s.$t("failed runs (not billed)")),1)):h("",!0)])],2),t("div",Fe,[t("div",qe,[t("div",Ye,[t("h3",Ge,e(s.$t("Daily spend by assistant")),1),t("span",He,e(tt.value),1)]),P(Pt,{class:"mt-2",days:r.value.daily_spend_by_assistant??[],assistants:r.value.by_assistant??[],colors:x.value},null,8,["days","assistants","colors"])]),t("div",Qe,[t("h3",We,e(s.$t("Price list")),1),t("div",Je,[t("table",Ke,[t("thead",Xe,[t("tr",Ze,[t("th",ts,e(s.$t("Model")),1),t("th",es,e(s.$t("Input / 1M")),1),t("th",ss,e(s.$t("Output / 1M")),1)])]),t("tbody",as,[(l(!0),n(b,null,E(st.value,a=>(l(),n("tr",{key:a.id},[t("td",os,e(a.name),1),yt(a)?(l(),n(b,{key:0},[t("td",ls,e(d(S)(a.input_per_1m)),1),t("td",rs,e(d(S)(a.output_per_1m)),1)],64)):(l(),n("td",ns,e(s.$t("Price not set yet")),1))]))),128)),st.value.length?h("",!0):(l(),n("tr",ds,[...o[9]||(o[9]=[t("td",{colspan:"3",class:"py-4 text-center text-gray-400"},"â",-1)])]))])])]),t("div",is,[t("p",null,[t("span",us,e(s.$t("Assistant price")),1),f(" · "+e(s.$t("model token price plus"))+" "+e(d(Et)(r.value.price_list?.rules))+"% · "+e(s.$t("prices above include it")),1)]),(l(!0),n(b,null,E(pt.value,a=>(l(),n("p",{key:a},e(a),1))),128))])])]),t("div",cs,[t("div",gs,[t("h3",ps,e(s.$t("Usage by assistant")),1),t("span",ys,e(tt.value),1)]),t("div",ms,[t("table",bs,[t("thead",hs,[t("tr",vs,[t("th",xs,e(s.$t("Assistant")),1),t("th",_s,e(s.$t("Model")),1),t("th",fs,e(s.$t("Runs")),1),t("th",ks,e(s.$t("Input tokens")),1),t("th",$s,e(s.$t("Output tokens")),1),t("th",ws,e(s.$t("Cost")),1),t("th",Ss,e(s.$t("Share of spend")),1)])]),t("tbody",Cs,[(l(!0),n(b,null,E(r.value.by_assistant,a=>(l(),n("tr",{key:a.assistant_id??`removed-${a.name}`,class:"text-sm"},[t("td",Ms,[(l(),Z(St(a.assistant_id?"RouterLink":"span"),{to:a.assistant_id?`/ai/assistants/${a.assistant_id}`:void 0,class:I(["flex items-center gap-2 font-medium text-gray-900 dark:text-white",{"hover:text-indigo-600 dark:hover:text-indigo-400":a.assistant_id}])},{default:H(()=>[t("span",{class:"size-2.5 shrink-0 rounded-sm",style:j({backgroundColor:x.value.get(a.assistant_id??`removed-${a.name}`)})},null,4),f(" "+e(a.name),1)]),_:2},1032,["to","class"]))]),t("td",As,e(a.llm?.name??"â"),1),t("td",Ns,[f(e(d(F)(a.runs))+" ",1),a.failed_runs?(l(),n("span",Ts,e(d(F)(a.failed_runs))+" "+e(s.$t("failed")),1)):h("",!0)]),t("td",Vs,e(d(U)(d(O)(a.tokens)?.input??d(dt)(a.tokens))),1),t("td",Ds,e(d(O)(a.tokens)?d(U)(d(O)(a.tokens).output):"â"),1),t("td",Us,e(d(S)(a.cost)),1),t("td",Bs,[t("div",Is,[t("div",Rs,[t("div",{class:"h-full rounded-full",style:j({width:`${Math.min(100,Number(a.share_pct)||0)}%`,backgroundColor:x.value.get(a.assistant_id??`removed-${a.name}`)})},null,4)]),t("span",zs,e((Number(a.share_pct)||0).toFixed(1))+"%",1)])])]))),128)),r.value.by_assistant.length?h("",!0):(l(),n("tr",Es,[t("td",Os,e(s.$t("No assistant usage in this period")),1)]))]),r.value.by_assistant.length?(l(),n("tfoot",Ls,[t("tr",null,[t("td",Ps,e(s.$t("Total")),1),t("td",js,e(d(F)(Y.value.runs)),1),t("td",Fs,e(d(U)(Y.value.input)),1),t("td",qs,e(d(U)(Y.value.output)),1),t("td",Ys,e(d(S)(Y.value.cost)),1),o[10]||(o[10]=t("td",null,null,-1))])])):h("",!0)])])])],64)):h("",!0)]),P(le,{modelValue:Q.value,"onUpdate:modelValue":o[4]||(o[4]=a=>Q.value=a),budget:_.value,onSaved:ct},null,8,["modelValue","budget"])]))}});
1export{la as default};
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.