@dudousxd/nestjs-agent-dashboard 0.15.2 → 0.15.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server/index.cjs +9 -9
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.js +14 -14
- package/dist/server/index.js.map +1 -1
- package/dist/spa/assets/base-ui-CWwgtV-8.js +41 -0
- package/dist/spa/assets/index-BkhmVSOi.js +25 -0
- package/dist/spa/assets/index-WO6ygoxH.js +1 -0
- package/dist/spa/assets/{preview-DD7Ge-bU.js → preview-DBglNCHg.js} +1 -1
- package/dist/spa/assets/{recharts-DSmxPXW6.js → recharts-El_Zr62O.js} +28 -28
- package/dist/spa/index.html +4 -4
- package/dist/spa/preview.html +4 -4
- package/package.json +15 -15
- package/dist/spa/assets/base-ui-CeQ9JhU_.js +0 -41
- package/dist/spa/assets/index-CTK2sMGd.js +0 -25
- package/dist/spa/assets/index-Cto4iy07.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var zt=t=>{throw TypeError(t)};var vt=(t,e,s)=>e.has(t)||zt("Cannot "+s);var n=(t,e,s)=>(vt(t,e,"read from private field"),s?s.call(t):e.get(t)),d=(t,e,s)=>e.has(t)?zt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),c=(t,e,s,r)=>(vt(t,e,"write to private field"),r?r.call(t,s):e.set(t,s),s),y=(t,e,s)=>(vt(t,e,"access private method"),s);var ut=(t,e,s,r)=>({set _(i){c(t,e,i,s)},get _(){return n(t,e,r)}});import{u as Cs,A as Ys,D as Zs,R as Xs,T as er,C as tr,E as sr,I as rr,a as nr,M as ir,S as ar,P as or,b as ur,c as cr,d as lr,e as hr,f as dr,p as fr,g as pr,h as yr,U as mr,W as Vt,i as gr,j as vr,k as br,l as Sr,m as wr,B as Ps,n as Cr,o as Pr,L as xr,q as Rr,r as Or,s as Tr,t as Er,v as jr}from"./index-BkhmVSOi.js";import{r as b,j as l,P as Dr,b as Fr,d as Qr,e as Ir,f as Mr}from"./base-ui-CWwgtV-8.js";import"./recharts-El_Zr62O.js";const xs=b.createContext(void 0),ot=t=>{const e=b.useContext(xs);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Ar=({client:t,children:e})=>(b.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),l.jsx(xs.Provider,{value:t,children:e})),qr={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)};var ce,Nt,ls,kr=(ls=class{constructor(){d(this,ce,qr);d(this,Nt,!1)}setTimeoutProvider(t){c(this,ce,t)}setTimeout(t,e){return n(this,ce).setTimeout(t,e)}clearTimeout(t){n(this,ce).clearTimeout(t)}setInterval(t,e){return n(this,ce).setInterval(t,e)}clearInterval(t){n(this,ce).clearInterval(t)}},ce=new WeakMap,Nt=new WeakMap,ls);const be=new kr;function Nr(t){setTimeout(t,0)}const Ur=typeof window>"u"||"Deno"in globalThis;function U(){}function Lr(t,e){return typeof t=="function"?t(e):t}function Rs(t){return typeof t=="number"&&t>=0&&t!==1/0}function Os(t,e){return Math.max(t+(e||0)-Date.now(),0)}function j(t,e){return typeof t=="function"?t(e):t}function Jt(t,e){const{type:s="all",exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:u}=t;if(o){if(r){if(e.queryHash!==Ut(o,e.options))return!1}else if(!ze(e.queryKey,o))return!1}if(s!=="all"){const h=e.isActive();if(s==="active"&&!h||s==="inactive"&&h)return!1}return!(typeof u=="boolean"&&e.isStale()!==u||i&&i!==e.state.fetchStatus||a&&!a(e))}function Yt(t,e){const{exact:s,status:r,predicate:i,mutationKey:a}=t;if(a){if(!e.options.mutationKey)return!1;if(s){if(Fe(e.options.mutationKey)!==Fe(a))return!1}else if(!ze(e.options.mutationKey,a))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function Ut(t,e){return((e==null?void 0:e.queryKeyHashFn)||Fe)(t)}function Fe(t){return JSON.stringify(t,(e,s)=>bt(s)?Object.keys(s).sort().reduce((r,i)=>(r[i]=s[i],r),{}):s)}function ze(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(t&&e&&typeof t=="object"&&typeof e=="object"){if(Array.isArray(t)&&Array.isArray(e)){if(e.length>t.length)return!1;for(let r=0;r<e.length;r++)if(!ze(t[r],e[r]))return!1;return!0}const s=Object.keys(e);for(const r of s)if(!ze(t[r],e[r]))return!1;return!0}return!1}const Kr=Object.prototype.hasOwnProperty;function Lt(t,e,s=0){if(t===e)return t;if(s>500)return e;const r=Zt(t)&&Zt(e);if(!r&&!(bt(t)&&bt(e)))return e;const i=(r?t:Object.keys(t)).length,a=r?e:Object.keys(e),o=a.length,u=r?new Array(o):{};let h=0;for(let g=0;g<o;g++){const p=r?g:a[g],m=t[p],f=e[p];if(m===f){u[p]=m,(r?g<i:Kr.call(t,p))&&h++;continue}if(m===null||f===null||typeof m!="object"||typeof f!="object"){u[p]=f;continue}const C=Lt(m,f,s+1);u[p]=C,C===m&&h++}return i===o&&h===i?t:u}function Ye(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 Zt(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function bt(t){if(!Xt(t))return!1;const e=Object.getPrototypeOf(t),s=e==null?void 0:e.constructor;if(s===void 0)return!0;if(typeof s!="function")return!1;const r=s.prototype;return!(!Xt(r)||!r.hasOwnProperty("isPrototypeOf")||e!==Object.prototype)}function Xt(t){return Object.prototype.toString.call(t)==="[object Object]"}function _r(t){return new Promise(e=>{be.setTimeout(e,t)})}function St(t,e,s){return typeof s.structuralSharing=="function"?s.structuralSharing(t,e):s.structuralSharing!==!1?Lt(t,e):e}function pt(t){return t}function $r(t,e,s=0){const r=[...t,e];return s&&r.length>s?r.slice(1):r}function Hr(t,e,s=0){const r=[e,...t];return s&&r.length>s?r.slice(0,-1):r}const Kt=Symbol();function Ts(t,e){return!t.queryFn&&(e!=null&&e.initialPromise)?()=>e.initialPromise:!t.queryFn||t.queryFn===Kt?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function _t(t,e){return typeof t=="function"?t(...e):!!t}function Br(t,e,s){let r=!1,i;return Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(i??(i=e()),r||(r=!0,i.aborted?s():i.addEventListener("abort",s,{once:!0})),i)}),t}let Gr=()=>Ur;const $t=()=>Gr();var Qe=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(){}},Se,le,Ie,hs,Wr=(hs=class extends Qe{constructor(){super();d(this,Se);d(this,le);d(this,Ie);c(this,Ie,e=>{if(typeof window<"u"&&window.addEventListener){const s=()=>e();return window.addEventListener("visibilitychange",s,!1),()=>{window.removeEventListener("visibilitychange",s)}}})}onSubscribe(){n(this,le)||this.setEventListener(n(this,Ie))}onUnsubscribe(){var e;this.hasListeners()||((e=n(this,le))==null||e.call(this),c(this,le,void 0))}setEventListener(e){var s;c(this,Ie,e),(s=n(this,le))==null||s.call(this),c(this,le,e(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(e){n(this,Se)!==e&&(c(this,Se,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(s=>{s(e)})}isFocused(){var e;return typeof n(this,Se)=="boolean"?n(this,Se):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},Se=new WeakMap,le=new WeakMap,Ie=new WeakMap,hs);const Ht=new Wr,zr=Nr;function Vr(){let t=[],e=0,s=u=>{u()},r=u=>{u()},i=zr;const a=u=>{e?t.push(u):i(()=>{s(u)})},o=()=>{const u=t;t=[],u.length&&i(()=>{r(()=>{u.forEach(h=>{s(h)})})})};return{batch:u=>{let h;e++;try{h=u()}finally{e--,e||o()}return h},batchCalls:u=>(...h)=>{a(()=>{u(...h)})},schedule:a,setNotifyFunction:u=>{s=u},setBatchNotifyFunction:u=>{r=u},setScheduler:u=>{i=u}}}const Q=Vr();var Me,he,Ae,ds,Jr=(ds=class extends Qe{constructor(){super();d(this,Me,!0);d(this,he);d(this,Ae);c(this,Ae,e=>{if(typeof window<"u"&&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(){n(this,he)||this.setEventListener(n(this,Ae))}onUnsubscribe(){var e;this.hasListeners()||((e=n(this,he))==null||e.call(this),c(this,he,void 0))}setEventListener(e){var s;c(this,Ae,e),(s=n(this,he))==null||s.call(this),c(this,he,e(this.setOnline.bind(this)))}setOnline(e){n(this,Me)!==e&&(c(this,Me,e),this.listeners.forEach(s=>{s(e)}))}isOnline(){return n(this,Me)}},Me=new WeakMap,he=new WeakMap,Ae=new WeakMap,ds);const dt=new Jr;function Yr(t){return Math.min(1e3*2**t,3e4)}function Es(t){return(t??"online")==="online"?dt.isOnline():!0}var wt=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function js(t){let e=!1,s=0,r,i="pending",a,o;const u=new Promise((x,R)=>{a=x,o=R});u.catch(U);const h=()=>i!=="pending",g=x=>{var R;if(!h()){const T=new wt(x);S(T),(R=t.onCancel)==null||R.call(t,T)}},p=()=>{e=!0},m=()=>{e=!1},f=()=>Ht.isFocused()&&(t.networkMode==="always"||dt.isOnline())&&t.canRun(),C=()=>Es(t.networkMode)&&t.canRun(),I=x=>{h()||(r==null||r(),i="resolved",a(x))},S=x=>{h()||(r==null||r(),i="rejected",o(x))},w=()=>new Promise(x=>{var R;r=T=>{(h()||f())&&x(T)},(R=t.onPause)==null||R.call(t)}).then(()=>{var x;r=void 0,h()||(x=t.onContinue)==null||x.call(t)}),E=()=>{if(h())return;let x;const R=s===0?t.initialPromise:void 0;try{x=R??t.fn()}catch(T){x=Promise.reject(T)}Promise.resolve(x).then(I).catch(T=>{var D;if(h())return;const v=t.retry??($t()?0:3),K=t.retryDelay??Yr,M=typeof K=="function"?K(s,T):K,J=v===!0||typeof v=="number"&&s<v||typeof v=="function"&&v(s,T);if(e||!J){S(T);return}s++,(D=t.onFail)==null||D.call(t,s,T),_r(M).then(()=>f()?void 0:w()).then(()=>{e?S(T):E()})})};return{promise:u,status:()=>i,cancel:g,continue:()=>(r==null||r(),u),cancelRetry:p,continueRetry:m,canStart:C,start:()=>(C()?E():w().then(E),u)}}var we,fs,Ds=(fs=class{constructor(){d(this,we)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Rs(this.gcTime)&&c(this,we,be.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??($t()?1/0:3e5))}clearGcTimeout(){n(this,we)!==void 0&&(be.clearTimeout(n(this,we)),c(this,we,void 0))}},we=new WeakMap,fs);function Zr(t){return{onFetch:(e,s)=>{var p,m,f,C,I;const r=e.options,i=(f=(m=(p=e.fetchOptions)==null?void 0:p.meta)==null?void 0:m.fetchMore)==null?void 0:f.direction,a=((C=e.state.data)==null?void 0:C.pages)||[],o=((I=e.state.data)==null?void 0:I.pageParams)||[];let u={pages:[],pageParams:[]},h=0;const g=async()=>{let S=!1;const w=R=>{Br(R,()=>e.signal,()=>S=!0)},E=Ts(e.options,e.fetchOptions),x=async(R,T,v)=>{if(S)return Promise.reject(e.signal.reason);if(T==null&&R.pages.length)return Promise.resolve(R);const M=(()=>{const Wt={client:e.client,queryKey:e.queryKey,pageParam:T,direction:v?"backward":"forward",meta:e.options.meta};return w(Wt),Wt})(),J=await E(M),{maxPages:D}=e.options,_=v?Hr:$r;return{pages:_(R.pages,J,D),pageParams:_(R.pageParams,T,D)}};if(i&&a.length){const R=i==="backward",T=R?Xr:es,v={pages:a,pageParams:o};u=await x(v,T(r,v),R)}else{const R=t??a.length;do{const T=h===0?o[0]??r.initialPageParam:es(r,u);if(h>0&&T==null)break;u=await x(u,T),h++}while(h<R)}return u};e.options.persister?e.fetchFn=()=>{var S,w;return(w=(S=e.options).persister)==null?void 0:w.call(S,g,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},s)}:e.fetchFn=g}}}function es(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 Xr(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 qe,Ce,ke,V,Pe,A,Ze,xe,Y,re,ps,en=(ps=class extends Ds{constructor(e){super();d(this,Y);d(this,qe);d(this,Ce);d(this,ke);d(this,V);d(this,Pe);d(this,A);d(this,Ze);d(this,xe);c(this,xe,!1),c(this,Ze,e.defaultOptions),this.setOptions(e.options),this.observers=[],c(this,Pe,e.client),c(this,V,n(this,Pe).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,c(this,Ce,ss(this.options)),this.state=e.state??n(this,Ce),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return n(this,qe)}get promise(){var e;return(e=n(this,A))==null?void 0:e.promise}setOptions(e){if(this.options={...n(this,Ze),...e},e!=null&&e._type&&c(this,qe,e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const s=ss(this.options);s.data!==void 0&&(this.setState(ts(s.data,s.dataUpdatedAt)),c(this,Ce,s))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&n(this,V).remove(this)}setData(e,s){const r=St(this.state.data,e,this.options);return y(this,Y,re).call(this,{data:r,type:"success",dataUpdatedAt:s==null?void 0:s.updatedAt,manual:s==null?void 0:s.manual}),r}setState(e){y(this,Y,re).call(this,{type:"setState",state:e})}cancel(e){var r,i;const s=(r=n(this,A))==null?void 0:r.promise;return(i=n(this,A))==null||i.cancel(e),s?s.then(U).catch(U):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return n(this,Ce)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>j(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Kt||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>j(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!Os(this.state.dataUpdatedAt,e)}onFocus(){var e,s;(e=this.observers.find(r=>r.shouldFetchOnWindowFocus()))==null||e.refetch({cancelRefetch:!1}),(s=n(this,A))==null||s.continue()}onOnline(){var e,s;(e=this.observers.find(r=>r.shouldFetchOnReconnect()))==null||e.refetch({cancelRefetch:!1}),(s=n(this,A))==null||s.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),n(this,V).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){const s=this.observers.indexOf(e);s!==-1&&(this.observers.splice(s,1),this.observers.length||(n(this,A)&&(n(this,xe)||this.state.fetchStatus==="paused"&&this.state.status==="pending"?n(this,A).cancel({revert:!0}):n(this,A).cancelRetry()),this.scheduleGc()),n(this,V).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||y(this,Y,re).call(this,{type:"invalidate"})}async fetch(e,s){var g,p,m,f,C,I,S,w,E,x,R,T;if(this.state.fetchStatus!=="idle"&&((g=n(this,A))==null?void 0:g.status())!=="rejected"){if(this.state.data!==void 0&&(s!=null&&s.cancelRefetch))this.cancel({silent:!0});else if(n(this,A))return n(this,A).continueRetry(),n(this,A).promise}if(e&&this.setOptions(e),!this.options.queryFn){const v=this.observers.find(K=>K.options.queryFn);v&&this.setOptions(v.options)}const r=new AbortController,i=v=>{Object.defineProperty(v,"signal",{enumerable:!0,get:()=>(c(this,xe,!0),r.signal)})},a=()=>{const v=Ts(this.options,s),M=(()=>{const J={client:n(this,Pe),queryKey:this.queryKey,meta:this.meta};return i(J),J})();return c(this,xe,!1),this.options.persister?this.options.persister(v,M,this):v(M)},u=(()=>{const v={fetchOptions:s,options:this.options,queryKey:this.queryKey,client:n(this,Pe),state:this.state,fetchFn:a};return i(v),v})();(p=n(this,qe)==="infinite"?Zr(this.options.pages):this.options.behavior)==null||p.onFetch(u,this),c(this,ke,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((m=u.fetchOptions)==null?void 0:m.meta))&&y(this,Y,re).call(this,{type:"fetch",meta:(f=u.fetchOptions)==null?void 0:f.meta});const h=c(this,A,js({initialPromise:s==null?void 0:s.initialPromise,fn:u.fetchFn,onCancel:v=>{v instanceof wt&&v.revert&&this.setState({...n(this,ke),fetchStatus:"idle"}),r.abort()},onFail:(v,K)=>{y(this,Y,re).call(this,{type:"failed",failureCount:v,error:K})},onPause:()=>{y(this,Y,re).call(this,{type:"pause"})},onContinue:()=>{y(this,Y,re).call(this,{type:"continue"})},retry:u.options.retry,retryDelay:u.options.retryDelay,networkMode:u.options.networkMode,canRun:()=>!0}));try{const v=await h.start();if(v===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(v),(I=(C=n(this,V).config).onSuccess)==null||I.call(C,v,this),(w=(S=n(this,V).config).onSettled)==null||w.call(S,v,this.state.error,this),v}catch(v){if(v instanceof wt){if(v.silent)return n(this,A).promise;if(v.revert){if(this.state.data===void 0)throw v;return this.state.data}}throw y(this,Y,re).call(this,{type:"error",error:v}),(x=(E=n(this,V).config).onError)==null||x.call(E,v,this),(T=(R=n(this,V).config).onSettled)==null||T.call(R,this.state.data,v,this),v}finally{n(this,A)===h&&c(this,A,void 0),this.scheduleGc()}}},qe=new WeakMap,Ce=new WeakMap,ke=new WeakMap,V=new WeakMap,Pe=new WeakMap,A=new WeakMap,Ze=new WeakMap,xe=new WeakMap,Y=new WeakSet,re=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,...Fs(r.data,this.options),fetchMeta:e.meta??null};case"success":const i={...r,...ts(e.data,e.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return c(this,ke,e.manual?i:void 0),i;case"error":const a=e.error;return{...r,error:a,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...e.state}}};this.state=s(this.state),Q.batch(()=>{this.observers.slice().forEach(r=>{r.onQueryUpdate()}),n(this,V).notify({query:this,type:"updated",action:e})})},ps);function Fs(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Es(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function ts(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function ss(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 H,P,Xe,B,Re,Ne,ne,et,Ue,Le,Oe,Te,de,Ke,O,Ve,Ct,Pt,xt,Rt,Ot,Tt,Et,jt,ys,yt=(ys=class extends Qe{constructor(e,s){super();d(this,O);d(this,H);d(this,P);d(this,Xe);d(this,B);d(this,Re);d(this,Ne);d(this,ne);d(this,et);d(this,Ue);d(this,Le);d(this,Oe);d(this,Te);d(this,de);d(this,Ke,new Set);this.options=s,c(this,H,e),c(this,ne,null),this.bindMethods(),this.setOptions(s)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(n(this,P).addObserver(this),rs(n(this,P),this.options)?y(this,O,Ve).call(this):this.updateResult(),y(this,O,Ot).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Dt(n(this,P),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Dt(n(this,P),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,y(this,O,Tt).call(this),y(this,O,Et).call(this),n(this,P).removeObserver(this)}setOptions(e){const s=this.options,r=n(this,P);if(this.options=n(this,H).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof j(this.options.enabled,n(this,P))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");y(this,O,jt).call(this),n(this,P).setOptions(this.options),s._defaulted&&!Ye(this.options,s)&&n(this,H).getQueryCache().notify({type:"observerOptionsUpdated",query:n(this,P),observer:this});const i=this.hasListeners();i&&ns(n(this,P),r,this.options,s)&&y(this,O,Ve).call(this),this.updateResult(),i&&(n(this,P)!==r||j(this.options.enabled,n(this,P))!==j(s.enabled,n(this,P))||j(this.options.staleTime,n(this,P))!==j(s.staleTime,n(this,P)))&&y(this,O,Pt).call(this);const a=y(this,O,xt).call(this);i&&(n(this,P)!==r||j(this.options.enabled,n(this,P))!==j(s.enabled,n(this,P))||a!==n(this,de))&&y(this,O,Rt).call(this,a)}getOptimisticResult(e){const s=n(this,H).getQueryCache().build(n(this,H),e),r=this.createResult(s,e);return Ye(this.getCurrentResult(),r)||(c(this,B,r),c(this,Ne,this.options),c(this,Re,n(this,P).state)),r}getCurrentResult(){return n(this,B)}trackResult(e,s){return new Proxy(e,{get:(r,i)=>(this.trackProp(i),s==null||s(i),Reflect.get(r,i))})}trackProp(e){n(this,Ke).add(e)}getCurrentQuery(){return n(this,P)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const s=n(this,H).defaultQueryOptions(e),r=n(this,H).getQueryCache().build(n(this,H),s);let i=()=>{},a;const o=new Promise(u=>{a=u,i=n(this,H).getQueryCache().subscribe(h=>{h.type==="updated"&&h.query.queryHash===r.queryHash&&r.state.data!==void 0&&(i(),u(this.createResult(r,s)))})});return Promise.race([r.fetch().then(()=>{const u=this.createResult(r,s);return a==null||a(u),u}).finally(()=>{i()}),o])}fetch(e){return y(this,O,Ve).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),n(this,B)))}createResult(e,s){var K;const r=n(this,P),i=this.options,a=n(this,B),o=n(this,Re),u=n(this,Ne),h=e!==r?e.state:n(this,Xe),{state:g}=e;let p={...g},m=!1,f;if(s._optimisticResults){const M=this.hasListeners(),J=!M&&rs(e,s),D=M&&ns(e,r,s,i);(J||D)&&(p={...p,...Fs(g.data,e.options)}),s._optimisticResults==="isRestoring"&&(p.fetchStatus="idle")}let{error:C,errorUpdatedAt:I,status:S}=p;f=p.data;let w=!1;if(s.placeholderData!==void 0&&f===void 0&&S==="pending"){let M;a!=null&&a.isPlaceholderData&&s.placeholderData===(u==null?void 0:u.placeholderData)?(M=a.data,w=!0):M=typeof s.placeholderData=="function"?s.placeholderData((K=n(this,Le))==null?void 0:K.state.data,n(this,Le)):s.placeholderData,M!==void 0&&(S="success",f=St(a==null?void 0:a.data,M,s),m=!0)}if(s.select&&f!==void 0&&!w)if(a&&f===(o==null?void 0:o.data)&&s.select===n(this,et))f=n(this,Ue);else try{c(this,et,s.select),f=s.select(f),f=St(a==null?void 0:a.data,f,s),c(this,Ue,f),c(this,ne,null)}catch(M){c(this,ne,M)}else f===void 0&&c(this,ne,null);n(this,ne)&&(C=n(this,ne),f=n(this,Ue),I=Date.now(),S="error",m=!1);const E=p.fetchStatus==="fetching",x=S==="pending",R=S==="error",T=x&&E,v=f!==void 0;return{status:S,fetchStatus:p.fetchStatus,isPending:x,isSuccess:S==="success",isError:R,isInitialLoading:T,isLoading:T,data:f,dataUpdatedAt:p.dataUpdatedAt,error:C,errorUpdatedAt:I,failureCount:p.fetchFailureCount,failureReason:p.fetchFailureReason,errorUpdateCount:p.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:p.dataUpdateCount>h.dataUpdateCount||p.errorUpdateCount>h.errorUpdateCount,isFetching:E,isRefetching:E&&!x,isLoadingError:R&&!v,isPaused:p.fetchStatus==="paused",isPlaceholderData:m,isRefetchError:R&&v,isStale:Bt(e,s),refetch:this.refetch,isEnabled:j(s.enabled,e)!==!1}}updateResult(){const e=n(this,B),s=this.createResult(n(this,P),this.options);if(c(this,Re,n(this,P).state),c(this,Ne,this.options),n(this,Re).data!==void 0&&c(this,Le,n(this,P)),Ye(s,e))return;c(this,B,s);const i=(()=>{if(!e)return!0;const{notifyOnChangeProps:a}=this.options,o=typeof a=="function"?a():a;if(o==="all"||!o&&!n(this,Ke).size)return!0;const u=new Set(o??n(this,Ke));return this.options.throwOnError&&u.add("error"),Object.keys(n(this,B)).some(h=>{const g=h;return n(this,B)[g]!==e[g]&&u.has(g)})})();Q.batch(()=>{i&&this.listeners.forEach(a=>{a(n(this,B))}),n(this,H).getQueryCache().notify({query:n(this,P),type:"observerResultsUpdated"})})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&y(this,O,Ot).call(this)}},H=new WeakMap,P=new WeakMap,Xe=new WeakMap,B=new WeakMap,Re=new WeakMap,Ne=new WeakMap,ne=new WeakMap,et=new WeakMap,Ue=new WeakMap,Le=new WeakMap,Oe=new WeakMap,Te=new WeakMap,de=new WeakMap,Ke=new WeakMap,O=new WeakSet,Ve=function(e){y(this,O,jt).call(this);let s=n(this,P).fetch(this.options,e);return e!=null&&e.throwOnError||(s=s.catch(U)),s},Ct=function(e){return!$t()&&j(this.options.enabled,n(this,P))!==!1&&Rs(e)},Pt=function(){y(this,O,Tt).call(this);const e=j(this.options.staleTime,n(this,P));if(n(this,B).isStale||!y(this,O,Ct).call(this,e))return;const s=Os(n(this,B).dataUpdatedAt,e)+1;c(this,Oe,be.setTimeout(()=>{n(this,B).isStale||this.updateResult()},s))},xt=function(){return j(this.options.refetchInterval,n(this,P))??!1},Rt=function(e){y(this,O,Et).call(this),c(this,de,e),!(n(this,de)===0||!y(this,O,Ct).call(this,n(this,de)))&&c(this,Te,be.setInterval(()=>{(this.options.refetchIntervalInBackground||Ht.isFocused())&&y(this,O,Ve).call(this)},n(this,de)))},Ot=function(){y(this,O,Pt).call(this),y(this,O,Rt).call(this,y(this,O,xt).call(this))},Tt=function(){n(this,Oe)!==void 0&&(be.clearTimeout(n(this,Oe)),c(this,Oe,void 0))},Et=function(){n(this,Te)!==void 0&&(be.clearInterval(n(this,Te)),c(this,Te,void 0))},jt=function(){const e=n(this,H).getQueryCache().build(n(this,H),this.options);if(e===n(this,P))return;const s=n(this,P);c(this,P,e),c(this,Xe,e.state),this.hasListeners()&&(s==null||s.removeObserver(this),e.addObserver(this))},ys);function tn(t,e){return j(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&j(e.retryOnMount,t)===!1)}function rs(t,e){return tn(t,e)||t.state.data!==void 0&&Dt(t,e,e.refetchOnMount)}function Dt(t,e,s){if(j(e.enabled,t)!==!1&&j(e.staleTime,t)!=="static"){const r=j(s,t);return r==="always"||r!==!1&&Bt(t,e)}return!1}function ns(t,e,s,r){return(t!==e||j(r.enabled,t)===!1)&&(!s.suspense||t.state.status!=="error")&&Bt(t,s)}function Bt(t,e){return j(e.enabled,t)!==!1&&t.isStaleByTime(j(e.staleTime,t))}var tt,X,k,Ee,ee,ue,ms,sn=(ms=class extends Ds{constructor(e){super();d(this,ee);d(this,tt);d(this,X);d(this,k);d(this,Ee);c(this,tt,e.client),this.mutationId=e.mutationId,c(this,k,e.mutationCache),c(this,X,[]),this.state=e.state||Qs(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){n(this,X).includes(e)||(n(this,X).push(e),this.clearGcTimeout(),n(this,k).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){c(this,X,n(this,X).filter(s=>s!==e)),this.scheduleGc(),n(this,k).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){n(this,X).length||(this.state.status==="pending"?this.scheduleGc():n(this,k).remove(this))}continue(){var e;return((e=n(this,Ee))==null?void 0:e.continue())??(this.state.status==="pending"?this.execute(this.state.variables):Promise.resolve())}async execute(e){var u,h,g,p,m,f,C,I,S,w,E,x,R,T,v,K,M,J;const s=()=>{y(this,ee,ue).call(this,{type:"continue"})},r={client:n(this,tt),meta:this.options.meta,mutationKey:this.options.mutationKey},i=c(this,Ee,js({fn:()=>this.options.mutationFn?this.options.mutationFn(e,r):Promise.reject(new Error("No mutationFn found")),onFail:(D,_)=>{y(this,ee,ue).call(this,{type:"failed",failureCount:D,error:_})},onPause:()=>{y(this,ee,ue).call(this,{type:"pause"})},onContinue:s,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>n(this,k).canRun(this)})),a=this.state.status==="pending",o=!i.canStart();try{if(a)s();else{y(this,ee,ue).call(this,{type:"pending",variables:e,isPaused:o}),n(this,k).config.onMutate&&await n(this,k).config.onMutate(e,this,r);const _=await((h=(u=this.options).onMutate)==null?void 0:h.call(u,e,r));_!==this.state.context&&y(this,ee,ue).call(this,{type:"pending",context:_,variables:e,isPaused:o})}const D=await i.start();return await((p=(g=n(this,k).config).onSuccess)==null?void 0:p.call(g,D,e,this.state.context,this,r)),await((f=(m=this.options).onSuccess)==null?void 0:f.call(m,D,e,this.state.context,r)),await((I=(C=n(this,k).config).onSettled)==null?void 0:I.call(C,D,null,this.state.variables,this.state.context,this,r)),await((w=(S=this.options).onSettled)==null?void 0:w.call(S,D,null,e,this.state.context,r)),y(this,ee,ue).call(this,{type:"success",data:D}),D}catch(D){try{await((x=(E=n(this,k).config).onError)==null?void 0:x.call(E,D,e,this.state.context,this,r))}catch(_){Promise.reject(_)}try{await((T=(R=this.options).onError)==null?void 0:T.call(R,D,e,this.state.context,r))}catch(_){Promise.reject(_)}try{await((K=(v=n(this,k).config).onSettled)==null?void 0:K.call(v,void 0,D,this.state.variables,this.state.context,this,r))}catch(_){Promise.reject(_)}try{await((J=(M=this.options).onSettled)==null?void 0:J.call(M,void 0,D,e,this.state.context,r))}catch(_){Promise.reject(_)}throw y(this,ee,ue).call(this,{type:"error",error:D}),D}finally{n(this,Ee)===i&&c(this,Ee,void 0),n(this,k).runNext(this)}}},tt=new WeakMap,X=new WeakMap,k=new WeakMap,Ee=new WeakMap,ee=new WeakSet,ue=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),Q.batch(()=>{n(this,X).forEach(r=>{r.onMutationUpdate(e)}),n(this,k).notify({mutation:this,type:"updated",action:e})})},ms);function Qs(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var ie,Z,st,gs,rn=(gs=class extends Qe{constructor(e={}){super();d(this,ie);d(this,Z);d(this,st);this.config=e,c(this,ie,new Set),c(this,Z,new Map),c(this,st,0)}build(e,s,r){const i=new sn({client:e,mutationCache:this,mutationId:++ut(this,st)._,options:e.defaultMutationOptions(s),state:r});return this.add(i),i}add(e){n(this,ie).add(e);const s=ct(e);if(typeof s=="string"){const r=n(this,Z).get(s);r?r.push(e):n(this,Z).set(s,[e])}this.notify({type:"added",mutation:e})}remove(e){if(n(this,ie).delete(e)){const s=ct(e);if(typeof s=="string"){const r=n(this,Z).get(s);if(r)if(r.length>1){const i=r.indexOf(e);i!==-1&&r.splice(i,1)}else r[0]===e&&n(this,Z).delete(s)}}this.notify({type:"removed",mutation:e})}canRun(e){var r;const s=ct(e);if(typeof s=="string"){const i=(r=n(this,Z).get(s))==null?void 0:r.find(a=>a.state.status==="pending");return!i||i===e}else return!0}runNext(e){var r,i;const s=ct(e);return typeof s=="string"?((i=(r=n(this,Z).get(s))==null?void 0:r.find(a=>a!==e&&a.state.isPaused))==null?void 0:i.continue())??Promise.resolve():Promise.resolve()}clear(){Q.batch(()=>{n(this,ie).forEach(e=>{this.notify({type:"removed",mutation:e})}),n(this,ie).clear(),n(this,Z).clear()})}getAll(){return Array.from(n(this,ie))}find(e){const s={exact:!0,...e};return this.getAll().find(r=>Yt(s,r))}findAll(e={}){return this.getAll().filter(s=>Yt(e,s))}notify(e){Q.batch(()=>{this.listeners.forEach(s=>{s(e)})})}resumePausedMutations(){const e=this.getAll().filter(s=>s.state.isPaused);return Q.batch(()=>Promise.all(e.map(s=>s.continue().catch(U))))}},ie=new WeakMap,Z=new WeakMap,st=new WeakMap,gs);function ct(t){var e;return(e=t.options.scope)==null?void 0:e.id}var ae,fe,N,oe,se,Je,Ft,vs,nn=(vs=class extends Qe{constructor(e,s){super();d(this,se);d(this,ae);d(this,fe);d(this,N);d(this,oe);c(this,ae,e),this.setOptions(s),this.bindMethods(),y(this,se,Je).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){var r;const s=this.options;this.options=n(this,ae).defaultMutationOptions(e),Ye(this.options,s)||n(this,ae).getMutationCache().notify({type:"observerOptionsUpdated",mutation:n(this,N),observer:this}),s!=null&&s.mutationKey&&this.options.mutationKey&&Fe(s.mutationKey)!==Fe(this.options.mutationKey)?this.reset():((r=n(this,N))==null?void 0:r.state.status)==="pending"&&n(this,N).setOptions(this.options)}onSubscribe(){this.listeners.size===1&&n(this,N)&&(n(this,N).addObserver(this),y(this,se,Je).call(this))}onUnsubscribe(){var e;this.hasListeners()||(e=n(this,N))==null||e.removeObserver(this)}onMutationUpdate(e){y(this,se,Je).call(this),y(this,se,Ft).call(this,e)}getCurrentResult(){return n(this,fe)}reset(){var e;(e=n(this,N))==null||e.removeObserver(this),c(this,N,void 0),y(this,se,Je).call(this),y(this,se,Ft).call(this)}mutate(e,s){var r;return c(this,oe,s),(r=n(this,N))==null||r.removeObserver(this),c(this,N,n(this,ae).getMutationCache().build(n(this,ae),this.options)),n(this,N).addObserver(this),n(this,N).execute(e)}},ae=new WeakMap,fe=new WeakMap,N=new WeakMap,oe=new WeakMap,se=new WeakSet,Je=function(){var s;const e=((s=n(this,N))==null?void 0:s.state)??Qs();c(this,fe,{...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset})},Ft=function(e){Q.batch(()=>{var s,r,i,a,o,u,h,g;if(n(this,oe)&&this.hasListeners()){const p=n(this,fe).variables,m=n(this,fe).context,f={client:n(this,ae),meta:this.options.meta,mutationKey:this.options.mutationKey};if((e==null?void 0:e.type)==="success"){try{(r=(s=n(this,oe)).onSuccess)==null||r.call(s,e.data,p,m,f)}catch(C){Promise.reject(C)}try{(a=(i=n(this,oe)).onSettled)==null||a.call(i,e.data,null,p,m,f)}catch(C){Promise.reject(C)}}else if((e==null?void 0:e.type)==="error"){try{(u=(o=n(this,oe)).onError)==null||u.call(o,e.error,p,m,f)}catch(C){Promise.reject(C)}try{(g=(h=n(this,oe)).onSettled)==null||g.call(h,void 0,e.error,p,m,f)}catch(C){Promise.reject(C)}}}this.listeners.forEach(p=>{p(n(this,fe))})})},vs);function is(t,e){const s=new Set(e);return t.filter(r=>!s.has(r))}var _e,G,$e,je,W,De,rt,nt,it,at,q,Qt,It,Is,Mt,At,qt,bs,an=(bs=class extends Qe{constructor(e,s,r){super();d(this,q);d(this,_e);d(this,G);d(this,$e);d(this,je);d(this,W);d(this,De);d(this,rt);d(this,nt);d(this,it);d(this,at,[]);c(this,_e,e),c(this,je,r),c(this,$e,[]),c(this,W,[]),c(this,G,[]),this.setQueries(s)}onSubscribe(){this.listeners.size===1&&n(this,W).forEach(e=>{e.subscribe(s=>{y(this,q,At).call(this,e,s)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,n(this,W).forEach(e=>{e.destroy()})}setQueries(e,s){c(this,$e,e),c(this,je,s),Q.batch(()=>{const r=n(this,W),i=y(this,q,Mt).call(this,n(this,$e));i.forEach(m=>m.observer.setOptions(m.defaultedQueryOptions));const a=i.map(m=>m.observer),o=a.map(m=>m.getCurrentResult()),u=r.length!==a.length,h=a.some((m,f)=>m!==r[f]),g=u||h,p=g?!0:o.some((m,f)=>{const C=n(this,G)[f];return!C||!Ye(m,C)});!g&&!p||(g&&(c(this,at,i),c(this,W,a)),c(this,G,o),this.hasListeners()&&(g&&(is(r,a).forEach(m=>{m.destroy()}),is(a,r).forEach(m=>{m.subscribe(f=>{y(this,q,At).call(this,m,f)})})),y(this,q,qt).call(this)))})}getCurrentResult(){return n(this,G)}getQueries(){return n(this,W).map(e=>e.getCurrentQuery())}getObservers(){return n(this,W)}getOptimisticResult(e,s){const r=y(this,q,Mt).call(this,e),i=r.map(o=>o.observer.getOptimisticResult(o.defaultedQueryOptions)),a=r.map(o=>o.defaultedQueryOptions.queryHash);return[i,o=>y(this,q,It).call(this,o??i,s,a),()=>y(this,q,Qt).call(this,i,r)]}},_e=new WeakMap,G=new WeakMap,$e=new WeakMap,je=new WeakMap,W=new WeakMap,De=new WeakMap,rt=new WeakMap,nt=new WeakMap,it=new WeakMap,at=new WeakMap,q=new WeakSet,Qt=function(e,s){const r=new Set;return s.map((i,a)=>{const o=e[a];return i.defaultedQueryOptions.notifyOnChangeProps?o:i.observer.trackResult(o,u=>{r.has(u)||(r.add(u),s.forEach(h=>{h.observer.trackProp(u)}))})})},It=function(e,s,r){if(s){const i=n(this,it),a=r!==void 0&&i!==void 0&&(i.length!==r.length||r.some((o,u)=>o!==i[u]));return(n(this,G)!==n(this,nt)||a||s!==n(this,rt))&&(c(this,rt,s),c(this,nt,n(this,G)),r!==void 0&&c(this,it,r),c(this,De,Lt(n(this,De),s(e)))),n(this,De)}return e},Is=function(){var e;return!((e=n(this,je))!=null&&e.combine)||n(this,W).some((s,r)=>{var i;return s.options.suspense&&((i=n(this,G)[r])==null?void 0:i.data)===void 0})},Mt=function(e){const s=new Map;n(this,W).forEach(i=>{const a=i.options.queryHash;if(!a)return;const o=s.get(a);o?o.push(i):s.set(a,[i])});const r=[];return e.forEach(i=>{var u;const a=n(this,_e).defaultQueryOptions(i),o=((u=s.get(a.queryHash))==null?void 0:u.shift())??new yt(n(this,_e),a);r.push({defaultedQueryOptions:a,observer:o})}),r},At=function(e,s){const r=n(this,W).indexOf(e);r!==-1&&(c(this,G,n(this,G).slice()),n(this,G)[r]=s,y(this,q,qt).call(this))},qt=function(){var e;if(this.hasListeners()){const s=y(this,q,Is).call(this),r=n(this,De),i=s?r:y(this,q,It).call(this,y(this,q,Qt).call(this,n(this,G),n(this,at)),(e=n(this,je))==null?void 0:e.combine);(s||r!==i)&&Q.batch(()=>{this.listeners.forEach(a=>{a(n(this,G))})})}},bs),te,Ss,on=(Ss=class extends Qe{constructor(e={}){super();d(this,te);this.config=e,c(this,te,new Map)}build(e,s,r){const i=s.queryKey,a=s.queryHash??Ut(i,s);let o=this.get(a);return o||(o=new en({client:e,queryKey:i,queryHash:a,options:e.defaultQueryOptions(s),state:r,defaultOptions:e.getQueryDefaults(i)}),this.add(o)),o}add(e){n(this,te).has(e.queryHash)||(n(this,te).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){n(this,te).get(e.queryHash)===e&&(e.destroy(),n(this,te).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){Q.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return n(this,te).get(e)}getAll(){return[...n(this,te).values()]}find(e){const s={exact:!0,...e};return this.getAll().find(r=>Jt(s,r))}findAll(e={}){const s=this.getAll();return Object.keys(e).length>0?s.filter(r=>Jt(e,r)):s}notify(e){Q.batch(()=>{this.listeners.forEach(s=>{s(e)})})}onFocus(){Q.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Q.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},te=new WeakMap,Ss),F,pe,ye,He,Be,me,Ge,We,ws,un=(ws=class{constructor(t={}){d(this,F);d(this,pe);d(this,ye);d(this,He);d(this,Be);d(this,me);d(this,Ge);d(this,We);c(this,F,t.queryCache||new on),c(this,pe,t.mutationCache||new rn),c(this,ye,t.defaultOptions||{}),c(this,He,new Map),c(this,Be,new Map),c(this,me,0)}mount(){ut(this,me)._++,n(this,me)===1&&(c(this,Ge,Ht.subscribe(async t=>{t&&(await this.resumePausedMutations(),n(this,F).onFocus())})),c(this,We,dt.subscribe(async t=>{t&&(await this.resumePausedMutations(),n(this,F).onOnline())})))}unmount(){var t,e;ut(this,me)._--,n(this,me)===0&&((t=n(this,Ge))==null||t.call(this),c(this,Ge,void 0),(e=n(this,We))==null||e.call(this),c(this,We,void 0))}isFetching(t){return n(this,F).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return n(this,pe).findAll({...t,status:"pending"}).length}getQueryData(t){var s;const e=this.defaultQueryOptions({queryKey:t});return(s=n(this,F).get(e.queryHash))==null?void 0:s.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),s=n(this,F).build(this,e),r=s.state.data;return r===void 0?this.fetchQuery(t):(t.revalidateIfStale&&s.isStaleByTime(j(e.staleTime,s))&&this.prefetchQuery(e),Promise.resolve(r))}getQueriesData(t){return n(this,F).findAll(t).map(({queryKey:e,state:s})=>[e,s.data])}setQueryData(t,e,s){var o;const r=this.defaultQueryOptions({queryKey:t}),i=(o=n(this,F).get(r.queryHash))==null?void 0:o.state.data,a=Lr(e,i);if(a!==void 0)return n(this,F).build(this,r).setData(a,{...s,manual:!0})}setQueriesData(t,e,s){return Q.batch(()=>n(this,F).findAll(t).map(({queryKey:r})=>[r,this.setQueryData(r,e,s)]))}getQueryState(t){var s;const e=this.defaultQueryOptions({queryKey:t});return(s=n(this,F).get(e.queryHash))==null?void 0:s.state}removeQueries(t){const e=n(this,F);Q.batch(()=>{e.findAll(t).forEach(s=>{e.remove(s)})})}resetQueries(t,e){const s=n(this,F);return Q.batch(()=>{const r=s.findAll(t),i=new Set(r);return r.forEach(a=>{a.reset()}),this.refetchQueries({type:"active",predicate:a=>i.has(a)},e)})}cancelQueries(t,e={}){const s={revert:!0,...e},r=Q.batch(()=>n(this,F).findAll(t).map(i=>i.cancel(s)));return Promise.all(r).then(U).catch(U)}invalidateQueries(t,e={}){return Q.batch(()=>(n(this,F).findAll(t).forEach(s=>{s.invalidate()}),(t==null?void 0:t.refetchType)==="none"?Promise.resolve():this.refetchQueries({...t,type:(t==null?void 0:t.refetchType)??(t==null?void 0:t.type)??"active"},e)))}refetchQueries(t,e={}){const s={...e,cancelRefetch:e.cancelRefetch??!0},r=Q.batch(()=>n(this,F).findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let a=i.fetch(void 0,s);return s.throwOnError||(a=a.catch(U)),i.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(U)}async query(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const s=n(this,F).build(this,e),r=s.isStaleByTime(j(e.staleTime,s))?await s.fetch(e):s.state.data,i=e.select;return i?i(r):r}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const s=n(this,F).build(this,e);return s.isStaleByTime(j(e.staleTime,s))?s.fetch(e):Promise.resolve(s.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(U).catch(U)}infiniteQuery(t){return t._type="infinite",this.query(t)}fetchInfiniteQuery(t){return t._type="infinite",this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(U).catch(U)}ensureInfiniteQueryData(t){return t._type="infinite",this.ensureQueryData(t)}resumePausedMutations(){return dt.isOnline()?n(this,pe).resumePausedMutations():Promise.resolve()}getQueryCache(){return n(this,F)}getMutationCache(){return n(this,pe)}getDefaultOptions(){return n(this,ye)}setDefaultOptions(t){c(this,ye,t)}setQueryDefaults(t,e){n(this,He).set(Fe(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...n(this,He).values()],s={};return e.forEach(r=>{ze(t,r.queryKey)&&Object.assign(s,r.defaultOptions)}),s}setMutationDefaults(t,e){n(this,Be).set(Fe(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...n(this,Be).values()],s={};return e.forEach(r=>{ze(t,r.mutationKey)&&Object.assign(s,r.defaultOptions)}),s}defaultQueryOptions(t){if(t._defaulted)return t;const e={...n(this,ye).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=Ut(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===Kt&&(e.enabled=!1),e}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...n(this,ye).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){n(this,F).clear(),n(this,pe).clear()}},F=new WeakMap,pe=new WeakMap,ye=new WeakMap,He=new WeakMap,Be=new WeakMap,me=new WeakMap,Ge=new WeakMap,We=new WeakMap,ws);const Ms=b.createContext(!1),As=()=>b.useContext(Ms);Ms.Provider;const qs=(t,e,s)=>{const r=s!=null&&s.state.error&&typeof t.throwOnError=="function"?_t(t.throwOnError,[s.state.error,s]):t.throwOnError;(t.suspense||r)&&(e.isReset()||(t.retryOnMount=!1))},ks=t=>{b.useEffect(()=>{t.clearReset()},[t])},Ns=({result:t,errorResetBoundary:e,throwOnError:s,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||_t(s,[t.error,r])),Us=(t,e)=>e.state.data===void 0,Ls=t=>{if(t.suspense){const s=i=>i==="static"?i:Math.max(i??1e3,1e3),r=t.staleTime;t.staleTime=typeof r=="function"?(...i)=>s(r(...i)):s(r),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},kt=(t,e)=>(t==null?void 0:t.suspense)&&e.isPending,Ks=(t,e,s)=>e.fetchOptimistic(t).catch(()=>{s.clearReset()});function cn({queries:t,...e},s){const r=ot(),i=As(),a=Cs(),o=e.subscribed!==!1,u=b.useMemo(()=>t.map(S=>{const w=r.defaultQueryOptions(S);return w._optimisticResults=i?"isRestoring":o?"optimistic":void 0,w}),[t,r,i,o]);u.forEach(S=>{Ls(S);const w=r.getQueryCache().get(S.queryHash);qs(S,a,w)}),ks(a);const[h]=b.useState(()=>new an(r,u,e)),[g,p,m]=h.getOptimisticResult(u,e.combine),f=!i&&o;b.useSyncExternalStore(b.useCallback(S=>f?h.subscribe(Q.batchCalls(S)):U,[h,f]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),b.useEffect(()=>{h.setQueries(u,e)},[u,e,h]);const C=g.some((S,w)=>kt(u[w],S))?g.flatMap((S,w)=>{const E=u[w];if(E&&kt(E,S)){const x=new yt(r,E);return Ks(E,x,a)}return[]}):[];if(C.length>0)throw Promise.all(C);const I=g.find((S,w)=>{const E=u[w];return E&&Ns({result:S,errorResetBoundary:a,throwOnError:E.throwOnError,query:r.getQueryCache().get(E.queryHash),suspense:E.suspense})});if(I)throw I.error;return p(m())}function _s(t,e,s){const r=As(),i=Cs(),a=ot(),o=a.defaultQueryOptions(t),u=a.getQueryCache().get(o.queryHash),h=t.subscribed!==!1;o._optimisticResults=r?"isRestoring":h?"optimistic":void 0,Ls(o),qs(o,i,u),ks(i);const[g]=b.useState(()=>new e(a,o)),p=g.getOptimisticResult(o),m=!r&&h;if(b.useSyncExternalStore(b.useCallback(f=>{const C=m?g.subscribe(Q.batchCalls(f)):U;return g.updateResult(),C},[g,m]),()=>g.getCurrentResult(),()=>g.getCurrentResult()),b.useEffect(()=>{g.setOptions(o)},[o,g]),kt(o,p))throw Ks(o,g,i);if(Ns({result:p,errorResetBoundary:i,throwOnError:o.throwOnError,query:u,suspense:o.suspense}))throw p.error;return o.notifyOnChangeProps?p:g.trackResult(p)}function ve(t,e){return _s(t,yt)}function mt(t,e){return _s({...t,enabled:!0,suspense:!0,throwOnError:Us,placeholderData:void 0},yt)}function ln(t,e){return cn({...t,queries:t.queries.map(s=>({...s,suspense:!0,throwOnError:Us,enabled:!0,placeholderData:void 0}))})}function $s(t,e){const s=ot(),[r]=b.useState(()=>new nn(s,t));b.useEffect(()=>{r.setOptions(t)},[r,t]);const i=b.useSyncExternalStore(b.useCallback(o=>r.subscribe(Q.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=b.useCallback((...o)=>{r.mutate(o[0],o[1]).catch(U)},[r]);if(i.error&&_t(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}const hn=864e5,dn=/^\d{4}-\d{2}-\d{2}$/;function as(t,e=Date.now()){return new Date(e-t*hn).toISOString().slice(0,10)}function fn(t=30,e=Date.now()){return{fromDay:as(t-1,e),toDay:as(0,e)}}function pn(t){return dn.test(t)}function ht(){return typeof window<"u"&&window.__AGENT_API__?window.__AGENT_API__:`${typeof window<"u"&&window.__AGENT_BASE__||"/ai-gateway"}/api`}async function $(t,e){const s=await fetch(ht()+t,e);if(!s.ok)throw new Error(`${s.status} ${s.statusText}`);return await s.json()}function lt(t){const e=new URLSearchParams({page:`${t.page}`,limit:`${t.pageSize}`});if(t.where!==void 0)for(const[s,r]of Object.entries(t.where))typeof r=="string"&&r!==""&&e.set(`where[${s}]`,r);return e}const L={spend(t){const e=new URLSearchParams({from:t.fromDay,to:t.toDay});return $(`/spend?${e.toString()}`)},topThreads(t,e=10){const s=new URLSearchParams({from:t.fromDay,to:t.toDay,limit:`${e}`});return $(`/top-threads?${s.toString()}`)},reliability(t){const e=new URLSearchParams({from:t.fromDay,to:t.toDay});return $(`/reliability?${e.toString()}`)},runs(t=50){return $(`/runs?limit=${t}`)},toolCalls(t=50){return $(`/tool-calls?limit=${t}`)},toolCallsPage(t){return $(`/tool-calls-page?${lt(t)}`)},approvals(t=50){return $(`/approvals?limit=${t}`)},approvalsPage(t){return $(`/approvals-page?${lt(t)}`)},runDetail(t){return $(`/runs/${encodeURIComponent(t)}`)},threadDetail(t,e={}){const s=new URLSearchParams;e.messages!==void 0&&s.set("messages",`${e.messages}`),e.runs!==void 0&&s.set("runs",`${e.runs}`);const r=s.size>0?`?${s.toString()}`:"";return $(`/threads/${encodeURIComponent(t)}${r}`)},async decideApproval(t,e){const s=await fetch(`${ht()}/approvals/${encodeURIComponent(t)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!s.ok)throw new Error(`${s.status} ${s.statusText}`)},toolStats(t){const e=new URLSearchParams({from:t.fromDay,to:t.toDay});return $(`/tools?${e.toString()}`)},threads(t=50){return $(`/threads?limit=${t}`)},threadsPage(t){return $(`/threads-page?${lt(t)}`)},runsPage(t){return $(`/runs-page?${lt(t)}`)},pricing(){return $("/pricing")},async upsertPrice(t){const e=await fetch(`${ht()}/pricing`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!e.ok)throw new Error(`${e.status} ${e.statusText}`)},streamEvents(t){const e=new EventSource(`${ht()}/stream`);return e.onmessage=s=>{try{t(JSON.parse(s.data))}catch{}},()=>e.close()}},z={aggregate:6e4,activity:15e3,queue:0,config:5*6e4,detail:3e4};function Hs(t){return{queryKey:["spend",t.fromDay,t.toDay],queryFn:()=>L.spend(t),staleTime:z.aggregate}}function Bs(t){return mt(Hs(t))}function yn(t,e=10){const[s,r]=ln({queries:[Hs(t),{queryKey:["top-threads",t.fromDay,t.toDay,e],queryFn:()=>L.topThreads(t,e),staleTime:z.aggregate}]});return{overview:s.data,topThreads:r.data}}function mn(t){return mt({queryKey:["reliability",t.fromDay,t.toDay],queryFn:()=>L.reliability(t),staleTime:z.aggregate})}function gn(t){return mt({queryKey:["tool-stats",t.fromDay,t.toDay],queryFn:()=>L.toolStats(t),staleTime:z.aggregate})}function vn(t=50){return mt({queryKey:["tool-calls",t],queryFn:()=>L.toolCalls(t),staleTime:z.activity})}function bn(t,e,s){return ve({queryKey:["runs-page",t,e,s],queryFn:()=>L.runsPage({page:t,pageSize:e,where:s}),placeholderData:pt,staleTime:z.activity})}function Sn(t,e,s){return ve({queryKey:["tool-calls-page",t,e,s],queryFn:()=>L.toolCallsPage({page:t,pageSize:e,where:s}),placeholderData:pt,staleTime:z.activity})}function wn(t,e,s){return ve({queryKey:["threads-page",t,e,s],queryFn:()=>L.threadsPage({page:t,pageSize:e,where:s}),placeholderData:pt,staleTime:z.activity})}function Cn(t,e,s){return ve({queryKey:["approvals-page",t,e,s],queryFn:()=>L.approvalsPage({page:t,pageSize:e,where:s}),placeholderData:pt,staleTime:z.queue})}function Pn(){return ve({queryKey:["approvals-count"],queryFn:async()=>(await L.approvalsPage({page:1,pageSize:1})).total,staleTime:z.queue,refetchInterval:2e4,refetchIntervalInBackground:!0})}function xn(t){return ve({queryKey:["run-detail",t],queryFn:()=>L.runDetail(t),staleTime:z.detail})}function Rn(t){return ve({queryKey:["thread-detail",t],queryFn:()=>L.threadDetail(t),staleTime:z.detail})}function On(){return ve({queryKey:["pricing"],queryFn:()=>L.pricing(),staleTime:z.config})}const Tn=[["approvals"],["approvals-page"],["approvals-count"],["tool-calls"],["tool-calls-page"],["tool-stats"],["run-detail"]];function En(){const t=ot();return $s({mutationFn:({toolCallId:e,input:s})=>L.decideApproval(e,s),onSuccess:()=>{for(const e of Tn)t.invalidateQueries({queryKey:e})}})}const jn=[["pricing"],["spend"],["top-threads"],["thread-detail"]];function Dn(){const t=ot();return $s({mutationFn:e=>L.upsertPrice(e),onSuccess:()=>{for(const e of jn)t.invalidateQueries({queryKey:e})}})}function Fn({range:t}){return l.jsx(Ys,{rows:Bs(t).data.byActor})}const Qn=["spend","models","actors","runs","reliability","approvals","tools","pricing","live"],Gs="spend";function In(t){return Qn.some(e=>e===t)}function os(t){const e=t.replace(/^#\/?/,""),s=e.indexOf("?"),r=s===-1?e:e.slice(0,s);return In(r)?{section:r,params:new URLSearchParams(s===-1?"":e.slice(s+1))}:{section:Gs,params:new URLSearchParams}}function Gt(t,e){const s=e===void 0?"":new URLSearchParams(e).toString();return s===""?`#/${t}`:`#/${t}?${s}`}const Ws=b.createContext({open:()=>{}});function gt(){return b.useContext(Ws)}function Mn({children:t}){const[e,s]=b.useState([]),r=b.useCallback(u=>{s(h=>[...h,u])},[]),i=b.useCallback(()=>s([]),[]),a=b.useCallback(()=>s(u=>u.slice(0,-1)),[]);b.useEffect(()=>(window.addEventListener("hashchange",i),()=>window.removeEventListener("hashchange",i)),[i]);const o=e[e.length-1];return l.jsxs(Ws.Provider,{value:{open:r},children:[t,o!==void 0&&l.jsx(Zs,{title:o.kind==="run"?"Run":"Thread",subtitle:o.kind==="run"?o.runId:o.threadId,onClose:i,...e.length>1?{onBack:a}:{},children:o.kind==="run"?l.jsx(Nn,{runId:o.runId,onOpenThread:qn(r)}):l.jsx(Un,{threadId:o.threadId,onOpenRun:kn(r)})},An(o))]})}function An(t){return t.kind==="run"?`run:${t.runId}`:`thread:${t.threadId}`}function qn(t){return e=>t({kind:"thread",threadId:e})}function kn(t){return e=>t({kind:"run",runId:e})}function Nn({runId:t,onOpenThread:e}){const s=xn(t);return s.isPending?l.jsx(Vs,{label:"run"}):s.isError?l.jsx(zs,{label:"This run",error:s.error,onRetry:()=>void s.refetch(),goneLabel:"This run no longer exists in the read-model."}):l.jsx(Xs,{detail:s.data,onOpenThread:e})}function Un({threadId:t,onOpenRun:e}){const s=Rn(t);return s.isPending?l.jsx(Vs,{label:"thread"}):s.isError?l.jsx(zs,{label:"This thread",error:s.error,onRetry:()=>void s.refetch(),goneLabel:"This thread no longer exists in the read-model."}):l.jsx(er,{detail:s.data,onOpenRun:e,runsHref:Gt("reliability",{threadId:t})})}function zs({label:t,error:e,onRetry:s,goneLabel:r}){return e instanceof Error&&e.message.startsWith("404")?l.jsx(sr,{label:r}):l.jsx(rr,{label:t,error:e,onRetry:s})}function Vs({label:t}){return l.jsxs(tr,{className:"animate-pulse p-6 text-sm text-muted-foreground","aria-busy":"true",children:["Loading ",t,"…"]})}const ge=25;function ft(t,e,s){return{page:t.data??{rows:[],total:0,page:e,pageSize:s},error:t.isError?t.error:null,retry:()=>void t.refetch()}}function Ln(){const{open:t}=gt(),[e,s]=b.useState(1),r=Cn(e,ge,{}),i=En();return l.jsx(nr,{table:ft(r,e,ge),onPageChange:s,onDecide:(a,o)=>i.mutateAsync({toolCallId:a,input:o}),onOpenRun:a=>t({kind:"run",runId:a})})}function Kn({range:t}){return l.jsx(ir,{rows:Bs(t).data.byModel})}const _n="501";function $n(){const t=On(),e=Dn(),s=t.isError&&t.error.message.startsWith(_n);return t.isError&&!s?l.jsx(ar,{label:"Pricing",error:t.error,onRetry:()=>void t.refetch()}):l.jsx(or,{prices:t.data??[],loading:t.isPending,unavailable:s,onUpsert:r=>e.mutateAsync(r),saving:e.isPending})}function Hn({range:t,threadId:e}){const{open:s}=gt(),r=mn(t),[i,a]=b.useState(1),[o,u]=b.useState(""),[h,g]=b.useState(""),p={...o!==""?{status:o}:{},...h!==""?{agentName:h}:{},...e!==void 0&&e!==""?{threadId:e}:{}},m=bn(i,ge,p);return l.jsx(ur,{overview:r.data,runsTable:ft(m,i,ge),runsWhere:p,onRunsStatusChange:f=>{u(f),a(1)},onRunsAgentNameChange:f=>{g(f),a(1)},onRunsThreadIdClear:()=>{a(1),window.location.hash=Gt("reliability")},onRunsPageChange:a,onOpenRun:f=>s({kind:"run",runId:f})})}function Bn(){const{open:t}=gt(),e=vn(),[s,r]=b.useState(1),[i,a]=b.useState(""),[o,u]=b.useState(""),h={...i!==""?{toolName:i}:{},...o!==""?{status:o}:{}},g=Sn(s,ge,h),[p,m]=b.useState(1),[f,C]=b.useState(""),I={...f!==""?{title:f}:{}},S=wn(p,ge,I);return l.jsx(cr,{toolCalls:e.data,toolCallsTable:ft(g,s,ge),toolCallsWhere:h,onToolCallsToolNameChange:w=>{a(w),r(1)},onToolCallsStatusChange:w=>{u(w),r(1)},onToolCallsPageChange:r,threadsTable:ft(S,p,ge),threadsWhere:I,onThreadsTitleChange:w=>{C(w),m(1)},onThreadsPageChange:m,onOpenRun:w=>t({kind:"run",runId:w}),onOpenThread:w=>t({kind:"thread",threadId:w})})}function Gn({range:t}){const{open:e}=gt(),{overview:s,topThreads:r}=yn(t);return l.jsx(lr,{overview:s,topThreads:r,onOpenThread:i=>e({kind:"thread",threadId:i})})}function Wn({range:t}){return l.jsx(hr,{rows:gn(t).data})}const zn=Dr,Vn=Fr;function Jn({className:t,align:e="end",sideOffset:s=6,...r}){return l.jsx(Qr,{children:l.jsx(Ir,{align:e,sideOffset:s,className:"z-50 outline-none",children:l.jsx(Mr,{className:dr("origin-[var(--transform-origin)] rounded-lg border border-line bg-popover p-3 text-popover-foreground shadow-lg shadow-black/50 outline-none","transition-[opacity,transform] duration-150 ease-out","data-[starting-style]:scale-95 data-[starting-style]:opacity-0","data-[ending-style]:scale-95 data-[ending-style]:opacity-0",t),...r})})})}function Yn(t=200){const[e,s]=b.useState([]),[r,i]=b.useState(!1),a=b.useRef(0);return b.useEffect(()=>{i(!0);const o=L.streamEvents(u=>{a.current+=1,s(h=>fr(h,u,a.current,t))});return()=>{i(!1),o()}},[t]),{events:e,connected:r}}const Js=[{key:"spend",label:"Spend & usage",icon:l.jsx(pr,{})},{key:"models",label:"Models",icon:l.jsx(yr,{})},{key:"actors",label:"Actors & budgets",icon:l.jsx(mr,{})},{key:"runs",label:"Runs & tools",icon:l.jsx(Vt,{})},{key:"reliability",label:"Reliability",icon:l.jsx(gr,{})},{key:"approvals",label:"Approvals",icon:l.jsx(vr,{})},{key:"tools",label:"Tools",icon:l.jsx(Vt,{})},{key:"pricing",label:"Pricing",icon:l.jsx(br,{})},{key:"live",label:"Live",icon:l.jsx(Sr,{})}],Zn=Object.fromEntries(Js.map(t=>[t.key,t.label]));function Xn(){const[t,e]=b.useState(()=>typeof window>"u"?{section:Gs,params:new URLSearchParams}:os(window.location.hash));return b.useEffect(()=>{function s(){e(os(window.location.hash))}return window.addEventListener("hashchange",s),()=>window.removeEventListener("hashchange",s)},[]),t}function ei(){const[t,e]=b.useState(fn()),{section:s,params:r}=Xn(),i=Yn(),a=Pn();return l.jsx(wr,{delay:400,closeDelay:0,timeout:300,children:l.jsx(Mn,{children:l.jsxs("div",{className:"relative min-h-full",children:[l.jsx("div",{className:"app-bg"}),l.jsxs("div",{className:"relative z-10 mx-auto max-w-[1180px] px-5 py-5",children:[l.jsx(si,{range:t,onRange:e,connected:i.connected,liveCount:i.events.length}),l.jsx("nav",{className:"mb-5 flex flex-wrap gap-1",children:Js.map(o=>{const u=o.key==="live"?i.events.length:o.key==="approvals"?a.data??0:0,h=s===o.key;return l.jsxs(Ps,{render:l.jsx("a",{href:Gt(o.key),...h?{"aria-current":"page"}:{}}),size:"md",variant:h?"default":"ghost",className:"gap-2 rounded-lg",children:[o.icon,o.label,u>0&&l.jsx(Cr,{variant:"accent",className:"tnum border-transparent bg-brand/20",children:u})]},o.key)})}),l.jsx(Pr,{label:Zn[s],children:l.jsx(ti,{section:s,range:t,params:r,liveEvents:i.events,connected:i.connected})},s)]})]})})})}function ti({section:t,range:e,params:s,liveEvents:r,connected:i}){switch(t){case"spend":return l.jsx(Gn,{range:e});case"models":return l.jsx(Kn,{range:e});case"actors":return l.jsx(Fn,{range:e});case"runs":return l.jsx(Bn,{});case"reliability":return l.jsx(Hn,{range:e,threadId:s.get("threadId")??void 0});case"approvals":return l.jsx(Ln,{});case"tools":return l.jsx(Wn,{range:e});case"pricing":return l.jsx($n,{});case"live":return l.jsx(Or,{events:r,connected:i});default:return null}}function si({range:t,onRange:e,connected:s,liveCount:r}){return l.jsxs("header",{className:"mb-5 flex flex-wrap items-center gap-4",children:[l.jsxs("div",{className:"flex items-center gap-2.5",children:[l.jsx("div",{className:"grid h-8 w-8 place-items-center rounded-lg border border-brand/40 bg-brand/10",children:l.jsx(xr,{className:"h-4 w-4 text-brand"})}),l.jsxs("div",{className:"leading-none",children:[l.jsx("div",{className:"text-sm font-semibold tracking-tight",children:"AI gateway"}),l.jsx("div",{className:"mono text-[10px] uppercase tracking-[0.2em] text-muted-foreground",children:"governance console"})]})]}),l.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[l.jsx(ri,{range:t,onRange:e}),l.jsxs("span",{className:"flex items-center gap-1.5 rounded-lg border border-line px-2.5 py-1.5 text-[11px] text-muted-foreground",children:[l.jsx(Rr,{tone:s?"live":"bad"}),"live ",r>0?`· ${r}`:""]})]})]})}function ri({range:t,onRange:e}){return l.jsxs(zn,{children:[l.jsxs(Vn,{render:l.jsx(Ps,{size:"md",variant:"outline",className:"mono gap-2 rounded-lg"}),children:[l.jsx(Tr,{width:12,height:12}),l.jsxs("span",{className:"tnum text-foreground",children:[t.fromDay," → ",t.toDay]})]}),l.jsxs(Jn,{className:"flex flex-col gap-2",children:[l.jsx(us,{label:"From",value:t.fromDay,onChange:s=>e({...t,fromDay:s})}),l.jsx(us,{label:"To",value:t.toDay,onChange:s=>e({...t,toDay:s})}),l.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Whole UTC days, inclusive."})]})]})}function us({label:t,value:e,onChange:s}){return l.jsxs("label",{className:"flex items-center justify-between gap-3 rounded-lg border border-line bg-panel px-2.5 py-1 text-[11px] text-muted-foreground",children:[l.jsx("span",{className:"uppercase tracking-wider",children:t}),l.jsx(Er,{type:"date",value:e,onChange:r=>{const i=r.target.value;pn(i)&&s(i)}})]})}const ni=new un({defaultOptions:{queries:{retry:1}}}),cs=document.getElementById("root");cs&&jr.createRoot(cs).render(l.jsx(b.StrictMode,{children:l.jsx(Ar,{client:ni,children:l.jsx(ei,{})})}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{v as w,m as x,L as D,d as O,M as R,A as y,c,b as v,a as A,e as N,P as M,r as j,S as u,w as _,C as P,B as h,D as E,R as k,T as L}from"./index-CTK2sMGd.js";import{j as e,r as T}from"./base-ui-CeQ9JhU_.js";import"./recharts-DSmxPXW6.js";const U=[{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}],K=[{actorRef:"tenant:acme",requests:8200,totalTokens:184e5,costUsd:78.1,actorLabel:"Acme Corp"},{actorRef:"user:davi@goflip.ai",requests:3100,totalTokens:69e5,costUsd:34.2,actorLabel:"Davi de Carvalho"},{actorRef:"tenant:globex",requests:4400,totalTokens:92e5,costUsd:21.8,actorLabel:null},{actorRef:"user:ops-bot",requests:2100,totalTokens:394e4,costUsd:1.1,actorLabel:null}],q={"tenant:acme":2e7,"user:davi@goflip.ai":5e6,"tenant:globex":12e6};function H(){const a=[];for(let t=29;t>=0;t-=1){const s=new Date(Date.now()-t*864e5).toISOString().slice(0,10),r=Math.sin(t/3)*.5+1;a.push({day:s,totalTokens:Math.round(7e5*r+t*4e3),costUsd:Number((4.2*r+t*.05).toFixed(2))})}return a}function B(){const a=[];for(let t=29;t>=0;t-=1){const s=new Date(Date.now()-t*864e5).toISOString().slice(0,10),r=Math.sin(t/3)*.5+1,i=Math.round(18*r+t*.3);a.push({day:s,runs:i,failed:Math.max(0,Math.round(i*.06))})}return a}const l={byModel:U,byActor:K,trend:H()},z={metrics:{runs:482,completed:461,failed:21,successRate:461/482,retries:34,durationP50Ms:640,durationP95Ms:2400},byAgent:[{agentName:"analyst",runs:210,failed:8,retries:14},{agentName:"billing-agent",runs:150,failed:9,retries:12},{agentName:"(default)",runs:122,failed:4,retries:8}],errors:[{errorCode:"TIMEOUT",count:9},{errorCode:"TOOL_ERROR",count:6},{errorCode:"RATE_LIMIT",count:4},{errorCode:"UNKNOWN",count:2}],trend:B()},b={runId:"r-7c31",threadId:"th2",actorRef:"user:ops-bot",agentName:"billing-agent",status:"failed",durationMs:4200,errorCode:"TIMEOUT",errorMessage:"upstream model request timed out after 3 attempts",retries:2,startedAt:new Date(Date.now()-21e4).toISOString(),promptHash:"ffeeddccbbaa99887766554433221100ffeeddccbbaa99887766554433221",parentRunId:null},S=[{runId:"r-9f2a",threadId:"th1",actorRef:"tenant:acme",agentName:"analyst",status:"completed",durationMs:820,errorCode:null,errorMessage:null,retries:0,startedAt:new Date(Date.now()-4e4).toISOString(),promptHash:"a1b2c3d4e5f60718293a4b5c6d7e8f9012345678901234567890abcdef01234",parentRunId:null},b,{runId:"r-a114",threadId:"th3",actorRef:"user:davi@goflip.ai",agentName:null,status:"completed",durationMs:1150,errorCode:null,errorMessage:null,retries:1,startedAt:new Date(Date.now()-54e4).toISOString(),promptHash:null,parentRunId:null},{runId:"r-b902",threadId:"th1",actorRef:"tenant:acme",agentName:"analyst",status:"failed",durationMs:980,errorCode:"TOOL_ERROR",errorMessage:"search_records returned a 500",retries:0,startedAt:new Date(Date.now()-132e4).toISOString(),promptHash:"a1b2c3d4e5f60718293a4b5c6d7e8f9012345678901234567890abcdef01234",parentRunId:null},{runId:"r-c447",threadId:"th2",actorRef:"user:ops-bot",agentName:"billing-agent",status:"running",durationMs:null,errorCode:null,errorMessage:null,retries:0,startedAt:new Date(Date.now()-8e3).toISOString(),promptHash:"ffeeddccbbaa99887766554433221100ffeeddccbbaa99887766554433221",parentRunId:"r-7c31"}],G=[{toolCallId:"tc-approve-1",runId:"r-c447",toolName:"delete_asset",input:{assetId:"asset-42",reason:"stale"},threadId:"th2",threadTitle:"Incident triage",actorRef:"user:ops-bot",agentName:"billing-agent",requestedAt:new Date(Date.now()-3e5).toISOString()},{toolCallId:"tc-approve-2",runId:"r-9f2a",toolName:"send_email",input:{to:"finance@acme.example",subject:"Q3 invoice adjustment"},threadId:"th1",threadTitle:"Q3 procurement review",actorRef:"tenant:acme",agentName:"analyst",requestedAt:new Date(Date.now()-9e5).toISOString()}],W=[{toolName:"search_records",toolType:"read",calls:420,failed:6,rejected:0,p50ExecutionMs:42,p95ExecutionMs:180},{toolName:"delete_asset",toolType:"action",calls:34,failed:1,rejected:4,p50ExecutionMs:310,p95ExecutionMs:620},{toolName:"send_email",toolType:"action",calls:58,failed:2,rejected:2,p50ExecutionMs:96,p95ExecutionMs:410},{toolName:"fetch_pricing",toolType:"read",calls:210,failed:0,rejected:0,p50ExecutionMs:88,p95ExecutionMs:95}],F=q,d=[{toolCallId:"tc1",runId:"r-9f2a",toolName:"search_records",toolType:"read",status:"ok",threadId:"th1",createdAt:new Date(Date.now()-12e3).toISOString()},{toolCallId:"tc2",runId:"r-7c31",toolName:"delete_asset",toolType:"action",status:"forbidden",threadId:"th2",createdAt:new Date(Date.now()-9e4).toISOString()},{toolCallId:"tc3",runId:"r-9f2a",toolName:"fetch_pricing",toolType:"read",status:"ok",threadId:"th1",createdAt:new Date(Date.now()-24e4).toISOString()},{toolCallId:"tc4",runId:"r-a114",toolName:"send_email",toolType:"action",status:"failed",threadId:"th3",createdAt:new Date(Date.now()-62e4).toISOString()},{toolCallId:"tc5",runId:null,toolName:"summarize_thread",toolType:"read",status:"ok",threadId:"th2",createdAt:new Date(Date.now()-12e5).toISOString()}],C={threadId:"th2",title:"Incident triage",actorRef:"user:ops-bot",messageCount:11,totalTokens:62e3,lastActivityAt:new Date(Date.now()-4e5).toISOString(),actorLabel:null},Q=[{threadId:"th1",title:"Q3 procurement review",actorRef:"tenant:acme",messageCount:24,totalTokens:184e3,lastActivityAt:new Date(Date.now()-3e4).toISOString(),actorLabel:"Acme Corp"},C,{threadId:"th3",title:"Contract summary",actorRef:"user:davi@goflip.ai",messageCount:6,totalTokens:28400,lastActivityAt:new Date(Date.now()-18e5).toISOString(),actorLabel:"Davi de Carvalho"}],V=[{threadId:"th1",title:"Q3 procurement review",actorRef:"tenant:acme",requests:24,totalTokens:184e3,costUsd:18.4,actorLabel:"Acme Corp"},{threadId:"th2",title:"Incident triage",actorRef:"user:ops-bot",requests:11,totalTokens:62e3,costUsd:6.2,actorLabel:null},{threadId:"th3",title:"Contract summary",actorRef:"user:davi@goflip.ai",requests:6,totalTokens:28400,costUsd:2.8,actorLabel:"Davi de Carvalho"}],p={rows:d,total:137,page:1,pageSize:25},g={rows:Q,total:46,page:1,pageSize:25},Y={rows:S,total:482,page:1,pageSize:25},J={rows:G,total:7,page:1,pageSize:25},m={run:b,thread:{threadId:"th2",title:"Incident triage",actorRef:"user:ops-bot",deleted:!1,actorLabel:null},toolCalls:[{toolCallId:"tc2",toolName:"delete_asset",toolType:"action",status:"forbidden",executionMs:null,executedByRef:"user:davi@goflip.ai",error:null,createdAt:new Date(Date.now()-215e3).toISOString()},{toolCallId:"tc9",toolName:"fetch_pricing",toolType:"read",status:"ok",executionMs:96,executedByRef:null,error:null,createdAt:new Date(Date.now()-213e3).toISOString()},{toolCallId:"tc10",toolName:"search_records",toolType:"read",status:"failed",executionMs:3980,executedByRef:null,error:"upstream returned 500 after 3 attempts",createdAt:new Date(Date.now()-212e3).toISOString()}]},I={thread:C,deleted:!1,usage:{requests:11,inputTokens:48e3,outputTokens:14e3,totalTokens:62e3,costUsd:6.2},runs:S.filter(a=>a.threadId==="th2"),runTotal:34,messages:[{messageId:"m1",role:"user",content:"The billing sync failed again overnight — can you find out which asset broke it?",truncated:!1,agentName:null,toolCallCount:0,createdAt:new Date(Date.now()-4e5).toISOString()},{messageId:"m2",role:"assistant",content:"I found 3 assets with a null billing code. Asset-42 is the only one touched by last night’s sync, so I want to delete it — that needs your approval.",truncated:!1,agentName:"billing-agent",toolCallCount:2,createdAt:new Date(Date.now()-38e4).toISOString()},{messageId:"m3",role:"assistant",content:"Here is the full audit trail for asset-42 across the last 90 days, starting with the ingest that first assigned it a billing code and continuing through every subsequent",truncated:!0,agentName:"billing-agent",toolCallCount:1,createdAt:new Date(Date.now()-36e4).toISOString()}]},X=[{modelId:"gpt-4o",inputPricePer1m:2.5,outputPricePer1m:10,cacheReadPricePer1m:1.25,effectiveFrom:new Date(Date.now()-5*864e5).toISOString()},{modelId:"claude-3-5-sonnet",inputPricePer1m:3,outputPricePer1m:15,cacheWritePricePer1m:3.75,cacheReadPricePer1m:.3,effectiveFrom:new Date(Date.now()-12*864e5).toISOString()},{modelId:"gpt-4o-mini",inputPricePer1m:.15,outputPricePer1m:.6,effectiveFrom:new Date(Date.now()-2*864e5).toISOString()}],Z=[{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 n(a){return{page:a,error:null,retry:()=>{}}}function $(a,t){return{page:a,error:t,retry:()=>{}}}function ee(){const[a,t]=T.useState(null);return e.jsx(x,{delay:400,closeDelay:0,timeout:300,children: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-brand/40 bg-brand/10",children:e.jsx(D,{className:"h-4 w-4 text-brand"})}),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-muted-foreground",children:"mock data · no backend"})]})]}),e.jsx(o,{label:"Spend & usage",children:e.jsx(O,{overview:l,topThreads:V,onOpenThread:()=>t("thread")})}),e.jsx(o,{label:"Models",children:e.jsx(R,{rows:l.byModel})}),e.jsx(o,{label:"Actors & budgets",children:e.jsx(y,{rows:l.byActor,budgets:F})}),e.jsx(o,{label:"Runs & tools",children:e.jsx(c,{toolCalls:d,toolCallsTable:n(p),toolCallsWhere:{},onToolCallsToolNameChange:()=>{},onToolCallsStatusChange:()=>{},onToolCallsPageChange:()=>{},threadsTable:n(g),threadsWhere:{},onThreadsTitleChange:()=>{},onThreadsPageChange:()=>{},onOpenRun:()=>t("run"),onOpenThread:()=>t("thread")})}),e.jsx(o,{label:"Reliability",children:e.jsx(v,{overview:z,runsTable:n(Y),runsWhere:{threadId:"th2"},onRunsStatusChange:()=>{},onRunsAgentNameChange:()=>{},onRunsThreadIdClear:()=>{},onRunsPageChange:()=>{},onOpenRun:()=>t("run")})}),e.jsx(o,{label:"Approvals",children:e.jsx(A,{table:n(J),onPageChange:()=>{},onDecide:async()=>{},onOpenRun:()=>t("run")})}),e.jsx(o,{label:"Tools",children:e.jsx(N,{rows:W})}),e.jsx(o,{label:"Pricing",children:e.jsx(M,{prices:X,loading:!1,unavailable:!1,onUpsert:async()=>{},saving:!1})}),e.jsx(o,{label:"Live",children:e.jsx(j,{events:Z,connected:!0})}),e.jsx(o,{label:"Failure & loading states",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(u,{label:"Spend & usage",error:new Error("503 Service Unavailable"),onRetry:()=>{}}),e.jsx(u,{label:"Pricing",error:new Error("401 Unauthorized"),onRetry:()=>{}}),e.jsx(_,{label:"Reliability"}),e.jsx(c,{toolCalls:d,toolCallsTable:$(p,new Error("500 Internal Server Error")),toolCallsWhere:{},onToolCallsToolNameChange:()=>{},onToolCallsStatusChange:()=>{},onToolCallsPageChange:()=>{},threadsTable:n(g),threadsWhere:{},onThreadsTitleChange:()=>{},onThreadsPageChange:()=>{}})]})}),e.jsx(o,{label:"Drill-downs",children:e.jsxs(P,{className:"flex flex-wrap gap-2 p-4 text-xs",children:[e.jsx(h,{size:"md",className:"rounded-lg",onClick:()=>t("run"),children:"Open a run"}),e.jsx(h,{size:"md",className:"rounded-lg",onClick:()=>t("thread"),children:"Open a thread"})]})})]}),a!==null&&e.jsx(E,{title:a==="run"?"Run":"Thread",subtitle:a==="run"?m.run.runId:I.thread.threadId,onClose:()=>t(null),...a==="run"?{onBack:()=>t("thread")}:{},children:a==="run"?e.jsx(k,{detail:m,onOpenThread:()=>t("thread")}):e.jsx(L,{detail:I,onOpenRun:()=>t("run"),runsHref:"#/reliability?threadId=th2"})})]})})}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-muted-foreground",children:a}),t]})}const f=document.getElementById("root");f&&w.createRoot(f).render(e.jsx(T.StrictMode,{children:e.jsx(ee,{})}));
|
|
1
|
+
import{v as w,m as x,L as D,d as O,M as R,A as y,c,b as v,a as A,e as N,P as M,r as j,S as u,w as _,C as P,B as h,D as E,R as k,T as L}from"./index-BkhmVSOi.js";import{j as e,r as T}from"./base-ui-CWwgtV-8.js";import"./recharts-El_Zr62O.js";const U=[{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}],K=[{actorRef:"tenant:acme",requests:8200,totalTokens:184e5,costUsd:78.1,actorLabel:"Acme Corp"},{actorRef:"user:davi@goflip.ai",requests:3100,totalTokens:69e5,costUsd:34.2,actorLabel:"Davi de Carvalho"},{actorRef:"tenant:globex",requests:4400,totalTokens:92e5,costUsd:21.8,actorLabel:null},{actorRef:"user:ops-bot",requests:2100,totalTokens:394e4,costUsd:1.1,actorLabel:null}],q={"tenant:acme":2e7,"user:davi@goflip.ai":5e6,"tenant:globex":12e6};function H(){const a=[];for(let t=29;t>=0;t-=1){const s=new Date(Date.now()-t*864e5).toISOString().slice(0,10),r=Math.sin(t/3)*.5+1;a.push({day:s,totalTokens:Math.round(7e5*r+t*4e3),costUsd:Number((4.2*r+t*.05).toFixed(2))})}return a}function B(){const a=[];for(let t=29;t>=0;t-=1){const s=new Date(Date.now()-t*864e5).toISOString().slice(0,10),r=Math.sin(t/3)*.5+1,i=Math.round(18*r+t*.3);a.push({day:s,runs:i,failed:Math.max(0,Math.round(i*.06))})}return a}const l={byModel:U,byActor:K,trend:H()},z={metrics:{runs:482,completed:461,failed:21,successRate:461/482,retries:34,durationP50Ms:640,durationP95Ms:2400},byAgent:[{agentName:"analyst",runs:210,failed:8,retries:14},{agentName:"billing-agent",runs:150,failed:9,retries:12},{agentName:"(default)",runs:122,failed:4,retries:8}],errors:[{errorCode:"TIMEOUT",count:9},{errorCode:"TOOL_ERROR",count:6},{errorCode:"RATE_LIMIT",count:4},{errorCode:"UNKNOWN",count:2}],trend:B()},b={runId:"r-7c31",threadId:"th2",actorRef:"user:ops-bot",agentName:"billing-agent",status:"failed",durationMs:4200,errorCode:"TIMEOUT",errorMessage:"upstream model request timed out after 3 attempts",retries:2,startedAt:new Date(Date.now()-21e4).toISOString(),promptHash:"ffeeddccbbaa99887766554433221100ffeeddccbbaa99887766554433221",parentRunId:null},S=[{runId:"r-9f2a",threadId:"th1",actorRef:"tenant:acme",agentName:"analyst",status:"completed",durationMs:820,errorCode:null,errorMessage:null,retries:0,startedAt:new Date(Date.now()-4e4).toISOString(),promptHash:"a1b2c3d4e5f60718293a4b5c6d7e8f9012345678901234567890abcdef01234",parentRunId:null},b,{runId:"r-a114",threadId:"th3",actorRef:"user:davi@goflip.ai",agentName:null,status:"completed",durationMs:1150,errorCode:null,errorMessage:null,retries:1,startedAt:new Date(Date.now()-54e4).toISOString(),promptHash:null,parentRunId:null},{runId:"r-b902",threadId:"th1",actorRef:"tenant:acme",agentName:"analyst",status:"failed",durationMs:980,errorCode:"TOOL_ERROR",errorMessage:"search_records returned a 500",retries:0,startedAt:new Date(Date.now()-132e4).toISOString(),promptHash:"a1b2c3d4e5f60718293a4b5c6d7e8f9012345678901234567890abcdef01234",parentRunId:null},{runId:"r-c447",threadId:"th2",actorRef:"user:ops-bot",agentName:"billing-agent",status:"running",durationMs:null,errorCode:null,errorMessage:null,retries:0,startedAt:new Date(Date.now()-8e3).toISOString(),promptHash:"ffeeddccbbaa99887766554433221100ffeeddccbbaa99887766554433221",parentRunId:"r-7c31"}],G=[{toolCallId:"tc-approve-1",runId:"r-c447",toolName:"delete_asset",input:{assetId:"asset-42",reason:"stale"},threadId:"th2",threadTitle:"Incident triage",actorRef:"user:ops-bot",agentName:"billing-agent",requestedAt:new Date(Date.now()-3e5).toISOString()},{toolCallId:"tc-approve-2",runId:"r-9f2a",toolName:"send_email",input:{to:"finance@acme.example",subject:"Q3 invoice adjustment"},threadId:"th1",threadTitle:"Q3 procurement review",actorRef:"tenant:acme",agentName:"analyst",requestedAt:new Date(Date.now()-9e5).toISOString()}],W=[{toolName:"search_records",toolType:"read",calls:420,failed:6,rejected:0,p50ExecutionMs:42,p95ExecutionMs:180},{toolName:"delete_asset",toolType:"action",calls:34,failed:1,rejected:4,p50ExecutionMs:310,p95ExecutionMs:620},{toolName:"send_email",toolType:"action",calls:58,failed:2,rejected:2,p50ExecutionMs:96,p95ExecutionMs:410},{toolName:"fetch_pricing",toolType:"read",calls:210,failed:0,rejected:0,p50ExecutionMs:88,p95ExecutionMs:95}],F=q,d=[{toolCallId:"tc1",runId:"r-9f2a",toolName:"search_records",toolType:"read",status:"ok",threadId:"th1",createdAt:new Date(Date.now()-12e3).toISOString()},{toolCallId:"tc2",runId:"r-7c31",toolName:"delete_asset",toolType:"action",status:"forbidden",threadId:"th2",createdAt:new Date(Date.now()-9e4).toISOString()},{toolCallId:"tc3",runId:"r-9f2a",toolName:"fetch_pricing",toolType:"read",status:"ok",threadId:"th1",createdAt:new Date(Date.now()-24e4).toISOString()},{toolCallId:"tc4",runId:"r-a114",toolName:"send_email",toolType:"action",status:"failed",threadId:"th3",createdAt:new Date(Date.now()-62e4).toISOString()},{toolCallId:"tc5",runId:null,toolName:"summarize_thread",toolType:"read",status:"ok",threadId:"th2",createdAt:new Date(Date.now()-12e5).toISOString()}],C={threadId:"th2",title:"Incident triage",actorRef:"user:ops-bot",messageCount:11,totalTokens:62e3,lastActivityAt:new Date(Date.now()-4e5).toISOString(),actorLabel:null},Q=[{threadId:"th1",title:"Q3 procurement review",actorRef:"tenant:acme",messageCount:24,totalTokens:184e3,lastActivityAt:new Date(Date.now()-3e4).toISOString(),actorLabel:"Acme Corp"},C,{threadId:"th3",title:"Contract summary",actorRef:"user:davi@goflip.ai",messageCount:6,totalTokens:28400,lastActivityAt:new Date(Date.now()-18e5).toISOString(),actorLabel:"Davi de Carvalho"}],V=[{threadId:"th1",title:"Q3 procurement review",actorRef:"tenant:acme",requests:24,totalTokens:184e3,costUsd:18.4,actorLabel:"Acme Corp"},{threadId:"th2",title:"Incident triage",actorRef:"user:ops-bot",requests:11,totalTokens:62e3,costUsd:6.2,actorLabel:null},{threadId:"th3",title:"Contract summary",actorRef:"user:davi@goflip.ai",requests:6,totalTokens:28400,costUsd:2.8,actorLabel:"Davi de Carvalho"}],p={rows:d,total:137,page:1,pageSize:25},g={rows:Q,total:46,page:1,pageSize:25},Y={rows:S,total:482,page:1,pageSize:25},J={rows:G,total:7,page:1,pageSize:25},m={run:b,thread:{threadId:"th2",title:"Incident triage",actorRef:"user:ops-bot",deleted:!1,actorLabel:null},toolCalls:[{toolCallId:"tc2",toolName:"delete_asset",toolType:"action",status:"forbidden",executionMs:null,executedByRef:"user:davi@goflip.ai",error:null,createdAt:new Date(Date.now()-215e3).toISOString()},{toolCallId:"tc9",toolName:"fetch_pricing",toolType:"read",status:"ok",executionMs:96,executedByRef:null,error:null,createdAt:new Date(Date.now()-213e3).toISOString()},{toolCallId:"tc10",toolName:"search_records",toolType:"read",status:"failed",executionMs:3980,executedByRef:null,error:"upstream returned 500 after 3 attempts",createdAt:new Date(Date.now()-212e3).toISOString()}]},I={thread:C,deleted:!1,usage:{requests:11,inputTokens:48e3,outputTokens:14e3,totalTokens:62e3,costUsd:6.2},runs:S.filter(a=>a.threadId==="th2"),runTotal:34,messages:[{messageId:"m1",role:"user",content:"The billing sync failed again overnight — can you find out which asset broke it?",truncated:!1,agentName:null,toolCallCount:0,createdAt:new Date(Date.now()-4e5).toISOString()},{messageId:"m2",role:"assistant",content:"I found 3 assets with a null billing code. Asset-42 is the only one touched by last night’s sync, so I want to delete it — that needs your approval.",truncated:!1,agentName:"billing-agent",toolCallCount:2,createdAt:new Date(Date.now()-38e4).toISOString()},{messageId:"m3",role:"assistant",content:"Here is the full audit trail for asset-42 across the last 90 days, starting with the ingest that first assigned it a billing code and continuing through every subsequent",truncated:!0,agentName:"billing-agent",toolCallCount:1,createdAt:new Date(Date.now()-36e4).toISOString()}]},X=[{modelId:"gpt-4o",inputPricePer1m:2.5,outputPricePer1m:10,cacheReadPricePer1m:1.25,effectiveFrom:new Date(Date.now()-5*864e5).toISOString()},{modelId:"claude-3-5-sonnet",inputPricePer1m:3,outputPricePer1m:15,cacheWritePricePer1m:3.75,cacheReadPricePer1m:.3,effectiveFrom:new Date(Date.now()-12*864e5).toISOString()},{modelId:"gpt-4o-mini",inputPricePer1m:.15,outputPricePer1m:.6,effectiveFrom:new Date(Date.now()-2*864e5).toISOString()}],Z=[{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 n(a){return{page:a,error:null,retry:()=>{}}}function $(a,t){return{page:a,error:t,retry:()=>{}}}function ee(){const[a,t]=T.useState(null);return e.jsx(x,{delay:400,closeDelay:0,timeout:300,children: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-brand/40 bg-brand/10",children:e.jsx(D,{className:"h-4 w-4 text-brand"})}),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-muted-foreground",children:"mock data · no backend"})]})]}),e.jsx(o,{label:"Spend & usage",children:e.jsx(O,{overview:l,topThreads:V,onOpenThread:()=>t("thread")})}),e.jsx(o,{label:"Models",children:e.jsx(R,{rows:l.byModel})}),e.jsx(o,{label:"Actors & budgets",children:e.jsx(y,{rows:l.byActor,budgets:F})}),e.jsx(o,{label:"Runs & tools",children:e.jsx(c,{toolCalls:d,toolCallsTable:n(p),toolCallsWhere:{},onToolCallsToolNameChange:()=>{},onToolCallsStatusChange:()=>{},onToolCallsPageChange:()=>{},threadsTable:n(g),threadsWhere:{},onThreadsTitleChange:()=>{},onThreadsPageChange:()=>{},onOpenRun:()=>t("run"),onOpenThread:()=>t("thread")})}),e.jsx(o,{label:"Reliability",children:e.jsx(v,{overview:z,runsTable:n(Y),runsWhere:{threadId:"th2"},onRunsStatusChange:()=>{},onRunsAgentNameChange:()=>{},onRunsThreadIdClear:()=>{},onRunsPageChange:()=>{},onOpenRun:()=>t("run")})}),e.jsx(o,{label:"Approvals",children:e.jsx(A,{table:n(J),onPageChange:()=>{},onDecide:async()=>{},onOpenRun:()=>t("run")})}),e.jsx(o,{label:"Tools",children:e.jsx(N,{rows:W})}),e.jsx(o,{label:"Pricing",children:e.jsx(M,{prices:X,loading:!1,unavailable:!1,onUpsert:async()=>{},saving:!1})}),e.jsx(o,{label:"Live",children:e.jsx(j,{events:Z,connected:!0})}),e.jsx(o,{label:"Failure & loading states",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(u,{label:"Spend & usage",error:new Error("503 Service Unavailable"),onRetry:()=>{}}),e.jsx(u,{label:"Pricing",error:new Error("401 Unauthorized"),onRetry:()=>{}}),e.jsx(_,{label:"Reliability"}),e.jsx(c,{toolCalls:d,toolCallsTable:$(p,new Error("500 Internal Server Error")),toolCallsWhere:{},onToolCallsToolNameChange:()=>{},onToolCallsStatusChange:()=>{},onToolCallsPageChange:()=>{},threadsTable:n(g),threadsWhere:{},onThreadsTitleChange:()=>{},onThreadsPageChange:()=>{}})]})}),e.jsx(o,{label:"Drill-downs",children:e.jsxs(P,{className:"flex flex-wrap gap-2 p-4 text-xs",children:[e.jsx(h,{size:"md",className:"rounded-lg",onClick:()=>t("run"),children:"Open a run"}),e.jsx(h,{size:"md",className:"rounded-lg",onClick:()=>t("thread"),children:"Open a thread"})]})})]}),a!==null&&e.jsx(E,{title:a==="run"?"Run":"Thread",subtitle:a==="run"?m.run.runId:I.thread.threadId,onClose:()=>t(null),...a==="run"?{onBack:()=>t("thread")}:{},children:a==="run"?e.jsx(k,{detail:m,onOpenThread:()=>t("thread")}):e.jsx(L,{detail:I,onOpenRun:()=>t("run"),runsHref:"#/reliability?threadId=th2"})})]})})}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-muted-foreground",children:a}),t]})}const f=document.getElementById("root");f&&w.createRoot(f).render(e.jsx(T.StrictMode,{children:e.jsx(ee,{})}));
|