@xopcai/xopc 0.0.119 → 0.0.120
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CU8J6zou.js → agent-avatar-dicebear-APTlX9Sq.js} +1 -1
- package/dist/gateway/static/root/assets/agents-CFW_FS_V.js +2 -0
- package/dist/gateway/static/root/assets/{app-management-settings-panel-B9vfYoEr.js → app-management-settings-panel-DTKc5HHT.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-ClOzIO24.js → appearance-settings-BTciFrE9.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-DU0dz9Zo.js → apps-page-DT52OrbM.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-BkVIgZzA.js → archive-plugin-CiHaUMII.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-CaCMWh1D.js → attachment-load-t4gSrNjL.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-DhGDpKP3.js → automation-suggestion-card-CtysjSoQ.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-CTedroVo.js → automations-page-B2YvT3ES.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-B4TO_bsn.js → binary-plugins-BAbSldW5.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-DJRWwWNI.js → block-editor-BNr_82xl.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-FCDwOOBK.js → browser-settings-page-BQEXPhDU.js} +3 -3
- package/dist/gateway/static/root/assets/{capability-presets-api-Befi89CL.js → capability-presets-api-tzD702Gg.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-settings-panel-_G8eb2vJ.js → capability-presets-settings-panel-AGhTueAc.js} +1 -1
- package/dist/gateway/static/root/assets/{channel-recipient-api-BNSuJb5f.js → channel-recipient-api-DL_KzwGE.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-C3d5JBJX.js → channels-settings-DRTutLlN.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-yaUNvt5u.js → connectors-page-DneJVuge.js} +2 -2
- package/dist/gateway/static/root/assets/dreaming-settings-BEwWA1yf.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-DYh402XV.js → extension-debug-page-Dl2kO0Sf.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-Cr_TizrN.js → extension-page-DmbLPsx_.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-BU1KoKRj.js → extension-settings-page-BS2rx40e.js} +1 -1
- package/dist/gateway/static/root/assets/{fetch-Y7AEX4H3.js → fetch-B3ME5Eri.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-RbMmAOpX.js → gateway-config-api-DI9_BBTo.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-C79wkXef.js → gateway-settings-DAFI_T0W.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-DiD_Tx4N.js → gateway-startup-retry-CSZQTz6K.js} +1 -1
- package/dist/gateway/static/root/assets/goal-detail-page-DLuz4jC9.js +1 -0
- package/dist/gateway/static/root/assets/{goals-config-api-DqxVi0p5.js → goals-config-api-Bhzqrp2w.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-page-CS0R-Af2.js → goals-page-DTAfv9Ft.js} +2 -2
- package/dist/gateway/static/root/assets/{goals-settings-CSuzZ8Ae.js → goals-settings-CWN2iirQ.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-DXPaYJm3.js → heartbeat-settings-CkkkHvOi.js} +1 -1
- package/dist/gateway/static/root/assets/index-CnjzMw5i.js +191 -0
- package/dist/gateway/static/root/assets/index-E1QinYKp.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-Dvg53qnd.js → keyboard-shortcuts-settings-kMp08SlX.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-DjbfSsfA.js → locale-store-Ba72bFmP.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-DLXPcksQ.js → logs-page-CDXDlS_W.js} +2 -2
- package/dist/gateway/static/root/assets/{markdown-split-CpHxbtWJ.js → markdown-split-Bc0w40vz.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-SFPQRSxq.js → media-plugins-DJ_HvgIy.js} +1 -1
- package/dist/gateway/static/root/assets/messages-CISb1HLv.js +3 -0
- package/dist/gateway/static/root/assets/models-hub-panel-BTwxMIgZ.js +2 -0
- package/dist/gateway/static/root/assets/note-detail-page-BBfOeB0m.js +2 -0
- package/dist/gateway/static/root/assets/{note-image-lightbox-BUYURRgn.js → note-image-lightbox-4zntqpZq.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-BsIBSFyZ.js → notes-page-VocWOjoK.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-BHz9iWYA.js → preview-open-alternatives-BbA7sRd_.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CXwjuD_Q.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-CefkOlRg.js → save-bar-controls-Dividh61.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-CmTRoOcE.js → schedule-field-pRheF2CO.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-FMKv1vGu.js → schema-form-D6PiPxfr.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-CpcVySQK.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-BVy_TawT.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-BouO6JTi.js → settings-collapsible-section-BMCOfuE_.js} +1 -1
- package/dist/gateway/static/root/assets/settings-form-section-DBkGwpIN.js +1 -0
- package/dist/gateway/static/root/assets/settings-page-CZpNyCWn.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-layout-BJ4Gsef5.js → settings-page-layout-NxoW5Y57.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-MVHLLu_a.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-BDy2btRN.js → share-preview-page-B0suFCfj.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-B18OBmH5.js → shares-settings-C6DBbQGo.js} +1 -1
- package/dist/gateway/static/root/assets/skill-reload-api-6hJmhwSn.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-Bm2ebkwl.js → skills-page-Im1MA0Iw.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-CRngrlnZ.js → system-settings-panel-CrmEnyX4.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-CD2wtgZV.js → theme-store-Bt6vAkSB.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-BltBc0b-.js → typed-models-lib-BAsGn25g.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-CjN-51e6.js → use-channel-catalog-C7vcAoGb.js} +1 -1
- package/dist/gateway/static/root/assets/{user-profile-settings-panel-DJ1dKwZy.js → user-profile-settings-panel-QAQWGelF.js} +1 -1
- package/dist/gateway/static/root/assets/{utils-B5M5-YvK.js → utils-Dl9efgnV.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-CeEevm7z.js → voice-api-key-field-D-6XueTv.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-player-store-B7ykUlHM.js → voice-player-store-CMC5NOJp.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-C4PzUQjB.js → workflow-run-setup-panel-DVPllR4k.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-BL84_-Ky.js → workflows-page-B94WISTW.js} +2 -2
- package/dist/gateway/static/root/index.html +7 -7
- package/dist/package.js +1 -1
- package/dist/src/agent/context/workspace-templates/AGENTS.md +3 -2
- package/dist/src/agent/memory/builtin-memory-store.d.ts +1 -1
- package/dist/src/agent/memory/builtin-memory-store.js +1 -1
- package/dist/src/agent/memory/builtin-memory-store.js.map +1 -1
- package/dist/src/agent/memory/builtin-provider.d.ts +2 -2
- package/dist/src/agent/memory/builtin-provider.js +2 -2
- package/dist/src/agent/memory/builtin-provider.js.map +1 -1
- package/dist/src/agent/memory/dreaming/light-sweep.d.ts +0 -7
- package/dist/src/agent/memory/dreaming/light-sweep.js +16 -277
- package/dist/src/agent/memory/dreaming/light-sweep.js.map +1 -1
- package/dist/src/agent/memory/dreaming/rem-patterns.d.ts +1 -1
- package/dist/src/agent/memory/dreaming/rem-patterns.js +1 -1
- package/dist/src/agent/memory/dreaming/rem-patterns.js.map +1 -1
- package/dist/src/agent/memory/dreaming/short-term-store.d.ts +3 -3
- package/dist/src/agent/memory/dreaming/short-term-store.js +5 -5
- package/dist/src/agent/memory/dreaming/short-term-store.js.map +1 -1
- package/dist/src/agent/memory/dreaming/utils.d.ts +2 -2
- package/dist/src/agent/memory/dreaming/utils.js +2 -2
- package/dist/src/agent/memory/dreaming/utils.js.map +1 -1
- package/dist/src/agent/memory/index.d.ts +0 -2
- package/dist/src/agent/memory/index.js +1 -2
- package/dist/src/agent/prompt/sections/memory-skills.js +11 -10
- package/dist/src/agent/prompt/sections/memory-skills.js.map +1 -1
- package/dist/src/agent/prompt/sections/tooling.js +2 -2
- package/dist/src/agent/prompt/sections/tooling.js.map +1 -1
- package/dist/src/agent/reply/startup-context.js +6 -105
- package/dist/src/agent/reply/startup-context.js.map +1 -1
- package/dist/src/agent/service.d.ts +0 -3
- package/dist/src/agent/service.js +0 -41
- package/dist/src/agent/service.js.map +1 -1
- package/dist/src/agent/tools/memory-tool.js +2 -2
- package/dist/src/agent/tools/memory-tool.js.map +1 -1
- package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
- package/dist/src/cli/commands/init.js +1 -1
- package/dist/src/cli/commands/init.js.map +1 -1
- package/dist/src/cli/templates.js +3 -2
- package/dist/src/cli/templates.js.map +1 -1
- package/dist/src/config/schema.d.ts +2 -2
- package/dist/src/config/schema.js +2 -2
- package/dist/src/config/schema.js.map +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +4 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js.map +1 -1
- package/dist/src/infra/update-restart.js +1 -1
- package/dist/src/storage/sqlite/row-mappers.js +3 -1
- package/dist/src/storage/sqlite/row-mappers.js.map +1 -1
- package/dist/src/tui/backends/embedded-backend.js +1 -2
- package/dist/src/tui/backends/embedded-backend.js.map +1 -1
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/agents-B0hkpLhP.js +0 -2
- package/dist/gateway/static/root/assets/dreaming-settings-DNrdg1Ve.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-9paXuHdo.js +0 -1
- package/dist/gateway/static/root/assets/index-BoKafJIZ.js +0 -191
- package/dist/gateway/static/root/assets/index-CArhCcYn.css +0 -1
- package/dist/gateway/static/root/assets/messages-CrDHEbss.js +0 -3
- package/dist/gateway/static/root/assets/models-hub-panel-BDF2iyRk.js +0 -2
- package/dist/gateway/static/root/assets/note-detail-page-CSb_hwig.js +0 -2
- package/dist/gateway/static/root/assets/remote-access-hub-CwzSovcS.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-PHmX-NmA.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BRAeKJN4.js +0 -1
- package/dist/gateway/static/root/assets/settings-form-section-D-4lBl6X.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-KKrbFjy8.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-CrUjHPQo.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-C28-2uKQ.js +0 -1
- package/dist/src/agent/memory/memory-flush.d.ts +0 -27
- package/dist/src/agent/memory/memory-flush.js +0 -124
- package/dist/src/agent/memory/memory-flush.js.map +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-CrDHEbss.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{i as s}from"./theme-store-CD2wtgZV.js";import{c,i as l,n as u}from"./fetch-Y7AEX4H3.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{$a as f,$n as p,Ai as m,Ar as h,Cn as g,Ct as _,Di as v,Dn as y,Fi as b,Fr as x,Fs as S,Ii as C,Ir as w,Ks as T,Li as E,Lr as D,Mi as O,Mr as k,Na as A,Ni as j,No as M,Nr as N,Oi as P,On as F,Oo as I,Pi as ee,Pr as L,Qn as te,Ri as ne,Rr as R,Sn as re,Tn as z,Ua as B,Vs as V,Wi as H,Xs as U,Ya as W,Ys as ie,Zn as ae,Zo as oe,Zs as se,_n as G,_r as ce,_t as le,aa as ue,at as de,ba as fe,bn as pe,br as me,bt as he,d as ge,dn as K,dr as _e,dt as ve,ea as ye,es as be,fn as xe,fr as q,ga as Se,gn as Ce,gr as we,ha as Te,hn as Ee,hr as De,ht as Oe,ja as ke,ji as Ae,jr as je,js as Me,ki as Ne,ko as Pe,la as Fe,ls as Ie,lt as Le,mn as Re,mr as J,mt as ze,n as Be,ni as Ve,no as He,pa as Ue,pn as We,pr as Ge,pt as Ke,sa as Y,so as qe,t as Je,ta as Ye,to as Xe,ts as Ze,u as X,ua as Qe,ut as $e,vn as et,vo as tt,wn as nt,xt as rt,ya as it,yn as at,zi as ot,zr as st,zs as ct}from"./index-BoKafJIZ.js";import{t as lt}from"./markdown-editor-AssmZFx4.js";import{n as ut,t as dt}from"./settings-form-section-D-4lBl6X.js";import{n as ft,t as pt}from"./settings-page-layout-BJ4Gsef5.js";import{n as mt}from"./agent-avatar-dicebear-CU8J6zou.js";import{n as ht,r as gt,t as _t}from"./channel-recipient-api-BNSuJb5f.js";import{n as vt,r as yt,t as bt}from"./utils-B5M5-YvK.js";import{a as xt,i as St,n as Ct,o as wt,t as Tt}from"./typed-models-lib-BltBc0b-.js";import{a as Et,o as Dt,r as Ot,s as kt}from"./capability-presets-api-Befi89CL.js";var Z=n(),Q=r();function At(e){let t=(0,Z.c)(40),{open:n,onOpenChange:r,busy:a,deletePurge:o,deleteTarget:s,deleteConfirmText:c,onDeleteConfirmTextChange:l,onConfirm:u,onCancel:d,a:f}=e,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Q.jsx)(Ae,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),t[0]=p):p=t[0];let h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h=i(`fixed left-1/2 top-1/2 z-[81] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-4 shadow-popover`,`dark:border-edge`),t[1]=h):h=t[1];let g=o?f.purgeDisk:f.removeFromConfig,_;t[2]===g?_=t[3]:(_=(0,Q.jsx)(ee,{className:`text-base font-semibold text-fg`,children:g}),t[2]=g,t[3]=_);let v=o?f.confirmDeletePurge:f.confirmDelete,y;t[4]===v?y=t[5]:(y=(0,Q.jsx)(m,{className:`mt-2 whitespace-pre-wrap text-sm leading-relaxed text-fg-muted`,children:v}),t[4]=v,t[5]=y);let b;t[6]!==f.purgeConfirmHint||t[7]!==f.purgeConfirmLabel||t[8]!==f.purgeConfirmPlaceholder||t[9]!==c||t[10]!==o||t[11]!==s||t[12]!==l?(b=o&&s?(0,Q.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,Q.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-fg`,htmlFor:`agent-delete-confirm`,children:f.purgeConfirmLabel}),(0,Q.jsx)(`input`,{id:`agent-delete-confirm`,type:`text`,autoComplete:`off`,spellCheck:!1,className:i(`w-full rounded-md border border-edge bg-surface-panel px-3 py-1.5 font-mono text-xs text-fg`,`placeholder:text-fg-subtle`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`dark:border-edge`),placeholder:f.purgeConfirmPlaceholder.replace(`{{agentId}}`,s.id),value:c,onChange:e=>l(e.target.value)}),(0,Q.jsx)(`p`,{className:`pt-0.5 text-xs text-fg-muted`,children:f.purgeConfirmHint.replace(`{{agentId}}`,s.id)})]}):null,t[6]=f.purgeConfirmHint,t[7]=f.purgeConfirmLabel,t[8]=f.purgeConfirmPlaceholder,t[9]=c,t[10]=o,t[11]=s,t[12]=l,t[13]=b):b=t[13];let x;t[14]!==f.createModalCancel||t[15]!==a||t[16]!==d?(x=(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,disabled:a,onClick:d,children:f.createModalCancel}),t[14]=f.createModalCancel,t[15]=a,t[16]=d,t[17]=x):x=t[17];let S=o?`border-red-200 text-red-700 hover:bg-red-50 dark:border-red-900/60 dark:text-red-300 dark:hover:bg-red-950/40`:void 0,C;t[18]!==a||t[19]!==c||t[20]!==o||t[21]!==s?(C=a||!s||o&&c.trim().toLowerCase()!==s.id.toLowerCase(),t[18]=a,t[19]=c,t[20]=o,t[21]=s,t[22]=C):C=t[22];let w=o?f.purgeDisk:f.removeFromConfig,T;t[23]!==u||t[24]!==C||t[25]!==w||t[26]!==S?(T=(0,Q.jsx)(Y,{type:`button`,variant:`secondary`,className:S,disabled:C,onClick:u,children:w}),t[23]=u,t[24]=C,t[25]=w,t[26]=S,t[27]=T):T=t[27];let E;t[28]!==T||t[29]!==x?(E=(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-end gap-2 border-t border-edge-subtle/60 pt-3`,children:[x,T]}),t[28]=T,t[29]=x,t[30]=E):E=t[30];let D;t[31]!==E||t[32]!==_||t[33]!==y||t[34]!==b?(D=(0,Q.jsxs)(O,{children:[p,(0,Q.jsxs)(Ne,{className:h,onOpenAutoFocus:jt,children:[_,y,b,E]})]}),t[31]=E,t[32]=_,t[33]=y,t[34]=b,t[35]=D):D=t[35];let k;return t[36]!==r||t[37]!==n||t[38]!==D?(k=(0,Q.jsx)(j,{open:n,onOpenChange:r,children:D}),t[36]=r,t[37]=n,t[38]=D,t[39]=k):k=t[39],k}function jt(e){return e.preventDefault()}var Mt=[{id:`overview`,labelKey:`navIdentity`,icon:Ue},{id:`models`,labelKey:`navModels`,icon:M},{id:`tools`,labelKey:`navTools`,icon:Qe},{id:`skills`,labelKey:`navSkills`,icon:f},{id:`memory`,labelKey:`tabMemory`,icon:Me},{id:`effective`,labelKey:`navEffective`,icon:I},{id:`files`,labelKey:`navCoreFiles`,icon:oe}],Nt=[{id:`channels`,labelKey:`tabChannels`,icon:He}];function Pt(e){let t=(0,Z.c)(20),{a:n,panel:r,onPanelChange:a}=e,o;t[0]!==a||t[1]!==r?(o=(e,t,n)=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>a(e),className:i(`flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-left text-sm font-medium transition-colors`,Ye.press,r===e?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:[(0,Q.jsx)(n,{className:`size-4 shrink-0 opacity-90`,strokeWidth:2,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:t})]},e),t[0]=a,t[1]=r,t[2]=o):o=t[2];let s=o,c=n.editorNavAria,l;t[3]!==n||t[4]!==s?(l=Mt.map(e=>{let{id:t,labelKey:r,icon:i}=e;return s(t,n[r],i)}),t[3]=n,t[4]=s,t[5]=l):l=t[5];let u;t[6]===l?u=t[7]:(u=(0,Q.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:l}),t[6]=l,t[7]=u);let d;t[8]===n.navAdvanced?d=t[9]:(d=(0,Q.jsx)(`p`,{className:`mt-4 px-3 text-[10px] font-semibold uppercase tracking-wide text-fg-subtle`,children:n.navAdvanced}),t[8]=n.navAdvanced,t[9]=d);let f;t[10]!==n||t[11]!==s?(f=Nt.map(e=>{let{id:t,labelKey:r,icon:i}=e;return s(t,n[r],i)}),t[10]=n,t[11]=s,t[12]=f):f=t[12];let p;t[13]===f?p=t[14]:(p=(0,Q.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:f}),t[13]=f,t[14]=p);let m;return t[15]!==n.editorNavAria||t[16]!==u||t[17]!==d||t[18]!==p?(m=(0,Q.jsxs)(`nav`,{className:`flex w-full flex-col gap-1`,"aria-label":c,children:[u,d,p]}),t[15]=n.editorNavAria,t[16]=u,t[17]=d,t[18]=p,t[19]=m):m=t[19],m}function Ft(e){let t=(0,Z.c)(49),{open:n,onOpenChange:r,a,title:o,subtitle:s,panel:c,onPanelChange:l,onFooterSave:u,footerSaveDisabled:d,footerSavedFlash:f,busy:p,children:h}=e,g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Q.jsx)(Ae,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim`,te)}),t[0]=g):g=t[0];let _;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(_=i(`xopc-dialog-content fixed flex flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,ae,`inset-4 h-[calc(100dvh-2rem)] max-h-[calc(100dvh-2rem)] min-h-0`,`sm:inset-auto sm:left-1/2 sm:top-1/2 sm:h-[min(88vh,48rem)] sm:max-h-[min(88vh,48rem)] sm:min-h-[32rem] sm:w-[min(100%-2rem,58rem)] sm:-translate-x-1/2 sm:-translate-y-1/2`),t[1]=_):_=t[1];let v;t[2]===o?v=t[3]:(v=(0,Q.jsx)(ee,{className:`text-base font-semibold leading-snug text-fg`,children:o}),t[2]=o,t[3]=v);let y;t[4]===s?y=t[5]:(y=(0,Q.jsx)(m,{className:`mt-1 font-mono text-xs text-fg-muted`,children:s}),t[4]=s,t[5]=y);let b;t[6]!==v||t[7]!==y?(b=(0,Q.jsxs)(`div`,{className:`min-w-0 pr-2`,children:[v,y]}),t[6]=v,t[7]=y,t[8]=b):b=t[8];let x;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(x=i(ye,`shrink-0 p-1.5 hover:bg-surface-base`),t[9]=x):x=t[9];let S;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Q.jsx)(Fe,{className:`size-4`,"aria-hidden":!0}),t[10]=S):S=t[10];let C;t[11]===a.closeDialogAria?C=t[12]:(C=(0,Q.jsx)(P,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:x,"aria-label":a.closeDialogAria,children:S})}),t[11]=a.closeDialogAria,t[12]=C);let w;t[13]!==b||t[14]!==C?(w=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-2 border-b border-edge-subtle px-4 pb-3 pt-4 dark:border-edge`,children:[b,C]}),t[13]=b,t[14]=C,t[15]=w):w=t[15];let T;t[16]!==a||t[17]!==l||t[18]!==c?(T=(0,Q.jsx)(`div`,{className:`shrink-0 border-b border-edge-subtle px-4 py-3 dark:border-edge sm:flex sm:w-56 sm:shrink-0 sm:flex-col sm:overflow-y-auto sm:border-b-0 sm:border-r sm:px-0 sm:py-4 sm:pl-4 sm:pr-3`,children:(0,Q.jsx)(Pt,{a,panel:c,onPanelChange:l})}),t[16]=a,t[17]=l,t[18]=c,t[19]=T):T=t[19];let E;t[20]===h?E=t[21]:(E=(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden p-4 sm:pl-2 sm:pr-5`,children:h}),t[20]=h,t[21]=E);let D;t[22]!==a.footerSaveNotApplicable||t[23]!==a.personaSaved||t[24]!==d||t[25]!==f?(D=f?(0,Q.jsxs)(`p`,{className:`order-2 text-center text-xs font-medium text-green-600 sm:order-1 sm:mr-auto sm:text-left dark:text-green-400`,children:[`✓ `,a.personaSaved]}):d?(0,Q.jsx)(`p`,{className:`order-2 text-center text-xs text-fg-muted sm:order-1 sm:mr-auto sm:text-left`,children:a.footerSaveNotApplicable}):null,t[22]=a.footerSaveNotApplicable,t[23]=a.personaSaved,t[24]=d,t[25]=f,t[26]=D):D=t[26];let k=p||d,A;t[27]===u?A=t[28]:(A=()=>void u(),t[27]=u,t[28]=A);let M;t[29]!==a.save||t[30]!==k||t[31]!==A?(M=(0,Q.jsx)(Y,{type:`button`,className:`order-1 w-full sm:order-2 sm:w-auto`,disabled:k,onClick:A,children:a.save}),t[29]=a.save,t[30]=k,t[31]=A,t[32]=M):M=t[32];let N;t[33]!==D||t[34]!==M?(N=(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-1 border-t border-edge-subtle px-4 py-3 dark:border-edge sm:flex-row sm:items-center sm:justify-end sm:gap-3`,children:[D,M]}),t[33]=D,t[34]=M,t[35]=N):N=t[35];let F;t[36]!==E||t[37]!==N?(F=(0,Q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[E,N]}),t[36]=E,t[37]=N,t[38]=F):F=t[38];let I;t[39]!==F||t[40]!==T?(I=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col sm:flex-row sm:overflow-hidden`,children:[T,F]}),t[39]=F,t[40]=T,t[41]=I):I=t[41];let L;t[42]!==I||t[43]!==w?(L=(0,Q.jsxs)(O,{children:[g,(0,Q.jsx)(Ne,{className:_,onOpenAutoFocus:It,children:(0,Q.jsxs)(Ke,{layer:`modal`,children:[w,I]})})]}),t[42]=I,t[43]=w,t[44]=L):L=t[44];let ne;return t[45]!==r||t[46]!==n||t[47]!==L?(ne=(0,Q.jsx)(j,{open:n,onOpenChange:r,children:L}),t[45]=r,t[46]=n,t[47]=L,t[48]=ne):ne=t[48],ne}function It(e){return e.preventDefault()}var $=e(t(),1),Lt=e=>u(e);function Rt(e){return!e||e.total<=0?null:Math.round(e.helpful/e.total*100)}function zt(e){let t=Rt(e);return t==null?`border-edge bg-surface-panel text-fg-muted`:t>=70?`border-success/30 bg-success-soft text-fg`:t>=40?`border-warning/40 bg-warning-soft text-fg`:`border-danger/30 bg-danger-soft text-fg`}function Bt({embedded:e=!1,agentId:t}){let n=a(o(e=>e.language)).agentsSettings.memoryPanel,[r,i]=(0,$.useState)(``),[s,c]=(0,$.useState)(``),[f,p]=(0,$.useState)(``),[m,h]=(0,$.useState)({}),[g,_]=(0,$.useState)({searchStrategy:`fanout`,writeStrategy:`local-first`,allowExternalWrites:!1,allowedProviderIds:[],autoWriteKinds:[]}),{data:v}=d(l(`/api/memory/providers`),Lt),{data:y,mutate:b}=d(l(`/api/memory/records?status=active&limit=80`),Lt),{data:x,mutate:S}=d(l(`/api/memory/records?status=candidate&limit=80`),Lt),{data:C}=d(l(`/api/memory/signals?limit=50`),Lt),{data:w,mutate:T}=d(l(`/api/memory/traces?limit=80`),Lt),{data:E}=d(l(`/api/memory/feedback-summary?limit=1000`),Lt),{data:D,mutate:O}=d(l(`/api/memory/config${t?`?agentId=${encodeURIComponent(t)}`:``}`),Lt),{data:k,isLoading:A}=d(s?l(`/api/memory/search`):null,e=>u(e,{method:`POST`,body:JSON.stringify({query:s,maxResults:20})})),j=k?.results.map(e=>({...e.record,score:e.score}))??y?.records??[],M=v?.providers.length??0,N=y?.records.length??0,P=x?.records.length??0,F=C?.signals.length??0,I=w?.traces.length??0,ee=E?.summaries??[],L=(0,$.useMemo)(()=>new Map(ee.map(e=>[e.recordId,e])),[ee]),te=ee.reduce((e,t)=>e+t.total,0),ne=ee.reduce((e,t)=>e+t.helpful,0),R=te>0?Math.round(ne/te*100):null,re=(0,$.useMemo)(()=>[{label:n.providers,value:M},{label:n.records,value:N},{label:n.inbox,value:P},{label:n.signals,value:F},{label:n.traceEvents,value:I},{label:n.recallQuality,value:R==null?`—`:`${R}%`}],[P,R,M,N,F,n.inbox,n.providers,n.recallQuality,n.records,n.signals,n.traceEvents,I]);(0,$.useEffect)(()=>{let e=D?.memory.providerRouting;e&&_({searchStrategy:e.searchStrategy??`fanout`,writeStrategy:e.writeStrategy??`local-first`,allowExternalWrites:e.allowExternalWrites??!1,allowedProviderIds:e.allowedProviderIds??[],autoWriteKinds:e.autoWriteKinds??[]})},[D]);async function z(){if(D){p(n.saving);try{await u(l(`/api/memory/config`),{method:`PATCH`,body:JSON.stringify({agentId:D.agentId,memory:{...D.memory,providerRouting:g}})}),await O(),p(n.saved)}catch(e){p(e instanceof Error?e.message:n.saveFailed)}}}async function B(e){h(t=>({...t,[e]:n.testing}));try{let t=(await u(l(`/api/memory/providers/${encodeURIComponent(e)}/test`),{method:`POST`})).checks.find(e=>!e.ok);h(r=>({...r,[e]:t?`${t.name}: ${t.message??n.checkFailed}`:n.testPassed})),T()}catch(t){h(r=>({...r,[e]:t instanceof Error?t.message:n.testFailed}))}}async function V(e,t){await u(l(`/api/memory/records/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({status:t})}),await Promise.all([S(),b()])}return(0,Q.jsxs)(`div`,{className:e?`flex min-h-0 w-full flex-1 flex-col gap-5 overflow-y-auto overscroll-contain pr-1`:`mx-auto flex w-full max-w-app-main flex-1 flex-col gap-5 px-4 py-6`,children:[e?null:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h1`,{className:`text-xl font-semibold text-fg`,children:n.title}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle})]}),(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-6`,children:re.map(e=>(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface px-4 py-3`,children:[(0,Q.jsx)(`div`,{className:`text-xs text-fg-muted`,children:e.label}),(0,Q.jsx)(`div`,{className:`mt-1 text-2xl font-semibold text-fg`,children:e.value})]},e.label))}),(0,Q.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface`,children:[(0,Q.jsx)(`div`,{className:`border-b border-edge px-4 py-3 text-sm font-semibold text-fg`,children:n.providerPolicy}),(0,Q.jsxs)(`div`,{className:`grid gap-3 p-4 md:grid-cols-2`,children:[(0,Q.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[n.searchStrategy,(0,Q.jsx)(`select`,{className:`mt-1 min-h-10 w-full rounded-md border border-edge bg-surface-panel px-3 text-sm text-fg`,value:g.searchStrategy,onChange:e=>_(t=>({...t,searchStrategy:e.target.value})),children:[`fanout`,`local-first`,`external-first`,`local-only`,`external-only`].map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))})]}),(0,Q.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[n.writeStrategy,(0,Q.jsx)(`select`,{className:`mt-1 min-h-10 w-full rounded-md border border-edge bg-surface-panel px-3 text-sm text-fg`,value:g.writeStrategy,onChange:e=>_(t=>({...t,writeStrategy:e.target.value})),children:[`local-first`,`write-through`,`external-first`,`local-only`,`external-only`].map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))})]}),(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg md:col-span-2`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:g.allowExternalWrites,onChange:e=>_(t=>({...t,allowExternalWrites:e.target.checked}))}),n.allowExternalWrites]}),(0,Q.jsxs)(`div`,{className:`md:col-span-2`,children:[(0,Q.jsx)(`div`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:n.writableProviders}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(v?.providers??[]).filter(e=>!e.capabilities.local).map(e=>(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md border border-edge px-3 py-2 text-sm text-fg`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:g.allowedProviderIds?.includes(e.id)??!1,onChange:t=>_(n=>({...n,allowedProviderIds:t.target.checked?[...n.allowedProviderIds??[],e.id]:(n.allowedProviderIds??[]).filter(t=>t!==e.id)}))}),e.displayName]},e.id))})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 md:col-span-2`,children:[(0,Q.jsx)(Y,{type:`button`,variant:`primary`,onClick:z,children:n.savePolicy}),f?(0,Q.jsx)(`span`,{className:`text-sm text-fg-muted`,children:f}):null]})]})]}),(0,Q.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.inbox}),(0,Q.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.inboxHint})]}),(0,Q.jsx)(`div`,{className:`text-xs text-fg-muted`,children:P})]}),(0,Q.jsxs)(`div`,{className:`divide-y divide-edge`,children:[(x?.records??[]).map(e=>(0,Q.jsxs)(`article`,{className:`px-4 py-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:e.kind}),(0,Q.jsx)(`span`,{children:e.sensitivity??`normal`}),(0,Q.jsx)(`span`,{children:e.source.provider??`local`}),e.confidence==null?null:(0,Q.jsxs)(`span`,{children:[Math.round(e.confidence*100),`%`]})]}),(0,Q.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-sm leading-6 text-fg`,children:e.content}),e.evidence?.[0]?.sourceText?(0,Q.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.evidence[0].sourceText}):null,(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(Y,{type:`button`,variant:`primary`,onClick:()=>V(e.id,`active`),children:n.approve}),(0,Q.jsx)(Y,{type:`button`,variant:`secondary`,onClick:()=>V(e.id,`rejected`),children:n.reject}),(0,Q.jsx)(Y,{type:`button`,variant:`secondary`,onClick:()=>V(e.id,`needs_review`),children:n.needsReview})]})]},e.id)),P===0?(0,Q.jsx)(`div`,{className:`px-4 py-8 text-sm text-fg-muted`,children:n.noInbox}):null]})]}),(0,Q.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),c(r.trim())},children:[(0,Q.jsx)(`input`,{className:`min-h-10 flex-1 rounded-md border border-edge bg-surface px-3 text-sm text-fg outline-none focus:border-accent`,value:r,onChange:e=>i(e.target.value),placeholder:n.searchPlaceholder}),(0,Q.jsx)(Y,{className:`min-h-10 rounded-md px-4`,type:`submit`,variant:`primary`,children:n.search})]}),(0,Q.jsxs)(`section`,{className:`grid gap-4 lg:grid-cols-[minmax(0,1fr)_20rem]`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge bg-surface`,children:[(0,Q.jsx)(`div`,{className:`border-b border-edge px-4 py-3 text-sm font-semibold text-fg`,children:s?`${n.searchResults}${A?`…`:``}`:n.recentRecords}),(0,Q.jsxs)(`div`,{className:`divide-y divide-edge`,children:[j.map(e=>{let t=L.get(e.id),r=Rt(t);return(0,Q.jsxs)(`article`,{className:`px-4 py-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:e.kind}),e.status?(0,Q.jsx)(`span`,{children:e.status}):null,e.sensitivity?(0,Q.jsx)(`span`,{children:e.sensitivity}):null,(0,Q.jsx)(`span`,{children:e.source.provider??`local`}),e.source.path?(0,Q.jsx)(`span`,{children:e.source.path}):null,(0,Q.jsx)(`span`,{className:`rounded-full border px-2 py-0.5 ${zt(t)}`,children:r==null?n.noRecallFeedback:`${n.recallQuality} ${r}% · ${t?.total??0}`})]}),(0,Q.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-sm leading-6 text-fg`,children:e.content}),t?(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2 text-xs text-fg-muted`,children:[(0,Q.jsxs)(`span`,{children:[n.helpful,`: `,t.helpful]}),(0,Q.jsxs)(`span`,{children:[n.notHelpful,`: `,t.notHelpful]}),t.mixed?(0,Q.jsxs)(`span`,{children:[n.mixed,`: `,t.mixed]}):null,t.irrelevant?(0,Q.jsxs)(`span`,{children:[n.irrelevant,`: `,t.irrelevant]}):null]}):null]},e.id)}),j.length===0?(0,Q.jsx)(`div`,{className:`px-4 py-8 text-sm text-fg-muted`,children:n.noRecords}):null]})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface`,children:[(0,Q.jsx)(`div`,{className:`border-b border-edge px-4 py-3 text-sm font-semibold text-fg`,children:n.providers}),(0,Q.jsx)(`div`,{className:`divide-y divide-edge`,children:(v?.providers??[]).map(e=>(0,Q.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.displayName}),(0,Q.jsxs)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:[e.id,` · `,e.available?n.available:n.unavailable]}),(0,Q.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,Q.jsx)(Y,{type:`button`,variant:`secondary`,onClick:()=>B(e.id),children:n.test}),m[e.id]?(0,Q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:m[e.id]}):null]})]},e.id))})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface`,children:[(0,Q.jsx)(`div`,{className:`border-b border-edge px-4 py-3 text-sm font-semibold text-fg`,children:n.recallQuality}),(0,Q.jsxs)(`div`,{className:`divide-y divide-edge`,children:[ee.slice(0,8).map(e=>{let t=(y?.records??[]).find(t=>t.id===e.recordId),r=Rt(e);return(0,Q.jsxs)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`div`,{className:`min-w-0 font-medium text-fg`,children:t?.kind??n.record}),(0,Q.jsxs)(`span`,{className:`shrink-0 rounded-full border px-2 py-0.5 ${zt(e)}`,children:[r??0,`%`]})]}),(0,Q.jsx)(`div`,{className:`mt-1 line-clamp-2 text-fg-muted`,children:t?.content??e.recordId}),(0,Q.jsxs)(`div`,{className:`mt-2`,children:[e.helpful,` `,n.helpful,` · `,e.notHelpful,` `,n.notHelpful,` · `,e.total,` `,n.feedback]})]},e.recordId)}),ee.length===0?(0,Q.jsx)(`div`,{className:`px-4 py-8 text-sm text-fg-muted`,children:n.noRecallFeedback}):null]})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface`,children:[(0,Q.jsx)(`div`,{className:`border-b border-edge px-4 py-3 text-sm font-semibold text-fg`,children:n.signals}),(0,Q.jsx)(`div`,{className:`divide-y divide-edge`,children:(C?.signals??[]).map(e=>(0,Q.jsxs)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:[(0,Q.jsx)(`div`,{className:`font-medium text-fg`,children:e.source}),(0,Q.jsxs)(`div`,{children:[e.providerId??`local`,` · `,new Date(e.createdAt).toLocaleString()]})]},e.signalId))})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface`,children:[(0,Q.jsx)(`div`,{className:`border-b border-edge px-4 py-3 text-sm font-semibold text-fg`,children:n.trace}),(0,Q.jsx)(`div`,{className:`divide-y divide-edge`,children:(w?.traces??[]).slice(0,20).map(e=>(0,Q.jsxs)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:[(0,Q.jsxs)(`div`,{className:`font-medium text-fg`,children:[e.phase,` · `,e.providerId]}),(0,Q.jsxs)(`div`,{children:[e.resultCount??0,` `,(e.resultCount??0)===1?n.result:n.results,` · `,e.durationMs,` ms`]}),e.skippedReason?(0,Q.jsxs)(`div`,{children:[n.skipped,`: `,e.skippedReason]}):null,e.error?(0,Q.jsx)(`div`,{className:`text-danger`,children:e.error}):null]},e.traceId))})]})]})]})]})}var Vt=i(ue,`w-full text-xs sm:w-auto sm:min-w-[11rem] sm:max-w-[17rem] sm:shrink-0`);function Ht(e){let t=(0,Z.c)(62),{a:n,busy:r,bindingsLoading:a,agentBindings:o,onRemoveBinding:s,onAddBinding:c,channelStatuses:l,channelsStatusLoading:u,useManualChannel:d,newBindChannel:f,setNewBindChannel:p,bindSessionChats:m,sessionsLoading:h,newBindSessionIdx:g,setNewBindSessionIdx:_,newBindCustomPeer:v,setNewBindCustomPeer:y,onRefreshSessions:b,lastActiveLabels:x,selectRecipient:S}=e,C=!u&&(d||l.length>0),w;t[0]!==n.channelsHint||t[1]!==n.channelsTitle?(w=(0,Q.jsx)(ut,{className:`shrink-0`,icon:Pe,title:n.channelsTitle,subtitle:n.channelsHint}),t[0]=n.channelsHint,t[1]=n.channelsTitle,t[2]=w):w=t[2];let T;t[3]!==n.channelsLoading||t[4]!==n.channelsNone||t[5]!==n.removeBinding||t[6]!==o||t[7]!==a||t[8]!==r||t[9]!==s?(T=a?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.channelsLoading}):o.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.channelsNone}):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2 text-sm`,children:o.map(e=>(0,Q.jsxs)(`li`,{className:`flex flex-wrap items-center justify-between gap-2 rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`font-mono text-xs`,children:yt(e.match)}),(0,Q.jsx)(Y,{type:`button`,variant:`secondary`,disabled:r,onClick:()=>void s(e),children:n.removeBinding})]},`${e.match.channel}-${yt(e.match)}`))}),t[3]=n.channelsLoading,t[4]=n.channelsNone,t[5]=n.removeBinding,t[6]=o,t[7]=a,t[8]=r,t[9]=s,t[10]=T):T=t[10];let E;t[11]!==n.channelLabel||t[12]!==n.channelsDisabledSuffix||t[13]!==n.channelsLoadingChannels||t[14]!==n.channelsManualChannelHint||t[15]!==l||t[16]!==u||t[17]!==f||t[18]!==p||t[19]!==y||t[20]!==_||t[21]!==d?(E=u?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.channelsLoadingChannels}):d?(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,Q.jsx)(`span`,{className:`text-fg-muted`,children:n.channelLabel}),(0,Q.jsx)(`input`,{className:bt(),value:f,onChange:e=>p(e.target.value),placeholder:`telegram`,autoComplete:`off`}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.channelsManualChannelHint})]}):(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,Q.jsx)(`span`,{className:`text-fg-muted`,children:n.channelLabel}),(0,Q.jsx)(`select`,{className:i(bt(),`py-2`),value:f,onChange:e=>{p(e.target.value),_(null),y(``)},children:l.map(e=>(0,Q.jsxs)(`option`,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:n.channelsDisabledSuffix]},e.name))})]}),t[11]=n.channelLabel,t[12]=n.channelsDisabledSuffix,t[13]=n.channelsLoadingChannels,t[14]=n.channelsManualChannelHint,t[15]=l,t[16]=u,t[17]=f,t[18]=p,t[19]=y,t[20]=_,t[21]=d,t[22]=E):E=t[22];let D;t[23]!==n.channelsCustomPeerHint||t[24]!==n.channelsCustomPeerPlaceholder||t[25]!==n.channelsLoadingSessions||t[26]!==n.channelsNoSessionsHint||t[27]!==n.channelsPeerAny||t[28]!==n.channelsPeerFromSessions||t[29]!==n.channelsRefreshSessions||t[30]!==n.channelsRefreshSessionsHint||t[31]!==n.channelsSessionLabel||t[32]!==n.peerIdLabel||t[33]!==m||t[34]!==r||t[35]!==x||t[36]!==f||t[37]!==v||t[38]!==g||t[39]!==b||t[40]!==S||t[41]!==h||t[42]!==y||t[43]!==_||t[44]!==C?(D=C&&f.trim()?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge-subtle pt-3 text-sm`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-fg-muted`,children:n.channelsSessionLabel}),(0,Q.jsxs)(Y,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,disabled:r||h||!f.trim(),title:n.channelsRefreshSessionsHint,onClick:()=>b(),children:[(0,Q.jsx)(W,{className:i(`size-3.5`,h&&`animate-spin`),strokeWidth:1.75}),n.channelsRefreshSessions]})]}),h&&m.length===0?(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.channelsLoadingSessions}):null,(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-fg-muted`,children:n.channelsPeerFromSessions}),(0,Q.jsxs)(`select`,{className:i(bt(),`py-2`),value:g==null?``:String(g),disabled:r||!f.trim()||!!v.trim(),onChange:e=>{let t=e.target.value;_(t===``?null:Number(t))},children:[(0,Q.jsx)(`option`,{value:``,children:n.channelsPeerAny}),m.map((e,t)=>(0,Q.jsx)(`option`,{value:String(t),children:_t(e,x)},`${e.channel}-${e.chatId}`))]})]}),m.length===0&&f.trim()&&!h?(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.channelsNoSessionsHint}):null,(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-fg-muted`,children:n.peerIdLabel}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch sm:gap-2`,children:[(0,Q.jsx)(`input`,{type:`text`,className:i(bt(),`min-w-0 w-full sm:flex-1`),value:v,onChange:e=>{y(e.target.value),e.target.value.trim()&&_(null)},placeholder:n.channelsCustomPeerPlaceholder,autoComplete:`off`}),(0,Q.jsxs)(`select`,{className:Vt,value:v,onChange:e=>{let t=e.target.value;y(t||``),_(null)},children:[(0,Q.jsx)(`option`,{value:``,children:S}),m.map(e=>(0,Q.jsx)(`option`,{value:e.chatId,children:_t(e,x)},`${e.channel}-${e.chatId}`))]})]}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.channelsCustomPeerHint})]})]}):null,t[23]=n.channelsCustomPeerHint,t[24]=n.channelsCustomPeerPlaceholder,t[25]=n.channelsLoadingSessions,t[26]=n.channelsNoSessionsHint,t[27]=n.channelsPeerAny,t[28]=n.channelsPeerFromSessions,t[29]=n.channelsRefreshSessions,t[30]=n.channelsRefreshSessionsHint,t[31]=n.channelsSessionLabel,t[32]=n.peerIdLabel,t[33]=m,t[34]=r,t[35]=x,t[36]=f,t[37]=v,t[38]=g,t[39]=b,t[40]=S,t[41]=h,t[42]=y,t[43]=_,t[44]=C,t[45]=D):D=t[45];let O;t[46]!==r||t[47]!==u||t[48]!==f?(O=r||!f.trim()||u,t[46]=r,t[47]=u,t[48]=f,t[49]=O):O=t[49];let k;t[50]!==n.addBinding||t[51]!==O?(k=(0,Q.jsx)(`div`,{children:(0,Q.jsx)(Y,{type:`submit`,disabled:O,children:n.addBinding})}),t[50]=n.addBinding,t[51]=O,t[52]=k):k=t[52];let A;t[53]!==c||t[54]!==E||t[55]!==D||t[56]!==k?(A=(0,Q.jsxs)(`form`,{className:`mt-4 flex flex-col gap-3`,onSubmit:c,children:[E,D,k]}),t[53]=c,t[54]=E,t[55]=D,t[56]=k,t[57]=A):A=t[57];let j;return t[58]!==w||t[59]!==T||t[60]!==A?(j=(0,Q.jsxs)(dt,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[w,T,A]}),t[58]=w,t[59]=T,t[60]=A,t[61]=j):j=t[61],j}function Ut(e,t){for(let n of t){let t=e[n];if(t)return t}return`default`}function Wt(e){let t=(0,Z.c)(5),{source:n}=e,r;if(t[0]!==n){let e=n.startsWith(`preset:`),a=n.startsWith(`agent:`);r=i(`shrink-0 rounded-full border px-2 py-0.5 text-[11px] font-medium`,e&&`border-accent/25 bg-accent/10 text-accent`,a&&`border-edge bg-surface-base text-fg-muted`,!e&&!a&&`border-edge-subtle bg-surface-panel text-fg-subtle`),t[0]=n,t[1]=r}else r=t[1];let a;return t[2]!==n||t[3]!==r?(a=(0,Q.jsx)(`span`,{className:r,children:n}),t[2]=n,t[3]=r,t[4]=a):a=t[4],a}function Gt(e){let t=(0,Z.c)(13),n;t[0]===e.name?n=t[1]:(n=(0,Q.jsx)(`div`,{className:`min-w-0 truncate font-mono text-xs font-medium text-fg`,children:e.name}),t[0]=e.name,t[1]=n);let r=e.monoValue&&`font-mono text-xs`,a;t[2]===r?a=t[3]:(a=i(`min-w-0 truncate text-sm text-fg`,r),t[2]=r,t[3]=a);let o;t[4]!==e.value||t[5]!==a?(o=(0,Q.jsx)(`div`,{className:a,children:e.value}),t[4]=e.value,t[5]=a,t[6]=o):o=t[6];let s;t[7]===e.source?s=t[8]:(s=(0,Q.jsx)(Wt,{source:e.source}),t[7]=e.source,t[8]=s);let c;return t[9]!==n||t[10]!==o||t[11]!==s?(c=(0,Q.jsxs)(`div`,{className:`grid gap-2 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2 sm:grid-cols-[minmax(0,10rem)_minmax(0,1fr)_auto] sm:items-center`,children:[n,o,s]}),t[9]=n,t[10]=o,t[11]=s,t[12]=c):c=t[12],c}function Kt(e,t){return e&&e.length>0?e.join(`, `):t}function qt(e){let t=(0,Z.c)(30),{a:n,selected:r}=e,i;t[0]===r.id?i=t[1]:(i=r.id?[`agent-effective-manifest`,r.id]:null,t[0]=r.id,t[1]=i);let a;t[2]===r.id?a=t[3]:(a=()=>et(r.id),t[2]=r.id,t[3]=a);let o;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(o={revalidateOnFocus:!1},t[4]=o):o=t[4];let{data:s,error:c,isLoading:l}=d(i,a,o),u=s?.manifest,f;t[5]!==s?.presetChain||t[6]!==u?.extends?(f=s?.presetChain??u?.extends??[],t[5]=s?.presetChain,t[6]=u?.extends,t[7]=f):f=t[7];let p=f,m;if(t[8]!==n.effectiveBoundariesTitle||t[9]!==n.effectiveEmpty||t[10]!==n.effectiveError||t[11]!==n.effectiveHint||t[12]!==n.effectiveLoading||t[13]!==n.effectiveMemoryTitle||t[14]!==n.effectiveModelsTitle||t[15]!==n.effectiveNoPresets||t[16]!==n.effectiveNoToolPolicies||t[17]!==n.effectivePresetChain||t[18]!==n.effectiveSkillsTitle||t[19]!==n.effectiveTitle||t[20]!==n.effectiveToolsTitle||t[21]!==s?.sources||t[22]!==c||t[23]!==l||t[24]!==u||t[25]!==p){let e=s?.sources??{},r=Object.entries(u?.models?.roles??{}).sort(Yt),i=Object.entries(u?.tools?.builtin??{}).sort(Jt),a=u?.skills,o=u?.memory,d=u?.boundaries,f;t[27]!==n.effectiveHint||t[28]!==n.effectiveTitle?(f=(0,Q.jsx)(ut,{className:`shrink-0`,icon:I,title:n.effectiveTitle,subtitle:n.effectiveHint}),t[27]=n.effectiveHint,t[28]=n.effectiveTitle,t[29]=f):f=t[29],m=(0,Q.jsxs)(dt,{className:`flex min-h-0 flex-1 flex-col`,children:[f,l?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.effectiveLoading}):c?(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:c instanceof Error?c.message:n.effectiveError}):u?(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain pr-1`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:n.effectivePresetChain}),(0,Q.jsx)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2 text-sm text-fg`,children:p.length?p.join(` -> `):n.effectiveNoPresets})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:n.effectiveModelsTitle}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(Gt,{name:`defaultRole`,value:u.models?.defaultRole??`—`,source:Ut(e,[`models.defaultRole`])}),r.map(t=>{let[n,r]=t;return(0,Q.jsx)(Gt,{name:n,value:r.model,monoValue:!0,source:Ut(e,[`models.roles.${n}.model`,`models.roles.${n}`])},n)})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:n.effectiveToolsTitle}),i.length>0?(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:i.map(t=>{let[n,r]=t;return(0,Q.jsx)(Gt,{name:n,value:r.mode,source:Ut(e,[`tools.builtin.${n}.mode`,`tools.builtin.${n}`])},n)})}):(0,Q.jsx)(`p`,{className:`rounded-lg border border-dashed border-edge-subtle px-3 py-2 text-sm text-fg-muted`,children:n.effectiveNoToolPolicies})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:n.effectiveSkillsTitle}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(Gt,{name:`mode`,value:a?.mode??`all`,source:Ut(e,[`skills.mode`,`skills`])}),a?.mode===`allowlist`?(0,Q.jsx)(Gt,{name:`allow`,value:Kt(a.allow,`—`),source:Ut(e,[`skills.allow`,`skills`])}):null,a?.mode===`denylist`?(0,Q.jsx)(Gt,{name:`deny`,value:Kt(a.deny,`—`),source:Ut(e,[`skills.deny`,`skills`])}):null]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:n.effectiveMemoryTitle}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(Gt,{name:`mode`,value:o?.mode??`off`,source:Ut(e,[`memory.mode`,`memory`])}),(0,Q.jsx)(Gt,{name:`sources`,value:Kt(o?.sources,`—`),source:Ut(e,[`memory.sources`,`memory`])})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:n.effectiveBoundariesTitle}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(Gt,{name:`requiresConfirmation`,value:Kt(d?.requiresConfirmation,`—`),source:Ut(e,[`boundaries.requiresConfirmation`,`boundaries`])}),(0,Q.jsx)(Gt,{name:`forbidden`,value:Kt(d?.forbidden,`—`),source:Ut(e,[`boundaries.forbidden`,`boundaries`])}),(0,Q.jsx)(Gt,{name:`escalation`,value:Kt(d?.escalation,`—`),source:Ut(e,[`boundaries.escalation`,`boundaries`])})]})]})]})}):(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.effectiveEmpty})]}),t[8]=n.effectiveBoundariesTitle,t[9]=n.effectiveEmpty,t[10]=n.effectiveError,t[11]=n.effectiveHint,t[12]=n.effectiveLoading,t[13]=n.effectiveMemoryTitle,t[14]=n.effectiveModelsTitle,t[15]=n.effectiveNoPresets,t[16]=n.effectiveNoToolPolicies,t[17]=n.effectivePresetChain,t[18]=n.effectiveSkillsTitle,t[19]=n.effectiveTitle,t[20]=n.effectiveToolsTitle,t[21]=s?.sources,t[22]=c,t[23]=l,t[24]=u,t[25]=p,t[26]=m}else m=t[26];return m}function Jt(e,t){let[n]=e,[r]=t;return n.localeCompare(r)}function Yt(e,t){let[n]=e,[r]=t;return n.localeCompare(r)}function Xt(e){let t=(0,Z.c)(29),{a:n,filesLoading:r,files:a,activeFile:o,setActiveFile:c,filesViewMode:l,setFilesViewMode:u,fileDraft:d,setFileDraft:f,fileSaving:p,profileFileLoading:m,profileEditorNonce:h,onTryInChat:g}=e,_=s(Zt),v;t[0]===n.filesHint?v=t[1]:(v=(0,Q.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:n.filesHint}),t[0]=n.filesHint,t[1]=v);let y;t[2]!==n.filesAutoSaveHint||t[3]!==n.filesEmpty||t[4]!==n.filesLoading||t[5]!==n.filesMarkdownEdit||t[6]!==n.filesMarkdownPreview||t[7]!==n.filesSavingStatus||t[8]!==n.missing||t[9]!==n.navCoreFiles||t[10]!==n.pickFile||t[11]!==n.tryInChat||t[12]!==o||t[13]!==d||t[14]!==p||t[15]!==a||t[16]!==r||t[17]!==l||t[18]!==_||t[19]!==g||t[20]!==h||t[21]!==m||t[22]!==c||t[23]!==f||t[24]!==u?(y=r?(0,Q.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:n.filesLoading}):a?(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden`,children:[(0,Q.jsx)(`nav`,{className:`-mx-1 flex shrink-0 flex-wrap gap-1 px-1 pb-1`,role:`tablist`,"aria-label":n.navCoreFiles,children:a.files.map(e=>{let t=o===e.name;return(0,Q.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t,className:i(`inline-flex shrink-0 items-center rounded-lg px-3 py-2 font-mono text-xs font-medium whitespace-nowrap transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,Ye.press,t?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`,e.missing&&`opacity-60`),onClick:()=>c(e.name),children:[e.name,e.missing?` (${n.missing})`:``]},e.name)})}),(0,Q.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-2 overflow-hidden`,children:o?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`inline-flex rounded-lg border border-edge bg-surface-panel p-0.5`,role:`group`,"aria-label":`${n.filesMarkdownEdit} / ${n.filesMarkdownPreview}`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:i(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,Ye.press,l===`edit`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>u(`edit`),children:[(0,Q.jsx)(ke,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),n.filesMarkdownEdit]}),(0,Q.jsxs)(`button`,{type:`button`,className:i(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,Ye.press,l===`preview`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>u(`preview`),children:[(0,Q.jsx)(be,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),n.filesMarkdownPreview]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[p?(0,Q.jsx)(`span`,{children:n.filesSavingStatus}):null,(0,Q.jsx)(`span`,{children:n.filesAutoSaveHint}),g?(0,Q.jsxs)(Y,{type:`button`,variant:`secondary`,className:`ml-auto text-xs`,onClick:g,children:[(0,Q.jsx)(tt,{className:`mr-1 size-3.5`,"aria-hidden":!0}),n.tryInChat]}):null]})]}),l===`edit`?(0,Q.jsx)(`div`,{className:i(bt(),`flex min-h-0 flex-1 flex-col overflow-hidden p-0`,m&&`pointer-events-none opacity-60`),children:(0,Q.jsx)(lt,{initialContent:d,onChange:f,isDark:_,className:`min-h-0 flex-1`},`${o??`file`}-${h}`)}):(0,Q.jsx)(`div`,{className:i(bt(),`min-h-0 flex-1 overflow-y-auto text-sm`,m&&`pointer-events-none opacity-60`),children:(0,Q.jsx)(me,{content:d,className:`text-sm`})})]}):(0,Q.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:n.pickFile})})]}):(0,Q.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:n.filesEmpty}),t[2]=n.filesAutoSaveHint,t[3]=n.filesEmpty,t[4]=n.filesLoading,t[5]=n.filesMarkdownEdit,t[6]=n.filesMarkdownPreview,t[7]=n.filesSavingStatus,t[8]=n.missing,t[9]=n.navCoreFiles,t[10]=n.pickFile,t[11]=n.tryInChat,t[12]=o,t[13]=d,t[14]=p,t[15]=a,t[16]=r,t[17]=l,t[18]=_,t[19]=g,t[20]=h,t[21]=m,t[22]=c,t[23]=f,t[24]=u,t[25]=y):y=t[25];let b;return t[26]!==v||t[27]!==y?(b=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-hidden`,children:[v,y]}),t[26]=v,t[27]=y,t[28]=b):b=t[28],b}function Zt(e){return e.resolved===`dark`}function Qt(e){let t=(0,Z.c)(66),{a:n,chat:r,selected:i,busy:a,modelRows:o,setModelRows:s,onSaveModels:c,onClearModelsEntry:l,hideInlineSave:u}=e,d;t[0]!==n.modelsTabHint||t[1]!==n.modelsTabTitle?(d=(0,Q.jsx)(ut,{className:`shrink-0`,icon:M,title:n.modelsTabTitle,subtitle:n.modelsTabHint}),t[0]=n.modelsTabHint,t[1]=n.modelsTabTitle,t[2]=d):d=t[2];let f;t[3]===n.modelsPresetLabel?f=t[4]:(f=(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:n.modelsPresetLabel}),t[3]=n.modelsPresetLabel,t[4]=f);let p;t[5]===i.typedModels.preset?p=t[6]:(p=Ct(i.typedModels.preset),t[5]=i.typedModels.preset,t[6]=p);let m;t[7]!==f||t[8]!==p?(m=(0,Q.jsxs)(`div`,{children:[f,` `,p]}),t[7]=f,t[8]=p,t[9]=m):m=t[9];let h;t[10]===n.modelsEffectiveLabel?h=t[11]:(h=(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:n.modelsEffectiveLabel}),t[10]=n.modelsEffectiveLabel,t[11]=h);let g;t[12]===i.typedModels.effective?g=t[13]:(g=Ct(i.typedModels.effective),t[12]=i.typedModels.effective,t[13]=g);let _;t[14]!==h||t[15]!==g?(_=(0,Q.jsxs)(`div`,{children:[h,` `,g]}),t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==m||t[18]!==_?(v=(0,Q.jsxs)(`div`,{className:`mb-4 grid gap-2 rounded-lg border border-edge-subtle bg-surface-base/60 p-3 text-xs text-fg-muted dark:border-edge`,children:[m,_]}),t[17]=m,t[18]=_,t[19]=v):v=t[19];let y;t[20]!==n.addTypedModel||t[21]!==n.addTypedModelPurpose||t[22]!==n.removeTypedModel||t[23]!==n.typedModelAddFallback||t[24]!==n.typedModelCustomTitle||t[25]!==n.typedModelDefaultBadge||t[26]!==n.typedModelDescriptionLabel||t[27]!==n.typedModelDescriptionPlaceholder||t[28]!==n.typedModelFallbackEmptyHint||t[29]!==n.typedModelFallbackModelsLabel||t[30]!==n.typedModelFallbackPlaceholder||t[31]!==n.typedModelIdLabel||t[32]!==n.typedModelIdPlaceholder||t[33]!==n.typedModelNoCustomRoles||t[34]!==n.typedModelPrimaryModelLabel||t[35]!==n.typedModelRecommendedTitle||t[36]!==n.typedModelRemoveFallback||t[37]!==n.typedModelRoleDescriptions||t[38]!==n.typedModelRoleNames?(y={id:n.typedModelIdLabel,description:n.typedModelDescriptionLabel,primaryModel:n.typedModelPrimaryModelLabel,fallbackModels:n.typedModelFallbackModelsLabel,addFallback:n.typedModelAddFallback,removeFallback:n.typedModelRemoveFallback,fallbackPlaceholder:n.typedModelFallbackPlaceholder,fallbackEmptyHint:n.typedModelFallbackEmptyHint,add:n.addTypedModel,remove:n.removeTypedModel,recommendedTitle:n.typedModelRecommendedTitle,customTitle:n.typedModelCustomTitle,defaultBadge:n.typedModelDefaultBadge,addPurpose:n.addTypedModelPurpose,noCustomRoles:n.typedModelNoCustomRoles,idPlaceholder:n.typedModelIdPlaceholder,descriptionPlaceholder:n.typedModelDescriptionPlaceholder,roleNames:n.typedModelRoleNames,roleDescriptions:n.typedModelRoleDescriptions},t[20]=n.addTypedModel,t[21]=n.addTypedModelPurpose,t[22]=n.removeTypedModel,t[23]=n.typedModelAddFallback,t[24]=n.typedModelCustomTitle,t[25]=n.typedModelDefaultBadge,t[26]=n.typedModelDescriptionLabel,t[27]=n.typedModelDescriptionPlaceholder,t[28]=n.typedModelFallbackEmptyHint,t[29]=n.typedModelFallbackModelsLabel,t[30]=n.typedModelFallbackPlaceholder,t[31]=n.typedModelIdLabel,t[32]=n.typedModelIdPlaceholder,t[33]=n.typedModelNoCustomRoles,t[34]=n.typedModelPrimaryModelLabel,t[35]=n.typedModelRecommendedTitle,t[36]=n.typedModelRemoveFallback,t[37]=n.typedModelRoleDescriptions,t[38]=n.typedModelRoleNames,t[39]=y):y=t[39];let b;t[40]!==a||t[41]!==r||t[42]!==o||t[43]!==i.typedModels.defaultRole||t[44]!==s||t[45]!==y?(b=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(kt,{rows:o,onChange:s,disabled:a,defaultRole:i.typedModels.defaultRole,chat:r,labels:y})}),t[40]=a,t[41]=r,t[42]=o,t[43]=i.typedModels.defaultRole,t[44]=s,t[45]=y,t[46]=b):b=t[46];let x;t[47]!==n.modelsSave||t[48]!==a||t[49]!==u||t[50]!==c?(x=u?null:(0,Q.jsx)(Y,{type:`button`,disabled:a,onClick:()=>void c(),children:n.modelsSave}),t[47]=n.modelsSave,t[48]=a,t[49]=u,t[50]=c,t[51]=x):x=t[51];let S;t[52]===l?S=t[53]:(S=()=>void l(),t[52]=l,t[53]=S);let C;t[54]!==n.modelsResetInherit||t[55]!==a||t[56]!==S?(C=(0,Q.jsx)(Y,{type:`button`,variant:`secondary`,disabled:a,onClick:S,children:n.modelsResetInherit}),t[54]=n.modelsResetInherit,t[55]=a,t[56]=S,t[57]=C):C=t[57];let w;t[58]!==x||t[59]!==C?(w=(0,Q.jsxs)(`div`,{className:`mt-4 flex shrink-0 flex-wrap gap-2`,children:[x,C]}),t[58]=x,t[59]=C,t[60]=w):w=t[60];let T;return t[61]!==d||t[62]!==w||t[63]!==v||t[64]!==b?(T=(0,Q.jsxs)(dt,{className:`flex min-h-0 flex-1 flex-col`,children:[d,v,b,w]}),t[61]=d,t[62]=w,t[63]=v,t[64]=b,t[65]=T):T=t[65],T}function $t(e){let t=(0,Z.c)(37),{value:n,onChange:r,disabled:a,wd:o,placeholder:s,inputClassName:c,trailing:l}=e,u;t[0]!==r||t[1]!==n?(u={initialPath:n,onPicked:r},t[0]=r,t[1]=n,t[2]=u):u=t[2];let d=Le(u),f;t[3]===n?f=t[4]:(f=n.trim(),t[3]=n,t[4]=f);let p=f,m=p?`${p}\n${o.chooseFolder}`:`${s??o.notSet}\n${o.selectWorkingDirectory}`,h;t[5]===c?h=t[6]:(h=i(`min-w-0 flex-1`,c),t[5]=c,t[6]=h);let g=a||d.picking,_;t[7]===r?_=t[8]:(_=e=>void r(e.target.value),t[7]=r,t[8]=_);let v=s??o.pathInputPlaceholder,y;t[9]!==h||t[10]!==g||t[11]!==_||t[12]!==v||t[13]!==n?(y=(0,Q.jsx)(`input`,{type:`text`,className:h,value:n,disabled:g,onChange:_,placeholder:v,autoComplete:`off`,spellCheck:!1}),t[9]=h,t[10]=g,t[11]=_,t[12]=v,t[13]=n,t[14]=y):y=t[14];let b=a||d.picking,x;t[15]!==m||t[16]!==d.pick||t[17]!==b||t[18]!==n||t[19]!==o.selectWorkingDirectory?(x=(0,Q.jsx)($e,{compact:!0,value:n,onPick:d.pick,disabled:b,title:m,"aria-label":o.selectWorkingDirectory}),t[15]=m,t[16]=d.pick,t[17]=b,t[18]=n,t[19]=o.selectWorkingDirectory,t[20]=x):x=t[20];let S;t[21]!==x||t[22]!==l?(S=(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[x,l]}),t[21]=x,t[22]=l,t[23]=S):S=t[23];let C;t[24]!==S||t[25]!==y?(C=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[y,S]}),t[24]=S,t[25]=y,t[26]=C):C=t[26];let w;t[27]!==d.confirmPick||t[28]!==d.hasNativePicker||t[29]!==d.modalOpen||t[30]!==d.setModalOpen||t[31]!==p||t[32]!==o?(w=d.hasNativePicker?null:(0,Q.jsx)(de,{open:d.modalOpen,onOpenChange:d.setModalOpen,initialAbsolutePath:p||void 0,onConfirm:d.confirmPick,wd:o}),t[27]=d.confirmPick,t[28]=d.hasNativePicker,t[29]=d.modalOpen,t[30]=d.setModalOpen,t[31]=p,t[32]=o,t[33]=w):w=t[33];let T;return t[34]!==C||t[35]!==w?(T=(0,Q.jsxs)(Q.Fragment,{children:[C,w]}),t[34]=C,t[35]=w,t[36]=T):T=t[36],T}function en(e){let t=(0,Z.c)(28),{label:n,mode:r,value:a,inheritedFrom:o,inheritLabel:s,overrideLabel:c,onClick:l}=e,u;t[0]===n?u=t[1]:(u=(0,Q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:n}),t[0]=n,t[1]=u);let d=a||`—`,f;t[2]===d?f=t[3]:(f=(0,Q.jsx)(`p`,{className:`mt-1 truncate text-sm font-medium text-fg`,children:d}),t[2]=d,t[3]=f);let p;t[4]!==o||t[5]!==r?(p=r===`inherit`&&o?(0,Q.jsx)(`p`,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:o}):null,t[4]=o,t[5]=r,t[6]=p):p=t[6];let m;t[7]!==u||t[8]!==f||t[9]!==p?(m=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[u,f,p]}),t[7]=u,t[8]=f,t[9]=p,t[10]=m):m=t[10];let h=r===`inherit`?`bg-surface-hover text-fg-muted`:`bg-accent-soft text-accent-fg`,g;t[11]===h?g=t[12]:(g=i(`mt-2 inline-flex shrink-0 self-start rounded-full px-2.5 py-0.5 text-xs font-medium sm:mt-0`,h),t[11]=h,t[12]=g);let _=r===`inherit`?s:c,v;t[13]!==g||t[14]!==_?(v=(0,Q.jsx)(`span`,{className:g,children:_}),t[13]=g,t[14]=_,t[15]=v):v=t[15];let y;t[16]!==m||t[17]!==v?(y=(0,Q.jsxs)(Q.Fragment,{children:[m,v]}),t[16]=m,t[17]=v,t[18]=y):y=t[18];let b=y,x=l?`w-full text-left transition-colors hover:border-edge hover:bg-surface-hover/45 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 active:scale-[0.995] motion-reduce:active:scale-100`:void 0,S;t[19]===x?S=t[20]:(S=i(`flex flex-col gap-1 rounded-xl border border-edge-subtle bg-surface-panel px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,x),t[19]=x,t[20]=S);let C=S;if(l){let e;return t[21]!==C||t[22]!==b||t[23]!==l?(e=(0,Q.jsx)(`button`,{type:`button`,className:C,onClick:l,children:b}),t[21]=C,t[22]=b,t[23]=l,t[24]=e):e=t[24],e}let w;return t[25]!==C||t[26]!==b?(w=(0,Q.jsx)(`div`,{className:C,children:b}),t[25]=C,t[26]=b,t[27]=w):w=t[27],w}function tn(e){let t=(0,Z.c)(38),{a:n,defaultModel:r,defaultWorkspace:i,agentModel:a,agentWorkspace:o,onEditModelStrategy:s,onEditWorkspace:c}=e,l=n.inheritance,u;t[0]===a?u=t[1]:(u=a.trim(),t[0]=a,t[1]=u);let d=!u,f;t[2]!==o||t[3]!==i?(f=!o.trim()||i.trim().length>0&&o.trim()===i.trim(),t[2]=o,t[3]=i,t[4]=f):f=t[4];let p=f,m=d?r||l.unset:a,h=p?i||l.unset:o,g;t[5]!==l.subtitle||t[6]!==l.title?(g=(0,Q.jsx)(ut,{icon:Pe,title:l.title,subtitle:l.subtitle}),t[5]=l.subtitle,t[6]=l.title,t[7]=g):g=t[7];let _=d?`inherit`:`override`,v;t[8]!==r||t[9]!==l.inheritsValue||t[10]!==d?(v=d&&r?l.inheritsValue.replace(`{{value}}`,r):void 0,t[8]=r,t[9]=l.inheritsValue,t[10]=d,t[11]=v):v=t[11];let y;t[12]!==m||t[13]!==l.badgeInherit||t[14]!==l.badgeOverride||t[15]!==l.modelLabel||t[16]!==s||t[17]!==_||t[18]!==v?(y=(0,Q.jsx)(en,{label:l.modelLabel,mode:_,value:m,inheritedFrom:v,inheritLabel:l.badgeInherit,overrideLabel:l.badgeOverride,onClick:s}),t[12]=m,t[13]=l.badgeInherit,t[14]=l.badgeOverride,t[15]=l.modelLabel,t[16]=s,t[17]=_,t[18]=v,t[19]=y):y=t[19];let b=p?`inherit`:`override`,x;t[20]!==i||t[21]!==l.inheritsValue||t[22]!==p?(x=p&&i?l.inheritsValue.replace(`{{value}}`,i):void 0,t[20]=i,t[21]=l.inheritsValue,t[22]=p,t[23]=x):x=t[23];let S;t[24]!==h||t[25]!==l.badgeInherit||t[26]!==l.badgeOverride||t[27]!==l.workspaceLabel||t[28]!==c||t[29]!==b||t[30]!==x?(S=(0,Q.jsx)(en,{label:l.workspaceLabel,mode:b,value:h,inheritedFrom:x,inheritLabel:l.badgeInherit,overrideLabel:l.badgeOverride,onClick:c}),t[24]=h,t[25]=l.badgeInherit,t[26]=l.badgeOverride,t[27]=l.workspaceLabel,t[28]=c,t[29]=b,t[30]=x,t[31]=S):S=t[31];let C;t[32]!==y||t[33]!==S?(C=(0,Q.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[y,S]}),t[32]=y,t[33]=S,t[34]=C):C=t[34];let w;return t[35]!==g||t[36]!==C?(w=(0,Q.jsxs)(dt,{children:[g,C]}),t[35]=g,t[36]=C,t[37]=w):w=t[37],w}function nn(e,t){switch(e){case`adventurer`:return t.avatarStyleAdventurer;case`bottts`:return t.avatarStyleRobot;case`lorelei`:return t.avatarStyleLorelei;case`thumbs`:return t.avatarStyleThumbs;case`fun-emoji`:return t.avatarStyleFunEmoji;default:return e}}function rn(e){let{agentId:t,value:n,onChange:r,a,id:o}=e,s=(0,$.useRef)(null),[c,l]=(0,$.useState)(!1),[u,d]=(0,$.useState)(null),[f,p]=(0,$.useState)(!1),m=(0,$.useMemo)(()=>{let e=D(n.trim());return e&&w(e.styleId)?e.styleId:N[0]??`adventurer`},[n]),g=(0,$.useCallback)(async(e,n)=>{try{await Re(t)}catch{}r(x(e,n)),p(!1)},[t,r]),_=(0,$.useCallback)(async e=>{let n=e.target.files?.[0];if(e.target.value=``,n){d(null),l(!0);try{await F(t,n),R(t),r(L)}catch(e){let t=e instanceof Error?e.message:``;d(t===`avatar_too_large`?a.avatarTooLarge:t===`unsupported_image_type`||t===`empty_file`?a.avatarInvalidImage:a.avatarUploadFailed)}finally{l(!1)}}},[a,t,r]),v=(e,t)=>{let r=D(n.trim());return!!(r&&r.styleId===e&&r.seed===t)};return(0,Q.jsxs)(`div`,{...o?{id:o}:{},className:`flex flex-col gap-3 sm:col-span-2`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:a.avatarPickerTitle}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{ref:s,type:`file`,accept:`image/png,image/jpeg,image/webp,.png,.jpg,.jpeg,.webp`,className:`hidden`,onChange:e=>void _(e)}),(0,Q.jsxs)(Y,{type:`button`,variant:`secondary`,className:`gap-1.5 px-2.5 py-1.5 text-xs`,disabled:c,onClick:()=>s.current?.click(),children:[(0,Q.jsx)(Se,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),c?a.avatarUploading:a.avatarUploadCustom]})]})]}),u?(0,Q.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:u}):null,(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:N.map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void g(e,k[0]??t),className:i(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,Ye.press,m===e?`border-fg bg-fg text-surface-base`:`border-edge-subtle bg-surface-panel text-fg hover:border-edge`),children:nn(e,a)},e))}),(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel/50 p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[k.map(e=>(0,Q.jsx)(`button`,{type:`button`,title:e,onClick:()=>void g(m,e),className:i(`flex size-12 shrink-0 items-center justify-center rounded-full border-2 transition-colors`,Ye.press,v(m,e)?`border-accent ring-2 ring-accent/30`:`border-transparent hover:border-edge`),children:(0,Q.jsx)(`img`,{src:mt(m,e,96),alt:``,width:44,height:44,className:`size-11 rounded-full object-cover`,draggable:!1})},e)),(0,Q.jsxs)(E,{open:f,onOpenChange:p,children:[(0,Q.jsx)(ne,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:i(`flex size-12 shrink-0 items-center justify-center rounded-xl border border-edge-subtle bg-surface-base text-xs font-medium text-fg-muted hover:border-edge hover:text-fg`,Ye.press),children:a.avatarMore})}),(0,Q.jsx)(C,{children:(0,Q.jsxs)(b,{className:`z-[80] max-h-72 w-[min(22rem,calc(100vw-2rem))] overflow-y-auto rounded-xl border border-edge-subtle bg-surface-panel p-3 shadow-lg`,sideOffset:6,align:`end`,children:[(0,Q.jsx)(`p`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:nn(m,a)}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:je.map(e=>(0,Q.jsx)(`button`,{type:`button`,title:e,onClick:()=>void g(m,e),className:i(`flex size-11 shrink-0 items-center justify-center rounded-full border-2 transition-colors`,Ye.press,v(m,e)?`border-accent ring-2 ring-accent/30`:`border-transparent hover:border-edge`),children:(0,Q.jsx)(`img`,{src:mt(m,e,88),alt:``,width:40,height:40,className:`size-10 rounded-full object-cover`,draggable:!1})},e))})]})})]})]}),(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t border-edge-subtle pt-3`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:a.personaAvatar}),(0,Q.jsx)(h,{agentId:t,avatar:n,size:40}),n.trim()&&!D(n.trim())&&n.trim()!==`xopc:custom`?(0,Q.jsx)(`span`,{className:`truncate font-mono text-[10px] text-fg-muted`,title:n,children:n}):null]})]})]})}function an(e){let t=(0,Z.c)(264),{a:n,chat:r,selected:a,busy:c,editName:l,setEditName:u,editDescription:d,setEditDescription:f,editWorkspace:p,setEditWorkspace:g,editModel:_,setEditModel:v,onSetDefault:y,onSaveAgentEdits:b,onDelete:x,capabilityPresets:S,onUpdateAgentExtends:C,onOpenCapabilityPreset:w,hideInlineSave:T,profileMarkdownLoading:E,profileDraft:D,updateIdentity:k,handleSoulTemplateChange:M,handleSoulContentChange:N,setAvatarDialogOpen:F,toggleSoulPreviewMode:I,defaultModel:L,defaultWorkspace:ne,defaultPresetId:R,onTryInChat:re,onEditModelStrategy:z}=e,B=L===void 0?``:L,H=ne===void 0?``:ne,U=R===void 0?`default`:R,W=o(dn),ie=s(un),oe=(0,$.useRef)(null),se;t[0]===D?.identity?se=t[1]:(se=D?.identity??{name:``,description:``,language:``,creature:``,emoji:``,avatar:``},t[0]=D?.identity,t[1]=se);let G=se,ce=D?.soulTemplate??`professional`,ue=D?.soulCustomContent??``,de=D?.soulEditorNonce??0,pe=D?.soulPreviewMode??!1,he=D?.avatarDialogOpen??!1,ge;t[2]===W?ge=t[3]:(ge=(e,t)=>W===`zh`?t:e,t[2]=W,t[3]=ge);let K=ge,_e;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(_e=bt(),t[4]=_e):_e=t[4];let xe=_e,q;t[5]===S?q=t[6]:(q=new Map(S.map(ln)),t[5]=S,t[6]=q);let Se=q,Ce;t[7]!==n.capabilityPresetsGlobalDefault||t[8]!==n.capabilityPresetsGlobalDefaultHint||t[9]!==U||t[10]!==Se?(Ce=Se.get(U)??{id:U,name:n.capabilityPresetsGlobalDefault,description:n.capabilityPresetsGlobalDefaultHint},t[7]=n.capabilityPresetsGlobalDefault,t[8]=n.capabilityPresetsGlobalDefaultHint,t[9]=U,t[10]=Se,t[11]=Ce):Ce=t[11];let we=Ce,Te,Ee,De,ke,je,Me,Pe;if(t[12]!==n||t[13]!==c||t[14]!==S||t[15]!==B||t[16]!==U||t[17]!==H||t[18]!==_||t[19]!==p||t[20]!==we||t[21]!==z||t[22]!==w||t[23]!==C||t[24]!==Se||t[25]!==a){je=Symbol.for(`react.early_return_sentinel`);bb0:{let e=a?.extends.filter(e=>e!==U)??[],r=S.map(cn).filter(t=>t!==U&&!e.includes(t)),i=r[0]??``,o;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{let e=oe.current;e?.scrollIntoView({behavior:`smooth`,block:`center`}),window.setTimeout(()=>{e?.querySelector(`input`)?.focus()},180)},t[33]=o):o=t[33];let s=o;if(!a){let e;t[34]===n.selectAgentHint?e=t[35]:(e=(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.selectAgentHint}),t[34]=n.selectAgentHint,t[35]=e),je=e;break bb0}De=`flex min-h-0 flex-1 flex-col gap-8 overflow-y-auto`,t[36]!==n||t[37]!==B||t[38]!==H||t[39]!==_||t[40]!==p||t[41]!==z?(ke=(0,Q.jsx)(tn,{a:n,defaultModel:B,defaultWorkspace:H,agentModel:_,agentWorkspace:p,onEditModelStrategy:z,onEditWorkspace:s}),t[36]=n,t[37]=B,t[38]=H,t[39]=_,t[40]=p,t[41]=z,t[42]=ke):ke=t[42],Te=dt;let l;t[43]===w?l=t[44]:(l=()=>w(``),t[43]=w,t[44]=l);let u;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(Ze,{className:`size-3.5`,"aria-hidden":!0}),t[45]=u):u=t[45];let d;t[46]!==n.capabilityPresetsManage||t[47]!==c||t[48]!==l?(d=(0,Q.jsxs)(Y,{type:`button`,variant:`secondary`,className:`text-xs`,disabled:c,onClick:l,children:[u,n.capabilityPresetsManage]}),t[46]=n.capabilityPresetsManage,t[47]=c,t[48]=l,t[49]=d):d=t[49],t[50]!==n.capabilityPresetsHint||t[51]!==n.capabilityPresetsTitle||t[52]!==d?(Me=(0,Q.jsx)(ut,{icon:A,title:n.capabilityPresetsTitle,subtitle:n.capabilityPresetsHint,trailing:d}),t[50]=n.capabilityPresetsHint,t[51]=n.capabilityPresetsTitle,t[52]=d,t[53]=Me):Me=t[53];let f;t[54]!==n.capabilityPresetsGlobalDefault||t[55]!==n.capabilityPresetsGlobalDefaultHint||t[56]!==we||t[57]!==w?(f=we?(0,Q.jsx)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-accent/25 bg-accent-soft/20 px-3 py-2 sm:flex-row sm:items-center sm:justify-between`,children:(0,Q.jsxs)(`button`,{type:`button`,className:`min-w-0 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>w(we.id),children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:we.name||n.capabilityPresetsGlobalDefault}),(0,Q.jsx)(`span`,{className:`shrink-0 rounded-full border border-accent/25 bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent`,children:n.capabilityPresetsGlobalDefault})]}),(0,Q.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-fg-muted`,children:we.id}),(0,Q.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:we.description||n.capabilityPresetsGlobalDefaultHint})]})}):null,t[54]=n.capabilityPresetsGlobalDefault,t[55]=n.capabilityPresetsGlobalDefaultHint,t[56]=we,t[57]=w,t[58]=f):f=t[58],Pe=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[f,e.length>0?e.map((t,r)=>{let i=Se.get(t);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`min-w-0 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>w(t),children:[(0,Q.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:i?.name??t}),(0,Q.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-fg-muted`,children:t}),i?.description?(0,Q.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:i.description}):null]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-1.5`,children:[(0,Q.jsx)(Y,{type:`button`,variant:`secondary`,className:`size-8 rounded-lg p-0`,disabled:c||r===0,"aria-label":n.capabilityPresetMoveUp,onClick:()=>{let t=[...e],[n,i]=[t[r],t[r-1]];t[r-1]=n,t[r]=i,C(t)},children:(0,Q.jsx)(ct,{className:`size-3.5`,"aria-hidden":!0})}),(0,Q.jsx)(Y,{type:`button`,variant:`secondary`,className:`size-8 rounded-lg p-0`,disabled:c||r===e.length-1,"aria-label":n.capabilityPresetMoveDown,onClick:()=>{let t=[...e],[n,i]=[t[r+1],t[r]];t[r]=n,t[r+1]=i,C(t)},children:(0,Q.jsx)(V,{className:`size-3.5`,"aria-hidden":!0})}),(0,Q.jsx)(Y,{type:`button`,variant:`secondary`,className:`size-8 rounded-lg p-0`,disabled:c,"aria-label":n.capabilityPresetRemove,onClick:()=>C(e.filter(e=>e!==t)),children:(0,Q.jsx)(fe,{className:`size-3.5`,"aria-hidden":!0})})]})]},t)}):we?(0,Q.jsx)(`div`,{className:`rounded-lg border border-dashed border-edge-subtle px-3 py-3 text-sm text-fg-muted`,children:n.capabilityPresetsEmptyAdditional}):(0,Q.jsx)(`div`,{className:`rounded-lg border border-dashed border-edge-subtle px-3 py-3 text-sm text-fg-muted`,children:n.capabilityPresetsEmpty})]}),Ee=r.length>0?(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,Q.jsx)(`select`,{className:`min-w-0 flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:border-edge-strong focus:outline-none`,disabled:c,defaultValue:i,onChange:sn,children:r.map(e=>(0,Q.jsx)(`option`,{value:e,children:Se.get(e)?.name??e},e))}),(0,Q.jsxs)(Y,{type:`button`,variant:`secondary`,disabled:c||!i,onClick:t=>{let n=t.currentTarget.parentElement?.querySelector(`select`)?.value||i;n&&C([...e,n])},children:[(0,Q.jsx)(Xe,{className:`size-4`,"aria-hidden":!0}),n.capabilityPresetAdd]})]}):null}t[12]=n,t[13]=c,t[14]=S,t[15]=B,t[16]=U,t[17]=H,t[18]=_,t[19]=p,t[20]=we,t[21]=z,t[22]=w,t[23]=C,t[24]=Se,t[25]=a,t[26]=Te,t[27]=Ee,t[28]=De,t[29]=ke,t[30]=je,t[31]=Me,t[32]=Pe}else Te=t[26],Ee=t[27],De=t[28],ke=t[29],je=t[30],Me=t[31],Pe=t[32];if(je!==Symbol.for(`react.early_return_sentinel`))return je;let Le;t[59]!==Te||t[60]!==Ee||t[61]!==Me||t[62]!==Pe?(Le=(0,Q.jsxs)(Te,{children:[Me,Pe,Ee]}),t[59]=Te,t[60]=Ee,t[61]=Me,t[62]=Pe,t[63]=Le):Le=t[63];let Re;t[64]!==G.avatar||t[65]!==a.id?(Re=(0,Q.jsx)(h,{agentId:a.id,avatar:G.avatar,size:36,className:`size-9 rounded-lg`}),t[64]=G.avatar,t[65]=a.id,t[66]=Re):Re=t[66];let J;t[67]===F?J=t[68]:(J=()=>F(!0),t[67]=F,t[68]=J);let ze;t[69]!==n.avatarOpenSettingsAria||t[70]!==J?(ze={onClick:J,ariaLabel:n.avatarOpenSettingsAria,id:`agent-avatar-settings`},t[69]=n.avatarOpenSettingsAria,t[70]=J,t[71]=ze):ze=t[71];let Be;t[72]!==n.setDefault||t[73]!==c||t[74]!==y||t[75]!==a.isDefault?(Be=a.isDefault?null:(0,Q.jsx)(Y,{type:`button`,variant:`secondary`,className:`text-xs`,disabled:c,onClick:()=>void y(),children:n.setDefault}),t[72]=n.setDefault,t[73]=c,t[74]=y,t[75]=a.isDefault,t[76]=Be):Be=t[76];let Ve;t[77]!==n.personaSectionIdentity||t[78]!==n.personaSectionIdentityHint||t[79]!==Re||t[80]!==ze||t[81]!==Be?(Ve=(0,Q.jsx)(ut,{icon:A,title:n.personaSectionIdentity,subtitle:n.personaSectionIdentityHint,iconLeading:Re,iconInteractive:ze,trailing:Be}),t[77]=n.personaSectionIdentity,t[78]=n.personaSectionIdentityHint,t[79]=Re,t[80]=ze,t[81]=Be,t[82]=Ve):Ve=t[82];let He;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(He=(0,Q.jsx)(Ae,{className:i(`fixed inset-0 bg-scrim backdrop-blur-[2px]`,te)}),t[83]=He):He=t[83];let We;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(We=i(`fixed left-1/2 top-1/2 w-[min(calc(100vw-2rem),26rem)] max-h-[min(90dvh,36rem)] -translate-x-1/2 -translate-y-1/2 overflow-y-auto rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`,ae),t[84]=We):We=t[84];let Ge;t[85]===n.avatarPickerTitle?Ge=t[86]:(Ge=(0,Q.jsx)(ee,{className:`text-base font-semibold text-fg`,children:n.avatarPickerTitle}),t[85]=n.avatarPickerTitle,t[86]=Ge);let Ke;t[87]===Symbol.for(`react.memo_cache_sentinel`)?(Ke=i(ye,`shrink-0 p-1.5 hover:bg-surface-base`),t[87]=Ke):Ke=t[87];let Je;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(Je=(0,Q.jsx)(Fe,{className:`size-4`,"aria-hidden":!0}),t[88]=Je):Je=t[88];let X;t[89]===n.closeDialogAria?X=t[90]:(X=(0,Q.jsx)(P,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:Ke,"aria-label":n.closeDialogAria,children:Je})}),t[89]=n.closeDialogAria,t[90]=X);let Qe;t[91]!==Ge||t[92]!==X?(Qe=(0,Q.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[Ge,X]}),t[91]=Ge,t[92]=X,t[93]=Qe):Qe=t[93];let $e;t[94]===n.avatarRowHint?$e=t[95]:($e=(0,Q.jsx)(m,{className:`sr-only`,children:n.avatarRowHint}),t[94]=n.avatarRowHint,t[95]=$e);let et;t[96]===k?et=t[97]:(et=e=>k({avatar:e}),t[96]=k,t[97]=et);let nt;t[98]!==n||t[99]!==G.avatar||t[100]!==a.id||t[101]!==et?(nt=(0,Q.jsx)(rn,{agentId:a.id,value:G.avatar,onChange:et,a:n}),t[98]=n,t[99]=G.avatar,t[100]=a.id,t[101]=et,t[102]=nt):nt=t[102];let rt;t[103]!==Qe||t[104]!==$e||t[105]!==nt?(rt=(0,Q.jsxs)(O,{children:[He,(0,Q.jsxs)(Ne,{className:We,onOpenAutoFocus:on,children:[Qe,$e,nt]})]}),t[103]=Qe,t[104]=$e,t[105]=nt,t[106]=rt):rt=t[106];let at;t[107]!==he||t[108]!==F||t[109]!==rt?(at=(0,Q.jsx)(j,{open:he,onOpenChange:F,children:rt}),t[107]=he,t[108]=F,t[109]=rt,t[110]=at):at=t[110];let ot;t[111]===n.displayName?ot=t[112]:(ot=(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:n.displayName}),t[111]=n.displayName,t[112]=ot);let st;t[113]!==u||t[114]!==k?(st=e=>{u(e.target.value),k({name:e.target.value})},t[113]=u,t[114]=k,t[115]=st):st=t[115];let ft;t[116]!==n.personaNamePlaceholder||t[117]!==l||t[118]!==st?(ft=(0,Q.jsx)(`input`,{className:xe,value:l,onChange:st,placeholder:n.personaNamePlaceholder,autoComplete:`off`}),t[116]=n.personaNamePlaceholder,t[117]=l,t[118]=st,t[119]=ft):ft=t[119];let pt;t[120]!==ot||t[121]!==ft?(pt=(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[ot,ft]}),t[120]=ot,t[121]=ft,t[122]=pt):pt=t[122];let mt;t[123]===n.personaEmoji?mt=t[124]:(mt=(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:n.personaEmoji}),t[123]=n.personaEmoji,t[124]=mt);let ht;t[125]===k?ht=t[126]:(ht=e=>k({emoji:e.target.value}),t[125]=k,t[126]=ht);let gt;t[127]!==n.personaEmojiPlaceholder||t[128]!==G.emoji||t[129]!==ht?(gt=(0,Q.jsx)(`input`,{className:xe,value:G.emoji,onChange:ht,placeholder:n.personaEmojiPlaceholder,autoComplete:`off`}),t[127]=n.personaEmojiPlaceholder,t[128]=G.emoji,t[129]=ht,t[130]=gt):gt=t[130];let _t;t[131]!==mt||t[132]!==gt?(_t=(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[mt,gt]}),t[131]=mt,t[132]=gt,t[133]=_t):_t=t[133];let vt;t[134]===n.agentDescription?vt=t[135]:(vt=(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:n.agentDescription}),t[134]=n.agentDescription,t[135]=vt);let yt;t[136]===Symbol.for(`react.memo_cache_sentinel`)?(yt=i(xe,`min-h-16 resize-y text-sm leading-relaxed`),t[136]=yt):yt=t[136];let xt;t[137]!==f||t[138]!==k?(xt=e=>{f(e.target.value),k({description:e.target.value})},t[137]=f,t[138]=k,t[139]=xt):xt=t[139];let St;t[140]!==n.agentDescriptionPlaceholder||t[141]!==d||t[142]!==xt?(St=(0,Q.jsx)(`textarea`,{className:yt,value:d,onChange:xt,placeholder:n.agentDescriptionPlaceholder,maxLength:4e3,rows:3,spellCheck:!0}),t[140]=n.agentDescriptionPlaceholder,t[141]=d,t[142]=xt,t[143]=St):St=t[143];let Ct;t[144]!==vt||t[145]!==St?(Ct=(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[vt,St]}),t[144]=vt,t[145]=St,t[146]=Ct):Ct=t[146];let wt;t[147]===n.personaCreature?wt=t[148]:(wt=(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:n.personaCreature}),t[147]=n.personaCreature,t[148]=wt);let Tt;t[149]===G.creature?Tt=t[150]:(Tt=Oe.some(e=>e.value===G.creature)?G.creature:`__custom__`,t[149]=G.creature,t[150]=Tt);let Et;t[151]===k?Et=t[152]:(Et=e=>{if(e.target.value===`__custom__`){k({creature:``});return}k({creature:e.target.value})},t[151]=k,t[152]=Et);let Dt;t[153]===K?Dt=t[154]:(Dt=Oe.map(e=>(0,Q.jsx)(`option`,{value:e.value,children:K(e.labelEn,e.labelZh)},e.value)),t[153]=K,t[154]=Dt);let Ot;t[155]===K?Ot=t[156]:(Ot=K(`Custom…`,`自定义…`),t[155]=K,t[156]=Ot);let kt;t[157]===Ot?kt=t[158]:(kt=(0,Q.jsx)(`option`,{value:`__custom__`,children:Ot}),t[157]=Ot,t[158]=kt);let At;t[159]!==Tt||t[160]!==Et||t[161]!==Dt||t[162]!==kt?(At=(0,Q.jsxs)(`select`,{className:xe,value:Tt,onChange:Et,children:[Dt,kt]}),t[159]=Tt,t[160]=Et,t[161]=Dt,t[162]=kt,t[163]=At):At=t[163];let jt;t[164]!==n.personaCreaturePlaceholder||t[165]!==G.creature||t[166]!==k?(jt=Oe.some(e=>e.value===G.creature)?null:(0,Q.jsx)(`input`,{className:i(xe,`mt-1 text-xs`),value:G.creature,onChange:e=>k({creature:e.target.value}),placeholder:n.personaCreaturePlaceholder,autoComplete:`off`}),t[164]=n.personaCreaturePlaceholder,t[165]=G.creature,t[166]=k,t[167]=jt):jt=t[167];let Mt;t[168]!==wt||t[169]!==At||t[170]!==jt?(Mt=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[wt,At,jt]}),t[168]=wt,t[169]=At,t[170]=jt,t[171]=Mt):Mt=t[171];let Nt;t[172]!==pt||t[173]!==_t||t[174]!==Ct||t[175]!==Mt?(Nt=(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[pt,_t,Ct,Mt]}),t[172]=pt,t[173]=_t,t[174]=Ct,t[175]=Mt,t[176]=Nt):Nt=t[176];let Pt;t[177]!==Ve||t[178]!==at||t[179]!==Nt?(Pt=(0,Q.jsxs)(dt,{children:[Ve,at,Nt]}),t[177]=Ve,t[178]=at,t[179]=Nt,t[180]=Pt):Pt=t[180];let Ft;t[181]!==n.editAgent||t[182]!==n.editAgentHint?(Ft=(0,Q.jsx)(ut,{icon:Ie,title:n.editAgent,subtitle:n.editAgentHint}),t[181]=n.editAgent,t[182]=n.editAgentHint,t[183]=Ft):Ft=t[183];let It;t[184]===n.modelPrimary?It=t[185]:(It=(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:n.modelPrimary}),t[184]=n.modelPrimary,t[185]=It);let Lt;t[186]===v?Lt=t[187]:(Lt=e=>v(e),t[186]=v,t[187]=Lt);let Rt;t[188]!==c||t[189]!==r.modelNoMatches||t[190]!==r.modelPlaceholder||t[191]!==r.modelSearchPlaceholder||t[192]!==_||t[193]!==Lt?(Rt=(0,Q.jsx)(ve,{className:`min-w-0 flex-1`,value:_,disabled:c,placeholder:r.modelPlaceholder,searchPlaceholder:r.modelSearchPlaceholder,noMatches:r.modelNoMatches,onChange:Lt}),t[188]=c,t[189]=r.modelNoMatches,t[190]=r.modelPlaceholder,t[191]=r.modelSearchPlaceholder,t[192]=_,t[193]=Lt,t[194]=Rt):Rt=t[194];let zt;t[195]!==n.modelClear||t[196]!==c||t[197]!==_||t[198]!==v?(zt=_.trim()?(0,Q.jsx)(Y,{type:`button`,variant:`secondary`,className:`shrink-0`,disabled:c,onClick:()=>v(``),children:n.modelClear}):null,t[195]=n.modelClear,t[196]=c,t[197]=_,t[198]=v,t[199]=zt):zt=t[199];let Bt;t[200]!==Rt||t[201]!==zt?(Bt=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[Rt,zt]}),t[200]=Rt,t[201]=zt,t[202]=Bt):Bt=t[202];let Vt;t[203]!==It||t[204]!==Bt?(Vt=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[It,Bt]}),t[203]=It,t[204]=Bt,t[205]=Vt):Vt=t[205];let Ht;t[206]===n.workspacePath?Ht=t[207]:(Ht=(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:n.workspacePath}),t[206]=n.workspacePath,t[207]=Ht);let Ut=r.workingDirectory,Wt=r.workingDirectory.notSet,Gt;t[208]===Symbol.for(`react.memo_cache_sentinel`)?(Gt=i(xe,`font-mono text-xs`),t[208]=Gt):Gt=t[208];let Kt;t[209]!==c||t[210]!==r.workingDirectory||t[211]!==p||t[212]!==g?(Kt=(0,Q.jsx)($t,{value:p,onChange:g,disabled:c,wd:Ut,placeholder:Wt,inputClassName:Gt}),t[209]=c,t[210]=r.workingDirectory,t[211]=p,t[212]=g,t[213]=Kt):Kt=t[213];let qt;t[214]!==Ht||t[215]!==Kt?(qt=(0,Q.jsxs)(`div`,{ref:oe,className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[Ht,Kt]}),t[214]=Ht,t[215]=Kt,t[216]=qt):qt=t[216];let Jt;t[217]!==Vt||t[218]!==qt?(Jt=(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[Vt,qt]}),t[217]=Vt,t[218]=qt,t[219]=Jt):Jt=t[219];let Yt;t[220]!==n.save||t[221]!==n.tryInChat||t[222]!==c||t[223]!==T||t[224]!==b||t[225]!==re?(Yt=T?null:(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(Y,{type:`button`,disabled:c,onClick:()=>void b(),children:n.save}),re?(0,Q.jsxs)(Y,{type:`button`,variant:`secondary`,disabled:c,onClick:re,children:[(0,Q.jsx)(tt,{className:`mr-1.5 size-4`,"aria-hidden":!0}),n.tryInChat]}):null]}),t[220]=n.save,t[221]=n.tryInChat,t[222]=c,t[223]=T,t[224]=b,t[225]=re,t[226]=Yt):Yt=t[226];let Xt;t[227]!==Ft||t[228]!==Jt||t[229]!==Yt?(Xt=(0,Q.jsxs)(dt,{children:[Ft,Jt,Yt]}),t[227]=Ft,t[228]=Jt,t[229]=Yt,t[230]=Xt):Xt=t[230];let Zt;t[231]!==n.loading||t[232]!==n.personaSectionSoul||t[233]!==n.personaSectionSoulHint||t[234]!==n.personaSoulCustomEdit||t[235]!==n.personaSoulEdit||t[236]!==n.personaSoulPreview||t[237]!==n.personaSoulTemplate||t[238]!==N||t[239]!==M||t[240]!==ie||t[241]!==K||t[242]!==E||t[243]!==ue||t[244]!==de||t[245]!==pe||t[246]!==ce||t[247]!==I?(Zt=E?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.loading}):(0,Q.jsxs)(dt,{children:[(0,Q.jsx)(ut,{icon:Ue,title:n.personaSectionSoul,subtitle:n.personaSectionSoulHint}),(0,Q.jsxs)(`div`,{className:`mb-4 flex flex-col gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.personaSoulTemplate}),(0,Q.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-4`,children:le.map(e=>(0,Q.jsxs)(`button`,{type:`button`,className:i(`flex flex-col items-center gap-1.5 rounded-xl border-2 p-3 text-center transition-all`,Ye.pressCard,ce===e.id?`border-accent bg-accent-soft/40 shadow-sm`:`border-edge hover:border-accent/40 hover:bg-surface-hover`),onClick:()=>M(e.id),children:[(0,Q.jsx)(`span`,{className:`text-xl`,children:e.emoji}),(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:K(e.labelEn,e.labelZh)})]},e.id))})]}),ce===`custom`?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.personaSoulCustomEdit}),(0,Q.jsx)(`button`,{type:`button`,className:i(ye,`inline-flex size-9 shrink-0 items-center justify-center rounded-md p-0 hover:bg-surface-hover`),title:pe?n.personaSoulEdit:n.personaSoulPreview,"aria-label":pe?n.personaSoulEdit:n.personaSoulPreview,onClick:I,children:pe?(0,Q.jsx)(qe,{className:`size-4`,"aria-hidden":!0}):(0,Q.jsx)(be,{className:`size-4`,"aria-hidden":!0})})]}),(0,Q.jsx)(`div`,{className:i(xe,`flex min-h-64 flex-col overflow-hidden p-0`),children:pe?(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,Q.jsx)(me,{content:ue})}):(0,Q.jsx)(lt,{initialContent:ue,onChange:N,isDark:ie,className:`min-h-0 flex-1`},`soul-${de}`)})]}):null]}),t[231]=n.loading,t[232]=n.personaSectionSoul,t[233]=n.personaSectionSoulHint,t[234]=n.personaSoulCustomEdit,t[235]=n.personaSoulEdit,t[236]=n.personaSoulPreview,t[237]=n.personaSoulTemplate,t[238]=N,t[239]=M,t[240]=ie,t[241]=K,t[242]=E,t[243]=ue,t[244]=de,t[245]=pe,t[246]=ce,t[247]=I,t[248]=Zt):Zt=t[248];let Qt;t[249]!==n.purgeDisk||t[250]!==n.removeFromConfig||t[251]!==c||t[252]!==K||t[253]!==x||t[254]!==a.id?(Qt=a.id===`main`?null:(0,Q.jsxs)(dt,{children:[(0,Q.jsx)(ut,{icon:it,title:K(`Danger Zone`,`危险操作`),subtitle:K(`Actions that cannot be undone. Be careful.`,`以下操作不可撤销,请谨慎操作。`)}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsxs)(Y,{type:`button`,variant:`secondary`,disabled:c,onClick:()=>void x(!1),children:[(0,Q.jsx)(fe,{className:`mr-1 size-4`,"aria-hidden":!0}),n.removeFromConfig]}),(0,Q.jsx)(Y,{type:`button`,variant:`secondary`,className:`border-red-200 text-red-700 hover:bg-red-50 dark:border-red-900/60 dark:text-red-300 dark:hover:bg-red-950/40`,disabled:c,onClick:()=>void x(!0),children:n.purgeDisk})]})]}),t[249]=n.purgeDisk,t[250]=n.removeFromConfig,t[251]=c,t[252]=K,t[253]=x,t[254]=a.id,t[255]=Qt):Qt=t[255];let en;return t[256]!==De||t[257]!==ke||t[258]!==Le||t[259]!==Pt||t[260]!==Xt||t[261]!==Zt||t[262]!==Qt?(en=(0,Q.jsxs)(`div`,{className:De,children:[ke,Le,Pt,Xt,Zt,Qt]}),t[256]=De,t[257]=ke,t[258]=Le,t[259]=Pt,t[260]=Xt,t[261]=Zt,t[262]=Qt,t[263]=en):en=t[263],en}function on(e){return e.preventDefault()}function sn(e){e.currentTarget.dataset.value=e.target.value}function cn(e){return e.id}function ln(e){return[e.id,e]}function un(e){return e.resolved===`dark`}function dn(e){return e.language}function fn(e){let t=(0,Z.c)(66),{a:n,selected:r,busy:a,skillsCatalogLoading:o,catalogForPick:s,skillsInherit:c,setSkillsInherit:l,skillsPick:u,setSkillsPick:d,onSaveSkills:f,hideInlineSave:p}=e,m;t[0]===r.skills.effectiveAllowlist?m=t[1]:(m=function(e){let t=r.skills.effectiveAllowlist;return t===void 0?!0:t.length===0?!1:t.includes(e)},t[0]=r.skills.effectiveAllowlist,t[1]=m);let h=m,g;t[2]!==s||t[3]!==r.skills.effectiveAllowlist?(g=function(){let e=r.skills.effectiveAllowlist;return e===void 0?new Set(s.map(pn)):new Set(e)},t[2]=s,t[3]=r.skills.effectiveAllowlist,t[4]=g):g=t[4];let _=g,v;t[5]!==n.skillsHint||t[6]!==n.skillsTitle?(v=(0,Q.jsx)(ut,{className:`shrink-0`,icon:S,title:n.skillsTitle,subtitle:n.skillsHint}),t[5]=n.skillsHint,t[6]=n.skillsTitle,t[7]=v):v=t[7];let y;t[8]===l?y=t[9]:(y=()=>l(!0),t[8]=l,t[9]=y);let b;t[10]!==n.skillsInherit||t[11]!==a||t[12]!==y?(b=(0,Q.jsx)(Y,{type:`button`,variant:`secondary`,disabled:a,onClick:y,children:n.skillsInherit}),t[10]=n.skillsInherit,t[11]=a,t[12]=y,t[13]=b):b=t[13];let x;t[14]!==_||t[15]!==l||t[16]!==d?(x=()=>{l(!1),d(_())},t[14]=_,t[15]=l,t[16]=d,t[17]=x):x=t[17];let C;t[18]!==n.skillsCustomize||t[19]!==a||t[20]!==x?(C=(0,Q.jsx)(Y,{type:`button`,variant:`secondary`,disabled:a,onClick:x,children:n.skillsCustomize}),t[18]=n.skillsCustomize,t[19]=a,t[20]=x,t[21]=C):C=t[21];let w;t[22]!==b||t[23]!==C?(w=(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[b,C]}),t[22]=b,t[23]=C,t[24]=w):w=t[24];let E;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(E=H(`skills`),t[25]=E):E=t[25];let D;t[26]===n.skillsLibraryLink?D=t[27]:(D=(0,Q.jsx)(T,{to:E,className:`shrink-0 text-xs font-medium text-accent-fg hover:underline`,children:n.skillsLibraryLink}),t[26]=n.skillsLibraryLink,t[27]=D);let O;t[28]!==w||t[29]!==D?(O=(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3`,children:[w,D]}),t[28]=w,t[29]=D,t[30]=O):O=t[30];let k;t[31]===r.skills.preset?k=t[32]:(k=r.skills.preset.length?r.skills.preset.join(`, `):`—`,t[31]=r.skills.preset,t[32]=k);let A;t[33]!==n.skillsPresetLabel||t[34]!==k?(A=(0,Q.jsxs)(`p`,{className:`mt-2 shrink-0 text-xs text-fg-muted`,children:[n.skillsPresetLabel,` `,k]}),t[33]=n.skillsPresetLabel,t[34]=k,t[35]=A):A=t[35];let j;t[36]!==n.skillsInherit||t[37]!==r.skills.effectiveAllowlist||t[38]!==c?(j=r.skills.effectiveAllowlist?.length?r.skills.effectiveAllowlist.join(`, `):c?n.skillsInherit:`—`,t[36]=n.skillsInherit,t[37]=r.skills.effectiveAllowlist,t[38]=c,t[39]=j):j=t[39];let M;t[40]!==n.skillsEffectiveLabel||t[41]!==j?(M=(0,Q.jsxs)(`p`,{className:`shrink-0 text-xs text-fg-muted`,children:[n.skillsEffectiveLabel,` `,j]}),t[40]=n.skillsEffectiveLabel,t[41]=j,t[42]=M):M=t[42];let N;t[43]!==n.skillsCatalogLoading||t[44]!==n.skillsEmptyCatalog||t[45]!==n.skillsNoDescription||t[46]!==a||t[47]!==s||t[48]!==h||t[49]!==d||t[50]!==o||t[51]!==c||t[52]!==u?(N=o?(0,Q.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:n.skillsCatalogLoading}):s.length===0?(0,Q.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:n.skillsEmptyCatalog}):(0,Q.jsx)(`div`,{className:i(`mt-3 min-h-0 flex-1 overflow-y-auto overscroll-contain pr-0.5`,c&&`opacity-50`),children:(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2.5 text-sm`,children:s.map(e=>{let t=e.name||e.directoryId,r=c?h(t):u.has(t),o=typeof e.description==`string`?e.description.trim():``,s=o||n.skillsNoDescription;return(0,Q.jsx)(`li`,{className:`h-16 shrink-0 overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel/60 px-3 dark:border-edge-subtle`,children:(0,Q.jsxs)(`label`,{className:`flex h-full cursor-pointer items-center gap-3 text-sm`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`shrink-0 rounded border-edge`,checked:r,disabled:c||a,onChange:()=>{d(e=>{let n=new Set(e);return r?n.delete(t):n.add(t),n})},"aria-label":t}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:[(0,Q.jsx)(`div`,{className:`truncate font-mono text-xs font-medium text-fg`,title:t,children:t}),(0,Q.jsx)(`p`,{className:i(`mt-0.5 truncate text-xs leading-tight text-fg-muted`,!o&&`italic text-fg-subtle`),title:s,children:s})]})]})},t)})})}),t[43]=n.skillsCatalogLoading,t[44]=n.skillsEmptyCatalog,t[45]=n.skillsNoDescription,t[46]=a,t[47]=s,t[48]=h,t[49]=d,t[50]=o,t[51]=c,t[52]=u,t[53]=N):N=t[53];let P;t[54]!==n.skillsSave||t[55]!==a||t[56]!==p||t[57]!==f?(P=p?null:(0,Q.jsx)(`div`,{className:`mt-4 shrink-0`,children:(0,Q.jsx)(Y,{type:`button`,disabled:a,onClick:()=>void f(),children:n.skillsSave})}),t[54]=n.skillsSave,t[55]=a,t[56]=p,t[57]=f,t[58]=P):P=t[58];let F;return t[59]!==O||t[60]!==A||t[61]!==M||t[62]!==N||t[63]!==P||t[64]!==v?(F=(0,Q.jsxs)(dt,{className:`flex min-h-0 flex-1 flex-col`,children:[v,O,A,M,N,P]}),t[59]=O,t[60]=A,t[61]=M,t[62]=N,t[63]=P,t[64]=v,t[65]=F):F=t[65],F}function pn(e){return e.name||e.directoryId}var mn=[`write_file`,`edit_file`,`shell`],hn=[`shell`,`image_generate`,`extensions`],gn=[`send_message`,`send_media`];function _n(e){let t=(0,Z.c)(88),{mode:n,builtinToolIds:r,loading:a,disableSet:o,onDisableSetChange:s,defaultsDisableSet:c,unknownDisabledIds:l,getToolDescription:u,getGroupTitle:d,labels:f,quickActionsDisabled:p}=e,m;t[0]===l?m=t[1]:(m=l===void 0?[]:l,t[0]=l,t[1]=m);let h=m,g=p===void 0?!1:p,_;t[2]===r?_=t[3]:(_=new Set(r),t[2]=r,t[3]=_);let v=_,y;t[4]===c?y=t[5]:(y=c??new Set,t[4]=c,t[5]=y);let b=y,x;t[6]!==b||t[7]!==o||t[8]!==n||t[9]!==s?(x=(e,t)=>{if(n===`agentEntry`&&t&&b.has(e))return;let r=new Set(o);t?r.delete(e):r.add(e),s(r)},t[6]=b,t[7]=o,t[8]=n,t[9]=s,t[10]=x):x=t[10];let S=x,C;t[11]!==v||t[12]!==s?(C=e=>{let t=new Set;for(let n of e)v.has(n)&&t.add(n);s(t)},t[11]=v,t[12]=s,t[13]=C):C=t[13];let w=C,T;t[14]===s?T=t[15]:(T=()=>{s(new Set)},t[14]=s,t[15]=T);let E=T,D;t[16]!==r||t[17]!==s||t[18]!==h?(D=()=>{s(new Set([...r,...h]))},t[16]=r,t[17]=s,t[18]=h,t[19]=D):D=t[19];let O=D,k;t[20]===r?k=t[21]:(k=Dt(r),t[20]=r,t[21]=k);let A=k,j;if(t[22]!==v||t[23]!==A||t[24]!==n||t[25]!==h){if(j=[],n===`defaults`&&h.length>0){let e;t[27]===h?e=t[28]:(e=h.toSorted(yn),t[27]=h,t[28]=e);let n;t[29]===e?n=t[30]:(n={key:`unknown`,ids:e},t[29]=e,t[30]=n),j.push(n)}for(let e of Et){let t=e.toolIds.filter(e=>v.has(e));t.length>0&&j.push({key:e.key,ids:[...t]})}if(A.length>0){let e;t[31]===A?e=t[32]:(e={key:`misc`,ids:A},t[31]=A,t[32]=e),j.push(e)}t[22]=v,t[23]=A,t[24]=n,t[25]=h,t[26]=j}else j=t[26];let M=j,N=M.some(vn),P=g||a,F;t[33]===f.quickActionsLabel?F=t[34]:(F=(0,Q.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:f.quickActionsLabel}),t[33]=f.quickActionsLabel,t[34]=F);let I=P||r.length===0&&h.length===0,ee;t[35]!==E||t[36]!==f.quickEnableAll||t[37]!==I?(ee=(0,Q.jsx)(Y,{type:`button`,variant:`secondary`,className:wt,disabled:I,onClick:E,children:f.quickEnableAll}),t[35]=E,t[36]=f.quickEnableAll,t[37]=I,t[38]=ee):ee=t[38];let L=P||r.length===0&&h.length===0,te;t[39]!==O||t[40]!==f.quickDisableAll||t[41]!==L?(te=(0,Q.jsx)(Y,{type:`button`,variant:`secondary`,className:wt,disabled:L,onClick:O,children:f.quickDisableAll}),t[39]=O,t[40]=f.quickDisableAll,t[41]=L,t[42]=te):te=t[42];let ne=P||r.length===0,R;t[43]===w?R=t[44]:(R=()=>w(mn),t[43]=w,t[44]=R);let re;t[45]!==f.quickReadOnlyWorkspace||t[46]!==ne||t[47]!==R?(re=(0,Q.jsx)(Y,{type:`button`,variant:`secondary`,className:wt,disabled:ne,onClick:R,children:f.quickReadOnlyWorkspace}),t[45]=f.quickReadOnlyWorkspace,t[46]=ne,t[47]=R,t[48]=re):re=t[48];let z=P||r.length===0,B;t[49]===w?B=t[50]:(B=()=>w(hn),t[49]=w,t[50]=B);let V;t[51]!==f.quickHighRiskOff||t[52]!==z||t[53]!==B?(V=(0,Q.jsx)(Y,{type:`button`,variant:`secondary`,className:wt,disabled:z,onClick:B,children:f.quickHighRiskOff}),t[51]=f.quickHighRiskOff,t[52]=z,t[53]=B,t[54]=V):V=t[54];let H=P||r.length===0,U;t[55]===w?U=t[56]:(U=()=>w(gn),t[55]=w,t[56]=U);let W;t[57]!==f.quickNoOutbound||t[58]!==H||t[59]!==U?(W=(0,Q.jsx)(Y,{type:`button`,variant:`secondary`,className:wt,disabled:H,onClick:U,children:f.quickNoOutbound}),t[57]=f.quickNoOutbound,t[58]=H,t[59]=U,t[60]=W):W=t[60];let ie;t[61]!==ee||t[62]!==te||t[63]!==re||t[64]!==V||t[65]!==W?(ie=(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[ee,te,re,V,W]}),t[61]=ee,t[62]=te,t[63]=re,t[64]=V,t[65]=W,t[66]=ie):ie=t[66];let ae;t[67]!==F||t[68]!==ie?(ae=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[F,ie]}),t[67]=F,t[68]=ie,t[69]=ae):ae=t[69];let oe;t[70]!==b||t[71]!==o||t[72]!==d||t[73]!==u||t[74]!==M||t[75]!==N||t[76]!==f.emptyBuiltin||t[77]!==f.loadingBuiltin||t[78]!==f.lockedByDefaults||t[79]!==f.notInBuiltin||t[80]!==a||t[81]!==n||t[82]!==P||t[83]!==S?(oe=a?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:f.loadingBuiltin}):N?(0,Q.jsx)(`div`,{className:`max-h-[min(50vh,22rem)] overflow-y-auto overscroll-contain pr-0.5`,children:(0,Q.jsx)(`div`,{className:`flex flex-col gap-5 pr-1`,children:M.map(e=>{let{key:t,ids:r}=e;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:d(t)}),(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:r.map(e=>{let r=n===`defaults`&&t===`unknown`,a=n===`agentEntry`&&b.has(e),s=o.has(e),c=a?!1:!s,l=u(e);return(0,Q.jsx)(`li`,{className:i(`rounded-xl border border-edge-subtle bg-surface-panel/60 px-3 py-2.5 dark:border-edge-subtle`,r&&`border-dashed`,a&&`opacity-60`),children:(0,Q.jsxs)(`label`,{className:i(`flex gap-3 text-sm`,a?`cursor-not-allowed`:`cursor-pointer`),children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`mt-1 shrink-0 rounded border-edge`,checked:c,disabled:a||P,onChange:()=>S(e,!c)}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,Q.jsx)(`span`,{className:`font-mono text-xs font-medium text-fg`,children:e}),r?(0,Q.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[`(`,f.notInBuiltin,`)`]}):null,a?(0,Q.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[`(`,f.lockedByDefaults,`)`]}):null]}),l?(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:l}):null]})]})},e)})})]},t)})})}):(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:f.emptyBuiltin}),t[70]=b,t[71]=o,t[72]=d,t[73]=u,t[74]=M,t[75]=N,t[76]=f.emptyBuiltin,t[77]=f.loadingBuiltin,t[78]=f.lockedByDefaults,t[79]=f.notInBuiltin,t[80]=a,t[81]=n,t[82]=P,t[83]=S,t[84]=oe):oe=t[84];let se;return t[85]!==ae||t[86]!==oe?(se=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[ae,oe]}),t[85]=ae,t[86]=oe,t[87]=se):se=t[87],se}function vn(e){return e.ids.length>0}function yn(e,t){return e.localeCompare(t)}function bn(e){let t=(0,Z.c)(51),{a:n,data:r,selected:i,busy:s,toolEntryDisable:c,setToolEntryDisable:l,onSaveTools:u,onClearToolsEntry:d,hideInlineSave:f}=e,p=o(Sn),m;t[0]===p?m=t[1]:(m=a(p),t[0]=p,t[1]=m);let h=m.agentSettings.advanced,g;t[2]===i.tools.presetDenied?g=t[3]:(g=new Set(i.tools.presetDenied.flatMap(xn)),t[2]=i.tools.presetDenied,t[3]=g);let _=g,v;t[4]===l?v=t[5]:(v=e=>{l(e)},t[4]=l,t[5]=v);let y=v,b=n.toolsDisableGroups,x;t[6]===b?x=t[7]:(x=e=>b[e],t[6]=b,t[7]=x);let S=x,C;t[8]===n.toolDescriptions?C=t[9]:(C=e=>e in n.toolDescriptions?n.toolDescriptions[e]:``,t[8]=n.toolDescriptions,t[9]=C);let w=C,T;t[10]!==n.toolsHint||t[11]!==n.toolsTitle?(T=(0,Q.jsx)(ut,{className:`shrink-0`,icon:Qe,title:n.toolsTitle,subtitle:n.toolsHint}),t[10]=n.toolsHint,t[11]=n.toolsTitle,t[12]=T):T=t[12];let E;t[13]!==n.toolsLockedByPreset||t[14]!==h.toolsDisableEmptyBuiltin||t[15]!==h.toolsDisableLoadingBuiltin||t[16]!==h.toolsDisableNotInBuiltin||t[17]!==h.toolsDisableQuickActionsLabel||t[18]!==h.toolsDisableQuickDisableAll||t[19]!==h.toolsDisableQuickEnableAll||t[20]!==h.toolsDisableQuickHighRiskOff||t[21]!==h.toolsDisableQuickNoOutbound||t[22]!==h.toolsDisableQuickReadOnlyWorkspace?(E={loadingBuiltin:h.toolsDisableLoadingBuiltin,emptyBuiltin:h.toolsDisableEmptyBuiltin,quickActionsLabel:h.toolsDisableQuickActionsLabel,quickEnableAll:h.toolsDisableQuickEnableAll,quickDisableAll:h.toolsDisableQuickDisableAll,quickReadOnlyWorkspace:h.toolsDisableQuickReadOnlyWorkspace,quickHighRiskOff:h.toolsDisableQuickHighRiskOff,quickNoOutbound:h.toolsDisableQuickNoOutbound,notInBuiltin:h.toolsDisableNotInBuiltin,lockedByDefaults:n.toolsLockedByPreset},t[13]=n.toolsLockedByPreset,t[14]=h.toolsDisableEmptyBuiltin,t[15]=h.toolsDisableLoadingBuiltin,t[16]=h.toolsDisableNotInBuiltin,t[17]=h.toolsDisableQuickActionsLabel,t[18]=h.toolsDisableQuickDisableAll,t[19]=h.toolsDisableQuickEnableAll,t[20]=h.toolsDisableQuickHighRiskOff,t[21]=h.toolsDisableQuickNoOutbound,t[22]=h.toolsDisableQuickReadOnlyWorkspace,t[23]=E):E=t[23];let D;t[24]!==s||t[25]!==r.builtinToolIds||t[26]!==S||t[27]!==w||t[28]!==y||t[29]!==_||t[30]!==E||t[31]!==c?(D=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(_n,{mode:`agentEntry`,builtinToolIds:r.builtinToolIds,loading:!1,disableSet:c,onDisableSetChange:y,defaultsDisableSet:_,getToolDescription:w,getGroupTitle:S,quickActionsDisabled:s,labels:E})}),t[24]=s,t[25]=r.builtinToolIds,t[26]=S,t[27]=w,t[28]=y,t[29]=_,t[30]=E,t[31]=c,t[32]=D):D=t[32];let O;t[33]!==n.toolsSave||t[34]!==s||t[35]!==f||t[36]!==u?(O=f?null:(0,Q.jsx)(Y,{type:`button`,disabled:s,onClick:()=>void u(),children:n.toolsSave}),t[33]=n.toolsSave,t[34]=s,t[35]=f,t[36]=u,t[37]=O):O=t[37];let k;t[38]===d?k=t[39]:(k=()=>void d(),t[38]=d,t[39]=k);let A;t[40]!==n.toolsClearEntry||t[41]!==s||t[42]!==k?(A=(0,Q.jsx)(Y,{type:`button`,variant:`secondary`,disabled:s,onClick:k,children:n.toolsClearEntry}),t[40]=n.toolsClearEntry,t[41]=s,t[42]=k,t[43]=A):A=t[43];let j;t[44]!==A||t[45]!==O?(j=(0,Q.jsxs)(`div`,{className:`mt-4 flex shrink-0 flex-wrap gap-2`,children:[O,A]}),t[44]=A,t[45]=O,t[46]=j):j=t[46];let M;return t[47]!==j||t[48]!==T||t[49]!==D?(M=(0,Q.jsxs)(dt,{className:`flex min-h-0 flex-1 flex-col`,children:[T,D,j]}),t[47]=j,t[48]=T,t[49]=D,t[50]=M):M=t[50],M}function xn(e){let t=String(e).trim();return t?[t]:[]}function Sn(e){return e.language}function Cn(e){let t=(0,Z.c)(106),{a:n,chat:r,cCron:i,selected:a,panel:o,data:s,busy:c,editName:l,setEditName:u,editDescription:d,setEditDescription:f,editWorkspace:p,setEditWorkspace:m,editModel:h,setEditModel:g,defaultModel:_,defaultWorkspace:v,onSetDefault:y,onSaveAgentEdits:b,onDelete:x,capabilityPresets:S,defaultPresetId:C,onUpdateAgentExtends:w,onOpenCapabilityPreset:T,overviewProfile:E,filesLoading:D,files:O,activeFile:k,setActiveFile:A,filesViewMode:j,setFilesViewMode:M,fileDraft:N,setFileDraft:P,fileSaving:F,profileFileLoading:I,profileEditorNonce:ee,toolEntryDisable:L,setToolEntryDisable:te,onSaveTools:ne,onClearToolsEntry:R,modelRows:re,setModelRows:z,onSaveModels:B,onClearModelsEntry:V,skillsCatalogLoading:H,catalogForPick:U,skillsInherit:W,setSkillsInherit:ie,skillsPick:ae,setSkillsPick:oe,onSaveSkills:se,bindingsLoading:G,agentBindings:ce,bindChannelStatuses:le,bindChannelsLoading:ue,useManualChannel:de,newBindChannel:fe,setNewBindChannel:pe,bindSessionChats:me,bindSessionsLoading:he,newBindSessionIdx:ge,setNewBindSessionIdx:K,newBindCustomPeer:_e,setNewBindCustomPeer:ve,refreshBindSessions:ye,onRemoveBinding:be,onAddBinding:xe,onTryInChat:q,onPanelChange:Se}=e;if(!a){let e;return t[0]===n.selectAgentHint?e=t[1]:(e=(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.selectAgentHint}),t[0]=n.selectAgentHint,t[1]=e),e}if(o===`overview`){let e;t[2]===Se?e=t[3]:(e=()=>Se?.(`models`),t[2]=Se,t[3]=e);let i;return t[4]!==n||t[5]!==c||t[6]!==S||t[7]!==r||t[8]!==_||t[9]!==C||t[10]!==v||t[11]!==d||t[12]!==h||t[13]!==l||t[14]!==p||t[15]!==x||t[16]!==T||t[17]!==b||t[18]!==y||t[19]!==q||t[20]!==w||t[21]!==E.draft||t[22]!==E.handleSoulContentChange||t[23]!==E.handleSoulTemplateChange||t[24]!==E.profileMarkdownLoading||t[25]!==E.setAvatarDialogOpen||t[26]!==E.toggleSoulPreviewMode||t[27]!==E.updateIdentity||t[28]!==a||t[29]!==f||t[30]!==g||t[31]!==u||t[32]!==m||t[33]!==e?(i=(0,Q.jsx)(an,{a:n,chat:r,selected:a,busy:c,editName:l,setEditName:u,editDescription:d,setEditDescription:f,editWorkspace:p,setEditWorkspace:m,editModel:h,setEditModel:g,onSetDefault:y,onSaveAgentEdits:b,onDelete:x,capabilityPresets:S,defaultPresetId:C,onUpdateAgentExtends:w,onOpenCapabilityPreset:T,hideInlineSave:!0,profileMarkdownLoading:E.profileMarkdownLoading,profileDraft:E.draft,updateIdentity:E.updateIdentity,handleSoulTemplateChange:E.handleSoulTemplateChange,handleSoulContentChange:E.handleSoulContentChange,setAvatarDialogOpen:E.setAvatarDialogOpen,toggleSoulPreviewMode:E.toggleSoulPreviewMode,defaultModel:_,defaultWorkspace:v,onTryInChat:q,onEditModelStrategy:e}),t[4]=n,t[5]=c,t[6]=S,t[7]=r,t[8]=_,t[9]=C,t[10]=v,t[11]=d,t[12]=h,t[13]=l,t[14]=p,t[15]=x,t[16]=T,t[17]=b,t[18]=y,t[19]=q,t[20]=w,t[21]=E.draft,t[22]=E.handleSoulContentChange,t[23]=E.handleSoulTemplateChange,t[24]=E.profileMarkdownLoading,t[25]=E.setAvatarDialogOpen,t[26]=E.toggleSoulPreviewMode,t[27]=E.updateIdentity,t[28]=a,t[29]=f,t[30]=g,t[31]=u,t[32]=m,t[33]=e,t[34]=i):i=t[34],i}if(o===`files`){let e;return t[35]!==n||t[36]!==k||t[37]!==N||t[38]!==F||t[39]!==O||t[40]!==D||t[41]!==j||t[42]!==q||t[43]!==ee||t[44]!==I||t[45]!==A||t[46]!==P||t[47]!==M?(e=(0,Q.jsx)(Xt,{a:n,filesLoading:D,files:O,activeFile:k,setActiveFile:A,filesViewMode:j,setFilesViewMode:M,fileDraft:N,setFileDraft:P,fileSaving:F,profileFileLoading:I,profileEditorNonce:ee,onTryInChat:q}),t[35]=n,t[36]=k,t[37]=N,t[38]=F,t[39]=O,t[40]=D,t[41]=j,t[42]=q,t[43]=ee,t[44]=I,t[45]=A,t[46]=P,t[47]=M,t[48]=e):e=t[48],e}if(o===`tools`){let e;return t[49]!==n||t[50]!==c||t[51]!==s||t[52]!==R||t[53]!==ne||t[54]!==a||t[55]!==te||t[56]!==L?(e=(0,Q.jsx)(bn,{a:n,data:s,selected:a,busy:c,toolEntryDisable:L,setToolEntryDisable:te,onSaveTools:ne,onClearToolsEntry:R,hideInlineSave:!0}),t[49]=n,t[50]=c,t[51]=s,t[52]=R,t[53]=ne,t[54]=a,t[55]=te,t[56]=L,t[57]=e):e=t[57],e}if(o===`models`){let e;return t[58]!==n||t[59]!==c||t[60]!==r||t[61]!==re||t[62]!==V||t[63]!==B||t[64]!==a||t[65]!==z?(e=(0,Q.jsx)(Qt,{a:n,chat:r,selected:a,busy:c,modelRows:re,setModelRows:z,onSaveModels:B,onClearModelsEntry:V,hideInlineSave:!0}),t[58]=n,t[59]=c,t[60]=r,t[61]=re,t[62]=V,t[63]=B,t[64]=a,t[65]=z,t[66]=e):e=t[66],e}if(o===`skills`){let e;return t[67]!==n||t[68]!==c||t[69]!==U||t[70]!==se||t[71]!==a||t[72]!==ie||t[73]!==oe||t[74]!==H||t[75]!==W||t[76]!==ae?(e=(0,Q.jsx)(fn,{a:n,selected:a,busy:c,skillsCatalogLoading:H,catalogForPick:U,skillsInherit:W,setSkillsInherit:ie,skillsPick:ae,setSkillsPick:oe,onSaveSkills:se,hideInlineSave:!0}),t[67]=n,t[68]=c,t[69]=U,t[70]=se,t[71]=a,t[72]=ie,t[73]=oe,t[74]=H,t[75]=W,t[76]=ae,t[77]=e):e=t[77],e}if(o===`memory`){let e;return t[78]===a.id?e=t[79]:(e=(0,Q.jsx)(Bt,{embedded:!0,agentId:a.id}),t[78]=a.id,t[79]=e),e}if(o===`effective`){let e;return t[80]!==n||t[81]!==a?(e=(0,Q.jsx)(qt,{a:n,selected:a}),t[80]=n,t[81]=a,t[82]=e):e=t[82],e}if(o===`channels`){let e;return t[83]!==n||t[84]!==ce||t[85]!==le||t[86]!==ue||t[87]!==me||t[88]!==he||t[89]!==G||t[90]!==c||t[91]!==i.lastActiveLabels||t[92]!==i.selectRecipient||t[93]!==fe||t[94]!==_e||t[95]!==ge||t[96]!==xe||t[97]!==be||t[98]!==ye||t[99]!==pe||t[100]!==ve||t[101]!==K||t[102]!==de?(e=(0,Q.jsx)(Ht,{a:n,busy:c,bindingsLoading:G,agentBindings:ce,channelStatuses:le,channelsStatusLoading:ue,useManualChannel:de,newBindChannel:fe,setNewBindChannel:pe,bindSessionChats:me,sessionsLoading:he,newBindSessionIdx:ge,setNewBindSessionIdx:K,newBindCustomPeer:_e,setNewBindCustomPeer:ve,onRefreshSessions:ye,lastActiveLabels:i.lastActiveLabels,selectRecipient:i.selectRecipient,onRemoveBinding:be,onAddBinding:xe}),t[83]=n,t[84]=ce,t[85]=le,t[86]=ue,t[87]=me,t[88]=he,t[89]=G,t[90]=c,t[91]=i.lastActiveLabels,t[92]=i.selectRecipient,t[93]=fe,t[94]=_e,t[95]=ge,t[96]=xe,t[97]=be,t[98]=ye,t[99]=pe,t[100]=ve,t[101]=K,t[102]=de,t[103]=e):e=t[103],e}let Ce;return t[104]===n.selectAgentHint?Ce=t[105]:(Ce=(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.selectAgentHint}),t[104]=n.selectAgentHint,t[105]=Ce),Ce}function wn(e,t,n){let r=t.trim().toLowerCase();return r?e.filter(e=>{let t=xe(e,n).toLowerCase(),i=e.id.toLowerCase(),a=e.workspace.toLowerCase(),o=K(e,n).toLowerCase();return t.includes(r)||i.includes(r)||a.includes(r)||o.includes(r)}):e}function Tn(e,t){return e.replace(`{{count}}`,String(t))}function En(e,t){let n=e.tools.effectiveDisable.length,r=e.skills.effectiveAllowlist?.length??0,i=n>0?Tn(t.listToolsDisabledCount,n):t.listToolsAllEnabled,a=r>0?Tn(t.listSkillsCount,r):t.listInheritedValue;return`${t.listToolsLabel} ${i} · ${t.listSkillsLabel} ${a}`}function Dn(e,t){let n=e.tools.effectiveDisable.length,r=e.skills.effectiveAllowlist?.length??0,i=n>0?Tn(t.listToolsDisabledCount,n):t.listToolsAllEnabled,a=r>0?Tn(t.listSkillsCount,r):t.listInheritedValue;return[`${t.listToolsLabel} ${i}`,`${t.listSkillsLabel} ${a}`]}function On(e){let t=(0,Z.c)(11),{text:n,children:r,className:a}=e,o;t[0]!==r||t[1]!==a||t[2]!==n?(o=(0,Q.jsx)(we,{asChild:!0,children:(0,Q.jsx)(`span`,{className:a,title:n,children:r})}),t[0]=r,t[1]=a,t[2]=n,t[3]=o):o=t[3];let s;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=i(`max-w-[min(28rem,calc(100vw-2rem))] rounded-lg border border-edge bg-surface-panel px-2.5 py-2`,`text-left text-xs leading-snug text-fg shadow-popover`,p),t[4]=s):s=t[4];let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(_e,{className:`fill-surface-panel`}),t[5]=c):c=t[5];let l;t[6]===n?l=t[7]:(l=(0,Q.jsx)(Ge,{children:(0,Q.jsxs)(q,{side:`top`,align:`start`,sideOffset:6,className:s,children:[n,c]})}),t[6]=n,t[7]=l);let u;return t[8]!==o||t[9]!==l?(u=(0,Q.jsx)(J,{delayDuration:300,skipDelayDuration:100,children:(0,Q.jsxs)(De,{children:[o,l]})}),t[8]=o,t[9]=l,t[10]=u):u=t[10],u}function kn(e){let t=(0,Z.c)(28),{a:n,agents:r,searchQuery:a,onOpenAgent:o,onChatWithAgent:s,busy:c}=e,l,u,d,f,p;if(t[0]!==n||t[1]!==r||t[2]!==c||t[3]!==s||t[4]!==o||t[5]!==a){p=Symbol.for(`react.early_return_sentinel`);bb0:{let e=wn(r,a,n),m=r.length>0&&e.length===0&&a.trim().length>0;if(r.length===0){let e;t[11]===n.listNoAgentsYet?e=t[12]:(e=(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.listNoAgentsYet}),t[11]=n.listNoAgentsYet,t[12]=e),p=e;break bb0}d=`flex flex-col gap-4`,t[13]!==n||t[14]!==m?(f=m?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.listEmpty}):null,t[13]=n,t[14]=m,t[15]=f):f=t[15],l=`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`;let g;t[16]!==n||t[17]!==c||t[18]!==s||t[19]!==o?(g=e=>{let t=xe(e,n),r=e.id,a=K(e,n),l=En(e,n),u=Dn(e,n);return(0,Q.jsx)(`li`,{className:`h-full min-h-0`,children:(0,Q.jsxs)(`article`,{role:`button`,tabIndex:c?-1:0,"aria-disabled":c,"aria-label":`${t} ${r}`,onClick:()=>{c||o(e.id)},onKeyDown:t=>{c||t.key!==`Enter`&&t.key!==` `||(t.preventDefault(),o(e.id))},className:i(`flex min-h-[15.5rem] cursor-pointer flex-col rounded-xl border border-edge-subtle bg-surface-panel p-4 shadow-surface`,`transition-[border-color,transform,box-shadow] duration-150 ease-out`,`hover:border-edge-strong`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,`aria-disabled:pointer-events-none aria-disabled:cursor-not-allowed aria-disabled:opacity-60`,Ye.pressCard),children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3 text-left`,children:[(0,Q.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center overflow-hidden rounded-2xl bg-surface-base text-fg ring-1 ring-edge-subtle/40`,"aria-hidden":!0,children:(0,Q.jsx)(h,{agentId:e.id,avatar:e.avatar,size:48,className:`size-full`})}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:t}),(0,Q.jsx)(`p`,{className:`mt-1 truncate font-mono text-xs text-fg-muted`,title:r,children:r})]})]}),e.isDefault?(0,Q.jsx)(`span`,{className:`shrink-0 rounded-full bg-accent-soft px-2 py-0.5 text-xs font-medium text-accent`,children:n.defaultBadge}):(0,Q.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-2 py-0.5 text-xs font-medium text-fg-muted`,children:n.listCustomBadge})]}),(0,Q.jsxs)(`div`,{className:`mt-5 min-h-[6.25rem] text-left`,children:[(0,Q.jsx)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-base px-3 py-3`,children:(0,Q.jsx)(`p`,{className:i(`line-clamp-2 text-sm leading-5`,a?`text-fg`:`text-fg-muted`),title:a||void 0,children:a||n.listNoDescription})}),(0,Q.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,title:l,children:u.map(An)})]}),(0,Q.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,Q.jsxs)(Y,{type:`button`,variant:`secondary`,disabled:c,onClick:t=>{t.stopPropagation(),s(e.id)},className:`w-full rounded-2xl py-2.5`,children:[(0,Q.jsx)(tt,{className:`size-4 shrink-0`,strokeWidth:2,"aria-hidden":!0}),n.listChatWithAgent]})})]})},e.id)},t[16]=n,t[17]=c,t[18]=s,t[19]=o,t[20]=g):g=t[20],u=e.map(g)}t[0]=n,t[1]=r,t[2]=c,t[3]=s,t[4]=o,t[5]=a,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=p}else l=t[6],u=t[7],d=t[8],f=t[9],p=t[10];if(p!==Symbol.for(`react.early_return_sentinel`))return p;let m;t[21]!==l||t[22]!==u?(m=(0,Q.jsx)(`ul`,{className:l,children:u}),t[21]=l,t[22]=u,t[23]=m):m=t[23];let g;return t[24]!==d||t[25]!==f||t[26]!==m?(g=(0,Q.jsxs)(`div`,{className:d,children:[f,m]}),t[24]=d,t[25]=f,t[26]=m,t[27]=g):g=t[27],g}function An(e){return(0,Q.jsx)(On,{text:e,className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function jn(e){let t=(0,Z.c)(130),{open:n,onOpenChange:r,a,chat:o,busy:s,modalError:c,profileLanguageLabel:l,createDisplayName:u,setCreateDisplayName:d,createAgentId:f,setCreateAgentId:p,createDescription:h,setCreateDescription:g,createWorkspace:_,setCreateWorkspace:v,createModel:y,setCreateModel:b,onCreate:x,onSuggestWorkspace:S,agents:C,duplicateSourceId:w,onSelectDuplicateSource:T}=e,E;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Q.jsx)(Ae,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim`,te)}),t[0]=E):E=t[0];let D;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(D=i(`xopc-dialog-content fixed left-1/2 top-1/2 max-h-[min(90vh,640px)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,ae,`overflow-y-auto rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`),t[1]=D):D=t[1];let k;t[2]===a.addAgent?k=t[3]:(k=(0,Q.jsx)(ee,{className:`text-base font-semibold text-fg`,children:a.addAgent}),t[2]=a.addAgent,t[3]=k);let A;t[4]===a.addAgentHint?A=t[5]:(A=(0,Q.jsx)(m,{className:`mt-0.5 text-xs text-fg-muted`,children:a.addAgentHint}),t[4]=a.addAgentHint,t[5]=A);let M;t[6]!==k||t[7]!==A?(M=(0,Q.jsxs)(`div`,{className:`min-w-0 pr-2`,children:[k,A]}),t[6]=k,t[7]=A,t[8]=M):M=t[8];let N;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(N=i(ye,`shrink-0 p-1.5 hover:bg-surface-base`),t[9]=N):N=t[9];let F;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Q.jsx)(Fe,{className:`size-4`,"aria-hidden":!0}),t[10]=F):F=t[10];let I;t[11]===a.closeDialogAria?I=t[12]:(I=(0,Q.jsx)(P,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:N,"aria-label":a.closeDialogAria,children:F})}),t[11]=a.closeDialogAria,t[12]=I);let L;t[13]!==M||t[14]!==I?(L=(0,Q.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[M,I]}),t[13]=M,t[14]=I,t[15]=L):L=t[15];let ne;t[16]!==a||t[17]!==C||t[18]!==w||t[19]!==T?(ne=C.length>0?(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,Q.jsx)(`span`,{className:`text-fg-muted`,children:a.copyFromExistingAgent}),(0,Q.jsxs)(`select`,{className:i(bt(),`bg-surface-panel`),value:w??``,onChange:e=>T(e.target.value||null),children:[(0,Q.jsx)(`option`,{value:``,children:a.copyFromExistingAgentNone}),C.map(e=>(0,Q.jsxs)(`option`,{value:e.id,children:[xe(e,a),` · `,e.id]},e.id))]}),(0,Q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:a.duplicateAgentHint})]}):null,t[16]=a,t[17]=C,t[18]=w,t[19]=T,t[20]=ne):ne=t[20];let R;t[21]===c?R=t[22]:(R=c?(0,Q.jsx)(`div`,{role:`alert`,className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:c}):null,t[21]=c,t[22]=R);let re;t[23]!==a.newAgentLabel||t[24]!==l?(re=(0,Q.jsxs)(`span`,{className:`text-fg-muted`,children:[a.newAgentLabel,` (`,l,`)`]}),t[23]=a.newAgentLabel,t[24]=l,t[25]=re):re=t[25];let z;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(z=bt(),t[26]=z):z=t[26];let B;t[27]===d?B=t[28]:(B=e=>d(e.target.value),t[27]=d,t[28]=B);let V;t[29]===S?V=t[30]:(V=()=>S(),t[29]=S,t[30]=V);let H;t[31]!==u||t[32]!==B||t[33]!==V?(H=(0,Q.jsx)(`input`,{className:z,value:u,onChange:B,onBlur:V,required:!0,autoComplete:`off`}),t[31]=u,t[32]=B,t[33]=V,t[34]=H):H=t[34];let U;t[35]!==re||t[36]!==H?(U=(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[re,H]}),t[35]=re,t[36]=H,t[37]=U):U=t[37];let W;t[38]===a.newAgentIdOptional?W=t[39]:(W=(0,Q.jsx)(`span`,{className:`text-fg-muted`,children:a.newAgentIdOptional}),t[38]=a.newAgentIdOptional,t[39]=W);let ie;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(ie=i(bt(),`font-mono text-xs`),t[40]=ie):ie=t[40];let oe;t[41]===p?oe=t[42]:(oe=e=>p(e.target.value),t[41]=p,t[42]=oe);let se;t[43]===S?se=t[44]:(se=()=>S(),t[43]=S,t[44]=se);let G;t[45]!==a.newAgentIdPlaceholder||t[46]!==a.newAgentIdRules||t[47]!==f||t[48]!==oe||t[49]!==se?(G=(0,Q.jsx)(`input`,{className:ie,value:f,onChange:oe,onBlur:se,placeholder:a.newAgentIdPlaceholder,autoComplete:`off`,spellCheck:!1,maxLength:64,pattern:`[A-Za-z0-9][A-Za-z0-9_-]{0,63}`,title:a.newAgentIdRules}),t[45]=a.newAgentIdPlaceholder,t[46]=a.newAgentIdRules,t[47]=f,t[48]=oe,t[49]=se,t[50]=G):G=t[50];let ce;t[51]===a.newAgentIdRules?ce=t[52]:(ce=(0,Q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:a.newAgentIdRules}),t[51]=a.newAgentIdRules,t[52]=ce);let le;t[53]!==W||t[54]!==G||t[55]!==ce?(le=(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[W,G,ce]}),t[53]=W,t[54]=G,t[55]=ce,t[56]=le):le=t[56];let ue;t[57]!==a.agentDescription||t[58]!==l?(ue=(0,Q.jsxs)(`span`,{className:`text-fg-muted`,children:[a.agentDescription,` (`,l,`)`]}),t[57]=a.agentDescription,t[58]=l,t[59]=ue):ue=t[59];let de;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(de=i(bt(),`min-h-18 resize-y font-sans text-sm leading-relaxed`),t[60]=de):de=t[60];let fe;t[61]===g?fe=t[62]:(fe=e=>g(e.target.value),t[61]=g,t[62]=fe);let pe;t[63]!==a.agentDescriptionPlaceholder||t[64]!==h||t[65]!==fe?(pe=(0,Q.jsx)(`textarea`,{className:de,value:h,onChange:fe,placeholder:a.agentDescriptionPlaceholder,maxLength:4e3,rows:3,spellCheck:!0}),t[63]=a.agentDescriptionPlaceholder,t[64]=h,t[65]=fe,t[66]=pe):pe=t[66];let me;t[67]!==ue||t[68]!==pe?(me=(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[ue,pe]}),t[67]=ue,t[68]=pe,t[69]=me):me=t[69];let he;t[70]===a.newWorkspace?he=t[71]:(he=(0,Q.jsx)(`span`,{className:`text-fg-muted`,children:a.newWorkspace}),t[70]=a.newWorkspace,t[71]=he);let ge;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(ge=i(bt(),`font-mono text-xs`),t[72]=ge):ge=t[72];let K;t[73]===v?K=t[74]:(K=e=>v(e.target.value),t[73]=v,t[74]=K);let _e;t[75]!==_||t[76]!==K?(_e=(0,Q.jsx)(`input`,{className:ge,value:_,onChange:K,required:!0,autoComplete:`off`}),t[75]=_,t[76]=K,t[77]=_e):_e=t[77];let be;t[78]!==he||t[79]!==_e?(be=(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[he,_e]}),t[78]=he,t[79]=_e,t[80]=be):be=t[80];let q;t[81]===a.newModelOptional?q=t[82]:(q=(0,Q.jsx)(`span`,{className:`text-fg-muted`,children:a.newModelOptional}),t[81]=a.newModelOptional,t[82]=q);let Se;t[83]===b?Se=t[84]:(Se=e=>b(e),t[83]=b,t[84]=Se);let Ce;t[85]!==s||t[86]!==o.modelNoMatches||t[87]!==o.modelPlaceholder||t[88]!==o.modelSearchPlaceholder||t[89]!==y||t[90]!==Se?(Ce=(0,Q.jsx)(ve,{className:`min-w-0 flex-1`,value:y,disabled:s,placeholder:o.modelPlaceholder,searchPlaceholder:o.modelSearchPlaceholder,noMatches:o.modelNoMatches,onChange:Se}),t[85]=s,t[86]=o.modelNoMatches,t[87]=o.modelPlaceholder,t[88]=o.modelSearchPlaceholder,t[89]=y,t[90]=Se,t[91]=Ce):Ce=t[91];let we;t[92]!==a.modelClear||t[93]!==s||t[94]!==y||t[95]!==b?(we=y.trim()?(0,Q.jsx)(Y,{type:`button`,variant:`secondary`,className:`shrink-0`,disabled:s,onClick:()=>b(``),children:a.modelClear}):null,t[92]=a.modelClear,t[93]=s,t[94]=y,t[95]=b,t[96]=we):we=t[96];let Ee;t[97]!==Ce||t[98]!==we?(Ee=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[Ce,we]}),t[97]=Ce,t[98]=we,t[99]=Ee):Ee=t[99];let De;t[100]!==q||t[101]!==Ee?(De=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm`,children:[q,Ee]}),t[100]=q,t[101]=Ee,t[102]=De):De=t[102];let Oe;t[103]!==a.createModalCancel||t[104]!==s?(Oe=(0,Q.jsx)(P,{asChild:!0,children:(0,Q.jsx)(Y,{type:`button`,variant:`secondary`,disabled:s,children:a.createModalCancel})}),t[103]=a.createModalCancel,t[104]=s,t[105]=Oe):Oe=t[105];let ke;t[106]===Symbol.for(`react.memo_cache_sentinel`)?(ke=(0,Q.jsx)(Te,{className:`mr-1 size-4`,"aria-hidden":!0}),t[106]=ke):ke=t[106];let je;t[107]!==a.create||t[108]!==s?(je=(0,Q.jsxs)(Y,{type:`submit`,disabled:s,children:[ke,a.create]}),t[107]=a.create,t[108]=s,t[109]=je):je=t[109];let Me;t[110]!==Oe||t[111]!==je?(Me=(0,Q.jsxs)(`div`,{className:`mt-1 flex justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[Oe,je]}),t[110]=Oe,t[111]=je,t[112]=Me):Me=t[112];let Pe;t[113]!==x||t[114]!==R||t[115]!==U||t[116]!==le||t[117]!==me||t[118]!==be||t[119]!==De||t[120]!==Me||t[121]!==ne?(Pe=(0,Q.jsxs)(`form`,{className:`grid gap-3`,onSubmit:x,children:[ne,R,U,le,me,be,De,Me]}),t[113]=x,t[114]=R,t[115]=U,t[116]=le,t[117]=me,t[118]=be,t[119]=De,t[120]=Me,t[121]=ne,t[122]=Pe):Pe=t[122];let Ie;t[123]!==Pe||t[124]!==L?(Ie=(0,Q.jsxs)(O,{children:[E,(0,Q.jsx)(Ne,{className:D,onOpenAutoFocus:Mn,children:(0,Q.jsxs)(Ke,{layer:`modal`,children:[L,Pe]})})]}),t[123]=Pe,t[124]=L,t[125]=Ie):Ie=t[125];let Le;return t[126]!==r||t[127]!==n||t[128]!==Ie?(Le=(0,Q.jsx)(j,{open:n,onOpenChange:r,children:Ie}),t[126]=r,t[127]=n,t[128]=Ie,t[129]=Le):Le=t[129],Le}function Mn(e){return e.preventDefault()}function Nn(e){let t=(0,Z.c)(37),{a:n,agents:r,savedAgentId:a,draftAgentId:o,unavailable:s,busy:c,onDraftChange:l,onSave:u}=e;if(r.length===0)return null;let d=o!==a,f;t[0]===n.tuiDefaultAgentTitle?f=t[1]:(f=(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.tuiDefaultAgentTitle}),t[0]=n.tuiDefaultAgentTitle,t[1]=f);let p;t[2]===n.tuiDefaultAgentHint?p=t[3]:(p=(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.tuiDefaultAgentHint}),t[2]=n.tuiDefaultAgentHint,t[3]=p);let m;t[4]!==n.tuiDefaultAgentUnavailable||t[5]!==a||t[6]!==s?(m=s?(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-amber-700 dark:text-amber-300`,children:n.tuiDefaultAgentUnavailable.replace(`{{agentId}}`,a)}):null,t[4]=n.tuiDefaultAgentUnavailable,t[5]=a,t[6]=s,t[7]=m):m=t[7];let h;t[8]!==f||t[9]!==p||t[10]!==m?(h=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[f,p,m]}),t[8]=f,t[9]=p,t[10]=m,t[11]=h):h=t[11];let g;t[12]===l?g=t[13]:(g=e=>l(e.target.value),t[12]=l,t[13]=g);let _=n.tuiDefaultAgentTitle,v;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(v=i(bt(),`min-w-48 bg-surface-base py-2`),t[14]=v):v=t[14];let y;if(t[15]!==n||t[16]!==r){let e;t[18]===n?e=t[19]:(e=e=>{let t=xe(e,n);return(0,Q.jsx)(`option`,{value:e.id,children:`${t} · ${e.id}`},e.id)},t[18]=n,t[19]=e),y=r.map(e),t[15]=n,t[16]=r,t[17]=y}else y=t[17];let b;t[20]!==n.tuiDefaultAgentTitle||t[21]!==c||t[22]!==o||t[23]!==g||t[24]!==v||t[25]!==y?(b=(0,Q.jsx)(`select`,{value:o,disabled:c,onChange:g,"aria-label":_,className:v,children:y}),t[20]=n.tuiDefaultAgentTitle,t[21]=c,t[22]=o,t[23]=g,t[24]=v,t[25]=y,t[26]=b):b=t[26];let x=c||!d,S=c?n.tuiDefaultAgentSaving:d?n.tuiDefaultAgentSave:n.tuiDefaultAgentSaved,C;t[27]!==u||t[28]!==x||t[29]!==S?(C=(0,Q.jsx)(Y,{type:`button`,variant:`secondary`,disabled:x,onClick:u,className:`shrink-0`,children:S}),t[27]=u,t[28]=x,t[29]=S,t[30]=C):C=t[30];let w;t[31]!==C||t[32]!==b?(w=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 sm:flex-row sm:items-center`,children:[b,C]}),t[31]=C,t[32]=b,t[33]=w):w=t[33];let T;return t[34]!==w||t[35]!==h?(T=(0,Q.jsx)(`section`,{className:`rounded-lg border border-edge bg-surface-panel px-4 py-3 shadow-surface`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-center md:justify-between`,children:[h,w]})}),t[34]=w,t[35]=h,t[36]=T):T=t[36],T}var Pn=`~/.xopc/workspace`;function Fn(e){let t=e.trim();return t?`${Pn}/${X(t)}`:``}function In(e){let t=(0,Z.c)(18),{a:n,busy:r,listSearchQuery:i,onListSearchQueryChange:a,onAddAgent:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(B,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=s):s=t[0];let c;t[1]===a?c=t[2]:(c=e=>a(e.target.value),t[1]=a,t[2]=c);let l;t[3]!==n.listSearchPlaceholder||t[4]!==i||t[5]!==c?(l=(0,Q.jsxs)(`label`,{className:`relative flex min-h-9 min-w-0 max-w-sm cursor-text items-center rounded-pill border border-edge bg-surface-base py-1.5 pl-9 pr-3 shadow-surface dark:bg-surface-hover/40 sm:max-w-md`,children:[s,(0,Q.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:i,onChange:c,placeholder:n.listSearchPlaceholder,autoComplete:`off`,spellCheck:!1,"aria-label":n.listSearchPlaceholder,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-sm leading-normal text-fg caret-current placeholder:text-fg-disabled focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 focus-visible:outline-none`})]}),t[3]=n.listSearchPlaceholder,t[4]=i,t[5]=c,t[6]=l):l=t[6];let u;t[7]===o?u=t[8]:(u=()=>o(),t[7]=o,t[8]=u);let d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsx)(Xe,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[9]=d):d=t[9];let f;t[10]!==n.addAgent||t[11]!==n.addAgentAria||t[12]!==r||t[13]!==u?(f=(0,Q.jsxs)(Y,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,"aria-label":n.addAgentAria,disabled:r,onClick:u,children:[d,n.addAgent]}),t[10]=n.addAgent,t[11]=n.addAgentAria,t[12]=r,t[13]=u,t[14]=f):f=t[14];let p;return t[15]!==l||t[16]!==f?(p=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[l,f]}),t[15]=l,t[16]=f,t[17]=p):p=t[17],p}function Ln(e){return{...e,soulEditorNonce:0,soulPreviewMode:!1,avatarDialogOpen:!1}}function Rn(e){let{agentId:t,enabled:n,saveRef:r}=e,i=v(async()=>{if(!t)return null;let[e,n]=await Promise.all([Ce(t,`IDENTITY.md`).catch(()=>``),Ce(t,`SOUL.md`).catch(()=>``)]),r=rt(e);return{identity:r,soulTemplate:he(n),soulCustomContent:n,identityBaseline:JSON.stringify(r),soulBaseline:n}},[t],{enabled:n&&!!t,initial:null,errorData:null}),a=i.data,o=i.loading,s=(0,$.useRef)(!1),[c,l]=(0,$.useState)(null),u=t??``,d=(0,$.useRef)(u);d.current!==u&&(d.current=u,s.current=!1,l(null));let f=c??(a?Ln(a):null),p=(0,$.useMemo)(()=>f?JSON.stringify(f.identity)!==f.identityBaseline||f.soulCustomContent!==f.soulBaseline:!1,[f]),m=(0,$.useRef)(t);m.current=t;let h=(0,$.useCallback)(e=>{s.current=!0,l(t=>{let n=t??(a?Ln(a):null);return n?e(n):null})},[a]),g=(0,$.useCallback)(e=>{h(t=>({...t,identity:{...t.identity,...e}}))},[h]),y=(0,$.useCallback)(e=>{h(t=>{if(e===`custom`)return{...t,soulTemplate:`custom`};let n=le.find(t=>t.id===e);return n?.content?{...t,soulTemplate:e,soulCustomContent:n.content,soulEditorNonce:t.soulEditorNonce+1}:{...t,soulTemplate:e}})},[h]),b=(0,$.useCallback)(e=>{h(t=>({...t,soulCustomContent:e,soulTemplate:`custom`}))},[h]),x=(0,$.useCallback)(e=>{h(t=>({...t,avatarDialogOpen:e}))},[h]),S=(0,$.useCallback)(()=>{h(e=>({...e,soulPreviewMode:!e.soulPreviewMode}))},[h]),C=(0,$.useCallback)(async()=>{let e=m.current;!e||!f||(await Promise.all([z(e,`IDENTITY.md`,_(f.identity)),z(e,`SOUL.md`,f.soulCustomContent)]),s.current=!1,l(e=>{let t=e??f;return{...t,identityBaseline:JSON.stringify(t.identity),soulBaseline:t.soulCustomContent}}))},[f]);return(0,$.useLayoutEffect)(()=>{if(r)return r.current=C,()=>{r.current=null}},[C,r]),{profileMarkdownLoading:o,draft:f,dirty:p,updateIdentity:g,handleSoulTemplateChange:y,handleSoulContentChange:b,setAvatarDialogOpen:x,toggleSoulPreviewMode:S}}var zn={draft:``,editorNonce:0,loadedKey:``};function Bn(e,t){switch(t.type){case`load`:return{draft:t.content,editorNonce:e.editorNonce+1,loadedKey:t.key};case`setDraft`:return{...e,draft:t.value};case`clear`:return{draft:``,editorNonce:e.editorNonce,loadedKey:``};case`resetViewMode`:return e}}function Vn(e){let{panel:t,selectedId:n,hasToken:r,dataAgentsLength:i,saveErrorMessage:a,setError:o}=e,s=v(()=>n?G(n):Promise.resolve(null),[t,n,r,i],{enabled:t===`files`&&!!n&&r,initial:null,errorData:null}),c=s.data,l=s.setData,u=s.loading,[d,f]=(0,$.useState)(null),[p,m]=(0,$.useReducer)(Bn,zn),[h,g]=(0,$.useState)(!1),[_,y]=(0,$.useState)(`edit`),b=(0,$.useRef)(n);(0,$.useEffect)(()=>{n!==b.current&&(b.current=n,f(null))},[n]),(0,$.useEffect)(()=>{if(c&&c.files.length>0&&!d){let e=c.files.find(e=>e.name===`AGENTS.md`);f(e?e.name:c.files[0].name)}},[c,d]);let x=p.draft,S=p.editorNonce,C=(0,$.useRef)(x);C.current=x;let w=(0,$.useRef)(n);w.current=n;let T=(0,$.useRef)(d);T.current=d;let E=(0,$.useRef)(null),D=(0,$.useRef)(``),O=(0,$.useRef)(``),k=(0,$.useRef)(``),A=(0,$.useRef)(()=>{}),j=v(()=>d&&n?Ce(n,d).catch(()=>``):Promise.resolve(``),[d,n,r],{enabled:!!(d&&n&&r),initial:``,errorData:``}),M=j.loading,N=ce(async()=>{let e=w.current,t=T.current;if(!e||!t||`${e}:${t}`!==D.current)return;let n=C.current;if(n!==O.current){g(!0),o(null);try{await z(e,t,n),O.current=n,l(n=>!n||n.agentId!==e?n:{...n,files:n.files.map(e=>e.name===t?{...e,missing:!1}:e)})}catch(e){o(e instanceof Error?e.message:a)}finally{g(!1)}}},800);A.current=N.flush,(0,$.useEffect)(()=>()=>{A.current()},[]);let P=(0,$.useRef)(t);P.current!==t&&(P.current===`files`&&A.current(),P.current=t);let F=d&&n?`${n}:${d}`:``;(0,$.useEffect)(()=>{F!==k.current&&(A.current(),k.current=F)},[F]),(0,$.useEffect)(()=>{if(!F){m({type:`clear`});return}M||(D.current=F,O.current=j.data,m({type:`load`,key:F,content:j.data}))},[F,M,j.data]);let I=(0,$.useRef)({activeFile:d,selectedId:n});return(I.current.activeFile!==d||I.current.selectedId!==n)&&(I.current={activeFile:d,selectedId:n},y(`edit`)),{files:c,setFiles:l,filesLoading:u,activeFile:d,setActiveFile:(0,$.useCallback)(e=>{A.current(),f(e)},[]),fileDraft:x,setFileDraft:(0,$.useCallback)(e=>{m({type:`setDraft`,value:typeof e==`function`?e(C.current):e}),N()},[N]),fileSaving:h,filesViewMode:_,setFilesViewMode:y,profileFileLoading:M,profileEditorNonce:S,overviewSaveProfileMarkdownRef:E,saveProfileMarkdownDebounced:N}}function Hn(e){let{panel:t,hasToken:n,bindingsFromConfig:r,gatewayCfgLoading:i,selected:a,saveErrorMessage:o,setBusy:s,setError:c}=e,l=(0,$.useRef)(!1),[u,d]=(0,$.useState)(null),f=(0,$.useRef)(r);t===`channels`&&n&&!l.current&&f.current!==r&&(f.current=r,d(r));let p=u??r,m=t===`channels`&&n,h=v(()=>ht(),[t,n],{enabled:m,initial:[],errorData:[]}),_=h.data,y=h.loading,b=(0,$.useMemo)(()=>y||_.length===0?``:_[0]?.name??``,[_,y]),[x,S]=(0,$.useState)(``),C=(0,$.useRef)(b);t===`channels`&&!y&&b&&C.current!==b&&(!x||!_.some(e=>e.name===x))&&(C.current=b,S(b)),C.current=b;let w=x.trim(),T=m&&w.length>0,E=v(()=>gt(w),[t,n,w],{enabled:T,initial:[],errorData:[]}),D=E.data,O=E.loading,k=E.setData,[A,j]=(0,$.useState)(null),[M,N]=(0,$.useState)(``),P=(0,$.useRef)(w);P.current!==w&&(P.current=w,j(null));let F=(0,$.useMemo)(()=>a?p.filter(e=>e.agentId.toLowerCase()===a.id.toLowerCase()):[],[p,a?.id]),I=(0,$.useCallback)(()=>{let e=x.trim();e&>(e).then(e=>{k(e),j(t=>t!=null&&t<e.length?t:null)}).catch(()=>{k([]),j(null)})},[x,k]),ee=!y&&_.length===0,L=t===`channels`&&n&&i,te=(0,$.useCallback)(async e=>{s(!0),c(null);try{let t=p.filter(t=>t!==e);await g(t),l.current=!0,d(t)}catch(e){c(e instanceof Error?e.message:o)}finally{s(!1)}},[p,o,s,c]);return{agentBindings:F,allBindings:p,bindChannelStatuses:_,bindChannelsLoading:y,bindSessionChats:D,bindSessionsLoading:O,bindingsLoading:L,newBindChannel:x,setNewBindChannel:S,newBindSessionIdx:A,setNewBindSessionIdx:j,newBindCustomPeer:M,setNewBindCustomPeer:N,onAddBinding:(0,$.useCallback)(async e=>{if(e.preventDefault(),!a||!x.trim())return;let t=vt(x,M,A,D),n=[...p,{agentId:a.id,priority:100,enabled:!0,match:t}];s(!0),c(null);try{await g(n),l.current=!0,d(n),j(null),N(``)}catch(e){c(e instanceof Error?e.message:o)}finally{s(!1)}},[p,D,x,M,A,o,a,s,c]),onRemoveBinding:te,refreshBindSessions:I,useManualChannel:ee}}function Un(e,t){let n=(0,Z.c)(16),[r,i]=(0,$.useState)(0),a,o;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>{let e=e=>{let t=e.detail;t&&typeof t==`object`&&`section`in t&&t.section===`skills`&&i(Kn)};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},o=[],n[0]=a,n[1]=o):(a=n[0],o=n[1]),(0,$.useEffect)(a,o);let s;n[2]!==r||n[3]!==e||n[4]!==t?(s=[e,t,r],n[2]=r,n[3]=e,n[4]=t,n[5]=s):s=n[5];let c=e&&t,l;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=[],n[6]=l):l=n[6];let u;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(u=[],n[7]=u):u=n[7];let d;n[8]===c?d=n[9]:(d={enabled:c,initial:l,errorData:u},n[8]=c,n[9]=d);let{data:f,loading:p}=v(Gn,s,d),m;n[10]===f?m=n[11]:(m=f.filter(Wn),n[10]=f,n[11]=m);let h=m,g;return n[12]!==h||n[13]!==f||n[14]!==p?(g={catalogForPick:h,skillCatalog:f,skillsCatalogLoading:p},n[12]=h,n[13]=f,n[14]=p,n[15]=g):g=n[15],g}function Wn(e){return e.enabled!==!1}function Gn(){return pe()}function Kn(e){return e+1}function qn(e){return Un(e.panel===`skills`,e.hasToken)}function Jn(e){return new Set(e.tools.entryDisable)}function Yn(e){return e.skills.entry===void 0?{inherit:!0,pick:new Set(e.skills.effectiveAllowlist??[])}:{inherit:!1,pick:new Set(e.skills.entry??[])}}function Xn(e){let{panel:t,selected:n}=e,r=`${t}:${n?.id??``}`,i=(0,$.useRef)(r),[a,o]=(0,$.useState)(()=>new Set),[s,c]=(0,$.useState)(()=>new Set),[l,u]=(0,$.useState)(!0),[d,f]=(0,$.useState)(()=>[]);if(i.current!==r){if(i.current=r,n&&t===`tools`&&o(Jn(n)),n&&t===`skills`){let e=Yn(n);u(e.inherit),c(e.pick)}n&&t===`models`&&f(St(n.typedModels.effective))}return{toolEntryDisable:a,setToolEntryDisable:o,skillsPick:s,setSkillsPick:c,skillsInherit:l,setSkillsInherit:u,modelRows:d,setModelRows:f}}function Zn(e,t){let n=e.typedModels.defaultRole;return{defaultRole:n,roles:{[n]:{model:t}}}}function Qn(e){let t=St(e.typedModels.preset);return t.some(t=>t.id===e.typedModels.defaultRole)?t:St(e.typedModels.effective)}function $n(e){return Object.fromEntries(Array.from(e).map(e=>e.trim()).filter(Boolean).toSorted((e,t)=>e.localeCompare(t)).map(e=>[e,{mode:`deny`}]))}function er(){let e=o(e=>e.language),t=a(e),n=t.agentsSettings,[r,i]=(0,$.useState)(!1),[s,l]=(0,$.useState)(null),[u,f]=(0,$.useState)(!1),[p,m]=(0,$.useState)(``),h=t.cron,g=t.chat,_=!!c(e=>e.token),[v,b]=se(),x=ie(),{agentId:S}=U(),C=ot(e=>e.setPageHeader),w=ot(e=>e.clearPageHeader),{data:T,error:E,isLoading:D,mutate:O}=d(_?`settings-gateway-agents`:null,at,{revalidateOnFocus:!1}),{data:k,mutate:A}=d(_?`settings-capability-presets`:null,Ot,{revalidateOnFocus:!1}),j=Ve(_),{data:M}=j,N=(0,$.useMemo)(()=>re(M?.payload?.config??{}),[M]),P=T??null,F=(0,$.useMemo)(()=>P?P.agents.find(e=>e.id===P.defaultId)??P.agents[0]??null:null,[P]),I=!!(_&&D),[ee,L]=(0,$.useState)(null),te=E instanceof Error?E.message:E?n.loadError:null,ne=ee??te,[R,z]=(0,$.useState)(null),[B,V]=(0,$.useState)(`overview`),[H,W]=(0,$.useState)(``),[ae,oe]=(0,$.useState)(``),[G,ce]=(0,$.useState)(``),[le,ue]=(0,$.useState)(``),[de,fe]=(0,$.useState)(``),[pe,me]=(0,$.useState)(null),[he,K]=(0,$.useState)(!1),_e=(0,$.useRef)(``),[ve,ye]=(0,$.useState)(null),[be,q]=(0,$.useState)(!1),[Se,Ce]=(0,$.useState)(``),[we,Te]=(0,$.useState)(``),[De,Oe]=(0,$.useState)(``),[ke,Ae]=(0,$.useState)(``),[je,Me]=(0,$.useState)(``),[Ne,Pe]=(0,$.useState)(``),Fe=(0,$.useRef)(null),[Ie,Le]=(0,$.useState)(!1),Re=(0,$.useRef)({data:null,routeAgentId:void 0});P&&(P!==Re.current.data||S!==Re.current.routeAgentId)&&(Re.current={data:P,routeAgentId:S},S&&P.agents.some(e=>e.id===S)?z(S):z(e=>e&&P.agents.some(t=>t.id===e)?e:P.defaultId)),(0,$.useEffect)(()=>{!P||!S||P.agents.some(e=>e.id===S)||x(Je,{replace:!0})},[P,S,x]),(0,$.useEffect)(()=>{S&&V(`overview`)},[S]),(0,$.useEffect)(()=>{v.get(`panel`)===`defaults`&&x(S?Be(S):Je,{replace:!0,state:{[ze]:S?Be(S):Je}})},[v,S,x]),(0,$.useEffect)(()=>{if(v.get(`focus`)!==`avatar`||!S||(V(`overview`),I||!P?.agents.some(e=>e.id===S)))return;let e=window.setTimeout(()=>{document.getElementById(`agent-avatar-settings`)?.scrollIntoView({behavior:`smooth`,block:`center`}),b(e=>{let t=new URLSearchParams(e);return t.delete(`focus`),t},{replace:!0})},220);return()=>window.clearTimeout(e)},[v,S,I,P,b]);let J=(0,$.useMemo)(()=>P?.agents.find(e=>e.id===R)??null,[P,R]),He=(0,$.useMemo)(()=>{let e=M?.payload?.config;if(!e||typeof e!=`object`||Array.isArray(e))return``;let t=e.tui;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t.defaultAgent;return typeof n==`string`?n.trim().toLowerCase():``},[M]),Ue=(0,$.useMemo)(()=>P?He&&P.agents.some(e=>e.id===He)?He:P.defaultId||P.agents[0]?.id||He||`coder`:He||`coder`,[P,He]),Ge=!!(P&&He&&!P.agents.some(e=>e.id===He)),Ke=Ge?He:Ue;(0,$.useEffect)(()=>{Te(Ue)},[Ue]);let Y=(0,$.useRef)(null),qe=J?J.id:null;J&&Y.current!==qe?(Y.current=qe,Oe(J.workspace),Ae(J.model?.primary??``),Me(xe(J,a(e).agentsSettings)),Pe(J.description??``)):!J&&Y.current!==null&&(Y.current=null,Oe(``),Ae(``),Me(``),Pe(``));let Ye=Rn({agentId:J?.id??null,enabled:B===`overview`&&!!J,saveRef:Fe}),Xe=Vn({panel:B,selectedId:R,hasToken:_,dataAgentsLength:P?.agents.length,saveErrorMessage:n.saveError,setError:L}),Ze=Xn({panel:B,selected:J}),X=Hn({panel:B,hasToken:_,bindingsFromConfig:N,gatewayCfgLoading:M===void 0,selected:J,saveErrorMessage:n.saveError,setBusy:q,setError:L}),Qe=qn({panel:B,hasToken:_}),$e=(0,$.useCallback)(()=>{let e=Fn(ae.trim()||H);ue(t=>t===``||t===_e.current?(_e.current=e,e):t)},[ae,H]),et=(0,$.useCallback)(()=>{_e.current=``,W(``),oe(``),ce(``),ue(``),fe(``),me(null),ye(null),K(!0)},[]),tt=(0,$.useCallback)(e=>{let t=new Set(P?.agents.map(e=>e.id.toLowerCase())??[]),r=e.trim();if(!t.has(r.toLowerCase()))return r;let i=`${r}${n.duplicateIdSuffix}`;if(!t.has(i.toLowerCase()))return i;for(let e=2;e<1e3;e+=1){let n=`${i}-${e}`;if(!t.has(n.toLowerCase()))return n}return i},[n.duplicateIdSuffix,P]),rt=(0,$.useCallback)(e=>{if(ye(e),!e)return;let t=P?.agents.find(t=>t.id===e);if(!t)return;let r=t.name?.trim()??t.id,i=n.duplicateName.replace(`{{name}}`,r),a=tt(t.id),o=t.description??``;_e.current=``,W(i),oe(a),ce(o),ue(t.workspace),fe(t.model?.primary??``),me(null)},[n.duplicateName,P,tt]),it=(0,$.useCallback)(e=>{rt(e),K(!0)},[rt]),ct=(0,$.useMemo)(()=>(0,Q.jsx)(In,{a:n,busy:be,listSearchQuery:Se,onListSearchQueryChange:Ce,onAddAgent:()=>et()}),[n,be,Se,et]);(0,$.useLayoutEffect)(()=>_?(C({startExtra:null,main:(0,Q.jsx)(`div`,{className:`min-w-0`,children:(0,Q.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title})}),end:ct}),()=>w()):(w(),()=>w()),[n.title,ct,w,_,C]);async function lt(t){t.preventDefault();let r=H.trim();if(!r)return;let i=ge(ae,r);if(i.ok===!1){me(i.error);return}let a=le.trim()||Fn(ae.trim()||r);if(a){q(!0),me(null);try{let t=[`# IDENTITY.md - Who Am I?`,``,`- **Name:** ${r}`,`- **Description:** ${G.trim()}`,`- **Language:** ${e}`,`- **Creature:** assistant`,`- **Emoji:**`,`- **Avatar:**`,``].join(`
|
|
2
|
-
`),{createdAgentId:n,...i}=await We({workspace:a,...ae.trim()?{id:ae.trim()}:{},...de.trim()?{models:{defaultRole:`deep`,roles:{deep:{model:de.trim()}}}}:{},profileFiles:{"IDENTITY.md":t},...ve?{cloneFrom:ve}:{}});O(i,{revalidate:!1}),W(``),oe(``),ce(``),ue(``),fe(``),me(null),K(!1),z(n),x(Be(n))}catch(e){me(e instanceof Error?e.message:n.saveError)}finally{q(!1)}}}async function ut(){if(J){q(!0),L(null);try{O(await y(J.id,{workspace:De.trim()||void 0,...ke.trim()?{models:Zn(J,ke.trim())}:{}}),{revalidate:!1})}catch(e){L(e instanceof Error?e.message:n.saveError)}finally{q(!1)}}}async function dt(e){q(!0),L(null);try{O(await y(e.id,{setDefault:!0}),{revalidate:!1}),z(e.id)}catch(e){L(e instanceof Error?e.message:n.saveError)}finally{q(!1)}}async function ft(){let e=we.trim().toLowerCase();if(!e||!P?.agents.some(t=>t.id===e)){L(n.tuiDefaultAgentInvalid);return}q(!0),L(null);try{await nt(e),await j.mutate()}catch(e){L(e instanceof Error?e.message:n.saveError)}finally{q(!1)}}async function pt(e,t){q(!0),L(null);try{let n=await Ee(e.id,t);O(n,{revalidate:!1}),z(n.defaultId),V(`overview`),S===e.id&&x(Je,{replace:!0}),i(!1),l(null),m(``)}catch(e){L(e instanceof Error?e.message:n.saveError)}finally{q(!1)}}function mt(e,t){e.id!==`main`&&(l(e),f(t),m(``),i(!0))}async function ht(){if(J){q(!0),L(null);try{O(await y(J.id,{tools:{builtin:$n(Ze.toolEntryDisable)}}),{revalidate:!1})}catch(e){L(e instanceof Error?e.message:n.saveError)}finally{q(!1)}}}async function gt(){if(J){q(!0),L(null);try{O(await y(J.id,{tools:null}),{revalidate:!1}),Ze.setToolEntryDisable(new Set)}catch(e){L(e instanceof Error?e.message:n.saveError)}finally{q(!1)}}}async function _t(){if(!J)return;let e=xt(Ze.modelRows,{invalidId:n.typedModelsInvalidId,duplicateId:n.typedModelsDuplicateId,invalidModel:n.typedModelsInvalidModel});if(e){L(e);return}q(!0),L(null);try{O(await y(J.id,{models:{roles:Tt(Ze.modelRows)?.roles??{}}}),{revalidate:!1})}catch(e){L(e instanceof Error?e.message:n.saveError)}finally{q(!1)}}async function vt(){if(!J)return;let e=Qn(J),t=Tt(e);if(!t?.roles?.[J.typedModels.defaultRole]){L(n.typedModelsInvalidModel);return}q(!0),L(null);try{O(await y(J.id,{models:{defaultRole:J.typedModels.defaultRole,roles:t.roles}}),{revalidate:!1}),Ze.setModelRows(e)}catch(e){L(e instanceof Error?e.message:n.saveError)}finally{q(!1)}}async function yt(){if(J){q(!0),L(null);try{O(await y(J.id,{skills:Ze.skillsInherit?null:[...Ze.skillsPick].toSorted((e,t)=>e.localeCompare(t))}),{revalidate:!1})}catch(e){L(e instanceof Error?e.message:n.saveError)}finally{q(!1)}}}async function bt(e){if(J){q(!0),L(null);try{O(await y(J.id,{extends:e}),{revalidate:!1}),A()}catch(e){L(e instanceof Error?e.message:n.saveError)}finally{q(!1)}}}let St=B===`channels`||B===`effective`||B===`memory`,Ct=(()=>{if(!J||B!==`overview`)return!1;let e=J.workspace,t=J.model?.primary??``;return De.trim()!==e||ke.trim()!==t})(),wt=(()=>{if(St||!J)return!1;switch(B){case`overview`:return Ct||Ye.dirty;default:return!0}})(),Et=St||!wt;function Dt(){Le(!0),setTimeout(()=>Le(!1),2e3)}async function kt(){switch(B){case`overview`:await Promise.all([ut(),Fe.current?.()??Promise.resolve()]),Dt();break;case`tools`:await ht(),Dt();break;case`models`:await _t(),Dt();break;case`skills`:await yt(),Dt();break;case`files`:Xe.saveProfileMarkdownDebounced.flush(),Dt();break;default:break}}function Z(e){e||x(Je)}let At=J?je.trim()||xe(J,n):S??``,jt=J?.id??S??``,Mt=(0,$.useCallback)(async()=>{if(J){await kt();try{globalThis.localStorage?.setItem(st,J.id)}catch{}x(`/chat/new`,{state:{agentId:J.id,fromAgentEditor:!0}})}},[J,kt,x]),Nt={a:n,chat:g,cCron:h,selected:J,panel:B,data:P,busy:be,editName:je,setEditName:Me,editDescription:Ne,setEditDescription:Pe,editWorkspace:De,setEditWorkspace:Oe,editModel:ke,setEditModel:Ae,defaultModel:F?.model?.primary??``,defaultWorkspace:F?.workspace??``,onSetDefault:()=>{J&&dt(J)},onSaveAgentEdits:()=>void ut(),onDelete:e=>{J&&mt(J,e)},onTryInChat:()=>void Mt(),capabilityPresets:k?.presets??[],defaultPresetId:k?.defaultPresetId,onUpdateAgentExtends:e=>void bt(e),onOpenCapabilityPreset:e=>{x(e?`/settings/capability-presets?preset=${encodeURIComponent(e)}`:`/settings/capability-presets`)},overviewSaveProfileMarkdownRef:Fe,overviewProfile:Ye,filesLoading:Xe.filesLoading,files:Xe.files,activeFile:Xe.activeFile,setActiveFile:Xe.setActiveFile,filesViewMode:Xe.filesViewMode,setFilesViewMode:Xe.setFilesViewMode,fileDraft:Xe.fileDraft,setFileDraft:Xe.setFileDraft,fileSaving:Xe.fileSaving,profileFileLoading:Xe.profileFileLoading,profileEditorNonce:Xe.profileEditorNonce,toolEntryDisable:Ze.toolEntryDisable,setToolEntryDisable:Ze.setToolEntryDisable,onSaveTools:()=>void ht(),onClearToolsEntry:()=>void gt(),modelRows:Ze.modelRows,setModelRows:Ze.setModelRows,onSaveModels:()=>void _t(),onClearModelsEntry:()=>void vt(),skillsCatalogLoading:Qe.skillsCatalogLoading,catalogForPick:Qe.catalogForPick,skillsInherit:Ze.skillsInherit,setSkillsInherit:Ze.setSkillsInherit,skillsPick:Ze.skillsPick,setSkillsPick:Ze.setSkillsPick,onSaveSkills:()=>void yt(),bindingsLoading:X.bindingsLoading,agentBindings:X.agentBindings,bindChannelStatuses:X.bindChannelStatuses,bindChannelsLoading:X.bindChannelsLoading,useManualChannel:X.useManualChannel,newBindChannel:X.newBindChannel,setNewBindChannel:X.setNewBindChannel,bindSessionChats:X.bindSessionChats,bindSessionsLoading:X.bindSessionsLoading,newBindSessionIdx:X.newBindSessionIdx,setNewBindSessionIdx:X.setNewBindSessionIdx,newBindCustomPeer:X.newBindCustomPeer,setNewBindCustomPeer:X.setNewBindCustomPeer,refreshBindSessions:X.refreshBindSessions,onRemoveBinding:e=>void X.onRemoveBinding(e),onAddBinding:X.onAddBinding,onPanelChange:V};return{hasToken:_,a:n,chat:g,language:e,data:P,savedTuiDefaultAgentId:Ke,tuiDefaultAgentDraft:we,setTuiDefaultAgentDraft:Te,tuiDefaultAgentUnavailable:Ge,onSaveTuiDefaultAgent:ft,loading:I,displayError:ne,navigate:x,routeAgentId:S,busy:be,listSearchQuery:Se,openAddAgentModal:et,openDuplicateAgentModal:it,duplicateSourceId:ve,onSelectDuplicateSource:rt,panel:B,setPanel:V,modalTitle:At,modalSubtitle:jt,footerSaveDisabled:Et,savedFlash:Ie,handleModalFooterSave:kt,onAgentModalOpenChange:Z,addAgentModalOpen:he,setAddAgentModalOpen:K,createWorkspaceSuggestedRef:_e,createModalError:pe,setCreateModalError:me,createDisplayName:H,setCreateDisplayName:W,createAgentId:ae,setCreateAgentId:oe,createDescription:G,setCreateDescription:ce,createWorkspace:le,setCreateWorkspace:ue,createModel:de,setCreateModel:fe,onCreate:lt,currentLanguageLabel:e===`zh`?`中文`:`English`,applyCreateWorkspaceSuggestion:$e,deleteDialogOpen:r,setDeleteDialogOpen:i,deletePurge:u,deleteTarget:s,setDeleteTarget:l,deleteConfirmText:p,setDeleteConfirmText:m,performDelete:pt,editorPanelProps:Nt}}function tr(){let e=er();return e.hasToken?(0,Q.jsxs)(pt,{gap:`gap-6`,padding:`px-4 py-8`,children:[e.displayError?(0,Q.jsx)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:e.displayError}):null,e.loading?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.a.loading}):e.data?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(Nn,{a:e.a,agents:e.data.agents,savedAgentId:e.savedTuiDefaultAgentId,draftAgentId:e.tuiDefaultAgentDraft,unavailable:e.tuiDefaultAgentUnavailable,busy:e.busy,onDraftChange:e.setTuiDefaultAgentDraft,onSave:()=>void e.onSaveTuiDefaultAgent()}),(0,Q.jsx)(kn,{a:e.a,agents:e.data.agents,searchQuery:e.listSearchQuery,onOpenAgent:t=>e.navigate(Be(t)),onChatWithAgent:t=>{let n=t.trim().toLowerCase();try{globalThis.localStorage?.setItem(st,n)}catch{}e.navigate(`/chat/new`,{state:{agentId:n}})},busy:e.busy})]}):null,e.routeAgentId&&e.hasToken?(0,Q.jsx)(Ft,{open:!!e.routeAgentId,onOpenChange:e.onAgentModalOpenChange,a:e.a,title:e.modalTitle,subtitle:e.modalSubtitle,panel:e.panel,onPanelChange:e.setPanel,onFooterSave:()=>void e.handleModalFooterSave(),footerSaveDisabled:e.footerSaveDisabled,footerSavedFlash:e.savedFlash,busy:e.busy,children:e.loading||!e.data?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.a.loading}):(0,Q.jsx)(Cn,{...e.editorPanelProps})}):null,(0,Q.jsx)(jn,{open:e.addAgentModalOpen,onOpenChange:t=>{e.setAddAgentModalOpen(t),t||(e.createWorkspaceSuggestedRef.current=``,e.setCreateDisplayName(``),e.setCreateAgentId(``),e.setCreateDescription(``),e.setCreateWorkspace(``),e.setCreateModel(``),e.setCreateModalError(null),e.onSelectDuplicateSource(null))},a:e.a,chat:e.chat,busy:e.busy,modalError:e.createModalError,profileLanguageLabel:e.currentLanguageLabel,createDisplayName:e.createDisplayName,setCreateDisplayName:e.setCreateDisplayName,createAgentId:e.createAgentId,setCreateAgentId:e.setCreateAgentId,createDescription:e.createDescription,setCreateDescription:e.setCreateDescription,createWorkspace:e.createWorkspace,setCreateWorkspace:e.setCreateWorkspace,createModel:e.createModel,setCreateModel:e.setCreateModel,onCreate:e.onCreate,onSuggestWorkspace:()=>e.applyCreateWorkspaceSuggestion(),agents:e.data?.agents??[],duplicateSourceId:e.duplicateSourceId,onSelectDuplicateSource:e.onSelectDuplicateSource}),(0,Q.jsx)(At,{open:e.deleteDialogOpen,onOpenChange:t=>{e.setDeleteDialogOpen(t),t||(e.setDeleteTarget(null),e.setDeleteConfirmText(``))},busy:e.busy,deletePurge:e.deletePurge,deleteTarget:e.deleteTarget,deleteConfirmText:e.deleteConfirmText,onDeleteConfirmTextChange:e.setDeleteConfirmText,onConfirm:()=>{e.deleteTarget&&e.performDelete(e.deleteTarget,e.deletePurge)},onCancel:()=>e.setDeleteDialogOpen(!1),a:e.a})]}):(0,Q.jsxs)(pt,{gap:`gap-3`,padding:`px-4 py-8`,children:[(0,Q.jsx)(ft,{title:e.a.title}),(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.a.needToken})]})}export{tr as AgentsSettingsPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-CrDHEbss.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{c as s,i as c,n as l}from"./fetch-Y7AEX4H3.js";import{r as u}from"./toast-z0toXu32.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{Ba as f,Ga as p,Gs as m,Na as h,So as g,Ta as _,Ya as v,Zs as y,ba as b,ct as x,po as S,ra as C,ro as w,sa as T,ti as E,ua as D,xo as O}from"./index-BoKafJIZ.js";import{n as ee,t as te}from"./settings-form-section-D-4lBl6X.js";import{i as k,n as A,r as j,t as ne}from"./settings-page-layout-BJ4Gsef5.js";import{n as re,t as M}from"./schedule-field-CmTRoOcE.js";import{t as N}from"./format-cron-label-arqgGlVV.js";var P=e(t(),1),F=n();function I(){return c(`/api/dreaming`)}async function ie(){let e=await l(I());if(!e.payload)throw Error(`Missing payload`);return e.payload}async function ae(e){await l(c(`/api/dreaming/action`),{method:`POST`,body:JSON.stringify({action:e})})}async function L(e=`deep`){let t=await l(c(`/api/dreaming/run`),{method:`POST`,body:JSON.stringify({phase:e})});if(t.ok===!1||!t.payload)throw Error(`Failed to run dreaming phase`);let n=t.payload.phase;return{phase:n===`light`||n===`deep`||n===`rem`?n:e,result:t.payload.result}}async function oe(e){let t=await l(c(`/api/dreaming/preview${typeof e==`number`&&Number.isFinite(e)?`?limit=${encodeURIComponent(String(e))}`:``}`));if(!t.payload)throw Error(`Missing payload`);return t.payload}async function R(e=50){return(await l(c(`/api/dreaming/events${`?limit=${encodeURIComponent(String(e))}`}`))).payload?.events??[]}function z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var B={enabled:!0,cron:`0 */6 * * *`,lookbackDays:1,limit:50,dedupeSimilarity:.85},V={enabled:!0,cron:`0 3 * * *`,minScore:.8,minRecallCount:3,limit:10,recencyHalfLifeDays:14,maxAgeDays:30},H={enabled:!0,cron:`0 5 * * 0`,lookbackDays:7,limit:20,minPatternStrength:.6},U={enabled:!1,frequency:`0 3 * * *`,timezone:``,deepEnabled:!0,minScore:.8,minRecallCount:3,limit:10,light:B,deep:V,rem:H};function W(e,t){return Number.isFinite(e)?Math.max(0,Math.min(1,e)):t}function G(e,t){let n=typeof e==`string`?Number(e):e;return Number.isFinite(n)?Math.max(0,Math.floor(n)):t}function K(e,t){let n=typeof e==`string`?Number(e):e;return Number.isFinite(n)?n:t}function se(e){let t=z(e)?e:{},n=z(t.memory)?t.memory:{},r=z(t.dreaming)?t.dreaming:{},i=typeof t.enabled==`boolean`||typeof t.frequency==`string`||z(t.phases)?t:{},a=z(n.dreaming)?n.dreaming:Object.keys(r).length>0?r:i,o=z(a.phases)?a.phases:{},s=z(o.light)?o.light:{},c=z(o.deep)?o.deep:{},l=z(o.rem)?o.rem:{};return{enabled:a.enabled===!0,frequency:typeof a.frequency==`string`&&a.frequency.trim()?a.frequency.trim():U.frequency,timezone:typeof a.timezone==`string`?a.timezone:``,deepEnabled:c.enabled!==!1,minScore:W(typeof c.minScore==`number`?c.minScore:Number(c.minScore),U.minScore),minRecallCount:Math.max(1,G(c.minRecallCount,U.minRecallCount)),limit:G(c.limit,U.limit),light:{enabled:s.enabled!==!1,cron:typeof s.cron==`string`&&s.cron.trim()?s.cron.trim():B.cron,lookbackDays:Math.max(1,G(s.lookbackDays,B.lookbackDays)),limit:G(s.limit,B.limit),dedupeSimilarity:W(K(s.dedupeSimilarity,B.dedupeSimilarity),B.dedupeSimilarity)},deep:{enabled:c.enabled!==!1,cron:typeof c.cron==`string`&&c.cron.trim()?c.cron.trim():V.cron,minScore:W(K(c.minScore,V.minScore),V.minScore),minRecallCount:Math.max(1,G(c.minRecallCount,V.minRecallCount)),limit:G(c.limit,V.limit),recencyHalfLifeDays:Math.max(1,K(c.recencyHalfLifeDays,V.recencyHalfLifeDays)),maxAgeDays:Math.max(1,K(c.maxAgeDays,V.maxAgeDays))},rem:{enabled:l.enabled!==!1,cron:typeof l.cron==`string`&&l.cron.trim()?l.cron.trim():H.cron,lookbackDays:Math.max(1,G(l.lookbackDays,H.lookbackDays)),limit:G(l.limit,H.limit),minPatternStrength:W(K(l.minPatternStrength,H.minPatternStrength),H.minPatternStrength)}}}async function q(e,t,n){let r=t.frequency.trim(),i=t.timezone.trim();await l(c(`/api/agents/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({memory:{...n??{},mode:t.enabled?`confirmWrite`:typeof n?.mode==`string`?n.mode:`off`,sources:Array.isArray(n?.sources)?n.sources:[`session`,`curated`,`workspace`],writePolicy:z(n?.writePolicy)?n.writePolicy:{curated:`confirm`,workspace:`confirm`},dreaming:{enabled:!!t.enabled,...r?{frequency:r}:{},...i?{timezone:i}:{},phases:{light:{enabled:!!t.light.enabled,...t.light.cron.trim()?{cron:t.light.cron.trim()}:{},lookbackDays:Math.max(1,Math.floor(t.light.lookbackDays)),limit:Math.max(0,Math.floor(t.light.limit)),dedupeSimilarity:W(t.light.dedupeSimilarity,B.dedupeSimilarity)},deep:{enabled:!!t.deep.enabled,...t.deep.cron.trim()?{cron:t.deep.cron.trim()}:{},minScore:W(t.deep.minScore,V.minScore),minRecallCount:Math.max(1,Math.floor(t.deep.minRecallCount)),limit:Math.max(0,Math.floor(t.deep.limit)),recencyHalfLifeDays:Math.max(1,t.deep.recencyHalfLifeDays),maxAgeDays:Math.max(1,t.deep.maxAgeDays)},rem:{enabled:!!t.rem.enabled,...t.rem.cron.trim()?{cron:t.rem.cron.trim()}:{},lookbackDays:Math.max(1,Math.floor(t.rem.lookbackDays)),limit:Math.max(0,Math.floor(t.rem.limit)),minPatternStrength:W(t.rem.minPatternStrength,H.minPatternStrength)}}}}})}),E()}var ce=`p-4 sm:px-5`,le=`mb-3`,J=`rounded-xl border border-edge-subtle bg-surface-panel/30 p-3 sm:p-4`,Y=i(`mt-1 w-full rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm text-fg`,C);function ue(e){return e?e.replace(`T`,` `).replace(`Z`,``):`—`}function X(e){return e===void 0||!Number.isFinite(e)||e<0?`—`:e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(2)} s`}function de(e,t){return e.locked?{text:t.lockValueLocked,className:`text-amber-600 dark:text-amber-400`}:{text:t.lockValueUnlocked,className:`text-emerald-600 dark:text-emerald-400`}}var Z=r(),fe=`text-xs font-medium text-fg-muted`,pe=`text-sm font-medium text-fg`;function Q(e){let t=(0,F.c)(6),{label:n,children:r,className:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(`span`,{className:fe,children:n}),t[0]=n,t[1]=a);let o;return t[2]!==r||t[3]!==i||t[4]!==a?(o=(0,Z.jsxs)(`div`,{className:i,children:[a,r]}),t[2]=r,t[3]=i,t[4]=a,t[5]=o):o=t[5],o}function $(e){let t=(0,F.c)(11),{label:n,children:r,className:a}=e,o;t[0]===a?o=t[1]:(o=i(`min-w-0`,a),t[0]=a,t[1]=o);let s;t[2]===n?s=t[3]:(s=(0,Z.jsx)(`dt`,{className:fe,children:n}),t[2]=n,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=i(pe,`mt-0.5`),t[4]=c):c=t[4];let l;t[5]===r?l=t[6]:(l=(0,Z.jsx)(`dd`,{className:c,children:r}),t[5]=r,t[6]=l);let u;return t[7]!==o||t[8]!==s||t[9]!==l?(u=(0,Z.jsxs)(`div`,{className:o,children:[s,l]}),t[7]=o,t[8]=s,t[9]=l,t[10]=u):u=t[10],u}function me(e){let t=(0,F.c)(5),{label:n,className:r}=e,a;t[0]===r?a=t[1]:(a=i(`text-[0.7rem] font-semibold uppercase tracking-wider text-fg-muted`,r),t[0]=r,t[1]=a);let o;return t[2]!==n||t[3]!==a?(o=(0,Z.jsx)(`h3`,{className:a,children:n}),t[2]=n,t[3]=a,t[4]=o):o=t[4],o}function he(e){let t=(0,F.c)(35),{icon:n,title:r,hint:i,enabled:a,onEnabledChange:o,cron:s,onCronChange:c,scheduleLabels:l,disabled:u,showEnabledControl:d,actions:f,onLabel:p,offLabel:m,cronLabel:h,children:g}=e,_=d===void 0?!0:d,v;t[0]===n?v=t[1]:(v=(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:n}),t[0]=n,t[1]=v);let y;t[2]===r?y=t[3]:(y=(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:r}),t[2]=r,t[3]=y);let b;t[4]===i?b=t[5]:(b=(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs leading-snug text-fg-muted`,children:i}),t[4]=i,t[5]=b);let x;t[6]!==y||t[7]!==b?(x=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[y,b]}),t[6]=y,t[7]=b,t[8]=x):x=t[8];let S;t[9]!==v||t[10]!==x?(S=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[v,x]}),t[9]=v,t[10]=x,t[11]=S):S=t[11];let C;t[12]!==f||t[13]!==u||t[14]!==a||t[15]!==m||t[16]!==o||t[17]!==p||t[18]!==_?(C=f||_?(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[f,_?(0,Z.jsxs)(`label`,{className:`inline-flex shrink-0 items-center gap-2 text-xs text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:a,disabled:u,onChange:e=>o(e.target.checked)}),(0,Z.jsx)(`span`,{children:a?p:m})]}):null]}):null,t[12]=f,t[13]=u,t[14]=a,t[15]=m,t[16]=o,t[17]=p,t[18]=_,t[19]=C):C=t[19];let w;t[20]!==S||t[21]!==C?(w=(0,Z.jsxs)(`div`,{className:`mb-2.5 flex flex-wrap items-start justify-between gap-2 border-b border-edge-subtle/80 pb-2.5`,children:[S,C]}),t[20]=S,t[21]=C,t[22]=w):w=t[22];let T;t[23]!==s||t[24]!==h||t[25]!==u||t[26]!==c||t[27]!==l?(T=(0,Z.jsx)(M,{kind:`cron`,className:`mb-2.5`,label:h,value:s,onChange:c,labels:l,disabled:u}),t[23]=s,t[24]=h,t[25]=u,t[26]=c,t[27]=l,t[28]=T):T=t[28];let E;t[29]===g?E=t[30]:(E=(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4`,children:g}),t[29]=g,t[30]=E);let D;return t[31]!==E||t[32]!==w||t[33]!==T?(D=(0,Z.jsxs)(`div`,{className:J,children:[w,T,E]}),t[31]=E,t[32]=w,t[33]=T,t[34]=D):D=t[34],D}function ge(e){let t=(0,F.c)(23),{icon:n,label:r,enabled:a,cron:o,scheduleSummary:s,details:c,t:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(J,`space-y-1`),t[0]=u):u=t[0];let d;t[1]===r?d=t[2]:(d=(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r}),t[1]=r,t[2]=d);let f=a?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`,p;t[3]===f?p=t[4]:(p=i(`ml-auto text-xs font-medium`,f),t[3]=f,t[4]=p);let m=a?l.on:l.off,h;t[5]!==p||t[6]!==m?(h=(0,Z.jsx)(`span`,{className:p,children:m}),t[5]=p,t[6]=m,t[7]=h):h=t[7];let g;t[8]!==n||t[9]!==d||t[10]!==h?(g=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n,d,h]}),t[8]=n,t[9]=d,t[10]=h,t[11]=g):g=t[11];let _;t[12]===s?_=t[13]:(_=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:s}),t[12]=s,t[13]=_);let v;t[14]===o?v=t[15]:(v=(0,Z.jsx)(`p`,{className:`truncate font-mono text-[0.65rem] text-fg-subtle`,title:o,children:o}),t[14]=o,t[15]=v);let y;t[16]===c?y=t[17]:(y=(0,Z.jsx)(`p`,{className:`text-[0.65rem] leading-snug text-fg-muted`,children:c}),t[16]=c,t[17]=y);let b;return t[18]!==y||t[19]!==g||t[20]!==_||t[21]!==v?(b=(0,Z.jsxs)(`div`,{className:u,children:[g,_,v,y]}),t[18]=y,t[19]=g,t[20]=_,t[21]=v,t[22]=b):b=t[22],b}function _e(e){let t=(0,F.c)(9),{label:n,lastRun:r,t:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(me,{label:n,className:`mb-2`}),t[0]=n,t[1]=a);let o;t[2]!==r||t[3]!==i.lastRunRaw||t[4]!==i.phaseLastRunEmpty?(o=r?.exists?(0,Z.jsxs)(`details`,{className:`group rounded-lg border border-edge-subtle`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer list-none px-2.5 py-1.5 text-xs font-medium text-fg-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:(0,Z.jsx)(`span`,{className:`underline decoration-edge underline-offset-2 group-open:text-fg`,children:i.lastRunRaw})}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto border-t border-edge-subtle p-2.5 text-xs text-fg-muted`,children:JSON.stringify(r.raw,null,2)})]}):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.phaseLastRunEmpty}),t[2]=r,t[3]=i.lastRunRaw,t[4]=i.phaseLastRunEmpty,t[5]=o):o=t[5];let s;return t[6]!==a||t[7]!==o?(s=(0,Z.jsxs)(`div`,{className:`border-t border-edge-subtle/80 pt-3`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8],s}function ve(e){let t=(0,F.c)(39),{t:n,r}=e,i=r.deep?.skipped,a=r.ok?`text-emerald-600 dark:text-emerald-400`:`text-amber-600 dark:text-amber-400`,o=r.ok?n.lastRunSuccess:n.lastRunFailure,s;t[0]!==a||t[1]!==o?(s=(0,Z.jsx)(`span`,{className:a,children:o}),t[0]=a,t[1]=o,t[2]=s):s=t[2];let c;t[3]!==n.lastRunStatus||t[4]!==s?(c=(0,Z.jsx)($,{label:n.lastRunStatus,children:s}),t[3]=n.lastRunStatus,t[4]=s,t[5]=c):c=t[5];let l=n.lastRunDuration,u;t[6]===r.durationMs?u=t[7]:(u=X(r.durationMs),t[6]=r.durationMs,t[7]=u);let d;t[8]!==n.lastRunDuration||t[9]!==u?(d=(0,Z.jsx)($,{label:l,children:u}),t[8]=n.lastRunDuration,t[9]=u,t[10]=d):d=t[10];let f=n.lastRunRanked,p=String(r.deep?.candidatesRanked??`—`),m;t[11]!==n.lastRunRanked||t[12]!==p?(m=(0,Z.jsx)($,{label:f,children:p}),t[11]=n.lastRunRanked,t[12]=p,t[13]=m):m=t[13];let h=n.lastRunApplied,g=String(r.deep?.applied??`—`),_;t[14]!==n.lastRunApplied||t[15]!==g?(_=(0,Z.jsx)($,{label:h,children:g}),t[14]=n.lastRunApplied,t[15]=g,t[16]=_):_=t[16];let v;t[17]===r.reason?v=t[18]:(v=(0,Z.jsx)(`span`,{className:`block text-pretty`,children:r.reason}),t[17]=r.reason,t[18]=v);let y;t[19]!==r.errorMessage||t[20]!==n.lastRunError?(y=r.errorMessage?(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-amber-600 dark:text-amber-400`,children:`${n.lastRunError}: ${r.errorMessage}`}):null,t[19]=r.errorMessage,t[20]=n.lastRunError,t[21]=y):y=t[21];let b;t[22]!==n.lastRunReason||t[23]!==v||t[24]!==y?(b=(0,Z.jsxs)($,{label:n.lastRunReason,className:`col-span-2 sm:col-span-3 lg:col-span-4`,children:[v,y]}),t[22]=n.lastRunReason,t[23]=v,t[24]=y,t[25]=b):b=t[25];let x;t[26]!==i||t[27]!==n.lastRunSkipContaminated||t[28]!==n.lastRunSkipHash||t[29]!==n.lastRunSkipKey||t[30]!==n.lastRunSkipRehydrate?(x=i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{label:n.lastRunSkipKey,children:String(i.alreadyPromotedKey)}),(0,Z.jsx)($,{label:n.lastRunSkipRehydrate,children:String(i.rehydrateFailed)}),(0,Z.jsx)($,{label:n.lastRunSkipContaminated,children:String(i.contaminated)}),(0,Z.jsx)($,{label:n.lastRunSkipHash,children:String(i.hashDuplicate)})]}):null,t[26]=i,t[27]=n.lastRunSkipContaminated,t[28]=n.lastRunSkipHash,t[29]=n.lastRunSkipKey,t[30]=n.lastRunSkipRehydrate,t[31]=x):x=t[31];let S;return t[32]!==m||t[33]!==_||t[34]!==b||t[35]!==x||t[36]!==c||t[37]!==d?(S=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-3 lg:grid-cols-4`,children:[c,d,m,_,b,x]}),t[32]=m,t[33]=_,t[34]=b,t[35]=x,t[36]=c,t[37]=d,t[38]=S):S=t[38],S}function ye(e){let t=(0,F.c)(47),{t:n,schedulePickerLabels:r,hasToken:a,cfgForm:o,cfgSaving:s,enableSaving:c,runPhase:l,setRunPhase:u,runBusy:d,setCfgForm:f,setDreamingEnabled:p,doRunNow:m}=e,v;t[0]!==o?.enabled||t[1]!==s||t[2]!==m||t[3]!==a||t[4]!==d||t[5]!==l||t[6]!==u||t[7]!==n?(v=(e,t)=>o?.enabled?(0,Z.jsx)(xe,{t:n,busy:d&&l===e,disabled:!a||s||d||!t,onClick:()=>{u(e),m(e)}}):null,t[0]=o?.enabled,t[1]=s,t[2]=m,t[3]=a,t[4]=d,t[5]=l,t[6]=u,t[7]=n,t[8]=v):v=t[8];let y=v,b;return t[9]!==o||t[10]!==s||t[11]!==c||t[12]!==a||t[13]!==y||t[14]!==r||t[15]!==f||t[16]!==p||t[17]!==n.configDeepHalfLife||t[18]!==n.configDeepLimit||t[19]!==n.configDeepMaxAge||t[20]!==n.configDeepMinRecallCount||t[21]!==n.configDeepMinScore||t[22]!==n.configFrequency||t[23]!==n.configLightDedupe||t[24]!==n.configLightLimit||t[25]!==n.configLightLookbackDays||t[26]!==n.configLoading||t[27]!==n.configPhaseCron||t[28]!==n.configPhaseDeep||t[29]!==n.configPhaseDeepHint||t[30]!==n.configPhaseLight||t[31]!==n.configPhaseLightHint||t[32]!==n.configPhaseRem||t[33]!==n.configPhaseRemHint||t[34]!==n.configRemLimit||t[35]!==n.configRemLookbackDays||t[36]!==n.configRemMinStrength||t[37]!==n.configTimezone||t[38]!==n.masterHint||t[39]!==n.masterOff||t[40]!==n.masterOn||t[41]!==n.masterTitle||t[42]!==n.off||t[43]!==n.on||t[44]!==n.phasesTitle||t[45]!==n.scheduleTitle?(b=(0,Z.jsx)(te,{className:`min-w-0 !p-0`,children:o?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:i(J,`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`),children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.masterTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.masterHint})]}),(0,Z.jsxs)(`label`,{className:i(`inline-flex w-fit cursor-pointer items-center gap-2 rounded-xl border px-3 py-1.5 text-sm transition-colors`,o.enabled?`border-emerald-500/30 bg-emerald-500/5 text-fg`:`border-edge-subtle bg-surface-panel/50 text-fg-muted`),children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:o.enabled,disabled:!a||s||c,onChange:e=>void p(e.target.checked)}),c?(0,Z.jsx)(g,{className:`size-3.5 animate-spin text-fg-muted`,"aria-hidden":!0}):(0,Z.jsx)(`span`,{className:i(`text-xs font-semibold`,o.enabled?`text-emerald-600 dark:text-emerald-400`:``),children:o.enabled?n.masterOn:n.masterOff})]})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(be,{title:n.scheduleTitle}),(0,Z.jsx)(`div`,{className:J,children:(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 lg:grid-cols-12`,children:[(0,Z.jsx)(`div`,{className:`lg:col-span-9`,children:(0,Z.jsx)(M,{kind:`cron`,label:n.configFrequency,value:o.frequency,onChange:e=>f(t=>t&&{...t,frequency:e}),labels:r,disabled:!a||s})}),(0,Z.jsx)(Q,{label:n.configTimezone,className:`lg:col-span-3`,children:(0,Z.jsx)(`input`,{className:Y,value:o.timezone,disabled:!a||s,onChange:e=>f(t=>t&&{...t,timezone:e.target.value}),placeholder:`Asia/Shanghai`})})]})})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(be,{title:n.phasesTitle}),(0,Z.jsxs)(he,{icon:(0,Z.jsx)(_,{className:`size-4 text-amber-500`}),title:n.configPhaseLight,hint:n.configPhaseLightHint,enabled:o.light.enabled,onEnabledChange:e=>f(t=>t&&{...t,light:{...t.light,enabled:e}}),cron:o.light.cron,onCronChange:e=>f(t=>t&&{...t,light:{...t.light,cron:e}}),scheduleLabels:r,disabled:!a||s,showEnabledControl:o.enabled,actions:y(`light`,o.light.enabled),onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configLightLookbackDays,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:Y,value:o.light.lookbackDays,disabled:!a||s,onChange:e=>f(t=>t&&{...t,light:{...t.light,lookbackDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configLightLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:Y,value:o.light.limit,disabled:!a||s,onChange:e=>f(t=>t&&{...t,light:{...t.light,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configLightDedupe,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:Y,value:o.light.dedupeSimilarity,disabled:!a||s,onChange:e=>f(t=>t&&{...t,light:{...t.light,dedupeSimilarity:Number(e.target.value)}})})})]}),(0,Z.jsxs)(he,{icon:(0,Z.jsx)(S,{className:`size-4 text-indigo-500`}),title:n.configPhaseDeep,hint:n.configPhaseDeepHint,enabled:o.deep.enabled,onEnabledChange:e=>f(t=>t&&{...t,deep:{...t.deep,enabled:e}}),cron:o.deep.cron,onCronChange:e=>f(t=>t&&{...t,deep:{...t.deep,cron:e}}),scheduleLabels:r,disabled:!a||s,showEnabledControl:o.enabled,actions:y(`deep`,o.deep.enabled),onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configDeepMinScore,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:Y,value:o.deep.minScore,disabled:!a||s,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,minScore:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepMinRecallCount,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:Y,value:o.deep.minRecallCount,disabled:!a||s,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,minRecallCount:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:Y,value:o.deep.limit,disabled:!a||s,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepHalfLife,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:Y,value:o.deep.recencyHalfLifeDays,disabled:!a||s,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,recencyHalfLifeDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepMaxAge,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:Y,value:o.deep.maxAgeDays,disabled:!a||s,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,maxAgeDays:Number(e.target.value)}})})})]}),(0,Z.jsxs)(he,{icon:(0,Z.jsx)(h,{className:`size-4 text-purple-500`}),title:n.configPhaseRem,hint:n.configPhaseRemHint,enabled:o.rem.enabled,onEnabledChange:e=>f(t=>t&&{...t,rem:{...t.rem,enabled:e}}),cron:o.rem.cron,onCronChange:e=>f(t=>t&&{...t,rem:{...t.rem,cron:e}}),scheduleLabels:r,disabled:!a||s,showEnabledControl:o.enabled,actions:y(`rem`,o.rem.enabled),onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configRemLookbackDays,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:Y,value:o.rem.lookbackDays,disabled:!a||s,onChange:e=>f(t=>t&&{...t,rem:{...t.rem,lookbackDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configRemLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:Y,value:o.rem.limit,disabled:!a||s,onChange:e=>f(t=>t&&{...t,rem:{...t.rem,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configRemMinStrength,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:Y,value:o.rem.minPatternStrength,disabled:!a||s,onChange:e=>f(t=>t&&{...t,rem:{...t.rem,minPatternStrength:Number(e.target.value)}})})})]})]})]}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.configLoading})}),t[9]=o,t[10]=s,t[11]=c,t[12]=a,t[13]=y,t[14]=r,t[15]=f,t[16]=p,t[17]=n.configDeepHalfLife,t[18]=n.configDeepLimit,t[19]=n.configDeepMaxAge,t[20]=n.configDeepMinRecallCount,t[21]=n.configDeepMinScore,t[22]=n.configFrequency,t[23]=n.configLightDedupe,t[24]=n.configLightLimit,t[25]=n.configLightLookbackDays,t[26]=n.configLoading,t[27]=n.configPhaseCron,t[28]=n.configPhaseDeep,t[29]=n.configPhaseDeepHint,t[30]=n.configPhaseLight,t[31]=n.configPhaseLightHint,t[32]=n.configPhaseRem,t[33]=n.configPhaseRemHint,t[34]=n.configRemLimit,t[35]=n.configRemLookbackDays,t[36]=n.configRemMinStrength,t[37]=n.configTimezone,t[38]=n.masterHint,t[39]=n.masterOff,t[40]=n.masterOn,t[41]=n.masterTitle,t[42]=n.off,t[43]=n.on,t[44]=n.phasesTitle,t[45]=n.scheduleTitle,t[46]=b):b=t[46],b}function be(e){let t=(0,F.c)(2),{title:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`div`,{className:`px-0.5 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:n}),t[0]=n,t[1]=r),r}function xe(e){let t=(0,F.c)(8),{t:n,busy:r,disabled:i,onClick:a}=e,o;t[0]===r?o=t[1]:(o=r?(0,Z.jsx)(g,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(w,{className:`size-3.5`,"aria-hidden":!0}),t[0]=r,t[1]=o);let s;return t[2]!==i||t[3]!==a||t[4]!==n.runNow||t[5]!==n.runNowHint||t[6]!==o?(s=(0,Z.jsxs)(T,{type:`button`,variant:`secondary`,className:`h-7 gap-1.5 rounded-lg px-2 text-xs`,disabled:i,title:n.runNowHint,onClick:a,children:[o,n.runNow]}),t[2]=i,t[3]=a,t[4]=n.runNow,t[5]=n.runNowHint,t[6]=o,t[7]=s):s=t[7],s}function Se(e){let t=(0,F.c)(20),{t:n,hasToken:r,eventsLoading:i,events:a,loadEvents:o}=e,s=!r||i,c;t[0]===o?c=t[1]:(c=()=>void o(),t[0]=o,t[1]=c);let l;t[2]===i?l=t[3]:(l=i?(0,Z.jsx)(g,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):null,t[2]=i,t[3]=l);let u;t[4]!==n.eventsLoad||t[5]!==s||t[6]!==c||t[7]!==l?(u=(0,Z.jsxs)(T,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:s,onClick:c,children:[l,n.eventsLoad]}),t[4]=n.eventsLoad,t[5]=s,t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]!==n.eventsHint||t[10]!==n.eventsTitle||t[11]!==u?(d=(0,Z.jsx)(ee,{className:le,icon:m,title:n.eventsTitle,subtitle:n.eventsHint,trailing:u}),t[9]=n.eventsHint,t[10]=n.eventsTitle,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==a||t[14]!==n.eventsEmpty||t[15]!==n.eventsNotLoaded?(f=a?a.length>0?(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:a.map(Ce)}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.eventsEmpty}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.eventsNotLoaded}),t[13]=a,t[14]=n.eventsEmpty,t[15]=n.eventsNotLoaded,t[16]=f):f=t[16];let p;return t[17]!==d||t[18]!==f?(p=(0,Z.jsxs)(te,{className:ce,children:[d,f]}),t[17]=d,t[18]=f,t[19]=p):p=t[19],p}function Ce(e){let t=e.phase===`light`?`☀️`:e.phase===`rem`?`✨`:`🌙`,n=e.phase===`light`?`scanned=${e.scannedEntries??0} new=${e.newSignals??0} deduped=${e.deduped??0}`:e.phase===`rem`?`patterns=${e.patternsDiscovered??0} analyzed=${e.entriesAnalyzed??0}`:`candidates=${e.candidates??0} applied=${e.applied??0}`;return(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 text-xs`,children:[(0,Z.jsx)(`span`,{children:t}),(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:e.phase}),(0,Z.jsx)(`span`,{className:i(`font-medium`,e.ok?`text-emerald-600 dark:text-emerald-400`:`text-amber-600 dark:text-amber-400`),children:e.ok?`OK`:`FAIL`}),(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:n}),(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:X(e.durationMs)}),(0,Z.jsx)(`span`,{className:`ml-auto text-fg-subtle`,children:ue(e.timestamp)})]},`${e.timestamp}:${e.phase}`)}function we(e){let t=(0,F.c)(23),{t:n,hasToken:r,cfgForm:i,cfgSaving:a,cfgDirty:o,saveConfig:s,doRefresh:c}=e,l=!r||!i||a||!o,u;t[0]===s?u=t[1]:(u=()=>void s(),t[0]=s,t[1]=u);let d;t[2]===a?d=t[3]:(d=a?(0,Z.jsx)(g,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[2]=a,t[3]=d);let f;t[4]!==n.saveConfig||t[5]!==l||t[6]!==u||t[7]!==d?(f=(0,Z.jsxs)(T,{type:`button`,variant:`primary`,disabled:l,onClick:u,children:[d,n.saveConfig]}),t[4]=n.saveConfig,t[5]=l,t[6]=u,t[7]=d,t[8]=f):f=t[8];let p=!r,m;t[9]===c?m=t[10]:(m=()=>void c(),t[9]=c,t[10]=m);let h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(v,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[11]=h):h=t[11];let _;t[12]!==n.refresh||t[13]!==p||t[14]!==m?(_=(0,Z.jsx)(T,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,disabled:p,title:n.refresh,"aria-label":n.refresh,onClick:m,children:h}),t[12]=n.refresh,t[13]=p,t[14]=m,t[15]=_):_=t[15];let y;t[16]!==f||t[17]!==_?(y=(0,Z.jsxs)(Z.Fragment,{children:[f,_]}),t[16]=f,t[17]=_,t[18]=y):y=t[18];let b;return t[19]!==n.subtitle||t[20]!==n.title||t[21]!==y?(b=(0,Z.jsx)(A,{title:n.title,subtitle:n.subtitle,actions:y}),t[19]=n.subtitle,t[20]=n.title,t[21]=y,t[22]=b):b=t[22],b}function Te(e){let t=(0,F.c)(30),{t:n,disabled:r,actionBusy:a,doAction:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=i(`max-w-2xl`,ce),t[0]=s):s=t[0];let c;t[1]!==n.maintenanceHint||t[2]!==n.maintenanceTitle?(c=(0,Z.jsx)(ee,{className:le,icon:D,title:n.maintenanceTitle,subtitle:n.maintenanceHint}),t[1]=n.maintenanceHint,t[2]=n.maintenanceTitle,t[3]=c):c=t[3];let l;t[4]!==o||t[5]!==n.confirmResetStore?(l=()=>{confirm(n.confirmResetStore)&&o(`reset_store`)},t[4]=o,t[5]=n.confirmResetStore,t[6]=l):l=t[6];let u;t[7]===a?u=t[8]:(u=a===`reset_store`?(0,Z.jsx)(g,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(b,{className:`mr-2 size-4`,"aria-hidden":!0}),t[7]=a,t[8]=u);let d;t[9]!==r||t[10]!==n.resetStore||t[11]!==l||t[12]!==u?(d=(0,Z.jsxs)(T,{variant:`secondary`,disabled:r,onClick:l,children:[u,n.resetStore]}),t[9]=r,t[10]=n.resetStore,t[11]=l,t[12]=u,t[13]=d):d=t[13];let f;t[14]!==o||t[15]!==n.confirmClearLock?(f=()=>{confirm(n.confirmClearLock)&&o(`clear_lock`)},t[14]=o,t[15]=n.confirmClearLock,t[16]=f):f=t[16];let p;t[17]===a?p=t[18]:(p=a===`clear_lock`?(0,Z.jsx)(g,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(O,{className:`mr-2 size-4`,"aria-hidden":!0}),t[17]=a,t[18]=p);let m;t[19]!==r||t[20]!==n.clearLock||t[21]!==f||t[22]!==p?(m=(0,Z.jsxs)(T,{variant:`secondary`,disabled:r,onClick:f,children:[p,n.clearLock]}),t[19]=r,t[20]=n.clearLock,t[21]=f,t[22]=p,t[23]=m):m=t[23];let h;t[24]!==d||t[25]!==m?(h=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[d,m]}),t[24]=d,t[25]=m,t[26]=h):h=t[26];let _;return t[27]!==c||t[28]!==h?(_=(0,Z.jsxs)(te,{className:s,children:[c,h]}),t[27]=c,t[28]=h,t[29]=_):_=t[29],_}function Ee(e){let t=(0,F.c)(21),{t:n,hasToken:r,previewLoading:i,previewItems:a,loadPreview:o}=e,s=!r||i,c;t[0]===o?c=t[1]:(c=()=>void o(),t[0]=o,t[1]=c);let l;t[2]===i?l=t[3]:(l=i?(0,Z.jsx)(g,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):null,t[2]=i,t[3]=l);let u;t[4]!==n.previewLoad||t[5]!==s||t[6]!==c||t[7]!==l?(u=(0,Z.jsxs)(T,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:s,onClick:c,children:[l,n.previewLoad]}),t[4]=n.previewLoad,t[5]=s,t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]!==n.previewHint||t[10]!==n.previewTitle||t[11]!==u?(d=(0,Z.jsx)(ee,{className:le,icon:p,title:n.previewTitle,subtitle:n.previewHint,trailing:u}),t[9]=n.previewHint,t[10]=n.previewTitle,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==a||t[14]!==n.previewEligible||t[15]!==n.previewEmpty||t[16]!==n.previewNotLoaded?(f=a?a.length>0?(0,Z.jsx)(`div`,{className:`space-y-2`,children:a.map(e=>{let t=`${e.path}:${e.startLine}-${e.endLine}`,r=e.skippedReason;return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel/60 px-2.5 py-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:t}),(0,Z.jsxs)(`span`,{children:[`score=`,e.score.toFixed(3)]}),(0,Z.jsxs)(`span`,{children:[`recalls=`,e.recallCount]}),(0,Z.jsxs)(`span`,{children:[`avg=`,e.avgScore.toFixed(3)]}),(0,Z.jsxs)(`span`,{children:[`decay=`,e.recencyDecay?.toFixed(3)??`—`]}),r?(0,Z.jsx)(`span`,{className:`text-amber-600 dark:text-amber-400`,children:r}):(0,Z.jsx)(`span`,{className:`text-emerald-600 dark:text-emerald-400`,children:n.previewEligible})]}),e.snippet?(0,Z.jsx)(`div`,{className:`mt-2 text-sm text-fg`,children:e.snippet}):null]},`${e.key}:${e.hash}:${t}`)})}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.previewEmpty}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.previewNotLoaded}),t[13]=a,t[14]=n.previewEligible,t[15]=n.previewEmpty,t[16]=n.previewNotLoaded,t[17]=f):f=t[17];let m;return t[18]!==d||t[19]!==f?(m=(0,Z.jsxs)(te,{className:ce,children:[d,f]}),t[18]=d,t[19]=f,t[20]=m):m=t[20],m}function De(e,t){switch(e){case 3e4:return t.every30s;case 6e4:return t.every1min;case 3e5:return t.every5min;case 6e5:return t.every10min;case 9e5:return t.every15min;case 18e5:return t.every30min;case 36e5:return t.every1h;case 72e5:return t.every2h;default:return null}}var Oe={second:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`second`,unitDisplay:`long`}),minute:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`minute`,unitDisplay:`long`}),hour:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`hour`,unitDisplay:`long`})},ke={second:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`second`,unitDisplay:`long`}),minute:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`minute`,unitDisplay:`long`}),hour:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`hour`,unitDisplay:`long`})};function Ae(e,t){return e.startsWith(`zh`)?ke[t]:Oe[t]}function je(e,t,n){let r=Math.max(1e3,Math.round(e));if(n&&re.has(r)){let e=De(r,n);if(e)return e}let i=Math.max(1,Math.round(r/1e3));if(i<120)return Ae(t,`second`).format(i);let a=Math.round(i/60);if(a<120)return Ae(t,`minute`).format(a);let o=Math.round(a/60);return Ae(t,`hour`).format(o)}function Me(e){let t=(0,F.c)(12),n;t[0]!==e.expression||t[1]!==e.kind||t[2]!==e.labels||t[3]!==e.locale||t[4]!==e.nextRun||t[5]!==e.presetLabels||t[6]!==e.timezone||t[7]!==e.valueMs?(n=e.kind===`cron`?N(e.expression,e.locale,e.labels,{timezone:e.timezone,nextRun:e.nextRun}):je(e.valueMs,e.locale,e.presetLabels),t[0]=e.expression,t[1]=e.kind,t[2]=e.labels,t[3]=e.locale,t[4]=e.nextRun,t[5]=e.presetLabels,t[6]=e.timezone,t[7]=e.valueMs,t[8]=n):n=t[8];let r=n,i;return t[9]!==e.className||t[10]!==r?(i=(0,Z.jsx)(`span`,{className:e.className,children:r}),t[9]=e.className,t[10]=r,t[11]=i):i=t[11],i}function Ne(e){let t=(0,F.c)(100),{t:n,data:r,isLoading:a,localeTag:o,scheduleBadgeLabels:s}=e,c;t[0]!==r||t[1]!==n?(c=r?de(r.lock,n):null,t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=c,u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(`min-w-0`,ce),t[3]=u):u=t[3];let d;t[4]===a?d=t[5]:(d=a?(0,Z.jsx)(g,{className:`size-4 shrink-0 animate-spin text-fg-muted`,"aria-hidden":!0}):null,t[4]=a,t[5]=d);let f;t[6]!==n.runtimeHint||t[7]!==n.runtimeTitle||t[8]!==d?(f=(0,Z.jsx)(ee,{className:le,icon:m,title:n.runtimeTitle,subtitle:n.runtimeHint,trailing:d}),t[6]=n.runtimeHint,t[7]=n.runtimeTitle,t[8]=d,t[9]=f):f=t[9];let p;t[10]===n.subsectionSchedule?p=t[11]:(p=(0,Z.jsx)(me,{label:n.subsectionSchedule,className:`mb-2`}),t[10]=n.subsectionSchedule,t[11]=p);let v=r?r.config.enabled?n.on:n.off:`—`,y;t[12]!==n.enabled||t[13]!==v?(y=(0,Z.jsx)($,{label:n.enabled,children:v}),t[12]=n.enabled,t[13]=v,t[14]=y):y=t[14];let b=l?.className,x=l?l.text:`—`,C;t[15]!==b||t[16]!==x?(C=(0,Z.jsx)(`span`,{className:b,children:x}),t[15]=b,t[16]=x,t[17]=C):C=t[17];let w;t[18]!==n.lock||t[19]!==C?(w=(0,Z.jsx)($,{label:n.lock,children:C}),t[18]=n.lock,t[19]=C,t[20]=w):w=t[20];let T=r&&r.config.timezone||`—`,E;t[21]!==n.timezone||t[22]!==T?(E=(0,Z.jsx)($,{label:n.timezone,children:T}),t[21]=n.timezone,t[22]=T,t[23]=E):E=t[23];let D;t[24]!==r||t[25]!==o||t[26]!==s?(D=r?(0,Z.jsx)(Me,{kind:`cron`,expression:r.config.frequency,locale:o,labels:s,timezone:r.config.timezone||void 0}):`—`,t[24]=r,t[25]=o,t[26]=s,t[27]=D):D=t[27];let O;t[28]===r?O=t[29]:(O=r?.config.frequency?(0,Z.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[0.65rem] text-fg-subtle`,title:r.config.frequency,children:r.config.frequency}):null,t[28]=r,t[29]=O);let k;t[30]!==n.schedule||t[31]!==D||t[32]!==O?(k=(0,Z.jsxs)($,{label:n.schedule,className:`col-span-2 sm:col-span-2`,children:[D,O]}),t[30]=n.schedule,t[31]=D,t[32]=O,t[33]=k):k=t[33];let A;t[34]!==w||t[35]!==E||t[36]!==k||t[37]!==y?(A=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-4`,children:[y,w,E,k]}),t[34]=w,t[35]=E,t[36]=k,t[37]=y,t[38]=A):A=t[38];let j;t[39]!==A||t[40]!==p?(j=(0,Z.jsxs)(`div`,{className:J,children:[p,A]}),t[39]=A,t[40]=p,t[41]=j):j=t[41];let ne;t[42]===n.subsectionStore?ne=t[43]:(ne=(0,Z.jsx)(me,{label:n.subsectionStore,className:`mb-2`}),t[42]=n.subsectionStore,t[43]=ne);let re=r?String(r.store.entryCount):`—`,M;t[44]!==n.storeEntries||t[45]!==re?(M=(0,Z.jsx)($,{label:n.storeEntries,children:re}),t[44]=n.storeEntries,t[45]=re,t[46]=M):M=t[46];let P=r?String(r.store.promotedCount):`—`,I;t[47]!==n.storePromoted||t[48]!==P?(I=(0,Z.jsx)($,{label:n.storePromoted,children:P}),t[47]=n.storePromoted,t[48]=P,t[49]=I):I=t[49];let ie;t[50]===r?ie=t[51]:(ie=r?ue(r.store.updatedAt):`—`,t[50]=r,t[51]=ie);let ae;t[52]!==n.storeUpdatedAt||t[53]!==ie?(ae=(0,Z.jsx)($,{label:n.storeUpdatedAt,children:ie}),t[52]=n.storeUpdatedAt,t[53]=ie,t[54]=ae):ae=t[54];let L;t[55]===r?L=t[56]:(L=r?ue(r.store.lastPromotedAt):`—`,t[55]=r,t[56]=L);let oe;t[57]!==n.storeLastPromotedAt||t[58]!==L?(oe=(0,Z.jsx)($,{label:n.storeLastPromotedAt,children:L}),t[57]=n.storeLastPromotedAt,t[58]=L,t[59]=oe):oe=t[59];let R;t[60]!==M||t[61]!==I||t[62]!==ae||t[63]!==oe?(R=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-4`,children:[M,I,ae,oe]}),t[60]=M,t[61]=I,t[62]=ae,t[63]=oe,t[64]=R):R=t[64];let z;t[65]!==ne||t[66]!==R?(z=(0,Z.jsxs)(`div`,{className:J,children:[ne,R]}),t[65]=ne,t[66]=R,t[67]=z):z=t[67];let B;t[68]!==r||t[69]!==o||t[70]!==s||t[71]!==n?(B=r?.config?.phases?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(me,{label:n.subsectionPhases,className:`mb-2`}),(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[(0,Z.jsx)(ge,{icon:(0,Z.jsx)(_,{className:`size-4 text-amber-500`}),label:`Light`,enabled:r.config.phases.light.enabled,cron:r.config.phases.light.cron,scheduleSummary:N(r.config.phases.light.cron,o,s,{timezone:r.config.timezone||void 0}),details:`lookback=${r.config.phases.light.lookbackDays}d, limit=${r.config.phases.light.limit}, dedupe=${r.config.phases.light.dedupeSimilarity}`,t:n}),(0,Z.jsx)(ge,{icon:(0,Z.jsx)(S,{className:`size-4 text-indigo-500`}),label:`Deep`,enabled:r.config.phases.deep.enabled,cron:r.config.phases.deep.cron,scheduleSummary:N(r.config.phases.deep.cron,o,s,{timezone:r.config.timezone||void 0}),details:`minScore=${r.config.phases.deep.minScore}, recalls≥${r.config.phases.deep.minRecallCount}, limit=${r.config.phases.deep.limit}, halfLife=${r.config.phases.deep.recencyHalfLifeDays}d`,t:n}),(0,Z.jsx)(ge,{icon:(0,Z.jsx)(h,{className:`size-4 text-purple-500`}),label:`REM`,enabled:r.config.phases.rem.enabled,cron:r.config.phases.rem.cron,scheduleSummary:N(r.config.phases.rem.cron,o,s,{timezone:r.config.timezone||void 0}),details:`lookback=${r.config.phases.rem.lookbackDays}d, limit=${r.config.phases.rem.limit}, strength≥${r.config.phases.rem.minPatternStrength}`,t:n})]})]}):null,t[68]=r,t[69]=o,t[70]=s,t[71]=n,t[72]=B):B=t[72];let V;t[73]===n.subsectionLastRun?V=t[74]:(V=(0,Z.jsx)(me,{label:n.subsectionLastRun,className:`mb-2`}),t[73]=n.subsectionLastRun,t[74]=V);let H;t[75]===n.lastRunBlockHint?H=t[76]:(H=(0,Z.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:n.lastRunBlockHint}),t[75]=n.lastRunBlockHint,t[76]=H);let U;t[77]!==r||t[78]!==n?(U=r?.lastRun?.exists?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[r.lastRun.parseError?(0,Z.jsxs)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:[n.lastRunParseError,`: `,r.lastRun.parseError]}):null,r.lastRun.record?(0,Z.jsx)(`div`,{className:`rounded-lg border border-edge-subtle/80 bg-surface-panel/50 p-2.5`,children:(0,Z.jsx)(ve,{t:n,r:r.lastRun.record})}):null,r.lastRun.raw!==void 0&&r.lastRun.raw!==null?(0,Z.jsxs)(`details`,{className:`group rounded-lg border border-edge-subtle`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer list-none px-2.5 py-1.5 text-xs font-medium text-fg-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:(0,Z.jsx)(`span`,{className:`underline decoration-edge underline-offset-2 group-open:text-fg`,children:n.lastRunRaw})}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto border-t border-edge-subtle p-2.5 text-xs text-fg-muted`,children:JSON.stringify(r.lastRun.raw,null,2)})]}):null]}):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.lastRunEmpty}),t[77]=r,t[78]=n,t[79]=U):U=t[79];let W;t[80]!==V||t[81]!==H||t[82]!==U?(W=(0,Z.jsxs)(`div`,{className:J,children:[V,H,U]}),t[80]=V,t[81]=H,t[82]=U,t[83]=W):W=t[83];let G=r?.lightLastRun,K;t[84]!==n||t[85]!==G?(K=(0,Z.jsx)(_e,{label:n.subsectionLightLastRun,lastRun:G,t:n}),t[84]=n,t[85]=G,t[86]=K):K=t[86];let se=r?.remLastRun,q;t[87]!==n||t[88]!==se?(q=(0,Z.jsx)(_e,{label:n.subsectionRemLastRun,lastRun:se,t:n}),t[87]=n,t[88]=se,t[89]=q):q=t[89];let Y;t[90]!==j||t[91]!==z||t[92]!==B||t[93]!==W||t[94]!==K||t[95]!==q?(Y=(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[j,z,B,W,K,q]}),t[90]=j,t[91]=z,t[92]=B,t[93]=W,t[94]=K,t[95]=q,t[96]=Y):Y=t[96];let X;return t[97]!==Y||t[98]!==f?(X=(0,Z.jsxs)(te,{className:u,children:[f,Y]}),t[97]=Y,t[98]=f,t[99]=X):X=t[99],X}var Pe=[`config`,`runtime`,`insights`,`maintenance`],Fe={config:f,runtime:m,insights:p,maintenance:D};function Ie(e){return e&&Pe.includes(e)?e:`config`}function Le(e,t){return t===`config`?e.tabConfig:t===`runtime`?e.tabRuntime:t===`insights`?e.tabInsights:e.tabMaintenance}function Re(e,t){return t===`config`?e.configTabHint:t===`runtime`?e.runtimeTabHint:t===`insights`?e.insightsTabHint:e.maintenanceTabHint}function ze(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:return{form:t.value,baseline:t.value};case`set`:return{...e,form:t.value};case`saved`:return{form:t.value,baseline:t.value}}}var Be={actionBusy:null,actionError:null,actionOk:!1,runBusy:!1,runOk:!1,runError:null,runPhase:`deep`,cfgSaving:!1,enableSaving:!1,cfgOk:!1,cfgError:null,previewLoading:!1,previewError:null,previewItems:null,eventsLoading:!1,eventsError:null,events:null};function Ve(){let e=o(e=>e.language),t=a(e),n=t.dreamingSettings,r=t.cron.schedulePicker,i=t.cron.scheduleBadge,c=e===`zh`?`zh-CN`:`en-US`,l=!!s(e=>e.token),[f,p]=y(),m=Ie(f.get(`tab`)),h=(0,P.useCallback)(e=>{p(t=>{let n=new URLSearchParams(t);return e===`config`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[p]),[g,_]=(0,P.useReducer)(x,Be),{actionBusy:v,actionError:b,runBusy:S,runError:C,runPhase:w,cfgSaving:T,enableSaving:E,cfgError:D,previewLoading:O,previewError:ee,previewItems:te,eventsLoading:k,eventsError:A,events:j}=g,[re,M]=(0,P.useReducer)(ze,{form:null,baseline:null}),N=re.form,F=re.baseline,z=(0,P.useRef)(!1),{data:B,error:V,isLoading:H,mutate:U}=d(l?I():null,ie,{revalidateOnFocus:!1}),W=(0,P.useMemo)(()=>{let e=[];return V&&e.push(V instanceof Error?V.message:String(V)),b&&e.push(b),C&&e.push(C),ee&&e.push(ee),A&&e.push(A),D&&e.push(D),e},[V,b,C,ee,A,D]),G=(0,P.useCallback)(async()=>{_({type:`patch`,patch:{actionOk:!1,actionError:null,runOk:!1,runError:null,cfgOk:!1,cfgError:null,previewError:null}}),await U()},[U]),K=(0,P.useCallback)(async()=>{_({type:`patch`,patch:{previewLoading:!0,previewError:null}});try{_({type:`patch`,patch:{previewItems:(await oe(20)).items??[]}})}catch(e){_({type:`patch`,patch:{previewError:e instanceof Error?e.message:String(e)}})}finally{_({type:`patch`,patch:{previewLoading:!1}})}},[]),ce=(0,P.useCallback)(async()=>{_({type:`patch`,patch:{eventsLoading:!0,eventsError:null}});try{_({type:`patch`,patch:{events:await R(50)}})}catch(e){_({type:`patch`,patch:{eventsError:e instanceof Error?e.message:String(e)}})}finally{_({type:`patch`,patch:{eventsLoading:!1}})}},[]),le=(0,P.useCallback)(async(e=`deep`)=>{_({type:`patch`,patch:{runBusy:!0,runOk:!1,runError:null}});try{await L(e),_({type:`patch`,patch:{runOk:!0}}),u({type:`success`,title:n.runQueued}),await U()}catch(e){_({type:`patch`,patch:{runError:e instanceof Error?e.message:String(e)}})}finally{_({type:`patch`,patch:{runBusy:!1}})}},[U,n.runQueued]),J=(0,P.useCallback)(async e=>{_({type:`patch`,patch:{actionBusy:e,actionError:null,actionOk:!1}});try{await ae(e),_({type:`patch`,patch:{actionOk:!0}}),u({type:`success`,title:n.actionOk}),await U()}catch(e){_({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{_({type:`patch`,patch:{actionBusy:null}})}},[U,n.actionOk]),Y=!l||H||!!v,ue=(0,P.useMemo)(()=>{let e=B?.config;return se(e??{})},[B]),X=B?.agentId??`main`,de=B?.memory;(0,P.useEffect)(()=>{if(!l){M({type:`reset`}),z.current=!1;return}z.current||M({type:`sync`,value:ue})},[ue,l]);let fe=(0,P.useMemo)(()=>!N||!F?!1:JSON.stringify(N)!==JSON.stringify(F),[N,F]),pe=(0,P.useCallback)(async()=>{if(N){_({type:`patch`,patch:{cfgSaving:!0,cfgOk:!1,cfgError:null}});try{await q(X,N,de),M({type:`saved`,value:N}),z.current=!1,_({type:`patch`,patch:{cfgOk:!0}}),u({type:`success`,title:n.configSaved}),await U()}catch(e){_({type:`patch`,patch:{cfgError:e instanceof Error?e.message:String(e)}})}finally{_({type:`patch`,patch:{cfgSaving:!1}})}}},[X,de,N,U,n.configSaved]),Q=(0,P.useCallback)(async e=>{if(!N||!l)return;let t={...N,enabled:e},r=N;z.current=!0,M({type:`set`,value:t}),_({type:`patch`,patch:{enableSaving:!0,cfgOk:!1,cfgError:null}});try{await q(X,t,de),M({type:`saved`,value:t}),z.current=!1,_({type:`patch`,patch:{cfgOk:!0}}),u({type:`success`,title:n.configSaved}),await U()}catch(e){M({type:`set`,value:r}),_({type:`patch`,patch:{cfgError:e instanceof Error?e.message:String(e)}})}finally{_({type:`patch`,patch:{enableSaving:!1}})}},[X,de,N,l,U,n.configSaved]);return(0,Z.jsxs)(ne,{children:[(0,Z.jsx)(we,{t:n,hasToken:l,cfgForm:N,cfgSaving:T,cfgDirty:fe,saveConfig:pe,doRefresh:G}),W.length>0?(0,Z.jsx)(`div`,{className:`space-y-1.5 rounded-2xl border border-amber-500/20 bg-amber-500/5 px-4 py-3`,role:`alert`,children:W.map(e=>(0,Z.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200/90`,children:e},e))}):null,(0,Z.jsx)(He,{t:n,activeTab:m,onChange:h}),(0,Z.jsx)(Ue,{t:n,id:`config`,activeTab:m,children:(0,Z.jsx)(ye,{t:n,schedulePickerLabels:r,hasToken:l,cfgForm:N,cfgSaving:T,enableSaving:E,runPhase:w,setRunPhase:e=>_({type:`patch`,patch:{runPhase:e}}),runBusy:S,setCfgForm:e=>{z.current=!0;let t=typeof e==`function`?e(N):e;t&&M({type:`set`,value:t})},setDreamingEnabled:Q,doRunNow:le})}),(0,Z.jsx)(Ue,{t:n,id:`runtime`,activeTab:m,children:(0,Z.jsx)(Ne,{t:n,data:B,isLoading:H,localeTag:c,scheduleBadgeLabels:i})}),(0,Z.jsx)(Ue,{t:n,id:`insights`,activeTab:m,children:(0,Z.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,Z.jsx)(Ee,{t:n,hasToken:l,previewLoading:O,previewItems:te,loadPreview:K}),(0,Z.jsx)(Se,{t:n,hasToken:l,eventsLoading:k,events:j,loadEvents:ce})]})}),(0,Z.jsx)(Ue,{t:n,id:`maintenance`,activeTab:m,children:(0,Z.jsx)(Te,{t:n,disabled:Y,actionBusy:v,doAction:J})})]})}function He(e){let t=(0,F.c)(7),{t:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=Pe.map(e=>({id:e,label:Le(n,e),icon:Fe[e]})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,Z.jsx)(k,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`dreaming-settings-tab`,panelIdPrefix:`dreaming-settings-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function Ue(e){let t=(0,F.c)(13),{t:n,id:r,activeTab:i,children:a}=e,o=r!==`config`,s;t[0]!==r||t[1]!==n?(s=Le(n,r),t[0]=r,t[1]=n,t[2]=s):s=t[2];let c;t[3]!==r||t[4]!==n?(c=Re(n,r),t[3]=r,t[4]=n,t[5]=c):c=t[5];let l;return t[6]!==i||t[7]!==a||t[8]!==r||t[9]!==o||t[10]!==s||t[11]!==c?(l=(0,Z.jsx)(j,{id:r,activeTab:i,tabIdPrefix:`dreaming-settings-tab`,panelIdPrefix:`dreaming-settings-panel`,title:s,hint:c,showHeading:o,children:a}),t[6]=i,t[7]=a,t[8]=r,t[9]=o,t[10]=s,t[11]=c,t[12]=l):l=t[12],l}export{Ve as DreamingSettingsPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-CrDHEbss.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{i as s,n as c}from"./fetch-Y7AEX4H3.js";import{Bs as l,Ca as u,Cs as d,Gs as f,Ko as p,Ks as m,Ns as h,Oo as g,Qo as _,Ss as v,Us as y,W as b,Wa as x,X as S,Xs as C,Ya as w,Ys as T,Z as E,Zo as D,Zs as ee,_s as te,ba as ne,ds as re,et as ie,i as ae,nt as oe,o as se,sa as O,to as ce,ts as k,vs as le,ws as ue,zi as de}from"./index-BoKafJIZ.js";import{t as fe}from"./automation-suggestion-card-DhGDpKP3.js";var A=n(),j=e(t(),1),M=r(),N=`min-w-0 rounded-md border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,pe=[`message`,`link`,`file`,`diff`,`command`,`test`,`artifact`];function P(e){return e===`command`||e===`test`?u:e===`diff`?re:e===`file`||e===`artifact`?D:e===`link`?k:x}function me(e){return e.data&&typeof e.data==`object`&&!Array.isArray(e.data)?e.data:{}}function he(e,t){let n=e[t];return typeof n==`string`&&n.trim()?n:void 0}function ge(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function _e(e){let t=(0,A.c)(57),{item:n,language:r,t:i}=e,a;t[0]===n.kind?a=t[1]:(a=P(n.kind),t[0]=n.kind,t[1]=a);let o=a,s,c,l,u,d,f,p,m,h;if(t[2]!==o||t[3]!==n||t[4]!==r||t[5]!==i){let e=me(n),a=he(e,`command`),g=ge(e,`exitCode`),_=he(e,`path`)||n.uri,v=ge(e,`outputBytes`);s=e.fuzzyMatchUsed===!0,f=`rounded-md border border-edge/70 bg-surface-muted/40 px-2.5 py-2`;let y;t[15]===o?y=t[16]:(y=(0,M.jsx)(o,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),t[15]=o,t[16]=y);let b;t[17]===n.title?b=t[18]:(b=(0,M.jsx)(`p`,{className:`break-words font-medium text-fg`,children:n.title}),t[17]=n.title,t[18]=b);let x=_?(0,M.jsx)(`p`,{className:`mt-1 break-all text-xs text-fg-muted`,children:_}):null,S;t[19]!==b||t[20]!==x?(S=(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[b,x]}),t[19]=b,t[20]=x,t[21]=S):S=t[21];let C;t[22]!==y||t[23]!==S?(C=(0,M.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:[y,S]}),t[22]=y,t[23]=S,t[24]=C):C=t[24];let w;t[25]!==n.kind||t[26]!==i?(w=De(n.kind,i),t[25]=n.kind,t[26]=i,t[27]=w):w=t[27];let T;t[28]===w?T=t[29]:(T=(0,M.jsx)(`span`,{className:`rounded-full border border-edge px-2 py-0.5 text-xs text-fg-muted`,children:w}),t[28]=w,t[29]=T),t[30]!==C||t[31]!==T?(p=(0,M.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[C,T]}),t[30]=C,t[31]=T,t[32]=p):p=t[32],m=a?(0,M.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded-md bg-surface-panel px-2 py-1.5 text-xs text-fg`,children:(0,M.jsx)(`code`,{children:a})}):null,t[33]!==n.kind||t[34]!==n.summary?(h=n.summary?n.kind===`diff`?(0,M.jsx)(`pre`,{className:`mt-2 max-h-56 overflow-auto whitespace-pre-wrap rounded-md bg-surface-panel px-2 py-1.5 text-xs text-fg-muted`,children:(0,M.jsx)(`code`,{children:n.summary})}):(0,M.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words text-xs text-fg-muted`,children:n.summary}):null,t[33]=n.kind,t[34]=n.summary,t[35]=h):h=t[35],c=`mt-2 flex flex-wrap items-center gap-2 text-xs text-fg-muted`;let E;t[36]!==n.createdAt||t[37]!==r||t[38]!==i?(E=I(n.createdAt,r,i),t[36]=n.createdAt,t[37]=r,t[38]=i,t[39]=E):E=t[39],t[40]===E?l=t[41]:(l=(0,M.jsx)(`time`,{children:E}),t[40]=E,t[41]=l),u=g==null?null:(0,M.jsx)(`span`,{children:F(i.exitCode,{code:g})}),d=v==null?null:(0,M.jsx)(`span`,{children:F(i.outputBytes,{bytes:v})}),t[2]=o,t[3]=n,t[4]=r,t[5]=i,t[6]=s,t[7]=c,t[8]=l,t[9]=u,t[10]=d,t[11]=f,t[12]=p,t[13]=m,t[14]=h}else s=t[6],c=t[7],l=t[8],u=t[9],d=t[10],f=t[11],p=t[12],m=t[13],h=t[14];let g;t[42]!==s||t[43]!==i?(g=s?(0,M.jsx)(`span`,{children:i.fuzzyMatch}):null,t[42]=s,t[43]=i,t[44]=g):g=t[44];let _;t[45]!==g||t[46]!==c||t[47]!==l||t[48]!==u||t[49]!==d?(_=(0,M.jsxs)(`div`,{className:c,children:[l,u,d,g]}),t[45]=g,t[46]=c,t[47]=l,t[48]=u,t[49]=d,t[50]=_):_=t[50];let v;return t[51]!==_||t[52]!==f||t[53]!==p||t[54]!==m||t[55]!==h?(v=(0,M.jsxs)(`li`,{className:f,children:[p,m,h,_]}),t[51]=_,t[52]=f,t[53]=p,t[54]=m,t[55]=h,t[56]=v):v=t[56],v}function ve(e){return e===`active`?`border-accent/40 bg-accent-soft text-accent-fg`:e===`done`?`border-edge bg-surface-muted text-fg-muted`:e===`blocked`||e===`needs_input`?`border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300`:`border-edge bg-surface-panel text-fg-muted`}function ye(e){return e===`succeeded`?`border-emerald-500/40 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`failed`||e===`timeout`?`border-destructive/40 bg-destructive/10 text-destructive`:e===`cancelled`?`border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300`:`border-accent/40 bg-accent-soft text-accent-fg`}function be(e){return e===`workflow_run`?p:e===`goal_run`?h:e===`queue`?v:e===`evidence`?D:f}function F(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function xe(e){return e===`zh`?`zh-CN`:`en-US`}function I(e,t,n){return e?new Intl.DateTimeFormat(xe(t),{dateStyle:`medium`,timeStyle:`short`}).format(new Date(e)):n.notSet}function Se(e,t,n){return e?new Intl.DateTimeFormat(xe(t),{dateStyle:`medium`}).format(new Date(e)):n.noDeadline}function Ce(e,t){return e===`blocked`||e===`needs_input`?t.primaryActions.resolveBlocker:e===`paused`?t.primaryActions.resume:e===`done`?t.primaryActions.completed:e===`archived`?t.primaryActions.archived:t.primaryActions.continue}function we(e){return e===`completed`?`✓`:e===`impossible`?`!`:`○`}function Te(e){return e===`all`||e===`queue`||e===`goal_run`||e===`workflow_run`||e===`event`||e===`evidence`}function L(e,t){return e?t.statuses[e]??e:``}function Ee(e,t){return t.priorities[e]??e}function De(e,t){return t.evidenceKinds[e]??e}async function Oe(e){return(await c(s(`/api/goals/${encodeURIComponent(e)}`))).goal}async function ke(e){return(await c(s(`/api/goals/${encodeURIComponent(e)}/runs?limit=100`))).runs}async function Ae(e){return(await c(s(`/api/goals/${encodeURIComponent(e)}/evidence?limit=100`))).evidence}async function je(e){return(await c(s(`/api/goals/${encodeURIComponent(e)}/activity?limit=120`))).activities}async function Me(e){return(await c(s(`/api/goals/${encodeURIComponent(e)}/workflow-suggestions`))).suggestions}function R(){let{goalId:e=``}=C(),t=T(),n=o(e=>e.language),r=a(n).goalDetailPage,u=a(n).automations.suggestions,h=de(e=>e.setPageHeader),x=de(e=>e.clearPageHeader),[D,re]=ee(),[A,P]=(0,j.useState)(null),[ge,xe]=(0,j.useState)([]),[R,Ne]=(0,j.useState)([]),[z,Pe]=(0,j.useState)([]),[Fe,Ie]=(0,j.useState)([]),[B,V]=(0,j.useState)([]),[Le,H]=(0,j.useState)([]),[U,Re]=(0,j.useState)(``),[ze,Be]=(0,j.useState)(`message`),[Ve,He]=(0,j.useState)(``),[Ue,We]=(0,j.useState)(``),[Ge,Ke]=(0,j.useState)(``),[qe,Je]=(0,j.useState)(``),[Ye,Xe]=(0,j.useState)(``),[Ze,Qe]=(0,j.useState)(`normal`),[$e,et]=(0,j.useState)(``),[tt,nt]=(0,j.useState)(`10`),[rt,it]=(0,j.useState)(``),[at,ot]=(0,j.useState)(``),[st,ct]=(0,j.useState)(``),[W,lt]=(0,j.useState)(``),[ut,dt]=(0,j.useState)(``),[G,ft]=(0,j.useState)(!0),[K,q]=(0,j.useState)(null),[pt,J]=(0,j.useState)(null),Y=(0,j.useCallback)(async()=>{if(e){ft(!0),J(null);try{let[t,n,r]=await Promise.all([Oe(e),ke(e),Ae(e)]);P(t),xe(n);let[i,a]=await Promise.all([S(e,50),je(e)]);Pe(i),H(a),Ie(await Me(e)),V(r)}catch(e){J(e instanceof Error?e.message:r.errors.load)}finally{ft(!1)}}},[e,r.errors.load]);(0,j.useEffect)(()=>{Y()},[Y]),(0,j.useEffect)(()=>{let e=!1;return E().then(t=>{e||(Ne(t),lt(e=>e||t[0]?.id||``))}).catch(t=>{e||J(t instanceof Error?t.message:r.errors.loadWorkflows)}),()=>{e=!0}},[r.errors.loadWorkflows]),(0,j.useEffect)(()=>{A&&(Je(A.title),Xe(A.description??``),Qe(A.priority),et(A.deadlineAt?new Date(A.deadlineAt).toISOString().slice(0,10):``),nt(String(A.maxTurns)),it(A.judgeModelRef??``),ot(A.nextAction??``),ct(A.blockedReason??``),dt(e=>e||A.nextAction||A.title))},[A?.id,A?.updatedAt]);let mt=async()=>{if(A){q(`continue`);try{let e=await c(s(`/api/goals/${encodeURIComponent(A.id)}/continue`),{method:`POST`,body:JSON.stringify({})});if(e.sessionKey){t(`/chat/${encodeURIComponent(e.sessionKey)}`);return}await Y()}catch(e){J(e instanceof Error?e.message:r.errors.continue)}finally{q(null)}}},ht=async e=>{if(e.preventDefault(),!A)return;let t=qe.trim();if(t){q(`details:save`),J(null);try{let e=Number.parseInt(tt,10);P((await c(s(`/api/goals/${encodeURIComponent(A.id)}`),{method:`PATCH`,body:JSON.stringify({title:t,description:Ye.trim()||void 0,priority:Ze,deadlineAt:$e?new Date(`${$e}T23:59:59`).getTime():void 0,maxTurns:Number.isFinite(e)?e:A.maxTurns,judgeModelRef:rt.trim()||void 0,nextAction:at.trim()||void 0,blockedReason:st.trim()||void 0})})).goal),await X(A.id)}catch(e){J(e instanceof Error?e.message:r.errors.save)}finally{q(null)}}},gt=async e=>{if(A){q(e);try{await c(s(`/api/goals/${encodeURIComponent(A.id)}/${e}`),{method:`POST`,body:JSON.stringify({})}),await Y()}catch(e){J(e instanceof Error?e.message:r.errors.action)}finally{q(null)}}},_t=async()=>{if(!(!A||!W)){q(`workflow:run`),J(null);try{let e=await oe({goalId:A.id,definitionId:W,goal:ut.trim()||A.nextAction||A.title});await Y(),t(`/chat/${encodeURIComponent(e.sessionKey)}`)}catch(e){J(e instanceof Error?e.message:r.errors.startWorkflow)}finally{q(null)}}},X=async e=>{try{H(await je(e))}catch{}},vt=async e=>{try{let[t,n,r]=await Promise.all([S(e,50),je(e),Me(e)]);Pe(t),H(n),Ie(r)}catch{}},yt=async e=>{if(A){q(`workflow:${e.id}:cancel`),J(null);try{await b(e.id,{ownerAgentId:A.agentId}),await vt(A.id)}catch(e){J(e instanceof Error?e.message:r.errors.cancelWorkflow)}finally{q(null)}}},bt=async e=>{if(A){q(`workflow:${e.id}:retry`),J(null);try{let n=await ie(e.id,{ownerAgentId:A.agentId});await vt(A.id),t(`/chat/${encodeURIComponent(n.sessionKey)}`)}catch(e){J(e instanceof Error?e.message:r.errors.retryWorkflow)}finally{q(null)}}},xt=async e=>{if(e.preventDefault(),!A)return;let t=U.trim();if(t){q(`checklist:add`),J(null);try{P((await c(s(`/api/goals/${encodeURIComponent(A.id)}/checklist`),{method:`POST`,body:JSON.stringify({text:t})})).goal),Re(``),await X(A.id)}catch(e){J(e instanceof Error?e.message:r.errors.addChecklist)}finally{q(null)}}},St=async(e,t)=>{if(A){q(`checklist:${e}:${t}`),J(null);try{P((await c(s(`/api/goals/${encodeURIComponent(A.id)}/checklist/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({status:t})})).goal),await X(A.id)}catch(e){J(e instanceof Error?e.message:r.errors.updateChecklist)}finally{q(null)}}},Ct=async e=>{if(A){q(`checklist:${e}:delete`),J(null);try{P((await c(s(`/api/goals/${encodeURIComponent(A.id)}/checklist/${encodeURIComponent(e)}`),{method:`DELETE`})).goal),await X(A.id)}catch(e){J(e instanceof Error?e.message:r.errors.deleteChecklist)}finally{q(null)}}},wt=async e=>{if(e.preventDefault(),!A)return;let t=Ve.trim();if(t){q(`evidence:add`),J(null);try{let e=await c(s(`/api/goals/${encodeURIComponent(A.id)}/evidence`),{method:`POST`,body:JSON.stringify({kind:ze,title:t,summary:Ue.trim()||void 0,uri:Ge.trim()||void 0})});V(t=>[e.evidence,...t]),He(``),We(``),Ke(``),await X(A.id)}catch(e){J(e instanceof Error?e.message:r.errors.addEvidence)}finally{q(null)}}},Tt=async e=>{if(!A||!e.summary)return;J(null);let t=a(n).automations,r=await c(s(`/api/goals/${encodeURIComponent(A.id)}/evidence`),{method:`POST`,body:JSON.stringify({kind:`message`,title:se(t.feedback.insightEvidenceTitle,{name:e.automationName}),summary:e.summary,data:{source:`automation`,automationRunId:e.id,automationId:e.automationId,automationName:e.automationName,sessionKey:e.sessionKey,workflowRunId:e.workflowRunId}})});V(e=>[r.evidence,...e]),await X(A.id)},Z=A?.checklist.filter(e=>e.status===`completed`||e.status===`impossible`).length??0,Q=A?.checklist.length??0,Et=(0,j.useMemo)(()=>{let e=new Set;for(let t of B){let n=he(me(t),`automationRunId`);n&&e.add(n)}return e},[B]),Dt=z.filter(e=>e.status===`failed`||e.status===`timeout`||e.status===`cancelled`),$=ge[0],Ot=Te(D.get(`timeline`))?D.get(`timeline`):`all`,kt=Ot===`all`?Le:Le.filter(e=>e.kind===Ot),At=z.filter(e=>e.status===`queued`||e.status===`running`),jt=K!=null||A?.status===`done`||A?.status===`archived`,Mt=(0,j.useMemo)(()=>A?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(O,{type:`button`,variant:`primary`,className:`h-9 gap-2 rounded-lg px-2.5 md:px-3`,"aria-label":Ce(A.status,r),disabled:jt,onClick:()=>void mt(),children:[(0,M.jsx)(v,{className:`size-4`,"aria-hidden":!0}),(0,M.jsx)(`span`,{className:`hidden md:inline`,children:Ce(A.status,r)})]}),A.activeSessionKey?(0,M.jsxs)(O,{type:`button`,variant:`secondary`,className:`h-9 gap-2 rounded-lg px-2.5 md:px-3`,"aria-label":r.chat,onClick:()=>t(`/chat/${encodeURIComponent(A.activeSessionKey)}`),children:[(0,M.jsx)(k,{className:`size-4`,"aria-hidden":!0}),(0,M.jsx)(`span`,{className:`hidden md:inline`,children:r.chat})]}):null,(0,M.jsxs)(O,{type:`button`,variant:`secondary`,className:`h-9 gap-2 rounded-lg px-2.5 md:px-3`,"aria-label":r.pause,disabled:K!=null||A.status!==`active`,onClick:()=>void gt(`pause`),children:[(0,M.jsx)(d,{className:`size-4`,"aria-hidden":!0}),(0,M.jsx)(`span`,{className:`hidden md:inline`,children:r.pause})]}),(0,M.jsxs)(O,{type:`button`,variant:`ghost`,className:`h-9 gap-2 rounded-lg px-2.5 md:px-3`,"aria-label":r.archive,disabled:K!=null||A.status===`archived`,onClick:()=>{window.confirm(r.archiveConfirm)&>(`archive`)},children:[(0,M.jsx)(y,{className:`size-4`,"aria-hidden":!0}),(0,M.jsx)(`span`,{className:`hidden md:inline`,children:r.archive})]})]}):null,[K,A,t,jt,r]);(0,j.useLayoutEffect)(()=>(h({startExtra:(0,M.jsx)(m,{to:`/goals`,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":r.back,children:(0,M.jsx)(l,{className:`size-4`,"aria-hidden":!0})}),main:(0,M.jsxs)(`div`,{className:`min-w-0`,children:[(0,M.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:A?.title??(G?r.loading:r.notFound)}),A?(0,M.jsxs)(`p`,{className:`truncate text-xs text-fg-muted`,children:[L(A.status,r),` · `,F(r.agent,{agentId:A.agentId}),` · `,F(r.turns,{used:A.turnsUsed,max:A.maxTurns}),Q?` · ${F(r.checklistProgress,{done:Z,total:Q})}`:``]}):null]}),end:Mt}),()=>x()),[x,Z,A,Mt,G,h,r,Q]);let Nt=e=>{let t=new URLSearchParams(D);e===`all`?t.delete(`timeline`):t.set(`timeline`,e),re(t,{replace:!0})};return(0,M.jsx)(`main`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto bg-surface-base`,children:(0,M.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-1 flex-col gap-4 px-4 py-5 sm:px-6`,children:[G?(0,M.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.loading}):null,pt?(0,M.jsx)(`p`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:pt}):null,!G&&!A?(0,M.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.notFound}):null,A?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsx)(`span`,{className:i(`rounded-full border px-2 py-0.5 text-xs`,ve(A.status)),children:L(A.status,r)}),(0,M.jsx)(`span`,{className:`text-xs text-fg-muted`,children:F(r.prioritySummary,{priority:Ee(A.priority,r)})}),(0,M.jsx)(`span`,{className:`text-xs text-fg-muted`,children:A.deadlineAt?Se(A.deadlineAt,n,r):r.noDeadline})]}),A.description?(0,M.jsx)(`p`,{className:`mt-3 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:A.description}):null,(0,M.jsxs)(`div`,{className:`mt-3 rounded-md border border-edge/70 bg-surface-muted/40 px-3 py-2`,children:[(0,M.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:A.blockedReason?r.currentBlocker:r.nextAction}),(0,M.jsx)(`p`,{className:i(`mt-1 break-words text-sm`,A.blockedReason?`text-amber-700 dark:text-amber-300`:`text-fg`),children:A.blockedReason||A.nextAction||r.noNextAction})]})]}),(0,M.jsxs)(`section`,{className:`grid gap-4 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,M.jsxs)(`div`,{className:`grid min-w-0 gap-4`,children:[(0,M.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,M.jsx)(g,{className:`size-4 text-accent`,"aria-hidden":!0}),r.acceptance]}),(0,M.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.acceptanceHint})]}),(0,M.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[Z,`/`,Q]})]}),$?(0,M.jsxs)(`div`,{className:`mt-3 rounded-md border border-edge/70 bg-surface-muted/40 px-3 py-2`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs text-fg-muted`,children:[(0,M.jsx)(`span`,{children:F(r.latestJudgement,{status:L($.verdict??$.status,r)})}),(0,M.jsx)(`time`,{children:I($.finishedAt??$.startedAt,n,r)})]}),$.reason?(0,M.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:$.reason}):null,$.nextAction?(0,M.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-muted`,children:F(r.latestNext,{next:$.nextAction})}):null]}):null,(0,M.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,M.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,M.jsx)(g,{className:`size-4 text-accent`,"aria-hidden":!0}),r.checklist]}),(0,M.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[Z,`/`,Q]})]}),(0,M.jsxs)(`form`,{className:`mb-3 flex flex-col gap-2 sm:flex-row`,onSubmit:xt,children:[(0,M.jsx)(`input`,{value:U,onChange:e=>Re(e.target.value),name:`checklistText`,"aria-label":r.addAcceptancePlaceholder,autoComplete:`off`,placeholder:r.addAcceptancePlaceholder,className:i(N,`flex-1`)}),(0,M.jsxs)(O,{type:`submit`,variant:`secondary`,className:`h-9 gap-2`,disabled:K!=null||!U.trim(),children:[(0,M.jsx)(ce,{className:`size-4`,"aria-hidden":!0}),r.add]})]}),A.checklist.length?(0,M.jsx)(`ul`,{className:`space-y-2 text-sm`,children:A.checklist.map(e=>(0,M.jsx)(`li`,{className:`rounded-md border border-edge/70 bg-surface-muted/40 px-2.5 py-2`,children:(0,M.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2`,children:[(0,M.jsx)(`span`,{className:`mt-1 w-5 shrink-0 text-center text-fg-muted`,children:we(e.status)}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(`p`,{className:`break-words text-fg`,children:e.text}),e.evidenceSummary?(0,M.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.evidenceSummary}):null]}),(0,M.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,M.jsx)(O,{type:`button`,variant:`ghost`,className:`size-8 p-0`,title:r.markPending,"aria-label":r.markPending,disabled:K!=null||e.status===`pending`,onClick:()=>void St(e.id,`pending`),children:(0,M.jsx)(te,{className:`size-4`,"aria-hidden":!0})}),(0,M.jsx)(O,{type:`button`,variant:`ghost`,className:`size-8 p-0`,title:r.markCompleted,"aria-label":r.markCompleted,disabled:K!=null||e.status===`completed`,onClick:()=>void St(e.id,`completed`),children:(0,M.jsx)(ue,{className:`size-4`,"aria-hidden":!0})}),(0,M.jsx)(O,{type:`button`,variant:`ghost`,className:`size-8 p-0`,title:r.markImpossible,"aria-label":r.markImpossible,disabled:K!=null||e.status===`impossible`,onClick:()=>void St(e.id,`impossible`),children:(0,M.jsx)(le,{className:`size-4`,"aria-hidden":!0})}),(0,M.jsx)(O,{type:`button`,variant:`ghost`,className:`size-8 p-0 text-destructive hover:text-destructive`,title:r.deleteChecklistItem,"aria-label":r.deleteChecklistItem,disabled:K!=null,onClick:()=>void Ct(e.id),children:(0,M.jsx)(ne,{className:`size-4`,"aria-hidden":!0})})]})]})},e.id))}):(0,M.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.noChecklist}),(0,M.jsxs)(`div`,{className:`mt-4 border-t border-edge pt-4`,children:[(0,M.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,M.jsx)(_,{className:`size-4 text-accent`,"aria-hidden":!0}),r.evidence]}),(0,M.jsxs)(`form`,{className:`mb-3 grid gap-2`,onSubmit:wt,children:[(0,M.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[9rem_minmax(0,1fr)]`,children:[(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.kind,(0,M.jsx)(`select`,{value:ze,onChange:e=>Be(e.target.value),className:N,name:`evidenceKind`,children:pe.map(e=>(0,M.jsx)(`option`,{value:e,children:De(e,r)},e))})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.title,(0,M.jsx)(`input`,{value:Ve,onChange:e=>He(e.target.value),name:`evidenceTitle`,autoComplete:`off`,placeholder:r.evidenceTitlePlaceholder,className:N})]})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.uriOrPath,(0,M.jsx)(`input`,{value:Ge,onChange:e=>Ke(e.target.value),name:`evidenceUri`,autoComplete:`off`,placeholder:r.uriOrPathPlaceholder,className:N})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.summary,(0,M.jsx)(`textarea`,{value:Ue,onChange:e=>We(e.target.value),name:`evidenceSummary`,autoComplete:`off`,placeholder:r.summaryPlaceholder,rows:3,className:i(N,`resize-y`)})]}),(0,M.jsxs)(O,{type:`submit`,variant:`secondary`,className:`h-9 w-fit gap-2`,disabled:K!=null||!Ve.trim(),children:[(0,M.jsx)(ce,{className:`size-4`,"aria-hidden":!0}),r.addEvidence]})]}),B.length?(0,M.jsx)(`ul`,{className:`space-y-2 text-sm`,children:B.slice(0,6).map(e=>(0,M.jsx)(_e,{item:e,language:n,t:r},e.id))}):(0,M.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.noEvidence})]})]}),(0,M.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,M.jsx)(f,{className:`size-4 text-accent`,"aria-hidden":!0}),r.timeline]}),(0,M.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.timelineHint})]}),(0,M.jsxs)(O,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,onClick:()=>void Y(),children:[(0,M.jsx)(w,{className:`size-3.5`,"aria-hidden":!0}),r.refresh]})]}),(0,M.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[`all`,`goal_run`,`workflow_run`,`evidence`,`queue`,`event`].map(e=>(0,M.jsx)(`button`,{type:`button`,className:i(`rounded-md border px-2.5 py-1 text-xs font-medium`,Ot===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>Nt(e),children:r.timelineFilters[e]},e))}),kt.length?(0,M.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm`,children:kt.map(e=>(0,M.jsx)(`li`,{className:`rounded-md border border-edge/60 bg-surface-muted/50 px-2.5 py-2`,children:(0,M.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:[(0,M.jsx)(be(e.kind),{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[(0,M.jsx)(`span`,{children:r.timelineFilters[e.kind]}),e.status?(0,M.jsx)(`span`,{children:L(e.status,r)}):null]}),(0,M.jsx)(`p`,{className:`mt-1 break-words font-medium text-fg`,children:e.title}),e.summary?(0,M.jsx)(`p`,{className:`mt-1 line-clamp-3 break-words text-xs text-fg-muted`,children:e.summary}):null]})]}),(0,M.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1 text-xs text-fg-muted`,children:[(0,M.jsx)(`time`,{children:I(e.createdAt,n,r)}),e.link?.type===`chat`?(0,M.jsxs)(O,{type:`button`,variant:`ghost`,className:`h-7 gap-1.5`,onClick:()=>t(`/chat/${encodeURIComponent(e.link.value)}`),children:[(0,M.jsx)(k,{className:`size-3.5`,"aria-hidden":!0}),r.chat]}):null,e.link?.type===`workflow_run`?(0,M.jsxs)(O,{type:`button`,variant:`ghost`,className:`h-7 gap-1.5`,onClick:()=>t(`/workflows?run=${encodeURIComponent(e.link.value)}`),children:[(0,M.jsx)(k,{className:`size-3.5`,"aria-hidden":!0}),r.run]}):null]})]})},e.id))}):(0,M.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:r.noTimeline})]})]}),(0,M.jsxs)(`aside`,{className:`grid h-fit gap-4`,children:[(0,M.jsx)(ae,{eventType:`goal.status_changed`,source:`goals`,payloadKey:`goalId`,payloadValue:A.id,onSaveInsight:Tt,isInsightSaved:e=>Et.has(e.id)}),(0,M.jsx)(ae,{eventType:`goal.created`,source:`goals`,payloadKey:`goalId`,payloadValue:A.id,onSaveInsight:Tt,isInsightSaved:e=>Et.has(e.id)}),A.status===`blocked`||A.blockedReason?(0,M.jsx)(fe,{title:u.goalBlockedTitle,description:u.goalBlockedDescription,prompt:F(u.goalBlockedPrompt,{title:A.title}),coverage:{eventType:`goal.status_changed`,source:`goals`,eventPayload:{goalId:A.id,status:`blocked`}}}):null,(0,M.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,M.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.goalSettings}),(0,M.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-sm`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,M.jsx)(`dt`,{className:`text-fg-muted`,children:r.deadline}),(0,M.jsx)(`dd`,{className:`text-right text-fg`,children:Se(A.deadlineAt,n,r)})]}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,M.jsx)(`dt`,{className:`text-fg-muted`,children:r.judgeModel}),(0,M.jsx)(`dd`,{className:`min-w-0 truncate text-right text-fg`,children:A.judgeModelRef||r.default})]}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,M.jsx)(`dt`,{className:`text-fg-muted`,children:r.created}),(0,M.jsx)(`dd`,{className:`text-right text-fg`,children:Se(A.createdAt,n,r)})]}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,M.jsx)(`dt`,{className:`text-fg-muted`,children:r.updated}),(0,M.jsx)(`dd`,{className:`text-right text-fg`,children:I(A.updatedAt,n,r)})]})]}),(0,M.jsxs)(`details`,{className:`mt-4 rounded-md border border-edge/70 bg-surface-muted/40 px-3 py-2`,children:[(0,M.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:r.editDetails}),(0,M.jsxs)(`form`,{className:`mt-3 grid gap-3`,onSubmit:ht,children:[(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.title,(0,M.jsx)(`input`,{value:qe,onChange:e=>Je(e.target.value),name:`goalTitle`,autoComplete:`off`,className:N,placeholder:`${r.title}…`})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.description,(0,M.jsx)(`textarea`,{value:Ye,onChange:e=>Xe(e.target.value),name:`goalDescription`,autoComplete:`off`,className:i(N,`resize-y`),rows:3,placeholder:`${r.description}…`})]}),(0,M.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3 xl:grid-cols-1`,children:[(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.priority,(0,M.jsxs)(`select`,{value:Ze,onChange:e=>Qe(e.target.value),name:`goalPriority`,className:N,children:[(0,M.jsx)(`option`,{value:`low`,children:r.priorities.low}),(0,M.jsx)(`option`,{value:`normal`,children:r.priorities.normal}),(0,M.jsx)(`option`,{value:`high`,children:r.priorities.high})]})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.deadline,(0,M.jsx)(`input`,{value:$e,onChange:e=>et(e.target.value),name:`goalDeadline`,className:N,type:`date`})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.maxTurns,(0,M.jsx)(`input`,{value:tt,onChange:e=>nt(e.target.value),name:`goalMaxTurns`,className:N,type:`number`,min:1,max:500,inputMode:`numeric`,placeholder:`${r.maxTurns}…`})]})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.judgeModel,(0,M.jsx)(`input`,{value:rt,onChange:e=>it(e.target.value),name:`goalJudgeModel`,autoComplete:`off`,className:N,placeholder:`${r.judgeModel}…`})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.nextAction,(0,M.jsx)(`textarea`,{value:at,onChange:e=>ot(e.target.value),name:`goalNextAction`,autoComplete:`off`,className:i(N,`resize-y`),rows:2,placeholder:`${r.nextAction}…`})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.blockedReason,(0,M.jsx)(`textarea`,{value:st,onChange:e=>ct(e.target.value),name:`goalBlockedReason`,autoComplete:`off`,className:i(N,`resize-y`),rows:2,placeholder:`${r.blockedReason}…`})]}),(0,M.jsx)(O,{type:`submit`,variant:`secondary`,className:`h-9 w-fit`,disabled:K!=null||!qe.trim(),children:r.saveDetails})]})]})]}),(0,M.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,M.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,M.jsx)(p,{className:`size-4 text-accent`,"aria-hidden":!0}),r.workflow]}),(0,M.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.workflowHint})]}),At.length?(0,M.jsx)(`span`,{className:`rounded-full border border-accent/40 bg-accent-soft px-2 py-0.5 text-xs text-accent-fg`,children:F(r.activeCount,{count:At.length})}):null]}),Fe.length?(0,M.jsx)(`div`,{className:`mt-3 grid gap-2`,children:Fe.slice(0,2).map(e=>(0,M.jsxs)(`button`,{type:`button`,className:i(`min-w-0 rounded-md border border-edge/70 bg-surface-muted/40 px-2.5 py-2 text-left hover:border-accent/60 hover:bg-accent-soft/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,W===e.definitionId&&`border-accent/70 bg-accent-soft/60`),onClick:()=>{lt(e.definitionId),dt(A.nextAction||A.title)},children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,M.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.title}),(0,M.jsx)(`span`,{className:`shrink-0 rounded-full border border-edge px-2 py-0.5 text-xs text-fg-muted`,children:e.score})]}),(0,M.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:e.description})]},e.definitionId))}):null,(0,M.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.definition,(0,M.jsxs)(`select`,{value:W,onChange:e=>lt(e.target.value),className:N,name:`workflowDefinition`,disabled:R.length===0,children:[R.length===0?(0,M.jsx)(`option`,{value:``,children:r.noWorkflows}):null,R.map(e=>(0,M.jsx)(`option`,{value:e.id,children:e.title||e.name},e.id))]})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.workflowGoal,(0,M.jsx)(`input`,{value:ut,onChange:e=>dt(e.target.value),name:`workflowGoal`,autoComplete:`off`,className:N,placeholder:`${r.workflowGoal}…`})]}),(0,M.jsxs)(O,{type:`button`,variant:`secondary`,className:`h-9 w-fit gap-2`,disabled:K!=null||!W||A.status===`done`||A.status===`archived`,onClick:()=>void _t(),children:[(0,M.jsx)(v,{className:`size-4`,"aria-hidden":!0}),r.runWorkflow]})]}),z.length?(0,M.jsxs)(`div`,{className:`mt-4 border-t border-edge pt-3`,children:[(0,M.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,M.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.recentWorkflowRuns}),(0,M.jsx)(`button`,{type:`button`,className:`text-xs text-fg-muted hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>Nt(`workflow_run`),children:r.viewTimeline})]}),(0,M.jsx)(`ul`,{className:`grid gap-2`,children:z.slice(0,3).map(e=>{let a=e.metadata?.sessionKey,o=e.status===`queued`||e.status===`running`,s=e.status===`failed`||e.status===`timeout`||e.status===`cancelled`;return(0,M.jsxs)(`li`,{className:`rounded-md border border-edge/70 bg-surface-muted/40 px-2.5 py-2 text-sm`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs text-fg-muted`,children:[(0,M.jsx)(`span`,{className:`min-w-0 truncate`,children:e.definitionId}),(0,M.jsx)(`span`,{className:i(`shrink-0 rounded-full border px-2 py-0.5`,ye(e.status)),children:L(e.status,r)})]}),(0,M.jsx)(`p`,{className:`mt-1 truncate text-fg`,children:e.title}),(0,M.jsx)(`time`,{className:`mt-1 block text-xs text-fg-muted`,children:I(e.completedAtMs??e.startedAtMs??e.createdAtMs,n,r)}),(0,M.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[a?(0,M.jsxs)(O,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,onClick:()=>t(`/chat/${encodeURIComponent(a)}`),children:[(0,M.jsx)(k,{className:`size-3.5`,"aria-hidden":!0}),r.chat]}):null,o?(0,M.jsxs)(O,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 text-destructive hover:text-destructive`,disabled:K!=null,onClick:()=>void yt(e),children:[(0,M.jsx)(le,{className:`size-3.5`,"aria-hidden":!0}),r.cancel]}):null,s?(0,M.jsxs)(O,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,disabled:K!=null,onClick:()=>void bt(e),children:[(0,M.jsx)(w,{className:`size-3.5`,"aria-hidden":!0}),r.retry]}):null]})]},e.id)})})]}):null,Dt.length?(0,M.jsxs)(`div`,{className:`mt-4 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-amber-800 dark:text-amber-200`,children:r.recoveryNeeded}),(0,M.jsx)(`span`,{className:`text-xs text-amber-700 dark:text-amber-300`,children:F(r.failedCount,{count:Dt.length})})]}),(0,M.jsx)(`ul`,{className:`mt-2 grid gap-2`,children:Dt.slice(0,3).map(e=>(0,M.jsxs)(`li`,{className:`grid gap-2 text-sm`,children:[(0,M.jsxs)(`div`,{className:`min-w-0`,children:[(0,M.jsx)(`p`,{className:`truncate text-fg`,children:e.title}),(0,M.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[e.definitionId,` · `,L(e.status,r)]})]}),(0,M.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,M.jsxs)(O,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,onClick:()=>t(`/workflows?run=${encodeURIComponent(e.id)}`),children:[(0,M.jsx)(k,{className:`size-3.5`,"aria-hidden":!0}),r.run]}),(0,M.jsxs)(O,{type:`button`,variant:`secondary`,className:`h-8 gap-1.5`,disabled:K!=null,onClick:()=>void bt(e),children:[(0,M.jsx)(w,{className:`size-3.5`,"aria-hidden":!0}),r.retry]})]})]},e.id))})]}):null]})]})]})]}):null]})})}export{R as GoalDetailPage};
|