@xopcai/xopc 0.0.225 → 0.0.228

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 (239) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{activity-store-CtTYnku4.js → activity-store-M0nAY5XB.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-dizuqu_4.js → agent-avatar-dicebear-CjGZBs4C.js} +1 -1
  5. package/dist/gateway/static/root/assets/agents-B0NI4_NI.js +68 -0
  6. package/dist/gateway/static/root/assets/{api-CLRMz2BT.js → api-BywYxpaS.js} +1 -1
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-Cnk-DtQh.js → app-management-settings-panel--SjycrXk.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-wP0rogVI.js → appearance-settings-8G-TVUtg.js} +1 -1
  9. package/dist/gateway/static/root/assets/apps-page-2NiqD-YP.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-Cpzsm-DM.js → archive-plugin-7_DXaMTP.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-Bd2OOoEK.js → attachment-load-Bx44zSpz.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automations-page-DNqhguyk.js → automations-page-CrKAHqc0.js} +1 -1
  13. package/dist/gateway/static/root/assets/automations-workspace-Q3g9cf0h.js +6 -0
  14. package/dist/gateway/static/root/assets/{binary-plugins-Dcma5HdI.js → binary-plugins-DjDwnHAQ.js} +1 -1
  15. package/dist/gateway/static/root/assets/{block-editor-D-B8ThwK.js → block-editor-7aMOKoZM.js} +3 -3
  16. package/dist/gateway/static/root/assets/browser-settings-page-DTwPkmAC.js +8 -0
  17. package/dist/gateway/static/root/assets/{browser-workflow-inputs-BAPZIXrs.js → browser-workflow-inputs-8NC2qDRF.js} +1 -1
  18. package/dist/gateway/static/root/assets/{browser-workflows-page-DHtaSKEh.js → browser-workflows-page-DVLrWKz_.js} +2 -2
  19. package/dist/gateway/static/root/assets/capabilities-settings-panel-YcP4FbN7.js +7 -0
  20. package/dist/gateway/static/root/assets/{capability-presets-api-zsZQ7im3.js → capability-presets-api-o0y9WgAI.js} +1 -1
  21. package/dist/gateway/static/root/assets/capability-presets-settings-panel-AcPjHHia.js +3 -0
  22. package/dist/gateway/static/root/assets/{channel-recipient-api-Cp8iaaXp.js → channel-recipient-api-C5ABr73b.js} +1 -1
  23. package/dist/gateway/static/root/assets/channels-settings-Ca94Q1D-.js +1 -0
  24. package/dist/gateway/static/root/assets/channels-status-swr-38FsOnR0.js +1 -0
  25. package/dist/gateway/static/root/assets/{chat-terminal-dock-Dr6Rq2ln.js → chat-terminal-dock-BR-_7KC0.js} +2 -2
  26. package/dist/gateway/static/root/assets/connectors-page-SGxfLTd6.js +2 -0
  27. package/dist/gateway/static/root/assets/{cron-expression-BiXrpzmo.js → cron-expression-D8-c-Tkw.js} +1 -1
  28. package/dist/gateway/static/root/assets/{date-picker-BPuRtwKt.js → date-picker-kV-Jyl9J.js} +1 -1
  29. package/dist/gateway/static/root/assets/{dependency-picker-BNC_W7wI.js → dependency-picker-CwKcrfGj.js} +1 -1
  30. package/dist/gateway/static/root/assets/{desktop-pet-DzOpt5nI.js → desktop-pet-D9rnchu3.js} +1 -1
  31. package/dist/gateway/static/root/assets/{desktop-pet-settings-BW0brCvH.js → desktop-pet-settings-CTs5WGzk.js} +1 -1
  32. package/dist/gateway/static/root/assets/{directory-picker-path-field-Baml0uTS.js → directory-picker-path-field-CCl0aaDm.js} +1 -1
  33. package/dist/gateway/static/root/assets/{extension-debug-page-CBXyKmfS.js → extension-debug-page-Cau40SvC.js} +1 -1
  34. package/dist/gateway/static/root/assets/{extension-page-BBhcr_SZ.js → extension-page-BsJXdvIL.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-settings-page-4rwWpN9_.js → extension-settings-page-qWqJyF7-.js} +1 -1
  36. package/dist/gateway/static/root/assets/{gateway-config-api-Dg-BlBe4.js → gateway-config-api-BI0SELXm.js} +1 -1
  37. package/dist/gateway/static/root/assets/{gateway-config-swr-Du0MvK9s.js → gateway-config-swr-BWGjnmDl.js} +1 -1
  38. package/dist/gateway/static/root/assets/{gateway-settings-BOuYZOYe.js → gateway-settings-6ZdOIC7F.js} +1 -1
  39. package/dist/gateway/static/root/assets/{gateway-startup-retry-JbjcHCaN.js → gateway-startup-retry-B_zrtccP.js} +1 -1
  40. package/dist/gateway/static/root/assets/heartbeat-settings-KBwhXeFD.js +1 -0
  41. package/dist/gateway/static/root/assets/home-page-BA2M4CLi.js +1 -0
  42. package/dist/gateway/static/root/assets/{image-generation-api-G2tfPvKP.js → image-generation-api-YKP2me5Z.js} +1 -1
  43. package/dist/gateway/static/root/assets/index-BX0dz1JK.js +70 -0
  44. package/dist/gateway/static/root/assets/index-D_hrEKXM.css +2 -0
  45. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-L1Vtxgp9.js → keyboard-shortcuts-settings-kHtpnyEm.js} +1 -1
  46. package/dist/gateway/static/root/assets/local-app-workbench-page-D2nkn09R.js +2 -0
  47. package/dist/gateway/static/root/assets/{local-apps-page--thlkBLS.js → local-apps-page-BCXa0oUa.js} +1 -1
  48. package/dist/gateway/static/root/assets/{locale-store-DqJz-cOR.js → locale-store-CXhjfe4q.js} +1 -1
  49. package/dist/gateway/static/root/assets/logs-page-D3sNst0K.js +2 -0
  50. package/dist/gateway/static/root/assets/{management-settings-p55fR4XO.js → management-settings-tHnlfOAQ.js} +1 -1
  51. package/dist/gateway/static/root/assets/{markdown-split-DwMcRlBR.js → markdown-split-BMLqHHr5.js} +1 -1
  52. package/dist/gateway/static/root/assets/{markdown-view-DD_PgVue.css → markdown-view-CLzTdVLW.css} +1 -1
  53. package/dist/gateway/static/root/assets/markdown-view-DvM5PWEH.js +201 -0
  54. package/dist/gateway/static/root/assets/{media-plugins-O6H3GZn7.js → media-plugins-DybwqTgv.js} +1 -1
  55. package/dist/gateway/static/root/assets/messages-BMdD0LWk.js +3 -0
  56. package/dist/gateway/static/root/assets/{notes-api-CrjQbmk1.js → notes-api-BFsOGYkd.js} +1 -1
  57. package/dist/gateway/static/root/assets/{notes-page-miO9ig9C.js → notes-page-C24SfF6r.js} +1 -1
  58. package/dist/gateway/static/root/assets/notes-workbench-CTdZc3ov.js +4 -0
  59. package/dist/gateway/static/root/assets/{product-open-page-BOu07nXf.js → product-open-page-DBfCVlJq.js} +1 -1
  60. package/dist/gateway/static/root/assets/project-detail-page-COHaEpbA.js +1 -0
  61. package/dist/gateway/static/root/assets/projects-page-lMnST7D_.js +1 -0
  62. package/dist/gateway/static/root/assets/{registry-api-Bf_HDLUJ.js → registry-api-BFZrVYfy.js} +1 -1
  63. package/dist/gateway/static/root/assets/remote-access-hub-BIRKBvO_.js +1 -0
  64. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DthuRqUH.js → runtime-tools-settings-panel-BPEGTip5.js} +2 -2
  65. package/dist/gateway/static/root/assets/{schema-form-8W8PhXxa.js → schema-form-Dxlu60Td.js} +1 -1
  66. package/dist/gateway/static/root/assets/sessions-page-CATO9G3y.js +1 -0
  67. package/dist/gateway/static/root/assets/settings-advanced-gate-Cco_W41x.js +1 -0
  68. package/dist/gateway/static/root/assets/{settings-form-section-CrsKGYiG.js → settings-form-section-ChXh3Bwk.js} +1 -1
  69. package/dist/gateway/static/root/assets/{settings-loading-skeleton-WJtI0AAq.js → settings-loading-skeleton-BCAUqIe2.js} +1 -1
  70. package/dist/gateway/static/root/assets/{settings-page-PCjwRF47.js → settings-page-D25W9Okr.js} +1 -1
  71. package/dist/gateway/static/root/assets/{setup-status-panel-D65CwlNC.js → setup-status-panel-DsN7Z4Fl.js} +1 -1
  72. package/dist/gateway/static/root/assets/{share-preview-page-BGtvLLeZ.js → share-preview-page-CRFnUaNb.js} +1 -1
  73. package/dist/gateway/static/root/assets/shares-settings-CAX0eNaP.js +1 -0
  74. package/dist/gateway/static/root/assets/skill-reload-api-Doy1gghe.js +1 -0
  75. package/dist/gateway/static/root/assets/{skills-page-C_npyryI.js → skills-page-Cl7jjTK7.js} +1 -1
  76. package/dist/gateway/static/root/assets/{skills-page.utils-C46Sd78k.js → skills-page.utils-BiCl4nb5.js} +1 -1
  77. package/dist/gateway/static/root/assets/{system-settings-panel-DomTLwki.js → system-settings-panel-BuESR7ZT.js} +1 -1
  78. package/dist/gateway/static/root/assets/task-detail-page-BRiy8NL3.js +1 -0
  79. package/dist/gateway/static/root/assets/{theme-store-Ce7wq__X.js → theme-store-DOdCjyuw.js} +1 -1
  80. package/dist/gateway/static/root/assets/{use-autosave-Do9mCRcY.js → use-autosave-Dg1mgJ_l.js} +1 -1
  81. package/dist/gateway/static/root/assets/user-context-page-CqoADNKu.js +1 -0
  82. package/dist/gateway/static/root/assets/{voice-api-key-field-Bc5p-0tX.js → voice-api-key-field-BDNexlVR.js} +1 -1
  83. package/dist/gateway/static/root/assets/{work-discovery-overlay-BieqsmT1.js → work-discovery-overlay-BHTfeaWL.js} +1 -1
  84. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DVj8iYvm.js → workflow-run-setup-panel-Cf_w-NZy.js} +2 -2
  85. package/dist/gateway/static/root/assets/workflows-page-j0P-uECz.js +5 -0
  86. package/dist/gateway/static/root/index.html +12 -12
  87. package/dist/gateway/static/root/notification-sw.js +1 -1
  88. package/dist/package.js +1 -1
  89. package/dist/packages/gateway-contract/src/notifications.js +56 -0
  90. package/dist/packages/gateway-contract/src/turn-outcome.js +114 -0
  91. package/dist/src/agent/agent-manager.d.ts +3 -1
  92. package/dist/src/agent/agent-manager.js +22 -5
  93. package/dist/src/agent/lifecycle/timeout-wrapper.d.ts +1 -0
  94. package/dist/src/agent/lifecycle/timeout-wrapper.js +7 -6
  95. package/dist/src/agent/mcp/mcp-transport-config.d.ts +1 -1
  96. package/dist/src/agent/mcp/mcp-transport-config.js +1 -1
  97. package/dist/src/agent/memory/understanding/service.js +1 -0
  98. package/dist/src/agent/memory/understanding/types.d.ts +1 -0
  99. package/dist/src/agent/orchestration/run-agent-turn-with-timeout.d.ts +2 -2
  100. package/dist/src/agent/orchestration/run-agent-turn-with-timeout.js +4 -4
  101. package/dist/src/agent/service.d.ts +2 -0
  102. package/dist/src/agent/service.js +6 -0
  103. package/dist/src/agent/skills/index.d.ts +22 -2
  104. package/dist/src/agent/skills/index.js +74 -32
  105. package/dist/src/agent/skills/skill-sources.d.ts +0 -1
  106. package/dist/src/agent/skills/skill-sources.js +1 -11
  107. package/dist/src/agent/tools/create-share-tool.js +14 -1
  108. package/dist/src/agent/tools/exec-command.js +3 -3
  109. package/dist/src/agent/tools/execute-code-tool.js +1 -1
  110. package/dist/src/agent/tools/executor.js +2 -2
  111. package/dist/src/agent/tools/image-generate-tool.js +12 -0
  112. package/dist/src/agent/tools/send-media.js +11 -0
  113. package/dist/src/agent/tools/xopc-use-tool.js +1 -1
  114. package/dist/src/cli/command-loaders.js +1 -0
  115. package/dist/src/cli/command-manifest.js +4 -0
  116. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  117. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  118. package/dist/src/cli/commands/history.d.ts +1 -0
  119. package/dist/src/cli/commands/history.js +50 -0
  120. package/dist/src/config/agent-profile.js +1 -1
  121. package/dist/src/connectors/connected-source-understanding.js +1 -1
  122. package/dist/src/gateway/agents-admin.js +1 -1
  123. package/dist/src/gateway/chat-stream/protocol.d.ts +3 -2
  124. package/dist/src/gateway/chat-stream/turn-outcome-collector.d.ts +16 -0
  125. package/dist/src/gateway/chat-stream/turn-outcome-collector.js +111 -0
  126. package/dist/src/gateway/heartbeat/service.js +1 -1
  127. package/dist/src/gateway/hono/lib/static-ui.js +7 -5
  128. package/dist/src/gateway/hono/routes/connectors.js +18 -16
  129. package/dist/src/gateway/hono/routes/index.js +2 -0
  130. package/dist/src/gateway/hono/routes/mobile.js +18 -40
  131. package/dist/src/gateway/hono/routes/notifications.d.ts +3 -0
  132. package/dist/src/gateway/hono/routes/notifications.js +45 -0
  133. package/dist/src/gateway/hono/routes/project-skills.js +30 -2
  134. package/dist/src/gateway/hono/routes/sessions.js +31 -0
  135. package/dist/src/gateway/hono/routes/tasks.js +1 -1
  136. package/dist/src/gateway/hono/routes/voice.js +1 -1
  137. package/dist/src/gateway/hono/routes/you.js +52 -0
  138. package/dist/src/gateway/service/agent-runner.js +6 -2
  139. package/dist/src/gateway/service/run-gateway-agent.js +53 -1
  140. package/dist/src/gateway/service/sessions-api.d.ts +6 -0
  141. package/dist/src/gateway/service/sessions-api.js +60 -3
  142. package/dist/src/gateway/service.d.ts +2 -2
  143. package/dist/src/gateway/service.js +8 -7
  144. package/dist/src/heartbeat/index.js +1 -1
  145. package/dist/src/history/ctx/exporter.d.ts +14 -0
  146. package/dist/src/history/ctx/exporter.js +99 -0
  147. package/dist/src/history/ctx/format.d.ts +25 -0
  148. package/dist/src/history/ctx/format.js +282 -0
  149. package/dist/src/infra/update-restart.js +1 -1
  150. package/dist/src/knowledge/connected-understanding-pipeline.js +12 -3
  151. package/dist/src/knowledge/index.d.ts +0 -1
  152. package/dist/src/knowledge/index.js +1 -2
  153. package/dist/src/media/session-references.d.ts +6 -0
  154. package/dist/src/media/session-references.js +24 -3
  155. package/dist/src/notifications/device-store.d.ts +16 -0
  156. package/dist/src/notifications/device-store.js +96 -0
  157. package/dist/src/notifications/planner.d.ts +6 -0
  158. package/dist/src/notifications/planner.js +156 -0
  159. package/dist/src/notifications/service.d.ts +18 -0
  160. package/dist/src/notifications/service.js +184 -0
  161. package/dist/src/notifications/store.d.ts +53 -0
  162. package/dist/src/notifications/store.js +184 -0
  163. package/dist/src/notifications/types.d.ts +29 -0
  164. package/dist/src/notifications/types.js +14 -0
  165. package/dist/src/projects/project-skill-service.d.ts +28 -6
  166. package/dist/src/projects/project-skill-service.js +76 -29
  167. package/dist/src/session/client-history.d.ts +3 -1
  168. package/dist/src/session/client-history.js +13 -0
  169. package/dist/src/session/index.d.ts +1 -1
  170. package/dist/src/session/manager.d.ts +1 -0
  171. package/dist/src/session/manager.js +6 -0
  172. package/dist/src/session/store.d.ts +15 -0
  173. package/dist/src/session/store.js +58 -0
  174. package/dist/src/storage/sqlite/index.d.ts +2 -1
  175. package/dist/src/storage/sqlite/index.js +3 -2
  176. package/dist/src/storage/sqlite/migrations/135_user_people.sql +59 -0
  177. package/dist/src/storage/sqlite/migrations/136_product_notifications.sql +79 -0
  178. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  179. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  180. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  181. package/dist/src/storage/sqlite/schema.js +1 -1
  182. package/dist/src/storage/sqlite/session-input-repository.d.ts +5 -0
  183. package/dist/src/storage/sqlite/session-input-repository.js +9 -1
  184. package/dist/src/storage/sqlite/user-people-repository.d.ts +32 -0
  185. package/dist/src/storage/sqlite/user-people-repository.js +246 -0
  186. package/dist/src/tasks/index.js +2 -2
  187. package/dist/src/tasks/task-application-service.js +42 -6
  188. package/dist/src/tasks/task-change-events.d.ts +9 -0
  189. package/dist/src/tasks/task-change-events.js +17 -1
  190. package/dist/src/tasks/task-outbox-dispatcher.js +5 -1
  191. package/dist/src/tasks/task-run-dispatcher.js +4 -2
  192. package/dist/src/tasks/task-run-repository.js +13 -0
  193. package/dist/src/user-context/relationships/indexer.d.ts +13 -0
  194. package/dist/src/user-context/relationships/indexer.js +185 -0
  195. package/dist/src/user-context/relationships/service.d.ts +22 -0
  196. package/dist/src/user-context/relationships/service.js +50 -0
  197. package/dist/src/user-context/relationships/types.d.ts +55 -0
  198. package/dist/src/user-context/relationships/types.js +10 -0
  199. package/dist/src/user-context/sources/repository.d.ts +1 -1
  200. package/dist/src/user-context/sources/repository.js +8 -2
  201. package/dist/src/work-discovery/service.js +1 -1
  202. package/package.json +2 -2
  203. package/dist/gateway/static/root/assets/agents-DeEEFZJ4.js +0 -68
  204. package/dist/gateway/static/root/assets/apps-page-Db5YNHVM.js +0 -1
  205. package/dist/gateway/static/root/assets/automations-workspace-CNT05YTb.js +0 -6
  206. package/dist/gateway/static/root/assets/browser-settings-page-UbDj3LIq.js +0 -8
  207. package/dist/gateway/static/root/assets/capabilities-settings-panel-CiO152QS.js +0 -7
  208. package/dist/gateway/static/root/assets/capability-presets-settings-panel-Bc_hRwfL.js +0 -3
  209. package/dist/gateway/static/root/assets/channels-settings-CFW7zBoT.js +0 -1
  210. package/dist/gateway/static/root/assets/channels-status-swr-5rNVq7iI.js +0 -1
  211. package/dist/gateway/static/root/assets/connectors-page-DLBr5nre.js +0 -2
  212. package/dist/gateway/static/root/assets/heartbeat-settings-Dq4YAlSx.js +0 -1
  213. package/dist/gateway/static/root/assets/home-page-BIXkO0Ck.js +0 -1
  214. package/dist/gateway/static/root/assets/index-Csccu8sa.js +0 -74
  215. package/dist/gateway/static/root/assets/index-D3_xSYKd.css +0 -2
  216. package/dist/gateway/static/root/assets/local-app-workbench-page-D-eacBcO.js +0 -2
  217. package/dist/gateway/static/root/assets/logs-page-BRCglHvd.js +0 -2
  218. package/dist/gateway/static/root/assets/markdown-view-CTB9u15e.js +0 -69
  219. package/dist/gateway/static/root/assets/mermaid-render-BbqDc_LQ.js +0 -134
  220. package/dist/gateway/static/root/assets/messages-CeydamsI.js +0 -3
  221. package/dist/gateway/static/root/assets/notes-workbench-_13lmvmF.js +0 -4
  222. package/dist/gateway/static/root/assets/project-detail-page-BStRkOQr.js +0 -1
  223. package/dist/gateway/static/root/assets/projects-page-CY03RxVr.js +0 -1
  224. package/dist/gateway/static/root/assets/remote-access-hub-B19llkld.js +0 -1
  225. package/dist/gateway/static/root/assets/sessions-page-BDA2qbTd.js +0 -1
  226. package/dist/gateway/static/root/assets/settings-advanced-gate-BONIDX4v.js +0 -1
  227. package/dist/gateway/static/root/assets/shares-settings-CdzVKrBl.js +0 -1
  228. package/dist/gateway/static/root/assets/skill-reload-api-CsRWid5h.js +0 -1
  229. package/dist/gateway/static/root/assets/task-detail-page-B6YFX7kK.js +0 -1
  230. package/dist/gateway/static/root/assets/user-context-page-CiCQA40E.js +0 -1
  231. package/dist/gateway/static/root/assets/workflows-page-AG04TTuH.js +0 -5
  232. package/dist/src/knowledge/people-graph.d.ts +0 -25
  233. package/dist/src/knowledge/people-graph.js +0 -92
  234. package/dist/src/mobile/notification-service.d.ts +0 -9
  235. package/dist/src/mobile/notification-service.js +0 -156
  236. package/dist/src/mobile/notification-store.d.ts +0 -28
  237. package/dist/src/mobile/notification-store.js +0 -132
  238. package/dist/src/mobile/notification-types.d.ts +0 -37
  239. package/dist/src/mobile/notification-types.js +0 -9
