@xopcai/xopc 0.0.112 → 0.0.113

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.
Files changed (102) hide show
  1. package/dist/browser-ext/icons/icon-128.png +0 -0
  2. package/dist/browser-ext/icons/icon-16.png +0 -0
  3. package/dist/browser-ext/icons/icon-32.png +0 -0
  4. package/dist/browser-ext/icons/icon-48.png +0 -0
  5. package/dist/browser-ext/manifest.json +1 -1
  6. package/dist/extensions/telegram/xopc.extension.json +1 -1
  7. package/dist/extensions/weixin/src/delivery-to.d.ts +3 -3
  8. package/dist/extensions/weixin/src/delivery-to.js.map +1 -1
  9. package/dist/gateway/static/root/apple-touch-icon.png +0 -0
  10. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-EhRp-ZMa.js → agent-avatar-dicebear-CBlklyNr.js} +1 -1
  11. package/dist/gateway/static/root/assets/{agent-browser-settings-page-H4foVCiS.js → agent-browser-settings-page-rGbKc2Hh.js} +1 -1
  12. package/dist/gateway/static/root/assets/{agent-defaults-tabbed-page-DDNw2oNU.js → agent-defaults-tabbed-page-CtwVbjOA.js} +1 -1
  13. package/dist/gateway/static/root/assets/{agents-E_X2kzS1.js → agents-CCBmGcwc.js} +3 -3
  14. package/dist/gateway/static/root/assets/{app-management-settings-panel-BIy7KEsM.js → app-management-settings-panel-28E_WfMe.js} +1 -1
  15. package/dist/gateway/static/root/assets/{appearance-settings-DGQG8NwA.js → appearance-settings-Do1z0XgJ.js} +1 -1
  16. package/dist/gateway/static/root/assets/{apps-page-BZLvInLr.js → apps-page-xwCsJS15.js} +1 -1
  17. package/dist/gateway/static/root/assets/{archive-plugin-uuQPupqx.js → archive-plugin-BAFlsov_.js} +1 -1
  18. package/dist/gateway/static/root/assets/{attachment-load-DBkv0cAv.js → attachment-load-V3qGPC3x.js} +1 -1
  19. package/dist/gateway/static/root/assets/{binary-plugins-DxxN_VAR.js → binary-plugins-DT8NvA6W.js} +1 -1
  20. package/dist/gateway/static/root/assets/{block-editor-CwnUlRmO.js → block-editor-CdLMEcHd.js} +1 -1
  21. package/dist/gateway/static/root/assets/{channels-settings-BHvUKlzw.js → channels-settings-C044DcYk.js} +1 -1
  22. package/dist/gateway/static/root/assets/{config-api-BD-NcD5d.js → config-api-Bf5mjpu7.js} +1 -1
  23. package/dist/gateway/static/root/assets/{connectors-settings-VBzXcEXL.js → connectors-settings-8VEWUOTj.js} +1 -1
  24. package/dist/gateway/static/root/assets/{cron-api-C5DoipZA.js → cron-api--pAB_rps.js} +1 -1
  25. package/dist/gateway/static/root/assets/cron-page-DqmNGNOy.js +3 -0
  26. package/dist/gateway/static/root/assets/{dreaming-settings-DSVhXTPq.js → dreaming-settings-6UZE1FSK.js} +1 -1
  27. package/dist/gateway/static/root/assets/{extension-debug-page-BDHA9o_e.js → extension-debug-page-BGhE7msg.js} +1 -1
  28. package/dist/gateway/static/root/assets/{extension-page-DmDLVSPE.js → extension-page-CvpI45WG.js} +1 -1
  29. package/dist/gateway/static/root/assets/{extension-settings-page-1124aHw_.js → extension-settings-page-DAmR5FUe.js} +1 -1
  30. package/dist/gateway/static/root/assets/{fetch-DOe56Wmy.js → fetch-NZmjSXLl.js} +1 -1
  31. package/dist/gateway/static/root/assets/{format-interval-label-tsMSvBSR.js → format-interval-label-qhth3BMV.js} +1 -1
  32. package/dist/gateway/static/root/assets/{gateway-config-api-CsD4FC9D.js → gateway-config-api-CaXBt-9R.js} +1 -1
  33. package/dist/gateway/static/root/assets/{gateway-settings-HQ8FBhY2.js → gateway-settings-DphpbLBc.js} +1 -1
  34. package/dist/gateway/static/root/assets/{gateway-startup-retry-C1zg7pH3.js → gateway-startup-retry-Be1omjh3.js} +1 -1
  35. package/dist/gateway/static/root/assets/{goal-detail-page-BG3Onph0.js → goal-detail-page-bv0VRDaf.js} +1 -1
  36. package/dist/gateway/static/root/assets/goals-page-1Ywnt4Cb.js +2 -0
  37. package/dist/gateway/static/root/assets/{goals-settings-B5nI6lgz.js → goals-settings-ceEBjnfc.js} +1 -1
  38. package/dist/gateway/static/root/assets/{heartbeat-config-api-CIv42nJD.js → heartbeat-config-api-BzO6G4fD.js} +1 -1
  39. package/dist/gateway/static/root/assets/{heartbeat-settings-DFcVuJ3M.js → heartbeat-settings-DCST9-du.js} +1 -1
  40. package/dist/gateway/static/root/assets/{index-BTmbp2AU.js → index-Cxm6xsps.js} +59 -58
  41. package/dist/gateway/static/root/assets/{index-5A_ZaABy.css → index-b_R4tKqt.css} +1 -1
  42. package/dist/gateway/static/root/assets/{interval-presets-DGP3S7OB.js → interval-presets-DJmshV8n.js} +1 -1
  43. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-fETaDYQP.js → keyboard-shortcuts-settings-9AUUlQ5Q.js} +1 -1
  44. package/dist/gateway/static/root/assets/{logs-page-B1-b27lK.js → logs-page-B_wrxhee.js} +1 -1
  45. package/dist/gateway/static/root/assets/{markdown-split-CgeBJMOD.js → markdown-split-CYYELqAr.js} +1 -1
  46. package/dist/gateway/static/root/assets/{media-plugins-C30GzlV2.js → media-plugins-BEcMR2M8.js} +1 -1
  47. package/dist/gateway/static/root/assets/messages-CkT-lcgP.js +3 -0
  48. package/dist/gateway/static/root/assets/{models-hub-panel-DPcTS1-u.js → models-hub-panel-D0JDSbNu.js} +1 -1
  49. package/dist/gateway/static/root/assets/{note-detail-page-xeGb4owe.js → note-detail-page-DpFV-EO6.js} +2 -2
  50. package/dist/gateway/static/root/assets/{note-image-lightbox-t1g0qZYh.js → note-image-lightbox-DNAoPcmm.js} +1 -1
  51. package/dist/gateway/static/root/assets/{notes-page-C_TdnKBe.js → notes-page-CdkjTch8.js} +1 -1
  52. package/dist/gateway/static/root/assets/{preview-open-alternatives-DeWp9x5g.js → preview-open-alternatives-BPLz0AIv.js} +1 -1
  53. package/dist/gateway/static/root/assets/{remote-access-hub-BtkPmJIN.js → remote-access-hub-DSYVAi96.js} +1 -1
  54. package/dist/gateway/static/root/assets/{save-bar-controls-BOaAOJI3.js → save-bar-controls-CrWwWRVK.js} +1 -1
  55. package/dist/gateway/static/root/assets/{schedule-field-BLWLKqgw.js → schedule-field-CF2sadvN.js} +1 -1
  56. package/dist/gateway/static/root/assets/{schema-form-plqRFYT8.js → schema-form-Di5cKjYE.js} +1 -1
  57. package/dist/gateway/static/root/assets/{sessions-page-DOUjxzJm.js → sessions-page-CenkcVjF.js} +1 -1
  58. package/dist/gateway/static/root/assets/settings-advanced-gate-D9sva86V.js +1 -0
  59. package/dist/gateway/static/root/assets/{settings-collapsible-section-BP5zRrDI.js → settings-collapsible-section-Chh282jW.js} +1 -1
  60. package/dist/gateway/static/root/assets/{settings-form-section-Bv8MZplG.js → settings-form-section-Dq-83cQd.js} +1 -1
  61. package/dist/gateway/static/root/assets/{settings-page-DmDfE1ww.js → settings-page-DL35U0x0.js} +1 -1
  62. package/dist/gateway/static/root/assets/{setup-status-panel-BEFwNcIZ.js → setup-status-panel-Ctwbp9Er.js} +1 -1
  63. package/dist/gateway/static/root/assets/{share-preview-page-4OX1YCgp.js → share-preview-page-0FXYnSUA.js} +1 -1
  64. package/dist/gateway/static/root/assets/{shares-settings-CbKmJZot.js → shares-settings-DIM3JNsr.js} +1 -1
  65. package/dist/gateway/static/root/assets/skill-reload-api-DAlNaNzL.js +1 -0
  66. package/dist/gateway/static/root/assets/skills-page-CLrHVzAt.js +2 -0
  67. package/dist/gateway/static/root/assets/{system-settings-panel-CGy4f_s2.js → system-settings-panel-W1pTcojB.js} +1 -1
  68. package/dist/gateway/static/root/assets/use-agent-defaults-form-BVRvkK7m.js +1 -0
  69. package/dist/gateway/static/root/assets/{use-channel-catalog-CjGHnDvN.js → use-channel-catalog-CgJibfMM.js} +1 -1
  70. package/dist/gateway/static/root/assets/{use-settings-tab-guard-BMMFa0oA.js → use-settings-tab-guard-Bw_qkRQE.js} +1 -1
  71. package/dist/gateway/static/root/assets/{voice-api-key-field-DnRbhMNq.js → voice-api-key-field-vYAO71Gn.js} +1 -1
  72. package/dist/gateway/static/root/assets/{voice-player-store-D5vzWwls.js → voice-player-store-C7lziaAx.js} +1 -1
  73. package/dist/gateway/static/root/assets/{workflow-page.utils-tjGpRVnw.js → workflow-page.utils-sgHjOXOm.js} +1 -1
  74. package/dist/gateway/static/root/assets/{workflows-page-DqqHKGj2.js → workflows-page-DYyOTmFx.js} +1 -1
  75. package/dist/gateway/static/root/favicon-16x16.png +0 -0
  76. package/dist/gateway/static/root/favicon-32x32.png +0 -0
  77. package/dist/gateway/static/root/favicon-icon.svg +1 -0
  78. package/dist/gateway/static/root/favicon.ico +0 -0
  79. package/dist/gateway/static/root/favicon.png +0 -0
  80. package/dist/gateway/static/root/favicon.svg +24 -17
  81. package/dist/gateway/static/root/index.html +5 -5
  82. package/dist/gateway/static/root/logo-dark.svg +23 -15
  83. package/dist/gateway/static/root/logo.svg +23 -16
  84. package/dist/package.js +1 -1
  85. package/dist/src/agent/service/process-direct-streaming.js +9 -4
  86. package/dist/src/agent/service/process-direct-streaming.js.map +1 -1
  87. package/dist/src/ai-assist/text-assist.d.ts +3 -0
  88. package/dist/src/ai-assist/text-assist.js +25 -7
  89. package/dist/src/ai-assist/text-assist.js.map +1 -1
  90. package/dist/src/channels/plugins/types.adapters.d.ts +2 -2
  91. package/dist/src/cron/executor.js.map +1 -1
  92. package/dist/src/cron/types.d.ts +2 -2
  93. package/dist/src/session/store-reader.d.ts +5 -0
  94. package/dist/src/session/store-reader.js +1 -0
  95. package/package.json +1 -1
  96. package/dist/gateway/static/root/assets/cron-page-BLTpdm34.js +0 -3
  97. package/dist/gateway/static/root/assets/goals-page-DgeKn8zL.js +0 -2
  98. package/dist/gateway/static/root/assets/messages-BUUfPaZ9.js +0 -3
  99. package/dist/gateway/static/root/assets/settings-advanced-gate-qK_bnTrw.js +0 -1
  100. package/dist/gateway/static/root/assets/skill-reload-api-YdtnUHtK.js +0 -1
  101. package/dist/gateway/static/root/assets/skills-page-DwW1IzQ0.js +0 -2
  102. package/dist/gateway/static/root/assets/use-agent-defaults-form-BMuMvzl_.js +0 -1
