@dudousxd/nestjs-agent-dashboard 0.19.1 → 0.20.0
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/README.md +121 -27
- package/dist/client/agent-client.d.ts +13 -0
- package/dist/client/agent-client.d.ts.map +1 -1
- package/dist/client/agent-client.js +30 -3
- package/dist/client/agent-client.js.map +1 -1
- package/dist/server/index.cjs +437 -49
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +150 -18
- package/dist/server/index.d.ts +150 -18
- package/dist/server/index.js +400 -35
- package/dist/server/index.js.map +1 -1
- package/dist/spa/assets/index-ClnZsvJ1.css +1 -0
- package/dist/spa/assets/index-D3yTBCU0.js +1 -0
- package/dist/spa/assets/{index-eW1zMwDF.js → index-DS11tOEH.js} +1 -1
- package/dist/spa/assets/{preview-Ch59R-LE.js → preview-CbqJ2CAQ.js} +1 -1
- package/dist/spa/index.html +3 -3
- package/dist/spa/preview.html +3 -3
- package/package.json +10 -4
- package/dist/spa/assets/index-B1znMy6W.css +0 -1
- package/dist/spa/assets/index-DzukxAmy.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var Jt=t=>{throw TypeError(t)};var bt=(t,e,s)=>e.has(t)||Jt("Cannot "+s);var n=(t,e,s)=>(bt(t,e,"read from private field"),s?s.call(t):e.get(t)),d=(t,e,s)=>e.has(t)?Jt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),l=(t,e,s,r)=>(bt(t,e,"write to private field"),r?r.call(t,s):e.set(t,s),s),m=(t,e,s)=>(bt(t,e,"access private method"),s);var ut=(t,e,s,r)=>({set _(i){l(t,e,i,s)},get _(){return n(t,e,r)}});import{u as Ps,L as Rs,A as tr,D as sr,R as rr,T as nr,C as ir,E as ar,I as or,a as ur,S as Os,b as cr,G as lr,M as hr,P as dr,c as fr,d as pr,e as yr,f as mr,g as gr,p as vr,h as br,i as Sr,U as wr,W as Yt,j as Cr,k as xr,l as Pr,m as Rr,n as Or,o as Tr,B as Ts,q as Er,r as jr,s as Dr,t as Fr,v as Ir,w as Qr,x as Ar}from"./index-DS11tOEH.js";import{r as b,j as c,P as Mr,b as qr,d as kr,e as Nr,f as Ur}from"./base-ui-Bm0nR785.js";import"./recharts-CURTGZ5d.js";const Es=b.createContext(void 0),ot=t=>{const e=b.useContext(Es);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Lr=({client:t,children:e})=>(b.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),c.jsx(Es.Provider,{value:t,children:e})),_r={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)};var le,Lt,ds,Kr=(ds=class{constructor(){d(this,le,_r);d(this,Lt,!1)}setTimeoutProvider(t){l(this,le,t)}setTimeout(t,e){return n(this,le).setTimeout(t,e)}clearTimeout(t){n(this,le).clearTimeout(t)}setInterval(t,e){return n(this,le).setInterval(t,e)}clearInterval(t){n(this,le).clearInterval(t)}},le=new WeakMap,Lt=new WeakMap,ds);const be=new Kr;function $r(t){setTimeout(t,0)}const Hr=typeof window>"u"||"Deno"in globalThis;function _(){}function Br(t,e){return typeof t=="function"?t(e):t}function js(t){return typeof t=="number"&&t>=0&&t!==1/0}function Ds(t,e){return Math.max(t+(e||0)-Date.now(),0)}function j(t,e){return typeof t=="function"?t(e):t}function Zt(t,e){const{type:s="all",exact:r,fetchStatus:i,predicate:a,queryKey:u,stale:o}=t;if(u){if(r){if(e.queryHash!==_t(u,e.options))return!1}else if(!ze(e.queryKey,u))return!1}if(s!=="all"){const h=e.isActive();if(s==="active"&&!h||s==="inactive"&&h)return!1}return!(typeof o=="boolean"&&e.isStale()!==o||i&&i!==e.state.fetchStatus||a&&!a(e))}function Xt(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 _t(t,e){return((e==null?void 0:e.queryKeyHashFn)||Fe)(t)}function Fe(t){return JSON.stringify(t,(e,s)=>St(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 Gr=Object.prototype.hasOwnProperty;function Kt(t,e,s=0){if(t===e)return t;if(s>500)return e;const r=es(t)&&es(e);if(!r&&!(St(t)&&St(e)))return e;const i=(r?t:Object.keys(t)).length,a=r?e:Object.keys(e),u=a.length,o=r?new Array(u):{};let h=0;for(let y=0;y<u;y++){const p=r?y:a[y],g=t[p],f=e[p];if(g===f){o[p]=g,(r?y<i:Gr.call(t,p))&&h++;continue}if(g===null||f===null||typeof g!="object"||typeof f!="object"){o[p]=f;continue}const C=Kt(g,f,s+1);o[p]=C,C===g&&h++}return i===u&&h===i?t:o}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 es(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function St(t){if(!ts(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!(!ts(r)||!r.hasOwnProperty("isPrototypeOf")||e!==Object.prototype)}function ts(t){return Object.prototype.toString.call(t)==="[object Object]"}function Wr(t){return new Promise(e=>{be.setTimeout(e,t)})}function wt(t,e,s){return typeof s.structuralSharing=="function"?s.structuralSharing(t,e):s.structuralSharing!==!1?Kt(t,e):e}function yt(t){return t}function zr(t,e,s=0){const r=[...t,e];return s&&r.length>s?r.slice(1):r}function Vr(t,e,s=0){const r=[e,...t];return s&&r.length>s?r.slice(0,-1):r}const $t=Symbol();function Fs(t,e){return!t.queryFn&&(e!=null&&e.initialPromise)?()=>e.initialPromise:!t.queryFn||t.queryFn===$t?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function Ht(t,e){return typeof t=="function"?t(...e):!!t}function Jr(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 Yr=()=>Hr;const Bt=()=>Yr();var Ie=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,he,Qe,fs,Zr=(fs=class extends Ie{constructor(){super();d(this,Se);d(this,he);d(this,Qe);l(this,Qe,e=>{if(typeof window<"u"&&window.addEventListener){const s=()=>e();return window.addEventListener("visibilitychange",s,!1),()=>{window.removeEventListener("visibilitychange",s)}}})}onSubscribe(){n(this,he)||this.setEventListener(n(this,Qe))}onUnsubscribe(){var e;this.hasListeners()||((e=n(this,he))==null||e.call(this),l(this,he,void 0))}setEventListener(e){var s;l(this,Qe,e),(s=n(this,he))==null||s.call(this),l(this,he,e(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(e){n(this,Se)!==e&&(l(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,he=new WeakMap,Qe=new WeakMap,fs);const Gt=new Zr,Xr=$r;function en(){let t=[],e=0,s=o=>{o()},r=o=>{o()},i=Xr;const a=o=>{e?t.push(o):i(()=>{s(o)})},u=()=>{const o=t;t=[],o.length&&i(()=>{r(()=>{o.forEach(h=>{s(h)})})})};return{batch:o=>{let h;e++;try{h=o()}finally{e--,e||u()}return h},batchCalls:o=>(...h)=>{a(()=>{o(...h)})},schedule:a,setNotifyFunction:o=>{s=o},setBatchNotifyFunction:o=>{r=o},setScheduler:o=>{i=o}}}const I=en();var Ae,de,Me,ps,tn=(ps=class extends Ie{constructor(){super();d(this,Ae,!0);d(this,de);d(this,Me);l(this,Me,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,de)||this.setEventListener(n(this,Me))}onUnsubscribe(){var e;this.hasListeners()||((e=n(this,de))==null||e.call(this),l(this,de,void 0))}setEventListener(e){var s;l(this,Me,e),(s=n(this,de))==null||s.call(this),l(this,de,e(this.setOnline.bind(this)))}setOnline(e){n(this,Ae)!==e&&(l(this,Ae,e),this.listeners.forEach(s=>{s(e)}))}isOnline(){return n(this,Ae)}},Ae=new WeakMap,de=new WeakMap,Me=new WeakMap,ps);const dt=new tn;function sn(t){return Math.min(1e3*2**t,3e4)}function Is(t){return(t??"online")==="online"?dt.isOnline():!0}var Ct=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function Qs(t){let e=!1,s=0,r,i="pending",a,u;const o=new Promise((P,R)=>{a=P,u=R});o.catch(_);const h=()=>i!=="pending",y=P=>{var R;if(!h()){const T=new Ct(P);S(T),(R=t.onCancel)==null||R.call(t,T)}},p=()=>{e=!0},g=()=>{e=!1},f=()=>Gt.isFocused()&&(t.networkMode==="always"||dt.isOnline())&&t.canRun(),C=()=>Is(t.networkMode)&&t.canRun(),Q=P=>{h()||(r==null||r(),i="resolved",a(P))},S=P=>{h()||(r==null||r(),i="rejected",u(P))},w=()=>new Promise(P=>{var R;r=T=>{(h()||f())&&P(T)},(R=t.onPause)==null||R.call(t)}).then(()=>{var P;r=void 0,h()||(P=t.onContinue)==null||P.call(t)}),E=()=>{if(h())return;let P;const R=s===0?t.initialPromise:void 0;try{P=R??t.fn()}catch(T){P=Promise.reject(T)}Promise.resolve(P).then(Q).catch(T=>{var D;if(h())return;const v=t.retry??(Bt()?0:3),K=t.retryDelay??sn,A=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),Wr(A).then(()=>f()?void 0:w()).then(()=>{e?S(T):E()})})};return{promise:o,status:()=>i,cancel:y,continue:()=>(r==null||r(),o),cancelRetry:p,continueRetry:g,canStart:C,start:()=>(C()?E():w().then(E),o)}}var we,ys,As=(ys=class{constructor(){d(this,we)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),js(this.gcTime)&&l(this,we,be.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Bt()?1/0:3e5))}clearGcTimeout(){n(this,we)!==void 0&&(be.clearTimeout(n(this,we)),l(this,we,void 0))}},we=new WeakMap,ys);function rn(t){return{onFetch:(e,s)=>{var p,g,f,C,Q;const r=e.options,i=(f=(g=(p=e.fetchOptions)==null?void 0:p.meta)==null?void 0:g.fetchMore)==null?void 0:f.direction,a=((C=e.state.data)==null?void 0:C.pages)||[],u=((Q=e.state.data)==null?void 0:Q.pageParams)||[];let o={pages:[],pageParams:[]},h=0;const y=async()=>{let S=!1;const w=R=>{Jr(R,()=>e.signal,()=>S=!0)},E=Fs(e.options,e.fetchOptions),P=async(R,T,v)=>{if(S)return Promise.reject(e.signal.reason);if(T==null&&R.pages.length)return Promise.resolve(R);const A=(()=>{const Vt={client:e.client,queryKey:e.queryKey,pageParam:T,direction:v?"backward":"forward",meta:e.options.meta};return w(Vt),Vt})(),J=await E(A),{maxPages:D}=e.options,$=v?Vr:zr;return{pages:$(R.pages,J,D),pageParams:$(R.pageParams,T,D)}};if(i&&a.length){const R=i==="backward",T=R?nn:ss,v={pages:a,pageParams:u};o=await P(v,T(r,v),R)}else{const R=t??a.length;do{const T=h===0?u[0]??r.initialPageParam:ss(r,o);if(h>0&&T==null)break;o=await P(o,T),h++}while(h<R)}return o};e.options.persister?e.fetchFn=()=>{var S,w;return(w=(S=e.options).persister)==null?void 0:w.call(S,y,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},s)}:e.fetchFn=y}}}function ss(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 nn(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,xe,M,Ze,Pe,Y,re,ms,an=(ms=class extends As{constructor(e){super();d(this,Y);d(this,qe);d(this,Ce);d(this,ke);d(this,V);d(this,xe);d(this,M);d(this,Ze);d(this,Pe);l(this,Pe,!1),l(this,Ze,e.defaultOptions),this.setOptions(e.options),this.observers=[],l(this,xe,e.client),l(this,V,n(this,xe).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,l(this,Ce,ns(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,M))==null?void 0:e.promise}setOptions(e){if(this.options={...n(this,Ze),...e},e!=null&&e._type&&l(this,qe,e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const s=ns(this.options);s.data!==void 0&&(this.setState(rs(s.data,s.dataUpdatedAt)),l(this,Ce,s))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&n(this,V).remove(this)}setData(e,s){const r=wt(this.state.data,e,this.options);return m(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){m(this,Y,re).call(this,{type:"setState",state:e})}cancel(e){var r,i;const s=(r=n(this,M))==null?void 0:r.promise;return(i=n(this,M))==null||i.cancel(e),s?s.then(_).catch(_):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===$t||!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:!Ds(this.state.dataUpdatedAt,e)}onFocus(){var e,s;(e=this.observers.find(r=>r.shouldFetchOnWindowFocus()))==null||e.refetch({cancelRefetch:!1}),(s=n(this,M))==null||s.continue()}onOnline(){var e,s;(e=this.observers.find(r=>r.shouldFetchOnReconnect()))==null||e.refetch({cancelRefetch:!1}),(s=n(this,M))==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,M)&&(n(this,Pe)||this.state.fetchStatus==="paused"&&this.state.status==="pending"?n(this,M).cancel({revert:!0}):n(this,M).cancelRetry()),this.scheduleGc()),n(this,V).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||m(this,Y,re).call(this,{type:"invalidate"})}async fetch(e,s){var y,p,g,f,C,Q,S,w,E,P,R,T;if(this.state.fetchStatus!=="idle"&&((y=n(this,M))==null?void 0:y.status())!=="rejected"){if(this.state.data!==void 0&&(s!=null&&s.cancelRefetch))this.cancel({silent:!0});else if(n(this,M))return n(this,M).continueRetry(),n(this,M).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:()=>(l(this,Pe,!0),r.signal)})},a=()=>{const v=Fs(this.options,s),A=(()=>{const J={client:n(this,xe),queryKey:this.queryKey,meta:this.meta};return i(J),J})();return l(this,Pe,!1),this.options.persister?this.options.persister(v,A,this):v(A)},o=(()=>{const v={fetchOptions:s,options:this.options,queryKey:this.queryKey,client:n(this,xe),state:this.state,fetchFn:a};return i(v),v})();(p=n(this,qe)==="infinite"?rn(this.options.pages):this.options.behavior)==null||p.onFetch(o,this),l(this,ke,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((g=o.fetchOptions)==null?void 0:g.meta))&&m(this,Y,re).call(this,{type:"fetch",meta:(f=o.fetchOptions)==null?void 0:f.meta});const h=l(this,M,Qs({initialPromise:s==null?void 0:s.initialPromise,fn:o.fetchFn,onCancel:v=>{v instanceof Ct&&v.revert&&this.setState({...n(this,ke),fetchStatus:"idle"}),r.abort()},onFail:(v,K)=>{m(this,Y,re).call(this,{type:"failed",failureCount:v,error:K})},onPause:()=>{m(this,Y,re).call(this,{type:"pause"})},onContinue:()=>{m(this,Y,re).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.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),(Q=(C=n(this,V).config).onSuccess)==null||Q.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 Ct){if(v.silent)return n(this,M).promise;if(v.revert){if(this.state.data===void 0)throw v;return this.state.data}}throw m(this,Y,re).call(this,{type:"error",error:v}),(P=(E=n(this,V).config).onError)==null||P.call(E,v,this),(T=(R=n(this,V).config).onSettled)==null||T.call(R,this.state.data,v,this),v}finally{n(this,M)===h&&l(this,M,void 0),this.scheduleGc()}}},qe=new WeakMap,Ce=new WeakMap,ke=new WeakMap,V=new WeakMap,xe=new WeakMap,M=new WeakMap,Ze=new WeakMap,Pe=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,...Ms(r.data,this.options),fetchMeta:e.meta??null};case"success":const i={...r,...rs(e.data,e.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return l(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),I.batch(()=>{this.observers.slice().forEach(r=>{r.onQueryUpdate()}),n(this,V).notify({query:this,type:"updated",action:e})})},ms);function Ms(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Is(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function rs(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function ns(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,x,Xe,B,Re,Ne,ne,et,Ue,Le,Oe,Te,fe,_e,O,Ve,xt,Pt,Rt,Ot,Tt,Et,jt,Dt,gs,mt=(gs=class extends Ie{constructor(e,s){super();d(this,O);d(this,H);d(this,x);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,fe);d(this,_e,new Set);this.options=s,l(this,H,e),l(this,ne,null),this.bindMethods(),this.setOptions(s)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(n(this,x).addObserver(this),is(n(this,x),this.options)?m(this,O,Ve).call(this):this.updateResult(),m(this,O,Tt).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ft(n(this,x),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ft(n(this,x),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,m(this,O,Et).call(this),m(this,O,jt).call(this),n(this,x).removeObserver(this)}setOptions(e){const s=this.options,r=n(this,x);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,x))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");m(this,O,Dt).call(this),n(this,x).setOptions(this.options),s._defaulted&&!Ye(this.options,s)&&n(this,H).getQueryCache().notify({type:"observerOptionsUpdated",query:n(this,x),observer:this});const i=this.hasListeners();i&&as(n(this,x),r,this.options,s)&&m(this,O,Ve).call(this),this.updateResult(),i&&(n(this,x)!==r||j(this.options.enabled,n(this,x))!==j(s.enabled,n(this,x))||j(this.options.staleTime,n(this,x))!==j(s.staleTime,n(this,x)))&&m(this,O,Pt).call(this);const a=m(this,O,Rt).call(this);i&&(n(this,x)!==r||j(this.options.enabled,n(this,x))!==j(s.enabled,n(this,x))||a!==n(this,fe))&&m(this,O,Ot).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)||(l(this,B,r),l(this,Ne,this.options),l(this,Re,n(this,x).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,_e).add(e)}getCurrentQuery(){return n(this,x)}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 u=new Promise(o=>{a=o,i=n(this,H).getQueryCache().subscribe(h=>{h.type==="updated"&&h.query.queryHash===r.queryHash&&r.state.data!==void 0&&(i(),o(this.createResult(r,s)))})});return Promise.race([r.fetch().then(()=>{const o=this.createResult(r,s);return a==null||a(o),o}).finally(()=>{i()}),u])}fetch(e){return m(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,x),i=this.options,a=n(this,B),u=n(this,Re),o=n(this,Ne),h=e!==r?e.state:n(this,Xe),{state:y}=e;let p={...y},g=!1,f;if(s._optimisticResults){const A=this.hasListeners(),J=!A&&is(e,s),D=A&&as(e,r,s,i);(J||D)&&(p={...p,...Ms(y.data,e.options)}),s._optimisticResults==="isRestoring"&&(p.fetchStatus="idle")}let{error:C,errorUpdatedAt:Q,status:S}=p;f=p.data;let w=!1;if(s.placeholderData!==void 0&&f===void 0&&S==="pending"){let A;a!=null&&a.isPlaceholderData&&s.placeholderData===(o==null?void 0:o.placeholderData)?(A=a.data,w=!0):A=typeof s.placeholderData=="function"?s.placeholderData((K=n(this,Le))==null?void 0:K.state.data,n(this,Le)):s.placeholderData,A!==void 0&&(S="success",f=wt(a==null?void 0:a.data,A,s),g=!0)}if(s.select&&f!==void 0&&!w)if(a&&f===(u==null?void 0:u.data)&&s.select===n(this,et))f=n(this,Ue);else try{l(this,et,s.select),f=s.select(f),f=wt(a==null?void 0:a.data,f,s),l(this,Ue,f),l(this,ne,null)}catch(A){l(this,ne,A)}else f===void 0&&l(this,ne,null);n(this,ne)&&(C=n(this,ne),f=n(this,Ue),Q=Date.now(),S="error",g=!1);const E=p.fetchStatus==="fetching",P=S==="pending",R=S==="error",T=P&&E,v=f!==void 0;return{status:S,fetchStatus:p.fetchStatus,isPending:P,isSuccess:S==="success",isError:R,isInitialLoading:T,isLoading:T,data:f,dataUpdatedAt:p.dataUpdatedAt,error:C,errorUpdatedAt:Q,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&&!P,isLoadingError:R&&!v,isPaused:p.fetchStatus==="paused",isPlaceholderData:g,isRefetchError:R&&v,isStale:Wt(e,s),refetch:this.refetch,isEnabled:j(s.enabled,e)!==!1}}updateResult(){const e=n(this,B),s=this.createResult(n(this,x),this.options);if(l(this,Re,n(this,x).state),l(this,Ne,this.options),n(this,Re).data!==void 0&&l(this,Le,n(this,x)),Ye(s,e))return;l(this,B,s);const i=(()=>{if(!e)return!0;const{notifyOnChangeProps:a}=this.options,u=typeof a=="function"?a():a;if(u==="all"||!u&&!n(this,_e).size)return!0;const o=new Set(u??n(this,_e));return this.options.throwOnError&&o.add("error"),Object.keys(n(this,B)).some(h=>{const y=h;return n(this,B)[y]!==e[y]&&o.has(y)})})();I.batch(()=>{i&&this.listeners.forEach(a=>{a(n(this,B))}),n(this,H).getQueryCache().notify({query:n(this,x),type:"observerResultsUpdated"})})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&m(this,O,Tt).call(this)}},H=new WeakMap,x=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,fe=new WeakMap,_e=new WeakMap,O=new WeakSet,Ve=function(e){m(this,O,Dt).call(this);let s=n(this,x).fetch(this.options,e);return e!=null&&e.throwOnError||(s=s.catch(_)),s},xt=function(e){return!Bt()&&j(this.options.enabled,n(this,x))!==!1&&js(e)},Pt=function(){m(this,O,Et).call(this);const e=j(this.options.staleTime,n(this,x));if(n(this,B).isStale||!m(this,O,xt).call(this,e))return;const s=Ds(n(this,B).dataUpdatedAt,e)+1;l(this,Oe,be.setTimeout(()=>{n(this,B).isStale||this.updateResult()},s))},Rt=function(){return j(this.options.refetchInterval,n(this,x))??!1},Ot=function(e){m(this,O,jt).call(this),l(this,fe,e),!(n(this,fe)===0||!m(this,O,xt).call(this,n(this,fe)))&&l(this,Te,be.setInterval(()=>{(this.options.refetchIntervalInBackground||Gt.isFocused())&&m(this,O,Ve).call(this)},n(this,fe)))},Tt=function(){m(this,O,Pt).call(this),m(this,O,Ot).call(this,m(this,O,Rt).call(this))},Et=function(){n(this,Oe)!==void 0&&(be.clearTimeout(n(this,Oe)),l(this,Oe,void 0))},jt=function(){n(this,Te)!==void 0&&(be.clearInterval(n(this,Te)),l(this,Te,void 0))},Dt=function(){const e=n(this,H).getQueryCache().build(n(this,H),this.options);if(e===n(this,x))return;const s=n(this,x);l(this,x,e),l(this,Xe,e.state),this.hasListeners()&&(s==null||s.removeObserver(this),e.addObserver(this))},gs);function on(t,e){return j(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&j(e.retryOnMount,t)===!1)}function is(t,e){return on(t,e)||t.state.data!==void 0&&Ft(t,e,e.refetchOnMount)}function Ft(t,e,s){if(j(e.enabled,t)!==!1&&j(e.staleTime,t)!=="static"){const r=j(s,t);return r==="always"||r!==!1&&Wt(t,e)}return!1}function as(t,e,s,r){return(t!==e||j(r.enabled,t)===!1)&&(!s.suspense||t.state.status!=="error")&&Wt(t,s)}function Wt(t,e){return j(e.enabled,t)!==!1&&t.isStaleByTime(j(e.staleTime,t))}var tt,X,U,Ee,ee,ce,vs,un=(vs=class extends As{constructor(e){super();d(this,ee);d(this,tt);d(this,X);d(this,U);d(this,Ee);l(this,tt,e.client),this.mutationId=e.mutationId,l(this,U,e.mutationCache),l(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,U).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){l(this,X,n(this,X).filter(s=>s!==e)),this.scheduleGc(),n(this,U).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){n(this,X).length||(this.state.status==="pending"?this.scheduleGc():n(this,U).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 o,h,y,p,g,f,C,Q,S,w,E,P,R,T,v,K,A,J;const s=()=>{m(this,ee,ce).call(this,{type:"continue"})},r={client:n(this,tt),meta:this.options.meta,mutationKey:this.options.mutationKey},i=l(this,Ee,Qs({fn:()=>this.options.mutationFn?this.options.mutationFn(e,r):Promise.reject(new Error("No mutationFn found")),onFail:(D,$)=>{m(this,ee,ce).call(this,{type:"failed",failureCount:D,error:$})},onPause:()=>{m(this,ee,ce).call(this,{type:"pause"})},onContinue:s,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>n(this,U).canRun(this)})),a=this.state.status==="pending",u=!i.canStart();try{if(a)s();else{m(this,ee,ce).call(this,{type:"pending",variables:e,isPaused:u}),n(this,U).config.onMutate&&await n(this,U).config.onMutate(e,this,r);const $=await((h=(o=this.options).onMutate)==null?void 0:h.call(o,e,r));$!==this.state.context&&m(this,ee,ce).call(this,{type:"pending",context:$,variables:e,isPaused:u})}const D=await i.start();return await((p=(y=n(this,U).config).onSuccess)==null?void 0:p.call(y,D,e,this.state.context,this,r)),await((f=(g=this.options).onSuccess)==null?void 0:f.call(g,D,e,this.state.context,r)),await((Q=(C=n(this,U).config).onSettled)==null?void 0:Q.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)),m(this,ee,ce).call(this,{type:"success",data:D}),D}catch(D){try{await((P=(E=n(this,U).config).onError)==null?void 0:P.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,U).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=(A=this.options).onSettled)==null?void 0:J.call(A,void 0,D,e,this.state.context,r))}catch($){Promise.reject($)}throw m(this,ee,ce).call(this,{type:"error",error:D}),D}finally{n(this,Ee)===i&&l(this,Ee,void 0),n(this,U).runNext(this)}}},tt=new WeakMap,X=new WeakMap,U=new WeakMap,Ee=new WeakMap,ee=new WeakSet,ce=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),I.batch(()=>{n(this,X).forEach(r=>{r.onMutationUpdate(e)}),n(this,U).notify({mutation:this,type:"updated",action:e})})},vs);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,bs,cn=(bs=class extends Ie{constructor(e={}){super();d(this,ie);d(this,Z);d(this,st);this.config=e,l(this,ie,new Set),l(this,Z,new Map),l(this,st,0)}build(e,s,r){const i=new un({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(){I.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=>Xt(s,r))}findAll(e={}){return this.getAll().filter(s=>Xt(e,s))}notify(e){I.batch(()=>{this.listeners.forEach(s=>{s(e)})})}resumePausedMutations(){const e=this.getAll().filter(s=>s.state.isPaused);return I.batch(()=>Promise.all(e.map(s=>s.continue().catch(_))))}},ie=new WeakMap,Z=new WeakMap,st=new WeakMap,bs);function ct(t){var e;return(e=t.options.scope)==null?void 0:e.id}var ae,pe,L,oe,se,Je,It,Ss,ln=(Ss=class extends Ie{constructor(e,s){super();d(this,se);d(this,ae);d(this,pe);d(this,L);d(this,oe);l(this,ae,e),this.setOptions(s),this.bindMethods(),m(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,L),observer:this}),s!=null&&s.mutationKey&&this.options.mutationKey&&Fe(s.mutationKey)!==Fe(this.options.mutationKey)?this.reset():((r=n(this,L))==null?void 0:r.state.status)==="pending"&&n(this,L).setOptions(this.options)}onSubscribe(){this.listeners.size===1&&n(this,L)&&(n(this,L).addObserver(this),m(this,se,Je).call(this))}onUnsubscribe(){var e;this.hasListeners()||(e=n(this,L))==null||e.removeObserver(this)}onMutationUpdate(e){m(this,se,Je).call(this),m(this,se,It).call(this,e)}getCurrentResult(){return n(this,pe)}reset(){var e;(e=n(this,L))==null||e.removeObserver(this),l(this,L,void 0),m(this,se,Je).call(this),m(this,se,It).call(this)}mutate(e,s){var r;return l(this,oe,s),(r=n(this,L))==null||r.removeObserver(this),l(this,L,n(this,ae).getMutationCache().build(n(this,ae),this.options)),n(this,L).addObserver(this),n(this,L).execute(e)}},ae=new WeakMap,pe=new WeakMap,L=new WeakMap,oe=new WeakMap,se=new WeakSet,Je=function(){var s;const e=((s=n(this,L))==null?void 0:s.state)??qs();l(this,pe,{...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset})},It=function(e){I.batch(()=>{var s,r,i,a,u,o,h,y;if(n(this,oe)&&this.hasListeners()){const p=n(this,pe).variables,g=n(this,pe).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,g,f)}catch(C){Promise.reject(C)}try{(a=(i=n(this,oe)).onSettled)==null||a.call(i,e.data,null,p,g,f)}catch(C){Promise.reject(C)}}else if((e==null?void 0:e.type)==="error"){try{(o=(u=n(this,oe)).onError)==null||o.call(u,e.error,p,g,f)}catch(C){Promise.reject(C)}try{(y=(h=n(this,oe)).onSettled)==null||y.call(h,void 0,e.error,p,g,f)}catch(C){Promise.reject(C)}}}this.listeners.forEach(p=>{p(n(this,pe))})})},Ss);function os(t,e){const s=new Set(e);return t.filter(r=>!s.has(r))}var Ke,G,$e,je,z,De,rt,nt,it,at,q,Qt,At,ks,Mt,qt,kt,ws,hn=(ws=class extends Ie{constructor(e,s,r){super();d(this,q);d(this,Ke);d(this,G);d(this,$e);d(this,je);d(this,z);d(this,De);d(this,rt);d(this,nt);d(this,it);d(this,at,[]);l(this,Ke,e),l(this,je,r),l(this,$e,[]),l(this,z,[]),l(this,G,[]),this.setQueries(s)}onSubscribe(){this.listeners.size===1&&n(this,z).forEach(e=>{e.subscribe(s=>{m(this,q,qt).call(this,e,s)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,n(this,z).forEach(e=>{e.destroy()})}setQueries(e,s){l(this,$e,e),l(this,je,s),I.batch(()=>{const r=n(this,z),i=m(this,q,Mt).call(this,n(this,$e));i.forEach(g=>g.observer.setOptions(g.defaultedQueryOptions));const a=i.map(g=>g.observer),u=a.map(g=>g.getCurrentResult()),o=r.length!==a.length,h=a.some((g,f)=>g!==r[f]),y=o||h,p=y?!0:u.some((g,f)=>{const C=n(this,G)[f];return!C||!Ye(g,C)});!y&&!p||(y&&(l(this,at,i),l(this,z,a)),l(this,G,u),this.hasListeners()&&(y&&(os(r,a).forEach(g=>{g.destroy()}),os(a,r).forEach(g=>{g.subscribe(f=>{m(this,q,qt).call(this,g,f)})})),m(this,q,kt).call(this)))})}getCurrentResult(){return n(this,G)}getQueries(){return n(this,z).map(e=>e.getCurrentQuery())}getObservers(){return n(this,z)}getOptimisticResult(e,s){const r=m(this,q,Mt).call(this,e),i=r.map(u=>u.observer.getOptimisticResult(u.defaultedQueryOptions)),a=r.map(u=>u.defaultedQueryOptions.queryHash);return[i,u=>m(this,q,At).call(this,u??i,s,a),()=>m(this,q,Qt).call(this,i,r)]}},Ke=new WeakMap,G=new WeakMap,$e=new WeakMap,je=new WeakMap,z=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 u=e[a];return i.defaultedQueryOptions.notifyOnChangeProps?u:i.observer.trackResult(u,o=>{r.has(o)||(r.add(o),s.forEach(h=>{h.observer.trackProp(o)}))})})},At=function(e,s,r){if(s){const i=n(this,it),a=r!==void 0&&i!==void 0&&(i.length!==r.length||r.some((u,o)=>u!==i[o]));return(n(this,G)!==n(this,nt)||a||s!==n(this,rt))&&(l(this,rt,s),l(this,nt,n(this,G)),r!==void 0&&l(this,it,r),l(this,De,Kt(n(this,De),s(e)))),n(this,De)}return e},ks=function(){var e;return!((e=n(this,je))!=null&&e.combine)||n(this,z).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,z).forEach(i=>{const a=i.options.queryHash;if(!a)return;const u=s.get(a);u?u.push(i):s.set(a,[i])});const r=[];return e.forEach(i=>{var o;const a=n(this,Ke).defaultQueryOptions(i),u=((o=s.get(a.queryHash))==null?void 0:o.shift())??new mt(n(this,Ke),a);r.push({defaultedQueryOptions:a,observer:u})}),r},qt=function(e,s){const r=n(this,z).indexOf(e);r!==-1&&(l(this,G,n(this,G).slice()),n(this,G)[r]=s,m(this,q,kt).call(this))},kt=function(){var e;if(this.hasListeners()){const s=m(this,q,ks).call(this),r=n(this,De),i=s?r:m(this,q,At).call(this,m(this,q,Qt).call(this,n(this,G),n(this,at)),(e=n(this,je))==null?void 0:e.combine);(s||r!==i)&&I.batch(()=>{this.listeners.forEach(a=>{a(n(this,G))})})}},ws),te,Cs,dn=(Cs=class extends Ie{constructor(e={}){super();d(this,te);this.config=e,l(this,te,new Map)}build(e,s,r){const i=s.queryKey,a=s.queryHash??_t(i,s);let u=this.get(a);return u||(u=new an({client:e,queryKey:i,queryHash:a,options:e.defaultQueryOptions(s),state:r,defaultOptions:e.getQueryDefaults(i)}),this.add(u)),u}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(){I.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=>Zt(s,r))}findAll(e={}){const s=this.getAll();return Object.keys(e).length>0?s.filter(r=>Zt(e,r)):s}notify(e){I.batch(()=>{this.listeners.forEach(s=>{s(e)})})}onFocus(){I.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){I.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},te=new WeakMap,Cs),F,ye,me,He,Be,ge,Ge,We,xs,fn=(xs=class{constructor(t={}){d(this,F);d(this,ye);d(this,me);d(this,He);d(this,Be);d(this,ge);d(this,Ge);d(this,We);l(this,F,t.queryCache||new dn),l(this,ye,t.mutationCache||new cn),l(this,me,t.defaultOptions||{}),l(this,He,new Map),l(this,Be,new Map),l(this,ge,0)}mount(){ut(this,ge)._++,n(this,ge)===1&&(l(this,Ge,Gt.subscribe(async t=>{t&&(await this.resumePausedMutations(),n(this,F).onFocus())})),l(this,We,dt.subscribe(async t=>{t&&(await this.resumePausedMutations(),n(this,F).onOnline())})))}unmount(){var t,e;ut(this,ge)._--,n(this,ge)===0&&((t=n(this,Ge))==null||t.call(this),l(this,Ge,void 0),(e=n(this,We))==null||e.call(this),l(this,We,void 0))}isFetching(t){return n(this,F).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return n(this,ye).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 u;const r=this.defaultQueryOptions({queryKey:t}),i=(u=n(this,F).get(r.queryHash))==null?void 0:u.state.data,a=Br(e,i);if(a!==void 0)return n(this,F).build(this,r).setData(a,{...s,manual:!0})}setQueriesData(t,e,s){return I.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);I.batch(()=>{e.findAll(t).forEach(s=>{e.remove(s)})})}resetQueries(t,e){const s=n(this,F);return I.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=I.batch(()=>n(this,F).findAll(t).map(i=>i.cancel(s)));return Promise.all(r).then(_).catch(_)}invalidateQueries(t,e={}){return I.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=I.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(_)),i.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(_)}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(_).catch(_)}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(_).catch(_)}ensureInfiniteQueryData(t){return t._type="infinite",this.ensureQueryData(t)}resumePausedMutations(){return dt.isOnline()?n(this,ye).resumePausedMutations():Promise.resolve()}getQueryCache(){return n(this,F)}getMutationCache(){return n(this,ye)}getDefaultOptions(){return n(this,me)}setDefaultOptions(t){l(this,me,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,me).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=_t(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===$t&&(e.enabled=!1),e}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...n(this,me).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){n(this,F).clear(),n(this,ye).clear()}},F=new WeakMap,ye=new WeakMap,me=new WeakMap,He=new WeakMap,Be=new WeakMap,ge=new WeakMap,Ge=new WeakMap,We=new WeakMap,xs);const Ns=b.createContext(!1),Us=()=>b.useContext(Ns);Ns.Provider;const Ls=(t,e,s)=>{const r=s!=null&&s.state.error&&typeof t.throwOnError=="function"?Ht(t.throwOnError,[s.state.error,s]):t.throwOnError;(t.suspense||r)&&(e.isReset()||(t.retryOnMount=!1))},_s=t=>{b.useEffect(()=>{t.clearReset()},[t])},Ks=({result:t,errorResetBoundary:e,throwOnError:s,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||Ht(s,[t.error,r])),$s=(t,e)=>e.state.data===void 0,Hs=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))}},Nt=(t,e)=>(t==null?void 0:t.suspense)&&e.isPending,Bs=(t,e,s)=>e.fetchOptimistic(t).catch(()=>{s.clearReset()});function pn({queries:t,...e},s){const r=ot(),i=Us(),a=Ps(),u=e.subscribed!==!1,o=b.useMemo(()=>t.map(S=>{const w=r.defaultQueryOptions(S);return w._optimisticResults=i?"isRestoring":u?"optimistic":void 0,w}),[t,r,i,u]);o.forEach(S=>{Hs(S);const w=r.getQueryCache().get(S.queryHash);Ls(S,a,w)}),_s(a);const[h]=b.useState(()=>new hn(r,o,e)),[y,p,g]=h.getOptimisticResult(o,e.combine),f=!i&&u;b.useSyncExternalStore(b.useCallback(S=>f?h.subscribe(I.batchCalls(S)):_,[h,f]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),b.useEffect(()=>{h.setQueries(o,e)},[o,e,h]);const C=y.some((S,w)=>Nt(o[w],S))?y.flatMap((S,w)=>{const E=o[w];if(E&&Nt(E,S)){const P=new mt(r,E);return Bs(E,P,a)}return[]}):[];if(C.length>0)throw Promise.all(C);const Q=y.find((S,w)=>{const E=o[w];return E&&Ks({result:S,errorResetBoundary:a,throwOnError:E.throwOnError,query:r.getQueryCache().get(E.queryHash),suspense:E.suspense})});if(Q)throw Q.error;return p(g())}function Gs(t,e,s){const r=Us(),i=Ps(),a=ot(),u=a.defaultQueryOptions(t),o=a.getQueryCache().get(u.queryHash),h=t.subscribed!==!1;u._optimisticResults=r?"isRestoring":h?"optimistic":void 0,Hs(u),Ls(u,i,o),_s(i);const[y]=b.useState(()=>new e(a,u)),p=y.getOptimisticResult(u),g=!r&&h;if(b.useSyncExternalStore(b.useCallback(f=>{const C=g?y.subscribe(I.batchCalls(f)):_;return y.updateResult(),C},[y,g]),()=>y.getCurrentResult(),()=>y.getCurrentResult()),b.useEffect(()=>{y.setOptions(u)},[u,y]),Nt(u,p))throw Bs(u,y,i);if(Ks({result:p,errorResetBoundary:i,throwOnError:u.throwOnError,query:o,suspense:u.suspense}))throw p.error;return u.notifyOnChangeProps?p:y.trackResult(p)}function ue(t,e){return Gs(t,mt)}function gt(t,e){return Gs({...t,enabled:!0,suspense:!0,throwOnError:$s,placeholderData:void 0},mt)}function yn(t,e){return pn({...t,queries:t.queries.map(s=>({...s,suspense:!0,throwOnError:$s,enabled:!0,placeholderData:void 0}))})}function Ws(t,e){const s=ot(),[r]=b.useState(()=>new ln(s,t));b.useEffect(()=>{r.setOptions(t)},[r,t]);const i=b.useSyncExternalStore(b.useCallback(u=>r.subscribe(I.batchCalls(u)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=b.useCallback((...u)=>{r.mutate(u[0],u[1]).catch(_)},[r]);if(i.error&&Ht(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}const mn=864e5,gn=/^\d{4}-\d{2}-\d{2}$/;function us(t,e=Date.now()){return new Date(e-t*mn).toISOString().slice(0,10)}function vn(t=30,e=Date.now()){return{fromDay:us(t-1,e),toDay:us(0,e)}}function bn(t){return gn.test(t)}function Sn(){return c.jsxs("div",{className:"relative grid min-h-full place-items-center px-5 py-16",children:[c.jsx("div",{className:"app-bg"}),c.jsxs("div",{role:"alert",className:"relative z-10 flex max-w-md flex-col items-center gap-3 rounded-xl border border-line bg-panel px-8 py-10 text-center",children:[c.jsx("div",{className:"grid h-10 w-10 place-items-center rounded-lg border border-brand/40 bg-brand/10",children:c.jsx(Rs,{className:"h-5 w-5 text-brand"})}),c.jsx("h1",{className:"text-base font-semibold tracking-tight",children:"Access denied"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"You are signed in, but not allowed to use this console. Ask an administrator for access."})]})]})}function ht(){return typeof window<"u"&&window.__AGENT_API__?window.__AGENT_API__:`${typeof window<"u"&&window.__AGENT_BASE__||"/ai-gateway"}/api`}const ft=new Set;function wn(t){return ft.add(t),()=>{ft.delete(t)}}async function Ut(t){if((t.status===401||t.status===403)&&ft.size>0){const e=await t.json().catch(()=>{}),s=t.status===401&&typeof(e==null?void 0:e.redirectTo)=="string"&&e.redirectTo!==""?{kind:"redirect",redirectTo:e.redirectTo}:t.status===403&&(e==null?void 0:e.error)==="forbidden"?{kind:"forbidden"}:void 0;if(s!==void 0)for(const r of ft)r(s)}throw new Error(`${t.status} ${t.statusText}`)}async function N(t,e){const s=await fetch(ht()+t,e);return s.ok?await s.json():Ut(s)}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 k={spend(t){const e=new URLSearchParams({from:t.fromDay,to:t.toDay});return N(`/spend?${e.toString()}`)},topThreads(t,e=10){const s=new URLSearchParams({from:t.fromDay,to:t.toDay,limit:`${e}`});return N(`/top-threads?${s.toString()}`)},reliability(t){const e=new URLSearchParams({from:t.fromDay,to:t.toDay});return N(`/reliability?${e.toString()}`)},runs(t=50){return N(`/runs?limit=${t}`)},toolCalls(t=50){return N(`/tool-calls?limit=${t}`)},toolCallsPage(t){return N(`/tool-calls-page?${lt(t)}`)},approvals(t=50){return N(`/approvals?limit=${t}`)},approvalsPage(t){return N(`/approvals-page?${lt(t)}`)},runDetail(t){return N(`/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 N(`/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)});s.ok||await Ut(s)},toolStats(t){const e=new URLSearchParams({from:t.fromDay,to:t.toDay});return N(`/tools?${e.toString()}`)},genuiStats(t){const e=new URLSearchParams({from:t.fromDay,to:t.toDay});return N(`/genui?${e.toString()}`)},threads(t=50){return N(`/threads?limit=${t}`)},threadsPage(t){return N(`/threads-page?${lt(t)}`)},runsPage(t){return N(`/runs-page?${lt(t)}`)},pricing(){return N("/pricing")},async upsertPrice(t){const e=await fetch(`${ht()}/pricing`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});e.ok||await Ut(e)},streamEvents(t){const e=new EventSource(`${ht()}/stream`);return e.onmessage=s=>{try{t(JSON.parse(s.data))}catch{}},()=>e.close()}},W={aggregate:6e4,activity:15e3,queue:0,config:5*6e4,detail:3e4};function zs(t){return{queryKey:["spend",t.fromDay,t.toDay],queryFn:()=>k.spend(t),staleTime:W.aggregate}}function Vs(t){return gt(zs(t))}function Cn(t,e=10){const[s,r]=yn({queries:[zs(t),{queryKey:["top-threads",t.fromDay,t.toDay,e],queryFn:()=>k.topThreads(t,e),staleTime:W.aggregate}]});return{overview:s.data,topThreads:r.data}}function xn(t){return gt({queryKey:["reliability",t.fromDay,t.toDay],queryFn:()=>k.reliability(t),staleTime:W.aggregate})}function Pn(t){return gt({queryKey:["tool-stats",t.fromDay,t.toDay],queryFn:()=>k.toolStats(t),staleTime:W.aggregate})}function Rn(t=50){return gt({queryKey:["tool-calls",t],queryFn:()=>k.toolCalls(t),staleTime:W.activity})}function On(t,e,s){return ue({queryKey:["runs-page",t,e,s],queryFn:()=>k.runsPage({page:t,pageSize:e,where:s}),placeholderData:yt,staleTime:W.activity})}function Tn(t,e,s){return ue({queryKey:["tool-calls-page",t,e,s],queryFn:()=>k.toolCallsPage({page:t,pageSize:e,where:s}),placeholderData:yt,staleTime:W.activity})}function En(t,e,s){return ue({queryKey:["threads-page",t,e,s],queryFn:()=>k.threadsPage({page:t,pageSize:e,where:s}),placeholderData:yt,staleTime:W.activity})}function jn(t,e,s){return ue({queryKey:["approvals-page",t,e,s],queryFn:()=>k.approvalsPage({page:t,pageSize:e,where:s}),placeholderData:yt,staleTime:W.queue})}function Dn(){return ue({queryKey:["approvals-count"],queryFn:async()=>(await k.approvalsPage({page:1,pageSize:1})).total,staleTime:W.queue,refetchInterval:2e4,refetchIntervalInBackground:!0})}function Fn(t){return ue({queryKey:["run-detail",t],queryFn:()=>k.runDetail(t),staleTime:W.detail})}function In(t){return ue({queryKey:["thread-detail",t],queryFn:()=>k.threadDetail(t),staleTime:W.detail})}function Qn(t){return ue({queryKey:["genui",t.fromDay,t.toDay],queryFn:()=>k.genuiStats(t),staleTime:W.aggregate})}function An(){return ue({queryKey:["pricing"],queryFn:()=>k.pricing(),staleTime:W.config})}const Mn=[["approvals"],["approvals-page"],["approvals-count"],["tool-calls"],["tool-calls-page"],["tool-stats"],["run-detail"]];function qn(){const t=ot();return Ws({mutationFn:({toolCallId:e,input:s})=>k.decideApproval(e,s),onSuccess:()=>{for(const e of Mn)t.invalidateQueries({queryKey:e})}})}const kn=[["pricing"],["spend"],["top-threads"],["thread-detail"]];function Nn(){const t=ot();return Ws({mutationFn:e=>k.upsertPrice(e),onSuccess:()=>{for(const e of kn)t.invalidateQueries({queryKey:e})}})}function Un({range:t}){return c.jsx(tr,{rows:Vs(t).data.byActor})}const Ln=["spend","models","actors","runs","reliability","approvals","tools","genui","pricing","live"],Js="spend";function _n(t){return Ln.some(e=>e===t)}function cs(t){const e=t.replace(/^#\/?/,""),s=e.indexOf("?"),r=s===-1?e:e.slice(0,s);return _n(r)?{section:r,params:new URLSearchParams(s===-1?"":e.slice(s+1))}:{section:Js,params:new URLSearchParams}}function zt(t,e){const s=e===void 0?"":new URLSearchParams(e).toString();return s===""?`#/${t}`:`#/${t}?${s}`}const Ys=b.createContext({open:()=>{}});function vt(){return b.useContext(Ys)}function Kn({children:t}){const[e,s]=b.useState([]),r=b.useCallback(o=>{s(h=>[...h,o])},[]),i=b.useCallback(()=>s([]),[]),a=b.useCallback(()=>s(o=>o.slice(0,-1)),[]);b.useEffect(()=>(window.addEventListener("hashchange",i),()=>window.removeEventListener("hashchange",i)),[i]);const u=e[e.length-1];return c.jsxs(Ys.Provider,{value:{open:r},children:[t,u!==void 0&&c.jsx(sr,{title:u.kind==="run"?"Run":"Thread",subtitle:u.kind==="run"?u.runId:u.threadId,onClose:i,...e.length>1?{onBack:a}:{},children:u.kind==="run"?c.jsx(Gn,{runId:u.runId,onOpenThread:Hn(r)}):c.jsx(Wn,{threadId:u.threadId,onOpenRun:Bn(r)})},$n(u))]})}function $n(t){return t.kind==="run"?`run:${t.runId}`:`thread:${t.threadId}`}function Hn(t){return e=>t({kind:"thread",threadId:e})}function Bn(t){return e=>t({kind:"run",runId:e})}function Gn({runId:t,onOpenThread:e}){const s=Fn(t);return s.isPending?c.jsx(Xs,{label:"run"}):s.isError?c.jsx(Zs,{label:"This run",error:s.error,onRetry:()=>void s.refetch(),goneLabel:"This run no longer exists in the read-model."}):c.jsx(rr,{detail:s.data,onOpenThread:e})}function Wn({threadId:t,onOpenRun:e}){const s=In(t);return s.isPending?c.jsx(Xs,{label:"thread"}):s.isError?c.jsx(Zs,{label:"This thread",error:s.error,onRetry:()=>void s.refetch(),goneLabel:"This thread no longer exists in the read-model."}):c.jsx(nr,{detail:s.data,onOpenRun:e,runsHref:zt("reliability",{threadId:t})})}function Zs({label:t,error:e,onRetry:s,goneLabel:r}){return e instanceof Error&&e.message.startsWith("404")?c.jsx(ar,{label:r}):c.jsx(or,{label:t,error:e,onRetry:s})}function Xs({label:t}){return c.jsxs(ir,{className:"animate-pulse p-6 text-sm text-muted-foreground","aria-busy":"true",children:["Loading ",t,"…"]})}const ve=25;function pt(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 zn(){const{open:t}=vt(),[e,s]=b.useState(1),r=jn(e,ve,{}),i=qn();return c.jsx(ur,{table:pt(r,e,ve),onPageChange:s,onDecide:(a,u)=>i.mutateAsync({toolCallId:a,input:u}),onOpenRun:a=>t({kind:"run",runId:a})})}const Vn="501";function Jn({range:t}){const e=Qn(t),s=e.isError&&e.error.message.startsWith(Vn);return e.isError&&!s?c.jsx(Os,{label:"Generative UI",error:e.error,onRetry:()=>void e.refetch()}):e.isPending?c.jsx(cr,{label:"Generative UI"}):c.jsx(lr,{stats:e.data??null,unavailable:s})}function Yn({range:t}){return c.jsx(hr,{rows:Vs(t).data.byModel})}const Zn="501";function Xn(){const t=An(),e=Nn(),s=t.isError&&t.error.message.startsWith(Zn);return t.isError&&!s?c.jsx(Os,{label:"Pricing",error:t.error,onRetry:()=>void t.refetch()}):c.jsx(dr,{prices:t.data??[],loading:t.isPending,unavailable:s,onUpsert:r=>e.mutateAsync(r),saving:e.isPending})}function ei({range:t,threadId:e}){const{open:s}=vt(),r=xn(t),[i,a]=b.useState(1),[u,o]=b.useState(""),[h,y]=b.useState(""),p={...u!==""?{status:u}:{},...h!==""?{agentName:h}:{},...e!==void 0&&e!==""?{threadId:e}:{}},g=On(i,ve,p);return c.jsx(fr,{overview:r.data,runsTable:pt(g,i,ve),runsWhere:p,onRunsStatusChange:f=>{o(f),a(1)},onRunsAgentNameChange:f=>{y(f),a(1)},onRunsThreadIdClear:()=>{a(1),window.location.hash=zt("reliability")},onRunsPageChange:a,onOpenRun:f=>s({kind:"run",runId:f})})}function ti(){const{open:t}=vt(),e=Rn(),[s,r]=b.useState(1),[i,a]=b.useState(""),[u,o]=b.useState(""),h={...i!==""?{toolName:i}:{},...u!==""?{status:u}:{}},y=Tn(s,ve,h),[p,g]=b.useState(1),[f,C]=b.useState(""),Q={...f!==""?{title:f}:{}},S=En(p,ve,Q);return c.jsx(pr,{toolCalls:e.data,toolCallsTable:pt(y,s,ve),toolCallsWhere:h,onToolCallsToolNameChange:w=>{a(w),r(1)},onToolCallsStatusChange:w=>{o(w),r(1)},onToolCallsPageChange:r,threadsTable:pt(S,p,ve),threadsWhere:Q,onThreadsTitleChange:w=>{C(w),g(1)},onThreadsPageChange:g,onOpenRun:w=>t({kind:"run",runId:w}),onOpenThread:w=>t({kind:"thread",threadId:w})})}function si({range:t}){const{open:e}=vt(),{overview:s,topThreads:r}=Cn(t);return c.jsx(yr,{overview:s,topThreads:r,onOpenThread:i=>e({kind:"thread",threadId:i})})}function ri({range:t}){return c.jsx(mr,{rows:Pn(t).data})}const ni=Mr,ii=qr;function ai({className:t,align:e="end",sideOffset:s=6,...r}){return c.jsx(kr,{children:c.jsx(Nr,{align:e,sideOffset:s,className:"z-50 outline-none",children:c.jsx(Ur,{className:gr("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 oi(t){window.location.assign(t)}function ui(t=oi){const[e,s]=b.useState(!1);return b.useEffect(()=>wn(r=>{r.kind==="redirect"?t(r.redirectTo):s(!0)}),[t]),{denied:e}}function ci(t=200){const[e,s]=b.useState([]),[r,i]=b.useState(!1),a=b.useRef(0);return b.useEffect(()=>{i(!0);const u=k.streamEvents(o=>{a.current+=1,s(h=>vr(h,o,a.current,t))});return()=>{i(!1),u()}},[t]),{events:e,connected:r}}const er=[{key:"spend",label:"Spend & usage",icon:c.jsx(br,{})},{key:"models",label:"Models",icon:c.jsx(Sr,{})},{key:"actors",label:"Actors & budgets",icon:c.jsx(wr,{})},{key:"runs",label:"Runs & tools",icon:c.jsx(Yt,{})},{key:"reliability",label:"Reliability",icon:c.jsx(Cr,{})},{key:"approvals",label:"Approvals",icon:c.jsx(xr,{})},{key:"tools",label:"Tools",icon:c.jsx(Yt,{})},{key:"genui",label:"Generative UI",icon:c.jsx(Pr,{})},{key:"pricing",label:"Pricing",icon:c.jsx(Rr,{})},{key:"live",label:"Live",icon:c.jsx(Or,{})}],li=Object.fromEntries(er.map(t=>[t.key,t.label]));function hi(){const[t,e]=b.useState(()=>typeof window>"u"?{section:Js,params:new URLSearchParams}:cs(window.location.hash));return b.useEffect(()=>{function s(){e(cs(window.location.hash))}return window.addEventListener("hashchange",s),()=>window.removeEventListener("hashchange",s)},[]),t}function di(){const[t,e]=b.useState(vn()),{section:s,params:r}=hi(),i=ci(),a=Dn();return ui().denied?c.jsx(Sn,{}):c.jsx(Tr,{delay:400,closeDelay:0,timeout:300,children:c.jsx(Kn,{children:c.jsxs("div",{className:"relative min-h-full",children:[c.jsx("div",{className:"app-bg"}),c.jsxs("div",{className:"relative z-10 mx-auto max-w-[1180px] px-5 py-5",children:[c.jsx(pi,{range:t,onRange:e,connected:i.connected,liveCount:i.events.length}),c.jsx("nav",{className:"mb-5 flex flex-wrap gap-1",children:er.map(o=>{const h=o.key==="live"?i.events.length:o.key==="approvals"?a.data??0:0,y=s===o.key;return c.jsxs(Ts,{render:c.jsx("a",{href:zt(o.key),...y?{"aria-current":"page"}:{}}),size:"md",variant:y?"default":"ghost",className:"gap-2 rounded-lg",children:[o.icon,o.label,h>0&&c.jsx(Er,{variant:"accent",className:"tnum border-transparent bg-brand/20",children:h})]},o.key)})}),c.jsx(jr,{label:li[s],children:c.jsx(fi,{section:s,range:t,params:r,liveEvents:i.events,connected:i.connected})},s)]})]})})})}function fi({section:t,range:e,params:s,liveEvents:r,connected:i}){switch(t){case"spend":return c.jsx(si,{range:e});case"models":return c.jsx(Yn,{range:e});case"actors":return c.jsx(Un,{range:e});case"runs":return c.jsx(ti,{});case"reliability":return c.jsx(ei,{range:e,threadId:s.get("threadId")??void 0});case"approvals":return c.jsx(zn,{});case"tools":return c.jsx(ri,{range:e});case"genui":return c.jsx(Jn,{range:e});case"pricing":return c.jsx(Xn,{});case"live":return c.jsx(Fr,{events:r,connected:i});default:return null}}function pi({range:t,onRange:e,connected:s,liveCount:r}){return c.jsxs("header",{className:"mb-5 flex flex-wrap items-center gap-4",children:[c.jsxs("div",{className:"flex items-center gap-2.5",children:[c.jsx("div",{className:"grid h-8 w-8 place-items-center rounded-lg border border-brand/40 bg-brand/10",children:c.jsx(Rs,{className:"h-4 w-4 text-brand"})}),c.jsxs("div",{className:"leading-none",children:[c.jsx("div",{className:"text-sm font-semibold tracking-tight",children:"AI gateway"}),c.jsx("div",{className:"mono text-[10px] uppercase tracking-[0.2em] text-muted-foreground",children:"governance console"})]})]}),c.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[c.jsx(yi,{range:t,onRange:e}),c.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:[c.jsx(Dr,{tone:s?"live":"bad"}),"live ",r>0?`· ${r}`:""]})]})]})}function yi({range:t,onRange:e}){return c.jsxs(ni,{children:[c.jsxs(ii,{render:c.jsx(Ts,{size:"md",variant:"outline",className:"mono gap-2 rounded-lg"}),children:[c.jsx(Ir,{width:12,height:12}),c.jsxs("span",{className:"tnum text-foreground",children:[t.fromDay," → ",t.toDay]})]}),c.jsxs(ai,{className:"flex flex-col gap-2",children:[c.jsx(ls,{label:"From",value:t.fromDay,onChange:s=>e({...t,fromDay:s})}),c.jsx(ls,{label:"To",value:t.toDay,onChange:s=>e({...t,toDay:s})}),c.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Whole UTC days, inclusive."})]})]})}function ls({label:t,value:e,onChange:s}){return c.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:[c.jsx("span",{className:"uppercase tracking-wider",children:t}),c.jsx(Qr,{type:"date",value:e,onChange:r=>{const i=r.target.value;bn(i)&&s(i)}})]})}const mi=new fn({defaultOptions:{queries:{retry:1}}}),hs=document.getElementById("root");hs&&Ar.createRoot(hs).render(c.jsx(b.StrictMode,{children:c.jsx(Lr,{client:mi,children:c.jsx(di,{})})}));
|