@@ -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{p as i,t as a}from"./chunk-KS7C4IRE-BaASWQor.js";import{t as o}from"./check-DUBLcKHA.js";import{t as s}from"./copy-Dv6d4Dvw.js";import{t as c}from"./external-link-DjqjBmc3.js";import{t as l}from"./globe-DSSGFWFn.js";import{t as u}from"./loader-circle-CifKLtgG.js";import{t as d}from"./cn-JdwAhgNB.js";import{t as f}from"./button-CSEbl4zT.js";import{s as p}from"./form-field-width-DJw_jULe.js";import{t as m}from"./copy-to-clipboard-HOJ79TWv.js";import{t as h}from"./messages-CeydamsI.js";import{a as g,i as _,l as v,n as y,o as b,r as x,s as S}from"./locale-store-DqJz-cOR.js";import{i as C,o as w}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{a as T,i as E,o as D,r as O,s as k,t as A}from"./dist-BPoKqzeH.js";import{a as j,i as M}from"./vendor-swr-BIWyz7Rc.js";import{n as N,r as P}from"./gateway-config-swr-Du0MvK9s.js";import{Ar as F,Dr as I,Er as L,Fr as R,Ic as z,Ir as B,Is as V,Ji as H,Lr as U,Ml as W,Mr as ee,Nr as G,On as te,Or as K,Pi as ne,Pl as q,Pr as J,Ps as re,Qs as Y,Rr as ie,Sn as ae,Ss as X,Ua as oe,Us as se,Xa as ce,Xo as le,fc as ue,jr as de,kr as fe,qs as pe,ts as me,uo as he,vs as ge,wn as _e,xl as ve,xn as ye,zr as be}from"./index-Csccu8sa.js";import{n as xe,r as Se,t as Ce}from"./settings-page-layout-BRQNel6r.js";import{t as we}from"./settings-advanced-gate-BONIDX4v.js";import{n as Te,r as Ee,t as De}from"./settings-form-section-CrsKGYiG.js";import{n as Oe,r as ke,t as Ae}from"./oauth-authorization-window-Cdolr2wE.js";import{t as je}from"./tab-completion-input-D64VNmiA.js";import{t as Me}from"./browser-BLJWD7WI.js";import{t as Ne}from"./page-tabs-BaEQMYm_.js";var Z=n(),Q=e(t(),1),$=r();function Pe(e){let t=(0,Z.c)(26),{showLabel:n,hideLabel:r,icon:i,hint:a,children:o,className:s,defaultOpen:c,advancedOnly:l}=e,u=l===void 0?!1:l,[f,p]=(0,Q.useState)(c??!1),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=e=>p(e.currentTarget.open),t[0]=m):m=t[0];let h;t[1]===s?h=t[2]:(h=d(`group rounded-2xl bg-surface-base open:pb-1`,s),t[1]=s,t[2]=h);let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(q,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[3]=g):g=t[3];let _;t[4]===i?_=t[5]:(_=i?(0,$.jsx)(i,{className:`size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}):null,t[4]=i,t[5]=_);let v;t[6]===n?v=t[7]:(v=(0,$.jsx)(`span`,{className:`group-open:hidden`,children:n}),t[6]=n,t[7]=v);let y;t[8]===r?y=t[9]:(y=(0,$.jsx)(`span`,{className:`hidden group-open:inline`,children:r}),t[8]=r,t[9]=y);let b;t[10]!==_||t[11]!==v||t[12]!==y?(b=(0,$.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 rounded-2xl px-4 py-3.5 text-sm font-medium text-fg transition-colors hover:text-fg group-open:rounded-b-none [&::-webkit-details-marker]:hidden`,children:[g,_,v,y]}),t[10]=_,t[11]=v,t[12]=y,t[13]=b):b=t[13];let x;t[14]===a?x=t[15]:(x=a?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:a}):null,t[14]=a,t[15]=x);let S;t[16]!==o||t[17]!==x?(S=(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 px-4 pb-4 pt-1`,children:[x,o]}),t[16]=o,t[17]=x,t[18]=S):S=t[18];let C;t[19]!==f||t[20]!==S||t[21]!==h||t[22]!==b?(C=(0,$.jsxs)(`details`,{open:f,onToggle:m,className:h,children:[b,S]}),t[19]=f,t[20]=S,t[21]=h,t[22]=b,t[23]=C):C=t[23];let w=C;if(u){let e;return t[24]===w?e=t[25]:(e=(0,$.jsx)(we,{children:w}),t[24]=w,t[25]=e),e}return w}function Fe(e,t){let{mutate:n}=j(),[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`),N()])},[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 F();if(!n.ok)throw Error(`Failed to enable LAN pairing`);if(n.requiresRestart){let t=await L();if(!t.ok)throw Error(t.message??`Gateway restart failed`);if(!await I(e))throw Error(`Gateway did not come back online in time`)}let r=n.requiresRestart?await K():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)}}function Ie(){return d(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,p,`dark:border-edge`)}function Le(e){let t=(0,Z.c)(122),{pairQr:n,gatewayToken:r,streamlined:i,lanOnly:o,onRefreshQr:s}=e,c=i===void 0?!1:i,l=o===void 0?!1:o,p=y(Be),m;t[0]===p?m=t[1]:(m=h(p),t[0]=p,t[1]=m);let g=m,_=g.tunnelSettings,v=l?g.remoteAccess.lan:null,b;t[2]!==g.clipboard.copyFailed||t[3]!==_.pairCopied||t[4]!==_.pairCopyLink?(b={copy:_.pairCopyLink,copied:_.pairCopied,copyFailed:g.clipboard.copyFailed},t[2]=g.clipboard.copyFailed,t[3]=_.pairCopied,t[4]=_.pairCopyLink,t[5]=b):b=t[5];let x=b,{tunnelActive:S,tunnelStatus:C,tunnelQr:w,pairContext:T,pairBaseUrl:E,setPairBaseUrl:D,applySuggestedPairUrl:O,applyCandidateUrl:k,resetPairBaseFromContext:A,baseOk:j,localhostWarn:M,pairingBlocked:N,deepLink:P,qrPayload:F,qrDataUrl:I,qrGenFailed:L,encoding:R}=n,z;t[6]===A?z=t[7]:(z=e=>{A(e.recommended.url)},t[6]=A,t[7]=z);let B=Fe(r,z),V,U,W,ee,G;if(t[8]!==k||t[9]!==O||t[10]!==j||t[11]!==B||t[12]!==r||t[13]!==v||t[14]!==l||t[15]!==M||t[16]!==s||t[17]!==E||t[18]!==T?.candidates||t[19]!==T?.recommended||t[20]!==N||t[21]!==D||t[22]!==c||t[23]!==_.pairBaseUrlHint||t[24]!==_.pairBaseUrlLabel||t[25]!==_.pairBaseUrlPlaceholder||t[26]!==_.pairBlockedLoopbackBody||t[27]!==_.pairBlockedNextSteps||t[28]!==_.pairBlockedTitle||t[29]!==_.pairCandidatesTitle||t[30]!==_.pairEnableLanButton||t[31]!==_.pairEnableLanEnabling||t[32]!==_.pairEnableLanSecurityAuditLink||t[33]!==_.pairInvalidBaseUrl||t[34]!==_.pairLocalhostWarning||t[35]!==_.pairSelectCandidateHint||t[36]!==_.pairSelectCandidateTitle||t[37]!==_.pairSubtitle||t[38]!==_.pairSuggestedLanLabel||t[39]!==_.pairTitle||t[40]!==_.pairTunnelActive||t[41]!==_.pairTunnelLanUrl||t[42]!==_.pairTunnelPublicUrl||t[43]!==_.pairUseSuggestedUrl||t[44]!==_.pairWaitingForTunnel||t[45]!==_.refreshQr||t[46]!==S||t[47]!==w||t[48]!==C?.publicUrl){G=Symbol.for(`react.early_return_sentinel`);bb0:{let e=T?.candidates.filter(ze)??[],n=l?(e.find(Re)?.url??e[0]?.url??``).trim():T?.recommended.url?.trim()??``,i=(l||!S)&&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:d(`text-xs font-medium`,r),children:i?_.pairSelectCandidateTitle:_.pairCandidatesTitle}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,className:d(`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`,E.trim()===e.url&&`border-accent bg-accent/5`,n),onClick:()=>k(e.url),children:[e.label?`${e.label}: `:``,e.url]})},e.url))}),i?(0,$.jsx)(`p`,{className:d(`mt-1 text-[11px] leading-relaxed`,r),children:_.pairSelectCandidateHint}):null]})};if(V=c&&!l,V&&!S){let e;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(re,{className:`size-4 text-accent`,strokeWidth:1.75}),t[54]=e):e=t[54];let n;t[55]===_.pairTitle?n=t[56]:(n=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[e,_.pairTitle]}),t[55]=_.pairTitle,t[56]=n);let r;t[57]===_.pairWaitingForTunnel?r=t[58]:(r=(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:_.pairWaitingForTunnel}),t[57]=_.pairWaitingForTunnel,t[58]=r);let i;t[59]!==n||t[60]!==r?(i=(0,$.jsxs)(De,{children:[n,r]}),t[59]=n,t[60]=r,t[61]=i):i=t[61],G=i;break bb0}let p=v?.pairTitle??_.pairTitle,m=l?v?.pairSubtitle??_.pairSubtitle:S?_.pairTunnelActive:_.pairSubtitle,h=!!(s&&(l||c&&S)),g=V?`mb-2`:`mb-3`,y;t[62]===g?y=t[63]:(y=d(`flex flex-wrap items-start justify-between gap-2`,g),t[62]=g,t[63]=y);let b;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(re,{className:`size-4 text-accent`,strokeWidth:1.75}),t[64]=b):b=t[64];let x;t[65]===p?x=t[66]:(x=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[b,p]}),t[65]=p,t[66]=x);let A;t[67]!==V||t[68]!==m||t[69]!==_.pairSubtitle?(A=V?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:_.pairSubtitle}):(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:m}),t[67]=V,t[68]=m,t[69]=_.pairSubtitle,t[70]=A):A=t[70];let P;t[71]!==x||t[72]!==A?(P=(0,$.jsxs)(`div`,{children:[x,A]}),t[71]=x,t[72]=A,t[73]=P):P=t[73];let F;t[74]!==s||t[75]!==h||t[76]!==_.refreshQr?(F=h?(0,$.jsxs)(f,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>void s(),children:[(0,$.jsx)(pe,{className:`size-4`}),_.refreshQr]}):null,t[74]=s,t[75]=h,t[76]=_.refreshQr,t[77]=F):F=t[77],t[78]!==y||t[79]!==P||t[80]!==F?(U=(0,$.jsxs)(`div`,{className:y,children:[P,F]}),t[78]=y,t[79]=P,t[80]=F,t[81]=U):U=t[81],W=N?(0,$.jsxs)(`div`,{className:`mb-3 space-y-3 rounded-lg border border-amber-200 bg-amber-50 p-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:_.pairBlockedTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-amber-900 dark:text-amber-200`,children:_.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:_.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)(f,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,onClick:O,children:_.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)(f,{type:`button`,className:`w-full sm:w-auto`,disabled:B.busy||!r,onClick:()=>B.setConfirmOpen(!0),children:[B.busy?(0,$.jsx)(u,{className:`size-3.5 animate-spin`}):null,B.busy?_.pairEnableLanEnabling:_.pairEnableLanButton]})}),B.error?(0,$.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:B.error}):null,(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-amber-900 dark:text-amber-200`,children:l?v?.pairBlockedNextSteps??_.pairBlockedNextSteps:_.pairBlockedNextSteps}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(a,{to:`/settings/gateway`,className:`inline-block text-xs font-medium text-accent hover:underline`,children:_.pairEnableLanSecurityAuditLink}),l&&v?.pairPublicTabLink?(0,$.jsx)(a,{to:`/settings/remote-access?tab=public`,className:`inline-block text-xs font-medium text-accent hover:underline`,children:v.pairPublicTabLink}):null]})]}):null,ee=S&&!l?V?null:(0,$.jsxs)(`div`,{className:`mb-3 space-y-2 rounded-lg bg-surface-panel/80 p-3 shadow-surface`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:_.pairTunnelPublicUrl}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-fg`,children:C?.publicUrl})]}),w?.lanUrl?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:_.pairTunnelLanUrl}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-fg`,children:w.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:_.pairBaseUrlLabel}),(0,$.jsx)(je,{id:`tunnel-mobile-pair-base`,className:d(Ie(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:n||_.pairBaseUrlPlaceholder,value:E,onChange:e=>D(e.target.value),suggestion:n||null,onAcceptSuggestion:D}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:_.pairBaseUrlHint}),!j&&E.trim()?(0,$.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:_.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:_.pairLocalhostWarning}):null,i?o(`neutral`):null]})}t[8]=k,t[9]=O,t[10]=j,t[11]=B,t[12]=r,t[13]=v,t[14]=l,t[15]=M,t[16]=s,t[17]=E,t[18]=T?.candidates,t[19]=T?.recommended,t[20]=N,t[21]=D,t[22]=c,t[23]=_.pairBaseUrlHint,t[24]=_.pairBaseUrlLabel,t[25]=_.pairBaseUrlPlaceholder,t[26]=_.pairBlockedLoopbackBody,t[27]=_.pairBlockedNextSteps,t[28]=_.pairBlockedTitle,t[29]=_.pairCandidatesTitle,t[30]=_.pairEnableLanButton,t[31]=_.pairEnableLanEnabling,t[32]=_.pairEnableLanSecurityAuditLink,t[33]=_.pairInvalidBaseUrl,t[34]=_.pairLocalhostWarning,t[35]=_.pairSelectCandidateHint,t[36]=_.pairSelectCandidateTitle,t[37]=_.pairSubtitle,t[38]=_.pairSuggestedLanLabel,t[39]=_.pairTitle,t[40]=_.pairTunnelActive,t[41]=_.pairTunnelLanUrl,t[42]=_.pairTunnelPublicUrl,t[43]=_.pairUseSuggestedUrl,t[44]=_.pairWaitingForTunnel,t[45]=_.refreshQr,t[46]=S,t[47]=w,t[48]=C?.publicUrl,t[49]=V,t[50]=U,t[51]=W,t[52]=ee,t[53]=G}else V=t[49],U=t[50],W=t[51],ee=t[52],G=t[53];if(G!==Symbol.for(`react.early_return_sentinel`))return G;let te;t[82]===_.pairSecurityNote?te=t[83]:(te=(0,$.jsx)(`p`,{className:`mb-3 text-xs text-fg-subtle`,children:_.pairSecurityNote}),t[82]=_.pairSecurityNote,t[83]=te);let K;t[84]!==x||t[85]!==P||t[86]!==R||t[87]!==N||t[88]!==I||t[89]!==L||t[90]!==_.pairEncoding||t[91]!==_.pairImageError||t[92]!==_.pairQrDisabled?(K=P?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 sm:items-start`,children:[I&&!L?(0,$.jsx)(`img`,{src:I,alt:``,className:`size-56 rounded-lg border border-edge-subtle bg-white object-contain p-3 dark:border-edge`}):null,R?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:_.pairEncoding}):null,L?(0,$.jsx)(`p`,{className:`text-center text-sm text-fg-muted sm:text-left`,children:_.pairImageError}):null,(0,$.jsx)(H,{text:P,labels:x})]}):N?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:_.pairQrDisabled}):null,t[84]=x,t[85]=P,t[86]=R,t[87]=N,t[88]=I,t[89]=L,t[90]=_.pairEncoding,t[91]=_.pairImageError,t[92]=_.pairQrDisabled,t[93]=K):K=t[93];let q;t[94]!==V||t[95]!==F||t[96]!==_.deeplinkTitle?(q=F&&!V?(0,$.jsxs)(`details`,{className:`mt-3 rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-muted`,children:_.deeplinkTitle}),(0,$.jsx)(`p`,{className:`mt-2 break-all font-mono text-[10px] leading-relaxed text-fg-subtle`,children:F})]}):null,t[94]=V,t[95]=F,t[96]=_.deeplinkTitle,t[97]=q):q=t[97];let J;t[98]!==V||t[99]!==_.pairMobileProbeHint||t[100]!==_.pairSchemeHint?(J=V?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`mt-3 break-all font-mono text-[10px] leading-relaxed text-fg-subtle`,children:_.pairSchemeHint}),(0,$.jsx)(`p`,{className:`mt-1 text-[10px] leading-relaxed text-fg-subtle`,children:_.pairMobileProbeHint})]}),t[98]=V,t[99]=_.pairMobileProbeHint,t[100]=_.pairSchemeHint,t[101]=J):J=t[101];let Y,ie;t[102]===B?(Y=t[103],ie=t[104]):(Y=()=>void B.runEnableLanPairing(),ie=()=>{B.busy||B.setConfirmOpen(!1)},t[102]=B,t[103]=Y,t[104]=ie);let ae;t[105]!==B.confirmOpen||t[106]!==_.consentCancel||t[107]!==_.pairEnableLanButton||t[108]!==_.pairEnableLanConfirmBody||t[109]!==_.pairEnableLanConfirmTitle||t[110]!==Y||t[111]!==ie?(ae=(0,$.jsx)(ne,{open:B.confirmOpen,title:_.pairEnableLanConfirmTitle,description:_.pairEnableLanConfirmBody,confirmLabel:_.pairEnableLanButton,cancelLabel:_.consentCancel,onConfirm:Y,onCancel:ie}),t[105]=B.confirmOpen,t[106]=_.consentCancel,t[107]=_.pairEnableLanButton,t[108]=_.pairEnableLanConfirmBody,t[109]=_.pairEnableLanConfirmTitle,t[110]=Y,t[111]=ie,t[112]=ae):ae=t[112];let X;return t[113]!==te||t[114]!==K||t[115]!==q||t[116]!==J||t[117]!==ae||t[118]!==U||t[119]!==W||t[120]!==ee?(X=(0,$.jsx)(De,{children:(0,$.jsxs)($.Fragment,{children:[U,W,ee,te,K,q,J,ae]})}),t[113]=te,t[114]=K,t[115]=q,t[116]=J,t[117]=ae,t[118]=U,t[119]=W,t[120]=ee,t[121]=X):X=t[121],X}function Re(e){return e.reachable}function ze(e){return e.kind===`lan`}function Be(e){return e.language}function Ve(e){let t=(0,Z.c)(40),{open:n,title:r,intro:i,bullets:a,checkboxLabel:o,confirmLabel:s,cancelLabel:c,onConfirm:l,onCancel:u}=e,[p,m]=(0,Q.useState)(!1),h;t[0]===u?h=t[1]:(h=e=>{e||(m(!1),u())},t[0]=u,t[1]=h);let g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(T,{className:d(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,w)}),t[2]=g):g=t[2];let _;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(_=d(`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`,C),t[3]=_):_=t[3];let v;t[4]===r?v=t[5]:(v=(0,$.jsx)(k,{className:`text-base font-semibold text-fg`,children:r}),t[4]=r,t[5]=v);let y;t[6]===i?y=t[7]:(y=(0,$.jsx)(E,{className:`mt-2 text-sm text-fg-muted`,children:i}),t[6]=i,t[7]=y);let b;t[8]===a?b=t[9]:(b=a.map(He),t[8]=a,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=>m(e.target.checked),t[12]=S):S=t[12];let j;t[13]===p?j=t[14]:(j=(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 shrink-0 rounded border-edge accent-accent`,checked:p,onChange:S}),t[13]=p,t[14]=j);let M;t[15]===o?M=t[16]:(M=(0,$.jsx)(`span`,{children:o}),t[15]=o,t[16]=M);let N;t[17]!==M||t[18]!==j?(N=(0,$.jsxs)(`label`,{className:`mt-5 flex cursor-pointer items-start gap-3 text-sm text-fg`,children:[j,M]}),t[17]=M,t[18]=j,t[19]=N):N=t[19];let P;t[20]!==c||t[21]!==u?(P=(0,$.jsx)(f,{type:`button`,variant:`secondary`,onClick:u,children:c}),t[20]=c,t[21]=u,t[22]=P):P=t[22];let F=!p,I;t[23]!==s||t[24]!==l||t[25]!==F?(I=(0,$.jsx)(f,{type:`button`,disabled:F,onClick:l,children:s}),t[23]=s,t[24]=l,t[25]=F,t[26]=I):I=t[26];let L;t[27]!==P||t[28]!==I?(L=(0,$.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[P,I]}),t[27]=P,t[28]=I,t[29]=L):L=t[29];let R;t[30]!==N||t[31]!==L||t[32]!==v||t[33]!==y||t[34]!==x?(R=(0,$.jsxs)(D,{children:[g,(0,$.jsxs)(O,{className:_,onOpenAutoFocus:Ue,children:[v,y,x,N,L]})]}),t[30]=N,t[31]=L,t[32]=v,t[33]=y,t[34]=x,t[35]=R):R=t[35];let z;return t[36]!==n||t[37]!==h||t[38]!==R?(z=(0,$.jsx)(A,{open:n,onOpenChange:h,children:R}),t[36]=n,t[37]=h,t[38]=R,t[39]=z):z=t[39],z}function He(e){return(0,$.jsx)(`li`,{children:e},e)}function Ue(e){return e.preventDefault()}function We(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var Ge=[`preparing_frpc`,`registering`,`starting_frpc`];function Ke(e){return e?e===`reconnecting_frpc`?Ge.indexOf(`starting_frpc`):Ge.indexOf(e):-1}function qe(e,t){if(t.state===`connected`)return`done`;let n=t.startProgress?.phase,r=Ge.indexOf(e),i=Ke(n);return i<0?t.state===`connecting`||t.state===`reconnecting`?`active`:`pending`:r<i?`done`:r===i?`active`:`pending`}function Je(e,t,n){let r=n.startProgress;return qe(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 Ye(e,t){switch(t){case`preparing_frpc`:return e.stepPrepareFrpc;case`registering`:return e.stepRegister;case`starting_frpc`:return e.stepFrpcLogin}}function Xe(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 Ze(e){let t=(0,Z.c)(31),{status:n,t:r}=e,[,i]=(0,Q.useState)(0),a;t[0]!==i||t[1]!==n.state?(a=()=>{if(n.state!==`connecting`&&n.state!==`reconnecting`)return;let e=window.setInterval(()=>i(Qe),1e3);return()=>window.clearInterval(e)},t[0]=i,t[1]=n.state,t[2]=a):a=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)(a,c),!(n.state===`connecting`||n.state===`reconnecting`||n.state===`connected`&&n.startProgress))return null;let l,f,p,m,h;if(t[6]!==n||t[7]!==r){let e=Xe(n.startProgress?.startedAt);l=!!n.publicUrl&&n.state!==`connected`&&n.startProgress?.phase!==`registering`,f=`mt-3 space-y-3 rounded-lg bg-surface-panel/80 p-3 shadow-surface`;let i;t[13]===r.startProgressTitle?i=t[14]:(i=(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:r.startProgressTitle}),t[13]=r.startProgressTitle,t[14]=i);let a;t[15]===r.startProgressHint?a=t[16]:(a=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.startProgressHint}),t[15]=r.startProgressHint,t[16]=a),t[17]!==i||t[18]!==a?(p=(0,$.jsxs)(`div`,{children:[i,a]}),t[17]=i,t[18]=a,t[19]=p):p=t[19];let s=Ge.map(e=>{let t=qe(e,n),i=Je(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)(o,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`}):t===`active`?(0,$.jsx)(u,{className:`size-3.5 animate-spin text-accent`}):(0,$.jsx)(ve,{className:`size-3.5`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:d(`font-medium`,t===`active`?`text-fg`:t===`done`?`text-fg-muted`:`text-fg-subtle`),children:Ye(r,e)}),i?(0,$.jsx)(`div`,{className:`mt-0.5 text-fg-muted`,children:i}):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:d(`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:[We(n.frpcDownload.bytesReceived),` /`,` `,We(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?m=t[21]:(m=(0,$.jsx)(`ol`,{className:`space-y-2`,children:s}),t[20]=s,t[21]=m),h=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]=f,t[10]=p,t[11]=m,t[12]=h}else l=t[8],f=t[9],p=t[10],m=t[11],h=t[12];let g;t[22]!==l||t[23]!==r.publicUrlPendingNotice?(g=l?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.publicUrlPendingNotice}):null,t[22]=l,t[23]=r.publicUrlPendingNotice,t[24]=g):g=t[24];let _;return t[25]!==f||t[26]!==p||t[27]!==m||t[28]!==h||t[29]!==g?(_=(0,$.jsxs)(`div`,{className:f,children:[p,m,h,g]}),t[25]=f,t[26]=p,t[27]=m,t[28]=h,t[29]=g,t[30]=_):_=t[30],_}function Qe(e){return e+1}function $e(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 et(e){return e.state===`connected`?`connected`:e.state===`error`?`error`:e.state===`connecting`||e.state===`reconnecting`||e.startProgress||e.frpcDownload?`progress`:`off`}function tt(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 nt(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 rt(e){let t=(0,Z.c)(61),{t:n,status:r,isLoading:i,statusErr:a,starting:o,stopping:s,showConsentExpired:c,copyLabels:p,startDisabled:m,startDisabledReason:h,stepLabel:g,onStart:_,onStop:v}=e,y=m===void 0?!1:m,b,x,S,C,w,T,E;t[0]!==r||t[1]!==o?(E=et(r),b=r.enabled||o,x=o||r.state===`connecting`||r.state===`reconnecting`||!!r.startProgress||!!r.frpcDownload,t[9]===Symbol.for(`react.memo_cache_sentinel`)?(T=d(Ee(),`space-y-4`),t[9]=T):T=t[9],w=`flex flex-wrap items-start justify-between gap-3`,C=`flex items-center gap-2`,S=d(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,tt(E)),t[0]=r,t[1]=o,t[2]=b,t[3]=x,t[4]=S,t[5]=C,t[6]=w,t[7]=T,t[8]=E):(b=t[2],x=t[3],S=t[4],C=t[5],w=t[6],T=t[7],E=t[8]);let D=E===`connected`&&`bg-emerald-500`,O=E===`progress`&&`bg-amber-500 animate-pulse`,k=E===`error`&&`bg-red-500`,A=E===`off`&&`bg-fg-subtle`,j;t[10]!==D||t[11]!==O||t[12]!==k||t[13]!==A?(j=d(`size-1.5 rounded-full`,D,O,k,A),t[10]=D,t[11]=O,t[12]=k,t[13]=A,t[14]=j):j=t[14];let M;t[15]===j?M=t[16]:(M=(0,$.jsx)(`span`,{className:j,"aria-hidden":!0}),t[15]=j,t[16]=M);let N;t[17]!==i||t[18]!==r||t[19]!==n?(N=i&&!r.enabled?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`inline-block h-3 w-16 animate-pulse rounded-full bg-surface-hover/70 motion-reduce:animate-none`}):$e(n,r),t[17]=i,t[18]=r,t[19]=n,t[20]=N):N=t[20];let P;t[21]!==M||t[22]!==N||t[23]!==S?(P=(0,$.jsxs)(`span`,{className:S,children:[M,N]}),t[21]=M,t[22]=N,t[23]=S,t[24]=P):P=t[24];let F;t[25]!==r.connectedSince||t[26]!==r.state||t[27]!==n.uptime?(F=r.connectedSince&&r.state===`connected`?(0,$.jsxs)(`span`,{className:`text-xs text-fg-subtle`,children:[n.uptime,` `,nt(r.connectedSince)]}):null,t[25]=r.connectedSince,t[26]=r.state,t[27]=n.uptime,t[28]=F):F=t[28];let I;t[29]!==P||t[30]!==F||t[31]!==C?(I=(0,$.jsxs)(`div`,{className:C,children:[P,F]}),t[29]=P,t[30]=F,t[31]=C,t[32]=I):I=t[32];let L;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(l,{className:`size-4 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[33]=L):L=t[33];let R;t[34]!==I||t[35]!==w?(R=(0,$.jsxs)(`div`,{className:w,children:[I,L]}),t[34]=I,t[35]=w,t[36]=R):R=t[36];let z;t[37]===a?z=t[38]:(z=a?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:a instanceof Error?a.message:String(a)}):null,t[37]=a,t[38]=z);let B;t[39]!==c||t[40]!==n.consentExpiredBanner?(B=c?(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]=c,t[40]=n.consentExpiredBanner,t[41]=B):B=t[41];let V;t[42]!==b||t[43]!==p||t[44]!==_||t[45]!==v||t[46]!==x||t[47]!==r||t[48]!==y||t[49]!==h||t[50]!==o||t[51]!==g||t[52]!==s||t[53]!==n?(V=b?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[r.publicUrl?(0,$.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,$.jsx)(H,{label:n.publicUrlLabel,text:r.publicUrl,labels:p})}):null,x?(0,$.jsx)(Ze,{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)(f,{type:`button`,variant:`secondary`,disabled:s,onClick:v,children:[s?(0,$.jsx)(u,{className:`size-4 animate-spin`}):null,n.stop]}):(0,$.jsxs)(f,{type:`button`,disabled:o,onClick:_,children:[o?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(Y,{className:`size-4`}),n.start]})})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[g?(0,$.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:g}):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)(ge,{className:`mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-400`}),(0,$.jsx)(`p`,{children:n.riskBannerBody})]}),y&&h?(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:h}):null,(0,$.jsxs)(f,{type:`button`,disabled:o||y,onClick:_,className:`w-full sm:w-auto`,children:[o?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(Y,{className:`size-4`}),n.start]})]}),t[42]=b,t[43]=p,t[44]=_,t[45]=v,t[46]=x,t[47]=r,t[48]=y,t[49]=h,t[50]=o,t[51]=g,t[52]=s,t[53]=n,t[54]=V):V=t[54];let U;return t[55]!==R||t[56]!==z||t[57]!==B||t[58]!==V||t[59]!==T?(U=(0,$.jsxs)(`section`,{className:T,children:[R,z,B,V]}),t[55]=R,t[56]=z,t[57]=B,t[58]=V,t[59]=T,t[60]=U):U=t[60],U}var it=`https://console.xopc.ai/access/client`,at={reconfiguring:!1};function ot(e){let t=(0,Z.c)(89),{t:n,brokerSecretReady:r,brokerSecretConfiguredInConfig:i,brokerSecretMaskedValue:a,brokerSecretDraft:s,savingBrokerSecret:l,authorizingBrokerSecret:p,brokerSecretAuthorizationUrl:m,brokerSecretNotice:h,copyFailedLabel:g,onDraftChange:_,onSave:v,onAuthorize:y,onClear:b,sectionRef:x}=e,S=(0,Q.useId)(),C=r,w=!C,[T,E]=(0,Q.useReducer)(oe,at),{reconfiguring:D}=T,O;t[0]!==i||t[1]!==s||t[2]!==D?(O=i&&!D&&!s.trim(),t[0]=i,t[1]=s,t[2]=D,t[3]=O):O=t[3];let k=O,A;t[4]!==n.copied||t[5]!==n.copyKey||t[6]!==n.hideKey||t[7]!==n.showKey?(A={show:n.showKey,hide:n.hideKey,copy:n.copyKey,copied:n.copied},t[4]=n.copied,t[5]=n.copyKey,t[6]=n.hideKey,t[7]=n.showKey,t[8]=A):A=t[8];let j=A,M;t[9]===s?M=t[10]:(M=s.trim().length>0&&!te(s.trim()),t[9]=s,t[10]=M);let N=M,P;t[11]===_?P=t[12]:(P=()=>{E({type:`patch`,patch:{reconfiguring:!1}}),_(``)},t[11]=_,t[12]=P);let F=P,I=w&&`ring-1 ring-amber-500/30`,L;t[13]===I?L=t[14]:(L=d(I),t[13]=I,t[14]=L);let R=C?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`:w?`bg-amber-500/10 text-amber-700 dark:text-amber-400`:`bg-surface-hover text-fg-muted`,B;t[15]===R?B=t[16]:(B=d(`flex size-9 shrink-0 items-center justify-center rounded-lg`,R),t[15]=R,t[16]=B);let V;t[17]===C?V=t[18]:(V=C?(0,$.jsx)(o,{className:`size-4`,strokeWidth:2,"aria-hidden":!0}):(0,$.jsx)(z,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[17]=C,t[18]=V);let H;t[19]!==B||t[20]!==V?(H=(0,$.jsx)(`span`,{className:B,children:V}),t[19]=B,t[20]=V,t[21]=H):H=t[21];let U=C?n.brokerSecretReadyTitle:n.brokerSecretStepTitle,W;t[22]===U?W=t[23]:(W=(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:U}),t[22]=U,t[23]=W);let ee=C?n.brokerSecretReadyHint:n.brokerSecretHint,G;t[24]===ee?G=t[25]:(G=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:ee}),t[24]=ee,t[25]=G);let K;t[26]!==w||t[27]!==n.brokerSecretMissingHint?(K=w?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-amber-800 dark:text-amber-200`,children:n.brokerSecretMissingHint}):null,t[26]=w,t[27]=n.brokerSecretMissingHint,t[28]=K):K=t[28];let ne;t[29]!==W||t[30]!==G||t[31]!==K?(ne=(0,$.jsxs)(`div`,{children:[W,G,K]}),t[29]=W,t[30]=G,t[31]=K,t[32]=ne):ne=t[32];let q;t[33]!==p||t[34]!==w||t[35]!==y||t[36]!==D||t[37]!==l||t[38]!==n.brokerSecretAuthorize||t[39]!==n.brokerSecretAuthorizing||t[40]!==n.brokerSecretConsoleLink?(q=w||D?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(f,{type:`button`,disabled:l||p,onClick:y,children:[p?(0,$.jsx)(u,{className:`size-4 animate-spin`}):null,p?n.brokerSecretAuthorizing:n.brokerSecretAuthorize]}),(0,$.jsxs)(`a`,{href:it,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,(0,$.jsx)(c,{className:`size-3`,"aria-hidden":!0})]})]}):null,t[33]=p,t[34]=w,t[35]=y,t[36]=D,t[37]=l,t[38]=n.brokerSecretAuthorize,t[39]=n.brokerSecretAuthorizing,t[40]=n.brokerSecretConsoleLink,t[41]=q):q=t[41];let J;t[42]!==p||t[43]!==m||t[44]!==n.brokerSecretOpenAuthorization?(J=p&&m?(0,$.jsxs)(`a`,{href:m,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline`,children:[n.brokerSecretOpenAuthorization,(0,$.jsx)(c,{className:`size-3`,"aria-hidden":!0})]}):null,t[42]=p,t[43]=m,t[44]=n.brokerSecretOpenAuthorization,t[45]=J):J=t[45];let re;t[46]!==i||t[47]!==s||t[48]!==a||t[49]!==N||t[50]!==F||t[51]!==g||t[52]!==S||t[53]!==w||t[54]!==b||t[55]!==_||t[56]!==v||t[57]!==D||t[58]!==l||t[59]!==j||t[60]!==k||t[61]!==n.brokerSecretCancelReconfigure||t[62]!==n.brokerSecretClear||t[63]!==n.brokerSecretMaskedHelp||t[64]!==n.brokerSecretNotInConfigFile||t[65]!==n.brokerSecretPlaceholder||t[66]!==n.brokerSecretReconfigure||t[67]!==n.brokerSecretRevealFailed||t[68]!==n.brokerSecretSave||t[69]!==n.brokerSecretSaveAndContinue||t[70]!==n.brokerSecretTitle?(re=k?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:S,children:n.brokerSecretTitle}),(0,$.jsx)(me,{id:S,value:a,labels:j,reveal:st,loadFailedLabel:g||n.brokerSecretRevealFailed,maskedHelp:n.brokerSecretMaskedHelp,notInConfigFile:n.brokerSecretNotInConfigFile,readOnly:!0}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(f,{type:`button`,variant:`secondary`,disabled:l,onClick:()=>{E({type:`patch`,patch:{reconfiguring:!0}})},children:n.brokerSecretReconfigure}),(0,$.jsx)(f,{type:`button`,variant:`ghost`,disabled:l,onClick:b,children:n.brokerSecretClear})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:S,children:n.brokerSecretTitle}),(0,$.jsx)(me,{id:S,value:s,onChange:_,placeholder:n.brokerSecretPlaceholder,labels:j,disabled:l}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(f,{type:`button`,disabled:l||!N,onClick:v,children:[l?(0,$.jsx)(u,{className:`size-4 animate-spin`}):null,w?n.brokerSecretSaveAndContinue:n.brokerSecretSave]}),i?(0,$.jsx)(f,{type:`button`,variant:`ghost`,disabled:l,onClick:b,children:n.brokerSecretClear}):null,D?(0,$.jsx)(f,{type:`button`,variant:`ghost`,disabled:l,onClick:F,children:n.brokerSecretCancelReconfigure}):null]})]}),t[46]=i,t[47]=s,t[48]=a,t[49]=N,t[50]=F,t[51]=g,t[52]=S,t[53]=w,t[54]=b,t[55]=_,t[56]=v,t[57]=D,t[58]=l,t[59]=j,t[60]=k,t[61]=n.brokerSecretCancelReconfigure,t[62]=n.brokerSecretClear,t[63]=n.brokerSecretMaskedHelp,t[64]=n.brokerSecretNotInConfigFile,t[65]=n.brokerSecretPlaceholder,t[66]=n.brokerSecretReconfigure,t[67]=n.brokerSecretRevealFailed,t[68]=n.brokerSecretSave,t[69]=n.brokerSecretSaveAndContinue,t[70]=n.brokerSecretTitle,t[71]=re):re=t[71];let Y;t[72]===h?Y=t[73]:(Y=h?(0,$.jsx)(`p`,{className:`text-xs text-emerald-700 dark:text-emerald-400`,children:h}):null,t[72]=h,t[73]=Y);let ie;t[74]!==ne||t[75]!==q||t[76]!==J||t[77]!==re||t[78]!==Y?(ie=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[ne,q,J,re,Y]}),t[74]=ne,t[75]=q,t[76]=J,t[77]=re,t[78]=Y,t[79]=ie):ie=t[79];let ae;t[80]!==H||t[81]!==ie?(ae=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[H,ie]}),t[80]=H,t[81]=ie,t[82]=ae):ae=t[82];let X;t[83]!==ae||t[84]!==L?(X=(0,$.jsx)(De,{className:L,children:ae}),t[83]=ae,t[84]=L,t[85]=X):X=t[85];let se;return t[86]!==x||t[87]!==X?(se=(0,$.jsx)(`div`,{ref:x,id:`tunnel-broker-secret-setup`,children:X}),t[86]=x,t[87]=X,t[88]=se):se=t[88],se}function st(){return U().then(ct)}function ct(e){return e.registrationSecret??null}function lt(e){let t=(0,Z.c)(10),{language:n,label:r,section:i,className:a}=e,o;t[0]!==n||t[1]!==i?(o=le(n,i),t[0]=n,t[1]=i,t[2]=o):o=t[2];let s;t[3]===a?s=t[4]:(s=d(`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`,a),t[3]=a,t[4]=s);let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(c,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[5]=l):l=t[5];let u;return t[6]!==r||t[7]!==o||t[8]!==s?(u=(0,$.jsxs)(`a`,{href:o,target:`_blank`,rel:`noreferrer`,className:s,children:[r,l]}),t[6]=r,t[7]=o,t[8]=s,t[9]=u):u=t[9],u}var ut=e(Me(),1),dt={width:216,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}};async function ft(e){return ut.toDataURL(e,dt)}function pt(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 mt(e,t){let n=t.trim();return!n||!e?!1:e.candidates.some(e=>e.kind===`tunnel`&&e.url.trim()===n)}function ht(e,t){return e?t?pt(e)||e.recommended.url?.trim()||``:e.recommended.url?.trim()||``:``}function gt(e,t){let n=t?.preferLan===!0,r=!!e,{mutate:i}=j(),a=(0,Q.useRef)(!1),{data:o}=M(r?`tunnel-status`:null,G,{refreshInterval:6e4}),{data:s,mutate:c}=M(r?`tunnel-pair-context`:null,de,{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 l=o?.state===`connected`&&!!o.publicUrl?.trim(),u=l&&!n,{data:d,mutate:f}=M(u&&r?`tunnel-qr`:null,ee,{refreshInterval:4*6e4}),{data:p,mutate:m}=M(!u&&r&&s?.pairingReady?`tunnel-pair`:null,fe,{refreshInterval:4*6e4}),[h,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(``),[x,S]=(0,Q.useState)({pairContext:void 0,preferLan:n});if(!a.current&&(s!==x.pairContext||n!==x.preferLan)){S({pairContext:s,preferLan:n});let e=ht(s,n);h!==e&&v(e)}let C=(0,Q.useCallback)(e=>{a.current=!0,v(e)},[]),w=(0,Q.useCallback)(()=>{let e=ht(s,n);e&&(a.current=!0,v(e))},[s,n]),T=(0,Q.useCallback)(e=>{let t=e.trim();t&&(a.current=!0,v(t))},[]),E=(0,Q.useCallback)(e=>{a.current=!1,v(e?.trim()||ht(s,n))},[s,n]),D=h.trim(),O=(0,Q.useMemo)(()=>{try{let e=new URL(D);return e.protocol===`http:`||e.protocol===`https:`}catch{return!1}},[D]),k=O&&g(D),A=!u&&!!(s&&!s.pairingReady&&s.blockReason===`GATEWAY_LOOPBACK_ONLY`),N=!u&&O&&!k&&!!p?.pairingSecret&&(s?.pairingReady===!0||!A),P=(0,Q.useMemo)(()=>{let e=pt(s);return n?e||(D&&!mt(s,D)?D:``):D},[s,n,D]),F=(0,Q.useMemo)(()=>{if(!e)return``;if(y.trim())return y.trim();if(u&&d?.qrPayload?.trim())return d.qrPayload.trim();if(!N||!p?.pairingSecret)return``;let t=s?.candidates.find(e=>e.kind===`tunnel`&&e.reachable),r=s?.candidates.find(e=>e.kind===`lan`&&e.reachable),i=n?P:t?.url??D;return i?_({baseUrl:i,pairingSecret:p.pairingSecret,lanUrl:n?null:t&&r?r.url:null}):``},[e,P,p?.pairingSecret,N,y,n,D,u,d?.qrPayload,s?.candidates]),I=he(()=>ft(F),[F],{enabled:!!F,initial:null,errorData:null}),L=F?I.data:null,R=!!(F&&I.error!==null&&!I.loading);return{tunnelActive:l,tunnelStatus:o,tunnelQr:d,pairContext:s,pairBaseUrl:h,setPairBaseUrl:C,applySuggestedPairUrl:w,applyCandidateUrl:T,baseOk:O,localhostWarn:k,pairingBlocked:A,deepLink:F,qrPayload:F,qrDataUrl:L,qrGenFailed:R,encoding:!!(F&&!L&&!R),refreshQr:(0,Q.useCallback)(async e=>{if(e?.trim()){b(e.trim()),f({qrPayload:e.trim(),publicUrl:o?.publicUrl??``,lanUrl:d?.lanUrl??null},!1);return}b(``),await c(),u?await f():s?.pairingReady&&await m()},[m,c,f,s?.pairingReady,d?.lanUrl,o?.publicUrl,u]),resetPairBaseFromContext:E}}var _t={actionError:null,starting:!1,stopping:!1,savingAutoStart:!1,consentOpen:!1,autoStartConfirmOpen:!1,releaseConfirmOpen:!1,releasing:!1,brokerSecretDraft:``,savingBrokerSecret:!1,authorizingBrokerSecret:!1,brokerSecretAuthorizationUrl:null,brokerSecretNotice:null};function vt({embedded:e=!1}){let t=y(e=>e.language),n=h(t).tunnelSettings,r=v(e=>e.token),i=!!r,[a,o]=(0,Q.useReducer)(oe,_t),{actionError:s,starting:c,stopping:p,savingAutoStart:m,consentOpen:g,autoStartConfirmOpen:_,releaseConfirmOpen:b,releasing:x,brokerSecretDraft:S,savingBrokerSecret:C,authorizingBrokerSecret:w,brokerSecretAuthorizationUrl:T,brokerSecretNotice:E}=a,D=(0,Q.useRef)(null),O=gt(r??``),{data:k}=P(i),{data:A,error:j,isLoading:F,mutate:I}=M(i?`tunnel-status`:null,G,{refreshInterval:e=>c?1e3:e?.frpcDownload||e?.state===`connecting`||e?.state===`reconnecting`?2e3:6e4}),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)&&t.autoStart===!0)return!0}return A?.config?.autoStart===!0},[k,A?.config?.autoStart]),z=(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]),V=te(z),H=A?.registrationSecret?.configured??V;(0,Q.useEffect)(()=>{let e=()=>{I()};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[I]);let U=(0,Q.useMemo)(()=>[n.consentBullet1,n.consentBullet2,n.consentBullet3],[n.consentBullet1,n.consentBullet2,n.consentBullet3]),W=(0,Q.useCallback)(async()=>{o({type:`patch`,patch:{actionError:null}}),o({type:`patch`,patch:{starting:!0}});try{let e=await ie();await I(),N(),await O.refreshQr(e.qrPayload)}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{o({type:`patch`,patch:{starting:!1}})}},[I,O.refreshQr]),ee=(0,Q.useCallback)(()=>{if(!H){o({type:`patch`,patch:{actionError:n.brokerSecretRequiredBeforeStart}}),D.current?.scrollIntoView({behavior:`smooth`,block:`start`});return}if(A?.consentRequired){o({type:`patch`,patch:{consentOpen:!0}});return}W()},[H,A?.consentRequired,W,n.brokerSecretRequiredBeforeStart]),K=(0,Q.useCallback)(async()=>{o({type:`patch`,patch:{consentOpen:!1}}),o({type:`patch`,patch:{actionError:null}});try{await B(),await Promise.all([I(),W()])}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}},[I,W]),q=(0,Q.useCallback)(async()=>{o({type:`patch`,patch:{actionError:null}}),o({type:`patch`,patch:{stopping:!0}});try{await be(),await Promise.all([O.refreshQr(),I()]),N()}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{o({type:`patch`,patch:{stopping:!1}})}},[I,O.refreshQr]),re=(0,Q.useCallback)(async e=>{o({type:`patch`,patch:{savingAutoStart:!0}}),o({type:`patch`,patch:{actionError:null}});try{await J({autoStart:e}),N()}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{o({type:`patch`,patch:{savingAutoStart:!1}})}},[]),Y=(0,Q.useCallback)(()=>{if(L){re(!1);return}if(A?.consentRequired){o({type:`patch`,patch:{actionError:n.consentExpiredBanner}});return}if(!A?.canAutoStart){o({type:`patch`,patch:{actionError:n.autoStartHint}});return}o({type:`patch`,patch:{autoStartConfirmOpen:!0}})},[re,A?.canAutoStart,A?.consentRequired,n,L]),X=(0,Q.useCallback)(async()=>{let e=S.trim();if(e){o({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await J({registrationSecret:e}),o({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretSaved}}),N(),await I(),o({type:`patch`,patch:{actionError:null}})}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{o({type:`patch`,patch:{savingBrokerSecret:!1}})}}},[S,I,n.brokerSecretSaved]),se=(0,Q.useCallback)(async()=>{o({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await J({registrationSecret:null}),o({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretCleared}}),N(),await Promise.all([O.refreshQr(),I()])}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{o({type:`patch`,patch:{savingBrokerSecret:!1}})}},[I,O.refreshQr,n.brokerSecretCleared]),ce=(0,Q.useCallback)(async()=>{let e=ke(),t=null,r=null;o({type:`patch`,patch:{authorizingBrokerSecret:!0,brokerSecretAuthorizationUrl:null,brokerSecretNotice:null,actionError:null}});try{for(t=(await _e(`xopc-tunnel`)).sessionId;;){await new Promise(e=>window.setTimeout(e,1e3));let i=await ae(t);if(i.authUrl&&i.authUrl!==r&&(r=i.authUrl,o({type:`patch`,patch:{brokerSecretAuthorizationUrl:i.authUrl}}),await Oe(i.authUrl,e)),i.status===`failed`||i.status===`cancelled`)throw Error(i.error??i.message??`OAuth authorization failed`);if(i.status===`completed`){await R(),await Promise.all([I(),N()]),o({type:`patch`,patch:{brokerSecretNotice:n.brokerSecretSaved,brokerSecretDraft:``}});return}}}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{Ae(e),t&&ye(t).catch(()=>void 0),o({type:`patch`,patch:{authorizingBrokerSecret:!1,brokerSecretAuthorizationUrl:null}})}},[I,n.brokerSecretSaved]),le=(0,Q.useCallback)(async()=>{o({type:`patch`,patch:{releaseConfirmOpen:!1,actionError:null,releasing:!0}});try{await be({release:!0}),await Promise.all([O.refreshQr(),I()]),N()}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{o({type:`patch`,patch:{releasing:!1}})}},[I,O.refreshQr]),ue=(0,Q.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:h(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]);if(!i)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 de=A??{enabled:!1,state:`disconnected`,subdomain:null,publicUrl:null,connectedSince:null,frpcPid:null,lastHeartbeatAt:null,lastError:null,consentRequired:!0,config:{autoStart:L,brokerUrl:`https://frp.xopc.ai/api`}},fe=A?.consentRequired&&(de.enabled||L||A?.consent?.acceptedAt),pe=(0,$.jsx)(ot,{t:n,brokerSecretReady:H,brokerSecretConfiguredInConfig:V,brokerSecretMaskedValue:V?z:``,brokerSecretDraft:S,savingBrokerSecret:C,authorizingBrokerSecret:w,brokerSecretAuthorizationUrl:T,brokerSecretNotice:E,copyFailedLabel:h(t).clipboard.copyFailed,onDraftChange:e=>o({type:`patch`,patch:{brokerSecretDraft:e}}),onSave:()=>void X(),onAuthorize:()=>void ce(),onClear:()=>void se(),sectionRef:D}),me=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ve,{open:g,title:n.consentTitle,intro:n.consentIntro,bullets:U,checkboxLabel:n.consentCheckbox,confirmLabel:fe?n.consentReconfirm:n.consentConfirm,cancelLabel:n.consentCancel,onConfirm:()=>void K(),onCancel:()=>o({type:`patch`,patch:{consentOpen:!1}})},g?`consent-open`:`consent-closed`),(0,$.jsx)(ne,{open:_,title:n.autoStartConfirmTitle,description:n.autoStartConfirmBody,confirmLabel:n.autoStartConfirmLabel,cancelLabel:n.consentCancel,onConfirm:()=>{o({type:`patch`,patch:{autoStartConfirmOpen:!1}}),re(!0)},onCancel:()=>o({type:`patch`,patch:{autoStartConfirmOpen:!1}})}),(0,$.jsx)(ne,{open:b,title:n.releaseConfirmTitle,description:n.releaseConfirmBody,confirmLabel:n.releaseConfirmLabel,cancelLabel:n.consentCancel,destructive:!0,onConfirm:()=>void le(),onCancel:()=>o({type:`patch`,patch:{releaseConfirmOpen:!1}})})]});return e?(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[s?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:s}):null,pe,(0,$.jsx)(rt,{t:n,status:de,isLoading:F,statusErr:j,starting:c,stopping:p,showConsentExpired:!!fe,copyLabels:ue,startDisabled:!H,startDisabledReason:H?void 0:n.brokerSecretRequiredBeforeStart,stepLabel:n.flowStepStart,onStart:ee,onStop:()=>void q()}),(0,$.jsx)(Le,{pairQr:O,gatewayToken:r??``,streamlined:!0,onRefreshQr:()=>void O.refreshQr()}),(0,$.jsxs)(Pe,{showLabel:n.showOptions,hideLabel:n.hideOptions,children:[(0,$.jsxs)(`label`,{className:d(`flex items-center gap-3 text-sm text-fg`,!L&&!A?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:L,disabled:m||!L&&!A?.canAutoStart,onChange:Y}),n.autoStart]}),!A?.canAutoStart&&!L?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.autoStartHint}):null,de.subdomain||de.publicUrl?(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-edge-subtle pt-4`,children:[(0,$.jsxs)(f,{type:`button`,variant:`secondary`,disabled:x||p,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>o({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[x?(0,$.jsx)(u,{className:`size-4 animate-spin`}):null,n.release]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint})]}):null]}),(0,$.jsx)(Pe,{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)(l,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(lt,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]})}),me]}):(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})]}),s?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:s}):null,pe,(0,$.jsx)(rt,{t:n,status:de,isLoading:F,statusErr:j,starting:c,stopping:p,showConsentExpired:!!fe,copyLabels:ue,startDisabled:!H,startDisabledReason:H?void 0:n.brokerSecretRequiredBeforeStart,onStart:ee,onStop:()=>void q()}),(0,$.jsx)(Le,{pairQr:O,gatewayToken:r??``}),de.subdomain||de.publicUrl?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,$.jsxs)(f,{type:`button`,variant:`secondary`,disabled:x||p,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>o({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[x?(0,$.jsx)(u,{className:`size-4 animate-spin`}):null,n.release]})}):null,de.subdomain||de.publicUrl?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint}):null,(0,$.jsxs)(De,{children:[(0,$.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-fg`,children:n.optionsTitle}),(0,$.jsxs)(`label`,{className:d(`flex items-center gap-3 text-sm text-fg`,!L&&!A?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:L,disabled:m||!L&&!A?.canAutoStart,onChange:Y}),n.autoStart]}),!A?.canAutoStart&&!L?(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 bg-surface-panel/80 px-3 py-2 text-xs text-fg-subtle shadow-surface`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(l,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(lt,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]}),me]})}async function yt(){let e=await b(`/api/exposure/status`);if(!e.ok)throw Error(`Failed to load exposure status (${e.status})`);return await e.json()}async function bt(e=`serve`){let t=await b(`/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 xt(){let e=await b(`/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 St=`https://tailscale.com/download`;function Ct(e){let t=(0,Z.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`a`,{href:St,target:`_blank`,rel:`noreferrer`,className:`font-medium text-accent hover:underline`,children:n}),t[0]=n,t[1]=r),r}function wt({embedded:e=!1}){let t=y(e=>e.language),n=h(t).remoteAccess.tailscale,r=(0,Q.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:h(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]),i=!!v(e=>e.token),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),{data:d,mutate:p,isLoading:m}=M(i?`exposure-status`:null,yt,{refreshInterval:3e4}),g=d?.tailscale.hostname,_=d?.tailscale.active===!0,b=d?.tailscale.cliAvailable!==!1,x=g?`https://${g}/`:null,S=(0,Q.useCallback)(async()=>{o(!0),c(null);try{await bt(`serve`),await p()}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}},[p]),C=(0,Q.useCallback)(async()=>{o(!0),c(null);try{await xt(),await p()}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}},[p]);if(!i)return null;let w=(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)(Ct,{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&&d?.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)(Ct,{label:n.cliMissingDownloadLink}),n.cliMissingSuffix]}):null,m&&!d?(0,$.jsxs)(`div`,{className:`grid gap-3`,"aria-busy":`true`,children:[(0,$.jsx)(ce,{className:`h-20 rounded-lg`}),(0,$.jsx)(ce,{className:`h-20 rounded-lg`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(De,{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:_?n.statusActive:n.statusOff}),x?(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(H,{text:x,labels:r})}):null,s?(0,$.jsx)(`p`,{className:`mt-2 text-sm text-red-600 dark:text-red-400`,children:s}):null,(0,$.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:_?(0,$.jsxs)(f,{type:`button`,variant:`secondary`,disabled:a,onClick:()=>void C(),children:[a?(0,$.jsx)(u,{className:`mr-1 size-4 animate-spin`}):null,n.disableServe]}):(0,$.jsxs)(f,{type:`button`,disabled:a||!b,onClick:()=>void S(),children:[a?(0,$.jsx)(u,{className:`mr-1 size-4 animate-spin`}):(0,$.jsx)(Y,{className:`mr-1 size-4`}),n.enableServe]})})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.hint}),(0,$.jsx)(lt,{language:t,label:n.docsLink,section:`tailscale-serve`,className:`mt-2`})]})]});return e?w:(0,$.jsxs)(De,{children:[(0,$.jsx)(Te,{icon:l,title:n.title,subtitle:n.subtitle}),w]})}function Tt(){let e=(0,Z.c)(26),t=y(Dt),n=v(Et),r;e[0]===t?r=e[1]:(r=h(t),e[0]=t,e[1]=r);let i=r.remoteAccess.lan,o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o={preferLan:!0},e[2]=o):o=e[2];let s=gt(n??``,o),l;e[3]!==i.subtitle||e[4]!==i.title?(l=(0,$.jsx)(Te,{icon:se,title:i.title,subtitle:i.subtitle}),e[3]=i.subtitle,e[4]=i.title,e[5]=l):l=e[5];let u;e[6]===i.body?u=e[7]:(u=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:i.body}),e[6]=i.body,e[7]=u);let d;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(c,{className:`size-3.5`,"aria-hidden":!0}),e[8]=d):d=e[8];let f;e[9]===i.link?f=e[10]:(f=(0,$.jsxs)(a,{to:`/settings/gateway`,className:`inline-flex items-center gap-1.5 text-sm font-medium text-accent hover:underline`,children:[i.link,d]}),e[9]=i.link,e[10]=f);let p;e[11]!==u||e[12]!==f?(p=(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[u,f]}),e[11]=u,e[12]=f,e[13]=p):p=e[13];let m;e[14]!==l||e[15]!==p?(m=(0,$.jsxs)(De,{children:[l,p]}),e[14]=l,e[15]=p,e[16]=m):m=e[16];let g=n??``,_;e[17]===s?_=e[18]:(_=()=>void s.refreshQr(),e[17]=s,e[18]=_);let b;e[19]!==s||e[20]!==g||e[21]!==_?(b=(0,$.jsx)(Le,{pairQr:s,gatewayToken:g,lanOnly:!0,onRefreshQr:_}),e[19]=s,e[20]=g,e[21]=_,e[22]=b):b=e[22];let x;return e[23]!==b||e[24]!==m?(x=(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[m,b]}),e[23]=b,e[24]=m,e[25]=x):x=e[25],x}function Et(e){return e.token}function Dt(e){return e.language}function Ot(e){let t=(0,Z.c)(30),{embedded:n}=e,r=n===void 0?!1:n,i=y(kt),a;t[0]===i?a=t[1]:(a=h(i),t[0]=i,t[1]=a);let o=a.remoteAccess.ssh,[c,l]=(0,Q.useState)(!1),u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=async()=>{await m(`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`)&&(l(!0),setTimeout(()=>l(!1),2e3))},t[2]=u):u=t[2];let d=u,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 g,_;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>void d(),_=(0,$.jsx)(s,{className:`mr-1 size-4`}),t[4]=g,t[5]=_):(g=t[4],_=t[5]);let v=c?o.copied:o.copy,b;t[6]===v?b=t[7]:(b=(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsxs)(f,{type:`button`,variant:`ghost`,onClick:g,children:[_,v]})}),t[6]=v,t[7]=b);let x;t[8]!==r||t[9]!==o.hint?(x=r?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:o.hint}):null,t[8]=r,t[9]=o.hint,t[10]=x):x=t[10];let S;t[11]!==b||t[12]!==x?(S=(0,$.jsxs)($.Fragment,{children:[p,b,x]}),t[11]=b,t[12]=x,t[13]=S):S=t[13];let C=S;if(r){let e;t[14]!==o.subtitle||t[15]!==o.title?(e=(0,$.jsx)(Te,{icon:X,title:o.title,subtitle:o.subtitle}),t[14]=o.subtitle,t[15]=o.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)(De,{children:[e,n]}),t[19]=e,t[20]=n,t[21]=r):r=t[21],r}let w;t[22]!==o.subtitle||t[23]!==o.title?(w=(0,$.jsx)(Te,{icon:X,title:o.title,subtitle:o.subtitle}),t[22]=o.subtitle,t[23]=o.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)(De,{children:[w,T]}),t[27]=w,t[28]=T,t[29]=E):E=t[29],E}function kt(e){return e.language}function At(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Ot,{embedded:!0}),e[0]=t):t=e[0],t}function jt(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 Mt(e){let t=(0,Z.c)(5),{label:n,kind:r}=e,i;t[0]===r?i=t[1]:(i=d(`rounded-full px-2 py-0.5 text-[11px] font-medium`,jt(r)),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,$.jsx)(`span`,{className:i,children:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}function Nt(e){let t=(0,Z.c)(32),{onOpenTab:n}=e,r=y(It),i;t[0]===r?i=t[1]:(i=h(r),t[0]=r,t[1]=i);let a=i.remoteAccess.guide,o=!!v(Ft),s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s={refreshInterval:3e4},t[2]=s):s=t[2];let{data:c}=M(o?`exposure-status`:null,yt,s),u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u={refreshInterval:15e3},t[3]=u):u=t[3];let{data:f}=M(o?`tunnel-status`:null,G,u),p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p={refreshInterval:6e4},t[4]=p):p=t[4];let{data:m}=M(o?`tunnel-pair-context`:null,de,p);if(!o)return null;let g=c?.tailscale.active===!0,_=f?.state,b=f?.enabled&&_===`connected`,x=f?.enabled&&(_===`connecting`||_===`reconnecting`||!!f?.startProgress||!!f?.frpcDownload),S=(m?.candidates??[]).some(Pt),C=g?`active`:`off`,w=g?a.statusActive:a.statusOff,T;t[5]!==a.tailscaleCardTitle||t[6]!==C||t[7]!==w?(T={tab:`tailscale`,icon:l,title:a.tailscaleCardTitle,kind:C,statusLabel:w},t[5]=a.tailscaleCardTitle,t[6]=C,t[7]=w,t[8]=T):T=t[8];let E=b?`active`:x?`connecting`:`off`,D=b?a.statusActive:x?a.statusConnecting:a.statusOff,O;t[9]!==a.publicCardTitle||t[10]!==E||t[11]!==D?(O={tab:`public`,icon:ue,title:a.publicCardTitle,kind:E,statusLabel:D},t[9]=a.publicCardTitle,t[10]=E,t[11]=D,t[12]=O):O=t[12];let k=S?`active`:`off`,A=S?a.statusActive:a.statusOff,j;t[13]!==a.reverseProxyCardTitle||t[14]!==k||t[15]!==A?(j={tab:`reverse-proxy`,icon:V,title:a.reverseProxyCardTitle,kind:k,statusLabel:A},t[13]=a.reverseProxyCardTitle,t[14]=k,t[15]=A,t[16]=j):j=t[16];let N;t[17]!==a.sshCardStatus||t[18]!==a.sshCardTitle?(N={tab:`ssh`,icon:X,title:a.sshCardTitle,kind:`off`,statusLabel:a.sshCardStatus},t[17]=a.sshCardStatus,t[18]=a.sshCardTitle,t[19]=N):N=t[19];let P;t[20]!==a.lanCardStatus||t[21]!==a.lanCardTitle?(P={tab:`lan`,icon:se,title:a.lanCardTitle,kind:`off`,statusLabel:a.lanCardStatus},t[20]=a.lanCardStatus,t[21]=a.lanCardTitle,t[22]=P):P=t[22];let F;t[23]!==O||t[24]!==j||t[25]!==N||t[26]!==P||t[27]!==T?(F=[T,O,j,N,P],t[23]=O,t[24]=j,t[25]=N,t[26]=P,t[27]=T,t[28]=F):F=t[28];let I=F,L;return t[29]!==I||t[30]!==n?(L=(0,$.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5`,children:I.map(e=>{let t=e.icon;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.tab),className:d(`flex items-start gap-3 rounded-xl bg-surface-base px-3 py-2.5 text-left shadow-surface transition-colors`,`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)(Mt,{label:e.statusLabel,kind:e.kind})]})]},`${e.tab}-${e.title}`)})}),t[29]=I,t[30]=n,t[31]=L):L=t[31],L}function Pt(e){return e.kind===`reverse-proxy`}function Ft(e){return e.token}function It(e){return e.language}function Lt(e){let t=(0,Z.c)(26),{title:n,description:r,recommended:i,icon:a,onOpen:o,openLabel:s,recommendedLabel:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=d(`group flex w-full flex-col rounded-2xl bg-surface-base p-4 text-left transition-colors`,`hover:bg-surface-hover/40`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),t[0]=l):l=t[0];let u;t[1]===a?u=t[2]:(u=(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)(a,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=a,t[2]=u);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]!==i||t[6]!==c?(p=i&&c?(0,$.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:c}):null,t[5]=i,t[6]=c,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)(W,{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]!==u||t[18]!==g?(v=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[u,g,_]}),t[17]=u,t[18]=g,t[19]=v):v=t[19];let y;t[20]===s?y=t[21]:(y=(0,$.jsx)(`span`,{className:`mt-3 text-xs font-medium text-accent`,children:s}),t[20]=s,t[21]=y);let b;return t[22]!==o||t[23]!==y||t[24]!==v?(b=(0,$.jsxs)(`button`,{type:`button`,onClick:o,className:l,children:[v,y]}),t[22]=o,t[23]=y,t[24]=v,t[25]=b):b=t[25],b}function Rt(e){let t=(0,Z.c)(83),{onOpenTab:n}=e,r=y(Vt),i;t[0]===r?i=t[1]:(i=h(r),t[0]=r,t[1]=i);let a=i.remoteAccess,o=a.guide,s=!!v(Bt),c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c={refreshInterval:3e4},t[2]=c):c=t[2];let{data:u}=M(s?`exposure-status`:null,yt,c),d;t[3]===u?.conflicts?d=t[4]:(d=u?.conflicts??[],t[3]=u?.conflicts,t[4]=d);let f=d;if(!s){let e;return t[5]===o.needToken?e=t[6]:(e=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.needToken}),t[5]=o.needToken,t[6]=e),e}let p;t[7]===n?p=t[8]:(p=(0,$.jsx)(Nt,{onOpenTab:n}),t[7]=n,t[8]=p);let m;t[9]!==f||t[10]!==o.conflictsHint||t[11]!==o.conflictsTitle?(m=f.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:o.conflictsTitle}),(0,$.jsx)(`p`,{className:`mt-1`,children:o.conflictsHint}),(0,$.jsx)(`ul`,{className:`mt-2 list-inside list-disc text-xs`,children:f.map(zt)})]}):null,t[9]=f,t[10]=o.conflictsHint,t[11]=o.conflictsTitle,t[12]=m):m=t[12];let g;t[13]===o.pickMethod?g=t[14]:(g=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:o.pickMethod}),t[13]=o.pickMethod,t[14]=g);let _;t[15]===n?_=t[16]:(_=()=>n(`tailscale`),t[15]=n,t[16]=_);let b;t[17]!==o.configure||t[18]!==o.recommended||t[19]!==o.tailscaleCardDesc||t[20]!==o.tailscaleCardTitle||t[21]!==_?(b=(0,$.jsx)(Lt,{icon:l,title:o.tailscaleCardTitle,description:o.tailscaleCardDesc,recommended:!0,recommendedLabel:o.recommended,openLabel:o.configure,onOpen:_}),t[17]=o.configure,t[18]=o.recommended,t[19]=o.tailscaleCardDesc,t[20]=o.tailscaleCardTitle,t[21]=_,t[22]=b):b=t[22];let x;t[23]===n?x=t[24]:(x=()=>n(`public`),t[23]=n,t[24]=x);let S;t[25]!==o.configure||t[26]!==o.publicCardDesc||t[27]!==o.publicCardTitle||t[28]!==x?(S=(0,$.jsx)(Lt,{icon:ue,title:o.publicCardTitle,description:o.publicCardDesc,openLabel:o.configure,onOpen:x}),t[25]=o.configure,t[26]=o.publicCardDesc,t[27]=o.publicCardTitle,t[28]=x,t[29]=S):S=t[29];let C;t[30]===n?C=t[31]:(C=()=>n(`reverse-proxy`),t[30]=n,t[31]=C);let w;t[32]!==o.configure||t[33]!==o.reverseProxyCardDesc||t[34]!==o.reverseProxyCardTitle||t[35]!==C?(w=(0,$.jsx)(Lt,{icon:V,title:o.reverseProxyCardTitle,description:o.reverseProxyCardDesc,openLabel:o.configure,onOpen:C}),t[32]=o.configure,t[33]=o.reverseProxyCardDesc,t[34]=o.reverseProxyCardTitle,t[35]=C,t[36]=w):w=t[36];let T;t[37]===n?T=t[38]:(T=()=>n(`ssh`),t[37]=n,t[38]=T);let E;t[39]!==o.configure||t[40]!==o.sshCardDesc||t[41]!==o.sshCardTitle||t[42]!==T?(E=(0,$.jsx)(Lt,{icon:X,title:o.sshCardTitle,description:o.sshCardDesc,openLabel:o.configure,onOpen:T}),t[39]=o.configure,t[40]=o.sshCardDesc,t[41]=o.sshCardTitle,t[42]=T,t[43]=E):E=t[43];let D;t[44]===n?D=t[45]:(D=()=>n(`lan`),t[44]=n,t[45]=D);let O;t[46]!==o.configure||t[47]!==o.lanCardDesc||t[48]!==o.lanCardTitle||t[49]!==D?(O=(0,$.jsx)(Lt,{icon:se,title:o.lanCardTitle,description:o.lanCardDesc,openLabel:o.configure,onOpen:D}),t[46]=o.configure,t[47]=o.lanCardDesc,t[48]=o.lanCardTitle,t[49]=D,t[50]=O):O=t[50];let k;t[51]!==S||t[52]!==w||t[53]!==E||t[54]!==O||t[55]!==b?(k=(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:[b,S,w,E,O]}),t[51]=S,t[52]=w,t[53]=E,t[54]=O,t[55]=b,t[56]=k):k=t[56];let A;t[57]!==k||t[58]!==g?(A=(0,$.jsxs)(`div`,{children:[g,k]}),t[57]=k,t[58]=g,t[59]=A):A=t[59];let j;t[60]===o.oneAtATimeHint?j=t[61]:(j=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:o.oneAtATimeHint}),t[60]=o.oneAtATimeHint,t[61]=j);let N;t[62]===a.advanced.proxyTitle?N=t[63]:(N=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.advanced.proxyTitle}),t[62]=a.advanced.proxyTitle,t[63]=N);let P;t[64]===a.advanced.proxyBody?P=t[65]:(P=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a.advanced.proxyBody}),t[64]=a.advanced.proxyBody,t[65]=P);let F;t[66]!==r||t[67]!==a.advanced.proxyDocs?(F=(0,$.jsx)(lt,{language:r,label:a.advanced.proxyDocs,section:`advanced`,className:`mt-2`}),t[66]=r,t[67]=a.advanced.proxyDocs,t[68]=F):F=t[68];let I;t[69]!==N||t[70]!==P||t[71]!==F?(I=(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base px-4 py-3`,children:[N,P,F]}),t[69]=N,t[70]=P,t[71]=F,t[72]=I):I=t[72];let L;t[73]!==o.docsLink||t[74]!==r?(L=(0,$.jsx)(lt,{language:r,label:o.docsLink}),t[73]=o.docsLink,t[74]=r,t[75]=L):L=t[75];let R;return t[76]!==A||t[77]!==j||t[78]!==I||t[79]!==L||t[80]!==p||t[81]!==m?(R=(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[p,m,A,j,I,L]}),t[76]=A,t[77]=j,t[78]=I,t[79]=L,t[80]=p,t[81]=m,t[82]=R):R=t[82],R}function zt(e){return(0,$.jsx)(`li`,{children:e.message},e.code)}function Bt(e){return e.token}function Vt(e){return e.language}async function Ht(e){let t=await b(x(`/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 Ut(e){await S(x(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{publicUrl:e??null}})})}function Wt(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 Gt(){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`)||Wt(r)?null:n.toLowerCase().replace(/\/+$/,``)},[])}function Kt(){return d(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,p,`dark:border-edge`)}function qt(e){return(e?.candidates.find(e=>e.kind===`reverse-proxy`))?.url?.trim()||null}function Jt(e){return(e?.candidates.find(e=>e.kind===`lan`&&e.reachable))?.url?.trim()||null}function Yt(){let e=y(e=>e.language),t=h(e).remoteAccess.reverseProxy,n=!!v(e=>e.token),r=Gt(),{mutate:i}=j(),{data:a,mutate:o}=M(n?`tunnel-pair-context`:null,de,{refreshInterval:6e4}),s=qt(a),[c,p]=(0,Q.useState)(``),[m,g]=(0,Q.useState)({busy:!1,result:null}),[b,x]=(0,Q.useState)({busy:!1,error:null});(0,Q.useEffect)(()=>{c||(s?p(s):r&&p(r))},[s,r,c]);let S=(0,Q.useMemo)(()=>c.trim()||(s??r??``),[s,r,c]),C=!s&&!!r&&S===r,w=Jt(a),{data:T,mutate:E}=M(n&&S?[`reverse-proxy-pair`,S]:null,()=>fe(),{refreshInterval:4*6e4,revalidateOnFocus:!1}),D=(0,Q.useMemo)(()=>!S||!T?.pairingSecret?``:_({baseUrl:S,pairingSecret:T.pairingSecret,lanUrl:w}),[S,w,T?.pairingSecret]),O=he(()=>ft(D),[D],{enabled:!!D,initial:null,errorData:null}),k=(0,Q.useCallback)(async()=>{let e=c.trim()||S;if(e){g({busy:!0,result:null});try{g({busy:!1,result:await Ht(e)})}catch(e){g({busy:!1,result:{ok:!1,code:`NETWORK_ERROR`,message:e instanceof Error?e.message:String(e)}})}}},[c,S]),A=(0,Q.useCallback)(async()=>{let e=S.trim();if(e){x({busy:!0,error:null});try{await Ut(e),await o(),await i(`tunnel-pair-context`),x({busy:!1,error:null})}catch(e){x({busy:!1,error:e instanceof Error?e.message:String(e)})}}},[S,i,o]),N=(0,Q.useCallback)(async()=>{x({busy:!0,error:null});try{await Ut(null),await o(),await i(`tunnel-pair-context`),p(``),g({busy:!1,result:null}),x({busy:!1,error:null})}catch(e){x({busy:!1,error:e instanceof Error?e.message:String(e)})}},[i,o]),P=(0,Q.useCallback)(async()=>{await E()},[E]);return n?(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(De,{children:[(0,$.jsx)(Te,{icon:l,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:d(Kt(),`font-mono text-xs sm:flex-1 sm:min-w-0 sm:w-auto`),type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:t.urlPlaceholder,value:c,onChange:e=>{p(e.target.value),g({busy:!1,result:null})}}),(0,$.jsxs)(f,{type:`button`,variant:`secondary`,className:`shrink-0 whitespace-nowrap`,onClick:()=>void k(),disabled:m.busy||!c.trim(),children:[m.busy?(0,$.jsx)(u,{className:`size-3.5 animate-spin`}):null,m.busy?t.probing:t.probeButton]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.urlHint}),C&&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,m.result?(0,$.jsx)(Xt,{result:m.result,labels:t.probeStatus}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:[S&&s!==S?(0,$.jsxs)(f,{type:`button`,onClick:()=>void A(),disabled:b.busy,children:[b.busy?(0,$.jsx)(u,{className:`size-3.5 animate-spin`}):null,b.busy?t.saving:t.saveAsDefault]}):null,s?(0,$.jsx)(f,{type:`button`,variant:`ghost`,onClick:()=>void N(),disabled:b.busy,children:t.clear}):null]}),b.error?(0,$.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:b.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)(De,{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})]}),D?(0,$.jsxs)(f,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>void P(),children:[(0,$.jsx)(pe,{className:`size-4`}),t.refreshQr]}):null]}),S?T?.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:`}),` `,S,w?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`br`,{}),(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:`lanUrl:`}),` `,w]}):null]}),O.data?(0,$.jsx)(`img`,{src:O.data,alt:``,className:`size-56 rounded-lg border border-edge-subtle bg-white object-contain p-3 dark:border-edge`}):O.loading?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.encoding}):null,(0,$.jsx)(H,{text:D,labels:{copy:t.copyLink,copied:t.copied,copyFailed:h(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 Xt(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 Zt=[`guide`,`tailscale`,`public`,`reverse-proxy`,`ssh`,`lan`];function Qt(e){return e&&Zt.includes(e)?e:`guide`}function $t(e,t){return e.tabs[t]}function en(e,t){return e.tabIntro[t]}function tn(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 nn(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)(Rt,{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)(wt,{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)(vt,{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)(Yt,{}),t[4]=e):e=t[4],e}case`ssh`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(At,{}),t[5]=e):e=t[5],e}case`lan`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Tt,{}),t[6]=e):e=t[6],e}}}function rn(){let e=(0,Z.c)(2),t=y(on),n=h(t).remoteAccess,r=!!v(an),[a,o]=i(),s=Qt(a.get(`tab`)),c;e[0]===o?c=e[1]:(c=e=>{o(t=>{let n=new URLSearchParams(t);return e===`guide`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[0]=o,e[1]=c);let l=c,u=en(n,s),d=Zt.map(e=>({id:e,label:$t(n,e)}));return(0,$.jsxs)(Se,{children:[(0,$.jsx)(xe,{title:n.pageTitle,subtitle:n.pageSubtitle,meta:(0,$.jsx)(lt,{language:t,label:n.docsLink,section:tn(s),className:`mt-1`})}),r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ne,{items:d,activeTab:s,onChange:l,ariaLabel:n.tabsAria,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`}),(0,$.jsx)(Ce,{id:s,activeTab:s,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`,title:$t(n,s),hint:s===`public`?void 0:u,children:(0,$.jsx)(nn,{tab:s,onOpenTab:l})})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.guide.needToken})]})}function an(e){return e.token}function on(e){return e.language}export{rn 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{p as i}from"./chunk-KS7C4IRE-BaASWQor.js";import{n as a,r as o}from"./popover-select-CccGri5Y.js";import{t as s}from"./download-Dk-ZjtO6.js";import{t as c}from"./plus-Q2yW6OE7.js";import{t as l}from"./search-DA7gz22f.js";import{t as u}from"./x-B_N4OPjy.js";import{t as d}from"./cn-JdwAhgNB.js";import{t as f}from"./button-CSEbl4zT.js";import{s as p}from"./form-field-width-DJw_jULe.js";import{n as m,t as h}from"./interaction-BmQogeqz.js";import{t as g}from"./messages-CeydamsI.js";import{l as _,n as v,r as y,s as b}from"./locale-store-DqJz-cOR.js";import{i as x,o as S}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{a as C,n as w,o as ee,r as T,s as E,t as D}from"./dist-BPoKqzeH.js";import{i as O}from"./vendor-swr-BIWyz7Rc.js";import{n as k,r as A}from"./gateway-config-swr-Du0MvK9s.js";import{n as j,t as M}from"./registry-api-Bf_HDLUJ.js";import{$c as N,Fc as P,Ha as F,Mc as I,Nc as L,Rn as R,Ua as z,Va as B,Vs as V,Xa as H,Ya as U,_a as W,_c as G,at as K,ba as te,da as ne,fa as re,ga as ie,ha as ae,hc as oe,ic as se,ma as ce,mt as le,nu as q,pa as ue,rc as de,rs as fe,tu as pe,ul as J,xl as me,ya as he,ys as ge,zn as _e}from"./index-Csccu8sa.js";import{n as ve,t as ye}from"./use-autosave-Do9mCRcY.js";import{t as be}from"./settings-advanced-gate-BONIDX4v.js";import{n as xe,t as Y}from"./settings-form-section-CrsKGYiG.js";import{t as Se}from"./page-tabs-BaEQMYm_.js";var X=e(t(),1),Ce=n(),Z=r();function we(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 Te(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Ee(e){let t=(0,Ce.c)(105),{session:n,variant:r,labels:i,sessionAgentId:a,sessionAgentAvatar:o,onOpen:c,onAction:l}=e,u;t[0]!==i.unnamedSession||t[1]!==n.name?(u=n.name?.trim()||i.unnamedSession,t[0]=i.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,g=n.status===`archived`,_=n.status===`pinned`,v=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,y;t[5]===v?y=t[6]:(y=d(`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=d(`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 C;t[11]===n.sourceChannel?C=t[12]:(C=(0,Z.jsx)(`div`,{className:`flex min-w-0 items-center gap-2`,children:(0,Z.jsx)(`span`,{className:`truncate text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:n.sourceChannel})}),t[11]=n.sourceChannel,t[12]=C);let w;t[13]===_?w=t[14]:(w=_?(0,Z.jsx)(se,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[13]=_,t[14]=w);let ee;t[15]===n.updatedAt?ee=t[16]:(ee=we(n.updatedAt),t[15]=n.updatedAt,t[16]=ee);let T;t[17]===ee?T=t[18]:(T=(0,Z.jsx)(`span`,{children:ee}),t[17]=ee,t[18]=T);let E;t[19]!==T||t[20]!==w?(E=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[w,T]}),t[19]=T,t[20]=w,t[21]=E):E=t[21];let D;t[22]!==E||t[23]!==S||t[24]!==C?(D=(0,Z.jsxs)(`div`,{className:S,children:[C,E]}),t[22]=E,t[23]=S,t[24]=C,t[25]=D):D=t[25];let O=r===`list`&&`sm:py-3`,k;t[26]===O?k=t[27]:(k=d(`min-w-0 flex-1 px-3 py-2`,O),t[26]=O,t[27]=k);let A=r===`list`&&`sm:items-start`,j;t[28]===A?j=t[29]:(j=d(`flex gap-3`,A),t[28]=A,t[29]=j);let M;t[30]!==o||t[31]!==a?(M=(0,Z.jsx)(K,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}),t[30]=o,t[31]=a,t[32]=M):M=t[32];let N;t[33]===f?N=t[34]:(N=(0,Z.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]=N);let P;t[35]!==n.key||t[36]!==m?(P=m?(0,Z.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]=P):P=t[37];let F;t[38]!==N||t[39]!==P?(F=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[N,P]}),t[38]=N,t[39]=P,t[40]=F):F=t[40];let I;t[41]!==j||t[42]!==M||t[43]!==F?(I=(0,Z.jsxs)(`div`,{className:j,children:[M,F]}),t[41]=j,t[42]=M,t[43]=F,t[44]=I):I=t[44];let L;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Z.jsx)(G,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[45]=L):L=t[45];let R;t[46]===n.messageCount?R=t[47]:(R=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[L,n.messageCount]}),t[46]=n.messageCount,t[47]=R);let z;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Z.jsx)(fe,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[48]=z):z=t[48];let B;t[49]===n.estimatedTokens?B=t[50]:(B=Te(n.estimatedTokens),t[49]=n.estimatedTokens,t[50]=B);let V;t[51]===B?V=t[52]:(V=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[z,B]}),t[51]=B,t[52]=V);let H;t[53]!==R||t[54]!==V?(H=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[R,V]}),t[53]=R,t[54]=V,t[55]=H):H=t[55];let U;t[56]===n.tags?U=t[57]:(U=n.tags.length>0?(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(ke),n.tags.length>3?(0,Z.jsxs)(`span`,{className:`text-[11px] text-fg-disabled`,children:[`+`,n.tags.length-3]}):null]}):null,t[56]=n.tags,t[57]=U);let W;t[58]!==k||t[59]!==I||t[60]!==H||t[61]!==U?(W=(0,Z.jsxs)(`div`,{className:k,children:[I,H,U]}),t[58]=k,t[59]=I,t[60]=H,t[61]=U,t[62]=W):W=t[62];let te;t[63]===l?te=t[64]:(te=()=>l(`continue`),t[63]=l,t[64]=te);let ne;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,Z.jsx)(G,{className:`size-4`,strokeWidth:1.75}),t[65]=ne):ne=t[65];let re;t[66]!==i.continueChat||t[67]!==te?(re=(0,Z.jsx)(`button`,{type:`button`,className:h,title:i.continueChat,"aria-label":i.continueChat,onClick:te,children:ne}),t[66]=i.continueChat,t[67]=te,t[68]=re):re=t[68];let ie;t[69]!==g||t[70]!==i.archive||t[71]!==i.unarchive||t[72]!==l?(ie=g?(0,Z.jsx)(`button`,{type:`button`,className:h,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>l(`unarchive`),children:(0,Z.jsx)(q,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:h,title:i.archive,"aria-label":i.archive,onClick:()=>l(`archive`),children:(0,Z.jsx)(pe,{className:`size-4`,strokeWidth:1.75})}),t[69]=g,t[70]=i.archive,t[71]=i.unarchive,t[72]=l,t[73]=ie):ie=t[73];let ae;t[74]!==_||t[75]!==i.pin||t[76]!==i.unpin||t[77]!==l?(ae=_?(0,Z.jsx)(`button`,{type:`button`,className:h,title:i.unpin,"aria-label":i.unpin,onClick:()=>l(`unpin`),children:(0,Z.jsx)(de,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:h,title:i.pin,"aria-label":i.pin,onClick:()=>l(`pin`),children:(0,Z.jsx)(se,{className:`size-4`,strokeWidth:1.75})}),t[74]=_,t[75]=i.pin,t[76]=i.unpin,t[77]=l,t[78]=ae):ae=t[78];let oe;t[79]===l?oe=t[80]:(oe=()=>l(`export`),t[79]=l,t[80]=oe);let ce;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,Z.jsx)(s,{className:`size-4`,strokeWidth:1.75}),t[81]=ce):ce=t[81];let le;t[82]!==i.export||t[83]!==oe?(le=(0,Z.jsx)(`button`,{type:`button`,className:h,title:i.export,"aria-label":i.export,onClick:oe,children:ce}),t[82]=i.export,t[83]=oe,t[84]=le):le=t[84];let ue;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(ue=d(h,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[85]=ue):ue=t[85];let J;t[86]===l?J=t[87]:(J=()=>l(`delete`),t[86]=l,t[87]=J);let me;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,Z.jsx)(ge,{className:`size-4`,strokeWidth:1.75}),t[88]=me):me=t[88];let he;t[89]!==i.delete||t[90]!==J?(he=(0,Z.jsx)(`button`,{type:`button`,className:ue,title:i.delete,"aria-label":i.delete,onClick:J,children:me}),t[89]=i.delete,t[90]=J,t[91]=he):he=t[91];let _e;t[92]!==re||t[93]!==ie||t[94]!==ae||t[95]!==le||t[96]!==he?(_e=(0,Z.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:Oe,onKeyDown:De,children:[re,ie,ae,le,he]}),t[92]=re,t[93]=ie,t[94]=ae,t[95]=le,t[96]=he,t[97]=_e):_e=t[97];let ve;return t[98]!==c||t[99]!==D||t[100]!==W||t[101]!==y||t[102]!==_e||t[103]!==b?(ve=(0,Z.jsxs)(`div`,{role:`button`,tabIndex:0,className:y,onClick:c,onKeyDown:b,children:[D,W,_e]}),t[98]=c,t[99]=D,t[100]=W,t[101]=y,t[102]=_e,t[103]=b,t[104]=ve):ve=t[104],ve}function De(e){return e.stopPropagation()}function Oe(e){return e.stopPropagation()}function ke(e){return(0,Z.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 Ae(e,t){return e.routing?.agentId?.trim().toLowerCase()||t.trim().toLowerCase()||`main`}function je(e,t){return t.find(t=>t.id===e)?.avatar}var Me={enabled:!0,triggerThreshold:.8,reserveTokens:8192,minMessagesBeforeCompact:10,keepRecentTokens:2e4,recentTurnsPreserve:3,summaryMaxTokens:2e3,summaryChunkTokens:24e3,summaryTimeoutMs:18e4,summaryRetries:2,qualityGuard:!0,gapAudit:!0,minToolResultKeepChars:1e3,maxActiveTranscriptBytes:2e6,postCompactionSections:[`Session Startup`,`Red Lines`]};function Ne(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Pe(e,t,n,r=1/0){return typeof e==`number`&&Number.isFinite(e)&&e>=n&&e<=r?e:t}function Q(e,t,n,r=1/0){return Number.isInteger(e)&&e>=n&&e<=r?e:t}function Fe(e){let t=Ne(e)?e:{},n=Ne(t.userContext)?t.userContext:{},r=Ne(n.memory)?n.memory:{},i=Ne(r.retention)?r.retention:{},a=Ne(i.compaction)?i.compaction:{},o=Me,s=typeof a.model==`string`&&a.model.trim()?a.model.trim():void 0,c=Array.isArray(a.postCompactionSections)&&a.postCompactionSections.length<=12&&a.postCompactionSections.every(e=>typeof e==`string`&&e.trim())?[...new Set(a.postCompactionSections.map(e=>e.trim()))]:[...o.postCompactionSections];return{enabled:typeof a.enabled==`boolean`?a.enabled:o.enabled,triggerThreshold:Pe(a.triggerThreshold,o.triggerThreshold,.1,.98),reserveTokens:Q(a.reserveTokens,o.reserveTokens,1024),minMessagesBeforeCompact:Q(a.minMessagesBeforeCompact,o.minMessagesBeforeCompact,2),keepRecentTokens:Q(a.keepRecentTokens,o.keepRecentTokens,1e3),recentTurnsPreserve:Q(a.recentTurnsPreserve,o.recentTurnsPreserve,1,12),summaryMaxTokens:Q(a.summaryMaxTokens,o.summaryMaxTokens,256),summaryChunkTokens:Q(a.summaryChunkTokens,o.summaryChunkTokens,1e3),summaryTimeoutMs:Q(a.summaryTimeoutMs,o.summaryTimeoutMs,1e3,6e5),summaryRetries:Q(a.summaryRetries,o.summaryRetries,0,5),qualityGuard:typeof a.qualityGuard==`boolean`?a.qualityGuard:o.qualityGuard,gapAudit:typeof a.gapAudit==`boolean`?a.gapAudit:o.gapAudit,...s?{model:s}:{},minToolResultKeepChars:Q(a.minToolResultKeepChars,o.minToolResultKeepChars,200),maxActiveTranscriptBytes:Q(a.maxActiveTranscriptBytes,o.maxActiveTranscriptBytes,64e3),postCompactionSections:c}}function Ie(e){return e.triggerThreshold<.1||e.triggerThreshold>.98?`triggerThreshold`:!Number.isInteger(e.reserveTokens)||e.reserveTokens<1024?`reserveTokens`:!Number.isInteger(e.minMessagesBeforeCompact)||e.minMessagesBeforeCompact<2?`minMessagesBeforeCompact`:!Number.isInteger(e.keepRecentTokens)||e.keepRecentTokens<1e3?`keepRecentTokens`:!Number.isInteger(e.recentTurnsPreserve)||e.recentTurnsPreserve<1||e.recentTurnsPreserve>12?`recentTurnsPreserve`:!Number.isInteger(e.summaryMaxTokens)||e.summaryMaxTokens<256?`summaryMaxTokens`:!Number.isInteger(e.summaryChunkTokens)||e.summaryChunkTokens<1e3?`summaryChunkTokens`:!Number.isInteger(e.summaryTimeoutMs)||e.summaryTimeoutMs<1e3||e.summaryTimeoutMs>6e5?`summaryTimeoutMs`:!Number.isInteger(e.summaryRetries)||e.summaryRetries<0||e.summaryRetries>5?`summaryRetries`:e.model!==void 0&&!e.model.trim()?`model`:!Number.isInteger(e.minToolResultKeepChars)||e.minToolResultKeepChars<200?`minToolResultKeepChars`:!Number.isInteger(e.maxActiveTranscriptBytes)||e.maxActiveTranscriptBytes<64e3?`maxActiveTranscriptBytes`:e.postCompactionSections.length>12||e.postCompactionSections.some(e=>!e.trim())?`postCompactionSections`:null}function Le(e){let t={...e,...e.model?.trim()?{model:e.model.trim()}:{}};return e.model?.trim()||delete t.model,{userContext:{memory:{retention:{compaction:t}}}}}async function Re(e){await b(y(`/api/config`),{method:`PATCH`,body:JSON.stringify(Le(e))}),await k()}var ze=128e3,Be={balanced:Me,preserve:{...Me,triggerThreshold:.88,keepRecentTokens:32e3,recentTurnsPreserve:5,maxActiveTranscriptBytes:4e6},early:{...Me,triggerThreshold:.65,reserveTokens:12e3,minMessagesBeforeCompact:6,keepRecentTokens:12e3,recentTurnsPreserve:2}},Ve=B();function He(){return d(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg disabled:cursor-not-allowed disabled:opacity-55`,p,`dark:border-edge`)}function Ue(e){let{enabled:t,model:n,postCompactionSections:r,...i}=e;return JSON.stringify(i)}function We(e){let t=Ue(e);for(let[e,n]of Object.entries(Be))if(t===Ue(n))return e;return`custom`}function Ge(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}m`:e>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}k`:String(e)}function $(e){let t=(0,Ce.c)(20),{id:n,label:r,hint:i,value:a,min:o,max:s,step:c,disabled:l,onChange:u}=e,d=c===void 0?1:c,f;t[0]!==n||t[1]!==r?(f=(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]=f):f=t[2];let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=He(),t[3]=p):p=t[3];let m;t[4]===u?m=t[5]:(m=e=>{if(!e.target.value.trim())return;let t=Number(e.target.value);Number.isFinite(t)&&u(t)},t[4]=u,t[5]=m);let h;t[6]!==l||t[7]!==n||t[8]!==s||t[9]!==o||t[10]!==d||t[11]!==m||t[12]!==a?(h=(0,Z.jsx)(`input`,{id:n,type:`number`,min:o,max:s,step:d,disabled:l,className:p,value:a,onChange:m}),t[6]=l,t[7]=n,t[8]=s,t[9]=o,t[10]=d,t[11]=m,t[12]=a,t[13]=h):h=t[13];let g;t[14]===i?g=t[15]:(g=i?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}):null,t[14]=i,t[15]=g);let _;return t[16]!==f||t[17]!==h||t[18]!==g?(_=(0,Z.jsxs)(`div`,{children:[f,h,g]}),t[16]=f,t[17]=h,t[18]=g,t[19]=_):_=t[19],_}function Ke(e){let t=(0,Ce.c)(19),{label:n,hint:r,checked:i,disabled:a,onChange:o}=e,s=a?`cursor-not-allowed opacity-55`:`cursor-pointer`,c;t[0]===s?c=t[1]:(c=d(`flex items-start gap-2 text-sm text-fg`,s),t[0]=s,t[1]=c);let l;t[2]===o?l=t[3]:(l=e=>o(e.target.checked),t[2]=o,t[3]=l);let u;t[4]!==i||t[5]!==a||t[6]!==l?(u=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:i,disabled:a,onChange:l}),t[4]=i,t[5]=a,t[6]=l,t[7]=u):u=t[7];let f;t[8]===n?f=t[9]:(f=(0,Z.jsx)(`span`,{className:`font-medium`,children:n}),t[8]=n,t[9]=f);let p;t[10]===r?p=t[11]:(p=(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r}),t[10]=r,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,Z.jsxs)(`span`,{children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;return t[15]!==c||t[16]!==u||t[17]!==m?(h=(0,Z.jsxs)(`label`,{className:c,children:[u,m]}),t[15]=c,t[16]=u,t[17]=m,t[18]=h):h=t[18],h}function qe({hasToken:e}){let t=g(v(e=>e.language)).sessions.compaction,{data:n,isLoading:r}=A(e),{data:i=[],isLoading:a}=O(e?M:null,j,{revalidateOnFocus:!1}),o=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:Fe(n.payload.config),[n]),[s,l]=(0,X.useReducer)(Ve,{form:null,baseline:null}),[p,h]=(0,X.useState)(``),_=(0,X.useRef)(!1),y=(0,X.useRef)(s.form);y.current=s.form;let b=(0,X.useRef)(null);F({enabled:e,parsed:o,dirty:_.current,trackedParsedRef:b,dispatch:l,onResetDirty:()=>{_.current=!1}});let x=s.form,S=s.baseline,C=!!(x&&S&&JSON.stringify(x)!==JSON.stringify(S)),w=(0,X.useCallback)(e=>{_.current=!0,l({type:`patch`,patch:e})},[]),ee=(0,X.useCallback)(e=>({enabled:t.enabled,triggerThreshold:t.triggerThreshold,reserveTokens:t.reserveTokens,minMessagesBeforeCompact:t.minMessagesBeforeCompact,keepRecentTokens:t.keepRecentTokens,recentTurnsPreserve:t.recentTurnsPreserve,summaryMaxTokens:t.summaryMaxTokens,summaryChunkTokens:t.summaryChunkTokens,summaryTimeoutMs:t.summaryTimeoutSeconds,summaryRetries:t.summaryRetries,qualityGuard:t.qualityGuard,gapAudit:t.gapAudit,model:t.summaryModel,minToolResultKeepChars:t.minToolResultKeepChars,maxActiveTranscriptBytes:t.maxActiveTranscriptMb,postCompactionSections:t.postCompactionSections})[e],[t]),T=ye({value:x,dirty:C,onSave:(0,X.useCallback)(async e=>{try{await Re(e),l({type:`saved`,value:e}),_.current=!!(y.current&&JSON.stringify(y.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError]),validate:e=>{let n=Ie(e);return n?t.invalidValue.replace(`{{field}}`,ee(n)):null}});if(!e||!x)return r?(0,Z.jsx)(Y,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(H,{className:`h-5 w-48`}),(0,Z.jsx)(H,{className:`h-20 w-full rounded-xl`}),(0,Z.jsx)(H,{className:`h-36 w-full rounded-xl`})]})}):null;let E=We(x),D=Math.max(0,ze-x.reserveTokens),k=Math.min(Math.floor(ze*x.triggerThreshold),D),N=Math.min(100,k/ze*100),P=Math.min(100,D/ze*100),I=x.model?i.find(e=>e.id===x.model):void 0,L=I?.contextWindow&&x.summaryChunkTokens+x.summaryMaxTokens+4096>I.contextWindow,R=x.keepRecentTokens+x.reserveTokens>k,z=Math.round(x.summaryTimeoutMs*(x.summaryRetries+1)/1e3),B=e=>{let t=Be[e];w({...t,...x.model?{model:x.model}:{model:void 0},postCompactionSections:x.postCompactionSections})},V={balanced:{title:t.presetBalanced,hint:t.presetBalancedHint},preserve:{title:t.presetPreserve,hint:t.presetPreserveHint},early:{title:t.presetEarly,hint:t.presetEarlyHint}},U=()=>{let e=p.trim();!e||x.postCompactionSections.includes(e)||x.postCompactionSections.length>=12||(w({postCompactionSections:[...x.postCompactionSections,e]}),h(``))};return(0,Z.jsxs)(Y,{onBlurCapture:T.onBlurCapture,children:[(0,Z.jsx)(xe,{icon:oe,title:t.title,subtitle:t.hint,trailing:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(ve,{status:T.status,error:T.error}),(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm font-medium text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:x.enabled,onChange:e=>w({enabled:e.target.checked})}),x.enabled?t.enabled:t.disabled]})]})}),T.error?(0,Z.jsx)(`p`,{className:`mb-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900 dark:bg-red-950/40 dark:text-red-300`,role:`alert`,children:T.error}):null,x.enabled?null:(0,Z.jsx)(`p`,{className:`mb-4 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:t.disabledWarning}),(0,Z.jsxs)(`fieldset`,{disabled:!x.enabled,className:`space-y-5 disabled:opacity-60`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.presetTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.presetHint})]}),E===`custom`?(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.presetCustom}):null]}),(0,Z.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[`balanced`,`preserve`,`early`].map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":E===e,className:d(`rounded-xl border px-3 py-3 text-left`,m.transition,m.focusRingPanel,E===e?`border-accent/50 bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg hover:bg-surface-hover`),onClick:()=>B(e),children:[(0,Z.jsx)(`span`,{className:`block text-sm font-medium`,children:V[e].title}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:V[e].hint})]},e))})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-hover/35 p-4 dark:border-edge`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.budgetPreview}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.budgetPreviewHint})]}),(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2.5 py-1 font-mono text-xs text-fg-muted`,children:t.previewModel128k})]}),(0,Z.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:t.compactionTrigger}),(0,Z.jsx)(`span`,{className:`font-mono text-fg`,children:Ge(k)})]}),(0,Z.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${N}%`}})})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:t.hardInputLimit}),(0,Z.jsx)(`span`,{className:`font-mono text-fg`,children:Ge(D)})]}),(0,Z.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-fg-subtle`,style:{width:`${P}%`}})})]})]}),(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:t.budgetFormula})]}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)($,{id:`compaction-trigger-threshold`,label:t.triggerThreshold,hint:t.triggerThresholdHint,value:Number((x.triggerThreshold*100).toFixed(2)),min:10,max:98,step:.1,onChange:e=>w({triggerThreshold:e/100})}),(0,Z.jsx)($,{id:`compaction-reserve-tokens`,label:t.reserveTokens,hint:t.reserveTokensHint.replace(`{{tokens}}`,Ge(x.reserveTokens)),value:x.reserveTokens,min:1024,step:1024,onChange:e=>w({reserveTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-recent-turns`,label:t.recentTurnsPreserve,hint:t.recentTurnsPreserveHint,value:x.recentTurnsPreserve,min:1,max:12,onChange:e=>w({recentTurnsPreserve:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-keep-recent-tokens`,label:t.keepRecentTokens,hint:t.keepRecentTokensHint.replace(`{{tokens}}`,Ge(x.keepRecentTokens)),value:x.keepRecentTokens,min:1e3,step:1e3,onChange:e=>w({keepRecentTokens:Math.floor(e)})})]}),R?(0,Z.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:t.retentionWarning}):null,(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.summaryModel}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,Z.jsx)(le,{value:x.model??``,disabled:!x.enabled,placeholder:t.summaryModelInherited,searchPlaceholder:t.summaryModelSearch,noMatches:t.summaryModelNoMatches,models:i,modelsLoading:a,className:`min-w-0 flex-1 justify-between`,contentAlign:`start`,showProviderSettingsFooter:!0,onChange:e=>w({model:e})}),x.model?(0,Z.jsx)(f,{type:`button`,variant:`secondary`,onClick:()=>w({model:void 0}),children:t.summaryModelUseSession}):null]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.summaryModelHint})]}),(0,Z.jsx)(Ke,{label:t.qualityGuard,hint:t.qualityGuardHint,checked:x.qualityGuard,onChange:e=>w({qualityGuard:e})}),(0,Z.jsx)(Ke,{label:t.gapAudit,hint:t.gapAuditHint,checked:x.gapAudit,onChange:e=>w({gapAudit:e})})]}),x.qualityGuard?null:(0,Z.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:t.qualityGuardWarning}),(0,Z.jsx)(be,{children:(0,Z.jsxs)(`div`,{className:`space-y-5 border-t border-edge pt-5`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:t.advancedTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.advancedHint})]}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)($,{id:`compaction-min-messages`,label:t.minMessagesBeforeCompact,hint:t.minMessagesBeforeCompactHint,value:x.minMessagesBeforeCompact,min:2,onChange:e=>w({minMessagesBeforeCompact:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-max-transcript-mb`,label:t.maxActiveTranscriptMb,hint:t.maxActiveTranscriptMbHint,value:Number((x.maxActiveTranscriptBytes/1e6).toFixed(3)),min:.064,step:.1,onChange:e=>w({maxActiveTranscriptBytes:Math.max(64e3,Math.round(e*1e6))})}),(0,Z.jsx)($,{id:`compaction-summary-max-tokens`,label:t.summaryMaxTokens,hint:t.summaryMaxTokensHint,value:x.summaryMaxTokens,min:256,step:256,onChange:e=>w({summaryMaxTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-chunk-tokens`,label:t.summaryChunkTokens,hint:t.summaryChunkTokensHint,value:x.summaryChunkTokens,min:1e3,step:1e3,onChange:e=>w({summaryChunkTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-timeout`,label:t.summaryTimeoutSeconds,hint:t.summaryTimeoutSecondsHint.replace(`{{seconds}}`,String(z)),value:x.summaryTimeoutMs/1e3,min:1,max:600,onChange:e=>w({summaryTimeoutMs:Math.round(e*1e3)})}),(0,Z.jsx)($,{id:`compaction-summary-retries`,label:t.summaryRetries,hint:t.summaryRetriesHint,value:x.summaryRetries,min:0,max:5,onChange:e=>w({summaryRetries:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-min-tool-result-chars`,label:t.minToolResultKeepChars,hint:t.minToolResultKeepCharsHint,value:x.minToolResultKeepChars,min:200,step:100,onChange:e=>w({minToolResultKeepChars:Math.floor(e)})})]}),L?(0,Z.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:t.summaryBudgetWarning}):null,(0,Z.jsxs)(`div`,{className:`border-t border-edge pt-5`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.postCompactionSections}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.postCompactionSectionsHint}),x.postCompactionSections.length>0?(0,Z.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:x.postCompactionSections.map(e=>(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs text-fg`,children:[e,(0,Z.jsx)(`button`,{type:`button`,className:d(`text-fg-muted hover:text-fg`,m.press),"aria-label":t.removeSection.replace(`{{section}}`,e),onClick:()=>w({postCompactionSections:x.postCompactionSections.filter(t=>t!==e)}),children:(0,Z.jsx)(u,{className:`size-3.5`,"aria-hidden":!0})})]},e))}):(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.postCompactionSectionsEmpty}),(0,Z.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,Z.jsx)(`input`,{className:He(),value:p,maxLength:120,disabled:x.postCompactionSections.length>=12,placeholder:t.postCompactionSectionsPlaceholder,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),U())}}),(0,Z.jsxs)(f,{type:`button`,variant:`secondary`,disabled:!p.trim()||x.postCompactionSections.length>=12,onClick:U,children:[(0,Z.jsx)(c,{className:`size-4`,"aria-hidden":!0}),t.addSection]})]})]})]})})]})]})}function Je(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ye(e){return e===`main`||e===`per-peer`||e===`per-channel-peer`||e===`per-account-channel-peer`?e:`main`}function Xe(e){let t=Je(e)?e:{},n=Je(t.session)?t.session:{},r=Je(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:Ye(n.dmScope),pruneAfterDays:i,maxEntries:a}}async function Ze(e){await b(y(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),k()}function Qe(){return d(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,p,`dark:border-edge`)}var $e=B();function et({hasToken:e}){let t=g(v(e=>e.language)).sessions.config,{data:n,isLoading:r}=A(e),i=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:Xe(n.payload.config),[n]),[s,c]=(0,X.useReducer)($e,{form:null,baseline:null}),l=s.form,u=s.baseline,d=(0,X.useRef)(!1),f=(0,X.useRef)(l);f.current=l;let p=(0,X.useRef)(null);F({enabled:e,parsed:i,dirty:d.current,trackedParsedRef:p,dispatch:c,onResetDirty:()=>{d.current=!1}});let m=!!(l&&u&&JSON.stringify(l)!==JSON.stringify(u)),h=(0,X.useCallback)(e=>{d.current=!0,c({type:`patch`,patch:e})},[]),_=ye({value:l,dirty:m,onSave:(0,X.useCallback)(async e=>{try{await Ze(e),c({type:`saved`,value:e}),d.current=!!(f.current&&JSON.stringify(f.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});return!e||!l?r?(0,Z.jsx)(Y,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(H,{className:`h-5 w-40`}),(0,Z.jsx)(H,{className:`h-24 w-full rounded-xl`})]})}):null:(0,Z.jsxs)(Y,{onBlurCapture:_.onBlurCapture,children:[(0,Z.jsx)(xe,{icon:J,title:t.title,subtitle:t.hint,trailing:(0,Z.jsx)(ve,{status:_.status,error:_.error})}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.dmScope}),(0,Z.jsxs)(a,{className:Qe(),value:l.dmScope,onChange:e=>h({dmScope:e.target.value}),children:[(0,Z.jsx)(o,{value:`main`,children:t.dmScopeMain}),(0,Z.jsx)(o,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Z.jsx)(o,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Z.jsx)(o,{value:`per-account-channel-peer`,children:t.dmScopePerAccountChannelPeer})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.dmScopeHint})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.pruneAfterDays}),(0,Z.jsx)(`input`,{type:`number`,min:0,className:Qe(),value:l.pruneAfterDays??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();h({pruneAfterDays:t===``?null:Math.max(0,Math.floor(Number(t)||0))})}})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.maxEntries}),(0,Z.jsx)(`input`,{type:`number`,min:1,className:Qe(),value:l.maxEntries??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();h({maxEntries:t===``?null:Math.max(1,Math.floor(Number(t)||1))})}})]})]})]})}function tt(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 nt(e){let t=(0,Ce.c)(60),{open:n,loading:r,session:i,sessionAgentId:a,sessionAgentAvatar:o,labels:s,onClose:c,onArchive:l,onUnarchive:p,onPin:m,onUnpin:h,onExport:g,onDelete:_}=e,v=i?.status===`archived`,y=i?.status===`pinned`,b;t[0]===c?b=t[1]:(b=e=>!e&&c(),t[0]=c,t[1]=b);let O;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(C,{className:d(`xopc-dialog-overlay fixed inset-0 bg-scrim`,S)}),t[2]=O):O=t[2];let k;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(k=d(`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`,x,`dark:border-edge`),t[3]=k):k=t[3];let A;t[4]!==i||t[5]!==o||t[6]!==a?(A=i&&a?(0,Z.jsx)(K,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}):null,t[4]=i,t[5]=o,t[6]=a,t[7]=A):A=t[7];let j;t[8]!==s.unnamedSession||t[9]!==i?.name?(j=i?.name?.trim()||s.unnamedSession,t[8]=s.unnamedSession,t[9]=i?.name,t[10]=j):j=t[10];let M;t[11]===j?M=t[12]:(M=(0,Z.jsx)(E,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:j}),t[11]=j,t[12]=M);let N;t[13]!==A||t[14]!==M?(N=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[A,M]}),t[13]=A,t[14]=M,t[15]=N):N=t[15];let P;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Z.jsx)(u,{className:`size-5`,strokeWidth:1.75}),t[16]=P):P=t[16];let F;t[17]===s.close?F=t[18]:(F=(0,Z.jsx)(w,{asChild:!0,children:(0,Z.jsx)(f,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":s.close,children:P})}),t[17]=s.close,t[18]=F);let I;t[19]!==N||t[20]!==F?(I=(0,Z.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:[N,F]}),t[19]=N,t[20]=F,t[21]=I):I=t[21];let L;t[22]!==s.detailLoading||t[23]!==s.detailMessages||t[24]!==r||t[25]!==i?(L=r?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.detailLoading}):i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`dl`,{className:`mb-4 grid gap-2 text-xs text-fg-muted`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-fg-disabled`,children:`Key`}),(0,Z.jsx)(`dd`,{className:`mt-0.5 break-all font-mono text-fg`,children:i.key})]}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-4`,children:(0,Z.jsxs)(`span`,{children:[i.messageCount,` msgs · `,i.estimatedTokens,` tok`]})})]}),(0,Z.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:s.detailMessages}),(0,Z.jsx)(`ul`,{className:`space-y-3`,children:i.messages.map(rt)})]}):null,t[22]=s.detailLoading,t[23]=s.detailMessages,t[24]=r,t[25]=i,t[26]=L):L=t[26];let R;t[27]===L?R=t[28]:(R=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:L}),t[27]=L,t[28]=R);let z;t[29]!==s.detailExport||t[30]!==g?(z=(0,Z.jsx)(f,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:g,children:s.detailExport}),t[29]=s.detailExport,t[30]=g,t[31]=z):z=t[31];let B;t[32]!==v||t[33]!==s.archive||t[34]!==s.unarchive||t[35]!==l||t[36]!==p?(B=v?(0,Z.jsx)(f,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:p,children:s.unarchive}):(0,Z.jsx)(f,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:l,children:s.archive}),t[32]=v,t[33]=s.archive,t[34]=s.unarchive,t[35]=l,t[36]=p,t[37]=B):B=t[37];let V;t[38]!==y||t[39]!==s.pin||t[40]!==s.unpin||t[41]!==m||t[42]!==h?(V=y?(0,Z.jsx)(f,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:h,children:s.unpin}):(0,Z.jsx)(f,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:m,children:s.pin}),t[38]=y,t[39]=s.pin,t[40]=s.unpin,t[41]=m,t[42]=h,t[43]=V):V=t[43];let H;t[44]!==s.delete||t[45]!==_?(H=(0,Z.jsx)(f,{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:s.delete}),t[44]=s.delete,t[45]=_,t[46]=H):H=t[46];let U;t[47]!==z||t[48]!==B||t[49]!==V||t[50]!==H?(U=(0,Z.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3 dark:border-edge`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[z,B,V,H]})}),t[47]=z,t[48]=B,t[49]=V,t[50]=H,t[51]=U):U=t[51];let W;t[52]!==I||t[53]!==R||t[54]!==U?(W=(0,Z.jsxs)(ee,{children:[O,(0,Z.jsxs)(T,{className:k,"aria-describedby":void 0,children:[I,R,U]})]}),t[52]=I,t[53]=R,t[54]=U,t[55]=W):W=t[55];let G;return t[56]!==n||t[57]!==b||t[58]!==W?(G=(0,Z.jsx)(D,{open:n,onOpenChange:b,children:W}),t[56]=n,t[57]=b,t[58]=W,t[59]=G):G=t[59],G}function rt(e){return(0,Z.jsxs)(`li`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/50 p-2 dark:border-edge`,children:[(0,Z.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase text-fg-subtle`,children:e.role}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-fg-muted`,children:tt(e.content)})]},`${e.timestamp??``}-${e.role}-${tt(e.content).slice(0,24)}`)}var it=20;function at(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var ot=new Set([`all`,`active`,`pinned`,`archived`]),st=new Set([`grid`,`list`]),ct=[`sessions`,`settings`];function lt(e){return e&&ct.includes(e)?e:`sessions`}function ut(e,t){return t===`sessions`?e.tabsSessions:e.tabsSettings}function dt(e,t){return t===`sessions`?e.tabsSessionsHint:e.tabsSettingsHint}function ft(e){let t=(0,Ce.c)(7),{s:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=ct.map(e=>({id:e,label:ut(n,e),icon:e===`sessions`?P:V})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,Z.jsx)(Se,{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 pt(e){let t=(0,Ce.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 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,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`mb-5`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:ut(n,r)}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:dt(n,r)})]}),(0,Z.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,Z.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 mt(e){let t=e.get(`status`),n=e.get(`view`);return{searchInput:e.get(`q`)??``,debouncedSearch:(e.get(`q`)??``).trim(),statusFilter:ot.has(t)?t:`all`,viewMode:st.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 ht(){let e=g(v(e=>e.language)),t=e.sessions,n=_(e=>e.token),r=!!n,{data:a,mutate:o}=O(r?[`gateway-chat-agents`,n]:null,U,{revalidateOnFocus:!1}),s=a?.defaultId??`main`,c=a?.items??[],[u,p]=i(),h=lt(u.get(`tab`)),y=(0,X.useCallback)(e=>{let t=new URLSearchParams(u);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),p(t,{replace:!0})},[u,p]),[b,w]=(0,X.useReducer)(z,u,mt),{searchInput:k,debouncedSearch:A,statusFilter:j,viewMode:M,channelFilter:F,sessions:B,loading:V,error:H,hasMore:G,stats:K,detailOpen:oe,detailLoading:le,detailSession:q,confirmOpen:de,confirmKey:fe}=b;(0,X.useEffect)(()=>{let e=setTimeout(()=>{let e=k.trim();A!==e&&w({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[k,A]);let J=u.toString(),ge=(0,X.useRef)(J);if(ge.current!==J){ge.current=J;let e=u.get(`q`)??``,t=u.get(`status`),n=u.get(`view`),r=(u.get(`channel`)??``).trim(),i=ot.has(t)?t:`all`,a=st.has(n)?n:`grid`,o=e.trim();w({type:`patch`,patch:{...k===e?{}:{searchInput:e},...A===o?{}:{debouncedSearch:o},...j===i?{}:{statusFilter:i},...M===a?{}:{viewMode:a},...F===r?{}:{channelFilter:r}}})}(0,X.useEffect)(()=>{let e=new URLSearchParams(u),t=A.trim();t?e.set(`q`,t):e.delete(`q`),j===`all`?e.delete(`status`):e.set(`status`,j),M===`grid`?e.delete(`view`):e.set(`view`,M),F?e.set(`channel`,F):e.delete(`channel`),e.toString()!==u.toString()&&p(e,{replace:!0})},[A,u,p,j,M,F]),(0,X.useEffect)(()=>{if(!r||h!==`sessions`)return;let e=!1;return(async()=>{w({type:`patch`,patch:{loading:!0,error:null}});try{let t=await ie({limit:it,offset:0,...A?{search:A}:{},...j===`all`?{}:{status:j},...F?{channel:F}:{}});if(e)return;w({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||w({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||w({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,h,A,j,F,t.loadError]),(0,X.useEffect)(()=>{!r||h!==`sessions`||ae().then(e=>w({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,h]),(0,X.useEffect)(()=>{if(!r||h!==`sessions`)return;let e=()=>void o();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,h,o]),(0,X.useEffect)(()=>{if(!r||h!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||w({type:`patch`,patch:{sessions:B.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:q&&q.key===t.key?{...q,name:t.name}:q}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,h,B,q]);let ve=(0,X.useCallback)(async()=>{if(!(!r||V||!G)){w({type:`patch`,patch:{loading:!0,error:null}});try{let e=await ie({limit:it,offset:B.length,...A?{search:A}:{},...j===`all`?{}:{status:j},...F?{channel:F}:{}});w({type:`patch`,patch:{sessions:[...B,...e.items],hasMore:e.hasMore}})}catch(e){w({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{w({type:`patch`,patch:{loading:!1}})}}},[r,V,G,B.length,A,j,F,t.loadError]),ye=(0,X.useCallback)((e,t)=>{w({type:`patch`,patch:{sessions:B.map(n=>n.key===e?{...n,status:t}:n),detailSession:q&&q.key===e?{...q,status:t}:q}})},[B,q]),be=(0,X.useCallback)(async e=>{w({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{w({type:`patch`,patch:{detailSession:await ce(e)}})}catch{w({type:`patch`,patch:{detailOpen:!1}})}finally{w({type:`patch`,patch:{detailLoading:!1}})}},[]),xe=e=>{be(e)},Y=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:e},bubbles:!0}));return}if(t===`delete`){w({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await ne(e),ye(e,`archived`);break;case`unarchive`:await he(e),ye(e,`active`);break;case`pin`:await W(e),ye(e,`pinned`);break;case`unpin`:await te(e),ye(e,`active`);break;case`export`:{let t=await ue(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}ae().then(e=>w({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Se=async e=>{try{await re(e),w({type:`patch`,patch:{sessions:B.filter(t=>t.key!==e),detailSession:q?.key===e?null:q,...q?.key===e?{detailOpen:!1}:{}}}),ae().then(e=>w({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Ce={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},we={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},Te=[{key:`all`,label:t.filterAll,icon:P},{key:`active`,label:t.filterActive,icon:me},{key:`pinned`,label:t.filterPinned,icon:se},{key:`archived`,label:t.filterArchived,icon:pe}],De=(()=>{let e=Object.entries(K?.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,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-surface-panel`,children:[(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,Z.jsx)(`header`,{className:`flex flex-col gap-2`,children:(0,Z.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.title})}),(0,Z.jsx)(ft,{s:t,activeTab:h,onChange:y}),(0,Z.jsx)(pt,{s:t,id:`settings`,activeTab:h,plain:!0,children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(qe,{hasToken:r}),(0,Z.jsx)(et,{hasToken:r})]})}),(0,Z.jsxs)(pt,{s:t,id:`sessions`,activeTab:h,plain:!0,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Te.map(({key:e,label:t,icon:n})=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":j===e,onClick:()=>w({type:`patch`,patch:{statusFilter:e}}),className:d(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,m.transition,m.focusRingPanel,j===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,Z.jsx)(n,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t]},e))}),(0,Z.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,Z.jsx)(l,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`input`,{type:`search`,value:k,onChange:e=>w({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"data-debounced-query":A||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,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:t.filterChannelLabel}),(0,Z.jsx)(`button`,{type:`button`,"aria-pressed":!F,onClick:()=>w({type:`patch`,patch:{channelFilter:``}}),className:d(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,m.transition,m.focusRingPanel,F?`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,Z.jsxs)(`button`,{type:`button`,"aria-pressed":F===e,onClick:()=>w({type:`patch`,patch:{channelFilter:e}}),className:d(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,m.transition,m.focusRingPanel,F===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,K?.byChannel?.[e]==null?null:(0,Z.jsx)(`span`,{className:`ml-2 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] text-fg-subtle`,children:K.byChannel[e]})]},e))]}),K?(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[K.totalSessions,t.totalSessions],[K.activeSessions,t.activeSessions],[K.pinnedSessions,t.pinnedSessions],[K.archivedSessions,t.archivedSessions]].map(([e,t])=>(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-base p-3 dark:bg-surface-hover/30`,children:[(0,Z.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-fg`,children:e}),(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:t})]},t))}):null,H?(0,Z.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:H}):null,(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:at(t.sessionCount,{count:B.length})}),(0,Z.jsxs)(`div`,{className:_e,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,Z.jsx)(f,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":M===`grid`,onClick:()=>w({type:`patch`,patch:{viewMode:`grid`}}),className:d(R,`size-7 p-0`,M===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,M===`grid`&&`text-accent-fg`),children:(0,Z.jsx)(L,{className:`size-3.5`,strokeWidth:1.5})}),(0,Z.jsx)(f,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":M===`list`,onClick:()=>w({type:`patch`,patch:{viewMode:`list`}}),className:d(R,`size-9 p-0`,M===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,M===`list`&&`text-accent-fg`),children:(0,Z.jsx)(I,{className:`size-3.5`,strokeWidth:1.5})})]})]}),V&&B.length===0?(0,Z.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,Z.jsx)(`div`,{className:`h-40 animate-pulse rounded-xl bg-surface-hover/60 dark:bg-surface-hover/40`},t))}):B.length===0?(0,Z.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,Z.jsx)(N,{className:`mb-3 size-12 text-fg-disabled`,strokeWidth:1.25,"aria-hidden":!0}),(0,Z.jsx)(`p`,{className:`text-base font-semibold text-fg`,children:t.noSessions}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-sm text-sm text-fg-muted`,children:t.noSessionsDescription}),(0,Z.jsx)(f,{variant:`primary`,className:`mt-6`,onClick:()=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:``},bubbles:!0}))},children:t.startNewChat})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:d(`grid min-w-0 gap-3`,M===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":A||void 0,children:B.map(e=>{let t=Ae(e,s);return(0,Z.jsx)(Ee,{session:e,variant:M,labels:Ce,sessionAgentId:t,sessionAgentAvatar:je(t,c),onOpen:()=>xe(e.key),onAction:t=>void Y(e.key,t)},e.key)})}),G?(0,Z.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Z.jsx)(f,{type:`button`,variant:`secondary`,disabled:V,onClick:()=>void ve(),children:t.loadMore})}):null]})]})]}),(0,Z.jsx)(nt,{open:oe,loading:le,session:q,sessionAgentId:q?Ae(q,s):void 0,sessionAgentAvatar:q?je(Ae(q,s),c):void 0,labels:we,onClose:()=>{w({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>q&&void Y(q.key,`archive`),onUnarchive:()=>q&&void Y(q.key,`unarchive`),onPin:()=>q&&void Y(q.key,`pin`),onUnpin:()=>q&&void Y(q.key,`unpin`),onExport:()=>q&&void Y(q.key,`export`),onDelete:()=>q&&w({type:`patch`,patch:{confirmKey:q.key,confirmOpen:!0}})}),(0,Z.jsx)(D,{open:de,onOpenChange:e=>w({type:`patch`,patch:{confirmOpen:e}}),children:(0,Z.jsxs)(ee,{children:[(0,Z.jsx)(C,{className:d(`xopc-dialog-overlay fixed inset-0 bg-scrim`,S)}),(0,Z.jsxs)(T,{className:d(`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`,x),children:[(0,Z.jsx)(E,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:fe?at(t.deleteSessionMessage,{name:B.find(e=>e.key===fe)?.name?.trim()||e.chat.newSession}):``}),(0,Z.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Z.jsx)(f,{type:`button`,variant:`secondary`,onClick:()=>w({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Z.jsx)(f,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{fe&&Se(fe),w({type:`patch`,patch:{confirmOpen:!1,confirmKey:null}})},children:t.delete})]})]})]})})]}):(0,Z.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{ht as SessionsPage};
@@ -1 +0,0 @@
1
- import{Sr as e}from"./index-Csccu8sa.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{p as i}from"./chunk-KS7C4IRE-BaASWQor.js";import{t as a}from"./check-DUBLcKHA.js";import{n as o,r as s}from"./popover-select-CccGri5Y.js";import{t as c}from"./copy-Dv6d4Dvw.js";import{t as l}from"./loader-circle-CifKLtgG.js";import{t as u}from"./plus-Q2yW6OE7.js";import{t as d}from"./x-B_N4OPjy.js";import{t as f}from"./cn-JdwAhgNB.js";import{t as p}from"./button-CSEbl4zT.js";import{s as m}from"./form-field-width-DJw_jULe.js";import{t as h}from"./copy-to-clipboard-HOJ79TWv.js";import{t as g}from"./messages-CeydamsI.js";import{l as _,n as v,r as y,s as b}from"./locale-store-DqJz-cOR.js";import{a as x,n as S,o as ee,r as C,s as w,t as te}from"./dist-BPoKqzeH.js";import{i as ne}from"./vendor-swr-BIWyz7Rc.js";import{n as T,r as E}from"./gateway-config-swr-Du0MvK9s.js";import{$c as re,Bi as D,Es as O,Gi as k,Hi as A,Ki as j,Li as M,Pi as N,Pl as P,Ua as F,Ui as ie,Vi as ae,Wi as I,Xa as oe,_l as L,al as R,ca as se,dr as ce,ir as le,qi as z,qs as ue,ys as B,zi as de}from"./index-Csccu8sa.js";import{n as V,r as fe,t as H}from"./settings-page-layout-BRQNel6r.js";import{t as pe}from"./settings-loading-skeleton-WJtI0AAq.js";import{t as me}from"./settings-form-section-CrsKGYiG.js";import{t as U}from"./page-tabs-BaEQMYm_.js";var W=e(t(),1),he=n(),G={enabled:!0,defaultTtlHours:24,maxTtlDays:30,maxActiveShares:500,maxFileSizeMb:500,directoryMaxFolderSizeMb:2048,directoryMaxFileCount:1e4,inlinePreviewMimes:[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`image/svg+xml`,`application/pdf`,`text/html`,`text/markdown`,`text/plain`,`application/json`],noteEnabled:!0,noteMaxTotalSizeMb:250,noteMaxAttachmentCount:50,siteEnabled:!0,siteDefaultTtlHours:24,siteMaxTtlDays:30,maxActiveSites:50,siteMaxRootDirSizeMb:1024,siteMaxFileCount:2e4};function ge(){return structuredClone(G)}var K=36e5,q=864e5,J=1048576;function Y(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function _e(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 ve(e){let t=Y(e)?e:{},n=Y(t.gateway)?t.gateway:{},r=Y(n.share)?n.share:{},i=Y(r.directory)?r.directory:{},a=Y(r.note)?r.note:{},o=Y(n.siteShare)?n.siteShare:{},s=Y(o.static)?o.static:{},c=typeof r.defaultTtlMs==`number`&&Number.isFinite(r.defaultTtlMs)?Math.floor(r.defaultTtlMs):G.defaultTtlHours*K,l=typeof r.maxTtlMs==`number`&&Number.isFinite(r.maxTtlMs)?Math.floor(r.maxTtlMs):G.maxTtlDays*q,u=typeof r.maxFileSize==`number`&&Number.isFinite(r.maxFileSize)?Math.floor(r.maxFileSize):G.maxFileSizeMb*J,d=typeof i.maxFolderSize==`number`&&Number.isFinite(i.maxFolderSize)?Math.floor(i.maxFolderSize):G.directoryMaxFolderSizeMb*J,f=typeof o.defaultTtlMs==`number`&&Number.isFinite(o.defaultTtlMs)?Math.floor(o.defaultTtlMs):G.siteDefaultTtlHours*K,p=typeof o.maxTtlMs==`number`&&Number.isFinite(o.maxTtlMs)?Math.floor(o.maxTtlMs):G.siteMaxTtlDays*q,m=typeof s.maxRootDirSize==`number`&&Number.isFinite(s.maxRootDirSize)?Math.floor(s.maxRootDirSize):G.siteMaxRootDirSizeMb*J,h=typeof a.maxTotalSize==`number`&&Number.isFinite(a.maxTotalSize)?Math.floor(a.maxTotalSize):G.noteMaxTotalSizeMb*J;return{enabled:r.enabled!==!1,defaultTtlHours:Math.max(1,Math.round(c/K)),maxTtlDays:Math.max(1,Math.round(l/q)),maxActiveShares:typeof r.maxActiveShares==`number`&&Number.isFinite(r.maxActiveShares)?Math.max(1,Math.min(1e4,Math.floor(r.maxActiveShares))):G.maxActiveShares,maxFileSizeMb:Math.max(1,Math.round(u/J)),directoryMaxFolderSizeMb:Math.max(1,Math.round(d/J)),directoryMaxFileCount:typeof i.maxFileCount==`number`&&Number.isFinite(i.maxFileCount)?Math.max(1,Math.min(1e5,Math.floor(i.maxFileCount))):G.directoryMaxFileCount,inlinePreviewMimes:_e(r.inlinePreviewMimes,32).length?_e(r.inlinePreviewMimes,32):[...G.inlinePreviewMimes],noteEnabled:a.enabled!==!1,noteMaxTotalSizeMb:Math.max(1,Math.round(h/J)),noteMaxAttachmentCount:typeof a.maxAttachmentCount==`number`&&Number.isFinite(a.maxAttachmentCount)?Math.max(0,Math.min(500,Math.floor(a.maxAttachmentCount))):G.noteMaxAttachmentCount,siteEnabled:o.enabled!==!1,siteDefaultTtlHours:Math.max(1,Math.round(f/K)),siteMaxTtlDays:Math.max(1,Math.round(p/q)),maxActiveSites:typeof o.maxActiveSites==`number`&&Number.isFinite(o.maxActiveSites)?Math.max(1,Math.min(1e3,Math.floor(o.maxActiveSites))):G.maxActiveSites,siteMaxRootDirSizeMb:Math.max(1,Math.round(m/J)),siteMaxFileCount:typeof s.maxFileCount==`number`&&Number.isFinite(s.maxFileCount)?Math.max(1,Math.min(1e5,Math.floor(s.maxFileCount))):G.siteMaxFileCount}}function ye(e){let t=e.defaultTtlHours*K,n=e.maxTtlDays*q,r=e.siteDefaultTtlHours*K,i=e.siteMaxTtlDays*q;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.`:e.directoryMaxFolderSizeMb<1||e.directoryMaxFolderSizeMb>10240?`Maximum folder size must be between 1 MB and 10 GB.`:e.directoryMaxFileCount<1||e.directoryMaxFileCount>1e5?`Maximum directory file count must be between 1 and 100,000.`:e.noteMaxTotalSizeMb<1||e.noteMaxTotalSizeMb>2048?`Maximum Note snapshot size must be between 1 MB and 2 GB.`:e.noteMaxAttachmentCount<0||e.noteMaxAttachmentCount>500?`Maximum Note attachment count must be between 0 and 500.`:r<6e4||r>6048e5?`Default site share TTL must be between 1 minute and 7 days.`:i<6e4||i>2592e6?`Maximum site share TTL must be between 1 minute and 30 days.`:r>i?`Default site TTL cannot exceed maximum site TTL.`:e.siteMaxRootDirSizeMb<1||e.siteMaxRootDirSizeMb>10240?`Maximum static site size must be between 1 MB and 10 GB.`:e.siteMaxFileCount<1||e.siteMaxFileCount>1e5?`Maximum static site file count must be between 1 and 100,000.`:null}async function X(e){let t=ye(e);if(t)throw Error(t);await b(y(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{share:{enabled:e.enabled,defaultTtlMs:e.defaultTtlHours*K,maxTtlMs:e.maxTtlDays*q,maxActiveShares:e.maxActiveShares,maxFileSize:e.maxFileSizeMb*J,inlinePreviewMimes:e.inlinePreviewMimes,directory:{maxFolderSize:e.directoryMaxFolderSizeMb*J,maxFileCount:e.directoryMaxFileCount},note:{enabled:e.noteEnabled,maxTotalSize:e.noteMaxTotalSizeMb*J,maxAttachmentCount:e.noteMaxAttachmentCount}},siteShare:{enabled:e.siteEnabled,defaultTtlMs:e.siteDefaultTtlHours*K,maxTtlMs:e.siteMaxTtlDays*q,maxActiveSites:e.maxActiveSites,static:{maxRootDirSize:e.siteMaxRootDirSizeMb*J,maxFileCount:e.siteMaxFileCount}}}})}),T()}var Z=r();function Q(){return f(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,m,`dark:border-edge`)}function be({hasToken:e}){let t=g(v(e=>e.language)).sharesSettings,{data:n,isLoading:r}=E(e),i=(0,W.useMemo)(()=>n?.payload?.config===void 0?null:structuredClone(ve(n.payload.config)),[n]),a=(0,W.useRef)(!1),[o,s]=(0,W.useState)(null),[c,l]=(0,W.useState)(!1),[u,d]=(0,W.useState)(null),[f,m]=(0,W.useState)(!1),h=o??i,_=i,y=(0,W.useMemo)(()=>!h||!_?!1:JSON.stringify(h)!==JSON.stringify(_),[h,_]),b=(0,W.useCallback)(e=>{a.current=!0,s(t=>{let n=t??_;return n?{...n,...e}:null})},[_]),x=(0,W.useCallback)(async()=>{if(!(!h||c)){l(!0),d(null),m(!1);try{await X(h),a.current=!1,s(null),m(!0),window.setTimeout(()=>m(!1),2500)}catch(e){d(e instanceof Error?e.message:t.policySaveError)}finally{l(!1)}}},[h,c,t.policySaveError]),S=(0,W.useCallback)(()=>{a.current=!1,s(null),d(null),m(!1)},[]);return!e||!h?r?(0,Z.jsx)(me,{children:(0,Z.jsx)(pe,{rows:2})}):null:(0,Z.jsxs)(me,{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:[f?(0,Z.jsx)(`span`,{className:`text-sm text-fg-muted`,children:t.policySaved}):null,(0,Z.jsx)(p,{type:`button`,variant:`secondary`,disabled:c,onClick:()=>b(ge()),children:t.policyUseRecommended}),(0,Z.jsx)(p,{type:`button`,variant:`secondary`,disabled:!y||c,onClick:S,children:t.policyDiscard}),(0,Z.jsx)(p,{type:`button`,variant:`primary`,disabled:!y||c,onClick:()=>void x(),children:c?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,u?(0,Z.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:u}):null,(0,Z.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:t.policyRestartHint}),(0,Z.jsx)(xe,{t,form:h,onChange:b})]})}function xe(e){let t=(0,he.c)(189),{t:n,form:r,onChange:i}=e,a;t[0]===n.policyFileSection?a=t[1]:(a=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policyFileSection}),t[0]=n.policyFileSection,t[1]=a);let o;t[2]===n.policyFileSectionHint?o=t[3]:(o=(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policyFileSectionHint}),t[2]=n.policyFileSectionHint,t[3]=o);let s;t[4]!==a||t[5]!==o?(s=(0,Z.jsxs)(`div`,{className:`mb-4`,children:[a,o]}),t[4]=a,t[5]=o,t[6]=s):s=t[6];let c;t[7]===i?c=t[8]:(c=e=>i({enabled:e.target.checked}),t[7]=i,t[8]=c);let l;t[9]!==r.enabled||t[10]!==c?(l=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:c}),t[9]=r.enabled,t[10]=c,t[11]=l):l=t[11];let u;t[12]!==n.policyEnabled||t[13]!==l?(u=(0,Z.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[l,n.policyEnabled]}),t[12]=n.policyEnabled,t[13]=l,t[14]=u):u=t[14];let d=!r.enabled,f;t[15]===i?f=t[16]:(f=e=>i({defaultTtlHours:e}),t[15]=i,t[16]=f);let p;t[17]!==r.defaultTtlHours||t[18]!==n.policyDefaultTtlHint||t[19]!==n.policyDefaultTtlHours||t[20]!==d||t[21]!==f?(p=(0,Z.jsx)($,{id:`share-default-ttl-hours`,label:n.policyDefaultTtlHours,hint:n.policyDefaultTtlHint,value:r.defaultTtlHours,min:1,max:168,disabled:d,onChange:f}),t[17]=r.defaultTtlHours,t[18]=n.policyDefaultTtlHint,t[19]=n.policyDefaultTtlHours,t[20]=d,t[21]=f,t[22]=p):p=t[22];let m=!r.enabled,h;t[23]===i?h=t[24]:(h=e=>i({maxTtlDays:e}),t[23]=i,t[24]=h);let g;t[25]!==r.maxTtlDays||t[26]!==n.policyMaxTtlDays||t[27]!==n.policyMaxTtlHint||t[28]!==m||t[29]!==h?(g=(0,Z.jsx)($,{id:`share-max-ttl-days`,label:n.policyMaxTtlDays,hint:n.policyMaxTtlHint,value:r.maxTtlDays,min:1,max:30,disabled:m,onChange:h}),t[25]=r.maxTtlDays,t[26]=n.policyMaxTtlDays,t[27]=n.policyMaxTtlHint,t[28]=m,t[29]=h,t[30]=g):g=t[30];let _=!r.enabled,v;t[31]===i?v=t[32]:(v=e=>i({maxActiveShares:e}),t[31]=i,t[32]=v);let y;t[33]!==r.maxActiveShares||t[34]!==n.policyMaxActiveShares||t[35]!==n.policyMaxActiveSharesHint||t[36]!==_||t[37]!==v?(y=(0,Z.jsx)($,{id:`share-max-active`,label:n.policyMaxActiveShares,hint:n.policyMaxActiveSharesHint,value:r.maxActiveShares,min:1,max:1e4,disabled:_,onChange:v}),t[33]=r.maxActiveShares,t[34]=n.policyMaxActiveShares,t[35]=n.policyMaxActiveSharesHint,t[36]=_,t[37]=v,t[38]=y):y=t[38];let b=!r.enabled,x;t[39]===i?x=t[40]:(x=e=>i({maxFileSizeMb:e}),t[39]=i,t[40]=x);let S;t[41]!==r.maxFileSizeMb||t[42]!==n.policyMaxFileSizeHint||t[43]!==n.policyMaxFileSizeMb||t[44]!==b||t[45]!==x?(S=(0,Z.jsx)($,{id:`share-max-file-mb`,label:n.policyMaxFileSizeMb,hint:n.policyMaxFileSizeHint,value:r.maxFileSizeMb,min:1,max:10240,disabled:b,onChange:x}),t[41]=r.maxFileSizeMb,t[42]=n.policyMaxFileSizeHint,t[43]=n.policyMaxFileSizeMb,t[44]=b,t[45]=x,t[46]=S):S=t[46];let ee=!r.enabled,C;t[47]===i?C=t[48]:(C=e=>i({directoryMaxFolderSizeMb:e}),t[47]=i,t[48]=C);let w;t[49]!==r.directoryMaxFolderSizeMb||t[50]!==n.policyDirectoryMaxFolderSizeHint||t[51]!==n.policyDirectoryMaxFolderSizeMb||t[52]!==ee||t[53]!==C?(w=(0,Z.jsx)($,{id:`share-directory-max-size-mb`,label:n.policyDirectoryMaxFolderSizeMb,hint:n.policyDirectoryMaxFolderSizeHint,value:r.directoryMaxFolderSizeMb,min:1,max:10240,disabled:ee,onChange:C}),t[49]=r.directoryMaxFolderSizeMb,t[50]=n.policyDirectoryMaxFolderSizeHint,t[51]=n.policyDirectoryMaxFolderSizeMb,t[52]=ee,t[53]=C,t[54]=w):w=t[54];let te=!r.enabled,ne;t[55]===i?ne=t[56]:(ne=e=>i({directoryMaxFileCount:e}),t[55]=i,t[56]=ne);let T;t[57]!==r.directoryMaxFileCount||t[58]!==n.policyDirectoryMaxFileCount||t[59]!==n.policyDirectoryMaxFileCountHint||t[60]!==te||t[61]!==ne?(T=(0,Z.jsx)($,{id:`share-directory-max-files`,label:n.policyDirectoryMaxFileCount,hint:n.policyDirectoryMaxFileCountHint,value:r.directoryMaxFileCount,min:1,max:1e5,disabled:te,onChange:ne}),t[57]=r.directoryMaxFileCount,t[58]=n.policyDirectoryMaxFileCount,t[59]=n.policyDirectoryMaxFileCountHint,t[60]=te,t[61]=ne,t[62]=T):T=t[62];let E;t[63]!==g||t[64]!==y||t[65]!==S||t[66]!==w||t[67]!==T||t[68]!==p?(E=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[p,g,y,S,w,T]}),t[63]=g,t[64]=y,t[65]=S,t[66]=w,t[67]=T,t[68]=p,t[69]=E):E=t[69];let re=!r.enabled,D;t[70]===i?D=t[71]:(D=e=>i({inlinePreviewMimes:e}),t[70]=i,t[71]=D);let O;t[72]!==r.inlinePreviewMimes||t[73]!==n||t[74]!==re||t[75]!==D?(O=(0,Z.jsx)(Se,{t:n,values:r.inlinePreviewMimes,disabled:re,onChange:D}),t[72]=r.inlinePreviewMimes,t[73]=n,t[74]=re,t[75]=D,t[76]=O):O=t[76];let k;t[77]!==E||t[78]!==O||t[79]!==s||t[80]!==u?(k=(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-muted/25 p-4`,children:[s,u,E,O]}),t[77]=E,t[78]=O,t[79]=s,t[80]=u,t[81]=k):k=t[81];let A;t[82]===n.policyNoteSection?A=t[83]:(A=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policyNoteSection}),t[82]=n.policyNoteSection,t[83]=A);let j;t[84]===n.policyNoteSectionHint?j=t[85]:(j=(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policyNoteSectionHint}),t[84]=n.policyNoteSectionHint,t[85]=j);let M;t[86]!==A||t[87]!==j?(M=(0,Z.jsxs)(`div`,{className:`mb-4`,children:[A,j]}),t[86]=A,t[87]=j,t[88]=M):M=t[88];let N;t[89]===i?N=t[90]:(N=e=>i({noteEnabled:e.target.checked}),t[89]=i,t[90]=N);let P;t[91]!==r.noteEnabled||t[92]!==N?(P=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.noteEnabled,onChange:N}),t[91]=r.noteEnabled,t[92]=N,t[93]=P):P=t[93];let F;t[94]!==n.policyNoteEnabled||t[95]!==P?(F=(0,Z.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[P,n.policyNoteEnabled]}),t[94]=n.policyNoteEnabled,t[95]=P,t[96]=F):F=t[96];let ie=!r.enabled||!r.noteEnabled,ae;t[97]===i?ae=t[98]:(ae=e=>i({noteMaxTotalSizeMb:e}),t[97]=i,t[98]=ae);let I;t[99]!==r.noteMaxTotalSizeMb||t[100]!==n.policyNoteMaxTotalSizeHint||t[101]!==n.policyNoteMaxTotalSizeMb||t[102]!==ie||t[103]!==ae?(I=(0,Z.jsx)($,{id:`share-note-max-size-mb`,label:n.policyNoteMaxTotalSizeMb,hint:n.policyNoteMaxTotalSizeHint,value:r.noteMaxTotalSizeMb,min:1,max:2048,disabled:ie,onChange:ae}),t[99]=r.noteMaxTotalSizeMb,t[100]=n.policyNoteMaxTotalSizeHint,t[101]=n.policyNoteMaxTotalSizeMb,t[102]=ie,t[103]=ae,t[104]=I):I=t[104];let oe=!r.enabled||!r.noteEnabled,L;t[105]===i?L=t[106]:(L=e=>i({noteMaxAttachmentCount:e}),t[105]=i,t[106]=L);let R;t[107]!==r.noteMaxAttachmentCount||t[108]!==n.policyNoteMaxAttachmentCount||t[109]!==n.policyNoteMaxAttachmentCountHint||t[110]!==oe||t[111]!==L?(R=(0,Z.jsx)($,{id:`share-note-max-attachments`,label:n.policyNoteMaxAttachmentCount,hint:n.policyNoteMaxAttachmentCountHint,value:r.noteMaxAttachmentCount,min:0,max:500,disabled:oe,onChange:L}),t[107]=r.noteMaxAttachmentCount,t[108]=n.policyNoteMaxAttachmentCount,t[109]=n.policyNoteMaxAttachmentCountHint,t[110]=oe,t[111]=L,t[112]=R):R=t[112];let se;t[113]!==I||t[114]!==R?(se=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[I,R]}),t[113]=I,t[114]=R,t[115]=se):se=t[115];let ce;t[116]!==M||t[117]!==F||t[118]!==se?(ce=(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-muted/25 p-4`,children:[M,F,se]}),t[116]=M,t[117]=F,t[118]=se,t[119]=ce):ce=t[119];let le;t[120]===n.policySiteSection?le=t[121]:(le=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policySiteSection}),t[120]=n.policySiteSection,t[121]=le);let z;t[122]===n.policySiteSectionHint?z=t[123]:(z=(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policySiteSectionHint}),t[122]=n.policySiteSectionHint,t[123]=z);let ue;t[124]!==le||t[125]!==z?(ue=(0,Z.jsxs)(`div`,{className:`mb-4`,children:[le,z]}),t[124]=le,t[125]=z,t[126]=ue):ue=t[126];let B;t[127]===i?B=t[128]:(B=e=>i({siteEnabled:e.target.checked}),t[127]=i,t[128]=B);let de;t[129]!==r.siteEnabled||t[130]!==B?(de=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.siteEnabled,onChange:B}),t[129]=r.siteEnabled,t[130]=B,t[131]=de):de=t[131];let V;t[132]!==n.policySiteEnabled||t[133]!==de?(V=(0,Z.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[de,n.policySiteEnabled]}),t[132]=n.policySiteEnabled,t[133]=de,t[134]=V):V=t[134];let fe=!r.siteEnabled,H;t[135]===i?H=t[136]:(H=e=>i({siteDefaultTtlHours:e}),t[135]=i,t[136]=H);let pe;t[137]!==r.siteDefaultTtlHours||t[138]!==n.policySiteDefaultTtlHint||t[139]!==n.policySiteDefaultTtlHours||t[140]!==fe||t[141]!==H?(pe=(0,Z.jsx)($,{id:`site-share-default-ttl-hours`,label:n.policySiteDefaultTtlHours,hint:n.policySiteDefaultTtlHint,value:r.siteDefaultTtlHours,min:1,max:168,disabled:fe,onChange:H}),t[137]=r.siteDefaultTtlHours,t[138]=n.policySiteDefaultTtlHint,t[139]=n.policySiteDefaultTtlHours,t[140]=fe,t[141]=H,t[142]=pe):pe=t[142];let me=!r.siteEnabled,U;t[143]===i?U=t[144]:(U=e=>i({siteMaxTtlDays:e}),t[143]=i,t[144]=U);let W;t[145]!==r.siteMaxTtlDays||t[146]!==n.policySiteMaxTtlDays||t[147]!==n.policySiteMaxTtlHint||t[148]!==me||t[149]!==U?(W=(0,Z.jsx)($,{id:`site-share-max-ttl-days`,label:n.policySiteMaxTtlDays,hint:n.policySiteMaxTtlHint,value:r.siteMaxTtlDays,min:1,max:30,disabled:me,onChange:U}),t[145]=r.siteMaxTtlDays,t[146]=n.policySiteMaxTtlDays,t[147]=n.policySiteMaxTtlHint,t[148]=me,t[149]=U,t[150]=W):W=t[150];let G=!r.siteEnabled,ge;t[151]===i?ge=t[152]:(ge=e=>i({maxActiveSites:e}),t[151]=i,t[152]=ge);let K;t[153]!==r.maxActiveSites||t[154]!==n.policyMaxActiveSites||t[155]!==n.policyMaxActiveSitesHint||t[156]!==G||t[157]!==ge?(K=(0,Z.jsx)($,{id:`site-share-max-active`,label:n.policyMaxActiveSites,hint:n.policyMaxActiveSitesHint,value:r.maxActiveSites,min:1,max:1e3,disabled:G,onChange:ge}),t[153]=r.maxActiveSites,t[154]=n.policyMaxActiveSites,t[155]=n.policyMaxActiveSitesHint,t[156]=G,t[157]=ge,t[158]=K):K=t[158];let q=!r.siteEnabled,J;t[159]===i?J=t[160]:(J=e=>i({siteMaxRootDirSizeMb:e}),t[159]=i,t[160]=J);let Y;t[161]!==r.siteMaxRootDirSizeMb||t[162]!==n.policySiteMaxRootDirSizeHint||t[163]!==n.policySiteMaxRootDirSizeMb||t[164]!==q||t[165]!==J?(Y=(0,Z.jsx)($,{id:`site-share-max-root-size-mb`,label:n.policySiteMaxRootDirSizeMb,hint:n.policySiteMaxRootDirSizeHint,value:r.siteMaxRootDirSizeMb,min:1,max:10240,disabled:q,onChange:J}),t[161]=r.siteMaxRootDirSizeMb,t[162]=n.policySiteMaxRootDirSizeHint,t[163]=n.policySiteMaxRootDirSizeMb,t[164]=q,t[165]=J,t[166]=Y):Y=t[166];let _e=!r.siteEnabled,ve;t[167]===i?ve=t[168]:(ve=e=>i({siteMaxFileCount:e}),t[167]=i,t[168]=ve);let ye;t[169]!==r.siteMaxFileCount||t[170]!==n.policySiteMaxFileCount||t[171]!==n.policySiteMaxFileCountHint||t[172]!==_e||t[173]!==ve?(ye=(0,Z.jsx)($,{id:`site-share-max-files`,label:n.policySiteMaxFileCount,hint:n.policySiteMaxFileCountHint,value:r.siteMaxFileCount,min:1,max:1e5,disabled:_e,onChange:ve}),t[169]=r.siteMaxFileCount,t[170]=n.policySiteMaxFileCount,t[171]=n.policySiteMaxFileCountHint,t[172]=_e,t[173]=ve,t[174]=ye):ye=t[174];let X;t[175]!==pe||t[176]!==W||t[177]!==K||t[178]!==Y||t[179]!==ye?(X=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[pe,W,K,Y,ye]}),t[175]=pe,t[176]=W,t[177]=K,t[178]=Y,t[179]=ye,t[180]=X):X=t[180];let Q;t[181]!==ue||t[182]!==V||t[183]!==X?(Q=(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-muted/25 p-4`,children:[ue,V,X]}),t[181]=ue,t[182]=V,t[183]=X,t[184]=Q):Q=t[184];let be;return t[185]!==k||t[186]!==ce||t[187]!==Q?(be=(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[k,ce,Q]}),t[185]=k,t[186]=ce,t[187]=Q,t[188]=be):be=t[188],be}function $(e){let t=(0,he.c)(21),{id:n,label:r,hint:i,value:a,min:o,max:s,disabled:c,onChange:l}=e,u;t[0]!==n||t[1]!==r?(u=(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]=u):u=t[2];let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=f(Q(),`max-w-xs font-mono text-xs`),t[3]=d):d=t[3];let p;t[4]!==s||t[5]!==o||t[6]!==l?(p=e=>{let t=Number(e.target.value);Number.isFinite(t)&&l(Math.max(o,Math.min(s,Math.floor(t))))},t[4]=s,t[5]=o,t[6]=l,t[7]=p):p=t[7];let m;t[8]!==c||t[9]!==n||t[10]!==s||t[11]!==o||t[12]!==p||t[13]!==a?(m=(0,Z.jsx)(`input`,{id:n,type:`number`,min:o,max:s,disabled:c,className:d,value:a,onChange:p}),t[8]=c,t[9]=n,t[10]=s,t[11]=o,t[12]=p,t[13]=a,t[14]=m):m=t[14];let h;t[15]===i?h=t[16]:(h=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}),t[15]=i,t[16]=h);let g;return t[17]!==u||t[18]!==m||t[19]!==h?(g=(0,Z.jsxs)(`div`,{children:[u,m,h]}),t[17]=u,t[18]=m,t[19]=h,t[20]=g):g=t[20],g}function Se(e){let t=(0,he.c)(25),{t:n,values:r,disabled:i,onChange:a}=e,o;t[0]!==a||t[1]!==r?(o=e=>{let t=e.trim();!t||r.includes(t)||r.length>=32||a([...r,t])},t[0]=a,t[1]=r,t[2]=o):o=t[2];let s=o,c;t[3]===n.policyInlinePreviewMimes?c=t[4]:(c=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.policyInlinePreviewMimes}),t[3]=n.policyInlinePreviewMimes,t[4]=c);let l;t[5]===n.policyInlinePreviewMimesHint?l=t[6]:(l=(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.policyInlinePreviewMimesHint}),t[5]=n.policyInlinePreviewMimesHint,t[6]=l);let u;t[7]!==i||t[8]!==a||t[9]!==r?(u=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,i?null:(0,Z.jsx)(`button`,{type:`button`,className:`text-fg-muted hover:text-fg`,"aria-label":`Remove ${e}`,onClick:()=>a(r.filter(t=>t!==e)),children:`×`})]},e)),t[7]=i,t[8]=a,t[9]=r,t[10]=u):u=t[10];let d;t[11]===u?d=t[12]:(d=(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:u}),t[11]=u,t[12]=d);let p;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(p=f(Q(),`font-mono text-xs`),t[13]=p):p=t[13];let m=i||r.length>=32,h;t[14]===s?h=t[15]:(h=e=>{e.key===`Enter`&&(e.preventDefault(),s(e.target.value),e.target.value=``)},t[14]=s,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]!==c||t[21]!==l||t[22]!==d||t[23]!==g?(_=(0,Z.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-4`,children:[c,l,d,g]}),t[20]=c,t[21]=l,t[22]=d,t[23]=g,t[24]=_):_=t[24],_}function Ce(e){let t=(0,he.c)(70),{open:n,onOpenChange:r,onConfirm:i,initialPath:a,selectKind:c,sessionKey:u,agentId:m}=e,h=c===void 0?`any`:c,y=g(v(Ee)),b=y.workspace,T=y.sharesSettings,E=M(Te),{data:D}=ne(_(we)?`picker-agents-list`:null,ce),O;bb0:{let e;t[0]===m?e=t[1]:(e=m?.trim(),t[0]=m,t[1]=e);let n=e;if(n){O=n;break bb0}let r;t[2]===E?r=t[3]:(r=E.trim(),t[2]=E,t[3]=r);let i=r;if(i){O=i;break bb0}if(D?.defaultId){O=D.defaultId;break bb0}if(D?.agents?.[0]?.id){O=D.agents[0].id;break bb0}O=``}let k=O,[A,j]=(0,W.useState)(k),N,P;t[4]===k?(N=t[5],P=t[6]):(N=()=>{j(k)},P=[k],t[4]=k,t[5]=N,t[6]=P),(0,W.useEffect)(N,P);let{tree:F,loading:ie,error:ae,loadRoot:I,loadChildren:oe,reset:L}=de(A,u??null),R;t[7]===a?R=t[8]:(R=a?{path:a,isDirectory:!1}:null,t[7]=a,t[8]=R);let[z,B]=(0,W.useState)(R),V;t[9]!==a||t[10]!==I||t[11]!==n||t[12]!==L||t[13]!==B?(V=()=>{if(!n){L(),B(a?{path:a,isDirectory:!1}:null);return}I()},t[9]=a,t[10]=I,t[11]=n,t[12]=L,t[13]=B,t[14]=V):V=t[14];let fe;t[15]!==a||t[16]!==I||t[17]!==n||t[18]!==A||t[19]!==L||t[20]!==u?(fe=[n,A,u,I,L,a],t[15]=a,t[16]=I,t[17]=n,t[18]=A,t[19]=L,t[20]=u,t[21]=fe):fe=t[21],(0,W.useEffect)(V,fe);let H;t[22]===oe?H=t[23]:(H=e=>{oe(e)},t[22]=oe,t[23]=H);let pe=H,me=z!==null&&(h===`any`||h===`file`&&!z.isDirectory||h===`directory`&&z.isDirectory),U;bb1:{if(!z){U=T.pickerHintNone;break bb1}if(h===`file`&&z.isDirectory){U=T.pickerHintNeedsFile;break bb1}if(h===`directory`&&!z.isDirectory){U=T.pickerHintNeedsDirectory;break bb1}U=`${z.isDirectory?`📁`:`📄`} ${z.path}`}let G=U,ge=D?.agents??[],K;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,Z.jsx)(x,{className:`fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),t[24]=K):K=t[24];let q;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(q=f(`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[25]=q):q=t[25];let J;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,Z.jsx)(re,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[26]=J):J=t[26];let Y=y.cron.refresh,_e=y.cron.refresh,ve;t[27]===I?ve=t[28]:(ve=()=>void I(),t[27]=I,t[28]=ve);let ye=ie&&`animate-spin`,X;t[29]===ye?X=t[30]:(X=f(`size-4`,ye),t[29]=ye,t[30]=X);let Q;t[31]===X?Q=t[32]:(Q=(0,Z.jsx)(ue,{className:X,"aria-hidden":!0}),t[31]=X,t[32]=Q);let be;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,Z.jsx)(d,{className:`size-4`}),t[33]=be):be=t[33];let xe;t[34]!==ae||t[35]!==b.loadError?(xe=ae?(0,Z.jsxs)(`p`,{className:`shrink-0 px-4 py-2 text-xs text-red-600 dark:text-red-400`,children:[b.loadError,`: `,ae]}):null,t[34]=ae,t[35]=b.loadError,t[36]=xe):xe=t[36];let $;t[37]!==pe||t[38]!==ie||t[39]!==z?.path||t[40]!==B||t[41]!==b.emptyDir||t[42]!==b.title||t[43]!==F?($=ie&&F.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)(se,{tree:F,selectedPath:z?.path??null,onSelectFile:e=>B({path:e,isDirectory:!1}),onSelectEntry:(e,t)=>B({path:e,isDirectory:t}),onExpandDir:pe,onAction:void 0,emptyHint:b.emptyDir}),t[37]=pe,t[38]=ie,t[39]=z?.path,t[40]=B,t[41]=b.emptyDir,t[42]=b.title,t[43]=F,t[44]=$):$=t[44];let Se;t[45]!==xe||t[46]!==$?(Se=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[xe,$]}),t[45]=xe,t[46]=$,t[47]=Se):Se=t[47];let Ce;t[48]===G?Ce=t[49]:(Ce=(0,Z.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:G}),t[48]=G,t[49]=Ce);let De;t[50]===r?De=t[51]:(De=()=>r(!1),t[50]=r,t[51]=De);let Oe;t[52]!==T.cancel||t[53]!==De?(Oe=(0,Z.jsx)(p,{type:`button`,variant:`ghost`,onClick:De,children:T.cancel}),t[52]=T.cancel,t[53]=De,t[54]=Oe):Oe=t[54];let ke=!me,Ae;t[55]!==i||t[56]!==r||t[57]!==A||t[58]!==z?(Ae=()=>{z&&(i({...z,agentId:A}),r(!1))},t[55]=i,t[56]=r,t[57]=A,t[58]=z,t[59]=Ae):Ae=t[59];let je;t[60]!==T.pickerConfirm||t[61]!==ke||t[62]!==Ae?(je=(0,Z.jsx)(p,{type:`button`,disabled:ke,onClick:Ae,children:T.pickerConfirm}),t[60]=T.pickerConfirm,t[61]=ke,t[62]=Ae,t[63]=je):je=t[63];let Me;t[64]!==Oe||t[65]!==je?(Me=(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[Oe,je]}),t[64]=Oe,t[65]=je,t[66]=Me):Me=t[66];let Ne;return t[67]!==Ce||t[68]!==Me?(Ne=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-t border-edge px-4 py-3`,children:[Ce,Me]}),t[67]=Ce,t[68]=Me,t[69]=Ne):Ne=t[69],(0,Z.jsx)(te,{open:n,onOpenChange:r,children:(0,Z.jsxs)(ee,{children:[K,(0,Z.jsxs)(C,{className:q,children:[(0,Z.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-edge px-4`,children:[J,(0,Z.jsx)(w,{className:`min-w-0 flex-1 truncate text-base font-semibold text-fg`,children:T.pickerTitle}),(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:Y,"aria-label":_e,disabled:ie,onClick:ve,children:Q}),(0,Z.jsx)(S,{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:be})})]}),ge.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:T.pickerAgentLabel}),(0,Z.jsx)(o,{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=>{j(e.target.value),B(null)},children:ge.map(e=>(0,Z.jsxs)(s,{value:e.id,children:[le(e,y.agentsSettings),e.id===D?.defaultId?` ★`:``]},e.id))})]}):null,Se,Ne]})]})})}function we(e){return e.token}function Te(e){return e.agentId}function Ee(e){return e.language}var De=[`shares`,`policy`];function Oe(e){let t=(e??``).trim();return De.includes(t)?t:`shares`}function ke(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 Ae(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 je=[{value:36e5,key:`1h`},{value:216e5,key:`6h`},{value:864e5,key:`24h`},{value:2592e5,key:`3d`},{value:6048e5,key:`7d`},{value:2592e6,key:`30d`}];function Me(){let e=(0,he.c)(24),t=v(Pe),n=g(t).sharesSettings,r=!!_(Ne),[a,o]=i(),s;e[0]===a?s=e[1]:(s=Oe(a.get(`tab`)),e[0]=a,e[1]=s);let c=s,l;e[2]===o?l=e[3]:(l=e=>{o(t=>{let n=new URLSearchParams(t);return e===`shares`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[2]=o,e[3]=l);let u=l;if(!r)return(0,Z.jsx)(fe,{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 d={shares:n.tabShares,policy:n.tabPolicy},f=De.map(e=>({id:e,label:d[e]})),p;e[4]!==n.subtitle||e[5]!==n.title?(p=(0,Z.jsx)(V,{title:n.title,subtitle:n.subtitle}),e[4]=n.subtitle,e[5]=n.title,e[6]=p):p=e[6];let m;e[7]!==c||e[8]!==u||e[9]!==n.tabsAria||e[10]!==f?(m=(0,Z.jsx)(U,{items:f,activeTab:c,onChange:u,ariaLabel:n.tabsAria,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`}),e[7]=c,e[8]=u,e[9]=n.tabsAria,e[10]=f,e[11]=m):m=e[11];let h;e[12]!==c||e[13]!==r||e[14]!==t||e[15]!==n?(h=c===`shares`?(0,Z.jsx)(Fe,{t:n,language:t}):(0,Z.jsx)(be,{hasToken:r}),e[12]=c,e[13]=r,e[14]=t,e[15]=n,e[16]=h):h=e[16];let y;e[17]!==c||e[18]!==h?(y=(0,Z.jsx)(H,{id:c,activeTab:c,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`,showHeading:!1,children:h}),e[17]=c,e[18]=h,e[19]=y):y=e[19];let b;return e[20]!==p||e[21]!==m||e[22]!==y?(b=(0,Z.jsxs)(fe,{children:[p,m,y]}),e[20]=p,e[21]=m,e[22]=y,e[23]=b):b=e[23],b}function Ne(e){return e.token}function Pe(e){return e.language}function Fe(e){let t=(0,he.c)(60),{t:n,language:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={refreshInterval:3e4},t[0]=i):i=t[0];let{data:a,error:o,isLoading:s,mutate:c}=ne(`shares-list`,ie,i),l;t[1]===a?.payload?.shares?l=t[2]:(l=a?.payload?.shares??[],t[1]=a?.payload?.shares,t[2]=l);let u=l,[d,m]=(0,W.useState)(!1),h;bb0:{if(d){h=u;break bb0}let e;t[3]===u?e=t[4]:(e=u.filter(Be),t[3]=u,t[4]=e),h=e}let g=h,_;t[5]===u?_=t[6]:(_=u.filter(ze),t[5]=u,t[6]=_);let v=_.length,y;t[7]===u?y=t[8]:(y=u.filter(Re),t[7]=u,t[8]=y);let b=y.length,x;t[9]===c?x=t[10]:(x=()=>void c(),t[9]=c,t[10]=x);let S;t[11]!==n||t[12]!==x?(S=(0,Z.jsx)(He,{t:n,onCreated:x}),t[11]=n,t[12]=x,t[13]=S):S=t[13];let ee=d?n.allSharesTitle:n.listTitle,C;t[14]===v?C=t[15]:(C=v>0&&(0,Z.jsxs)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:[`(`,v,`)`]}),t[14]=v,t[15]=C);let w;t[16]!==ee||t[17]!==C?(w=(0,Z.jsxs)(`h2`,{className:`text-sm font-semibold text-fg`,children:[ee,C]}),t[16]=ee,t[17]=C,t[18]=w):w=t[18];let te;t[19]===c?te=t[20]:(te=()=>void c(),t[19]=c,t[20]=te);let T=s&&`animate-spin`,E;t[21]===T?E=t[22]:(E=f(`size-3.5`,T),t[21]=T,t[22]=E);let re;t[23]===E?re=t[24]:(re=(0,Z.jsx)(ue,{className:E}),t[23]=E,t[24]=re);let D;t[25]!==s||t[26]!==te||t[27]!==re?(D=(0,Z.jsx)(p,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:te,disabled:s,children:re}),t[25]=s,t[26]=te,t[27]=re,t[28]=D):D=t[28];let O;t[29]!==b||t[30]!==d||t[31]!==n.hideExpired||t[32]!==n.showExpired?(O=b>0&&(0,Z.jsx)(`button`,{type:`button`,className:`text-xs text-accent hover:underline`,onClick:()=>m(Le),children:d?n.hideExpired:n.showExpired}),t[29]=b,t[30]=d,t[31]=n.hideExpired,t[32]=n.showExpired,t[33]=O):O=t[33];let k;t[34]!==D||t[35]!==O?(k=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[D,O]}),t[34]=D,t[35]=O,t[36]=k):k=t[36];let A;t[37]!==w||t[38]!==k?(A=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[w,k]}),t[37]=w,t[38]=k,t[39]=A):A=t[39];let j;t[40]!==a||t[41]!==o||t[42]!==g||t[43]!==s||t[44]!==r||t[45]!==c||t[46]!==n?(j=s&&!a?(0,Z.jsx)(`div`,{className:`grid gap-2`,"aria-busy":`true`,children:Array.from({length:4}).map(Ie)}):o?(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 c(),children:n.retry})]}):g.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:g.map(e=>(0,Z.jsx)(We,{share:e,t:n,language:r,onRevoked:()=>void c(),onExtended:()=>void c()},e.id))}),t[40]=a,t[41]=o,t[42]=g,t[43]=s,t[44]=r,t[45]=c,t[46]=n,t[47]=j):j=t[47];let M;t[48]!==b||t[49]!==c||t[50]!==d||t[51]!==n?(M=b>0&&d&&(0,Z.jsx)(Ge,{t:n,onCleaned:()=>void c()}),t[48]=b,t[49]=c,t[50]=d,t[51]=n,t[52]=M):M=t[52];let N;t[53]!==A||t[54]!==j||t[55]!==M?(N=(0,Z.jsxs)(me,{children:[A,j,M]}),t[53]=A,t[54]=j,t[55]=M,t[56]=N):N=t[56];let P;return t[57]!==N||t[58]!==S?(P=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[S,N]}),t[57]=N,t[58]=S,t[59]=P):P=t[59],P}function Ie(e,t){return(0,Z.jsx)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(oe,{className:`h-4 w-2/3`}),(0,Z.jsx)(oe,{className:`mt-2 h-3 w-1/2`})]}),(0,Z.jsx)(oe,{className:`h-7 w-20 rounded-md`})]})},t)}function Le(e){return!e}function Re(e){return e.expired||e.revoked}function ze(e){return!e.expired&&!e.revoked}function Be(e){return!e.expired&&!e.revoked}var Ve={expanded:!0,path:``,isDirectory:!1,agentId:``,ttlMs:864e5,maxViews:null,description:``,directoryMode:`browse`,creating:!1,result:null,errorMsg:null,resultDialogOpen:!1,pickerOpen:!1};function He({t:e,onCreated:t}){let[n,r]=(0,W.useReducer)(F,Ve),{expanded:i,path:a,isDirectory:c,agentId:d,ttlMs:m,maxViews:h,description:g,directoryMode:_,creating:v,result:y,errorMsg:b,resultDialogOpen:x,pickerOpen:S}=n,ee=(0,W.useCallback)(async()=>{if(a.trim()){r({type:`patch`,patch:{creating:!0,errorMsg:null,result:null}});try{r({type:`patch`,patch:{result:(await ae({path:a.trim(),ttlMs:m,maxViews:h,description:g.trim()||void 0,...d?{agentId:d}:{},...c?{kind:`directory`,directoryMode:_}:{}})).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}})}}},[a,c,d,m,h,g,_,t]),C=(0,W.useCallback)(()=>{r({type:`patch`,patch:{path:``,isDirectory:!1,agentId:``,description:``,maxViews:null,ttlMs:864e5,directoryMode:`browse`,result:null,errorMsg:null}})},[]);return i?(0,Z.jsxs)(me,{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:f(`flex min-w-0 flex-1 items-center gap-2 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm`,a?`text-fg`:`text-fg-subtle`),children:a?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,children:c?`📁`:`📄`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:a,children:a})]}):(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)(R,{className:`size-4`}),a?e.pathBrowseChange:e.pathBrowse]})]})]}),c?(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)(o,{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:_,onChange:e=>r({type:`patch`,patch:{directoryMode:e.target.value===`zip-only`?`zip-only`:`browse`}}),children:[(0,Z.jsx)(s,{value:`browse`,children:e.directoryModeBrowse}),(0,Z.jsx)(s,{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)(o,{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:m,onChange:e=>r({type:`patch`,patch:{ttlMs:Number(e.target.value)}}),children:je.map(t=>(0,Z.jsx)(s,{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)(o,{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:h??`unlimited`,onChange:e=>r({type:`patch`,patch:{maxViews:e.target.value===`unlimited`?null:Number(e.target.value)}}),children:[(0,Z.jsx)(s,{value:`unlimited`,children:e.maxViewsUnlimited}),(0,Z.jsx)(s,{value:`1`,children:`1`}),(0,Z.jsx)(s,{value:`5`,children:`5`}),(0,Z.jsx)(s,{value:`10`,children:`10`}),(0,Z.jsx)(s,{value:`50`,children:`50`}),(0,Z.jsx)(s,{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:g,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:v||!a.trim(),onClick:()=>void ee(),children:[v?(0,Z.jsx)(l,{className:`size-4 animate-spin`}):(0,Z.jsx)(u,{className:`size-4`}),v?e.creating:e.createButton]}),(0,Z.jsx)(p,{type:`button`,variant:`ghost`,onClick:()=>{C(),r({type:`patch`,patch:{expanded:!1}})},children:e.cancel})]}),b&&(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:b})]}),(0,Z.jsx)(j,{open:x,onOpenChange:e=>{r({type:`patch`,patch:{resultDialogOpen:e,...e?{}:{result:null}}})},result:y}),(0,Z.jsx)(Ce,{open:S,onOpenChange:e=>r({type:`patch`,patch:{pickerOpen:e}}),initialPath:a||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)(u,{className:`size-4`}),e.createTitle]})}var Ue={revokeOpen:!1,revoking:!1,linksOpen:!1,urlCopied:!1,copyFailed:!1,extending:!1};function We({share:e,t,language:n,onRevoked:r,onExtended:i}){let[o,s]=(0,W.useReducer)(F,Ue),{revokeOpen:u,revoking:d,linksOpen:m,urlCopied:g,copyFailed:_,extending:v}=o,y=!e.expired&&!e.revoked,b=e.revoked?t.statusRevoked:e.expired?t.statusExpired:t.statusActive,x=e.revoked?`text-red-600 dark:text-red-400`:e.expired?`text-fg-subtle`:`text-emerald-600 dark:text-emerald-400`,S=(0,W.useCallback)(async()=>{s({type:`patch`,patch:{revokeOpen:!1,revoking:!0}});try{await I(e.id),r()}catch{}finally{s({type:`patch`,patch:{revoking:!1}})}},[e.id,r]),ee=(0,W.useCallback)(async()=>{if(s({type:`patch`,patch:{linksOpen:!0,copyFailed:!1}}),!await h(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]),C=(0,W.useCallback)(async()=>{s({type:`patch`,patch:{extending:!0}});try{await A(e.id,864e5),i()}catch{}finally{s({type:`patch`,patch:{extending:!1}})}},[e.id,i]),w=`share-links-${e.id}`;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:f(`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":m,"aria-controls":w,onClick:()=>s({type:`patch`,patch:{linksOpen:!m}}),children:[(0,Z.jsx)(P,{className:f(`mt-0.5 size-4 shrink-0 text-fg-muted transition-transform`,m?`rotate-0`:`-rotate-90`),"aria-hidden":!0}),e.kind===`note`?(0,Z.jsx)(O,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}):(0,Z.jsx)(R,{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:f(`text-xs font-medium`,x),children:b})]}),(0,Z.jsx)(`p`,{className:`truncate text-xs text-fg-subtle`,children:e.kind===`note`?n===`zh`?`笔记快照 · 版本 ${e.snapshotRevision??1}`:`Note snapshot · revision ${e.snapshotRevision??1}`: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:ke(e.fileSize)}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(L,{className:`size-3`}),e.expired?n===`zh`?`已过期`:`expired`:Ae(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:y&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(p,{type:`button`,variant:`ghost`,className:`px-2 py-1`,title:t.copyUrl,onClick:()=>void ee(),children:g?(0,Z.jsx)(a,{className:`size-3.5 text-emerald-500`}):(0,Z.jsx)(c,{className:`size-3.5`})}),(0,Z.jsx)(p,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:()=>void C(),disabled:v,title:t.extend,children:v?(0,Z.jsx)(l,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(L,{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:d,children:d?(0,Z.jsx)(l,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(B,{className:`size-3.5`})})]})})]}),y&&m?(0,Z.jsxs)(`div`,{id:w,className:`mt-3 bg-surface-base/45 py-3 pl-7 pr-3`,children:[(0,Z.jsx)(z,{shareUrl:e.shareUrl,lanUrl:e.lanUrl,reachability:e.reachability,compact:!0}),_?(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)(k,{reachability:e.reachability})})]}):null]}),(0,Z.jsx)(N,{open:u,title:t.revokeConfirmTitle,description:t.revokeConfirmBody,confirmLabel:t.revokeConfirmLabel,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void S(),onCancel:()=>s({type:`patch`,patch:{revokeOpen:!1}})})]})}function Ge({t:e,onCleaned:t}){let[n,r]=(0,W.useState)(!1),[i,a]=(0,W.useState)(!1),o=(0,W.useCallback)(async()=>{r(!1),a(!0);try{await D(),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)(B,{className:`size-3.5`}),e.cleanExpired]})}),(0,Z.jsx)(N,{open:n,title:e.cleanExpiredConfirmTitle,description:e.cleanExpiredConfirmBody,confirmLabel:e.cleanExpiredConfirmLabel,cancelLabel:e.cancel,destructive:!0,onConfirm:()=>void o(),onCancel:()=>r(!1)})]})}export{Me as SharesSettingsPanel};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{o as t,r as n}from"./locale-store-DqJz-cOR.js";import{br as r}from"./index-Csccu8sa.js";var i=e({reloadSkills:()=>a});async function a(){let e=await t(n(`/api/skills/reload`),{method:`POST`});if(!e.ok)throw Error(await r(e))}export{i as n,a as 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{d as i,l as a,p as o,t as s}from"./chunk-KS7C4IRE-BaASWQor.js";import{n as c,r as l}from"./popover-select-CccGri5Y.js";import{t as u}from"./circle-check-C23XjkUj.js";import{t as d}from"./ellipsis-0k4rZLoy.js";import{t as f}from"./external-link-DjqjBmc3.js";import{d as p,p as m,t as h}from"./markdown-view-CTB9u15e.js";import{t as g}from"./x-B_N4OPjy.js";import{t as _}from"./cn-JdwAhgNB.js";import{t as v}from"./button-CSEbl4zT.js";import{l as ee,n as te}from"./locale-store-DqJz-cOR.js";import{i as y,n as ne,o as re,r as ie,s as ae,t as oe}from"./dist-BPoKqzeH.js";import{$ as b,$c as se,B as ce,Bn as le,Br as x,Fi as ue,Gr as S,Hn as C,Hr as de,I as fe,Ii as w,J as pe,Kr as me,L as he,P as ge,Pi as _e,Q as ve,Ql as T,Sl as ye,Ur as E,Vn as D,Vr as be,W as xe,Wr as O,X as k,Xa as A,Ya as j,_c as M,at as N,do as P,el as F,ka as Se,n as Ce,sc as we,tc as Te,wi as Ee,xl as De}from"./index-Csccu8sa.js";import{t as Oe}from"./date-picker-BPuRtwKt.js";import{t as ke}from"./dependency-picker-BNC_W7wI.js";var I=e(t(),1),L=n();function Ae(e,t,n,r){return!!(e&&t!==e.version&&n!==e.value&&r!==n)}function je(e,t){let n={...e.task};t.title!==void 0&&(n.title=t.title),t.priority!==void 0&&(n.priority=t.priority);for(let e of[`body`,`projectId`,`milestoneId`,`parentTaskId`,`dueAt`,`ownerId`]){let r=t[e];r!==void 0&&(r===null?delete n[e]:Object.assign(n,{[e]:r}))}return n.version+=1,n.updatedAt=Date.now(),{...e,task:n}}var R=r();function z(e,t){return(t===`zh`?{backlog:`待规划`,ready:`就绪`,active:`进行中`,review:`待验收`,closed:`已完成`}:{backlog:`Backlog`,ready:`Ready`,active:`Active`,review:`Review`,closed:`Completed`})[e]}function Me(){let e=(0,L.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,R.jsxs)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[(0,R.jsx)(A,{className:`h-32 rounded-2xl`}),(0,R.jsx)(A,{className:`h-52 rounded-2xl`}),(0,R.jsx)(A,{className:`h-40 rounded-2xl`})]}),e[0]=t):t=e[0],t}function Ne(e){if(e===void 0)return``;let t=new Date(e);return new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,10)}function Pe(e){return e?new Date(`${e}T23:59:59.999`).getTime():null}var B=[`backlog`,`ready`,`active`,`review`,`closed`],Fe=[`low`,`normal`,`high`,`critical`],Ie=(0,I.memo)(function(e){let t=(0,L.c)(20),{value:n,disabled:r,canMove:i,canApprove:a,canReopen:o,language:s,label:u,onChange:d}=e,f;t[0]!==a||t[1]!==i||t[2]!==o||t[3]!==n?(f=e=>e!==n&&(e===`closed`?!a:n===`closed`?!o:!i),t[0]=a,t[1]=i,t[2]=o,t[3]=n,t[4]=f):f=t[4];let p=f,m;t[5]===u?m=t[6]:(m=(0,R.jsx)(`span`,{children:u}),t[5]=u,t[6]=m);let h;t[7]===d?h=t[8]:(h=e=>d(e.target.value),t[7]=d,t[8]=h);let g;t[9]!==s||t[10]!==p?(g=B.map(e=>(0,R.jsx)(l,{value:e,disabled:p(e),children:z(e,s)},e)),t[9]=s,t[10]=p,t[11]=g):g=t[11];let _;t[12]!==r||t[13]!==h||t[14]!==g||t[15]!==n?(_=(0,R.jsx)(c,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:h,children:g}),t[12]=r,t[13]=h,t[14]=g,t[15]=n,t[16]=_):_=t[16];let v;return t[17]!==m||t[18]!==_?(v=(0,R.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[m,_]}),t[17]=m,t[18]=_,t[19]=v):v=t[19],v}),Le=(0,I.memo)(function(e){let t=(0,L.c)(14),{value:n,disabled:r,label:i,labels:a,onChange:o}=e,s;t[0]===i?s=t[1]:(s=(0,R.jsx)(`span`,{children:i}),t[0]=i,t[1]=s);let u;t[2]===o?u=t[3]:(u=e=>o(e.target.value),t[2]=o,t[3]=u);let d;t[4]===a?d=t[5]:(d=Fe.map(e=>(0,R.jsx)(l,{value:e,children:a[e]},e)),t[4]=a,t[5]=d);let f;t[6]!==r||t[7]!==u||t[8]!==d||t[9]!==n?(f=(0,R.jsx)(c,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:u,children:d}),t[6]=r,t[7]=u,t[8]=d,t[9]=n,t[10]=f):f=t[10];let p;return t[11]!==s||t[12]!==f?(p=(0,R.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[s,f]}),t[11]=s,t[12]=f,t[13]=p):p=t[13],p}),Re=(0,I.memo)(function(e){let t=(0,L.c)(10),{value:n,disabled:r,label:i,onChange:a}=e,o;t[0]===i?o=t[1]:(o=(0,R.jsx)(`span`,{children:i}),t[0]=i,t[1]=o);let s;t[2]!==r||t[3]!==i||t[4]!==a||t[5]!==n?(s=(0,R.jsx)(Oe,{disabled:r,value:n,onChange:a,ariaLabel:i}),t[2]=r,t[3]=i,t[4]=a,t[5]=n,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,R.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}),ze=(0,I.memo)(function(e){let t=(0,L.c)(17),{value:n,disabled:r,label:i,unassignedLabel:a,agents:o,onChange:s}=e,u;t[0]===i?u=t[1]:(u=(0,R.jsx)(`span`,{children:i}),t[0]=i,t[1]=u);let d;t[2]===s?d=t[3]:(d=e=>s(e.target.value),t[2]=s,t[3]=d);let f;t[4]===a?f=t[5]:(f=(0,R.jsx)(l,{value:``,disabled:!0,children:a}),t[4]=a,t[5]=f);let p;t[6]===o?p=t[7]:(p=o.map(nt),t[6]=o,t[7]=p);let m;t[8]!==r||t[9]!==d||t[10]!==f||t[11]!==p||t[12]!==n?(m=(0,R.jsxs)(c,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:d,children:[f,p]}),t[8]=r,t[9]=d,t[10]=f,t[11]=p,t[12]=n,t[13]=m):m=t[13];let h;return t[14]!==u||t[15]!==m?(h=(0,R.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[u,m]}),t[14]=u,t[15]=m,t[16]=h):h=t[16],h}),Be=(0,I.memo)(function(e){let t=(0,L.c)(8),{candidates:n,selected:r,disabled:i,labels:a,onChange:o}=e,s;t[0]===r?s=t[1]:(s=r.map(G),t[0]=r,t[1]=s);let c;return t[2]!==n||t[3]!==i||t[4]!==a||t[5]!==o||t[6]!==s?(c=(0,R.jsx)(ke,{borderless:!0,candidates:n,selectedIds:s,disabled:i,onChange:o,labels:a}),t[2]=n,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c):c=t[7],c},(e,t)=>e.disabled===t.disabled&&e.labels===t.labels&&e.onChange===t.onChange&&e.candidates.length===t.candidates.length&&e.candidates.every((e,n)=>e.id===t.candidates[n]?.id&&e.title===t.candidates[n]?.title)&&e.selected.length===t.selected.length&&e.selected.every((e,n)=>e.id===t.selected[n]?.id&&e.title===t.selected[n]?.title)),Ve=`xopc.taskDetail.chatPanelPercent`,He=42;function Ue(e,t){let n=Math.max(30,352/Math.max(t,1)*100),r=Math.min(60,(t-480)/Math.max(t,1)*100);return r<n?He:Math.min(r,Math.max(n,e))}function We(){try{let e=Number(window.localStorage.getItem(Ve));return Number.isFinite(e)&&e>=30&&e<=60?e:He}catch{return He}}function Ge(e){return e.task.phase===`closed`?e.task.resolution===`done`?`completed`:`ended`:e.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`)?`needsUser`:e.operationalState===`idle`?e.task.phase===`backlog`?`captured`:e.task.phase===`ready`?`ready`:e.task.phase===`review`?`review`:`paused`:e.operationalState}function V(e){let t=(0,L.c)(9),{items:n,empty:r,verificationByCriterion:i}=e;if(n.length===0){let e;return t[0]===r?e=t[1]:(e=(0,R.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:r}),t[0]=r,t[1]=e),e}let a;if(t[2]!==n||t[3]!==i){let e;t[5]===i?e=t[6]:(e=e=>{let t=i?.get(e)??`unverified`;return(0,R.jsxs)(`li`,{className:`flex gap-2 text-sm leading-6 text-fg`,children:[(0,R.jsx)(t===`passed`?u:t===`failed`?ye:De,{className:t===`passed`?`mt-1 size-4 shrink-0 text-success`:t===`failed`?`mt-1 size-4 shrink-0 text-danger`:`mt-1 size-4 shrink-0 text-fg-subtle`}),(0,R.jsx)(`span`,{children:e})]},e)},t[5]=i,t[6]=e),a=n.map(e),t[2]=n,t[3]=i,t[4]=a}else a=t[4];let o;return t[7]===a?o=t[8]:(o=(0,R.jsx)(`ul`,{className:`space-y-2`,children:a}),t[7]=a,t[8]=o),o}function Ke({taskId:e,presentation:t,backgroundPath:n,onDeleted:r}){let[i]=o(),c=a(),l=te(e=>e.language),g=ee(e=>e.token),y=(0,I.useMemo)(()=>b(l),[l]),ne=P(e=>e.setPageHeader),re=P(e=>e.clearPageHeader),ie=w(e=>e.open),ae=w(e=>e.sessionKeyOverride),oe=w(e=>e.openForSession),ue=me(e=>e.setOpen),{data:C,error:ye,mutate:A,lastChange:De,conversationLoading:Oe,conversationError:ke}=ge(e),[L,z]=(0,I.useState)(null),[B,Fe]=(0,I.useState)(()=>new Set),[Ke,qe]=(0,I.useState)([]),[H,Je]=(0,I.useState)(null),[Ye,Xe]=(0,I.useState)([]),[Ze,U]=(0,I.useState)(!1),[Qe,$e]=(0,I.useState)(``),[et,W]=(0,I.useState)(!1),[tt,nt]=(0,I.useState)(``),[G,rt]=(0,I.useState)(We),[it,at]=(0,I.useState)(!1),ot=(0,I.useRef)(null),st=(0,I.useRef)(!1),ct=(0,I.useRef)(!1),lt=(0,I.useRef)(``),ut=(0,I.useRef)(null),dt=(0,I.useRef)(null),ft=(0,I.useRef)(null),pt=(0,I.useRef)(C),[mt,K]=(0,I.useState)(null),[ht,gt]=(0,I.useState)(null),[_t,vt]=(0,I.useState)(!1),yt=(0,I.useMemo)(()=>({link:y.linkDependencies,linked:y.linkedDependencies,searchPlaceholder:y.dependencySearchPlaceholder,noMatches:y.noDependencyMatches,noCandidates:y.noDependencyCandidates,remove:y.removeDependency}),[y.dependencySearchPlaceholder,y.linkDependencies,y.linkedDependencies,y.noDependencyCandidates,y.noDependencyMatches,y.removeDependency]),bt=C?.dependencies.map(e=>`${e.id}:${e.title}`).join(`\0`)??``,xt=(0,I.useMemo)(()=>p(i.get(`returnTo`),`/`,[`/projects`,`/chat`,`/notes`,`/tasks`]),[i]);pt.current=C;let q=(0,I.useCallback)((e,t)=>{Fe(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]);(0,I.useEffect)(()=>{z(null),K(null),U(!1),W(!1),gt(null),vt(!1)},[e]),(0,I.useEffect)(()=>{let e=!0;return j().then(t=>{e&&Xe(t.items)}).catch(()=>void 0),()=>{e=!1}},[g]),(0,I.useEffect)(()=>{if(!De||De.source===`user`)return;gt(De);let e=window.setTimeout(()=>gt(null),3500);return()=>window.clearTimeout(e)},[De]),(0,I.useEffect)(()=>{let t=C?.task.projectId,n=C?.dependencies??[];if(!t){ft.current=null,Je(null),qe(n);return}ft.current!==t&&(ft.current=t,Je(null));let r=!0;return Se(t).then(t=>{if(!r)return;Je(t.project.name);let i=new Map;for(let r of[...t.tasks,...n])r.id!==e&&i.set(r.id,{id:r.id,title:r.title});qe([...i.values()])}).catch(()=>{r&&qe(n)}),()=>{r=!1}},[bt,C?.task.projectId,e]);let J=(0,I.useCallback)(async(t,n=`command`)=>{let r=pt.current;if(r){q(n,!0),z(null);try{await A(await he(e,t,r.task.version),{revalidate:!1})}catch{z(y.actionFailed)}finally{q(n,!1)}}},[y.actionFailed,A,q,e]),Y=(0,I.useCallback)(async(t,n)=>{let r=pt.current;if(!r)return!1;n&&q(n,!0),z(null);try{return await A(k(e,t,r.task.version),{optimisticData:je(r,t),populateCache:!0,revalidate:!1,rollbackOnError:!0}),!0}catch{return z(y.actionFailed),!1}finally{n&&q(n,!1)}},[y.actionFailed,A,q,e]),St=async()=>{if(!C)return;if(st.current){st.current=!1;return}let e=Qe.trim(),t=ut.current;if(Ae(t,C.task.version,C.task.title,e)){K(`title`);return}if(!e||e===C.task.title){$e(C.task.title),U(!1);return}await Y({title:e})&&(K(null),U(!1))},Ct=async()=>{if(!C)return;if(ct.current){ct.current=!1;return}let e=tt.trim(),t=dt.current;if(Ae(t,C.task.version,C.task.body??``,e)){K(`description`);return}if(tt===lt.current||e===(C.task.body??``).trim()){W(!1);return}await Y({body:e||null})&&(K(null),W(!1))},wt=(0,I.useCallback)(async e=>{let t=pt.current;if(!(!t||e===t.task.phase)){if(t.task.phase===`closed`){await J({type:`reopen`,phase:e===`closed`?`ready`:e},`phase`);return}if(e===`closed`){await J({type:`close`,resolution:`done`},`phase`);return}await J({type:`move`,phase:e},`phase`)}},[J]),Tt=(0,I.useCallback)(e=>{Y({priority:e},`priority`)},[Y]),Et=(0,I.useCallback)(e=>{Y({dueAt:Pe(e)},`dueAt`)},[Y]),Dt=(0,I.useCallback)(e=>{rt(e);try{window.localStorage.setItem(Ve,String(e))}catch{}},[]),Ot=(0,I.useCallback)(e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`&&e.key!==`Home`)return;e.preventDefault();let t=ot.current?.clientWidth??0;Dt(Ue(e.key===`Home`?He:G+(e.key===`ArrowLeft`?2:-2),t))},[G,Dt]),kt=(0,I.useCallback)(e=>{if(!window.matchMedia(`(min-width: 1024px)`).matches)return;let t=ot.current;if(!t)return;e.preventDefault();let n=e.currentTarget,r=e.pointerId;n.setPointerCapture(r),at(!0);let i=G,a=0,o=()=>{a=0,t.style.setProperty(`--task-chat-panel-width`,`${i}%`)},s=e=>{let n=t.getBoundingClientRect();i=Ue((n.right-e.clientX)/n.width*100,n.width),a===0&&(a=window.requestAnimationFrame(o))},c=()=>{a!==0&&(window.cancelAnimationFrame(a),o());try{n.releasePointerCapture(r)}catch{}at(!1),Dt(i),window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c)};window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,c)},[G,Dt]),At=(0,I.useCallback)(async t=>{let n=pt.current;if(n){q(`dependencies`,!0),z(null);try{await A(await ve(e,t,n.task.version),{revalidate:!1})}catch{z(y.dependencyUpdateFailed)}finally{q(`dependencies`,!1)}}},[y.dependencyUpdateFailed,A,q,e]),jt=(0,I.useCallback)(async t=>{let n=pt.current;if(!(!n||!t||t===n.conversation.currentExecutorAgentId)){q(`delegateAgentId`,!0),z(null);try{await A(await xe(e,t,n.task.version),{revalidate:!1})}catch{z(y.actionFailed)}finally{q(`delegateAgentId`,!1)}}},[y.actionFailed,A,q,e]),Mt=(0,I.useCallback)(async()=>{q(`delete`,!0),z(null);try{await ce(e),r?r():c(xt,{replace:!0})}catch(e){z(e instanceof Error?e.message:y.actionFailed)}finally{q(`delete`,!1)}},[y.actionFailed,c,r,xt,q,e]);if((0,I.useLayoutEffect)(()=>{if(t!==`modal`)return ne({startExtra:(0,R.jsx)(s,{to:xt,className:`flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":y.backToWork,children:(0,R.jsx)(T,{className:`size-4`})}),main:C?(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`p`,{className:`truncate text-sm font-semibold text-fg`,children:H?`${H} / ${y.taskLabel}`:y.taskLabel}),(0,R.jsx)(`p`,{className:`text-xs text-fg-muted`,children:y.detailStatuses[Ge(C)]})]}):null,end:null}),re},[re,y.backToWork,y.detailStatuses,y.taskLabel,C,t,H,xt,ne]),ye&&!C)return(0,R.jsx)(`div`,{className:t===`modal`?`p-5 text-sm text-danger`:`mx-auto max-w-3xl p-6 text-sm text-danger`,children:y.taskNotFound});if(!C)return(0,R.jsx)(`div`,{className:t===`modal`?`p-5`:`mx-auto max-w-4xl p-4 sm:p-6`,children:(0,R.jsx)(Me,{})});let Nt=C.waits[0],Pt=Nt?.kind===`paused`?Nt:void 0,X=C.receipts[0],Ft=y.detailStatuses[Ge(C)],It=y.detailStatusDescriptions[Ge(C)],Lt=C.task.body?.trim()||C.task.contract?.objective.trim(),Rt=new Map(X?.verification.checks.map(e=>[e.criterion,e.status])),zt=C.allowedCommands.includes(`mark_ready`),Bt=C.allowedCommands.includes(`start`),Vt=C.allowedCommands.includes(`add_wait`),Ht=C.task.phase===`review`&&C.allowedCommands.includes(`close`),Ut=C.allowedCommands.includes(`reopen`),Z=C.conversation.activeSessionKey,Wt=C.conversation.currentExecutorAgentId??C.task.delegateAgentId??C.task.ownerId,Gt=Ye.find(e=>e.id===Wt),Kt=!!(Z&&ie&&ae===Z),qt=C.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`),Jt=C.task.contract?.acceptanceCriteria??[],Yt=Jt.filter(e=>Rt.get(e)===`passed`).length,Xt=C.task.contract?.expectedOutputs??[],Zt=C.task.contract?.constraints??[],Qt=C.task.contract?.approvalRequired??[],$t=C.task.contract?.assumptions??[],en=C.task.contract?.risks??[],Q=(...e)=>!!ht?.changedFields.some(t=>e.includes(t)),tn=e=>t===`modal`&&n?D(n,e):m(`/tasks/${e}`,xt),nn=C.allowedCommands.includes(`move`),$=B.has(`command`),rn=B.has(`delete`),an=C.runs.find(e=>[`queued`,`running`,`waiting`,`verifying`].includes(e.status)),on=an!==void 0,sn=(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[zt?(0,R.jsxs)(v,{variant:`primary`,disabled:$,onClick:()=>void J({type:`mark_ready`}),children:[(0,R.jsx)(Te,{className:`size-4`}),y.scheduleTask]}):null,Pt?(0,R.jsxs)(v,{variant:`primary`,disabled:$,onClick:()=>void J({type:`resolve_wait`,waitId:Pt.id}),children:[(0,R.jsx)(Te,{className:`size-4`}),y.resumeTask]}):null,!Nt&&Bt&&Wt?(0,R.jsxs)(v,{variant:`primary`,disabled:$,onClick:()=>void J({type:`start`,executor:{kind:`agent`,agentId:Wt}}),children:[(0,R.jsx)(Te,{className:`size-4`}),y.runTask]}):null,Ht?(0,R.jsxs)(v,{variant:`primary`,disabled:$,onClick:()=>void J({type:`close`,resolution:`done`}),children:[(0,R.jsx)(u,{className:`size-4`}),y.approveTask]}):null,Ut?(0,R.jsxs)(v,{variant:`primary`,disabled:$,onClick:()=>void J({type:`reopen`,phase:`ready`}),children:[(0,R.jsx)(Te,{className:`size-4`}),y.reopenTask]}):null,!Nt&&Vt?(0,R.jsxs)(v,{variant:`secondary`,className:`border-0 bg-surface-hover shadow-none`,disabled:$,onClick:()=>void J({type:`add_wait`,wait:{kind:`paused`,reason:`Paused by user`,condition:{}}}),children:[(0,R.jsx)(we,{className:`size-4`}),y.pauseTask]}):null,(0,R.jsxs)(E,{children:[(0,R.jsx)(S,{asChild:!0,children:(0,R.jsx)(v,{type:`button`,variant:`ghost`,className:`size-9 p-0`,disabled:$||rn,"aria-label":y.moreActions,children:(0,R.jsx)(d,{className:`size-4`,"aria-hidden":!0})})}),(0,R.jsx)(de,{children:(0,R.jsxs)(x,{align:`end`,sideOffset:6,className:`z-[100] min-w-44 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:[an?(0,R.jsx)(be,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>{q(`command`,!0),z(null),A(fe(e,an.id,an.version),{revalidate:!1}).catch(()=>z(y.actionFailed)).finally(()=>q(`command`,!1))},children:y.cancelActiveRun}):null,an?(0,R.jsx)(O,{className:`my-1 h-px bg-edge`}):null,C.task.phase===`closed`?null:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(be,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>void J({type:`close`,resolution:`cancelled`}),children:y.cancelTask}),(0,R.jsx)(O,{className:`my-1 h-px bg-edge`})]}),(0,R.jsx)(be,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>{if(on){z(y.deleteActiveTaskBlocked);return}vt(!0)},children:y.deleteTask})]})})]})]});return(0,R.jsxs)(`div`,{ref:ot,className:`${t===`modal`?`flex h-full min-h-0 flex-col lg:flex-row`:`flex min-h-[calc(100dvh-8rem)] flex-col overflow-hidden lg:flex-row`} ${it?`lg:cursor-col-resize lg:select-none`:``}`,style:{"--task-chat-panel-width":`${G}%`},children:[(0,R.jsxs)(`section`,{className:`task-detail-scroll min-w-0 flex-1 overflow-y-auto overscroll-contain p-5 sm:p-6`,children:[(0,R.jsxs)(`header`,{className:_(`px-4 pb-5`,Q(`title`)&&`task-detail-live-update`),children:[(0,R.jsx)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[H?(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,R.jsx)(F,{className:`size-3.5`,"aria-hidden":!0}),H]}):null,(0,R.jsx)(`span`,{children:`/`}),(0,R.jsx)(`span`,{children:y.taskLabel}),ht?(0,R.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,role:`status`,children:ht.source===`agent`?l===`zh`?`Agent 刚刚更新`:`Updated by Agent`:l===`zh`?`执行结果已同步`:`Execution result synced`}):null]}),Ze?(0,R.jsx)(`input`,{autoFocus:!0,"data-task-inline-editor":!0,value:Qe,onChange:e=>$e(e.target.value),onBlur:()=>void St(),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),st.current=!0,$e(C.task.title),U(!1),queueMicrotask(()=>{st.current=!1}))},className:`mt-3 w-full max-w-3xl rounded-lg bg-surface-hover px-3 py-2 text-2xl font-semibold leading-8 text-fg outline-none ring-2 ring-accent/30 focus:ring-accent/60`}):(0,R.jsx)(`button`,{type:`button`,className:`mt-3 block max-w-3xl rounded-lg text-left outline-none hover:bg-surface-hover focus-visible:bg-surface-hover`,onClick:()=>{ut.current={value:C.task.title,version:C.task.version},K(null),$e(C.task.title),U(!0)},children:(0,R.jsx)(`h1`,{className:`text-2xl font-semibold leading-8 text-fg`,children:C.task.title})}),mt===`title`?(0,R.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,R.jsx)(`span`,{children:l===`zh`?`Agent 在你编辑期间更新了标题。`:`The Agent updated the title while you were editing.`}),(0,R.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{$e(C.task.title),K(null),U(!1)},children:l===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,R.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void Y({title:Qe.trim()}).then(e=>{e&&(K(null),U(!1))}),children:l===`zh`?`保留我的修改`:`Keep my changes`})]}):null]})}),L?(0,R.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:L}):null]}),(0,R.jsxs)(`div`,{className:`mt-5 flex flex-col gap-5`,children:[(0,R.jsxs)(`main`,{className:`order-2 min-w-0 space-y-5`,children:[(0,R.jsxs)(`section`,{className:_(`rounded-xl bg-surface-panel p-4`,Q(`body`)&&`task-detail-live-update`),children:[(0,R.jsx)(`h2`,{className:`font-medium text-fg`,children:y.taskDescription}),et?(0,R.jsx)(`textarea`,{autoFocus:!0,"data-task-inline-editor":!0,rows:6,value:tt,onChange:e=>nt(e.target.value),onBlur:()=>void Ct(),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),ct.current=!0,nt(C.task.body??C.task.contract?.objective??``),W(!1),queueMicrotask(()=>{ct.current=!1}))},className:`mt-3 w-full resize-y rounded-lg bg-surface-hover px-3 py-2 text-sm leading-6 text-fg outline-none ring-2 ring-accent/20 focus:ring-accent/50`}):(0,R.jsx)(`button`,{type:`button`,className:`-mx-1 mt-2 block w-[calc(100%+0.5rem)] rounded-lg px-1 py-1 text-left outline-none hover:bg-surface-hover focus-visible:bg-surface-hover`,onClick:()=>{let e=C.task.body??C.task.contract?.objective??``;lt.current=e,dt.current={value:C.task.body??``,version:C.task.version},K(null),nt(e),W(!0)},children:(0,R.jsx)(`span`,{className:`whitespace-pre-wrap text-sm leading-6 text-fg-muted`,children:Lt&&Lt!==C.task.title?Lt:y.noTaskDescription})}),mt===`description`?(0,R.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,R.jsx)(`span`,{children:l===`zh`?`Agent 在你编辑期间更新了描述。`:`The Agent updated the description while you were editing.`}),(0,R.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{nt(C.task.body??``),K(null),W(!1)},children:l===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,R.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void Y({body:tt.trim()||null}).then(e=>{e&&(K(null),W(!1))}),children:l===`zh`?`保留我的修改`:`Keep my changes`})]}):null]}),C.attention.length>0?(0,R.jsxs)(`section`,{className:_(`rounded-xl bg-warning/10 p-4`,Q(`attention`)&&`task-detail-live-update`),children:[(0,R.jsx)(`h3`,{className:`font-medium text-fg`,children:qt?y.needsAttention:y.waitingStatus}),(0,R.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm text-fg-muted`,children:C.attention.map((e,t)=>(0,R.jsx)(`li`,{children:e.summary},`${e.kind}-${t}`))})]}):null,(0,R.jsxs)(`section`,{className:_(`rounded-xl bg-surface-panel p-4`,Q(`contract`)&&`task-detail-live-update`),children:[(0,R.jsx)(`h2`,{className:`font-medium text-fg`,children:y.taskDefinition}),(0,R.jsxs)(`div`,{className:`mt-5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:y.successDefinition}),Jt.length>0?(0,R.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:y.criteriaProgress.replace(`{{verified}}`,String(Yt)).replace(`{{total}}`,String(Jt.length))}):null]}),(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(V,{items:Jt,empty:y.noDefinition,verificationByCriterion:Rt})})]}),Xt.length>0?(0,R.jsxs)(`div`,{className:`mt-5 rounded-lg bg-surface-hover p-4`,children:[(0,R.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:y.expectedOutputs}),(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(V,{items:Xt,empty:y.noDefinition})})]}):null,Zt.length>0?(0,R.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:y.constraints}),(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(V,{items:Zt,empty:y.noDefinition})})]}):null,Qt.length>0?(0,R.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:y.approvalRequired}),(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(V,{items:Qt,empty:y.noDefinition})})]}):null,$t.length>0?(0,R.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:y.contextAssumptions}),(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(V,{items:$t,empty:y.noDefinition})})]}):null,en.length>0?(0,R.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:y.contextRisks}),(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(V,{items:en,empty:y.noDefinition})})]}):null]}),X?(0,R.jsxs)(`section`,{className:_(`rounded-xl bg-surface-panel p-4`,Q(`runs`,`receipts`)&&`task-detail-live-update`),children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`h2`,{className:`font-medium text-fg`,children:y.latestResult}),(0,R.jsx)(h,{content:X.summary,compact:!0,className:`mt-2 text-sm leading-6 text-fg`})]}),(0,R.jsxs)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-xs text-fg-muted`,children:[y.receiptStatuses[X.status],` · `,y.verificationStatuses[X.verification.status]]})]}),X.remainingWork.length>0?(0,R.jsxs)(`div`,{className:`mt-4`,children:[(0,R.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:y.remainingWork}),(0,R.jsx)(`div`,{className:`mt-2`,children:(0,R.jsx)(V,{items:X.remainingWork,empty:y.noRemainingWork})})]}):null,X.nextAction?(0,R.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-hover p-3`,children:[(0,R.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:y.nextAction}),(0,R.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:X.nextAction})]}):null,(0,R.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(v,{className:`border-0 bg-surface-hover px-2 py-1 text-xs shadow-none`,variant:`secondary`,onClick:()=>void pe(X.runId,`helpful`),children:y.doneWell}),(0,R.jsx)(v,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>void pe(X.runId,`not_helpful`),children:y.needsFix}),X.evidence.filter(e=>e.uri).map(e=>(0,R.jsxs)(`a`,{className:`ml-auto inline-flex items-center gap-1 text-xs text-accent hover:underline`,href:e.uri,children:[(0,R.jsx)(f,{className:`size-3`}),e.title]},`${e.title}-${e.uri}`))]}),C.receipts.length>1?(0,R.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:y.executionHistory.replace(`{{count}}`,String(C.receipts.length-1))}),(0,R.jsx)(`div`,{className:`mt-3 space-y-3`,children:C.receipts.slice(1).map(e=>(0,R.jsx)(`article`,{className:`rounded-lg bg-surface-active p-3`,children:(0,R.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,R.jsx)(`p`,{className:`text-sm text-fg`,children:e.summary}),(0,R.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:y.receiptStatuses[e.status]})]})},e.runId))})]}):null]}):null,C.context.length>0?(0,R.jsxs)(`section`,{className:_(`rounded-xl bg-surface-panel p-4`,Q(`context`)&&`task-detail-live-update`),children:[(0,R.jsx)(`h2`,{className:`font-medium text-fg`,children:y.contextUsed}),(0,R.jsx)(`ul`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:C.context.map(e=>(0,R.jsxs)(`li`,{className:`min-w-0 rounded-lg bg-surface-hover p-2.5`,children:[(0,R.jsxs)(`span`,{className:`text-[11px] text-fg-subtle`,children:[y.contextRoleLabels[e.role],` · `,y.contextKindLabels[e.targetKind]]}),e.targetKind===`url`&&/^https?:\/\//.test(e.targetId)?(0,R.jsx)(`a`,{className:`mt-1 block break-all text-sm text-accent hover:underline`,href:e.targetId,target:`_blank`,rel:`noreferrer`,children:e.title??e.targetId}):(0,R.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:e.title??e.targetId})]},e.id))})]}):null]}),(0,R.jsxs)(`aside`,{className:`order-1 min-w-0 space-y-4`,children:[(0,R.jsxs)(`section`,{className:_(`rounded-xl bg-surface-subtle p-4`,Q(`phase`,`resolution`,`priority`,`dueAt`,`delegateAgentId`)&&`task-detail-live-update`),children:[(0,R.jsx)(`h2`,{className:`font-medium text-fg`,children:y.taskProperties}),(0,R.jsxs)(`div`,{className:`mt-4 grid gap-4 sm:grid-cols-2`,children:[(0,R.jsx)(Ie,{value:C.task.phase,disabled:B.has(`phase`),canMove:nn,canApprove:Ht,canReopen:Ut,language:l,label:y.taskPhase,onChange:wt}),(0,R.jsx)(Le,{value:C.task.priority,disabled:B.has(`priority`),label:y.priority,labels:y.priorityLabels,onChange:Tt}),(0,R.jsx)(Re,{value:Ne(C.task.dueAt),disabled:B.has(`dueAt`),label:y.dueDate,onChange:Et}),(0,R.jsx)(ze,{value:C.conversation.currentExecutorAgentId??``,disabled:B.has(`delegateAgentId`),label:y.executorLabel,unassignedLabel:y.unassigned,agents:Ye,onChange:jt}),H?(0,R.jsxs)(`div`,{className:`grid gap-1 text-xs text-fg-muted`,children:[(0,R.jsx)(`span`,{children:y.projectLabel}),(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5 rounded-lg bg-surface-hover px-3 py-2 text-sm text-fg`,children:[(0,R.jsx)(F,{className:`size-3.5`}),H]})]}):null]}),(0,R.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-hover p-3 text-xs leading-5 text-fg-subtle`,children:[(0,R.jsx)(`p`,{children:Ft}),(0,R.jsx)(`p`,{children:It}),(0,R.jsx)(`p`,{className:`mt-2`,children:y.updatedAt.replace(`{{date}}`,Ee(C.task.updatedAt,l))})]})]}),(0,R.jsxs)(`section`,{className:_(`rounded-xl bg-surface-panel p-4`,Q(`dependencies`)&&`task-detail-live-update`),children:[(0,R.jsx)(`h2`,{className:`font-medium text-fg`,children:y.taskRelations}),(0,R.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:y.dependencies}),(0,R.jsx)(Be,{candidates:Ke,selected:C.dependencies,disabled:B.has(`dependencies`),labels:yt,onChange:At})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:y.dependents}),C.dependents.length>0?(0,R.jsx)(`div`,{className:`space-y-1.5`,children:C.dependents.map(e=>(0,R.jsx)(s,{to:tn(e.id),className:`block rounded-lg bg-surface-hover p-2.5 text-sm text-accent hover:underline`,children:e.title},e.id))}):(0,R.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:y.noDependents})]})]})]})]})]})]}),(0,R.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":l===`zh`?`调整任务信息和 Agent 对话的宽度`:`Resize task details and Agent chat`,"aria-valuemin":30,"aria-valuemax":60,"aria-valuenow":Math.round(G),tabIndex:0,onPointerDown:kt,onKeyDown:Ot,onDoubleClick:()=>Dt(He),className:`group hidden w-2 shrink-0 cursor-col-resize touch-none items-stretch justify-center bg-surface-panel outline-none transition-colors hover:bg-surface-hover focus-visible:bg-surface-hover lg:flex ${it?`bg-surface-hover`:``}`,children:(0,R.jsx)(`div`,{className:`my-3 w-px rounded-full bg-edge-strong/70 transition-colors group-hover:bg-accent group-focus-visible:bg-accent`})}),(0,R.jsxs)(`aside`,{className:`flex min-h-[34rem] min-w-0 flex-col bg-surface-panel lg:min-h-0 lg:w-[var(--task-chat-panel-width)] lg:shrink-0`,children:[(0,R.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3 bg-surface-subtle px-4 py-3.5`,children:[(0,R.jsx)(`div`,{className:`min-w-0`,children:(0,R.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[Wt?(0,R.jsx)(N,{agentId:Wt,avatar:Gt?.avatar,size:28,className:`shrink-0`}):null,(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:l===`zh`?`Agent 执行与对话`:`Agent execution and chat`}),(0,R.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:[Gt?.name??Wt??y.unassigned,` · `,Ft]})]})]})}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[sn,Z&&t!==`modal`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(v,{type:`button`,variant:`ghost`,className:_(`h-8 shrink-0 px-2 text-xs`,Kt&&`bg-surface-hover text-fg`),"aria-label":l===`zh`?`项目文件`:`Project files`,"aria-pressed":Kt,onClick:()=>{ue(Z,!1),oe(Z)},children:[(0,R.jsx)(se,{className:`size-3.5`,"aria-hidden":!0}),l===`zh`?`文件`:`Files`]}),(0,R.jsx)(v,{asChild:!0,variant:`ghost`,className:`h-8 shrink-0 px-2 text-xs`,children:(0,R.jsxs)(s,{to:le(e),children:[(0,R.jsx)(f,{className:`size-3.5`}),l===`zh`?`全屏`:`Full screen`]})})]}):null]})]}),Z?(0,R.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,R.jsx)(Ce,{embedded:!0,sessionKey:Z,taskId:e})}):Oe?(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,R.jsxs)(`div`,{className:`max-w-xs`,children:[(0,R.jsx)(M,{className:`mx-auto size-8 animate-pulse text-fg-subtle`}),(0,R.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`正在创建任务会话`:`Creating task conversation`})]})}):ke?(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,R.jsxs)(`div`,{className:`max-w-xs`,children:[(0,R.jsx)(M,{className:`mx-auto size-8 text-danger`}),(0,R.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`任务会话创建失败`:`Could not create task conversation`}),(0,R.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:ke instanceof Error?ke.message:String(ke)})]})}):(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,R.jsxs)(`div`,{className:`max-w-xs`,children:[(0,R.jsx)(M,{className:`mx-auto size-8 text-fg-subtle`}),(0,R.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`等待任务会话`:`Waiting for a task conversation`}),(0,R.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:l===`zh`?`安排或开始任务后,Agent 的执行过程和持续对话会显示在这里。`:`Schedule or start the task to see the agent run and continue the conversation here.`})]})})]}),(0,R.jsx)(_e,{open:_t,title:y.deleteTaskTitle,description:y.deleteTaskDescription.replace(`{{title}}`,C.task.title),confirmLabel:y.confirmDeleteTask,cancelLabel:y.keepTask,destructive:!0,onConfirm:()=>{vt(!1),Mt()},onCancel:()=>vt(!1)})]})}function qe(){let e=(0,L.c)(2),{taskId:t}=i(),n=t===void 0?``:t,r;return e[0]===n?r=e[1]:(r=(0,R.jsx)(Ke,{taskId:n,presentation:`page`}),e[0]=n,e[1]=r),r}function H(e){let t=(0,L.c)(58),{taskId:n,backgroundPath:r,onClose:i}=e,a=te(tt),{data:o}=ge(n),c=o?.conversation.activeSessionKey??null,l=w(W),u=w(et),d=w($e),p=w(Qe),m=me(U),h=ue(Ze),v=ue(Xe),ee=l?u:0,b;t[0]!==i||t[1]!==v?(b=e=>{e||(v(null),i())},t[0]=i,t[1]=v,t[2]=b):b=t[2];let ce=a===`zh`?`关闭任务详情`:`Close task details`,x;t[3]!==i||t[4]!==v?(x=()=>{v(null),i()},t[3]=i,t[4]=v,t[5]=x):x=t[5];let S;t[6]!==ce||t[7]!==x?(S=(0,R.jsx)(`button`,{type:`button`,tabIndex:-1,"data-task-modal-backdrop":!0,className:`fixed inset-0 z-[80] bg-black/45 backdrop-blur-[1px]`,"aria-label":ce,onClick:x}),t[6]=ce,t[7]=x,t[8]=S):S=t[8];let de=l?`true`:`false`,fe=`${ee/2}px`,pe=`${ee}px`,he;t[9]!==fe||t[10]!==pe?(he={"--task-detail-workspace-offset":fe,"--task-detail-workspace-width":pe},t[9]=fe,t[10]=pe,t[11]=he):he=t[11];let _e=he,ve=a===`zh`?`任务详情`:`Task details`,T;t[12]===ve?T=t[13]:(T=(0,R.jsx)(ae,{className:`font-medium text-fg`,children:ve}),t[12]=ve,t[13]=T);let ye=a===`zh`?`查看并操作任务详情`:`View and manage task details`,E;t[14]===ye?E=t[15]:(E=(0,R.jsx)(y,{className:`sr-only`,children:ye}),t[14]=ye,t[15]=E);let D;t[16]!==c||t[17]!==a||t[18]!==p||t[19]!==m||t[20]!==n||t[21]!==l||t[22]!==d?(D=c?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,className:_(`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,l&&d===c&&`bg-surface-hover text-fg`),"aria-label":a===`zh`?`项目文件`:`Project files`,title:a===`zh`?`项目文件`:`Project files`,"aria-pressed":l&&d===c,onClick:()=>{m(c,!1),p(c)},children:(0,R.jsx)(se,{className:`size-4`,"aria-hidden":!0})}),(0,R.jsx)(s,{to:le(n),className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":a===`zh`?`全屏打开对话`:`Open chat full screen`,title:a===`zh`?`全屏打开对话`:`Open chat full screen`,children:(0,R.jsx)(f,{className:`size-4`,"aria-hidden":!0})})]}):null,t[16]=c,t[17]=a,t[18]=p,t[19]=m,t[20]=n,t[21]=l,t[22]=d,t[23]=D):D=t[23];let be=a===`zh`?`关闭任务详情`:`Close task details`,xe;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,R.jsx)(g,{className:`size-4`,"aria-hidden":!0}),t[24]=xe):xe=t[24];let O;t[25]===be?O=t[26]:(O=(0,R.jsx)(ne,{className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":be,children:xe}),t[25]=be,t[26]=O);let k;t[27]!==D||t[28]!==O?(k=(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[D,O]}),t[27]=D,t[28]=O,t[29]=k):k=t[29];let A;t[30]!==T||t[31]!==E||t[32]!==k?(A=(0,R.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-3 bg-surface-panel px-5 py-3.5`,children:[T,E,k]}),t[30]=T,t[31]=E,t[32]=k,t[33]=A):A=t[33];let j;t[34]!==i||t[35]!==v?(j=()=>{v(null),i()},t[34]=i,t[35]=v,t[36]=j):j=t[36];let M;t[37]!==r||t[38]!==j||t[39]!==n?(M=(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,R.jsx)(Ke,{taskId:n,presentation:`modal`,backgroundPath:r,onDeleted:j})}),t[37]=r,t[38]=j,t[39]=n,t[40]=M):M=t[40];let N;t[41]!==A||t[42]!==M||t[43]!==de||t[44]!==_e?(N=(0,R.jsxs)(ie,{className:`task-detail-modal-content fixed top-1/2 z-[90] flex h-[min(54rem,calc(100dvh-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl bg-surface-base shadow-float focus:outline-none`,"data-workspace-panel-open":de,style:_e,onEscapeKeyDown:Ye,onInteractOutside:Je,children:[A,M]}),t[41]=A,t[42]=M,t[43]=de,t[44]=_e,t[45]=N):N=t[45];let P;t[46]!==h||t[47]!==l||t[48]!==u||t[49]!==d?(P=h?(0,R.jsx)(`div`,{className:`fixed inset-y-0 left-0 z-[100] flex min-h-0 min-w-0 overflow-hidden bg-surface-panel transition-[right] duration-200 ease-out motion-reduce:transition-none`,style:{right:l?u:0},children:(0,R.jsx)(C,{allowOutsideChat:!0,sessionKey:d??void 0})}):null,t[46]=h,t[47]=l,t[48]=u,t[49]=d,t[50]=P):P=t[50];let F;t[51]!==N||t[52]!==P||t[53]!==S?(F=(0,R.jsxs)(re,{children:[S,N,P]}),t[51]=N,t[52]=P,t[53]=S,t[54]=F):F=t[54];let Se;return t[55]!==b||t[56]!==F?(Se=(0,R.jsx)(oe,{modal:!1,open:!0,onOpenChange:b,children:F}),t[55]=b,t[56]=F,t[57]=Se):Se=t[57],Se}function Je(e){let t=e.detail.originalEvent.target;t instanceof Element&&t.closest(`#app-workspace-panel, [data-task-modal-backdrop]`)&&e.preventDefault()}function Ye(e){let t=e.target;t instanceof HTMLElement&&t.closest(`[data-task-inline-editor]`)&&e.preventDefault()}function Xe(e){return e.setPath}function Ze(e){return e.path}function U(e){return e.setOpen}function Qe(e){return e.openForSession}function $e(e){return e.sessionKeyOverride}function et(e){return e.widthPx}function W(e){return e.open}function tt(e){return e.language}function nt(e){return(0,R.jsx)(l,{value:e.id,children:e.name||e.id},e.id)}function G(e){return e.id}export{H as TaskDetailModal,qe as TaskDetailPage};