limixbot 0.2.13 → 0.3.2

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 (140) hide show
  1. package/dist/assets/{ActivityPanel-Crvi6UFN.js → ActivityPanel-BDwrkDBX.js} +1 -1
  2. package/dist/assets/{App-DBQxC6tF.js → App-Cb2UOJS6.js} +97 -97
  3. package/dist/assets/{AppEventEditor-BKkrL3lm.js → AppEventEditor-B383TR3m.js} +1 -1
  4. package/dist/assets/BotSettingsDialog-CbbZerHF.js +16 -0
  5. package/dist/assets/{BrowserPanel-CXiPysF8.js → BrowserPanel-DY-yCZ9T.js} +1 -1
  6. package/dist/assets/{BrowserProfilesManager-B5ZQeFJ9.js → BrowserProfilesManager-BmOMzdgM.js} +1 -1
  7. package/dist/assets/{CloudAddDialog-CjSOW3Ui.js → CloudAddDialog-DP5-ha1H.js} +1 -1
  8. package/dist/assets/{ComputerFilesPane-VwEQWopG.js → ComputerFilesPane-CB2u6MXN.js} +1 -1
  9. package/dist/assets/{ComputerPanel-C4y6Mvwd.js → ComputerPanel-DI10c-7Z.js} +2 -2
  10. package/dist/assets/{DataPanel-CeaLVEeb.js → DataPanel-fAjB6GSn.js} +1 -1
  11. package/dist/assets/{DesktopViewer-CfxFVwdn.js → DesktopViewer-mWGetNwB.js} +1 -1
  12. package/dist/assets/{FilesView-B9X_qlkn.js → FilesView-CLR6NiY2.js} +1 -1
  13. package/dist/assets/{GrokMoveDialog-CuC9v4Fd.js → GrokMoveDialog-lZOa5ZKz.js} +2 -2
  14. package/dist/assets/{InspectorPanel-B6ZAVTyD.js → InspectorPanel-lOPEUSb8.js} +1 -1
  15. package/dist/assets/{KeyboardShortcutsModal-DkoOxF2t.js → KeyboardShortcutsModal-BGRMc9wJ.js} +1 -1
  16. package/dist/assets/{LiveDesktop-BsPQ6sGB.js → LiveDesktop-LRjYEzUz.js} +1 -1
  17. package/dist/assets/{LocalVmWorkspace-U6rVY7_g.js → LocalVmWorkspace-Bwq-s97O.js} +1 -1
  18. package/dist/assets/{MacLocalControl-CC-lKazM.js → MacLocalControl-DuTxY3A3.js} +1 -1
  19. package/dist/assets/{MarkdownFilePreview-D0maDIQ1.js → MarkdownFilePreview-B69UWgiO.js} +1 -1
  20. package/dist/assets/{MenuMotion-CLF0GByT.js → MenuMotion-DKMkKESs.js} +1 -1
  21. package/dist/assets/NewBotDialog-Bpi6-xSj.js +1 -0
  22. package/dist/assets/{PhoneAppDialog-CTPZwJnL.js → PhoneAppDialog-V46SXKel.js} +1 -1
  23. package/dist/assets/{PlacesRail-D510vk5R.js → PlacesRail-4ErVypbT.js} +1 -1
  24. package/dist/assets/{PluginsPanel-BC0YDZ8h.js → PluginsPanel-Cw8XeQBF.js} +1 -1
  25. package/dist/assets/{ProIntroduction-BIiaveWm.js → ProIntroduction-DPYk--IK.js} +1 -1
  26. package/dist/assets/{RemoteAgentSettingsPanel-OVWheJHu.js → RemoteAgentSettingsPanel-qxzESq_H.js} +1 -1
  27. package/dist/assets/{RoomPanel-mDRTZ2vs.js → RoomPanel-DaoRmKS_.js} +1 -1
  28. package/dist/assets/{RoutinesPage-9VDuovqw.js → RoutinesPage-CD1DvtyW.js} +2 -2
  29. package/dist/assets/{SettingsModal-BHJvNrwz.js → SettingsModal-C359HBUM.js} +1 -1
  30. package/dist/assets/{ShareTeamDialog-C4go2USY.js → ShareTeamDialog-rc1xx02E.js} +1 -1
  31. package/dist/assets/{SignedInSites-Cm_X_p_X.js → SignedInSites-CPp5ofCJ.js} +1 -1
  32. package/dist/assets/TeamLibraryPanel-D-iDVZPU.js +1 -0
  33. package/dist/assets/{TeamMapPage-CkYOrZ7X.js → TeamMapPage-od4f3NJr.js} +1 -1
  34. package/dist/assets/{TriggersPage-_qYPJ97Z.js → TriggersPage-D2ovyRGM.js} +1 -1
  35. package/dist/assets/{VisibilitySection-CpwyInUL.js → VisibilitySection-oSi2vtmx.js} +1 -1
  36. package/dist/assets/{WebhookTrigger-CfspvK5m.js → WebhookTrigger-CyP8At0y.js} +1 -1
  37. package/dist/assets/{WorksOnGrid-BtfeNPO2.js → WorksOnGrid-DbfBPgPv.js} +1 -1
  38. package/dist/assets/{abnfDiagram-YUKMZFIV-qTIn3JJ1.js → abnfDiagram-YUKMZFIV-C7wn2CLu.js} +1 -1
  39. package/dist/assets/{activity-CEhxqMcq.js → activity-Cru8B1z7.js} +1 -1
  40. package/dist/assets/{architectureDiagram-47P4ROYG-BQls0L4i.js → architectureDiagram-47P4ROYG-DgFc7YIC.js} +1 -1
  41. package/dist/assets/{blockDiagram-E7TT5TSB-DMD6noIL.js → blockDiagram-E7TT5TSB-qR-t8DMo.js} +1 -1
  42. package/dist/assets/{c4Diagram-CRA5TL53-CIp2zuwT.js → c4Diagram-CRA5TL53-DdmUjVbB.js} +1 -1
  43. package/dist/assets/{calendar-days-Di_J-dvc.js → calendar-days-CN7x0QvP.js} +1 -1
  44. package/dist/assets/channel-BIffrG1w.js +1 -0
  45. package/dist/assets/{chunk-2Q5K7J3B-BBkqbpZ4.js → chunk-2Q5K7J3B-D09jrdDt.js} +1 -1
  46. package/dist/assets/{chunk-5VM5RSS4-JdwNE0CO.js → chunk-5VM5RSS4-DJXT-XDN.js} +1 -1
  47. package/dist/assets/{chunk-7TKQ45FW-D_Zh7_1M.js → chunk-7TKQ45FW-CaULsRlr.js} +1 -1
  48. package/dist/assets/{chunk-AW2ZBBNX-BvSbOQeA.js → chunk-AW2ZBBNX-BcEB179w.js} +1 -1
  49. package/dist/assets/{chunk-FVRAUYC3-CXYsdaIb.js → chunk-FVRAUYC3-DMhPq4_N.js} +2 -2
  50. package/dist/assets/{chunk-HTAEGDNF-CO93FKYG.js → chunk-HTAEGDNF-DcoWRcH-.js} +1 -1
  51. package/dist/assets/{chunk-JWPE2WC7-Ko0D98Sv.js → chunk-JWPE2WC7-CpN6DEZO.js} +1 -1
  52. package/dist/assets/{chunk-KQW6MTUR-DBGMbUnJ.js → chunk-KQW6MTUR-BxIldIqB.js} +1 -1
  53. package/dist/assets/{chunk-XXDRQBXY-PVMPph1f.js → chunk-XXDRQBXY--M4TxaOR.js} +1 -1
  54. package/dist/assets/{classDiagram-v2-K4WV4PDN-Z-SRrzrQ.js → classDiagram-v2-K4WV4PDN-DQUUn5pg.js} +1 -1
  55. package/dist/assets/{coins-QIRjm19F.js → coins-DxQLVJqa.js} +1 -1
  56. package/dist/assets/{core-Cb-3LQeb.js → core-CjjU--NA.js} +1 -1
  57. package/dist/assets/{cose-bilkent-JH36ORCC-DcOhjasx.js → cose-bilkent-JH36ORCC-DCCMLnpT.js} +1 -1
  58. package/dist/assets/{cynefin-EF2NZ3EQ-D9Pv76Si.js → cynefin-EF2NZ3EQ-iK--S4gB.js} +1 -1
  59. package/dist/assets/{cynefinDiagram-3GCD6N5R-1Nlm6fT4.js → cynefinDiagram-3GCD6N5R-DiwEQVzk.js} +1 -1
  60. package/dist/assets/{dagre-W4DXFKR2-CW-TdWBz.js → dagre-W4DXFKR2-Bb-WXIrp.js} +1 -1
  61. package/dist/assets/{diagram-2UJZ2QOL-DJYwBSWN.js → diagram-2UJZ2QOL-CU1G-LPy.js} +1 -1
  62. package/dist/assets/{diagram-OVF4WLC6-ZajDgMU2.js → diagram-OVF4WLC6-KUL_hQtY.js} +1 -1
  63. package/dist/assets/{diagram-PFPMY2P6-D03UoQDq.js → diagram-PFPMY2P6-Du0EMvGo.js} +1 -1
  64. package/dist/assets/{diagram-UMYRVEAY-B9gI6La0.js → diagram-UMYRVEAY-BUNv47Vc.js} +1 -1
  65. package/dist/assets/{diagram-YEKJPTXX-Dxzg_fDQ.js → diagram-YEKJPTXX-DyWO406P.js} +1 -1
  66. package/dist/assets/{diagram-ZIFT7M5P-Cv6eTFZE.js → diagram-ZIFT7M5P-DGps1w58.js} +1 -1
  67. package/dist/assets/{ebnfDiagram-VR2GEFS7-BCUklW6x.js → ebnfDiagram-VR2GEFS7-BxaaJRK8.js} +1 -1
  68. package/dist/assets/{elk-IJKZMXRS-VcZs96wT.js → elk-IJKZMXRS-BuVZZmTr.js} +1 -1
  69. package/dist/assets/{erDiagram-O2IAPWRE-CJ61fO-Z.js → erDiagram-O2IAPWRE-qhhsO6Fp.js} +1 -1
  70. package/dist/assets/{file-up-BObBqrEg.js → file-up-BiK20g0M.js} +1 -1
  71. package/dist/assets/{flowDiagram-OXPTDLAJ-CQMoLXxB.js → flowDiagram-OXPTDLAJ-BsRrcKnA.js} +1 -1
  72. package/dist/assets/{ganttDiagram-R7TSEDQI-ev5i74AH.js → ganttDiagram-R7TSEDQI-jVqCmREp.js} +1 -1
  73. package/dist/assets/{gitGraphDiagram-XJZIOB7I-B8MGdCiz.js → gitGraphDiagram-XJZIOB7I-COi9bChD.js} +1 -1
  74. package/dist/assets/{import-name-6aD0J6QH.js → import-name-CrWA8Hw3.js} +1 -1
  75. package/dist/assets/{index-CRF26t5P.js → index-BIC6c7Sg.js} +1 -1
  76. package/dist/assets/{index-DgGTgaCO.js → index-Bhz3ZrDI.js} +2 -2
  77. package/dist/assets/{index-Dpov1WyC.js → index-Dy5VWChH.js} +1 -1
  78. package/dist/assets/{infoDiagram-5W2HQ5XZ-CoqaIohe.js → infoDiagram-5W2HQ5XZ-CUfzOgVW.js} +1 -1
  79. package/dist/assets/{ishikawaDiagram-K3B6WC7H-BMzA3Pkb.js → ishikawaDiagram-K3B6WC7H-DMR_Ey1I.js} +1 -1
  80. package/dist/assets/{journeyDiagram-COXZFDF6-DLNIN037.js → journeyDiagram-COXZFDF6-UiPc_2sp.js} +1 -1
  81. package/dist/assets/{kanban-definition-P3RFRI5V-savLUzO8.js → kanban-definition-P3RFRI5V-VvQXCMxr.js} +1 -1
  82. package/dist/assets/{mcp-servers-D2hHUxUp.js → mcp-servers-CBCpG62C.js} +1 -1
  83. package/dist/assets/{mermaid.core-1h5EGl1v.js → mermaid.core-BZKmLobY.js} +4 -4
  84. package/dist/assets/{mindmap-definition-LZFPQGKD-hMbAYcVv.js → mindmap-definition-LZFPQGKD-BJi3q0s6.js} +1 -1
  85. package/dist/assets/{minimize-63hYzV5y.js → minimize-B78LHbd3.js} +1 -1
  86. package/dist/assets/{monitor-DOeLdhQc.js → monitor-UBjV7Qf5.js} +1 -1
  87. package/dist/assets/{new-bot-DkcWCdL_.js → new-bot-D0DDXTKe.js} +1 -1
  88. package/dist/assets/{org-library-C-rnQ1YG.js → org-library-BdlqWown.js} +1 -1
  89. package/dist/assets/{package-format-CMpBgycc.js → package-format-EwGfXp1v.js} +1 -1
  90. package/dist/assets/{pegDiagram-BGZESJAR-BIY55aib.js → pegDiagram-BGZESJAR-C6W87HN9.js} +1 -1
  91. package/dist/assets/{pieDiagram-CAPJLFHJ-DR8o8piD.js → pieDiagram-CAPJLFHJ-B1E_Ycub.js} +1 -1
  92. package/dist/assets/{quadrantDiagram-GDMTTRAM-Dqb1703W.js → quadrantDiagram-GDMTTRAM-BasGTzC_.js} +1 -1
  93. package/dist/assets/{rail-Ok1gt1lN.js → rail-BFRrwJ6b.js} +1 -1
  94. package/dist/assets/{railroadDiagram-SM67HX2B-ZWJ9xWQY.js → railroadDiagram-SM67HX2B-BZVzOUlx.js} +1 -1
  95. package/dist/assets/{remote-desktop-panel-ganxVzJo.js → remote-desktop-panel--ikzFjV8.js} +1 -1
  96. package/dist/assets/{requirementDiagram-X7JNWC4A-Cjv_VLZj.js → requirementDiagram-X7JNWC4A-C8s2XakO.js} +1 -1
  97. package/dist/assets/{sankeyDiagram-UM26HJRW-ChHoiXzB.js → sankeyDiagram-UM26HJRW-CCCP1mnQ.js} +1 -1
  98. package/dist/assets/{sequenceDiagram-ZO4K6R2Y-B67gwOH0.js → sequenceDiagram-ZO4K6R2Y-BvwC79vw.js} +1 -1
  99. package/dist/assets/{sizeCapture-INFHLROL-DOr4ZALb.js → sizeCapture-INFHLROL-DzRVDjCL.js} +1 -1
  100. package/dist/assets/{stateDiagram-v2-TBUQTH76-DnoBtm-E.js → stateDiagram-v2-TBUQTH76-CKVmZfLe.js} +1 -1
  101. package/dist/assets/{styles-BcVNrxGE.js → styles-Bo7bYxUt.js} +5 -5
  102. package/dist/assets/styles-bUbK33f1.css +1 -0
  103. package/dist/assets/{swimlanes-N4OXWK64-2TFXb7MH.js → swimlanes-N4OXWK64-BaSkTx2s.js} +1 -1
  104. package/dist/assets/swimlanesDiagram-K3J5GTZL-D67LlSLv.js +8 -0
  105. package/dist/assets/{team-share-C9qIusMs.js → team-share-BgI5VFVf.js} +1 -1
  106. package/dist/assets/{timeline-definition-YOQAKGHF-4zjxAMyG.js → timeline-definition-YOQAKGHF-Np9aXu8d.js} +1 -1
  107. package/dist/assets/{usecaseDiagram-VIAY4XPW-CCfZ1eoO.js → usecaseDiagram-VIAY4XPW-CaHpESyo.js} +1 -1
  108. package/dist/assets/{vennDiagram-BLWOH2XV-h7rTFRTN.js → vennDiagram-BLWOH2XV-BpnM9QrV.js} +1 -1
  109. package/dist/assets/vi-B8BbvT0G.js +15 -0
  110. package/dist/assets/{wardleyDiagram-YMQ3BMBF-CXwA22zv.js → wardleyDiagram-YMQ3BMBF-Cb0psm8G.js} +1 -1
  111. package/dist/assets/{xychartDiagram-TAQBALBS-d4qol5BJ.js → xychartDiagram-TAQBALBS-Bi_SjN1M.js} +1 -1
  112. package/dist/index.html +3 -3
  113. package/dist/rail.html +5 -5
  114. package/dist-server/container-mcp.js +22 -21
  115. package/dist-server/index.js +529 -523
  116. package/dist-server/openmausbot.js +46 -46
  117. package/dist-server/package.json +1 -1
  118. package/dist-server/pair-cli.js +46 -46
  119. package/dist-server/server/config.js +6 -1
  120. package/dist-server/server/container-computer.js +4 -4
  121. package/dist-server/server/host/team-connections-host.js +2 -2
  122. package/dist-server/server/index.js +21 -4
  123. package/dist-server/server/limix-skill-folder.js +72 -0
  124. package/dist-server/server/mcp-registry.js +2 -2
  125. package/dist-server/server/routes/bot-skills.js +2 -1
  126. package/dist-server/server/service-unit.js +1 -1
  127. package/dist-server/server/skill-library.js +1 -1
  128. package/dist-server/server/team-library.js +2 -2
  129. package/dist-server/shared/grok-import.js +1 -1
  130. package/dist-server/shared/package-format.js +3 -3
  131. package/dist-server/vps-container-mcp.js +22 -21
  132. package/dist-server/workspace-backup.worker.js +20 -20
  133. package/package.json +1 -1
  134. package/dist/assets/BotSettingsDialog-BVTAiGvS.js +0 -16
  135. package/dist/assets/NewBotDialog-D9e-ED-j.js +0 -1
  136. package/dist/assets/TeamLibraryPanel-B-R6YFK-.js +0 -1
  137. package/dist/assets/channel-DRGNbeY-.js +0 -1
  138. package/dist/assets/styles-D-yh7Z23.css +0 -1
  139. package/dist/assets/swimlanesDiagram-K3J5GTZL-C_836Lnu.js +0 -8
  140. package/dist/assets/vi-KgT8L8Qj.js +0 -15
