limixbot 0.3.50 → 0.3.52

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 (230) hide show
  1. package/dist/assets/{ActivityPanel-BwDOVD9j.js → ActivityPanel-DoWrjUz7.js} +1 -1
  2. package/dist/assets/App-DmJM-bVw.js +243 -0
  3. package/dist/assets/{AppEventEditor-zUBmRtgm.js → AppEventEditor-emHq_cA0.js} +1 -1
  4. package/dist/assets/BotSettingsDialog-BshbTnT_.js +16 -0
  5. package/dist/assets/{BrowserPanel-B5vUqP5d.js → BrowserPanel-PLHN7znJ.js} +2 -2
  6. package/dist/assets/{BrowserProfilesManager-DF3iHV1l.js → BrowserProfilesManager-ChG7MrYQ.js} +1 -1
  7. package/dist/assets/CloudAddDialog-CyKmG4VN.js +1 -0
  8. package/dist/assets/ComputerFilesPane-BPu6_l8N.js +1 -0
  9. package/dist/assets/{ComputerPanel-o_9TTtVS.js → ComputerPanel-Df-QaAS2.js} +2 -2
  10. package/dist/assets/{DataPanel-D6Yq58K8.js → DataPanel-QSdW8P4h.js} +1 -1
  11. package/dist/assets/{DesktopViewer-DFhYwHIq.js → DesktopViewer-Du64Zar0.js} +1 -1
  12. package/dist/assets/{FilesView-DIY7IawO.js → FilesView-0Ijtj6CN.js} +1 -1
  13. package/dist/assets/{GrokMoveDialog-yVqkaGh0.js → GrokMoveDialog-BVG5-cPU.js} +1 -1
  14. package/dist/assets/{InspectorPanel-DZmieMQG.js → InspectorPanel-CtBr7aZo.js} +2 -2
  15. package/dist/assets/{KeyboardShortcutsModal-S5e-EG9u.js → KeyboardShortcutsModal-Co3LHjUp.js} +1 -1
  16. package/dist/assets/{LimixChannelReview-CrGNdtS-.js → LimixChannelReview-LNSDJ-cn.js} +1 -1
  17. package/dist/assets/{LiveDesktop-H2irpbo4.js → LiveDesktop-DPs1lypu.js} +1 -1
  18. package/dist/assets/{LocalVmWorkspace-5beJanrU.js → LocalVmWorkspace-Bf2EXh1s.js} +1 -1
  19. package/dist/assets/{MacLocalControl-D5PKKnuP.js → MacLocalControl-BGeq2FOD.js} +1 -1
  20. package/dist/assets/{MarkdownFilePreview-CKcwA3Cw.js → MarkdownFilePreview-BDNgFKxV.js} +1 -1
  21. package/dist/assets/{MenuMotion-CtV49YrJ.js → MenuMotion-DFWzLAOE.js} +1 -1
  22. package/dist/assets/{NewBotDialog-Cna8-DSW.js → NewBotDialog-itNxT2iU.js} +1 -1
  23. package/dist/assets/{PhoneAppDialog-Dtkpl1Hc.js → PhoneAppDialog-CMtCT9Xu.js} +1 -1
  24. package/dist/assets/PlacesRail-i-4ph-KR.js +1 -0
  25. package/dist/assets/{PluginsPanel-LvPKdxpW.js → PluginsPanel-49ZWw79q.js} +2 -2
  26. package/dist/assets/ProIntroduction-CyKL7OF8.js +1 -0
  27. package/dist/assets/{RemoteAgentSettingsPanel-BIqx787N.js → RemoteAgentSettingsPanel-Bbp1t8mD.js} +1 -1
  28. package/dist/assets/{RoomPanel-CJTHUkDN.js → RoomPanel-Gw0rFOk7.js} +1 -1
  29. package/dist/assets/{RoutinesPage-C8QjVdJH.js → RoutinesPage-Bo4NVg7D.js} +2 -2
  30. package/dist/assets/SettingsModal-D4XZMVXS.js +19 -0
  31. package/dist/assets/{ShareTeamDialog-DLKGTkzv.js → ShareTeamDialog-CeT0rE7W.js} +1 -1
  32. package/dist/assets/{SignedInSites-Ccr7Us46.js → SignedInSites-BGpe1m04.js} +1 -1
  33. package/dist/assets/{TeamLibraryPanel-DWkmvSW0.js → TeamLibraryPanel-SJebr72G.js} +1 -1
  34. package/dist/assets/{TeamMapPage-BjPonu5A.js → TeamMapPage-DIiHaEPP.js} +1 -1
  35. package/dist/assets/{TriggersPage-BE8reM-u.js → TriggersPage-Dz_RBgRC.js} +1 -1
  36. package/dist/assets/VisibilitySection-BLgOrAop.js +22 -0
  37. package/dist/assets/{WebhookTrigger-BOsrYQH6.js → WebhookTrigger-Cw7eIur5.js} +1 -1
  38. package/dist/assets/{WorksOnGrid-D204I3p5.js → WorksOnGrid-DJiQ_gRM.js} +1 -1
  39. package/dist/assets/{abnfDiagram-YUKMZFIV-DmWI1Mtg.js → abnfDiagram-YUKMZFIV-CAhmS2rs.js} +1 -1
  40. package/dist/assets/{activity-WfPBvs3Z.js → activity-Bi0tXcsw.js} +1 -1
  41. package/dist/assets/{architectureDiagram-47P4ROYG-rzc3-Q0w.js → architectureDiagram-47P4ROYG-B6w0Yu0g.js} +1 -1
  42. package/dist/assets/{blockDiagram-E7TT5TSB-VPDyKlQ7.js → blockDiagram-E7TT5TSB-BYtaJu6s.js} +1 -1
  43. package/dist/assets/{c4Diagram-CRA5TL53-C9OGckku.js → c4Diagram-CRA5TL53-B_FsOyDV.js} +1 -1
  44. package/dist/assets/{calendar-days-W4JHp6-m.js → calendar-days-B8SfZLZO.js} +1 -1
  45. package/dist/assets/channel-DVwNbGUM.js +1 -0
  46. package/dist/assets/{chunk-2Q5K7J3B-EpYkwMC8.js → chunk-2Q5K7J3B-BdKiuWEd.js} +1 -1
  47. package/dist/assets/{chunk-5VM5RSS4-DyJEI8X6.js → chunk-5VM5RSS4-CgItQr02.js} +1 -1
  48. package/dist/assets/{chunk-7TKQ45FW-CJvVxQ2I.js → chunk-7TKQ45FW-BFsWqiRT.js} +1 -1
  49. package/dist/assets/{chunk-AW2ZBBNX-s78zNrhy.js → chunk-AW2ZBBNX-Cnj5ddTo.js} +1 -1
  50. package/dist/assets/{chunk-FVRAUYC3-CUPjaz9e.js → chunk-FVRAUYC3-BCqqreNP.js} +2 -2
  51. package/dist/assets/{chunk-HTAEGDNF-BhuM2dxl.js → chunk-HTAEGDNF-BOE8LQps.js} +1 -1
  52. package/dist/assets/{chunk-JWPE2WC7-DAj1UgJ8.js → chunk-JWPE2WC7-DhA4nyzx.js} +1 -1
  53. package/dist/assets/{chunk-KQW6MTUR-BgfdtkJI.js → chunk-KQW6MTUR-DzXl5ZXS.js} +1 -1
  54. package/dist/assets/{chunk-XXDRQBXY-Vak43p0S.js → chunk-XXDRQBXY-C6tPSut7.js} +1 -1
  55. package/dist/assets/{classDiagram-v2-K4WV4PDN-Cjvbs86l.js → classDiagram-v2-K4WV4PDN-DQW9NJQl.js} +1 -1
  56. package/dist/assets/{core-D5ZIkAZ3.js → core-B3WlSEbe.js} +1 -1
  57. package/dist/assets/{cose-bilkent-JH36ORCC-BEekB3gO.js → cose-bilkent-JH36ORCC-6jNO5GSL.js} +1 -1
  58. package/dist/assets/{cynefin-EF2NZ3EQ-D3g3_jPk.js → cynefin-EF2NZ3EQ-mnQt4_3K.js} +1 -1
  59. package/dist/assets/{cynefinDiagram-3GCD6N5R-13xmjXZj.js → cynefinDiagram-3GCD6N5R-DoEMDFuf.js} +1 -1
  60. package/dist/assets/{dagre-W4DXFKR2-CHAV8s2t.js → dagre-W4DXFKR2-DoKMCbtK.js} +1 -1
  61. package/dist/assets/de-C8GllVmL.js +8 -0
  62. package/dist/assets/{diagram-2UJZ2QOL-DgwdzZN7.js → diagram-2UJZ2QOL-dVwBPQ-y.js} +1 -1
  63. package/dist/assets/{diagram-OVF4WLC6-DobmWwa_.js → diagram-OVF4WLC6-xIwVUznT.js} +1 -1
  64. package/dist/assets/{diagram-PFPMY2P6-CWjTVc0N.js → diagram-PFPMY2P6-DAkRkPXu.js} +1 -1
  65. package/dist/assets/{diagram-UMYRVEAY-CAruZkhk.js → diagram-UMYRVEAY-YE49n-np.js} +1 -1
  66. package/dist/assets/{diagram-YEKJPTXX-Bcs89mQN.js → diagram-YEKJPTXX-DQkmy5qU.js} +1 -1
  67. package/dist/assets/{diagram-ZIFT7M5P-Dz-O18tl.js → diagram-ZIFT7M5P-u9Uj06_B.js} +1 -1
  68. package/dist/assets/{ebnfDiagram-VR2GEFS7-CJX4rMIs.js → ebnfDiagram-VR2GEFS7-DoxIDWDW.js} +1 -1
  69. package/dist/assets/{elk-IJKZMXRS-Byop6FtW.js → elk-IJKZMXRS-DPDeQQIg.js} +1 -1
  70. package/dist/assets/{erDiagram-O2IAPWRE-ChpLnNCF.js → erDiagram-O2IAPWRE-BHdTvU5H.js} +1 -1
  71. package/dist/assets/{file-up-G3qWGpEB.js → file-up-BkYyRMzo.js} +1 -1
  72. package/dist/assets/{flowDiagram-OXPTDLAJ-CWWhkNOE.js → flowDiagram-OXPTDLAJ-ChNmwKMG.js} +1 -1
  73. package/dist/assets/{ganttDiagram-R7TSEDQI-DMXicWgq.js → ganttDiagram-R7TSEDQI-3Sx3AKf_.js} +1 -1
  74. package/dist/assets/{gitGraphDiagram-XJZIOB7I-CpiCnPUQ.js → gitGraphDiagram-XJZIOB7I-C67fsohV.js} +1 -1
  75. package/dist/assets/{import-name-Cjp7lk7e.js → import-name-zOg5ckYf.js} +1 -1
  76. package/dist/assets/index-DhTEAf1-.js +3 -0
  77. package/dist/assets/{index-CZvRt7dv.js → index-Uvk6r9xX.js} +1 -1
  78. package/dist/assets/{infoDiagram-5W2HQ5XZ-BU9zbv9f.js → infoDiagram-5W2HQ5XZ-CBtxWn_a.js} +1 -1
  79. package/dist/assets/{ishikawaDiagram-K3B6WC7H-KEjUVvmG.js → ishikawaDiagram-K3B6WC7H-B0368JQ8.js} +1 -1
  80. package/dist/assets/{journeyDiagram-COXZFDF6-DGU1V_40.js → journeyDiagram-COXZFDF6-BlyoIOJv.js} +1 -1
  81. package/dist/assets/{kanban-definition-P3RFRI5V-weJ2OFB2.js → kanban-definition-P3RFRI5V-Cn5CUDI2.js} +1 -1
  82. package/dist/assets/{mcp-servers-_vV_C1no.js → mcp-servers-BffOs9kX.js} +1 -1
  83. package/dist/assets/{mermaid.core-DhSRukyE.js → mermaid.core-BitzuZjJ.js} +4 -4
  84. package/dist/assets/{mindmap-definition-LZFPQGKD-DKKO0DWj.js → mindmap-definition-LZFPQGKD-Jg9lbPrn.js} +1 -1
  85. package/dist/assets/{minimize-C16JX5N8.js → minimize-CIbeUlkc.js} +1 -1
  86. package/dist/assets/{monitor-Bben4nuu.js → monitor-CQgH3Q9j.js} +1 -1
  87. package/dist/assets/{new-bot-DwK47ypo.js → new-bot-D75cIR6C.js} +2 -2
  88. package/dist/assets/org-library-pEzmTM3q.js +1 -0
  89. package/dist/assets/{package-format-CmRh54Ve.js → package-format-C8RU0HIi.js} +2 -2
  90. package/dist/assets/{pegDiagram-BGZESJAR-CNNprTkt.js → pegDiagram-BGZESJAR-CnAlnJHt.js} +1 -1
  91. package/dist/assets/{pieDiagram-CAPJLFHJ-pS8U8zdK.js → pieDiagram-CAPJLFHJ-DaL17-zU.js} +1 -1
  92. package/dist/assets/pt-br-DiNqB940.js +13 -0
  93. package/dist/assets/{quadrantDiagram-GDMTTRAM-CLk_fr2j.js → quadrantDiagram-GDMTTRAM-BJHzyXHs.js} +1 -1
  94. package/dist/assets/rail-BDfsZpav.js +1 -0
  95. package/dist/assets/{railroadDiagram-SM67HX2B-DH8VPMJG.js → railroadDiagram-SM67HX2B-Cw9re6eo.js} +1 -1
  96. package/dist/assets/{remote-desktop-panel-C_EqBmng.js → remote-desktop-panel-BI4lP7pc.js} +1 -1
  97. package/dist/assets/{requirementDiagram-X7JNWC4A-CoHRI7dx.js → requirementDiagram-X7JNWC4A-Cd7X7PJA.js} +1 -1
  98. package/dist/assets/{sankeyDiagram-UM26HJRW-2zcVfvWw.js → sankeyDiagram-UM26HJRW-nufeOHip.js} +1 -1
  99. package/dist/assets/{sequenceDiagram-ZO4K6R2Y-B0d21eid.js → sequenceDiagram-ZO4K6R2Y-CMZoHw7j.js} +1 -1
  100. package/dist/assets/{sizeCapture-INFHLROL-CcYkvoh7.js → sizeCapture-INFHLROL-DPZOqMVW.js} +1 -1
  101. package/dist/assets/{stateDiagram-v2-TBUQTH76-B5EilR72.js → stateDiagram-v2-TBUQTH76-BpWOIyFw.js} +1 -1
  102. package/dist/assets/styles-BvB4UlHn.js +79 -0
  103. package/dist/assets/styles-Ce5Qc_2r.css +1 -0
  104. package/dist/assets/{swimlanes-N4OXWK64-xM7mNll9.js → swimlanes-N4OXWK64-BNx8ZaTX.js} +1 -1
  105. package/dist/assets/swimlanesDiagram-K3J5GTZL-BO73RuC_.js +8 -0
  106. package/dist/assets/{team-share-Bp69YR8I.js → team-share-CNY994iy.js} +1 -1
  107. package/dist/assets/{timeline-definition-YOQAKGHF-DM6SmhCQ.js → timeline-definition-YOQAKGHF-L78B2xWx.js} +1 -1
  108. package/dist/assets/{usecaseDiagram-VIAY4XPW-DiUdGN3G.js → usecaseDiagram-VIAY4XPW-gU5zWpPp.js} +1 -1
  109. package/dist/assets/{vennDiagram-BLWOH2XV-DrtmNBp4.js → vennDiagram-BLWOH2XV-pdiz8880.js} +1 -1
  110. package/dist/assets/vi-Cbg_srO_.js +15 -0
  111. package/dist/assets/{wardleyDiagram-YMQ3BMBF-D7jihWm5.js → wardleyDiagram-YMQ3BMBF-F-D92MhK.js} +1 -1
  112. package/dist/assets/{xychartDiagram-TAQBALBS-BCk-D9Uj.js → xychartDiagram-TAQBALBS-DKMdsWWR.js} +1 -1
  113. package/dist/index.html +3 -3
  114. package/dist/rail.html +5 -5
  115. package/dist-server/bot-box/box-check.js +10 -10
  116. package/dist-server/cloud-home-start.js +5 -5
  117. package/dist-server/container-mcp.js +2 -2
  118. package/dist-server/drivers/agents-proxy.js +128 -126
  119. package/dist-server/index.js +8256 -7937
  120. package/dist-server/mcp-gate.js +18 -17
  121. package/dist-server/openmausbot.js +1190 -1156
  122. package/dist-server/package.json +1 -1
  123. package/dist-server/pair-cli.js +1065 -1034
  124. package/dist-server/server/activity.js +1 -0
  125. package/dist-server/server/agents-turn.js +2 -1
  126. package/dist-server/server/app-settings/host.js +187 -0
  127. package/dist-server/server/app-settings/picture-file.js +62 -0
  128. package/dist-server/server/app-settings/registry-bots.js +147 -0
  129. package/dist-server/server/app-settings/registry-config.js +190 -0
  130. package/dist-server/server/app-settings/registry-pictures.js +59 -0
  131. package/dist-server/server/app-settings/registry-window.js +35 -0
  132. package/dist-server/server/app-settings/registry.js +287 -0
  133. package/dist-server/server/attachments.js +16 -12
  134. package/dist-server/server/automation-reports.js +11 -1
  135. package/dist-server/server/bot-attachment.js +34 -10
  136. package/dist-server/server/bot-box/env.js +2 -2
  137. package/dist-server/server/bot-box/plan.js +1 -1
  138. package/dist-server/server/cloud-home-start.js +2 -0
  139. package/dist-server/server/config.js +1 -0
  140. package/dist-server/server/drivers/acp/client-path.js +39 -0
  141. package/dist-server/server/drivers/acp/core.js +9 -37
  142. package/dist-server/server/drivers/agents-app-settings-tool.js +22 -0
  143. package/dist-server/server/drivers/agents-call.js +8 -3
  144. package/dist-server/server/drivers/agents-catalog-profile.js +2 -1
  145. package/dist-server/server/drivers/agents-catalog.js +19 -2
  146. package/dist-server/server/drivers/agents-claude-defer.js +38 -0
  147. package/dist-server/server/drivers/agents-mcp-env.js +2 -2
  148. package/dist-server/server/drivers/agents-mcp.js +2 -1
  149. package/dist-server/server/drivers/agents-proxy.js +0 -1
  150. package/dist-server/server/drivers/agents-tool-groups.js +45 -0
  151. package/dist-server/server/drivers/antigravity-acp.js +6 -2
  152. package/dist-server/server/drivers/antigravity-skills.js +107 -0
  153. package/dist-server/server/drivers/antigravity.js +9 -1
  154. package/dist-server/server/drivers/claude-bot-settings.js +22 -1
  155. package/dist-server/server/drivers/claude-tool-search.js +20 -2
  156. package/dist-server/server/drivers/claude.js +12 -12
  157. package/dist-server/server/drivers/codex.js +4 -1
  158. package/dist-server/server/drivers/ollama-context.js +5 -2
  159. package/dist-server/server/drivers/openai-chat.js +10 -10
  160. package/dist-server/server/drivers/retry.js +3 -2
  161. package/dist-server/server/email/host.js +6 -2
  162. package/dist-server/server/engine-handshake.js +1 -0
  163. package/dist-server/server/generated-image.js +1 -1
  164. package/dist-server/server/host/bot-holds.js +76 -0
  165. package/dist-server/server/host/fill-login-turn.js +2 -2
  166. package/dist-server/server/host/handoff-limits.js +30 -0
  167. package/dist-server/server/host/limit-takeover.js +11 -0
  168. package/dist-server/server/host/peer-limit-resend.js +147 -0
  169. package/dist-server/server/host/skills-library.js +15 -1
  170. package/dist-server/server/host/trust-answers.js +42 -0
  171. package/dist-server/server/imported-skills.js +15 -4
  172. package/dist-server/server/index.js +109 -125
  173. package/dist-server/server/limit-poll.js +32 -0
  174. package/dist-server/server/limit-reset-owed.js +15 -0
  175. package/dist-server/server/limit-resets.js +33 -8
  176. package/dist-server/server/login-fill.js +37 -9
  177. package/dist-server/server/mcp-gate-config.js +28 -0
  178. package/dist-server/server/mcp-gate.js +8 -2
  179. package/dist-server/server/message-file.js +10 -1
  180. package/dist-server/server/quota-switch.js +7 -5
  181. package/dist-server/server/replies.js +1 -1
  182. package/dist-server/server/request-auth.js +7 -4
  183. package/dist-server/server/routes/app-settings.js +46 -0
  184. package/dist-server/server/routes/bot-holds.js +24 -0
  185. package/dist-server/server/routes/bot-patch.js +7 -0
  186. package/dist-server/server/routes/call-route.js +16 -0
  187. package/dist-server/server/routes/channels.js +45 -38
  188. package/dist-server/server/routes/custom-domain.js +36 -0
  189. package/dist-server/server/routes/sidebar-sections.js +1 -0
  190. package/dist-server/server/routes/threads.js +1 -1
  191. package/dist-server/server/routine-lines.js +25 -0
  192. package/dist-server/server/routines.js +9 -5
  193. package/dist-server/server/runtime/envelope.js +3 -0
  194. package/dist-server/server/runtime/store.js +1 -0
  195. package/dist-server/server/send-idempotency.js +43 -0
  196. package/dist-server/server/shared-computers.js +35 -6
  197. package/dist-server/server/themes/history.js +54 -0
  198. package/dist-server/server/themes/routes.js +136 -0
  199. package/dist-server/server/themes/store.js +266 -0
  200. package/dist-server/server/themes/tool.js +151 -0
  201. package/dist-server/server/tool-groups.js +12 -0
  202. package/dist-server/server/turn-continuation.js +6 -6
  203. package/dist-server/shared/app-settings.js +60 -0
  204. package/dist-server/shared/bot-limit.js +2 -0
  205. package/dist-server/shared/plain-preview.js +3 -2
  206. package/dist-server/shared/theme.js +240 -0
  207. package/dist-server/shared/tool-groups.js +27 -0
  208. package/dist-server/src/lib/composer-attachments.js +22 -6
  209. package/dist-server/vps-container-mcp.js +12 -12
  210. package/dist-server/workspace-backup.worker.js +2 -2
  211. package/package.json +1 -1
  212. package/dist/assets/App-CGZnP4z7.js +0 -243
  213. package/dist/assets/BotSettingsDialog-DTFwZfbQ.js +0 -16
  214. package/dist/assets/CloudAddDialog-Bi9x2OVN.js +0 -1
  215. package/dist/assets/ComputerFilesPane-DXb-rVT_.js +0 -1
  216. package/dist/assets/PlacesRail-COZEZH0n.js +0 -57
  217. package/dist/assets/ProIntroduction-Cjw1BiAB.js +0 -1
  218. package/dist/assets/SettingsModal-D3I1whQj.js +0 -19
  219. package/dist/assets/VisibilitySection-diCNRN7h.js +0 -22
  220. package/dist/assets/channel-DAFePtOr.js +0 -1
  221. package/dist/assets/de-CJcRve_J.js +0 -8
  222. package/dist/assets/index-CSGTkyGn.js +0 -2
  223. package/dist/assets/org-library-BXuxCBsG.js +0 -1
  224. package/dist/assets/pt-br-Dr9a700a.js +0 -13
  225. package/dist/assets/rail-CpM5o3ti.js +0 -1
  226. package/dist/assets/styles-Cbtcp5Re.js +0 -23
  227. package/dist/assets/styles-rYmbSF4Y.css +0 -1
  228. package/dist/assets/swimlanesDiagram-K3J5GTZL-CnVwW_RC.js +0 -8
  229. package/dist/assets/vi-vTat5qyz.js +0 -15
  230. package/dist-server/server/limix-managed-grant.js +0 -110
