@cognisphere-sh/cognisphere-harness 0.12.0 → 0.13.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/CHANGELOG.md +66 -11
- package/LICENSE +21 -0
- package/dist-web/assets/{file-editor-CQSmlsy_.js → file-editor-CqGYKmT3.js} +1 -1
- package/dist-web/assets/{index-1Hg12QW0.js → index-CDE-jsH8.js} +3 -3
- package/dist-web/index.html +1 -1
- package/home-template/config.example +0 -6
- package/home-template/docs/base-harness/README.md +11 -4
- package/home-template/scripts/build.sh +0 -5
- package/home-template/scripts/lib/remote-bootstrap.sh +2 -6
- package/home-template/scripts/setup-server.sh +7 -39
- package/package.json +7 -5
- package/skills/cognisphere-upgrade/SKILL.md +1 -1
- package/skills/create-plugin/SKILL.md +2 -2
- package/src/agents/base-agent/bootstrap/bootstrap.sh +2 -18
- package/src/agents/base-agent/extensions/context-meta.ts +4 -1
- package/src/agents/base-agent/system_prompts/0-base_prompt.md +3 -0
- package/src/api/agents.ts +3 -13
- package/src/api/credentials.ts +0 -15
- package/src/api/models.ts +2 -8
- package/src/api/secrets.ts +3 -3
- package/src/cli/index.ts +1 -1
- package/src/cli/init.ts +0 -12
- package/src/core/agent-manager.ts +12 -47
- package/src/core/config.ts +6 -0
- package/src/core/main.ts +10 -2
- package/src/core/model-access.ts +55 -0
- package/src/core/models-catalog.ts +72 -40
- package/src/core/models-store.ts +3 -4
- package/src/core/oauth-logins.ts +7 -3
- package/src/core/pi-delivery-receipts.ts +69 -0
- package/src/core/pi-models-sync.ts +2 -2
- package/src/core/queue.ts +7 -25
- package/src/core/rpc.ts +55 -49
- package/src/core/runner.ts +137 -131
- package/src/core/secrets.ts +2 -3
- package/src/core/types.ts +1 -1
- package/src/plugins/artifacts/index.ts +1 -1
- package/src/agents/base-agent/extensions/harness-bridge.ts +0 -63
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/file-editor-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/file-editor-CqGYKmT3.js","assets/radix-DHW5y7jr.js","assets/react-BIlrhC09.js","assets/markdown-sumxz7Eq.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
var sd=s=>{throw TypeError(s)};var Ja=(s,e,t)=>e.has(s)||sd("Cannot "+t);var v=(s,e,t)=>(Ja(s,e,"read from private field"),t?t.call(s):e.get(s)),Y=(s,e,t)=>e.has(s)?sd("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),z=(s,e,t,i)=>(Ja(s,e,"write to private field"),i?i.call(s,t):e.set(s,t),t),re=(s,e,t)=>(Ja(s,e,"access private method"),t);var ro=(s,e,t,i)=>({set _(n){z(s,e,n,t)},get _(){return v(s,e,i)}});import{j as h,C as Kf,P as Dx,R as Rx,T as Ix,S as Lx,a as _f,b as Uf,D as Qf,c as Bx,d as Gf,e as zx,f as Yf,g as Jf,h as Fx,i as $x,k as Xf,I as Zf,l as ep,m as Wx,n as Hx}from"./radix-DHW5y7jr.js";import{a as qx,r as C,b as R,v as Vx,u as tp,d as Oa,L as Rt,N as id,O as sp,e as Pa,f as on,h as Kx,i as ip,j as tt,B as _x}from"./react-BIlrhC09.js";import{M as Ux,r as Qx}from"./markdown-sumxz7Eq.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))i(n);new MutationObserver(n=>{for(const r of n)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function t(n){const r={};return n.integrity&&(r.integrity=n.integrity),n.referrerPolicy&&(r.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?r.credentials="include":n.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(n){if(n.ep)return;n.ep=!0;const r=t(n);fetch(n.href,r)}})();var Ll={},nd=qx;Ll.createRoot=nd.createRoot,Ll.hydrateRoot=nd.hydrateRoot;var Fn=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(s){return this.listeners.add(s),this.onSubscribe(),()=>{this.listeners.delete(s),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Ai,Gs,xn,Rf,Gx=(Rf=class extends Fn{constructor(){super();Y(this,Ai);Y(this,Gs);Y(this,xn);z(this,xn,e=>{if(typeof window<"u"&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}})}onSubscribe(){v(this,Gs)||this.setEventListener(v(this,xn))}onUnsubscribe(){var e;this.hasListeners()||((e=v(this,Gs))==null||e.call(this),z(this,Gs,void 0))}setEventListener(e){var t;z(this,xn,e),(t=v(this,Gs))==null||t.call(this),z(this,Gs,e(i=>{typeof i=="boolean"?this.setFocused(i):this.onFocus()}))}setFocused(e){v(this,Ai)!==e&&(z(this,Ai,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){var e;return typeof v(this,Ai)=="boolean"?v(this,Ai):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},Ai=new WeakMap,Gs=new WeakMap,xn=new WeakMap,Rf),eh=new Gx,Yx={setTimeout:(s,e)=>setTimeout(s,e),clearTimeout:s=>clearTimeout(s),setInterval:(s,e)=>setInterval(s,e),clearInterval:s=>clearInterval(s)},Ys,Zc,If,Jx=(If=class{constructor(){Y(this,Ys,Yx);Y(this,Zc,!1)}setTimeoutProvider(s){z(this,Ys,s)}setTimeout(s,e){return v(this,Ys).setTimeout(s,e)}clearTimeout(s){v(this,Ys).clearTimeout(s)}setInterval(s,e){return v(this,Ys).setInterval(s,e)}clearInterval(s){v(this,Ys).clearInterval(s)}},Ys=new WeakMap,Zc=new WeakMap,If),Ci=new Jx;function Xx(s){setTimeout(s,0)}var Zx=typeof window>"u"||"Deno"in globalThis;function ht(){}function ey(s,e){return typeof s=="function"?s(e):s}function Bl(s){return typeof s=="number"&&s>=0&&s!==1/0}function np(s,e){return Math.max(s+(e||0)-Date.now(),0)}function ri(s,e){return typeof s=="function"?s(e):s}function Et(s,e){return typeof s=="function"?s(e):s}function rd(s,e){const{type:t="all",exact:i,fetchStatus:n,predicate:r,queryKey:o,stale:a}=s;if(o){if(i){if(e.queryHash!==th(o,e.options))return!1}else if(!mr(e.queryKey,o))return!1}if(t!=="all"){const l=e.isActive();if(t==="active"&&!l||t==="inactive"&&l)return!1}return!(typeof a=="boolean"&&e.isStale()!==a||n&&n!==e.state.fetchStatus||r&&!r(e))}function od(s,e){const{exact:t,status:i,predicate:n,mutationKey:r}=s;if(r){if(!e.options.mutationKey)return!1;if(t){if(Fi(e.options.mutationKey)!==Fi(r))return!1}else if(!mr(e.options.mutationKey,r))return!1}return!(i&&e.state.status!==i||n&&!n(e))}function th(s,e){return((e==null?void 0:e.queryKeyHashFn)||Fi)(s)}function Fi(s){return JSON.stringify(s,(e,t)=>zl(t)?Object.keys(t).sort().reduce((i,n)=>(i[n]=t[n],i),{}):t)}function mr(s,e){return s===e?!0:typeof s!=typeof e?!1:s&&e&&typeof s=="object"&&typeof e=="object"?Object.keys(e).every(t=>mr(s[t],e[t])):!1}var ty=Object.prototype.hasOwnProperty;function rp(s,e,t=0){if(s===e)return s;if(t>500)return e;const i=ad(s)&&ad(e);if(!i&&!(zl(s)&&zl(e)))return e;const r=(i?s:Object.keys(s)).length,o=i?e:Object.keys(e),a=o.length,l=i?new Array(a):{};let c=0;for(let d=0;d<a;d++){const u=i?d:o[d],f=s[u],p=e[u];if(f===p){l[u]=f,(i?d<r:ty.call(s,u))&&c++;continue}if(f===null||p===null||typeof f!="object"||typeof p!="object"){l[u]=p;continue}const m=rp(f,p,t+1);l[u]=m,m===f&&c++}return r===a&&c===r?s:l}function _o(s,e){if(!e||Object.keys(s).length!==Object.keys(e).length)return!1;for(const t in s)if(s[t]!==e[t])return!1;return!0}function ad(s){return Array.isArray(s)&&s.length===Object.keys(s).length}function zl(s){if(!ld(s))return!1;const e=s.constructor;if(e===void 0)return!0;const t=e.prototype;return!(!ld(t)||!t.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(s)!==Object.prototype)}function ld(s){return Object.prototype.toString.call(s)==="[object Object]"}function sy(s){return new Promise(e=>{Ci.setTimeout(e,s)})}function Fl(s,e,t){return typeof t.structuralSharing=="function"?t.structuralSharing(s,e):t.structuralSharing!==!1?rp(s,e):e}function iy(s){return s}function ny(s,e,t=0){const i=[...s,e];return t&&i.length>t?i.slice(1):i}function ry(s,e,t=0){const i=[e,...s];return t&&i.length>t?i.slice(0,-1):i}var sh=Symbol();function op(s,e){return!s.queryFn&&(e!=null&&e.initialPromise)?()=>e.initialPromise:!s.queryFn||s.queryFn===sh?()=>Promise.reject(new Error(`Missing queryFn: '${s.queryHash}'`)):s.queryFn}function ih(s,e){return typeof s=="function"?s(...e):!!s}function oy(s,e,t){let i=!1,n;return Object.defineProperty(s,"signal",{enumerable:!0,get:()=>(n??(n=e()),i||(i=!0,n.aborted?t():n.addEventListener("abort",t,{once:!0})),n)}),s}var gr=(()=>{let s=()=>Zx;return{isServer(){return s()},setIsServer(e){s=e}}})();function $l(){let s,e;const t=new Promise((n,r)=>{s=n,e=r});t.status="pending",t.catch(()=>{});function i(n){Object.assign(t,n),delete t.resolve,delete t.reject}return t.resolve=n=>{i({status:"fulfilled",value:n}),s(n)},t.reject=n=>{i({status:"rejected",reason:n}),e(n)},t}var ay=Xx;function ly(){let s=[],e=0,t=a=>{a()},i=a=>{a()},n=ay;const r=a=>{e?s.push(a):n(()=>{t(a)})},o=()=>{const a=s;s=[],a.length&&n(()=>{i(()=>{a.forEach(l=>{t(l)})})})};return{batch:a=>{let l;e++;try{l=a()}finally{e--,e||o()}return l},batchCalls:a=>(...l)=>{r(()=>{a(...l)})},schedule:r,setNotifyFunction:a=>{t=a},setBatchNotifyFunction:a=>{i=a},setScheduler:a=>{n=a}}}var qe=ly(),yn,Js,bn,Lf,cy=(Lf=class extends Fn{constructor(){super();Y(this,yn,!0);Y(this,Js);Y(this,bn);z(this,bn,e=>{if(typeof window<"u"&&window.addEventListener){const t=()=>e(!0),i=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",i,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",i)}}})}onSubscribe(){v(this,Js)||this.setEventListener(v(this,bn))}onUnsubscribe(){var e;this.hasListeners()||((e=v(this,Js))==null||e.call(this),z(this,Js,void 0))}setEventListener(e){var t;z(this,bn,e),(t=v(this,Js))==null||t.call(this),z(this,Js,e(this.setOnline.bind(this)))}setOnline(e){v(this,yn)!==e&&(z(this,yn,e),this.listeners.forEach(i=>{i(e)}))}isOnline(){return v(this,yn)}},yn=new WeakMap,Js=new WeakMap,bn=new WeakMap,Lf),Uo=new cy;function hy(s){return Math.min(1e3*2**s,3e4)}function ap(s){return(s??"online")==="online"?Uo.isOnline():!0}var Wl=class extends Error{constructor(s){super("CancelledError"),this.revert=s==null?void 0:s.revert,this.silent=s==null?void 0:s.silent}};function lp(s){let e=!1,t=0,i;const n=$l(),r=()=>n.status!=="pending",o=g=>{var x;if(!r()){const b=new Wl(g);f(b),(x=s.onCancel)==null||x.call(s,b)}},a=()=>{e=!0},l=()=>{e=!1},c=()=>eh.isFocused()&&(s.networkMode==="always"||Uo.isOnline())&&s.canRun(),d=()=>ap(s.networkMode)&&s.canRun(),u=g=>{r()||(i==null||i(),n.resolve(g))},f=g=>{r()||(i==null||i(),n.reject(g))},p=()=>new Promise(g=>{var x;i=b=>{(r()||c())&&g(b)},(x=s.onPause)==null||x.call(s)}).then(()=>{var g;i=void 0,r()||(g=s.onContinue)==null||g.call(s)}),m=()=>{if(r())return;let g;const x=t===0?s.initialPromise:void 0;try{g=x??s.fn()}catch(b){g=Promise.reject(b)}Promise.resolve(g).then(u).catch(b=>{var k;if(r())return;const S=s.retry??(gr.isServer()?0:3),N=s.retryDelay??hy,y=typeof N=="function"?N(t,b):N,w=S===!0||typeof S=="number"&&t<S||typeof S=="function"&&S(t,b);if(e||!w){f(b);return}t++,(k=s.onFail)==null||k.call(s,t,b),sy(y).then(()=>c()?void 0:p()).then(()=>{e?f(b):m()})})};return{promise:n,status:()=>n.status,cancel:o,continue:()=>(i==null||i(),n),cancelRetry:a,continueRetry:l,canStart:d,start:()=>(d()?m():p().then(m),n)}}var Ti,Bf,cp=(Bf=class{constructor(){Y(this,Ti)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Bl(this.gcTime)&&z(this,Ti,Ci.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(s){this.gcTime=Math.max(this.gcTime||0,s??(gr.isServer()?1/0:5*60*1e3))}clearGcTimeout(){v(this,Ti)!==void 0&&(Ci.clearTimeout(v(this,Ti)),z(this,Ti,void 0))}},Ti=new WeakMap,Bf);function dy(s){return{onFetch:(e,t)=>{var d,u,f,p,m;const i=e.options,n=(f=(u=(d=e.fetchOptions)==null?void 0:d.meta)==null?void 0:u.fetchMore)==null?void 0:f.direction,r=((p=e.state.data)==null?void 0:p.pages)||[],o=((m=e.state.data)==null?void 0:m.pageParams)||[];let a={pages:[],pageParams:[]},l=0;const c=async()=>{let g=!1;const x=N=>{oy(N,()=>e.signal,()=>g=!0)},b=op(e.options,e.fetchOptions),S=async(N,y,w)=>{if(g)return Promise.reject(e.signal.reason);if(y==null&&N.pages.length)return Promise.resolve(N);const M=(()=>{const F={client:e.client,queryKey:e.queryKey,pageParam:y,direction:w?"backward":"forward",meta:e.options.meta};return x(F),F})(),P=await b(M),{maxPages:L}=e.options,H=w?ry:ny;return{pages:H(N.pages,P,L),pageParams:H(N.pageParams,y,L)}};if(n&&r.length){const N=n==="backward",y=N?uy:cd,w={pages:r,pageParams:o},k=y(i,w);a=await S(w,k,N)}else{const N=s??r.length;do{const y=l===0?o[0]??i.initialPageParam:cd(i,a);if(l>0&&y==null)break;a=await S(a,y),l++}while(l<N)}return a};e.options.persister?e.fetchFn=()=>{var g,x;return(x=(g=e.options).persister)==null?void 0:x.call(g,c,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},t)}:e.fetchFn=c}}}function cd(s,{pages:e,pageParams:t}){const i=e.length-1;return e.length>0?s.getNextPageParam(e[i],e,t[i],t):void 0}function uy(s,{pages:e,pageParams:t}){var i;return e.length>0?(i=s.getPreviousPageParam)==null?void 0:i.call(s,e[0],e,t[0],t):void 0}var vn,Oi,wn,zt,Pi,Ve,Fr,Ei,Pt,hp,Ns,zf,fy=(zf=class extends cp{constructor(e){super();Y(this,Pt);Y(this,vn);Y(this,Oi);Y(this,wn);Y(this,zt);Y(this,Pi);Y(this,Ve);Y(this,Fr);Y(this,Ei);z(this,Ei,!1),z(this,Fr,e.defaultOptions),this.setOptions(e.options),this.observers=[],z(this,Pi,e.client),z(this,zt,v(this,Pi).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,z(this,Oi,dd(this.options)),this.state=e.state??v(this,Oi),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return v(this,vn)}get promise(){var e;return(e=v(this,Ve))==null?void 0:e.promise}setOptions(e){if(this.options={...v(this,Fr),...e},e!=null&&e._type&&z(this,vn,e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const t=dd(this.options);t.data!==void 0&&(this.setState(hd(t.data,t.dataUpdatedAt)),z(this,Oi,t))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&v(this,zt).remove(this)}setData(e,t){const i=Fl(this.state.data,e,this.options);return re(this,Pt,Ns).call(this,{data:i,type:"success",dataUpdatedAt:t==null?void 0:t.updatedAt,manual:t==null?void 0:t.manual}),i}setState(e){re(this,Pt,Ns).call(this,{type:"setState",state:e})}cancel(e){var i,n;const t=(i=v(this,Ve))==null?void 0:i.promise;return(n=v(this,Ve))==null||n.cancel(e),t?t.then(ht).catch(ht):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return v(this,Oi)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>Et(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===sh||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>ri(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:!np(this.state.dataUpdatedAt,e)}onFocus(){var t;const e=this.observers.find(i=>i.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(t=v(this,Ve))==null||t.continue()}onOnline(){var t;const e=this.observers.find(i=>i.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(t=v(this,Ve))==null||t.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),v(this,zt).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(v(this,Ve)&&(v(this,Ei)||re(this,Pt,hp).call(this)?v(this,Ve).cancel({revert:!0}):v(this,Ve).cancelRetry()),this.scheduleGc()),v(this,zt).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||re(this,Pt,Ns).call(this,{type:"invalidate"})}async fetch(e,t){var c,d,u,f,p,m,g,x,b,S,N;if(this.state.fetchStatus!=="idle"&&((c=v(this,Ve))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(t!=null&&t.cancelRefetch))this.cancel({silent:!0});else if(v(this,Ve))return v(this,Ve).continueRetry(),v(this,Ve).promise}if(e&&this.setOptions(e),!this.options.queryFn){const y=this.observers.find(w=>w.options.queryFn);y&&this.setOptions(y.options)}const i=new AbortController,n=y=>{Object.defineProperty(y,"signal",{enumerable:!0,get:()=>(z(this,Ei,!0),i.signal)})},r=()=>{const y=op(this.options,t),k=(()=>{const M={client:v(this,Pi),queryKey:this.queryKey,meta:this.meta};return n(M),M})();return z(this,Ei,!1),this.options.persister?this.options.persister(y,k,this):y(k)},a=(()=>{const y={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:v(this,Pi),state:this.state,fetchFn:r};return n(y),y})(),l=v(this,vn)==="infinite"?dy(this.options.pages):this.options.behavior;l==null||l.onFetch(a,this),z(this,wn,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=a.fetchOptions)==null?void 0:d.meta))&&re(this,Pt,Ns).call(this,{type:"fetch",meta:(u=a.fetchOptions)==null?void 0:u.meta}),z(this,Ve,lp({initialPromise:t==null?void 0:t.initialPromise,fn:a.fetchFn,onCancel:y=>{y instanceof Wl&&y.revert&&this.setState({...v(this,wn),fetchStatus:"idle"}),i.abort()},onFail:(y,w)=>{re(this,Pt,Ns).call(this,{type:"failed",failureCount:y,error:w})},onPause:()=>{re(this,Pt,Ns).call(this,{type:"pause"})},onContinue:()=>{re(this,Pt,Ns).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0}));try{const y=await v(this,Ve).start();if(y===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(y),(p=(f=v(this,zt).config).onSuccess)==null||p.call(f,y,this),(g=(m=v(this,zt).config).onSettled)==null||g.call(m,y,this.state.error,this),y}catch(y){if(y instanceof Wl){if(y.silent)return v(this,Ve).promise;if(y.revert){if(this.state.data===void 0)throw y;return this.state.data}}throw re(this,Pt,Ns).call(this,{type:"error",error:y}),(b=(x=v(this,zt).config).onError)==null||b.call(x,y,this),(N=(S=v(this,zt).config).onSettled)==null||N.call(S,this.state.data,y,this),y}finally{this.scheduleGc()}}},vn=new WeakMap,Oi=new WeakMap,wn=new WeakMap,zt=new WeakMap,Pi=new WeakMap,Ve=new WeakMap,Fr=new WeakMap,Ei=new WeakMap,Pt=new WeakSet,hp=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},Ns=function(e){const t=i=>{switch(e.type){case"failed":return{...i,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...i,fetchStatus:"paused"};case"continue":return{...i,fetchStatus:"fetching"};case"fetch":return{...i,...dp(i.data,this.options),fetchMeta:e.meta??null};case"success":const n={...i,...hd(e.data,e.dataUpdatedAt),dataUpdateCount:i.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return z(this,wn,e.manual?n:void 0),n;case"error":const r=e.error;return{...i,error:r,errorUpdateCount:i.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:i.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...i,isInvalidated:!0};case"setState":return{...i,...e.state}}};this.state=t(this.state),qe.batch(()=>{this.observers.forEach(i=>{i.onQueryUpdate()}),v(this,zt).notify({query:this,type:"updated",action:e})})},zf);function dp(s,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:ap(e.networkMode)?"fetching":"paused",...s===void 0&&{error:null,status:"pending"}}}function hd(s,e){return{data:s,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function dd(s){const e=typeof s.initialData=="function"?s.initialData():s.initialData,t=e!==void 0,i=t?typeof s.initialDataUpdatedAt=="function"?s.initialDataUpdatedAt():s.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:t?i??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:t?"success":"pending",fetchStatus:"idle"}}var bt,ge,$r,ct,Di,kn,As,Xs,Wr,Sn,Cn,Ri,Ii,Zs,jn,ve,sr,Hl,ql,Vl,Kl,_l,Ul,Ql,up,Ff,py=(Ff=class extends Fn{constructor(e,t){super();Y(this,ve);Y(this,bt);Y(this,ge);Y(this,$r);Y(this,ct);Y(this,Di);Y(this,kn);Y(this,As);Y(this,Xs);Y(this,Wr);Y(this,Sn);Y(this,Cn);Y(this,Ri);Y(this,Ii);Y(this,Zs);Y(this,jn,new Set);this.options=t,z(this,bt,e),z(this,Xs,null),z(this,As,$l()),this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(v(this,ge).addObserver(this),ud(v(this,ge),this.options)?re(this,ve,sr).call(this):this.updateResult(),re(this,ve,Kl).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Gl(v(this,ge),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Gl(v(this,ge),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,re(this,ve,_l).call(this),re(this,ve,Ul).call(this),v(this,ge).removeObserver(this)}setOptions(e){const t=this.options,i=v(this,ge);if(this.options=v(this,bt).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Et(this.options.enabled,v(this,ge))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");re(this,ve,Ql).call(this),v(this,ge).setOptions(this.options),t._defaulted&&!_o(this.options,t)&&v(this,bt).getQueryCache().notify({type:"observerOptionsUpdated",query:v(this,ge),observer:this});const n=this.hasListeners();n&&fd(v(this,ge),i,this.options,t)&&re(this,ve,sr).call(this),this.updateResult(),n&&(v(this,ge)!==i||Et(this.options.enabled,v(this,ge))!==Et(t.enabled,v(this,ge))||ri(this.options.staleTime,v(this,ge))!==ri(t.staleTime,v(this,ge)))&&re(this,ve,Hl).call(this);const r=re(this,ve,ql).call(this);n&&(v(this,ge)!==i||Et(this.options.enabled,v(this,ge))!==Et(t.enabled,v(this,ge))||r!==v(this,Zs))&&re(this,ve,Vl).call(this,r)}getOptimisticResult(e){const t=v(this,bt).getQueryCache().build(v(this,bt),e),i=this.createResult(t,e);return gy(this,i)&&(z(this,ct,i),z(this,kn,this.options),z(this,Di,v(this,ge).state)),i}getCurrentResult(){return v(this,ct)}trackResult(e,t){return new Proxy(e,{get:(i,n)=>(this.trackProp(n),t==null||t(n),n==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&v(this,As).status==="pending"&&v(this,As).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(i,n))})}trackProp(e){v(this,jn).add(e)}getCurrentQuery(){return v(this,ge)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=v(this,bt).defaultQueryOptions(e),i=v(this,bt).getQueryCache().build(v(this,bt),t);return i.fetch().then(()=>this.createResult(i,t))}fetch(e){return re(this,ve,sr).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),v(this,ct)))}createResult(e,t){var L;const i=v(this,ge),n=this.options,r=v(this,ct),o=v(this,Di),a=v(this,kn),c=e!==i?e.state:v(this,$r),{state:d}=e;let u={...d},f=!1,p;if(t._optimisticResults){const H=this.hasListeners(),F=!H&&ud(e,t),O=H&&fd(e,i,t,n);(F||O)&&(u={...u,...dp(d.data,e.options)}),t._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:m,errorUpdatedAt:g,status:x}=u;p=u.data;let b=!1;if(t.placeholderData!==void 0&&p===void 0&&x==="pending"){let H;r!=null&&r.isPlaceholderData&&t.placeholderData===(a==null?void 0:a.placeholderData)?(H=r.data,b=!0):H=typeof t.placeholderData=="function"?t.placeholderData((L=v(this,Cn))==null?void 0:L.state.data,v(this,Cn)):t.placeholderData,H!==void 0&&(x="success",p=Fl(r==null?void 0:r.data,H,t),f=!0)}if(t.select&&p!==void 0&&!b)if(r&&p===(o==null?void 0:o.data)&&t.select===v(this,Wr))p=v(this,Sn);else try{z(this,Wr,t.select),p=t.select(p),p=Fl(r==null?void 0:r.data,p,t),z(this,Sn,p),z(this,Xs,null)}catch(H){z(this,Xs,H)}v(this,Xs)&&(m=v(this,Xs),p=v(this,Sn),g=Date.now(),x="error");const S=u.fetchStatus==="fetching",N=x==="pending",y=x==="error",w=N&&S,k=p!==void 0,P={status:x,fetchStatus:u.fetchStatus,isPending:N,isSuccess:x==="success",isError:y,isInitialLoading:w,isLoading:w,data:p,dataUpdatedAt:u.dataUpdatedAt,error:m,errorUpdatedAt:g,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:u.dataUpdateCount>c.dataUpdateCount||u.errorUpdateCount>c.errorUpdateCount,isFetching:S,isRefetching:S&&!N,isLoadingError:y&&!k,isPaused:u.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:y&&k,isStale:nh(e,t),refetch:this.refetch,promise:v(this,As),isEnabled:Et(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const H=P.data!==void 0,F=P.status==="error"&&!H,O=U=>{F?U.reject(P.error):H&&U.resolve(P.data)},Q=()=>{const U=z(this,As,P.promise=$l());O(U)},K=v(this,As);switch(K.status){case"pending":e.queryHash===i.queryHash&&O(K);break;case"fulfilled":(F||P.data!==K.value)&&Q();break;case"rejected":(!F||P.error!==K.reason)&&Q();break}}return P}updateResult(){const e=v(this,ct),t=this.createResult(v(this,ge),this.options);if(z(this,Di,v(this,ge).state),z(this,kn,this.options),v(this,Di).data!==void 0&&z(this,Cn,v(this,ge)),_o(t,e))return;z(this,ct,t);const i=()=>{if(!e)return!0;const{notifyOnChangeProps:n}=this.options,r=typeof n=="function"?n():n;if(r==="all"||!r&&!v(this,jn).size)return!0;const o=new Set(r??v(this,jn));return this.options.throwOnError&&o.add("error"),Object.keys(v(this,ct)).some(a=>{const l=a;return v(this,ct)[l]!==e[l]&&o.has(l)})};re(this,ve,up).call(this,{listeners:i()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&re(this,ve,Kl).call(this)}},bt=new WeakMap,ge=new WeakMap,$r=new WeakMap,ct=new WeakMap,Di=new WeakMap,kn=new WeakMap,As=new WeakMap,Xs=new WeakMap,Wr=new WeakMap,Sn=new WeakMap,Cn=new WeakMap,Ri=new WeakMap,Ii=new WeakMap,Zs=new WeakMap,jn=new WeakMap,ve=new WeakSet,sr=function(e){re(this,ve,Ql).call(this);let t=v(this,ge).fetch(this.options,e);return e!=null&&e.throwOnError||(t=t.catch(ht)),t},Hl=function(){re(this,ve,_l).call(this);const e=ri(this.options.staleTime,v(this,ge));if(gr.isServer()||v(this,ct).isStale||!Bl(e))return;const i=np(v(this,ct).dataUpdatedAt,e)+1;z(this,Ri,Ci.setTimeout(()=>{v(this,ct).isStale||this.updateResult()},i))},ql=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(v(this,ge)):this.options.refetchInterval)??!1},Vl=function(e){re(this,ve,Ul).call(this),z(this,Zs,e),!(gr.isServer()||Et(this.options.enabled,v(this,ge))===!1||!Bl(v(this,Zs))||v(this,Zs)===0)&&z(this,Ii,Ci.setInterval(()=>{(this.options.refetchIntervalInBackground||eh.isFocused())&&re(this,ve,sr).call(this)},v(this,Zs)))},Kl=function(){re(this,ve,Hl).call(this),re(this,ve,Vl).call(this,re(this,ve,ql).call(this))},_l=function(){v(this,Ri)!==void 0&&(Ci.clearTimeout(v(this,Ri)),z(this,Ri,void 0))},Ul=function(){v(this,Ii)!==void 0&&(Ci.clearInterval(v(this,Ii)),z(this,Ii,void 0))},Ql=function(){const e=v(this,bt).getQueryCache().build(v(this,bt),this.options);if(e===v(this,ge))return;const t=v(this,ge);z(this,ge,e),z(this,$r,e.state),this.hasListeners()&&(t==null||t.removeObserver(this),e.addObserver(this))},up=function(e){qe.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(v(this,ct))}),v(this,bt).getQueryCache().notify({query:v(this,ge),type:"observerResultsUpdated"})})},Ff);function my(s,e){return Et(e.enabled,s)!==!1&&s.state.data===void 0&&!(s.state.status==="error"&&Et(e.retryOnMount,s)===!1)}function ud(s,e){return my(s,e)||s.state.data!==void 0&&Gl(s,e,e.refetchOnMount)}function Gl(s,e,t){if(Et(e.enabled,s)!==!1&&ri(e.staleTime,s)!=="static"){const i=typeof t=="function"?t(s):t;return i==="always"||i!==!1&&nh(s,e)}return!1}function fd(s,e,t,i){return(s!==e||Et(i.enabled,s)===!1)&&(!t.suspense||s.state.status!=="error")&&nh(s,t)}function nh(s,e){return Et(e.enabled,s)!==!1&&s.isStaleByTime(ri(e.staleTime,s))}function gy(s,e){return!_o(s.getCurrentResult(),e)}var Hr,hs,et,Li,ds,Ks,$f,xy=($f=class extends cp{constructor(e){super();Y(this,ds);Y(this,Hr);Y(this,hs);Y(this,et);Y(this,Li);z(this,Hr,e.client),this.mutationId=e.mutationId,z(this,et,e.mutationCache),z(this,hs,[]),this.state=e.state||fp(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){v(this,hs).includes(e)||(v(this,hs).push(e),this.clearGcTimeout(),v(this,et).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){z(this,hs,v(this,hs).filter(t=>t!==e)),this.scheduleGc(),v(this,et).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){v(this,hs).length||(this.state.status==="pending"?this.scheduleGc():v(this,et).remove(this))}continue(){var e;return((e=v(this,Li))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var o,a,l,c,d,u,f,p,m,g,x,b,S,N,y,w,k,M;const t=()=>{re(this,ds,Ks).call(this,{type:"continue"})},i={client:v(this,Hr),meta:this.options.meta,mutationKey:this.options.mutationKey};z(this,Li,lp({fn:()=>this.options.mutationFn?this.options.mutationFn(e,i):Promise.reject(new Error("No mutationFn found")),onFail:(P,L)=>{re(this,ds,Ks).call(this,{type:"failed",failureCount:P,error:L})},onPause:()=>{re(this,ds,Ks).call(this,{type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>v(this,et).canRun(this)}));const n=this.state.status==="pending",r=!v(this,Li).canStart();try{if(n)t();else{re(this,ds,Ks).call(this,{type:"pending",variables:e,isPaused:r}),v(this,et).config.onMutate&&await v(this,et).config.onMutate(e,this,i);const L=await((a=(o=this.options).onMutate)==null?void 0:a.call(o,e,i));L!==this.state.context&&re(this,ds,Ks).call(this,{type:"pending",context:L,variables:e,isPaused:r})}const P=await v(this,Li).start();return await((c=(l=v(this,et).config).onSuccess)==null?void 0:c.call(l,P,e,this.state.context,this,i)),await((u=(d=this.options).onSuccess)==null?void 0:u.call(d,P,e,this.state.context,i)),await((p=(f=v(this,et).config).onSettled)==null?void 0:p.call(f,P,null,this.state.variables,this.state.context,this,i)),await((g=(m=this.options).onSettled)==null?void 0:g.call(m,P,null,e,this.state.context,i)),re(this,ds,Ks).call(this,{type:"success",data:P}),P}catch(P){try{await((b=(x=v(this,et).config).onError)==null?void 0:b.call(x,P,e,this.state.context,this,i))}catch(L){Promise.reject(L)}try{await((N=(S=this.options).onError)==null?void 0:N.call(S,P,e,this.state.context,i))}catch(L){Promise.reject(L)}try{await((w=(y=v(this,et).config).onSettled)==null?void 0:w.call(y,void 0,P,this.state.variables,this.state.context,this,i))}catch(L){Promise.reject(L)}try{await((M=(k=this.options).onSettled)==null?void 0:M.call(k,void 0,P,e,this.state.context,i))}catch(L){Promise.reject(L)}throw re(this,ds,Ks).call(this,{type:"error",error:P}),P}finally{v(this,et).runNext(this)}}},Hr=new WeakMap,hs=new WeakMap,et=new WeakMap,Li=new WeakMap,ds=new WeakSet,Ks=function(e){const t=i=>{switch(e.type){case"failed":return{...i,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...i,isPaused:!0};case"continue":return{...i,isPaused:!1};case"pending":return{...i,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{...i,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...i,data:void 0,error:e.error,failureCount:i.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),qe.batch(()=>{v(this,hs).forEach(i=>{i.onMutationUpdate(e)}),v(this,et).notify({mutation:this,type:"updated",action:e})})},$f);function fp(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ts,Gt,qr,Wf,yy=(Wf=class extends Fn{constructor(e={}){super();Y(this,Ts);Y(this,Gt);Y(this,qr);this.config=e,z(this,Ts,new Set),z(this,Gt,new Map),z(this,qr,0)}build(e,t,i){const n=new xy({client:e,mutationCache:this,mutationId:++ro(this,qr)._,options:e.defaultMutationOptions(t),state:i});return this.add(n),n}add(e){v(this,Ts).add(e);const t=oo(e);if(typeof t=="string"){const i=v(this,Gt).get(t);i?i.push(e):v(this,Gt).set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(v(this,Ts).delete(e)){const t=oo(e);if(typeof t=="string"){const i=v(this,Gt).get(t);if(i)if(i.length>1){const n=i.indexOf(e);n!==-1&&i.splice(n,1)}else i[0]===e&&v(this,Gt).delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=oo(e);if(typeof t=="string"){const i=v(this,Gt).get(t),n=i==null?void 0:i.find(r=>r.state.status==="pending");return!n||n===e}else return!0}runNext(e){var i;const t=oo(e);if(typeof t=="string"){const n=(i=v(this,Gt).get(t))==null?void 0:i.find(r=>r!==e&&r.state.isPaused);return(n==null?void 0:n.continue())??Promise.resolve()}else return Promise.resolve()}clear(){qe.batch(()=>{v(this,Ts).forEach(e=>{this.notify({type:"removed",mutation:e})}),v(this,Ts).clear(),v(this,Gt).clear()})}getAll(){return Array.from(v(this,Ts))}find(e){const t={exact:!0,...e};return this.getAll().find(i=>od(t,i))}findAll(e={}){return this.getAll().filter(t=>od(e,t))}notify(e){qe.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return qe.batch(()=>Promise.all(e.map(t=>t.continue().catch(ht))))}},Ts=new WeakMap,Gt=new WeakMap,qr=new WeakMap,Wf);function oo(s){var e;return(e=s.options.scope)==null?void 0:e.id}var Os,ei,vt,Ps,Is,Io,Yl,Hf,by=(Hf=class extends Fn{constructor(t,i){super();Y(this,Is);Y(this,Os);Y(this,ei);Y(this,vt);Y(this,Ps);z(this,Os,t),this.setOptions(i),this.bindMethods(),re(this,Is,Io).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var n;const i=this.options;this.options=v(this,Os).defaultMutationOptions(t),_o(this.options,i)||v(this,Os).getMutationCache().notify({type:"observerOptionsUpdated",mutation:v(this,vt),observer:this}),i!=null&&i.mutationKey&&this.options.mutationKey&&Fi(i.mutationKey)!==Fi(this.options.mutationKey)?this.reset():((n=v(this,vt))==null?void 0:n.state.status)==="pending"&&v(this,vt).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=v(this,vt))==null||t.removeObserver(this)}onMutationUpdate(t){re(this,Is,Io).call(this),re(this,Is,Yl).call(this,t)}getCurrentResult(){return v(this,ei)}reset(){var t;(t=v(this,vt))==null||t.removeObserver(this),z(this,vt,void 0),re(this,Is,Io).call(this),re(this,Is,Yl).call(this)}mutate(t,i){var n;return z(this,Ps,i),(n=v(this,vt))==null||n.removeObserver(this),z(this,vt,v(this,Os).getMutationCache().build(v(this,Os),this.options)),v(this,vt).addObserver(this),v(this,vt).execute(t)}},Os=new WeakMap,ei=new WeakMap,vt=new WeakMap,Ps=new WeakMap,Is=new WeakSet,Io=function(){var i;const t=((i=v(this,vt))==null?void 0:i.state)??fp();z(this,ei,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},Yl=function(t){qe.batch(()=>{var i,n,r,o,a,l,c,d;if(v(this,Ps)&&this.hasListeners()){const u=v(this,ei).variables,f=v(this,ei).context,p={client:v(this,Os),meta:this.options.meta,mutationKey:this.options.mutationKey};if((t==null?void 0:t.type)==="success"){try{(n=(i=v(this,Ps)).onSuccess)==null||n.call(i,t.data,u,f,p)}catch(m){Promise.reject(m)}try{(o=(r=v(this,Ps)).onSettled)==null||o.call(r,t.data,null,u,f,p)}catch(m){Promise.reject(m)}}else if((t==null?void 0:t.type)==="error"){try{(l=(a=v(this,Ps)).onError)==null||l.call(a,t.error,u,f,p)}catch(m){Promise.reject(m)}try{(d=(c=v(this,Ps)).onSettled)==null||d.call(c,void 0,t.error,u,f,p)}catch(m){Promise.reject(m)}}}this.listeners.forEach(u=>{u(v(this,ei))})})},Hf),us,qf,vy=(qf=class extends Fn{constructor(e={}){super();Y(this,us);this.config=e,z(this,us,new Map)}build(e,t,i){const n=t.queryKey,r=t.queryHash??th(n,t);let o=this.get(r);return o||(o=new fy({client:e,queryKey:n,queryHash:r,options:e.defaultQueryOptions(t),state:i,defaultOptions:e.getQueryDefaults(n)}),this.add(o)),o}add(e){v(this,us).has(e.queryHash)||(v(this,us).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=v(this,us).get(e.queryHash);t&&(e.destroy(),t===e&&v(this,us).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){qe.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return v(this,us).get(e)}getAll(){return[...v(this,us).values()]}find(e){const t={exact:!0,...e};return this.getAll().find(i=>rd(t,i))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(i=>rd(e,i)):t}notify(e){qe.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){qe.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){qe.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},us=new WeakMap,qf),Re,ti,si,Nn,Mn,ii,An,Tn,Vf,wy=(Vf=class{constructor(s={}){Y(this,Re);Y(this,ti);Y(this,si);Y(this,Nn);Y(this,Mn);Y(this,ii);Y(this,An);Y(this,Tn);z(this,Re,s.queryCache||new vy),z(this,ti,s.mutationCache||new yy),z(this,si,s.defaultOptions||{}),z(this,Nn,new Map),z(this,Mn,new Map),z(this,ii,0)}mount(){ro(this,ii)._++,v(this,ii)===1&&(z(this,An,eh.subscribe(async s=>{s&&(await this.resumePausedMutations(),v(this,Re).onFocus())})),z(this,Tn,Uo.subscribe(async s=>{s&&(await this.resumePausedMutations(),v(this,Re).onOnline())})))}unmount(){var s,e;ro(this,ii)._--,v(this,ii)===0&&((s=v(this,An))==null||s.call(this),z(this,An,void 0),(e=v(this,Tn))==null||e.call(this),z(this,Tn,void 0))}isFetching(s){return v(this,Re).findAll({...s,fetchStatus:"fetching"}).length}isMutating(s){return v(this,ti).findAll({...s,status:"pending"}).length}getQueryData(s){var t;const e=this.defaultQueryOptions({queryKey:s});return(t=v(this,Re).get(e.queryHash))==null?void 0:t.state.data}ensureQueryData(s){const e=this.defaultQueryOptions(s),t=v(this,Re).build(this,e),i=t.state.data;return i===void 0?this.fetchQuery(s):(s.revalidateIfStale&&t.isStaleByTime(ri(e.staleTime,t))&&this.prefetchQuery(e),Promise.resolve(i))}getQueriesData(s){return v(this,Re).findAll(s).map(({queryKey:e,state:t})=>{const i=t.data;return[e,i]})}setQueryData(s,e,t){const i=this.defaultQueryOptions({queryKey:s}),n=v(this,Re).get(i.queryHash),r=n==null?void 0:n.state.data,o=ey(e,r);if(o!==void 0)return v(this,Re).build(this,i).setData(o,{...t,manual:!0})}setQueriesData(s,e,t){return qe.batch(()=>v(this,Re).findAll(s).map(({queryKey:i})=>[i,this.setQueryData(i,e,t)]))}getQueryState(s){var t;const e=this.defaultQueryOptions({queryKey:s});return(t=v(this,Re).get(e.queryHash))==null?void 0:t.state}removeQueries(s){const e=v(this,Re);qe.batch(()=>{e.findAll(s).forEach(t=>{e.remove(t)})})}resetQueries(s,e){const t=v(this,Re);return qe.batch(()=>(t.findAll(s).forEach(i=>{i.reset()}),this.refetchQueries({type:"active",...s},e)))}cancelQueries(s,e={}){const t={revert:!0,...e},i=qe.batch(()=>v(this,Re).findAll(s).map(n=>n.cancel(t)));return Promise.all(i).then(ht).catch(ht)}invalidateQueries(s,e={}){return qe.batch(()=>(v(this,Re).findAll(s).forEach(t=>{t.invalidate()}),(s==null?void 0:s.refetchType)==="none"?Promise.resolve():this.refetchQueries({...s,type:(s==null?void 0:s.refetchType)??(s==null?void 0:s.type)??"active"},e)))}refetchQueries(s,e={}){const t={...e,cancelRefetch:e.cancelRefetch??!0},i=qe.batch(()=>v(this,Re).findAll(s).filter(n=>!n.isDisabled()&&!n.isStatic()).map(n=>{let r=n.fetch(void 0,t);return t.throwOnError||(r=r.catch(ht)),n.state.fetchStatus==="paused"?Promise.resolve():r}));return Promise.all(i).then(ht)}fetchQuery(s){const e=this.defaultQueryOptions(s);e.retry===void 0&&(e.retry=!1);const t=v(this,Re).build(this,e);return t.isStaleByTime(ri(e.staleTime,t))?t.fetch(e):Promise.resolve(t.state.data)}prefetchQuery(s){return this.fetchQuery(s).then(ht).catch(ht)}fetchInfiniteQuery(s){return s._type="infinite",this.fetchQuery(s)}prefetchInfiniteQuery(s){return this.fetchInfiniteQuery(s).then(ht).catch(ht)}ensureInfiniteQueryData(s){return s._type="infinite",this.ensureQueryData(s)}resumePausedMutations(){return Uo.isOnline()?v(this,ti).resumePausedMutations():Promise.resolve()}getQueryCache(){return v(this,Re)}getMutationCache(){return v(this,ti)}getDefaultOptions(){return v(this,si)}setDefaultOptions(s){z(this,si,s)}setQueryDefaults(s,e){v(this,Nn).set(Fi(s),{queryKey:s,defaultOptions:e})}getQueryDefaults(s){const e=[...v(this,Nn).values()],t={};return e.forEach(i=>{mr(s,i.queryKey)&&Object.assign(t,i.defaultOptions)}),t}setMutationDefaults(s,e){v(this,Mn).set(Fi(s),{mutationKey:s,defaultOptions:e})}getMutationDefaults(s){const e=[...v(this,Mn).values()],t={};return e.forEach(i=>{mr(s,i.mutationKey)&&Object.assign(t,i.defaultOptions)}),t}defaultQueryOptions(s){if(s._defaulted)return s;const e={...v(this,si).queries,...this.getQueryDefaults(s.queryKey),...s,_defaulted:!0};return e.queryHash||(e.queryHash=th(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===sh&&(e.enabled=!1),e}defaultMutationOptions(s){return s!=null&&s._defaulted?s:{...v(this,si).mutations,...(s==null?void 0:s.mutationKey)&&this.getMutationDefaults(s.mutationKey),...s,_defaulted:!0}}clear(){v(this,Re).clear(),v(this,ti).clear()}},Re=new WeakMap,ti=new WeakMap,si=new WeakMap,Nn=new WeakMap,Mn=new WeakMap,ii=new WeakMap,An=new WeakMap,Tn=new WeakMap,Vf),pp=C.createContext(void 0),Xe=s=>{const e=C.useContext(pp);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},ky=({client:s,children:e})=>(C.useEffect(()=>(s.mount(),()=>{s.unmount()}),[s]),h.jsx(pp.Provider,{value:s,children:e})),mp=C.createContext(!1),Sy=()=>C.useContext(mp);mp.Provider;function Cy(){let s=!1;return{clearReset:()=>{s=!1},reset:()=>{s=!0},isReset:()=>s}}var jy=C.createContext(Cy()),Ny=()=>C.useContext(jy),My=(s,e,t)=>{const i=t!=null&&t.state.error&&typeof s.throwOnError=="function"?ih(s.throwOnError,[t.state.error,t]):s.throwOnError;(s.suspense||s.experimental_prefetchInRender||i)&&(e.isReset()||(s.retryOnMount=!1))},Ay=s=>{C.useEffect(()=>{s.clearReset()},[s])},Ty=({result:s,errorResetBoundary:e,throwOnError:t,query:i,suspense:n})=>s.isError&&!e.isReset()&&!s.isFetching&&i&&(n&&s.data===void 0||ih(t,[s.error,i])),Oy=s=>{if(s.suspense){const t=n=>n==="static"?n:Math.max(n??1e3,1e3),i=s.staleTime;s.staleTime=typeof i=="function"?(...n)=>t(i(...n)):t(i),typeof s.gcTime=="number"&&(s.gcTime=Math.max(s.gcTime,1e3))}},Py=(s,e)=>s.isLoading&&s.isFetching&&!e,Ey=(s,e)=>(s==null?void 0:s.suspense)&&e.isPending,pd=(s,e,t)=>e.fetchOptimistic(s).catch(()=>{t.clearReset()});function Dy(s,e,t){var p,m,g,x;const i=Sy(),n=Ny(),r=Xe(),o=r.defaultQueryOptions(s);(m=(p=r.getDefaultOptions().queries)==null?void 0:p._experimental_beforeQuery)==null||m.call(p,o);const a=r.getQueryCache().get(o.queryHash),l=s.subscribed!==!1;o._optimisticResults=i?"isRestoring":l?"optimistic":void 0,Oy(o),My(o,n,a),Ay(n);const c=!r.getQueryCache().get(o.queryHash),[d]=C.useState(()=>new e(r,o)),u=d.getOptimisticResult(o),f=!i&&l;if(C.useSyncExternalStore(C.useCallback(b=>{const S=f?d.subscribe(qe.batchCalls(b)):ht;return d.updateResult(),S},[d,f]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),C.useEffect(()=>{d.setOptions(o)},[o,d]),Ey(o,u))throw pd(o,d,n);if(Ty({result:u,errorResetBoundary:n,throwOnError:o.throwOnError,query:a,suspense:o.suspense}))throw u.error;if((x=(g=r.getDefaultOptions().queries)==null?void 0:g._experimental_afterQuery)==null||x.call(g,o,u),o.experimental_prefetchInRender&&!gr.isServer()&&Py(u,i)){const b=c?pd(o,d,n):a==null?void 0:a.promise;b==null||b.catch(ht).finally(()=>{d.updateResult()})}return o.notifyOnChangeProps?u:d.trackResult(u)}function Ie(s,e){return Dy(s,py)}function we(s,e){const t=Xe(),[i]=C.useState(()=>new by(t,s));C.useEffect(()=>{i.setOptions(s)},[i,s]);const n=C.useSyncExternalStore(C.useCallback(o=>i.subscribe(qe.batchCalls(o)),[i]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),r=C.useCallback((o,a)=>{i.mutate(o,a).catch(ht)},[i]);if(n.error&&ih(i.options.throwOnError,[n.error]))throw n.error;return{...n,mutate:r,mutateAsync:n.mutate}}var Ry=s=>{switch(s){case"success":return By;case"info":return Fy;case"warning":return zy;case"error":return $y;default:return null}},Iy=Array(12).fill(0),Ly=({visible:s,className:e})=>R.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":s},R.createElement("div",{className:"sonner-spinner"},Iy.map((t,i)=>R.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${i}`})))),By=R.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},R.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),zy=R.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},R.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),Fy=R.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},R.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),$y=R.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},R.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),Wy=R.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},R.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),R.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),Hy=()=>{let[s,e]=R.useState(document.hidden);return R.useEffect(()=>{let t=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",t),()=>window.removeEventListener("visibilitychange",t)},[]),s},Jl=1,qy=class{constructor(){this.subscribe=s=>(this.subscribers.push(s),()=>{let e=this.subscribers.indexOf(s);this.subscribers.splice(e,1)}),this.publish=s=>{this.subscribers.forEach(e=>e(s))},this.addToast=s=>{this.publish(s),this.toasts=[...this.toasts,s]},this.create=s=>{var e;let{message:t,...i}=s,n=typeof(s==null?void 0:s.id)=="number"||((e=s.id)==null?void 0:e.length)>0?s.id:Jl++,r=this.toasts.find(a=>a.id===n),o=s.dismissible===void 0?!0:s.dismissible;return this.dismissedToasts.has(n)&&this.dismissedToasts.delete(n),r?this.toasts=this.toasts.map(a=>a.id===n?(this.publish({...a,...s,id:n,title:t}),{...a,...s,id:n,dismissible:o,title:t}):a):this.addToast({title:t,...i,dismissible:o,id:n}),n},this.dismiss=s=>(this.dismissedToasts.add(s),s||this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),this.subscribers.forEach(e=>e({id:s,dismiss:!0})),s),this.message=(s,e)=>this.create({...e,message:s}),this.error=(s,e)=>this.create({...e,message:s,type:"error"}),this.success=(s,e)=>this.create({...e,type:"success",message:s}),this.info=(s,e)=>this.create({...e,type:"info",message:s}),this.warning=(s,e)=>this.create({...e,type:"warning",message:s}),this.loading=(s,e)=>this.create({...e,type:"loading",message:s}),this.promise=(s,e)=>{if(!e)return;let t;e.loading!==void 0&&(t=this.create({...e,promise:s,type:"loading",message:e.loading,description:typeof e.description!="function"?e.description:void 0}));let i=s instanceof Promise?s:s(),n=t!==void 0,r,o=i.then(async l=>{if(r=["resolve",l],R.isValidElement(l))n=!1,this.create({id:t,type:"default",message:l});else if(Ky(l)&&!l.ok){n=!1;let c=typeof e.error=="function"?await e.error(`HTTP error! status: ${l.status}`):e.error,d=typeof e.description=="function"?await e.description(`HTTP error! status: ${l.status}`):e.description;this.create({id:t,type:"error",message:c,description:d})}else if(e.success!==void 0){n=!1;let c=typeof e.success=="function"?await e.success(l):e.success,d=typeof e.description=="function"?await e.description(l):e.description;this.create({id:t,type:"success",message:c,description:d})}}).catch(async l=>{if(r=["reject",l],e.error!==void 0){n=!1;let c=typeof e.error=="function"?await e.error(l):e.error,d=typeof e.description=="function"?await e.description(l):e.description;this.create({id:t,type:"error",message:c,description:d})}}).finally(()=>{var l;n&&(this.dismiss(t),t=void 0),(l=e.finally)==null||l.call(e)}),a=()=>new Promise((l,c)=>o.then(()=>r[0]==="reject"?c(r[1]):l(r[1])).catch(c));return typeof t!="string"&&typeof t!="number"?{unwrap:a}:Object.assign(t,{unwrap:a})},this.custom=(s,e)=>{let t=(e==null?void 0:e.id)||Jl++;return this.create({jsx:s(t),id:t,...e}),t},this.getActiveToasts=()=>this.toasts.filter(s=>!this.dismissedToasts.has(s.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},wt=new qy,Vy=(s,e)=>{let t=(e==null?void 0:e.id)||Jl++;return wt.addToast({title:s,...e,id:t}),t},Ky=s=>s&&typeof s=="object"&&"ok"in s&&typeof s.ok=="boolean"&&"status"in s&&typeof s.status=="number",_y=Vy,Uy=()=>wt.toasts,Qy=()=>wt.getActiveToasts(),q=Object.assign(_y,{success:wt.success,info:wt.info,warning:wt.warning,error:wt.error,custom:wt.custom,message:wt.message,promise:wt.promise,dismiss:wt.dismiss,loading:wt.loading},{getHistory:Uy,getToasts:Qy});function Gy(s,{insertAt:e}={}){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css",e==="top"&&t.firstChild?t.insertBefore(i,t.firstChild):t.appendChild(i),i.styleSheet?i.styleSheet.cssText=s:i.appendChild(document.createTextNode(s))}Gy(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
|
|
3
3
|
`);function ao(s){return s.label!==void 0}var Yy=3,Jy="32px",Xy="16px",md=4e3,Zy=356,eb=14,tb=20,sb=200;function Qt(...s){return s.filter(Boolean).join(" ")}function ib(s){let[e,t]=s.split("-"),i=[];return e&&i.push(e),t&&i.push(t),i}var nb=s=>{var e,t,i,n,r,o,a,l,c,d,u;let{invert:f,toast:p,unstyled:m,interacting:g,setHeights:x,visibleToasts:b,heights:S,index:N,toasts:y,expanded:w,removeToast:k,defaultRichColors:M,closeButton:P,style:L,cancelButtonStyle:H,actionButtonStyle:F,className:O="",descriptionClassName:Q="",duration:K,position:U,gap:ae,loadingIcon:fe,expandByDefault:be,classNames:B,icons:ce,closeButtonAriaLabel:me="Close toast",pauseWhenPageIsHidden:Z}=s,[se,_]=R.useState(null),[de,Fe]=R.useState(null),[pe,gt]=R.useState(!1),[Ae,xt]=R.useState(!1),[yt,ns]=R.useState(!1),[Cs,Lt]=R.useState(!1),[j,E]=R.useState(!1),[he,De]=R.useState(0),[xi,io]=R.useState(0),Un=R.useRef(p.duration||K||md),Jh=R.useRef(null),yi=R.useRef(null),Cx=N===0,jx=N+1<=b,Bt=p.type,Ui=p.dismissible!==!1,Nx=p.className||"",Mx=p.descriptionClassName||"",no=R.useMemo(()=>S.findIndex(ie=>ie.toastId===p.id)||0,[S,p.id]),Ax=R.useMemo(()=>{var ie;return(ie=p.closeButton)!=null?ie:P},[p.closeButton,P]),Xh=R.useMemo(()=>p.duration||K||md,[p.duration,K]),Ga=R.useRef(0),Qi=R.useRef(0),Zh=R.useRef(0),Gi=R.useRef(null),[Tx,Ox]=U.split("-"),ed=R.useMemo(()=>S.reduce((ie,ke,Oe)=>Oe>=no?ie:ie+ke.height,0),[S,no]),td=Hy(),Px=p.invert||f,Ya=Bt==="loading";Qi.current=R.useMemo(()=>no*ae+ed,[no,ed]),R.useEffect(()=>{Un.current=Xh},[Xh]),R.useEffect(()=>{gt(!0)},[]),R.useEffect(()=>{let ie=yi.current;if(ie){let ke=ie.getBoundingClientRect().height;return io(ke),x(Oe=>[{toastId:p.id,height:ke,position:p.position},...Oe]),()=>x(Oe=>Oe.filter(Kt=>Kt.toastId!==p.id))}},[x,p.id]),R.useLayoutEffect(()=>{if(!pe)return;let ie=yi.current,ke=ie.style.height;ie.style.height="auto";let Oe=ie.getBoundingClientRect().height;ie.style.height=ke,io(Oe),x(Kt=>Kt.find(_t=>_t.toastId===p.id)?Kt.map(_t=>_t.toastId===p.id?{..._t,height:Oe}:_t):[{toastId:p.id,height:Oe,position:p.position},...Kt])},[pe,p.title,p.description,x,p.id]);let Fs=R.useCallback(()=>{xt(!0),De(Qi.current),x(ie=>ie.filter(ke=>ke.toastId!==p.id)),setTimeout(()=>{k(p)},sb)},[p,k,x,Qi]);R.useEffect(()=>{if(p.promise&&Bt==="loading"||p.duration===1/0||p.type==="loading")return;let ie;return w||g||Z&&td?(()=>{if(Zh.current<Ga.current){let ke=new Date().getTime()-Ga.current;Un.current=Un.current-ke}Zh.current=new Date().getTime()})():Un.current!==1/0&&(Ga.current=new Date().getTime(),ie=setTimeout(()=>{var ke;(ke=p.onAutoClose)==null||ke.call(p,p),Fs()},Un.current)),()=>clearTimeout(ie)},[w,g,p,Bt,Z,td,Fs]),R.useEffect(()=>{p.delete&&Fs()},[Fs,p.delete]);function Ex(){var ie,ke,Oe;return ce!=null&&ce.loading?R.createElement("div",{className:Qt(B==null?void 0:B.loader,(ie=p==null?void 0:p.classNames)==null?void 0:ie.loader,"sonner-loader"),"data-visible":Bt==="loading"},ce.loading):fe?R.createElement("div",{className:Qt(B==null?void 0:B.loader,(ke=p==null?void 0:p.classNames)==null?void 0:ke.loader,"sonner-loader"),"data-visible":Bt==="loading"},fe):R.createElement(Ly,{className:Qt(B==null?void 0:B.loader,(Oe=p==null?void 0:p.classNames)==null?void 0:Oe.loader),visible:Bt==="loading"})}return R.createElement("li",{tabIndex:0,ref:yi,className:Qt(O,Nx,B==null?void 0:B.toast,(e=p==null?void 0:p.classNames)==null?void 0:e.toast,B==null?void 0:B.default,B==null?void 0:B[Bt],(t=p==null?void 0:p.classNames)==null?void 0:t[Bt]),"data-sonner-toast":"","data-rich-colors":(i=p.richColors)!=null?i:M,"data-styled":!(p.jsx||p.unstyled||m),"data-mounted":pe,"data-promise":!!p.promise,"data-swiped":j,"data-removed":Ae,"data-visible":jx,"data-y-position":Tx,"data-x-position":Ox,"data-index":N,"data-front":Cx,"data-swiping":yt,"data-dismissible":Ui,"data-type":Bt,"data-invert":Px,"data-swipe-out":Cs,"data-swipe-direction":de,"data-expanded":!!(w||be&&pe),style:{"--index":N,"--toasts-before":N,"--z-index":y.length-N,"--offset":`${Ae?he:Qi.current}px`,"--initial-height":be?"auto":`${xi}px`,...L,...p.style},onDragEnd:()=>{ns(!1),_(null),Gi.current=null},onPointerDown:ie=>{Ya||!Ui||(Jh.current=new Date,De(Qi.current),ie.target.setPointerCapture(ie.pointerId),ie.target.tagName!=="BUTTON"&&(ns(!0),Gi.current={x:ie.clientX,y:ie.clientY}))},onPointerUp:()=>{var ie,ke,Oe,Kt;if(Cs||!Ui)return;Gi.current=null;let _t=Number(((ie=yi.current)==null?void 0:ie.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),$s=Number(((ke=yi.current)==null?void 0:ke.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),bi=new Date().getTime()-((Oe=Jh.current)==null?void 0:Oe.getTime()),Ut=se==="x"?_t:$s,Ws=Math.abs(Ut)/bi;if(Math.abs(Ut)>=tb||Ws>.11){De(Qi.current),(Kt=p.onDismiss)==null||Kt.call(p,p),Fe(se==="x"?_t>0?"right":"left":$s>0?"down":"up"),Fs(),Lt(!0),E(!1);return}ns(!1),_(null)},onPointerMove:ie=>{var ke,Oe,Kt,_t;if(!Gi.current||!Ui||((ke=window.getSelection())==null?void 0:ke.toString().length)>0)return;let $s=ie.clientY-Gi.current.y,bi=ie.clientX-Gi.current.x,Ut=(Oe=s.swipeDirections)!=null?Oe:ib(U);!se&&(Math.abs(bi)>1||Math.abs($s)>1)&&_(Math.abs(bi)>Math.abs($s)?"x":"y");let Ws={x:0,y:0};se==="y"?(Ut.includes("top")||Ut.includes("bottom"))&&(Ut.includes("top")&&$s<0||Ut.includes("bottom")&&$s>0)&&(Ws.y=$s):se==="x"&&(Ut.includes("left")||Ut.includes("right"))&&(Ut.includes("left")&&bi<0||Ut.includes("right")&&bi>0)&&(Ws.x=bi),(Math.abs(Ws.x)>0||Math.abs(Ws.y)>0)&&E(!0),(Kt=yi.current)==null||Kt.style.setProperty("--swipe-amount-x",`${Ws.x}px`),(_t=yi.current)==null||_t.style.setProperty("--swipe-amount-y",`${Ws.y}px`)}},Ax&&!p.jsx?R.createElement("button",{"aria-label":me,"data-disabled":Ya,"data-close-button":!0,onClick:Ya||!Ui?()=>{}:()=>{var ie;Fs(),(ie=p.onDismiss)==null||ie.call(p,p)},className:Qt(B==null?void 0:B.closeButton,(n=p==null?void 0:p.classNames)==null?void 0:n.closeButton)},(r=ce==null?void 0:ce.close)!=null?r:Wy):null,p.jsx||C.isValidElement(p.title)?p.jsx?p.jsx:typeof p.title=="function"?p.title():p.title:R.createElement(R.Fragment,null,Bt||p.icon||p.promise?R.createElement("div",{"data-icon":"",className:Qt(B==null?void 0:B.icon,(o=p==null?void 0:p.classNames)==null?void 0:o.icon)},p.promise||p.type==="loading"&&!p.icon?p.icon||Ex():null,p.type!=="loading"?p.icon||(ce==null?void 0:ce[Bt])||Ry(Bt):null):null,R.createElement("div",{"data-content":"",className:Qt(B==null?void 0:B.content,(a=p==null?void 0:p.classNames)==null?void 0:a.content)},R.createElement("div",{"data-title":"",className:Qt(B==null?void 0:B.title,(l=p==null?void 0:p.classNames)==null?void 0:l.title)},typeof p.title=="function"?p.title():p.title),p.description?R.createElement("div",{"data-description":"",className:Qt(Q,Mx,B==null?void 0:B.description,(c=p==null?void 0:p.classNames)==null?void 0:c.description)},typeof p.description=="function"?p.description():p.description):null),C.isValidElement(p.cancel)?p.cancel:p.cancel&&ao(p.cancel)?R.createElement("button",{"data-button":!0,"data-cancel":!0,style:p.cancelButtonStyle||H,onClick:ie=>{var ke,Oe;ao(p.cancel)&&Ui&&((Oe=(ke=p.cancel).onClick)==null||Oe.call(ke,ie),Fs())},className:Qt(B==null?void 0:B.cancelButton,(d=p==null?void 0:p.classNames)==null?void 0:d.cancelButton)},p.cancel.label):null,C.isValidElement(p.action)?p.action:p.action&&ao(p.action)?R.createElement("button",{"data-button":!0,"data-action":!0,style:p.actionButtonStyle||F,onClick:ie=>{var ke,Oe;ao(p.action)&&((Oe=(ke=p.action).onClick)==null||Oe.call(ke,ie),!ie.defaultPrevented&&Fs())},className:Qt(B==null?void 0:B.actionButton,(u=p==null?void 0:p.classNames)==null?void 0:u.actionButton)},p.action.label):null))};function gd(){if(typeof window>"u"||typeof document>"u")return"ltr";let s=document.documentElement.getAttribute("dir");return s==="auto"||!s?window.getComputedStyle(document.documentElement).direction:s}function rb(s,e){let t={};return[s,e].forEach((i,n)=>{let r=n===1,o=r?"--mobile-offset":"--offset",a=r?Xy:Jy;function l(c){["top","right","bottom","left"].forEach(d=>{t[`${o}-${d}`]=typeof c=="number"?`${c}px`:c})}typeof i=="number"||typeof i=="string"?l(i):typeof i=="object"?["top","right","bottom","left"].forEach(c=>{i[c]===void 0?t[`${o}-${c}`]=a:t[`${o}-${c}`]=typeof i[c]=="number"?`${i[c]}px`:i[c]}):l(a)}),t}var ob=C.forwardRef(function(s,e){let{invert:t,position:i="bottom-right",hotkey:n=["altKey","KeyT"],expand:r,closeButton:o,className:a,offset:l,mobileOffset:c,theme:d="light",richColors:u,duration:f,style:p,visibleToasts:m=Yy,toastOptions:g,dir:x=gd(),gap:b=eb,loadingIcon:S,icons:N,containerAriaLabel:y="Notifications",pauseWhenPageIsHidden:w}=s,[k,M]=R.useState([]),P=R.useMemo(()=>Array.from(new Set([i].concat(k.filter(Z=>Z.position).map(Z=>Z.position)))),[k,i]),[L,H]=R.useState([]),[F,O]=R.useState(!1),[Q,K]=R.useState(!1),[U,ae]=R.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),fe=R.useRef(null),be=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),B=R.useRef(null),ce=R.useRef(!1),me=R.useCallback(Z=>{M(se=>{var _;return(_=se.find(de=>de.id===Z.id))!=null&&_.delete||wt.dismiss(Z.id),se.filter(({id:de})=>de!==Z.id)})},[]);return R.useEffect(()=>wt.subscribe(Z=>{if(Z.dismiss){M(se=>se.map(_=>_.id===Z.id?{..._,delete:!0}:_));return}setTimeout(()=>{Vx.flushSync(()=>{M(se=>{let _=se.findIndex(de=>de.id===Z.id);return _!==-1?[...se.slice(0,_),{...se[_],...Z},...se.slice(_+1)]:[Z,...se]})})})}),[]),R.useEffect(()=>{if(d!=="system"){ae(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?ae("dark"):ae("light")),typeof window>"u")return;let Z=window.matchMedia("(prefers-color-scheme: dark)");try{Z.addEventListener("change",({matches:se})=>{ae(se?"dark":"light")})}catch{Z.addListener(({matches:_})=>{try{ae(_?"dark":"light")}catch(de){console.error(de)}})}},[d]),R.useEffect(()=>{k.length<=1&&O(!1)},[k]),R.useEffect(()=>{let Z=se=>{var _,de;n.every(Fe=>se[Fe]||se.code===Fe)&&(O(!0),(_=fe.current)==null||_.focus()),se.code==="Escape"&&(document.activeElement===fe.current||(de=fe.current)!=null&&de.contains(document.activeElement))&&O(!1)};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},[n]),R.useEffect(()=>{if(fe.current)return()=>{B.current&&(B.current.focus({preventScroll:!0}),B.current=null,ce.current=!1)}},[fe.current]),R.createElement("section",{ref:e,"aria-label":`${y} ${be}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},P.map((Z,se)=>{var _;let[de,Fe]=Z.split("-");return k.length?R.createElement("ol",{key:Z,dir:x==="auto"?gd():x,tabIndex:-1,ref:fe,className:a,"data-sonner-toaster":!0,"data-theme":U,"data-y-position":de,"data-lifted":F&&k.length>1&&!r,"data-x-position":Fe,style:{"--front-toast-height":`${((_=L[0])==null?void 0:_.height)||0}px`,"--width":`${Zy}px`,"--gap":`${b}px`,...p,...rb(l,c)},onBlur:pe=>{ce.current&&!pe.currentTarget.contains(pe.relatedTarget)&&(ce.current=!1,B.current&&(B.current.focus({preventScroll:!0}),B.current=null))},onFocus:pe=>{pe.target instanceof HTMLElement&&pe.target.dataset.dismissible==="false"||ce.current||(ce.current=!0,B.current=pe.relatedTarget)},onMouseEnter:()=>O(!0),onMouseMove:()=>O(!0),onMouseLeave:()=>{Q||O(!1)},onDragEnd:()=>O(!1),onPointerDown:pe=>{pe.target instanceof HTMLElement&&pe.target.dataset.dismissible==="false"||K(!0)},onPointerUp:()=>K(!1)},k.filter(pe=>!pe.position&&se===0||pe.position===Z).map((pe,gt)=>{var Ae,xt;return R.createElement(nb,{key:pe.id,icons:N,index:gt,toast:pe,defaultRichColors:u,duration:(Ae=g==null?void 0:g.duration)!=null?Ae:f,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:t,visibleToasts:m,closeButton:(xt=g==null?void 0:g.closeButton)!=null?xt:o,interacting:Q,position:Z,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:me,toasts:k.filter(yt=>yt.position==pe.position),heights:L.filter(yt=>yt.position==pe.position),setHeights:H,expandByDefault:r,gap:b,loadingIcon:S,expanded:F,pauseWhenPageIsHidden:w,swipeDirections:s.swipeDirections})})):null}))});class gp extends Error{constructor(e,t,i){super(e),this.status=t,this.body=i}}let xr=null;function xd(s){xr=s}async function lo(s,e={}){const t=xp(s,e.query),i={method:e.method??"GET",credentials:"same-origin",signal:e.signal,headers:e.body!==void 0?{"content-type":"application/json"}:void 0,body:e.body!==void 0?JSON.stringify(e.body):void 0},n=await fetch(t,i);n.status===401&&xr&&xr();const r=await n.text(),a=(n.headers.get("content-type")??"").includes("application/json")&&r?yp(r):r;if(!n.ok){const l=a&&typeof a=="object"&&"error"in a&&a.error||n.statusText||`HTTP ${n.status}`;throw new gp(String(l),n.status,a)}return a}function xp(s,e){if(!e)return s;const t=new URLSearchParams;for(const[n,r]of Object.entries(e))r!=null&&t.set(n,String(r));const i=t.toString();return i?`${s}?${i}`:s}function yp(s){try{return JSON.parse(s)}catch{return s}}const ne={get:(s,e,t)=>lo(s,{query:e,signal:t}),post:(s,e,t)=>lo(s,{method:"POST",body:e,query:t}),put:(s,e,t)=>lo(s,{method:"PUT",body:e,query:t}),delete:(s,e)=>lo(s,{method:"DELETE",query:e}),upload:async(s,e,t)=>{const i=new FormData;i.append("file",e);const n=xp(s,t),r=await fetch(n,{method:"POST",credentials:"same-origin",body:i});r.status===401&&xr&&xr();const o=await r.text(),l=(r.headers.get("content-type")??"").includes("application/json")&&o?yp(o):o;if(!r.ok)throw new gp(`upload failed: ${r.status}`,r.status,l);return l}},ee={me:()=>ne.get("/api/auth/me"),login:(s,e)=>ne.post("/api/auth/login",{username:s,password:e}),logout:()=>ne.post("/api/auth/logout"),listAgents:()=>ne.get("/api/agents"),getAgent:s=>ne.get(`/api/agents/${s}`),listPlugins:s=>ne.get(`/api/agents/${s}/plugins`),startAgent:s=>ne.post(`/api/agents/${s}/start`),stopAgent:s=>ne.post(`/api/agents/${s}/stop`),restartAgent:s=>ne.post(`/api/agents/${s}/restart`),listTree:(s,e)=>ne.get(`/api/agents/${s}/fs/tree`,{path:e}),readFile:(s,e)=>ne.get(`/api/agents/${s}/fs/file`,{path:e}),writeFile:(s,e,t)=>ne.put(`/api/agents/${s}/fs/file`,{content:t},{path:e}),uploadFile:(s,e,t)=>ne.upload(`/api/agents/${s}/fs/upload`,e,{dir:t}),mkdir:(s,e)=>ne.post(`/api/agents/${s}/fs/mkdir`,void 0,{path:e}),deletePath:(s,e)=>ne.delete(`/api/agents/${s}/fs/path`,{path:e}),listThreads:s=>ne.get(`/api/agents/${s}/sessions`),readSession:(s,e,t,i)=>ne.get(`/api/agents/${s}/sessions/${encodeURIComponent(e)}/${encodeURIComponent(t)}`+(i?`?limit=${i}`:"")),deleteThread:(s,e)=>ne.delete(`/api/agents/${s}/sessions/${encodeURIComponent(e)}`),readUsage:(s,e)=>ne.get(`/api/agents/${s}/sessions/${encodeURIComponent(e)}/usage`),setThreadModel:(s,e,t)=>ne.put(`/api/agents/${s}/sessions/${encodeURIComponent(e)}/model`,t),listEvents:(s,e)=>{var t;return ne.get(`/api/agents/${s}/events`,{status:(t=e==null?void 0:e.status)==null?void 0:t.join(","),plugin:e==null?void 0:e.plugin,search:e==null?void 0:e.search,isSilent:(e==null?void 0:e.isSilent)===void 0?void 0:e.isSilent?"true":"false",tsFrom:e==null?void 0:e.tsFrom,tsTo:e==null?void 0:e.tsTo,updatedFrom:e==null?void 0:e.updatedFrom,updatedTo:e==null?void 0:e.updatedTo,sortBy:e==null?void 0:e.sortBy,sortDir:e==null?void 0:e.sortDir,limit:e==null?void 0:e.limit,offset:e==null?void 0:e.offset})},discardEvent:(s,e)=>ne.delete(`/api/agents/${s}/events/${e}`),setEventStatus:(s,e,t)=>ne.post(`/api/agents/${s}/events/${e}/status`,{status:t}),sendChat:(s,e,t,i)=>ne.post(`/admin/${s}/send`,{text:e,threadId:t,channelId:i}),abortChat:(s,e)=>ne.post(`/admin/${s}/abort`,{threadId:e}),getSecrets:()=>ne.get("/api/secrets"),putSecrets:s=>ne.put("/api/secrets",s),getModels:()=>ne.get("/api/models"),putModels:s=>ne.put("/api/models",s),startOauthLogin:s=>ne.post(`/api/models/oauth/${s}/login`),submitOauthInput:(s,e,t="text")=>ne.post(`/api/models/oauth/${s}/input`,{value:e,kind:t}),cancelOauthLogin:s=>ne.post(`/api/models/oauth/${s}/cancel`),getOauthStatus:s=>ne.get(`/api/models/oauth/${s}/status`),oauthLogout:s=>ne.delete(`/api/models/oauth/${s}`),getGwsOauth:()=>ne.get("/api/gws/oauth"),putGwsOauthClient:s=>ne.put("/api/gws/oauth/client",s),startGwsSignIn:s=>ne.post(`/api/gws/oauth/${s}/start`,{redirectUri:`${window.location.origin}/api/gws/oauth/callback`}),gwsSignOut:s=>ne.delete(`/api/gws/oauth/${s}`),getHarness:()=>ne.get("/api/harness"),putHarness:s=>ne.put("/api/harness",s),putAgentConfig:(s,e)=>ne.put(`/api/agents/${s}/config`,{config:e}),putPluginConfig:(s,e,t)=>ne.put(`/api/agents/${s}/plugins/${e}/config`,{config:t})};function bp(s,e,t){const i=new URLSearchParams({path:e});return t!=null&&t.download&&i.set("download","1"),`/api/agents/${s}/fs/raw?${i.toString()}`}function vp(s,e){return`/agents/${encodeURIComponent(s)}/chat?thread=${encodeURIComponent(e)}`}let wp={user:null,status:"unknown"};const Xl=new Set;function co(s){wp=s;for(const e of Xl)e()}function ab(s){return Xl.add(s),()=>Xl.delete(s)}const lb={refresh:async()=>{try{const s=await ee.me();co({user:s.user,status:s.user?"authed":"anon"})}catch{co({user:null,status:"anon"})}},login:async(s,e)=>{const t=await ee.login(s,e);co({user:t.username,status:"authed"})},logout:async()=>{await ee.logout().catch(()=>{}),co({user:null,status:"anon"})}};function Ea(){return{...C.useSyncExternalStore(ab,()=>wp),...lb}}const kp="pi-theme";function cb(){try{const s=localStorage.getItem(kp);if(s==="light"||s==="dark")return s}catch{}return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Sp(s){const e=document.documentElement.classList;s==="dark"?e.add("dark"):e.remove("dark");try{localStorage.setItem(kp,s)}catch{}}let Qo=cb();Sp(Qo);const Zl=new Set;function yd(s){Sp(s),Qo=s;for(const e of Zl)e()}function hb(s){return Zl.add(s),()=>Zl.delete(s)}function Vr(){return{theme:C.useSyncExternalStore(hb,()=>Qo),toggle:()=>yd(Qo==="dark"?"light":"dark"),set:yd}}function Cp(s){var e,t,i="";if(typeof s=="string"||typeof s=="number")i+=s;else if(typeof s=="object")if(Array.isArray(s)){var n=s.length;for(e=0;e<n;e++)s[e]&&(t=Cp(s[e]))&&(i&&(i+=" "),i+=t)}else for(t in s)s[t]&&(i&&(i+=" "),i+=t);return i}function db(){for(var s,e,t=0,i="",n=arguments.length;t<n;t++)(s=arguments[t])&&(e=Cp(s))&&(i&&(i+=" "),i+=e);return i}const rh="-",ub=s=>{const e=pb(s),{conflictingClassGroups:t,conflictingClassGroupModifiers:i}=s;return{getClassGroupId:o=>{const a=o.split(rh);return a[0]===""&&a.length!==1&&a.shift(),jp(a,e)||fb(o)},getConflictingClassGroupIds:(o,a)=>{const l=t[o]||[];return a&&i[o]?[...l,...i[o]]:l}}},jp=(s,e)=>{var o;if(s.length===0)return e.classGroupId;const t=s[0],i=e.nextPart.get(t),n=i?jp(s.slice(1),i):void 0;if(n)return n;if(e.validators.length===0)return;const r=s.join(rh);return(o=e.validators.find(({validator:a})=>a(r)))==null?void 0:o.classGroupId},bd=/^\[(.+)\]$/,fb=s=>{if(bd.test(s)){const e=bd.exec(s)[1],t=e==null?void 0:e.substring(0,e.indexOf(":"));if(t)return"arbitrary.."+t}},pb=s=>{const{theme:e,prefix:t}=s,i={nextPart:new Map,validators:[]};return gb(Object.entries(s.classGroups),t).forEach(([r,o])=>{ec(o,i,r,e)}),i},ec=(s,e,t,i)=>{s.forEach(n=>{if(typeof n=="string"){const r=n===""?e:vd(e,n);r.classGroupId=t;return}if(typeof n=="function"){if(mb(n)){ec(n(i),e,t,i);return}e.validators.push({validator:n,classGroupId:t});return}Object.entries(n).forEach(([r,o])=>{ec(o,vd(e,r),t,i)})})},vd=(s,e)=>{let t=s;return e.split(rh).forEach(i=>{t.nextPart.has(i)||t.nextPart.set(i,{nextPart:new Map,validators:[]}),t=t.nextPart.get(i)}),t},mb=s=>s.isThemeGetter,gb=(s,e)=>e?s.map(([t,i])=>{const n=i.map(r=>typeof r=="string"?e+r:typeof r=="object"?Object.fromEntries(Object.entries(r).map(([o,a])=>[e+o,a])):r);return[t,n]}):s,xb=s=>{if(s<1)return{get:()=>{},set:()=>{}};let e=0,t=new Map,i=new Map;const n=(r,o)=>{t.set(r,o),e++,e>s&&(e=0,i=t,t=new Map)};return{get(r){let o=t.get(r);if(o!==void 0)return o;if((o=i.get(r))!==void 0)return n(r,o),o},set(r,o){t.has(r)?t.set(r,o):n(r,o)}}},Np="!",yb=s=>{const{separator:e,experimentalParseClassName:t}=s,i=e.length===1,n=e[0],r=e.length,o=a=>{const l=[];let c=0,d=0,u;for(let x=0;x<a.length;x++){let b=a[x];if(c===0){if(b===n&&(i||a.slice(x,x+r)===e)){l.push(a.slice(d,x)),d=x+r;continue}if(b==="/"){u=x;continue}}b==="["?c++:b==="]"&&c--}const f=l.length===0?a:a.substring(d),p=f.startsWith(Np),m=p?f.substring(1):f,g=u&&u>d?u-d:void 0;return{modifiers:l,hasImportantModifier:p,baseClassName:m,maybePostfixModifierPosition:g}};return t?a=>t({className:a,parseClassName:o}):o},bb=s=>{if(s.length<=1)return s;const e=[];let t=[];return s.forEach(i=>{i[0]==="["?(e.push(...t.sort(),i),t=[]):t.push(i)}),e.push(...t.sort()),e},vb=s=>({cache:xb(s.cacheSize),parseClassName:yb(s),...ub(s)}),wb=/\s+/,kb=(s,e)=>{const{parseClassName:t,getClassGroupId:i,getConflictingClassGroupIds:n}=e,r=[],o=s.trim().split(wb);let a="";for(let l=o.length-1;l>=0;l-=1){const c=o[l],{modifiers:d,hasImportantModifier:u,baseClassName:f,maybePostfixModifierPosition:p}=t(c);let m=!!p,g=i(m?f.substring(0,p):f);if(!g){if(!m){a=c+(a.length>0?" "+a:a);continue}if(g=i(f),!g){a=c+(a.length>0?" "+a:a);continue}m=!1}const x=bb(d).join(":"),b=u?x+Np:x,S=b+g;if(r.includes(S))continue;r.push(S);const N=n(g,m);for(let y=0;y<N.length;++y){const w=N[y];r.push(b+w)}a=c+(a.length>0?" "+a:a)}return a};function Sb(){let s=0,e,t,i="";for(;s<arguments.length;)(e=arguments[s++])&&(t=Mp(e))&&(i&&(i+=" "),i+=t);return i}const Mp=s=>{if(typeof s=="string")return s;let e,t="";for(let i=0;i<s.length;i++)s[i]&&(e=Mp(s[i]))&&(t&&(t+=" "),t+=e);return t};function Cb(s,...e){let t,i,n,r=o;function o(l){const c=e.reduce((d,u)=>u(d),s());return t=vb(c),i=t.cache.get,n=t.cache.set,r=a,a(l)}function a(l){const c=i(l);if(c)return c;const d=kb(l,t);return n(l,d),d}return function(){return r(Sb.apply(null,arguments))}}const Te=s=>{const e=t=>t[s]||[];return e.isThemeGetter=!0,e},Ap=/^\[(?:([a-z-]+):)?(.+)\]$/i,jb=/^\d+\/\d+$/,Nb=new Set(["px","full","screen"]),Mb=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Ab=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Tb=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Ob=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Pb=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,js=s=>an(s)||Nb.has(s)||jb.test(s),Hs=s=>$n(s,"length",Fb),an=s=>!!s&&!Number.isNaN(Number(s)),Xa=s=>$n(s,"number",an),Qn=s=>!!s&&Number.isInteger(Number(s)),Eb=s=>s.endsWith("%")&&an(s.slice(0,-1)),oe=s=>Ap.test(s),qs=s=>Mb.test(s),Db=new Set(["length","size","percentage"]),Rb=s=>$n(s,Db,Tp),Ib=s=>$n(s,"position",Tp),Lb=new Set(["image","url"]),Bb=s=>$n(s,Lb,Wb),zb=s=>$n(s,"",$b),Gn=()=>!0,$n=(s,e,t)=>{const i=Ap.exec(s);return i?i[1]?typeof e=="string"?i[1]===e:e.has(i[1]):t(i[2]):!1},Fb=s=>Ab.test(s)&&!Tb.test(s),Tp=()=>!1,$b=s=>Ob.test(s),Wb=s=>Pb.test(s),Hb=()=>{const s=Te("colors"),e=Te("spacing"),t=Te("blur"),i=Te("brightness"),n=Te("borderColor"),r=Te("borderRadius"),o=Te("borderSpacing"),a=Te("borderWidth"),l=Te("contrast"),c=Te("grayscale"),d=Te("hueRotate"),u=Te("invert"),f=Te("gap"),p=Te("gradientColorStops"),m=Te("gradientColorStopPositions"),g=Te("inset"),x=Te("margin"),b=Te("opacity"),S=Te("padding"),N=Te("saturate"),y=Te("scale"),w=Te("sepia"),k=Te("skew"),M=Te("space"),P=Te("translate"),L=()=>["auto","contain","none"],H=()=>["auto","hidden","clip","visible","scroll"],F=()=>["auto",oe,e],O=()=>[oe,e],Q=()=>["",js,Hs],K=()=>["auto",an,oe],U=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],ae=()=>["solid","dashed","dotted","double","none"],fe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],be=()=>["start","end","center","between","around","evenly","stretch"],B=()=>["","0",oe],ce=()=>["auto","avoid","all","avoid-page","page","left","right","column"],me=()=>[an,oe];return{cacheSize:500,separator:":",theme:{colors:[Gn],spacing:[js,Hs],blur:["none","",qs,oe],brightness:me(),borderColor:[s],borderRadius:["none","","full",qs,oe],borderSpacing:O(),borderWidth:Q(),contrast:me(),grayscale:B(),hueRotate:me(),invert:B(),gap:O(),gradientColorStops:[s],gradientColorStopPositions:[Eb,Hs],inset:F(),margin:F(),opacity:me(),padding:O(),saturate:me(),scale:me(),sepia:B(),skew:me(),space:O(),translate:O()},classGroups:{aspect:[{aspect:["auto","square","video",oe]}],container:["container"],columns:[{columns:[qs]}],"break-after":[{"break-after":ce()}],"break-before":[{"break-before":ce()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...U(),oe]}],overflow:[{overflow:H()}],"overflow-x":[{"overflow-x":H()}],"overflow-y":[{"overflow-y":H()}],overscroll:[{overscroll:L()}],"overscroll-x":[{"overscroll-x":L()}],"overscroll-y":[{"overscroll-y":L()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[g]}],"inset-x":[{"inset-x":[g]}],"inset-y":[{"inset-y":[g]}],start:[{start:[g]}],end:[{end:[g]}],top:[{top:[g]}],right:[{right:[g]}],bottom:[{bottom:[g]}],left:[{left:[g]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Qn,oe]}],basis:[{basis:F()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",oe]}],grow:[{grow:B()}],shrink:[{shrink:B()}],order:[{order:["first","last","none",Qn,oe]}],"grid-cols":[{"grid-cols":[Gn]}],"col-start-end":[{col:["auto",{span:["full",Qn,oe]},oe]}],"col-start":[{"col-start":K()}],"col-end":[{"col-end":K()}],"grid-rows":[{"grid-rows":[Gn]}],"row-start-end":[{row:["auto",{span:[Qn,oe]},oe]}],"row-start":[{"row-start":K()}],"row-end":[{"row-end":K()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",oe]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",oe]}],gap:[{gap:[f]}],"gap-x":[{"gap-x":[f]}],"gap-y":[{"gap-y":[f]}],"justify-content":[{justify:["normal",...be()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...be(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...be(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[S]}],px:[{px:[S]}],py:[{py:[S]}],ps:[{ps:[S]}],pe:[{pe:[S]}],pt:[{pt:[S]}],pr:[{pr:[S]}],pb:[{pb:[S]}],pl:[{pl:[S]}],m:[{m:[x]}],mx:[{mx:[x]}],my:[{my:[x]}],ms:[{ms:[x]}],me:[{me:[x]}],mt:[{mt:[x]}],mr:[{mr:[x]}],mb:[{mb:[x]}],ml:[{ml:[x]}],"space-x":[{"space-x":[M]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[M]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",oe,e]}],"min-w":[{"min-w":[oe,e,"min","max","fit"]}],"max-w":[{"max-w":[oe,e,"none","full","min","max","fit","prose",{screen:[qs]},qs]}],h:[{h:[oe,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[oe,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[oe,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[oe,e,"auto","min","max","fit"]}],"font-size":[{text:["base",qs,Hs]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Xa]}],"font-family":[{font:[Gn]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",oe]}],"line-clamp":[{"line-clamp":["none",an,Xa]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",js,oe]}],"list-image":[{"list-image":["none",oe]}],"list-style-type":[{list:["none","disc","decimal",oe]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[s]}],"placeholder-opacity":[{"placeholder-opacity":[b]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[s]}],"text-opacity":[{"text-opacity":[b]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ae(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",js,Hs]}],"underline-offset":[{"underline-offset":["auto",js,oe]}],"text-decoration-color":[{decoration:[s]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:O()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",oe]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",oe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[b]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...U(),Ib]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",Rb]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},Bb]}],"bg-color":[{bg:[s]}],"gradient-from-pos":[{from:[m]}],"gradient-via-pos":[{via:[m]}],"gradient-to-pos":[{to:[m]}],"gradient-from":[{from:[p]}],"gradient-via":[{via:[p]}],"gradient-to":[{to:[p]}],rounded:[{rounded:[r]}],"rounded-s":[{"rounded-s":[r]}],"rounded-e":[{"rounded-e":[r]}],"rounded-t":[{"rounded-t":[r]}],"rounded-r":[{"rounded-r":[r]}],"rounded-b":[{"rounded-b":[r]}],"rounded-l":[{"rounded-l":[r]}],"rounded-ss":[{"rounded-ss":[r]}],"rounded-se":[{"rounded-se":[r]}],"rounded-ee":[{"rounded-ee":[r]}],"rounded-es":[{"rounded-es":[r]}],"rounded-tl":[{"rounded-tl":[r]}],"rounded-tr":[{"rounded-tr":[r]}],"rounded-br":[{"rounded-br":[r]}],"rounded-bl":[{"rounded-bl":[r]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[b]}],"border-style":[{border:[...ae(),"hidden"]}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[b]}],"divide-style":[{divide:ae()}],"border-color":[{border:[n]}],"border-color-x":[{"border-x":[n]}],"border-color-y":[{"border-y":[n]}],"border-color-s":[{"border-s":[n]}],"border-color-e":[{"border-e":[n]}],"border-color-t":[{"border-t":[n]}],"border-color-r":[{"border-r":[n]}],"border-color-b":[{"border-b":[n]}],"border-color-l":[{"border-l":[n]}],"divide-color":[{divide:[n]}],"outline-style":[{outline:["",...ae()]}],"outline-offset":[{"outline-offset":[js,oe]}],"outline-w":[{outline:[js,Hs]}],"outline-color":[{outline:[s]}],"ring-w":[{ring:Q()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[s]}],"ring-opacity":[{"ring-opacity":[b]}],"ring-offset-w":[{"ring-offset":[js,Hs]}],"ring-offset-color":[{"ring-offset":[s]}],shadow:[{shadow:["","inner","none",qs,zb]}],"shadow-color":[{shadow:[Gn]}],opacity:[{opacity:[b]}],"mix-blend":[{"mix-blend":[...fe(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":fe()}],filter:[{filter:["","none"]}],blur:[{blur:[t]}],brightness:[{brightness:[i]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",qs,oe]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[d]}],invert:[{invert:[u]}],saturate:[{saturate:[N]}],sepia:[{sepia:[w]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[t]}],"backdrop-brightness":[{"backdrop-brightness":[i]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[d]}],"backdrop-invert":[{"backdrop-invert":[u]}],"backdrop-opacity":[{"backdrop-opacity":[b]}],"backdrop-saturate":[{"backdrop-saturate":[N]}],"backdrop-sepia":[{"backdrop-sepia":[w]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",oe]}],duration:[{duration:me()}],ease:[{ease:["linear","in","out","in-out",oe]}],delay:[{delay:me()}],animate:[{animate:["none","spin","ping","pulse","bounce",oe]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[y]}],"scale-x":[{"scale-x":[y]}],"scale-y":[{"scale-y":[y]}],rotate:[{rotate:[Qn,oe]}],"translate-x":[{"translate-x":[P]}],"translate-y":[{"translate-y":[P]}],"skew-x":[{"skew-x":[k]}],"skew-y":[{"skew-y":[k]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",oe]}],accent:[{accent:["auto",s]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",oe]}],"caret-color":[{caret:[s]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":O()}],"scroll-mx":[{"scroll-mx":O()}],"scroll-my":[{"scroll-my":O()}],"scroll-ms":[{"scroll-ms":O()}],"scroll-me":[{"scroll-me":O()}],"scroll-mt":[{"scroll-mt":O()}],"scroll-mr":[{"scroll-mr":O()}],"scroll-mb":[{"scroll-mb":O()}],"scroll-ml":[{"scroll-ml":O()}],"scroll-p":[{"scroll-p":O()}],"scroll-px":[{"scroll-px":O()}],"scroll-py":[{"scroll-py":O()}],"scroll-ps":[{"scroll-ps":O()}],"scroll-pe":[{"scroll-pe":O()}],"scroll-pt":[{"scroll-pt":O()}],"scroll-pr":[{"scroll-pr":O()}],"scroll-pb":[{"scroll-pb":O()}],"scroll-pl":[{"scroll-pl":O()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",oe]}],fill:[{fill:[s,"none"]}],"stroke-w":[{stroke:[js,Hs,Xa]}],stroke:[{stroke:[s,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},qb=Cb(Hb);function V(...s){return qb(db(s))}function Vb(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:s<1024*1024*1024?`${(s/1024/1024).toFixed(1)} MB`:`${(s/1024/1024/1024).toFixed(2)} GB`}function Go(s){if(!s)return"";const e=new Date(s),t=new Date;return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()?e.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):e.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}const Kb=Dx,_b=Rx,Ub=Ix,Op=C.forwardRef(({className:s,sideOffset:e=4,...t},i)=>h.jsx(Kf,{ref:i,sideOffset:e,className:V("z-50 overflow-hidden rounded-md bg-popover px-2 py-1 text-xs text-popover-foreground shadow-card","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...t}));Op.displayName=Kf.displayName;/**
|
|
4
4
|
* @license lucide-react v0.468.0 - ISC
|
|
@@ -315,7 +315,7 @@ var sd=s=>{throw TypeError(s)};var Ja=(s,e,t)=>e.has(s)||sd("Cannot "+t);var v=(
|
|
|
315
315
|
*
|
|
316
316
|
* This source code is licensed under the ISC license.
|
|
317
317
|
* See the LICENSE file in the root directory of this source tree.
|
|
318
|
-
*/const _i=G("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),w1="inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",k1={default:"bg-primary text-primary-foreground shadow-card hover:bg-primary/90 active:scale-[0.98]",secondary:"bg-secondary text-secondary-foreground hover:bg-accent active:scale-[0.98]",outline:"border border-border bg-card hover:bg-accent text-foreground active:scale-[0.98]",ghost:"hover:bg-accent hover:text-accent-foreground",destructive:"bg-destructive text-destructive-foreground shadow-card hover:bg-destructive/90 active:scale-[0.98]"},S1={default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",icon:"h-9 w-9"},J=C.forwardRef(({className:s,variant:e="default",size:t="default",asChild:i=!1,...n},r)=>{const o=i?Lx:"button";return h.jsx(o,{className:V(w1,k1[e],S1[t],s),ref:r,...n})});J.displayName="Button";const Zt=C.forwardRef(({className:s,orientation:e="horizontal",decorative:t=!0,...i},n)=>h.jsx(_f,{ref:n,decorative:t,orientation:e,className:V("shrink-0 bg-border",e==="horizontal"?"h-px w-full":"h-full w-px",s),...i}));Zt.displayName=_f.displayName;function C1(){const{id:s}=tp(),{user:e,logout:t}=Ea(),{theme:i,toggle:n}=Vr(),r=Oa(),[o,a]=C.useState(!1),{data:l}=Ie({queryKey:["agents"],queryFn:ee.listAgents,refetchInterval:3e4});C.useEffect(()=>{a(!1)},[s]);const c=async()=>{await t(),r("/login")},d=h.jsxs("aside",{className:V("flex h-full w-64 max-w-[85vw] flex-col border-r border-border bg-card","shrink-0"),children:[h.jsxs("div",{className:"flex items-center justify-between gap-2 px-4 py-3",children:[h.jsxs(Rt,{to:"/",className:"flex items-center gap-2",children:[h.jsx("div",{className:"grid size-8 place-items-center rounded-md bg-primary text-primary-foreground",children:h.jsx(ws,{className:"size-4"})}),h.jsxs("div",{className:"leading-tight",children:[h.jsx("div",{className:"text-sm font-semibold",children:"CogniSphere"}),h.jsx("div",{className:"text-[10px] text-muted-foreground",children:"v0"})]})]}),h.jsx("button",{"aria-label":"close menu",onClick:()=>a(!1),className:"md:hidden",children:h.jsx(_i,{className:"size-4"})})]}),h.jsx(Zt,{}),h.jsxs("div",{className:"flex-1 overflow-y-auto px-2 py-3",children:[h.jsx("div",{className:"px-2 pb-2 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Agents"}),h.jsxs("ul",{className:"flex flex-col gap-1",children:[(l==null?void 0:l.agents.length)===0&&h.jsxs("li",{className:"px-3 py-2 text-xs text-muted-foreground",children:["No agents loaded. Create one under"," ",h.jsx("code",{className:"rounded bg-muted px-1",children:"~/.cognisphere/default/agents/"})," ","and restart the server."]}),l==null?void 0:l.agents.map(u=>h.jsx("li",{children:h.jsxs(id,{to:`/agents/${u.id}`,end:!1,className:({isActive:f})=>V("group flex items-center gap-2 rounded-md px-3 py-2 text-sm transition-colors",f?"bg-primary/10 text-primary font-medium":"text-foreground/80 hover:bg-accent hover:text-foreground"),children:[h.jsx(ws,{className:"size-4 opacity-70"}),h.jsx("span",{className:"truncate",children:u.name}),h.jsx(On,{className:"ml-auto size-4 opacity-0 group-hover:opacity-50 transition-opacity"})]})},u.id))]})]}),h.jsx(Zt,{}),h.jsxs("div",{className:"flex flex-col gap-1 p-2",children:[h.jsxs(id,{to:"/settings",className:({isActive:u})=>V("flex items-center gap-2 rounded-md px-3 py-2 text-sm transition-colors",u?"bg-primary/10 text-primary font-medium":"text-foreground/80 hover:bg-accent"),children:[h.jsx(Qp,{className:"size-4"}),"Settings"]}),h.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-2 rounded-md px-3 py-2 text-sm text-foreground/80 transition-colors hover:bg-accent","aria-label":`switch to ${i==="dark"?"light":"dark"} mode`,children:[i==="dark"?h.jsx(Jp,{className:"size-4"}):h.jsx(_p,{className:"size-4"}),i==="dark"?"Light mode":"Dark mode"]}),h.jsxs(J,{variant:"ghost",className:"justify-start",onClick:c,children:[h.jsx(oh,{className:"size-4"}),"Sign Out"]}),h.jsx(Zt,{className:"my-1"}),h.jsxs("div",{className:"flex items-center gap-2.5 rounded-md px-3 py-2",children:[h.jsx("div",{className:"grid size-9 shrink-0 place-items-center rounded-full bg-emerald-500 text-xs font-semibold text-white",children:j1(e)}),h.jsxs("div",{className:"min-w-0 leading-tight",children:[h.jsx("div",{className:"truncate text-sm font-medium",children:e??"—"}),h.jsx("div",{className:"truncate text-xs text-muted-foreground",children:"Signed in"})]})]})]})]});return h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"hidden md:flex",children:d}),h.jsxs("div",{className:"md:hidden",children:[h.jsx("button",{"aria-label":"open menu",className:"fixed left-3 top-3 z-30 grid size-9 place-items-center rounded-md border bg-card shadow-card",onClick:()=>a(!0),children:h.jsx(c1,{className:"size-4"})}),o&&h.jsxs("div",{className:"fixed inset-0 z-40 flex animate-in fade-in duration-200",children:[h.jsx("div",{className:"h-full animate-in slide-in-from-left-full duration-200",children:d}),h.jsx("div",{className:"flex-1 bg-background/70 backdrop-blur-sm",onClick:()=>a(!1)})]})]})]})}function j1(s){if(!s)return"?";const e=s.trim().split(/[\s._-]+/).filter(Boolean);return e.length===0?"?":e.length===1?e[0].slice(0,2).toUpperCase():(e[0][0]+e[1][0]).toUpperCase()}function N1(){return h.jsxs("div",{className:"flex h-full w-full bg-background text-foreground",children:[h.jsx(C1,{}),h.jsx("main",{className:"flex min-w-0 flex-1 flex-col",children:h.jsx(sp,{})})]})}const it=C.forwardRef(({className:s,hoverable:e,...t},i)=>h.jsx("div",{ref:i,className:V("rounded-lg border bg-card text-card-foreground shadow-card transition-shadow",e&&"hover:shadow-card-hover hover:-translate-y-px","transition-all duration-150",s),...t}));it.displayName="Card";const ut=C.forwardRef(({className:s,...e},t)=>h.jsx("div",{ref:t,className:V("flex flex-col gap-1 p-4",s),...e}));ut.displayName="CardHeader";const nt=C.forwardRef(({className:s,...e},t)=>h.jsx("h3",{ref:t,className:V("text-base font-semibold leading-none tracking-tight",s),...e}));nt.displayName="CardTitle";const ft=C.forwardRef(({className:s,...e},t)=>h.jsx("p",{ref:t,className:V("text-xs text-muted-foreground",s),...e}));ft.displayName="CardDescription";const Pn=C.forwardRef(({className:s,...e},t)=>h.jsx("div",{ref:t,className:V("p-4 pt-0",s),...e}));Pn.displayName="CardContent";const at=C.forwardRef(({className:s,type:e,...t},i)=>h.jsx("input",{type:e,ref:i,className:V("flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm shadow-sm transition-colors","file:border-0 file:bg-transparent file:text-sm file:font-medium","placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background","disabled:cursor-not-allowed disabled:opacity-50",s),...t}));at.displayName="Input";const It=C.forwardRef(({className:s,...e},t)=>h.jsx(Uf,{ref:t,className:V("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",s),...e}));It.displayName=Uf.displayName;function M1(){const{theme:s,toggle:e}=Vr();return h.jsx(J,{variant:"ghost",size:"icon",onClick:e,"aria-label":`switch to ${s==="dark"?"light":"dark"} mode`,children:h.jsx("div",{className:"flex animate-in fade-in spin-in-45 duration-200",children:s==="dark"?h.jsx(Jp,{className:"size-4"}):h.jsx(_p,{className:"size-4"})},s)})}function A1(){var m,g;const{login:s,status:e}=Ea(),t=Oa(),i=Pa(),[n,r]=C.useState(""),[o,a]=C.useState(""),[l,c]=C.useState(!1),[d,u]=C.useState(null),f=((g=(m=i.state)==null?void 0:m.from)==null?void 0:g.pathname)??"/";if(e==="authed")return h.jsx(on,{to:f,replace:!0});const p=async x=>{x.preventDefault(),c(!0),u(null);try{await s(n,o),t(f,{replace:!0})}catch(b){u(b.message)}finally{c(!1)}};return h.jsxs("div",{className:"relative flex min-h-full min-h-dvh w-full items-center justify-center bg-background p-4",children:[h.jsx("div",{className:"absolute right-3 top-3 z-10",children:h.jsx(M1,{})}),h.jsx("div",{className:"w-full max-w-sm animate-in fade-in slide-in-from-bottom-2 duration-200",children:h.jsxs(it,{className:"overflow-hidden",children:[h.jsxs(ut,{className:"items-center text-center",children:[h.jsx("div",{className:"mb-2 grid size-10 place-items-center rounded-md bg-primary text-primary-foreground",children:h.jsx(ws,{className:"size-5"})}),h.jsx(nt,{children:"CogniSphere"}),h.jsx(ft,{children:"Sign in to manage your agents"})]}),h.jsx(Pn,{children:h.jsxs("form",{onSubmit:p,className:"flex flex-col gap-3",children:[h.jsxs("div",{className:"flex flex-col gap-1.5",children:[h.jsx(It,{htmlFor:"u",children:"Username"}),h.jsx(at,{id:"u",value:n,onChange:x=>r(x.target.value),autoFocus:!0,autoComplete:"username",required:!0})]}),h.jsxs("div",{className:"flex flex-col gap-1.5",children:[h.jsx(It,{htmlFor:"p",children:"Password"}),h.jsx(at,{id:"p",type:"password",value:o,onChange:x=>a(x.target.value),autoComplete:"current-password",required:!0})]}),d&&h.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive",children:d}),h.jsxs(J,{type:"submit",disabled:l,children:[l&&h.jsx($e,{className:"size-4 animate-spin"}),"Sign in"]}),h.jsxs("p",{className:"text-center text-[11px] text-muted-foreground",children:["Default: ",h.jsx("code",{children:"admin"})," / ",h.jsx("code",{children:"changeme"}),". Edit"," ",h.jsx("code",{children:"~/.cognisphere/default/.secrets/users.json"})," to change."]})]})})]})})]})}const T1={default:"border-transparent bg-primary/10 text-primary",secondary:"border-transparent bg-secondary text-secondary-foreground",outline:"text-foreground",success:"border-transparent bg-success/15 text-success",warning:"border-transparent bg-warning/15 text-warning",destructive:"border-transparent bg-destructive/15 text-destructive"};function rt({className:s,variant:e="default",...t}){return h.jsx("div",{className:V("inline-flex items-center rounded-md border px-2 py-0.5 text-xs font-medium transition-colors",T1[e],s),...t})}const O1={running:"bg-emerald-500",stopped:"bg-muted-foreground/40",failed:"bg-destructive"};function P1({state:s,className:e}){return h.jsx("span",{title:s,"aria-label":`status: ${s}`,className:V("inline-block size-2 shrink-0 rounded-full",O1[s],e)})}const E1={running:"success",stopped:"secondary",failed:"destructive"};function Xp({state:s}){return h.jsx(rt,{variant:E1[s],children:s})}function D1({agentId:s,state:e}){const t=Xe(),i=()=>{t.invalidateQueries({queryKey:["agents"]}),t.invalidateQueries({queryKey:["agent",s]}),t.invalidateQueries({queryKey:["plugins",s]})},n=we({mutationFn:()=>ee.startAgent(s),onSuccess:l=>{l.error?q.warning(`started with errors: ${l.error}`):q.success("agent started")},onError:l=>q.error(`start failed: ${l.message}`),onSettled:i}),r=we({mutationFn:()=>ee.stopAgent(s),onSuccess:()=>q.success("agent stopped"),onError:l=>q.error(`stop failed: ${l.message}`),onSettled:i}),o=we({mutationFn:()=>ee.restartAgent(s),onSuccess:l=>{l.error?q.warning(`restarted with errors: ${l.error}`):q.success("agent restarted")},onError:l=>q.error(`restart failed: ${l.message}`),onSettled:i}),a=n.isPending||r.isPending||o.isPending;return h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsxs(J,{size:"sm",variant:"outline",disabled:e==="running"||a,onClick:()=>n.mutate(),children:[n.isPending?h.jsx($e,{className:"animate-spin"}):h.jsx(p1,{}),"Start"]}),h.jsxs(J,{size:"sm",variant:"outline",disabled:e!=="running"||a,onClick:()=>r.mutate(),children:[r.isPending?h.jsx($e,{className:"animate-spin"}):h.jsx(Yp,{}),"Stop"]}),h.jsxs(J,{size:"sm",variant:"outline",disabled:a,onClick:()=>o.mutate(),children:[o.isPending?h.jsx($e,{className:"animate-spin"}):h.jsx(m1,{}),"Restart"]})]})}function R1(){const{data:s,isLoading:e}=Ie({queryKey:["agents"],queryFn:ee.listAgents,refetchInterval:5e3});return h.jsxs("div",{className:"flex h-full flex-col",children:[h.jsxs("header",{className:"border-b py-3 pl-14 pr-4 md:px-6",children:[h.jsx("h1",{className:"text-lg font-semibold",children:"Agents"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Pick an agent to manage files, chat, or inspect the queue."})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto p-4 sm:p-6",children:[e&&h.jsx("div",{className:"text-sm text-muted-foreground",children:"loading…"}),!e&&((s==null?void 0:s.agents.length)??0)===0&&h.jsx(I1,{}),h.jsx("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-3",children:s==null?void 0:s.agents.map((t,i)=>h.jsx(Rt,{to:`/agents/${t.id}`,className:"block animate-in fade-in slide-in-from-bottom-1.5 fill-mode-backwards duration-200",style:{animationDelay:`${i*40}ms`},children:h.jsx(it,{hoverable:!0,className:V("group relative overflow-hidden",t.state==="stopped"&&"opacity-70"),children:h.jsxs(ut,{children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("div",{className:"grid size-8 place-items-center rounded-md bg-primary/10 text-primary",children:h.jsx(ws,{className:"size-4"})}),h.jsx(nt,{className:"truncate",children:t.name}),h.jsx(P1,{state:t.state}),h.jsx(On,{className:"ml-auto size-4 text-muted-foreground transition-transform group-hover:translate-x-0.5"})]}),h.jsx(ft,{className:"font-mono",children:t.id}),t.installedPlugins.length>0&&h.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:t.installedPlugins.map(n=>{const r=t.failedPlugins.includes(n)?"destructive":t.runningPlugins.includes(n)?"secondary":"outline";return h.jsx(rt,{variant:r,children:n},n)})}),t.state==="failed"&&t.error&&h.jsx("p",{className:"mt-2 truncate text-xs text-destructive",children:t.error})]})})},t.id))})]})]})}function I1(){return h.jsxs(it,{className:"p-6 text-center",children:[h.jsx(Jo,{className:"mx-auto mb-2 size-6 text-primary"}),h.jsx(nt,{children:"No agents yet"}),h.jsxs(ft,{className:"mt-2",children:["Agents are created manually on disk in v0. See"," ",h.jsx("code",{children:"docs/v0-deferred.md"})," for the recipe."]})]})}const L1="modulepreload",B1=function(s){return"/"+s},kd={},z1=function(e,t,i){let n=Promise.resolve();if(t&&t.length>0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),a=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));n=Promise.allSettled(t.map(l=>{if(l=B1(l),l in kd)return;kd[l]=!0;const c=l.endsWith(".css"),d=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${d}`))return;const u=document.createElement("link");if(u.rel=c?"stylesheet":L1,c||(u.as="script"),u.crossOrigin="",u.href=l,a&&u.setAttribute("nonce",a),document.head.appendChild(u),c)return new Promise((f,p)=>{u.addEventListener("load",f),u.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${l}`)))})}))}function r(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return n.then(o=>{for(const a of o||[])a.status==="rejected"&&r(a.reason);return e().catch(r)})},Xo=Fx,F1=Bx,Zp=C.forwardRef(({className:s,...e},t)=>h.jsx(Qf,{ref:t,className:V("fixed inset-0 z-50 bg-background/70 backdrop-blur-sm","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...e}));Zp.displayName=Qf.displayName;const br=C.forwardRef(({className:s,children:e,...t},i)=>h.jsxs(F1,{children:[h.jsx(Zp,{}),h.jsxs(Gf,{ref:i,className:V("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 border bg-card p-6 shadow-card-hover sm:rounded-lg","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",s),...t,children:[e,h.jsxs(zx,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring",children:[h.jsx(_i,{className:"h-4 w-4"}),h.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));br.displayName=Gf.displayName;const Zo=({className:s,...e})=>h.jsx("div",{className:V("flex flex-col gap-1.5 text-left",s),...e}),vr=C.forwardRef(({className:s,...e},t)=>h.jsx(Yf,{ref:t,className:V("text-lg font-semibold",s),...e}));vr.displayName=Yf.displayName;const wr=C.forwardRef(({className:s,...e},t)=>h.jsx(Jf,{ref:t,className:V("text-sm text-muted-foreground",s),...e}));wr.displayName=Jf.displayName;const Kr=Wx,_r=Hx,Hn=C.forwardRef(({className:s,sideOffset:e=6,...t},i)=>h.jsx($x,{children:h.jsx(Xf,{ref:i,sideOffset:e,className:V("z-50 min-w-[10rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-card-hover","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...t})}));Hn.displayName=Xf.displayName;const oi=C.forwardRef(({className:s,...e},t)=>h.jsx(Zf,{ref:t,className:V("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors","focus:bg-accent focus:text-accent-foreground","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...e}));oi.displayName=Zf.displayName;const em=C.forwardRef(({className:s,...e},t)=>h.jsx(ep,{ref:t,className:V("-mx-1 my-1 h-px bg-border",s),...e}));em.displayName=ep.displayName;function $1(s){const{data:e}=Ie({queryKey:["agent",s.agentId],queryFn:()=>ee.getAgent(s.agentId),enabled:!!s.agentId});return h.jsxs("div",{className:"flex h-full flex-col text-sm",children:[h.jsx("div",{className:"px-3 py-2 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Files"}),h.jsx("div",{className:"flex-1 overflow-y-auto px-1 pb-2",children:h.jsx(tm,{...s,path:"",name:(e==null?void 0:e.name)??s.agentId,depth:0,defaultOpen:!0,isRoot:!0})})]})}function tm({agentId:s,path:e,name:t,depth:i,defaultOpen:n,selectedPath:r,onSelectFile:o,onPathDeleted:a,isRoot:l}){const c=Xe(),[d,u]=C.useState(!!n),[f,p]=C.useState(null),[m,g]=C.useState(!1),{data:x,isLoading:b}=Ie({queryKey:["tree",s,e],queryFn:()=>ee.listTree(s,e),enabled:d}),S=new Set((x==null?void 0:x.entries.map(k=>k.name))??[]),N=we({mutationFn:async k=>{const M=f,P=e?`${e}/${k}`:k;return M==="folder"?await ee.mkdir(s,P):await ee.writeFile(s,P,""),{child:P,kind:M}},onSuccess:({child:k,kind:M})=>{p(null),q.success(M==="folder"?"folder created":"file created"),c.invalidateQueries({queryKey:["tree",s,e]}),M==="file"&&o(k)},onError:k=>q.error(`create failed: ${k.message}`)}),y=we({mutationFn:()=>ee.deletePath(s,e),onSuccess:()=>{g(!1),q.success("deleted"),c.invalidateQueries({queryKey:["tree",s,sm(e)]}),a==null||a(e)},onError:k=>q.error(`delete failed: ${k.message}`)}),w=k=>{u(!0),p(k)};return h.jsxs("div",{children:[h.jsxs("div",{className:"group relative flex items-center",style:{paddingLeft:8+i*12},children:[h.jsxs("button",{type:"button",onClick:()=>u(k=>!k),className:V("flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-2 py-1 text-left transition-colors","hover:bg-accent"),children:[h.jsx("span",{className:V("inline-flex transition-transform duration-150",d&&"rotate-90"),children:h.jsx(On,{className:"size-3.5 text-muted-foreground"})}),d?h.jsx(a1,{className:"size-4 text-primary/80"}):h.jsx(qp,{className:"size-4 text-primary/80"}),h.jsx("span",{className:"truncate",children:t})]}),h.jsxs(Kr,{children:[h.jsx(_r,{asChild:!0,children:h.jsx("button",{type:"button","aria-label":"folder actions",className:V("mr-1 rounded p-1 opacity-0 transition-opacity hover:bg-accent","group-hover:opacity-100 focus:opacity-100 data-[state=open]:opacity-100"),children:h.jsx(Lp,{className:"size-3.5 text-muted-foreground"})})}),h.jsxs(Hn,{align:"end",children:[h.jsxs(oi,{onSelect:()=>w("file"),children:[h.jsx(o1,{className:"size-4"}),"New file"]}),h.jsxs(oi,{onSelect:()=>w("folder"),children:[h.jsx(l1,{className:"size-4"}),"New folder"]}),!l&&h.jsxs(h.Fragment,{children:[h.jsx(em,{}),h.jsxs(oi,{onSelect:()=>g(!0),className:"text-destructive focus:text-destructive",children:[h.jsx(Wn,{className:"size-4"}),"Delete"]})]})]})]})]}),d&&h.jsxs("div",{children:[f&&h.jsx(q1,{depth:i+1,kind:f,taken:S,pending:N.isPending,onSubmit:k=>N.mutate(k),onCancel:()=>p(null)}),b&&h.jsx("div",{className:"px-2 py-1 text-xs text-muted-foreground",style:{paddingLeft:28+i*12},children:"loading…"}),x==null?void 0:x.entries.map(k=>h.jsx(W1,{entry:k,depth:i+1,agentId:s,selectedPath:r,onSelectFile:o,onPathDeleted:a},k.path)),x&&x.entries.length===0&&!f&&h.jsx("div",{className:"px-2 py-1 text-xs text-muted-foreground",style:{paddingLeft:28+i*12},children:"empty"})]}),h.jsx(Xo,{open:m,onOpenChange:g,children:h.jsxs(br,{children:[h.jsxs(Zo,{children:[h.jsx(vr,{children:"Delete folder?"}),h.jsxs(wr,{children:[h.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:e})," and everything inside will be permanently removed. This cannot be undone."]})]}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx(J,{variant:"outline",size:"sm",onClick:()=>g(!1),disabled:y.isPending,children:"Cancel"}),h.jsx(J,{variant:"destructive",size:"sm",onClick:()=>y.mutate(),disabled:y.isPending,children:"Delete"})]})]})})]})}function W1({entry:s,depth:e,agentId:t,selectedPath:i,onSelectFile:n,onPathDeleted:r}){return s.isDir?h.jsx(tm,{agentId:t,path:s.path,name:s.name,depth:e,selectedPath:i,onSelectFile:n,onPathDeleted:r}):h.jsx(H1,{entry:s,depth:e,agentId:t,selectedPath:i,onSelectFile:n,onPathDeleted:r})}function H1({entry:s,depth:e,agentId:t,selectedPath:i,onSelectFile:n,onPathDeleted:r}){const o=Xe(),[a,l]=C.useState(!1),c=i===s.path,d=we({mutationFn:()=>ee.deletePath(t,s.path),onSuccess:()=>{l(!1),q.success("deleted"),o.invalidateQueries({queryKey:["tree",t,sm(s.path)]}),r==null||r(s.path)},onError:u=>q.error(`delete failed: ${u.message}`)});return h.jsxs("div",{className:"group relative flex items-center",style:{paddingLeft:24+e*12},children:[h.jsxs("button",{type:"button",onClick:()=>n(s.path),className:V("flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-2 py-1 text-left transition-colors",c?"bg-primary/10 text-primary":"hover:bg-accent"),children:[h.jsx(Wp,{className:"size-4 text-muted-foreground"}),h.jsx("span",{className:"truncate",children:s.name}),h.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:Vb(s.size)})]}),h.jsxs(Kr,{children:[h.jsx(_r,{asChild:!0,children:h.jsx("button",{type:"button","aria-label":"file actions",className:V("mr-1 rounded p-1 opacity-0 transition-opacity hover:bg-accent","group-hover:opacity-100 focus:opacity-100 data-[state=open]:opacity-100"),children:h.jsx(Lp,{className:"size-3.5 text-muted-foreground"})})}),h.jsx(Hn,{align:"end",children:h.jsxs(oi,{onSelect:()=>l(!0),className:"text-destructive focus:text-destructive",children:[h.jsx(Wn,{className:"size-4"}),"Delete"]})})]}),h.jsx(Xo,{open:a,onOpenChange:l,children:h.jsxs(br,{children:[h.jsxs(Zo,{children:[h.jsx(vr,{children:"Delete file?"}),h.jsxs(wr,{children:[h.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:s.path})," ","will be permanently removed. This cannot be undone."]})]}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx(J,{variant:"outline",size:"sm",onClick:()=>l(!1),disabled:d.isPending,children:"Cancel"}),h.jsx(J,{variant:"destructive",size:"sm",onClick:()=>d.mutate(),disabled:d.isPending,children:"Delete"})]})]})})]})}function q1({depth:s,kind:e,taken:t,pending:i,onSubmit:n,onCancel:r}){const[o,a]=C.useState(""),l=o.trim(),c=l.length===0||l.includes("/")||l.startsWith(".")||t.has(l);return h.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",style:{paddingLeft:24+(s-1)*12},children:[e==="folder"?h.jsx(qp,{className:"size-4 text-primary/80"}):h.jsx(Wp,{className:"size-4 text-muted-foreground"}),h.jsx("input",{autoFocus:!0,type:"text",value:o,disabled:i,onChange:d=>a(d.target.value),onKeyDown:d=>{d.key==="Enter"&&!c?n(l):d.key==="Escape"&&r()},onBlur:()=>{i||r()},placeholder:e==="folder"?"folder name":"file name",className:V("h-6 min-w-0 flex-1 rounded border bg-background px-1.5 text-xs outline-none focus:border-primary",c&&o!==""&&"border-destructive")})]})}function sm(s){const e=s.lastIndexOf("/");return e===-1?"":s.slice(0,e)}function sc(){return sc=Object.assign?Object.assign.bind():function(s){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(s[i]=t[i])}return s},sc.apply(null,arguments)}function V1(s,e){if(s==null)return{};var t={};for(var i in s)if({}.hasOwnProperty.call(s,i)){if(e.indexOf(i)!==-1)continue;t[i]=s[i]}return t}let ic=[],im=[];(()=>{let s="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<s.length;e++)(e%2?im:ic).push(t=t+s[e])})();function K1(s){if(s<768)return!1;for(let e=0,t=ic.length;;){let i=e+t>>1;if(s<ic[i])t=i;else if(s>=im[i])e=i+1;else return!0;if(e==t)return!1}}function Sd(s){return s>=127462&&s<=127487}const Cd=8205;function _1(s,e,t=!0,i=!0){return(t?nm:U1)(s,e,i)}function nm(s,e,t){if(e==s.length)return e;e&&rm(s.charCodeAt(e))&&om(s.charCodeAt(e-1))&&e--;let i=Za(s,e);for(e+=jd(i);e<s.length;){let n=Za(s,e);if(i==Cd||n==Cd||t&&K1(n))e+=jd(n),i=n;else if(Sd(n)){let r=0,o=e-2;for(;o>=0&&Sd(Za(s,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function U1(s,e,t){for(;e>0;){let i=nm(s,e-2,t);if(i<e)return i;e--}return 0}function Za(s,e){let t=s.charCodeAt(e);if(!om(t)||e+1==s.length)return t;let i=s.charCodeAt(e+1);return rm(i)?(t-55296<<10)+(i-56320)+65536:t}function rm(s){return s>=56320&&s<57344}function om(s){return s>=55296&&s<56320}function jd(s){return s<65536?1:2}class ye{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=En(this,e,t);let n=[];return this.decompose(0,e,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(t,this.length,n,1),fs.from(n,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=En(this,e,t);let i=[];return this.decompose(e,t,i,0),fs.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),n=new ar(this),r=new ar(e);for(let o=t,a=t;;){if(n.next(o),r.next(o),o=0,n.lineBreak!=r.lineBreak||n.done!=r.done||n.value!=r.value)return!1;if(a+=n.value.length,n.done||a>=i)return!0}}iter(e=1){return new ar(this,e)}iterRange(e,t=this.length){return new am(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let n=this.line(e).from;i=this.iterRange(n,Math.max(n,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new lm(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?ye.empty:e.length<=32?new ze(e):fs.from(ze.split(e,[]))}}class ze extends ye{constructor(e,t=Q1(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,n){for(let r=0;;r++){let o=this.text[r],a=n+o.length;if((t?i:a)>=e)return new G1(n,a,i,o);n=a+1,i++}}decompose(e,t,i,n){let r=e<=0&&t>=this.length?this:new ze(Nd(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(n&1){let o=i.pop(),a=Lo(r.text,o.text.slice(),0,r.length);if(a.length<=32)i.push(new ze(a,o.length+r.length));else{let l=a.length>>1;i.push(new ze(a.slice(0,l)),new ze(a.slice(l)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof ze))return super.replace(e,t,i);[e,t]=En(this,e,t);let n=Lo(this.text,Lo(i.text,Nd(this.text,0,e)),t),r=this.length+i.length-(t-e);return n.length<=32?new ze(n,r):fs.from(ze.split(n,[]),r)}sliceString(e,t=this.length,i=`
|
|
318
|
+
*/const _i=G("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),w1="inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",k1={default:"bg-primary text-primary-foreground shadow-card hover:bg-primary/90 active:scale-[0.98]",secondary:"bg-secondary text-secondary-foreground hover:bg-accent active:scale-[0.98]",outline:"border border-border bg-card hover:bg-accent text-foreground active:scale-[0.98]",ghost:"hover:bg-accent hover:text-accent-foreground",destructive:"bg-destructive text-destructive-foreground shadow-card hover:bg-destructive/90 active:scale-[0.98]"},S1={default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",icon:"h-9 w-9"},J=C.forwardRef(({className:s,variant:e="default",size:t="default",asChild:i=!1,...n},r)=>{const o=i?Lx:"button";return h.jsx(o,{className:V(w1,k1[e],S1[t],s),ref:r,...n})});J.displayName="Button";const Zt=C.forwardRef(({className:s,orientation:e="horizontal",decorative:t=!0,...i},n)=>h.jsx(_f,{ref:n,decorative:t,orientation:e,className:V("shrink-0 bg-border",e==="horizontal"?"h-px w-full":"h-full w-px",s),...i}));Zt.displayName=_f.displayName;function C1(){const{id:s}=tp(),{user:e,logout:t}=Ea(),{theme:i,toggle:n}=Vr(),r=Oa(),[o,a]=C.useState(!1),{data:l}=Ie({queryKey:["agents"],queryFn:ee.listAgents,refetchInterval:3e4});C.useEffect(()=>{a(!1)},[s]);const c=async()=>{await t(),r("/login")},d=h.jsxs("aside",{className:V("flex h-full w-64 max-w-[85vw] flex-col border-r border-border bg-card","shrink-0"),children:[h.jsxs("div",{className:"flex items-center justify-between gap-2 px-4 py-3",children:[h.jsxs(Rt,{to:"/",className:"flex items-center gap-2",children:[h.jsx("div",{className:"grid size-8 place-items-center rounded-md bg-primary text-primary-foreground",children:h.jsx(ws,{className:"size-4"})}),h.jsxs("div",{className:"leading-tight",children:[h.jsx("div",{className:"text-sm font-semibold",children:"CogniSphere"}),h.jsx("div",{className:"text-[10px] text-muted-foreground",children:"v0"})]})]}),h.jsx("button",{"aria-label":"close menu",onClick:()=>a(!1),className:"md:hidden",children:h.jsx(_i,{className:"size-4"})})]}),h.jsx(Zt,{}),h.jsxs("div",{className:"flex-1 overflow-y-auto px-2 py-3",children:[h.jsx("div",{className:"px-2 pb-2 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Agents"}),h.jsxs("ul",{className:"flex flex-col gap-1",children:[(l==null?void 0:l.agents.length)===0&&h.jsxs("li",{className:"px-3 py-2 text-xs text-muted-foreground",children:["No agents loaded. Create one under"," ",h.jsx("code",{className:"rounded bg-muted px-1",children:"~/.cognisphere/default/agents/"})," ","and restart the server."]}),l==null?void 0:l.agents.map(u=>h.jsx("li",{children:h.jsxs(id,{to:`/agents/${u.id}`,end:!1,className:({isActive:f})=>V("group flex items-center gap-2 rounded-md px-3 py-2 text-sm transition-colors",f?"bg-primary/10 text-primary font-medium":"text-foreground/80 hover:bg-accent hover:text-foreground"),children:[h.jsx(ws,{className:"size-4 opacity-70"}),h.jsx("span",{className:"truncate",children:u.name}),h.jsx(On,{className:"ml-auto size-4 opacity-0 group-hover:opacity-50 transition-opacity"})]})},u.id))]})]}),h.jsx(Zt,{}),h.jsxs("div",{className:"flex flex-col gap-1 p-2",children:[h.jsxs(id,{to:"/settings",className:({isActive:u})=>V("flex items-center gap-2 rounded-md px-3 py-2 text-sm transition-colors",u?"bg-primary/10 text-primary font-medium":"text-foreground/80 hover:bg-accent"),children:[h.jsx(Qp,{className:"size-4"}),"Settings"]}),h.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-2 rounded-md px-3 py-2 text-sm text-foreground/80 transition-colors hover:bg-accent","aria-label":`switch to ${i==="dark"?"light":"dark"} mode`,children:[i==="dark"?h.jsx(Jp,{className:"size-4"}):h.jsx(_p,{className:"size-4"}),i==="dark"?"Light mode":"Dark mode"]}),h.jsxs(J,{variant:"ghost",className:"justify-start",onClick:c,children:[h.jsx(oh,{className:"size-4"}),"Sign Out"]}),h.jsx(Zt,{className:"my-1"}),h.jsxs("div",{className:"flex items-center gap-2.5 rounded-md px-3 py-2",children:[h.jsx("div",{className:"grid size-9 shrink-0 place-items-center rounded-full bg-emerald-500 text-xs font-semibold text-white",children:j1(e)}),h.jsxs("div",{className:"min-w-0 leading-tight",children:[h.jsx("div",{className:"truncate text-sm font-medium",children:e??"—"}),h.jsx("div",{className:"truncate text-xs text-muted-foreground",children:"Signed in"})]})]})]})]});return h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"hidden md:flex",children:d}),h.jsxs("div",{className:"md:hidden",children:[h.jsx("button",{"aria-label":"open menu",className:"fixed left-3 top-3 z-30 grid size-9 place-items-center rounded-md border bg-card shadow-card",onClick:()=>a(!0),children:h.jsx(c1,{className:"size-4"})}),o&&h.jsxs("div",{className:"fixed inset-0 z-40 flex animate-in fade-in duration-200",children:[h.jsx("div",{className:"h-full animate-in slide-in-from-left-full duration-200",children:d}),h.jsx("div",{className:"flex-1 bg-background/70 backdrop-blur-sm",onClick:()=>a(!1)})]})]})]})}function j1(s){if(!s)return"?";const e=s.trim().split(/[\s._-]+/).filter(Boolean);return e.length===0?"?":e.length===1?e[0].slice(0,2).toUpperCase():(e[0][0]+e[1][0]).toUpperCase()}function N1(){return h.jsxs("div",{className:"flex h-full w-full bg-background text-foreground",children:[h.jsx(C1,{}),h.jsx("main",{className:"flex min-w-0 flex-1 flex-col",children:h.jsx(sp,{})})]})}const it=C.forwardRef(({className:s,hoverable:e,...t},i)=>h.jsx("div",{ref:i,className:V("rounded-lg border bg-card text-card-foreground shadow-card transition-shadow",e&&"hover:shadow-card-hover hover:-translate-y-px","transition-all duration-150",s),...t}));it.displayName="Card";const ut=C.forwardRef(({className:s,...e},t)=>h.jsx("div",{ref:t,className:V("flex flex-col gap-1 p-4",s),...e}));ut.displayName="CardHeader";const nt=C.forwardRef(({className:s,...e},t)=>h.jsx("h3",{ref:t,className:V("text-base font-semibold leading-none tracking-tight",s),...e}));nt.displayName="CardTitle";const ft=C.forwardRef(({className:s,...e},t)=>h.jsx("p",{ref:t,className:V("text-xs text-muted-foreground",s),...e}));ft.displayName="CardDescription";const Pn=C.forwardRef(({className:s,...e},t)=>h.jsx("div",{ref:t,className:V("p-4 pt-0",s),...e}));Pn.displayName="CardContent";const at=C.forwardRef(({className:s,type:e,...t},i)=>h.jsx("input",{type:e,ref:i,className:V("flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm shadow-sm transition-colors","file:border-0 file:bg-transparent file:text-sm file:font-medium","placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background","disabled:cursor-not-allowed disabled:opacity-50",s),...t}));at.displayName="Input";const It=C.forwardRef(({className:s,...e},t)=>h.jsx(Uf,{ref:t,className:V("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",s),...e}));It.displayName=Uf.displayName;function M1(){const{theme:s,toggle:e}=Vr();return h.jsx(J,{variant:"ghost",size:"icon",onClick:e,"aria-label":`switch to ${s==="dark"?"light":"dark"} mode`,children:h.jsx("div",{className:"flex animate-in fade-in spin-in-45 duration-200",children:s==="dark"?h.jsx(Jp,{className:"size-4"}):h.jsx(_p,{className:"size-4"})},s)})}function A1(){var m,g;const{login:s,status:e}=Ea(),t=Oa(),i=Pa(),[n,r]=C.useState(""),[o,a]=C.useState(""),[l,c]=C.useState(!1),[d,u]=C.useState(null),f=((g=(m=i.state)==null?void 0:m.from)==null?void 0:g.pathname)??"/";if(e==="authed")return h.jsx(on,{to:f,replace:!0});const p=async x=>{x.preventDefault(),c(!0),u(null);try{await s(n,o),t(f,{replace:!0})}catch(b){u(b.message)}finally{c(!1)}};return h.jsxs("div",{className:"relative flex min-h-full min-h-dvh w-full items-center justify-center bg-background p-4",children:[h.jsx("div",{className:"absolute right-3 top-3 z-10",children:h.jsx(M1,{})}),h.jsx("div",{className:"w-full max-w-sm animate-in fade-in slide-in-from-bottom-2 duration-200",children:h.jsxs(it,{className:"overflow-hidden",children:[h.jsxs(ut,{className:"items-center text-center",children:[h.jsx("div",{className:"mb-2 grid size-10 place-items-center rounded-md bg-primary text-primary-foreground",children:h.jsx(ws,{className:"size-5"})}),h.jsx(nt,{children:"CogniSphere"}),h.jsx(ft,{children:"Sign in to manage your agents"})]}),h.jsx(Pn,{children:h.jsxs("form",{onSubmit:p,className:"flex flex-col gap-3",children:[h.jsxs("div",{className:"flex flex-col gap-1.5",children:[h.jsx(It,{htmlFor:"u",children:"Username"}),h.jsx(at,{id:"u",value:n,onChange:x=>r(x.target.value),autoFocus:!0,autoComplete:"username",required:!0})]}),h.jsxs("div",{className:"flex flex-col gap-1.5",children:[h.jsx(It,{htmlFor:"p",children:"Password"}),h.jsx(at,{id:"p",type:"password",value:o,onChange:x=>a(x.target.value),autoComplete:"current-password",required:!0})]}),d&&h.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive",children:d}),h.jsxs(J,{type:"submit",disabled:l,children:[l&&h.jsx($e,{className:"size-4 animate-spin"}),"Sign in"]}),h.jsxs("p",{className:"text-center text-[11px] text-muted-foreground",children:["Default: ",h.jsx("code",{children:"admin"})," / ",h.jsx("code",{children:"changeme"}),". Edit"," ",h.jsx("code",{children:"~/.cognisphere/default/.secrets/users.json"})," to change."]})]})})]})})]})}const T1={default:"border-transparent bg-primary/10 text-primary",secondary:"border-transparent bg-secondary text-secondary-foreground",outline:"text-foreground",success:"border-transparent bg-success/15 text-success",warning:"border-transparent bg-warning/15 text-warning",destructive:"border-transparent bg-destructive/15 text-destructive"};function rt({className:s,variant:e="default",...t}){return h.jsx("div",{className:V("inline-flex items-center rounded-md border px-2 py-0.5 text-xs font-medium transition-colors",T1[e],s),...t})}const O1={running:"bg-emerald-500",stopped:"bg-muted-foreground/40",failed:"bg-destructive"};function P1({state:s,className:e}){return h.jsx("span",{title:s,"aria-label":`status: ${s}`,className:V("inline-block size-2 shrink-0 rounded-full",O1[s],e)})}const E1={running:"success",stopped:"secondary",failed:"destructive"};function Xp({state:s}){return h.jsx(rt,{variant:E1[s],children:s})}function D1({agentId:s,state:e}){const t=Xe(),i=()=>{t.invalidateQueries({queryKey:["agents"]}),t.invalidateQueries({queryKey:["agent",s]}),t.invalidateQueries({queryKey:["plugins",s]})},n=we({mutationFn:()=>ee.startAgent(s),onSuccess:l=>{l.error?q.warning(`started with errors: ${l.error}`):q.success("agent started")},onError:l=>q.error(`start failed: ${l.message}`),onSettled:i}),r=we({mutationFn:()=>ee.stopAgent(s),onSuccess:()=>q.success("agent stopped"),onError:l=>q.error(`stop failed: ${l.message}`),onSettled:i}),o=we({mutationFn:()=>ee.restartAgent(s),onSuccess:l=>{l.error?q.warning(`restarted with errors: ${l.error}`):q.success("agent restarted")},onError:l=>q.error(`restart failed: ${l.message}`),onSettled:i}),a=n.isPending||r.isPending||o.isPending;return h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsxs(J,{size:"sm",variant:"outline",disabled:e==="running"||a,onClick:()=>n.mutate(),children:[n.isPending?h.jsx($e,{className:"animate-spin"}):h.jsx(p1,{}),"Start"]}),h.jsxs(J,{size:"sm",variant:"outline",disabled:e!=="running"||a,onClick:()=>r.mutate(),children:[r.isPending?h.jsx($e,{className:"animate-spin"}):h.jsx(Yp,{}),"Stop"]}),h.jsxs(J,{size:"sm",variant:"outline",disabled:a,onClick:()=>o.mutate(),children:[o.isPending?h.jsx($e,{className:"animate-spin"}):h.jsx(m1,{}),"Restart"]})]})}function R1(){const{data:s,isLoading:e}=Ie({queryKey:["agents"],queryFn:ee.listAgents,refetchInterval:5e3});return h.jsxs("div",{className:"flex h-full flex-col",children:[h.jsxs("header",{className:"border-b py-3 pl-14 pr-4 md:px-6",children:[h.jsx("h1",{className:"text-lg font-semibold",children:"Agents"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Pick an agent to manage files, chat, or inspect the queue."})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto p-4 sm:p-6",children:[e&&h.jsx("div",{className:"text-sm text-muted-foreground",children:"loading…"}),!e&&((s==null?void 0:s.agents.length)??0)===0&&h.jsx(I1,{}),h.jsx("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-3",children:s==null?void 0:s.agents.map((t,i)=>h.jsx(Rt,{to:`/agents/${t.id}`,className:"block animate-in fade-in slide-in-from-bottom-1.5 fill-mode-backwards duration-200",style:{animationDelay:`${i*40}ms`},children:h.jsx(it,{hoverable:!0,className:V("group relative overflow-hidden",t.state==="stopped"&&"opacity-70"),children:h.jsxs(ut,{children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("div",{className:"grid size-8 place-items-center rounded-md bg-primary/10 text-primary",children:h.jsx(ws,{className:"size-4"})}),h.jsx(nt,{className:"truncate",children:t.name}),h.jsx(P1,{state:t.state}),h.jsx(On,{className:"ml-auto size-4 text-muted-foreground transition-transform group-hover:translate-x-0.5"})]}),h.jsx(ft,{className:"font-mono",children:t.id}),t.installedPlugins.length>0&&h.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:t.installedPlugins.map(n=>{const r=t.failedPlugins.includes(n)?"destructive":t.runningPlugins.includes(n)?"secondary":"outline";return h.jsx(rt,{variant:r,children:n},n)})}),t.state==="failed"&&t.error&&h.jsx("p",{className:"mt-2 truncate text-xs text-destructive",children:t.error})]})})},t.id))})]})]})}function I1(){return h.jsxs(it,{className:"p-6 text-center",children:[h.jsx(Jo,{className:"mx-auto mb-2 size-6 text-primary"}),h.jsx(nt,{children:"No agents yet"}),h.jsxs(ft,{className:"mt-2",children:["Run ",h.jsx("code",{children:"cognisphere agent new <name>"})," in your harness directory, configure its model, then restart the server."]})]})}const L1="modulepreload",B1=function(s){return"/"+s},kd={},z1=function(e,t,i){let n=Promise.resolve();if(t&&t.length>0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),a=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));n=Promise.allSettled(t.map(l=>{if(l=B1(l),l in kd)return;kd[l]=!0;const c=l.endsWith(".css"),d=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${d}`))return;const u=document.createElement("link");if(u.rel=c?"stylesheet":L1,c||(u.as="script"),u.crossOrigin="",u.href=l,a&&u.setAttribute("nonce",a),document.head.appendChild(u),c)return new Promise((f,p)=>{u.addEventListener("load",f),u.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${l}`)))})}))}function r(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return n.then(o=>{for(const a of o||[])a.status==="rejected"&&r(a.reason);return e().catch(r)})},Xo=Fx,F1=Bx,Zp=C.forwardRef(({className:s,...e},t)=>h.jsx(Qf,{ref:t,className:V("fixed inset-0 z-50 bg-background/70 backdrop-blur-sm","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...e}));Zp.displayName=Qf.displayName;const br=C.forwardRef(({className:s,children:e,...t},i)=>h.jsxs(F1,{children:[h.jsx(Zp,{}),h.jsxs(Gf,{ref:i,className:V("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 border bg-card p-6 shadow-card-hover sm:rounded-lg","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",s),...t,children:[e,h.jsxs(zx,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring",children:[h.jsx(_i,{className:"h-4 w-4"}),h.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));br.displayName=Gf.displayName;const Zo=({className:s,...e})=>h.jsx("div",{className:V("flex flex-col gap-1.5 text-left",s),...e}),vr=C.forwardRef(({className:s,...e},t)=>h.jsx(Yf,{ref:t,className:V("text-lg font-semibold",s),...e}));vr.displayName=Yf.displayName;const wr=C.forwardRef(({className:s,...e},t)=>h.jsx(Jf,{ref:t,className:V("text-sm text-muted-foreground",s),...e}));wr.displayName=Jf.displayName;const Kr=Wx,_r=Hx,Hn=C.forwardRef(({className:s,sideOffset:e=6,...t},i)=>h.jsx($x,{children:h.jsx(Xf,{ref:i,sideOffset:e,className:V("z-50 min-w-[10rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-card-hover","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...t})}));Hn.displayName=Xf.displayName;const oi=C.forwardRef(({className:s,...e},t)=>h.jsx(Zf,{ref:t,className:V("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors","focus:bg-accent focus:text-accent-foreground","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...e}));oi.displayName=Zf.displayName;const em=C.forwardRef(({className:s,...e},t)=>h.jsx(ep,{ref:t,className:V("-mx-1 my-1 h-px bg-border",s),...e}));em.displayName=ep.displayName;function $1(s){const{data:e}=Ie({queryKey:["agent",s.agentId],queryFn:()=>ee.getAgent(s.agentId),enabled:!!s.agentId});return h.jsxs("div",{className:"flex h-full flex-col text-sm",children:[h.jsx("div",{className:"px-3 py-2 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Files"}),h.jsx("div",{className:"flex-1 overflow-y-auto px-1 pb-2",children:h.jsx(tm,{...s,path:"",name:(e==null?void 0:e.name)??s.agentId,depth:0,defaultOpen:!0,isRoot:!0})})]})}function tm({agentId:s,path:e,name:t,depth:i,defaultOpen:n,selectedPath:r,onSelectFile:o,onPathDeleted:a,isRoot:l}){const c=Xe(),[d,u]=C.useState(!!n),[f,p]=C.useState(null),[m,g]=C.useState(!1),{data:x,isLoading:b}=Ie({queryKey:["tree",s,e],queryFn:()=>ee.listTree(s,e),enabled:d}),S=new Set((x==null?void 0:x.entries.map(k=>k.name))??[]),N=we({mutationFn:async k=>{const M=f,P=e?`${e}/${k}`:k;return M==="folder"?await ee.mkdir(s,P):await ee.writeFile(s,P,""),{child:P,kind:M}},onSuccess:({child:k,kind:M})=>{p(null),q.success(M==="folder"?"folder created":"file created"),c.invalidateQueries({queryKey:["tree",s,e]}),M==="file"&&o(k)},onError:k=>q.error(`create failed: ${k.message}`)}),y=we({mutationFn:()=>ee.deletePath(s,e),onSuccess:()=>{g(!1),q.success("deleted"),c.invalidateQueries({queryKey:["tree",s,sm(e)]}),a==null||a(e)},onError:k=>q.error(`delete failed: ${k.message}`)}),w=k=>{u(!0),p(k)};return h.jsxs("div",{children:[h.jsxs("div",{className:"group relative flex items-center",style:{paddingLeft:8+i*12},children:[h.jsxs("button",{type:"button",onClick:()=>u(k=>!k),className:V("flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-2 py-1 text-left transition-colors","hover:bg-accent"),children:[h.jsx("span",{className:V("inline-flex transition-transform duration-150",d&&"rotate-90"),children:h.jsx(On,{className:"size-3.5 text-muted-foreground"})}),d?h.jsx(a1,{className:"size-4 text-primary/80"}):h.jsx(qp,{className:"size-4 text-primary/80"}),h.jsx("span",{className:"truncate",children:t})]}),h.jsxs(Kr,{children:[h.jsx(_r,{asChild:!0,children:h.jsx("button",{type:"button","aria-label":"folder actions",className:V("mr-1 rounded p-1 opacity-0 transition-opacity hover:bg-accent","group-hover:opacity-100 focus:opacity-100 data-[state=open]:opacity-100"),children:h.jsx(Lp,{className:"size-3.5 text-muted-foreground"})})}),h.jsxs(Hn,{align:"end",children:[h.jsxs(oi,{onSelect:()=>w("file"),children:[h.jsx(o1,{className:"size-4"}),"New file"]}),h.jsxs(oi,{onSelect:()=>w("folder"),children:[h.jsx(l1,{className:"size-4"}),"New folder"]}),!l&&h.jsxs(h.Fragment,{children:[h.jsx(em,{}),h.jsxs(oi,{onSelect:()=>g(!0),className:"text-destructive focus:text-destructive",children:[h.jsx(Wn,{className:"size-4"}),"Delete"]})]})]})]})]}),d&&h.jsxs("div",{children:[f&&h.jsx(q1,{depth:i+1,kind:f,taken:S,pending:N.isPending,onSubmit:k=>N.mutate(k),onCancel:()=>p(null)}),b&&h.jsx("div",{className:"px-2 py-1 text-xs text-muted-foreground",style:{paddingLeft:28+i*12},children:"loading…"}),x==null?void 0:x.entries.map(k=>h.jsx(W1,{entry:k,depth:i+1,agentId:s,selectedPath:r,onSelectFile:o,onPathDeleted:a},k.path)),x&&x.entries.length===0&&!f&&h.jsx("div",{className:"px-2 py-1 text-xs text-muted-foreground",style:{paddingLeft:28+i*12},children:"empty"})]}),h.jsx(Xo,{open:m,onOpenChange:g,children:h.jsxs(br,{children:[h.jsxs(Zo,{children:[h.jsx(vr,{children:"Delete folder?"}),h.jsxs(wr,{children:[h.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:e})," and everything inside will be permanently removed. This cannot be undone."]})]}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx(J,{variant:"outline",size:"sm",onClick:()=>g(!1),disabled:y.isPending,children:"Cancel"}),h.jsx(J,{variant:"destructive",size:"sm",onClick:()=>y.mutate(),disabled:y.isPending,children:"Delete"})]})]})})]})}function W1({entry:s,depth:e,agentId:t,selectedPath:i,onSelectFile:n,onPathDeleted:r}){return s.isDir?h.jsx(tm,{agentId:t,path:s.path,name:s.name,depth:e,selectedPath:i,onSelectFile:n,onPathDeleted:r}):h.jsx(H1,{entry:s,depth:e,agentId:t,selectedPath:i,onSelectFile:n,onPathDeleted:r})}function H1({entry:s,depth:e,agentId:t,selectedPath:i,onSelectFile:n,onPathDeleted:r}){const o=Xe(),[a,l]=C.useState(!1),c=i===s.path,d=we({mutationFn:()=>ee.deletePath(t,s.path),onSuccess:()=>{l(!1),q.success("deleted"),o.invalidateQueries({queryKey:["tree",t,sm(s.path)]}),r==null||r(s.path)},onError:u=>q.error(`delete failed: ${u.message}`)});return h.jsxs("div",{className:"group relative flex items-center",style:{paddingLeft:24+e*12},children:[h.jsxs("button",{type:"button",onClick:()=>n(s.path),className:V("flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-2 py-1 text-left transition-colors",c?"bg-primary/10 text-primary":"hover:bg-accent"),children:[h.jsx(Wp,{className:"size-4 text-muted-foreground"}),h.jsx("span",{className:"truncate",children:s.name}),h.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:Vb(s.size)})]}),h.jsxs(Kr,{children:[h.jsx(_r,{asChild:!0,children:h.jsx("button",{type:"button","aria-label":"file actions",className:V("mr-1 rounded p-1 opacity-0 transition-opacity hover:bg-accent","group-hover:opacity-100 focus:opacity-100 data-[state=open]:opacity-100"),children:h.jsx(Lp,{className:"size-3.5 text-muted-foreground"})})}),h.jsx(Hn,{align:"end",children:h.jsxs(oi,{onSelect:()=>l(!0),className:"text-destructive focus:text-destructive",children:[h.jsx(Wn,{className:"size-4"}),"Delete"]})})]}),h.jsx(Xo,{open:a,onOpenChange:l,children:h.jsxs(br,{children:[h.jsxs(Zo,{children:[h.jsx(vr,{children:"Delete file?"}),h.jsxs(wr,{children:[h.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:s.path})," ","will be permanently removed. This cannot be undone."]})]}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx(J,{variant:"outline",size:"sm",onClick:()=>l(!1),disabled:d.isPending,children:"Cancel"}),h.jsx(J,{variant:"destructive",size:"sm",onClick:()=>d.mutate(),disabled:d.isPending,children:"Delete"})]})]})})]})}function q1({depth:s,kind:e,taken:t,pending:i,onSubmit:n,onCancel:r}){const[o,a]=C.useState(""),l=o.trim(),c=l.length===0||l.includes("/")||l.startsWith(".")||t.has(l);return h.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",style:{paddingLeft:24+(s-1)*12},children:[e==="folder"?h.jsx(qp,{className:"size-4 text-primary/80"}):h.jsx(Wp,{className:"size-4 text-muted-foreground"}),h.jsx("input",{autoFocus:!0,type:"text",value:o,disabled:i,onChange:d=>a(d.target.value),onKeyDown:d=>{d.key==="Enter"&&!c?n(l):d.key==="Escape"&&r()},onBlur:()=>{i||r()},placeholder:e==="folder"?"folder name":"file name",className:V("h-6 min-w-0 flex-1 rounded border bg-background px-1.5 text-xs outline-none focus:border-primary",c&&o!==""&&"border-destructive")})]})}function sm(s){const e=s.lastIndexOf("/");return e===-1?"":s.slice(0,e)}function sc(){return sc=Object.assign?Object.assign.bind():function(s){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(s[i]=t[i])}return s},sc.apply(null,arguments)}function V1(s,e){if(s==null)return{};var t={};for(var i in s)if({}.hasOwnProperty.call(s,i)){if(e.indexOf(i)!==-1)continue;t[i]=s[i]}return t}let ic=[],im=[];(()=>{let s="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<s.length;e++)(e%2?im:ic).push(t=t+s[e])})();function K1(s){if(s<768)return!1;for(let e=0,t=ic.length;;){let i=e+t>>1;if(s<ic[i])t=i;else if(s>=im[i])e=i+1;else return!0;if(e==t)return!1}}function Sd(s){return s>=127462&&s<=127487}const Cd=8205;function _1(s,e,t=!0,i=!0){return(t?nm:U1)(s,e,i)}function nm(s,e,t){if(e==s.length)return e;e&&rm(s.charCodeAt(e))&&om(s.charCodeAt(e-1))&&e--;let i=Za(s,e);for(e+=jd(i);e<s.length;){let n=Za(s,e);if(i==Cd||n==Cd||t&&K1(n))e+=jd(n),i=n;else if(Sd(n)){let r=0,o=e-2;for(;o>=0&&Sd(Za(s,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function U1(s,e,t){for(;e>0;){let i=nm(s,e-2,t);if(i<e)return i;e--}return 0}function Za(s,e){let t=s.charCodeAt(e);if(!om(t)||e+1==s.length)return t;let i=s.charCodeAt(e+1);return rm(i)?(t-55296<<10)+(i-56320)+65536:t}function rm(s){return s>=56320&&s<57344}function om(s){return s>=55296&&s<56320}function jd(s){return s<65536?1:2}class ye{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=En(this,e,t);let n=[];return this.decompose(0,e,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(t,this.length,n,1),fs.from(n,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=En(this,e,t);let i=[];return this.decompose(e,t,i,0),fs.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),n=new ar(this),r=new ar(e);for(let o=t,a=t;;){if(n.next(o),r.next(o),o=0,n.lineBreak!=r.lineBreak||n.done!=r.done||n.value!=r.value)return!1;if(a+=n.value.length,n.done||a>=i)return!0}}iter(e=1){return new ar(this,e)}iterRange(e,t=this.length){return new am(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let n=this.line(e).from;i=this.iterRange(n,Math.max(n,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new lm(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?ye.empty:e.length<=32?new ze(e):fs.from(ze.split(e,[]))}}class ze extends ye{constructor(e,t=Q1(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,n){for(let r=0;;r++){let o=this.text[r],a=n+o.length;if((t?i:a)>=e)return new G1(n,a,i,o);n=a+1,i++}}decompose(e,t,i,n){let r=e<=0&&t>=this.length?this:new ze(Nd(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(n&1){let o=i.pop(),a=Lo(r.text,o.text.slice(),0,r.length);if(a.length<=32)i.push(new ze(a,o.length+r.length));else{let l=a.length>>1;i.push(new ze(a.slice(0,l)),new ze(a.slice(l)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof ze))return super.replace(e,t,i);[e,t]=En(this,e,t);let n=Lo(this.text,Lo(i.text,Nd(this.text,0,e)),t),r=this.length+i.length-(t-e);return n.length<=32?new ze(n,r):fs.from(ze.split(n,[]),r)}sliceString(e,t=this.length,i=`
|
|
319
319
|
`){[e,t]=En(this,e,t);let n="";for(let r=0,o=0;r<=t&&o<this.text.length;o++){let a=this.text[o],l=r+a.length;r>e&&o&&(n+=i),e<l&&t>r&&(n+=a.slice(Math.max(0,e-r),t-r)),r=l+1}return n}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],n=-1;for(let r of e)i.push(r),n+=r.length+1,i.length==32&&(t.push(new ze(i,n)),i=[],n=-1);return n>-1&&t.push(new ze(i,n)),t}}class fs extends ye{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,n){for(let r=0;;r++){let o=this.children[r],a=n+o.length,l=i+o.lines-1;if((t?l:a)>=e)return o.lineInner(e,t,i,n);n=a+1,i=l+1}}decompose(e,t,i,n){for(let r=0,o=0;o<=t&&r<this.children.length;r++){let a=this.children[r],l=o+a.length;if(e<=l&&t>=o){let c=n&((o<=e?1:0)|(l>=t?2:0));o>=e&&l<=t&&!c?i.push(a):a.decompose(e-o,t-o,i,c)}o=l+1}}replace(e,t,i){if([e,t]=En(this,e,t),i.lines<this.lines)for(let n=0,r=0;n<this.children.length;n++){let o=this.children[n],a=r+o.length;if(e>=r&&t<=a){let l=o.replace(e-r,t-r,i),c=this.lines-o.lines+l.lines;if(l.lines<c>>4&&l.lines>c>>6){let d=this.children.slice();return d[n]=l,new fs(d,this.length-(t-e)+i.length)}return super.replace(r,a,l)}r=a+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=`
|
|
320
320
|
`){[e,t]=En(this,e,t);let n="";for(let r=0,o=0;r<this.children.length&&o<=t;r++){let a=this.children[r],l=o+a.length;o>e&&r&&(n+=i),e<l&&t>o&&(n+=a.sliceString(e-o,t-o,i)),o=l+1}return n}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof fs))return 0;let i=0,[n,r,o,a]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;n+=t,r+=t){if(n==o||r==a)return i;let l=this.children[n],c=e.children[r];if(l!=c)return i+l.scanIdentical(c,t);i+=l.length+1}}static from(e,t=e.reduce((i,n)=>i+n.length+1,-1)){let i=0;for(let p of e)i+=p.lines;if(i<32){let p=[];for(let m of e)m.flatten(p);return new ze(p,t)}let n=Math.max(32,i>>5),r=n<<1,o=n>>1,a=[],l=0,c=-1,d=[];function u(p){let m;if(p.lines>r&&p instanceof fs)for(let g of p.children)u(g);else p.lines>o&&(l>o||!l)?(f(),a.push(p)):p instanceof ze&&l&&(m=d[d.length-1])instanceof ze&&p.lines+m.lines<=32?(l+=p.lines,c+=p.length+1,d[d.length-1]=new ze(m.text.concat(p.text),m.length+1+p.length)):(l+p.lines>n&&f(),l+=p.lines,c+=p.length+1,d.push(p))}function f(){l!=0&&(a.push(d.length==1?d[0]:fs.from(d,c)),c=-1,l=d.length=0)}for(let p of e)u(p);return f(),a.length==1?a[0]:new fs(a,t)}}ye.empty=new ze([""],0);function Q1(s){let e=-1;for(let t of s)e+=t.length+1;return e}function Lo(s,e,t=0,i=1e9){for(let n=0,r=0,o=!0;r<s.length&&n<=i;r++){let a=s[r],l=n+a.length;l>=t&&(l>i&&(a=a.slice(0,i-n)),n<t&&(a=a.slice(t-n)),o?(e[e.length-1]+=a,o=!1):e.push(a)),n=l+1}return e}function Nd(s,e,t){return Lo(s,[""],e,t)}class ar{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof ze?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],r=this.offsets[i],o=r>>1,a=n instanceof ze?n.text.length:n.children.length;if(o==(t>0?a:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=`
|
|
321
321
|
`,this;e--}else if(n instanceof ze){let l=n.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,l.length>Math.max(0,e))return this.value=e==0?l:t>0?l.slice(e):l.slice(0,l.length-e),this;e-=l.length}else{let l=n.children[o+(t<0?-1:0)];e>l.length?(e-=l.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(l),this.offsets.push(t>0?1:(l instanceof ze?l.text.length:l.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class am{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new ar(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:n}=this.cursor.next(e);return this.pos+=(n.length+e)*t,this.value=n.length<=i?n:t<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class lm{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:n}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(ye.prototype[Symbol.iterator]=function(){return this.iter()},ar.prototype[Symbol.iterator]=am.prototype[Symbol.iterator]=lm.prototype[Symbol.iterator]=function(){return this});class G1{constructor(e,t,i,n){this.from=e,this.to=t,this.number=i,this.text=n}get length(){return this.to-this.from}}function En(s,e,t){return e=Math.max(0,Math.min(s.length,e)),[e,Math.max(e,Math.min(s.length,t))]}function _e(s,e,t=!0,i=!0){return _1(s,e,t,i)}function Y1(s){return s>=56320&&s<57344}function J1(s){return s>=55296&&s<56320}function kt(s,e){let t=s.charCodeAt(e);if(!J1(t)||e+1==s.length)return t;let i=s.charCodeAt(e+1);return Y1(i)?(t-55296<<10)+(i-56320)+65536:t}function lh(s){return s<=65535?String.fromCharCode(s):(s-=65536,String.fromCharCode((s>>10)+55296,(s&1023)+56320))}function ps(s){return s<65536?1:2}const nc=/\r\n?|\n/;var Ge=function(s){return s[s.Simple=0]="Simple",s[s.TrackDel=1]="TrackDel",s[s.TrackBefore=2]="TrackBefore",s[s.TrackAfter=3]="TrackAfter",s}(Ge||(Ge={}));class vs{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,n=0;t<this.sections.length;){let r=this.sections[t++],o=this.sections[t++];o<0?(e(i,n,r),n+=r):n+=o,i+=r}}iterChangedRanges(e,t=!1){rc(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],n=this.sections[t++];n<0?e.push(i,n):e.push(n,i)}return new vs(e)}composeDesc(e){return this.empty?e:e.empty?this:cm(this,e)}mapDesc(e,t=!1){return e.empty?this:oc(this,e,t)}mapPos(e,t=-1,i=Ge.Simple){let n=0,r=0;for(let o=0;o<this.sections.length;){let a=this.sections[o++],l=this.sections[o++],c=n+a;if(l<0){if(c>e)return r+(e-n);r+=a}else{if(i!=Ge.Simple&&c>=e&&(i==Ge.TrackDel&&n<e&&c>e||i==Ge.TrackBefore&&n<e||i==Ge.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!a)return e==n||t<0?r:r+l;r+=l}n=c}if(e>n)throw new RangeError(`Position ${e} is out of range for changeset of length ${n}`);return r}touchesRange(e,t=e){for(let i=0,n=0;i<this.sections.length&&n<=t;){let r=this.sections[i++],o=this.sections[i++],a=n+r;if(o>=0&&n<=t&&a>=e)return n<e&&a>t?"cover":!0;n=a}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],n=this.sections[t++];e+=(e?" ":"")+i+(n>=0?":"+n:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new vs(e)}static create(e){return new vs(e)}}class He extends vs{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return rc(this,(t,i,n,r,o)=>e=e.replace(n,n+(i-t),o),!1),e}mapDesc(e,t=!1){return oc(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let n=0,r=0;n<t.length;n+=2){let o=t[n],a=t[n+1];if(a>=0){t[n]=a,t[n+1]=o;let l=n>>1;for(;i.length<l;)i.push(ye.empty);i.push(o?e.slice(r,r+o):ye.empty)}r+=o}return new He(t,i)}compose(e){return this.empty?e:e.empty?this:cm(this,e,!0)}map(e,t=!1){return e.empty?this:oc(this,e,t,!0)}iterChanges(e,t=!1){rc(this,e,t)}get desc(){return vs.create(this.sections)}filter(e){let t=[],i=[],n=[],r=new kr(this);e:for(let o=0,a=0;;){let l=o==e.length?1e9:e[o++];for(;a<l||a==l&&r.len==0;){if(r.done)break e;let d=Math.min(r.len,l-a);st(n,d,-1);let u=r.ins==-1?-1:r.off==0?r.ins:0;st(t,d,u),u>0&&ni(i,t,r.text),r.forward(d),a+=d}let c=e[o++];for(;a<c;){if(r.done)break e;let d=Math.min(r.len,c-a);st(t,d,-1),st(n,d,r.ins==-1?-1:r.off==0?r.ins:0),r.forward(d),a+=d}}return{changes:new He(t,i),filtered:vs.create(n)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],n=this.sections[t+1];n<0?e.push(i):n==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let n=[],r=[],o=0,a=null;function l(d=!1){if(!d&&!n.length)return;o<t&&st(n,t-o,-1);let u=new He(n,r);a=a?a.compose(u.map(a)):u,n=[],r=[],o=0}function c(d){if(Array.isArray(d))for(let u of d)c(u);else if(d instanceof He){if(d.length!=t)throw new RangeError(`Mismatched change set length (got ${d.length}, expected ${t})`);l(),a=a?a.compose(d.map(a)):d}else{let{from:u,to:f=u,insert:p}=d;if(u>f||u<0||f>t)throw new RangeError(`Invalid change range ${u} to ${f} (in doc of length ${t})`);let m=p?typeof p=="string"?ye.of(p.split(i||nc)):p:ye.empty,g=m.length;if(u==f&&g==0)return;u<o&&l(),u>o&&st(n,u-o,-1),st(n,f-u,g),ni(r,n,m),o=f}}return c(e),l(!a),a}static empty(e){return new He(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let n=0;n<e.length;n++){let r=e[n];if(typeof r=="number")t.push(r,-1);else{if(!Array.isArray(r)||typeof r[0]!="number"||r.some((o,a)=>a&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)t.push(r[0],0);else{for(;i.length<n;)i.push(ye.empty);i[n]=ye.of(r.slice(1)),t.push(r[0],i[n].length)}}}return new He(t,i)}static createSet(e,t){return new He(e,t)}}function st(s,e,t,i=!1){if(e==0&&t<=0)return;let n=s.length-2;n>=0&&t<=0&&t==s[n+1]?s[n]+=e:n>=0&&e==0&&s[n]==0?s[n+1]+=t:i?(s[n]+=e,s[n+1]+=t):s.push(e,t)}function ni(s,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<s.length)s[s.length-1]=s[s.length-1].append(t);else{for(;s.length<i;)s.push(ye.empty);s.push(t)}}function rc(s,e,t){let i=s.inserted;for(let n=0,r=0,o=0;o<s.sections.length;){let a=s.sections[o++],l=s.sections[o++];if(l<0)n+=a,r+=a;else{let c=n,d=r,u=ye.empty;for(;c+=a,d+=l,l&&i&&(u=u.append(i[o-2>>1])),!(t||o==s.sections.length||s.sections[o+1]<0);)a=s.sections[o++],l=s.sections[o++];e(n,c,r,d,u),n=c,r=d}}}function oc(s,e,t,i=!1){let n=[],r=i?[]:null,o=new kr(s),a=new kr(e);for(let l=-1;;){if(o.done&&a.len||a.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&a.ins==-1){let c=Math.min(o.len,a.len);st(n,c,-1),o.forward(c),a.forward(c)}else if(a.ins>=0&&(o.ins<0||l==o.i||o.off==0&&(a.len<o.len||a.len==o.len&&!t))){let c=a.len;for(st(n,a.ins,-1);c;){let d=Math.min(o.len,c);o.ins>=0&&l<o.i&&o.len<=d&&(st(n,0,o.ins),r&&ni(r,n,o.text),l=o.i),o.forward(d),c-=d}a.next()}else if(o.ins>=0){let c=0,d=o.len;for(;d;)if(a.ins==-1){let u=Math.min(d,a.len);c+=u,d-=u,a.forward(u)}else if(a.ins==0&&a.len<d)d-=a.len,a.next();else break;st(n,c,l<o.i?o.ins:0),r&&l<o.i&&ni(r,n,o.text),l=o.i,o.forward(o.len-d)}else{if(o.done&&a.done)return r?He.createSet(n,r):vs.create(n);throw new Error("Mismatched change set lengths")}}}function cm(s,e,t=!1){let i=[],n=t?[]:null,r=new kr(s),o=new kr(e);for(let a=!1;;){if(r.done&&o.done)return n?He.createSet(i,n):vs.create(i);if(r.ins==0)st(i,r.len,0,a),r.next();else if(o.len==0&&!o.done)st(i,0,o.ins,a),n&&ni(n,i,o.text),o.next();else{if(r.done||o.done)throw new Error("Mismatched change set lengths");{let l=Math.min(r.len2,o.len),c=i.length;if(r.ins==-1){let d=o.ins==-1?-1:o.off?0:o.ins;st(i,l,d,a),n&&d&&ni(n,i,o.text)}else o.ins==-1?(st(i,r.off?0:r.len,l,a),n&&ni(n,i,r.textBit(l))):(st(i,r.off?0:r.len,o.off?0:o.ins,a),n&&!o.off&&ni(n,i,o.text));a=(r.ins>l||o.ins>=0&&o.len>l)&&(a||i.length>c),r.forward2(l),o.forward(l)}}}}class kr{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?ye.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?ye.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class ji{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let i,n;return this.empty?i=n=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),n=e.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new ji(i,n,this.flags)}extend(e,t=e,i=0){if(e<=this.anchor&&t>=this.anchor)return T.range(e,t,void 0,void 0,i);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return T.range(this.anchor,n,void 0,void 0,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return T.range(e.anchor,e.head)}static create(e,t,i){return new ji(e,t,i)}}class T{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:T.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new T([this.main],0)}addRange(e,t=!0){return T.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,T.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new T(e.ranges.map(t=>ji.fromJSON(t)),e.main)}static single(e,t=e){return new T([T.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<e.length;n++){let r=e[n];if(r.empty?r.from<=i:r.from<i)return T.normalized(e.slice(),t);i=r.to}return new T(e,t)}static cursor(e,t=0,i,n){return ji.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i))|(n??16777215)<<6)}static range(e,t,i,n,r){let o=(i??16777215)<<6|(n==null?7:Math.min(6,n));return!r&&e!=t&&(r=t<e?1:-1),t<e?ji.create(t,e,48|o):ji.create(e,t,(r?r<0?8:16:0)|o)}static normalized(e,t=0){let i=e[t];e.sort((n,r)=>n.from-r.from),t=e.indexOf(i);for(let n=1;n<e.length;n++){let r=e[n],o=e[n-1];if(r.empty?r.from<=o.to:r.from<o.to){let a=o.from,l=Math.max(r.to,o.to);n<=t&&t--,e.splice(--n,2,r.anchor>r.head?T.range(l,a):T.range(a,l))}}return new T(e,t)}}function hm(s,e){for(let t of s.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let ch=0;class ${constructor(e,t,i,n,r){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=n,this.id=ch++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new $(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:hh),!!e.static,e.enables)}of(e){return new Bo([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Bo(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Bo(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function hh(s,e){return s==e||s.length==e.length&&s.every((t,i)=>t===e[i])}class Bo{constructor(e,t,i,n){this.dependencies=e,this.facet=t,this.type=i,this.value=n,this.id=ch++}dynamicSlot(e){var t;let i=this.value,n=this.facet.compareInput,r=this.id,o=e[r]>>1,a=this.type==2,l=!1,c=!1,d=[];for(let u of this.dependencies)u=="doc"?l=!0:u=="selection"?c=!0:((t=e[u.id])!==null&&t!==void 0?t:1)&1||d.push(e[u.id]);return{create(u){return u.values[o]=i(u),1},update(u,f){if(l&&f.docChanged||c&&(f.docChanged||f.selection)||ac(u,d)){let p=i(u);if(a?!Md(p,u.values[o],n):!n(p,u.values[o]))return u.values[o]=p,1}return 0},reconfigure:(u,f)=>{let p,m=f.config.address[r];if(m!=null){let g=ta(f,m);if(this.dependencies.every(x=>x instanceof $?f.facet(x)===u.facet(x):x instanceof Ze?f.field(x,!1)==u.field(x,!1):!0)||(a?Md(p=i(u),g,n):n(p=i(u),g)))return u.values[o]=g,0}else p=i(u);return u.values[o]=p,1}}}}function Md(s,e,t){if(s.length!=e.length)return!1;for(let i=0;i<s.length;i++)if(!t(s[i],e[i]))return!1;return!0}function ac(s,e){let t=!1;for(let i of e)lr(s,i)&1&&(t=!0);return t}function X1(s,e,t){let i=t.map(l=>s[l.id]),n=t.map(l=>l.type),r=i.filter(l=>!(l&1)),o=s[e.id]>>1;function a(l){let c=[];for(let d=0;d<i.length;d++){let u=ta(l,i[d]);if(n[d]==2)for(let f of u)c.push(f);else c.push(u)}return e.combine(c)}return{create(l){for(let c of i)lr(l,c);return l.values[o]=a(l),1},update(l,c){if(!ac(l,r))return 0;let d=a(l);return e.compare(d,l.values[o])?0:(l.values[o]=d,1)},reconfigure(l,c){let d=ac(l,i),u=c.config.facets[e.id],f=c.facet(e);if(u&&!d&&hh(t,u))return l.values[o]=f,0;let p=a(l);return e.compare(p,f)?(l.values[o]=f,0):(l.values[o]=p,1)}}}const ho=$.define({static:!0});class Ze{constructor(e,t,i,n,r){this.id=e,this.createF=t,this.updateF=i,this.compareF=n,this.spec=r,this.provides=void 0}static define(e){let t=new Ze(ch++,e.create,e.update,e.compare||((i,n)=>i===n),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(ho).find(i=>i.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,n)=>{let r=i.values[t],o=this.updateF(r,n);return this.compareF(r,o)?0:(i.values[t]=o,1)},reconfigure:(i,n)=>{let r=i.facet(ho),o=n.facet(ho),a;return(a=r.find(l=>l.field==this))&&a!=o.find(l=>l.field==this)?(i.values[t]=a.create(i),1):n.config.address[this.id]!=null?(i.values[t]=n.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,ho.of({field:this,create:e})]}get extension(){return this}}const ki={lowest:4,low:3,default:2,high:1,highest:0};function Yn(s){return e=>new dm(e,s)}const mi={highest:Yn(ki.highest),high:Yn(ki.high),default:Yn(ki.default),low:Yn(ki.low),lowest:Yn(ki.lowest)};class dm{constructor(e,t){this.inner=e,this.prec=t}}class Ra{of(e){return new lc(this,e)}reconfigure(e){return Ra.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class lc{constructor(e,t){this.compartment=e,this.inner=t}}class ea{constructor(e,t,i,n,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=n,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let n=[],r=Object.create(null),o=new Map;for(let f of Z1(e,t,o))f instanceof Ze?n.push(f):(r[f.facet.id]||(r[f.facet.id]=[])).push(f);let a=Object.create(null),l=[],c=[];for(let f of n)a[f.id]=c.length<<1,c.push(p=>f.slot(p));let d=i==null?void 0:i.config.facets;for(let f in r){let p=r[f],m=p[0].facet,g=d&&d[f]||[];if(p.every(x=>x.type==0))if(a[m.id]=l.length<<1|1,hh(g,p))l.push(i.facet(m));else{let x=m.combine(p.map(b=>b.value));l.push(i&&m.compare(x,i.facet(m))?i.facet(m):x)}else{for(let x of p)x.type==0?(a[x.id]=l.length<<1|1,l.push(x.value)):(a[x.id]=c.length<<1,c.push(b=>x.dynamicSlot(b)));a[m.id]=c.length<<1,c.push(x=>X1(x,m,p))}}let u=c.map(f=>f(a));return new ea(e,o,u,a,l,r)}}function Z1(s,e,t){let i=[[],[],[],[],[]],n=new Map;function r(o,a){let l=n.get(o);if(l!=null){if(l<=a)return;let c=i[l].indexOf(o);c>-1&&i[l].splice(c,1),o instanceof lc&&t.delete(o.compartment)}if(n.set(o,a),Array.isArray(o))for(let c of o)r(c,a);else if(o instanceof lc){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(o.compartment)||o.inner;t.set(o.compartment,c),r(c,a)}else if(o instanceof dm)r(o.inner,o.prec);else if(o instanceof Ze)i[a].push(o),o.provides&&r(o.provides,a);else if(o instanceof Bo)i[a].push(o),o.facet.extensions&&r(o.facet.extensions,ki.default);else{let c=o.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(c,a)}}return r(s,ki.default),i.reduce((o,a)=>o.concat(a))}function lr(s,e){if(e&1)return 2;let t=e>>1,i=s.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;s.status[t]=4;let n=s.computeSlot(s,s.config.dynamicSlots[t]);return s.status[t]=2|n}function ta(s,e){return e&1?s.config.staticValues[e>>1]:s.values[e>>1]}const um=$.define(),cc=$.define({combine:s=>s.some(e=>e),static:!0}),fm=$.define({combine:s=>s.length?s[0]:void 0,static:!0}),pm=$.define(),mm=$.define(),gm=$.define(),xm=$.define({combine:s=>s.length?s[0]:!1});class ks{constructor(e,t){this.type=e,this.value=t}static define(){return new ev}}class ev{of(e){return new ks(this,e)}}class tv{constructor(e){this.map=e}of(e){return new te(this,e)}}class te{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new te(this.type,t)}is(e){return this.type==e}static define(e={}){return new tv(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let n of e){let r=n.map(t);r&&i.push(r)}return i}}te.reconfigure=te.define();te.appendConfig=te.define();class We{constructor(e,t,i,n,r,o){this.startState=e,this.changes=t,this.selection=i,this.effects=n,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,i&&hm(i,t.newLength),r.some(a=>a.type==We.time)||(this.annotations=r.concat(We.time.of(Date.now())))}static create(e,t,i,n,r,o){return new We(e,t,i,n,r,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(We.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}We.time=ks.define();We.userEvent=ks.define();We.addToHistory=ks.define();We.remote=ks.define();function sv(s,e){let t=[];for(let i=0,n=0;;){let r,o;if(i<s.length&&(n==e.length||e[n]>=s[i]))r=s[i++],o=s[i++];else if(n<e.length)r=e[n++],o=e[n++];else return t;!t.length||t[t.length-1]<r?t.push(r,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function ym(s,e,t){var i;let n,r,o;return t?(n=e.changes,r=He.empty(e.changes.length),o=s.changes.compose(e.changes)):(n=e.changes.map(s.changes),r=s.changes.mapDesc(e.changes,!0),o=s.changes.compose(n)),{changes:o,selection:e.selection?e.selection.map(r):(i=s.selection)===null||i===void 0?void 0:i.map(n),effects:te.mapEffects(s.effects,n).concat(te.mapEffects(e.effects,r)),annotations:s.annotations.length?s.annotations.concat(e.annotations):e.annotations,scrollIntoView:s.scrollIntoView||e.scrollIntoView}}function hc(s,e,t){let i=e.selection,n=ln(e.annotations);return e.userEvent&&(n=n.concat(We.userEvent.of(e.userEvent))),{changes:e.changes instanceof He?e.changes:He.of(e.changes||[],t,s.facet(fm)),selection:i&&(i instanceof T?i:T.single(i.anchor,i.head)),effects:ln(e.effects),annotations:n,scrollIntoView:!!e.scrollIntoView}}function bm(s,e,t){let i=hc(s,e.length?e[0]:{},s.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let r=1;r<e.length;r++){e[r].filter===!1&&(t=!1);let o=!!e[r].sequential;i=ym(i,hc(s,e[r],o?i.changes.newLength:s.doc.length),o)}let n=We.create(s,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return nv(t?iv(n):n)}function iv(s){let e=s.startState,t=!0;for(let n of e.facet(pm)){let r=n(s);if(r===!1){t=!1;break}Array.isArray(r)&&(t=t===!0?r:sv(t,r))}if(t!==!0){let n,r;if(t===!1)r=s.changes.invertedDesc,n=He.empty(e.doc.length);else{let o=s.changes.filter(t);n=o.changes,r=o.filtered.mapDesc(o.changes).invertedDesc}s=We.create(e,n,s.selection&&s.selection.map(r),te.mapEffects(s.effects,r),s.annotations,s.scrollIntoView)}let i=e.facet(mm);for(let n=i.length-1;n>=0;n--){let r=i[n](s);r instanceof We?s=r:Array.isArray(r)&&r.length==1&&r[0]instanceof We?s=r[0]:s=bm(e,ln(r),!1)}return s}function nv(s){let e=s.startState,t=e.facet(gm),i=s;for(let n=t.length-1;n>=0;n--){let r=t[n](s);r&&Object.keys(r).length&&(i=ym(i,hc(e,r,s.changes.newLength),!0))}return i==s?s:We.create(e,s.changes,s.selection,i.effects,i.annotations,i.scrollIntoView)}const rv=[];function ln(s){return s==null?rv:Array.isArray(s)?s:[s]}var Pe=function(s){return s[s.Word=0]="Word",s[s.Space=1]="Space",s[s.Other=2]="Other",s}(Pe||(Pe={}));const ov=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let dc;try{dc=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function av(s){if(dc)return dc.test(s);for(let e=0;e<s.length;e++){let t=s[e];if(/\w/.test(t)||t>""&&(t.toUpperCase()!=t.toLowerCase()||ov.test(t)))return!0}return!1}function lv(s){return e=>{if(!/\S/.test(e))return Pe.Space;if(av(e))return Pe.Word;for(let t=0;t<s.length;t++)if(e.indexOf(s[t])>-1)return Pe.Word;return Pe.Other}}class xe{constructor(e,t,i,n,r,o){this.config=e,this.doc=t,this.selection=i,this.values=n,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let a=0;a<this.config.dynamicSlots.length;a++)lr(this,a<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return lr(this,i),ta(this,i)}update(...e){return bm(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:n}=t;for(let a of e.effects)a.is(Ra.reconfigure)?(t&&(n=new Map,t.compartments.forEach((l,c)=>n.set(c,l)),t=null),n.set(a.value.compartment,a.value.extension)):a.is(te.reconfigure)?(t=null,i=a.value):a.is(te.appendConfig)&&(t=null,i=ln(i).concat(a.value));let r;t?r=e.startState.values.slice():(t=ea.resolve(i,n,this),r=new xe(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(l,c)=>c.reconfigure(l,this),null).values);let o=e.startState.facet(cc)?e.newSelection:e.newSelection.asSingle();new xe(t,e.newDoc,o,r,(a,l)=>l.update(a,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:T.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),n=this.changes(i.changes),r=[i.range],o=ln(i.effects);for(let a=1;a<t.ranges.length;a++){let l=e(t.ranges[a]),c=this.changes(l.changes),d=c.map(n);for(let f=0;f<a;f++)r[f]=r[f].map(d);let u=n.mapDesc(c,!0);r.push(l.range.map(u)),n=n.compose(d),o=te.mapEffects(o,d).concat(te.mapEffects(ln(l.effects),u))}return{changes:n,selection:T.create(r,t.mainIndex),effects:o}}changes(e=[]){return e instanceof He?e:He.of(e,this.doc.length,this.facet(xe.lineSeparator))}toText(e){return ye.of(e.split(this.facet(xe.lineSeparator)||nc))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(lr(this,t),ta(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let n=e[i];n instanceof Ze&&this.config.address[n.id]!=null&&(t[i]=n.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i){for(let r in i)if(Object.prototype.hasOwnProperty.call(e,r)){let o=i[r],a=e[r];n.push(o.init(l=>o.spec.fromJSON(a,l)))}}return xe.create({doc:e.doc,selection:T.fromJSON(e.selection),extensions:t.extensions?n.concat([t.extensions]):n})}static create(e={}){let t=ea.resolve(e.extensions||[],new Map),i=e.doc instanceof ye?e.doc:ye.of((e.doc||"").split(t.staticFacet(xe.lineSeparator)||nc)),n=e.selection?e.selection instanceof T?e.selection:T.single(e.selection.anchor,e.selection.head):T.single(0);return hm(n,i.length),t.staticFacet(cc)||(n=n.asSingle()),new xe(t,i,n,t.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(xe.tabSize)}get lineBreak(){return this.facet(xe.lineSeparator)||`
|
|
@@ -333,4 +333,4 @@ var sd=s=>{throw TypeError(s)};var Ja=(s,e,t)=>e.has(s)||sd("Cannot "+t);var v=(
|
|
|
333
333
|
`);return ee.sendChat(s,De,r==null?void 0:r.threadId)},onSuccess:()=>{K(""),ae([]),e.invalidateQueries({queryKey:["threads",s]}),e.invalidateQueries({queryKey:["session",s,r==null?void 0:r.threadId,r==null?void 0:r.sessionId]}),e.invalidateQueries({queryKey:["tree",s]})},onError:j=>q.error(`send failed: ${j.message}`)}),Fe=we({mutationFn:()=>r?ee.abortChat(s,r.threadId):Promise.resolve({ok:!1}),onSuccess:j=>{j.ok?q.info("abort sent"):q.message("nothing in flight")}}),[pe,gt]=C.useState(null),Ae=we({mutationFn:j=>ee.deleteThread(s,j),onSuccess:(j,E)=>{q.success(`thread "${E}" deleted`),(r==null?void 0:r.threadId)===E&&o(null),gt(null),e.invalidateQueries({queryKey:["threads",s]}),e.invalidateQueries({queryKey:["events",s]}),e.invalidateQueries({queryKey:["tree",s]})},onError:j=>q.error(`delete failed: ${j.message}`)}),xt=j=>{if((r==null?void 0:r.threadId)===j&&r.sessionId===""&&!n.some(E=>E.threadId===j)){o(null);return}gt(j)},yt=()=>{const j=Q.trim();!j&&U.length===0||de.mutate({text:j,files:U})},ns=j=>{j.length!==0&&ae(E=>[...E,...j])},Cs=j=>{ae(E=>E.filter((he,De)=>De!==j))},Lt=(!!Q.trim()||U.length>0)&&!de.isPending&&M;return h.jsxs("div",{className:"flex h-full min-h-0 flex-col lg:grid lg:grid-cols-[minmax(220px,22%)_1fr]",children:[h.jsx(SM,{threads:n,loading:i,selected:r,onSelect:o,onNewThread:()=>L(!0),onDeleteThread:xt,deletingThreadId:Ae.isPending?Ae.variables??null:null}),h.jsx(Xo,{open:!!pe,onOpenChange:j=>{j||gt(null)},children:h.jsxs(br,{className:"max-w-md",children:[h.jsxs(Zo,{children:[h.jsx(vr,{children:"Delete thread?"}),h.jsxs(wr,{children:["This permanently removes the thread"," ",h.jsx("code",{className:"rounded bg-muted px-1 font-mono",children:pe})," ","and all of its sessions, queued events, and history."]})]}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx(J,{variant:"ghost",onClick:()=>gt(null),children:"Cancel"}),h.jsxs(J,{variant:"destructive",onClick:()=>pe&&Ae.mutate(pe),disabled:Ae.isPending,children:[Ae.isPending?h.jsx($e,{className:"size-4 animate-spin"}):h.jsx(Wn,{className:"size-4"}),"Delete"]})]})]})}),h.jsx(Xo,{open:P,onOpenChange:L,children:h.jsxs(br,{className:"max-w-md",children:[h.jsxs(Zo,{children:[h.jsx(vr,{children:"New thread"}),h.jsx(wr,{children:"Enter an id for the new thread. The thread will be created when you send the first message."})]}),h.jsx(at,{autoFocus:!0,placeholder:"thread id",value:H,onChange:j=>F(j.target.value),onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),O())}}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx(J,{variant:"ghost",onClick:()=>{F(""),L(!1)},children:"Cancel"}),h.jsx(J,{onClick:O,disabled:!H.trim(),children:"Create"})]})]})}),h.jsxs("div",{className:"flex h-full min-h-0 min-w-0 flex-1 flex-col lg:border-l",children:[h.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-x-3 gap-y-1 border-b px-4 py-2 text-xs text-muted-foreground",children:[h.jsx(kM,{threads:n,selected:r,onSelect:o}),r?h.jsxs(h.Fragment,{children:[h.jsx(yr,{className:"hidden size-4 lg:inline"}),h.jsx("code",{className:"min-w-0 truncate",children:r.threadId}),h.jsx("span",{className:"text-[10px]",children:"·"}),h.jsx(wM,{sessions:(y==null?void 0:y.sessions)??[],selectedSessionId:r.sessionId,activeSessionId:w,onSelect:j=>o({threadId:r.threadId,sessionId:j})}),h.jsx("span",{className:"text-[10px]",children:"·"}),h.jsx(vM,{agentId:s,threadId:r.threadId,modelOverride:(y==null?void 0:y.modelOverride)??null})]}):h.jsx("span",{children:"No session selected"}),h.jsxs("div",{className:"ml-auto inline-flex gap-1",children:[h.jsx(Pl,{active:Z==="messages",onClick:()=>se("messages"),icon:yr,label:"Messages"}),h.jsx(Pl,{active:Z==="raw",onClick:()=>se("raw"),icon:n1,label:"Raw"}),h.jsx(Pl,{active:Z==="usage",onClick:()=>se("usage"),icon:t1,label:"Usage"})]})]}),h.jsxs("div",{ref:be,onScroll:_,className:V("flex-1 space-y-4 overflow-y-auto p-4",Z!=="messages"&&"hidden"),children:[S.length===0&&h.jsx("div",{className:"grid h-full place-items-center text-sm text-muted-foreground",children:k?"Send a message to create this thread.":r?"(empty session)":"Send a message to start a thread."}),N&&h.jsx("div",{className:"flex justify-center",children:h.jsx(J,{variant:"outline",size:"sm",onClick:()=>{var j;B.current=((j=be.current)==null?void 0:j.scrollHeight)??null,x(E=>(E??0)+100)},children:"Load 100 more"})}),S.map(j=>h.jsx("div",{"data-entry-id":j.id,className:"transition-shadow",children:j.kind==="user"?h.jsx(aM,{agentId:s,bubble:j}):h.jsx(lM,{agentId:s,bubble:j})},j.id))]}),Z==="raw"&&h.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:h.jsx(hM,{entries:(b==null?void 0:b.entries)??[]})}),h.jsx("div",{className:V("flex-1 overflow-y-auto",Z!=="usage"&&"hidden"),children:h.jsx(dM,{agentId:s,threadId:(r==null?void 0:r.threadId)??null,active:Z==="usage"})}),h.jsxs("div",{className:V("shrink-0 border-t bg-card p-3",Z!=="messages"&&"hidden"),children:[U.length>0&&h.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:U.map((j,E)=>h.jsx(gM,{file:j,onRemove:()=>Cs(E),disabled:de.isPending},`${j.name}-${E}`))}),h.jsxs("div",{className:"flex items-end gap-2",children:[h.jsx("input",{ref:fe,type:"file",multiple:!0,className:"hidden",onChange:j=>{const E=j.target.files?Array.from(j.target.files):[];j.target.value="",ns(E)}}),h.jsx(J,{variant:"outline",size:"icon",onClick:()=>{var j;return(j=fe.current)==null?void 0:j.click()},disabled:de.isPending||!M,"aria-label":"attach file",children:h.jsx(d1,{className:"size-4"})}),h.jsx(Gh,{value:Q,onChange:j=>K(j.target.value),placeholder:M?"Message the agent…":"Archived session — switch to the latest session to send messages",rows:1,disabled:!M,className:V("max-h-40 min-h-9 min-w-0 flex-1 resize-none"),onKeyDown:j=>{j.key==="Enter"&&!j.shiftKey&&!j.metaKey&&(j.preventDefault(),yt())}}),h.jsx(J,{variant:de.isPending?"secondary":"default",size:"icon",onClick:()=>de.isPending?null:yt(),disabled:!Lt,"aria-label":"send",children:de.isPending?h.jsx($e,{className:"size-4 animate-spin"}):h.jsx(Rp,{className:"size-4"})}),h.jsx(J,{variant:"ghost",size:"icon",onClick:()=>Fe.mutate(),disabled:!r,"aria-label":"abort",title:"Abort current batch",children:h.jsx(Yp,{className:"size-4"})})]}),h.jsx("div",{className:"px-1 pt-1 text-[10px] text-muted-foreground",children:M?h.jsxs(h.Fragment,{children:["Enter to send · Shift+Enter for newline · 📎 attaches to"," ",h.jsx("code",{children:"plugins/admin/inbox/"})]}):h.jsx(h.Fragment,{children:"Read-only — this is an archived session."})})]})]})]})}function Pl({active:s,onClick:e,icon:t,label:i}){return h.jsxs("button",{type:"button",onClick:e,className:V("inline-flex shrink-0 items-center gap-1.5 rounded-md px-2 py-1 text-[11px] font-medium transition-colors",s?"bg-primary/10 text-primary":"text-muted-foreground hover:bg-accent hover:text-foreground"),"aria-pressed":s,children:[h.jsx(t,{className:"size-3.5"}),i]})}function hM({entries:s}){const{theme:e}=Vr(),t=C.useMemo(()=>s.map(i=>JSON.stringify(i)).join(`
|
|
334
334
|
`),[s]);return s.length===0?h.jsx("div",{className:"grid h-full place-items-center text-sm text-muted-foreground",children:"(empty session)"}):h.jsx(nx,{value:t,height:"100%",readOnly:!0,theme:e==="dark"?ix:"light",extensions:[qN()],basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!0,tabSize:2},style:{height:"100%",fontSize:13}})}function dM({agentId:s,threadId:e,active:t}){const{data:i,isLoading:n,error:r}=Ie({queryKey:["usage",s,e],queryFn:()=>ee.readUsage(s,e),enabled:!!e&&t,refetchInterval:5e3});return e?n&&!i?h.jsx("div",{className:"grid h-full place-items-center p-6 text-sm text-muted-foreground",children:"Loading usage…"}):r?h.jsxs("div",{className:"p-6 text-sm text-destructive",children:["Failed to load usage: ",r.message]}):i?i.main.models.length===0?h.jsx("div",{className:"grid h-full place-items-center p-6 text-sm text-muted-foreground",children:"No usage recorded yet for this thread."}):h.jsx("div",{className:"space-y-6 p-4 sm:p-6",children:h.jsx(uM,{title:"This thread",agent:i.main})}):null:h.jsx("div",{className:"grid h-full place-items-center p-6 text-sm text-muted-foreground",children:"Select a thread to see usage."})}function uM({title:s,agent:e}){return h.jsxs("section",{children:[h.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-3",children:[h.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:s}),h.jsx(dx,{info:e.lastContext})]}),h.jsx(pM,{agent:e})]})}function dx({info:s}){if(!s||s.tokens<=0)return null;const{tokens:e,contextWindow:t,model:i}=s,n=t?Math.min(100,e/t*100):null,r=n===null?"bg-muted-foreground/40":n<50?"bg-emerald-500/80":n<75?"bg-amber-500/80":"bg-red-500/80",o=t?`${El(e)} / ${El(t)}`:El(e),a=i?`${o} — ${i}`:o;return h.jsxs("div",{className:"inline-flex items-center gap-1.5",title:a,"aria-label":`context usage ${a}`,children:[h.jsx("div",{className:"h-1.5 w-16 overflow-hidden rounded-full bg-muted",children:h.jsx("div",{className:V("h-full transition-all",r),style:{width:n===null?"100%":`${Math.max(2,n)}%`}})}),h.jsx("span",{className:"font-mono text-[10px] tabular-nums text-muted-foreground",children:o})]})}function El(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e4?`${Math.round(s/1e3)}k`:s>=1e3?`${(s/1e3).toFixed(1)}k`:String(s)}function fM(s){const e={input:0,output:0,cacheRead:0,cacheWrite:0,totalCost:0,costInput:0,costOutput:0,costCacheRead:0,costCacheWrite:0};for(const t of s.models)e.input+=t.input,e.output+=t.output,e.cacheRead+=t.cacheRead,e.cacheWrite+=t.cacheWrite,e.totalCost+=t.cost.total,e.costInput+=t.cost.input,e.costOutput+=t.cost.output,e.costCacheRead+=t.cost.cacheRead,e.costCacheWrite+=t.cost.cacheWrite;return e}function pM({agent:s}){if(s.models.length===0)return h.jsx("div",{className:"rounded-md border border-dashed px-3 py-2 text-xs text-muted-foreground",children:"no recorded model usage"});const e=fM(s);return h.jsx("div",{className:"overflow-x-auto rounded-md border",children:h.jsxs("table",{className:"w-full text-xs",children:[h.jsx("thead",{className:"bg-muted/40 text-muted-foreground",children:h.jsxs("tr",{className:"text-left",children:[h.jsx("th",{className:"px-3 py-2 font-medium",children:"Agent"}),h.jsx("th",{className:"px-3 py-2 font-medium",children:"Model"}),h.jsx("th",{className:"px-3 py-2 text-right font-medium",children:"Input"}),h.jsx("th",{className:"px-3 py-2 text-right font-medium",children:"Output"}),h.jsx("th",{className:"px-3 py-2 text-right font-medium",children:"Cache Write"}),h.jsx("th",{className:"px-3 py-2 text-right font-medium",children:"Cache Read"}),h.jsx("th",{className:"px-3 py-2 text-right font-medium",children:"Total Cost"})]})}),h.jsx("tbody",{children:s.models.map(t=>h.jsxs("tr",{className:"border-t align-top",children:[h.jsx("td",{className:"px-3 py-2 font-mono",children:s.agent}),h.jsx("td",{className:"px-3 py-2 font-mono",children:t.provider?`${t.provider}/${t.model}`:t.model}),h.jsx(Vs,{tokens:t.input,cost:t.cost.input}),h.jsx(Vs,{tokens:t.output,cost:t.cost.output}),h.jsx(Vs,{tokens:t.cacheWrite,cost:t.cost.cacheWrite}),h.jsx(Vs,{tokens:t.cacheRead,cost:t.cost.cacheRead}),h.jsx(Tf,{cost:t.cost.total})]},`${t.provider}/${t.model}`))}),h.jsx("tfoot",{children:h.jsxs("tr",{className:"border-t bg-muted/20 font-medium",children:[h.jsx("td",{className:"px-3 py-2",colSpan:2,children:"Total"}),h.jsx(Vs,{tokens:e.input,cost:e.costInput}),h.jsx(Vs,{tokens:e.output,cost:e.costOutput}),h.jsx(Vs,{tokens:e.cacheWrite,cost:e.costCacheWrite}),h.jsx(Vs,{tokens:e.cacheRead,cost:e.costCacheRead}),h.jsx(Tf,{cost:e.totalCost})]})})]})})}function Vs({tokens:s,cost:e}){return h.jsxs("td",{className:"whitespace-nowrap px-3 py-2 text-right font-mono",children:[h.jsx("div",{children:mM(s)}),h.jsx("div",{className:"text-[10px] text-muted-foreground",children:Yh(e)})]})}function Tf({cost:s}){return h.jsx("td",{className:"whitespace-nowrap px-3 py-2 text-right font-mono",children:Yh(s)})}function mM(s){return s.toLocaleString()}function Yh(s){return s===0?"$0":s<.01?`$${s.toFixed(4)}`:s<1?`$${s.toFixed(3)}`:`$${s.toFixed(2)}`}function gM({file:s,onRemove:e,disabled:t}){return h.jsxs("div",{className:"flex max-w-xs items-center gap-2 rounded-md border bg-background px-2 py-1.5 text-xs",children:[h.jsx("div",{className:"grid size-7 shrink-0 place-items-center rounded-md bg-primary/10 text-primary",children:h.jsx($p,{className:"size-4"})}),h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsx("div",{className:"truncate font-medium",children:s.name}),h.jsx("div",{className:"text-[10px] text-muted-foreground",children:xM(s.size)})]}),h.jsx("button",{type:"button",onClick:e,disabled:t,"aria-label":`remove ${s.name}`,className:"grid size-5 shrink-0 place-items-center rounded-full text-muted-foreground hover:bg-accent hover:text-foreground disabled:opacity-50",children:h.jsx(_i,{className:"size-3"})})]})}function xM(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function pr(s){var e;return s.activeSessionId??((e=s.sessions[0])==null?void 0:e.sessionId)??null}const Of="-§-[TASK]-§-";function yM(s){const e=s.lastIndexOf(Of);if(e<=0)return null;const t=s.slice(e+Of.length);return t?{parent:s.slice(0,e),slug:t}:null}function ux(s){const e=new Map(s.map(i=>[i.threadId,{row:i,label:i.threadId,children:[]}])),t=[];for(const i of e.values()){const n=yM(i.row.threadId),r=n?e.get(n.parent):void 0;n&&r?(i.label=n.slug,r.children.push(i)):t.push(i)}return t}function fx(s,e){const t=[];for(const i of s){if(i.row.threadId.toLowerCase().includes(e)){t.push(i);continue}const n=fx(i.children,e);n.length>0&&t.push({...i,children:n})}return t}function px(s,e=0){return s.flatMap(t=>[{node:t,depth:e},...px(t.children,e+1)])}const bM=["off","minimal","low","medium","high","xhigh"];function vM({agentId:s,threadId:e,modelOverride:t}){const i=Xe(),{data:n}=Ie({queryKey:["models"],queryFn:ee.getModels}),{data:r}=Ie({queryKey:["agent",s],queryFn:()=>ee.getAgent(s)}),o=we({mutationFn:d=>ee.setThreadModel(s,e,d),onSuccess:()=>i.invalidateQueries({queryKey:["threads",s]}),onError:d=>q.error(`model change failed: ${d.message}`)}),a=C.useMemo(()=>((n==null?void 0:n.providers)??[]).filter(d=>d.configured&&d.enabledModels.length>0),[n]);if(!n||!(r!=null&&r.agentJson))return null;const l=r.agentJson.model,c=t?`${t.provider}/${t.modelId}`:"";return h.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[h.jsxs("select",{value:c,onChange:d=>{const u=d.target.value;if(!u){o.mutate({provider:null,modelId:null});return}const f=u.indexOf("/");o.mutate({provider:u.slice(0,f),modelId:u.slice(f+1),thinkingLevel:(t==null?void 0:t.thinkingLevel)??null})},disabled:o.isPending,className:"min-w-0 max-w-[14rem] truncate rounded-md border border-input bg-background px-2 py-1 font-mono text-[11px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":"thread model",children:[h.jsxs("option",{value:"",children:["Agent default (",l.provider,"/",l.id,")"]}),a.map(d=>h.jsx("optgroup",{label:d.displayName,children:d.enabledModels.map(u=>h.jsx("option",{value:`${d.id}/${u}`,children:u},`${d.id}/${u}`))},d.id))]}),h.jsxs("select",{value:(t==null?void 0:t.thinkingLevel)??"",onChange:d=>t&&o.mutate({provider:t.provider,modelId:t.modelId,thinkingLevel:d.target.value||null}),disabled:!t||o.isPending,className:"rounded-md border border-input bg-background px-1.5 py-1 font-mono text-[11px] disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":"thread thinking level",title:t?"thinking level":"thinking level (override the model first)",children:[h.jsx("option",{value:"",children:"think: default"}),bM.map(d=>h.jsxs("option",{value:d,children:["think: ",d]},d))]})]})}function wM({sessions:s,selectedSessionId:e,activeSessionId:t,onSelect:i}){const n=C.useMemo(()=>{const r=[...s].sort((l,c)=>c.modified-l.modified);if(!t)return r;const o=r.find(l=>l.sessionId===t);if(!o)return r;const a=r.filter(l=>l.sessionId!==t);return[o,...a]},[s,t]);return n.length<=1?h.jsx("code",{className:"min-w-0 truncate",children:e}):h.jsxs(Kr,{children:[h.jsx(_r,{asChild:!0,children:h.jsxs("button",{type:"button",className:V("flex min-w-0 items-center gap-1 truncate rounded-md px-1.5 py-0.5 font-mono text-xs","hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),"aria-label":"select session",children:[h.jsx("span",{className:"min-w-0 truncate",children:e}),h.jsx(Vi,{className:"size-3 shrink-0 opacity-70"})]})}),h.jsx(Hn,{align:"start",className:"max-w-[min(28rem,90vw)]",children:n.map(r=>{const o=r.sessionId===e,a=r.sessionId===t;return h.jsxs(oi,{onSelect:()=>i(r.sessionId),className:"flex items-start gap-2",children:[h.jsx(s1,{className:V("mt-0.5 size-3.5 shrink-0",o?"opacity-100":"opacity-0")}),h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("code",{className:"truncate text-xs",children:r.sessionId}),a&&h.jsx("span",{className:"rounded bg-primary/15 px-1 py-px text-[9px] font-medium uppercase tracking-wider text-primary",children:"latest"})]}),h.jsx("div",{className:"text-[10px] text-muted-foreground",children:new Date(r.modified).toLocaleString()})]})]},r.sessionId)})})]})}function kM({threads:s,selected:e,onSelect:t}){const i=C.useMemo(()=>ux(s),[s]);if(s.length===0)return null;const n=e?e.threadId:"";return h.jsxs("label",{className:"flex min-w-0 flex-1 items-center gap-1.5 lg:hidden",children:[h.jsx(yr,{className:"size-4 shrink-0"}),h.jsxs("select",{value:n,onChange:r=>{const o=s.find(l=>l.threadId===r.target.value);if(!o)return;const a=pr(o);a&&t({threadId:o.threadId,sessionId:a})},className:"min-w-0 flex-1 truncate rounded-md border border-input bg-background px-2 py-1 font-mono text-[11px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":"select thread",children:[!e&&h.jsx("option",{value:"",children:"— pick a thread —"}),px(i).map(({node:r,depth:o})=>h.jsx("option",{value:r.row.threadId,children:o>0?`${" ".repeat(o*2)}↳ ${r.label}`:r.label},r.row.threadId))]})]})}function SM({threads:s,loading:e,selected:t,onSelect:i,onNewThread:n,onDeleteThread:r,deletingThreadId:o}){const[a,l]=C.useState(""),c=t&&t.sessionId===""&&!s.some(m=>m.threadId===t.threadId)?t.threadId:null,[d,u]=C.useState(new Set),f=m=>u(g=>{const x=new Set(g);return x.delete(m)||x.add(m),x}),p=C.useMemo(()=>{const m=a.trim().toLowerCase(),g=ux(s);return m?fx(g,m):g},[s,a]);return h.jsxs("div",{className:"hidden h-full min-h-0 flex-col lg:flex",children:[h.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2",children:[h.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Threads"}),h.jsxs("button",{type:"button",onClick:n,className:"inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":"new thread",children:[h.jsx(ah,{className:"size-3.5"}),"New"]})]}),h.jsx("div",{className:"px-3 pb-2",children:h.jsxs("div",{className:"relative",children:[h.jsx(Up,{className:"pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),h.jsx(at,{type:"text",value:a,onChange:m=>l(m.target.value),placeholder:"Search threads…","aria-label":"search threads",className:"h-8 pl-8 text-xs"})]})}),h.jsxs("div",{className:"flex-1 overflow-y-auto px-1 pb-2",children:[e&&h.jsx("div",{className:"px-3 py-1 text-xs text-muted-foreground",children:"loading…"}),c&&h.jsx(gx,{label:c,sublabel:"pending — send a message to create",lastContext:null,totalCost:0,selected:!0,onSelect:null,onDelete:()=>r(c),deleting:!1}),p.map(m=>h.jsx(mx,{node:m,depth:0,selectedThreadId:(t==null?void 0:t.threadId)??null,onSelect:i,onDeleteThread:r,deletingThreadId:o,collapsed:d,onToggle:f},m.row.threadId)),!e&&s.length===0&&!c&&h.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No threads yet. Send a message below to start one."}),!e&&s.length>0&&p.length===0&&h.jsxs("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:["No threads match “",a.trim(),"”."]})]})]})}function mx({node:s,depth:e,selectedThreadId:t,onSelect:i,onDeleteThread:n,deletingThreadId:r,collapsed:o,onToggle:a}){const{row:l,children:c}=s,d=pr(l),u=o.has(l.threadId);return h.jsxs("div",{children:[h.jsx(gx,{label:s.label,sublabel:d?`${d.slice(0,18)}…`:null,lastContext:l.lastContext,totalCost:l.totalCost,selected:!!d&&t===l.threadId,onSelect:d?()=>i({threadId:l.threadId,sessionId:d}):null,onDelete:()=>n(l.threadId),deleting:r===l.threadId,depth:e,collapsed:u,onToggle:c.length>0?()=>a(l.threadId):null}),!u&&c.map(f=>h.jsx(mx,{node:f,depth:e+1,selectedThreadId:t,onSelect:i,onDeleteThread:n,deletingThreadId:r,collapsed:o,onToggle:a},f.row.threadId))]})}function gx({label:s,sublabel:e,lastContext:t,totalCost:i,selected:n,onSelect:r,onDelete:o,deleting:a,depth:l=0,collapsed:c=!1,onToggle:d=null}){return h.jsxs("div",{className:V("group relative mb-1 flex items-center gap-1 rounded-md transition-colors",l>0&&"border-l border-border",n?"bg-primary/10 text-primary":"text-muted-foreground hover:bg-accent"),style:l>0?{marginLeft:l*12}:void 0,children:[d?h.jsx("button",{type:"button",onClick:d,"aria-label":c?"expand task threads":"collapse task threads","aria-expanded":!c,className:"ml-1 grid size-4 shrink-0 place-items-center rounded text-muted-foreground/70 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:h.jsx(Vi,{className:V("size-3 transition-transform",c&&"-rotate-90")})}):h.jsx("span",{className:"ml-1 size-4 shrink-0"}),h.jsxs("button",{type:"button",onClick:r??void 0,disabled:!r,className:V("min-w-0 flex-1 truncate py-1.5 pl-1 pr-3 text-left",!r&&"cursor-default"),title:e??"no active session",children:[h.jsx("div",{className:"truncate font-mono text-xs text-foreground/90",children:s}),e&&h.jsx("div",{className:V("truncate font-mono text-[10px]",n?"text-primary/70":"text-muted-foreground"),children:e}),(t||i!=null&&i>0)&&h.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5",children:[t&&h.jsx(dx,{info:t}),i!=null&&i>0&&h.jsx("span",{className:"font-mono text-[10px] tabular-nums text-muted-foreground",title:"Total spend for this thread",children:Yh(i)})]})]}),h.jsx("button",{type:"button",onClick:u=>{u.stopPropagation(),o()},disabled:a,"aria-label":`delete thread ${s}`,title:"Delete thread",className:V("mr-1 grid size-6 shrink-0 place-items-center rounded text-muted-foreground/70","opacity-0 transition-opacity hover:bg-destructive/10 hover:text-destructive focus-visible:opacity-100 group-hover:opacity-100","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",a&&"opacity-100"),children:a?h.jsx($e,{className:"size-3.5 animate-spin"}):h.jsx(Wn,{className:"size-3.5"})})]})}const Pf=100,Yc=[{key:"select",width:36},{key:"actions",width:56},{key:"id",width:64},{key:"created",width:130},{key:"updated",width:130},{key:"status",width:120},{key:"error",width:280},{key:"plugin",width:96},{key:"channel",width:140},{key:"thread",width:160},{key:"silent",width:48},{key:"noSteer",width:60},{key:"text",width:280},{key:"metadata",width:200},{key:"chat",width:80}],CM=Yc.reduce((s,e)=>s+e.width,0),jM=["queued","in_flight","done","failed","cancelled"],xx=["queued","done","failed","cancelled"];async function Dl(s,e){const t=await Promise.allSettled(s.map(e));return{total:s.length,ok:t.filter(i=>i.status==="fulfilled").length}}function NM({agentId:s}){const e=Xe(),[t,i]=C.useState(""),[n,r]=C.useState(""),[o,a]=C.useState([]),[l,c]=C.useState(""),[d,u]=C.useState("all"),[f,p]=C.useState(""),[m,g]=C.useState(""),[x,b]=C.useState(""),[S,N]=C.useState(""),[y,w]=C.useState("updated_at"),[k,M]=C.useState("desc"),[P,L]=C.useState(0),[H,F]=C.useState(new Set);C.useEffect(()=>{const j=setTimeout(()=>r(t.trim()),300);return()=>clearTimeout(j)},[t]),C.useEffect(()=>{L(0),F(new Set)},[n,o,l,d,f,m,x,S,y,k]),C.useEffect(()=>{F(new Set)},[P]);const O={status:o.length?o:void 0,plugin:l||void 0,search:n||void 0,isSilent:d==="silent"?!0:d==="non_silent"?!1:void 0,tsFrom:Ro(f),tsTo:Ro(m),updatedFrom:Ro(x),updatedTo:Ro(S),sortBy:y,sortDir:k,limit:Pf,offset:P},{data:Q,isLoading:K}=Ie({queryKey:["events",s,O],queryFn:()=>ee.listEvents(s,O),refetchInterval:2e3,placeholderData:iy}),U=C.useMemo(()=>(Q==null?void 0:Q.events)??[],[Q]),ae=(Q==null?void 0:Q.total)??0,fe=C.useMemo(()=>[...new Set(U.map(j=>j.pluginId))].sort(),[U]),be=j=>{a(E=>E.includes(j)?E.filter(he=>he!==j):[...E,j])},B=j=>{j===y?M(E=>E==="asc"?"desc":"asc"):(w(j),M("desc"))},ce=!!(f||m||x||S),me=()=>{p(""),g(""),b(""),N("")},Z=()=>e.invalidateQueries({queryKey:["events",s]}),se=(j,E)=>{F(he=>{const De=new Set(he);return E?De.add(j):De.delete(j),De})},_=C.useMemo(()=>U.map(j=>j.id),[U]),de=C.useMemo(()=>_.filter(j=>H.has(j)).length,[_,H]),Fe=_.length>0&&de===_.length,pe=de>0&&!Fe,gt=()=>{F(j=>{const E=new Set(j);if(Fe)for(const he of _)E.delete(he);else for(const he of _)E.add(he);return E})},Ae=C.useMemo(()=>U.filter(j=>H.has(j.id)),[U,H]),xt=Ae.filter(j=>j.status==="in_flight"),yt=Ae.filter(j=>j.status!=="in_flight"),ns=we({mutationFn:j=>Dl(yt.map(E=>E.id),E=>ee.setEventStatus(s,E,j)),onSuccess:({total:j,ok:E},he)=>{j===0?q.message("no eligible rows (in_flight rows skipped)"):E===j?q.success(`status → ${he} (${E})`):q.warning(`status → ${he} (${E}/${j})`),F(new Set),Z()},onError:j=>q.error(j.message)}),Cs=we({mutationFn:()=>Dl(yt.map(j=>j.id),j=>ee.discardEvent(s,j)),onSuccess:({total:j,ok:E})=>{j===0?q.message("no eligible rows (in_flight rows skipped)"):E===j?q.success(`deleted ${E}`):q.warning(`deleted ${E}/${j}`),F(new Set),Z()},onError:j=>q.error(j.message)}),Lt=we({mutationFn:()=>Dl([...new Set(xt.map(j=>j.threadId))],j=>ee.abortChat(s,j)),onSuccess:({total:j,ok:E})=>{j===0?q.message("no in_flight rows selected"):E===j?q.success(`abort sent to ${E} thread${E===1?"":"s"}`):q.warning(`abort: ${E}/${j} threads`),F(new Set),Z()},onError:j=>q.error(j.message)});return h.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-3",children:[h.jsx(MM,{searchInput:t,onSearchInput:i,statuses:o,onToggleStatus:be,plugin:l,pluginOptions:fe,onPluginChange:c,silent:d,onSilentChange:u}),h.jsx(RM,{tsFrom:f,tsTo:m,updatedFrom:x,updatedTo:S,onTsFrom:p,onTsTo:g,onUpdatedFrom:b,onUpdatedTo:N,anyRangeSet:ce,onClear:me}),H.size>0&&h.jsx(AM,{selectedCount:H.size,inFlightCount:xt.length,notInFlightCount:yt.length,busy:ns.isPending||Cs.isPending||Lt.isPending,onSetStatus:j=>ns.mutate(j),onAbort:()=>Lt.mutate(),onDelete:()=>Cs.mutate(),onClear:()=>F(new Set)}),h.jsx("div",{className:"min-h-0 flex-1 overflow-auto rounded-md border",children:h.jsxs("table",{className:"w-full table-fixed text-xs",style:{minWidth:CM},children:[h.jsx("colgroup",{children:Yc.map(j=>h.jsx("col",{style:{width:j.width}},j.key))}),h.jsx("thead",{className:"sticky top-0 z-10 bg-card",children:h.jsxs("tr",{className:"border-b text-left",children:[h.jsx(ls,{className:"text-center",children:h.jsx(yx,{checked:Fe,indeterminate:pe,onChange:gt,disabled:_.length===0,ariaLabel:"Select all rows on this page"})}),h.jsx(ls,{children:"Actions"}),h.jsx(ls,{children:"#"}),h.jsx(tr,{col:"ts",sortBy:y,sortDir:k,onSort:B,children:"Created"}),h.jsx(tr,{col:"updated_at",sortBy:y,sortDir:k,onSort:B,children:"Updated"}),h.jsx(tr,{col:"status",sortBy:y,sortDir:k,onSort:B,children:"Status"}),h.jsx(ls,{children:"Error"}),h.jsx(tr,{col:"plugin_id",sortBy:y,sortDir:k,onSort:B,children:"Plugin"}),h.jsx(ls,{children:"Channel"}),h.jsx(tr,{col:"thread_id",sortBy:y,sortDir:k,onSort:B,children:"Thread"}),h.jsx(ls,{children:"Silent"}),h.jsx(ls,{children:"No-Steer"}),h.jsx(ls,{children:"Text"}),h.jsx(ls,{children:"Metadata"}),h.jsx(ls,{children:"Chat"})]})}),h.jsxs("tbody",{children:[U.map(j=>h.jsx(TM,{agentId:s,row:j,selected:H.has(j.id),onToggleSelect:E=>se(j.id,E)},j.id)),!K&&U.length===0&&h.jsx("tr",{children:h.jsx("td",{colSpan:Yc.length,className:"px-3 py-8 text-center text-muted-foreground",children:"No events match the current filters."})})]})]})}),h.jsx(IM,{total:ae,offset:P,pageSize:Pf,onChange:L})]})}function MM({searchInput:s,onSearchInput:e,statuses:t,onToggleStatus:i,plugin:n,pluginOptions:r,onPluginChange:o,silent:a,onSilentChange:l}){return h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[h.jsx(at,{placeholder:"Search text / metadata…",value:s,onChange:c=>e(c.target.value),className:"h-8 w-64 text-xs"}),h.jsx("div",{className:"flex flex-wrap items-center gap-1",children:jM.map(c=>{const d=t.includes(c);return h.jsx("button",{type:"button",onClick:()=>i(c),className:V("rounded-md border px-2 py-0.5 text-[11px] font-medium transition-colors",d?DM(c):"border-transparent bg-muted text-muted-foreground hover:bg-accent"),children:c},c)})}),h.jsxs("select",{value:n,onChange:c=>o(c.target.value),className:"h-8 rounded-md border bg-background px-2 text-xs",children:[h.jsx("option",{value:"",children:"all plugins"}),r.map(c=>h.jsx("option",{value:c,children:c},c))]}),h.jsxs("select",{value:a,onChange:c=>l(c.target.value),className:"h-8 rounded-md border bg-background px-2 text-xs",title:"Silent filter",children:[h.jsx("option",{value:"all",children:"silent: any"}),h.jsx("option",{value:"silent",children:"silent only"}),h.jsx("option",{value:"non_silent",children:"non-silent only"})]})]})}function yx({checked:s,indeterminate:e,onChange:t,disabled:i,ariaLabel:n}){const r=C.useRef(null);return C.useEffect(()=>{r.current&&(r.current.indeterminate=!!e&&!s)},[e,s]),h.jsx("input",{ref:r,type:"checkbox",className:"size-3.5 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50",checked:s,disabled:i,onChange:o=>t(o.target.checked),onClick:o=>o.stopPropagation(),"aria-label":n})}function AM({selectedCount:s,inFlightCount:e,notInFlightCount:t,busy:i,onSetStatus:n,onAbort:r,onDelete:o,onClear:a}){return h.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-md border bg-accent/30 px-3 py-1.5 text-xs",children:[h.jsxs("span",{className:"font-medium",children:[s," selected",e>0&&h.jsxs("span",{className:"ml-1 text-[10px] text-muted-foreground",children:["(",e," in_flight)"]})]}),h.jsxs(Kr,{children:[h.jsx(_r,{asChild:!0,children:h.jsxs(J,{size:"sm",variant:"outline",className:"h-7 gap-1 text-xs",disabled:i||t===0,title:t===0?"No eligible (non-in_flight) rows":"Set status for non-in_flight rows",children:["Set status",h.jsx(Vi,{className:"size-3"})]})}),h.jsx(Hn,{align:"start",className:"min-w-[8rem]",children:xx.map(l=>h.jsx(oi,{onSelect:()=>n(l),className:"text-xs",children:h.jsx(Ko,{status:l})},l))})]}),h.jsxs(J,{size:"sm",variant:"outline",className:"h-7 gap-1 text-xs text-warning hover:text-warning",disabled:i||e===0,onClick:r,title:e===0?"No in_flight rows selected":`Abort ${e} in_flight row${e===1?"":"s"} (dedup by thread)`,children:[h.jsx(Ip,{className:"size-3"})," Abort"]}),h.jsxs(J,{size:"sm",variant:"outline",className:"h-7 gap-1 text-xs text-destructive hover:text-destructive",disabled:i||t===0,onClick:o,title:t===0?"No eligible (non-in_flight) rows":`Delete ${t} row${t===1?"":"s"}`,children:[h.jsx(Wn,{className:"size-3"})," Delete"]}),h.jsx(J,{size:"sm",variant:"ghost",className:"ml-auto h-7 px-2 text-xs",onClick:a,disabled:i,children:"Clear"})]})}function ls({children:s,className:e}){return h.jsx("th",{className:V("whitespace-nowrap px-3 py-2 text-[11px] font-medium text-muted-foreground",e),children:s})}function tr({col:s,sortBy:e,sortDir:t,onSort:i,children:n}){const r=e===s;return h.jsx("th",{className:"whitespace-nowrap px-3 py-2 text-[11px] font-medium text-muted-foreground",children:h.jsxs("button",{type:"button",onClick:()=>i(s),className:V("inline-flex items-center gap-1 transition-colors hover:text-foreground",r&&"text-foreground"),children:[n,r?t==="asc"?h.jsx(Rp,{className:"size-3"}):h.jsx(Xb,{className:"size-3"}):h.jsx(Zb,{className:"size-3 opacity-50"})]})})}function TM({agentId:s,row:e,selected:t,onToggleSelect:i}){const n=Xe(),r=()=>n.invalidateQueries({queryKey:["events",s]}),o=we({mutationFn:u=>ee.setEventStatus(s,e.id,u),onSuccess:(u,f)=>{q.success(f==="queued"?"requeued":`status → ${f}`),r()},onError:u=>q.error(u.message)}),a=we({mutationFn:()=>ee.discardEvent(s,e.id),onSuccess:()=>{q.success("deleted"),r()},onError:u=>q.error(u.message)}),l=we({mutationFn:()=>ee.abortChat(s,e.threadId),onSuccess:u=>{u.ok?q.info("abort sent"):q.message("nothing in flight"),r()},onError:u=>q.error(u.message)}),c=e.metadata?JSON.stringify(e.metadata):"",d=e.status==="in_flight";return h.jsxs("tr",{className:"border-b last:border-b-0 hover:bg-accent/50",children:[h.jsx("td",{className:"whitespace-nowrap px-3 py-1.5 text-center",children:h.jsx(yx,{checked:t,onChange:u=>i(u),ariaLabel:`Select row ${e.id}`})}),h.jsx("td",{className:"whitespace-nowrap px-3 py-1.5",children:d?h.jsx(J,{size:"sm",variant:"ghost",className:"h-6 px-1.5 text-warning",onClick:()=>l.mutate(),disabled:l.isPending,title:"Abort this batch",children:h.jsx(Ip,{className:"size-3"})}):h.jsx(J,{size:"sm",variant:"ghost",className:"h-6 px-1.5 text-destructive",onClick:()=>a.mutate(),disabled:a.isPending,title:"Delete row",children:h.jsx(Wn,{className:"size-3"})})}),h.jsx("td",{className:"px-3 py-1.5 font-mono text-[11px] text-muted-foreground",children:e.id}),h.jsx("td",{className:"whitespace-nowrap px-3 py-1.5 text-[11px] text-muted-foreground",children:Go(e.ts)}),h.jsx("td",{className:"whitespace-nowrap px-3 py-1.5 text-[11px] text-muted-foreground",children:Go(e.updatedAt)}),h.jsxs("td",{className:"whitespace-nowrap px-3 py-1.5",children:[h.jsx(PM,{status:e.status,disabled:d||o.isPending,onChange:u=>{u!==e.status&&o.mutate(u)}}),e.attempts>0&&h.jsxs("span",{className:"ml-1 text-[10px] text-muted-foreground",children:["·",e.attempts]})]}),h.jsx("td",{className:"px-3 py-1.5",children:h.jsx(Yi,{text:e.error,children:h.jsx(OM,{error:e.error})})}),h.jsx("td",{className:"px-3 py-1.5 font-mono text-[11px]",children:h.jsx(Yi,{text:e.pluginId,children:e.pluginId})}),h.jsx("td",{className:"px-3 py-1.5 font-mono text-[11px] text-muted-foreground",children:h.jsx(Yi,{text:e.channelId,children:e.channelId})}),h.jsx("td",{className:"px-3 py-1.5 font-mono text-[11px] text-muted-foreground",children:h.jsx(Yi,{text:e.threadId,children:e.threadId})}),h.jsx("td",{className:"px-3 py-1.5 text-center text-muted-foreground",children:e.isSilent?"•":""}),h.jsx("td",{className:"px-3 py-1.5 text-center text-muted-foreground",title:e.doNotSteer?"doNotSteer: never steered into a live batch":void 0,children:e.doNotSteer?"•":""}),h.jsx("td",{className:"px-3 py-1.5",children:h.jsx(Yi,{text:e.text,children:e.text})}),h.jsx("td",{className:"px-3 py-1.5 font-mono text-[10px] text-muted-foreground",children:h.jsx(Yi,{text:c,children:c})}),h.jsx("td",{className:"whitespace-nowrap px-3 py-1.5",children:e.piSessionId&&e.piEntryId?h.jsxs(Rt,{to:`/agents/${s}/chat?thread=${encodeURIComponent(e.threadId)}&session=${encodeURIComponent(e.piSessionId)}&entry=${encodeURIComponent(e.piEntryId)}`,className:"inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] text-primary hover:bg-primary/10",title:`Open in chat
|
|
335
335
|
session ${e.piSessionId}
|
|
336
|
-
entry ${e.piEntryId}`,children:[h.jsx(yr,{className:"size-3"}),"open"]}):h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"—"})})]})}function Ko({status:s}){const e=EM(s);return h.jsx(rt,{variant:e,children:s})}function OM({error:s}){if(!s)return h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"—"});const e=/^\[([^\]]+)\]\s*(.*)$/.exec(s),t=e?e[1]:null,i=e?e[2]:s;return h.jsxs("div",{className:"flex items-center gap-1.5 overflow-hidden",children:[t&&h.jsx(rt,{variant:"outline",className:"shrink-0 font-mono text-[10px]",children:t}),h.jsx("span",{className:"truncate text-[11px] text-muted-foreground",children:i})]})}function Yi({text:s,className:e,children:t}){return s?h.jsxs(_b,{children:[h.jsx(Ub,{asChild:!0,children:h.jsx("div",{className:V("truncate",e),children:t})}),h.jsx(Op,{side:"bottom",align:"start",className:"max-w-[60ch] whitespace-pre-wrap break-words",children:s})]}):h.jsx("div",{className:V("truncate",e),children:t})}function PM({status:s,disabled:e,onChange:t}){return e?h.jsx(Ko,{status:s}):h.jsxs(Kr,{children:[h.jsx(_r,{asChild:!0,children:h.jsxs("button",{type:"button",className:"inline-flex items-center gap-0.5 rounded-md outline-none focus-visible:ring-2 focus-visible:ring-ring",title:"Change status",children:[h.jsx(Ko,{status:s}),h.jsx(Vi,{className:"size-3 text-muted-foreground"})]})}),h.jsx(Hn,{align:"start",className:"min-w-[8rem]",children:xx.map(i=>h.jsx(oi,{disabled:i===s,onSelect:()=>t(i),className:"text-xs",children:h.jsx(Ko,{status:i})},i))})]})}function EM(s){switch(s){case"queued":return"secondary";case"in_flight":return"warning";case"done":return"success";case"failed":return"destructive";case"cancelled":return"outline"}}function DM(s,e){switch(s){case"queued":return"border-transparent bg-secondary text-secondary-foreground";case"in_flight":return"border-transparent bg-warning/15 text-warning";case"done":return"border-transparent bg-success/15 text-success";case"failed":return"border-transparent bg-destructive/15 text-destructive";case"cancelled":return"border-border bg-background text-foreground"}}function RM({tsFrom:s,tsTo:e,updatedFrom:t,updatedTo:i,onTsFrom:n,onTsTo:r,onUpdatedFrom:o,onUpdatedTo:a,anyRangeSet:l,onClear:c}){return h.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[h.jsx(Ef,{label:"Created",from:s,to:e,onFrom:n,onTo:r}),h.jsx(Ef,{label:"Updated",from:t,to:i,onFrom:o,onTo:a}),l&&h.jsxs(J,{size:"sm",variant:"ghost",className:"h-6 px-1.5 text-[11px]",onClick:c,children:[h.jsx(_i,{className:"size-3"})," Clear"]})]})}function Ef({label:s,from:e,to:t,onFrom:i,onTo:n}){return h.jsxs("div",{className:"inline-flex items-center gap-1",children:[h.jsx("span",{className:"text-[10px] uppercase tracking-wider",children:s}),h.jsx("input",{type:"datetime-local",value:e,onChange:r=>i(r.target.value),className:"h-7 rounded-md border bg-background px-1.5 text-[11px] text-foreground"}),h.jsx("span",{children:"→"}),h.jsx("input",{type:"datetime-local",value:t,onChange:r=>n(r.target.value),className:"h-7 rounded-md border bg-background px-1.5 text-[11px] text-foreground"})]})}function Ro(s){if(!s)return;const e=new Date(s).getTime();return Number.isFinite(e)?e:void 0}function IM({total:s,offset:e,pageSize:t,onChange:i}){const n=s===0?0:e+1,r=Math.min(e+t,s),o=e>0,a=e+t<s;return h.jsxs("div",{className:"flex items-center justify-between text-[11px] text-muted-foreground",children:[h.jsx("span",{children:s===0?"no events":`${n}–${r} of ${s}`}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx(J,{size:"sm",variant:"ghost",className:"h-7 px-2",disabled:!o,onClick:()=>i(Math.max(0,e-t)),children:"Prev"}),h.jsx(J,{size:"sm",variant:"ghost",className:"h-7 px-2",disabled:!a,onClick:()=>i(e+t),children:"Next"}),e>0&&h.jsx(J,{size:"sm",variant:"ghost",className:"h-7 px-2",onClick:()=>i(0),title:"Back to top",children:h.jsx(_i,{className:"size-3"})})]})]})}function bx({schema:s,value:e,onChange:t}){return VM(s)?h.jsx(vx,{schema:s,value:wx(e)?e:{},onChange:t}):h.jsx(Jc,{value:e,onChange:t})}function vx({schema:s,value:e,onChange:t,depth:i=0}){const n=s.properties??{},r=new Set(s.required??[]),o=Object.keys(n);return o.length===0?h.jsx(rt,{variant:"outline",className:"w-fit",children:"no fields declared"}):h.jsx("div",{className:V("grid gap-3",i===0&&"sm:grid-cols-2"),children:o.map(a=>{var u;const l=n[a],c=Qa(l),d=c==="object"||c==="array"||c==="string"&&(((u=l.description)==null?void 0:u.length)??0)>60;return h.jsxs("div",{className:V("flex flex-col gap-1.5",d&&"sm:col-span-2"),children:[h.jsx(LM,{name:a,schema:l,required:r.has(a)}),h.jsx(BM,{schema:l,value:e[a],onChange:f=>t({...e,[a]:f}),depth:i+1})]},a)})})}function LM({name:s,schema:e,required:t}){return h.jsxs("div",{className:"flex flex-col",children:[h.jsxs(It,{className:"font-mono text-xs",children:[s,t&&h.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.description&&h.jsx("span",{className:"text-[11px] text-muted-foreground",children:e.description})]})}function BM({schema:s,value:e,onChange:t,depth:i}){var r;const n=Qa(s);if(Array.isArray(s.enum))return h.jsx(WM,{options:s.enum.map(String),value:e==null?"":String(e),onChange:o=>t(KM(s,o))});if(n==="boolean")return h.jsx($M,{value:!!e,onChange:t});if(n==="integer"||n==="number")return h.jsx(FM,{schema:s,value:e,onChange:t,integer:n==="integer"});if(n==="string")return h.jsx(zM,{value:typeof e=="string"?e:"",onChange:t});if(n==="array"&&((r=s.items)==null?void 0:r.type)==="string")return h.jsx(HM,{value:Array.isArray(e)?e.map(String):[],onChange:t});if(n==="object"){const o=!s.properties||Object.keys(s.properties).length===0,a=s.additionalProperties!==void 0&&s.additionalProperties!==!1;return o&&a?h.jsx(Jc,{value:e,onChange:t}):h.jsx(qM,{schema:s,value:wx(e)?e:{},onChange:t,depth:i})}return h.jsx(Jc,{value:e,onChange:t})}function zM({value:s,onChange:e}){return h.jsx(at,{value:s,onChange:t=>e(t.target.value),className:"font-mono text-xs"})}function FM({schema:s,value:e,onChange:t,integer:i}){return h.jsx(at,{type:"number",value:e??"",step:i?1:"any",min:s.minimum,max:s.maximum,onChange:n=>{const r=n.target.value;if(r==="")return t(void 0);const o=i?Number.parseInt(r,10):Number.parseFloat(r);t(Number.isFinite(o)?o:void 0)},className:"font-mono text-xs"})}function $M({value:s,onChange:e}){return h.jsxs("label",{className:"flex w-fit cursor-pointer items-center gap-2 rounded-md border px-3 py-1.5 text-xs transition-colors hover:bg-accent/40",children:[h.jsx("input",{type:"checkbox",checked:s,onChange:t=>e(t.target.checked),className:"size-4 accent-primary"}),h.jsx("span",{children:s?"true":"false"})]})}function WM({options:s,value:e,onChange:t}){return h.jsxs("div",{className:"relative",children:[h.jsxs("select",{value:e,onChange:i=>t(i.target.value),className:V("h-9 w-full appearance-none rounded-md border border-input bg-background px-3 pr-8 font-mono text-xs shadow-sm transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"),children:[!s.includes(e)&&h.jsx("option",{value:"",children:"— select —"}),s.map(i=>h.jsx("option",{value:i,children:i},i))]}),h.jsx(Vi,{className:"pointer-events-none absolute right-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"})]})}function HM({value:s,onChange:e}){const[t,i]=C.useState(""),n=()=>{const o=t.trim();if(o){if(s.includes(o)){i("");return}e([...s,o]),i("")}},r=o=>e(s.filter((a,l)=>l!==o));return h.jsxs("div",{className:"flex flex-col gap-2",children:[h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx(at,{value:t,onChange:o=>i(o.target.value),placeholder:"add an entry…",className:"font-mono text-xs",onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),n())}}),h.jsx(J,{type:"button",variant:"outline",size:"icon",onClick:n,"aria-label":"add",children:h.jsx(ah,{className:"size-4"})})]}),s.length>0&&h.jsx("div",{className:"flex flex-wrap gap-1",children:s.map((o,a)=>h.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border bg-secondary px-2 py-0.5 font-mono text-[11px]",children:[o,h.jsx("button",{type:"button",onClick:()=>r(a),"aria-label":`remove ${o}`,className:"text-muted-foreground hover:text-foreground",children:h.jsx(_i,{className:"size-3"})})]},`${o}-${a}`))})]})}function qM({schema:s,value:e,onChange:t,depth:i}){return h.jsx("div",{className:"rounded-md border bg-muted/20 p-3",children:h.jsx(vx,{schema:s,value:e,onChange:t,depth:i})})}function Jc({value:s,onChange:e}){const[t,i]=C.useState(()=>JSON.stringify(s??null,null,2)),[n,r]=C.useState(null);return h.jsxs("div",{children:[h.jsx("textarea",{value:t,onChange:o=>{i(o.target.value);try{const a=JSON.parse(o.target.value);r(null),e(a)}catch(a){r(a.message)}},rows:4,className:"block w-full rounded-md border bg-background px-2 py-1 font-mono text-[11px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"}),n&&h.jsxs("p",{className:"mt-1 text-[11px] text-destructive",children:["invalid JSON: ",n]})]})}function Qa(s){return Array.isArray(s.type)?s.type.find(e=>e!=="null"):s.type}function VM(s){return Qa(s)==="object"||!!s.properties}function wx(s){return!!s&&typeof s=="object"&&!Array.isArray(s)}function KM(s,e){const t=Qa(s);if(e!=="")return t==="integer"?Number.parseInt(e,10):t==="number"?Number.parseFloat(e):t==="boolean"?e==="true":e}function Rl(s){return s.split("/").pop()??s}const kx=[{service:"Gmail",scopes:[{scope:"https://www.googleapis.com/auth/gmail.modify",always:!0}]},{service:"Calendar",scopes:[{scope:"https://www.googleapis.com/auth/calendar"},{scope:"https://www.googleapis.com/auth/calendar.readonly"},{scope:"https://www.googleapis.com/auth/calendar.events"},{scope:"https://www.googleapis.com/auth/calendar.events.readonly"}]},{service:"Drive",scopes:[{scope:"https://www.googleapis.com/auth/drive"},{scope:"https://www.googleapis.com/auth/drive.file"},{scope:"https://www.googleapis.com/auth/drive.readonly"},{scope:"https://www.googleapis.com/auth/drive.metadata.readonly"}]},{service:"Docs",scopes:[{scope:"https://www.googleapis.com/auth/documents"},{scope:"https://www.googleapis.com/auth/documents.readonly"}]},{service:"Sheets",scopes:[{scope:"https://www.googleapis.com/auth/spreadsheets"},{scope:"https://www.googleapis.com/auth/spreadsheets.readonly"}]},{service:"Slides",scopes:[{scope:"https://www.googleapis.com/auth/presentations"},{scope:"https://www.googleapis.com/auth/presentations.readonly"}]},{service:"Contacts",scopes:[{scope:"https://www.googleapis.com/auth/contacts"},{scope:"https://www.googleapis.com/auth/contacts.readonly"},{scope:"https://www.googleapis.com/auth/contacts.other.readonly"}]},{service:"Tasks",scopes:[{scope:"https://www.googleapis.com/auth/tasks"},{scope:"https://www.googleapis.com/auth/tasks.readonly"}]}],Df=new Set(kx.flatMap(s=>s.scopes.filter(e=>!e.always).map(e=>e.scope)));function _M({agentId:s,plugin:e}){const t=Xe(),{data:i}=Ie({queryKey:["gws-oauth"],queryFn:ee.getGwsOauth}),[n,r]=C.useState(!1),[o,a]=C.useState(null);C.useEffect(()=>{const y=new URLSearchParams(window.location.search),w=y.get("gws"),k=y.get("gwsError");!w&&!k||(w&&q.success("Google sign-in complete"),k&&q.error(`Google sign-in failed: ${k}`),window.history.replaceState(null,"",window.location.pathname))},[]);const l=we({mutationFn:()=>ee.startGwsSignIn(s),onSuccess:({url:y})=>{window.location.href=y},onError:y=>q.error(`sign-in failed: ${y.message}`)}),c=we({mutationFn:()=>ee.gwsSignOut(s),onSuccess:()=>{q.success("Signed out of Google"),t.invalidateQueries({queryKey:["gws-oauth"]}),t.invalidateQueries({queryKey:["plugins",s]})},onError:y=>q.error(`sign-out failed: ${y.message}`)}),d=e.config??null,u=C.useMemo(()=>new Set(((d==null?void 0:d.oauthScopes)??"").split(",").map(y=>y.trim()).filter(Boolean)),[d==null?void 0:d.oauthScopes]),f=[...u].filter(y=>Df.has(y)),p=[...u].filter(y=>!Df.has(y)),m=o??u,g=o!==null&&[...o].sort().join(",")!==[...f].sort().join(","),x=(y,w)=>{a(k=>{const M=new Set(k??f);return w?M.add(y):M.delete(y),M})},b=i==null?void 0:i.agents.find(y=>y.agentId===s),S=we({mutationFn:()=>ee.putPluginConfig(s,"gws",{...d??{},oauthScopes:[...p,...o??[]].join(", ")}),onSuccess:()=>{q.success(b!=null&&b.signedIn?"Scopes saved — sign in again to apply":"Scopes saved"),a(null),t.invalidateQueries({queryKey:["plugins",s]})},onError:y=>q.error(`save failed: ${y.message}`)});if(!i||!b)return null;const N=i.client.clientId.length>0&&i.client.clientSecret.length>0;return h.jsxs("div",{className:"flex flex-col gap-2",children:[h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[h.jsx(Kp,{className:"size-3.5 text-primary/60"}),h.jsx("h3",{className:"text-sm font-medium",children:"Google account"}),h.jsxs("div",{className:"min-w-0 flex-1 truncate text-[11px] text-muted-foreground",children:[b.signedIn?b.email?`Signed in as ${b.email}`:"Signed in":"Not signed in",b.scopes.length>0&&h.jsxs(h.Fragment,{children:[" · ",b.scopes.filter(y=>y.includes("googleapis.com/auth/")&&!y.includes("/userinfo.")).map(Rl).join(", ")]})]}),h.jsxs(J,{size:"sm",variant:"ghost",onClick:()=>r(y=>!y),children:[h.jsx(On,{className:`size-4 transition-transform ${n?"rotate-90":""}`}),"Scopes"]}),b.signedIn?h.jsxs(J,{size:"sm",variant:"outline",disabled:c.isPending,onClick:()=>c.mutate(),children:[c.isPending?h.jsx($e,{className:"size-4 animate-spin"}):h.jsx(oh,{className:"size-4"}),"Sign out"]}):h.jsxs(J,{size:"sm",disabled:!N||l.isPending,onClick:()=>l.mutate(),title:N?void 0:"Save the OAuth client id and secret in Settings first",children:[l.isPending?h.jsx($e,{className:"size-4 animate-spin"}):h.jsx(tc,{className:"size-4"}),"Sign in with Google"]})]}),!N&&h.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["The shared Google OAuth client isn’t configured yet —"," ",h.jsx(Rt,{to:"/settings",className:"text-primary hover:underline",children:"save a client id and secret in Settings"})," ","first."]}),n&&h.jsxs("div",{className:"flex flex-col gap-3 border-t pt-3",children:[h.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Stored as ",h.jsx("code",{children:"oauthScopes"})," in this plugin’s config — changing scopes requires signing in again."," ",h.jsx("code",{children:"gmail.modify"})," is always requested: it is Google’s read/write Gmail tier (read, drafts, send, labels, mark-read — everything except permanent deletion), and the narrower Gmail scopes are subsets of it that would break inbox polling on their own."]}),h.jsx("div",{className:"grid gap-x-6 gap-y-2 sm:grid-cols-2 lg:grid-cols-4",children:kx.map(y=>h.jsxs("div",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:y.service}),y.scopes.map(w=>h.jsxs("label",{className:"flex cursor-pointer items-center gap-1.5 font-mono text-[11px]",title:w.scope,children:[h.jsx("input",{type:"checkbox",className:"accent-primary",checked:w.always||m.has(w.scope),disabled:w.always,onChange:k=>x(w.scope,k.target.checked)}),Rl(w.scope),w.always&&h.jsx("span",{className:"font-sans text-[10px] text-muted-foreground",children:"(always)"})]},w.scope))]},y.service))}),p.length>0&&h.jsxs("div",{className:"text-[11px] text-muted-foreground",children:["Also configured: ",p.map(Rl).join(", ")," (kept on save)"]}),h.jsx("div",{children:h.jsxs(J,{size:"sm",disabled:!g||S.isPending,onClick:()=>S.mutate(),children:[S.isPending?h.jsx($e,{className:"size-4 animate-spin"}):h.jsx(Ki,{className:"size-4"}),"Save scopes"]})})]})]})}const Ta="__CLEAR__",UM={properties:{name:{type:"string",description:"Display name shown in the UI."},model:{type:"object",description:"Model selection passed to pi --provider/--model/--thinking.",properties:{provider:{type:"string",description:"Provider id (e.g. anthropic, openai, google, openrouter)."},id:{type:"string",description:"Model id (e.g. claude-sonnet-4-5)."},thinkingLevel:{type:"string",enum:["off","minimal","low","medium","high","xhigh"],description:"Reasoning depth (provider permitting)."}}},threadIdStrategy:{type:"object",description:"How threads are derived from incoming notifications.",properties:{type:{type:"string",enum:["single","plugin","plugin_channel"]}}},maxConcurrentSlots:{type:"integer",minimum:1,description:"Parallel batches the runner may execute for this agent."},maxAttempts:{type:"integer",minimum:1,description:"Retries before a message moves to the dead-letter queue."}}};function QM({agentId:s}){const{hash:e}=Pa(),t=C.useRef(null),{data:i}=Ie({queryKey:["agent",s],queryFn:()=>ee.getAgent(s)}),{data:n}=Ie({queryKey:["plugins",s],queryFn:()=>ee.listPlugins(s)}),{data:r}=Ie({queryKey:["secrets"],queryFn:ee.getSecrets}),o=!!i&&!!n&&!!r;return C.useEffect(()=>{var c;if(!o||!e)return;const a=e.slice(1),l=(c=t.current)==null?void 0:c.querySelector(`[id="${CSS.escape(a)}"]`);l&&l.scrollIntoView({behavior:"smooth",block:"start"})},[o,e]),o?h.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[h.jsx("div",{className:"flex shrink-0 items-center gap-3 border-b px-4 py-2 sm:px-6",children:h.jsx("p",{className:"text-xs text-muted-foreground",children:"Settings · saves auto-reload the agent if it's running"})}),h.jsxs("div",{ref:t,className:"flex-1 overflow-y-auto p-4 sm:p-6",children:[h.jsx(GM,{}),h.jsxs("div",{className:"grid gap-6",children:[h.jsx(YM,{agentId:s,agentJson:i.agentJson,secrets:r}),n.plugins.map(a=>h.jsx(JM,{agentId:s,plugin:a,secrets:r},a.pluginId)),n.plugins.length===0&&h.jsx("p",{className:"text-sm text-muted-foreground",children:"No plugins installed."})]})]})]}):h.jsx("div",{className:"p-6 text-sm text-muted-foreground",children:"loading…"})}function GM(){return h.jsx(it,{className:"mb-6 border-warning/40 bg-warning/5",children:h.jsxs(ut,{className:"flex-row items-start gap-3",children:[h.jsx(Gp,{className:"mt-0.5 size-4 text-warning"}),h.jsxs("div",{children:[h.jsx(nt,{className:"text-sm",children:"Plaintext storage"}),h.jsxs(ft,{className:"mt-1",children:["Secrets are stored unencrypted in ",h.jsx("code",{children:"secrets.json"}),"; agent + plugin configuration is plain JSON on disk. v1 will encrypt secrets at rest."]})]})]})})}function YM({agentId:s,agentJson:e,secrets:t}){var l,c,d,u;const i=Xe(),{data:n}=Ie({queryKey:["models"],queryFn:ee.getModels}),r=we({mutationFn:f=>ee.putAgentConfig(s,f),onSuccess:()=>{q.success("saved · agent reloaded"),i.invalidateQueries({queryKey:["agent",s]})},onError:f=>q.error(`save failed: ${f.message}`)}),o=((c=(l=t.schemas)==null?void 0:l[s])==null?void 0:c[t.agentBucket])??null,a=((u=(d=t.secrets)==null?void 0:d[s])==null?void 0:u[t.agentBucket])??{};return h.jsxs(it,{children:[h.jsx(ut,{children:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(ws,{className:"size-4 text-primary/80"}),h.jsx(nt,{children:"Agent"}),h.jsx(rt,{variant:"outline",className:"font-mono",children:s})]})}),h.jsx(Zt,{}),h.jsxs("div",{className:"grid gap-5 p-4",children:[h.jsx(ZM,{initial:e,models:n??null,onSave:f=>r.mutate(f),saving:r.isPending}),h.jsx(Zt,{}),h.jsx(Sx,{agentId:s,bucketId:t.agentBucket,heading:"Secrets",icon:h.jsx(ws,{className:"size-3.5 text-primary/70"}),schema:o??{type:"object",properties:{}},existing:a,mask:t.mask,emptyHint:"No agent secrets declared. Add a `secretsSchema` block to agent.json to define agent-level secret keys."})]})]})}function JM({agentId:s,plugin:e,secrets:t}){var l,c,d,u,f,p,m;const i=Xe(),n=we({mutationFn:g=>ee.putPluginConfig(s,e.pluginId,g),onSuccess:()=>{q.success("saved · agent reloaded"),i.invalidateQueries({queryKey:["plugins",s]}),i.invalidateQueries({queryKey:["agent",s]})},onError:g=>q.error(`save failed: ${g.message}`)}),r=((c=(l=t.schemas)==null?void 0:l[s])==null?void 0:c[e.pluginId])??null,o=((u=(d=t.secrets)==null?void 0:d[s])==null?void 0:u[e.pluginId])??{},a=((f=e.manifest)==null?void 0:f.configSchema)??{type:"object",properties:{}};return h.jsxs(it,{id:`plugin-${e.pluginId}`,className:"scroll-mt-4",children:[h.jsxs(ut,{children:[h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[h.jsx(Yo,{className:"size-4 text-primary/80"}),h.jsx(nt,{children:((p=e.manifest)==null?void 0:p.displayName)||e.pluginId}),h.jsx(rt,{variant:"outline",className:"font-mono",children:e.pluginId}),e.state!=="running"&&h.jsx(rt,{variant:e.state==="failed"?"destructive":"secondary",children:e.state}),!e.manifest&&h.jsx(rt,{variant:"destructive",children:"unknown plugin"})]}),((m=e.manifest)==null?void 0:m.description)&&h.jsx(ft,{className:"mt-1",children:e.manifest.description})]}),h.jsx(Zt,{}),h.jsxs("div",{className:"grid gap-5 p-4",children:[e.pluginId==="gws"&&h.jsxs(h.Fragment,{children:[h.jsx(_M,{agentId:s,plugin:e}),h.jsx(Zt,{})]}),h.jsx(tA,{subtitle:`plugins/${e.pluginId}/config.json`,schema:a,initial:e.config,onSave:g=>n.mutate(g),saving:n.isPending}),(r==null?void 0:r.properties)&&Object.keys(r.properties).length>0&&h.jsxs(h.Fragment,{children:[h.jsx(Zt,{}),h.jsx(Sx,{agentId:s,bucketId:e.pluginId,heading:"Secrets",icon:h.jsx(Yo,{className:"size-3.5 text-primary/70"}),schema:r,existing:o,mask:t.mask})]})]})]})}const XM=["off","minimal","low","medium","high","xhigh"];function ZM({initial:s,models:e,onSave:t,saving:i}){const n=C.useMemo(()=>gn(s??{}),[s]),[r,o]=C.useState(()=>n);C.useEffect(()=>{o(gn(s??{}))},[s]);const a=C.useMemo(()=>JSON.stringify(r)!==JSON.stringify(n),[r,n]),l=r.model??{},c=u=>o(f=>({...f,model:{...f.model,...u}})),d=C.useMemo(()=>{const u=Object.fromEntries(Object.entries(UM.properties??{}).filter(([p])=>p!=="model")),f=n.configSchema;return f&&(u.config={...f,description:f.description??"Non-secret env vars exposed to the pi runtime (validated against configSchema in agent.json)."}),{type:"object",properties:u}},[n]);return h.jsxs("div",{children:[h.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[h.jsx(Fp,{className:"size-3.5 text-primary/60"}),h.jsx("h3",{className:"text-sm font-medium",children:"Configuration"}),h.jsx("code",{className:"text-[11px] text-muted-foreground",children:"agent.json"}),h.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[h.jsxs(J,{variant:"outline",size:"sm",onClick:()=>o(gn(s??{})),disabled:!a||i,children:[h.jsx(Da,{className:"size-3.5"})," Reset"]}),h.jsxs(J,{size:"sm",disabled:!a||i,onClick:()=>t(r),children:[i?h.jsx($e,{className:"size-4 animate-spin"}):h.jsx(Ki,{className:"size-4"}),"Save"]})]})]}),h.jsxs("div",{className:"grid gap-4",children:[h.jsx(eA,{models:e,value:l,onChange:c}),h.jsx(bx,{schema:d,value:r,onChange:u=>o(u)})]})]})}function eA({models:s,value:e,onChange:t,title:i="Model",hint:n="--provider / --model / --thinking"}){const r=C.useMemo(()=>((s==null?void 0:s.providers)??[]).filter(f=>f.configured&&f.enabledModels.length>0),[s]),o=C.useMemo(()=>{const f=new Map;for(const p of(s==null?void 0:s.providers)??[])f.set(p.id,p);return f},[s]),a=e.provider?o.get(e.provider):void 0,l=!!(a&&a.configured&&a.enabledModels.length>0),c=[...r];e.provider&&!c.find(f=>f.id===e.provider)&&a&&c.unshift(a);const d=a?a.enabledModels:[],u=!!e.id&&!!a&&!d.includes(e.id);return h.jsxs("div",{className:"rounded-md border bg-muted/20 p-3",children:[h.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[h.jsx(ws,{className:"size-3.5 text-primary/60"}),h.jsx("h4",{className:"text-sm font-medium",children:i}),h.jsx("span",{className:"text-[11px] text-muted-foreground",children:n}),h.jsx(Rt,{to:"/settings/models",className:"ml-auto text-[11px] text-primary hover:underline",children:"Manage providers →"})]}),s?r.length===0&&!e.provider?h.jsxs("p",{className:"text-xs text-muted-foreground",children:["No providers configured yet."," ",h.jsx(Rt,{to:"/settings/models",className:"text-primary hover:underline",children:"Add an API key and enable models"})," ","to choose one here."]}):h.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[h.jsxs("div",{className:"flex flex-col gap-1.5",children:[h.jsx(It,{className:"font-mono text-xs",children:"provider"}),h.jsx(Il,{options:c.map(f=>({value:f.id,label:f.displayName,hint:f.configured&&f.enabledModels.length>0?f.id:`${f.id} · not configured`})),value:e.provider??"",placeholder:"— select provider —",onChange:f=>t({provider:f||void 0,id:void 0})}),e.provider&&!l&&h.jsx("span",{className:"text-[10px] text-warning",children:"● provider has no key or no enabled models"})]}),h.jsxs("div",{className:"flex flex-col gap-1.5 sm:col-span-2",children:[h.jsx(It,{className:"font-mono text-xs",children:"model id"}),a?d.length===0?h.jsxs("p",{className:"text-[11px] text-warning",children:["no models enabled for this provider —"," ",h.jsx(Rt,{to:"/settings/models",className:"text-primary hover:underline",children:"enable some"})]}):h.jsx(Il,{options:[...u&&e.id?[{value:e.id,label:`${e.id} (not enabled)`,hint:"no longer in allowlist"}]:[],...d.map(f=>({value:f,label:f}))],value:e.id??"",placeholder:"— select model —",onChange:f=>t({id:f||void 0})}):h.jsx("p",{className:"text-[11px] text-muted-foreground",children:"pick a provider first"}),u&&h.jsx("span",{className:"text-[10px] text-warning",children:"● this model is no longer enabled in Models settings"})]}),h.jsxs("div",{className:"flex flex-col gap-1.5 sm:col-span-3",children:[h.jsx(It,{className:"font-mono text-xs",children:"thinkingLevel"}),h.jsx(Il,{options:XM.map(f=>({value:f,label:f})),value:e.thinkingLevel??"",placeholder:"— default —",onChange:f=>t({thinkingLevel:f||void 0})})]})]}):h.jsx("p",{className:"text-xs text-muted-foreground",children:"loading providers…"})]})}function Il({options:s,value:e,placeholder:t,onChange:i}){return h.jsxs("div",{className:"relative",children:[h.jsxs("select",{value:e,onChange:n=>i(n.target.value),className:V("h-9 w-full appearance-none rounded-md border border-input bg-background px-3 pr-8 font-mono text-xs shadow-sm transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"),children:[h.jsx("option",{value:"",children:t}),s.map(n=>h.jsxs("option",{value:n.value,children:[n.label,n.hint?` — ${n.hint}`:""]},n.value))]}),h.jsx(Vi,{className:"pointer-events-none absolute right-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"})]})}function tA({subtitle:s,schema:e,initial:t,onSave:i,saving:n}){const r=C.useMemo(()=>gn(t??{}),[t]),[o,a]=C.useState(r);C.useEffect(()=>{a(gn(t??{}))},[t]);const l=C.useMemo(()=>JSON.stringify(o)!==JSON.stringify(r),[o,r]);return h.jsxs("div",{children:[h.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[h.jsx(Fp,{className:"size-3.5 text-primary/60"}),h.jsx("h3",{className:"text-sm font-medium",children:"Configuration"}),h.jsx("code",{className:"text-[11px] text-muted-foreground",children:s}),h.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[h.jsxs(J,{variant:"outline",size:"sm",onClick:()=>a(gn(t??{})),disabled:!l||n,children:[h.jsx(Da,{className:"size-3.5"})," Reset"]}),h.jsxs(J,{size:"sm",disabled:!l||n,onClick:()=>i(o),children:[n?h.jsx($e,{className:"size-4 animate-spin"}):h.jsx(Ki,{className:"size-4"}),"Save"]})]})]}),h.jsx(bx,{schema:e,value:o,onChange:a})]})}function Sx({agentId:s,bucketId:e,heading:t,icon:i,schema:n,existing:r,mask:o,emptyHint:a}){const l=Xe(),[c,d]=C.useState({}),[u,f]=C.useState({}),p=we({mutationFn:y=>ee.putSecrets(y),onSuccess:()=>{q.success("saved · agent reloaded"),d({}),l.invalidateQueries({queryKey:["secrets"]}),l.invalidateQueries({queryKey:["agent",s]}),l.invalidateQueries({queryKey:["plugins",s]})},onError:y=>q.error(`save failed: ${y.message}`)}),m=Object.keys(c).length>0,g=n.properties??{},x=Object.keys(g),b=(y,w)=>d(k=>({...k,[y]:w})),S=y=>d(w=>({...w,[y]:Ta})),N=()=>{const y={};for(const[w,k]of Object.entries(c))y[w]=k===Ta?null:k;p.mutate({secrets:{[s]:{[e]:y}}})};return h.jsxs("div",{children:[h.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[h.jsx(x1,{className:"size-3.5 text-primary/60"}),i,h.jsx("h3",{className:"text-sm font-medium",children:t}),x.length>0&&h.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[h.jsxs(J,{variant:"outline",size:"sm",onClick:()=>d({}),disabled:!m||p.isPending,children:[h.jsx(Da,{className:"size-3.5"})," Reset"]}),h.jsxs(J,{size:"sm",onClick:N,disabled:!m||p.isPending,children:[p.isPending?h.jsx($e,{className:"size-4 animate-spin"}):h.jsx(Ki,{className:"size-4"}),"Save"]})]})]}),x.length===0?h.jsx("p",{className:"text-xs text-muted-foreground",children:a??"No secrets declared."}):h.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:x.map(y=>h.jsx(sA,{keyName:y,schema:g[y],present:!!r[y],draftVal:c[y],mask:o,revealed:!!u[`${s}/${e}/${y}`],onToggleReveal:()=>f(w=>({...w,[`${s}/${e}/${y}`]:!w[`${s}/${e}/${y}`]})),onChange:w=>b(y,w),onClear:()=>S(y)},y))})]})}function sA({keyName:s,schema:e,present:t,draftVal:i,mask:n,revealed:r,onToggleReveal:o,onChange:a,onClear:l}){const c=t?n:"(not set)",d=i===Ta;return h.jsxs("div",{className:"flex flex-col gap-1.5",children:[h.jsx(It,{className:"font-mono text-xs",children:s}),e.description&&h.jsx("span",{className:"text-[11px] text-muted-foreground",children:e.description}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx(at,{type:r?"text":"password",placeholder:c,value:d?"":i??"",onChange:u=>a(u.target.value),className:"font-mono text-xs"}),h.jsx(J,{type:"button",variant:"ghost",size:"icon",onClick:o,"aria-label":r?"hide":"reveal",children:r?h.jsx(Bp,{className:"size-4"}):h.jsx(zp,{className:"size-4"})}),t&&h.jsx(J,{type:"button",variant:"ghost",size:"sm",className:"text-[11px] text-destructive hover:text-destructive",onClick:l,disabled:d,children:"Clear"})]}),i&&i!==Ta&&h.jsx("span",{className:"text-[10px] text-warning",children:"● new value"}),d&&h.jsx("span",{className:"text-[10px] text-destructive",children:"● will be cleared"})]})}function gn(s){return structuredClone(s)}const iA=C.lazy(()=>z1(()=>import("./file-editor-CQSmlsy_.js"),__vite__mapDeps([0,1,2,3])).then(s=>({default:s.FileEditor})));function nA(){const{id:s=""}=tp(),{data:e}=Ie({queryKey:["agent",s],queryFn:()=>ee.getAgent(s),enabled:!!s,refetchInterval:3e3});return h.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[h.jsxs("header",{className:"flex flex-wrap items-center gap-3 border-b py-3 pl-14 pr-4 md:px-6",children:[h.jsx("div",{className:"grid size-8 place-items-center rounded-md bg-primary/10 text-primary",children:h.jsx(ws,{className:"size-4"})}),h.jsxs("div",{className:"min-w-0",children:[h.jsx("div",{className:"truncate text-sm font-semibold",children:(e==null?void 0:e.name)??s}),h.jsx("div",{className:"truncate font-mono text-[11px] text-muted-foreground",children:e!=null&&e.agentJson?`${e.agentJson.model.provider}/${e.agentJson.model.id}`:s})]}),h.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[e&&h.jsx(Xp,{state:e.state}),e&&h.jsx(D1,{agentId:s,state:e.state})]})]}),(e==null?void 0:e.state)==="failed"&&e.error&&h.jsx(lA,{message:e.error}),h.jsx(rA,{agentId:s}),h.jsx("div",{className:"flex-1 overflow-hidden",children:h.jsxs(ip,{children:[h.jsx(tt,{index:!0,element:h.jsx(on,{to:"chat",replace:!0})}),h.jsx(tt,{path:"chat",element:h.jsx(cM,{agentId:s})}),h.jsx(tt,{path:"files/*",element:h.jsx(oA,{agentId:s})}),h.jsx(tt,{path:"events",element:h.jsx("div",{className:"h-full p-4 sm:p-6",children:h.jsx(NM,{agentId:s})})}),h.jsx(tt,{path:"queue",element:h.jsx(on,{to:"../events",replace:!0})}),h.jsx(tt,{path:"plugins",element:h.jsx(aA,{agentId:s})}),h.jsx(tt,{path:"settings",element:h.jsx(QM,{agentId:s})}),h.jsx(tt,{path:"*",element:h.jsx(on,{to:"chat",replace:!0})})]})})]})}function rA({agentId:s}){const e=Pa(),t=[{to:`/agents/${s}/chat`,key:"chat",label:"Chat",icon:yr},{to:`/agents/${s}/files`,key:"files",label:"Files",icon:Hp},{to:`/agents/${s}/events`,key:"events",label:"Events",icon:Jb},{to:`/agents/${s}/plugins`,key:"plugins",label:"Plugins",icon:Yo},{to:`/agents/${s}/settings`,key:"settings",label:"Settings",icon:Qp}];return h.jsx("nav",{className:"flex shrink-0 gap-1 overflow-x-auto border-b px-3 py-1 sm:px-4",children:t.map(i=>{const n=e.pathname.startsWith(i.to),r=i.icon;return h.jsxs(Rt,{to:i.to,className:V("inline-flex shrink-0 items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",n?"bg-primary/10 text-primary":"text-muted-foreground hover:bg-accent hover:text-foreground"),children:[h.jsx(r,{className:"size-3.5"}),i.label]},i.key)})})}function oA({agentId:s}){const[e,t]=C.useState(null);return h.jsxs("div",{className:"flex h-full min-h-0 md:grid md:grid-cols-[minmax(220px,28%)_1fr]",children:[h.jsx("aside",{className:V("min-h-0 flex-1 overflow-y-auto border-r bg-card/50 md:flex-none",e&&"hidden md:block"),children:h.jsx($1,{agentId:s,selectedPath:e,onSelectFile:i=>t(i),onPathDeleted:i=>{e&&(e===i||e.startsWith(`${i}/`))&&t(null)}})}),h.jsx("section",{className:V("min-h-0 min-w-0 flex-1 flex-col md:flex",e?"flex":"hidden md:flex"),children:e?h.jsxs(h.Fragment,{children:[h.jsxs("button",{type:"button",onClick:()=>t(null),className:"flex shrink-0 items-center gap-1.5 border-b px-3 py-1.5 text-xs text-muted-foreground hover:bg-accent md:hidden",children:[h.jsx(Ep,{className:"size-3.5"}),"Back to files"]}),h.jsx("div",{className:"min-h-0 flex-1",children:h.jsx(C.Suspense,{fallback:h.jsx("div",{className:"grid h-full place-items-center text-sm text-muted-foreground",children:"Loading editor…"}),children:h.jsx(iA,{agentId:s,path:e})})})]}):h.jsx("div",{className:"grid h-full place-items-center text-sm text-muted-foreground",children:"Select a file from the tree to open it."})})]})}function aA({agentId:s}){const e=Oa(),{data:t,isLoading:i}=Ie({queryKey:["plugins",s],queryFn:()=>ee.listPlugins(s),refetchInterval:5e3});return i?h.jsx("div",{className:"p-6 text-sm text-muted-foreground",children:"loading…"}):h.jsxs("div",{className:"grid gap-3 p-4 sm:p-6 md:grid-cols-2 xl:grid-cols-3",children:[t==null?void 0:t.plugins.map(n=>{var r,o;return h.jsx(it,{role:"button",tabIndex:0,onClick:()=>e(`/agents/${s}/settings#plugin-${n.pluginId}`),onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),e(`/agents/${s}/settings#plugin-${n.pluginId}`))},className:"cursor-pointer transition-colors hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:h.jsxs(ut,{children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Yo,{className:"size-4 text-primary/80"}),h.jsx(nt,{className:"truncate",children:((r=n.manifest)==null?void 0:r.displayName)||n.pluginId}),h.jsx(Xp,{state:n.state})]}),h.jsx(ft,{className:"font-mono",children:n.pluginId}),((o=n.manifest)==null?void 0:o.description)&&h.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:n.manifest.description}),n.state==="failed"&&n.error&&h.jsx("pre",{className:"mt-2 overflow-x-auto rounded-md bg-destructive/10 px-2 py-1.5 text-xs text-destructive",children:n.error})]})},n.pluginId)}),t&&t.plugins.length===0&&h.jsx("div",{className:"text-sm text-muted-foreground",children:"No plugins installed."})]})}function lA({message:s}){return h.jsxs("div",{className:"flex items-start gap-3 border-y border-destructive/30 bg-destructive/10 px-4 py-2 text-destructive sm:px-6",children:[h.jsx("pre",{className:"min-w-0 flex-1 overflow-x-auto whitespace-pre-wrap break-words text-xs",children:s}),h.jsxs(J,{size:"sm",variant:"ghost",className:"text-destructive hover:bg-destructive/10",onClick:()=>{navigator.clipboard.writeText(s),q.success("error copied")},children:[h.jsx(r1,{}),"Copy"]})]})}function cA(){const{theme:s,set:e}=Vr(),{data:t}=Ie({queryKey:["agents"],queryFn:ee.listAgents});return h.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[h.jsxs("header",{className:"border-b py-3 pl-14 pr-4 md:px-6",children:[h.jsx("h1",{className:"text-lg font-semibold",children:"Settings"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"App-level — for agent and plugin configuration, open the agent's own Settings tab."})]}),h.jsx("div",{className:"flex-1 overflow-y-auto p-4 sm:p-6",children:h.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[h.jsxs(it,{children:[h.jsxs(ut,{children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(h1,{className:"size-4 text-primary/80"}),h.jsx(nt,{children:"Appearance"})]}),h.jsx(ft,{children:"Theme"})]}),h.jsxs(Pn,{className:"flex gap-2",children:[h.jsx(J,{variant:s==="light"?"default":"outline",size:"sm",onClick:()=>e("light"),children:"Light"}),h.jsx(J,{variant:s==="dark"?"default":"outline",size:"sm",onClick:()=>e("dark"),children:"Dark"})]})]}),h.jsx(dA,{}),h.jsx(Rt,{to:"/settings/models",className:"lg:col-span-2 block",children:h.jsx(it,{className:"group cursor-pointer transition-colors hover:bg-accent/30",children:h.jsxs(ut,{children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Jo,{className:"size-4 text-primary/80"}),h.jsx(nt,{children:"Models"}),h.jsx(On,{className:"ml-auto size-4 text-muted-foreground transition-transform group-hover:translate-x-0.5"})]}),h.jsx(ft,{children:"Provider API keys and the per-provider allowlist of models that agents can pick from."})]})})}),h.jsx(hA,{}),h.jsx(it,{className:"lg:col-span-2 border-warning/40 bg-warning/5",children:h.jsxs(ut,{className:"flex-row items-start gap-3",children:[h.jsx(Gp,{className:"mt-0.5 size-4 text-warning"}),h.jsxs("div",{children:[h.jsx(nt,{className:"text-sm",children:"Plaintext secrets on disk"}),h.jsxs(ft,{className:"mt-1",children:["All plugin and agent secrets are stored unencrypted in the harness root's ",h.jsx("code",{children:"secrets.json"}),". Restrict access to that file at the OS level until v1 ships encryption."]})]})]})}),t&&t.agents.length>0&&h.jsxs(it,{className:"lg:col-span-2",children:[h.jsxs(ut,{children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Vp,{className:"size-4 text-primary/80"}),h.jsx(nt,{children:"Per-agent settings"})]}),h.jsxs(ft,{children:["Configure each agent's ",h.jsx("code",{children:"agent.json"}),", plugin configs, and secrets in its own Settings tab."]})]}),h.jsx(Pn,{className:"grid gap-2 sm:grid-cols-2",children:t.agents.map(i=>h.jsxs(Rt,{to:`/agents/${i.id}/settings`,className:"group flex items-center gap-2 rounded-md border p-3 transition-colors hover:bg-accent",children:[h.jsx(ws,{className:"size-4 text-primary/80"}),h.jsxs("div",{className:"min-w-0",children:[h.jsx("div",{className:"truncate text-sm font-medium",children:i.name}),h.jsx("div",{className:"truncate font-mono text-[11px] text-muted-foreground",children:i.id})]}),h.jsx(On,{className:"ml-auto size-4 text-muted-foreground transition-transform group-hover:translate-x-0.5"})]},i.id))})]})]})})]})}function hA(){const s=Xe(),{data:e}=Ie({queryKey:["gws-oauth"],queryFn:ee.getGwsOauth}),[t,i]=C.useState(""),[n,r]=C.useState("");C.useEffect(()=>{e&&(i(e.client.clientId),r(e.client.clientSecret))},[e]),C.useEffect(()=>{const l=new URLSearchParams(window.location.search),c=l.get("gws"),d=l.get("gwsError");!c&&!d||(c&&q.success("Google sign-in complete"),d&&q.error(`Google sign-in failed: ${d}`),window.history.replaceState(null,"",window.location.pathname))},[]);const o=we({mutationFn:()=>ee.putGwsOauthClient({clientId:t.trim(),clientSecret:n}),onSuccess:()=>{q.success("OAuth client saved"),s.invalidateQueries({queryKey:["gws-oauth"]})},onError:l=>q.error(`save failed: ${l.message}`)});if(!e||e.agents.length===0)return null;const a=t.trim()!==e.client.clientId||n!==e.client.clientSecret;return h.jsxs(it,{className:"lg:col-span-2",children:[h.jsxs(ut,{children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Kp,{className:"size-4 text-primary/80"}),h.jsx(nt,{children:"Google Workspace"})]}),h.jsxs(ft,{children:["Shared OAuth client for Google sign-in. Create a “Web application” OAuth client in your GCP project and register"," ",h.jsxs("code",{children:[window.location.origin,"/api/gws/oauth/callback"]})," as a redirect URI. Sign-in and scope selection live on each agent’s own Settings tab, on the gws plugin card."]})]}),h.jsx(Pn,{className:"flex flex-col gap-4",children:h.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[h.jsxs("div",{className:"flex min-w-[16rem] flex-1 flex-col gap-1.5",children:[h.jsx(It,{className:"font-mono text-xs",htmlFor:"gws-client-id",children:"client id"}),h.jsx(at,{id:"gws-client-id",value:t,onChange:l=>i(l.target.value),placeholder:"…apps.googleusercontent.com",autoComplete:"off",className:"font-mono text-xs"})]}),h.jsxs("div",{className:"flex min-w-[12rem] flex-1 flex-col gap-1.5",children:[h.jsx(It,{className:"font-mono text-xs",htmlFor:"gws-client-secret",children:"client secret"}),h.jsx(at,{id:"gws-client-secret",type:"password",value:n,onChange:l=>r(l.target.value),autoComplete:"off",className:"font-mono text-xs"})]}),h.jsxs(J,{size:"sm",disabled:!a||t.trim()===""||o.isPending,onClick:()=>o.mutate(),children:[o.isPending?h.jsx($e,{className:"size-4 animate-spin"}):h.jsx(Ki,{className:"size-4"}),"Save"]})]})})]})}function dA(){const s=Xe(),{data:e}=Ie({queryKey:["harness"],queryFn:ee.getHarness}),[t,i]=C.useState("");C.useEffect(()=>{e!=null&&e.timezone&&i(e.timezone)},[e==null?void 0:e.timezone]);const n=C.useMemo(()=>uA(),[]),r=C.useMemo(()=>new Set(n),[n]),o=we({mutationFn:d=>ee.putHarness({timezone:d}),onSuccess:d=>{q.success(d.restarted.length>0?`timezone saved · reloaded ${d.restarted.length} agent(s)`:"timezone saved"),s.invalidateQueries({queryKey:["harness"]}),s.invalidateQueries({queryKey:["agents"]})},onError:d=>q.error(`save failed: ${d.message}`)}),a=t.trim(),l=r.has(a),c=!!e&&a.length>0&&a!==e.timezone;return h.jsxs(it,{children:[h.jsxs(ut,{children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(i1,{className:"size-4 text-primary/80"}),h.jsx(nt,{children:"Timezone"})]}),h.jsxs(ft,{children:["IANA timezone used for ",h.jsx("code",{children:"<harness-metadata>"})," ","timestamps and scheduler cron firing. Saving reloads every running agent."]})]}),h.jsxs(Pn,{className:"flex flex-wrap items-end gap-2",children:[h.jsxs("div",{className:"flex min-w-[14rem] flex-1 flex-col gap-1.5",children:[h.jsx(It,{className:"font-mono text-xs",htmlFor:"harness-tz-input",children:"timezone"}),h.jsx(at,{id:"harness-tz-input",list:"harness-tz-options",value:t,onChange:d=>i(d.target.value),placeholder:"Search… e.g. Asia/Kolkata",autoComplete:"off",className:"font-mono text-xs"}),h.jsx("datalist",{id:"harness-tz-options",children:n.map(d=>h.jsx("option",{value:d},d))}),a.length>0&&!l&&h.jsx("span",{className:"text-[11px] text-warning",children:"● not a recognized IANA timezone"})]}),h.jsxs(J,{size:"sm",disabled:!c||!l||o.isPending,onClick:()=>o.mutate(a),children:[o.isPending?h.jsx($e,{className:"size-4 animate-spin"}):h.jsx(Ki,{className:"size-4"}),"Save"]})]})]})}function uA(){const s=Intl;if(typeof s.supportedValuesOf=="function")try{return s.supportedValuesOf("timeZone")}catch{}return["UTC","America/Los_Angeles","America/New_York","Europe/London","Europe/Berlin","Asia/Kolkata","Asia/Singapore","Asia/Tokyo","Australia/Sydney"]}const rn="__CLEAR__";function Xc(s){for(const e of["models","agents","agent"])s.invalidateQueries({queryKey:[e]})}function fA(){const{data:s,isLoading:e}=Ie({queryKey:["models"],queryFn:ee.getModels});return h.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[h.jsxs("header",{className:"border-b py-3 pl-14 pr-4 md:px-6",children:[h.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[h.jsxs(Rt,{to:"/settings",className:"inline-flex items-center gap-1 hover:text-foreground",children:[h.jsx(Ep,{className:"size-3"}),"Settings"]}),h.jsx("span",{children:"·"}),h.jsx("span",{children:"Models"})]}),h.jsx("h1",{className:"text-lg font-semibold",children:"Models"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Provider credentials and the model allowlist agents can choose from. Saving here automatically reloads any running agent that uses a changed provider — no server restart needed."})]}),h.jsx("div",{className:"flex-1 overflow-y-auto p-4 sm:p-6",children:e||!s?h.jsx("div",{className:"text-sm text-muted-foreground",children:"loading…"}):h.jsxs("div",{className:"grid gap-4",children:[h.jsx(it,{className:"border-warning/40 bg-warning/5",children:h.jsxs(ut,{children:[h.jsx(nt,{className:"text-sm",children:"Plaintext storage"}),h.jsxs(ft,{className:"mt-1",children:["Provider credentials are stored unencrypted at"," ",h.jsx("code",{children:s.path}),". v1 will encrypt at rest. OAuth subscription tokens are stored separately in pi's own"," ",h.jsx("code",{children:"~/.pi/agent/auth.json"}),"."]})]})}),s.providers.map(t=>h.jsx(pA,{provider:t,mask:s.mask},t.id))]})})]})}function pA({provider:s,mask:e}){var N;const t=Xe(),[i,n]=C.useState({credentials:{},enabledModels:new Set(s.enabledModels)}),[r,o]=C.useState("");C.useEffect(()=>{n({credentials:{},enabledModels:new Set(s.enabledModels)}),o("")},[s.enabledModels,s.credentialValues]);const a=C.useMemo(()=>{const y=new Set(s.catalogModels);for(const w of s.enabledModels)y.add(w);return[...y]},[s.catalogModels,s.enabledModels]),l=C.useMemo(()=>new Set(s.enabledModels),[s.enabledModels]),c=C.useMemo(()=>{if(Object.keys(i.credentials).length>0||i.enabledModels.size!==l.size)return!0;for(const y of i.enabledModels)if(!l.has(y))return!0;return!1},[i,l]),d=C.useMemo(()=>{var y;if((y=s.oauth)!=null&&y.connected)return!0;for(const w of s.credentials){if(!w.required)continue;const k=i.credentials[w.key];if(k===rn)return!1;if(k!==void 0){if(k.length===0)return!1;continue}if((s.credentialValues[w.key]??"").length===0)return!1}return!0},[s.credentials,s.credentialValues,s.oauth,i.credentials]),u=we({mutationFn:y=>ee.putModels(y),onSuccess:()=>{q.success("saved · agents using this provider reloaded"),Xc(t)},onError:y=>q.error(`save failed: ${y.message}`)}),f=(y,w)=>{n(k=>{const M={...k.credentials};return w===void 0?delete M[y]:M[y]=w,{...k,credentials:M}})},p=y=>{n(w=>{const k=new Set(w.enabledModels);return k.has(y)?k.delete(y):k.add(y),{...w,enabledModels:k}})},m=()=>{const y=r.trim();y&&(n(w=>{const k=new Set(w.enabledModels);return k.add(y),{...w,enabledModels:k}}),o(""))},g=y=>{n(w=>{const k=new Set(w.enabledModels);return k.delete(y),{...w,enabledModels:k}})},x=()=>{n({credentials:{},enabledModels:new Set(s.enabledModels)}),o("")},b=()=>{const y={};for(const[k,M]of Object.entries(i.credentials))M!==void 0&&(y[k]=M===rn?null:M);const w={enabledModels:[...i.enabledModels]};Object.keys(y).length>0&&(w.credentials=y),u.mutate({providers:{[s.id]:w}})},S=[...i.enabledModels].filter(y=>!s.catalogModels.includes(y));return h.jsxs(it,{children:[h.jsxs(ut,{children:[h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[h.jsx(Jo,{className:"size-4 text-primary/80"}),h.jsx(nt,{children:s.displayName}),h.jsx(rt,{variant:"outline",className:"font-mono",children:s.id}),s.configured?h.jsx(rt,{variant:"secondary",children:"configured"}):h.jsx(rt,{variant:"outline",children:"incomplete"}),h.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[h.jsxs(J,{variant:"outline",size:"sm",onClick:x,disabled:!c||u.isPending,children:[h.jsx(Da,{className:"size-3.5"})," Reset"]}),h.jsxs(J,{size:"sm",onClick:b,disabled:!c||u.isPending,children:[u.isPending?h.jsx($e,{className:"size-4 animate-spin"}):h.jsx(Ki,{className:"size-4"}),"Save"]})]})]}),s.notes&&h.jsx(ft,{className:"mt-1 text-[11px]",children:s.notes})]}),h.jsx(Zt,{}),h.jsxs("div",{className:"grid gap-5 p-4",children:[((N=s.oauth)==null?void 0:N.supported)&&h.jsx(mA,{provider:s}),s.credentials.length>0&&h.jsxs("div",{children:[h.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[h.jsx(Vp,{className:"size-3.5 text-primary/60"}),h.jsx("h3",{className:"text-sm font-medium",children:"Credentials"}),!d&&h.jsx("span",{className:"text-[11px] text-warning",children:"required field(s) missing"})]}),h.jsx("div",{className:"grid gap-3",children:s.credentials.map(y=>h.jsx(gA,{field:y,serverValue:s.credentialValues[y.key]??"",draftValue:i.credentials[y.key],mask:e,onChange:w=>f(y.key,w)},y.key))})]}),h.jsx(Zt,{}),h.jsxs("div",{children:[h.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[h.jsx(Jo,{className:"size-3.5 text-primary/60"}),h.jsx("h3",{className:"text-sm font-medium",children:"Enabled models"}),h.jsx("span",{className:"text-[11px] text-muted-foreground",children:"only checked models can be selected by agents"})]}),a.length===0?h.jsx("p",{className:"text-xs text-muted-foreground",children:"No catalog models — add a custom model id below."}):h.jsx("div",{className:"grid gap-1.5 sm:grid-cols-2",children:a.map(y=>{const w=i.enabledModels.has(y),k=!s.catalogModels.includes(y);return h.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-md border p-2 transition-colors hover:bg-accent/40",children:[h.jsx("input",{type:"checkbox",checked:w,onChange:()=>p(y),className:"size-4 accent-primary"}),h.jsx("span",{className:"font-mono text-xs",children:y}),k&&h.jsx(rt,{variant:"outline",className:"ml-auto text-[10px]",children:"custom"})]},y)})}),h.jsxs("div",{className:"mt-3",children:[h.jsx(It,{className:"text-xs",children:"Add custom model id"}),h.jsxs("div",{className:"mt-1 flex items-center gap-1",children:[h.jsx(at,{value:r,onChange:y=>o(y.target.value),placeholder:"e.g. my-org/my-model",onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),m())},className:"font-mono text-xs"}),h.jsx(J,{type:"button",variant:"outline",size:"icon",onClick:m,"aria-label":"add",children:h.jsx(ah,{className:"size-4"})})]}),S.length>0&&h.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:S.map(y=>h.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border bg-secondary px-2 py-0.5 font-mono text-[11px]",children:[y,h.jsx("button",{type:"button",onClick:()=>g(y),"aria-label":`remove ${y}`,className:"text-muted-foreground hover:text-foreground",children:h.jsx(_i,{className:"size-3"})})]},y))})]})]})]})]})}function mA({provider:s}){var f,p,m,g;const e=Xe(),[t,i]=C.useState(!1),[n,r]=C.useState(""),a=Ie({queryKey:["oauth-status",s.id],queryFn:()=>ee.getOauthStatus(s.id),enabled:t,refetchInterval:x=>{var b;return((b=x.state.data)==null?void 0:b.state)==="pending"?1e3:!1}}).data;C.useEffect(()=>{!t||(a==null?void 0:a.state)!=="success"||(i(!1),r(""),q.success("signed in · agents using this provider reloaded"),Xc(e))},[t,a==null?void 0:a.state,e]);const l=we({mutationFn:()=>ee.startOauthLogin(s.id),onSuccess:x=>{i(!0),x.url&&window.open(x.url,"_blank","noopener")},onError:x=>q.error(`sign-in failed to start: ${x.message}`)}),c=we({mutationFn:({value:x,kind:b})=>ee.submitOauthInput(s.id,x,b),onSuccess:()=>r(""),onError:x=>q.error(`submit failed: ${x.message}`)}),d=we({mutationFn:()=>ee.cancelOauthLogin(s.id),onSuccess:()=>i(!1)}),u=we({mutationFn:()=>ee.oauthLogout(s.id),onSuccess:()=>{q.success("signed out · agents using this provider reloaded"),Xc(e)},onError:x=>q.error(`sign-out failed: ${x.message}`)});return h.jsxs("div",{children:[h.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[h.jsx(tc,{className:"size-3.5 text-primary/60"}),h.jsx("h3",{className:"text-sm font-medium",children:"Subscription sign-in"}),((f=s.oauth)==null?void 0:f.connected)&&h.jsx(rt,{variant:"secondary",children:"OAuth connected"})]}),(p=s.oauth)!=null&&p.connected?h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[h.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Tokens are stored in pi's ",h.jsx("code",{children:"auth.json"})," and auto-refreshed. OAuth takes precedence over an API key."]}),h.jsxs(J,{type:"button",variant:"outline",size:"sm",onClick:()=>u.mutate(),disabled:u.isPending,children:[u.isPending?h.jsx($e,{className:"size-3.5 animate-spin"}):h.jsx(oh,{className:"size-3.5"}),"Sign out"]})]}):t?h.jsxs("div",{className:"grid gap-2 rounded-md border bg-accent/20 p-3",children:[(a==null?void 0:a.state)==="error"?h.jsx("p",{className:"text-xs text-destructive",children:a.message}):h.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[h.jsx($e,{className:"size-3.5 animate-spin"}),"waiting for sign-in to complete…"]}),(a==null?void 0:a.state)==="pending"&&a.select&&h.jsxs("div",{className:"grid gap-1.5",children:[h.jsx("p",{className:"text-xs",children:a.select.message}),h.jsx("div",{className:"flex flex-wrap gap-2",children:a.select.options.map(x=>h.jsx(J,{type:"button",variant:"outline",size:"sm",onClick:()=>c.mutate({value:x.id,kind:"select"}),disabled:c.isPending,children:x.label},x.id))})]}),(a==null?void 0:a.state)==="pending"&&a.deviceCode&&h.jsxs("div",{className:"grid gap-1",children:[h.jsx("p",{className:"text-xs",children:"Open the verification page and enter this code:"}),h.jsx("code",{className:"w-fit rounded-md border bg-secondary px-2 py-1 font-mono text-sm tracking-widest",children:a.deviceCode.userCode}),h.jsxs("a",{href:a.deviceCode.verificationUri,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-primary hover:underline",children:[h.jsx(wd,{className:"size-3"}),a.deviceCode.verificationUri]})]}),(a==null?void 0:a.instructions)&&h.jsx("p",{className:"text-[11px] text-muted-foreground",children:a.instructions}),(a==null?void 0:a.url)&&h.jsxs("a",{href:a.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-primary hover:underline",children:[h.jsx(wd,{className:"size-3"}),"open sign-in page"]}),(a==null?void 0:a.state)==="pending"&&!a.select&&!a.deviceCode&&h.jsxs("div",{className:"grid gap-1",children:[h.jsx("p",{className:"text-[11px] text-muted-foreground",children:((m=a.prompt)==null?void 0:m.message)??"If this harness runs on a different machine than your browser, the final redirect will land on a localhost URL that fails to load — copy that URL from the address bar and paste it here."}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx(at,{value:n,onChange:x=>r(x.target.value),placeholder:((g=a.prompt)==null?void 0:g.placeholder)??"http://localhost:…/callback?code=…&state=…",className:"font-mono text-xs",onKeyDown:x=>{x.key==="Enter"&&n.trim()&&(x.preventDefault(),c.mutate({value:n.trim(),kind:"text"}))}}),h.jsx(J,{type:"button",variant:"outline",size:"sm",onClick:()=>c.mutate({value:n.trim(),kind:"text"}),disabled:!n.trim()||c.isPending,children:c.isPending?h.jsx($e,{className:"size-3.5 animate-spin"}):"Submit"})]})]}),h.jsx("div",{children:h.jsx(J,{type:"button",variant:"ghost",size:"sm",className:"text-[11px] text-muted-foreground",onClick:()=>(a==null?void 0:a.state)==="error"?i(!1):d.mutate(),children:(a==null?void 0:a.state)==="error"?"Dismiss":"Cancel"})})]}):h.jsxs(J,{type:"button",variant:"outline",size:"sm",onClick:()=>l.mutate(),disabled:l.isPending,children:[l.isPending?h.jsx($e,{className:"size-3.5 animate-spin"}):h.jsx(tc,{className:"size-3.5"}),"Sign in with ",s.displayName]})]})}function gA({field:s,serverValue:e,draftValue:t,mask:i,onChange:n}){const[r,o]=C.useState(!1),a=e.length>0,l=t===rn,c=t!==void 0&&t!==rn&&t.length>0,d=t===void 0?s.secret?"":e:t===rn?"":t,u=s.secret&&a?i:s.placeholder??"(not set)";return h.jsxs("div",{children:[h.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[h.jsxs(It,{className:"text-xs",children:[s.label,s.required&&h.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),h.jsx("code",{className:"text-[10px] text-muted-foreground",children:s.envVar}),c&&h.jsx("span",{className:"text-[10px] text-warning",children:"● new value"}),l&&h.jsx("span",{className:"text-[10px] text-destructive",children:"● will clear"})]}),h.jsxs("div",{className:"flex items-start gap-1",children:[s.multiline?h.jsx(Gh,{value:d,placeholder:u,rows:6,className:"font-mono text-xs",onChange:f=>n(f.target.value.length===0?void 0:f.target.value)}):h.jsx(at,{type:s.secret&&!r?"password":"text",value:d,placeholder:u,className:"font-mono text-xs",onChange:f=>n(f.target.value.length===0?void 0:f.target.value)}),s.secret&&!s.multiline&&h.jsx(J,{type:"button",variant:"ghost",size:"icon",onClick:()=>o(f=>!f),"aria-label":r?"hide":"reveal",children:r?h.jsx(Bp,{className:"size-4"}):h.jsx(zp,{className:"size-4"})}),a&&h.jsx(J,{type:"button",variant:"ghost",size:"sm",className:"text-[11px] text-destructive hover:text-destructive",onClick:()=>n(rn),disabled:l,children:"Clear"})]}),s.helpText&&h.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:s.helpText})]})}const xA=new wy({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1}}});function yA(){return h.jsx(ky,{client:xA,children:h.jsxs(Kb,{delayDuration:200,children:[h.jsx(_x,{children:h.jsx(vA,{children:h.jsxs(ip,{children:[h.jsx(tt,{path:"/login",element:h.jsx(A1,{})}),h.jsx(tt,{element:h.jsx(wA,{}),children:h.jsxs(tt,{element:h.jsx(N1,{}),children:[h.jsx(tt,{path:"/",element:h.jsx(R1,{})}),h.jsx(tt,{path:"/agents/:id/*",element:h.jsx(nA,{})}),h.jsx(tt,{path:"/settings",element:h.jsx(cA,{})}),h.jsx(tt,{path:"/settings/models",element:h.jsx(fA,{})}),h.jsx(tt,{path:"*",element:h.jsx(on,{to:"/",replace:!0})})]})})]})})}),h.jsx(bA,{})]})})}function bA(){const{theme:s}=Vr();return h.jsx(ob,{theme:s,richColors:!0,position:"top-right"})}function vA({children:s}){const{refresh:e,status:t}=Ea(),i=Oa();return C.useEffect(()=>{e()},[e]),C.useEffect(()=>(xd(()=>i("/login",{replace:!0})),()=>xd(null)),[i]),t==="unknown"?h.jsx("div",{className:"grid h-full place-items-center text-sm text-muted-foreground",children:"loading…"}):h.jsx(h.Fragment,{children:s})}function wA(){const{status:s}=Ea(),e=Pa();return s!=="authed"?h.jsx(on,{to:"/login",replace:!0,state:{from:e}}):h.jsx(kA,{})}function kA(){return h.jsx(sp,{})}Ll.createRoot(document.getElementById("root")).render(h.jsx(R.StrictMode,{children:h.jsx(yA,{})}));export{n1 as $,mi as A,Yr as B,zA as C,BS as D,BA as E,qn as F,Xt as G,Jr as H,Ce as I,H0 as J,xe as K,Aa as L,sn as M,TA as N,Bg as O,Eg as P,pa as Q,Vr as R,Xe as S,Ft as T,Ie as U,we as V,bp as W,Vb as X,yr as Y,zp as Z,V as _,DN as a,J as a0,$e as a1,Ki as a2,nx as a3,ix as a4,qN as a5,q as a6,ee as a7,cx as a8,VN as a9,aM as aa,lM as ab,MS as b,G as c,ij as d,CS as e,fa as f,zg as g,RA as h,IA as i,Lu as j,DA as k,Wg as l,zS as m,LA as n,I as o,Je as p,T as q,SS as r,Dg as s,A as t,mt as u,le as v,Mh as w,Ee as x,OA as y,l2 as z};
|
|
336
|
+
entry ${e.piEntryId}`,children:[h.jsx(yr,{className:"size-3"}),"open"]}):h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"—"})})]})}function Ko({status:s}){const e=EM(s);return h.jsx(rt,{variant:e,children:s})}function OM({error:s}){if(!s)return h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"—"});const e=/^\[([^\]]+)\]\s*(.*)$/.exec(s),t=e?e[1]:null,i=e?e[2]:s;return h.jsxs("div",{className:"flex items-center gap-1.5 overflow-hidden",children:[t&&h.jsx(rt,{variant:"outline",className:"shrink-0 font-mono text-[10px]",children:t}),h.jsx("span",{className:"truncate text-[11px] text-muted-foreground",children:i})]})}function Yi({text:s,className:e,children:t}){return s?h.jsxs(_b,{children:[h.jsx(Ub,{asChild:!0,children:h.jsx("div",{className:V("truncate",e),children:t})}),h.jsx(Op,{side:"bottom",align:"start",className:"max-w-[60ch] whitespace-pre-wrap break-words",children:s})]}):h.jsx("div",{className:V("truncate",e),children:t})}function PM({status:s,disabled:e,onChange:t}){return e?h.jsx(Ko,{status:s}):h.jsxs(Kr,{children:[h.jsx(_r,{asChild:!0,children:h.jsxs("button",{type:"button",className:"inline-flex items-center gap-0.5 rounded-md outline-none focus-visible:ring-2 focus-visible:ring-ring",title:"Change status",children:[h.jsx(Ko,{status:s}),h.jsx(Vi,{className:"size-3 text-muted-foreground"})]})}),h.jsx(Hn,{align:"start",className:"min-w-[8rem]",children:xx.map(i=>h.jsx(oi,{disabled:i===s,onSelect:()=>t(i),className:"text-xs",children:h.jsx(Ko,{status:i})},i))})]})}function EM(s){switch(s){case"queued":return"secondary";case"in_flight":return"warning";case"done":return"success";case"failed":return"destructive";case"cancelled":return"outline"}}function DM(s,e){switch(s){case"queued":return"border-transparent bg-secondary text-secondary-foreground";case"in_flight":return"border-transparent bg-warning/15 text-warning";case"done":return"border-transparent bg-success/15 text-success";case"failed":return"border-transparent bg-destructive/15 text-destructive";case"cancelled":return"border-border bg-background text-foreground"}}function RM({tsFrom:s,tsTo:e,updatedFrom:t,updatedTo:i,onTsFrom:n,onTsTo:r,onUpdatedFrom:o,onUpdatedTo:a,anyRangeSet:l,onClear:c}){return h.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[h.jsx(Ef,{label:"Created",from:s,to:e,onFrom:n,onTo:r}),h.jsx(Ef,{label:"Updated",from:t,to:i,onFrom:o,onTo:a}),l&&h.jsxs(J,{size:"sm",variant:"ghost",className:"h-6 px-1.5 text-[11px]",onClick:c,children:[h.jsx(_i,{className:"size-3"})," Clear"]})]})}function Ef({label:s,from:e,to:t,onFrom:i,onTo:n}){return h.jsxs("div",{className:"inline-flex items-center gap-1",children:[h.jsx("span",{className:"text-[10px] uppercase tracking-wider",children:s}),h.jsx("input",{type:"datetime-local",value:e,onChange:r=>i(r.target.value),className:"h-7 rounded-md border bg-background px-1.5 text-[11px] text-foreground"}),h.jsx("span",{children:"→"}),h.jsx("input",{type:"datetime-local",value:t,onChange:r=>n(r.target.value),className:"h-7 rounded-md border bg-background px-1.5 text-[11px] text-foreground"})]})}function Ro(s){if(!s)return;const e=new Date(s).getTime();return Number.isFinite(e)?e:void 0}function IM({total:s,offset:e,pageSize:t,onChange:i}){const n=s===0?0:e+1,r=Math.min(e+t,s),o=e>0,a=e+t<s;return h.jsxs("div",{className:"flex items-center justify-between text-[11px] text-muted-foreground",children:[h.jsx("span",{children:s===0?"no events":`${n}–${r} of ${s}`}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx(J,{size:"sm",variant:"ghost",className:"h-7 px-2",disabled:!o,onClick:()=>i(Math.max(0,e-t)),children:"Prev"}),h.jsx(J,{size:"sm",variant:"ghost",className:"h-7 px-2",disabled:!a,onClick:()=>i(e+t),children:"Next"}),e>0&&h.jsx(J,{size:"sm",variant:"ghost",className:"h-7 px-2",onClick:()=>i(0),title:"Back to top",children:h.jsx(_i,{className:"size-3"})})]})]})}function bx({schema:s,value:e,onChange:t}){return VM(s)?h.jsx(vx,{schema:s,value:wx(e)?e:{},onChange:t}):h.jsx(Jc,{value:e,onChange:t})}function vx({schema:s,value:e,onChange:t,depth:i=0}){const n=s.properties??{},r=new Set(s.required??[]),o=Object.keys(n);return o.length===0?h.jsx(rt,{variant:"outline",className:"w-fit",children:"no fields declared"}):h.jsx("div",{className:V("grid gap-3",i===0&&"sm:grid-cols-2"),children:o.map(a=>{var u;const l=n[a],c=Qa(l),d=c==="object"||c==="array"||c==="string"&&(((u=l.description)==null?void 0:u.length)??0)>60;return h.jsxs("div",{className:V("flex flex-col gap-1.5",d&&"sm:col-span-2"),children:[h.jsx(LM,{name:a,schema:l,required:r.has(a)}),h.jsx(BM,{schema:l,value:e[a],onChange:f=>t({...e,[a]:f}),depth:i+1})]},a)})})}function LM({name:s,schema:e,required:t}){return h.jsxs("div",{className:"flex flex-col",children:[h.jsxs(It,{className:"font-mono text-xs",children:[s,t&&h.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.description&&h.jsx("span",{className:"text-[11px] text-muted-foreground",children:e.description})]})}function BM({schema:s,value:e,onChange:t,depth:i}){var r;const n=Qa(s);if(Array.isArray(s.enum))return h.jsx(WM,{options:s.enum.map(String),value:e==null?"":String(e),onChange:o=>t(KM(s,o))});if(n==="boolean")return h.jsx($M,{value:!!e,onChange:t});if(n==="integer"||n==="number")return h.jsx(FM,{schema:s,value:e,onChange:t,integer:n==="integer"});if(n==="string")return h.jsx(zM,{value:typeof e=="string"?e:"",onChange:t});if(n==="array"&&((r=s.items)==null?void 0:r.type)==="string")return h.jsx(HM,{value:Array.isArray(e)?e.map(String):[],onChange:t});if(n==="object"){const o=!s.properties||Object.keys(s.properties).length===0,a=s.additionalProperties!==void 0&&s.additionalProperties!==!1;return o&&a?h.jsx(Jc,{value:e,onChange:t}):h.jsx(qM,{schema:s,value:wx(e)?e:{},onChange:t,depth:i})}return h.jsx(Jc,{value:e,onChange:t})}function zM({value:s,onChange:e}){return h.jsx(at,{value:s,onChange:t=>e(t.target.value),className:"font-mono text-xs"})}function FM({schema:s,value:e,onChange:t,integer:i}){return h.jsx(at,{type:"number",value:e??"",step:i?1:"any",min:s.minimum,max:s.maximum,onChange:n=>{const r=n.target.value;if(r==="")return t(void 0);const o=i?Number.parseInt(r,10):Number.parseFloat(r);t(Number.isFinite(o)?o:void 0)},className:"font-mono text-xs"})}function $M({value:s,onChange:e}){return h.jsxs("label",{className:"flex w-fit cursor-pointer items-center gap-2 rounded-md border px-3 py-1.5 text-xs transition-colors hover:bg-accent/40",children:[h.jsx("input",{type:"checkbox",checked:s,onChange:t=>e(t.target.checked),className:"size-4 accent-primary"}),h.jsx("span",{children:s?"true":"false"})]})}function WM({options:s,value:e,onChange:t}){return h.jsxs("div",{className:"relative",children:[h.jsxs("select",{value:e,onChange:i=>t(i.target.value),className:V("h-9 w-full appearance-none rounded-md border border-input bg-background px-3 pr-8 font-mono text-xs shadow-sm transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"),children:[!s.includes(e)&&h.jsx("option",{value:"",children:"— select —"}),s.map(i=>h.jsx("option",{value:i,children:i},i))]}),h.jsx(Vi,{className:"pointer-events-none absolute right-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"})]})}function HM({value:s,onChange:e}){const[t,i]=C.useState(""),n=()=>{const o=t.trim();if(o){if(s.includes(o)){i("");return}e([...s,o]),i("")}},r=o=>e(s.filter((a,l)=>l!==o));return h.jsxs("div",{className:"flex flex-col gap-2",children:[h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx(at,{value:t,onChange:o=>i(o.target.value),placeholder:"add an entry…",className:"font-mono text-xs",onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),n())}}),h.jsx(J,{type:"button",variant:"outline",size:"icon",onClick:n,"aria-label":"add",children:h.jsx(ah,{className:"size-4"})})]}),s.length>0&&h.jsx("div",{className:"flex flex-wrap gap-1",children:s.map((o,a)=>h.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border bg-secondary px-2 py-0.5 font-mono text-[11px]",children:[o,h.jsx("button",{type:"button",onClick:()=>r(a),"aria-label":`remove ${o}`,className:"text-muted-foreground hover:text-foreground",children:h.jsx(_i,{className:"size-3"})})]},`${o}-${a}`))})]})}function qM({schema:s,value:e,onChange:t,depth:i}){return h.jsx("div",{className:"rounded-md border bg-muted/20 p-3",children:h.jsx(vx,{schema:s,value:e,onChange:t,depth:i})})}function Jc({value:s,onChange:e}){const[t,i]=C.useState(()=>JSON.stringify(s??null,null,2)),[n,r]=C.useState(null);return h.jsxs("div",{children:[h.jsx("textarea",{value:t,onChange:o=>{i(o.target.value);try{const a=JSON.parse(o.target.value);r(null),e(a)}catch(a){r(a.message)}},rows:4,className:"block w-full rounded-md border bg-background px-2 py-1 font-mono text-[11px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"}),n&&h.jsxs("p",{className:"mt-1 text-[11px] text-destructive",children:["invalid JSON: ",n]})]})}function Qa(s){return Array.isArray(s.type)?s.type.find(e=>e!=="null"):s.type}function VM(s){return Qa(s)==="object"||!!s.properties}function wx(s){return!!s&&typeof s=="object"&&!Array.isArray(s)}function KM(s,e){const t=Qa(s);if(e!=="")return t==="integer"?Number.parseInt(e,10):t==="number"?Number.parseFloat(e):t==="boolean"?e==="true":e}function Rl(s){return s.split("/").pop()??s}const kx=[{service:"Gmail",scopes:[{scope:"https://www.googleapis.com/auth/gmail.modify",always:!0}]},{service:"Calendar",scopes:[{scope:"https://www.googleapis.com/auth/calendar"},{scope:"https://www.googleapis.com/auth/calendar.readonly"},{scope:"https://www.googleapis.com/auth/calendar.events"},{scope:"https://www.googleapis.com/auth/calendar.events.readonly"}]},{service:"Drive",scopes:[{scope:"https://www.googleapis.com/auth/drive"},{scope:"https://www.googleapis.com/auth/drive.file"},{scope:"https://www.googleapis.com/auth/drive.readonly"},{scope:"https://www.googleapis.com/auth/drive.metadata.readonly"}]},{service:"Docs",scopes:[{scope:"https://www.googleapis.com/auth/documents"},{scope:"https://www.googleapis.com/auth/documents.readonly"}]},{service:"Sheets",scopes:[{scope:"https://www.googleapis.com/auth/spreadsheets"},{scope:"https://www.googleapis.com/auth/spreadsheets.readonly"}]},{service:"Slides",scopes:[{scope:"https://www.googleapis.com/auth/presentations"},{scope:"https://www.googleapis.com/auth/presentations.readonly"}]},{service:"Contacts",scopes:[{scope:"https://www.googleapis.com/auth/contacts"},{scope:"https://www.googleapis.com/auth/contacts.readonly"},{scope:"https://www.googleapis.com/auth/contacts.other.readonly"}]},{service:"Tasks",scopes:[{scope:"https://www.googleapis.com/auth/tasks"},{scope:"https://www.googleapis.com/auth/tasks.readonly"}]}],Df=new Set(kx.flatMap(s=>s.scopes.filter(e=>!e.always).map(e=>e.scope)));function _M({agentId:s,plugin:e}){const t=Xe(),{data:i}=Ie({queryKey:["gws-oauth"],queryFn:ee.getGwsOauth}),[n,r]=C.useState(!1),[o,a]=C.useState(null);C.useEffect(()=>{const y=new URLSearchParams(window.location.search),w=y.get("gws"),k=y.get("gwsError");!w&&!k||(w&&q.success("Google sign-in complete"),k&&q.error(`Google sign-in failed: ${k}`),window.history.replaceState(null,"",window.location.pathname))},[]);const l=we({mutationFn:()=>ee.startGwsSignIn(s),onSuccess:({url:y})=>{window.location.href=y},onError:y=>q.error(`sign-in failed: ${y.message}`)}),c=we({mutationFn:()=>ee.gwsSignOut(s),onSuccess:()=>{q.success("Signed out of Google"),t.invalidateQueries({queryKey:["gws-oauth"]}),t.invalidateQueries({queryKey:["plugins",s]})},onError:y=>q.error(`sign-out failed: ${y.message}`)}),d=e.config??null,u=C.useMemo(()=>new Set(((d==null?void 0:d.oauthScopes)??"").split(",").map(y=>y.trim()).filter(Boolean)),[d==null?void 0:d.oauthScopes]),f=[...u].filter(y=>Df.has(y)),p=[...u].filter(y=>!Df.has(y)),m=o??u,g=o!==null&&[...o].sort().join(",")!==[...f].sort().join(","),x=(y,w)=>{a(k=>{const M=new Set(k??f);return w?M.add(y):M.delete(y),M})},b=i==null?void 0:i.agents.find(y=>y.agentId===s),S=we({mutationFn:()=>ee.putPluginConfig(s,"gws",{...d??{},oauthScopes:[...p,...o??[]].join(", ")}),onSuccess:()=>{q.success(b!=null&&b.signedIn?"Scopes saved — sign in again to apply":"Scopes saved"),a(null),t.invalidateQueries({queryKey:["plugins",s]})},onError:y=>q.error(`save failed: ${y.message}`)});if(!i||!b)return null;const N=i.client.clientId.length>0&&i.client.clientSecret.length>0;return h.jsxs("div",{className:"flex flex-col gap-2",children:[h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[h.jsx(Kp,{className:"size-3.5 text-primary/60"}),h.jsx("h3",{className:"text-sm font-medium",children:"Google account"}),h.jsxs("div",{className:"min-w-0 flex-1 truncate text-[11px] text-muted-foreground",children:[b.signedIn?b.email?`Signed in as ${b.email}`:"Signed in":"Not signed in",b.scopes.length>0&&h.jsxs(h.Fragment,{children:[" · ",b.scopes.filter(y=>y.includes("googleapis.com/auth/")&&!y.includes("/userinfo.")).map(Rl).join(", ")]})]}),h.jsxs(J,{size:"sm",variant:"ghost",onClick:()=>r(y=>!y),children:[h.jsx(On,{className:`size-4 transition-transform ${n?"rotate-90":""}`}),"Scopes"]}),b.signedIn?h.jsxs(J,{size:"sm",variant:"outline",disabled:c.isPending,onClick:()=>c.mutate(),children:[c.isPending?h.jsx($e,{className:"size-4 animate-spin"}):h.jsx(oh,{className:"size-4"}),"Sign out"]}):h.jsxs(J,{size:"sm",disabled:!N||l.isPending,onClick:()=>l.mutate(),title:N?void 0:"Save the OAuth client id and secret in Settings first",children:[l.isPending?h.jsx($e,{className:"size-4 animate-spin"}):h.jsx(tc,{className:"size-4"}),"Sign in with Google"]})]}),!N&&h.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["The shared Google OAuth client isn’t configured yet —"," ",h.jsx(Rt,{to:"/settings",className:"text-primary hover:underline",children:"save a client id and secret in Settings"})," ","first."]}),n&&h.jsxs("div",{className:"flex flex-col gap-3 border-t pt-3",children:[h.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Stored as ",h.jsx("code",{children:"oauthScopes"})," in this plugin’s config — changing scopes requires signing in again."," ",h.jsx("code",{children:"gmail.modify"})," is always requested: it is Google’s read/write Gmail tier (read, drafts, send, labels, mark-read — everything except permanent deletion), and the narrower Gmail scopes are subsets of it that would break inbox polling on their own."]}),h.jsx("div",{className:"grid gap-x-6 gap-y-2 sm:grid-cols-2 lg:grid-cols-4",children:kx.map(y=>h.jsxs("div",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:y.service}),y.scopes.map(w=>h.jsxs("label",{className:"flex cursor-pointer items-center gap-1.5 font-mono text-[11px]",title:w.scope,children:[h.jsx("input",{type:"checkbox",className:"accent-primary",checked:w.always||m.has(w.scope),disabled:w.always,onChange:k=>x(w.scope,k.target.checked)}),Rl(w.scope),w.always&&h.jsx("span",{className:"font-sans text-[10px] text-muted-foreground",children:"(always)"})]},w.scope))]},y.service))}),p.length>0&&h.jsxs("div",{className:"text-[11px] text-muted-foreground",children:["Also configured: ",p.map(Rl).join(", ")," (kept on save)"]}),h.jsx("div",{children:h.jsxs(J,{size:"sm",disabled:!g||S.isPending,onClick:()=>S.mutate(),children:[S.isPending?h.jsx($e,{className:"size-4 animate-spin"}):h.jsx(Ki,{className:"size-4"}),"Save scopes"]})})]})]})}const Ta="__CLEAR__",UM={properties:{name:{type:"string",description:"Display name shown in the UI."},model:{type:"object",description:"Model selection passed to pi --provider/--model/--thinking.",properties:{provider:{type:"string",description:"Provider id (e.g. anthropic, openai, google, openrouter)."},id:{type:"string",description:"Model id (e.g. claude-sonnet-4-5)."},thinkingLevel:{type:"string",enum:["off","minimal","low","medium","high","xhigh"],description:"Reasoning depth (provider permitting)."}}},threadIdStrategy:{type:"object",description:"How threads are derived from incoming notifications.",properties:{type:{type:"string",enum:["single","plugin","plugin_channel"]}}},maxConcurrentSlots:{type:"integer",minimum:1,description:"Parallel batches the runner may execute for this agent."},maxAttempts:{type:"integer",minimum:1,description:"Retries before a message moves to the dead-letter queue."}}};function QM({agentId:s}){const{hash:e}=Pa(),t=C.useRef(null),{data:i}=Ie({queryKey:["agent",s],queryFn:()=>ee.getAgent(s)}),{data:n}=Ie({queryKey:["plugins",s],queryFn:()=>ee.listPlugins(s)}),{data:r}=Ie({queryKey:["secrets"],queryFn:ee.getSecrets}),o=!!i&&!!n&&!!r;return C.useEffect(()=>{var c;if(!o||!e)return;const a=e.slice(1),l=(c=t.current)==null?void 0:c.querySelector(`[id="${CSS.escape(a)}"]`);l&&l.scrollIntoView({behavior:"smooth",block:"start"})},[o,e]),o?h.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[h.jsx("div",{className:"flex shrink-0 items-center gap-3 border-b px-4 py-2 sm:px-6",children:h.jsx("p",{className:"text-xs text-muted-foreground",children:"Settings · saves auto-reload the agent if it's running"})}),h.jsxs("div",{ref:t,className:"flex-1 overflow-y-auto p-4 sm:p-6",children:[h.jsx(GM,{}),h.jsxs("div",{className:"grid gap-6",children:[h.jsx(YM,{agentId:s,agentJson:i.agentJson,secrets:r}),n.plugins.map(a=>h.jsx(JM,{agentId:s,plugin:a,secrets:r},a.pluginId)),n.plugins.length===0&&h.jsx("p",{className:"text-sm text-muted-foreground",children:"No plugins installed."})]})]})]}):h.jsx("div",{className:"p-6 text-sm text-muted-foreground",children:"loading…"})}function GM(){return h.jsx(it,{className:"mb-6 border-warning/40 bg-warning/5",children:h.jsxs(ut,{className:"flex-row items-start gap-3",children:[h.jsx(Gp,{className:"mt-0.5 size-4 text-warning"}),h.jsxs("div",{children:[h.jsx(nt,{className:"text-sm",children:"Plaintext storage"}),h.jsxs(ft,{className:"mt-1",children:["Secrets are stored unencrypted in ",h.jsx("code",{children:"secrets.json"}),"; agent + plugin configuration is plain JSON on disk. v1 will encrypt secrets at rest."]})]})]})})}function YM({agentId:s,agentJson:e,secrets:t}){var l,c,d,u;const i=Xe(),{data:n}=Ie({queryKey:["models"],queryFn:ee.getModels}),r=we({mutationFn:f=>ee.putAgentConfig(s,f),onSuccess:()=>{q.success("saved · agent reloaded"),i.invalidateQueries({queryKey:["agent",s]})},onError:f=>q.error(`save failed: ${f.message}`)}),o=((c=(l=t.schemas)==null?void 0:l[s])==null?void 0:c[t.agentBucket])??null,a=((u=(d=t.secrets)==null?void 0:d[s])==null?void 0:u[t.agentBucket])??{};return h.jsxs(it,{children:[h.jsx(ut,{children:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(ws,{className:"size-4 text-primary/80"}),h.jsx(nt,{children:"Agent"}),h.jsx(rt,{variant:"outline",className:"font-mono",children:s})]})}),h.jsx(Zt,{}),h.jsxs("div",{className:"grid gap-5 p-4",children:[h.jsx(ZM,{initial:e,models:n??null,onSave:f=>r.mutate(f),saving:r.isPending}),h.jsx(Zt,{}),h.jsx(Sx,{agentId:s,bucketId:t.agentBucket,heading:"Secrets",icon:h.jsx(ws,{className:"size-3.5 text-primary/70"}),schema:o??{type:"object",properties:{}},existing:a,mask:t.mask,emptyHint:"No agent secrets declared. Add a `secretsSchema` block to agent.json to define agent-level secret keys."})]})]})}function JM({agentId:s,plugin:e,secrets:t}){var l,c,d,u,f,p,m;const i=Xe(),n=we({mutationFn:g=>ee.putPluginConfig(s,e.pluginId,g),onSuccess:()=>{q.success("saved · agent reloaded"),i.invalidateQueries({queryKey:["plugins",s]}),i.invalidateQueries({queryKey:["agent",s]})},onError:g=>q.error(`save failed: ${g.message}`)}),r=((c=(l=t.schemas)==null?void 0:l[s])==null?void 0:c[e.pluginId])??null,o=((u=(d=t.secrets)==null?void 0:d[s])==null?void 0:u[e.pluginId])??{},a=((f=e.manifest)==null?void 0:f.configSchema)??{type:"object",properties:{}};return h.jsxs(it,{id:`plugin-${e.pluginId}`,className:"scroll-mt-4",children:[h.jsxs(ut,{children:[h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[h.jsx(Yo,{className:"size-4 text-primary/80"}),h.jsx(nt,{children:((p=e.manifest)==null?void 0:p.displayName)||e.pluginId}),h.jsx(rt,{variant:"outline",className:"font-mono",children:e.pluginId}),e.state!=="running"&&h.jsx(rt,{variant:e.state==="failed"?"destructive":"secondary",children:e.state}),!e.manifest&&h.jsx(rt,{variant:"destructive",children:"unknown plugin"})]}),((m=e.manifest)==null?void 0:m.description)&&h.jsx(ft,{className:"mt-1",children:e.manifest.description})]}),h.jsx(Zt,{}),h.jsxs("div",{className:"grid gap-5 p-4",children:[e.pluginId==="gws"&&h.jsxs(h.Fragment,{children:[h.jsx(_M,{agentId:s,plugin:e}),h.jsx(Zt,{})]}),h.jsx(tA,{subtitle:`plugins/${e.pluginId}/config.json`,schema:a,initial:e.config,onSave:g=>n.mutate(g),saving:n.isPending}),(r==null?void 0:r.properties)&&Object.keys(r.properties).length>0&&h.jsxs(h.Fragment,{children:[h.jsx(Zt,{}),h.jsx(Sx,{agentId:s,bucketId:e.pluginId,heading:"Secrets",icon:h.jsx(Yo,{className:"size-3.5 text-primary/70"}),schema:r,existing:o,mask:t.mask})]})]})]})}const XM=["off","minimal","low","medium","high","xhigh"];function ZM({initial:s,models:e,onSave:t,saving:i}){const n=C.useMemo(()=>gn(s??{}),[s]),[r,o]=C.useState(()=>n);C.useEffect(()=>{o(gn(s??{}))},[s]);const a=C.useMemo(()=>JSON.stringify(r)!==JSON.stringify(n),[r,n]),l=r.model??{},c=u=>o(f=>({...f,model:{...f.model,...u}})),d=C.useMemo(()=>{const u=Object.fromEntries(Object.entries(UM.properties??{}).filter(([p])=>p!=="model")),f=n.configSchema;return f&&(u.config={...f,description:f.description??"Non-secret env vars exposed to the pi runtime (validated against configSchema in agent.json)."}),{type:"object",properties:u}},[n]);return h.jsxs("div",{children:[h.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[h.jsx(Fp,{className:"size-3.5 text-primary/60"}),h.jsx("h3",{className:"text-sm font-medium",children:"Configuration"}),h.jsx("code",{className:"text-[11px] text-muted-foreground",children:"agent.json"}),h.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[h.jsxs(J,{variant:"outline",size:"sm",onClick:()=>o(gn(s??{})),disabled:!a||i,children:[h.jsx(Da,{className:"size-3.5"})," Reset"]}),h.jsxs(J,{size:"sm",disabled:!a||i,onClick:()=>t(r),children:[i?h.jsx($e,{className:"size-4 animate-spin"}):h.jsx(Ki,{className:"size-4"}),"Save"]})]})]}),h.jsxs("div",{className:"grid gap-4",children:[h.jsx(eA,{models:e,value:l,onChange:c}),h.jsx(bx,{schema:d,value:r,onChange:u=>o(u)})]})]})}function eA({models:s,value:e,onChange:t,title:i="Model",hint:n="--provider / --model / --thinking"}){const r=C.useMemo(()=>((s==null?void 0:s.providers)??[]).filter(f=>f.configured&&f.enabledModels.length>0),[s]),o=C.useMemo(()=>{const f=new Map;for(const p of(s==null?void 0:s.providers)??[])f.set(p.id,p);return f},[s]),a=e.provider?o.get(e.provider):void 0,l=!!(a&&a.configured&&a.enabledModels.length>0),c=[...r];e.provider&&!c.find(f=>f.id===e.provider)&&a&&c.unshift(a);const d=a?a.enabledModels:[],u=!!e.id&&!!a&&!d.includes(e.id);return h.jsxs("div",{className:"rounded-md border bg-muted/20 p-3",children:[h.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[h.jsx(ws,{className:"size-3.5 text-primary/60"}),h.jsx("h4",{className:"text-sm font-medium",children:i}),h.jsx("span",{className:"text-[11px] text-muted-foreground",children:n}),h.jsx(Rt,{to:"/settings/models",className:"ml-auto text-[11px] text-primary hover:underline",children:"Manage providers →"})]}),s?r.length===0&&!e.provider?h.jsxs("p",{className:"text-xs text-muted-foreground",children:["No providers configured yet."," ",h.jsx(Rt,{to:"/settings/models",className:"text-primary hover:underline",children:"Add an API key and enable models"})," ","to choose one here."]}):h.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[h.jsxs("div",{className:"flex flex-col gap-1.5",children:[h.jsx(It,{className:"font-mono text-xs",children:"provider"}),h.jsx(Il,{options:c.map(f=>({value:f.id,label:f.displayName,hint:f.configured&&f.enabledModels.length>0?f.id:`${f.id} · not configured`})),value:e.provider??"",placeholder:"— select provider —",onChange:f=>t({provider:f||void 0,id:void 0})}),e.provider&&!l&&h.jsx("span",{className:"text-[10px] text-warning",children:"● provider has no key or no enabled models"})]}),h.jsxs("div",{className:"flex flex-col gap-1.5 sm:col-span-2",children:[h.jsx(It,{className:"font-mono text-xs",children:"model id"}),a?d.length===0?h.jsxs("p",{className:"text-[11px] text-warning",children:["no models enabled for this provider —"," ",h.jsx(Rt,{to:"/settings/models",className:"text-primary hover:underline",children:"enable some"})]}):h.jsx(Il,{options:[...u&&e.id?[{value:e.id,label:`${e.id} (not enabled)`,hint:"no longer in allowlist"}]:[],...d.map(f=>({value:f,label:f}))],value:e.id??"",placeholder:"— select model —",onChange:f=>t({id:f||void 0})}):h.jsx("p",{className:"text-[11px] text-muted-foreground",children:"pick a provider first"}),u&&h.jsx("span",{className:"text-[10px] text-warning",children:"● this model is no longer enabled in Models settings"})]}),h.jsxs("div",{className:"flex flex-col gap-1.5 sm:col-span-3",children:[h.jsx(It,{className:"font-mono text-xs",children:"thinkingLevel"}),h.jsx(Il,{options:XM.map(f=>({value:f,label:f})),value:e.thinkingLevel??"",placeholder:"— default —",onChange:f=>t({thinkingLevel:f||void 0})})]})]}):h.jsx("p",{className:"text-xs text-muted-foreground",children:"loading providers…"})]})}function Il({options:s,value:e,placeholder:t,onChange:i}){return h.jsxs("div",{className:"relative",children:[h.jsxs("select",{value:e,onChange:n=>i(n.target.value),className:V("h-9 w-full appearance-none rounded-md border border-input bg-background px-3 pr-8 font-mono text-xs shadow-sm transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"),children:[h.jsx("option",{value:"",children:t}),s.map(n=>h.jsxs("option",{value:n.value,children:[n.label,n.hint?` — ${n.hint}`:""]},n.value))]}),h.jsx(Vi,{className:"pointer-events-none absolute right-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"})]})}function tA({subtitle:s,schema:e,initial:t,onSave:i,saving:n}){const r=C.useMemo(()=>gn(t??{}),[t]),[o,a]=C.useState(r);C.useEffect(()=>{a(gn(t??{}))},[t]);const l=C.useMemo(()=>JSON.stringify(o)!==JSON.stringify(r),[o,r]);return h.jsxs("div",{children:[h.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[h.jsx(Fp,{className:"size-3.5 text-primary/60"}),h.jsx("h3",{className:"text-sm font-medium",children:"Configuration"}),h.jsx("code",{className:"text-[11px] text-muted-foreground",children:s}),h.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[h.jsxs(J,{variant:"outline",size:"sm",onClick:()=>a(gn(t??{})),disabled:!l||n,children:[h.jsx(Da,{className:"size-3.5"})," Reset"]}),h.jsxs(J,{size:"sm",disabled:!l||n,onClick:()=>i(o),children:[n?h.jsx($e,{className:"size-4 animate-spin"}):h.jsx(Ki,{className:"size-4"}),"Save"]})]})]}),h.jsx(bx,{schema:e,value:o,onChange:a})]})}function Sx({agentId:s,bucketId:e,heading:t,icon:i,schema:n,existing:r,mask:o,emptyHint:a}){const l=Xe(),[c,d]=C.useState({}),[u,f]=C.useState({}),p=we({mutationFn:y=>ee.putSecrets(y),onSuccess:()=>{q.success("saved · agent reloaded"),d({}),l.invalidateQueries({queryKey:["secrets"]}),l.invalidateQueries({queryKey:["agent",s]}),l.invalidateQueries({queryKey:["plugins",s]})},onError:y=>q.error(`save failed: ${y.message}`)}),m=Object.keys(c).length>0,g=n.properties??{},x=Object.keys(g),b=(y,w)=>d(k=>({...k,[y]:w})),S=y=>d(w=>({...w,[y]:Ta})),N=()=>{const y={};for(const[w,k]of Object.entries(c))y[w]=k===Ta?null:k;p.mutate({secrets:{[s]:{[e]:y}}})};return h.jsxs("div",{children:[h.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[h.jsx(x1,{className:"size-3.5 text-primary/60"}),i,h.jsx("h3",{className:"text-sm font-medium",children:t}),x.length>0&&h.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[h.jsxs(J,{variant:"outline",size:"sm",onClick:()=>d({}),disabled:!m||p.isPending,children:[h.jsx(Da,{className:"size-3.5"})," Reset"]}),h.jsxs(J,{size:"sm",onClick:N,disabled:!m||p.isPending,children:[p.isPending?h.jsx($e,{className:"size-4 animate-spin"}):h.jsx(Ki,{className:"size-4"}),"Save"]})]})]}),x.length===0?h.jsx("p",{className:"text-xs text-muted-foreground",children:a??"No secrets declared."}):h.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:x.map(y=>h.jsx(sA,{keyName:y,schema:g[y],present:!!r[y],draftVal:c[y],mask:o,revealed:!!u[`${s}/${e}/${y}`],onToggleReveal:()=>f(w=>({...w,[`${s}/${e}/${y}`]:!w[`${s}/${e}/${y}`]})),onChange:w=>b(y,w),onClear:()=>S(y)},y))})]})}function sA({keyName:s,schema:e,present:t,draftVal:i,mask:n,revealed:r,onToggleReveal:o,onChange:a,onClear:l}){const c=t?n:"(not set)",d=i===Ta;return h.jsxs("div",{className:"flex flex-col gap-1.5",children:[h.jsx(It,{className:"font-mono text-xs",children:s}),e.description&&h.jsx("span",{className:"text-[11px] text-muted-foreground",children:e.description}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx(at,{type:r?"text":"password",placeholder:c,value:d?"":i??"",onChange:u=>a(u.target.value),className:"font-mono text-xs"}),h.jsx(J,{type:"button",variant:"ghost",size:"icon",onClick:o,"aria-label":r?"hide":"reveal",children:r?h.jsx(Bp,{className:"size-4"}):h.jsx(zp,{className:"size-4"})}),t&&h.jsx(J,{type:"button",variant:"ghost",size:"sm",className:"text-[11px] text-destructive hover:text-destructive",onClick:l,disabled:d,children:"Clear"})]}),i&&i!==Ta&&h.jsx("span",{className:"text-[10px] text-warning",children:"● new value"}),d&&h.jsx("span",{className:"text-[10px] text-destructive",children:"● will be cleared"})]})}function gn(s){return structuredClone(s)}const iA=C.lazy(()=>z1(()=>import("./file-editor-CqGYKmT3.js"),__vite__mapDeps([0,1,2,3])).then(s=>({default:s.FileEditor})));function nA(){const{id:s=""}=tp(),{data:e}=Ie({queryKey:["agent",s],queryFn:()=>ee.getAgent(s),enabled:!!s,refetchInterval:3e3});return h.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[h.jsxs("header",{className:"flex flex-wrap items-center gap-3 border-b py-3 pl-14 pr-4 md:px-6",children:[h.jsx("div",{className:"grid size-8 place-items-center rounded-md bg-primary/10 text-primary",children:h.jsx(ws,{className:"size-4"})}),h.jsxs("div",{className:"min-w-0",children:[h.jsx("div",{className:"truncate text-sm font-semibold",children:(e==null?void 0:e.name)??s}),h.jsx("div",{className:"truncate font-mono text-[11px] text-muted-foreground",children:e!=null&&e.agentJson?`${e.agentJson.model.provider}/${e.agentJson.model.id}`:s})]}),h.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[e&&h.jsx(Xp,{state:e.state}),e&&h.jsx(D1,{agentId:s,state:e.state})]})]}),(e==null?void 0:e.state)==="failed"&&e.error&&h.jsx(lA,{message:e.error}),h.jsx(rA,{agentId:s}),h.jsx("div",{className:"flex-1 overflow-hidden",children:h.jsxs(ip,{children:[h.jsx(tt,{index:!0,element:h.jsx(on,{to:"chat",replace:!0})}),h.jsx(tt,{path:"chat",element:h.jsx(cM,{agentId:s})}),h.jsx(tt,{path:"files/*",element:h.jsx(oA,{agentId:s})}),h.jsx(tt,{path:"events",element:h.jsx("div",{className:"h-full p-4 sm:p-6",children:h.jsx(NM,{agentId:s})})}),h.jsx(tt,{path:"queue",element:h.jsx(on,{to:"../events",replace:!0})}),h.jsx(tt,{path:"plugins",element:h.jsx(aA,{agentId:s})}),h.jsx(tt,{path:"settings",element:h.jsx(QM,{agentId:s})}),h.jsx(tt,{path:"*",element:h.jsx(on,{to:"chat",replace:!0})})]})})]})}function rA({agentId:s}){const e=Pa(),t=[{to:`/agents/${s}/chat`,key:"chat",label:"Chat",icon:yr},{to:`/agents/${s}/files`,key:"files",label:"Files",icon:Hp},{to:`/agents/${s}/events`,key:"events",label:"Events",icon:Jb},{to:`/agents/${s}/plugins`,key:"plugins",label:"Plugins",icon:Yo},{to:`/agents/${s}/settings`,key:"settings",label:"Settings",icon:Qp}];return h.jsx("nav",{className:"flex shrink-0 gap-1 overflow-x-auto border-b px-3 py-1 sm:px-4",children:t.map(i=>{const n=e.pathname.startsWith(i.to),r=i.icon;return h.jsxs(Rt,{to:i.to,className:V("inline-flex shrink-0 items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",n?"bg-primary/10 text-primary":"text-muted-foreground hover:bg-accent hover:text-foreground"),children:[h.jsx(r,{className:"size-3.5"}),i.label]},i.key)})})}function oA({agentId:s}){const[e,t]=C.useState(null);return h.jsxs("div",{className:"flex h-full min-h-0 md:grid md:grid-cols-[minmax(220px,28%)_1fr]",children:[h.jsx("aside",{className:V("min-h-0 flex-1 overflow-y-auto border-r bg-card/50 md:flex-none",e&&"hidden md:block"),children:h.jsx($1,{agentId:s,selectedPath:e,onSelectFile:i=>t(i),onPathDeleted:i=>{e&&(e===i||e.startsWith(`${i}/`))&&t(null)}})}),h.jsx("section",{className:V("min-h-0 min-w-0 flex-1 flex-col md:flex",e?"flex":"hidden md:flex"),children:e?h.jsxs(h.Fragment,{children:[h.jsxs("button",{type:"button",onClick:()=>t(null),className:"flex shrink-0 items-center gap-1.5 border-b px-3 py-1.5 text-xs text-muted-foreground hover:bg-accent md:hidden",children:[h.jsx(Ep,{className:"size-3.5"}),"Back to files"]}),h.jsx("div",{className:"min-h-0 flex-1",children:h.jsx(C.Suspense,{fallback:h.jsx("div",{className:"grid h-full place-items-center text-sm text-muted-foreground",children:"Loading editor…"}),children:h.jsx(iA,{agentId:s,path:e})})})]}):h.jsx("div",{className:"grid h-full place-items-center text-sm text-muted-foreground",children:"Select a file from the tree to open it."})})]})}function aA({agentId:s}){const e=Oa(),{data:t,isLoading:i}=Ie({queryKey:["plugins",s],queryFn:()=>ee.listPlugins(s),refetchInterval:5e3});return i?h.jsx("div",{className:"p-6 text-sm text-muted-foreground",children:"loading…"}):h.jsxs("div",{className:"grid gap-3 p-4 sm:p-6 md:grid-cols-2 xl:grid-cols-3",children:[t==null?void 0:t.plugins.map(n=>{var r,o;return h.jsx(it,{role:"button",tabIndex:0,onClick:()=>e(`/agents/${s}/settings#plugin-${n.pluginId}`),onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),e(`/agents/${s}/settings#plugin-${n.pluginId}`))},className:"cursor-pointer transition-colors hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:h.jsxs(ut,{children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Yo,{className:"size-4 text-primary/80"}),h.jsx(nt,{className:"truncate",children:((r=n.manifest)==null?void 0:r.displayName)||n.pluginId}),h.jsx(Xp,{state:n.state})]}),h.jsx(ft,{className:"font-mono",children:n.pluginId}),((o=n.manifest)==null?void 0:o.description)&&h.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:n.manifest.description}),n.state==="failed"&&n.error&&h.jsx("pre",{className:"mt-2 overflow-x-auto rounded-md bg-destructive/10 px-2 py-1.5 text-xs text-destructive",children:n.error})]})},n.pluginId)}),t&&t.plugins.length===0&&h.jsx("div",{className:"text-sm text-muted-foreground",children:"No plugins installed."})]})}function lA({message:s}){return h.jsxs("div",{className:"flex items-start gap-3 border-y border-destructive/30 bg-destructive/10 px-4 py-2 text-destructive sm:px-6",children:[h.jsx("pre",{className:"min-w-0 flex-1 overflow-x-auto whitespace-pre-wrap break-words text-xs",children:s}),h.jsxs(J,{size:"sm",variant:"ghost",className:"text-destructive hover:bg-destructive/10",onClick:()=>{navigator.clipboard.writeText(s),q.success("error copied")},children:[h.jsx(r1,{}),"Copy"]})]})}function cA(){const{theme:s,set:e}=Vr(),{data:t}=Ie({queryKey:["agents"],queryFn:ee.listAgents});return h.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[h.jsxs("header",{className:"border-b py-3 pl-14 pr-4 md:px-6",children:[h.jsx("h1",{className:"text-lg font-semibold",children:"Settings"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"App-level — for agent and plugin configuration, open the agent's own Settings tab."})]}),h.jsx("div",{className:"flex-1 overflow-y-auto p-4 sm:p-6",children:h.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[h.jsxs(it,{children:[h.jsxs(ut,{children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(h1,{className:"size-4 text-primary/80"}),h.jsx(nt,{children:"Appearance"})]}),h.jsx(ft,{children:"Theme"})]}),h.jsxs(Pn,{className:"flex gap-2",children:[h.jsx(J,{variant:s==="light"?"default":"outline",size:"sm",onClick:()=>e("light"),children:"Light"}),h.jsx(J,{variant:s==="dark"?"default":"outline",size:"sm",onClick:()=>e("dark"),children:"Dark"})]})]}),h.jsx(dA,{}),h.jsx(Rt,{to:"/settings/models",className:"lg:col-span-2 block",children:h.jsx(it,{className:"group cursor-pointer transition-colors hover:bg-accent/30",children:h.jsxs(ut,{children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Jo,{className:"size-4 text-primary/80"}),h.jsx(nt,{children:"Models"}),h.jsx(On,{className:"ml-auto size-4 text-muted-foreground transition-transform group-hover:translate-x-0.5"})]}),h.jsx(ft,{children:"Provider API keys and the per-provider allowlist of models that agents can pick from."})]})})}),h.jsx(hA,{}),h.jsx(it,{className:"lg:col-span-2 border-warning/40 bg-warning/5",children:h.jsxs(ut,{className:"flex-row items-start gap-3",children:[h.jsx(Gp,{className:"mt-0.5 size-4 text-warning"}),h.jsxs("div",{children:[h.jsx(nt,{className:"text-sm",children:"Plaintext secrets on disk"}),h.jsxs(ft,{className:"mt-1",children:["All plugin and agent secrets are stored unencrypted in the harness root's ",h.jsx("code",{children:"secrets.json"}),". Restrict access to that file at the OS level until v1 ships encryption."]})]})]})}),t&&t.agents.length>0&&h.jsxs(it,{className:"lg:col-span-2",children:[h.jsxs(ut,{children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Vp,{className:"size-4 text-primary/80"}),h.jsx(nt,{children:"Per-agent settings"})]}),h.jsxs(ft,{children:["Configure each agent's ",h.jsx("code",{children:"agent.json"}),", plugin configs, and secrets in its own Settings tab."]})]}),h.jsx(Pn,{className:"grid gap-2 sm:grid-cols-2",children:t.agents.map(i=>h.jsxs(Rt,{to:`/agents/${i.id}/settings`,className:"group flex items-center gap-2 rounded-md border p-3 transition-colors hover:bg-accent",children:[h.jsx(ws,{className:"size-4 text-primary/80"}),h.jsxs("div",{className:"min-w-0",children:[h.jsx("div",{className:"truncate text-sm font-medium",children:i.name}),h.jsx("div",{className:"truncate font-mono text-[11px] text-muted-foreground",children:i.id})]}),h.jsx(On,{className:"ml-auto size-4 text-muted-foreground transition-transform group-hover:translate-x-0.5"})]},i.id))})]})]})})]})}function hA(){const s=Xe(),{data:e}=Ie({queryKey:["gws-oauth"],queryFn:ee.getGwsOauth}),[t,i]=C.useState(""),[n,r]=C.useState("");C.useEffect(()=>{e&&(i(e.client.clientId),r(e.client.clientSecret))},[e]),C.useEffect(()=>{const l=new URLSearchParams(window.location.search),c=l.get("gws"),d=l.get("gwsError");!c&&!d||(c&&q.success("Google sign-in complete"),d&&q.error(`Google sign-in failed: ${d}`),window.history.replaceState(null,"",window.location.pathname))},[]);const o=we({mutationFn:()=>ee.putGwsOauthClient({clientId:t.trim(),clientSecret:n}),onSuccess:()=>{q.success("OAuth client saved"),s.invalidateQueries({queryKey:["gws-oauth"]})},onError:l=>q.error(`save failed: ${l.message}`)});if(!e||e.agents.length===0)return null;const a=t.trim()!==e.client.clientId||n!==e.client.clientSecret;return h.jsxs(it,{className:"lg:col-span-2",children:[h.jsxs(ut,{children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Kp,{className:"size-4 text-primary/80"}),h.jsx(nt,{children:"Google Workspace"})]}),h.jsxs(ft,{children:["Shared OAuth client for Google sign-in. Create a “Web application” OAuth client in your GCP project and register"," ",h.jsxs("code",{children:[window.location.origin,"/api/gws/oauth/callback"]})," as a redirect URI. Sign-in and scope selection live on each agent’s own Settings tab, on the gws plugin card."]})]}),h.jsx(Pn,{className:"flex flex-col gap-4",children:h.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[h.jsxs("div",{className:"flex min-w-[16rem] flex-1 flex-col gap-1.5",children:[h.jsx(It,{className:"font-mono text-xs",htmlFor:"gws-client-id",children:"client id"}),h.jsx(at,{id:"gws-client-id",value:t,onChange:l=>i(l.target.value),placeholder:"…apps.googleusercontent.com",autoComplete:"off",className:"font-mono text-xs"})]}),h.jsxs("div",{className:"flex min-w-[12rem] flex-1 flex-col gap-1.5",children:[h.jsx(It,{className:"font-mono text-xs",htmlFor:"gws-client-secret",children:"client secret"}),h.jsx(at,{id:"gws-client-secret",type:"password",value:n,onChange:l=>r(l.target.value),autoComplete:"off",className:"font-mono text-xs"})]}),h.jsxs(J,{size:"sm",disabled:!a||t.trim()===""||o.isPending,onClick:()=>o.mutate(),children:[o.isPending?h.jsx($e,{className:"size-4 animate-spin"}):h.jsx(Ki,{className:"size-4"}),"Save"]})]})})]})}function dA(){const s=Xe(),{data:e}=Ie({queryKey:["harness"],queryFn:ee.getHarness}),[t,i]=C.useState("");C.useEffect(()=>{e!=null&&e.timezone&&i(e.timezone)},[e==null?void 0:e.timezone]);const n=C.useMemo(()=>uA(),[]),r=C.useMemo(()=>new Set(n),[n]),o=we({mutationFn:d=>ee.putHarness({timezone:d}),onSuccess:d=>{q.success(d.restarted.length>0?`timezone saved · reloaded ${d.restarted.length} agent(s)`:"timezone saved"),s.invalidateQueries({queryKey:["harness"]}),s.invalidateQueries({queryKey:["agents"]})},onError:d=>q.error(`save failed: ${d.message}`)}),a=t.trim(),l=r.has(a),c=!!e&&a.length>0&&a!==e.timezone;return h.jsxs(it,{children:[h.jsxs(ut,{children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(i1,{className:"size-4 text-primary/80"}),h.jsx(nt,{children:"Timezone"})]}),h.jsxs(ft,{children:["IANA timezone used for ",h.jsx("code",{children:"<harness-metadata>"})," ","timestamps and scheduler cron firing. Saving reloads every running agent."]})]}),h.jsxs(Pn,{className:"flex flex-wrap items-end gap-2",children:[h.jsxs("div",{className:"flex min-w-[14rem] flex-1 flex-col gap-1.5",children:[h.jsx(It,{className:"font-mono text-xs",htmlFor:"harness-tz-input",children:"timezone"}),h.jsx(at,{id:"harness-tz-input",list:"harness-tz-options",value:t,onChange:d=>i(d.target.value),placeholder:"Search… e.g. Asia/Kolkata",autoComplete:"off",className:"font-mono text-xs"}),h.jsx("datalist",{id:"harness-tz-options",children:n.map(d=>h.jsx("option",{value:d},d))}),a.length>0&&!l&&h.jsx("span",{className:"text-[11px] text-warning",children:"● not a recognized IANA timezone"})]}),h.jsxs(J,{size:"sm",disabled:!c||!l||o.isPending,onClick:()=>o.mutate(a),children:[o.isPending?h.jsx($e,{className:"size-4 animate-spin"}):h.jsx(Ki,{className:"size-4"}),"Save"]})]})]})}function uA(){const s=Intl;if(typeof s.supportedValuesOf=="function")try{return s.supportedValuesOf("timeZone")}catch{}return["UTC","America/Los_Angeles","America/New_York","Europe/London","Europe/Berlin","Asia/Kolkata","Asia/Singapore","Asia/Tokyo","Australia/Sydney"]}const rn="__CLEAR__";function Xc(s){for(const e of["models","agents","agent"])s.invalidateQueries({queryKey:[e]})}function fA(){const{data:s,isLoading:e}=Ie({queryKey:["models"],queryFn:ee.getModels});return h.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[h.jsxs("header",{className:"border-b py-3 pl-14 pr-4 md:px-6",children:[h.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[h.jsxs(Rt,{to:"/settings",className:"inline-flex items-center gap-1 hover:text-foreground",children:[h.jsx(Ep,{className:"size-3"}),"Settings"]}),h.jsx("span",{children:"·"}),h.jsx("span",{children:"Models"})]}),h.jsx("h1",{className:"text-lg font-semibold",children:"Models"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Provider credentials and the model allowlist agents can choose from. Saving here automatically reloads any running agent that uses a changed provider — no server restart needed."})]}),h.jsx("div",{className:"flex-1 overflow-y-auto p-4 sm:p-6",children:e||!s?h.jsx("div",{className:"text-sm text-muted-foreground",children:"loading…"}):h.jsxs("div",{className:"grid gap-4",children:[h.jsx(it,{className:"border-warning/40 bg-warning/5",children:h.jsxs(ut,{children:[h.jsx(nt,{className:"text-sm",children:"Plaintext storage"}),h.jsxs(ft,{className:"mt-1",children:["Provider credentials are stored unencrypted at"," ",h.jsx("code",{children:s.path}),". v1 will encrypt at rest. OAuth subscription tokens are stored separately in pi's own"," ",h.jsx("code",{children:".secrets/pi/auth.json"}),", one per harness."]})]})}),s.providers.map(t=>h.jsx(pA,{provider:t,mask:s.mask},t.id))]})})]})}function pA({provider:s,mask:e}){var N;const t=Xe(),[i,n]=C.useState({credentials:{},enabledModels:new Set(s.enabledModels)}),[r,o]=C.useState("");C.useEffect(()=>{n({credentials:{},enabledModels:new Set(s.enabledModels)}),o("")},[s.enabledModels,s.credentialValues]);const a=C.useMemo(()=>{const y=new Set(s.catalogModels);for(const w of s.enabledModels)y.add(w);return[...y]},[s.catalogModels,s.enabledModels]),l=C.useMemo(()=>new Set(s.enabledModels),[s.enabledModels]),c=C.useMemo(()=>{if(Object.keys(i.credentials).length>0||i.enabledModels.size!==l.size)return!0;for(const y of i.enabledModels)if(!l.has(y))return!0;return!1},[i,l]),d=C.useMemo(()=>{var y;if((y=s.oauth)!=null&&y.connected)return!0;for(const w of s.credentials){if(!w.required)continue;const k=i.credentials[w.key];if(k===rn)return!1;if(k!==void 0){if(k.length===0)return!1;continue}if((s.credentialValues[w.key]??"").length===0)return!1}return!0},[s.credentials,s.credentialValues,s.oauth,i.credentials]),u=we({mutationFn:y=>ee.putModels(y),onSuccess:()=>{q.success("saved · agents using this provider reloaded"),Xc(t)},onError:y=>q.error(`save failed: ${y.message}`)}),f=(y,w)=>{n(k=>{const M={...k.credentials};return w===void 0?delete M[y]:M[y]=w,{...k,credentials:M}})},p=y=>{n(w=>{const k=new Set(w.enabledModels);return k.has(y)?k.delete(y):k.add(y),{...w,enabledModels:k}})},m=()=>{const y=r.trim();y&&(n(w=>{const k=new Set(w.enabledModels);return k.add(y),{...w,enabledModels:k}}),o(""))},g=y=>{n(w=>{const k=new Set(w.enabledModels);return k.delete(y),{...w,enabledModels:k}})},x=()=>{n({credentials:{},enabledModels:new Set(s.enabledModels)}),o("")},b=()=>{const y={};for(const[k,M]of Object.entries(i.credentials))M!==void 0&&(y[k]=M===rn?null:M);const w={enabledModels:[...i.enabledModels]};Object.keys(y).length>0&&(w.credentials=y),u.mutate({providers:{[s.id]:w}})},S=[...i.enabledModels].filter(y=>!s.catalogModels.includes(y));return h.jsxs(it,{children:[h.jsxs(ut,{children:[h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[h.jsx(Jo,{className:"size-4 text-primary/80"}),h.jsx(nt,{children:s.displayName}),h.jsx(rt,{variant:"outline",className:"font-mono",children:s.id}),s.configured?h.jsx(rt,{variant:"secondary",children:"configured"}):h.jsx(rt,{variant:"outline",children:"incomplete"}),h.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[h.jsxs(J,{variant:"outline",size:"sm",onClick:x,disabled:!c||u.isPending,children:[h.jsx(Da,{className:"size-3.5"})," Reset"]}),h.jsxs(J,{size:"sm",onClick:b,disabled:!c||u.isPending,children:[u.isPending?h.jsx($e,{className:"size-4 animate-spin"}):h.jsx(Ki,{className:"size-4"}),"Save"]})]})]}),s.notes&&h.jsx(ft,{className:"mt-1 text-[11px]",children:s.notes})]}),h.jsx(Zt,{}),h.jsxs("div",{className:"grid gap-5 p-4",children:[((N=s.oauth)==null?void 0:N.supported)&&h.jsx(mA,{provider:s}),s.credentials.length>0&&h.jsxs("div",{children:[h.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[h.jsx(Vp,{className:"size-3.5 text-primary/60"}),h.jsx("h3",{className:"text-sm font-medium",children:"Credentials"}),!d&&h.jsx("span",{className:"text-[11px] text-warning",children:"required field(s) missing"})]}),h.jsx("div",{className:"grid gap-3",children:s.credentials.map(y=>h.jsx(gA,{field:y,serverValue:s.credentialValues[y.key]??"",draftValue:i.credentials[y.key],mask:e,onChange:w=>f(y.key,w)},y.key))})]}),h.jsx(Zt,{}),h.jsxs("div",{children:[h.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[h.jsx(Jo,{className:"size-3.5 text-primary/60"}),h.jsx("h3",{className:"text-sm font-medium",children:"Enabled models"}),h.jsx("span",{className:"text-[11px] text-muted-foreground",children:"only checked models can be selected by agents"})]}),a.length===0?h.jsx("p",{className:"text-xs text-muted-foreground",children:"No catalog models — add a custom model id below."}):h.jsx("div",{className:"grid gap-1.5 sm:grid-cols-2",children:a.map(y=>{const w=i.enabledModels.has(y),k=!s.catalogModels.includes(y);return h.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-md border p-2 transition-colors hover:bg-accent/40",children:[h.jsx("input",{type:"checkbox",checked:w,onChange:()=>p(y),className:"size-4 accent-primary"}),h.jsx("span",{className:"font-mono text-xs",children:y}),k&&h.jsx(rt,{variant:"outline",className:"ml-auto text-[10px]",children:"custom"})]},y)})}),h.jsxs("div",{className:"mt-3",children:[h.jsx(It,{className:"text-xs",children:"Add custom model id"}),h.jsxs("div",{className:"mt-1 flex items-center gap-1",children:[h.jsx(at,{value:r,onChange:y=>o(y.target.value),placeholder:"e.g. my-org/my-model",onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),m())},className:"font-mono text-xs"}),h.jsx(J,{type:"button",variant:"outline",size:"icon",onClick:m,"aria-label":"add",children:h.jsx(ah,{className:"size-4"})})]}),S.length>0&&h.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:S.map(y=>h.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border bg-secondary px-2 py-0.5 font-mono text-[11px]",children:[y,h.jsx("button",{type:"button",onClick:()=>g(y),"aria-label":`remove ${y}`,className:"text-muted-foreground hover:text-foreground",children:h.jsx(_i,{className:"size-3"})})]},y))})]})]})]})]})}function mA({provider:s}){var f,p,m,g;const e=Xe(),[t,i]=C.useState(!1),[n,r]=C.useState(""),a=Ie({queryKey:["oauth-status",s.id],queryFn:()=>ee.getOauthStatus(s.id),enabled:t,refetchInterval:x=>{var b;return((b=x.state.data)==null?void 0:b.state)==="pending"?1e3:!1}}).data;C.useEffect(()=>{!t||(a==null?void 0:a.state)!=="success"||(i(!1),r(""),q.success("signed in · agents using this provider reloaded"),Xc(e))},[t,a==null?void 0:a.state,e]);const l=we({mutationFn:()=>ee.startOauthLogin(s.id),onSuccess:x=>{i(!0),x.url&&window.open(x.url,"_blank","noopener")},onError:x=>q.error(`sign-in failed to start: ${x.message}`)}),c=we({mutationFn:({value:x,kind:b})=>ee.submitOauthInput(s.id,x,b),onSuccess:()=>r(""),onError:x=>q.error(`submit failed: ${x.message}`)}),d=we({mutationFn:()=>ee.cancelOauthLogin(s.id),onSuccess:()=>i(!1)}),u=we({mutationFn:()=>ee.oauthLogout(s.id),onSuccess:()=>{q.success("signed out · agents using this provider reloaded"),Xc(e)},onError:x=>q.error(`sign-out failed: ${x.message}`)});return h.jsxs("div",{children:[h.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[h.jsx(tc,{className:"size-3.5 text-primary/60"}),h.jsx("h3",{className:"text-sm font-medium",children:"Subscription sign-in"}),((f=s.oauth)==null?void 0:f.connected)&&h.jsx(rt,{variant:"secondary",children:"OAuth connected"})]}),(p=s.oauth)!=null&&p.connected?h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[h.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Tokens are stored in pi's ",h.jsx("code",{children:"auth.json"})," and auto-refreshed. OAuth takes precedence over an API key."]}),h.jsxs(J,{type:"button",variant:"outline",size:"sm",onClick:()=>u.mutate(),disabled:u.isPending,children:[u.isPending?h.jsx($e,{className:"size-3.5 animate-spin"}):h.jsx(oh,{className:"size-3.5"}),"Sign out"]})]}):t?h.jsxs("div",{className:"grid gap-2 rounded-md border bg-accent/20 p-3",children:[(a==null?void 0:a.state)==="error"?h.jsx("p",{className:"text-xs text-destructive",children:a.message}):h.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[h.jsx($e,{className:"size-3.5 animate-spin"}),"waiting for sign-in to complete…"]}),(a==null?void 0:a.state)==="pending"&&a.select&&h.jsxs("div",{className:"grid gap-1.5",children:[h.jsx("p",{className:"text-xs",children:a.select.message}),h.jsx("div",{className:"flex flex-wrap gap-2",children:a.select.options.map(x=>h.jsx(J,{type:"button",variant:"outline",size:"sm",onClick:()=>c.mutate({value:x.id,kind:"select"}),disabled:c.isPending,children:x.label},x.id))})]}),(a==null?void 0:a.state)==="pending"&&a.deviceCode&&h.jsxs("div",{className:"grid gap-1",children:[h.jsx("p",{className:"text-xs",children:"Open the verification page and enter this code:"}),h.jsx("code",{className:"w-fit rounded-md border bg-secondary px-2 py-1 font-mono text-sm tracking-widest",children:a.deviceCode.userCode}),h.jsxs("a",{href:a.deviceCode.verificationUri,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-primary hover:underline",children:[h.jsx(wd,{className:"size-3"}),a.deviceCode.verificationUri]})]}),(a==null?void 0:a.instructions)&&h.jsx("p",{className:"text-[11px] text-muted-foreground",children:a.instructions}),(a==null?void 0:a.url)&&h.jsxs("a",{href:a.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-primary hover:underline",children:[h.jsx(wd,{className:"size-3"}),"open sign-in page"]}),(a==null?void 0:a.state)==="pending"&&!a.select&&!a.deviceCode&&h.jsxs("div",{className:"grid gap-1",children:[h.jsx("p",{className:"text-[11px] text-muted-foreground",children:((m=a.prompt)==null?void 0:m.message)??"If this harness runs on a different machine than your browser, the final redirect will land on a localhost URL that fails to load — copy that URL from the address bar and paste it here."}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx(at,{value:n,onChange:x=>r(x.target.value),placeholder:((g=a.prompt)==null?void 0:g.placeholder)??"http://localhost:…/callback?code=…&state=…",className:"font-mono text-xs",onKeyDown:x=>{x.key==="Enter"&&n.trim()&&(x.preventDefault(),c.mutate({value:n.trim(),kind:"text"}))}}),h.jsx(J,{type:"button",variant:"outline",size:"sm",onClick:()=>c.mutate({value:n.trim(),kind:"text"}),disabled:!n.trim()||c.isPending,children:c.isPending?h.jsx($e,{className:"size-3.5 animate-spin"}):"Submit"})]})]}),h.jsx("div",{children:h.jsx(J,{type:"button",variant:"ghost",size:"sm",className:"text-[11px] text-muted-foreground",onClick:()=>(a==null?void 0:a.state)==="error"?i(!1):d.mutate(),children:(a==null?void 0:a.state)==="error"?"Dismiss":"Cancel"})})]}):h.jsxs(J,{type:"button",variant:"outline",size:"sm",onClick:()=>l.mutate(),disabled:l.isPending,children:[l.isPending?h.jsx($e,{className:"size-3.5 animate-spin"}):h.jsx(tc,{className:"size-3.5"}),"Sign in with ",s.displayName]})]})}function gA({field:s,serverValue:e,draftValue:t,mask:i,onChange:n}){const[r,o]=C.useState(!1),a=e.length>0,l=t===rn,c=t!==void 0&&t!==rn&&t.length>0,d=t===void 0?s.secret?"":e:t===rn?"":t,u=s.secret&&a?i:s.placeholder??"(not set)";return h.jsxs("div",{children:[h.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[h.jsxs(It,{className:"text-xs",children:[s.label,s.required&&h.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),h.jsx("code",{className:"text-[10px] text-muted-foreground",children:s.envVar}),c&&h.jsx("span",{className:"text-[10px] text-warning",children:"● new value"}),l&&h.jsx("span",{className:"text-[10px] text-destructive",children:"● will clear"})]}),h.jsxs("div",{className:"flex items-start gap-1",children:[s.multiline?h.jsx(Gh,{value:d,placeholder:u,rows:6,className:"font-mono text-xs",onChange:f=>n(f.target.value.length===0?void 0:f.target.value)}):h.jsx(at,{type:s.secret&&!r?"password":"text",value:d,placeholder:u,className:"font-mono text-xs",onChange:f=>n(f.target.value.length===0?void 0:f.target.value)}),s.secret&&!s.multiline&&h.jsx(J,{type:"button",variant:"ghost",size:"icon",onClick:()=>o(f=>!f),"aria-label":r?"hide":"reveal",children:r?h.jsx(Bp,{className:"size-4"}):h.jsx(zp,{className:"size-4"})}),a&&h.jsx(J,{type:"button",variant:"ghost",size:"sm",className:"text-[11px] text-destructive hover:text-destructive",onClick:()=>n(rn),disabled:l,children:"Clear"})]}),s.helpText&&h.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:s.helpText})]})}const xA=new wy({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1}}});function yA(){return h.jsx(ky,{client:xA,children:h.jsxs(Kb,{delayDuration:200,children:[h.jsx(_x,{children:h.jsx(vA,{children:h.jsxs(ip,{children:[h.jsx(tt,{path:"/login",element:h.jsx(A1,{})}),h.jsx(tt,{element:h.jsx(wA,{}),children:h.jsxs(tt,{element:h.jsx(N1,{}),children:[h.jsx(tt,{path:"/",element:h.jsx(R1,{})}),h.jsx(tt,{path:"/agents/:id/*",element:h.jsx(nA,{})}),h.jsx(tt,{path:"/settings",element:h.jsx(cA,{})}),h.jsx(tt,{path:"/settings/models",element:h.jsx(fA,{})}),h.jsx(tt,{path:"*",element:h.jsx(on,{to:"/",replace:!0})})]})})]})})}),h.jsx(bA,{})]})})}function bA(){const{theme:s}=Vr();return h.jsx(ob,{theme:s,richColors:!0,position:"top-right"})}function vA({children:s}){const{refresh:e,status:t}=Ea(),i=Oa();return C.useEffect(()=>{e()},[e]),C.useEffect(()=>(xd(()=>i("/login",{replace:!0})),()=>xd(null)),[i]),t==="unknown"?h.jsx("div",{className:"grid h-full place-items-center text-sm text-muted-foreground",children:"loading…"}):h.jsx(h.Fragment,{children:s})}function wA(){const{status:s}=Ea(),e=Pa();return s!=="authed"?h.jsx(on,{to:"/login",replace:!0,state:{from:e}}):h.jsx(kA,{})}function kA(){return h.jsx(sp,{})}Ll.createRoot(document.getElementById("root")).render(h.jsx(R.StrictMode,{children:h.jsx(yA,{})}));export{n1 as $,mi as A,Yr as B,zA as C,BS as D,BA as E,qn as F,Xt as G,Jr as H,Ce as I,H0 as J,xe as K,Aa as L,sn as M,TA as N,Bg as O,Eg as P,pa as Q,Vr as R,Xe as S,Ft as T,Ie as U,we as V,bp as W,Vb as X,yr as Y,zp as Z,V as _,DN as a,J as a0,$e as a1,Ki as a2,nx as a3,ix as a4,qN as a5,q as a6,ee as a7,cx as a8,VN as a9,aM as aa,lM as ab,MS as b,G as c,ij as d,CS as e,fa as f,zg as g,RA as h,IA as i,Lu as j,DA as k,Wg as l,zS as m,LA as n,I as o,Je as p,T as q,SS as r,Dg as s,A as t,mt as u,le as v,Mh as w,Ee as x,OA as y,l2 as z};
|