@@ -1,16 +0,0 @@
1
- import{c as Ce,t as s,b as ee,aA as Os,j as e,i as Ae,ae as pe,a as O,r as x,S as Lt,ah as Mt,o as Es,X as Tt}from"./styles-BcVNrxGE.js";import{fa as Rs,fb as Is,_ as Ve,bu as As,dd as Bt,w as Ls,fc as Ms,fd as Ts,E as Dt,fe as Bs,N as Ft,eo as Ds,x as Fs,ff as st,bp as at,fg as $t,n as se,u as B,fh as $s,ad as Ye,F as zt,A as Ht,S as nt,a9 as Pe,T as _t,R as zs,fi as Hs,fj as _s,fk as Us,fl as Ks,fm as qs,fn as rt,fo as Ws,fp as Vs,fq as Ys,fr as Gs,b5 as Js,fs as Qs,ft as Xs,fu as Zs,I as ea,fv as ke,bL as Ge,fw as ta,aE as L,aK as X,e8 as sa,dF as aa,fx as na,aF as He,ck as ra,dU as ia,dV as la,fy as oa,fz as Ut,fA as Kt,fB as ca,fC as da,fD as ua,fE as ma,dI as _e,an as it,fF as Le,fG as pa,fH as je,ar as xa,fI as qt,fJ as lt,ag as Ue,fK as ha,fL as fa,fM as ga,fN as Wt,fO as ya,fP as va,fQ as ba,fR as ka,fS as Q,aT as te,aV as J,fT as ja,fU as wa,fV as Na,d0 as Sa,d as Ca,G as Pa,c_ as Vt,af as Oa,fW as W,aS as ce,fX as fe,fY as Ea,dj as Ra,fZ as Oe,aU as re,f_ as Ia,f$ as Aa,g0 as La,eb as Ma,g1 as ot,g2 as Ta,g3 as Ba,g4 as Da,g5 as Fa,g6 as $a,g7 as za,ay as Ha,g8 as Yt,g9 as _a,ga as Ua,gb as Ka,gc as qa,gd as Wa,ge as Va,gf as Ya,gg as Ga,gh as Ja,gi as Qa,gj as Xa,gk as Za,gl as Je,k as en,B as Ke,gm as tn,gn as sn,go as an,gp as nn,bT as rn,gq as Gt,eS as ln,gr as ct,gs as on,gt as cn,cH as dt,bs as dn,cZ as un,gu as mn,gv as Jt,gw as ve,gx as ut,gy as pn,aI as Me,dW as xn,gz as hn,aN as fn,C as gn,cl as yn,gA as vn,gB as bn,gC as kn,aP as jn}from"./App-DBQxC6tF.js";import{y as Qt,d as ge,a0 as we,a1 as wn,a2 as Nn,a3 as mt,a4 as Te,a5 as Sn,a6 as Cn,a7 as Pn,a8 as On,a9 as En,aa as pt,ab as Rn,ac as In,L as An,K as Ln,B as qe,P as Ee,r as Mn,ad as Tn,$ as Bn,u as Xt}from"./PlacesRail-D510vk5R.js";import{C as Dn}from"./coins-QIRjm19F.js";import{C as he,a as Fn}from"./MenuMotion-CLF0GByT.js";import{b as Z,m as Zt,i as We,f as Qe,c as me,d as xt,e as Ne,o as $n,g as zn,h as oe,n as Be,t as es,s as Xe,j as ts,k as Hn,l as _n,p as Un,r as ss,q as Kn,u as qn,w as Wn,x as as,y as ns,z as ht,B as Vn,C as rs,R as ft,D as Yn,E as Gn,F as Jn,G as Qn,H as Xn,J as Zn,O as er,K as tr,L as is,N as sr,V as ar,P as nr,M as rr,A as ir,a as lr,S as or,I as cr}from"./VisibilitySection-CpwyInUL.js";import{s as dr,r as ur,a as mr,R as pr}from"./ComputerFilesPane-VwEQWopG.js";import{M as gt}from"./monitor-DOeLdhQc.js";import{a as ls,m as os,b as xr,c as hr}from"./mcp-servers-D2hHUxUp.js";import{R as fr}from"./RoutinesPage-9VDuovqw.js";import{S as gr}from"./SignedInSites-Cm_X_p_X.js";import"./index-DgGTgaCO.js";import"./org-library-C-rnQ1YG.js";import"./package-format-CMpBgycc.js";import"./WorksOnGrid-BtfeNPO2.js";import"./ProIntroduction-BIiaveWm.js";import"./remote-desktop-DDRRx8uY.js";const yr=[["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M19 16v6",key:"tddt3s"}],["path",{d:"M21 12.598V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8.5",key:"1glfrc"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}]],vr=Ce("calendar-plus",yr);const br=[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]],kr=Ce("library",br);const jr=[["rect",{width:"3",height:"8",x:"13",y:"2",rx:"1.5",key:"diqz80"}],["path",{d:"M19 8.5V10h1.5A1.5 1.5 0 1 0 19 8.5",key:"183iwg"}],["rect",{width:"3",height:"8",x:"8",y:"14",rx:"1.5",key:"hqg7r1"}],["path",{d:"M5 15.5V14H3.5A1.5 1.5 0 1 0 5 15.5",key:"76g71w"}],["rect",{width:"8",height:"3",x:"14",y:"13",rx:"1.5",key:"1kmz0a"}],["path",{d:"M15.5 19H14v1.5a1.5 1.5 0 1 0 1.5-1.5",key:"jc4sz0"}],["rect",{width:"8",height:"3",x:"2",y:"8",rx:"1.5",key:"1omvl4"}],["path",{d:"M8.5 5H10V3.5A1.5 1.5 0 1 0 8.5 5",key:"16f3cl"}]],cs=Ce("slack",jr);const wr=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],Nr=Ce("tag",wr),Sr=[{id:"overview",label:"Overview",labelKey:"botSettings.sections.overview",icon:Rs,keywords:["summary","status","what it does","won't","prompt","what the model sees"]},{id:"identity",label:"Identity",labelKey:"botSettings.sections.identity",icon:Is,keywords:["name","title","avatar","blurb","instructions"]},{id:"slack",label:"Slack",icon:cs,keywords:["slack","slack app","admin","message","direct messages","mentions"]},{id:"soul",label:"Soul",labelKey:"botSettings.sections.soul",icon:Ve,keywords:["standing instructions","instructions","persona","rules","soul.md"]},{id:"skills",label:"Skills",labelKey:"botSettings.sections.skills",icon:As,keywords:["skills","learned","procedures","teach"]},{id:"memory",label:"Memory",labelKey:"botSettings.sections.memory",icon:Bt,keywords:["memory","notes","remember","topics"]},{id:"library",label:"Library",labelKey:"botPanel.tab.library",icon:kr,keywords:["library","made","pages","apps","files","published"]},{id:"routines",label:"Routines",labelKey:"botSettings.sections.routines",icon:Ls,keywords:["schedule","routines","cron","tasks"]},{id:"access",label:"Access",labelKey:"botSettings.sections.access",icon:Ms,keywords:["works on","computer","vm","cloud","vps","folder","workspace","browser","connected apps","composio","webhooks","always allow","grants","tool selection","tools","mcp","allow","exclude"]},{id:"model",label:"Model",labelKey:"botSettings.sections.model",icon:Ts,keywords:["engine","model","provider","cli","effort"]},{id:"permissions",label:"Permissions",labelKey:"botSettings.sections.permissions",icon:Dt,keywords:["auto mode","approve","auto approve","review","routine approvals","coordination","chief of staff","section"]},{id:"voice",label:"Voice & alerts",labelKey:"botSettings.sections.voice",icon:Bs,keywords:["voice","alerts","notifications","speak"]},{id:"visibility",label:"Who can see it",labelKey:"botSettings.visibility.title",icon:Ft,keywords:["visibility","who can see","private","people","admins","members","access","hide"]},{id:"history",label:"History",labelKey:"botSettings.sections.history",icon:Ds,keywords:["history","changes","undo","rollback","log"]},{id:"usage",label:"Usage",labelKey:"botSettings.sections.usage",icon:Dn,keywords:["tokens","cost","billing"]}],yt={completed:"botOverview.routine.last.completed",failed:"botOverview.routine.last.failed",missed:"botOverview.routine.last.missed",cancelled:"botOverview.routine.last.cancelled",running:"botOverview.routine.last.running",queued:"botOverview.routine.last.queued",waiting:"botOverview.routine.last.waiting"};function Cr(t,a=ee()){if(!t||a==="en")return null;if(t.paused)return s("botOverview.routine.paused",{name:t.name});const n=t.lastRun;if(n&&!Object.hasOwn(yt,n.status))return null;try{return[s("botOverview.routine.line",{schedule:Fs(t.schedule),name:t.name}),...t.nextRunAt!=null?[s("botOverview.routine.next",{time:st(t.nextRunAt)})]:[],...n?[s(yt[n.status],{time:st(n.at)})]:[]].join(" ")}catch{return null}}const vt={"Works in its private workspace.":"botOverview.line.privateWorkspace","Has the built-in browser.":"botOverview.line.browser","Has no connected apps.":"botOverview.line.noApps","Won't act on a schedule.":"botOverview.line.noSchedule","Can talk to the other bot.":"botOverview.line.talksToOne","Talks only to the bots chosen for it.":"botOverview.line.talksToChosen","Cannot initiate contact with other bots.":"botOverview.line.noPeerContact","Command approvals use Ask mode; saved permissions and provider rules still apply.":"botOverview.line.askMode","Command approvals follow the provider's custom configuration.":"botOverview.line.customApprovals","Asks before contacting other bots.":"botOverview.line.asksPeers","Can't use a computer.":"botOverview.line.noComputer","Profile proposal cards require your approval.":"botOverview.line.profileApproval","Connected apps could not be checked.":"botOverview.line.appsUnchecked"},bt={"Auto; availability is checked when a task starts":"botOverview.preference.auto","cloud computer":"botOverview.preference.cloud","Local VM":"botOverview.preference.vm","this computer":"botOverview.preference.local","browser only":"botOverview.preference.browser"};function kt(t,a){return!a||a.map(n=>n||"General").join(", ")!==t?t:a.map(n=>n||s("botAccess.teams.general")).join(", ")}const jt=t=>Object.hasOwn(bt,t)?s(bt[t]):t,wt=(t,a,n)=>Number(t)===1?a:n,Pr=[{line:/^Can talk to all (\d+) other bots, in any department\.$/,key:()=>"botOverview.line.talksToAll",params:([,t])=>({count:Number(t)})},{line:/^Also in charge of these departments: (.+)\.$/,key:()=>"botOverview.line.alsoInCharge",params:([,t],a)=>({departments:kt(t,a)})},{line:/^Can talk to (\d+) other bots? in its (?:section|department)\.$/,key:([,t])=>wt(t,"botOverview.line.peersSectionOne","botOverview.line.peersSectionMany"),params:([,t])=>({count:Number(t)})},{line:/^Can talk to (\d+) other bots? in its allowed (?:teams|departments)\.$/,key:([,t])=>wt(t,"botOverview.line.peersTeamsOne","botOverview.line.peersTeamsMany"),params:([,t])=>({count:Number(t)})},{line:/^Coordinates its (?:section|department) as Chief of Staff\.$/,key:()=>"botOverview.line.chief",params:()=>({role:s("sidebar.bot.chiefOfStaff")})},{line:/^May also coordinate these (?:teams|departments): (.+)\.$/,key:()=>"botOverview.line.alsoTeams",params:([,t],a)=>({teams:kt(t,a)})}],Or=t=>ee()!=="en"&&Object.hasOwn(Os[ee()]??{},t);function Er(t,a){for(const n of Pr){const l=n.line.exec(t);if(!l)continue;const r=n.key(l);return Or(r)?s(r,n.params(l,a)):t}return null}function De(t,a){if(Object.hasOwn(vt,t))return s(vt[t]);const n=Er(t,a);if(n!==null)return n;const l=/^Can use (\d+) connected apps?: (.+)\.$/.exec(t);if(l)return s(l[1]==="1"?"botOverview.line.appsOne":"botOverview.line.appsMany",{count:Number(l[1]),apps:l[2]});const r=ee()==="en"?null:/^Computer preference: (.+), which isn't available on My Cloud\.$/.exec(t);if(r)return s("botOverview.line.computerNotOnCloud",{preference:jt(r[1])});const i=/^Computer preference: (.+)\.$/.exec(t);if(i)return s("botOverview.line.computer",{preference:jt(i[1])});const c=/^Works in (.+)\.$/.exec(t);if(c)return s("botOverview.line.folder",{folder:c[1]});const d=/^Knows how to (.+)\.$/.exec(t);if(d)return s("botOverview.line.skill",{skill:d[1]});const o=/^Listens for “(.+)” webhooks\.$/.exec(t);return o?s("botOverview.line.webhook",{name:o[1]}):t}const Nt={name:"approval.applied.field.name",title:"approval.applied.field.title",description:"approval.applied.field.description",soul:"approval.applied.field.soul",cwd:"approval.applied.field.cwd",notifications:"approval.applied.field.notifications",speakReplies:"approval.applied.field.speakReplies"};function Rr(t,a=ee()){const n=/^(\w+): /.exec(t)?.[1];return a==="en"||!n||!Object.hasOwn(Nt,n)?t:`${s(Nt[n])}: ${t.slice(n.length+2)}`}function Ir({data:t,error:a,open:n,onToggle:l}){return e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("button",{type:"button",onClick:l,"aria-expanded":n,className:"flex w-full items-center justify-between gap-3 text-left",children:[e.jsx("span",{className:"text-[15px] font-medium text-ink",children:t?s("botOverview.promptPreviewCount",{bytes:t.totalBytes.toLocaleString(Ae()),tokens:t.approxTokens.toLocaleString(Ae())}):s("botOverview.promptPreview")}),e.jsx(pe,{size:16,className:O("shrink-0 text-ink-secondary transition-transform",n&&"rotate-180")})]}),n&&!t&&a&&e.jsx("div",{className:"mt-3 text-[13px] text-ink-secondary",children:s("botOverview.promptError")}),n&&!t&&!a&&e.jsx("div",{className:"mt-3 text-[13px] text-ink-secondary",children:s("botOverview.loading")}),n&&t&&e.jsxs("div",{className:"mt-3 flex flex-col gap-2",children:[t.sections.map(r=>e.jsxs("details",{className:"rounded-lg border border-hairline/40 bg-inset px-3 py-2",children:[e.jsxs("summary",{className:"flex cursor-pointer items-center justify-between gap-3 text-[13px] text-ink",children:[e.jsx("span",{children:r.label}),e.jsx("span",{className:"shrink-0 tabular-nums text-ink-secondary",children:s("botOverview.bytes",{count:r.bytes.toLocaleString(Ae())})})]}),e.jsx("pre",{className:"mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-words font-mono text-[12px] leading-relaxed text-ink",children:r.text})]},r.id)),t.note&&e.jsx("div",{className:"text-[11px] text-ink-secondary",children:t.note})]})]})}function Ar({overview:t,refreshError:a,prompt:n,promptError:l,onOpen:r,onSetup:i}){const[c,d]=x.useState(!1);if(!t)return e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("botOverview.loading")});const u=(t.setup??[]).filter(h=>!h.done),p=(h,k)=>s(`botOverview.setup.${h}`)||k;return e.jsxs("div",{className:"flex flex-col gap-4",children:[a&&e.jsx("div",{className:"rounded-lg bg-inset px-3 py-2 text-[13px] text-ink-secondary",children:s("botOverview.refreshError")}),u.length>0&&e.jsxs("div",{className:"rounded-xl border border-accent/30 bg-accent/[0.06] p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botSetup.ideas")}),e.jsx("p",{className:"mt-1 text-[13px] text-ink-secondary",children:s("botSetup.optional")}),e.jsx("ul",{className:"mt-2 flex flex-col gap-1",children:u.map(h=>e.jsx("li",{children:h.section?e.jsxs("button",{type:"button",onClick:()=>r(h.section),className:"flex w-full items-center gap-2.5 rounded-lg px-1 py-1 text-left text-[13px] text-ink hover:bg-inset",children:[e.jsx(at,{"aria-hidden":"true",size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"flex-1",children:p(h.id,h.label)}),e.jsx(he,{size:14,"aria-hidden":"true",className:"shrink-0 text-ink-secondary rtl:-scale-x-100"})]}):e.jsxs("div",{className:"flex items-center gap-2.5 px-1 py-1 text-[13px] text-ink",children:[e.jsx(at,{"aria-hidden":"true",size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("span",{children:p(h.id,h.label)})]})},h.id))}),i&&e.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[e.jsxs("button",{type:"button",onClick:i,className:"flex items-center gap-1.5 rounded-lg bg-accent px-3 py-2 text-[13px] font-medium text-accent-ink hover:brightness-110",children:[e.jsx(Ve,{size:14})," ",s("botSetup.withBot")]}),e.jsx("span",{className:"text-[12px] text-ink-secondary",children:s("botSetup.help")})]})]}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:t.who.name}),t.who.title&&e.jsx("div",{className:"mt-0.5 text-[13px] text-ink-secondary",children:t.who.title}),t.who.blurb&&e.jsx("p",{className:"mt-2 text-[13px] leading-relaxed text-ink",children:t.who.blurb}),t.who.soulLead&&e.jsxs("div",{className:"mt-3 rounded-lg bg-inset px-3 py-2.5",children:[e.jsx("p",{className:"text-[13px] leading-relaxed text-ink-secondary",children:t.who.soulLead}),e.jsx("button",{type:"button",onClick:()=>r("soul"),className:"mt-1.5 rounded-md text-[12px] font-medium text-accent-text hover:underline",children:s("botOverview.readAll")})]})]}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botOverview.does")}),t.does.length===0?e.jsx("p",{className:"mt-2 text-[13px] text-ink-secondary",children:s("botOverview.doesEmpty")}):e.jsx("ul",{className:"mt-2 flex flex-col gap-1.5 text-[13px] leading-relaxed text-ink",children:t.does.map((h,k)=>e.jsx("li",{children:Cr(t.doesRoutines?.[k])??De(h)},k))})]}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botOverview.canReach")}),t.reaches.length===0?e.jsx("p",{className:"mt-2 text-[13px] text-ink-secondary",children:s("botOverview.reachEmpty")}):e.jsx("ul",{className:"mt-2 flex flex-col gap-1.5 text-[13px] leading-relaxed text-ink",children:t.reaches.map((h,k)=>e.jsx("li",{children:De(h,t.managedSections)},k))})]}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botOverview.wont")}),e.jsx("ul",{className:"mt-2 flex flex-col gap-1.5 text-[13px] leading-relaxed text-ink",children:t.wont.map((h,k)=>e.jsx("li",{children:De(h,t.managedSections)},k))})]}),e.jsx(Ir,{data:n,error:l,open:c,onToggle:()=>d(h=>!h)}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botOverview.recentChanges")}),e.jsxs("button",{type:"button",onClick:()=>r("history"),className:"shrink-0 text-[12px] text-ink-secondary hover:text-ink",children:[s("botOverview.viewAll")," ",e.jsx(he,{size:14,"aria-hidden":"true",className:"inline align-[-2px] rtl:-scale-x-100"})]})]}),t.recent.length===0?e.jsx("p",{className:"mt-2 text-[13px] text-ink-secondary",children:s("botOverview.recentEmpty")}):e.jsx("ul",{className:"mt-2 flex flex-col gap-1.5 text-[13px] text-ink",children:t.recent.map((h,k)=>e.jsxs("li",{className:"flex items-baseline justify-between gap-3",children:[e.jsx("span",{className:"min-w-0 truncate",children:Rr(h.summary)}),e.jsxs("span",{className:"shrink-0 text-[12px] text-ink-secondary",children:["· ",$t(h.at)]})]},k))})]})]})}function Lr({managementUrl:t}){return e.jsxs("div",{className:"flex flex-col gap-3 text-[13px] leading-relaxed text-ink-secondary",children:[e.jsx("p",{children:s("botSlack.body")}),e.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"flex w-fit items-center gap-2 rounded-lg bg-control px-3 py-2 font-medium text-ink hover:bg-control/70",children:[s("botSlack.manage")," ",e.jsx(Qt,{size:14,"aria-hidden":"true"})]})]})}function Mr(t){if(!t||typeof t!="object")return null;const{available:a,managementUrl:n}=t;if(a!==!0||typeof n!="string")return null;try{return new URL(n).protocol==="https:"?n:null}catch{return null}}function ds(t){const[a,n]=x.useState(null);return x.useEffect(()=>{const l=new AbortController;return se(`/api/bots/${encodeURIComponent(t)}/slack-management`,{signal:l.signal,timeoutMs:1e4}).then(r=>{l.signal.aborted||n({botId:t,url:Mr(r)})}).catch(()=>{l.signal.aborted||n({botId:t,url:null})}),()=>l.abort()},[t]),a?.botId===t?a.url:null}const ne="rounded-lg bg-control px-3 py-1.5 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",Fe="rounded-md px-2 py-1 text-[13px] text-ink-secondary hover:bg-control hover:text-ink disabled:opacity-50",ae=t=>t instanceof Error?t.message:String(t);function us(t){const a=[],n=(r,i,c)=>{r&&a.push(s(r===1?i:c,{count:r}))};n(t.expired,"memory.upkeep.summary.archived.one","memory.upkeep.summary.archived.many"),n(t.duplicates,"memory.upkeep.summary.merged.one","memory.upkeep.summary.merged.many"),n(t.superseded,"memory.upkeep.summary.crossed.one","memory.upkeep.summary.crossed.many"),n(t.organized,"memory.upkeep.summary.filed.one","memory.upkeep.summary.filed.many");const l=a.length?a.join(", "):s("memory.upkeep.summary.none");return l.charAt(0).toUpperCase()+l.slice(1)}function Tr(t,a){const n=t.via==="team-setup"?s("memory.journal.actor.teamSetup"):t.actor==="bot"?a:t.actor==="import"?s("memory.journal.actor.import"):t.actor==="upkeep"?s("memory.journal.actor.upkeep"):s("memory.journal.actor.you"),l=Kn(t.path),r=t.path===Z?l:t.path===qn?s("memory.journal.instructions"):t.path.startsWith("memory/log/")?s("memory.journal.log",{file:l}):s("memory.journal.topic",{file:l}),i=c=>s(c===1?"memory.journal.line.one":"memory.journal.line.many",{count:c});return t.kind==="created"?s("memory.journal.created",{who:n,topic:r,detail:t.added?s("memory.journal.withLines",{lines:i(t.added)}):""}):t.kind==="deleted"?s("memory.journal.deleted",{who:n,topic:r}):t.added&&!t.removed?s("memory.journal.added",{who:n,lines:i(t.added),topic:r}):t.removed&&!t.added?s("memory.journal.removed",{who:n,lines:i(t.removed),topic:r}):s("memory.journal.rewrote",{who:n,lines:i(Math.max(t.added,t.removed)),topic:r})}function ms({changed:t,stale:a,busy:n,onReviewed:l}){return e.jsxs("div",{role:"status",className:"rounded-xl border border-danger/40 bg-card p-4",children:[e.jsx("p",{className:"text-[13px] leading-relaxed text-ink",children:s(a?"memory.lendingReviewStale":"memory.lendingReview")}),t.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mt-2 text-[12px] text-ink-secondary",children:s("memory.lendingReviewChanged")}),e.jsx("ul",{className:"mt-1 space-y-0.5",children:t.map(r=>e.jsx("li",{className:"break-all font-mono text-[12px] text-ink",children:r},r))})]}),e.jsx("button",{type:"button",className:O(ne,"mt-3"),disabled:n,onClick:l,children:s("memory.lendingReviewed")})]})}function Br({bot:t,active:a=!0,onToggle:n}){const{capabilities:l}=ge(),[r,i]=x.useState(null),[c,d]=x.useState(null),[o,u]=x.useState(null),[p,h]=x.useState(null),[k,f]=x.useState(null),[b,y]=x.useState(null),[C,v]=x.useState(null),[w,N]=x.useState(!1),[E,M]=x.useState(null),[F,T]=x.useState(""),[I,z]=x.useState(null),[A,m]=x.useState(!1),[R,D]=x.useState(null),[H,_]=x.useState(!1),[G,Y]=x.useState(!1),{state:U,dispatch:g}=B(),$=$s(U.config),[ie,de]=x.useState(!1),[xe,S]=x.useState(""),K=async j=>{const[P,Re,Ps]=await Promise.all([Qe(t.id),me(t.id),xt(t.id).catch(()=>null)]);if(i(P),D(P.lendingReview??null),d(Re),z(Ps),j){const Ie=await Ne(t.id,j);u({path:Ie.path,text:Ie.text,hash:Ie.hash,dirty:!1,readOnly:j.startsWith("memory/log/")})}};x.useEffect(()=>{if(!a)return;let j=!1;y(null);const P=o?.dirty===!0;return K(P?void 0:o?.path??Z).catch(Re=>{j||y(ae(Re))}),()=>{j=!0}},[a,t.id]);const V=async j=>{y(null),h(null);try{const P=await Ne(t.id,j);u({path:P.path,text:P.text,hash:P.hash,dirty:!1,readOnly:j.startsWith("memory/log/")})}catch(P){y(ae(P))}},q=async j=>{if(o){N(!0),y(null);try{const P=await Xe(t.id,o.path,o.text,j);if(!P.ok){h({path:o.path,current:P.current,currentHash:P.currentHash});return}h(null),f(null),u({...o,text:P.doc.text,hash:P.doc.hash,dirty:!1}),i(P.overview),d(await me(t.id))}catch(P){y(ae(P))}finally{N(!1)}}},le=()=>{!p||!o||(f(o.text),u({...o,text:p.current,hash:p.currentHash,dirty:!1}),h(null))},ye=async j=>{if(window.confirm(s("memory.confirmDelete",{name:j.name}))){y(null);try{const{overview:P}=await ts(t.id,j.path);i(P),d(await me(t.id)),o?.path===j.path&&u(null)}catch(P){y(ae(P))}}},et=async()=>{const j=Hn(F);if(!j){y(s("memory.topicNameError"));return}T(""),await V(`memory/${j}`),u(P=>P&&{...P,dirty:!0,text:P.text||Dr(j)})},js=async j=>{M(j.id),y(null);try{const P=await ss(t.id,j.id);i(P.overview),d(await me(t.id)),o?.path===j.path&&!o.dirty&&u({...o,text:P.text,hash:P.hash}),v(s("memory.restored",{path:j.path}))}catch(P){y(ae(P))}finally{M(null)}},tt=async j=>{y(null),v(null);try{await $n(t.id,j)}catch(P){y(ae(P))}},ws=()=>{const j=t.memoryUpkeep===!1;g({type:"updateBot",botId:t.id,patch:{memoryUpkeep:j}}),z(P=>P&&{...P,enabled:j})},Ns=async()=>{if(!ie){de(!0),S("");try{const j=await se("/api/config",{method:"PATCH",body:JSON.stringify({features:{roomMemoryCapture:!$}})});g({type:"configStatus",config:j})}catch(j){S(j instanceof Error?j.message:s("memory.learnFromRooms.error"))}finally{de(!1)}}},Ss=async()=>{m(!0),y(null),v(null);try{const{report:j,overview:P}=await es(t.id);i(P),d(await me(t.id)),z(await xt(t.id)),o&&!o.dirty&&await V(o.path),v(`${us(j)}.${j.note?` ${j.note}`:""}`)}catch(j){y(ae(j))}finally{m(!1)}},Cs=l.host.homeDir;return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("memory.title")}),e.jsxs("label",{className:"mt-3 flex items-center gap-2 text-[13px] text-ink",children:[e.jsx("input",{type:"checkbox",checked:t.memoryEnabled!==!1,disabled:t.busy,onChange:j=>n(j.target.checked)}),s("memory.enable")]}),e.jsxs("p",{className:"mt-1 text-[13px] text-ink-secondary",children:[s("memory.enableHelp"),t.busy?` ${s("memory.busyHelp")}`:""]}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("memory.notesHelp")}),r&&e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-ink-secondary",title:r.workspacePath,children:Ye(r.workspacePath,Cs)}),e.jsx("button",{type:"button",className:ne,onClick:()=>{tt("obsidian")},children:s("memory.openObsidian")}),e.jsxs("button",{type:"button",className:O(ne,"inline-flex items-center gap-1.5"),onClick:()=>{tt("folder")},children:[e.jsx(zt,{size:14}),s("memory.showFileManager")]})]})]}),R&&e.jsx(ms,{changed:R.changed,stale:H,busy:G,onReviewed:()=>{Y(!0),Zt(t.id,R.token).then(()=>{D(null),_(!1)}).catch(j=>{if(j instanceof Ht&&j.status===409)return _(!0),K();y(ae(j))}).finally(()=>Y(!1))}}),r&&e.jsx($r,{index:r.index}),t.memoryEnabled!==!1&&e.jsx(Fr,{enabled:t.memoryUpkeep!==!1,status:I,tidying:A,onToggle:ws,onTidy:()=>{Ss()},rooms:{enabled:$,saving:ie,error:xe,onToggle:()=>{Ns()}}}),o&&e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"truncate font-mono text-[13px] text-ink",children:o.path}),o.path!==Z&&e.jsx("button",{type:"button",className:Fe,onClick:()=>{V(Z)},children:s("memory.backToIndex")})]}),p&&e.jsx(ps,{botName:t.name,busy:w,onReload:le,onOverwrite:()=>{q(p.currentHash)}}),e.jsx("textarea",{className:O(We,"mt-2 min-h-[200px] resize-y font-mono text-[13px] leading-relaxed"),value:o.text,readOnly:o.readOnly,placeholder:o.path===Z?s("memory.indexPlaceholder"):s("memory.notePlaceholder"),"aria-label":o.path===Z?s("memory.botMemory"):s("memory.fileLabel",{path:o.path}),onChange:j=>u({...o,text:j.target.value,dirty:!0})}),o.readOnly?e.jsx("p",{className:"mt-2 text-[12px] text-ink-secondary",children:s("memory.logsReadOnly")}):e.jsxs("div",{className:"mt-2 flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>{q(o.hash)},disabled:w||!o.dirty,className:ne,children:w?s("memory.saving"):s("memory.save")}),o.dirty&&e.jsx("button",{type:"button",className:Fe,disabled:w,onClick:()=>{V(o.path)},children:s("memory.discard")})]}),k!==null&&e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"mb-1 text-[12px] text-ink-secondary",children:s("memory.unsavedDraft")}),e.jsx("pre",{className:"max-h-[160px] overflow-auto whitespace-pre-wrap rounded-lg border border-hairline/40 bg-inset p-3 font-mono text-[12px] leading-relaxed text-ink",children:k}),e.jsx("button",{type:"button",className:O(Fe,"mt-1"),onClick:()=>f(null),children:s("memory.dismissDraft")})]})]}),r&&e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx(Ct,{title:s("memory.topicFiles"),hint:s("memory.topicFilesHint"),files:r.topics,selected:o?.path,onOpen:j=>{V(j.path)},onDelete:j=>{ye(j)}}),e.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[e.jsx("input",{className:O(We,"py-1.5 text-[13px]"),value:F,placeholder:s("memory.newTopicPlaceholder"),"aria-label":s("memory.newTopicLabel"),onChange:j=>T(j.target.value),onKeyDown:j=>{j.key==="Enter"&&et()}}),e.jsx("button",{type:"button",className:ne,disabled:!F.trim(),onClick:()=>{et()},children:s("memory.newTopic")})]}),r.logs.length>0&&e.jsx("div",{className:"mt-4",children:e.jsx(Ct,{title:s("memory.dailyLogs"),hint:s("memory.dailyLogsHint"),files:r.logs,selected:o?.path,onOpen:j=>{V(j.path)},onDelete:j=>{ye(j)}})})]}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("memory.changes")}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("memory.changesHelp")}),e.jsx("div",{className:"mt-3",children:e.jsx(Ze,{rows:c,botName:t.name,reverting:E,onRevert:j=>{js(j)}})})]}),C&&e.jsx("div",{className:"text-[13px] text-ink-secondary",children:C}),b&&e.jsx("div",{className:"text-[13px] text-danger",children:b})]})}function Dr(t){return`---
2
- title: ${t.replace(/\.md$/,"")}
3
- description:
4
- aliases: []
5
- ---
6
-
7
- `}function Fr({enabled:t,status:a,tidying:n,onToggle:l,onTidy:r,rooms:i}){return e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("memory.upkeep.title")}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("memory.upkeep.help")})]}),e.jsx(nt,{checked:t,"aria-label":s("memory.upkeep.title"),onClick:l})]}),t&&i&&e.jsxs("div",{className:"mt-3 flex items-start justify-between gap-3 border-t border-hairline/40 pt-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:s("memory.learnFromRooms.title")}),e.jsx("p",{className:"mt-0.5 text-[13px] leading-relaxed text-ink-secondary",children:s("memory.learnFromRooms.subtitle")}),a&&!a.modelSteps&&e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("memory.learnFromRooms.noModelSteps")}),i.error&&e.jsx("p",{role:"alert",className:"mt-1 text-[13px] text-danger",children:i.error})]}),e.jsx(nt,{checked:i.enabled,"aria-label":s("memory.learnFromRooms.title"),disabled:i.saving,onClick:i.onToggle,className:"disabled:cursor-wait disabled:opacity-50"})]}),t&&a&&!a.modelSteps&&e.jsx("p",{className:"mt-2 text-[13px] text-ink-secondary",children:s("memory.upkeep.noModelSteps")}),t&&e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-3",children:[e.jsx("button",{type:"button",className:ne,disabled:n,onClick:r,children:n?s("memory.upkeep.tidying"):s("memory.upkeep.tidyNow")}),e.jsxs("span",{className:"text-[13px] text-ink-secondary",children:[a?.lastTidy?s("memory.upkeep.lastTidy",{time:we(a.lastTidy.at,ee()),summary:us(a.lastTidy).toLowerCase()}):s("memory.upkeep.notTidied"),a?.lastCapture&&Be(a.lastCapture)?` ${s(Be(a.lastCapture)===1?"memory.upkeep.lastNoticed.one":"memory.upkeep.lastNoticed.many",{count:Be(a.lastCapture),time:we(a.lastCapture.at,ee())})}`:""]})]})]})}function $r({index:t}){const a=zn(t),n=a.level==="over"?"bg-danger":a.level==="near"?"bg-warning":"bg-accent";return e.jsxs("div",{className:O("rounded-xl p-4",a.level==="over"?"border border-danger/30 bg-danger/10":"bg-card"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 text-[13px]",children:[e.jsx("span",{className:"font-medium text-ink",children:s("memory.capacity.title")}),e.jsx("span",{className:O("text-[12px]",a.level==="over"?"text-danger":"text-ink-secondary"),children:s("memory.capacity.summary",{lines:t.lines,maxLines:t.maxLines,bytes:oe(t.bytes),maxBytes:oe(t.maxBytes)})})]}),e.jsx(St,{label:s("memory.capacity.lines"),share:a.lineShare,fill:n}),e.jsx(St,{label:s("memory.capacity.size"),share:a.byteShare,fill:n}),e.jsx("p",{className:O("mt-2 text-[13px] leading-relaxed",a.level==="over"?"text-danger":"text-ink-secondary"),children:a.warning??s("memory.capacity.sentence",{lines:t.lines,maxLines:t.maxLines,bytes:oe(t.bytes),maxBytes:oe(t.maxBytes),maxLoaded:t.maxLines})}),a.warning&&e.jsx("p",{className:"mt-1 text-[12px] text-ink-secondary",children:s("memory.capacity.sentence",{lines:t.lines,maxLines:t.maxLines,bytes:oe(t.bytes),maxBytes:oe(t.maxBytes),maxLoaded:t.maxLines})})]})}function St({label:t,share:a,fill:n}){const l=`${Math.min(100,Math.round(a*100))}%`;return e.jsxs("div",{className:"mt-2 flex items-center gap-2 text-[12px] text-ink-secondary",children:[e.jsx("span",{className:"w-10 shrink-0",children:t}),e.jsx("div",{className:"h-1.5 flex-1 overflow-hidden rounded-full bg-inset",role:"meter","aria-label":s("memory.capacity.used",{label:t}),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.min(100,Math.round(a*100)),children:e.jsx("div",{className:O("h-full rounded-full",n),style:{width:l}})})]})}function ps({botName:t,busy:a,onReload:n,onOverwrite:l}){return e.jsxs("div",{className:"mt-2 rounded-lg border border-warning/25 bg-warning/10 p-3 text-[13px] leading-relaxed text-ink",children:[e.jsx("div",{className:"font-medium",children:s("memory.conflict.title",{name:t})}),e.jsx("div",{className:"mt-0.5 text-ink-secondary",children:s("memory.conflict.help",{name:t})}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx("button",{type:"button",className:ne,disabled:a,onClick:n,children:s("memory.reload")}),e.jsx("button",{type:"button",className:ne,disabled:a,onClick:l,children:s("memory.overwrite")})]})]})}function Ct({title:t,hint:a,files:n,selected:l,onOpen:r,onDelete:i}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] font-medium uppercase tracking-[0.08em] text-ink-secondary",children:t}),e.jsx("div",{className:"mt-0.5 text-[12px] text-ink-secondary",children:a}),n.length===0?e.jsx("div",{className:"mt-2 text-[13px] text-ink-secondary",children:s("memory.noneYet")}):e.jsx("div",{className:"mt-2 overflow-hidden rounded-lg border border-hairline/40",children:n.map(c=>e.jsxs("div",{className:O("flex items-center gap-2 border-b border-hairline/40 px-3 py-2 last:border-b-0",l===c.path?"bg-control/60":"hover:bg-control/40"),children:[e.jsxs("button",{type:"button",onClick:()=>r(c),className:"flex min-w-0 flex-1 items-center gap-2 text-left",children:[e.jsx(Pe,{size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"truncate font-mono text-[13px] text-ink",children:c.name}),e.jsxs("span",{className:"shrink-0 text-[12px] text-ink-secondary",children:[oe(c.bytes)," · ",we(c.modifiedAt,ee())]})]}),e.jsx("button",{type:"button",onClick:()=>i(c),"aria-label":s("memory.deleteFile",{name:c.name}),title:s("memory.delete"),className:"shrink-0 rounded-md p-1 text-ink-secondary hover:bg-control hover:text-danger",children:e.jsx(_t,{size:14})})]},c.path))})]})}function Ze({rows:t,botName:a,reverting:n,onRevert:l,now:r=Date.now()}){return t?t.length===0?e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("memory.noChanges")}):e.jsx("div",{className:"flex flex-col gap-2",children:t.map(i=>{const c=_n(i),d=Un(i);return e.jsxs("div",{className:"rounded-lg bg-inset px-3 py-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1 text-[13px] leading-relaxed text-ink",children:[e.jsx("span",{children:Tr(i,a)})," · ",e.jsx("span",{className:"text-ink-secondary",children:we(i.at,ee(),r)}),c&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"text-ink-secondary",children:d?s(d,i.threadTitle?{title:i.threadTitle}:void 0):c})]})]}),i.canRevert?e.jsxs("button",{type:"button",disabled:n!==null,onClick:()=>l(i),className:"inline-flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-[12px] font-medium text-accent-text hover:bg-accent/10 disabled:opacity-50",children:[e.jsx(zs,{size:12}),n===i.id?s("memory.undoing"):s("memory.undo")]}):e.jsx("span",{className:"shrink-0 text-[12px] text-ink-secondary",title:i.revertUnavailableReason,children:s("memory.cantUndo")})]}),i.diff&&e.jsxs("details",{className:"mt-1",children:[e.jsxs("summary",{className:"cursor-pointer text-[12px] text-ink-secondary",children:["+",i.added," −",i.removed," · ",s("memory.showChanged")]}),e.jsx("pre",{className:"mt-1 max-h-[240px] overflow-auto whitespace-pre-wrap rounded-md bg-card p-2 font-mono text-[12px] leading-relaxed text-ink",children:i.diff})]})]},i.id)})}):e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("memory.loading")})}function zr({bot:t,rows:a,refreshError:n,onRollback:l,rollingBack:r}){if(!a)return e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("history.loading")});if(a.length===0)return e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("history.empty")});const i=[...a].sort((c,d)=>d.at-c.at);return e.jsxs("div",{className:"flex flex-col gap-2",children:[n&&e.jsx("div",{className:"rounded-lg bg-inset px-3 py-2 text-[13px] text-ink-secondary",children:s("history.refreshError")}),i.map(c=>e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1 text-[13px] leading-relaxed text-ink",children:[e.jsx("span",{className:"text-ink-secondary",children:$t(c.at)})," · ",e.jsxs("span",{children:[c.actor," via ",c.via]})," · ",e.jsx("span",{children:c.summary})]}),c.field==="soul"&&c.canRestore===!0&&e.jsx("button",{type:"button",disabled:r,onClick:()=>l(c.id),className:"shrink-0 rounded-md px-2 py-1 text-[12px] font-medium text-accent-text hover:bg-accent/10 disabled:opacity-50",children:s("history.undo")})]}),c.field==="soul"&&c.canRestore!==!0&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-ink-secondary",children:c.restoreUnavailableReason??s("history.restoreUnavailable")})]},`${t.id}-${c.id}`))]})}function Hr({bot:t,bare:a=!1}){const{state:n,dispatch:l}=B(),r=Hs(t),i=n.instances.find(c=>c.instanceId===t.modelSelection.instanceId);return r.turns===0?e.jsx("div",{className:O(a?"":"rounded-xl bg-card p-4","text-[13px] text-ink-secondary"),children:s("usage.bot.empty")}):e.jsxs("div",{className:a?void 0:"rounded-xl bg-card p-4",children:[!a&&e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("usage.title")}),e.jsxs("button",{onClick:()=>l({type:"toggleAppSettings",open:!0,section:"usage"}),className:"text-[12px] text-ink-secondary hover:text-ink",children:[s("usage.allBots")," ",e.jsx(he,{size:14,"aria-hidden":"true",className:"inline align-[-2px] rtl:-scale-x-100"})]})]}),e.jsxs("div",{className:O("grid grid-cols-3 gap-3 text-[13px]",!a&&"mt-3"),children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] uppercase tracking-wide text-ink-secondary",children:s("usage.colTurns")}),e.jsx("div",{className:"mt-0.5 tabular-nums text-ink",children:r.turns})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] uppercase tracking-wide text-ink-secondary",children:_s(r)}),e.jsx("div",{className:"mt-0.5 tabular-nums text-ink",title:qs(r),children:Us(Ks(r))})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] uppercase tracking-wide text-ink-secondary",children:s("usage.colCost")}),e.jsx("div",{className:"mt-0.5 tabular-nums text-ink",children:rt(r.costUsd)?Ws(r.costUsd):"—"})]})]}),e.jsx("div",{className:"mt-2 text-[12px] text-ink-secondary",children:rt(r.costUsd)?s("usage.costLine",{caption:Vs(i?.snapshot.billing)}):s("usage.bot.unpriced")})]})}const _r=[["bot","botPanel.avatar.tabBot"],["generate","botPanel.avatar.tabGenerate"],["upload","botPanel.avatar.tabUpload"]],Ur=["circle","rounded","square"],Kr={circle:"botPanel.avatar.circle",rounded:"botPanel.avatar.rounded",square:"botPanel.avatar.square"},qr={idle:"botPanel.face.idle",happy:"botPanel.face.happy",curious:"botPanel.face.curious",drowsy:"botPanel.face.drowsy",working:"botPanel.face.working",thinking:"botPanel.face.thinking",listening:"botPanel.face.listening",sleeping:"botPanel.face.sleeping",suspicious:"botPanel.face.suspicious",proud:"botPanel.face.proud"},Wr=t=>{const a=qr[t];return a?s(a):t};function Vr({bot:t,activeState:a,onPatch:n,onClose:l}){const r=Ys(t,n),{fileRef:i,crop:c,uploading:d,generating:o,busy:u,error:p,upload:h,removeImage:k,generate:f}=r,b=c!=="mascot"&&!!t.avatarUrl,[y,C]=x.useState(b?"upload":"bot"),v=x.useRef(null);x.useEffect(()=>{v.current?.querySelector('[aria-selected="true"]')?.focus()},[]);const w=m=>n(c==="mascot"?m:{...m,avatarCrop:"mascot"}),N=t.mascotBody??"cursor",E=wn(),M=Nn(t.mascotBody,t.color,E),[F,T]=x.useState(()=>!!E||mt(N)||!!(t.mascotExpression&&t.mascotExpression!=="idle")),I=E&&M!==N&&mt(M)?Te(M):null,z=(m,R)=>e.jsx("button",{type:"button",disabled:u,"aria-pressed":!b&&N===m,"aria-label":s("mascot.useBody",{name:R}),title:R,onClick:()=>w({mascotBody:m}),className:O("flex h-[58px] items-center justify-center rounded-xl disabled:opacity-50",!b&&N===m?"bg-ink/[0.08] ring-[1.5px] ring-inset ring-ink/25":"hover:bg-ink/[0.05]"),children:e.jsx(Ln,{color:t.color,faceColor:t.mascotFaceColor,bodyId:m,size:40,animated:!1,trackPointer:!1})},m),A=m=>{m.key==="Escape"&&(m.preventDefault(),m.stopPropagation(),l())};return e.jsxs("div",{role:"dialog","aria-label":s("botPanel.avatar.edit"),"data-panel-avatar-editor":!0,onKeyDown:A,className:"popover-surface absolute inset-x-[-5px] top-[80px] z-30 overflow-hidden rounded-2xl border border-ink/[0.08] bg-menu text-left shadow-2xl shadow-black/50",children:[e.jsxs("div",{ref:v,className:"flex items-center gap-0.5 border-b border-ink/[0.06] p-2",children:[_r.map(([m,R])=>e.jsx("button",{type:"button",role:"tab","aria-selected":y===m,"data-avatar-tab":m,onClick:()=>C(m),className:O("rounded-lg px-[11px] py-[5px] text-[13px]",y===m?"bg-ink/[0.08] font-medium text-ink":"text-ink-secondary hover:text-ink"),children:s(R)},m)),e.jsx("button",{type:"button","data-avatar-reset":!0,disabled:u,onClick:()=>n(Gs),className:"ml-auto rounded-lg px-[11px] py-[5px] text-[13px] text-ink-secondary hover:text-ink disabled:opacity-50",children:s("botPanel.avatar.reset")})]}),e.jsxs("div",{className:"p-3",children:[y==="bot"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-5 gap-1.5",children:Sn.map(m=>z(m,Te(m)))}),e.jsx("div",{className:"flex flex-wrap justify-center gap-2 px-1 pb-1 pt-3.5",children:Js.map(m=>e.jsx("button",{type:"button",disabled:u,"aria-pressed":t.color===m,"aria-label":s("mascot.useColor",{color:On(m)}),title:s(Pn[m]),onClick:()=>w({color:m}),className:O("size-6 rounded-full disabled:opacity-50",t.color===m&&"ring-2 ring-ink/80 ring-offset-2 ring-offset-menu"),style:{background:Cn(m)}},m))}),e.jsx(Wn,{bot:t,disabled:u,onPatch:w}),e.jsxs("button",{type:"button","data-avatar-more":!0,"aria-expanded":F,onClick:()=>T(m=>!m),className:"mx-auto mt-2.5 flex items-center gap-1 rounded-full px-2.5 py-1 text-[12px] text-ink-secondary hover:bg-ink/[0.04] hover:text-ink",children:[s("botPanel.avatar.more"),e.jsx(pe,{size:13,"aria-hidden":"true",className:O("transition-transform",F&&"rotate-180")})]}),F&&e.jsxs("div",{"data-avatar-more-looks":!0,children:[En.map(m=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 px-1 pb-1.5 pt-2 text-[12px] text-ink-tertiary",children:[e.jsx("span",{children:pt(m)}),m===E&&I&&e.jsx("span",{"data-avatar-costume":!0,children:s("botPanel.avatar.costume",{name:I,skin:pt(m)})})]}),e.jsx("div",{className:"grid grid-cols-5 gap-1.5","data-festival-bodies":m,children:Rn[m].bodies.map(R=>z(R,Te(R)))})]},m)),e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-1.5 pt-2.5",role:"group","aria-label":s("botPanel.avatar.face"),children:[e.jsx("span",{className:"mr-0.5 text-[12px] text-ink-tertiary",children:s("botPanel.avatar.face")}),In.map(m=>e.jsx("button",{type:"button",disabled:u,"data-avatar-face":m,"aria-pressed":a===m,onClick:()=>w({mascotExpression:m}),className:O("rounded-full px-2.5 py-1 text-[12px] disabled:opacity-50",a===m?"bg-ink/[0.15] text-ink":"bg-ink/[0.04] text-ink-secondary hover:text-ink"),children:Wr(m)},m))]})]})]}),y==="generate"&&e.jsx("div",{className:"[&>div:first-child]:mt-0 [&>div:first-child]:border-0 [&>div:first-child]:pt-0",children:e.jsx(Qs,{botLabel:t.title||t.name,disabled:d,generating:o,onGenerate:f})}),y==="upload"&&e.jsxs(e.Fragment,{children:[e.jsx(Xs,{busy:u,onUpload:m=>{h(m)}}),b&&e.jsx(Zs,{bot:t,disabled:u,onPatch:n}),e.jsx("input",{ref:i,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"sr-only",onChange:m=>{h(m.target.files?.[0])}}),e.jsxs("button",{type:"button","data-avatar-drop":!0,disabled:u,onClick:()=>i.current?.click(),onDragOver:m=>m.preventDefault(),onDrop:m=>{m.preventDefault(),h(m.dataTransfer.files?.[0])},className:"flex w-full flex-col items-center gap-1.5 rounded-xl border-[1.5px] border-dashed border-ink/15 px-3 py-6 text-center text-[13px] text-ink-secondary hover:border-ink/25 hover:text-ink disabled:opacity-50",children:[d?e.jsx(An,{size:22,className:"animate-spin"}):e.jsx(ea,{size:22}),e.jsx("span",{children:s("botPanel.avatar.drop")}),e.jsx("span",{className:"text-[12px] text-ink-tertiary",children:s("botPanel.avatar.types")})]}),e.jsxs("div",{className:"mt-2.5 flex items-center gap-2.5",children:[e.jsx("span",{className:"shrink-0 text-[12px] text-ink-secondary",children:s("botPanel.avatar.shape")}),e.jsx(ke,{attr:"data-avatar-crop",label:s("botPanel.avatar.shape"),value:b?c:null,onChange:m=>n({avatarCrop:m}),options:Ur.map(m=>({value:m,label:s(Kr[m]),disabled:u||!t.avatarUrl}))}),t.avatarUrl&&e.jsx("button",{type:"button",onClick:k,disabled:u,"aria-label":s("botIdentity.removeAvatar"),title:s("botPanel.avatar.remove"),className:"flex size-8 shrink-0 items-center justify-center rounded-lg text-ink-secondary hover:bg-control hover:text-danger disabled:opacity-50",children:e.jsx(_t,{size:14})})]}),!b&&e.jsx("p",{className:"mt-2 text-[12px] text-ink-tertiary",children:s("botPanel.avatar.uploadHint")})]}),p&&e.jsx("div",{role:"alert",className:"mt-3 text-[12px] text-danger",children:p})]})]})}const Yr=()=>s("place.off");function xs(t){const{dispatch:a}=B();return(n="computer")=>{aa(t.id,n),a({type:"toggleSettings",open:!1}),a({type:"toggleComputer",open:!0})}}function Gr(t,a){const[n,l]=x.useState(null);return x.useEffect(()=>{if(!a)return;let r=!1;return se(`/api/browser-sites?bot=${encodeURIComponent(t.id)}`).then(i=>{r||l({botId:t.id,count:i.sites?.length??0})}).catch(()=>{}),()=>{r=!0}},[t.id,a]),n?.botId===t.id?n.count:null}function hs(t){const{state:a}=B(),{capabilities:n}=ge(),l=n.host?.platform??"other",r=na(t),i=t.computer??"auto",c=a.config?.browserEngine?.myChrome===!0&&(a.config?.browserProfiles??[]).some(f=>f.id===t.browserProfile&&f.browser==="chrome"),d=f=>f==="browser"&&c?s("settings.profiles.myChrome"):la(f,l),o=f=>{const{view:b,reachable:y}=r[f];return{value:f,label:d(f),disabled:!y,hint:!y||ia(b)?b.line:void 0}},u=[{value:"auto",label:s("computer.simple.dest.letItChoose")},...r.local.policy?[o("local")]:[],...r.browser.policy||i==="browser"?[o("browser")]:[],...r.cloud.policy?[o("cloud")]:[],...r.vm.policy||i==="vm"?[o("vm")]:[],...i==="off"?[{value:i,label:Yr(),disabled:!0}]:[]],p=t.tasks?.find(f=>f.threadId===t.threadId)?.surface,h=p&&p!==i?d(p):null,k=u.find(f=>f.value===i)?.label??(i==="auto"||i==="off"?void 0:d(i));return{options:u,current:i,currentLabel:k,usingNow:h}}function Jr({bot:t,derived:a}){const{dispatch:n}=B(),{options:l,current:r,usingNow:i}=hs(t),[c,d]=x.useState(null),{patch:o,approvalMode:u}=a,p=h=>{if(!(h===r||h==="off")){if(h==="local"&&u==="auto"){d({botId:t.id,patch:{computer:"local",acknowledgeLocalAuto:!0}});return}o(h==="browser"?{computer:"browser",browser:!0}:{computer:h==="auto"?null:h})}};return e.jsxs(e.Fragment,{children:[e.jsx(L,{children:e.jsx("div",{role:"radiogroup","aria-label":s("computer.simple.whereWorks",{name:t.name}),className:"flex flex-col divide-y divide-ink/[0.05]",children:l.map(h=>e.jsx(He,{"data-panel-choice":h.value,title:h.label,hint:h.hint,checked:r===h.value,disabled:h.disabled,onClick:()=>p(h.value)},h.value))})}),i&&e.jsx("p",{"data-panel-using-now":!0,className:"mx-1 text-[13px] text-ink-secondary",children:s("computer.simple.usingNow",{place:i})}),e.jsx(ra,{open:c!==null,onCancel:()=>d(null),onConfirm:()=>{const h=c;d(null),h&&n({type:"updateBot",botId:h.botId,patch:h.patch})}})]})}function Qr({bot:t,derived:a,onOpen:n}){const l=xs(t),r=Ge(),{browserEnabled:i}=a,c=Gr(t,i&&t.computer!=="off"&&r!==!1),{currentLabel:d,usingNow:o}=hs(t),u=s("computer.screenOf",{name:t.name}),p=[...t.messages].reverse().find(k=>k.kind==="screen"&&(k.hasImage||k.png)),h=p?ta({threadId:t.threadId,messageId:p.id},p.mime).src:null;return e.jsxs("div",{"data-panel-tabpanel":"computer",children:[e.jsxs("button",{type:"button","data-panel-action":"open-computer","aria-label":`${s("place.action.watch")}: ${u}`,onClick:()=>l(),className:"group relative mt-2.5 flex aspect-[16/10] w-full flex-col items-center justify-center gap-2 overflow-hidden rounded-xl bg-composer ring-1 ring-inset ring-ink/[0.06] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-border",children:[h?e.jsx("img",{src:h,alt:"",className:"absolute inset-0 size-full object-cover"}):t.busy?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"opacity-55",children:e.jsx(qe,{bot:t,size:52,animated:!1})}),e.jsx("span",{className:"max-w-[80%] text-center text-[13px] text-ink-secondary",children:s("botPanel.screen.working")})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"opacity-60",children:e.jsx(qe,{bot:t,size:44,state:"sleeping",animated:!1})}),e.jsx("span",{className:"max-w-[80%] text-center text-[13px] font-medium text-ink",children:s("botPanel.screen.resting")})]}),e.jsxs("span",{"aria-hidden":"true",className:"absolute bottom-2.5 right-2.5 flex h-7 items-center gap-1.5 rounded-full border border-ink/10 bg-panel/80 px-2.5 text-[12px] text-ink opacity-0 backdrop-blur-sm transition-opacity group-hover:opacity-100 group-focus-within:opacity-100 touch:opacity-100",children:[e.jsx(gt,{size:13,"aria-hidden":"true"}),s("place.action.watch")]})]}),e.jsx("div",{className:"mt-3 text-center text-[13px] text-ink-tertiary",children:u}),e.jsxs(L,{anchor:"where",children:[e.jsx(X,{"data-panel-page":"where",icon:gt,title:s("computer.simple.whereWorks",{name:t.name}),hint:o?s("computer.simple.usingNow",{place:o}):void 0,value:d,onClick:()=>n("where")}),e.jsx(X,{"data-panel-page":"browser",icon:sa,title:s("settings.sites.title"),value:c??void 0,onClick:()=>n("browser")})]})]})}const Xr=3,Pt="[&_.font-semibold]:font-medium [&_time]:text-[12px] [&_time]:text-ink-tertiary [&_span.bg-accent]:size-2",Zr=8,ei=200,ue=new Map,$e=new Set,Ot=t=>`${t.threadId}@${Wt(t)}`;function ti(t,a){const[,n]=x.useState(0),r=a.filter(d=>d.threadId!==t.threadId).map(Ot).filter(d=>!ue.has(d)&&!$e.has(d)).join(",");x.useEffect(()=>{if(r)for(const d of r.split(",")){$e.add(d);const o=d.slice(0,d.lastIndexOf("@"));se(`/api/threads/${encodeURIComponent(o)}/messages?limit=${Zr}`,{background:!0}).then(u=>{ue.set(d,Ue({messages:u.messages??[],activeLeafId:u.activeLeafId??void 0})),ue.size>ei&&ue.delete(ue.keys().next().value),n(p=>p+1)}).catch(()=>{}).finally(()=>$e.delete(d))}},[r]);const i=Ue(t),c=new Map(a.map(d=>[d.threadId,Ot(d)]));return d=>d===t.threadId?i:ue.get(c.get(d)??"")}function si({bot:t}){const{state:a,dispatch:n}=B(),l=oa(),r=!Ut(Kt,!0),[i,c]=x.useState(""),[d,o]=x.useState(!1),[u,p]=x.useState(!1),[h,k]=x.useState(!1),f=ca(a.config),b=x.useMemo(()=>{const{onRename:g,onRegenerateTitle:$,onDelete:ie,onMove:de,onPin:xe,onArchive:S}=da(t.id,n,f);return{onRename:g,onRegenerateTitle:$,onDelete:ie,onMove:de,onPin:xe,onArchive:S}},[t.id,n,f]),y=ua(t),C=t.tasks??[{threadId:t.threadId,title:s("task.newShort"),createdAt:0}],v=(y?ma({...t,tasks:C},y):C).filter(g=>!g.routineRunId).map(g=>{const $=_e(t,g.threadId);return{...g,busy:$.busy,activity:$.activity,waitingForTeammates:$.waitingForTeammates,turnStartedAt:$.turnStartedAt??void 0,queued:!!a.pendingQueued[g.threadId]?.length}}),w=it(v.filter(g=>!Le(g)||g.threadId===t.threadId)),N=it(v.filter(g=>Le(g)&&g.threadId!==t.threadId)),E=i.trim(),M=w.filter((g,$)=>$<Xr||g.threadId===t.threadId),F=ti(t,[...E||u?w:M,...h?N:[]]),T=g=>{const $=F(g);return $?ha(_e(t,g),$,a.instances,!1):void 0},I=pa(w,E),z=E?[...I,...w.filter(g=>!I.includes(g)&&T(g.threadId)?.toLowerCase().includes(E.toLowerCase()))]:w,A=E?z:u?w:M,m=w.length-M.length,R=t.projects?.find(g=>g.id===t.tasks?.find($=>$.threadId===t.threadId)?.projectId),D=()=>{r&&n({type:"toggleSettings",open:!1})},H=g=>{g.threadId!==t.threadId&&ya(n,t,g.threadId,!1),D()},_=()=>{n({type:"newTask",botId:t.id,...R?{projectId:R.id}:{}}),D()},G=()=>{c(""),o(!1)},Y=w.length>=2||d||w.some(g=>g.threadId===t.threadId&&Le(g)),U=g=>e.jsx("div",{role:"listitem","data-conversation":g.threadId,children:e.jsx(fa,{panel:!0,preview:T(g.threadId),task:g,ownerId:t.id,current:g.threadId===t.threadId,folders:t.projects,now:ga(Wt(g),l),locale:ee(),onSelect:H,...b})},g.threadId);return e.jsxs("section",{"data-panel-card":"conversations","aria-label":s("botPanel.conversations.title"),children:[e.jsx(je,{action:Y&&e.jsx("button",{type:"button","data-conversations-search":!0,"aria-label":s("botPanel.conversations.search"),title:s("botPanel.conversations.search"),"aria-pressed":d,onClick:()=>d?G():o(!0),className:O("-me-1 flex size-6 shrink-0 items-center justify-center rounded-[6px] text-ink-secondary transition-colors hover:bg-ink/[0.06] hover:text-ink",d&&"bg-ink/[0.06] text-ink"),children:e.jsx(Lt,{size:14,"aria-hidden":"true"})}),children:s("botPanel.conversations.title")}),e.jsx("div",{className:O("flex items-center gap-2",Y&&"mb-2"),children:t.yourAccess!=="view"&&y!=="team"&&e.jsxs("button",{type:"button","data-conversations-new":!0,"aria-label":s("botPanel.conversations.new"),onClick:_,className:O(qt,"flex-1"),children:[e.jsx(xa,{size:15,"aria-hidden":"true",className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"truncate",children:s("botPanel.conversations.new")})]})}),Y&&d&&e.jsx("input",{autoFocus:!0,type:"search","data-conversations-query":!0,value:i,onChange:g=>c(g.target.value),onKeyDown:g=>{g.key==="Escape"&&(g.preventDefault(),g.stopPropagation(),G())},placeholder:s("botPanel.conversations.searchPlaceholder",{name:t.name}),"aria-label":s("botPanel.conversations.searchPlaceholder",{name:t.name}),className:"mb-1.5 w-full rounded-[8px] border border-hairline/60 bg-inset px-3 py-1.5 text-[13px] text-ink outline-none placeholder:text-ink-tertiary focus:border-focus"}),Y&&e.jsx("div",{role:"list","aria-label":s("botPanel.conversations.title"),className:O("flex flex-col gap-px",Pt),children:A.map(U)}),Y&&E&&A.length===0&&e.jsx("p",{className:"px-3 py-3 text-[13px] text-ink-secondary",children:s("task.noMatch",{query:E})}),Y&&!E&&m>0&&e.jsxs("button",{type:"button","data-conversations-more":!0,"aria-expanded":u,onClick:()=>p(g=>!g),className:"mt-0.5 flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-[13px] text-ink-secondary hover:bg-ink/[0.04] hover:text-ink",children:[u?e.jsx(lt,{size:14,"aria-hidden":"true"}):e.jsx(pe,{size:14,"aria-hidden":"true"}),u?s("botPanel.conversations.showFewer"):s("botPanel.conversations.showMore",{count:m})]}),!E&&N.length>0&&e.jsxs("button",{type:"button","data-conversations-archived":!0,"aria-expanded":h,onClick:()=>k(g=>!g),className:"mt-0.5 flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-[13px] text-ink-secondary hover:bg-ink/[0.04] hover:text-ink",children:[h?e.jsx(lt,{size:14,"aria-hidden":"true"}):e.jsx(pe,{size:14,"aria-hidden":"true"}),s("task.archivedList",{count:N.length})]}),!E&&h&&N.length>0&&e.jsx("div",{role:"list","aria-label":s("task.archivedList",{count:N.length}),className:O("flex flex-col gap-px",Pt),children:N.map(U)})]})}function ai({bot:t}){const{dispatch:a}=B();return Mt()||!t.defaultBot?null:e.jsx(L,{label:s("botPanel.tryAsking"),anchor:"try-asking",children:va.map(l=>e.jsx("button",{type:"button","data-panel-ask":l,onClick:()=>a({type:"send",botId:t.id,text:s(l),threadId:t.threadId}),className:"flex h-9 w-full items-center px-3.5 text-left text-[14px] text-ink transition-colors hover:bg-ink/[0.03]",children:e.jsx("span",{className:"truncate",children:s(l)})},l))})}const ni=["find","start-fresh","usage","activity","inspector"];function ri({item:t}){const a=t.key==="usage";return e.jsxs("button",{type:"button","data-panel-item":t.key,disabled:t.disabled,title:t.title,"aria-pressed":t.active||void 0,onClick:t.onSelect,className:O(J,"w-full rounded-[8px] text-left enabled:hover:bg-ink/[0.04] disabled:cursor-default disabled:opacity-45"),children:[e.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center text-ink-secondary [&_svg]:size-4","aria-hidden":"true",children:t.icon}),e.jsx("span",{className:O("min-w-0 truncate text-[14px] font-medium",!a&&"flex-1",t.active?"text-accent-text":"text-ink"),children:t.label}),t.trailing&&e.jsx("span",{className:O("flex items-center",a?"min-w-0 flex-1 justify-end text-right":"shrink-0"),children:t.trailing}),t.key!=="find"&&t.key!=="start-fresh"&&e.jsx(he,{size:15,"aria-hidden":"true",className:"shrink-0 text-ink-tertiary rtl:-scale-x-100"})]})}function ii({bot:t,derived:a,onOpen:n}){const{items:l}=ba(t),{dispatch:r}=B(),i=a.botRoutines.filter(d=>d.enabled).length,c=ni.flatMap(d=>l.filter(o=>o.key===d));return e.jsxs("div",{"data-panel-tabpanel":"details",children:[e.jsx("section",{"data-panel-card":"model",className:"pt-2",children:e.jsx("div",{"data-panel-row":"model",className:O(J,"rounded-[8px]"),children:e.jsx(ka,{bot:t,contained:!0,threadId:t.threadId,label:e.jsxs("span",{className:"flex shrink-0 items-center gap-2.5",children:[e.jsx(Q,{icon:Ve}),e.jsx(te,{title:s("model.simple.model")})]})})})}),e.jsx(si,{bot:t}),e.jsx(ai,{bot:t}),c.length>0&&e.jsxs("section",{"data-panel-card":"conversation",children:[e.jsx(je,{children:s("botPanel.section.conversation")}),c.map(d=>e.jsx(ri,{item:d},d.key))]}),a.botRoutines.length===0?e.jsxs("section",{"data-panel-empty":"routines",children:[e.jsx(je,{action:e.jsx(ja,{"data-panel-automations":"",onClick:()=>r({type:"showRoutines",view:"list"}),children:s("sidebar.nav.automations")}),children:s("botSettings.simple.routines")}),e.jsxs("button",{type:"button","data-panel-page":"routines",title:s("botPanel.routines.emptyHint"),onClick:()=>n("routines"),className:O(qt,"w-full"),children:[e.jsx(vr,{size:15,"aria-hidden":"true",className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"truncate",children:s("botPanel.routines.add")})]})]}):e.jsx(L,{label:s("botSettings.simple.routines"),anchor:"routines",children:e.jsx(X,{"data-panel-page":"routines",icon:wa,title:s("botSettings.simple.routines"),value:i>0?s("botPanel.routinesOn",{count:i}):s("botPanel.none"),onClick:()=>n("routines")})})]})}const fs=/^\s*[-*]\s+(.+?)\s*$/;function li(t){return t.split(`
8
- `).flatMap((a,n)=>{const l=fs.exec(a)?.[1];return l?[{line:n,text:l}]:[]})}function oi(t,a){const n=t.split(`
9
- `);return fs.test(n[a]??"")?(n.splice(a,1),n.join(`
10
- `)):t}function ci(t,a){const n=t.replace(/\s+$/,""),l=`- ${a.trim().replace(/\s*\n\s*/g," ")}`;return n?`${n}
11
- ${l}
12
- `:`${l}
13
- `}function gs(t){return t.flatMap(a=>{const n=li(a.text).map(r=>({path:a.path,...r}));if(n.length||a.path===Z)return n;const l=a.text.split(`
14
- `).map(r=>r.replace(/^#+\s*/,"").trim()).filter(Boolean).join(" ");return l?[{path:a.path,line:null,text:l}]:[]})}async function di(t,a){if(!a)return[await Ne(t,Z)];const n=await Qe(t,!0);return Promise.all([Z,...n.topics.map(l=>l.path)].map(l=>Ne(t,l,!0)))}function ys(t){const a=!!B().state.config?.team,[n,l]=x.useState({botId:t.id,docs:null,error:!1}),r=t.memoryEnabled!==!1,i=async(o,u)=>{try{const p=await di(o,a);u?.()||l({botId:o,docs:p,error:!1})}catch{u?.()||l({botId:o,docs:null,error:!0})}},c=!!t.busy;x.useEffect(()=>{if(!r)return;let o=!1;return i(t.id,()=>o),()=>{o=!0}},[t.id,r,c,a]);const d=n.botId===t.id;return{docs:d?n.docs:null,error:d&&n.error,mine:a,setDoc:o=>l(u=>({botId:t.id,docs:(u.botId===t.id?u.docs??[]:[]).map(p=>p.path===o.path?o:p),error:!1})),reload:()=>i(t.id)}}function ui(t,a=Ue(t)){const n=[],l=[],r=new Set;for(const u of[...a].reverse()){const p=u.publishedPage;p?.state==="live"&&p.url&&!r.has(p.url)&&(r.add(p.url),n.push({messageId:u.id,title:p.title||p.url,url:p.url})),u.kind==="app"&&u.app?.doc&&l.push({messageId:u.id,title:u.app.title})}const i=dr(t),c=[],d=new Set;for(const u of i.values())d.has(u.file.path)||(d.add(u.file.path),c.push(u));const o=ur(t).filter(u=>!i.has(u));return{pages:n,apps:l,shared:c,unshared:o}}const mi=t=>t.slice(Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"))+1);function vs({bot:t,onOpen:a}){const{dispatch:n}=B(),{capabilities:l}=ge(),r=Na(),i=!Ut(Kt,!0),c=as(t),d=ys(t),{pages:o,apps:u,shared:p,unshared:h}=x.useMemo(()=>ui(t),[t]),k=v=>{n({type:"focusMessage",threadId:t.threadId,messageId:v}),i&&n({type:"toggleSettings",open:!1})},f=c.skills.filter(ns).length,b=d.docs?gs(d.docs).length:null,y=t.memoryEnabled===!1?s("botPanel.memory.off"):b===null?d.error?s("botPanel.memory.nothingYet"):void 0:b===0?s("botPanel.memory.nothingYet"):b===1?s("botPanel.memory.note"):s("botPanel.memory.notes",{count:b}),C=e.jsxs(L,{anchor:"keeps",children:[e.jsx(X,{"data-panel-page":"memory",icon:Bt,title:s("botPanel.memoryRow"),value:y,onClick:()=>a("memory")}),e.jsx(X,{"data-panel-page":"skills",icon:Sa,title:s("botSettings.simple.skills"),value:c.loading?void 0:f>0?f:s("botPanel.none"),onClick:()=>a("skills")}),e.jsx(X,{"data-panel-page":"folder",icon:Ca,title:s("computer.files.folder"),value:t.cwd?Ye(t.cwd,l.host?.homeDir):s("botPanel.folder.private"),onClick:()=>a("folder")})]});return o.length+u.length+p.length+h.length===0?e.jsxs("div",{"data-panel-tabpanel":"library",children:[e.jsx("p",{"data-panel-empty":"library",className:"px-3 py-7 text-center text-[13px] leading-[18px] text-ink-tertiary",children:s("botPanel.library.empty")}),C]}):e.jsxs("div",{"data-panel-tabpanel":"library",children:[o.length>0&&e.jsx(L,{label:s("botPanel.library.pages"),anchor:"pages",children:o.map(v=>e.jsx(X,{"data-panel-row":"page",icon:Pa,title:e.jsx("span",{className:"block truncate",children:v.title}),hint:e.jsx("span",{className:"block truncate",children:v.url}),onClick:()=>r(v.url)},v.url))}),u.length>0&&e.jsx(L,{label:s("botPanel.library.apps"),anchor:"apps",children:u.map(v=>e.jsx(X,{"data-panel-row":"app",icon:Vt,title:e.jsx("span",{className:"block truncate",children:v.title}),onClick:()=>k(v.messageId)},v.messageId))}),p.length+h.length>0&&e.jsxs("section",{"data-panel-card":"files",children:[e.jsx(je,{children:s("botPanel.library.files")}),e.jsxs("ul",{className:"flex flex-col gap-1.5",children:[p.map(v=>e.jsx("li",{className:"min-w-0",children:e.jsx(Oa,{file:v.file,message:v.message,linked:v.file.linked,className:"w-full max-w-none"})},`${v.message.messageId}:${v.file.path}`)),h.map(v=>e.jsxs("li",{title:s("computer.files.notSharedHint"),className:"flex min-w-0 items-center gap-2 rounded-lg border border-hairline/40 px-2.5 py-2",children:[e.jsx(Pe,{size:14,className:"shrink-0 text-ink-secondary","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] text-ink",children:mi(v)}),e.jsx("span",{className:"shrink-0 text-[11px] text-ink-tertiary",children:s("computer.files.notShared")})]},v))]})]}),e.jsx("p",{className:"mt-3 text-center text-[12px] text-ink-tertiary",children:s("botPanel.library.scope")}),C]})}function pi({bot:t,browserEnabled:a,onOpenBrowser:n}){const{state:l}=B(),r=Ge(),i=t.browserProfile??"",c=(l.config?.browserProfiles??[]).find(p=>p.id===i),d=i==="guest",o=c?.browser==="chrome"&&l.config?.browserEngine?.myChrome===!0,u=i&&!d?l.bots.filter(p=>p.browserProfile===i).map(p=>p.name):[t.name];return e.jsx(L,{anchor:"logins",children:a?d?e.jsx(W,{children:s("settings.profiles.temporaryHint")}):o?e.jsx(W,{children:s("settings.profiles.myChromeHint")}):e.jsxs(e.Fragment,{children:[r!==!1&&(i===""||c)&&e.jsx(ce,{children:e.jsx(gr,{bare:!0,target:{bot:t.id},sharedBy:u,disabled:!!t.busy},`${t.id}:${i}`)}),e.jsx(W,{children:s("botSettings.simple.loginsHint",{name:t.name})}),e.jsx(fe,{"data-panel-action":"add-login",icon:Ee,onClick:n,children:s("botSettings.simple.addLogin")})]}):e.jsx(W,{children:s("botSettings.simple.loginsOff",{name:t.name})})})}const xi=5,hi={instanceId:"",model:""},bs=(t,a)=>`${t}\0${a}`,fi=new Set;function Et({bot:t,current:a,exclude:n,onPick:l,label:r,title:i,buttonRef:c,className:d,children:o,...u}){const{state:p,dispatch:h,refreshInstances:k,refreshModels:f}=B(),[b,y]=x.useState(!1),[C,v]=x.useState(""),[w,N]=x.useState(()=>new Set),[E,M]=x.useState(!1),[F,T]=x.useState(null),[I,z]=x.useState(null),A=x.useRef(null),m=c??A,R=x.useRef(null),D=x.useRef(null),H=x.useRef(!1),_=x.useId(),G=Fn(b),Y=x.useRef({contains:S=>[m.current,R.current].some(K=>K?.contains(S))});Ma(b,Y,()=>y(!1)),x.useLayoutEffect(()=>{if(!b)return;const S=K=>{if(K?.type==="scroll"&&K.target instanceof Node&&R.current?.contains(K.target))return;const V=m.current?.getBoundingClientRect(),q=R.current;!V||!q||z(le=>Da(V,{width:ot,height:q.offsetHeight},{width:window.innerWidth,height:window.innerHeight},le??void 0))};return S(),window.addEventListener("resize",S),window.addEventListener("scroll",S,!0),()=>{window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0)}},[b,m]),x.useEffect(()=>{if(!b||!I||!H.current)return;H.current=!1;const S=R.current;(S?.querySelector("[data-menu-search]")??S?.querySelector("[data-current-model]")??S?.querySelector("[data-menu-row]:not(:disabled)")??S)?.focus({preventScroll:!0})},[b,I]);const U=S=>{y(!1),S&&m.current?.focus({preventScroll:!0})},g=()=>{v(""),N(new Set),z(null),H.current=!0,y(!0),M(!0),k().catch(()=>{}).finally(()=>M(!1))},$=S=>{F||(T(S.instanceId),f(S.instanceId).catch(()=>{}).finally(()=>T(null)))},ie=()=>{U(!1),h({type:"toggleAppSettings",open:!0,section:"engines"})},de=()=>{const S=$a(p.instances,a?.instanceId).flatMap(q=>{const le=q.models.options.filter(ye=>!n.has(bs(q.instanceId,ye.id)));return le.length===q.models.options.length?[q]:le.length?[{...q,models:{...q.models,options:le}}]:[]}),K=za({instances:p.instances,listed:S,selection:a??hi,bot:{name:t.name,selection:t.modelSelection},query:C,expanded:w,probing:fi,loading:E,refreshing:F}),V=K.groups.map(q=>q.instance.instanceId===t.modelSelection.instanceId?{...q,note:s("botPanel.backups.sameAccount")}:q);return{...K,groups:V,...a?{}:{current:null}}},xe=S=>{if(!(S.nativeEvent.isComposing||S.defaultPrevented)){if(S.key!=="Escape")return Fa(S,{query:C,typed:D,close:()=>U(!0)});S.preventDefault(),S.stopPropagation(),C?v(""):U(!0)}};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:m,type:"button",...u,"aria-label":r,title:i,"aria-haspopup":"dialog","aria-expanded":b,"aria-controls":b?_:void 0,onClick:()=>b?U(!1):g(),onKeyDown:S=>{S.key==="Escape"&&b?(S.preventDefault(),S.stopPropagation(),U(!1)):(S.key==="ArrowDown"||S.key==="ArrowUp")&&!b&&(S.preventDefault(),g())},className:d,children:o}),G.shown&&Mn.createPortal(e.jsx("div",{ref:R,id:_,"data-backup-menu":!0,role:"dialog","aria-label":s("botPanel.backups.choose"),"aria-modal":"false",tabIndex:-1,...G.exitProps,onKeyDown:xe,onPointerMove:Ta,style:{position:"fixed",left:I?.left??0,top:I?.top,bottom:I?.bottom,width:I?.width??ot,maxHeight:I?.maxHeight,transformOrigin:I?.origin,visibility:I?void 0:"hidden"},className:O("menu-surface z-[80] flex flex-col overflow-hidden",G.className),children:e.jsx(Ba,{menu:de(),query:C,bot:t,botModel:{label:"",title:""},idPrefix:_,onQuery:v,onPick:(S,K)=>{S.policy||(l({instanceId:S.instanceId,model:K}),U(!0))},onPickCurrent:()=>U(!0),onFollowBot:()=>U(!0),onToggle:S=>N(K=>{const V=new Set(K);return V.delete(S.instanceId)||V.add(S.instanceId),V}),onSetUp:ie,onCheckAgain:$,onManage:ie})}),document.body)]})}function gi({bot:t,onChange:a}){const{state:n}=B(),l=t.fallback??[],r=x.useRef(null),i=d=>new Set([t.modelSelection,...l.filter((o,u)=>u!==d)].map(o=>bs(o.instanceId,o.model))),c=d=>{const o=n.instances.find(h=>h.instanceId===d.instanceId),u=o?.models.options.find(h=>h.id===d.model),p=Ia(o,d.model);return{instance:o,name:p,short:o&&u?Aa(u.label,La(o)):p}};return e.jsx(L,{anchor:"backups",children:e.jsxs(ce,{"data-panel-row":"backups",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(Q,{icon:Ea}),e.jsx(te,{title:s("botPanel.backups.title")})]}),e.jsx("p",{className:"-mt-1 pl-[38px] text-[13px] leading-[1.35] text-ink-secondary",children:s("botPanel.backups.hint",{name:t.name})}),l.length>0&&e.jsx("ol",{"aria-label":s("botPanel.backups.title"),className:"flex flex-col gap-1 pl-[38px]",children:l.map((d,o)=>{const{instance:u,name:p,short:h}=c(d);return e.jsxs("li",{"data-backup":d.instanceId,className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:"w-3 shrink-0 text-[12px] tabular-nums text-ink-tertiary","aria-hidden":"true",children:o+1}),e.jsxs(Et,{bot:t,current:d,exclude:i(o),onPick:k=>a(l.map((f,b)=>b===o?k:f)),label:s("botPanel.backups.row",{position:o+1,model:p}),title:u?`${u.displayName} · ${p}`:p,"data-panel-action":"backup-change",className:"group flex h-8 min-w-0 flex-1 items-center gap-2 rounded-[8px] bg-ink/[0.04] pl-2.5 pr-2 text-left text-[13px] text-ink hover:bg-ink/[0.07] aria-expanded:bg-ink/[0.08]",children:[u?e.jsx(Ra,{instance:u,size:14,subtle:!0}):e.jsx("span",{className:"size-3.5 shrink-0 rounded-full bg-ink/[0.08]","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:h}),!u&&e.jsx("span",{className:"shrink-0 text-[12px] text-warning",children:s("model.simple.unavailable")}),e.jsx(pe,{size:12,strokeWidth:2,"aria-hidden":"true",className:"shrink-0 text-ink-tertiary group-hover:text-ink-secondary"})]}),e.jsx(Oe,{"data-panel-action":"backup-remove",label:s("botPanel.backups.remove",{model:p}),onClick:()=>{a(l.filter((k,f)=>f!==o)),r.current?.focus({preventScroll:!0})}})]},o)})}),l.length<xi&&e.jsx("div",{className:"pl-[38px]",children:e.jsxs(Et,{bot:t,current:null,exclude:i(null),onPick:d=>a([...l,d]),label:s("model.fallback.add"),buttonRef:r,"data-panel-action":"backup-add",className:O(re,"aria-expanded:bg-raised-hover"),children:[e.jsx(Ee,{size:14,"aria-hidden":"true"}),s("model.fallback.add")]})})]})})}function yi({bot:t}){const{dispatch:a}=B(),[n,l]=x.useState(!1),[r,i]=x.useState(!1),[c,d]=x.useState(0),o=t.memoryEnabled!==!1&&t.memoryUpkeep!==!1;if(x.useEffect(()=>{if(!o)return;let p=!0;return se(`/api/bots/${t.id}/system-prompt`).then(h=>{p&&l(h.heavy===!0)},()=>{}),()=>{p=!1}},[t.id,o,c]),!o||!n)return null;const u=async()=>{i(!0);try{await es(t.id)}catch(p){a({type:"error",message:p instanceof Error&&p.message?p.message:s("common.tryAgain")})}finally{i(!1),d(p=>p+1)}};return e.jsx(L,{anchor:"heavy",children:e.jsxs("div",{"data-panel-row":"heavy",className:J,children:[e.jsx(Q,{icon:Ha}),e.jsx(te,{title:s("botPanel.heavy")}),e.jsx("button",{type:"button","data-panel-action":"tidy-memory",disabled:r,onClick:()=>{u()},className:re,children:r?s("memory.upkeep.tidying"):s("botPanel.tidyMemory")})]})})}const vi=5;function bi({bot:t}){const{dispatch:a,flushBotPatches:n}=B(),[l,r]=x.useState([]),[i,c]=x.useState(null),d=x.useCallback(()=>ht(t.id).then(u=>r(u.rows.slice(0,vi)),()=>{}),[t.id]);if(x.useEffect(()=>{d()},[d,t.soul]),!l.length)return null;const o=async u=>{if(!i){c(u.id);try{await n(t.id);const{revision:p}=await ht(t.id);await Vn(t.id,u.id,p)}catch(p){a({type:"error",message:p instanceof Error&&p.message?p.message:s("botOverview.undoFailed")})}finally{c(null),await d()}}};return e.jsxs("div",{"data-panel-row":"soul-changes",className:"flex flex-col gap-1.5",children:[e.jsx("div",{className:"text-[12px] font-medium text-ink-secondary",children:s("memory.changes")}),e.jsx(Ze,{rows:l,botName:t.name,reverting:i,onRevert:u=>{o(u)}})]})}const ze={ask:()=>s("botSettings.simple.ask"),full:()=>s("botSettings.simple.justDoIt"),auto:()=>s("botSettings.simple.decide"),edits:()=>s("approvalMode.edits.label"),custom:()=>s("botPanel.acts.custom")};function ki({bot:t,derived:a,onOpen:n,editingInstructions:l=!1,onEditInstructions:r}){const{state:i,dispatch:c,flushBotPatches:d}=B(),{capabilities:o,ready:u}=ge(),p=Yt(t),{servers:h}=ls(),k=_a(_e(t)),f=Ua(),b=ds(t.id),y=rs(),[C,v]=x.useState(null),{patch:w,approvalMode:N,engine:E}=a,M=t.name,F=()=>{C!==null&&C.trim()!==t.title.trim()&&w({title:C.trim()}),v(null)},T=E?.driverKind==="antigravityAgent"&&N==="auto"?"ask":N,I=[{value:"ask",label:ze.ask(),tooltip:s("botSettings.simple.askHint")},{value:"full",label:ze.full(),tooltip:s("botSettings.simple.fullHint")},...T==="ask"||T==="full"?[]:[{value:T,label:ze[T](),disabled:!0,tooltip:T==="custom"?s("botPanel.acts.customHint"):void 0}]],z=g=>{g===N||g!=="ask"&&g!=="full"||c({type:"updateBot",botId:t.id,patch:{approvalMode:g,applyToAllThreads:!0}})},A=!u||Ka(o,i.config),m=sn(f,{turnsHere:A,canLive:!0}),R=A?null:qa(o,!!Va()?.speechStart,Wa(i.config)),D=Ya.map(g=>({value:g.id,label:s(g.label),disabled:g.id==="turns"&&R!==null,tooltip:g.id==="turns"&&R?`${R.label}. ${R.reason}`:g.id==="live"?s("call.mode.liveHint"):Ga("turns")})),H=Ja.map(g=>({value:g,label:s(ft[g][0]),tooltip:s(ft[g][1])})),_=()=>{const g=!t.notifications;g&&an(),w({notifications:g})},G=t.alwaysAllow??[],Y=l||!!t.soulDrift,U=[...p.apps.filter(g=>g.scope!==null).map(g=>g.label),...h?os(h,t.mcpServers,t.id).map(g=>g.name):[]];return e.jsxs("div",{"data-panel-settings":!0,children:[e.jsx(Yn,{bot:t}),e.jsx(L,{anchor:"instructions",children:Y?e.jsxs(ce,{"data-panel-row":"soul",children:[e.jsx(Gn,{bot:t,onPatch:w,simple:{label:s("botSettings.simple.instructions"),placeholder:s("botSettings.simple.instructionsPlaceholder",{name:M})}}),e.jsx(bi,{bot:t}),l&&e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"button","data-panel-done":"soul",onClick:()=>{d(t.id),r?.(!1)},className:re,children:s("botSettings.simple.done")})})]}):e.jsxs("button",{type:"button","data-panel-edit":"soul","aria-label":`${s("botSettings.simple.edit")}: ${s("botSettings.simple.instructions")}`,onClick:()=>r?.(!0),className:O(J,"w-full text-left hover:bg-ink/[0.03]"),children:[e.jsx(Q,{icon:Pe}),e.jsx(te,{title:s("botSettings.simple.instructions"),hint:e.jsx("span",{className:"line-clamp-1",children:Jn(t.soul??"")||s("botPanel.instructionsHint",{name:M})})}),e.jsx(he,{size:15,className:"shrink-0 text-ink-tertiary","aria-hidden":"true"})]})}),e.jsx(yi,{bot:t}),e.jsx(L,{anchor:"approval",children:e.jsxs(ce,{"data-panel-row":"approval",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(Q,{icon:Dt}),e.jsx(te,{title:s("botSettings.simple.beforeActs",{name:M}),hint:t.busy?s("approvalMode.whileWorking"):void 0})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(ke,{attr:"data-approval-choice",label:s("botSettings.simple.beforeActs",{name:M}),value:T,onChange:z,options:I})}),k.choice&&e.jsxs("div",{"data-panel-row":"thread-approval",className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 pl-[38px]",children:[e.jsx("span",{className:"text-[13px] text-ink-secondary",children:s("botPanel.thisConversation")}),e.jsx("span",{className:"ms-auto flex",children:e.jsx(Qa,{choice:k.choice})})]}),G.length>0&&e.jsxs("div",{"data-panel-row":"always-allow",className:"flex min-w-0 flex-col gap-1 pl-[38px]",children:[e.jsx("span",{className:"text-[13px] text-ink-secondary",children:s("botAccess.always.title")}),G.map(g=>e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-ink",children:g}),e.jsx(Oe,{"data-panel-action":`always-allow:${g}`,label:s("botAccess.always.remove",{entry:g}),onClick:()=>w({alwaysAllow:G.filter($=>$!==g)})})]},g))]})]})}),e.jsx(gi,{bot:t,onChange:g=>w({fallback:g})}),e.jsx(L,{anchor:"call",children:e.jsxs(ce,{"data-panel-row":"call-mode",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(Q,{icon:Tn}),e.jsx(te,{title:s("call.mode.menu")})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(ke,{attr:"data-call-mode",label:s("call.mode.menu"),value:m,onChange:Xa,options:D})})]})}),e.jsxs(L,{anchor:"replies",children:[e.jsxs(ce,{"data-panel-row":"reply-style",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(Q,{icon:Za}),e.jsx(te,{title:s("botSettings.replyStyle.title")})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(ke,{attr:"data-reply-style",label:s("botSettings.replyStyle.title"),value:t.replyStyle??"default",onChange:g=>w({replyStyle:g}),options:H})})]}),e.jsx(Je,{"data-panel-row":"notifications",icon:en,title:s("voice.notifications.title"),color:t.color,checked:t.notifications,onChange:_})]}),e.jsxs(L,{anchor:"uses",children:[e.jsx(X,{"data-panel-page":"apps",icon:Vt,title:s("botPanel.appsRow"),value:U.length>0?U.join(", "):s("botPanel.appsNoneYet"),onClick:()=>n?.("apps")}),e.jsxs("label",{"data-panel-row":"job",className:O(J,"cursor-text"),children:[e.jsx(Q,{icon:Nr}),e.jsx("span",{className:"shrink-0 text-[14px] font-medium text-ink",children:s("botSettings.simple.job")}),e.jsx("input",{"data-panel-job":!0,value:C??t.title,placeholder:s("botSettings.simple.jobPlaceholder"),"aria-label":s("botSettings.simple.job"),maxLength:Ke.title,onChange:g=>v(g.target.value),onBlur:F,onKeyDown:g=>{g.key==="Enter"?(g.preventDefault(),g.currentTarget.blur()):g.key==="Escape"&&C!==null&&(g.preventDefault(),g.stopPropagation(),v(null))},className:"min-w-0 flex-1 bg-transparent text-right text-[13px] text-ink-secondary outline-none placeholder:text-ink-tertiary focus:text-ink"})]}),b&&e.jsxs("a",{"data-panel-row":"slack",href:b,target:"_blank",rel:"noopener noreferrer",className:O(J,"hover:bg-ink/[0.03]"),children:[e.jsx(Q,{icon:cs}),e.jsx(te,{title:s("botPanel.page.slack"),hint:s("botSlack.manage")}),e.jsx(Qt,{size:14,className:"shrink-0 text-ink-tertiary","aria-hidden":"true"})]}),y&&e.jsx(X,{"data-panel-page":"visibility",icon:Ft,title:s("botSettings.visibility.title"),value:Qn(t.visibility),onClick:()=>n?.("visibility")})]}),e.jsx(Xn,{bot:t,webhooksLink:!0,className:"mt-3.5"}),e.jsx(tn,{bot:t}),k.dialogs]})}const ji=5;function wi({bot:t,onChanged:a}){const{dispatch:n}=B(),[l,r]=x.useState([]),[i,c]=x.useState(null),[d,o]=x.useState(null),u=x.useCallback(async()=>{const[f,b]=await Promise.all([Qe(t.id),me(t.id)]);c(y=>f.lendingReview?{value:f.lendingReview,stale:y?.stale??!1}:null),r(b.slice(0,ji))},[t.id]);x.useEffect(()=>{u().catch(()=>{})},[u,t.busy]);const p=f=>n({type:"error",message:f instanceof Error&&f.message?f.message:s("common.tryAgain")}),h=async f=>{o(f.id);try{await ss(t.id,f.id),await a()}catch(b){p(b)}finally{o(null),await u().catch(()=>{})}},k=async f=>{o("review");try{await Zt(t.id,f.value.token),c(null)}catch(b){b instanceof Ht&&b.status===409?(c({...f,stale:!0}),await u().catch(()=>{})):p(b)}finally{o(null)}};return e.jsxs(e.Fragment,{children:[i&&e.jsx(ms,{changed:i.value.changed,stale:i.stale,busy:d!==null,onReviewed:()=>{k(i)}}),e.jsx(L,{children:e.jsx(Je,{"data-panel-row":"memory-upkeep",title:s("memory.upkeep.title"),checked:t.memoryUpkeep!==!1,color:t.color,onChange:()=>n({type:"updateBot",botId:t.id,patch:{memoryUpkeep:t.memoryUpkeep===!1}})})}),l.length>0&&e.jsx(L,{label:s("memory.changes"),children:e.jsx("div",{"data-panel-row":"memory-changes",className:"px-3.5 py-3",children:e.jsx(Ze,{rows:l,botName:t.name,reverting:d,onRevert:f=>{h(f)}})})})]})}const Ni="flex flex-col gap-3",Si="https://skills.sh";function Se(t,a){return t instanceof Error&&t.message?t.message:a}function Ci({bot:t,derived:a}){const{dispatch:n}=B(),l=Yt(t),{servers:r,error:i}=ls(),{patch:c,canUseConnectedApps:d}=a,o=r?xr(r,t.id):[],u=new Set(os(o,t.mcpServers,t.id).map(f=>f.name)),p=f=>{const b=cn(t,l.connectedSlugs,f.slug,f.scope===null);Object.keys(b).length>0&&c(b)},h=f=>{t.busy||i||c({mcpServers:hr(o,t.mcpServers,f)})},k=d?l.phase==="loading"?s("common.checking"):l.phase==="unknown"?s("botSettings.simple.appsUnknown"):l.apps.length===0?s("botSettings.simple.appsNone"):null:s("botSettings.simple.appsCannot",{name:t.name});return e.jsxs(e.Fragment,{children:[e.jsxs(L,{children:[k&&e.jsx(W,{children:k}),d&&l.apps.map(f=>e.jsxs("div",{"data-simple-app":f.slug,className:J,children:[e.jsx(ln,{card:f.card,className:"size-7 shrink-0"},`${f.card.logo}:${f.card.domain}`),e.jsx("div",{className:"min-w-0 flex-1 truncate text-[14px] font-medium text-ink",children:f.label}),e.jsx(ct,{color:t.color,checked:f.scope!==null,"aria-label":s("botSettings.simple.appToggle",{name:t.name,app:f.label}),disabled:!!t.busy,onClick:()=>p(f),className:"disabled:cursor-not-allowed"})]},f.slug))]}),(o.length>0||i)&&e.jsxs(L,{label:s("connectors.tab.mcp"),children:[i&&e.jsx(W,{children:s("botAccess.mcpRefreshError")}),o.map(f=>e.jsxs("div",{"data-simple-mcp":f.name,className:J,children:[e.jsx(Q,{icon:Bn}),e.jsx(te,{title:e.jsx("span",{className:"block truncate",children:f.name}),hint:f.enabled?f.offFor?.includes(t.id)?s("mcp.offFor",{bots:t.name}):void 0:s("botAccess.mcpDisabled")}),e.jsx(ct,{color:t.color,checked:u.has(f.name),"aria-label":s("botSettings.simple.appToggle",{name:t.name,app:f.name}),disabled:!f.enabled||!!t.busy||i,onClick:()=>h(f.name),className:"disabled:cursor-not-allowed"})]},f.name))]}),e.jsx(L,{children:e.jsx(fe,{"data-panel-link":"add-app",icon:Ee,onClick:()=>on(n,t.id),children:s("botPanel.apps.connectAnother")})})]})}function Pi({bot:t,derived:a}){const{state:n,dispatch:l}=B(),[r,i]=x.useState(()=>a.botRoutines.length===0?"new":null);return e.jsxs(e.Fragment,{children:[e.jsx(mr,{routines:a.botRoutines,runs:n.routineRuns,pausedBots:n.config?.pausedBots,loading:n.routinesLoadState==="loading"&&a.botRoutines.length===0,error:n.routinesLoadState==="error",onOpen:i,onLogs:c=>l({type:"showRoutines",section:"logs",botId:t.id,routineId:c.id}),onToggle:c=>l({type:"updateRoutine",routineId:c.id,patch:{enabled:!c.enabled}})}),e.jsx(L,{children:e.jsx(fe,{"data-panel-action":"new-routine",icon:Ee,onClick:()=>i("new"),children:s("botPanel.routines.add")})}),e.jsx("p",{className:"mx-1 text-[13px] leading-normal text-ink-secondary",children:s("botPanel.routines.ask",{name:t.name})}),r&&e.jsx(fr,{routine:r==="new"?void 0:r,bots:[t],lockedBotId:t.id,onClose:()=>i(null)},t.id)]})}function Oi({bot:t}){const a=ys(t),[n,l]=x.useState(""),[r,i]=x.useState(null),[c,d]=x.useState(!1),[o,u]=x.useState(null),p=t.memoryEnabled!==!1,h=a.docs?gs(a.docs):null,k=a.docs?.find(v=>v.path===Z)??null;x.useEffect(()=>i(null),[t.id,p]);const f=async v=>{if(c)return!1;d(!0),u(null);try{return await v()}catch(w){return u(Se(w,s("botPanel.library.memoryError"))),!1}finally{d(!1)}},b=(v,w)=>f(async()=>{const N=await Xe(t.id,v.path,w,v.exists?v.hash:void 0,a.mine);return N.ok?(a.setDoc(N.doc),!0):(await a.reload(),u(s("memory.conflict.title",{name:t.name})),!1)}),y=v=>{const w=a.docs?.find(N=>N.path===v.path);w&&(v.line!==null?b(w,oi(w.text,v.line)):f(async()=>(await ts(t.id,w.path,a.mine),await a.reload(),!0)))},C=async()=>{!k||!n.trim()||await b(k,ci(k.text,n))&&l("")};return p&&r?.botId===t.id?e.jsx(Ei,{bot:t,doc:r.doc,mine:a.mine,onDone:v=>{v&&a.setDoc(v),i(null),u(null)}}):e.jsxs(e.Fragment,{children:[e.jsxs(L,{children:[p?a.error?e.jsx(W,{tone:"warn",children:s("botPanel.library.memoryError")}):h===null?e.jsx(W,{children:s("common.checking")}):h.length===0?e.jsx(W,{children:s("botPanel.memory.empty")}):h.map(v=>e.jsxs("div",{"data-memory-note":v.line??v.path,className:J,children:[e.jsx("div",{className:"min-w-0 flex-1 text-[13px] leading-[1.45] text-ink",children:v.text}),e.jsx(Oe,{label:s("botPanel.memory.forget"),disabled:c,onClick:()=>y(v)})]},`${v.path}:${v.line}:${v.text}`)):e.jsx(W,{children:s("botPanel.library.memoryOff",{name:t.name})}),o&&e.jsx(W,{tone:"warn",children:o})]}),p&&e.jsxs(L,{children:[e.jsx(Gt,{"data-panel-form":"memory-add",value:n,placeholder:s("botPanel.memory.addPlaceholder",{name:t.name}),label:s("botPanel.memory.addPlaceholder",{name:t.name}),action:s("common.add"),disabled:c||k===null,onChange:l,onSubmit:()=>{C()}}),k&&e.jsx(fe,{"data-panel-link":"memory-text",icon:Pe,onClick:()=>i({botId:t.id,doc:k}),children:s("botPanel.memory.editText")})]}),p&&!a.mine&&e.jsx(wi,{bot:t,onChanged:a.reload})]})}function Ei({bot:t,doc:a,mine:n,onDone:l}){const[r,i]=x.useState({text:a.text,hash:a.hash}),[c,d]=x.useState(a.text),[o,u]=x.useState(null),[p,h]=x.useState(null),[k,f]=x.useState(!1),[b,y]=x.useState(null),C=x.useRef(!0);x.useEffect(()=>(C.current=!0,()=>{C.current=!1}),[]);const v=async N=>{f(!0),y(null);try{const E=await Xe(t.id,a.path,c,N,n);if(!C.current)return;E.ok?l(E.doc):u({current:E.current,currentHash:E.currentHash})}catch(E){y(Se(E,s("botPanel.library.memoryError")))}finally{f(!1)}},w=()=>{o&&(h(N=>N===null||N===c?c:`${N}
15
-
16
- ${c}`),i({text:o.current,hash:o.currentHash}),d(o.current),u(null))};return e.jsx(L,{children:e.jsxs(ce,{"data-panel-row":"memory-text",children:[o&&e.jsx(ps,{botName:t.name,busy:k,onReload:w,onOverwrite:()=>{v(o.currentHash)}}),e.jsx("textarea",{"data-memory-text":"",className:O(We,"min-h-[280px] resize-y font-mono text-[13px] leading-relaxed"),value:c,placeholder:s("memory.indexPlaceholder"),"aria-label":s("memory.botMemory"),readOnly:k,onChange:N=>d(N.target.value)}),b&&e.jsx("div",{className:"text-[13px] text-warning",children:b}),p!==null&&e.jsxs("div",{"data-memory-draft":"",children:[e.jsx("div",{className:"mb-1 text-[12px] text-ink-secondary",children:s("memory.unsavedDraft")}),e.jsx("pre",{className:"max-h-[160px] overflow-auto whitespace-pre-wrap rounded-lg border border-hairline/40 bg-inset p-3 font-mono text-[12px] leading-relaxed text-ink",children:p}),e.jsx("button",{type:"button",className:O(re,"mt-1"),onClick:()=>h(null),children:s("memory.dismissDraft")})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",className:re,disabled:k,onClick:()=>l(null),children:s("common.cancel")}),e.jsx("button",{type:"button","data-panel-done":"memory-text",className:re,disabled:k||c===r.text,onClick:()=>{v(r.hash)},children:k?s("memory.saving"):s("memory.save")})]})]})})}function Ri({bot:t}){const{request:a}=nn(),{state:n,dispatch:l}=B(),r=as(t),[i,c]=x.useState(""),[d,o]=x.useState(!1),[u,p]=x.useState([]),h=rn(n.config),k=async y=>{if(!r.working&&window.confirm(s(y.origin==="library"?"skills.unassignConfirm":"botPanel.skills.removeConfirm",{name:y.name}))){r.setWorking(y.name),r.setError("");try{await a(`/api/bots/${t.id}/skills/${encodeURIComponent(y.name)}`,{method:"DELETE"}),await r.refresh()}catch(C){r.setError(Se(C,s("botPanel.skills.removeFailed")))}finally{r.setWorking("")}}},f=async()=>{const y=i.trim();if(!(!y||d)){o(!0),r.setError(""),p([]);try{const C=await a(`/api/bots/${t.id}/skills`,{method:"POST",body:JSON.stringify({source:y})});p(sr(C.imported??[])),c(""),await r.refresh()}catch(C){r.setError(Se(C,s("botPanel.skills.importFailed")))}finally{o(!1)}}},b=()=>{if(h){l({type:"toggleSettings",open:!1}),l({type:"toggleAppSettings",open:!0,section:"skills"});return}Es(Si)};return e.jsxs(e.Fragment,{children:[e.jsxs(L,{children:[r.loading?e.jsx(W,{children:s("skills.loading")}):r.skills.length===0?e.jsx(W,{children:s("botSettings.simple.noSkills")}):r.skills.map(y=>e.jsx(Je,{"data-panel-row":`skill:${y.name}`,title:y.name,hint:y.description||y.source,label:s("botSettings.simple.skillToggle",{name:y.name}),color:t.color,checked:ns(y),disabled:!!r.working,onChange:()=>{r.toggle(y)},extra:y.origin==="imported"||y.origin==="native"?void 0:e.jsx(Oe,{"data-panel-action":`remove-skill:${y.name}`,label:s("botPanel.skills.remove",{name:y.name}),disabled:!!r.working,onClick:()=>{k(y)}})},y.name)),r.error&&!r.reviewing&&e.jsx(W,{tone:"warn",children:r.error})]}),e.jsx(er,{bot:t,onAdded:()=>{r.refresh()}}),e.jsxs(L,{children:[e.jsx(Gt,{"data-panel-form":"skill-import",value:i,placeholder:s("botPanel.skills.importPlaceholder"),label:s("skills.import.label"),action:d?s("skills.import.importing"):s("common.add"),disabled:d,onChange:c,onSubmit:()=>{f()}}),u.map(y=>e.jsx(W,{children:y},y)),e.jsx(fe,{"data-panel-link":"browse-skills",onClick:b,children:s("botPanel.skills.browse")})]}),r.reviewing&&e.jsx(tr,{skill:r.reviewing.skill,text:r.reviewing.text,error:r.error,working:r.working===r.reviewing.skill.name,onCancel:()=>r.setReviewing(null),onEnable:()=>{r.enableReviewed()}})]})}function Ii({bot:t}){const{capabilities:a}=ge(),n=a.host?.homeDir,{draft:l,setDraft:r,error:i,saving:c,canPick:d,save:o,pick:u}=Zn(t),[p,h]=x.useState(!1),k=!!t.cwd||p,f=()=>{if(d){u();return}h(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(L,{children:[e.jsx(He,{"data-panel-choice":"private",title:s("botPanel.folder.own"),hint:s("botPanel.folder.ownHint"),checked:!k,disabled:c,onClick:()=>{h(!1),t.cwd&&o(null)}}),e.jsx(He,{"data-panel-choice":"pick",title:s("botPanel.folder.pick"),hint:s("botPanel.folder.pickHint"),checked:k,disabled:c,onClick:()=>{t.cwd||f()}})]}),k&&e.jsxs(L,{children:[d?e.jsxs("div",{className:J,children:[e.jsx("div",{className:"min-w-0 flex-1 truncate rounded-lg border border-hairline/40 bg-inset px-3 py-2 font-mono text-[13px] text-ink",title:t.cwd,children:t.cwd?Ye(t.cwd,n):e.jsx("span",{className:"text-ink-secondary",children:s("botAccess.folder.private")})}),e.jsxs("button",{type:"button","data-panel-action":"pick-folder",disabled:c,onClick:()=>{u()},className:re,children:[e.jsx(zt,{size:14,"aria-hidden":"true"}),s("botAccess.folder.choose")]})]}):e.jsxs("form",{"data-panel-form":"folder-path",className:J,onSubmit:b=>{b.preventDefault();const y=(l??t.cwd??"").trim();y&&o(y)},children:[e.jsx("input",{value:l??t.cwd??"",placeholder:s("botAccess.folder.placeholder"),"aria-label":s("botAccess.folder.title"),onChange:b=>r(b.target.value),className:"h-8 min-w-0 flex-1 rounded-lg border border-hairline bg-inset px-2.5 font-mono text-[13px] text-ink outline-none placeholder:text-ink-tertiary focus:border-accent-border"}),e.jsx("button",{type:"submit",disabled:c||l===null,className:re,children:s("botAccess.folder.save")})]}),i&&e.jsx(W,{tone:"warn",children:i})]})]})}function Ai({bot:t,derived:a}){const n=xs(t);return e.jsx(pi,{bot:t,browserEnabled:a.browserEnabled,onOpenBrowser:()=>n("browser")})}function Li({bot:t}){return rs()?e.jsx(is,{bot:t}):null}function Mi({page:t,onOpen:a,editingInstructions:n,onEditInstructions:l,...r}){switch(t){case"settings":return e.jsx(ki,{...r,onOpen:a,editingInstructions:n,onEditInstructions:l});case"where":return e.jsx(Jr,{...r});case"apps":return e.jsx(Ci,{...r});case"routines":return e.jsx(Pi,{...r});case"visibility":return e.jsx(Li,{...r});case"memory":return e.jsx(Oi,{...r});case"skills":return e.jsx(Ri,{...r});case"folder":return e.jsx(Ii,{...r});case"browser":return e.jsx(Ai,{...r})}}const Rt="rounded-lg border border-accent-border bg-inset px-2 py-[3px] text-center text-ink outline-none placeholder:text-ink-tertiary";function It(t){const[a,n]=x.useState(null),l=x.useRef(!1),r=x.useRef(!1),i=x.useRef(null);x.useEffect(()=>{a!==null||!r.current||(r.current=!1,i.current?.focus())},[a]);const c=p=>{l.current=!1,n(p)},d=()=>{a!==null&&t(a),n(null)};return{draft:a,setDraft:n,start:c,onKeyDown:p=>{if(un(p.nativeEvent)){p.stopPropagation();return}p.key==="Enter"?(p.preventDefault(),l.current=!0,r.current=!0,d()):p.key==="Escape"&&(p.preventDefault(),p.stopPropagation(),l.current=!0,r.current=!0,n(null))},onBlur:()=>{l.current||d()},buttonRef:i}}function Ti({bot:t,activeState:a,patch:n,editorOpen:l,onToggleEditor:r}){const i=It(o=>{const u=o.trim();u&&u!==t.name&&n({name:u})}),c=It(o=>{const u=o.trim();u!==t.title.trim()&&n({title:u})}),d=t.title.trim();return e.jsxs("div",{className:"group/hero flex flex-col items-center text-center",children:[e.jsxs("button",{type:"button","data-panel-avatar":!0,"aria-label":s("botPanel.avatar.edit"),"aria-expanded":l,onClick:r,className:"group relative rounded-[18px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-border",children:[e.jsx(qe,{bot:t,size:64,state:a}),e.jsx("span",{"aria-hidden":"true",className:"absolute inset-0 flex items-center justify-center rounded-[18px] bg-black/0 text-white opacity-0 transition-[opacity,background-color] group-hover:bg-black/40 group-hover:opacity-100 group-focus-visible:bg-black/40 group-focus-visible:opacity-100 group-focus-within:opacity-100 touch:opacity-100 motion-reduce:transition-none",children:e.jsx(dt,{size:20})}),t.chiefOfStaff&&e.jsxs("span",{"data-panel-chief":!0,title:s("chat.chiefOfStaff"),className:"absolute -bottom-0.5 -right-0.5 flex size-[22px] items-center justify-center rounded-full bg-accent text-accent-ink ring-[3px] ring-app",children:[e.jsx(dn,{size:12,"aria-hidden":"true"}),e.jsx("span",{className:"sr-only",children:s("chat.chiefOfStaff")})]}),e.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute left-1/2 top-[calc(100%+4px)] z-10 -translate-x-1/2 whitespace-nowrap rounded-md border border-hairline bg-menu px-[7px] py-0.5 text-[12px] text-ink opacity-0 transition-opacity group-hover:opacity-100",children:s("botPanel.avatar.edit")})]}),e.jsx("div",{"data-panel-name-row":!0,className:"mt-2 flex max-w-full items-center justify-center",children:e.jsx("h2",{id:"bot-settings-title",className:"flex min-w-0 justify-center",children:i.draft!==null?e.jsx("input",{autoFocus:!0,"data-panel-rename-input":!0,"aria-label":s("botSettings.simple.name"),maxLength:Ke.name,value:i.draft,onChange:o=>i.setDraft(o.target.value),onKeyDown:i.onKeyDown,onBlur:i.onBlur,className:O(Rt,"w-[220px] max-w-full text-[17px] font-medium leading-6")}):e.jsxs("button",{ref:i.buttonRef,type:"button","data-panel-rename":!0,title:s("botPanel.rename"),onClick:()=>i.start(t.name),className:"group/name relative inline-flex max-w-full items-center rounded-[8px] px-1.5 text-[17px] font-medium leading-6 text-ink hover:bg-ink/[0.04]",children:[e.jsx("span",{className:"min-w-0 truncate",children:t.name}),e.jsx(dt,{size:13,"aria-hidden":"true",className:"absolute -right-4 shrink-0 text-ink-tertiary opacity-0 transition-opacity group-hover/name:opacity-100 group-focus-visible/name:opacity-100 group-focus-within/name:opacity-100 touch:opacity-100"})]})})}),c.draft!==null?e.jsx("input",{autoFocus:!0,"data-panel-label-input":!0,"aria-label":s("botSettings.simple.job"),placeholder:s("botSettings.simple.jobPlaceholder"),maxLength:Ke.title,value:c.draft,onChange:o=>c.setDraft(o.target.value),onKeyDown:c.onKeyDown,onBlur:c.onBlur,className:O(Rt,"mt-[3px] w-[200px] max-w-full text-[13px]")}):d&&e.jsx("button",{ref:c.buttonRef,type:"button","data-panel-label":!0,onClick:()=>c.start(t.title),className:"mt-px max-w-full truncate rounded-md px-1.5 py-px text-[13px] text-ink-secondary hover:bg-ink/[0.04]",children:d})]})}function be(t,a){return t?Jt(t,a):{tab:"details"}}function Bi({bot:t,derived:a,linkedSection:n,onClose:l}){const{dragProps:r}=Xt(),i=mn(),[c,d]=x.useState(()=>be(n,i).tab),[o,u]=x.useState(()=>{const m=be(n,i).page;return m?[m]:[]}),[p,h]=x.useState(()=>be(n,i).anchor??null),[k,f]=x.useState(!1),[b,y]=x.useState(()=>!!be(n,i).editInstructions),C=x.useRef(null),v=x.useRef(null),w=o.at(-1)??null,N=()=>C.current?.scrollTo({top:0}),E=m=>{d(m.tab),u(m.page?[m.page]:[]),h(m.anchor??null),f(!1),y(!!m.editInstructions),N()},M=m=>E({tab:m}),F=m=>{u(R=>[...R,m]),f(!1),N()},T=()=>{f(!1),v.current?.querySelector("[data-panel-avatar]")?.focus()},I=()=>{u(m=>m.slice(0,-1)),N()};x.useEffect(()=>{n&&E(Jt(n,i))},[n,i]),x.useEffect(()=>{p&&(C.current?.querySelector(`[data-panel-card="${p}"]`)?.scrollIntoView({block:"start"}),h(null))},[p,w,c]);const z=m=>{if(m.key!=="Escape"||m.defaultPrevented)return;const R=m.target,D=typeof R?.closest=="function"?R.closest('[role="dialog"], [role="alertdialog"]'):null;if(!(D&&!D.contains(m.currentTarget)&&D!==v.current&&!v.current?.contains(D))){if(k)T();else if(o.length>0)I();else return;m.preventDefault(),m.stopPropagation()}},A=o.length>1?s(ve[o[o.length-2]].title,{name:t.name}):s(ut[c]);return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",onKeyDown:z,children:[e.jsxs("div",{...r,className:"flex h-[50px] shrink-0 items-start justify-end gap-2.5 px-[13px] pt-[13px]",children:[e.jsx(pn,{bot:t,className:Me}),e.jsx("button",{type:"button","data-panel-gear":!0,"aria-label":s("botPanel.page.settings"),title:s("botPanel.page.settings"),"aria-current":w==="settings"?"page":void 0,onClick:()=>E({tab:"details",page:"settings"}),className:Me,children:e.jsx(xn,{size:16,className:"pointer-events-none"})}),e.jsx("button",{type:"button",onClick:l,"aria-label":s("botSettings.simple.close"),className:Me,children:e.jsx(Tt,{size:16,className:"pointer-events-none"})})]}),e.jsx("div",{ref:C,className:"@container relative min-h-0 flex-1 overflow-y-auto px-4 pb-7",children:w===null?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative mt-3.5",ref:v,children:[e.jsx(Ti,{bot:t,activeState:a.activeState,patch:a.patch,editorOpen:k,onToggleEditor:()=>f(m=>!m)}),k&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-20","aria-hidden":"true","data-panel-scrim":!0,onClick:T}),e.jsx(Vr,{bot:t,activeState:a.activeState,onPatch:a.patch,onClose:T})]})]}),e.jsx("div",{role:"tablist","aria-label":s("botSettings.simple.tabs"),className:"sticky top-0 z-[1] -mx-4 mt-[15px] flex justify-center bg-app px-4 pb-2.5 pt-1 after:pointer-events-none after:absolute after:inset-x-0 after:top-full after:h-3 after:bg-linear-to-b after:from-app after:to-transparent",children:e.jsx("div",{className:"flex min-w-0 gap-0.5 rounded-full bg-ink/[0.05] p-[3px]",children:hn.map(m=>e.jsx("button",{type:"button",role:"tab","aria-selected":c===m,"data-panel-tab":m,onClick:()=>M(m),className:O("h-[26px] min-w-0 shrink truncate rounded-full px-3 text-[13px] leading-[18px] transition-colors",c===m?"bg-ink/[0.1] font-medium text-ink":"text-ink-secondary hover:text-ink"),children:s(ut[m])},m))})}),e.jsxs("div",{role:"tabpanel",children:[c==="details"&&e.jsx(ii,{bot:t,derived:a,onOpen:F}),c==="library"&&e.jsx(vs,{bot:t,onOpen:F}),c==="computer"&&e.jsx(Qr,{bot:t,derived:a,onOpen:F})]})]}):e.jsxs("div",{"data-panel-page-view":w,children:[e.jsx("span",{id:"bot-settings-title",className:"sr-only",children:t.name}),e.jsx(fn,{back:A,title:s(ve[w].title,{name:t.name}),intro:ve[w].intro?s(ve[w].intro,{name:t.name}):void 0,onBack:I}),e.jsx("div",{className:O("mt-4",Ni),children:e.jsx(Mi,{page:w,bot:t,derived:a,onOpen:F,editingInstructions:b,onEditInstructions:y})})]})})]})}function Di(t,a){const{state:n,flushBotPatches:l}=B(),[r,i]=x.useState(null),[c,d]=x.useState(!1),[o,u]=x.useState(null),[p,h]=x.useState(!1),k=x.useMemo(()=>JSON.stringify([t.name,t.title,t.description,t.soul,t.computer,t.cloudBackend,t.cwd,t.autoApprove,t.section,t.composio,t.browser,t.mcpServers,t.chiefOfStaff,t.managedSections,t.modelSelection]),[t.name,t.title,t.description,t.soul,t.computer,t.cloudBackend,t.cwd,t.autoApprove,t.section,t.composio,t.browser,t.mcpServers,t.chiefOfStaff,t.managedSections,t.modelSelection]),f=a.followEdits??!0,b=f?k:null,y=f?n.routines:null,C=f?n.webhooks:null;return x.useEffect(()=>{if(!a.overview&&!a.prompt)return;let v=!1;return(async()=>(await l(t.id),!v&&(a.overview&&se(`/api/bots/${t.id}/overview`).then(N=>{v||(i(N),d(!1))}).catch(()=>{v||d(!0)}),a.prompt&&se(`/api/bots/${t.id}/system-prompt`).then(N=>{v||(u(N),h(!1))}).catch(()=>{v||h(!0)}))))(),()=>{v=!0}},[t.id,a.overview,a.prompt,b,y,C,l]),{overview:r,overviewError:c,prompt:o,promptError:p}}function Fi(t,a){const{dispatch:n,flushBotPatches:l}=B(),[r,i]=x.useState(null),[c,d]=x.useState(!1),[o,u]=x.useState(null),p=x.useRef(0),[h,k]=x.useState(!1),[f,b]=x.useState(null),y=x.useCallback(()=>{const w=++p.current;return d(!1),l(t.id).then(()=>se(`/api/bots/${t.id}/history?limit=100`)).then(N=>{w===p.current&&(i(N.rows),u(N.revision))}).catch(()=>{w===p.current&&d(!0)})},[t.id,l]);return x.useEffect(()=>{if(a)return y(),()=>{p.current++}},[a,y]),{rows:r,error:c,revision:o,rollingBack:h,rollbackTarget:f,setRollbackTarget:b,rollback:async w=>{if(!h){b(null),k(!0);try{await l(t.id),await se(`/api/bots/${t.id}/history/rollback`,{method:"POST",body:JSON.stringify(w)})}catch(N){n({type:"error",message:N instanceof Error?N.message:s("botOverview.undoFailed")})}finally{await y(),k(!1)}}},requestRollback:w=>{o&&b({id:w,expectedRevision:o})}}}function $i({history:t,returnFocusRef:a}){const{rollbackTarget:n,setRollbackTarget:l,rollback:r}=t;return e.jsx(gn,{open:n!==null,title:s("botOverview.restoreSoul.title"),body:s("botOverview.restoreSoul.body"),confirmLabel:s("botOverview.restoreSoul.confirm"),tone:"neutral",returnFocusRef:a,onCancel:()=>l(null),onConfirm:()=>{n&&r(n)}})}const zi={memory:"memory",skills:"skills",folder:"access"},ks=t=>t.labelKey?s(t.labelKey):t.label;function At(t,a){return a?[t.label,ks(t),...t.keywords].some(n=>n.toLowerCase().includes(a)):!0}function nl({bot:t,overlay:a=!1}){const{state:n,dispatch:l}=B(),r=n.botSettingsSection,i=yn(t),c=x.useRef(null),{dragProps:d}=Xt(),[o,u]=x.useState(""),p=!n.botSettingsExpandAccordion,h=o.trim().toLowerCase(),f=!Mt(),b=!p&&!n.botSettingsExpandRemembered?r:null,y=ds(t.id),C=Ge(),v=vn(),w=Sr.filter(A=>A.id!=="slack"||y!==null).filter(A=>A.id!=="visibility"||!window.ogb&&C===!0&&!v),N=w.filter(A=>At(A,h)),{overview:E,overviewError:M,prompt:F,promptError:T}=Di(t,{overview:r==="overview"&&!f,prompt:r==="overview"&&!f}),I=Fi(t,r==="history"&&!f);x.useEffect(()=>{if(!p){if(h){u("");return}c.current?.querySelector(`[data-bot-settings-section="${r}"]`)?.scrollIntoView({block:"nearest"})}},[p,r,h]),x.useEffect(()=>{const A=document.activeElement instanceof HTMLElement?document.activeElement:null,m=c.current;m?.focus();const R=D=>{const H=m?.querySelector('[role="dialog"], [role="alertdialog"]');H&&H.getClientRects().length>0||m&&D.target instanceof Node&&!m.contains(D.target)||D.key==="Escape"&&!D.defaultPrevented&&(D.preventDefault(),l({type:"toggleSettings",open:!1}))};return window.addEventListener("keydown",R),()=>{window.removeEventListener("keydown",R),A?.focus()}},[l]);const z=A=>{switch(A){case"overview":return E===null&&M?e.jsx("div",{className:"rounded-xl bg-card p-4 text-[13px] text-ink-secondary",children:s("botSettings.overviewFailed")}):e.jsx(Ar,{overview:E,refreshError:E!==null&&M,prompt:F,promptError:T,onOpen:m=>l({type:"toggleSettings",open:!0,section:m}),onSetup:i.canCoordinate&&!t.busy?()=>{l({type:"toggleSettings",open:!1}),l({type:"send",botId:t.id,text:"/setup",threadId:t.threadId})}:void 0});case"identity":return e.jsx(cr,{bot:t,patch:i.patch,activeState:i.activeState,mascotMotion:i.mascotMotion});case"soul":return e.jsx(or,{bot:t,patch:i.patch});case"slack":return y?e.jsx(Lr,{managementUrl:y}):null;case"skills":return e.jsx(lr,{bot:t});case"memory":return e.jsx(Br,{bot:t,active:!p&&r==="memory",onToggle:m=>i.patch({memoryEnabled:m})});case"library":return e.jsx(vs,{bot:t,onOpen:m=>l({type:"toggleSettings",open:!0,section:zi[m]??"overview"})});case"routines":return e.jsx(pr,{bot:t,routines:i.botRoutines,runs:n.routineRuns});case"access":return e.jsx(ir,{bot:t,derived:i});case"model":return e.jsx(rr,{bot:t});case"permissions":return e.jsx(nr,{bot:t,derived:i});case"voice":return e.jsx(ar,{bot:t,derived:i});case"visibility":return e.jsx(is,{bot:t});case"history":return I.rows===null&&I.error?e.jsx("div",{className:"rounded-xl bg-card p-4 text-[13px] text-ink-secondary",children:s("botSettings.historyFailed")}):e.jsx(zr,{bot:t,rows:I.rows,refreshError:I.rows!==null&&I.error,onRollback:I.requestRollback,rollingBack:I.rollingBack||!I.revision});case"usage":return e.jsx(Hr,{bot:t});default:return null}};return e.jsxs(e.Fragment,{children:[e.jsx("aside",{ref:c,id:f?bn:void 0,role:"dialog","aria-labelledby":"bot-settings-title",tabIndex:-1,className:jn(a,f),children:f?e.jsx(Bi,{bot:t,derived:i,linkedSection:b,onClose:()=>l({type:"toggleSettings",open:!1})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{...d,className:"flex shrink-0 items-center justify-between px-4 py-3",children:[e.jsx("span",{id:"bot-settings-title",className:"truncate text-[15px] font-semibold text-ink",children:t.name}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(kn,{bot:t,className:"rounded-md p-1 text-ink-secondary hover:bg-control hover:text-ink"}),e.jsx("button",{type:"button",onClick:()=>l({type:"toggleSettings",open:!1}),"aria-label":s("botSettings.simple.close"),className:"rounded-md p-1 text-ink-secondary hover:bg-control hover:text-ink",children:e.jsx(Tt,{size:18,className:"pointer-events-none"})})]})]}),e.jsxs("div",{className:"mx-4 mb-2 flex shrink-0 items-center gap-2 rounded-lg border border-transparent bg-control/70 px-2.5 py-2 focus-within:border-focus",children:[e.jsx(Lt,{size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("input",{value:o,onChange:A=>{u(A.target.value),l({type:"toggleSettings",open:!0})},onKeyDown:A=>{A.key==="Escape"&&(A.stopPropagation(),o?u(""):l({type:"toggleSettings",open:!1}))},placeholder:s("botSettings.search"),"aria-label":s("botSettings.searchAria"),className:"w-full bg-transparent text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto",children:[N.length===0&&e.jsx("div",{className:"px-4 py-4 text-[13px] leading-relaxed text-ink-secondary",children:s("botSettings.searchNone",{query:o.trim()})}),w.map(A=>{const{id:m,icon:R}=A,D=ks(A),H=At(A,h);if(!H&&m!=="memory")return null;const _=!p&&r===m;return e.jsxs("div",{"data-bot-settings-section":m,className:"border-b border-hairline/30",hidden:!H,children:[e.jsxs("button",{type:"button",onClick:()=>{if(r===m&&!p){l({type:"toggleSettings",open:!0});return}l({type:"toggleSettings",open:!0,section:m})},"aria-expanded":_,className:O("flex w-full shrink-0 items-center gap-2.5 px-4 py-2.5 text-left text-[14px]",_?"bg-control/60 text-ink":"text-ink-secondary hover:bg-control/40 hover:text-ink"),children:[e.jsx(R,{size:15,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:D}),e.jsx(pe,{size:16,className:O("shrink-0 text-ink-secondary transition-transform",_&&"rotate-180")})]}),m==="memory"?e.jsx("div",{hidden:!_,className:"px-4 pb-4 pt-1",children:z("memory")}):_&&e.jsx("div",{className:"px-4 pb-4 pt-1",children:z(m)})]},m)})]})]})}),e.jsx($i,{history:I,returnFocusRef:c})]})}export{nl as BotSettingsDialog};
@@ -1 +0,0 @@
1
- import{t as s,r as o,d as Te,j as e,X as ve,f as Ae,a as G,ah as ye,ai as Le,h as De,k as Oe,aj as Me,ak as Ue,al as Fe,b as ze,am as Ie,an as Ke,ao as _e,ap as $e,p as le,B as He}from"./styles-BcVNrxGE.js";import{n as B,E as Je,u as k,bH as ee,bI as Ve,bJ as w,S as T,bK as We,bL as we,bM as te,bN as Ye,bO as qe,bP as Xe,bQ as oe,bR as ce,bS as Qe,bT as Ze,bU as Ge,bV as je,D as O,bW as et,bX as tt,e as Se,bY as st,bZ as de,b_ as nt,b$ as at,c0 as it,c1 as rt,c2 as lt,c3 as ot,c4 as ct,c5 as dt,c6 as ut,c7 as pt,c8 as mt,c9 as xt,ca as ue,cb as gt,cc as ht,cd as ft,ce as bt,cf as ke,cg as Ne,ch as vt,ci as yt,cj as wt,ck as jt,cl as St,cm as pe,T as Ce,cn as kt}from"./App-DBQxC6tF.js";import{B as me,E as Nt,s as Ct,r as xe,p as Et,c as Bt,a as Rt}from"./new-bot-DkcWCdL_.js";import{o as Pt}from"./index-DgGTgaCO.js";import{I as Tt,S as At,a as Lt,A as Dt,M as Ot,P as Mt,V as Ut,v as Ft,i as ge}from"./VisibilitySection-CpwyInUL.js";import{R as zt}from"./RoutinesPage-9VDuovqw.js";import{r as It,L as X,Q as Kt,R as _t,U as $t,P as Ht}from"./PlacesRail-D510vk5R.js";import{p as Jt,d as Vt,e as Wt,f as Yt}from"./team-share-C9qIusMs.js";import{B as qt}from"./BrowserProfilesManager-B5ZQeFJ9.js";function Xt(t){const n=[];for(const a of t){const i=a.source==="org"?s("newBot.presetsFromOrganization",{name:a.publisherName??a.packageName}):s("newBot.presetsImported"),r=n.find(l=>l.label===i);r?r.presets.push(a):n.push({label:i,presets:[a]})}return n}function Qt(t){const n={name:t.bot.name??t.name,title:t.bot.title??"",description:t.bot.description??"",soul:t.bot.soul??""},a=t.bot.appearance;return a&&(n.color=a.color,n.mascotExpression=a.mascotExpression??null,a.mascotBody&&(n.mascotBody=a.mascotBody)),n}function Zt(t){const n=t.bot.appearance?.avatar;if(!n)return null;let a;try{a=atob(n.data)}catch{return null}const i=new Uint8Array(a.length);for(let r=0;r<a.length;r+=1)i[r]=a.charCodeAt(r);return new File([i],`preset.${n.mime.slice(6)}`,{type:n.mime})}function Gt(t){const n=[t.source==="org"&&t.publisherName?s("newBot.presetFromOrg",{package:t.packageName,release:t.release,publisher:t.publisherName}):s("newBot.presetFrom",{package:t.packageName,release:t.release})];t.description&&n.push(t.description);const a=t.skills.map(i=>i.name).join(", ");return a&&n.push(s(t.skillsEnabled?"newBot.presetSkillsOn":"newBot.presetSkillsOff",{names:a})),t.notes.length&&n.push(s("newBot.presetNotes",{names:t.notes.join(", ")})),t.playbooks.length&&n.push(s("newBot.presetPlaybooks",{names:t.playbooks.join(", ")})),n.push(s("newBot.presetKeeps")),n}function es(t){return{id:t.id,skills:t.skills.map(n=>n.name),notes:[...t.notes]}}function he(t){const n=a=>a?.trim()?a.trim():void 0;return{format:"package",version:2,kind:"library",name:n(t.name),presetName:n(t.name),presetDescription:n(t.description),release:n(t.release),notes:n(t.notes),includeMemory:t.includeNotes,...t.picture?{presetAvatar:t.picture}:{},...t.dryRun?{dryRun:!0}:{}}}function fe({preview:t,localSkips:n}){const a=t.document.package.presets?.[0],i=Object.keys(a?.seed?.memory??{}).length,r=[[s("teamShare.part.skills"),a?.skills?.length?`${a.skills.length} · ${a.skills.join(", ")}`:"0"],[s("teamShare.part.notes"),i?String(i):s("teamShare.none")],[s("teamShare.part.pictures"),a?.bot.appearance?.avatar?s("teamShare.yes"):s("teamShare.none")]],l=[...n,...t.skipped.map(d=>Vt(d,t.document))];return e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] font-medium text-ink-secondary",children:s("teamShare.included")}),e.jsx("dl",{className:"mt-2 grid grid-cols-[minmax(0,1fr)_auto] gap-x-4 gap-y-1.5 rounded-xl bg-raised/45 px-4 py-3 text-[13px]",children:r.map(([d,c])=>e.jsxs("div",{className:"contents",children:[e.jsx("dt",{className:"text-ink-secondary",children:d}),e.jsx("dd",{className:"max-w-[300px] truncate text-right text-ink",title:c,children:c})]},d))}),e.jsxs("p",{className:"mt-3 flex items-start gap-2 text-[13px] leading-relaxed text-ink-secondary",children:[e.jsx(Je,{size:15,className:"mt-0.5 shrink-0 text-success"}),e.jsx("span",{children:s("presetShare.never")})]}),t.redacted.length>0&&e.jsxs("div",{className:"mt-3 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:s("teamShare.redacted")}),e.jsx("ul",{className:"mt-1 list-disc pl-5",children:t.redacted.map(d=>e.jsx("li",{children:Wt(d,t.document)},d))})]}),l.length>0&&e.jsxs("div",{className:"mt-3 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:s("teamShare.skipped")}),e.jsx("ul",{className:"mt-1 list-disc pl-5",children:l.map((d,c)=>e.jsx("li",{children:d},`${d}-${c}`))})]})]})}function ts({onClose:t}){const n=o.useRef(null),[a,i]=o.useState(""),[r,l]=o.useState(""),[d,c]=o.useState(""),[p,g]=o.useState(""),[j,A]=o.useState(!0),[N,x]=o.useState(!0),[h,y]=o.useState(null),[b,v]=o.useState(null),[f,M]=o.useState(!1),[I,$]=o.useState(null),[U,K]=o.useState(""),_=o.useRef(0);o.useEffect(()=>{let u=!1;return B("/api/bot-defaults").then(async({defaults:R})=>{!u&&R.profile.name?.trim()&&i(L=>L||R.profile.name.trim());const C=await Jt([{id:"defaults",avatarUrl:R.profile.avatarUrl,avatarCrop:R.profile.avatarCrop}]);u||y({dataUrl:C.avatars.defaults,skipped:C.skipped.map(L=>`${s("teamShare.field.picture")} — ${Te(`teamShare.skip.${L.reason}`,L.reason)}`)})}).catch(()=>{u||y({skipped:[]})}),()=>{u=!0}},[]);const V=u=>({name:a,description:r,release:d,notes:p,includeNotes:j,dryRun:u,...N&&h?.dataUrl?{picture:h.dataUrl}:{}});o.useEffect(()=>{if(!h)return;const u=++_.current,R=window.setTimeout(()=>{B("/api/teams/export",{method:"POST",body:JSON.stringify(he({...V(!0),release:void 0}))}).then(C=>{u===_.current&&(v(C),K(""),c(L=>L||C.document.package.release))}).catch(C=>{u===_.current&&(v(null),K(C instanceof Error?C.message:String(C)))})},250);return()=>window.clearTimeout(R)},[h,j,N]);const F=async()=>{if(!f){M(!0),K("");try{const u=await B("/api/teams/export",{method:"POST",body:JSON.stringify(he(V(!1)))});Yt(u.filename,u.document),$(u)}catch(u){K(u instanceof Error?u.message:String(u))}finally{M(!1)}}};o.useEffect(()=>{const u=document.activeElement instanceof HTMLElement?document.activeElement:null;return n.current?.focus(),()=>{u?.isConnected&&u.focus()}},[]);const H=N?h?.skipped??[]:[],z="mt-1 w-full rounded-lg border border-hairline/50 bg-inset px-3 py-2 text-[14px] text-ink disabled:opacity-60";return It.createPortal(e.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center bg-black/55 p-4",onMouseDown:u=>{u.target===u.currentTarget&&!f&&t()},children:e.jsxs("div",{ref:n,role:"dialog","aria-modal":"true","aria-labelledby":"share-preset-title",tabIndex:-1,className:"flex max-h-[90vh] w-full max-w-[560px] flex-col overflow-hidden rounded-2xl border border-hairline/50 bg-panel text-ink shadow-2xl outline-none",onKeyDown:u=>{if(u.key==="Escape"&&!f&&(u.stopPropagation(),t()),u.key==="Tab"){const R=n.current?.querySelectorAll("input:enabled, textarea:enabled, button:enabled");if(!R?.length)return;const C=R[0],L=R[R.length-1];u.shiftKey&&document.activeElement===C?(u.preventDefault(),L.focus()):!u.shiftKey&&document.activeElement===L&&(u.preventDefault(),C.focus())}},children:[e.jsxs("header",{className:"flex items-start justify-between gap-3 px-6 pb-2 pt-5",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"share-preset-title",className:"text-[17px] font-semibold",children:s("presetShare.title")}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("presetShare.intro")})]}),e.jsx("button",{"aria-label":s("presetShare.close"),disabled:f,onClick:t,className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised",children:e.jsx(ve,{size:18})})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-4 pt-2",children:I?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"flex items-center gap-2 text-[14px] font-medium text-ink",children:[e.jsx(Ae,{size:16,className:"text-success"}),s("teamShare.saved",{filename:I.filename})]}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("presetShare.savedHint")}),e.jsx("div",{className:"mt-4",children:e.jsx(fe,{preview:I,localSkips:H})})]}):e.jsxs(e.Fragment,{children:[b?e.jsx(fe,{preview:b,localSkips:H}):!U&&e.jsxs("div",{className:"flex items-center gap-2 py-6 text-[13px] text-ink-secondary",children:[e.jsx(X,{size:15,className:"animate-spin"}),s("presetShare.preparing")]}),e.jsxs("fieldset",{className:"mt-4 space-y-2 text-[13px]",disabled:f,children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",className:"size-4 accent-accent",checked:N,onChange:u=>x(u.target.checked)}),s("presetShare.includePicture")]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",className:"size-4 accent-accent",checked:j,onChange:u=>A(u.target.checked)}),s("presetShare.includeNotes")]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:[e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[s("presetShare.name"),e.jsx("input",{value:a,maxLength:100,disabled:f,onChange:u=>i(u.target.value),className:z})]}),e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[s("teamShare.release"),e.jsx("input",{value:d,maxLength:20,disabled:f,placeholder:"1.0.0",onChange:u=>c(u.target.value),className:z})]})]}),e.jsxs("label",{className:"mt-3 block text-[13px] text-ink-secondary",children:[s("presetShare.description"),e.jsx("input",{value:r,maxLength:300,disabled:f,onChange:u=>l(u.target.value),className:z})]}),e.jsxs("label",{className:"mt-3 block text-[13px] text-ink-secondary",children:[s("teamShare.notes"),e.jsx("textarea",{value:p,maxLength:4e3,rows:2,disabled:f,onChange:u=>g(u.target.value),className:z})]})]})}),U&&e.jsx("p",{role:"alert",className:"mx-6 mb-2 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:U}),e.jsx("footer",{className:"flex justify-end gap-2 border-t border-hairline/35 px-6 py-3",children:I?e.jsx("button",{onClick:t,className:"rounded-lg bg-accent px-4 py-2 text-[13px] font-medium text-white",children:s("teamShare.done")}):e.jsxs(e.Fragment,{children:[e.jsx("button",{disabled:f,onClick:t,className:"rounded-lg px-3 py-2 text-[13px] text-ink-secondary hover:bg-raised",children:s("common.cancel")}),e.jsxs("button",{disabled:f||!b,onClick:()=>{F()},className:"flex items-center gap-2 rounded-lg bg-accent px-4 py-2 text-[13px] font-medium text-white disabled:opacity-40",children:[f&&e.jsx(X,{size:14,className:"animate-spin"}),f?s("teamShare.saving"):s("teamShare.save")]})]})})]})}),document.body)}function se(){const{dispatch:t}=k(),[n,a]=o.useState(!1),[i,r]=o.useState("");return{saving:n,error:i,save:async d=>{if(!n){a(!0),r("");try{const c=await B("/api/config",{method:"PATCH",body:JSON.stringify(d)});t({type:"configStatus",config:c})}catch(c){r(c instanceof Error?c.message:s("settings.experimental.error"))}finally{a(!1)}}}}}function Es(){const{state:t}=k(),n=ee(t.config),a=Ve(t.config),i=t.config?.browserEngine?.installable===!0,r=window.ogb?.platform==="win32"&&!a&&!i,{saving:l,error:d,save:c}=se();return e.jsx(w,{title:s("settings.experimental.browserAria"),subtitle:a?n?s("settings.experimental.browserOn"):s("settings.experimental.browserOff"):r?s("settings.experimental.browserWindows"):We(t.config),message:d?e.jsx("p",{role:"alert",className:"text-danger",children:d}):null,children:e.jsx(T,{checked:n,"aria-label":s("settings.experimental.browserAria"),disabled:l||!n&&!a&&!i,onClick:()=>{c({features:{browser:!n}})},className:"disabled:cursor-wait disabled:opacity-50"})})}function Bs(){const{state:t}=k(),n=we(),a=t.config?.browserEngine?.serverSites,{saving:i,error:r,save:l}=se();return a===void 0||n!==!0||!ee(t.config)?null:e.jsx(w,{title:s("settings.browser.serverSites"),subtitle:s("settings.browser.serverSitesDetail"),message:r?e.jsx("p",{role:"alert",className:"text-danger",children:r}):null,children:e.jsx(T,{checked:a,"aria-label":s("settings.browser.serverSites"),disabled:i,onClick:()=>{l({browserEngine:{egress:{localNetwork:!a}}})},className:"disabled:cursor-wait disabled:opacity-50"})})}function ss(){const{state:t}=k(),n=t.config?.browserEngine?.engine==="chrome",{saving:a,error:i,save:r}=se();return e.jsxs("div",{className:"mt-4 border-t border-hairline/30 pt-4","data-testid":"new-browser-settings",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:s("settings.experimental.newBrowser")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:s("settings.experimental.newBrowserDetail")})]}),e.jsx(T,{checked:n,"aria-label":s("settings.experimental.newBrowserAria"),disabled:a,onClick:()=>{r({browserEngine:{engine:n?"agent-browser":"chrome"}})},className:"disabled:cursor-wait disabled:opacity-50"})]}),i?e.jsx("p",{role:"alert",className:"mt-2 text-[12px] text-danger",children:i}):null]})}function ns(){const{state:t,dispatch:n}=k(),a=te(t.config),i=Ye(t.config),r=qe(t.config),l=Xe(t.bots,t.instances),[d,c]=o.useState(String(r)),[p,g]=o.useState(!1),[j,A]=o.useState(!1),[N,x]=o.useState(""),h=o.useRef(!1);o.useEffect(()=>{p||c(String(r))},[r,p]);const y=async v=>{if(h.current)return!1;h.current=!0,A(!0),x("");try{const f=await B("/api/config",{method:"PATCH",body:JSON.stringify({features:v})});return n({type:"configStatus",config:f}),!0}catch(f){return x(f instanceof Error?f.message:s("settings.experimental.error")),!1}finally{h.current=!1,A(!1)}},b=async()=>{if(!p)return;const v=Qe(d);if(v===null){x(s("settings.experimental.skillReviewStepsRange",{min:ce,max:oe}));return}await y({skillReviewSteps:v})&&g(!1)};return e.jsxs("div",{className:"mt-4 border-t border-hairline/30 pt-4","data-testid":"skill-review-settings",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:s("settings.experimental.skillReview")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:s(a?"settings.experimental.skillReviewDetail":"settings.experimental.skillReviewNeedsAuthoring")})]}),e.jsx(T,{checked:i,"aria-label":s("settings.experimental.skillReviewAria"),disabled:j||!a,onClick:()=>{y({skillReview:!i})},className:"disabled:cursor-not-allowed disabled:opacity-50"})]}),e.jsx(as,{engines:l}),i?e.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[e.jsx("label",{htmlFor:"skill-review-steps",className:"text-[13px] text-ink",children:s("settings.experimental.skillReviewSteps")}),e.jsx("div",{className:`flex w-[96px] items-center rounded-lg border bg-inset ${N?"border-danger/60":"border-hairline/40 focus-within:border-focus"}`,children:e.jsx("input",{id:"skill-review-steps",type:"number",min:ce,max:oe,step:1,inputMode:"numeric",value:d,disabled:j,"aria-invalid":!!N,onChange:v=>{c(v.target.value),g(!0),x("")},onBlur:()=>{b()},onKeyDown:v=>{v.key==="Enter"&&v.currentTarget.blur()},className:"min-w-0 flex-1 bg-transparent px-3 py-1.5 text-[14px] tabular-nums text-ink focus:outline-none"})})]}):null,N?e.jsx("p",{role:"alert",className:"mt-2 text-[12px] text-danger",children:N}):null]})}function as({engines:t}){return t.length?e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-ink-secondary","data-testid":"skill-review-engine-note",children:s("settings.experimental.skillReviewNoEngine",{engines:t.join(", ")})}):null}const is=[{value:"off",label:"settings.experimental.shareSkillsOff"},{value:"ask",label:"settings.experimental.shareSkillsAsk"},{value:"auto",label:"settings.experimental.shareSkillsAuto"}];function rs(){const{state:t,dispatch:n}=k(),[a,i]=o.useState(!1),[r,l]=o.useState("");if(!Ze(t.config))return null;const d=te(t.config),c=Ge(t.config),p=async g=>{if(!(a||g===c)){i(!0),l("");try{const j=await B("/api/config",{method:"PATCH",body:JSON.stringify({features:{shareLearnedSkills:g}})});n({type:"configStatus",config:j})}catch(j){l(j instanceof Error?j.message:s("settings.experimental.error"))}finally{i(!1)}}};return e.jsxs("div",{className:"mt-4 border-t border-hairline/30 pt-4","data-testid":"share-learned-skills-settings",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:s("settings.experimental.shareSkills")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:s(d?"settings.experimental.shareSkillsDetail":"settings.experimental.shareSkillsNeedsAuthoring")})]}),e.jsx("div",{className:"inline-flex shrink-0 rounded-xl bg-inset p-1",role:"radiogroup","aria-label":s("settings.experimental.shareSkillsAria"),children:is.map(g=>e.jsx("button",{type:"button",role:"radio","aria-checked":c===g.value,disabled:a||!d,onClick:()=>{p(g.value)},className:G("rounded-lg px-3 py-1.5 text-[13px] transition-colors disabled:cursor-not-allowed disabled:opacity-50",c===g.value?"bg-raised text-ink shadow":"text-ink-secondary hover:text-ink"),children:s(g.label)},g.value))})]}),r?e.jsx("p",{role:"alert",className:"mt-2 text-[12px] text-danger",children:r}):null]})}function ls(){return e.jsxs(e.Fragment,{children:[e.jsx(ns,{}),e.jsx(rs,{})]})}function Rs({title:t=s("settings.updates.title")}){const n=xt(),a=window.ogb?.updater;if(!n||!a)return null;const i=n.status==="checking"?s("settings.updates.checking"):n.status==="downloading"?n.percent==null?s("settings.updates.startingDownload"):s("settings.updates.downloading",{percent:Math.round(n.percent)}):n.status==="preparing"?s("settings.updates.preparing"):n.status==="downloaded"?n.installMode==="handoff"?s("settings.updates.readyInstall",{app:le(),version:n.version??""}):s("settings.updates.ready",{app:le(),version:n.version??""}):n.status==="installing"?ue(n)||(n.installMode==="handoff"?s("settings.updates.openingTerminal"):s("settings.updates.restarting")):n.status==="handed-off"?s("settings.updates.handedOff"):n.status==="error"?s("settings.updates.failed",{message:ue(n)??s("settings.updates.unknownError")}):s("settings.updates.latest");return e.jsx(w,{title:t,subtitle:i,children:e.jsx("button",{onClick:()=>{if(n.status==="downloaded")return void a.install();a.check()},disabled:n.status==="checking"||n.status==="downloading"||n.status==="preparing"||n.status==="installing"||n.retryable===!1,className:"ui-button",children:n.retryable===!1?s("settings.updates.quitReopen"):n.status==="downloaded"?n.installMode==="handoff"?s("settings.updates.install"):s("settings.updates.restart"):n.status==="preparing"?s("settings.updates.preparingShort"):n.status==="installing"?n.installMode==="handoff"?s("settings.updates.opening"):s("settings.updates.restartingShort"):s("settings.updates.check")})})}function Ee(){const{state:t,dispatch:n}=k(),a=t.config?.newBots?.effort??"",[i,r]=o.useState(!1),[l,d]=o.useState("");return{current:a,saving:i,error:l,save:async p=>{if(!i){r(!0),d("");try{const g=await B("/api/config",{method:"PATCH",body:JSON.stringify({newBots:{effort:bt(p)?p:null}})});n({type:"configStatus",config:g})}catch(g){d(g instanceof Error?g.message:s("settings.newBotEffort.error"))}finally{r(!1)}}}}}function Be({effort:t,className:n}){return e.jsxs(O,{size:"sm",className:n,value:t.current,disabled:t.saving,"aria-label":s("settings.newBotEffort.aria"),onChange:a=>{t.save(a.target.value)},children:[e.jsx("option",{value:"",children:s("settings.newBotEffort.default")}),gt.map(a=>e.jsx("option",{value:a,children:ht(a)},a))]})}function Ps(){const t=Ee();return e.jsx(w,{title:s("settings.newBotEffort.title"),subtitle:s("settings.newBotEffort.subtitle"),message:t.error?e.jsx("p",{role:"alert",className:"text-danger",children:t.error}):null,children:e.jsx(Be,{effort:t,className:"w-full max-w-[240px]"})})}function os({onEdit:t,onShare:n}){const a=Ee();return e.jsx(w,{title:s("newBot.defaults"),subtitle:s("settings.newBotEffort.title"),message:a.error?e.jsx("p",{role:"alert",className:"text-danger",children:a.error}):null,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Be,{effort:a,className:"w-auto"}),e.jsx("button",{type:"button",className:"ui-button","data-new-bot-share":!0,onClick:n,children:s("newBot.sharePreset")}),e.jsx("button",{type:"button",className:"ui-button","data-new-bot-defaults":!0,onClick:t,children:s("newBot.edit")})]})})}function cs(){const{state:t,dispatch:n}=k(),[a,i]=o.useState(!1),[r,l]=o.useState(!1);return e.jsxs("div",{children:[e.jsx("button",{disabled:a,onClick:()=>{i(!0),l(!1),B("/api/config",{method:"PUT",body:JSON.stringify({onboarding:{...t.config?.onboarding?.completedAt?{}:Kt().onboarding,hintsSeen:ft(t.config?.onboarding)}}),signal:AbortSignal.timeout(1e4)}).then(d=>{n({type:"configStatus",config:d}),n({type:"toggleTour",open:!0})}).catch(()=>l(!0)).finally(()=>i(!1))},className:"ui-button",children:s("settings.welcome.appTour")}),r&&e.jsx("p",{role:"alert",className:"mt-2 text-[13px] text-danger",children:s("onboarding.tour.error")})]})}function Ts(){const{dispatch:t}=k();return e.jsx(w,{title:s("settings.welcome.title"),subtitle:s("settings.welcome.subtitleShort"),children:e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.jsx(cs,{}),e.jsx("button",{onClick:()=>t({type:"toggleWelcome",open:!0}),className:"ui-button",children:s("settings.welcome.replay")})]})})}function As({simple:t=!1}){const{state:n}=k(),a=De(Oe(),n.config?.language);return e.jsx(w,{title:s("settings.language.title"),subtitle:Fe()?s("settings.language.subtitleComplete"):t?ze()==="en"?void 0:s("settings.simple.language.partial"):s("settings.language.subtitle"),children:e.jsxs(O,{size:"sm",variant:t?"ghost":"field",className:t?void 0:"w-full max-w-[240px]",value:a,"aria-label":s("settings.language.aria"),onChange:i=>Ue(i.target.value),children:[e.jsx("option",{value:"",children:s(t?"settings.simple.language.system":"settings.language.system")}),Me.map(({code:i,label:r})=>e.jsx("option",{value:i,children:r},i))]})})}function Ls({simple:t=!1}){const n=Se();return e.jsx(w,{title:s("settings.sendKey.title"),subtitle:s(t?"settings.simple.sendKey":"settings.sendKey.subtitle",{key:de("mod-enter")}),children:e.jsx(O,{size:"sm",variant:t?"ghost":"field",className:t?void 0:"w-full max-w-[240px]",value:n,"aria-label":s("settings.sendKey.title"),onChange:a=>nt(at(a.target.value)),children:st.map(a=>e.jsx("option",{value:a,children:de(a)},a))})})}function Ds({simple:t=!1}){const n=it(),a=rt(Se());return e.jsx(w,{title:s("settings.followUp.title"),subtitle:s(t?"settings.simple.followUp":"settings.followUp.subtitle",{key:a}),children:e.jsxs(O,{size:"sm",variant:t?"ghost":"field",className:t?void 0:"w-full max-w-[240px]",value:n,"aria-label":s("settings.followUp.title"),onChange:i=>lt(ot(i.target.value)),children:[e.jsx("option",{value:"steer",children:s("settings.followUp.steer")}),e.jsx("option",{value:"queue",children:s("settings.followUp.queue")})]})})}function Os({simple:t=!1}){const n=et();return e.jsx(w,{title:s(t?"settings.userBubbles.simpleTitle":"settings.userBubbles.title"),subtitle:t?void 0:s("settings.userBubbles.subtitle"),children:e.jsx(T,{checked:n,"aria-label":s("settings.userBubbles.aria"),onClick:()=>tt(!n)})})}function Ms({simple:t=!1}){const n=ye();return e.jsx(w,{className:t?void 0:"rounded-2xl border border-accent-border/40 bg-raised-hover/40 py-4",title:s("settings.advancedMode.title"),subtitle:s(t?"settings.simple.advancedMode":"settings.advancedMode.subtitle"),children:e.jsx(T,{checked:n,"aria-label":s("settings.advancedMode.title"),onClick:()=>Le(!n)})})}function Us(){const t=Ie();return e.jsx(w,{title:s("settings.threadDisplay.title"),subtitle:s("settings.threadDisplay.subtitle"),children:e.jsx(T,{checked:t,"aria-label":s("settings.threadDisplay.show"),onClick:()=>Ke(!t)})})}function Fs(){const t=ct();return e.jsx(w,{title:s("settings.pinnedCircles.title"),subtitle:s("settings.pinnedCircles.subtitle"),children:e.jsx(T,{checked:t,"aria-label":s("settings.pinnedCircles.title"),onClick:()=>dt(!t)})})}function zs(){const t=_e();return e.jsx(w,{title:s("settings.runCard.title"),subtitle:s("settings.runCard.subtitle"),children:e.jsx(T,{checked:t,"aria-label":s("settings.runCard.show"),onClick:()=>$e(!t)})})}function Is(){const t=ut();return e.jsx(w,{title:s("settings.universalPins.title"),subtitle:s("settings.universalPins.subtitle"),children:e.jsx(T,{checked:t,"aria-label":s("settings.universalPins.title"),onClick:()=>pt(!t)})})}function Ks(){const{state:t,dispatch:n}=k(),a=mt(t.config),[i,r]=o.useState(!1),[l,d]=o.useState(""),c=async()=>{if(!i){r(!0),d("");try{const p=await B("/api/config",{method:"PATCH",body:JSON.stringify({features:{showToolCalls:!a}})});n({type:"configStatus",config:p})}catch(p){d(p instanceof Error?p.message:s("settings.toolCalls.error"))}finally{r(!1)}}};return e.jsx(w,{title:s("settings.toolCalls.title"),subtitle:e.jsxs(e.Fragment,{children:[s("settings.toolCalls.subtitle")," ",s("settings.toolCalls.detail")]}),message:l?e.jsx("p",{role:"alert",className:"text-danger",children:l}):null,children:e.jsx(T,{checked:a,"aria-label":s("settings.toolCalls.aria"),disabled:i,onClick:()=>{c()},className:"disabled:cursor-wait disabled:opacity-50"})})}function _s(){const{state:t,dispatch:n}=k(),a=te(t.config),[i,r]=o.useState(!1),[l,d]=o.useState(""),c=async p=>{if(!i){r(!0),d("");try{const g=await B("/api/config",{method:"PATCH",body:JSON.stringify({features:{skillAuthoring:p}})});n({type:"configStatus",config:g})}catch(g){d(g instanceof Error?g.message:s("settings.experimental.error"))}finally{r(!1)}}};return e.jsxs(je,{title:s("settings.experimental.title"),subtitle:s("settings.experimental.subtitle"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:s("settings.experimental.skillAuthoring")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:s("settings.experimental.skillAuthoringDetail")})]}),e.jsx(T,{checked:a,"aria-label":s("settings.experimental.skillAuthoringAria"),disabled:i,onClick:()=>{c(!a)},className:"disabled:cursor-wait disabled:opacity-50"})]}),l?e.jsx("p",{role:"alert",className:"mt-2 text-[12px] text-danger",children:l}):null,e.jsx(ls,{}),e.jsx(ss,{})]})}function $s(){const{state:t}=k(),n=t.config?.browserProfiles??[];return!ee(t.config)&&n.length===0?null:e.jsx(je,{title:s("settings.profiles.title"),subtitle:s("settings.profiles.sharedSubtitle"),children:e.jsx(qt,{})})}const be=["Identity","Soul","Skills","Memory","Routines","Access","Model","Permissions","Voice & alerts"],ds={Identity:"botSettings.sections.identity",Soul:"botSettings.sections.soul",Skills:"botSettings.sections.skills",Memory:"botSettings.sections.memory",Routines:"botSettings.sections.routines",Access:"botSettings.sections.access",Model:"botSettings.sections.model",Permissions:"botSettings.sections.permissions","Voice & alerts":"botSettings.sections.voice"};function Re(t){return e.jsx(_t,{modal:!0,children:e.jsx(us,{...t})})}function us({defaultsMode:t=!1,onClose:n,onCreated:a,readyBotId:i}){const r=$t(),l=k(),[,d]=o.useState(0),[c,p]=o.useState(()=>new me(Nt,()=>d(m=>m+1))),[g,j]=o.useState("Identity"),[A,N]=o.useState(!1),[x,h]=o.useState(!1),y=x||l.state.botCreationPending,b=o.useRef(!1),v=o.useRef(!0),[f,M]=o.useState(""),[I,$]=o.useState(null),[U,K]=o.useState("everyone"),[_,V]=o.useState(""),F=ke(),H=l.state.config?.team?.name,[z,u]=o.useState(null),R=we(),C=He(),L=ye()?be:be.filter(m=>m!=="Model"),ne=!t&&typeof window<"u"&&!window.ogb&&R===!0,W=o.useRef(null),J=o.useRef(n);J.current=n,o.useEffect(()=>{let m=!1;return B("/api/bot-defaults").then(P=>{if(m)return;const S=Ct(P,!t),E=t||!i?void 0:Ne(i),D=new me(E?vt(S,E):S,()=>d(q=>q+1));E&&(D.role=E.id),p(D),N(!0)}).catch(P=>{m||M(String(P))}),()=>{m=!0}},[t,i]),o.useEffect(()=>(v.current=!0,()=>{v.current=!1}),[]),o.useEffect(()=>()=>c.dispose(),[c]),o.useEffect(()=>{y&&W.current?.focus()},[y]),o.useEffect(()=>{const m=document.activeElement instanceof HTMLElement?document.activeElement:null;W.current?.focus();const P=S=>{if(!r())return;const E=W.current;if(!E||S.target instanceof Node&&!E.contains(S.target))return;const D=E.querySelector('[role="dialog"], [role="alertdialog"]');if(D&&D.getClientRects().length||(S.key==="Escape"&&(S.preventDefault(),J.current()),S.key!=="Tab"))return;const q=[...E.querySelectorAll('button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex="0"]')].filter(re=>re.getClientRects().length&&!re.closest("[hidden],fieldset:disabled")),Q=q[0],Z=q.at(-1);if(!Q||!Z){S.preventDefault(),E.focus();return}S.shiftKey&&(document.activeElement===Q||document.activeElement===E)?(S.preventDefault(),Z.focus()):!S.shiftKey&&(document.activeElement===Z||document.activeElement===E)&&(S.preventDefault(),Q.focus())};return window.addEventListener("keydown",P),()=>{window.removeEventListener("keydown",P),m?.isConnected&&m.focus()}},[r]);const ae=async()=>{if(!A||b.current||l.state.botCreationPending)return;if(!t&&c.bot.approvalMode==="auto"&&c.bot.computer==="local"&&!c.consent.acknowledgeLocalAuto){$("local");return}const m=ne?Ft(U,_):null;if(m&&!m.ok){M(s("botSettings.visibility.needPeople"));return}b.current=!0,h(!0),M(""),l.dispatch({type:"botCreationPending",on:!0});try{if(t)await B("/api/config",{method:"PATCH",body:JSON.stringify({newBotDefaults:await Et(c)})});else{const{bot:P,warnings:S,paused:E}=await Bt(c,void 0,void 0,void 0,m?.ok?m.visibility:void 0,F?xe(z,c.bot.section,l.state.bots,F)??void 0:void 0);Rt(l.dispatch,P,S,{showThreads:C,source:c.preset?"preset":c.role?"template":"blank",role:c.role,paused:E});try{await a?.(P)}catch(D){l.dispatch({type:"error",message:D instanceof Error?D.message:String(D)})}}b.current=!1,v.current&&J.current()}catch(P){v.current&&M(P instanceof Error?P.message:String(P))}finally{b.current=!1,l.dispatch({type:"botCreationPending",on:!1}),v.current&&h(!1)}},Y=c.bot,Pe={...l,state:{...l.state,bots:[Y,...l.state.bots],routines:c.routines,routineRuns:[],routinesLoadState:"ready"},flushBotPatches:async()=>Y,dispatch:m=>{m.type==="updateBot"&&m.botId===c.id?c.patch(m.patch):m.type==="setModel"&&m.botId===c.id?(c.setModel(m.selection),m.resetApprovalToAsk&&c.patch({approvalMode:"ask"})):m.type==="routinePatched"||m.type==="toggleSettings"||l.dispatch(m)}},ie=t?s("newBot.defaults"):s("sidebar.newBot");return e.jsx("div",{className:"fixed inset-0 z-[70] flex items-center justify-center bg-black/60 p-3 sm:p-5",hidden:!t&&l.state.appSettingsOpen,children:e.jsxs("div",{ref:W,role:"dialog","aria-modal":"true","aria-label":ie,"aria-busy":y,tabIndex:-1,className:"flex h-[min(760px,94dvh)] w-full max-w-[900px] flex-col overflow-hidden rounded-2xl border border-hairline/50 bg-panel shadow-2xl outline-none",children:[e.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-hairline/40 px-5 py-4",children:[e.jsx("h2",{className:"text-[17px] font-semibold text-ink",children:ie}),e.jsx("button",{type:"button",onClick:()=>J.current(),"aria-label":s("common.close"),className:"flex size-8 shrink-0 items-center justify-center rounded-lg text-ink-secondary hover:bg-control hover:text-ink disabled:opacity-40",children:e.jsx(ve,{size:18,className:"pointer-events-none"})})]}),F&&!t&&H&&e.jsx(ps,{team:H}),ne&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-5 pt-3 text-[13px] text-ink-secondary","data-new-bot-visibility":!0,children:[e.jsxs("label",{className:"flex items-center gap-2",children:[s("botSettings.visibility.title"),e.jsxs(O,{size:"sm",value:U,disabled:y,onChange:m=>K(m.target.value),children:[e.jsx("option",{value:"everyone",children:s("botSettings.visibility.everyone")}),e.jsx("option",{value:"admins",children:s("botSettings.visibility.admins")}),e.jsx("option",{value:"people",children:s("botSettings.visibility.people")})]})]}),U==="people"&&e.jsx("input",{value:_,disabled:y,onChange:m=>V(m.target.value),placeholder:s("botSettings.visibility.peoplePlaceholder"),"aria-label":s("botSettings.visibility.peopleLabel"),className:"min-w-[16rem] flex-1 rounded-lg border border-hairline/40 bg-inset px-3 py-1.5 text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col sm:flex-row",children:[e.jsx("nav",{"aria-label":s("newBot.sections"),className:"flex shrink-0 gap-1 overflow-x-auto border-b border-hairline/40 p-2 sm:w-40 sm:flex-col sm:border-b-0 sm:border-r",children:L.map(m=>e.jsx("button",{type:"button",onClick:()=>j(m),"aria-current":g===m?"page":void 0,className:G("shrink-0 rounded-lg px-3 py-2 text-left text-[13px]",g===m?"bg-control text-ink":"text-ink-secondary hover:bg-control/50"),children:s(ds[m])},m))}),e.jsxs("div",{className:"min-h-0 min-w-0 flex-1 overflow-y-auto p-4 sm:p-5",children:[!A&&!f&&e.jsxs("div",{role:"status",className:"flex items-center gap-2 text-[13px] text-ink-secondary",children:[e.jsx(X,{size:16,className:"animate-spin"}),s("newBot.loading")]}),A&&e.jsx("fieldset",{disabled:y,className:"min-w-0",children:e.jsx(yt,{value:Pe,children:e.jsx(wt.Provider,{value:{request:c.request,draft:!0,uploadAvatar:c.uploadAvatar},children:e.jsx(ms,{active:g,draft:c,defaultsMode:t,owner:F&&!t?{value:xe(z,Y.section,l.state.bots,F),choose:u}:void 0})})})})]})]}),f&&e.jsx("p",{role:"alert",className:"max-h-24 overflow-y-auto border-t border-hairline/40 px-5 py-3 text-[13px] text-danger",children:f}),e.jsxs("div",{className:"flex shrink-0 justify-end gap-2 border-t border-hairline/40 px-5 py-3",children:[e.jsx("button",{type:"button",onClick:()=>J.current(),className:"rounded-lg px-4 py-2 text-[13px] text-ink-secondary hover:bg-control",children:s("common.cancel")}),e.jsxs("button",{type:"button",disabled:!A||y||!t&&!Y.name.trim(),onClick:()=>{ae()},className:"ui-button-primary flex items-center gap-2 rounded-lg bg-accent px-5 py-2 text-[13px] font-medium text-white hover:brightness-110 disabled:opacity-40",children:[y&&e.jsx(X,{size:15,className:"animate-spin"}),s(t?"newBot.saveDefaults":"newBot.create")]})]}),e.jsx(jt,{open:I==="local",onCancel:()=>$(null),onConfirm:()=>{c.consent.acknowledgeLocalAuto=!0,$(null),ae()}})]})})}function ps({team:t}){const n=typeof window>"u"?void 0:window.ogb?.workspaces;return e.jsxs("div",{"data-new-bot-shared":!0,className:"flex flex-wrap items-center gap-x-2 gap-y-1 border-b border-hairline/40 bg-raised/30 px-5 py-2.5 text-[13px] text-ink-secondary",children:[e.jsx("span",{children:s("newBot.sharedWith",{team:t})}),n?e.jsx("button",{type:"button",onClick:()=>{Pt(n).catch(()=>{})},className:"font-medium text-accent hover:underline",children:s("newBot.justForYou")}):e.jsx("span",{children:s("newBot.justForYou").replace(/\s*→$/,"")})]})}function ms({active:t,draft:n,defaultsMode:a,owner:i}){const r=n.bot,{state:l}=k(),d=ke(),c=St(r);return t==="Identity"?e.jsxs("div",{className:"space-y-4",children:[e.jsx(xs,{draft:n,defaultsMode:a}),e.jsx(Tt,{bot:r,patch:c.patch,activeState:c.activeState,mascotMotion:null,namePlaceholder:a?s("newBot.randomName"):void 0}),e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[s("newBot.team"),e.jsxs(O,{size:"lg",className:"mt-1.5 w-full",value:r.section??"",onChange:p=>n.patch({section:p.target.value}),children:[e.jsx("option",{value:"",children:s("teamSettings.general")}),[...new Set([...l.sections??[],...l.bots.map(p=>p.section??"")])].filter(Boolean).map(p=>e.jsx("option",{children:p},p))]})]}),i&&d&&e.jsxs("label",{className:"block text-[13px] text-ink-secondary","data-new-bot-reports-to":!0,children:[s("lookedAfter.newBot"),e.jsx(O,{size:"lg",className:"mt-1.5 w-full",value:i.value??"",onChange:p=>i.choose(p.target.value),children:d.people.map(p=>e.jsx("option",{value:p.email,children:p.you?s("owner.you",{name:p.name}):p.name},p.email))}),e.jsx("span",{className:"mt-1 block text-[12px]",children:s("lookedAfter.pickHint")})]})]}):t==="Soul"?e.jsx(At,{bot:r,patch:c.patch}):t==="Skills"?e.jsx(Lt,{bot:r}):t==="Memory"?e.jsx(gs,{draft:n}):t==="Routines"?e.jsx(hs,{draft:n}):t==="Access"?e.jsx(Dt,{bot:r,derived:c}):t==="Model"?e.jsx(Ot,{bot:r}):t==="Permissions"?e.jsx(Mt,{bot:r,derived:c}):e.jsx(Ut,{bot:r,derived:c})}function xs({draft:t,defaultsMode:n}){const[a,i]=o.useState([]),[r,l]=o.useState(0),[d,c]=o.useState(""),p=o.useRef(!1);o.useEffect(()=>{if(n)return;let x=!1;return B("/api/bot-presets").then(h=>{x||i(h.presets)}).catch(()=>{x||i([])}),()=>{x=!0}},[n,r]);const g=t.preset?a.find(x=>x.id===t.preset.id):void 0,j=async x=>{c("");const h=x.startsWith("preset:")?a.find(b=>b.id===x.slice(7)):void 0;if(!h){t.choosePreset(void 0);const b=pe.find(f=>f.id===x);t.chooseRole(b?.id);const v=b&&Ne(b.id)?.look;b&&t.patch({...kt(b),...v});return}t.patch(Qt(h)),t.choosePreset(es(h));const y=Zt(h);try{y?(t.patch({avatarUrl:await t.uploadAvatar(y),avatarCrop:h.bot.appearance.avatar.crop}),p.current=!0):p.current&&(t.patch({avatarUrl:""}),p.current=!1)}catch(b){c(b instanceof Error?b.message:String(b))}},A=async x=>{c("");try{await B(`/api/bot-presets/${encodeURIComponent(x.id)}`,{method:"DELETE"}),t.preset?.id===x.id&&t.choosePreset(void 0),l(h=>h+1)}catch(h){c(h instanceof Error?h.message:String(h))}},N=pe.map(x=>e.jsx("option",{value:x.id,children:x.title},x.id));return e.jsxs("div",{children:[e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[s("newBot.startingRole"),e.jsxs(O,{size:"lg",className:"mt-1.5 w-full",value:t.preset?`preset:${t.preset.id}`:"",onChange:x=>{j(x.target.value)},children:[e.jsx("option",{value:"",children:s("newBot.customSettings")}),Xt(a).map(x=>e.jsx("optgroup",{label:x.label,children:x.presets.map(h=>e.jsx("option",{value:`preset:${h.id}`,children:h.name},h.id))},x.label)),a.length?e.jsx("optgroup",{label:s("newBot.builtInRoles"),children:N}):N]})]}),g&&e.jsxs("div",{className:"mt-2 space-y-1 rounded-lg bg-card px-3 py-2.5 text-[13px] text-ink-secondary","data-new-bot-preset":!0,children:[Gt(g).map((x,h)=>e.jsx("p",{className:"break-words",children:x},h)),g.source==="file"&&e.jsx("button",{type:"button",onClick:()=>{A(g)},className:"mt-1 rounded-md px-2 py-1 text-[12px] text-ink-secondary hover:bg-control hover:text-ink",children:s("newBot.presetRemove")})]}),d&&e.jsx("p",{role:"alert",className:"mt-2 text-[13px] text-danger",children:d})]})}function gs({draft:t}){const[n,a]=o.useState("MEMORY.md"),[i,r]=o.useState("");return e.jsxs("div",{className:"space-y-3",children:[e.jsx(O,{size:"lg",className:"w-full","aria-label":s("memory.fileLabel",{path:n}),value:n,onChange:l=>a(l.target.value),children:[...new Set(["MEMORY.md",...Object.keys(t.template.memory)])].map(l=>e.jsx("option",{children:l},l))}),e.jsx("textarea",{className:G(ge,"min-h-72 font-mono"),"aria-label":s("memory.contents"),value:t.template.memory[n]??"",onChange:l=>t.setMemory(n,l.target.value)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{className:ge,"aria-label":s("memory.newTopicLabel"),placeholder:s("memory.newTopicLabel"),value:i,onChange:l=>r(l.target.value)}),e.jsx("button",{type:"button","aria-label":s("memory.addTopic"),disabled:!/^[a-zA-Z0-9_-]+$/.test(i),className:"rounded-lg bg-control px-3 disabled:opacity-40",onClick:()=>{const l=`memory/${i}.md`;l in t.template.memory||t.setMemory(l,""),a(l),r("")},children:e.jsx(Ht,{size:16})}),n!=="MEMORY.md"&&e.jsx("button",{type:"button","aria-label":s("memory.removeTopic"),className:"rounded-lg bg-control px-3",onClick:()=>{t.setMemory(n,null),a("MEMORY.md")},children:e.jsx(Ce,{size:16})})]})]})}function hs({draft:t}){const[n,a]=o.useState(null);return e.jsxs("div",{className:"space-y-3",children:[e.jsx("button",{type:"button",className:"rounded-lg bg-accent px-3 py-2 text-[13px] text-white",onClick:()=>a("new"),children:s("computer.routines.create")}),t.routines.map(i=>e.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-card p-3",children:[e.jsx("button",{type:"button",className:"min-w-0 flex-1 text-left text-[13px]",onClick:()=>a(i),children:i.name}),e.jsxs("label",{className:"flex items-center gap-1.5 text-[12px] text-ink-secondary",children:[e.jsx("input",{type:"checkbox",checked:i.enabled,onChange:r=>t.setRoutineEnabled(i.id,r.target.checked)}),s("newBot.enabled")]}),e.jsx("button",{type:"button","aria-label":s("newBot.removeRoutine",{name:i.name}),onClick:()=>t.removeRoutine(i.id),className:"rounded p-1.5 hover:bg-control",children:e.jsx(Ce,{size:15})})]},i.id)),n&&e.jsx(zt,{routine:n==="new"?void 0:n,bots:[t.bot],lockedBotId:t.id,onClose:()=>a(null)})]})}function fs({simple:t=!1}){const[n,a]=o.useState(!1),[i,r]=o.useState(!1),l=e.jsxs(e.Fragment,{children:[n&&e.jsx(Re,{defaultsMode:!0,onClose:()=>a(!1)}),i&&e.jsx(ts,{onClose:()=>r(!1)})]});if(t)return e.jsxs(e.Fragment,{children:[e.jsx(os,{onEdit:()=>a(!0),onShare:()=>r(!0)}),l]});const d=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex shrink-0 gap-2",children:[e.jsx("button",{type:"button",onClick:()=>r(!0),className:"cursor-pointer rounded-lg px-3 py-1.5 text-[13px] text-ink-secondary hover:bg-control hover:text-ink",children:s("newBot.sharePreset")}),e.jsx("button",{type:"button",onClick:()=>a(!0),className:"cursor-pointer rounded-lg bg-control px-3 py-1.5 text-[13px] text-ink hover:bg-raised-hover",children:s("newBot.edit")})]}),l]});return e.jsx(w,{title:s("newBot.defaults"),children:d})}const Hs=Object.freeze(Object.defineProperty({__proto__:null,DefaultBotSettings:fs,NewBotDialog:Re},Symbol.toStringTag,{value:"Module"}));export{Ms as A,Es as B,Os as C,fs as D,_s as E,Ds as F,As as L,Ps as N,Fs as P,Ts as R,Bs as S,Ks as T,Rs as U,$s as a,Ls as b,Us as c,Is as d,zs as e,Hs as f};
@@ -1 +0,0 @@
1
- import{t as s,j as e,a as y,f as re,r as n,X as lt,S as ot,D as J}from"./styles-BcVNrxGE.js";import{o as Fe,a as ct,b as dt,c as mt,d as xt,t as ae,e as pt,M as ut}from"./org-library-C-rnQ1YG.js";import{t as gt,a as ht}from"./import-name-6aD0J6QH.js";import{bs as bt,bt as ft,bu as yt,w as jt,bv as Te,bw as kt,aM as Ge,u as Me,bx as Nt,by as vt,bz as wt,bA as St,bB as Ct,bC as Lt,n as S,bD as Bt,bE as Oe,bF as Et,F as zt,bG as Tt}from"./App-DBQxC6tF.js";import{K as Ot,P as It,r as _e,N as At,L as C,y as Ie,O as Dt}from"./PlacesRail-D510vk5R.js";import{ShareTeamDialog as Pt}from"./ShareTeamDialog-C4go2USY.js";import"./package-format-CMpBgycc.js";import"./index-DgGTgaCO.js";import"./monitor-DOeLdhQc.js";import"./MenuMotion-CLF0GByT.js";import"./team-share-C9qIusMs.js";const Rt={"seo growth team":"seoGrowth","engineering team":"engineering","100x marketing team":"marketing100x","reddit lead miner":"redditLeadMiner","competitor watch":"competitorWatch","inbox follow-up":"inboxFollowup"};function Ue(a){const m=Rt[a.name.trim().toLowerCase()];return m?{...a,name:s(`templates.catalog.${m}.name`),summary:s(`templates.catalog.${m}.summary`),outcome:a.outcome?s(`templates.catalog.${m}.outcome`):void 0}:a}function $t(a,m){const x=Ue(a);return`${x.name} ${x.summary} ${a.name} ${a.summary} ${a.category} ${a.skills.join(" ")} ${a.requires.apps.join(" ")}`.toLowerCase().includes(m)}const O=["bg-purple-500/15 text-purple-300","bg-cyan-500/15 text-cyan-300","bg-orange-500/15 text-orange-300","bg-emerald-500/15 text-emerald-300"];function Ft({pending:a,importedNames:m,org:x=!1}){return e.jsxs(e.Fragment,{children:[a.description&&e.jsx("p",{className:"max-w-2xl text-[14px] leading-relaxed text-ink-secondary",children:a.description}),a.brief&&e.jsxs("div",{className:"mt-4 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:s("teamImport.brief")}),e.jsx("p",{className:"mt-1 line-clamp-4 whitespace-pre-wrap break-words",children:a.brief})]}),!!a.warnings?.length&&e.jsxs("div",{className:"mt-4 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"mb-2 font-medium text-ink",children:s("templates.backupNotes")}),a.warnings?.map((d,o)=>e.jsx("p",{children:d},o))]}),(a.kind==="package"||a.kind==="backup")&&e.jsxs("div",{className:"mt-5 flex flex-wrap gap-2 text-[12px] text-ink-secondary",children:[a.chiefOfStaff&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(bt,{size:13}),s("templates.leads",{name:a.chiefOfStaff})]}),!a.library&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(ft,{size:13}),s("templates.groupChats",{count:a.rooms})]}),!(a.library&&!a.playbooks)&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(yt,{size:13}),s("templates.playbooks",{count:a.playbooks})]}),!a.library&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(jt,{size:13}),a.version===2?s("teamImport.routinesPaused",{count:a.routines}):s("templates.pausedRoutines",{count:a.routines})]}),a.kind==="package"&&a.version!==2&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(Te,{size:13}),s("templates.connections",{count:a.apps.length})]}),!!a.connections?.length&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(Te,{size:13}),s("teamImport.connections",{count:a.connections?.length??0})]}),!!a.notes&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(kt,{size:13}),s("teamImport.notes",{count:a.notes??0})]}),!!a.presets?.length&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(Ge,{size:13}),s("teamImport.presets",{count:a.presets?.length??0})]})]}),!!a.skills?.length&&e.jsxs("div",{className:"mt-4 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:x?s("orgLibrary.skillsOn"):a.version===2?s("teamImport.skillsOff"):s("templates.skillsDisabled")}),e.jsx("p",{className:"mt-1 break-words",children:a.skills?.join(", ")}),!x&&e.jsx("p",{className:"mt-1",children:a.version===2?s("teamImport.skillsReview"):s("templates.skillsReview")})]}),a.library&&!!a.presets?.length&&e.jsxs("div",{className:"mt-4 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:s("teamImport.presetList")}),e.jsx("p",{className:"mt-1 break-words",children:a.presets?.join(", ")})]}),!!a.offeredSkills?.length&&e.jsxs("div",{className:"mt-4 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:s("teamImport.offeredSkills")}),e.jsx("p",{className:"mt-1 break-words",children:a.offeredSkills?.join(", ")})]}),!!a.connections?.length&&e.jsxs("div",{className:"mt-4 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:s("teamImport.connections",{count:a.connections?.length??0})}),e.jsx("ul",{className:"mt-1",children:a.connections?.map((d,o)=>e.jsxs("li",{className:"truncate",children:[d.label," · ",d.url]},`${d.label}-${o}`))})]}),a.members.length>0&&e.jsx("div",{className:"mt-6 text-[12px] font-medium text-ink-secondary",children:s("templates.teamMembers")}),e.jsx("div",{className:"mt-2 grid grid-cols-1 gap-x-10 md:grid-cols-2",children:a.members.map((d,o)=>e.jsxs("div",{className:"flex min-h-[72px] items-center gap-3 border-b border-hairline/35 px-1 py-3",children:[a.pictures?.[o]?e.jsx("img",{src:a.pictures[o],alt:"",className:"size-9 shrink-0 rounded-lg object-cover"}):e.jsx("div",{className:y("flex size-9 shrink-0 items-center justify-center rounded-lg text-[13px] font-semibold",O[o%O.length]),children:d.name.slice(0,1).toUpperCase()}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-[14px] font-medium text-ink",children:m[o]}),m[o]!==d.name&&e.jsx("div",{className:"text-[12px] text-ink-secondary",children:s("templates.newCopyOf",{name:d.name})}),e.jsx("div",{className:"mt-0.5 truncate text-[13px] text-ink-secondary",children:d.title||s("templates.generalAssistant")})]})]},`${d.name}-${o}`))}),e.jsxs("div",{className:"mt-6 flex items-start gap-2.5 rounded-xl bg-raised/45 px-4 py-3 text-[13px] leading-relaxed text-ink-secondary",children:[e.jsx(re,{size:15,className:"mt-0.5 shrink-0 text-success"}),e.jsx("p",{children:a.kind==="backup"?s("templates.backupSafety",{archived:a.archivedBots?s("templates.archivedBots",{count:a.archivedBots}):""}):x?a.members.length?s("orgLibrary.teamSafety"):s("orgLibrary.librarySafety"):a.library?s("teamImport.librarySafety"):a.version===2?s("teamImport.sharedTeamSafety"):a.kind==="package"?s("templates.packageSafety"):s("templates.legacySafety")})]})]})}const Gt={gmail:"Gmail",github:"GitHub",discord:"Discord",slack:"Slack",googlecalendar:"Google Calendar",notion:"Notion",linear:"Linear",figma:"Figma",gong:"Gong",hubspot:"HubSpot",postiz:"Postiz"},Ae={everyday:"readyBots.category.everyday",work:"readyBots.category.work",writing:"readyBots.category.writing",design:"readyBots.category.design",sales:"readyBots.category.sales",personal:"readyBots.category.personal"};function Mt({search:a,onDialog:m,onAdded:x}){const[d,o]=n.useState(null),{state:h,dispatch:j}=Me(),[v,p]=n.useState(null),b=l=>{if(!(l!==null&&Lt(h))){if(l!==null&&window.ogb?.remoteClient?.active){j({type:"newBot",onCreated:x});return}p(l),m(l!==null)}},L=Nt.filter(l=>(!d||l.category===d)&&vt(l,a));return a.trim()&&L.length===0?null:e.jsxs("section",{className:"mb-8","aria-labelledby":"ready-bots-title",children:[e.jsxs("div",{className:"mb-1 flex flex-wrap items-baseline justify-between gap-2",children:[e.jsx("h3",{id:"ready-bots-title",className:"text-[12px] font-medium text-ink-secondary",children:s("readyBots.title")}),e.jsx("p",{className:"text-[12px] text-ink-tertiary",children:s("readyBots.subtitle")})]}),e.jsx("div",{className:"mb-3 mt-2 flex flex-wrap gap-1.5",role:"group","aria-label":s("readyBots.categories"),children:[null,...wt].map(l=>e.jsx("button",{type:"button","aria-pressed":d===l,onClick:()=>o(l),className:y("rounded-full px-3 py-1 text-[13px] transition-colors",d===l?"bg-ink text-panel":"bg-raised/70 text-ink-secondary hover:text-ink"),children:l?s(Ae[l]):s("readyBots.all")},l??"all"))}),e.jsx("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2 lg:grid-cols-3",children:L.map(l=>{const w=St(l);return e.jsxs("article",{"data-ready-bot":l.id,className:"flex flex-col rounded-2xl border border-hairline/40 bg-card p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ot,{color:l.look.color,bodyId:l.look.mascotBody,size:40,animated:!1,label:l.name}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h4",{className:"truncate text-[14px] font-medium text-ink",children:l.name}),e.jsxs("p",{className:"truncate text-[12px] text-ink-secondary",children:[w.title," · ",s(Ae[l.category])]})]}),e.jsxs("button",{type:"button",onClick:()=>b(l.id),"aria-label":s("readyBots.addAria",{name:l.name,title:w.title}),className:"flex h-8 shrink-0 items-center gap-1 rounded-full bg-raised px-3 text-[13px] font-medium text-ink hover:bg-raised-hover focus-visible:outline-2 focus-visible:outline-accent",children:[e.jsx(It,{size:14,"aria-hidden":"true"}),s("readyBots.add")]})]}),e.jsx("p",{className:"mt-3 text-[13px] leading-[1.45] text-ink-secondary",children:w.description}),e.jsx("p",{className:"mt-2 text-[12px] italic text-ink-tertiary",children:s("readyBots.try",{prompt:w.tryAsking})}),(l.apps.length>0||l.routines?.length)&&e.jsx("p",{className:"mt-auto pt-2 text-[12px] text-ink-tertiary",children:[l.apps.length>0&&s("readyBots.worksWith",{apps:l.apps.map(I=>Gt[I]??I).join(", ")}),l.routines?.length&&s("readyBots.pausedRoutine")].filter(Boolean).join(" · ")})]},l.id)})}),v&&_e.createPortal(e.jsx(Ct,{readyBotId:v,onClose:()=>b(null),onCreated:l=>{m(!1),x(l)}}),document.body)]})}const De=["bg-cyan-500/15 text-cyan-300","bg-purple-500/15 text-purple-300","bg-emerald-500/15 text-emerald-300","bg-orange-500/15 text-orange-300"];function _t({listing:a,busy:m,notice:x,error:d,onAdd:o,onDetails:h}){const j=a.organization.name;return e.jsxs("div",{children:[e.jsx("p",{className:"max-w-2xl text-[13px] leading-relaxed text-ink-secondary",children:s("orgLibrary.intro",{name:j})}),a.packages.length===0?e.jsx("p",{className:"mt-6 text-[13px] text-ink-secondary",children:s("orgLibrary.empty",{name:j})}):e.jsx("div",{className:"mt-4 grid grid-cols-1 gap-x-10 md:grid-cols-2",children:a.packages.map((v,p)=>e.jsx(Ut,{entry:v,index:p,busy:m,onAdd:o,onDetails:h},v.packageId))}),x&&e.jsx("div",{role:"status",className:"mt-4 rounded-lg bg-raised/60 px-3 py-2 text-[13px] text-ink-secondary",children:x}),d&&e.jsx("div",{role:"alert",className:"mt-4 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:d})]})}function Ut({entry:a,index:m,busy:x,onAdd:d,onDetails:o}){const h=Fe(a),j=ct(a),v=dt(a),p=x===a.packageId;return e.jsxs("article",{className:"flex min-h-[104px] items-center gap-3 border-b border-hairline/35 px-1 py-4",children:[e.jsx("div",{className:y("flex size-11 shrink-0 items-center justify-center rounded-xl",De[m%De.length]),children:e.jsx(At,{size:20})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"truncate text-[14px] font-medium text-ink",children:a.name}),e.jsx("p",{className:"mt-0.5 truncate text-[13px] text-ink-secondary",children:a.tagline}),e.jsxs("p",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-[12px] text-ink-tertiary",children:[e.jsx("span",{children:mt(a)}),j&&e.jsx("span",{className:"rounded-full bg-accent/10 px-2 py-0.5 text-accent-text",children:j}),a.release&&e.jsx("span",{children:a.release.version})]}),e.jsx("p",{className:"mt-0.5 truncate text-[12px] text-ink-tertiary",children:xt(a.contents)}),v.map(b=>e.jsx("p",{className:"mt-0.5 text-[12px] text-warning",children:b},b))]}),e.jsxs("div",{className:"flex shrink-0 flex-col items-end gap-1.5",children:[h==="add"&&e.jsxs("button",{onClick:()=>d(a),disabled:x!==null,"aria-label":s("orgLibrary.addAria",{name:a.name}),className:"flex min-w-[72px] items-center justify-center gap-1.5 rounded-full bg-accent px-3.5 py-2 text-[13px] font-medium text-white hover:bg-accent/90 disabled:opacity-40",children:[p&&e.jsx(C,{size:13,className:"animate-spin"}),p?s("orgLibrary.adding"):s("orgLibrary.add")]}),h==="added"&&e.jsxs("span",{className:"flex items-center gap-1 rounded-full bg-raised px-3 py-1.5 text-[12px] text-ink-secondary",children:[e.jsx(re,{size:13,className:"text-success"}),s("orgLibrary.added")]}),h==="updateApp"&&e.jsx("span",{className:"max-w-[140px] text-right text-[12px] text-ink-secondary",children:s("orgLibrary.updateApp")}),h==="notReady"&&e.jsx("span",{className:"text-[12px] text-ink-secondary",children:s("orgLibrary.notReady")}),h==="noRelease"&&e.jsx("span",{className:"text-[12px] text-ink-secondary",children:s("orgLibrary.noRelease")}),a.blob==="ready"&&e.jsx("button",{onClick:()=>o(a),disabled:x!==null,"aria-label":s("orgLibrary.detailsAria",{name:a.name}),className:"rounded-full px-2.5 py-1 text-[12px] text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-40",children:s("orgLibrary.details")})]})]})}const Yt="https://github.com/milind-soni/openmausbot-teams",Pe=["cyan","red","purple","green","orange"];async function Re(a){if(window.ogb?.openExternal){await window.ogb.openExternal(a);return}const m=window.open(a,"_blank","noopener,noreferrer");m&&(m.opener=null)}function Kt(a,m){const x=new Map;for(const o of m){if(o.hidden)continue;const h=o.section?.trim()??"";x.set(h,(x.get(h)??0)+1)}return[...[...new Set([...a.map(o=>o.trim()).filter(Boolean),...x.keys()])].filter(o=>o!==""),""].flatMap(o=>x.get(o)?[{name:o,bots:x.get(o)}]:[])}function $e({index:a}){return e.jsx("div",{className:y("flex size-11 shrink-0 items-center justify-center rounded-xl",O[a%O.length]),children:e.jsx(Ge,{size:20})})}function as({onClose:a,onImported:m,returnFocusRef:x,initialUrl:d}){const{state:o,dispatch:h}=Me(),j=n.useRef(null),v=n.useRef(null),[p,b]=n.useState("explore"),[L,l]=n.useState(null),[w,I]=n.useState(!0),[ne,ie]=n.useState(""),[W,le]=n.useState(null),[c,A]=n.useState(null),[Ye,Ke]=n.useState("file"),[X,oe]=n.useState(""),[ce,de]=n.useState(!1),[k,P]=n.useState(!1),[He,Q]=n.useState(!1),[R,qe]=n.useState(""),[E,g]=n.useState(""),[me,xe]=n.useState(""),[$,pe]=n.useState(!1),[f,ue]=n.useState(null),[Je,We]=n.useState(""),[F,V]=n.useState(null),[ge,he]=n.useState(new Set),[be,fe]=n.useState(""),[G,ye]=n.useState(!1),[M,je]=n.useState(null),[ke,Xe]=n.useState(!1),[_,Ne]=n.useState(null),[Qe,U]=n.useState(null),[Ve,ve]=n.useState(""),[Ze,Y]=n.useState(""),[z,K]=n.useState(null),B=n.useRef(!1),T=n.useRef(0),Z=o.bots.filter(t=>!t.hidden).length,we=Kt(o.sections??[],o.bots),et=new Set(o.bots.map(t=>t.name.trim().toLowerCase())),tt=c?.members.map(t=>gt(t.name,et))??[],ee=n.useCallback(async()=>{I(!0),ie("");try{l(await S("/api/team-library/catalog"))}catch(t){ie(t instanceof Error?t.message:String(t))}finally{I(!1)}},[]);n.useEffect(()=>{ee()},[ee]);const H=n.useCallback(async()=>{try{const t=await S("/api/org-library");Ne(t),t.organization&&!B.current&&b("org")}catch{Ne({organization:null,packages:[]})}},[]);n.useEffect(()=>{H()},[H]),n.useEffect(()=>(j.current?.focus(),()=>x.current?.focus()),[x]),n.useEffect(()=>{const t=r=>{if(M!==null||ke)return;if(r.key==="Escape"&&!k){r.preventDefault(),r.stopPropagation(),c?(A(null),K(null)):a();return}if(r.key!=="Tab")return;const i=j.current,u=Array.from(i?.querySelectorAll('button:not([disabled]), a[href], input:not([disabled]), [tabindex]:not([tabindex="-1"])')??[]);if(!i||u.length===0)return;const N=u[0],q=u.at(-1);r.shiftKey&&(document.activeElement===N||!i.contains(document.activeElement))?(r.preventDefault(),q.focus()):!r.shiftKey&&document.activeElement===q&&(r.preventDefault(),N.focus())};return window.addEventListener("keydown",t,!0),()=>window.removeEventListener("keydown",t,!0)},[k,a,c,M,ke]);const te=(t,r)=>{A(t),Ke(r),g("")},Se=async t=>{if(t.size>ut)throw new Error(s("templates.fileTooLarge"));const r=await t.text();let i=r;if(!t.name.toLowerCase().endsWith(".md"))try{i=JSON.parse(r)}catch(u){throw u instanceof SyntaxError?new Error(s("teamLibrary.invalidJson")):u}te(ae(i),"file")},st=async t=>{le(t.slug),g("");try{te(ae(await S(`/api/team-library/teams/${t.slug}`)),"library")}catch(r){g(r instanceof Error?r.message:String(r))}finally{le(null)}},Ce=async()=>{await Le(X)},Le=async t=>{if(t.trim()){de(!0),g("");try{const r=await S("/api/team-library/github",{method:"POST",body:JSON.stringify({url:t.trim()})});te(ae(r),"github")}catch(r){g(r instanceof Error?r.message:String(r))}finally{de(!1)}}};n.useEffect(()=>{d&&(B.current=!0,b("import"),oe(d),Le(d))},[d]);const at=async()=>{if(c){P(!0),g("");try{const t=await ht(c.manifest,h);J("team_imported",{members:t.bots.length,source:Ye,mode:"add",format:c.kind}),m({name:c.name,members:t.bots.length,...t.connections?.length?{connections:t.connections.length}:{},...t.presets?.length?{presets:t.presets.length}:{}})}catch(t){g(t instanceof Error?t.message:String(t))}finally{P(!1)}}},rt=async t=>{U(t.packageId),Y("");try{const r=await S(`/api/org-library/packages/${t.packageId}`);A(pt(r.document)),K(t),g("")}catch(r){Y(r instanceof Error?r.message:String(r))}finally{U(null)}},Be=async t=>{U(t.packageId),P(!0),Y(""),ve(""),g("");try{const r=await S("/api/org-library/add",{method:"POST",body:JSON.stringify({packageId:t.packageId})});for(const u of r.bots??[])h({type:"botAdded",bot:u});for(const u of r.groups??[])h({type:"groupPatched",group:u});for(const u of r.routines??[])h({type:"routinePatched",routine:u});const i=r.bots?.find(u=>!u.hidden);if(J("team_imported",{members:r.bots?.length??0,source:"organization",mode:"add",format:"package"}),i){h({type:"select",id:i.id}),m({name:t.name,members:r.bots.length,...r.connections?.length?{connections:r.connections.length}:{}});return}A(null),K(null),r.alreadyAdded||ve(s("orgLibrary.addedSkills",{name:t.name})),await H()}catch(r){const i=r instanceof Error?r.message:String(r);z?g(i):Y(i),await H()}finally{U(null),P(!1)}},D=me.trim(),se=async t=>{const r=++T.current;pe(!0),g(""),ue(null),V(null),he(new Set);try{const i=await S(`/api/teams/scout?cwd=${encodeURIComponent(t)}`);if(r!==T.current)return;ue(i),We(t),fe(i.suggestion.roomName),J("team_scouted",{signals:i.suggestion.manifest.team.members.length-1}),S(`/api/teams/scout/directory?cwd=${encodeURIComponent(t)}`).then(u=>{r===T.current&&V(u.directory)}).catch(()=>{r===T.current&&V([])})}catch(i){if(r!==T.current)return;g(i instanceof Error?i.message:String(i))}finally{r===T.current&&pe(!1)}},nt=async()=>{const t=await window.ogb?.pickFolder?.(D||void 0);t&&(xe(t),await se(t))},it=async()=>{if(!(!f||G)){ye(!0),g("");try{const t=(F??[]).filter(N=>ge.has(N.slug)).map((N,q)=>({key:`dir-${N.slug}`,name:N.name,title:N.category||s("templates.communityBot"),description:N.prompt,appearance:{color:Pe[q%Pe.length]}})),r={...f.suggestion.manifest,team:{...f.suggestion.manifest.team,members:[...f.suggestion.manifest.team.members,...t]}},i=be.trim()||f.suggestion.roomName,u=await S(`/api/teams/import?mode=project&cwd=${encodeURIComponent(Je)}&room=${encodeURIComponent(i)}`,{method:"POST",body:JSON.stringify(r)});for(const N of u.bots)h({type:"botAdded",bot:N});u.group&&(h({type:"groupPatched",group:{...u.group,messages:[]}}),h({type:"select",id:u.group.id})),J("team_imported",{members:u.bots.length,source:"scout",mode:"project"}),m({name:i,members:u.bots.length})}catch(t){g(t instanceof Error?t.message:String(t))}finally{ye(!1)}}},Ee=R.trim().toLowerCase(),ze=(L?.teams??[]).filter(t=>!Ee||$t(t,Ee));return _e.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/55 p-4 sm:p-6",onMouseDown:t=>t.target===t.currentTarget&&!k&&a(),children:[e.jsxs("div",{ref:j,role:"dialog","aria-modal":"true","aria-labelledby":"team-library-title",tabIndex:-1,className:"animate-pop-in flex h-[min(780px,calc(100dvh-2rem))] w-full max-w-[1040px] flex-col overflow-hidden rounded-2xl border border-hairline/50 bg-panel shadow-2xl shadow-black/50 outline-none",children:[e.jsxs("header",{className:"flex items-start justify-between gap-4 px-6 pb-3 pt-6 sm:px-8 sm:pt-7",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[c&&e.jsx("button",{onClick:()=>{A(null),K(null),g("")},disabled:k,className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-50","aria-label":s("templates.back"),children:e.jsx(Bt,{size:18})}),e.jsx("h2",{id:"team-library-title",className:"truncate text-[22px] font-semibold tracking-[-0.01em] text-ink",children:c?c.name:s("templates.title")})]}),e.jsx("p",{className:y("mt-1 text-[13px] text-ink-secondary",c&&"ml-9"),children:c?c.kind==="backup"?s("templates.backupSummary",{bots:c.members.length,conversations:c.conversations??0}):c.kind==="package"?c.library?s("teamImport.library"):c.version===2?s("teamImport.sharedTeam",{count:c.members.length}):s("templates.playbookSummary",{count:c.members.length}):s("templates.readyBots",{count:c.members.length}):s("templates.subtitle")})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[!c&&e.jsxs("button",{onClick:()=>{Re(L?.repositoryUrl??Yt)},className:"flex items-center gap-1.5 rounded-lg px-2.5 py-2 text-[13px] text-ink-secondary hover:bg-raised hover:text-ink",title:s("templates.openRepository"),children:[e.jsx(Oe,{size:16}),e.jsx("span",{className:"max-sm:hidden",children:s("templates.communityRepo")}),e.jsx(Ie,{size:12})]}),e.jsx("button",{onClick:a,disabled:k,className:"rounded-lg p-2 text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-50","aria-label":s("templates.close"),children:e.jsx(lt,{size:21})})]})]}),c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-6 pt-6 sm:px-8",children:[e.jsx(Ft,{pending:c,importedNames:tt,org:z!==null}),E&&e.jsx("div",{role:"alert",className:"mt-4 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:E})]}),e.jsxs("footer",{className:"flex flex-col gap-3 border-t border-hairline/35 px-6 py-4 sm:flex-row sm:items-center sm:justify-between sm:px-8",children:[e.jsxs("div",{className:"text-[13px] text-ink-secondary",children:[s(Z===0?"templates.existingNone":Z===1?"templates.existingOne":"templates.existingMany",{count:Z})," ",c.kind==="backup"?s("teamImport.backupCopies"):c.library?s("teamImport.libraryAdds"):c.members.length===0?"":s("teamImport.newSection",{name:c.teamName??c.name})]}),z?Fe(z)==="add"?e.jsxs("button",{onClick:()=>{Be(z)},disabled:k,"aria-label":s("orgLibrary.addAria",{name:z.name}),className:"flex shrink-0 items-center justify-center gap-2 rounded-full bg-accent px-5 py-2.5 text-[14px] font-medium text-white hover:bg-accent/90 disabled:opacity-60",children:[k&&e.jsx(C,{size:15,className:"animate-spin"}),k?s("orgLibrary.adding"):s("orgLibrary.add")]}):e.jsxs("span",{className:"flex shrink-0 items-center gap-1 rounded-full bg-raised px-4 py-2 text-[13px] text-ink-secondary",children:[e.jsx(re,{size:14,className:"text-success"}),s("orgLibrary.added")]}):e.jsxs("button",{onClick:()=>{at()},disabled:k,className:"flex shrink-0 items-center justify-center gap-2 rounded-full bg-accent px-5 py-2.5 text-[14px] font-medium text-white hover:bg-accent/90 disabled:opacity-60",children:[k&&e.jsx(C,{size:15,className:"animate-spin"}),k?s("templates.importing"):c.kind==="backup"?s("templates.importBackup"):c.library?s("teamImport.addPresets"):s("templates.addTeam")]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-3 px-6 pb-4 pt-5 sm:flex-row sm:items-center sm:justify-between sm:px-8",children:[e.jsxs("div",{className:"flex w-fit rounded-xl bg-raised/70 p-1",role:"tablist","aria-label":s("templates.source"),children:[_?.organization&&e.jsx("button",{role:"tab","aria-selected":p==="org",onClick:()=>{B.current=!0,b("org"),g("")},className:y("max-w-[220px] truncate rounded-lg px-4 py-2 text-[14px] transition-colors",p==="org"?"bg-card text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:s("orgLibrary.tab",{name:_.organization.name})}),e.jsx("button",{role:"tab","aria-selected":p==="explore",onClick:()=>{B.current=!0,b("explore"),g("")},className:y("rounded-lg px-4 py-2 text-[14px] transition-colors",p==="explore"?"bg-card text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:s("templates.explore")}),e.jsx("button",{role:"tab","aria-selected":p==="import",onClick:()=>{B.current=!0,b("import"),g("")},className:y("rounded-lg px-4 py-2 text-[14px] transition-colors",p==="import"?"bg-card text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:s("templates.import")}),e.jsx("button",{role:"tab","aria-selected":p==="scout",onClick:()=>{B.current=!0,b("scout"),g("")},className:y("rounded-lg px-4 py-2 text-[14px] transition-colors",p==="scout"?"bg-card text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:s("templates.fromFolder")}),e.jsx("button",{role:"tab","aria-selected":p==="share",onClick:()=>{B.current=!0,b("share"),g("")},className:y("rounded-lg px-4 py-2 text-[14px] transition-colors",p==="share"?"bg-card text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:s("teamLibrary.shareTab")})]}),p==="explore"&&e.jsxs("label",{className:"flex h-11 w-full items-center gap-2.5 rounded-xl bg-raised/70 px-3.5 sm:w-[320px]",children:[e.jsx(ot,{size:17,className:"shrink-0 text-ink-secondary"}),e.jsx("input",{value:R,onChange:t=>qe(t.target.value),placeholder:s("templates.search"),"aria-label":s("templates.search"),className:"min-w-0 flex-1 bg-transparent text-[14px] text-ink placeholder:text-ink-secondary focus:outline-none"})]})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-7 pt-5 sm:px-8",children:[p==="org"&&_?.organization&&e.jsx(_t,{listing:_,busy:Qe,notice:Ve,error:Ze,onAdd:t=>{Be(t)},onDetails:t=>{rt(t)}}),p==="explore"&&e.jsxs("div",{children:[e.jsx(Mt,{search:R,onDialog:Xe,onAdded:a}),e.jsx("div",{className:"mb-3 text-[12px] font-medium text-ink-secondary",children:R?s("templates.searchResults"):s("templates.communityTemplates")}),w&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-24 text-[13px] text-ink-secondary",children:[e.jsx(C,{size:16,className:"animate-spin"})," ",s("templates.loading")]}),!w&&ne&&e.jsxs("div",{className:"rounded-xl bg-danger/10 p-4 text-[13px] text-danger",children:[e.jsx("p",{children:ne}),e.jsx("button",{onClick:()=>{ee()},className:"mt-3 rounded-full bg-raised px-3.5 py-2 text-ink hover:bg-raised-hover",children:s("common.tryAgain")})]}),!w&&L&&e.jsx("div",{className:"grid grid-cols-1 gap-x-10 md:grid-cols-2",children:ze.map((t,r)=>{const i=Ue(t);return e.jsxs("article",{className:"flex min-h-[104px] items-center gap-3 border-b border-hairline/35 px-1 py-4",children:[e.jsx($e,{index:r}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"truncate text-[14px] font-medium text-ink",children:i.name}),e.jsx("p",{className:"mt-0.5 truncate text-[13px] text-ink-secondary",children:i.outcome??i.summary}),e.jsxs("p",{className:"mt-1 truncate text-[12px] text-ink-tertiary",children:[s("templates.botCount",{count:t.members})," · ",s("templates.playbookCount",{count:t.skills.length}),t.requires.apps.length>0&&` · ${t.requires.apps.join(", ")}`,t.setupMinutes&&` · ${s("templates.minutes",{count:t.setupMinutes})}`]})]}),e.jsxs("button",{onClick:()=>{st(t)},disabled:W!==null,className:"flex min-w-[72px] items-center justify-center gap-1.5 rounded-full bg-raised px-3.5 py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-40",children:[W===t.slug&&e.jsx(C,{size:13,className:"animate-spin"}),W===t.slug?s("templates.loadingShort"):s("templates.load")]})]},t.slug)})}),!w&&L&&ze.length===0&&e.jsxs("div",{className:"flex min-h-56 flex-col items-center justify-center text-center",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:s("templates.noneFound")}),e.jsx("div",{className:"mt-1 text-[13px] text-ink-secondary",children:s("templates.tryDifferentSearch")})]})]}),p==="import"&&e.jsxs("div",{children:[e.jsx("input",{ref:v,type:"file",accept:".md,.json,.mausbackup.json,.mausteam.json,text/markdown,application/json",className:"hidden",onChange:t=>{const r=t.currentTarget.files?.[0];t.currentTarget.value="",r&&Se(r).catch(i=>g(i instanceof Error?i.message:String(i)))}}),e.jsx("div",{className:"mb-3 text-[12px] font-medium text-ink-secondary",children:s("templates.bringYourOwn")}),e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[e.jsxs("button",{onClick:()=>v.current?.click(),onDragEnter:t=>{t.preventDefault(),Q(!0)},onDragOver:t=>t.preventDefault(),onDragLeave:()=>Q(!1),onDrop:t=>{t.preventDefault(),Q(!1);const r=t.dataTransfer.files[0];r&&Se(r).catch(i=>g(i instanceof Error?i.message:String(i)))},className:y("flex min-h-56 flex-col items-center justify-center rounded-2xl border border-dashed px-6 text-center transition-colors",He?"border-accent bg-accent/5":"border-hairline/60 bg-raised/20 hover:bg-raised/35"),children:[e.jsx(Dt,{size:27,className:"text-accent"}),e.jsx("span",{className:"mt-3 text-[14px] font-medium text-ink",children:s("templates.chooseFile")}),e.jsx("span",{className:"mt-1 text-[13px] text-ink-secondary",children:s("templates.dropFile")})]}),e.jsxs("div",{className:"flex min-h-56 flex-col justify-center rounded-2xl bg-raised/25 px-6",children:[e.jsx(Oe,{size:25,className:"text-ink-secondary"}),e.jsx("h3",{className:"mt-3 text-[14px] font-medium text-ink",children:s("templates.loadGithub")}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("templates.githubHint")}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsx("input",{value:X,onChange:t=>oe(t.target.value),onKeyDown:t=>t.key==="Enter"&&void Ce(),placeholder:s("templates.githubPlaceholder"),"aria-label":s("templates.githubUrl"),className:"min-w-0 flex-1 rounded-xl bg-raised/80 px-3 py-2.5 text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"}),e.jsxs("button",{onClick:()=>{Ce()},disabled:!X.trim()||ce,className:"flex items-center gap-1.5 rounded-full bg-accent px-4 py-2.5 text-[13px] font-medium text-white hover:bg-accent/90 disabled:opacity-40",children:[ce&&e.jsx(C,{size:13,className:"animate-spin"}),s("templates.load")]})]})]})]}),E&&e.jsx("div",{role:"alert",className:"mt-4 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:E})]}),p==="share"&&e.jsxs("div",{children:[e.jsx("p",{className:"max-w-2xl text-[13px] leading-relaxed text-ink-secondary",children:s("teamLibrary.shareIntro")}),we.length===0?e.jsx("p",{className:"mt-6 text-[13px] text-ink-secondary",children:s("teamLibrary.shareEmpty")}):e.jsx("div",{className:"mt-4 grid grid-cols-1 gap-x-10 md:grid-cols-2",children:we.map((t,r)=>e.jsxs("article",{className:"flex min-h-[84px] items-center gap-3 border-b border-hairline/35 px-1 py-4",children:[e.jsx($e,{index:r}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"truncate text-[14px] font-medium text-ink",children:t.name||s("teamLibrary.general")}),e.jsx("p",{className:"mt-0.5 text-[13px] text-ink-secondary",children:s("teamLibrary.shareBots",{count:t.bots})})]}),e.jsxs("button",{onClick:()=>je(t.name),"aria-label":s("teamLibrary.shareTeamAria",{name:t.name||s("teamLibrary.general")}),className:"flex items-center gap-1.5 rounded-full bg-raised px-3.5 py-2 text-[13px] text-ink hover:bg-raised-hover",children:[e.jsx(Et,{size:13}),s("teamLibrary.shareTeam")]})]},t.name||"general"))})]}),p==="scout"&&e.jsxs("div",{children:[e.jsx("div",{className:"mb-3 text-[12px] font-medium text-ink-secondary",children:s("templates.startFolder")}),e.jsx("p",{className:"max-w-2xl text-[13px] leading-relaxed text-ink-secondary",children:s("templates.scoutHint")}),e.jsxs("div",{className:"mt-4 flex flex-col gap-2 sm:flex-row",children:[e.jsx("input",{value:me,onChange:t=>xe(t.target.value),onKeyDown:t=>t.key==="Enter"&&D&&void se(D),placeholder:"/path/to/your/project","aria-label":s("templates.projectFolder"),className:"min-w-0 flex-1 rounded-xl bg-raised/80 px-3 py-2.5 text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"}),!!window.ogb?.pickFolder&&e.jsxs("button",{onClick:()=>{nt()},disabled:$,className:"flex items-center justify-center gap-1.5 rounded-full bg-raised px-4 py-2.5 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-40",children:[e.jsx(zt,{size:14}),s("templates.browse")]}),e.jsxs("button",{onClick:()=>{se(D)},disabled:!D||$,className:"flex items-center justify-center gap-1.5 rounded-full bg-accent px-4 py-2.5 text-[13px] font-medium text-white hover:bg-accent/90 disabled:opacity-40",children:[$?e.jsx(C,{size:14,className:"animate-spin"}):e.jsx(Tt,{size:14}),$?s("templates.scouting"):s("templates.scout")]})]}),f&&e.jsxs("div",{className:"mt-6",children:[e.jsxs("div",{className:"rounded-2xl bg-raised/25 px-5 py-4",children:[e.jsx("div",{className:"text-[15px] font-semibold text-ink",children:f.profile.name}),f.profile.summary&&e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:f.profile.summary}),f.profile.stacks.length>0&&e.jsx("div",{className:"mt-2.5 flex flex-wrap gap-1.5",children:f.profile.stacks.map(t=>e.jsx("span",{className:"rounded-full bg-raised px-2.5 py-1 text-[12px] text-ink-secondary",children:t},t))})]}),e.jsx("div",{className:"mt-5 text-[12px] font-medium text-ink-secondary",children:s("templates.suggestedTeam")}),e.jsx("div",{className:"mt-1 grid grid-cols-1 gap-x-10 md:grid-cols-2",children:f.suggestion.manifest.team.members.map((t,r)=>e.jsxs("div",{className:"flex min-h-[64px] items-center gap-3 border-b border-hairline/35 px-1 py-3",children:[e.jsx("div",{className:y("flex size-9 shrink-0 items-center justify-center rounded-lg text-[13px] font-semibold",O[r%O.length]),children:t.name.slice(0,1).toUpperCase()}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"truncate text-[14px] font-medium text-ink",children:[t.name," ",e.jsxs("span",{className:"font-normal text-ink-secondary",children:["· ",t.title]})]}),e.jsx("div",{className:"mt-0.5 truncate text-[12px] text-ink-secondary",children:f.suggestion.reasons[t.key]??""})]})]},t.key))}),F&&F.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-5 text-[12px] font-medium text-ink-secondary",children:s("templates.communityDirectory")}),e.jsx("div",{className:"mt-1 flex flex-col",children:F.map(t=>e.jsxs("div",{className:"flex items-center gap-3 border-b border-hairline/35 px-1 py-3",children:[e.jsxs("label",{className:"flex min-w-0 flex-1 cursor-pointer items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:ge.has(t.slug),onChange:()=>he(r=>{const i=new Set(r);return i.has(t.slug)?i.delete(t.slug):i.add(t.slug),i}),className:"size-4 accent-accent"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"truncate text-[14px] font-medium text-ink",children:[t.name,t.category&&e.jsxs("span",{className:"font-normal text-ink-secondary",children:[" · ",t.category]})]}),e.jsx("div",{className:"mt-0.5 truncate text-[12px] text-ink-secondary",children:s("templates.matches",{values:t.matched.join(", ")})})]})]}),e.jsx("button",{onClick:()=>{Re(t.detailUrl)},"aria-label":s("templates.openDirectory",{name:t.name}),title:s("templates.readBeforeAdding"),className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised hover:text-ink",children:e.jsx(Ie,{size:14})})]},t.slug))})]}),e.jsxs("div",{className:"mt-6 flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsx("input",{value:be,onChange:t=>fe(t.target.value),"aria-label":s("templates.groupChatName"),className:"min-w-0 flex-1 rounded-xl bg-raised/80 px-3 py-2.5 text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"}),e.jsxs("button",{onClick:()=>{it()},disabled:G,className:"flex shrink-0 items-center justify-center gap-2 rounded-full bg-accent px-5 py-2.5 text-[14px] font-medium text-white hover:bg-accent/90 disabled:opacity-60",children:[G&&e.jsx(C,{size:15,className:"animate-spin"}),G?s("templates.creating"):s("templates.createGroupChat")]})]}),e.jsx("p",{className:"mt-2 text-[12px] text-ink-secondary",children:s("templates.createGroupHint")})]}),E&&e.jsx("div",{role:"alert",className:"mt-4 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:E})]})]})]})]}),M!==null&&e.jsx(Pt,{team:M,onClose:()=>je(null)})]}),document.body)}export{Ft as TeamImportDetails,as as TeamLibraryPanel,Kt as shareableTeamList};
@@ -1 +0,0 @@
1
- import{U as a,C as n}from"./mermaid.core-1h5EGl1v.js";const t=(r,o)=>a.lang.round(n.parse(r)[o]);export{t as c};