@@ -1,16 +0,0 @@
1
- import{c as Re,t as s,b as se,av as Ds,j as e,i as Me,a9 as fe,a as R,r as p,S as Je,ac as Kt,X as Qe,f as lt}from"./styles-Cbtcp5Re.js";import{fg as $s,fh as Fs,a2 as Ze,by as zs,di as Ut,w as Hs,fi as _s,fj as Ks,K as qt,fk as Us,R as Wt,eu as qs,x as Ws,fl as ot,bt as ct,fm as Vt,n as ae,u as F,fn as Vs,ah as Xe,F as Gt,A as Yt,S as dt,ad as Ie,T as Jt,W as Gs,fo as Ys,fp as Js,fq as Qs,fr as Zs,fs as Xs,ft as mt,fu as ea,fv as ta,fw as sa,fx as aa,b9 as na,fy as ra,fz as ia,fA as la,I as oa,fB as Se,bP as et,fC as ca,aI as D,aO as ee,ed as da,dK as ma,fD as ua,aJ as Ue,cp as pa,dZ as xa,d_ as ha,fE as fa,fF as Qt,fG as Zt,fH as ga,fI as ya,fJ as ba,fK as va,dN as qe,fL as je,ar as ut,fM as ka,fN as Pe,av as ja,fO as Xt,bB as B,fP as pt,ak as We,fQ as wa,fR as Na,fS as Sa,fT as es,fU as Ca,fV as Pa,fW as Oa,fX as Ea,fY as X,aX as ne,aZ as Z,fZ as Ra,f_ as Ia,f$ as Aa,d5 as La,d as Ta,G as Ma,d3 as ts,aj as Ba,g0 as G,aW as ue,g1 as pe,g2 as Da,dp as $a,g3 as Ae,aY as ce,g4 as Fa,g5 as za,g6 as Ha,eh as _a,g7 as xt,g8 as Ka,g9 as Ua,ga as qa,gb as Wa,gc as Va,gd as Ga,aC as Ya,ge as ss,gf as Ja,gg as Qa,gh as Za,gi as Xa,gj as en,gk as tn,gl as sn,gm as an,gn as nn,go as rn,gp as ln,gq as on,gr as tt,k as cn,B as Ve,gs as dn,gt as mn,gu as un,gv as pn,bY as xn,gw as as,J as ht,eY as hn,gx as ft,gy as fn,gz as gn,cM as gt,bw as yn,d2 as bn,gA as vn,gB as ns,gC as we,gD as yt,gE as kn,aM as Be,d$ as jn,gF as wn,aR as Nn,C as Sn,cq as Cn,gG as Pn,gH as On,gI as En,aT as Rn}from"./App-CGZnP4z7.js";import{z as rs,d as be,a1 as Oe,a2 as In,a3 as An,a4 as bt,a5 as De,a6 as Ln,a7 as Tn,a8 as Mn,a9 as Bn,aa as Dn,ab as vt,ac as $n,ad as Fn,L as Ce,N as zn,B as Ge,P as ve,r as is,ae as Hn,a0 as _n,u as ls}from"./PlacesRail-COZEZH0n.js";import{C as Kn,a as Un}from"./LimixChannelReview-CrGNdtS-.js";import{C as ye,a as qn}from"./MenuMotion-CtV49YrJ.js";import{b as te,m as os,i as Ye,f as st,c as he,d as kt,e as Ee,o as Wn,g as Vn,h as me,n as $e,t as cs,s as at,j as ds,k as Gn,l as Yn,p as Jn,r as ms,q as Qn,u as Zn,w as Xn,x as us,y as ps,z as jt,B as er,C as xs,R as wt,D as tr,E as sr,F as ar,G as nr,H as rr,J as ir,O as lr,K as or,L as hs,N as Nt,V as cr,P as dr,M as mr,A as ur,a as pr,S as xr,I as hr}from"./VisibilitySection-diCNRN7h.js";import{s as fr,r as gr,a as yr,R as br}from"./ComputerFilesPane-DXb-rVT_.js";import{M as St}from"./monitor-Bben4nuu.js";import{a as fs,m as gs,b as vr,c as kr}from"./mcp-servers-_vV_C1no.js";import{R as jr}from"./RoutinesPage-C8QjVdJH.js";import{S as wr}from"./SignedInSites-Ccr7Us46.js";import"./index-CSGTkyGn.js";import"./org-library-BXuxCBsG.js";import"./package-format-CmRh54Ve.js";import"./WorksOnGrid-D204I3p5.js";import"./ProIntroduction-Cjw1BiAB.js";import"./remote-desktop-DDRRx8uY.js";const Nr=[["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"}]],Sr=Re("calendar-plus",Nr);const Cr=[["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"}]],Pr=Re("library",Cr);const Or=[["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"}]],ys=Re("slack",Or);const Er=[["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"}]],Rr=Re("tag",Er),Ir=[{id:"overview",label:"Overview",labelKey:"botSettings.sections.overview",icon:$s,keywords:["summary","status","what it does","won't","prompt","what the model sees"]},{id:"identity",label:"Identity",labelKey:"botSettings.sections.identity",icon:Fs,keywords:["name","title","avatar","blurb","instructions"]},{id:"slack",label:"Slack",icon:ys,keywords:["slack","slack app","admin","message","direct messages","mentions"]},{id:"soul",label:"Soul",labelKey:"botSettings.sections.soul",icon:Ze,keywords:["standing instructions","instructions","persona","rules","soul.md"]},{id:"skills",label:"Skills",labelKey:"botSettings.sections.skills",icon:zs,keywords:["skills","learned","procedures","teach"]},{id:"memory",label:"Memory",labelKey:"botSettings.sections.memory",icon:Ut,keywords:["memory","notes","remember","topics"]},{id:"library",label:"Library",labelKey:"botPanel.tab.library",icon:Pr,keywords:["library","made","pages","apps","files","published"]},{id:"routines",label:"Routines",labelKey:"botSettings.sections.routines",icon:Hs,keywords:["schedule","routines","cron","tasks"]},{id:"access",label:"Access",labelKey:"botSettings.sections.access",icon:_s,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:Ks,keywords:["engine","model","provider","cli","effort"]},{id:"permissions",label:"Permissions",labelKey:"botSettings.sections.permissions",icon:qt,keywords:["auto mode","approve","auto approve","review","routine approvals","coordination","chief of staff","section"]},{id:"voice",label:"Voice & alerts",labelKey:"botSettings.sections.voice",icon:Us,keywords:["voice","alerts","notifications","speak"]},{id:"visibility",label:"Who can see it",labelKey:"botSettings.visibility.title",icon:Wt,keywords:["visibility","who can see","private","people","admins","members","access","hide"]},{id:"history",label:"History",labelKey:"botSettings.sections.history",icon:qs,keywords:["history","changes","undo","rollback","log"]},{id:"usage",label:"Usage",labelKey:"botSettings.sections.usage",icon:Kn,keywords:["tokens","cost","billing"]}],Ct={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 Ar(t,a=se()){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(Ct,n.status))return null;try{return[s("botOverview.routine.line",{schedule:Ws(t.schedule),name:t.name}),...t.nextRunAt!=null?[s("botOverview.routine.next",{time:ot(t.nextRunAt)})]:[],...n?[s(Ct[n.status],{time:ot(n.at)})]:[]].join(" ")}catch{return null}}const Pt={"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"},Ot={"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 Et(t,a){return!a||a.map(n=>n||"General").join(", ")!==t?t:a.map(n=>n||s("botAccess.teams.general")).join(", ")}const Rt=t=>Object.hasOwn(Ot,t)?s(Ot[t]):t,It=(t,a,n)=>Number(t)===1?a:n,Lr=[{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:Et(t,a)})},{line:/^Can talk to (\d+) other bots? in its (?:section|department)\.$/,key:([,t])=>It(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])=>It(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:Et(t,a)})}],Tr=t=>se()!=="en"&&Object.hasOwn(Ds[se()]??{},t);function Mr(t,a){for(const n of Lr){const i=n.line.exec(t);if(!i)continue;const r=n.key(i);return Tr(r)?s(r,n.params(i,a)):t}return null}function Fe(t,a){if(Object.hasOwn(Pt,t))return s(Pt[t]);const n=Mr(t,a);if(n!==null)return n;const i=/^Can use (\d+) connected apps?: (.+)\.$/.exec(t);if(i)return s(i[1]==="1"?"botOverview.line.appsOne":"botOverview.line.appsMany",{count:Number(i[1]),apps:i[2]});const r=se()==="en"?null:/^Computer preference: (.+), which isn't available on My Cloud\.$/.exec(t);if(r)return s("botOverview.line.computerNotOnCloud",{preference:Rt(r[1])});const l=/^Computer preference: (.+)\.$/.exec(t);if(l)return s("botOverview.line.computer",{preference:Rt(l[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 At={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 Br(t,a=se()){const n=/^(\w+): /.exec(t)?.[1];return a==="en"||!n||!Object.hasOwn(At,n)?t:`${s(At[n])}: ${t.slice(n.length+2)}`}function Dr({data:t,error:a,open:n,onToggle:i}){return e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("button",{type:"button",onClick:i,"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(Me()),tokens:t.approxTokens.toLocaleString(Me())}):s("botOverview.promptPreview")}),e.jsx(fe,{size:16,className:R("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(Me())})})]}),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 $r({overview:t,refreshError:a,prompt:n,promptError:i,onOpen:r,onSetup:l}){const[c,d]=p.useState(!1);if(!t)return e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("botOverview.loading")});const u=(t.setup??[]).filter(f=>!f.done),m=(f,v)=>s(`botOverview.setup.${f}`)||v;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(f=>e.jsx("li",{children:f.section?e.jsxs("button",{type:"button",onClick:()=>r(f.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(ct,{"aria-hidden":"true",size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"flex-1",children:m(f.id,f.label)}),e.jsx(ye,{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(ct,{"aria-hidden":"true",size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("span",{children:m(f.id,f.label)})]})},f.id))}),l&&e.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[e.jsxs("button",{type:"button",onClick:l,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(Ze,{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((f,v)=>e.jsx("li",{children:Ar(t.doesRoutines?.[v])??Fe(f)},v))})]}),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((f,v)=>e.jsx("li",{children:Fe(f,t.managedSections)},v))})]}),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((f,v)=>e.jsx("li",{children:Fe(f,t.managedSections)},v))})]}),e.jsx(Dr,{data:n,error:i,open:c,onToggle:()=>d(f=>!f)}),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(ye,{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((f,v)=>e.jsxs("li",{className:"flex items-baseline justify-between gap-3",children:[e.jsx("span",{className:"min-w-0 truncate",children:Br(f.summary)}),e.jsxs("span",{className:"shrink-0 text-[12px] text-ink-secondary",children:["· ",Vt(f.at)]})]},v))})]})]})}function Fr({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(rs,{size:14,"aria-hidden":"true"})]})]})}function zr(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 bs(t){const[a,n]=p.useState(null);return p.useEffect(()=>{const i=new AbortController;return ae(`/api/bots/${encodeURIComponent(t)}/slack-management`,{signal:i.signal,timeoutMs:1e4}).then(r=>{i.signal.aborted||n({botId:t,url:zr(r)})}).catch(()=>{i.signal.aborted||n({botId:t,url:null})}),()=>i.abort()},[t]),a?.botId===t?a.url:null}const oe="rounded-lg bg-control px-3 py-1.5 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",ze="rounded-md px-2 py-1 text-[13px] text-ink-secondary hover:bg-control hover:text-ink disabled:opacity-50",le=t=>t instanceof Error?t.message:String(t);function vs(t){const a=[],n=(r,l,c)=>{r&&a.push(s(r===1?l: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 i=a.length?a.join(", "):s("memory.upkeep.summary.none");return i.charAt(0).toUpperCase()+i.slice(1)}function Hr(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"),i=Qn(t.path),r=t.path===te?i:t.path===Zn?s("memory.journal.instructions"):t.path.startsWith("memory/log/")?s("memory.journal.log",{file:i}):s("memory.journal.topic",{file:i}),l=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:l(t.added)}):""}):t.kind==="deleted"?s("memory.journal.deleted",{who:n,topic:r}):t.added&&!t.removed?s("memory.journal.added",{who:n,lines:l(t.added),topic:r}):t.removed&&!t.added?s("memory.journal.removed",{who:n,lines:l(t.removed),topic:r}):s("memory.journal.rewrote",{who:n,lines:l(Math.max(t.added,t.removed)),topic:r})}function ks({changed:t,stale:a,busy:n,onReviewed:i}){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:R(oe,"mt-3"),disabled:n,onClick:i,children:s("memory.lendingReviewed")})]})}function _r({bot:t,active:a=!0,onToggle:n}){const{capabilities:i}=be(),[r,l]=p.useState(null),[c,d]=p.useState(null),[o,u]=p.useState(null),[m,f]=p.useState(null),[v,g]=p.useState(null),[b,k]=p.useState(null),[O,y]=p.useState(null),[N,x]=p.useState(!1),[S,L]=p.useState(null),[$,M]=p.useState(""),[A,H]=p.useState(null),[T,h]=p.useState(!1),[I,z]=p.useState(null),[U,q]=p.useState(!1),[Q,re]=p.useState(!1),{state:Y,dispatch:C}=F(),J=Vs(Y.config),[ie,w]=p.useState(!1),[W,P]=p.useState(""),_=async j=>{const[E,Le,Bs]=await Promise.all([st(t.id),he(t.id),kt(t.id).catch(()=>null)]);if(l(E),z(E.lendingReview??null),d(Le),H(Bs),j){const Te=await Ee(t.id,j);u({path:Te.path,text:Te.text,hash:Te.hash,dirty:!1,readOnly:j.startsWith("memory/log/")})}};p.useEffect(()=>{if(!a)return;let j=!1;k(null);const E=o?.dirty===!0;return _(E?void 0:o?.path??te).catch(Le=>{j||k(le(Le))}),()=>{j=!0}},[a,t.id]);const V=async j=>{k(null),f(null);try{const E=await Ee(t.id,j);u({path:E.path,text:E.text,hash:E.hash,dirty:!1,readOnly:j.startsWith("memory/log/")})}catch(E){k(le(E))}},K=async j=>{if(o){x(!0),k(null);try{const E=await at(t.id,o.path,o.text,j);if(!E.ok){f({path:o.path,current:E.current,currentHash:E.currentHash});return}f(null),g(null),u({...o,text:E.doc.text,hash:E.doc.hash,dirty:!1}),l(E.overview),d(await he(t.id))}catch(E){k(le(E))}finally{x(!1)}}},de=()=>{!m||!o||(g(o.text),u({...o,text:m.current,hash:m.currentHash,dirty:!1}),f(null))},ke=async j=>{if(window.confirm(s("memory.confirmDelete",{name:j.name}))){k(null);try{const{overview:E}=await ds(t.id,j.path);l(E),d(await he(t.id)),o?.path===j.path&&u(null)}catch(E){k(le(E))}}},rt=async()=>{const j=Gn($);if(!j){k(s("memory.topicNameError"));return}M(""),await V(`memory/${j}`),u(E=>E&&{...E,dirty:!0,text:E.text||Kr(j)})},Is=async j=>{L(j.id),k(null);try{const E=await ms(t.id,j.id);l(E.overview),d(await he(t.id)),o?.path===j.path&&!o.dirty&&u({...o,text:E.text,hash:E.hash}),y(s("memory.restored",{path:j.path}))}catch(E){k(le(E))}finally{L(null)}},it=async j=>{k(null),y(null);try{await Wn(t.id,j)}catch(E){k(le(E))}},As=()=>{const j=t.memoryUpkeep===!1;C({type:"updateBot",botId:t.id,patch:{memoryUpkeep:j}}),H(E=>E&&{...E,enabled:j})},Ls=async()=>{if(!ie){w(!0),P("");try{const j=await ae("/api/config",{method:"PATCH",body:JSON.stringify({features:{roomMemoryCapture:!J}})});C({type:"configStatus",config:j})}catch(j){P(j instanceof Error?j.message:s("memory.learnFromRooms.error"))}finally{w(!1)}}},Ts=async()=>{h(!0),k(null),y(null);try{const{report:j,overview:E}=await cs(t.id);l(E),d(await he(t.id)),H(await kt(t.id)),o&&!o.dirty&&await V(o.path),y(`${vs(j)}.${j.note?` ${j.note}`:""}`)}catch(j){k(le(j))}finally{h(!1)}},Ms=i.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:Xe(r.workspacePath,Ms)}),e.jsx("button",{type:"button",className:oe,onClick:()=>{it("obsidian")},children:s("memory.openObsidian")}),e.jsxs("button",{type:"button",className:R(oe,"inline-flex items-center gap-1.5"),onClick:()=>{it("folder")},children:[e.jsx(Gt,{size:14}),s("memory.showFileManager")]})]})]}),I&&e.jsx(ks,{changed:I.changed,stale:U,busy:Q,onReviewed:()=>{re(!0),os(t.id,I.token).then(()=>{z(null),q(!1)}).catch(j=>{if(j instanceof Yt&&j.status===409)return q(!0),_();k(le(j))}).finally(()=>re(!1))}}),r&&e.jsx(qr,{index:r.index}),t.memoryEnabled!==!1&&e.jsx(Ur,{enabled:t.memoryUpkeep!==!1,status:A,tidying:T,onToggle:As,onTidy:()=>{Ts()},rooms:{enabled:J,saving:ie,error:W,onToggle:()=>{Ls()}}}),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!==te&&e.jsx("button",{type:"button",className:ze,onClick:()=>{V(te)},children:s("memory.backToIndex")})]}),m&&e.jsx(js,{botName:t.name,busy:N,onReload:de,onOverwrite:()=>{K(m.currentHash)}}),e.jsx("textarea",{className:R(Ye,"mt-2 min-h-[200px] resize-y font-mono text-[13px] leading-relaxed"),value:o.text,readOnly:o.readOnly,placeholder:o.path===te?s("memory.indexPlaceholder"):s("memory.notePlaceholder"),"aria-label":o.path===te?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:()=>{K(o.hash)},disabled:N||!o.dirty,className:oe,children:N?s("memory.saving"):s("memory.save")}),o.dirty&&e.jsx("button",{type:"button",className:ze,disabled:N,onClick:()=>{V(o.path)},children:s("memory.discard")})]}),v!==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:v}),e.jsx("button",{type:"button",className:R(ze,"mt-1"),onClick:()=>g(null),children:s("memory.dismissDraft")})]})]}),r&&e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx(Tt,{title:s("memory.topicFiles"),hint:s("memory.topicFilesHint"),files:r.topics,selected:o?.path,onOpen:j=>{V(j.path)},onDelete:j=>{ke(j)}}),e.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[e.jsx("input",{className:R(Ye,"py-1.5 text-[13px]"),value:$,placeholder:s("memory.newTopicPlaceholder"),"aria-label":s("memory.newTopicLabel"),onChange:j=>M(j.target.value),onKeyDown:j=>{j.key==="Enter"&&rt()}}),e.jsx("button",{type:"button",className:oe,disabled:!$.trim(),onClick:()=>{rt()},children:s("memory.newTopic")})]}),r.logs.length>0&&e.jsx("div",{className:"mt-4",children:e.jsx(Tt,{title:s("memory.dailyLogs"),hint:s("memory.dailyLogsHint"),files:r.logs,selected:o?.path,onOpen:j=>{V(j.path)},onDelete:j=>{ke(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(nt,{rows:c,botName:t.name,reverting:S,onRevert:j=>{Is(j)}})})]}),O&&e.jsx("div",{className:"text-[13px] text-ink-secondary",children:O}),b&&e.jsx("div",{className:"text-[13px] text-danger",children:b})]})}function Kr(t){return`---
2
- title: ${t.replace(/\.md$/,"")}
3
- description:
4
- aliases: []
5
- ---
6
-
7
- `}function Ur({enabled:t,status:a,tidying:n,onToggle:i,onTidy:r,rooms:l}){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(dt,{checked:t,"aria-label":s("memory.upkeep.title"),onClick:i})]}),t&&l&&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")}),l.error&&e.jsx("p",{role:"alert",className:"mt-1 text-[13px] text-danger",children:l.error})]}),e.jsx(dt,{checked:l.enabled,"aria-label":s("memory.learnFromRooms.title"),disabled:l.saving,onClick:l.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:oe,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:Oe(a.lastTidy.at,se()),summary:vs(a.lastTidy).toLowerCase()}):s("memory.upkeep.notTidied"),a?.lastCapture&&$e(a.lastCapture)?` ${s($e(a.lastCapture)===1?"memory.upkeep.lastNoticed.one":"memory.upkeep.lastNoticed.many",{count:$e(a.lastCapture),time:Oe(a.lastCapture.at,se())})}`:""]})]})]})}function qr({index:t}){const a=Vn(t),n=a.level==="over"?"bg-danger":a.level==="near"?"bg-warning":"bg-accent";return e.jsxs("div",{className:R("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:R("text-[12px]",a.level==="over"?"text-danger":"text-ink-secondary"),children:s("memory.capacity.summary",{lines:t.lines,maxLines:t.maxLines,bytes:me(t.bytes),maxBytes:me(t.maxBytes)})})]}),e.jsx(Lt,{label:s("memory.capacity.lines"),share:a.lineShare,fill:n}),e.jsx(Lt,{label:s("memory.capacity.size"),share:a.byteShare,fill:n}),e.jsx("p",{className:R("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:me(t.bytes),maxBytes:me(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:me(t.bytes),maxBytes:me(t.maxBytes),maxLoaded:t.maxLines})})]})}function Lt({label:t,share:a,fill:n}){const i=`${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:R("h-full rounded-full",n),style:{width:i}})})]})}function js({botName:t,busy:a,onReload:n,onOverwrite:i}){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:oe,disabled:a,onClick:n,children:s("memory.reload")}),e.jsx("button",{type:"button",className:oe,disabled:a,onClick:i,children:s("memory.overwrite")})]})]})}function Tt({title:t,hint:a,files:n,selected:i,onOpen:r,onDelete:l}){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:R("flex items-center gap-2 border-b border-hairline/40 px-3 py-2 last:border-b-0",i===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(Ie,{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:[me(c.bytes)," · ",Oe(c.modifiedAt,se())]})]}),e.jsx("button",{type:"button",onClick:()=>l(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(Jt,{size:14})})]},c.path))})]})}function nt({rows:t,botName:a,reverting:n,onRevert:i,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(l=>{const c=Yn(l),d=Jn(l);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:Hr(l,a)})," · ",e.jsx("span",{className:"text-ink-secondary",children:Oe(l.at,se(),r)}),c&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"text-ink-secondary",children:d?s(d,l.threadTitle?{title:l.threadTitle}:void 0):c})]})]}),l.canRevert?e.jsxs("button",{type:"button",disabled:n!==null,onClick:()=>i(l),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(Gs,{size:12}),n===l.id?s("memory.undoing"):s("memory.undo")]}):e.jsx("span",{className:"shrink-0 text-[12px] text-ink-secondary",title:l.revertUnavailableReason,children:s("memory.cantUndo")})]}),l.diff&&e.jsxs("details",{className:"mt-1",children:[e.jsxs("summary",{className:"cursor-pointer text-[12px] text-ink-secondary",children:["+",l.added," −",l.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:l.diff})]})]},l.id)})}):e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("memory.loading")})}function Wr({bot:t,rows:a,refreshError:n,onRollback:i,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 l=[...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")}),l.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:Vt(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:()=>i(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 Vr({bot:t,bare:a=!1}){const{state:n,dispatch:i}=F(),r=Ys(t),l=n.instances.find(c=>c.instanceId===t.modelSelection.instanceId);return r.turns===0?e.jsx("div",{className:R(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:()=>i({type:"toggleAppSettings",open:!0,section:"usage"}),className:"text-[12px] text-ink-secondary hover:text-ink",children:[s("usage.allBots")," ",e.jsx(ye,{size:14,"aria-hidden":"true",className:"inline align-[-2px] rtl:-scale-x-100"})]})]}),e.jsxs("div",{className:R("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:Js(r)}),e.jsx("div",{className:"mt-0.5 tabular-nums text-ink",title:Xs(r),children:Qs(Zs(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:mt(r.costUsd)?ea(r.costUsd):"—"})]})]}),e.jsx("div",{className:"mt-2 text-[12px] text-ink-secondary",children:mt(r.costUsd)?s("usage.costLine",{caption:ta(l?.snapshot.billing)}):s("usage.bot.unpriced")})]})}const Gr=[["bot","botPanel.avatar.tabBot"],["generate","botPanel.avatar.tabGenerate"],["upload","botPanel.avatar.tabUpload"]],Yr=["circle","rounded","square"],Jr={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"},Zr=t=>{const a=Qr[t];return a?s(a):t};function Xr({bot:t,activeState:a,onPatch:n,onClose:i}){const r=sa(t,n),{fileRef:l,crop:c,uploading:d,generating:o,busy:u,error:m,upload:f,removeImage:v,generate:g}=r,b=c!=="mascot"&&!!t.avatarUrl,[k,O]=p.useState(b?"upload":"bot"),y=p.useRef(null);p.useEffect(()=>{y.current?.querySelector('[aria-selected="true"]')?.focus()},[]);const N=h=>n(c==="mascot"?h:{...h,avatarCrop:"mascot"}),x=t.mascotBody??"cursor",S=In(),L=An(t.mascotBody,t.color,S),[$,M]=p.useState(()=>!!S||bt(x)||!!(t.mascotExpression&&t.mascotExpression!=="idle")),A=S&&L!==x&&bt(L)?De(L):null,H=(h,I)=>e.jsx("button",{type:"button",disabled:u,"aria-pressed":!b&&x===h,"aria-label":s("mascot.useBody",{name:I}),title:I,onClick:()=>N({mascotBody:h}),className:R("flex h-[58px] items-center justify-center rounded-xl disabled:opacity-50",!b&&x===h?"bg-ink/[0.08] ring-[1.5px] ring-inset ring-ink/25":"hover:bg-ink/[0.05]"),children:e.jsx(zn,{color:t.color,faceColor:t.mascotFaceColor,bodyId:h,size:40,animated:!1,trackPointer:!1})},h),T=h=>{h.key==="Escape"&&(h.preventDefault(),h.stopPropagation(),i())};return e.jsxs("div",{role:"dialog","aria-label":s("botPanel.avatar.edit"),"data-panel-avatar-editor":!0,onKeyDown:T,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:y,className:"flex items-center gap-0.5 border-b border-ink/[0.06] p-2",children:[Gr.map(([h,I])=>e.jsx("button",{type:"button",role:"tab","aria-selected":k===h,"data-avatar-tab":h,onClick:()=>O(h),className:R("rounded-lg px-[11px] py-[5px] text-[13px]",k===h?"bg-ink/[0.08] font-medium text-ink":"text-ink-secondary hover:text-ink"),children:s(I)},h)),e.jsx("button",{type:"button","data-avatar-reset":!0,disabled:u,onClick:()=>n(aa),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:[k==="bot"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-5 gap-1.5",children:Ln.map(h=>H(h,De(h)))}),e.jsx("div",{className:"flex flex-wrap justify-center gap-2 px-1 pb-1 pt-3.5",children:na.map(h=>e.jsx("button",{type:"button",disabled:u,"aria-pressed":t.color===h,"aria-label":s("mascot.useColor",{color:Bn(h)}),title:s(Mn[h]),onClick:()=>N({color:h}),className:R("size-6 rounded-full disabled:opacity-50",t.color===h&&"ring-2 ring-ink/80 ring-offset-2 ring-offset-menu"),style:{background:Tn(h)}},h))}),e.jsx(Xn,{bot:t,disabled:u,onPatch:N}),e.jsxs("button",{type:"button","data-avatar-more":!0,"aria-expanded":$,onClick:()=>M(h=>!h),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(fe,{size:13,"aria-hidden":"true",className:R("transition-transform",$&&"rotate-180")})]}),$&&e.jsxs("div",{"data-avatar-more-looks":!0,children:[Dn.map(h=>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:vt(h)}),h===S&&A&&e.jsx("span",{"data-avatar-costume":!0,children:s("botPanel.avatar.costume",{name:A,skin:vt(h)})})]}),e.jsx("div",{className:"grid grid-cols-5 gap-1.5","data-festival-bodies":h,children:$n[h].bodies.map(I=>H(I,De(I)))})]},h)),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")}),Fn.map(h=>e.jsx("button",{type:"button",disabled:u,"data-avatar-face":h,"aria-pressed":a===h,onClick:()=>N({mascotExpression:h}),className:R("rounded-full px-2.5 py-1 text-[12px] disabled:opacity-50",a===h?"bg-ink/[0.15] text-ink":"bg-ink/[0.04] text-ink-secondary hover:text-ink"),children:Zr(h)},h))]})]})]}),k==="generate"&&e.jsx("div",{className:"[&>div:first-child]:mt-0 [&>div:first-child]:border-0 [&>div:first-child]:pt-0",children:e.jsx(ra,{botLabel:t.title||t.name,disabled:d,generating:o,onGenerate:g})}),k==="upload"&&e.jsxs(e.Fragment,{children:[e.jsx(ia,{busy:u,onUpload:h=>{f(h)}}),b&&e.jsx(la,{bot:t,disabled:u,onPatch:n}),e.jsx("input",{ref:l,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"sr-only",onChange:h=>{f(h.target.files?.[0])}}),e.jsxs("button",{type:"button","data-avatar-drop":!0,disabled:u,onClick:()=>l.current?.click(),onDragOver:h=>h.preventDefault(),onDrop:h=>{h.preventDefault(),f(h.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(Ce,{size:22,className:"animate-spin"}):e.jsx(oa,{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(Se,{attr:"data-avatar-crop",label:s("botPanel.avatar.shape"),value:b?c:null,onChange:h=>n({avatarCrop:h}),options:Yr.map(h=>({value:h,label:s(Jr[h]),disabled:u||!t.avatarUrl}))}),t.avatarUrl&&e.jsx("button",{type:"button",onClick:v,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(Jt,{size:14})})]}),!b&&e.jsx("p",{className:"mt-2 text-[12px] text-ink-tertiary",children:s("botPanel.avatar.uploadHint")})]}),m&&e.jsx("div",{role:"alert",className:"mt-3 text-[12px] text-danger",children:m})]})]})}const ei=()=>s("place.off");function ws(t){const{dispatch:a}=F();return(n="computer")=>{ma(t.id,n),a({type:"toggleSettings",open:!1}),a({type:"toggleComputer",open:!0})}}function ti(t,a){const[n,i]=p.useState(null);return p.useEffect(()=>{if(!a)return;let r=!1;return ae(`/api/browser-sites?bot=${encodeURIComponent(t.id)}`).then(l=>{r||i({botId:t.id,count:l.sites?.length??0})}).catch(()=>{}),()=>{r=!0}},[t.id,a]),n?.botId===t.id?n.count:null}function Ns(t){const{state:a}=F(),{capabilities:n}=be(),i=n.host?.platform??"other",r=ua(t),l=t.computer??"auto",c=a.config?.browserEngine?.myChrome===!0&&(a.config?.browserProfiles??[]).some(g=>g.id===t.browserProfile&&g.browser==="chrome"),d=g=>g==="browser"&&c?s("settings.profiles.myChrome"):ha(g,i),o=g=>{const{view:b,reachable:k}=r[g];return{value:g,label:d(g),disabled:!k,hint:!k||xa(b)?b.line:void 0}},u=[{value:"auto",label:s("computer.simple.dest.letItChoose")},...r.local.policy?[o("local")]:[],...r.browser.policy||l==="browser"?[o("browser")]:[],...r.cloud.policy?[o("cloud")]:[],...r.vm.policy||l==="vm"?[o("vm")]:[],...l==="off"?[{value:l,label:ei(),disabled:!0}]:[]],m=t.tasks?.find(g=>g.threadId===t.threadId)?.surface,f=m&&m!==l?d(m):null,v=u.find(g=>g.value===l)?.label??(l==="auto"||l==="off"?void 0:d(l));return{options:u,current:l,currentLabel:v,usingNow:f}}function si({bot:t,derived:a}){const{dispatch:n}=F(),{options:i,current:r,usingNow:l}=Ns(t),[c,d]=p.useState(null),{patch:o,approvalMode:u}=a,m=f=>{if(!(f===r||f==="off")){if(f==="local"&&u==="auto"){d({botId:t.id,patch:{computer:"local",acknowledgeLocalAuto:!0}});return}o(f==="browser"?{computer:"browser",browser:!0}:{computer:f==="auto"?null:f})}};return e.jsxs(e.Fragment,{children:[e.jsx(D,{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:i.map(f=>e.jsx(Ue,{"data-panel-choice":f.value,title:f.label,hint:f.hint,checked:r===f.value,disabled:f.disabled,onClick:()=>m(f.value)},f.value))})}),l&&e.jsx("p",{"data-panel-using-now":!0,className:"mx-1 text-[13px] text-ink-secondary",children:s("computer.simple.usingNow",{place:l})}),e.jsx(pa,{open:c!==null,onCancel:()=>d(null),onConfirm:()=>{const f=c;d(null),f&&n({type:"updateBot",botId:f.botId,patch:f.patch})}})]})}function ai({bot:t,derived:a,onOpen:n}){const i=ws(t),r=et(),{browserEnabled:l}=a,c=ti(t,l&&t.computer!=="off"&&r!==!1),{currentLabel:d,usingNow:o}=Ns(t),u=s("computer.screenOf",{name:t.name}),m=[...t.messages].reverse().find(v=>v.kind==="screen"&&(v.hasImage||v.png)),f=m?ca({threadId:t.threadId,messageId:m.id},m.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:()=>i(),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:[f?e.jsx("img",{src:f,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(Ge,{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(Ge,{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(St,{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(D,{anchor:"where",children:[e.jsx(ee,{"data-panel-page":"where",icon:St,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(ee,{"data-panel-page":"browser",icon:da,title:s("settings.sites.title"),value:c??void 0,onClick:()=>n("browser")})]})]})}const ni=3,Mt="[&_.font-semibold]:font-medium [&_time]:text-[12px] [&_time]:text-ink-tertiary [&_span.bg-accent]:size-2",ri=8,ii=200,xe=new Map,He=new Set,Bt=t=>`${t.threadId}@${es(t)}`;function li(t,a){const[,n]=p.useState(0),r=a.filter(d=>d.threadId!==t.threadId).map(Bt).filter(d=>!xe.has(d)&&!He.has(d)).join(",");p.useEffect(()=>{if(r)for(const d of r.split(",")){He.add(d);const o=d.slice(0,d.lastIndexOf("@"));ae(`/api/threads/${encodeURIComponent(o)}/messages?limit=${ri}`,{background:!0}).then(u=>{xe.set(d,We({messages:u.messages??[],activeLeafId:u.activeLeafId??void 0})),xe.size>ii&&xe.delete(xe.keys().next().value),n(m=>m+1)}).catch(()=>{}).finally(()=>He.delete(d))}},[r]);const l=We(t),c=new Map(a.map(d=>[d.threadId,Bt(d)]));return d=>d===t.threadId?l:xe.get(c.get(d)??"")}function oi({bot:t}){const{state:a,dispatch:n}=F(),i=fa(),r=!Qt(Zt,!0),[l,c]=p.useState(""),[d,o]=p.useState(!1),[u,m]=p.useState(!1),[f,v]=p.useState(!1),g=ga(a.config),b=p.useMemo(()=>{const{onRename:w,onRegenerateTitle:W,onDelete:P,onMove:_,onPin:V,onArchive:K}=ya(t.id,n,g);return{onRename:w,onRegenerateTitle:W,onDelete:P,onMove:_,onPin:V,onArchive:K}},[t.id,n,g]),k=ba(t),O=t.tasks??[{threadId:t.threadId,title:s("task.newShort"),createdAt:0}],y=(k?va({...t,tasks:O},k):O).filter(w=>!w.routineRunId).map(w=>{const W=qe(t,w.threadId);return{...w,busy:W.busy,activity:W.activity,waitingForTeammates:W.waitingForTeammates,turnStartedAt:W.turnStartedAt??void 0,queued:!!a.pendingQueued[w.threadId]?.length}}),N=w=>!!(w.botApi&&!w.channelOwner),x=y.filter(w=>N(w)&&!je(w)).length,S=!!t.hideChannelGuests,L=ut(y.filter(w=>(!je(w)||w.threadId===t.threadId)&&!(S&&N(w)&&w.threadId!==t.threadId))),$=ut(y.filter(w=>je(w)&&w.threadId!==t.threadId)),M=l.trim(),A=L.filter((w,W)=>W<ni||w.threadId===t.threadId),H=li(t,[...M||u?L:A,...f?$:[]]),T=w=>{const W=H(w);return W?wa(qe(t,w),W,a.instances,!1):void 0},h=ka(L,M),I=M?[...h,...L.filter(w=>!h.includes(w)&&T(w.threadId)?.toLowerCase().includes(M.toLowerCase()))]:L,z=M?I:u?L:A,U=L.length-A.length,q=t.projects?.find(w=>w.id===t.tasks?.find(W=>W.threadId===t.threadId)?.projectId),Q=()=>{r&&n({type:"toggleSettings",open:!1})},re=w=>{w.threadId!==t.threadId&&Ca(n,t,w.threadId,!1),Q()},Y=()=>{n({type:"newTask",botId:t.id,...q?{projectId:q.id}:{}}),Q()},C=()=>{c(""),o(!1)},J=L.length>=2||d||L.some(w=>w.threadId===t.threadId&&je(w)),ie=w=>e.jsx("div",{role:"listitem","data-conversation":w.threadId,children:e.jsx(Na,{panel:!0,preview:T(w.threadId),task:w,ownerId:t.id,current:w.threadId===t.threadId,folders:t.projects,now:Sa(es(w),i),locale:se(),onSelect:re,...b})},w.threadId);return e.jsxs("section",{"data-panel-card":"conversations","aria-label":s("botPanel.conversations.title"),children:[e.jsx(Pe,{action:J&&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?C():o(!0),className:R("-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(Je,{size:14,"aria-hidden":"true"})}),children:s("botPanel.conversations.title")}),e.jsx("div",{className:R("flex items-center gap-2",J&&"mb-2"),children:t.yourAccess!=="view"&&k!=="team"&&e.jsxs("button",{type:"button","data-conversations-new":!0,"aria-label":s("botPanel.conversations.new"),onClick:Y,className:R(Xt,"flex-1"),children:[e.jsx(ja,{size:15,"aria-hidden":"true",className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"truncate",children:s("botPanel.conversations.new")})]})}),x>0&&t.yourAccess!=="view"&&e.jsx("button",{type:"button","data-conversations-guests":!0,"aria-pressed":!S,onClick:()=>{ae(`/api/bots/${t.id}`,{method:"PATCH",body:JSON.stringify({hideChannelGuests:!S})}).catch(()=>{})},className:"mb-2 w-full rounded-[6px] px-2 py-1 text-start text-[12px] text-ink-secondary hover:bg-ink/[0.06] hover:text-ink",children:S?B(`Hiện chat khách Telegram/Zalo (${x})`,`Show Telegram/Zalo guest chats (${x})`):B(`Ẩn chat khách Telegram/Zalo (${x})`,`Hide Telegram/Zalo guest chats (${x})`)}),t.yourAccess!=="view"&&e.jsx(Un,{}),J&&d&&e.jsx("input",{autoFocus:!0,type:"search","data-conversations-query":!0,value:l,onChange:w=>c(w.target.value),onKeyDown:w=>{w.key==="Escape"&&(w.preventDefault(),w.stopPropagation(),C())},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"}),J&&e.jsx("div",{role:"list","aria-label":s("botPanel.conversations.title"),className:R("flex flex-col gap-px",Mt),children:z.map(ie)}),J&&M&&z.length===0&&e.jsx("p",{className:"px-3 py-3 text-[13px] text-ink-secondary",children:s("task.noMatch",{query:M})}),J&&!M&&U>0&&e.jsxs("button",{type:"button","data-conversations-more":!0,"aria-expanded":u,onClick:()=>m(w=>!w),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(pt,{size:14,"aria-hidden":"true"}):e.jsx(fe,{size:14,"aria-hidden":"true"}),u?s("botPanel.conversations.showFewer"):s("botPanel.conversations.showMore",{count:U})]}),!M&&$.length>0&&e.jsxs("button",{type:"button","data-conversations-archived":!0,"aria-expanded":f,onClick:()=>v(w=>!w),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:[f?e.jsx(pt,{size:14,"aria-hidden":"true"}):e.jsx(fe,{size:14,"aria-hidden":"true"}),s("task.archivedList",{count:$.length})]}),!M&&f&&$.length>0&&e.jsx("div",{role:"list","aria-label":s("task.archivedList",{count:$.length}),className:R("flex flex-col gap-px",Mt),children:$.map(ie)})]})}function ci({bot:t}){const{dispatch:a}=F();return Kt()||!t.defaultBot?null:e.jsx(D,{label:s("botPanel.tryAsking"),anchor:"try-asking",children:Pa.map(i=>e.jsx("button",{type:"button","data-panel-ask":i,onClick:()=>a({type:"send",botId:t.id,text:s(i),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(i)})},i))})}const di=["find","start-fresh","usage","activity","inspector"];function mi({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:R(Z,"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:R("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:R("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(ye,{size:15,"aria-hidden":"true",className:"shrink-0 text-ink-tertiary rtl:-scale-x-100"})]})}function ui({bot:t,derived:a,onOpen:n}){const{items:i}=Oa(t),{dispatch:r}=F(),l=a.botRoutines.filter(d=>d.enabled).length,c=di.flatMap(d=>i.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:R(Z,"rounded-[8px]"),children:e.jsx(Ea,{bot:t,contained:!0,threadId:t.threadId,label:e.jsxs("span",{className:"flex shrink-0 items-center gap-2.5",children:[e.jsx(X,{icon:Ze}),e.jsx(ne,{title:s("model.simple.model")})]})})})}),e.jsx(oi,{bot:t}),e.jsx(ci,{bot:t}),c.length>0&&e.jsxs("section",{"data-panel-card":"conversation",children:[e.jsx(Pe,{children:s("botPanel.section.conversation")}),c.map(d=>e.jsx(mi,{item:d},d.key))]}),a.botRoutines.length===0?e.jsxs("section",{"data-panel-empty":"routines",children:[e.jsx(Pe,{action:e.jsx(Ra,{"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:R(Xt,"w-full"),children:[e.jsx(Sr,{size:15,"aria-hidden":"true",className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"truncate",children:s("botPanel.routines.add")})]})]}):e.jsx(D,{label:s("botSettings.simple.routines"),anchor:"routines",children:e.jsx(ee,{"data-panel-page":"routines",icon:Ia,title:s("botSettings.simple.routines"),value:l>0?s("botPanel.routinesOn",{count:l}):s("botPanel.none"),onClick:()=>n("routines")})})]})}const Ss=/^\s*[-*]\s+(.+?)\s*$/;function pi(t){return t.split(`
8
- `).flatMap((a,n)=>{const i=Ss.exec(a)?.[1];return i?[{line:n,text:i}]:[]})}function xi(t,a){const n=t.split(`
9
- `);return Ss.test(n[a]??"")?(n.splice(a,1),n.join(`
10
- `)):t}function hi(t,a){const n=t.replace(/\s+$/,""),i=`- ${a.trim().replace(/\s*\n\s*/g," ")}`;return n?`${n}
11
- ${i}
12
- `:`${i}
13
- `}function Cs(t){return t.flatMap(a=>{const n=pi(a.text).map(r=>({path:a.path,...r}));if(n.length||a.path===te)return n;const i=a.text.split(`
14
- `).map(r=>r.replace(/^#+\s*/,"").trim()).filter(Boolean).join(" ");return i?[{path:a.path,line:null,text:i}]:[]})}async function fi(t,a){if(!a)return[await Ee(t,te)];const n=await st(t,!0);return Promise.all([te,...n.topics.map(i=>i.path)].map(i=>Ee(t,i,!0)))}function Ps(t){const a=!!F().state.config?.team,[n,i]=p.useState({botId:t.id,docs:null,error:!1}),r=t.memoryEnabled!==!1,l=async(o,u)=>{try{const m=await fi(o,a);u?.()||i({botId:o,docs:m,error:!1})}catch{u?.()||i({botId:o,docs:null,error:!0})}},c=!!t.busy;p.useEffect(()=>{if(!r)return;let o=!1;return l(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=>i(u=>({botId:t.id,docs:(u.botId===t.id?u.docs??[]:[]).map(m=>m.path===o.path?o:m),error:!1})),reload:()=>l(t.id)}}function gi(t,a=We(t)){const n=[],i=[],r=new Set;for(const u of[...a].reverse()){const m=u.publishedPage;m?.state==="live"&&m.url&&!r.has(m.url)&&(r.add(m.url),n.push({messageId:u.id,title:m.title||m.url,url:m.url})),u.kind==="app"&&u.app?.doc&&i.push({messageId:u.id,title:u.app.title})}const l=fr(t),c=[],d=new Set;for(const u of l.values())d.has(u.file.path)||(d.add(u.file.path),c.push(u));const o=gr(t).filter(u=>!l.has(u));return{pages:n,apps:i,shared:c,unshared:o}}const yi=t=>t.slice(Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"))+1);function Os({bot:t,onOpen:a}){const{dispatch:n}=F(),{capabilities:i}=be(),r=Aa(),l=!Qt(Zt,!0),c=us(t),d=Ps(t),{pages:o,apps:u,shared:m,unshared:f}=p.useMemo(()=>gi(t),[t]),v=y=>{n({type:"focusMessage",threadId:t.threadId,messageId:y}),l&&n({type:"toggleSettings",open:!1})},g=c.skills.filter(ps).length,b=d.docs?Cs(d.docs).length:null,k=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}),O=e.jsxs(D,{anchor:"keeps",children:[e.jsx(ee,{"data-panel-page":"memory",icon:Ut,title:s("botPanel.memoryRow"),value:k,onClick:()=>a("memory")}),e.jsx(ee,{"data-panel-page":"skills",icon:La,title:s("botSettings.simple.skills"),value:c.loading?void 0:g>0?g:s("botPanel.none"),onClick:()=>a("skills")}),e.jsx(ee,{"data-panel-page":"folder",icon:Ta,title:s("computer.files.folder"),value:t.cwd?Xe(t.cwd,i.host?.homeDir):s("botPanel.folder.private"),onClick:()=>a("folder")})]});return o.length+u.length+m.length+f.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")}),O]}):e.jsxs("div",{"data-panel-tabpanel":"library",children:[o.length>0&&e.jsx(D,{label:s("botPanel.library.pages"),anchor:"pages",children:o.map(y=>e.jsx(ee,{"data-panel-row":"page",icon:Ma,title:e.jsx("span",{className:"block truncate",children:y.title}),hint:e.jsx("span",{className:"block truncate",children:y.url}),onClick:()=>r(y.url)},y.url))}),u.length>0&&e.jsx(D,{label:s("botPanel.library.apps"),anchor:"apps",children:u.map(y=>e.jsx(ee,{"data-panel-row":"app",icon:ts,title:e.jsx("span",{className:"block truncate",children:y.title}),onClick:()=>v(y.messageId)},y.messageId))}),m.length+f.length>0&&e.jsxs("section",{"data-panel-card":"files",children:[e.jsx(Pe,{children:s("botPanel.library.files")}),e.jsxs("ul",{className:"flex flex-col gap-1.5",children:[m.map(y=>e.jsx("li",{className:"min-w-0",children:e.jsx(Ba,{file:y.file,message:y.message,linked:y.file.linked,className:"w-full max-w-none"})},`${y.message.messageId}:${y.file.path}`)),f.map(y=>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(Ie,{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:yi(y)}),e.jsx("span",{className:"shrink-0 text-[11px] text-ink-tertiary",children:s("computer.files.notShared")})]},y))]})]}),e.jsx("p",{className:"mt-3 text-center text-[12px] text-ink-tertiary",children:s("botPanel.library.scope")}),O]})}function bi({bot:t,browserEnabled:a,onOpenBrowser:n}){const{state:i}=F(),r=et(),l=t.browserProfile??"",c=(i.config?.browserProfiles??[]).find(m=>m.id===l),d=l==="guest",o=c?.browser==="chrome"&&i.config?.browserEngine?.myChrome===!0,u=l&&!d?i.bots.filter(m=>m.browserProfile===l).map(m=>m.name):[t.name];return e.jsx(D,{anchor:"logins",children:a?d?e.jsx(G,{children:s("settings.profiles.temporaryHint")}):o?e.jsx(G,{children:s("settings.profiles.myChromeHint")}):e.jsxs(e.Fragment,{children:[r!==!1&&(l===""||c)&&e.jsx(ue,{children:e.jsx(wr,{bare:!0,target:{bot:t.id},sharedBy:u,disabled:!!t.busy},`${t.id}:${l}`)}),e.jsx(G,{children:s("botSettings.simple.loginsHint",{name:t.name})}),e.jsx(pe,{"data-panel-action":"add-login",icon:ve,onClick:n,children:s("botSettings.simple.addLogin")})]}):e.jsx(G,{children:s("botSettings.simple.loginsOff",{name:t.name})})})}const vi=[["all",()=>B("Tất cả","All")],["added",()=>B("Bot đang có","On this bot")],["more",()=>B("Chưa thêm","Not added")]],ki=t=>({bundled:B("Có sẵn","Built in"),library:B("Đã tải về","Downloaded"),imported:B("Từ máy tính","From this computer")})[t],_e="inline-flex shrink-0 items-center gap-1.5 rounded-lg border border-hairline/60 bg-raised px-3 py-1.5 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50";async function Dt(t,a){const n=await fetch(t,a===void 0?void 0:{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(a)}),i=await n.json().catch(()=>({}));if(!n.ok)throw new Error(i.error??B(`Lỗi ${n.status}`,`Error ${n.status}`));return i.skills??[]}function ji({botId:t,botName:a,onClose:n,onOpenSettings:i}){const[r,l]=p.useState(null),[c,d]=p.useState(""),[o,u]=p.useState("all"),[m,f]=p.useState(""),[v,g]=p.useState(""),b=`/api/limix/skill-store/${encodeURIComponent(t)}`;p.useEffect(()=>{let x=!1;return Dt(b).then(S=>{x||l(S)}).catch(S=>{x||(l([]),g(S.message))}),()=>{x=!0}},[b]),p.useEffect(()=>{const x=S=>{S.key==="Escape"&&n()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[n]);const k=p.useMemo(()=>{const x=c.trim().toLowerCase();return(r??[]).filter(S=>(o==="all"||(o==="added"?S.added:!S.added))&&(!x||`${S.name} ${S.description}`.toLowerCase().includes(x)))},[r,c,o]),O=async(x,S)=>{if(!m){f(x.name),g("");try{l(await Dt(b,{name:x.name,kind:x.kind,add:S}))}catch(L){g(L instanceof Error?L.message:B("Không đổi được kĩ năng này.","Couldn't change this skill."))}finally{f("")}}},y=(r??[]).filter(x=>x.added).length,N=e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-6",onMouseDown:x=>x.stopPropagation(),children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"limix-skill-store-title",className:"flex max-h-full w-full max-w-[640px] flex-col rounded-2xl border border-hairline/50 bg-panel shadow-2xl",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 px-6 pb-3 pt-5",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"limix-skill-store-title",className:"text-[17px] font-semibold text-ink",children:B("Kho Kĩ Năng (Skills)","Skills Store")}),e.jsx("p",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:B(`Chọn kĩ năng riêng cho ${a}. Chỉ những kĩ năng được thêm mới nằm trong lời nhắc của bot, nên bot không bị quá tải. Gõ /tên-kĩ-năng trong chat để gọi.`,`Pick skills just for ${a}. Only added skills go into the bot's prompt, so it never gets overloaded. Type /skill-name in chat to call one.`)})]}),e.jsx("button",{type:"button",onClick:n,"aria-label":B("Đóng","Close"),className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised hover:text-ink",children:e.jsx(Qe,{size:16})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-6 pb-3",children:[e.jsxs("label",{className:"flex min-w-[200px] flex-1 items-center gap-2 rounded-lg border border-hairline/40 bg-inset px-3 py-2",children:[e.jsx(Je,{size:14,className:"text-ink-tertiary"}),e.jsx("input",{value:c,onChange:x=>d(x.target.value),placeholder:B("Tìm kĩ năng…","Search skills…"),"aria-label":B("Tìm kĩ năng","Search skills"),className:"w-full bg-transparent text-[14px] text-ink placeholder:text-ink-secondary focus:outline-none"})]}),e.jsx("div",{className:"flex gap-1",role:"tablist","aria-label":B("Lọc kĩ năng","Filter skills"),children:vi.map(([x,S])=>e.jsxs("button",{type:"button",role:"tab","aria-selected":o===x,onClick:()=>u(x),className:`rounded-lg px-2.5 py-1.5 text-[13px] ${o===x?"bg-raised text-ink":"text-ink-secondary hover:bg-raised"}`,children:[S(),x==="added"&&r?` ${y}`:""]},x))})]}),v&&e.jsx("p",{role:"alert",className:"mx-6 mb-2 rounded-lg bg-danger/10 px-3 py-2 text-[12px] text-danger",children:v}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6",children:r===null?e.jsxs("p",{className:"flex items-center gap-2 py-6 text-[13px] text-ink-secondary",children:[e.jsx(Ce,{size:14,className:"animate-spin"}),B("Đang tải kho…","Loading the store…")]}):k.length===0?e.jsx("p",{className:"py-6 text-[13px] text-ink-secondary",children:r.length===0?B("Kho chưa có kĩ năng nào.","The store has no skills yet."):B("Không có kĩ năng khớp.","No matching skills.")}):e.jsx("ul",{className:"flex flex-col divide-y divide-hairline/40 rounded-xl border border-hairline/40",children:k.map(x=>e.jsxs("li",{className:"flex items-start gap-3 px-3 py-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsx("span",{className:"font-mono text-[13px] text-ink",children:x.name}),e.jsx("span",{className:"text-[12px] text-ink-tertiary",children:x.core?B("Kĩ năng gốc","Core skill"):ki(x.kind)}),x.warnings>0&&e.jsxs("span",{className:"text-[12px] text-warning",children:[x.warnings," ",B("cảnh báo","warnings")]})]}),e.jsx("p",{className:"mt-0.5 line-clamp-2 text-[12px] leading-relaxed text-ink-secondary",children:x.description})]}),x.core?e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 px-1 py-1.5 text-[12px] text-ink-secondary",children:[e.jsx(lt,{size:14}),B("Luôn bật","Always on")]}):x.added?e.jsxs("button",{type:"button",className:_e,disabled:!!m,onClick:()=>{O(x,!1)},"aria-label":B(`Bỏ ${x.name} khỏi bot`,`Remove ${x.name} from this bot`),children:[m===x.name?e.jsx(Ce,{size:14,className:"animate-spin"}):e.jsx(lt,{size:14}),B("Đã thêm","Added")]}):e.jsxs("button",{type:"button",className:_e,disabled:!!m||!x.ready,onClick:()=>{O(x,!0)},"aria-label":B(`Thêm ${x.name} cho bot`,`Add ${x.name} to this bot`),children:[m===x.name?e.jsx(Ce,{size:14,className:"animate-spin"}):e.jsx(ve,{size:14}),B("Thêm","Add")]})]},`${x.kind}:${x.name}`))})}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-6 pb-5 pt-3",children:[e.jsx("p",{className:"text-[12px] text-ink-tertiary",children:B('Bấm "Đã thêm" để bỏ kĩ năng khỏi bot này.','Press "Added" to remove a skill from this bot.')}),e.jsx("button",{type:"button",className:_e,onClick:i,children:B("Tải thêm kĩ năng","Get more skills")})]})]})});return typeof document>"u"?N:is.createPortal(N,document.body)}const wi=5,Ni={instanceId:"",model:""},Es=(t,a)=>`${t}\0${a}`,Si=new Set;function $t({bot:t,current:a,exclude:n,onPick:i,label:r,title:l,buttonRef:c,className:d,children:o,...u}){const{state:m,dispatch:f,refreshInstances:v,refreshModels:g}=F(),[b,k]=p.useState(!1),[O,y]=p.useState(""),[N,x]=p.useState(()=>new Set),[S,L]=p.useState(!1),[$,M]=p.useState(null),[A,H]=p.useState(null),T=p.useRef(null),h=c??T,I=p.useRef(null),z=p.useRef(null),U=p.useRef(!1),q=p.useId(),Q=qn(b),re=p.useRef({contains:P=>[h.current,I.current].some(_=>_?.contains(P))});_a(b,re,()=>k(!1)),p.useLayoutEffect(()=>{if(!b)return;const P=_=>{if(_?.type==="scroll"&&_.target instanceof Node&&I.current?.contains(_.target))return;const V=h.current?.getBoundingClientRect(),K=I.current;!V||!K||H(de=>qa(V,{width:xt,height:K.offsetHeight},{width:window.innerWidth,height:window.innerHeight},de??void 0))};return P(),window.addEventListener("resize",P),window.addEventListener("scroll",P,!0),()=>{window.removeEventListener("resize",P),window.removeEventListener("scroll",P,!0)}},[b,h]),p.useEffect(()=>{if(!b||!A||!U.current)return;U.current=!1;const P=I.current;(P?.querySelector("[data-menu-search]")??P?.querySelector("[data-current-model]")??P?.querySelector("[data-menu-row]:not(:disabled)")??P)?.focus({preventScroll:!0})},[b,A]);const Y=P=>{k(!1),P&&h.current?.focus({preventScroll:!0})},C=()=>{y(""),x(new Set),H(null),U.current=!0,k(!0),L(!0),v().catch(()=>{}).finally(()=>L(!1))},J=P=>{$||(M(P.instanceId),g(P.instanceId).catch(()=>{}).finally(()=>M(null)))},ie=()=>{Y(!1),f({type:"toggleAppSettings",open:!0,section:"engines"})},w=()=>{const P=Va(m.instances,a?.instanceId).flatMap(K=>{const de=K.models.options.filter(ke=>!n.has(Es(K.instanceId,ke.id)));return de.length===K.models.options.length?[K]:de.length?[{...K,models:{...K.models,options:de}}]:[]}),_=Ga({instances:m.instances,listed:P,selection:a??Ni,bot:{name:t.name,selection:t.modelSelection},query:O,expanded:N,probing:Si,loading:S,refreshing:$}),V=_.groups.map(K=>K.instance.instanceId===t.modelSelection.instanceId?{...K,note:s("botPanel.backups.sameAccount")}:K);return{..._,groups:V,...a?{}:{current:null}}},W=P=>{if(!(P.nativeEvent.isComposing||P.defaultPrevented)){if(P.key!=="Escape")return Wa(P,{query:O,typed:z,close:()=>Y(!0)});P.preventDefault(),P.stopPropagation(),O?y(""):Y(!0)}};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:h,type:"button",...u,"aria-label":r,title:l,"aria-haspopup":"dialog","aria-expanded":b,"aria-controls":b?q:void 0,onClick:()=>b?Y(!1):C(),onKeyDown:P=>{P.key==="Escape"&&b?(P.preventDefault(),P.stopPropagation(),Y(!1)):(P.key==="ArrowDown"||P.key==="ArrowUp")&&!b&&(P.preventDefault(),C())},className:d,children:o}),Q.shown&&is.createPortal(e.jsx("div",{ref:I,id:q,"data-backup-menu":!0,role:"dialog","aria-label":s("botPanel.backups.choose"),"aria-modal":"false",tabIndex:-1,...Q.exitProps,onKeyDown:W,onPointerMove:Ka,style:{position:"fixed",left:A?.left??0,top:A?.top,bottom:A?.bottom,width:A?.width??xt,maxHeight:A?.maxHeight,transformOrigin:A?.origin,visibility:A?void 0:"hidden"},className:R("menu-surface z-[80] flex flex-col overflow-hidden",Q.className),children:e.jsx(Ua,{menu:w(),query:O,bot:t,botModel:{label:"",title:""},idPrefix:q,onQuery:y,onPick:(P,_)=>{P.policy||(i({instanceId:P.instanceId,model:_}),Y(!0))},onPickCurrent:()=>Y(!0),onFollowBot:()=>Y(!0),onToggle:P=>x(_=>{const V=new Set(_);return V.delete(P.instanceId)||V.add(P.instanceId),V}),onSetUp:ie,onCheckAgain:J,onManage:ie})}),document.body)]})}function Ci({bot:t,onChange:a}){const{state:n}=F(),i=t.fallback??[],r=p.useRef(null),l=d=>new Set([t.modelSelection,...i.filter((o,u)=>u!==d)].map(o=>Es(o.instanceId,o.model))),c=d=>{const o=n.instances.find(f=>f.instanceId===d.instanceId),u=o?.models.options.find(f=>f.id===d.model),m=Fa(o,d.model);return{instance:o,name:m,short:o&&u?za(u.label,Ha(o)):m}};return e.jsx(D,{anchor:"backups",children:e.jsxs(ue,{"data-panel-row":"backups",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(X,{icon:Da}),e.jsx(ne,{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})}),i.length>0&&e.jsx("ol",{"aria-label":s("botPanel.backups.title"),className:"flex flex-col gap-1 pl-[38px]",children:i.map((d,o)=>{const{instance:u,name:m,short:f}=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($t,{bot:t,current:d,exclude:l(o),onPick:v=>a(i.map((g,b)=>b===o?v:g)),label:s("botPanel.backups.row",{position:o+1,model:m}),title:u?`${u.displayName} · ${m}`:m,"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($a,{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:f}),!u&&e.jsx("span",{className:"shrink-0 text-[12px] text-warning",children:s("model.simple.unavailable")}),e.jsx(fe,{size:12,strokeWidth:2,"aria-hidden":"true",className:"shrink-0 text-ink-tertiary group-hover:text-ink-secondary"})]}),e.jsx(Ae,{"data-panel-action":"backup-remove",label:s("botPanel.backups.remove",{model:m}),onClick:()=>{a(i.filter((v,g)=>g!==o)),r.current?.focus({preventScroll:!0})}})]},o)})}),i.length<wi&&e.jsx("div",{className:"pl-[38px]",children:e.jsxs($t,{bot:t,current:null,exclude:l(null),onPick:d=>a([...i,d]),label:s("model.fallback.add"),buttonRef:r,"data-panel-action":"backup-add",className:R(ce,"aria-expanded:bg-raised-hover"),children:[e.jsx(ve,{size:14,"aria-hidden":"true"}),s("model.fallback.add")]})})]})})}function Pi({bot:t}){const{dispatch:a}=F(),[n,i]=p.useState(!1),[r,l]=p.useState(!1),[c,d]=p.useState(0),o=t.memoryEnabled!==!1&&t.memoryUpkeep!==!1;if(p.useEffect(()=>{if(!o)return;let m=!0;return ae(`/api/bots/${t.id}/system-prompt`).then(f=>{m&&i(f.heavy===!0)},()=>{}),()=>{m=!1}},[t.id,o,c]),!o||!n)return null;const u=async()=>{l(!0);try{await cs(t.id)}catch(m){a({type:"error",message:m instanceof Error&&m.message?m.message:s("common.tryAgain")})}finally{l(!1),d(m=>m+1)}};return e.jsx(D,{anchor:"heavy",children:e.jsxs("div",{"data-panel-row":"heavy",className:Z,children:[e.jsx(X,{icon:Ya}),e.jsx(ne,{title:s("botPanel.heavy")}),e.jsx("button",{type:"button","data-panel-action":"tidy-memory",disabled:r,onClick:()=>{u()},className:ce,children:r?s("memory.upkeep.tidying"):s("botPanel.tidyMemory")})]})})}const Oi=5;function Ei({bot:t}){const{dispatch:a,flushBotPatches:n}=F(),[i,r]=p.useState([]),[l,c]=p.useState(null),d=p.useCallback(()=>jt(t.id).then(u=>r(u.rows.slice(0,Oi)),()=>{}),[t.id]);if(p.useEffect(()=>{d()},[d,t.soul]),!i.length)return null;const o=async u=>{if(!l){c(u.id);try{await n(t.id);const{revision:m}=await jt(t.id);await er(t.id,u.id,m)}catch(m){a({type:"error",message:m instanceof Error&&m.message?m.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(nt,{rows:i,botName:t.name,reverting:l,onRevert:u=>{o(u)}})]})}const Ke={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 Ri({bot:t,derived:a,onOpen:n,editingInstructions:i=!1,onEditInstructions:r}){const{state:l,dispatch:c,flushBotPatches:d}=F(),{capabilities:o,ready:u}=be(),m=ss(t),{servers:f}=fs(),v=Ja(qe(t)),g=Qa(),b=bs(t.id),k=xs(),[O,y]=p.useState(null),{patch:N,approvalMode:x,engine:S}=a,L=t.name,$=()=>{O!==null&&O.trim()!==t.title.trim()&&N({title:O.trim()}),y(null)},M=S?.driverKind==="antigravityAgent"&&x==="auto"?"ask":x,A=[{value:"ask",label:Ke.ask(),tooltip:s("botSettings.simple.askHint")},{value:"full",label:Ke.full(),tooltip:s("botSettings.simple.fullHint")},...M==="ask"||M==="full"?[]:[{value:M,label:Ke[M](),disabled:!0,tooltip:M==="custom"?s("botPanel.acts.customHint"):void 0}]],H=C=>{C===x||C!=="ask"&&C!=="full"||c({type:"updateBot",botId:t.id,patch:{approvalMode:C,applyToAllThreads:!0}})},T=!u||Za(o,l.config),h=mn(g,{turnsHere:T,canLive:!0}),I=T?null:Xa(o,!!tn()?.speechStart,en(l.config)),z=sn.map(C=>({value:C.id,label:s(C.label),disabled:C.id==="turns"&&I!==null,tooltip:C.id==="turns"&&I?`${I.label}. ${I.reason}`:C.id==="live"?s("call.mode.liveHint"):an("turns")})),U=nn.map(C=>({value:C,label:s(wt[C][0]),tooltip:s(wt[C][1])})),q=()=>{const C=!t.notifications;C&&un(),N({notifications:C})},Q=t.alwaysAllow??[],re=i||!!t.soulDrift,Y=[...m.apps.filter(C=>C.scope!==null).map(C=>C.label),...f?gs(f,t.mcpServers,t.id).map(C=>C.name):[]];return e.jsxs("div",{"data-panel-settings":!0,children:[e.jsx(tr,{bot:t}),e.jsx(D,{anchor:"instructions",children:re?e.jsxs(ue,{"data-panel-row":"soul",children:[e.jsx(sr,{bot:t,onPatch:N,simple:{label:s("botSettings.simple.instructions"),placeholder:s("botSettings.simple.instructionsPlaceholder",{name:L})}}),e.jsx(Ei,{bot:t}),i&&e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"button","data-panel-done":"soul",onClick:()=>{d(t.id),r?.(!1)},className:ce,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:R(Z,"w-full text-left hover:bg-ink/[0.03]"),children:[e.jsx(X,{icon:Ie}),e.jsx(ne,{title:s("botSettings.simple.instructions"),hint:e.jsx("span",{className:"line-clamp-1",children:ar(t.soul??"")||s("botPanel.instructionsHint",{name:L})})}),e.jsx(ye,{size:15,className:"shrink-0 text-ink-tertiary","aria-hidden":"true"})]})}),e.jsx(Pi,{bot:t}),e.jsx(D,{anchor:"approval",children:e.jsxs(ue,{"data-panel-row":"approval",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(X,{icon:qt}),e.jsx(ne,{title:s("botSettings.simple.beforeActs",{name:L}),hint:t.busy?s("approvalMode.whileWorking"):void 0})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(Se,{attr:"data-approval-choice",label:s("botSettings.simple.beforeActs",{name:L}),value:M,onChange:H,options:A})}),v.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(rn,{choice:v.choice})})]}),Q.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")}),Q.map(C=>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:C}),e.jsx(Ae,{"data-panel-action":`always-allow:${C}`,label:s("botAccess.always.remove",{entry:C}),onClick:()=>N({alwaysAllow:Q.filter(J=>J!==C)})})]},C))]})]})}),e.jsx(Ci,{bot:t,onChange:C=>N({fallback:C})}),e.jsx(D,{anchor:"call",children:e.jsxs(ue,{"data-panel-row":"call-mode",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(X,{icon:Hn}),e.jsx(ne,{title:s("call.mode.menu")})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(Se,{attr:"data-call-mode",label:s("call.mode.menu"),value:h,onChange:ln,options:z})})]})}),e.jsxs(D,{anchor:"replies",children:[e.jsxs(ue,{"data-panel-row":"reply-style",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(X,{icon:on}),e.jsx(ne,{title:s("botSettings.replyStyle.title")})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(Se,{attr:"data-reply-style",label:s("botSettings.replyStyle.title"),value:t.replyStyle??"default",onChange:C=>N({replyStyle:C}),options:U})})]}),e.jsx(tt,{"data-panel-row":"notifications",icon:cn,title:s("voice.notifications.title"),color:t.color,checked:t.notifications,onChange:q})]}),e.jsxs(D,{anchor:"uses",children:[e.jsx(ee,{"data-panel-page":"apps",icon:ts,title:s("botPanel.appsRow"),value:Y.length>0?Y.join(", "):s("botPanel.appsNoneYet"),onClick:()=>n?.("apps")}),e.jsxs("label",{"data-panel-row":"job",className:R(Z,"cursor-text"),children:[e.jsx(X,{icon:Rr}),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:O??t.title,placeholder:s("botSettings.simple.jobPlaceholder"),"aria-label":s("botSettings.simple.job"),maxLength:Ve.title,onChange:C=>y(C.target.value),onBlur:$,onKeyDown:C=>{C.key==="Enter"?(C.preventDefault(),C.currentTarget.blur()):C.key==="Escape"&&O!==null&&(C.preventDefault(),C.stopPropagation(),y(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:R(Z,"hover:bg-ink/[0.03]"),children:[e.jsx(X,{icon:ys}),e.jsx(ne,{title:s("botPanel.page.slack"),hint:s("botSlack.manage")}),e.jsx(rs,{size:14,className:"shrink-0 text-ink-tertiary","aria-hidden":"true"})]}),k&&e.jsx(ee,{"data-panel-page":"visibility",icon:Wt,title:s("botSettings.visibility.title"),value:nr(t.visibility),onClick:()=>n?.("visibility")})]}),e.jsx(rr,{bot:t,webhooksLink:!0,className:"mt-3.5"}),e.jsx(dn,{bot:t}),v.dialogs]})}const Ii=5;function Ai({bot:t,onChanged:a}){const{dispatch:n}=F(),[i,r]=p.useState([]),[l,c]=p.useState(null),[d,o]=p.useState(null),u=p.useCallback(async()=>{const[g,b]=await Promise.all([st(t.id),he(t.id)]);c(k=>g.lendingReview?{value:g.lendingReview,stale:k?.stale??!1}:null),r(b.slice(0,Ii))},[t.id]);p.useEffect(()=>{u().catch(()=>{})},[u,t.busy]);const m=g=>n({type:"error",message:g instanceof Error&&g.message?g.message:s("common.tryAgain")}),f=async g=>{o(g.id);try{await ms(t.id,g.id),await a()}catch(b){m(b)}finally{o(null),await u().catch(()=>{})}},v=async g=>{o("review");try{await os(t.id,g.value.token),c(null)}catch(b){b instanceof Yt&&b.status===409?(c({...g,stale:!0}),await u().catch(()=>{})):m(b)}finally{o(null)}};return e.jsxs(e.Fragment,{children:[l&&e.jsx(ks,{changed:l.value.changed,stale:l.stale,busy:d!==null,onReviewed:()=>{v(l)}}),e.jsx(D,{children:e.jsx(tt,{"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}})})}),i.length>0&&e.jsx(D,{label:s("memory.changes"),children:e.jsx("div",{"data-panel-row":"memory-changes",className:"px-3.5 py-3",children:e.jsx(nt,{rows:i,botName:t.name,reverting:d,onRevert:g=>{f(g)}})})})]})}const Li="flex flex-col gap-3",Ft="https://www.skills.sh";function ge(t,a){return t instanceof Error&&t.message?t.message:a}function Ti({bot:t,derived:a}){const{dispatch:n}=F(),i=ss(t),{servers:r,error:l}=fs(),{patch:c,canUseConnectedApps:d}=a,o=r?vr(r,t.id):[],u=new Set(gs(o,t.mcpServers,t.id).map(g=>g.name)),m=g=>{const b=gn(t,i.connectedSlugs,g.slug,g.scope===null);Object.keys(b).length>0&&c(b)},f=g=>{t.busy||l||c({mcpServers:kr(o,t.mcpServers,g)})},v=d?i.phase==="loading"?s("common.checking"):i.phase==="unknown"?s("botSettings.simple.appsUnknown"):i.apps.length===0?s("botSettings.simple.appsNone"):null:s("botSettings.simple.appsCannot",{name:t.name});return e.jsxs(e.Fragment,{children:[e.jsxs(D,{children:[v&&e.jsx(G,{children:v}),d&&i.apps.map(g=>e.jsxs("div",{"data-simple-app":g.slug,className:Z,children:[e.jsx(hn,{card:g.card,className:"size-7 shrink-0"},`${g.card.logo}:${g.card.domain}`),e.jsx("div",{className:"min-w-0 flex-1 truncate text-[14px] font-medium text-ink",children:g.label}),e.jsx(ft,{color:t.color,checked:g.scope!==null,"aria-label":s("botSettings.simple.appToggle",{name:t.name,app:g.label}),disabled:!!t.busy,onClick:()=>m(g),className:"disabled:cursor-not-allowed"})]},g.slug))]}),(o.length>0||l)&&e.jsxs(D,{label:s("connectors.tab.mcp"),children:[l&&e.jsx(G,{children:s("botAccess.mcpRefreshError")}),o.map(g=>e.jsxs("div",{"data-simple-mcp":g.name,className:Z,children:[e.jsx(X,{icon:_n}),e.jsx(ne,{title:e.jsx("span",{className:"block truncate",children:g.name}),hint:g.enabled?g.offFor?.includes(t.id)?s("mcp.offFor",{bots:t.name}):void 0:s("botAccess.mcpDisabled")}),e.jsx(ft,{color:t.color,checked:u.has(g.name),"aria-label":s("botSettings.simple.appToggle",{name:t.name,app:g.name}),disabled:!g.enabled||!!t.busy||l,onClick:()=>f(g.name),className:"disabled:cursor-not-allowed"})]},g.name))]}),e.jsx(D,{children:e.jsx(pe,{"data-panel-link":"add-app",icon:ve,onClick:()=>fn(n,t.id),children:s("botPanel.apps.connectAnother")})})]})}function Mi({bot:t,derived:a}){const{state:n,dispatch:i}=F(),[r,l]=p.useState(()=>a.botRoutines.length===0?"new":null);return e.jsxs(e.Fragment,{children:[e.jsx(yr,{routines:a.botRoutines,runs:n.routineRuns,pausedBots:n.config?.pausedBots,loading:n.routinesLoadState==="loading"&&a.botRoutines.length===0,error:n.routinesLoadState==="error",onOpen:l,onLogs:c=>i({type:"showRoutines",section:"logs",botId:t.id,routineId:c.id}),onToggle:c=>i({type:"updateRoutine",routineId:c.id,patch:{enabled:!c.enabled}})}),e.jsx(D,{children:e.jsx(pe,{"data-panel-action":"new-routine",icon:ve,onClick:()=>l("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(jr,{routine:r==="new"?void 0:r,bots:[t],lockedBotId:t.id,onClose:()=>l(null)},t.id)]})}function Bi({bot:t}){const a=Ps(t),[n,i]=p.useState(""),[r,l]=p.useState(null),[c,d]=p.useState(!1),[o,u]=p.useState(null),m=t.memoryEnabled!==!1,f=a.docs?Cs(a.docs):null,v=a.docs?.find(y=>y.path===te)??null;p.useEffect(()=>l(null),[t.id,m]);const g=async y=>{if(c)return!1;d(!0),u(null);try{return await y()}catch(N){return u(ge(N,s("botPanel.library.memoryError"))),!1}finally{d(!1)}},b=(y,N)=>g(async()=>{const x=await at(t.id,y.path,N,y.exists?y.hash:void 0,a.mine);return x.ok?(a.setDoc(x.doc),!0):(await a.reload(),u(s("memory.conflict.title",{name:t.name})),!1)}),k=y=>{const N=a.docs?.find(x=>x.path===y.path);N&&(y.line!==null?b(N,xi(N.text,y.line)):g(async()=>(await ds(t.id,N.path,a.mine),await a.reload(),!0)))},O=async()=>{!v||!n.trim()||await b(v,hi(v.text,n))&&i("")};return m&&r?.botId===t.id?e.jsx(Di,{bot:t,doc:r.doc,mine:a.mine,onDone:y=>{y&&a.setDoc(y),l(null),u(null)}}):e.jsxs(e.Fragment,{children:[e.jsxs(D,{children:[m?a.error?e.jsx(G,{tone:"warn",children:s("botPanel.library.memoryError")}):f===null?e.jsx(G,{children:s("common.checking")}):f.length===0?e.jsx(G,{children:s("botPanel.memory.empty")}):f.map(y=>e.jsxs("div",{"data-memory-note":y.line??y.path,className:Z,children:[e.jsx("div",{className:"min-w-0 flex-1 text-[13px] leading-[1.45] text-ink",children:y.text}),e.jsx(Ae,{label:s("botPanel.memory.forget"),disabled:c,onClick:()=>k(y)})]},`${y.path}:${y.line}:${y.text}`)):e.jsx(G,{children:s("botPanel.library.memoryOff",{name:t.name})}),o&&e.jsx(G,{tone:"warn",children:o})]}),m&&e.jsxs(D,{children:[e.jsx(as,{"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||v===null,onChange:i,onSubmit:()=>{O()}}),v&&e.jsx(pe,{"data-panel-link":"memory-text",icon:Ie,onClick:()=>l({botId:t.id,doc:v}),children:s("botPanel.memory.editText")})]}),m&&!a.mine&&e.jsx(Ai,{bot:t,onChanged:a.reload})]})}function Di({bot:t,doc:a,mine:n,onDone:i}){const[r,l]=p.useState({text:a.text,hash:a.hash}),[c,d]=p.useState(a.text),[o,u]=p.useState(null),[m,f]=p.useState(null),[v,g]=p.useState(!1),[b,k]=p.useState(null),O=p.useRef(!0);p.useEffect(()=>(O.current=!0,()=>{O.current=!1}),[]);const y=async x=>{g(!0),k(null);try{const S=await at(t.id,a.path,c,x,n);if(!O.current)return;S.ok?i(S.doc):u({current:S.current,currentHash:S.currentHash})}catch(S){k(ge(S,s("botPanel.library.memoryError")))}finally{g(!1)}},N=()=>{o&&(f(x=>x===null||x===c?c:`${x}
15
-
16
- ${c}`),l({text:o.current,hash:o.currentHash}),d(o.current),u(null))};return e.jsx(D,{children:e.jsxs(ue,{"data-panel-row":"memory-text",children:[o&&e.jsx(js,{botName:t.name,busy:v,onReload:N,onOverwrite:()=>{y(o.currentHash)}}),e.jsx("textarea",{"data-memory-text":"",className:R(Ye,"min-h-[280px] resize-y font-mono text-[13px] leading-relaxed"),value:c,placeholder:s("memory.indexPlaceholder"),"aria-label":s("memory.botMemory"),readOnly:v,onChange:x=>d(x.target.value)}),b&&e.jsx("div",{className:"text-[13px] text-warning",children:b}),m!==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:m}),e.jsx("button",{type:"button",className:R(ce,"mt-1"),onClick:()=>f(null),children:s("memory.dismissDraft")})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",className:ce,disabled:v,onClick:()=>i(null),children:s("common.cancel")}),e.jsx("button",{type:"button","data-panel-done":"memory-text",className:ce,disabled:v||c===r.text,onClick:()=>{y(r.hash)},children:v?s("memory.saving"):s("memory.save")})]})]})})}function $i({bot:t}){const{request:a}=pn(),{state:n,dispatch:i}=F(),r=us(t),[l,c]=p.useState(""),[d,o]=p.useState(!1),[u,m]=p.useState([]),f=xn(n.config),v=async x=>{if(!r.working&&window.confirm(s(x.origin==="library"?"skills.unassignConfirm":"botPanel.skills.removeConfirm",{name:x.name}))){r.setWorking(x.name),r.setError("");try{await a(`/api/bots/${t.id}/skills/${encodeURIComponent(x.name)}`,{method:"DELETE"}),await r.refresh()}catch(S){r.setError(ge(S,s("botPanel.skills.removeFailed")))}finally{r.setWorking("")}}},g=async()=>{const x=l.trim();if(!(!x||d)){o(!0),r.setError(""),m([]);try{const S=await a(`/api/bots/${t.id}/skills`,{method:"POST",body:JSON.stringify({source:x})});m(Nt(S.imported??[])),c(""),await r.refresh()}catch(S){r.setError(ge(S,s("botPanel.skills.importFailed")))}finally{o(!1)}}},b=async()=>{const x=await window.ogb?.pickFolder?.();if(!(!x||d)){o(!0),r.setError(""),m([]);try{const S=await a(`/api/bots/${t.id}/skills`,{method:"POST",body:JSON.stringify({source:`local-folder:${x}`})});m(Nt(S.imported??[])),await r.refresh()}catch(S){r.setError(ge(S,s("botPanel.skills.importFailed")))}finally{o(!1)}}},[k,O]=p.useState(!1),y=()=>{O(!1),i({type:"toggleSettings",open:!1}),i({type:"toggleAppSettings",open:!0,section:"skills"})},N=()=>{if(f){O(!0);return}ht(Ft)};return e.jsxs(e.Fragment,{children:[e.jsxs(D,{children:[r.loading?e.jsx(G,{children:s("skills.loading")}):r.skills.length===0?e.jsx(G,{children:s("botSettings.simple.noSkills")}):r.skills.map(x=>e.jsx(tt,{"data-panel-row":`skill:${x.name}`,title:x.name,hint:x.description||x.source,label:s("botSettings.simple.skillToggle",{name:x.name}),color:t.color,checked:ps(x),disabled:!!r.working||x.core===!0,onChange:()=>{r.toggle(x)},extra:x.origin==="imported"||x.origin==="native"||x.origin==="bundled"?void 0:e.jsx(Ae,{"data-panel-action":`remove-skill:${x.name}`,label:s("botPanel.skills.remove",{name:x.name}),disabled:!!r.working,onClick:()=>{v(x)}})},x.name)),r.error&&!r.reviewing&&e.jsx(G,{tone:"warn",children:r.error})]}),e.jsx(lr,{bot:t,onAdded:()=>{r.refresh()}}),e.jsxs(D,{children:[e.jsx(as,{"data-panel-form":"skill-import",value:l,placeholder:s("botPanel.skills.importPlaceholder"),label:s("skills.import.label"),action:d?s("skills.import.importing"):s("common.add"),disabled:d,onChange:c,onSubmit:()=>{g()}}),u.map(x=>e.jsx(G,{children:x},x)),e.jsx(pe,{"data-panel-link":"skills-sh",onClick:()=>{ht(Ft)},children:s("botPanel.skills.skillsSh")}),e.jsx(pe,{"data-panel-link":"browse-skills",onClick:N,children:s("botPanel.skills.bundled")}),window.ogb?.pickFolder&&e.jsx(pe,{"data-panel-link":"skills-folder",onClick:()=>{b()},children:s("botPanel.skills.fromFolder")})]}),k&&e.jsx(ji,{botId:t.id,botName:t.name,onOpenSettings:y,onClose:()=>{O(!1),r.refresh()}}),r.reviewing&&e.jsx(or,{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 Fi({bot:t}){const{capabilities:a}=be(),n=a.host?.homeDir,{draft:i,setDraft:r,error:l,saving:c,canPick:d,save:o,pick:u}=ir(t),[m,f]=p.useState(!1),v=!!t.cwd||m,g=()=>{if(d){u();return}f(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(D,{children:[e.jsx(Ue,{"data-panel-choice":"private",title:s("botPanel.folder.own"),hint:s("botPanel.folder.ownHint"),checked:!v,disabled:c,onClick:()=>{f(!1),t.cwd&&o(null)}}),e.jsx(Ue,{"data-panel-choice":"pick",title:s("botPanel.folder.pick"),hint:s("botPanel.folder.pickHint"),checked:v,disabled:c,onClick:()=>{t.cwd||g()}})]}),v&&e.jsxs(D,{children:[d?e.jsxs("div",{className:Z,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?Xe(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:ce,children:[e.jsx(Gt,{size:14,"aria-hidden":"true"}),s("botAccess.folder.choose")]})]}):e.jsxs("form",{"data-panel-form":"folder-path",className:Z,onSubmit:b=>{b.preventDefault();const k=(i??t.cwd??"").trim();k&&o(k)},children:[e.jsx("input",{value:i??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||i===null,className:ce,children:s("botAccess.folder.save")})]}),l&&e.jsx(G,{tone:"warn",children:l})]})]})}function zi({bot:t,derived:a}){const n=ws(t);return e.jsx(bi,{bot:t,browserEnabled:a.browserEnabled,onOpenBrowser:()=>n("browser")})}function Hi({bot:t}){return xs()?e.jsx(hs,{bot:t}):null}function _i({page:t,onOpen:a,editingInstructions:n,onEditInstructions:i,...r}){switch(t){case"settings":return e.jsx(Ri,{...r,onOpen:a,editingInstructions:n,onEditInstructions:i});case"where":return e.jsx(si,{...r});case"apps":return e.jsx(Ti,{...r});case"routines":return e.jsx(Mi,{...r});case"visibility":return e.jsx(Hi,{...r});case"memory":return e.jsx(Bi,{...r});case"skills":return e.jsx($i,{...r});case"folder":return e.jsx(Fi,{...r});case"browser":return e.jsx(zi,{...r})}}const zt="rounded-lg border border-accent-border bg-inset px-2 py-[3px] text-center text-ink outline-none placeholder:text-ink-tertiary";function Ht(t){const[a,n]=p.useState(null),i=p.useRef(!1),r=p.useRef(!1),l=p.useRef(null);p.useEffect(()=>{a!==null||!r.current||(r.current=!1,l.current?.focus())},[a]);const c=m=>{i.current=!1,n(m)},d=()=>{a!==null&&t(a),n(null)};return{draft:a,setDraft:n,start:c,onKeyDown:m=>{if(bn(m.nativeEvent)){m.stopPropagation();return}m.key==="Enter"?(m.preventDefault(),i.current=!0,r.current=!0,d()):m.key==="Escape"&&(m.preventDefault(),m.stopPropagation(),i.current=!0,r.current=!0,n(null))},onBlur:()=>{i.current||d()},buttonRef:l}}function Ki({bot:t,activeState:a,patch:n,editorOpen:i,onToggleEditor:r}){const l=Ht(o=>{const u=o.trim();u&&u!==t.name&&n({name:u})}),c=Ht(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":i,onClick:r,className:"group relative rounded-[18px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-border",children:[e.jsx(Ge,{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(gt,{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(yn,{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:l.draft!==null?e.jsx("input",{autoFocus:!0,"data-panel-rename-input":!0,"aria-label":s("botSettings.simple.name"),maxLength:Ve.name,value:l.draft,onChange:o=>l.setDraft(o.target.value),onKeyDown:l.onKeyDown,onBlur:l.onBlur,className:R(zt,"w-[220px] max-w-full text-[17px] font-medium leading-6")}):e.jsxs("button",{ref:l.buttonRef,type:"button","data-panel-rename":!0,title:s("botPanel.rename"),onClick:()=>l.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(gt,{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:Ve.title,value:c.draft,onChange:o=>c.setDraft(o.target.value),onKeyDown:c.onKeyDown,onBlur:c.onBlur,className:R(zt,"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 Ne(t,a){return t?ns(t,a):{tab:"details"}}function Ui({bot:t,derived:a,linkedSection:n,onClose:i}){const{dragProps:r}=ls(),l=vn(),[c,d]=p.useState(()=>Ne(n,l).tab),[o,u]=p.useState(()=>{const h=Ne(n,l).page;return h?[h]:[]}),[m,f]=p.useState(()=>Ne(n,l).anchor??null),[v,g]=p.useState(!1),[b,k]=p.useState(()=>!!Ne(n,l).editInstructions),O=p.useRef(null),y=p.useRef(null),N=o.at(-1)??null,x=()=>O.current?.scrollTo({top:0}),S=h=>{d(h.tab),u(h.page?[h.page]:[]),f(h.anchor??null),g(!1),k(!!h.editInstructions),x()},L=h=>S({tab:h}),$=h=>{u(I=>[...I,h]),g(!1),x()},M=()=>{g(!1),y.current?.querySelector("[data-panel-avatar]")?.focus()},A=()=>{u(h=>h.slice(0,-1)),x()};p.useEffect(()=>{n&&S(ns(n,l))},[n,l]),p.useEffect(()=>{m&&(O.current?.querySelector(`[data-panel-card="${m}"]`)?.scrollIntoView({block:"start"}),f(null))},[m,N,c]);const H=h=>{if(h.key!=="Escape"||h.defaultPrevented)return;const I=h.target,z=typeof I?.closest=="function"?I.closest('[role="dialog"], [role="alertdialog"]'):null;if(!(z&&!z.contains(h.currentTarget)&&z!==y.current&&!y.current?.contains(z))){if(v)M();else if(o.length>0)A();else return;h.preventDefault(),h.stopPropagation()}},T=o.length>1?s(we[o[o.length-2]].title,{name:t.name}):s(yt[c]);return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",onKeyDown:H,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(kn,{bot:t,className:Be}),e.jsx("button",{type:"button","data-panel-gear":!0,"aria-label":s("botPanel.page.settings"),title:s("botPanel.page.settings"),"aria-current":N==="settings"?"page":void 0,onClick:()=>S({tab:"details",page:"settings"}),className:Be,children:e.jsx(jn,{size:16,className:"pointer-events-none"})}),e.jsx("button",{type:"button",onClick:i,"aria-label":s("botSettings.simple.close"),className:Be,children:e.jsx(Qe,{size:16,className:"pointer-events-none"})})]}),e.jsx("div",{ref:O,className:"@container relative min-h-0 flex-1 overflow-y-auto px-4 pb-7",children:N===null?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative mt-3.5",ref:y,children:[e.jsx(Ki,{bot:t,activeState:a.activeState,patch:a.patch,editorOpen:v,onToggleEditor:()=>g(h=>!h)}),v&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-20","aria-hidden":"true","data-panel-scrim":!0,onClick:M}),e.jsx(Xr,{bot:t,activeState:a.activeState,onPatch:a.patch,onClose:M})]})]}),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:wn.map(h=>e.jsx("button",{type:"button",role:"tab","aria-selected":c===h,"data-panel-tab":h,onClick:()=>L(h),className:R("h-[26px] min-w-0 shrink truncate rounded-full px-3 text-[13px] leading-[18px] transition-colors",c===h?"bg-ink/[0.1] font-medium text-ink":"text-ink-secondary hover:text-ink"),children:s(yt[h])},h))})}),e.jsxs("div",{role:"tabpanel",children:[c==="details"&&e.jsx(ui,{bot:t,derived:a,onOpen:$}),c==="library"&&e.jsx(Os,{bot:t,onOpen:$}),c==="computer"&&e.jsx(ai,{bot:t,derived:a,onOpen:$})]})]}):e.jsxs("div",{"data-panel-page-view":N,children:[e.jsx("span",{id:"bot-settings-title",className:"sr-only",children:t.name}),e.jsx(Nn,{back:T,title:s(we[N].title,{name:t.name}),intro:we[N].intro?s(we[N].intro,{name:t.name}):void 0,onBack:A}),e.jsx("div",{className:R("mt-4",Li),children:e.jsx(_i,{page:N,bot:t,derived:a,onOpen:$,editingInstructions:b,onEditInstructions:k})})]})})]})}function qi(t,a){const{state:n,flushBotPatches:i}=F(),[r,l]=p.useState(null),[c,d]=p.useState(!1),[o,u]=p.useState(null),[m,f]=p.useState(!1),v=p.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]),g=a.followEdits??!0,b=g?v:null,k=g?n.routines:null,O=g?n.webhooks:null;return p.useEffect(()=>{if(!a.overview&&!a.prompt)return;let y=!1;return(async()=>(await i(t.id),!y&&(a.overview&&ae(`/api/bots/${t.id}/overview`).then(x=>{y||(l(x),d(!1))}).catch(()=>{y||d(!0)}),a.prompt&&ae(`/api/bots/${t.id}/system-prompt`).then(x=>{y||(u(x),f(!1))}).catch(()=>{y||f(!0)}))))(),()=>{y=!0}},[t.id,a.overview,a.prompt,b,k,O,i]),{overview:r,overviewError:c,prompt:o,promptError:m}}function Wi(t,a){const{dispatch:n,flushBotPatches:i}=F(),[r,l]=p.useState(null),[c,d]=p.useState(!1),[o,u]=p.useState(null),m=p.useRef(0),[f,v]=p.useState(!1),[g,b]=p.useState(null),k=p.useCallback(()=>{const N=++m.current;return d(!1),i(t.id).then(()=>ae(`/api/bots/${t.id}/history?limit=100`)).then(x=>{N===m.current&&(l(x.rows),u(x.revision))}).catch(()=>{N===m.current&&d(!0)})},[t.id,i]);return p.useEffect(()=>{if(a)return k(),()=>{m.current++}},[a,k]),{rows:r,error:c,revision:o,rollingBack:f,rollbackTarget:g,setRollbackTarget:b,rollback:async N=>{if(!f){b(null),v(!0);try{await i(t.id),await ae(`/api/bots/${t.id}/history/rollback`,{method:"POST",body:JSON.stringify(N)})}catch(x){n({type:"error",message:x instanceof Error?x.message:s("botOverview.undoFailed")})}finally{await k(),v(!1)}}},requestRollback:N=>{o&&b({id:N,expectedRevision:o})}}}function Vi({history:t,returnFocusRef:a}){const{rollbackTarget:n,setRollbackTarget:i,rollback:r}=t;return e.jsx(Sn,{open:n!==null,title:s("botOverview.restoreSoul.title"),body:s("botOverview.restoreSoul.body"),confirmLabel:s("botOverview.restoreSoul.confirm"),tone:"neutral",returnFocusRef:a,onCancel:()=>i(null),onConfirm:()=>{n&&r(n)}})}const Gi={memory:"memory",skills:"skills",folder:"access"},Rs=t=>t.labelKey?s(t.labelKey):t.label;function _t(t,a){return a?[t.label,Rs(t),...t.keywords].some(n=>n.toLowerCase().includes(a)):!0}function ul({bot:t,overlay:a=!1}){const{state:n,dispatch:i}=F(),r=n.botSettingsSection,l=Cn(t),c=p.useRef(null),{dragProps:d}=ls(),[o,u]=p.useState(""),m=!n.botSettingsExpandAccordion,f=o.trim().toLowerCase(),g=!Kt(),b=!m&&!n.botSettingsExpandRemembered?r:null,k=bs(t.id),O=et(),y=Pn(),N=Ir.filter(T=>T.id!=="slack"||k!==null).filter(T=>T.id!=="visibility"||!window.ogb&&O===!0&&!y),x=N.filter(T=>_t(T,f)),{overview:S,overviewError:L,prompt:$,promptError:M}=qi(t,{overview:r==="overview"&&!g,prompt:r==="overview"&&!g}),A=Wi(t,r==="history"&&!g);p.useEffect(()=>{if(!m){if(f){u("");return}c.current?.querySelector(`[data-bot-settings-section="${r}"]`)?.scrollIntoView({block:"nearest"})}},[m,r,f]),p.useEffect(()=>{const T=document.activeElement instanceof HTMLElement?document.activeElement:null,h=c.current;h?.focus();const I=z=>{const U=h?.querySelector('[role="dialog"], [role="alertdialog"]');U&&U.getClientRects().length>0||h&&z.target instanceof Node&&!h.contains(z.target)||z.key==="Escape"&&!z.defaultPrevented&&(z.preventDefault(),i({type:"toggleSettings",open:!1}))};return window.addEventListener("keydown",I),()=>{window.removeEventListener("keydown",I),T?.focus()}},[i]);const H=T=>{switch(T){case"overview":return S===null&&L?e.jsx("div",{className:"rounded-xl bg-card p-4 text-[13px] text-ink-secondary",children:s("botSettings.overviewFailed")}):e.jsx($r,{overview:S,refreshError:S!==null&&L,prompt:$,promptError:M,onOpen:h=>i({type:"toggleSettings",open:!0,section:h}),onSetup:l.canCoordinate&&!t.busy?()=>{i({type:"toggleSettings",open:!1}),i({type:"send",botId:t.id,text:"/setup",threadId:t.threadId})}:void 0});case"identity":return e.jsx(hr,{bot:t,patch:l.patch,activeState:l.activeState,mascotMotion:l.mascotMotion});case"soul":return e.jsx(xr,{bot:t,patch:l.patch});case"slack":return k?e.jsx(Fr,{managementUrl:k}):null;case"skills":return e.jsx(pr,{bot:t});case"memory":return e.jsx(_r,{bot:t,active:!m&&r==="memory",onToggle:h=>l.patch({memoryEnabled:h})});case"library":return e.jsx(Os,{bot:t,onOpen:h=>i({type:"toggleSettings",open:!0,section:Gi[h]??"overview"})});case"routines":return e.jsx(br,{bot:t,routines:l.botRoutines,runs:n.routineRuns});case"access":return e.jsx(ur,{bot:t,derived:l});case"model":return e.jsx(mr,{bot:t});case"permissions":return e.jsx(dr,{bot:t,derived:l});case"voice":return e.jsx(cr,{bot:t,derived:l});case"visibility":return e.jsx(hs,{bot:t});case"history":return A.rows===null&&A.error?e.jsx("div",{className:"rounded-xl bg-card p-4 text-[13px] text-ink-secondary",children:s("botSettings.historyFailed")}):e.jsx(Wr,{bot:t,rows:A.rows,refreshError:A.rows!==null&&A.error,onRollback:A.requestRollback,rollingBack:A.rollingBack||!A.revision});case"usage":return e.jsx(Vr,{bot:t});default:return null}};return e.jsxs(e.Fragment,{children:[e.jsx("aside",{ref:c,id:g?On:void 0,role:"dialog","aria-labelledby":"bot-settings-title",tabIndex:-1,className:Rn(a,g),children:g?e.jsx(Ui,{bot:t,derived:l,linkedSection:b,onClose:()=>i({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(En,{bot:t,className:"rounded-md p-1 text-ink-secondary hover:bg-control hover:text-ink"}),e.jsx("button",{type:"button",onClick:()=>i({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(Qe,{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(Je,{size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("input",{value:o,onChange:T=>{u(T.target.value),i({type:"toggleSettings",open:!0})},onKeyDown:T=>{T.key==="Escape"&&(T.stopPropagation(),o?u(""):i({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:[x.length===0&&e.jsx("div",{className:"px-4 py-4 text-[13px] leading-relaxed text-ink-secondary",children:s("botSettings.searchNone",{query:o.trim()})}),N.map(T=>{const{id:h,icon:I}=T,z=Rs(T),U=_t(T,f);if(!U&&h!=="memory")return null;const q=!m&&r===h;return e.jsxs("div",{"data-bot-settings-section":h,className:"border-b border-hairline/30",hidden:!U,children:[e.jsxs("button",{type:"button",onClick:()=>{if(r===h&&!m){i({type:"toggleSettings",open:!0});return}i({type:"toggleSettings",open:!0,section:h})},"aria-expanded":q,className:R("flex w-full shrink-0 items-center gap-2.5 px-4 py-2.5 text-left text-[14px]",q?"bg-control/60 text-ink":"text-ink-secondary hover:bg-control/40 hover:text-ink"),children:[e.jsx(I,{size:15,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:z}),e.jsx(fe,{size:16,className:R("shrink-0 text-ink-secondary transition-transform",q&&"rotate-180")})]}),h==="memory"?e.jsx("div",{hidden:!q,className:"px-4 pb-4 pt-1",children:H("memory")}):q&&e.jsx("div",{className:"px-4 pb-4 pt-1",children:H(h)})]},h)})]})]})}),e.jsx(Vi,{history:A,returnFocusRef:c})]})}export{ul as BotSettingsDialog};
@@ -1 +0,0 @@
1
- import{j as e,A as z,B as ve,H as U,t as n,D as se,Q,E as X,F as He,G as pe,I as Ce,J as Ee,K as fe,M as ze,N as Ae,O as Ue,R as qe,T as Me,U as G,a as ue,V as $e,W as Ke,r,Y as We,Z as Ve,$ as we,a0 as Ge,X as Je,a1 as Qe,a2 as Xe,a3 as Ye,a4 as Ze,a5 as et,a6 as Le,a7 as tt}from"./styles-Cbtcp5Re.js";import{L as nt,z as st,C as lt,y as J,F as at,G as ot,H as dt,S as rt,I as ct,J as it}from"./PlacesRail-COZEZH0n.js";import{u as ut}from"./App-CGZnP4z7.js";import"./monitor-Bben4nuu.js";import"./index-CSGTkyGn.js";import"./MenuMotion-CtV49YrJ.js";function pt({name:t,color:a,busy:o,interest:d,openFailed:s,onInterest:u,onOpen:p}){return e.jsxs("div",{"data-cloud-add":"has-cloud",className:z,children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(ve,{color:a,size:32}),e.jsx(U,{title:n("cloudBuy.one.title"),sub:n("cloudBuy.one.sub",{name:t})})]}),e.jsxs("div",{className:se,children:[d!=="sent"&&e.jsx("button",{type:"button",className:Q,disabled:o,onClick:u,children:n("cloudBuy.one.email")}),e.jsx("button",{type:"button",className:X,disabled:o,onClick:p,children:n("cloudBuy.setup.open",{name:t})})]}),e.jsxs("div",{"aria-live":"polite",className:"text-[13px] leading-[18px] empty:-mt-5",children:[d==="sent"&&e.jsx("p",{className:"text-ink-secondary",children:n("cloudBuy.one.thanks")}),d==="failed"&&e.jsx("p",{role:"alert",className:"text-danger",children:n("cloudBuy.one.failed")}),s&&e.jsx("p",{role:"alert",className:"text-danger",children:n("cloudBuy.openFailed",{name:t})})]})]})}function ie({kind:t,line:a,onRetry:o,onClose:d}){return e.jsxs("div",{"data-cloud-add":t,className:z,children:[e.jsx(U,{title:n("cloudAdd.title")}),a?e.jsx("p",{role:"alert",className:"text-[14px] leading-5 text-ink",children:a}):e.jsxs("p",{role:"status",className:"flex items-center gap-2 text-[13px] leading-[18px] text-ink-secondary",children:[e.jsx(nt,{size:14,className:"animate-spin motion-reduce:animate-none","aria-hidden":"true"}),n("cloudAdd.checking")]}),e.jsxs("div",{className:se,children:[e.jsx("button",{type:"button",className:Q,onClick:d,children:n("cloudAdd.close")}),o&&e.jsx("button",{type:"button",className:X,onClick:o,children:n("cloudAdd.tryAgain")})]})]})}function ft({plan:t,offer:a,browser:o,late:d,link:s,email:u,busy:p,copied:v,failed:N,onReopen:k,onCopy:I,onChangePlan:q}){const y=a?.plans.find(M=>M.tier===t)??null,E=y?He(y):pe(t),A=y?.trialDays===1?n("cloudBuy.pay.planTrial.one",{plan:E,due:Ce(0)}):y?.trialDays?n("cloudBuy.pay.planTrial.many",{plan:E,days:y.trialDays,due:Ce(0)}):y?n("cloudBuy.pay.planPaid",{plan:E,price:Ee(y.amount/100)}):E;return e.jsxs("div",{"data-cloud-add":d?"waiting-late":o==="signin"?"waiting-signin":"waiting",className:z,children:[e.jsx(U,{title:d?n("cloudBuy.pay.lateTitle"):n("cloudAdd.browserTitle"),sub:d?n("cloudBuy.pay.lateSub"):n(o==="signin"?"cloudBuy.pay.subSignIn":"cloudBuy.pay.sub")}),e.jsx(fe,{items:[{key:"signed-in",state:"done",title:n("cloudBuy.pay.signedIn"),detail:u},{key:"payment",state:"now",title:n("cloudBuy.pay.waiting"),detail:A},{key:"setup",state:"next",title:n("cloudBuy.pay.setup"),detail:n("cloudBuy.pay.setupHint")}]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("button",{type:"button",className:d?X:Q,disabled:p,onClick:k,children:[e.jsx(st,{size:14,"aria-hidden":"true"}),n("cloudAdd.reopenCheckout")]}),s&&e.jsxs("button",{type:"button",className:Q,disabled:p,onClick:I,children:[e.jsx(lt,{size:14,"aria-hidden":"true"}),n("cloudBuy.pay.copy")]}),e.jsx("button",{type:"button",className:`${ze} ms-1 px-1 py-1`,onClick:q,children:n("cloudAdd.changePlan")})]}),e.jsxs("div",{"aria-live":"polite",className:"text-[13px] leading-[18px] empty:-mt-5",children:[v&&e.jsx("p",{className:"text-ink-secondary",children:n("cloudBuy.pay.copied")}),N&&e.jsx("p",{role:"alert",className:"text-danger",children:n("cloudBuy.pay.failed")})]})]})}const R=[["reserving","cloudHome.step.reserving"],["storage","cloudHome.step.storage"],["starting","cloudBuy.step.starting"],["checking","cloudHome.step.checking"]];function mt({tier:t,trial:a,credit:o},d){if(d)return n("cloudAdd.receivedTitle");const s=pe(t??a?.tier??void 0);return a?o?n("cloudBuy.setup.badgeCredit",{plan:s,credit:Ee(o.grantedUsd)}):n("cloudBuy.setup.badgeTrial",{plan:s}):n("cloudBuy.setup.badgePaid",{plan:s})}function xt({started:t,received:a,step:o,slow:d,ready:s,sleeps:u=!1,name:p,typed:v,color:N,counting:k,busy:I,openFailed:q,onName:y,onColor:E,onOpen:A,onNotNow:M}){const _=s?R.length:Math.max(0,R.findIndex(([i])=>i===o)),C=pe(t.tier??t.trial?.tier??void 0);return e.jsxs("div",{"data-cloud-add":s?"ready":a?"received":"starting","data-cloud-setup":s?"ready":o??"reserving",className:z,children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(Ue,{children:mt(t,a)}),e.jsx(U,{title:s?n("cloudBuy.ready.title",{name:p}):n("cloudBuy.setup.title"),sub:s?n("cloudBuy.ready.sub"):a?n("cloudAccount.purchaseNoteNoDate"):n("cloudBuy.setup.sub")})]}),e.jsxs("div",{className:"grid gap-6 sm:grid-cols-2",children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(Ae,{value:_/R.length,label:n("cloudBuy.setup.progress")}),e.jsx(fe,{label:n("cloudBuy.setup.progress"),items:R.map(([i,w],j)=>({key:i,title:n(w,{name:p}),state:j<_?"done":j===_?"now":"next"}))}),d&&!s&&e.jsx("p",{role:"status",className:"px-3 text-[13px] leading-[18px] text-ink-secondary",children:n("cloudHome.slow")})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"cloud-add-name",className:"text-[13px] leading-[18px] text-ink-secondary",children:n("cloudBuy.setup.name")}),e.jsx("input",{id:"cloud-add-name",value:v,maxLength:Me,placeholder:n("cloudSetup.myCloud"),autoComplete:"off",spellCheck:!1,onChange:i=>y(i.target.value),className:qe})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("span",{id:"cloud-add-color",className:"text-[13px] leading-[18px] text-ink-secondary",children:n("cloudBuy.setup.color")}),e.jsx("div",{role:"radiogroup","aria-labelledby":"cloud-add-color",className:"flex flex-wrap gap-2",children:G.map(i=>e.jsx("button",{type:"button",role:"radio","aria-checked":i===N,"aria-label":n(Ke[i]),tabIndex:i===N?0:-1,"data-color":i,onClick:()=>E(i),onKeyDown:w=>{const j=G.indexOf(i),$=w.key==="ArrowRight"||w.key==="ArrowDown"?1:w.key==="ArrowLeft"||w.key==="ArrowUp"?-1:0;if(!$)return;w.preventDefault();const Y=G[(j+$+G.length)%G.length];E(Y),w.currentTarget.parentElement?.querySelector(`[data-color="${Y}"]`)?.focus()},style:{background:$e(i)},className:ue("size-[26px] rounded-lg border-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",i===N?"border-ink shadow-[inset_0_0_0_2px_var(--color-app)]":"border-transparent")},i))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("span",{className:"text-[13px] leading-[18px] text-ink-secondary",children:n("cloudBuy.setup.preview")}),e.jsxs("span",{"data-cloud-preview":!0,className:"inline-flex max-w-full items-center gap-2 self-start rounded-[12px] border-[0.5px] border-ink/10 bg-menu py-1.5 pe-3 ps-1.5",children:[e.jsx(ve,{color:N}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block truncate text-[13px] font-medium leading-4 text-ink",children:p}),e.jsx("span",{className:"block truncate text-[12px] text-ink-tertiary",children:n(u?"cloudBuy.setup.previewLineSleeps":"cloudBuy.setup.previewLine",{plan:C})})]})]})]})]})]}),s&&k===null&&e.jsx("p",{className:"text-[13px] leading-[18px] text-ink-tertiary",children:n("cloudBuy.ready.hint",{name:p})}),e.jsxs("div",{className:se,children:[k!==null&&e.jsx("span",{role:"status",className:"me-1 text-[13px] text-ink-secondary",children:n("cloudBuy.setup.openingIn",{seconds:k})}),k!==null&&e.jsx("button",{type:"button",className:Q,onClick:M,children:n("notice.notNow")}),e.jsx("button",{type:"button",className:X,disabled:!s||I,onClick:A,children:n("cloudBuy.setup.open",{name:p})})]}),q&&e.jsx("p",{role:"alert",className:"-mt-2 text-end text-[13px] leading-[18px] text-danger",children:n("cloudBuy.openFailed",{name:p})})]})}function yt({team:t,step:a,slow:o}){const d=Math.max(0,R.findIndex(([u])=>u===a)),s=t??n("cloudBuy.team.unnamed");return e.jsxs("div",{"data-cloud-add":"team-starting","data-cloud-setup":a??"reserving",className:z,children:[e.jsx(U,{title:n("cloudBuy.team.setupTitle"),sub:n("cloudBuy.team.setupSub")}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(Ae,{value:d/R.length,label:n("cloudBuy.setup.progress")}),e.jsx(fe,{label:n("cloudBuy.setup.progress"),items:R.map(([u,p],v)=>({key:u,title:n(p,{name:s}),state:v<d?"done":v===d?"now":"next"}))}),o&&e.jsx("p",{role:"status",className:"px-3 text-[13px] leading-[18px] text-ink-secondary",children:n("cloudHome.slow")})]})]})}function gt({name:t,busy:a,openFailed:o,onOpen:d}){return e.jsxs("div",{"data-cloud-add":"team-ready",className:z,children:[e.jsx(U,{title:n("cloudBuy.team.readyTitle"),sub:n("cloudBuy.team.readySub",{name:t})}),e.jsx("p",{className:"text-[13px] leading-[18px] text-ink-tertiary",children:n("cloudBuy.ready.hint",{name:t})}),e.jsx("div",{className:se,children:e.jsx("button",{type:"button","data-autofocus":!0,className:X,disabled:a,onClick:d,children:n("cloudBuy.setup.open",{name:t})})}),o&&e.jsx("p",{role:"alert",className:"-mt-2 text-end text-[13px] leading-[18px] text-danger",children:n("cloudBuy.openFailed",{name:t})})]})}function ht({view:t,ui:a,actions:o}){switch(t.kind){case"checking":return e.jsx(ie,{kind:"checking",line:null,onClose:o.close});case"unreachable":return e.jsx(ie,{kind:"unreachable",line:n("cloudAdd.unreachable"),onRetry:o.retry,onClose:o.close});case"error":return e.jsx(ie,{kind:`error-${t.reason}`,line:n(t.reason==="rate-limited"?"cloudAdd.rateLimited":"cloudAdd.failed"),onRetry:o.retry,onClose:o.close});case"offer":return e.jsx(ct,{offer:t.offer,current:a.current,now:a.now,busy:a.busy,signedOut:t.signedOut,notice:t.notice?n(t.notice==="code-expired"?"cloudAdd.codeExpired":t.notice==="signin-ended"?"cloudAdd.signInEnded":t.notice==="terms"?"cloudBuy.termsChanged":"cloudAdd.preparing"):null,onStart:o.start,onSignIn:o.signIn});case"sign-in":return e.jsx(rt,{phase:t.phase,email:a.email,code:a.code,profileEmail:a.profileEmail,busy:a.busy,now:a.now,onBack:o.back,onEmail:o.email,onSend:o.sendCode,onChangeEmail:o.changeEmail,onCode:o.code,onResend:o.resend,onBrowser:o.browser});case"signing-in":return e.jsx(dt,{code:t.code,checkout:t.checkout,busy:a.busy,trial:a.offerShown?!!Le(a.offerShown,a.chosen).trialDays:!1,onReopen:o.reopenBrowser,onCancel:o.cancelSignIn});case"waiting":return e.jsx(ft,{plan:t.plan,offer:a.offerShown,browser:t.browser,late:t.late,link:t.link,email:t.email,busy:a.busy,copied:a.copied,failed:a.payFailed,onReopen:o.reopenCheckout,onCopy:o.copyLink,onChangePlan:o.changePlan});case"starting":case"ready":return e.jsx(xt,{started:t,received:t.kind==="starting"&&t.received,step:t.kind==="starting"?t.step:null,slow:t.kind==="starting"&&t.slow,ready:t.kind==="ready",sleeps:et(t,a.offerShown),name:a.look.name,typed:a.look.typed,color:a.look.color,counting:a.counting,busy:a.busy,openFailed:a.openFailed,onName:o.name,onColor:o.color,onOpen:o.openCloud,onNotNow:o.notNow});case"has-cloud":return e.jsx(pt,{name:a.look.name,color:a.look.color,busy:a.busy,interest:a.interest,openFailed:a.openFailed,onInterest:o.interest,onOpen:o.openCloud});case"team-starting":return e.jsx(yt,{team:t.team,step:t.step,slow:t.slow});case"team-ready":return e.jsx(gt,{name:t.team.name,busy:a.busy,openFailed:a.openFailed,onOpen:()=>o.openTeam(t.team.id)});case"settings":return null}}const bt={offer:"max-w-[920px]",starting:"max-w-[720px]",ready:"max-w-[720px]"};function Be({kind:t,staging:a,onClose:o,children:d}){return e.jsx("div",{className:"ui-scrim fixed inset-0 z-[60] flex items-center justify-center p-4 sm:p-6",onMouseDown:s=>s.stopPropagation(),children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"cloud-add-title","data-cloud-add-dialog":!0,tabIndex:-1,className:ue(Ze,"group/sheet animate-pop-in relative max-h-full w-full overflow-y-auto overscroll-contain outline-none",bt[t]??"max-w-[540px]"),children:[e.jsx("button",{type:"button",onClick:o,"aria-label":n("cloudAdd.close"),className:ue(Xe,Qe,"absolute end-4 top-4 z-10"),children:e.jsx(Je,{size:16})}),a&&e.jsx(Ye,{className:"absolute end-14 top-[22px] z-10 group-has-[[data-night-card]]/sheet:bg-app"}),d]})})}const kt=["offer","checking","unreachable","waiting","sign-in","signing-in"],jt="button:not([disabled]):not([tabindex='-1']), input:not([disabled]):not([tabindex='-1']), [href], [tabindex='0']",St=t=>t.status==="connected"&&t.entitlement?.plan==="free"&&!t.purchase&&!t.machine,Nt=t=>t?.status==="connected"&&t.entitlement?.plan==="pro"&&t.entitlement.status==="active"?t.entitlement.tier??"pro":null;function Lt({now:t=Date.now}){const{state:a,dispatch:o}=ut(),d=a.cloudAdd,s=window.ogb?.remoteClient?.active?void 0:window.ogb?.cloudAccount,[u,p]=r.useState(null),[v,N]=r.useState(void 0),[k,I]=r.useState(null),[q,y]=r.useState(null),[E,A]=r.useState(!1),[M,_]=r.useState(!1),[C,i]=r.useState(!1),[w,j]=r.useState(!1),[$,Y]=r.useState(0),[Z,me]=r.useState([]),[b,h]=r.useState(null),[T,O]=r.useState({email:"",code:""}),[B,ee]=r.useState(null),[F,P]=r.useState(null),[H,S]=r.useState(null),[,Ie]=r.useState(0),[xe,le]=r.useState(!1),[Te,ae]=r.useState(!1),[Oe,Fe]=r.useState(!1),L=!!(d&&s),oe=a.config?.profile?.email?.trim()||null,de=ot();r.useEffect(()=>{if(!L||!s)return;let l=!0,c=!1;const g=s.onState(x=>{c=!0,l&&p(x)});return s.state().then(x=>{l&&!c&&p(x)}).catch(()=>{}),()=>{l=!1,g()}},[L,s]);const m=L?We(u,v,{now:t(),error:q,choosing:M,conflict:E,signIn:b,arrived:xe,terms:Te}):null,ye=L&&m&&kt.includes(m.kind)&&u?`${u.status}:${JSON.stringify(u.offer??null)}:${$}`:null;r.useEffect(()=>{if(!ye||!s?.offer)return;let l=!0;return s.offer().then(c=>{l&&N(c)},()=>{l&&N(null)}),()=>{l=!1}},[ye,s]);const re=n("cloudSetup.myCloud"),K={typed:B?.typed??re,color:B?.color??we,name:Ve(B?.typed??re,re)},D=()=>{b&&s?.signInCancel?.().catch(()=>{}),o({type:"closeCloudAdd"}),y(null),A(!1),_(!1),j(!1),me([]),I(null),h(null),O({email:"",code:""}),ee(null),P(null),S(null),le(!1),ae(!1)};r.useEffect(()=>{if(!L)return;const l=document.activeElement,c=l&&l!==document.body&&typeof l.focus=="function"?l:null;d?.signIn&&(h({step:"email",intent:!1,problem:null}),O({email:oe??"",code:""}));const g=x=>{if(x.key==="Escape"){x.preventDefault(),D();return}if(x.key!=="Tab")return;const V=[...document.querySelector("[data-cloud-add-dialog]")?.querySelectorAll(jt)??[]];if(!V.length)return;x.preventDefault();const Ne=V.indexOf(document.activeElement);V[Ne===-1?0:(Ne+(x.shiftKey?-1:1)+V.length)%V.length].focus()};return window.addEventListener("keydown",g,!0),(document.querySelector("#cloud-add-title")??document.querySelector("[data-cloud-add-dialog]"))?.focus(),()=>{window.removeEventListener("keydown",g,!0),c?.isConnected&&c.focus()}},[L]),r.useEffect(()=>{if(!(!L||!s?.sheet||de))return s.sheet(!0).catch(()=>{}),()=>{s.sheet?.(!1).catch(()=>{})}},[L,s,de]);const f=m?.kind??null,te=m?.kind==="sign-in"?`sign-in-${m.phase.step}`:f;r.useEffect(()=>{!te||te==="checking"||te==="settings"||document.activeElement?.closest?.("[data-cloud-add-dialog]")||(document.querySelector("[data-cloud-add-dialog] [data-autofocus]")??document.querySelector("#cloud-add-title"))?.focus()},[te]),r.useEffect(()=>{(f==="waiting"||f==="starting"||f==="ready")&&!xe&&le(!0),(f==="ready"||f==="team-ready")&&s?.readySeen?.().catch(()=>{})},[f]),r.useEffect(()=>{if(!f||!d)return;if(f==="settings"){D(),o({type:"toggleAppSettings",open:!0,section:"cloudAccount"});return}if(f==="checking")return;const l=Z.length===0;l&&J("cloud_dialog_shown",{source:d.source}),["starting","ready"].includes(f)&&Z.includes(f),(l||!Z.includes(f))&&me([...Z,f])},[f]),r.useEffect(()=>{if(!f||!["starting","ready","has-cloud"].includes(f)||B||!s?.look)return;let l=!0;return s.look().then(c=>{l&&ee({typed:c.name,color:Ge(c.color)??we,dirty:f!=="has-cloud"})},()=>{}),()=>{l=!1}},[f]),r.useEffect(()=>{if(!B?.dirty||!s?.setLook)return;const l=setTimeout(()=>{s.setLook?.(K.name,B.color).catch(()=>{})},400);return()=>clearTimeout(l)},[B?.typed,B?.color]),r.useEffect(()=>{f!=="ready"||F!==null||P(!de&&typeof document.hasFocus=="function"&&document.hasFocus()?3:"off")},[f]);const ge=b?.step==="code"?b.resendAt:0;r.useEffect(()=>{if(!ge||ge<=t())return;const l=setTimeout(()=>Ie(t()),1e3);return()=>clearTimeout(l)}),r.useEffect(()=>{if(H!=="copied")return;const l=setTimeout(()=>S(null),2500);return()=>clearTimeout(l)},[H]);const ne=l=>{C||(i(!0),j(!1),l().catch(()=>y("failed")).finally(()=>i(!1)))},he=()=>{C||!s||(i(!0),j(!1),P("done"),(async()=>{B?.dirty&&s.setLook&&await s.setLook(K.name,B.color).catch(()=>{}),await s.connectHome()})().then(()=>D(),()=>j(!0)).finally(()=>i(!1)))},De=l=>{C||!s?.openTeam||(i(!0),j(!1),s.openTeam(l).then(()=>D(),()=>j(!0)).finally(()=>i(!1)))};r.useEffect(()=>{if(typeof F!="number")return;const l=setTimeout(()=>{F>1?P(F-1):he()},1e3);return()=>clearTimeout(l)},[F]);const be=typeof F=="number";if(r.useEffect(()=>{if(!be)return;const l=()=>P("off");return window.addEventListener("blur",l),()=>window.removeEventListener("blur",l)},[be]),!L||!m||!d||!s||m.kind==="settings")return null;if(m.kind==="has-cloud"&&u?.status==="connected"&&u.clouds&&window.ogb?.cloudAdd&&(u.addCloud?.canAdd!==!1||u.adding&&!u.adding.done))return e.jsx(Be,{kind:Oe?"offer":"has-cloud",staging:u.staging===!0,onClose:D,children:e.jsx(at,{onClose:D,onFirstCloud:()=>{},onWide:Fe,source:d.source})});const W=v??null,ke=()=>m.kind==="waiting"&&!k?m.plan:W?Le(W,k).tier:null,ce=async l=>{if(!l||!s.checkout){y("failed");return}W?.plans.find(x=>x.tier===l)?.trialDays;const c=await s.checkout(l,d.source),g=c.outcome;p(c.state),g==="opened"||g==="signing-in"?(_(!1),y(null),A(!1),S(null),ae(!1),J("cloud_checkout_opened",{source:d.source})):g==="rate-limited"?y("rate-limited"):g==="failed"?y("failed"):A(!0)},je=l=>{h({step:"email",intent:l,problem:null}),O({email:T.email||oe||"",code:""})},Se=()=>{if(C||!s.signInStart||!b||b.step==="done")return;const l=b;i(!0),s.signInStart(T.email).then(c=>{c.outcome==="sent"?(h({step:"code",intent:l.intent,email:c.email,resendAt:c.resendAt,problem:null,triesLeft:null,...c.signupOpen===!1?{signupOpen:!1}:{}}),O({email:c.email,code:""}),J("cloud_signin",{source:d.source})):h({...l,problem:c.outcome})},()=>h({...l,problem:"failed"})).finally(()=>i(!1))},_e=l=>{if(!s.signInVerify||b?.step!=="code")return;const c=b,g=c.intent?ke():null;i(!0),(async()=>{try{const x=await s.signInVerify(l);if(x.outcome!=="signed-in"){O({email:T.email,code:""}),h({...c,problem:x.outcome,triesLeft:x.outcome==="wrong-code"?x.triesLeft:null});return}p(x.state),le(!0),J("cloud_signin",{step:"signed_in",source:d.source}),g&&St(x.state)&&(tt(W,x.state.offer,g)?(h({step:"done",intent:!0}),await ce(g)):(ae(!0),I(g))),h(null),O({email:T.email,code:""})}catch{h({...c,problem:"failed",triesLeft:null})}finally{i(!1)}})()},Re={start:l=>{if(I(l),A(!1),m.kind==="offer"&&m.signedOut&&s.signInStart){je(!0);return}ne(()=>ce(l))},signIn:()=>je(!1),back:()=>{h(null),s.signInCancel?.().catch(()=>{})},email:l=>O({email:l,code:T.code}),sendCode:Se,changeEmail:()=>{b&&(h({step:"email",intent:b.intent,problem:null}),s.signInCancel?.().catch(()=>{}))},code:l=>{const c=it(l);O({email:T.email,code:c}),c.length===8&&!C&&_e(c)},resend:Se,browser:()=>ne(async()=>{const l=b?.intent?ke():null;h(null),await s.signInCancel?.().catch(()=>{}),J("cloud_signin",{source:d.source}),l?await ce(l):p(await s.begin())}),reopenBrowser:()=>ne(async()=>p(await s.reopen())),cancelSignIn:()=>ne(async()=>p(await s.cancel())),reopenCheckout:()=>{if(m.kind!=="waiting"||C)return;i(!0),S(null),(s.reopenCheckout?s.reopenCheckout(m.plan,d.source):s.checkout(m.plan,d.source)).then(c=>{p(c.state),c.outcome!=="opened"&&S("pay-failed")},()=>S("pay-failed")).finally(()=>i(!1))},copyLink:()=>{s.copyCheckoutLink?.().then(l=>S(l?"copied":"pay-failed"),()=>S("pay-failed"))},changePlan:()=>{I(m.kind==="waiting"?m.plan:k),_(!0),S(null)},retry:()=>{y(null),A(!1),N(void 0),Y($+1)},name:l=>ee({typed:l,color:K.color,dirty:!0}),color:l=>ee({typed:K.typed,color:l,dirty:!0}),openCloud:he,openTeam:De,notNow:()=>P("off"),interest:()=>{C||!s.interest||(i(!0),s.interest().then(()=>S("interest-sent"),()=>S("interest-failed")).finally(()=>i(!1)))},close:D},Pe={chosen:k,current:Nt(u),offerShown:W,now:t(),busy:C,openFailed:w,email:T.email,code:T.code,profileEmail:oe,look:K,counting:typeof F=="number"?F:null,copied:H==="copied",payFailed:H==="pay-failed",interest:H==="interest-sent"?"sent":H==="interest-failed"?"failed":null};return e.jsx(Be,{kind:m.kind,staging:u?.staging===!0,onClose:D,children:e.jsx(ht,{view:m,ui:Pe,actions:Re})})}export{Lt as CloudAddDialog,ht as CloudAddPanel,Be as CloudAddSheet};
@@ -1 +0,0 @@
1
- import{j as e,t as a,a as N,r as R}from"./styles-Cbtcp5Re.js";import{a6 as F,a7 as S,x as L,S as z,a8 as y,a9 as b,aa as A,ab as M,ac as w,ad as k,ae as P,af as E,ag as $,u as I,w as B,F as O,ah as v,ai as T,aj as D,ak as C,al as H,am as W,an as X}from"./App-CGZnP4z7.js";import{a as _,R as q}from"./RoutinesPage-C8QjVdJH.js";import{L as G,P as J,d as K}from"./PlacesRail-COZEZH0n.js";import{C as Q}from"./MenuMotion-CtV49YrJ.js";function U({routines:t,runs:r,bots:p,pausedBots:c,loading:o,error:d,onOpen:l,onLogs:n,onToggle:x}){const u=[...t].sort((s,i)=>Number(i.enabled)-Number(s.enabled)||(s.nextRunAt??1/0)-(i.nextRunAt??1/0)||s.name.localeCompare(i.name));return e.jsxs("div",{className:"space-y-3","aria-label":a("routines.list"),children:[d&&e.jsx("div",{role:"alert",className:"rounded-lg bg-danger/10 p-3 text-[12px] text-danger",children:a("routines.loadError")}),o&&e.jsxs("p",{role:"status",className:"flex items-center gap-2 p-3 text-[12px] text-ink-secondary",children:[e.jsx(G,{size:14,className:"animate-spin"}),a("routines.loading")]}),!o&&!d&&u.length===0&&e.jsxs("div",{className:"rounded-xl border border-dashed border-hairline/50 p-5 text-center text-[13px] text-ink-secondary",children:[e.jsx(_,{size:20,className:"mx-auto mb-2 opacity-60"}),a("routines.empty")]}),u.map(s=>{const i=F(s.id,r),m=i&&(i.attention?"attention":i.error?"error":i.output?"output":null),h=p?.find(g=>g.id===s.botId),f=x!==void 0&&!S(s);return e.jsxs("article",{className:"rounded-xl border border-hairline/40 bg-card p-3.5","aria-label":s.name,children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>l(s),className:"min-w-0 flex-1 text-left hover:text-accent",children:[e.jsx("span",{className:"block truncate text-[13px] font-semibold text-ink",children:s.name}),e.jsxs("span",{className:"mt-1 block text-[12px] leading-relaxed text-ink-secondary",children:[h&&`${h.name} · `,L(s.schedule)]})]}),f?e.jsx(z,{checked:s.enabled,"aria-label":a("routines.toggle",{name:s.name}),onClick:()=>x(s)}):e.jsx("span",{className:N("shrink-0 rounded-full bg-inset px-2 py-0.5 text-[10px]",s.enabled&&s.nextRunAt!=null?"text-accent":"text-ink-secondary"),children:y(s)})]}),(f||b(s)!==y(s))&&e.jsx("div",{className:"mt-2 text-[12px] text-ink-secondary",children:b(s)}),e.jsxs("div",{className:"mt-1 flex items-start justify-between gap-2",children:[e.jsx("div",{className:"min-w-0 text-[12px]",children:i?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:M(i),children:a("routines.latestRun",{status:A(i)})}),e.jsx("span",{className:"block text-[11px] text-ink-secondary",children:w(i.finishedAt??i.startedAt??i.scheduledFor)})]}):e.jsx("span",{className:"text-ink-secondary",children:a("routines.neverRun")})}),e.jsxs("button",{type:"button",onClick:()=>n(s),"aria-label":a("routines.logsFor",{name:s.name}),className:"flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-[11px] text-ink-secondary hover:bg-raised hover:text-ink",children:[e.jsx(k,{size:12}),a("routines.logs")]})]}),i&&m&&e.jsx("p",{className:N("mt-2 line-clamp-2 whitespace-pre-wrap text-[12px] leading-relaxed",i.error?"text-danger":"text-ink-secondary"),children:P(i,m)}),!!s.failureStreak&&e.jsx("p",{className:"mt-2 text-[12px] text-danger",children:a("routines.failureStreak",{count:s.failureStreak})}),s.weekRuns&&e.jsx("p",{className:"mt-2 text-[12px] text-ink-secondary",children:a(s.weekRuns.total===1?"routines.weekRunsOne":"routines.weekRuns",s.weekRuns)}),s.warning&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-warning",children:s.warning}),s.enabled&&c?.includes(s.botId)&&e.jsxs("p",{className:"mt-2 text-[12px] leading-relaxed text-warning","data-routine-bot-paused":"",children:[a("routines.botPaused")," ",e.jsx("button",{type:"button",className:"cursor-pointer text-accent hover:underline",onClick:()=>E("paused"),children:a("routines.botPausedSwap")})]}),s.heldFor&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-ink-secondary",children:$(s)}),!!s.skippedRuns&&e.jsxs("p",{className:"mt-2 text-[12px] text-ink-secondary",children:[a("routines.skippedRuns",{count:s.skippedRuns}),s.lastSkippedAt!=null&&e.jsxs(e.Fragment,{children:[" · ",a("routines.lastSkipped",{date:w(s.lastSkippedAt)})]})]})]},s.id)})]})}function le({bot:t,routines:r,runs:p,defaultRunOn:c}){const{state:o,dispatch:d}=I(),[l,n]=R.useState(null);return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{size:16,className:"text-accent"}),e.jsx("h2",{className:"min-w-0 flex-1 text-[15px] font-medium text-ink",children:a("computer.tab.routines")}),e.jsx("span",{className:"text-[12px] text-ink-secondary",children:r.length})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>n("new"),className:"flex flex-1 items-center justify-center gap-1.5 rounded-lg bg-accent px-3 py-2 text-[12px] font-medium text-white hover:brightness-110",children:[e.jsx(J,{size:14}),a("computer.routines.create")]}),e.jsxs("button",{type:"button",onClick:()=>d({type:"showRoutines",section:"logs",botId:t.id}),className:"flex items-center gap-1.5 rounded-lg bg-control px-3 py-2 text-[12px] text-ink hover:bg-raised-hover",children:[e.jsx(k,{size:13}),a("routines.logs")]})]})]}),e.jsx(U,{routines:r,runs:p,pausedBots:o.config?.pausedBots,loading:o.routinesLoadState==="loading"&&r.length===0,error:o.routinesLoadState==="error",onOpen:n,onLogs:x=>d({type:"showRoutines",section:"logs",botId:t.id,routineId:x.id}),onToggle:x=>d({type:"updateRoutine",routineId:x.id,patch:{enabled:!x.enabled}})}),e.jsxs("button",{type:"button",onClick:()=>d({type:"showRoutines",section:"schedule",view:"list",botId:t.id}),className:"self-start text-[12px] text-accent hover:underline",children:[a("computer.routines.openTitle")," ",e.jsx(Q,{size:14,"aria-hidden":"true",className:"inline align-[-2px] rtl:-scale-x-100"})]}),l&&e.jsx(q,{routine:l==="new"?void 0:l,bots:[t],lockedBotId:t.id,defaultRunOn:c,onClose:()=>n(null)},t.id)]})}const V=20;function Y(t,r=V){const p=new Set,c=[],o=C(t);for(let d=o.length-1;d>=0&&c.length<r;d-=1){const l=o[d].digest?.files;if(l){for(const n of l.deleted)p.add(n);for(const n of[...l.added,...l.changed])if(!p.has(n)&&(p.add(n),c.push(n),c.length>=r))break}}return c}function Z(t){const r=new Map,p=t.tasks?.find(n=>n.threadId===t.threadId),c=p?.cwd===void 0?t.cwd:p.cwd,o=c&&(/^[a-z]:[\\/]/i.test(c)||c.startsWith("\\\\")),d=n=>o?n.replace(/\\/g,"/"):n,l=typeof c=="string"?`${d(c).replace(/\/+$/,"")}/`:void 0;for(const n of[...C(t)].reverse()){if(n.role!=="bot"||n.kind!=="text")continue;const x=H(n.attachments),u=[...x.files,...W(n.text??"",[...x.images,...x.files.map(s=>s.path)])];for(const s of u){const i=s.private?s.path:X(s.path),m={file:s,message:{threadId:t.threadId,messageId:n.id}},h=d(i),f=l&&(o?h.slice(0,l.length).toLowerCase()===l.toLowerCase():h.startsWith(l)),g=[i,...f?[h.slice(l.length)]:[]];i.startsWith("./")&&g.push(i.replace(/^(\.\/)+/,""));for(const j of g)r.has(j)||r.set(j,m)}}return r}function ee(t){const r=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return r<0?{name:t,folder:""}:{name:t.slice(r+1),folder:t.slice(0,r)}}function re({bot:t}){const{dispatch:r}=I(),{capabilities:p}=K(),c=p.host.homeDir,d=t.tasks?.find(u=>u.threadId===t.threadId)?.cwd,l=d===void 0?t.cwd:d,n=Y(t),x=R.useMemo(()=>Z(t),[t.messages,t.activeLeafId,t.threadId,t.tasks,t.cwd]);return e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 pb-5","data-testid":"computer-files",children:[e.jsxs("div",{className:"mt-2 rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:a("computer.files.folder")}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx(O,{size:15,className:"shrink-0 text-ink-secondary","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-ink",title:l??void 0,children:l?v(l,c):l===null?a("computer.files.homeFolder"):a("computer.files.privateFolder",{name:t.name})}),e.jsx("button",{type:"button",onClick:()=>{r({type:"toggleComputer",open:!1}),T(r,"access",{page:"folder"})},className:"shrink-0 rounded-lg bg-control px-2.5 py-1 text-[12px] text-ink hover:bg-raised-hover",children:a(d===void 0?"computer.files.changeFolder":"computer.files.changeDefaultFolder")})]}),d!==void 0&&e.jsx("p",{className:"mt-2 text-[12px] leading-5 text-ink-secondary",children:a("computer.files.pinnedFolderHint")})]}),e.jsxs("div",{className:"mt-3 rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:a("computer.files.recent")}),n.length===0?e.jsx("p",{className:"mt-2 text-[12px] leading-5 text-ink-secondary",children:a("computer.files.empty",{name:t.name})}):e.jsx("ul",{className:"mt-2 flex flex-col gap-1",children:n.map(u=>{const{name:s,folder:i}=ee(u),m=x.get(u);return e.jsxs("li",{className:"min-w-0 rounded-lg py-1",title:u,children:[m?e.jsx(D,{file:{...m.file,name:s},message:m.message,linked:m.file.linked,className:"w-full max-w-none"},`${m.message.threadId}:${m.message.messageId}:${m.file.path}`):e.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-2.5 py-2",title:a("computer.files.notSharedHint"),children:[e.jsx(k,{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:s}),e.jsx("span",{className:"shrink-0 text-[11px] text-ink-tertiary",children:a("computer.files.notShared")})]}),i&&e.jsx("div",{className:"mt-1 truncate px-2.5 text-[11px] text-ink-tertiary",children:v(i,c)})]},u)})})]})]})}export{re as C,le as R,U as a,Y as r,Z as s};