@hybridaione/hybridclaw 0.26.0 → 0.27.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 +30 -0
- package/README.md +10 -4
- package/console/dist/assets/apps-BCUhkPkB.js +1 -0
- package/console/dist/assets/apps-fd_S5yFK.css +1 -0
- package/console/dist/assets/chat-B4ykLwkT.js +4 -0
- package/console/dist/assets/chat-sidebar-bGb6YbfM.js +5 -0
- package/console/dist/assets/{index-CkDPeA4c.js → index-Btzl6jZZ.js} +3 -3
- package/console/dist/assets/index-DuxG8IST.css +1 -0
- package/console/dist/assets/{terminal-6wR9ID9V.js → terminal-BOibs0Ai.js} +1 -1
- package/console/dist/index.html +2 -2
- package/console/package.json +1 -1
- package/container/dist/providers/openai-codex.js +2 -1
- package/container/dist/providers/openai-codex.js.map +1 -1
- package/container/npm-shrinkwrap.json +2 -2
- package/container/package-lock.json +2 -2
- package/container/package.json +1 -1
- package/container/src/providers/openai-codex.ts +5 -1
- package/dist/apps/app-generator.d.ts +21 -0
- package/dist/apps/app-generator.d.ts.map +1 -0
- package/dist/apps/app-generator.js +105 -0
- package/dist/apps/app-generator.js.map +1 -0
- package/dist/command-registry.d.ts.map +1 -1
- package/dist/command-registry.js +20 -0
- package/dist/command-registry.js.map +1 -1
- package/dist/gateway/gateway-chat-service.d.ts.map +1 -1
- package/dist/gateway/gateway-chat-service.js +6 -2
- package/dist/gateway/gateway-chat-service.js.map +1 -1
- package/dist/gateway/gateway-http-server.d.ts.map +1 -1
- package/dist/gateway/gateway-http-server.js +686 -4
- package/dist/gateway/gateway-http-server.js.map +1 -1
- package/dist/gateway/gateway-types.d.ts +17 -0
- package/dist/gateway/gateway-types.d.ts.map +1 -1
- package/dist/gateway/gateway-types.js.map +1 -1
- package/dist/memory/apps.d.ts +70 -0
- package/dist/memory/apps.d.ts.map +1 -0
- package/dist/memory/apps.js +206 -0
- package/dist/memory/apps.js.map +1 -0
- package/dist/memory/db.d.ts +8 -1
- package/dist/memory/db.d.ts.map +1 -1
- package/dist/memory/db.js +80 -3
- package/dist/memory/db.js.map +1 -1
- package/dist/types/activity-trace.d.ts +45 -0
- package/dist/types/activity-trace.d.ts.map +1 -0
- package/dist/types/activity-trace.js +138 -0
- package/dist/types/activity-trace.js.map +1 -0
- package/dist/types/session.d.ts +3 -0
- package/dist/types/session.d.ts.map +1 -1
- package/docs/content/README.md +20 -3
- package/docs/content/agents.md +1 -0
- package/docs/content/developer-guide/desktop-release.md +1 -1
- package/docs/content/developer-guide/runtime.md +5 -4
- package/docs/content/getting-started/README.md +1 -1
- package/docs/content/getting-started/local-vs-cloud.md +4 -3
- package/docs/content/getting-started/quickstart.md +3 -1
- package/docs/content/guides/README.md +3 -1
- package/docs/content/guides/apps.md +107 -0
- package/docs/content/guides/remote-access.md +5 -4
- package/docs/content/navigation.json +4 -0
- package/docs/content/reference/commands.md +3 -0
- package/docs/content/reference/configuration.md +3 -2
- package/docs/content/reference/faq.md +3 -2
- package/npm-shrinkwrap.json +5 -5
- package/package.json +1 -1
- package/console/dist/assets/chat-B3O0bG4k.js +0 -4
- package/console/dist/assets/index-ClyCVP4a.css +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/terminal-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/terminal-BOibs0Ai.js","assets/rolldown-runtime-Bh1tDfsg.js","assets/query-o_Dd9s85.js","assets/terminal-CCHv1x3w.js","assets/terminal-kHJ-D0s7.css","assets/chat-B4ykLwkT.js","assets/chat-sidebar-bGb6YbfM.js","assets/router-DoNPHesn.js","assets/chat-BBTk0x5Q.css","assets/apps-BCUhkPkB.js","assets/apps-fd_S5yFK.css"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{n as e,t}from"./rolldown-runtime-Bh1tDfsg.js";import{t as n}from"./vendor-GuSYcVD5.js";import{C as r,S as i,_ as a,a as o,b as s,c,d as l,f as u,g as d,h as f,i as p,l as m,m as h,n as g,o as _,p as v,r as y,s as b,t as x,u as S,v as C,x as w,y as T}from"./query-o_Dd9s85.js";import{a as E,c as D,d as O,f as k,i as A,l as j,n as M,o as N,r as P,s as F,t as I,u as ee}from"./router-DoNPHesn.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var L=`hybridclaw-theme`;function te(){if(typeof window>`u`)return`system`;let e=window.localStorage.getItem(L);return e===`light`||e===`dark`||e===`system`?e:`system`}function ne(){return typeof window>`u`?`light`:window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}function re(e,t){return e===`system`?t:e}function ie(e){if(typeof document>`u`)return;let t=document.documentElement;t.dataset.theme=e,t.style.colorScheme=e}function ae(){let e=te(),t=re(e,ne());return ie(t),{theme:e,resolved:t}}ae();var oe=class extends i{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new b({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=se(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=se(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=se(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=se(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){S.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>f(t,e))}findAll(e={}){return this.getAll().filter(t=>f(e,t))}notify(e){S.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return S.batch(()=>Promise.all(e.map(e=>e.continue().catch(a))))}};function se(e){return e.options.scope?.id}var ce=class extends i{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??v(r,t),a=this.get(i);return a||(a=new c({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){S.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>d(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>d(e,t)):t}notify(e){S.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){S.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){S.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},le=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new ce,this.#t=e.mutationCache||new oe,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=w.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=m.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(T(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=l(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return S.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;S.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return S.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=S.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(a).catch(a)}invalidateQueries(e,t={}){return S.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=S.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(a)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(a)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(T(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(a).catch(a)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(a).catch(a)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return m.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(u(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{C(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(u(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{C(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=v(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===s&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},R=e(r(),1),ue=e(n(),1),de=`hybridclaw_token`,fe=`hybridclaw:auth-required`,pe=`__hybridclaw_token_bootstrapped`,me=`hybridclaw_local_auth_reload_at`,he=15e3,ge=()=>window.location.reload();function _e(e,t){let n=e.trim();return{...n?{Authorization:`Bearer ${n}`}:{},...t===void 0?{}:{"Content-Type":`application/json`}}}function ve(e){return{sessionId:e.sessionId,guildId:null,channelId:`web`,args:e.args,...e.userId?{userId:e.userId}:{},...e.username?{username:e.username}:{}}}function ye(e){ke(),!be()&&window.dispatchEvent(new CustomEvent(fe,{detail:{message:e}}))}function be(){if(!xe())return!1;let e=Date.now(),t=Number(window.sessionStorage.getItem(me)||`0`);if(Number.isFinite(t)){let n=e-t;if(n>=0&&n<he)return!1}return window.sessionStorage.setItem(me,String(e)),ge(),!0}function xe(){if(!Se(window.location.hostname))return!1;let e=window.location.pathname;return e===`/admin`||e.startsWith(`/admin/`)||e===`/chat`||e.startsWith(`/chat/`)}function Se(e){let t=e.toLowerCase();return t===`localhost`||t===`::1`||t===`[::1]`||/^127(?:\.\d{1,3}){3}$/.test(t)}async function Ce(e){let t=`${e.status} ${e.statusText}`,n=(await e.text().catch(()=>``)).trim();if(!n)return t;try{let e=JSON.parse(n);return e.error||e.text||n}catch{return n}}var we=class extends Error{status;constructor(e,t){super(e),this.name=`HttpResponseError`,this.status=t}};async function Te(e,t){let n=await Ce(e);throw e.status===401&&t?.onAuthError!==`ignore`&&ye(n),new we(n,e.status)}async function z(e,t){let n=await fetch(e,{method:t.method||`GET`,headers:{..._e(t.token,t.body),...t.extraHeaders},body:t.body===void 0?t.rawBody??void 0:JSON.stringify(t.body)});return n.ok||await Te(n,{onAuthError:t.onAuthError}),await n.json().catch(()=>({}))}function Ee(){return De([`token`,pe]),ke(),``}function De(e){let t=new URL(window.location.href),n=!1;for(let r of e)t.searchParams.has(r)&&(t.searchParams.delete(r),n=!0);n&&window.history.replaceState(window.history.state,``,`${t.pathname}${t.search}${t.hash}`)}function Oe(e){ke()}function ke(){window.sessionStorage.removeItem(de),window.localStorage.removeItem(de)}function Ae(e){return`/api/events`}function je(e){return z(`/api/status`,{token:e,onAuthError:`ignore`})}function Me(){return z(`/health`,{token:``,onAuthError:`ignore`})}function Ne(e){return z(`/api/admin/overview`,{token:e})}function Pe(e){return z(`/api/admin/tunnel`,{token:e})}function Fe(e,t){return z(`/api/admin/tunnel`,{token:e,method:`PUT`,body:t})}async function Ie(e){return(await z(`/api/admin/tunnel/reconnect`,{token:e,method:`POST`})).tunnel}async function Le(e){return(await z(`/api/admin/tunnel/stop`,{token:e,method:`POST`})).tunnel}function Re(e,t){return z(`/api/admin/statistics${typeof t==`number`&&Number.isFinite(t)?`?days=${Math.max(1,Math.floor(t))}`:``}`,{token:e})}function ze(e,t){let n=new URLSearchParams;t?.fileId&&n.set(`file`,t.fileId),t?.tailBytes&&n.set(`tailBytes`,String(t.tailBytes));let r=n.toString();return z(r?`/api/admin/logs?${r}`:`/api/admin/logs`,{token:e})}function Be(e){return z(`/api/admin/a2a/trust`,{token:e})}function Ve(e){return z(`/api/admin/fleet-topology`,{token:e})}function He(e){return z(`/api/admin/distill`,{token:e})}function Ue(e,t){return z(`/api/admin/distill/subjects`,{token:e,method:`POST`,body:t})}function We(e,t){return z(`/api/admin/distill/consent`,{token:e,method:`POST`,body:t})}function Ge(e,t){return z(`/api/admin/distill/register`,{token:e,method:`POST`,body:t})}function Ke(e,t){return z(`/api/admin/distill/runs`,{token:e,method:`POST`,body:t})}function qe(e,t,n){let r=new URLSearchParams({alias:n.alias});return n.agentId?.trim()&&r.set(`agentId`,n.agentId.trim()),n.kind?.trim()&&r.set(`kind`,n.kind.trim()),z(`/api/admin/distill/sources/upload?${r.toString()}`,{token:e,method:`POST`,rawBody:t,extraHeaders:{"Content-Type":t.type||`application/octet-stream`,"X-Hybridclaw-Filename":encodeURIComponent(t.name||`source.txt`)}})}function Je(e){let t=new URLSearchParams({alias:e.alias});return e.agentId?.trim()&&t.set(`agentId`,e.agentId.trim()),`/api/admin/distill/corpus/${encodeURIComponent(e.documentId)}?${t.toString()}`}async function Ye(e,t){let n=await fetch(Je(t),{headers:_e(e),cache:`no-store`});return n.ok||await Te(n),n.blob()}function Xe(e,t){return z(Je(t),{token:e,method:`DELETE`})}function Ze(e,t){return z(`/api/admin/fleet-topology`,{token:e,method:`POST`,body:t})}function Qe(e,t){return z(`/api/admin/fleet-topology?${new URLSearchParams({peerId:t}).toString()}`,{token:e,method:`DELETE`})}function $e(e,t){return z(`/api/admin/a2a/inbox${t?.trim()?`?${new URLSearchParams({threadId:t.trim()}).toString()}`:``}`,{token:e})}function et(e,t){let n=new URLSearchParams({peerId:t.peerId});return t.reason?.trim()&&n.set(`reason`,t.reason.trim()),z(`/api/admin/a2a/trust?${n.toString()}`,{token:e,method:`DELETE`})}function tt(e,t){return z(`/api/admin/a2a/trust`,{token:e,method:`POST`,body:t})}function nt(e,t){return z(`/api/admin/a2a/trust?${new URLSearchParams({peerId:t,action:`delete`}).toString()}`,{token:e,method:`DELETE`})}function rt(e,t){return z(`/api/admin/a2a/pairing`,{token:e,method:`POST`,body:t})}function it(e,t){return z(`/api/admin/a2a/pairing/preview`,{token:e,method:`POST`,body:t})}function at(e,t,n){return z(`/api/admin/a2a/pairing/approve`,{token:e,method:`POST`,body:{requestId:t,...n?.trim()?{reason:n.trim()}:{}}})}function ot(e,t,n){return z(`/api/admin/a2a/pairing/decline`,{token:e,method:`POST`,body:{requestId:t,...n?.trim()?{reason:n.trim()}:{}}})}function st(e){return z(`/api/admin/config/reload`,{token:e,method:`POST`})}function ct(e,t){return z(`/api/admin/terminal`,{token:e,method:`POST`,body:t??{}})}function lt(e,t){return z(`/api/admin/terminal?${new URLSearchParams({sessionId:t}).toString()}`,{token:e,method:`DELETE`})}function ut(e,t){let n=window.location.protocol===`https:`?`wss:`:`ws:`,r=new URL(`/api/admin/terminal/stream`,`${n}//${window.location.host}`);return r.searchParams.set(`sessionId`,t),r.toString()}function dt(e){return z(`/api/agents`,{token:e})}async function ft(e){let t=await z(`/api/agents/list`,{token:e}),n=t.agents.map(e=>({...e,source:{type:`local`}})),r=(t.remotePeers??[]).flatMap(e=>e.agents.map(t=>({...t,source:{type:`remote`,peerId:e.peerId,instanceId:e.instanceId}})));return[...n,...r]}async function pt(e){return(await z(`/api/admin/agents`,{token:e})).agents}async function mt(e,t){let n=new URLSearchParams;t?.trim()&&n.set(`baseUrl`,t.trim());let r=n.toString();return(await z(`/api/admin/hybridai/bots${r?`?${r}`:``}`,{token:e})).bots}async function ht(e,t,n){return(await z(`/api/admin/agents/${encodeURIComponent(t)}`,{token:e,method:`PUT`,body:n})).agent}function gt(e){return z(`/api/admin/team-structure`,{token:e})}function _t(e,t){return z(`/api/admin/team-structure/revisions/${encodeURIComponent(String(t))}`,{token:e})}function vt(e,t){return z(`/api/admin/team-structure/revisions/${encodeURIComponent(String(t))}/restore`,{token:e,method:`POST`})}function yt(e,t){return z(`/api/admin/agents/${encodeURIComponent(t.agentId)}/files/${encodeURIComponent(t.fileName)}`,{token:e})}function bt(e,t){return z(`/api/admin/agents/${encodeURIComponent(t.agentId)}/files/${encodeURIComponent(t.fileName)}`,{token:e,method:`PUT`,body:{content:t.content}})}function xt(e,t){return z(`/api/admin/agents/${encodeURIComponent(t.agentId)}/files/${encodeURIComponent(t.fileName)}/revisions/${encodeURIComponent(t.revisionId)}`,{token:e})}function St(e,t){return z(`/api/admin/agents/${encodeURIComponent(t.agentId)}/files/${encodeURIComponent(t.fileName)}/revisions/${encodeURIComponent(t.revisionId)}/restore`,{token:e,method:`POST`})}function Ct(e){return z(`/api/admin/jobs/context`,{token:e})}function wt(e,t){let n=new URLSearchParams;for(let e of t||[]){let t=e.trim();t&&n.append(`agentId`,t)}let r=n.toString();return z(`/api/admin/jobs/budgets${r?`?${r}`:``}`,{token:e})}async function Tt(e){return(await z(`/api/admin/sessions`,{token:e})).sessions}function Et(e){return z(`/api/admin/email`,{token:e})}function Dt(e,t){let n=new URLSearchParams({folder:t.folder});return typeof t.limit==`number`&&n.set(`limit`,String(t.limit)),typeof t.offset==`number`&&n.set(`offset`,String(t.offset)),z(`/api/admin/email/messages?${n.toString()}`,{token:e})}function Ot(e,t){return z(`/api/admin/email/message?${new URLSearchParams({folder:t.folder,uid:String(t.uid)}).toString()}`,{token:e})}function kt(e,t){return z(`/api/admin/email/message?${new URLSearchParams({folder:t.folder,uid:String(t.uid)}).toString()}`,{token:e,method:`DELETE`})}function At(e,t,n){let r=new URLSearchParams({sessionId:t});return n?.onlyWithoutUserMessages&&r.set(`ifNoUserMessages`,`1`),z(`/api/admin/sessions?${r.toString()}`,{token:e,method:`DELETE`})}function jt(e){return z(`/api/admin/channels`,{token:e})}function Mt(e){return z(`/api/admin/config`,{token:e})}function Nt(e){return z(`/api/admin/browser-pool/health`,{token:e})}function Pt(e){return z(`/api/admin/browser-pool/start`,{method:`POST`,token:e})}function Ft(e,t={}){let n=new URLSearchParams,r=String(t.handleId||``).trim();r&&n.set(`handleId`,r);let i=n.toString();return z(`/api/admin/email-config/fetch${i?`?${i}`:``}`,{token:e})}function It(e,t){return z(`/api/admin/config`,{token:e,method:`PUT`,body:{config:t}})}function Lt(e,t){return z(`/api/admin/slack-webhook-targets`,{token:e,method:`PUT`,body:t})}function Rt(e,t){return z(`/api/admin/discord-webhook-targets`,{token:e,method:`PUT`,body:t})}function zt(e,t){return z(`/api/admin/signal/link`,{token:e,method:`POST`,body:t})}function Bt(e){return z(`/api/admin/signal/link`,{token:e})}function Vt(e,t){return z(`/api/command`,{token:e,method:`POST`,body:ve({sessionId:`web-admin-secrets`,args:t})})}function Ht(e,t,n){return Vt(e,[`secret`,`set`,t,n])}function Ut(e){return z(`/api/admin/secrets`,{token:e})}function Wt(e,t,n){return z(`/api/admin/secrets/${encodeURIComponent(t)}`,{token:e,method:`PUT`,body:{value:n}})}function Gt(e,t){return z(`/api/admin/secrets/${encodeURIComponent(t)}`,{token:e,method:`DELETE`})}function Kt(e){return z(`/api/admin/models`,{token:e})}function qt(e,t){return z(`/api/admin/models`,{token:e,method:`PUT`,body:t})}function Jt(e){return z(`/api/admin/scheduler`,{token:e})}function Yt(e,t){return z(`/api/admin/scheduler`,{token:e,method:`PUT`,body:{job:t}})}function Xt(e,t){return z(`/api/admin/scheduler?${new URLSearchParams(t.source===`task`?{source:`task`,taskId:String(t.taskId??``)}:{jobId:t.id}).toString()}`,{token:e,method:`DELETE`})}function Zt(e,t){return z(`/api/admin/scheduler`,{token:e,method:`POST`,body:t})}function Qt(e,t){return z(`/api/admin/scheduler`,{token:e,method:`POST`,body:{action:`move`,...t}})}function $t(e){return z(`/api/admin/mcp`,{token:e})}function en(e){return z(`/api/admin/connectors`,{token:e})}function tn(e,t){return z(`/api/admin/connectors/hybridai/key`,{token:e,method:`PUT`,body:{apiKey:t}})}function nn(e,t){return z(`/api/admin/connectors/oauth/start`,{token:e,method:`POST`,body:t})}function rn(e,t){return z(`/api/admin/connectors/logout`,{token:e,method:`POST`,body:{provider:t}})}function an(e,t){return z(`/api/admin/connectors/test`,{token:e,method:`POST`,body:{provider:t}})}function on(e,t){return z(`/api/admin/mcp`,{token:e,method:`PUT`,body:t})}function sn(e,t){return z(`/api/admin/mcp?${new URLSearchParams({name:t}).toString()}`,{token:e,method:`DELETE`})}function cn(e,t){return z(`/api/admin/mcp/oauth/start`,{token:e,method:`POST`,body:{name:t}})}function ln(e,t){return z(`/api/admin/mcp/oauth/status?${new URLSearchParams({name:t}).toString()}`,{token:e})}function un(e,t){return z(`/api/admin/mcp/oauth/logout`,{token:e,method:`POST`,body:{name:t}})}function dn(e,t){let n=new URLSearchParams;t.query&&n.set(`query`,t.query),t.sessionId&&n.set(`sessionId`,t.sessionId),t.eventType&&n.set(`eventType`,t.eventType),t.since&&n.set(`since`,t.since),t.until&&n.set(`until`,t.until),typeof t.cursor==`number`&&t.cursor>0&&n.set(`cursor`,String(t.cursor)),typeof t.limit==`number`&&n.set(`limit`,String(t.limit));let r=n.toString();return z(r?`/api/admin/audit?${r}`:`/api/admin/audit`,{token:e})}function fn(e,t){let n=new URLSearchParams;t?.agentId&&n.set(`agentId`,t.agentId);let r=n.toString();return z(r?`/api/admin/approvals?${r}`:`/api/admin/approvals`,{token:e})}function pn(e,t){return z(`/api/interactive-escalations/resume`,{token:e,method:`POST`,body:t})}function mn(e,t){return z(`/api/admin/policy`,{token:e,method:`PUT`,body:t})}function hn(e,t){return z(`/api/admin/policy`,{token:e,method:`PUT`,body:t})}function gn(e,t){return z(`/api/admin/policy`,{token:e,method:`PUT`,body:{agentId:t.agentId,lanHttpAccessMode:t.mode}})}function _n(e,t){return z(`/api/admin/policy`,{token:e,method:`PUT`,body:t})}function vn(e,t){return z(`/api/admin/policy?${new URLSearchParams({agentId:t.agentId,index:String(t.index)}).toString()}`,{token:e,method:`DELETE`})}function yn(e){return z(`/api/admin/skills`,{token:e})}function bn(e,t){return z(`/api/admin/skills`,{token:e,method:`POST`,body:t})}function xn(e,t,n){return z(n?.force?`/api/admin/skills/upload?force=true`:`/api/admin/skills/upload`,{token:e,method:`POST`,rawBody:t,extraHeaders:{"Content-Type":`application/zip`}})}function Sn(e,t){return z(`/api/admin/skills/unblock`,{token:e,method:`POST`,body:{name:t}})}function Cn(e,t){return z(`/api/admin/skills/${encodeURIComponent(t)}/files`,{token:e})}function wn(e,t){return z(`/api/admin/skills/${encodeURIComponent(t)}/invocations`,{token:e})}function Tn(e,t){return z(`/api/admin/skills/${encodeURIComponent(t.skillName)}/files/content?path=${encodeURIComponent(t.path)}`,{token:e})}function En(e,t){return z(`/api/admin/skills/${encodeURIComponent(t.skillName)}/files/content?path=${encodeURIComponent(t.path)}`,{token:e,method:`PUT`,body:{content:t.content}})}function Dn(e){return z(`/api/admin/plugins`,{token:e})}function On(e){return z(`/api/admin/output-guard`,{token:e})}function kn(e,t){return z(`/api/admin/output-guard`,{token:e,method:`PUT`,body:{profile:t}})}function An(e,t,n){return z(`/api/admin/output-guard/preview`,{token:e,method:`POST`,body:{profile:t,sample:n}})}function jn(e){return z(`/api/skills/health`,{token:e})}function Mn(e){return z(`/api/admin/agent-scoreboard`,{token:e})}function Nn(e,t){return z(`/api/admin/harness-evolution?${new URLSearchParams({targetRoot:t}).toString()}`,{token:e})}function Pn(e,t,n){return z(`/api/admin/harness-evolution?${new URLSearchParams({targetRoot:t,summaryPath:n}).toString()}`,{token:e})}function Fn(e,t,n){return z(`/api/admin/harness-evolution?${new URLSearchParams({targetRoot:t,manifestPath:n}).toString()}`,{token:e})}function In(e){return z(`/api/skills/amendments`,{token:e})}function Ln(e,t){return z(`/api/skills/amendments/${encodeURIComponent(t)}`,{token:e})}function Rn(e,t,n=`console`){return z(`/api/skills/amendments/${encodeURIComponent(t)}/apply`,{token:e,method:`POST`,body:{reviewedBy:n}})}function zn(e,t,n=`console`){return z(`/api/skills/amendments/${encodeURIComponent(t)}/reject`,{token:e,method:`POST`,body:{reviewedBy:n}})}function Bn(e){return z(`/api/admin/tools`,{token:e})}function Vn(e,t){return z(`/api/admin/skills`,{token:e,method:`PUT`,body:t})}var B=_(),Hn=(0,R.createContext)(null);function Un(e){let[t]=(0,R.useState)(()=>Ee()),[n,r]=(0,R.useState)({status:`checking`,token:t,gatewayStatus:null,error:null});(0,R.useEffect)(()=>{let e=!1;return(async()=>{try{let n=await Me();if(e)return;if(n.webAuthConfigured){if(!t.trim()){try{let t=await je(``);if(e)return;r({status:`ready`,token:``,gatewayStatus:t,error:null});return}catch{if(e)return}r({status:`prompt`,token:``,gatewayStatus:null,error:null});return}try{let n=await je(t);if(e)return;r({status:`ready`,token:t,gatewayStatus:n,error:null});return}catch(t){if(e)return;ke(),r({status:`prompt`,token:``,gatewayStatus:null,error:t instanceof Error?t.message:String(t)});return}}try{let n=await je(t);if(e)return;r({status:`ready`,token:t,gatewayStatus:n,error:null})}catch{if(e)return;ke(),r({status:`error`,token:``,gatewayStatus:n,error:`This admin console is localhost-only unless WEB_API_TOKEN is configured.`})}}catch(t){if(e)return;r({status:`error`,token:``,gatewayStatus:null,error:t instanceof Error?t.message:String(t)})}})(),()=>{e=!0}},[t]),(0,R.useEffect)(()=>{let e=e=>{let t=e instanceof CustomEvent&&e.detail&&typeof e.detail==`object`?e.detail:null;r({status:`prompt`,token:``,gatewayStatus:null,error:typeof t?.message==`string`?t.message:`API token required.`})};return window.addEventListener(fe,e),()=>{window.removeEventListener(fe,e)}},[]);let i=(0,R.useCallback)(async e=>{let t=e.trim();if(!t){r({status:`prompt`,token:``,gatewayStatus:null,error:`Enter a WEB_API_TOKEN to continue.`});return}r({status:`checking`,token:t,gatewayStatus:null,error:null});try{let e=await je(t);Oe(t),r({status:`ready`,token:t,gatewayStatus:e,error:null})}catch(e){ke(),r({status:`prompt`,token:``,gatewayStatus:null,error:e instanceof Error?e.message:String(e)})}},[]),a=(0,R.useCallback)(()=>{ke(),r(e=>e.gatewayStatus?.webAuthConfigured?{status:`prompt`,token:``,gatewayStatus:null,error:null}:e.gatewayStatus?{status:`ready`,token:``,gatewayStatus:e.gatewayStatus,error:null}:{status:`checking`,token:``,gatewayStatus:null,error:null})},[]),o=(0,R.useCallback)(async()=>{window.location.reload()},[]),s=(0,R.useMemo)(()=>({...n,login:i,logout:a,retry:o}),[n,i,a,o]);return(0,B.jsx)(Hn.Provider,{value:s,children:e.children})}function Wn(e){return e.status===`ready`}function Gn(){let e=(0,R.useContext)(Hn);if(!e)throw Error(`useAuth must be used inside AuthProvider.`);return e}function Kn({children:e,viewBox:t=`0 0 24 24`,fill:n=`none`,stroke:r=`currentColor`,strokeWidth:i=`2`,...a}){return(0,B.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,viewBox:t,fill:n,stroke:r,strokeWidth:i,...a,children:e})}function qn(e){return(0,B.jsxs)(Kn,{...e,children:[(0,B.jsx)(`path`,{d:`M12 3l7 4v10l-7 4-7-4V7l7-4z`}),(0,B.jsx)(`path`,{d:`M12 8v8`}),(0,B.jsx)(`path`,{d:`M8.5 10 12 8l3.5 2`})]})}function Jn(e){return(0,B.jsxs)(Kn,{...e,children:[(0,B.jsx)(`circle`,{cx:`9`,cy:`8`,r:`4`}),(0,B.jsx)(`circle`,{cx:`17`,cy:`9`,r:`3`}),(0,B.jsx)(`path`,{d:`M3 21v-2a6 6 0 0 1 12 0v2`}),(0,B.jsx)(`path`,{d:`M14 17.5a5 5 0 0 1 7 4.5`})]})}function Yn(e){return(0,B.jsxs)(Kn,{...e,children:[(0,B.jsx)(`rect`,{x:`3`,y:`3`,width:`7`,height:`7`,rx:`2`}),(0,B.jsx)(`rect`,{x:`14`,y:`3`,width:`7`,height:`7`,rx:`2`}),(0,B.jsx)(`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`2`}),(0,B.jsx)(`rect`,{x:`14`,y:`14`,width:`7`,height:`7`,rx:`2`})]})}function Xn(e){return(0,B.jsxs)(Kn,{...e,children:[(0,B.jsx)(`path`,{d:`M12 3 5 6v5c0 4.5 3 8.4 7 10 4-1.6 7-5.5 7-10V6l-7-3Z`}),(0,B.jsx)(`path`,{d:`m9.5 12 1.7 1.7 3.3-3.7`})]})}function Zn(e){return(0,B.jsxs)(Kn,{...e,children:[(0,B.jsx)(`path`,{d:`M9 4 7 20`}),(0,B.jsx)(`path`,{d:`M17 4 15 20`}),(0,B.jsx)(`path`,{d:`M4 9h16`}),(0,B.jsx)(`path`,{d:`M3 15h16`})]})}function Qn(e){return(0,B.jsx)(Kn,{...e,children:(0,B.jsx)(`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`})})}function $n(e){return(0,B.jsx)(Kn,{strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`,...e,children:(0,B.jsx)(`path`,{d:`M4.5 12.5l5 5L19.5 6.5`})})}function er(e){return(0,B.jsx)(Kn,{strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,...e,children:(0,B.jsx)(`path`,{d:`m6 9 6 6 6-6`})})}function tr(e){return(0,B.jsx)(Kn,{strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,...e,children:(0,B.jsx)(`path`,{d:`m15 18-6-6 6-6`})})}function nr(e){return(0,B.jsx)(Kn,{strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,...e,children:(0,B.jsx)(`path`,{d:`m9 18 6-6-6-6`})})}function rr(e){return(0,B.jsx)(Kn,{fill:`currentColor`,stroke:`none`,...e,children:(0,B.jsx)(`circle`,{cx:`12`,cy:`12`,r:`5`})})}function ir(e){return(0,B.jsxs)(Kn,{strokeWidth:`1.8`,...e,children:[(0,B.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3.25`}),(0,B.jsx)(`path`,{d:`M12 2.75v2.5`}),(0,B.jsx)(`path`,{d:`M12 18.75v2.5`}),(0,B.jsx)(`path`,{d:`m4.93 4.93 1.77 1.77`}),(0,B.jsx)(`path`,{d:`m17.3 17.3 1.77 1.77`}),(0,B.jsx)(`path`,{d:`M2.75 12h2.5`}),(0,B.jsx)(`path`,{d:`M18.75 12h2.5`}),(0,B.jsx)(`path`,{d:`m4.93 19.07 1.77-1.77`}),(0,B.jsx)(`path`,{d:`m17.3 6.7 1.77-1.77`})]})}function ar(e){return(0,B.jsxs)(Kn,{...e,children:[(0,B.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3.25`}),(0,B.jsx)(`path`,{d:`M12 2.75v2.5`}),(0,B.jsx)(`path`,{d:`M12 18.75v2.5`}),(0,B.jsx)(`path`,{d:`m4.93 4.93 1.77 1.77`}),(0,B.jsx)(`path`,{d:`m17.3 17.3 1.77 1.77`}),(0,B.jsx)(`path`,{d:`M2.75 12h2.5`}),(0,B.jsx)(`path`,{d:`M18.75 12h2.5`}),(0,B.jsx)(`path`,{d:`m4.93 19.07 1.77-1.77`}),(0,B.jsx)(`path`,{d:`m17.3 6.7 1.77-1.77`})]})}function or(e){return(0,B.jsxs)(Kn,{...e,children:[(0,B.jsx)(`path`,{d:`M4 13.5a8 8 0 1 1 16 0`}),(0,B.jsx)(`path`,{d:`M12 13l4-4`}),(0,B.jsx)(`path`,{d:`M12 13v.01`})]})}function sr(e){return(0,B.jsxs)(Kn,{...e,children:[(0,B.jsx)(`path`,{d:`M4 19.5A2.5 2.5 0 0 1 6.5 17H20`}),(0,B.jsx)(`path`,{d:`M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2Z`})]})}function cr(e){return(0,B.jsxs)(Kn,{...e,children:[(0,B.jsx)(`path`,{d:`M4 6h16v12H4z`}),(0,B.jsx)(`path`,{d:`m4 7 8 6 8-6`})]})}function lr(e){return(0,B.jsxs)(Kn,{...e,children:[(0,B.jsx)(`path`,{d:`M15 2H6a2 2 0 0 0-2 2v12`}),(0,B.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h11z`}),(0,B.jsx)(`path`,{d:`M15 2v4h4`}),(0,B.jsx)(`path`,{d:`M10 12h5`}),(0,B.jsx)(`path`,{d:`M10 16h5`})]})}function ur(e){return(0,B.jsxs)(Kn,{strokeLinecap:`round`,strokeLinejoin:`round`,...e,children:[(0,B.jsx)(`path`,{d:`M9 3h6`}),(0,B.jsx)(`path`,{d:`M10 3v5.2l-4.4 8.2A3 3 0 0 0 8.2 21h7.6a3 3 0 0 0 2.6-4.6L14 8.2V3`}),(0,B.jsx)(`path`,{d:`M8 14h8`}),(0,B.jsx)(`path`,{d:`M9.5 17h5`})]})}function dr(e){return(0,B.jsxs)(Kn,{...e,children:[(0,B.jsx)(`path`,{d:`M12 3v18`}),(0,B.jsx)(`path`,{d:`M6 7h6`}),(0,B.jsx)(`path`,{d:`M6 17h6`}),(0,B.jsx)(`path`,{d:`M12 12h6`})]})}function fr(e){return(0,B.jsxs)(Kn,{strokeLinecap:`round`,strokeLinejoin:`round`,...e,children:[(0,B.jsx)(`path`,{d:`M8 4 5 11v8`}),(0,B.jsx)(`path`,{d:`m16 4 3 7v8`}),(0,B.jsx)(`path`,{d:`M8 4h8`}),(0,B.jsx)(`path`,{d:`M9 6.5 12 12l3-5.5`}),(0,B.jsx)(`path`,{d:`M7 13h10`}),(0,B.jsx)(`path`,{d:`M6 17h12`}),(0,B.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.6`})]})}function pr(e){return(0,B.jsxs)(Kn,{viewBox:`0 0 800 880`,fill:`currentColor`,stroke:`none`,strokeWidth:`0`,...e,children:[(0,B.jsx)(`path`,{d:`M507.729828,92.190903 C542.757812,110.456673 571.424255,135.694031 595.775391,166.119827 C619.579956,195.862732 638.856934,228.219177 652.442078,263.850647 C658.479370,279.685486 662.272888,296.087799 661.244873,313.145020 C660.222595,330.108704 654.180420,344.928284 640.343445,355.720642 C627.428833,365.793610 612.935364,367.856323 597.373230,363.754395 C593.516968,362.737946 589.397949,361.895905 586.067444,359.873871 C578.530823,355.298187 571.261902,355.886414 563.224670,358.424438 C554.176697,361.281677 544.599487,361.880035 535.139954,362.708588 C503.348907,365.493256 471.935760,363.967682 441.306305,354.183746 C434.485138,352.004822 427.884583,349.166840 421.995331,344.941254 C419.271454,342.986908 417.618744,340.549011 417.634216,336.997040 C417.692871,323.504272 417.707977,310.010254 417.567596,296.518463 C417.531677,293.064697 418.864990,291.103882 421.903137,289.475525 C436.048309,281.894226 442.159882,269.402985 438.696381,255.741867 C435.398956,242.735855 422.214264,232.561279 408.365753,232.335831 C393.614441,232.095627 380.572144,241.785385 376.695343,255.865250 C373.262543,268.332550 379.366638,282.005371 391.995056,288.564514 C396.547821,290.929199 398.147736,293.803955 398.053528,298.719421 C397.823578,310.714386 397.861786,322.719879 398.084869,334.715698 C398.191528,340.450714 395.656799,344.207092 390.831329,346.768372 C373.951355,355.727936 355.739044,360.035950 336.916931,362.253662 C313.460205,365.017487 290.059021,364.294250 266.684662,361.281708 C259.407349,360.343781 252.176224,359.038208 245.221390,356.759186 C241.066254,355.397644 237.558655,355.908691 233.732346,357.664001 C223.539429,362.339905 213.099457,366.176178 201.562149,365.444641 C180.953476,364.137970 167.133926,353.166199 159.023743,334.804932 C152.313522,319.613129 152.931183,303.777405 156.128448,287.774323 C159.920319,268.795105 167.141647,251.115952 176.011139,234.097870 C194.991669,197.679611 217.903442,164.023529 247.837326,135.612793 C284.602356,100.718506 327.367798,77.135025 377.670380,68.302414 C404.830780,63.533329 431.707947,65.339912 458.279724,72.516678 C475.401306,77.141045 491.769989,83.646782 507.729828,92.190903 M470.811340,314.083008 C470.004425,323.096130 474.067200,328.937256 482.844788,330.662079 C487.729767,331.621948 492.735657,332.280182 497.706848,332.433624 C520.719727,333.143982 535.795471,326.973236 546.370361,305.011780 C555.453369,286.148468 556.519897,265.994873 553.154419,245.902328 C546.768616,207.778671 527.574890,176.891663 496.885162,153.448715 C484.902252,144.295334 471.551483,137.419052 456.489288,134.546432 C453.536621,133.983307 450.726898,134.271683 449.076050,137.233429 C447.403961,140.233276 449.269409,142.167389 451.297638,144.118927 C479.605591,171.356659 498.163116,203.667862 501.754364,243.367645 C503.720459,265.101898 501.622894,285.523987 480.042206,298.356262 C474.805237,301.470245 471.806488,306.984283 470.811340,314.083008 M329.727112,189.313919 C338.691223,172.616455 349.535278,157.346970 363.640320,144.538696 C365.809113,142.569290 367.789154,140.284348 366.029358,137.166122 C364.403717,134.285568 361.513763,133.855591 358.580414,134.623001 C352.951447,136.095657 347.315094,137.514465 341.928986,139.849701 C316.388824,150.923141 297.420502,169.350677 283.061371,192.751572 C270.537994,213.160721 261.867645,234.963089 261.049652,259.297241 C260.507629,275.420837 261.752777,291.198181 269.221588,305.964874 C276.934692,321.214478 288.591034,330.449554 306.034454,332.208008 C314.443176,333.055634 322.708710,332.456726 330.912598,331.318970 C341.340057,329.872833 346.440338,321.370148 343.830902,311.162964 C342.019531,304.077393 337.202148,299.397003 331.425964,295.481537 C324.501526,290.787750 318.864258,285.062592 316.345215,276.830078 C313.737213,268.306732 312.861694,259.494812 313.126587,250.678513 C313.771637,229.209946 319.520844,209.020950 329.727112,189.313919z`}),(0,B.jsx)(`path`,{d:`M210.441925,503.432068 C247.314560,521.655334 270.317474,551.237915 283.528076,589.123047 C289.629333,606.620056 292.365021,624.554260 290.347961,643.101990 C290.016632,646.148682 289.197571,648.751587 286.167908,649.869995 C283.190613,650.969055 281.061493,649.108337 279.156433,647.167358 C267.260620,635.047302 256.051575,622.210938 242.719162,611.580750 C234.493866,605.022583 225.924133,598.988037 215.194504,597.085693 C200.833801,594.539795 188.392563,607.695862 191.780853,621.933044 C193.693115,629.968079 197.764282,636.645081 204.262115,641.860107 C216.682327,651.828186 218.891983,658.008240 213.988632,673.136963 C210.513336,683.859680 213.396210,692.388367 220.839249,699.991882 C229.883942,709.231567 237.973907,718.883972 240.500259,732.248047 C241.883179,739.563599 247.428726,745.056335 251.031647,751.407288 C251.852844,752.854797 252.775574,754.244385 253.631058,755.672913 C255.236221,758.353577 256.426758,761.245178 254.355469,764.057312 C252.421570,766.682800 249.463562,766.379333 246.560349,765.872375 C237.975800,764.373169 229.700104,761.742432 221.880203,758.039795 C164.170914,730.714600 122.057175,688.404114 99.029068,628.335876 C90.255867,605.451233 88.103424,581.417664 94.028709,557.622742 C101.470154,527.739014 117.483910,504.193390 149.043518,495.366455 C170.327591,489.413544 190.550797,494.424347 210.441925,503.432068z`}),(0,B.jsx)(`path`,{d:`M640.615479,493.459625 C667.304382,489.860901 695.193481,504.364319 709.507935,528.717224 C722.905701,551.510681 726.558411,575.965637 722.703125,601.847168 C717.553955,636.414795 701.183960,665.708923 679.347839,692.118103 C656.996399,719.150574 630.089172,740.753845 598.253967,755.859619 C588.767761,760.360779 578.968872,764.106262 568.520752,765.842896 C565.648743,766.320251 562.780396,766.750061 560.787231,763.973999 C558.808044,761.217529 559.927429,758.526123 561.426941,756.035645 C563.488403,752.611816 565.623230,749.224304 567.887085,745.931641 C572.165955,739.708069 575.530457,733.196716 577.233276,725.682800 C579.447754,715.910645 585.968201,708.461121 592.832886,701.679077 C601.942932,692.678711 605.207275,682.939880 600.619202,670.489197 C596.713379,659.890076 599.624023,651.059448 608.571899,643.888428 C615.665344,638.203613 621.245422,631.798767 622.887512,622.429504 C626.035400,604.467957 612.231873,592.284424 595.018127,598.238892 C583.116821,602.355835 573.453125,610.135315 564.456116,618.593323 C554.869324,627.605652 545.811768,637.180359 536.499146,646.485535 C534.383179,648.599854 532.246399,651.213562 528.806763,649.913391 C525.276855,648.579041 524.961304,645.211548 524.782654,641.974182 C522.545105,601.437134 535.967896,566.400452 562.338318,536.055786 C578.995972,516.887573 599.140625,502.900116 623.956787,496.301331 C629.261719,494.890717 634.625854,493.649292 640.615479,493.459625z`}),(0,B.jsx)(`path`,{d:`M468.599182,550.247314 C464.299561,543.652771 462.516388,536.847412 464.750977,529.526917 C465.784729,526.140381 464.889954,523.844788 462.544281,521.545593 C456.240387,515.366516 450.116364,509.002441 443.755402,502.883881 C440.911163,500.148041 439.673248,497.143341 439.684113,493.166016 C439.786652,455.688446 439.806519,418.210327 439.684692,380.732910 C439.670319,376.301147 440.880646,374.021332 445.609497,374.638824 C449.879700,375.196442 455.025452,372.535126 458.237366,375.244293 C461.583588,378.066681 459.546631,383.464661 459.669006,387.634949 C460.049500,400.598785 459.686951,413.584137 459.627960,426.561188 C459.531860,447.699371 459.461884,468.837708 459.336121,489.975708 C459.324097,491.996735 460.238068,493.427795 461.539825,494.801849 C466.234283,499.757050 470.913818,504.726837 475.556030,509.730927 C477.466278,511.790070 479.497192,513.295166 482.535095,512.453491 C495.185608,508.948456 507.935699,517.325562 511.492493,527.866821 C515.294739,539.135559 511.046326,551.084900 501.021515,556.859741 C489.936981,563.245056 478.048737,560.910522 468.599182,550.247314 M496.982025,536.538208 C496.770538,533.039612 495.752441,529.997742 492.320801,528.328796 C487.451416,525.960632 482.015778,528.163513 480.079102,533.287659 C478.099823,538.524475 480.947906,543.754456 486.579681,545.224976 C491.595184,546.534546 495.767731,543.361328 496.982025,536.538208z`}),(0,B.jsx)(`path`,{d:`M356.795441,377.276306 C358.570312,373.325073 361.812286,374.631226 364.406616,374.640961 C377.276550,374.689148 376.261200,372.900696 376.261505,386.300385 C376.262329,420.964844 376.142242,455.629761 376.314972,490.293304 C376.343658,496.051331 374.859314,500.493958 370.533966,504.428375 C364.623566,509.804596 359.262390,515.779663 353.488892,521.313538 C350.824829,523.867004 349.948547,526.308105 350.811951,530.130371 C353.632477,542.616760 347.402344,554.466003 336.312744,558.686890 C324.835907,563.055115 311.826599,558.901672 305.822906,548.503418 C301.051239,540.238831 300.863159,531.586243 306.099304,523.425598 C311.989105,514.246155 320.793640,510.488220 331.432312,512.172913 C335.489044,512.815369 338.095398,511.959229 340.602783,509.030670 C343.091858,506.123474 345.522675,503.011139 348.547791,500.749390 C355.593506,495.481659 356.946106,488.662384 356.846680,480.237152 C356.443573,446.078033 356.706177,411.911072 356.795441,377.276306 M319.366730,540.885925 C322.839935,547.054688 331.732574,546.091553 334.369110,541.196594 C336.488281,537.262146 336.474487,533.435852 333.266266,530.160461 C330.271698,527.103210 326.635437,526.473572 322.763397,528.566406 C318.566284,530.834839 317.510376,534.236206 319.366730,540.885925z`}),(0,B.jsx)(`path`,{d:`M397.757507,474.000000 C397.767456,443.015961 397.770599,412.531952 397.790222,382.047913 C397.794830,374.856567 398.814270,373.908691 405.898315,374.311066 C418.147675,375.006805 418.198730,375.006805 418.198700,387.454956 C418.198669,420.770599 418.266083,454.086914 418.074982,487.401611 C417.972778,505.217773 417.412598,523.031677 417.013458,540.845520 C416.907379,545.579224 415.979919,549.960632 410.475372,551.298706 C403.426117,553.012268 398.875366,549.348022 398.656097,541.937988 C397.990967,519.463440 397.611664,496.985260 397.757507,474.000000z`}),(0,B.jsx)(`path`,{d:`M360.751953,742.683472 C369.855377,737.399231 378.604431,732.231812 387.436768,727.210754 C392.079071,724.571716 393.099060,725.095703 393.129089,730.151917 C393.225952,746.481079 393.161377,762.811157 393.234253,779.140564 C393.249176,782.487732 391.916534,784.739136 389.028870,786.463684 C375.157532,794.748108 361.371002,803.174438 347.520050,811.493286 C342.855103,814.294983 341.771393,813.685059 341.755859,808.231934 C341.708893,791.735596 341.799683,775.238708 341.697449,758.742920 C341.676544,755.373047 342.740387,753.120422 345.787476,751.470825 C350.764130,748.776489 355.560028,745.748291 360.751953,742.683472z`}),(0,B.jsx)(`path`,{d:`M332.093964,801.947632 C331.760712,805.977661 332.959869,809.695801 331.200684,812.930603 C329.162689,813.653503 328.033783,812.451416 326.800446,811.701782 C312.860718,803.229004 298.958557,794.694031 284.984558,786.278320 C282.253204,784.633362 281.025085,782.475037 281.029907,779.344238 C281.055298,762.871399 280.980652,746.398376 281.035919,729.925659 C281.051880,725.171509 282.218719,724.492859 286.357208,726.917419 C300.289673,735.079773 314.118530,743.419373 328.069000,751.550537 C331.505981,753.553772 332.097595,756.473267 332.086121,759.991394 C332.041107,773.813232 332.083099,787.635437 332.093964,801.947632z`}),(0,B.jsx)(`path`,{d:`M510.988220,736.939758 C518.181946,732.855774 525.055542,728.951355 532.303040,724.834534 C534.077637,729.453430 533.824402,733.483521 533.840332,737.327759 C533.898804,751.442505 533.563293,765.558472 533.452698,779.674561 C533.431580,782.369751 532.768982,784.459229 530.290649,785.950684 C515.610229,794.786133 500.976410,803.699219 486.330658,812.592346 C485.462372,813.119568 484.611511,813.630737 483.538574,813.190186 C482.480682,812.616028 482.462708,811.586121 482.465576,810.590271 C482.514679,793.450134 482.679840,776.309204 482.555359,759.170349 C482.527588,755.348999 483.802521,753.029785 487.089142,751.158264 C495.036560,746.632812 502.819031,741.817627 510.988220,736.939758z`}),(0,B.jsx)(`path`,{d:`M462.988831,809.092651 C450.594604,801.522034 438.564270,794.058777 426.406189,786.809814 C423.033508,784.798950 421.524933,782.387817 421.570007,778.363953 C421.749023,762.372559 421.628937,746.377991 421.662231,730.384644 C421.665588,728.776306 421.216278,727.029419 422.706512,725.421326 C426.142639,725.317139 428.693085,727.741577 431.440002,729.350708 C443.796448,736.588623 455.969757,744.139587 468.339905,751.353455 C471.329254,753.096680 472.447418,755.132324 472.450867,758.535339 C472.467255,774.686218 472.713593,790.836792 472.852478,806.987732 C472.869385,808.955505 473.408234,811.332886 471.643188,812.614197 C469.608276,814.091431 468.016998,811.878967 466.311554,811.064453 C465.264130,810.564331 464.303833,809.881714 462.988831,809.092651z`}),(0,B.jsx)(`path`,{d:`M334.049652,472.364777 C329.851746,485.123169 319.751007,492.206665 307.625488,491.249023 C296.145966,490.342407 287.243134,481.918701 285.131378,469.965515 C283.584503,461.209595 288.805450,450.791870 297.853424,445.880554 C301.209595,444.058777 302.159424,441.887573 302.135468,438.374908 C302.010559,420.073547 302.020477,401.771027 302.043915,383.468994 C302.054291,375.385590 302.498322,375.000183 310.468628,374.890930 C322.029694,374.732452 322.159515,374.735016 321.932068,386.275970 C321.565033,404.901001 322.669952,423.539703 321.378479,442.153137 C321.253815,443.949432 321.665100,445.332520 323.276001,446.411011 C332.435516,452.543060 335.539978,461.295593 334.049652,472.364777 M301.286713,468.201569 C301.926910,471.882355 303.459656,474.829193 307.487854,475.707001 C312.580322,476.816681 317.530975,473.739471 318.528381,468.851685 C319.463409,464.269745 315.974487,459.568787 311.069092,458.801056 C305.804382,457.977020 302.192810,461.147827 301.286713,468.201569z`}),(0,B.jsx)(`path`,{d:`M402.333496,659.057800 C402.332642,675.136841 402.332642,690.726379 402.332642,705.881348 C399.778137,707.423340 398.410583,706.140991 397.041565,705.347717 C383.367462,697.424133 369.746063,689.409241 356.041962,681.538269 C352.951447,679.763184 351.633270,677.467224 351.671326,673.870972 C351.840515,657.896790 351.783417,641.920349 351.886963,625.945251 C351.916473,621.395630 352.969971,620.721191 356.851105,622.948120 C371.131256,631.141846 385.334198,639.470032 399.580200,647.723511 C404.234619,650.420044 401.673492,654.889648 402.333496,659.057800z`}),(0,B.jsx)(`path`,{d:`M429.495911,639.469910 C440.424438,633.205566 451.039642,627.129272 461.337219,621.234802 C463.939026,623.247498 463.296173,625.226074 463.301849,626.944702 C463.353546,642.591858 463.294312,658.239319 463.358154,673.886414 C463.370422,676.894836 462.928711,679.292053 459.952606,680.990112 C445.789825,689.070984 431.719910,697.314636 417.616730,705.499939 C416.476288,706.161865 415.356293,706.897827 413.973480,706.661255 C412.098877,705.236328 412.683075,703.254761 412.679016,701.529236 C412.642059,685.715454 412.765411,669.900696 412.627319,654.088074 C412.595612,650.458801 413.762421,648.235840 417.062408,646.611572 C421.233002,644.558838 425.153961,641.999084 429.495911,639.469910z`}),(0,B.jsx)(`path`,{d:`M376.128784,623.927246 C370.444305,620.567993 365.071198,617.399170 360.017731,614.418884 C360.361847,612.379517 361.224030,611.862549 362.099670,611.362976 C375.693115,603.607910 389.289429,595.857849 402.879791,588.097290 C405.850555,586.400940 408.783264,586.144592 411.868347,587.905029 C425.316833,595.579468 438.797577,603.197327 452.254578,610.856812 C453.384918,611.500183 454.665497,612.089172 454.776520,613.716125 C454.316376,615.348572 452.802216,615.852478 451.535400,616.583313 C438.554993,624.071289 425.504456,631.440308 412.610260,639.073486 C408.987427,641.218201 405.997528,641.120789 402.448486,639.004456 C393.870270,633.889221 385.120667,629.061340 376.128784,623.927246z`}),(0,B.jsx)(`path`,{d:`M242.299408,438.279297 C252.006012,431.762848 256.521606,423.593109 255.230011,411.674988 C254.124954,401.477997 255.108200,391.064331 254.958374,380.749542 C254.894836,376.375488 256.324188,374.182953 261.038269,374.608673 C264.174500,374.891907 267.360840,374.764954 270.517426,374.638702 C273.965332,374.500732 275.282196,376.118652 275.269684,379.441071 C275.208832,395.582062 275.260773,411.723480 275.189850,427.864380 C275.174652,431.323761 273.830261,434.303436 271.218719,436.704590 C255.913254,450.777130 240.649780,464.895386 225.328384,478.950531 C222.506638,481.539032 219.517548,483.925323 217.617462,487.362701 C217.149307,488.209595 216.453644,489.032227 215.664200,489.580261 C213.626511,490.994812 202.953079,488.164825 200.974960,485.431274 C198.439163,481.927155 199.473038,478.288910 202.061020,475.385132 C205.150391,471.918823 208.638962,468.793976 212.077835,465.656250 C222.031769,456.574066 232.047455,447.559570 242.299408,438.279297z`}),(0,B.jsx)(`path`,{d:`M570.742676,461.278748 C561.963379,453.334656 553.505554,445.564453 544.928284,437.928406 C541.193726,434.603699 539.515381,430.755615 539.582947,425.652100 C539.783386,410.507263 539.721375,395.355774 539.501526,380.210632 C539.443237,376.195526 540.513245,374.481873 544.786621,374.568481 C561.698853,374.911438 559.023621,372.368805 559.200256,388.668945 C559.321045,399.820587 559.307190,410.975037 559.205200,422.126862 C559.178650,425.035919 560.154236,427.028046 562.351257,428.991577 C578.359253,443.298340 594.240356,457.747131 610.160095,472.152710 C611.891785,473.719696 613.585938,475.318970 614.633911,477.464844 C616.886536,482.077789 615.586426,485.446991 610.811646,487.347382 C608.648010,488.208557 606.497803,489.106934 604.313538,489.912445 C602.230042,490.680786 600.327332,490.332275 598.937378,488.514526 C590.982117,478.110687 580.327515,470.503998 570.742676,461.278748z`}),(0,B.jsx)(`path`,{d:`M510.884399,726.950562 C501.595795,732.536011 492.540253,737.804871 483.671234,743.370911 C479.665771,745.884583 476.244019,745.942749 472.145966,743.440186 C459.377014,735.642700 446.422150,728.149597 433.537201,720.542114 C432.261719,719.789001 430.851013,719.196472 430.273254,717.820374 C430.332611,715.982300 431.756744,715.550171 432.850616,714.911316 C446.346527,707.030090 459.875153,699.204834 473.359283,691.303589 C476.171722,689.655579 478.815643,689.226013 481.782227,690.968445 C495.401306,698.967834 509.068542,706.885254 522.708679,714.848816 C523.705750,715.430969 524.729614,716.054199 525.050781,718.083313 C521.179993,721.707764 515.692810,723.508545 510.884399,726.950562z`}),(0,B.jsx)(`path`,{d:`M324.203491,696.145752 C333.136627,688.303589 341.200531,689.493774 350.293427,696.006470 C359.593140,702.667236 369.971863,707.818481 379.852081,713.674683 C381.518341,714.662292 383.572815,715.268738 384.283936,717.379883 C383.937531,719.392090 382.201355,719.964783 380.829590,720.776306 C368.081451,728.317749 355.281097,735.770935 342.541473,743.326660 C339.322388,745.235779 336.181396,746.163269 332.705566,744.086853 C319.129486,735.976318 305.539307,727.889282 291.976074,719.757385 C291.164337,719.270691 290.542145,718.467957 288.922760,716.973267 C300.905212,709.897705 312.395447,703.112732 324.203491,696.145752z`}),(0,B.jsx)(`path`,{d:`M512.233826,378.381226 C512.297852,398.654144 512.391785,418.463837 512.277649,438.272278 C512.256714,441.891632 513.409912,443.966949 516.724182,445.658112 C526.928101,450.864990 531.905396,460.905609 529.860474,471.209717 C527.713806,482.026276 518.785034,490.092407 507.716095,491.214630 C497.467255,492.253693 487.039459,486.051971 482.787994,476.389221 C478.463409,466.560303 480.865051,455.472931 489.336761,448.361389 C492.073517,446.063995 492.974487,443.789825 492.934479,440.295929 C492.705811,420.322388 492.810242,400.345245 492.641724,380.370697 C492.607269,376.283234 494.140503,374.551086 498.222900,374.794891 C501.375824,374.983185 504.546661,374.856812 507.708984,374.906128 C509.835632,374.939270 511.721954,375.390259 512.233826,378.381226 M508.578430,475.418884 C512.508789,473.681152 514.549866,470.555817 514.241516,466.373993 C513.978394,462.805420 511.836823,460.386047 508.280029,459.166016 C504.668549,457.927277 501.737152,458.888092 499.220062,461.432556 C496.393768,464.289673 496.455627,467.846588 497.841187,471.180756 C499.667908,475.576477 503.488800,476.386444 508.578430,475.418884z`})]})}function mr(e){return(0,B.jsxs)(Kn,{...e,children:[(0,B.jsx)(`rect`,{x:`4`,y:`5`,width:`16`,height:`14`,rx:`2.5`}),(0,B.jsx)(`path`,{d:`M8 9h8`}),(0,B.jsx)(`path`,{d:`M8 13h5`}),(0,B.jsx)(`path`,{d:`M8 17h7`})]})}function hr(e){return(0,B.jsxs)(Kn,{...e,children:[(0,B.jsx)(`path`,{d:`M9 18h6`}),(0,B.jsx)(`path`,{d:`M10 22h4`}),(0,B.jsx)(`path`,{d:`M12 2a7 7 0 0 0-4 12.74V16a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2v-1.26A7 7 0 0 0 12 2z`})]})}function gr(e){return(0,B.jsxs)(Kn,{strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,...e,children:[(0,B.jsx)(`rect`,{width:`16`,height:`16`,x:`4`,y:`4`,rx:`2`}),(0,B.jsx)(`rect`,{width:`6`,height:`6`,x:`9`,y:`9`}),(0,B.jsx)(`path`,{d:`M15 2v2`}),(0,B.jsx)(`path`,{d:`M15 20v2`}),(0,B.jsx)(`path`,{d:`M2 15h2`}),(0,B.jsx)(`path`,{d:`M2 9h2`}),(0,B.jsx)(`path`,{d:`M20 15h2`}),(0,B.jsx)(`path`,{d:`M20 9h2`}),(0,B.jsx)(`path`,{d:`M9 2v2`}),(0,B.jsx)(`path`,{d:`M9 20v2`})]})}function _r(e){return(0,B.jsxs)(Kn,{...e,children:[(0,B.jsx)(`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`}),(0,B.jsx)(`polyline`,{points:`16 17 21 12 16 7`}),(0,B.jsx)(`line`,{x1:`21`,y1:`12`,x2:`9`,y2:`12`})]})}function vr(e){return(0,B.jsxs)(Kn,{...e,children:[(0,B.jsx)(`path`,{d:`M6 3h9l3 3v15H6z`}),(0,B.jsx)(`path`,{d:`M14 3v4h4`}),(0,B.jsx)(`path`,{d:`M9 11h6`}),(0,B.jsx)(`path`,{d:`M9 15h6`}),(0,B.jsx)(`path`,{d:`M9 19h3`})]})}function yr(e){return(0,B.jsxs)(Kn,{strokeWidth:`1.8`,...e,children:[(0,B.jsx)(`path`,{d:`M4 7h16`}),(0,B.jsx)(`path`,{d:`M4 12h16`}),(0,B.jsx)(`path`,{d:`M4 17h16`})]})}function br(e){return(0,B.jsx)(Kn,{strokeWidth:`2.4`,strokeLinecap:`round`,...e,children:(0,B.jsx)(`path`,{d:`M5 12h14`})})}function xr(e){return(0,B.jsxs)(Kn,{...e,children:[(0,B.jsx)(`ellipse`,{cx:`12`,cy:`6`,rx:`6.5`,ry:`2.5`}),(0,B.jsx)(`path`,{d:`M5.5 6v6c0 1.4 2.9 2.5 6.5 2.5s6.5-1.1 6.5-2.5V6`}),(0,B.jsx)(`path`,{d:`M5.5 12v6c0 1.4 2.9 2.5 6.5 2.5s6.5-1.1 6.5-2.5v-6`})]})}function Sr(e){return(0,B.jsxs)(Kn,{strokeWidth:`1.8`,...e,children:[(0,B.jsx)(`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`}),(0,B.jsx)(`path`,{d:`M9 3v18`})]})}function Cr(e){return(0,B.jsxs)(Kn,{...e,children:[(0,B.jsx)(`path`,{d:`M9 3v6`}),(0,B.jsx)(`path`,{d:`M15 15v6`}),(0,B.jsx)(`path`,{d:`M15 3v2`}),(0,B.jsx)(`path`,{d:`M9 19v2`}),(0,B.jsx)(`path`,{d:`M8 8h2a3 3 0 1 1 0 6H8a3 3 0 1 1 0-6Z`}),(0,B.jsx)(`path`,{d:`M14 10h2a3 3 0 1 1 0 6h-2a3 3 0 1 1 0-6Z`})]})}function wr(e){return(0,B.jsxs)(Kn,{...e,children:[(0,B.jsx)(`path`,{d:`M12 3 5 6v5c0 4.5 3 8.4 7 10 4-1.6 7-5.5 7-10V6l-7-3Z`}),(0,B.jsx)(`path`,{d:`M9 10h6`}),(0,B.jsx)(`path`,{d:`M9 13h4`})]})}function Tr(e){return(0,B.jsxs)(Kn,{...e,children:[(0,B.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8`}),(0,B.jsx)(`path`,{d:`M12 7v5l3 2`})]})}function Er(e){return(0,B.jsxs)(Kn,{strokeLinecap:`round`,strokeLinejoin:`round`,...e,children:[(0,B.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,B.jsx)(`path`,{d:`m20 20-3.5-3.5`})]})}function Dr(e){return(0,B.jsxs)(Kn,{...e,children:[(0,B.jsx)(`rect`,{x:`4`,y:`11`,width:`16`,height:`9`,rx:`2`}),(0,B.jsx)(`path`,{d:`M8 11V7a4 4 0 0 1 8 0v4`}),(0,B.jsx)(`circle`,{cx:`12`,cy:`15.5`,r:`1.2`,fill:`currentColor`,stroke:`none`})]})}function Or(e){return(0,B.jsxs)(Kn,{strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,...e,children:[(0,B.jsx)(`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`}),(0,B.jsx)(`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`}),(0,B.jsx)(`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`}),(0,B.jsx)(`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`})]})}function kr(e){return(0,B.jsxs)(Kn,{...e,children:[(0,B.jsx)(`rect`,{x:`4`,y:`5`,width:`16`,height:`12`,rx:`2.5`}),(0,B.jsx)(`path`,{d:`M8 19h8`}),(0,B.jsx)(`path`,{d:`M9 9h6`}),(0,B.jsx)(`path`,{d:`M9 13h4`})]})}function Ar(e){return(0,B.jsxs)(Kn,{...e,children:[(0,B.jsx)(`path`,{d:`M4 19V5`}),(0,B.jsx)(`path`,{d:`M4 19h16`}),(0,B.jsx)(`rect`,{x:`7`,y:`12`,width:`3`,height:`7`}),(0,B.jsx)(`rect`,{x:`12`,y:`8`,width:`3`,height:`11`}),(0,B.jsx)(`rect`,{x:`17`,y:`14`,width:`3`,height:`5`})]})}function jr(e){return(0,B.jsxs)(Kn,{...e,children:[(0,B.jsx)(`path`,{d:`m5 7 4 5-4 5`}),(0,B.jsx)(`path`,{d:`M13 17h6`})]})}function Mr({filled:e=!1,...t}){return(0,B.jsxs)(Kn,{fill:e?`currentColor`:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,...t,children:[(0,B.jsx)(`path`,{d:`M17 14V2`}),(0,B.jsx)(`path`,{d:`M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z`})]})}function Nr({filled:e=!1,...t}){return(0,B.jsxs)(Kn,{fill:e?`currentColor`:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,...t,children:[(0,B.jsx)(`path`,{d:`M7 10v12`}),(0,B.jsx)(`path`,{d:`M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z`})]})}function Pr(e){return(0,B.jsxs)(Kn,{...e,children:[(0,B.jsx)(`path`,{d:`m14.7 6.3 3 3`}),(0,B.jsx)(`path`,{d:`m11.5 9.5 6.2 6.2`}),(0,B.jsx)(`path`,{d:`m3 21 6.2-6.2`}),(0,B.jsx)(`path`,{d:`M7.8 16.2 5 19l-2-2 2.8-2.8`}),(0,B.jsx)(`path`,{d:`M14 4a4 4 0 0 0-4 5l-6 6 3 3 6-6a4 4 0 0 0 5-4Z`})]})}function Fr(e){return(0,B.jsxs)(Kn,{strokeLinecap:`round`,strokeLinejoin:`round`,...e,children:[(0,B.jsx)(`path`,{d:`M3 6h18`}),(0,B.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,B.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,B.jsx)(`path`,{d:`M10 11v5`}),(0,B.jsx)(`path`,{d:`M14 11v5`})]})}function Ir(){let e=Gn(),[t,n]=(0,R.useState)(e.token);return(0,B.jsx)(`div`,{className:`login-shell`,children:(0,B.jsxs)(`div`,{className:`login-card`,children:[(0,B.jsx)(`p`,{className:`eyebrow`,children:`HybridClaw Admin`}),(0,B.jsx)(`h1`,{children:`Enter API token.`}),(0,B.jsxs)(`p`,{className:`supporting-text`,children:[`This instance has `,(0,B.jsx)(`code`,{children:`WEB_API_TOKEN`}),` enabled. Enter it once and the console will keep it in local storage, the same way`,(0,B.jsx)(`code`,{children:` /chat`}),` already does.`]}),(0,B.jsxs)(`form`,{className:`stack-form`,onSubmit:async n=>{n.preventDefault(),await e.login(t)},children:[(0,B.jsxs)(`label`,{className:`field`,children:[(0,B.jsx)(`span`,{children:`Token`}),(0,B.jsx)(`input`,{autoComplete:`off`,spellCheck:!1,type:`password`,value:t,onChange:e=>n(e.target.value),placeholder:`Paste WEB_API_TOKEN`})]}),e.error?(0,B.jsx)(`p`,{className:`error-banner`,children:e.error}):null,(0,B.jsx)(`button`,{className:`primary-button`,type:`submit`,children:e.status===`checking`?`Checking...`:`Continue`})]})]})})}function Lr(e){return e===`/chat`||e.startsWith(`/chat/`)?`HybridClaw Chat`:e===`/agents`||e.startsWith(`/agents/`)?`HybridClaw Agents`:e===`/admin`||e.startsWith(`/admin/`)?`HybridClaw Admin`:`HybridClaw`}var Rr=[{label:`Overview`,items:[{to:`/admin`,label:`Dashboard`,icon:or},{to:`/admin/statistics`,label:`Statistics`,icon:Ar},{to:`/admin/approvals`,label:`Approvals`,icon:wr},{to:`/admin/audit`,label:`Audit`,icon:Xn},{to:`/admin/jobs`,label:`Jobs`,icon:mr},{to:`/admin/harness-evolution`,label:`Harness Evolution`,icon:fr},{to:`/admin/distill`,label:`Distill`,icon:ur}]},{label:`A2A`,items:[{to:`/admin/a2a-inbox`,label:`Inbox`,icon:Qn},{to:`/admin/a2a-trust`,label:`Trust`,icon:wr}]},{label:`Runtime`,items:[{to:`/admin/terminal`,label:`Terminal`,icon:jr},{to:`/admin/gateway`,label:`Gateway`,icon:dr},{to:`/admin/logs`,label:`Logs`,icon:vr},{to:`/admin/fleet-topology`,label:`Fleet`,icon:Or},{to:`/admin/sessions`,label:`Sessions`,icon:kr},{to:`/admin/channels`,label:`Channels`,icon:Zn},{to:`/admin/email`,label:`Email`,icon:cr,requiresEmail:!0},{to:`/admin/models`,label:`Models`,icon:xr},{to:`/admin/scheduler`,label:`Scheduler`,icon:Tr},{to:`/admin/connectors`,label:`Connectors`,icon:Cr},{to:`/admin/mcp`,label:`MCP`,icon:ir}]},{label:`Configuration`,items:[{to:`/admin/agents`,label:`Agent Files`,icon:lr},{to:`/admin/agent-scoreboard`,label:`Agents`,icon:Jn},{to:`/admin/skills`,label:`Skills`,icon:hr},{to:`/admin/plugins`,label:`Plugins`,icon:Cr},{to:`/admin/output-guard`,label:`Output Guard`,icon:wr},{to:`/admin/tools`,label:`Tools`,icon:Pr},{to:`/admin/secrets`,label:`Secrets`,icon:Dr},{to:`/admin/config`,label:`Config`,icon:ar}]}],zr=Rr.flatMap(e=>e.items.map(({to:e,label:t})=>({to:e,label:t}))).concat([{to:`/agents`,label:`Agents`}]);function Br(e){return e.startsWith(`/admin/skills/`)?{to:`/admin/skills`,label:`Skill`}:zr.find(t=>t.to===e)??zr[0]}function V(...e){return e.filter(Boolean).join(` `)}var Vr=k();function Hr(e,t,n){(0,R.useEffect)(()=>{if(!t)return;let r=e.current;if(!r||typeof r.getAnimations!=`function`){n();return}let i=r.getAnimations();if(i.length===0){n();return}let a=!1;return Promise.all(i.map(e=>e.finished)).then(()=>{a||n()},()=>{a||n()}),()=>{a=!0}},[t,e,n])}function Ur(e,t){let n=(0,R.useRef)(e);(0,R.useEffect)(()=>{n.current=e},[e]),(0,R.useEffect)(()=>{if(!t)return;function e(e){if(e.key!==`Escape`)return;let t=e.target;t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`||t.isContentEditable||(e.stopPropagation(),n.current())}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t])}function Wr({onFocus:e}){return(0,B.jsx)(`span`,{tabIndex:0,"aria-hidden":`true`,style:{position:`fixed`,outline:`none`,opacity:0,pointerEvents:`none`},onFocus:e})}var Gr=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`;function Kr(e){return Array.from(e.querySelectorAll(Gr))}function qr(e,t,n){(0,R.useEffect)(()=>{if(!t)return;let r=e.current;if(!r)return;let i=document.activeElement,a=requestAnimationFrame(()=>{(n?.current??Kr(r)[0])?.focus({preventScroll:!0})});function o(e){if(e.key!==`Tab`||!r)return;let t=Kr(r);if(!t.length){e.preventDefault();return}let n=t[0],i=t[t.length-1],a=document.activeElement;e.shiftKey?(a===n||!r.contains(a))&&(e.preventDefault(),i.focus({preventScroll:!0})):(a===i||!r.contains(a))&&(e.preventDefault(),n.focus({preventScroll:!0}))}return document.addEventListener(`keydown`,o),()=>{cancelAnimationFrame(a),document.removeEventListener(`keydown`,o),i?.focus({preventScroll:!0})}},[t,e,n])}var Jr=new WeakMap;function Yr(e){let t=(Jr.get(e)??0)+1;Jr.set(e,t),t===1&&(e.inert=!0)}function Xr(e){let t=(Jr.get(e)??1)-1;t<=0?(Jr.delete(e),e.inert=!1):Jr.set(e,t)}function Zr(e,t){(0,R.useEffect)(()=>{if(!t)return;let n=e.current;if(!n)return;let r=[];for(let e of document.body.children)e===n||e.contains(n)||(Yr(e),r.push(e));return()=>{for(let e of r)Xr(e)}},[t,e])}var Qr=0;function $r(e){(0,R.useEffect)(()=>{if(e){if(Qr++===0){let e=window.innerWidth-document.documentElement.clientWidth;document.body.style.overflow=`hidden`,e>0&&(document.body.style.paddingRight=`${e}px`)}return()=>{--Qr===0&&(document.body.style.overflow=``,document.body.style.paddingRight=``)}}},[e])}var ei={backdrop:`_backdrop_18ebo_1`,dialogFadeIn:`_dialogFadeIn_18ebo_1`,viewport:`_viewport_18ebo_9`,content:`_content_18ebo_19`,dialogSlideIn:`_dialogSlideIn_18ebo_1`,sm:`_sm_18ebo_36`,lg:`_lg_18ebo_40`,header:`_header_18ebo_44`,title:`_title_18ebo_49`,description:`_description_18ebo_57`,footer:`_footer_18ebo_63`,exiting:`_exiting_18ebo_82`,dialogFadeOut:`_dialogFadeOut_18ebo_1`,dialogSlideOut:`_dialogSlideOut_18ebo_1`,overlay:`_overlay_18ebo_118`,overlayVisible:`_overlayVisible_18ebo_131`,drawer:`_drawer_18ebo_114`,left:`_left_18ebo_151`,right:`_right_18ebo_162`,top:`_top_18ebo_173`,bottom:`_bottom_18ebo_184`,drawerOpen:`_drawerOpen_18ebo_114`,srOnly:`_srOnly_18ebo_201 _srOnly_jfnet_1`},ti=(0,R.createContext)(null);function ni(){let e=(0,R.useContext)(ti);if(!e)throw Error(`Dialog components must be used within <Dialog>.`);return e}function ri(e){let t=(0,R.useId)(),n=(0,R.useId)();return(0,B.jsx)(ti.Provider,{value:{open:e.open,onOpenChange:e.onOpenChange,titleId:t,descriptionId:n,isDrawer:e.isDrawer??!1},children:e.children})}function ii({children:e,className:t,size:n,initialFocus:r,preventCloseOnOutsideClick:i,role:a,side:o=`right`,...s}){let c=ni(),l=(0,R.useRef)(null),u=(0,R.useRef)(null),d=(0,R.useRef)(null),{open:f,onOpenChange:p,titleId:m,descriptionId:h,isDrawer:g}=c,[_,v]=(0,R.useState)(!1),y=(0,R.useRef)(f);(0,R.useEffect)(()=>{!g&&y.current&&!f&&v(!0),y.current=f},[f,g]);let b=(0,R.useCallback)(()=>v(!1),[]);Hr(u,!g&&_,b);let x=g?d:u;$r(f),qr(x,f,r),Ur(()=>p(!1),f),Zr(l,f);let S=(0,R.useCallback)(()=>{Array.from(u.current?.querySelectorAll(`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`)??[])[0]?.focus({preventScroll:!0})},[]),C=(0,R.useCallback)(()=>{let e=Array.from(u.current?.querySelectorAll(`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`)??[]);e[e.length-1]?.focus({preventScroll:!0})},[]);if((0,R.useEffect)(()=>{},[f,m]),typeof document>`u`)return null;if(g)return(0,Vr.createPortal)((0,B.jsxs)(`div`,{ref:l,children:[(0,B.jsx)(`div`,{"data-sheet":`overlay`,className:V(ei.overlay,f&&ei.overlayVisible),"aria-hidden":`true`,onClick:()=>!i&&p(!1)}),(0,B.jsx)(`section`,{...s,ref:d,role:a??`dialog`,"aria-modal":f?`true`:void 0,"aria-hidden":f?void 0:!0,inert:!f,"aria-labelledby":m,"aria-describedby":h,"data-sheet":`content`,"data-side":o,"data-state":f?`open`:`closed`,className:V(ei.drawer,ei[o],f&&ei.drawerOpen,t),children:e})]}),document.body);if(!f&&!_)return null;let w=n===`sm`?ei.sm:n===`lg`?ei.lg:void 0;return(0,Vr.createPortal)((0,B.jsxs)(`div`,{ref:l,children:[(0,B.jsx)(`div`,{className:V(ei.backdrop,_&&ei.exiting),"aria-hidden":`true`,onClick:()=>!_&&!i&&p(!1)}),(0,B.jsxs)(`div`,{className:ei.viewport,children:[(0,B.jsx)(Wr,{onFocus:C}),(0,B.jsx)(`div`,{...s,ref:u,role:a??`dialog`,"aria-modal":`true`,"aria-labelledby":m,"aria-describedby":h,"data-state":_?`closed`:`open`,className:V(ei.content,w,_&&ei.exiting,t),children:e}),(0,B.jsx)(Wr,{onFocus:S})]})]}),document.body)}function ai(e){return(0,B.jsx)(`div`,{className:V(e.visuallyHidden?ei.srOnly:ei.header,e.className),children:e.children})}function oi(e){let{titleId:t}=ni();return(0,B.jsx)(`h3`,{id:t,className:V(ei.title,e.className),children:e.children})}function si(e){let{descriptionId:t}=ni();return(0,B.jsx)(`p`,{id:t,className:V(ei.description,e.className),children:e.children})}function ci(e){return(0,B.jsx)(`div`,{className:V(ei.footer,e.className),children:e.children})}function li(e){let{onOpenChange:t}=ni(),{children:n,className:r,onClick:i,...a}=e;return(0,B.jsx)(`button`,{...a,type:`button`,className:r,onClick:e=>{i?.(e),t(!1)},children:n})}var ui=new Set,di=te(),fi=ne(),pi=null,mi=!1,hi=gi();function gi(){return{theme:di,resolved:re(di,fi)}}function _i(){hi=gi(),ie(hi.resolved);for(let e of ui)e()}function vi(e){fi=e.matches?`dark`:`light`,_i()}function yi(e){e.key===`hybridclaw-theme`&&(di=te(),_i())}function bi(){mi||typeof window>`u`||(mi=!0,di=te(),fi=ne(),hi=gi(),ie(hi.resolved),pi=window.matchMedia(`(prefers-color-scheme: dark)`),pi.addEventListener(`change`,vi),window.addEventListener(`storage`,yi))}function xi(){return hi}function Si(e){di=e,typeof window<`u`&&window.localStorage.setItem(L,e),_i()}function Ci(e){return bi(),ui.add(e),()=>ui.delete(e)}function wi(){return(0,R.useSyncExternalStore)(Ci,xi,xi)}var Ti={content:`_content_y9cp1_1`},Ei=(0,R.createContext)(null);function Di(e){let t=(0,R.useContext)(Ei);if(!t)throw Error(`${e} must be used within <Popover>`);return t}function Oi({children:e,open:t,defaultOpen:n=!1,onOpenChange:r}){let[i,a]=(0,R.useState)(n),[o,s]=(0,R.useState)(null),[c,l]=(0,R.useState)(null),u=(0,R.useId)(),d=t!==void 0,f=d?t:i,p=(0,R.useCallback)(e=>{d||a(e),r?.(e)},[d,r]),m=(0,R.useCallback)(()=>p(!f),[f,p]),h=(0,R.useMemo)(()=>({open:f,setOpen:p,toggle:m,triggerEl:o,setTriggerEl:s,contentEl:c,setContentEl:l,contentId:u}),[f,p,m,o,c,u]);return(0,B.jsx)(Ei.Provider,{value:h,children:e})}function ki({children:e,className:t,...n}){return(0,B.jsx)(`div`,{ref:Di(`PopoverAnchor`).setTriggerEl,className:t,...n,children:e})}function Ai({align:e=`start`,side:t=`bottom`,sideOffset:n=4,focusOnOpen:r=`first-button`,closeOnEscape:i=!0,closeOnOutsideClick:a=!0,className:o,style:s,children:c,ref:l,...u}){let d=Di(`PopoverContent`),f=(0,R.useRef)(null),[p,m]=(0,R.useState)(null),{setContentEl:h}=d,g=(0,R.useCallback)(e=>{f.current=e,h(e),typeof l==`function`?l(e):l&&(l.current=e)},[h,l]);if((0,R.useLayoutEffect)(()=>{let r=f.current;if(!d.open||!d.triggerEl||!r)return;let i=0,a=()=>{if(!d.triggerEl||!r)return;let i=d.triggerEl.getBoundingClientRect(),a=r.getBoundingClientRect(),o=window.innerWidth,s=window.innerHeight,c=i.left;e===`end`?c=i.right-a.width:e===`center`&&(c=i.left+(i.width-a.width)/2);let l=t===`top`?i.top-a.height-n:i.bottom+n;if(c+a.width>o-8&&(c=o-a.width-8),c<8&&(c=8),t===`bottom`&&l+a.height>s-8){let e=i.top-a.height-n;e>=8&&(l=e)}t===`top`&&l<8&&(l=8),m({x:c,y:l,minWidth:i.width})},o=()=>{i||=window.requestAnimationFrame(()=>{i=0,a()})};a();let s=typeof ResizeObserver>`u`?null:new ResizeObserver(o);return s?.observe(d.triggerEl),s?.observe(r),window.addEventListener(`resize`,a),window.addEventListener(`scroll`,a,!0),()=>{i&&window.cancelAnimationFrame(i),s?.disconnect(),window.removeEventListener(`resize`,a),window.removeEventListener(`scroll`,a,!0)}},[d.open,d.triggerEl,e,t,n]),(0,R.useEffect)(()=>{let e=f.current;if(!d.open||!e||r===`none`)return;let t=window.setTimeout(()=>{r===`first-button`?e.querySelector(`button:not(:disabled)`)?.focus():r(e)},0);return()=>window.clearTimeout(t)},[d.open,r]),(0,R.useEffect)(()=>{if(!d.open||!a)return;let e=f.current,t=d.triggerEl;if(!e||!t)return;let n=n=>{let r=n.target;t.contains(r)||e.contains(r)||d.setOpen(!1)};return document.addEventListener(`mousedown`,n),()=>document.removeEventListener(`mousedown`,n)},[d.open,d.triggerEl,d.setOpen,a]),(0,R.useEffect)(()=>{if(!d.open||!i)return;let e=d.triggerEl,t=t=>{t.key===`Escape`&&(d.setOpen(!1),e&&`focus`in e&&e.focus())};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[d.open,d.triggerEl,d.setOpen,i]),!d.open||typeof document>`u`)return null;let _={left:p?.x??0,top:p?.y??0,minWidth:p?.minWidth,visibility:p?`visible`:`hidden`};return(0,Vr.createPortal)((0,B.jsx)(`div`,{ref:g,id:d.contentId,"data-state":`open`,className:V(Ti.content,o),style:{..._,...s},...u,children:c}),document.body)}var ji={trigger:`_trigger_sn70v_1`,content:`_content_sn70v_17`,item:`_item_sn70v_29`};function Mi({children:e,open:t,defaultOpen:n,onOpenChange:r}){return(0,B.jsx)(Oi,{open:t,defaultOpen:n,onOpenChange:r,children:e})}function Ni({children:e,className:t=``,"aria-label":n,title:r}){let i=Di(`DropdownTrigger`);return(0,B.jsx)(`button`,{ref:i.setTriggerEl,type:`button`,className:V(ji.trigger,t),"aria-haspopup":`menu`,"aria-expanded":i.open,"aria-controls":i.contentId,"aria-label":n,title:r,"data-state":i.open?`open`:`closed`,onClick:i.toggle,onKeyDown:e=>{(e.key===`Enter`||e.key===` `||e.key===`ArrowDown`)&&(e.preventDefault(),i.setOpen(!0))},children:e})}function Pi({children:e,className:t=``,align:n=`start`,sideOffset:r=4}){return(0,B.jsx)(Ai,{role:`menu`,align:n,sideOffset:r,focusOnOpen:`first-button`,className:V(ji.content,t),children:e})}function Fi({children:e,className:t=``,active:n=!1,onSelect:r}){let i=Di(`DropdownItem`);return(0,B.jsx)(`button`,{type:`button`,role:`menuitem`,className:V(ji.item,t),"data-active":n?`true`:`false`,onClick:()=>{r?.(),i.setOpen(!1)},children:e})}var Ii=()=>(0,B.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,"aria-hidden":`true`,children:[(0,B.jsx)(`circle`,{cx:`12`,cy:`12`,r:`5`}),(0,B.jsx)(`path`,{d:`M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42`})]}),Li=()=>(0,B.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,"aria-hidden":`true`,children:(0,B.jsx)(`path`,{d:`M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z`})}),Ri=()=>(0,B.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,"aria-hidden":`true`,children:[(0,B.jsx)(`rect`,{x:`2`,y:`3`,width:`20`,height:`14`,rx:`2`,ry:`2`}),(0,B.jsx)(`path`,{d:`M8 21h8M12 17v4`})]});function zi({theme:e}){return e===`light`?(0,B.jsx)(Ii,{}):e===`dark`?(0,B.jsx)(Li,{}):(0,B.jsx)(Ri,{})}var Bi=[{value:`light`,label:`Light`},{value:`dark`,label:`Dark`},{value:`system`,label:`System`}];function Vi(e){let{theme:t,resolved:n}=wi(),r=Bi.find(e=>e.value===t)?.label??t;return(0,B.jsxs)(Mi,{children:[(0,B.jsxs)(Ni,{className:`theme-toggle-trigger`,"aria-label":`Theme: ${t} (${n})`,title:`Change theme`,children:[(0,B.jsx)(zi,{theme:t}),(0,B.jsx)(`span`,{className:e.labelClassName,children:r})]}),(0,B.jsx)(Pi,{className:`theme-toggle-menu`,align:`end`,children:Bi.map(e=>(0,B.jsxs)(Fi,{className:`theme-toggle-option`,active:t===e.value,onSelect:()=>Si(e.value),children:[(0,B.jsx)(zi,{theme:e.value}),(0,B.jsx)(`span`,{children:e.label})]},e.value))})]})}var Hi={layout:`_layout_1qte4_1`,root:`_root_1qte4_10`,header:`_header_1qte4_36`,footer:`_footer_1qte4_37`,content:`_content_1qte4_49`,inset:`_inset_1qte4_65`,trigger:`_trigger_1qte4_73`,group:`_group_1qte4_104`,groupContent:`_groupContent_1qte4_105`,eyebrow:`_eyebrow_1qte4_114`,groupLabel:`_groupLabel_1qte4_123`,menu:`_menu_1qte4_141`,menuItem:`_menuItem_1qte4_146`,menuButton:`_menuButton_1qte4_150`,menuButtonActive:`_menuButtonActive_1qte4_176`,headerRow:`_headerRow_1qte4_182`,sidebarToggle:`_sidebarToggle_1qte4_189`,brand:`_brand_1qte4_202`,brandTitle:`_brandTitle_1qte4_208`,brandText:`_brandText_1qte4_215`,brandMark:`_brandMark_1qte4_229`,menuIcon:`_menuIcon_1qte4_230`,icon:`_icon_1qte4_231`,footerMeta:`_footerMeta_1qte4_266`,footerValue:`_footerValue_1qte4_271`,footerBlock:`_footerBlock_1qte4_279`,footerDivider:`_footerDivider_1qte4_286`,footerActions:`_footerActions_1qte4_292`,footerMenu:`_footerMenu_1qte4_293`,footerAction:`_footerAction_1qte4_292`,footerButton:`_footerButton_1qte4_308`,themeToggleLabel:`_themeToggleLabel_1qte4_345`},Ui=1080,Wi=`b`,Gi=(0,R.createContext)(null);function Ki(){let e=(0,R.useContext)(Gi);if(!e)throw Error(`Sidebar components must be used within SidebarProvider.`);return e}function qi(){return typeof window>`u`?!1:window.innerWidth<Ui}var Ji=`hybridclaw_sidebar_state`;function Yi(e,t){if(!t||typeof window>`u`)return e;let n=localStorage.getItem(t);return n===`true`?!0:n===`false`?!1:e}function Xi(e){let t=e.storageKey??Ji,[n,r]=(0,R.useState)(()=>Yi(e.defaultOpen??!0,t)),i=(0,R.useCallback)(e=>{r(n=>{let r=typeof e==`function`?e(n):e;if(r===n)return n;if(t)try{localStorage.setItem(t,String(r))}catch{}return r})},[t]),[a,o]=(0,R.useState)(!1),[s,c]=(0,R.useState)(qi);(0,R.useEffect)(()=>{if(typeof window>`u`)return;let e=qi();function t(){let t=qi();t!==e&&(e=t,c(t),t||o(!1))}function n(e){if(e.key.toLowerCase()!==Wi||!(e.metaKey||e.ctrlKey))return;let t=e.target;t instanceof HTMLElement&&(t.isContentEditable||t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`)||(e.preventDefault(),qi()?o(e=>!e):i(e=>!e))}return t(),window.addEventListener(`resize`,t),window.addEventListener(`keydown`,n),()=>{window.removeEventListener(`resize`,t),window.removeEventListener(`keydown`,n)}},[i]);let l=(0,R.useMemo)(()=>({state:n?`expanded`:`collapsed`,open:n,setOpen:i,openMobile:a,setOpenMobile:o,isMobile:s,toggleSidebar(){s?o(e=>!e):i(e=>!e)}}),[s,n,a,i]);return(0,B.jsx)(Gi.Provider,{value:l,children:(0,B.jsx)(`div`,{className:Hi.layout,style:e.style,children:e.children})})}function Zi(){return Ki()}function Qi({side:e=`left`,collapsible:t=`icon`,children:n}){let r=Ki();if(r.isMobile)return(0,B.jsx)(ri,{open:r.openMobile,onOpenChange:r.setOpenMobile,isDrawer:!0,children:(0,B.jsxs)(ii,{side:e,"data-sidebar":`sidebar`,"data-mobile":`true`,style:{"--sheet-width":`var(--sidebar-width-mobile)`},children:[(0,B.jsxs)(ai,{visuallyHidden:!0,children:[(0,B.jsx)(oi,{children:`Navigation`}),(0,B.jsx)(si,{children:`Sidebar navigation panel.`})]}),n]})});if(t===`none`)return(0,B.jsx)(`aside`,{className:Hi.root,"data-side":e,"data-state":`expanded`,children:n});let i=r.open?`expanded`:`collapsed`;return(0,B.jsx)(`aside`,{className:Hi.root,"data-hc-sidebar-root":``,"data-side":e,"data-state":i,children:n})}function $i(e){return(0,B.jsx)(`div`,{className:Hi.header,"data-hc-sidebar-header":``,children:e.children})}function ea(e){return(0,B.jsx)(`div`,{className:Hi.content,children:e.children})}function ta(e){return(0,B.jsx)(`div`,{className:Hi.footer,children:e.children})}function na(e){let{className:t,children:n,...r}=e;return(0,B.jsx)(`main`,{...r,className:V(Hi.inset,t),"data-hc-main-panel":``,children:n})}function ra(e){let{className:t,children:n,...r}=e,i=Ki(),a=i.isMobile?i.openMobile?`Close sidebar`:`Open sidebar`:i.open?`Collapse sidebar`:`Expand sidebar`;return(0,B.jsx)(`button`,{...r,type:e.type??`button`,className:V(Hi.trigger,t),"aria-label":e[`aria-label`]??a,"aria-expanded":i.isMobile?i.openMobile:i.open,onClick:t=>{e.onClick?.(t),t.defaultPrevented||i.toggleSidebar()},children:n??(0,B.jsx)(Sr,{})})}function ia(e){let{isMobile:t}=Ki();return t?(0,B.jsx)(ra,{className:e.className}):null}function aa(e){return(0,B.jsx)(`section`,{className:Hi.group,children:e.children})}function oa(e){return(0,B.jsx)(`p`,{className:Hi.groupLabel,children:e.children})}function sa(e){return(0,B.jsx)(`div`,{className:Hi.groupContent,children:e.children})}function ca(e){return(0,B.jsx)(`nav`,{className:Hi.menu,"aria-label":e.ariaLabel,children:e.children})}function la(e){return(0,B.jsx)(`div`,{className:Hi.menuItem,children:e.children})}function ua(e){return(0,B.jsx)(`div`,{className:Hi.footerActions,children:e.children})}function da(e){return(0,B.jsx)(`div`,{className:Hi.footerMenu,children:e.children})}function fa(e){return(0,B.jsx)(`div`,{className:Hi.footerAction,children:e.children})}function pa(e,t=e){return{"--sidebar-width":e,"--sidebar-width-icon":`4rem`,"--sidebar-width-mobile":t}}function ma(e){return(0,B.jsxs)(Qi,{collapsible:`icon`,children:[(0,B.jsx)($i,{children:(0,B.jsxs)(`div`,{className:Hi.headerRow,children:[(0,B.jsx)(ha,{subtitle:`Admin console`}),(0,B.jsx)(ra,{className:Hi.sidebarToggle})]})}),(0,B.jsx)(ea,{children:e.groups.map(e=>(0,B.jsxs)(aa,{children:[(0,B.jsx)(oa,{children:e.label}),(0,B.jsx)(sa,{children:(0,B.jsx)(ca,{ariaLabel:e.label,children:e.items.map(e=>(0,B.jsx)(la,{children:(0,B.jsx)(ga,{item:e})},e.to))})})]},e.label))}),(0,B.jsxs)(ta,{children:[(0,B.jsxs)(`div`,{className:Hi.footerBlock,children:[(0,B.jsx)(_a,{version:e.version}),(0,B.jsx)(ua,{children:(0,B.jsx)(da,{children:(0,B.jsx)(fa,{children:(0,B.jsx)(Vi,{labelClassName:Hi.themeToggleLabel})})})})]}),e.showLogout?(0,B.jsx)(va,{onLogout:e.onLogout}):null]})]})}function ha(e){return(0,B.jsx)(`div`,{className:Hi.brand,children:(0,B.jsxs)(`div`,{className:Hi.brandTitle,children:[(0,B.jsx)(`span`,{className:Hi.brandMark,"aria-hidden":`true`,children:(0,B.jsx)(pr,{})}),(0,B.jsxs)(`div`,{className:Hi.brandText,children:[(0,B.jsx)(`h1`,{children:`HybridClaw`}),e.subtitle?(0,B.jsx)(`span`,{className:Hi.eyebrow,children:e.subtitle}):null]})]})})}function ga(e){let{isMobile:t,setOpenMobile:n}=Zi();return(0,B.jsxs)(D,{to:e.item.to,title:e.item.label,activeProps:{className:V(Hi.menuButton,Hi.menuButtonActive)},inactiveProps:{className:Hi.menuButton},activeOptions:{exact:!0},onClick:()=>{t&&n(!1)},children:[(0,B.jsx)(`span`,{className:Hi.menuIcon,"aria-hidden":`true`,children:(0,B.jsx)(e.item.icon,{})}),(0,B.jsx)(`span`,{children:e.item.label})]})}function _a(e){return e.version?(0,B.jsx)(`div`,{className:Hi.footerMeta,children:(0,B.jsxs)(`span`,{className:Hi.footerValue,children:[`v`,e.version]})}):null}function va(e){let[t,n]=(0,R.useState)(!1);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:Hi.footerDivider}),(0,B.jsx)(ua,{children:(0,B.jsx)(da,{children:(0,B.jsx)(fa,{children:(0,B.jsxs)(`button`,{className:Hi.footerButton,type:`button`,onClick:()=>n(!0),children:[(0,B.jsx)(`span`,{className:Hi.icon,"aria-hidden":`true`,children:(0,B.jsx)(_r,{})}),`Forget token`]})})})}),(0,B.jsx)(ri,{open:t,onOpenChange:n,children:(0,B.jsxs)(ii,{size:`sm`,role:`alertdialog`,children:[(0,B.jsxs)(ai,{children:[(0,B.jsx)(oi,{children:`Forget token?`}),(0,B.jsx)(si,{children:`You will be logged out and will need to enter your token again to access the admin console.`})]}),(0,B.jsxs)(ci,{children:[(0,B.jsx)(li,{className:`ghost-button`,children:`Cancel`}),(0,B.jsx)(li,{className:`danger-button`,onClick:e.onLogout,children:`Forget token`})]})]})})]})}var ya=[{href:`/chat`,icon:`chat`,label:`Chat`},{href:`/agents`,icon:`agents`,label:`Agents`},{href:`/admin`,icon:`admin`,label:`Admin`},{href:`https://github.com/HybridAIOne/hybridclaw`,image:`/icons/github.svg`,label:`GitHub`},{href:`/docs`,icon:`docs`,label:`Docs`}],ba={admin:qn,agents:Yn,chat:Qn,docs:sr},xa=[`/admin`,`/agents`,`/chat`],Sa=3e4;function Ca(e){return y({queryKey:[`config`,e],queryFn:()=>Mt(e),staleTime:3e4,refetchInterval:Sa,refetchOnWindowFocus:!0}).data?.config.ui?.navigation}function wa(e,t){return e===t||e.startsWith(`${t}/`)}function Ta(e){return/^https?:\/\//iu.test(e)}function Ea(e){return xa.some(t=>e===t||e.startsWith(`${t}/`))}function Da({item:e}){return e.image?(0,B.jsx)(`img`,{src:e.image,alt:``,"aria-hidden":`true`,decoding:`async`,draggable:!1,referrerPolicy:`no-referrer`}):(0,B.jsx)(e.icon?ba[e.icon]:rr,{})}function Oa(e,t){return t.filter(t=>!Ta(t.href)&&wa(e,t.href)).sort((e,t)=>t.href.length-e.href.length)[0]?.href??null}function ka(e){let t=I({select:e=>e.location.pathname}),n=e.items??ya;if(n.length===0)return null;let r=Oa(t,n);return(0,B.jsx)(`nav`,{className:`view-switch`,"aria-label":`Switch view`,children:n.map((e,t)=>{let n=`${e.href}:${e.label}:${t}`,i=(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`nav-link-icon`,"aria-hidden":`true`,children:(0,B.jsx)(Da,{item:e})}),(0,B.jsx)(`span`,{children:e.label})]}),a=Ta(e.href);if(a||!Ea(e.href)){let t=e.href===r;return(0,B.jsx)(`a`,{className:t?`view-switch-link active`:`view-switch-link`,href:e.href,"aria-current":t?`page`:void 0,target:a?`_blank`:void 0,rel:a?`noopener noreferrer`:void 0,children:i},n)}return e.href===r?(0,B.jsx)(`span`,{className:`view-switch-link active`,"aria-current":`page`,children:i},n):(0,B.jsx)(D,{className:`view-switch-link`,to:e.href,children:i},n)})})}var Aa=pa(`15.5rem`,`18rem`),ja=(0,R.createContext)({emailEnabled:!1});function Ma(e){let t=Gn(),n=Wn(t),r=I({select:e=>e.location.pathname}),i=y({queryKey:[`status`,t.token],queryFn:()=>je(t.token),initialData:t.gatewayStatus??void 0,enabled:n,staleTime:3e4}),a=Ca(t.token),o=(i.data?.emailEnabled??t.gatewayStatus?.emailEnabled)===!0,s=Rr.map(e=>({...e,items:e.items.filter(e=>!e.requiresEmail||o||r===e.to)})).filter(e=>e.items.length>0),c=Br(r);return(0,B.jsx)(ja.Provider,{value:{emailEnabled:o},children:(0,B.jsxs)(Xi,{style:Aa,children:[(0,B.jsx)(ma,{groups:s,version:t.gatewayStatus?.version,showLogout:!!t.token,onLogout:t.logout}),(0,B.jsxs)(na,{className:`main-panel`,children:[(0,B.jsxs)(`div`,{className:`topbar`,children:[(0,B.jsx)(`div`,{className:`topbar-title`,children:(0,B.jsxs)(`div`,{className:`topbar-heading`,children:[(0,B.jsx)(ia,{}),(0,B.jsx)(`h2`,{children:c.label})]})}),(0,B.jsx)(ka,{items:a})]}),(0,B.jsx)(`div`,{className:`page-content`,children:e.children})]})]})})}function Na(){return(0,R.useContext)(ja)}var Pa={skeleton:`_skeleton_z1cth_1`,"skeleton-pulse":`_skeleton-pulse_z1cth_1`},Fa=(0,R.forwardRef)(function({className:e,...t},n){return(0,B.jsx)(`div`,{ref:n,"data-slot":`skeleton`,className:V(Pa.skeleton,e),...t})}),Ia=(0,R.createContext)(null);function La(){let e=(0,R.useContext)(Ia);if(!e)throw Error(`<ToggleGroupItem> must be used inside <ToggleGroup>`);return e}function Ra(e){let t=e.disabled??!1,n=(0,R.useMemo)(()=>({value:e.value,onValueChange:e.onValueChange,disabled:t}),[e.value,e.onValueChange,t]);return(0,B.jsx)(Ia.Provider,{value:n,children:(0,B.jsx)(`fieldset`,{"aria-label":e.ariaLabel,className:V(`binary-toggle`,e.size===`sm`&&`toggle-group--sm`,e.className),"data-disabled":t||void 0,children:e.children})})}function za(e){let t=La(),n=e.value===t.value,r=e.activeTone??`is-on`,i=e.disabled??t.disabled;return(0,B.jsx)(`button`,{type:`button`,"aria-pressed":n,"data-state":n?r===`is-off`?`off`:`on`:`off`,className:V(`binary-toggle-button`,n&&`active`,n&&r),disabled:i,"data-disabled":i||void 0,onClick:()=>{!n&&!i&&t.onValueChange(e.value)},children:e.children})}function Ba(e,t){let[n,r]=(0,R.useState)(t.initialSort);return{sortedRows:(0,R.useMemo)(()=>{let r=t.sorters[n.key];return r?[...e].sort((e,t)=>{let i=r(e,t);return i===0?0:n.direction===`asc`?i:-i}):[...e]},[t.sorters,e,n]),sortState:n,toggleSort:e=>{r(n=>n.key===e?{key:e,direction:n.direction===`asc`?`desc`:`asc`}:{key:e,direction:t.defaultDirections?.[e]||`asc`})}}}function Va(e){let t=e.sortState.key===e.sortKey;return(0,B.jsx)(`th`,{"aria-sort":t?e.sortState.direction===`asc`?`ascending`:`descending`:`none`,children:(0,B.jsxs)(`button`,{type:`button`,className:`table-sort-button`,onClick:()=>e.onToggle(e.sortKey),children:[(0,B.jsx)(`span`,{children:e.label}),(0,B.jsx)(`span`,{"aria-hidden":`true`,className:t?`table-sort-indicator is-active is-${e.sortState.direction}`:`table-sort-indicator`})]})})}function Ha(e){return!e.description&&!e.actions?null:(0,B.jsxs)(`div`,{className:`page-header`,children:[e.description?(0,B.jsx)(`div`,{className:`supporting-text page-header-description`,children:e.description}):(0,B.jsx)(`span`,{}),e.actions?(0,B.jsx)(`div`,{className:`header-actions`,children:e.actions}):null]})}function Ua(e){let t=(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{children:e.label}),e.loading?(0,B.jsx)(Fa,{className:`metric-card-value-skeleton`}):(0,B.jsx)(`strong`,{children:e.value}),e.loading&&e.detail!==void 0?(0,B.jsx)(Fa,{className:`metric-card-detail-skeleton`}):!e.loading&&e.detail?(0,B.jsx)(`small`,{children:e.detail}):null]});return e.href?(0,B.jsx)(`a`,{className:`metric-card metric-card-link`,href:e.href,children:t}):(0,B.jsx)(`div`,{className:`metric-card`,children:t})}function Wa(e){return(0,B.jsx)(Ra,{value:e.value,onValueChange:t=>e.onChange(t),ariaLabel:e.ariaLabel,className:e.className,disabled:e.disabled,size:e.size,children:e.options.map(e=>(0,B.jsx)(za,{value:e.value,activeTone:e.activeTone,children:e.label},e.value))})}function Ga(e){let t=e.value?e.trueLabel??`on`:e.falseLabel??`off`,n=!e.value&&e.falseTone===`danger`?` tone-danger`:``;return(0,B.jsxs)(`span`,{className:e.value?`boolean-pill is-on`:`boolean-pill is-off${n}`,children:[(0,B.jsx)(`span`,{className:`boolean-pill-dot`}),t]})}function H(e){return e instanceof Error?e.message||`An unexpected error occurred.`:typeof e==`string`?e:typeof e==`object`&&e&&`message`in e&&typeof e.message==`string`?e.message||`An unexpected error occurred.`:String(e)}function Ka(e){return new Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:1}).format(e)}function qa(e){return typeof e==`number`&&Number.isFinite(e)?e:0}function Ja(e){return`${Ka(qa(e.inputTokens))} in / ${Ka(qa(e.outputTokens))} out`}function Ya(e){return`${Math.round(e*100)}%`}function Xa(e){return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`,minimumFractionDigits:e>=1?2:4,maximumFractionDigits:e>=1?2:6}).format(e)}function Za(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return`unknown`;let n=Date.now()-t.getTime(),r=6e4,i=60*r,a=24*i;return n<r?`just now`:n<i?`${Math.floor(n/r)}m ago`:n<a?`${Math.floor(n/i)}h ago`:`${Math.floor(n/a)}d ago`}function Qa(e){if(!e)return`never`;let t=new Date(e);return Number.isNaN(t.getTime())?`unknown`:t.toLocaleString()}function $a(e){let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60);return[t?`${t}d`:null,n?`${n}h`:null,`${r}m`].filter(Boolean).join(` `)}function eo(e,t,n=`${t}s`){return`${e} ${e===1?t:n}`}function to(e){return e.split(/[\n,]/g).map(e=>e.trim()).filter(Boolean)}function no(e){return(e||[]).join(`, `)}function ro(e){let t=e.latestMessage?.content.replace(/\s+/g,` `).trim();return t?t.length>140?`${t.slice(0,137)}...`:t:`No message content`}function io(e){return e.participants.length===0?`No participants`:e.participants.length<=2?e.participants.join(` -> `):`${e.participants.slice(0,2).join(` -> `)} +${e.participants.length-2}`}function ao(e){return`${e} message${e===1?``:`s`}`}function oo(e){return e===`escalate`||e===`policy.update`?`mailbox-role-pill needs-reply`:`mailbox-role-pill replied`}function so(e){let{message:t}=e;return(0,B.jsxs)(`article`,{className:`mailbox-message-card user`,children:[(0,B.jsxs)(`div`,{className:`mailbox-message-header`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:t.senderAgentId}),(0,B.jsxs)(`small`,{children:[`To: `,t.recipientAgentId]}),(0,B.jsx)(`small`,{children:Qa(t.createdAt)})]}),(0,B.jsx)(`span`,{children:t.intent})]}),(0,B.jsxs)(`div`,{className:`mailbox-message-metadata`,children:[(0,B.jsx)(`small`,{children:t.id}),t.parentMessageId?(0,B.jsxs)(`small`,{children:[`Parent: `,t.parentMessageId]}):null]}),(0,B.jsx)(`div`,{className:`mailbox-message-body`,children:t.content})]})}function co(){let e=Gn(),[t,n]=(0,R.useState)(null),r=y({queryKey:[`a2a-inbox`,e.token,t],queryFn:()=>$e(e.token,t)}),i=r.data?.threads||[],a=t||r.data?.selectedThreadId||null,o=i.find(e=>e.id===a)||null,s=r.data?.messages||[];return(0,B.jsxs)(`div`,{className:`page-stack`,children:[(0,B.jsx)(Ha,{}),(0,B.jsxs)(`div`,{className:`mailbox-shell a2a-inbox-shell`,children:[(0,B.jsxs)(`section`,{className:`mailbox-main`,children:[(0,B.jsx)(`div`,{className:`mailbox-column-header`,children:(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:`Threads`}),(0,B.jsx)(`small`,{children:r.isLoading&&!r.data?`Loading threads...`:`${i.length} total`})]})}),(0,B.jsx)(`div`,{className:`mailbox-thread-list`,children:r.isLoading&&!r.data?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading A2A threads...`}):r.isError?(0,B.jsx)(`div`,{className:`empty-state error`,children:H(r.error)}):i.length===0?(0,B.jsx)(`div`,{className:`empty-state`,children:`No A2A threads recorded.`}):i.map(e=>{let t=e.latestMessage;return(0,B.jsx)(`div`,{className:[`mailbox-thread-row`,e.id===a?`is-unread`:``].filter(Boolean).join(` `),children:(0,B.jsxs)(`button`,{className:`mailbox-thread-button`,type:`button`,onClick:()=>n(e.id),children:[(0,B.jsxs)(`div`,{className:`mailbox-thread-summary`,children:[(0,B.jsx)(`strong`,{className:`mailbox-thread-sender`,children:e.id}),(0,B.jsx)(`span`,{className:`mailbox-thread-separator`,children:`-`}),(0,B.jsx)(`strong`,{className:`mailbox-thread-subject`,children:t?.intent||`thread`}),(0,B.jsx)(`span`,{className:`mailbox-thread-separator`,children:`-`}),(0,B.jsx)(`span`,{className:`mailbox-thread-preview`,children:ro(e)})]}),(0,B.jsx)(`span`,{className:`mailbox-thread-time`,children:t?.createdAt?Za(t.createdAt):`unknown`})]})},e.id)})})]}),(0,B.jsx)(`section`,{className:`mailbox-detail`,children:o?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`mailbox-detail-header`,children:(0,B.jsxs)(`div`,{className:`mailbox-detail-copy`,children:[(0,B.jsxs)(`div`,{className:`mailbox-detail-heading`,children:[(0,B.jsx)(`h3`,{children:o.id}),o.latestMessage?(0,B.jsx)(`span`,{className:oo(o.latestMessage.intent),children:o.latestMessage.intent}):null]}),(0,B.jsxs)(`p`,{className:`supporting-text`,children:[io(o),` ·`,` `,ao(o.messageCount),` ·`,` `,o.ownerCoworkerId?`Owned by ${o.ownerCoworkerId}`:`No owner`]}),o.latestMessage?(0,B.jsxs)(`p`,{className:`supporting-text`,children:[`Last message:`,` `,Qa(o.latestMessage.createdAt)]}):null]})}),(0,B.jsx)(`div`,{className:`mailbox-message-list`,children:r.isFetching&&!r.data?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading messages...`}):s.length===0?(0,B.jsx)(`div`,{className:`empty-state`,children:`No messages in this thread.`}):s.map(e=>(0,B.jsx)(so,{message:e},e.id))})]}):(0,B.jsx)(`div`,{className:`empty-state mailbox-detail-empty`,children:`Select an A2A thread.`})})]})]})}var lo={card:`_card_1739l_1`,header:`_header_1739l_34`,action:`_action_1739l_41`,title:`_title_1739l_45`,description:`_description_1739l_54`,content:`_content_1739l_70`,footer:`_footer_1739l_77`},U=(0,R.forwardRef)(function({variant:e=`default`,interactive:t,className:n,...r},i){return(0,B.jsx)(`div`,{ref:i,"data-slot":`card`,"data-variant":e,"data-interactive":t?``:void 0,tabIndex:t?r.tabIndex??0:r.tabIndex,className:V(lo.card,n),...r})}),W=(0,R.forwardRef)(function({className:e,...t},n){return(0,B.jsx)(`div`,{ref:n,"data-slot":`card-header`,className:V(lo.header,e),...t})}),G=(0,R.forwardRef)(function({className:e,...t},n){return(0,B.jsx)(`h4`,{ref:n,"data-slot":`card-title`,className:V(lo.title,e),...t})}),uo=(0,R.forwardRef)(function({className:e,...t},n){return(0,B.jsx)(`p`,{ref:n,"data-slot":`card-description`,className:V(lo.description,e),...t})}),fo=(0,R.forwardRef)(function({className:e,...t},n){return(0,B.jsx)(`div`,{ref:n,"data-slot":`card-action`,className:V(lo.action,e),...t})}),K=(0,R.forwardRef)(function({className:e,...t},n){return(0,B.jsx)(`div`,{ref:n,"data-slot":`card-content`,className:V(lo.content,e),...t})});(0,R.forwardRef)(function({className:e,...t},n){return(0,B.jsx)(`div`,{ref:n,"data-slot":`card-footer`,className:V(lo.footer,e),...t})});function po(e){let t=(0,R.useRef)(e);return(0,R.useLayoutEffect)(()=>{t.current=e}),(0,R.useCallback)((...e)=>t.current(...e),[])}var mo=(0,R.createContext)(null);function ho(){return(0,R.useContext)(mo)}var go=(0,R.createContext)(null);function _o(){return(0,R.useContext)(go)}var vo=(0,R.createContext)(null),yo=(0,R.createContext)(null),bo=(0,R.createContext)(null);function xo(){return(0,R.useContext)(vo)}function So(){return(0,R.useContext)(bo)}var Co={label:`_label_g5ybj_1`};function wo({className:e,...t}){return(0,B.jsx)(`label`,{"data-slot":`label`,className:V(Co.label,e),...t})}var To=(0,R.createContext)({id:void 0,labelId:void 0,descriptionId:void 0,errorId:void 0,invalid:void 0,disabled:void 0,required:void 0,error:null,setError:()=>{},touched:!1,setTouched:()=>{}});function Eo(){return(0,R.useContext)(To)}function Do(e){let t=Eo(),n=Oo(t.descriptionId,t.invalid?t.errorId:void 0,e[`aria-describedby`]),r=e.required??t.required;return{...e,id:e.id??t.id,disabled:e.disabled??t.disabled,required:r,"aria-invalid":e[`aria-invalid`]??t.invalid,"aria-required":e[`aria-required`]??(r?!0:void 0),"aria-describedby":n}}function Oo(...e){let t=e.filter(e=>!!e);return t.length===0?void 0:t.join(` `)}var ko={fieldSet:`_fieldSet_ykv3y_3`,legend:`_legend_ykv3y_10`,group:`_group_ykv3y_30`,field:`_field_ykv3y_3`,orientationVertical:`_orientationVertical_ykv3y_58`,orientationHorizontal:`_orientationHorizontal_ykv3y_66`,orientationResponsive:`_orientationResponsive_ykv3y_81`,content:`_content_ykv3y_104`,label:`_label_ykv3y_114`,title:`_title_ykv3y_126`,description:`_description_ykv3y_139`,error:`_error_ykv3y_159`,errorList:`_errorList_ykv3y_166`,separator:`_separator_ykv3y_176`,separatorLine:`_separatorLine_ykv3y_187`,separatorLabel:`_separatorLabel_ykv3y_194`},Ao=e=>e==null||typeof e==`string`&&e.trim()===``?`Required.`:null;function jo(e){return e===void 0?Ao:t=>t==null||typeof t==`string`&&t.trim()===``?e:null}function Mo(e,t){return n=>typeof n==`string`?(e.lastIndex=0,e.test(n)?null:t):null}function No(...e){let t=e.filter(e=>typeof e==`function`);return e=>{for(let n of t){let t=n(e);if(t)return t}return null}}var Po={vertical:ko.orientationVertical,horizontal:ko.orientationHorizontal,responsive:ko.orientationResponsive};function Fo({className:e,...t}){return(0,B.jsx)(`fieldset`,{"data-slot":`field-set`,className:V(ko.fieldSet,e),...t})}function Io({className:e,variant:t=`legend`,...n}){return(0,B.jsx)(`legend`,{"data-slot":`field-legend`,"data-variant":t,className:V(ko.legend,e),...n})}function Lo({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`field-group`,className:V(ko.group,e),...t})}function q({className:e,orientation:t=`vertical`,invalid:n,disabled:r,required:i,controlId:a,onErrorChange:o,error:s,touched:c,validate:l,onBlur:u,onChange:d,...f}){let p=_o(),m=(0,R.useId)(),h=a??p?.id??m,g=i??p?.required,_=r??p?.disabled,v=l??p?.validate,[y,b]=(0,R.useState)(null),[x,S]=(0,R.useState)(!1),C=po(o??Ro),w=s!==void 0,T=c??x,E=(0,R.useCallback)(e=>{w||b(t=>t===e?t:e)},[w]),D=w?s:y??p?.error??null,O=xo();(0,R.useEffect)(()=>{O&&O.registerError(h,D)},[O,h,D]),(0,R.useEffect)(()=>{if(O)return()=>O.registerError(h,null)},[O,h]),(0,R.useEffect)(()=>{if(!(!O||w))return O.registerErrorSetter(h,e=>{e!==null&&S(!0),E(e)})},[O,h,w,E]),(0,R.useEffect)(()=>{C(D)},[D,C]);let k=So(),A=k?.submitAttempted??!1,j=k?.resetSeq??0,M=(0,R.useRef)(j);M.current!==j&&(M.current=j,S(!1),b(null));let N=po(v??zo);(0,R.useEffect)(()=>{if(!(v===void 0||!O))return O.registerValidator(h,()=>{let e=N();return E(e),e})},[O,h,v,N,E]);let P;P=n===void 0?(w||T||A)&&D!==null?!0:void 0:n;let F=(0,R.useMemo)(()=>({id:h,labelId:`${h}-label`,descriptionId:`${h}-description`,errorId:`${h}-error`,invalid:P,disabled:_,required:g,error:D,setError:E,touched:T,setTouched:S}),[h,P,_,g,D,E,T]);return(0,B.jsx)(To.Provider,{value:F,children:(0,B.jsx)(`div`,{"data-slot":`field`,"data-orientation":t,"data-invalid":P||void 0,"data-disabled":_||void 0,className:V(ko.field,Po[t],e),onBlur:e=>{S(!0),u?.(e)},onChange:e=>{S(!0),d?.(e)},...f})})}function Ro(){}function zo(){return null}function Bo({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`field-content`,className:V(ko.content,e),...t})}function J({className:e,htmlFor:t,id:n,...r}){let i=Eo();return(0,B.jsx)(wo,{"data-slot":`field-label`,id:n??i.labelId,htmlFor:t??i.id,className:V(ko.label,e),...r})}function Vo({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`field-title`,className:V(ko.title,e),...t})}function Ho({className:e,id:t,...n}){let r=Eo();return(0,B.jsx)(`p`,{"data-slot":`field-description`,id:t??r.descriptionId,className:V(ko.description,e),...n})}function Uo(e,t,n){if(e)return e;if(t?.length){let e=[...new Map(t.map(e=>[e?.message,e])).values()].filter(e=>!!e?.message);return e.length===0?n:e.length===1?e[0]?.message:(0,B.jsx)(`ul`,{className:ko.errorList,children:e.map(e=>(0,B.jsx)(`li`,{children:e.message},e.message))})}return n}function Wo({className:e,children:t,errors:n,id:r,...i}){let a=Eo(),o=Uo(t,n,a.error);return!o||!a.invalid?null:(0,B.jsx)(`div`,{...i,role:`alert`,"data-slot":`field-error`,id:r??a.errorId,className:V(ko.error,e),children:o})}var Go={input:`_input_19no1_1`,sizeDefault:`_sizeDefault_19no1_68`,sizeSm:`_sizeSm_19no1_73`},Ko={default:Go.sizeDefault,sm:Go.sizeSm};function Y({className:e,type:t=`text`,size:n=`default`,...r}){return(0,B.jsx)(`input`,{...Do(r),type:t,"data-slot":`input`,"data-size":n,className:V(Go.input,Ko[n],e)})}var qo={textarea:`_textarea_1euii_1`,autoSize:`_autoSize_1euii_49`};function Jo({className:e,autoSize:t=!1,...n}){return(0,B.jsx)(`textarea`,{...Do(n),"data-slot":`textarea`,"data-auto-size":t?``:void 0,className:V(qo.textarea,t&&qo.autoSize,e)})}function Yo(e){return e.length>18?`${e.slice(0,12)}...${e.slice(-6)}`:e}function Xo(e){return e.status===`revoked`?(0,B.jsx)(Ga,{value:!1,falseLabel:`revoked`,falseTone:`danger`}):(0,B.jsx)(Ga,{value:!0,trueLabel:`trusted`})}function Zo(){let e=Gn(),t=o(),[n,r]=(0,R.useState)(null),[i,a]=(0,R.useState)(``),[s,c]=(0,R.useState)(``),[l,u]=(0,R.useState)(``),[d,f]=(0,R.useState)(``),[p,m]=(0,R.useState)(``),[h,_]=(0,R.useState)(``),[v,b]=(0,R.useState)(``),[x,S]=(0,R.useState)(``),[C,w]=(0,R.useState)(``),[T,E]=(0,R.useState)(``),[D,O]=(0,R.useState)(``),[k,A]=(0,R.useState)(!0),[j,M]=(0,R.useState)(null),[N,P]=(0,R.useState)(null),[F,I]=(0,R.useState)(``),ee=y({queryKey:[`a2a-trust`,e.token],queryFn:()=>Be(e.token)}),L=g({mutationFn:t=>et(e.token,{peerId:t,reason:i}),onSuccess:n=>{t.setQueryData([`a2a-trust`,e.token],n)}}),te=g({mutationFn:()=>{let t=h.trim()?JSON.parse(h):void 0;return tt(e.token,{peerId:s,agentCardUrl:l||void 0,deliveryUrl:d||void 0,publicKeyFingerprint:p||void 0,publicKeyJwk:t,reason:v||void 0})},onSuccess:n=>{t.setQueryData([`a2a-trust`,e.token],n)}}),ne=g({mutationFn:t=>nt(e.token,t),onSuccess:n=>{t.setQueryData([`a2a-trust`,e.token],n),r(n.peers[0]?.peerId||null)}}),re=g({mutationFn:()=>rt(e.token,{peerUrl:x||void 0,canonicalId:C||void 0,canonicalInstanceId:T||void 0,reason:D||void 0,notifyPeer:k}),onSuccess:n=>{t.setQueryData([`a2a-trust`,e.token],n),P(n),r(n.proposal.peerId)}}),ie=g({mutationFn:()=>it(e.token,{peerUrl:x||void 0,canonicalId:C||void 0,canonicalInstanceId:T||void 0}),onSuccess:e=>{M(e),P(null)}}),ae=g({mutationFn:t=>at(e.token,t,F),onSuccess:n=>{t.setQueryData([`a2a-trust`,e.token],n)}}),oe=g({mutationFn:t=>ot(e.token,t,F),onSuccess:n=>{t.setQueryData([`a2a-trust`,e.token],n)}}),se=ee.data?.peers||[],ce=ee.data?.pairingRequests||[],le=se.find(e=>e.peerId===n)||se[0]||null;function ue(e){c(e.peerId),u(e.agentCardUrl),f(e.deliveryUrl),m(e.publicKeyFingerprint),_(e.publicKeyJwk?JSON.stringify(e.publicKeyJwk,null,2):``),b(``)}function de(){M(null),P(null)}return(0,B.jsxs)(`div`,{className:`page-stack`,children:[(0,B.jsx)(Ha,{}),(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{children:(0,B.jsx)(G,{children:`Local identity`})}),(0,B.jsx)(K,{children:ee.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading identity...`}):ee.data?(0,B.jsxs)(`div`,{className:`key-value-grid`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Instance`}),(0,B.jsx)(`strong`,{children:ee.data.identity.instanceId})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Public key`}),(0,B.jsx)(`strong`,{children:Yo(ee.data.identity.publicKeyFingerprint)})]})]}):(0,B.jsx)(`div`,{className:`empty-state`,children:`Identity unavailable.`})})]}),(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:`Add peer instance`}),(0,B.jsx)(uo,{children:`Fetch a peer Agent Card, pin its public key, and notify the remote operator.`})]}),(0,B.jsx)(K,{children:(0,B.jsxs)(`div`,{className:`detail-stack`,children:[(0,B.jsxs)(`div`,{className:`two-column-grid`,children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Peer URL`}),(0,B.jsx)(Y,{placeholder:`https://peer.example.com`,value:x,onChange:e=>{S(e.target.value),de()}})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Canonical agent id`}),(0,B.jsx)(Y,{placeholder:`agent@user@instance`,value:C,onChange:e=>{w(e.target.value),de()}})]})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Canonical instance id`}),(0,B.jsx)(Y,{placeholder:`instance-prod`,value:T,onChange:e=>{E(e.target.value),de()}})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Reason`}),(0,B.jsx)(Y,{value:D,onChange:e=>O(e.target.value)})]}),(0,B.jsxs)(`label`,{className:`inline-checkbox`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:k,onChange:e=>A(e.target.checked)}),(0,B.jsx)(`span`,{children:`Send peer-side approval prompt`})]}),(0,B.jsx)(`button`,{className:`primary-button`,type:`button`,disabled:!x.trim()&&!C.trim()&&!T.trim()||ie.isPending,onClick:()=>ie.mutate(),children:`Fetch peer`}),j?(0,B.jsx)(`div`,{className:`info-row`,children:(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:j.proposal.peerId}),(0,B.jsx)(`small`,{children:j.proposal.agentCardUrl}),(0,B.jsx)(`small`,{children:j.proposal.deliveryUrl}),(0,B.jsx)(`small`,{children:j.proposal.publicKeyFingerprint})]})}):null,(0,B.jsx)(`button`,{className:`primary-button`,type:`button`,disabled:!j||re.isPending||ie.isPending,onClick:()=>re.mutate(),children:`Trust peer`}),N?(0,B.jsx)(`small`,{className:`row-status-note`,children:`Trusted ${N.proposal.peerId} (${Yo(N.proposal.publicKeyFingerprint)}); peer prompt ${N.remoteNotification.status}.`}):null,re.error?(0,B.jsx)(`small`,{className:`row-status-note-danger`,children:re.error instanceof Error?re.error.message:`Pairing failed.`}):null,ie.error?(0,B.jsx)(`small`,{className:`row-status-note-danger`,children:ie.error instanceof Error?ie.error.message:`Pairing preview failed.`}):null]})})]}),(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:`Incoming pairing requests`}),(0,B.jsx)(uo,{children:`${ce.length} request${ce.length===1?``:`s`}`})]}),(0,B.jsx)(K,{children:ce.length?(0,B.jsxs)(`div`,{className:`detail-stack`,children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Decision reason`}),(0,B.jsx)(Y,{value:F,onChange:e=>I(e.target.value)})]}),(0,B.jsx)(`div`,{className:`list-stack`,children:ce.map(e=>(0,B.jsxs)(`div`,{className:`info-row`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:e.peerId}),(0,B.jsx)(`small`,{children:`${e.status} - ${Yo(e.publicKeyFingerprint)}`}),e.pairingId?(0,B.jsx)(`small`,{children:`Pairing ${e.pairingId}`}):null]}),(0,B.jsxs)(`div`,{className:`row-actions`,children:[(0,B.jsx)(`button`,{className:`primary-button`,type:`button`,disabled:e.status!==`pending`||ae.isPending,onClick:()=>ae.mutate(e.requestId),children:`Approve`}),(0,B.jsx)(`button`,{className:`danger-button`,type:`button`,disabled:e.status!==`pending`||oe.isPending,onClick:()=>oe.mutate(e.requestId),children:`Decline`})]})]},e.requestId))}),ae.error||oe.error?(0,B.jsx)(`small`,{className:`row-status-note-danger`,children:(ae.error||oe.error)instanceof Error?(ae.error||oe.error)?.message:`Pairing decision failed.`}):null]}):(0,B.jsx)(`div`,{className:`empty-state`,children:`No incoming pairing requests.`})})]}),(0,B.jsxs)(`div`,{className:`two-column-grid`,children:[(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:`Trusted peers`}),(0,B.jsx)(uo,{children:`${se.length} peer${se.length===1?``:`s`}`})]}),(0,B.jsx)(K,{children:ee.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading peers...`}):se.length?(0,B.jsx)(`div`,{className:`list-stack selectable-list`,children:se.map(e=>(0,B.jsxs)(`button`,{className:e.peerId===le?.peerId?`selectable-row active`:`selectable-row`,type:`button`,onClick:()=>r(e.peerId),children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:e.peerId}),(0,B.jsx)(`small`,{children:Yo(e.publicKeyFingerprint)})]}),Xo(e)]},e.peerId))}):(0,B.jsx)(`div`,{className:`empty-state`,children:`No A2A peer keys cached.`})})]}),(0,B.jsxs)(`div`,{className:`sticky-detail`,children:[(0,B.jsxs)(U,{variant:`muted`,children:[(0,B.jsx)(W,{children:(0,B.jsx)(G,{children:`Peer detail`})}),(0,B.jsx)(K,{children:le?(0,B.jsxs)(`div`,{className:`detail-stack`,children:[(0,B.jsxs)(`div`,{className:`key-value-grid`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Peer`}),(0,B.jsx)(`strong`,{children:le.peerId})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Status`}),(0,B.jsx)(`strong`,{children:le.status})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Trusted`}),(0,B.jsx)(`strong`,{children:Qa(le.trustedAt)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Last seen`}),(0,B.jsx)(`strong`,{children:Za(le.lastSeenAt)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Agent Card`}),(0,B.jsx)(`strong`,{children:le.agentCardUrl})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Delivery URL`}),(0,B.jsx)(`strong`,{children:le.deliveryUrl})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Fingerprint`}),(0,B.jsx)(`strong`,{children:le.publicKeyFingerprint})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Mismatch`}),(0,B.jsx)(`strong`,{children:le.lastMismatchAt||`none`})]})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Revocation reason`}),(0,B.jsx)(Y,{value:i,onChange:e=>a(e.target.value)})]}),(0,B.jsx)(`button`,{className:`danger-button`,type:`button`,disabled:le.status===`revoked`||L.isPending,onClick:()=>L.mutate(le.peerId),children:`Revoke`}),(0,B.jsx)(`button`,{className:`danger-button`,type:`button`,disabled:ne.isPending,onClick:()=>ne.mutate(le.peerId),children:`Delete`}),(0,B.jsx)(`button`,{className:`primary-button`,type:`button`,onClick:()=>ue(le),children:`Use in override`}),L.error?(0,B.jsx)(`small`,{className:`row-status-note-danger`,children:L.error instanceof Error?L.error.message:`Revocation failed.`}):null,ne.error?(0,B.jsx)(`small`,{className:`row-status-note-danger`,children:ne.error instanceof Error?ne.error.message:`Delete failed.`}):null]}):(0,B.jsx)(`div`,{className:`empty-state`,children:`Select a peer.`})})]}),(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{children:(0,B.jsx)(G,{children:`Operator override`})}),(0,B.jsx)(K,{children:(0,B.jsxs)(`div`,{className:`detail-stack`,children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Peer`}),(0,B.jsx)(Y,{value:s,onChange:e=>c(e.target.value)})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Agent Card`}),(0,B.jsx)(Y,{value:l,onChange:e=>u(e.target.value)})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Delivery URL`}),(0,B.jsx)(Y,{value:d,onChange:e=>f(e.target.value)})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Fingerprint`}),(0,B.jsx)(Y,{value:p,onChange:e=>m(e.target.value)})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Public JWK`}),(0,B.jsx)(Jo,{rows:5,value:h,onChange:e=>_(e.target.value)})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Reason`}),(0,B.jsx)(Y,{value:v,onChange:e=>b(e.target.value)})]}),(0,B.jsx)(`button`,{className:`primary-button`,type:`button`,disabled:!s.trim()||te.isPending,onClick:()=>te.mutate(),children:`Trust`}),te.error?(0,B.jsx)(`small`,{className:`row-status-note-danger`,children:te.error instanceof Error?te.error.message:`Trust update failed.`}):null]})})]})]})]})]})}function Qo(e){return String(e||``).trim().toLowerCase()}function X(e,t){return Qo(e).localeCompare(Qo(t))}function $o(e,t){return(e??0)-(t??0)}function es(e,t){return Number(e)-Number(t)}function ts(e,t){let n=Date.parse(String(e||``)),r=Date.parse(String(t||``));return(Number.isNaN(n)?0:n)-(Number.isNaN(r)?0:r)}function ns(e){let t=e.best_skills[0];return t?`${t.skill_name} (${t.score}/100)`:`No observed skill runs`}var rs={agent:(e,t)=>X(e.display_name,t.display_name)||X(e.agent_id,t.agent_id),score:(e,t)=>$o(e.avg_score,t.avg_score)||X(e.display_name,t.display_name),runs:(e,t)=>$o(e.total_executions,t.total_executions)||X(e.display_name,t.display_name),quality:(e,t)=>$o(e.avg_quality_score,t.avg_quality_score)||X(e.display_name,t.display_name),reliability:(e,t)=>$o(e.avg_reliability_score,t.avg_reliability_score)||X(e.display_name,t.display_name),timing:(e,t)=>$o(e.avg_timing_score,t.avg_timing_score)||X(e.display_name,t.display_name),anomalies:(e,t)=>$o(e.weekly_anomalies_flagged,t.weekly_anomalies_flagged)||X(e.display_name,t.display_name),skill:(e,t)=>X(ns(e),ns(t))||X(e.display_name,t.display_name),recent:(e,t)=>X(e.last_observed_at||``,t.last_observed_at||``)||X(e.display_name,t.display_name)},is={score:`desc`,runs:`desc`,quality:`desc`,reliability:`desc`,timing:`desc`,anomalies:`desc`,recent:`desc`};function as(){let e=Gn(),t=y({queryKey:[`agent-scoreboard`,e.token],queryFn:()=>Mn(e.token)}),n=t.data?.agents||[],r=t.data?.observed_skill_count??0,i=[...n].sort((e,t)=>t.avg_score-e.avg_score)[0],{sortedRows:a,sortState:o,toggleSort:s}=Ba(n,{initialSort:{key:`score`,direction:`desc`},sorters:rs,defaultDirections:is});return(0,B.jsxs)(`div`,{className:`page-stack`,children:[(0,B.jsx)(Ha,{description:`Review agent skill track records, top strengths, and generated CV paths.`}),(0,B.jsxs)(`div`,{className:`metric-grid`,children:[(0,B.jsx)(Ua,{label:`Observed agents`,value:String(n.length),detail:`with recorded skill runs`,loading:!t.data}),(0,B.jsx)(Ua,{label:`Observed skills`,value:String(r),detail:`across agent runs`,loading:!t.data}),(0,B.jsx)(Ua,{label:`Best average score`,value:i?`${i.avg_score}/100`:`0/100`,detail:i?.display_name||`No runs yet`,loading:!t.data}),(0,B.jsx)(Ua,{label:`Total runs`,value:String(n.reduce((e,t)=>e+t.total_executions,0)),detail:`skill executions`,loading:!t.data})]}),(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:`Agent scoreboard`}),(0,B.jsx)(uo,{children:`${a.length} agent${a.length===1?``:`s`} visible`})]}),(0,B.jsx)(K,{children:t.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading agent scoreboard...`}):a.length===0?(0,B.jsx)(`div`,{className:`empty-state`,children:`No agent skill runs recorded yet.`}):(0,B.jsx)(`div`,{className:`table-shell`,children:(0,B.jsxs)(`table`,{children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(Va,{label:`Agent`,sortKey:`agent`,sortState:o,onToggle:s}),(0,B.jsx)(Va,{label:`Score`,sortKey:`score`,sortState:o,onToggle:s}),(0,B.jsx)(Va,{label:`Runs`,sortKey:`runs`,sortState:o,onToggle:s}),(0,B.jsx)(Va,{label:`Quality`,sortKey:`quality`,sortState:o,onToggle:s}),(0,B.jsx)(Va,{label:`Reliability`,sortKey:`reliability`,sortState:o,onToggle:s}),(0,B.jsx)(Va,{label:`Timing`,sortKey:`timing`,sortState:o,onToggle:s}),(0,B.jsx)(Va,{label:`Best at`,sortKey:`skill`,sortState:o,onToggle:s}),(0,B.jsx)(Va,{label:`Anomalies`,sortKey:`anomalies`,sortState:o,onToggle:s}),(0,B.jsx)(Va,{label:`Recent`,sortKey:`recent`,sortState:o,onToggle:s}),(0,B.jsx)(`th`,{children:`CV`})]})}),(0,B.jsx)(`tbody`,{children:a.map(e=>(0,B.jsxs)(`tr`,{children:[(0,B.jsxs)(`td`,{children:[(0,B.jsx)(`strong`,{children:e.display_name}),(0,B.jsx)(`div`,{className:`supporting-text`,children:e.agent_id})]}),(0,B.jsxs)(`td`,{children:[e.avg_score,`/100`]}),(0,B.jsx)(`td`,{children:e.total_executions}),(0,B.jsxs)(`td`,{children:[e.avg_quality_score,`/100`]}),(0,B.jsxs)(`td`,{children:[e.avg_reliability_score,`/100`]}),(0,B.jsxs)(`td`,{children:[e.avg_timing_score,`/100`]}),(0,B.jsxs)(`td`,{children:[(0,B.jsx)(`strong`,{children:ns(e)}),e.best_skills[0]?(0,B.jsxs)(`div`,{className:`supporting-text`,children:[`Q `,e.best_skills[0].quality_score,` · R`,` `,e.best_skills[0].reliability_score,` · T`,` `,e.best_skills[0].timing_score]}):null]}),(0,B.jsxs)(`td`,{children:[e.weekly_anomalies_flagged,(0,B.jsxs)(`div`,{className:`supporting-text`,children:[e.weekly_anomalies_confirmed_normal,` confirmed normal`]})]}),(0,B.jsx)(`td`,{children:e.last_observed_at?Za(e.last_observed_at):`No recent runs`}),(0,B.jsx)(`td`,{children:(0,B.jsx)(`a`,{href:`/admin/agents?agent=${encodeURIComponent(e.agent_id)}&file=CV.md`,children:`CV.md`})})]},e.agent_id))})]})})})]})]})}var os={button:`_button_kxq2k_1`,default:`_default_kxq2k_50`,ghost:`_ghost_kxq2k_60`,outline:`_outline_kxq2k_70`,danger:`_danger_kxq2k_80`,sizeDefault:`_sizeDefault_kxq2k_92`,sizeSm:`_sizeSm_kxq2k_97`,sizeIcon:`_sizeIcon_kxq2k_103`},ss={default:os.default,ghost:os.ghost,outline:os.outline,danger:os.danger},cs={default:os.sizeDefault,sm:os.sizeSm,icon:os.sizeIcon},Z=(0,R.forwardRef)(function({variant:e=`default`,size:t=`default`,loading:n=!1,disabled:r,className:i,onClick:a,type:o,render:s,children:c,...l},u){let d=r||n,f=e=>{if(d){e.preventDefault();return}a?.(e)},p=V(os.button,ss[e],cs[t],i),m={"data-disabled":d?``:void 0,"data-loading":n?``:void 0};if(s&&(0,R.isValidElement)(s)){let e=s.props;return(0,R.cloneElement)(s,{...l,ref:u,className:V(p,e.className),"aria-disabled":d||void 0,"aria-busy":n||void 0,onClick:f,children:c??e.children,...m})}return(0,B.jsx)(`button`,{ref:u,type:o??`button`,className:p,disabled:r,"aria-disabled":n||void 0,"aria-busy":n||void 0,onClick:f,...m,...l,children:c})}),ls={wrapper:`_wrapper_1gpbx_1`,select:`_select_1gpbx_12`,chevron:`_chevron_1gpbx_55`,option:`_option_1gpbx_66`,optgroup:`_optgroup_1gpbx_71`,sizeDefault:`_sizeDefault_1gpbx_78`,sizeSm:`_sizeSm_1gpbx_83`},us={default:ls.sizeDefault,sm:ls.sizeSm};function ds({className:e,size:t=`default`,children:n,...r}){let i=Do(r);return(0,B.jsxs)(`div`,{className:ls.wrapper,"data-slot":`native-select-wrapper`,children:[(0,B.jsx)(`select`,{...i,"data-slot":`native-select`,"data-size":t,className:V(ls.select,us[t],e),children:n}),(0,B.jsx)(er,{"aria-hidden":`true`,className:ls.chevron,"data-slot":`native-select-icon`})]})}function Q({className:e,...t}){return(0,B.jsx)(`option`,{...t,"data-slot":`native-select-option`,className:V(ls.option,e)})}function fs({className:e,...t}){return(0,B.jsx)(`optgroup`,{...t,"data-slot":`native-select-optgroup`,className:V(ls.optgroup,e)})}var ps={viewport:`_viewport_ct6pf_1`,toast:`_toast_ct6pf_18`,toastSlideIn:`_toastSlideIn_ct6pf_1`,exiting:`_exiting_ct6pf_34`,toastSlideOut:`_toastSlideOut_ct6pf_1`,body:`_body_ct6pf_38`,title:`_title_ct6pf_45`,description:`_description_ct6pf_52`,success:`_success_ct6pf_59`,error:`_error_ct6pf_68`,info:`_info_ct6pf_77`,actions:`_actions_ct6pf_86`,actionButton:`_actionButton_ct6pf_93`,closeButton:`_closeButton_ct6pf_108`},ms=(0,R.createContext)(null);function hs(){let e=(0,R.useContext)(ms);if(!e)throw Error(`useToast must be used within <ToastProvider>.`);return e}var gs=0;function _s(e){return Math.max(0,e)}function vs(e){let t=e.limit??3,[n,r]=(0,R.useState)([]),i=(0,R.useRef)(null),[a,o]=(0,R.useState)(!1);(0,R.useEffect)(()=>{function e(){o(!0)}function t(){o(!1)}return window.addEventListener(`blur`,e),window.addEventListener(`focus`,t),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`focus`,t)}},[]);let s=(0,R.useCallback)(e=>{r(t=>t.filter(t=>t.id!==e))},[]),c=(0,R.useCallback)(e=>{r(t=>t.map(t=>t.id===e?{...t,exiting:!0}:t))},[]),l=(0,R.useCallback)(e=>{let n=`toast-${++gs}`,i={id:n,title:e.title,description:e.description,type:e.type??`default`,duration:_s(e.duration??5e3),action:e.action,pinned:e.pinned??!1,exiting:!1};return r(e=>{let n=[...e,i];if(n.length>t){let e=n.length-t;return n.map(t=>e>0&&!t.exiting&&!t.pinned?(--e,{...t,exiting:!0}):t)}return n}),n},[t]),u=(0,R.useCallback)((e,t)=>{r(n=>n.map(n=>{if(n.id!==e)return n;let r={...n,...t};return t.duration!==void 0&&(r.duration=_s(t.duration)),r}))},[]),d=(0,R.useCallback)((e,t)=>l({title:e,description:t,type:`success`}),[l]),f=(0,R.useCallback)((e,t)=>l({title:e,description:t,type:`error`,duration:0}),[l]),p=(0,R.useCallback)((e,t)=>l({title:e,description:t,type:`info`}),[l]);(0,R.useEffect)(()=>{function e(e){if(e.key===`F8`){i.current?.focus({preventScroll:!0});return}e.key===`Escape`&&(!i.current||!i.current.contains(document.activeElement)||r(e=>{let t;for(let n=e.length-1;n>=0;n--)if(!e[n].exiting){t=e[n];break}return t?e.map(e=>e.id===t.id?{...e,exiting:!0}:e):e}))}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let m=(0,R.useMemo)(()=>({add:l,success:d,error:f,info:p,update:u,dismiss:c}),[l,d,f,p,u,c]);return(0,B.jsxs)(ms.Provider,{value:m,children:[e.children,typeof document<`u`&&(0,Vr.createPortal)((0,B.jsx)(ys,{ref:i,toasts:n,windowBlurred:a,onDismiss:c,onRemove:s}),document.body)]})}var ys=(0,R.forwardRef)(function(e,t){return(0,B.jsx)(`div`,{ref:t,className:ps.viewport,tabIndex:-1,children:e.toasts.map(t=>(0,B.jsx)(bs,{toast:t,windowBlurred:e.windowBlurred,onDismiss:e.onDismiss,onRemove:e.onRemove},t.id))})});function bs(e){let{toast:t,windowBlurred:n,onDismiss:r,onRemove:i}=e,a=(0,R.useRef)(null),[o,s]=(0,R.useState)(!1),[c,l]=(0,R.useState)(!1),u=(0,R.useRef)(t.duration),d=(0,R.useRef)(0),f=o||c||n;(0,R.useEffect)(()=>{if(t.duration<=0||t.exiting||f)return;d.current=Date.now();let e=setTimeout(()=>r(t.id),u.current);return()=>{clearTimeout(e),u.current-=Date.now()-d.current,u.current<0&&(u.current=0)}},[t.id,t.duration,t.exiting,f,r]);let p=(0,R.useCallback)(()=>i(t.id),[i,t.id]);return Hr(a,t.exiting,p),(0,B.jsxs)(`div`,{ref:a,className:V(ps.toast,t.type===`success`&&ps.success,t.type===`error`&&ps.error,t.type===`info`&&ps.info,t.exiting&&ps.exiting),"data-type":t.type,role:t.type===`error`?`alert`:`status`,"aria-live":t.type===`error`?`assertive`:`polite`,"aria-atomic":`true`,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),onFocus:()=>l(!0),onBlur:()=>l(!1),children:[(0,B.jsxs)(`div`,{className:ps.body,children:[(0,B.jsx)(`p`,{className:ps.title,children:t.title}),t.description?(0,B.jsx)(`p`,{className:ps.description,children:t.description}):null]}),(0,B.jsxs)(`div`,{className:ps.actions,children:[t.action?(0,B.jsx)(`button`,{type:`button`,className:ps.actionButton,onClick:()=>{try{t.action?.onClick()}catch(e){console.error(`Toast action callback failed:`,e)}r(t.id)},children:t.action.label}):null,(0,B.jsx)(`button`,{type:`button`,className:ps.closeButton,"aria-label":`Dismiss`,onClick:()=>r(t.id),children:`×`})]})]})}function xs(e){return e&&(e.markdownFiles.find(e=>e.exists)?.name||e.markdownFiles[0]?.name)||null}function Ss(e,t){return!e||!t?null:`${e}:${t}`}function Cs(e){return e.displayName||e.name}function ws(e){return Array.isArray(e)?e.length>0?e.join(`, `):`none`:e||`none`}function Ts(e){let t=[];for(let n of e.added)t.push(`+ ${n.id}`);for(let n of e.removed)t.push(`- ${n.id}`);for(let n of e.changed)for(let e of n.fields)t.push(`~ ${n.agentId}.${e.field}: ${ws(e.before)} -> ${ws(e.after)}`);return t.length>0?t.join(`
|
|
3
3
|
`):`No field changes recorded.`}var Es=10;function Ds(){let e=Gn(),t=o(),n=hs(),r=new URLSearchParams(window.location.search),[i,a]=(0,R.useState)(r.get(`agent`)),[s,c]=(0,R.useState)(r.get(`file`)),[l,u]=(0,R.useState)(null),[d,f]=(0,R.useState)(null),[p,m]=(0,R.useState)(Es),[h,_]=(0,R.useState)(Es),[v,b]=(0,R.useState)(``),x=(0,R.useRef)(null),S=(0,R.useRef)(``),C=y({queryKey:[`admin-agents`,e.token],queryFn:()=>pt(e.token)}),w=C.data?.find(e=>e.id===i)||C.data?.[0]||null;(0,R.useEffect)(()=>{w&&w.id!==i&&a(w.id)},[w,i]),(0,R.useEffect)(()=>{if(!C.data)return;if(!w){s!==null&&(c(null),u(null));return}let e=w.markdownFiles.find(e=>e.name===s)?.name||xs(w);e!==s&&(c(e),u(null),m(Es))},[C.data,w,s]);let T=w?.markdownFiles.find(e=>e.name===s)||null,E=Ss(w?.id,s),D=y({queryKey:[`admin-agent-markdown`,e.token,w?.id||``,s||``],queryFn:()=>yt(e.token,{agentId:w?.id||``,fileName:s||``}),enabled:!!(w?.id&&s),refetchOnWindowFocus:!1}),O=D.data?.file.name===s?D.data.file:T,k=w?.markdownFiles.filter(e=>!e.readOnly),A=w?.markdownFiles.filter(e=>e.readOnly),j=!!O?.readOnly,M=O?Cs(O):s,N=y({queryKey:[`admin-agent-markdown-revision`,e.token,w?.id||``,s||``,l||``],queryFn:()=>xt(e.token,{agentId:w?.id||``,fileName:s||``,revisionId:l||``}),enabled:!!(w?.id&&s&&l),refetchOnWindowFocus:!1}),P=y({queryKey:[`admin-team-structure`,e.token],queryFn:()=>gt(e.token),refetchOnWindowFocus:!1}),F=y({queryKey:[`admin-team-structure-revision`,e.token,d||0],queryFn:()=>_t(e.token,d||0),enabled:!!d,refetchOnWindowFocus:!1});(0,R.useEffect)(()=>{if(!E){x.current=null,S.current=``,b(``);return}if(!D.data)return;let e=D.data.file.content;(x.current!==E||v===S.current)&&(x.current=E,S.current=e,b(e))},[v,D.data,E]);let I=g({mutationFn:async()=>{if(!w||!s)throw Error(`Select an agent and markdown file first.`);return bt(e.token,{agentId:w.id,fileName:s,content:v})},onSuccess:r=>{let i=Ss(r.agent.id,r.file.name);t.setQueryData([`admin-agent-markdown`,e.token,r.agent.id,r.file.name],r),t.invalidateQueries({queryKey:[`admin-agents`,e.token]}),x.current=i,S.current=r.file.content,b(r.file.content),n.success(`Saved ${r.file.name} for ${r.agent.name||r.agent.id}.`)},onError:e=>{n.error(`Save failed`,H(e))}}),ee=g({mutationFn:async()=>{if(!w||!s||!l)throw Error(`Select a version to restore first.`);return St(e.token,{agentId:w.id,fileName:s,revisionId:l})},onSuccess:r=>{let i=Ss(r.agent.id,r.file.name);t.setQueryData([`admin-agent-markdown`,e.token,r.agent.id,r.file.name],r),t.invalidateQueries({queryKey:[`admin-agents`,e.token]}),x.current=i,S.current=r.file.content,b(r.file.content),n.success(`Restored ${r.file.name} from version history.`)},onError:e=>{n.error(`Restore failed`,H(e))}}),L=g({mutationFn:async()=>{if(!d)throw Error(`Select a team revision to restore first.`);return vt(e.token,d)},onSuccess:r=>{t.setQueryData([`admin-team-structure`,e.token],r),t.invalidateQueries({queryKey:[`admin-agents`,e.token]}),f(null),n.success(`Restored team structure from revision history.`)},onError:e=>{n.error(`Team restore failed`,H(e))}}),te=D.data?v!==D.data.file.content:!1,ne=D.data?.file.revisions||[],re=ne.slice(0,p),ie=Math.max(0,ne.length-p),ae=P.data?.revisions||[],oe=ae.slice(0,h),se=Math.max(0,ae.length-h);return(0,B.jsx)(`div`,{className:`page-stack`,children:(0,B.jsx)(U,{variant:`muted`,children:C.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading agents...`}):C.data?.length?w?s?(0,B.jsxs)(`div`,{className:`detail-stack`,children:[(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Agent`}),(0,B.jsx)(ds,{value:w.id,onChange:e=>{a(e.target.value),u(null)},children:C.data.map(e=>(0,B.jsx)(Q,{value:e.id,children:e.name||e.id},e.id))})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Markdown file`}),(0,B.jsxs)(ds,{value:s,onChange:e=>{c(e.target.value),u(null),m(Es)},children:[k?.map(e=>(0,B.jsx)(Q,{value:e.name,children:Cs(e)},e.name)),A?.length?(0,B.jsx)(fs,{label:`Shared memory`,children:A.map(e=>(0,B.jsx)(Q,{value:e.name,children:Cs(e)},e.name))}):null]})]})]}),T?(0,B.jsx)(`div`,{className:`agent-file-meta`,children:(0,B.jsx)(`p`,{className:`supporting-text agent-file-meta-line`,children:O?.exists?O.readOnly?`${O.cloudPath||O.path} · read-only cloud memory cache`:O.updatedAt?`Last updated ${Za(O.updatedAt)} · ${Qa(O.updatedAt)} · ${O.path}`:O.path:O?.readOnly?`Shared memory has not synced to this agent yet`:`File not created yet`})}):null,D.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading markdown file...`}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`label`,{className:`field textarea-field`,children:[(0,B.jsx)(`span`,{className:`agent-file-editor-title`,children:M}),(0,B.jsx)(Jo,{className:`code-editor`,rows:28,readOnly:j,value:v,onChange:e=>b(e.target.value)})]}),(0,B.jsxs)(`div`,{className:`button-row`,children:[(0,B.jsx)(Z,{type:`button`,loading:I.isPending,disabled:j||I.isPending||!D.data||!te,onClick:()=>I.mutate(),children:I.isPending?`Saving...`:`Save Markdown`}),(0,B.jsx)(Z,{variant:`ghost`,type:`button`,disabled:!D.data||I.isPending||!te||j,onClick:()=>{let e=D.data?.file.content||``;E&&(x.current=E),S.current=e,b(e)},children:`Reset to Disk`}),(0,B.jsx)(`p`,{className:`supporting-text`,children:j?O?.exists?`Read-only cloud memory cache.`:`Waiting for cloud memory sync.`:te?`Unsaved changes.`:T?.exists?`Disk copy loaded.`:`Saving will create this file in the agent workspace.`})]}),(0,B.jsxs)(`div`,{className:`two-column-grid`,children:[(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:`Versions`}),(0,B.jsx)(uo,{children:`${D.data?.file.revisions.length||0} saved revision${D.data?.file.revisions.length===1?``:`s`}`})]}),(0,B.jsx)(K,{children:D.data?.file.revisions.length?(0,B.jsxs)(`div`,{className:`detail-stack`,children:[(0,B.jsx)(`div`,{className:`list-stack selectable-list`,children:re.map(e=>(0,B.jsx)(`button`,{className:e.id===l?`selectable-row active`:`selectable-row`,type:`button`,onClick:()=>u(e.id),children:(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:Qa(e.createdAt)}),(0,B.jsxs)(`small`,{children:[Za(e.createdAt),` ·`,` `,e.source,` · `,e.sizeBytes,` `,`bytes`]})]})},e.id))}),ie>0?(0,B.jsx)(`div`,{className:`button-row`,children:(0,B.jsxs)(Z,{variant:`outline`,size:`sm`,type:`button`,onClick:()=>m(e=>Math.min(e+Es,ne.length)),children:[`Show`,` `,Math.min(Es,ie),` `,`more`]})}):null]}):(0,B.jsx)(`div`,{className:`empty-state`,children:j?`Shared memory files are read-only and do not have local revisions.`:`Revisions appear here after the file changes.`})})]}),(0,B.jsxs)(U,{variant:`muted`,children:[(0,B.jsx)(W,{children:(0,B.jsx)(G,{children:`Version Preview`})}),(0,B.jsx)(K,{children:l?N.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading version...`}):N.data?(0,B.jsxs)(`div`,{className:`detail-stack`,children:[(0,B.jsxs)(`div`,{className:`summary-block`,children:[(0,B.jsx)(`span`,{children:Qa(N.data.revision.createdAt)}),(0,B.jsxs)(`p`,{children:[N.data.revision.sha256.slice(0,16),` `,`· `,N.data.revision.source]})]}),(0,B.jsxs)(`label`,{className:`field textarea-field`,children:[(0,B.jsx)(`span`,{children:`Saved content`}),(0,B.jsx)(Jo,{className:`code-editor`,rows:14,readOnly:!0,value:N.data.revision.content})]}),(0,B.jsxs)(`div`,{className:`button-row`,children:[(0,B.jsx)(Z,{type:`button`,loading:ee.isPending,disabled:ee.isPending,onClick:()=>ee.mutate(),children:ee.isPending?`Restoring...`:`Restore Version`}),(0,B.jsx)(Z,{variant:`ghost`,type:`button`,onClick:()=>b(N.data?.revision.content||``),children:`Copy to Editor`})]})]}):(0,B.jsx)(`div`,{className:`empty-state`,children:`Version details are unavailable.`}):(0,B.jsx)(`div`,{className:`empty-state`,children:`Select a saved version to preview or restore it.`})})]})]}),(0,B.jsxs)(`div`,{className:`two-column-grid`,children:[(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:`Team Revisions`}),(0,B.jsx)(uo,{children:`${P.data?.revisions.length||0} saved revision${P.data?.revisions.length===1?``:`s`}`})]}),(0,B.jsx)(K,{children:P.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading team revisions...`}):P.data?.revisions.length?(0,B.jsxs)(`div`,{className:`detail-stack`,children:[(0,B.jsx)(`div`,{className:`list-stack selectable-list`,children:oe.map(e=>(0,B.jsx)(`button`,{className:e.id===d?`selectable-row active`:`selectable-row`,type:`button`,onClick:()=>f(e.id),children:(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`strong`,{children:[`#`,e.id,` ·`,` `,Qa(e.createdAt)]}),(0,B.jsxs)(`small`,{children:[Za(e.createdAt),` ·`,` `,e.changeCount,` change`,e.changeCount===1?``:`s`,` ·`,` `,e.route]})]})},e.id))}),se>0?(0,B.jsx)(`div`,{className:`button-row`,children:(0,B.jsxs)(Z,{variant:`outline`,size:`sm`,type:`button`,onClick:()=>_(e=>Math.min(e+Es,ae.length)),children:[`Show`,` `,Math.min(Es,se),` `,`more`]})}):null]}):(0,B.jsx)(`div`,{className:`empty-state`,children:`Team revisions appear here after org-chart changes.`})})]}),(0,B.jsxs)(U,{variant:`muted`,children:[(0,B.jsx)(W,{children:(0,B.jsx)(G,{children:`Team Diff`})}),(0,B.jsx)(K,{children:d?F.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading team revision...`}):F.data?(0,B.jsxs)(`div`,{className:`detail-stack`,children:[(0,B.jsxs)(`div`,{className:`summary-block`,children:[(0,B.jsxs)(`span`,{children:[`Revision #`,F.data.revision.id]}),(0,B.jsxs)(`p`,{children:[F.data.revision.md5.slice(0,16),` `,`· `,F.data.revision.source]})]}),(0,B.jsxs)(`label`,{className:`field textarea-field`,children:[(0,B.jsx)(`span`,{children:`Diff`}),(0,B.jsx)(Jo,{className:`code-editor`,rows:10,readOnly:!0,value:Ts(F.data.revision.diff)})]}),(0,B.jsx)(`div`,{className:`button-row`,children:(0,B.jsx)(Z,{type:`button`,loading:L.isPending,disabled:L.isPending,onClick:()=>L.mutate(),children:L.isPending?`Restoring...`:`Restore Team`})})]}):(0,B.jsx)(`div`,{className:`empty-state`,children:`Team revision details are unavailable.`}):(0,B.jsx)(`div`,{className:`empty-state`,children:`Select a team revision to inspect its diff.`})})]})]})]})]}):(0,B.jsx)(`div`,{className:`empty-state`,children:`This agent does not expose editable markdown files.`}):(0,B.jsx)(`div`,{className:`empty-state`,children:`Select an agent to edit its files.`}):(0,B.jsx)(`div`,{className:`empty-state`,children:`No agents are registered yet.`})})})}function Os(e){console.error(`Navigation failed:`,e)}var ks=[{key:`all`,label:`All`},{key:`active`,label:`Active`},{key:`idle`,label:`Idle`},{key:`stopped`,label:`Stopped`}];function As(e){return e.model||`Inherited default`}function js(e){return e.sessionCount?`${e.sessionCount} total · ${e.activeSessions} active · ${e.idleSessions} idle · ${e.stoppedSessions} stopped`:`No persisted sessions`}function Ms(e){return`Chatbot ${e.chatbotId?.trim()||`none`} · RAG ${e.enableRag==null?`inherit`:e.enableRag?`on`:`off`}`}function Ns(e){return e.channelName&&e.channelName!==e.channelId?`${e.channelName} · ${e.channelId}`:e.channelId||`unknown`}function Ps(e){return`is-${e}`}function Fs(e){return(0,B.jsxs)(`span`,{className:`agents-status-badge ${Ps(e.status)}`,children:[(0,B.jsx)(`span`,{className:`agents-status-badge-dot`,"aria-hidden":`true`}),e.status]})}function Is(e){let t=e.toLowerCase();return e.startsWith(`$`)?`is-command`:t.includes(`error`)||t.includes(`failed`)?`is-error`:t.includes(`idle`)||t.includes(`waiting`)?`is-warning`:t.includes(`healthy`)||t.includes(`success`)?`is-success`:``}function Ls(e,t){let n=new Map;return t.map(t=>{let r=(n.get(t)??0)+1;return n.set(t,r),{key:`${e}-${r}-${t}`,line:t}})}function Rs(e){let t=(0,R.useMemo)(()=>Ls(e.sessionId,e.output),[e.sessionId,e.output]);return(0,B.jsxs)(`div`,{className:`agents-terminal`,children:[(0,B.jsxs)(`div`,{className:`agents-terminal-top`,children:[(0,B.jsx)(`span`,{className:`agents-terminal-dot is-red`}),(0,B.jsx)(`span`,{className:`agents-terminal-dot is-yellow`}),(0,B.jsx)(`span`,{className:`agents-terminal-dot is-green`}),(0,B.jsx)(`span`,{className:`agents-terminal-label`,children:e.title})]}),(0,B.jsx)(`div`,{className:`agents-session-output`,children:t.map(({key:e,line:t})=>(0,B.jsx)(`span`,{className:`agents-terminal-line ${Is(t)}`,children:t},e))})]})}var zs=(0,R.memo)(Rs,(e,t)=>e.sessionId===t.sessionId&&e.title===t.title&&e.output.length===t.output.length&&e.output.every((e,n)=>e===t.output[n]));function Bs(){let e=Gn(),t=j(),n=Ca(e.token),[r,i]=(0,R.useState)(`all`),[a,o]=(0,R.useState)(new Set),s=y({queryKey:[`agents-overview`,e.token],queryFn:()=>dt(e.token),refetchInterval:15e3}),c=s.data,l=(0,R.useMemo)(()=>{let e=c?.sessions||[];return r===`all`?e:e.filter(e=>e.status===r)},[r,c?.sessions]);function u(e){o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}if(s.isLoading&&!c)return(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading agents...`});if(s.isError&&!c)return(0,B.jsx)(`div`,{className:`empty-state error`,children:`Agent overview unavailable.`});if(!c)return(0,B.jsx)(`div`,{className:`empty-state`,children:`Agent overview unavailable.`});let d=c.totals.sessions,f={all:d.all,active:d.active,idle:d.idle,stopped:d.stopped};return(0,B.jsxs)(`div`,{className:`page-stack agents-dashboard`,children:[(0,B.jsxs)(`header`,{className:`agents-page-header`,children:[(0,B.jsxs)(`div`,{className:`agents-title-row`,children:[(0,B.jsx)(`h1`,{children:`Agents`}),(0,B.jsxs)(`button`,{className:s.isFetching?`agents-refresh-chip is-spinning`:`agents-refresh-chip`,type:`button`,onClick:()=>void s.refetch(),children:[(0,B.jsx)(`span`,{className:`agents-refresh-spinner`,"aria-hidden":`true`}),(0,B.jsx)(`span`,{children:c?`Last refresh ${Qa(c.generatedAt)}`:`Loading agents`})]}),c?(0,B.jsxs)(`span`,{className:`agents-uptime-chip`,children:[`uptime `,$a(c.uptime)]}):null]}),(0,B.jsx)(ka,{items:n})]}),(0,B.jsxs)(`div`,{className:`agents-stats-row`,children:[(0,B.jsxs)(`div`,{className:`agents-stat-card`,children:[(0,B.jsx)(`span`,{className:`agents-metric-accent is-green`,children:`A`}),(0,B.jsx)(`span`,{children:`Agents`}),(0,B.jsx)(`strong`,{children:c.totals.agents.all}),(0,B.jsxs)(`small`,{children:[c.totals.agents.active,` active`]})]}),(0,B.jsxs)(`div`,{className:`agents-stat-card`,children:[(0,B.jsx)(`span`,{className:`agents-metric-accent is-blue`,children:`S`}),(0,B.jsx)(`span`,{children:`Sessions Live`}),(0,B.jsx)(`strong`,{children:d.running}),(0,B.jsxs)(`small`,{children:[d.all,` total`]})]}),(0,B.jsxs)(`div`,{className:`agents-stat-card`,children:[(0,B.jsx)(`span`,{className:`agents-metric-accent is-gold`,children:`T`}),(0,B.jsx)(`span`,{children:`Tokens Used`}),(0,B.jsx)(`strong`,{children:Ka(d.totalTokens)}),(0,B.jsx)(`small`,{children:Ja({inputTokens:d.totalInputTokens,outputTokens:d.totalOutputTokens})})]}),(0,B.jsxs)(`div`,{className:`agents-stat-card`,children:[(0,B.jsx)(`span`,{className:`agents-metric-accent is-slate`,children:`$`}),(0,B.jsx)(`span`,{children:`Total Cost`}),(0,B.jsx)(`strong`,{children:Xa(d.totalCostUsd)}),(0,B.jsxs)(`small`,{children:[`Ralph `,c.ralph?.enabled?`enabled`:`disabled`]})]})]}),(0,B.jsxs)(`section`,{className:`agents-dashboard-panel`,children:[(0,B.jsx)(`div`,{className:`agents-section-head`,children:(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h2`,{children:`Registered Agents`}),(0,B.jsxs)(`p`,{children:[c.agents.length.toString(),` workspace`,c.agents.length===1?``:`s`,` aggregated across every bound session.`]})]})}),(0,B.jsx)(`div`,{children:c.agents.length?(0,B.jsx)(`div`,{className:`agents-overview-grid`,children:c.agents.map(e=>(0,B.jsxs)(`article`,{className:`agents-overview-card ${Ps(e.status)}`,children:[(0,B.jsxs)(`div`,{className:`agents-overview-card-header`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{children:e.name||e.id}),(0,B.jsx)(`p`,{children:js(e)}),e.recentSessionId?(0,B.jsx)(`div`,{className:`agents-tag-row`,children:(0,B.jsxs)(`span`,{className:`agents-tag`,children:[`Recent `,e.recentSessionId]})}):null]}),(0,B.jsx)(Fs,{status:e.status})]}),(0,B.jsxs)(`div`,{className:`agents-meta-grid`,children:[(0,B.jsxs)(`div`,{className:`agents-meta-block`,children:[(0,B.jsx)(`span`,{children:`Default Model`}),(0,B.jsx)(`strong`,{children:As(e)})]}),(0,B.jsxs)(`div`,{className:`agents-meta-block`,children:[(0,B.jsx)(`span`,{children:`Session Models`}),(0,B.jsx)(`strong`,{children:e.effectiveModels.length?e.effectiveModels.join(`, `):`none`})]}),(0,B.jsxs)(`div`,{className:`agents-meta-block`,children:[(0,B.jsx)(`span`,{children:`Workspace`}),(0,B.jsx)(`strong`,{children:e.workspacePath})]}),(0,B.jsxs)(`div`,{className:`agents-meta-block`,children:[(0,B.jsx)(`span`,{children:`Token I/O`}),(0,B.jsx)(`strong`,{children:Ja({inputTokens:e.inputTokens,outputTokens:e.outputTokens})})]}),(0,B.jsxs)(`div`,{className:`agents-meta-block`,children:[(0,B.jsx)(`span`,{children:`Cost`}),(0,B.jsx)(`strong`,{children:Xa(e.costUsd)})]}),(0,B.jsxs)(`div`,{className:`agents-meta-block`,children:[(0,B.jsx)(`span`,{children:`Chatbot / RAG`}),(0,B.jsx)(`strong`,{children:Ms(e)})]}),(0,B.jsxs)(`div`,{className:`agents-meta-block`,children:[(0,B.jsx)(`span`,{children:`Last Active`}),(0,B.jsx)(`strong`,{children:Qa(e.lastActive)})]}),(0,B.jsxs)(`div`,{className:`agents-meta-block`,children:[(0,B.jsx)(`span`,{children:`Messages / Tools`}),(0,B.jsxs)(`strong`,{children:[e.messageCount,` msgs / `,e.toolCalls,` calls`]})]})]})]},e.id))}):(0,B.jsx)(`div`,{className:`empty-state`,children:`No agents found.`})})]}),(0,B.jsxs)(`section`,{className:`agents-dashboard-panel`,children:[(0,B.jsx)(`div`,{className:`agents-section-head`,children:(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h2`,{children:`Sessions`}),(0,B.jsxs)(`p`,{children:[l.length,` visible of `,d.all,` persisted per-channel and per-client sessions.`]})]})}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`agents-filter-row`,role:`tablist`,"aria-label":`Session filters`,children:ks.map(e=>(0,B.jsxs)(`button`,{className:r===e.key?`agents-filter-pill is-active`:`agents-filter-pill`,type:`button`,role:`tab`,"aria-selected":r===e.key,onClick:()=>i(e.key),children:[e.label,(0,B.jsx)(`span`,{className:`agents-filter-count`,children:f[e.key]})]},e.key))}),l.length?(0,B.jsx)(`div`,{className:`agents-session-list`,children:l.map(e=>{let n=a.has(e.id),r=e.output.length?e.output:[`No recent activity captured for this session yet.`];return(0,B.jsxs)(`article`,{className:`agents-session-card ${Ps(e.status)}`,children:[(0,B.jsxs)(`div`,{className:`agents-overview-card-header`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{children:e.name}),(0,B.jsx)(`p`,{children:e.task}),e.fullAutoEnabled?(0,B.jsx)(`span`,{className:`agents-fullauto-badge`,children:`Full auto`}):null]}),(0,B.jsx)(Fs,{status:e.status})]}),(e.lastQuestion||e.lastAnswer)&&(0,B.jsxs)(`div`,{className:`agents-preview`,children:[e.lastQuestion?(0,B.jsxs)(`p`,{children:[(0,B.jsx)(`span`,{children:`Q`}),e.lastQuestion]}):null,e.lastAnswer?(0,B.jsxs)(`p`,{children:[(0,B.jsx)(`span`,{children:`A`}),e.lastAnswer]}):null]}),(0,B.jsxs)(`div`,{className:`agents-meta-grid`,children:[(0,B.jsxs)(`div`,{className:`agents-meta-block`,children:[(0,B.jsx)(`span`,{children:`Model`}),(0,B.jsx)(`strong`,{children:e.model})]}),(0,B.jsxs)(`div`,{className:`agents-meta-block`,children:[(0,B.jsx)(`span`,{children:`Agent`}),(0,B.jsx)(`strong`,{children:e.agentId})]}),(0,B.jsxs)(`div`,{className:`agents-meta-block`,children:[(0,B.jsx)(`span`,{children:`Session ID`}),(0,B.jsx)(`strong`,{children:e.sessionId})]}),(0,B.jsxs)(`div`,{className:`agents-meta-block`,children:[(0,B.jsx)(`span`,{children:`Channel`}),(0,B.jsx)(`strong`,{children:Ns(e)})]}),(0,B.jsxs)(`div`,{className:`agents-meta-block`,children:[(0,B.jsx)(`span`,{children:`Runtime`}),(0,B.jsxs)(`strong`,{children:[e.runtimeMinutes,`m`]})]}),(0,B.jsxs)(`div`,{className:`agents-meta-block`,children:[(0,B.jsx)(`span`,{children:`Token I/O`}),(0,B.jsx)(`strong`,{children:Ja({inputTokens:e.inputTokens,outputTokens:e.outputTokens})})]}),(0,B.jsxs)(`div`,{className:`agents-meta-block`,children:[(0,B.jsx)(`span`,{children:`Cost`}),(0,B.jsx)(`strong`,{children:Xa(e.costUsd)})]}),(0,B.jsxs)(`div`,{className:`agents-meta-block`,children:[(0,B.jsx)(`span`,{children:`Last Active`}),(0,B.jsx)(`strong`,{children:Za(e.lastActive)})]})]}),n?(0,B.jsx)(zs,{sessionId:e.id,title:e.previewTitle,output:r}):null,(0,B.jsxs)(`div`,{className:`button-row`,children:[(0,B.jsx)(`button`,{className:`ghost-button`,type:`button`,onClick:()=>{t({to:`/admin/sessions`,search:{sessionId:e.id}}).catch(Os)},children:`Open Session`}),(0,B.jsx)(`button`,{className:`ghost-button`,type:`button`,onClick:()=>u(e.id),children:n?`Hide Output`:`Show Output`})]})]},e.id)})}):(0,B.jsx)(`div`,{className:`empty-state`,children:`No sessions match this filter.`})]})]})]})}function Vs(e){let t=Gn(),n=o(),r=hs(),[i,a]=(0,R.useState)(``),s=g({mutationFn:e=>pn(t.token,e),onSuccess:()=>{a(``),n.invalidateQueries({queryKey:[`admin-approvals`,t.token]}),n.invalidateQueries({queryKey:[`jobs-context`,t.token]}),e.onResumed?.(),r.success(`Blocked session resumed.`)},onError:e=>{r.error(`Failed to resume blocked session`,H(e))}});function c(t){if(t.kind===`code`&&!t.value.trim()){r.error(`Code required`,`Enter the operator-provided code first.`);return}s.mutate({sessionId:e.session.sessionId,response:t})}return(0,B.jsxs)(`div`,{className:`button-row`,children:[e.session.expectedReturnKinds.includes(`code`)?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`input`,{"aria-label":`Code for ${e.session.sessionId}`,value:i,disabled:s.isPending,placeholder:`Code`,onChange:e=>a(e.target.value)}),(0,B.jsx)(`button`,{className:`primary-button`,type:`button`,disabled:s.isPending,onClick:()=>c({kind:`code`,value:i.trim()}),children:`Resume`})]}):null,e.session.expectedReturnKinds.includes(`approved`)?(0,B.jsx)(`button`,{className:`primary-button`,type:`button`,disabled:s.isPending,onClick:()=>c({kind:`approved`}),children:`Approved`}):null,e.session.expectedReturnKinds.includes(`scanned`)?(0,B.jsx)(`button`,{className:`primary-button`,type:`button`,disabled:s.isPending,onClick:()=>c({kind:`scanned`}),children:`Scanned`}):null,e.session.expectedReturnKinds.includes(`declined`)?(0,B.jsx)(`button`,{className:`danger-button`,type:`button`,disabled:s.isPending,onClick:()=>c({kind:`declined`}),children:`Decline`}):null,e.session.expectedReturnKinds.includes(`timeout`)?(0,B.jsx)(`button`,{className:`ghost-button`,type:`button`,disabled:s.isPending,onClick:()=>c({kind:`timeout`}),children:`Timeout`}):null]})}function Hs(e){let t=[`once`];return e.allowSession&&t.push(`session`),e.allowAgent&&t.push(`agent`),e.allowAll&&t.push(`all`),t.join(`, `)}function Us(e){return e.comment&&e.managedByPreset?`${e.comment} · preset:${e.managedByPreset}`:e.comment?e.comment:e.managedByPreset?`preset:${e.managedByPreset}`:``}function Ws(e){return{action:`allow`,host:``,port:`*`,methods:`*`,paths:`/**`,agent:e||`*`,comment:``}}function Gs(e){return{action:e.action,host:e.host,port:String(e.port),methods:e.methods.join(`, `),paths:e.paths.join(`, `),agent:e.agent,comment:e.comment||``}}function Ks(e,t){let n=e.split(`,`).map(e=>e.trim()).filter(Boolean);return n.length>0?n:t}function qs(e){let t=e.trim();if(!t||t===`*`)return`*`;if(!/^\d+$/.test(t))throw Error("Port must be `*` or a whole number from 1 to 65535.");let n=Number(t);if(!Number.isSafeInteger(n)||n<=0||n>65535)throw Error("Port must be `*` or a whole number from 1 to 65535.");return n}function Js(e){let t=e.host.trim();if(!t)throw Error(`Host is required.`);let n=e.agent.trim()||`*`,r=e.comment.trim();return{action:e.action,host:t,port:qs(e.port),methods:Ks(e.methods,[`*`]),paths:Ks(e.paths,[`/**`]),agent:n,...r?{comment:r}:{}}}function Ys(){let e=Gn(),t=o(),n=hs(),[r,i]=(0,R.useState)(``),[a,s]=(0,R.useState)(``),[c,l]=(0,R.useState)(null),[u,d]=(0,R.useState)(null),[f,p]=(0,R.useState)(null),[m,h]=(0,R.useState)(()=>Ws(`main`)),_=y({queryKey:[`admin-approvals`,e.token,r],queryFn:()=>fn(e.token,r?{agentId:r}:void 0)}),v=r||_.data?.selectedAgentId||`main`,b=_.data?.agents||[];(0,R.useEffect)(()=>{l(null),d(null),h(Ws(v))},[v]);function x(){l(null),d(null),h(Ws(v))}function S(){l(`create`),d(null),h(Ws(v))}let C=g({mutationFn:t=>mn(e.token,{agentId:v,...t.index==null?{}:{index:t.index},rule:t.rule}),onSuccess:(r,i)=>{x(),t.invalidateQueries({queryKey:[`admin-approvals`,e.token]}),n.success(i.index==null?`Policy rule added.`:`Rule #${i.index} updated.`)},onError:(e,t)=>{n.error(t.index==null?`Failed to add rule`:`Failed to update rule`,H(e))}}),w=g({mutationFn:t=>vn(e.token,{agentId:v,index:t}),onSuccess:(r,i)=>{u===i&&x(),t.invalidateQueries({queryKey:[`admin-approvals`,e.token]}),n.success(`Rule #${i} deleted.`)},onError:(e,t)=>{n.error(`Failed to delete rule #${t}`,H(e))}}),T=g({mutationFn:t=>_n(e.token,{agentId:v,presetName:t}),onSuccess:(r,i)=>{t.invalidateQueries({queryKey:[`admin-approvals`,e.token]}),n.success(`Template '${i}' applied.`)},onError:e=>{n.error(`Failed to apply template`,H(e))}}),E=g({mutationFn:t=>hn(e.token,{agentId:v,defaultAction:t}),onSuccess:(r,i)=>{t.invalidateQueries({queryKey:[`admin-approvals`,e.token]}),n.success(`Default policy set to ${i}.`)},onError:e=>{n.error(`Failed to update default policy`,H(e))}}),D=g({mutationFn:t=>gn(e.token,{agentId:v,mode:t}),onSuccess:(r,i)=>{t.invalidateQueries({queryKey:[`admin-approvals`,e.token]}),n.success(`LAN HTTP access set to ${i}.`)},onError:e=>{n.error(`Failed to update LAN HTTP access`,H(e))}});function O(e){e.preventDefault();try{C.mutate({index:u,rule:Js(m)})}catch(e){n.error(`Invalid policy rule`,H(e))}}function k(e){l(`edit`),d(e.index),h(Gs(e))}function A(e){p(e)}let j=_.data?.policy.rules||[],M=(_.data?.availablePresets||[]).filter(e=>!_.data?.policy.presets.includes(e.name)).sort((e,t)=>e.name.localeCompare(t.name)),N=C.isPending||w.isPending||E.isPending||D.isPending||T.isPending,P=c!==null,F=E.isPending&&E.variables?E.variables:_.data?.policy.defaultAction||`deny`,I=D.isPending&&D.variables?D.variables:_.data?.policy.lanHttpAccess?.mode||`off`;return(0,R.useEffect)(()=>{s(e=>e&&M.some(t=>t.name===e)?e:M[0]?.name||``)},[M]),(0,B.jsxs)(`div`,{className:`page-stack`,children:[(0,B.jsx)(Ha,{actions:(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Policy agent`}),(0,B.jsx)(ds,{value:v,disabled:_.isLoading&&b.length===0,onChange:e=>i(e.target.value),children:b.length?b.map(e=>(0,B.jsx)(Q,{value:e.id,children:e.name?`${e.name} (${e.id})`:e.id},e.id)):(0,B.jsx)(Q,{value:v,children:`Loading agents...`})})]})}),(0,B.jsxs)(`div`,{className:`metric-grid`,children:[(0,B.jsx)(Ua,{label:`Pending approvals`,value:String(_.data?.pending.length??0),loading:!_.data}),(0,B.jsx)(Ua,{label:`Blocked sessions`,value:String(_.data?.suspendedSessions.length??0),loading:!_.data}),(0,B.jsx)(Ua,{label:`Policy rules`,value:String(j.length),loading:!_.data}),(0,B.jsx)(Ua,{label:`Applied presets`,value:String(_.data?.policy.presets.length??0),loading:!_.data}),(0,B.jsxs)(`div`,{className:`metric-card`,children:[(0,B.jsx)(`span`,{children:`Default policy`}),(0,B.jsx)(`div`,{className:`field`,children:(0,B.jsxs)(ds,{value:F,disabled:!_.data||N,onChange:e=>E.mutate(e.target.value===`allow`?`allow`:`deny`),children:[(0,B.jsx)(Q,{value:`deny`,children:`deny`}),(0,B.jsx)(Q,{value:`allow`,children:`allow`})]})})]}),(0,B.jsxs)(`div`,{className:`metric-card`,children:[(0,B.jsx)(`span`,{children:`LAN HTTP access`}),(0,B.jsx)(`div`,{className:`field`,children:(0,B.jsxs)(`select`,{"aria-label":`LAN HTTP access`,value:I,disabled:!_.data||N,onChange:e=>{let t=e.target.value;if(t===`custom`){S();return}D.mutate(t)},children:[(0,B.jsx)(`option`,{value:`off`,children:`Off`}),(0,B.jsx)(`option`,{value:`read-only`,children:`Read-only LAN`}),(0,B.jsx)(`option`,{value:`read-write`,children:`Read-write LAN`}),(0,B.jsx)(`option`,{value:`custom`,children:`Custom`})]})})]})]}),(0,B.jsxs)(`div`,{className:`page-stack`,children:[(0,B.jsxs)(U,{variant:`muted`,children:[(0,B.jsx)(W,{children:(0,B.jsx)(G,{children:`Policy`})}),(0,B.jsx)(K,{children:_.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading policy...`}):_.data?(0,B.jsxs)(`div`,{className:`detail-stack`,children:[j.length?(0,B.jsx)(`div`,{className:`table-shell`,children:(0,B.jsxs)(`table`,{className:`policy-rules-table`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{children:`#`}),(0,B.jsx)(`th`,{children:`Action`}),(0,B.jsx)(`th`,{children:`Host`}),(0,B.jsx)(`th`,{children:`Port`}),(0,B.jsx)(`th`,{children:`Methods`}),(0,B.jsx)(`th`,{children:`Paths`}),(0,B.jsx)(`th`,{children:`Agent`}),(0,B.jsx)(`th`,{children:`Comment`}),(0,B.jsx)(`th`,{children:`Actions`})]})}),(0,B.jsx)(`tbody`,{children:j.map(e=>(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`td`,{children:e.index}),(0,B.jsx)(`td`,{children:(0,B.jsx)(`strong`,{children:e.action.toUpperCase()})}),(0,B.jsx)(`td`,{children:e.host}),(0,B.jsx)(`td`,{children:String(e.port)}),(0,B.jsx)(`td`,{children:e.methods.join(`, `)}),(0,B.jsx)(`td`,{children:e.paths.join(`, `)}),(0,B.jsx)(`td`,{children:e.agent}),(0,B.jsx)(`td`,{children:Us(e)}),(0,B.jsx)(`td`,{children:(0,B.jsxs)(`div`,{className:`policy-table-actions`,children:[(0,B.jsx)(`button`,{className:`ghost-button`,type:`button`,disabled:N,onClick:()=>k(e),children:`Edit`}),(0,B.jsx)(`button`,{className:`danger-button`,type:`button`,disabled:N,onClick:()=>A(e),children:`Delete`})]})})]},`${e.index}:${e.host}:${e.agent}`))})]})}):(0,B.jsx)(`div`,{className:`empty-state`,children:`No policy rules found.`}),(0,B.jsxs)(`div`,{className:`policy-action-row`,children:[(0,B.jsx)(`button`,{className:`primary-button`,type:`button`,disabled:N,onClick:S,children:`New rule`}),(0,B.jsxs)(`div`,{className:`policy-template-actions`,children:[(0,B.jsxs)(`label`,{className:`policy-template-inline`,children:[(0,B.jsx)(`span`,{children:`Template:`}),(0,B.jsx)(ds,{value:a,disabled:N||M.length===0,onChange:e=>s(e.target.value),children:M.length>0?M.map(e=>(0,B.jsx)(Q,{value:e.name,children:e.name},e.name)):(0,B.jsx)(Q,{value:``,children:`No templates available`})})]}),(0,B.jsx)(`button`,{className:`ghost-button`,type:`button`,disabled:N||!a,onClick:()=>T.mutate(a),children:`Add template`})]})]}),P?(0,B.jsxs)(`form`,{className:`config-section detail-stack`,onSubmit:O,children:[(0,B.jsx)(`strong`,{children:c===`edit`&&u!=null?`Edit rule #${u}`:`Add rule`}),(0,B.jsxs)(`div`,{className:`field-grid policy-editor-grid`,children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Action`}),(0,B.jsxs)(ds,{value:m.action,disabled:N,onChange:e=>h(t=>({...t,action:e.target.value===`deny`?`deny`:`allow`})),children:[(0,B.jsx)(Q,{value:`allow`,children:`allow`}),(0,B.jsx)(Q,{value:`deny`,children:`deny`})]})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Host`}),(0,B.jsx)(Y,{value:m.host,disabled:N,placeholder:`example.com`,onChange:e=>h(t=>({...t,host:e.target.value}))})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Port`}),(0,B.jsx)(Y,{value:m.port,disabled:N,placeholder:`*`,onChange:e=>h(t=>({...t,port:e.target.value}))})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Methods`}),(0,B.jsx)(Y,{value:m.methods,disabled:N,placeholder:`*`,onChange:e=>h(t=>({...t,methods:e.target.value}))})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Paths`}),(0,B.jsx)(Y,{value:m.paths,disabled:N,placeholder:`/**`,onChange:e=>h(t=>({...t,paths:e.target.value}))})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Agent`}),(0,B.jsx)(Y,{value:m.agent,disabled:N,placeholder:`*`,onChange:e=>h(t=>({...t,agent:e.target.value}))})]}),(0,B.jsxs)(`label`,{className:`field policy-comment-field`,children:[(0,B.jsx)(`span`,{children:`Comment`}),(0,B.jsx)(Jo,{rows:2,value:m.comment,disabled:N,placeholder:`Optional note`,onChange:e=>h(t=>({...t,comment:e.target.value}))})]})]}),(0,B.jsxs)(`div`,{className:`button-row`,children:[(0,B.jsx)(`button`,{className:`primary-button`,type:`submit`,disabled:N,children:C.isPending?(0,B.jsxs)(`span`,{className:`button-with-spinner`,children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`button-spinner`}),c===`edit`?`Saving...`:`Adding...`]}):c===`edit`?`Save changes`:`Save`}),(0,B.jsx)(`button`,{className:`ghost-button`,type:`button`,disabled:N,onClick:x,children:`Cancel`})]})]}):null]}):(0,B.jsx)(`div`,{className:`empty-state`,children:`Policy state is unavailable.`})})]}),(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{children:(0,B.jsx)(G,{children:`Blocked sessions`})}),(0,B.jsx)(K,{children:_.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading blocked sessions...`}):_.data?.suspendedSessions.length?(0,B.jsx)(`div`,{className:`list-stack`,children:_.data.suspendedSessions.map(e=>(0,B.jsxs)(`div`,{className:`summary-block`,children:[(0,B.jsxs)(`div`,{className:`key-value-grid`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Status`}),(0,B.jsx)(`strong`,{children:e.blockedLabel})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Modality`}),(0,B.jsx)(`strong`,{children:e.modality})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Agent`}),(0,B.jsx)(`strong`,{children:e.agentId||`unknown`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Host`}),(0,B.jsx)(`strong`,{children:e.context.host||`unknown`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Created`}),(0,B.jsx)(`strong`,{title:Qa(e.createdAt),children:Za(e.createdAt)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Expires`}),(0,B.jsx)(`strong`,{title:Qa(e.expiresAt),children:Za(e.expiresAt)})]})]}),(0,B.jsx)(`p`,{className:`supporting-text`,children:e.prompt}),(0,B.jsx)(Vs,{session:e})]},e.sessionId))}):(0,B.jsx)(`div`,{className:`empty-state`,children:`No blocked sessions right now.`})})]}),(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{children:(0,B.jsx)(G,{children:`Pending approvals`})}),(0,B.jsx)(K,{children:_.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading pending approvals...`}):_.data?.pending.length?(0,B.jsx)(`div`,{className:`list-stack`,children:_.data.pending.map(e=>(0,B.jsxs)(`div`,{className:`summary-block`,children:[(0,B.jsxs)(`div`,{className:`key-value-grid`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Approval`}),(0,B.jsx)(`strong`,{children:e.actionKey||e.approvalId})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Agent`}),(0,B.jsx)(`strong`,{children:e.agentId||`unknown`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Session`}),(0,B.jsx)(`strong`,{children:e.sessionId})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Trust scopes`}),(0,B.jsx)(`strong`,{children:Hs({allowSession:e.allowSession,allowAgent:e.allowAgent,allowAll:e.allowAll})})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Created`}),(0,B.jsx)(`strong`,{title:Qa(e.createdAt),children:Za(e.createdAt)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Expires`}),(0,B.jsx)(`strong`,{title:Qa(e.expiresAt),children:Za(e.expiresAt)})]})]}),(0,B.jsx)(`p`,{className:`supporting-text`,children:e.prompt})]},e.approvalId))}):(0,B.jsx)(`div`,{className:`empty-state`,children:`No pending approvals right now.`})})]})]}),(0,B.jsx)(ri,{open:f!==null,onOpenChange:e=>{e||p(null)},children:(0,B.jsxs)(ii,{size:`sm`,role:`alertdialog`,children:[(0,B.jsxs)(ai,{children:[(0,B.jsx)(oi,{children:`Delete policy rule?`}),(0,B.jsx)(si,{children:f?`This will remove rule #${f.index} for ${f.host}.`:`This will remove the selected policy rule.`})]}),(0,B.jsxs)(ci,{children:[(0,B.jsx)(li,{className:`ghost-button`,children:`Cancel`}),(0,B.jsx)(li,{className:`danger-button`,onClick:()=>{f&&w.mutate(f.index)},children:`Delete`})]})]})})]})}var Xs={page:`_page_17tay_1`,toolbar:`_toolbar_17tay_8`,searchRow:`_searchRow_17tay_16`,searchWrap:`_searchWrap_17tay_23`,searchIcon:`_searchIcon_17tay_31`,searchInput:`_searchInput_17tay_41`,shortcutHint:`_shortcutHint_17tay_47`,timeRange:`_timeRange_17tay_64`,meta:`_meta_17tay_106`,chipRow:`_chipRow_17tay_117`,categoryChip:`_categoryChip_17tay_128`,activeRow:`_activeRow_17tay_208`,activeChip:`_activeChip_17tay_221`,activeChipRemove:`_activeChipRemove_17tay_239`,clearAll:`_clearAll_17tay_260`,tableWrap:`_tableWrap_17tay_281`,table:`_table_17tay_281`,colTime:`_colTime_17tay_341`,colEvent:`_colEvent_17tay_346`,colSession:`_colSession_17tay_350`,colSeq:`_colSeq_17tay_356`,colId:`_colId_17tay_357`,colRun:`_colRun_17tay_365`,mono:`_mono_17tay_375`,eventPill:`_eventPill_17tay_379`,empty:`_empty_17tay_435`,loadMoreRow:`_loadMoreRow_17tay_442`,loadMore:`_loadMore_17tay_442`,sheet:`_sheet_17tay_478`,sheetHeader:`_sheetHeader_17tay_485`,sheetHeaderMain:`_sheetHeaderMain_17tay_494`,sheetHeaderId:`_sheetHeaderId_17tay_501`,sheetClose:`_sheetClose_17tay_507`,sheetBody:`_sheetBody_17tay_531`,sheetMeta:`_sheetMeta_17tay_540`,payloadSection:`_payloadSection_17tay_564`,payloadHeader:`_payloadHeader_17tay_571`,payloadBlock:`_payloadBlock_17tay_582`},Zs=[`session`,`turn`,`model`,`tool`,`autonomy`,`authorization`,`approval`,`a2a`],Qs=new Set(Zs),$s=[{value:`all`,label:`All`},{value:`1h`,label:`1h`},{value:`24h`,label:`24h`},{value:`7d`,label:`7d`}],ec=new Set($s.map(e=>e.value)),tc={"1h":3600*1e3,"24h":1440*60*1e3,"7d":10080*60*1e3};function nc(e){let t=e.split(`.`,1)[0]??``;return Qs.has(t)?t:`default`}function rc(e,t=Date.now()){if(e!==`all`)return new Date(t-tc[e]).toISOString()}function ic(e){return e&&ec.has(e)?e:`all`}var ac={session:`session`,type:`type`,event:`type`};function oc(e){let t=[],n=``,r=!1;for(let i of e){if(i===`"`){r=!r,n+=i;continue}if(!r&&/\s/.test(i)){n&&=(t.push(n),``);continue}n+=i}return n&&t.push(n),t}function sc(e){return e.length>=2&&e.startsWith(`"`)&&e.endsWith(`"`)?e.slice(1,-1):e.startsWith(`"`)?e.slice(1):e.endsWith(`"`)?e.slice(0,-1):e}function cc(e){let t=e.indexOf(`:`);if(t>0){let n=ac[e.slice(0,t).toLowerCase()];if(n)return{kind:`field`,key:n,value:sc(e.slice(t+1)),raw:e}}return{kind:`text`,value:sc(e),raw:e}}function lc(e){let t=oc(e).map(cc),n=``,r=``,i=[];for(let e of t)e.kind===`field`?e.key===`session`?n=e.value:r=e.value:e.value&&i.push(e.value);return{sessionId:n,eventType:r,query:i.join(` `)}}function uc(e,t){return oc(e).map(cc).filter(e=>!(e.kind===`field`&&e.key===t)).map(e=>e.raw).join(` `)}function dc(e,t,n){let r=n.trim(),i=uc(e,t);if(!r)return i;let a=`${t}:${/\s/.test(r)?`"${r}"`:r}`;return i?`${i} ${a}`:a}var fc=200;function pc(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function mc(e){if(!e)return null;let t=nc(e);return t==="default"?null:t}function hc(){let e=Gn(),t=j(),n=ee({strict:!1}),r=n.q??``,i=ic(n.range),[a,o]=(0,R.useState)(r),[s,c]=(0,R.useState)(i),[l,u]=(0,R.useState)(null),[d,f]=(0,R.useState)(!1),p=(0,R.useRef)(null),m=(0,R.useRef)(null),g=(0,R.useRef)(n.q),_=(0,R.useRef)(n.range),v=(0,R.useMemo)(()=>lc(a),[a]),{query:y,sessionId:b,eventType:S}=(0,R.useDeferredValue)(v);(0,R.useEffect)(()=>{let e=a.trim()||void 0,n=s===`all`?void 0:s;e===g.current&&n===_.current||(g.current=e,_.current=n,t({to:`/admin/audit`,search:{q:e,range:n},replace:!0}).catch(Os))},[t,a,s]),(0,R.useEffect)(()=>{n.q!==g.current&&(g.current=n.q,o(n.q??``)),n.range!==_.current&&(_.current=n.range,c(ic(n.range)))},[n.q,n.range]),(0,R.useEffect)(()=>{function e(e){if(e.key!==`/`||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target,n=t?.tagName;n===`INPUT`||n===`TEXTAREA`||t?.isContentEditable||(e.preventDefault(),p.current?.focus(),p.current?.select())}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let[C,w]=(0,R.useState)(()=>Date.now()),T=(0,R.useRef)(0);(0,R.useEffect)(()=>{if(s===`all`)return;w(Date.now());let e=window.setInterval(()=>{T.current>1||w(Date.now())},3e4);return()=>window.clearInterval(e)},[s]);let E=(0,R.useMemo)(()=>rc(s,C),[s,C]),D=x({queryKey:[`audit`,e.token,y,b,S,E],initialPageParam:void 0,queryFn:({pageParam:t})=>dn(e.token,{query:y,sessionId:b,eventType:S,since:E,cursor:t,limit:fc}),getNextPageParam:e=>e.nextCursor??void 0,placeholderData:h}),O=(0,R.useRef)(D);O.current=D,T.current=D.data?.pages.length??0,(0,R.useEffect)(()=>{let e=m.current;if(!e||!D.hasNextPage)return;let t=new IntersectionObserver(([e])=>{let t=O.current;e?.isIntersecting&&t.hasNextPage&&!t.isFetchingNextPage&&t.fetchNextPage()},{rootMargin:`400px`});return t.observe(e),()=>t.disconnect()},[D.hasNextPage]);let k=(0,R.useMemo)(()=>D.data?.pages.flatMap(e=>e.entries)??[],[D.data]),A=D.data?.pages[0]?.total??k.length,M=(0,R.useMemo)(()=>mc(v.eventType),[v.eventType]),N=!!(v.query||v.sessionId||v.eventType||s!==`all`);function P(e){u(e),f(!0)}function F(e,t){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),P(t))}let I=(0,R.useCallback)(e=>{o(t=>e===null||mc(lc(t).eventType)===e?uc(t,`type`):dc(t,`type`,e))},[]);function L(){o(e=>uc(e,`session`))}function te(){o(e=>uc(e,`type`))}function ne(){o(``),c(`all`)}return(0,B.jsxs)(`div`,{className:Xs.page,children:[(0,B.jsxs)(`div`,{className:Xs.toolbar,children:[(0,B.jsxs)(`div`,{className:Xs.searchRow,children:[(0,B.jsxs)(`div`,{className:Xs.searchWrap,children:[(0,B.jsx)(Er,{className:Xs.searchIcon,"aria-hidden":`true`}),(0,B.jsx)(Y,{ref:p,className:Xs.searchInput,value:a,onChange:e=>o(e.target.value),placeholder:`Search payloads… try session:web type:tool`,"aria-label":`Audit search`,spellCheck:!1,autoComplete:`off`}),(0,B.jsx)(`span`,{className:Xs.shortcutHint,"data-hidden":a?`true`:void 0,"aria-hidden":`true`,children:`/`})]}),(0,B.jsx)(`div`,{className:Xs.timeRange,role:`toolbar`,"aria-label":`Time range`,children:$s.map(e=>{let t=s===e.value;return(0,B.jsx)(`button`,{type:`button`,"aria-pressed":t,"data-active":t||void 0,onClick:()=>c(e.value),children:e.label},e.value)})}),(0,B.jsx)(`div`,{className:Xs.meta,"aria-live":`polite`,children:D.isLoading?`Loading…`:`${A} event${A===1?``:`s`}`})]}),(0,B.jsxs)(`div`,{className:Xs.chipRow,role:`toolbar`,"aria-label":`Event category`,children:[(0,B.jsx)(`button`,{type:`button`,className:Xs.categoryChip,"data-category":`all`,"aria-pressed":M===null,"data-active":M===null||void 0,onClick:()=>I(null),children:`all`}),Zs.map(e=>{let t=M===e;return(0,B.jsx)(`button`,{type:`button`,className:Xs.categoryChip,"data-category":e,"aria-pressed":t,"data-active":t||void 0,onClick:()=>I(e),children:e},e)})]}),(0,B.jsxs)(`div`,{className:Xs.activeRow,"data-empty":N?void 0:`true`,children:[v.sessionId?(0,B.jsxs)(`span`,{className:Xs.activeChip,children:[(0,B.jsx)(`strong`,{children:`session:`}),v.sessionId,(0,B.jsx)(`button`,{type:`button`,className:Xs.activeChipRemove,"aria-label":`Remove session filter ${v.sessionId}`,onClick:L,children:`×`})]}):null,v.eventType?(0,B.jsxs)(`span`,{className:Xs.activeChip,children:[(0,B.jsx)(`strong`,{children:`type:`}),v.eventType,(0,B.jsx)(`button`,{type:`button`,className:Xs.activeChipRemove,"aria-label":`Remove event type filter ${v.eventType}`,onClick:te,children:`×`})]}):null,s===`all`?null:(0,B.jsxs)(`span`,{className:Xs.activeChip,children:[(0,B.jsx)(`strong`,{children:`last:`}),s,(0,B.jsx)(`button`,{type:`button`,className:Xs.activeChipRemove,"aria-label":`Reset time range`,onClick:()=>c(`all`),children:`×`})]}),N?(0,B.jsx)(`button`,{type:`button`,className:Xs.clearAll,onClick:ne,children:`Clear all`}):null]})]}),(0,B.jsxs)(`div`,{className:Xs.tableWrap,children:[(0,B.jsxs)(`table`,{className:Xs.table,children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{scope:`col`,children:`Time`}),(0,B.jsx)(`th`,{scope:`col`,children:`Event`}),(0,B.jsx)(`th`,{scope:`col`,children:`Session`}),(0,B.jsx)(`th`,{scope:`col`,"data-col":`run`,children:`Run`}),(0,B.jsx)(`th`,{scope:`col`,className:Xs.colSeq,children:`Seq`}),(0,B.jsx)(`th`,{scope:`col`,className:Xs.colId,children:`ID`})]})}),(0,B.jsx)(`tbody`,{children:k.map(e=>{let t=nc(e.eventType);return(0,B.jsxs)(`tr`,{role:`button`,tabIndex:0,"data-selected":e.id===l?.id||void 0,"aria-label":`Inspect audit event ${e.id} (${e.eventType})`,onClick:()=>P(e),onKeyDown:t=>F(t,e),children:[(0,B.jsx)(`td`,{className:Xs.colTime,title:Qa(e.timestamp),children:Za(e.timestamp)}),(0,B.jsx)(`td`,{className:Xs.colEvent,children:(0,B.jsx)(`span`,{className:Xs.eventPill,"data-category":t,children:e.eventType})}),(0,B.jsx)(`td`,{className:Xs.colSession,title:e.sessionId,children:(0,B.jsx)(`span`,{className:Xs.mono,children:e.sessionId})}),(0,B.jsx)(`td`,{className:Xs.colRun,title:e.runId,children:e.runId}),(0,B.jsx)(`td`,{className:Xs.colSeq,children:e.seq}),(0,B.jsxs)(`td`,{className:Xs.colId,children:[`#`,e.id]})]},e.id)})})]}),k.length===0?(0,B.jsx)(`div`,{className:Xs.empty,children:D.isLoading?`Loading audit entries…`:`No audit entries match these filters.`}):null,D.hasNextPage?(0,B.jsx)(`div`,{ref:m,className:Xs.loadMoreRow,children:(0,B.jsx)(`button`,{type:`button`,className:Xs.loadMore,onClick:()=>{D.fetchNextPage()},disabled:D.isFetchingNextPage,children:D.isFetchingNextPage?`Loading…`:`Load more`})}):null]}),(0,B.jsx)(ri,{open:d,onOpenChange:f,isDrawer:!0,children:(0,B.jsxs)(ii,{side:`right`,className:Xs.sheet,children:[(0,B.jsx)(ai,{children:(0,B.jsx)(oi,{children:l?`Audit event #${l.id} (${l.eventType})`:`Audit event`})}),l?(0,B.jsx)(gc,{entry:l,onClose:()=>f(!1)}):null]})})]})}function gc({entry:e,onClose:t}){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:Xs.sheetHeader,children:[(0,B.jsxs)(`div`,{className:Xs.sheetHeaderMain,children:[(0,B.jsx)(`span`,{className:Xs.eventPill,"data-category":nc(e.eventType),children:e.eventType}),(0,B.jsxs)(`span`,{className:Xs.sheetHeaderId,children:[`#`,e.id,` · `,Qa(e.timestamp)]})]}),(0,B.jsx)(`button`,{type:`button`,className:Xs.sheetClose,"aria-label":`Close inspector`,onClick:t,children:`×`})]}),(0,B.jsxs)(`div`,{className:Xs.sheetBody,children:[(0,B.jsxs)(`dl`,{className:Xs.sheetMeta,children:[(0,B.jsx)(`dt`,{children:`Session`}),(0,B.jsx)(`dd`,{children:e.sessionId}),(0,B.jsx)(`dt`,{children:`Run ID`}),(0,B.jsx)(`dd`,{children:e.runId}),(0,B.jsx)(`dt`,{children:`Parent run`}),(0,B.jsx)(`dd`,{children:e.parentRunId||`—`}),(0,B.jsx)(`dt`,{children:`Seq`}),(0,B.jsx)(`dd`,{children:e.seq}),(0,B.jsx)(`dt`,{children:`Timestamp`}),(0,B.jsx)(`dd`,{children:Qa(e.timestamp)})]}),(0,B.jsxs)(`section`,{className:Xs.payloadSection,children:[(0,B.jsx)(`div`,{className:Xs.payloadHeader,children:(0,B.jsx)(`span`,{children:`Payload`})}),(0,B.jsx)(`pre`,{className:Xs.payloadBlock,children:pc(e.payload)})]})]})]})}function _c(e){switch(e.kind){case`discord`:case`discord_webhook`:return(0,B.jsx)(`span`,{className:`channel-logo`,"aria-hidden":`true`,children:(0,B.jsxs)(`svg`,{viewBox:`0 0 32 32`,"aria-hidden":`true`,focusable:`false`,children:[(0,B.jsx)(`rect`,{x:`3`,y:`3`,width:`26`,height:`26`,rx:`9`,fill:`#5865F2`}),(0,B.jsx)(`path`,{fill:`#FFFFFF`,d:`M10.6 21.7c1.5 1 3.3 1.7 5.1 1.9l.6-1.1c1 .2 2 .2 3 0l.6 1.1c1.9-.2 3.6-.9 5.1-1.9.3-3.2-.4-6.2-2-8.9a11.4 11.4 0 0 0-4.1-1.8l-.5 1a12.2 12.2 0 0 0-3.5 0l-.5-1a11.4 11.4 0 0 0-4.1 1.8c-1.6 2.7-2.3 5.7-2 8.9Z`}),(0,B.jsx)(`circle`,{cx:`13.6`,cy:`16.9`,r:`1.25`,fill:`#5865F2`}),(0,B.jsx)(`circle`,{cx:`18.4`,cy:`16.9`,r:`1.25`,fill:`#5865F2`})]})});case`whatsapp`:return(0,B.jsx)(`span`,{className:`channel-logo`,"aria-hidden":`true`,children:(0,B.jsxs)(`svg`,{viewBox:`0 0 32 32`,"aria-hidden":`true`,focusable:`false`,children:[(0,B.jsx)(`circle`,{cx:`16`,cy:`16`,r:`13`,fill:`#25D366`}),(0,B.jsx)(`path`,{fill:`#FFFFFF`,d:`M16 8.1a7.5 7.5 0 0 0-6.4 11.5l-.8 3 3.1-.8A7.5 7.5 0 1 0 16 8.1Zm0 13.3a5.8 5.8 0 0 1-3-.8l-.4-.2-1.8.5.5-1.7-.3-.4a5.8 5.8 0 1 1 5 2.6Z`}),(0,B.jsx)(`path`,{fill:`#25D366`,d:`M13.2 12.3c-.2 0-.4.1-.5.4-.3.4-.7 1-.7 1.8s.7 1.7.8 1.8c.1.1 1.5 2.3 3.6 3.2 1.8.8 2.2.7 2.6.6.4-.1 1.2-.5 1.4-1 .1-.5.1-.8.1-.9 0-.1-.2-.2-.5-.3l-1.4-.7c-.2-.1-.4-.1-.5.1l-.6.8c-.1.1-.3.2-.5.1-.3-.1-1-.4-1.9-1.2-.8-.7-1.2-1.5-1.4-1.7-.1-.3 0-.4.1-.5l.4-.5c.1-.1.1-.3.2-.4s0-.3 0-.4l-.6-1.5c-.1-.3-.3-.4-.5-.4Z`})]})});case`telegram`:return(0,B.jsx)(`span`,{className:`channel-logo`,"aria-hidden":`true`,children:(0,B.jsxs)(`svg`,{viewBox:`0 0 32 32`,"aria-hidden":`true`,focusable:`false`,children:[(0,B.jsx)(`circle`,{cx:`16`,cy:`16`,r:`13`,fill:`#27A7E7`}),(0,B.jsx)(`path`,{fill:`#FFFFFF`,d:`m23.4 10.2-2.3 11c-.2 1-.8 1.3-1.6.8l-3.5-2.6-1.7 1.6c-.2.2-.4.4-.7.4l.3-3.7 6.8-6.1c.3-.3-.1-.4-.4-.2l-8.4 5.3-3.6-1.1c-.8-.2-.8-.8.2-1.2l14-5.4c.7-.3 1.2.2 1 .9Z`})]})});case`threema`:return(0,B.jsx)(`span`,{className:`channel-logo`,"aria-hidden":`true`,children:(0,B.jsxs)(`svg`,{viewBox:`0 0 32 32`,"aria-hidden":`true`,focusable:`false`,children:[(0,B.jsx)(`rect`,{x:`3`,y:`3`,width:`26`,height:`26`,rx:`8`,fill:`#F4C430`}),(0,B.jsx)(`path`,{fill:`#111827`,d:`M10 13.6h2.2v-1.5c0-2.3 1.7-4.1 3.8-4.1s3.8 1.8 3.8 4.1v1.5H22c.7 0 1.2.5 1.2 1.2v7.9c0 .7-.5 1.2-1.2 1.2H10c-.7 0-1.2-.5-1.2-1.2v-7.9c0-.7.5-1.2 1.2-1.2Zm4.1 0h3.8v-1.5c0-1.2-.8-2.1-1.9-2.1s-1.9.9-1.9 2.1v1.5Z`})]})});case`signal`:return(0,B.jsx)(`span`,{className:`channel-logo channel-logo-compact`,"aria-hidden":`true`,children:(0,B.jsx)(`svg`,{viewBox:`0 0 128 128`,"aria-hidden":`true`,focusable:`false`,children:(0,B.jsx)(`path`,{fill:`#3A76F0`,d:`M48.64,1.87l1.44,5.82A57.84,57.84,0,0,0,34,14.34L30.92,9.2A63.76,63.76,0,0,1,48.64,1.87Zm30.72,0L77.92,7.69A57.84,57.84,0,0,1,94,14.34l3.1-5.14A63.76,63.76,0,0,0,79.36,1.87ZM9.2,30.92A63.76,63.76,0,0,0,1.87,48.64l5.82,1.44A57.84,57.84,0,0,1,14.34,34ZM6,64a57.9,57.9,0,0,1,.65-8.69l-5.93-.9a64.23,64.23,0,0,0,0,19.18l5.93-.9A57.9,57.9,0,0,1,6,64Zm91.08,54.8L94,113.66a57.84,57.84,0,0,1-16.06,6.65l1.44,5.82A63.76,63.76,0,0,0,97.08,118.8ZM122,64a57.9,57.9,0,0,1-.65,8.69l5.93.9a64.23,64.23,0,0,0,0-19.18l-5.93.9A57.9,57.9,0,0,1,122,64Zm4.13,15.36-5.82-1.44A57.84,57.84,0,0,1,113.66,94l5.14,3.1A63.76,63.76,0,0,0,126.13,79.36Zm-53.44,42a58.41,58.41,0,0,1-17.38,0l-.9,5.93a64.23,64.23,0,0,0,19.18,0Zm38-22.95A58.21,58.21,0,0,1,98.4,110.69l3.56,4.83A64.1,64.1,0,0,0,115.52,102ZM98.4,17.31A58.21,58.21,0,0,1,110.69,29.6L115.52,26A64.1,64.1,0,0,0,102,12.48ZM17.31,29.6A58.21,58.21,0,0,1,29.6,17.31L26,12.48A64.1,64.1,0,0,0,12.48,26ZM118.8,30.92,113.66,34a57.84,57.84,0,0,1,6.65,16.06l5.82-1.44A63.76,63.76,0,0,0,118.8,30.92ZM55.31,6.65a58.41,58.41,0,0,1,17.38,0l.9-5.93a64.23,64.23,0,0,0-19.18,0ZM20.39,117.11,8,120l2.89-12.39-5.84-1.37L2.16,118.63a6,6,0,0,0,7.21,7.21L21.75,123ZM6.3,100.89l5.84,1.36,2-8.59A57.75,57.75,0,0,1,7.69,77.92L1.87,79.36a63.52,63.52,0,0,0,5.9,15.21Zm28,13-8.59,2,1.36,5.84,6.32-1.47a63.52,63.52,0,0,0,15.21,5.9l1.44-5.82A57.75,57.75,0,0,1,34.34,113.85ZM64,12A52,52,0,0,0,20,91.67L15,113l21.33-5A52,52,0,1,0,64,12Z`})})});case`voice`:return(0,B.jsx)(`span`,{className:`channel-logo`,"aria-hidden":`true`,children:(0,B.jsx)(`svg`,{viewBox:`0 0 100 30`,"aria-hidden":`true`,focusable:`false`,fill:`#F22F46`,children:(0,B.jsx)(`path`,{d:`M14.4 11.3c0 1.7-1.4 3.1-3.1 3.1S8.2 13 8.2 11.3s1.4-3.1 3.1-3.1 3.1 1.4 3.1 3.1zm-3.1 4.3c-1.7 0-3.1 1.4-3.1 3.1s1.4 3.1 3.1 3.1 3.1-1.4 3.1-3.1-1.4-3.1-3.1-3.1zM30 15c0 8.3-6.7 15-15 15S0 23.3 0 15 6.7 0 15 0s15 6.7 15 15zm-4 0c0-6.1-4.9-11-11-11S4 8.9 4 15s4.9 11 11 11 11-4.9 11-11zm-7.3.6c-1.7 0-3.1 1.4-3.1 3.1s1.4 3.1 3.1 3.1 3.1-1.4 3.1-3.1-1.4-3.1-3.1-3.1zm0-7.4c-1.7 0-3.1 1.4-3.1 3.1s1.4 3.1 3.1 3.1 3.1-1.4 3.1-3.1-1.4-3.1-3.1-3.1zm51.6-2.3c.1 0 .2.1.3.2v3.2c0 .2-.2.3-.3.3H65c-.2 0-.3-.2-.3-.3V6.2c0-.2.2-.3.3-.3h5.3zm-.1 4.5H60c-.1 0-.3.1-.3.3l-1.3 5-.1.3-1.6-5.3c0-.1-.2-.3-.3-.3h-4c-.1 0-.3.1-.3.3l-1.5 5-.1.3-.1-.3-.6-2.5-.6-2.5c0-.1-.2-.3-.3-.3h-8V6.1c0-.1-.2-.3-.4-.2l-5 1.6c-.2 0-.3.1-.3.3v2.7h-1.3c-.1 0-.3.1-.3.3v3.8c0 .1.1.3.3.3h1.3v4.7c0 3.3 1.8 4.8 5.1 4.8 1.4 0 2.7-.3 3.6-.8v-4c0-.2-.2-.3-.3-.2-.5.2-1 .3-1.4.3-.9 0-1.4-.4-1.4-1.4v-3.4h2.9c.1 0 .3-.1.3-.3v-3.2L47.8 24c0 .1.2.3.3.3h4.2c.1 0 .3-.1.3-.3l1.8-5.6.9 2.9.8 2.7c0 .1.2.3.3.3h4.2c.1 0 .3-.1.3-.3l3.8-12.6V24c0 .1.1.3.3.3h5.1c.1 0 .3-.1.3-.3V10.7c0-.1-.1-.3-.2-.3zm6.7-4.5h-5.1c-.1 0-.3.1-.3.3v17.7c0 .1.1.3.3.3h5.1c.1 0 .3-.1.3-.3V6.1c0-.1-.1-.2-.3-.2zm6.8 0h-5.3c-.1 0-.3.1-.3.3v3.1c0 .1.1.3.3.3h5.3c.1 0 .3-.1.3-.3V6.1c0-.1-.1-.2-.3-.2zm-.1 4.5h-5.1c-.1 0-.3.1-.3.3v13.1c0 .1.1.3.3.3h5.1c.1 0 .3-.1.3-.3V10.7c0-.1-.1-.3-.3-.3zm16.1 6.8c0 3.8-3.2 7.1-7.7 7.1-4.4 0-7.6-3.3-7.6-7.1s3.2-7.1 7.7-7.1c4.4 0 7.6 3.3 7.6 7.1zm-5.4.1c0-1.4-1-2.5-2.2-2.4-1.3 0-2.2 1.1-2.2 2.4s1 2.4 2.2 2.4c1.3 0 2.2-1.1 2.2-2.4z`})})});case`email`:return(0,B.jsx)(`span`,{className:`channel-logo`,"aria-hidden":`true`,children:(0,B.jsxs)(`svg`,{viewBox:`0 0 32 32`,"aria-hidden":`true`,focusable:`false`,children:[(0,B.jsx)(`rect`,{x:`3`,y:`5`,width:`26`,height:`22`,rx:`6`,fill:`#2563EB`}),(0,B.jsx)(`path`,{fill:`#FFFFFF`,d:`M8 10.5h16v11H8z`}),(0,B.jsx)(`path`,{d:`m8.8 11.6 7.2 5.2 7.2-5.2`,fill:`none`,stroke:`#2563EB`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,B.jsx)(`path`,{d:`m8.8 20.8 5.5-4.6m8.9 4.6-5.5-4.6`,fill:`none`,stroke:`#93C5FD`,strokeWidth:`1.4`,strokeLinecap:`round`})]})});case`slack`:case`slack_webhook`:return(0,B.jsx)(`span`,{className:`channel-logo channel-logo-compact`,"aria-hidden":`true`,children:(0,B.jsxs)(`svg`,{viewBox:`0 0 127 127`,"aria-hidden":`true`,focusable:`false`,children:[(0,B.jsx)(`path`,{fill:`#E01E5A`,d:`M27.2 80c0 7.3-5.9 13.2-13.2 13.2C6.7 93.2.8 87.3.8 80c0-7.3 5.9-13.2 13.2-13.2h13.2V80zm6.6 0c0-7.3 5.9-13.2 13.2-13.2 7.3 0 13.2 5.9 13.2 13.2v33c0 7.3-5.9 13.2-13.2 13.2-7.3 0-13.2-5.9-13.2-13.2V80z`}),(0,B.jsx)(`path`,{fill:`#36C5F0`,d:`M47 27c-7.3 0-13.2-5.9-13.2-13.2C33.8 6.5 39.7.6 47 .6c7.3 0 13.2 5.9 13.2 13.2V27H47zm0 6.7c7.3 0 13.2 5.9 13.2 13.2 0 7.3-5.9 13.2-13.2 13.2H13.9C6.6 60.1.7 54.2.7 46.9c0-7.3 5.9-13.2 13.2-13.2H47z`}),(0,B.jsx)(`path`,{fill:`#2EB67D`,d:`M99.9 46.9c0-7.3 5.9-13.2 13.2-13.2 7.3 0 13.2 5.9 13.2 13.2 0 7.3-5.9 13.2-13.2 13.2H99.9V46.9zm-6.6 0c0 7.3-5.9 13.2-13.2 13.2-7.3 0-13.2-5.9-13.2-13.2V13.8C66.9 6.5 72.8.6 80.1.6c7.3 0 13.2 5.9 13.2 13.2v33.1z`}),(0,B.jsx)(`path`,{fill:`#ECB22E`,d:`M80.1 99.8c7.3 0 13.2 5.9 13.2 13.2 0 7.3-5.9 13.2-13.2 13.2-7.3 0-13.2-5.9-13.2-13.2V99.8h13.2zm0-6.6c-7.3 0-13.2-5.9-13.2-13.2 0-7.3 5.9-13.2 13.2-13.2h33.1c7.3 0 13.2 5.9 13.2 13.2 0 7.3-5.9 13.2-13.2 13.2H80.1z`})]})});case`msteams`:return(0,B.jsx)(`span`,{className:`channel-logo`,"aria-hidden":`true`,children:(0,B.jsxs)(`svg`,{viewBox:`4 4 36 38`,"aria-hidden":`true`,focusable:`false`,fill:`none`,children:[(0,B.jsx)(`path`,{fill:`url(#teams-logo-a)`,d:`M21.9999 20h12c3.3137 0 6 2.6863 6 6v10c0 3.3137-2.6863 6-6 6s-6-2.6863-6-6V26c0-3.3137-2.6863-6-6-6`}),(0,B.jsx)(`path`,{fill:`url(#teams-logo-b)`,d:`M7.99988 24c0-3.3137 2.68632-6 6.00002-6h8c3.3137 0 6 2.6863 6 6v12c0 3.3137 2.6863 6 6 6l-16.0001-.0001c-5.5228 0-9.99992-4.4771-9.99992-10z`}),(0,B.jsx)(`path`,{fill:`url(#teams-logo-c)`,fillOpacity:`.7`,d:`M7.99988 24c0-3.3137 2.68632-6 6.00002-6h8c3.3137 0 6 2.6863 6 6v12c0 3.3137 2.6863 6 6 6l-16.0001-.0001c-5.5228 0-9.99992-4.4771-9.99992-10z`}),(0,B.jsx)(`path`,{fill:`url(#teams-logo-d)`,fillOpacity:`.7`,d:`M7.99988 24c0-3.3137 2.68632-6 6.00002-6h8c3.3137 0 6 2.6863 6 6v12c0 3.3137 2.6863 6 6 6l-16.0001-.0001c-5.5228 0-9.99992-4.4771-9.99992-10z`}),(0,B.jsx)(`path`,{fill:`url(#teams-logo-e)`,d:`M32.9999 18c2.7614 0 5-2.2386 5-5s-2.2386-5-5-5-5 2.2386-5 5 2.2386 5 5 5`}),(0,B.jsx)(`path`,{fill:`url(#teams-logo-f)`,fillOpacity:`.46`,d:`M32.9999 18c2.7614 0 5-2.2386 5-5s-2.2386-5-5-5-5 2.2386-5 5 2.2386 5 5 5`}),(0,B.jsx)(`path`,{fill:`url(#teams-logo-g)`,fillOpacity:`.4`,d:`M32.9999 18c2.7614 0 5-2.2386 5-5s-2.2386-5-5-5-5 2.2386-5 5 2.2386 5 5 5`}),(0,B.jsx)(`path`,{fill:`url(#teams-logo-h)`,d:`M17.9999 16c3.3137 0 6-2.6863 6-6 0-3.31371-2.6863-6-6-6s-6 2.68629-6 6c0 3.3137 2.6863 6 6 6`}),(0,B.jsx)(`path`,{fill:`url(#teams-logo-i)`,fillOpacity:`.6`,d:`M17.9999 16c3.3137 0 6-2.6863 6-6 0-3.31371-2.6863-6-6-6s-6 2.68629-6 6c0 3.3137 2.6863 6 6 6`}),(0,B.jsx)(`path`,{fill:`url(#teams-logo-j)`,fillOpacity:`.5`,d:`M17.9999 16c3.3137 0 6-2.6863 6-6 0-3.31371-2.6863-6-6-6s-6 2.68629-6 6c0 3.3137 2.6863 6 6 6`}),(0,B.jsx)(`rect`,{width:`16`,height:`16`,x:`4`,y:`23`,fill:`url(#teams-logo-k)`,rx:`3.25`}),(0,B.jsx)(`rect`,{width:`16`,height:`16`,x:`4`,y:`23`,fill:`url(#teams-logo-l)`,fillOpacity:`.7`,rx:`3.25`}),(0,B.jsx)(`path`,{fill:`#fff`,d:`M15.4792 28.1054h-2.4471v7.466h-2.0648v-7.466H8.52014v-1.6768h6.95906z`}),(0,B.jsxs)(`defs`,{children:[(0,B.jsxs)(`radialGradient`,{id:`teams-logo-a`,cx:`0`,cy:`0`,r:`1`,gradientTransform:`matrix(13.4784 0 0 33.2694 39.7967 22.1739)`,gradientUnits:`userSpaceOnUse`,children:[(0,B.jsx)(`stop`,{stopColor:`#a98aff`}),(0,B.jsx)(`stop`,{offset:`.14`,stopColor:`#8c75ff`}),(0,B.jsx)(`stop`,{offset:`.565`,stopColor:`#5f50e2`}),(0,B.jsx)(`stop`,{offset:`.9`,stopColor:`#3c2cb8`})]}),(0,B.jsxs)(`radialGradient`,{id:`teams-logo-b`,cx:`0`,cy:`0`,r:`1`,gradientTransform:`rotate(68.1539 -7.71566095 14.71355834)scale(32.752 33.1231)`,gradientUnits:`userSpaceOnUse`,children:[(0,B.jsx)(`stop`,{stopColor:`#85c2ff`}),(0,B.jsx)(`stop`,{offset:`.69`,stopColor:`#7588ff`}),(0,B.jsx)(`stop`,{offset:`1`,stopColor:`#6459fe`})]}),(0,B.jsxs)(`linearGradient`,{id:`teams-logo-c`,x1:`20.5936`,x2:`20.5936`,y1:`18`,y2:`42`,gradientUnits:`userSpaceOnUse`,children:[(0,B.jsx)(`stop`,{offset:`.801159`,stopColor:`#6864f6`,stopOpacity:`0`}),(0,B.jsx)(`stop`,{offset:`1`,stopColor:`#5149de`})]}),(0,B.jsxs)(`radialGradient`,{id:`teams-logo-d`,cx:`0`,cy:`0`,r:`1`,gradientTransform:`rotate(113.326 8.09285255 17.64474501)scale(19.2186 15.4273)`,gradientUnits:`userSpaceOnUse`,children:[(0,B.jsx)(`stop`,{stopColor:`#bd96ff`}),(0,B.jsx)(`stop`,{offset:`.686685`,stopColor:`#bd96ff`,stopOpacity:`0`})]}),(0,B.jsxs)(`radialGradient`,{id:`teams-logo-e`,cx:`0`,cy:`0`,r:`1`,gradientTransform:`matrix(0 -10 12.6216 0 32.9999 11.5714)`,gradientUnits:`userSpaceOnUse`,children:[(0,B.jsx)(`stop`,{offset:`.268201`,stopColor:`#6868f7`}),(0,B.jsx)(`stop`,{offset:`1`,stopColor:`#3923b1`})]}),(0,B.jsxs)(`radialGradient`,{id:`teams-logo-f`,cx:`0`,cy:`0`,r:`1`,gradientTransform:`rotate(40.0516 -.03068196 44.8729095)scale(7.14629 10.3363)`,gradientUnits:`userSpaceOnUse`,children:[(0,B.jsx)(`stop`,{offset:`.270711`,stopColor:`#a1d3ff`}),(0,B.jsx)(`stop`,{offset:`.813393`,stopColor:`#a1d3ff`,stopOpacity:`0`})]}),(0,B.jsxs)(`radialGradient`,{id:`teams-logo-g`,cx:`0`,cy:`0`,r:`1`,gradientTransform:`rotate(-41.6581 32.11799918 -43.41948423)scale(8.51275 20.8824)`,gradientUnits:`userSpaceOnUse`,children:[(0,B.jsx)(`stop`,{stopColor:`#e3acfd`}),(0,B.jsx)(`stop`,{offset:`.816041`,stopColor:`#9fa2ff`,stopOpacity:`0`})]}),(0,B.jsxs)(`radialGradient`,{id:`teams-logo-h`,cx:`0`,cy:`0`,r:`1`,gradientTransform:`matrix(0 -12 15.146 0 17.9999 8.28571)`,gradientUnits:`userSpaceOnUse`,children:[(0,B.jsx)(`stop`,{offset:`.268201`,stopColor:`#8282ff`}),(0,B.jsx)(`stop`,{offset:`1`,stopColor:`#3923b1`})]}),(0,B.jsxs)(`radialGradient`,{id:`teams-logo-i`,cx:`0`,cy:`0`,r:`1`,gradientTransform:`rotate(40.0516 -3.15465147 21.41641466)scale(8.57554 12.4035)`,gradientUnits:`userSpaceOnUse`,children:[(0,B.jsx)(`stop`,{offset:`.270711`,stopColor:`#a1d3ff`}),(0,B.jsx)(`stop`,{offset:`.813393`,stopColor:`#a1d3ff`,stopOpacity:`0`})]}),(0,B.jsxs)(`radialGradient`,{id:`teams-logo-j`,cx:`0`,cy:`0`,r:`1`,gradientTransform:`rotate(-41.6581 20.38180375 -26.51566158)scale(10.2153 25.0589)`,gradientUnits:`userSpaceOnUse`,children:[(0,B.jsx)(`stop`,{stopColor:`#e3acfd`}),(0,B.jsx)(`stop`,{offset:`.816041`,stopColor:`#9fa2ff`,stopOpacity:`0`})]}),(0,B.jsxs)(`radialGradient`,{id:`teams-logo-k`,cx:`0`,cy:`0`,r:`1`,gradientTransform:`rotate(45 -25.76345597 16.32842712)scale(22.6274)`,gradientUnits:`userSpaceOnUse`,children:[(0,B.jsx)(`stop`,{offset:`.046875`,stopColor:`#688eff`}),(0,B.jsx)(`stop`,{offset:`.946875`,stopColor:`#230f94`})]}),(0,B.jsxs)(`radialGradient`,{id:`teams-logo-l`,cx:`0`,cy:`0`,r:`1`,gradientTransform:`matrix(0 11.2 -13.0702 0 12 32.6)`,gradientUnits:`userSpaceOnUse`,children:[(0,B.jsx)(`stop`,{offset:`.570647`,stopColor:`#6965f6`,stopOpacity:`0`}),(0,B.jsx)(`stop`,{offset:`1`,stopColor:`#8f8fff`})]})]})]})});case`imessage`:return(0,B.jsx)(`span`,{className:`channel-logo`,"aria-hidden":`true`,children:(0,B.jsxs)(`svg`,{viewBox:`0 0 32 32`,"aria-hidden":`true`,focusable:`false`,children:[(0,B.jsx)(`path`,{fill:`#34C759`,d:`M16 4.5c6.4 0 11.5 4.2 11.5 9.5 0 5.2-5.1 9.5-11.5 9.5-1 0-2-.1-2.9-.3L7.4 27l1.8-4.2C6.3 21 4.5 17.8 4.5 14c0-5.3 5.1-9.5 11.5-9.5Z`}),(0,B.jsx)(`path`,{fill:`#FFFFFF`,d:`M10.7 12.2h10.6c.6 0 1 .4 1 1s-.4 1-1 1H10.7c-.6 0-1-.4-1-1s.4-1 1-1Zm0 4.6h7.8c.6 0 1 .4 1 1s-.4 1-1 1h-7.8c-.6 0-1-.4-1-1s.4-1 1-1Z`})]})})}}function vc(e,t){if(Object.is(e,t))return!0;if(e===null||t===null||typeof e!=`object`||typeof t!=`object`)return!1;if(e instanceof Date||t instanceof Date)return!(e instanceof Date)||!(t instanceof Date)?!1:e.getTime()===t.getTime();let n=Array.isArray(e),r=Array.isArray(t);if(n!==r)return!1;if(n&&r){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(!vc(e[n],t[n]))return!1;return!0}let i=Object.keys(e),a=Object.keys(t);if(i.length!==a.length)return!1;for(let n of i)if(!Object.hasOwn(t,n)||!vc(e[n],t[n]))return!1;return!0}var yc=new Set([`__proto__`,`prototype`,`constructor`]);function bc(e){return yc.has(e)}function xc(e,t){if(e==null)return;let n=t.split(`.`),r=e;for(let e of n){if(typeof r!=`object`||!r||bc(e))return;r=r[e]}return r}function Sc(e,t,n){if(!t)throw Error(`setPath requires a non-empty path.`);let r=t.split(`.`);if(r.some(bc))throw Error(`setPath rejected an unsafe path segment in "${t}".`);return wc(e,r,0,n)}function Cc(e){return Array.isArray(e)?[...e]:{...e}}function wc(e,t,n,r){let i=t[n],a=n===t.length-1,o=typeof e==`object`&&!!e;if(a){if(o&&e[i]===r)return e;let t=o?Cc(e):{};return t[i]=r,t}let s=o?e[i]:void 0,c=wc(s,t,n+1,r);if(o&&c===s)return e;let l=o?Cc(e):{};return l[i]=c,l}function Tc(e){let{source:t}=e,n=e.equals??vc,[r,i]=(0,R.useState)(()=>t??null),a=(0,R.useRef)(t);(0,R.useEffect)(()=>{if(t===void 0)return;let e=a.current;if(a.current=t,r===null){i(t);return}e!==void 0&&!n(e,t)&&n(r,e)&&i(t)},[t,r,n]);let o=(0,R.useMemo)(()=>r===null||t===void 0?!1:!n(r,t),[r,t,n]),s=(0,R.useCallback)(()=>{t!==void 0&&i(t)},[t]),c=(0,R.useCallback)(e=>{i(e)},[]);return{draft:r,setDraft:i,setField:(0,R.useCallback)((e,t)=>{i(n=>n===null?n:Sc(n,e,t))},[]),isDirty:o,discard:s,commit:c}}function $(e){let{form:t,name:n,rules:r,required:i,disabled:a,render:o,children:s}=e,c=ho(),l=t??c;if(!l)throw Error("FormField requires either a `form` prop or to be nested inside <Form>.");let u=(0,R.useId)(),d=(0,R.useMemo)(()=>{let e=[];if(i&&e.push(jo()),r)for(let t of r)typeof t==`function`&&e.push(t);return No(...e)},[i,r]),f=xc(l.draft,n),p=d(f),m=(0,R.useCallback)(e=>{l.setField(n,Ec(e))},[l,n]),h=(0,R.useCallback)(()=>d(xc(l.draft,n)),[l,n,d]),g=(0,R.useMemo)(()=>({name:n,value:f,id:u,onChange:m,"aria-required":i?!0:void 0,disabled:a}),[n,f,u,m,i,a]),_=(0,R.useMemo)(()=>({error:p,invalid:p!==null}),[p]),v=(0,R.useMemo)(()=>({name:n,id:u,error:p,validate:h,required:i,disabled:a}),[n,u,p,h,i,a]),y=o?.({field:g,fieldState:_})??(typeof s==`function`?s({field:g,fieldState:_}):s);return(0,B.jsx)(go.Provider,{value:v,children:y})}function Ec(e){if(typeof e!=`object`||!e)return e;let t=e;if(!t.target||typeof t.target!=`object`)return e;let n=t.target;return n.type===`checkbox`?n.checked??!1:`value`in n?n.value:e}function Dc(e){let[t,n]=(0,R.useState)(()=>new Map),[r,i]=(0,R.useState)(0),a=(0,R.useRef)(new Map),o=(0,R.useRef)(new Map),s=(0,R.useRef)(t);s.current=t;let c=(0,R.useCallback)((e,t)=>{n(n=>{if(t===null){if(!n.has(e))return n;let t=new Map(n);return t.delete(e),t}if(n.get(e)===t)return n;let r=new Map(n);return r.set(e,t),r})},[]),l=(0,R.useCallback)((e,t)=>(a.current.set(e,t),()=>{a.current.get(e)===t&&a.current.delete(e)}),[]),u=(0,R.useCallback)((e,t)=>(o.current.set(e,t),()=>{o.current.get(e)===t&&o.current.delete(e)}),[]),d=(0,R.useCallback)(()=>{let e=new Map(s.current);for(let[t,n]of a.current){let r=n();r===null?e.delete(t):e.set(t,r),c(t,r)}return e},[c]),f=(0,R.useCallback)(e=>{for(let[t,n]of Object.entries(e)){let e=o.current.get(t);e?e(n):c(t,n)}},[c]),p=(0,R.useCallback)(()=>{for(let e of o.current.values())e(null);n(e=>e.size===0?e:new Map)},[]),m=(0,R.useCallback)(()=>{n(e=>e.size===0?e:new Map),i(e=>e+1)},[]),h=(0,R.useMemo)(()=>({registerError:c,registerValidator:l,registerErrorSetter:u,validateAll:d,setErrors:f,clearErrors:p,reset:m,resetSeq:r,errors:t,isValid:t.size===0}),[c,l,u,d,f,p,m,r,t]),g=Tc({source:e?.source,equals:e?.equals});return e?{...h,...g}:h}function Oc({form:e,onSubmit:t,children:n,noValidate:r=!0,...i}){let[a,o]=(0,R.useState)(!1),[s,c]=(0,R.useState)(!1),l=(0,R.useRef)(e.validateAll);l.current=e.validateAll;let u=(0,R.useRef)(t);u.current=t;let d=(0,R.useRef)(!1),f=(0,R.useRef)(e.resetSeq);f.current!==e.resetSeq&&(f.current=e.resetSeq,a&&o(!1));let p=(0,R.useCallback)(e=>{if(e.preventDefault(),d.current)return;o(!0);let t=l.current();if(t.size>0){let e=Ac(t);if(e){let t=document.getElementById(e);t&&typeof t.focus==`function`&&t.focus()}return}let n=u.current?.();if(!kc(n))return;d.current=!0,c(!0);let r=()=>{d.current=!1,c(!1)};n.then(r,r)},[]),m=(0,R.useMemo)(()=>({registerError:e.registerError,registerValidator:e.registerValidator,registerErrorSetter:e.registerErrorSetter}),[e.registerError,e.registerValidator,e.registerErrorSetter]),h=(0,R.useMemo)(()=>({isValid:e.isValid,errors:e.errors}),[e.isValid,e.errors]),g=(0,R.useMemo)(()=>({submitAttempted:a,resetSeq:e.resetSeq,isSubmitting:s}),[a,e.resetSeq,s]),_=(0,R.useMemo)(()=>{if(!(`setField`in e&&`draft`in e))return null;let t=e;return{draft:t.draft,setField:t.setField}},[e]);return(0,B.jsx)(mo.Provider,{value:_,children:(0,B.jsx)(vo.Provider,{value:m,children:(0,B.jsx)(yo.Provider,{value:h,children:(0,B.jsx)(bo.Provider,{value:g,children:(0,B.jsx)(`form`,{noValidate:r,...i,onSubmit:p,children:n})})})})})}function kc(e){return typeof e==`object`&&!!e&&typeof e.then==`function`}function Ac(e){if(e.size===0)return;if(typeof document>`u`)return e.keys().next().value;let t=null;for(let n of e.keys()){let e=document.getElementById(n);e&&(t===null||(t.el.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)!==0)&&(t={id:n,el:e})}return t?.id??e.keys().next().value}function jc({value:e,onValueChange:t,onErrorChange:n,integer:r,min:i,max:a,step:o,emptyValue:s,requiredMessage:c=`Required.`,...l}){let[u,d]=(0,R.useState)(()=>String(e)),f=(0,R.useRef)(u);f.current=u;let p=Eo(),m=po(e=>{p.setError(e),n?.(e)});(0,R.useEffect)(()=>{let t=f.current;t.trim()===``&&s!==void 0&&e===s||Number(t)!==e&&(d(String(e)),m(null))},[e,s,m]);let h=e=>{if(e.trim()===``)return s===void 0?{error:c}:{value:s,error:null};let t=Number(e);return Number.isFinite(t)?r&&!Number.isInteger(t)?{error:`Enter a whole number.`}:i!==void 0&&t<i?{error:`Must be ≥ ${i}.`}:a!==void 0&&t>a?{error:`Must be ≤ ${a}.`}:{value:t,error:null}:{error:`Enter a valid number.`}};return(0,B.jsx)(Y,{...l,type:r?`number`:`text`,inputMode:r?`numeric`:`decimal`,min:i,max:a,step:r?o:void 0,value:u,onBlur:t=>{if(!r){let t=Number(u);Number.isFinite(t)||(d(String(e)),m(null))}l.onBlur?.(t)},onChange:e=>{let n=e.target.value;d(n);let r=h(n);m(r.error),r.error===null&&r.value!==void 0&&t(r.value)}})}var Mc={root:`_root_tqjv2_1`,thumb:`_thumb_tqjv2_40`,sizeDefault:`_sizeDefault_tqjv2_50`,sizeSm:`_sizeSm_tqjv2_65`},Nc={default:Mc.sizeDefault,sm:Mc.sizeSm};function Pc({checked:e,onCheckedChange:t,disabled:n,size:r=`default`,className:i,onClick:a,name:o,value:s=`on`,required:c,...l}){let{required:u,...d}=Do({disabled:n,required:c,...l}),f=Eo(),p=e?`checked`:`unchecked`,m=d.disabled,h=n=>{m||(a?.(n),!n.defaultPrevented&&(f.setTouched(!0),t?.(!e)))};return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`button`,{...d,type:`button`,role:`switch`,"aria-checked":e,"data-slot":`switch`,"data-state":p,"data-size":r,className:V(Mc.root,Nc[r],i),onClick:h,children:(0,B.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`switch-thumb`,"data-state":p,className:Mc.thumb})}),o&&e&&!m?(0,B.jsx)(`input`,{type:`hidden`,name:o,value:s}):null]})}function Fc(e){let t=o();return g({mutationFn:async t=>{try{return await e.mutationFn(t)}catch(e){throw e instanceof Error?e:Error(String(e),{cause:e})}},onSuccess:(n,r)=>{e.onSuccess?.(n,r);for(let n of e.invalidates??[])t.invalidateQueries({queryKey:n})},onError:(t,n)=>{e.onError?.(t,n)}})}var Ic=`hybridclaw_session`,Lc=new Set;function Rc(){try{return localStorage.getItem(Ic)??``}catch{return``}}function zc(e){if(Rc()!==e){try{e?localStorage.setItem(Ic,e):localStorage.removeItem(Ic)}catch{}for(let e of Lc)e()}}var Bc=`main`;function Vc(e){let t=new Uint8Array(e);return crypto.getRandomValues(t),Array.from(t,e=>e.toString(16).padStart(2,`0`)).join(``)}function Hc(){return`sess_${new Date().toISOString().slice(0,19).replace(/[-:]/g,``).replace(`T`,`_`)}_${Vc(4)}`}function Uc(){let e=`hybridclaw_user_id`,t=localStorage.getItem(e);if(t)return t;let n=`web-user-${Vc(4)}`;return localStorage.setItem(e,n),n}function Wc(e){zc(e)}var Gc=0;function Kc(){return Gc+=1,`local-${Gc}-${Date.now()}`}async function qc(e){if(navigator.clipboard?.writeText)try{return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}function Jc(e){if(!e)return``;if(e.summary)return e.summary;let t=[];return e.intent&&t.push(`Approval needed for: ${e.intent}`),e.reason&&t.push(`Why: ${e.reason}`),t.push(`Approval ID: ${e.approvalId}`),t.join(`
|
|
4
4
|
`)}var Yc={once:`/approve yes`,session:`/approve session`,agent:`/approve agent`,all:`/approve all`,deny:`/approve no`};function Xc(e,t){let n=Yc[e],r=t.trim();return/\s/.test(r)?null:r?`${n} ${r}`:n}function Zc(e){return(e.name??``).trim()||`clipboard${{"application/pdf":`.pdf`,"image/gif":`.gif`,"image/jpeg":`.jpg`,"image/png":`.png`,"image/webp":`.webp`,"text/plain":`.txt`}[(e.type??``).trim().toLowerCase()]??``}`}function Qc(e){let t=Zc(e);return e.name===t?e:new File([e],t,{type:e.type||`application/octet-stream`,lastModified:Number.isFinite(e.lastModified)?e.lastModified:Date.now()})}function $c(e){if(!e)return[];let t=[];for(let n of Array.from(e.files))t.push(Qc(n));if(t.length>0)return t;let n=new Set;for(let r of Array.from(e.items)){if(r.kind!==`file`)continue;let e=r.getAsFile();if(!e)continue;let i=Qc(e),a=`${i.name}:${i.size}:${i.type}:${i.lastModified}`;n.has(a)||(n.add(a),t.push(i))}return t}function el(e){return Object.keys(e).length}function tl(e){return el(e.discord.guilds)}function nl(e){return Object.values(e.discord.guilds).reduce((e,t)=>e+el(t.channels),0)}function rl(e){return el(e.msteams.teams)}function il(e){return Object.values(e.msteams.teams).reduce((e,t)=>e+el(t.channels),0)}function al(e,t){let n=tl(e),r=nl(e),i=e.discord.commandsOnly||e.discord.groupPolicy!==`disabled`,a=t.discordTokenConfigured===!0,o=i&&a,s=o?`active`:o||a||n>0||r>0?`configured`:`available`;return{kind:`discord`,label:`Discord`,summary:`${eo(n,`guild default`)} · ${eo(r,`explicit override`)}`,statusTone:s,statusLabel:s===`active`?`active`:s===`configured`?`configured`:`available`}}function ol(e,t){let n=t.whatsappLinked===!0,r=e.whatsapp.dmPolicy!==`disabled`||e.whatsapp.groupPolicy!==`disabled`,i=n?r?`Linked device · groups ${e.whatsapp.groupPolicy}`:`Linked device available but transport is off`:r?`Link device to enable WhatsApp`:`WhatsApp transport is off`,a=n?r?`active`:`configured`:`available`;return{kind:`whatsapp`,label:`WhatsApp`,summary:i,statusTone:a,statusLabel:a===`active`?`active`:a===`configured`?`configured`:`available`}}function sl(e,t){let n=t.telegramTokenConfigured===!0,r=e.telegram.dmPolicy!==`disabled`||e.telegram.groupPolicy!==`disabled`,i=e.telegram.enabled&&n&&r,a=i||e.telegram.enabled||n||e.telegram.allowFrom.length>0||e.telegram.groupAllowFrom.length>0,o=i?`active`:a?`configured`:`available`;return{kind:`telegram`,label:`Telegram`,summary:`DM ${e.telegram.dmPolicy} · groups ${e.telegram.groupPolicy}`,statusTone:o,statusLabel:o===`active`?`active`:o===`configured`?`configured`:`available`}}function cl(e,t){let n=t.signalDaemonUrlConfigured===!0,r=t.signalAccountConfigured===!0,i=t.signalCliAvailable===!0,a=e.signal.dmPolicy!==`disabled`||e.signal.groupPolicy!==`disabled`,o=e.signal.enabled&&n&&r&&a,s=o||e.signal.enabled||n||r||i||e.signal.allowFrom.length>0||e.signal.groupAllowFrom.length>0,c=o?`active`:s?`configured`:`available`;return{kind:`signal`,label:`Signal`,summary:`DM ${e.signal.dmPolicy} · groups ${e.signal.groupPolicy}${i?` · QR ready`:``}`,statusTone:c,statusLabel:c===`active`?`active`:c===`configured`?`configured`:`available`}}function ll(e,t){let n=t.threemaSecretConfigured===!0,r=e.threema.enabled&&!!e.threema.identity&&n&&e.threema.dmPolicy!==`disabled`,i=r||e.threema.enabled||!!e.threema.identity||n||e.threema.allowFrom.length>0,a=r?`active`:i?`configured`:`available`;return{kind:`threema`,label:`Threema`,summary:e.threema.identity?`Gateway ${e.threema.identity} · DM ${e.threema.dmPolicy}`:`No Gateway identity configured yet`,statusTone:a,statusLabel:a===`active`?`active`:a===`configured`?`configured`:`available`}}function ul(e,t){let n=t.slackBotTokenConfigured===!0,r=t.slackAppTokenConfigured===!0,i=e.slack.enabled&&n&&r,a=i||e.slack.enabled||n||r||e.slack.allowFrom.length>0||e.slack.groupAllowFrom.length>0,o=i?`active`:a?`configured`:`available`;return{kind:`slack`,label:`Slack`,summary:`DM ${e.slack.dmPolicy} · channels ${e.slack.groupPolicy}`,statusTone:o,statusLabel:o===`active`?`active`:o===`configured`?`configured`:`available`}}function dl(e,t){let n=Object.keys(e.slackWebhook.webhooks).length,r=e.slackWebhook.enabled&&t.slackWebhookDefaultConfigured===!0,i=r||e.slackWebhook.enabled||n>0,a=r?`active`:i?`configured`:`available`;return{kind:`slack_webhook`,label:`Slack Incoming Webhook`,summary:n>0?`${eo(n,`webhook target`)} · outbound only`:`No webhook targets configured yet`,statusTone:a,statusLabel:a===`active`?`active`:a===`configured`?`configured`:`available`}}function fl(e,t){let n=Object.keys(e.discordWebhook.webhooks).length,r=e.discordWebhook.enabled&&t.discordWebhookDefaultConfigured===!0,i=r||e.discordWebhook.enabled||n>0,a=r?`active`:i?`configured`:`available`;return{kind:`discord_webhook`,label:`Discord Incoming Webhook`,summary:n>0?`${eo(n,`webhook target`)} · outbound only`:`No webhook targets configured yet`,statusTone:a,statusLabel:a===`active`?`active`:a===`configured`?`configured`:`available`}}function pl(e,t){let n=t.voiceAuthTokenConfigured===!0,r=e.voice.twilio.accountSid.trim(),i=e.voice.twilio.fromNumber.trim(),a=e.voice.enabled&&!!r&&!!i&&n,o=a||e.voice.enabled||!!r||!!i||n,s=a?`active`:o?`configured`:`available`;return{kind:`voice`,label:`Voice`,summary:`Twilio · webhook ${e.voice.webhookPath}`,statusTone:s,statusLabel:s===`active`?`active`:s===`configured`?`configured`:`available`}}function ml(e,t){let n=t.emailPasswordConfigured===!0,r=String(e.email.address||``).trim(),i=Array.isArray(e.email.accounts)?e.email.accounts:[],a=i.filter(e=>e.address||e.agentId),o=r.length>0&&a.some(e=>{let t=String(e.agentId||``).trim(),n=String(e.address||``).trim();return!t||t===`main`||n.toLowerCase()===r.toLowerCase()}),s=a.length+(r&&!o?1:0),c=i.some(e=>{let t=e.password;return(typeof t==`string`?t.trim().length>0:!!t?.id)&&!!e.agentId&&!!e.address&&!!e.imapHost&&!!e.smtpHost}),l=e.email.enabled&&(c||n&&!!e.email.address&&!!e.email.imapHost&&!!e.email.smtpHost),u=l||a.length>0||!!e.email.address||!!e.email.imapHost||!!e.email.smtpHost||e.email.allowFrom.length>0,d=l?`active`:u?`configured`:`available`;return{kind:`email`,label:`Email`,summary:s>0?`${s} mailbox${s===1?``:`es`}`:e.email.address||`No mailbox address configured yet`,statusTone:d,statusLabel:d===`active`?`active`:d===`configured`?`configured`:`available`}}function hl(e){let t=rl(e),n=il(e),r=e.msteams.enabled&&!!e.msteams.appId&&!!e.msteams.tenantId,i=r||e.msteams.enabled||!!e.msteams.appId||!!e.msteams.tenantId||t>0||n>0,a=r?`active`:i?`configured`:`available`;return{kind:`msteams`,label:`Microsoft Teams`,summary:`${eo(t,`team default`)} · ${eo(n,`channel override`)}`,statusTone:a,statusLabel:a===`active`?`active`:a===`configured`?`configured`:`available`}}function gl(e,t){let n=e.imessage.backend===`bluebubbles`,r=t.imessagePasswordConfigured===!0,i=(n?e.imessage.enabled&&r&&e.imessage.serverUrl&&e.imessage.webhookPath:e.imessage.enabled&&e.imessage.cliPath&&e.imessage.dbPath)?`active`:`available`;return{kind:`imessage`,label:`iMessage`,summary:`${n?`Remote`:`Local`} backend · DM ${e.imessage.dmPolicy}`,statusTone:i,statusLabel:i===`active`?`active`:`available`}}function _l(e){switch(e.statusTone){case`active`:return 2;case`configured`:return 1;default:return 0}}function vl(e,t={}){return[al(e,t),fl(e,t),ul(e,t),dl(e,t),sl(e,t),cl(e,t),ll(e,t),pl(e,t),ol(e,t),ml(e,t),hl(e),gl(e,t)].sort((e,t)=>{let n=_l(t)-_l(e);return n===0?e.label.localeCompare(t.label):n})}function yl(e){return e.discord.commandsOnly||e.discord.groupPolicy!==`disabled`}function bl(e){return e.whatsapp.dmPolicy!==`disabled`||e.whatsapp.groupPolicy!==`disabled`}function xl(e){return e.telegram.dmPolicy!==`disabled`||e.telegram.groupPolicy!==`disabled`}function Sl(e){return(0,B.jsxs)(`label`,{className:`field textarea-field`,children:[(0,B.jsx)(`span`,{children:e.label}),(0,B.jsx)(Jo,{rows:e.rows??3,value:no(e.value),onChange:t=>e.onChange(to(t.target.value)),placeholder:e.placeholder})]})}var Cl=`*`;function wl(e){return e.trim()||null}function Tl(e){let t=[];for(let n of e)!n||t.includes(n)||t.push(n);return t}function El(e){let[t,n]=(0,R.useState)(``),r=Tl(e.value),i=wl(t),a=i!==null,o=()=>{if(!i||i===Cl&&!r.includes(Cl)&&!window.confirm(`Adding * allows every sender for this allowlist. Continue?`))return;let t=Tl([...r,i]);e.onChange(t),e.onAdd?.(t),n(``)},s=t=>{e.onChange(r.filter(e=>e!==t))};return(0,B.jsxs)(q,{className:`allow-list-field`,children:[(0,B.jsx)(J,{children:e.label}),(0,B.jsxs)(`div`,{className:`allow-list-add-row`,children:[(0,B.jsx)(Y,{value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),o())},placeholder:e.placeholder}),(0,B.jsx)(Z,{type:`button`,variant:`ghost`,disabled:!a,onClick:o,children:`Add`})]}),r.length>0?(0,B.jsx)(`ul`,{className:`allow-list-items`,children:r.map(e=>(0,B.jsxs)(`li`,{className:e===Cl?`allow-list-item allow-list-item-wildcard`:`allow-list-item`,children:[(0,B.jsxs)(`div`,{className:`allow-list-entry-main`,children:[(0,B.jsx)(`span`,{className:`allow-list-entry-value`,children:e}),e===Cl?(0,B.jsx)(`span`,{className:`allow-list-warning-label`,children:`all senders`}):null]}),(0,B.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Remove ${e}`,onClick:()=>s(e),children:(0,B.jsx)(Fr,{width:15,height:15})})]},e))}):(0,B.jsx)(`p`,{className:`muted-copy`,children:`No allowed senders configured.`})]})}function Dl(e){return Array.isArray(e.email.accounts)?e.email.accounts:[]}function Ol(e){return{agentId:``,imapHost:e.imapHost,imapPort:e.imapPort,imapSecure:e.imapSecure,smtpHost:e.smtpHost,smtpPort:e.smtpPort,smtpSecure:e.smtpSecure,address:``,password:``,pollIntervalMs:e.pollIntervalMs,folders:[...e.folders],allowFrom:[...e.allowFrom],mediaMaxMb:e.mediaMaxMb}}function kl(e){let t=e.password;return t&&typeof t==`object`&&t.source===`store`?t.id:``}function Al(e,t){let n={...e};return t?n.password={source:`store`,id:t}:delete n.password,n}function jl(e){return e.name?`${e.name} (${e.id})`:e.id}function Ml(e){let t=e.find(e=>e.id===Bc);return t?jl(t):`Main Agent (${Bc})`}function Nl(e){return e.trim().toUpperCase().replace(/[^A-Z0-9]+/g,`_`).replace(/^_+|_+$/g,``)||`AGENT`}function Pl(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36).toUpperCase().padStart(6,`0`)}function Fl(e,t){return`${Nl(e.agentId||t)}_${Pl(`${e.agentId||``}\n${t}\n${e.address||``}`)}_EMAIL_PASSWORD`}function Il(e,t){let n=t.find(t=>t.id===e.agentId);return String(n?.chatbotId||e.agentId||``).trim()}function Ll(){return`mailbox-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function Rl(e){return(0,B.jsx)($,{name:`channelInstructions.${e.kind}`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Channel instructions`}),(0,B.jsx)(Jo,{rows:4,...e,placeholder:`Optional extra instructions for this channel only.`})]})})}function zl(e){let[t,n]=(0,R.useState)(!1),[r,i]=(0,R.useState)(``),[a,o]=(0,R.useState)(!1),s=e.source!==null||a||e.configured||String(e.configValue||``).trim().length>0?`Change ${e.secretLabel}`:`Set ${e.secretLabel}`,c=hs(),l=g({mutationFn:async t=>Ht(e.token,e.secretName,t),onSuccess:()=>{o(!0),e.onSecretSaved(),n(!1),i(``),c.success(`${e.label} updated in encrypted runtime secrets.`)},onError:e=>{c.error(`Save failed`,H(e))}});return(0,B.jsxs)(q,{className:`managed-secret-field`,children:[(0,B.jsx)(Vo,{children:e.label}),t?null:(0,B.jsx)(`div`,{className:`button-row`,children:(0,B.jsx)(Z,{className:`managed-secret-action`,variant:`ghost`,type:`button`,onClick:()=>{l.reset(),n(!0),i(``)},children:s})}),t?(0,B.jsxs)(`div`,{className:`managed-secret-editor`,children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`New ${e.secretLabel}`}),(0,B.jsx)(Y,{type:`password`,value:r,autoComplete:`new-password`,onChange:e=>i(e.target.value)})]}),(0,B.jsxs)(`div`,{className:`button-row`,children:[(0,B.jsx)(Z,{type:`button`,loading:l.isPending,disabled:!r.trim()||l.isPending,onClick:()=>l.mutate(r),children:l.isPending?`Saving...`:`Save ${e.secretLabel}`}),(0,B.jsx)(Z,{variant:`ghost`,type:`button`,disabled:l.isPending,onClick:()=>{l.reset(),n(!1),i(``)},children:`Cancel`})]})]}):null]})}function Bl(e){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:yl(e.draft),onCheckedChange:t=>{let n=e.draft.discord,r=t&&n.groupPolicy===`disabled`&&!n.commandsOnly?`open`:t?n.groupPolicy:`disabled`,i=t?n.commandsOnly:!1;e.form.setField(`discord.groupPolicy`,r),e.form.setField(`discord.commandsOnly`,i)}}),(0,B.jsx)(Bo,{children:(0,B.jsx)(J,{children:`Enabled`})})]}),(0,B.jsx)(zl,{label:`Bot token`,secretName:`DISCORD_TOKEN`,secretLabel:`token`,configured:e.tokenConfigured,source:e.tokenSource,token:e.token,onSecretSaved:e.onSecretSaved}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`discord.prefix`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Prefix`}),(0,B.jsx)(Y,{...e})]})}),(0,B.jsx)($,{name:`discord.groupPolicy`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Group policy`}),(0,B.jsxs)(ds,{value:e.value,onChange:e.onChange,children:[(0,B.jsx)(Q,{value:`open`,children:`open`}),(0,B.jsx)(Q,{value:`allowlist`,children:`allowlist`}),(0,B.jsx)(Q,{value:`disabled`,children:`disabled`})]})]})})]}),(0,B.jsx)($,{name:`discord.commandsOnly`,render:({field:e})=>(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:!!e.value,onCheckedChange:e.onChange}),(0,B.jsx)(Bo,{children:(0,B.jsx)(J,{children:`Commands only`})})]})}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`discord.commandMode`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Command mode`}),(0,B.jsxs)(ds,{value:e.value,onChange:e.onChange,children:[(0,B.jsx)(Q,{value:`public`,children:`public`}),(0,B.jsx)(Q,{value:`restricted`,children:`restricted`})]})]})}),(0,B.jsx)($,{name:`discord.sendPolicy`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Send policy`}),(0,B.jsxs)(ds,{value:e.value,onChange:e.onChange,children:[(0,B.jsx)(Q,{value:`open`,children:`open`}),(0,B.jsx)(Q,{value:`allowlist`,children:`allowlist`}),(0,B.jsx)(Q,{value:`disabled`,children:`disabled`})]})]})})]}),(0,B.jsx)($,{name:`discord.commandAllowedUserIds`,render:({field:e})=>(0,B.jsx)(Sl,{label:`Allowed command user IDs`,value:e.value,rows:3,placeholder:`comma or newline separated`,onChange:e.onChange})}),(0,B.jsx)($,{name:`discord.sendAllowedChannelIds`,render:({field:e})=>(0,B.jsx)(Sl,{label:`Allowed outbound channel IDs`,value:e.value,rows:3,placeholder:`comma or newline separated`,onChange:e.onChange})}),(0,B.jsx)($,{name:`discord.freeResponseChannels`,render:({field:e})=>(0,B.jsx)(Sl,{label:`Free response channel IDs`,value:e.value,rows:3,placeholder:`comma or newline separated`,onChange:e.onChange})}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`discord.typingMode`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Typing mode`}),(0,B.jsxs)(ds,{value:e.value,onChange:e.onChange,children:[(0,B.jsx)(Q,{value:`instant`,children:`instant`}),(0,B.jsx)(Q,{value:`thinking`,children:`thinking`}),(0,B.jsx)(Q,{value:`streaming`,children:`streaming`}),(0,B.jsx)(Q,{value:`never`,children:`never`})]})]})}),(0,B.jsx)($,{name:`discord.ackReaction`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Ack reaction`}),(0,B.jsx)(Y,{...e,placeholder:`👀`})]})})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`discord.ackReactionScope`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Ack reaction scope`}),(0,B.jsxs)(ds,{value:e.value,onChange:e.onChange,children:[(0,B.jsx)(Q,{value:`all`,children:`all`}),(0,B.jsx)(Q,{value:`group-mentions`,children:`group-mentions`}),(0,B.jsx)(Q,{value:`direct`,children:`direct`}),(0,B.jsx)(Q,{value:`off`,children:`off`})]})]})}),(0,B.jsx)($,{name:`discord.textChunkLimit`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Text chunk limit`}),(0,B.jsx)(jc,{integer:!0,min:0,value:e.value,onValueChange:e.onChange})]})})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`discord.debounceMs`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Debounce ms`}),(0,B.jsx)(jc,{integer:!0,min:0,value:e.value,onValueChange:e.onChange})]})}),(0,B.jsx)($,{name:`discord.maxLinesPerMessage`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Max lines per message`}),(0,B.jsx)(jc,{integer:!0,min:0,value:e.value,onValueChange:e.onChange})]})})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`discord.rateLimitPerUser`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Rate limit per user`}),(0,B.jsx)(jc,{integer:!0,min:0,value:e.value,onValueChange:e.onChange})]})}),(0,B.jsx)($,{name:`discord.maxConcurrentPerChannel`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Max concurrent per channel`}),(0,B.jsx)(jc,{integer:!0,min:0,value:e.value,onValueChange:e.onChange})]})})]}),(0,B.jsx)($,{name:`discord.removeAckAfterReply`,render:({field:e})=>(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:!!e.value,onCheckedChange:e.onChange}),(0,B.jsx)(Bo,{children:(0,B.jsx)(J,{children:`Remove ack after reply`})})]})}),(0,B.jsx)(Rl,{kind:`discord`}),(0,B.jsx)(`p`,{className:`muted-copy`,children:`Discord guild defaults and explicit per-channel overrides stay intact. This page edits the transport defaults that apply across the space.`})]})}function Vl(e){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:bl(e.draft),onCheckedChange:t=>{let n=e.draft.whatsapp,r=t&&n.dmPolicy===`disabled`?`pairing`:t?n.dmPolicy:`disabled`,i=t?n.groupPolicy:`disabled`;e.form.setField(`whatsapp.dmPolicy`,r),e.form.setField(`whatsapp.groupPolicy`,i)}}),(0,B.jsx)(Bo,{children:(0,B.jsx)(J,{children:`Enabled`})})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`whatsapp.dmPolicy`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`DM policy`}),(0,B.jsxs)(ds,{value:e.value,onChange:e.onChange,children:[(0,B.jsx)(Q,{value:`open`,children:`open`}),(0,B.jsx)(Q,{value:`pairing`,children:`pairing`}),(0,B.jsx)(Q,{value:`allowlist`,children:`allowlist`}),(0,B.jsx)(Q,{value:`disabled`,children:`disabled`})]})]})}),(0,B.jsx)($,{name:`whatsapp.groupPolicy`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Group policy`}),(0,B.jsxs)(ds,{value:e.value,onChange:e.onChange,children:[(0,B.jsx)(Q,{value:`open`,children:`open`}),(0,B.jsx)(Q,{value:`allowlist`,children:`allowlist`}),(0,B.jsx)(Q,{value:`disabled`,children:`disabled`})]})]})})]}),bl(e.draft)&&!e.linked?(0,B.jsxs)(`div`,{className:`field whatsapp-pairing-field`,children:[(0,B.jsx)(`span`,{children:`Pairing QR`}),e.pairingQrText?(0,B.jsx)(`pre`,{className:`whatsapp-pairing-qr`,role:`img`,"aria-label":`WhatsApp pairing QR`,children:e.pairingQrText}):(0,B.jsx)(`p`,{className:`muted-copy`,children:e.pairingError||`Waiting for a fresh QR from the gateway.`})]}):null,(0,B.jsx)($,{name:`whatsapp.allowFrom`,render:({field:e})=>(0,B.jsx)(El,{label:`Allowed DM senders`,value:e.value,placeholder:`+14155551212 or *`,onChange:e.onChange})}),(0,B.jsx)($,{name:`whatsapp.groupAllowFrom`,render:({field:e})=>(0,B.jsx)(El,{label:`Allowed group senders`,value:e.value,placeholder:`+14155551212 or *`,onChange:e.onChange})}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`whatsapp.debounceMs`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Debounce ms`}),(0,B.jsx)(jc,{integer:!0,min:0,value:e.value,onValueChange:e.onChange})]})}),(0,B.jsx)($,{name:`whatsapp.ackReaction`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Ack reaction`}),(0,B.jsx)(Y,{...e})]})})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`whatsapp.textChunkLimit`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Text chunk limit`}),(0,B.jsx)(jc,{integer:!0,min:0,value:e.value,onValueChange:e.onChange})]})}),(0,B.jsx)($,{name:`whatsapp.mediaMaxMb`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Media max MB`}),(0,B.jsx)(jc,{integer:!0,min:0,value:e.value,onValueChange:e.onChange})]})})]}),(0,B.jsx)($,{name:`whatsapp.sendReadReceipts`,render:({field:e})=>(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:!!e.value,onCheckedChange:e.onChange}),(0,B.jsx)(Bo,{children:(0,B.jsx)(J,{children:`Send read receipts`})})]})}),(0,B.jsx)(Rl,{kind:`whatsapp`})]})}function Hl(e){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)($,{name:`telegram.enabled`,render:({field:e})=>(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:!!e.value,onCheckedChange:e.onChange}),(0,B.jsx)(Bo,{children:(0,B.jsx)(J,{children:`Enabled`})})]})}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)(zl,{label:`Bot token`,secretName:`TELEGRAM_BOT_TOKEN`,secretLabel:`token`,configValue:e.draft.telegram.botToken,configured:e.tokenConfigured,source:e.tokenSource,token:e.token,onSecretSaved:e.onSecretSaved}),(0,B.jsx)($,{name:`telegram.pollIntervalMs`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Poll interval ms`}),(0,B.jsx)(jc,{integer:!0,min:0,value:e.value,onValueChange:e.onChange})]})})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`telegram.dmPolicy`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`DM policy`}),(0,B.jsxs)(ds,{value:e.value,onChange:e.onChange,children:[(0,B.jsx)(Q,{value:`open`,children:`open`}),(0,B.jsx)(Q,{value:`allowlist`,children:`allowlist`}),(0,B.jsx)(Q,{value:`disabled`,children:`disabled`})]})]})}),(0,B.jsx)($,{name:`telegram.groupPolicy`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Group policy`}),(0,B.jsxs)(ds,{value:e.value,onChange:e.onChange,children:[(0,B.jsx)(Q,{value:`open`,children:`open`}),(0,B.jsx)(Q,{value:`allowlist`,children:`allowlist`}),(0,B.jsx)(Q,{value:`disabled`,children:`disabled`})]})]})})]}),(0,B.jsx)($,{name:`telegram.requireMention`,render:({field:e})=>(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:!!e.value,onCheckedChange:e.onChange}),(0,B.jsx)(Bo,{children:(0,B.jsx)(J,{children:`Require mention in groups`})})]})}),(0,B.jsx)($,{name:`telegram.allowFrom`,render:({field:e})=>(0,B.jsx)(El,{label:`Allowed DM senders`,value:e.value,placeholder:`numeric user id, @username, or *`,onChange:e.onChange})}),(0,B.jsx)($,{name:`telegram.groupAllowFrom`,render:({field:e})=>(0,B.jsx)(El,{label:`Allowed group senders`,value:e.value,placeholder:`numeric user id, @username, or *`,onChange:e.onChange})}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`telegram.textChunkLimit`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Text chunk limit`}),(0,B.jsx)(jc,{integer:!0,min:0,value:e.value,onValueChange:e.onChange})]})}),(0,B.jsx)($,{name:`telegram.mediaMaxMb`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Media max MB`}),(0,B.jsx)(jc,{integer:!0,min:0,value:e.value,onValueChange:e.onChange})]})})]}),(0,B.jsx)(`p`,{className:`muted-copy`,children:`Telegram inbound handling stays off until DM or group policy is opened or allowlisted.`}),xl(e.draft)?null:(0,B.jsx)(`p`,{className:`muted-copy`,children:`This page edits transport-level Telegram settings. Discord and Teams remain the only transports with per-channel override bindings.`}),(0,B.jsx)(Rl,{kind:`telegram`})]})}function Ul(e){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)($,{name:`threema.enabled`,render:({field:e})=>(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:!!e.value,onCheckedChange:e.onChange}),(0,B.jsx)(Bo,{children:(0,B.jsx)(J,{children:`Enabled`})})]})}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`threema.identity`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Gateway identity`}),(0,B.jsx)(Y,{...e,placeholder:`*HYBRID1`})]})}),(0,B.jsx)(zl,{label:`Gateway secret`,secretName:`THREEMA_GATEWAY_SECRET`,secretLabel:`secret`,configValue:e.draft.threema.secret,configured:e.secretConfigured,source:e.secretSource,token:e.token,onSecretSaved:e.onSecretSaved})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`threema.apiBaseUrl`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`API base URL`}),(0,B.jsx)(Y,{...e})]})}),(0,B.jsx)($,{name:`threema.dmPolicy`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`DM policy`}),(0,B.jsxs)(ds,{value:e.value,onChange:e.onChange,children:[(0,B.jsx)(Q,{value:`open`,children:`open`}),(0,B.jsx)(Q,{value:`allowlist`,children:`allowlist`}),(0,B.jsx)(Q,{value:`disabled`,children:`disabled`})]})]})})]}),(0,B.jsx)($,{name:`threema.allowFrom`,render:({field:e})=>(0,B.jsx)(El,{label:`Allowed senders`,value:e.value,placeholder:`threema:ABCDEFGH, threema:phone:41791234567, or *`,onChange:e.onChange})}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`threema.textChunkLimit`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Text chunk limit`}),(0,B.jsx)(jc,{integer:!0,min:0,value:e.value,onValueChange:e.onChange})]})}),(0,B.jsx)($,{name:`threema.outboundDelayMs`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Outbound delay ms`}),(0,B.jsx)(jc,{integer:!0,min:0,value:e.value,onValueChange:e.onChange})]})})]}),(0,B.jsx)(`p`,{className:`muted-copy`,children:`Threema Gateway Basic mode supports outbound text only. Inbound chat history, typing, and attachments are not available.`}),(0,B.jsx)(Rl,{kind:`threema`})]})}function Wl(e){let t=o(),n=hs(),[r,i]=(0,R.useState)(`signal-cli`),[a,s]=(0,R.useState)(`HybridClaw`),c=y({queryKey:[`signal-link`,e.token],queryFn:()=>Bt(e.token),refetchInterval:e=>{let t=e.state.data?.status;return t===`starting`||t===`qr`?2e3:!1}}).data,l=g({mutationFn:()=>zt(e.token,{cliPath:r,deviceName:a}),onSuccess:r=>{t.setQueryData([`signal-link`,e.token],r),n.success(`Signal linked-device QR started.`),t.invalidateQueries({queryKey:[`status`,e.token]})},onError:e=>{n.error(`Signal link failed`,H(e))}});return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)($,{name:`signal.enabled`,render:({field:e})=>(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:!!e.value,onCheckedChange:e.onChange}),(0,B.jsx)(Bo,{children:(0,B.jsx)(J,{children:`Enabled`})})]})}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`signal-cli path`}),(0,B.jsx)(Y,{value:r,onChange:e=>i(e.target.value),placeholder:`signal-cli`})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Device name`}),(0,B.jsx)(Y,{value:a,onChange:e=>s(e.target.value),placeholder:`HybridClaw`})]})]}),(0,B.jsxs)(`div`,{className:`field whatsapp-pairing-field`,children:[(0,B.jsx)(`span`,{children:`Linked-device QR`}),(0,B.jsx)(`div`,{className:`button-row`,children:(0,B.jsx)(Z,{type:`button`,variant:`ghost`,loading:l.isPending,disabled:!e.cliAvailable||l.isPending||c?.status===`starting`||c?.status===`qr`,onClick:()=>l.mutate(),children:l.isPending?`Starting...`:`Start QR link`})}),e.cliAvailable?c?.pairingQrText?(0,B.jsx)(`pre`,{className:`whatsapp-pairing-qr`,role:`img`,"aria-label":`Signal linked-device QR`,children:c.pairingQrText}):c?.status===`starting`?(0,B.jsx)(`p`,{className:`muted-copy`,children:`Waiting for signal-cli to print a QR.`}):c?.status===`complete`?(0,B.jsx)(`p`,{className:`muted-copy`,children:`Linked-device flow completed. Start the daemon and save the account below.`}):c?.status===`error`?(0,B.jsx)(`p`,{className:`muted-copy`,children:c.error||`Signal linked-device setup failed.`}):(0,B.jsxs)(`p`,{className:`muted-copy`,children:["Starts `signal-cli link -n HybridClaw` on the gateway host",e.cliVersion?` (${e.cliVersion})`:``,`.`]}):(0,B.jsxs)(`p`,{className:`muted-copy`,children:[`signal-cli is not available on this gateway host. Install signal-cli, use a bundled cloud amd64 gateway image, or configure an external daemon/sidecar.`,e.cliError?` ${e.cliError}`:``]})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`signal.daemonUrl`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Daemon URL`}),(0,B.jsx)(Y,{...e,placeholder:`http://127.0.0.1:8080`})]})}),(0,B.jsx)($,{name:`signal.account`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Account`}),(0,B.jsx)(Y,{...e,placeholder:`+14155550123`})]})})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`signal.dmPolicy`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`DM policy`}),(0,B.jsxs)(ds,{value:e.value,onChange:e.onChange,children:[(0,B.jsx)(Q,{value:`open`,children:`open`}),(0,B.jsx)(Q,{value:`allowlist`,children:`allowlist`}),(0,B.jsx)(Q,{value:`disabled`,children:`disabled`})]})]})}),(0,B.jsx)($,{name:`signal.groupPolicy`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Group policy`}),(0,B.jsxs)(ds,{value:e.value,onChange:e.onChange,children:[(0,B.jsx)(Q,{value:`open`,children:`open`}),(0,B.jsx)(Q,{value:`allowlist`,children:`allowlist`}),(0,B.jsx)(Q,{value:`disabled`,children:`disabled`})]})]})})]}),(0,B.jsx)($,{name:`signal.allowFrom`,render:({field:e})=>(0,B.jsx)(El,{label:`Allowed DM senders`,value:e.value,placeholder:`+14155551212, Signal UUID, or *`,onChange:e.onChange})}),(0,B.jsx)($,{name:`signal.groupAllowFrom`,render:({field:e})=>(0,B.jsx)(El,{label:`Allowed group senders`,value:e.value,placeholder:`+14155551212, Signal UUID, or *`,onChange:e.onChange})}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`signal.textChunkLimit`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Text chunk limit`}),(0,B.jsx)(jc,{integer:!0,min:0,value:e.value,onValueChange:e.onChange})]})}),(0,B.jsx)($,{name:`signal.reconnectIntervalMs`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Reconnect interval ms`}),(0,B.jsx)(jc,{integer:!0,min:0,value:e.value,onValueChange:e.onChange})]})}),(0,B.jsx)($,{name:`signal.outboundDelayMs`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Outbound delay ms`}),(0,B.jsx)(jc,{integer:!0,min:0,value:e.value,onValueChange:e.onChange})]})})]}),(0,B.jsx)(`p`,{className:`muted-copy`,children:`After scanning the QR in Signal mobile, start the daemon and save the daemon URL here. Groups stay disabled by default; start with one allowlisted DM sender.`}),(0,B.jsx)(Rl,{kind:`signal`})]})}function Gl(e){let[t,n]=(0,R.useState)(!1),[r,i]=(0,R.useState)(null),a=hs(),o=Dl(e.draft),[s,c]=(0,R.useState)(()=>o.map(()=>Ll()));(0,R.useEffect)(()=>{c(e=>e.length===o.length?e:e.length>o.length?e.slice(0,o.length):[...e,...Array.from({length:o.length-e.length},Ll)])},[o.length]);function l(t){e.form.setField(`email.accounts`,t)}function u(e,t){l(o.map((n,r)=>r===e?t(n):n))}function d(){c(e=>[...e,Ll()]),l([...o,Ol(e.draft.email)])}function f(e){c(t=>t.filter((t,n)=>n!==e)),l(o.filter((t,n)=>n!==e))}function p(t){let n={...e.draft,email:{...e.draft.email,allowFrom:t}};e.form.setDraft(n),e.onAutoSave(n)}async function m(){n(!0);try{let t=await Ft(e.token),n=t?.handles;if(!Array.isArray(n)||n.length===0){a.info(`No HybridAI agent handles found.`);return}let r=t?.credentials;if(!r){let e=n.map(e=>`${e.handle} (${e.status})`).join(`, `);a.info(`Handles found: ${e}. Could not retrieve mailbox credentials.`);return}if(r.email&&e.form.setField(`email.address`,r.email),r.imap_host&&e.form.setField(`email.imapHost`,r.imap_host),r.imap_port!=null&&e.form.setField(`email.imapPort`,r.imap_port),r.smtp_host&&e.form.setField(`email.smtpHost`,r.smtp_host),r.smtp_port!=null&&e.form.setField(`email.smtpPort`,r.smtp_port),r.password)try{await Ht(e.token,`EMAIL_PASSWORD`,r.password),e.onSecretSaved()}catch(e){a.error(`Password could not be saved`,H(e)),a.info(`Email fields were populated, but password was not saved.`);return}let i=t.handleId||`HybridAI`;a.success(`Email config loaded from ${i}.`)}catch(e){a.error(`Failed to fetch email config`,H(e))}finally{n(!1)}}async function h(t){let n=o[t];if(!n)return;let r=Il(n,e.agents);if(!r){a.info(`Select an agent before fetching a HybridAI mailbox.`);return}i(t);try{let i=await Ft(e.token,{handleId:r}),o=i?.credentials;if(!o){a.info(`Could not retrieve mailbox credentials for ${i?.handleId||r}.`);return}let s=Fl(n,i.handleId||r);if(o.password)try{await Ht(e.token,s,o.password),e.onSecretSaved()}catch(e){a.error(`Password could not be saved`,H(e)),a.info(`Mailbox credentials were not applied because the password was not saved.`);return}u(t,e=>({...e,...o.email?{address:o.email}:{},...o.imap_host?{imapHost:o.imap_host}:{},...o.imap_port==null?{}:{imapPort:o.imap_port},...o.smtp_host?{smtpHost:o.smtp_host}:{},...o.smtp_port==null?{}:{smtpPort:o.smtp_port},...o.password?{password:{source:`store`,id:s}}:{}})),a.success(`Mailbox config loaded from ${i.handleId||r}.`)}catch(e){a.error(`Failed to fetch mailbox config`,H(e))}finally{i(null)}}return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)($,{name:`email.enabled`,render:({field:e})=>(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:!!e.value,onCheckedChange:e.onChange}),(0,B.jsx)(Bo,{children:(0,B.jsx)(J,{children:`Enabled`})})]})}),e.hybridaiApiKeyConfigured?(0,B.jsx)(`div`,{className:`button-row`,children:(0,B.jsx)(Z,{type:`button`,variant:`ghost`,loading:t,disabled:t,onClick:m,children:t?`Fetching…`:`Fetch HybridAI Agent Email`})}):null,(0,B.jsx)(`div`,{className:`email-account-section-header`,children:(0,B.jsxs)(`div`,{className:`email-account-section-copy`,children:[(0,B.jsxs)(`h4`,{children:[`Default agent mailbox:`,(0,B.jsx)(`span`,{className:`email-default-agent-target`,children:Ml(e.agents)})]}),(0,B.jsx)(`p`,{children:`Inbound target; outbound fallback for agents without an additional mailbox.`})]})}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`email.address`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Default mailbox address`}),(0,B.jsx)(Y,{...e,placeholder:`bot@example.com`})]})}),(0,B.jsx)(zl,{label:`Default mailbox password`,secretName:`EMAIL_PASSWORD`,secretLabel:`password`,configValue:e.draft.email.password,configured:e.passwordConfigured,source:e.passwordSource,token:e.token,onSecretSaved:e.onSecretSaved})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`email.imapHost`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`IMAP host`}),(0,B.jsx)(Y,{...e})]})}),(0,B.jsx)($,{name:`email.smtpHost`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`SMTP host`}),(0,B.jsx)(Y,{...e})]})})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`email.imapPort`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`IMAP port`}),(0,B.jsx)(jc,{integer:!0,min:0,value:e.value,onValueChange:e.onChange})]})}),(0,B.jsx)($,{name:`email.smtpPort`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`SMTP port`}),(0,B.jsx)(jc,{integer:!0,min:0,value:e.value,onValueChange:e.onChange})]})})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`email.imapSecure`,render:({field:e})=>(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:!!e.value,onCheckedChange:e.onChange}),(0,B.jsx)(Bo,{children:(0,B.jsx)(J,{children:`IMAP secure`})})]})}),(0,B.jsx)($,{name:`email.smtpSecure`,render:({field:e})=>(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:!!e.value,onCheckedChange:e.onChange}),(0,B.jsx)(Bo,{children:(0,B.jsx)(J,{children:`SMTP secure`})})]})})]}),(0,B.jsx)($,{name:`email.folders`,render:({field:e})=>(0,B.jsx)(Sl,{label:`Folders`,value:e.value,rows:3,placeholder:`INBOX, Support`,onChange:e.onChange})}),(0,B.jsx)($,{name:`email.allowFrom`,render:({field:e})=>(0,B.jsx)(El,{label:`Allowed senders`,value:e.value,placeholder:`name@example.com, *@example.com`,onChange:e.onChange,onAdd:p})}),(0,B.jsxs)(`details`,{className:`channel-advanced-settings`,children:[(0,B.jsx)(`summary`,{children:`Advanced settings`}),(0,B.jsxs)(`div`,{className:`channel-advanced-settings-body`,children:[(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`email.pollIntervalMs`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Poll interval ms`}),(0,B.jsx)(jc,{integer:!0,min:0,value:e.value,onValueChange:e.onChange})]})}),(0,B.jsx)($,{name:`email.textChunkLimit`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Text chunk limit`}),(0,B.jsx)(jc,{integer:!0,min:0,value:e.value,onValueChange:e.onChange})]})})]}),(0,B.jsx)($,{name:`email.mediaMaxMb`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Media max MB`}),(0,B.jsx)(jc,{integer:!0,min:0,value:e.value,onValueChange:e.onChange})]})}),(0,B.jsx)(Rl,{kind:`email`})]})]}),(0,B.jsxs)(`div`,{className:`email-account-section`,children:[(0,B.jsxs)(`div`,{className:`email-account-section-header`,children:[(0,B.jsx)(`h4`,{children:`Additional agent mailboxes`}),(0,B.jsx)(Z,{type:`button`,variant:`ghost`,onClick:d,children:`Add additional mailbox`})]}),o.length===0?(0,B.jsx)(`div`,{className:`empty-state email-account-empty`,children:`No additional agent mailboxes configured.`}):(0,B.jsx)(`div`,{className:`email-account-list`,children:o.map((t,n)=>{let i=s[n]||`${t.agentId}:${t.address}:${t.imapHost}:${t.smtpHost}`,a=e.agents.some(e=>e.id===t.agentId),o=Il(t,e.agents),c=r===n;return(0,B.jsxs)(`div`,{className:`email-account-row`,children:[(0,B.jsxs)(`div`,{className:`email-account-row-header`,children:[(0,B.jsx)(`strong`,{children:t.address||`Mailbox ${n+1}`}),(0,B.jsxs)(`div`,{className:`email-account-row-actions`,children:[e.hybridaiApiKeyConfigured?(0,B.jsx)(Z,{type:`button`,variant:`ghost`,loading:c,disabled:r!==null||!o,title:o?`Fetch HybridAI mailbox for ${o}`:`Select an agent before fetching a HybridAI mailbox`,onClick:()=>h(n),children:`Fetch HybridAI mailbox`}):null,(0,B.jsx)(Z,{"aria-label":`Remove mailbox ${n+1}`,title:`Remove mailbox ${n+1}`,className:`email-account-remove`,type:`button`,variant:`ghost`,size:`icon`,onClick:()=>f(n),children:(0,B.jsx)(Fr,{width:`16`,height:`16`})})]})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Agent`}),e.agents.length>0?(0,B.jsxs)(ds,{value:t.agentId,onChange:e=>u(n,t=>({...t,agentId:e.target.value})),children:[(0,B.jsx)(Q,{value:``,children:`Select agent`}),e.agents.map(e=>(0,B.jsx)(Q,{value:e.id,children:jl(e)},e.id)),t.agentId&&!a?(0,B.jsx)(Q,{value:t.agentId,children:t.agentId}):null]}):(0,B.jsx)(Y,{value:t.agentId,placeholder:`sales`,onChange:e=>u(n,t=>({...t,agentId:e.target.value}))})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Mailbox address`}),(0,B.jsx)(Y,{type:`email`,value:t.address,placeholder:`sales@example.com`,onChange:e=>u(n,t=>({...t,address:e.target.value}))})]})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Password SecretRef id`}),(0,B.jsx)(Y,{value:kl(t),placeholder:`SALES_EMAIL_PASSWORD`,onChange:e=>u(n,t=>Al(t,e.target.value.trim()))})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Mailbox IMAP host`}),(0,B.jsx)(Y,{value:t.imapHost,onChange:e=>u(n,t=>({...t,imapHost:e.target.value}))})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Mailbox SMTP host`}),(0,B.jsx)(Y,{value:t.smtpHost,onChange:e=>u(n,t=>({...t,smtpHost:e.target.value}))})]})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Mailbox IMAP port`}),(0,B.jsx)(jc,{integer:!0,min:0,value:t.imapPort,onValueChange:e=>u(n,t=>({...t,imapPort:e}))})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Mailbox SMTP port`}),(0,B.jsx)(jc,{integer:!0,min:0,value:t.smtpPort,onValueChange:e=>u(n,t=>({...t,smtpPort:e}))})]})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:t.imapSecure,onCheckedChange:e=>u(n,t=>({...t,imapSecure:e}))}),(0,B.jsx)(Bo,{children:(0,B.jsx)(J,{children:`Mailbox IMAP secure`})})]}),(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:t.smtpSecure,onCheckedChange:e=>u(n,t=>({...t,smtpSecure:e}))}),(0,B.jsx)(Bo,{children:(0,B.jsx)(J,{children:`Mailbox SMTP secure`})})]})]}),(0,B.jsx)(Sl,{label:`Mailbox folders`,value:t.folders,rows:2,placeholder:`INBOX, Support`,onChange:e=>u(n,t=>({...t,folders:e}))}),(0,B.jsx)(El,{label:`Mailbox allowed senders`,value:t.allowFrom,placeholder:`name@example.com, *@example.com`,onChange:e=>u(n,t=>({...t,allowFrom:e}))}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Mailbox poll interval ms`}),(0,B.jsx)(jc,{integer:!0,min:0,value:t.pollIntervalMs,onValueChange:e=>u(n,t=>({...t,pollIntervalMs:e}))})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Mailbox media max MB`}),(0,B.jsx)(jc,{integer:!0,min:0,value:t.mediaMaxMb,onValueChange:e=>u(n,t=>({...t,mediaMaxMb:e}))})]})]})]},i)})})]})]})}function Kl(e){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)($,{name:`voice.enabled`,render:({field:e})=>(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:!!e.value,onCheckedChange:e.onChange}),(0,B.jsx)(Bo,{children:(0,B.jsx)(J,{children:`Enabled`})})]})}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`voice.twilio.accountSid`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Twilio account SID`}),(0,B.jsx)(Y,{...e,placeholder:`AC...`})]})}),(0,B.jsx)($,{name:`voice.twilio.fromNumber`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`From number`}),(0,B.jsx)(Y,{...e,placeholder:`+14155550123`})]})})]}),(0,B.jsx)(zl,{label:`Twilio auth token`,secretName:`TWILIO_AUTH_TOKEN`,secretLabel:`token`,configValue:e.draft.voice.twilio.authToken,configured:e.authTokenConfigured,source:e.authTokenSource,token:e.token,onSecretSaved:e.onSecretSaved}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`voice.webhookPath`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Webhook path`}),(0,B.jsx)(Y,{...e,placeholder:`/voice`})]})}),(0,B.jsx)($,{name:`voice.maxConcurrentCalls`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Max concurrent calls`}),(0,B.jsx)(jc,{integer:!0,min:0,value:e.value,onValueChange:e.onChange})]})})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`voice.relay.ttsProvider`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`TTS provider`}),(0,B.jsxs)(ds,{value:e.value,onChange:e.onChange,children:[(0,B.jsx)(Q,{value:`default`,children:`default`}),(0,B.jsx)(Q,{value:`google`,children:`google`}),(0,B.jsx)(Q,{value:`amazon`,children:`amazon`})]})]})}),(0,B.jsx)($,{name:`voice.relay.voice`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Voice`}),(0,B.jsx)(Y,{...e,placeholder:`en-US-Journey-D`})]})})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`voice.relay.transcriptionProvider`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Transcription provider`}),(0,B.jsxs)(ds,{value:e.value,onChange:e.onChange,children:[(0,B.jsx)(Q,{value:`default`,children:`default`}),(0,B.jsx)(Q,{value:`deepgram`,children:`deepgram`}),(0,B.jsx)(Q,{value:`google`,children:`google`})]})]})}),(0,B.jsx)($,{name:`voice.relay.language`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Language`}),(0,B.jsx)(Y,{...e,placeholder:`en-US`})]})})]}),(0,B.jsx)($,{name:`voice.relay.interruptible`,render:({field:e})=>(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:!!e.value,onCheckedChange:e.onChange}),(0,B.jsx)(Bo,{children:(0,B.jsx)(J,{children:`Interruptible`})})]})}),(0,B.jsx)($,{name:`voice.relay.welcomeGreeting`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Welcome greeting`}),(0,B.jsx)(Jo,{rows:3,...e})]})}),(0,B.jsx)(Rl,{kind:`voice`}),(0,B.jsx)(`p`,{className:`muted-copy`,children:`Voice uses Twilio ConversationRelay. Expose the configured webhook path over public HTTPS and WSS so Twilio can reach both the webhook and the relay socket.`})]})}function ql(e){let t=rl(e.draft),n=il(e.draft);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`key-value-grid`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Team defaults`}),(0,B.jsx)(`strong`,{children:String(t)}),(0,B.jsx)(`small`,{children:`Per-team rules preserved`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Channel overrides`}),(0,B.jsx)(`strong`,{children:String(n)}),(0,B.jsx)(`small`,{children:`Explicit Teams channel entries`})]})]}),(0,B.jsx)($,{name:`msteams.enabled`,render:({field:e})=>(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:!!e.value,onCheckedChange:e.onChange}),(0,B.jsx)(Bo,{children:(0,B.jsx)(J,{children:`Enabled`})})]})}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`msteams.appId`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`App ID`}),(0,B.jsx)(Y,{...e})]})}),(0,B.jsx)($,{name:`msteams.tenantId`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Tenant ID`}),(0,B.jsx)(Y,{...e})]})})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`msteams.webhook.path`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Webhook path`}),(0,B.jsx)(Y,{...e})]})}),(0,B.jsx)($,{name:`msteams.webhook.port`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Webhook port`}),(0,B.jsx)(jc,{integer:!0,min:0,max:65535,value:e.value,onValueChange:e.onChange})]})})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`msteams.dmPolicy`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`DM policy`}),(0,B.jsxs)(ds,{value:e.value,onChange:e.onChange,children:[(0,B.jsx)(Q,{value:`open`,children:`open`}),(0,B.jsx)(Q,{value:`allowlist`,children:`allowlist`}),(0,B.jsx)(Q,{value:`disabled`,children:`disabled`})]})]})}),(0,B.jsx)($,{name:`msteams.groupPolicy`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Group policy`}),(0,B.jsxs)(ds,{value:e.value,onChange:e.onChange,children:[(0,B.jsx)(Q,{value:`open`,children:`open`}),(0,B.jsx)(Q,{value:`allowlist`,children:`allowlist`}),(0,B.jsx)(Q,{value:`disabled`,children:`disabled`})]})]})})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`msteams.requireMention`,render:({field:e})=>(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:!!e.value,onCheckedChange:e.onChange}),(0,B.jsx)(Bo,{children:(0,B.jsx)(J,{children:`Require mention`})})]})}),(0,B.jsx)($,{name:`msteams.replyStyle`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Reply style`}),(0,B.jsxs)(ds,{value:e.value,onChange:e.onChange,children:[(0,B.jsx)(Q,{value:`thread`,children:`thread`}),(0,B.jsx)(Q,{value:`top-level`,children:`top-level`})]})]})})]}),(0,B.jsx)($,{name:`msteams.allowFrom`,render:({field:e})=>(0,B.jsx)(El,{label:`Allowed AAD object IDs`,value:e.value,placeholder:`AAD object ID or *`,onChange:e.onChange})}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`msteams.textChunkLimit`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Text chunk limit`}),(0,B.jsx)(jc,{integer:!0,min:0,value:e.value,onValueChange:e.onChange})]})}),(0,B.jsx)($,{name:`msteams.mediaMaxMb`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Media max MB`}),(0,B.jsx)(jc,{integer:!0,min:0,value:e.value,onValueChange:e.onChange})]})})]}),(0,B.jsx)(Rl,{kind:`msteams`})]})}function Jl(e){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)($,{name:`slack.enabled`,render:({field:e})=>(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:!!e.value,onCheckedChange:e.onChange}),(0,B.jsx)(Bo,{children:(0,B.jsx)(J,{children:`Enabled`})})]})}),(0,B.jsx)(zl,{label:`Bot token`,secretName:`SLACK_BOT_TOKEN`,secretLabel:`token`,configured:e.botTokenConfigured,source:e.botTokenSource,token:e.token,onSecretSaved:e.onSecretSaved}),(0,B.jsx)(zl,{label:`App token`,secretName:`SLACK_APP_TOKEN`,secretLabel:`token`,configured:e.appTokenConfigured,source:e.appTokenSource,token:e.token,onSecretSaved:e.onSecretSaved}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`slack.dmPolicy`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`DM policy`}),(0,B.jsxs)(ds,{value:e.value,onChange:e.onChange,children:[(0,B.jsx)(Q,{value:`open`,children:`open`}),(0,B.jsx)(Q,{value:`allowlist`,children:`allowlist`}),(0,B.jsx)(Q,{value:`disabled`,children:`disabled`})]})]})}),(0,B.jsx)($,{name:`slack.groupPolicy`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Group policy`}),(0,B.jsxs)(ds,{value:e.value,onChange:e.onChange,children:[(0,B.jsx)(Q,{value:`open`,children:`open`}),(0,B.jsx)(Q,{value:`allowlist`,children:`allowlist`}),(0,B.jsx)(Q,{value:`disabled`,children:`disabled`})]})]})})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`slack.requireMention`,render:({field:e})=>(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:!!e.value,onCheckedChange:e.onChange}),(0,B.jsx)(Bo,{children:(0,B.jsx)(J,{children:`Require mention`})})]})}),(0,B.jsx)($,{name:`slack.replyStyle`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Reply style`}),(0,B.jsxs)(ds,{value:e.value,onChange:e.onChange,children:[(0,B.jsx)(Q,{value:`thread`,children:`thread`}),(0,B.jsx)(Q,{value:`top-level`,children:`top-level`})]})]})})]}),(0,B.jsx)($,{name:`slack.allowFrom`,render:({field:e})=>(0,B.jsx)(El,{label:`Allowed DM Slack user IDs`,value:e.value,placeholder:`Slack user ID or *`,onChange:e.onChange})}),(0,B.jsx)($,{name:`slack.groupAllowFrom`,render:({field:e})=>(0,B.jsx)(El,{label:`Allowed channel Slack user IDs`,value:e.value,placeholder:`Slack user ID or *`,onChange:e.onChange})}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`slack.textChunkLimit`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Text chunk limit`}),(0,B.jsx)(jc,{integer:!0,min:0,value:e.value,onValueChange:e.onChange})]})}),(0,B.jsx)($,{name:`slack.mediaMaxMb`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Media max MB`}),(0,B.jsx)(jc,{integer:!0,min:0,value:e.value,onValueChange:e.onChange})]})})]}),(0,B.jsx)(`p`,{className:`muted-copy`,children:`Slack runs through Socket Mode. HybridClaw needs both a bot token and an app token before the gateway can connect.`}),(0,B.jsx)(Rl,{kind:`slack`})]})}function Yl(e){let t=hs(),n=Object.keys(e.draft.slackWebhook.webhooks).sort(),[r,i]=(0,R.useState)(n[0]||`default`),[a,o]=(0,R.useState)(``),[s,c]=(0,R.useState)(``),[l,u]=(0,R.useState)(``),[d,f]=(0,R.useState)(``),p=e.draft.slackWebhook.webhooks[r],m=g({mutationFn:async()=>Lt(e.token,{target:r,webhookUrl:a.trim()||void 0,defaultUsername:s,defaultIconEmoji:l,defaultIconUrl:d}),onSuccess:n=>{e.onConfigSaved(n.config),o(``),t.success(`Slack webhook target saved.`)},onError:e=>{t.error(`Save failed`,H(e))}});return(0,R.useEffect)(()=>{let t=e.draft.slackWebhook.webhooks[r];c(t?.defaultUsername||``),u(t?.defaultIconEmoji||``),f(t?.defaultIconUrl||``)},[e.draft.slackWebhook.webhooks,r]),(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)($,{name:`slackWebhook.enabled`,render:({field:e})=>(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:!!e.value,onCheckedChange:e.onChange}),(0,B.jsx)(Bo,{children:(0,B.jsx)(J,{children:`Enabled`})})]})}),(0,B.jsxs)(`div`,{className:`field`,children:[(0,B.jsx)(`span`,{children:`Webhook targets`}),(0,B.jsx)(`div`,{className:`readonly-value`,children:n.length>0?n.join(`, `):`none`})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Target`}),(0,B.jsx)(Y,{list:`slack-webhook-targets`,value:r,onChange:e=>i(e.target.value)}),(0,B.jsx)(`datalist`,{id:`slack-webhook-targets`,children:n.map(e=>(0,B.jsx)(Q,{value:e},e))})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Webhook URL`}),(0,B.jsx)(Y,{type:`password`,autoComplete:`off`,placeholder:p?`leave blank to keep current URL`:`required`,value:a,onChange:e=>o(e.target.value)})]})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Username`}),(0,B.jsx)(Y,{value:s,onChange:e=>c(e.target.value)})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Icon emoji`}),(0,B.jsx)(Y,{value:l,onChange:e=>u(e.target.value)})]})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Icon URL`}),(0,B.jsx)(Y,{value:d,onChange:e=>f(e.target.value)})]}),(0,B.jsx)(`div`,{className:`button-row`,children:(0,B.jsx)(`button`,{className:`secondary-button`,type:`button`,disabled:m.isPending,onClick:()=>m.mutate(),children:m.isPending?`Saving...`:`Save webhook target`})}),(0,B.jsx)(`p`,{className:`muted-copy`,children:`Webhook URLs are stored as encrypted runtime secrets and are never shown after save.`}),(0,B.jsx)(Rl,{kind:`slack_webhook`})]})}function Xl(e){let t=hs(),n=Object.keys(e.draft.discordWebhook.webhooks).sort(),[r,i]=(0,R.useState)(n[0]||`default`),[a,o]=(0,R.useState)(``),[s,c]=(0,R.useState)(``),[l,u]=(0,R.useState)(``),d=e.draft.discordWebhook.webhooks[r],f=g({mutationFn:async()=>Rt(e.token,{target:r,webhookUrl:a.trim()||void 0,defaultUsername:s,defaultAvatarUrl:l}),onSuccess:n=>{e.onConfigSaved(n.config),o(``),t.success(`Discord webhook target saved.`)},onError:e=>{t.error(`Save failed`,H(e))}});return(0,R.useEffect)(()=>{let t=e.draft.discordWebhook.webhooks[r];c(t?.defaultUsername||``),u(t?.defaultAvatarUrl||``)},[e.draft.discordWebhook.webhooks,r]),(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)($,{name:`discordWebhook.enabled`,render:({field:e})=>(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:!!e.value,onCheckedChange:e.onChange}),(0,B.jsx)(Bo,{children:(0,B.jsx)(J,{children:`Enabled`})})]})}),(0,B.jsxs)(`div`,{className:`field`,children:[(0,B.jsx)(`span`,{children:`Webhook targets`}),(0,B.jsx)(`div`,{className:`readonly-value`,children:n.length>0?n.join(`, `):`none`})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Target`}),(0,B.jsx)(Y,{list:`discord-webhook-targets`,value:r,onChange:e=>i(e.target.value)}),(0,B.jsx)(`datalist`,{id:`discord-webhook-targets`,children:n.map(e=>(0,B.jsx)(Q,{value:e},e))})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Webhook URL`}),(0,B.jsx)(Y,{type:`password`,autoComplete:`off`,placeholder:d?`leave blank to keep current URL`:`required`,value:a,onChange:e=>o(e.target.value)})]})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Username`}),(0,B.jsx)(Y,{value:s,onChange:e=>c(e.target.value)})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Avatar URL`}),(0,B.jsx)(Y,{value:l,onChange:e=>u(e.target.value)})]})]}),(0,B.jsx)(`div`,{className:`button-row`,children:(0,B.jsx)(`button`,{className:`secondary-button`,type:`button`,disabled:f.isPending,onClick:()=>f.mutate(),children:f.isPending?`Saving...`:`Save webhook target`})}),(0,B.jsx)(`p`,{className:`muted-copy`,children:`Webhook URLs are stored as encrypted runtime secrets and are never shown after save.`}),(0,B.jsx)(Rl,{kind:`discord_webhook`})]})}function Zl(e){let t=e.draft.imessage.backend===`bluebubbles`;return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)($,{name:`imessage.enabled`,render:({field:e})=>(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:!!e.value,onCheckedChange:e.onChange}),(0,B.jsx)(Bo,{children:(0,B.jsx)(J,{children:`Enabled`})})]})}),(0,B.jsx)($,{name:`imessage.backend`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Backend`}),(0,B.jsxs)(ds,{value:e.value,onChange:e.onChange,children:[(0,B.jsx)(Q,{value:`local`,children:`local`}),(0,B.jsx)(Q,{value:`bluebubbles`,children:`remote`})]})]})}),t?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`imessage.serverUrl`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Server URL`}),(0,B.jsx)(Y,{...e})]})}),(0,B.jsx)(zl,{label:`Password`,secretName:`IMESSAGE_PASSWORD`,secretLabel:`password`,configValue:e.draft.imessage.password,configured:e.passwordConfigured,source:e.passwordSource,token:e.token,onSecretSaved:e.onSecretSaved})]}),(0,B.jsx)($,{name:`imessage.webhookPath`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Webhook path`}),(0,B.jsx)(Y,{...e})]})}),(0,B.jsx)($,{name:`imessage.allowPrivateNetwork`,render:({field:e})=>(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:!!e.value,onCheckedChange:e.onChange}),(0,B.jsx)(Bo,{children:(0,B.jsx)(J,{children:`Allow private network`})})]})})]}):(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`imessage.cliPath`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`CLI path`}),(0,B.jsx)(Y,{...e})]})}),(0,B.jsx)($,{name:`imessage.dbPath`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Database path`}),(0,B.jsx)(Y,{...e})]})})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`imessage.dmPolicy`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`DM policy`}),(0,B.jsxs)(ds,{value:e.value,onChange:e.onChange,children:[(0,B.jsx)(Q,{value:`open`,children:`open`}),(0,B.jsx)(Q,{value:`allowlist`,children:`allowlist`}),(0,B.jsx)(Q,{value:`disabled`,children:`disabled`})]})]})}),(0,B.jsx)($,{name:`imessage.groupPolicy`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Group policy`}),(0,B.jsxs)(ds,{value:e.value,onChange:e.onChange,children:[(0,B.jsx)(Q,{value:`open`,children:`open`}),(0,B.jsx)(Q,{value:`allowlist`,children:`allowlist`}),(0,B.jsx)(Q,{value:`disabled`,children:`disabled`})]})]})})]}),(0,B.jsx)($,{name:`imessage.allowFrom`,render:({field:e})=>(0,B.jsx)(El,{label:`Allowed DM senders`,value:e.value,placeholder:`phone, email, or chat:id`,onChange:e.onChange})}),(0,B.jsx)($,{name:`imessage.groupAllowFrom`,render:({field:e})=>(0,B.jsx)(El,{label:`Allowed group senders`,value:e.value,placeholder:`phone, email, or chat:id`,onChange:e.onChange})}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`imessage.pollIntervalMs`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:t?`Webhook / poll interval ms`:`Poll interval ms`}),(0,B.jsx)(jc,{integer:!0,min:0,value:e.value,onValueChange:e.onChange})]})}),(0,B.jsx)($,{name:`imessage.debounceMs`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Debounce ms`}),(0,B.jsx)(jc,{integer:!0,min:0,value:e.value,onValueChange:e.onChange})]})})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsx)($,{name:`imessage.textChunkLimit`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Text chunk limit`}),(0,B.jsx)(jc,{integer:!0,min:0,value:e.value,onValueChange:e.onChange})]})}),(0,B.jsx)($,{name:`imessage.mediaMaxMb`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Media max MB`}),(0,B.jsx)(jc,{integer:!0,min:0,value:e.value,onValueChange:e.onChange})]})})]}),(0,B.jsx)(Rl,{kind:`imessage`})]})}function Ql(e,t,n,r,i,a,o,s,c,l,u,d){switch(e){case`discord`:return(0,B.jsx)(Bl,{draft:t,form:n,tokenConfigured:i.discord.configured,tokenSource:i.discord.source,token:r,onSecretSaved:d});case`whatsapp`:return(0,B.jsx)(Vl,{draft:t,form:n,linked:o.linked,pairingQrText:o.pairingQrText,pairingError:o.pairingError});case`slack`:return(0,B.jsx)(Jl,{draft:t,form:n,botTokenConfigured:i.slack.botConfigured,botTokenSource:i.slack.botSource,appTokenConfigured:i.slack.appConfigured,appTokenSource:i.slack.appSource,token:r,onSecretSaved:d});case`slack_webhook`:return(0,B.jsx)(Yl,{draft:t,onConfigSaved:l,token:r,form:n});case`discord_webhook`:return(0,B.jsx)(Xl,{draft:t,onConfigSaved:l,token:r,form:n});case`telegram`:return(0,B.jsx)(Hl,{draft:t,form:n,tokenConfigured:i.telegram.configured,tokenSource:i.telegram.source,token:r,onSecretSaved:d});case`signal`:return(0,B.jsx)(Wl,{draft:t,form:n,token:r,cliAvailable:s.cliAvailable,cliVersion:s.cliVersion,cliError:s.cliError});case`threema`:return(0,B.jsx)(Ul,{draft:t,form:n,secretConfigured:i.threema.configured,secretSource:i.threema.source,token:r,onSecretSaved:d});case`voice`:return(0,B.jsx)(Kl,{draft:t,form:n,authTokenConfigured:i.voice.configured,authTokenSource:i.voice.source,token:r,onSecretSaved:d});case`email`:return(0,B.jsx)(Gl,{draft:t,form:n,passwordConfigured:i.email.configured,passwordSource:i.email.source,hybridaiApiKeyConfigured:a,agents:c,token:r,onAutoSave:u,onSecretSaved:d});case`msteams`:return(0,B.jsx)(ql,{draft:t,form:n});case`imessage`:return(0,B.jsx)(Zl,{draft:t,form:n,passwordConfigured:i.imessage.configured,passwordSource:i.imessage.source,token:r,onSecretSaved:d})}}function $l(){let e=Gn(),t=o(),n=hs(),[r,i]=(0,R.useState)(null),a=y({queryKey:[`config`,e.token],queryFn:()=>Mt(e.token)}),s=y({queryKey:[`status`,e.token],queryFn:()=>je(e.token),initialData:e.gatewayStatus,refetchInterval:3e3}),c=y({queryKey:[`admin-agents`,e.token],queryFn:()=>pt(e.token),enabled:r===`email`}),l=Dc({source:a.data?.config}),{draft:u,isDirty:d,commit:f}=l,p=Fc({mutationFn:t=>It(e.token,t),onSuccess:r=>{t.setQueryData([`config`,e.token],r),f(r.config),n.success(`Channel settings saved.`)},onError:e=>{n.error(`Save failed`,e.message)},invalidates:[[`status`,e.token],[`overview`]]}),m=u?vl(u,{discordTokenConfigured:s.data?.discord?.tokenConfigured,discordWebhookDefaultConfigured:s.data?.discordWebhook?.defaultTargetConfigured,slackBotTokenConfigured:s.data?.slack?.botTokenConfigured,slackAppTokenConfigured:s.data?.slack?.appTokenConfigured,slackWebhookDefaultConfigured:s.data?.slackWebhook?.defaultTargetConfigured,telegramTokenConfigured:s.data?.telegram?.tokenConfigured,threemaSecretConfigured:s.data?.threema?.secretConfigured,signalDaemonUrlConfigured:s.data?.signal?.daemonUrlConfigured,signalAccountConfigured:s.data?.signal?.accountConfigured,signalCliAvailable:s.data?.signal?.cliAvailable,voiceAuthTokenConfigured:s.data?.voice?.authTokenConfigured,whatsappLinked:s.data?.whatsapp?.linked,emailPasswordConfigured:s.data?.email?.passwordConfigured,imessagePasswordConfigured:s.data?.imessage?.passwordConfigured}):[];(0,R.useEffect)(()=>{let e=m[0];e&&i(t=>{let n=window.location.hash.replace(/^#/,``),r=m.find(e=>e.kind===n);return r?r.kind:t&&m.some(e=>e.kind===t)?t:e.kind})},[m]),(0,R.useEffect)(()=>{let e=window.location.hash.replace(/^#/,``);!r||r!==e||window.setTimeout(()=>{let e=document.getElementById(r);typeof e?.scrollIntoView==`function`&&e.scrollIntoView({block:`start`})},0)},[r]);let h=p.reset;if((0,R.useEffect)(()=>{d&&h()},[d,h]),a.isLoading&&!u)return(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading channel settings...`});if(!u)return(0,B.jsx)(`div`,{className:`empty-state`,children:`Channel settings are unavailable.`});let g=m.find(e=>e.kind===r)??m[0]??null,_={discord:{configured:s.data?.discord?.tokenConfigured??!1,source:s.data?.discord?.tokenSource??null},slack:{botConfigured:s.data?.slack?.botTokenConfigured??!1,botSource:s.data?.slack?.botTokenSource??null,appConfigured:s.data?.slack?.appTokenConfigured??!1,appSource:s.data?.slack?.appTokenSource??null},telegram:{configured:s.data?.telegram?.tokenConfigured??!1,source:s.data?.telegram?.tokenSource??null},threema:{configured:s.data?.threema?.secretConfigured??!1,source:s.data?.threema?.secretSource??null},voice:{configured:s.data?.voice?.authTokenConfigured??!1,source:s.data?.voice?.authTokenSource??null},email:{configured:s.data?.email?.passwordConfigured??!1,source:s.data?.email?.passwordSource??null},imessage:{configured:s.data?.imessage?.passwordConfigured??!1,source:s.data?.imessage?.passwordSource??null}},v={linked:s.data?.whatsapp?.linked??!1,pairingQrText:s.data?.whatsapp?.pairingQrText??null,pairingError:s.data?.whatsapp?.pairingError??null},b={cliAvailable:s.data?.signal?.cliAvailable??!1,cliVersion:s.data?.signal?.cliVersion??null,cliError:s.data?.signal?.cliError??null},x=s.data?.hybridai?.apiKeyConfigured??!1;return(0,B.jsx)(`div`,{className:`page-stack`,children:(0,B.jsxs)(`div`,{className:`two-column-grid channels-layout`,children:[(0,B.jsx)(U,{children:(0,B.jsx)(`div`,{className:`list-stack selectable-list channel-catalog`,children:m.map(e=>(0,B.jsxs)(`button`,{className:e.kind===g?.kind?`selectable-row active channel-selectable-row`:`selectable-row channel-selectable-row`,type:`button`,onClick:()=>i(e.kind),children:[(0,B.jsxs)(`div`,{className:`channel-row-main`,children:[(0,B.jsx)(_c,{kind:e.kind}),(0,B.jsxs)(`div`,{className:`channel-row-copy`,children:[(0,B.jsx)(`strong`,{children:e.label}),(0,B.jsx)(`small`,{children:e.summary})]})]}),(0,B.jsx)(`div`,{className:`row-status-stack`,children:(0,B.jsx)(`span`,{className:`channel-status-badge channel-status-${e.statusTone}`,children:e.statusLabel})})]},e.kind))})}),(0,B.jsx)(Oc,{form:l,onSubmit:()=>p.mutate(u),children:(0,B.jsxs)(U,{id:g?.kind,variant:`muted`,children:[(0,B.jsx)(W,{children:(0,B.jsx)(G,{children:g?`${g.label} settings`:`Channels`})}),(0,B.jsx)(K,{children:(0,B.jsxs)(`div`,{className:`stack-form`,children:[g?Ql(g.kind,u,l,e.token,_,x,v,b,c.data||[],n=>{let r={path:a.data?.path||``,config:n};t.setQueryData([`config`,e.token],r),f(n),t.invalidateQueries({queryKey:[`status`,e.token]})},e=>p.mutate(e),()=>{t.invalidateQueries({queryKey:[`status`,e.token]})}):null,(0,B.jsxs)(`div`,{className:`button-row`,children:[(0,B.jsx)(Z,{type:`submit`,loading:p.isPending,disabled:!d||p.isPending,children:p.isPending?`Saving...`:`Save channel settings`}),(0,B.jsx)(Z,{variant:`ghost`,type:`button`,disabled:!d||!a.data,onClick:()=>{a.data&&(p.reset(),l.discard())},children:`Reset changes`})]})]})})]})})]})})}var eu=[`fatal`,`error`,`warn`,`info`,`debug`,`trace`,`silent`];function tu(e){let{isDirty:t,title:n=`Discard unsaved changes?`,description:r=`You have unsaved edits. Leaving this page will discard them.`,keepLabel:i=`Keep editing`,discardLabel:a=`Discard and leave`}=e,o=M({shouldBlockFn:({next:e,current:n})=>t&&e.pathname!==n.pathname,enableBeforeUnload:()=>t,withResolver:!0});return{dialog:(0,B.jsx)(ri,{open:o.status===`blocked`,onOpenChange:e=>{!e&&o.status===`blocked`&&o.reset()},children:(0,B.jsxs)(ii,{role:`alertdialog`,size:`sm`,children:[(0,B.jsxs)(ai,{children:[(0,B.jsx)(oi,{children:n}),(0,B.jsx)(si,{children:r})]}),(0,B.jsxs)(ci,{children:[(0,B.jsx)(Z,{variant:`ghost`,onClick:()=>{o.status===`blocked`&&o.reset()},children:i}),(0,B.jsx)(Z,{variant:`danger`,onClick:()=>{o.status===`blocked`&&o.proceed()},children:a})]})]})})}}function nu(e,t,n){return e.includes(t)?t:n}function ru(e,t){return e.includes(t)}var iu={page:`_page_4ys0b_1`,content:`_content_4ys0b_9`,path:`_path_4ys0b_16`,statusInline:`_statusInline_4ys0b_21`,statusDot:`_statusDot_4ys0b_36`,formNote:`_formNote_4ys0b_45`,sectionDescription:`_sectionDescription_4ys0b_61`,sectionCard:`_sectionCard_4ys0b_66`,jsonField:`_jsonField_4ys0b_71`,poolStatusPending:`_poolStatusPending_4ys0b_75`,jsonEditor:`_jsonEditor_4ys0b_80`,navigationList:`_navigationList_4ys0b_85`,navigationRow:`_navigationRow_4ys0b_90`,navigationControl:`_navigationControl_4ys0b_100`,unavailable:`_unavailable_4ys0b_104`};function au(e){return JSON.stringify(e,null,2)}var ou=`main`,su=[{value:`local`,label:`Local (Playwright)`},{value:`camofox`,label:`Camoufox (anti-detection)`},{value:`managed-cloud`,label:`Managed cloud (Docker pool)`},{value:`browser-use-cloud`,label:`Browser Use cloud`},{value:`mac-cua`,label:`Mac CUA (native browser)`}],cu=/^\d+(?:\.\d+)?[kKmMgG]?$/,lu=48,uu=`(?:/(?!/).*|https?://.+)`,du=`Use a local path starting with / or an http(s) URL.`,fu=`(?:|/(?!/).*|https?://.+)`,pu=`Use a local image path starting with / or an http(s) image URL.`,mu={href:``,label:``};function hu(){return{provider:`local`,allowPrivateNetwork:!1,local:{profileDir:``,headed:!1},camofox:{profileDir:``,headed:!1},managedCloud:{endpointUrl:`http://127.0.0.1:8787`,poolTokenRef:void 0,defaultTenantId:``,pricing:{actionUsd:0}},browserUseCloud:{apiKeyRef:void 0,projectId:``,profileId:``,region:``,keepAlive:!1,pricing:{browserUsdPerMinute:0,actionUsd:0}},macCua:{browser:`chrome`,driverCommand:``,driverArgs:[],screenshotMode:`som`}}}function gu(e){try{let t=new URL(e),n=t.hostname.toLowerCase();return t.protocol===`http:`&&(n===`localhost`||n===`127.0.0.1`||n===`::1`)}catch{return!1}}function _u(e){return e.provider!==`managed-cloud`||!gu(e.managedCloud.endpointUrl)||e.managedCloud.defaultTenantId.trim()?e:{...e,managedCloud:{...e.managedCloud,defaultTenantId:ou}}}function vu(e){return _u({...hu(),...e.browser??{},local:{...hu().local,...e.browser?.local??{}},camofox:{...hu().camofox,...e.browser?.camofox??{}},managedCloud:{...hu().managedCloud,...e.browser?.managedCloud??{},pricing:{...hu().managedCloud.pricing,...e.browser?.managedCloud?.pricing??{}}},browserUseCloud:{...hu().browserUseCloud,...e.browser?.browserUseCloud??{},pricing:{...hu().browserUseCloud.pricing,...e.browser?.browserUseCloud?.pricing??{}}},macCua:{...hu().macCua,...e.browser?.macCua??{}}})}function yu(e){return Array.isArray(e.ui?.navigation)?e.ui.navigation:ya.map(e=>({...e}))}function bu(e){return e.trim()===``?`Required.`:e.length>lu?`Must be at most ${lu} characters.`:null}function xu(e){let t=e.trim();if(t===``)return`Required.`;if(t.startsWith(`/`)){if(t.startsWith(`//`))return du;try{return new URL(t,`http://127.0.0.1`),null}catch{return du}}try{let e=new URL(t);return e.protocol===`http:`||e.protocol===`https:`?null:du}catch{return du}}function Su(e){let t=(e??``).trim();if(t===``)return null;if(t.startsWith(`/`)){if(t.startsWith(`//`))return pu;try{return new URL(t,`http://127.0.0.1`),null}catch{return pu}}try{let e=new URL(t);return e.protocol===`http:`||e.protocol===`https:`?null:pu}catch{return pu}}function Cu(e,t){return e&&{...e,browser:t(vu(e))}}function wu(e,t){return e&&{...e,ui:{...e.ui??{},navigation:t(yu(e))}}}function Tu(e,t,n){e(e=>Cu(e,e=>({...e,[t]:{...e[t],...n}})))}function Eu(e,t,n){e(e=>Cu(e,e=>({...e,[t]:{...e[t],pricing:{...e[t].pricing,...n}}})))}function Du(e){return e?e.status===`online`?`list-status list-status-success`:e.status===`offline`?`list-status list-status-danger`:`list-status list-status-warning`:`list-status`}function Ou(e){return e?e.status===`online`?`status-dot status-dot-success`:e.status===`offline`?`status-dot status-dot-danger`:`status-dot status-dot-warning`:`status-dot`}function ku(e,t){return t?`checking`:e?e.status===`online`?`online - ${e.healthyNodeCount}/${e.nodeCount} nodes healthy`:`${e.status} - ${e.message}`:`not checked`}function Au({provider:e,config:t,setDraft:n}){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Profile directory`}),(0,B.jsx)(Y,{value:t.profileDir,onChange:t=>Tu(n,e,{profileDir:t.target.value})})]}),(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:t.headed,onCheckedChange:t=>Tu(n,e,{headed:t})}),(0,B.jsxs)(Bo,{children:[(0,B.jsx)(J,{children:`Headed browser`}),(0,B.jsx)(Ho,{children:`Show the browser window instead of running headless.`})]})]})]})}function ju({items:e,setDraft:t}){let n=(0,R.useRef)(0),r=(0,R.useRef)([]),i=e=>{for(;r.current.length<=e;){let e=n.current;n.current+=1,r.current.push(`navigation-row-${e}`)}return r.current[e]},a=(e,n)=>{t(t=>wu(t,t=>t.map((t,r)=>r===e?{...t,...n}:t)))},o=e=>{r.current.splice(e,1),t(t=>wu(t,t=>t.filter((t,n)=>n!==e)))};return(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Navigation links`}),(0,B.jsxs)(Ho,{children:[`Local paths like `,(0,B.jsx)(`code`,{children:`/admin/channels`}),` and HTTP(S) URLs are shown in the top navigation strip. Optional image paths or URLs render as the link icon.`]}),e.length>0?(0,B.jsx)(`div`,{className:iu.navigationList,children:e.map((e,t)=>{let n=i(t);return(0,B.jsxs)(`div`,{className:iu.navigationRow,children:[(0,B.jsxs)(q,{required:!0,error:bu(e.label),className:iu.navigationControl,children:[(0,B.jsx)(Y,{"aria-label":`Navigation item ${t+1} label`,value:e.label,placeholder:`Link text`,maxLength:lu,onChange:e=>a(t,{icon:void 0,label:e.target.value})}),(0,B.jsx)(Wo,{})]}),(0,B.jsxs)(q,{required:!0,error:xu(e.href),className:iu.navigationControl,children:[(0,B.jsx)(Y,{"aria-label":`Navigation item ${t+1} href`,value:e.href,placeholder:`/admin/channels or https://hybridclaw.io`,pattern:uu,title:du,onChange:e=>a(t,{href:e.target.value,icon:void 0})}),(0,B.jsx)(Wo,{})]}),(0,B.jsxs)(q,{error:Su(e.image),className:iu.navigationControl,children:[(0,B.jsx)(Y,{"aria-label":`Navigation item ${t+1} image`,value:e.image??``,placeholder:`/icons/hybridai.png`,pattern:fu,title:pu,onChange:e=>a(t,{image:e.target.value.trim()?e.target.value:void 0})}),(0,B.jsx)(Wo,{})]}),(0,B.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Remove navigation item ${t+1}`,onClick:()=>o(t),children:(0,B.jsx)(Fr,{width:15,height:15})})]},n)})}):(0,B.jsx)(`p`,{className:`muted-copy`,children:`No navigation links configured.`}),(0,B.jsx)(`div`,{className:`button-row`,children:(0,B.jsx)(Z,{type:`button`,variant:`ghost`,onClick:()=>{let e=n.current;n.current+=1,r.current.push(`navigation-row-${e}`),t(e=>wu(e,e=>[...e,{...mu}]))},children:`Add link`})})]})}function Mu(){let e=Gn(),t=hs(),n=o(),[r,i]=(0,R.useState)(`form`),[a,s]=(0,R.useState)(``),[c,l]=(0,R.useState)(null),u=y({queryKey:[`config`,e.token],queryFn:()=>Mt(e.token)}),d=Dc({source:u.data?.config}),{draft:f,setDraft:p,isDirty:m,discard:h,commit:_}=d,v=(0,R.useMemo)(()=>u.data?au(u.data.config):``,[u.data]),b=(0,R.useRef)(!1);!b.current&&v!==``&&(b.current=!0,s(v));let x=r===`json`?a!==v:m,S=Fc({mutationFn:t=>It(e.token,t),onSuccess:r=>{n.setQueryData([`config`,e.token],r),_(r.config),s(au(r.config)),l(null),t.success(`Runtime config saved.`)},onError:e=>{t.error(`Save failed`,e.message)}}),C=f?vu(f):hu(),w=u.data?.config.browser?.provider??`local`,T=C.provider!==w,E=C.managedCloud.poolTokenRef?.id??``,O=C.browserUseCloud.apiKeyRef?.id??``,k=y({queryKey:[`browser-pool-health`,e.token,C.provider,C.managedCloud.endpointUrl],queryFn:()=>Nt(e.token),enabled:!!(f&&r===`form`&&C.provider===`managed-cloud`),refetchInterval:15e3}),A=k.data,j=g({mutationFn:()=>Pt(e.token),onSuccess:e=>{e.ok?t.success(`Browser pool start requested.`,e.message):t.error(`Browser pool did not start`,e.message),e.poolTokenRefId&&Tu(p,`managedCloud`,{poolTokenRef:{source:`store`,id:e.poolTokenRefId}}),u.refetch(),k.refetch()},onError:e=>{t.error(`Browser pool start failed`,H(e))}}),M=(0,R.useCallback)(e=>{s(e);try{JSON.parse(e),l(null)}catch(e){l(H(e))}},[]),{dialog:N}=tu({isDirty:x,description:`You have unsaved edits to the runtime config. Leaving this page will discard them.`});if(u.isLoading&&!f)return(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading runtime config…`});if(!f||!u.data)return(0,B.jsxs)(`div`,{className:iu.unavailable,children:[(0,B.jsx)(`p`,{children:`Runtime config is unavailable.`}),(0,B.jsx)(Z,{variant:`ghost`,onClick:()=>void u.refetch(),disabled:u.isFetching,children:u.isFetching?`Retrying…`:`Retry`})]});let P=C,F=yu(f),I=e=>{let t=e===`json`?`json`:`form`;if(t!==r){if(t===`form`){try{p(JSON.parse(a)),l(null),i(`form`)}catch(e){l(H(e))}return}s(au(f)),l(null),i(`json`)}},ee=()=>{h(),u.data&&s(au(u.data.config)),l(null)},L=()=>{if(r===`json`){try{let e=JSON.parse(a);p(e),l(null),S.mutate(e)}catch(e){l(H(e))}return}S.mutate(f)},te=S.isPending||(r===`json`?!!c:!d.isValid);return(0,B.jsxs)(Oc,{form:d,className:iu.page,onSubmit:L,children:[(0,B.jsx)(Ha,{description:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:iu.path,children:u.data.path}),x?(0,B.jsxs)(`span`,{className:iu.statusInline,children:[(0,B.jsx)(`span`,{className:iu.statusDot,"aria-hidden":`true`}),`Unsaved changes`]}):(0,B.jsx)(`span`,{className:iu.statusInline,children:`Saved`})]}),actions:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(Ra,{ariaLabel:`Editor view`,value:r,onValueChange:I,size:`sm`,children:[(0,B.jsx)(za,{value:`form`,children:`Form`}),(0,B.jsx)(za,{value:`json`,children:`JSON`})]}),x?(0,B.jsx)(Z,{variant:`ghost`,onClick:ee,children:`Discard`}):null,x||S.isPending?(0,B.jsx)(Z,{type:`submit`,loading:S.isPending,disabled:te,children:S.isPending?`Saving…`:`Save changes`}):null]})}),(0,B.jsxs)(`p`,{className:iu.formNote,children:[`Form covers core runtime fields. For the full schema (channels, deployment, plugins, scheduler…) switch to `,(0,B.jsx)(`strong`,{children:`JSON`}),`.`]}),(0,B.jsx)(`div`,{className:iu.content,children:r===`json`?(0,B.jsxs)(q,{className:iu.jsonField,invalid:!!c,children:[(0,B.jsx)(J,{children:`config.json`}),(0,B.jsx)(Jo,{className:`code-editor ${iu.jsonEditor}`,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,value:a,onChange:e=>M(e.target.value)}),(0,B.jsx)(Wo,{children:c})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{className:iu.sectionCard,children:(0,B.jsxs)(Fo,{children:[(0,B.jsx)(Io,{children:`Operations`}),(0,B.jsx)(Ho,{className:iu.sectionDescription,children:`Gateway listener and log verbosity.`}),(0,B.jsxs)(Lo,{children:[(0,B.jsx)($,{name:`ops.healthHost`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Health host`}),(0,B.jsx)(Y,{...e}),(0,B.jsxs)(Ho,{children:[`Interface the gateway binds to. Use`,` `,(0,B.jsx)(`code`,{children:`127.0.0.1`}),` for loopback-only.`]})]})}),(0,B.jsx)($,{name:`ops.healthPort`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Health port`}),(0,B.jsx)(jc,{integer:!0,min:1,max:65535,value:e.value,onValueChange:e.onChange}),(0,B.jsx)(Wo,{})]})}),(0,B.jsx)($,{name:`ops.logLevel`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Log level`}),(0,B.jsx)(ds,{value:e.value,onChange:t=>{let n=t.target.value;ru(eu,n)&&e.onChange(n)},children:eu.map(e=>(0,B.jsx)(Q,{value:e,children:e},e))})]})}),(0,B.jsx)($,{name:`ops.gatewayBaseUrl`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Gateway public URL`}),(0,B.jsx)(Y,{...e}),(0,B.jsx)(Ho,{children:`Externally reachable URL used for webhooks and public callbacks.`})]})}),(0,B.jsx)($,{name:`ops.gatewayInternalBaseUrl`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Gateway internal URL`}),(0,B.jsx)(Y,{...e}),(0,B.jsx)(Ho,{children:`Local URL used by TUI, containers, and host-side gateway clients.`})]})})]})]})}),(0,B.jsx)(U,{className:iu.sectionCard,children:(0,B.jsxs)(Fo,{children:[(0,B.jsx)(Io,{children:`Navigation`}),(0,B.jsx)(Ho,{className:iu.sectionDescription,children:`Top-level links shown in the console navigation strip.`}),(0,B.jsx)(Lo,{children:(0,B.jsx)(ju,{items:F,setDraft:p})})]})}),(0,B.jsx)(U,{className:iu.sectionCard,children:(0,B.jsxs)(Fo,{children:[(0,B.jsx)(Io,{children:`Security`}),(0,B.jsx)(Ho,{className:iu.sectionDescription,children:`Sensitive-content guards applied to agent output.`}),(0,B.jsx)(Lo,{children:(0,B.jsx)($,{name:`security.confidentialRedactionEnabled`,render:({field:e})=>(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:!!e.value,onCheckedChange:e.onChange}),(0,B.jsxs)(Bo,{children:[(0,B.jsx)(J,{children:`Confidential leak guard`}),(0,B.jsx)(Ho,{children:`Redact secrets and sensitive patterns before they leave the agent.`})]})]})})})]})}),(0,B.jsx)(U,{className:iu.sectionCard,children:(0,B.jsxs)(Fo,{children:[(0,B.jsx)(Io,{children:`HybridAI`}),(0,B.jsx)(Ho,{className:iu.sectionDescription,children:`HybridAI provider defaults.`}),(0,B.jsxs)(Lo,{children:[(0,B.jsx)($,{name:`hybridai.baseUrl`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Base URL`}),(0,B.jsx)(Y,{type:`url`,...e})]})}),(0,B.jsx)($,{name:`hybridai.defaultModel`,render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Default model`}),(0,B.jsx)(Y,{...e})]})}),(0,B.jsx)($,{name:`hybridai.enableRag`,render:({field:e})=>(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:!!e.value,onCheckedChange:e.onChange}),(0,B.jsxs)(Bo,{children:[(0,B.jsx)(J,{children:`RAG default`}),(0,B.jsx)(Ho,{children:`Enable retrieval augmentation by default for new conversations.`})]})]})})]})]})}),(0,B.jsx)(U,{className:iu.sectionCard,children:(0,B.jsxs)(Fo,{children:[(0,B.jsx)(Io,{children:`Container`}),(0,B.jsx)(Ho,{className:iu.sectionDescription,children:`Sandboxed container runtime for tool execution.`}),(0,B.jsxs)(Lo,{children:[(0,B.jsx)($,{name:`container.memory`,rules:[jo(),Mo(cu,`Use a number with optional k, m, or g suffix.`)],render:({field:e})=>(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Memory`}),(0,B.jsx)(Y,{...e,placeholder:`1024m`}),(0,B.jsxs)(Ho,{children:[`Docker memory limit. e.g. `,(0,B.jsx)(`code`,{children:`512m`}),`,`,` `,(0,B.jsx)(`code`,{children:`1g`}),`, `,(0,B.jsx)(`code`,{children:`2048m`}),`.`]}),(0,B.jsx)(Wo,{})]})}),(0,B.jsx)($,{name:`container.persistBashState`,render:({field:e})=>(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:!!e.value,onCheckedChange:e.onChange}),(0,B.jsxs)(Bo,{children:[(0,B.jsx)(J,{children:`Persistent bash state`}),(0,B.jsx)(Ho,{children:`Reuse the same shell across tool calls so cwd, env, and aliases survive.`})]})]})})]})]})}),(0,B.jsx)(U,{className:iu.sectionCard,children:(0,B.jsxs)(Fo,{children:[(0,B.jsx)(Io,{children:`Browser`}),(0,B.jsx)(Ho,{className:iu.sectionDescription,children:`Browser provider used for agent web tasks.`}),(0,B.jsxs)(Lo,{children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Provider`}),(0,B.jsx)(ds,{value:P.provider,onChange:e=>p(t=>Cu(t,t=>({...t,provider:e.target.value}))),children:su.map(e=>(0,B.jsx)(Q,{value:e.value,children:e.label},e.value))})]}),(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:P.allowPrivateNetwork,onCheckedChange:e=>p(t=>Cu(t,t=>({...t,allowPrivateNetwork:e})))}),(0,B.jsxs)(Bo,{children:[(0,B.jsx)(J,{children:`Allow private network navigation`}),(0,B.jsx)(Ho,{children:`Allow the browser to navigate to private and loopback network addresses.`})]})]}),P.provider===`local`?(0,B.jsx)(Au,{provider:`local`,config:P.local,setDraft:p}):null,P.provider===`camofox`?(0,B.jsx)(Au,{provider:`camofox`,config:P.camofox,setDraft:p}):null,P.provider===`managed-cloud`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Pool status`}),(0,B.jsxs)(`div`,{className:`button-row`,children:[(0,B.jsxs)(`span`,{className:Du(A),children:[(0,B.jsx)(`span`,{className:Ou(A)}),ku(A,k.isLoading)]}),(0,B.jsx)(Z,{variant:`ghost`,type:`button`,disabled:k.isFetching,onClick:()=>void k.refetch(),children:k.isFetching?`Checking...`:`Check now`}),(0,B.jsx)(Z,{variant:`ghost`,type:`button`,disabled:j.isPending,onClick:()=>j.mutate(),children:j.isPending?`Starting...`:`Start Docker pool`})]}),T?(0,B.jsxs)(Ho,{className:iu.poolStatusPending,children:[`Pending save — status above reflects the previously saved provider (`,w,`). Save changes to refresh.`]}):null]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Pool endpoint URL`}),(0,B.jsx)(Y,{type:`url`,value:P.managedCloud.endpointUrl,onChange:e=>Tu(p,`managedCloud`,{endpointUrl:e.target.value})})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Pool token SecretRef id`}),(0,B.jsx)(Y,{value:E,placeholder:`MANAGED_BROWSER_POOL_TOKEN`,onChange:e=>{let t=e.target.value.trim();Tu(p,`managedCloud`,{poolTokenRef:t?{source:`store`,id:t}:void 0})}})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Default tenant id (optional)`}),(0,B.jsx)(Y,{value:P.managedCloud.defaultTenantId,placeholder:`Uses agent id when blank`,onChange:e=>Tu(p,`managedCloud`,{defaultTenantId:e.target.value})})]}),(0,B.jsx)(`div`,{className:`button-row`,children:(0,B.jsx)(D,{to:`/admin/approvals`,className:`ghost-button`,children:`Manage network policy`})}),(0,B.jsxs)(q,{controlId:`managed-cloud-action-usd`,children:[(0,B.jsx)(J,{children:`Action price USD`}),(0,B.jsx)(jc,{id:`managed-cloud-action-usd`,min:0,emptyValue:0,value:P.managedCloud.pricing.actionUsd,onValueChange:e=>Eu(p,`managedCloud`,{actionUsd:e})}),(0,B.jsx)(Wo,{})]})]}):null,P.provider===`browser-use-cloud`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`API key SecretRef id`}),(0,B.jsx)(Y,{value:O,onChange:e=>{let t=e.target.value.trim();Tu(p,`browserUseCloud`,{apiKeyRef:t?{source:`store`,id:t}:void 0})}})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Project id`}),(0,B.jsx)(Y,{value:P.browserUseCloud.projectId,onChange:e=>Tu(p,`browserUseCloud`,{projectId:e.target.value})})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Profile id`}),(0,B.jsx)(Y,{value:P.browserUseCloud.profileId,onChange:e=>Tu(p,`browserUseCloud`,{profileId:e.target.value})})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Region`}),(0,B.jsx)(Y,{value:P.browserUseCloud.region,onChange:e=>Tu(p,`browserUseCloud`,{region:e.target.value})})]}),(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:P.browserUseCloud.keepAlive,onCheckedChange:e=>Tu(p,`browserUseCloud`,{keepAlive:e})}),(0,B.jsxs)(Bo,{children:[(0,B.jsx)(J,{children:`Keep alive`}),(0,B.jsx)(Ho,{children:`Keep the cloud browser session alive between calls instead of tearing it down.`})]})]}),(0,B.jsxs)(q,{controlId:`browser-use-browser-usd`,children:[(0,B.jsx)(J,{children:`Browser price USD/min`}),(0,B.jsx)(jc,{id:`browser-use-browser-usd`,min:0,emptyValue:0,value:P.browserUseCloud.pricing.browserUsdPerMinute,onValueChange:e=>Eu(p,`browserUseCloud`,{browserUsdPerMinute:e})}),(0,B.jsx)(Wo,{})]}),(0,B.jsxs)(q,{controlId:`browser-use-action-usd`,children:[(0,B.jsx)(J,{children:`Action price USD`}),(0,B.jsx)(jc,{id:`browser-use-action-usd`,min:0,emptyValue:0,value:P.browserUseCloud.pricing.actionUsd,onValueChange:e=>Eu(p,`browserUseCloud`,{actionUsd:e})}),(0,B.jsx)(Wo,{})]})]}):null,P.provider===`mac-cua`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Native browser`}),(0,B.jsxs)(ds,{value:P.macCua.browser,onChange:e=>p(t=>Cu(t,t=>({...t,macCua:{...t.macCua,browser:e.target.value}}))),children:[(0,B.jsx)(Q,{value:`safari`,children:`safari`}),(0,B.jsx)(Q,{value:`chrome`,children:`chrome`}),(0,B.jsx)(Q,{value:`firefox`,children:`firefox`}),(0,B.jsx)(Q,{value:`brave`,children:`brave`}),(0,B.jsx)(Q,{value:`arc`,children:`arc`})]})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Driver command`}),(0,B.jsx)(Y,{value:P.macCua.driverCommand,placeholder:`cua-driver`,onChange:e=>p(t=>Cu(t,t=>({...t,macCua:{...t.macCua,driverCommand:e.target.value}})))})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Driver args`}),(0,B.jsx)(Y,{value:P.macCua.driverArgs.join(` `),placeholder:`mcp --no-daemon-relaunch`,onChange:e=>p(t=>Cu(t,t=>({...t,macCua:{...t.macCua,driverArgs:e.target.value.split(/\s+/u).map(e=>e.trim()).filter(Boolean)}})))})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Screenshot mode`}),(0,B.jsxs)(ds,{value:P.macCua.screenshotMode,onChange:e=>p(t=>Cu(t,t=>({...t,macCua:{...t.macCua,screenshotMode:e.target.value}}))),children:[(0,B.jsx)(Q,{value:`som`,children:`som`}),(0,B.jsx)(Q,{value:`vision`,children:`vision`}),(0,B.jsx)(Q,{value:`ax`,children:`ax`})]})]})]}):null]})]})})]})}),N]})}var Nu=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20512%20512'%20role='img'%20aria-label='LM%20Studio'%3e%3cdefs%3e%3clinearGradient%20id='lmstudio-bg'%20x1='84'%20y1='37'%20x2='426'%20y2='473'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%236f7df1'/%3e%3cstop%20offset='0.53'%20stop-color='%235c3de1'/%3e%3cstop%20offset='1'%20stop-color='%234c0fcb'/%3e%3c/linearGradient%3e%3c/defs%3e%3crect%20width='512'%20height='512'%20rx='108'%20fill='url(%23lmstudio-bg)'/%3e%3cg%20opacity='.72'%20fill='%23b5a9f3'%3e%3crect%20x='68'%20y='91'%20width='290'%20height='43'%20rx='21.5'/%3e%3crect%20x='156'%20y='150'%20width='290'%20height='43'%20rx='21.5'/%3e%3crect%20x='105'%20y='208'%20width='290'%20height='43'%20rx='21.5'/%3e%3crect%20x='40'%20y='269'%20width='291'%20height='43'%20rx='21.5'/%3e%3crect%20x='105'%20y='327'%20width='290'%20height='43'%20rx='21.5'/%3e%3crect%20x='245'%20y='385'%20width='214'%20height='43'%20rx='21.5'/%3e%3c/g%3e%3cg%20fill='%23f2f1ff'%20opacity='.95'%3e%3crect%20x='68'%20y='91'%20width='223'%20height='43'%20rx='21.5'/%3e%3crect%20x='156'%20y='150'%20width='223'%20height='43'%20rx='21.5'/%3e%3crect%20x='105'%20y='208'%20width='222'%20height='43'%20rx='21.5'/%3e%3crect%20x='40'%20y='269'%20width='223'%20height='43'%20rx='21.5'/%3e%3crect%20x='105'%20y='327'%20width='222'%20height='43'%20rx='21.5'/%3e%3crect%20x='245'%20y='385'%20width='146'%20height='43'%20rx='21.5'/%3e%3c/g%3e%3cg%20fill='%23fff'%20opacity='.22'%3e%3crect%20x='135'%20y='91'%20width='156'%20height='43'%20rx='21.5'/%3e%3crect%20x='224'%20y='150'%20width='155'%20height='43'%20rx='21.5'/%3e%3crect%20x='173'%20y='208'%20width='154'%20height='43'%20rx='21.5'/%3e%3crect%20x='108'%20y='269'%20width='155'%20height='43'%20rx='21.5'/%3e%3crect%20x='173'%20y='327'%20width='154'%20height='43'%20rx='21.5'/%3e%3crect%20x='312'%20y='385'%20width='79'%20height='43'%20rx='21.5'/%3e%3c/g%3e%3c/svg%3e`;function Pu(e){return(0,B.jsxs)(`svg`,{"aria-hidden":`true`,focusable:`false`,width:`18`,height:`18`,viewBox:`0 0 100 100`,xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,...e,children:[(0,B.jsxs)(`defs`,{children:[(0,B.jsx)(`style`,{children:`
|
|
@@ -69,7 +69,7 @@ import{n as e,t}from"./rolldown-runtime-Bh1tDfsg.js";import{t as n}from"./vendor
|
|
|
69
69
|
|
|
70
70
|
`)),children:s===`all`?`Copied`:`Copy all`}):null]}),o.length?(0,B.jsx)(`div`,{className:`jobs-output-list`,children:o.map(t=>(0,B.jsxs)(`div`,{className:`jobs-output-card`,children:[(0,B.jsxs)(`div`,{className:`jobs-output-actions`,children:[(0,B.jsx)(`small`,{children:`Output`}),(0,B.jsx)(`button`,{className:`ghost-button`,type:`button`,onClick:()=>p(Np(`copy`,t),t),children:s===Np(`copy`,t)?`Copied`:`Copy`})]}),(0,B.jsx)(`pre`,{className:`jobs-output-pre`,children:t})]},Np(e.item.key,t)))}):(0,B.jsx)(`p`,{children:`No outputs captured for this job yet.`})]}),(0,B.jsxs)(`div`,{className:`summary-block`,children:[(0,B.jsx)(`span`,{children:`Runtime`}),e.runtime.length?(0,B.jsx)(`div`,{className:`jobs-runtime-list`,children:e.runtime.map(e=>(0,B.jsxs)(`div`,{className:`jobs-runtime-row`,children:[(0,B.jsx)(`strong`,{children:e.label}),(0,B.jsx)(`small`,{children:e.value})]},e.key))}):(0,B.jsx)(`p`,{children:`No runtime details recorded yet.`})]})]})]})}function Fp(){let e=Gn(),t=j(),n=o(),r=hs(),[i,a]=(0,R.useState)(``),[s,c]=(0,R.useState)(null),[l,u]=(0,R.useState)(null),[d,f]=(0,R.useState)(null),[p,m]=(0,R.useState)(null),h=(0,R.useDeferredValue)(i),_=y({queryKey:[`scheduler`,e.token],queryFn:()=>Jt(e.token),refetchInterval:15e3}),v=y({queryKey:[`jobs-context`,e.token],queryFn:()=>Ct(e.token),refetchInterval:15e3}),b=g({mutationFn:t=>Yt(e.token,t),onMutate:async t=>{await n.cancelQueries({queryKey:[`scheduler`,e.token]});let r=n.getQueryData([`scheduler`,e.token]);return n.setQueryData([`scheduler`,e.token],r&&{...r,jobs:Ap(r.jobs,t)}),{previous:r}},onError:(t,i,a)=>{a?.previous&&n.setQueryData([`scheduler`,e.token],a.previous),r.error(`Save failed`,H(t))},onSuccess:t=>{n.setQueryData([`scheduler`,e.token],t)}}),x=g({mutationFn:t=>Qt(e.token,{jobId:t.jobId,beforeJobId:t.beforeJobId,boardStatus:t.boardStatus}),onSuccess:t=>{n.setQueryData([`scheduler`,e.token],t)},onError:e=>{r.error(`Move failed`,H(e))}}),S=(0,R.useMemo)(()=>new Map((v.data?.sessions||[]).map(e=>[e.sessionId,e])),[v.data?.sessions]),C=(0,R.useMemo)(()=>new Map((v.data?.agents||[]).map(e=>[e.id,e])),[v.data?.agents]),w=(0,R.useMemo)(()=>{let e=(_.data?.jobs||[]).map(e=>{let t=S.get(yp(e)||``)||null,n=e.agentId||t?.agentId||`unassigned`,r=(C.get(n)||null)?.name||e.agentId||t?.agentId||(n===`unassigned`?`Unassigned`:n),i=bp(e,t),a=vp(e.description,28)||vp(e.action.message,36)||vp(e.channelId,24)||`No summary`;return{key:e.id,kind:`job`,job:e,session:t,agentKey:n,agentLabel:r,column:i,tone:xp(i),stateLabel:Tp(e,i),summary:a,searchIndex:[e.id,e.name,a,e.action.message,e.description||``,r,e.channelId||``,e.delivery.to].join(` `).toLowerCase()}}),t=(v.data?.suspendedSessions||[]).map(e=>{let t=`blocked:${e.sessionId}`,n=e.agentId||`unassigned`,r=(C.get(n)||null)?.name||e.agentId||(n===`unassigned`?`Unassigned`:n);return{key:t,kind:`blocked`,suspendedSession:e,session:null,agentKey:n,agentLabel:r,column:`review`,tone:`danger`,stateLabel:e.blockedLabel,summary:vp(e.context.host,24)||vp(e.prompt,32)||`Needs operator`,searchIndex:[t,e.blockedLabel,e.prompt,e.context.host||``,e.modality,r].join(` `).toLowerCase()}}),n=(v.data?.cards||[]).map(e=>{let t=e.owner.type===`agent`?e.owner.id:`unassigned`,n=(C.get(t)||null)?.name||(e.owner.type===`agent`?e.owner.id:`User ${e.owner.id}`),r=Sp(e),i=vp(e.body,36)||vp(e.status,28)||vp(e.source,24)||`No summary`;return{key:`card:${e.id}`,kind:`card`,card:e,session:null,agentKey:t,agentLabel:n,column:r,tone:e.blocked?`danger`:xp(r),stateLabel:e.blocked?`blocked`:e.status||`ready`,summary:i,searchIndex:[e.id,e.title,e.body,e.status,e.source,e.parent||``,n,...e.edges.flatMap(e=>[e.kind,e.fromCardId,e.toCardId])].join(` `).toLowerCase()}});return[...t,...n,...e]},[C,v.data?.cards,v.data?.suspendedSessions,_.data?.jobs,S]),T=(0,R.useMemo)(()=>{let e=h.trim().toLowerCase();return e?w.filter(t=>t.searchIndex.includes(e)):w},[w,h]),E=(0,R.useMemo)(()=>new Map(w.map(e=>[e.key,e])),[w]),D=(0,R.useMemo)(()=>Array.from(new Set(w.map(e=>e.agentKey).filter(e=>e&&e!==`unassigned`))).sort((e,t)=>e.localeCompare(t)),[w]),O=(0,R.useMemo)(()=>[...D].sort((e,t)=>e.localeCompare(t)).join(`\0`),[D]),k=y({queryKey:[`board-budget-summaries`,e.token,O],queryFn:()=>wt(e.token,D),enabled:D.length>0,staleTime:3e4}),A=(0,R.useMemo)(()=>new Map((k.data?.budgets||[]).map(e=>[e.agentId,e])),[k.data?.budgets]),M=(0,R.useMemo)(()=>new Set(T.map(e=>e.key)),[T]),N=(0,R.useMemo)(()=>_p.map(e=>({...e,items:T.filter(t=>t.column===e.id)})),[T]),P=(0,R.useMemo)(()=>s&&E.get(s)||null,[E,s]);(0,R.useEffect)(()=>{s!==null&&(!P||!M.has(s))&&c(null)},[P,s,M]);let F=(0,R.useMemo)(()=>P?jp(P):[],[P]),I=(0,R.useMemo)(()=>w.find(e=>e.key===l)||null,[w,l]);function ee(e,t=null){if(!(!I||I.kind!==`job`||I.job.source!==`job`)){if(t===I.job.id){u(null),f(null),m(null);return}x.mutate({jobId:I.job.id,beforeJobId:t,boardStatus:e}),u(null),f(null),m(null)}}return _.isLoading&&!_.data?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading jobs board...`}):_.isError&&!_.data?(0,B.jsx)(`div`,{className:`empty-state error`,children:H(_.error)}):(0,B.jsxs)(`div`,{className:`page-stack`,children:[(0,B.jsx)(Ha,{actions:(0,B.jsxs)(`div`,{className:`header-actions`,children:[(0,B.jsx)(`input`,{className:`compact-search jobs-header-search`,value:i,onChange:e=>a(e.target.value),placeholder:`Search jobs`}),(0,B.jsx)(`button`,{className:`primary-button`,type:`button`,onClick:()=>{t({to:`/admin/scheduler`,search:{jobId:void 0}}).catch(Os)},children:`New Job`})]})}),v.isError?(0,B.jsx)(`p`,{className:`error-banner`,children:H(v.error)}):null,(0,B.jsxs)(`section`,{className:P?`jobs-board-layout has-detail`:`jobs-board-layout`,children:[(0,B.jsx)(`div`,{className:`jobs-columns`,children:N.map(e=>(0,B.jsxs)(`fieldset`,{"aria-label":`${e.title} jobs`,className:p===e.id?`jobs-column jobs-column-${e.id} drop-target`:`jobs-column jobs-column-${e.id}`,onDragOver:t=>{!I||I.kind!==`job`||I.job.source!==`job`||(t.preventDefault(),p!==e.id&&m(e.id))},onDragLeave:t=>{t.currentTarget.contains(t.relatedTarget)||p===e.id&&m(null)},onDrop:t=>{t.preventDefault(),ee(e.id,null)},children:[(0,B.jsxs)(`div`,{className:`jobs-column-header`,children:[(0,B.jsx)(`strong`,{children:e.title}),(0,B.jsx)(`span`,{children:e.items.length})]}),(0,B.jsx)(`div`,{className:`jobs-column-body`,children:e.items.length?e.items.map(t=>(0,B.jsx)(`div`,{className:[`jobs-card-frame`,d===t.key?`drop-target`:``,t.key===l?`dragging`:``].filter(Boolean).join(` `),children:(0,B.jsx)(kp,{item:t,budget:A.get(t.agentKey)||null,selected:t.key===P?.key,draggable:t.kind===`job`&&t.job.source===`job`,onSelect:()=>c(e=>e===t.key?null:t.key),onDragStart:e=>{t.kind!==`job`||t.job.source!==`job`||(e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t.key),u(t.key))},onDragEnd:()=>{u(null),f(null),m(null)},onDragOver:n=>{!I||I.kind!==`job`||I.job.source!==`job`||t.kind!==`job`||t.job.source!==`job`||(n.preventDefault(),n.stopPropagation(),d!==t.key&&f(t.key),p!==e.id&&m(e.id))},onDragLeave:e=>{let n=e.relatedTarget;n instanceof Node&&e.currentTarget.contains(n)||d===t.key&&f(null)},onDrop:n=>{t.kind!==`job`||t.job.source!==`job`||(n.preventDefault(),n.stopPropagation(),ee(e.id,t.job.id))}})},t.key)):(0,B.jsx)(`div`,{className:`jobs-column-empty`,children:`No jobs`})})]},e.id))}),P?(0,B.jsx)(Pp,{item:P,runtime:F,agents:v.data?.agents||[],savePending:b.isPending,onUpdate:e=>b.mutate(e)}):null]})]})}var Ip=128*1024,Lp=3e4,Rp=[{value:`off`,label:`Off`,activeTone:`is-off`},{value:`on`,label:`On`},{value:`debug`,label:`Debug`}],zp={off:{logLevel:`silent`,logRequests:!1,debugModelResponses:!1},on:{logLevel:`info`,logRequests:!1,debugModelResponses:!1},debug:{logLevel:`debug`,logRequests:!0,debugModelResponses:!0}};function Bp(e){if(e==null)return`missing`;if(e<1024)return`${e} B`;let t=[`KiB`,`MiB`,`GiB`],n=e/1024;for(let e of t){if(n<1024||e===t.at(-1))return`${n.toFixed(n>=10?0:1)} ${e}`;n/=1024}return`${e} B`}function Vp(e){return e.exists?e.readable?`readable`:`unreadable`:`missing`}function Hp(e,t){let n=t?.effectiveLevel??e?.ops.logLevel;return n===zp.off.logLevel?`off`:n===zp.debug.logLevel||t?.logRequests.effective===!0||t?.debugModelResponses.effective===!0||e?.ops.logRequests===!0||e?.ops.debugModelResponses===!0?`debug`:`on`}function Up(e,t){return t?t.forcedLevel?`Current mode: ${e} (forced by runtime)`:t.logRequests.envEnabled||t.debugModelResponses.envEnabled?`Current mode: ${e} (enabled by runtime flag)`:`Current mode: ${e}`:`Current mode: ${e}`}function Wp(e,t){let n=zp[t];return{...e,ops:{...e.ops,...n}}}function Gp(){let e=Gn(),t=o(),n=hs(),[r,i]=(0,R.useState)(null),a=(0,R.useRef)(null),s=y({queryKey:[`admin-logs`,e.token,r],queryFn:()=>ze(e.token,{fileId:r,tailBytes:Ip}),placeholderData:e=>e,refetchOnWindowFocus:!1}),c=y({queryKey:[`config`,e.token],queryFn:()=>Mt(e.token),refetchOnWindowFocus:!1,staleTime:Lp}),l=s.data?.logging,u=Hp(c.data?.config??null,l),d=g({mutationFn:async t=>{let n=c.data?.config;if(!n)throw Error(`Runtime config has not loaded yet.`);let r=await It(e.token,Wp(n,t)),i=await st(e.token);if(i.status!==`ok`)throw Error(i.message||`Gateway reload failed.`);return r},onSuccess:r=>{t.setQueryData([`config`,e.token],r),n.success(`Logging mode saved.`),s.refetch()},onError:e=>{n.error(`Logging mode update failed`,H(e))}}),f=s.data?.files||[],p=s.data?.selected,m=(0,R.useMemo)(()=>{let e=p?.fileId||r;return f.find(t=>t.id===e)||f.find(e=>e.readable)||f[0]||null},[f,p?.fileId,r]);return(0,R.useEffect)(()=>{!m||m.id===r||i(m.id)},[m,r]),(0,R.useEffect)(()=>{let e=a.current;!e||!p||(e.scrollTop=e.scrollHeight)},[p]),(0,B.jsxs)(`div`,{className:`page-stack`,children:[(0,B.jsx)(Ha,{description:`Gateway runtime log files`,actions:(0,B.jsx)(Z,{type:`button`,variant:`outline`,disabled:s.isFetching,onClick:()=>void s.refetch(),children:`Refresh`})}),(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:`Logging`}),(0,B.jsx)(uo,{children:c.data?Up(u,l):c.isError?`Runtime config unavailable.`:`Loading runtime config...`})]}),(0,B.jsx)(K,{children:(0,B.jsx)(Wa,{ariaLabel:`Logging mode`,value:u,options:Rp,disabled:!c.data||c.isFetching||d.isPending,onChange:e=>d.mutate(e)})})]}),(0,B.jsxs)(`div`,{className:`two-column-grid logs-layout`,children:[(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:`Files`}),(0,B.jsx)(uo,{children:`${f.length} configured log${f.length===1?``:`s`}`})]}),(0,B.jsx)(K,{children:s.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading log files...`}):f.length===0?(0,B.jsx)(`div`,{className:`empty-state`,children:`No log files are configured.`}):(0,B.jsx)(`div`,{className:`list-stack selectable-list`,children:f.map(e=>(0,B.jsxs)(`button`,{className:e.id===m?.id?`selectable-row active`:`selectable-row`,type:`button`,onClick:()=>i(e.id),children:[(0,B.jsx)(`div`,{className:`session-row-main`,children:(0,B.jsx)(`strong`,{children:e.label})}),(0,B.jsx)(`span`,{className:`session-row-time`,children:Vp(e)})]},e.id))})})]}),(0,B.jsxs)(U,{variant:`muted`,children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:m?.label||`Log tail`}),(0,B.jsx)(uo,{children:m?.description||`Select a log file.`})]}),(0,B.jsx)(K,{children:m?(0,B.jsxs)(`div`,{className:`detail-stack`,children:[(0,B.jsxs)(`div`,{className:`key-value-grid`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Status`}),(0,B.jsx)(`strong`,{children:(0,B.jsx)(Ga,{value:m.readable,trueLabel:`readable`,falseLabel:Vp(m),falseTone:m.exists?`danger`:void 0})})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Size`}),(0,B.jsx)(`strong`,{children:Bp(m.sizeBytes)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Modified`}),(0,B.jsx)(`strong`,{children:m.mtime?Qa(m.mtime):`missing`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Path`}),(0,B.jsx)(`strong`,{children:m.path})]})]}),m.error?(0,B.jsx)(`div`,{className:`empty-state error`,children:m.error}):p?(0,B.jsxs)(B.Fragment,{children:[p.truncated?(0,B.jsxs)(`p`,{className:`muted-copy`,children:[`Showing the last `,Bp(p.tailBytes),`.`]}):null,(0,B.jsx)(`pre`,{className:`log-viewer`,ref:a,children:p.content||`(empty log file)`})]}):(0,B.jsx)(`div`,{className:`empty-state`,children:`This log file is not available yet.`})]}):(0,B.jsx)(`div`,{className:`empty-state`,children:`Select a log file.`})})]})]})]})}var Kp=2e3,qp=3*6e4;function Jp(e){return!e||Object.keys(e).length===0?``:JSON.stringify(e,null,2)}function Yp(e){return e?.auth===`oauth`?`oauth`:e?.headers&&Object.keys(e.headers).length>0?`headers`:`none`}function Xp(e){return{originalName:e?.name||null,name:e?.name||``,transport:e?.config.transport||`http`,enabled:e?.enabled??!0,command:e?.config.command||``,args:(e?.config.args||[]).join(`
|
|
71
71
|
`),cwd:e?.config.cwd||``,url:e?.config.url||``,envJson:Jp(e?.config.env),authMode:e?Yp(e.config):`oauth`,headersJson:Jp(e?.config.headers)}}function Zp(e,t){let n=e.trim();if(!n)return;let r;try{r=JSON.parse(n)}catch(e){throw Error(`${t}: ${e instanceof Error?e.message:String(e)}`)}if(!r||typeof r!=`object`||Array.isArray(r))throw Error(`${t} must be a JSON object.`);return Object.fromEntries(Object.entries(r).map(([e,t])=>[e,String(t??``)]).filter(([e])=>e.trim()))}function Qp(e){return{name:e.name.trim(),config:{transport:e.transport,...e.enabled?{}:{enabled:!1},...e.transport===`stdio`?{command:e.command.trim(),args:e.args.split(`
|
|
72
|
-
`).map(e=>e.trim()).filter(Boolean),...e.cwd.trim()?{cwd:e.cwd.trim()}:{},...e.envJson.trim()?{env:Zp(e.envJson,`Environment JSON`)}:{}}:{url:e.url.trim(),...e.authMode===`oauth`?{auth:`oauth`}:{},...e.authMode===`headers`&&e.headersJson.trim()?{headers:Zp(e.headersJson,`Headers JSON`)}:{}}}}}function $p(e){return e.state===`connected`?{label:`connected`,connected:!0}:e.state===`expired`?{label:`expired`,connected:!1}:{label:`login required`,connected:!1}}function em(e){return new Promise(t=>setTimeout(t,e))}function tm(){let e=Gn(),t=o(),n=hs(),[r,i]=(0,R.useState)(null),[a,s]=(0,R.useState)(Xp()),[c,l]=(0,R.useState)(null),u=(0,R.useRef)(!1),d=y({queryKey:[`mcp`,e.token],queryFn:()=>$t(e.token)}),f=g({mutationFn:()=>on(e.token,Qp(a)),onSuccess:r=>{t.setQueryData([`mcp`,e.token],r),i(a.name.trim()),s(Xp(r.servers.find(e=>e.name===a.name.trim()))),n.success(`Saved MCP server ${a.name.trim()}.`)},onError:e=>{n.error(`Save failed`,H(e))}}),p=g({mutationFn:()=>sn(e.token,a.name.trim()),onSuccess:r=>{t.setQueryData([`mcp`,e.token],r),i(null),s(Xp()),n.success(`MCP server deleted.`)},onError:e=>{n.error(`Delete failed`,H(e))}}),m=g({mutationFn:async()=>{u.current=!1;let n=Qp(a),r=await on(e.token,n);t.setQueryData([`mcp`,e.token],r);let i=await cn(e.token,n.name);l(i.authorizationUrl),window.open(i.authorizationUrl,`_blank`,`noopener`);let o=Date.now()+Math.max(Kp,Math.min(qp,i.expiresAt-Date.now()));for(;Date.now()<o;){if(u.current)throw Error(`Authorization cancelled.`);if(await em(Kp),(await ln(e.token,n.name)).auth.state===`connected`)return n.name}throw Error(`Timed out waiting for authorization. Complete the login in the opened tab and try again.`)},onSuccess:async r=>{l(null),await t.invalidateQueries({queryKey:[`mcp`,e.token]}),i(r),n.success(`Connected to ${r} via OAuth.`)},onError:e=>{l(null),n.error(`OAuth connection failed`,H(e))}}),h=g({mutationFn:()=>un(e.token,a.name.trim()),onSuccess:r=>{t.setQueryData([`mcp`,e.token],r),n.success(`OAuth credentials cleared.`)},onError:e=>{n.error(`Disconnect failed`,H(e))}}),_=d.data?.servers.find(e=>e.name===r)||null;(0,R.useEffect)(()=>{if(_){s(Xp(_));return}r||s(Xp())},[r,_]),(0,R.useEffect)(()=>()=>{u.current=!0},[]);let v=_?.auth,b=v?.state===`connected`;return(0,B.jsxs)(`div`,{className:`page-stack`,children:[(0,B.jsx)(Ha,{actions:(0,B.jsx)(Z,{variant:`ghost`,type:`button`,onClick:()=>{i(null),s(Xp())},children:`New server`})}),(0,B.jsxs)(`div`,{className:`two-column-grid`,children:[(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:`Servers`}),(0,B.jsx)(uo,{children:`${d.data?.servers.length||0} configured server${d.data?.servers.length===1?``:`s`}`})]}),(0,B.jsx)(K,{children:d.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading MCP servers...`}):d.data?.servers.length?(0,B.jsx)(`div`,{className:`list-stack selectable-list`,children:d.data.servers.map(e=>{let t=e.auth.method===`oauth`?$p(e.auth):null;return(0,B.jsxs)(`button`,{className:e.name===r?`selectable-row active`:`selectable-row`,type:`button`,onClick:()=>i(e.name),children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:e.name}),(0,B.jsx)(`small`,{children:e.summary})]}),(0,B.jsxs)(`div`,{className:`button-row`,children:[t?(0,B.jsx)(Ga,{value:t.connected,trueLabel:`oauth`,falseLabel:t.label,falseTone:`danger`}):null,(0,B.jsx)(Ga,{value:e.enabled,trueLabel:`active`,falseLabel:`inactive`})]})]},e.name)})}):(0,B.jsx)(`div`,{className:`empty-state`,children:`No MCP servers are configured yet. Add a remote server with its URL and connect it with OAuth, or run a local stdio command.`})})]}),(0,B.jsxs)(U,{variant:`muted`,children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:_?`Edit ${_.name}`:`New server`}),(0,B.jsx)(uo,{children:`Changes apply on the next agent turn.`})]}),(0,B.jsx)(K,{children:(0,B.jsxs)(`div`,{className:`stack-form`,children:[(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Name`}),(0,B.jsx)(Y,{value:a.name,onChange:e=>s(t=>({...t,name:e.target.value})),placeholder:`github`}),(0,B.jsx)(Ho,{children:`Lowercase letters, numbers, - and _. Used as the tool prefix.`})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Transport`}),(0,B.jsxs)(ds,{value:a.transport,onChange:e=>s(t=>({...t,transport:e.target.value})),children:[(0,B.jsx)(Q,{value:`http`,children:`http — remote server`}),(0,B.jsx)(Q,{value:`sse`,children:`sse — remote server (legacy)`}),(0,B.jsx)(Q,{value:`stdio`,children:`stdio — local command`})]})]})]}),(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:a.enabled,onCheckedChange:e=>s(t=>({...t,enabled:e}))}),(0,B.jsx)(Bo,{children:(0,B.jsx)(J,{children:`Server state`})})]}),a.transport===`stdio`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Command`}),(0,B.jsx)(Y,{value:a.command,onChange:e=>s(t=>({...t,command:e.target.value})),placeholder:`docker`})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Arguments`}),(0,B.jsx)(Jo,{rows:4,value:a.args,onChange:e=>s(t=>({...t,args:e.target.value})),placeholder:`One argument per line`})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Working directory`}),(0,B.jsx)(Y,{value:a.cwd,onChange:e=>s(t=>({...t,cwd:e.target.value})),placeholder:`/workspace`})]})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Environment JSON`}),(0,B.jsx)(Jo,{rows:5,value:a.envJson,onChange:e=>s(t=>({...t,envJson:e.target.value})),placeholder:`{"GITHUB_TOKEN":"..."}`})]})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`URL`}),(0,B.jsx)(Y,{value:a.url,onChange:e=>s(t=>({...t,url:e.target.value})),placeholder:`https://mcp.example.com/mcp`})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Authentication`}),(0,B.jsxs)(ds,{value:a.authMode,onChange:e=>s(t=>({...t,authMode:e.target.value})),children:[(0,B.jsx)(Q,{value:`oauth`,children:`OAuth — log in via browser`}),(0,B.jsx)(Q,{value:`headers`,children:`Custom headers (API key / bearer token)`}),(0,B.jsx)(Q,{value:`none`,children:`None`})]}),(0,B.jsx)(Ho,{children:a.authMode===`oauth`?`The gateway discovers the authorization server, registers a client, and refreshes tokens automatically.`:a.authMode===`headers`?`Headers are sent with every request to the server.`:`Requests are sent without credentials.`})]}),a.authMode===`headers`?(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Headers JSON`}),(0,B.jsx)(Jo,{rows:5,value:a.headersJson,onChange:e=>s(t=>({...t,headersJson:e.target.value})),placeholder:`{"Authorization":"Bearer ..."}`})]}):null,a.authMode===`oauth`?(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsxs)(Bo,{children:[(0,B.jsx)(J,{children:`OAuth connection`}),(0,B.jsxs)(Ho,{children:[m.isPending?`Waiting for you to approve access in the browser...`:b?`Connected. Tokens refresh automatically.`:v?.state===`expired`?`The session expired. Reconnect to continue.`:`Not connected yet. Saving happens automatically when you connect.`,c&&m.isPending?(0,B.jsxs)(B.Fragment,{children:[` `,(0,B.jsx)(`a`,{href:c,target:`_blank`,rel:`noreferrer`,children:`Open the login page`}),` `,`if it did not open automatically.`]}):null]})]}),(0,B.jsxs)(`div`,{className:`button-row`,children:[(0,B.jsx)(Z,{type:`button`,loading:m.isPending,disabled:m.isPending||!a.name.trim()||!a.url.trim(),onClick:()=>m.mutate(),children:m.isPending?`Waiting...`:b?`Reconnect`:`Connect`}),b?(0,B.jsx)(Z,{variant:`ghost`,type:`button`,loading:h.isPending,disabled:h.isPending,onClick:()=>h.mutate(),children:`Disconnect`}):null]})]}):null]}),(0,B.jsxs)(`div`,{className:`button-row`,children:[(0,B.jsx)(Z,{type:`button`,loading:f.isPending,disabled:f.isPending,onClick:()=>f.mutate(),children:f.isPending?`Saving...`:`Save server`}),_?(0,B.jsx)(Z,{variant:`danger`,type:`button`,loading:p.isPending,disabled:p.isPending,onClick:()=>p.mutate(),children:p.isPending?`Deleting...`:`Delete server`}):null]}),_?(0,B.jsxs)(`div`,{className:`summary-block`,children:[(0,B.jsx)(`span`,{children:`Summary`}),(0,B.jsx)(`p`,{children:_.summary})]}):null]})})]})]})]})}function nm(e){return e.usageDaily!==null}function rm(e,t){let n=e.usageMonthly?.totalTokens||0,r=t.usageMonthly?.totalTokens||0;if(n!==r)return n-r;let i=e.usageMonthly?.callCount||0,a=t.usageMonthly?.callCount||0;return i===a?e.id.localeCompare(t.id):i-a}var im=[`hybridai`,`codex`,`openrouter`,`mistral`,`huggingface`,`ollama`,`lmstudio`,`llamacpp`,`vllm`];function am(e){if(e.backend)return e.backend;let t=e.id.trim().toLowerCase();return t.startsWith(`openai-codex/`)?`codex`:t.startsWith(`openrouter/`)?`openrouter`:t.startsWith(`mistral/`)?`mistral`:t.startsWith(`huggingface/`)?`huggingface`:null}function om(e,t){let n=im.indexOf(e),r=im.indexOf(t);if(n!==-1||r!==-1){if(n===-1)return 1;if(r===-1)return-1;if(n!==r)return n-r}return e.localeCompare(t)}function sm(e){let t=new Set(Object.keys(e?.providerStatus||{}));for(let n of e?.models||[]){let e=am(n);e&&t.add(e)}return[...t].sort(om).map(t=>({name:t,status:e?.providerStatus?.[t]||null}))}var cm={model:(e,t)=>X(e.id,t.id),backend:(e,t)=>X(e.backend||`remote`,t.backend||`remote`)||X(e.id,t.id),context:(e,t)=>$o(e.contextWindow,t.contextWindow)||X(e.id,t.id),monthlyUsage:rm},lm={context:`desc`,monthlyUsage:`desc`};function um(e){return{defaultModel:e?.defaultModel||``}}function dm(e){return[e.isReasoning?`reasoning`:``,e.thinkingFormat||``,e.family||``].filter(Boolean).join(` · `)}function fm(){let e=Gn(),t=o(),n=hs(),[r,i]=(0,R.useState)(``),[a,s]=(0,R.useState)(um()),c=y({queryKey:[`models`,e.token],queryFn:()=>Kt(e.token)}),l=g({mutationFn:()=>qt(e.token,{defaultModel:a.defaultModel}),onSuccess:r=>{t.setQueryData([`models`,e.token],r),s(um(r)),t.invalidateQueries({queryKey:[`overview`]}),n.success(`Default model is now ${r.defaultModel}.`)},onError:e=>{n.error(`Save failed`,H(e))}});(0,R.useEffect)(()=>{c.data&&s(e=>e.defaultModel?e:um(c.data))},[c.data]);let{sortedRows:u,sortState:d,toggleSort:f}=Ba((c.data?.models||[]).filter(e=>[e.id,e.backend||``,e.family||``,e.parameterSize||``].join(` `).toLowerCase().includes(r.trim().toLowerCase())),{initialSort:{key:`monthlyUsage`,direction:`desc`},sorters:cm,defaultDirections:lm}),p=sm(c.data),m=(c.data?.models||[]).filter(nm);return(0,B.jsxs)(`div`,{className:`page-stack`,children:[(0,B.jsx)(Ha,{actions:(0,B.jsx)(Y,{className:`compact-search`,value:r,onChange:e=>i(e.target.value),placeholder:`Filter models`})}),(0,B.jsxs)(`div`,{className:`two-column-grid`,children:[(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{children:(0,B.jsx)(G,{children:`Provider status`})}),(0,B.jsx)(K,{children:(0,B.jsxs)(`div`,{className:`list-stack`,children:[p.map(({name:e,status:t})=>(0,B.jsxs)(`div`,{className:`list-row`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:e}),(0,B.jsx)(`small`,{children:t?.reachable?`${t.detail||(typeof t.latencyMs==`number`?`${t.latencyMs}ms`:`ready`)} · ${t.modelCount??0} models`:t?t.error||`unreachable`:`Visible in catalog · no live health data`})]}),(0,B.jsxs)(`span`,{className:t?.reachable?`list-status list-status-success`:t?`list-status list-status-danger`:`list-status`,children:[(0,B.jsx)(`span`,{className:t?.reachable?`status-dot status-dot-success`:t?`status-dot status-dot-danger`:`status-dot`}),t?.reachable?`healthy`:t?`down`:`catalog`]})]},e)),p.length===0?(0,B.jsx)(`div`,{className:`empty-state`,children:`No provider health checks available.`}):null]})})]}),(0,B.jsxs)(U,{variant:`muted`,children:[(0,B.jsx)(W,{children:(0,B.jsx)(G,{children:`Selection`})}),(0,B.jsx)(K,{children:c.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading model catalog...`}):(0,B.jsxs)(`div`,{className:`stack-form`,children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Default model`}),(0,B.jsxs)(ds,{value:a.defaultModel,onChange:e=>s(t=>({...t,defaultModel:e.target.value})),children:[(0,B.jsx)(Q,{value:``,children:`Select model`}),(c.data?.models||[]).map(e=>(0,B.jsx)(Q,{value:e.id,children:e.id},e.id))]})]}),(0,B.jsx)(`div`,{className:`button-row`,children:(0,B.jsx)(`button`,{className:`primary-button`,type:`button`,disabled:l.isPending,onClick:()=>l.mutate(),children:l.isPending?`Saving...`:`Save selection`})})]})})]})]}),(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:`Catalog`}),(0,B.jsx)(uo,{children:`${eo(u.length,`model`)} visible`})]}),(0,B.jsx)(K,{children:c.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading model catalog...`}):(0,B.jsx)(`div`,{className:`table-shell`,children:(0,B.jsxs)(`table`,{children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(Va,{label:`Model`,sortKey:`model`,sortState:d,onToggle:f}),(0,B.jsx)(Va,{label:`Backend`,sortKey:`backend`,sortState:d,onToggle:f}),(0,B.jsx)(Va,{label:`Context`,sortKey:`context`,sortState:d,onToggle:f}),(0,B.jsx)(Va,{label:`Monthly usage`,sortKey:`monthlyUsage`,sortState:d,onToggle:f})]})}),(0,B.jsxs)(`tbody`,{children:[u.map(e=>(0,B.jsxs)(`tr`,{children:[(0,B.jsxs)(`td`,{children:[(0,B.jsx)(`strong`,{children:e.id}),dm(e)?(0,B.jsx)(`small`,{children:dm(e)}):null]}),(0,B.jsx)(`td`,{children:e.backend||`remote`}),(0,B.jsx)(`td`,{children:e.contextWindow?Ka(e.contextWindow):`unknown`}),(0,B.jsx)(`td`,{children:e.usageMonthly?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`strong`,{children:Ka(e.usageMonthly.totalTokens)}),(0,B.jsx)(`small`,{children:Ja({inputTokens:e.usageMonthly.totalInputTokens??0,outputTokens:e.usageMonthly.totalOutputTokens??0})}),(0,B.jsxs)(`small`,{children:[Xa(e.usageMonthly.totalCostUsd),` ·`,` `,eo(e.usageMonthly.callCount,`call`)]})]}):(0,B.jsx)(`small`,{children:`No usage recorded`})})]},e.id)),u.length===0?(0,B.jsx)(`tr`,{children:(0,B.jsx)(`td`,{colSpan:4,children:(0,B.jsx)(`div`,{className:`empty-state`,children:`No models match this filter.`})})}):null]})]})})})]}),m.length>0?(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:`Recent daily activity`}),(0,B.jsx)(uo,{children:`Updated ${Za(new Date().toISOString())}`})]}),(0,B.jsx)(K,{children:(0,B.jsx)(`div`,{className:`list-stack`,children:m.sort((e,t)=>t.usageDaily.totalTokens-e.usageDaily.totalTokens).slice(0,6).map(e=>(0,B.jsxs)(`div`,{className:`list-row`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:e.id}),(0,B.jsxs)(`small`,{children:[Ja({inputTokens:e.usageDaily.totalInputTokens??0,outputTokens:e.usageDaily.totalOutputTokens??0}),` `,`· `,eo(e.usageDaily.callCount,`call`),` today`]})]}),(0,B.jsx)(`span`,{children:Xa(e.usageDaily.totalCostUsd??0)})]},`${e.id}-daily`))})})]}):null]})}var pm={root:`_root_16nbt_1`,viewport:`_viewport_16nbt_10`,scrollbar:`_scrollbar_16nbt_29`,thumb:`_thumb_16nbt_55`},mm=(0,R.createContext)(null);function hm(e){let t=(0,R.useContext)(mm);if(!t)throw Error(`${e} must be used within <ScrollArea>`);return t}function gm({className:e,children:t,...n}){let r=(0,R.useRef)(null),i=(0,R.useRef)(null),[a,o]=(0,R.useState)({thumbSize:0,thumbOffset:0,visible:!1}),s=(0,R.useCallback)(()=>{let e=r.current,t=i.current;if(!e||!t){o(e=>e.visible?{...e,visible:!1}:e);return}let{scrollTop:n,scrollHeight:a,clientHeight:s}=e;if(a<=s+1){o(e=>e.visible?{...e,visible:!1}:e);return}let c=t.clientHeight;if(c<=0)return;let l=s/a,u=Math.max(20,c*l),d=a-s,f=c-u,p=d<=0?0:n/d*f;o(e=>e.visible&&e.thumbSize===u&&e.thumbOffset===p?e:{thumbSize:u,thumbOffset:p,visible:!0})},[]),c=(0,R.useCallback)(e=>{r.current=e,requestAnimationFrame(s)},[s]),l=(0,R.useCallback)(e=>{i.current=e,requestAnimationFrame(s)},[s]);(0,R.useLayoutEffect)(()=>{let e=r.current;if(!e)return;s();let t=0,n=()=>{t||=requestAnimationFrame(()=>{t=0,s()})};e.addEventListener(`scroll`,n,{passive:!0});let a=new ResizeObserver(()=>s());return a.observe(e),e.firstElementChild&&a.observe(e.firstElementChild),i.current&&a.observe(i.current),()=>{t&&cancelAnimationFrame(t),e.removeEventListener(`scroll`,n),a.disconnect()}},[s]);let u={viewportRef:r,setViewportEl:c,scrollState:a,registerScrollbarTrack:l};return(0,B.jsx)(mm.Provider,{value:u,children:(0,B.jsx)(`div`,{className:V(pm.root,e),...n,children:t})})}function _m({className:e,children:t,ref:n,...r}){let i=hm(`ScrollAreaViewport`);return(0,B.jsx)(`div`,{ref:e=>{i.setViewportEl(e),typeof n==`function`?n(e):n&&typeof n==`object`&&(n.current=e)},className:V(pm.viewport,e),...r,children:t})}function vm({className:e,children:t,...n}){let r=hm(`ScrollAreaScrollbar`);return(0,B.jsx)(`div`,{ref:r.registerScrollbarTrack,"data-orientation":`vertical`,"data-state":r.scrollState.visible?`visible`:`hidden`,"aria-hidden":`true`,className:V(pm.scrollbar,e),...n,children:t})}function ym({className:e,...t}){let n=hm(`ScrollAreaThumb`),{thumbSize:r,thumbOffset:i}=n.scrollState;return(0,B.jsx)(`div`,{className:V(pm.thumb,e),style:{height:r,transform:`translateY(${i}px)`},onPointerDown:e=>{if(e.button!==0)return;e.preventDefault(),e.stopPropagation();let t=n.viewportRef.current,i=e.currentTarget.parentElement??null;if(!t||!i)return;let a=e.clientY,o=t.scrollTop,s=i.clientHeight,c=t.scrollHeight-t.clientHeight,l=Math.max(1,s-r),u=e=>{t.scrollTop=o+(e.clientY-a)/l*c},d=()=>{window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),window.removeEventListener(`pointercancel`,d)};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d),window.addEventListener(`pointercancel`,d)},...t})}var bm={trigger:`_trigger_1fi1d_1`,value:`_value_1fi1d_40`,icon:`_icon_1fi1d_52`,popup:`_popup_1fi1d_66`,"select-in":`_select-in_1fi1d_1`,popupHeader:`_popupHeader_1fi1d_111`,popupBodyPlain:`_popupBodyPlain_1fi1d_117`,popupBody:`_popupBody_1fi1d_117`,popupRail:`_popupRail_1fi1d_131`,listScroll:`_listScroll_1fi1d_151`,list:`_list_1fi1d_151`,group:`_group_1fi1d_168`,groupLabel:`_groupLabel_1fi1d_176`,separator:`_separator_1fi1d_184`,empty:`_empty_1fi1d_190`,item:`_item_1fi1d_197`,itemIndicator:`_itemIndicator_1fi1d_214`,itemText:`_itemText_1fi1d_248`,itemBody:`_itemBody_1fi1d_256`,itemSubtitle:`_itemSubtitle_1fi1d_272`,itemMeta:`_itemMeta_1fi1d_279`},xm=(0,R.createContext)(null);function Sm(e){let t=(0,R.useContext)(xm);if(!t)throw Error(`${e} must be used within <Select>`);return t}function Cm({value:e,defaultValue:t=``,onValueChange:n,open:r,defaultOpen:i,onOpenChange:a,disabled:o=!1,children:s}){let c=e!==void 0,[l,u]=(0,R.useState)(t),d=c?e:l,[f,p]=(0,R.useState)(null),[m,h]=(0,R.useState)(null),g=(0,R.useId)(),_=(0,R.useId)(),v=(0,R.useCallback)(e=>{c||u(e),n?.(e)},[c,n]),y=(0,R.useCallback)(e=>`${_}-item-${Lm(e)}`,[_]),b=(0,R.useMemo)(()=>({value:d,selectValue:v,listEl:f,setListEl:p,listId:g,highlightedValue:m,setHighlightedValue:h,disabled:o,getItemId:y}),[d,v,f,g,m,o,y]);return(0,B.jsx)(Oi,{open:r,defaultOpen:i,onOpenChange:(0,R.useCallback)(e=>{o&&e||(e||h(null),a?.(e))},[o,a]),children:(0,B.jsx)(xm.Provider,{value:b,children:s})})}function wm({children:e,className:t,onClick:n,onKeyDown:r,...i}){let a=Di(`SelectTrigger`),o=Sm(`SelectTrigger`);return(0,B.jsx)(`button`,{ref:a.setTriggerEl,type:`button`,role:`combobox`,"aria-haspopup":`listbox`,"aria-expanded":a.open,"aria-controls":a.open?o.listId:void 0,"aria-disabled":o.disabled||void 0,"data-state":a.open?`open`:`closed`,"data-disabled":o.disabled?``:void 0,disabled:o.disabled,className:V(bm.trigger,t),onClick:e=>{n?.(e),!e.defaultPrevented&&(a.open||o.setHighlightedValue(o.value||null),a.toggle())},onKeyDown:e=>{r?.(e),!e.defaultPrevented&&(e.key===`ArrowDown`||e.key===`ArrowUp`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),o.setHighlightedValue(o.value||null),a.setOpen(!0))},...i,children:e})}function Tm({placeholder:e,children:t,className:n,...r}){let i=Sm(`SelectValue`),a=t==null||t===``||i.value===``;return(0,B.jsx)(`span`,{className:V(bm.value,n),"data-placeholder":a?``:void 0,...r,children:a?e:t})}function Em({className:e,children:t,...n}){return(0,B.jsx)(`span`,{"aria-hidden":`true`,className:V(bm.icon,e),...n,children:t??(0,B.jsx)(er,{width:14,height:14})})}var Dm=e=>{let t=e.querySelector(`input`);if(t){t.focus();return}e.querySelector(`[role="listbox"]`)?.focus()};function Om({align:e=`start`,sideOffset:t=6,header:n,rail:r,children:i,className:a,...o}){let s=Di(`SelectContent`),c=Sm(`SelectContent`),l=(0,R.useRef)({buffer:``,timer:0}),u=n!=null&&n!==!1,d=r!=null&&r!==!1;(0,R.useEffect)(()=>{let e=s.contentEl;if(!s.open||!e||!c.highlightedValue)return;let t=c.getItemId(c.highlightedValue);e.querySelector(`#${Rm(t)}`)?.scrollIntoView({block:`nearest`})},[s.open,s.contentEl,c.highlightedValue,c.getItemId]),(0,R.useEffect)(()=>{let e=l.current;return()=>{e.timer&&window.clearTimeout(e.timer)}},[]);let f=(0,R.useCallback)(()=>c.listEl?Array.from(c.listEl.querySelectorAll(`[role="option"]:not([aria-disabled="true"])`)):[],[c.listEl]),p=(0,R.useCallback)(e=>{let t=f();if(t.length===0)return;let n=c.highlightedValue?t.findIndex(e=>e.getAttribute(`data-value`)===c.highlightedValue):-1,r;r=e===`first`?0:e===`last`?t.length-1:n<0?e>0?0:t.length-1:(n+e+t.length)%t.length;let i=t[r],a=i?.getAttribute(`data-value`)??null;c.setHighlightedValue(a),i?.scrollIntoView({block:`nearest`})},[f,c.highlightedValue,c.setHighlightedValue]),m=e=>{let t=l.current;t.buffer+=e.toLowerCase(),t.timer&&window.clearTimeout(t.timer),t.timer=window.setTimeout(()=>{t.buffer=``,t.timer=0},500);let n=f();if(n.length===0)return;let r=c.highlightedValue?n.findIndex(e=>e.getAttribute(`data-value`)===c.highlightedValue):-1,i=[...n.slice(r+1),...n.slice(0,r+1)].find(e=>(e.textContent??``).trim().toLowerCase().startsWith(t.buffer));if(i){let e=i.getAttribute(`data-value`);c.setHighlightedValue(e),i.scrollIntoView({block:`nearest`})}},h=e=>{if(e.key===`Tab`){s.setOpen(!1);return}if(e.key===`ArrowDown`){e.preventDefault(),p(1);return}if(e.key===`ArrowUp`){e.preventDefault(),p(-1);return}if(e.key===`Home`){e.preventDefault(),p(`first`);return}if(e.key===`End`){e.preventDefault(),p(`last`);return}if(e.key===`Enter`){if(c.highlightedValue==null)return;e.preventDefault(),c.selectValue(c.highlightedValue),s.setOpen(!1),s.triggerEl?.focus();return}if(!u&&e.key===` `&&c.highlightedValue!=null){e.preventDefault(),c.selectValue(c.highlightedValue),s.setOpen(!1),s.triggerEl?.focus();return}!u&&e.key.length===1&&!e.ctrlKey&&!e.metaKey&&m(e.key)},g=c.highlightedValue?c.getItemId(c.highlightedValue):void 0;return(0,B.jsxs)(Ai,{align:e,sideOffset:t,focusOnOpen:Dm,className:V(bm.popup,a),onKeyDown:h,...o,children:[u?(0,B.jsx)(`div`,{className:bm.popupHeader,children:n}):null,(0,B.jsxs)(`div`,{className:d?bm.popupBody:bm.popupBodyPlain,children:[d?(0,B.jsx)(`div`,{className:bm.popupRail,children:r}):null,(0,B.jsxs)(gm,{className:bm.listScroll,children:[(0,B.jsx)(_m,{ref:c.setListEl,id:c.listId,role:`listbox`,tabIndex:-1,"aria-activedescendant":g,className:bm.list,children:i}),(0,B.jsx)(vm,{children:(0,B.jsx)(ym,{})})]})]})]})}function km({className:e,children:t,...n}){return(0,B.jsx)(`div`,{role:`group`,className:V(bm.group,e),...n,children:t})}function Am({className:e,children:t,...n}){return(0,B.jsx)(`div`,{className:V(bm.groupLabel,e),...n,children:t})}function jm({className:e,children:t,...n}){return(0,B.jsx)(`div`,{className:V(bm.empty,e),...n,children:t})}function Mm({value:e,disabled:t=!1,textValue:n,children:r,className:i,onClick:a,onPointerEnter:o,...s}){let c=Di(`SelectItem`),l=Sm(`SelectItem`),u=l.value===e,d=l.highlightedValue===e;return(0,B.jsx)(`div`,{id:l.getItemId(e),role:`option`,"aria-selected":u,"aria-disabled":t||void 0,"aria-label":n,"data-value":e,"data-state":u?`checked`:`unchecked`,"data-highlighted":d?``:void 0,"data-disabled":t?``:void 0,className:V(bm.item,i),onClick:n=>{t||(a?.(n),!n.defaultPrevented&&(l.selectValue(e),c.setOpen(!1),c.triggerEl?.focus()))},onPointerEnter:n=>{o?.(n),!n.defaultPrevented&&(t||l.setHighlightedValue(e))},...s,children:r})}function Nm({className:e,children:t,...n}){return(0,B.jsx)(`span`,{className:V(bm.itemText,e),...n,children:t})}function Pm({className:e,children:t,...n}){return(0,B.jsx)(`span`,{className:V(bm.itemBody,e),...n,children:t})}function Fm({className:e,children:t,...n}){return(0,B.jsx)(`span`,{className:V(bm.itemSubtitle,e),...n,children:t})}function Im({className:e,children:t,...n}){return(0,B.jsx)(`span`,{className:V(bm.itemMeta,e),...n,children:t})}function Lm(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`)}function Rm(e){return typeof CSS<`u`&&typeof CSS.escape==`function`?CSS.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,`\\$&`)}var zm={chatPage:`_chatPage_eu8x8_1`,chatSidebarHeader:`_chatSidebarHeader_eu8x8_36`,chatSidebarContent:`_chatSidebarContent_eu8x8_44`,newChatButton:`_newChatButton_eu8x8_52`,sidebarLabel:`_sidebarLabel_eu8x8_82`,sidebarListHeader:`_sidebarListHeader_eu8x8_92`,sidebarScopeToggle:`_sidebarScopeToggle_eu8x8_99`,sidebarScopeButton:`_sidebarScopeButton_eu8x8_108`,sidebarScopeButtonActive:`_sidebarScopeButtonActive_eu8x8_130`,sessionList:`_sessionList_eu8x8_143`,sessionItemRow:`_sessionItemRow_eu8x8_152`,sessionItem:`_sessionItem_eu8x8_152`,sessionItemPending:`_sessionItemPending_eu8x8_183`,sessionPulse:`_sessionPulse_eu8x8_1`,sessionTitle:`_sessionTitle_eu8x8_197`,sessionTime:`_sessionTime_eu8x8_206`,sessionSnippet:`_sessionSnippet_eu8x8_211`,sessionItemActive:`_sessionItemActive_eu8x8_219`,sessionDeleteButton:`_sessionDeleteButton_eu8x8_224`,sessionDeleteIcon:`_sessionDeleteIcon_eu8x8_260`,sidebarSearchWrap:`_sidebarSearchWrap_eu8x8_273`,sidebarSearch:`_sidebarSearch_eu8x8_273`,sidebarStatus:`_sidebarStatus_eu8x8_297`,chatMobileTrigger:`_chatMobileTrigger_eu8x8_316`,chatTopbar:`_chatTopbar_eu8x8_321`,mobileQrButton:`_mobileQrButton_eu8x8_335`,mobileQrIcon:`_mobileQrIcon_eu8x8_359`,mobileQrOverlay:`_mobileQrOverlay_eu8x8_371`,mobileQrDialog:`_mobileQrDialog_eu8x8_382`,mobileQrHeader:`_mobileQrHeader_eu8x8_391`,mobileQrClose:`_mobileQrClose_eu8x8_405`,mobileQrImage:`_mobileQrImage_eu8x8_418`,mobileQrLink:`_mobileQrLink_eu8x8_432`,chatMain:`_chatMain_eu8x8_441`,messageArea:`_messageArea_eu8x8_453`,messageList:`_messageList_eu8x8_466`,sidebarCollapseButton:`_sidebarCollapseButton_eu8x8_475`,emptyState:`_emptyState_eu8x8_479`,greeting:`_greeting_eu8x8_489`,messageBlock:`_messageBlock_eu8x8_498`,jumpToLatest:`_jumpToLatest_eu8x8_510`,messageBlockUser:`_messageBlockUser_eu8x8_546`,messageBlockAssistant:`_messageBlockAssistant_eu8x8_550`,messageBlockSystem:`_messageBlockSystem_eu8x8_551`,agentLabel:`_agentLabel_eu8x8_555`,agentAvatar:`_agentAvatar_eu8x8_565`,agentInitial:`_agentInitial_eu8x8_572`,bubble:`_bubble_eu8x8_585`,bubbleUser:`_bubbleUser_eu8x8_596`,userAgentMentionPill:`_userAgentMentionPill_eu8x8_603`,userAgentMentionAvatar:`_userAgentMentionAvatar_eu8x8_624`,userSkillCommandLink:`_userSkillCommandLink_eu8x8_632`,bubbleAssistant:`_bubbleAssistant_eu8x8_644`,bubbleApproval:`_bubbleApproval_eu8x8_652`,bubbleSystem:`_bubbleSystem_eu8x8_666`,bubbleCommand:`_bubbleCommand_eu8x8_678`,markdownContent:`_markdownContent_eu8x8_705`,codeCopyButton:`_codeCopyButton_eu8x8_784`,codeCopyButtonDone:`_codeCopyButtonDone_eu8x8_812`,codeBlockLabeled:`_codeBlockLabeled_eu8x8_820`,codeLangLabel:`_codeLangLabel_eu8x8_824`,messageActions:`_messageActions_eu8x8_984`,actionButton:`_actionButton_eu8x8_990`,actionButtonSelected:`_actionButtonSelected_eu8x8_1009`,actionButtonSuccess:`_actionButtonSuccess_eu8x8_1014`,branchSwitcher:`_branchSwitcher_eu8x8_1018`,branchButton:`_branchButton_eu8x8_1027`,approvalCard:`_approvalCard_eu8x8_1045`,approvalHeader:`_approvalHeader_eu8x8_1052`,approvalTier:`_approvalTier_eu8x8_1059`,approvalTitle:`_approvalTitle_eu8x8_1077`,approvalIntro:`_approvalIntro_eu8x8_1084`,approvalDetails:`_approvalDetails_eu8x8_1090`,approvalDetailRow:`_approvalDetailRow_eu8x8_1096`,approvalPrimaryActions:`_approvalPrimaryActions_eu8x8_1119`,approvalTrustActions:`_approvalTrustActions_eu8x8_1120`,approvalAllow:`_approvalAllow_eu8x8_1135`,artifactCard:`_artifactCard_eu8x8_1141`,artifactCardWithPreview:`_artifactCardWithPreview_eu8x8_1155`,artifactHeader:`_artifactHeader_eu8x8_1160`,artifactFilename:`_artifactFilename_eu8x8_1167`,artifactBadge:`_artifactBadge_eu8x8_1177`,artifactDownload:`_artifactDownload_eu8x8_1187`,artifactPreview:`_artifactPreview_eu8x8_1209`,artifactPdfPreview:`_artifactPdfPreview_eu8x8_1221`,artifactVideoPreview:`_artifactVideoPreview_eu8x8_1237`,thinking:`_thinking_eu8x8_1250`,thinkingDot:`_thinkingDot_eu8x8_1257`,thinkingBounce:`_thinkingBounce_eu8x8_1`,composerWrapper:`_composerWrapper_eu8x8_1286`,composer:`_composer_eu8x8_1286`,pendingMediaRow:`_pendingMediaRow_eu8x8_1310`,mediaChip:`_mediaChip_eu8x8_1317`,mediaChipName:`_mediaChipName_eu8x8_1329`,mediaChipRemove:`_mediaChipRemove_eu8x8_1335`,composerRow:`_composerRow_eu8x8_1354`,composerActions:`_composerActions_eu8x8_1361`,composerLeftActions:`_composerLeftActions_eu8x8_1368`,composerInputWrap:`_composerInputWrap_eu8x8_1375`,composerInputOverlay:`_composerInputOverlay_eu8x8_1381`,composerOverlayCaret:`_composerOverlayCaret_eu8x8_1394`,composerMentionPill:`_composerMentionPill_eu8x8_1407`,composerMentionAvatar:`_composerMentionAvatar_eu8x8_1427`,composerInput:`_composerInput_eu8x8_1375`,composerInputHasOverlay:`_composerInputHasOverlay_eu8x8_1452`,attachButton:`_attachButton_eu8x8_1466`,sendButton:`_sendButton_eu8x8_1467`,composerPill:`_composerPill_eu8x8_1501`,agentSelectPopup:`_agentSelectPopup_eu8x8_1541`,agentSelectItem:`_agentSelectItem_eu8x8_1547`,remoteAgentGroupLabel:`_remoteAgentGroupLabel_eu8x8_1551`,remoteAgentGroupIcon:`_remoteAgentGroupIcon_eu8x8_1557`,agentSelectItemText:`_agentSelectItemText_eu8x8_1562`,agentSelectAvatar:`_agentSelectAvatar_eu8x8_1569`,agentSelectAvatarLoading:`_agentSelectAvatarLoading_eu8x8_1570`,composerPillChevron:`_composerPillChevron_eu8x8_1585`,stopping:`_stopping_eu8x8_1615`,slashSuggestions:`_slashSuggestions_eu8x8_1620`,slashSuggestionsScroll:`_slashSuggestionsScroll_eu8x8_1628`,slashSuggestionsList:`_slashSuggestionsList_eu8x8_1632`,suggestionItem:`_suggestionItem_eu8x8_1636`,suggestionItemAgent:`_suggestionItemAgent_eu8x8_1651`,suggestionItemActive:`_suggestionItemActive_eu8x8_1658`,suggestionItemSub:`_suggestionItemSub_eu8x8_1663`,suggestionLabel:`_suggestionLabel_eu8x8_1667`,suggestionText:`_suggestionText_eu8x8_1677`,suggestionAvatar:`_suggestionAvatar_eu8x8_1684`,suggestionAvatarLoading:`_suggestionAvatarLoading_eu8x8_1685`,suggestionLabelMono:`_suggestionLabelMono_eu8x8_1700`,suggestionMatch:`_suggestionMatch_eu8x8_1706`,suggestionDesc:`_suggestionDesc_eu8x8_1715`,suggestionEmpty:`_suggestionEmpty_eu8x8_1723`,slashLiveRegion:`_slashLiveRegion_eu8x8_1729 _srOnly_jfnet_1`,errorBanner:`_errorBanner_eu8x8_1745`,errorBannerFadeIn:`_errorBannerFadeIn_eu8x8_1`,errorBannerExiting:`_errorBannerExiting_eu8x8_1760`,errorBannerFadeOut:`_errorBannerFadeOut_eu8x8_1`,editArea:`_editArea_eu8x8_1776`,editButtons:`_editButtons_eu8x8_1791`},Bm={search:`_search_12ewc_1`,searchInput:`_searchInput_12ewc_17`,rail:`_rail_12ewc_33`,railItem:`_railItem_12ewc_37`,railGlyph:`_railGlyph_12ewc_70`,triggerPill:`_triggerPill_12ewc_90`,triggerLogo:`_triggerLogo_12ewc_105`,itemLogo:`_itemLogo_12ewc_114`},Vm={hybridai:`HybridAI`,codex:`OpenAI Codex`,anthropic:`Anthropic`,openrouter:`OpenRouter`,mistral:`Mistral`,huggingface:`Hugging Face`,gemini:`Gemini`,deepseek:`DeepSeek`,xai:`xAI`,zai:`Z.ai`,kimi:`Kimi`,minimax:`MiniMax`,dashscope:`DashScope`,xiaomi:`Xiaomi`,kilo:`Kilo`,ollama:`Ollama`,lmstudio:`LM Studio`,llamacpp:`llama.cpp`,vllm:`vLLM`},Hm={anthropic:`Anthropic`,google:`Google`,openai:`OpenAI`,mistral:`Mistral`,meta:`Meta`,deepseek:`DeepSeek`,xai:`xAI`},Um={Local:0,HybridAI:1,"OpenAI Codex":2},Wm={Anthropic:1,OpenAI:2,Google:3,Mistral:4,Meta:5};function Gm(e,t){let n=e.toLowerCase();return t[n]?t[n]:e.split(/[-_]/).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}var Km=new Set([`gpt`,`ai`,`ml`,`vl`,`ui`,`pdf`,`sdk`,`api`]),qm={deepseek:`DeepSeek`,openai:`OpenAI`,hybridai:`HybridAI`},Jm=/^[a-z]\d+$/;function Ym(e){let t=e.toLowerCase();return Km.has(t)?t.toUpperCase():qm[t]?qm[t]:Jm.test(t)?t:t.charAt(0).toUpperCase()+t.slice(1)}function Xm(e){if(!e)return e;let t=e.split(`-`).filter(e=>!/^\d{5,}$/.test(e)),n=[],r=null,i=0;for(;i<t.length;){let e=t[i],a,o=!1;if(/^\d+$/.test(e)){let n=[e];for(;i+1<t.length&&/^\d+$/.test(t[i+1]);)i++,n.push(t[i]);a=n.join(`.`),o=!0}else a=Ym(e),o=/^\d/.test(e);if(o&&r&&Km.has(r)){let e=n.pop()??``;n.push(e?`${e}-${a}`:a)}else n.push(a);r=t[i].toLowerCase(),i++}return n.join(` `)}function Zm(e){return e.provider}function Qm(e){let t=e.split(`/`,1)[0]?.trim().toLowerCase()??``;return t===`openai-codex`?`codex`:t&&Vm[t]?t:`hybridai`}function $m(e){return e===`ollama`?`ollama`:e===`lmstudio`?`lmstudio`:e===`llamacpp`?`llamacpp`:e===`vllm`?`vllm`:null}function eh(e){let t=e.trim();if(!t)return null;let n=Qm(t);return{id:t,provider:n,backend:$m(n),contextWindow:null,isReasoning:!1,family:null,parameterSize:null}}var th={HybridAI:Pu,"OpenAI Codex":Xu,Anthropic:Iu,OpenRouter:Ku,Mistral:Hu,"Hugging Face":Gu,Gemini:Ru,DeepSeek:Vu,xAI:Wu,"Z.ai":Zu,Kimi:Qu,MiniMax:$u,DashScope:ed,Xiaomi:td,Kilo:nd,Ollama:Ju,"LM Studio":rd,"llama.cpp":id,vLLM:ad,Local:gr},nh={Anthropic:Iu,OpenAI:Lu,Google:zu,Mistral:Hu,Meta:Uu,DeepSeek:Vu,xAI:Wu,Alibaba:od,Microsoft:qu};function rh({provider:e,size:t=18}){let n=th[e];return n?(0,B.jsx)(n,{width:t,height:t}):(0,B.jsx)(Or,{width:t,height:t})}function ih({vendor:e,fallbackProvider:t,size:n=18}){let r=e?nh[e]:void 0;return r?(0,B.jsx)(r,{width:n,height:n}):(0,B.jsx)(rh,{provider:t,size:n})}function ah({value:e,onValueChange:t,className:n,placeholder:r=`Search…`,...i}){return(0,B.jsxs)(`div`,{className:V(Bm.search,n),children:[(0,B.jsx)(Er,{width:`14`,height:`14`}),(0,B.jsx)(`input`,{type:`text`,autoComplete:`off`,spellCheck:!1,className:Bm.searchInput,placeholder:r,value:e,onChange:e=>t(e.target.value),...i})]})}function oh({children:e}){return(0,B.jsx)(`div`,{role:`toolbar`,"aria-orientation":`vertical`,className:Bm.rail,children:e})}function sh({active:e=!1,label:t,color:n,icon:r,className:i,...a}){return(0,B.jsx)(`button`,{type:`button`,"aria-pressed":e,"aria-label":t,title:t,"data-active":e?``:void 0,className:V(Bm.railItem,i),...a,children:(0,B.jsx)(`span`,{"aria-hidden":`true`,className:Bm.railGlyph,style:n?{color:n}:void 0,children:r??t.charAt(0).toUpperCase()})})}var ch=[[`claude`,`Anthropic`],[`gpt`,`OpenAI`],[`o1`,`OpenAI`],[`o3`,`OpenAI`],[`o4`,`OpenAI`],[`gemini`,`Google`],[`mistral`,`Mistral`],[`grok`,`xAI`],[`llama`,`Meta`],[`codellama`,`Meta`],[`deepseek`,`DeepSeek`],[`qwen`,`Alibaba`],[`phi`,`Microsoft`]];function lh(e){let t=e.toLowerCase();return ch.find(([e])=>t.startsWith(e))?.[1]??null}function uh(e,t){if(!t.backend||e.length<2)return null;let n=e[0]?.trim();return n?n.toLowerCase()===t.backend?Gm(t.backend,Vm):n:null}function dh(e){let t=e.id,n=t.split(`/`),r=Gm(e.provider,Vm),i,a;return n.length===1?(i=lh(n[0]),a=n[0]):n.length===2?(i=lh(n[1]),a=n[1]):(i=Gm(n[1],Hm),a=n.slice(2).join(`/`)),{id:t,groupLabel:i?`${r} · ${i}`:r,providerRank:Um[r]??50,vendorRank:i?Wm[i]??50:0,routeLabel:uh(n,e),shortName:a,displayName:Xm(a),vendor:i,provider:r,meta:e}}function fh(e,t){return e.providerRank===t.providerRank?e.vendorRank===t.vendorRank?e.groupLabel.localeCompare(t.groupLabel):e.vendorRank-t.vendorRank:e.providerRank-t.providerRank}function ph(e){return!e||e<=0?null:Ka(e)}function mh(e){let t=e.meta.family,n=t&&t!==e.shortName?Xm(t):null,r=[e.routeLabel,e.meta.parameterSize?.trim()||null,n&&n!==e.displayName?n:null,e.vendor].filter(e=>!!e);return r.length===0?null:r.join(` · `)}function hh(e,t){if(!t)return!0;let n=[e.id,e.shortName,e.displayName,e.provider,e.routeLabel??``,e.vendor??``,e.groupLabel].join(` `).toLowerCase();return t.toLowerCase().split(/\s+/).filter(Boolean).every(e=>n.includes(e))}function gh(e){let[t,n]=(0,R.useState)(``),[r,i]=(0,R.useState)(null),a=(0,R.useMemo)(()=>e.models.map(dh),[e.models]),o=(0,R.useMemo)(()=>{let e=new Map;for(let t of a){let n=Zm(t);e.set(n,(e.get(n)??0)+1)}return Array.from(e.entries()).map(([e,t])=>({key:e,count:t})).sort((e,t)=>e.key.localeCompare(t.key))},[a]),s=(0,R.useMemo)(()=>{let e=a.filter(e=>!(!hh(e,t)||r&&Zm(e)!==r)),n=new Map;for(let t of e){let e=n.get(t.groupLabel);e||(e={head:t,items:[]},n.set(t.groupLabel,e)),e.items.push(t)}let i=Array.from(n.values()).sort((e,t)=>fh(e.head,t.head));for(let e of i)e.items.sort((e,t)=>e.shortName.localeCompare(t.shortName)||(e.routeLabel??``).localeCompare(t.routeLabel??``)||e.id.localeCompare(t.id));return i},[a,t,r]),c=e.selectedModelId.trim(),l=eh(c),u=a.find(e=>e.id===c)??(l?dh(l):void 0);return e.models.length===0&&!u?null:(0,B.jsxs)(Cm,{value:u?u.id:``,disabled:e.disabled,onValueChange:t=>{!t||t===c||e.onSwitch(t)},children:[(0,B.jsxs)(wm,{"aria-label":`Switch model`,title:`Switch model`,className:V(zm.composerPill,Bm.triggerPill),children:[u?(0,B.jsx)(`span`,{"aria-hidden":`true`,className:Bm.triggerLogo,children:(0,B.jsx)(ih,{vendor:u.vendor,fallbackProvider:u.provider,size:16})}):null,(0,B.jsx)(Tm,{placeholder:`Select model`,children:u?u.displayName:``}),(0,B.jsx)(Em,{})]}),(0,B.jsx)(Om,{align:`start`,header:(0,B.jsx)(ah,{value:t,onValueChange:n,placeholder:`Search models…`,"aria-label":`Search models`}),rail:(0,B.jsxs)(oh,{children:[(0,B.jsx)(sh,{label:r===null?`All providers`:`Clear filter`,active:r===null,icon:(0,B.jsx)(yr,{width:`16`,height:`16`}),onClick:()=>i(null)}),o.map(({key:e,count:t})=>(0,B.jsx)(sh,{label:`${e} (${t})`,active:r===e,icon:(0,B.jsx)(rh,{provider:e}),onClick:()=>i(t=>t===e?null:e)},e))]}),children:s.length===0?(0,B.jsxs)(jm,{children:[`No models match “`,t,`”.`]}):s.map(e=>(0,B.jsxs)(km,{children:[(0,B.jsx)(Am,{children:e.head.groupLabel}),e.items.map(e=>{let t=ph(e.meta.contextWindow),n=mh(e);return(0,B.jsxs)(Mm,{value:e.id,textValue:`${e.displayName} ${e.groupLabel} ${e.routeLabel??``}`,children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,className:Bm.itemLogo,children:(0,B.jsx)(ih,{vendor:e.vendor,fallbackProvider:e.provider,size:18})}),(0,B.jsxs)(Pm,{children:[(0,B.jsx)(Nm,{children:e.displayName}),n?(0,B.jsx)(Fm,{children:n}):null]}),(0,B.jsx)(Im,{children:t?(0,B.jsx)(`span`,{children:t}):null})]},e.id)})]},e.head.groupLabel))})]})}var _h={enabled:!1,mode:`rewrite`,policy:``,doList:[],dontList:[],bannedPhrases:[],bannedPatterns:[],requirePhrases:[],classifier:{provider:`default`,model:``},rewriter:{provider:`default`,model:``}};function vh(e,t){return JSON.stringify(e)===JSON.stringify(t)}function yh(e,t=``){return{provider:e,model:e===`model`?t.trim():``}}function bh(e,t){let n=e?.trim()??``;if(!n)return``;let r=t.find(e=>e.id===n);return r?dh(r).displayName:n}function xh(e){let t=e=>e.map(e=>e.trim()).filter(Boolean);return{...e,policy:e.policy.trim(),doList:t(e.doList),dontList:t(e.dontList),bannedPhrases:t(e.bannedPhrases),bannedPatterns:t(e.bannedPatterns),requirePhrases:t(e.requirePhrases),classifier:yh(e.classifier.provider,e.classifier.model),rewriter:yh(e.rewriter.provider,e.rewriter.model)}}function Sh(e){let t=(0,R.useRef)(0),n=(0,R.useCallback)(n=>{let r={id:`${e.label}-${t.current}`,value:n};return t.current+=1,r},[e.label]),[r,i]=(0,R.useState)(()=>e.values.map(n)),a=t=>{i(t),e.onChange(t.map(e=>e.value))};return(0,R.useEffect)(()=>{i(t=>e.values.map((e,r)=>{if(t[r]?.value===e)return t[r];let i=t[r];return i?{...i,value:e}:n(e)}))},[n,e.values]),(0,B.jsxs)(`div`,{className:`field output-guard-list-field`,children:[(0,B.jsx)(`span`,{children:e.label}),(0,B.jsxs)(`div`,{className:`output-guard-list`,children:[r.map((t,n)=>(0,B.jsxs)(`div`,{className:`output-guard-list-row`,children:[(0,B.jsx)(`input`,{"aria-label":`${e.label} item ${n+1}`,value:t.value,onChange:e=>a(r.map((t,r)=>r===n?{...t,value:e.target.value}:t)),placeholder:e.placeholder}),(0,B.jsx)(`button`,{className:`ghost-button icon-button`,type:`button`,"aria-label":`Remove ${e.label} item ${n+1}`,title:`Remove`,onClick:()=>{a(r.filter((e,t)=>t!==n))},children:(0,B.jsx)(Fr,{width:`16`,height:`16`})})]},t.id)),(0,B.jsx)(`button`,{className:`ghost-button output-guard-add-button`,type:`button`,"aria-label":`Add ${e.label} item`,onClick:()=>{a([...r,n(``)])},children:`Add`})]})]})}function Ch(e){let t=e.value.provider===`model`?e.value.model:``,n=bh(e.activeModelId,e.modelOptions)||e.activeModelFallback;return(0,B.jsxs)(`div`,{className:`field`,children:[(0,B.jsx)(`span`,{children:e.label}),(0,B.jsxs)(`div`,{className:`output-guard-model-source-control has-model-readout ${e.value.provider===`model`?`has-model-select`:``}`,children:[(0,B.jsx)(Wa,{ariaLabel:e.ariaLabel,value:e.value.provider,options:[{value:`default`,label:`default model`},{value:`auxiliary`,label:`aux model`},{value:`model`,label:`other model`}],onChange:t=>{let n=t===`model`?e.value.model||e.defaultOtherModelId:``;e.onChange(yh(t,n))}}),e.value.provider===`model`?(0,B.jsx)(gh,{models:e.modelOptions,selectedModelId:t,disabled:e.modelsLoading,onSwitch:t=>e.onChange(yh(`model`,t))}):(0,B.jsx)(`div`,{className:`output-guard-model-readout`,title:e.activeModelId||n,children:n})]})]})}function wh(e){return e===`compliant`?`compliant`:e===`needs_review`?`needs review`:`non-compliant`}function Th(e){return e.kind===`banned_phrase`?`Contains banned phrase "${e.detail}".`:e.kind===`banned_pattern`?`Matches banned pattern ${e.detail}.`:`Missing required phrase "${e.detail}".`}function Eh(e){let{classifier:t}=e;if(t.status===`evaluated`&&t.verdict){let e=t.severity?`, ${t.severity}`:``,n=t.model?` via ${t.model}`:``;return`Classifier ${t.provider==="default"?`default model`:t.provider===`auxiliary`?`aux model`:`selected model`}${n}: ${wh(t.verdict)}${e}.`}return t.status===`unparseable`?`Classifier response was not parseable; showing rules score.`:e.scoreSource===`classifier`?`Classifier unavailable; failure mode blocks output.`:`Classifier unavailable; showing rules score.`}function Dh(){let e=Gn(),t=hs(),n=o(),[r,i]=(0,R.useState)(_h),[a,s]=(0,R.useState)(``),[c,l]=(0,R.useState)(null),u=y({queryKey:[`output-guard-profile`,e.token],queryFn:()=>On(e.token)}),d=y({queryKey:[`models`,e.token],queryFn:()=>Kt(e.token)});(0,R.useEffect)(()=>{u.data?.profile&&i(u.data.profile)},[u.data?.profile]);let f=u.data?.profile??_h,p=!vh(xh(r),f),m=d.data?.models??[],h=d.data?.defaultModel??``,_=d.data?.auxiliaryModels?.skillsHub.model??null,v=d.data?.auxiliaryModels?.skillsHub.provider??`auto`,b=m.find(e=>e.id!==h)?.id??h;(0,R.useEffect)(()=>{b&&((r.classifier.provider!==`model`||r.classifier.model)&&(r.rewriter.provider!==`model`||r.rewriter.model)||i(e=>{let t=e;return e.classifier.provider===`model`&&!e.classifier.model&&(t={...t,classifier:yh(`model`,b)}),e.rewriter.provider===`model`&&!e.rewriter.model&&(t={...t,rewriter:yh(`model`,b)}),t}))},[b,r.classifier.model,r.classifier.provider,r.rewriter.model,r.rewriter.provider]);let x=g({mutationFn:()=>kn(e.token,xh(r)),onSuccess:r=>{i(r.profile),t.success(r.changed?`Output guard saved.`:`Output guard unchanged.`,r.reloadMessage),n.setQueryData([`output-guard-profile`,e.token],r),n.invalidateQueries({queryKey:[`output-guard-profile`,e.token]})},onError:e=>{t.error(`Save failed`,H(e))}}),S=g({mutationFn:()=>An(e.token,xh(r),a),onSuccess:e=>{l(e)},onError:e=>{t.error(`Preview failed`,H(e))}});return(0,B.jsxs)(`div`,{className:`page-stack output-guard-page`,children:[(0,B.jsx)(Ha,{description:`Operator controls for output policy, rules, classifier, and rewrite behavior.`,actions:(0,B.jsx)(`button`,{className:`primary-button`,type:`button`,disabled:!p||x.isPending,onClick:()=>x.mutate(),children:x.isPending?`Saving...`:`Save profile`})}),(0,B.jsxs)(`div`,{className:`two-column-grid`,children:[(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:`Profile`}),(0,B.jsx)(uo,{children:`Runtime plugin profile`})]}),(0,B.jsx)(K,{children:u.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading output guard...`}):u.isError?(0,B.jsx)(`div`,{className:`empty-state`,children:H(u.error)}):(0,B.jsxs)(`div`,{className:`stack-form`,children:[(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:r.enabled,onCheckedChange:e=>i(t=>({...t,enabled:e}))}),(0,B.jsx)(Bo,{children:(0,B.jsx)(J,{children:`Enabled`})})]}),(0,B.jsxs)(`div`,{className:`field`,children:[(0,B.jsx)(`span`,{children:`Mode`}),(0,B.jsx)(Wa,{ariaLabel:`Output guard mode`,value:r.mode,options:[{value:`rewrite`,label:`rewrite`},{value:`block`,label:`block`},{value:`flag`,label:`flag`}],onChange:e=>i(t=>({...t,mode:e}))})]}),(0,B.jsx)(Ch,{label:`Classifier`,ariaLabel:`Output guard classifier source`,value:r.classifier,modelOptions:m,defaultOtherModelId:b,activeModelId:r.classifier.provider==="default"?h:_,activeModelFallback:r.classifier.provider==="default"?`No default model`:v===`disabled`?`Aux model disabled`:`Auto routing`,modelsLoading:d.isLoading,onChange:e=>i(t=>({...t,classifier:e}))}),(0,B.jsx)(Ch,{label:`Rewriter`,ariaLabel:`Output guard rewriter source`,value:r.rewriter,modelOptions:m,defaultOtherModelId:b,activeModelId:r.rewriter.provider==="default"?h:_,activeModelFallback:r.rewriter.provider==="default"?`No default model`:v===`disabled`?`Aux model disabled`:`Auto routing`,modelsLoading:d.isLoading,onChange:e=>i(t=>({...t,rewriter:e}))}),(0,B.jsxs)(`label`,{className:`field textarea-field`,children:[(0,B.jsx)(`span`,{children:`Policy`}),(0,B.jsx)(`textarea`,{rows:5,value:r.policy,onChange:e=>i(t=>({...t,policy:e.target.value})),placeholder:`Clear, direct, concrete. No hype.`})]}),(0,B.jsx)(Sh,{label:`Do`,values:r.doList,placeholder:`Use concrete nouns`,onChange:e=>i(t=>({...t,doList:e}))}),(0,B.jsx)(Sh,{label:`Don't`,values:r.dontList,placeholder:`Use hype or vague claims`,onChange:e=>i(t=>({...t,dontList:e}))}),(0,B.jsx)(`small`,{className:`output-guard-list-note`,children:`Do and Don't guide rewrites and classifier context; banned and required rules stay deterministic.`}),(0,B.jsx)(Sh,{label:`Banned phrases`,values:r.bannedPhrases,placeholder:`game changing`,onChange:e=>i(t=>({...t,bannedPhrases:e}))}),(0,B.jsx)(Sh,{label:`Banned patterns`,values:r.bannedPatterns,placeholder:`/\\\\bguarantee[sd]?\\\\b/i`,onChange:e=>i(t=>({...t,bannedPatterns:e}))}),(0,B.jsx)(Sh,{label:`Required phrases`,values:r.requirePhrases,placeholder:`Best regards`,onChange:e=>i(t=>({...t,requirePhrases:e}))})]})})]}),(0,B.jsxs)(`div`,{className:`page-stack`,children:[(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:`Preview`}),(0,B.jsx)(uo,{children:c?`${c.score}/100, ${wh(c.verdict)} (${c.scoreSource})`:`No score yet`})]}),(0,B.jsxs)(K,{children:[(0,B.jsxs)(`label`,{className:`field textarea-field`,children:[(0,B.jsx)(`span`,{children:`Sample output`}),(0,B.jsx)(`textarea`,{rows:9,value:a,onChange:e=>s(e.target.value),placeholder:`Paste assistant output`})]}),(0,B.jsx)(`button`,{className:`primary-button`,type:`button`,disabled:!a.trim()||S.isPending,onClick:()=>S.mutate(),children:S.isPending?`Scoring...`:`Score sample`}),c?(0,B.jsxs)(`div`,{className:`output-guard-score-panel`,children:[(0,B.jsx)(`div`,{className:`output-guard-score-bar`,children:(0,B.jsx)(`span`,{style:{width:`${c.score}%`}})}),(0,B.jsx)(`small`,{children:Eh(c)}),c.violations.length>0?(0,B.jsx)(`ul`,{className:`output-guard-reason-list`,children:c.violations.map(e=>{let t=Th(e);return(0,B.jsx)(`li`,{children:t},t)})}):(0,B.jsx)(`small`,{children:`No rule violations detected.`}),c.classifier.reasons.length>0?(0,B.jsx)(`ul`,{className:`output-guard-reason-list`,children:c.classifier.reasons.map(e=>(0,B.jsx)(`li`,{children:e},`classifier-${e}`))}):null]}):null]})]}),(0,B.jsxs)(U,{variant:`muted`,children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:`Versions`}),(0,B.jsx)(uo,{children:`${u.data?.revisions.length??0} profile edits`})]}),(0,B.jsx)(K,{children:u.data?.revisions.length?(0,B.jsx)(`div`,{className:`list-stack selectable-list`,children:u.data.revisions.map(e=>(0,B.jsxs)(`div`,{className:`list-row`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`strong`,{children:[`Revision `,e.id]}),(0,B.jsx)(`small`,{children:Qa(e.createdAt)}),(0,B.jsx)(`small`,{children:e.actor})]}),(0,B.jsx)(`span`,{className:`list-status`,children:e.source})]},e.id))}):(0,B.jsx)(`div`,{className:`empty-state`,children:`No saved profile edits yet.`})})]})]})]})]})}var Oh={plugin:(e,t)=>X(e.name||e.id,t.name||t.id)||X(e.id,t.id),source:(e,t)=>X(e.source,t.source)||X(e.name||e.id,t.name||t.id),enabled:(e,t)=>es(e.enabled,t.enabled)||X(e.name||e.id,t.name||t.id),status:(e,t)=>es(e.status===`loaded`,t.status===`loaded`)||X(e.name||e.id,t.name||t.id),commands:(e,t)=>$o(e.commands.length,t.commands.length)||X(e.name||e.id,t.name||t.id),tools:(e,t)=>$o(e.tools.length,t.tools.length)||X(e.name||e.id,t.name||t.id),hooks:(e,t)=>$o(e.hooks.length,t.hooks.length)||X(e.name||e.id,t.name||t.id)},kh={enabled:`desc`,status:`desc`,commands:`desc`,tools:`desc`,hooks:`desc`};function Ah(e){return e.length>0?e.join(`, `):`none`}function jh(e,t){return t?[e.id,e.name||``,e.description||``,e.source,e.status,e.error||``,...e.commands,...e.tools,...e.hooks].join(` `).toLowerCase().includes(t):!0}function Mh(){let e=Gn(),[t,n]=(0,R.useState)(``),r=(0,R.useDeferredValue)(t).trim().toLowerCase(),i=y({queryKey:[`plugins`,e.token],queryFn:()=>Dn(e.token)}),{sortedRows:a,sortState:o,toggleSort:s}=Ba((i.data?.plugins||[]).filter(e=>jh(e,r)),{initialSort:{key:`plugin`,direction:`asc`},sorters:Oh,defaultDirections:kh}),c=a.filter(e=>e.status===`failed`);return(0,B.jsxs)(`div`,{className:`page-stack`,children:[(0,B.jsx)(Ha,{description:`Discovery and runtime load status for configured HybridClaw plugins.`,actions:(0,B.jsx)(`input`,{className:`compact-search`,value:t,onChange:e=>n(e.target.value),placeholder:`Filter plugins`})}),(0,B.jsxs)(`div`,{className:`metric-grid`,children:[(0,B.jsx)(Ua,{label:`Plugins`,value:String(i.data?.totals.totalPlugins??0),detail:`${i.data?.totals.enabledPlugins??0} enabled`,loading:!i.data}),(0,B.jsx)(Ua,{label:`Load failures`,value:String(i.data?.totals.failedPlugins??0),detail:`runtime initialization errors`,loading:!i.data}),(0,B.jsx)(Ua,{label:`Commands`,value:String(i.data?.totals.commands??0),detail:`plugin-defined commands`,loading:!i.data}),(0,B.jsx)(Ua,{label:`Tools / Hooks`,value:`${i.data?.totals.tools??0} / ${i.data?.totals.hooks??0}`,detail:`registered runtime surfaces`,loading:!i.data})]}),(0,B.jsxs)(`div`,{className:`two-column-grid`,children:[(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:`Registry`}),(0,B.jsx)(uo,{children:`${a.length} plugin${a.length===1?``:`s`} visible`})]}),(0,B.jsx)(K,{children:i.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading plugins...`}):a.length===0?(0,B.jsx)(`div`,{className:`empty-state`,children:`No plugins match this filter.`}):(0,B.jsx)(`div`,{className:`table-shell`,children:(0,B.jsxs)(`table`,{children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(Va,{label:`Plugin`,sortKey:`plugin`,sortState:o,onToggle:s}),(0,B.jsx)(Va,{label:`Source`,sortKey:`source`,sortState:o,onToggle:s}),(0,B.jsx)(Va,{label:`Enabled`,sortKey:`enabled`,sortState:o,onToggle:s}),(0,B.jsx)(Va,{label:`Status`,sortKey:`status`,sortState:o,onToggle:s}),(0,B.jsx)(Va,{label:`Commands`,sortKey:`commands`,sortState:o,onToggle:s}),(0,B.jsx)(Va,{label:`Tools`,sortKey:`tools`,sortState:o,onToggle:s}),(0,B.jsx)(Va,{label:`Hooks`,sortKey:`hooks`,sortState:o,onToggle:s})]})}),(0,B.jsx)(`tbody`,{children:a.map(e=>(0,B.jsxs)(`tr`,{children:[(0,B.jsxs)(`td`,{children:[(0,B.jsx)(`strong`,{children:e.name||e.id}),(0,B.jsxs)(`small`,{children:[e.id,e.version?` · v${e.version}`:``]}),e.description?(0,B.jsx)(`small`,{children:e.description}):null,e.error?(0,B.jsx)(`small`,{children:e.error}):null]}),(0,B.jsx)(`td`,{children:e.source}),(0,B.jsx)(`td`,{children:(0,B.jsx)(Ga,{value:e.enabled,trueLabel:`enabled`,falseLabel:`disabled`})}),(0,B.jsx)(`td`,{children:(0,B.jsx)(Ga,{value:e.status===`loaded`,trueLabel:`loaded`,falseLabel:`failed`})}),(0,B.jsxs)(`td`,{children:[(0,B.jsx)(`strong`,{children:e.commands.length}),(0,B.jsx)(`small`,{children:Ah(e.commands)})]}),(0,B.jsxs)(`td`,{children:[(0,B.jsx)(`strong`,{children:e.tools.length}),(0,B.jsx)(`small`,{children:Ah(e.tools)})]}),(0,B.jsxs)(`td`,{children:[(0,B.jsx)(`strong`,{children:e.hooks.length}),(0,B.jsx)(`small`,{children:Ah(e.hooks)})]})]},e.id))})]})})})]}),(0,B.jsxs)(U,{variant:`muted`,children:[(0,B.jsx)(W,{children:(0,B.jsx)(G,{children:`Failures`})}),(0,B.jsx)(K,{children:i.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading plugin status...`}):c.length>0?(0,B.jsx)(`div`,{className:`list-stack selectable-list`,children:c.map(e=>(0,B.jsxs)(`div`,{className:`list-row`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:e.name||e.id}),(0,B.jsxs)(`small`,{children:[e.id,e.version?` · v${e.version}`:``]}),(0,B.jsx)(`small`,{children:e.error||`Unknown plugin load error.`})]}),(0,B.jsxs)(`span`,{className:`list-status list-status-danger`,children:[(0,B.jsx)(`span`,{className:`status-dot status-dot-danger`}),`failed`]})]},e.id))}):(0,B.jsx)(`div`,{className:`empty-state`,children:`No plugin load failures were reported.`})})]})]})]})}var Nh={anchor:`_anchor_1k3rt_1`,input:`_input_1k3rt_7`,chevron:`_chevron_1k3rt_11`,popover:`_popover_1k3rt_22`,list:`_list_1k3rt_28`,option:`_option_1k3rt_39`,optionLabel:`_optionLabel_1k3rt_60`,optionDescription:`_optionDescription_1k3rt_64`,empty:`_empty_1k3rt_69`},Ph=(e,t)=>{if(!t)return!0;let n=t.toLowerCase();return e.label.toLowerCase().includes(n)||e.value.toLowerCase().includes(n)};function Fh({value:e,onValueChange:t,options:n,placeholder:r,disabled:i,renderOption:a,emptyMessage:o=`No matches.`,filter:s=Ph,allowFreeText:c=!1,popoverAlign:l=`start`,className:u,id:d,onBlur:f}){let p=Do({id:d,disabled:i,"aria-invalid":void 0,"aria-describedby":void 0}),m=(0,R.useId)(),h=`${p.id??m}-listbox`,g=(0,R.useMemo)(()=>n.find(t=>t.value===e)??null,[n,e]),_=g?g.label:c?e:``,[v,y]=(0,R.useState)(!1),[b,x]=(0,R.useState)(_),[S,C]=(0,R.useState)(0),w=(0,R.useRef)(null),T=(0,R.useRef)(!1);(0,R.useEffect)(()=>{v||x(_)},[_,v]);let E=(0,R.useMemo)(()=>v?n.filter(e=>s(e,b.trim())):n,[n,v,b,s]);(0,R.useEffect)(()=>{S>=E.length&&C(0)},[E.length,S]);let D=(0,R.useCallback)((e,n)=>{T.current=!0,e?(t(e.value,e),x(e.label)):c&&t(n??``,null),y(!1)},[c,t]),O=e=>{x(e.target.value),y(!0),C(0)},k=e=>{if(e.key===`ArrowDown`)e.preventDefault(),y(!0),C(e=>Math.min(e+1,Math.max(0,E.length-1)));else if(e.key===`ArrowUp`)e.preventDefault(),y(!0),C(e=>Math.max(e-1,0));else if(e.key===`Enter`){if(!v)return;e.preventDefault();let t=E[S];t&&!t.disabled?D(t):c&&D(null,b)}else if(e.key===`Escape`){if(!v)return;e.preventDefault(),y(!1),x(_)}else if(e.key===`Tab`){if(!v)return;let e=E[S];e&&!e.disabled&&D(e)}},A=()=>{if(y(!1),T.current){T.current=!1,f?.();return}if(c)b!==_&&D(null,b);else{let t=n.find(e=>e.label===b||e.value===b);t?t.value!==e&&D(t):x(_)}f?.()};return(0,B.jsxs)(Oi,{open:v,onOpenChange:y,children:[(0,B.jsxs)(ki,{className:V(Nh.anchor,u),children:[(0,B.jsx)(Y,{...p,ref:w,type:`text`,role:`combobox`,"aria-expanded":v,"aria-controls":v?h:void 0,"aria-autocomplete":`list`,"aria-activedescendant":v&&E[S]?`${h}-option-${S}`:void 0,value:b,placeholder:r,onFocus:()=>y(!0),onChange:O,onKeyDown:k,onBlur:A,className:Nh.input,autoComplete:`off`,spellCheck:!1}),(0,B.jsx)(er,{"aria-hidden":`true`,className:Nh.chevron})]}),(0,B.jsx)(Ai,{align:l,className:Nh.popover,children:(0,B.jsx)(`div`,{role:`listbox`,id:h,className:Nh.list,children:E.length===0?(0,B.jsx)(`div`,{className:Nh.empty,children:o}):E.map((t,n)=>{let r=n===S,i=t.value===e;return(0,B.jsx)(`div`,{id:`${h}-option-${n}`,role:`option`,"aria-selected":i,"aria-disabled":t.disabled||void 0,"data-active":r||void 0,"data-disabled":t.disabled||void 0,tabIndex:-1,className:Nh.option,onMouseDown:e=>{e.preventDefault(),t.disabled||D(t)},onMouseEnter:()=>C(n),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t.disabled||D(t))},children:a?a(t,r):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:Nh.optionLabel,children:t.label}),t.description?(0,B.jsx)(`span`,{className:Nh.optionDescription,children:t.description}):null]})},t.value)})})})]})}function Ih(e){if(e==null)return null;if(e instanceof Date)return Number.isNaN(e.getTime())?null:e;let t=e.trim();if(!t)return null;let n=/^\d{4}-\d{2}-\d{2}$/.test(t)?`${t}T00:00`:t,r=new Date(n);return Number.isNaN(r.getTime())?null:r}function Lh(e,t){if(!e)return``;let n=e.getTimezoneOffset()*6e4,r=new Date(e.getTime()-n).toISOString();return t===`day`?r.slice(0,10):t===`second`?r.slice(0,19):r.slice(0,16)}function Rh({value:e,onValueChange:t,onErrorChange:n,granularity:r=`minute`,min:i,max:a,required:o=!1,...s}){let c=Eo(),l=r===`day`?`date`:`datetime-local`,u=r===`second`?1:void 0,d=(0,R.useMemo)(()=>Ih(i??null),[i]),f=(0,R.useMemo)(()=>Ih(a??null),[a]),p=Lh((0,R.useMemo)(()=>Ih(e),[e]),r),m=(0,R.useCallback)(e=>{c.setError(e),n?.(e)},[c.setError,n]);return(0,B.jsx)(Y,{...s,type:l,step:u,value:p,min:d?Lh(d,r):void 0,max:f?Lh(f,r):void 0,onChange:e=>{let n=e.target.value;if(n.trim()===``){if(o){m(`Required.`);return}m(null),t(null);return}let r=Ih(n);if(!r){m(`Enter a valid date.`);return}if(d&&r<d){m(`Date is earlier than the minimum allowed.`);return}if(f&&r>f){m(`Date is later than the maximum allowed.`);return}m(null),t(r)}})}var zh=[`backlog`,`in_progress`,`review`,`done`,`cancelled`],Bh=[`cron`,`every`,`at`,`one_shot`],Vh=[`agent_turn`,`system_event`],Hh=[`channel`,`last-channel`,`webhook`];function Uh(e){return e?.source===`job`}function Wh(e){return e?.source===`task`}function Gh(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t}function Kh(e){return e.schedule.kind===`one_shot`?`one shot`:e.schedule.kind===`cron`?e.schedule.expr||`invalid cron`:e.schedule.kind===`every`?`every ${e.schedule.everyMs}ms`:Qa(e.schedule.at)}function qh(e){return e.source===`task`?`task #${e.taskId??`n/a`} · ${Kh(e)}`:`${e.id} · ${Kh(e)}`}function Jh(e){return e.disabled?`paused`:e.boardStatus===`review`&&e.lastStatus===`error`?`failed`:e.lastStatus?e.lastStatus:e.enabled?`ready`:`inactive`}function Yh(e){return e?.boardStatus?e.boardStatus:e?!e.enabled||e.disabled?`cancelled`:e.lastStatus===`success`?`done`:e.lastStatus===`error`?`cancelled`:`backlog`:`backlog`}function Xh(e){return{originalId:e?.id||null,id:e?.id||``,name:e?.name||``,description:e?.description||``,agentId:e?.agentId||``,boardStatus:Yh(e),enabled:e?.enabled??!0,scheduleKind:e?.schedule.kind||`cron`,scheduleExpr:e?.schedule.expr||`0 * * * *`,scheduleEveryMs:e?.schedule.everyMs??6e4,scheduleAt:Gh(e?.schedule.at||null),scheduleTz:e?.schedule.tz||``,maxRetries:typeof e?.maxRetries==`number`?e.maxRetries:3,actionKind:e?.action.kind||`agent_turn`,actionMessage:e?.action.message||``,deliveryKind:e?.delivery.kind||`channel`,deliveryChannel:e?.delivery.channel||`tui`,deliveryTo:e?.delivery.to||``,deliveryWebhookUrl:e?.delivery.webhookUrl||``}}function Zh(e){let t=[{value:`tui`,label:`Local TUI`}],n=e.config;if(n){let r=vl(n,{discordTokenConfigured:e.status?.discord?.tokenConfigured,slackBotTokenConfigured:e.status?.slack?.botTokenConfigured,slackAppTokenConfigured:e.status?.slack?.appTokenConfigured,telegramTokenConfigured:e.status?.telegram?.tokenConfigured,whatsappLinked:e.status?.whatsapp?.linked,emailPasswordConfigured:e.status?.email?.passwordConfigured,imessagePasswordConfigured:e.status?.imessage?.passwordConfigured});for(let e of r)e.statusTone===`active`&&t.push({value:e.kind,label:e.label})}let r=e.currentChannel.trim();return r&&!t.some(e=>e.value===r)&&t.push({value:r,label:`${Qh(r)} (current)`}),t}function Qh(e){switch(e){case`discord`:return`Discord`;case`slack`:return`Slack`;case`telegram`:return`Telegram`;case`whatsapp`:return`WhatsApp`;case`email`:return`Email`;case`msteams`:return`Microsoft Teams`;case`imessage`:return`iMessage`;case`tui`:return`Local TUI`;case`web`:return`Local Web`;default:return e}}function $h(e,t){return t?e===`discord`?t.channels.filter(e=>e.transport===`discord`).map(e=>({value:e.channelId,label:`${e.guildId} · ${e.channelId}`})):e===`msteams`?t.channels.filter(e=>e.transport===`msteams`).map(e=>({value:e.channelId,label:`${e.guildId} · ${e.channelId}`})):[]:[]}function eg(e){let t=e.currentValue.trim();return e.channel===`tui`||e.channel===`web`?e.channel:e.options.length===0||e.options.some(e=>e.value===t)?t:e.options[0].value}function tg(e){let t=$h(e.channel,e.channels),n=eg({channel:e.channel,currentValue:e.currentValue,options:t});if(e.channel===`tui`||e.channel===`web`||(e.channel===`discord`||e.channel===`msteams`)&&t.length===1)return{kind:`none`,value:n};if((e.channel===`discord`||e.channel===`msteams`)&&t.length>1)return{kind:`select`,value:n,label:`Channel`,options:t};switch(e.channel){case`discord`:return{kind:`input`,value:n,label:`Channel ID`,placeholder:`123456789012345678`};case`slack`:return{kind:`input`,value:n,label:`Conversation target`,placeholder:`slack:C1234567890`};case`telegram`:return{kind:`input`,value:n,label:`Chat ID`,placeholder:`telegram:-1001234567890`};case`whatsapp`:return{kind:`input`,value:n,label:`Chat JID`,placeholder:`491234567890@s.whatsapp.net`};case`email`:return{kind:`input`,value:n,label:`Recipient`,placeholder:`ops@example.com`};case`imessage`:return{kind:`input`,value:n,label:`Handle`,placeholder:`imessage:ops@example.com`};case`msteams`:return{kind:`input`,value:n,label:`Channel ID`,placeholder:`19:channel-id@thread.tacv2`};default:return{kind:`input`,value:n,label:`Target`,placeholder:e.channel||`target`}}}function ng(e,t){return e.deliveryKind===`channel`?{...e,deliveryTo:t.value}:{...e,deliveryTo:``}}function rg(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,48)}function ig(e){let t=e.id.trim();if(t)return{...e,id:t};let n=rg(e.name)||rg(e.description)||rg(e.actionMessage)||`job-${Date.now().toString(36).slice(-8).toLowerCase()}`;return{...e,id:n}}function ag(e){let t=e.scheduleKind===`at`&&e.scheduleAt?e.scheduleAt.toISOString():null;if(e.scheduleKind===`at`&&!t)throw Error(`Pick a valid "Run at" timestamp.`);return{id:e.id.trim(),source:`job`,name:e.name.trim()||e.id.trim(),description:e.description.trim()||null,agentId:e.agentId.trim()||null,boardStatus:e.boardStatus,maxRetries:e.scheduleKind===`one_shot`?e.maxRetries:null,enabled:e.enabled,schedule:{kind:e.scheduleKind,at:t,everyMs:e.scheduleKind===`every`?e.scheduleEveryMs:null,expr:e.scheduleKind===`cron`&&e.scheduleExpr.trim()||null,tz:e.scheduleKind===`one_shot`?``:e.scheduleTz.trim()},action:{kind:e.actionKind,message:e.actionMessage.trim()},delivery:{kind:e.deliveryKind,channel:e.deliveryChannel.trim()||`tui`,to:e.deliveryKind===`channel`?e.deliveryTo.trim():``,webhookUrl:e.deliveryKind===`webhook`?e.deliveryWebhookUrl.trim():``},lastRun:null,lastStatus:null,nextRunAt:null,disabled:!1,consecutiveErrors:0,createdAt:null,sessionId:null,channelId:null,taskId:null}}function og(e,t,n){n.setQueryData([`scheduler`,t],e)}function sg(e){return(0,B.jsxs)(U,{variant:`muted`,children:[(0,B.jsx)(W,{children:(0,B.jsx)(G,{children:`Task`})}),(0,B.jsx)(K,{children:(0,B.jsxs)(`div`,{className:`stack-form`,children:[(0,B.jsxs)(`div`,{className:`key-value-grid`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Task`}),(0,B.jsxs)(`strong`,{children:[`#`,e.job.taskId??`n/a`]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`State`}),(0,B.jsx)(Ga,{value:e.job.enabled&&!e.job.disabled,trueLabel:`active`,falseLabel:`inactive`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Session`}),(0,B.jsx)(`strong`,{children:e.job.sessionId||`n/a`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Channel`}),(0,B.jsx)(`strong`,{children:e.job.channelId||`n/a`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Created`}),(0,B.jsx)(`strong`,{children:Qa(e.job.createdAt)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Next run`}),(0,B.jsx)(`strong`,{children:Qa(e.job.nextRunAt)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Last run`}),(0,B.jsx)(`strong`,{children:Qa(e.job.lastRun)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Last status`}),(0,B.jsx)(`strong`,{children:e.job.lastStatus||`n/a`})]})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Message`}),(0,B.jsx)(Jo,{readOnly:!0,rows:6,value:e.job.action.message})]}),(0,B.jsxs)(`div`,{className:`button-row`,children:[(0,B.jsx)(`button`,{className:`ghost-button`,type:`button`,disabled:e.pausePending,onClick:e.onPauseToggle,children:e.pausePending?`Updating...`:e.job.disabled?`Resume task`:`Pause task`}),(0,B.jsx)(`button`,{className:`danger-button`,type:`button`,disabled:e.deletePending,onClick:e.onDelete,children:e.deletePending?`Deleting...`:`Delete task`})]})]})})]})}function cg(e){let{draft:t,selectedJob:n}=e;return(0,B.jsx)(Oc,{form:e.form,onSubmit:e.onSave,children:(0,B.jsxs)(U,{variant:`muted`,children:[(0,B.jsx)(W,{children:(0,B.jsx)(G,{children:`Job`})}),(0,B.jsx)(K,{children:(0,B.jsxs)(`div`,{className:`stack-form`,children:[(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`ID`}),(0,B.jsx)(Y,{value:t.id,onChange:t=>e.onDraftChange(e=>({...e,id:t.target.value})),placeholder:`Auto-generated from name if blank`})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Name`}),(0,B.jsx)(Y,{value:t.name,onChange:t=>e.onDraftChange(e=>({...e,name:t.target.value})),placeholder:`Nightly research`})]})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Description`}),(0,B.jsx)(Y,{value:t.description,onChange:t=>e.onDraftChange(e=>({...e,description:t.target.value})),placeholder:`Optional`})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Status`}),(0,B.jsxs)(ds,{value:t.boardStatus,onChange:t=>e.onDraftChange(e=>({...e,boardStatus:nu(zh,t.target.value,e.boardStatus)})),children:[(0,B.jsx)(Q,{value:`backlog`,children:`backlog`}),(0,B.jsx)(Q,{value:`in_progress`,children:`in progress`}),(0,B.jsx)(Q,{value:`review`,children:`review`}),(0,B.jsx)(Q,{value:`done`,children:`done`}),(0,B.jsx)(Q,{value:`cancelled`,children:`cancelled`})]})]}),(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:t.enabled,onCheckedChange:t=>e.onDraftChange(e=>({...e,enabled:t}))}),(0,B.jsx)(Bo,{children:(0,B.jsx)(J,{children:`State`})})]})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Schedule`}),(0,B.jsxs)(ds,{value:t.scheduleKind,onChange:t=>e.onDraftChange(e=>{let n=nu(Bh,t.target.value,e.scheduleKind);return{...e,scheduleKind:n,boardStatus:n===`one_shot`?`backlog`:e.boardStatus}}),children:[(0,B.jsx)(Q,{value:`cron`,children:`cron`}),(0,B.jsx)(Q,{value:`every`,children:`every`}),(0,B.jsx)(Q,{value:`at`,children:`at`}),(0,B.jsx)(Q,{value:`one_shot`,children:`one shot`})]})]}),t.scheduleKind===`one_shot`?null:(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Timezone`}),(0,B.jsx)(Y,{value:t.scheduleTz,onChange:t=>e.onDraftChange(e=>({...e,scheduleTz:t.target.value})),placeholder:`Europe/Berlin`})]})]}),t.scheduleKind===`cron`?(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Cron`}),(0,B.jsx)(Y,{value:t.scheduleExpr,onChange:t=>e.onDraftChange(e=>({...e,scheduleExpr:t.target.value})),placeholder:`0 * * * *`})]}):null,t.scheduleKind===`every`?(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Every ms`}),(0,B.jsx)(jc,{integer:!0,min:1,value:t.scheduleEveryMs,onValueChange:t=>e.onDraftChange(e=>({...e,scheduleEveryMs:t})),placeholder:`60000`}),(0,B.jsx)(Wo,{})]}):null,t.scheduleKind===`at`?(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Run at`}),(0,B.jsx)(Rh,{required:!0,value:t.scheduleAt,onValueChange:t=>e.onDraftChange(e=>({...e,scheduleAt:t}))}),(0,B.jsx)(Wo,{})]}):null,t.scheduleKind===`one_shot`?(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Retries after failure`}),(0,B.jsx)(jc,{integer:!0,min:0,max:100,value:t.maxRetries,onValueChange:t=>e.onDraftChange(e=>({...e,maxRetries:t})),placeholder:`3`}),(0,B.jsx)(Wo,{})]}):null,(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Action`}),(0,B.jsxs)(ds,{value:t.actionKind,onChange:t=>e.onDraftChange(e=>({...e,actionKind:nu(Vh,t.target.value,e.actionKind)})),children:[(0,B.jsx)(Q,{value:`agent_turn`,children:`agent_turn`}),(0,B.jsx)(Q,{value:`system_event`,children:`system_event`})]})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Delivery`}),(0,B.jsxs)(ds,{value:t.deliveryKind,onChange:t=>e.onDraftChange(e=>({...e,deliveryKind:nu(Hh,t.target.value,e.deliveryKind)})),children:[(0,B.jsx)(Q,{value:`channel`,children:`channel`}),(0,B.jsx)(Q,{value:`last-channel`,children:`last-channel`}),(0,B.jsx)(Q,{value:`webhook`,children:`webhook`})]})]})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Message`}),(0,B.jsx)(Jo,{rows:4,value:t.actionMessage,onChange:t=>e.onDraftChange(e=>({...e,actionMessage:t.target.value})),placeholder:`Prompt or system-event message`})]}),t.deliveryKind===`channel`?(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Channel type`}),(0,B.jsx)(ds,{value:t.deliveryChannel,onChange:t=>e.onDraftChange(e=>({...e,deliveryChannel:t.target.value,deliveryTo:``})),children:e.channelOptions.map(e=>(0,B.jsx)(Q,{value:e.value,children:e.label},e.value))})]}),e.targetControl.kind===`select`?(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:e.targetControl.label}),(0,B.jsx)(Fh,{value:e.targetControl.value,onValueChange:t=>e.onDraftChange(e=>({...e,deliveryTo:t})),options:e.targetControl.options})]}):null,e.targetControl.kind===`input`?(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:e.targetControl.label}),(0,B.jsx)(Y,{value:e.targetControl.value,onChange:t=>e.onDraftChange(e=>({...e,deliveryTo:t.target.value})),placeholder:e.targetControl.placeholder})]}):null]}):null,t.deliveryKind===`webhook`?(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Webhook URL`}),(0,B.jsx)(Y,{type:`url`,value:t.deliveryWebhookUrl,onChange:t=>e.onDraftChange(e=>({...e,deliveryWebhookUrl:t.target.value})),placeholder:`https://example.test/hook`})]}):null,n?(0,B.jsxs)(`div`,{className:`key-value-grid`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Next run`}),(0,B.jsx)(`strong`,{children:Qa(n.nextRunAt)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Last run`}),(0,B.jsx)(`strong`,{children:Qa(n.lastRun)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Last status`}),(0,B.jsx)(`strong`,{children:n.lastStatus||`n/a`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Errors`}),(0,B.jsx)(`strong`,{children:n.consecutiveErrors})]})]}):null,(0,B.jsxs)(`div`,{className:`button-row`,children:[(0,B.jsx)(Z,{type:`button`,loading:e.savePending,disabled:e.saveDisabled,onClick:e.onSave,children:e.savePending?`Saving...`:`Save job`}),(0,B.jsx)(Z,{variant:`ghost`,type:`button`,disabled:e.savePending,onClick:e.onCancel,children:`Cancel`}),n?(0,B.jsx)(Z,{variant:`ghost`,type:`button`,disabled:e.pausePending,onClick:e.onPauseToggle,children:e.pausePending?`Updating...`:n.disabled?`Resume job`:`Pause job`}):null,n?(0,B.jsx)(Z,{variant:`danger`,type:`button`,loading:e.deletePending,disabled:e.deletePending,onClick:e.onDelete,children:e.deletePending?`Deleting...`:`Delete job`}):null]})]})})]})})}function lg(){let e=Gn(),t=j(),n=ee({strict:!1}),r=hs(),i=o(),a=n.jobId?.trim()||null,s=(0,R.useCallback)(e=>{t({to:`/admin/scheduler`,replace:!0,search:{jobId:e||void 0}}).catch(Os)},[t]),[c,l]=(0,R.useState)(Xh()),u=Dc(),d=y({queryKey:[`scheduler`,e.token],queryFn:()=>Jt(e.token)}),f=y({queryKey:[`config`,e.token],queryFn:()=>Mt(e.token)}),p=y({queryKey:[`channels`,e.token],queryFn:()=>jt(e.token)}),m=d.data?.jobs.find(e=>e.id===a)||null,h=Uh(m)?m:null,_=Zh({config:f.data?.config,status:e.gatewayStatus,currentChannel:c.deliveryChannel}),v=tg({channel:c.deliveryChannel,currentValue:c.deliveryTo,channels:p.data}),b=Fc({mutationFn:t=>Yt(e.token,ag(t)),onSuccess:n=>{og(n,e.token,i),t({to:`/admin/jobs`}).catch(Os)},onError:e=>{r.error(`Save failed`,e.message)},invalidates:[[`overview`]]}),x=b.isPending||!u.isValid,S=g({mutationFn:()=>{if(!m)throw Error(`Select a scheduler item first.`);return Xt(e.token,m)},onSuccess:t=>{og(t,e.token,i),r.success(`Deleted.`),s(null),l(Xh())},onError:e=>{r.error(`Delete failed`,H(e))}}),C=g({mutationFn:t=>{if(!m)throw Error(`Select a scheduler item first.`);return m.source===`task`?Zt(e.token,{source:`task`,taskId:m.taskId??0,action:t}):Zt(e.token,{source:`job`,jobId:m.id,action:t})},onSuccess:(t,n)=>{if(og(t,e.token,i),r.success(n===`pause`?`Paused.`:`Resumed.`),!m)return;let a=t.jobs.find(e=>e.id===m.id)||null;if(!a){s(null),l(Xh());return}Uh(a)&&l(Xh(a))},onError:e=>{r.error(`Pause/resume failed`,H(e))}});return(0,R.useEffect)(()=>{if(h){l(Xh(h));return}a||l(Xh())},[h,a]),(0,R.useEffect)(()=>{!a||d.isLoading||m||s(null)},[d.isLoading,a,m,s]),(0,B.jsxs)(`div`,{className:`page-stack`,children:[(0,B.jsx)(Ha,{actions:(0,B.jsx)(Z,{variant:`ghost`,type:`button`,onClick:()=>{s(null),l(Xh())},children:`New job`})}),(0,B.jsxs)(`div`,{className:`two-column-grid`,children:[(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:`Jobs`}),(0,B.jsx)(uo,{children:`${d.data?.jobs.length||0} item${d.data?.jobs.length===1?``:`s`}`})]}),(0,B.jsx)(K,{children:d.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading scheduler items...`}):d.data?.jobs.length?(0,B.jsx)(`div`,{className:`list-stack selectable-list`,children:d.data.jobs.map(e=>(0,B.jsxs)(`button`,{className:e.id===a?`selectable-row active`:`selectable-row`,type:`button`,onClick:()=>s(e.id),children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:e.name}),(0,B.jsx)(`small`,{children:qh(e)})]}),(0,B.jsxs)(`div`,{className:`row-status-stack`,children:[(0,B.jsx)(Ga,{value:e.enabled&&!e.disabled,trueLabel:`active`,falseLabel:`inactive`}),(0,B.jsx)(`small`,{children:Jh(e)})]})]},e.id))}):(0,B.jsx)(`div`,{className:`empty-state`,children:`No scheduled work yet.`})})]}),Wh(m)?(0,B.jsx)(sg,{job:m,pausePending:C.isPending,deletePending:S.isPending,onPauseToggle:()=>C.mutate(m.disabled?`resume`:`pause`),onDelete:()=>S.mutate()}):(0,B.jsx)(cg,{draft:c,selectedJob:h,channelOptions:_,targetControl:v,savePending:b.isPending,pausePending:C.isPending,deletePending:S.isPending,saveDisabled:x,onDraftChange:e=>l(t=>e(t)),form:u,onSave:()=>{let e=ig(ng(c,v));l(e),b.mutate(e)},onCancel:()=>{if(h){l(Xh(h));return}s(null),l(Xh()),t({to:`/admin/jobs`}).catch(Os)},onPauseToggle:()=>C.mutate(h?.disabled?`resume`:`pause`),onDelete:()=>S.mutate()})]})]})}var ug={section:`_section_1dqd9_1`,sectionHead:`_sectionHead_1dqd9_7`,sectionTitle:`_sectionTitle_1dqd9_13`,count:`_count_1dqd9_23`,caption:`_caption_1dqd9_30`,name:`_name_1dqd9_36`,fingerprint:`_fingerprint_1dqd9_42`,actionsHead:`_actionsHead_1dqd9_47`,actions:`_actions_1dqd9_47`,overwriteForm:`_overwriteForm_1dqd9_57`,overwriteNote:`_overwriteNote_1dqd9_63`};function dg(e){return e.length===null?`—`:`${e.length} bytes`}function fg(e){return e.fingerprint?`sha256:${e.fingerprint.sha256_prefix}`:`—`}function pg(e){return e?Za(e):`never`}function mg(){let{token:e}=Gn(),t=hs(),n=o(),[r,i]=(0,R.useState)(null),[a,s]=(0,R.useState)(null),[c,l]=(0,R.useState)(``),u=y({queryKey:[`admin`,`secrets`,e],queryFn:()=>Ut(e),retry:!1}),d=(0,R.useCallback)(()=>n.invalidateQueries({queryKey:[`admin`,`secrets`]}),[n]),f=g({mutationFn:t=>Wt(e,t.name,t.value),onSuccess:async(e,n)=>{t.success(n.wasSet?`Rotated ${n.name}.`:`Set ${n.name}.`),i(null),await d()},onError:e=>{t.error(`Overwrite failed: ${H(e)}`)}}),p=g({mutationFn:t=>Gt(e,t),onSuccess:async(e,n)=>{t.success(`Removed ${n}.`),s(null),await d()},onError:e=>{t.error(`Unset failed: ${H(e)}`)}}),m=u.data,h=(0,R.useMemo)(()=>{if(!m)return null;let e=c.trim().toLowerCase(),t=m.secrets.filter(e=>e.state===`set`),n=m.secrets.filter(e=>e.state===`unset`),r=t=>e===``||t.name.toLowerCase().includes(e);return{setAll:t,unsetAll:n,setEntries:t.filter(r),unsetEntries:n.filter(r)}},[m,c]);if(u.isPending)return(0,B.jsxs)(`div`,{className:`page-stack`,children:[(0,B.jsx)(Ha,{description:`Runtime secret store`}),(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading the runtime secret store…`})]});if(u.isError||!h){let e=u.error instanceof we&&u.error.status===403;return(0,B.jsxs)(`div`,{className:`page-stack`,children:[(0,B.jsx)(Ha,{description:`Runtime secret store`}),(0,B.jsx)(`div`,{className:`empty-state`,children:e?`You do not have permission to view secret metadata.`:`Failed to load secrets: ${H(u.error)}`})]})}let _=m?.actions.includes(`secret.overwrite`)??!1,v=m?.actions.includes(`secret.unset`)??!1,b=_||v;return(0,B.jsxs)(`div`,{className:`page-stack`,children:[(0,B.jsx)(Ha,{description:`Runtime credential store. Values are write-only — set or rotate them here; they are never read back to the browser.`,actions:(0,B.jsx)(`input`,{className:`compact-search`,value:c,onChange:e=>l(e.target.value),placeholder:`Filter secrets`,"aria-label":`Filter secrets by name`})}),(0,B.jsxs)(`section`,{className:ug.section,"aria-label":`Set`,children:[(0,B.jsxs)(`div`,{className:ug.sectionHead,children:[(0,B.jsxs)(`h2`,{className:ug.sectionTitle,children:[`Set `,(0,B.jsx)(`span`,{className:ug.count,children:h.setAll.length})]}),(0,B.jsx)(`p`,{className:ug.caption,children:`Stored values, shown only as metadata — length and a SHA-256 fingerprint, never the value itself.`})]}),h.setEntries.length===0?(0,B.jsx)(`div`,{className:`empty-state`,children:h.setAll.length===0?`No secrets are currently set.`:`No set secrets match this filter.`}):(0,B.jsx)(`div`,{className:`table-shell`,children:(0,B.jsxs)(`table`,{children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{children:`Name`}),(0,B.jsx)(`th`,{children:`Length`}),(0,B.jsx)(`th`,{children:`Fingerprint`}),(0,B.jsx)(`th`,{children:`Last rotated`}),b?(0,B.jsx)(`th`,{className:ug.actionsHead,children:`Actions`}):null]})}),(0,B.jsx)(`tbody`,{children:h.setEntries.map(e=>(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`td`,{children:(0,B.jsx)(`strong`,{className:ug.name,children:e.name})}),(0,B.jsx)(`td`,{children:dg(e)}),(0,B.jsx)(`td`,{children:(0,B.jsx)(`code`,{className:ug.fingerprint,children:fg(e)})}),(0,B.jsx)(`td`,{title:e.last_rotated_at??void 0,children:pg(e.last_rotated_at)}),b?(0,B.jsx)(`td`,{children:(0,B.jsxs)(`div`,{className:ug.actions,children:[_?(0,B.jsx)(Z,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>i(e.name),children:`Rotate`}):null,v?(0,B.jsx)(Z,{type:`button`,variant:`danger`,size:`sm`,onClick:()=>s(e.name),children:`Unset`}):null]})}):null]},e.name))})]})})]}),(0,B.jsxs)(`section`,{className:ug.section,"aria-label":`Declared but unset`,children:[(0,B.jsxs)(`div`,{className:ug.sectionHead,children:[(0,B.jsxs)(`h2`,{className:ug.sectionTitle,children:[`Declared but unset`,` `,(0,B.jsx)(`span`,{className:ug.count,children:h.unsetAll.length})]}),(0,B.jsx)(`p`,{className:ug.caption,children:`Referenced by a skill, connector, or provider, with no value yet.`})]}),h.unsetEntries.length===0?(0,B.jsx)(`div`,{className:`empty-state`,children:h.unsetAll.length===0?`No declared-but-unset secrets.`:`No declared secrets match this filter.`}):(0,B.jsx)(`div`,{className:`table-shell`,children:(0,B.jsxs)(`table`,{children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{children:`Name`}),_?(0,B.jsx)(`th`,{className:ug.actionsHead,children:`Actions`}):null]})}),(0,B.jsx)(`tbody`,{children:h.unsetEntries.map(e=>(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`td`,{children:(0,B.jsx)(`strong`,{className:ug.name,children:e.name})}),_?(0,B.jsx)(`td`,{children:(0,B.jsx)(`div`,{className:ug.actions,children:(0,B.jsx)(Z,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>i(e.name),children:`Set`})})}):null]},e.name))})]})})]}),(0,B.jsx)(hg,{name:r,onClose:()=>i(null),pending:f.isPending,onSubmit:e=>{if(!r)return;let t=h.setAll.some(e=>e.name===r);f.mutate({name:r,value:e,wasSet:t})}}),(0,B.jsx)(gg,{name:a,onClose:()=>s(null),pending:p.isPending,onConfirm:()=>{a&&p.mutate(a)}})]})}function hg(e){let t=e.name!==null,n=(0,R.useRef)(null),r=(0,R.useId)(),i=(0,R.useId)();return(0,B.jsx)(ri,{open:t,onOpenChange:t=>{t||(n.current&&(n.current.value=``),e.onClose())},children:(0,B.jsxs)(ii,{role:`dialog`,size:`default`,preventCloseOnOutsideClick:e.pending,children:[(0,B.jsxs)(ai,{children:[(0,B.jsxs)(oi,{children:[`Set value for `,(0,B.jsx)(`code`,{children:e.name})]}),(0,B.jsx)(si,{children:`The new value is sent to the gateway and immediately discarded from this form. There is no way to read the stored value back.`})]}),(0,B.jsxs)(`form`,{className:ug.overwriteForm,onSubmit:t=>{t.preventDefault();let r=n.current;if(!r)return;let i=r.value;i.trim()&&e.onSubmit(i)},children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{htmlFor:r,children:`New value`}),(0,B.jsx)(Y,{id:r,ref:n,type:`password`,autoComplete:`new-password`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,required:!0,"aria-describedby":i,disabled:e.pending}),(0,B.jsx)(`p`,{id:i,className:ug.overwriteNote,children:`Pasted value is not echoed. Once submitted, the value lives only in the runtime secret store; this page cannot show it again.`})]}),(0,B.jsxs)(ci,{children:[(0,B.jsx)(li,{className:`ghost-button`,disabled:e.pending,children:`Cancel`}),(0,B.jsx)(Z,{type:`submit`,disabled:e.pending,children:e.pending?`Saving…`:`Save value`})]})]})]})})}function gg(e){return(0,B.jsx)(ri,{open:e.name!==null,onOpenChange:t=>{t||e.onClose()},children:(0,B.jsxs)(ii,{role:`alertdialog`,size:`default`,preventCloseOnOutsideClick:e.pending,children:[(0,B.jsxs)(ai,{children:[(0,B.jsxs)(oi,{children:[`Unset `,(0,B.jsx)(`code`,{children:e.name}),`?`]}),(0,B.jsx)(si,{children:`The stored value will be removed from the runtime secret store. Skills or connectors that depend on this secret will fail their preflight checks until a new value is set.`})]}),(0,B.jsxs)(ci,{children:[(0,B.jsx)(li,{className:`ghost-button`,disabled:e.pending,children:`Cancel`}),(0,B.jsx)(Z,{type:`button`,variant:`danger`,disabled:e.pending,onClick:e.onConfirm,children:e.pending?`Removing…`:`Unset secret`})]})]})})}function _g(){let e=Gn(),t=o(),n=hs(),r=j(),i=ee({strict:!1}).sessionId?.trim()||null,a=(0,R.useRef)(i),[s,c]=(0,R.useState)(``),[l,u]=(0,R.useState)(()=>i),[d,f]=(0,R.useState)(!1),p=(0,R.useDeferredValue)(s),m=y({queryKey:[`sessions`,e.token],queryFn:()=>Tt(e.token)}),h=g({mutationFn:t=>At(e.token,t),onSuccess:(e,i)=>{t.invalidateQueries({queryKey:[`sessions`]}),t.invalidateQueries({queryKey:[`overview`]}),n.success(`Session deleted`,`Removed ${e.deletedMessages} messages and ${e.deletedTasks} tasks.`),l===i&&(u(null),r({to:`/admin/sessions`,replace:!0,search:{sessionId:void 0}}).catch(Os))},onError:e=>{n.error(`Delete failed`,H(e))}}),_=(m.data||[]).filter(e=>[e.id,e.channelId,e.guildId||``,e.effectiveModel,e.summary||``].join(` `).toLowerCase().includes(p.trim().toLowerCase())),v=_.find(e=>e.id===l)||_[0]||null;(0,R.useEffect)(()=>{v&&v.id!==l&&u(v.id)},[l,v]),(0,R.useEffect)(()=>{i!==a.current&&(a.current=i,i&&i!==l&&u(i))},[i,l]);function b(e){u(e),r({to:`/admin/sessions`,replace:!0,search:{sessionId:e}}).catch(Os)}return(0,B.jsxs)(`div`,{className:`page-stack`,children:[(0,B.jsx)(Ha,{actions:(0,B.jsx)(`input`,{className:`compact-search`,value:s,onChange:e=>c(e.target.value),placeholder:`Filter by session, channel, model`})}),(0,B.jsxs)(`div`,{className:`two-column-grid sessions-layout`,children:[(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:`Session list`}),(0,B.jsx)(uo,{children:`${_.length} result${_.length===1?``:`s`}`})]}),(0,B.jsx)(K,{children:m.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading sessions...`}):_.length===0?(0,B.jsx)(`div`,{className:`empty-state`,children:`No sessions match this filter.`}):(0,B.jsx)(`div`,{className:`list-stack selectable-list`,children:_.map(e=>(0,B.jsxs)(`button`,{className:e.id===v?.id?`selectable-row active`:`selectable-row`,type:`button`,onClick:()=>b(e.id),children:[(0,B.jsxs)(`div`,{className:`session-row-main`,children:[(0,B.jsx)(`strong`,{children:e.id}),(0,B.jsxs)(`small`,{className:`session-row-meta`,children:[e.channelId,` · `,e.effectiveModel]})]}),(0,B.jsx)(`span`,{className:`session-row-time`,children:Za(e.lastActive)})]},e.id))})})]}),(0,B.jsxs)(U,{variant:`muted`,children:[(0,B.jsx)(W,{children:(0,B.jsx)(G,{children:`Inspection`})}),(0,B.jsx)(K,{children:v?(0,B.jsxs)(`div`,{className:`detail-stack`,children:[(0,B.jsxs)(`div`,{className:`key-value-grid`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Session`}),(0,B.jsx)(`strong`,{children:v.id})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Channel`}),(0,B.jsx)(`strong`,{children:v.channelId})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Guild`}),(0,B.jsx)(`strong`,{children:v.guildId||`direct/web`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Model`}),(0,B.jsx)(`strong`,{children:v.effectiveModel})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Messages`}),(0,B.jsx)(`strong`,{children:v.messageCount})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Scheduled tasks`}),(0,B.jsx)(`strong`,{children:v.taskCount})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`RAG`}),(0,B.jsx)(Ga,{value:v.ragEnabled,trueLabel:`on`,falseLabel:`off`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Last active`}),(0,B.jsx)(`strong`,{children:Za(v.lastActive)})]})]}),(0,B.jsxs)(`div`,{className:`summary-block`,children:[(0,B.jsx)(`span`,{children:`Summary`}),(0,B.jsx)(`p`,{children:v.summary||`No summary stored for this session.`})]}),(0,B.jsx)(`button`,{className:`danger-button`,type:`button`,disabled:h.isPending,onClick:()=>f(!0),children:h.isPending?`Deleting...`:`Delete session`})]}):(0,B.jsx)(`div`,{className:`empty-state`,children:`Select a session to inspect it.`})})]})]}),(0,B.jsx)(ri,{open:d,onOpenChange:f,children:(0,B.jsxs)(ii,{size:`sm`,role:`alertdialog`,children:[(0,B.jsxs)(ai,{children:[(0,B.jsx)(oi,{children:`Delete session?`}),(0,B.jsx)(si,{children:`This will permanently remove the session and all associated audit events.`})]}),(0,B.jsxs)(ci,{children:[(0,B.jsx)(li,{className:`ghost-button`,children:`Cancel`}),(0,B.jsx)(li,{className:`danger-button`,onClick:()=>{v&&h.mutate(v.id)},children:`Delete`})]})]})})]})}function vg(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var yg=vg();function bg(e){yg=e}var xg={exec:()=>null};function Sg(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(wg.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Cg=(()=>{try{return!0}catch{return!1}})(),wg={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`),blockquoteBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}>`)},Tg=/^(?:[ \t]*(?:\n|$))+/,Eg=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Dg=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Og=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,kg=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Ag=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,jg=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Mg=Sg(jg).replace(/bull/g,Ag).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),Ng=Sg(jg).replace(/bull/g,Ag).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Pg=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Fg=/^[^\n]+/,Ig=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Lg=Sg(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,Ig).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Rg=Sg(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Ag).getRegex(),zg=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,Bg=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Vg=Sg(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Bg).replace(`tag`,zg).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Hg=Sg(Pg).replace(`hr`,Og).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,zg).getRegex(),Ug={blockquote:Sg(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Hg).getRegex(),code:Eg,def:Lg,fences:Dg,heading:kg,hr:Og,html:Vg,lheading:Mg,list:Rg,newline:Tg,paragraph:Hg,table:xg,text:Fg},Wg=Sg(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,Og).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,zg).getRegex(),Gg={...Ug,lheading:Ng,table:Wg,paragraph:Sg(Pg).replace(`hr`,Og).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,Wg).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,zg).getRegex()},Kg={...Ug,html:Sg(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Bg).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:xg,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Sg(Pg).replace(`hr`,Og).replace(`heading`,` *#{1,6} *[^
|
|
72
|
+
`).map(e=>e.trim()).filter(Boolean),...e.cwd.trim()?{cwd:e.cwd.trim()}:{},...e.envJson.trim()?{env:Zp(e.envJson,`Environment JSON`)}:{}}:{url:e.url.trim(),...e.authMode===`oauth`?{auth:`oauth`}:{},...e.authMode===`headers`&&e.headersJson.trim()?{headers:Zp(e.headersJson,`Headers JSON`)}:{}}}}}function $p(e){return e.state===`connected`?{label:`connected`,connected:!0}:e.state===`expired`?{label:`expired`,connected:!1}:{label:`login required`,connected:!1}}function em(e){return new Promise(t=>setTimeout(t,e))}function tm(){let e=Gn(),t=o(),n=hs(),[r,i]=(0,R.useState)(null),[a,s]=(0,R.useState)(Xp()),[c,l]=(0,R.useState)(null),u=(0,R.useRef)(!1),d=y({queryKey:[`mcp`,e.token],queryFn:()=>$t(e.token)}),f=g({mutationFn:()=>on(e.token,Qp(a)),onSuccess:r=>{t.setQueryData([`mcp`,e.token],r),i(a.name.trim()),s(Xp(r.servers.find(e=>e.name===a.name.trim()))),n.success(`Saved MCP server ${a.name.trim()}.`)},onError:e=>{n.error(`Save failed`,H(e))}}),p=g({mutationFn:()=>sn(e.token,a.name.trim()),onSuccess:r=>{t.setQueryData([`mcp`,e.token],r),i(null),s(Xp()),n.success(`MCP server deleted.`)},onError:e=>{n.error(`Delete failed`,H(e))}}),m=g({mutationFn:async()=>{u.current=!1;let n=Qp(a),r=await on(e.token,n);t.setQueryData([`mcp`,e.token],r);let i=await cn(e.token,n.name);l(i.authorizationUrl),window.open(i.authorizationUrl,`_blank`,`noopener`);let o=Date.now()+Math.max(Kp,Math.min(qp,i.expiresAt-Date.now()));for(;Date.now()<o;){if(u.current)throw Error(`Authorization cancelled.`);if(await em(Kp),(await ln(e.token,n.name)).auth.state===`connected`)return n.name}throw Error(`Timed out waiting for authorization. Complete the login in the opened tab and try again.`)},onSuccess:async r=>{l(null),await t.invalidateQueries({queryKey:[`mcp`,e.token]}),i(r),n.success(`Connected to ${r} via OAuth.`)},onError:e=>{l(null),n.error(`OAuth connection failed`,H(e))}}),h=g({mutationFn:()=>un(e.token,a.name.trim()),onSuccess:r=>{t.setQueryData([`mcp`,e.token],r),n.success(`OAuth credentials cleared.`)},onError:e=>{n.error(`Disconnect failed`,H(e))}}),_=d.data?.servers.find(e=>e.name===r)||null;(0,R.useEffect)(()=>{if(_){s(Xp(_));return}r||s(Xp())},[r,_]),(0,R.useEffect)(()=>()=>{u.current=!0},[]);let v=_?.auth,b=v?.state===`connected`;return(0,B.jsxs)(`div`,{className:`page-stack`,children:[(0,B.jsx)(Ha,{actions:(0,B.jsx)(Z,{variant:`ghost`,type:`button`,onClick:()=>{i(null),s(Xp())},children:`New server`})}),(0,B.jsxs)(`div`,{className:`two-column-grid`,children:[(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:`Servers`}),(0,B.jsx)(uo,{children:`${d.data?.servers.length||0} configured server${d.data?.servers.length===1?``:`s`}`})]}),(0,B.jsx)(K,{children:d.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading MCP servers...`}):d.data?.servers.length?(0,B.jsx)(`div`,{className:`list-stack selectable-list`,children:d.data.servers.map(e=>{let t=e.auth.method===`oauth`?$p(e.auth):null;return(0,B.jsxs)(`button`,{className:e.name===r?`selectable-row active`:`selectable-row`,type:`button`,onClick:()=>i(e.name),children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:e.name}),(0,B.jsx)(`small`,{children:e.summary})]}),(0,B.jsxs)(`div`,{className:`button-row`,children:[t?(0,B.jsx)(Ga,{value:t.connected,trueLabel:`oauth`,falseLabel:t.label,falseTone:`danger`}):null,(0,B.jsx)(Ga,{value:e.enabled,trueLabel:`active`,falseLabel:`inactive`})]})]},e.name)})}):(0,B.jsx)(`div`,{className:`empty-state`,children:`No MCP servers are configured yet. Add a remote server with its URL and connect it with OAuth, or run a local stdio command.`})})]}),(0,B.jsxs)(U,{variant:`muted`,children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:_?`Edit ${_.name}`:`New server`}),(0,B.jsx)(uo,{children:`Changes apply on the next agent turn.`})]}),(0,B.jsx)(K,{children:(0,B.jsxs)(`div`,{className:`stack-form`,children:[(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Name`}),(0,B.jsx)(Y,{value:a.name,onChange:e=>s(t=>({...t,name:e.target.value})),placeholder:`github`}),(0,B.jsx)(Ho,{children:`Lowercase letters, numbers, - and _. Used as the tool prefix.`})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Transport`}),(0,B.jsxs)(ds,{value:a.transport,onChange:e=>s(t=>({...t,transport:e.target.value})),children:[(0,B.jsx)(Q,{value:`http`,children:`http — remote server`}),(0,B.jsx)(Q,{value:`sse`,children:`sse — remote server (legacy)`}),(0,B.jsx)(Q,{value:`stdio`,children:`stdio — local command`})]})]})]}),(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:a.enabled,onCheckedChange:e=>s(t=>({...t,enabled:e}))}),(0,B.jsx)(Bo,{children:(0,B.jsx)(J,{children:`Server state`})})]}),a.transport===`stdio`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Command`}),(0,B.jsx)(Y,{value:a.command,onChange:e=>s(t=>({...t,command:e.target.value})),placeholder:`docker`})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Arguments`}),(0,B.jsx)(Jo,{rows:4,value:a.args,onChange:e=>s(t=>({...t,args:e.target.value})),placeholder:`One argument per line`})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Working directory`}),(0,B.jsx)(Y,{value:a.cwd,onChange:e=>s(t=>({...t,cwd:e.target.value})),placeholder:`/workspace`})]})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Environment JSON`}),(0,B.jsx)(Jo,{rows:5,value:a.envJson,onChange:e=>s(t=>({...t,envJson:e.target.value})),placeholder:`{"GITHUB_TOKEN":"..."}`})]})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`URL`}),(0,B.jsx)(Y,{value:a.url,onChange:e=>s(t=>({...t,url:e.target.value})),placeholder:`https://mcp.example.com/mcp`})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Authentication`}),(0,B.jsxs)(ds,{value:a.authMode,onChange:e=>s(t=>({...t,authMode:e.target.value})),children:[(0,B.jsx)(Q,{value:`oauth`,children:`OAuth — log in via browser`}),(0,B.jsx)(Q,{value:`headers`,children:`Custom headers (API key / bearer token)`}),(0,B.jsx)(Q,{value:`none`,children:`None`})]}),(0,B.jsx)(Ho,{children:a.authMode===`oauth`?`The gateway discovers the authorization server, registers a client, and refreshes tokens automatically.`:a.authMode===`headers`?`Headers are sent with every request to the server.`:`Requests are sent without credentials.`})]}),a.authMode===`headers`?(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Headers JSON`}),(0,B.jsx)(Jo,{rows:5,value:a.headersJson,onChange:e=>s(t=>({...t,headersJson:e.target.value})),placeholder:`{"Authorization":"Bearer ..."}`})]}):null,a.authMode===`oauth`?(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsxs)(Bo,{children:[(0,B.jsx)(J,{children:`OAuth connection`}),(0,B.jsxs)(Ho,{children:[m.isPending?`Waiting for you to approve access in the browser...`:b?`Connected. Tokens refresh automatically.`:v?.state===`expired`?`The session expired. Reconnect to continue.`:`Not connected yet. Saving happens automatically when you connect.`,c&&m.isPending?(0,B.jsxs)(B.Fragment,{children:[` `,(0,B.jsx)(`a`,{href:c,target:`_blank`,rel:`noreferrer`,children:`Open the login page`}),` `,`if it did not open automatically.`]}):null]})]}),(0,B.jsxs)(`div`,{className:`button-row`,children:[(0,B.jsx)(Z,{type:`button`,loading:m.isPending,disabled:m.isPending||!a.name.trim()||!a.url.trim(),onClick:()=>m.mutate(),children:m.isPending?`Waiting...`:b?`Reconnect`:`Connect`}),b?(0,B.jsx)(Z,{variant:`ghost`,type:`button`,loading:h.isPending,disabled:h.isPending,onClick:()=>h.mutate(),children:`Disconnect`}):null]})]}):null]}),(0,B.jsxs)(`div`,{className:`button-row`,children:[(0,B.jsx)(Z,{type:`button`,loading:f.isPending,disabled:f.isPending,onClick:()=>f.mutate(),children:f.isPending?`Saving...`:`Save server`}),_?(0,B.jsx)(Z,{variant:`danger`,type:`button`,loading:p.isPending,disabled:p.isPending,onClick:()=>p.mutate(),children:p.isPending?`Deleting...`:`Delete server`}):null]}),_?(0,B.jsxs)(`div`,{className:`summary-block`,children:[(0,B.jsx)(`span`,{children:`Summary`}),(0,B.jsx)(`p`,{children:_.summary})]}):null]})})]})]})]})}function nm(e){return e.usageDaily!==null}function rm(e,t){let n=e.usageMonthly?.totalTokens||0,r=t.usageMonthly?.totalTokens||0;if(n!==r)return n-r;let i=e.usageMonthly?.callCount||0,a=t.usageMonthly?.callCount||0;return i===a?e.id.localeCompare(t.id):i-a}var im=[`hybridai`,`codex`,`openrouter`,`mistral`,`huggingface`,`ollama`,`lmstudio`,`llamacpp`,`vllm`];function am(e){if(e.backend)return e.backend;let t=e.id.trim().toLowerCase();return t.startsWith(`openai-codex/`)?`codex`:t.startsWith(`openrouter/`)?`openrouter`:t.startsWith(`mistral/`)?`mistral`:t.startsWith(`huggingface/`)?`huggingface`:null}function om(e,t){let n=im.indexOf(e),r=im.indexOf(t);if(n!==-1||r!==-1){if(n===-1)return 1;if(r===-1)return-1;if(n!==r)return n-r}return e.localeCompare(t)}function sm(e){let t=new Set(Object.keys(e?.providerStatus||{}));for(let n of e?.models||[]){let e=am(n);e&&t.add(e)}return[...t].sort(om).map(t=>({name:t,status:e?.providerStatus?.[t]||null}))}var cm={model:(e,t)=>X(e.id,t.id),backend:(e,t)=>X(e.backend||`remote`,t.backend||`remote`)||X(e.id,t.id),context:(e,t)=>$o(e.contextWindow,t.contextWindow)||X(e.id,t.id),monthlyUsage:rm},lm={context:`desc`,monthlyUsage:`desc`};function um(e){return{defaultModel:e?.defaultModel||``}}function dm(e){return[e.isReasoning?`reasoning`:``,e.thinkingFormat||``,e.family||``].filter(Boolean).join(` · `)}function fm(){let e=Gn(),t=o(),n=hs(),[r,i]=(0,R.useState)(``),[a,s]=(0,R.useState)(um()),c=y({queryKey:[`models`,e.token],queryFn:()=>Kt(e.token)}),l=g({mutationFn:()=>qt(e.token,{defaultModel:a.defaultModel}),onSuccess:r=>{t.setQueryData([`models`,e.token],r),s(um(r)),t.invalidateQueries({queryKey:[`overview`]}),n.success(`Default model is now ${r.defaultModel}.`)},onError:e=>{n.error(`Save failed`,H(e))}});(0,R.useEffect)(()=>{c.data&&s(e=>e.defaultModel?e:um(c.data))},[c.data]);let{sortedRows:u,sortState:d,toggleSort:f}=Ba((c.data?.models||[]).filter(e=>[e.id,e.backend||``,e.family||``,e.parameterSize||``].join(` `).toLowerCase().includes(r.trim().toLowerCase())),{initialSort:{key:`monthlyUsage`,direction:`desc`},sorters:cm,defaultDirections:lm}),p=sm(c.data),m=(c.data?.models||[]).filter(nm);return(0,B.jsxs)(`div`,{className:`page-stack`,children:[(0,B.jsx)(Ha,{actions:(0,B.jsx)(Y,{className:`compact-search`,value:r,onChange:e=>i(e.target.value),placeholder:`Filter models`})}),(0,B.jsxs)(`div`,{className:`two-column-grid`,children:[(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{children:(0,B.jsx)(G,{children:`Provider status`})}),(0,B.jsx)(K,{children:(0,B.jsxs)(`div`,{className:`list-stack`,children:[p.map(({name:e,status:t})=>(0,B.jsxs)(`div`,{className:`list-row`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:e}),(0,B.jsx)(`small`,{children:t?.reachable?`${t.detail||(typeof t.latencyMs==`number`?`${t.latencyMs}ms`:`ready`)} · ${t.modelCount??0} models`:t?t.error||`unreachable`:`Visible in catalog · no live health data`})]}),(0,B.jsxs)(`span`,{className:t?.reachable?`list-status list-status-success`:t?`list-status list-status-danger`:`list-status`,children:[(0,B.jsx)(`span`,{className:t?.reachable?`status-dot status-dot-success`:t?`status-dot status-dot-danger`:`status-dot`}),t?.reachable?`healthy`:t?`down`:`catalog`]})]},e)),p.length===0?(0,B.jsx)(`div`,{className:`empty-state`,children:`No provider health checks available.`}):null]})})]}),(0,B.jsxs)(U,{variant:`muted`,children:[(0,B.jsx)(W,{children:(0,B.jsx)(G,{children:`Selection`})}),(0,B.jsx)(K,{children:c.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading model catalog...`}):(0,B.jsxs)(`div`,{className:`stack-form`,children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Default model`}),(0,B.jsxs)(ds,{value:a.defaultModel,onChange:e=>s(t=>({...t,defaultModel:e.target.value})),children:[(0,B.jsx)(Q,{value:``,children:`Select model`}),(c.data?.models||[]).map(e=>(0,B.jsx)(Q,{value:e.id,children:e.id},e.id))]})]}),(0,B.jsx)(`div`,{className:`button-row`,children:(0,B.jsx)(`button`,{className:`primary-button`,type:`button`,disabled:l.isPending,onClick:()=>l.mutate(),children:l.isPending?`Saving...`:`Save selection`})})]})})]})]}),(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:`Catalog`}),(0,B.jsx)(uo,{children:`${eo(u.length,`model`)} visible`})]}),(0,B.jsx)(K,{children:c.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading model catalog...`}):(0,B.jsx)(`div`,{className:`table-shell`,children:(0,B.jsxs)(`table`,{children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(Va,{label:`Model`,sortKey:`model`,sortState:d,onToggle:f}),(0,B.jsx)(Va,{label:`Backend`,sortKey:`backend`,sortState:d,onToggle:f}),(0,B.jsx)(Va,{label:`Context`,sortKey:`context`,sortState:d,onToggle:f}),(0,B.jsx)(Va,{label:`Monthly usage`,sortKey:`monthlyUsage`,sortState:d,onToggle:f})]})}),(0,B.jsxs)(`tbody`,{children:[u.map(e=>(0,B.jsxs)(`tr`,{children:[(0,B.jsxs)(`td`,{children:[(0,B.jsx)(`strong`,{children:e.id}),dm(e)?(0,B.jsx)(`small`,{children:dm(e)}):null]}),(0,B.jsx)(`td`,{children:e.backend||`remote`}),(0,B.jsx)(`td`,{children:e.contextWindow?Ka(e.contextWindow):`unknown`}),(0,B.jsx)(`td`,{children:e.usageMonthly?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`strong`,{children:Ka(e.usageMonthly.totalTokens)}),(0,B.jsx)(`small`,{children:Ja({inputTokens:e.usageMonthly.totalInputTokens??0,outputTokens:e.usageMonthly.totalOutputTokens??0})}),(0,B.jsxs)(`small`,{children:[Xa(e.usageMonthly.totalCostUsd),` ·`,` `,eo(e.usageMonthly.callCount,`call`)]})]}):(0,B.jsx)(`small`,{children:`No usage recorded`})})]},e.id)),u.length===0?(0,B.jsx)(`tr`,{children:(0,B.jsx)(`td`,{colSpan:4,children:(0,B.jsx)(`div`,{className:`empty-state`,children:`No models match this filter.`})})}):null]})]})})})]}),m.length>0?(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:`Recent daily activity`}),(0,B.jsx)(uo,{children:`Updated ${Za(new Date().toISOString())}`})]}),(0,B.jsx)(K,{children:(0,B.jsx)(`div`,{className:`list-stack`,children:m.sort((e,t)=>t.usageDaily.totalTokens-e.usageDaily.totalTokens).slice(0,6).map(e=>(0,B.jsxs)(`div`,{className:`list-row`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:e.id}),(0,B.jsxs)(`small`,{children:[Ja({inputTokens:e.usageDaily.totalInputTokens??0,outputTokens:e.usageDaily.totalOutputTokens??0}),` `,`· `,eo(e.usageDaily.callCount,`call`),` today`]})]}),(0,B.jsx)(`span`,{children:Xa(e.usageDaily.totalCostUsd??0)})]},`${e.id}-daily`))})})]}):null]})}var pm={root:`_root_16nbt_1`,viewport:`_viewport_16nbt_10`,scrollbar:`_scrollbar_16nbt_29`,thumb:`_thumb_16nbt_55`},mm=(0,R.createContext)(null);function hm(e){let t=(0,R.useContext)(mm);if(!t)throw Error(`${e} must be used within <ScrollArea>`);return t}function gm({className:e,children:t,...n}){let r=(0,R.useRef)(null),i=(0,R.useRef)(null),[a,o]=(0,R.useState)({thumbSize:0,thumbOffset:0,visible:!1}),s=(0,R.useCallback)(()=>{let e=r.current,t=i.current;if(!e||!t){o(e=>e.visible?{...e,visible:!1}:e);return}let{scrollTop:n,scrollHeight:a,clientHeight:s}=e;if(a<=s+1){o(e=>e.visible?{...e,visible:!1}:e);return}let c=t.clientHeight;if(c<=0)return;let l=s/a,u=Math.max(20,c*l),d=a-s,f=c-u,p=d<=0?0:n/d*f;o(e=>e.visible&&e.thumbSize===u&&e.thumbOffset===p?e:{thumbSize:u,thumbOffset:p,visible:!0})},[]),c=(0,R.useCallback)(e=>{r.current=e,requestAnimationFrame(s)},[s]),l=(0,R.useCallback)(e=>{i.current=e,requestAnimationFrame(s)},[s]);(0,R.useLayoutEffect)(()=>{let e=r.current;if(!e)return;s();let t=0,n=()=>{t||=requestAnimationFrame(()=>{t=0,s()})};e.addEventListener(`scroll`,n,{passive:!0});let a=new ResizeObserver(()=>s());return a.observe(e),e.firstElementChild&&a.observe(e.firstElementChild),i.current&&a.observe(i.current),()=>{t&&cancelAnimationFrame(t),e.removeEventListener(`scroll`,n),a.disconnect()}},[s]);let u={viewportRef:r,setViewportEl:c,scrollState:a,registerScrollbarTrack:l};return(0,B.jsx)(mm.Provider,{value:u,children:(0,B.jsx)(`div`,{className:V(pm.root,e),...n,children:t})})}function _m({className:e,children:t,ref:n,...r}){let i=hm(`ScrollAreaViewport`);return(0,B.jsx)(`div`,{ref:e=>{i.setViewportEl(e),typeof n==`function`?n(e):n&&typeof n==`object`&&(n.current=e)},className:V(pm.viewport,e),...r,children:t})}function vm({className:e,children:t,...n}){let r=hm(`ScrollAreaScrollbar`);return(0,B.jsx)(`div`,{ref:r.registerScrollbarTrack,"data-orientation":`vertical`,"data-state":r.scrollState.visible?`visible`:`hidden`,"aria-hidden":`true`,className:V(pm.scrollbar,e),...n,children:t})}function ym({className:e,...t}){let n=hm(`ScrollAreaThumb`),{thumbSize:r,thumbOffset:i}=n.scrollState;return(0,B.jsx)(`div`,{className:V(pm.thumb,e),style:{height:r,transform:`translateY(${i}px)`},onPointerDown:e=>{if(e.button!==0)return;e.preventDefault(),e.stopPropagation();let t=n.viewportRef.current,i=e.currentTarget.parentElement??null;if(!t||!i)return;let a=e.clientY,o=t.scrollTop,s=i.clientHeight,c=t.scrollHeight-t.clientHeight,l=Math.max(1,s-r),u=e=>{t.scrollTop=o+(e.clientY-a)/l*c},d=()=>{window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),window.removeEventListener(`pointercancel`,d)};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d),window.addEventListener(`pointercancel`,d)},...t})}var bm={trigger:`_trigger_1fi1d_1`,value:`_value_1fi1d_40`,icon:`_icon_1fi1d_52`,popup:`_popup_1fi1d_66`,"select-in":`_select-in_1fi1d_1`,popupHeader:`_popupHeader_1fi1d_111`,popupBodyPlain:`_popupBodyPlain_1fi1d_117`,popupBody:`_popupBody_1fi1d_117`,popupRail:`_popupRail_1fi1d_131`,listScroll:`_listScroll_1fi1d_151`,list:`_list_1fi1d_151`,group:`_group_1fi1d_168`,groupLabel:`_groupLabel_1fi1d_176`,separator:`_separator_1fi1d_184`,empty:`_empty_1fi1d_190`,item:`_item_1fi1d_197`,itemIndicator:`_itemIndicator_1fi1d_214`,itemText:`_itemText_1fi1d_248`,itemBody:`_itemBody_1fi1d_256`,itemSubtitle:`_itemSubtitle_1fi1d_272`,itemMeta:`_itemMeta_1fi1d_279`},xm=(0,R.createContext)(null);function Sm(e){let t=(0,R.useContext)(xm);if(!t)throw Error(`${e} must be used within <Select>`);return t}function Cm({value:e,defaultValue:t=``,onValueChange:n,open:r,defaultOpen:i,onOpenChange:a,disabled:o=!1,children:s}){let c=e!==void 0,[l,u]=(0,R.useState)(t),d=c?e:l,[f,p]=(0,R.useState)(null),[m,h]=(0,R.useState)(null),g=(0,R.useId)(),_=(0,R.useId)(),v=(0,R.useCallback)(e=>{c||u(e),n?.(e)},[c,n]),y=(0,R.useCallback)(e=>`${_}-item-${Lm(e)}`,[_]),b=(0,R.useMemo)(()=>({value:d,selectValue:v,listEl:f,setListEl:p,listId:g,highlightedValue:m,setHighlightedValue:h,disabled:o,getItemId:y}),[d,v,f,g,m,o,y]);return(0,B.jsx)(Oi,{open:r,defaultOpen:i,onOpenChange:(0,R.useCallback)(e=>{o&&e||(e||h(null),a?.(e))},[o,a]),children:(0,B.jsx)(xm.Provider,{value:b,children:s})})}function wm({children:e,className:t,onClick:n,onKeyDown:r,...i}){let a=Di(`SelectTrigger`),o=Sm(`SelectTrigger`);return(0,B.jsx)(`button`,{ref:a.setTriggerEl,type:`button`,role:`combobox`,"aria-haspopup":`listbox`,"aria-expanded":a.open,"aria-controls":a.open?o.listId:void 0,"aria-disabled":o.disabled||void 0,"data-state":a.open?`open`:`closed`,"data-disabled":o.disabled?``:void 0,disabled:o.disabled,className:V(bm.trigger,t),onClick:e=>{n?.(e),!e.defaultPrevented&&(a.open||o.setHighlightedValue(o.value||null),a.toggle())},onKeyDown:e=>{r?.(e),!e.defaultPrevented&&(e.key===`ArrowDown`||e.key===`ArrowUp`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),o.setHighlightedValue(o.value||null),a.setOpen(!0))},...i,children:e})}function Tm({placeholder:e,children:t,className:n,...r}){let i=Sm(`SelectValue`),a=t==null||t===``||i.value===``;return(0,B.jsx)(`span`,{className:V(bm.value,n),"data-placeholder":a?``:void 0,...r,children:a?e:t})}function Em({className:e,children:t,...n}){return(0,B.jsx)(`span`,{"aria-hidden":`true`,className:V(bm.icon,e),...n,children:t??(0,B.jsx)(er,{width:14,height:14})})}var Dm=e=>{let t=e.querySelector(`input`);if(t){t.focus();return}e.querySelector(`[role="listbox"]`)?.focus()};function Om({align:e=`start`,sideOffset:t=6,header:n,rail:r,children:i,className:a,...o}){let s=Di(`SelectContent`),c=Sm(`SelectContent`),l=(0,R.useRef)({buffer:``,timer:0}),u=n!=null&&n!==!1,d=r!=null&&r!==!1;(0,R.useEffect)(()=>{let e=s.contentEl;if(!s.open||!e||!c.highlightedValue)return;let t=c.getItemId(c.highlightedValue);e.querySelector(`#${Rm(t)}`)?.scrollIntoView({block:`nearest`})},[s.open,s.contentEl,c.highlightedValue,c.getItemId]),(0,R.useEffect)(()=>{let e=l.current;return()=>{e.timer&&window.clearTimeout(e.timer)}},[]);let f=(0,R.useCallback)(()=>c.listEl?Array.from(c.listEl.querySelectorAll(`[role="option"]:not([aria-disabled="true"])`)):[],[c.listEl]),p=(0,R.useCallback)(e=>{let t=f();if(t.length===0)return;let n=c.highlightedValue?t.findIndex(e=>e.getAttribute(`data-value`)===c.highlightedValue):-1,r;r=e===`first`?0:e===`last`?t.length-1:n<0?e>0?0:t.length-1:(n+e+t.length)%t.length;let i=t[r],a=i?.getAttribute(`data-value`)??null;c.setHighlightedValue(a),i?.scrollIntoView({block:`nearest`})},[f,c.highlightedValue,c.setHighlightedValue]),m=e=>{let t=l.current;t.buffer+=e.toLowerCase(),t.timer&&window.clearTimeout(t.timer),t.timer=window.setTimeout(()=>{t.buffer=``,t.timer=0},500);let n=f();if(n.length===0)return;let r=c.highlightedValue?n.findIndex(e=>e.getAttribute(`data-value`)===c.highlightedValue):-1,i=[...n.slice(r+1),...n.slice(0,r+1)].find(e=>(e.textContent??``).trim().toLowerCase().startsWith(t.buffer));if(i){let e=i.getAttribute(`data-value`);c.setHighlightedValue(e),i.scrollIntoView({block:`nearest`})}},h=e=>{if(e.key===`Tab`){s.setOpen(!1);return}if(e.key===`ArrowDown`){e.preventDefault(),p(1);return}if(e.key===`ArrowUp`){e.preventDefault(),p(-1);return}if(e.key===`Home`){e.preventDefault(),p(`first`);return}if(e.key===`End`){e.preventDefault(),p(`last`);return}if(e.key===`Enter`){if(c.highlightedValue==null)return;e.preventDefault(),c.selectValue(c.highlightedValue),s.setOpen(!1),s.triggerEl?.focus();return}if(!u&&e.key===` `&&c.highlightedValue!=null){e.preventDefault(),c.selectValue(c.highlightedValue),s.setOpen(!1),s.triggerEl?.focus();return}!u&&e.key.length===1&&!e.ctrlKey&&!e.metaKey&&m(e.key)},g=c.highlightedValue?c.getItemId(c.highlightedValue):void 0;return(0,B.jsxs)(Ai,{align:e,sideOffset:t,focusOnOpen:Dm,className:V(bm.popup,a),onKeyDown:h,...o,children:[u?(0,B.jsx)(`div`,{className:bm.popupHeader,children:n}):null,(0,B.jsxs)(`div`,{className:d?bm.popupBody:bm.popupBodyPlain,children:[d?(0,B.jsx)(`div`,{className:bm.popupRail,children:r}):null,(0,B.jsxs)(gm,{className:bm.listScroll,children:[(0,B.jsx)(_m,{ref:c.setListEl,id:c.listId,role:`listbox`,tabIndex:-1,"aria-activedescendant":g,className:bm.list,children:i}),(0,B.jsx)(vm,{children:(0,B.jsx)(ym,{})})]})]})]})}function km({className:e,children:t,...n}){return(0,B.jsx)(`div`,{role:`group`,className:V(bm.group,e),...n,children:t})}function Am({className:e,children:t,...n}){return(0,B.jsx)(`div`,{className:V(bm.groupLabel,e),...n,children:t})}function jm({className:e,children:t,...n}){return(0,B.jsx)(`div`,{className:V(bm.empty,e),...n,children:t})}function Mm({value:e,disabled:t=!1,textValue:n,children:r,className:i,onClick:a,onPointerEnter:o,...s}){let c=Di(`SelectItem`),l=Sm(`SelectItem`),u=l.value===e,d=l.highlightedValue===e;return(0,B.jsx)(`div`,{id:l.getItemId(e),role:`option`,"aria-selected":u,"aria-disabled":t||void 0,"aria-label":n,"data-value":e,"data-state":u?`checked`:`unchecked`,"data-highlighted":d?``:void 0,"data-disabled":t?``:void 0,className:V(bm.item,i),onClick:n=>{t||(a?.(n),!n.defaultPrevented&&(l.selectValue(e),c.setOpen(!1),c.triggerEl?.focus()))},onPointerEnter:n=>{o?.(n),!n.defaultPrevented&&(t||l.setHighlightedValue(e))},...s,children:r})}function Nm({className:e,children:t,...n}){return(0,B.jsx)(`span`,{className:V(bm.itemText,e),...n,children:t})}function Pm({className:e,children:t,...n}){return(0,B.jsx)(`span`,{className:V(bm.itemBody,e),...n,children:t})}function Fm({className:e,children:t,...n}){return(0,B.jsx)(`span`,{className:V(bm.itemSubtitle,e),...n,children:t})}function Im({className:e,children:t,...n}){return(0,B.jsx)(`span`,{className:V(bm.itemMeta,e),...n,children:t})}function Lm(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`)}function Rm(e){return typeof CSS<`u`&&typeof CSS.escape==`function`?CSS.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,`\\$&`)}var zm={chatPage:`_chatPage_n3vc4_1`,chatSidebarHeader:`_chatSidebarHeader_n3vc4_36`,chatSidebarContent:`_chatSidebarContent_n3vc4_44`,newChatButton:`_newChatButton_n3vc4_52`,navLinkIcon:`_navLinkIcon_n3vc4_82`,appPreviewDialog:`_appPreviewDialog_n3vc4_92`,appPreviewHeader:`_appPreviewHeader_n3vc4_102`,appPreviewTitle:`_appPreviewTitle_n3vc4_111`,appPreviewActions:`_appPreviewActions_n3vc4_120`,appPreviewLink:`_appPreviewLink_n3vc4_127`,appPreviewFrame:`_appPreviewFrame_n3vc4_145`,sidebarLabel:`_sidebarLabel_n3vc4_152`,sidebarListHeader:`_sidebarListHeader_n3vc4_162`,sidebarScopeToggle:`_sidebarScopeToggle_n3vc4_169`,sidebarScopeButton:`_sidebarScopeButton_n3vc4_178`,sidebarScopeButtonActive:`_sidebarScopeButtonActive_n3vc4_200`,sessionList:`_sessionList_n3vc4_213`,sessionItemRow:`_sessionItemRow_n3vc4_222`,sessionItem:`_sessionItem_n3vc4_222`,sessionItemPending:`_sessionItemPending_n3vc4_253`,sessionPulse:`_sessionPulse_n3vc4_1`,sessionTitle:`_sessionTitle_n3vc4_267`,sessionTime:`_sessionTime_n3vc4_276`,sessionSnippet:`_sessionSnippet_n3vc4_281`,sessionItemActive:`_sessionItemActive_n3vc4_289`,sessionDeleteButton:`_sessionDeleteButton_n3vc4_294`,sessionDeleteIcon:`_sessionDeleteIcon_n3vc4_330`,sidebarSearchWrap:`_sidebarSearchWrap_n3vc4_343`,sidebarSearch:`_sidebarSearch_n3vc4_343`,sidebarStatus:`_sidebarStatus_n3vc4_367`,chatMobileTrigger:`_chatMobileTrigger_n3vc4_386`,chatTopbar:`_chatTopbar_n3vc4_391`,mobileQrButton:`_mobileQrButton_n3vc4_405`,mobileQrIcon:`_mobileQrIcon_n3vc4_429`,mobileQrOverlay:`_mobileQrOverlay_n3vc4_441`,mobileQrDialog:`_mobileQrDialog_n3vc4_452`,mobileQrHeader:`_mobileQrHeader_n3vc4_461`,mobileQrClose:`_mobileQrClose_n3vc4_475`,mobileQrImage:`_mobileQrImage_n3vc4_488`,mobileQrLink:`_mobileQrLink_n3vc4_502`,chatMain:`_chatMain_n3vc4_511`,messageArea:`_messageArea_n3vc4_523`,messageList:`_messageList_n3vc4_536`,sidebarCollapseButton:`_sidebarCollapseButton_n3vc4_545`,emptyState:`_emptyState_n3vc4_549`,greeting:`_greeting_n3vc4_559`,messageBlock:`_messageBlock_n3vc4_568`,jumpToLatest:`_jumpToLatest_n3vc4_580`,messageBlockUser:`_messageBlockUser_n3vc4_616`,messageBlockAssistant:`_messageBlockAssistant_n3vc4_620`,messageBlockSystem:`_messageBlockSystem_n3vc4_621`,agentLabel:`_agentLabel_n3vc4_625`,agentAvatar:`_agentAvatar_n3vc4_635`,agentInitial:`_agentInitial_n3vc4_642`,bubble:`_bubble_n3vc4_655`,bubbleUser:`_bubbleUser_n3vc4_666`,userAgentMentionPill:`_userAgentMentionPill_n3vc4_673`,userAgentMentionAvatar:`_userAgentMentionAvatar_n3vc4_694`,userSkillCommandLink:`_userSkillCommandLink_n3vc4_702`,bubbleAssistant:`_bubbleAssistant_n3vc4_714`,bubbleApproval:`_bubbleApproval_n3vc4_722`,bubbleSystem:`_bubbleSystem_n3vc4_736`,bubbleCommand:`_bubbleCommand_n3vc4_748`,markdownContent:`_markdownContent_n3vc4_775`,codeCopyButton:`_codeCopyButton_n3vc4_854`,codeCopyButtonDone:`_codeCopyButtonDone_n3vc4_882`,codeBlockLabeled:`_codeBlockLabeled_n3vc4_890`,codeLangLabel:`_codeLangLabel_n3vc4_894`,messageActions:`_messageActions_n3vc4_1054`,actionButton:`_actionButton_n3vc4_1060`,actionButtonSelected:`_actionButtonSelected_n3vc4_1079`,actionButtonSuccess:`_actionButtonSuccess_n3vc4_1084`,branchSwitcher:`_branchSwitcher_n3vc4_1088`,branchButton:`_branchButton_n3vc4_1097`,approvalCard:`_approvalCard_n3vc4_1115`,approvalHeader:`_approvalHeader_n3vc4_1122`,approvalTier:`_approvalTier_n3vc4_1129`,approvalTitle:`_approvalTitle_n3vc4_1147`,approvalIntro:`_approvalIntro_n3vc4_1154`,approvalDetails:`_approvalDetails_n3vc4_1160`,approvalDetailRow:`_approvalDetailRow_n3vc4_1166`,approvalPrimaryActions:`_approvalPrimaryActions_n3vc4_1189`,approvalTrustActions:`_approvalTrustActions_n3vc4_1190`,approvalAllow:`_approvalAllow_n3vc4_1205`,artifactCard:`_artifactCard_n3vc4_1211`,artifactCardWithPreview:`_artifactCardWithPreview_n3vc4_1225`,artifactHeader:`_artifactHeader_n3vc4_1230`,artifactFilename:`_artifactFilename_n3vc4_1237`,artifactBadge:`_artifactBadge_n3vc4_1247`,artifactDownload:`_artifactDownload_n3vc4_1257`,artifactPreview:`_artifactPreview_n3vc4_1279`,artifactPdfPreview:`_artifactPdfPreview_n3vc4_1291`,artifactVideoPreview:`_artifactVideoPreview_n3vc4_1307`,thinking:`_thinking_n3vc4_1320`,thinkingDot:`_thinkingDot_n3vc4_1327`,thinkingBounce:`_thinkingBounce_n3vc4_1`,traceBlock:`_traceBlock_n3vc4_1359`,traceHeader:`_traceHeader_n3vc4_1366`,traceChevron:`_traceChevron_n3vc4_1387`,traceChevronOpen:`_traceChevronOpen_n3vc4_1396`,traceSummary:`_traceSummary_n3vc4_1400`,traceSummaryLive:`_traceSummaryLive_n3vc4_1405`,tracePulse:`_tracePulse_n3vc4_1`,traceSteps:`_traceSteps_n3vc4_1419`,traceStep:`_traceStep_n3vc4_1419`,traceStepMarker:`_traceStepMarker_n3vc4_1438`,traceDot:`_traceDot_n3vc4_1447`,traceDotRunning:`_traceDotRunning_n3vc4_1454`,traceStepBody:`_traceStepBody_n3vc4_1459`,traceToolLine:`_traceToolLine_n3vc4_1467`,traceToolName:`_traceToolName_n3vc4_1474`,traceToolPreview:`_traceToolPreview_n3vc4_1479`,traceToolDuration:`_traceToolDuration_n3vc4_1490`,traceToolResult:`_traceToolResult_n3vc4_1497`,traceThinkingText:`_traceThinkingText_n3vc4_1506`,composerWrapper:`_composerWrapper_n3vc4_1515`,composer:`_composer_n3vc4_1515`,pendingMediaRow:`_pendingMediaRow_n3vc4_1539`,mediaChip:`_mediaChip_n3vc4_1546`,mediaChipName:`_mediaChipName_n3vc4_1558`,mediaChipRemove:`_mediaChipRemove_n3vc4_1564`,composerRow:`_composerRow_n3vc4_1583`,composerActions:`_composerActions_n3vc4_1590`,composerLeftActions:`_composerLeftActions_n3vc4_1597`,composerInputWrap:`_composerInputWrap_n3vc4_1604`,composerInputOverlay:`_composerInputOverlay_n3vc4_1610`,composerOverlayCaret:`_composerOverlayCaret_n3vc4_1623`,composerMentionPill:`_composerMentionPill_n3vc4_1636`,composerMentionAvatar:`_composerMentionAvatar_n3vc4_1656`,composerInput:`_composerInput_n3vc4_1604`,composerInputHasOverlay:`_composerInputHasOverlay_n3vc4_1681`,attachButton:`_attachButton_n3vc4_1695`,sendButton:`_sendButton_n3vc4_1696`,composerPill:`_composerPill_n3vc4_1730`,agentSelectPopup:`_agentSelectPopup_n3vc4_1770`,agentSelectItem:`_agentSelectItem_n3vc4_1776`,remoteAgentGroupLabel:`_remoteAgentGroupLabel_n3vc4_1780`,remoteAgentGroupIcon:`_remoteAgentGroupIcon_n3vc4_1786`,agentSelectItemText:`_agentSelectItemText_n3vc4_1791`,agentSelectAvatar:`_agentSelectAvatar_n3vc4_1798`,agentSelectAvatarLoading:`_agentSelectAvatarLoading_n3vc4_1799`,composerPillChevron:`_composerPillChevron_n3vc4_1814`,stopping:`_stopping_n3vc4_1844`,slashSuggestions:`_slashSuggestions_n3vc4_1849`,slashSuggestionsScroll:`_slashSuggestionsScroll_n3vc4_1857`,slashSuggestionsList:`_slashSuggestionsList_n3vc4_1861`,suggestionItem:`_suggestionItem_n3vc4_1865`,suggestionItemAgent:`_suggestionItemAgent_n3vc4_1880`,suggestionItemActive:`_suggestionItemActive_n3vc4_1887`,suggestionItemSub:`_suggestionItemSub_n3vc4_1892`,suggestionLabel:`_suggestionLabel_n3vc4_1896`,suggestionText:`_suggestionText_n3vc4_1906`,suggestionAvatar:`_suggestionAvatar_n3vc4_1913`,suggestionAvatarLoading:`_suggestionAvatarLoading_n3vc4_1914`,suggestionLabelMono:`_suggestionLabelMono_n3vc4_1929`,suggestionMatch:`_suggestionMatch_n3vc4_1935`,suggestionDesc:`_suggestionDesc_n3vc4_1944`,suggestionEmpty:`_suggestionEmpty_n3vc4_1952`,slashLiveRegion:`_slashLiveRegion_n3vc4_1958 _srOnly_jfnet_1`,errorBanner:`_errorBanner_n3vc4_1974`,errorBannerFadeIn:`_errorBannerFadeIn_n3vc4_1`,errorBannerExiting:`_errorBannerExiting_n3vc4_1989`,errorBannerFadeOut:`_errorBannerFadeOut_n3vc4_1`,editArea:`_editArea_n3vc4_2005`,editButtons:`_editButtons_n3vc4_2020`},Bm={search:`_search_12ewc_1`,searchInput:`_searchInput_12ewc_17`,rail:`_rail_12ewc_33`,railItem:`_railItem_12ewc_37`,railGlyph:`_railGlyph_12ewc_70`,triggerPill:`_triggerPill_12ewc_90`,triggerLogo:`_triggerLogo_12ewc_105`,itemLogo:`_itemLogo_12ewc_114`},Vm={hybridai:`HybridAI`,codex:`OpenAI Codex`,anthropic:`Anthropic`,openrouter:`OpenRouter`,mistral:`Mistral`,huggingface:`Hugging Face`,gemini:`Gemini`,deepseek:`DeepSeek`,xai:`xAI`,zai:`Z.ai`,kimi:`Kimi`,minimax:`MiniMax`,dashscope:`DashScope`,xiaomi:`Xiaomi`,kilo:`Kilo`,ollama:`Ollama`,lmstudio:`LM Studio`,llamacpp:`llama.cpp`,vllm:`vLLM`},Hm={anthropic:`Anthropic`,google:`Google`,openai:`OpenAI`,mistral:`Mistral`,meta:`Meta`,deepseek:`DeepSeek`,xai:`xAI`},Um={Local:0,HybridAI:1,"OpenAI Codex":2},Wm={Anthropic:1,OpenAI:2,Google:3,Mistral:4,Meta:5};function Gm(e,t){let n=e.toLowerCase();return t[n]?t[n]:e.split(/[-_]/).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}var Km=new Set([`gpt`,`ai`,`ml`,`vl`,`ui`,`pdf`,`sdk`,`api`]),qm={deepseek:`DeepSeek`,openai:`OpenAI`,hybridai:`HybridAI`},Jm=/^[a-z]\d+$/;function Ym(e){let t=e.toLowerCase();return Km.has(t)?t.toUpperCase():qm[t]?qm[t]:Jm.test(t)?t:t.charAt(0).toUpperCase()+t.slice(1)}function Xm(e){if(!e)return e;let t=e.split(`-`).filter(e=>!/^\d{5,}$/.test(e)),n=[],r=null,i=0;for(;i<t.length;){let e=t[i],a,o=!1;if(/^\d+$/.test(e)){let n=[e];for(;i+1<t.length&&/^\d+$/.test(t[i+1]);)i++,n.push(t[i]);a=n.join(`.`),o=!0}else a=Ym(e),o=/^\d/.test(e);if(o&&r&&Km.has(r)){let e=n.pop()??``;n.push(e?`${e}-${a}`:a)}else n.push(a);r=t[i].toLowerCase(),i++}return n.join(` `)}function Zm(e){return e.provider}function Qm(e){let t=e.split(`/`,1)[0]?.trim().toLowerCase()??``;return t===`openai-codex`?`codex`:t&&Vm[t]?t:`hybridai`}function $m(e){return e===`ollama`?`ollama`:e===`lmstudio`?`lmstudio`:e===`llamacpp`?`llamacpp`:e===`vllm`?`vllm`:null}function eh(e){let t=e.trim();if(!t)return null;let n=Qm(t);return{id:t,provider:n,backend:$m(n),contextWindow:null,isReasoning:!1,family:null,parameterSize:null}}var th={HybridAI:Pu,"OpenAI Codex":Xu,Anthropic:Iu,OpenRouter:Ku,Mistral:Hu,"Hugging Face":Gu,Gemini:Ru,DeepSeek:Vu,xAI:Wu,"Z.ai":Zu,Kimi:Qu,MiniMax:$u,DashScope:ed,Xiaomi:td,Kilo:nd,Ollama:Ju,"LM Studio":rd,"llama.cpp":id,vLLM:ad,Local:gr},nh={Anthropic:Iu,OpenAI:Lu,Google:zu,Mistral:Hu,Meta:Uu,DeepSeek:Vu,xAI:Wu,Alibaba:od,Microsoft:qu};function rh({provider:e,size:t=18}){let n=th[e];return n?(0,B.jsx)(n,{width:t,height:t}):(0,B.jsx)(Or,{width:t,height:t})}function ih({vendor:e,fallbackProvider:t,size:n=18}){let r=e?nh[e]:void 0;return r?(0,B.jsx)(r,{width:n,height:n}):(0,B.jsx)(rh,{provider:t,size:n})}function ah({value:e,onValueChange:t,className:n,placeholder:r=`Search…`,...i}){return(0,B.jsxs)(`div`,{className:V(Bm.search,n),children:[(0,B.jsx)(Er,{width:`14`,height:`14`}),(0,B.jsx)(`input`,{type:`text`,autoComplete:`off`,spellCheck:!1,className:Bm.searchInput,placeholder:r,value:e,onChange:e=>t(e.target.value),...i})]})}function oh({children:e}){return(0,B.jsx)(`div`,{role:`toolbar`,"aria-orientation":`vertical`,className:Bm.rail,children:e})}function sh({active:e=!1,label:t,color:n,icon:r,className:i,...a}){return(0,B.jsx)(`button`,{type:`button`,"aria-pressed":e,"aria-label":t,title:t,"data-active":e?``:void 0,className:V(Bm.railItem,i),...a,children:(0,B.jsx)(`span`,{"aria-hidden":`true`,className:Bm.railGlyph,style:n?{color:n}:void 0,children:r??t.charAt(0).toUpperCase()})})}var ch=[[`claude`,`Anthropic`],[`gpt`,`OpenAI`],[`o1`,`OpenAI`],[`o3`,`OpenAI`],[`o4`,`OpenAI`],[`gemini`,`Google`],[`mistral`,`Mistral`],[`grok`,`xAI`],[`llama`,`Meta`],[`codellama`,`Meta`],[`deepseek`,`DeepSeek`],[`qwen`,`Alibaba`],[`phi`,`Microsoft`]];function lh(e){let t=e.toLowerCase();return ch.find(([e])=>t.startsWith(e))?.[1]??null}function uh(e,t){if(!t.backend||e.length<2)return null;let n=e[0]?.trim();return n?n.toLowerCase()===t.backend?Gm(t.backend,Vm):n:null}function dh(e){let t=e.id,n=t.split(`/`),r=Gm(e.provider,Vm),i,a;return n.length===1?(i=lh(n[0]),a=n[0]):n.length===2?(i=lh(n[1]),a=n[1]):(i=Gm(n[1],Hm),a=n.slice(2).join(`/`)),{id:t,groupLabel:i?`${r} · ${i}`:r,providerRank:Um[r]??50,vendorRank:i?Wm[i]??50:0,routeLabel:uh(n,e),shortName:a,displayName:Xm(a),vendor:i,provider:r,meta:e}}function fh(e,t){return e.providerRank===t.providerRank?e.vendorRank===t.vendorRank?e.groupLabel.localeCompare(t.groupLabel):e.vendorRank-t.vendorRank:e.providerRank-t.providerRank}function ph(e){return!e||e<=0?null:Ka(e)}function mh(e){let t=e.meta.family,n=t&&t!==e.shortName?Xm(t):null,r=[e.routeLabel,e.meta.parameterSize?.trim()||null,n&&n!==e.displayName?n:null,e.vendor].filter(e=>!!e);return r.length===0?null:r.join(` · `)}function hh(e,t){if(!t)return!0;let n=[e.id,e.shortName,e.displayName,e.provider,e.routeLabel??``,e.vendor??``,e.groupLabel].join(` `).toLowerCase();return t.toLowerCase().split(/\s+/).filter(Boolean).every(e=>n.includes(e))}function gh(e){let[t,n]=(0,R.useState)(``),[r,i]=(0,R.useState)(null),a=(0,R.useMemo)(()=>e.models.map(dh),[e.models]),o=(0,R.useMemo)(()=>{let e=new Map;for(let t of a){let n=Zm(t);e.set(n,(e.get(n)??0)+1)}return Array.from(e.entries()).map(([e,t])=>({key:e,count:t})).sort((e,t)=>e.key.localeCompare(t.key))},[a]),s=(0,R.useMemo)(()=>{let e=a.filter(e=>!(!hh(e,t)||r&&Zm(e)!==r)),n=new Map;for(let t of e){let e=n.get(t.groupLabel);e||(e={head:t,items:[]},n.set(t.groupLabel,e)),e.items.push(t)}let i=Array.from(n.values()).sort((e,t)=>fh(e.head,t.head));for(let e of i)e.items.sort((e,t)=>e.shortName.localeCompare(t.shortName)||(e.routeLabel??``).localeCompare(t.routeLabel??``)||e.id.localeCompare(t.id));return i},[a,t,r]),c=e.selectedModelId.trim(),l=eh(c),u=a.find(e=>e.id===c)??(l?dh(l):void 0);return e.models.length===0&&!u?null:(0,B.jsxs)(Cm,{value:u?u.id:``,disabled:e.disabled,onValueChange:t=>{!t||t===c||e.onSwitch(t)},children:[(0,B.jsxs)(wm,{"aria-label":`Switch model`,title:`Switch model`,className:V(zm.composerPill,Bm.triggerPill),children:[u?(0,B.jsx)(`span`,{"aria-hidden":`true`,className:Bm.triggerLogo,children:(0,B.jsx)(ih,{vendor:u.vendor,fallbackProvider:u.provider,size:16})}):null,(0,B.jsx)(Tm,{placeholder:`Select model`,children:u?u.displayName:``}),(0,B.jsx)(Em,{})]}),(0,B.jsx)(Om,{align:`start`,header:(0,B.jsx)(ah,{value:t,onValueChange:n,placeholder:`Search models…`,"aria-label":`Search models`}),rail:(0,B.jsxs)(oh,{children:[(0,B.jsx)(sh,{label:r===null?`All providers`:`Clear filter`,active:r===null,icon:(0,B.jsx)(yr,{width:`16`,height:`16`}),onClick:()=>i(null)}),o.map(({key:e,count:t})=>(0,B.jsx)(sh,{label:`${e} (${t})`,active:r===e,icon:(0,B.jsx)(rh,{provider:e}),onClick:()=>i(t=>t===e?null:e)},e))]}),children:s.length===0?(0,B.jsxs)(jm,{children:[`No models match “`,t,`”.`]}):s.map(e=>(0,B.jsxs)(km,{children:[(0,B.jsx)(Am,{children:e.head.groupLabel}),e.items.map(e=>{let t=ph(e.meta.contextWindow),n=mh(e);return(0,B.jsxs)(Mm,{value:e.id,textValue:`${e.displayName} ${e.groupLabel} ${e.routeLabel??``}`,children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,className:Bm.itemLogo,children:(0,B.jsx)(ih,{vendor:e.vendor,fallbackProvider:e.provider,size:18})}),(0,B.jsxs)(Pm,{children:[(0,B.jsx)(Nm,{children:e.displayName}),n?(0,B.jsx)(Fm,{children:n}):null]}),(0,B.jsx)(Im,{children:t?(0,B.jsx)(`span`,{children:t}):null})]},e.id)})]},e.head.groupLabel))})]})}var _h={enabled:!1,mode:`rewrite`,policy:``,doList:[],dontList:[],bannedPhrases:[],bannedPatterns:[],requirePhrases:[],classifier:{provider:`default`,model:``},rewriter:{provider:`default`,model:``}};function vh(e,t){return JSON.stringify(e)===JSON.stringify(t)}function yh(e,t=``){return{provider:e,model:e===`model`?t.trim():``}}function bh(e,t){let n=e?.trim()??``;if(!n)return``;let r=t.find(e=>e.id===n);return r?dh(r).displayName:n}function xh(e){let t=e=>e.map(e=>e.trim()).filter(Boolean);return{...e,policy:e.policy.trim(),doList:t(e.doList),dontList:t(e.dontList),bannedPhrases:t(e.bannedPhrases),bannedPatterns:t(e.bannedPatterns),requirePhrases:t(e.requirePhrases),classifier:yh(e.classifier.provider,e.classifier.model),rewriter:yh(e.rewriter.provider,e.rewriter.model)}}function Sh(e){let t=(0,R.useRef)(0),n=(0,R.useCallback)(n=>{let r={id:`${e.label}-${t.current}`,value:n};return t.current+=1,r},[e.label]),[r,i]=(0,R.useState)(()=>e.values.map(n)),a=t=>{i(t),e.onChange(t.map(e=>e.value))};return(0,R.useEffect)(()=>{i(t=>e.values.map((e,r)=>{if(t[r]?.value===e)return t[r];let i=t[r];return i?{...i,value:e}:n(e)}))},[n,e.values]),(0,B.jsxs)(`div`,{className:`field output-guard-list-field`,children:[(0,B.jsx)(`span`,{children:e.label}),(0,B.jsxs)(`div`,{className:`output-guard-list`,children:[r.map((t,n)=>(0,B.jsxs)(`div`,{className:`output-guard-list-row`,children:[(0,B.jsx)(`input`,{"aria-label":`${e.label} item ${n+1}`,value:t.value,onChange:e=>a(r.map((t,r)=>r===n?{...t,value:e.target.value}:t)),placeholder:e.placeholder}),(0,B.jsx)(`button`,{className:`ghost-button icon-button`,type:`button`,"aria-label":`Remove ${e.label} item ${n+1}`,title:`Remove`,onClick:()=>{a(r.filter((e,t)=>t!==n))},children:(0,B.jsx)(Fr,{width:`16`,height:`16`})})]},t.id)),(0,B.jsx)(`button`,{className:`ghost-button output-guard-add-button`,type:`button`,"aria-label":`Add ${e.label} item`,onClick:()=>{a([...r,n(``)])},children:`Add`})]})]})}function Ch(e){let t=e.value.provider===`model`?e.value.model:``,n=bh(e.activeModelId,e.modelOptions)||e.activeModelFallback;return(0,B.jsxs)(`div`,{className:`field`,children:[(0,B.jsx)(`span`,{children:e.label}),(0,B.jsxs)(`div`,{className:`output-guard-model-source-control has-model-readout ${e.value.provider===`model`?`has-model-select`:``}`,children:[(0,B.jsx)(Wa,{ariaLabel:e.ariaLabel,value:e.value.provider,options:[{value:`default`,label:`default model`},{value:`auxiliary`,label:`aux model`},{value:`model`,label:`other model`}],onChange:t=>{let n=t===`model`?e.value.model||e.defaultOtherModelId:``;e.onChange(yh(t,n))}}),e.value.provider===`model`?(0,B.jsx)(gh,{models:e.modelOptions,selectedModelId:t,disabled:e.modelsLoading,onSwitch:t=>e.onChange(yh(`model`,t))}):(0,B.jsx)(`div`,{className:`output-guard-model-readout`,title:e.activeModelId||n,children:n})]})]})}function wh(e){return e===`compliant`?`compliant`:e===`needs_review`?`needs review`:`non-compliant`}function Th(e){return e.kind===`banned_phrase`?`Contains banned phrase "${e.detail}".`:e.kind===`banned_pattern`?`Matches banned pattern ${e.detail}.`:`Missing required phrase "${e.detail}".`}function Eh(e){let{classifier:t}=e;if(t.status===`evaluated`&&t.verdict){let e=t.severity?`, ${t.severity}`:``,n=t.model?` via ${t.model}`:``;return`Classifier ${t.provider==="default"?`default model`:t.provider===`auxiliary`?`aux model`:`selected model`}${n}: ${wh(t.verdict)}${e}.`}return t.status===`unparseable`?`Classifier response was not parseable; showing rules score.`:e.scoreSource===`classifier`?`Classifier unavailable; failure mode blocks output.`:`Classifier unavailable; showing rules score.`}function Dh(){let e=Gn(),t=hs(),n=o(),[r,i]=(0,R.useState)(_h),[a,s]=(0,R.useState)(``),[c,l]=(0,R.useState)(null),u=y({queryKey:[`output-guard-profile`,e.token],queryFn:()=>On(e.token)}),d=y({queryKey:[`models`,e.token],queryFn:()=>Kt(e.token)});(0,R.useEffect)(()=>{u.data?.profile&&i(u.data.profile)},[u.data?.profile]);let f=u.data?.profile??_h,p=!vh(xh(r),f),m=d.data?.models??[],h=d.data?.defaultModel??``,_=d.data?.auxiliaryModels?.skillsHub.model??null,v=d.data?.auxiliaryModels?.skillsHub.provider??`auto`,b=m.find(e=>e.id!==h)?.id??h;(0,R.useEffect)(()=>{b&&((r.classifier.provider!==`model`||r.classifier.model)&&(r.rewriter.provider!==`model`||r.rewriter.model)||i(e=>{let t=e;return e.classifier.provider===`model`&&!e.classifier.model&&(t={...t,classifier:yh(`model`,b)}),e.rewriter.provider===`model`&&!e.rewriter.model&&(t={...t,rewriter:yh(`model`,b)}),t}))},[b,r.classifier.model,r.classifier.provider,r.rewriter.model,r.rewriter.provider]);let x=g({mutationFn:()=>kn(e.token,xh(r)),onSuccess:r=>{i(r.profile),t.success(r.changed?`Output guard saved.`:`Output guard unchanged.`,r.reloadMessage),n.setQueryData([`output-guard-profile`,e.token],r),n.invalidateQueries({queryKey:[`output-guard-profile`,e.token]})},onError:e=>{t.error(`Save failed`,H(e))}}),S=g({mutationFn:()=>An(e.token,xh(r),a),onSuccess:e=>{l(e)},onError:e=>{t.error(`Preview failed`,H(e))}});return(0,B.jsxs)(`div`,{className:`page-stack output-guard-page`,children:[(0,B.jsx)(Ha,{description:`Operator controls for output policy, rules, classifier, and rewrite behavior.`,actions:(0,B.jsx)(`button`,{className:`primary-button`,type:`button`,disabled:!p||x.isPending,onClick:()=>x.mutate(),children:x.isPending?`Saving...`:`Save profile`})}),(0,B.jsxs)(`div`,{className:`two-column-grid`,children:[(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:`Profile`}),(0,B.jsx)(uo,{children:`Runtime plugin profile`})]}),(0,B.jsx)(K,{children:u.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading output guard...`}):u.isError?(0,B.jsx)(`div`,{className:`empty-state`,children:H(u.error)}):(0,B.jsxs)(`div`,{className:`stack-form`,children:[(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:r.enabled,onCheckedChange:e=>i(t=>({...t,enabled:e}))}),(0,B.jsx)(Bo,{children:(0,B.jsx)(J,{children:`Enabled`})})]}),(0,B.jsxs)(`div`,{className:`field`,children:[(0,B.jsx)(`span`,{children:`Mode`}),(0,B.jsx)(Wa,{ariaLabel:`Output guard mode`,value:r.mode,options:[{value:`rewrite`,label:`rewrite`},{value:`block`,label:`block`},{value:`flag`,label:`flag`}],onChange:e=>i(t=>({...t,mode:e}))})]}),(0,B.jsx)(Ch,{label:`Classifier`,ariaLabel:`Output guard classifier source`,value:r.classifier,modelOptions:m,defaultOtherModelId:b,activeModelId:r.classifier.provider==="default"?h:_,activeModelFallback:r.classifier.provider==="default"?`No default model`:v===`disabled`?`Aux model disabled`:`Auto routing`,modelsLoading:d.isLoading,onChange:e=>i(t=>({...t,classifier:e}))}),(0,B.jsx)(Ch,{label:`Rewriter`,ariaLabel:`Output guard rewriter source`,value:r.rewriter,modelOptions:m,defaultOtherModelId:b,activeModelId:r.rewriter.provider==="default"?h:_,activeModelFallback:r.rewriter.provider==="default"?`No default model`:v===`disabled`?`Aux model disabled`:`Auto routing`,modelsLoading:d.isLoading,onChange:e=>i(t=>({...t,rewriter:e}))}),(0,B.jsxs)(`label`,{className:`field textarea-field`,children:[(0,B.jsx)(`span`,{children:`Policy`}),(0,B.jsx)(`textarea`,{rows:5,value:r.policy,onChange:e=>i(t=>({...t,policy:e.target.value})),placeholder:`Clear, direct, concrete. No hype.`})]}),(0,B.jsx)(Sh,{label:`Do`,values:r.doList,placeholder:`Use concrete nouns`,onChange:e=>i(t=>({...t,doList:e}))}),(0,B.jsx)(Sh,{label:`Don't`,values:r.dontList,placeholder:`Use hype or vague claims`,onChange:e=>i(t=>({...t,dontList:e}))}),(0,B.jsx)(`small`,{className:`output-guard-list-note`,children:`Do and Don't guide rewrites and classifier context; banned and required rules stay deterministic.`}),(0,B.jsx)(Sh,{label:`Banned phrases`,values:r.bannedPhrases,placeholder:`game changing`,onChange:e=>i(t=>({...t,bannedPhrases:e}))}),(0,B.jsx)(Sh,{label:`Banned patterns`,values:r.bannedPatterns,placeholder:`/\\\\bguarantee[sd]?\\\\b/i`,onChange:e=>i(t=>({...t,bannedPatterns:e}))}),(0,B.jsx)(Sh,{label:`Required phrases`,values:r.requirePhrases,placeholder:`Best regards`,onChange:e=>i(t=>({...t,requirePhrases:e}))})]})})]}),(0,B.jsxs)(`div`,{className:`page-stack`,children:[(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:`Preview`}),(0,B.jsx)(uo,{children:c?`${c.score}/100, ${wh(c.verdict)} (${c.scoreSource})`:`No score yet`})]}),(0,B.jsxs)(K,{children:[(0,B.jsxs)(`label`,{className:`field textarea-field`,children:[(0,B.jsx)(`span`,{children:`Sample output`}),(0,B.jsx)(`textarea`,{rows:9,value:a,onChange:e=>s(e.target.value),placeholder:`Paste assistant output`})]}),(0,B.jsx)(`button`,{className:`primary-button`,type:`button`,disabled:!a.trim()||S.isPending,onClick:()=>S.mutate(),children:S.isPending?`Scoring...`:`Score sample`}),c?(0,B.jsxs)(`div`,{className:`output-guard-score-panel`,children:[(0,B.jsx)(`div`,{className:`output-guard-score-bar`,children:(0,B.jsx)(`span`,{style:{width:`${c.score}%`}})}),(0,B.jsx)(`small`,{children:Eh(c)}),c.violations.length>0?(0,B.jsx)(`ul`,{className:`output-guard-reason-list`,children:c.violations.map(e=>{let t=Th(e);return(0,B.jsx)(`li`,{children:t},t)})}):(0,B.jsx)(`small`,{children:`No rule violations detected.`}),c.classifier.reasons.length>0?(0,B.jsx)(`ul`,{className:`output-guard-reason-list`,children:c.classifier.reasons.map(e=>(0,B.jsx)(`li`,{children:e},`classifier-${e}`))}):null]}):null]})]}),(0,B.jsxs)(U,{variant:`muted`,children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:`Versions`}),(0,B.jsx)(uo,{children:`${u.data?.revisions.length??0} profile edits`})]}),(0,B.jsx)(K,{children:u.data?.revisions.length?(0,B.jsx)(`div`,{className:`list-stack selectable-list`,children:u.data.revisions.map(e=>(0,B.jsxs)(`div`,{className:`list-row`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`strong`,{children:[`Revision `,e.id]}),(0,B.jsx)(`small`,{children:Qa(e.createdAt)}),(0,B.jsx)(`small`,{children:e.actor})]}),(0,B.jsx)(`span`,{className:`list-status`,children:e.source})]},e.id))}):(0,B.jsx)(`div`,{className:`empty-state`,children:`No saved profile edits yet.`})})]})]})]})]})}var Oh={plugin:(e,t)=>X(e.name||e.id,t.name||t.id)||X(e.id,t.id),source:(e,t)=>X(e.source,t.source)||X(e.name||e.id,t.name||t.id),enabled:(e,t)=>es(e.enabled,t.enabled)||X(e.name||e.id,t.name||t.id),status:(e,t)=>es(e.status===`loaded`,t.status===`loaded`)||X(e.name||e.id,t.name||t.id),commands:(e,t)=>$o(e.commands.length,t.commands.length)||X(e.name||e.id,t.name||t.id),tools:(e,t)=>$o(e.tools.length,t.tools.length)||X(e.name||e.id,t.name||t.id),hooks:(e,t)=>$o(e.hooks.length,t.hooks.length)||X(e.name||e.id,t.name||t.id)},kh={enabled:`desc`,status:`desc`,commands:`desc`,tools:`desc`,hooks:`desc`};function Ah(e){return e.length>0?e.join(`, `):`none`}function jh(e,t){return t?[e.id,e.name||``,e.description||``,e.source,e.status,e.error||``,...e.commands,...e.tools,...e.hooks].join(` `).toLowerCase().includes(t):!0}function Mh(){let e=Gn(),[t,n]=(0,R.useState)(``),r=(0,R.useDeferredValue)(t).trim().toLowerCase(),i=y({queryKey:[`plugins`,e.token],queryFn:()=>Dn(e.token)}),{sortedRows:a,sortState:o,toggleSort:s}=Ba((i.data?.plugins||[]).filter(e=>jh(e,r)),{initialSort:{key:`plugin`,direction:`asc`},sorters:Oh,defaultDirections:kh}),c=a.filter(e=>e.status===`failed`);return(0,B.jsxs)(`div`,{className:`page-stack`,children:[(0,B.jsx)(Ha,{description:`Discovery and runtime load status for configured HybridClaw plugins.`,actions:(0,B.jsx)(`input`,{className:`compact-search`,value:t,onChange:e=>n(e.target.value),placeholder:`Filter plugins`})}),(0,B.jsxs)(`div`,{className:`metric-grid`,children:[(0,B.jsx)(Ua,{label:`Plugins`,value:String(i.data?.totals.totalPlugins??0),detail:`${i.data?.totals.enabledPlugins??0} enabled`,loading:!i.data}),(0,B.jsx)(Ua,{label:`Load failures`,value:String(i.data?.totals.failedPlugins??0),detail:`runtime initialization errors`,loading:!i.data}),(0,B.jsx)(Ua,{label:`Commands`,value:String(i.data?.totals.commands??0),detail:`plugin-defined commands`,loading:!i.data}),(0,B.jsx)(Ua,{label:`Tools / Hooks`,value:`${i.data?.totals.tools??0} / ${i.data?.totals.hooks??0}`,detail:`registered runtime surfaces`,loading:!i.data})]}),(0,B.jsxs)(`div`,{className:`two-column-grid`,children:[(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:`Registry`}),(0,B.jsx)(uo,{children:`${a.length} plugin${a.length===1?``:`s`} visible`})]}),(0,B.jsx)(K,{children:i.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading plugins...`}):a.length===0?(0,B.jsx)(`div`,{className:`empty-state`,children:`No plugins match this filter.`}):(0,B.jsx)(`div`,{className:`table-shell`,children:(0,B.jsxs)(`table`,{children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(Va,{label:`Plugin`,sortKey:`plugin`,sortState:o,onToggle:s}),(0,B.jsx)(Va,{label:`Source`,sortKey:`source`,sortState:o,onToggle:s}),(0,B.jsx)(Va,{label:`Enabled`,sortKey:`enabled`,sortState:o,onToggle:s}),(0,B.jsx)(Va,{label:`Status`,sortKey:`status`,sortState:o,onToggle:s}),(0,B.jsx)(Va,{label:`Commands`,sortKey:`commands`,sortState:o,onToggle:s}),(0,B.jsx)(Va,{label:`Tools`,sortKey:`tools`,sortState:o,onToggle:s}),(0,B.jsx)(Va,{label:`Hooks`,sortKey:`hooks`,sortState:o,onToggle:s})]})}),(0,B.jsx)(`tbody`,{children:a.map(e=>(0,B.jsxs)(`tr`,{children:[(0,B.jsxs)(`td`,{children:[(0,B.jsx)(`strong`,{children:e.name||e.id}),(0,B.jsxs)(`small`,{children:[e.id,e.version?` · v${e.version}`:``]}),e.description?(0,B.jsx)(`small`,{children:e.description}):null,e.error?(0,B.jsx)(`small`,{children:e.error}):null]}),(0,B.jsx)(`td`,{children:e.source}),(0,B.jsx)(`td`,{children:(0,B.jsx)(Ga,{value:e.enabled,trueLabel:`enabled`,falseLabel:`disabled`})}),(0,B.jsx)(`td`,{children:(0,B.jsx)(Ga,{value:e.status===`loaded`,trueLabel:`loaded`,falseLabel:`failed`})}),(0,B.jsxs)(`td`,{children:[(0,B.jsx)(`strong`,{children:e.commands.length}),(0,B.jsx)(`small`,{children:Ah(e.commands)})]}),(0,B.jsxs)(`td`,{children:[(0,B.jsx)(`strong`,{children:e.tools.length}),(0,B.jsx)(`small`,{children:Ah(e.tools)})]}),(0,B.jsxs)(`td`,{children:[(0,B.jsx)(`strong`,{children:e.hooks.length}),(0,B.jsx)(`small`,{children:Ah(e.hooks)})]})]},e.id))})]})})})]}),(0,B.jsxs)(U,{variant:`muted`,children:[(0,B.jsx)(W,{children:(0,B.jsx)(G,{children:`Failures`})}),(0,B.jsx)(K,{children:i.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading plugin status...`}):c.length>0?(0,B.jsx)(`div`,{className:`list-stack selectable-list`,children:c.map(e=>(0,B.jsxs)(`div`,{className:`list-row`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:e.name||e.id}),(0,B.jsxs)(`small`,{children:[e.id,e.version?` · v${e.version}`:``]}),(0,B.jsx)(`small`,{children:e.error||`Unknown plugin load error.`})]}),(0,B.jsxs)(`span`,{className:`list-status list-status-danger`,children:[(0,B.jsx)(`span`,{className:`status-dot status-dot-danger`}),`failed`]})]},e.id))}):(0,B.jsx)(`div`,{className:`empty-state`,children:`No plugin load failures were reported.`})})]})]})]})}var Nh={anchor:`_anchor_1k3rt_1`,input:`_input_1k3rt_7`,chevron:`_chevron_1k3rt_11`,popover:`_popover_1k3rt_22`,list:`_list_1k3rt_28`,option:`_option_1k3rt_39`,optionLabel:`_optionLabel_1k3rt_60`,optionDescription:`_optionDescription_1k3rt_64`,empty:`_empty_1k3rt_69`},Ph=(e,t)=>{if(!t)return!0;let n=t.toLowerCase();return e.label.toLowerCase().includes(n)||e.value.toLowerCase().includes(n)};function Fh({value:e,onValueChange:t,options:n,placeholder:r,disabled:i,renderOption:a,emptyMessage:o=`No matches.`,filter:s=Ph,allowFreeText:c=!1,popoverAlign:l=`start`,className:u,id:d,onBlur:f}){let p=Do({id:d,disabled:i,"aria-invalid":void 0,"aria-describedby":void 0}),m=(0,R.useId)(),h=`${p.id??m}-listbox`,g=(0,R.useMemo)(()=>n.find(t=>t.value===e)??null,[n,e]),_=g?g.label:c?e:``,[v,y]=(0,R.useState)(!1),[b,x]=(0,R.useState)(_),[S,C]=(0,R.useState)(0),w=(0,R.useRef)(null),T=(0,R.useRef)(!1);(0,R.useEffect)(()=>{v||x(_)},[_,v]);let E=(0,R.useMemo)(()=>v?n.filter(e=>s(e,b.trim())):n,[n,v,b,s]);(0,R.useEffect)(()=>{S>=E.length&&C(0)},[E.length,S]);let D=(0,R.useCallback)((e,n)=>{T.current=!0,e?(t(e.value,e),x(e.label)):c&&t(n??``,null),y(!1)},[c,t]),O=e=>{x(e.target.value),y(!0),C(0)},k=e=>{if(e.key===`ArrowDown`)e.preventDefault(),y(!0),C(e=>Math.min(e+1,Math.max(0,E.length-1)));else if(e.key===`ArrowUp`)e.preventDefault(),y(!0),C(e=>Math.max(e-1,0));else if(e.key===`Enter`){if(!v)return;e.preventDefault();let t=E[S];t&&!t.disabled?D(t):c&&D(null,b)}else if(e.key===`Escape`){if(!v)return;e.preventDefault(),y(!1),x(_)}else if(e.key===`Tab`){if(!v)return;let e=E[S];e&&!e.disabled&&D(e)}},A=()=>{if(y(!1),T.current){T.current=!1,f?.();return}if(c)b!==_&&D(null,b);else{let t=n.find(e=>e.label===b||e.value===b);t?t.value!==e&&D(t):x(_)}f?.()};return(0,B.jsxs)(Oi,{open:v,onOpenChange:y,children:[(0,B.jsxs)(ki,{className:V(Nh.anchor,u),children:[(0,B.jsx)(Y,{...p,ref:w,type:`text`,role:`combobox`,"aria-expanded":v,"aria-controls":v?h:void 0,"aria-autocomplete":`list`,"aria-activedescendant":v&&E[S]?`${h}-option-${S}`:void 0,value:b,placeholder:r,onFocus:()=>y(!0),onChange:O,onKeyDown:k,onBlur:A,className:Nh.input,autoComplete:`off`,spellCheck:!1}),(0,B.jsx)(er,{"aria-hidden":`true`,className:Nh.chevron})]}),(0,B.jsx)(Ai,{align:l,className:Nh.popover,children:(0,B.jsx)(`div`,{role:`listbox`,id:h,className:Nh.list,children:E.length===0?(0,B.jsx)(`div`,{className:Nh.empty,children:o}):E.map((t,n)=>{let r=n===S,i=t.value===e;return(0,B.jsx)(`div`,{id:`${h}-option-${n}`,role:`option`,"aria-selected":i,"aria-disabled":t.disabled||void 0,"data-active":r||void 0,"data-disabled":t.disabled||void 0,tabIndex:-1,className:Nh.option,onMouseDown:e=>{e.preventDefault(),t.disabled||D(t)},onMouseEnter:()=>C(n),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t.disabled||D(t))},children:a?a(t,r):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:Nh.optionLabel,children:t.label}),t.description?(0,B.jsx)(`span`,{className:Nh.optionDescription,children:t.description}):null]})},t.value)})})})]})}function Ih(e){if(e==null)return null;if(e instanceof Date)return Number.isNaN(e.getTime())?null:e;let t=e.trim();if(!t)return null;let n=/^\d{4}-\d{2}-\d{2}$/.test(t)?`${t}T00:00`:t,r=new Date(n);return Number.isNaN(r.getTime())?null:r}function Lh(e,t){if(!e)return``;let n=e.getTimezoneOffset()*6e4,r=new Date(e.getTime()-n).toISOString();return t===`day`?r.slice(0,10):t===`second`?r.slice(0,19):r.slice(0,16)}function Rh({value:e,onValueChange:t,onErrorChange:n,granularity:r=`minute`,min:i,max:a,required:o=!1,...s}){let c=Eo(),l=r===`day`?`date`:`datetime-local`,u=r===`second`?1:void 0,d=(0,R.useMemo)(()=>Ih(i??null),[i]),f=(0,R.useMemo)(()=>Ih(a??null),[a]),p=Lh((0,R.useMemo)(()=>Ih(e),[e]),r),m=(0,R.useCallback)(e=>{c.setError(e),n?.(e)},[c.setError,n]);return(0,B.jsx)(Y,{...s,type:l,step:u,value:p,min:d?Lh(d,r):void 0,max:f?Lh(f,r):void 0,onChange:e=>{let n=e.target.value;if(n.trim()===``){if(o){m(`Required.`);return}m(null),t(null);return}let r=Ih(n);if(!r){m(`Enter a valid date.`);return}if(d&&r<d){m(`Date is earlier than the minimum allowed.`);return}if(f&&r>f){m(`Date is later than the maximum allowed.`);return}m(null),t(r)}})}var zh=[`backlog`,`in_progress`,`review`,`done`,`cancelled`],Bh=[`cron`,`every`,`at`,`one_shot`],Vh=[`agent_turn`,`system_event`],Hh=[`channel`,`last-channel`,`webhook`];function Uh(e){return e?.source===`job`}function Wh(e){return e?.source===`task`}function Gh(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t}function Kh(e){return e.schedule.kind===`one_shot`?`one shot`:e.schedule.kind===`cron`?e.schedule.expr||`invalid cron`:e.schedule.kind===`every`?`every ${e.schedule.everyMs}ms`:Qa(e.schedule.at)}function qh(e){return e.source===`task`?`task #${e.taskId??`n/a`} · ${Kh(e)}`:`${e.id} · ${Kh(e)}`}function Jh(e){return e.disabled?`paused`:e.boardStatus===`review`&&e.lastStatus===`error`?`failed`:e.lastStatus?e.lastStatus:e.enabled?`ready`:`inactive`}function Yh(e){return e?.boardStatus?e.boardStatus:e?!e.enabled||e.disabled?`cancelled`:e.lastStatus===`success`?`done`:e.lastStatus===`error`?`cancelled`:`backlog`:`backlog`}function Xh(e){return{originalId:e?.id||null,id:e?.id||``,name:e?.name||``,description:e?.description||``,agentId:e?.agentId||``,boardStatus:Yh(e),enabled:e?.enabled??!0,scheduleKind:e?.schedule.kind||`cron`,scheduleExpr:e?.schedule.expr||`0 * * * *`,scheduleEveryMs:e?.schedule.everyMs??6e4,scheduleAt:Gh(e?.schedule.at||null),scheduleTz:e?.schedule.tz||``,maxRetries:typeof e?.maxRetries==`number`?e.maxRetries:3,actionKind:e?.action.kind||`agent_turn`,actionMessage:e?.action.message||``,deliveryKind:e?.delivery.kind||`channel`,deliveryChannel:e?.delivery.channel||`tui`,deliveryTo:e?.delivery.to||``,deliveryWebhookUrl:e?.delivery.webhookUrl||``}}function Zh(e){let t=[{value:`tui`,label:`Local TUI`}],n=e.config;if(n){let r=vl(n,{discordTokenConfigured:e.status?.discord?.tokenConfigured,slackBotTokenConfigured:e.status?.slack?.botTokenConfigured,slackAppTokenConfigured:e.status?.slack?.appTokenConfigured,telegramTokenConfigured:e.status?.telegram?.tokenConfigured,whatsappLinked:e.status?.whatsapp?.linked,emailPasswordConfigured:e.status?.email?.passwordConfigured,imessagePasswordConfigured:e.status?.imessage?.passwordConfigured});for(let e of r)e.statusTone===`active`&&t.push({value:e.kind,label:e.label})}let r=e.currentChannel.trim();return r&&!t.some(e=>e.value===r)&&t.push({value:r,label:`${Qh(r)} (current)`}),t}function Qh(e){switch(e){case`discord`:return`Discord`;case`slack`:return`Slack`;case`telegram`:return`Telegram`;case`whatsapp`:return`WhatsApp`;case`email`:return`Email`;case`msteams`:return`Microsoft Teams`;case`imessage`:return`iMessage`;case`tui`:return`Local TUI`;case`web`:return`Local Web`;default:return e}}function $h(e,t){return t?e===`discord`?t.channels.filter(e=>e.transport===`discord`).map(e=>({value:e.channelId,label:`${e.guildId} · ${e.channelId}`})):e===`msteams`?t.channels.filter(e=>e.transport===`msteams`).map(e=>({value:e.channelId,label:`${e.guildId} · ${e.channelId}`})):[]:[]}function eg(e){let t=e.currentValue.trim();return e.channel===`tui`||e.channel===`web`?e.channel:e.options.length===0||e.options.some(e=>e.value===t)?t:e.options[0].value}function tg(e){let t=$h(e.channel,e.channels),n=eg({channel:e.channel,currentValue:e.currentValue,options:t});if(e.channel===`tui`||e.channel===`web`||(e.channel===`discord`||e.channel===`msteams`)&&t.length===1)return{kind:`none`,value:n};if((e.channel===`discord`||e.channel===`msteams`)&&t.length>1)return{kind:`select`,value:n,label:`Channel`,options:t};switch(e.channel){case`discord`:return{kind:`input`,value:n,label:`Channel ID`,placeholder:`123456789012345678`};case`slack`:return{kind:`input`,value:n,label:`Conversation target`,placeholder:`slack:C1234567890`};case`telegram`:return{kind:`input`,value:n,label:`Chat ID`,placeholder:`telegram:-1001234567890`};case`whatsapp`:return{kind:`input`,value:n,label:`Chat JID`,placeholder:`491234567890@s.whatsapp.net`};case`email`:return{kind:`input`,value:n,label:`Recipient`,placeholder:`ops@example.com`};case`imessage`:return{kind:`input`,value:n,label:`Handle`,placeholder:`imessage:ops@example.com`};case`msteams`:return{kind:`input`,value:n,label:`Channel ID`,placeholder:`19:channel-id@thread.tacv2`};default:return{kind:`input`,value:n,label:`Target`,placeholder:e.channel||`target`}}}function ng(e,t){return e.deliveryKind===`channel`?{...e,deliveryTo:t.value}:{...e,deliveryTo:``}}function rg(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,48)}function ig(e){let t=e.id.trim();if(t)return{...e,id:t};let n=rg(e.name)||rg(e.description)||rg(e.actionMessage)||`job-${Date.now().toString(36).slice(-8).toLowerCase()}`;return{...e,id:n}}function ag(e){let t=e.scheduleKind===`at`&&e.scheduleAt?e.scheduleAt.toISOString():null;if(e.scheduleKind===`at`&&!t)throw Error(`Pick a valid "Run at" timestamp.`);return{id:e.id.trim(),source:`job`,name:e.name.trim()||e.id.trim(),description:e.description.trim()||null,agentId:e.agentId.trim()||null,boardStatus:e.boardStatus,maxRetries:e.scheduleKind===`one_shot`?e.maxRetries:null,enabled:e.enabled,schedule:{kind:e.scheduleKind,at:t,everyMs:e.scheduleKind===`every`?e.scheduleEveryMs:null,expr:e.scheduleKind===`cron`&&e.scheduleExpr.trim()||null,tz:e.scheduleKind===`one_shot`?``:e.scheduleTz.trim()},action:{kind:e.actionKind,message:e.actionMessage.trim()},delivery:{kind:e.deliveryKind,channel:e.deliveryChannel.trim()||`tui`,to:e.deliveryKind===`channel`?e.deliveryTo.trim():``,webhookUrl:e.deliveryKind===`webhook`?e.deliveryWebhookUrl.trim():``},lastRun:null,lastStatus:null,nextRunAt:null,disabled:!1,consecutiveErrors:0,createdAt:null,sessionId:null,channelId:null,taskId:null}}function og(e,t,n){n.setQueryData([`scheduler`,t],e)}function sg(e){return(0,B.jsxs)(U,{variant:`muted`,children:[(0,B.jsx)(W,{children:(0,B.jsx)(G,{children:`Task`})}),(0,B.jsx)(K,{children:(0,B.jsxs)(`div`,{className:`stack-form`,children:[(0,B.jsxs)(`div`,{className:`key-value-grid`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Task`}),(0,B.jsxs)(`strong`,{children:[`#`,e.job.taskId??`n/a`]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`State`}),(0,B.jsx)(Ga,{value:e.job.enabled&&!e.job.disabled,trueLabel:`active`,falseLabel:`inactive`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Session`}),(0,B.jsx)(`strong`,{children:e.job.sessionId||`n/a`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Channel`}),(0,B.jsx)(`strong`,{children:e.job.channelId||`n/a`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Created`}),(0,B.jsx)(`strong`,{children:Qa(e.job.createdAt)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Next run`}),(0,B.jsx)(`strong`,{children:Qa(e.job.nextRunAt)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Last run`}),(0,B.jsx)(`strong`,{children:Qa(e.job.lastRun)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Last status`}),(0,B.jsx)(`strong`,{children:e.job.lastStatus||`n/a`})]})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Message`}),(0,B.jsx)(Jo,{readOnly:!0,rows:6,value:e.job.action.message})]}),(0,B.jsxs)(`div`,{className:`button-row`,children:[(0,B.jsx)(`button`,{className:`ghost-button`,type:`button`,disabled:e.pausePending,onClick:e.onPauseToggle,children:e.pausePending?`Updating...`:e.job.disabled?`Resume task`:`Pause task`}),(0,B.jsx)(`button`,{className:`danger-button`,type:`button`,disabled:e.deletePending,onClick:e.onDelete,children:e.deletePending?`Deleting...`:`Delete task`})]})]})})]})}function cg(e){let{draft:t,selectedJob:n}=e;return(0,B.jsx)(Oc,{form:e.form,onSubmit:e.onSave,children:(0,B.jsxs)(U,{variant:`muted`,children:[(0,B.jsx)(W,{children:(0,B.jsx)(G,{children:`Job`})}),(0,B.jsx)(K,{children:(0,B.jsxs)(`div`,{className:`stack-form`,children:[(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`ID`}),(0,B.jsx)(Y,{value:t.id,onChange:t=>e.onDraftChange(e=>({...e,id:t.target.value})),placeholder:`Auto-generated from name if blank`})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Name`}),(0,B.jsx)(Y,{value:t.name,onChange:t=>e.onDraftChange(e=>({...e,name:t.target.value})),placeholder:`Nightly research`})]})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Description`}),(0,B.jsx)(Y,{value:t.description,onChange:t=>e.onDraftChange(e=>({...e,description:t.target.value})),placeholder:`Optional`})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Status`}),(0,B.jsxs)(ds,{value:t.boardStatus,onChange:t=>e.onDraftChange(e=>({...e,boardStatus:nu(zh,t.target.value,e.boardStatus)})),children:[(0,B.jsx)(Q,{value:`backlog`,children:`backlog`}),(0,B.jsx)(Q,{value:`in_progress`,children:`in progress`}),(0,B.jsx)(Q,{value:`review`,children:`review`}),(0,B.jsx)(Q,{value:`done`,children:`done`}),(0,B.jsx)(Q,{value:`cancelled`,children:`cancelled`})]})]}),(0,B.jsxs)(q,{orientation:`horizontal`,children:[(0,B.jsx)(Pc,{checked:t.enabled,onCheckedChange:t=>e.onDraftChange(e=>({...e,enabled:t}))}),(0,B.jsx)(Bo,{children:(0,B.jsx)(J,{children:`State`})})]})]}),(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Schedule`}),(0,B.jsxs)(ds,{value:t.scheduleKind,onChange:t=>e.onDraftChange(e=>{let n=nu(Bh,t.target.value,e.scheduleKind);return{...e,scheduleKind:n,boardStatus:n===`one_shot`?`backlog`:e.boardStatus}}),children:[(0,B.jsx)(Q,{value:`cron`,children:`cron`}),(0,B.jsx)(Q,{value:`every`,children:`every`}),(0,B.jsx)(Q,{value:`at`,children:`at`}),(0,B.jsx)(Q,{value:`one_shot`,children:`one shot`})]})]}),t.scheduleKind===`one_shot`?null:(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Timezone`}),(0,B.jsx)(Y,{value:t.scheduleTz,onChange:t=>e.onDraftChange(e=>({...e,scheduleTz:t.target.value})),placeholder:`Europe/Berlin`})]})]}),t.scheduleKind===`cron`?(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Cron`}),(0,B.jsx)(Y,{value:t.scheduleExpr,onChange:t=>e.onDraftChange(e=>({...e,scheduleExpr:t.target.value})),placeholder:`0 * * * *`})]}):null,t.scheduleKind===`every`?(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Every ms`}),(0,B.jsx)(jc,{integer:!0,min:1,value:t.scheduleEveryMs,onValueChange:t=>e.onDraftChange(e=>({...e,scheduleEveryMs:t})),placeholder:`60000`}),(0,B.jsx)(Wo,{})]}):null,t.scheduleKind===`at`?(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Run at`}),(0,B.jsx)(Rh,{required:!0,value:t.scheduleAt,onValueChange:t=>e.onDraftChange(e=>({...e,scheduleAt:t}))}),(0,B.jsx)(Wo,{})]}):null,t.scheduleKind===`one_shot`?(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Retries after failure`}),(0,B.jsx)(jc,{integer:!0,min:0,max:100,value:t.maxRetries,onValueChange:t=>e.onDraftChange(e=>({...e,maxRetries:t})),placeholder:`3`}),(0,B.jsx)(Wo,{})]}):null,(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Action`}),(0,B.jsxs)(ds,{value:t.actionKind,onChange:t=>e.onDraftChange(e=>({...e,actionKind:nu(Vh,t.target.value,e.actionKind)})),children:[(0,B.jsx)(Q,{value:`agent_turn`,children:`agent_turn`}),(0,B.jsx)(Q,{value:`system_event`,children:`system_event`})]})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Delivery`}),(0,B.jsxs)(ds,{value:t.deliveryKind,onChange:t=>e.onDraftChange(e=>({...e,deliveryKind:nu(Hh,t.target.value,e.deliveryKind)})),children:[(0,B.jsx)(Q,{value:`channel`,children:`channel`}),(0,B.jsx)(Q,{value:`last-channel`,children:`last-channel`}),(0,B.jsx)(Q,{value:`webhook`,children:`webhook`})]})]})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Message`}),(0,B.jsx)(Jo,{rows:4,value:t.actionMessage,onChange:t=>e.onDraftChange(e=>({...e,actionMessage:t.target.value})),placeholder:`Prompt or system-event message`})]}),t.deliveryKind===`channel`?(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Channel type`}),(0,B.jsx)(ds,{value:t.deliveryChannel,onChange:t=>e.onDraftChange(e=>({...e,deliveryChannel:t.target.value,deliveryTo:``})),children:e.channelOptions.map(e=>(0,B.jsx)(Q,{value:e.value,children:e.label},e.value))})]}),e.targetControl.kind===`select`?(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:e.targetControl.label}),(0,B.jsx)(Fh,{value:e.targetControl.value,onValueChange:t=>e.onDraftChange(e=>({...e,deliveryTo:t})),options:e.targetControl.options})]}):null,e.targetControl.kind===`input`?(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:e.targetControl.label}),(0,B.jsx)(Y,{value:e.targetControl.value,onChange:t=>e.onDraftChange(e=>({...e,deliveryTo:t.target.value})),placeholder:e.targetControl.placeholder})]}):null]}):null,t.deliveryKind===`webhook`?(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Webhook URL`}),(0,B.jsx)(Y,{type:`url`,value:t.deliveryWebhookUrl,onChange:t=>e.onDraftChange(e=>({...e,deliveryWebhookUrl:t.target.value})),placeholder:`https://example.test/hook`})]}):null,n?(0,B.jsxs)(`div`,{className:`key-value-grid`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Next run`}),(0,B.jsx)(`strong`,{children:Qa(n.nextRunAt)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Last run`}),(0,B.jsx)(`strong`,{children:Qa(n.lastRun)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Last status`}),(0,B.jsx)(`strong`,{children:n.lastStatus||`n/a`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Errors`}),(0,B.jsx)(`strong`,{children:n.consecutiveErrors})]})]}):null,(0,B.jsxs)(`div`,{className:`button-row`,children:[(0,B.jsx)(Z,{type:`button`,loading:e.savePending,disabled:e.saveDisabled,onClick:e.onSave,children:e.savePending?`Saving...`:`Save job`}),(0,B.jsx)(Z,{variant:`ghost`,type:`button`,disabled:e.savePending,onClick:e.onCancel,children:`Cancel`}),n?(0,B.jsx)(Z,{variant:`ghost`,type:`button`,disabled:e.pausePending,onClick:e.onPauseToggle,children:e.pausePending?`Updating...`:n.disabled?`Resume job`:`Pause job`}):null,n?(0,B.jsx)(Z,{variant:`danger`,type:`button`,loading:e.deletePending,disabled:e.deletePending,onClick:e.onDelete,children:e.deletePending?`Deleting...`:`Delete job`}):null]})]})})]})})}function lg(){let e=Gn(),t=j(),n=ee({strict:!1}),r=hs(),i=o(),a=n.jobId?.trim()||null,s=(0,R.useCallback)(e=>{t({to:`/admin/scheduler`,replace:!0,search:{jobId:e||void 0}}).catch(Os)},[t]),[c,l]=(0,R.useState)(Xh()),u=Dc(),d=y({queryKey:[`scheduler`,e.token],queryFn:()=>Jt(e.token)}),f=y({queryKey:[`config`,e.token],queryFn:()=>Mt(e.token)}),p=y({queryKey:[`channels`,e.token],queryFn:()=>jt(e.token)}),m=d.data?.jobs.find(e=>e.id===a)||null,h=Uh(m)?m:null,_=Zh({config:f.data?.config,status:e.gatewayStatus,currentChannel:c.deliveryChannel}),v=tg({channel:c.deliveryChannel,currentValue:c.deliveryTo,channels:p.data}),b=Fc({mutationFn:t=>Yt(e.token,ag(t)),onSuccess:n=>{og(n,e.token,i),t({to:`/admin/jobs`}).catch(Os)},onError:e=>{r.error(`Save failed`,e.message)},invalidates:[[`overview`]]}),x=b.isPending||!u.isValid,S=g({mutationFn:()=>{if(!m)throw Error(`Select a scheduler item first.`);return Xt(e.token,m)},onSuccess:t=>{og(t,e.token,i),r.success(`Deleted.`),s(null),l(Xh())},onError:e=>{r.error(`Delete failed`,H(e))}}),C=g({mutationFn:t=>{if(!m)throw Error(`Select a scheduler item first.`);return m.source===`task`?Zt(e.token,{source:`task`,taskId:m.taskId??0,action:t}):Zt(e.token,{source:`job`,jobId:m.id,action:t})},onSuccess:(t,n)=>{if(og(t,e.token,i),r.success(n===`pause`?`Paused.`:`Resumed.`),!m)return;let a=t.jobs.find(e=>e.id===m.id)||null;if(!a){s(null),l(Xh());return}Uh(a)&&l(Xh(a))},onError:e=>{r.error(`Pause/resume failed`,H(e))}});return(0,R.useEffect)(()=>{if(h){l(Xh(h));return}a||l(Xh())},[h,a]),(0,R.useEffect)(()=>{!a||d.isLoading||m||s(null)},[d.isLoading,a,m,s]),(0,B.jsxs)(`div`,{className:`page-stack`,children:[(0,B.jsx)(Ha,{actions:(0,B.jsx)(Z,{variant:`ghost`,type:`button`,onClick:()=>{s(null),l(Xh())},children:`New job`})}),(0,B.jsxs)(`div`,{className:`two-column-grid`,children:[(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:`Jobs`}),(0,B.jsx)(uo,{children:`${d.data?.jobs.length||0} item${d.data?.jobs.length===1?``:`s`}`})]}),(0,B.jsx)(K,{children:d.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading scheduler items...`}):d.data?.jobs.length?(0,B.jsx)(`div`,{className:`list-stack selectable-list`,children:d.data.jobs.map(e=>(0,B.jsxs)(`button`,{className:e.id===a?`selectable-row active`:`selectable-row`,type:`button`,onClick:()=>s(e.id),children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:e.name}),(0,B.jsx)(`small`,{children:qh(e)})]}),(0,B.jsxs)(`div`,{className:`row-status-stack`,children:[(0,B.jsx)(Ga,{value:e.enabled&&!e.disabled,trueLabel:`active`,falseLabel:`inactive`}),(0,B.jsx)(`small`,{children:Jh(e)})]})]},e.id))}):(0,B.jsx)(`div`,{className:`empty-state`,children:`No scheduled work yet.`})})]}),Wh(m)?(0,B.jsx)(sg,{job:m,pausePending:C.isPending,deletePending:S.isPending,onPauseToggle:()=>C.mutate(m.disabled?`resume`:`pause`),onDelete:()=>S.mutate()}):(0,B.jsx)(cg,{draft:c,selectedJob:h,channelOptions:_,targetControl:v,savePending:b.isPending,pausePending:C.isPending,deletePending:S.isPending,saveDisabled:x,onDraftChange:e=>l(t=>e(t)),form:u,onSave:()=>{let e=ig(ng(c,v));l(e),b.mutate(e)},onCancel:()=>{if(h){l(Xh(h));return}s(null),l(Xh()),t({to:`/admin/jobs`}).catch(Os)},onPauseToggle:()=>C.mutate(h?.disabled?`resume`:`pause`),onDelete:()=>S.mutate()})]})]})}var ug={section:`_section_1dqd9_1`,sectionHead:`_sectionHead_1dqd9_7`,sectionTitle:`_sectionTitle_1dqd9_13`,count:`_count_1dqd9_23`,caption:`_caption_1dqd9_30`,name:`_name_1dqd9_36`,fingerprint:`_fingerprint_1dqd9_42`,actionsHead:`_actionsHead_1dqd9_47`,actions:`_actions_1dqd9_47`,overwriteForm:`_overwriteForm_1dqd9_57`,overwriteNote:`_overwriteNote_1dqd9_63`};function dg(e){return e.length===null?`—`:`${e.length} bytes`}function fg(e){return e.fingerprint?`sha256:${e.fingerprint.sha256_prefix}`:`—`}function pg(e){return e?Za(e):`never`}function mg(){let{token:e}=Gn(),t=hs(),n=o(),[r,i]=(0,R.useState)(null),[a,s]=(0,R.useState)(null),[c,l]=(0,R.useState)(``),u=y({queryKey:[`admin`,`secrets`,e],queryFn:()=>Ut(e),retry:!1}),d=(0,R.useCallback)(()=>n.invalidateQueries({queryKey:[`admin`,`secrets`]}),[n]),f=g({mutationFn:t=>Wt(e,t.name,t.value),onSuccess:async(e,n)=>{t.success(n.wasSet?`Rotated ${n.name}.`:`Set ${n.name}.`),i(null),await d()},onError:e=>{t.error(`Overwrite failed: ${H(e)}`)}}),p=g({mutationFn:t=>Gt(e,t),onSuccess:async(e,n)=>{t.success(`Removed ${n}.`),s(null),await d()},onError:e=>{t.error(`Unset failed: ${H(e)}`)}}),m=u.data,h=(0,R.useMemo)(()=>{if(!m)return null;let e=c.trim().toLowerCase(),t=m.secrets.filter(e=>e.state===`set`),n=m.secrets.filter(e=>e.state===`unset`),r=t=>e===``||t.name.toLowerCase().includes(e);return{setAll:t,unsetAll:n,setEntries:t.filter(r),unsetEntries:n.filter(r)}},[m,c]);if(u.isPending)return(0,B.jsxs)(`div`,{className:`page-stack`,children:[(0,B.jsx)(Ha,{description:`Runtime secret store`}),(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading the runtime secret store…`})]});if(u.isError||!h){let e=u.error instanceof we&&u.error.status===403;return(0,B.jsxs)(`div`,{className:`page-stack`,children:[(0,B.jsx)(Ha,{description:`Runtime secret store`}),(0,B.jsx)(`div`,{className:`empty-state`,children:e?`You do not have permission to view secret metadata.`:`Failed to load secrets: ${H(u.error)}`})]})}let _=m?.actions.includes(`secret.overwrite`)??!1,v=m?.actions.includes(`secret.unset`)??!1,b=_||v;return(0,B.jsxs)(`div`,{className:`page-stack`,children:[(0,B.jsx)(Ha,{description:`Runtime credential store. Values are write-only — set or rotate them here; they are never read back to the browser.`,actions:(0,B.jsx)(`input`,{className:`compact-search`,value:c,onChange:e=>l(e.target.value),placeholder:`Filter secrets`,"aria-label":`Filter secrets by name`})}),(0,B.jsxs)(`section`,{className:ug.section,"aria-label":`Set`,children:[(0,B.jsxs)(`div`,{className:ug.sectionHead,children:[(0,B.jsxs)(`h2`,{className:ug.sectionTitle,children:[`Set `,(0,B.jsx)(`span`,{className:ug.count,children:h.setAll.length})]}),(0,B.jsx)(`p`,{className:ug.caption,children:`Stored values, shown only as metadata — length and a SHA-256 fingerprint, never the value itself.`})]}),h.setEntries.length===0?(0,B.jsx)(`div`,{className:`empty-state`,children:h.setAll.length===0?`No secrets are currently set.`:`No set secrets match this filter.`}):(0,B.jsx)(`div`,{className:`table-shell`,children:(0,B.jsxs)(`table`,{children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{children:`Name`}),(0,B.jsx)(`th`,{children:`Length`}),(0,B.jsx)(`th`,{children:`Fingerprint`}),(0,B.jsx)(`th`,{children:`Last rotated`}),b?(0,B.jsx)(`th`,{className:ug.actionsHead,children:`Actions`}):null]})}),(0,B.jsx)(`tbody`,{children:h.setEntries.map(e=>(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`td`,{children:(0,B.jsx)(`strong`,{className:ug.name,children:e.name})}),(0,B.jsx)(`td`,{children:dg(e)}),(0,B.jsx)(`td`,{children:(0,B.jsx)(`code`,{className:ug.fingerprint,children:fg(e)})}),(0,B.jsx)(`td`,{title:e.last_rotated_at??void 0,children:pg(e.last_rotated_at)}),b?(0,B.jsx)(`td`,{children:(0,B.jsxs)(`div`,{className:ug.actions,children:[_?(0,B.jsx)(Z,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>i(e.name),children:`Rotate`}):null,v?(0,B.jsx)(Z,{type:`button`,variant:`danger`,size:`sm`,onClick:()=>s(e.name),children:`Unset`}):null]})}):null]},e.name))})]})})]}),(0,B.jsxs)(`section`,{className:ug.section,"aria-label":`Declared but unset`,children:[(0,B.jsxs)(`div`,{className:ug.sectionHead,children:[(0,B.jsxs)(`h2`,{className:ug.sectionTitle,children:[`Declared but unset`,` `,(0,B.jsx)(`span`,{className:ug.count,children:h.unsetAll.length})]}),(0,B.jsx)(`p`,{className:ug.caption,children:`Referenced by a skill, connector, or provider, with no value yet.`})]}),h.unsetEntries.length===0?(0,B.jsx)(`div`,{className:`empty-state`,children:h.unsetAll.length===0?`No declared-but-unset secrets.`:`No declared secrets match this filter.`}):(0,B.jsx)(`div`,{className:`table-shell`,children:(0,B.jsxs)(`table`,{children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{children:`Name`}),_?(0,B.jsx)(`th`,{className:ug.actionsHead,children:`Actions`}):null]})}),(0,B.jsx)(`tbody`,{children:h.unsetEntries.map(e=>(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`td`,{children:(0,B.jsx)(`strong`,{className:ug.name,children:e.name})}),_?(0,B.jsx)(`td`,{children:(0,B.jsx)(`div`,{className:ug.actions,children:(0,B.jsx)(Z,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>i(e.name),children:`Set`})})}):null]},e.name))})]})})]}),(0,B.jsx)(hg,{name:r,onClose:()=>i(null),pending:f.isPending,onSubmit:e=>{if(!r)return;let t=h.setAll.some(e=>e.name===r);f.mutate({name:r,value:e,wasSet:t})}}),(0,B.jsx)(gg,{name:a,onClose:()=>s(null),pending:p.isPending,onConfirm:()=>{a&&p.mutate(a)}})]})}function hg(e){let t=e.name!==null,n=(0,R.useRef)(null),r=(0,R.useId)(),i=(0,R.useId)();return(0,B.jsx)(ri,{open:t,onOpenChange:t=>{t||(n.current&&(n.current.value=``),e.onClose())},children:(0,B.jsxs)(ii,{role:`dialog`,size:`default`,preventCloseOnOutsideClick:e.pending,children:[(0,B.jsxs)(ai,{children:[(0,B.jsxs)(oi,{children:[`Set value for `,(0,B.jsx)(`code`,{children:e.name})]}),(0,B.jsx)(si,{children:`The new value is sent to the gateway and immediately discarded from this form. There is no way to read the stored value back.`})]}),(0,B.jsxs)(`form`,{className:ug.overwriteForm,onSubmit:t=>{t.preventDefault();let r=n.current;if(!r)return;let i=r.value;i.trim()&&e.onSubmit(i)},children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{htmlFor:r,children:`New value`}),(0,B.jsx)(Y,{id:r,ref:n,type:`password`,autoComplete:`new-password`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,required:!0,"aria-describedby":i,disabled:e.pending}),(0,B.jsx)(`p`,{id:i,className:ug.overwriteNote,children:`Pasted value is not echoed. Once submitted, the value lives only in the runtime secret store; this page cannot show it again.`})]}),(0,B.jsxs)(ci,{children:[(0,B.jsx)(li,{className:`ghost-button`,disabled:e.pending,children:`Cancel`}),(0,B.jsx)(Z,{type:`submit`,disabled:e.pending,children:e.pending?`Saving…`:`Save value`})]})]})]})})}function gg(e){return(0,B.jsx)(ri,{open:e.name!==null,onOpenChange:t=>{t||e.onClose()},children:(0,B.jsxs)(ii,{role:`alertdialog`,size:`default`,preventCloseOnOutsideClick:e.pending,children:[(0,B.jsxs)(ai,{children:[(0,B.jsxs)(oi,{children:[`Unset `,(0,B.jsx)(`code`,{children:e.name}),`?`]}),(0,B.jsx)(si,{children:`The stored value will be removed from the runtime secret store. Skills or connectors that depend on this secret will fail their preflight checks until a new value is set.`})]}),(0,B.jsxs)(ci,{children:[(0,B.jsx)(li,{className:`ghost-button`,disabled:e.pending,children:`Cancel`}),(0,B.jsx)(Z,{type:`button`,variant:`danger`,disabled:e.pending,onClick:e.onConfirm,children:e.pending?`Removing…`:`Unset secret`})]})]})})}function _g(){let e=Gn(),t=o(),n=hs(),r=j(),i=ee({strict:!1}).sessionId?.trim()||null,a=(0,R.useRef)(i),[s,c]=(0,R.useState)(``),[l,u]=(0,R.useState)(()=>i),[d,f]=(0,R.useState)(!1),p=(0,R.useDeferredValue)(s),m=y({queryKey:[`sessions`,e.token],queryFn:()=>Tt(e.token)}),h=g({mutationFn:t=>At(e.token,t),onSuccess:(e,i)=>{t.invalidateQueries({queryKey:[`sessions`]}),t.invalidateQueries({queryKey:[`overview`]}),n.success(`Session deleted`,`Removed ${e.deletedMessages} messages and ${e.deletedTasks} tasks.`),l===i&&(u(null),r({to:`/admin/sessions`,replace:!0,search:{sessionId:void 0}}).catch(Os))},onError:e=>{n.error(`Delete failed`,H(e))}}),_=(m.data||[]).filter(e=>[e.id,e.channelId,e.guildId||``,e.effectiveModel,e.summary||``].join(` `).toLowerCase().includes(p.trim().toLowerCase())),v=_.find(e=>e.id===l)||_[0]||null;(0,R.useEffect)(()=>{v&&v.id!==l&&u(v.id)},[l,v]),(0,R.useEffect)(()=>{i!==a.current&&(a.current=i,i&&i!==l&&u(i))},[i,l]);function b(e){u(e),r({to:`/admin/sessions`,replace:!0,search:{sessionId:e}}).catch(Os)}return(0,B.jsxs)(`div`,{className:`page-stack`,children:[(0,B.jsx)(Ha,{actions:(0,B.jsx)(`input`,{className:`compact-search`,value:s,onChange:e=>c(e.target.value),placeholder:`Filter by session, channel, model`})}),(0,B.jsxs)(`div`,{className:`two-column-grid sessions-layout`,children:[(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:`Session list`}),(0,B.jsx)(uo,{children:`${_.length} result${_.length===1?``:`s`}`})]}),(0,B.jsx)(K,{children:m.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading sessions...`}):_.length===0?(0,B.jsx)(`div`,{className:`empty-state`,children:`No sessions match this filter.`}):(0,B.jsx)(`div`,{className:`list-stack selectable-list`,children:_.map(e=>(0,B.jsxs)(`button`,{className:e.id===v?.id?`selectable-row active`:`selectable-row`,type:`button`,onClick:()=>b(e.id),children:[(0,B.jsxs)(`div`,{className:`session-row-main`,children:[(0,B.jsx)(`strong`,{children:e.id}),(0,B.jsxs)(`small`,{className:`session-row-meta`,children:[e.channelId,` · `,e.effectiveModel]})]}),(0,B.jsx)(`span`,{className:`session-row-time`,children:Za(e.lastActive)})]},e.id))})})]}),(0,B.jsxs)(U,{variant:`muted`,children:[(0,B.jsx)(W,{children:(0,B.jsx)(G,{children:`Inspection`})}),(0,B.jsx)(K,{children:v?(0,B.jsxs)(`div`,{className:`detail-stack`,children:[(0,B.jsxs)(`div`,{className:`key-value-grid`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Session`}),(0,B.jsx)(`strong`,{children:v.id})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Channel`}),(0,B.jsx)(`strong`,{children:v.channelId})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Guild`}),(0,B.jsx)(`strong`,{children:v.guildId||`direct/web`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Model`}),(0,B.jsx)(`strong`,{children:v.effectiveModel})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Messages`}),(0,B.jsx)(`strong`,{children:v.messageCount})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Scheduled tasks`}),(0,B.jsx)(`strong`,{children:v.taskCount})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`RAG`}),(0,B.jsx)(Ga,{value:v.ragEnabled,trueLabel:`on`,falseLabel:`off`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`Last active`}),(0,B.jsx)(`strong`,{children:Za(v.lastActive)})]})]}),(0,B.jsxs)(`div`,{className:`summary-block`,children:[(0,B.jsx)(`span`,{children:`Summary`}),(0,B.jsx)(`p`,{children:v.summary||`No summary stored for this session.`})]}),(0,B.jsx)(`button`,{className:`danger-button`,type:`button`,disabled:h.isPending,onClick:()=>f(!0),children:h.isPending?`Deleting...`:`Delete session`})]}):(0,B.jsx)(`div`,{className:`empty-state`,children:`Select a session to inspect it.`})})]})]}),(0,B.jsx)(ri,{open:d,onOpenChange:f,children:(0,B.jsxs)(ii,{size:`sm`,role:`alertdialog`,children:[(0,B.jsxs)(ai,{children:[(0,B.jsx)(oi,{children:`Delete session?`}),(0,B.jsx)(si,{children:`This will permanently remove the session and all associated audit events.`})]}),(0,B.jsxs)(ci,{children:[(0,B.jsx)(li,{className:`ghost-button`,children:`Cancel`}),(0,B.jsx)(li,{className:`danger-button`,onClick:()=>{v&&h.mutate(v.id)},children:`Delete`})]})]})})]})}function vg(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var yg=vg();function bg(e){yg=e}var xg={exec:()=>null};function Sg(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(wg.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Cg=(()=>{try{return!0}catch{return!1}})(),wg={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`),blockquoteBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}>`)},Tg=/^(?:[ \t]*(?:\n|$))+/,Eg=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Dg=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Og=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,kg=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Ag=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,jg=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Mg=Sg(jg).replace(/bull/g,Ag).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),Ng=Sg(jg).replace(/bull/g,Ag).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Pg=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Fg=/^[^\n]+/,Ig=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Lg=Sg(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,Ig).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Rg=Sg(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Ag).getRegex(),zg=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,Bg=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Vg=Sg(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Bg).replace(`tag`,zg).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Hg=Sg(Pg).replace(`hr`,Og).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,zg).getRegex(),Ug={blockquote:Sg(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Hg).getRegex(),code:Eg,def:Lg,fences:Dg,heading:kg,hr:Og,html:Vg,lheading:Mg,list:Rg,newline:Tg,paragraph:Hg,table:xg,text:Fg},Wg=Sg(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,Og).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,zg).getRegex(),Gg={...Ug,lheading:Ng,table:Wg,paragraph:Sg(Pg).replace(`hr`,Og).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,Wg).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,zg).getRegex()},Kg={...Ug,html:Sg(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Bg).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:xg,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Sg(Pg).replace(`hr`,Og).replace(`heading`,` *#{1,6} *[^
|
|
73
73
|
]`).replace(`lheading`,Mg).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},qg=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Jg=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Yg=/^( {2,}|\\)\n(?!\s*$)/,Xg=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Zg=/[\p{P}\p{S}]/u,Qg=/[\s\p{P}\p{S}]/u,$g=/[^\s\p{P}\p{S}]/u,e_=Sg(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,Qg).getRegex(),t_=/(?!~)[\p{P}\p{S}]/u,n_=/(?!~)[\s\p{P}\p{S}]/u,r_=/(?:[^\s\p{P}\p{S}]|~)/u,i_=/(?![*_])[\p{P}\p{S}]/u,a_=/(?![*_])[\s\p{P}\p{S}]/u,o_=/(?:[^\s\p{P}\p{S}]|[*_])/u,s_=Sg(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,Cg?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),c_=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,l_=Sg(c_,`u`).replace(/punct/g,Zg).getRegex(),u_=Sg(c_,`u`).replace(/punct/g,t_).getRegex(),d_=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,f_=Sg(d_,`gu`).replace(/notPunctSpace/g,$g).replace(/punctSpace/g,Qg).replace(/punct/g,Zg).getRegex(),p_=Sg(d_,`gu`).replace(/notPunctSpace/g,r_).replace(/punctSpace/g,n_).replace(/punct/g,t_).getRegex(),m_=Sg(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,$g).replace(/punctSpace/g,Qg).replace(/punct/g,Zg).getRegex(),h_=Sg(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,i_).getRegex(),g_=Sg(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,o_).replace(/punctSpace/g,a_).replace(/punct/g,i_).getRegex(),__=Sg(/\\(punct)/,`gu`).replace(/punct/g,Zg).getRegex(),v_=Sg(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),y_=Sg(Bg).replace(`(?:-->|$)`,`-->`).getRegex(),b_=Sg(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,y_).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),x_=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,S_=Sg(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,x_).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),C_=Sg(/^!?\[(label)\]\[(ref)\]/).replace(`label`,x_).replace(`ref`,Ig).getRegex(),w_=Sg(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Ig).getRegex(),T_=Sg(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,C_).replace(`nolink`,w_).getRegex(),E_=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,D_={_backpedal:xg,anyPunctuation:__,autolink:v_,blockSkip:s_,br:Yg,code:Jg,del:xg,delLDelim:xg,delRDelim:xg,emStrongLDelim:l_,emStrongRDelimAst:f_,emStrongRDelimUnd:m_,escape:qg,link:S_,nolink:w_,punctuation:e_,reflink:C_,reflinkSearch:T_,tag:b_,text:Xg,url:xg},O_={...D_,link:Sg(/^!?\[(label)\]\((.*?)\)/).replace(`label`,x_).getRegex(),reflink:Sg(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,x_).getRegex()},k_={...D_,emStrongRDelimAst:p_,emStrongLDelim:u_,delLDelim:h_,delRDelim:g_,url:Sg(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,E_).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:Sg(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,E_).getRegex()},A_={...k_,br:Sg(Yg).replace(`{2,}`,`*`).getRegex(),text:Sg(k_.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},j_={normal:Ug,gfm:Gg,pedantic:Kg},M_={normal:D_,gfm:k_,breaks:A_,pedantic:O_},N_={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},P_=e=>N_[e];function F_(e,t){if(t){if(wg.escapeTest.test(e))return e.replace(wg.escapeReplace,P_)}else if(wg.escapeTestNoEncode.test(e))return e.replace(wg.escapeReplaceNoEncode,P_);return e}function I_(e){try{e=encodeURI(e).replace(wg.percentDecode,`%`)}catch{return null}return e}function L_(e,t){let n=e.replace(wg.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(wg.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``);for(;r<n.length;r++)n[r]=n[r].trim().replace(wg.slashPipe,`|`);return n}function R_(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function z_(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function B_(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function V_(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function H_(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
74
74
|
`).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(`
|
|
75
75
|
`)}var U_=class{options;rules;lexer;constructor(e){this.options=e||yg}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,``);return{type:`code`,raw:t[0],codeBlockStyle:`indented`,text:this.options.pedantic?e:R_(e,`
|
|
@@ -171,4 +171,4 @@ Use this skill when the user asks to ...
|
|
|
171
171
|
1. ...
|
|
172
172
|
2. ...`})]}),(0,B.jsxs)(`div`,{className:`panel-header`,style:{marginTop:`0.5rem`},children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h4`,{children:`Files`}),(0,B.jsx)(`p`,{className:`supporting-text`,children:`Add scripts or references (e.g. scripts/run.mjs, references/guide.md)`})]}),(0,B.jsx)(Z,{variant:`ghost`,type:`button`,onClick:()=>h(e=>({...e,files:[...e.files,{id:Qb++,path:`scripts/new-file.mjs`,content:``}]})),children:`Add file`})]}),m.files.map((e,t)=>(0,B.jsxs)(`div`,{className:`stack-form`,style:{gap:`0.25rem`},children:[(0,B.jsxs)(`div`,{className:`field-grid`,children:[(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Path`}),(0,B.jsx)(Y,{value:e.path,onChange:e=>h(n=>{let r=[...n.files];return r[t]={...r[t],path:e.target.value},{...n,files:r}}),placeholder:`scripts/my-tool.mjs`})]}),(0,B.jsx)(Z,{variant:`danger`,type:`button`,style:{alignSelf:`end`},onClick:()=>h(e=>({...e,files:e.files.filter((e,n)=>n!==t)})),children:`Remove`})]}),(0,B.jsxs)(q,{children:[(0,B.jsx)(J,{children:`Content`}),(0,B.jsx)(Jo,{rows:8,value:e.content,onChange:e=>h(n=>{let r=[...n.files];return r[t]={...r[t],content:e.target.value},{...n,files:r}}),placeholder:`// Script content...`,style:{fontFamily:`monospace`,fontSize:`0.85rem`}})]})]},e.id)),(0,B.jsx)(`div`,{className:`button-row`,children:(0,B.jsx)(Z,{type:`button`,loading:A.isPending,disabled:A.isPending||!m.name.trim()||!m.description.trim()||!m.category.trim(),onClick:()=>A.mutate(),children:A.isPending?`Creating...`:`Create skill`})})]})]})]}):null,(0,B.jsxs)(`div`,{className:`metric-grid`,children:[(0,B.jsx)(Ua,{label:`Installed skills`,value:String(C.data?.skills.length??0),detail:`${C.data?.disabled.length??0} disabled${le>0?` · ${le} blocked`:``}`,loading:!C.data}),(0,B.jsx)(Ua,{label:`Observed skills`,value:String(M.length),detail:`from AdaptiveSkills observations`,href:`#observed-skill-health`}),(0,B.jsx)(Ua,{label:`Degraded skills`,value:String(ce),detail:`current inspection window`}),(0,B.jsx)(Ua,{label:`Staged amendments`,value:String(N.length),detail:`awaiting human review`,href:`#staged-amendments`})]}),(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:`Installed skills`}),(0,B.jsx)(uo,{children:`${ne.length} skill${ne.length===1?``:`s`} visible`}),(0,B.jsx)(fo,{children:(0,B.jsxs)(`label`,{className:`skills-enabled-filter`,children:[(0,B.jsx)(Pc,{checked:a,"aria-label":`Show enabled skills only`,size:`sm`,onCheckedChange:s}),(0,B.jsx)(`span`,{children:`Enabled only`})]})})]}),(0,B.jsx)(K,{children:C.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading skill catalog...`}):(0,B.jsx)(`div`,{className:`table-shell`,children:(0,B.jsxs)(`table`,{children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(Va,{label:`Skill`,sortKey:`skill`,sortState:re,onToggle:ie}),(0,B.jsx)(Va,{label:`Category`,sortKey:`category`,sortState:re,onToggle:ie}),(0,B.jsx)(Va,{label:`Source`,sortKey:`source`,sortState:re,onToggle:ie}),(0,B.jsx)(Va,{label:`Health`,sortKey:`health`,sortState:re,onToggle:ie}),(0,B.jsx)(Va,{label:`Tags`,sortKey:`tags`,sortState:re,onToggle:ie}),(0,B.jsx)(Va,{label:`Action`,sortKey:`action`,sortState:re,onToggle:ie})]})}),(0,B.jsxs)(`tbody`,{children:[ne.map(({skill:e,metrics:t})=>{let n=t?zb(t):null,r=e.shortDescription?.trim()||Bb(e.description),i=e.guardFindings?.[0],a=O.isPending&&O.variables===e.name;return(0,B.jsxs)(`tr`,{children:[(0,B.jsxs)(`td`,{children:[(0,B.jsx)(D,{className:`table-link-button`,to:pb(e.name),children:e.name}),(0,B.jsx)(`small`,{children:r}),e.blocked&&i?(0,B.jsxs)(`small`,{className:`row-status-note-danger`,children:[i.severity,`/`,i.category,`:`,` `,i.description]}):null]}),(0,B.jsx)(`td`,{children:e.category}),(0,B.jsx)(`td`,{children:e.source}),(0,B.jsx)(`td`,{children:t?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Ga,{value:!t.degraded,trueLabel:`healthy`,falseLabel:`degraded`,falseTone:`danger`}),(0,B.jsxs)(`small`,{children:[t.total_executions,` runs`,t.degraded||!n?``:` · `,t.degraded?`${Ya(t.success_rate)} full success`:n]})]}):null}),(0,B.jsx)(`td`,{children:e.tags.join(`, `)||`none`}),(0,B.jsx)(`td`,{children:(0,B.jsx)(`div`,{className:`row-status-stack`,children:e.blocked?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`skill-blocked-badge`,role:`status`,"aria-label":`${e.name} is blocked`,title:e.blockedReason||`guarded`,children:`blocked`}),(0,B.jsx)(`small`,{className:`row-status-note-danger`,children:e.blockedReason||`guarded`}),(0,B.jsx)(`button`,{type:`button`,className:`skill-unblock-button`,disabled:O.isPending,onClick:()=>O.mutate(e.name),children:a?`Unblocking...`:`Unblock`})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Pc,{checked:e.enabled,"aria-label":`${e.name} status`,disabled:E.isPending||!e.available&&!e.enabled,onCheckedChange:t=>{t&&!e.available||E.mutate({name:e.name,enabled:t})}}),e.available?null:(0,B.jsx)(`small`,{className:`row-status-note-danger`,children:e.missing.join(`, `)||`missing requirements`})]})})})]},e.name)}),ne.length===0?(0,B.jsx)(`tr`,{children:(0,B.jsx)(`td`,{colSpan:6,children:(0,B.jsx)(`div`,{className:`empty-state`,children:`No skills match this filter.`})})}):null]})]})})})]}),(0,B.jsxs)(U,{id:`observed-skill-health`,children:[(0,B.jsx)(W,{children:(0,B.jsx)(G,{children:`Observed skill health`})}),(0,B.jsx)(K,{children:w.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading AdaptiveSkills health...`}):ae.length===0?(0,B.jsx)(`div`,{className:`empty-state`,children:`No observed skills match this filter.`}):(0,B.jsx)(`div`,{className:`table-shell`,children:(0,B.jsxs)(`table`,{children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(Va,{label:`Skill`,sortKey:`skill`,sortState:oe,onToggle:se}),(0,B.jsx)(Va,{label:`Status`,sortKey:`status`,sortState:oe,onToggle:se}),(0,B.jsx)(Va,{label:`Executions`,sortKey:`executions`,sortState:oe,onToggle:se}),(0,B.jsx)(Va,{label:`Full success`,sortKey:`success`,sortState:oe,onToggle:se}),(0,B.jsx)(Va,{label:`Partial success`,sortKey:`partial`,sortState:oe,onToggle:se}),(0,B.jsx)(Va,{label:`Failure`,sortKey:`failure`,sortState:oe,onToggle:se}),(0,B.jsx)(Va,{label:`Tool breakage`,sortKey:`toolBreakage`,sortState:oe,onToggle:se}),(0,B.jsx)(Va,{label:`Feedback`,sortKey:`feedback`,sortState:oe,onToggle:se}),(0,B.jsx)(Va,{label:`Reasons`,sortKey:`reasons`,sortState:oe,onToggle:se})]})}),(0,B.jsx)(`tbody`,{children:ae.map(e=>(0,B.jsxs)(`tr`,{children:[(0,B.jsxs)(`td`,{children:[(0,B.jsx)(D,{className:`table-link-button`,to:pb(e.skill_name),children:e.skill_name}),(0,B.jsxs)(`small`,{children:[`Window ending`,` `,Qa(e.window_ended_at)]})]}),(0,B.jsx)(`td`,{children:(0,B.jsx)(Ga,{value:!e.degraded,trueLabel:`healthy`,falseLabel:`degraded`,falseTone:`danger`})}),(0,B.jsx)(`td`,{children:e.total_executions}),(0,B.jsx)(`td`,{children:Jb(e,e.success_count)}),(0,B.jsx)(`td`,{children:Jb(e,e.partial_count)}),(0,B.jsx)(`td`,{children:Jb(e,e.failure_count)}),(0,B.jsx)(`td`,{children:Yb(e)}),(0,B.jsx)(`td`,{children:zb(e)||null}),(0,B.jsx)(`td`,{children:(0,B.jsx)(`small`,{children:e.degradation_reasons.join(`; `)||`healthy`})})]},e.skill_name))})]})})})]}),(0,B.jsxs)(`div`,{className:`two-column-grid skills-review-grid`,children:[(0,B.jsxs)(U,{id:`staged-amendments`,variant:`muted`,children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:`Staged amendments`}),(0,B.jsx)(uo,{children:`${N.length} waiting for review`})]}),(0,B.jsx)(K,{children:T.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading staged amendments...`}):N.length===0?(0,B.jsx)(`div`,{className:`empty-state`,children:`No staged amendments are waiting for review.`}):(0,B.jsx)(`div`,{className:`list-stack selectable-list`,children:N.map(e=>(0,B.jsxs)(`div`,{className:`list-row`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(D,{className:`table-link-button`,to:pb(e.skill_name),children:e.skill_name}),(0,B.jsxs)(`small`,{children:[Vb(e),` ·`,` `,Hb(e),` · guard`,` `,e.guard_verdict,`/`,e.guard_findings_count]}),(0,B.jsx)(`small`,{children:e.rationale||e.diff_summary})]}),(0,B.jsxs)(`div`,{className:`skill-review-actions`,children:[(0,B.jsx)(Z,{type:`button`,variant:`ghost`,onClick:()=>l(e.skill_name),children:`History`}),(0,B.jsx)(Z,{type:`button`,loading:k.isPending,disabled:k.isPending,onClick:()=>k.mutate({action:`apply`,skillName:e.skill_name}),children:`Apply`}),(0,B.jsx)(Z,{type:`button`,variant:`danger`,loading:k.isPending,disabled:k.isPending,onClick:()=>k.mutate({action:`reject`,skillName:e.skill_name}),children:`Reject`})]})]},e.id))})})]}),(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:I?`Amendment history: ${I}`:`Amendment history`}),(0,B.jsx)(uo,{children:`Full review trail for the selected skill`})]}),(0,B.jsx)(K,{children:I?ee.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading amendment history...`}):ue.length===0?(0,B.jsx)(`div`,{className:`empty-state`,children:`No amendment history exists for this skill yet.`}):(0,B.jsx)(`div`,{className:`list-stack selectable-list`,children:ue.map(e=>(0,B.jsxs)(`div`,{className:`list-row`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`strong`,{children:[Vb(e),` ·`,` `,Hb(e)]}),(0,B.jsxs)(`small`,{children:[`Guard `,e.guard_verdict,`/`,e.guard_findings_count,` · runs since apply`,` `,e.runs_since_apply]}),(0,B.jsx)(`small`,{children:e.rationale||`No rationale recorded.`}),(0,B.jsx)(`small`,{children:e.diff_summary||`No diff summary recorded.`})]}),(0,B.jsx)(`span`,{className:e.status===`applied`?`list-status list-status-success`:e.status===`rejected`?`list-status list-status-danger`:`list-status`,children:e.status})]},e.id))}):(0,B.jsx)(`div`,{className:`empty-state`,children:`Select a skill to inspect its amendment history.`})})]})]})]})}var tx=[{value:7,label:`Last 7 days`},{value:14,label:`Last 14 days`},{value:30,label:`Last 30 days`},{value:60,label:`Last 60 days`},{value:90,label:`Last 90 days`}];function nx(){let e=Gn(),[t,n]=(0,R.useState)(30),r=y({queryKey:[`statistics`,e.token,t],queryFn:()=>Re(e.token,t),refetchInterval:6e4}),i=r.data,a=i?.trend??[],o=i?.channels??[],s=i?.totals,c=(0,B.jsxs)(`label`,{className:`header-actions`,children:[(0,B.jsx)(`span`,{className:`supporting-text`,style:{marginRight:8},children:`Range`}),(0,B.jsx)(`select`,{value:t,onChange:e=>n(Number.parseInt(e.target.value,10)),children:tx.map(e=>(0,B.jsx)(`option`,{value:e.value,children:e.label},e.value))})]});if(r.isLoading&&!i)return(0,B.jsxs)(`div`,{className:`page-stack`,children:[(0,B.jsx)(Ha,{actions:c}),(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading statistics…`})]});if(r.isError&&!i)return(0,B.jsxs)(`div`,{className:`page-stack`,children:[(0,B.jsx)(Ha,{actions:c}),(0,B.jsx)(`div`,{className:`empty-state error`,children:H(r.error)})]});if(!i||!s)return(0,B.jsxs)(`div`,{className:`page-stack`,children:[(0,B.jsx)(Ha,{actions:c}),(0,B.jsx)(`div`,{className:`empty-state`,children:`No statistics available.`})]});let l=`${i.startDate} → ${i.endDate}`;return(0,B.jsxs)(`div`,{className:`page-stack`,children:[(0,B.jsx)(Ha,{description:`Activity across the last ${eo(i.rangeDays,`day`)} (${l}).`,actions:c}),(0,B.jsxs)(`div`,{className:`metric-grid`,children:[(0,B.jsx)(Ua,{label:`Active sessions`,value:Ka(s.activeSessions),detail:`${s.newSessions} new in range`}),(0,B.jsx)(Ua,{label:`Messages`,value:Ka(s.totalMessages),detail:`${Ka(s.userMessages)} user / ${Ka(s.assistantMessages)} assistant`}),(0,B.jsx)(Ua,{label:`Tokens`,value:Ka(s.totalTokens),detail:Ja({inputTokens:s.totalInputTokens,outputTokens:s.totalOutputTokens})}),(0,B.jsx)(Ua,{label:`Cost`,value:Xa(s.totalCostUsd),detail:`${eo(s.callCount,`call`)} · ${eo(s.totalToolCalls,`tool call`)}`})]}),(0,B.jsxs)(`div`,{className:`two-column-grid`,children:[(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:`Message trend`}),(0,B.jsx)(uo,{children:`User vs assistant messages per day`})]}),(0,B.jsx)(K,{children:(0,B.jsx)(rx,{trend:a,series:[{key:`userMessages`,label:`User`,color:`var(--primary)`},{key:`assistantMessages`,label:`Assistant`,color:`var(--success)`}]})})]}),(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:`Session trend`}),(0,B.jsx)(uo,{children:`New vs active sessions per day`})]}),(0,B.jsx)(K,{children:(0,B.jsx)(rx,{trend:a,series:[{key:`newSessions`,label:`New`,color:`var(--primary)`},{key:`activeSessions`,label:`Active`,color:`var(--accent-foreground)`}],stacked:!1})})]})]}),(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{children:[(0,B.jsx)(G,{children:`Channel breakdown`}),(0,B.jsx)(uo,{children:`Distribution of sessions and messages by channel`})]}),(0,B.jsx)(K,{children:(0,B.jsx)(ix,{channels:o})})]})]})}function rx(e){let t=e.stacked!==!1,{maxValue:n,hasData:r}=(0,R.useMemo)(()=>{let n=0,r=!1;for(let i of e.trend)if(t){let t=e.series.reduce((e,t)=>e+(i[t.key]||0),0);t>0&&(r=!0),t>n&&(n=t)}else for(let t of e.series){let e=i[t.key]||0;e>0&&(r=!0),e>n&&(n=e)}return{maxValue:n,hasData:r}},[e.trend,e.series,t]);if(!r||e.trend.length===0)return(0,B.jsx)(`p`,{className:`supporting-text`,children:`No activity in the selected range.`});let i=Math.max(6,Math.min(28,Math.floor(480/Math.max(1,e.trend.length)))),a=e.trend.length*(i+6);return(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{style:{display:`flex`,gap:12,flexWrap:`wrap`,marginBottom:10},children:e.series.map(e=>(0,B.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:6,fontSize:`0.8rem`},children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,style:{display:`inline-block`,width:10,height:10,borderRadius:2,background:e.color}}),e.label]},e.key))}),(0,B.jsxs)(`svg`,{role:`img`,"aria-label":`Daily activity chart`,viewBox:`0 0 ${a} 164`,width:`100%`,height:164,preserveAspectRatio:`none`,children:[(0,B.jsx)(`title`,{children:`Daily activity chart`}),e.trend.map((r,a)=>{let o=a*(i+6),s=0;return(0,B.jsxs)(`g`,{children:[e.series.map(e=>{let a=r[e.key]||0,c=n>0?a/n*140:0,l=t?140-s-c:140-c;return t&&(s+=c),(0,B.jsx)(`rect`,{x:o,y:l,width:i,height:Math.max(0,c),fill:e.color,opacity:t?1:.85,children:(0,B.jsx)(`title`,{children:`${r.date} · ${e.label}: ${a}`})},e.key)}),a===0||a===e.trend.length-1||a===Math.floor(e.trend.length/2)?(0,B.jsx)(`text`,{x:o+i/2,y:156,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,opacity:`0.6`,children:r.date.slice(5)}):null]},r.date)})]})]})}function ix(e){if(e.channels.length===0)return(0,B.jsx)(`p`,{className:`supporting-text`,children:`No channel activity recorded in the selected range.`});let t=e.channels.reduce((e,t)=>e+t.sessionCount,0),n=e.channels.reduce((e,t)=>e+t.totalMessages,0);return(0,B.jsx)(`div`,{className:`table-shell`,children:(0,B.jsxs)(`table`,{children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{children:`Channel`}),(0,B.jsx)(`th`,{style:{textAlign:`right`},children:`Sessions`}),(0,B.jsx)(`th`,{style:{textAlign:`right`},children:`Messages`}),(0,B.jsx)(`th`,{style:{textAlign:`right`},children:`User`}),(0,B.jsx)(`th`,{style:{textAlign:`right`},children:`Assistant`}),(0,B.jsx)(`th`,{style:{minWidth:140},children:`Share`})]})}),(0,B.jsx)(`tbody`,{children:e.channels.map(e=>{let r=n>0?e.totalMessages/n:0;return(0,B.jsxs)(`tr`,{children:[(0,B.jsxs)(`td`,{children:[(0,B.jsx)(`strong`,{children:e.channelId||`(unknown)`}),(0,B.jsx)(`small`,{children:t>0?`${Math.round(e.sessionCount/t*100)}% of sessions`:`—`})]}),(0,B.jsx)(`td`,{style:{textAlign:`right`},children:e.sessionCount}),(0,B.jsx)(`td`,{style:{textAlign:`right`},children:e.totalMessages}),(0,B.jsx)(`td`,{style:{textAlign:`right`},children:e.userMessages}),(0,B.jsx)(`td`,{style:{textAlign:`right`},children:e.assistantMessages}),(0,B.jsx)(`td`,{children:(0,B.jsx)(`div`,{role:`progressbar`,"aria-label":`${Math.round(r*100)}% of messages`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(r*100),style:{background:`var(--accent-soft)`,borderRadius:4,height:8,overflow:`hidden`},children:(0,B.jsx)(`div`,{style:{width:r>0?`${r*100}%`:0,minWidth:r>0?2:0,height:`100%`,background:`var(--primary)`}})})})]},e.channelId)})})]})})}var ax={tool:(e,t)=>X(e.name,t.name),group:(e,t)=>X(e.groupLabel,t.groupLabel)||X(e.name,t.name),type:(e,t)=>X(e.kind,t.kind)||X(e.name,t.name),invocations:(e,t)=>$o(e.recentCalls,t.recentCalls)||X(e.name,t.name),lastUsed:(e,t)=>ts(e.lastUsedAt,t.lastUsedAt)||X(e.name,t.name)},ox={invocations:`desc`,lastUsed:`desc`};function sx(e){let[t,n]=(0,R.useState)(!1),r=(0,R.useRef)(null);return(0,R.useEffect)(()=>{if(!t)return;function e(e){e.key===`Escape`&&n(!1)}function i(e){let t=r.current;t&&!t.contains(e.target)&&n(!1)}return document.addEventListener(`keydown`,e),document.addEventListener(`mousedown`,i),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`mousedown`,i)}},[t]),e.recentErrors===0?(0,B.jsx)(`small`,{children:`no recent errors`}):e.samples.length===0?(0,B.jsxs)(`small`,{children:[e.recentErrors,` recent error`,e.recentErrors===1?``:`s`]}):(0,B.jsxs)(`details`,{ref:r,className:`inline-popover`,open:t,onToggle:e=>n(e.currentTarget.open),children:[(0,B.jsxs)(`summary`,{className:`inline-popover-trigger`,title:e.samples.map(e=>`${e.sessionId}: ${e.summary}`).join(`
|
|
173
173
|
|
|
174
|
-
`),children:[e.recentErrors,` recent error`,e.recentErrors===1?``:`s`]}),(0,B.jsxs)(`div`,{className:`inline-popover-panel`,children:[(0,B.jsx)(`div`,{className:`inline-popover-header`,children:`Recent errors`}),(0,B.jsx)(`div`,{className:`inline-popover-list`,children:e.samples.map(e=>(0,B.jsxs)(`div`,{className:`inline-popover-entry`,children:[(0,B.jsx)(`strong`,{children:Za(e.timestamp)}),(0,B.jsx)(`small`,{children:e.sessionId}),(0,B.jsx)(`p`,{children:e.summary})]},e.id))})]})]})}function cx(){let e=Gn(),[t,n]=(0,R.useState)(``),r=(0,R.useDeferredValue)(t),i=y({queryKey:[`tools`,e.token],queryFn:()=>Bn(e.token)}),{sortedRows:a,sortState:o,toggleSort:s}=Ba((0,R.useMemo)(()=>{let e=r.trim().toLowerCase();return(i.data?.groups||[]).flatMap(t=>t.tools.filter(t=>[t.name,t.group,t.kind].join(` `).toLowerCase().includes(e)).map(e=>({...e,groupLabel:t.label})))},[r,i.data?.groups]),{initialSort:{key:`invocations`,direction:`desc`},sorters:ax,defaultDirections:ox});return(0,B.jsxs)(`div`,{className:`page-stack`,children:[(0,B.jsx)(Ha,{actions:(0,B.jsx)(`input`,{className:`compact-search`,value:t,onChange:e=>n(e.target.value),placeholder:`Filter tools`})}),(0,B.jsxs)(`div`,{className:`metric-grid`,children:[(0,B.jsx)(Ua,{label:`Catalog tools`,value:String(i.data?.totals.totalTools??0),loading:!i.data}),(0,B.jsx)(Ua,{label:`MCP tools seen`,value:String(i.data?.totals.mcpTools??0),loading:!i.data}),(0,B.jsx)(Ua,{label:`Recent executions`,value:String(i.data?.totals.recentExecutions??0),loading:!i.data}),(0,B.jsx)(Ua,{label:`Recent errors`,value:String(i.data?.totals.recentErrors??0),loading:!i.data})]}),(0,B.jsxs)(`div`,{className:`two-column-grid`,children:[(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{children:(0,B.jsx)(G,{children:`Catalog`})}),(0,B.jsx)(K,{children:i.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading tool catalog...`}):a.length===0?(0,B.jsx)(`div`,{className:`empty-state`,children:`No tools match this filter.`}):(0,B.jsx)(`div`,{className:`table-shell`,children:(0,B.jsxs)(`table`,{children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(Va,{label:`Tool`,sortKey:`tool`,sortState:o,onToggle:s}),(0,B.jsx)(Va,{label:`Group`,sortKey:`group`,sortState:o,onToggle:s}),(0,B.jsx)(Va,{label:`Type`,sortKey:`type`,sortState:o,onToggle:s}),(0,B.jsx)(Va,{label:`Invocations`,sortKey:`invocations`,sortState:o,onToggle:s}),(0,B.jsx)(Va,{label:`Last used`,sortKey:`lastUsed`,sortState:o,onToggle:s})]})}),(0,B.jsx)(`tbody`,{children:a.map(e=>(0,B.jsxs)(`tr`,{children:[(0,B.jsxs)(`td`,{children:[(0,B.jsx)(`strong`,{children:e.name}),(0,B.jsx)(sx,{recentErrors:e.recentErrors,samples:e.recentErrorSamples})]}),(0,B.jsx)(`td`,{children:e.groupLabel}),(0,B.jsx)(`td`,{children:e.kind}),(0,B.jsx)(`td`,{children:e.recentCalls}),(0,B.jsx)(`td`,{children:Qa(e.lastUsedAt)})]},e.name))})]})})})]}),(0,B.jsxs)(U,{variant:`muted`,children:[(0,B.jsx)(W,{children:(0,B.jsx)(G,{children:`Recent executions`})}),(0,B.jsx)(K,{children:i.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading recent executions...`}):i.data?.recentExecutions.length?(0,B.jsx)(`div`,{className:`list-stack selectable-list`,children:i.data.recentExecutions.map(e=>(0,B.jsxs)(`div`,{className:`list-row`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:e.toolName}),(0,B.jsxs)(`small`,{children:[e.sessionId,` ·`,` `,Za(e.timestamp),e.durationMs==null?``:` · ${e.durationMs}ms`]}),e.isError&&e.summary?(0,B.jsx)(`small`,{children:e.summary}):null]}),(0,B.jsxs)(`span`,{className:e.isError?`list-status list-status-danger`:`list-status list-status-success`,children:[(0,B.jsx)(`span`,{className:e.isError?`status-dot status-dot-danger`:`status-dot status-dot-success`}),e.isError?`error`:`ok`]})]},e.id))}):(0,B.jsx)(`div`,{className:`empty-state`,children:`No recent tool executions were found in structured audit events.`})})]})]})]})}var lx=`modulepreload`,ux=function(e){return`/`+e},dx={},fx=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=ux(t,n),t in dx)return;dx[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:lx,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},px=(0,R.lazy)(async()=>({default:(await fx(()=>import(`./terminal-6wR9ID9V.js`),__vite__mapDeps([0,1,2,3,4]))).TerminalPage}));function mx(){return(0,B.jsx)(R.Suspense,{fallback:(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading terminal…`}),children:(0,B.jsx)(px,{})})}var hx=(0,R.lazy)(async()=>({default:(await fx(()=>import(`./chat-B3O0bG4k.js`),__vite__mapDeps([5,1,6,2,7]))).ChatPage}));function gx(){return(0,B.jsx)(R.Suspense,{fallback:(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading chat…`}),children:(0,B.jsx)(hx,{})})}function _x(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function vx(){let e=I({select:e=>e.location.pathname});return(0,R.useEffect)(()=>{document.title=Lr(e)},[e]),null}function yx(){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(vx,{}),(0,B.jsx)(E,{})]})}var bx=N({component:yx});function xx(){return(0,B.jsx)(Ma,{children:(0,B.jsx)(E,{})})}var Sx=F({getParentRoute:()=>bx,id:`_admin_layout`,component:xx}),Cx=F({getParentRoute:()=>bx,path:`/agents`,component:Bs}),wx=F({getParentRoute:()=>Sx,path:`/admin`,component:of}),Tx=F({getParentRoute:()=>Sx,path:`/admin/statistics`,component:nx}),Ex=F({getParentRoute:()=>Sx,path:`/admin/approvals`,component:Ys}),Dx=F({getParentRoute:()=>Sx,path:`/admin/a2a-inbox`,component:co}),Ox=F({getParentRoute:()=>Sx,path:`/admin/a2a-trust`,component:Zo}),kx=F({getParentRoute:()=>Sx,path:`/admin/agents`,component:Ds}),Ax=F({getParentRoute:()=>Sx,path:`/admin/agent-scoreboard`,component:as}),jx=F({getParentRoute:()=>Sx,path:`/admin/terminal`,component:mx}),Mx=F({getParentRoute:()=>Sx,path:`/admin/gateway`,component:rp}),Nx=F({getParentRoute:()=>Sx,path:`/admin/logs`,component:Gp}),Px=F({getParentRoute:()=>Sx,path:`/admin/fleet-topology`,component:Yf}),Fx=F({getParentRoute:()=>Sx,path:`/admin/sessions`,validateSearch:e=>({sessionId:_x(e.sessionId)}),component:_g}),Ix=F({getParentRoute:()=>Sx,path:`/admin/channels`,component:$l}),Lx=F({getParentRoute:()=>Sx,path:`/admin/email`,component:Gf}),Rx=F({getParentRoute:()=>Sx,path:`/admin/config`,component:Mu}),zx=F({getParentRoute:()=>Sx,path:`/admin/models`,component:fm}),Bx=F({getParentRoute:()=>Sx,path:`/admin/scheduler`,validateSearch:e=>({jobId:_x(e.jobId)}),component:lg}),Vx=F({getParentRoute:()=>Sx,path:`/admin/jobs`,component:Fp}),Hx=F({getParentRoute:()=>Sx,path:`/admin/harness-evolution`,component:up}),Ux=F({getParentRoute:()=>Sx,path:`/admin/distill`,component:Of}),Wx=F({getParentRoute:()=>Sx,path:`/admin/mcp`,component:tm}),Gx=F({getParentRoute:()=>Sx,path:`/admin/connectors`,component:Cd}),Kx=F({getParentRoute:()=>Sx,path:`/admin/audit`,validateSearch:e=>({q:_x(e.q),range:_x(e.range)}),component:hc}),qx=F({getParentRoute:()=>Sx,path:`/admin/skills`,component:ex}),Jx=F({getParentRoute:()=>Sx,path:`/admin/skills/$skillName`,component:Lb}),Yx=F({getParentRoute:()=>Sx,path:`/admin/plugins`,component:Mh}),Xx=F({getParentRoute:()=>Sx,path:`/admin/output-guard`,component:Dh}),Zx=F({getParentRoute:()=>Sx,path:`/admin/tools`,component:cx}),Qx=F({getParentRoute:()=>Sx,path:`/admin/secrets`,component:mg}),$x=F({getParentRoute:()=>bx,path:`/chat`,component:gx}),eS=F({getParentRoute:()=>$x,path:`$sessionId`}),tS=A({routeTree:bx.addChildren([Sx.addChildren([wx,Tx,Ex,Dx,Ox,kx,Ax,jx,Mx,Nx,Px,Fx,Ix,Lx,Rx,zx,Bx,Vx,Hx,Ux,Gx,Wx,Kx,qx,Jx,Yx,Xx,Zx,Qx]),Cx,$x.addChildren([eS])])});function nS(){let e=Gn(),[t]=(0,R.useState)(()=>new le({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}));return(0,R.useEffect)(()=>{document.title=Lr(window.location.pathname)},[]),e.status===`checking`?(0,B.jsx)(`div`,{className:`loading-shell`,children:(0,B.jsxs)(`div`,{"aria-label":`Loading HybridClaw`,"aria-live":`polite`,className:`loading-panel`,role:`status`,children:[(0,B.jsx)(`div`,{className:`loading-mark-wrap`,children:(0,B.jsx)(pr,{className:`loading-mark`})}),(0,B.jsx)(`div`,{className:`loading-copy`,children:(0,B.jsx)(`h1`,{children:`Loading HybridClaw ...`})}),(0,B.jsx)(`div`,{className:`loading-progress`,"aria-hidden":`true`,children:(0,B.jsx)(`span`,{})})]})}):e.status===`error`?(0,B.jsx)(`div`,{className:`login-shell`,children:(0,B.jsxs)(`div`,{className:`login-card`,children:[(0,B.jsx)(`p`,{className:`eyebrow`,children:`HybridClaw Admin`}),(0,B.jsx)(`h1`,{children:`Console unavailable.`}),(0,B.jsx)(`p`,{className:`supporting-text`,children:e.error}),(0,B.jsx)(`button`,{className:`primary-button`,type:`button`,onClick:e.retry,children:`Retry`})]})}):e.status===`prompt`?(0,B.jsx)(Ir,{}):(0,B.jsx)(p,{client:t,children:(0,B.jsx)(P,{router:tS})})}bi(),ue.createRoot(document.getElementById(`root`)).render((0,B.jsx)(Un,{children:(0,B.jsx)(vs,{children:(0,B.jsx)(nS,{})})}));export{ci as $,H as A,$i as B,Hc as C,Z as D,Wc as E,_a as F,Vi as G,ra as H,ia as I,Ai as J,Oi as K,Qi as L,ka as M,Ca as N,Za as O,ha as P,si as Q,ea as R,$c as S,Uc as T,Zi as U,Xi as V,Hi as W,li as X,ri as Y,ii as Z,_m as _,z as _t,Om as a,Mr as at,Jc as b,Te as bt,Em as c,Gn as ct,Fm as d,At as dt,ai as et,wm as f,ye as ft,ym as g,_e as gt,vm as h,yn as ht,Cm as i,Nr as it,Ha as j,eo as k,Mm as l,ut as lt,gm as m,Kt as mt,gh as n,V as nt,km as o,Or as ot,Tm as p,ft as pt,ki as q,zm as r,Fr as rt,Am as s,Wn as st,fb as t,oi as tt,Pm as u,ve as ut,Bc as v,ct as vt,Kc as w,qc as x,je as xt,Xc as y,lt as yt,ta as z};
|
|
174
|
+
`),children:[e.recentErrors,` recent error`,e.recentErrors===1?``:`s`]}),(0,B.jsxs)(`div`,{className:`inline-popover-panel`,children:[(0,B.jsx)(`div`,{className:`inline-popover-header`,children:`Recent errors`}),(0,B.jsx)(`div`,{className:`inline-popover-list`,children:e.samples.map(e=>(0,B.jsxs)(`div`,{className:`inline-popover-entry`,children:[(0,B.jsx)(`strong`,{children:Za(e.timestamp)}),(0,B.jsx)(`small`,{children:e.sessionId}),(0,B.jsx)(`p`,{children:e.summary})]},e.id))})]})]})}function cx(){let e=Gn(),[t,n]=(0,R.useState)(``),r=(0,R.useDeferredValue)(t),i=y({queryKey:[`tools`,e.token],queryFn:()=>Bn(e.token)}),{sortedRows:a,sortState:o,toggleSort:s}=Ba((0,R.useMemo)(()=>{let e=r.trim().toLowerCase();return(i.data?.groups||[]).flatMap(t=>t.tools.filter(t=>[t.name,t.group,t.kind].join(` `).toLowerCase().includes(e)).map(e=>({...e,groupLabel:t.label})))},[r,i.data?.groups]),{initialSort:{key:`invocations`,direction:`desc`},sorters:ax,defaultDirections:ox});return(0,B.jsxs)(`div`,{className:`page-stack`,children:[(0,B.jsx)(Ha,{actions:(0,B.jsx)(`input`,{className:`compact-search`,value:t,onChange:e=>n(e.target.value),placeholder:`Filter tools`})}),(0,B.jsxs)(`div`,{className:`metric-grid`,children:[(0,B.jsx)(Ua,{label:`Catalog tools`,value:String(i.data?.totals.totalTools??0),loading:!i.data}),(0,B.jsx)(Ua,{label:`MCP tools seen`,value:String(i.data?.totals.mcpTools??0),loading:!i.data}),(0,B.jsx)(Ua,{label:`Recent executions`,value:String(i.data?.totals.recentExecutions??0),loading:!i.data}),(0,B.jsx)(Ua,{label:`Recent errors`,value:String(i.data?.totals.recentErrors??0),loading:!i.data})]}),(0,B.jsxs)(`div`,{className:`two-column-grid`,children:[(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{children:(0,B.jsx)(G,{children:`Catalog`})}),(0,B.jsx)(K,{children:i.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading tool catalog...`}):a.length===0?(0,B.jsx)(`div`,{className:`empty-state`,children:`No tools match this filter.`}):(0,B.jsx)(`div`,{className:`table-shell`,children:(0,B.jsxs)(`table`,{children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(Va,{label:`Tool`,sortKey:`tool`,sortState:o,onToggle:s}),(0,B.jsx)(Va,{label:`Group`,sortKey:`group`,sortState:o,onToggle:s}),(0,B.jsx)(Va,{label:`Type`,sortKey:`type`,sortState:o,onToggle:s}),(0,B.jsx)(Va,{label:`Invocations`,sortKey:`invocations`,sortState:o,onToggle:s}),(0,B.jsx)(Va,{label:`Last used`,sortKey:`lastUsed`,sortState:o,onToggle:s})]})}),(0,B.jsx)(`tbody`,{children:a.map(e=>(0,B.jsxs)(`tr`,{children:[(0,B.jsxs)(`td`,{children:[(0,B.jsx)(`strong`,{children:e.name}),(0,B.jsx)(sx,{recentErrors:e.recentErrors,samples:e.recentErrorSamples})]}),(0,B.jsx)(`td`,{children:e.groupLabel}),(0,B.jsx)(`td`,{children:e.kind}),(0,B.jsx)(`td`,{children:e.recentCalls}),(0,B.jsx)(`td`,{children:Qa(e.lastUsedAt)})]},e.name))})]})})})]}),(0,B.jsxs)(U,{variant:`muted`,children:[(0,B.jsx)(W,{children:(0,B.jsx)(G,{children:`Recent executions`})}),(0,B.jsx)(K,{children:i.isLoading?(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading recent executions...`}):i.data?.recentExecutions.length?(0,B.jsx)(`div`,{className:`list-stack selectable-list`,children:i.data.recentExecutions.map(e=>(0,B.jsxs)(`div`,{className:`list-row`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:e.toolName}),(0,B.jsxs)(`small`,{children:[e.sessionId,` ·`,` `,Za(e.timestamp),e.durationMs==null?``:` · ${e.durationMs}ms`]}),e.isError&&e.summary?(0,B.jsx)(`small`,{children:e.summary}):null]}),(0,B.jsxs)(`span`,{className:e.isError?`list-status list-status-danger`:`list-status list-status-success`,children:[(0,B.jsx)(`span`,{className:e.isError?`status-dot status-dot-danger`:`status-dot status-dot-success`}),e.isError?`error`:`ok`]})]},e.id))}):(0,B.jsx)(`div`,{className:`empty-state`,children:`No recent tool executions were found in structured audit events.`})})]})]})]})}var lx=`modulepreload`,ux=function(e){return`/`+e},dx={},fx=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=ux(t,n),t in dx)return;dx[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:lx,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},px=(0,R.lazy)(async()=>({default:(await fx(()=>import(`./terminal-BOibs0Ai.js`),__vite__mapDeps([0,1,2,3,4]))).TerminalPage}));function mx(){return(0,B.jsx)(R.Suspense,{fallback:(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading terminal…`}),children:(0,B.jsx)(px,{})})}var hx=(0,R.lazy)(async()=>({default:(await fx(()=>import(`./chat-B4ykLwkT.js`),__vite__mapDeps([5,1,6,7,2,8]))).ChatPage}));function gx(){return(0,B.jsx)(R.Suspense,{fallback:(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading chat…`}),children:(0,B.jsx)(hx,{})})}var _x=(0,R.lazy)(async()=>({default:(await fx(()=>import(`./apps-BCUhkPkB.js`),__vite__mapDeps([9,1,6,7,2,10]))).AppsPage}));function vx(){return(0,B.jsx)(R.Suspense,{fallback:(0,B.jsx)(`div`,{className:`empty-state`,children:`Loading apps…`}),children:(0,B.jsx)(_x,{})})}function yx(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function bx(){let e=I({select:e=>e.location.pathname});return(0,R.useEffect)(()=>{document.title=Lr(e)},[e]),null}function xx(){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(bx,{}),(0,B.jsx)(E,{})]})}var Sx=N({component:xx});function Cx(){return(0,B.jsx)(Ma,{children:(0,B.jsx)(E,{})})}var wx=F({getParentRoute:()=>Sx,id:`_admin_layout`,component:Cx}),Tx=F({getParentRoute:()=>Sx,path:`/agents`,component:Bs}),Ex=F({getParentRoute:()=>wx,path:`/admin`,component:of}),Dx=F({getParentRoute:()=>wx,path:`/admin/statistics`,component:nx}),Ox=F({getParentRoute:()=>wx,path:`/admin/approvals`,component:Ys}),kx=F({getParentRoute:()=>wx,path:`/admin/a2a-inbox`,component:co}),Ax=F({getParentRoute:()=>wx,path:`/admin/a2a-trust`,component:Zo}),jx=F({getParentRoute:()=>wx,path:`/admin/agents`,component:Ds}),Mx=F({getParentRoute:()=>wx,path:`/admin/agent-scoreboard`,component:as}),Nx=F({getParentRoute:()=>wx,path:`/admin/terminal`,component:mx}),Px=F({getParentRoute:()=>wx,path:`/admin/gateway`,component:rp}),Fx=F({getParentRoute:()=>wx,path:`/admin/logs`,component:Gp}),Ix=F({getParentRoute:()=>wx,path:`/admin/fleet-topology`,component:Yf}),Lx=F({getParentRoute:()=>wx,path:`/admin/sessions`,validateSearch:e=>({sessionId:yx(e.sessionId)}),component:_g}),Rx=F({getParentRoute:()=>wx,path:`/admin/channels`,component:$l}),zx=F({getParentRoute:()=>wx,path:`/admin/email`,component:Gf}),Bx=F({getParentRoute:()=>wx,path:`/admin/config`,component:Mu}),Vx=F({getParentRoute:()=>wx,path:`/admin/models`,component:fm}),Hx=F({getParentRoute:()=>wx,path:`/admin/scheduler`,validateSearch:e=>({jobId:yx(e.jobId)}),component:lg}),Ux=F({getParentRoute:()=>wx,path:`/admin/jobs`,component:Fp}),Wx=F({getParentRoute:()=>wx,path:`/admin/harness-evolution`,component:up}),Gx=F({getParentRoute:()=>wx,path:`/admin/distill`,component:Of}),Kx=F({getParentRoute:()=>wx,path:`/admin/mcp`,component:tm}),qx=F({getParentRoute:()=>wx,path:`/admin/connectors`,component:Cd}),Jx=F({getParentRoute:()=>wx,path:`/admin/audit`,validateSearch:e=>({q:yx(e.q),range:yx(e.range)}),component:hc}),Yx=F({getParentRoute:()=>wx,path:`/admin/skills`,component:ex}),Xx=F({getParentRoute:()=>wx,path:`/admin/skills/$skillName`,component:Lb}),Zx=F({getParentRoute:()=>wx,path:`/admin/plugins`,component:Mh}),Qx=F({getParentRoute:()=>wx,path:`/admin/output-guard`,component:Dh}),$x=F({getParentRoute:()=>wx,path:`/admin/tools`,component:cx}),eS=F({getParentRoute:()=>wx,path:`/admin/secrets`,component:mg}),tS=F({getParentRoute:()=>Sx,path:`/chat`,validateSearch:e=>{let t=yx(e.prompt),n=yx(e.send),r=yx(e.agent),i=yx(e.app),a=yx(e.category),o=yx(e.kind);return{...t?{prompt:t}:{},...n?{send:n}:{},...r?{agent:r}:{},...i?{app:i}:{},...a?{category:a}:{},...o?{kind:o}:{}}},component:gx}),nS=F({getParentRoute:()=>tS,path:`$sessionId`}),rS=F({getParentRoute:()=>Sx,path:`/apps`,component:vx}),iS=A({routeTree:Sx.addChildren([wx.addChildren([Ex,Dx,Ox,kx,Ax,jx,Mx,Nx,Px,Fx,Ix,Lx,Rx,zx,Bx,Vx,Hx,Ux,Wx,Gx,qx,Kx,Jx,Yx,Xx,Zx,Qx,$x,eS]),Tx,tS.addChildren([nS]),rS])});function aS(){let e=Gn(),[t]=(0,R.useState)(()=>new le({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}));return(0,R.useEffect)(()=>{document.title=Lr(window.location.pathname)},[]),e.status===`checking`?(0,B.jsx)(`div`,{className:`loading-shell`,children:(0,B.jsxs)(`div`,{"aria-label":`Loading HybridClaw`,"aria-live":`polite`,className:`loading-panel`,role:`status`,children:[(0,B.jsx)(`div`,{className:`loading-mark-wrap`,children:(0,B.jsx)(pr,{className:`loading-mark`})}),(0,B.jsx)(`div`,{className:`loading-copy`,children:(0,B.jsx)(`h1`,{children:`Loading HybridClaw ...`})}),(0,B.jsx)(`div`,{className:`loading-progress`,"aria-hidden":`true`,children:(0,B.jsx)(`span`,{})})]})}):e.status===`error`?(0,B.jsx)(`div`,{className:`login-shell`,children:(0,B.jsxs)(`div`,{className:`login-card`,children:[(0,B.jsx)(`p`,{className:`eyebrow`,children:`HybridClaw Admin`}),(0,B.jsx)(`h1`,{children:`Console unavailable.`}),(0,B.jsx)(`p`,{className:`supporting-text`,children:e.error}),(0,B.jsx)(`button`,{className:`primary-button`,type:`button`,onClick:e.retry,children:`Retry`})]})}):e.status===`prompt`?(0,B.jsx)(Ir,{}):(0,B.jsx)(p,{client:t,children:(0,B.jsx)(P,{router:iS})})}bi(),ue.createRoot(document.getElementById(`root`)).render((0,B.jsx)(Un,{children:(0,B.jsx)(vs,{children:(0,B.jsx)(aS,{})})}));export{Ai as $,eo as A,ta as B,Hc as C,_e as Ct,hs as D,Te as Dt,Wc as E,lt as Et,ha as F,Hi as G,Xi as H,_a as I,Pi as J,Vi as K,ia as L,Ha as M,ka as N,Z as O,je as Ot,Ca as P,ki as Q,Qi as R,$c as S,yn as St,Uc as T,ct as Tt,ra as U,$i as V,Zi as W,Ni as X,Fi as Y,Oi as Z,_m as _,ve as _t,Om as a,ai as at,Jc as b,ft as bt,Em as c,Fr as ct,Fm as d,Or as dt,ri as et,wm as f,Er as ft,ym as g,ut as gt,vm as h,Gn as ht,Cm as i,ci as it,H as j,Za as k,Mm as l,Nr as lt,gm as m,Wn as mt,gh as n,ii as nt,km as o,oi as ot,Tm as p,er as pt,Mi as q,zm as r,si as rt,Am as s,V as st,fb as t,li as tt,Pm as u,Mr as ut,Bc as v,At as vt,Kc as w,z as wt,qc as x,Kt as xt,Xc as y,ye as yt,ea as z};
|