@@ -1,4 +1,4 @@
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-JdwAhgNB.js";import{t as a}from"./messages-BUUfPaZ9.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{i as s}from"./theme-store-CD2wtgZV.js";import{c}from"./fetch-DOe56Wmy.js";import{i as l}from"./vendor-swr-BIWyz7Rc.js";import{$n as u,$r as d,An as f,Bo as p,Bt as m,Da as h,Di as g,Ds as _,Ea as v,Es as y,Fi as b,Fn as x,Ft as S,G as C,Gt as w,Hi as T,In as E,Io as D,It as O,Jn as k,Jr as A,Ko as j,Kr as M,Kt as N,Li as P,Lt as F,Ma as I,Mi as L,Mn as R,Nn as ee,Oi as z,Oo as te,Pn as ne,Pt as re,Qn as ie,Qr as ae,Ri as B,Rt as oe,Ss as se,To as ce,Ts as le,U as ue,Ua as de,Ut as fe,Vi as pe,Vt as me,W as V,Wt as he,Xn as H,Xr as ge,Yn as U,Yr as _e,Zn as W,Zr as ve,_n as ye,ba as G,bi as be,br as xe,bs as Se,ds as Ce,ei as K,eo as q,er as we,gn as Te,ii as Ee,ji as De,jn as Oe,ki as J,n as ke,ni as Ae,nr as je,oo as Me,pa as Ne,qr as Pe,qt as Fe,ra as Ie,ri as Le,rr as Re,t as ze,ta as Be,ti as Ve,tr as He,ui as Y,uo as Ue,vn as We,wa as Ge,xi as X,zn as Ke,zt as Z}from"./index-BTmbp2AU.js";import{t as qe}from"./markdown-editor-AssmZFx4.js";import{n as Je,t as Ye}from"./settings-form-section-Bv8MZplG.js";import{n as Xe}from"./agent-avatar-dicebear-EhRp-ZMa.js";import{a as Ze,c as Qe,n as $e,o as et,s as tt}from"./config-api-BD-NcD5d.js";import{AgentBrowserSettingsPage as nt}from"./agent-browser-settings-page-H4foVCiS.js";import{AgentDefaultsTabbedPage as rt,a as it,i as at,n as ot,o as st,r as ct,t as lt}from"./agent-defaults-tabbed-page-DDNw2oNU.js";import{S as ut,d as dt,f as ft,g as pt,i as mt,o as ht,w as gt,x as _t}from"./cron-api-C5DoipZA.js";import{t as vt}from"./cron-dreaming-jobs-nCMWCf0p.js";var yt=n(),Q=r();function bt(e){let t=(0,yt.c)(40),{open:n,onOpenChange:r,busy:a,deletePurge:o,deleteTarget:s,deleteConfirmText:c,onDeleteConfirmTextChange:l,onConfirm:u,onCancel:f,a:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(ge,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),t[0]=m):m=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?p.purgeDisk:p.removeFromConfig,_;t[2]===g?_=t[3]:(_=(0,Q.jsx)(d,{className:`text-base font-semibold text-fg`,children:g}),t[2]=g,t[3]=_);let v=o?p.confirmDeletePurge:p.confirmDelete,y;t[4]===v?y=t[5]:(y=(0,Q.jsx)(_e,{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]!==p.purgeConfirmHint||t[7]!==p.purgeConfirmLabel||t[8]!==p.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:p.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:p.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:p.purgeConfirmHint.replace(`{{agentId}}`,s.id)})]}):null,t[6]=p.purgeConfirmHint,t[7]=p.purgeConfirmLabel,t[8]=p.purgeConfirmPlaceholder,t[9]=c,t[10]=o,t[11]=s,t[12]=l,t[13]=b):b=t[13];let x;t[14]!==p.createModalCancel||t[15]!==a||t[16]!==f?(x=(0,Q.jsx)(J,{type:`button`,variant:`ghost`,disabled:a,onClick:f,children:p.createModalCancel}),t[14]=p.createModalCancel,t[15]=a,t[16]=f,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?p.purgeDisk:p.removeFromConfig,T;t[23]!==u||t[24]!==C||t[25]!==w||t[26]!==S?(T=(0,Q.jsx)(J,{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)(ve,{children:[m,(0,Q.jsxs)(A,{className:h,onOpenAutoFocus:xt,children:[_,y,b,E]})]}),t[31]=E,t[32]=_,t[33]=y,t[34]=b,t[35]=D):D=t[35];let O;return t[36]!==r||t[37]!==n||t[38]!==D?(O=(0,Q.jsx)(ae,{open:n,onOpenChange:r,children:D}),t[36]=r,t[37]=n,t[38]=D,t[39]=O):O=t[39],O}function xt(e){return e.preventDefault()}var St=[{id:`overview`,labelKey:`navIdentity`,icon:b},{id:`profile`,labelKey:`navProfile`,icon:j},{id:`models`,labelKey:`navModels`,icon:Me},{id:`tools`,labelKey:`navTools`,icon:L},{id:`skills`,labelKey:`navSkills`,icon:Ge},{id:`files`,labelKey:`navCoreFiles`,icon:ce}],Ct=[{id:`channels`,labelKey:`tabChannels`,icon:h},{id:`cron`,labelKey:`tabCron`,icon:p}];function wt(e){let t=(0,yt.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`,X.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=St.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=Ct.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 Tt(e){let t=(0,yt.c)(49),{open:n,onOpenChange:r,a,title:o,subtitle:s,panel:c,onPanelChange:l,onFooterSave:u,footerSaveDisabled:f,footerSavedFlash:p,busy:m,children:h}=e,g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Q.jsx)(ge,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim`,ye)}),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`,Te,`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)(d,{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)(_e,{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(be,`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)(De,{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)(Pe,{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)(wt,{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]!==f||t[25]!==p?(D=p?(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]}):f?(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]=f,t[25]=p,t[26]=D):D=t[26];let O=m||f,k;t[27]===u?k=t[28]:(k=()=>void u(),t[27]=u,t[28]=k);let j;t[29]!==a.save||t[30]!==O||t[31]!==k?(j=(0,Q.jsx)(J,{type:`button`,className:`order-1 w-full sm:order-2 sm:w-auto`,disabled:O,onClick:k,children:a.save}),t[29]=a.save,t[30]=O,t[31]=k,t[32]=j):j=t[32];let M;t[33]!==D||t[34]!==j?(M=(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,j]}),t[33]=D,t[34]=j,t[35]=M):M=t[35];let N;t[36]!==E||t[37]!==M?(N=(0,Q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[E,M]}),t[36]=E,t[37]=M,t[38]=N):N=t[38];let P;t[39]!==N||t[40]!==T?(P=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col sm:flex-row sm:overflow-hidden`,children:[T,N]}),t[39]=N,t[40]=T,t[41]=P):P=t[41];let F;t[42]!==P||t[43]!==w?(F=(0,Q.jsxs)(ve,{children:[g,(0,Q.jsx)(A,{className:_,onOpenAutoFocus:Et,children:(0,Q.jsxs)(V,{layer:`modal`,children:[w,P]})})]}),t[42]=P,t[43]=w,t[44]=F):F=t[44];let I;return t[45]!==r||t[46]!==n||t[47]!==F?(I=(0,Q.jsx)(ae,{open:n,onOpenChange:r,children:F}),t[45]=r,t[46]=n,t[47]=F,t[48]=I):I=t[48],I}function Et(e){return e.preventDefault()}function Dt(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,z,`dark:border-edge`)}function Ot(e,t,n){let r=e.agentId?.trim().toLowerCase();return r?r===t.toLowerCase():t.toLowerCase()===n.toLowerCase()}function kt(e){return[e.channel,e.accountId,e.peerKind,e.peerId].filter(e=>typeof e==`string`&&e.length>0).join(` · `)||e.channel}function At(e,t,n,r){let i=e.trim(),a=t.trim();if(a)return{channel:i,peerId:a};if(n!=null){let e=r[n];if(!e)return{channel:i};let t={channel:i};e.accountId?.trim()&&(t.accountId=e.accountId.trim()),e.peerKind?.trim()&&(t.peerKind=e.peerKind.trim());let a=e.peerId?.trim()||e.chatId?.trim();return a&&(t.peerId=a),t}return{channel:i}}var jt=i(g,`w-full text-xs sm:w-auto sm:min-w-[11rem] sm:max-w-[17rem] sm:shrink-0`);function Mt(e){let t=(0,yt.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)(Je,{className:`shrink-0`,icon:q,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:kt(e.match)}),(0,Q.jsx)(J,{type:`button`,variant:`secondary`,disabled:r,onClick:()=>void s(e),children:n.removeBinding})]},`${e.match.channel}-${kt(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:Dt(),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(Dt(),`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)(J,{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)(G,{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(Dt(),`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(Dt(),`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:jt,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)(J,{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)(Ye,{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 Nt(e){let t=(0,yt.c)(20),{a:n,data:r,busy:s,cronLoading:c,agentCronJobs:l,onSetCronJobAgent:u}=e,d=o(Ft),f;if(t[0]!==n.cronAgentClear||t[1]!==n.cronAgentDefault||t[2]!==n.cronColAgent||t[3]!==n.cronColMessage||t[4]!==n.cronColSchedule||t[5]!==n.cronColSession||t[6]!==n.cronHint||t[7]!==n.cronLoading||t[8]!==n.cronNone||t[9]!==n.cronTitle||t[10]!==l||t[11]!==s||t[12]!==c||t[13]!==r||t[14]!==d||t[15]!==u){let e=a(d),o=d===`zh`?`zh-CN`:`en-US`,p=e.cron.scheduleBadge,m;t[17]!==n.cronHint||t[18]!==n.cronTitle?(m=(0,Q.jsx)(Je,{className:`shrink-0`,icon:Se,title:n.cronTitle,subtitle:n.cronHint}),t[17]=n.cronHint,t[18]=n.cronTitle,t[19]=m):m=t[19],f=(0,Q.jsxs)(Ye,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[m,c?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.cronLoading}):l.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.cronNone}):(0,Q.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Q.jsxs)(`table`,{className:`w-full min-w-[32rem] border-collapse text-left text-sm`,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{className:`border-b border-edge text-fg-muted`,children:[(0,Q.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:n.cronColSchedule}),(0,Q.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:n.cronColMessage}),(0,Q.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:n.cronColSession}),(0,Q.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:n.cronColAgent})]})}),(0,Q.jsx)(`tbody`,{children:l.map(e=>{let t=!e.agentId?.trim(),a=t?``:e.agentId.trim().toLowerCase();return(0,Q.jsxs)(`tr`,{className:`border-b border-edge-subtle`,children:[(0,Q.jsx)(`td`,{className:`py-2 pr-3`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:ut(e,o,p)}),(0,Q.jsx)(`span`,{className:`truncate font-mono text-[0.65rem] text-fg-subtle`,title:gt(e.schedule),children:gt(e.schedule)})]})}),(0,Q.jsx)(`td`,{className:`max-w-[12rem] truncate py-2 pr-3 text-xs`,title:mt(e),children:mt(e)}),(0,Q.jsx)(`td`,{className:`py-2 pr-3 text-xs`,children:e.sessionTarget??`main`}),(0,Q.jsx)(`td`,{className:`py-2 pr-3`,children:(0,Q.jsxs)(`select`,{className:i(Dt(),`min-w-[8rem] py-1 text-xs`),value:a,disabled:s||e.sessionTarget!==`isolated`,onChange:t=>void u(e,t.target.value),children:[(0,Q.jsx)(`option`,{value:``,children:t?n.cronAgentDefault:n.cronAgentClear}),r.agents.map(Pt)]})})]},e.id)})})]})})]}),t[0]=n.cronAgentClear,t[1]=n.cronAgentDefault,t[2]=n.cronColAgent,t[3]=n.cronColMessage,t[4]=n.cronColSchedule,t[5]=n.cronColSession,t[6]=n.cronHint,t[7]=n.cronLoading,t[8]=n.cronNone,t[9]=n.cronTitle,t[10]=l,t[11]=s,t[12]=c,t[13]=r,t[14]=d,t[15]=u,t[16]=f}else f=t[16];return f}function Pt(e){return(0,Q.jsx)(`option`,{value:e.id,children:e.id},e.id)}function Ft(e){return e.language}function It(e){let t=(0,yt.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(Lt),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`,X.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`,X.press,l===`edit`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>u(`edit`),children:[(0,Q.jsx)(Be,{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`,X.press,l===`preview`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>u(`preview`),children:[(0,Q.jsx)(te,{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)(J,{type:`button`,variant:`secondary`,className:`ml-auto text-xs`,onClick:g,children:[(0,Q.jsx)(de,{className:`mr-1 size-3.5`,"aria-hidden":!0}),n.tryInChat]}):null]})]}),l===`edit`?(0,Q.jsx)(`div`,{className:i(Dt(),`flex min-h-0 flex-1 flex-col overflow-hidden p-0`,m&&`pointer-events-none opacity-60`),children:(0,Q.jsx)(qe,{initialContent:d,onChange:f,isDark:_,className:`min-h-0 flex-1`},`${o??`file`}-${h}`)}):(0,Q.jsx)(`div`,{className:i(Dt(),`min-h-0 flex-1 overflow-y-auto text-sm`,m&&`pointer-events-none opacity-60`),children:(0,Q.jsx)(Ke,{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 Lt(e){return e.resolved===`dark`}function Rt(e){let t=(0,yt.c)(52),{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)(Je,{className:`shrink-0`,icon:Me,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.modelsDefaultsLabel?f=t[4]:(f=(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:n.modelsDefaultsLabel}),t[3]=n.modelsDefaultsLabel,t[4]=f);let p;t[5]===i.typedModels.defaults?p=t[6]:(p=et(i.typedModels.defaults),t[5]=i.typedModels.defaults,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=et(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.removeTypedModel||t[22]!==n.typedModelDescriptionLabel||t[23]!==n.typedModelDescriptionPlaceholder||t[24]!==n.typedModelIdLabel||t[25]!==n.typedModelIdPlaceholder?(y={id:n.typedModelIdLabel,description:n.typedModelDescriptionLabel,add:n.addTypedModel,remove:n.removeTypedModel,idPlaceholder:n.typedModelIdPlaceholder,descriptionPlaceholder:n.typedModelDescriptionPlaceholder},t[20]=n.addTypedModel,t[21]=n.removeTypedModel,t[22]=n.typedModelDescriptionLabel,t[23]=n.typedModelDescriptionPlaceholder,t[24]=n.typedModelIdLabel,t[25]=n.typedModelIdPlaceholder,t[26]=y):y=t[26];let b;t[27]!==a||t[28]!==r||t[29]!==o||t[30]!==s||t[31]!==y?(b=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(st,{rows:o,onChange:s,disabled:a,chat:r,labels:y})}),t[27]=a,t[28]=r,t[29]=o,t[30]=s,t[31]=y,t[32]=b):b=t[32];let x;t[33]!==n.modelsSave||t[34]!==a||t[35]!==u||t[36]!==c?(x=u?null:(0,Q.jsx)(J,{type:`button`,disabled:a,onClick:()=>void c(),children:n.modelsSave}),t[33]=n.modelsSave,t[34]=a,t[35]=u,t[36]=c,t[37]=x):x=t[37];let S;t[38]===l?S=t[39]:(S=()=>void l(),t[38]=l,t[39]=S);let C;t[40]!==n.modelsResetInherit||t[41]!==a||t[42]!==S?(C=(0,Q.jsx)(J,{type:`button`,variant:`secondary`,disabled:a,onClick:S,children:n.modelsResetInherit}),t[40]=n.modelsResetInherit,t[41]=a,t[42]=S,t[43]=C):C=t[43];let w;t[44]!==x||t[45]!==C?(w=(0,Q.jsxs)(`div`,{className:`mt-4 flex shrink-0 flex-wrap gap-2`,children:[x,C]}),t[44]=x,t[45]=C,t[46]=w):w=t[46];let T;return t[47]!==d||t[48]!==w||t[49]!==v||t[50]!==b?(T=(0,Q.jsxs)(Ye,{className:`flex min-h-0 flex-1 flex-col`,children:[d,v,b,w]}),t[47]=d,t[48]=w,t[49]=v,t[50]=b,t[51]=T):T=t[51],T}var $=e(t(),1);function zt(e){let t=(0,yt.c)(19),{label:n,mode:r,value:a,inheritedFrom:o,inheritLabel:s,overrideLabel:c}=e,l;t[0]===n?l=t[1]:(l=(0,Q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:n}),t[0]=n,t[1]=l);let u=a||`—`,d;t[2]===u?d=t[3]:(d=(0,Q.jsx)(`p`,{className:`mt-1 truncate text-sm font-medium text-fg`,children:u}),t[2]=u,t[3]=d);let f;t[4]!==o||t[5]!==r?(f=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]=f):f=t[6];let p;t[7]!==l||t[8]!==d||t[9]!==f?(p=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[l,d,f]}),t[7]=l,t[8]=d,t[9]=f,t[10]=p):p=t[10];let m=r===`inherit`?`bg-surface-hover text-fg-muted`:`bg-accent-soft text-accent-fg`,h;t[11]===m?h=t[12]:(h=i(`mt-2 inline-flex shrink-0 self-start rounded-full px-2.5 py-0.5 text-xs font-medium sm:mt-0`,m),t[11]=m,t[12]=h);let g=r===`inherit`?s:c,_;t[13]!==h||t[14]!==g?(_=(0,Q.jsx)(`span`,{className:h,children:g}),t[13]=h,t[14]=g,t[15]=_):_=t[15];let v;return t[16]!==p||t[17]!==_?(v=(0,Q.jsxs)(`div`,{className:`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`,children:[p,_]}),t[16]=p,t[17]=_,t[18]=v):v=t[18],v}function Bt(e){let t=(0,yt.c)(41),{a:n,defaultModel:r,defaultWorkspace:i,agentModel:a,agentWorkspace:o,settingsPath:s,settingsState:c}=e,l=s===void 0?`/settings/agent-defaults`:s,u=n.inheritance,d;t[0]===a?d=t[1]:(d=a.trim(),t[0]=a,t[1]=d);let f=!d,p;t[2]!==o||t[3]!==i?(p=!o.trim()||i.trim().length>0&&o.trim()===i.trim(),t[2]=o,t[3]=i,t[4]=p):p=t[4];let m=p,h=f?r||u.unset:a,g=m?i||u.unset:o,_;t[5]!==u.editDefaultsLink||t[6]!==l||t[7]!==c?(_=(0,Q.jsx)(se,{to:l,state:c,className:`text-xs font-medium text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:u.editDefaultsLink}),t[5]=u.editDefaultsLink,t[6]=l,t[7]=c,t[8]=_):_=t[8];let v;t[9]!==u.subtitle||t[10]!==u.title||t[11]!==_?(v=(0,Q.jsx)(Je,{icon:q,title:u.title,subtitle:u.subtitle,trailing:_}),t[9]=u.subtitle,t[10]=u.title,t[11]=_,t[12]=v):v=t[12];let y=f?`inherit`:`override`,b;t[13]!==r||t[14]!==u.inheritsValue||t[15]!==f?(b=f&&r?u.inheritsValue.replace(`{{value}}`,r):void 0,t[13]=r,t[14]=u.inheritsValue,t[15]=f,t[16]=b):b=t[16];let x;t[17]!==h||t[18]!==u.badgeInherit||t[19]!==u.badgeOverride||t[20]!==u.modelLabel||t[21]!==y||t[22]!==b?(x=(0,Q.jsx)(zt,{label:u.modelLabel,mode:y,value:h,inheritedFrom:b,inheritLabel:u.badgeInherit,overrideLabel:u.badgeOverride}),t[17]=h,t[18]=u.badgeInherit,t[19]=u.badgeOverride,t[20]=u.modelLabel,t[21]=y,t[22]=b,t[23]=x):x=t[23];let S=m?`inherit`:`override`,C;t[24]!==i||t[25]!==u.inheritsValue||t[26]!==m?(C=m&&i?u.inheritsValue.replace(`{{value}}`,i):void 0,t[24]=i,t[25]=u.inheritsValue,t[26]=m,t[27]=C):C=t[27];let w;t[28]!==g||t[29]!==u.badgeInherit||t[30]!==u.badgeOverride||t[31]!==u.workspaceLabel||t[32]!==S||t[33]!==C?(w=(0,Q.jsx)(zt,{label:u.workspaceLabel,mode:S,value:g,inheritedFrom:C,inheritLabel:u.badgeInherit,overrideLabel:u.badgeOverride}),t[28]=g,t[29]=u.badgeInherit,t[30]=u.badgeOverride,t[31]=u.workspaceLabel,t[32]=S,t[33]=C,t[34]=w):w=t[34];let T;t[35]!==w||t[36]!==x?(T=(0,Q.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[x,w]}),t[35]=w,t[36]=x,t[37]=T):T=t[37];let E;return t[38]!==T||t[39]!==v?(E=(0,Q.jsxs)(Ye,{children:[v,T]}),t[38]=T,t[39]=v,t[40]=E):E=t[40],E}function Vt(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 Ht(e){let{agentId:t,value:n,onChange:r,a,id:o}=e,s=(0,$.useRef)(null),[c,l]=(0,$.useState)(!1),[d,f]=(0,$.useState)(null),[p,m]=(0,$.useState)(!1),h=(0,$.useMemo)(()=>{let e=He(n.trim());return e&&we(e.styleId)?e.styleId:W[0]??`adventurer`},[n]),g=(0,$.useCallback)(async(e,n)=>{try{await F(t)}catch{}r(u(e,n)),m(!1)},[t,r]),_=(0,$.useCallback)(async e=>{let n=e.target.files?.[0];if(e.target.value=``,n){f(null),l(!0);try{await Fe(t,n),je(t),r(ie)}catch(e){let t=e instanceof Error?e.message:``;f(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=He(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)(J,{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)(B,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),c?a.avatarUploading:a.avatarUploadCustom]})]})]}),d?(0,Q.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:d}):null,(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:W.map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void g(e,H[0]??t),className:i(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,X.press,h===e?`border-fg bg-fg text-surface-base`:`border-edge-subtle bg-surface-panel text-fg hover:border-edge`),children:Vt(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:[H.map(e=>(0,Q.jsx)(`button`,{type:`button`,title:e,onClick:()=>void g(h,e),className:i(`flex size-12 shrink-0 items-center justify-center rounded-full border-2 transition-colors`,X.press,v(h,e)?`border-accent ring-2 ring-accent/30`:`border-transparent hover:border-edge`),children:(0,Q.jsx)(`img`,{src:Xe(h,e,96),alt:``,width:44,height:44,className:`size-11 rounded-full object-cover`,draggable:!1})},e)),(0,Q.jsxs)(Ae,{open:p,onOpenChange:m,children:[(0,Q.jsx)(Le,{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`,X.press),children:a.avatarMore})}),(0,Q.jsx)(Ve,{children:(0,Q.jsxs)(K,{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:Vt(h,a)}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:U.map(e=>(0,Q.jsx)(`button`,{type:`button`,title:e,onClick:()=>void g(h,e),className:i(`flex size-11 shrink-0 items-center justify-center rounded-full border-2 transition-colors`,X.press,v(h,e)?`border-accent ring-2 ring-accent/30`:`border-transparent hover:border-edge`),children:(0,Q.jsx)(`img`,{src:Xe(h,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)(k,{agentId:t,avatar:n,size:40}),n.trim()&&!He(n.trim())&&n.trim()!==`xopc:custom`?(0,Q.jsx)(`span`,{className:`truncate font-mono text-[10px] text-fg-muted`,title:n,children:n}):null]})]})]})}var Ut={name:``,description:``,language:``,creature:``,emoji:``,avatar:``};function Wt(e){let t={...Ut};if(!e.trim())return t;let n={name:`name`,description:`description`,language:`language`,creature:`creature`,emoji:`emoji`,avatar:`avatar`};for(let r of e.split(`
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-JdwAhgNB.js";import{t as a}from"./messages-CkT-lcgP.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{i as s}from"./theme-store-CD2wtgZV.js";import{c}from"./fetch-NZmjSXLl.js";import{i as l}from"./vendor-swr-BIWyz7Rc.js";import{$n as u,$r as d,An as f,Bo as p,Bt as m,Da as h,Di as g,Ds as _,Ea as v,Es as y,Fi as b,Fn as x,Ft as S,G as C,Gt as w,Hi as T,In as E,Io as D,It as O,Jn as k,Jr as A,Ko as j,Kr as M,Kt as N,Li as P,Lt as F,Ma as I,Mi as L,Mn as R,Nn as ee,Oi as z,Oo as te,Pn as ne,Pt as re,Qn as ie,Qr as ae,Ri as B,Rt as oe,Ss as se,To as ce,Ts as le,U as ue,Ua as de,Ut as fe,Vi as pe,Vt as me,W as V,Wt as he,Xn as H,Xr as ge,Yn as U,Yr as _e,Zn as W,Zr as ve,_n as ye,ba as G,bi as be,br as xe,bs as Se,ds as Ce,ei as K,eo as q,er as we,gn as Te,ii as Ee,ji as De,jn as Oe,ki as J,n as ke,ni as Ae,nr as je,oo as Me,pa as Ne,qr as Pe,qt as Fe,ra as Ie,ri as Le,rr as Re,t as ze,ta as Be,ti as Ve,tr as He,ui as Y,uo as Ue,vn as We,wa as Ge,xi as X,zn as Ke,zt as Z}from"./index-Cxm6xsps.js";import{t as qe}from"./markdown-editor-AssmZFx4.js";import{n as Je,t as Ye}from"./settings-form-section-Dq-83cQd.js";import{n as Xe}from"./agent-avatar-dicebear-CBlklyNr.js";import{a as Ze,c as Qe,n as $e,o as et,s as tt}from"./config-api-Bf5mjpu7.js";import{AgentBrowserSettingsPage as nt}from"./agent-browser-settings-page-rGbKc2Hh.js";import{AgentDefaultsTabbedPage as rt,a as it,i as at,n as ot,o as st,r as ct,t as lt}from"./agent-defaults-tabbed-page-CtwVbjOA.js";import{S as ut,d as dt,f as ft,g as pt,i as mt,o as ht,w as gt,x as _t}from"./cron-api--pAB_rps.js";import{t as vt}from"./cron-dreaming-jobs-nCMWCf0p.js";var yt=n(),Q=r();function bt(e){let t=(0,yt.c)(40),{open:n,onOpenChange:r,busy:a,deletePurge:o,deleteTarget:s,deleteConfirmText:c,onDeleteConfirmTextChange:l,onConfirm:u,onCancel:f,a:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(ge,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),t[0]=m):m=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?p.purgeDisk:p.removeFromConfig,_;t[2]===g?_=t[3]:(_=(0,Q.jsx)(d,{className:`text-base font-semibold text-fg`,children:g}),t[2]=g,t[3]=_);let v=o?p.confirmDeletePurge:p.confirmDelete,y;t[4]===v?y=t[5]:(y=(0,Q.jsx)(_e,{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]!==p.purgeConfirmHint||t[7]!==p.purgeConfirmLabel||t[8]!==p.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:p.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:p.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:p.purgeConfirmHint.replace(`{{agentId}}`,s.id)})]}):null,t[6]=p.purgeConfirmHint,t[7]=p.purgeConfirmLabel,t[8]=p.purgeConfirmPlaceholder,t[9]=c,t[10]=o,t[11]=s,t[12]=l,t[13]=b):b=t[13];let x;t[14]!==p.createModalCancel||t[15]!==a||t[16]!==f?(x=(0,Q.jsx)(J,{type:`button`,variant:`ghost`,disabled:a,onClick:f,children:p.createModalCancel}),t[14]=p.createModalCancel,t[15]=a,t[16]=f,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?p.purgeDisk:p.removeFromConfig,T;t[23]!==u||t[24]!==C||t[25]!==w||t[26]!==S?(T=(0,Q.jsx)(J,{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)(ve,{children:[m,(0,Q.jsxs)(A,{className:h,onOpenAutoFocus:xt,children:[_,y,b,E]})]}),t[31]=E,t[32]=_,t[33]=y,t[34]=b,t[35]=D):D=t[35];let O;return t[36]!==r||t[37]!==n||t[38]!==D?(O=(0,Q.jsx)(ae,{open:n,onOpenChange:r,children:D}),t[36]=r,t[37]=n,t[38]=D,t[39]=O):O=t[39],O}function xt(e){return e.preventDefault()}var St=[{id:`overview`,labelKey:`navIdentity`,icon:b},{id:`profile`,labelKey:`navProfile`,icon:j},{id:`models`,labelKey:`navModels`,icon:Me},{id:`tools`,labelKey:`navTools`,icon:L},{id:`skills`,labelKey:`navSkills`,icon:Ge},{id:`files`,labelKey:`navCoreFiles`,icon:ce}],Ct=[{id:`channels`,labelKey:`tabChannels`,icon:h},{id:`cron`,labelKey:`tabCron`,icon:p}];function wt(e){let t=(0,yt.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`,X.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=St.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=Ct.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 Tt(e){let t=(0,yt.c)(49),{open:n,onOpenChange:r,a,title:o,subtitle:s,panel:c,onPanelChange:l,onFooterSave:u,footerSaveDisabled:f,footerSavedFlash:p,busy:m,children:h}=e,g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Q.jsx)(ge,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim`,ye)}),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`,Te,`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)(d,{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)(_e,{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(be,`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)(De,{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)(Pe,{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)(wt,{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]!==f||t[25]!==p?(D=p?(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]}):f?(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]=f,t[25]=p,t[26]=D):D=t[26];let O=m||f,k;t[27]===u?k=t[28]:(k=()=>void u(),t[27]=u,t[28]=k);let j;t[29]!==a.save||t[30]!==O||t[31]!==k?(j=(0,Q.jsx)(J,{type:`button`,className:`order-1 w-full sm:order-2 sm:w-auto`,disabled:O,onClick:k,children:a.save}),t[29]=a.save,t[30]=O,t[31]=k,t[32]=j):j=t[32];let M;t[33]!==D||t[34]!==j?(M=(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,j]}),t[33]=D,t[34]=j,t[35]=M):M=t[35];let N;t[36]!==E||t[37]!==M?(N=(0,Q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[E,M]}),t[36]=E,t[37]=M,t[38]=N):N=t[38];let P;t[39]!==N||t[40]!==T?(P=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col sm:flex-row sm:overflow-hidden`,children:[T,N]}),t[39]=N,t[40]=T,t[41]=P):P=t[41];let F;t[42]!==P||t[43]!==w?(F=(0,Q.jsxs)(ve,{children:[g,(0,Q.jsx)(A,{className:_,onOpenAutoFocus:Et,children:(0,Q.jsxs)(V,{layer:`modal`,children:[w,P]})})]}),t[42]=P,t[43]=w,t[44]=F):F=t[44];let I;return t[45]!==r||t[46]!==n||t[47]!==F?(I=(0,Q.jsx)(ae,{open:n,onOpenChange:r,children:F}),t[45]=r,t[46]=n,t[47]=F,t[48]=I):I=t[48],I}function Et(e){return e.preventDefault()}function Dt(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,z,`dark:border-edge`)}function Ot(e,t,n){let r=e.agentId?.trim().toLowerCase();return r?r===t.toLowerCase():t.toLowerCase()===n.toLowerCase()}function kt(e){return[e.channel,e.accountId,e.peerKind,e.peerId].filter(e=>typeof e==`string`&&e.length>0).join(` · `)||e.channel}function At(e,t,n,r){let i=e.trim(),a=t.trim();if(a)return{channel:i,peerId:a};if(n!=null){let e=r[n];if(!e)return{channel:i};let t={channel:i};e.accountId?.trim()&&(t.accountId=e.accountId.trim()),e.peerKind?.trim()&&(t.peerKind=e.peerKind.trim());let a=e.peerId?.trim()||e.chatId?.trim();return a&&(t.peerId=a),t}return{channel:i}}var jt=i(g,`w-full text-xs sm:w-auto sm:min-w-[11rem] sm:max-w-[17rem] sm:shrink-0`);function Mt(e){let t=(0,yt.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)(Je,{className:`shrink-0`,icon:q,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:kt(e.match)}),(0,Q.jsx)(J,{type:`button`,variant:`secondary`,disabled:r,onClick:()=>void s(e),children:n.removeBinding})]},`${e.match.channel}-${kt(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:Dt(),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(Dt(),`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)(J,{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)(G,{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(Dt(),`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(Dt(),`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:jt,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)(J,{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)(Ye,{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 Nt(e){let t=(0,yt.c)(20),{a:n,data:r,busy:s,cronLoading:c,agentCronJobs:l,onSetCronJobAgent:u}=e,d=o(Ft),f;if(t[0]!==n.cronAgentClear||t[1]!==n.cronAgentDefault||t[2]!==n.cronColAgent||t[3]!==n.cronColMessage||t[4]!==n.cronColSchedule||t[5]!==n.cronColSession||t[6]!==n.cronHint||t[7]!==n.cronLoading||t[8]!==n.cronNone||t[9]!==n.cronTitle||t[10]!==l||t[11]!==s||t[12]!==c||t[13]!==r||t[14]!==d||t[15]!==u){let e=a(d),o=d===`zh`?`zh-CN`:`en-US`,p=e.cron.scheduleBadge,m;t[17]!==n.cronHint||t[18]!==n.cronTitle?(m=(0,Q.jsx)(Je,{className:`shrink-0`,icon:Se,title:n.cronTitle,subtitle:n.cronHint}),t[17]=n.cronHint,t[18]=n.cronTitle,t[19]=m):m=t[19],f=(0,Q.jsxs)(Ye,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[m,c?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.cronLoading}):l.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.cronNone}):(0,Q.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Q.jsxs)(`table`,{className:`w-full min-w-[32rem] border-collapse text-left text-sm`,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{className:`border-b border-edge text-fg-muted`,children:[(0,Q.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:n.cronColSchedule}),(0,Q.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:n.cronColMessage}),(0,Q.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:n.cronColSession}),(0,Q.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:n.cronColAgent})]})}),(0,Q.jsx)(`tbody`,{children:l.map(e=>{let t=!e.agentId?.trim(),a=t?``:e.agentId.trim().toLowerCase();return(0,Q.jsxs)(`tr`,{className:`border-b border-edge-subtle`,children:[(0,Q.jsx)(`td`,{className:`py-2 pr-3`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:ut(e,o,p)}),(0,Q.jsx)(`span`,{className:`truncate font-mono text-[0.65rem] text-fg-subtle`,title:gt(e.schedule),children:gt(e.schedule)})]})}),(0,Q.jsx)(`td`,{className:`max-w-[12rem] truncate py-2 pr-3 text-xs`,title:mt(e),children:mt(e)}),(0,Q.jsx)(`td`,{className:`py-2 pr-3 text-xs`,children:e.sessionTarget??`main`}),(0,Q.jsx)(`td`,{className:`py-2 pr-3`,children:(0,Q.jsxs)(`select`,{className:i(Dt(),`min-w-[8rem] py-1 text-xs`),value:a,disabled:s||e.sessionTarget!==`isolated`,onChange:t=>void u(e,t.target.value),children:[(0,Q.jsx)(`option`,{value:``,children:t?n.cronAgentDefault:n.cronAgentClear}),r.agents.map(Pt)]})})]},e.id)})})]})})]}),t[0]=n.cronAgentClear,t[1]=n.cronAgentDefault,t[2]=n.cronColAgent,t[3]=n.cronColMessage,t[4]=n.cronColSchedule,t[5]=n.cronColSession,t[6]=n.cronHint,t[7]=n.cronLoading,t[8]=n.cronNone,t[9]=n.cronTitle,t[10]=l,t[11]=s,t[12]=c,t[13]=r,t[14]=d,t[15]=u,t[16]=f}else f=t[16];return f}function Pt(e){return(0,Q.jsx)(`option`,{value:e.id,children:e.id},e.id)}function Ft(e){return e.language}function It(e){let t=(0,yt.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(Lt),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`,X.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`,X.press,l===`edit`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>u(`edit`),children:[(0,Q.jsx)(Be,{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`,X.press,l===`preview`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>u(`preview`),children:[(0,Q.jsx)(te,{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)(J,{type:`button`,variant:`secondary`,className:`ml-auto text-xs`,onClick:g,children:[(0,Q.jsx)(de,{className:`mr-1 size-3.5`,"aria-hidden":!0}),n.tryInChat]}):null]})]}),l===`edit`?(0,Q.jsx)(`div`,{className:i(Dt(),`flex min-h-0 flex-1 flex-col overflow-hidden p-0`,m&&`pointer-events-none opacity-60`),children:(0,Q.jsx)(qe,{initialContent:d,onChange:f,isDark:_,className:`min-h-0 flex-1`},`${o??`file`}-${h}`)}):(0,Q.jsx)(`div`,{className:i(Dt(),`min-h-0 flex-1 overflow-y-auto text-sm`,m&&`pointer-events-none opacity-60`),children:(0,Q.jsx)(Ke,{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 Lt(e){return e.resolved===`dark`}function Rt(e){let t=(0,yt.c)(52),{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)(Je,{className:`shrink-0`,icon:Me,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.modelsDefaultsLabel?f=t[4]:(f=(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:n.modelsDefaultsLabel}),t[3]=n.modelsDefaultsLabel,t[4]=f);let p;t[5]===i.typedModels.defaults?p=t[6]:(p=et(i.typedModels.defaults),t[5]=i.typedModels.defaults,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=et(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.removeTypedModel||t[22]!==n.typedModelDescriptionLabel||t[23]!==n.typedModelDescriptionPlaceholder||t[24]!==n.typedModelIdLabel||t[25]!==n.typedModelIdPlaceholder?(y={id:n.typedModelIdLabel,description:n.typedModelDescriptionLabel,add:n.addTypedModel,remove:n.removeTypedModel,idPlaceholder:n.typedModelIdPlaceholder,descriptionPlaceholder:n.typedModelDescriptionPlaceholder},t[20]=n.addTypedModel,t[21]=n.removeTypedModel,t[22]=n.typedModelDescriptionLabel,t[23]=n.typedModelDescriptionPlaceholder,t[24]=n.typedModelIdLabel,t[25]=n.typedModelIdPlaceholder,t[26]=y):y=t[26];let b;t[27]!==a||t[28]!==r||t[29]!==o||t[30]!==s||t[31]!==y?(b=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(st,{rows:o,onChange:s,disabled:a,chat:r,labels:y})}),t[27]=a,t[28]=r,t[29]=o,t[30]=s,t[31]=y,t[32]=b):b=t[32];let x;t[33]!==n.modelsSave||t[34]!==a||t[35]!==u||t[36]!==c?(x=u?null:(0,Q.jsx)(J,{type:`button`,disabled:a,onClick:()=>void c(),children:n.modelsSave}),t[33]=n.modelsSave,t[34]=a,t[35]=u,t[36]=c,t[37]=x):x=t[37];let S;t[38]===l?S=t[39]:(S=()=>void l(),t[38]=l,t[39]=S);let C;t[40]!==n.modelsResetInherit||t[41]!==a||t[42]!==S?(C=(0,Q.jsx)(J,{type:`button`,variant:`secondary`,disabled:a,onClick:S,children:n.modelsResetInherit}),t[40]=n.modelsResetInherit,t[41]=a,t[42]=S,t[43]=C):C=t[43];let w;t[44]!==x||t[45]!==C?(w=(0,Q.jsxs)(`div`,{className:`mt-4 flex shrink-0 flex-wrap gap-2`,children:[x,C]}),t[44]=x,t[45]=C,t[46]=w):w=t[46];let T;return t[47]!==d||t[48]!==w||t[49]!==v||t[50]!==b?(T=(0,Q.jsxs)(Ye,{className:`flex min-h-0 flex-1 flex-col`,children:[d,v,b,w]}),t[47]=d,t[48]=w,t[49]=v,t[50]=b,t[51]=T):T=t[51],T}var $=e(t(),1);function zt(e){let t=(0,yt.c)(19),{label:n,mode:r,value:a,inheritedFrom:o,inheritLabel:s,overrideLabel:c}=e,l;t[0]===n?l=t[1]:(l=(0,Q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:n}),t[0]=n,t[1]=l);let u=a||`—`,d;t[2]===u?d=t[3]:(d=(0,Q.jsx)(`p`,{className:`mt-1 truncate text-sm font-medium text-fg`,children:u}),t[2]=u,t[3]=d);let f;t[4]!==o||t[5]!==r?(f=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]=f):f=t[6];let p;t[7]!==l||t[8]!==d||t[9]!==f?(p=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[l,d,f]}),t[7]=l,t[8]=d,t[9]=f,t[10]=p):p=t[10];let m=r===`inherit`?`bg-surface-hover text-fg-muted`:`bg-accent-soft text-accent-fg`,h;t[11]===m?h=t[12]:(h=i(`mt-2 inline-flex shrink-0 self-start rounded-full px-2.5 py-0.5 text-xs font-medium sm:mt-0`,m),t[11]=m,t[12]=h);let g=r===`inherit`?s:c,_;t[13]!==h||t[14]!==g?(_=(0,Q.jsx)(`span`,{className:h,children:g}),t[13]=h,t[14]=g,t[15]=_):_=t[15];let v;return t[16]!==p||t[17]!==_?(v=(0,Q.jsxs)(`div`,{className:`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`,children:[p,_]}),t[16]=p,t[17]=_,t[18]=v):v=t[18],v}function Bt(e){let t=(0,yt.c)(41),{a:n,defaultModel:r,defaultWorkspace:i,agentModel:a,agentWorkspace:o,settingsPath:s,settingsState:c}=e,l=s===void 0?`/settings/agent-defaults`:s,u=n.inheritance,d;t[0]===a?d=t[1]:(d=a.trim(),t[0]=a,t[1]=d);let f=!d,p;t[2]!==o||t[3]!==i?(p=!o.trim()||i.trim().length>0&&o.trim()===i.trim(),t[2]=o,t[3]=i,t[4]=p):p=t[4];let m=p,h=f?r||u.unset:a,g=m?i||u.unset:o,_;t[5]!==u.editDefaultsLink||t[6]!==l||t[7]!==c?(_=(0,Q.jsx)(se,{to:l,state:c,className:`text-xs font-medium text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:u.editDefaultsLink}),t[5]=u.editDefaultsLink,t[6]=l,t[7]=c,t[8]=_):_=t[8];let v;t[9]!==u.subtitle||t[10]!==u.title||t[11]!==_?(v=(0,Q.jsx)(Je,{icon:q,title:u.title,subtitle:u.subtitle,trailing:_}),t[9]=u.subtitle,t[10]=u.title,t[11]=_,t[12]=v):v=t[12];let y=f?`inherit`:`override`,b;t[13]!==r||t[14]!==u.inheritsValue||t[15]!==f?(b=f&&r?u.inheritsValue.replace(`{{value}}`,r):void 0,t[13]=r,t[14]=u.inheritsValue,t[15]=f,t[16]=b):b=t[16];let x;t[17]!==h||t[18]!==u.badgeInherit||t[19]!==u.badgeOverride||t[20]!==u.modelLabel||t[21]!==y||t[22]!==b?(x=(0,Q.jsx)(zt,{label:u.modelLabel,mode:y,value:h,inheritedFrom:b,inheritLabel:u.badgeInherit,overrideLabel:u.badgeOverride}),t[17]=h,t[18]=u.badgeInherit,t[19]=u.badgeOverride,t[20]=u.modelLabel,t[21]=y,t[22]=b,t[23]=x):x=t[23];let S=m?`inherit`:`override`,C;t[24]!==i||t[25]!==u.inheritsValue||t[26]!==m?(C=m&&i?u.inheritsValue.replace(`{{value}}`,i):void 0,t[24]=i,t[25]=u.inheritsValue,t[26]=m,t[27]=C):C=t[27];let w;t[28]!==g||t[29]!==u.badgeInherit||t[30]!==u.badgeOverride||t[31]!==u.workspaceLabel||t[32]!==S||t[33]!==C?(w=(0,Q.jsx)(zt,{label:u.workspaceLabel,mode:S,value:g,inheritedFrom:C,inheritLabel:u.badgeInherit,overrideLabel:u.badgeOverride}),t[28]=g,t[29]=u.badgeInherit,t[30]=u.badgeOverride,t[31]=u.workspaceLabel,t[32]=S,t[33]=C,t[34]=w):w=t[34];let T;t[35]!==w||t[36]!==x?(T=(0,Q.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[x,w]}),t[35]=w,t[36]=x,t[37]=T):T=t[37];let E;return t[38]!==T||t[39]!==v?(E=(0,Q.jsxs)(Ye,{children:[v,T]}),t[38]=T,t[39]=v,t[40]=E):E=t[40],E}function Vt(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 Ht(e){let{agentId:t,value:n,onChange:r,a,id:o}=e,s=(0,$.useRef)(null),[c,l]=(0,$.useState)(!1),[d,f]=(0,$.useState)(null),[p,m]=(0,$.useState)(!1),h=(0,$.useMemo)(()=>{let e=He(n.trim());return e&&we(e.styleId)?e.styleId:W[0]??`adventurer`},[n]),g=(0,$.useCallback)(async(e,n)=>{try{await F(t)}catch{}r(u(e,n)),m(!1)},[t,r]),_=(0,$.useCallback)(async e=>{let n=e.target.files?.[0];if(e.target.value=``,n){f(null),l(!0);try{await Fe(t,n),je(t),r(ie)}catch(e){let t=e instanceof Error?e.message:``;f(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=He(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)(J,{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)(B,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),c?a.avatarUploading:a.avatarUploadCustom]})]})]}),d?(0,Q.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:d}):null,(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:W.map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void g(e,H[0]??t),className:i(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,X.press,h===e?`border-fg bg-fg text-surface-base`:`border-edge-subtle bg-surface-panel text-fg hover:border-edge`),children:Vt(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:[H.map(e=>(0,Q.jsx)(`button`,{type:`button`,title:e,onClick:()=>void g(h,e),className:i(`flex size-12 shrink-0 items-center justify-center rounded-full border-2 transition-colors`,X.press,v(h,e)?`border-accent ring-2 ring-accent/30`:`border-transparent hover:border-edge`),children:(0,Q.jsx)(`img`,{src:Xe(h,e,96),alt:``,width:44,height:44,className:`size-11 rounded-full object-cover`,draggable:!1})},e)),(0,Q.jsxs)(Ae,{open:p,onOpenChange:m,children:[(0,Q.jsx)(Le,{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`,X.press),children:a.avatarMore})}),(0,Q.jsx)(Ve,{children:(0,Q.jsxs)(K,{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:Vt(h,a)}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:U.map(e=>(0,Q.jsx)(`button`,{type:`button`,title:e,onClick:()=>void g(h,e),className:i(`flex size-11 shrink-0 items-center justify-center rounded-full border-2 transition-colors`,X.press,v(h,e)?`border-accent ring-2 ring-accent/30`:`border-transparent hover:border-edge`),children:(0,Q.jsx)(`img`,{src:Xe(h,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)(k,{agentId:t,avatar:n,size:40}),n.trim()&&!He(n.trim())&&n.trim()!==`xopc:custom`?(0,Q.jsx)(`span`,{className:`truncate font-mono text-[10px] text-fg-muted`,title:n,children:n}):null]})]})]})}var Ut={name:``,description:``,language:``,creature:``,emoji:``,avatar:``};function Wt(e){let t={...Ut};if(!e.trim())return t;let n={name:`name`,description:`description`,language:`language`,creature:`creature`,emoji:`emoji`,avatar:`avatar`};for(let r of e.split(`
2
2
  `)){let e=r.match(/^[-*]\s+\*\*(\w+):\*\*\s*(.*)/i);if(!e)continue;let i=n[e[1].toLowerCase()];if(!i)continue;let a=e[2].trim();/^_\(.*\)_$/.test(a)&&(a=``),t[i]=a}return t}function Gt(e){return[`# IDENTITY.md - Who Am I?`,``,`- **Name:** ${e.name}`,`- **Description:** ${e.description}`,`- **Language:** ${e.language}`,`- **Creature:** ${e.creature}`,`- **Emoji:** ${e.emoji}`,`- **Avatar:** ${e.avatar}`,``].join(`
3
3
  `)}var Kt={callName:``,pronouns:``,timezone:``,notes:``};function qt(e){let t={...Kt};if(!e.trim())return t;let n={name:`callName`,"what to call them":`callName`,pronouns:`pronouns`,timezone:`timezone`,notes:`notes`},r=e.split(`
4
4
  `),i=-1;for(let e=0;e<r.length;e++){let a=r[e];if(/^##\s+Context/i.test(a)){i=e+1;continue}let o=a.match(/^[-*]\s+\*\*(.+?):\*\*\s*(.*)/i);if(!o)continue;let s=n[o[1].toLowerCase().trim()];if(!s)continue;let c=o[2].trim();/^_\(.*\)_$/.test(c)&&(c=``),t[s]=c}if(i>0){let e=r.slice(i).join(`
@@ -67,5 +67,5 @@ Warm, friendly, and a little playful. Like a helpful friend who happens to know
67
67
 
68
68
  ## Vibe
69
69
 
70
- Sharp, direct, slightly nerdy. The kind of engineer you'd want on your team — competent, opinionated, and occasionally funny.`},{id:`custom`,labelEn:`Custom`,labelZh:`自定义`,emoji:`✍️`,content:``}];function Xt(e){let t=e.trimStart();if(!t.startsWith(`---`))return e;let n=t.indexOf(`---`,3);return n===-1?e:t.slice(n+3).trimStart()}function Zt(e){let t=Xt(e).trim();if(!t)return`professional`;for(let e of Yt)if(e.id!==`custom`&&(t===e.content.trim()||$t(t,e.id)>=2))return e.id;return`custom`}var Qt={professional:/precise and efficient|Value the user's time|actionable answers/g,casual:/good friend|corporate drone|a little playful/g,geeky:/Precision over politeness|Go deep|slightly nerdy/g};function $t(e,t){let n=Qt[t];if(!n)return 0;let r=new RegExp(n.source,`g`),i=new Set,a;for(;(a=r.exec(e))!==null;)if(i.add(a[0]),i.size>=2)return i.size;return i.size}var en=[{value:``,labelEn:`Not set`,labelZh:`未设置`},{value:`Asia/Shanghai`,labelEn:`Asia/Shanghai (CST, UTC+8)`,labelZh:`亚洲/上海 (北京时间, UTC+8)`},{value:`Asia/Tokyo`,labelEn:`Asia/Tokyo (JST, UTC+9)`,labelZh:`亚洲/东京 (日本时间, UTC+9)`},{value:`Asia/Seoul`,labelEn:`Asia/Seoul (KST, UTC+9)`,labelZh:`亚洲/首尔 (韩国时间, UTC+9)`},{value:`Asia/Singapore`,labelEn:`Asia/Singapore (SGT, UTC+8)`,labelZh:`亚洲/新加坡 (UTC+8)`},{value:`Asia/Hong_Kong`,labelEn:`Asia/Hong Kong (HKT, UTC+8)`,labelZh:`亚洲/香港 (UTC+8)`},{value:`Asia/Taipei`,labelEn:`Asia/Taipei (CST, UTC+8)`,labelZh:`亚洲/台北 (UTC+8)`},{value:`Asia/Kolkata`,labelEn:`Asia/Kolkata (IST, UTC+5:30)`,labelZh:`亚洲/加尔各答 (印度时间, UTC+5:30)`},{value:`Asia/Dubai`,labelEn:`Asia/Dubai (GST, UTC+4)`,labelZh:`亚洲/迪拜 (UTC+4)`},{value:`Europe/London`,labelEn:`Europe/London (GMT/BST)`,labelZh:`欧洲/伦敦 (格林尼治时间)`},{value:`Europe/Paris`,labelEn:`Europe/Paris (CET, UTC+1)`,labelZh:`欧洲/巴黎 (中欧时间, UTC+1)`},{value:`Europe/Berlin`,labelEn:`Europe/Berlin (CET, UTC+1)`,labelZh:`欧洲/柏林 (中欧时间, UTC+1)`},{value:`Europe/Moscow`,labelEn:`Europe/Moscow (MSK, UTC+3)`,labelZh:`欧洲/莫斯科 (UTC+3)`},{value:`America/New_York`,labelEn:`America/New York (EST, UTC-5)`,labelZh:`美国/纽约 (东部时间, UTC-5)`},{value:`America/Chicago`,labelEn:`America/Chicago (CST, UTC-6)`,labelZh:`美国/芝加哥 (中部时间, UTC-6)`},{value:`America/Denver`,labelEn:`America/Denver (MST, UTC-7)`,labelZh:`美国/丹佛 (山地时间, UTC-7)`},{value:`America/Los_Angeles`,labelEn:`America/Los Angeles (PST, UTC-8)`,labelZh:`美国/洛杉矶 (太平洋时间, UTC-8)`},{value:`America/Sao_Paulo`,labelEn:`America/São Paulo (BRT, UTC-3)`,labelZh:`美洲/圣保罗 (巴西时间, UTC-3)`},{value:`Australia/Sydney`,labelEn:`Australia/Sydney (AEST, UTC+10)`,labelZh:`澳大利亚/悉尼 (UTC+10)`},{value:`Pacific/Auckland`,labelEn:`Pacific/Auckland (NZST, UTC+12)`,labelZh:`太平洋/奥克兰 (新西兰时间, UTC+12)`}];function tn(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return``}}var nn=[{value:`先生`,labelEn:`Mr.`,labelZh:`先生`},{value:`女士`,labelEn:`Ms.`,labelZh:`女士`},{value:`同学`,labelEn:`Colleague`,labelZh:`同学`},{value:`老师`,labelEn:`Teacher`,labelZh:`老师`},{value:`老板`,labelEn:`Boss`,labelZh:`老板`},{value:`朋友`,labelEn:`Friend`,labelZh:`朋友`}],rn=[{value:`AI assistant`,labelEn:`AI Assistant`,labelZh:`AI 助手`},{value:`robot`,labelEn:`Robot`,labelZh:`机器人`},{value:`familiar`,labelEn:`Familiar`,labelZh:`精灵`},{value:`ghost in the machine`,labelEn:`Ghost in the machine`,labelZh:`机器幽灵`},{value:`digital companion`,labelEn:`Digital Companion`,labelZh:`数字伙伴`}];function an(e){let t=(0,yt.c)(216),{a:n,chat:r,selected:a,busy:c,editName:l,setEditName:u,editDescription:f,setEditDescription:p,editWorkspace:m,setEditWorkspace:h,editModel:g,setEditModel:_,onSetDefault:v,onSaveAgentEdits:y,onDelete:x,hideInlineSave:S,profileMarkdownLoading:w,profileDraft:E,updateIdentity:O,handleSoulTemplateChange:j,handleSoulContentChange:M,setAvatarDialogOpen:N,toggleSoulPreviewMode:P,defaultModel:F,defaultWorkspace:L,onTryInChat:R}=e,ee=F===void 0?``:F,z=L===void 0?``:L,ne=o(cn),re=s(sn),ie;t[0]===E?.identity?ie=t[1]:(ie=E?.identity??{name:``,description:``,language:``,creature:``,emoji:``,avatar:``},t[0]=E?.identity,t[1]=ie);let B=ie,oe=E?.soulTemplate??`professional`,se=E?.soulCustomContent??``,ce=E?.soulEditorNonce??0,le=E?.soulPreviewMode??!1,fe=E?.avatarDialogOpen??!1,me;t[2]===ne?me=t[3]:(me=(e,t)=>ne===`zh`?t:e,t[2]=ne,t[3]=me);let V=me,he;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(he=Dt(),t[4]=he):he=t[4];let H=he;if(!a){let e;return t[5]===n.selectAgentHint?e=t[6]:(e=(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.selectAgentHint}),t[5]=n.selectAgentHint,t[6]=e),e}let U;t[7]===a.id?U=t[8]:(U=ke(a.id),t[7]=a.id,t[8]=U);let W;t[9]===U?W=t[10]:(W={[C]:U},t[9]=U,t[10]=W);let G;t[11]!==n||t[12]!==ee||t[13]!==z||t[14]!==g||t[15]!==m||t[16]!==W?(G=(0,Q.jsx)(Bt,{a:n,defaultModel:ee,defaultWorkspace:z,agentModel:g,agentWorkspace:m,settingsState:W}),t[11]=n,t[12]=ee,t[13]=z,t[14]=g,t[15]=m,t[16]=W,t[17]=G):G=t[17];let xe;t[18]!==B.avatar||t[19]!==a.id?(xe=(0,Q.jsx)(k,{agentId:a.id,avatar:B.avatar,size:36,className:`size-9 rounded-lg`}),t[18]=B.avatar,t[19]=a.id,t[20]=xe):xe=t[20];let Se;t[21]===N?Se=t[22]:(Se=()=>N(!0),t[21]=N,t[22]=Se);let Ce;t[23]!==n.avatarOpenSettingsAria||t[24]!==Se?(Ce={onClick:Se,ariaLabel:n.avatarOpenSettingsAria,id:`agent-avatar-settings`},t[23]=n.avatarOpenSettingsAria,t[24]=Se,t[25]=Ce):Ce=t[25];let K;t[26]!==n.setDefault||t[27]!==c||t[28]!==v||t[29]!==a.isDefault?(K=a.isDefault?null:(0,Q.jsx)(J,{type:`button`,variant:`secondary`,className:`text-xs`,disabled:c,onClick:()=>void v(),children:n.setDefault}),t[26]=n.setDefault,t[27]=c,t[28]=v,t[29]=a.isDefault,t[30]=K):K=t[30];let q;t[31]!==n.personaSectionIdentity||t[32]!==n.personaSectionIdentityHint||t[33]!==Ce||t[34]!==K||t[35]!==xe?(q=(0,Q.jsx)(Je,{icon:Ie,title:n.personaSectionIdentity,subtitle:n.personaSectionIdentityHint,iconLeading:xe,iconInteractive:Ce,trailing:K}),t[31]=n.personaSectionIdentity,t[32]=n.personaSectionIdentityHint,t[33]=Ce,t[34]=K,t[35]=xe,t[36]=q):q=t[36];let we;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(we=(0,Q.jsx)(ge,{className:i(`fixed inset-0 bg-scrim backdrop-blur-[2px]`,ye)}),t[37]=we):we=t[37];let Ee;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=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`,Te),t[38]=Ee):Ee=t[38];let Oe;t[39]===n.avatarPickerTitle?Oe=t[40]:(Oe=(0,Q.jsx)(d,{className:`text-base font-semibold text-fg`,children:n.avatarPickerTitle}),t[39]=n.avatarPickerTitle,t[40]=Oe);let Ae;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=i(be,`shrink-0 p-1.5 hover:bg-surface-base`),t[41]=Ae):Ae=t[41];let je;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(je=(0,Q.jsx)(De,{className:`size-4`,"aria-hidden":!0}),t[42]=je):je=t[42];let Me;t[43]===n.closeDialogAria?Me=t[44]:(Me=(0,Q.jsx)(Pe,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:Ae,"aria-label":n.closeDialogAria,children:je})}),t[43]=n.closeDialogAria,t[44]=Me);let Ne;t[45]!==Oe||t[46]!==Me?(Ne=(0,Q.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[Oe,Me]}),t[45]=Oe,t[46]=Me,t[47]=Ne):Ne=t[47];let Fe;t[48]===n.avatarRowHint?Fe=t[49]:(Fe=(0,Q.jsx)(_e,{className:`sr-only`,children:n.avatarRowHint}),t[48]=n.avatarRowHint,t[49]=Fe);let Le;t[50]===O?Le=t[51]:(Le=e=>O({avatar:e}),t[50]=O,t[51]=Le);let Re;t[52]!==n||t[53]!==B.avatar||t[54]!==a.id||t[55]!==Le?(Re=(0,Q.jsx)(Ht,{agentId:a.id,value:B.avatar,onChange:Le,a:n}),t[52]=n,t[53]=B.avatar,t[54]=a.id,t[55]=Le,t[56]=Re):Re=t[56];let ze;t[57]!==Ne||t[58]!==Fe||t[59]!==Re?(ze=(0,Q.jsxs)(ve,{children:[we,(0,Q.jsxs)(A,{className:Ee,onOpenAutoFocus:on,children:[Ne,Fe,Re]})]}),t[57]=Ne,t[58]=Fe,t[59]=Re,t[60]=ze):ze=t[60];let Be;t[61]!==fe||t[62]!==N||t[63]!==ze?(Be=(0,Q.jsx)(ae,{open:fe,onOpenChange:N,children:ze}),t[61]=fe,t[62]=N,t[63]=ze,t[64]=Be):Be=t[64];let Ve;t[65]===n.displayName?Ve=t[66]:(Ve=(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:n.displayName}),t[65]=n.displayName,t[66]=Ve);let He;t[67]!==u||t[68]!==O?(He=e=>{u(e.target.value),O({name:e.target.value})},t[67]=u,t[68]=O,t[69]=He):He=t[69];let Y;t[70]!==n.personaNamePlaceholder||t[71]!==l||t[72]!==He?(Y=(0,Q.jsx)(`input`,{className:H,value:l,onChange:He,placeholder:n.personaNamePlaceholder,autoComplete:`off`}),t[70]=n.personaNamePlaceholder,t[71]=l,t[72]=He,t[73]=Y):Y=t[73];let Ue;t[74]!==Ve||t[75]!==Y?(Ue=(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[Ve,Y]}),t[74]=Ve,t[75]=Y,t[76]=Ue):Ue=t[76];let We;t[77]===n.personaEmoji?We=t[78]:(We=(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:n.personaEmoji}),t[77]=n.personaEmoji,t[78]=We);let Ge;t[79]===O?Ge=t[80]:(Ge=e=>O({emoji:e.target.value}),t[79]=O,t[80]=Ge);let Z;t[81]!==n.personaEmojiPlaceholder||t[82]!==B.emoji||t[83]!==Ge?(Z=(0,Q.jsx)(`input`,{className:H,value:B.emoji,onChange:Ge,placeholder:n.personaEmojiPlaceholder,autoComplete:`off`}),t[81]=n.personaEmojiPlaceholder,t[82]=B.emoji,t[83]=Ge,t[84]=Z):Z=t[84];let Xe;t[85]!==We||t[86]!==Z?(Xe=(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[We,Z]}),t[85]=We,t[86]=Z,t[87]=Xe):Xe=t[87];let Ze;t[88]===n.agentDescription?Ze=t[89]:(Ze=(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:n.agentDescription}),t[88]=n.agentDescription,t[89]=Ze);let Qe;t[90]===Symbol.for(`react.memo_cache_sentinel`)?(Qe=i(H,`min-h-16 resize-y text-sm leading-relaxed`),t[90]=Qe):Qe=t[90];let $e;t[91]!==p||t[92]!==O?($e=e=>{p(e.target.value),O({description:e.target.value})},t[91]=p,t[92]=O,t[93]=$e):$e=t[93];let et;t[94]!==n.agentDescriptionPlaceholder||t[95]!==f||t[96]!==$e?(et=(0,Q.jsx)(`textarea`,{className:Qe,value:f,onChange:$e,placeholder:n.agentDescriptionPlaceholder,maxLength:4e3,rows:3,spellCheck:!0}),t[94]=n.agentDescriptionPlaceholder,t[95]=f,t[96]=$e,t[97]=et):et=t[97];let tt;t[98]!==Ze||t[99]!==et?(tt=(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[Ze,et]}),t[98]=Ze,t[99]=et,t[100]=tt):tt=t[100];let nt;t[101]===n.personaCreature?nt=t[102]:(nt=(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:n.personaCreature}),t[101]=n.personaCreature,t[102]=nt);let rt;t[103]===B.creature?rt=t[104]:(rt=rn.some(e=>e.value===B.creature)?B.creature:`__custom__`,t[103]=B.creature,t[104]=rt);let it;t[105]===O?it=t[106]:(it=e=>{if(e.target.value===`__custom__`){O({creature:``});return}O({creature:e.target.value})},t[105]=O,t[106]=it);let at;t[107]===V?at=t[108]:(at=rn.map(e=>(0,Q.jsx)(`option`,{value:e.value,children:V(e.labelEn,e.labelZh)},e.value)),t[107]=V,t[108]=at);let ot;t[109]===V?ot=t[110]:(ot=V(`Custom…`,`自定义…`),t[109]=V,t[110]=ot);let st;t[111]===ot?st=t[112]:(st=(0,Q.jsx)(`option`,{value:`__custom__`,children:ot}),t[111]=ot,t[112]=st);let lt;t[113]!==rt||t[114]!==it||t[115]!==at||t[116]!==st?(lt=(0,Q.jsxs)(`select`,{className:H,value:rt,onChange:it,children:[at,st]}),t[113]=rt,t[114]=it,t[115]=at,t[116]=st,t[117]=lt):lt=t[117];let ut;t[118]!==n.personaCreaturePlaceholder||t[119]!==B.creature||t[120]!==O?(ut=rn.some(e=>e.value===B.creature)?null:(0,Q.jsx)(`input`,{className:i(H,`mt-1 text-xs`),value:B.creature,onChange:e=>O({creature:e.target.value}),placeholder:n.personaCreaturePlaceholder,autoComplete:`off`}),t[118]=n.personaCreaturePlaceholder,t[119]=B.creature,t[120]=O,t[121]=ut):ut=t[121];let dt;t[122]!==nt||t[123]!==lt||t[124]!==ut?(dt=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[nt,lt,ut]}),t[122]=nt,t[123]=lt,t[124]=ut,t[125]=dt):dt=t[125];let ft;t[126]!==Ue||t[127]!==Xe||t[128]!==tt||t[129]!==dt?(ft=(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[Ue,Xe,tt,dt]}),t[126]=Ue,t[127]=Xe,t[128]=tt,t[129]=dt,t[130]=ft):ft=t[130];let pt;t[131]!==q||t[132]!==Be||t[133]!==ft?(pt=(0,Q.jsxs)(Ye,{children:[q,Be,ft]}),t[131]=q,t[132]=Be,t[133]=ft,t[134]=pt):pt=t[134];let mt;t[135]!==n.editAgent||t[136]!==n.editAgentHint?(mt=(0,Q.jsx)(Je,{icon:D,title:n.editAgent,subtitle:n.editAgentHint}),t[135]=n.editAgent,t[136]=n.editAgentHint,t[137]=mt):mt=t[137];let ht;t[138]===n.modelPrimary?ht=t[139]:(ht=(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:n.modelPrimary}),t[138]=n.modelPrimary,t[139]=ht);let gt;t[140]===_?gt=t[141]:(gt=e=>_(e),t[140]=_,t[141]=gt);let _t;t[142]!==c||t[143]!==r.modelNoMatches||t[144]!==r.modelPlaceholder||t[145]!==r.modelSearchPlaceholder||t[146]!==g||t[147]!==gt?(_t=(0,Q.jsx)(ue,{className:`min-w-0 flex-1`,value:g,disabled:c,placeholder:r.modelPlaceholder,searchPlaceholder:r.modelSearchPlaceholder,noMatches:r.modelNoMatches,onChange:gt}),t[142]=c,t[143]=r.modelNoMatches,t[144]=r.modelPlaceholder,t[145]=r.modelSearchPlaceholder,t[146]=g,t[147]=gt,t[148]=_t):_t=t[148];let vt;t[149]!==n.modelClear||t[150]!==c||t[151]!==g||t[152]!==_?(vt=g.trim()?(0,Q.jsx)(J,{type:`button`,variant:`secondary`,className:`shrink-0`,disabled:c,onClick:()=>_(``),children:n.modelClear}):null,t[149]=n.modelClear,t[150]=c,t[151]=g,t[152]=_,t[153]=vt):vt=t[153];let bt;t[154]!==_t||t[155]!==vt?(bt=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[_t,vt]}),t[154]=_t,t[155]=vt,t[156]=bt):bt=t[156];let xt;t[157]!==ht||t[158]!==bt?(xt=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[ht,bt]}),t[157]=ht,t[158]=bt,t[159]=xt):xt=t[159];let St;t[160]===n.workspacePath?St=t[161]:(St=(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:n.workspacePath}),t[160]=n.workspacePath,t[161]=St);let Ct=r.workingDirectory,wt=r.workingDirectory.notSet,Tt;t[162]===Symbol.for(`react.memo_cache_sentinel`)?(Tt=i(H,`font-mono text-xs`),t[162]=Tt):Tt=t[162];let Et;t[163]!==c||t[164]!==r.workingDirectory||t[165]!==m||t[166]!==h?(Et=(0,Q.jsx)(ct,{value:m,onChange:h,disabled:c,wd:Ct,placeholder:wt,inputClassName:Tt}),t[163]=c,t[164]=r.workingDirectory,t[165]=m,t[166]=h,t[167]=Et):Et=t[167];let Ot;t[168]!==St||t[169]!==Et?(Ot=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[St,Et]}),t[168]=St,t[169]=Et,t[170]=Ot):Ot=t[170];let kt;t[171]!==xt||t[172]!==Ot?(kt=(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[xt,Ot]}),t[171]=xt,t[172]=Ot,t[173]=kt):kt=t[173];let At;t[174]!==n.save||t[175]!==n.tryInChat||t[176]!==c||t[177]!==S||t[178]!==y||t[179]!==R?(At=S?null:(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(J,{type:`button`,disabled:c,onClick:()=>void y(),children:n.save}),R?(0,Q.jsxs)(J,{type:`button`,variant:`secondary`,disabled:c,onClick:R,children:[(0,Q.jsx)(de,{className:`mr-1.5 size-4`,"aria-hidden":!0}),n.tryInChat]}):null]}),t[174]=n.save,t[175]=n.tryInChat,t[176]=c,t[177]=S,t[178]=y,t[179]=R,t[180]=At):At=t[180];let jt;t[181]!==mt||t[182]!==kt||t[183]!==At?(jt=(0,Q.jsxs)(Ye,{children:[mt,kt,At]}),t[181]=mt,t[182]=kt,t[183]=At,t[184]=jt):jt=t[184];let Mt;t[185]!==n.loading||t[186]!==n.personaSectionSoul||t[187]!==n.personaSectionSoulHint||t[188]!==n.personaSoulCustomEdit||t[189]!==n.personaSoulEdit||t[190]!==n.personaSoulPreview||t[191]!==n.personaSoulTemplate||t[192]!==M||t[193]!==j||t[194]!==re||t[195]!==V||t[196]!==w||t[197]!==se||t[198]!==ce||t[199]!==le||t[200]!==oe||t[201]!==P?(Mt=w?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.loading}):(0,Q.jsxs)(Ye,{children:[(0,Q.jsx)(Je,{icon:b,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:Yt.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`,X.pressCard,oe===e.id?`border-accent bg-accent-soft/40 shadow-sm`:`border-edge hover:border-accent/40 hover:bg-surface-hover`),onClick:()=>j(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:V(e.labelEn,e.labelZh)})]},e.id))})]}),oe===`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(be,`inline-flex size-9 shrink-0 items-center justify-center rounded-md p-0 hover:bg-surface-hover`),title:le?n.personaSoulEdit:n.personaSoulPreview,"aria-label":le?n.personaSoulEdit:n.personaSoulPreview,onClick:P,children:le?(0,Q.jsx)(I,{className:`size-4`,"aria-hidden":!0}):(0,Q.jsx)(te,{className:`size-4`,"aria-hidden":!0})})]}),(0,Q.jsx)(`div`,{className:i(H,`flex min-h-64 flex-col overflow-hidden p-0`),children:le?(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,Q.jsx)(Ke,{content:se})}):(0,Q.jsx)(qe,{initialContent:se,onChange:M,isDark:re,className:`min-h-0 flex-1`},`soul-${ce}`)})]}):null]}),t[185]=n.loading,t[186]=n.personaSectionSoul,t[187]=n.personaSectionSoulHint,t[188]=n.personaSoulCustomEdit,t[189]=n.personaSoulEdit,t[190]=n.personaSoulPreview,t[191]=n.personaSoulTemplate,t[192]=M,t[193]=j,t[194]=re,t[195]=V,t[196]=w,t[197]=se,t[198]=ce,t[199]=le,t[200]=oe,t[201]=P,t[202]=Mt):Mt=t[202];let Nt;t[203]!==n.purgeDisk||t[204]!==n.removeFromConfig||t[205]!==c||t[206]!==V||t[207]!==x||t[208]!==a.id?(Nt=a.id===`main`?null:(0,Q.jsxs)(Ye,{children:[(0,Q.jsx)(Je,{icon:pe,title:V(`Danger Zone`,`危险操作`),subtitle:V(`Actions that cannot be undone. Be careful.`,`以下操作不可撤销,请谨慎操作。`)}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsxs)(J,{type:`button`,variant:`secondary`,disabled:c,onClick:()=>void x(!1),children:[(0,Q.jsx)(T,{className:`mr-1 size-4`,"aria-hidden":!0}),n.removeFromConfig]}),(0,Q.jsx)(J,{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[203]=n.purgeDisk,t[204]=n.removeFromConfig,t[205]=c,t[206]=V,t[207]=x,t[208]=a.id,t[209]=Nt):Nt=t[209];let Pt;return t[210]!==pt||t[211]!==jt||t[212]!==Mt||t[213]!==Nt||t[214]!==G?(Pt=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-8 overflow-y-auto`,children:[G,pt,jt,Mt,Nt]}),t[210]=pt,t[211]=jt,t[212]=Mt,t[213]=Nt,t[214]=G,t[215]=Pt):Pt=t[215],Pt}function on(e){return e.preventDefault()}function sn(e){return e.resolved===`dark`}function cn(e){return e.language}function ln(e){let t=!e.pronouns||nn.some(t=>t.value===e.pronouns),n=en.some(t=>t.value===e.timezone);return{showCustomPronouns:!!(e.pronouns&&!t),showCustomTimezone:!!(e.timezone&&!n),customTimezone:e.timezone&&!n?e.timezone:``}}function un(e,t){switch(t.type){case`load`:{let e=ln(t.user),n=JSON.stringify(t.user);return{user:t.user,snapshot:n,...e}}case`patch`:{let n={...e.user,...t.patch};return{...e,user:n}}case`setShowCustomPronouns`:return{...e,showCustomPronouns:t.value};case`setShowCustomTimezone`:return{...e,showCustomTimezone:t.value};case`setCustomTimezone`:return{...e,customTimezone:t.value};case`saved`:return{...e,snapshot:JSON.stringify(e.user)}}}var dn={callName:``,pronouns:``,timezone:``,notes:``},fn={user:dn,showCustomPronouns:!1,showCustomTimezone:!1,customTimezone:``,snapshot:JSON.stringify(dn)};function pn({a:e,agentId:t,saveRef:n,onDirtyChange:r}){let a=o(e=>e.language),[s,c]=(0,$.useReducer)(un,fn),l=(0,$.useRef)(t);l.current=t;let u=(0,$.useRef)(r);u.current=r;let d=M(async()=>{let e=qt(await Z(t,`USER.md`).catch(()=>``));if(!e.timezone){let t=tn();if(t)return{...e,timezone:t}}return e},[t],{enabled:!!t,initial:null,errorData:dn}),f=(0,$.useRef)(null);(0,$.useEffect)(()=>{d.loading||!d.data||f.current!==t&&(f.current=t,c({type:`load`,user:d.data}),u.current?.(!1))},[t,d.loading,d.data]);let p=(0,$.useCallback)(async e=>{await w(l.current,`USER.md`,e)},[]),m=(0,$.useRef)(s.user);m.current=s.user,(0,$.useEffect)(()=>{if(n)return n.current=async()=>{await p(Jt(m.current)),c({type:`saved`}),u.current?.(!1)},()=>{n.current=null}},[n,p]);let h=(0,$.useCallback)(e=>{c({type:`patch`,patch:e});let t={...m.current,...e};u.current?.(JSON.stringify(t)!==s.snapshot)},[s.snapshot]),g=(0,$.useCallback)(e=>{if(e===`__custom__`){c({type:`setShowCustomTimezone`,value:!0});return}c({type:`setShowCustomTimezone`,value:!1}),c({type:`setCustomTimezone`,value:``}),h({timezone:e})},[h]),_=(0,$.useCallback)(e=>{c({type:`setCustomTimezone`,value:e}),h({timezone:e})},[h]),v=(0,$.useCallback)(()=>{let e=tn();e&&(en.some(t=>t.value===e)?(c({type:`setShowCustomTimezone`,value:!1}),c({type:`setCustomTimezone`,value:``})):(c({type:`setShowCustomTimezone`,value:!0}),c({type:`setCustomTimezone`,value:e})),h({timezone:e}))},[h]),y=s.showCustomTimezone?`__custom__`:en.some(e=>e.value===s.user.timezone)?s.user.timezone:`__custom__`,b=(0,$.useCallback)((e,t)=>a===`zh`?t:e,[a]);if(d.loading)return(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.loading});let x=Dt(),{user:S,showCustomPronouns:C,showCustomTimezone:T,customTimezone:E}=s;return(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-6 overflow-y-auto`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.personaSectionUserHint}),(0,Q.jsxs)(Ye,{children:[(0,Q.jsx)(Je,{icon:j,title:e.personaSectionUser,subtitle:e.personaSectionUserHint}),(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:e.personaCallName}),(0,Q.jsx)(`input`,{className:x,value:S.callName,onChange:e=>h({callName:e.target.value}),placeholder:e.personaCallNamePlaceholder,autoComplete:`off`})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:e.personaPronouns}),(0,Q.jsxs)(`select`,{className:x,value:nn.some(e=>e.value===S.pronouns)?S.pronouns:`__custom__`,onChange:e=>{if(e.target.value===`__custom__`){c({type:`setShowCustomPronouns`,value:!0});return}c({type:`setShowCustomPronouns`,value:!1}),h({pronouns:e.target.value})},children:[(0,Q.jsx)(`option`,{value:``,disabled:!0,children:e.personaPronounsPlaceholder}),nn.map(e=>(0,Q.jsx)(`option`,{value:e.value,children:b(e.labelEn,e.labelZh)},e.value)),(0,Q.jsx)(`option`,{value:`__custom__`,children:b(`Custom…`,`自定义…`)})]}),C?(0,Q.jsx)(`input`,{className:i(x,`mt-1 text-xs`),value:nn.some(e=>e.value===S.pronouns)?``:S.pronouns,onChange:e=>h({pronouns:e.target.value}),placeholder:e.personaPronounsPlaceholder,autoComplete:`off`}):null]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:e.personaTimezone}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[(0,Q.jsxs)(`select`,{className:i(x,`min-w-0 flex-1`),value:y,onChange:e=>g(e.target.value),children:[en.map(e=>(0,Q.jsx)(`option`,{value:e.value,children:b(e.labelEn,e.labelZh)},e.value)),(0,Q.jsx)(`option`,{value:`__custom__`,children:e.personaTimezoneCustom})]}),(0,Q.jsx)(`button`,{type:`button`,className:i(`shrink-0 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,X.press),onClick:v,children:e.personaTimezoneDetect})]}),T?(0,Q.jsx)(`input`,{className:i(x,`mt-1 font-mono text-xs`),value:E,onChange:e=>_(e.target.value),placeholder:`e.g. Asia/Shanghai`,autoComplete:`off`}):null]}),(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:e.personaNotes}),(0,Q.jsx)(`textarea`,{className:i(x,`min-h-16 resize-y text-sm leading-relaxed`),value:S.notes,onChange:e=>h({notes:e.target.value}),placeholder:e.personaNotesPlaceholder,rows:3,spellCheck:!0})]})]}),(0,Q.jsxs)(`div`,{className:`mt-3 flex items-start gap-2 rounded-lg bg-accent-soft/30 px-3 py-2.5 text-xs text-fg-muted`,children:[(0,Q.jsx)(Ue,{className:`mt-0.5 size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{children:e.personaMemoryNote})]})]})]})}function mn(e){let t=(0,yt.c)(2),n;return t[0]===e?n=t[1]:(n=(0,Q.jsx)(pn,{...e},e.agentId),t[0]=e,t[1]=n),n}function hn(e){let t=(0,yt.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(gn)):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)(Je,{className:`shrink-0`,icon:Ce,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)(J,{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 S;t[18]!==n.skillsCustomize||t[19]!==a||t[20]!==x?(S=(0,Q.jsx)(J,{type:`button`,variant:`secondary`,disabled:a,onClick:x,children:n.skillsCustomize}),t[18]=n.skillsCustomize,t[19]=a,t[20]=x,t[21]=S):S=t[21];let C;t[22]!==b||t[23]!==S?(C=(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[b,S]}),t[22]=b,t[23]=S,t[24]=C):C=t[24];let w;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(w=Y(`skills`),t[25]=w):w=t[25];let T;t[26]===n.skillsLibraryLink?T=t[27]:(T=(0,Q.jsx)(se,{to:w,className:`shrink-0 text-xs font-medium text-accent-fg hover:underline`,children:n.skillsLibraryLink}),t[26]=n.skillsLibraryLink,t[27]=T);let E;t[28]!==C||t[29]!==T?(E=(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3`,children:[C,T]}),t[28]=C,t[29]=T,t[30]=E):E=t[30];let D;t[31]===r.skills.defaults?D=t[32]:(D=r.skills.defaults.length?r.skills.defaults.join(`, `):`—`,t[31]=r.skills.defaults,t[32]=D);let O;t[33]!==n.skillsDefaultsLabel||t[34]!==D?(O=(0,Q.jsxs)(`p`,{className:`mt-2 shrink-0 text-xs text-fg-muted`,children:[n.skillsDefaultsLabel,` `,D]}),t[33]=n.skillsDefaultsLabel,t[34]=D,t[35]=O):O=t[35];let k;t[36]!==n.skillsInherit||t[37]!==r.skills.effectiveAllowlist||t[38]!==c?(k=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]=k):k=t[39];let A;t[40]!==n.skillsEffectiveLabel||t[41]!==k?(A=(0,Q.jsxs)(`p`,{className:`shrink-0 text-xs text-fg-muted`,children:[n.skillsEffectiveLabel,` `,k]}),t[40]=n.skillsEffectiveLabel,t[41]=k,t[42]=A):A=t[42];let j;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?(j=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]=j):j=t[53];let M;t[54]!==n.skillsSave||t[55]!==a||t[56]!==p||t[57]!==f?(M=p?null:(0,Q.jsx)(`div`,{className:`mt-4 shrink-0`,children:(0,Q.jsx)(J,{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]=M):M=t[58];let N;return t[59]!==E||t[60]!==O||t[61]!==A||t[62]!==j||t[63]!==M||t[64]!==v?(N=(0,Q.jsxs)(Ye,{className:`flex min-h-0 flex-1 flex-col`,children:[v,E,O,A,j,M]}),t[59]=E,t[60]=O,t[61]=A,t[62]=j,t[63]=M,t[64]=v,t[65]=N):N=t[65],N}function gn(e){return e.name||e.directoryId}function _n(e){let t=(0,yt.c)(51),{a:n,data:r,selected:i,busy:s,toolEntryDisable:c,setToolEntryDisable:l,onSaveTools:u,onClearToolsEntry:d,hideInlineSave:f}=e,p=o(yn),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.defaultsDisable?g=t[3]:(g=new Set(i.tools.defaultsDisable.flatMap(vn)),t[2]=i.tools.defaultsDisable,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)(Je,{className:`shrink-0`,icon:L,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.toolsLockedByDefaults||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.toolsLockedByDefaults},t[13]=n.toolsLockedByDefaults,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]!==_||t[27]!==S||t[28]!==w||t[29]!==y||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)(it,{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]=_,t[27]=S,t[28]=w,t[29]=y,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)(J,{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)(J,{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)(Ye,{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 vn(e){let t=String(e).trim();return t?[t]:[]}function yn(e){return e.language}function bn(e){let t=(0,yt.c)(107),{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,profileSaveRef:S,overviewProfile:C,setProfileDirty:w,filesLoading:T,files:E,activeFile:D,setActiveFile:O,filesViewMode:k,setFilesViewMode:A,fileDraft:j,setFileDraft:M,fileSaving:N,profileFileLoading:P,profileEditorNonce:F,toolEntryDisable:I,setToolEntryDisable:L,onSaveTools:R,onClearToolsEntry:ee,modelRows:z,setModelRows:te,onSaveModels:ne,onClearModelsEntry:re,skillsCatalogLoading:ie,catalogForPick:ae,skillsInherit:B,setSkillsInherit:oe,skillsPick:se,setSkillsPick:ce,onSaveSkills:le,bindingsLoading:ue,agentBindings:de,bindChannelStatuses:fe,bindChannelsLoading:pe,useManualChannel:me,newBindChannel:V,setNewBindChannel:he,bindSessionChats:H,bindSessionsLoading:ge,newBindSessionIdx:U,setNewBindSessionIdx:_e,newBindCustomPeer:W,setNewBindCustomPeer:ve,refreshBindSessions:ye,onRemoveBinding:G,onAddBinding:be,cronLoading:xe,agentCronJobs:Se,onSetCronJobAgent:Ce,onTryInChat:K}=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;return t[2]!==n||t[3]!==c||t[4]!==r||t[5]!==_||t[6]!==v||t[7]!==d||t[8]!==h||t[9]!==l||t[10]!==p||t[11]!==x||t[12]!==b||t[13]!==y||t[14]!==K||t[15]!==C.draft||t[16]!==C.handleSoulContentChange||t[17]!==C.handleSoulTemplateChange||t[18]!==C.profileMarkdownLoading||t[19]!==C.setAvatarDialogOpen||t[20]!==C.toggleSoulPreviewMode||t[21]!==C.updateIdentity||t[22]!==a||t[23]!==f||t[24]!==g||t[25]!==u||t[26]!==m?(e=(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,hideInlineSave:!0,profileMarkdownLoading:C.profileMarkdownLoading,profileDraft:C.draft,updateIdentity:C.updateIdentity,handleSoulTemplateChange:C.handleSoulTemplateChange,handleSoulContentChange:C.handleSoulContentChange,setAvatarDialogOpen:C.setAvatarDialogOpen,toggleSoulPreviewMode:C.toggleSoulPreviewMode,defaultModel:_,defaultWorkspace:v,onTryInChat:K}),t[2]=n,t[3]=c,t[4]=r,t[5]=_,t[6]=v,t[7]=d,t[8]=h,t[9]=l,t[10]=p,t[11]=x,t[12]=b,t[13]=y,t[14]=K,t[15]=C.draft,t[16]=C.handleSoulContentChange,t[17]=C.handleSoulTemplateChange,t[18]=C.profileMarkdownLoading,t[19]=C.setAvatarDialogOpen,t[20]=C.toggleSoulPreviewMode,t[21]=C.updateIdentity,t[22]=a,t[23]=f,t[24]=g,t[25]=u,t[26]=m,t[27]=e):e=t[27],e}if(o===`profile`){let e;return t[28]!==n||t[29]!==S||t[30]!==a.id||t[31]!==w?(e=(0,Q.jsx)(mn,{a:n,agentId:a.id,saveRef:S,onDirtyChange:w}),t[28]=n,t[29]=S,t[30]=a.id,t[31]=w,t[32]=e):e=t[32],e}if(o===`files`){let e;return t[33]!==n||t[34]!==D||t[35]!==j||t[36]!==N||t[37]!==E||t[38]!==T||t[39]!==k||t[40]!==K||t[41]!==F||t[42]!==P||t[43]!==O||t[44]!==M||t[45]!==A?(e=(0,Q.jsx)(It,{a:n,filesLoading:T,files:E,activeFile:D,setActiveFile:O,filesViewMode:k,setFilesViewMode:A,fileDraft:j,setFileDraft:M,fileSaving:N,profileFileLoading:P,profileEditorNonce:F,onTryInChat:K}),t[33]=n,t[34]=D,t[35]=j,t[36]=N,t[37]=E,t[38]=T,t[39]=k,t[40]=K,t[41]=F,t[42]=P,t[43]=O,t[44]=M,t[45]=A,t[46]=e):e=t[46],e}if(o===`tools`){let e;return t[47]!==n||t[48]!==c||t[49]!==s||t[50]!==ee||t[51]!==R||t[52]!==a||t[53]!==L||t[54]!==I?(e=(0,Q.jsx)(_n,{a:n,data:s,selected:a,busy:c,toolEntryDisable:I,setToolEntryDisable:L,onSaveTools:R,onClearToolsEntry:ee,hideInlineSave:!0}),t[47]=n,t[48]=c,t[49]=s,t[50]=ee,t[51]=R,t[52]=a,t[53]=L,t[54]=I,t[55]=e):e=t[55],e}if(o===`models`){let e;return t[56]!==n||t[57]!==c||t[58]!==r||t[59]!==z||t[60]!==re||t[61]!==ne||t[62]!==a||t[63]!==te?(e=(0,Q.jsx)(Rt,{a:n,chat:r,selected:a,busy:c,modelRows:z,setModelRows:te,onSaveModels:ne,onClearModelsEntry:re,hideInlineSave:!0}),t[56]=n,t[57]=c,t[58]=r,t[59]=z,t[60]=re,t[61]=ne,t[62]=a,t[63]=te,t[64]=e):e=t[64],e}if(o===`skills`){let e;return t[65]!==n||t[66]!==c||t[67]!==ae||t[68]!==le||t[69]!==a||t[70]!==oe||t[71]!==ce||t[72]!==ie||t[73]!==B||t[74]!==se?(e=(0,Q.jsx)(hn,{a:n,selected:a,busy:c,skillsCatalogLoading:ie,catalogForPick:ae,skillsInherit:B,setSkillsInherit:oe,skillsPick:se,setSkillsPick:ce,onSaveSkills:le,hideInlineSave:!0}),t[65]=n,t[66]=c,t[67]=ae,t[68]=le,t[69]=a,t[70]=oe,t[71]=ce,t[72]=ie,t[73]=B,t[74]=se,t[75]=e):e=t[75],e}if(o===`channels`){let e;return t[76]!==n||t[77]!==de||t[78]!==fe||t[79]!==pe||t[80]!==H||t[81]!==ge||t[82]!==ue||t[83]!==c||t[84]!==i.lastActiveLabels||t[85]!==i.selectRecipient||t[86]!==V||t[87]!==W||t[88]!==U||t[89]!==be||t[90]!==G||t[91]!==ye||t[92]!==he||t[93]!==ve||t[94]!==_e||t[95]!==me?(e=(0,Q.jsx)(Mt,{a:n,busy:c,bindingsLoading:ue,agentBindings:de,channelStatuses:fe,channelsStatusLoading:pe,useManualChannel:me,newBindChannel:V,setNewBindChannel:he,bindSessionChats:H,sessionsLoading:ge,newBindSessionIdx:U,setNewBindSessionIdx:_e,newBindCustomPeer:W,setNewBindCustomPeer:ve,onRefreshSessions:ye,lastActiveLabels:i.lastActiveLabels,selectRecipient:i.selectRecipient,onRemoveBinding:G,onAddBinding:be}),t[76]=n,t[77]=de,t[78]=fe,t[79]=pe,t[80]=H,t[81]=ge,t[82]=ue,t[83]=c,t[84]=i.lastActiveLabels,t[85]=i.selectRecipient,t[86]=V,t[87]=W,t[88]=U,t[89]=be,t[90]=G,t[91]=ye,t[92]=he,t[93]=ve,t[94]=_e,t[95]=me,t[96]=e):e=t[96],e}if(o===`cron`&&s){let e;return t[97]!==n||t[98]!==Se||t[99]!==c||t[100]!==xe||t[101]!==s||t[102]!==Ce||t[103]!==a?(e=(0,Q.jsx)(Nt,{a:n,data:s,selected:a,busy:c,cronLoading:xe,agentCronJobs:Se,onSetCronJobAgent:Ce}),t[97]=n,t[98]=Se,t[99]=c,t[100]=xe,t[101]=s,t[102]=Ce,t[103]=a,t[104]=e):e=t[104],e}let q;return t[105]===n.selectAgentHint?q=t[106]:(q=(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.selectAgentHint}),t[105]=n.selectAgentHint,t[106]=q),q}function xn(e,t,n){let r=t.trim().toLowerCase();return r?e.filter(e=>{let t=S(e,n).toLowerCase(),i=e.id.toLowerCase(),a=e.workspace.toLowerCase(),o=re(e,n).toLowerCase();return t.includes(r)||i.includes(r)||a.includes(r)||o.includes(r)}):e}function Sn(e,t){return e.replace(`{{count}}`,String(t))}function Cn(e,t){let n=e.model?.primary?.trim(),r=e.workspace.trim();return[{label:t.listModelLabel,value:n||t.listInheritedValue,title:n||void 0},{label:t.listWorkspaceLabel,value:r||t.listUnsetValue,title:r||void 0}]}function wn(e,t){let n=e.tools.effectiveDisable.length,r=e.skills.effectiveAllowlist?.length??0,i=n>0?Sn(t.listToolsDisabledCount,n):t.listToolsAllEnabled,a=r>0?Sn(t.listSkillsCount,r):t.listInheritedValue;return`${t.listToolsLabel} ${i} · ${t.listSkillsLabel} ${a}`}function Tn(e,t){let n=e.tools.effectiveDisable.length,r=e.skills.effectiveAllowlist?.length??0,i=n>0?Sn(t.listToolsDisabledCount,n):t.listToolsAllEnabled,a=r>0?Sn(t.listSkillsCount,r):t.listInheritedValue;return[`${t.listToolsLabel} ${i}`,`${t.listSkillsLabel} ${a}`]}function En(e){let t=(0,yt.c)(11),{text:n,children:r,className:a}=e,o;t[0]!==r||t[1]!==a||t[2]!==n?(o=(0,Q.jsx)(x,{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`,We),t[4]=s):s=t[4];let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(f,{className:`fill-surface-panel`}),t[5]=c):c=t[5];let l;t[6]===n?l=t[7]:(l=(0,Q.jsx)(R,{children:(0,Q.jsxs)(Oe,{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)(ee,{delayDuration:300,skipDelayDuration:100,children:(0,Q.jsxs)(ne,{children:[o,l]})}),t[8]=o,t[9]=l,t[10]=u):u=t[10],u}function Dn(e){let t=(0,yt.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=xn(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 h;t[16]!==n||t[17]!==c||t[18]!==s||t[19]!==o?(h=e=>{let t=S(e,n),r=e.id,a=re(e,n),l=Cn(e,n),u=wn(e,n),d=Tn(e,n);return(0,Q.jsx)(`li`,{className:`h-full min-h-0`,children:(0,Q.jsxs)(`article`,{className:`flex min-h-[15.5rem] flex-col rounded-xl border border-edge-subtle bg-surface-panel p-4 shadow-surface transition-colors hover:border-edge`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Q.jsxs)(`button`,{type:`button`,disabled:c,onClick:()=>o(e.id),className:i(`flex min-w-0 items-start gap-3 text-left`,`rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`,X.pressCard),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)(k,{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)(`button`,{type:`button`,disabled:c,onClick:()=>o(e.id),className:i(`mt-5 min-h-[6.25rem] text-left`,`rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,Q.jsxs)(`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 space-y-1 text-sm leading-5 text-fg-muted`,children:l.map(kn)})]}),(0,Q.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,title:u,children:d.map(On)})]}),(0,Q.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,Q.jsxs)(J,{type:`button`,variant:`primary`,disabled:c,onClick:()=>s(e.id),className:`w-full rounded-2xl py-2.5`,children:[(0,Q.jsx)(de,{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]=h):h=t[20],u=e.map(h)}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 h;return t[24]!==d||t[25]!==f||t[26]!==m?(h=(0,Q.jsxs)(`div`,{className:d,children:[f,m]}),t[24]=d,t[25]=f,t[26]=m,t[27]=h):h=t[27],h}function On(e){return(0,Q.jsx)(En,{text:e,className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function kn(e){return(0,Q.jsxs)(`p`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,Q.jsx)(`span`,{className:`shrink-0 text-xs font-medium text-fg-subtle`,children:e.label}),(0,Q.jsx)(En,{text:e.title??e.value,className:`min-w-0 truncate`,children:e.value})]},e.label)}function An(e){let t=(0,yt.c)(130),{open:n,onOpenChange:r,a,chat:o,busy:s,modalError:c,profileLanguageLabel:l,createDisplayName:u,setCreateDisplayName:f,createAgentId:p,setCreateAgentId:m,createDescription:h,setCreateDescription:g,createWorkspace:_,setCreateWorkspace:v,createModel:y,setCreateModel:b,onCreate:x,onSuggestWorkspace:C,agents:w,duplicateSourceId:T,onSelectDuplicateSource:E}=e,D;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Q.jsx)(ge,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim`,ye)}),t[0]=D):D=t[0];let O;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(O=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`,Te,`overflow-y-auto rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`),t[1]=O):O=t[1];let k;t[2]===a.addAgent?k=t[3]:(k=(0,Q.jsx)(d,{className:`text-base font-semibold text-fg`,children:a.addAgent}),t[2]=a.addAgent,t[3]=k);let j;t[4]===a.addAgentHint?j=t[5]:(j=(0,Q.jsx)(_e,{className:`mt-0.5 text-xs text-fg-muted`,children:a.addAgentHint}),t[4]=a.addAgentHint,t[5]=j);let M;t[6]!==k||t[7]!==j?(M=(0,Q.jsxs)(`div`,{className:`min-w-0 pr-2`,children:[k,j]}),t[6]=k,t[7]=j,t[8]=M):M=t[8];let N;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(N=i(be,`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)(De,{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)(Pe,{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 R;t[16]!==a||t[17]!==w||t[18]!==T||t[19]!==E?(R=w.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(Dt(),`bg-surface-panel`),value:T??``,onChange:e=>E(e.target.value||null),children:[(0,Q.jsx)(`option`,{value:``,children:a.copyFromExistingAgentNone}),w.map(e=>(0,Q.jsxs)(`option`,{value:e.id,children:[S(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]=w,t[18]=T,t[19]=E,t[20]=R):R=t[20];let ee;t[21]===c?ee=t[22]:(ee=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]=ee);let z;t[23]!==a.newAgentLabel||t[24]!==l?(z=(0,Q.jsxs)(`span`,{className:`text-fg-muted`,children:[a.newAgentLabel,` (`,l,`)`]}),t[23]=a.newAgentLabel,t[24]=l,t[25]=z):z=t[25];let te;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(te=Dt(),t[26]=te):te=t[26];let ne;t[27]===f?ne=t[28]:(ne=e=>f(e.target.value),t[27]=f,t[28]=ne);let re;t[29]===C?re=t[30]:(re=()=>C(),t[29]=C,t[30]=re);let ie;t[31]!==u||t[32]!==ne||t[33]!==re?(ie=(0,Q.jsx)(`input`,{className:te,value:u,onChange:ne,onBlur:re,required:!0,autoComplete:`off`}),t[31]=u,t[32]=ne,t[33]=re,t[34]=ie):ie=t[34];let B;t[35]!==z||t[36]!==ie?(B=(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[z,ie]}),t[35]=z,t[36]=ie,t[37]=B):B=t[37];let oe;t[38]===a.newAgentIdOptional?oe=t[39]:(oe=(0,Q.jsx)(`span`,{className:`text-fg-muted`,children:a.newAgentIdOptional}),t[38]=a.newAgentIdOptional,t[39]=oe);let se;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(se=i(Dt(),`font-mono text-xs`),t[40]=se):se=t[40];let ce;t[41]===m?ce=t[42]:(ce=e=>m(e.target.value),t[41]=m,t[42]=ce);let le;t[43]===C?le=t[44]:(le=()=>C(),t[43]=C,t[44]=le);let de;t[45]!==a.newAgentIdPlaceholder||t[46]!==a.newAgentIdRules||t[47]!==p||t[48]!==ce||t[49]!==le?(de=(0,Q.jsx)(`input`,{className:se,value:p,onChange:ce,onBlur:le,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]=p,t[48]=ce,t[49]=le,t[50]=de):de=t[50];let fe;t[51]===a.newAgentIdRules?fe=t[52]:(fe=(0,Q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:a.newAgentIdRules}),t[51]=a.newAgentIdRules,t[52]=fe);let pe;t[53]!==oe||t[54]!==de||t[55]!==fe?(pe=(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[oe,de,fe]}),t[53]=oe,t[54]=de,t[55]=fe,t[56]=pe):pe=t[56];let me;t[57]!==a.agentDescription||t[58]!==l?(me=(0,Q.jsxs)(`span`,{className:`text-fg-muted`,children:[a.agentDescription,` (`,l,`)`]}),t[57]=a.agentDescription,t[58]=l,t[59]=me):me=t[59];let he;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(he=i(Dt(),`min-h-18 resize-y font-sans text-sm leading-relaxed`),t[60]=he):he=t[60];let H;t[61]===g?H=t[62]:(H=e=>g(e.target.value),t[61]=g,t[62]=H);let U;t[63]!==a.agentDescriptionPlaceholder||t[64]!==h||t[65]!==H?(U=(0,Q.jsx)(`textarea`,{className:he,value:h,onChange:H,placeholder:a.agentDescriptionPlaceholder,maxLength:4e3,rows:3,spellCheck:!0}),t[63]=a.agentDescriptionPlaceholder,t[64]=h,t[65]=H,t[66]=U):U=t[66];let W;t[67]!==me||t[68]!==U?(W=(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[me,U]}),t[67]=me,t[68]=U,t[69]=W):W=t[69];let G;t[70]===a.newWorkspace?G=t[71]:(G=(0,Q.jsx)(`span`,{className:`text-fg-muted`,children:a.newWorkspace}),t[70]=a.newWorkspace,t[71]=G);let xe;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(xe=i(Dt(),`font-mono text-xs`),t[72]=xe):xe=t[72];let Se;t[73]===v?Se=t[74]:(Se=e=>v(e.target.value),t[73]=v,t[74]=Se);let Ce;t[75]!==_||t[76]!==Se?(Ce=(0,Q.jsx)(`input`,{className:xe,value:_,onChange:Se,required:!0,autoComplete:`off`}),t[75]=_,t[76]=Se,t[77]=Ce):Ce=t[77];let K;t[78]!==G||t[79]!==Ce?(K=(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[G,Ce]}),t[78]=G,t[79]=Ce,t[80]=K):K=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 we;t[83]===b?we=t[84]:(we=e=>b(e),t[83]=b,t[84]=we);let Ee;t[85]!==s||t[86]!==o.modelNoMatches||t[87]!==o.modelPlaceholder||t[88]!==o.modelSearchPlaceholder||t[89]!==y||t[90]!==we?(Ee=(0,Q.jsx)(ue,{className:`min-w-0 flex-1`,value:y,disabled:s,placeholder:o.modelPlaceholder,searchPlaceholder:o.modelSearchPlaceholder,noMatches:o.modelNoMatches,onChange:we}),t[85]=s,t[86]=o.modelNoMatches,t[87]=o.modelPlaceholder,t[88]=o.modelSearchPlaceholder,t[89]=y,t[90]=we,t[91]=Ee):Ee=t[91];let Oe;t[92]!==a.modelClear||t[93]!==s||t[94]!==y||t[95]!==b?(Oe=y.trim()?(0,Q.jsx)(J,{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]=Oe):Oe=t[96];let ke;t[97]!==Ee||t[98]!==Oe?(ke=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[Ee,Oe]}),t[97]=Ee,t[98]=Oe,t[99]=ke):ke=t[99];let Ae;t[100]!==q||t[101]!==ke?(Ae=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm`,children:[q,ke]}),t[100]=q,t[101]=ke,t[102]=Ae):Ae=t[102];let je;t[103]!==a.createModalCancel||t[104]!==s?(je=(0,Q.jsx)(Pe,{asChild:!0,children:(0,Q.jsx)(J,{type:`button`,variant:`secondary`,disabled:s,children:a.createModalCancel})}),t[103]=a.createModalCancel,t[104]=s,t[105]=je):je=t[105];let Me;t[106]===Symbol.for(`react.memo_cache_sentinel`)?(Me=(0,Q.jsx)(P,{className:`mr-1 size-4`,"aria-hidden":!0}),t[106]=Me):Me=t[106];let Ne;t[107]!==a.create||t[108]!==s?(Ne=(0,Q.jsxs)(J,{type:`submit`,disabled:s,children:[Me,a.create]}),t[107]=a.create,t[108]=s,t[109]=Ne):Ne=t[109];let Fe;t[110]!==je||t[111]!==Ne?(Fe=(0,Q.jsxs)(`div`,{className:`mt-1 flex justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[je,Ne]}),t[110]=je,t[111]=Ne,t[112]=Fe):Fe=t[112];let Ie;t[113]!==x||t[114]!==ee||t[115]!==B||t[116]!==pe||t[117]!==W||t[118]!==K||t[119]!==Ae||t[120]!==Fe||t[121]!==R?(Ie=(0,Q.jsxs)(`form`,{className:`grid gap-3`,onSubmit:x,children:[R,ee,B,pe,W,K,Ae,Fe]}),t[113]=x,t[114]=ee,t[115]=B,t[116]=pe,t[117]=W,t[118]=K,t[119]=Ae,t[120]=Fe,t[121]=R,t[122]=Ie):Ie=t[122];let Le;t[123]!==Ie||t[124]!==L?(Le=(0,Q.jsxs)(ve,{children:[D,(0,Q.jsx)(A,{className:O,onOpenAutoFocus:jn,children:(0,Q.jsxs)(V,{layer:`modal`,children:[L,Ie]})})]}),t[123]=Ie,t[124]=L,t[125]=Le):Le=t[125];let Re;return t[126]!==r||t[127]!==n||t[128]!==Le?(Re=(0,Q.jsx)(ae,{open:n,onOpenChange:r,children:Le}),t[126]=r,t[127]=n,t[128]=Le,t[129]=Re):Re=t[129],Re}function jn(e){return e.preventDefault()}function Mn(e){let t=(0,yt.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)(Ne,{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)(v,{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)(J,{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 Nn(e){return{...e,soulEditorNonce:0,soulPreviewMode:!1,avatarDialogOpen:!1}}function Pn(e){let{agentId:t,enabled:n,saveRef:r}=e,i=M(async()=>{if(!t)return null;let[e,n]=await Promise.all([Z(t,`IDENTITY.md`).catch(()=>``),Z(t,`SOUL.md`).catch(()=>``)]),r=Wt(e);return{identity:r,soulTemplate:Zt(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?Nn(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?Nn(a):null);return n?e(n):null})},[a]),g=(0,$.useCallback)(e=>{h(t=>({...t,identity:{...t.identity,...e}}))},[h]),_=(0,$.useCallback)(e=>{h(t=>{if(e===`custom`)return{...t,soulTemplate:`custom`};let n=Yt.find(t=>t.id===e);return n?.content?{...t,soulTemplate:e,soulCustomContent:n.content,soulEditorNonce:t.soulEditorNonce+1}:{...t,soulTemplate:e}})},[h]),v=(0,$.useCallback)(e=>{h(t=>({...t,soulCustomContent:e,soulTemplate:`custom`}))},[h]),y=(0,$.useCallback)(e=>{h(t=>({...t,avatarDialogOpen:e}))},[h]),b=(0,$.useCallback)(()=>{h(e=>({...e,soulPreviewMode:!e.soulPreviewMode}))},[h]),x=(0,$.useCallback)(async()=>{let e=m.current;!e||!f||(await Promise.all([w(e,`IDENTITY.md`,Gt(f.identity)),w(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=x,()=>{r.current=null}},[x,r]),{profileMarkdownLoading:o,draft:f,dirty:p,updateIdentity:g,handleSoulTemplateChange:_,handleSoulContentChange:v,setAvatarDialogOpen:y,toggleSoulPreviewMode:b}}var Fn={draft:``,editorNonce:0,loadedKey:``};function In(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 Ln(e){let{panel:t,selectedId:n,hasToken:r,dataAgentsLength:i,saveErrorMessage:a,setError:o}=e,s=M(()=>n?m(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,h]=(0,$.useReducer)(In,Fn),[g,_]=(0,$.useState)(!1),[v,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 T=(0,$.useRef)(n);T.current=n;let D=(0,$.useRef)(d);D.current=d;let O=(0,$.useRef)(null),k=(0,$.useRef)(``),A=(0,$.useRef)(``),j=(0,$.useRef)(``),N=(0,$.useRef)(()=>{}),P=M(()=>d&&n?Z(n,d).catch(()=>``):Promise.resolve(``),[d,n,r],{enabled:!!(d&&n&&r),initial:``,errorData:``}),F=P.loading,I=E(async()=>{let e=T.current,t=D.current;if(!e||!t||`${e}:${t}`!==k.current)return;let n=C.current;if(n!==A.current){_(!0),o(null);try{await w(e,t,n),A.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{_(!1)}}},800);N.current=I.flush,(0,$.useEffect)(()=>()=>{N.current()},[]);let L=(0,$.useRef)(t);L.current!==t&&(L.current===`files`&&N.current(),L.current=t);let R=d&&n?`${n}:${d}`:``;(0,$.useEffect)(()=>{R!==j.current&&(N.current(),j.current=R)},[R]),(0,$.useEffect)(()=>{if(!R){h({type:`clear`});return}F||(k.current=R,A.current=P.data,h({type:`load`,key:R,content:P.data}))},[R,F,P.data]);let ee=(0,$.useRef)({activeFile:d,selectedId:n});return(ee.current.activeFile!==d||ee.current.selectedId!==n)&&(ee.current={activeFile:d,selectedId:n},y(`edit`)),{files:c,setFiles:l,filesLoading:u,activeFile:d,setActiveFile:(0,$.useCallback)(e=>{N.current(),f(e)},[]),fileDraft:x,setFileDraft:(0,$.useCallback)(e=>{h({type:`setDraft`,value:typeof e==`function`?e(C.current):e}),I()},[I]),fileSaving:g,filesViewMode:v,setFilesViewMode:y,profileFileLoading:F,profileEditorNonce:S,overviewSaveProfileMarkdownRef:O,saveProfileMarkdownDebounced:I}}function Rn(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=M(()=>ht(),[t,n],{enabled:m,initial:[],errorData:[]}),g=h.data,_=h.loading,v=(0,$.useMemo)(()=>_||g.length===0?``:g[0]?.name??``,[g,_]),[y,b]=(0,$.useState)(``),x=(0,$.useRef)(v);t===`channels`&&!_&&v&&x.current!==v&&(!y||!g.some(e=>e.name===y))&&(x.current=v,b(v)),x.current=v;let S=y.trim(),C=m&&S.length>0,w=M(()=>dt(S),[t,n,S],{enabled:C,initial:[],errorData:[]}),T=w.data,E=w.loading,D=w.setData,[O,k]=(0,$.useState)(null),[A,j]=(0,$.useState)(``),N=(0,$.useRef)(S);N.current!==S&&(N.current=S,k(null));let P=(0,$.useMemo)(()=>a?p.filter(e=>e.agentId.toLowerCase()===a.id.toLowerCase()):[],[p,a?.id]),F=(0,$.useCallback)(()=>{let e=y.trim();e&&dt(e).then(e=>{D(e),k(t=>t!=null&&t<e.length?t:null)}).catch(()=>{D([]),k(null)})},[y,D]),I=!_&&g.length===0,L=t===`channels`&&n&&i,R=(0,$.useCallback)(async e=>{s(!0),c(null);try{let t=p.filter(t=>t!==e);await he(t),l.current=!0,d(t)}catch(e){c(e instanceof Error?e.message:o)}finally{s(!1)}},[p,o,s,c]);return{agentBindings:P,allBindings:p,bindChannelStatuses:g,bindChannelsLoading:_,bindSessionChats:T,bindSessionsLoading:E,bindingsLoading:L,newBindChannel:y,setNewBindChannel:b,newBindSessionIdx:O,setNewBindSessionIdx:k,newBindCustomPeer:A,setNewBindCustomPeer:j,onAddBinding:(0,$.useCallback)(async e=>{if(e.preventDefault(),!a||!y.trim())return;let t=At(y,A,O,T),n=[...p,{agentId:a.id,priority:100,enabled:!0,match:t}];s(!0),c(null);try{await he(n),l.current=!0,d(n),k(null),j(``)}catch(e){c(e instanceof Error?e.message:o)}finally{s(!1)}},[p,T,y,A,O,o,a,s,c]),onRemoveBinding:R,refreshBindSessions:F,useManualChannel:I}}function zn(e){let{panel:t,hasToken:n,data:r,selected:i,saveErrorMessage:a,setBusy:o,setError:s}=e,{data:c,loading:l}=M(()=>ft(),[t,n],{enabled:t===`cron`&&n,initial:[],errorData:[]}),[u,d]=(0,$.useState)(null),f=u??c,p=(0,$.useMemo)(()=>!r||!i?[]:f.filter(e=>!vt(e)&&Ot(e,i.id,r.defaultId)),[f,r,i]);async function m(e,t){o(!0),s(null);try{await pt(e.id,{agentId:t}),d(await ft())}catch(e){s(e instanceof Error?e.message:a)}finally{o(!1)}}return{agentCronJobs:p,cronJobs:f,cronLoading:l,onSetCronJobAgent:m}}function Bn(e){return new Set(e.tools.entryDisable)}function Vn(e){return e.skills.entry===void 0?{inherit:!0,pick:new Set(e.skills.effectiveAllowlist??[])}:{inherit:!1,pick:new Set(e.skills.entry??[])}}function Hn(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(Bn(n)),n&&t===`skills`){let e=Vn(n);u(e.inherit),c(e.pick)}n&&t===`models`&&f(tt(n.typedModels.entry))}return{toolEntryDisable:a,setToolEntryDisable:o,skillsPick:s,setSkillsPick:c,skillsInherit:l,setSkillsInherit:u,modelRows:d,setModelRows:f}}function Un(){let e=o(e=>e.language),t=a(e),n=t.agentsSettings,[r,i]=(0,$.useState)(!1),[s,u]=(0,$.useState)(null),[d,f]=(0,$.useState)(!1),[p,m]=(0,$.useState)(``),h=t.cron,g=t.chat,v=!!c(e=>e.token),[b,x]=_(),w=le(),{agentId:T}=y(),E=Ee(e=>e.setPageHeader),D=Ee(e=>e.clearPageHeader),{data:k,error:A,isLoading:j,mutate:M}=l(v?`settings-gateway-agents`:null,me,{revalidateOnFocus:!1}),{data:P}=xe(v),F=(0,$.useMemo)(()=>fe(P?.payload?.config??{}),[P]),I=(0,$.useMemo)(()=>$e(P?.payload?.config??{}),[P]),L=k??null,R=!!(v&&j),[ee,z]=(0,$.useState)(null),te=A instanceof Error?A.message:A?n.loadError:null,ne=ee??te,[re,ie]=(0,$.useState)(null),[ae,B]=(0,$.useState)(`overview`),[se,ce]=(0,$.useState)(``),[ue,de]=(0,$.useState)(``),[pe,V]=(0,$.useState)(``),[he,H]=(0,$.useState)(``),[ge,U]=(0,$.useState)(``),[_e,W]=(0,$.useState)(null),[ve,ye]=(0,$.useState)(!1),G=(0,$.useRef)(``),[be,Se]=(0,$.useState)(null),[Ce,K]=(0,$.useState)(!1),[q,we]=(0,$.useState)(``),[Te,De]=(0,$.useState)(``),[Oe,J]=(0,$.useState)(``),[Ae,je]=(0,$.useState)(``),[Me,Ne]=(0,$.useState)(``),Pe=(0,$.useRef)(null),Fe=(0,$.useRef)(null),[Ie,Le]=(0,$.useState)(!1),[Be,Ve]=(0,$.useState)(!1),He=(0,$.useRef)({data:null,routeAgentId:void 0});L&&(L!==He.current.data||T!==He.current.routeAgentId)&&(He.current={data:L,routeAgentId:T},T&&L.agents.some(e=>e.id===T)?ie(T):ie(e=>e&&L.agents.some(t=>t.id===e)?e:L.defaultId)),(0,$.useEffect)(()=>{!L||!T||L.agents.some(e=>e.id===T)||w(ze,{replace:!0})},[L,T,w]),(0,$.useEffect)(()=>{T&&B(`overview`)},[T]),(0,$.useEffect)(()=>{b.get(`panel`)===`defaults`&&w(`/settings/agent-defaults`,{replace:!0,state:{[C]:T?ke(T):ze}})},[b,T,w]),(0,$.useEffect)(()=>{if(b.get(`focus`)!==`avatar`||!T||(B(`overview`),R||!L?.agents.some(e=>e.id===T)))return;let e=window.setTimeout(()=>{document.getElementById(`agent-avatar-settings`)?.scrollIntoView({behavior:`smooth`,block:`center`}),x(e=>{let t=new URLSearchParams(e);return t.delete(`focus`),t},{replace:!0})},220);return()=>window.clearTimeout(e)},[b,T,R,L,x]);let Y=(0,$.useMemo)(()=>L?.agents.find(e=>e.id===re)??null,[L,re]),Ue=(0,$.useRef)(null),We=Y?Y.id:null;Y&&Ue.current!==We?(Ue.current=We,De(Y.workspace),J(Y.model?.primary??``),je(S(Y,a(e).agentsSettings)),Ne(Y.description??``)):!Y&&Ue.current!==null&&(Ue.current=null,De(``),J(``),je(``),Ne(``));let Ge=Pn({agentId:Y?.id??null,enabled:ae===`overview`&&!!Y,saveRef:Fe}),X=Ln({panel:ae,selectedId:re,hasToken:v,dataAgentsLength:L?.agents.length,saveErrorMessage:n.saveError,setError:z}),Ke=Hn({panel:ae,selected:Y}),Z=Rn({panel:ae,hasToken:v,bindingsFromConfig:F,gatewayCfgLoading:P===void 0,selected:Y,saveErrorMessage:n.saveError,setBusy:K,setError:z}),qe=zn({panel:ae,hasToken:v,data:L,selected:Y,saveErrorMessage:n.saveError,setBusy:K,setError:z}),Je=at({panel:ae,hasToken:v}),Ye=(0,$.useCallback)(()=>{let e=lt(ue.trim()||se);H(t=>t===``||t===G.current?(G.current=e,e):t)},[ue,se]),Xe=(0,$.useCallback)(()=>{G.current=``,ce(``),de(``),V(``),H(``),U(``),W(null),Se(null),ye(!0)},[]),et=(0,$.useCallback)(e=>{let t=new Set(L?.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,L]),tt=(0,$.useCallback)(e=>{if(Se(e),!e)return;let t=L?.agents.find(t=>t.id===e);if(!t)return;let r=t.name?.trim()??t.id,i=n.duplicateName.replace(`{{name}}`,r),a=et(t.id),o=t.description??``;G.current=``,ce(i),de(a),V(o),H(t.workspace),U(t.model?.primary??``),W(null)},[n.duplicateName,L,et]),nt=(0,$.useCallback)(e=>{tt(e),ye(!0)},[tt]),rt=(0,$.useMemo)(()=>(0,Q.jsx)(Mn,{a:n,busy:Ce,listSearchQuery:q,onListSearchQueryChange:we,onAddAgent:()=>Xe()}),[n,Ce,q,Xe]);(0,$.useLayoutEffect)(()=>v?(E({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:rt}),()=>D()):(D(),()=>D()),[n.title,rt,D,v,E]);async function it(t){t.preventDefault();let r=se.trim();if(!r)return;let i=ot(ue,r);if(i.ok===!1){W(i.error);return}let a=he.trim()||lt(ue.trim()||r);if(a){K(!0),W(null);try{let t=[`# IDENTITY.md - Who Am I?`,``,`- **Name:** ${r}`,`- **Description:** ${pe.trim()}`,`- **Language:** ${e}`,`- **Creature:** assistant`,`- **Emoji:**`,`- **Avatar:**`,``].join(`
71
- `),{createdAgentId:n,...i}=await O({workspace:a,...ue.trim()?{id:ue.trim()}:{},...ge.trim()?{models:{chat:{primary:ge.trim()}}}:{},profileFiles:{"IDENTITY.md":t},...be?{cloneFrom:be}:{}});M(i,{revalidate:!1}),ce(``),de(``),V(``),H(``),U(``),W(null),ye(!1),ie(n),w(ke(n))}catch(e){W(e instanceof Error?e.message:n.saveError)}finally{K(!1)}}}async function st(){if(Y){K(!0),z(null);try{M(await N(Y.id,{workspace:Te.trim()||void 0,models:{chat:Oe.trim()?{primary:Oe.trim()}:null}}),{revalidate:!1})}catch(e){z(e instanceof Error?e.message:n.saveError)}finally{K(!1)}}}async function ct(e){K(!0),z(null);try{M(await N(e.id,{setDefault:!0}),{revalidate:!1}),ie(e.id)}catch(e){z(e instanceof Error?e.message:n.saveError)}finally{K(!1)}}async function ut(e,t){K(!0),z(null);try{let n=await oe(e.id,t);M(n,{revalidate:!1}),ie(n.defaultId),B(`overview`),T===e.id&&w(ze,{replace:!0}),i(!1),u(null),m(``)}catch(e){z(e instanceof Error?e.message:n.saveError)}finally{K(!1)}}function dt(e,t){e.id!==`main`&&(u(e),f(t),m(``),i(!0))}async function ft(){if(Y){K(!0),z(null);try{let e=Array.from(Ke.toolEntryDisable).toSorted((e,t)=>e.localeCompare(t));M(await N(Y.id,{tools:{disable:e}}),{revalidate:!1})}catch(e){z(e instanceof Error?e.message:n.saveError)}finally{K(!1)}}}async function pt(){if(Y){K(!0),z(null);try{M(await N(Y.id,{tools:{disable:null}}),{revalidate:!1}),Ke.setToolEntryDisable(new Set)}catch(e){z(e instanceof Error?e.message:n.saveError)}finally{K(!1)}}}async function mt(){if(!Y)return;let e=Qe(Ke.modelRows,{invalidId:n.typedModelsInvalidId,duplicateId:n.typedModelsDuplicateId,invalidModel:n.typedModelsInvalidModel});if(e){z(e);return}K(!0),z(null);try{M(await N(Y.id,{models:{roles:Ze(Ke.modelRows)?.roles??{}}}),{revalidate:!1})}catch(e){z(e instanceof Error?e.message:n.saveError)}finally{K(!1)}}async function ht(){if(Y){K(!0),z(null);try{M(await N(Y.id,{models:{roles:null}}),{revalidate:!1}),Ke.setModelRows([])}catch(e){z(e instanceof Error?e.message:n.saveError)}finally{K(!1)}}}async function gt(){if(Y){K(!0),z(null);try{M(await N(Y.id,{skills:Ke.skillsInherit?null:[...Ke.skillsPick].toSorted((e,t)=>e.localeCompare(t))}),{revalidate:!1})}catch(e){z(e instanceof Error?e.message:n.saveError)}finally{K(!1)}}}let _t=ae===`channels`||ae===`cron`,vt=(()=>{if(!Y||ae!==`overview`)return!1;let e=Y.workspace,t=Y.model?.primary??``;return Te.trim()!==e||Oe.trim()!==t})(),yt=(()=>{if(_t||!Y)return!1;switch(ae){case`overview`:return vt||Ge.dirty;case`profile`:return Ie;default:return!0}})(),bt=_t||!yt;function xt(){Ve(!0),setTimeout(()=>Ve(!1),2e3)}async function St(){switch(ae){case`overview`:await Promise.all([st(),Fe.current?.()??Promise.resolve()]),xt();break;case`profile`:await Pe.current?.(),xt();break;case`tools`:await ft(),xt();break;case`models`:await mt(),xt();break;case`skills`:await gt(),xt();break;case`files`:X.saveProfileMarkdownDebounced.flush(),xt();break;default:break}}function Ct(e){e||w(ze)}let wt=Y?Ae.trim()||S(Y,n):T??``,Tt=Y?.id??T??``,Et=(0,$.useCallback)(async()=>{if(Y){await St();try{globalThis.localStorage?.setItem(Re,Y.id)}catch{}w(`/chat/new`,{state:{agentId:Y.id,fromAgentEditor:!0}})}},[Y,St,w]),Dt={a:n,chat:g,cCron:h,selected:Y,panel:ae,data:L,busy:Ce,editName:Ae,setEditName:je,editDescription:Me,setEditDescription:Ne,editWorkspace:Te,setEditWorkspace:De,editModel:Oe,setEditModel:J,defaultModel:I.model,defaultWorkspace:I.workspace,onSetDefault:()=>{Y&&ct(Y)},onSaveAgentEdits:()=>void st(),onDelete:e=>{Y&&dt(Y,e)},onTryInChat:()=>void Et(),overviewSaveProfileMarkdownRef:Fe,profileSaveRef:Pe,overviewProfile:Ge,setProfileDirty:Le,filesLoading:X.filesLoading,files:X.files,activeFile:X.activeFile,setActiveFile:X.setActiveFile,filesViewMode:X.filesViewMode,setFilesViewMode:X.setFilesViewMode,fileDraft:X.fileDraft,setFileDraft:X.setFileDraft,fileSaving:X.fileSaving,profileFileLoading:X.profileFileLoading,profileEditorNonce:X.profileEditorNonce,toolEntryDisable:Ke.toolEntryDisable,setToolEntryDisable:Ke.setToolEntryDisable,onSaveTools:()=>void ft(),onClearToolsEntry:()=>void pt(),modelRows:Ke.modelRows,setModelRows:Ke.setModelRows,onSaveModels:()=>void mt(),onClearModelsEntry:()=>void ht(),skillsCatalogLoading:Je.skillsCatalogLoading,catalogForPick:Je.catalogForPick,skillsInherit:Ke.skillsInherit,setSkillsInherit:Ke.setSkillsInherit,skillsPick:Ke.skillsPick,setSkillsPick:Ke.setSkillsPick,onSaveSkills:()=>void gt(),bindingsLoading:Z.bindingsLoading,agentBindings:Z.agentBindings,bindChannelStatuses:Z.bindChannelStatuses,bindChannelsLoading:Z.bindChannelsLoading,useManualChannel:Z.useManualChannel,newBindChannel:Z.newBindChannel,setNewBindChannel:Z.setNewBindChannel,bindSessionChats:Z.bindSessionChats,bindSessionsLoading:Z.bindSessionsLoading,newBindSessionIdx:Z.newBindSessionIdx,setNewBindSessionIdx:Z.setNewBindSessionIdx,newBindCustomPeer:Z.newBindCustomPeer,setNewBindCustomPeer:Z.setNewBindCustomPeer,refreshBindSessions:Z.refreshBindSessions,onRemoveBinding:e=>void Z.onRemoveBinding(e),onAddBinding:Z.onAddBinding,cronLoading:qe.cronLoading,agentCronJobs:qe.agentCronJobs,onSetCronJobAgent:(e,t)=>void qe.onSetCronJobAgent(e,t)};return{hasToken:v,a:n,chat:g,language:e,data:L,loading:R,displayError:ne,navigate:w,routeAgentId:T,busy:Ce,listSearchQuery:q,openAddAgentModal:Xe,openDuplicateAgentModal:nt,duplicateSourceId:be,onSelectDuplicateSource:tt,panel:ae,setPanel:B,modalTitle:wt,modalSubtitle:Tt,footerSaveDisabled:bt,savedFlash:Be,handleModalFooterSave:St,onAgentModalOpenChange:Ct,addAgentModalOpen:ve,setAddAgentModalOpen:ye,createWorkspaceSuggestedRef:G,createModalError:_e,setCreateModalError:W,createDisplayName:se,setCreateDisplayName:ce,createAgentId:ue,setCreateAgentId:de,createDescription:pe,setCreateDescription:V,createWorkspace:he,setCreateWorkspace:H,createModel:ge,setCreateModel:U,onCreate:it,currentLanguageLabel:e===`zh`?`中文`:`English`,applyCreateWorkspaceSuggestion:Ye,deleteDialogOpen:r,setDeleteDialogOpen:i,deletePurge:d,deleteTarget:s,setDeleteTarget:u,deleteConfirmText:p,setDeleteConfirmText:m,performDelete:ut,editorPanelProps:Dt}}function Wn(){let e=Un();return e.hasToken?(0,Q.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 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.jsx)(Dn,{a:e.a,agents:e.data.agents,searchQuery:e.listSearchQuery,onOpenAgent:t=>e.navigate(ke(t)),onChatWithAgent:t=>{let n=t.trim().toLowerCase();try{globalThis.localStorage?.setItem(Re,n)}catch{}e.navigate(`/chat/new`,{state:{agentId:n}})},busy:e.busy}):null,e.routeAgentId&&e.hasToken?(0,Q.jsx)(Tt,{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)(bn,{...e.editorPanelProps})}):null,(0,Q.jsx)(An,{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)(bt,{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)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,Q.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:e.a.title}),(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.a.needToken})]})}export{nt as AgentBrowserSettingsPage,rt as AgentDefaultsTabbedPage,Wn as AgentsSettingsPanel};
70
+ Sharp, direct, slightly nerdy. The kind of engineer you'd want on your team — competent, opinionated, and occasionally funny.`},{id:`custom`,labelEn:`Custom`,labelZh:`自定义`,emoji:`✍️`,content:``}];function Xt(e){let t=e.trimStart();if(!t.startsWith(`---`))return e;let n=t.indexOf(`---`,3);return n===-1?e:t.slice(n+3).trimStart()}function Zt(e){let t=Xt(e).trim();if(!t)return`professional`;for(let e of Yt)if(e.id!==`custom`&&(t===e.content.trim()||$t(t,e.id)>=2))return e.id;return`custom`}var Qt={professional:/precise and efficient|Value the user's time|actionable answers/g,casual:/good friend|corporate drone|a little playful/g,geeky:/Precision over politeness|Go deep|slightly nerdy/g};function $t(e,t){let n=Qt[t];if(!n)return 0;let r=new RegExp(n.source,`g`),i=new Set,a;for(;(a=r.exec(e))!==null;)if(i.add(a[0]),i.size>=2)return i.size;return i.size}var en=[{value:``,labelEn:`Not set`,labelZh:`未设置`},{value:`Asia/Shanghai`,labelEn:`Asia/Shanghai (CST, UTC+8)`,labelZh:`亚洲/上海 (北京时间, UTC+8)`},{value:`Asia/Tokyo`,labelEn:`Asia/Tokyo (JST, UTC+9)`,labelZh:`亚洲/东京 (日本时间, UTC+9)`},{value:`Asia/Seoul`,labelEn:`Asia/Seoul (KST, UTC+9)`,labelZh:`亚洲/首尔 (韩国时间, UTC+9)`},{value:`Asia/Singapore`,labelEn:`Asia/Singapore (SGT, UTC+8)`,labelZh:`亚洲/新加坡 (UTC+8)`},{value:`Asia/Hong_Kong`,labelEn:`Asia/Hong Kong (HKT, UTC+8)`,labelZh:`亚洲/香港 (UTC+8)`},{value:`Asia/Taipei`,labelEn:`Asia/Taipei (CST, UTC+8)`,labelZh:`亚洲/台北 (UTC+8)`},{value:`Asia/Kolkata`,labelEn:`Asia/Kolkata (IST, UTC+5:30)`,labelZh:`亚洲/加尔各答 (印度时间, UTC+5:30)`},{value:`Asia/Dubai`,labelEn:`Asia/Dubai (GST, UTC+4)`,labelZh:`亚洲/迪拜 (UTC+4)`},{value:`Europe/London`,labelEn:`Europe/London (GMT/BST)`,labelZh:`欧洲/伦敦 (格林尼治时间)`},{value:`Europe/Paris`,labelEn:`Europe/Paris (CET, UTC+1)`,labelZh:`欧洲/巴黎 (中欧时间, UTC+1)`},{value:`Europe/Berlin`,labelEn:`Europe/Berlin (CET, UTC+1)`,labelZh:`欧洲/柏林 (中欧时间, UTC+1)`},{value:`Europe/Moscow`,labelEn:`Europe/Moscow (MSK, UTC+3)`,labelZh:`欧洲/莫斯科 (UTC+3)`},{value:`America/New_York`,labelEn:`America/New York (EST, UTC-5)`,labelZh:`美国/纽约 (东部时间, UTC-5)`},{value:`America/Chicago`,labelEn:`America/Chicago (CST, UTC-6)`,labelZh:`美国/芝加哥 (中部时间, UTC-6)`},{value:`America/Denver`,labelEn:`America/Denver (MST, UTC-7)`,labelZh:`美国/丹佛 (山地时间, UTC-7)`},{value:`America/Los_Angeles`,labelEn:`America/Los Angeles (PST, UTC-8)`,labelZh:`美国/洛杉矶 (太平洋时间, UTC-8)`},{value:`America/Sao_Paulo`,labelEn:`America/São Paulo (BRT, UTC-3)`,labelZh:`美洲/圣保罗 (巴西时间, UTC-3)`},{value:`Australia/Sydney`,labelEn:`Australia/Sydney (AEST, UTC+10)`,labelZh:`澳大利亚/悉尼 (UTC+10)`},{value:`Pacific/Auckland`,labelEn:`Pacific/Auckland (NZST, UTC+12)`,labelZh:`太平洋/奥克兰 (新西兰时间, UTC+12)`}];function tn(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return``}}var nn=[{value:`先生`,labelEn:`Mr.`,labelZh:`先生`},{value:`女士`,labelEn:`Ms.`,labelZh:`女士`},{value:`同学`,labelEn:`Colleague`,labelZh:`同学`},{value:`老师`,labelEn:`Teacher`,labelZh:`老师`},{value:`老板`,labelEn:`Boss`,labelZh:`老板`},{value:`朋友`,labelEn:`Friend`,labelZh:`朋友`}],rn=[{value:`AI assistant`,labelEn:`AI Assistant`,labelZh:`AI 助手`},{value:`robot`,labelEn:`Robot`,labelZh:`机器人`},{value:`familiar`,labelEn:`Familiar`,labelZh:`精灵`},{value:`ghost in the machine`,labelEn:`Ghost in the machine`,labelZh:`机器幽灵`},{value:`digital companion`,labelEn:`Digital Companion`,labelZh:`数字伙伴`}];function an(e){let t=(0,yt.c)(216),{a:n,chat:r,selected:a,busy:c,editName:l,setEditName:u,editDescription:f,setEditDescription:p,editWorkspace:m,setEditWorkspace:h,editModel:g,setEditModel:_,onSetDefault:v,onSaveAgentEdits:y,onDelete:x,hideInlineSave:S,profileMarkdownLoading:w,profileDraft:E,updateIdentity:O,handleSoulTemplateChange:j,handleSoulContentChange:M,setAvatarDialogOpen:N,toggleSoulPreviewMode:P,defaultModel:F,defaultWorkspace:L,onTryInChat:R}=e,ee=F===void 0?``:F,z=L===void 0?``:L,ne=o(cn),re=s(sn),ie;t[0]===E?.identity?ie=t[1]:(ie=E?.identity??{name:``,description:``,language:``,creature:``,emoji:``,avatar:``},t[0]=E?.identity,t[1]=ie);let B=ie,oe=E?.soulTemplate??`professional`,se=E?.soulCustomContent??``,ce=E?.soulEditorNonce??0,le=E?.soulPreviewMode??!1,fe=E?.avatarDialogOpen??!1,me;t[2]===ne?me=t[3]:(me=(e,t)=>ne===`zh`?t:e,t[2]=ne,t[3]=me);let V=me,he;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(he=Dt(),t[4]=he):he=t[4];let H=he;if(!a){let e;return t[5]===n.selectAgentHint?e=t[6]:(e=(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.selectAgentHint}),t[5]=n.selectAgentHint,t[6]=e),e}let U;t[7]===a.id?U=t[8]:(U=ke(a.id),t[7]=a.id,t[8]=U);let W;t[9]===U?W=t[10]:(W={[C]:U},t[9]=U,t[10]=W);let G;t[11]!==n||t[12]!==ee||t[13]!==z||t[14]!==g||t[15]!==m||t[16]!==W?(G=(0,Q.jsx)(Bt,{a:n,defaultModel:ee,defaultWorkspace:z,agentModel:g,agentWorkspace:m,settingsState:W}),t[11]=n,t[12]=ee,t[13]=z,t[14]=g,t[15]=m,t[16]=W,t[17]=G):G=t[17];let xe;t[18]!==B.avatar||t[19]!==a.id?(xe=(0,Q.jsx)(k,{agentId:a.id,avatar:B.avatar,size:36,className:`size-9 rounded-lg`}),t[18]=B.avatar,t[19]=a.id,t[20]=xe):xe=t[20];let Se;t[21]===N?Se=t[22]:(Se=()=>N(!0),t[21]=N,t[22]=Se);let Ce;t[23]!==n.avatarOpenSettingsAria||t[24]!==Se?(Ce={onClick:Se,ariaLabel:n.avatarOpenSettingsAria,id:`agent-avatar-settings`},t[23]=n.avatarOpenSettingsAria,t[24]=Se,t[25]=Ce):Ce=t[25];let K;t[26]!==n.setDefault||t[27]!==c||t[28]!==v||t[29]!==a.isDefault?(K=a.isDefault?null:(0,Q.jsx)(J,{type:`button`,variant:`secondary`,className:`text-xs`,disabled:c,onClick:()=>void v(),children:n.setDefault}),t[26]=n.setDefault,t[27]=c,t[28]=v,t[29]=a.isDefault,t[30]=K):K=t[30];let q;t[31]!==n.personaSectionIdentity||t[32]!==n.personaSectionIdentityHint||t[33]!==Ce||t[34]!==K||t[35]!==xe?(q=(0,Q.jsx)(Je,{icon:Ie,title:n.personaSectionIdentity,subtitle:n.personaSectionIdentityHint,iconLeading:xe,iconInteractive:Ce,trailing:K}),t[31]=n.personaSectionIdentity,t[32]=n.personaSectionIdentityHint,t[33]=Ce,t[34]=K,t[35]=xe,t[36]=q):q=t[36];let we;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(we=(0,Q.jsx)(ge,{className:i(`fixed inset-0 bg-scrim backdrop-blur-[2px]`,ye)}),t[37]=we):we=t[37];let Ee;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=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`,Te),t[38]=Ee):Ee=t[38];let Oe;t[39]===n.avatarPickerTitle?Oe=t[40]:(Oe=(0,Q.jsx)(d,{className:`text-base font-semibold text-fg`,children:n.avatarPickerTitle}),t[39]=n.avatarPickerTitle,t[40]=Oe);let Ae;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=i(be,`shrink-0 p-1.5 hover:bg-surface-base`),t[41]=Ae):Ae=t[41];let je;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(je=(0,Q.jsx)(De,{className:`size-4`,"aria-hidden":!0}),t[42]=je):je=t[42];let Me;t[43]===n.closeDialogAria?Me=t[44]:(Me=(0,Q.jsx)(Pe,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:Ae,"aria-label":n.closeDialogAria,children:je})}),t[43]=n.closeDialogAria,t[44]=Me);let Ne;t[45]!==Oe||t[46]!==Me?(Ne=(0,Q.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[Oe,Me]}),t[45]=Oe,t[46]=Me,t[47]=Ne):Ne=t[47];let Fe;t[48]===n.avatarRowHint?Fe=t[49]:(Fe=(0,Q.jsx)(_e,{className:`sr-only`,children:n.avatarRowHint}),t[48]=n.avatarRowHint,t[49]=Fe);let Le;t[50]===O?Le=t[51]:(Le=e=>O({avatar:e}),t[50]=O,t[51]=Le);let Re;t[52]!==n||t[53]!==B.avatar||t[54]!==a.id||t[55]!==Le?(Re=(0,Q.jsx)(Ht,{agentId:a.id,value:B.avatar,onChange:Le,a:n}),t[52]=n,t[53]=B.avatar,t[54]=a.id,t[55]=Le,t[56]=Re):Re=t[56];let ze;t[57]!==Ne||t[58]!==Fe||t[59]!==Re?(ze=(0,Q.jsxs)(ve,{children:[we,(0,Q.jsxs)(A,{className:Ee,onOpenAutoFocus:on,children:[Ne,Fe,Re]})]}),t[57]=Ne,t[58]=Fe,t[59]=Re,t[60]=ze):ze=t[60];let Be;t[61]!==fe||t[62]!==N||t[63]!==ze?(Be=(0,Q.jsx)(ae,{open:fe,onOpenChange:N,children:ze}),t[61]=fe,t[62]=N,t[63]=ze,t[64]=Be):Be=t[64];let Ve;t[65]===n.displayName?Ve=t[66]:(Ve=(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:n.displayName}),t[65]=n.displayName,t[66]=Ve);let He;t[67]!==u||t[68]!==O?(He=e=>{u(e.target.value),O({name:e.target.value})},t[67]=u,t[68]=O,t[69]=He):He=t[69];let Y;t[70]!==n.personaNamePlaceholder||t[71]!==l||t[72]!==He?(Y=(0,Q.jsx)(`input`,{className:H,value:l,onChange:He,placeholder:n.personaNamePlaceholder,autoComplete:`off`}),t[70]=n.personaNamePlaceholder,t[71]=l,t[72]=He,t[73]=Y):Y=t[73];let Ue;t[74]!==Ve||t[75]!==Y?(Ue=(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[Ve,Y]}),t[74]=Ve,t[75]=Y,t[76]=Ue):Ue=t[76];let We;t[77]===n.personaEmoji?We=t[78]:(We=(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:n.personaEmoji}),t[77]=n.personaEmoji,t[78]=We);let Ge;t[79]===O?Ge=t[80]:(Ge=e=>O({emoji:e.target.value}),t[79]=O,t[80]=Ge);let Z;t[81]!==n.personaEmojiPlaceholder||t[82]!==B.emoji||t[83]!==Ge?(Z=(0,Q.jsx)(`input`,{className:H,value:B.emoji,onChange:Ge,placeholder:n.personaEmojiPlaceholder,autoComplete:`off`}),t[81]=n.personaEmojiPlaceholder,t[82]=B.emoji,t[83]=Ge,t[84]=Z):Z=t[84];let Xe;t[85]!==We||t[86]!==Z?(Xe=(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[We,Z]}),t[85]=We,t[86]=Z,t[87]=Xe):Xe=t[87];let Ze;t[88]===n.agentDescription?Ze=t[89]:(Ze=(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:n.agentDescription}),t[88]=n.agentDescription,t[89]=Ze);let Qe;t[90]===Symbol.for(`react.memo_cache_sentinel`)?(Qe=i(H,`min-h-16 resize-y text-sm leading-relaxed`),t[90]=Qe):Qe=t[90];let $e;t[91]!==p||t[92]!==O?($e=e=>{p(e.target.value),O({description:e.target.value})},t[91]=p,t[92]=O,t[93]=$e):$e=t[93];let et;t[94]!==n.agentDescriptionPlaceholder||t[95]!==f||t[96]!==$e?(et=(0,Q.jsx)(`textarea`,{className:Qe,value:f,onChange:$e,placeholder:n.agentDescriptionPlaceholder,maxLength:4e3,rows:3,spellCheck:!0}),t[94]=n.agentDescriptionPlaceholder,t[95]=f,t[96]=$e,t[97]=et):et=t[97];let tt;t[98]!==Ze||t[99]!==et?(tt=(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[Ze,et]}),t[98]=Ze,t[99]=et,t[100]=tt):tt=t[100];let nt;t[101]===n.personaCreature?nt=t[102]:(nt=(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:n.personaCreature}),t[101]=n.personaCreature,t[102]=nt);let rt;t[103]===B.creature?rt=t[104]:(rt=rn.some(e=>e.value===B.creature)?B.creature:`__custom__`,t[103]=B.creature,t[104]=rt);let it;t[105]===O?it=t[106]:(it=e=>{if(e.target.value===`__custom__`){O({creature:``});return}O({creature:e.target.value})},t[105]=O,t[106]=it);let at;t[107]===V?at=t[108]:(at=rn.map(e=>(0,Q.jsx)(`option`,{value:e.value,children:V(e.labelEn,e.labelZh)},e.value)),t[107]=V,t[108]=at);let ot;t[109]===V?ot=t[110]:(ot=V(`Custom…`,`自定义…`),t[109]=V,t[110]=ot);let st;t[111]===ot?st=t[112]:(st=(0,Q.jsx)(`option`,{value:`__custom__`,children:ot}),t[111]=ot,t[112]=st);let lt;t[113]!==rt||t[114]!==it||t[115]!==at||t[116]!==st?(lt=(0,Q.jsxs)(`select`,{className:H,value:rt,onChange:it,children:[at,st]}),t[113]=rt,t[114]=it,t[115]=at,t[116]=st,t[117]=lt):lt=t[117];let ut;t[118]!==n.personaCreaturePlaceholder||t[119]!==B.creature||t[120]!==O?(ut=rn.some(e=>e.value===B.creature)?null:(0,Q.jsx)(`input`,{className:i(H,`mt-1 text-xs`),value:B.creature,onChange:e=>O({creature:e.target.value}),placeholder:n.personaCreaturePlaceholder,autoComplete:`off`}),t[118]=n.personaCreaturePlaceholder,t[119]=B.creature,t[120]=O,t[121]=ut):ut=t[121];let dt;t[122]!==nt||t[123]!==lt||t[124]!==ut?(dt=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[nt,lt,ut]}),t[122]=nt,t[123]=lt,t[124]=ut,t[125]=dt):dt=t[125];let ft;t[126]!==Ue||t[127]!==Xe||t[128]!==tt||t[129]!==dt?(ft=(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[Ue,Xe,tt,dt]}),t[126]=Ue,t[127]=Xe,t[128]=tt,t[129]=dt,t[130]=ft):ft=t[130];let pt;t[131]!==q||t[132]!==Be||t[133]!==ft?(pt=(0,Q.jsxs)(Ye,{children:[q,Be,ft]}),t[131]=q,t[132]=Be,t[133]=ft,t[134]=pt):pt=t[134];let mt;t[135]!==n.editAgent||t[136]!==n.editAgentHint?(mt=(0,Q.jsx)(Je,{icon:D,title:n.editAgent,subtitle:n.editAgentHint}),t[135]=n.editAgent,t[136]=n.editAgentHint,t[137]=mt):mt=t[137];let ht;t[138]===n.modelPrimary?ht=t[139]:(ht=(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:n.modelPrimary}),t[138]=n.modelPrimary,t[139]=ht);let gt;t[140]===_?gt=t[141]:(gt=e=>_(e),t[140]=_,t[141]=gt);let _t;t[142]!==c||t[143]!==r.modelNoMatches||t[144]!==r.modelPlaceholder||t[145]!==r.modelSearchPlaceholder||t[146]!==g||t[147]!==gt?(_t=(0,Q.jsx)(ue,{className:`min-w-0 flex-1`,value:g,disabled:c,placeholder:r.modelPlaceholder,searchPlaceholder:r.modelSearchPlaceholder,noMatches:r.modelNoMatches,onChange:gt}),t[142]=c,t[143]=r.modelNoMatches,t[144]=r.modelPlaceholder,t[145]=r.modelSearchPlaceholder,t[146]=g,t[147]=gt,t[148]=_t):_t=t[148];let vt;t[149]!==n.modelClear||t[150]!==c||t[151]!==g||t[152]!==_?(vt=g.trim()?(0,Q.jsx)(J,{type:`button`,variant:`secondary`,className:`shrink-0`,disabled:c,onClick:()=>_(``),children:n.modelClear}):null,t[149]=n.modelClear,t[150]=c,t[151]=g,t[152]=_,t[153]=vt):vt=t[153];let bt;t[154]!==_t||t[155]!==vt?(bt=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[_t,vt]}),t[154]=_t,t[155]=vt,t[156]=bt):bt=t[156];let xt;t[157]!==ht||t[158]!==bt?(xt=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[ht,bt]}),t[157]=ht,t[158]=bt,t[159]=xt):xt=t[159];let St;t[160]===n.workspacePath?St=t[161]:(St=(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:n.workspacePath}),t[160]=n.workspacePath,t[161]=St);let Ct=r.workingDirectory,wt=r.workingDirectory.notSet,Tt;t[162]===Symbol.for(`react.memo_cache_sentinel`)?(Tt=i(H,`font-mono text-xs`),t[162]=Tt):Tt=t[162];let Et;t[163]!==c||t[164]!==r.workingDirectory||t[165]!==m||t[166]!==h?(Et=(0,Q.jsx)(ct,{value:m,onChange:h,disabled:c,wd:Ct,placeholder:wt,inputClassName:Tt}),t[163]=c,t[164]=r.workingDirectory,t[165]=m,t[166]=h,t[167]=Et):Et=t[167];let Ot;t[168]!==St||t[169]!==Et?(Ot=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[St,Et]}),t[168]=St,t[169]=Et,t[170]=Ot):Ot=t[170];let kt;t[171]!==xt||t[172]!==Ot?(kt=(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[xt,Ot]}),t[171]=xt,t[172]=Ot,t[173]=kt):kt=t[173];let At;t[174]!==n.save||t[175]!==n.tryInChat||t[176]!==c||t[177]!==S||t[178]!==y||t[179]!==R?(At=S?null:(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(J,{type:`button`,disabled:c,onClick:()=>void y(),children:n.save}),R?(0,Q.jsxs)(J,{type:`button`,variant:`secondary`,disabled:c,onClick:R,children:[(0,Q.jsx)(de,{className:`mr-1.5 size-4`,"aria-hidden":!0}),n.tryInChat]}):null]}),t[174]=n.save,t[175]=n.tryInChat,t[176]=c,t[177]=S,t[178]=y,t[179]=R,t[180]=At):At=t[180];let jt;t[181]!==mt||t[182]!==kt||t[183]!==At?(jt=(0,Q.jsxs)(Ye,{children:[mt,kt,At]}),t[181]=mt,t[182]=kt,t[183]=At,t[184]=jt):jt=t[184];let Mt;t[185]!==n.loading||t[186]!==n.personaSectionSoul||t[187]!==n.personaSectionSoulHint||t[188]!==n.personaSoulCustomEdit||t[189]!==n.personaSoulEdit||t[190]!==n.personaSoulPreview||t[191]!==n.personaSoulTemplate||t[192]!==M||t[193]!==j||t[194]!==re||t[195]!==V||t[196]!==w||t[197]!==se||t[198]!==ce||t[199]!==le||t[200]!==oe||t[201]!==P?(Mt=w?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.loading}):(0,Q.jsxs)(Ye,{children:[(0,Q.jsx)(Je,{icon:b,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:Yt.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`,X.pressCard,oe===e.id?`border-accent bg-accent-soft/40 shadow-sm`:`border-edge hover:border-accent/40 hover:bg-surface-hover`),onClick:()=>j(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:V(e.labelEn,e.labelZh)})]},e.id))})]}),oe===`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(be,`inline-flex size-9 shrink-0 items-center justify-center rounded-md p-0 hover:bg-surface-hover`),title:le?n.personaSoulEdit:n.personaSoulPreview,"aria-label":le?n.personaSoulEdit:n.personaSoulPreview,onClick:P,children:le?(0,Q.jsx)(I,{className:`size-4`,"aria-hidden":!0}):(0,Q.jsx)(te,{className:`size-4`,"aria-hidden":!0})})]}),(0,Q.jsx)(`div`,{className:i(H,`flex min-h-64 flex-col overflow-hidden p-0`),children:le?(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,Q.jsx)(Ke,{content:se})}):(0,Q.jsx)(qe,{initialContent:se,onChange:M,isDark:re,className:`min-h-0 flex-1`},`soul-${ce}`)})]}):null]}),t[185]=n.loading,t[186]=n.personaSectionSoul,t[187]=n.personaSectionSoulHint,t[188]=n.personaSoulCustomEdit,t[189]=n.personaSoulEdit,t[190]=n.personaSoulPreview,t[191]=n.personaSoulTemplate,t[192]=M,t[193]=j,t[194]=re,t[195]=V,t[196]=w,t[197]=se,t[198]=ce,t[199]=le,t[200]=oe,t[201]=P,t[202]=Mt):Mt=t[202];let Nt;t[203]!==n.purgeDisk||t[204]!==n.removeFromConfig||t[205]!==c||t[206]!==V||t[207]!==x||t[208]!==a.id?(Nt=a.id===`main`?null:(0,Q.jsxs)(Ye,{children:[(0,Q.jsx)(Je,{icon:pe,title:V(`Danger Zone`,`危险操作`),subtitle:V(`Actions that cannot be undone. Be careful.`,`以下操作不可撤销,请谨慎操作。`)}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsxs)(J,{type:`button`,variant:`secondary`,disabled:c,onClick:()=>void x(!1),children:[(0,Q.jsx)(T,{className:`mr-1 size-4`,"aria-hidden":!0}),n.removeFromConfig]}),(0,Q.jsx)(J,{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[203]=n.purgeDisk,t[204]=n.removeFromConfig,t[205]=c,t[206]=V,t[207]=x,t[208]=a.id,t[209]=Nt):Nt=t[209];let Pt;return t[210]!==pt||t[211]!==jt||t[212]!==Mt||t[213]!==Nt||t[214]!==G?(Pt=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-8 overflow-y-auto`,children:[G,pt,jt,Mt,Nt]}),t[210]=pt,t[211]=jt,t[212]=Mt,t[213]=Nt,t[214]=G,t[215]=Pt):Pt=t[215],Pt}function on(e){return e.preventDefault()}function sn(e){return e.resolved===`dark`}function cn(e){return e.language}function ln(e){let t=!e.pronouns||nn.some(t=>t.value===e.pronouns),n=en.some(t=>t.value===e.timezone);return{showCustomPronouns:!!(e.pronouns&&!t),showCustomTimezone:!!(e.timezone&&!n),customTimezone:e.timezone&&!n?e.timezone:``}}function un(e,t){switch(t.type){case`load`:{let e=ln(t.user),n=JSON.stringify(t.user);return{user:t.user,snapshot:n,...e}}case`patch`:{let n={...e.user,...t.patch};return{...e,user:n}}case`setShowCustomPronouns`:return{...e,showCustomPronouns:t.value};case`setShowCustomTimezone`:return{...e,showCustomTimezone:t.value};case`setCustomTimezone`:return{...e,customTimezone:t.value};case`saved`:return{...e,snapshot:JSON.stringify(e.user)}}}var dn={callName:``,pronouns:``,timezone:``,notes:``},fn={user:dn,showCustomPronouns:!1,showCustomTimezone:!1,customTimezone:``,snapshot:JSON.stringify(dn)};function pn({a:e,agentId:t,saveRef:n,onDirtyChange:r}){let a=o(e=>e.language),[s,c]=(0,$.useReducer)(un,fn),l=(0,$.useRef)(t);l.current=t;let u=(0,$.useRef)(r);u.current=r;let d=M(async()=>{let e=qt(await Z(t,`USER.md`).catch(()=>``));if(!e.timezone){let t=tn();if(t)return{...e,timezone:t}}return e},[t],{enabled:!!t,initial:null,errorData:dn}),f=(0,$.useRef)(null);(0,$.useEffect)(()=>{d.loading||!d.data||f.current!==t&&(f.current=t,c({type:`load`,user:d.data}),u.current?.(!1))},[t,d.loading,d.data]);let p=(0,$.useCallback)(async e=>{await w(l.current,`USER.md`,e)},[]),m=(0,$.useRef)(s.user);m.current=s.user,(0,$.useEffect)(()=>{if(n)return n.current=async()=>{await p(Jt(m.current)),c({type:`saved`}),u.current?.(!1)},()=>{n.current=null}},[n,p]);let h=(0,$.useCallback)(e=>{c({type:`patch`,patch:e});let t={...m.current,...e};u.current?.(JSON.stringify(t)!==s.snapshot)},[s.snapshot]),g=(0,$.useCallback)(e=>{if(e===`__custom__`){c({type:`setShowCustomTimezone`,value:!0});return}c({type:`setShowCustomTimezone`,value:!1}),c({type:`setCustomTimezone`,value:``}),h({timezone:e})},[h]),_=(0,$.useCallback)(e=>{c({type:`setCustomTimezone`,value:e}),h({timezone:e})},[h]),v=(0,$.useCallback)(()=>{let e=tn();e&&(en.some(t=>t.value===e)?(c({type:`setShowCustomTimezone`,value:!1}),c({type:`setCustomTimezone`,value:``})):(c({type:`setShowCustomTimezone`,value:!0}),c({type:`setCustomTimezone`,value:e})),h({timezone:e}))},[h]),y=s.showCustomTimezone?`__custom__`:en.some(e=>e.value===s.user.timezone)?s.user.timezone:`__custom__`,b=(0,$.useCallback)((e,t)=>a===`zh`?t:e,[a]);if(d.loading)return(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.loading});let x=Dt(),{user:S,showCustomPronouns:C,showCustomTimezone:T,customTimezone:E}=s;return(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-6 overflow-y-auto`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.personaSectionUserHint}),(0,Q.jsxs)(Ye,{children:[(0,Q.jsx)(Je,{icon:j,title:e.personaSectionUser,subtitle:e.personaSectionUserHint}),(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:e.personaCallName}),(0,Q.jsx)(`input`,{className:x,value:S.callName,onChange:e=>h({callName:e.target.value}),placeholder:e.personaCallNamePlaceholder,autoComplete:`off`})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:e.personaPronouns}),(0,Q.jsxs)(`select`,{className:x,value:nn.some(e=>e.value===S.pronouns)?S.pronouns:`__custom__`,onChange:e=>{if(e.target.value===`__custom__`){c({type:`setShowCustomPronouns`,value:!0});return}c({type:`setShowCustomPronouns`,value:!1}),h({pronouns:e.target.value})},children:[(0,Q.jsx)(`option`,{value:``,disabled:!0,children:e.personaPronounsPlaceholder}),nn.map(e=>(0,Q.jsx)(`option`,{value:e.value,children:b(e.labelEn,e.labelZh)},e.value)),(0,Q.jsx)(`option`,{value:`__custom__`,children:b(`Custom…`,`自定义…`)})]}),C?(0,Q.jsx)(`input`,{className:i(x,`mt-1 text-xs`),value:nn.some(e=>e.value===S.pronouns)?``:S.pronouns,onChange:e=>h({pronouns:e.target.value}),placeholder:e.personaPronounsPlaceholder,autoComplete:`off`}):null]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:e.personaTimezone}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[(0,Q.jsxs)(`select`,{className:i(x,`min-w-0 flex-1`),value:y,onChange:e=>g(e.target.value),children:[en.map(e=>(0,Q.jsx)(`option`,{value:e.value,children:b(e.labelEn,e.labelZh)},e.value)),(0,Q.jsx)(`option`,{value:`__custom__`,children:e.personaTimezoneCustom})]}),(0,Q.jsx)(`button`,{type:`button`,className:i(`shrink-0 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,X.press),onClick:v,children:e.personaTimezoneDetect})]}),T?(0,Q.jsx)(`input`,{className:i(x,`mt-1 font-mono text-xs`),value:E,onChange:e=>_(e.target.value),placeholder:`e.g. Asia/Shanghai`,autoComplete:`off`}):null]}),(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:e.personaNotes}),(0,Q.jsx)(`textarea`,{className:i(x,`min-h-16 resize-y text-sm leading-relaxed`),value:S.notes,onChange:e=>h({notes:e.target.value}),placeholder:e.personaNotesPlaceholder,rows:3,spellCheck:!0})]})]}),(0,Q.jsxs)(`div`,{className:`mt-3 flex items-start gap-2 rounded-lg bg-accent-soft/30 px-3 py-2.5 text-xs text-fg-muted`,children:[(0,Q.jsx)(Ue,{className:`mt-0.5 size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{children:e.personaMemoryNote})]})]})]})}function mn(e){let t=(0,yt.c)(2),n;return t[0]===e?n=t[1]:(n=(0,Q.jsx)(pn,{...e},e.agentId),t[0]=e,t[1]=n),n}function hn(e){let t=(0,yt.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(gn)):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)(Je,{className:`shrink-0`,icon:Ce,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)(J,{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 S;t[18]!==n.skillsCustomize||t[19]!==a||t[20]!==x?(S=(0,Q.jsx)(J,{type:`button`,variant:`secondary`,disabled:a,onClick:x,children:n.skillsCustomize}),t[18]=n.skillsCustomize,t[19]=a,t[20]=x,t[21]=S):S=t[21];let C;t[22]!==b||t[23]!==S?(C=(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[b,S]}),t[22]=b,t[23]=S,t[24]=C):C=t[24];let w;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(w=Y(`skills`),t[25]=w):w=t[25];let T;t[26]===n.skillsLibraryLink?T=t[27]:(T=(0,Q.jsx)(se,{to:w,className:`shrink-0 text-xs font-medium text-accent-fg hover:underline`,children:n.skillsLibraryLink}),t[26]=n.skillsLibraryLink,t[27]=T);let E;t[28]!==C||t[29]!==T?(E=(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3`,children:[C,T]}),t[28]=C,t[29]=T,t[30]=E):E=t[30];let D;t[31]===r.skills.defaults?D=t[32]:(D=r.skills.defaults.length?r.skills.defaults.join(`, `):`—`,t[31]=r.skills.defaults,t[32]=D);let O;t[33]!==n.skillsDefaultsLabel||t[34]!==D?(O=(0,Q.jsxs)(`p`,{className:`mt-2 shrink-0 text-xs text-fg-muted`,children:[n.skillsDefaultsLabel,` `,D]}),t[33]=n.skillsDefaultsLabel,t[34]=D,t[35]=O):O=t[35];let k;t[36]!==n.skillsInherit||t[37]!==r.skills.effectiveAllowlist||t[38]!==c?(k=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]=k):k=t[39];let A;t[40]!==n.skillsEffectiveLabel||t[41]!==k?(A=(0,Q.jsxs)(`p`,{className:`shrink-0 text-xs text-fg-muted`,children:[n.skillsEffectiveLabel,` `,k]}),t[40]=n.skillsEffectiveLabel,t[41]=k,t[42]=A):A=t[42];let j;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?(j=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]=j):j=t[53];let M;t[54]!==n.skillsSave||t[55]!==a||t[56]!==p||t[57]!==f?(M=p?null:(0,Q.jsx)(`div`,{className:`mt-4 shrink-0`,children:(0,Q.jsx)(J,{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]=M):M=t[58];let N;return t[59]!==E||t[60]!==O||t[61]!==A||t[62]!==j||t[63]!==M||t[64]!==v?(N=(0,Q.jsxs)(Ye,{className:`flex min-h-0 flex-1 flex-col`,children:[v,E,O,A,j,M]}),t[59]=E,t[60]=O,t[61]=A,t[62]=j,t[63]=M,t[64]=v,t[65]=N):N=t[65],N}function gn(e){return e.name||e.directoryId}function _n(e){let t=(0,yt.c)(51),{a:n,data:r,selected:i,busy:s,toolEntryDisable:c,setToolEntryDisable:l,onSaveTools:u,onClearToolsEntry:d,hideInlineSave:f}=e,p=o(yn),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.defaultsDisable?g=t[3]:(g=new Set(i.tools.defaultsDisable.flatMap(vn)),t[2]=i.tools.defaultsDisable,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)(Je,{className:`shrink-0`,icon:L,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.toolsLockedByDefaults||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.toolsLockedByDefaults},t[13]=n.toolsLockedByDefaults,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]!==_||t[27]!==S||t[28]!==w||t[29]!==y||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)(it,{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]=_,t[27]=S,t[28]=w,t[29]=y,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)(J,{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)(J,{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)(Ye,{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 vn(e){let t=String(e).trim();return t?[t]:[]}function yn(e){return e.language}function bn(e){let t=(0,yt.c)(107),{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,profileSaveRef:S,overviewProfile:C,setProfileDirty:w,filesLoading:T,files:E,activeFile:D,setActiveFile:O,filesViewMode:k,setFilesViewMode:A,fileDraft:j,setFileDraft:M,fileSaving:N,profileFileLoading:P,profileEditorNonce:F,toolEntryDisable:I,setToolEntryDisable:L,onSaveTools:R,onClearToolsEntry:ee,modelRows:z,setModelRows:te,onSaveModels:ne,onClearModelsEntry:re,skillsCatalogLoading:ie,catalogForPick:ae,skillsInherit:B,setSkillsInherit:oe,skillsPick:se,setSkillsPick:ce,onSaveSkills:le,bindingsLoading:ue,agentBindings:de,bindChannelStatuses:fe,bindChannelsLoading:pe,useManualChannel:me,newBindChannel:V,setNewBindChannel:he,bindSessionChats:H,bindSessionsLoading:ge,newBindSessionIdx:U,setNewBindSessionIdx:_e,newBindCustomPeer:W,setNewBindCustomPeer:ve,refreshBindSessions:ye,onRemoveBinding:G,onAddBinding:be,cronLoading:xe,agentCronJobs:Se,onSetCronJobAgent:Ce,onTryInChat:K}=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;return t[2]!==n||t[3]!==c||t[4]!==r||t[5]!==_||t[6]!==v||t[7]!==d||t[8]!==h||t[9]!==l||t[10]!==p||t[11]!==x||t[12]!==b||t[13]!==y||t[14]!==K||t[15]!==C.draft||t[16]!==C.handleSoulContentChange||t[17]!==C.handleSoulTemplateChange||t[18]!==C.profileMarkdownLoading||t[19]!==C.setAvatarDialogOpen||t[20]!==C.toggleSoulPreviewMode||t[21]!==C.updateIdentity||t[22]!==a||t[23]!==f||t[24]!==g||t[25]!==u||t[26]!==m?(e=(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,hideInlineSave:!0,profileMarkdownLoading:C.profileMarkdownLoading,profileDraft:C.draft,updateIdentity:C.updateIdentity,handleSoulTemplateChange:C.handleSoulTemplateChange,handleSoulContentChange:C.handleSoulContentChange,setAvatarDialogOpen:C.setAvatarDialogOpen,toggleSoulPreviewMode:C.toggleSoulPreviewMode,defaultModel:_,defaultWorkspace:v,onTryInChat:K}),t[2]=n,t[3]=c,t[4]=r,t[5]=_,t[6]=v,t[7]=d,t[8]=h,t[9]=l,t[10]=p,t[11]=x,t[12]=b,t[13]=y,t[14]=K,t[15]=C.draft,t[16]=C.handleSoulContentChange,t[17]=C.handleSoulTemplateChange,t[18]=C.profileMarkdownLoading,t[19]=C.setAvatarDialogOpen,t[20]=C.toggleSoulPreviewMode,t[21]=C.updateIdentity,t[22]=a,t[23]=f,t[24]=g,t[25]=u,t[26]=m,t[27]=e):e=t[27],e}if(o===`profile`){let e;return t[28]!==n||t[29]!==S||t[30]!==a.id||t[31]!==w?(e=(0,Q.jsx)(mn,{a:n,agentId:a.id,saveRef:S,onDirtyChange:w}),t[28]=n,t[29]=S,t[30]=a.id,t[31]=w,t[32]=e):e=t[32],e}if(o===`files`){let e;return t[33]!==n||t[34]!==D||t[35]!==j||t[36]!==N||t[37]!==E||t[38]!==T||t[39]!==k||t[40]!==K||t[41]!==F||t[42]!==P||t[43]!==O||t[44]!==M||t[45]!==A?(e=(0,Q.jsx)(It,{a:n,filesLoading:T,files:E,activeFile:D,setActiveFile:O,filesViewMode:k,setFilesViewMode:A,fileDraft:j,setFileDraft:M,fileSaving:N,profileFileLoading:P,profileEditorNonce:F,onTryInChat:K}),t[33]=n,t[34]=D,t[35]=j,t[36]=N,t[37]=E,t[38]=T,t[39]=k,t[40]=K,t[41]=F,t[42]=P,t[43]=O,t[44]=M,t[45]=A,t[46]=e):e=t[46],e}if(o===`tools`){let e;return t[47]!==n||t[48]!==c||t[49]!==s||t[50]!==ee||t[51]!==R||t[52]!==a||t[53]!==L||t[54]!==I?(e=(0,Q.jsx)(_n,{a:n,data:s,selected:a,busy:c,toolEntryDisable:I,setToolEntryDisable:L,onSaveTools:R,onClearToolsEntry:ee,hideInlineSave:!0}),t[47]=n,t[48]=c,t[49]=s,t[50]=ee,t[51]=R,t[52]=a,t[53]=L,t[54]=I,t[55]=e):e=t[55],e}if(o===`models`){let e;return t[56]!==n||t[57]!==c||t[58]!==r||t[59]!==z||t[60]!==re||t[61]!==ne||t[62]!==a||t[63]!==te?(e=(0,Q.jsx)(Rt,{a:n,chat:r,selected:a,busy:c,modelRows:z,setModelRows:te,onSaveModels:ne,onClearModelsEntry:re,hideInlineSave:!0}),t[56]=n,t[57]=c,t[58]=r,t[59]=z,t[60]=re,t[61]=ne,t[62]=a,t[63]=te,t[64]=e):e=t[64],e}if(o===`skills`){let e;return t[65]!==n||t[66]!==c||t[67]!==ae||t[68]!==le||t[69]!==a||t[70]!==oe||t[71]!==ce||t[72]!==ie||t[73]!==B||t[74]!==se?(e=(0,Q.jsx)(hn,{a:n,selected:a,busy:c,skillsCatalogLoading:ie,catalogForPick:ae,skillsInherit:B,setSkillsInherit:oe,skillsPick:se,setSkillsPick:ce,onSaveSkills:le,hideInlineSave:!0}),t[65]=n,t[66]=c,t[67]=ae,t[68]=le,t[69]=a,t[70]=oe,t[71]=ce,t[72]=ie,t[73]=B,t[74]=se,t[75]=e):e=t[75],e}if(o===`channels`){let e;return t[76]!==n||t[77]!==de||t[78]!==fe||t[79]!==pe||t[80]!==H||t[81]!==ge||t[82]!==ue||t[83]!==c||t[84]!==i.lastActiveLabels||t[85]!==i.selectRecipient||t[86]!==V||t[87]!==W||t[88]!==U||t[89]!==be||t[90]!==G||t[91]!==ye||t[92]!==he||t[93]!==ve||t[94]!==_e||t[95]!==me?(e=(0,Q.jsx)(Mt,{a:n,busy:c,bindingsLoading:ue,agentBindings:de,channelStatuses:fe,channelsStatusLoading:pe,useManualChannel:me,newBindChannel:V,setNewBindChannel:he,bindSessionChats:H,sessionsLoading:ge,newBindSessionIdx:U,setNewBindSessionIdx:_e,newBindCustomPeer:W,setNewBindCustomPeer:ve,onRefreshSessions:ye,lastActiveLabels:i.lastActiveLabels,selectRecipient:i.selectRecipient,onRemoveBinding:G,onAddBinding:be}),t[76]=n,t[77]=de,t[78]=fe,t[79]=pe,t[80]=H,t[81]=ge,t[82]=ue,t[83]=c,t[84]=i.lastActiveLabels,t[85]=i.selectRecipient,t[86]=V,t[87]=W,t[88]=U,t[89]=be,t[90]=G,t[91]=ye,t[92]=he,t[93]=ve,t[94]=_e,t[95]=me,t[96]=e):e=t[96],e}if(o===`cron`&&s){let e;return t[97]!==n||t[98]!==Se||t[99]!==c||t[100]!==xe||t[101]!==s||t[102]!==Ce||t[103]!==a?(e=(0,Q.jsx)(Nt,{a:n,data:s,selected:a,busy:c,cronLoading:xe,agentCronJobs:Se,onSetCronJobAgent:Ce}),t[97]=n,t[98]=Se,t[99]=c,t[100]=xe,t[101]=s,t[102]=Ce,t[103]=a,t[104]=e):e=t[104],e}let q;return t[105]===n.selectAgentHint?q=t[106]:(q=(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.selectAgentHint}),t[105]=n.selectAgentHint,t[106]=q),q}function xn(e,t,n){let r=t.trim().toLowerCase();return r?e.filter(e=>{let t=S(e,n).toLowerCase(),i=e.id.toLowerCase(),a=e.workspace.toLowerCase(),o=re(e,n).toLowerCase();return t.includes(r)||i.includes(r)||a.includes(r)||o.includes(r)}):e}function Sn(e,t){return e.replace(`{{count}}`,String(t))}function Cn(e,t){let n=e.tools.effectiveDisable.length,r=e.skills.effectiveAllowlist?.length??0,i=n>0?Sn(t.listToolsDisabledCount,n):t.listToolsAllEnabled,a=r>0?Sn(t.listSkillsCount,r):t.listInheritedValue;return`${t.listToolsLabel} ${i} · ${t.listSkillsLabel} ${a}`}function wn(e,t){let n=e.tools.effectiveDisable.length,r=e.skills.effectiveAllowlist?.length??0,i=n>0?Sn(t.listToolsDisabledCount,n):t.listToolsAllEnabled,a=r>0?Sn(t.listSkillsCount,r):t.listInheritedValue;return[`${t.listToolsLabel} ${i}`,`${t.listSkillsLabel} ${a}`]}function Tn(e){let t=(0,yt.c)(11),{text:n,children:r,className:a}=e,o;t[0]!==r||t[1]!==a||t[2]!==n?(o=(0,Q.jsx)(x,{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`,We),t[4]=s):s=t[4];let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(f,{className:`fill-surface-panel`}),t[5]=c):c=t[5];let l;t[6]===n?l=t[7]:(l=(0,Q.jsx)(R,{children:(0,Q.jsxs)(Oe,{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)(ee,{delayDuration:300,skipDelayDuration:100,children:(0,Q.jsxs)(ne,{children:[o,l]})}),t[8]=o,t[9]=l,t[10]=u):u=t[10],u}function En(e){let t=(0,yt.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=xn(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 h;t[16]!==n||t[17]!==c||t[18]!==s||t[19]!==o?(h=e=>{let t=S(e,n),r=e.id,a=re(e,n),l=Cn(e,n),u=wn(e,n);return(0,Q.jsx)(`li`,{className:`h-full min-h-0`,children:(0,Q.jsxs)(`article`,{className:`flex min-h-[15.5rem] flex-col rounded-xl border border-edge-subtle bg-surface-panel p-4 shadow-surface transition-colors hover:border-edge`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Q.jsxs)(`button`,{type:`button`,disabled:c,onClick:()=>o(e.id),className:i(`flex min-w-0 items-start gap-3 text-left`,`rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`,X.pressCard),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)(k,{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)(`button`,{type:`button`,disabled:c,onClick:()=>o(e.id),className:i(`mt-5 min-h-[6.25rem] text-left`,`rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`),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(Dn)})]}),(0,Q.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,Q.jsxs)(J,{type:`button`,variant:`secondary`,disabled:c,onClick:()=>s(e.id),className:`w-full rounded-2xl py-2.5`,children:[(0,Q.jsx)(de,{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]=h):h=t[20],u=e.map(h)}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 h;return t[24]!==d||t[25]!==f||t[26]!==m?(h=(0,Q.jsxs)(`div`,{className:d,children:[f,m]}),t[24]=d,t[25]=f,t[26]=m,t[27]=h):h=t[27],h}function Dn(e){return(0,Q.jsx)(Tn,{text:e,className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function On(e){let t=(0,yt.c)(130),{open:n,onOpenChange:r,a,chat:o,busy:s,modalError:c,profileLanguageLabel:l,createDisplayName:u,setCreateDisplayName:f,createAgentId:p,setCreateAgentId:m,createDescription:h,setCreateDescription:g,createWorkspace:_,setCreateWorkspace:v,createModel:y,setCreateModel:b,onCreate:x,onSuggestWorkspace:C,agents:w,duplicateSourceId:T,onSelectDuplicateSource:E}=e,D;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Q.jsx)(ge,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim`,ye)}),t[0]=D):D=t[0];let O;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(O=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`,Te,`overflow-y-auto rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`),t[1]=O):O=t[1];let k;t[2]===a.addAgent?k=t[3]:(k=(0,Q.jsx)(d,{className:`text-base font-semibold text-fg`,children:a.addAgent}),t[2]=a.addAgent,t[3]=k);let j;t[4]===a.addAgentHint?j=t[5]:(j=(0,Q.jsx)(_e,{className:`mt-0.5 text-xs text-fg-muted`,children:a.addAgentHint}),t[4]=a.addAgentHint,t[5]=j);let M;t[6]!==k||t[7]!==j?(M=(0,Q.jsxs)(`div`,{className:`min-w-0 pr-2`,children:[k,j]}),t[6]=k,t[7]=j,t[8]=M):M=t[8];let N;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(N=i(be,`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)(De,{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)(Pe,{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 R;t[16]!==a||t[17]!==w||t[18]!==T||t[19]!==E?(R=w.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(Dt(),`bg-surface-panel`),value:T??``,onChange:e=>E(e.target.value||null),children:[(0,Q.jsx)(`option`,{value:``,children:a.copyFromExistingAgentNone}),w.map(e=>(0,Q.jsxs)(`option`,{value:e.id,children:[S(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]=w,t[18]=T,t[19]=E,t[20]=R):R=t[20];let ee;t[21]===c?ee=t[22]:(ee=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]=ee);let z;t[23]!==a.newAgentLabel||t[24]!==l?(z=(0,Q.jsxs)(`span`,{className:`text-fg-muted`,children:[a.newAgentLabel,` (`,l,`)`]}),t[23]=a.newAgentLabel,t[24]=l,t[25]=z):z=t[25];let te;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(te=Dt(),t[26]=te):te=t[26];let ne;t[27]===f?ne=t[28]:(ne=e=>f(e.target.value),t[27]=f,t[28]=ne);let re;t[29]===C?re=t[30]:(re=()=>C(),t[29]=C,t[30]=re);let ie;t[31]!==u||t[32]!==ne||t[33]!==re?(ie=(0,Q.jsx)(`input`,{className:te,value:u,onChange:ne,onBlur:re,required:!0,autoComplete:`off`}),t[31]=u,t[32]=ne,t[33]=re,t[34]=ie):ie=t[34];let B;t[35]!==z||t[36]!==ie?(B=(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[z,ie]}),t[35]=z,t[36]=ie,t[37]=B):B=t[37];let oe;t[38]===a.newAgentIdOptional?oe=t[39]:(oe=(0,Q.jsx)(`span`,{className:`text-fg-muted`,children:a.newAgentIdOptional}),t[38]=a.newAgentIdOptional,t[39]=oe);let se;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(se=i(Dt(),`font-mono text-xs`),t[40]=se):se=t[40];let ce;t[41]===m?ce=t[42]:(ce=e=>m(e.target.value),t[41]=m,t[42]=ce);let le;t[43]===C?le=t[44]:(le=()=>C(),t[43]=C,t[44]=le);let de;t[45]!==a.newAgentIdPlaceholder||t[46]!==a.newAgentIdRules||t[47]!==p||t[48]!==ce||t[49]!==le?(de=(0,Q.jsx)(`input`,{className:se,value:p,onChange:ce,onBlur:le,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]=p,t[48]=ce,t[49]=le,t[50]=de):de=t[50];let fe;t[51]===a.newAgentIdRules?fe=t[52]:(fe=(0,Q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:a.newAgentIdRules}),t[51]=a.newAgentIdRules,t[52]=fe);let pe;t[53]!==oe||t[54]!==de||t[55]!==fe?(pe=(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[oe,de,fe]}),t[53]=oe,t[54]=de,t[55]=fe,t[56]=pe):pe=t[56];let me;t[57]!==a.agentDescription||t[58]!==l?(me=(0,Q.jsxs)(`span`,{className:`text-fg-muted`,children:[a.agentDescription,` (`,l,`)`]}),t[57]=a.agentDescription,t[58]=l,t[59]=me):me=t[59];let he;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(he=i(Dt(),`min-h-18 resize-y font-sans text-sm leading-relaxed`),t[60]=he):he=t[60];let H;t[61]===g?H=t[62]:(H=e=>g(e.target.value),t[61]=g,t[62]=H);let U;t[63]!==a.agentDescriptionPlaceholder||t[64]!==h||t[65]!==H?(U=(0,Q.jsx)(`textarea`,{className:he,value:h,onChange:H,placeholder:a.agentDescriptionPlaceholder,maxLength:4e3,rows:3,spellCheck:!0}),t[63]=a.agentDescriptionPlaceholder,t[64]=h,t[65]=H,t[66]=U):U=t[66];let W;t[67]!==me||t[68]!==U?(W=(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[me,U]}),t[67]=me,t[68]=U,t[69]=W):W=t[69];let G;t[70]===a.newWorkspace?G=t[71]:(G=(0,Q.jsx)(`span`,{className:`text-fg-muted`,children:a.newWorkspace}),t[70]=a.newWorkspace,t[71]=G);let xe;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(xe=i(Dt(),`font-mono text-xs`),t[72]=xe):xe=t[72];let Se;t[73]===v?Se=t[74]:(Se=e=>v(e.target.value),t[73]=v,t[74]=Se);let Ce;t[75]!==_||t[76]!==Se?(Ce=(0,Q.jsx)(`input`,{className:xe,value:_,onChange:Se,required:!0,autoComplete:`off`}),t[75]=_,t[76]=Se,t[77]=Ce):Ce=t[77];let K;t[78]!==G||t[79]!==Ce?(K=(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[G,Ce]}),t[78]=G,t[79]=Ce,t[80]=K):K=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 we;t[83]===b?we=t[84]:(we=e=>b(e),t[83]=b,t[84]=we);let Ee;t[85]!==s||t[86]!==o.modelNoMatches||t[87]!==o.modelPlaceholder||t[88]!==o.modelSearchPlaceholder||t[89]!==y||t[90]!==we?(Ee=(0,Q.jsx)(ue,{className:`min-w-0 flex-1`,value:y,disabled:s,placeholder:o.modelPlaceholder,searchPlaceholder:o.modelSearchPlaceholder,noMatches:o.modelNoMatches,onChange:we}),t[85]=s,t[86]=o.modelNoMatches,t[87]=o.modelPlaceholder,t[88]=o.modelSearchPlaceholder,t[89]=y,t[90]=we,t[91]=Ee):Ee=t[91];let Oe;t[92]!==a.modelClear||t[93]!==s||t[94]!==y||t[95]!==b?(Oe=y.trim()?(0,Q.jsx)(J,{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]=Oe):Oe=t[96];let ke;t[97]!==Ee||t[98]!==Oe?(ke=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[Ee,Oe]}),t[97]=Ee,t[98]=Oe,t[99]=ke):ke=t[99];let Ae;t[100]!==q||t[101]!==ke?(Ae=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm`,children:[q,ke]}),t[100]=q,t[101]=ke,t[102]=Ae):Ae=t[102];let je;t[103]!==a.createModalCancel||t[104]!==s?(je=(0,Q.jsx)(Pe,{asChild:!0,children:(0,Q.jsx)(J,{type:`button`,variant:`secondary`,disabled:s,children:a.createModalCancel})}),t[103]=a.createModalCancel,t[104]=s,t[105]=je):je=t[105];let Me;t[106]===Symbol.for(`react.memo_cache_sentinel`)?(Me=(0,Q.jsx)(P,{className:`mr-1 size-4`,"aria-hidden":!0}),t[106]=Me):Me=t[106];let Ne;t[107]!==a.create||t[108]!==s?(Ne=(0,Q.jsxs)(J,{type:`submit`,disabled:s,children:[Me,a.create]}),t[107]=a.create,t[108]=s,t[109]=Ne):Ne=t[109];let Fe;t[110]!==je||t[111]!==Ne?(Fe=(0,Q.jsxs)(`div`,{className:`mt-1 flex justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[je,Ne]}),t[110]=je,t[111]=Ne,t[112]=Fe):Fe=t[112];let Ie;t[113]!==x||t[114]!==ee||t[115]!==B||t[116]!==pe||t[117]!==W||t[118]!==K||t[119]!==Ae||t[120]!==Fe||t[121]!==R?(Ie=(0,Q.jsxs)(`form`,{className:`grid gap-3`,onSubmit:x,children:[R,ee,B,pe,W,K,Ae,Fe]}),t[113]=x,t[114]=ee,t[115]=B,t[116]=pe,t[117]=W,t[118]=K,t[119]=Ae,t[120]=Fe,t[121]=R,t[122]=Ie):Ie=t[122];let Le;t[123]!==Ie||t[124]!==L?(Le=(0,Q.jsxs)(ve,{children:[D,(0,Q.jsx)(A,{className:O,onOpenAutoFocus:kn,children:(0,Q.jsxs)(V,{layer:`modal`,children:[L,Ie]})})]}),t[123]=Ie,t[124]=L,t[125]=Le):Le=t[125];let Re;return t[126]!==r||t[127]!==n||t[128]!==Le?(Re=(0,Q.jsx)(ae,{open:n,onOpenChange:r,children:Le}),t[126]=r,t[127]=n,t[128]=Le,t[129]=Re):Re=t[129],Re}function kn(e){return e.preventDefault()}function An(e){let t=(0,yt.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)(Ne,{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)(v,{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)(J,{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 jn(e){return{...e,soulEditorNonce:0,soulPreviewMode:!1,avatarDialogOpen:!1}}function Mn(e){let{agentId:t,enabled:n,saveRef:r}=e,i=M(async()=>{if(!t)return null;let[e,n]=await Promise.all([Z(t,`IDENTITY.md`).catch(()=>``),Z(t,`SOUL.md`).catch(()=>``)]),r=Wt(e);return{identity:r,soulTemplate:Zt(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?jn(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?jn(a):null);return n?e(n):null})},[a]),g=(0,$.useCallback)(e=>{h(t=>({...t,identity:{...t.identity,...e}}))},[h]),_=(0,$.useCallback)(e=>{h(t=>{if(e===`custom`)return{...t,soulTemplate:`custom`};let n=Yt.find(t=>t.id===e);return n?.content?{...t,soulTemplate:e,soulCustomContent:n.content,soulEditorNonce:t.soulEditorNonce+1}:{...t,soulTemplate:e}})},[h]),v=(0,$.useCallback)(e=>{h(t=>({...t,soulCustomContent:e,soulTemplate:`custom`}))},[h]),y=(0,$.useCallback)(e=>{h(t=>({...t,avatarDialogOpen:e}))},[h]),b=(0,$.useCallback)(()=>{h(e=>({...e,soulPreviewMode:!e.soulPreviewMode}))},[h]),x=(0,$.useCallback)(async()=>{let e=m.current;!e||!f||(await Promise.all([w(e,`IDENTITY.md`,Gt(f.identity)),w(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=x,()=>{r.current=null}},[x,r]),{profileMarkdownLoading:o,draft:f,dirty:p,updateIdentity:g,handleSoulTemplateChange:_,handleSoulContentChange:v,setAvatarDialogOpen:y,toggleSoulPreviewMode:b}}var Nn={draft:``,editorNonce:0,loadedKey:``};function Pn(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 Fn(e){let{panel:t,selectedId:n,hasToken:r,dataAgentsLength:i,saveErrorMessage:a,setError:o}=e,s=M(()=>n?m(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,h]=(0,$.useReducer)(Pn,Nn),[g,_]=(0,$.useState)(!1),[v,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 T=(0,$.useRef)(n);T.current=n;let D=(0,$.useRef)(d);D.current=d;let O=(0,$.useRef)(null),k=(0,$.useRef)(``),A=(0,$.useRef)(``),j=(0,$.useRef)(``),N=(0,$.useRef)(()=>{}),P=M(()=>d&&n?Z(n,d).catch(()=>``):Promise.resolve(``),[d,n,r],{enabled:!!(d&&n&&r),initial:``,errorData:``}),F=P.loading,I=E(async()=>{let e=T.current,t=D.current;if(!e||!t||`${e}:${t}`!==k.current)return;let n=C.current;if(n!==A.current){_(!0),o(null);try{await w(e,t,n),A.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{_(!1)}}},800);N.current=I.flush,(0,$.useEffect)(()=>()=>{N.current()},[]);let L=(0,$.useRef)(t);L.current!==t&&(L.current===`files`&&N.current(),L.current=t);let R=d&&n?`${n}:${d}`:``;(0,$.useEffect)(()=>{R!==j.current&&(N.current(),j.current=R)},[R]),(0,$.useEffect)(()=>{if(!R){h({type:`clear`});return}F||(k.current=R,A.current=P.data,h({type:`load`,key:R,content:P.data}))},[R,F,P.data]);let ee=(0,$.useRef)({activeFile:d,selectedId:n});return(ee.current.activeFile!==d||ee.current.selectedId!==n)&&(ee.current={activeFile:d,selectedId:n},y(`edit`)),{files:c,setFiles:l,filesLoading:u,activeFile:d,setActiveFile:(0,$.useCallback)(e=>{N.current(),f(e)},[]),fileDraft:x,setFileDraft:(0,$.useCallback)(e=>{h({type:`setDraft`,value:typeof e==`function`?e(C.current):e}),I()},[I]),fileSaving:g,filesViewMode:v,setFilesViewMode:y,profileFileLoading:F,profileEditorNonce:S,overviewSaveProfileMarkdownRef:O,saveProfileMarkdownDebounced:I}}function In(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=M(()=>ht(),[t,n],{enabled:m,initial:[],errorData:[]}),g=h.data,_=h.loading,v=(0,$.useMemo)(()=>_||g.length===0?``:g[0]?.name??``,[g,_]),[y,b]=(0,$.useState)(``),x=(0,$.useRef)(v);t===`channels`&&!_&&v&&x.current!==v&&(!y||!g.some(e=>e.name===y))&&(x.current=v,b(v)),x.current=v;let S=y.trim(),C=m&&S.length>0,w=M(()=>dt(S),[t,n,S],{enabled:C,initial:[],errorData:[]}),T=w.data,E=w.loading,D=w.setData,[O,k]=(0,$.useState)(null),[A,j]=(0,$.useState)(``),N=(0,$.useRef)(S);N.current!==S&&(N.current=S,k(null));let P=(0,$.useMemo)(()=>a?p.filter(e=>e.agentId.toLowerCase()===a.id.toLowerCase()):[],[p,a?.id]),F=(0,$.useCallback)(()=>{let e=y.trim();e&&dt(e).then(e=>{D(e),k(t=>t!=null&&t<e.length?t:null)}).catch(()=>{D([]),k(null)})},[y,D]),I=!_&&g.length===0,L=t===`channels`&&n&&i,R=(0,$.useCallback)(async e=>{s(!0),c(null);try{let t=p.filter(t=>t!==e);await he(t),l.current=!0,d(t)}catch(e){c(e instanceof Error?e.message:o)}finally{s(!1)}},[p,o,s,c]);return{agentBindings:P,allBindings:p,bindChannelStatuses:g,bindChannelsLoading:_,bindSessionChats:T,bindSessionsLoading:E,bindingsLoading:L,newBindChannel:y,setNewBindChannel:b,newBindSessionIdx:O,setNewBindSessionIdx:k,newBindCustomPeer:A,setNewBindCustomPeer:j,onAddBinding:(0,$.useCallback)(async e=>{if(e.preventDefault(),!a||!y.trim())return;let t=At(y,A,O,T),n=[...p,{agentId:a.id,priority:100,enabled:!0,match:t}];s(!0),c(null);try{await he(n),l.current=!0,d(n),k(null),j(``)}catch(e){c(e instanceof Error?e.message:o)}finally{s(!1)}},[p,T,y,A,O,o,a,s,c]),onRemoveBinding:R,refreshBindSessions:F,useManualChannel:I}}function Ln(e){let{panel:t,hasToken:n,data:r,selected:i,saveErrorMessage:a,setBusy:o,setError:s}=e,{data:c,loading:l}=M(()=>ft(),[t,n],{enabled:t===`cron`&&n,initial:[],errorData:[]}),[u,d]=(0,$.useState)(null),f=u??c,p=(0,$.useMemo)(()=>!r||!i?[]:f.filter(e=>!vt(e)&&Ot(e,i.id,r.defaultId)),[f,r,i]);async function m(e,t){o(!0),s(null);try{await pt(e.id,{agentId:t}),d(await ft())}catch(e){s(e instanceof Error?e.message:a)}finally{o(!1)}}return{agentCronJobs:p,cronJobs:f,cronLoading:l,onSetCronJobAgent:m}}function Rn(e){return new Set(e.tools.entryDisable)}function zn(e){return e.skills.entry===void 0?{inherit:!0,pick:new Set(e.skills.effectiveAllowlist??[])}:{inherit:!1,pick:new Set(e.skills.entry??[])}}function Bn(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(Rn(n)),n&&t===`skills`){let e=zn(n);u(e.inherit),c(e.pick)}n&&t===`models`&&f(tt(n.typedModels.entry))}return{toolEntryDisable:a,setToolEntryDisable:o,skillsPick:s,setSkillsPick:c,skillsInherit:l,setSkillsInherit:u,modelRows:d,setModelRows:f}}function Vn(){let e=o(e=>e.language),t=a(e),n=t.agentsSettings,[r,i]=(0,$.useState)(!1),[s,u]=(0,$.useState)(null),[d,f]=(0,$.useState)(!1),[p,m]=(0,$.useState)(``),h=t.cron,g=t.chat,v=!!c(e=>e.token),[b,x]=_(),w=le(),{agentId:T}=y(),E=Ee(e=>e.setPageHeader),D=Ee(e=>e.clearPageHeader),{data:k,error:A,isLoading:j,mutate:M}=l(v?`settings-gateway-agents`:null,me,{revalidateOnFocus:!1}),{data:P}=xe(v),F=(0,$.useMemo)(()=>fe(P?.payload?.config??{}),[P]),I=(0,$.useMemo)(()=>$e(P?.payload?.config??{}),[P]),L=k??null,R=!!(v&&j),[ee,z]=(0,$.useState)(null),te=A instanceof Error?A.message:A?n.loadError:null,ne=ee??te,[re,ie]=(0,$.useState)(null),[ae,B]=(0,$.useState)(`overview`),[se,ce]=(0,$.useState)(``),[ue,de]=(0,$.useState)(``),[pe,V]=(0,$.useState)(``),[he,H]=(0,$.useState)(``),[ge,U]=(0,$.useState)(``),[_e,W]=(0,$.useState)(null),[ve,ye]=(0,$.useState)(!1),G=(0,$.useRef)(``),[be,Se]=(0,$.useState)(null),[Ce,K]=(0,$.useState)(!1),[q,we]=(0,$.useState)(``),[Te,De]=(0,$.useState)(``),[Oe,J]=(0,$.useState)(``),[Ae,je]=(0,$.useState)(``),[Me,Ne]=(0,$.useState)(``),Pe=(0,$.useRef)(null),Fe=(0,$.useRef)(null),[Ie,Le]=(0,$.useState)(!1),[Be,Ve]=(0,$.useState)(!1),He=(0,$.useRef)({data:null,routeAgentId:void 0});L&&(L!==He.current.data||T!==He.current.routeAgentId)&&(He.current={data:L,routeAgentId:T},T&&L.agents.some(e=>e.id===T)?ie(T):ie(e=>e&&L.agents.some(t=>t.id===e)?e:L.defaultId)),(0,$.useEffect)(()=>{!L||!T||L.agents.some(e=>e.id===T)||w(ze,{replace:!0})},[L,T,w]),(0,$.useEffect)(()=>{T&&B(`overview`)},[T]),(0,$.useEffect)(()=>{b.get(`panel`)===`defaults`&&w(`/settings/agent-defaults`,{replace:!0,state:{[C]:T?ke(T):ze}})},[b,T,w]),(0,$.useEffect)(()=>{if(b.get(`focus`)!==`avatar`||!T||(B(`overview`),R||!L?.agents.some(e=>e.id===T)))return;let e=window.setTimeout(()=>{document.getElementById(`agent-avatar-settings`)?.scrollIntoView({behavior:`smooth`,block:`center`}),x(e=>{let t=new URLSearchParams(e);return t.delete(`focus`),t},{replace:!0})},220);return()=>window.clearTimeout(e)},[b,T,R,L,x]);let Y=(0,$.useMemo)(()=>L?.agents.find(e=>e.id===re)??null,[L,re]),Ue=(0,$.useRef)(null),We=Y?Y.id:null;Y&&Ue.current!==We?(Ue.current=We,De(Y.workspace),J(Y.model?.primary??``),je(S(Y,a(e).agentsSettings)),Ne(Y.description??``)):!Y&&Ue.current!==null&&(Ue.current=null,De(``),J(``),je(``),Ne(``));let Ge=Mn({agentId:Y?.id??null,enabled:ae===`overview`&&!!Y,saveRef:Fe}),X=Fn({panel:ae,selectedId:re,hasToken:v,dataAgentsLength:L?.agents.length,saveErrorMessage:n.saveError,setError:z}),Ke=Bn({panel:ae,selected:Y}),Z=In({panel:ae,hasToken:v,bindingsFromConfig:F,gatewayCfgLoading:P===void 0,selected:Y,saveErrorMessage:n.saveError,setBusy:K,setError:z}),qe=Ln({panel:ae,hasToken:v,data:L,selected:Y,saveErrorMessage:n.saveError,setBusy:K,setError:z}),Je=at({panel:ae,hasToken:v}),Ye=(0,$.useCallback)(()=>{let e=lt(ue.trim()||se);H(t=>t===``||t===G.current?(G.current=e,e):t)},[ue,se]),Xe=(0,$.useCallback)(()=>{G.current=``,ce(``),de(``),V(``),H(``),U(``),W(null),Se(null),ye(!0)},[]),et=(0,$.useCallback)(e=>{let t=new Set(L?.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,L]),tt=(0,$.useCallback)(e=>{if(Se(e),!e)return;let t=L?.agents.find(t=>t.id===e);if(!t)return;let r=t.name?.trim()??t.id,i=n.duplicateName.replace(`{{name}}`,r),a=et(t.id),o=t.description??``;G.current=``,ce(i),de(a),V(o),H(t.workspace),U(t.model?.primary??``),W(null)},[n.duplicateName,L,et]),nt=(0,$.useCallback)(e=>{tt(e),ye(!0)},[tt]),rt=(0,$.useMemo)(()=>(0,Q.jsx)(An,{a:n,busy:Ce,listSearchQuery:q,onListSearchQueryChange:we,onAddAgent:()=>Xe()}),[n,Ce,q,Xe]);(0,$.useLayoutEffect)(()=>v?(E({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:rt}),()=>D()):(D(),()=>D()),[n.title,rt,D,v,E]);async function it(t){t.preventDefault();let r=se.trim();if(!r)return;let i=ot(ue,r);if(i.ok===!1){W(i.error);return}let a=he.trim()||lt(ue.trim()||r);if(a){K(!0),W(null);try{let t=[`# IDENTITY.md - Who Am I?`,``,`- **Name:** ${r}`,`- **Description:** ${pe.trim()}`,`- **Language:** ${e}`,`- **Creature:** assistant`,`- **Emoji:**`,`- **Avatar:**`,``].join(`
71
+ `),{createdAgentId:n,...i}=await O({workspace:a,...ue.trim()?{id:ue.trim()}:{},...ge.trim()?{models:{chat:{primary:ge.trim()}}}:{},profileFiles:{"IDENTITY.md":t},...be?{cloneFrom:be}:{}});M(i,{revalidate:!1}),ce(``),de(``),V(``),H(``),U(``),W(null),ye(!1),ie(n),w(ke(n))}catch(e){W(e instanceof Error?e.message:n.saveError)}finally{K(!1)}}}async function st(){if(Y){K(!0),z(null);try{M(await N(Y.id,{workspace:Te.trim()||void 0,models:{chat:Oe.trim()?{primary:Oe.trim()}:null}}),{revalidate:!1})}catch(e){z(e instanceof Error?e.message:n.saveError)}finally{K(!1)}}}async function ct(e){K(!0),z(null);try{M(await N(e.id,{setDefault:!0}),{revalidate:!1}),ie(e.id)}catch(e){z(e instanceof Error?e.message:n.saveError)}finally{K(!1)}}async function ut(e,t){K(!0),z(null);try{let n=await oe(e.id,t);M(n,{revalidate:!1}),ie(n.defaultId),B(`overview`),T===e.id&&w(ze,{replace:!0}),i(!1),u(null),m(``)}catch(e){z(e instanceof Error?e.message:n.saveError)}finally{K(!1)}}function dt(e,t){e.id!==`main`&&(u(e),f(t),m(``),i(!0))}async function ft(){if(Y){K(!0),z(null);try{let e=Array.from(Ke.toolEntryDisable).toSorted((e,t)=>e.localeCompare(t));M(await N(Y.id,{tools:{disable:e}}),{revalidate:!1})}catch(e){z(e instanceof Error?e.message:n.saveError)}finally{K(!1)}}}async function pt(){if(Y){K(!0),z(null);try{M(await N(Y.id,{tools:{disable:null}}),{revalidate:!1}),Ke.setToolEntryDisable(new Set)}catch(e){z(e instanceof Error?e.message:n.saveError)}finally{K(!1)}}}async function mt(){if(!Y)return;let e=Qe(Ke.modelRows,{invalidId:n.typedModelsInvalidId,duplicateId:n.typedModelsDuplicateId,invalidModel:n.typedModelsInvalidModel});if(e){z(e);return}K(!0),z(null);try{M(await N(Y.id,{models:{roles:Ze(Ke.modelRows)?.roles??{}}}),{revalidate:!1})}catch(e){z(e instanceof Error?e.message:n.saveError)}finally{K(!1)}}async function ht(){if(Y){K(!0),z(null);try{M(await N(Y.id,{models:{roles:null}}),{revalidate:!1}),Ke.setModelRows([])}catch(e){z(e instanceof Error?e.message:n.saveError)}finally{K(!1)}}}async function gt(){if(Y){K(!0),z(null);try{M(await N(Y.id,{skills:Ke.skillsInherit?null:[...Ke.skillsPick].toSorted((e,t)=>e.localeCompare(t))}),{revalidate:!1})}catch(e){z(e instanceof Error?e.message:n.saveError)}finally{K(!1)}}}let _t=ae===`channels`||ae===`cron`,vt=(()=>{if(!Y||ae!==`overview`)return!1;let e=Y.workspace,t=Y.model?.primary??``;return Te.trim()!==e||Oe.trim()!==t})(),yt=(()=>{if(_t||!Y)return!1;switch(ae){case`overview`:return vt||Ge.dirty;case`profile`:return Ie;default:return!0}})(),bt=_t||!yt;function xt(){Ve(!0),setTimeout(()=>Ve(!1),2e3)}async function St(){switch(ae){case`overview`:await Promise.all([st(),Fe.current?.()??Promise.resolve()]),xt();break;case`profile`:await Pe.current?.(),xt();break;case`tools`:await ft(),xt();break;case`models`:await mt(),xt();break;case`skills`:await gt(),xt();break;case`files`:X.saveProfileMarkdownDebounced.flush(),xt();break;default:break}}function Ct(e){e||w(ze)}let wt=Y?Ae.trim()||S(Y,n):T??``,Tt=Y?.id??T??``,Et=(0,$.useCallback)(async()=>{if(Y){await St();try{globalThis.localStorage?.setItem(Re,Y.id)}catch{}w(`/chat/new`,{state:{agentId:Y.id,fromAgentEditor:!0}})}},[Y,St,w]),Dt={a:n,chat:g,cCron:h,selected:Y,panel:ae,data:L,busy:Ce,editName:Ae,setEditName:je,editDescription:Me,setEditDescription:Ne,editWorkspace:Te,setEditWorkspace:De,editModel:Oe,setEditModel:J,defaultModel:I.model,defaultWorkspace:I.workspace,onSetDefault:()=>{Y&&ct(Y)},onSaveAgentEdits:()=>void st(),onDelete:e=>{Y&&dt(Y,e)},onTryInChat:()=>void Et(),overviewSaveProfileMarkdownRef:Fe,profileSaveRef:Pe,overviewProfile:Ge,setProfileDirty:Le,filesLoading:X.filesLoading,files:X.files,activeFile:X.activeFile,setActiveFile:X.setActiveFile,filesViewMode:X.filesViewMode,setFilesViewMode:X.setFilesViewMode,fileDraft:X.fileDraft,setFileDraft:X.setFileDraft,fileSaving:X.fileSaving,profileFileLoading:X.profileFileLoading,profileEditorNonce:X.profileEditorNonce,toolEntryDisable:Ke.toolEntryDisable,setToolEntryDisable:Ke.setToolEntryDisable,onSaveTools:()=>void ft(),onClearToolsEntry:()=>void pt(),modelRows:Ke.modelRows,setModelRows:Ke.setModelRows,onSaveModels:()=>void mt(),onClearModelsEntry:()=>void ht(),skillsCatalogLoading:Je.skillsCatalogLoading,catalogForPick:Je.catalogForPick,skillsInherit:Ke.skillsInherit,setSkillsInherit:Ke.setSkillsInherit,skillsPick:Ke.skillsPick,setSkillsPick:Ke.setSkillsPick,onSaveSkills:()=>void gt(),bindingsLoading:Z.bindingsLoading,agentBindings:Z.agentBindings,bindChannelStatuses:Z.bindChannelStatuses,bindChannelsLoading:Z.bindChannelsLoading,useManualChannel:Z.useManualChannel,newBindChannel:Z.newBindChannel,setNewBindChannel:Z.setNewBindChannel,bindSessionChats:Z.bindSessionChats,bindSessionsLoading:Z.bindSessionsLoading,newBindSessionIdx:Z.newBindSessionIdx,setNewBindSessionIdx:Z.setNewBindSessionIdx,newBindCustomPeer:Z.newBindCustomPeer,setNewBindCustomPeer:Z.setNewBindCustomPeer,refreshBindSessions:Z.refreshBindSessions,onRemoveBinding:e=>void Z.onRemoveBinding(e),onAddBinding:Z.onAddBinding,cronLoading:qe.cronLoading,agentCronJobs:qe.agentCronJobs,onSetCronJobAgent:(e,t)=>void qe.onSetCronJobAgent(e,t)};return{hasToken:v,a:n,chat:g,language:e,data:L,loading:R,displayError:ne,navigate:w,routeAgentId:T,busy:Ce,listSearchQuery:q,openAddAgentModal:Xe,openDuplicateAgentModal:nt,duplicateSourceId:be,onSelectDuplicateSource:tt,panel:ae,setPanel:B,modalTitle:wt,modalSubtitle:Tt,footerSaveDisabled:bt,savedFlash:Be,handleModalFooterSave:St,onAgentModalOpenChange:Ct,addAgentModalOpen:ve,setAddAgentModalOpen:ye,createWorkspaceSuggestedRef:G,createModalError:_e,setCreateModalError:W,createDisplayName:se,setCreateDisplayName:ce,createAgentId:ue,setCreateAgentId:de,createDescription:pe,setCreateDescription:V,createWorkspace:he,setCreateWorkspace:H,createModel:ge,setCreateModel:U,onCreate:it,currentLanguageLabel:e===`zh`?`中文`:`English`,applyCreateWorkspaceSuggestion:Ye,deleteDialogOpen:r,setDeleteDialogOpen:i,deletePurge:d,deleteTarget:s,setDeleteTarget:u,deleteConfirmText:p,setDeleteConfirmText:m,performDelete:ut,editorPanelProps:Dt}}function Hn(){let e=Vn();return e.hasToken?(0,Q.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 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.jsx)(En,{a:e.a,agents:e.data.agents,searchQuery:e.listSearchQuery,onOpenAgent:t=>e.navigate(ke(t)),onChatWithAgent:t=>{let n=t.trim().toLowerCase();try{globalThis.localStorage?.setItem(Re,n)}catch{}e.navigate(`/chat/new`,{state:{agentId:n}})},busy:e.busy}):null,e.routeAgentId&&e.hasToken?(0,Q.jsx)(Tt,{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)(bn,{...e.editorPanelProps})}):null,(0,Q.jsx)(On,{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)(bt,{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)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,Q.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:e.a.title}),(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.a.needToken})]})}export{nt as AgentBrowserSettingsPage,rt as AgentDefaultsTabbedPage,Hn as AgentsSettingsPanel};