@dudousxd/nestjs-agent-dashboard 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +0,0 @@
1
- var ut=t=>{throw TypeError(t)};var _e=(t,e,s)=>e.has(t)||ut("Cannot "+s);var i=(t,e,s)=>(_e(t,e,"read from private field"),s?s.call(t):e.get(t)),d=(t,e,s)=>e.has(t)?ut("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),c=(t,e,s,r)=>(_e(t,e,"write to private field"),r?r.call(t,s):e.set(t,s),s),m=(t,e,s)=>(_e(t,e,"access private method"),s);var Ue=(t,e,s,r)=>({set _(n){c(t,e,n,s)},get _(){return i(t,e,r)}});import{r as F,j as y,p as Ht,L as Gt,D as Bt,C as $t,U as zt,W as Wt,A as Vt,a as Yt,R as Jt,b as Xt,M as Zt,S as es,c as ts}from"./index-CVpU-HIB.js";var Te=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},le=typeof window>"u"||"Deno"in globalThis;function _(){}function ss(t,e){return typeof t=="function"?t(e):t}function Ge(t){return typeof t=="number"&&t>=0&&t!==1/0}function Qt(t,e){return Math.max(t+(e||0)-Date.now(),0)}function ye(t,e){return typeof t=="function"?t(e):t}function G(t,e){return typeof t=="function"?t(e):t}function ct(t,e){const{type:s="all",exact:r,fetchStatus:n,predicate:a,queryKey:o,stale:u}=t;if(o){if(r){if(e.queryHash!==rt(o,e.options))return!1}else if(!je(e.queryKey,o))return!1}if(s!=="all"){const l=e.isActive();if(s==="active"&&!l||s==="inactive"&&l)return!1}return!(typeof u=="boolean"&&e.isStale()!==u||n&&n!==e.state.fetchStatus||a&&!a(e))}function ht(t,e){const{exact:s,status:r,predicate:n,mutationKey:a}=t;if(a){if(!e.options.mutationKey)return!1;if(s){if(De(e.options.mutationKey)!==De(a))return!1}else if(!je(e.options.mutationKey,a))return!1}return!(r&&e.state.status!==r||n&&!n(e))}function rt(t,e){return((e==null?void 0:e.queryKeyHashFn)||De)(t)}function De(t){return JSON.stringify(t,(e,s)=>$e(s)?Object.keys(s).sort().reduce((r,n)=>(r[n]=s[n],r),{}):s)}function je(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?!Object.keys(e).some(s=>!je(t[s],e[s])):!1}function At(t,e){if(t===e)return t;const s=lt(t)&&lt(e);if(s||$e(t)&&$e(e)){const r=s?t:Object.keys(t),n=r.length,a=s?e:Object.keys(e),o=a.length,u=s?[]:{};let l=0;for(let p=0;p<o;p++){const b=s?p:a[p];(!s&&r.includes(b)||s)&&t[b]===void 0&&e[b]===void 0?(u[b]=void 0,l++):(u[b]=At(t[b],e[b]),u[b]===t[b]&&t[b]!==void 0&&l++)}return n===o&&l===n?t:u}return e}function Be(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(const s in t)if(t[s]!==e[s])return!1;return!0}function lt(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function $e(t){if(!dt(t))return!1;const e=t.constructor;if(e===void 0)return!0;const s=e.prototype;return!(!dt(s)||!s.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function dt(t){return Object.prototype.toString.call(t)==="[object Object]"}function rs(t){return new Promise(e=>{setTimeout(e,t)})}function ze(t,e,s){return typeof s.structuralSharing=="function"?s.structuralSharing(t,e):s.structuralSharing!==!1?At(t,e):e}function is(t,e,s=0){const r=[...t,e];return s&&r.length>s?r.slice(1):r}function ns(t,e,s=0){const r=[e,...t];return s&&r.length>s?r.slice(0,-1):r}var it=Symbol();function Mt(t,e){return!t.queryFn&&(e!=null&&e.initialPromise)?()=>e.initialPromise:!t.queryFn||t.queryFn===it?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}var ie,J,pe,St,as=(St=class extends Te{constructor(){super();d(this,ie);d(this,J);d(this,pe);c(this,pe,e=>{if(!le&&window.addEventListener){const s=()=>e();return window.addEventListener("visibilitychange",s,!1),()=>{window.removeEventListener("visibilitychange",s)}}})}onSubscribe(){i(this,J)||this.setEventListener(i(this,pe))}onUnsubscribe(){var e;this.hasListeners()||((e=i(this,J))==null||e.call(this),c(this,J,void 0))}setEventListener(e){var s;c(this,pe,e),(s=i(this,J))==null||s.call(this),c(this,J,e(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(e){i(this,ie)!==e&&(c(this,ie,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(s=>{s(e)})}isFocused(){var e;return typeof i(this,ie)=="boolean"?i(this,ie):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},ie=new WeakMap,J=new WeakMap,pe=new WeakMap,St),nt=new as,me,X,ve,Ct,os=(Ct=class extends Te{constructor(){super();d(this,me,!0);d(this,X);d(this,ve);c(this,ve,e=>{if(!le&&window.addEventListener){const s=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",s,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",s),window.removeEventListener("offline",r)}}})}onSubscribe(){i(this,X)||this.setEventListener(i(this,ve))}onUnsubscribe(){var e;this.hasListeners()||((e=i(this,X))==null||e.call(this),c(this,X,void 0))}setEventListener(e){var s;c(this,ve,e),(s=i(this,X))==null||s.call(this),c(this,X,e(this.setOnline.bind(this)))}setOnline(e){i(this,me)!==e&&(c(this,me,e),this.listeners.forEach(r=>{r(e)}))}isOnline(){return i(this,me)}},me=new WeakMap,X=new WeakMap,ve=new WeakMap,Ct),Le=new os;function We(){let t,e;const s=new Promise((n,a)=>{t=n,e=a});s.status="pending",s.catch(()=>{});function r(n){Object.assign(s,n),delete s.resolve,delete s.reject}return s.resolve=n=>{r({status:"fulfilled",value:n}),t(n)},s.reject=n=>{r({status:"rejected",reason:n}),e(n)},s}function us(t){return Math.min(1e3*2**t,3e4)}function It(t){return(t??"online")==="online"?Le.isOnline():!0}var Tt=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function Ke(t){return t instanceof Tt}function qt(t){let e=!1,s=0,r=!1,n;const a=We(),o=f=>{var g;r||(w(new Tt(f)),(g=t.abort)==null||g.call(t))},u=()=>{e=!0},l=()=>{e=!1},p=()=>nt.isFocused()&&(t.networkMode==="always"||Le.isOnline())&&t.canRun(),b=()=>It(t.networkMode)&&t.canRun(),h=f=>{var g;r||(r=!0,(g=t.onSuccess)==null||g.call(t,f),n==null||n(),a.resolve(f))},w=f=>{var g;r||(r=!0,(g=t.onError)==null||g.call(t,f),n==null||n(),a.reject(f))},S=()=>new Promise(f=>{var g;n=D=>{(r||p())&&f(D)},(g=t.onPause)==null||g.call(t)}).then(()=>{var f;n=void 0,r||(f=t.onContinue)==null||f.call(t)}),P=()=>{if(r)return;let f;const g=s===0?t.initialPromise:void 0;try{f=g??t.fn()}catch(D){f=Promise.reject(D)}Promise.resolve(f).then(h).catch(D=>{var K;if(r)return;const M=t.retry??(le?0:3),R=t.retryDelay??us,Q=typeof R=="function"?R(s,D):R,k=M===!0||typeof M=="number"&&s<M||typeof M=="function"&&M(s,D);if(e||!k){w(D);return}s++,(K=t.onFail)==null||K.call(t,s,D),rs(Q).then(()=>p()?void 0:S()).then(()=>{e?w(D):P()})})};return{promise:a,cancel:o,continue:()=>(n==null||n(),a),cancelRetry:u,continueRetry:l,canStart:b,start:()=>(b()?P():S().then(P),a)}}function cs(){let t=[],e=0,s=u=>{u()},r=u=>{u()},n=u=>setTimeout(u,0);const a=u=>{e?t.push(u):n(()=>{s(u)})},o=()=>{const u=t;t=[],u.length&&n(()=>{r(()=>{u.forEach(l=>{s(l)})})})};return{batch:u=>{let l;e++;try{l=u()}finally{e--,e||o()}return l},batchCalls:u=>(...l)=>{a(()=>{u(...l)})},schedule:a,setNotifyFunction:u=>{s=u},setBatchNotifyFunction:u=>{r=u},setScheduler:u=>{n=u}}}var j=cs(),ne,Rt,Ut=(Rt=class{constructor(){d(this,ne)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Ge(this.gcTime)&&c(this,ne,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(le?1/0:5*60*1e3))}clearGcTimeout(){i(this,ne)&&(clearTimeout(i(this,ne)),c(this,ne,void 0))}},ne=new WeakMap,Rt),be,ge,N,A,Qe,ae,H,V,Ot,hs=(Ot=class extends Ut{constructor(e){super();d(this,H);d(this,be);d(this,ge);d(this,N);d(this,A);d(this,Qe);d(this,ae);c(this,ae,!1),c(this,Qe,e.defaultOptions),this.setOptions(e.options),this.observers=[],c(this,N,e.cache),this.queryKey=e.queryKey,this.queryHash=e.queryHash,c(this,be,ls(this.options)),this.state=e.state??i(this,be),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var e;return(e=i(this,A))==null?void 0:e.promise}setOptions(e){this.options={...i(this,Qe),...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&i(this,N).remove(this)}setData(e,s){const r=ze(this.state.data,e,this.options);return m(this,H,V).call(this,{data:r,type:"success",dataUpdatedAt:s==null?void 0:s.updatedAt,manual:s==null?void 0:s.manual}),r}setState(e,s){m(this,H,V).call(this,{type:"setState",state:e,setStateOptions:s})}cancel(e){var r,n;const s=(r=i(this,A))==null?void 0:r.promise;return(n=i(this,A))==null||n.cancel(e),s?s.then(_).catch(_):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(i(this,be))}isActive(){return this.observers.some(e=>G(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===it||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(e=0){return this.state.isInvalidated||this.state.data===void 0||!Qt(this.state.dataUpdatedAt,e)}onFocus(){var s;const e=this.observers.find(r=>r.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(s=i(this,A))==null||s.continue()}onOnline(){var s;const e=this.observers.find(r=>r.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(s=i(this,A))==null||s.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),i(this,N).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(s=>s!==e),this.observers.length||(i(this,A)&&(i(this,ae)?i(this,A).cancel({revert:!0}):i(this,A).cancelRetry()),this.scheduleGc()),i(this,N).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||m(this,H,V).call(this,{type:"invalidate"})}fetch(e,s){var l,p,b;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(s!=null&&s.cancelRefetch))this.cancel({silent:!0});else if(i(this,A))return i(this,A).continueRetry(),i(this,A).promise}if(e&&this.setOptions(e),!this.options.queryFn){const h=this.observers.find(w=>w.options.queryFn);h&&this.setOptions(h.options)}const r=new AbortController,n=h=>{Object.defineProperty(h,"signal",{enumerable:!0,get:()=>(c(this,ae,!0),r.signal)})},a=()=>{const h=Mt(this.options,s),w={queryKey:this.queryKey,meta:this.meta};return n(w),c(this,ae,!1),this.options.persister?this.options.persister(h,w,this):h(w)},o={fetchOptions:s,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:a};n(o),(l=this.options.behavior)==null||l.onFetch(o,this),c(this,ge,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((p=o.fetchOptions)==null?void 0:p.meta))&&m(this,H,V).call(this,{type:"fetch",meta:(b=o.fetchOptions)==null?void 0:b.meta});const u=h=>{var w,S,P,f;Ke(h)&&h.silent||m(this,H,V).call(this,{type:"error",error:h}),Ke(h)||((S=(w=i(this,N).config).onError)==null||S.call(w,h,this),(f=(P=i(this,N).config).onSettled)==null||f.call(P,this.state.data,h,this)),this.scheduleGc()};return c(this,A,qt({initialPromise:s==null?void 0:s.initialPromise,fn:o.fetchFn,abort:r.abort.bind(r),onSuccess:h=>{var w,S,P,f;if(h===void 0){u(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(h)}catch(g){u(g);return}(S=(w=i(this,N).config).onSuccess)==null||S.call(w,h,this),(f=(P=i(this,N).config).onSettled)==null||f.call(P,h,this.state.error,this),this.scheduleGc()},onError:u,onFail:(h,w)=>{m(this,H,V).call(this,{type:"failed",failureCount:h,error:w})},onPause:()=>{m(this,H,V).call(this,{type:"pause"})},onContinue:()=>{m(this,H,V).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0})),i(this,A).start()}},be=new WeakMap,ge=new WeakMap,N=new WeakMap,A=new WeakMap,Qe=new WeakMap,ae=new WeakMap,H=new WeakSet,V=function(e){const s=r=>{switch(e.type){case"failed":return{...r,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...kt(r.data,this.options),fetchMeta:e.meta??null};case"success":return{...r,data:e.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const n=e.error;return Ke(n)&&n.revert&&i(this,ge)?{...i(this,ge),fetchStatus:"idle"}:{...r,error:n,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...e.state}}};this.state=s(this.state),j.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),i(this,N).notify({query:this,type:"updated",action:e})})},Ot);function kt(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:It(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function ls(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,s=e!==void 0,r=s?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:s?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:s?"success":"pending",fetchStatus:"idle"}}var B,Pt,ds=(Pt=class extends Te{constructor(e={}){super();d(this,B);this.config=e,c(this,B,new Map)}build(e,s,r){const n=s.queryKey,a=s.queryHash??rt(n,s);let o=this.get(a);return o||(o=new hs({cache:this,queryKey:n,queryHash:a,options:e.defaultQueryOptions(s),state:r,defaultOptions:e.getQueryDefaults(n)}),this.add(o)),o}add(e){i(this,B).has(e.queryHash)||(i(this,B).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const s=i(this,B).get(e.queryHash);s&&(e.destroy(),s===e&&i(this,B).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){j.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return i(this,B).get(e)}getAll(){return[...i(this,B).values()]}find(e){const s={exact:!0,...e};return this.getAll().find(r=>ct(s,r))}findAll(e={}){const s=this.getAll();return Object.keys(e).length>0?s.filter(r=>ct(e,r)):s}notify(e){j.batch(()=>{this.listeners.forEach(s=>{s(e)})})}onFocus(){j.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){j.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},B=new WeakMap,Pt),$,T,oe,z,Y,Et,fs=(Et=class extends Ut{constructor(e){super();d(this,z);d(this,$);d(this,T);d(this,oe);this.mutationId=e.mutationId,c(this,T,e.mutationCache),c(this,$,[]),this.state=e.state||ys(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){i(this,$).includes(e)||(i(this,$).push(e),this.clearGcTimeout(),i(this,T).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){c(this,$,i(this,$).filter(s=>s!==e)),this.scheduleGc(),i(this,T).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){i(this,$).length||(this.state.status==="pending"?this.scheduleGc():i(this,T).remove(this))}continue(){var e;return((e=i(this,oe))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var n,a,o,u,l,p,b,h,w,S,P,f,g,D,M,R,Q,k,K,I;c(this,oe,qt({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(E,C)=>{m(this,z,Y).call(this,{type:"failed",failureCount:E,error:C})},onPause:()=>{m(this,z,Y).call(this,{type:"pause"})},onContinue:()=>{m(this,z,Y).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>i(this,T).canRun(this)}));const s=this.state.status==="pending",r=!i(this,oe).canStart();try{if(!s){m(this,z,Y).call(this,{type:"pending",variables:e,isPaused:r}),await((a=(n=i(this,T).config).onMutate)==null?void 0:a.call(n,e,this));const C=await((u=(o=this.options).onMutate)==null?void 0:u.call(o,e));C!==this.state.context&&m(this,z,Y).call(this,{type:"pending",context:C,variables:e,isPaused:r})}const E=await i(this,oe).start();return await((p=(l=i(this,T).config).onSuccess)==null?void 0:p.call(l,E,e,this.state.context,this)),await((h=(b=this.options).onSuccess)==null?void 0:h.call(b,E,e,this.state.context)),await((S=(w=i(this,T).config).onSettled)==null?void 0:S.call(w,E,null,this.state.variables,this.state.context,this)),await((f=(P=this.options).onSettled)==null?void 0:f.call(P,E,null,e,this.state.context)),m(this,z,Y).call(this,{type:"success",data:E}),E}catch(E){try{throw await((D=(g=i(this,T).config).onError)==null?void 0:D.call(g,E,e,this.state.context,this)),await((R=(M=this.options).onError)==null?void 0:R.call(M,E,e,this.state.context)),await((k=(Q=i(this,T).config).onSettled)==null?void 0:k.call(Q,void 0,E,this.state.variables,this.state.context,this)),await((I=(K=this.options).onSettled)==null?void 0:I.call(K,void 0,E,e,this.state.context)),E}finally{m(this,z,Y).call(this,{type:"error",error:E})}}finally{i(this,T).runNext(this)}}},$=new WeakMap,T=new WeakMap,oe=new WeakMap,z=new WeakSet,Y=function(e){const s=r=>{switch(e.type){case"failed":return{...r,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...r,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:e.error,failureCount:r.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=s(this.state),j.batch(()=>{i(this,$).forEach(r=>{r.onMutationUpdate(e)}),i(this,T).notify({mutation:this,type:"updated",action:e})})},Et);function ys(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var L,Ae,Ft,ps=(Ft=class extends Te{constructor(e={}){super();d(this,L);d(this,Ae);this.config=e,c(this,L,new Map),c(this,Ae,Date.now())}build(e,s,r){const n=new fs({mutationCache:this,mutationId:++Ue(this,Ae)._,options:e.defaultMutationOptions(s),state:r});return this.add(n),n}add(e){const s=ke(e),r=i(this,L).get(s)??[];r.push(e),i(this,L).set(s,r),this.notify({type:"added",mutation:e})}remove(e){var r;const s=ke(e);if(i(this,L).has(s)){const n=(r=i(this,L).get(s))==null?void 0:r.filter(a=>a!==e);n&&(n.length===0?i(this,L).delete(s):i(this,L).set(s,n))}this.notify({type:"removed",mutation:e})}canRun(e){var r;const s=(r=i(this,L).get(ke(e)))==null?void 0:r.find(n=>n.state.status==="pending");return!s||s===e}runNext(e){var r;const s=(r=i(this,L).get(ke(e)))==null?void 0:r.find(n=>n!==e&&n.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}clear(){j.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}getAll(){return[...i(this,L).values()].flat()}find(e){const s={exact:!0,...e};return this.getAll().find(r=>ht(s,r))}findAll(e={}){return this.getAll().filter(s=>ht(e,s))}notify(e){j.batch(()=>{this.listeners.forEach(s=>{s(e)})})}resumePausedMutations(){const e=this.getAll().filter(s=>s.state.isPaused);return j.batch(()=>Promise.all(e.map(s=>s.continue().catch(_))))}},L=new WeakMap,Ae=new WeakMap,Ft);function ke(t){var e;return((e=t.options.scope)==null?void 0:e.id)??String(t.mutationId)}function ft(t){return{onFetch:(e,s)=>{var b,h,w,S,P;const r=e.options,n=(w=(h=(b=e.fetchOptions)==null?void 0:b.meta)==null?void 0:h.fetchMore)==null?void 0:w.direction,a=((S=e.state.data)==null?void 0:S.pages)||[],o=((P=e.state.data)==null?void 0:P.pageParams)||[];let u={pages:[],pageParams:[]},l=0;const p=async()=>{let f=!1;const g=R=>{Object.defineProperty(R,"signal",{enumerable:!0,get:()=>(e.signal.aborted?f=!0:e.signal.addEventListener("abort",()=>{f=!0}),e.signal)})},D=Mt(e.options,e.fetchOptions),M=async(R,Q,k)=>{if(f)return Promise.reject();if(Q==null&&R.pages.length)return Promise.resolve(R);const K={queryKey:e.queryKey,pageParam:Q,direction:k?"backward":"forward",meta:e.options.meta};g(K);const I=await D(K),{maxPages:E}=e.options,C=k?ns:is;return{pages:C(R.pages,I,E),pageParams:C(R.pageParams,Q,E)}};if(n&&a.length){const R=n==="backward",Q=R?ms:yt,k={pages:a,pageParams:o},K=Q(r,k);u=await M(k,K,R)}else{const R=t??a.length;do{const Q=l===0?o[0]??r.initialPageParam:yt(r,u);if(l>0&&Q==null)break;u=await M(u,Q),l++}while(l<R)}return u};e.options.persister?e.fetchFn=()=>{var f,g;return(g=(f=e.options).persister)==null?void 0:g.call(f,p,{queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},s)}:e.fetchFn=p}}}function yt(t,{pages:e,pageParams:s}){const r=e.length-1;return e.length>0?t.getNextPageParam(e[r],e,s[r],s):void 0}function ms(t,{pages:e,pageParams:s}){var r;return e.length>0?(r=t.getPreviousPageParam)==null?void 0:r.call(t,e[0],e,s[0],s):void 0}var O,Z,ee,we,xe,te,Se,Ce,Dt,vs=(Dt=class{constructor(t={}){d(this,O);d(this,Z);d(this,ee);d(this,we);d(this,xe);d(this,te);d(this,Se);d(this,Ce);c(this,O,t.queryCache||new ds),c(this,Z,t.mutationCache||new ps),c(this,ee,t.defaultOptions||{}),c(this,we,new Map),c(this,xe,new Map),c(this,te,0)}mount(){Ue(this,te)._++,i(this,te)===1&&(c(this,Se,nt.subscribe(async t=>{t&&(await this.resumePausedMutations(),i(this,O).onFocus())})),c(this,Ce,Le.subscribe(async t=>{t&&(await this.resumePausedMutations(),i(this,O).onOnline())})))}unmount(){var t,e;Ue(this,te)._--,i(this,te)===0&&((t=i(this,Se))==null||t.call(this),c(this,Se,void 0),(e=i(this,Ce))==null||e.call(this),c(this,Ce,void 0))}isFetching(t){return i(this,O).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return i(this,Z).findAll({...t,status:"pending"}).length}getQueryData(t){var s;const e=this.defaultQueryOptions({queryKey:t});return(s=i(this,O).get(e.queryHash))==null?void 0:s.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),s=i(this,O).build(this,e),r=s.state.data;return r===void 0?this.fetchQuery(t):(t.revalidateIfStale&&s.isStaleByTime(ye(e.staleTime,s))&&this.prefetchQuery(e),Promise.resolve(r))}getQueriesData(t){return i(this,O).findAll(t).map(({queryKey:e,state:s})=>{const r=s.data;return[e,r]})}setQueryData(t,e,s){const r=this.defaultQueryOptions({queryKey:t}),n=i(this,O).get(r.queryHash),a=n==null?void 0:n.state.data,o=ss(e,a);if(o!==void 0)return i(this,O).build(this,r).setData(o,{...s,manual:!0})}setQueriesData(t,e,s){return j.batch(()=>i(this,O).findAll(t).map(({queryKey:r})=>[r,this.setQueryData(r,e,s)]))}getQueryState(t){var s;const e=this.defaultQueryOptions({queryKey:t});return(s=i(this,O).get(e.queryHash))==null?void 0:s.state}removeQueries(t){const e=i(this,O);j.batch(()=>{e.findAll(t).forEach(s=>{e.remove(s)})})}resetQueries(t,e){const s=i(this,O),r={type:"active",...t};return j.batch(()=>(s.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries(r,e)))}cancelQueries(t,e={}){const s={revert:!0,...e},r=j.batch(()=>i(this,O).findAll(t).map(n=>n.cancel(s)));return Promise.all(r).then(_).catch(_)}invalidateQueries(t,e={}){return j.batch(()=>{if(i(this,O).findAll(t).forEach(r=>{r.invalidate()}),(t==null?void 0:t.refetchType)==="none")return Promise.resolve();const s={...t,type:(t==null?void 0:t.refetchType)??(t==null?void 0:t.type)??"active"};return this.refetchQueries(s,e)})}refetchQueries(t,e={}){const s={...e,cancelRefetch:e.cancelRefetch??!0},r=j.batch(()=>i(this,O).findAll(t).filter(n=>!n.isDisabled()).map(n=>{let a=n.fetch(void 0,s);return s.throwOnError||(a=a.catch(_)),n.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(_)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const s=i(this,O).build(this,e);return s.isStaleByTime(ye(e.staleTime,s))?s.fetch(e):Promise.resolve(s.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(_).catch(_)}fetchInfiniteQuery(t){return t.behavior=ft(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(_).catch(_)}ensureInfiniteQueryData(t){return t.behavior=ft(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return Le.isOnline()?i(this,Z).resumePausedMutations():Promise.resolve()}getQueryCache(){return i(this,O)}getMutationCache(){return i(this,Z)}getDefaultOptions(){return i(this,ee)}setDefaultOptions(t){c(this,ee,t)}setQueryDefaults(t,e){i(this,we).set(De(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...i(this,we).values()],s={};return e.forEach(r=>{je(t,r.queryKey)&&Object.assign(s,r.defaultOptions)}),s}setMutationDefaults(t,e){i(this,xe).set(De(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...i(this,xe).values()];let s={};return e.forEach(r=>{je(t,r.mutationKey)&&(s={...s,...r.defaultOptions})}),s}defaultQueryOptions(t){if(t._defaulted)return t;const e={...i(this,ee).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=rt(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===it&&(e.enabled=!1),e}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...i(this,ee).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){i(this,O).clear(),i(this,Z).clear()}},O=new WeakMap,Z=new WeakMap,ee=new WeakMap,we=new WeakMap,xe=new WeakMap,te=new WeakMap,Se=new WeakMap,Ce=new WeakMap,Dt),U,v,Me,q,ue,Re,se,W,Ie,Oe,Pe,ce,he,re,Ee,x,Fe,Ve,Ye,Je,Xe,Ze,et,tt,Lt,jt,bs=(jt=class extends Te{constructor(e,s){super();d(this,x);d(this,U);d(this,v);d(this,Me);d(this,q);d(this,ue);d(this,Re);d(this,se);d(this,W);d(this,Ie);d(this,Oe);d(this,Pe);d(this,ce);d(this,he);d(this,re);d(this,Ee,new Set);this.options=s,c(this,U,e),c(this,W,null),c(this,se,We()),this.options.experimental_prefetchInRender||i(this,se).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(s)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(i(this,v).addObserver(this),pt(i(this,v),this.options)?m(this,x,Fe).call(this):this.updateResult(),m(this,x,Xe).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return st(i(this,v),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return st(i(this,v),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,m(this,x,Ze).call(this),m(this,x,et).call(this),i(this,v).removeObserver(this)}setOptions(e,s){const r=this.options,n=i(this,v);if(this.options=i(this,U).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof G(this.options.enabled,i(this,v))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");m(this,x,tt).call(this),i(this,v).setOptions(this.options),r._defaulted&&!Be(this.options,r)&&i(this,U).getQueryCache().notify({type:"observerOptionsUpdated",query:i(this,v),observer:this});const a=this.hasListeners();a&&mt(i(this,v),n,this.options,r)&&m(this,x,Fe).call(this),this.updateResult(s),a&&(i(this,v)!==n||G(this.options.enabled,i(this,v))!==G(r.enabled,i(this,v))||ye(this.options.staleTime,i(this,v))!==ye(r.staleTime,i(this,v)))&&m(this,x,Ve).call(this);const o=m(this,x,Ye).call(this);a&&(i(this,v)!==n||G(this.options.enabled,i(this,v))!==G(r.enabled,i(this,v))||o!==i(this,re))&&m(this,x,Je).call(this,o)}getOptimisticResult(e){const s=i(this,U).getQueryCache().build(i(this,U),e),r=this.createResult(s,e);return ws(this,r)&&(c(this,q,r),c(this,Re,this.options),c(this,ue,i(this,v).state)),r}getCurrentResult(){return i(this,q)}trackResult(e,s){const r={};return Object.keys(e).forEach(n=>{Object.defineProperty(r,n,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(n),s==null||s(n),e[n])})}),r}trackProp(e){i(this,Ee).add(e)}getCurrentQuery(){return i(this,v)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const s=i(this,U).defaultQueryOptions(e),r=i(this,U).getQueryCache().build(i(this,U),s);return r.fetch().then(()=>this.createResult(r,s))}fetch(e){return m(this,x,Fe).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),i(this,q)))}createResult(e,s){var E;const r=i(this,v),n=this.options,a=i(this,q),o=i(this,ue),u=i(this,Re),p=e!==r?e.state:i(this,Me),{state:b}=e;let h={...b},w=!1,S;if(s._optimisticResults){const C=this.hasListeners(),de=!C&&pt(e,s),fe=C&&mt(e,r,s,n);(de||fe)&&(h={...h,...kt(b.data,e.options)}),s._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:P,errorUpdatedAt:f,status:g}=h;if(s.select&&h.data!==void 0)if(a&&h.data===(o==null?void 0:o.data)&&s.select===i(this,Ie))S=i(this,Oe);else try{c(this,Ie,s.select),S=s.select(h.data),S=ze(a==null?void 0:a.data,S,s),c(this,Oe,S),c(this,W,null)}catch(C){c(this,W,C)}else S=h.data;if(s.placeholderData!==void 0&&S===void 0&&g==="pending"){let C;if(a!=null&&a.isPlaceholderData&&s.placeholderData===(u==null?void 0:u.placeholderData))C=a.data;else if(C=typeof s.placeholderData=="function"?s.placeholderData((E=i(this,Pe))==null?void 0:E.state.data,i(this,Pe)):s.placeholderData,s.select&&C!==void 0)try{C=s.select(C),c(this,W,null)}catch(de){c(this,W,de)}C!==void 0&&(g="success",S=ze(a==null?void 0:a.data,C,s),w=!0)}i(this,W)&&(P=i(this,W),S=i(this,Oe),f=Date.now(),g="error");const D=h.fetchStatus==="fetching",M=g==="pending",R=g==="error",Q=M&&D,k=S!==void 0,I={status:g,fetchStatus:h.fetchStatus,isPending:M,isSuccess:g==="success",isError:R,isInitialLoading:Q,isLoading:Q,data:S,dataUpdatedAt:h.dataUpdatedAt,error:P,errorUpdatedAt:f,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:h.dataUpdateCount>0||h.errorUpdateCount>0,isFetchedAfterMount:h.dataUpdateCount>p.dataUpdateCount||h.errorUpdateCount>p.errorUpdateCount,isFetching:D,isRefetching:D&&!M,isLoadingError:R&&!k,isPaused:h.fetchStatus==="paused",isPlaceholderData:w,isRefetchError:R&&k,isStale:at(e,s),refetch:this.refetch,promise:i(this,se)};if(this.options.experimental_prefetchInRender){const C=qe=>{I.status==="error"?qe.reject(I.error):I.data!==void 0&&qe.resolve(I.data)},de=()=>{const qe=c(this,se,I.promise=We());C(qe)},fe=i(this,se);switch(fe.status){case"pending":e.queryHash===r.queryHash&&C(fe);break;case"fulfilled":(I.status==="error"||I.data!==fe.value)&&de();break;case"rejected":(I.status!=="error"||I.error!==fe.reason)&&de();break}}return I}updateResult(e){const s=i(this,q),r=this.createResult(i(this,v),this.options);if(c(this,ue,i(this,v).state),c(this,Re,this.options),i(this,ue).data!==void 0&&c(this,Pe,i(this,v)),Be(r,s))return;c(this,q,r);const n={},a=()=>{if(!s)return!0;const{notifyOnChangeProps:o}=this.options,u=typeof o=="function"?o():o;if(u==="all"||!u&&!i(this,Ee).size)return!0;const l=new Set(u??i(this,Ee));return this.options.throwOnError&&l.add("error"),Object.keys(i(this,q)).some(p=>{const b=p;return i(this,q)[b]!==s[b]&&l.has(b)})};(e==null?void 0:e.listeners)!==!1&&a()&&(n.listeners=!0),m(this,x,Lt).call(this,{...n,...e})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&m(this,x,Xe).call(this)}},U=new WeakMap,v=new WeakMap,Me=new WeakMap,q=new WeakMap,ue=new WeakMap,Re=new WeakMap,se=new WeakMap,W=new WeakMap,Ie=new WeakMap,Oe=new WeakMap,Pe=new WeakMap,ce=new WeakMap,he=new WeakMap,re=new WeakMap,Ee=new WeakMap,x=new WeakSet,Fe=function(e){m(this,x,tt).call(this);let s=i(this,v).fetch(this.options,e);return e!=null&&e.throwOnError||(s=s.catch(_)),s},Ve=function(){m(this,x,Ze).call(this);const e=ye(this.options.staleTime,i(this,v));if(le||i(this,q).isStale||!Ge(e))return;const r=Qt(i(this,q).dataUpdatedAt,e)+1;c(this,ce,setTimeout(()=>{i(this,q).isStale||this.updateResult()},r))},Ye=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(i(this,v)):this.options.refetchInterval)??!1},Je=function(e){m(this,x,et).call(this),c(this,re,e),!(le||G(this.options.enabled,i(this,v))===!1||!Ge(i(this,re))||i(this,re)===0)&&c(this,he,setInterval(()=>{(this.options.refetchIntervalInBackground||nt.isFocused())&&m(this,x,Fe).call(this)},i(this,re)))},Xe=function(){m(this,x,Ve).call(this),m(this,x,Je).call(this,m(this,x,Ye).call(this))},Ze=function(){i(this,ce)&&(clearTimeout(i(this,ce)),c(this,ce,void 0))},et=function(){i(this,he)&&(clearInterval(i(this,he)),c(this,he,void 0))},tt=function(){const e=i(this,U).getQueryCache().build(i(this,U),this.options);if(e===i(this,v))return;const s=i(this,v);c(this,v,e),c(this,Me,e.state),this.hasListeners()&&(s==null||s.removeObserver(this),e.addObserver(this))},Lt=function(e){j.batch(()=>{e.listeners&&this.listeners.forEach(s=>{s(i(this,q))}),i(this,U).getQueryCache().notify({query:i(this,v),type:"observerResultsUpdated"})})},jt);function gs(t,e){return G(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function pt(t,e){return gs(t,e)||t.state.data!==void 0&&st(t,e,e.refetchOnMount)}function st(t,e,s){if(G(e.enabled,t)!==!1){const r=typeof s=="function"?s(t):s;return r==="always"||r!==!1&&at(t,e)}return!1}function mt(t,e,s,r){return(t!==e||G(r.enabled,t)===!1)&&(!s.suspense||t.state.status!=="error")&&at(t,s)}function at(t,e){return G(e.enabled,t)!==!1&&t.isStaleByTime(ye(e.staleTime,t))}function ws(t,e){return!Be(t.getCurrentResult(),e)}var Nt=F.createContext(void 0),xs=t=>{const e=F.useContext(Nt);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Ss=({client:t,children:e})=>(F.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),y.jsx(Nt.Provider,{value:t,children:e})),_t=F.createContext(!1),Cs=()=>F.useContext(_t);_t.Provider;function Rs(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Os=F.createContext(Rs()),Ps=()=>F.useContext(Os);function Es(t,e){return typeof t=="function"?t(...e):!!t}function vt(){}var Fs=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},Ds=t=>{F.useEffect(()=>{t.clearReset()},[t])},js=({result:t,errorResetBoundary:e,throwOnError:s,query:r})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&Es(s,[t.error,r]),Qs=t=>{t.suspense&&(t.staleTime===void 0&&(t.staleTime=1e3),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3)))},As=(t,e)=>t.isLoading&&t.isFetching&&!e,Ms=(t,e)=>(t==null?void 0:t.suspense)&&e.isPending,bt=(t,e,s)=>e.fetchOptimistic(t).catch(()=>{s.clearReset()});function Is(t,e,s){var b,h,w,S,P;const r=xs(),n=Cs(),a=Ps(),o=r.defaultQueryOptions(t);(h=(b=r.getDefaultOptions().queries)==null?void 0:b._experimental_beforeQuery)==null||h.call(b,o),o._optimisticResults=n?"isRestoring":"optimistic",Qs(o),Fs(o,a),Ds(a);const u=!r.getQueryCache().get(o.queryHash),[l]=F.useState(()=>new e(r,o)),p=l.getOptimisticResult(o);if(F.useSyncExternalStore(F.useCallback(f=>{const g=n?vt:l.subscribe(j.batchCalls(f));return l.updateResult(),g},[l,n]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),F.useEffect(()=>{l.setOptions(o,{listeners:!1})},[o,l]),Ms(o,p))throw bt(o,l,a);if(js({result:p,errorResetBoundary:a,throwOnError:o.throwOnError,query:r.getQueryCache().get(o.queryHash)}))throw p.error;if((S=(w=r.getDefaultOptions().queries)==null?void 0:w._experimental_afterQuery)==null||S.call(w,o,p),o.experimental_prefetchInRender&&!le&&As(p,n)){const f=u?bt(o,l,a):(P=r.getQueryCache().get(o.queryHash))==null?void 0:P.promise;f==null||f.catch(vt).finally(()=>{l.updateResult()})}return o.notifyOnChangeProps?p:l.trackResult(p)}function ot(t,e){return Is(t,bs)}const Ts=864e5,qs=/^\d{4}-\d{2}-\d{2}$/;function gt(t,e=Date.now()){return new Date(e-t*Ts).toISOString().slice(0,10)}function Us(t=30,e=Date.now()){return{fromDay:gt(t-1,e),toDay:gt(0,e)}}function ks(t){return qs.test(t)}function Kt(){return typeof window<"u"&&window.__AGENT_API__?window.__AGENT_API__:`${typeof window<"u"&&window.__AGENT_BASE__||"/ai-gateway"}/api`}async function He(t,e){const s=await fetch(Kt()+t,e);if(!s.ok)throw new Error(`${s.status} ${s.statusText}`);return await s.json()}const Ne={spend(t){const e=new URLSearchParams({from:t.fromDay,to:t.toDay});return He(`/spend?${e.toString()}`)},toolCalls(t=50){return He(`/tool-calls?limit=${t}`)},threads(t=50){return He(`/threads?limit=${t}`)},streamEvents(t){const e=new EventSource(`${Kt()}/stream`);return e.onmessage=s=>{try{t(JSON.parse(s.data))}catch{}},()=>e.close()}};function Ls(t){return ot({queryKey:["spend",t.fromDay,t.toDay],queryFn:()=>Ne.spend(t)})}function Ns(t=50){return ot({queryKey:["tool-calls",t],queryFn:()=>Ne.toolCalls(t)})}function _s(t=50){return ot({queryKey:["threads",t],queryFn:()=>Ne.threads(t)})}function Ks(t=200){const[e,s]=F.useState([]),[r,n]=F.useState(!1),a=F.useRef(0);return F.useEffect(()=>{n(!0);const o=Ne.streamEvents(u=>{a.current+=1,s(l=>Ht(l,u,a.current,t))});return()=>{n(!1),o()}},[t]),{events:e,connected:r}}const Hs=[{key:"spend",label:"Spend & usage",icon:y.jsx(Bt,{})},{key:"models",label:"Models",icon:y.jsx($t,{})},{key:"actors",label:"Actors & budgets",icon:y.jsx(zt,{})},{key:"runs",label:"Runs & tools",icon:y.jsx(Wt,{})},{key:"live",label:"Live",icon:y.jsx(Vt,{})}],Gs={byModel:[],byActor:[],trend:[]},Bs=[],$s=[];function zs(){const[t,e]=F.useState(Us()),[s,r]=F.useState("spend"),n=Ls(t),a=Ns(),o=_s(),u=Ks(),l=n.data??Gs;return y.jsxs("div",{className:"relative min-h-full",children:[y.jsx("div",{className:"app-bg"}),y.jsxs("div",{className:"relative z-10 mx-auto max-w-[1180px] px-5 py-5",children:[y.jsx(Vs,{range:t,onRange:e,connected:u.connected,liveCount:u.events.length}),y.jsx("nav",{className:"mb-5 flex flex-wrap gap-1",children:Hs.map(p=>y.jsxs("button",{type:"button",onClick:()=>r(p.key),className:`flex items-center gap-2 rounded-lg border px-3 py-1.5 text-xs transition-colors ${s===p.key?"border-[var(--accent)]/50 bg-[var(--accent)]/10 text-[var(--text)]":"border-transparent text-[var(--muted)] hover:text-[var(--text)]"}`,children:[p.icon,p.label,p.key==="live"&&u.events.length>0&&y.jsx("span",{className:"mono tnum rounded bg-[var(--accent)]/20 px-1 text-[10px] text-[var(--accent)]",children:u.events.length})]},p.key))}),y.jsx(Ws,{section:s,overview:l,loadingSpend:n.isLoading,errorSpend:n.isError,toolCalls:a.data??Bs,threads:o.data??$s,liveEvents:u.events,connected:u.connected})]})]})}function Ws({section:t,overview:e,loadingSpend:s,errorSpend:r,toolCalls:n,threads:a,liveEvents:o,connected:u}){if(r&&(t==="spend"||t==="models"||t==="actors"))return y.jsx("div",{className:"panel p-6 text-sm text-[var(--bad)]",children:"Failed to load the read-model. Is the governance read-model bound and the API reachable?"});if(s&&(t==="spend"||t==="models"||t==="actors"))return y.jsx("div",{className:"panel animate-pulse p-6 text-sm text-[var(--muted)]",children:"Loading…"});switch(t){case"spend":return y.jsx(es,{overview:e});case"models":return y.jsx(Zt,{rows:e.byModel});case"actors":return y.jsx(Xt,{rows:e.byActor});case"runs":return y.jsx(Jt,{toolCalls:n,threads:a});case"live":return y.jsx(Yt,{events:o,connected:u});default:return null}}function Vs({range:t,onRange:e,connected:s,liveCount:r}){return y.jsxs("header",{className:"mb-5 flex flex-wrap items-center gap-4",children:[y.jsxs("div",{className:"flex items-center gap-2.5",children:[y.jsx("div",{className:"grid h-8 w-8 place-items-center rounded-lg border border-[var(--accent)]/40 bg-[var(--accent)]/10",children:y.jsx(Gt,{className:"h-4 w-4 text-[var(--accent)]"})}),y.jsxs("div",{className:"leading-none",children:[y.jsx("div",{className:"text-sm font-semibold tracking-tight",children:"AI gateway"}),y.jsx("div",{className:"mono text-[10px] uppercase tracking-[0.2em] text-[var(--muted)]",children:"governance console"})]})]}),y.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[y.jsx(wt,{label:"From",value:t.fromDay,onChange:n=>e({...t,fromDay:n})}),y.jsx(wt,{label:"To",value:t.toDay,onChange:n=>e({...t,toDay:n})}),y.jsxs("span",{className:"flex items-center gap-1.5 rounded-lg border border-[var(--line)] px-2.5 py-1.5 text-[11px] text-[var(--muted)]",children:[y.jsx("span",{className:`dot ${s?"s-ok pulse":"s-failed"}`,"aria-hidden":!0}),"live ",r>0?`· ${r}`:""]})]})]})}function wt({label:t,value:e,onChange:s}){return y.jsxs("label",{className:"flex items-center gap-1.5 rounded-lg border border-[var(--line)] bg-[var(--panel)] px-2.5 py-1 text-[11px] text-[var(--muted)]",children:[y.jsx("span",{className:"uppercase tracking-wider",children:t}),y.jsx("input",{type:"date",value:e,onChange:r=>{const n=r.target.value;ks(n)&&s(n)},className:"mono bg-transparent text-[var(--text)] outline-none"})]})}const Ys=new vs({defaultOptions:{queries:{refetchInterval:5e3,refetchOnWindowFocus:!1,retry:1}}}),xt=document.getElementById("root");xt&&ts.createRoot(xt).render(y.jsx(F.StrictMode,{children:y.jsx(Ss,{client:Ys,children:y.jsx(zs,{})})}));
@@ -1 +0,0 @@
1
- import{c as l,j as e,r as c,L as i,S as u,M as m,b as p,R as h,a as x}from"./index-CVpU-HIB.js";const g=[{modelId:"gpt-4o",requests:4200,inputTokens:84e5,outputTokens:21e5,costUsd:84.2},{modelId:"claude-3-5-sonnet",requests:2600,inputTokens:52e5,outputTokens:13e5,costUsd:41.6},{modelId:"gpt-4o-mini",requests:9800,inputTokens:12e6,outputTokens:3e6,costUsd:9.4},{modelId:"llama-3-70b",requests:1200,inputTokens:21e5,outputTokens:64e4,costUsd:0}],v=[{actorRef:"tenant:acme",requests:8200,totalTokens:184e5,costUsd:78.1},{actorRef:"user:davi@goflip.ai",requests:3100,totalTokens:69e5,costUsd:34.2},{actorRef:"tenant:globex",requests:4400,totalTokens:92e5,costUsd:21.8},{actorRef:"user:ops-bot",requests:2100,totalTokens:394e4,costUsd:1.1}],w={"tenant:acme":2e7,"user:davi@goflip.ai":5e6,"tenant:globex":12e6};function S(){const a=[];for(let t=29;t>=0;t-=1){const d=new Date(Date.now()-t*864e5).toISOString().slice(0,10),n=Math.sin(t/3)*.5+1;a.push({day:d,totalTokens:Math.round(7e5*n+t*4e3),costUsd:Number((4.2*n+t*.05).toFixed(2))})}return a}const s={byModel:g,byActor:v,trend:S()},T=w,I=[{toolCallId:"tc1",toolName:"search_records",toolType:"read",status:"ok",threadId:"th1",createdAt:new Date(Date.now()-12e3).toISOString()},{toolCallId:"tc2",toolName:"delete_asset",toolType:"action",status:"forbidden",threadId:"th2",createdAt:new Date(Date.now()-9e4).toISOString()},{toolCallId:"tc3",toolName:"fetch_pricing",toolType:"read",status:"ok",threadId:"th1",createdAt:new Date(Date.now()-24e4).toISOString()},{toolCallId:"tc4",toolName:"send_email",toolType:"action",status:"failed",threadId:"th3",createdAt:new Date(Date.now()-62e4).toISOString()},{toolCallId:"tc5",toolName:"summarize_thread",toolType:"read",status:"ok",threadId:"th2",createdAt:new Date(Date.now()-12e5).toISOString()}],k=[{threadId:"th1",title:"Q3 procurement review",actorRef:"tenant:acme",messageCount:24,totalTokens:184e3,lastActivityAt:new Date(Date.now()-3e4).toISOString()},{threadId:"th2",title:"Incident triage",actorRef:"user:ops-bot",messageCount:11,totalTokens:62e3,lastActivityAt:new Date(Date.now()-4e5).toISOString()},{threadId:"th3",title:"Contract summary",actorRef:"user:davi@goflip.ai",messageCount:6,totalTokens:28400,lastActivityAt:new Date(Date.now()-18e5).toISOString()}],b=[{id:"e1",event:"run.started",ts:Date.now()-2e3,payload:{runId:"r-9f2",agentName:"analyst"}},{id:"e2",event:"tool-call",ts:Date.now()-5e3,payload:{toolName:"search_records",toolType:"read",status:"ok"}},{id:"e3",event:"quota.exceeded",ts:Date.now()-9e3,payload:{actorId:"tenant:globex",usedTokens:124e5,limitTokens:12e6}},{id:"e4",event:"tool-call",ts:Date.now()-14e3,payload:{toolName:"delete_asset",toolType:"action",status:"forbidden"}},{id:"e5",event:"delegated",ts:Date.now()-2e4,payload:{fromAgent:"router",toAgent:"billing-agent"}},{id:"e6",event:"run.finished",ts:Date.now()-26e3,payload:{runId:"r-8a1",steps:7,inputTokens:4200,outputTokens:1100}}];function D(){return e.jsxs("div",{className:"relative min-h-full",children:[e.jsx("div",{className:"app-bg"}),e.jsxs("div",{className:"relative z-10 mx-auto max-w-[1180px] space-y-6 px-5 py-6",children:[e.jsxs("header",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"grid h-8 w-8 place-items-center rounded-lg border border-[var(--accent)]/40 bg-[var(--accent)]/10",children:e.jsx(i,{className:"h-4 w-4 text-[var(--accent)]"})}),e.jsxs("div",{className:"leading-none",children:[e.jsx("div",{className:"text-sm font-semibold tracking-tight",children:"AI gateway — preview"}),e.jsx("div",{className:"mono text-[10px] uppercase tracking-[0.2em] text-[var(--muted)]",children:"mock data · no backend"})]})]}),e.jsx(o,{label:"Spend & usage",children:e.jsx(u,{overview:s})}),e.jsx(o,{label:"Models",children:e.jsx(m,{rows:s.byModel})}),e.jsx(o,{label:"Actors & budgets",children:e.jsx(p,{rows:s.byActor,budgets:T})}),e.jsx(o,{label:"Runs & tools",children:e.jsx(h,{toolCalls:I,threads:k})}),e.jsx(o,{label:"Live",children:e.jsx(x,{events:b,connected:!0})})]})]})}function o({label:a,children:t}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"mono text-[11px] uppercase tracking-[0.2em] text-[var(--muted)]",children:a}),t]})}const r=document.getElementById("root");r&&l.createRoot(r).render(e.jsx(c.StrictMode,{children:e.jsx(D,{})}));