@xopcai/xopc 0.0.122 → 0.0.124

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 (273) hide show
  1. package/README.md +28 -11
  2. package/README.zh-CN.md +28 -11
  3. package/dist/browser-ext/manifest.json +1 -1
  4. package/dist/extensions/telegram/xopc.extension.json +1 -1
  5. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CK3s5cJo.js → agent-avatar-dicebear-B5uSVAyJ.js} +1 -1
  6. package/dist/gateway/static/root/assets/agents-BjIxt67Z.js +2 -0
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-CWsNHtTs.js → app-management-settings-panel-CYCONLIL.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-C4b8y6iZ.js → appearance-settings-Clw3ryKg.js} +1 -1
  9. package/dist/gateway/static/root/assets/apps-page-QICTeGjX.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-DAtNW3Ia.js → archive-plugin-CXUGRp2i.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-Dm-RY54y.js → attachment-load-Cmiub3Wg.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automation-suggestion-card-BKHewSVT.js → automation-suggestion-card-CU0-4nQ-.js} +1 -1
  13. package/dist/gateway/static/root/assets/automations-page-Car-jtiz.js +1 -0
  14. package/dist/gateway/static/root/assets/{binary-plugins-BG6Xnk71.js → binary-plugins-0Izz-N3p.js} +1 -1
  15. package/dist/gateway/static/root/assets/{block-editor-DfndiO3h.js → block-editor-C1Kv0IkJ.js} +28 -28
  16. package/dist/gateway/static/root/assets/browser-settings-page-CMeBJzlS.js +8 -0
  17. package/dist/gateway/static/root/assets/{capability-presets-api-Cx93GLdw.js → capability-presets-api-BmQTM9Il.js} +1 -1
  18. package/dist/gateway/static/root/assets/capability-presets-settings-panel-DZEJEoCF.js +1 -0
  19. package/dist/gateway/static/root/assets/{channel-recipient-api-DdPTtEs8.js → channel-recipient-api-BeA2aVor.js} +1 -1
  20. package/dist/gateway/static/root/assets/channels-settings-kkW-xFau.js +1 -0
  21. package/dist/gateway/static/root/assets/connectors-page-BvaQvO5F.js +2 -0
  22. package/dist/gateway/static/root/assets/{directory-picker-path-field-D835EHJd.js → directory-picker-path-field-2rjzUu57.js} +1 -1
  23. package/dist/gateway/static/root/assets/{dreaming-settings-CCa1F7Fg.js → dreaming-settings-DnHO686d.js} +1 -1
  24. package/dist/gateway/static/root/assets/{extension-debug-page-W2ITCPSA.js → extension-debug-page-BGLRuWVN.js} +1 -1
  25. package/dist/gateway/static/root/assets/{extension-page-DrvUytvn.js → extension-page-D978ePp9.js} +1 -1
  26. package/dist/gateway/static/root/assets/{extension-settings-page-qM8aLT5u.js → extension-settings-page-B6Ih4Swx.js} +1 -1
  27. package/dist/gateway/static/root/assets/{fetch-ovkvM8KQ.js → fetch-BU5S0Sn7.js} +1 -1
  28. package/dist/gateway/static/root/assets/{gateway-config-api-BB3biuD0.js → gateway-config-api-BIPGwrl1.js} +1 -1
  29. package/dist/gateway/static/root/assets/gateway-settings-CMEA3r5u.js +1 -0
  30. package/dist/gateway/static/root/assets/{gateway-startup-retry-CanQ8UcR.js → gateway-startup-retry-Cd0Zz30N.js} +1 -1
  31. package/dist/gateway/static/root/assets/{goal-create-dialog-CNqNdEkQ.js → goal-create-dialog-B-KHKeXN.js} +1 -1
  32. package/dist/gateway/static/root/assets/goal-detail-page-BxrSoWdj.js +1 -0
  33. package/dist/gateway/static/root/assets/{goals-config-api-BBOX6mUl.js → goals-config-api-B95KdGMj.js} +1 -1
  34. package/dist/gateway/static/root/assets/{goals-page-BP1kfvWv.js → goals-page-BTJzIl28.js} +2 -2
  35. package/dist/gateway/static/root/assets/{goals-settings-Bh3A7OZV.js → goals-settings-BJyEuLLm.js} +1 -1
  36. package/dist/gateway/static/root/assets/heartbeat-settings-wkOjYNQT.js +1 -0
  37. package/dist/gateway/static/root/assets/index-BLaXr6Ev.css +1 -0
  38. package/dist/gateway/static/root/assets/index-c_9TVr_C.js +191 -0
  39. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-B4TKJHla.js → keyboard-shortcuts-settings-BT8T4DyC.js} +1 -1
  40. package/dist/gateway/static/root/assets/logs-page-CrxBJUgI.js +2 -0
  41. package/dist/gateway/static/root/assets/{markdown-split-DcFtdLci.js → markdown-split-Dv66bO2b.js} +1 -1
  42. package/dist/gateway/static/root/assets/{media-plugins-B6SmeLVB.js → media-plugins-BhIQU5yS.js} +1 -1
  43. package/dist/gateway/static/root/assets/messages-O6TAtdFC.js +3 -0
  44. package/dist/gateway/static/root/assets/models-hub-panel-DOOpz6y1.js +2 -0
  45. package/dist/gateway/static/root/assets/notes-page-Br16pK9v.js +1 -0
  46. package/dist/gateway/static/root/assets/notes-workbench-PSJAi0ZC.js +2 -0
  47. package/dist/gateway/static/root/assets/{preview-open-alternatives-C29O19s7.js → preview-open-alternatives-DGzet1d7.js} +1 -1
  48. package/dist/gateway/static/root/assets/project-detail-page-CIGGgKuw.js +1 -0
  49. package/dist/gateway/static/root/assets/projects-page-B2grhsBt.js +1 -0
  50. package/dist/gateway/static/root/assets/remote-access-hub-CXMORxBD.js +1 -0
  51. package/dist/gateway/static/root/assets/{save-bar-controls-B4ad9GfB.js → save-bar-controls-Cqgb-jqa.js} +1 -1
  52. package/dist/gateway/static/root/assets/{schedule-field-DdYncfLR.js → schedule-field-DVZcI8Yt.js} +1 -1
  53. package/dist/gateway/static/root/assets/{schema-form-BMTrDE-7.js → schema-form-Bj7sOxC8.js} +1 -1
  54. package/dist/gateway/static/root/assets/sessions-page-Bi2wkBzU.js +1 -0
  55. package/dist/gateway/static/root/assets/settings-advanced-gate-B1L3G4IA.js +1 -0
  56. package/dist/gateway/static/root/assets/{settings-collapsible-section-MwTW2eK4.js → settings-collapsible-section-BmXn-8N6.js} +1 -1
  57. package/dist/gateway/static/root/assets/{settings-form-section-Dg6LBbcr.js → settings-form-section-BnqYMWHR.js} +1 -1
  58. package/dist/gateway/static/root/assets/settings-page-BfRSHJmO.js +1 -0
  59. package/dist/gateway/static/root/assets/{settings-page-layout-BX4T-OLF.js → settings-page-layout-CdWZU1hd.js} +1 -1
  60. package/dist/gateway/static/root/assets/{setup-status-panel-Ce1pcFtR.js → setup-status-panel-CWtPM7RK.js} +1 -1
  61. package/dist/gateway/static/root/assets/{share-preview-page-DWE-dUFh.js → share-preview-page-IB1v8i86.js} +1 -1
  62. package/dist/gateway/static/root/assets/shares-settings-ngbsBgij.js +1 -0
  63. package/dist/gateway/static/root/assets/skill-reload-api-BIe442Gv.js +1 -0
  64. package/dist/gateway/static/root/assets/skills-page-BfchZRVa.js +2 -0
  65. package/dist/gateway/static/root/assets/{system-settings-panel-Dd6Y35Cm.js → system-settings-panel-BxQ384RC.js} +1 -1
  66. package/dist/gateway/static/root/assets/{typed-models-lib-Cx6XV5A2.js → typed-models-lib-BkcpvFYO.js} +1 -1
  67. package/dist/gateway/static/root/assets/{use-channel-catalog-D4sMbmy7.js → use-channel-catalog-Cd0FaEQ4.js} +1 -1
  68. package/dist/gateway/static/root/assets/{user-profile-settings-panel-Bx-hjMQc.js → user-profile-settings-panel-DQ7NnRSY.js} +1 -1
  69. package/dist/gateway/static/root/assets/{utils-D7b_vZnv.js → utils-YKhVf7Ka.js} +1 -1
  70. package/dist/gateway/static/root/assets/voice-api-key-field-C5Ov8Uk_.js +1 -0
  71. package/dist/gateway/static/root/assets/{workflow-run-setup-panel--TdohF5N.js → workflow-run-setup-panel-BYD9BtOq.js} +2 -2
  72. package/dist/gateway/static/root/assets/{workflow-start-dialog-B0lavx_o.js → workflow-start-dialog-BNJVCWoS.js} +1 -1
  73. package/dist/gateway/static/root/assets/workflows-page-BYF29ANm.js +18 -0
  74. package/dist/gateway/static/root/index.html +5 -5
  75. package/dist/package.js +1 -1
  76. package/dist/src/agent/agent-manager.d.ts +6 -1
  77. package/dist/src/agent/agent-manager.js +28 -12
  78. package/dist/src/agent/agent-manager.js.map +1 -1
  79. package/dist/src/agent/context/workspace-templates/AGENTS.md +1 -1
  80. package/dist/src/agent/embedded/xopc-tools-bridge.js +11 -7
  81. package/dist/src/agent/embedded/xopc-tools-bridge.js.map +1 -1
  82. package/dist/src/agent/lifecycle/progress.js +3 -1
  83. package/dist/src/agent/lifecycle/progress.js.map +1 -1
  84. package/dist/src/agent/lifecycle/timeout-wrapper.d.ts +2 -2
  85. package/dist/src/agent/lifecycle/timeout-wrapper.js +4 -4
  86. package/dist/src/agent/lifecycle/timeout-wrapper.js.map +1 -1
  87. package/dist/src/agent/memory/summary-generator.d.ts +1 -1
  88. package/dist/src/agent/memory/summary-generator.js +1 -2
  89. package/dist/src/agent/memory/summary-generator.js.map +1 -1
  90. package/dist/src/agent/middleware/index.d.ts +1 -1
  91. package/dist/src/agent/middleware/self-verify.d.ts +44 -14
  92. package/dist/src/agent/middleware/self-verify.js +214 -44
  93. package/dist/src/agent/middleware/self-verify.js.map +1 -1
  94. package/dist/src/agent/orchestration/agent-event-handler.js +57 -15
  95. package/dist/src/agent/orchestration/agent-event-handler.js.map +1 -1
  96. package/dist/src/agent/prompt/sections/tooling.js +18 -13
  97. package/dist/src/agent/prompt/sections/tooling.js.map +1 -1
  98. package/dist/src/agent/prompt/system-reminder.js +2 -2
  99. package/dist/src/agent/prompt/system-reminder.js.map +1 -1
  100. package/dist/src/agent/sandbox/sanitize-env-vars.d.ts +2 -2
  101. package/dist/src/agent/sandbox/sanitize-env-vars.js +2 -2
  102. package/dist/src/agent/sandbox/sanitize-env-vars.js.map +1 -1
  103. package/dist/src/agent/sandbox/types.d.ts +2 -2
  104. package/dist/src/agent/sandbox/types.js.map +1 -1
  105. package/dist/src/agent/service/btw-query.js +1 -1
  106. package/dist/src/agent/service/btw-query.js.map +1 -1
  107. package/dist/src/agent/service/process-direct-one-shot.js +6 -2
  108. package/dist/src/agent/service/process-direct-one-shot.js.map +1 -1
  109. package/dist/src/agent/service/process-direct-streaming.js +12 -7
  110. package/dist/src/agent/service/process-direct-streaming.js.map +1 -1
  111. package/dist/src/agent/service.js +2 -1
  112. package/dist/src/agent/service.js.map +1 -1
  113. package/dist/src/agent/skills/skill-tool-gating.js +1 -1
  114. package/dist/src/agent/skills/skill-tool-gating.js.map +1 -1
  115. package/dist/src/agent/starter-agents.js +9 -9
  116. package/dist/src/agent/starter-agents.js.map +1 -1
  117. package/dist/src/agent/tools/apply-patch.d.ts +25 -0
  118. package/dist/src/agent/tools/apply-patch.js +256 -0
  119. package/dist/src/agent/tools/apply-patch.js.map +1 -0
  120. package/dist/src/agent/tools/delegate-tool.d.ts +1 -1
  121. package/dist/src/agent/tools/delegate-tool.js +3 -3
  122. package/dist/src/agent/tools/delegate-tool.js.map +1 -1
  123. package/dist/src/agent/tools/exec-command.d.ts +30 -0
  124. package/dist/src/agent/tools/exec-command.js +224 -0
  125. package/dist/src/agent/tools/exec-command.js.map +1 -0
  126. package/dist/src/agent/tools/execute-code-tool.js +7 -4
  127. package/dist/src/agent/tools/execute-code-tool.js.map +1 -1
  128. package/dist/src/agent/tools/factory.d.ts +3 -3
  129. package/dist/src/agent/tools/factory.js +8 -9
  130. package/dist/src/agent/tools/factory.js.map +1 -1
  131. package/dist/src/agent/tools/goal-tool.d.ts +5 -1
  132. package/dist/src/agent/tools/goal-tool.js +8 -2
  133. package/dist/src/agent/tools/goal-tool.js.map +1 -1
  134. package/dist/src/agent/tools/index.d.ts +4 -3
  135. package/dist/src/agent/tools/index.js +5 -4
  136. package/dist/src/agent/tools/skills-tools.d.ts +1 -1
  137. package/dist/src/agent/tools/skills-tools.js.map +1 -1
  138. package/dist/src/agent/tools/update-plan-tool.d.ts +11 -0
  139. package/dist/src/agent/tools/update-plan-tool.js +72 -0
  140. package/dist/src/agent/tools/update-plan-tool.js.map +1 -0
  141. package/dist/src/agent/workflow/builtins/debug-incident.d.ts +1 -1
  142. package/dist/src/agent/workflow/builtins/debug-incident.js +1 -1
  143. package/dist/src/agent/workflow/builtins/debug-incident.js.map +1 -1
  144. package/dist/src/agent/workflow/builtins/pr-review.d.ts +1 -1
  145. package/dist/src/agent/workflow/builtins/pr-review.js +1 -1
  146. package/dist/src/agent/workflow/builtins/pr-review.js.map +1 -1
  147. package/dist/src/agent/workflow/builtins/release-check.d.ts +1 -1
  148. package/dist/src/agent/workflow/builtins/release-check.js +1 -1
  149. package/dist/src/agent/workflow/builtins/release-check.js.map +1 -1
  150. package/dist/src/agent/workflow/step-labels.js +7 -3
  151. package/dist/src/agent/workflow/step-labels.js.map +1 -1
  152. package/dist/src/chat-commands/agent-edit.js +1 -1
  153. package/dist/src/chat-commands/agent-edit.js.map +1 -1
  154. package/dist/src/chat-commands/builtins/goal.js +4 -1
  155. package/dist/src/chat-commands/builtins/goal.js.map +1 -1
  156. package/dist/src/chat-commands/builtins/review.d.ts +1 -0
  157. package/dist/src/chat-commands/builtins/review.js +167 -0
  158. package/dist/src/chat-commands/builtins/review.js.map +1 -0
  159. package/dist/src/chat-commands/index.d.ts +1 -0
  160. package/dist/src/chat-commands/index.js +3 -1
  161. package/dist/src/chat-commands/index.js.map +1 -1
  162. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  163. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  164. package/dist/src/config/agent-profile.js +1 -1
  165. package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
  166. package/dist/src/gateway/agent-builtin-tools.js +3 -2
  167. package/dist/src/gateway/agent-builtin-tools.js.map +1 -1
  168. package/dist/src/gateway/agents-admin.js +1 -1
  169. package/dist/src/gateway/chat-stream/mapper.d.ts +6 -0
  170. package/dist/src/gateway/chat-stream/mapper.js +149 -6
  171. package/dist/src/gateway/chat-stream/mapper.js.map +1 -1
  172. package/dist/src/gateway/chat-stream/protocol.d.ts +51 -1
  173. package/dist/src/gateway/hono/routes/commands-skills.js +21 -0
  174. package/dist/src/gateway/hono/routes/commands-skills.js.map +1 -1
  175. package/dist/src/gateway/hono/routes/index.js +2 -0
  176. package/dist/src/gateway/hono/routes/index.js.map +1 -1
  177. package/dist/src/gateway/hono/routes/lazy-bundles.js +1 -0
  178. package/dist/src/gateway/hono/routes/lazy-bundles.js.map +1 -1
  179. package/dist/src/gateway/hono/routes/projects.js +136 -14
  180. package/dist/src/gateway/hono/routes/projects.js.map +1 -1
  181. package/dist/src/gateway/hono/routes/search.d.ts +3 -0
  182. package/dist/src/gateway/hono/routes/search.js +47 -0
  183. package/dist/src/gateway/hono/routes/search.js.map +1 -0
  184. package/dist/src/gateway/security/dangerous-tools.js +1 -1
  185. package/dist/src/gateway/security/dangerous-tools.js.map +1 -1
  186. package/dist/src/infra/update-restart.js +1 -1
  187. package/dist/src/projects/index.d.ts +3 -0
  188. package/dist/src/projects/index.js +4 -1
  189. package/dist/src/projects/project-agent-suggestion.d.ts +14 -0
  190. package/dist/src/projects/project-agent-suggestion.js +19 -0
  191. package/dist/src/projects/project-agent-suggestion.js.map +1 -0
  192. package/dist/src/projects/project-kind.d.ts +13 -0
  193. package/dist/src/projects/project-kind.js +147 -0
  194. package/dist/src/projects/project-kind.js.map +1 -0
  195. package/dist/src/projects/project-service.d.ts +15 -0
  196. package/dist/src/projects/project-service.js +96 -3
  197. package/dist/src/projects/project-service.js.map +1 -1
  198. package/dist/src/projects/project-store.js +32 -8
  199. package/dist/src/projects/project-store.js.map +1 -1
  200. package/dist/src/projects/types.d.ts +4 -1
  201. package/dist/src/projects/workspace-project.d.ts +22 -0
  202. package/dist/src/projects/workspace-project.js +143 -0
  203. package/dist/src/projects/workspace-project.js.map +1 -0
  204. package/dist/src/review/review-git.d.ts +48 -0
  205. package/dist/src/review/review-git.js +333 -0
  206. package/dist/src/review/review-git.js.map +1 -0
  207. package/dist/src/review/review-types.d.ts +22 -0
  208. package/dist/src/review/review-types.js +29 -0
  209. package/dist/src/review/review-types.js.map +1 -0
  210. package/dist/src/session/session-context-for-llm.js +151 -0
  211. package/dist/src/session/session-context-for-llm.js.map +1 -1
  212. package/dist/src/storage/sqlite/migrations/021_projects_fts.sql +21 -0
  213. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  214. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  215. package/dist/src/storage/sqlite/migrations/runner.js.map +1 -1
  216. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  217. package/dist/src/storage/sqlite/schema.js +1 -1
  218. package/dist/src/tui/backends/embedded-backend.d.ts +8 -1
  219. package/dist/src/tui/backends/embedded-backend.js +60 -1
  220. package/dist/src/tui/backends/embedded-backend.js.map +1 -1
  221. package/dist/src/tui/backends/gateway-sse-backend.d.ts +9 -1
  222. package/dist/src/tui/backends/gateway-sse-backend.js +29 -0
  223. package/dist/src/tui/backends/gateway-sse-backend.js.map +1 -1
  224. package/dist/src/tui/components/assistant-message.js +35 -0
  225. package/dist/src/tui/components/assistant-message.js.map +1 -1
  226. package/dist/src/tui/tui-agent-events.js +25 -0
  227. package/dist/src/tui/tui-agent-events.js.map +1 -1
  228. package/dist/src/tui/tui-backend.d.ts +20 -0
  229. package/dist/src/tui/tui-commands.d.ts +1 -0
  230. package/dist/src/tui/tui-commands.js +110 -4
  231. package/dist/src/tui/tui-commands.js.map +1 -1
  232. package/dist/src/tui/tui-picker-overlay.d.ts +2 -0
  233. package/dist/src/tui/tui-picker-overlay.js +153 -1
  234. package/dist/src/tui/tui-picker-overlay.js.map +1 -1
  235. package/dist/src/tui/tui.js +36 -2
  236. package/dist/src/tui/tui.js.map +1 -1
  237. package/dist/src/workflows/service/workflow-run-service.js +1 -1
  238. package/dist/src/workflows/service/workflow-run-service.js.map +1 -1
  239. package/package.json +1 -1
  240. package/dist/gateway/static/root/assets/agents-SsQrj9B-.js +0 -2
  241. package/dist/gateway/static/root/assets/apps-page-CYb6fame.js +0 -1
  242. package/dist/gateway/static/root/assets/automations-page-DpOOq1nk.js +0 -1
  243. package/dist/gateway/static/root/assets/browser-settings-page-9nXxgh4u.js +0 -8
  244. package/dist/gateway/static/root/assets/capability-presets-settings-panel-D528_YFy.js +0 -1
  245. package/dist/gateway/static/root/assets/channels-settings-Ck-3h5lI.js +0 -1
  246. package/dist/gateway/static/root/assets/connectors-page-DL-fAqE_.js +0 -2
  247. package/dist/gateway/static/root/assets/gateway-settings-mmmnIH27.js +0 -1
  248. package/dist/gateway/static/root/assets/goal-detail-page-Ceu5zrN6.js +0 -1
  249. package/dist/gateway/static/root/assets/heartbeat-settings-YoYgKlfX.js +0 -1
  250. package/dist/gateway/static/root/assets/index-DdqSO9R2.js +0 -191
  251. package/dist/gateway/static/root/assets/index-jGB-2nI-.css +0 -1
  252. package/dist/gateway/static/root/assets/logs-page-BgVk5DvZ.js +0 -2
  253. package/dist/gateway/static/root/assets/messages-B5O4OIEo.js +0 -3
  254. package/dist/gateway/static/root/assets/models-hub-panel-BU0x8PGP.js +0 -2
  255. package/dist/gateway/static/root/assets/notes-page-D6JYVP4I.js +0 -1
  256. package/dist/gateway/static/root/assets/notes-workbench-mqRJYnJS.js +0 -2
  257. package/dist/gateway/static/root/assets/project-detail-page-DOTgzoeh.js +0 -1
  258. package/dist/gateway/static/root/assets/projects-page-DGUIb4y5.js +0 -1
  259. package/dist/gateway/static/root/assets/remote-access-hub-DVKKUj3u.js +0 -1
  260. package/dist/gateway/static/root/assets/sessions-page-BVbzUWxW.js +0 -1
  261. package/dist/gateway/static/root/assets/settings-advanced-gate-DrNNoSqE.js +0 -1
  262. package/dist/gateway/static/root/assets/settings-page-CMDqgeMR.js +0 -1
  263. package/dist/gateway/static/root/assets/shares-settings-aKSraR8l.js +0 -1
  264. package/dist/gateway/static/root/assets/skill-reload-api-CS-FU_B-.js +0 -1
  265. package/dist/gateway/static/root/assets/skills-page-BaF3u0LA.js +0 -2
  266. package/dist/gateway/static/root/assets/voice-api-key-field-CkhbRt1q.js +0 -1
  267. package/dist/gateway/static/root/assets/workflows-page-CZR05Bu_.js +0 -18
  268. package/dist/src/agent/tools/edit.d.ts +0 -14
  269. package/dist/src/agent/tools/edit.js +0 -132
  270. package/dist/src/agent/tools/edit.js.map +0 -1
  271. package/dist/src/agent/tools/shell.d.ts +0 -15
  272. package/dist/src/agent/tools/shell.js +0 -158
  273. package/dist/src/agent/tools/shell.js.map +0 -1
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-B5O4OIEo.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{a as s,c,i as l,n as u,o as d,t as f}from"./fetch-ovkvM8KQ.js";import{a as p,i as m}from"./vendor-swr-BIWyz7Rc.js";import{$i as h,Aa as g,Ba as _,Dr as v,Ds as y,Gs as b,H as x,Ic as S,Ko as C,Mi as w,No as T,Oo as E,Qa as D,Yt as O,aa as k,ar as A,ba as j,bo as M,cr as N,dc as P,dr as F,f as I,fr as L,ho as R,hs as z,ia as B,ir as V,jc as H,ji as U,ka as W,lr as G,mc as ee,mr as te,na as ne,no as K,nr as q,ns as re,oa as J,or as Y,pa as X,po as ie,pr as ae,ra as oe,rr as se,sr as ce,ta as le,tc as ue,ur as de,ut as fe,ya as pe,za as me,zs as he}from"./index-DdqSO9R2.js";import{t as ge}from"./settings-collapsible-section-MwTW2eK4.js";import{n as _e,r as ve,t as ye}from"./settings-form-section-Dg6LBbcr.js";import{t as be}from"./browser-BLJWD7WI.js";import{n as xe,r as Se,t as Ce}from"./settings-page-layout-BX4T-OLF.js";var Z=n(),Q=e(t(),1);function we(e,t){let{mutate:n}=p(),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(!1),l=(0,Q.useCallback)(async()=>{await Promise.all([n(`tunnel-pair-context`),n(`tunnel-pair`),n(`tunnel-status`),U()])},[n]);return{busy:r,error:a,confirmOpen:s,setConfirmOpen:c,runEnableLanPairing:(0,Q.useCallback)(async()=>{if(!(!e||r)){i(!0),o(null);try{let n=await Y();if(!n.ok)throw Error(`Failed to enable LAN pairing`);if(n.requiresRestart){let t=await q();if(!t.ok)throw Error(t.message??`Gateway restart failed`);if(!await se(e))throw Error(`Gateway did not come back online in time`)}let r=n.requiresRestart?await V():n.context;if(!r?.pairingReady)throw Error(`LAN pairing is still not ready after restart`);return await l(),t?.(r),c(!1),r}catch(e){return o(e instanceof Error?e.message:`Enable LAN pairing failed`),null}finally{i(!1)}}},[r,e,t,l]),clearError:()=>o(null)}}var $=r();function Te(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,me,`dark:border-edge`)}function Ee(e){let t=(0,Z.c)(122),{pairQr:n,gatewayToken:r,streamlined:s,lanOnly:c,onRefreshQr:l}=e,u=s===void 0?!1:s,d=c===void 0?!1:c,f=o(ke),p;t[0]===f?p=t[1]:(p=a(f),t[0]=f,t[1]=p);let m=p,h=m.tunnelSettings,g=d?m.remoteAccess.lan:null,y;t[2]!==m.clipboard.copyFailed||t[3]!==h.pairCopied||t[4]!==h.pairCopyLink?(y={copy:h.pairCopyLink,copied:h.pairCopied,copyFailed:m.clipboard.copyFailed},t[2]=m.clipboard.copyFailed,t[3]=h.pairCopied,t[4]=h.pairCopyLink,t[5]=y):y=t[5];let b=y,{tunnelActive:x,tunnelStatus:S,tunnelQr:C,pairContext:w,pairBaseUrl:T,setPairBaseUrl:D,applySuggestedPairUrl:O,applyCandidateUrl:k,resetPairBaseFromContext:A,baseOk:j,localhostWarn:M,pairingBlocked:N,deepLink:P,qrPayload:F,qrDataUrl:L,qrGenFailed:R,encoding:z}=n,B;t[6]===A?B=t[7]:(B=e=>{A(e.recommended.url)},t[6]=A,t[7]=B);let V=we(r,B),U,W,G,ee,te;if(t[8]!==k||t[9]!==O||t[10]!==j||t[11]!==V||t[12]!==r||t[13]!==g||t[14]!==d||t[15]!==M||t[16]!==l||t[17]!==T||t[18]!==w?.candidates||t[19]!==w?.recommended||t[20]!==N||t[21]!==D||t[22]!==u||t[23]!==h.pairBaseUrlHint||t[24]!==h.pairBaseUrlLabel||t[25]!==h.pairBaseUrlPlaceholder||t[26]!==h.pairBlockedLoopbackBody||t[27]!==h.pairBlockedNextSteps||t[28]!==h.pairBlockedTitle||t[29]!==h.pairCandidatesTitle||t[30]!==h.pairEnableLanButton||t[31]!==h.pairEnableLanEnabling||t[32]!==h.pairEnableLanSecurityAuditLink||t[33]!==h.pairInvalidBaseUrl||t[34]!==h.pairLocalhostWarning||t[35]!==h.pairSelectCandidateHint||t[36]!==h.pairSelectCandidateTitle||t[37]!==h.pairSubtitle||t[38]!==h.pairSuggestedLanLabel||t[39]!==h.pairTitle||t[40]!==h.pairTunnelActive||t[41]!==h.pairTunnelLanUrl||t[42]!==h.pairTunnelPublicUrl||t[43]!==h.pairUseSuggestedUrl||t[44]!==h.pairWaitingForTunnel||t[45]!==h.refreshQr||t[46]!==x||t[47]!==C||t[48]!==S?.publicUrl){te=Symbol.for(`react.early_return_sentinel`);bb0:{let e=w?.candidates.filter(Oe)??[],n=d?(e.find(De)?.url??e[0]?.url??``).trim():w?.recommended.url?.trim()??``,a=(d||!x)&&e.length>1,o=function(t){if(e.length===0)return null;let n=t===`amber`?`text-amber-950 dark:text-amber-100`:`text-fg`,r=t===`amber`?`text-amber-950/80 dark:text-amber-200/90`:`text-fg-muted`;return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:i(`text-xs font-medium`,r),children:a?h.pairSelectCandidateTitle:h.pairCandidatesTitle}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,className:i(`w-full rounded-md border px-2 py-1.5 text-left font-mono text-[11px] transition-colors`,t===`amber`?`border-amber-300/70 hover:bg-amber-100/80 dark:border-amber-800 dark:hover:bg-amber-950/50`:`border-edge hover:bg-surface-panel`,T.trim()===e.url&&`border-accent bg-accent/5`,n),onClick:()=>k(e.url),children:[e.label?`${e.label}: `:``,e.url]})},e.url))}),a?(0,$.jsx)(`p`,{className:i(`mt-1 text-[11px] leading-relaxed`,r),children:h.pairSelectCandidateHint}):null]})};if(U=u&&!d,U&&!x){let e;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ie,{className:`size-4 text-accent`,strokeWidth:1.75}),t[54]=e):e=t[54];let n;t[55]===h.pairTitle?n=t[56]:(n=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[e,h.pairTitle]}),t[55]=h.pairTitle,t[56]=n);let r;t[57]===h.pairWaitingForTunnel?r=t[58]:(r=(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:h.pairWaitingForTunnel}),t[57]=h.pairWaitingForTunnel,t[58]=r);let i;t[59]!==n||t[60]!==r?(i=(0,$.jsxs)(ye,{children:[n,r]}),t[59]=n,t[60]=r,t[61]=i):i=t[61],te=i;break bb0}let s=g?.pairTitle??h.pairTitle,c=d?g?.pairSubtitle??h.pairSubtitle:x?h.pairTunnelActive:h.pairSubtitle,f=!!(l&&(d||u&&x)),p=U?`mb-2`:`mb-3`,m;t[62]===p?m=t[63]:(m=i(`flex flex-wrap items-start justify-between gap-2`,p),t[62]=p,t[63]=m);let v;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(ie,{className:`size-4 text-accent`,strokeWidth:1.75}),t[64]=v):v=t[64];let y;t[65]===s?y=t[66]:(y=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[v,s]}),t[65]=s,t[66]=y);let b;t[67]!==U||t[68]!==c||t[69]!==h.pairSubtitle?(b=U?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:h.pairSubtitle}):(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:c}),t[67]=U,t[68]=c,t[69]=h.pairSubtitle,t[70]=b):b=t[70];let A;t[71]!==y||t[72]!==b?(A=(0,$.jsxs)(`div`,{children:[y,b]}),t[71]=y,t[72]=b,t[73]=A):A=t[73];let P;t[74]!==l||t[75]!==f||t[76]!==h.refreshQr?(P=f?(0,$.jsxs)(_,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>void l(),children:[(0,$.jsx)(E,{className:`size-4`}),h.refreshQr]}):null,t[74]=l,t[75]=f,t[76]=h.refreshQr,t[77]=P):P=t[77],t[78]!==m||t[79]!==A||t[80]!==P?(W=(0,$.jsxs)(`div`,{className:m,children:[A,P]}),t[78]=m,t[79]=A,t[80]=P,t[81]=W):W=t[81],G=N?(0,$.jsxs)(`div`,{className:`mb-3 space-y-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-3 dark:border-amber-900/50 dark:bg-amber-950/30`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-amber-950 dark:text-amber-100`,children:h.pairBlockedTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-amber-900 dark:text-amber-200`,children:h.pairBlockedLoopbackBody})]}),n?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-amber-950/80 dark:text-amber-200/90`,children:h.pairSuggestedLanLabel}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-amber-950 dark:text-amber-100`,children:n})]}),(0,$.jsx)(_,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,onClick:O,children:h.pairUseSuggestedUrl})]}):null,e.length>0?o(`amber`):null,(0,$.jsx)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:(0,$.jsxs)(_,{type:`button`,className:`w-full sm:w-auto`,disabled:V.busy||!r,onClick:()=>V.setConfirmOpen(!0),children:[V.busy?(0,$.jsx)(re,{className:`size-3.5 animate-spin`}):null,V.busy?h.pairEnableLanEnabling:h.pairEnableLanButton]})}),V.error?(0,$.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:V.error}):null,(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-amber-900 dark:text-amber-200`,children:d?g?.pairBlockedNextSteps??h.pairBlockedNextSteps:h.pairBlockedNextSteps}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(H,{to:`/settings/gateway`,className:`inline-block text-xs font-medium text-accent hover:underline`,children:h.pairEnableLanSecurityAuditLink}),d&&g?.pairPublicTabLink?(0,$.jsx)(H,{to:`/settings/remote-access?tab=public`,className:`inline-block text-xs font-medium text-accent hover:underline`,children:g.pairPublicTabLink}):null]})]}):null,ee=x&&!d?U?null:(0,$.jsxs)(`div`,{className:`mb-3 space-y-2 rounded-lg border border-edge bg-surface-panel px-3 py-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:h.pairTunnelPublicUrl}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-fg`,children:S?.publicUrl})]}),C?.lanUrl?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:h.pairTunnelLanUrl}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-fg`,children:C.lanUrl})]}):null]}):(0,$.jsxs)(`div`,{className:`mb-3 space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`tunnel-mobile-pair-base`,children:h.pairBaseUrlLabel}),(0,$.jsx)(`input`,{id:`tunnel-mobile-pair-base`,className:i(Te(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:n||h.pairBaseUrlPlaceholder,value:T,onChange:e=>D(e.target.value)}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:h.pairBaseUrlHint}),!j&&T.trim()?(0,$.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:h.pairInvalidBaseUrl}):null,M?(0,$.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:h.pairLocalhostWarning}):null,a?o(`neutral`):null]})}t[8]=k,t[9]=O,t[10]=j,t[11]=V,t[12]=r,t[13]=g,t[14]=d,t[15]=M,t[16]=l,t[17]=T,t[18]=w?.candidates,t[19]=w?.recommended,t[20]=N,t[21]=D,t[22]=u,t[23]=h.pairBaseUrlHint,t[24]=h.pairBaseUrlLabel,t[25]=h.pairBaseUrlPlaceholder,t[26]=h.pairBlockedLoopbackBody,t[27]=h.pairBlockedNextSteps,t[28]=h.pairBlockedTitle,t[29]=h.pairCandidatesTitle,t[30]=h.pairEnableLanButton,t[31]=h.pairEnableLanEnabling,t[32]=h.pairEnableLanSecurityAuditLink,t[33]=h.pairInvalidBaseUrl,t[34]=h.pairLocalhostWarning,t[35]=h.pairSelectCandidateHint,t[36]=h.pairSelectCandidateTitle,t[37]=h.pairSubtitle,t[38]=h.pairSuggestedLanLabel,t[39]=h.pairTitle,t[40]=h.pairTunnelActive,t[41]=h.pairTunnelLanUrl,t[42]=h.pairTunnelPublicUrl,t[43]=h.pairUseSuggestedUrl,t[44]=h.pairWaitingForTunnel,t[45]=h.refreshQr,t[46]=x,t[47]=C,t[48]=S?.publicUrl,t[49]=U,t[50]=W,t[51]=G,t[52]=ee,t[53]=te}else U=t[49],W=t[50],G=t[51],ee=t[52],te=t[53];if(te!==Symbol.for(`react.early_return_sentinel`))return te;let ne;t[82]===h.pairSecurityNote?ne=t[83]:(ne=(0,$.jsx)(`p`,{className:`mb-3 text-xs text-fg-subtle`,children:h.pairSecurityNote}),t[82]=h.pairSecurityNote,t[83]=ne);let K;t[84]!==b||t[85]!==P||t[86]!==z||t[87]!==N||t[88]!==L||t[89]!==R||t[90]!==h.pairEncoding||t[91]!==h.pairImageError||t[92]!==h.pairQrDisabled?(K=P?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 sm:items-start`,children:[L&&!R?(0,$.jsx)(`img`,{src:L,alt:``,className:`size-56 rounded-lg border border-edge-subtle bg-white object-contain p-3 dark:border-edge`}):null,z?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:h.pairEncoding}):null,R?(0,$.jsx)(`p`,{className:`text-center text-sm text-fg-muted sm:text-left`,children:h.pairImageError}):null,(0,$.jsx)(v,{text:P,labels:b})]}):N?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:h.pairQrDisabled}):null,t[84]=b,t[85]=P,t[86]=z,t[87]=N,t[88]=L,t[89]=R,t[90]=h.pairEncoding,t[91]=h.pairImageError,t[92]=h.pairQrDisabled,t[93]=K):K=t[93];let q;t[94]!==U||t[95]!==F||t[96]!==h.deeplinkTitle?(q=F&&!U?(0,$.jsxs)(`details`,{className:`mt-3 rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-muted`,children:h.deeplinkTitle}),(0,$.jsx)(`p`,{className:`mt-2 break-all font-mono text-[10px] leading-relaxed text-fg-subtle`,children:F})]}):null,t[94]=U,t[95]=F,t[96]=h.deeplinkTitle,t[97]=q):q=t[97];let J;t[98]!==U||t[99]!==h.pairMobileProbeHint||t[100]!==h.pairSchemeHint?(J=U?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`mt-3 break-all font-mono text-[10px] leading-relaxed text-fg-subtle`,children:h.pairSchemeHint}),(0,$.jsx)(`p`,{className:`mt-1 text-[10px] leading-relaxed text-fg-subtle`,children:h.pairMobileProbeHint})]}),t[98]=U,t[99]=h.pairMobileProbeHint,t[100]=h.pairSchemeHint,t[101]=J):J=t[101];let Y,X;t[102]===V?(Y=t[103],X=t[104]):(Y=()=>void V.runEnableLanPairing(),X=()=>{V.busy||V.setConfirmOpen(!1)},t[102]=V,t[103]=Y,t[104]=X);let ae;t[105]!==V.confirmOpen||t[106]!==h.consentCancel||t[107]!==h.pairEnableLanButton||t[108]!==h.pairEnableLanConfirmBody||t[109]!==h.pairEnableLanConfirmTitle||t[110]!==Y||t[111]!==X?(ae=(0,$.jsx)(I,{open:V.confirmOpen,title:h.pairEnableLanConfirmTitle,description:h.pairEnableLanConfirmBody,confirmLabel:h.pairEnableLanButton,cancelLabel:h.consentCancel,onConfirm:Y,onCancel:X}),t[105]=V.confirmOpen,t[106]=h.consentCancel,t[107]=h.pairEnableLanButton,t[108]=h.pairEnableLanConfirmBody,t[109]=h.pairEnableLanConfirmTitle,t[110]=Y,t[111]=X,t[112]=ae):ae=t[112];let oe;return t[113]!==ne||t[114]!==K||t[115]!==q||t[116]!==J||t[117]!==ae||t[118]!==W||t[119]!==G||t[120]!==ee?(oe=(0,$.jsx)(ye,{children:(0,$.jsxs)($.Fragment,{children:[W,G,ee,ne,K,q,J,ae]})}),t[113]=ne,t[114]=K,t[115]=q,t[116]=J,t[117]=ae,t[118]=W,t[119]=G,t[120]=ee,t[121]=oe):oe=t[121],oe}function De(e){return e.reachable}function Oe(e){return e.kind===`lan`}function ke(e){return e.language}function Ae(e){let t=(0,Z.c)(40),{open:n,title:r,intro:a,bullets:o,checkboxLabel:s,confirmLabel:c,cancelLabel:l,onConfirm:u,onCancel:d}=e,[f,p]=(0,Q.useState)(!1),m;t[0]===d?m=t[1]:(m=e=>{e||(p(!1),d())},t[0]=d,t[1]=m);let h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(oe,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,j)}),t[2]=h):h=t[2];let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=i(`fixed left-1/2 top-1/2 max-h-[min(90vh,40rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-y-auto rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`,pe),t[3]=g):g=t[3];let v;t[4]===r?v=t[5]:(v=(0,$.jsx)(J,{className:`text-base font-semibold text-fg`,children:r}),t[4]=r,t[5]=v);let y;t[6]===a?y=t[7]:(y=(0,$.jsx)(ne,{className:`mt-2 text-sm text-fg-muted`,children:a}),t[6]=a,t[7]=y);let b;t[8]===o?b=t[9]:(b=o.map(je),t[8]=o,t[9]=b);let x;t[10]===b?x=t[11]:(x=(0,$.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5 text-sm text-fg-muted`,children:b}),t[10]=b,t[11]=x);let S;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(S=e=>p(e.target.checked),t[12]=S):S=t[12];let C;t[13]===f?C=t[14]:(C=(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 shrink-0 rounded border-edge accent-accent`,checked:f,onChange:S}),t[13]=f,t[14]=C);let w;t[15]===s?w=t[16]:(w=(0,$.jsx)(`span`,{children:s}),t[15]=s,t[16]=w);let T;t[17]!==w||t[18]!==C?(T=(0,$.jsxs)(`label`,{className:`mt-5 flex cursor-pointer items-start gap-3 text-sm text-fg`,children:[C,w]}),t[17]=w,t[18]=C,t[19]=T):T=t[19];let E;t[20]!==l||t[21]!==d?(E=(0,$.jsx)(_,{type:`button`,variant:`secondary`,onClick:d,children:l}),t[20]=l,t[21]=d,t[22]=E):E=t[22];let D=!f,O;t[23]!==c||t[24]!==u||t[25]!==D?(O=(0,$.jsx)(_,{type:`button`,disabled:D,onClick:u,children:c}),t[23]=c,t[24]=u,t[25]=D,t[26]=O):O=t[26];let A;t[27]!==E||t[28]!==O?(A=(0,$.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[E,O]}),t[27]=E,t[28]=O,t[29]=A):A=t[29];let M;t[30]!==T||t[31]!==A||t[32]!==v||t[33]!==y||t[34]!==x?(M=(0,$.jsxs)(B,{children:[h,(0,$.jsxs)(le,{className:g,onOpenAutoFocus:Me,children:[v,y,x,T,A]})]}),t[30]=T,t[31]=A,t[32]=v,t[33]=y,t[34]=x,t[35]=M):M=t[35];let N;return t[36]!==n||t[37]!==m||t[38]!==M?(N=(0,$.jsx)(k,{open:n,onOpenChange:m,children:M}),t[36]=n,t[37]=m,t[38]=M,t[39]=N):N=t[39],N}function je(e){return(0,$.jsx)(`li`,{children:e},e)}function Me(e){return e.preventDefault()}function Ne(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var Pe=[`preparing_frpc`,`registering`,`starting_frpc`];function Fe(e){return e?e===`reconnecting_frpc`?Pe.indexOf(`starting_frpc`):Pe.indexOf(e):-1}function Ie(e,t){if(t.state===`connected`)return`done`;let n=t.startProgress?.phase,r=Pe.indexOf(e),i=Fe(n);return i<0?t.state===`connecting`||t.state===`reconnecting`?`active`:`pending`:r<i?`done`:r===i?`active`:`pending`}function Le(e,t,n){let r=n.startProgress;return Ie(t,n)===`active`?t===`preparing_frpc`&&n.frpcDownload?n.frpcDownload.phase===`extracting`?e.frpcExtracting:n.frpcDownload.percent==null?e.frpcDownloading:e.frpcDownloadingPercent.replace(`{{percent}}`,String(n.frpcDownload.percent)):t===`registering`&&r?.publicUrl?e.stepRegisterDetail:t===`starting_frpc`?r?.phase===`reconnecting_frpc`?e.stepReconnectDetail:e.stepFrpcDetail:null:null}function Re(e,t){switch(t){case`preparing_frpc`:return e.stepPrepareFrpc;case`registering`:return e.stepRegister;case`starting_frpc`:return e.stepFrpcLogin}}function ze(e){if(!e)return null;let t=Math.max(0,Math.floor((Date.now()-new Date(e).getTime())/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function Be(e){let t=(0,Z.c)(31),{status:n,t:r}=e,[,a]=(0,Q.useState)(0),o;t[0]!==a||t[1]!==n.state?(o=()=>{if(n.state!==`connecting`&&n.state!==`reconnecting`)return;let e=window.setInterval(()=>a(Ve),1e3);return()=>window.clearInterval(e)},t[0]=a,t[1]=n.state,t[2]=o):o=t[2];let s=n.startProgress?.startedAt,c;if(t[3]!==n.state||t[4]!==s?(c=[n.state,s],t[3]=n.state,t[4]=s,t[5]=c):c=t[5],(0,Q.useEffect)(o,c),!(n.state===`connecting`||n.state===`reconnecting`||n.state===`connected`&&n.startProgress))return null;let l,u,d,f,p;if(t[6]!==n||t[7]!==r){let e=ze(n.startProgress?.startedAt);l=!!n.publicUrl&&n.state!==`connected`&&n.startProgress?.phase!==`registering`,u=`mt-3 space-y-3 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-3`;let a;t[13]===r.startProgressTitle?a=t[14]:(a=(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:r.startProgressTitle}),t[13]=r.startProgressTitle,t[14]=a);let o;t[15]===r.startProgressHint?o=t[16]:(o=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.startProgressHint}),t[15]=r.startProgressHint,t[16]=o),t[17]!==a||t[18]!==o?(d=(0,$.jsxs)(`div`,{children:[a,o]}),t[17]=a,t[18]=o,t[19]=d):d=t[19];let s=Pe.map(e=>{let t=Ie(e,n),a=Le(r,e,n);return(0,$.jsxs)(`li`,{className:`flex gap-2 text-xs`,children:[(0,$.jsx)(`span`,{className:`mt-0.5 shrink-0 text-fg-subtle`,"aria-hidden":!0,children:t===`done`?(0,$.jsx)(ee,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`}):t===`active`?(0,$.jsx)(re,{className:`size-3.5 animate-spin text-accent`}):(0,$.jsx)(ue,{className:`size-3.5`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:i(`font-medium`,t===`active`?`text-fg`:t===`done`?`text-fg-muted`:`text-fg-subtle`),children:Re(r,e)}),a?(0,$.jsx)(`div`,{className:`mt-0.5 text-fg-muted`,children:a}):null,e===`preparing_frpc`&&t===`active`&&n.frpcDownload&&n.frpcDownload.phase===`downloading`?(0,$.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,$.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-surface-panel`,children:(0,$.jsx)(`div`,{className:i(`h-full rounded-full bg-accent transition-[width] duration-300`,n.frpcDownload.percent==null&&`w-1/3 animate-pulse`),style:n.frpcDownload.percent==null?void 0:{width:`${n.frpcDownload.percent}%`}})}),n.frpcDownload.bytesReceived!=null&&n.frpcDownload.totalBytes?(0,$.jsxs)(`p`,{className:`text-fg-subtle`,children:[Ne(n.frpcDownload.bytesReceived),` /`,` `,Ne(n.frpcDownload.totalBytes)]}):null]}):null,e===`preparing_frpc`&&t===`active`&&n.frpcDownload?.url?(0,$.jsxs)(`p`,{className:`mt-2 text-fg-subtle`,children:[(0,$.jsxs)(`span`,{className:`font-sans`,children:[r.frpcDownloadingUrlLabel,`: `]}),(0,$.jsx)(`a`,{href:n.frpcDownload.url,target:`_blank`,rel:`noopener noreferrer`,className:`break-all font-mono text-[11px] text-accent hover:underline`,children:n.frpcDownload.url})]}):null]})]},e)});t[20]===s?f=t[21]:(f=(0,$.jsx)(`ol`,{className:`space-y-2`,children:s}),t[20]=s,t[21]=f),p=e&&n.startProgress?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.startProgressElapsed.replace(`{{elapsed}}`,e)}):null,t[6]=n,t[7]=r,t[8]=l,t[9]=u,t[10]=d,t[11]=f,t[12]=p}else l=t[8],u=t[9],d=t[10],f=t[11],p=t[12];let m;t[22]!==l||t[23]!==r.publicUrlPendingNotice?(m=l?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.publicUrlPendingNotice}):null,t[22]=l,t[23]=r.publicUrlPendingNotice,t[24]=m):m=t[24];let h;return t[25]!==u||t[26]!==d||t[27]!==f||t[28]!==p||t[29]!==m?(h=(0,$.jsxs)(`div`,{className:u,children:[d,f,p,m]}),t[25]=u,t[26]=d,t[27]=f,t[28]=p,t[29]=m,t[30]=h):h=t[30],h}function Ve(e){return e+1}function He(e,t){return t.state===`connected`?e.statusConnected:t.state===`error`?e.statusError:t.startProgress?.phase===`reconnecting_frpc`?e.statusReconnecting:t.startProgress?.phase===`starting_frpc`?e.statusStartingFrpc:t.startProgress?.phase===`registering`?e.statusRegistering:t.startProgress?.phase===`preparing_frpc`||t.frpcDownload?e.statusPreparingFrpc:t.state===`connecting`||t.state===`reconnecting`?e.statusConnecting:e.statusOff}function Ue(e){return e.state===`connected`?`connected`:e.state===`error`?`error`:e.state===`connecting`||e.state===`reconnecting`||e.startProgress||e.frpcDownload?`progress`:`off`}function We(e){switch(e){case`connected`:return`bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`;case`progress`:return`bg-amber-500/15 text-amber-700 dark:text-amber-400`;case`error`:return`bg-red-500/15 text-red-700 dark:text-red-400`;default:return`bg-surface-hover text-fg-muted`}}function Ge(e){if(!e)return`—`;let t=Date.now()-new Date(e).getTime();if(t<0)return`—`;let n=Math.floor(t/6e4);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}function Ke(e){let t=(0,Z.c)(61),{t:n,status:r,isLoading:a,statusErr:o,starting:s,stopping:c,showConsentExpired:l,copyLabels:u,startDisabled:d,startDisabledReason:f,stepLabel:p,onStart:m,onStop:h}=e,g=d===void 0?!1:d,b,x,S,C,w,E,O;t[0]!==r||t[1]!==s?(O=Ue(r),b=r.enabled||s,x=s||r.state===`connecting`||r.state===`reconnecting`||!!r.startProgress||!!r.frpcDownload,t[9]===Symbol.for(`react.memo_cache_sentinel`)?(E=i(ve(),`space-y-4`),t[9]=E):E=t[9],w=`flex flex-wrap items-start justify-between gap-3`,C=`flex items-center gap-2`,S=i(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,We(O)),t[0]=r,t[1]=s,t[2]=b,t[3]=x,t[4]=S,t[5]=C,t[6]=w,t[7]=E,t[8]=O):(b=t[2],x=t[3],S=t[4],C=t[5],w=t[6],E=t[7],O=t[8]);let k=O===`connected`&&`bg-emerald-500`,A=O===`progress`&&`bg-amber-500 animate-pulse`,j=O===`error`&&`bg-red-500`,M=O===`off`&&`bg-fg-subtle`,N;t[10]!==k||t[11]!==A||t[12]!==j||t[13]!==M?(N=i(`size-1.5 rounded-full`,k,A,j,M),t[10]=k,t[11]=A,t[12]=j,t[13]=M,t[14]=N):N=t[14];let P;t[15]===N?P=t[16]:(P=(0,$.jsx)(`span`,{className:N,"aria-hidden":!0}),t[15]=N,t[16]=P);let F;t[17]!==a||t[18]!==r||t[19]!==n?(F=a&&!r.enabled?n.loading:He(n,r),t[17]=a,t[18]=r,t[19]=n,t[20]=F):F=t[20];let I;t[21]!==P||t[22]!==F||t[23]!==S?(I=(0,$.jsxs)(`span`,{className:S,children:[P,F]}),t[21]=P,t[22]=F,t[23]=S,t[24]=I):I=t[24];let L;t[25]!==r.connectedSince||t[26]!==r.state||t[27]!==n.uptime?(L=r.connectedSince&&r.state===`connected`?(0,$.jsxs)(`span`,{className:`text-xs text-fg-subtle`,children:[n.uptime,` `,Ge(r.connectedSince)]}):null,t[25]=r.connectedSince,t[26]=r.state,t[27]=n.uptime,t[28]=L):L=t[28];let R;t[29]!==I||t[30]!==L||t[31]!==C?(R=(0,$.jsxs)(`div`,{className:C,children:[I,L]}),t[29]=I,t[30]=L,t[31]=C,t[32]=R):R=t[32];let z;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(y,{className:`size-4 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[33]=z):z=t[33];let B;t[34]!==R||t[35]!==w?(B=(0,$.jsxs)(`div`,{className:w,children:[R,z]}),t[34]=R,t[35]=w,t[36]=B):B=t[36];let V;t[37]===o?V=t[38]:(V=o?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:o instanceof Error?o.message:String(o)}):null,t[37]=o,t[38]=V);let H;t[39]!==l||t[40]!==n.consentExpiredBanner?(H=l?(0,$.jsx)(`p`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-xs text-fg-muted`,children:n.consentExpiredBanner}):null,t[39]=l,t[40]=n.consentExpiredBanner,t[41]=H):H=t[41];let U;t[42]!==b||t[43]!==u||t[44]!==m||t[45]!==h||t[46]!==x||t[47]!==r||t[48]!==g||t[49]!==f||t[50]!==s||t[51]!==p||t[52]!==c||t[53]!==n?(U=b?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[r.publicUrl?(0,$.jsx)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel px-3 py-3`,children:(0,$.jsx)(v,{label:n.publicUrlLabel,text:r.publicUrl,labels:u})}):null,x?(0,$.jsx)(Be,{status:r,t:n}):null,r.lastError&&r.state===`error`?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:r.lastError}):null,(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.enabled?(0,$.jsxs)(_,{type:`button`,variant:`secondary`,disabled:c,onClick:h,children:[c?(0,$.jsx)(re,{className:`size-4 animate-spin`}):null,n.stop]}):(0,$.jsxs)(_,{type:`button`,disabled:s,onClick:m,children:[s?(0,$.jsx)(re,{className:`size-4 animate-spin`}):(0,$.jsx)(T,{className:`size-4`}),n.start]})})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[p?(0,$.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:p}):null,(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.emptyStateTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:n.emptyStateBody})]}),(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2.5 text-xs text-fg-muted`,children:[(0,$.jsx)(D,{className:`mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-400`}),(0,$.jsx)(`p`,{children:n.riskBannerBody})]}),g&&f?(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:f}):null,(0,$.jsxs)(_,{type:`button`,disabled:s||g,onClick:m,className:`w-full sm:w-auto`,children:[s?(0,$.jsx)(re,{className:`size-4 animate-spin`}):(0,$.jsx)(T,{className:`size-4`}),n.start]})]}),t[42]=b,t[43]=u,t[44]=m,t[45]=h,t[46]=x,t[47]=r,t[48]=g,t[49]=f,t[50]=s,t[51]=p,t[52]=c,t[53]=n,t[54]=U):U=t[54];let W;return t[55]!==B||t[56]!==V||t[57]!==H||t[58]!==U||t[59]!==E?(W=(0,$.jsxs)(`section`,{className:E,children:[B,V,H,U]}),t[55]=B,t[56]=V,t[57]=H,t[58]=U,t[59]=E,t[60]=W):W=t[60],W}var qe=`https://console.xopc.ai/keys/tunnel`,Je={reconfiguring:!1};function Ye(e){let t=(0,Z.c)(84),{t:n,brokerSecretFromEnv:r,brokerSecretMissing:a,brokerSecretConfiguredInConfig:o,brokerSecretMaskedValue:s,brokerSecretDraft:c,savingBrokerSecret:l,brokerSecretNotice:u,copyFailedLabel:d,onDraftChange:f,onSave:p,onClear:m,sectionRef:h}=e,g=(0,Q.useId)(),v=a&&!r,y=!v,[b,x]=(0,Q.useReducer)(fe,Je),{reconfiguring:S}=b,C;t[0]!==o||t[1]!==c||t[2]!==r||t[3]!==S?(C=o&&!r&&!S&&!c.trim(),t[0]=o,t[1]=c,t[2]=r,t[3]=S,t[4]=C):C=t[4];let w=C,T;t[5]!==n.copied||t[6]!==n.copyKey||t[7]!==n.hideKey||t[8]!==n.showKey?(T={show:n.showKey,hide:n.hideKey,copy:n.copyKey,copied:n.copied},t[5]=n.copied,t[6]=n.copyKey,t[7]=n.hideKey,t[8]=n.showKey,t[9]=T):T=t[9];let E=T,D;t[10]===c?D=t[11]:(D=c.trim().length>0&&!O(c.trim()),t[10]=c,t[11]=D);let k=D,A;t[12]===f?A=t[13]:(A=()=>{x({type:`patch`,patch:{reconfiguring:!1}}),f(``)},t[12]=f,t[13]=A);let j=A,M=v&&`ring-1 ring-amber-500/30`,N;t[14]===M?N=t[15]:(N=i(M),t[14]=M,t[15]=N);let P=y?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`:v?`bg-amber-500/10 text-amber-700 dark:text-amber-400`:`bg-surface-hover text-fg-muted`,F;t[16]===P?F=t[17]:(F=i(`flex size-9 shrink-0 items-center justify-center rounded-lg`,P),t[16]=P,t[17]=F);let I;t[18]===y?I=t[19]:(I=y?(0,$.jsx)(ee,{className:`size-4`,strokeWidth:2,"aria-hidden":!0}):(0,$.jsx)(z,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[18]=y,t[19]=I);let L;t[20]!==F||t[21]!==I?(L=(0,$.jsx)(`span`,{className:F,children:I}),t[20]=F,t[21]=I,t[22]=L):L=t[22];let R=y?n.brokerSecretReadyTitle:n.brokerSecretStepTitle,B;t[23]===R?B=t[24]:(B=(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:R}),t[23]=R,t[24]=B);let V=y?n.brokerSecretReadyHint:n.brokerSecretHint,H;t[25]===V?H=t[26]:(H=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:V}),t[25]=V,t[26]=H);let U;t[27]!==v||t[28]!==n.brokerSecretMissingHint?(U=v?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-amber-800 dark:text-amber-200`,children:n.brokerSecretMissingHint}):null,t[27]=v,t[28]=n.brokerSecretMissingHint,t[29]=U):U=t[29];let G;t[30]!==B||t[31]!==H||t[32]!==U?(G=(0,$.jsxs)(`div`,{children:[B,H,U]}),t[30]=B,t[31]=H,t[32]=U,t[33]=G):G=t[33];let te;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(he,{className:`size-3`,"aria-hidden":!0}),t[34]=te):te=t[34];let ne;t[35]===n.brokerSecretConsoleLink?ne=t[36]:(ne=(0,$.jsxs)(`a`,{href:qe,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[n.brokerSecretConsoleLink,te]}),t[35]=n.brokerSecretConsoleLink,t[36]=ne);let K;t[37]!==r||t[38]!==n.brokerSecretEnvHint?(K=r?(0,$.jsx)(`p`,{className:`rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2 text-xs text-fg-muted`,children:n.brokerSecretEnvHint}):null,t[37]=r,t[38]=n.brokerSecretEnvHint,t[39]=K):K=t[39];let q;t[40]!==o||t[41]!==c||t[42]!==r||t[43]!==s||t[44]!==k||t[45]!==j||t[46]!==d||t[47]!==g||t[48]!==v||t[49]!==m||t[50]!==f||t[51]!==p||t[52]!==S||t[53]!==l||t[54]!==E||t[55]!==w||t[56]!==n.brokerSecretCancelReconfigure||t[57]!==n.brokerSecretClear||t[58]!==n.brokerSecretMaskedHelp||t[59]!==n.brokerSecretNotInConfigFile||t[60]!==n.brokerSecretPlaceholder||t[61]!==n.brokerSecretReconfigure||t[62]!==n.brokerSecretRevealFailed||t[63]!==n.brokerSecretSave||t[64]!==n.brokerSecretSaveAndContinue||t[65]!==n.brokerSecretTitle?(q=w?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:g,children:n.brokerSecretTitle}),(0,$.jsx)(W,{id:g,value:s,labels:E,reveal:Xe,loadFailedLabel:d||n.brokerSecretRevealFailed,maskedHelp:n.brokerSecretMaskedHelp,notInConfigFile:n.brokerSecretNotInConfigFile,readOnly:!0}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(_,{type:`button`,variant:`secondary`,disabled:l,onClick:()=>{x({type:`patch`,patch:{reconfiguring:!0}})},children:n.brokerSecretReconfigure}),(0,$.jsx)(_,{type:`button`,variant:`ghost`,disabled:l,onClick:m,children:n.brokerSecretClear})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:g,children:n.brokerSecretTitle}),(0,$.jsx)(W,{id:g,value:c,onChange:f,placeholder:n.brokerSecretPlaceholder,labels:E,disabled:l}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(_,{type:`button`,disabled:l||!k,onClick:p,children:[l?(0,$.jsx)(re,{className:`size-4 animate-spin`}):null,v?n.brokerSecretSaveAndContinue:n.brokerSecretSave]}),o||r?(0,$.jsx)(_,{type:`button`,variant:`ghost`,disabled:l,onClick:m,children:n.brokerSecretClear}):null,S?(0,$.jsx)(_,{type:`button`,variant:`ghost`,disabled:l,onClick:j,children:n.brokerSecretCancelReconfigure}):null]})]}),t[40]=o,t[41]=c,t[42]=r,t[43]=s,t[44]=k,t[45]=j,t[46]=d,t[47]=g,t[48]=v,t[49]=m,t[50]=f,t[51]=p,t[52]=S,t[53]=l,t[54]=E,t[55]=w,t[56]=n.brokerSecretCancelReconfigure,t[57]=n.brokerSecretClear,t[58]=n.brokerSecretMaskedHelp,t[59]=n.brokerSecretNotInConfigFile,t[60]=n.brokerSecretPlaceholder,t[61]=n.brokerSecretReconfigure,t[62]=n.brokerSecretRevealFailed,t[63]=n.brokerSecretSave,t[64]=n.brokerSecretSaveAndContinue,t[65]=n.brokerSecretTitle,t[66]=q):q=t[66];let J;t[67]===u?J=t[68]:(J=u?(0,$.jsx)(`p`,{className:`text-xs text-emerald-700 dark:text-emerald-400`,children:u}):null,t[67]=u,t[68]=J);let Y;t[69]!==G||t[70]!==ne||t[71]!==K||t[72]!==q||t[73]!==J?(Y=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[G,ne,K,q,J]}),t[69]=G,t[70]=ne,t[71]=K,t[72]=q,t[73]=J,t[74]=Y):Y=t[74];let X;t[75]!==L||t[76]!==Y?(X=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[L,Y]}),t[75]=L,t[76]=Y,t[77]=X):X=t[77];let ie;t[78]!==X||t[79]!==N?(ie=(0,$.jsx)(ye,{className:N,children:X}),t[78]=X,t[79]=N,t[80]=ie):ie=t[80];let ae;return t[81]!==h||t[82]!==ie?(ae=(0,$.jsx)(`div`,{ref:h,id:`tunnel-broker-secret-setup`,children:ie}),t[81]=h,t[82]=ie,t[83]=ae):ae=t[83],ae}function Xe(){return L().then(Ze)}function Ze(e){return e.registrationSecret??null}function Qe(e){let t=(0,Z.c)(10),{language:n,label:r,section:a,className:o}=e,s;t[0]!==n||t[1]!==a?(s=X(n,a),t[0]=n,t[1]=a,t[2]=s):s=t[2];let c;t[3]===o?c=t[4]:(c=i(`inline-flex items-center gap-1 text-sm font-medium text-accent hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,o),t[3]=o,t[4]=c);let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(he,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[5]=l):l=t[5];let u;return t[6]!==r||t[7]!==s||t[8]!==c?(u=(0,$.jsxs)(`a`,{href:s,target:`_blank`,rel:`noreferrer`,className:c,children:[r,l]}),t[6]=r,t[7]=s,t[8]=c,t[9]=u):u=t[9],u}var $e=e(be(),1),et={width:216,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}};async function tt(e){return $e.toDataURL(e,et)}function nt(e){let t=e?.candidates??[],n=t.find(e=>e.kind===`lan`&&e.reachable),r=t.find(e=>e.kind===`lan`);return(n??r)?.url?.trim()??``}function rt(e,t){let n=t.trim();return!n||!e?!1:e.candidates.some(e=>e.kind===`tunnel`&&e.url.trim()===n)}function it(e,t){return e?t?nt(e)||e.recommended.url?.trim()||``:e.recommended.url?.trim()||``:``}function at(e,t){let n=t?.preferLan===!0,r=!!e,{mutate:i}=p(),a=(0,Q.useRef)(!1),{data:o}=m(r?`tunnel-status`:null,G,{refreshInterval:6e4}),{data:c,mutate:l}=m(r?`tunnel-pair-context`:null,ce,{refreshInterval:6e4});(0,Q.useEffect)(()=>{let e=()=>{i(`tunnel-status`),i(`tunnel-qr`),i(`tunnel-pair`),i(`tunnel-pair-context`)};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[i]);let u=o?.state===`connected`&&!!o.publicUrl?.trim(),f=u&&!n,{data:g,mutate:_}=m(f&&r?`tunnel-qr`:null,N,{refreshInterval:4*6e4}),{data:v,mutate:y}=m(!f&&r&&c?.pairingReady?`tunnel-pair`:null,A,{refreshInterval:4*6e4}),[b,x]=(0,Q.useState)(``),[S,C]=(0,Q.useState)(``),[w,T]=(0,Q.useState)({pairContext:void 0,preferLan:n});if(!a.current&&(c!==w.pairContext||n!==w.preferLan)){T({pairContext:c,preferLan:n});let e=it(c,n);b!==e&&x(e)}let E=(0,Q.useCallback)(e=>{a.current=!0,x(e)},[]),D=(0,Q.useCallback)(()=>{let e=it(c,n);e&&(a.current=!0,x(e))},[c,n]),O=(0,Q.useCallback)(e=>{let t=e.trim();t&&(a.current=!0,x(t))},[]),k=(0,Q.useCallback)(e=>{a.current=!1,x(e?.trim()||it(c,n))},[c,n]),j=b.trim(),M=(0,Q.useMemo)(()=>{try{let e=new URL(j);return e.protocol===`http:`||e.protocol===`https:`}catch{return!1}},[j]),P=M&&d(j),F=!f&&!!(c&&!c.pairingReady&&c.blockReason===`GATEWAY_LOOPBACK_ONLY`),I=!f&&M&&!P&&!!v?.pairingSecret&&(c?.pairingReady===!0||!F),L=(0,Q.useMemo)(()=>{let e=nt(c);return n?e||(j&&!rt(c,j)?j:``):j},[c,n,j]),R=(0,Q.useMemo)(()=>{if(!e)return``;if(S.trim())return S.trim();if(f&&g?.qrPayload?.trim())return g.qrPayload.trim();if(!I||!v?.pairingSecret)return``;let t=c?.candidates.find(e=>e.kind===`tunnel`&&e.reachable),r=c?.candidates.find(e=>e.kind===`lan`&&e.reachable),i=n?L:t?.url??j;return i?s({baseUrl:i,pairingSecret:v.pairingSecret,lanUrl:n?null:t&&r?r.url:null}):``},[e,L,v?.pairingSecret,I,S,n,j,f,g?.qrPayload,c?.candidates]),z=h(()=>tt(R),[R],{enabled:!!R,initial:null,errorData:null}),B=R?z.data:null,V=!!(R&&z.error!==null&&!z.loading);return{tunnelActive:u,tunnelStatus:o,tunnelQr:g,pairContext:c,pairBaseUrl:b,setPairBaseUrl:E,applySuggestedPairUrl:D,applyCandidateUrl:O,baseOk:M,localhostWarn:P,pairingBlocked:F,deepLink:R,qrPayload:R,qrDataUrl:B,qrGenFailed:V,encoding:!!(R&&!B&&!V),refreshQr:(0,Q.useCallback)(async e=>{if(e?.trim()){C(e.trim()),_({qrPayload:e.trim(),publicUrl:o?.publicUrl??``,lanUrl:g?.lanUrl??null},!1);return}C(``),await l(),f?await _():c?.pairingReady&&await y()},[y,l,_,c?.pairingReady,g?.lanUrl,o?.publicUrl,f]),resetPairBaseFromContext:k}}var ot={actionError:null,starting:!1,stopping:!1,savingAutoStart:!1,consentOpen:!1,autoStartConfirmOpen:!1,releaseConfirmOpen:!1,releasing:!1,brokerSecretDraft:``,savingBrokerSecret:!1,brokerSecretNotice:null};function st({embedded:e=!1}){let t=o(e=>e.language),n=a(t).tunnelSettings,r=c(e=>e.token),s=!!r,[l,u]=(0,Q.useReducer)(fe,ot),{actionError:d,starting:f,stopping:p,savingAutoStart:h,consentOpen:g,autoStartConfirmOpen:v,releaseConfirmOpen:b,releasing:x,brokerSecretDraft:S,savingBrokerSecret:C,brokerSecretNotice:T}=l,E=(0,Q.useRef)(null),D=at(r??``),{data:k}=w(s),{data:A,error:j,isLoading:M,mutate:N}=m(s?`tunnel-status`:null,G,{refreshInterval:e=>f?1e3:e?.frpcDownload||e?.state===`connecting`||e?.state===`reconnecting`?2e3:6e4}),P=(0,Q.useMemo)(()=>{let e=k?.payload?.config;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.tunnel;if(t&&typeof t==`object`&&!Array.isArray(t)&&t.autoStart===!0)return!0}return A?.config?.autoStart===!0},[k,A?.config?.autoStart]),L=(0,Q.useMemo)(()=>{let e=k?.payload?.config;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.tunnel;if(t&&typeof t==`object`&&!Array.isArray(t)){let e=t.registrationSecret;if(typeof e==`string`)return e}}return``},[k]),R=O(L),z=A?.registrationSecret?.source===`env`,B=A?.registrationSecret?.source===`missing`,V=A?.registrationSecret?.configured===!0;(0,Q.useEffect)(()=>{let e=()=>{N()};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[N]);let H=(0,Q.useMemo)(()=>[n.consentBullet1,n.consentBullet2,n.consentBullet3],[n.consentBullet1,n.consentBullet2,n.consentBullet3]),W=(0,Q.useCallback)(async()=>{u({type:`patch`,patch:{actionError:null}}),u({type:`patch`,patch:{starting:!0}});try{let e=await ae();await N(),U(),await D.refreshQr(e.qrPayload)}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{starting:!1}})}},[N,D.refreshQr]),ee=(0,Q.useCallback)(()=>{if(!V){u({type:`patch`,patch:{actionError:n.brokerSecretRequiredBeforeStart}}),E.current?.scrollIntoView({behavior:`smooth`,block:`start`});return}if(A?.consentRequired){u({type:`patch`,patch:{consentOpen:!0}});return}W()},[V,A?.consentRequired,W,n.brokerSecretRequiredBeforeStart]),ne=(0,Q.useCallback)(async()=>{u({type:`patch`,patch:{consentOpen:!1}}),u({type:`patch`,patch:{actionError:null}});try{await F(),await Promise.all([N(),W()])}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}},[N,W]),K=(0,Q.useCallback)(async()=>{u({type:`patch`,patch:{actionError:null}}),u({type:`patch`,patch:{stopping:!0}});try{await te(),await Promise.all([D.refreshQr(),N()]),U()}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{stopping:!1}})}},[N,D.refreshQr]),q=(0,Q.useCallback)(async e=>{u({type:`patch`,patch:{savingAutoStart:!0}}),u({type:`patch`,patch:{actionError:null}});try{await de({autoStart:e}),U()}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{savingAutoStart:!1}})}},[]),J=(0,Q.useCallback)(()=>{if(P){q(!1);return}if(A?.consentRequired){u({type:`patch`,patch:{actionError:n.consentExpiredBanner}});return}if(!A?.canAutoStart){u({type:`patch`,patch:{actionError:n.autoStartHint}});return}u({type:`patch`,patch:{autoStartConfirmOpen:!0}})},[q,A?.canAutoStart,A?.consentRequired,n,P]),Y=(0,Q.useCallback)(async()=>{let e=S.trim();if(e){u({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await de({registrationSecret:e}),u({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretSaved}}),U(),await N(),u({type:`patch`,patch:{actionError:null}})}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{savingBrokerSecret:!1}})}}},[S,N,n.brokerSecretSaved]),X=(0,Q.useCallback)(async()=>{u({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await de({registrationSecret:null}),u({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretCleared}}),U(),await N()}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{savingBrokerSecret:!1}})}},[N,n.brokerSecretCleared]),ie=(0,Q.useCallback)(async()=>{u({type:`patch`,patch:{releaseConfirmOpen:!1,actionError:null,releasing:!0}});try{await te({release:!0}),await Promise.all([D.refreshQr(),N()]),U()}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{releasing:!1}})}},[N,D.refreshQr]),oe=(0,Q.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:a(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]);if(!s)return(0,$.jsx)(`div`,{className:e?void 0:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})});let se=A??{enabled:!1,state:`disconnected`,subdomain:null,publicUrl:null,connectedSince:null,frpcPid:null,lastHeartbeatAt:null,lastError:null,consentRequired:!0,config:{autoStart:P,brokerUrl:`https://frp.xopc.ai/api`}},ce=A?.consentRequired&&(se.enabled||P||A?.consent?.acceptedAt),le=(0,$.jsx)(Ye,{t:n,brokerSecretFromEnv:z,brokerSecretMissing:B,brokerSecretConfiguredInConfig:R,brokerSecretMaskedValue:R?L:``,brokerSecretDraft:S,savingBrokerSecret:C,brokerSecretNotice:T,copyFailedLabel:a(t).clipboard.copyFailed,onDraftChange:e=>u({type:`patch`,patch:{brokerSecretDraft:e}}),onSave:()=>void Y(),onClear:()=>void X(),sectionRef:E}),ue=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ae,{open:g,title:n.consentTitle,intro:n.consentIntro,bullets:H,checkboxLabel:n.consentCheckbox,confirmLabel:ce?n.consentReconfirm:n.consentConfirm,cancelLabel:n.consentCancel,onConfirm:()=>void ne(),onCancel:()=>u({type:`patch`,patch:{consentOpen:!1}})},g?`consent-open`:`consent-closed`),(0,$.jsx)(I,{open:v,title:n.autoStartConfirmTitle,description:n.autoStartConfirmBody,confirmLabel:n.autoStartConfirmLabel,cancelLabel:n.consentCancel,onConfirm:()=>{u({type:`patch`,patch:{autoStartConfirmOpen:!1}}),q(!0)},onCancel:()=>u({type:`patch`,patch:{autoStartConfirmOpen:!1}})}),(0,$.jsx)(I,{open:b,title:n.releaseConfirmTitle,description:n.releaseConfirmBody,confirmLabel:n.releaseConfirmLabel,cancelLabel:n.consentCancel,destructive:!0,onConfirm:()=>void ie(),onCancel:()=>u({type:`patch`,patch:{releaseConfirmOpen:!1}})})]});return e?(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[d?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:d}):null,le,(0,$.jsx)(Ke,{t:n,status:se,isLoading:M,statusErr:j,starting:f,stopping:p,showConsentExpired:!!ce,copyLabels:oe,startDisabled:!V,startDisabledReason:V?void 0:n.brokerSecretRequiredBeforeStart,stepLabel:n.flowStepStart,onStart:ee,onStop:()=>void K()}),(0,$.jsx)(Ee,{pairQr:D,gatewayToken:r??``,streamlined:!0,onRefreshQr:()=>void D.refreshQr()}),(0,$.jsxs)(ge,{showLabel:n.showOptions,hideLabel:n.hideOptions,children:[(0,$.jsxs)(`label`,{className:i(`flex items-center gap-3 text-sm text-fg`,!P&&!A?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:P,disabled:h||!P&&!A?.canAutoStart,onChange:J}),n.autoStart]}),!A?.canAutoStart&&!P?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.autoStartHint}):null,se.subdomain||se.publicUrl?(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-edge-subtle pt-4`,children:[(0,$.jsxs)(_,{type:`button`,variant:`secondary`,disabled:x||p,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>u({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[x?(0,$.jsx)(re,{className:`size-4 animate-spin`}):null,n.release]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint})]}):null]}),(0,$.jsx)(ge,{showLabel:n.showAdvanced,hideLabel:n.hideAdvanced,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge-subtle pt-4 text-xs text-fg-subtle`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(y,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(Qe,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]})}),ue]}):(0,$.jsxs)(`div`,{className:e?`flex w-full flex-col gap-6`:`flex w-full flex-col gap-6 px-3 py-8 sm:px-5 xl:px-6`,children:[e?null:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:n.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle})]}),d?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:d}):null,le,(0,$.jsx)(Ke,{t:n,status:se,isLoading:M,statusErr:j,starting:f,stopping:p,showConsentExpired:!!ce,copyLabels:oe,startDisabled:!V,startDisabledReason:V?void 0:n.brokerSecretRequiredBeforeStart,onStart:ee,onStop:()=>void K()}),(0,$.jsx)(Ee,{pairQr:D,gatewayToken:r??``}),se.subdomain||se.publicUrl?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,$.jsxs)(_,{type:`button`,variant:`secondary`,disabled:x||p,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>u({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[x?(0,$.jsx)(re,{className:`size-4 animate-spin`}):null,n.release]})}):null,se.subdomain||se.publicUrl?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint}):null,(0,$.jsxs)(ye,{children:[(0,$.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-fg`,children:n.optionsTitle}),(0,$.jsxs)(`label`,{className:i(`flex items-center gap-3 text-sm text-fg`,!P&&!A?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:P,disabled:h||!P&&!A?.canAutoStart,onChange:J}),n.autoStart]}),!A?.canAutoStart&&!P?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:n.autoStartHint}):null]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2 text-xs text-fg-subtle`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(y,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(Qe,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]}),ue]})}async function ct(){let e=await f(`/api/exposure/status`);if(!e.ok)throw Error(`Failed to load exposure status (${e.status})`);return await e.json()}async function lt(e=`serve`){let t=await f(`/api/exposure/tailscale/start`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`Start failed (${t.status})`)}return await t.json()}async function ut(){let e=await f(`/api/exposure/tailscale/stop`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`Stop failed (${e.status})`)}return await e.json()}var dt=`https://tailscale.com/download`;function ft(e){let t=(0,Z.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`a`,{href:dt,target:`_blank`,rel:`noreferrer`,className:`font-medium text-accent hover:underline`,children:n}),t[0]=n,t[1]=r),r}function pt({embedded:e=!1}){let t=o(e=>e.language),n=a(t).remoteAccess.tailscale,r=(0,Q.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:a(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]),i=!!c(e=>e.token),[s,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(null),{data:f,mutate:p,isLoading:h}=m(i?`exposure-status`:null,ct,{refreshInterval:3e4}),g=f?.tailscale.hostname,b=f?.tailscale.active===!0,x=f?.tailscale.cliAvailable!==!1,S=g?`https://${g}/`:null,C=(0,Q.useCallback)(async()=>{l(!0),d(null);try{await lt(`serve`),await p()}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(!1)}},[p]),w=(0,Q.useCallback)(async()=>{l(!0),d(null);try{await ut(),await p()}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(!1)}},[p]);if(!i)return null;let E=(0,$.jsxs)(`div`,{className:e?`space-y-4`:`mt-4 space-y-3`,children:[e?(0,$.jsxs)(`ol`,{className:`space-y-3 text-sm text-fg-muted`,children:[(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`1`}),(0,$.jsxs)(`span`,{children:[n.stepInstallBefore,(0,$.jsx)(ft,{label:n.stepInstallLink}),n.stepInstallAfter]})]}),(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`2`}),(0,$.jsx)(`span`,{children:n.stepEnable})]}),(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`3`}),(0,$.jsx)(`span`,{children:n.stepCopy})]})]}):null,e&&f?.tailscale.cliAvailable===!1?(0,$.jsxs)(`p`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-sm text-fg-muted`,children:[n.cliMissingIntro,` `,(0,$.jsx)(ft,{label:n.cliMissingDownloadLink}),n.cliMissingSuffix]}):null,h&&!f?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.loading}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(ye,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.statusLabel}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:b?n.statusActive:n.statusOff}),S?(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(v,{text:S,labels:r})}):null,u?(0,$.jsx)(`p`,{className:`mt-2 text-sm text-red-600 dark:text-red-400`,children:u}):null,(0,$.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:b?(0,$.jsxs)(_,{type:`button`,variant:`secondary`,disabled:s,onClick:()=>void w(),children:[s?(0,$.jsx)(re,{className:`mr-1 h-4 w-4 animate-spin`}):null,n.disableServe]}):(0,$.jsxs)(_,{type:`button`,disabled:s||!x,onClick:()=>void C(),children:[s?(0,$.jsx)(re,{className:`mr-1 h-4 w-4 animate-spin`}):(0,$.jsx)(T,{className:`mr-1 h-4 w-4`}),n.enableServe]})})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.hint}),(0,$.jsx)(Qe,{language:t,label:n.docsLink,section:`tailscale-serve`,className:`mt-2`})]})]});return e?E:(0,$.jsxs)(ye,{children:[(0,$.jsx)(_e,{icon:y,title:n.title,subtitle:n.subtitle}),E]})}function mt(){let e=(0,Z.c)(26),t=o(gt),n=c(ht),r;e[0]===t?r=e[1]:(r=a(t),e[0]=t,e[1]=r);let i=r.remoteAccess.lan,s;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(s={preferLan:!0},e[2]=s):s=e[2];let l=at(n??``,s),u;e[3]!==i.subtitle||e[4]!==i.title?(u=(0,$.jsx)(_e,{icon:M,title:i.title,subtitle:i.subtitle}),e[3]=i.subtitle,e[4]=i.title,e[5]=u):u=e[5];let d;e[6]===i.body?d=e[7]:(d=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:i.body}),e[6]=i.body,e[7]=d);let f;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(he,{className:`size-3.5`,"aria-hidden":!0}),e[8]=f):f=e[8];let p;e[9]===i.link?p=e[10]:(p=(0,$.jsxs)(H,{to:`/settings/gateway`,className:`inline-flex items-center gap-1.5 text-sm font-medium text-accent hover:underline`,children:[i.link,f]}),e[9]=i.link,e[10]=p);let m;e[11]!==d||e[12]!==p?(m=(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[d,p]}),e[11]=d,e[12]=p,e[13]=m):m=e[13];let h;e[14]!==u||e[15]!==m?(h=(0,$.jsxs)(ye,{children:[u,m]}),e[14]=u,e[15]=m,e[16]=h):h=e[16];let g=n??``,_;e[17]===l?_=e[18]:(_=()=>void l.refreshQr(),e[17]=l,e[18]=_);let v;e[19]!==l||e[20]!==g||e[21]!==_?(v=(0,$.jsx)(Ee,{pairQr:l,gatewayToken:g,lanOnly:!0,onRefreshQr:_}),e[19]=l,e[20]=g,e[21]=_,e[22]=v):v=e[22];let y;return e[23]!==v||e[24]!==h?(y=(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[h,v]}),e[23]=v,e[24]=h,e[25]=y):y=e[25],y}function ht(e){return e.token}function gt(e){return e.language}function _t(e){let t=(0,Z.c)(30),{embedded:n}=e,r=n===void 0?!1:n,i=o(vt),s;t[0]===i?s=t[1]:(s=a(i),t[0]=i,t[1]=s);let c=s.remoteAccess.ssh,[l,u]=(0,Q.useState)(!1),d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=async()=>{await g(`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`)&&(u(!0),setTimeout(()=>u(!1),2e3))},t[2]=d):d=t[2];let f=d,p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(`pre`,{className:`overflow-x-auto rounded-lg border border-edge bg-surface px-3 py-2 text-xs text-fg-muted`,children:`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`}),t[3]=p):p=t[3];let m,h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>void f(),h=(0,$.jsx)(b,{className:`mr-1 h-4 w-4`}),t[4]=m,t[5]=h):(m=t[4],h=t[5]);let v=l?c.copied:c.copy,y;t[6]===v?y=t[7]:(y=(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsxs)(_,{type:`button`,variant:`ghost`,onClick:m,children:[h,v]})}),t[6]=v,t[7]=y);let x;t[8]!==r||t[9]!==c.hint?(x=r?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:c.hint}):null,t[8]=r,t[9]=c.hint,t[10]=x):x=t[10];let S;t[11]!==y||t[12]!==x?(S=(0,$.jsxs)($.Fragment,{children:[p,y,x]}),t[11]=y,t[12]=x,t[13]=S):S=t[13];let C=S;if(r){let e;t[14]!==c.subtitle||t[15]!==c.title?(e=(0,$.jsx)(_e,{icon:K,title:c.title,subtitle:c.subtitle}),t[14]=c.subtitle,t[15]=c.title,t[16]=e):e=t[16];let n;t[17]===C?n=t[18]:(n=(0,$.jsx)(`div`,{className:`mt-4 space-y-2`,children:C}),t[17]=C,t[18]=n);let r;return t[19]!==e||t[20]!==n?(r=(0,$.jsxs)(ye,{children:[e,n]}),t[19]=e,t[20]=n,t[21]=r):r=t[21],r}let w;t[22]!==c.subtitle||t[23]!==c.title?(w=(0,$.jsx)(_e,{icon:K,title:c.title,subtitle:c.subtitle}),t[22]=c.subtitle,t[23]=c.title,t[24]=w):w=t[24];let T;t[25]===C?T=t[26]:(T=(0,$.jsx)(`div`,{className:`mt-4`,children:C}),t[25]=C,t[26]=T);let E;return t[27]!==w||t[28]!==T?(E=(0,$.jsxs)(ye,{children:[w,T]}),t[27]=w,t[28]=T,t[29]=E):E=t[29],E}function vt(e){return e.language}function yt(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(_t,{embedded:!0}),e[0]=t):t=e[0],t}function bt(e){switch(e){case`active`:return`bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`;case`connecting`:return`bg-amber-500/15 text-amber-700 dark:text-amber-400`;default:return`bg-surface-hover text-fg-muted`}}function xt(e){let t=(0,Z.c)(5),{label:n,kind:r}=e,a;t[0]===r?a=t[1]:(a=i(`rounded-full px-2 py-0.5 text-[11px] font-medium`,bt(r)),t[0]=r,t[1]=a);let o;return t[2]!==n||t[3]!==a?(o=(0,$.jsx)(`span`,{className:a,children:n}),t[2]=n,t[3]=a,t[4]=o):o=t[4],o}function St(e){let t=(0,Z.c)(32),{onOpenTab:n}=e,r=o(Tt),s;t[0]===r?s=t[1]:(s=a(r),t[0]=r,t[1]=s);let l=s.remoteAccess.guide,u=!!c(wt),d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d={refreshInterval:3e4},t[2]=d):d=t[2];let{data:f}=m(u?`exposure-status`:null,ct,d),p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p={refreshInterval:15e3},t[3]=p):p=t[3];let{data:h}=m(u?`tunnel-status`:null,G,p),g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(g={refreshInterval:6e4},t[4]=g):g=t[4];let{data:_}=m(u?`tunnel-pair-context`:null,ce,g);if(!u)return null;let v=f?.tailscale.active===!0,b=h?.state,x=h?.enabled&&b===`connected`,S=h?.enabled&&(b===`connecting`||b===`reconnecting`||!!h?.startProgress||!!h?.frpcDownload),w=(_?.candidates??[]).some(Ct),T=v?`active`:`off`,E=v?l.statusActive:l.statusOff,D;t[5]!==l.tailscaleCardTitle||t[6]!==T||t[7]!==E?(D={tab:`tailscale`,icon:y,title:l.tailscaleCardTitle,kind:T,statusLabel:E},t[5]=l.tailscaleCardTitle,t[6]=T,t[7]=E,t[8]=D):D=t[8];let O=x?`active`:S?`connecting`:`off`,k=x?l.statusActive:S?l.statusConnecting:l.statusOff,A;t[9]!==l.publicCardTitle||t[10]!==O||t[11]!==k?(A={tab:`public`,icon:C,title:l.publicCardTitle,kind:O,statusLabel:k},t[9]=l.publicCardTitle,t[10]=O,t[11]=k,t[12]=A):A=t[12];let j=w?`active`:`off`,N=w?l.statusActive:l.statusOff,P;t[13]!==l.reverseProxyCardTitle||t[14]!==j||t[15]!==N?(P={tab:`reverse-proxy`,icon:R,title:l.reverseProxyCardTitle,kind:j,statusLabel:N},t[13]=l.reverseProxyCardTitle,t[14]=j,t[15]=N,t[16]=P):P=t[16];let F;t[17]!==l.sshCardStatus||t[18]!==l.sshCardTitle?(F={tab:`ssh`,icon:K,title:l.sshCardTitle,kind:`off`,statusLabel:l.sshCardStatus},t[17]=l.sshCardStatus,t[18]=l.sshCardTitle,t[19]=F):F=t[19];let I;t[20]!==l.lanCardStatus||t[21]!==l.lanCardTitle?(I={tab:`lan`,icon:M,title:l.lanCardTitle,kind:`off`,statusLabel:l.lanCardStatus},t[20]=l.lanCardStatus,t[21]=l.lanCardTitle,t[22]=I):I=t[22];let L;t[23]!==A||t[24]!==P||t[25]!==F||t[26]!==I||t[27]!==D?(L=[D,A,P,F,I],t[23]=A,t[24]=P,t[25]=F,t[26]=I,t[27]=D,t[28]=L):L=t[28];let z=L,B;return t[29]!==z||t[30]!==n?(B=(0,$.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5`,children:z.map(e=>{let t=e.icon;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.tab),className:i(`flex items-start gap-3 rounded-xl border border-edge-subtle bg-surface-base px-3 py-2.5 text-left transition-colors`,`hover:border-edge hover:bg-surface-hover/50`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,$.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,children:(0,$.jsx)(t,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.title}),(0,$.jsx)(xt,{label:e.statusLabel,kind:e.kind})]})]},`${e.tab}-${e.title}`)})}),t[29]=z,t[30]=n,t[31]=B):B=t[31],B}function Ct(e){return e.kind===`reverse-proxy`}function wt(e){return e.token}function Tt(e){return e.language}function Et(e){let t=(0,Z.c)(26),{title:n,description:r,recommended:a,icon:o,onOpen:s,openLabel:c,recommendedLabel:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(`group flex w-full flex-col rounded-2xl bg-surface-base px-4 py-4 text-left transition-colors`,`hover:bg-surface-hover/40`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),t[0]=u):u=t[0];let d;t[1]===o?d=t[2]:(d=(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,children:(0,$.jsx)(o,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=o,t[2]=d);let f;t[3]===n?f=t[4]:(f=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=f);let p;t[5]!==a||t[6]!==l?(p=a&&l?(0,$.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:l}):null,t[5]=a,t[6]=l,t[7]=p):p=t[7];let m;t[8]!==f||t[9]!==p?(m=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f,p]}),t[8]=f,t[9]=p,t[10]=m):m=t[10];let h;t[11]===r?h=t[12]:(h=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=h);let g;t[13]!==m||t[14]!==h?(g=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[m,h]}),t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(P,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==g?(v=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[d,g,_]}),t[17]=d,t[18]=g,t[19]=v):v=t[19];let y;t[20]===c?y=t[21]:(y=(0,$.jsx)(`span`,{className:`mt-3 text-xs font-medium text-accent`,children:c}),t[20]=c,t[21]=y);let b;return t[22]!==s||t[23]!==y||t[24]!==v?(b=(0,$.jsxs)(`button`,{type:`button`,onClick:s,className:u,children:[v,y]}),t[22]=s,t[23]=y,t[24]=v,t[25]=b):b=t[25],b}function Dt(e){let t=(0,Z.c)(83),{onOpenTab:n}=e,r=o(At),i;t[0]===r?i=t[1]:(i=a(r),t[0]=r,t[1]=i);let s=i.remoteAccess,l=s.guide,u=!!c(kt),d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d={refreshInterval:3e4},t[2]=d):d=t[2];let{data:f}=m(u?`exposure-status`:null,ct,d),p;t[3]===f?.conflicts?p=t[4]:(p=f?.conflicts??[],t[3]=f?.conflicts,t[4]=p);let h=p;if(!u){let e;return t[5]===l.needToken?e=t[6]:(e=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.needToken}),t[5]=l.needToken,t[6]=e),e}let g;t[7]===n?g=t[8]:(g=(0,$.jsx)(St,{onOpenTab:n}),t[7]=n,t[8]=g);let _;t[9]!==h||t[10]!==l.conflictsHint||t[11]!==l.conflictsTitle?(_=h.length>0?(0,$.jsxs)(`div`,{className:`rounded-xl border border-amber-500/30 bg-amber-500/5 px-4 py-3 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:l.conflictsTitle}),(0,$.jsx)(`p`,{className:`mt-1`,children:l.conflictsHint}),(0,$.jsx)(`ul`,{className:`mt-2 list-inside list-disc text-xs`,children:h.map(Ot)})]}):null,t[9]=h,t[10]=l.conflictsHint,t[11]=l.conflictsTitle,t[12]=_):_=t[12];let v;t[13]===l.pickMethod?v=t[14]:(v=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:l.pickMethod}),t[13]=l.pickMethod,t[14]=v);let b;t[15]===n?b=t[16]:(b=()=>n(`tailscale`),t[15]=n,t[16]=b);let x;t[17]!==l.configure||t[18]!==l.recommended||t[19]!==l.tailscaleCardDesc||t[20]!==l.tailscaleCardTitle||t[21]!==b?(x=(0,$.jsx)(Et,{icon:y,title:l.tailscaleCardTitle,description:l.tailscaleCardDesc,recommended:!0,recommendedLabel:l.recommended,openLabel:l.configure,onOpen:b}),t[17]=l.configure,t[18]=l.recommended,t[19]=l.tailscaleCardDesc,t[20]=l.tailscaleCardTitle,t[21]=b,t[22]=x):x=t[22];let S;t[23]===n?S=t[24]:(S=()=>n(`public`),t[23]=n,t[24]=S);let w;t[25]!==l.configure||t[26]!==l.publicCardDesc||t[27]!==l.publicCardTitle||t[28]!==S?(w=(0,$.jsx)(Et,{icon:C,title:l.publicCardTitle,description:l.publicCardDesc,openLabel:l.configure,onOpen:S}),t[25]=l.configure,t[26]=l.publicCardDesc,t[27]=l.publicCardTitle,t[28]=S,t[29]=w):w=t[29];let T;t[30]===n?T=t[31]:(T=()=>n(`reverse-proxy`),t[30]=n,t[31]=T);let E;t[32]!==l.configure||t[33]!==l.reverseProxyCardDesc||t[34]!==l.reverseProxyCardTitle||t[35]!==T?(E=(0,$.jsx)(Et,{icon:R,title:l.reverseProxyCardTitle,description:l.reverseProxyCardDesc,openLabel:l.configure,onOpen:T}),t[32]=l.configure,t[33]=l.reverseProxyCardDesc,t[34]=l.reverseProxyCardTitle,t[35]=T,t[36]=E):E=t[36];let D;t[37]===n?D=t[38]:(D=()=>n(`ssh`),t[37]=n,t[38]=D);let O;t[39]!==l.configure||t[40]!==l.sshCardDesc||t[41]!==l.sshCardTitle||t[42]!==D?(O=(0,$.jsx)(Et,{icon:K,title:l.sshCardTitle,description:l.sshCardDesc,openLabel:l.configure,onOpen:D}),t[39]=l.configure,t[40]=l.sshCardDesc,t[41]=l.sshCardTitle,t[42]=D,t[43]=O):O=t[43];let k;t[44]===n?k=t[45]:(k=()=>n(`lan`),t[44]=n,t[45]=k);let A;t[46]!==l.configure||t[47]!==l.lanCardDesc||t[48]!==l.lanCardTitle||t[49]!==k?(A=(0,$.jsx)(Et,{icon:M,title:l.lanCardTitle,description:l.lanCardDesc,openLabel:l.configure,onOpen:k}),t[46]=l.configure,t[47]=l.lanCardDesc,t[48]=l.lanCardTitle,t[49]=k,t[50]=A):A=t[50];let j;t[51]!==w||t[52]!==E||t[53]!==O||t[54]!==A||t[55]!==x?(j=(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:[x,w,E,O,A]}),t[51]=w,t[52]=E,t[53]=O,t[54]=A,t[55]=x,t[56]=j):j=t[56];let N;t[57]!==j||t[58]!==v?(N=(0,$.jsxs)(`div`,{children:[v,j]}),t[57]=j,t[58]=v,t[59]=N):N=t[59];let P;t[60]===l.oneAtATimeHint?P=t[61]:(P=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:l.oneAtATimeHint}),t[60]=l.oneAtATimeHint,t[61]=P);let F;t[62]===s.advanced.proxyTitle?F=t[63]:(F=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:s.advanced.proxyTitle}),t[62]=s.advanced.proxyTitle,t[63]=F);let I;t[64]===s.advanced.proxyBody?I=t[65]:(I=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s.advanced.proxyBody}),t[64]=s.advanced.proxyBody,t[65]=I);let L;t[66]!==r||t[67]!==s.advanced.proxyDocs?(L=(0,$.jsx)(Qe,{language:r,label:s.advanced.proxyDocs,section:`advanced`,className:`mt-2`}),t[66]=r,t[67]=s.advanced.proxyDocs,t[68]=L):L=t[68];let z;t[69]!==F||t[70]!==I||t[71]!==L?(z=(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-base px-4 py-3`,children:[F,I,L]}),t[69]=F,t[70]=I,t[71]=L,t[72]=z):z=t[72];let B;t[73]!==l.docsLink||t[74]!==r?(B=(0,$.jsx)(Qe,{language:r,label:l.docsLink}),t[73]=l.docsLink,t[74]=r,t[75]=B):B=t[75];let V;return t[76]!==N||t[77]!==P||t[78]!==z||t[79]!==B||t[80]!==g||t[81]!==_?(V=(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[g,_,N,P,z,B]}),t[76]=N,t[77]=P,t[78]=z,t[79]=B,t[80]=g,t[81]=_,t[82]=V):V=t[82],V}function Ot(e){return(0,$.jsx)(`li`,{children:e.message},e.code)}function kt(e){return e.token}function At(e){return e.language}async function jt(e){let t=await f(l(`/api/tunnel/pair/probe-public`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:e})});if(!t.ok&&t.status!==400)throw Error(`Probe failed (${t.status})`);return await t.json()}async function Mt(e){await u(l(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{publicUrl:e??null}})})}function Nt(e){let t=e.split(`.`).map(e=>Number.parseInt(e,10));if(t.length!==4||t.some(e=>!Number.isFinite(e)))return!1;let[n,r]=t;return n===10||n===127||n===169&&r===254||n===172&&r>=16&&r<=31||n===192&&r===168||n===100&&r>=64&&r<=127}function Pt(){return(0,Q.useMemo)(()=>{if(typeof window>`u`)return null;let{protocol:e,hostname:t,origin:n}=window.location;if(e!==`https:`&&e!==`http:`)return null;let r=t.toLowerCase();return!r||r===`localhost`||r===`127.0.0.1`||r===`::1`||r===`[::1]`||r.endsWith(`.local`)||r.endsWith(`.localhost`)||Nt(r)?null:n.toLowerCase().replace(/\/+$/,``)},[])}function Ft(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,me,`dark:border-edge`)}function It(e){return(e?.candidates.find(e=>e.kind===`reverse-proxy`))?.url?.trim()||null}function Lt(e){return(e?.candidates.find(e=>e.kind===`lan`&&e.reachable))?.url?.trim()||null}function Rt(){let e=o(e=>e.language),t=a(e).remoteAccess.reverseProxy,n=!!c(e=>e.token),r=Pt(),{mutate:l}=p(),{data:u,mutate:d}=m(n?`tunnel-pair-context`:null,ce,{refreshInterval:6e4}),f=It(u),[g,b]=(0,Q.useState)(``),[x,S]=(0,Q.useState)({busy:!1,result:null}),[C,w]=(0,Q.useState)({busy:!1,error:null});(0,Q.useEffect)(()=>{g||(f?b(f):r&&b(r))},[f,r,g]);let T=(0,Q.useMemo)(()=>g.trim()||(f??r??``),[f,r,g]),D=!f&&!!r&&T===r,O=Lt(u),{data:k,mutate:j}=m(n&&T?[`reverse-proxy-pair`,T]:null,()=>A(),{refreshInterval:4*6e4,revalidateOnFocus:!1}),M=(0,Q.useMemo)(()=>!T||!k?.pairingSecret?``:s({baseUrl:T,pairingSecret:k.pairingSecret,lanUrl:O}),[T,O,k?.pairingSecret]),N=h(()=>tt(M),[M],{enabled:!!M,initial:null,errorData:null}),P=(0,Q.useCallback)(async()=>{let e=g.trim()||T;if(e){S({busy:!0,result:null});try{S({busy:!1,result:await jt(e)})}catch(e){S({busy:!1,result:{ok:!1,code:`NETWORK_ERROR`,message:e instanceof Error?e.message:String(e)}})}}},[g,T]),F=(0,Q.useCallback)(async()=>{let e=T.trim();if(e){w({busy:!0,error:null});try{await Mt(e),await d(),await l(`tunnel-pair-context`),w({busy:!1,error:null})}catch(e){w({busy:!1,error:e instanceof Error?e.message:String(e)})}}},[T,l,d]),I=(0,Q.useCallback)(async()=>{w({busy:!0,error:null});try{await Mt(null),await d(),await l(`tunnel-pair-context`),b(``),S({busy:!1,result:null}),w({busy:!1,error:null})}catch(e){w({busy:!1,error:e instanceof Error?e.message:String(e)})}},[l,d]),L=(0,Q.useCallback)(async()=>{await j()},[j]);return n?(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(ye,{children:[(0,$.jsx)(_e,{icon:y,title:t.title,subtitle:t.subtitle}),(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`reverse-proxy-url`,children:t.urlLabel}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch`,children:[(0,$.jsx)(`input`,{id:`reverse-proxy-url`,className:i(Ft(),`font-mono text-xs sm:flex-1 sm:min-w-0 sm:w-auto`),type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:t.urlPlaceholder,value:g,onChange:e=>{b(e.target.value),S({busy:!1,result:null})}}),(0,$.jsxs)(_,{type:`button`,variant:`secondary`,className:`shrink-0 whitespace-nowrap`,onClick:()=>void P(),disabled:x.busy||!g.trim(),children:[x.busy?(0,$.jsx)(re,{className:`size-3.5 animate-spin`}):null,x.busy?t.probing:t.probeButton]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.urlHint}),D&&r?(0,$.jsxs)(`div`,{className:`rounded-lg border border-accent/40 bg-accent-soft/50 px-3 py-2 text-xs leading-relaxed text-accent-fg`,children:[(0,$.jsx)(`div`,{className:`font-medium`,children:t.autoDetectedTitle}),(0,$.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px]`,children:r}),(0,$.jsx)(`p`,{className:`mt-1`,children:t.autoDetectedHint})]}):null,x.result?(0,$.jsx)(zt,{result:x.result,labels:t.probeStatus}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:[T&&f!==T?(0,$.jsxs)(_,{type:`button`,onClick:()=>void F(),disabled:C.busy,children:[C.busy?(0,$.jsx)(re,{className:`size-3.5 animate-spin`}):null,C.busy?t.saving:t.saveAsDefault]}):null,f?(0,$.jsx)(_,{type:`button`,variant:`ghost`,onClick:()=>void I(),disabled:C.busy,children:t.clear}):null]}),C.error?(0,$.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:C.error}):null,(0,$.jsx)(`div`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs leading-relaxed text-amber-950 dark:border-amber-800/60 dark:bg-amber-950/30 dark:text-amber-100`,children:t.certWarning})]})]}),(0,$.jsxs)(ye,{children:[(0,$.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:t.qrTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.qrSubtitle})]}),M?(0,$.jsxs)(_,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>void L(),children:[(0,$.jsx)(E,{className:`size-4`}),t.refreshQr]}):null]}),T?k?.pairingSecret?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 sm:items-start`,children:[(0,$.jsxs)(`div`,{className:`break-all font-mono text-[11px] text-fg-muted`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:`baseUrl:`}),` `,T,O?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`br`,{}),(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:`lanUrl:`}),` `,O]}):null]}),N.data?(0,$.jsx)(`img`,{src:N.data,alt:``,className:`size-56 rounded-lg border border-edge-subtle bg-white object-contain p-3 dark:border-edge`}):N.loading?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.encoding}):null,(0,$.jsx)(v,{text:M,labels:{copy:t.copyLink,copied:t.copied,copyFailed:a(e).clipboard.copyFailed}})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.mintingSecret}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noUrlYet})]})]}):null}function zt(e){let t=(0,Z.c)(18),{result:n,labels:r}=e;if(n.ok){let e;t[0]===r.ok?e=t[1]:(e=(0,$.jsx)(`span`,{className:`font-medium`,children:r.ok}),t[0]=r.ok,t[1]=e);let i;t[2]===n.latencyMs?i=t[3]:(i=(0,$.jsxs)(`span`,{className:`font-mono`,children:[n.latencyMs,`ms`]}),t[2]=n.latencyMs,t[3]=i);let a;t[4]!==r.mobileReady||t[5]!==n.mobilePairing?(a=n.mobilePairing?(0,$.jsxs)($.Fragment,{children:[` · `,(0,$.jsx)(`span`,{children:r.mobileReady})]}):null,t[4]=r.mobileReady,t[5]=n.mobilePairing,t[6]=a):a=t[6];let o;return t[7]!==e||t[8]!==i||t[9]!==a?(o=(0,$.jsxs)(`div`,{className:`rounded-lg border border-emerald-200 bg-emerald-50 px-3 py-2 text-xs text-emerald-900 dark:border-emerald-800/60 dark:bg-emerald-950/30 dark:text-emerald-100`,children:[e,` · `,i,a]}),t[7]=e,t[8]=i,t[9]=a,t[10]=o):o=t[10],o}let i=r[`code_${n.code}`]??r.codeUnknown,a;t[11]===i?a=t[12]:(a=(0,$.jsx)(`span`,{className:`font-medium`,children:i}),t[11]=i,t[12]=a);let o;t[13]===n.message?o=t[14]:(o=n.message?(0,$.jsxs)($.Fragment,{children:[` — `,(0,$.jsx)(`span`,{className:`font-mono break-all`,children:n.message})]}):null,t[13]=n.message,t[14]=o);let s;return t[15]!==a||t[16]!==o?(s=(0,$.jsxs)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-900 dark:border-red-800/60 dark:bg-red-950/30 dark:text-red-100`,children:[a,o]}),t[15]=a,t[16]=o,t[17]=s):s=t[17],s}var Bt=[`guide`,`tailscale`,`public`,`reverse-proxy`,`ssh`,`lan`];function Vt(e){return e&&Bt.includes(e)?e:`guide`}function Ht(e,t){return e.tabs[t]}function Ut(e,t){return e.tabIntro[t]}function Wt(e){switch(e){case`tailscale`:return`tailscale-serve`;case`public`:return`public-tunnel`;case`reverse-proxy`:return`reverse-proxy`;case`ssh`:return`ssh-tunnel`;case`lan`:return`lan`;default:return}}function Gt(e){let t=(0,Z.c)(7),{tab:n,onOpenTab:r}=e;switch(n){case`guide`:{let e;return t[0]===r?e=t[1]:(e=(0,$.jsx)(Dt,{onOpenTab:r}),t[0]=r,t[1]=e),e}case`tailscale`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(pt,{embedded:!0}),t[2]=e):e=t[2],e}case`public`:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(st,{embedded:!0}),t[3]=e):e=t[3],e}case`reverse-proxy`:{let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Rt,{}),t[4]=e):e=t[4],e}case`ssh`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(yt,{}),t[5]=e):e=t[5],e}case`lan`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(mt,{}),t[6]=e):e=t[6],e}}}function Kt(){let e=(0,Z.c)(2),t=o(Jt),n=a(t).remoteAccess,r=!!c(qt),[i,s]=S(),l=Vt(i.get(`tab`)),u;e[0]===s?u=e[1]:(u=e=>{s(t=>{let n=new URLSearchParams(t);return e===`guide`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[0]=s,e[1]=u);let d=u,f=Ut(n,l),p=Bt.map(e=>({id:e,label:Ht(n,e)}));return(0,$.jsxs)(Ce,{children:[(0,$.jsx)(xe,{title:n.pageTitle,subtitle:n.pageSubtitle,meta:(0,$.jsx)(Qe,{language:t,label:n.docsLink,section:Wt(l),className:`mt-1`})}),r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(x,{items:p,activeTab:l,onChange:d,ariaLabel:n.tabsAria,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`}),(0,$.jsx)(Se,{id:l,activeTab:l,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`,title:Ht(n,l),hint:l===`public`?void 0:f,children:(0,$.jsx)(Gt,{tab:l,onOpenTab:d})})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.guide.needToken})]})}function qt(e){return e.token}function Jt(e){return e.language}export{Kt as RemoteAccessHub};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-B5O4OIEo.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{c as s,i as c,n as l}from"./fetch-ovkvM8KQ.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{$a as d,$r as f,Ba as p,Gr as m,H as h,Ha as g,Hs as _,Ic as v,Jr as y,Kr as b,Mi as x,Ms as S,Na as C,Oc as w,Pa as T,Ro as ee,So as E,Us as D,Va as O,Xr as k,Yr as A,Zo as j,Zr as M,aa as te,ba as ne,ct as N,ds as P,ea as F,ei as I,fs as L,ga as R,ia as z,ji as B,kc as re,ki as ie,lt as ae,ms as oe,ni as V,ns as H,oa as U,qr as se,ra as W,ri as G,ta as ce,tc as le,ti as K,ut as ue,va as q,vo as de,ya as J,za as Y,zo as fe}from"./index-DdqSO9R2.js";import{n as pe,t as X}from"./settings-form-section-Dg6LBbcr.js";import{n as me,r as he}from"./segmented-styles-BL8oLBEp.js";var Z=e(t(),1),ge=n(),Q=r();function _e(e){let t=new Date(e),n=Math.floor((new Date().getTime()-t.getTime())/(1e3*60*60*24));return n===0?t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):n===1?`Yesterday`:n<7?t.toLocaleDateString([],{weekday:`short`}):t.toLocaleDateString([],{month:`short`,day:`numeric`})}function ve(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ye(e){let t=(0,ge.c)(105),{session:n,variant:r,labels:a,sessionAgentId:o,sessionAgentAvatar:s,onOpen:c,onAction:l}=e,u;t[0]!==a.unnamedSession||t[1]!==n.name?(u=n.name?.trim()||a.unnamedSession,t[0]=a.unnamedSession,t[1]=n.name,t[2]=u):u=t[2];let f=u,p;t[3]===n.name?p=t[4]:(p=n.name?.trim(),t[3]=n.name,t[4]=p);let m=!!p,h=n.status===`archived`,g=n.status===`pinned`,v=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,y;t[5]===v?y=t[6]:(y=i(`group flex min-w-0 w-full max-w-full cursor-pointer flex-col rounded-xl bg-surface-base text-left transition-colors duration-150 ease-out`,`hover:bg-surface-hover active:scale-[0.99]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,v),t[5]=v,t[6]=y);let b;t[7]===c?b=t[8]:(b=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},t[7]=c,t[8]=b);let x=r===`list`&&`sm:py-3`,S;t[9]===x?S=t[10]:(S=i(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,x),t[9]=x,t[10]=S);let T;t[11]===n.sourceChannel?T=t[12]:(T=(0,Q.jsx)(`div`,{className:`flex min-w-0 items-center gap-2`,children:(0,Q.jsx)(`span`,{className:`truncate text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:n.sourceChannel})}),t[11]=n.sourceChannel,t[12]=T);let E;t[13]===g?E=t[14]:(E=g?(0,Q.jsx)(fe,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[13]=g,t[14]=E);let D;t[15]===n.updatedAt?D=t[16]:(D=_e(n.updatedAt),t[15]=n.updatedAt,t[16]=D);let k;t[17]===D?k=t[18]:(k=(0,Q.jsx)(`span`,{children:D}),t[17]=D,t[18]=k);let A;t[19]!==k||t[20]!==E?(A=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[E,k]}),t[19]=k,t[20]=E,t[21]=A):A=t[21];let M;t[22]!==A||t[23]!==S||t[24]!==T?(M=(0,Q.jsxs)(`div`,{className:S,children:[T,A]}),t[22]=A,t[23]=S,t[24]=T,t[25]=M):M=t[25];let te=r===`list`&&`sm:py-3`,ne;t[26]===te?ne=t[27]:(ne=i(`min-w-0 flex-1 px-3 py-2`,te),t[26]=te,t[27]=ne);let N=r===`list`&&`sm:items-start`,P;t[28]===N?P=t[29]:(P=i(`flex gap-3`,N),t[28]=N,t[29]=P);let F;t[30]!==s||t[31]!==o?(F=(0,Q.jsx)(G,{agentId:o,avatar:s,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}),t[30]=s,t[31]=o,t[32]=F):F=t[32];let I;t[33]===f?I=t[34]:(I=(0,Q.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:f,children:f}),t[33]=f,t[34]=I);let L;t[35]!==n.key||t[36]!==m?(L=m?(0,Q.jsx)(`div`,{className:`mt-0.5 min-w-0 max-w-full truncate font-mono text-[11px] text-fg-subtle`,title:n.key,children:n.key}):null,t[35]=n.key,t[36]=m,t[37]=L):L=t[37];let R;t[38]!==I||t[39]!==L?(R=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[I,L]}),t[38]=I,t[39]=L,t[40]=R):R=t[40];let z;t[41]!==P||t[42]!==F||t[43]!==R?(z=(0,Q.jsxs)(`div`,{className:P,children:[F,R]}),t[41]=P,t[42]=F,t[43]=R,t[44]=z):z=t[44];let B;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Q.jsx)(j,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[45]=B):B=t[45];let ie;t[46]===n.messageCount?ie=t[47]:(ie=(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[B,n.messageCount]}),t[46]=n.messageCount,t[47]=ie);let ae;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,Q.jsx)(O,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[48]=ae):ae=t[48];let oe;t[49]===n.estimatedTokens?oe=t[50]:(oe=ve(n.estimatedTokens),t[49]=n.estimatedTokens,t[50]=oe);let V;t[51]===oe?V=t[52]:(V=(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[ae,oe]}),t[51]=oe,t[52]=V);let H;t[53]!==ie||t[54]!==V?(H=(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[ie,V]}),t[53]=ie,t[54]=V,t[55]=H):H=t[55];let U;t[56]===n.tags?U=t[57]:(U=n.tags.length>0?(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(Se),n.tags.length>3?(0,Q.jsxs)(`span`,{className:`text-[11px] text-fg-disabled`,children:[`+`,n.tags.length-3]}):null]}):null,t[56]=n.tags,t[57]=U);let se;t[58]!==ne||t[59]!==z||t[60]!==H||t[61]!==U?(se=(0,Q.jsxs)(`div`,{className:ne,children:[z,H,U]}),t[58]=ne,t[59]=z,t[60]=H,t[61]=U,t[62]=se):se=t[62];let W;t[63]===l?W=t[64]:(W=()=>l(`continue`),t[63]=l,t[64]=W);let ce;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,Q.jsx)(j,{className:`size-4`,strokeWidth:1.75}),t[65]=ce):ce=t[65];let le;t[66]!==a.continueChat||t[67]!==W?(le=(0,Q.jsx)(`button`,{type:`button`,className:C,title:a.continueChat,"aria-label":a.continueChat,onClick:W,children:ce}),t[66]=a.continueChat,t[67]=W,t[68]=le):le=t[68];let K;t[69]!==h||t[70]!==a.archive||t[71]!==a.unarchive||t[72]!==l?(K=h?(0,Q.jsx)(`button`,{type:`button`,className:C,title:a.unarchive,"aria-label":a.unarchive,onClick:()=>l(`unarchive`),children:(0,Q.jsx)(re,{className:`size-4`,strokeWidth:1.75})}):(0,Q.jsx)(`button`,{type:`button`,className:C,title:a.archive,"aria-label":a.archive,onClick:()=>l(`archive`),children:(0,Q.jsx)(w,{className:`size-4`,strokeWidth:1.75})}),t[69]=h,t[70]=a.archive,t[71]=a.unarchive,t[72]=l,t[73]=K):K=t[73];let ue;t[74]!==g||t[75]!==a.pin||t[76]!==a.unpin||t[77]!==l?(ue=g?(0,Q.jsx)(`button`,{type:`button`,className:C,title:a.unpin,"aria-label":a.unpin,onClick:()=>l(`unpin`),children:(0,Q.jsx)(ee,{className:`size-4`,strokeWidth:1.75})}):(0,Q.jsx)(`button`,{type:`button`,className:C,title:a.pin,"aria-label":a.pin,onClick:()=>l(`pin`),children:(0,Q.jsx)(fe,{className:`size-4`,strokeWidth:1.75})}),t[74]=g,t[75]=a.pin,t[76]=a.unpin,t[77]=l,t[78]=ue):ue=t[78];let q;t[79]===l?q=t[80]:(q=()=>l(`export`),t[79]=l,t[80]=q);let de;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,Q.jsx)(_,{className:`size-4`,strokeWidth:1.75}),t[81]=de):de=t[81];let J;t[82]!==a.export||t[83]!==q?(J=(0,Q.jsx)(`button`,{type:`button`,className:C,title:a.export,"aria-label":a.export,onClick:q,children:de}),t[82]=a.export,t[83]=q,t[84]=J):J=t[84];let Y;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(Y=i(C,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[85]=Y):Y=t[85];let pe;t[86]===l?pe=t[87]:(pe=()=>l(`delete`),t[86]=l,t[87]=pe);let X;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(X=(0,Q.jsx)(d,{className:`size-4`,strokeWidth:1.75}),t[88]=X):X=t[88];let me;t[89]!==a.delete||t[90]!==pe?(me=(0,Q.jsx)(`button`,{type:`button`,className:Y,title:a.delete,"aria-label":a.delete,onClick:pe,children:X}),t[89]=a.delete,t[90]=pe,t[91]=me):me=t[91];let he;t[92]!==le||t[93]!==K||t[94]!==ue||t[95]!==J||t[96]!==me?(he=(0,Q.jsxs)(`div`,{role:`group`,className:`flex flex-wrap items-center gap-0.5 border-t border-edge-subtle/80 bg-surface-hover/25 p-2 dark:border-edge-subtle`,onClick:xe,onKeyDown:be,children:[le,K,ue,J,me]}),t[92]=le,t[93]=K,t[94]=ue,t[95]=J,t[96]=me,t[97]=he):he=t[97];let Z;return t[98]!==c||t[99]!==M||t[100]!==se||t[101]!==y||t[102]!==he||t[103]!==b?(Z=(0,Q.jsxs)(`div`,{role:`button`,tabIndex:0,className:y,onClick:c,onKeyDown:b,children:[M,se,he]}),t[98]=c,t[99]=M,t[100]=se,t[101]=y,t[102]=he,t[103]=b,t[104]=Z):Z=t[104],Z}function be(e){return e.stopPropagation()}function xe(e){return e.stopPropagation()}function Se(e){return(0,Q.jsx)(`span`,{className:`max-w-full break-words rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e},e)}function $(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ce(e){return e===`main`||e===`per-peer`||e===`per-channel-peer`||e===`per-account-channel-peer`?e:`main`}function we(e){let t=$(e)?e:{},n=$(t.session)?t.session:{},r=$(n.storage)?n.storage:{},i=typeof r.pruneAfterDays==`number`&&Number.isFinite(r.pruneAfterDays)?Math.max(0,Math.floor(r.pruneAfterDays)):typeof r.pruneAfterMs==`number`&&Number.isFinite(r.pruneAfterMs)?Math.max(0,Math.round(r.pruneAfterMs/864e5)):null,a=typeof r.maxEntries==`number`&&Number.isFinite(r.maxEntries)?Math.max(1,Math.floor(r.maxEntries)):null;return{dmScope:Ce(n.dmScope),pruneAfterDays:i,maxEntries:a}}async function Te(e){await l(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),B()}function Ee(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,Y,`dark:border-edge`)}var De=N();function Oe({hasToken:e}){let t=a(o(e=>e.language)).sessions.config,{data:n,isLoading:r}=x(e),i=(0,Z.useMemo)(()=>n?.payload?.config===void 0?null:we(n.payload.config),[n]),[s,c]=(0,Z.useReducer)(De,{form:null,baseline:null}),l=s.form,u=s.baseline,[d,f]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(null),g=(0,Z.useRef)(!1),_=(0,Z.useRef)(null);ae({enabled:e,parsed:i,dirty:g.current,trackedParsedRef:_,dispatch:c,onResetDirty:()=>{g.current=!1}});let v=l&&u&&JSON.stringify(l)!==JSON.stringify(u),y=(0,Z.useCallback)(e=>{g.current=!0,c({type:`patch`,patch:e})},[]);return!e||!l?r?(0,Q.jsx)(X,{children:(0,Q.jsx)(H,{className:`size-4 animate-spin text-fg-muted`})}):null:(0,Q.jsxs)(X,{children:[(0,Q.jsx)(pe,{icon:D,title:t.title,subtitle:t.hint}),(0,Q.jsxs)(`div`,{className:`mb-4 flex justify-end gap-2`,children:[(0,Q.jsx)(p,{type:`button`,variant:`secondary`,disabled:!v||d,onClick:()=>c({type:`discard`}),children:t.discard}),(0,Q.jsx)(p,{type:`button`,variant:`primary`,disabled:!v||d,onClick:()=>{(async()=>{f(!0),h(null);try{await Te(l),g.current=!1,c({type:`saved`,value:l})}catch(e){h(e instanceof Error?e.message:t.saveError)}finally{f(!1)}})()},children:d?t.saving:t.save})]}),m?(0,Q.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:m}):null,(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.dmScope}),(0,Q.jsxs)(R,{className:Ee(),value:l.dmScope,onChange:e=>y({dmScope:e.target.value}),children:[(0,Q.jsx)(q,{value:`main`,children:t.dmScopeMain}),(0,Q.jsx)(q,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Q.jsx)(q,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Q.jsx)(q,{value:`per-account-channel-peer`,children:t.dmScopePerAccountChannelPeer})]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.dmScopeHint})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.pruneAfterDays}),(0,Q.jsx)(`input`,{type:`number`,min:0,className:Ee(),value:l.pruneAfterDays??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();y({pruneAfterDays:t===``?null:Math.max(0,Math.floor(Number(t)||0))})}})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.maxEntries}),(0,Q.jsx)(`input`,{type:`number`,min:1,className:Ee(),value:l.maxEntries??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();y({maxEntries:t===``?null:Math.max(1,Math.floor(Number(t)||1))})}})]})]})]})}function ke(e){if(typeof e==`string`)return e.length>2e3?`${e.slice(0,2e3)}…`:e;try{let t=JSON.stringify(e,null,2);return t.length>2e3?`${t.slice(0,2e3)}…`:t}catch{return String(e)}}function Ae(e){let t=(0,ge.c)(60),{open:n,loading:r,session:a,sessionAgentId:o,sessionAgentAvatar:s,labels:c,onClose:l,onArchive:u,onUnarchive:d,onPin:f,onUnpin:m,onExport:h,onDelete:_}=e,v=a?.status===`archived`,y=a?.status===`pinned`,b;t[0]===l?b=t[1]:(b=e=>!e&&l(),t[0]=l,t[1]=b);let x;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Q.jsx)(W,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim`,ne)}),t[2]=x):x=t[2];let S;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(S=i(`xopc-drawer-right fixed right-0 top-0 flex size-full max-w-lg flex-col border-l border-edge bg-surface-panel shadow-popover outline-none`,J,`dark:border-edge`),t[3]=S):S=t[3];let C;t[4]!==a||t[5]!==s||t[6]!==o?(C=a&&o?(0,Q.jsx)(G,{agentId:o,avatar:s,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}):null,t[4]=a,t[5]=s,t[6]=o,t[7]=C):C=t[7];let w;t[8]!==c.unnamedSession||t[9]!==a?.name?(w=a?.name?.trim()||c.unnamedSession,t[8]=c.unnamedSession,t[9]=a?.name,t[10]=w):w=t[10];let T;t[11]===w?T=t[12]:(T=(0,Q.jsx)(U,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:w}),t[11]=w,t[12]=T);let ee;t[13]!==C||t[14]!==T?(ee=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[C,T]}),t[13]=C,t[14]=T,t[15]=ee):ee=t[15];let E;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Q.jsx)(g,{className:`size-5`,strokeWidth:1.75}),t[16]=E):E=t[16];let D;t[17]===c.close?D=t[18]:(D=(0,Q.jsx)(F,{asChild:!0,children:(0,Q.jsx)(p,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":c.close,children:E})}),t[17]=c.close,t[18]=D);let O;t[19]!==ee||t[20]!==D?(O=(0,Q.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3 dark:border-edge`,children:[ee,D]}),t[19]=ee,t[20]=D,t[21]=O):O=t[21];let k;t[22]!==c.detailLoading||t[23]!==c.detailMessages||t[24]!==r||t[25]!==a?(k=r?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:c.detailLoading}):a?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`dl`,{className:`mb-4 grid gap-2 text-xs text-fg-muted`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-fg-disabled`,children:`Key`}),(0,Q.jsx)(`dd`,{className:`mt-0.5 break-all font-mono text-fg`,children:a.key})]}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-4`,children:(0,Q.jsxs)(`span`,{children:[a.messageCount,` msgs · `,a.estimatedTokens,` tok`]})})]}),(0,Q.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:c.detailMessages}),(0,Q.jsx)(`ul`,{className:`space-y-3`,children:a.messages.map(je)})]}):null,t[22]=c.detailLoading,t[23]=c.detailMessages,t[24]=r,t[25]=a,t[26]=k):k=t[26];let A;t[27]===k?A=t[28]:(A=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:k}),t[27]=k,t[28]=A);let j;t[29]!==c.detailExport||t[30]!==h?(j=(0,Q.jsx)(p,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:h,children:c.detailExport}),t[29]=c.detailExport,t[30]=h,t[31]=j):j=t[31];let M;t[32]!==v||t[33]!==c.archive||t[34]!==c.unarchive||t[35]!==u||t[36]!==d?(M=v?(0,Q.jsx)(p,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:d,children:c.unarchive}):(0,Q.jsx)(p,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:u,children:c.archive}),t[32]=v,t[33]=c.archive,t[34]=c.unarchive,t[35]=u,t[36]=d,t[37]=M):M=t[37];let N;t[38]!==y||t[39]!==c.pin||t[40]!==c.unpin||t[41]!==f||t[42]!==m?(N=y?(0,Q.jsx)(p,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:m,children:c.unpin}):(0,Q.jsx)(p,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:f,children:c.pin}),t[38]=y,t[39]=c.pin,t[40]=c.unpin,t[41]=f,t[42]=m,t[43]=N):N=t[43];let P;t[44]!==c.delete||t[45]!==_?(P=(0,Q.jsx)(p,{type:`button`,variant:`secondary`,className:`text-sm text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`,onClick:_,children:c.delete}),t[44]=c.delete,t[45]=_,t[46]=P):P=t[46];let I;t[47]!==j||t[48]!==M||t[49]!==N||t[50]!==P?(I=(0,Q.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3 dark:border-edge`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[j,M,N,P]})}),t[47]=j,t[48]=M,t[49]=N,t[50]=P,t[51]=I):I=t[51];let L;t[52]!==O||t[53]!==A||t[54]!==I?(L=(0,Q.jsxs)(z,{children:[x,(0,Q.jsxs)(ce,{className:S,"aria-describedby":void 0,children:[O,A,I]})]}),t[52]=O,t[53]=A,t[54]=I,t[55]=L):L=t[55];let R;return t[56]!==n||t[57]!==b||t[58]!==L?(R=(0,Q.jsx)(te,{open:n,onOpenChange:b,children:L}),t[56]=n,t[57]=b,t[58]=L,t[59]=R):R=t[59],R}function je(e){return(0,Q.jsxs)(`li`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/50 p-2 dark:border-edge`,children:[(0,Q.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase text-fg-subtle`,children:e.role}),(0,Q.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-fg-muted`,children:ke(e.content)})]},`${e.timestamp??``}-${e.role}-${ke(e.content).slice(0,24)}`)}var Me=20;function Ne(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var Pe=new Set([`all`,`active`,`pinned`,`archived`]),Fe=new Set([`grid`,`list`]),Ie=[`sessions`,`settings`];function Le(e){return e&&Ie.includes(e)?e:`sessions`}function Re(e,t){return t===`sessions`?e.tabsSessions:e.tabsSettings}function ze(e,t){return t===`sessions`?e.tabsSessionsHint:e.tabsSettingsHint}function Be(e){let t=(0,ge.c)(7),{s:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=Ie.map(e=>({id:e,label:Re(n,e),icon:e===`sessions`?oe:de})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,Q.jsx)(h,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`sessions-tab`,panelIdPrefix:`sessions-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function Ve(e){let t=(0,ge.c)(10),{s:n,id:r,activeTab:i,plain:a,children:o}=e,s=a===void 0?!1:a;if(i!==r)return null;let c=`sessions-panel-${r}`,l=`sessions-tab-${r}`,u=s?`contents`:`rounded-2xl border border-edge bg-surface-base px-4 py-5 sm:px-5`,d;t[0]!==o||t[1]!==r||t[2]!==s||t[3]!==n?(d=s?o:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`mb-5`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:Re(n,r)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:ze(n,r)})]}),(0,Q.jsx)(`div`,{className:`space-y-4`,children:o})]}),t[0]=o,t[1]=r,t[2]=s,t[3]=n,t[4]=d):d=t[4];let f;return t[5]!==c||t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,Q.jsx)(`section`,{id:c,role:`tabpanel`,"aria-labelledby":l,className:u,children:d}),t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9],f}function He(e){let t=e.get(`status`),n=e.get(`view`);return{searchInput:e.get(`q`)??``,debouncedSearch:(e.get(`q`)??``).trim(),statusFilter:Pe.has(t)?t:`all`,viewMode:Fe.has(n)?n:`grid`,channelFilter:(e.get(`channel`)??``).trim(),sessions:[],loading:!1,error:null,hasMore:!1,stats:null,detailOpen:!1,detailLoading:!1,detailSession:null,confirmOpen:!1,confirmKey:null}}function Ue(){let e=a(o(e=>e.language)),t=e.sessions,n=s(e=>e.token),r=!!n,{data:c,mutate:l}=u(r?[`gateway-chat-agents`,n]:null,ie,{revalidateOnFocus:!1}),d=c?.defaultId??`main`,h=c?.items??[],[g,_]=v(),x=Le(g.get(`tab`)),C=(0,Z.useCallback)(e=>{let t=new URLSearchParams(g);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),_(t,{replace:!0})},[g,_]),[ee,D]=(0,Z.useReducer)(ue,g,He),{searchInput:O,debouncedSearch:j,statusFilter:N,viewMode:F,channelFilter:R,sessions:B,loading:re,error:ae,hasMore:H,stats:G,detailOpen:q,detailLoading:de,detailSession:Y,confirmOpen:pe,confirmKey:X}=ee;(0,Z.useEffect)(()=>{let e=setTimeout(()=>{let e=O.trim();j!==e&&D({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[O,j]);let ge=g.toString(),_e=(0,Z.useRef)(ge);if(_e.current!==ge){_e.current=ge;let e=g.get(`q`)??``,t=g.get(`status`),n=g.get(`view`),r=(g.get(`channel`)??``).trim(),i=Pe.has(t)?t:`all`,a=Fe.has(n)?n:`grid`,o=e.trim();D({type:`patch`,patch:{...O===e?{}:{searchInput:e},...j===o?{}:{debouncedSearch:o},...N===i?{}:{statusFilter:i},...F===a?{}:{viewMode:a},...R===r?{}:{channelFilter:r}}})}(0,Z.useEffect)(()=>{let e=new URLSearchParams(g),t=j.trim();t?e.set(`q`,t):e.delete(`q`),N===`all`?e.delete(`status`):e.set(`status`,N),F===`grid`?e.delete(`view`):e.set(`view`,F),R?e.set(`channel`,R):e.delete(`channel`),e.toString()!==g.toString()&&_(e,{replace:!0})},[j,g,_,N,F,R]),(0,Z.useEffect)(()=>{if(!r||x!==`sessions`)return;let e=!1;return(async()=>{D({type:`patch`,patch:{loading:!0,error:null}});try{let t=await k({limit:Me,offset:0,...j?{search:j}:{},...N===`all`?{}:{status:N},...R?{channel:R}:{}});if(e)return;D({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||D({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||D({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,x,j,N,R,t.loadError]),(0,Z.useEffect)(()=>{!r||x!==`sessions`||A().then(e=>D({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,x]),(0,Z.useEffect)(()=>{if(!r||x!==`sessions`)return;let e=()=>void l();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,x,l]),(0,Z.useEffect)(()=>{if(!r||x!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||D({type:`patch`,patch:{sessions:B.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:Y&&Y.key===t.key?{...Y,name:t.name}:Y}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,x,B,Y]);let ve=(0,Z.useCallback)(async()=>{if(!(!r||re||!H)){D({type:`patch`,patch:{loading:!0,error:null}});try{let e=await k({limit:Me,offset:B.length,...j?{search:j}:{},...N===`all`?{}:{status:N},...R?{channel:R}:{}});D({type:`patch`,patch:{sessions:[...B,...e.items],hasMore:e.hasMore}})}catch(e){D({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{D({type:`patch`,patch:{loading:!1}})}}},[r,re,H,B.length,j,N,R,t.loadError]),be=(0,Z.useCallback)((e,t)=>{D({type:`patch`,patch:{sessions:B.map(n=>n.key===e?{...n,status:t}:n),detailSession:Y&&Y.key===e?{...Y,status:t}:Y}})},[B,Y]),xe=(0,Z.useCallback)(async e=>{D({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{D({type:`patch`,patch:{detailSession:await y(e)}})}catch{D({type:`patch`,patch:{detailOpen:!1}})}finally{D({type:`patch`,patch:{detailLoading:!1}})}},[]),Se=e=>{xe(e)},$=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:e},bubbles:!0}));return}if(t===`delete`){D({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await m(e),be(e,`archived`);break;case`unarchive`:await f(e),be(e,`active`);break;case`pin`:await M(e),be(e,`pinned`);break;case`unpin`:await I(e),be(e,`active`);break;case`export`:{let t=await se(e),n=new Blob([t],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`session-${e.replace(/[^a-z0-9]/gi,`_`)}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r);break}default:break}A().then(e=>D({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Ce=async e=>{try{await b(e),D({type:`patch`,patch:{sessions:B.filter(t=>t.key!==e),detailSession:Y?.key===e?null:Y,...Y?.key===e?{detailOpen:!1}:{}}}),A().then(e=>D({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},we={continueChat:t.continueChat,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,export:t.export,delete:t.delete,unnamedSession:e.chat.newSession},Te={close:t.close,detailLoading:t.detailLoading,detailMessages:t.detailMessages,detailExport:t.detailExport,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,delete:t.delete,unnamedSession:e.chat.newSession},Ee=[{key:`all`,label:t.filterAll,icon:oe},{key:`active`,label:t.filterActive,icon:le},{key:`pinned`,label:t.filterPinned,icon:fe},{key:`archived`,label:t.filterArchived,icon:w}],De=(()=>{let e=Object.entries(G?.byChannel??{}).sort((e,t)=>t[1]-e[1]).slice(0,6).map(([e])=>e),t=new Set(e);for(let n of[`telegram`,`weixin`,`feishu`])t.has(n)||(e.push(n),t.add(n));return e.slice(0,8)})();return r?(0,Q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-surface-panel`,children:[(0,Q.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,Q.jsx)(`header`,{className:`flex flex-col gap-2`,children:(0,Q.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.title})}),(0,Q.jsx)(Be,{s:t,activeTab:x,onChange:C}),(0,Q.jsx)(Ve,{s:t,id:`settings`,activeTab:x,plain:!0,children:(0,Q.jsx)(Oe,{hasToken:r})}),(0,Q.jsxs)(Ve,{s:t,id:`sessions`,activeTab:x,plain:!0,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Ee.map(({key:e,label:t,icon:n})=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":N===e,onClick:()=>D({type:`patch`,patch:{statusFilter:e}}),className:i(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,T.transition,T.focusRingPanel,N===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[(0,Q.jsx)(n,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t]},e))}),(0,Q.jsxs)(`div`,{className:`flex w-full min-w-0 items-center gap-2 rounded-xl bg-surface-base px-3 py-2 transition-colors lg:max-w-md dark:bg-surface-hover/40`,children:[(0,Q.jsx)(E,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`input`,{type:`search`,value:O,onChange:e=>D({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"data-debounced-query":j||void 0,className:`min-w-0 flex-1 border-0 bg-transparent text-sm text-fg placeholder:text-fg-disabled focus:outline-none focus:ring-0`})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:t.filterChannelLabel}),(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":!R,onClick:()=>D({type:`patch`,patch:{channelFilter:``}}),className:i(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,T.transition,T.focusRingPanel,R?`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`:`bg-accent-soft text-accent-fg`),children:t.filterChannelAll}),De.map(e=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":R===e,onClick:()=>D({type:`patch`,patch:{channelFilter:e}}),className:i(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,T.transition,T.focusRingPanel,R===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[e,G?.byChannel?.[e]==null?null:(0,Q.jsx)(`span`,{className:`ml-2 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] text-fg-subtle`,children:G.byChannel[e]})]},e))]}),G?(0,Q.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[G.totalSessions,t.totalSessions],[G.activeSessions,t.activeSessions],[G.pinnedSessions,t.pinnedSessions],[G.archivedSessions,t.archivedSessions]].map(([e,t])=>(0,Q.jsxs)(`div`,{className:`rounded-xl bg-surface-base p-3 dark:bg-surface-hover/30`,children:[(0,Q.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-fg`,children:e}),(0,Q.jsx)(`div`,{className:`text-xs text-fg-muted`,children:t})]},t))}):null,ae?(0,Q.jsx)(`div`,{className:`rounded-lg border border-edge bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-edge dark:bg-red-950/40 dark:text-red-300`,children:ae}):null,(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:Ne(t.sessionCount,{count:B.length})}),(0,Q.jsxs)(`div`,{className:he,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,Q.jsx)(p,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":F===`grid`,onClick:()=>D({type:`patch`,patch:{viewMode:`grid`}}),className:i(me,`size-7 p-0`,F===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,F===`grid`&&`text-accent-fg`),children:(0,Q.jsx)(L,{className:`size-3.5`,strokeWidth:1.5})}),(0,Q.jsx)(p,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":F===`list`,onClick:()=>D({type:`patch`,patch:{viewMode:`list`}}),className:i(me,`size-9 p-0`,F===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,F===`list`&&`text-accent-fg`),children:(0,Q.jsx)(P,{className:`size-3.5`,strokeWidth:1.5})})]})]}),re&&B.length===0?(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,Q.jsx)(`div`,{className:`h-40 animate-pulse rounded-xl bg-surface-hover/60 dark:bg-surface-hover/40`},t))}):B.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-2xl bg-surface-base py-16 text-center dark:bg-surface-hover/25`,children:[(0,Q.jsx)(S,{className:`mb-3 size-12 text-fg-disabled`,strokeWidth:1.25,"aria-hidden":!0}),(0,Q.jsx)(`p`,{className:`text-base font-semibold text-fg`,children:t.noSessions}),(0,Q.jsx)(`p`,{className:`mt-1 max-w-sm text-sm text-fg-muted`,children:t.noSessionsDescription}),(0,Q.jsx)(p,{variant:`primary`,className:`mt-6`,onClick:()=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:``},bubbles:!0}))},children:t.startNewChat})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:i(`grid min-w-0 gap-3`,F===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":j||void 0,children:B.map(e=>{let t=V(e,d);return(0,Q.jsx)(ye,{session:e,variant:F,labels:we,sessionAgentId:t,sessionAgentAvatar:K(t,h),onOpen:()=>Se(e.key),onAction:t=>void $(e.key,t)},e.key)})}),H?(0,Q.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Q.jsx)(p,{type:`button`,variant:`secondary`,disabled:re,onClick:()=>void ve(),children:t.loadMore})}):null]})]})]}),(0,Q.jsx)(Ae,{open:q,loading:de,session:Y,sessionAgentId:Y?V(Y,d):void 0,sessionAgentAvatar:Y?K(V(Y,d),h):void 0,labels:Te,onClose:()=>{D({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>Y&&void $(Y.key,`archive`),onUnarchive:()=>Y&&void $(Y.key,`unarchive`),onPin:()=>Y&&void $(Y.key,`pin`),onUnpin:()=>Y&&void $(Y.key,`unpin`),onExport:()=>Y&&void $(Y.key,`export`),onDelete:()=>Y&&D({type:`patch`,patch:{confirmKey:Y.key,confirmOpen:!0}})}),(0,Q.jsx)(te,{open:pe,onOpenChange:e=>D({type:`patch`,patch:{confirmOpen:e}}),children:(0,Q.jsxs)(z,{children:[(0,Q.jsx)(W,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim`,ne)}),(0,Q.jsxs)(ce,{className:i(`xopc-dialog-content fixed left-1/2 top-1/2 w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`,J),children:[(0,Q.jsx)(U,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:X?Ne(t.deleteSessionMessage,{name:B.find(e=>e.key===X)?.name?.trim()||e.chat.newSession}):``}),(0,Q.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Q.jsx)(p,{type:`button`,variant:`secondary`,onClick:()=>D({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Q.jsx)(p,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{X&&Ce(X),D({type:`patch`,patch:{confirmOpen:!1,confirmKey:null}})},children:t.delete})]})]})]})})]}):(0,Q.jsx)(`div`,{className:`w-full px-3 py-16 text-center text-sm text-fg-muted sm:px-5 xl:px-6`,children:t.needToken})}export{Ue as SessionsPage};
@@ -1 +0,0 @@
1
- import{Qn as e}from"./index-DdqSO9R2.js";function t(t){let{children:n,fallback:r}=t,i=r===void 0?null:r;return e()?n:i}export{t};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./messages-B5O4OIEo.js";import{n as a}from"./locale-store-Ba72bFmP.js";import{Bi as o,Fc as s,Gi as c,Hi as l,Ji as u,Ki as d,Mc as f,Qi as p,Ui as m,Vi as h,Wi as g,Xi as _,Yi as v,Zi as y,qi as b,zi as x}from"./index-DdqSO9R2.js";var S=n(),C=e(t(),1),w=r(),T=[`overview`,`appearance`,`keyboard-shortcuts`,`user-profile`,`system`,`app-management`,`credentials`,`capability-presets`,`gateway`,`heartbeat`,`remote-access`,`shares`,`goals`,`dreams`],E=(0,C.lazy)(()=>v().then(e=>({default:e.SetupStatusPanel}))),D=(0,C.lazy)(()=>o().then(e=>({default:e.AppearanceSettingsPanel}))),O=(0,C.lazy)(()=>d().then(e=>({default:e.KeyboardShortcutsSettingsPanel}))),k=(0,C.lazy)(()=>p().then(e=>({default:e.UserProfileSettingsPanel}))),A=(0,C.lazy)(()=>y().then(e=>({default:e.SystemSettingsPanel}))),j=(0,C.lazy)(()=>x().then(e=>({default:e.AppManagementSettingsPanel}))),M=(0,C.lazy)(()=>b().then(e=>({default:e.ModelsHubPanel}))),N=(0,C.lazy)(()=>m().then(e=>({default:e.GatewaySettingsPanel}))),P=(0,C.lazy)(()=>c().then(e=>({default:e.HeartbeatSettingsPanel}))),F=(0,C.lazy)(()=>u().then(e=>({default:e.RemoteAccessHub}))),I=(0,C.lazy)(()=>_().then(e=>({default:e.SharesSettingsPanel}))),L=(0,C.lazy)(()=>l().then(e=>({default:e.DreamingSettingsPanel}))),R=(0,C.lazy)(()=>g().then(e=>({default:e.GoalsSettingsPanel}))),z=(0,C.lazy)(()=>h().then(e=>({default:e.CapabilityPresetsSettingsPanel})));function B(){let e=(0,S.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,w.jsxs)(`div`,{className:`w-full flex-1 px-3 py-8 sm:px-5 xl:px-6`,"aria-busy":!0,children:[(0,w.jsx)(`div`,{className:`h-8 w-48 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,w.jsx)(`div`,{className:`mt-6 h-36 animate-pulse rounded-xl bg-surface-hover`}),(0,w.jsx)(`div`,{className:`mt-4 h-24 animate-pulse rounded-xl bg-surface-hover`})]}),e[0]=t):t=e[0],t}function V(e){return(0,w.jsx)(C.Suspense,{fallback:(0,w.jsx)(B,{}),children:(0,w.jsx)(e,{})})}function H(){let e=(0,S.c)(29),{section:t}=s(),n=a(U),r,o,c,l,u;if(e[0]!==n||e[1]!==t){u=Symbol.for(`react.early_return_sentinel`);bb0:{let a=i(n);if(!t||!T.includes(t)){let t;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,w.jsx)(f,{to:`/settings/overview`,replace:!0}),e[7]=t):t=e[7],u=t;break bb0}let s=t;if(s===`overview`){let t;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(t=V(E),e[8]=t):t=e[8],u=t;break bb0}let d=a.settingsSections[s];if(s===`appearance`){let t;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(t=V(D),e[9]=t):t=e[9],u=t;break bb0}if(s===`keyboard-shortcuts`){let t;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(t=V(O),e[10]=t):t=e[10],u=t;break bb0}if(s===`user-profile`){let t;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(t=V(k),e[11]=t):t=e[11],u=t;break bb0}if(s===`system`){let t;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(t=V(A),e[12]=t):t=e[12],u=t;break bb0}if(s===`app-management`){let t;e[13]===Symbol.for(`react.memo_cache_sentinel`)?(t=V(j),e[13]=t):t=e[13],u=t;break bb0}if(s===`credentials`){let t;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(t=V(M),e[14]=t):t=e[14],u=t;break bb0}if(s===`capability-presets`){let t;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(t=V(z),e[15]=t):t=e[15],u=t;break bb0}if(s===`gateway`){let t;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(t=V(N),e[16]=t):t=e[16],u=t;break bb0}if(s===`heartbeat`){let t;e[17]===Symbol.for(`react.memo_cache_sentinel`)?(t=V(P),e[17]=t):t=e[17],u=t;break bb0}if(s===`remote-access`){let t;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(t=V(F),e[18]=t):t=e[18],u=t;break bb0}if(s===`shares`){let t;e[19]===Symbol.for(`react.memo_cache_sentinel`)?(t=V(I),e[19]=t):t=e[19],u=t;break bb0}if(s===`dreams`){let t;e[20]===Symbol.for(`react.memo_cache_sentinel`)?(t=V(L),e[20]=t):t=e[20],u=t;break bb0}if(s===`goals`){let t;e[21]===Symbol.for(`react.memo_cache_sentinel`)?(t=V(R),e[21]=t):t=e[21],u=t;break bb0}c=`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,l=(0,w.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:d}),r=`text-sm text-fg-muted`,o=a.settingsPage.comingSoon.replace(`{{title}}`,d)}e[0]=n,e[1]=t,e[2]=r,e[3]=o,e[4]=c,e[5]=l,e[6]=u}else r=e[2],o=e[3],c=e[4],l=e[5],u=e[6];if(u!==Symbol.for(`react.early_return_sentinel`))return u;let d;e[22]!==r||e[23]!==o?(d=(0,w.jsx)(`p`,{className:r,children:o}),e[22]=r,e[23]=o,e[24]=d):d=e[24];let p;return e[25]!==c||e[26]!==l||e[27]!==d?(p=(0,w.jsxs)(`div`,{className:c,children:[l,d]}),e[25]=c,e[26]=l,e[27]=d,e[28]=p):p=e[28],p}function U(e){return e.language}export{H as SettingsPage};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-B5O4OIEo.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{c as s,i as c,n as l}from"./fetch-ovkvM8KQ.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{$a as d,Aa as f,Ba as p,Cr as m,Er as h,Fs as g,Gs as _,H as v,Ha as y,Ic as b,Mi as x,Ms as S,Oo as C,Po as w,Sr as T,Tr as E,Ur as D,Zs as O,_r as k,aa as ee,br as A,ea as j,f as M,ga as N,ia as P,ji as F,mc as I,ns as L,oa as R,pc as z,ra as te,ta as ne,ut as B,va as V,vr as re,wr as ie,xr as H,yr as ae,za as U,zn as oe}from"./index-DdqSO9R2.js";import{t as W}from"./settings-form-section-Dg6LBbcr.js";import{n as G,r as se,t as ce}from"./settings-page-layout-BX4T-OLF.js";var K=e(t(),1),le=n(),q={enabled:!0,defaultTtlHours:24,maxTtlDays:7,maxActiveShares:100,maxActiveSites:5,maxFileSizeMb:100,inlinePreviewMimes:[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`image/svg+xml`,`application/pdf`,`text/html`,`text/markdown`,`text/plain`,`application/json`]},J=36e5,Y=864e5,ue=1048576;function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function de(e,t=32){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()).slice(0,t):[]}function fe(e){let t=X(e)?e:{},n=X(t.gateway)?t.gateway:{},r=X(n.share)?n.share:{},i=X(n.siteShare)?n.siteShare:{},a=typeof r.defaultTtlMs==`number`&&Number.isFinite(r.defaultTtlMs)?Math.floor(r.defaultTtlMs):q.defaultTtlHours*J,o=typeof r.maxTtlMs==`number`&&Number.isFinite(r.maxTtlMs)?Math.floor(r.maxTtlMs):q.maxTtlDays*Y,s=typeof r.maxFileSize==`number`&&Number.isFinite(r.maxFileSize)?Math.floor(r.maxFileSize):q.maxFileSizeMb*ue;return{enabled:r.enabled!==!1,defaultTtlHours:Math.max(1,Math.round(a/J)),maxTtlDays:Math.max(1,Math.round(o/Y)),maxActiveShares:typeof r.maxActiveShares==`number`&&Number.isFinite(r.maxActiveShares)?Math.max(1,Math.min(1e4,Math.floor(r.maxActiveShares))):q.maxActiveShares,maxActiveSites:typeof i.maxActiveSites==`number`&&Number.isFinite(i.maxActiveSites)?Math.max(1,Math.min(1e3,Math.floor(i.maxActiveSites))):q.maxActiveSites,maxFileSizeMb:Math.max(1,Math.round(s/ue)),inlinePreviewMimes:de(r.inlinePreviewMimes,32).length?de(r.inlinePreviewMimes,32):[...q.inlinePreviewMimes]}}function pe(e){let t=e.defaultTtlHours*J,n=e.maxTtlDays*Y;return t<6e4||t>6048e5?`Default share TTL must be between 1 minute and 7 days.`:n<6e4||n>2592e6?`Maximum share TTL must be between 1 minute and 30 days.`:t>n?`Default TTL cannot exceed maximum TTL.`:e.maxActiveShares<1||e.maxActiveShares>1e4?`Maximum active shares must be between 1 and 10,000.`:e.maxActiveSites<1||e.maxActiveSites>1e3?`Maximum active site shares must be between 1 and 1,000.`:e.maxFileSizeMb<1||e.maxFileSizeMb>10240?`Maximum file size must be between 1 MB and 10 GB.`:null}async function me(e){let t=pe(e);if(t)throw Error(t);await l(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{share:{enabled:e.enabled,defaultTtlMs:e.defaultTtlHours*J,maxTtlMs:e.maxTtlDays*Y,maxActiveShares:e.maxActiveShares,maxFileSize:e.maxFileSizeMb*ue,inlinePreviewMimes:e.inlinePreviewMimes},siteShare:{maxActiveSites:e.maxActiveSites}}})}),F()}var Z=r();function he(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,U,`dark:border-edge`)}function ge({hasToken:e}){let t=a(o(e=>e.language)).sharesSettings,{data:n,isLoading:r}=x(e),i=(0,K.useMemo)(()=>n?.payload?.config===void 0?null:structuredClone(fe(n.payload.config)),[n]),s=(0,K.useRef)(!1),[c,l]=(0,K.useState)(null),[u,d]=(0,K.useState)(!1),[f,m]=(0,K.useState)(null),[h,g]=(0,K.useState)(!1),_=c??i,v=i,y=(0,K.useMemo)(()=>!_||!v?!1:JSON.stringify(_)!==JSON.stringify(v),[_,v]),b=(0,K.useCallback)(e=>{s.current=!0,l(t=>{let n=t??v;return n?{...n,...e}:null})},[v]),S=(0,K.useCallback)(async()=>{if(!(!_||u)){d(!0),m(null),g(!1);try{await me(_),s.current=!1,l(null),g(!0),window.setTimeout(()=>g(!1),2500)}catch(e){m(e instanceof Error?e.message:t.policySaveError)}finally{d(!1)}}},[_,u,t.policySaveError]),C=(0,K.useCallback)(()=>{s.current=!1,l(null),m(null),g(!1)},[]);return!e||!_?r?(0,Z.jsx)(W,{children:(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,Z.jsx)(L,{className:`size-4 animate-spin`}),t.policyLoading]})}):null:(0,Z.jsxs)(W,{children:[(0,Z.jsxs)(`div`,{className:`mb-4 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.policyTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:t.policyHint})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[h?(0,Z.jsx)(`span`,{className:`text-sm text-fg-muted`,children:t.policySaved}):null,(0,Z.jsx)(p,{type:`button`,variant:`secondary`,disabled:!y||u,onClick:C,children:t.policyDiscard}),(0,Z.jsx)(p,{type:`button`,variant:`primary`,disabled:!y||u,onClick:()=>void S(),children:u?t.policySaving:t.policySave})]})]}),y?(0,Z.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:t.policyUnsaved}):null,f?(0,Z.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:f}):null,(0,Z.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:t.policyRestartHint}),(0,Z.jsx)(_e,{t,form:_,onChange:b})]})}function _e(e){let t=(0,le.c)(64),{t:n,form:r,onChange:i}=e,a;t[0]===i?a=t[1]:(a=e=>i({enabled:e.target.checked}),t[0]=i,t[1]=a);let o;t[2]!==r.enabled||t[3]!==a?(o=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:a}),t[2]=r.enabled,t[3]=a,t[4]=o):o=t[4];let s;t[5]!==n.policyEnabled||t[6]!==o?(s=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[o,n.policyEnabled]}),t[5]=n.policyEnabled,t[6]=o,t[7]=s):s=t[7];let c=!r.enabled,l;t[8]===i?l=t[9]:(l=e=>i({defaultTtlHours:e}),t[8]=i,t[9]=l);let u;t[10]!==r.defaultTtlHours||t[11]!==n.policyDefaultTtlHint||t[12]!==n.policyDefaultTtlHours||t[13]!==c||t[14]!==l?(u=(0,Z.jsx)(ve,{id:`share-default-ttl-hours`,label:n.policyDefaultTtlHours,hint:n.policyDefaultTtlHint,value:r.defaultTtlHours,min:1,max:168,disabled:c,onChange:l}),t[10]=r.defaultTtlHours,t[11]=n.policyDefaultTtlHint,t[12]=n.policyDefaultTtlHours,t[13]=c,t[14]=l,t[15]=u):u=t[15];let d=!r.enabled,f;t[16]===i?f=t[17]:(f=e=>i({maxTtlDays:e}),t[16]=i,t[17]=f);let p;t[18]!==r.maxTtlDays||t[19]!==n.policyMaxTtlDays||t[20]!==n.policyMaxTtlHint||t[21]!==d||t[22]!==f?(p=(0,Z.jsx)(ve,{id:`share-max-ttl-days`,label:n.policyMaxTtlDays,hint:n.policyMaxTtlHint,value:r.maxTtlDays,min:1,max:30,disabled:d,onChange:f}),t[18]=r.maxTtlDays,t[19]=n.policyMaxTtlDays,t[20]=n.policyMaxTtlHint,t[21]=d,t[22]=f,t[23]=p):p=t[23];let m=!r.enabled,h;t[24]===i?h=t[25]:(h=e=>i({maxActiveShares:e}),t[24]=i,t[25]=h);let g;t[26]!==r.maxActiveShares||t[27]!==n.policyMaxActiveShares||t[28]!==n.policyMaxActiveSharesHint||t[29]!==m||t[30]!==h?(g=(0,Z.jsx)(ve,{id:`share-max-active`,label:n.policyMaxActiveShares,hint:n.policyMaxActiveSharesHint,value:r.maxActiveShares,min:1,max:1e4,disabled:m,onChange:h}),t[26]=r.maxActiveShares,t[27]=n.policyMaxActiveShares,t[28]=n.policyMaxActiveSharesHint,t[29]=m,t[30]=h,t[31]=g):g=t[31];let _;t[32]===i?_=t[33]:(_=e=>i({maxActiveSites:e}),t[32]=i,t[33]=_);let v;t[34]!==r.maxActiveSites||t[35]!==n.policyMaxActiveSites||t[36]!==n.policyMaxActiveSitesHint||t[37]!==_?(v=(0,Z.jsx)(ve,{id:`site-share-max-active`,label:n.policyMaxActiveSites,hint:n.policyMaxActiveSitesHint,value:r.maxActiveSites,min:1,max:1e3,onChange:_}),t[34]=r.maxActiveSites,t[35]=n.policyMaxActiveSites,t[36]=n.policyMaxActiveSitesHint,t[37]=_,t[38]=v):v=t[38];let y=!r.enabled,b;t[39]===i?b=t[40]:(b=e=>i({maxFileSizeMb:e}),t[39]=i,t[40]=b);let x;t[41]!==r.maxFileSizeMb||t[42]!==n.policyMaxFileSizeHint||t[43]!==n.policyMaxFileSizeMb||t[44]!==y||t[45]!==b?(x=(0,Z.jsx)(ve,{id:`share-max-file-mb`,label:n.policyMaxFileSizeMb,hint:n.policyMaxFileSizeHint,value:r.maxFileSizeMb,min:1,max:10240,disabled:y,onChange:b}),t[41]=r.maxFileSizeMb,t[42]=n.policyMaxFileSizeHint,t[43]=n.policyMaxFileSizeMb,t[44]=y,t[45]=b,t[46]=x):x=t[46];let S;t[47]!==g||t[48]!==v||t[49]!==x||t[50]!==u||t[51]!==p?(S=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[u,p,g,v,x]}),t[47]=g,t[48]=v,t[49]=x,t[50]=u,t[51]=p,t[52]=S):S=t[52];let C=!r.enabled,w;t[53]===i?w=t[54]:(w=e=>i({inlinePreviewMimes:e}),t[53]=i,t[54]=w);let T;t[55]!==r.inlinePreviewMimes||t[56]!==n||t[57]!==C||t[58]!==w?(T=(0,Z.jsx)(ye,{t:n,values:r.inlinePreviewMimes,disabled:C,onChange:w}),t[55]=r.inlinePreviewMimes,t[56]=n,t[57]=C,t[58]=w,t[59]=T):T=t[59];let E;return t[60]!==S||t[61]!==T||t[62]!==s?(E=(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[s,S,T]}),t[60]=S,t[61]=T,t[62]=s,t[63]=E):E=t[63],E}function ve(e){let t=(0,le.c)(21),{id:n,label:r,hint:a,value:o,min:s,max:c,disabled:l,onChange:u}=e,d;t[0]!==n||t[1]!==r?(d=(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=d):d=t[2];let f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=i(he(),`max-w-xs font-mono text-xs`),t[3]=f):f=t[3];let p;t[4]!==c||t[5]!==s||t[6]!==u?(p=e=>{let t=Number(e.target.value);Number.isFinite(t)&&u(Math.max(s,Math.min(c,Math.floor(t))))},t[4]=c,t[5]=s,t[6]=u,t[7]=p):p=t[7];let m;t[8]!==l||t[9]!==n||t[10]!==c||t[11]!==s||t[12]!==p||t[13]!==o?(m=(0,Z.jsx)(`input`,{id:n,type:`number`,min:s,max:c,disabled:l,className:f,value:o,onChange:p}),t[8]=l,t[9]=n,t[10]=c,t[11]=s,t[12]=p,t[13]=o,t[14]=m):m=t[14];let h;t[15]===a?h=t[16]:(h=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:a}),t[15]=a,t[16]=h);let g;return t[17]!==d||t[18]!==m||t[19]!==h?(g=(0,Z.jsxs)(`div`,{children:[d,m,h]}),t[17]=d,t[18]=m,t[19]=h,t[20]=g):g=t[20],g}function ye(e){let t=(0,le.c)(25),{t:n,values:r,disabled:a,onChange:o}=e,s;t[0]!==o||t[1]!==r?(s=e=>{let t=e.trim();!t||r.includes(t)||r.length>=32||o([...r,t])},t[0]=o,t[1]=r,t[2]=s):s=t[2];let c=s,l;t[3]===n.policyInlinePreviewMimes?l=t[4]:(l=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.policyInlinePreviewMimes}),t[3]=n.policyInlinePreviewMimes,t[4]=l);let u;t[5]===n.policyInlinePreviewMimesHint?u=t[6]:(u=(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.policyInlinePreviewMimesHint}),t[5]=n.policyInlinePreviewMimesHint,t[6]=u);let d;t[7]!==a||t[8]!==o||t[9]!==r?(d=r.map(e=>(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 font-mono text-xs text-fg`,children:[e,a?null:(0,Z.jsx)(`button`,{type:`button`,className:`text-fg-muted hover:text-fg`,"aria-label":`Remove ${e}`,onClick:()=>o(r.filter(t=>t!==e)),children:`×`})]},e)),t[7]=a,t[8]=o,t[9]=r,t[10]=d):d=t[10];let f;t[11]===d?f=t[12]:(f=(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:d}),t[11]=d,t[12]=f);let p;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(p=i(he(),`font-mono text-xs`),t[13]=p):p=t[13];let m=a||r.length>=32,h;t[14]===c?h=t[15]:(h=e=>{e.key===`Enter`&&(e.preventDefault(),c(e.target.value),e.target.value=``)},t[14]=c,t[15]=h);let g;t[16]!==n.policyMimePlaceholder||t[17]!==m||t[18]!==h?(g=(0,Z.jsx)(`input`,{className:p,placeholder:n.policyMimePlaceholder,disabled:m,onKeyDown:h}),t[16]=n.policyMimePlaceholder,t[17]=m,t[18]=h,t[19]=g):g=t[19];let _;return t[20]!==l||t[21]!==u||t[22]!==f||t[23]!==g?(_=(0,Z.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-4`,children:[l,u,f,g]}),t[20]=l,t[21]=u,t[22]=f,t[23]=g,t[24]=_):_=t[24],_}function Q(e){let t=(0,le.c)(99),{open:n,onOpenChange:r,onConfirm:c,initialPath:l,selectKind:d,sessionKey:f,agentId:m}=e,h=d===void 0?`any`:d,g=o(Se),_;t[0]===g?_=t[1]:(_=a(g),t[0]=g,t[1]=_);let v=_,b=v.workspace,x=v.sharesSettings,w=k(xe),{data:T}=u(s(be)?`picker-agents-list`:null,oe),E;bb0:{let e;t[2]===m?e=t[3]:(e=m?.trim(),t[2]=m,t[3]=e);let n=e;if(n){E=n;break bb0}let r;t[4]===w?r=t[5]:(r=w.trim(),t[4]=w,t[5]=r);let i=r;if(i){E=i;break bb0}if(T?.defaultId){E=T.defaultId;break bb0}if(T?.agents?.[0]?.id){E=T.agents[0].id;break bb0}E=``}let O=E,[A,M]=(0,K.useState)(O),F,I;t[6]===O?(F=t[7],I=t[8]):(F=()=>{M(O)},I=[O],t[6]=O,t[7]=F,t[8]=I),(0,K.useEffect)(F,I);let{tree:z,loading:B,error:ie,loadRoot:H,loadChildren:ae,reset:U}=re(A,f??null),W;t[9]===l?W=t[10]:(W=l?{path:l,isDirectory:!1}:null,t[9]=l,t[10]=W);let[G,se]=(0,K.useState)(W),ce;t[11]!==l||t[12]!==H||t[13]!==n||t[14]!==U?(ce=()=>{if(!n){U(),se(l?{path:l,isDirectory:!1}:null);return}H()},t[11]=l,t[12]=H,t[13]=n,t[14]=U,t[15]=ce):ce=t[15];let q;t[16]!==l||t[17]!==H||t[18]!==n||t[19]!==A||t[20]!==U||t[21]!==f?(q=[n,A,f,H,U,l],t[16]=l,t[17]=H,t[18]=n,t[19]=A,t[20]=U,t[21]=f,t[22]=q):q=t[22],(0,K.useEffect)(ce,q);let J;t[23]===ae?J=t[24]:(J=e=>{ae(e)},t[23]=ae,t[24]=J);let Y=J,ue=G!==null&&(h===`any`||h===`file`&&!G.isDirectory||h===`directory`&&G.isDirectory),X;bb1:{if(!G){X=x.pickerHintNone;break bb1}if(h===`file`&&G.isDirectory){X=x.pickerHintNeedsFile;break bb1}if(h===`directory`&&!G.isDirectory){X=x.pickerHintNeedsDirectory;break bb1}X=`${G.isDirectory?`📁`:`📄`} ${G.path}`}let de=X,fe;t[25]===T?.agents?fe=t[26]:(fe=T?.agents??[],t[25]=T?.agents,t[26]=fe);let pe=fe,me;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,Z.jsx)(te,{className:`fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),t[27]=me):me=t[27];let he;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(he=i(`fixed left-1/2 top-1/2 z-[71] w-[min(34rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2`,`flex h-[min(28rem,calc(100vh-3rem))] flex-col overflow-hidden rounded-lg border border-edge bg-surface-panel shadow-popover outline-none`),t[28]=he):he=t[28];let ge;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,Z.jsx)(S,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[29]=ge):ge=t[29];let _e;t[30]===x.pickerTitle?_e=t[31]:(_e=(0,Z.jsx)(R,{className:`min-w-0 flex-1 truncate text-base font-semibold text-fg`,children:x.pickerTitle}),t[30]=x.pickerTitle,t[31]=_e);let ve=v.cron.refresh,ye=v.cron.refresh,Q;t[32]===H?Q=t[33]:(Q=()=>void H(),t[32]=H,t[33]=Q);let Ce=B&&`animate-spin`,we;t[34]===Ce?we=t[35]:(we=i(`size-4`,Ce),t[34]=Ce,t[35]=we);let Te;t[36]===we?Te=t[37]:(Te=(0,Z.jsx)(C,{className:we,"aria-hidden":!0}),t[36]=we,t[37]=Te);let Ee;t[38]!==B||t[39]!==v.cron.refresh||t[40]!==Q||t[41]!==Te?(Ee=(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50`,title:ve,"aria-label":ye,disabled:B,onClick:Q,children:Te}),t[38]=B,t[39]=v.cron.refresh,t[40]=Q,t[41]=Te,t[42]=Ee):Ee=t[42];let De;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(De=(0,Z.jsx)(y,{className:`size-4`}),t[43]=De):De=t[43];let Oe;t[44]===b.close?Oe=t[45]:(Oe=(0,Z.jsx)(j,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":b.close,children:De})}),t[44]=b.close,t[45]=Oe);let ke;t[46]!==_e||t[47]!==Ee||t[48]!==Oe?(ke=(0,Z.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-edge px-4`,children:[ge,_e,Ee,Oe]}),t[46]=_e,t[47]=Ee,t[48]=Oe,t[49]=ke):ke=t[49];let Ae;t[50]!==pe||t[51]!==T?.defaultId||t[52]!==A||t[53]!==x.pickerAgentLabel?(Ae=pe.length>0?(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-edge px-4 py-2`,children:[(0,Z.jsx)(`label`,{className:`text-xs text-fg-muted`,htmlFor:`picker-agent-select`,children:x.pickerAgentLabel}),(0,Z.jsx)(N,{id:`picker-agent-select`,className:`min-w-0 flex-1 rounded-md border border-edge bg-surface-panel px-2 py-1 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:A,onChange:e=>{M(e.target.value),se(null)},children:pe.map(e=>(0,Z.jsxs)(V,{value:e.id,children:[e.name||e.id,e.id===T?.defaultId?` ★`:``]},e.id))})]}):null,t[50]=pe,t[51]=T?.defaultId,t[52]=A,t[53]=x.pickerAgentLabel,t[54]=Ae):Ae=t[54];let je;t[55]!==ie||t[56]!==b.loadError?(je=ie?(0,Z.jsxs)(`p`,{className:`shrink-0 px-4 py-2 text-xs text-red-600 dark:text-red-400`,children:[b.loadError,`: `,ie]}):null,t[55]=ie,t[56]=b.loadError,t[57]=je):je=t[57];let Me;t[58]!==Y||t[59]!==B||t[60]!==G?.path||t[61]!==b.emptyDir||t[62]!==b.title||t[63]!==z?(Me=B&&z.length===0?(0,Z.jsxs)(`p`,{className:`flex shrink-0 items-center gap-2 px-4 py-3 text-sm text-fg-muted`,children:[(0,Z.jsx)(L,{className:`size-4 animate-spin`}),b.title,`…`]}):(0,Z.jsx)(D,{tree:z,selectedPath:G?.path??null,onSelectFile:e=>se({path:e,isDirectory:!1}),onSelectEntry:(e,t)=>se({path:e,isDirectory:t}),onExpandDir:Y,onAction:void 0,emptyHint:b.emptyDir}),t[58]=Y,t[59]=B,t[60]=G?.path,t[61]=b.emptyDir,t[62]=b.title,t[63]=z,t[64]=Me):Me=t[64];let Ne;t[65]!==je||t[66]!==Me?(Ne=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[je,Me]}),t[65]=je,t[66]=Me,t[67]=Ne):Ne=t[67];let Pe;t[68]===de?Pe=t[69]:(Pe=(0,Z.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:de}),t[68]=de,t[69]=Pe);let Fe;t[70]===r?Fe=t[71]:(Fe=()=>r(!1),t[70]=r,t[71]=Fe);let Ie;t[72]!==x.cancel||t[73]!==Fe?(Ie=(0,Z.jsx)(p,{type:`button`,variant:`ghost`,onClick:Fe,children:x.cancel}),t[72]=x.cancel,t[73]=Fe,t[74]=Ie):Ie=t[74];let Le=!ue,Re;t[75]!==c||t[76]!==r||t[77]!==A||t[78]!==G?(Re=()=>{G&&(c({...G,agentId:A}),r(!1))},t[75]=c,t[76]=r,t[77]=A,t[78]=G,t[79]=Re):Re=t[79];let ze;t[80]!==x.pickerConfirm||t[81]!==Le||t[82]!==Re?(ze=(0,Z.jsx)(p,{type:`button`,disabled:Le,onClick:Re,children:x.pickerConfirm}),t[80]=x.pickerConfirm,t[81]=Le,t[82]=Re,t[83]=ze):ze=t[83];let $;t[84]!==Ie||t[85]!==ze?($=(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[Ie,ze]}),t[84]=Ie,t[85]=ze,t[86]=$):$=t[86];let Be;t[87]!==Pe||t[88]!==$?(Be=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-t border-edge px-4 py-3`,children:[Pe,$]}),t[87]=Pe,t[88]=$,t[89]=Be):Be=t[89];let Ve;t[90]!==ke||t[91]!==Ae||t[92]!==Ne||t[93]!==Be?(Ve=(0,Z.jsxs)(P,{children:[me,(0,Z.jsxs)(ne,{className:he,children:[ke,Ae,Ne,Be]})]}),t[90]=ke,t[91]=Ae,t[92]=Ne,t[93]=Be,t[94]=Ve):Ve=t[94];let He;return t[95]!==r||t[96]!==n||t[97]!==Ve?(He=(0,Z.jsx)(ee,{open:n,onOpenChange:r,children:Ve}),t[95]=r,t[96]=n,t[97]=Ve,t[98]=He):He=t[98],He}function be(e){return e.token}function xe(e){return e.agentId}function Se(e){return e.language}var Ce=[`shares`,`policy`];function we(e){let t=(e??``).trim();return Ce.includes(t)?t:`shares`}function Te(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}function Ee(e,t){let n=new Date(e).getTime()-Date.now(),r=Math.abs(n),i=n<0;if(r<6e4)return t===`zh`?`刚刚`:`just now`;let a=Math.floor(r/6e4);if(a<60){let e=t===`zh`?`${a} 分钟`:`${a}m`;return i?t===`zh`?`${e}前`:`${e} ago`:e}let o=Math.floor(a/60);if(o<24){let e=t===`zh`?`${o} 小时`:`${o}h`;return i?t===`zh`?`${e}前`:`${e} ago`:e}let s=Math.floor(o/24),c=t===`zh`?`${s} 天`:`${s}d`;return i?t===`zh`?`${c}前`:`${c} ago`:c}var De=[{value:36e5,key:`1h`},{value:216e5,key:`6h`},{value:864e5,key:`24h`},{value:2592e5,key:`3d`},{value:6048e5,key:`7d`}];function Oe(){let e=(0,le.c)(24),t=o(Ae),n=a(t).sharesSettings,r=!!s(ke),[i,c]=b(),l;e[0]===i?l=e[1]:(l=we(i.get(`tab`)),e[0]=i,e[1]=l);let u=l,d;e[2]===c?d=e[3]:(d=e=>{c(t=>{let n=new URLSearchParams(t);return e===`shares`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[2]=c,e[3]=d);let f=d;if(!r)return(0,Z.jsx)(ce,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})});let p={shares:n.tabShares,policy:n.tabPolicy},m=Ce.map(e=>({id:e,label:p[e]})),h;e[4]!==n.subtitle||e[5]!==n.title?(h=(0,Z.jsx)(G,{title:n.title,subtitle:n.subtitle}),e[4]=n.subtitle,e[5]=n.title,e[6]=h):h=e[6];let g;e[7]!==u||e[8]!==f||e[9]!==n.tabsAria||e[10]!==m?(g=(0,Z.jsx)(v,{items:m,activeTab:u,onChange:f,ariaLabel:n.tabsAria,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`}),e[7]=u,e[8]=f,e[9]=n.tabsAria,e[10]=m,e[11]=g):g=e[11];let _;e[12]!==u||e[13]!==r||e[14]!==t||e[15]!==n?(_=u===`shares`?(0,Z.jsx)(je,{t:n,language:t}):(0,Z.jsx)(ge,{hasToken:r}),e[12]=u,e[13]=r,e[14]=t,e[15]=n,e[16]=_):_=e[16];let y;e[17]!==u||e[18]!==_?(y=(0,Z.jsx)(se,{id:u,activeTab:u,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`,showHeading:!1,children:_}),e[17]=u,e[18]=_,e[19]=y):y=e[19];let x;return e[20]!==h||e[21]!==g||e[22]!==y?(x=(0,Z.jsxs)(ce,{children:[h,g,y]}),e[20]=h,e[21]=g,e[22]=y,e[23]=x):x=e[23],x}function ke(e){return e.token}function Ae(e){return e.language}function je(e){let t=(0,le.c)(60),{t:n,language:r}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a={refreshInterval:3e4},t[0]=a):a=t[0];let{data:o,error:s,isLoading:c,mutate:l}=u(`shares-list`,T,a),d;t[1]===o?.payload?.shares?d=t[2]:(d=o?.payload?.shares??[],t[1]=o?.payload?.shares,t[2]=d);let f=d,[m,h]=(0,K.useState)(!1),g;bb0:{if(m){g=f;break bb0}let e;t[3]===f?e=t[4]:(e=f.filter(Fe),t[3]=f,t[4]=e),g=e}let _=g,v;t[5]===f?v=t[6]:(v=f.filter(Pe),t[5]=f,t[6]=v);let y=v.length,b;t[7]===f?b=t[8]:(b=f.filter(Ne),t[7]=f,t[8]=b);let x=b.length,S;t[9]===l?S=t[10]:(S=()=>void l(),t[9]=l,t[10]=S);let w;t[11]!==n||t[12]!==S?(w=(0,Z.jsx)(Le,{t:n,onCreated:S}),t[11]=n,t[12]=S,t[13]=w):w=t[13];let E=m?n.allSharesTitle:n.listTitle,D;t[14]===y?D=t[15]:(D=y>0&&(0,Z.jsxs)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:[`(`,y,`)`]}),t[14]=y,t[15]=D);let O;t[16]!==E||t[17]!==D?(O=(0,Z.jsxs)(`h2`,{className:`text-sm font-semibold text-fg`,children:[E,D]}),t[16]=E,t[17]=D,t[18]=O):O=t[18];let k;t[19]===l?k=t[20]:(k=()=>void l(),t[19]=l,t[20]=k);let ee=c&&`animate-spin`,A;t[21]===ee?A=t[22]:(A=i(`size-3.5`,ee),t[21]=ee,t[22]=A);let j;t[23]===A?j=t[24]:(j=(0,Z.jsx)(C,{className:A}),t[23]=A,t[24]=j);let M;t[25]!==c||t[26]!==k||t[27]!==j?(M=(0,Z.jsx)(p,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:k,disabled:c,children:j}),t[25]=c,t[26]=k,t[27]=j,t[28]=M):M=t[28];let N;t[29]!==x||t[30]!==m||t[31]!==n.hideExpired||t[32]!==n.showExpired?(N=x>0&&(0,Z.jsx)(`button`,{type:`button`,className:`text-xs text-accent hover:underline`,onClick:()=>h(Me),children:m?n.hideExpired:n.showExpired}),t[29]=x,t[30]=m,t[31]=n.hideExpired,t[32]=n.showExpired,t[33]=N):N=t[33];let P;t[34]!==M||t[35]!==N?(P=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[M,N]}),t[34]=M,t[35]=N,t[36]=P):P=t[36];let F;t[37]!==O||t[38]!==P?(F=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[O,P]}),t[37]=O,t[38]=P,t[39]=F):F=t[39];let I;t[40]!==o||t[41]!==s||t[42]!==_||t[43]!==c||t[44]!==r||t[45]!==l||t[46]!==n?(I=c&&!o?(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,Z.jsx)(L,{className:`size-4 animate-spin`}),n.loading]}):s?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-red-600 dark:text-red-400`,children:[(0,Z.jsx)(`span`,{children:n.error}),(0,Z.jsx)(p,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-xs`,onClick:()=>void l(),children:n.retry})]}):_.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.emptyState}):(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:_.map(e=>(0,Z.jsx)(ze,{share:e,t:n,language:r,onRevoked:()=>void l(),onExtended:()=>void l()},e.id))}),t[40]=o,t[41]=s,t[42]=_,t[43]=c,t[44]=r,t[45]=l,t[46]=n,t[47]=I):I=t[47];let R;t[48]!==x||t[49]!==l||t[50]!==m||t[51]!==n?(R=x>0&&m&&(0,Z.jsx)($,{t:n,onCleaned:()=>void l()}),t[48]=x,t[49]=l,t[50]=m,t[51]=n,t[52]=R):R=t[52];let z;t[53]!==F||t[54]!==I||t[55]!==R?(z=(0,Z.jsxs)(W,{children:[F,I,R]}),t[53]=F,t[54]=I,t[55]=R,t[56]=z):z=t[56];let te;return t[57]!==z||t[58]!==w?(te=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[w,z]}),t[57]=z,t[58]=w,t[59]=te):te=t[59],te}function Me(e){return!e}function Ne(e){return e.expired||e.revoked}function Pe(e){return!e.expired&&!e.revoked}function Fe(e){return!e.expired&&!e.revoked}var Ie={expanded:!0,path:``,isDirectory:!1,agentId:``,ttlMs:864e5,maxViews:null,description:``,directoryMode:`browse`,creating:!1,result:null,errorMsg:null,resultDialogOpen:!1,pickerOpen:!1};function Le({t:e,onCreated:t}){let[n,r]=(0,K.useReducer)(B,Ie),{expanded:a,path:o,isDirectory:s,agentId:c,ttlMs:l,maxViews:u,description:d,directoryMode:f,creating:m,result:h,errorMsg:_,resultDialogOpen:v,pickerOpen:y}=n,b=(0,K.useCallback)(async()=>{if(o.trim()){r({type:`patch`,patch:{creating:!0,errorMsg:null,result:null}});try{r({type:`patch`,patch:{result:(await A({path:o.trim(),ttlMs:l,maxViews:u,description:d.trim()||void 0,...c?{agentId:c}:{},...s?{kind:`directory`,directoryMode:f}:{}})).payload,resultDialogOpen:!0}}),t()}catch(e){r({type:`patch`,patch:{errorMsg:e instanceof Error?e.message:String(e)}})}finally{r({type:`patch`,patch:{creating:!1}})}}},[o,s,c,l,u,d,f,t]),x=(0,K.useCallback)(()=>{r({type:`patch`,patch:{path:``,isDirectory:!1,agentId:``,description:``,maxViews:null,ttlMs:864e5,directoryMode:`browse`,result:null,errorMsg:null}})},[]);return a?(0,Z.jsxs)(W,{children:[(0,Z.jsx)(`h2`,{className:`mb-1 text-sm font-semibold text-fg`,children:e.createTitle}),(0,Z.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:e.createHint}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.pathLabel}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:i(`flex min-w-0 flex-1 items-center gap-2 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm`,o?`text-fg`:`text-fg-subtle`),children:o?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,children:s?`📁`:`📄`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:o,children:o})]}):(0,Z.jsx)(`span`,{className:`truncate`,children:e.pathPlaceholder})}),(0,Z.jsxs)(p,{type:`button`,variant:`ghost`,onClick:()=>r({type:`patch`,patch:{pickerOpen:!0}}),children:[(0,Z.jsx)(g,{className:`size-4`}),o?e.pathBrowseChange:e.pathBrowse]})]})]}),s?(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.directoryModeLabel}),(0,Z.jsxs)(N,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:f,onChange:e=>r({type:`patch`,patch:{directoryMode:e.target.value===`zip-only`?`zip-only`:`browse`}}),children:[(0,Z.jsx)(V,{value:`browse`,children:e.directoryModeBrowse}),(0,Z.jsx)(V,{value:`zip-only`,children:e.directoryModeZipOnly})]})]}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.ttlLabel}),(0,Z.jsx)(N,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:l,onChange:e=>r({type:`patch`,patch:{ttlMs:Number(e.target.value)}}),children:De.map(t=>(0,Z.jsx)(V,{value:t.value,children:e.ttlOptions[t.key]},t.key))})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.maxViewsLabel}),(0,Z.jsxs)(N,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:u??`unlimited`,onChange:e=>r({type:`patch`,patch:{maxViews:e.target.value===`unlimited`?null:Number(e.target.value)}}),children:[(0,Z.jsx)(V,{value:`unlimited`,children:e.maxViewsUnlimited}),(0,Z.jsx)(V,{value:`1`,children:`1`}),(0,Z.jsx)(V,{value:`5`,children:`5`}),(0,Z.jsx)(V,{value:`10`,children:`10`}),(0,Z.jsx)(V,{value:`50`,children:`50`}),(0,Z.jsx)(V,{value:`100`,children:`100`})]})]})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.descriptionLabel}),(0,Z.jsx)(`input`,{type:`text`,className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:outline-none focus:ring-2 focus:ring-accent`,placeholder:e.descriptionPlaceholder,value:d,onChange:e=>r({type:`patch`,patch:{description:e.target.value}})})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,Z.jsxs)(p,{type:`button`,disabled:m||!o.trim(),onClick:()=>void b(),children:[m?(0,Z.jsx)(L,{className:`size-4 animate-spin`}):(0,Z.jsx)(w,{className:`size-4`}),m?e.creating:e.createButton]}),(0,Z.jsx)(p,{type:`button`,variant:`ghost`,onClick:()=>{x(),r({type:`patch`,patch:{expanded:!1}})},children:e.cancel})]}),_&&(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:_})]}),(0,Z.jsx)(E,{open:v,onOpenChange:e=>{r({type:`patch`,patch:{resultDialogOpen:e,...e?{}:{result:null}}})},result:h}),(0,Z.jsx)(Q,{open:y,onOpenChange:e=>r({type:`patch`,patch:{pickerOpen:e}}),initialPath:o||void 0,selectKind:`any`,onConfirm:e=>r({type:`patch`,patch:{path:e.path,isDirectory:e.isDirectory,agentId:e.agentId,directoryMode:`browse`}})})]}):(0,Z.jsxs)(p,{type:`button`,onClick:()=>r({type:`patch`,patch:{expanded:!0}}),className:`self-start`,children:[(0,Z.jsx)(w,{className:`size-4`}),e.createTitle]})}var Re={revokeOpen:!1,revoking:!1,linksOpen:!1,urlCopied:!1,copyFailed:!1,extending:!1};function ze({share:e,t,language:n,onRevoked:r,onExtended:a}){let[o,s]=(0,K.useReducer)(B,Re),{revokeOpen:c,revoking:l,linksOpen:u,urlCopied:v,copyFailed:y,extending:b}=o,x=!e.expired&&!e.revoked,S=e.revoked?t.statusRevoked:e.expired?t.statusExpired:t.statusActive,C=e.revoked?`text-red-600 dark:text-red-400`:e.expired?`text-fg-subtle`:`text-emerald-600 dark:text-emerald-400`,w=(0,K.useCallback)(async()=>{s({type:`patch`,patch:{revokeOpen:!1,revoking:!0}});try{await m(e.id),r()}catch{}finally{s({type:`patch`,patch:{revoking:!1}})}},[e.id,r]),T=(0,K.useCallback)(async()=>{if(s({type:`patch`,patch:{linksOpen:!0,copyFailed:!1}}),!await f(e.shareUrl)){s({type:`patch`,patch:{copyFailed:!0}}),window.setTimeout(()=>s({type:`patch`,patch:{copyFailed:!1}}),2500);return}s({type:`patch`,patch:{urlCopied:!0}}),window.setTimeout(()=>s({type:`patch`,patch:{urlCopied:!1}}),2e3)},[e.shareUrl]),E=(0,K.useCallback)(async()=>{s({type:`patch`,patch:{extending:!0}});try{await H(e.id,864e5),a()}catch{}finally{s({type:`patch`,patch:{extending:!1}})}},[e.id,a]),D=`share-links-${e.id}`;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:i(`flex min-w-0 flex-1 items-start gap-3 rounded-md text-left`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),"aria-expanded":u,"aria-controls":D,onClick:()=>s({type:`patch`,patch:{linksOpen:!u}}),children:[(0,Z.jsx)(z,{className:i(`mt-0.5 size-4 shrink-0 text-fg-muted transition-transform`,u?`rotate-0`:`-rotate-90`),"aria-hidden":!0}),(0,Z.jsx)(g,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.fileName}),(0,Z.jsx)(`span`,{className:i(`text-xs font-medium`,C),children:S})]}),(0,Z.jsx)(`p`,{className:`truncate text-xs text-fg-subtle`,children:e.workspaceRelativePath}),(0,Z.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:Te(e.fileSize)}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(O,{className:`size-3`}),e.expired?n===`zh`?`已过期`:`expired`:Ee(e.expiresAt,n)]}),(0,Z.jsxs)(`span`,{children:[t.views,`: `,e.downloadCount,e.maxViews!==null&&` ${t.viewsOf} ${e.maxViews}`]}),e.description&&(0,Z.jsx)(`span`,{className:`italic text-fg-subtle`,children:e.description})]})]})]}),(0,Z.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:x&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(p,{type:`button`,variant:`ghost`,className:`px-2 py-1`,title:t.copyUrl,onClick:()=>void T(),children:v?(0,Z.jsx)(I,{className:`size-3.5 text-emerald-500`}):(0,Z.jsx)(_,{className:`size-3.5`})}),(0,Z.jsx)(p,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:()=>void E(),disabled:b,title:t.extend,children:b?(0,Z.jsx)(L,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(O,{className:`size-3.5`})}),(0,Z.jsx)(p,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-red-600 hover:text-red-700 dark:text-red-400`,onClick:()=>s({type:`patch`,patch:{revokeOpen:!0}}),disabled:l,children:l?(0,Z.jsx)(L,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(d,{className:`size-3.5`})})]})})]}),x&&u?(0,Z.jsxs)(`div`,{id:D,className:`mt-3 border-t border-edge-subtle pt-3 pl-7`,children:[(0,Z.jsx)(h,{shareUrl:e.shareUrl,lanUrl:e.lanUrl,reachability:e.reachability,compact:!0}),y?(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-red-600 dark:text-red-400`,children:t.copyFailed}):null,(0,Z.jsx)(`div`,{className:`mt-2`,children:(0,Z.jsx)(ie,{reachability:e.reachability})})]}):null]}),(0,Z.jsx)(M,{open:c,title:t.revokeConfirmTitle,description:t.revokeConfirmBody,confirmLabel:t.revokeConfirmLabel,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void w(),onCancel:()=>s({type:`patch`,patch:{revokeOpen:!1}})})]})}function $({t:e,onCleaned:t}){let[n,r]=(0,K.useState)(!1),[i,a]=(0,K.useState)(!1),o=(0,K.useCallback)(async()=>{r(!1),a(!0);try{await ae(),t()}catch{}finally{a(!1)}},[t]);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Z.jsxs)(p,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>r(!0),className:`border-danger/40 px-2 py-1 text-xs text-danger hover:bg-danger/10`,children:[i?(0,Z.jsx)(L,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(d,{className:`size-3.5`}),e.cleanExpired]})}),(0,Z.jsx)(M,{open:n,title:e.cleanExpiredConfirmTitle,description:e.cleanExpiredConfirmBody,confirmLabel:e.cleanExpiredConfirmLabel,cancelLabel:e.cancel,destructive:!0,onConfirm:()=>void o(),onCancel:()=>r(!1)})]})}export{Oe as SharesSettingsPanel};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{i as t,t as n}from"./fetch-ovkvM8KQ.js";import{Xn as r}from"./index-DdqSO9R2.js";var i=e({reloadSkills:()=>a});async function a(){let e=await n(t(`/api/skills/reload`),{method:`POST`});if(!e.ok)throw Error(await r(e))}export{i as n,a as t};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/jszip.min-DT31yWkU.js","assets/rolldown-runtime-aKtaBQYM.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{t as a}from"./cn-BQ_8x0bT.js";import{t as o}from"./messages-B5O4OIEo.js";import{n as s}from"./locale-store-Ba72bFmP.js";import{c,i as l,t as u}from"./fetch-ovkvM8KQ.js";import{t as d}from"./config-reload-event-Bjh2zoKp.js";import{$a as f,$i as p,As as m,Ba as h,Fr as g,H as _,Ha as v,Ic as y,Lr as b,Ls as x,Nc as S,Pa as C,Pc as w,Po as T,Qa as E,So as D,Wr as O,Xn as k,Yn as A,_s as j,aa as M,co as ee,dc as N,ea as P,fc as F,ia as I,ns as te,oa as L,pc as R,ra as ne,sa as z,ta as re,zs as ie}from"./index-DdqSO9R2.js";import{t as B}from"./skill-reload-api-CS-FU_B-.js";import{i as ae,n as oe,o as se,r as V,t as ce}from"./dist-wO9a2_ID.js";var H=n(),U=e(t(),1),W=r(),G=(0,U.memo)(function(e){let t=(0,H.c)(23),{loading:n,onReloadClick:r,searchQuery:i,setSearchQuery:a,mainTab:o,sk:s,setPendingFile:c,setInstallOpen:l}=e,u;t[0]!==n||t[1]!==r||t[2]!==s.reloadDiskAria||t[3]!==s.reloadRuntime?(u=(0,W.jsx)(O,{className:`size-9 shrink-0 p-0`,loading:n,label:s.reloadDiskAria,title:s.reloadRuntime,onClick:r}),t[0]=n,t[1]=r,t[2]=s.reloadDiskAria,t[3]=s.reloadRuntime,t[4]=u):u=t[4];let d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,W.jsx)(D,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),t[5]=d):d=t[5];let f;t[6]===a?f=t[7]:(f=e=>a(e.target.value),t[6]=a,t[7]=f);let p=o===`marketplace`?s.marketplaceSearchPackages:s.searchPlaceholder,m;t[8]!==i||t[9]!==f||t[10]!==p?(m=(0,W.jsxs)(`label`,{className:`relative flex min-h-9 min-w-0 max-w-sm cursor-text items-center rounded-pill border border-edge bg-surface-base py-1.5 pl-9 pr-3 shadow-surface dark:bg-surface-hover/40 sm:max-w-md`,children:[d,(0,W.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:i,onChange:f,placeholder:p,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-sm leading-normal text-fg caret-current placeholder:text-fg-disabled focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 focus-visible:outline-none`})]}),t[8]=i,t[9]=f,t[10]=p,t[11]=m):m=t[11];let g;t[12]!==l||t[13]!==c?(g=()=>{c(null),l(!0)},t[12]=l,t[13]=c,t[14]=g):g=t[14];let _;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,W.jsx)(T,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[15]=_):_=t[15];let v;t[16]!==s.installCta||t[17]!==g?(v=(0,W.jsxs)(h,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,onClick:g,children:[_,s.installCta]}),t[16]=s.installCta,t[17]=g,t[18]=v):v=t[18];let y;return t[19]!==u||t[20]!==m||t[21]!==v?(y=(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[u,m,v]}),t[19]=u,t[20]=m,t[21]=v,t[22]=y):y=t[22],y}),K=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function le(){let e=(0,H.c)(5),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,W.jsx)(`div`,{className:a(`h-4 min-w-0 flex-1`,K)}),e[0]=t):t=e[0];let n,r,i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[t,(0,W.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,W.jsx)(`div`,{className:a(`size-8 shrink-0 rounded-lg`,K)}),(0,W.jsx)(`div`,{className:a(`h-8 w-[4.5rem] shrink-0 rounded-lg`,K)})]})]}),r=(0,W.jsx)(`div`,{className:a(`h-3 w-full`,K)}),i=(0,W.jsx)(`div`,{className:a(`h-3 w-[92%]`,K)}),e[1]=n,e[2]=r,e[3]=i):(n=e[1],r=e[2],i=e[3]);let o;return e[4]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,W.jsx)(`div`,{className:`flex h-full min-h-[10.5rem] flex-col rounded-xl border border-edge-subtle bg-surface-base p-4 dark:border-edge-subtle`,"aria-hidden":!0,children:(0,W.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[n,r,i,(0,W.jsxs)(`div`,{className:`mt-auto space-y-1 pt-0.5`,children:[(0,W.jsx)(`div`,{className:a(`h-3 w-full`,K)}),(0,W.jsx)(`div`,{className:a(`h-2.5 w-4/5`,K)})]})]})})}),e[4]=o):o=e[4],o}function q(){let e=(0,H.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,W.jsx)(le,{}),e[0]=t):t=e[0],t}var ue=new Set([`builtin`,`user`,`marketplace`]),de=new Set([`all`,`global`,`workspace`,`extra`]),fe=`mprov`,J=[`s0`,`s1`,`s2`,`s3`,`s4`,`s5`],pe=[`business`,`creative`,`documents`,`engineering`,`tools`];function me(e){let t=(0,H.c)(28),{sk:n,mainTab:r,loading:i,catalog:o,filteredCatalog:s,builtinCategories:c,builtinCategoryFilter:l,setBuiltinCategoryFilter:u,catalogDisplayRows:d,catalogStatusFilter:f,resolveSkillEnabled:p,categoryLabel:m,sourceLabel:g,openSkillDetail:v,onSkillToggle:y,onUseSkillInChat:b,usingSkillInChatName:x,togglingSkillName:S}=e;if(i){let e=n.loading,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=J.map(Z),t[0]=r):r=t[0];let i;return t[1]===n.loading?i=t[2]:(i=(0,W.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,"aria-busy":`true`,"aria-label":e,children:r}),t[1]=n.loading,t[2]=i),i}if(o.length===0){let e;return t[3]===n.empty?e=t[4]:(e=(0,W.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge py-16 text-center text-sm text-fg-muted`,children:n.empty}),t[3]=n.empty,t[4]=e),e}if(s.length===0){let e;return t[5]===n.noSearchResults?e=t[6]:(e=(0,W.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge py-16 text-center text-sm text-fg-muted`,children:n.noSearchResults}),t[5]=n.noSearchResults,t[6]=e),e}let w;t[7]!==c||t[8]!==l||t[9]!==m||t[10]!==u||t[11]!==n?(w=c.length>1?(0,W.jsx)(_,{items:[{id:``,label:n.marketplaceCategoryAll},...c.map(e=>({id:e,label:m(e),title:m(e)}))],activeTab:l,onChange:u,ariaLabel:n.marketplaceCategoriesAria,tabIdPrefix:`skills-builtin-category-tab`,className:`gap-2 pt-0.5 [scrollbar-width:thin]`,buttonClassName:`max-w-[14rem] truncate rounded-full border px-3 py-1.5 text-xs`,selectedClassName:`border-fg bg-fg text-surface-panel dark:border-fg dark:bg-fg dark:text-surface-base`,unselectedClassName:`border-edge bg-surface-panel text-fg-muted hover:border-edge-strong hover:text-fg dark:border-edge dark:bg-surface-hover/40`}):null,t[7]=c,t[8]=l,t[9]=m,t[10]=u,t[11]=n,t[12]=w):w=t[12];let T;t[13]!==d||t[14]!==f||t[15]!==r||t[16]!==y||t[17]!==b||t[18]!==v||t[19]!==p||t[20]!==n||t[21]!==g||t[22]!==S||t[23]!==x?(T=d.length===0?(0,W.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge py-16 text-center text-sm text-fg-muted`,children:f===`disabled`?n.noDisabledSkills:n.noSearchResults}):(0,W.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:d.map(e=>{let t=p(e);return(0,W.jsxs)(`article`,{className:a(`group flex h-full flex-col rounded-xl border bg-surface-base p-4 transition-colors`,t?`border-edge-subtle hover:border-accent/40 hover:bg-surface-hover dark:border-edge-subtle`:`border-amber-300/70 bg-amber-50/30 hover:border-amber-400/80 hover:bg-amber-50/50 dark:border-amber-700/50 dark:bg-amber-950/20 dark:hover:border-amber-600/60`),children:[(0,W.jsx)(`div`,{role:`button`,tabIndex:0,className:a(`flex min-h-0 flex-1 cursor-pointer flex-col rounded-lg text-left outline-none`,C.focusRingPanel),"aria-labelledby":`catalog-skill-title-${e.directoryId}`,onClick:t=>{t.target.closest(`button`)||v(e)},onKeyDown:t=>{t.target.closest(`button`)||(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),v(e))},children:(0,W.jsx)(`div`,{className:`flex items-start gap-3`,children:(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,W.jsx)(`h3`,{id:`catalog-skill-title-${e.directoryId}`,className:`min-w-0 flex-1 truncate text-[15px] font-semibold leading-snug tracking-tight text-fg`,children:e.name}),(0,W.jsxs)(`div`,{role:`group`,className:a(`hidden shrink-0 items-center gap-1 transition-opacity sm:flex`,`sm:pointer-events-none sm:opacity-0 sm:group-hover:pointer-events-auto sm:group-hover:opacity-100 sm:group-focus-within:pointer-events-auto sm:group-focus-within:opacity-100`),onClick:X,onKeyDown:Y,children:[t?null:(0,W.jsx)(h,{type:`button`,variant:`primary`,className:`h-8 shrink-0 whitespace-nowrap px-2.5 text-xs font-medium`,disabled:S===e.name,onClick:()=>void y(e.name,!0),children:S===e.name?n.uploading:n.detailModalEnable}),(0,W.jsx)(h,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 whitespace-nowrap px-2.5 text-xs font-medium`,disabled:!t||x===e.name||S===e.name,title:t?void 0:n.useRequiresEnabled,onClick:()=>void b({name:e.name,source:`catalog`}),children:x===e.name?n.previewUseInChatBusy:n.previewUseInChat})]})]}),(0,W.jsx)(`p`,{className:`line-clamp-2 text-sm leading-relaxed text-fg-muted`,title:e.description?e.description:void 0,children:e.description||`—`}),(0,W.jsx)(`div`,{className:`flex flex-wrap gap-1.5 text-[11px] text-fg-subtle`,children:r!==`builtin`||e.managed?(0,W.jsxs)(W.Fragment,{children:[r===`builtin`?null:(0,W.jsx)(`span`,{className:`rounded-md bg-surface-hover/60 px-2 py-0.5 dark:bg-surface-active/50`,children:g(e.source)}),e.managed?(0,W.jsxs)(`span`,{className:`rounded-md bg-surface-hover/60 px-2 py-0.5 dark:bg-surface-active/50`,children:[n.col.managed,`: `,n.yes]}):null,e.hub?(0,W.jsxs)(`span`,{className:`max-w-full break-all rounded-md bg-surface-hover/60 px-2 py-0.5 font-mono text-[10px] leading-snug dark:bg-surface-active/50 line-clamp-2`,title:`${e.hub.source}${e.hub.ref?`\nref: ${e.hub.ref}`:``}\nupdated: ${e.hub.updatedAt}`,children:[n.hubRemote,` ·`,` `,e.hub.kind===`git`?n.hubKindGit:n.hubKindArchive,` ·`,` `,e.hub.source.length>48?`${e.hub.source.slice(0,48)}…`:e.hub.source]}):null]}):null})]})})}),(0,W.jsxs)(`div`,{role:`group`,className:`mt-3 flex items-center justify-end gap-1 border-t border-edge-subtle pt-3 sm:hidden`,children:[t?null:(0,W.jsx)(h,{type:`button`,variant:`primary`,className:`h-8 shrink-0 whitespace-nowrap px-2.5 text-xs font-medium`,disabled:S===e.name,onClick:()=>void y(e.name,!0),children:S===e.name?n.uploading:n.detailModalEnable}),(0,W.jsx)(h,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 whitespace-nowrap px-2.5 text-xs font-medium`,disabled:!t||x===e.name||S===e.name,title:t?void 0:n.useRequiresEnabled,onClick:()=>void b({name:e.name,source:`catalog`}),children:x===e.name?n.previewUseInChatBusy:n.previewUseInChat})]})]},`${e.directoryId}-${e.path}`)})}),t[13]=d,t[14]=f,t[15]=r,t[16]=y,t[17]=b,t[18]=v,t[19]=p,t[20]=n,t[21]=g,t[22]=S,t[23]=x,t[24]=T):T=t[24];let E;return t[25]!==w||t[26]!==T?(E=(0,W.jsxs)(W.Fragment,{children:[w,T]}),t[25]=w,t[26]=T,t[27]=E):E=t[27],E}function Y(e){return e.stopPropagation()}function X(e){return e.stopPropagation()}function Z(e){return(0,W.jsx)(q,{},e)}var Q=`https://skillhub.cn`,he=`https://clawhub.ai`;function ge(e){let t=e.trim();return t?`${Q}/skills/${encodeURIComponent(t)}`:null}function _e(e){let t=e.trim();return t?`${he}/${encodeURIComponent(t)}`:null}function ve(e,t){return e===`skillhub`?ge(t):e===`clawhub`?_e(t):null}function ye(e,t){return t===`store`?e.name.trim()||e.id:e.id.trim()||e.name}function be(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function xe(e){let t=[e.kind];return e.label?.trim()&&t.push(e.label.trim()),e.package?.trim()&&t.push(e.package.trim()),e.formula?.trim()&&t.push(e.formula.trim()),e.module?.trim()&&t.push(e.module.trim()),e.url?.trim()&&t.push(e.url.trim()),t.join(` · `)}function Se(e){return{...e,enabled:e.enabled??!0,disableModelInvocation:e.disableModelInvocation??!1}}function Ce(e){let t=(0,H.c)(32),{sk:n,confirmOpen:r,setConfirmOpen:i,confirmId:a,setConfirmId:o,runDelete:s}=e,c;t[0]!==o||t[1]!==i?(c=e=>{i(e),e||o(null)},t[0]=o,t[1]=i,t[2]=c):c=t[2];let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,W.jsx)(ne,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[3]=l):l=t[3];let u;t[4]===n.deleteTitle?u=t[5]:(u=(0,W.jsx)(L,{className:`text-base font-semibold text-fg`,children:n.deleteTitle}),t[4]=n.deleteTitle,t[5]=u);let d;t[6]!==a||t[7]!==n.deleteMessage?(d=a?be(n.deleteMessage,{id:a}):``,t[6]=a,t[7]=n.deleteMessage,t[8]=d):d=t[8];let f;t[9]===d?f=t[10]:(f=(0,W.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:d}),t[9]=d,t[10]=f);let p;t[11]===i?p=t[12]:(p=()=>i(!1),t[11]=i,t[12]=p);let m;t[13]!==n.cancel||t[14]!==p?(m=(0,W.jsx)(h,{type:`button`,variant:`secondary`,onClick:p,children:n.cancel}),t[13]=n.cancel,t[14]=p,t[15]=m):m=t[15];let g;t[16]===s?g=t[17]:(g=()=>void s(),t[16]=s,t[17]=g);let _;t[18]!==n.deleteConfirm||t[19]!==g?(_=(0,W.jsx)(h,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:g,children:n.deleteConfirm}),t[18]=n.deleteConfirm,t[19]=g,t[20]=_):_=t[20];let v;t[21]!==m||t[22]!==_?(v=(0,W.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[m,_]}),t[21]=m,t[22]=_,t[23]=v):v=t[23];let y;t[24]!==v||t[25]!==u||t[26]!==f?(y=(0,W.jsxs)(I,{children:[l,(0,W.jsxs)(re,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`,children:[u,f,v]})]}),t[24]=v,t[25]=u,t[26]=f,t[27]=y):y=t[27];let b;return t[28]!==r||t[29]!==c||t[30]!==y?(b=(0,W.jsx)(M,{open:r,onOpenChange:c,children:y}),t[28]=r,t[29]=c,t[30]=y,t[31]=b):b=t[31],b}var we=[{light:`bg-sky-100 text-sky-800`,dark:`dark:bg-sky-950/55 dark:text-sky-200`},{light:`bg-violet-100 text-violet-800`,dark:`dark:bg-violet-950/55 dark:text-violet-200`},{light:`bg-emerald-100 text-emerald-800`,dark:`dark:bg-emerald-950/55 dark:text-emerald-200`},{light:`bg-orange-100 text-orange-800`,dark:`dark:bg-orange-950/55 dark:text-orange-200`},{light:`bg-rose-100 text-rose-800`,dark:`dark:bg-rose-950/55 dark:text-rose-200`},{light:`bg-amber-100 text-amber-900`,dark:`dark:bg-amber-950/55 dark:text-amber-200`},{light:`bg-cyan-100 text-cyan-800`,dark:`dark:bg-cyan-950/55 dark:text-cyan-200`},{light:`bg-indigo-100 text-indigo-800`,dark:`dark:bg-indigo-950/55 dark:text-indigo-200`},{light:`bg-fuchsia-100 text-fuchsia-800`,dark:`dark:bg-fuchsia-950/55 dark:text-fuchsia-200`},{light:`bg-teal-100 text-teal-800`,dark:`dark:bg-teal-950/55 dark:text-teal-200`}];function Te(e){let t=0;for(let n=0;n<e.length;n+=1)t=Math.imul(31,t)+e.charCodeAt(n)|0;return Math.abs(t)}function Ee(e){let t=e.trim();if(!t)return`?`;let n=t.match(/[\p{L}\p{N}]/u);return n?n[0].toLocaleUpperCase(`en-US`):t[0]}function De(e){let t=(0,H.c)(9),{name:n,className:r}=e,i;t[0]===n?i=t[1]:(i=Ee(n),t[0]=n,t[1]=i);let o=i,s=we[Te(n)%we.length],c;t[2]!==r||t[3]!==s.dark||t[4]!==s.light?(c=a(`flex size-11 shrink-0 items-center justify-center rounded-xl font-semibold tracking-tight shadow-surface`,`text-[1.05rem] ring-1 ring-inset ring-black/[0.06] dark:ring-white/[0.1]`,`transition-[transform,box-shadow] duration-200 ease-out group-hover:ring-black/[0.1] dark:group-hover:ring-white/[0.14]`,`group-hover:-translate-y-px`,s.light,s.dark,r),t[2]=r,t[3]=s.dark,t[4]=s.light,t[5]=c):c=t[5];let l;return t[6]!==o||t[7]!==c?(l=(0,W.jsx)(`div`,{className:c,"aria-hidden":!0,children:o}),t[6]=o,t[7]=c,t[8]=l):l=t[8],l}function Oe(e){let t=(0,H.c)(7),{label:n,children:r}=e;if(r==null||r===!1)return null;let i;t[0]===n?i=t[1]:(i=(0,W.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,W.jsx)(`div`,{className:`mt-1.5 min-w-0 text-sm text-fg`,children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,W.jsxs)(`div`,{className:`mt-3 border-t border-edge-subtle pt-3 dark:border-edge/60`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function ke(e){let t=(0,H.c)(118),{preview:n,sk:r}=e,i=n.metadata,o=n.toolConditions,s=!!o&&(o.requiresTools.length>0||o.requiresToolsets.length>0||o.fallbackForTools.length>0||o.fallbackForToolsets.length>0),c=i.requires,l=c&&((c.bins?.length??0)>0||(c.env?.length??0)>0||(c.anyBins?.length??0)>0),u,d,f,p,m,h,g,_,v,y,x,S,C,w,T;if(t[0]!==o||t[1]!==l||t[2]!==s||t[3]!==i.emoji||t[4]!==i.homepage||t[5]!==i.install||t[6]!==i.os||t[7]!==n.description||t[8]!==n.disableModelInvocation||t[9]!==n.requiredEnvVarNames||t[10]!==c||t[11]!==r.detailEnvVarsLabel||t[12]!==r.detailHomepageLabel||t[13]!==r.detailInstallLabel||t[14]!==r.detailNotInjectedNote||t[15]!==r.detailPlatformsLabel||t[16]!==r.detailRequiresAnyBins||t[17]!==r.detailRequiresBins||t[18]!==r.detailRequiresEnv||t[19]!==r.detailRequiresLabel||t[20]!==r.detailSummaryHeading||t[21]!==r.detailToolGatingLabel||t[22]!==r.detailToolsFallbackList||t[23]!==r.detailToolsRequiresList||t[24]!==r.detailToolsetsFallbackList||t[25]!==r.detailToolsetsRequiresList){let e=i.install?.filter(Me)??[],b=n.requiredEnvVarNames?.filter(je)??[];g=`space-y-6`,m=`skill-detail-summary-heading`,t[41]===r.detailSummaryHeading?h=t[42]:(h=(0,W.jsx)(`h3`,{id:`skill-detail-summary-heading`,className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:r.detailSummaryHeading}),t[41]=r.detailSummaryHeading,t[42]=h),v=`rounded-xl border border-edge bg-surface-base px-4 py-3 dark:bg-surface-hover/25`,t[43]===i.emoji?y=t[44]:(y=i.emoji?.trim()?(0,W.jsx)(`p`,{className:`text-2xl leading-none`,"aria-hidden":!0,children:i.emoji.trim()}):null,t[43]=i.emoji,t[44]=y);let E;t[45]===i.emoji?E=t[46]:(E=i.emoji?.trim()?`mt-2`:``,t[45]=i.emoji,t[46]=E);let D;t[47]===E?D=t[48]:(D=a(`text-sm leading-relaxed text-fg`,E),t[47]=E,t[48]=D),t[49]!==n.description||t[50]!==D?(x=(0,W.jsx)(`p`,{className:D,children:n.description}),t[49]=n.description,t[50]=D,t[51]=x):x=t[51],t[52]!==n.disableModelInvocation||t[53]!==r.detailNotInjectedNote?(S=n.disableModelInvocation?(0,W.jsx)(`p`,{className:`mt-3 rounded-lg border border-amber-200/80 bg-amber-50/90 px-3 py-2 text-xs leading-snug text-amber-950 dark:border-amber-900/50 dark:bg-amber-950/40 dark:text-amber-100`,children:r.detailNotInjectedNote}):null,t[52]=n.disableModelInvocation,t[53]=r.detailNotInjectedNote,t[54]=S):S=t[54];let O;t[55]===i.homepage?O=t[56]:(O=i.homepage?.trim()?(0,W.jsx)(`a`,{href:i.homepage.trim(),target:`_blank`,rel:`noopener noreferrer`,className:`break-all text-accent underline-offset-2 hover:underline`,children:i.homepage.trim()}):null,t[55]=i.homepage,t[56]=O),t[57]!==r.detailHomepageLabel||t[58]!==O?(C=(0,W.jsx)(Oe,{label:r.detailHomepageLabel,children:O}),t[57]=r.detailHomepageLabel,t[58]=O,t[59]=C):C=t[59];let k;t[60]===i.os?k=t[61]:(k=i.os&&i.os.length>0?(0,W.jsx)(`span`,{className:`font-mono text-xs text-fg-muted`,children:i.os.join(`, `)}):null,t[60]=i.os,t[61]=k),t[62]!==r.detailPlatformsLabel||t[63]!==k?(w=(0,W.jsx)(Oe,{label:r.detailPlatformsLabel,children:k}),t[62]=r.detailPlatformsLabel,t[63]=k,t[64]=w):w=t[64];let A;t[65]!==l||t[66]!==c||t[67]!==r.detailRequiresAnyBins||t[68]!==r.detailRequiresBins||t[69]!==r.detailRequiresEnv?(A=l&&c?(0,W.jsxs)(`ul`,{className:`list-inside list-disc space-y-1 text-sm text-fg-muted`,children:[c.bins&&c.bins.length>0?(0,W.jsxs)(`li`,{children:[(0,W.jsxs)(`span`,{className:`text-fg`,children:[r.detailRequiresBins,`: `]}),c.bins.join(`, `)]}):null,c.env&&c.env.length>0?(0,W.jsxs)(`li`,{children:[(0,W.jsxs)(`span`,{className:`text-fg`,children:[r.detailRequiresEnv,`: `]}),(0,W.jsx)(`span`,{className:`font-mono text-xs`,children:c.env.join(`, `)})]}):null,c.anyBins&&c.anyBins.length>0?(0,W.jsxs)(`li`,{children:[(0,W.jsxs)(`span`,{className:`text-fg`,children:[r.detailRequiresAnyBins,`: `]}),c.anyBins.join(`, `)]}):null]}):null,t[65]=l,t[66]=c,t[67]=r.detailRequiresAnyBins,t[68]=r.detailRequiresBins,t[69]=r.detailRequiresEnv,t[70]=A):A=t[70],t[71]!==r.detailRequiresLabel||t[72]!==A?(T=(0,W.jsx)(Oe,{label:r.detailRequiresLabel,children:A}),t[71]=r.detailRequiresLabel,t[72]=A,t[73]=T):T=t[73];let j=e.length>0?(0,W.jsx)(`ul`,{className:`list-inside list-decimal space-y-1.5 text-sm text-fg-muted`,children:e.map(Ae)}):null;t[74]!==r.detailInstallLabel||t[75]!==j?(f=(0,W.jsx)(Oe,{label:r.detailInstallLabel,children:j}),t[74]=r.detailInstallLabel,t[75]=j,t[76]=f):f=t[76];let M;t[77]!==o||t[78]!==s||t[79]!==r.detailToolsFallbackList||t[80]!==r.detailToolsRequiresList||t[81]!==r.detailToolsetsFallbackList||t[82]!==r.detailToolsetsRequiresList?(M=s&&o?(0,W.jsxs)(`ul`,{className:`mt-1 space-y-2 text-sm text-fg-muted`,children:[o.requiresTools.length>0?(0,W.jsxs)(`li`,{children:[(0,W.jsxs)(`span`,{className:`font-medium text-fg`,children:[r.detailToolsRequiresList,`: `]}),o.requiresTools.join(`, `)]}):null,o.requiresToolsets.length>0?(0,W.jsxs)(`li`,{children:[(0,W.jsxs)(`span`,{className:`font-medium text-fg`,children:[r.detailToolsetsRequiresList,`: `]}),o.requiresToolsets.join(`, `)]}):null,o.fallbackForTools.length>0?(0,W.jsxs)(`li`,{children:[(0,W.jsxs)(`span`,{className:`font-medium text-fg`,children:[r.detailToolsFallbackList,`: `]}),o.fallbackForTools.join(`, `)]}):null,o.fallbackForToolsets.length>0?(0,W.jsxs)(`li`,{children:[(0,W.jsxs)(`span`,{className:`font-medium text-fg`,children:[r.detailToolsetsFallbackList,`: `]}),o.fallbackForToolsets.join(`, `)]}):null]}):null,t[77]=o,t[78]=s,t[79]=r.detailToolsFallbackList,t[80]=r.detailToolsRequiresList,t[81]=r.detailToolsetsFallbackList,t[82]=r.detailToolsetsRequiresList,t[83]=M):M=t[83],t[84]!==r.detailToolGatingLabel||t[85]!==M?(p=(0,W.jsx)(Oe,{label:r.detailToolGatingLabel,children:M}),t[84]=r.detailToolGatingLabel,t[85]=M,t[86]=p):p=t[86],u=Oe,d=r.detailEnvVarsLabel,_=b.length>0?(0,W.jsx)(`span`,{className:`font-mono text-xs text-fg-muted`,children:b.join(`, `)}):null,t[0]=o,t[1]=l,t[2]=s,t[3]=i.emoji,t[4]=i.homepage,t[5]=i.install,t[6]=i.os,t[7]=n.description,t[8]=n.disableModelInvocation,t[9]=n.requiredEnvVarNames,t[10]=c,t[11]=r.detailEnvVarsLabel,t[12]=r.detailHomepageLabel,t[13]=r.detailInstallLabel,t[14]=r.detailNotInjectedNote,t[15]=r.detailPlatformsLabel,t[16]=r.detailRequiresAnyBins,t[17]=r.detailRequiresBins,t[18]=r.detailRequiresEnv,t[19]=r.detailRequiresLabel,t[20]=r.detailSummaryHeading,t[21]=r.detailToolGatingLabel,t[22]=r.detailToolsFallbackList,t[23]=r.detailToolsRequiresList,t[24]=r.detailToolsetsFallbackList,t[25]=r.detailToolsetsRequiresList,t[26]=u,t[27]=d,t[28]=f,t[29]=p,t[30]=m,t[31]=h,t[32]=g,t[33]=_,t[34]=v,t[35]=y,t[36]=x,t[37]=S,t[38]=C,t[39]=w,t[40]=T}else u=t[26],d=t[27],f=t[28],p=t[29],m=t[30],h=t[31],g=t[32],_=t[33],v=t[34],y=t[35],x=t[36],S=t[37],C=t[38],w=t[39],T=t[40];let E;t[87]!==u||t[88]!==d||t[89]!==_?(E=(0,W.jsx)(u,{label:d,children:_}),t[87]=u,t[88]=d,t[89]=_,t[90]=E):E=t[90];let D;t[91]!==f||t[92]!==p||t[93]!==E||t[94]!==v||t[95]!==y||t[96]!==x||t[97]!==S||t[98]!==C||t[99]!==w||t[100]!==T?(D=(0,W.jsxs)(`div`,{className:v,children:[y,x,S,C,w,T,f,p,E]}),t[91]=f,t[92]=p,t[93]=E,t[94]=v,t[95]=y,t[96]=x,t[97]=S,t[98]=C,t[99]=w,t[100]=T,t[101]=D):D=t[101];let O;t[102]!==m||t[103]!==h||t[104]!==D?(O=(0,W.jsxs)(`section`,{"aria-labelledby":m,children:[h,D]}),t[102]=m,t[103]=h,t[104]=D,t[105]=O):O=t[105];let k;t[106]===r.detailInstructionsHeading?k=t[107]:(k=(0,W.jsx)(`h3`,{id:`skill-detail-instructions-heading`,className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:r.detailInstructionsHeading}),t[106]=r.detailInstructionsHeading,t[107]=k);let A;t[108]!==n.bodyMarkdown||t[109]!==r.detailNoInstructionsBody?(A=n.bodyMarkdown.trim()?(0,W.jsx)(`div`,{className:`markdown-content min-w-0 break-words`,children:(0,W.jsx)(b,{content:n.bodyMarkdown})}):(0,W.jsx)(`p`,{className:`text-sm italic text-fg-muted`,children:r.detailNoInstructionsBody}),t[108]=n.bodyMarkdown,t[109]=r.detailNoInstructionsBody,t[110]=A):A=t[110];let j;t[111]!==k||t[112]!==A?(j=(0,W.jsxs)(`section`,{"aria-labelledby":`skill-detail-instructions-heading`,children:[k,A]}),t[111]=k,t[112]=A,t[113]=j):j=t[113];let M;return t[114]!==g||t[115]!==O||t[116]!==j?(M=(0,W.jsxs)(`div`,{className:g,children:[O,j]}),t[114]=g,t[115]=O,t[116]=j,t[117]=M):M=t[117],M}function Ae(e,t){return(0,W.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:(0,W.jsx)(`span`,{className:`text-fg`,children:xe(e)})},e.id||`${e.kind}-${t}`)}function je(e){return e.trim()}function Me(e){return e&&typeof e.kind==`string`}var Ne=[{id:`s0`,width:`w-[92%]`},{id:`s1`,width:`w-full`},{id:`s2`,width:`w-4/5`},{id:`s3`,width:`w-[92%]`},{id:`s4`,width:`w-full`},{id:`s5`,width:`w-4/5`},{id:`s6`,width:`w-[92%]`},{id:`s7`,width:`w-full`},{id:`s8`,width:`w-4/5`},{id:`s9`,width:`w-[92%]`}];function Pe(e){let t=(0,H.c)(81),{sk:n,detailOpen:r,setDetailOpen:i,detailSource:o,setDetailSource:s,detailTitle:c,setDetailTitle:l,detailCatalogPreview:u,setDetailCatalogPreview:d,detailMarketplacePreview:p,setDetailMarketplacePreview:m,detailLoading:g,detailError:_,setDetailError:y,detailEnabled:b,detailDirectoryId:x,detailManaged:S,detailExternalUrl:w,usingSkillInChatName:T,installingMarketName:D,togglingSkillName:O,isSkillInstalledByName:k,onUseSkillInChat:A,onMarketInstall:ee,onSkillToggle:N,setConfirmId:F,setConfirmOpen:te}=e,R;t[0]!==d||t[1]!==y||t[2]!==m||t[3]!==i||t[4]!==s||t[5]!==l?(R=e=>{i(e),e||(s(`catalog`),d(null),m(null),y(null),l(``))},t[0]=d,t[1]=y,t[2]=m,t[3]=i,t[4]=s,t[5]=l,t[6]=R):R=t[6];let z;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,W.jsx)(ne,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[7]=z):z=t[7];let B;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(B=a(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(88vh,44rem)] max-h-[min(92vh,56rem)] w-[min(100%-2rem,min(92vw,56rem))]`,`-translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),t[8]=B):B=t[8];let ae=c||`?`,oe;t[9]===ae?oe=t[10]:(oe=(0,W.jsx)(De,{name:ae}),t[9]=ae,t[10]=oe);let se=c||`—`,V;t[11]===se?V=t[12]:(V=(0,W.jsx)(L,{className:`min-w-0 flex-1 truncate text-base font-semibold text-fg`,children:se}),t[11]=se,t[12]=V);let ce;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(ce=a(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,C.focusRingPanel),t[13]=ce):ce=t[13];let U;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,W.jsx)(v,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[14]=U):U=t[14];let G;t[15]===n.detailCloseAria?G=t[16]:(G=(0,W.jsx)(P,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,className:ce,"aria-label":n.detailCloseAria,children:U})}),t[15]=n.detailCloseAria,t[16]=G);let K;t[17]!==oe||t[18]!==V||t[19]!==G?(K=(0,W.jsxs)(`div`,{className:`group flex min-h-[3.25rem] shrink-0 items-center gap-3 border-b border-edge px-4 py-3`,children:[oe,V,G]}),t[17]=oe,t[18]=V,t[19]=G,t[20]=K):K=t[20];let le;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,W.jsx)(j,{className:`mt-0.5 size-4 shrink-0 text-blue-600 dark:text-blue-400`,strokeWidth:1.75,"aria-hidden":!0}),t[21]=le):le=t[21];let q=o===`store`&&p?n.detailModalBanner:o===`store`?n.detailModalBannerStore:n.detailModalBanner,ue;t[22]===q?ue=t[23]:(ue=(0,W.jsxs)(`div`,{className:`flex min-h-[3.25rem] shrink-0 items-start gap-2 border-b border-blue-200/80 bg-blue-50/95 px-4 py-2.5 text-sm text-fg dark:border-blue-900/50 dark:bg-blue-950/45`,children:[le,(0,W.jsx)(`p`,{className:`min-w-0 leading-relaxed`,children:q})]}),t[22]=q,t[23]=ue);let de;t[24]!==u||t[25]!==b||t[26]!==_||t[27]!==g||t[28]!==p||t[29]!==o||t[30]!==n?(de=(0,W.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-auto p-4`,children:g?(0,W.jsx)(`div`,{className:`flex h-full min-h-[14rem] flex-col gap-2.5 py-1`,"aria-busy":`true`,"aria-label":n.loading,children:Ne.map(Fe)}):_?(0,W.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:_}):o===`catalog`&&u?(0,W.jsxs)(W.Fragment,{children:[b?null:(0,W.jsxs)(`div`,{className:`mb-4 flex items-start gap-2 rounded-xl border border-amber-200 bg-amber-50 px-3 py-2.5 text-sm text-amber-900 dark:border-amber-900/50 dark:bg-amber-950/30 dark:text-amber-100`,children:[(0,W.jsx)(E,{className:`mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-300`,strokeWidth:1.75,"aria-hidden":!0}),(0,W.jsx)(`p`,{className:`leading-relaxed`,children:n.detailDisabledNotice})]}),(0,W.jsx)(ke,{preview:u,sk:n})]}):o===`store`&&p?(0,W.jsx)(ke,{preview:p,sk:n}):(0,W.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:n.detailLoadFailed})}),t[24]=u,t[25]=b,t[26]=_,t[27]=g,t[28]=p,t[29]=o,t[30]=n,t[31]=de):de=t[31];let fe;t[32]!==w||t[33]!==o||t[34]!==n.marketplaceOpenExternal||t[35]!==n.marketplaceOpenExternalAria?(fe=o===`store`&&w?(0,W.jsxs)(`a`,{href:w,target:`_blank`,rel:`noopener noreferrer`,className:a(`inline-flex h-9 items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-3 text-sm font-medium text-fg-muted`,`hover:bg-surface-hover hover:text-fg dark:border-edge`,C.focusRingPanel),"aria-label":n.marketplaceOpenExternalAria,title:n.marketplaceOpenExternal,children:[(0,W.jsx)(ie,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),(0,W.jsx)(`span`,{children:n.marketplaceOpenExternal})]}):null,t[32]=w,t[33]=o,t[34]=n.marketplaceOpenExternal,t[35]=n.marketplaceOpenExternalAria,t[36]=fe):fe=t[36];let J;t[37]!==x||t[38]!==S||t[39]!==o||t[40]!==F||t[41]!==te||t[42]!==n.delete?(J=o===`catalog`&&S&&x?(0,W.jsxs)(h,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:bg-red-50 hover:text-red-700 dark:text-red-400 dark:hover:bg-red-950/40 dark:hover:text-red-300`,onClick:()=>{F(x),te(!0)},children:[(0,W.jsx)(f,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),n.delete]}):null,t[37]=x,t[38]=S,t[39]=o,t[40]=F,t[41]=te,t[42]=n.delete,t[43]=J):J=t[43];let pe;t[44]!==fe||t[45]!==J?(pe=(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[fe,J]}),t[44]=fe,t[45]=J,t[46]=pe):pe=t[46];let me;t[47]!==b||t[48]!==g||t[49]!==o||t[50]!==c||t[51]!==D||t[52]!==k||t[53]!==ee||t[54]!==N||t[55]!==A||t[56]!==i||t[57]!==n.cancel||t[58]!==n.detailModalDisable||t[59]!==n.detailModalEnable||t[60]!==n.marketplaceInstall||t[61]!==n.marketplaceReinstall||t[62]!==n.previewUseInChat||t[63]!==n.previewUseInChatBusy||t[64]!==n.uploading||t[65]!==n.useRequiresEnabled||t[66]!==O||t[67]!==T?(me=(0,W.jsx)(`div`,{className:`flex items-center gap-2`,children:o===`store`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(h,{type:`button`,variant:`ghost`,onClick:()=>i(!1),children:n.cancel}),(0,W.jsx)(h,{type:`button`,variant:`secondary`,disabled:!c||g||T===c||D===c,onClick:()=>void A(),children:T===c?n.previewUseInChatBusy:n.previewUseInChat}),(0,W.jsx)(h,{type:`button`,variant:k(c)?`secondary`:`primary`,disabled:!c||D===c,onClick:()=>{c&&ee(c,{useDetailProvider:!0})},children:D===c?n.uploading:k(c)?n.marketplaceReinstall:n.marketplaceInstall})]}):(0,W.jsxs)(W.Fragment,{children:[b?(0,W.jsx)(h,{type:`button`,variant:`secondary`,disabled:!c||O===c,onClick:()=>{c&&N(c,!1)},children:O===c?n.uploading:n.detailModalDisable}):(0,W.jsx)(h,{type:`button`,variant:`primary`,disabled:!c||O===c,onClick:()=>{c&&N(c,!0)},children:O===c?n.uploading:n.detailModalEnable}),(0,W.jsx)(h,{type:`button`,variant:`secondary`,disabled:!c||!b||g||T===c||O===c,title:b?void 0:n.useRequiresEnabled,onClick:()=>void A(),children:T===c?n.previewUseInChatBusy:n.previewUseInChat})]})}),t[47]=b,t[48]=g,t[49]=o,t[50]=c,t[51]=D,t[52]=k,t[53]=ee,t[54]=N,t[55]=A,t[56]=i,t[57]=n.cancel,t[58]=n.detailModalDisable,t[59]=n.detailModalEnable,t[60]=n.marketplaceInstall,t[61]=n.marketplaceReinstall,t[62]=n.previewUseInChat,t[63]=n.previewUseInChatBusy,t[64]=n.uploading,t[65]=n.useRequiresEnabled,t[66]=O,t[67]=T,t[68]=me):me=t[68];let Y;t[69]!==pe||t[70]!==me?(Y=(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-t border-edge px-4 py-3`,children:[pe,me]}),t[69]=pe,t[70]=me,t[71]=Y):Y=t[71];let X;t[72]!==K||t[73]!==ue||t[74]!==de||t[75]!==Y?(X=(0,W.jsxs)(I,{children:[z,(0,W.jsxs)(re,{className:B,children:[K,ue,de,Y]})]}),t[72]=K,t[73]=ue,t[74]=de,t[75]=Y,t[76]=X):X=t[76];let Z;return t[77]!==r||t[78]!==R||t[79]!==X?(Z=(0,W.jsx)(M,{open:r,onOpenChange:R,children:X}),t[77]=r,t[78]=R,t[79]=X,t[80]=Z):Z=t[80],Z}function Fe(e){return(0,W.jsx)(`div`,{className:a(`h-4 animate-pulse rounded-md bg-surface-hover dark:bg-surface-active/50`,e.width)},e.id)}function $(e){let t=(0,H.c)(67),{sk:n,installOpen:r,setInstallOpen:i,pendingFile:o,setPendingFile:s,dropActive:c,setDropActive:l,uploading:u,onModalDragOver:d,onModalDragLeave:f,onModalDrop:p,onFileInputChange:m,onInstallSubmit:h}=e,g;t[0]!==l||t[1]!==i||t[2]!==s?(g=e=>{i(e),e||(s(null),l(!1))},t[0]=l,t[1]=i,t[2]=s,t[3]=g):g=t[3];let _;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,W.jsx)(ne,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[4]=_):_=t[4];let y;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(y=a(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] max-h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 overflow-y-auto`,`rounded-2xl border border-edge bg-surface-panel p-6 shadow-float dark:border-edge`),t[5]=y):y=t[5];let b;t[6]===n.installModalTitle?b=t[7]:(b=(0,W.jsx)(L,{className:`text-base font-semibold text-fg`,children:n.installModalTitle}),t[6]=n.installModalTitle,t[7]=b);let S;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(S=a(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,C.focusRingPanel),t[8]=S):S=t[8];let w;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,W.jsx)(v,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[9]=w):w=t[9];let T;t[10]===n.installClose?T=t[11]:(T=(0,W.jsx)(`span`,{className:`sr-only`,children:n.installClose}),t[10]=n.installClose,t[11]=T);let E;t[12]!==n.installClose||t[13]!==T?(E=(0,W.jsx)(P,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,className:S,"aria-label":n.installClose,children:[w,T]})}),t[12]=n.installClose,t[13]=T,t[14]=E):E=t[14];let D;t[15]!==b||t[16]!==E?(D=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[b,E]}),t[15]=b,t[16]=E,t[17]=D):D=t[17];let O=c?`border-accent bg-accent-soft/60 dark:bg-blue-950/40`:`border-edge bg-surface-base dark:bg-surface-hover/30`,k;t[18]===O?k=t[19]:(k=a(`mt-4 flex min-h-[11rem] cursor-pointer flex-col items-center justify-center gap-3 rounded-xl border-2 border-dashed px-6 py-12 text-center transition-colors`,O),t[18]=O,t[19]=k);let A;t[20]!==m||t[21]!==n.installModalDropHint||t[22]!==u?(A=(0,W.jsx)(`input`,{type:`file`,accept:`.zip,.md,application/zip,text/markdown`,className:`sr-only`,"aria-label":n.installModalDropHint,disabled:u,onChange:m}),t[20]=m,t[21]=n.installModalDropHint,t[22]=u,t[23]=A):A=t[23];let j;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,W.jsx)(x,{className:`size-12 text-fg-subtle`,strokeWidth:1.25,"aria-hidden":!0}),t[24]=j):j=t[24];let ee;t[25]===n.installModalDropHint?ee=t[26]:(ee=(0,W.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.installModalDropHint}),t[25]=n.installModalDropHint,t[26]=ee);let N;t[27]===o?N=t[28]:(N=o?(0,W.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:o.name}):null,t[27]=o,t[28]=N);let F;t[29]!==f||t[30]!==d||t[31]!==p||t[32]!==k||t[33]!==A||t[34]!==ee||t[35]!==N?(F=(0,W.jsxs)(`label`,{className:k,onDragLeave:f,onDragOver:d,onDrop:p,children:[A,j,ee,N]}),t[29]=f,t[30]=d,t[31]=p,t[32]=k,t[33]=A,t[34]=ee,t[35]=N,t[36]=F):F=t[36];let te;t[37]===n.installModalReqTitle?te=t[38]:(te=(0,W.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.installModalReqTitle}),t[37]=n.installModalReqTitle,t[38]=te);let R;t[39]===n.installModalReq1?R=t[40]:(R=(0,W.jsx)(`li`,{children:n.installModalReq1}),t[39]=n.installModalReq1,t[40]=R);let z;t[41]===n.installModalReq2?z=t[42]:(z=(0,W.jsx)(`li`,{children:n.installModalReq2}),t[41]=n.installModalReq2,t[42]=z);let ie;t[43]!==R||t[44]!==z?(ie=(0,W.jsxs)(`ul`,{className:`list-inside list-disc space-y-1 text-sm text-fg-muted`,children:[R,z]}),t[43]=R,t[44]=z,t[45]=ie):ie=t[45];let B;t[46]!==te||t[47]!==ie?(B=(0,W.jsxs)(`div`,{className:`mt-5 space-y-2`,children:[te,ie]}),t[46]=te,t[47]=ie,t[48]=B):B=t[48];let ae=!o||u,oe=!o||u?`cursor-not-allowed bg-surface-active text-fg-disabled`:`bg-accent text-white hover:bg-accent-hover`,se;t[49]===oe?se=t[50]:(se=a(`mt-6 flex w-full items-center justify-center rounded-xl py-3 text-sm font-semibold`,`transition-colors`,oe,C.focusRingPanel),t[49]=oe,t[50]=se);let V;t[51]===h?V=t[52]:(V=()=>void h(),t[51]=h,t[52]=V);let ce=u?n.uploading:n.installAction,U;t[53]!==ae||t[54]!==se||t[55]!==V||t[56]!==ce?(U=(0,W.jsx)(`button`,{type:`button`,disabled:ae,className:se,onClick:V,children:ce}),t[53]=ae,t[54]=se,t[55]=V,t[56]=ce,t[57]=U):U=t[57];let G;t[58]!==F||t[59]!==B||t[60]!==U||t[61]!==D?(G=(0,W.jsxs)(I,{children:[_,(0,W.jsxs)(re,{className:y,children:[D,F,B,U]})]}),t[58]=F,t[59]=B,t[60]=U,t[61]=D,t[62]=G):G=t[62];let K;return t[63]!==r||t[64]!==g||t[65]!==G?(K=(0,W.jsx)(M,{open:r,onOpenChange:g,children:G}),t[63]=r,t[64]=g,t[65]=G,t[66]=K):K=t[66],K}function Ie(e){let t=(0,H.c)(66),{sk:n,mpCategories:r,mpCategoriesLoading:i,mpCategoriesError:o,mpPayload:s,mpLoading:c,mpError:l,marketCategoryId:u,setMarketCategoryId:d,marketPage:f,setMarketPage:p,isSkillInstalledByName:m,openMarketplaceDetail:g,onMarketInstall:v,installingMarketName:y,onUseSkillInChat:b,usingSkillInChatName:x,searchInputActive:S,searchQuery:w,setSearchQuery:T,registeredProviders:E,marketBrowseProvider:D,setMarketBrowseProvider:O}=e,k=!S,A,j,M;if(t[0]!==y||t[1]!==m||t[2]!==D||t[3]!==u||t[4]!==f||t[5]!==r||t[6]!==o||t[7]!==i||t[8]!==l||t[9]!==c||t[10]!==s||t[11]!==v||t[12]!==b||t[13]!==g||t[14]!==E||t[15]!==S||t[16]!==w||t[17]!==O||t[18]!==d||t[19]!==p||t[20]!==T||t[21]!==k||t[22]!==n.loading||t[23]!==n.marketplaceAuthor||t[24]!==n.marketplaceCategoriesAria||t[25]!==n.marketplaceCategoryAll||t[26]!==n.marketplaceDownloads||t[27]!==n.marketplaceEmpty||t[28]!==n.marketplaceEmptySearch||t[29]!==n.marketplaceEmptySearchClear||t[30]!==n.marketplaceEmptySearchTryProvider||t[31]!==n.marketplaceInstall||t[32]!==n.marketplaceInstalled||t[33]!==n.marketplacePageNext||t[34]!==n.marketplacePagePrev||t[35]!==n.marketplacePageStatus||t[36]!==n.marketplaceVersion||t[37]!==n.previewUseInChat||t[38]!==n.previewUseInChatBusy||t[39]!==n.uploading||t[40]!==x){let e;t[44]===D?e=t[45]:(e=e=>e.id!==D,t[44]=D,t[45]=e);let P=E.filter(e),I=w.trim(),L;t[46]===n.marketplaceCategoryAll?L=t[47]:(L={id:``,label:n.marketplaceCategoryAll},t[46]=n.marketplaceCategoryAll,t[47]=L);let R;t[48]!==r||t[49]!==L?(R=[L,...r.map(He)],t[48]=r,t[49]=L,t[50]=R):R=t[50];let ne=R;t[51]!==ne||t[52]!==u||t[53]!==r.length||t[54]!==i||t[55]!==d||t[56]!==k||t[57]!==n.marketplaceCategoriesAria?(A=k?r.length>0?(0,W.jsx)(_,{items:ne,activeTab:u,onChange:d,ariaLabel:n.marketplaceCategoriesAria,tabIdPrefix:`skills-marketplace-category-tab`,className:`min-h-[2.75rem] items-center gap-2 pt-0.5 [scrollbar-width:thin]`,buttonClassName:`max-w-[14rem] truncate rounded-full border px-3 py-1.5 text-xs`,selectedClassName:`border-fg bg-fg text-surface-panel dark:border-fg dark:bg-fg dark:text-surface-base`,unselectedClassName:`border-edge bg-surface-panel text-fg-muted hover:border-edge-strong hover:text-fg dark:border-edge dark:bg-surface-hover/40`}):i?(0,W.jsx)(`div`,{className:`-mx-1 flex min-h-[2.75rem] items-center gap-2 overflow-x-auto px-1 pb-1 pt-0.5 [scrollbar-width:thin]`,"aria-hidden":!0,children:[`p0`,`p1`,`p2`,`p3`,`p4`].map(Ve)}):null:null,t[51]=ne,t[52]=u,t[53]=r.length,t[54]=i,t[55]=d,t[56]=k,t[57]=n.marketplaceCategoriesAria,t[58]=A):A=t[58],t[59]!==o||t[60]!==k?(j=k&&o?(0,W.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,role:`alert`,children:o}):null,t[59]=o,t[60]=k,t[61]=j):j=t[61],M=!s&&!l?(0,W.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,"aria-busy":`true`,"aria-label":n.loading,children:J.map(Be)}):l&&!s?(0,W.jsx)(`div`,{className:`rounded-xl border border-edge bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-edge dark:bg-red-950/40 dark:text-red-300`,role:`alert`,children:l}):s?(0,W.jsxs)(`div`,{className:`relative`,children:[c?(0,W.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[1] flex justify-center bg-surface-panel/40 pt-[min(28vh,7.5rem)] backdrop-blur-[1px] motion-reduce:backdrop-blur-none dark:bg-surface-base/35`,"aria-busy":`true`,"aria-label":n.loading,children:(0,W.jsx)(te,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,s.items.length===0?(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-3 rounded-2xl border border-dashed border-edge py-12 text-center text-sm text-fg-muted`,children:[(0,W.jsx)(`p`,{className:`px-4`,children:S&&I?be(n.marketplaceEmptySearch,{query:I}):n.marketplaceEmpty}),S?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[P.map(e=>(0,W.jsx)(h,{type:`button`,variant:`secondary`,className:`h-8 px-3 text-xs`,onClick:()=>O(e.id),children:be(n.marketplaceEmptySearchTryProvider,{provider:e.displayName})},e.id)),(0,W.jsx)(h,{type:`button`,variant:`ghost`,className:`h-8 px-3 text-xs`,onClick:()=>T(``),children:n.marketplaceEmptySearchClear})]}):null]}):(0,W.jsx)(`div`,{className:a(`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,c&&`pointer-events-none opacity-[0.52] motion-reduce:opacity-100`),children:s.items.map(e=>{let t=ye(e,e.providerId??D),r=m(t);return(0,W.jsxs)(`article`,{className:a(`group flex h-full flex-col rounded-xl border border-edge-subtle bg-surface-base p-4`,`transition-colors hover:border-accent/40 hover:bg-surface-hover`,`dark:border-edge-subtle`),children:[(0,W.jsx)(`div`,{role:`button`,tabIndex:0,className:a(`flex min-h-0 flex-1 cursor-pointer flex-col rounded-lg text-left outline-none`,C.focusRingPanel),"aria-labelledby":`mp-skill-title-${e.id}`,onClick:n=>{n.target.closest(`button`)||g(t,e.name,e.providerId??void 0)},onKeyDown:n=>{n.target.closest(`button`)||(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),g(t,e.name,e.providerId??void 0))},children:(0,W.jsx)(`div`,{className:`flex items-start gap-3`,children:(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,W.jsx)(`h3`,{id:`mp-skill-title-${e.id}`,className:`min-w-0 flex-1 truncate text-[15px] font-semibold leading-snug tracking-tight text-fg`,children:e.name}),(0,W.jsxs)(`div`,{role:`group`,className:a(`hidden shrink-0 items-center gap-1 transition-opacity sm:flex`,`sm:pointer-events-none sm:opacity-0 sm:group-hover:pointer-events-auto sm:group-hover:opacity-100 sm:group-focus-within:pointer-events-auto sm:group-focus-within:opacity-100`),onClick:ze,onKeyDown:Re,children:[r?null:(0,W.jsx)(h,{type:`button`,variant:`primary`,className:`h-8 shrink-0 whitespace-nowrap px-2.5 text-xs font-medium`,disabled:c||y===t,onClick:()=>void v(t,{providerOverride:e.providerId??null}),children:y===t?n.uploading:n.marketplaceInstall}),(0,W.jsx)(h,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 whitespace-nowrap px-2.5 text-xs font-medium`,disabled:c||x===t||y===t,onClick:()=>void b({name:t,source:`store`,providerOverride:e.providerId??null}),children:x===t?n.previewUseInChatBusy:n.previewUseInChat})]})]}),(0,W.jsx)(`p`,{className:`line-clamp-2 text-sm leading-relaxed text-fg-muted`,title:e.description?e.description:void 0,children:e.description||`—`}),(0,W.jsxs)(`div`,{className:`mt-auto min-h-[2.625rem] space-y-1 text-[11px] leading-snug text-fg-muted`,children:[(0,W.jsxs)(`p`,{className:`line-clamp-1`,title:`${n.marketplaceAuthor}: ${e.author.username} · ${n.marketplaceDownloads}: ${e.downloads}${e.stars!=null&&e.stars>0?` · ★${e.stars}`:``}${r?` · ${n.marketplaceInstalled}`:``}`,children:[(0,W.jsx)(`span`,{className:`text-fg-subtle`,children:n.marketplaceAuthor}),` `,(0,W.jsx)(`span`,{className:`text-fg`,children:e.author.username}),(0,W.jsx)(`span`,{className:`text-fg-subtle`,children:` · `}),(0,W.jsxs)(`span`,{children:[n.marketplaceDownloads,`: `,e.downloads]}),e.stars!=null&&e.stars>0?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`text-fg-subtle`,children:` · `}),(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-fg-muted`,children:[(0,W.jsx)(ee,{className:`size-3 shrink-0 text-amber-600 dark:text-amber-400`,strokeWidth:2,"aria-hidden":!0}),e.stars]})]}):null,r?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`text-fg-subtle`,children:` · `}),(0,W.jsx)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:n.marketplaceInstalled})]}):null]}),e.latestVersion?(0,W.jsxs)(`p`,{className:`line-clamp-1 min-h-[1.125rem] font-mono text-[10px] text-fg-subtle`,title:`${n.marketplaceVersion}: ${e.latestVersion}`,children:[n.marketplaceVersion,`: `,e.latestVersion]}):null]})]})})}),(0,W.jsxs)(`div`,{role:`group`,className:`mt-3 flex items-center justify-end gap-1 border-t border-edge-subtle pt-3 sm:hidden`,children:[r?null:(0,W.jsx)(h,{type:`button`,variant:`primary`,className:`h-8 shrink-0 whitespace-nowrap px-2.5 text-xs font-medium`,disabled:c||y===t,onClick:()=>void v(t,{providerOverride:e.providerId??null}),children:y===t?n.uploading:n.marketplaceInstall}),(0,W.jsx)(h,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 whitespace-nowrap px-2.5 text-xs font-medium`,disabled:c||x===t||y===t,onClick:()=>void b({name:t,source:`store`,providerOverride:e.providerId??null}),children:x===t?n.previewUseInChatBusy:n.previewUseInChat})]})]},e.id)})}),s.items.length>0?(0,W.jsxs)(`div`,{className:`mt-3 flex flex-col items-center justify-between gap-3 sm:flex-row`,children:[(0,W.jsx)(`p`,{className:`text-center text-xs text-fg-muted sm:text-left`,children:be(n.marketplacePageStatus,{page:s.meta.page,totalPages:s.meta.totalPages,total:s.meta.total})}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsxs)(h,{type:`button`,variant:`ghost`,className:`h-9 gap-1 px-2`,disabled:c||f<=1,"aria-label":n.marketplacePagePrev,onClick:()=>p(Le),children:[(0,W.jsx)(F,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`sr-only sm:not-sr-only`,children:n.marketplacePagePrev})]}),(0,W.jsxs)(h,{type:`button`,variant:`ghost`,className:`h-9 gap-1 px-2`,disabled:c||f>=s.meta.totalPages,"aria-label":n.marketplacePageNext,onClick:()=>p(e=>Math.min(s.meta.totalPages,e+1)),children:[(0,W.jsx)(`span`,{className:`sr-only sm:not-sr-only`,children:n.marketplacePageNext}),(0,W.jsx)(N,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})]})]})]}):null]}):null,t[0]=y,t[1]=m,t[2]=D,t[3]=u,t[4]=f,t[5]=r,t[6]=o,t[7]=i,t[8]=l,t[9]=c,t[10]=s,t[11]=v,t[12]=b,t[13]=g,t[14]=E,t[15]=S,t[16]=w,t[17]=O,t[18]=d,t[19]=p,t[20]=T,t[21]=k,t[22]=n.loading,t[23]=n.marketplaceAuthor,t[24]=n.marketplaceCategoriesAria,t[25]=n.marketplaceCategoryAll,t[26]=n.marketplaceDownloads,t[27]=n.marketplaceEmpty,t[28]=n.marketplaceEmptySearch,t[29]=n.marketplaceEmptySearchClear,t[30]=n.marketplaceEmptySearchTryProvider,t[31]=n.marketplaceInstall,t[32]=n.marketplaceInstalled,t[33]=n.marketplacePageNext,t[34]=n.marketplacePagePrev,t[35]=n.marketplacePageStatus,t[36]=n.marketplaceVersion,t[37]=n.previewUseInChat,t[38]=n.previewUseInChatBusy,t[39]=n.uploading,t[40]=x,t[41]=A,t[42]=j,t[43]=M}else A=t[41],j=t[42],M=t[43];let P;return t[62]!==A||t[63]!==j||t[64]!==M?(P=(0,W.jsxs)(W.Fragment,{children:[A,j,M]}),t[62]=A,t[63]=j,t[64]=M,t[65]=P):P=t[65],P}function Le(e){return Math.max(1,e-1)}function Re(e){return e.stopPropagation()}function ze(e){return e.stopPropagation()}function Be(e){return(0,W.jsx)(le,{},e)}function Ve(e){return(0,W.jsx)(`div`,{className:`h-8 w-[4.5rem] shrink-0 animate-pulse rounded-full bg-surface-hover motion-reduce:animate-none dark:bg-surface-active/50`},e)}function He(e){return{id:e.id,label:e.label,title:e.label}}function Ue(e){let t=(0,H.c)(114),{vm:n}=e,{sk:r,hasToken:i,error:o,actionFeedback:s,skillDiagnostics:c,mainTab:l,setMainTab:u,setSourceFilter:d,builtinTabStats:f,userTabStats:p,catalogDisabledCount:h,catalogStatusFilter:g,setCatalogStatusFilter:v,marketSort:y,setMarketSort:b,marketBrowseProvider:x,setMarketBrowseProvider:S,registeredProviders:w,filterLabel:T,inSettingsShell:E,searchInputActive:D,resultTab:O,setResultTab:k,aggregatedTabCounts:A,aggregatedProviderStatus:j}=n;if(!i){let e;t[0]===n?e=t[1]:(e=(0,W.jsx)(qe,{vm:n}),t[0]=n,t[1]=e);let i;t[2]===r.needToken?i=t[3]:(i=(0,W.jsx)(`div`,{className:`w-full px-3 py-16 text-center text-sm text-fg-muted sm:px-5 xl:px-6`,children:r.needToken}),t[2]=r.needToken,t[3]=i);let a;return t[4]!==e||t[5]!==i?(a=(0,W.jsxs)(W.Fragment,{children:[e,i]}),t[4]=e,t[5]=i,t[6]=a):a=t[6],a}let M;t[7]===r.tabMarketplace?M=t[8]:(M={id:`marketplace`,label:r.tabMarketplace},t[7]=r.tabMarketplace,t[8]=M);let ee=`${f.enabled}/${f.total}`,N;t[9]!==r.tabBuiltin||t[10]!==ee?(N={id:`builtin`,label:r.tabBuiltin,count:ee},t[9]=r.tabBuiltin,t[10]=ee,t[11]=N):N=t[11];let P=`${p.enabled}/${p.total}`,F;t[12]!==r.tabUser||t[13]!==P?(F={id:`user`,label:r.tabUser,count:P},t[12]=r.tabUser,t[13]=P,t[14]=F):F=t[14];let I;t[15]!==M||t[16]!==N||t[17]!==F?(I=[M,N,F],t[15]=M,t[16]=N,t[17]=F,t[18]=I):I=t[18];let te=I,L;t[19]===w?L=t[20]:(L=[`all`,...w.map(Ke)],t[19]=w,t[20]=L);let ne=L,z;t[21]!==j||t[22]!==A||t[23]!==w||t[24]!==r.marketplaceLoadFailed||t[25]!==r.marketplaceResultsTabAll||t[26]!==ne?(z=ne.map(e=>{let t=e===`all`?r.marketplaceResultsTabAll:w.find(t=>t.id===e)?.displayName??e,n=A[e]??0,i=e===`all`?null:j[e];return{id:e,label:t,title:i===`error`?`${t} · ${r.marketplaceLoadFailed}`:void 0,suffix:i===`loading`?(0,W.jsx)(`span`,{className:`inline-block size-1.5 animate-pulse rounded-full bg-fg-muted/60 motion-reduce:animate-none`,"aria-hidden":!0}):i===`error`?(0,W.jsx)(`span`,{className:`inline-block size-1.5 rounded-full bg-red-500`,"aria-hidden":!0}):(0,W.jsx)(`span`,{className:`tabular-nums opacity-70`,children:n})}}),t[21]=j,t[22]=A,t[23]=w,t[24]=r.marketplaceLoadFailed,t[25]=r.marketplaceResultsTabAll,t[26]=ne,t[27]=z):z=t[27];let re=z,ie;t[28]===n?ie=t[29]:(ie=(0,W.jsx)(qe,{vm:n}),t[28]=n,t[29]=ie);let B;t[30]!==s||t[31]!==o?(B=s?(0,W.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:a(`rounded-xl border px-3 py-2 text-sm`,s.kind===`success`?`border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-900/40 dark:bg-emerald-950/40 dark:text-emerald-200`:`border-red-200 bg-red-50 text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`),children:s.message}):o?(0,W.jsx)(`div`,{className:`rounded-xl border border-edge bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-edge dark:bg-red-950/40 dark:text-red-300`,role:`alert`,children:o}):null,t[30]=s,t[31]=o,t[32]=B):B=t[32];let U;t[33]===c?U=t[34]:(U=c.length>0?(0,W.jsxs)(`div`,{className:`rounded-xl border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-900 dark:border-amber-900/50 dark:bg-amber-950/30 dark:text-amber-200`,role:`status`,children:[(0,W.jsxs)(`div`,{className:`font-medium`,children:[`Skill diagnostics: `,c.length]}),(0,W.jsx)(`ul`,{className:`mt-1 space-y-1`,children:c.slice(0,3).map(Ge)})]}):null,t[33]=c,t[34]=U);let K;t[35]!==E||t[36]!==n.loading||t[37]!==n.mainTab||t[38]!==n.onReloadClick||t[39]!==n.searchQuery||t[40]!==n.setInstallOpen||t[41]!==n.setPendingFile||t[42]!==n.setSearchQuery||t[43]!==n.sk?(K=E?(0,W.jsx)(`div`,{className:`flex flex-col gap-3 border-b border-edge-subtle pb-4 dark:border-edge-subtle sm:flex-row sm:flex-wrap sm:items-center sm:justify-end`,children:(0,W.jsx)(G,{loading:n.loading,onReloadClick:n.onReloadClick,searchQuery:n.searchQuery,setSearchQuery:n.setSearchQuery,mainTab:n.mainTab,sk:n.sk,setPendingFile:n.setPendingFile,setInstallOpen:n.setInstallOpen})}):null,t[35]=E,t[36]=n.loading,t[37]=n.mainTab,t[38]=n.onReloadClick,t[39]=n.searchQuery,t[40]=n.setInstallOpen,t[41]=n.setPendingFile,t[42]=n.setSearchQuery,t[43]=n.sk,t[44]=K):K=t[44];let le;t[45]!==l||t[46]!==te||t[47]!==u||t[48]!==r.skillsNavAria?(le=(0,W.jsx)(_,{items:te,activeTab:l,onChange:u,ariaLabel:r.skillsNavAria,tabIdPrefix:`skills-tab`,panelIdPrefix:`skills-panel`,className:`flex-wrap`}),t[45]=l,t[46]=te,t[47]=u,t[48]=r.skillsNavAria,t[49]=le):le=t[49];let q=l===`user`?`flex-nowrap overflow-x-auto pb-0.5 sm:justify-end`:`flex-wrap sm:justify-end`,ue;t[50]===q?ue=t[51]:(ue=a(`flex min-h-9 min-w-0 items-center gap-2`,q),t[50]=q,t[51]=ue);let de;t[52]!==T||t[53]!==l||t[54]!==d||t[55]!==r.filterAll||t[56]!==r.filterExtra||t[57]!==r.filterGlobal||t[58]!==r.filterWorkspace?(de=l===`user`?(0,W.jsxs)(ae,{children:[(0,W.jsx)(se,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,className:a(`inline-flex h-9 min-h-9 min-w-[9rem] shrink-0 items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 text-xs font-medium text-fg shadow-surface`,C.transition,C.focusRingPanel),children:[(0,W.jsx)(m,{className:`size-3.5 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,W.jsx)(`span`,{children:T}),(0,W.jsx)(R,{className:`size-3.5 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0})]})}),(0,W.jsx)(V,{children:(0,W.jsx)(ce,{className:`z-50 min-w-[10rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[`all`,`global`,`workspace`,`extra`].map(e=>(0,W.jsx)(oe,{className:a(`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none`,`hover:bg-surface-hover data-[highlighted]:bg-surface-hover`),onSelect:()=>d(e),children:e===`all`?r.filterAll:e===`global`?r.filterGlobal:e===`workspace`?r.filterWorkspace:r.filterExtra},e))})})]}):null,t[52]=T,t[53]=l,t[54]=d,t[55]=r.filterAll,t[56]=r.filterExtra,t[57]=r.filterGlobal,t[58]=r.filterWorkspace,t[59]=de):de=t[59];let fe;t[60]!==l||t[61]!==x||t[62]!==y||t[63]!==w||t[64]!==O||t[65]!==re||t[66]!==D||t[67]!==S||t[68]!==b||t[69]!==k||t[70]!==r.marketplaceBrowseSwitchAria||t[71]!==r.marketplaceResultsTabsAria||t[72]!==r.marketplaceSortDownloads||t[73]!==r.marketplaceSortNewest?(fe=l===`marketplace`?D?(0,W.jsx)(_,{items:re,activeTab:O,onChange:k,ariaLabel:r.marketplaceResultsTabsAria,tabIdPrefix:`skills-marketplace-results-tab`,panelIdPrefix:`skills-marketplace-results-panel`,className:`inline-flex h-9 shrink-0 rounded-lg border border-edge bg-surface-panel p-0.5 shadow-surface`,buttonClassName:`rounded-md px-2.5 py-1.5 text-xs`,selectedClassName:`bg-fg text-surface-panel dark:bg-fg dark:text-surface-base`,unselectedClassName:`text-fg-muted hover:text-fg`}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`inline-flex h-9 shrink-0 rounded-lg border border-edge bg-surface-panel p-0.5 shadow-surface`,role:`group`,"aria-label":r.marketplaceBrowseSwitchAria,children:w.map(e=>{let t=x===e.id;return(0,W.jsx)(`button`,{type:`button`,className:a(`rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors`,C.focusRingPanel,t?`bg-fg text-surface-panel dark:bg-fg dark:text-surface-base`:`text-fg-muted hover:text-fg`),"aria-pressed":t,onClick:()=>S(e.id),children:e.displayName},e.id)})}),(0,W.jsxs)(ae,{children:[(0,W.jsx)(se,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,className:a(`inline-flex h-9 min-h-9 min-w-[9rem] shrink-0 items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 text-xs font-medium text-fg shadow-surface`,C.transition,C.focusRingPanel),children:[(0,W.jsx)(m,{className:`size-3.5 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,W.jsx)(`span`,{children:y===`newest`?r.marketplaceSortNewest:r.marketplaceSortDownloads}),(0,W.jsx)(R,{className:`size-3.5 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0})]})}),(0,W.jsx)(V,{children:(0,W.jsxs)(ce,{className:`z-50 min-w-[10rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[(0,W.jsx)(oe,{className:a(`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none`,`hover:bg-surface-hover data-[highlighted]:bg-surface-hover`),onSelect:()=>b(`downloads`),children:r.marketplaceSortDownloads}),(0,W.jsx)(oe,{className:a(`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none`,`hover:bg-surface-hover data-[highlighted]:bg-surface-hover`),onSelect:()=>b(`newest`),children:r.marketplaceSortNewest})]})})]})]}):null,t[60]=l,t[61]=x,t[62]=y,t[63]=w,t[64]=O,t[65]=re,t[66]=D,t[67]=S,t[68]=b,t[69]=k,t[70]=r.marketplaceBrowseSwitchAria,t[71]=r.marketplaceResultsTabsAria,t[72]=r.marketplaceSortDownloads,t[73]=r.marketplaceSortNewest,t[74]=fe):fe=t[74];let J;t[75]!==h||t[76]!==g||t[77]!==l||t[78]!==v||t[79]!==r.filterAll||t[80]!==r.filterDisabledOnly||t[81]!==r.filterDisabledOnlyAria?(J=l!==`marketplace`&&h>0?(0,W.jsx)(`button`,{type:`button`,className:a(`inline-flex h-9 shrink-0 items-center rounded-lg border px-2.5 text-xs font-medium transition-colors`,C.focusRingPanel,g===`disabled`?`border-fg bg-fg text-surface-panel dark:border-fg dark:bg-fg dark:text-surface-base`:`border-amber-300/80 bg-amber-50/90 text-amber-950 hover:border-amber-400 dark:border-amber-700/60 dark:bg-amber-950/40 dark:text-amber-100`),"aria-pressed":g===`disabled`,"aria-label":r.filterDisabledOnlyAria,onClick:()=>v(We),children:g===`disabled`?r.filterAll:be(r.filterDisabledOnly,{count:h})}):l===`builtin`?(0,W.jsx)(`div`,{className:`h-9 min-w-[9rem] shrink-0`,"aria-hidden":!0}):null,t[75]=h,t[76]=g,t[77]=l,t[78]=v,t[79]=r.filterAll,t[80]=r.filterDisabledOnly,t[81]=r.filterDisabledOnlyAria,t[82]=J):J=t[82];let pe;t[83]!==ue||t[84]!==de||t[85]!==fe||t[86]!==J?(pe=(0,W.jsxs)(`div`,{className:ue,children:[de,fe,J]}),t[83]=ue,t[84]=de,t[85]=fe,t[86]=J,t[87]=pe):pe=t[87];let Y;t[88]!==le||t[89]!==pe?(Y=(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-edge-subtle pb-3 sm:flex-row sm:items-center sm:justify-between dark:border-edge-subtle`,children:[le,pe]}),t[88]=le,t[89]=pe,t[90]=Y):Y=t[90];let X;t[91]!==l||t[92]!==n?(X=l===`marketplace`?(0,W.jsx)(Ie,{...n}):(0,W.jsx)(me,{...n}),t[91]=l,t[92]=n,t[93]=X):X=t[93];let Z;t[94]!==Y||t[95]!==X?(Z=(0,W.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[Y,X]}),t[94]=Y,t[95]=X,t[96]=Z):Z=t[96];let Q;t[97]!==B||t[98]!==U||t[99]!==K||t[100]!==Z?(Q=(0,W.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[B,U,K,Z]}),t[97]=B,t[98]=U,t[99]=K,t[100]=Z,t[101]=Q):Q=t[101];let he,ge,_e;t[102]===n?(he=t[103],ge=t[104],_e=t[105]):(he=(0,W.jsx)(Pe,{...n}),ge=(0,W.jsx)($,{...n}),_e=(0,W.jsx)(Ce,{...n}),t[102]=n,t[103]=he,t[104]=ge,t[105]=_e);let ve;t[106]!==Q||t[107]!==he||t[108]!==ge||t[109]!==_e?(ve=(0,W.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[Q,he,ge,_e]}),t[106]=Q,t[107]=he,t[108]=ge,t[109]=_e,t[110]=ve):ve=t[110];let ye;return t[111]!==ie||t[112]!==ve?(ye=(0,W.jsxs)(W.Fragment,{children:[ie,ve]}),t[111]=ie,t[112]=ve,t[113]=ye):ye=t[113],ye}function We(e){return e===`disabled`?`all`:`disabled`}function Ge(e,t){return(0,W.jsxs)(`li`,{className:`truncate`,children:[e.type,`: `,e.message]},`${e.path??e.skillName??`diagnostic`}-${t}`)}function Ke(e){return e.id}function qe(e){let t=(0,H.c)(17),{vm:n}=e,{sk:r,hasToken:i,loading:a,onReloadClick:o,searchQuery:s,setSearchQuery:c,mainTab:l,setPendingFile:u,setInstallOpen:d,inSettingsShell:f}=n,p=z(Ye),m=z(Je),h;t[0]!==a||t[1]!==l||t[2]!==o||t[3]!==s||t[4]!==d||t[5]!==u||t[6]!==c||t[7]!==r?(h=(0,W.jsx)(G,{loading:a,onReloadClick:o,searchQuery:s,setSearchQuery:c,mainTab:l,sk:r,setPendingFile:u,setInstallOpen:d}),t[0]=a,t[1]=l,t[2]=o,t[3]=s,t[4]=d,t[5]=u,t[6]=c,t[7]=r,t[8]=h):h=t[8];let g=h,_,v;return t[9]!==m||t[10]!==i||t[11]!==f||t[12]!==p||t[13]!==r.title||t[14]!==g?(_=()=>!i||f?(m(),()=>m()):(p({startExtra:null,main:(0,W.jsx)(`div`,{className:`min-w-0`,children:(0,W.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:r.title})}),end:g}),()=>m()),v=[m,i,f,p,g,r.title],t[9]=m,t[10]=i,t[11]=f,t[12]=p,t[13]=r.title,t[14]=g,t[15]=_,t[16]=v):(_=t[15],v=t[16]),(0,U.useLayoutEffect)(_,v),null}function Je(e){return e.clearPageHeader}function Ye(e){return e.setPageHeader}async function Xe(e,t){let n=new FormData;n.append(`file`,e),t.skillId&&n.append(`skillId`,t.skillId),t.overwrite&&n.append(`overwrite`,`true`);let r=c.getState().token,i=new Headers;r&&i.set(`Authorization`,`Bearer ${r}`);let a=await fetch(l(`/api/skills/upload`),{method:`POST`,headers:i,body:n});a.status===401&&c.getState().onUnauthorized();let o=await a.json().catch(()=>({}));if(!a.ok)throw Error(o.error||`HTTP ${a.status}`);if(!o.payload?.skillId)throw Error(`Invalid response`);return o.payload}async function Ze(e){let t=await u(l(`/api/skills/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw Error(await k(t))}async function Qe(e,t){let n=await u(l(`/api/skills/enabled`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({skillName:e,enabled:t})});if(!n.ok)throw Error(await k(n))}function $e(e,t){t?.trim()&&e.set(`provider`,t.trim())}async function et(e){let t=new URLSearchParams;$e(t,e?.provider);let n=t.toString(),r=await u(l(`/api/skills/marketplace/categories${n?`?${n}`:``}`),{cache:`no-store`});if(!r.ok)throw Error(await k(r));let i=await r.json();if(!i.payload||!Array.isArray(i.payload.items))throw Error(`Invalid response`);return{items:i.payload.items}}async function tt(e){let t=new URLSearchParams;e.q?.trim()&&t.set(`q`,e.q.trim()),e.page!=null&&t.set(`page`,String(e.page)),e.pageSize!=null&&t.set(`pageSize`,String(e.pageSize)),e.sort&&t.set(`sort`,e.sort),e.category?.trim()&&t.set(`category`,e.category.trim()),$e(t,e.provider);let n=t.toString(),r=await u(l(`/api/skills/marketplace${n?`?${n}`:``}`),{cache:`no-store`,signal:e.signal});if(!r.ok)throw Error(await k(r));let i=await r.json();if(!i.payload?.items||!i.payload.meta)throw Error(`Invalid response`);return i.payload}async function nt(e,t){let n=encodeURIComponent(e),r=new URLSearchParams;$e(r,t?.provider);let i=r.toString(),a=await u(l(`/api/skills/marketplace/packages/${n}${i?`?${i}`:``}`),{cache:`no-store`});if(!a.ok)throw Error(await k(a));let o=(await a.json()).payload;if(!o?.name||!o.skillDocPreview||typeof o.skillDocPreview.name!=`string`||typeof o.skillDocPreview.description!=`string`||typeof o.skillDocPreview.bodyMarkdown!=`string`||typeof o.skillDocPreview.disableModelInvocation!=`boolean`||!o.skillDocPreview.metadata||typeof o.skillDocPreview.metadata!=`object`||typeof o.skillDocPreview.metadata.name!=`string`||typeof o.skillDocPreview.metadata.description!=`string`)throw Error(`Invalid response`);return o}async function rt(e){let t=await u(l(`/api/skills/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await k(t));let n=await t.json();if(!n.payload?.skillId)throw Error(n.error||`Invalid response`);return n.payload}async function it(e){let t=await u(l(`/api/skills/${encodeURIComponent(e)}/content`),{cache:`no-store`});if(!t.ok)throw Error(await k(t));let n=(await t.json()).payload;if(!n||typeof n.name!=`string`||typeof n.description!=`string`||typeof n.bodyMarkdown!=`string`||typeof n.disableModelInvocation!=`boolean`||!n.metadata||typeof n.metadata!=`object`||typeof n.metadata.name!=`string`||typeof n.metadata.description!=`string`)throw Error(`Invalid response`);return n}async function at(){let e=await u(l(`/api/skills/marketplace/provider`),{cache:`no-store`});if(!e.ok)throw Error(await k(e));let t=await e.json();if(!t.payload?.provider)throw Error(`Invalid response`);return t.payload}async function ot(){let e=await u(l(`/api/skills/marketplace/providers`),{cache:`no-store`});if(!e.ok)throw Error(await k(e));let t=await e.json();if(!t.payload?.providers)throw Error(`Invalid response`);return t.payload}async function st(t){let n=t.name.toLowerCase();if(n.endsWith(`.zip`))return t;if(n.endsWith(`skill.md`)){let n=(await i(async()=>{let{default:t}=await import(`./jszip.min-DT31yWkU.js`).then(t=>e(t.default,1));return{default:t}},__vite__mapDeps([0,1]))).default,r=new n;r.file(`SKILL.md`,await t.arrayBuffer());let a=await r.generateAsync({type:`blob`,compression:`DEFLATE`}),o=t.name.replace(/\.md$/i,``).replace(/\s+/g,`-`)||`skill`;return new File([a],`${o}.zip`,{type:`application/zip`})}throw Error(`invalid`)}function ct(){let e=o(s(e=>e.language)).skills,t=!!c(e=>e.token),n=w(),[r,i]=y(),a=r.get(`mprov`)?.trim()||null,[l,u]=(0,U.useState)(!1),[f,m]=(0,U.useState)(null),[h,_]=(0,U.useState)(!1),v=r.get(`q`)??``,b=r.get(`tab`),x=r.get(`source`),C=ue.has(b)?b:`marketplace`,T=de.has(x)?x:`all`,[E,D]=(0,U.useState)(v),[O]=g(E,250),k=O.trim(),j=E.trim().length>0,M=k.length>0,[ee,N]=(0,U.useState)(null),[P,F]=(0,U.useState)(C),[I,te]=(0,U.useState)(T),[L,R]=(0,U.useState)(``),[ne,z]=(0,U.useState)(`all`),[re,ie]=(0,U.useState)(!1),[ae,oe]=(0,U.useState)(null),[se,V]=(0,U.useState)(!1),[ce,H]=(0,U.useState)(!1),[W,G]=(0,U.useState)(null),[K,le]=(0,U.useState)(null),[q,J]=(0,U.useState)({}),[me,Y]=(0,U.useState)(!1),[X,Z]=(0,U.useState)(`catalog`),[Q,he]=(0,U.useState)(``),[ge,_e]=(0,U.useState)(null),[ye,be]=(0,U.useState)(null),[xe,Ce]=(0,U.useState)(!1),[we,Te]=(0,U.useState)(null),[Ee,De]=(0,U.useState)(`downloads`),[Oe,ke]=(0,U.useState)(1),[Ae,je]=(0,U.useState)(null),[Me,Ne]=(0,U.useState)(null),[Pe,Fe]=(0,U.useState)(``),[$,Ie]=(0,U.useState)(()=>a),[Le,Re]=(0,U.useState)(0),[ze,Be]=(0,U.useState)(0),[Ve,He]=(0,U.useState)([]),Ue=(0,U.useRef)(null),We=(0,U.useRef)(a),Ge=(0,U.useRef)(null),Ke=(0,U.useRef)(``),qe=(0,U.useRef)(null),Je=(0,U.useRef)(!1),[Ye,$e]=(0,U.useState)({query:``,byProvider:{}}),[ct,lt]=(0,U.useState)(`all`),ut=(0,U.useRef)(0),dt=(0,U.useRef)(k);dt.current!==k&&(dt.current=k,lt(e=>e===`all`?e:`all`));let ft=p(()=>A().then(e=>(He(e.diagnostics??[]),e.catalog.map(Se))),[t,ze],{enabled:t,initial:[],errorData:[]}),{data:pt,loading:mt,setData:ht}=ft,gt=p(async()=>{try{let{providers:e,current:t}=await ot();return{providers:e.map(e=>({id:e.id,displayName:e.displayName})),current:t}}catch{try{return{providers:[],current:(await at()).provider}}catch{return{providers:[],current:`skillhub`}}}},[t,Le],{enabled:t,initial:{providers:[],current:null}}),_t=l||mt,vt=gt.data.providers;(0,U.useEffect)(()=>{let e=e=>{if(d(e.detail)===`skills`){if(Je.current){Je.current=!1;return}Be(e=>e+1)}else Re(e=>e+1)};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[]);let yt=r.toString(),bt=(0,U.useRef)(yt);if(bt.current!==yt){bt.current=yt;let e=r.get(`q`)??``,t=r.get(`tab`),n=r.get(`source`),i=ue.has(t)?t:`marketplace`,a=de.has(n)?n:`all`;D(t=>t===e?t:e),F(e=>e===i?e:i),te(e=>e===a?e:a);let o=r.get(`mcat`)??``;Fe(i===`marketplace`?e=>e===o?e:o:``)}let xt=(0,U.useRef)(t);!t&&xt.current&&(Ie(null),Ue.current=null),xt.current=t,t&&a&&We.current!==a&&(We.current=a,Ie(a)),t&&a==null&&gt.data.current&&gt.data.current!==Ge.current&&(Ge.current=gt.data.current,Ie(e=>e??gt.data.current));let St=`${k}|${Ee}|${P}|${Pe}|${$??``}|${ct}`;Ke.current!==St&&(Ke.current=St,ke(1)),P===`marketplace`&&$&&qe.current!=null&&qe.current!==$&&Fe(``),qe.current=$;let Ct=p(()=>tt({page:Oe,pageSize:20,sort:Ee,category:Pe.trim()||void 0,provider:$}),[t,P,Pe,Oe,Ee,M,$],{enabled:t&&P===`marketplace`&&!!$&&!M,initial:null,errorData:null});(0,U.useLayoutEffect)(()=>{!t||!j||F(e=>e===`marketplace`?e:`marketplace`)},[t,j]),(0,U.useEffect)(()=>{if(!t||!M||P!==`marketplace`||vt.length===0)return;let n=++ut.current,r={};for(let e of vt)r[e.id]={status:`loading`,rows:[]};$e({query:k,byProvider:r});let i=[],a=[];for(let t of vt){let r=new AbortController;i.push(r);let o=window.setTimeout(()=>{r.abort(new DOMException(`Adapter timed out`,`TimeoutError`))},8e3);a.push(o),tt({provider:t.id,q:k,page:1,pageSize:40,sort:Ee,signal:r.signal}).then(e=>{if(window.clearTimeout(o),n!==ut.current)return;let r=e.items.map(e=>({...e,providerId:t.id}));$e(e=>({...e,byProvider:{...e.byProvider,[t.id]:{status:`ok`,rows:r}}}))}).catch(r=>{if(window.clearTimeout(o),n!==ut.current)return;let i=r instanceof DOMException&&(r.name===`TimeoutError`||r.name===`AbortError`)?e.marketplaceLoadFailed:r instanceof Error?r.message:e.marketplaceLoadFailed;$e(e=>({...e,byProvider:{...e.byProvider,[t.id]:{status:`error`,rows:[],error:i}}}))})}return()=>{for(let e of a)window.clearTimeout(e);for(let e of i)e.abort()}},[t,P,M,k,vt,Ee,e.marketplaceLoadFailed]);let wt=p(()=>et({provider:$}).then(e=>e.items),[t,P,$],{enabled:t&&P===`marketplace`&&!!$,initial:[],errorData:[]}),Tt=(0,U.useMemo)(()=>{if(!M||Ye.query!==k)return[];let e=vt.map(e=>({id:e.id,rows:[...Ye.byProvider[e.id]?.rows??[]]})),t=[];for(;e.some(e=>e.rows.length>0);)for(let n of e)n.rows.length>0&&t.push(n.rows.shift());let n=new Map;for(let e of t){let t=[(e.id??``).toLowerCase().trim(),(e.name??``).toLowerCase().trim(),(e.author?.username??``).toLowerCase().trim()].join(`|`),r=n.get(t);if(!r){n.set(t,{...e,additionalSources:[]});continue}if(e.providerId&&e.providerId!==r.providerId){let t=r.additionalSources??[];t.some(t=>t.providerId===e.providerId)||(t.push({providerId:e.providerId,sourceLabel:e.sourceLabel}),r.additionalSources=t)}}return Array.from(n.values())},[M,k,Ye,vt]),Et=(0,U.useMemo)(()=>{if(!M)return{};let e={all:Tt.length};for(let t of vt)e[t.id]=Tt.filter(e=>e.providerId===t.id||(e.additionalSources??[]).some(e=>e.providerId===t.id)).length;return e},[M,Tt,vt]),Dt=(0,U.useMemo)(()=>M?ct===`all`?Tt:Tt.filter(e=>e.providerId===ct||(e.additionalSources??[]).some(e=>e.providerId===ct)):[],[M,Tt,ct]),Ot=(0,U.useMemo)(()=>{if(!M)return{};let e={};for(let t of vt)e[t.id]=Ye.byProvider[t.id]?.status??`loading`;return e},[M,Ye,vt]),kt=(0,U.useMemo)(()=>Object.values(Ot).some(e=>e===`loading`),[Ot]),At=(0,U.useMemo)(()=>{if(!M)return!1;let e=Object.values(Ot);return e.length>0&&e.every(e=>e===`error`)},[M,Ot]),jt=(0,U.useMemo)(()=>{if(!M||Tt.length===0&&kt)return null;let e=Dt.length,t=(Oe-1)*20;return{items:Dt.slice(t,t+20),meta:{page:Oe,pageSize:20,total:e,totalPages:Math.max(1,Math.ceil(e/20))},provider:ct}},[M,Tt,kt,Dt,Oe,ct]),Mt=P===`marketplace`?j?M?jt:null:Ct.data:null,Nt=P===`marketplace`?j?M?kt:!0:Ct.loading:!1,Pt=M?At?e.marketplaceLoadFailed:null:Ct.error instanceof Error?Ct.error.message:Ct.error?e.marketplaceLoadFailed:null,Ft=P===`marketplace`?wt.data:[],It=P===`marketplace`?wt.loading:!1,Lt=wt.error instanceof Error?wt.error.message:wt.error?e.marketplaceCategoriesFailed:null;Pe.trim()&&Ft.length>0&&!Ft.some(e=>e.id===Pe)&&Fe(``);let Rt=(0,U.useCallback)(async t=>{let n=t?.silent===!0;n||u(!0),m(null);try{let e=await A();return He(e.diagnostics??[]),ht(e.catalog.map(Se)),{ok:!0}}catch(t){let n=t instanceof Error?t.message:e.loadFailed;return m(n),{ok:!1,message:n}}finally{n||u(!1)}},[ht,e.loadFailed]),zt=!l&&ft.error?ft.error instanceof Error?ft.error.message:e.loadFailed:null,Bt=f??zt;(0,U.useEffect)(()=>{i(e=>{let t=new URLSearchParams(e);return k?t.set(`q`,k):t.delete(`q`),P===`marketplace`?t.delete(`tab`):t.set(`tab`,P),I===`all`?t.delete(`source`):t.set(`source`,I),P===`marketplace`&&Pe.trim()?t.set(`mcat`,Pe.trim()):t.delete(`mcat`),P===`marketplace`&&$?t.set(fe,$):t.delete(fe),t.toString()===e.toString()?e:t},{replace:!0})},[P,Pe,$,k,i,I]);let Vt=(0,U.useCallback)((e,t,n=5e3)=>{N({kind:e,message:t}),window.setTimeout(()=>N(null),n)},[]),Ht=(0,U.useCallback)(t=>{let n=t.availability;if(!n)return e.installSuccess;let r=n.skillName||n.skillId;if(!n.loaded)return`Skill "${r}" installed, but it was not loaded. Check skill diagnostics.`;if(n.diagnostics.length>0)return`Skill "${r}" installed with ${n.diagnostics.length} diagnostic(s).`;if(n.enabled===!1)return`Skill "${r}" installed but disabled. Enable it before use.`;if(n.availableForDefaultAgent===!1){let e=n.unavailableReason||`unavailable`;return`Skill "${r}" installed but unavailable for agent "${n.defaultAgentId}" (${e}).`}return`Skill "${r}" installed and ready.`},[e.installSuccess]),Ut=(0,U.useCallback)(async t=>{Z(`catalog`),Y(!0),he(t.name),_e(null),be(null),Te(null),Ce(!0);try{let e=await it(t.name);_e(e),he(e.name)}catch(t){_e(null),Te(t instanceof Error?t.message:e.detailLoadFailed)}finally{Ce(!1)}},[e.detailLoadFailed]),Wt=(0,U.useCallback)(async t=>{let n=t.trim();if(n){Z(`catalog`),Y(!0),he(n),_e(null),be(null),Te(null),Ce(!0);try{let e=await it(n);_e(e),he(e.name)}catch(t){_e(null),Te(t instanceof Error?t.message:e.detailLoadFailed)}finally{Ce(!1)}}},[e.detailLoadFailed]),Gt=(0,U.useCallback)(async(t,n,r)=>{let i=r?.trim()||$;if(i){Ue.current=i,Z(`store`),Y(!0),he(n?.trim()||t),_e(null),be(null),Te(null),Ce(!0);try{let e=await nt(t,{provider:i});he(e.name),be(e.skillDocPreview)}catch(t){be(null),Te(t instanceof Error?t.message:e.detailLoadFailed)}finally{Ce(!1)}}},[$,e.detailLoadFailed]),Kt=(0,U.useCallback)(async(t,n)=>{le(t),J(e=>({...e,[t]:n})),N(null);try{return await Qe(t,n),await Rt({silent:!0}),!0}catch(n){return J(e=>{let{[t]:n,...r}=e;return r}),Vt(`error`,n instanceof Error?n.message:e.skillToggleFailed),!1}finally{le(null),J(e=>{let{[t]:n,...r}=e;return r})}},[Rt,Vt,e.skillToggleFailed]),qt=(0,U.useCallback)(async()=>{N(null),u(!0),m(null);try{await B()}catch(t){m(t instanceof Error?t.message:e.reloadFailed),u(!1);return}await Rt()},[Rt,e.reloadFailed]),Jt=(0,U.useMemo)(()=>{let e=E.trim().toLowerCase();return e?pt.filter(t=>[t.name,t.description,t.directoryId,t.path,t.source,t.hub?.source,t.hub?.ref].filter(Boolean).join(` `).toLowerCase().includes(e)):pt},[pt,E]),Yt=(0,U.useMemo)(()=>{let e=Jt.filter(e=>e.source===`builtin`);return{total:e.length,enabled:e.filter(e=>q[e.name]??e.enabled).length}},[Jt,q]),Xt=(0,U.useMemo)(()=>{let e=Jt.filter(e=>e.source!==`builtin`);return{total:e.length,enabled:e.filter(e=>q[e.name]??e.enabled).length}},[Jt,q]),Zt=(0,U.useMemo)(()=>Q?pt.find(e=>e.name===Q):void 0,[pt,Q]),Qt=Zt==null?!0:q[Q]??Zt.enabled,$t=Zt?.directoryId??null,en=Zt?.managed??!1,tn=(0,U.useMemo)(()=>X!==`store`||!Q?null:ve(Ue.current??$,Q),[X,Q,$]),nn=(0,U.useMemo)(()=>{let e=Jt;return P===`builtin`?e=e.filter(e=>e.source===`builtin`):P===`user`&&(e=e.filter(e=>e.source!==`builtin`),I!==`all`&&(e=e.filter(e=>e.source===I))),e},[Jt,P,I]),rn=(0,U.useMemo)(()=>{let e=new Set,t=[];for(let n of nn){let r=n.category;!r||e.has(r)||(e.add(r),t.push(r))}return t.sort((e,t)=>{let n=pe.indexOf(e),r=pe.indexOf(t);return n>=0&&r>=0?n-r:n>=0?-1:r>=0?1:e.localeCompare(t)})},[nn]),an=(0,U.useCallback)(t=>e.categoryLabel?.[t]||t,[e.categoryLabel]),on=(0,U.useMemo)(()=>L?nn.filter(e=>e.category===L):nn,[nn,L]);(0,U.useEffect)(()=>{z(`all`)},[P]);let sn=(0,U.useCallback)(e=>q[e.name]??e.enabled,[q]),cn=(0,U.useMemo)(()=>on.filter(e=>!sn(e)).length,[on,sn]),ln=(0,U.useMemo)(()=>{let e=on;return ne===`disabled`&&(e=e.filter(e=>!sn(e))),[...e].toSorted((e,t)=>{let n=sn(e);return n===sn(t)?e.name.localeCompare(t.name,void 0,{sensitivity:`base`}):n?-1:1})},[on,ne,sn]),un=async t=>{N(null),_(!0),m(null);try{let n;try{n=await st(t)}catch{m(e.invalidFile),Vt(`error`,e.invalidFile);return}let r=await Xe(n,{overwrite:!0});Je.current=!0,await Rt(),Vt(`success`,Ht(r)),ie(!1),oe(null),F(`user`),await Wt(r.availability?.skillName||r.skillId)}catch(t){m(t instanceof Error?t.message:e.uploadFailed),Vt(`error`,t instanceof Error?t.message:e.uploadFailed)}finally{_(!1)}},dn=()=>{ae&&un(ae)},fn=e=>{let t=e.target.files?.[0];e.target.value=``,t&&oe(t)},pn=e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.types.includes(`Files`)&&(V(!0),e.dataTransfer.dropEffect=`copy`)},mn=e=>{let t=e.currentTarget,n=e.relatedTarget;n&&t.contains(n)||V(!1)},hn=e=>{e.preventDefault(),e.stopPropagation(),V(!1);let t=e.dataTransfer?.files?.[0];t&&oe(t)},gn=t=>{switch(t){case`builtin`:return e.source.builtin;case`workspace`:return e.source.workspace;case`global`:return e.source.global;case`extra`:return e.source.extra;default:return t}},_n=async()=>{let t=W,n=me&&X===`catalog`&&$t===t;if(H(!1),G(null),t){N(null);try{await Ze(t),Je.current=!0,await Rt(),n&&(Y(!1),Z(`catalog`),he(``),_e(null),be(null),Te(null))}catch(t){m(t instanceof Error?t.message:e.deleteFailed)}}},vn=(0,U.useCallback)(e=>pt.some(t=>t.name===e),[pt]),yn=(0,U.useCallback)(async t=>{let r=(t?.name??Q).trim();if(!r)return;let i=t?.source??X;if(i===`catalog`){let e=pt.find(e=>e.name===r);if(e&&!(q[e.name]??e.enabled))return}N(null);let a=i===`store`&&!vn(r);Ne(r);try{if(a){let e=t?.providerOverride?.trim()||Ue.current||$;await rt({name:r,overwrite:!1,...e?{provider:e}:{}}),Je.current=!0,await Rt({silent:!0})}Y(!1),n(`/chat/new?skill=${encodeURIComponent(r)}`)}catch(t){Vt(`error`,t instanceof Error?t.message:e.uploadFailed)}finally{Ne(null)}},[pt,Q,X,q,vn,Rt,n,Vt,e.uploadFailed,$]),bn=(0,U.useCallback)(async(t,n)=>{let r=vn(t);if(!(r&&!window.confirm(e.marketplaceReinstallConfirm))){N(null),je(t);try{let e=n?.providerOverride?.trim()||(n?.useDetailProvider?Ue.current??$:$),i=await rt({name:t,overwrite:r,...e?{provider:e}:{}});Je.current=!0,await Rt({silent:!0}),Vt(`success`,Ht(i)),F(`user`),await Wt(i.availability?.skillName||i.skillId||t)}catch(t){Vt(`error`,t instanceof Error?t.message:e.uploadFailed)}finally{je(null)}}},[vn,Ht,Rt,$,Wt,Vt,e.marketplaceReinstallConfirm,e.uploadFailed]),xn=I===`all`?e.filterAll:I===`global`?e.filterGlobal:I===`workspace`?e.filterWorkspace:e.filterExtra,{pathname:Sn}=S();return{sk:e,hasToken:t,catalog:pt,loading:_t,error:Bt,uploading:h,searchQuery:E,setSearchQuery:D,actionFeedback:ee,skillDiagnostics:Ve,mainTab:P,setMainTab:F,sourceFilter:I,setSourceFilter:te,builtinCategoryFilter:L,setBuiltinCategoryFilter:R,installOpen:re,setInstallOpen:ie,pendingFile:ae,setPendingFile:oe,dropActive:se,setDropActive:V,confirmOpen:ce,setConfirmOpen:H,confirmId:W,setConfirmId:G,togglingSkillName:K,enabledOverride:q,detailOpen:me,setDetailOpen:Y,detailSource:X,setDetailSource:Z,detailTitle:Q,setDetailTitle:he,detailCatalogPreview:ge,setDetailCatalogPreview:_e,detailMarketplacePreview:ye,setDetailMarketplacePreview:be,detailLoading:xe,detailError:we,setDetailError:Te,marketSort:Ee,setMarketSort:De,marketPage:Oe,setMarketPage:ke,mpLoading:Nt,mpError:Pt,mpPayload:Mt,searchActive:M,searchInputActive:j,resultTab:ct,setResultTab:lt,aggregatedTabCounts:Et,aggregatedProviderStatus:Ot,aggregatedAllFailed:At,installingMarketName:Ae,usingSkillInChatName:Me,onUseSkillInChat:yn,marketCategoryId:Pe,setMarketCategoryId:Fe,mpCategories:Ft,mpCategoriesError:Lt,mpCategoriesLoading:It,marketBrowseProvider:$,setMarketBrowseProvider:Ie,registeredProviders:vt,builtinTabStats:Yt,userTabStats:Xt,detailEnabled:Qt,detailDirectoryId:$t,detailManaged:en,detailExternalUrl:tn,filteredCatalog:nn,builtinCategories:rn,categoryFilteredCatalog:on,catalogDisplayRows:ln,catalogDisabledCount:cn,catalogStatusFilter:ne,setCatalogStatusFilter:z,resolveSkillEnabled:sn,filterLabel:xn,inSettingsShell:Sn.startsWith(`/settings/`),categoryLabel:an,onReloadClick:qt,openSkillDetail:Ut,openMarketplaceDetail:Gt,onSkillToggle:Kt,onInstallSubmit:dn,onFileInputChange:fn,onModalDragOver:pn,onModalDragLeave:mn,onModalDrop:hn,sourceLabel:gn,runDelete:_n,onMarketInstall:bn,isSkillInstalledByName:vn}}function lt(){let e=(0,H.c)(2),t=ct(),n;return e[0]===t?n=e[1]:(n=(0,W.jsx)(Ue,{vm:t}),e[0]=t,e[1]=n),n}export{lt as SkillsPage};