@xopcai/xopc 0.0.196 → 0.0.199

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 (258) 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-BwmdJ5pv.js → activity-store-DYVN1hRp.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-B1oxPli_.js → agent-avatar-dicebear-Bt70bZjv.js} +1 -1
  5. package/dist/gateway/static/root/assets/agents-D19uNmJf.js +68 -0
  6. package/dist/gateway/static/root/assets/{api-BM1hNzjw.js → api-B8mzbAle.js} +1 -1
  7. package/dist/gateway/static/root/assets/app-management-settings-panel-B4x7JfL8.js +1 -0
  8. package/dist/gateway/static/root/assets/appearance-settings-Dwdagf-Q.js +1 -0
  9. package/dist/gateway/static/root/assets/apps-page-DkTiesxe.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-BdE4Mati.js → archive-plugin-Cv0VXKLm.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-CTzaQcLV.js → attachment-load-CgidKrXn.js} +1 -1
  12. package/dist/gateway/static/root/assets/automations-page-BR6qMOVr.js +6 -0
  13. package/dist/gateway/static/root/assets/{binary-plugins-B25zTNxl.js → binary-plugins-DN3CQgIq.js} +1 -1
  14. package/dist/gateway/static/root/assets/{block-editor-Cdrf2awF.js → block-editor-BwkSl1F_.js} +46 -46
  15. package/dist/gateway/static/root/assets/browser-settings-page-CDFQWAxI.js +8 -0
  16. package/dist/gateway/static/root/assets/browser-workflow-inputs-_ndaecsf.js +1 -0
  17. package/dist/gateway/static/root/assets/{browser-workflows-page-Wx9FrbK-.js → browser-workflows-page-C_I31wLm.js} +2 -2
  18. package/dist/gateway/static/root/assets/button-CSEbl4zT.js +1 -0
  19. package/dist/gateway/static/root/assets/capabilities-settings-panel-D41mssOq.js +7 -0
  20. package/dist/gateway/static/root/assets/{capability-presets-api-BoOzFotX.js → capability-presets-api-Dy1jZJKs.js} +1 -1
  21. package/dist/gateway/static/root/assets/capability-presets-settings-panel-BXgCyuu2.js +3 -0
  22. package/dist/gateway/static/root/assets/{channel-recipient-api-_8IiTxRB.js → channel-recipient-api-D-9qiuio.js} +1 -1
  23. package/dist/gateway/static/root/assets/channels-settings-DV5BhAeu.js +1 -0
  24. package/dist/gateway/static/root/assets/channels-status-swr-B4Rbh3bM.js +1 -0
  25. package/dist/gateway/static/root/assets/connectors-api-5FEBYguL.js +1 -0
  26. package/dist/gateway/static/root/assets/connectors-page-C_qkEN0T.js +2 -0
  27. package/dist/gateway/static/root/assets/copy-Dv6d4Dvw.js +1 -0
  28. package/dist/gateway/static/root/assets/cron-expression-SEFx5rnr.js +2 -0
  29. package/dist/gateway/static/root/assets/date-picker-D4zCUQJL.js +1 -0
  30. package/dist/gateway/static/root/assets/dependency-picker-DpQAxS2k.js +1 -0
  31. package/dist/gateway/static/root/assets/{desktop-pet-BOb8sEhN.js → desktop-pet-B_5G3lQl.js} +1 -1
  32. package/dist/gateway/static/root/assets/desktop-pet-settings-ClEyoUJe.js +1 -0
  33. package/dist/gateway/static/root/assets/directory-picker-path-field-AsFWmOjG.js +1 -0
  34. package/dist/gateway/static/root/assets/dist-BPoKqzeH.js +1 -0
  35. package/dist/gateway/static/root/assets/dist-DY4Af0fY.js +1 -0
  36. package/dist/gateway/static/root/assets/{extension-debug-page-p83TmZFd.js → extension-debug-page-C22Y2o5l.js} +1 -1
  37. package/dist/gateway/static/root/assets/{extension-page-DMQ3ovxA.js → extension-page-C61Ikawk.js} +1 -1
  38. package/dist/gateway/static/root/assets/extension-settings-page-WlWWcDFr.js +1 -0
  39. package/dist/gateway/static/root/assets/external-link-DjqjBmc3.js +1 -0
  40. package/dist/gateway/static/root/assets/form-field-width-DJw_jULe.js +1 -0
  41. package/dist/gateway/static/root/assets/gateway-config-api-ByIOMQdc.js +1 -0
  42. package/dist/gateway/static/root/assets/gateway-config-swr-jB0hAhWO.js +1 -0
  43. package/dist/gateway/static/root/assets/gateway-settings-CzzS9A17.js +1 -0
  44. package/dist/gateway/static/root/assets/{gateway-startup-retry--2njcDpC.js → gateway-startup-retry-C-fRlHCL.js} +1 -1
  45. package/dist/gateway/static/root/assets/globe-DSSGFWFn.js +1 -0
  46. package/dist/gateway/static/root/assets/heartbeat-settings-B4A_CXUL.js +1 -0
  47. package/dist/gateway/static/root/assets/home-page-FVGYYPWo.js +3 -0
  48. package/dist/gateway/static/root/assets/index-CGbKTCST.js +152 -0
  49. package/dist/gateway/static/root/assets/index-CR233S0Q.css +1 -0
  50. package/dist/gateway/static/root/assets/interaction-BmQogeqz.js +1 -0
  51. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BQb06_jl.js → keyboard-shortcuts-settings-BD_TFz0_.js} +1 -1
  52. package/dist/gateway/static/root/assets/loader-circle-CifKLtgG.js +1 -0
  53. package/dist/gateway/static/root/assets/local-app-workbench-page-BNpkigNb.js +2 -0
  54. package/dist/gateway/static/root/assets/local-apps-page-BwbUeLfm.js +1 -0
  55. package/dist/gateway/static/root/assets/{locale-store-Bjvw7jtg.js → locale-store-xULEcFVs.js} +1 -1
  56. package/dist/gateway/static/root/assets/logs-page-DXP9OQQt.js +2 -0
  57. package/dist/gateway/static/root/assets/management-settings-CW2VpqtT.js +1 -0
  58. package/dist/gateway/static/root/assets/{markdown-split-Db-KrpOQ.js → markdown-split-B1M9KO16.js} +1 -1
  59. package/dist/gateway/static/root/assets/{media-plugins-CHN66qs0.js → media-plugins-B_QlNdqZ.js} +1 -1
  60. package/dist/gateway/static/root/assets/messages-3qRsLZuX.js +3 -0
  61. package/dist/gateway/static/root/assets/{notes-page-CJtKZM0P.js → notes-page-BTbD4GmH.js} +1 -1
  62. package/dist/gateway/static/root/assets/notes-workbench-JRiq7QDW.js +4 -0
  63. package/dist/gateway/static/root/assets/page-tabs-BaEQMYm_.js +1 -0
  64. package/dist/gateway/static/root/assets/popover-select-BzdnTy3h.js +1 -0
  65. package/dist/gateway/static/root/assets/preview-open-alternatives-CeqtArlZ.js +1 -0
  66. package/dist/gateway/static/root/assets/{product-open-page--RnCc9bb.js → product-open-page-DnalBZZs.js} +1 -1
  67. package/dist/gateway/static/root/assets/project-detail-page-CjWA13aE.js +1 -0
  68. package/dist/gateway/static/root/assets/projects-page-jsCkScbG.js +1 -0
  69. package/dist/gateway/static/root/assets/remote-access-hub-CGPJTEkM.js +1 -0
  70. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-Bg1W2__k.js → runtime-tools-settings-panel-cGkBEfg4.js} +4 -4
  71. package/dist/gateway/static/root/assets/schema-form-CmsrLlxu.js +1 -0
  72. package/dist/gateway/static/root/assets/sessions-page-BBHzziMd.js +1 -0
  73. package/dist/gateway/static/root/assets/settings-advanced-gate-2cGg8-9h.js +1 -0
  74. package/dist/gateway/static/root/assets/settings-form-draft-Dy10ldo8.js +1 -0
  75. package/dist/gateway/static/root/assets/settings-form-section-DUWCbaMJ.js +1 -0
  76. package/dist/gateway/static/root/assets/{settings-loading-skeleton-BS36Mjzz.js → settings-loading-skeleton-Bvy5rdMY.js} +1 -1
  77. package/dist/gateway/static/root/assets/{settings-page-BDSd7F9Y.js → settings-page-cZSAwsRR.js} +1 -1
  78. package/dist/gateway/static/root/assets/settings-page-layout-BRQNel6r.js +1 -0
  79. package/dist/gateway/static/root/assets/settings-shell-dialog-layer-BU3UuiJr.js +1 -0
  80. package/dist/gateway/static/root/assets/setup-status-panel-Cf06b66-.js +1 -0
  81. package/dist/gateway/static/root/assets/share-preview-page-BzA2NCAH.js +2 -0
  82. package/dist/gateway/static/root/assets/shares-settings-xlNKydYY.js +1 -0
  83. package/dist/gateway/static/root/assets/skill-reload-api-C5Xu93c_.js +1 -0
  84. package/dist/gateway/static/root/assets/skills-page-Bvde7_i5.js +2 -0
  85. package/dist/gateway/static/root/assets/{skills-page.utils-CnbJncdL.js → skills-page.utils-vXSqHR7g.js} +1 -1
  86. package/dist/gateway/static/root/assets/system-settings-panel-9cQGOGCK.js +1 -0
  87. package/dist/gateway/static/root/assets/task-detail-page-Bkno4tTe.js +1 -0
  88. package/dist/gateway/static/root/assets/{theme-store-DtxpMC5S.js → theme-store-CHQRiuCF.js} +1 -1
  89. package/dist/gateway/static/root/assets/tool-activity-R8V9l6nk.js +1 -0
  90. package/dist/gateway/static/root/assets/typed-models-lib-q5-Vfqd8.js +1 -0
  91. package/dist/gateway/static/root/assets/use-autosave-7XfKULPI.js +1 -0
  92. package/dist/gateway/static/root/assets/user-context-page-CZ9m9aC_.js +1 -0
  93. package/dist/gateway/static/root/assets/voice-api-key-field-DXr21v-3.js +1 -0
  94. package/dist/gateway/static/root/assets/work-discovery-overlay-CeG7g_DZ.js +1 -0
  95. package/dist/gateway/static/root/assets/work-discovery-page-CQWZD03N.js +1 -0
  96. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BEmugHfL.js → workflow-run-setup-panel-DSQQZP9T.js} +2 -2
  97. package/dist/gateway/static/root/assets/workflows-page-Cs-MXFJ1.js +5 -0
  98. package/dist/gateway/static/root/assets/working-directory-picker-modal-D-IgcHPp.js +1 -0
  99. package/dist/gateway/static/root/index.html +23 -8
  100. package/dist/package.js +1 -1
  101. package/dist/packages/gateway-contract/src/tasks.js +54 -2
  102. package/dist/src/agent/agent-manager.d.ts +1 -0
  103. package/dist/src/agent/agent-manager.js +1 -0
  104. package/dist/src/agent/embedded/execution-context.d.ts +2 -0
  105. package/dist/src/agent/embedded/execution-context.js +11 -0
  106. package/dist/src/agent/embedded/index.d.ts +3 -1
  107. package/dist/src/agent/embedded/index.js +5 -3
  108. package/dist/src/agent/embedded/run-turn.js +15 -9
  109. package/dist/src/agent/embedded/session-runner.d.ts +6 -11
  110. package/dist/src/agent/embedded/session-runner.js +25 -36
  111. package/dist/src/agent/embedded/transcript-runtime.d.ts +35 -0
  112. package/dist/src/agent/embedded/transcript-runtime.js +66 -0
  113. package/dist/src/agent/embedded/types.d.ts +3 -1
  114. package/dist/src/agent/service.d.ts +15 -0
  115. package/dist/src/agent/service.js +31 -0
  116. package/dist/src/agent/service.types.d.ts +1 -0
  117. package/dist/src/agent/tools/factory.d.ts +2 -0
  118. package/dist/src/agent/tools/factory.js +2 -1
  119. package/dist/src/agent/tools/xopc-use-tool.d.ts +1 -0
  120. package/dist/src/agent/tools/xopc-use-tool.js +56 -6
  121. package/dist/src/automations/domain/validation.d.ts +40 -0
  122. package/dist/src/automations/draft/automation-draft-validator.d.ts +4 -1
  123. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  124. package/dist/src/config/agent-profile.js +1 -1
  125. package/dist/src/config/rules.js +2 -2
  126. package/dist/src/gateway/agents-admin.js +1 -1
  127. package/dist/src/gateway/hono/app.d.ts +2 -0
  128. package/dist/src/gateway/hono/app.js +10 -3
  129. package/dist/src/gateway/hono/middleware/strict-rate-limit.d.ts +4 -0
  130. package/dist/src/gateway/hono/middleware/strict-rate-limit.js +8 -1
  131. package/dist/src/gateway/hono/routes/config-patch/misc.js +2 -1
  132. package/dist/src/gateway/hono/routes/config.js +9 -0
  133. package/dist/src/gateway/hono/routes/deps.d.ts +1 -0
  134. package/dist/src/gateway/hono/routes/home.d.ts +1 -1
  135. package/dist/src/gateway/hono/routes/home.js +2 -2
  136. package/dist/src/gateway/hono/routes/index.js +2 -0
  137. package/dist/src/gateway/hono/routes/projects.js +67 -1
  138. package/dist/src/gateway/hono/routes/side-chats.d.ts +3 -0
  139. package/dist/src/gateway/hono/routes/side-chats.js +173 -0
  140. package/dist/src/gateway/hono/routes/tasks.js +112 -19
  141. package/dist/src/gateway/host.d.ts +9 -1
  142. package/dist/src/gateway/host.js +22 -5
  143. package/dist/src/gateway/rate-limit/buckets.d.ts +3 -0
  144. package/dist/src/gateway/rate-limit/buckets.js +12 -0
  145. package/dist/src/gateway/runtime-config.js +6 -5
  146. package/dist/src/gateway/security/audit.js +0 -7
  147. package/dist/src/gateway/server.js +4 -1
  148. package/dist/src/gateway/service/agent-runner.d.ts +4 -0
  149. package/dist/src/gateway/service/agent-runner.js +15 -1
  150. package/dist/src/gateway/service/run-gateway-agent.js +1 -1
  151. package/dist/src/gateway/service.d.ts +5 -0
  152. package/dist/src/gateway/service.js +38 -8
  153. package/dist/src/gateway/side-chat/context-snapshot.d.ts +11 -0
  154. package/dist/src/gateway/side-chat/context-snapshot.js +108 -0
  155. package/dist/src/gateway/side-chat/index.d.ts +5 -0
  156. package/dist/src/gateway/side-chat/index.js +4 -0
  157. package/dist/src/gateway/side-chat/manager.d.ts +45 -0
  158. package/dist/src/gateway/side-chat/manager.js +198 -0
  159. package/dist/src/gateway/side-chat/run-service.d.ts +22 -0
  160. package/dist/src/gateway/side-chat/run-service.js +110 -0
  161. package/dist/src/gateway/side-chat/types.d.ts +61 -0
  162. package/dist/src/gateway/side-chat/types.js +1 -0
  163. package/dist/src/proactive/actions/service.d.ts +2 -0
  164. package/dist/src/proactive/actions/service.js +80 -0
  165. package/dist/src/proactive/execution/insight.js +20 -0
  166. package/dist/src/proactive/execution/repository.js +8 -2
  167. package/dist/src/proactive/execution/types.d.ts +14 -0
  168. package/dist/src/proactive/inbox/repository.js +59 -9
  169. package/dist/src/proactive/inbox/service.d.ts +2 -2
  170. package/dist/src/proactive/inbox/service.js +7 -2
  171. package/dist/src/proactive/inbox/types.d.ts +14 -0
  172. package/dist/src/proactive/inbox/worker.js +2 -0
  173. package/dist/src/proactive/scenarios/prompt-composer.js +2 -2
  174. package/dist/src/routing/session-key-utils.d.ts +0 -1
  175. package/dist/src/routing/session-key-utils.js +1 -6
  176. package/dist/src/routing/session-key.js +2 -2
  177. package/dist/src/storage/sqlite/migrations/118_task_board_rank.sql +6 -0
  178. package/dist/src/storage/sqlite/migrations/119_proactive_disposition.sql +13 -0
  179. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  180. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  181. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  182. package/dist/src/storage/sqlite/schema.js +1 -1
  183. package/dist/src/tasks/home-query-service.d.ts +29 -0
  184. package/dist/src/tasks/home-query-service.js +291 -7
  185. package/dist/src/tasks/index.d.ts +1 -0
  186. package/dist/src/tasks/index.js +5 -4
  187. package/dist/src/tasks/project-monitoring-service.d.ts +9 -0
  188. package/dist/src/tasks/project-monitoring-service.js +41 -3
  189. package/dist/src/tasks/project-operating-view-service.d.ts +2 -2
  190. package/dist/src/tasks/project-operating-view-service.js +47 -21
  191. package/dist/src/tasks/task-application-service.js +99 -6
  192. package/dist/src/tasks/task-change-events.d.ts +13 -0
  193. package/dist/src/tasks/task-change-events.js +29 -0
  194. package/dist/src/tasks/task-read-model-projector.js +2 -1
  195. package/dist/src/tasks/task-repository.d.ts +7 -0
  196. package/dist/src/tasks/task-repository.js +29 -6
  197. package/dist/src/tunnel/enable-lan-pairing.js +15 -26
  198. package/dist/src/tunnel/pair-context.js +1 -1
  199. package/dist/src/tunnel/pair-url.js +1 -1
  200. package/dist/src/tunnel/tunnel-qr.d.ts +0 -7
  201. package/dist/src/tunnel/tunnel-qr.js +2 -19
  202. package/package.json +4 -2
  203. package/dist/gateway/static/root/assets/agents-VoFNMGL3.js +0 -68
  204. package/dist/gateway/static/root/assets/app-management-settings-panel-vmuJ_Z6i.js +0 -1
  205. package/dist/gateway/static/root/assets/appearance-settings-BMlEoe-G.js +0 -1
  206. package/dist/gateway/static/root/assets/apps-page-CsNB6mv_.js +0 -1
  207. package/dist/gateway/static/root/assets/automations-page-CW1YWgiX.js +0 -6
  208. package/dist/gateway/static/root/assets/browser-settings-page-BMTmGMM6.js +0 -8
  209. package/dist/gateway/static/root/assets/browser-workflow-inputs-BsmHy0ks.js +0 -1
  210. package/dist/gateway/static/root/assets/capabilities-settings-panel-C5l85__e.js +0 -7
  211. package/dist/gateway/static/root/assets/capability-presets-settings-panel-9T2KXAs1.js +0 -3
  212. package/dist/gateway/static/root/assets/channels-settings-DquD4BPQ.js +0 -1
  213. package/dist/gateway/static/root/assets/channels-status-swr-DPaJSYX_.js +0 -1
  214. package/dist/gateway/static/root/assets/connectors-api-BC-4ftOM.js +0 -1
  215. package/dist/gateway/static/root/assets/connectors-page-7zUxVHQg.js +0 -2
  216. package/dist/gateway/static/root/assets/cron-expression-BycQlU8Q.js +0 -2
  217. package/dist/gateway/static/root/assets/dependency-picker-BvYqHRz0.js +0 -1
  218. package/dist/gateway/static/root/assets/desktop-pet-settings-DStgPb82.js +0 -1
  219. package/dist/gateway/static/root/assets/directory-picker-path-field-DUUr9sq0.js +0 -1
  220. package/dist/gateway/static/root/assets/extension-settings-page-BcSKEU8s.js +0 -1
  221. package/dist/gateway/static/root/assets/gateway-config-api-C-MmtCc7.js +0 -1
  222. package/dist/gateway/static/root/assets/gateway-settings-CuaRDWbg.js +0 -1
  223. package/dist/gateway/static/root/assets/heartbeat-settings-Dm8TrfGa.js +0 -1
  224. package/dist/gateway/static/root/assets/home-page-BYhDbUvI.js +0 -3
  225. package/dist/gateway/static/root/assets/index-BzPwnXho.js +0 -150
  226. package/dist/gateway/static/root/assets/index-CFFYvilx.css +0 -1
  227. package/dist/gateway/static/root/assets/local-app-workbench-page-CHk4x0kR.js +0 -2
  228. package/dist/gateway/static/root/assets/local-apps-page-DQtsxjGs.js +0 -1
  229. package/dist/gateway/static/root/assets/logs-page-CDqIY72S.js +0 -2
  230. package/dist/gateway/static/root/assets/management-settings-D7itDEHl.js +0 -1
  231. package/dist/gateway/static/root/assets/messages-DQ5X6cXp.js +0 -3
  232. package/dist/gateway/static/root/assets/notes-workbench-epHGeKd5.js +0 -4
  233. package/dist/gateway/static/root/assets/page-tabs-HXweXqYE.js +0 -1
  234. package/dist/gateway/static/root/assets/preview-open-alternatives-Dob6Oe2l.js +0 -1
  235. package/dist/gateway/static/root/assets/project-detail-page-BxOD5-zj.js +0 -1
  236. package/dist/gateway/static/root/assets/projects-page-D-9AhrH5.js +0 -1
  237. package/dist/gateway/static/root/assets/remote-access-hub-CSUNXLKM.js +0 -1
  238. package/dist/gateway/static/root/assets/schema-form-BI4rVt3u.js +0 -1
  239. package/dist/gateway/static/root/assets/sessions-page-BxOUBMca.js +0 -1
  240. package/dist/gateway/static/root/assets/settings-advanced-gate-DAvTIbgw.js +0 -1
  241. package/dist/gateway/static/root/assets/settings-form-section-C7rzhi7x.js +0 -1
  242. package/dist/gateway/static/root/assets/settings-page-layout-CTMmZcwj.js +0 -1
  243. package/dist/gateway/static/root/assets/setup-status-panel-D1v-2Ci-.js +0 -1
  244. package/dist/gateway/static/root/assets/share-preview-page-BeCxg6eb.js +0 -2
  245. package/dist/gateway/static/root/assets/shares-settings-CXL1EldF.js +0 -1
  246. package/dist/gateway/static/root/assets/skill-reload-api-BxwkKgVw.js +0 -1
  247. package/dist/gateway/static/root/assets/skills-page-CyfjEM4D.js +0 -2
  248. package/dist/gateway/static/root/assets/system-settings-panel-CAv0Yk0Y.js +0 -1
  249. package/dist/gateway/static/root/assets/task-detail-page-DGTVJs_N.js +0 -1
  250. package/dist/gateway/static/root/assets/typed-models-lib-DomX3Szl.js +0 -1
  251. package/dist/gateway/static/root/assets/use-autosave-BLc4gfG0.js +0 -1
  252. package/dist/gateway/static/root/assets/user-context-page-C2kQENTK.js +0 -1
  253. package/dist/gateway/static/root/assets/voice-api-key-field-BijmpPjb.js +0 -1
  254. package/dist/gateway/static/root/assets/work-discovery-overlay-D7w2JFFq.js +0 -1
  255. package/dist/gateway/static/root/assets/work-discovery-page-XtoPgPUS.js +0 -1
  256. package/dist/gateway/static/root/assets/workflows-page-D_K2xOWq.js +0 -5
  257. package/dist/src/gateway/ensure-network-cors.d.ts +0 -3
  258. package/dist/src/gateway/ensure-network-cors.js +0 -23
@@ -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{f as i,t as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./check-DUBLcKHA.js";import{t as s}from"./cn-JdwAhgNB.js";import{t as c}from"./copy-to-clipboard-HOJ79TWv.js";import{t as l}from"./messages-DQ5X6cXp.js";import{a as u,i as d,l as f,n as p,o as m,r as h,s as g}from"./locale-store-Bjvw7jtg.js";import{a as _,i as v}from"./vendor-swr-BIWyz7Rc.js";import{At as y,Bo as b,Br as x,Bs as S,Cs as C,Fc as w,Fo as T,Gr as E,Ha as D,Hr as O,Jo as k,Jr as A,Kc as j,Kr as M,Ll as N,Lo as P,Mn as F,Na as I,Ro as L,Ur as R,Vo as z,Vr as B,Wl as V,Wr as H,Ws as U,Xr as ee,Yr as te,Zr as ne,bc as W,bo as G,du as K,eu as q,hc as re,hi as ie,hs as ae,is as J,lc as Y,mn as oe,pu as se,qr as ce,rc as le,rs as ue,sl as de,tc as fe,ws as X,xl as pe,xo as me,zo as he,zr as ge}from"./index-BzPwnXho.js";import{n as _e,r as ve,t as ye}from"./settings-page-layout-CTMmZcwj.js";import{t as be}from"./settings-advanced-gate-DAvTIbgw.js";import{n as xe,r as Se,t as Ce}from"./settings-form-section-C7rzhi7x.js";import{t as we}from"./browser-BLJWD7WI.js";import{t as Te}from"./page-tabs-HXweXqYE.js";var Z=n(),Q=e(t(),1),$=r();function Ee(e){let t=(0,Z.c)(26),{showLabel:n,hideLabel:r,icon:i,hint:a,children:o,className:c,defaultOpen:l,advancedOnly:u}=e,d=u===void 0?!1:u,[f,p]=(0,Q.useState)(l??!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]===c?h=t[2]:(h=s(`group rounded-2xl bg-surface-base open:pb-1`,c),t[1]=c,t[2]=h);let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(se,{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(d){let e;return t[24]===w?e=t[25]:(e=(0,$.jsx)(be,{children:w}),t[24]=w,t[25]=e),e}return w}function De(e,t){let{mutate:n}=_(),[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`),G()])},[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 R();if(!n.ok)throw Error(`Failed to enable LAN pairing`);if(n.requiresRestart){let t=await ge();if(!t.ok)throw Error(t.message??`Gateway restart failed`);if(!await x(e))throw Error(`Gateway did not come back online in time`)}let r=n.requiresRestart?await B():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 Oe(){return s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,C,`dark:border-edge`)}function ke(e){let t=(0,Z.c)(122),{pairQr:n,gatewayToken:r,streamlined:i,lanOnly:o,onRefreshQr:c}=e,u=i===void 0?!1:i,d=o===void 0?!1:o,f=p(Me),m;t[0]===f?m=t[1]:(m=l(f),t[0]=f,t[1]=m);let h=m,g=h.tunnelSettings,_=d?h.remoteAccess.lan:null,v;t[2]!==h.clipboard.copyFailed||t[3]!==g.pairCopied||t[4]!==g.pairCopyLink?(v={copy:g.pairCopyLink,copied:g.pairCopied,copyFailed:h.clipboard.copyFailed},t[2]=h.clipboard.copyFailed,t[3]=g.pairCopied,t[4]=g.pairCopyLink,t[5]=v):v=t[5];let y=v,{tunnelActive:b,tunnelStatus:x,tunnelQr:S,pairContext:C,pairBaseUrl:w,setPairBaseUrl:T,applySuggestedPairUrl:E,applyCandidateUrl:D,resetPairBaseFromContext:O,baseOk:k,localhostWarn:A,pairingBlocked:M,deepLink:N,qrPayload:P,qrDataUrl:I,qrGenFailed:L,encoding:R}=n,z;t[6]===O?z=t[7]:(z=e=>{O(e.recommended.url)},t[6]=O,t[7]=z);let B=De(r,z),V,H,U,ee,te;if(t[8]!==D||t[9]!==E||t[10]!==k||t[11]!==B||t[12]!==r||t[13]!==_||t[14]!==d||t[15]!==A||t[16]!==c||t[17]!==w||t[18]!==C?.candidates||t[19]!==C?.recommended||t[20]!==M||t[21]!==T||t[22]!==u||t[23]!==g.pairBaseUrlHint||t[24]!==g.pairBaseUrlLabel||t[25]!==g.pairBaseUrlPlaceholder||t[26]!==g.pairBlockedLoopbackBody||t[27]!==g.pairBlockedNextSteps||t[28]!==g.pairBlockedTitle||t[29]!==g.pairCandidatesTitle||t[30]!==g.pairEnableLanButton||t[31]!==g.pairEnableLanEnabling||t[32]!==g.pairEnableLanSecurityAuditLink||t[33]!==g.pairInvalidBaseUrl||t[34]!==g.pairLocalhostWarning||t[35]!==g.pairSelectCandidateHint||t[36]!==g.pairSelectCandidateTitle||t[37]!==g.pairSubtitle||t[38]!==g.pairSuggestedLanLabel||t[39]!==g.pairTitle||t[40]!==g.pairTunnelActive||t[41]!==g.pairTunnelLanUrl||t[42]!==g.pairTunnelPublicUrl||t[43]!==g.pairUseSuggestedUrl||t[44]!==g.pairWaitingForTunnel||t[45]!==g.refreshQr||t[46]!==b||t[47]!==S||t[48]!==x?.publicUrl){te=Symbol.for(`react.early_return_sentinel`);bb0:{let e=C?.candidates.filter(je)??[],n=d?(e.find(Ae)?.url??e[0]?.url??``).trim():C?.recommended.url?.trim()??``,i=(d||!b)&&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:s(`text-xs font-medium`,r),children:i?g.pairSelectCandidateTitle:g.pairCandidatesTitle}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,className:s(`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`,w.trim()===e.url&&`border-accent bg-accent/5`,n),onClick:()=>D(e.url),children:[e.label?`${e.label}: `:``,e.url]})},e.url))}),i?(0,$.jsx)(`p`,{className:s(`mt-1 text-[11px] leading-relaxed`,r),children:g.pairSelectCandidateHint}):null]})};if(V=u&&!d,V&&!b){let e;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(fe,{className:`size-4 text-accent`,strokeWidth:1.75}),t[54]=e):e=t[54];let n;t[55]===g.pairTitle?n=t[56]:(n=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[e,g.pairTitle]}),t[55]=g.pairTitle,t[56]=n);let r;t[57]===g.pairWaitingForTunnel?r=t[58]:(r=(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:g.pairWaitingForTunnel}),t[57]=g.pairWaitingForTunnel,t[58]=r);let i;t[59]!==n||t[60]!==r?(i=(0,$.jsxs)(Ce,{children:[n,r]}),t[59]=n,t[60]=r,t[61]=i):i=t[61],te=i;break bb0}let l=_?.pairTitle??g.pairTitle,f=d?_?.pairSubtitle??g.pairSubtitle:b?g.pairTunnelActive:g.pairSubtitle,p=!!(c&&(d||u&&b)),m=V?`mb-2`:`mb-3`,h;t[62]===m?h=t[63]:(h=s(`flex flex-wrap items-start justify-between gap-2`,m),t[62]=m,t[63]=h);let v;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(fe,{className:`size-4 text-accent`,strokeWidth:1.75}),t[64]=v):v=t[64];let y;t[65]===l?y=t[66]:(y=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[v,l]}),t[65]=l,t[66]=y);let O;t[67]!==V||t[68]!==f||t[69]!==g.pairSubtitle?(O=V?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:g.pairSubtitle}):(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:f}),t[67]=V,t[68]=f,t[69]=g.pairSubtitle,t[70]=O):O=t[70];let N;t[71]!==y||t[72]!==O?(N=(0,$.jsxs)(`div`,{children:[y,O]}),t[71]=y,t[72]=O,t[73]=N):N=t[73];let P;t[74]!==c||t[75]!==p||t[76]!==g.refreshQr?(P=p?(0,$.jsxs)(X,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>void c(),children:[(0,$.jsx)(re,{className:`size-4`}),g.refreshQr]}):null,t[74]=c,t[75]=p,t[76]=g.refreshQr,t[77]=P):P=t[77],t[78]!==h||t[79]!==N||t[80]!==P?(H=(0,$.jsxs)(`div`,{className:h,children:[N,P]}),t[78]=h,t[79]=N,t[80]=P,t[81]=H):H=t[81],U=M?(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:g.pairBlockedTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-amber-900 dark:text-amber-200`,children:g.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:g.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)(X,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,onClick:E,children:g.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)(X,{type:`button`,className:`w-full sm:w-auto`,disabled:B.busy||!r,onClick:()=>B.setConfirmOpen(!0),children:[B.busy?(0,$.jsx)(j,{className:`size-3.5 animate-spin`}):null,B.busy?g.pairEnableLanEnabling:g.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:d?_?.pairBlockedNextSteps??g.pairBlockedNextSteps:g.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:g.pairEnableLanSecurityAuditLink}),d&&_?.pairPublicTabLink?(0,$.jsx)(a,{to:`/settings/remote-access?tab=public`,className:`inline-block text-xs font-medium text-accent hover:underline`,children:_.pairPublicTabLink}):null]})]}):null,ee=b&&!d?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:g.pairTunnelPublicUrl}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-fg`,children:x?.publicUrl})]}),S?.lanUrl?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.pairTunnelLanUrl}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-fg`,children:S.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:g.pairBaseUrlLabel}),(0,$.jsx)(`input`,{id:`tunnel-mobile-pair-base`,className:s(Oe(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:n||g.pairBaseUrlPlaceholder,value:w,onChange:e=>T(e.target.value)}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:g.pairBaseUrlHint}),!k&&w.trim()?(0,$.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:g.pairInvalidBaseUrl}):null,A?(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:g.pairLocalhostWarning}):null,i?o(`neutral`):null]})}t[8]=D,t[9]=E,t[10]=k,t[11]=B,t[12]=r,t[13]=_,t[14]=d,t[15]=A,t[16]=c,t[17]=w,t[18]=C?.candidates,t[19]=C?.recommended,t[20]=M,t[21]=T,t[22]=u,t[23]=g.pairBaseUrlHint,t[24]=g.pairBaseUrlLabel,t[25]=g.pairBaseUrlPlaceholder,t[26]=g.pairBlockedLoopbackBody,t[27]=g.pairBlockedNextSteps,t[28]=g.pairBlockedTitle,t[29]=g.pairCandidatesTitle,t[30]=g.pairEnableLanButton,t[31]=g.pairEnableLanEnabling,t[32]=g.pairEnableLanSecurityAuditLink,t[33]=g.pairInvalidBaseUrl,t[34]=g.pairLocalhostWarning,t[35]=g.pairSelectCandidateHint,t[36]=g.pairSelectCandidateTitle,t[37]=g.pairSubtitle,t[38]=g.pairSuggestedLanLabel,t[39]=g.pairTitle,t[40]=g.pairTunnelActive,t[41]=g.pairTunnelLanUrl,t[42]=g.pairTunnelPublicUrl,t[43]=g.pairUseSuggestedUrl,t[44]=g.pairWaitingForTunnel,t[45]=g.refreshQr,t[46]=b,t[47]=S,t[48]=x?.publicUrl,t[49]=V,t[50]=H,t[51]=U,t[52]=ee,t[53]=te}else V=t[49],H=t[50],U=t[51],ee=t[52],te=t[53];if(te!==Symbol.for(`react.early_return_sentinel`))return te;let ne;t[82]===g.pairSecurityNote?ne=t[83]:(ne=(0,$.jsx)(`p`,{className:`mb-3 text-xs text-fg-subtle`,children:g.pairSecurityNote}),t[82]=g.pairSecurityNote,t[83]=ne);let W;t[84]!==y||t[85]!==N||t[86]!==R||t[87]!==M||t[88]!==I||t[89]!==L||t[90]!==g.pairEncoding||t[91]!==g.pairImageError||t[92]!==g.pairQrDisabled?(W=N?(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:g.pairEncoding}):null,L?(0,$.jsx)(`p`,{className:`text-center text-sm text-fg-muted sm:text-left`,children:g.pairImageError}):null,(0,$.jsx)(ie,{text:N,labels:y})]}):M?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:g.pairQrDisabled}):null,t[84]=y,t[85]=N,t[86]=R,t[87]=M,t[88]=I,t[89]=L,t[90]=g.pairEncoding,t[91]=g.pairImageError,t[92]=g.pairQrDisabled,t[93]=W):W=t[93];let G;t[94]!==V||t[95]!==P||t[96]!==g.deeplinkTitle?(G=P&&!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:g.deeplinkTitle}),(0,$.jsx)(`p`,{className:`mt-2 break-all font-mono text-[10px] leading-relaxed text-fg-subtle`,children:P})]}):null,t[94]=V,t[95]=P,t[96]=g.deeplinkTitle,t[97]=G):G=t[97];let K;t[98]!==V||t[99]!==g.pairMobileProbeHint||t[100]!==g.pairSchemeHint?(K=V?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`mt-3 break-all font-mono text-[10px] leading-relaxed text-fg-subtle`,children:g.pairSchemeHint}),(0,$.jsx)(`p`,{className:`mt-1 text-[10px] leading-relaxed text-fg-subtle`,children:g.pairMobileProbeHint})]}),t[98]=V,t[99]=g.pairMobileProbeHint,t[100]=g.pairSchemeHint,t[101]=K):K=t[101];let q,ae;t[102]===B?(q=t[103],ae=t[104]):(q=()=>void B.runEnableLanPairing(),ae=()=>{B.busy||B.setConfirmOpen(!1)},t[102]=B,t[103]=q,t[104]=ae);let J;t[105]!==B.confirmOpen||t[106]!==g.consentCancel||t[107]!==g.pairEnableLanButton||t[108]!==g.pairEnableLanConfirmBody||t[109]!==g.pairEnableLanConfirmTitle||t[110]!==q||t[111]!==ae?(J=(0,$.jsx)(F,{open:B.confirmOpen,title:g.pairEnableLanConfirmTitle,description:g.pairEnableLanConfirmBody,confirmLabel:g.pairEnableLanButton,cancelLabel:g.consentCancel,onConfirm:q,onCancel:ae}),t[105]=B.confirmOpen,t[106]=g.consentCancel,t[107]=g.pairEnableLanButton,t[108]=g.pairEnableLanConfirmBody,t[109]=g.pairEnableLanConfirmTitle,t[110]=q,t[111]=ae,t[112]=J):J=t[112];let Y;return t[113]!==ne||t[114]!==W||t[115]!==G||t[116]!==K||t[117]!==J||t[118]!==H||t[119]!==U||t[120]!==ee?(Y=(0,$.jsx)(Ce,{children:(0,$.jsxs)($.Fragment,{children:[H,U,ee,ne,W,G,K,J]})}),t[113]=ne,t[114]=W,t[115]=G,t[116]=K,t[117]=J,t[118]=H,t[119]=U,t[120]=ee,t[121]=Y):Y=t[121],Y}function Ae(e){return e.reachable}function je(e){return e.kind===`lan`}function Me(e){return e.language}function Ne(e){let t=(0,Z.c)(40),{open:n,title:r,intro:i,bullets:a,checkboxLabel:o,confirmLabel:c,cancelLabel:l,onConfirm:u,onCancel:d}=e,[f,p]=(0,Q.useState)(!1),m;t[0]===d?m=t[1]:(m=e=>{e||(p(!1),d())},t[0]=d,t[1]=m);let h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(he,{className:s(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,J)}),t[2]=h):h=t[2];let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=s(`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`,ue),t[3]=g):g=t[3];let _;t[4]===r?_=t[5]:(_=(0,$.jsx)(z,{className:`text-base font-semibold text-fg`,children:r}),t[4]=r,t[5]=_);let v;t[6]===i?v=t[7]:(v=(0,$.jsx)(L,{className:`mt-2 text-sm text-fg-muted`,children:i}),t[6]=i,t[7]=v);let y;t[8]===a?y=t[9]:(y=a.map(Pe),t[8]=a,t[9]=y);let x;t[10]===y?x=t[11]:(x=(0,$.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5 text-sm text-fg-muted`,children:y}),t[10]=y,t[11]=x);let S;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(S=e=>p(e.target.checked),t[12]=S):S=t[12];let C;t[13]===f?C=t[14]:(C=(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 shrink-0 rounded border-edge accent-accent`,checked:f,onChange:S}),t[13]=f,t[14]=C);let w;t[15]===o?w=t[16]:(w=(0,$.jsx)(`span`,{children:o}),t[15]=o,t[16]=w);let E;t[17]!==w||t[18]!==C?(E=(0,$.jsxs)(`label`,{className:`mt-5 flex cursor-pointer items-start gap-3 text-sm text-fg`,children:[C,w]}),t[17]=w,t[18]=C,t[19]=E):E=t[19];let D;t[20]!==l||t[21]!==d?(D=(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:d,children:l}),t[20]=l,t[21]=d,t[22]=D):D=t[22];let O=!f,k;t[23]!==c||t[24]!==u||t[25]!==O?(k=(0,$.jsx)(X,{type:`button`,disabled:O,onClick:u,children:c}),t[23]=c,t[24]=u,t[25]=O,t[26]=k):k=t[26];let A;t[27]!==D||t[28]!==k?(A=(0,$.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[D,k]}),t[27]=D,t[28]=k,t[29]=A):A=t[29];let j;t[30]!==E||t[31]!==A||t[32]!==_||t[33]!==v||t[34]!==x?(j=(0,$.jsxs)(b,{children:[h,(0,$.jsxs)(P,{className:g,onOpenAutoFocus:Fe,children:[_,v,x,E,A]})]}),t[30]=E,t[31]=A,t[32]=_,t[33]=v,t[34]=x,t[35]=j):j=t[35];let M;return t[36]!==n||t[37]!==m||t[38]!==j?(M=(0,$.jsx)(T,{open:n,onOpenChange:m,children:j}),t[36]=n,t[37]=m,t[38]=j,t[39]=M):M=t[39],M}function Pe(e){return(0,$.jsx)(`li`,{children:e},e)}function Fe(e){return e.preventDefault()}function Ie(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var Le=[`preparing_frpc`,`registering`,`starting_frpc`];function Re(e){return e?e===`reconnecting_frpc`?Le.indexOf(`starting_frpc`):Le.indexOf(e):-1}function ze(e,t){if(t.state===`connected`)return`done`;let n=t.startProgress?.phase,r=Le.indexOf(e),i=Re(n);return i<0?t.state===`connecting`||t.state===`reconnecting`?`active`:`pending`:r<i?`done`:r===i?`active`:`pending`}function Be(e,t,n){let r=n.startProgress;return ze(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 Ve(e,t){switch(t){case`preparing_frpc`:return e.stepPrepareFrpc;case`registering`:return e.stepRegister;case`starting_frpc`:return e.stepFrpcLogin}}function He(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 Ue(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(We),1e3);return()=>window.clearInterval(e)},t[0]=i,t[1]=n.state,t[2]=a):a=t[2];let c=n.startProgress?.startedAt,l;if(t[3]!==n.state||t[4]!==c?(l=[n.state,c],t[3]=n.state,t[4]=c,t[5]=l):l=t[5],(0,Q.useEffect)(a,l),!(n.state===`connecting`||n.state===`reconnecting`||n.state===`connected`&&n.startProgress))return null;let u,d,f,p,m;if(t[6]!==n||t[7]!==r){let e=He(n.startProgress?.startedAt);u=!!n.publicUrl&&n.state!==`connected`&&n.startProgress?.phase!==`registering`,d=`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?(f=(0,$.jsxs)(`div`,{children:[i,a]}),t[17]=i,t[18]=a,t[19]=f):f=t[19];let c=Le.map(e=>{let t=ze(e,n),i=Be(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)(j,{className:`size-3.5 animate-spin text-accent`}):(0,$.jsx)(q,{className:`size-3.5`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:s(`font-medium`,t===`active`?`text-fg`:t===`done`?`text-fg-muted`:`text-fg-subtle`),children:Ve(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:s(`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:[Ie(n.frpcDownload.bytesReceived),` /`,` `,Ie(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]===c?p=t[21]:(p=(0,$.jsx)(`ol`,{className:`space-y-2`,children:c}),t[20]=c,t[21]=p),m=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]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m}else u=t[8],d=t[9],f=t[10],p=t[11],m=t[12];let h;t[22]!==u||t[23]!==r.publicUrlPendingNotice?(h=u?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.publicUrlPendingNotice}):null,t[22]=u,t[23]=r.publicUrlPendingNotice,t[24]=h):h=t[24];let g;return t[25]!==d||t[26]!==f||t[27]!==p||t[28]!==m||t[29]!==h?(g=(0,$.jsxs)(`div`,{className:d,children:[f,p,m,h]}),t[25]=d,t[26]=f,t[27]=p,t[28]=m,t[29]=h,t[30]=g):g=t[30],g}function We(e){return e+1}function Ge(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 Ke(e){return e.state===`connected`?`connected`:e.state===`error`?`error`:e.state===`connecting`||e.state===`reconnecting`||e.startProgress||e.frpcDownload?`progress`:`off`}function qe(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 Je(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 Ye(e){let t=(0,Z.c)(61),{t:n,status:r,isLoading:i,statusErr:a,starting:o,stopping:c,showConsentExpired:l,copyLabels:u,startDisabled:d,startDisabledReason:f,stepLabel:p,onStart:m,onStop:h}=e,g=d===void 0?!1:d,_,v,y,b,x,C,w;t[0]!==r||t[1]!==o?(w=Ke(r),_=r.enabled||o,v=o||r.state===`connecting`||r.state===`reconnecting`||!!r.startProgress||!!r.frpcDownload,t[9]===Symbol.for(`react.memo_cache_sentinel`)?(C=s(Se(),`space-y-4`),t[9]=C):C=t[9],x=`flex flex-wrap items-start justify-between gap-3`,b=`flex items-center gap-2`,y=s(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,qe(w)),t[0]=r,t[1]=o,t[2]=_,t[3]=v,t[4]=y,t[5]=b,t[6]=x,t[7]=C,t[8]=w):(_=t[2],v=t[3],y=t[4],b=t[5],x=t[6],C=t[7],w=t[8]);let T=w===`connected`&&`bg-emerald-500`,E=w===`progress`&&`bg-amber-500 animate-pulse`,D=w===`error`&&`bg-red-500`,O=w===`off`&&`bg-fg-subtle`,k;t[10]!==T||t[11]!==E||t[12]!==D||t[13]!==O?(k=s(`size-1.5 rounded-full`,T,E,D,O),t[10]=T,t[11]=E,t[12]=D,t[13]=O,t[14]=k):k=t[14];let A;t[15]===k?A=t[16]:(A=(0,$.jsx)(`span`,{className:k,"aria-hidden":!0}),t[15]=k,t[16]=A);let M;t[17]!==i||t[18]!==r||t[19]!==n?(M=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`}):Ge(n,r),t[17]=i,t[18]=r,t[19]=n,t[20]=M):M=t[20];let N;t[21]!==A||t[22]!==M||t[23]!==y?(N=(0,$.jsxs)(`span`,{className:y,children:[A,M]}),t[21]=A,t[22]=M,t[23]=y,t[24]=N):N=t[24];let P;t[25]!==r.connectedSince||t[26]!==r.state||t[27]!==n.uptime?(P=r.connectedSince&&r.state===`connected`?(0,$.jsxs)(`span`,{className:`text-xs text-fg-subtle`,children:[n.uptime,` `,Je(r.connectedSince)]}):null,t[25]=r.connectedSince,t[26]=r.state,t[27]=n.uptime,t[28]=P):P=t[28];let F;t[29]!==N||t[30]!==P||t[31]!==b?(F=(0,$.jsxs)(`div`,{className:b,children:[N,P]}),t[29]=N,t[30]=P,t[31]=b,t[32]=F):F=t[32];let I;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(pe,{className:`size-4 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[33]=I):I=t[33];let L;t[34]!==F||t[35]!==x?(L=(0,$.jsxs)(`div`,{className:x,children:[F,I]}),t[34]=F,t[35]=x,t[36]=L):L=t[36];let R;t[37]===a?R=t[38]:(R=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]=R);let z;t[39]!==l||t[40]!==n.consentExpiredBanner?(z=l?(0,$.jsx)(`p`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-xs text-fg-muted`,children:n.consentExpiredBanner}):null,t[39]=l,t[40]=n.consentExpiredBanner,t[41]=z):z=t[41];let B;t[42]!==_||t[43]!==u||t[44]!==m||t[45]!==h||t[46]!==v||t[47]!==r||t[48]!==g||t[49]!==f||t[50]!==o||t[51]!==p||t[52]!==c||t[53]!==n?(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)(ie,{label:n.publicUrlLabel,text:r.publicUrl,labels:u})}):null,v?(0,$.jsx)(Ue,{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)(X,{type:`button`,variant:`secondary`,disabled:c,onClick:h,children:[c?(0,$.jsx)(j,{className:`size-4 animate-spin`}):null,n.stop]}):(0,$.jsxs)(X,{type:`button`,disabled:o,onClick:m,children:[o?(0,$.jsx)(j,{className:`size-4 animate-spin`}):(0,$.jsx)(W,{className:`size-4`}),n.start]})})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[p?(0,$.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:p}):null,(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.emptyStateTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:n.emptyStateBody})]}),(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2.5 text-xs text-fg-muted`,children:[(0,$.jsx)(S,{className:`mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-400`}),(0,$.jsx)(`p`,{children:n.riskBannerBody})]}),g&&f?(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:f}):null,(0,$.jsxs)(X,{type:`button`,disabled:o||g,onClick:m,className:`w-full sm:w-auto`,children:[o?(0,$.jsx)(j,{className:`size-4 animate-spin`}):(0,$.jsx)(W,{className:`size-4`}),n.start]})]}),t[42]=_,t[43]=u,t[44]=m,t[45]=h,t[46]=v,t[47]=r,t[48]=g,t[49]=f,t[50]=o,t[51]=p,t[52]=c,t[53]=n,t[54]=B):B=t[54];let V;return t[55]!==L||t[56]!==R||t[57]!==z||t[58]!==B||t[59]!==C?(V=(0,$.jsxs)(`section`,{className:C,children:[L,R,z,B]}),t[55]=L,t[56]=R,t[57]=z,t[58]=B,t[59]=C,t[60]=V):V=t[60],V}var Xe=`https://console.xopc.ai/keys/tunnel`,Ze={reconfiguring:!1};function Qe(e){let t=(0,Z.c)(84),{t:n,brokerSecretFromEnv:r,brokerSecretMissing:i,brokerSecretConfiguredInConfig:a,brokerSecretMaskedValue:c,brokerSecretDraft:l,savingBrokerSecret:u,brokerSecretNotice:d,copyFailedLabel:f,onDraftChange:p,onSave:m,onClear:h,sectionRef:g}=e,_=(0,Q.useId)(),v=i&&!r,b=!v,[x,S]=(0,Q.useReducer)(y,Ze),{reconfiguring:C}=x,w;t[0]!==a||t[1]!==l||t[2]!==r||t[3]!==C?(w=a&&!r&&!C&&!l.trim(),t[0]=a,t[1]=l,t[2]=r,t[3]=C,t[4]=w):w=t[4];let T=w,E;t[5]!==n.copied||t[6]!==n.copyKey||t[7]!==n.hideKey||t[8]!==n.showKey?(E={show:n.showKey,hide:n.hideKey,copy:n.copyKey,copied:n.copied},t[5]=n.copied,t[6]=n.copyKey,t[7]=n.hideKey,t[8]=n.showKey,t[9]=E):E=t[9];let D=E,O;t[10]===l?O=t[11]:(O=l.trim().length>0&&!oe(l.trim()),t[10]=l,t[11]=O);let k=O,A;t[12]===p?A=t[13]:(A=()=>{S({type:`patch`,patch:{reconfiguring:!1}}),p(``)},t[12]=p,t[13]=A);let M=A,P=v&&`ring-1 ring-amber-500/30`,F;t[14]===P?F=t[15]:(F=s(P),t[14]=P,t[15]=F);let I=b?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`:v?`bg-amber-500/10 text-amber-700 dark:text-amber-400`:`bg-surface-hover text-fg-muted`,L;t[16]===I?L=t[17]:(L=s(`flex size-9 shrink-0 items-center justify-center rounded-lg`,I),t[16]=I,t[17]=L);let R;t[18]===b?R=t[19]:(R=b?(0,$.jsx)(o,{className:`size-4`,strokeWidth:2,"aria-hidden":!0}):(0,$.jsx)(de,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[18]=b,t[19]=R);let z;t[20]!==L||t[21]!==R?(z=(0,$.jsx)(`span`,{className:L,children:R}),t[20]=L,t[21]=R,t[22]=z):z=t[22];let B=b?n.brokerSecretReadyTitle:n.brokerSecretStepTitle,V;t[23]===B?V=t[24]:(V=(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:B}),t[23]=B,t[24]=V);let H=b?n.brokerSecretReadyHint:n.brokerSecretHint,U;t[25]===H?U=t[26]:(U=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:H}),t[25]=H,t[26]=U);let ee;t[27]!==v||t[28]!==n.brokerSecretMissingHint?(ee=v?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-amber-800 dark:text-amber-200`,children:n.brokerSecretMissingHint}):null,t[27]=v,t[28]=n.brokerSecretMissingHint,t[29]=ee):ee=t[29];let te;t[30]!==V||t[31]!==U||t[32]!==ee?(te=(0,$.jsxs)(`div`,{children:[V,U,ee]}),t[30]=V,t[31]=U,t[32]=ee,t[33]=te):te=t[33];let ne;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(N,{className:`size-3`,"aria-hidden":!0}),t[34]=ne):ne=t[34];let W;t[35]===n.brokerSecretConsoleLink?W=t[36]:(W=(0,$.jsxs)(`a`,{href:Xe,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,ne]}),t[35]=n.brokerSecretConsoleLink,t[36]=W);let G;t[37]!==r||t[38]!==n.brokerSecretEnvHint?(G=r?(0,$.jsx)(`p`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 text-xs text-fg-muted shadow-surface`,children:n.brokerSecretEnvHint}):null,t[37]=r,t[38]=n.brokerSecretEnvHint,t[39]=G):G=t[39];let K;t[40]!==a||t[41]!==l||t[42]!==r||t[43]!==c||t[44]!==k||t[45]!==M||t[46]!==f||t[47]!==_||t[48]!==v||t[49]!==h||t[50]!==p||t[51]!==m||t[52]!==C||t[53]!==u||t[54]!==D||t[55]!==T||t[56]!==n.brokerSecretCancelReconfigure||t[57]!==n.brokerSecretClear||t[58]!==n.brokerSecretMaskedHelp||t[59]!==n.brokerSecretNotInConfigFile||t[60]!==n.brokerSecretPlaceholder||t[61]!==n.brokerSecretReconfigure||t[62]!==n.brokerSecretRevealFailed||t[63]!==n.brokerSecretSave||t[64]!==n.brokerSecretSaveAndContinue||t[65]!==n.brokerSecretTitle?(K=T?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:_,children:n.brokerSecretTitle}),(0,$.jsx)(ae,{id:_,value:c,labels:D,reveal:$e,loadFailedLabel:f||n.brokerSecretRevealFailed,maskedHelp:n.brokerSecretMaskedHelp,notInConfigFile:n.brokerSecretNotInConfigFile,readOnly:!0}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,disabled:u,onClick:()=>{S({type:`patch`,patch:{reconfiguring:!0}})},children:n.brokerSecretReconfigure}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,disabled:u,onClick:h,children:n.brokerSecretClear})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:_,children:n.brokerSecretTitle}),(0,$.jsx)(ae,{id:_,value:l,onChange:p,placeholder:n.brokerSecretPlaceholder,labels:D,disabled:u}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(X,{type:`button`,disabled:u||!k,onClick:m,children:[u?(0,$.jsx)(j,{className:`size-4 animate-spin`}):null,v?n.brokerSecretSaveAndContinue:n.brokerSecretSave]}),a||r?(0,$.jsx)(X,{type:`button`,variant:`ghost`,disabled:u,onClick:h,children:n.brokerSecretClear}):null,C?(0,$.jsx)(X,{type:`button`,variant:`ghost`,disabled:u,onClick:M,children:n.brokerSecretCancelReconfigure}):null]})]}),t[40]=a,t[41]=l,t[42]=r,t[43]=c,t[44]=k,t[45]=M,t[46]=f,t[47]=_,t[48]=v,t[49]=h,t[50]=p,t[51]=m,t[52]=C,t[53]=u,t[54]=D,t[55]=T,t[56]=n.brokerSecretCancelReconfigure,t[57]=n.brokerSecretClear,t[58]=n.brokerSecretMaskedHelp,t[59]=n.brokerSecretNotInConfigFile,t[60]=n.brokerSecretPlaceholder,t[61]=n.brokerSecretReconfigure,t[62]=n.brokerSecretRevealFailed,t[63]=n.brokerSecretSave,t[64]=n.brokerSecretSaveAndContinue,t[65]=n.brokerSecretTitle,t[66]=K):K=t[66];let q;t[67]===d?q=t[68]:(q=d?(0,$.jsx)(`p`,{className:`text-xs text-emerald-700 dark:text-emerald-400`,children:d}):null,t[67]=d,t[68]=q);let re;t[69]!==te||t[70]!==W||t[71]!==G||t[72]!==K||t[73]!==q?(re=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[te,W,G,K,q]}),t[69]=te,t[70]=W,t[71]=G,t[72]=K,t[73]=q,t[74]=re):re=t[74];let ie;t[75]!==z||t[76]!==re?(ie=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[z,re]}),t[75]=z,t[76]=re,t[77]=ie):ie=t[77];let J;t[78]!==ie||t[79]!==F?(J=(0,$.jsx)(Ce,{className:F,children:ie}),t[78]=ie,t[79]=F,t[80]=J):J=t[80];let Y;return t[81]!==g||t[82]!==J?(Y=(0,$.jsx)(`div`,{ref:g,id:`tunnel-broker-secret-setup`,children:J}),t[81]=g,t[82]=J,t[83]=Y):Y=t[83],Y}function $e(){return te().then(et)}function et(e){return e.registrationSecret??null}function tt(e){let t=(0,Z.c)(10),{language:n,label:r,section:i,className:a}=e,o;t[0]!==n||t[1]!==i?(o=k(n,i),t[0]=n,t[1]=i,t[2]=o):o=t[2];let c;t[3]===a?c=t[4]:(c=s(`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]=c);let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(N,{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]!==c?(u=(0,$.jsxs)(`a`,{href:o,target:`_blank`,rel:`noreferrer`,className:c,children:[r,l]}),t[6]=r,t[7]=o,t[8]=c,t[9]=u):u=t[9],u}var nt=e(we(),1),rt={width:216,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}};async function it(e){return nt.toDataURL(e,rt)}function at(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 ot(e,t){let n=t.trim();return!n||!e?!1:e.candidates.some(e=>e.kind===`tunnel`&&e.url.trim()===n)}function st(e,t){return e?t?at(e)||e.recommended.url?.trim()||``:e.recommended.url?.trim()||``:``}function ct(e,t){let n=t?.preferLan===!0,r=!!e,{mutate:i}=_(),a=(0,Q.useRef)(!1),{data:o}=v(r?`tunnel-status`:null,M,{refreshInterval:6e4}),{data:s,mutate:c}=v(r?`tunnel-pair-context`:null,H,{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(),f=l&&!n,{data:p,mutate:m}=v(f&&r?`tunnel-qr`:null,E,{refreshInterval:4*6e4}),{data:h,mutate:g}=v(!f&&r&&s?.pairingReady?`tunnel-pair`:null,O,{refreshInterval:4*6e4}),[y,b]=(0,Q.useState)(``),[x,S]=(0,Q.useState)(``),[C,w]=(0,Q.useState)({pairContext:void 0,preferLan:n});if(!a.current&&(s!==C.pairContext||n!==C.preferLan)){w({pairContext:s,preferLan:n});let e=st(s,n);y!==e&&b(e)}let T=(0,Q.useCallback)(e=>{a.current=!0,b(e)},[]),k=(0,Q.useCallback)(()=>{let e=st(s,n);e&&(a.current=!0,b(e))},[s,n]),A=(0,Q.useCallback)(e=>{let t=e.trim();t&&(a.current=!0,b(t))},[]),j=(0,Q.useCallback)(e=>{a.current=!1,b(e?.trim()||st(s,n))},[s,n]),N=y.trim(),P=(0,Q.useMemo)(()=>{try{let e=new URL(N);return e.protocol===`http:`||e.protocol===`https:`}catch{return!1}},[N]),F=P&&u(N),I=!f&&!!(s&&!s.pairingReady&&s.blockReason===`GATEWAY_LOOPBACK_ONLY`),L=!f&&P&&!F&&!!h?.pairingSecret&&(s?.pairingReady===!0||!I),R=(0,Q.useMemo)(()=>{let e=at(s);return n?e||(N&&!ot(s,N)?N:``):N},[s,n,N]),z=(0,Q.useMemo)(()=>{if(!e)return``;if(x.trim())return x.trim();if(f&&p?.qrPayload?.trim())return p.qrPayload.trim();if(!L||!h?.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?R:t?.url??N;return i?d({baseUrl:i,pairingSecret:h.pairingSecret,lanUrl:n?null:t&&r?r.url:null}):``},[e,R,h?.pairingSecret,L,x,n,N,f,p?.qrPayload,s?.candidates]),B=D(()=>it(z),[z],{enabled:!!z,initial:null,errorData:null}),V=z?B.data:null,U=!!(z&&B.error!==null&&!B.loading);return{tunnelActive:l,tunnelStatus:o,tunnelQr:p,pairContext:s,pairBaseUrl:y,setPairBaseUrl:T,applySuggestedPairUrl:k,applyCandidateUrl:A,baseOk:P,localhostWarn:F,pairingBlocked:I,deepLink:z,qrPayload:z,qrDataUrl:V,qrGenFailed:U,encoding:!!(z&&!V&&!U),refreshQr:(0,Q.useCallback)(async e=>{if(e?.trim()){S(e.trim()),m({qrPayload:e.trim(),publicUrl:o?.publicUrl??``,lanUrl:p?.lanUrl??null},!1);return}S(``),await c(),f?await m():s?.pairingReady&&await g()},[g,c,m,s?.pairingReady,p?.lanUrl,o?.publicUrl,f]),resetPairBaseFromContext:j}}var lt={actionError:null,starting:!1,stopping:!1,savingAutoStart:!1,consentOpen:!1,autoStartConfirmOpen:!1,releaseConfirmOpen:!1,releasing:!1,brokerSecretDraft:``,savingBrokerSecret:!1,brokerSecretNotice:null};function ut({embedded:e=!1}){let t=p(e=>e.language),n=l(t).tunnelSettings,r=f(e=>e.token),i=!!r,[a,o]=(0,Q.useReducer)(y,lt),{actionError:c,starting:u,stopping:d,savingAutoStart:m,consentOpen:h,autoStartConfirmOpen:g,releaseConfirmOpen:_,releasing:b,brokerSecretDraft:x,savingBrokerSecret:S,brokerSecretNotice:C}=a,w=(0,Q.useRef)(null),T=ct(r??``),{data:E}=me(i),{data:D,error:O,isLoading:k,mutate:N}=v(i?`tunnel-status`:null,M,{refreshInterval:e=>u?1e3:e?.frpcDownload||e?.state===`connecting`||e?.state===`reconnecting`?2e3:6e4}),P=(0,Q.useMemo)(()=>{let e=E?.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 D?.config?.autoStart===!0},[E,D?.config?.autoStart]),I=(0,Q.useMemo)(()=>{let e=E?.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``},[E]),L=oe(I),R=D?.registrationSecret?.source===`env`,z=D?.registrationSecret?.source===`missing`,B=D?.registrationSecret?.configured===!0;(0,Q.useEffect)(()=>{let e=()=>{N()};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[N]);let V=(0,Q.useMemo)(()=>[n.consentBullet1,n.consentBullet2,n.consentBullet3],[n.consentBullet1,n.consentBullet2,n.consentBullet3]),H=(0,Q.useCallback)(async()=>{o({type:`patch`,patch:{actionError:null}}),o({type:`patch`,patch:{starting:!0}});try{let e=await ee();await N(),G(),await T.refreshQr(e.qrPayload)}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{o({type:`patch`,patch:{starting:!1}})}},[N,T.refreshQr]),U=(0,Q.useCallback)(()=>{if(!B){o({type:`patch`,patch:{actionError:n.brokerSecretRequiredBeforeStart}}),w.current?.scrollIntoView({behavior:`smooth`,block:`start`});return}if(D?.consentRequired){o({type:`patch`,patch:{consentOpen:!0}});return}H()},[B,D?.consentRequired,H,n.brokerSecretRequiredBeforeStart]),te=(0,Q.useCallback)(async()=>{o({type:`patch`,patch:{consentOpen:!1}}),o({type:`patch`,patch:{actionError:null}});try{await A(),await Promise.all([N(),H()])}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}},[N,H]),W=(0,Q.useCallback)(async()=>{o({type:`patch`,patch:{actionError:null}}),o({type:`patch`,patch:{stopping:!0}});try{await ne(),await Promise.all([T.refreshQr(),N()]),G()}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{o({type:`patch`,patch:{stopping:!1}})}},[N,T.refreshQr]),K=(0,Q.useCallback)(async e=>{o({type:`patch`,patch:{savingAutoStart:!0}}),o({type:`patch`,patch:{actionError:null}});try{await ce({autoStart:e}),G()}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{o({type:`patch`,patch:{savingAutoStart:!1}})}},[]),q=(0,Q.useCallback)(()=>{if(P){K(!1);return}if(D?.consentRequired){o({type:`patch`,patch:{actionError:n.consentExpiredBanner}});return}if(!D?.canAutoStart){o({type:`patch`,patch:{actionError:n.autoStartHint}});return}o({type:`patch`,patch:{autoStartConfirmOpen:!0}})},[K,D?.canAutoStart,D?.consentRequired,n,P]),re=(0,Q.useCallback)(async()=>{let e=x.trim();if(e){o({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await ce({registrationSecret:e}),o({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretSaved}}),G(),await N(),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}})}}},[x,N,n.brokerSecretSaved]),ie=(0,Q.useCallback)(async()=>{o({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await ce({registrationSecret:null}),o({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretCleared}}),G(),await N()}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{o({type:`patch`,patch:{savingBrokerSecret:!1}})}},[N,n.brokerSecretCleared]),ae=(0,Q.useCallback)(async()=>{o({type:`patch`,patch:{releaseConfirmOpen:!1,actionError:null,releasing:!0}});try{await ne({release:!0}),await Promise.all([T.refreshQr(),N()]),G()}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{o({type:`patch`,patch:{releasing:!1}})}},[N,T.refreshQr]),J=(0,Q.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:l(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 Y=D??{enabled:!1,state:`disconnected`,subdomain:null,publicUrl:null,connectedSince:null,frpcPid:null,lastHeartbeatAt:null,lastError:null,consentRequired:!0,config:{autoStart:P,brokerUrl:`https://frp.xopc.ai/api`}},se=D?.consentRequired&&(Y.enabled||P||D?.consent?.acceptedAt),le=(0,$.jsx)(Qe,{t:n,brokerSecretFromEnv:R,brokerSecretMissing:z,brokerSecretConfiguredInConfig:L,brokerSecretMaskedValue:L?I:``,brokerSecretDraft:x,savingBrokerSecret:S,brokerSecretNotice:C,copyFailedLabel:l(t).clipboard.copyFailed,onDraftChange:e=>o({type:`patch`,patch:{brokerSecretDraft:e}}),onSave:()=>void re(),onClear:()=>void ie(),sectionRef:w}),ue=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ne,{open:h,title:n.consentTitle,intro:n.consentIntro,bullets:V,checkboxLabel:n.consentCheckbox,confirmLabel:se?n.consentReconfirm:n.consentConfirm,cancelLabel:n.consentCancel,onConfirm:()=>void te(),onCancel:()=>o({type:`patch`,patch:{consentOpen:!1}})},h?`consent-open`:`consent-closed`),(0,$.jsx)(F,{open:g,title:n.autoStartConfirmTitle,description:n.autoStartConfirmBody,confirmLabel:n.autoStartConfirmLabel,cancelLabel:n.consentCancel,onConfirm:()=>{o({type:`patch`,patch:{autoStartConfirmOpen:!1}}),K(!0)},onCancel:()=>o({type:`patch`,patch:{autoStartConfirmOpen:!1}})}),(0,$.jsx)(F,{open:_,title:n.releaseConfirmTitle,description:n.releaseConfirmBody,confirmLabel:n.releaseConfirmLabel,cancelLabel:n.consentCancel,destructive:!0,onConfirm:()=>void ae(),onCancel:()=>o({type:`patch`,patch:{releaseConfirmOpen:!1}})})]});return e?(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[c?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:c}):null,le,(0,$.jsx)(Ye,{t:n,status:Y,isLoading:k,statusErr:O,starting:u,stopping:d,showConsentExpired:!!se,copyLabels:J,startDisabled:!B,startDisabledReason:B?void 0:n.brokerSecretRequiredBeforeStart,stepLabel:n.flowStepStart,onStart:U,onStop:()=>void W()}),(0,$.jsx)(ke,{pairQr:T,gatewayToken:r??``,streamlined:!0,onRefreshQr:()=>void T.refreshQr()}),(0,$.jsxs)(Ee,{showLabel:n.showOptions,hideLabel:n.hideOptions,children:[(0,$.jsxs)(`label`,{className:s(`flex items-center gap-3 text-sm text-fg`,!P&&!D?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:P,disabled:m||!P&&!D?.canAutoStart,onChange:q}),n.autoStart]}),!D?.canAutoStart&&!P?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.autoStartHint}):null,Y.subdomain||Y.publicUrl?(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-edge-subtle pt-4`,children:[(0,$.jsxs)(X,{type:`button`,variant:`secondary`,disabled:b||d,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>o({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[b?(0,$.jsx)(j,{className:`size-4 animate-spin`}):null,n.release]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint})]}):null]}),(0,$.jsx)(Ee,{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)(pe,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(tt,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]})}),ue]}):(0,$.jsxs)(`div`,{className:e?`flex w-full flex-col gap-6`:`flex w-full flex-col gap-6 px-3 py-8 sm:px-5 xl:px-6`,children:[e?null:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:n.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle})]}),c?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:c}):null,le,(0,$.jsx)(Ye,{t:n,status:Y,isLoading:k,statusErr:O,starting:u,stopping:d,showConsentExpired:!!se,copyLabels:J,startDisabled:!B,startDisabledReason:B?void 0:n.brokerSecretRequiredBeforeStart,onStart:U,onStop:()=>void W()}),(0,$.jsx)(ke,{pairQr:T,gatewayToken:r??``}),Y.subdomain||Y.publicUrl?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,$.jsxs)(X,{type:`button`,variant:`secondary`,disabled:b||d,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>o({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[b?(0,$.jsx)(j,{className:`size-4 animate-spin`}):null,n.release]})}):null,Y.subdomain||Y.publicUrl?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint}):null,(0,$.jsxs)(Ce,{children:[(0,$.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-fg`,children:n.optionsTitle}),(0,$.jsxs)(`label`,{className:s(`flex items-center gap-3 text-sm text-fg`,!P&&!D?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:P,disabled:m||!P&&!D?.canAutoStart,onChange:q}),n.autoStart]}),!D?.canAutoStart&&!P?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:n.autoStartHint}):null]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg 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)(pe,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(tt,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]}),ue]})}async function dt(){let e=await m(`/api/exposure/status`);if(!e.ok)throw Error(`Failed to load exposure status (${e.status})`);return await e.json()}async function ft(e=`serve`){let t=await m(`/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 pt(){let e=await m(`/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 mt=`https://tailscale.com/download`;function ht(e){let t=(0,Z.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`a`,{href:mt,target:`_blank`,rel:`noreferrer`,className:`font-medium text-accent hover:underline`,children:n}),t[0]=n,t[1]=r),r}function gt({embedded:e=!1}){let t=p(e=>e.language),n=l(t).remoteAccess.tailscale,r=(0,Q.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:l(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]),i=!!f(e=>e.token),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),{data:u,mutate:d,isLoading:m}=v(i?`exposure-status`:null,dt,{refreshInterval:3e4}),h=u?.tailscale.hostname,g=u?.tailscale.active===!0,_=u?.tailscale.cliAvailable!==!1,y=h?`https://${h}/`:null,b=(0,Q.useCallback)(async()=>{o(!0),c(null);try{await ft(`serve`),await d()}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}},[d]),x=(0,Q.useCallback)(async()=>{o(!0),c(null);try{await pt(),await d()}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}},[d]);if(!i)return null;let S=(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)(ht,{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&&u?.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)(ht,{label:n.cliMissingDownloadLink}),n.cliMissingSuffix]}):null,m&&!u?(0,$.jsxs)(`div`,{className:`grid gap-3`,"aria-busy":`true`,children:[(0,$.jsx)(I,{className:`h-20 rounded-lg`}),(0,$.jsx)(I,{className:`h-20 rounded-lg`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Ce,{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:g?n.statusActive:n.statusOff}),y?(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(ie,{text:y,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:g?(0,$.jsxs)(X,{type:`button`,variant:`secondary`,disabled:a,onClick:()=>void x(),children:[a?(0,$.jsx)(j,{className:`mr-1 size-4 animate-spin`}):null,n.disableServe]}):(0,$.jsxs)(X,{type:`button`,disabled:a||!_,onClick:()=>void b(),children:[a?(0,$.jsx)(j,{className:`mr-1 size-4 animate-spin`}):(0,$.jsx)(W,{className:`mr-1 size-4`}),n.enableServe]})})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.hint}),(0,$.jsx)(tt,{language:t,label:n.docsLink,section:`tailscale-serve`,className:`mt-2`})]})]});return e?S:(0,$.jsxs)(Ce,{children:[(0,$.jsx)(xe,{icon:pe,title:n.title,subtitle:n.subtitle}),S]})}function _t(){let e=(0,Z.c)(26),t=p(yt),n=f(vt),r;e[0]===t?r=e[1]:(r=l(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=ct(n??``,o),c;e[3]!==i.subtitle||e[4]!==i.title?(c=(0,$.jsx)(xe,{icon:Y,title:i.title,subtitle:i.subtitle}),e[3]=i.subtitle,e[4]=i.title,e[5]=c):c=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)(N,{className:`size-3.5`,"aria-hidden":!0}),e[8]=d):d=e[8];let m;e[9]===i.link?m=e[10]:(m=(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]=m);let h;e[11]!==u||e[12]!==m?(h=(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[u,m]}),e[11]=u,e[12]=m,e[13]=h):h=e[13];let g;e[14]!==c||e[15]!==h?(g=(0,$.jsxs)(Ce,{children:[c,h]}),e[14]=c,e[15]=h,e[16]=g):g=e[16];let _=n??``,v;e[17]===s?v=e[18]:(v=()=>void s.refreshQr(),e[17]=s,e[18]=v);let y;e[19]!==s||e[20]!==_||e[21]!==v?(y=(0,$.jsx)(ke,{pairQr:s,gatewayToken:_,lanOnly:!0,onRefreshQr:v}),e[19]=s,e[20]=_,e[21]=v,e[22]=y):y=e[22];let b;return e[23]!==y||e[24]!==g?(b=(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[g,y]}),e[23]=y,e[24]=g,e[25]=b):b=e[25],b}function vt(e){return e.token}function yt(e){return e.language}function bt(e){let t=(0,Z.c)(30),{embedded:n}=e,r=n===void 0?!1:n,i=p(xt),a;t[0]===i?a=t[1]:(a=l(i),t[0]=i,t[1]=a);let o=a.remoteAccess.ssh,[s,u]=(0,Q.useState)(!1),d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=async()=>{await c(`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`)&&(u(!0),setTimeout(()=>u(!1),2e3))},t[2]=d):d=t[2];let f=d,m;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(m=(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]=m):m=t[3];let h,g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>void f(),g=(0,$.jsx)(V,{className:`mr-1 size-4`}),t[4]=h,t[5]=g):(h=t[4],g=t[5]);let _=s?o.copied:o.copy,v;t[6]===_?v=t[7]:(v=(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsxs)(X,{type:`button`,variant:`ghost`,onClick:h,children:[g,_]})}),t[6]=_,t[7]=v);let y;t[8]!==r||t[9]!==o.hint?(y=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]=y):y=t[10];let b;t[11]!==v||t[12]!==y?(b=(0,$.jsxs)($.Fragment,{children:[m,v,y]}),t[11]=v,t[12]=y,t[13]=b):b=t[13];let x=b;if(r){let e;t[14]!==o.subtitle||t[15]!==o.title?(e=(0,$.jsx)(xe,{icon:U,title:o.title,subtitle:o.subtitle}),t[14]=o.subtitle,t[15]=o.title,t[16]=e):e=t[16];let n;t[17]===x?n=t[18]:(n=(0,$.jsx)(`div`,{className:`mt-4 space-y-2`,children:x}),t[17]=x,t[18]=n);let r;return t[19]!==e||t[20]!==n?(r=(0,$.jsxs)(Ce,{children:[e,n]}),t[19]=e,t[20]=n,t[21]=r):r=t[21],r}let S;t[22]!==o.subtitle||t[23]!==o.title?(S=(0,$.jsx)(xe,{icon:U,title:o.title,subtitle:o.subtitle}),t[22]=o.subtitle,t[23]=o.title,t[24]=S):S=t[24];let C;t[25]===x?C=t[26]:(C=(0,$.jsx)(`div`,{className:`mt-4`,children:x}),t[25]=x,t[26]=C);let w;return t[27]!==S||t[28]!==C?(w=(0,$.jsxs)(Ce,{children:[S,C]}),t[27]=S,t[28]=C,t[29]=w):w=t[29],w}function xt(e){return e.language}function St(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(bt,{embedded:!0}),e[0]=t):t=e[0],t}function Ct(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 wt(e){let t=(0,Z.c)(5),{label:n,kind:r}=e,i;t[0]===r?i=t[1]:(i=s(`rounded-full px-2 py-0.5 text-[11px] font-medium`,Ct(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 Tt(e){let t=(0,Z.c)(32),{onOpenTab:n}=e,r=p(Ot),i;t[0]===r?i=t[1]:(i=l(r),t[0]=r,t[1]=i);let a=i.remoteAccess.guide,o=!!f(Dt),c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c={refreshInterval:3e4},t[2]=c):c=t[2];let{data:u}=v(o?`exposure-status`:null,dt,c),d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d={refreshInterval:15e3},t[3]=d):d=t[3];let{data:m}=v(o?`tunnel-status`:null,M,d),h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h={refreshInterval:6e4},t[4]=h):h=t[4];let{data:g}=v(o?`tunnel-pair-context`:null,H,h);if(!o)return null;let _=u?.tailscale.active===!0,y=m?.state,b=m?.enabled&&y===`connected`,x=m?.enabled&&(y===`connecting`||y===`reconnecting`||!!m?.startProgress||!!m?.frpcDownload),S=(g?.candidates??[]).some(Et),C=_?`active`:`off`,T=_?a.statusActive:a.statusOff,E;t[5]!==a.tailscaleCardTitle||t[6]!==C||t[7]!==T?(E={tab:`tailscale`,icon:pe,title:a.tailscaleCardTitle,kind:C,statusLabel:T},t[5]=a.tailscaleCardTitle,t[6]=C,t[7]=T,t[8]=E):E=t[8];let D=b?`active`:x?`connecting`:`off`,O=b?a.statusActive:x?a.statusConnecting:a.statusOff,k;t[9]!==a.publicCardTitle||t[10]!==D||t[11]!==O?(k={tab:`public`,icon:w,title:a.publicCardTitle,kind:D,statusLabel:O},t[9]=a.publicCardTitle,t[10]=D,t[11]=O,t[12]=k):k=t[12];let A=S?`active`:`off`,j=S?a.statusActive:a.statusOff,N;t[13]!==a.reverseProxyCardTitle||t[14]!==A||t[15]!==j?(N={tab:`reverse-proxy`,icon:le,title:a.reverseProxyCardTitle,kind:A,statusLabel:j},t[13]=a.reverseProxyCardTitle,t[14]=A,t[15]=j,t[16]=N):N=t[16];let P;t[17]!==a.sshCardStatus||t[18]!==a.sshCardTitle?(P={tab:`ssh`,icon:U,title:a.sshCardTitle,kind:`off`,statusLabel:a.sshCardStatus},t[17]=a.sshCardStatus,t[18]=a.sshCardTitle,t[19]=P):P=t[19];let F;t[20]!==a.lanCardStatus||t[21]!==a.lanCardTitle?(F={tab:`lan`,icon:Y,title:a.lanCardTitle,kind:`off`,statusLabel:a.lanCardStatus},t[20]=a.lanCardStatus,t[21]=a.lanCardTitle,t[22]=F):F=t[22];let I;t[23]!==k||t[24]!==N||t[25]!==P||t[26]!==F||t[27]!==E?(I=[E,k,N,P,F],t[23]=k,t[24]=N,t[25]=P,t[26]=F,t[27]=E,t[28]=I):I=t[28];let L=I,R;return t[29]!==L||t[30]!==n?(R=(0,$.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5`,children:L.map(e=>{let t=e.icon;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.tab),className:s(`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)(wt,{label:e.statusLabel,kind:e.kind})]})]},`${e.tab}-${e.title}`)})}),t[29]=L,t[30]=n,t[31]=R):R=t[31],R}function Et(e){return e.kind===`reverse-proxy`}function Dt(e){return e.token}function Ot(e){return e.language}function kt(e){let t=(0,Z.c)(26),{title:n,description:r,recommended:i,icon:a,onOpen:o,openLabel:c,recommendedLabel:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=s(`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]=u):u=t[0];let d;t[1]===a?d=t[2]:(d=(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,children:(0,$.jsx)(a,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=a,t[2]=d);let f;t[3]===n?f=t[4]:(f=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=f);let p;t[5]!==i||t[6]!==l?(p=i&&l?(0,$.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:l}):null,t[5]=i,t[6]=l,t[7]=p):p=t[7];let m;t[8]!==f||t[9]!==p?(m=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f,p]}),t[8]=f,t[9]=p,t[10]=m):m=t[10];let h;t[11]===r?h=t[12]:(h=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=h);let g;t[13]!==m||t[14]!==h?(g=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[m,h]}),t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(K,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==g?(v=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[d,g,_]}),t[17]=d,t[18]=g,t[19]=v):v=t[19];let y;t[20]===c?y=t[21]:(y=(0,$.jsx)(`span`,{className:`mt-3 text-xs font-medium text-accent`,children:c}),t[20]=c,t[21]=y);let b;return t[22]!==o||t[23]!==y||t[24]!==v?(b=(0,$.jsxs)(`button`,{type:`button`,onClick:o,className:u,children:[v,y]}),t[22]=o,t[23]=y,t[24]=v,t[25]=b):b=t[25],b}function At(e){let t=(0,Z.c)(83),{onOpenTab:n}=e,r=p(Nt),i;t[0]===r?i=t[1]:(i=l(r),t[0]=r,t[1]=i);let a=i.remoteAccess,o=a.guide,s=!!f(Mt),c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c={refreshInterval:3e4},t[2]=c):c=t[2];let{data:u}=v(s?`exposure-status`:null,dt,c),d;t[3]===u?.conflicts?d=t[4]:(d=u?.conflicts??[],t[3]=u?.conflicts,t[4]=d);let m=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 h;t[7]===n?h=t[8]:(h=(0,$.jsx)(Tt,{onOpenTab:n}),t[7]=n,t[8]=h);let g;t[9]!==m||t[10]!==o.conflictsHint||t[11]!==o.conflictsTitle?(g=m.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:m.map(jt)})]}):null,t[9]=m,t[10]=o.conflictsHint,t[11]=o.conflictsTitle,t[12]=g):g=t[12];let _;t[13]===o.pickMethod?_=t[14]:(_=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:o.pickMethod}),t[13]=o.pickMethod,t[14]=_);let y;t[15]===n?y=t[16]:(y=()=>n(`tailscale`),t[15]=n,t[16]=y);let b;t[17]!==o.configure||t[18]!==o.recommended||t[19]!==o.tailscaleCardDesc||t[20]!==o.tailscaleCardTitle||t[21]!==y?(b=(0,$.jsx)(kt,{icon:pe,title:o.tailscaleCardTitle,description:o.tailscaleCardDesc,recommended:!0,recommendedLabel:o.recommended,openLabel:o.configure,onOpen:y}),t[17]=o.configure,t[18]=o.recommended,t[19]=o.tailscaleCardDesc,t[20]=o.tailscaleCardTitle,t[21]=y,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)(kt,{icon:w,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 T;t[32]!==o.configure||t[33]!==o.reverseProxyCardDesc||t[34]!==o.reverseProxyCardTitle||t[35]!==C?(T=(0,$.jsx)(kt,{icon:le,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]=T):T=t[36];let E;t[37]===n?E=t[38]:(E=()=>n(`ssh`),t[37]=n,t[38]=E);let D;t[39]!==o.configure||t[40]!==o.sshCardDesc||t[41]!==o.sshCardTitle||t[42]!==E?(D=(0,$.jsx)(kt,{icon:U,title:o.sshCardTitle,description:o.sshCardDesc,openLabel:o.configure,onOpen:E}),t[39]=o.configure,t[40]=o.sshCardDesc,t[41]=o.sshCardTitle,t[42]=E,t[43]=D):D=t[43];let O;t[44]===n?O=t[45]:(O=()=>n(`lan`),t[44]=n,t[45]=O);let k;t[46]!==o.configure||t[47]!==o.lanCardDesc||t[48]!==o.lanCardTitle||t[49]!==O?(k=(0,$.jsx)(kt,{icon:Y,title:o.lanCardTitle,description:o.lanCardDesc,openLabel:o.configure,onOpen:O}),t[46]=o.configure,t[47]=o.lanCardDesc,t[48]=o.lanCardTitle,t[49]=O,t[50]=k):k=t[50];let A;t[51]!==S||t[52]!==T||t[53]!==D||t[54]!==k||t[55]!==b?(A=(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:[b,S,T,D,k]}),t[51]=S,t[52]=T,t[53]=D,t[54]=k,t[55]=b,t[56]=A):A=t[56];let j;t[57]!==A||t[58]!==_?(j=(0,$.jsxs)(`div`,{children:[_,A]}),t[57]=A,t[58]=_,t[59]=j):j=t[59];let M;t[60]===o.oneAtATimeHint?M=t[61]:(M=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:o.oneAtATimeHint}),t[60]=o.oneAtATimeHint,t[61]=M);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)(tt,{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)(tt,{language:r,label:o.docsLink}),t[73]=o.docsLink,t[74]=r,t[75]=L):L=t[75];let R;return t[76]!==j||t[77]!==M||t[78]!==I||t[79]!==L||t[80]!==h||t[81]!==g?(R=(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[h,g,j,M,I,L]}),t[76]=j,t[77]=M,t[78]=I,t[79]=L,t[80]=h,t[81]=g,t[82]=R):R=t[82],R}function jt(e){return(0,$.jsx)(`li`,{children:e.message},e.code)}function Mt(e){return e.token}function Nt(e){return e.language}async function Pt(e){let t=await m(h(`/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 Ft(e){await g(h(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{publicUrl:e??null}})})}function It(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 Lt(){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`)||It(r)?null:n.toLowerCase().replace(/\/+$/,``)},[])}function Rt(){return s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,C,`dark:border-edge`)}function zt(e){return(e?.candidates.find(e=>e.kind===`reverse-proxy`))?.url?.trim()||null}function Bt(e){return(e?.candidates.find(e=>e.kind===`lan`&&e.reachable))?.url?.trim()||null}function Vt(){let e=p(e=>e.language),t=l(e).remoteAccess.reverseProxy,n=!!f(e=>e.token),r=Lt(),{mutate:i}=_(),{data:a,mutate:o}=v(n?`tunnel-pair-context`:null,H,{refreshInterval:6e4}),c=zt(a),[u,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)({busy:!1,result:null}),[y,b]=(0,Q.useState)({busy:!1,error:null});(0,Q.useEffect)(()=>{u||(c?m(c):r&&m(r))},[c,r,u]);let x=(0,Q.useMemo)(()=>u.trim()||(c??r??``),[c,r,u]),S=!c&&!!r&&x===r,C=Bt(a),{data:w,mutate:T}=v(n&&x?[`reverse-proxy-pair`,x]:null,()=>O(),{refreshInterval:4*6e4,revalidateOnFocus:!1}),E=(0,Q.useMemo)(()=>!x||!w?.pairingSecret?``:d({baseUrl:x,pairingSecret:w.pairingSecret,lanUrl:C}),[x,C,w?.pairingSecret]),k=D(()=>it(E),[E],{enabled:!!E,initial:null,errorData:null}),A=(0,Q.useCallback)(async()=>{let e=u.trim()||x;if(e){g({busy:!0,result:null});try{g({busy:!1,result:await Pt(e)})}catch(e){g({busy:!1,result:{ok:!1,code:`NETWORK_ERROR`,message:e instanceof Error?e.message:String(e)}})}}},[u,x]),M=(0,Q.useCallback)(async()=>{let e=x.trim();if(e){b({busy:!0,error:null});try{await Ft(e),await o(),await i(`tunnel-pair-context`),b({busy:!1,error:null})}catch(e){b({busy:!1,error:e instanceof Error?e.message:String(e)})}}},[x,i,o]),N=(0,Q.useCallback)(async()=>{b({busy:!0,error:null});try{await Ft(null),await o(),await i(`tunnel-pair-context`),m(``),g({busy:!1,result:null}),b({busy:!1,error:null})}catch(e){b({busy:!1,error:e instanceof Error?e.message:String(e)})}},[i,o]),P=(0,Q.useCallback)(async()=>{await T()},[T]);return n?(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(Ce,{children:[(0,$.jsx)(xe,{icon:pe,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:s(Rt(),`font-mono text-xs sm:flex-1 sm:min-w-0 sm:w-auto`),type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:t.urlPlaceholder,value:u,onChange:e=>{m(e.target.value),g({busy:!1,result:null})}}),(0,$.jsxs)(X,{type:`button`,variant:`secondary`,className:`shrink-0 whitespace-nowrap`,onClick:()=>void A(),disabled:h.busy||!u.trim(),children:[h.busy?(0,$.jsx)(j,{className:`size-3.5 animate-spin`}):null,h.busy?t.probing:t.probeButton]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.urlHint}),S&&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,h.result?(0,$.jsx)(Ht,{result:h.result,labels:t.probeStatus}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:[x&&c!==x?(0,$.jsxs)(X,{type:`button`,onClick:()=>void M(),disabled:y.busy,children:[y.busy?(0,$.jsx)(j,{className:`size-3.5 animate-spin`}):null,y.busy?t.saving:t.saveAsDefault]}):null,c?(0,$.jsx)(X,{type:`button`,variant:`ghost`,onClick:()=>void N(),disabled:y.busy,children:t.clear}):null]}),y.error?(0,$.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:y.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)(Ce,{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})]}),E?(0,$.jsxs)(X,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>void P(),children:[(0,$.jsx)(re,{className:`size-4`}),t.refreshQr]}):null]}),x?w?.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:`}),` `,x,C?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`br`,{}),(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:`lanUrl:`}),` `,C]}):null]}),k.data?(0,$.jsx)(`img`,{src:k.data,alt:``,className:`size-56 rounded-lg border border-edge-subtle bg-white object-contain p-3 dark:border-edge`}):k.loading?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.encoding}):null,(0,$.jsx)(ie,{text:E,labels:{copy:t.copyLink,copied:t.copied,copyFailed:l(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 Ht(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 Ut=[`guide`,`tailscale`,`public`,`reverse-proxy`,`ssh`,`lan`];function Wt(e){return e&&Ut.includes(e)?e:`guide`}function Gt(e,t){return e.tabs[t]}function Kt(e,t){return e.tabIntro[t]}function qt(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 Jt(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)(At,{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)(gt,{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)(ut,{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)(Vt,{}),t[4]=e):e=t[4],e}case`ssh`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(St,{}),t[5]=e):e=t[5],e}case`lan`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(_t,{}),t[6]=e):e=t[6],e}}}function Yt(){let e=(0,Z.c)(2),t=p(Zt),n=l(t).remoteAccess,r=!!f(Xt),[a,o]=i(),s=Wt(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 u=c,d=Kt(n,s),m=Ut.map(e=>({id:e,label:Gt(n,e)}));return(0,$.jsxs)(ve,{children:[(0,$.jsx)(_e,{title:n.pageTitle,subtitle:n.pageSubtitle,meta:(0,$.jsx)(tt,{language:t,label:n.docsLink,section:qt(s),className:`mt-1`})}),r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Te,{items:m,activeTab:s,onChange:u,ariaLabel:n.tabsAria,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`}),(0,$.jsx)(ye,{id:s,activeTab:s,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`,title:Gt(n,s),hint:s===`public`?void 0:d,children:(0,$.jsx)(Jt,{tab:s,onOpenTab:u})})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.guide.needToken})]})}function Xt(e){return e.token}function Zt(e){return e.language}export{Yt as RemoteAccessHub};
@@ -1 +0,0 @@
1
- import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./cn-JdwAhgNB.js";import{Qo as i,Zo as a,fs as o,hs as s}from"./index-BzPwnXho.js";var c=t();e();var l=n();function u(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function d(e){let t=e[`x-order`];return typeof t==`number`&&!Number.isNaN(t)?t:999}function f(e){let t=e[`x-group`];return typeof t==`string`&&t.length>0?t:``}function p(e){return e[`x-hidden`]===!0}function m(e){let t=e.properties;if(!u(t))return[];let n=[];for(let[e,r]of Object.entries(t))u(r)&&(p(r)||n.push({key:e,sub:r,order:d(r),group:f(r),hidden:!1}));return n.sort((e,t)=>e.order-t.order||e.key.localeCompare(t.key)),n}function h(e){let t=new Map;for(let n of e){let e=n.group;t.has(e)||t.set(e,[]),t.get(e).push(n)}return t}function g(e){let t=(0,c.c)(38),{name:n,s:r,value:i,onChange:u,disabled:d}=e,f=typeof r.description==`string`?r.description:void 0,p=(typeof r[`x-placeholder`]==`string`?r[`x-placeholder`]:null)||f,m=r.format;if(Array.isArray(r.enum)&&r.enum.every(v)){let e;t[0]===f?e=t[1]:(e=f?(0,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:f}):null,t[0]=f,t[1]=e);let o;t[2]===u?o=t[3]:(o=e=>u(e.target.value),t[2]=u,t[3]=o);let s;t[4]===r.enum?s=t[5]:(s=r.enum.map(_),t[4]=r.enum,t[5]=s);let c;t[6]!==d||t[7]!==n||t[8]!==o||t[9]!==s||t[10]!==i?(c=(0,l.jsx)(a,{name:n,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2 text-sm text-fg`,value:i,disabled:d,onChange:o,children:s}),t[6]=d,t[7]=n,t[8]=o,t[9]=s,t[10]=i,t[11]=c):c=t[11];let p;return t[12]!==e||t[13]!==c?(p=(0,l.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e,c]}),t[12]=e,t[13]=c,t[14]=p):p=t[14],p}if(m===`password`){let e;t[15]===f?e=t[16]:(e=f?(0,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:f}):null,t[15]=f,t[16]=e);let n;t[17]!==d||t[18]!==u||t[19]!==p||t[20]!==i?(n=(0,l.jsx)(s,{value:i,onChange:u,placeholder:p,labels:o,disabled:d,inputClassName:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg placeholder:text-fg-muted/70`}),t[17]=d,t[18]=u,t[19]=p,t[20]=i,t[21]=n):n=t[21];let r;return t[22]!==e||t[23]!==n?(r=(0,l.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e,n]}),t[22]=e,t[23]=n,t[24]=r):r=t[24],r}let h;t[25]===f?h=t[26]:(h=f?(0,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:f}):null,t[25]=f,t[26]=h);let g;t[27]===u?g=t[28]:(g=e=>u(e.target.value),t[27]=u,t[28]=g);let y;t[29]!==d||t[30]!==n||t[31]!==p||t[32]!==g||t[33]!==i?(y=(0,l.jsx)(`input`,{name:n,type:`text`,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg placeholder:text-fg-muted/70`,value:i,placeholder:p,disabled:d,onChange:g}),t[29]=d,t[30]=n,t[31]=p,t[32]=g,t[33]=i,t[34]=y):y=t[34];let b;return t[35]!==h||t[36]!==y?(b=(0,l.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[h,y]}),t[35]=h,t[36]=y,t[37]=b):b=t[37],b}function _(e){return(0,l.jsx)(i,{value:e,children:e},e)}function v(e){return typeof e==`string`}function y(e){let t=(0,c.c)(11),{s:n,value:r,onChange:i,disabled:a}=e,o=typeof n.description==`string`?n.description:void 0,s;t[0]===o?s=t[1]:(s=o?(0,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:o}):null,t[0]=o,t[1]=s);let u=Number.isFinite(r)?r:0,d;t[2]===i?d=t[3]:(d=e=>i(Number(e.target.value)),t[2]=i,t[3]=d);let f;t[4]!==a||t[5]!==u||t[6]!==d?(f=(0,l.jsx)(`input`,{type:`number`,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg`,value:u,disabled:a,onChange:d}),t[4]=a,t[5]=u,t[6]=d,t[7]=f):f=t[7];let p;return t[8]!==s||t[9]!==f?(p=(0,l.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[s,f]}),t[8]=s,t[9]=f,t[10]=p):p=t[10],p}function b(e){let t=(0,c.c)(11),{s:n,value:r,onChange:i,disabled:a,labels:o}=e,s=(typeof n.description==`string`?n.description:void 0)??(typeof n.title==`string`&&n.title.length>0?n.title:o?.defaultBooleanLabel??`Enable`),u;t[0]===i?u=t[1]:(u=e=>i(e.target.checked),t[0]=i,t[1]=u);let d;t[2]!==a||t[3]!==u||t[4]!==r?(d=(0,l.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border border-edge`,checked:r,disabled:a,onChange:u}),t[2]=a,t[3]=u,t[4]=r,t[5]=d):d=t[5];let f;t[6]===s?f=t[7]:(f=(0,l.jsx)(`span`,{children:s}),t[6]=s,t[7]=f);let p;return t[8]!==d||t[9]!==f?(p=(0,l.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[d,f]}),t[8]=d,t[9]=f,t[10]=p):p=t[10],p}function x(e){let t=(0,c.c)(27),{s:n,value:r,onChange:i,disabled:a,labels:o}=e,s=typeof n.description==`string`?n.description:void 0,d=n.items,f=u(d)?d.type:void 0;if(!(f===`string`||Array.isArray(f)&&f.includes(`string`))){let e=o?.unsupportedArrayType??`Unsupported array type`,n;return t[0]===e?n=t[1]:(n=(0,l.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e}),t[0]=e,t[1]=n),n}let p,m,h,g,_;if(t[2]!==s||t[3]!==a||t[4]!==i||t[5]!==r){let e=r.map(String);p=t=>{let n=t.trim();!n||e.includes(n)||i([...e,n])},g=`flex flex-col gap-1.5`,t[11]===s?_=t[12]:(_=s?(0,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:s}):null,t[11]=s,t[12]=_),m=`flex flex-wrap gap-1`,h=e.map(t=>(0,l.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 text-sm`,children:[t,(0,l.jsx)(`button`,{type:`button`,className:`text-fg-muted hover:text-fg`,disabled:a,onClick:()=>i(e.filter(e=>e!==t)),children:`×`})]},t)),t[2]=s,t[3]=a,t[4]=i,t[5]=r,t[6]=p,t[7]=m,t[8]=h,t[9]=g,t[10]=_}else p=t[6],m=t[7],h=t[8],g=t[9],_=t[10];let v;t[13]!==m||t[14]!==h?(v=(0,l.jsx)(`div`,{className:m,children:h}),t[13]=m,t[14]=h,t[15]=v):v=t[15];let y=o?.arrayAddPlaceholder??`Add and press Enter`,b;t[16]===p?b=t[17]:(b=e=>{e.key===`Enter`&&(e.preventDefault(),p(e.target.value),e.target.value=``)},t[16]=p,t[17]=b);let x;t[18]!==a||t[19]!==y||t[20]!==b?(x=(0,l.jsx)(`input`,{className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm`,disabled:a,placeholder:y,onKeyDown:b}),t[18]=a,t[19]=y,t[20]=b,t[21]=x):x=t[21];let S;return t[22]!==g||t[23]!==_||t[24]!==v||t[25]!==x?(S=(0,l.jsxs)(`div`,{className:g,children:[_,v,x]}),t[22]=g,t[23]=_,t[24]=v,t[25]=x,t[26]=S):S=t[26],S}function S(e){let t=(0,c.c)(66),{k:n,sub:r,value:i,onValue:a,disabled:o,labels:s}=e,d=r.type,f=(typeof r.title==`string`&&r.title.length>0?r.title:null)??n;if(d===`boolean`){let e;t[0]===f?e=t[1]:(e=(0,l.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[0]=f,t[1]=e);let n=i===!0,c;t[2]===a?c=t[3]:(c=e=>a(e),t[2]=a,t[3]=c);let u;t[4]!==o||t[5]!==s||t[6]!==r||t[7]!==n||t[8]!==c?(u=(0,l.jsx)(b,{s:r,value:n,disabled:o,onChange:c,labels:s}),t[4]=o,t[5]=s,t[6]=r,t[7]=n,t[8]=c,t[9]=u):u=t[9];let d;return t[10]!==e||t[11]!==u?(d=(0,l.jsxs)(`div`,{className:`space-y-1.5`,children:[e,u]}),t[10]=e,t[11]=u,t[12]=d):d=t[12],d}if(d===`number`||d===`integer`){let e;t[13]===f?e=t[14]:(e=(0,l.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[13]=f,t[14]=e);let n=typeof i==`number`?i:0,s;t[15]!==o||t[16]!==a||t[17]!==r||t[18]!==n?(s=(0,l.jsx)(y,{s:r,value:n,disabled:o,onChange:a}),t[15]=o,t[16]=a,t[17]=r,t[18]=n,t[19]=s):s=t[19];let c;return t[20]!==e||t[21]!==s?(c=(0,l.jsxs)(`div`,{className:`space-y-1.5`,children:[e,s]}),t[20]=e,t[21]=s,t[22]=c):c=t[22],c}if(d===`string`){let e;t[23]===f?e=t[24]:(e=(0,l.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[23]=f,t[24]=e);let s=typeof i==`string`?i:``,c;t[25]!==o||t[26]!==n||t[27]!==a||t[28]!==r||t[29]!==s?(c=(0,l.jsx)(g,{name:n,s:r,value:s,disabled:o,onChange:a}),t[25]=o,t[26]=n,t[27]=a,t[28]=r,t[29]=s,t[30]=c):c=t[30];let u;return t[31]!==e||t[32]!==c?(u=(0,l.jsxs)(`div`,{className:`space-y-1.5`,children:[e,c]}),t[31]=e,t[32]=c,t[33]=u):u=t[33],u}if(d===`array`){let e=r.items,n=u(e)?e.type:void 0;if(n===`string`||Array.isArray(n)&&n.includes(`string`)){let e;t[34]===f?e=t[35]:(e=(0,l.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[34]=f,t[35]=e);let n;t[36]===i?n=t[37]:(n=Array.isArray(i)&&i.every(C)?i.map(String):[],t[36]=i,t[37]=n);let c;t[38]!==o||t[39]!==s||t[40]!==a||t[41]!==r||t[42]!==n?(c=(0,l.jsx)(x,{s:r,value:n,disabled:o,onChange:a,labels:s}),t[38]=o,t[39]=s,t[40]=a,t[41]=r,t[42]=n,t[43]=c):c=t[43];let u;return t[44]!==e||t[45]!==c?(u=(0,l.jsxs)(`div`,{className:`space-y-1.5`,children:[e,c]}),t[44]=e,t[45]=c,t[46]=u):u=t[46],u}}if(d===`object`){let e;t[47]===i?e=t[48]:(e=u(i)?i:{},t[47]=i,t[48]=e);let n=e,c;t[49]===f?c=t[50]:(c=(0,l.jsx)(`summary`,{className:`cursor-pointer select-none px-3 py-2 text-sm font-medium text-fg group-open:rounded-b-none`,children:f}),t[49]=f,t[50]=c);let d;t[51]!==o||t[52]!==s||t[53]!==n||t[54]!==a||t[55]!==r?(d=(0,l.jsx)(`div`,{className:`border-t border-edge p-3`,children:(0,l.jsx)(w,{schema:r,values:n,onChange:a,disabled:o,labels:s})}),t[51]=o,t[52]=s,t[53]=n,t[54]=a,t[55]=r,t[56]=d):d=t[56];let p;return t[57]!==c||t[58]!==d?(p=(0,l.jsxs)(`details`,{className:`group rounded-lg border border-edge bg-surface-panel/40 open:bg-surface-base`,open:!0,children:[c,d]}),t[57]=c,t[58]=d,t[59]=p):p=t[59],p}let p;t[60]!==s||t[61]!==d||t[62]!==f?(p=s?.unsupportedFieldType?.(f,typeof d==`string`?d:void 0)??`${f}: unsupported field type${typeof d==`string`?` (${d})`:``}`,t[60]=s,t[61]=d,t[62]=f,t[63]=p):p=t[63];let m;return t[64]===p?m=t[65]:(m=(0,l.jsx)(`p`,{className:`text-xs text-fg-muted`,children:p}),t[64]=p,t[65]=m),m}function C(e){return typeof e==`string`||typeof e==`number`}function w(e){let t=(0,c.c)(28),{schema:n,values:i,onChange:a,disabled:o,className:s,labels:d}=e,f=o===void 0?!1:o,p;bb0:{if(n.type!==`object`){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],p=e;break bb0}let e;t[1]===n?e=t[2]:(e=m(n),t[1]=n,t[2]=e),p=e}let g=p,_;bb1:{if(g.length===0){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=new Map,t[3]=e):e=t[3],_=e;break bb1}let e;t[4]===g?e=t[5]:(e=h(g),t[4]=g,t[5]=e),_=e}let v=_,y;t[6]!==a||t[7]!==i?(y=(e,t)=>{a({...i,[e]:t})},t[6]=a,t[7]=i,t[8]=y):y=t[8];let b=y;if(n.type!==`object`||!u(n.properties)||g.length===0)return null;let x,C;if(t[9]!==s||t[10]!==f||t[11]!==v||t[12]!==d||t[13]!==b||t[14]!==i){let e=Array.from(v.keys()).sort(T);t[17]===s?x=t[18]:(x=r(`flex flex-col gap-4`,s),t[17]=s,t[18]=x);let n;t[19]!==f||t[20]!==v||t[21]!==d||t[22]!==b||t[23]!==i?(n=e=>{let t=(v.get(e)??[]).map(e=>(0,l.jsx)(S,{k:e.key,sub:e.sub,value:i[e.key],onValue:t=>b(e.key,t),disabled:f,labels:d},e.key));return e===``?(0,l.jsx)(`div`,{children:t},`default`):(0,l.jsxs)(`details`,{className:`group rounded-lg border border-edge bg-surface-panel/40 open:bg-surface-base`,open:!0,children:[(0,l.jsx)(`summary`,{className:`cursor-pointer select-none px-3 py-2 text-sm font-medium text-fg group-open:rounded-b-none`,children:e}),(0,l.jsx)(`div`,{className:`space-y-4 border-t border-edge p-3`,children:t})]},e)},t[19]=f,t[20]=v,t[21]=d,t[22]=b,t[23]=i,t[24]=n):n=t[24],C=e.map(n),t[9]=s,t[10]=f,t[11]=v,t[12]=d,t[13]=b,t[14]=i,t[15]=x,t[16]=C}else x=t[15],C=t[16];let w;return t[25]!==x||t[26]!==C?(w=(0,l.jsx)(`div`,{className:x,children:C}),t[25]=x,t[26]=C,t[27]=w):w=t[27],w}function T(e,t){return e===``?-1:t===``?1:e.localeCompare(t)}export{w 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{f as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./cn-JdwAhgNB.js";import{t as o}from"./messages-DQ5X6cXp.js";import{l as s,n as c,r as l,s as u}from"./locale-store-Bjvw7jtg.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{$i as f,At as p,Bo as m,Cn as h,Cs as g,Dc as _,Ds as v,Ec as y,El as b,En as x,Es as ee,Fo as S,Gi as C,Hi as w,Hl as T,Io as E,Ki as D,Lo as O,Ma as k,Mu as te,Na as A,Nt as j,Nu as M,Ot as N,Qi as P,Qo as F,Sc as I,Tn as L,Ui as R,Vc as z,Vi as B,Vl as ne,Vo as re,Vs as V,Wi as ie,Xi as ae,Yi as oe,Zi as se,Zo as ce,_s as H,bo as U,dc as le,eu as ue,il as de,is as fe,kt as W,ol as pe,qi as me,rl as he,rs as ge,sc as G,vs as K,wn as _e,ws as q,xo as J,zc as ve,zo as ye}from"./index-BzPwnXho.js";import{n as be,t as xe}from"./use-autosave-BLc4gfG0.js";import{t as Se}from"./settings-advanced-gate-DAvTIbgw.js";import{n as Ce,t as Y}from"./settings-form-section-C7rzhi7x.js";import{t as we}from"./page-tabs-HXweXqYE.js";var X=e(t(),1),Te=n(),Z=r();function Ee(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 De(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Oe(e){let t=(0,Te.c)(105),{session:n,variant:r,labels:i,sessionAgentId:o,sessionAgentAvatar:s,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 d=u,p;t[3]===n.name?p=t[4]:(p=n.name?.trim(),t[3]=n.name,t[4]=p);let m=!!p,h=n.status===`archived`,g=n.status===`pinned`,v=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,b;t[5]===v?b=t[6]:(b=a(`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]=b);let x;t[7]===c?x=t[8]:(x=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},t[7]=c,t[8]=x);let S=r===`list`&&`sm:py-3`,C;t[9]===S?C=t[10]:(C=a(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,S),t[9]=S,t[10]=C);let w;t[11]===n.sourceChannel?w=t[12]:(w=(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]=w);let T;t[13]===g?T=t[14]:(T=g?(0,Z.jsx)(_,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[13]=g,t[14]=T);let E;t[15]===n.updatedAt?E=t[16]:(E=Ee(n.updatedAt),t[15]=n.updatedAt,t[16]=E);let D;t[17]===E?D=t[18]:(D=(0,Z.jsx)(`span`,{children:E}),t[17]=E,t[18]=D);let O;t[19]!==D||t[20]!==T?(O=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[T,D]}),t[19]=D,t[20]=T,t[21]=O):O=t[21];let k;t[22]!==O||t[23]!==C||t[24]!==w?(k=(0,Z.jsxs)(`div`,{className:C,children:[w,O]}),t[22]=O,t[23]=C,t[24]=w,t[25]=k):k=t[25];let A=r===`list`&&`sm:py-3`,j;t[26]===A?j=t[27]:(j=a(`min-w-0 flex-1 px-3 py-2`,A),t[26]=A,t[27]=j);let N=r===`list`&&`sm:items-start`,P;t[28]===N?P=t[29]:(P=a(`flex gap-3`,N),t[28]=N,t[29]=P);let F;t[30]!==s||t[31]!==o?(F=(0,Z.jsx)(f,{agentId:o,avatar:s,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}),t[30]=s,t[31]=o,t[32]=F):F=t[32];let I;t[33]===d?I=t[34]:(I=(0,Z.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:d,children:d}),t[33]=d,t[34]=I);let L;t[35]!==n.key||t[36]!==m?(L=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]=L):L=t[37];let R;t[38]!==I||t[39]!==L?(R=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[I,L]}),t[38]=I,t[39]=L,t[40]=R):R=t[40];let B;t[41]!==P||t[42]!==F||t[43]!==R?(B=(0,Z.jsxs)(`div`,{className:P,children:[F,R]}),t[41]=P,t[42]=F,t[43]=R,t[44]=B):B=t[44];let re;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,Z.jsx)(z,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[45]=re):re=t[45];let ie;t[46]===n.messageCount?ie=t[47]:(ie=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[re,n.messageCount]}),t[46]=n.messageCount,t[47]=ie);let ae;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,Z.jsx)(ee,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[48]=ae):ae=t[48];let oe;t[49]===n.estimatedTokens?oe=t[50]:(oe=De(n.estimatedTokens),t[49]=n.estimatedTokens,t[50]=oe);let se;t[51]===oe?se=t[52]:(se=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[ae,oe]}),t[51]=oe,t[52]=se);let ce;t[53]!==ie||t[54]!==se?(ce=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[ie,se]}),t[53]=ie,t[54]=se,t[55]=ce):ce=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(je),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 le;t[58]!==j||t[59]!==B||t[60]!==ce||t[61]!==U?(le=(0,Z.jsxs)(`div`,{className:j,children:[B,ce,U]}),t[58]=j,t[59]=B,t[60]=ce,t[61]=U,t[62]=le):le=t[62];let ue;t[63]===l?ue=t[64]:(ue=()=>l(`continue`),t[63]=l,t[64]=ue);let de;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,Z.jsx)(z,{className:`size-4`,strokeWidth:1.75}),t[65]=de):de=t[65];let fe;t[66]!==i.continueChat||t[67]!==ue?(fe=(0,Z.jsx)(`button`,{type:`button`,className:H,title:i.continueChat,"aria-label":i.continueChat,onClick:ue,children:de}),t[66]=i.continueChat,t[67]=ue,t[68]=fe):fe=t[68];let W;t[69]!==h||t[70]!==i.archive||t[71]!==i.unarchive||t[72]!==l?(W=h?(0,Z.jsx)(`button`,{type:`button`,className:H,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>l(`unarchive`),children:(0,Z.jsx)(M,{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)(te,{className:`size-4`,strokeWidth:1.75})}),t[69]=h,t[70]=i.archive,t[71]=i.unarchive,t[72]=l,t[73]=W):W=t[73];let pe;t[74]!==g||t[75]!==i.pin||t[76]!==i.unpin||t[77]!==l?(pe=g?(0,Z.jsx)(`button`,{type:`button`,className:H,title:i.unpin,"aria-label":i.unpin,onClick:()=>l(`unpin`),children:(0,Z.jsx)(y,{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)(_,{className:`size-4`,strokeWidth:1.75})}),t[74]=g,t[75]=i.pin,t[76]=i.unpin,t[77]=l,t[78]=pe):pe=t[78];let me;t[79]===l?me=t[80]:(me=()=>l(`export`),t[79]=l,t[80]=me);let he;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,Z.jsx)(ne,{className:`size-4`,strokeWidth:1.75}),t[81]=he):he=t[81];let ge;t[82]!==i.export||t[83]!==me?(ge=(0,Z.jsx)(`button`,{type:`button`,className:H,title:i.export,"aria-label":i.export,onClick:me,children:he}),t[82]=i.export,t[83]=me,t[84]=ge):ge=t[84];let G;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(G=a(H,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[85]=G):G=t[85];let K;t[86]===l?K=t[87]:(K=()=>l(`delete`),t[86]=l,t[87]=K);let _e;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,Z.jsx)(V,{className:`size-4`,strokeWidth:1.75}),t[88]=_e):_e=t[88];let q;t[89]!==i.delete||t[90]!==K?(q=(0,Z.jsx)(`button`,{type:`button`,className:G,title:i.delete,"aria-label":i.delete,onClick:K,children:_e}),t[89]=i.delete,t[90]=K,t[91]=q):q=t[91];let J;t[92]!==fe||t[93]!==W||t[94]!==pe||t[95]!==ge||t[96]!==q?(J=(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:Ae,onKeyDown:ke,children:[fe,W,pe,ge,q]}),t[92]=fe,t[93]=W,t[94]=pe,t[95]=ge,t[96]=q,t[97]=J):J=t[97];let ve;return t[98]!==c||t[99]!==k||t[100]!==le||t[101]!==b||t[102]!==J||t[103]!==x?(ve=(0,Z.jsxs)(`div`,{role:`button`,tabIndex:0,className:b,onClick:c,onKeyDown:x,children:[k,le,J]}),t[98]=c,t[99]=k,t[100]=le,t[101]=b,t[102]=J,t[103]=x,t[104]=ve):ve=t[104],ve}function ke(e){return e.stopPropagation()}function Ae(e){return e.stopPropagation()}function je(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)}var Me={enabled:!0,triggerThreshold:.8,reserveTokens:8192,minMessagesBeforeCompact:10,keepRecentTokens:2e4,recentTurnsPreserve:3,summaryMaxTokens:2e3,summaryChunkTokens:24e3,summaryTimeoutMs:18e4,summaryRetries:2,qualityGuard:!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,...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 u(l(`/api/config`),{method:`PATCH`,body:JSON.stringify(Le(e))}),await U()}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=N();function He(){return a(`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`,g,`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,Te.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,Te.c)(19),{label:n,hint:r,checked:i,disabled:o,onChange:s}=e,c=o?`cursor-not-allowed opacity-55`:`cursor-pointer`,l;t[0]===c?l=t[1]:(l=a(`flex items-start gap-2 text-sm text-fg`,c),t[0]=c,t[1]=l);let u;t[2]===s?u=t[3]:(u=e=>s(e.target.checked),t[2]=s,t[3]=u);let d;t[4]!==i||t[5]!==o||t[6]!==u?(d=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:i,disabled:o,onChange:u}),t[4]=i,t[5]=o,t[6]=u,t[7]=d):d=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]!==l||t[16]!==d||t[17]!==m?(h=(0,Z.jsxs)(`label`,{className:l,children:[d,m]}),t[15]=l,t[16]=d,t[17]=m,t[18]=h):h=t[18],h}function qe({hasToken:e}){let t=o(c(e=>e.language)).sessions.compaction,{data:n,isLoading:r}=J(e),{data:i=[],isLoading:s}=d(e?L:null,x,{revalidateOnFocus:!1}),l=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:Fe(n.payload.config),[n]),[u,f]=(0,X.useReducer)(Ve,{form:null,baseline:null}),[p,m]=(0,X.useState)(``),h=(0,X.useRef)(!1),g=(0,X.useRef)(u.form);g.current=u.form;let _=(0,X.useRef)(null);W({enabled:e,parsed:l,dirty:h.current,trackedParsedRef:_,dispatch:f,onResetDirty:()=>{h.current=!1}});let y=u.form,b=u.baseline,ee=!!(y&&b&&JSON.stringify(y)!==JSON.stringify(b)),S=(0,X.useCallback)(e=>{h.current=!0,f({type:`patch`,patch:e})},[]),C=(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,model:t.summaryModel,minToolResultKeepChars:t.minToolResultKeepChars,maxActiveTranscriptBytes:t.maxActiveTranscriptMb,postCompactionSections:t.postCompactionSections})[e],[t]),w=xe({value:y,dirty:ee,onSave:(0,X.useCallback)(async e=>{try{await Re(e),f({type:`saved`,value:e}),h.current=!!(g.current&&JSON.stringify(g.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}}`,C(n)):null}});if(!e||!y)return r?(0,Z.jsx)(Y,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(A,{className:`h-5 w-48`}),(0,Z.jsx)(A,{className:`h-20 w-full rounded-xl`}),(0,Z.jsx)(A,{className:`h-36 w-full rounded-xl`})]})}):null;let T=We(y),E=Math.max(0,ze-y.reserveTokens),D=Math.min(Math.floor(ze*y.triggerThreshold),E),O=Math.min(100,D/ze*100),k=Math.min(100,E/ze*100),te=y.model?i.find(e=>e.id===y.model):void 0,M=te?.contextWindow&&y.summaryChunkTokens+y.summaryMaxTokens+4096>te.contextWindow,N=y.keepRecentTokens+y.reserveTokens>D,P=Math.round(y.summaryTimeoutMs*(y.summaryRetries+1)/1e3),F=e=>{let t=Be[e];S({...t,...y.model?{model:y.model}:{model:void 0},postCompactionSections:y.postCompactionSections})},R={balanced:{title:t.presetBalanced,hint:t.presetBalancedHint},preserve:{title:t.presetPreserve,hint:t.presetPreserveHint},early:{title:t.presetEarly,hint:t.presetEarlyHint}},z=()=>{let e=p.trim();!e||y.postCompactionSections.includes(e)||y.postCompactionSections.length>=12||(S({postCompactionSections:[...y.postCompactionSections,e]}),m(``))};return(0,Z.jsxs)(Y,{onBlurCapture:w.onBlurCapture,children:[(0,Z.jsx)(Ce,{icon:ve,title:t.title,subtitle:t.hint,trailing:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(be,{status:w.status,error:w.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:y.enabled,onChange:e=>S({enabled:e.target.checked})}),y.enabled?t.enabled:t.disabled]})]})}),w.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:w.error}):null,y.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:!y.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})]}),T===`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":T===e,className:a(`rounded-xl border px-3 py-3 text-left`,K.transition,K.focusRingPanel,T===e?`border-accent/50 bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg hover:bg-surface-hover`),onClick:()=>F(e),children:[(0,Z.jsx)(`span`,{className:`block text-sm font-medium`,children:R[e].title}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:R[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(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-accent`,style:{width:`${O}%`}})})]}),(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(E)})]}),(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:`${k}%`}})})]})]}),(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((y.triggerThreshold*100).toFixed(2)),min:10,max:98,step:.1,onChange:e=>S({triggerThreshold:e/100})}),(0,Z.jsx)($,{id:`compaction-reserve-tokens`,label:t.reserveTokens,hint:t.reserveTokensHint.replace(`{{tokens}}`,Ge(y.reserveTokens)),value:y.reserveTokens,min:1024,step:1024,onChange:e=>S({reserveTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-recent-turns`,label:t.recentTurnsPreserve,hint:t.recentTurnsPreserveHint,value:y.recentTurnsPreserve,min:1,max:12,onChange:e=>S({recentTurnsPreserve:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-keep-recent-tokens`,label:t.keepRecentTokens,hint:t.keepRecentTokensHint.replace(`{{tokens}}`,Ge(y.keepRecentTokens)),value:y.keepRecentTokens,min:1e3,step:1e3,onChange:e=>S({keepRecentTokens:Math.floor(e)})})]}),N?(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)(j,{value:y.model??``,disabled:!y.enabled,placeholder:t.summaryModelInherited,searchPlaceholder:t.summaryModelSearch,noMatches:t.summaryModelNoMatches,models:i,modelsLoading:s,className:`min-w-0 flex-1 justify-between`,contentAlign:`start`,showProviderSettingsFooter:!0,onChange:e=>S({model:e})}),y.model?(0,Z.jsx)(q,{type:`button`,variant:`secondary`,onClick:()=>S({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:y.qualityGuard,onChange:e=>S({qualityGuard:e})})]}),y.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)(Se,{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:y.minMessagesBeforeCompact,min:2,onChange:e=>S({minMessagesBeforeCompact:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-max-transcript-mb`,label:t.maxActiveTranscriptMb,hint:t.maxActiveTranscriptMbHint,value:Number((y.maxActiveTranscriptBytes/1e6).toFixed(3)),min:.064,step:.1,onChange:e=>S({maxActiveTranscriptBytes:Math.max(64e3,Math.round(e*1e6))})}),(0,Z.jsx)($,{id:`compaction-summary-max-tokens`,label:t.summaryMaxTokens,hint:t.summaryMaxTokensHint,value:y.summaryMaxTokens,min:256,step:256,onChange:e=>S({summaryMaxTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-chunk-tokens`,label:t.summaryChunkTokens,hint:t.summaryChunkTokensHint,value:y.summaryChunkTokens,min:1e3,step:1e3,onChange:e=>S({summaryChunkTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-timeout`,label:t.summaryTimeoutSeconds,hint:t.summaryTimeoutSecondsHint.replace(`{{seconds}}`,String(P)),value:y.summaryTimeoutMs/1e3,min:1,max:600,onChange:e=>S({summaryTimeoutMs:Math.round(e*1e3)})}),(0,Z.jsx)($,{id:`compaction-summary-retries`,label:t.summaryRetries,hint:t.summaryRetriesHint,value:y.summaryRetries,min:0,max:5,onChange:e=>S({summaryRetries:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-min-tool-result-chars`,label:t.minToolResultKeepChars,hint:t.minToolResultKeepCharsHint,value:y.minToolResultKeepChars,min:200,step:100,onChange:e=>S({minToolResultKeepChars:Math.floor(e)})})]}),M?(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}),y.postCompactionSections.length>0?(0,Z.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:y.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:a(`text-fg-muted hover:text-fg`,K.press),"aria-label":t.removeSection.replace(`{{section}}`,e),onClick:()=>S({postCompactionSections:y.postCompactionSections.filter(t=>t!==e)}),children:(0,Z.jsx)(v,{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:y.postCompactionSections.length>=12,placeholder:t.postCompactionSectionsPlaceholder,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),z())}}),(0,Z.jsxs)(q,{type:`button`,variant:`secondary`,disabled:!p.trim()||y.postCompactionSections.length>=12,onClick:z,children:[(0,Z.jsx)(I,{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 u(l(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),U()}function Qe(){return a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,g,`dark:border-edge`)}var $e=N();function et({hasToken:e}){let t=o(c(e=>e.language)).sessions.config,{data:n,isLoading:r}=J(e),i=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:Xe(n.payload.config),[n]),[a,s]=(0,X.useReducer)($e,{form:null,baseline:null}),l=a.form,u=a.baseline,d=(0,X.useRef)(!1),f=(0,X.useRef)(l);f.current=l;let p=(0,X.useRef)(null);W({enabled:e,parsed:i,dirty:d.current,trackedParsedRef:p,dispatch:s,onResetDirty:()=>{d.current=!1}});let m=!!(l&&u&&JSON.stringify(l)!==JSON.stringify(u)),h=(0,X.useCallback)(e=>{d.current=!0,s({type:`patch`,patch:e})},[]),g=xe({value:l,dirty:m,onSave:(0,X.useCallback)(async e=>{try{await Ze(e),s({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)(A,{className:`h-5 w-40`}),(0,Z.jsx)(A,{className:`h-24 w-full rounded-xl`})]})}):null:(0,Z.jsxs)(Y,{onBlurCapture:g.onBlurCapture,children:[(0,Z.jsx)(Ce,{icon:T,title:t.title,subtitle:t.hint,trailing:(0,Z.jsx)(be,{status:g.status,error:g.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)(ce,{className:Qe(),value:l.dmScope,onChange:e=>h({dmScope:e.target.value}),children:[(0,Z.jsx)(F,{value:`main`,children:t.dmScopeMain}),(0,Z.jsx)(F,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Z.jsx)(F,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Z.jsx)(F,{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,Te.c)(60),{open:n,loading:r,session:i,sessionAgentId:o,sessionAgentAvatar:s,labels:c,onClose:l,onArchive:u,onUnarchive:d,onPin:p,onUnpin:h,onExport:g,onDelete:_}=e,y=i?.status===`archived`,b=i?.status===`pinned`,x;t[0]===l?x=t[1]:(x=e=>!e&&l(),t[0]=l,t[1]=x);let ee;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,Z.jsx)(ye,{className:a(`xopc-dialog-overlay fixed inset-0 bg-scrim`,fe)}),t[2]=ee):ee=t[2];let C;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(C=a(`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`,ge,`dark:border-edge`),t[3]=C):C=t[3];let w;t[4]!==i||t[5]!==s||t[6]!==o?(w=i&&o?(0,Z.jsx)(f,{agentId:o,avatar:s,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}):null,t[4]=i,t[5]=s,t[6]=o,t[7]=w):w=t[7];let T;t[8]!==c.unnamedSession||t[9]!==i?.name?(T=i?.name?.trim()||c.unnamedSession,t[8]=c.unnamedSession,t[9]=i?.name,t[10]=T):T=t[10];let D;t[11]===T?D=t[12]:(D=(0,Z.jsx)(re,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:T}),t[11]=T,t[12]=D);let k;t[13]!==w||t[14]!==D?(k=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[w,D]}),t[13]=w,t[14]=D,t[15]=k):k=t[15];let te;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,Z.jsx)(v,{className:`size-5`,strokeWidth:1.75}),t[16]=te):te=t[16];let A;t[17]===c.close?A=t[18]:(A=(0,Z.jsx)(E,{asChild:!0,children:(0,Z.jsx)(q,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":c.close,children:te})}),t[17]=c.close,t[18]=A);let j;t[19]!==k||t[20]!==A?(j=(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:[k,A]}),t[19]=k,t[20]=A,t[21]=j):j=t[21];let M;t[22]!==c.detailLoading||t[23]!==c.detailMessages||t[24]!==r||t[25]!==i?(M=r?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:c.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:c.detailMessages}),(0,Z.jsx)(`ul`,{className:`space-y-3`,children:i.messages.map(rt)})]}):null,t[22]=c.detailLoading,t[23]=c.detailMessages,t[24]=r,t[25]=i,t[26]=M):M=t[26];let N;t[27]===M?N=t[28]:(N=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:M}),t[27]=M,t[28]=N);let P;t[29]!==c.detailExport||t[30]!==g?(P=(0,Z.jsx)(q,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:g,children:c.detailExport}),t[29]=c.detailExport,t[30]=g,t[31]=P):P=t[31];let F;t[32]!==y||t[33]!==c.archive||t[34]!==c.unarchive||t[35]!==u||t[36]!==d?(F=y?(0,Z.jsx)(q,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:d,children:c.unarchive}):(0,Z.jsx)(q,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:u,children:c.archive}),t[32]=y,t[33]=c.archive,t[34]=c.unarchive,t[35]=u,t[36]=d,t[37]=F):F=t[37];let I;t[38]!==b||t[39]!==c.pin||t[40]!==c.unpin||t[41]!==p||t[42]!==h?(I=b?(0,Z.jsx)(q,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:h,children:c.unpin}):(0,Z.jsx)(q,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:p,children:c.pin}),t[38]=b,t[39]=c.pin,t[40]=c.unpin,t[41]=p,t[42]=h,t[43]=I):I=t[43];let L;t[44]!==c.delete||t[45]!==_?(L=(0,Z.jsx)(q,{type:`button`,variant:`secondary`,className:`text-sm text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`,onClick:_,children:c.delete}),t[44]=c.delete,t[45]=_,t[46]=L):L=t[46];let R;t[47]!==P||t[48]!==F||t[49]!==I||t[50]!==L?(R=(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:[P,F,I,L]})}),t[47]=P,t[48]=F,t[49]=I,t[50]=L,t[51]=R):R=t[51];let z;t[52]!==j||t[53]!==N||t[54]!==R?(z=(0,Z.jsxs)(m,{children:[ee,(0,Z.jsxs)(O,{className:C,"aria-describedby":void 0,children:[j,N,R]})]}),t[52]=j,t[53]=N,t[54]=R,t[55]=z):z=t[55];let B;return t[56]!==n||t[57]!==x||t[58]!==z?(B=(0,Z.jsx)(S,{open:n,onOpenChange:x,children:z}),t[56]=n,t[57]=x,t[58]=z,t[59]=B):B=t[59],B}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,Te.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`?pe:G})),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)(we,{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,Te.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=o(c(e=>e.language)),t=e.sessions,n=s(e=>e.token),r=!!n,{data:l,mutate:u}=d(r?[`gateway-chat-agents`,n]:null,k,{revalidateOnFocus:!1}),f=l?.defaultId??`main`,g=l?.items??[],[v,y]=i(),x=lt(v.get(`tab`)),ee=(0,X.useCallback)(e=>{let t=new URLSearchParams(v);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),y(t,{replace:!0})},[v,y]),[T,E]=(0,X.useReducer)(p,v,mt),{searchInput:A,debouncedSearch:j,statusFilter:M,viewMode:N,channelFilter:F,sessions:I,loading:L,error:z,hasMore:ne,stats:V,detailOpen:ce,detailLoading:H,detailSession:U,confirmOpen:W,confirmKey:G}=T;(0,X.useEffect)(()=>{let e=setTimeout(()=>{let e=A.trim();j!==e&&E({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[A,j]);let J=v.toString(),ve=(0,X.useRef)(J);if(ve.current!==J){ve.current=J;let e=v.get(`q`)??``,t=v.get(`status`),n=v.get(`view`),r=(v.get(`channel`)??``).trim(),i=ot.has(t)?t:`all`,a=st.has(n)?n:`grid`,o=e.trim();E({type:`patch`,patch:{...A===e?{}:{searchInput:e},...j===o?{}:{debouncedSearch:o},...M===i?{}:{statusFilter:i},...N===a?{}:{viewMode:a},...F===r?{}:{channelFilter:r}}})}(0,X.useEffect)(()=>{let e=new URLSearchParams(v),t=j.trim();t?e.set(`q`,t):e.delete(`q`),M===`all`?e.delete(`status`):e.set(`status`,M),N===`grid`?e.delete(`view`):e.set(`view`,N),F?e.set(`channel`,F):e.delete(`channel`),e.toString()!==v.toString()&&y(e,{replace:!0})},[j,v,y,M,N,F]),(0,X.useEffect)(()=>{if(!r||x!==`sessions`)return;let e=!1;return(async()=>{E({type:`patch`,patch:{loading:!0,error:null}});try{let t=await D({limit:it,offset:0,...j?{search:j}:{},...M===`all`?{}:{status:M},...F?{channel:F}:{}});if(e)return;E({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||E({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||E({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,x,j,M,F,t.loadError]),(0,X.useEffect)(()=>{!r||x!==`sessions`||C().then(e=>E({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,x]),(0,X.useEffect)(()=>{if(!r||x!==`sessions`)return;let e=()=>void u();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,x,u]),(0,X.useEffect)(()=>{if(!r||x!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||E({type:`patch`,patch:{sessions:I.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:U&&U.key===t.key?{...U,name:t.name}:U}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,x,I,U]);let be=(0,X.useCallback)(async()=>{if(!(!r||L||!ne)){E({type:`patch`,patch:{loading:!0,error:null}});try{let e=await D({limit:it,offset:I.length,...j?{search:j}:{},...M===`all`?{}:{status:M},...F?{channel:F}:{}});E({type:`patch`,patch:{sessions:[...I,...e.items],hasMore:e.hasMore}})}catch(e){E({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{E({type:`patch`,patch:{loading:!1}})}}},[r,L,ne,I.length,j,M,F,t.loadError]),xe=(0,X.useCallback)((e,t)=>{E({type:`patch`,patch:{sessions:I.map(n=>n.key===e?{...n,status:t}:n),detailSession:U&&U.key===e?{...U,status:t}:U}})},[I,U]),Se=(0,X.useCallback)(async e=>{E({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{E({type:`patch`,patch:{detailSession:await ie(e)}})}catch{E({type:`patch`,patch:{detailOpen:!1}})}finally{E({type:`patch`,patch:{detailLoading:!1}})}},[]),Ce=e=>{Se(e)},Y=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:e},bubbles:!0}));return}if(t===`delete`){E({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await B(e),xe(e,`archived`);break;case`unarchive`:await oe(e),xe(e,`active`);break;case`pin`:await me(e),xe(e,`pinned`);break;case`unpin`:await ae(e),xe(e,`active`);break;case`export`:{let t=await R(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}C().then(e=>E({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},we=async e=>{try{await w(e),E({type:`patch`,patch:{sessions:I.filter(t=>t.key!==e),detailSession:U?.key===e?null:U,...U?.key===e?{detailOpen:!1}:{}}}),C().then(e=>E({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Te={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},Ee={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},De=[{key:`all`,label:t.filterAll,icon:pe},{key:`active`,label:t.filterActive,icon:ue},{key:`pinned`,label:t.filterPinned,icon:_},{key:`archived`,label:t.filterArchived,icon:te}],ke=(()=>{let e=Object.entries(V?.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:x,onChange:ee}),(0,Z.jsx)(pt,{s:t,id:`settings`,activeTab:x,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:x,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:De.map(({key:e,label:t,icon:n})=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":M===e,onClick:()=>E({type:`patch`,patch:{statusFilter:e}}),className:a(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,K.transition,K.focusRingPanel,M===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)(le,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`input`,{type:`search`,value:A,onChange:e=>E({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"data-debounced-query":j||void 0,className:`min-w-0 flex-1 border-0 bg-transparent text-sm text-fg placeholder:text-fg-disabled focus:outline-none focus:ring-0`})]})]}),(0,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:()=>E({type:`patch`,patch:{channelFilter:``}}),className:a(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,K.transition,K.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}),ke.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":F===e,onClick:()=>E({type:`patch`,patch:{channelFilter:e}}),className:a(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,K.transition,K.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,V?.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:V.byChannel[e]})]},e))]}),V?(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[V.totalSessions,t.totalSessions],[V.activeSessions,t.activeSessions],[V.pinnedSessions,t.pinnedSessions],[V.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,z?(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:z}):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:I.length})}),(0,Z.jsxs)(`div`,{className:_e,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,Z.jsx)(q,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":N===`grid`,onClick:()=>E({type:`patch`,patch:{viewMode:`grid`}}),className:a(h,`size-7 p-0`,N===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,N===`grid`&&`text-accent-fg`),children:(0,Z.jsx)(de,{className:`size-3.5`,strokeWidth:1.5})}),(0,Z.jsx)(q,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":N===`list`,onClick:()=>E({type:`patch`,patch:{viewMode:`list`}}),className:a(h,`size-9 p-0`,N===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,N===`list`&&`text-accent-fg`),children:(0,Z.jsx)(he,{className:`size-3.5`,strokeWidth:1.5})})]})]}),L&&I.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))}):I.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)(b,{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)(q,{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:a(`grid min-w-0 gap-3`,N===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":j||void 0,children:I.map(e=>{let t=P(e,f);return(0,Z.jsx)(Oe,{session:e,variant:N,labels:Te,sessionAgentId:t,sessionAgentAvatar:se(t,g),onOpen:()=>Ce(e.key),onAction:t=>void Y(e.key,t)},e.key)})}),ne?(0,Z.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Z.jsx)(q,{type:`button`,variant:`secondary`,disabled:L,onClick:()=>void be(),children:t.loadMore})}):null]})]})]}),(0,Z.jsx)(nt,{open:ce,loading:H,session:U,sessionAgentId:U?P(U,f):void 0,sessionAgentAvatar:U?se(P(U,f),g):void 0,labels:Ee,onClose:()=>{E({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>U&&void Y(U.key,`archive`),onUnarchive:()=>U&&void Y(U.key,`unarchive`),onPin:()=>U&&void Y(U.key,`pin`),onUnpin:()=>U&&void Y(U.key,`unpin`),onExport:()=>U&&void Y(U.key,`export`),onDelete:()=>U&&E({type:`patch`,patch:{confirmKey:U.key,confirmOpen:!0}})}),(0,Z.jsx)(S,{open:W,onOpenChange:e=>E({type:`patch`,patch:{confirmOpen:e}}),children:(0,Z.jsxs)(m,{children:[(0,Z.jsx)(ye,{className:a(`xopc-dialog-overlay fixed inset-0 bg-scrim`,fe)}),(0,Z.jsxs)(O,{className:a(`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`,ge),children:[(0,Z.jsx)(re,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:G?at(t.deleteSessionMessage,{name:I.find(e=>e.key===G)?.name?.trim()||e.chat.newSession}):``}),(0,Z.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Z.jsx)(q,{type:`button`,variant:`secondary`,onClick:()=>E({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Z.jsx)(q,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{G&&we(G),E({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{Fr as e}from"./index-BzPwnXho.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{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-JdwAhgNB.js";import{Oc as r,vs as i}from"./index-BzPwnXho.js";var a=e();function o(){return`rounded-2xl border border-edge-subtle bg-surface-base px-4 py-5 sm:px-5`}var s=t();function c(e){let t=(0,a.c)(7),{children:r,className:i,id:c,onBlurCapture:l}=e,u;t[0]===i?u=t[1]:(u=n(o(),i),t[0]=i,t[1]=u);let d;return t[2]!==r||t[3]!==c||t[4]!==l||t[5]!==u?(d=(0,s.jsx)(`section`,{id:c,className:u,onBlurCapture:l,children:r}),t[2]=r,t[3]=c,t[4]=l,t[5]=u,t[6]=d):d=t[6],d}var l=`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted transition-colors dark:bg-surface-hover/70`;function u(e){let t=(0,a.c)(29),{icon:o,title:c,subtitle:u,trailing:d,titleAccessory:f,className:p,iconInteractive:m,iconLeading:h}=e,g;t[0]===o?g=t[1]:(g=(0,s.jsx)(o,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=o,t[1]=g);let _=h??g,v;t[2]===h?v=t[3]:(v=h?n(`flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface-panel p-0 ring-1 ring-inset ring-edge-subtle transition-[box-shadow] hover:ring-accent/40 dark:ring-edge-subtle`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,i.press):n(l,`hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,i.press),t[2]=h,t[3]=v);let y=v,b=!!(m&&h),x;t[4]===p?x=t[5]:(x=n(`mb-5 flex items-start gap-3`,p),t[4]=p,t[5]=x);let S;t[6]!==m||t[7]!==h||t[8]!==_||t[9]!==y||t[10]!==b?(S=m?b?(0,s.jsxs)(`span`,{className:`relative shrink-0`,children:[(0,s.jsx)(`button`,{type:`button`,id:m.id,onClick:m.onClick,"aria-label":m.ariaLabel,className:y,children:_}),(0,s.jsx)(`span`,{className:`pointer-events-none absolute -bottom-0.5 -right-0.5 flex size-4 items-center justify-center rounded-md border border-edge bg-surface-panel text-fg-muted shadow-sm dark:border-edge dark:bg-surface-base`,"aria-hidden":!0,children:(0,s.jsx)(r,{className:`size-2.5`,strokeWidth:2.25})})]}):(0,s.jsx)(`button`,{type:`button`,id:m.id,onClick:m.onClick,"aria-label":m.ariaLabel,className:y,children:_}):(0,s.jsx)(`div`,{className:n(h?`flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface-panel ring-1 ring-inset ring-edge-subtle dark:ring-edge-subtle`:l),"aria-hidden":!h,children:_}),t[6]=m,t[7]=h,t[8]=_,t[9]=y,t[10]=b,t[11]=S):S=t[11];let C;t[12]===c?C=t[13]:(C=(0,s.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:c}),t[12]=c,t[13]=C);let w;t[14]!==C||t[15]!==f?(w=(0,s.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[C,f]}),t[14]=C,t[15]=f,t[16]=w):w=t[16];let T;t[17]===u?T=t[18]:(T=u?(0,s.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:u}):null,t[17]=u,t[18]=T);let E;t[19]!==w||t[20]!==T?(E=(0,s.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[w,T]}),t[19]=w,t[20]=T,t[21]=E):E=t[21];let D;t[22]===d?D=t[23]:(D=d?(0,s.jsx)(`div`,{className:`shrink-0`,children:d}):null,t[22]=d,t[23]=D);let O;return t[24]!==x||t[25]!==S||t[26]!==E||t[27]!==D?(O=(0,s.jsxs)(`div`,{className:x,children:[S,E,D]}),t[24]=x,t[25]=S,t[26]=E,t[27]=D,t[28]=O):O=t[28],O}export{u as n,o as r,c as t};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-JdwAhgNB.js";import{Ll as r}from"./index-BzPwnXho.js";var i=e(),a=t();function o(e){let t=(0,i.c)(14),r,o,s,c,l;t[0]===e?(r=t[1],o=t[2],s=t[3],c=t[4],l=t[5]):({children:r,className:o,gap:c,padding:l,...s}=e,t[0]=e,t[1]=r,t[2]=o,t[3]=s,t[4]=c,t[5]=l);let u=c===void 0?`gap-4`:c,d=l===void 0?`px-3 py-6 sm:px-5 xl:px-6`:l,f;t[6]!==o||t[7]!==u||t[8]!==d?(f=n(`flex min-h-full w-full flex-col bg-surface-panel`,u,d,o),t[6]=o,t[7]=u,t[8]=d,t[9]=f):f=t[9];let p;return t[10]!==r||t[11]!==s||t[12]!==f?(p=(0,a.jsx)(`div`,{className:f,...s,children:r}),t[10]=r,t[11]=s,t[12]=f,t[13]=p):p=t[13],p}function s(e){let t=(0,i.c)(20),{title:o,subtitle:s,docsLink:c,docsLabel:l,meta:u,actions:d,className:f}=e,p;t[0]===f?p=t[1]:(p=n(`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,f),t[0]=f,t[1]=p);let m;t[2]===o?m=t[3]:(m=(0,a.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:o}),t[2]=o,t[3]=m);let h;t[4]===s?h=t[5]:(h=s?(0,a.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s}):null,t[4]=s,t[5]=h);let g;t[6]!==l||t[7]!==c?(g=c&&l?(0,a.jsxs)(`a`,{href:c,target:`_blank`,rel:`noreferrer`,className:`mt-1 inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[l,(0,a.jsx)(r,{className:`size-3.5`,"aria-hidden":!0})]}):null,t[6]=l,t[7]=c,t[8]=g):g=t[8];let _;t[9]!==u||t[10]!==m||t[11]!==h||t[12]!==g?(_=(0,a.jsxs)(`div`,{className:`min-w-0`,children:[m,h,g,u]}),t[9]=u,t[10]=m,t[11]=h,t[12]=g,t[13]=_):_=t[13];let v;t[14]===d?v=t[15]:(v=d?(0,a.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:d}):null,t[14]=d,t[15]=v);let y;return t[16]!==p||t[17]!==_||t[18]!==v?(y=(0,a.jsxs)(`header`,{className:p,children:[_,v]}),t[16]=p,t[17]=_,t[18]=v,t[19]=y):y=t[19],y}function c(e){let t=(0,i.c)(13),{id:r,activeTab:o,tabIdPrefix:s,panelIdPrefix:c,title:l,hint:u,showHeading:d,framed:f,children:p,className:m}=e,h=d===void 0?!0:d,g=f===void 0?!0:f;if(o!==r)return null;let _=`${c}-${r}`,v=`${s}-${r}`,y=g&&`rounded-2xl border border-edge-subtle bg-surface-base px-4 py-5 sm:px-5`,b;t[0]!==m||t[1]!==y?(b=n(`min-w-0`,y,m),t[0]=m,t[1]=y,t[2]=b):b=t[2];let x;t[3]!==u||t[4]!==h||t[5]!==l?(x=h&&(l||u)?(0,a.jsxs)(`div`,{className:`mb-5`,children:[l?(0,a.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:l}):null,u?(0,a.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:u}):null]}):null,t[3]=u,t[4]=h,t[5]=l,t[6]=x):x=t[6];let S;return t[7]!==p||t[8]!==_||t[9]!==v||t[10]!==b||t[11]!==x?(S=(0,a.jsxs)(`section`,{id:_,role:`tabpanel`,"aria-labelledby":v,className:b,children:[x,p]}),t[7]=p,t[8]=_,t[9]=v,t[10]=b,t[11]=x,t[12]=S):S=t[12],S}export{s as n,o as r,c 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{t as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./cn-JdwAhgNB.js";import{t as o}from"./messages-DQ5X6cXp.js";import{l as s,n as c,r as l,s as u}from"./locale-store-Bjvw7jtg.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{Bs as f,Da as p,En as m,Kc as h,Mr as g,Pu as _,Tn as v,Ys as y,cu as b,du as x,eu as S,gs as C,hc as w,ll as T,pn as E,tu as D,vs as O,xo as k}from"./index-BzPwnXho.js";import{n as A,r as j}from"./settings-page-layout-CTMmZcwj.js";import{n as M}from"./settings-loading-skeleton-BS36Mjzz.js";import{n as N,t as P}from"./settings-form-section-C7rzhi7x.js";var F=e(t(),1),I=n();function L(e){if(!e||typeof e!=`object`)return 0;let t=e.providers;return!t||typeof t!=`object`||Array.isArray(t)?0:Object.values(t).filter(e=>typeof e==`string`&&C(e)).length}function R(e){if(!e||typeof e!=`object`)return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t,r=typeof n.defaultPreset==`string`&&n.defaultPreset.trim()?n.defaultPreset.trim():`default`,i=n.capabilityPresets,a=i&&typeof i==`object`&&!Array.isArray(i)?i[r]:void 0,o=a&&typeof a==`object`&&!Array.isArray(a)?a.models:void 0;if(!o||typeof o!=`object`||Array.isArray(o))return``;let s=o,c=s.roles;if(!c||typeof c!=`object`||Array.isArray(c))return``;let l=c,u=typeof s.defaultRole==`string`&&s.defaultRole.trim()?s.defaultRole.trim():Object.keys(l)[0],d=u?l[u]:void 0;if(!d||typeof d!=`object`||Array.isArray(d))return``;let f=d.model;return typeof f==`string`?f.trim():``}function z(e){if(!e||typeof e!=`object`)return!1;let t=e.channels;return!t||typeof t!=`object`||Array.isArray(t)?!1:Object.values(t).some(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;if(`configured`in t||`config`in t||`schema`in t||`uiHints`in t){if(t.configured===!0)return!0;let e=t.config;if(!e||typeof e!=`object`||Array.isArray(e))return!1;let n=e;return n.enabled===!0||Object.keys(n).length>0}return t.enabled===!0||Object.keys(t).length>0})}function B(e){if(!e||typeof e!=`object`)return{enabled:!1,backend:`extension`};let t=e.browser;if(!t||typeof t!=`object`||Array.isArray(t))return{enabled:!1,backend:`extension`};let n=t;return{enabled:n.enabled===!0,backend:typeof n.backend==`string`&&n.backend.trim()?n.backend.trim():`extension`}}function V(e){return e?`pass`:`fail`}function H(e){if(e===`provider-auth`)return`/settings/capabilities/models`;if(e===`config-health`)return`/settings/gateway`;if(e===`state-integrity`||e===`workspace-status`)return`/agents`;if(e===`database-schema`||e===`session-integrity`)return`/settings/sessions`;if(e===`channel-config`||e===`channel-pairing-pending`||e.startsWith(`channel:`))return`/channels`;if(e===`security-audit`||e===`gateway-service`||e===`gateway-health`)return`/settings/gateway`;if(e===`version-check`)return`/settings/desktop-app`}function U(e){return{fail:4,warn:3,skip:2,pass:1}[e]}function ee(e){return e.filter(e=>e.status===`fail`||e.status===`warn`).map(e=>({id:e.id,label:e.label,status:e.status,message:e.message,hints:e.hints,path:H(e.id),source:`doctor`})).toSorted((e,t)=>U(t.status)-U(e.status)||e.label.localeCompare(t.label))}function W(e){let t=new Map(e.doctorChecks.map(e=>[e.id,e])),n=[];for(let e of[`security-audit`,`channel-config`,`channel-pairing-pending`,`gateway-health`]){let r=t.get(e);r&&n.push({id:r.id,label:r.label,status:r.status,message:r.message,path:H(r.id)})}if(e.logsHealth){let t=e.logsHealth.stats?.errorsLast24h??0;n.push({id:`logs-health`,label:`Logs`,status:e.logsHealth.shuttingDown||t>0?`warn`:`pass`,message:e.logsHealth.shuttingDown?`Logger is shutting down.`:t>0?`${t} error(s) in the last 24 hours.`:`Log system is healthy.`,path:`/settings/logs`})}for(let t of e.browserDiagnostics??[])n.push(t);return n}function te(e){let t=L(e.config),n=e.providerMeta?.configured??t,r=e.providerMeta?.total??0,i=n>0||t>0,a=R(e.config),o=a.length>0,s=e.hasToken&&e.realtimeConnected,c=z(e.config),l=e.skillCount>0,u=e.doctorChecks??[],d=ee(u),f=[{id:`gateway`,done:s,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline},{id:`provider`,done:i,detail:i?e.providerMeta&&e.providerMeta.total>0?e.labels.providersMetaReady(n,r):e.labels.providersConfigured(t):e.labels.providersMissing},{id:`defaultModel`,done:o,detail:o?e.labels.modelConfigured(a):e.labels.modelMissing},{id:`channel`,done:c,optional:!0,detail:c?e.labels.channelConfigured:e.labels.channelMissing},{id:`skill`,done:l,optional:!0,detail:l?e.labels.skillsConfigured(e.skillCount):e.labels.skillsMissing}],p=f.filter(e=>!e.optional).every(e=>e.done),m=f.every(e=>e.done),h=[{id:`gateway`,status:V(s),title:`Gateway`,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline,path:`/settings/gateway`},{id:`provider`,status:V(i),title:`Model provider`,detail:i?e.providerMeta&&e.providerMeta.total>0?e.labels.providersMetaReady(n,r):e.labels.providersConfigured(t):e.labels.providersMissing,path:`/settings/capabilities/models`},{id:`defaultModel`,status:V(o),title:`Default model`,detail:o?e.labels.modelConfigured(a):e.labels.modelMissing,path:`/settings/capabilities/models`},{id:`ready`,status:p?`pass`:`fail`,title:`Chat readiness`,detail:p?e.labels.readyToChat:e.labels.modelMissing,path:`/chat`}],g=d.some(e=>e.status===`fail`),_=d.some(e=>e.status===`warn`),v=g?`blocked`:_?`attention`:p?`ready`:`setup`,y=W({doctorChecks:u,logsHealth:e.logsHealth,browserDiagnostics:e.browserDiagnostics});return{gatewayConnected:s,providerConfigured:i,providerCount:t,providerMetaConfigured:n,providerMetaTotal:r,defaultModel:a,defaultModelConfigured:o,channelConfigured:c,skillInstalled:l,skillCount:e.skillCount,checklist:f,readiness:h,issues:d,healthTier:v,diagnosticSignals:y,requiredComplete:p,allComplete:m}}function ne(e){return B(e)}function G(e){return!e.id||!e.label||!e.status||!e.message||![`pass`,`warn`,`fail`,`skip`].includes(e.status)?null:{id:e.id,label:e.label,status:e.status,message:e.message,hints:Array.isArray(e.hints)?e.hints.filter(e=>typeof e==`string`):[],fixed:e.fixed===!0,findings:Array.isArray(e.findings)?e.findings:void 0}}function re(){return l(`/api/doctor`)}async function ie(){return((await u(re())).checks??[]).map(G).filter(e=>e!==null)}function ae(){return l(`/api/logs/health`)}async function oe(){return u(ae())}function K(e){return e?`pass`:`warn`}function q(e){return`/settings/agent-browser?tab=${encodeURIComponent(e)}`}function se(e){return e?.enabled?[`setup-browser-diagnostics`,e]:null}async function ce(e){if(!e.enabled)return[];if(e.backend===`local`){let e=await u(l(`/api/browser/playwright/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-playwright`,label:`Browser: Playwright`,status:K(t),message:t?`Local Chromium is installed.`:e.payload?.reason??`Local Chromium is not installed.`,path:q(`local`)}]}if(e.backend===`cloakbrowser`){let e=await u(l(`/api/browser/cloakbrowser/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-cloakbrowser`,label:`Browser: CloakBrowser`,status:K(t),message:t?`CloakBrowser ${e.payload?.version??``}`.trim():`CloakBrowser is not installed.`,path:q(`cloakbrowser`)}]}if(e.backend===`extension`){let e=await u(l(`/api/browser/extension-status?probe=true`)),t=e.artifacts?.installed===!0,n=e.connected===!0,r=e.artifacts?.needsRefresh===!0||e.artifacts?.needsChromeReload===!0;return[{id:`browser-extension`,label:`Browser: Chrome extension`,status:n?`pass`:`warn`,message:n?`Chrome extension bridge is connected.`:t?r?`Chrome extension needs refresh.`:`Chrome extension is installed but not connected.`:`Chrome extension is not installed.`,path:q(`extension`)}]}return[{id:`browser-playwright`,label:`Browser`,status:`skip`,message:`Browser backend "${e.backend}" is not checked on this overview.`,path:q(e.backend||`overview`)}]}function J(){let e=(0,I.c)(57),t=s(me),n=c(pe),r;e[0]===n?r=e[1]:(r=o(n),e[0]=n,e[1]=r);let i=r,a=i.setupStatus.labels,l=p(fe),{data:u,error:f,isLoading:h,mutate:g}=k(!!t),_;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(_={revalidateOnFocus:!1},e[2]=_):_=e[2];let{data:y,error:b,isLoading:x,mutate:S}=d(t?`setup-checklist-skills`:null,de,_),C;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(C={revalidateOnFocus:!1},e[3]=C):C=e[3];let{data:w,error:T,isLoading:D,mutate:O}=d(t?`setup-checklist-provider-meta`:null,E,C),A;e[4]===t?A=e[5]:(A=t?re():null,e[4]=t,e[5]=A);let j;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(j={revalidateOnFocus:!1},e[6]=j):j=e[6];let{data:M,error:N,isLoading:P,mutate:F}=d(A,ie,j),L;e[7]===t?L=e[8]:(L=t?ae():null,e[7]=t,e[8]=L);let R;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(R={revalidateOnFocus:!1},e[9]=R):R=e[9];let{data:z,isLoading:B,mutate:V}=d(L,oe,R);u?.payload?.config;let H=u?.payload?.config,U;e[10]===H?U=e[11]:(U=ne(H),e[10]=H,e[11]=U);let ee=t?U:null,W;e[12]===ee?W=e[13]:(W=se(ee),e[12]=ee,e[13]=W);let G;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(G={revalidateOnFocus:!1},e[14]=G):G=e[14];let{data:K,isLoading:q,mutate:ce}=d(W,ue,G),J;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(J={revalidateOnFocus:!1},e[15]=J):J=e[15],d(t?v:null,m,J);let Y=!t||!h&&!x&&!D&&!P&&!B&&!q,X=!!(f||b||T||N),Z;bb0:{if(!t||!Y){Z=null;break bb0}let n=y?.catalog?.length??0,r;if(e[16]!==K||e[17]!==u?.payload?.config||e[18]!==M||e[19]!==a.channelConfigured||e[20]!==a.channelMissing||e[21]!==a.gatewayOffline||e[22]!==a.gatewayOnline||e[23]!==a.modelConfigured||e[24]!==a.modelMissing||e[25]!==a.providersConfigured||e[26]!==a.providersMetaReady||e[27]!==a.providersMissing||e[28]!==a.skillsConfigured||e[29]!==a.skillsMissing||e[30]!==z||e[31]!==i.setupStatus.requiredCompleteMessage||e[32]!==w||e[33]!==l||e[34]!==n||e[35]!==t){let o=w?.filter(le).length??0,s=w?.length??0,c;e[37]===a.providersConfigured?c=e[38]:(c=e=>a.providersConfigured.replace(`{{count}}`,String(e)),e[37]=a.providersConfigured,e[38]=c);let d;e[39]===a.providersMetaReady?d=e[40]:(d=(e,t)=>a.providersMetaReady.replace(`{{configured}}`,String(e)).replace(`{{total}}`,String(t)),e[39]=a.providersMetaReady,e[40]=d);let f;e[41]===a.modelConfigured?f=e[42]:(f=e=>a.modelConfigured.replace(`{{model}}`,e),e[41]=a.modelConfigured,e[42]=f);let p;e[43]===a.skillsConfigured?p=e[44]:(p=e=>a.skillsConfigured.replace(`{{count}}`,String(e)),e[43]=a.skillsConfigured,e[44]=p),r=te({hasToken:!!t,realtimeConnected:l,config:u?.payload?.config,skillCount:n,providerMeta:s>0?{configured:o,total:s}:null,doctorChecks:M,logsHealth:z,browserDiagnostics:K,labels:{gatewayOnline:a.gatewayOnline,gatewayOffline:a.gatewayOffline,providersConfigured:c,providersMetaReady:d,providersMissing:a.providersMissing,modelConfigured:f,modelMissing:a.modelMissing,channelConfigured:a.channelConfigured,channelMissing:a.channelMissing,skillsConfigured:p,skillsMissing:a.skillsMissing,readyToChat:i.setupStatus.requiredCompleteMessage}}),e[16]=K,e[17]=u?.payload?.config,e[18]=M,e[19]=a.channelConfigured,e[20]=a.channelMissing,e[21]=a.gatewayOffline,e[22]=a.gatewayOnline,e[23]=a.modelConfigured,e[24]=a.modelMissing,e[25]=a.providersConfigured,e[26]=a.providersMetaReady,e[27]=a.providersMissing,e[28]=a.skillsConfigured,e[29]=a.skillsMissing,e[30]=z,e[31]=i.setupStatus.requiredCompleteMessage,e[32]=w,e[33]=l,e[34]=n,e[35]=t,e[36]=r}else r=e[36];Z=r}let he=Z,Q;e[45]!==ce||e[46]!==g||e[47]!==F||e[48]!==V||e[49]!==O||e[50]!==S?(Q=async()=>{await Promise.all([g(),S(),O(),F(),V(),ce()])},e[45]=ce,e[46]=g,e[47]=F,e[48]=V,e[49]=O,e[50]=S,e[51]=Q):Q=e[51];let ge=Q,$;return e[52]!==X||e[53]!==Y||e[54]!==ge||e[55]!==he?($={ready:Y,error:X,snapshot:he,refresh:ge},e[52]=X,e[53]=Y,e[54]=ge,e[55]=he,e[56]=$):$=e[56],$}function le(e){return e.configured}function ue(e){let[,t]=e;return ce(t)}function de(){return g()}function fe(e){return e.connectionState===`connected`}function pe(e){return e.language}function me(e){return e.token}var Y=r();function X(e){return e===`pass`?`border-success/30 bg-success-soft text-success`:e===`warn`?`border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`fail`?`border-red-500/30 bg-red-500/10 text-red-700 dark:text-red-300`:`border-edge bg-surface-hover text-fg-muted`}function Z(e){return e===`pass`?b:e===`warn`?f:e===`fail`?D:T}function he(e,t){return e===`blocked`?{icon:D,className:`bg-red-500/10 text-red-950 dark:text-red-100`,title:t.health.blockedTitle,body:t.health.blockedBody,action:t.health.viewIssues,targetId:`next-steps`}:e===`attention`?{icon:f,className:`bg-amber-500/10 text-amber-950 dark:text-amber-100`,title:t.health.attentionTitle,body:t.health.attentionBody,action:t.health.viewIssues,targetId:`next-steps`}:e===`setup`?{icon:S,className:`bg-surface-base text-fg shadow-surface`,title:t.health.setupTitle,body:t.health.setupBody,action:t.health.continueSetup,targetId:`next-steps`}:{icon:b,className:`bg-success-soft text-success`,title:t.health.readyTitle,body:t.health.readyBody,action:t.health.startChat,actionPath:`/chat`}}function Q(e){let t=(0,I.c)(48),{tier:n,issueCount:r,onRunDoctor:s,ready:l,doctorRunning:u,doctorRunState:d}=e,f=c(ge),p,m,g,_,v,y,b,S,C,T,E;if(t[0]!==r||t[1]!==f||t[2]!==n){m=o(f).setupStatus;let e=he(n,m),s=e.icon,c=`targetId`in e&&typeof e.targetId==`string`?e.targetId:null,l=`actionPath`in e&&typeof e.actionPath==`string`?e.actionPath:`/chat`;p=c?(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>document.getElementById(c)?.scrollIntoView({block:`start`,behavior:`smooth`}),className:`inline-flex items-center gap-1 rounded-lg bg-surface-base px-3 py-2 text-sm font-medium text-fg shadow-sm hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[e.action,(0,Y.jsx)(x,{className:`size-4`,"aria-hidden":!0})]}):(0,Y.jsxs)(i,{to:l,className:`inline-flex items-center gap-1 rounded-lg bg-surface-base px-3 py-2 text-sm font-medium text-fg shadow-sm hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[e.action,(0,Y.jsx)(x,{className:`size-4`,"aria-hidden":!0})]}),E=a(`rounded-xl p-4`,e.className),T=`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,S=`flex min-w-0 gap-3`,C=(0,Y.jsx)(s,{className:`mt-0.5 size-5 shrink-0`,"aria-hidden":!0}),v=`min-w-0`,y=(0,Y.jsx)(`h2`,{className:`text-base font-semibold`,children:e.title}),b=(0,Y.jsx)(`p`,{className:`mt-1 text-sm opacity-85`,children:e.body}),g=`mt-2 text-xs opacity-75`,_=m.health.issueCount.replace(`{{count}}`,String(r)),t[0]=r,t[1]=f,t[2]=n,t[3]=p,t[4]=m,t[5]=g,t[6]=_,t[7]=v,t[8]=y,t[9]=b,t[10]=S,t[11]=C,t[12]=T,t[13]=E}else p=t[3],m=t[4],g=t[5],_=t[6],v=t[7],y=t[8],b=t[9],S=t[10],C=t[11],T=t[12],E=t[13];let D;t[14]!==g||t[15]!==_?(D=(0,Y.jsx)(`p`,{className:g,children:_}),t[14]=g,t[15]=_,t[16]=D):D=t[16];let k;t[17]!==D||t[18]!==v||t[19]!==y||t[20]!==b?(k=(0,Y.jsxs)(`div`,{className:v,children:[y,b,D]}),t[17]=D,t[18]=v,t[19]=y,t[20]=b,t[21]=k):k=t[21];let A;t[22]!==k||t[23]!==S||t[24]!==C?(A=(0,Y.jsxs)(`div`,{className:S,children:[C,k]}),t[22]=k,t[23]=S,t[24]=C,t[25]=A):A=t[25];let j;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(j=a(`inline-flex items-center gap-2 rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,O.press),t[26]=j):j=t[26];let M=!l||u,N;t[27]===u?N=t[28]:(N=u?(0,Y.jsx)(h,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,Y.jsx)(w,{className:`size-4`,"aria-hidden":!0}),t[27]=u,t[28]=N);let P=u?m.health.runDoctorRunning:m.health.runDoctor,F;t[29]!==u||t[30]!==s||t[31]!==M||t[32]!==N||t[33]!==P?(F=(0,Y.jsxs)(`button`,{type:`button`,className:j,onClick:s,disabled:M,"aria-busy":u,children:[N,P]}),t[29]=u,t[30]=s,t[31]=M,t[32]=N,t[33]=P,t[34]=F):F=t[34];let L;t[35]!==p||t[36]!==F?(L=(0,Y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[p,F]}),t[35]=p,t[36]=F,t[37]=L):L=t[37];let R;t[38]!==A||t[39]!==L||t[40]!==T?(R=(0,Y.jsxs)(`div`,{className:T,children:[A,L]}),t[38]=A,t[39]=L,t[40]=T,t[41]=R):R=t[41];let z=u?m.health.doctorRunningMessage:d===`success`?m.health.doctorCompleteMessage:d===`error`?m.health.doctorFailedMessage:m.health.doctorIdleMessage,B;t[42]===z?B=t[43]:(B=(0,Y.jsx)(`p`,{className:`mt-3 text-xs opacity-75`,role:`status`,"aria-live":`polite`,children:z}),t[42]=z,t[43]=B);let V;return t[44]!==R||t[45]!==B||t[46]!==E?(V=(0,Y.jsxs)(`section`,{className:E,children:[R,B]}),t[44]=R,t[45]=B,t[46]=E,t[47]=V):V=t[47],V}function ge(e){return e.language}function $(e){let t=(0,I.c)(34),{issue:n,fixLabel:r}=e,o;t[0]===n.status?o=t[1]:(o=Z(n.status),t[0]=n.status,t[1]=o);let s=o,c;t[2]===s?c=t[3]:(c=(0,Y.jsx)(s,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=s,t[3]=c);let l;t[4]===n.label?l=t[5]:(l=(0,Y.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:n.label}),t[4]=n.label,t[5]=l);let u;t[6]===n.status?u=t[7]:(u=a(`rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase`,X(n.status)),t[6]=n.status,t[7]=u);let d;t[8]!==n.status||t[9]!==u?(d=(0,Y.jsx)(`span`,{className:u,children:n.status}),t[8]=n.status,t[9]=u,t[10]=d):d=t[10];let f;t[11]!==l||t[12]!==d?(f=(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[l,d]}),t[11]=l,t[12]=d,t[13]=f):f=t[13];let p;t[14]===n.message?p=t[15]:(p=(0,Y.jsx)(`span`,{className:`mt-1 block text-sm text-fg-muted`,children:n.message}),t[14]=n.message,t[15]=p);let m;t[16]===n.hints[0]?m=t[17]:(m=n.hints[0]?(0,Y.jsx)(`span`,{className:`mt-1 block truncate text-xs text-fg-subtle`,children:n.hints[0]}):null,t[16]=n.hints[0],t[17]=m);let h;t[18]!==f||t[19]!==p||t[20]!==m?(h=(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[f,p,m]}),t[18]=f,t[19]=p,t[20]=m,t[21]=h):h=t[21];let g;t[22]!==r||t[23]!==n.path?(g=n.path?(0,Y.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs font-medium text-accent-fg`,children:[r,(0,Y.jsx)(x,{className:`size-4`,"aria-hidden":!0})]}):null,t[22]=r,t[23]=n.path,t[24]=g):g=t[24];let _;t[25]!==g||t[26]!==c||t[27]!==h?(_=(0,Y.jsxs)(Y.Fragment,{children:[c,h,g]}),t[25]=g,t[26]=c,t[27]=h,t[28]=_):_=t[28];let v=_;if(n.path){let e;return t[29]!==v||t[30]!==n.path?(e=(0,Y.jsx)(i,{to:n.path,className:`flex items-start gap-3 rounded-lg bg-surface-panel/80 p-3 shadow-surface hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:v}),t[29]=v,t[30]=n.path,t[31]=e):e=t[31],e}let y;return t[32]===v?y=t[33]:(y=(0,Y.jsx)(`div`,{className:`flex items-start gap-3 rounded-lg bg-surface-panel/80 p-3 shadow-surface`,children:v}),t[32]=v,t[33]=y),y}function _e(e){let t=(0,I.c)(27),{item:n,labels:r}=e,o;t[0]===n.status?o=t[1]:(o=Z(n.status),t[0]=n.status,t[1]=o);let s=o,c=r[n.id]??n.title,l;t[2]===n.status?l=t[3]:(l=a(`flex size-7 shrink-0 items-center justify-center rounded-full border`,X(n.status)),t[2]=n.status,t[3]=l);let u;t[4]===s?u=t[5]:(u=(0,Y.jsx)(s,{className:`size-4`,"aria-hidden":!0}),t[4]=s,t[5]=u);let d;t[6]!==l||t[7]!==u?(d=(0,Y.jsx)(`span`,{className:l,children:u}),t[6]=l,t[7]=u,t[8]=d):d=t[8];let f;t[9]===c?f=t[10]:(f=(0,Y.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:c}),t[9]=c,t[10]=f);let p;t[11]===n.detail?p=t[12]:(p=(0,Y.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.detail}),t[11]=n.detail,t[12]=p);let m;t[13]!==f||t[14]!==p?(m=(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[f,p]}),t[13]=f,t[14]=p,t[15]=m):m=t[15];let h;t[16]===n.path?h=t[17]:(h=n.path?(0,Y.jsx)(x,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}):null,t[16]=n.path,t[17]=h);let g;t[18]!==d||t[19]!==m||t[20]!==h?(g=(0,Y.jsxs)(Y.Fragment,{children:[d,m,h]}),t[18]=d,t[19]=m,t[20]=h,t[21]=g):g=t[21];let _=g;if(n.path){let e;return t[22]!==_||t[23]!==n.path?(e=(0,Y.jsx)(i,{to:n.path,className:`flex items-center gap-3 rounded-lg p-3 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:_}),t[22]=_,t[23]=n.path,t[24]=e):e=t[24],e}let v;return t[25]===_?v=t[26]:(v=(0,Y.jsx)(`div`,{className:`flex items-center gap-3 rounded-lg p-3`,children:_}),t[25]=_,t[26]=v),v}function ve(e){let t=(0,I.c)(29),{signal:n,fixLabel:r}=e,o;t[0]===n.status?o=t[1]:(o=Z(n.status),t[0]=n.status,t[1]=o);let s=o,c;t[2]===s?c=t[3]:(c=(0,Y.jsx)(s,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=s,t[3]=c);let l;t[4]===n.label?l=t[5]:(l=(0,Y.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:n.label}),t[4]=n.label,t[5]=l);let u;t[6]===n.message?u=t[7]:(u=(0,Y.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.message}),t[6]=n.message,t[7]=u);let d;t[8]!==l||t[9]!==u?(d=(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[l,u]}),t[8]=l,t[9]=u,t[10]=d):d=t[10];let f;t[11]===n.status?f=t[12]:(f=a(`shrink-0 rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase`,X(n.status)),t[11]=n.status,t[12]=f);let p;t[13]!==n.status||t[14]!==f?(p=(0,Y.jsx)(`span`,{className:f,children:n.status}),t[13]=n.status,t[14]=f,t[15]=p):p=t[15];let m;t[16]!==r||t[17]!==n.path?(m=n.path?(0,Y.jsx)(`span`,{className:`sr-only`,children:r}):null,t[16]=r,t[17]=n.path,t[18]=m):m=t[18];let h;t[19]!==c||t[20]!==d||t[21]!==p||t[22]!==m?(h=(0,Y.jsxs)(Y.Fragment,{children:[c,d,p,m]}),t[19]=c,t[20]=d,t[21]=p,t[22]=m,t[23]=h):h=t[23];let g=h;if(n.path){let e;return t[24]!==g||t[25]!==n.path?(e=(0,Y.jsx)(i,{to:n.path,className:`flex min-w-0 items-start gap-2 rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:g}),t[24]=g,t[25]=n.path,t[26]=e):e=t[26],e}let _;return t[27]===g?_=t[28]:(_=(0,Y.jsx)(`div`,{className:`flex min-w-0 items-start gap-2 rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:g}),t[27]=g,t[28]=_),_}function ye(){let e=o(c(e=>e.language)).setupStatus,{ready:t,error:n,snapshot:r,refresh:i}=J(),[s,l]=(0,F.useState)(!1),[u,d]=(0,F.useState)(`idle`),p=r?.diagnosticSignals.filter(e=>e.status===`fail`||e.status===`warn`)??[],m=async()=>{if(!(s||!t)){l(!0),d(`idle`);try{await i(),d(`success`)}catch{d(`error`)}finally{l(!1)}}};return(0,Y.jsxs)(j,{gap:`gap-6`,children:[(0,Y.jsx)(A,{title:e.title,subtitle:e.subtitle,actions:(0,Y.jsxs)(`button`,{type:`button`,className:a(`inline-flex shrink-0 items-center gap-2 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,O.press),onClick:()=>void m(),disabled:!t||s,"aria-busy":s,children:[(0,Y.jsx)(w,{className:a(`size-4`,(!t||s)&&`animate-spin`),"aria-hidden":!0}),s?e.health.runDoctorRunning:e.refresh]})}),n?(0,Y.jsx)(`p`,{className:`rounded-xl border border-red-300/40 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/40 dark:bg-red-950/30 dark:text-red-300`,children:e.loadError}):null,!t||!r?(0,Y.jsx)(M,{sections:2}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{tier:r.healthTier,issueCount:r.issues.length,ready:t,onRunDoctor:()=>void m(),doctorRunning:s,doctorRunState:u}),(0,Y.jsxs)(P,{id:`next-steps`,children:[(0,Y.jsx)(N,{icon:r.issues.length?f:_,title:e.nextStepsTitle,subtitle:r.issues.length?e.nextStepsIssuesSubtitle:e.nextStepsReadySubtitle}),r.issues.length?(0,Y.jsx)(`div`,{className:`mt-4 flex flex-col gap-2`,children:r.issues.slice(0,8).map(t=>(0,Y.jsx)($,{issue:t,fixLabel:e.fixIssue},`${t.source}:${t.id}`))}):(0,Y.jsx)(`div`,{className:`mt-4 rounded-lg bg-surface-panel/80 shadow-surface`,children:r.readiness.map(t=>(0,Y.jsx)(_e,{item:t,labels:e.readinessLabels},t.id))})]}),(0,Y.jsxs)(P,{children:[(0,Y.jsx)(N,{icon:y,title:e.diagnosticsTitle,subtitle:e.diagnosticsSubtitle}),p.length?(0,Y.jsx)(`div`,{className:`mt-4 grid gap-2 md:grid-cols-2`,children:p.map(t=>(0,Y.jsx)(ve,{signal:t,fixLabel:e.fixIssue},t.id))}):(0,Y.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-panel/80 p-3 text-sm text-fg-muted shadow-surface`,children:r.diagnosticSignals.length?e.diagnosticsAllClear:e.diagnosticsEmpty})]})]})]})}export{ye as SetupStatusPanel};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/attachment-process-heavy-B2_kr5EA.js","assets/rolldown-runtime-aKtaBQYM.js","assets/preload-helper-zJ_50EbN.js","assets/excel-worksheet-utils-EyvwNT4X.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./preload-helper-zJ_50EbN.js";import{d as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{n as a,r as o}from"./locale-store-Bjvw7jtg.js";import{Ai as s,Ll as c,Mi as l,Na as u,Ni as d,Vl as f,ka as p,wi as m}from"./index-BzPwnXho.js";var h=e(t(),1),g=n();function _(){return{textContent:null,binaryBuffer:null,extractedText:null,extractedTextTruncated:!1}}function v(){let{token:e}=i(),t=a(e=>e.language),n=t===`zh`?b:x,[v,S]=(0,h.useState)(null),[C,w]=(0,h.useState)(_),[T,E]=(0,h.useState)(!0),[D,O]=(0,h.useState)(null),k=(0,h.useMemo)(()=>{if(!v||!e||v.kind!==`file`)return null;let t=l(v.fileName,v.mimeType);return{id:`share:${e}:${v.fileName}`,context:`share`,fileName:v.fileName,mimeType:t,size:v.fileSize,type:s(v.fileName,t),source:{kind:`share`,token:e}}},[v,e]);(0,h.useEffect)(()=>{if(!e){O(n.invalidLink),E(!1);return}let t=!1;return(async()=>{try{E(!0),O(null),w(_());let i=await fetch(o(`/s/${encodeURIComponent(e)}/meta`));if(!i.ok){t||O(i.status===404?n.notFound:n.expired);return}let a=await i.json();if(t)return;if(S(a),!a.valid){O(n.expired);return}if(a.kind!==`file`)return;let c=l(a.fileName,a.mimeType),u=s(a.fileName,c),f=d(u),m=o(`/s/${encodeURIComponent(e)}?inline=1`);if(f===`text`){if(a.fileSize>5242880){O(n.tooLarge);return}let e=await fetch(m);if(!e.ok){O(n.expired);return}let r=await e.text();t||w({..._(),textContent:r});return}if(f===`binary`){if(a.fileSize>33554432){O(n.tooLarge);return}let e=await fetch(m);if(!e.ok){O(n.expired);return}let i=await e.arrayBuffer();if(t)return;if(u===`pptx`){let{processPptx:e}=await r(async()=>{let{processPptx:e}=await import(`./attachment-process-heavy-B2_kr5EA.js`);return{processPptx:e}},__vite__mapDeps([0,1,2,3])),{extractedText:t}=await e(i,a.fileName),n=t.length>p;w({textContent:null,binaryBuffer:i,extractedText:n?t.slice(0,p):t,extractedTextTruncated:n});return}w({..._(),binaryBuffer:i})}}catch(e){t||O(e instanceof Error?e.message:String(e))}finally{t||E(!1)}})(),()=>{t=!0}},[e,n.expired,n.invalidLink,n.notFound,n.tooLarge]);let A=e?o(`/s/${encodeURIComponent(e)}?dl=1`):`#`,j=e?o(`/s/${encodeURIComponent(e)}?inline=1`):`#`;return(0,g.jsxs)(`div`,{className:`flex min-h-screen flex-col bg-surface-base`,children:[(0,g.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-3 border-b border-edge px-4`,children:[(0,g.jsx)(`span`,{className:`text-lg`,"aria-hidden":!0,children:`#`}),(0,g.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[v?(0,g.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,title:v.fileName,children:v.fileName}):T?(0,g.jsx)(u,{className:`h-4 w-48 max-w-full`}):(0,g.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:n.error}),v?(0,g.jsxs)(`div`,{className:`truncate text-xs text-fg-muted`,children:[y(v.fileSize),` · `,n.expiresAt,` `,new Date(v.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}):null]}),v?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`a`,{href:j,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,children:[(0,g.jsx)(c,{className:`size-3.5`,"aria-hidden":!0}),n.openInline]}),(0,g.jsxs)(`a`,{href:A,className:`inline-flex items-center gap-1 rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-white hover:opacity-90`,download:v.fileName,children:[(0,g.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),n.download]})]}):null]}),(0,g.jsx)(`main`,{className:`flex min-h-0 w-full flex-1 flex-col px-3 py-6 sm:px-5 xl:px-6`,children:T?(0,g.jsxs)(`div`,{className:`flex min-h-[70vh] flex-1 flex-col overflow-hidden rounded-lg bg-surface-panel p-4 shadow-surface`,"aria-busy":`true`,children:[(0,g.jsx)(u,{className:`h-5 w-56 max-w-full`}),(0,g.jsxs)(`div`,{className:`mt-5 grid gap-3`,children:[(0,g.jsx)(u,{className:`h-4 w-full`}),(0,g.jsx)(u,{className:`h-4 w-11/12`}),(0,g.jsx)(u,{className:`h-4 w-10/12`}),(0,g.jsx)(u,{className:`h-4 w-3/4`})]}),(0,g.jsx)(u,{className:`mt-6 min-h-0 flex-1 rounded-lg`})]}):D?(0,g.jsxs)(`div`,{className:`rounded-lg bg-surface-panel p-6 shadow-surface text-sm text-fg`,children:[(0,g.jsx)(`p`,{className:`font-medium`,children:n.error}),(0,g.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:D})]}):v?.kind===`directory`?(0,g.jsx)(`div`,{className:`rounded-lg bg-surface-panel p-6 shadow-surface text-sm text-fg-muted`,children:n.directoryHint}):k?(0,g.jsx)(`div`,{className:`flex min-h-[70vh] flex-1 flex-col overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:(0,g.jsx)(m,{language:t,descriptor:k,loading:!1,loadError:null,textContent:C.textContent,binaryBuffer:C.binaryBuffer,extractedText:C.extractedText,extractedTextTruncated:C.extractedTextTruncated,actions:{onDownload:()=>{window.location.href=A},canDownload:!0}})}):null})]})}function y(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:e<1073741824?`${(e/1048576).toFixed(1)} MB`:`${(e/1073741824).toFixed(1)} GB`}var b={error:`加载失败`,expired:`链接已失效`,notFound:`链接不存在`,invalidLink:`链接无效`,expiresAt:`有效期至`,download:`下载`,openInline:`在新窗口打开`,directoryHint:`目录分享请使用主页面浏览。`,tooLarge:`文件过大,无法在线预览,请下载查看。`},x={error:`Failed to load`,expired:`Link no longer valid`,notFound:`Link not found`,invalidLink:`Invalid link`,expiresAt:`Expires`,download:`Download`,openInline:`Open raw`,directoryHint:`Directory shares are browsed from the main page.`,tooLarge:`This file is too large to preview here. Please download it instead.`};export{v as SharePreviewPage};
@@ -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{f as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./cn-JdwAhgNB.js";import{t as s}from"./copy-to-clipboard-HOJ79TWv.js";import{t as c}from"./messages-DQ5X6cXp.js";import{l,n as u,r as d,s as f}from"./locale-store-Bjvw7jtg.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{At as m,Bo as h,Cs as g,Ds as _,El as v,Fo as y,Io as b,Kc as x,Lo as S,Ml as C,Mn as w,Na as T,Qo as E,Ri as ee,Sc as D,Vo as O,Vs as k,Wl as A,Xl as j,Zo as M,_r as N,bo as P,ci as F,di as I,fi as L,hc as te,ii as ne,li as R,mi as z,oi as re,pi as B,pu as ie,si as ae,ui as oe,wr as se,ws as V,xo as H,zo as ce}from"./index-BzPwnXho.js";import{n as U,r as W,t as G}from"./settings-page-layout-CTMmZcwj.js";import{t as K}from"./settings-loading-skeleton-BS36Mjzz.js";import{t as q}from"./settings-form-section-C7rzhi7x.js";import{t as le}from"./page-tabs-HXweXqYE.js";var J=e(t(),1),ue=n(),Y={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`],siteEnabled:!0,siteDefaultTtlHours:24,siteMaxTtlDays:30,maxActiveSites:50,siteMaxRootDirSizeMb:1024,siteMaxFileCount:2e4};function de(){return structuredClone(Y)}var fe=36e5,X=864e5,Z=1048576;function pe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function me(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 he(e){let t=pe(e)?e:{},n=pe(t.gateway)?t.gateway:{},r=pe(n.share)?n.share:{},i=pe(r.directory)?r.directory:{},a=pe(n.siteShare)?n.siteShare:{},o=pe(a.static)?a.static:{},s=typeof r.defaultTtlMs==`number`&&Number.isFinite(r.defaultTtlMs)?Math.floor(r.defaultTtlMs):Y.defaultTtlHours*fe,c=typeof r.maxTtlMs==`number`&&Number.isFinite(r.maxTtlMs)?Math.floor(r.maxTtlMs):Y.maxTtlDays*X,l=typeof r.maxFileSize==`number`&&Number.isFinite(r.maxFileSize)?Math.floor(r.maxFileSize):Y.maxFileSizeMb*Z,u=typeof i.maxFolderSize==`number`&&Number.isFinite(i.maxFolderSize)?Math.floor(i.maxFolderSize):Y.directoryMaxFolderSizeMb*Z,d=typeof a.defaultTtlMs==`number`&&Number.isFinite(a.defaultTtlMs)?Math.floor(a.defaultTtlMs):Y.siteDefaultTtlHours*fe,f=typeof a.maxTtlMs==`number`&&Number.isFinite(a.maxTtlMs)?Math.floor(a.maxTtlMs):Y.siteMaxTtlDays*X,p=typeof o.maxRootDirSize==`number`&&Number.isFinite(o.maxRootDirSize)?Math.floor(o.maxRootDirSize):Y.siteMaxRootDirSizeMb*Z;return{enabled:r.enabled!==!1,defaultTtlHours:Math.max(1,Math.round(s/fe)),maxTtlDays:Math.max(1,Math.round(c/X)),maxActiveShares:typeof r.maxActiveShares==`number`&&Number.isFinite(r.maxActiveShares)?Math.max(1,Math.min(1e4,Math.floor(r.maxActiveShares))):Y.maxActiveShares,maxFileSizeMb:Math.max(1,Math.round(l/Z)),directoryMaxFolderSizeMb:Math.max(1,Math.round(u/Z)),directoryMaxFileCount:typeof i.maxFileCount==`number`&&Number.isFinite(i.maxFileCount)?Math.max(1,Math.min(1e5,Math.floor(i.maxFileCount))):Y.directoryMaxFileCount,inlinePreviewMimes:me(r.inlinePreviewMimes,32).length?me(r.inlinePreviewMimes,32):[...Y.inlinePreviewMimes],siteEnabled:a.enabled!==!1,siteDefaultTtlHours:Math.max(1,Math.round(d/fe)),siteMaxTtlDays:Math.max(1,Math.round(f/X)),maxActiveSites:typeof a.maxActiveSites==`number`&&Number.isFinite(a.maxActiveSites)?Math.max(1,Math.min(1e3,Math.floor(a.maxActiveSites))):Y.maxActiveSites,siteMaxRootDirSizeMb:Math.max(1,Math.round(p/Z)),siteMaxFileCount:typeof o.maxFileCount==`number`&&Number.isFinite(o.maxFileCount)?Math.max(1,Math.min(1e5,Math.floor(o.maxFileCount))):Y.siteMaxFileCount}}function ge(e){let t=e.defaultTtlHours*fe,n=e.maxTtlDays*X,r=e.siteDefaultTtlHours*fe,i=e.siteMaxTtlDays*X;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.`: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 _e(e){let t=ge(e);if(t)throw Error(t);await f(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{share:{enabled:e.enabled,defaultTtlMs:e.defaultTtlHours*fe,maxTtlMs:e.maxTtlDays*X,maxActiveShares:e.maxActiveShares,maxFileSize:e.maxFileSizeMb*Z,inlinePreviewMimes:e.inlinePreviewMimes,directory:{maxFolderSize:e.directoryMaxFolderSizeMb*Z,maxFileCount:e.directoryMaxFileCount}},siteShare:{enabled:e.siteEnabled,defaultTtlMs:e.siteDefaultTtlHours*fe,maxTtlMs:e.siteMaxTtlDays*X,maxActiveSites:e.maxActiveSites,static:{maxRootDirSize:e.siteMaxRootDirSizeMb*Z,maxFileCount:e.siteMaxFileCount}}}})}),P()}var Q=r();function ve(){return o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,g,`dark:border-edge`)}function ye({hasToken:e}){let t=c(u(e=>e.language)).sharesSettings,{data:n,isLoading:r}=H(e),i=(0,J.useMemo)(()=>n?.payload?.config===void 0?null:structuredClone(he(n.payload.config)),[n]),a=(0,J.useRef)(!1),[o,s]=(0,J.useState)(null),[l,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)(null),[m,h]=(0,J.useState)(!1),g=o??i,_=i,v=(0,J.useMemo)(()=>!g||!_?!1:JSON.stringify(g)!==JSON.stringify(_),[g,_]),y=(0,J.useCallback)(e=>{a.current=!0,s(t=>{let n=t??_;return n?{...n,...e}:null})},[_]),b=(0,J.useCallback)(async()=>{if(!(!g||l)){d(!0),p(null),h(!1);try{await _e(g),a.current=!1,s(null),h(!0),window.setTimeout(()=>h(!1),2500)}catch(e){p(e instanceof Error?e.message:t.policySaveError)}finally{d(!1)}}},[g,l,t.policySaveError]),x=(0,J.useCallback)(()=>{a.current=!1,s(null),p(null),h(!1)},[]);return!e||!g?r?(0,Q.jsx)(q,{children:(0,Q.jsx)(K,{rows:2})}):null:(0,Q.jsxs)(q,{children:[(0,Q.jsxs)(`div`,{className:`mb-4 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.policyTitle}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:t.policyHint})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[m?(0,Q.jsx)(`span`,{className:`text-sm text-fg-muted`,children:t.policySaved}):null,(0,Q.jsx)(V,{type:`button`,variant:`secondary`,disabled:l,onClick:()=>y(de()),children:t.policyUseRecommended}),(0,Q.jsx)(V,{type:`button`,variant:`secondary`,disabled:!v||l,onClick:x,children:t.policyDiscard}),(0,Q.jsx)(V,{type:`button`,variant:`primary`,disabled:!v||l,onClick:()=>void b(),children:l?t.policySaving:t.policySave})]})]}),v?(0,Q.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:t.policyUnsaved}):null,f?(0,Q.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:f}):null,(0,Q.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:t.policyRestartHint}),(0,Q.jsx)(be,{t,form:g,onChange:y})]})}function be(e){let t=(0,ue.c)(150),{t:n,form:r,onChange:i}=e,a;t[0]===n.policyFileSection?a=t[1]:(a=(0,Q.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,Q.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,Q.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,Q.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,Q.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,Q.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,Q.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,Q.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,Q.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 C=!r.enabled,w;t[47]===i?w=t[48]:(w=e=>i({directoryMaxFolderSizeMb:e}),t[47]=i,t[48]=w);let T;t[49]!==r.directoryMaxFolderSizeMb||t[50]!==n.policyDirectoryMaxFolderSizeHint||t[51]!==n.policyDirectoryMaxFolderSizeMb||t[52]!==C||t[53]!==w?(T=(0,Q.jsx)($,{id:`share-directory-max-size-mb`,label:n.policyDirectoryMaxFolderSizeMb,hint:n.policyDirectoryMaxFolderSizeHint,value:r.directoryMaxFolderSizeMb,min:1,max:10240,disabled:C,onChange:w}),t[49]=r.directoryMaxFolderSizeMb,t[50]=n.policyDirectoryMaxFolderSizeHint,t[51]=n.policyDirectoryMaxFolderSizeMb,t[52]=C,t[53]=w,t[54]=T):T=t[54];let E=!r.enabled,ee;t[55]===i?ee=t[56]:(ee=e=>i({directoryMaxFileCount:e}),t[55]=i,t[56]=ee);let D;t[57]!==r.directoryMaxFileCount||t[58]!==n.policyDirectoryMaxFileCount||t[59]!==n.policyDirectoryMaxFileCountHint||t[60]!==E||t[61]!==ee?(D=(0,Q.jsx)($,{id:`share-directory-max-files`,label:n.policyDirectoryMaxFileCount,hint:n.policyDirectoryMaxFileCountHint,value:r.directoryMaxFileCount,min:1,max:1e5,disabled:E,onChange:ee}),t[57]=r.directoryMaxFileCount,t[58]=n.policyDirectoryMaxFileCount,t[59]=n.policyDirectoryMaxFileCountHint,t[60]=E,t[61]=ee,t[62]=D):D=t[62];let O;t[63]!==g||t[64]!==y||t[65]!==S||t[66]!==T||t[67]!==D||t[68]!==p?(O=(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[p,g,y,S,T,D]}),t[63]=g,t[64]=y,t[65]=S,t[66]=T,t[67]=D,t[68]=p,t[69]=O):O=t[69];let k=!r.enabled,A;t[70]===i?A=t[71]:(A=e=>i({inlinePreviewMimes:e}),t[70]=i,t[71]=A);let j;t[72]!==r.inlinePreviewMimes||t[73]!==n||t[74]!==k||t[75]!==A?(j=(0,Q.jsx)(xe,{t:n,values:r.inlinePreviewMimes,disabled:k,onChange:A}),t[72]=r.inlinePreviewMimes,t[73]=n,t[74]=k,t[75]=A,t[76]=j):j=t[76];let M;t[77]!==O||t[78]!==j||t[79]!==s||t[80]!==u?(M=(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-muted/25 p-4`,children:[s,u,O,j]}),t[77]=O,t[78]=j,t[79]=s,t[80]=u,t[81]=M):M=t[81];let N;t[82]===n.policySiteSection?N=t[83]:(N=(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policySiteSection}),t[82]=n.policySiteSection,t[83]=N);let P;t[84]===n.policySiteSectionHint?P=t[85]:(P=(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policySiteSectionHint}),t[84]=n.policySiteSectionHint,t[85]=P);let F;t[86]!==N||t[87]!==P?(F=(0,Q.jsxs)(`div`,{className:`mb-4`,children:[N,P]}),t[86]=N,t[87]=P,t[88]=F):F=t[88];let I;t[89]===i?I=t[90]:(I=e=>i({siteEnabled:e.target.checked}),t[89]=i,t[90]=I);let L;t[91]!==r.siteEnabled||t[92]!==I?(L=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.siteEnabled,onChange:I}),t[91]=r.siteEnabled,t[92]=I,t[93]=L):L=t[93];let te;t[94]!==n.policySiteEnabled||t[95]!==L?(te=(0,Q.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[L,n.policySiteEnabled]}),t[94]=n.policySiteEnabled,t[95]=L,t[96]=te):te=t[96];let ne=!r.siteEnabled,R;t[97]===i?R=t[98]:(R=e=>i({siteDefaultTtlHours:e}),t[97]=i,t[98]=R);let z;t[99]!==r.siteDefaultTtlHours||t[100]!==n.policySiteDefaultTtlHint||t[101]!==n.policySiteDefaultTtlHours||t[102]!==ne||t[103]!==R?(z=(0,Q.jsx)($,{id:`site-share-default-ttl-hours`,label:n.policySiteDefaultTtlHours,hint:n.policySiteDefaultTtlHint,value:r.siteDefaultTtlHours,min:1,max:168,disabled:ne,onChange:R}),t[99]=r.siteDefaultTtlHours,t[100]=n.policySiteDefaultTtlHint,t[101]=n.policySiteDefaultTtlHours,t[102]=ne,t[103]=R,t[104]=z):z=t[104];let re=!r.siteEnabled,B;t[105]===i?B=t[106]:(B=e=>i({siteMaxTtlDays:e}),t[105]=i,t[106]=B);let ie;t[107]!==r.siteMaxTtlDays||t[108]!==n.policySiteMaxTtlDays||t[109]!==n.policySiteMaxTtlHint||t[110]!==re||t[111]!==B?(ie=(0,Q.jsx)($,{id:`site-share-max-ttl-days`,label:n.policySiteMaxTtlDays,hint:n.policySiteMaxTtlHint,value:r.siteMaxTtlDays,min:1,max:30,disabled:re,onChange:B}),t[107]=r.siteMaxTtlDays,t[108]=n.policySiteMaxTtlDays,t[109]=n.policySiteMaxTtlHint,t[110]=re,t[111]=B,t[112]=ie):ie=t[112];let ae=!r.siteEnabled,oe;t[113]===i?oe=t[114]:(oe=e=>i({maxActiveSites:e}),t[113]=i,t[114]=oe);let se;t[115]!==r.maxActiveSites||t[116]!==n.policyMaxActiveSites||t[117]!==n.policyMaxActiveSitesHint||t[118]!==ae||t[119]!==oe?(se=(0,Q.jsx)($,{id:`site-share-max-active`,label:n.policyMaxActiveSites,hint:n.policyMaxActiveSitesHint,value:r.maxActiveSites,min:1,max:1e3,disabled:ae,onChange:oe}),t[115]=r.maxActiveSites,t[116]=n.policyMaxActiveSites,t[117]=n.policyMaxActiveSitesHint,t[118]=ae,t[119]=oe,t[120]=se):se=t[120];let V=!r.siteEnabled,H;t[121]===i?H=t[122]:(H=e=>i({siteMaxRootDirSizeMb:e}),t[121]=i,t[122]=H);let ce;t[123]!==r.siteMaxRootDirSizeMb||t[124]!==n.policySiteMaxRootDirSizeHint||t[125]!==n.policySiteMaxRootDirSizeMb||t[126]!==V||t[127]!==H?(ce=(0,Q.jsx)($,{id:`site-share-max-root-size-mb`,label:n.policySiteMaxRootDirSizeMb,hint:n.policySiteMaxRootDirSizeHint,value:r.siteMaxRootDirSizeMb,min:1,max:10240,disabled:V,onChange:H}),t[123]=r.siteMaxRootDirSizeMb,t[124]=n.policySiteMaxRootDirSizeHint,t[125]=n.policySiteMaxRootDirSizeMb,t[126]=V,t[127]=H,t[128]=ce):ce=t[128];let U=!r.siteEnabled,W;t[129]===i?W=t[130]:(W=e=>i({siteMaxFileCount:e}),t[129]=i,t[130]=W);let G;t[131]!==r.siteMaxFileCount||t[132]!==n.policySiteMaxFileCount||t[133]!==n.policySiteMaxFileCountHint||t[134]!==U||t[135]!==W?(G=(0,Q.jsx)($,{id:`site-share-max-files`,label:n.policySiteMaxFileCount,hint:n.policySiteMaxFileCountHint,value:r.siteMaxFileCount,min:1,max:1e5,disabled:U,onChange:W}),t[131]=r.siteMaxFileCount,t[132]=n.policySiteMaxFileCount,t[133]=n.policySiteMaxFileCountHint,t[134]=U,t[135]=W,t[136]=G):G=t[136];let K;t[137]!==z||t[138]!==ie||t[139]!==se||t[140]!==ce||t[141]!==G?(K=(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[z,ie,se,ce,G]}),t[137]=z,t[138]=ie,t[139]=se,t[140]=ce,t[141]=G,t[142]=K):K=t[142];let q;t[143]!==F||t[144]!==te||t[145]!==K?(q=(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-muted/25 p-4`,children:[F,te,K]}),t[143]=F,t[144]=te,t[145]=K,t[146]=q):q=t[146];let le;return t[147]!==M||t[148]!==q?(le=(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[M,q]}),t[147]=M,t[148]=q,t[149]=le):le=t[149],le}function $(e){let t=(0,ue.c)(21),{id:n,label:r,hint:i,value:a,min:s,max:c,disabled:l,onChange:u}=e,d;t[0]!==n||t[1]!==r?(d=(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=d):d=t[2];let f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=o(ve(),`max-w-xs font-mono text-xs`),t[3]=f):f=t[3];let p;t[4]!==c||t[5]!==s||t[6]!==u?(p=e=>{let t=Number(e.target.value);Number.isFinite(t)&&u(Math.max(s,Math.min(c,Math.floor(t))))},t[4]=c,t[5]=s,t[6]=u,t[7]=p):p=t[7];let m;t[8]!==l||t[9]!==n||t[10]!==c||t[11]!==s||t[12]!==p||t[13]!==a?(m=(0,Q.jsx)(`input`,{id:n,type:`number`,min:s,max:c,disabled:l,className:f,value:a,onChange:p}),t[8]=l,t[9]=n,t[10]=c,t[11]=s,t[12]=p,t[13]=a,t[14]=m):m=t[14];let h;t[15]===i?h=t[16]:(h=(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}),t[15]=i,t[16]=h);let g;return t[17]!==d||t[18]!==m||t[19]!==h?(g=(0,Q.jsxs)(`div`,{children:[d,m,h]}),t[17]=d,t[18]=m,t[19]=h,t[20]=g):g=t[20],g}function xe(e){let t=(0,ue.c)(25),{t:n,values:r,disabled:i,onChange:a}=e,s;t[0]!==a||t[1]!==r?(s=e=>{let t=e.trim();!t||r.includes(t)||r.length>=32||a([...r,t])},t[0]=a,t[1]=r,t[2]=s):s=t[2];let c=s,l;t[3]===n.policyInlinePreviewMimes?l=t[4]:(l=(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.policyInlinePreviewMimes}),t[3]=n.policyInlinePreviewMimes,t[4]=l);let u;t[5]===n.policyInlinePreviewMimesHint?u=t[6]:(u=(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.policyInlinePreviewMimesHint}),t[5]=n.policyInlinePreviewMimesHint,t[6]=u);let d;t[7]!==i||t[8]!==a||t[9]!==r?(d=r.map(e=>(0,Q.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,Q.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]=d):d=t[10];let f;t[11]===d?f=t[12]:(f=(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:d}),t[11]=d,t[12]=f);let p;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(p=o(ve(),`font-mono text-xs`),t[13]=p):p=t[13];let m=i||r.length>=32,h;t[14]===c?h=t[15]:(h=e=>{e.key===`Enter`&&(e.preventDefault(),c(e.target.value),e.target.value=``)},t[14]=c,t[15]=h);let g;t[16]!==n.policyMimePlaceholder||t[17]!==m||t[18]!==h?(g=(0,Q.jsx)(`input`,{className:p,placeholder:n.policyMimePlaceholder,disabled:m,onKeyDown:h}),t[16]=n.policyMimePlaceholder,t[17]=m,t[18]=h,t[19]=g):g=t[19];let _;return t[20]!==l||t[21]!==u||t[22]!==f||t[23]!==g?(_=(0,Q.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-4`,children:[l,u,f,g]}),t[20]=l,t[21]=u,t[22]=f,t[23]=g,t[24]=_):_=t[24],_}function Se(e){let t=(0,ue.c)(70),{open:n,onOpenChange:r,onConfirm:i,initialPath:a,selectKind:s,sessionKey:d,agentId:f}=e,m=s===void 0?`any`:s,g=c(u(Te)),C=g.workspace,w=g.sharesSettings,T=ne(we),{data:D}=p(l(Ce)?`picker-agents-list`:null,se),k;bb0:{let e;t[0]===f?e=t[1]:(e=f?.trim(),t[0]=f,t[1]=e);let n=e;if(n){k=n;break bb0}let r;t[2]===T?r=t[3]:(r=T.trim(),t[2]=T,t[3]=r);let i=r;if(i){k=i;break bb0}if(D?.defaultId){k=D.defaultId;break bb0}if(D?.agents?.[0]?.id){k=D.agents[0].id;break bb0}k=``}let A=k,[j,P]=(0,J.useState)(A),F,I;t[4]===A?(F=t[5],I=t[6]):(F=()=>{P(A)},I=[A],t[4]=A,t[5]=F,t[6]=I),(0,J.useEffect)(F,I);let{tree:L,loading:R,error:z,loadRoot:B,loadChildren:ie,reset:ae}=re(j,d??null),oe;t[7]===a?oe=t[8]:(oe=a?{path:a,isDirectory:!1}:null,t[7]=a,t[8]=oe);let[H,U]=(0,J.useState)(oe),W;t[9]!==a||t[10]!==B||t[11]!==n||t[12]!==ae||t[13]!==U?(W=()=>{if(!n){ae(),U(a?{path:a,isDirectory:!1}:null);return}B()},t[9]=a,t[10]=B,t[11]=n,t[12]=ae,t[13]=U,t[14]=W):W=t[14];let G;t[15]!==a||t[16]!==B||t[17]!==n||t[18]!==j||t[19]!==ae||t[20]!==d?(G=[n,j,d,B,ae,a],t[15]=a,t[16]=B,t[17]=n,t[18]=j,t[19]=ae,t[20]=d,t[21]=G):G=t[21],(0,J.useEffect)(W,G);let K;t[22]===ie?K=t[23]:(K=e=>{ie(e)},t[22]=ie,t[23]=K);let q=K,le=H!==null&&(m===`any`||m===`file`&&!H.isDirectory||m===`directory`&&H.isDirectory),Y;bb1:{if(!H){Y=w.pickerHintNone;break bb1}if(m===`file`&&H.isDirectory){Y=w.pickerHintNeedsFile;break bb1}if(m===`directory`&&!H.isDirectory){Y=w.pickerHintNeedsDirectory;break bb1}Y=`${H.isDirectory?`📁`:`📄`} ${H.path}`}let de=Y,fe=D?.agents??[],X;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(X=(0,Q.jsx)(ce,{className:`fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),t[24]=X):X=t[24];let Z;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(Z=o(`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]=Z):Z=t[25];let pe;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,Q.jsx)(v,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[26]=pe):pe=t[26];let me=g.cron.refresh,he=g.cron.refresh,ge;t[27]===B?ge=t[28]:(ge=()=>void B(),t[27]=B,t[28]=ge);let _e=R&&`animate-spin`,ve;t[29]===_e?ve=t[30]:(ve=o(`size-4`,_e),t[29]=_e,t[30]=ve);let ye;t[31]===ve?ye=t[32]:(ye=(0,Q.jsx)(te,{className:ve,"aria-hidden":!0}),t[31]=ve,t[32]=ye);let be;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,Q.jsx)(_,{className:`size-4`}),t[33]=be):be=t[33];let $;t[34]!==z||t[35]!==C.loadError?($=z?(0,Q.jsxs)(`p`,{className:`shrink-0 px-4 py-2 text-xs text-red-600 dark:text-red-400`,children:[C.loadError,`: `,z]}):null,t[34]=z,t[35]=C.loadError,t[36]=$):$=t[36];let xe;t[37]!==q||t[38]!==R||t[39]!==H?.path||t[40]!==U||t[41]!==C.emptyDir||t[42]!==C.title||t[43]!==L?(xe=R&&L.length===0?(0,Q.jsxs)(`p`,{className:`flex shrink-0 items-center gap-2 px-4 py-3 text-sm text-fg-muted`,children:[(0,Q.jsx)(x,{className:`size-4 animate-spin`}),C.title,`…`]}):(0,Q.jsx)(ee,{tree:L,selectedPath:H?.path??null,onSelectFile:e=>U({path:e,isDirectory:!1}),onSelectEntry:(e,t)=>U({path:e,isDirectory:t}),onExpandDir:q,onAction:void 0,emptyHint:C.emptyDir}),t[37]=q,t[38]=R,t[39]=H?.path,t[40]=U,t[41]=C.emptyDir,t[42]=C.title,t[43]=L,t[44]=xe):xe=t[44];let Se;t[45]!==$||t[46]!==xe?(Se=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[$,xe]}),t[45]=$,t[46]=xe,t[47]=Se):Se=t[47];let Ee;t[48]===de?Ee=t[49]:(Ee=(0,Q.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:de}),t[48]=de,t[49]=Ee);let De;t[50]===r?De=t[51]:(De=()=>r(!1),t[50]=r,t[51]=De);let Oe;t[52]!==w.cancel||t[53]!==De?(Oe=(0,Q.jsx)(V,{type:`button`,variant:`ghost`,onClick:De,children:w.cancel}),t[52]=w.cancel,t[53]=De,t[54]=Oe):Oe=t[54];let ke=!le,Ae;t[55]!==i||t[56]!==r||t[57]!==j||t[58]!==H?(Ae=()=>{H&&(i({...H,agentId:j}),r(!1))},t[55]=i,t[56]=r,t[57]=j,t[58]=H,t[59]=Ae):Ae=t[59];let je;t[60]!==w.pickerConfirm||t[61]!==ke||t[62]!==Ae?(je=(0,Q.jsx)(V,{type:`button`,disabled:ke,onClick:Ae,children:w.pickerConfirm}),t[60]=w.pickerConfirm,t[61]=ke,t[62]=Ae,t[63]=je):je=t[63];let Me;t[64]!==Oe||t[65]!==je?(Me=(0,Q.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]!==Ee||t[68]!==Me?(Ne=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-t border-edge px-4 py-3`,children:[Ee,Me]}),t[67]=Ee,t[68]=Me,t[69]=Ne):Ne=t[69],(0,Q.jsx)(y,{open:n,onOpenChange:r,children:(0,Q.jsxs)(h,{children:[X,(0,Q.jsxs)(S,{className:Z,children:[(0,Q.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-edge px-4`,children:[pe,(0,Q.jsx)(O,{className:`min-w-0 flex-1 truncate text-base font-semibold text-fg`,children:w.pickerTitle}),(0,Q.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:me,"aria-label":he,disabled:R,onClick:ge,children:ye}),(0,Q.jsx)(b,{asChild:!0,children:(0,Q.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":C.close,children:be})})]}),fe.length>0?(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-edge px-4 py-2`,children:[(0,Q.jsx)(`label`,{className:`text-xs text-fg-muted`,htmlFor:`picker-agent-select`,children:w.pickerAgentLabel}),(0,Q.jsx)(M,{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:j,onChange:e=>{P(e.target.value),U(null)},children:fe.map(e=>(0,Q.jsxs)(E,{value:e.id,children:[N(e,g.agentsSettings),e.id===D?.defaultId?` ★`:``]},e.id))})]}):null,Se,Ne]})]})})}function Ce(e){return e.token}function we(e){return e.agentId}function Te(e){return e.language}var Ee=[`shares`,`policy`];function De(e){let t=(e??``).trim();return Ee.includes(t)?t:`shares`}function Oe(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 ke(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 Ae=[{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 je(){let e=(0,ue.c)(24),t=u(Ne),n=c(t).sharesSettings,r=!!l(Me),[a,o]=i(),s;e[0]===a?s=e[1]:(s=De(a.get(`tab`)),e[0]=a,e[1]=s);let d=s,f;e[2]===o?f=e[3]:(f=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]=f);let p=f;if(!r)return(0,Q.jsx)(W,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})});let m={shares:n.tabShares,policy:n.tabPolicy},h=Ee.map(e=>({id:e,label:m[e]})),g;e[4]!==n.subtitle||e[5]!==n.title?(g=(0,Q.jsx)(U,{title:n.title,subtitle:n.subtitle}),e[4]=n.subtitle,e[5]=n.title,e[6]=g):g=e[6];let _;e[7]!==d||e[8]!==p||e[9]!==n.tabsAria||e[10]!==h?(_=(0,Q.jsx)(le,{items:h,activeTab:d,onChange:p,ariaLabel:n.tabsAria,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`}),e[7]=d,e[8]=p,e[9]=n.tabsAria,e[10]=h,e[11]=_):_=e[11];let v;e[12]!==d||e[13]!==r||e[14]!==t||e[15]!==n?(v=d===`shares`?(0,Q.jsx)(Pe,{t:n,language:t}):(0,Q.jsx)(ye,{hasToken:r}),e[12]=d,e[13]=r,e[14]=t,e[15]=n,e[16]=v):v=e[16];let y;e[17]!==d||e[18]!==v?(y=(0,Q.jsx)(G,{id:d,activeTab:d,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`,showHeading:!1,children:v}),e[17]=d,e[18]=v,e[19]=y):y=e[19];let b;return e[20]!==g||e[21]!==_||e[22]!==y?(b=(0,Q.jsxs)(W,{children:[g,_,y]}),e[20]=g,e[21]=_,e[22]=y,e[23]=b):b=e[23],b}function Me(e){return e.token}function Ne(e){return e.language}function Pe(e){let t=(0,ue.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:s,isLoading:c,mutate:l}=p(`shares-list`,oe,i),u;t[1]===a?.payload?.shares?u=t[2]:(u=a?.payload?.shares??[],t[1]=a?.payload?.shares,t[2]=u);let d=u,[f,m]=(0,J.useState)(!1),h;bb0:{if(f){h=d;break bb0}let e;t[3]===d?e=t[4]:(e=d.filter(ze),t[3]=d,t[4]=e),h=e}let g=h,_;t[5]===d?_=t[6]:(_=d.filter(Re),t[5]=d,t[6]=_);let v=_.length,y;t[7]===d?y=t[8]:(y=d.filter(Le),t[7]=d,t[8]=y);let b=y.length,x;t[9]===l?x=t[10]:(x=()=>void l(),t[9]=l,t[10]=x);let S;t[11]!==n||t[12]!==x?(S=(0,Q.jsx)(Ve,{t:n,onCreated:x}),t[11]=n,t[12]=x,t[13]=S):S=t[13];let C=f?n.allSharesTitle:n.listTitle,w;t[14]===v?w=t[15]:(w=v>0&&(0,Q.jsxs)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:[`(`,v,`)`]}),t[14]=v,t[15]=w);let T;t[16]!==C||t[17]!==w?(T=(0,Q.jsxs)(`h2`,{className:`text-sm font-semibold text-fg`,children:[C,w]}),t[16]=C,t[17]=w,t[18]=T):T=t[18];let E;t[19]===l?E=t[20]:(E=()=>void l(),t[19]=l,t[20]=E);let ee=c&&`animate-spin`,D;t[21]===ee?D=t[22]:(D=o(`size-3.5`,ee),t[21]=ee,t[22]=D);let O;t[23]===D?O=t[24]:(O=(0,Q.jsx)(te,{className:D}),t[23]=D,t[24]=O);let k;t[25]!==c||t[26]!==E||t[27]!==O?(k=(0,Q.jsx)(V,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:E,disabled:c,children:O}),t[25]=c,t[26]=E,t[27]=O,t[28]=k):k=t[28];let A;t[29]!==b||t[30]!==f||t[31]!==n.hideExpired||t[32]!==n.showExpired?(A=b>0&&(0,Q.jsx)(`button`,{type:`button`,className:`text-xs text-accent hover:underline`,onClick:()=>m(Ie),children:f?n.hideExpired:n.showExpired}),t[29]=b,t[30]=f,t[31]=n.hideExpired,t[32]=n.showExpired,t[33]=A):A=t[33];let j;t[34]!==k||t[35]!==A?(j=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[k,A]}),t[34]=k,t[35]=A,t[36]=j):j=t[36];let M;t[37]!==T||t[38]!==j?(M=(0,Q.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[T,j]}),t[37]=T,t[38]=j,t[39]=M):M=t[39];let N;t[40]!==a||t[41]!==s||t[42]!==g||t[43]!==c||t[44]!==r||t[45]!==l||t[46]!==n?(N=c&&!a?(0,Q.jsx)(`div`,{className:`grid gap-2`,"aria-busy":`true`,children:Array.from({length:4}).map(Fe)}):s?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-red-600 dark:text-red-400`,children:[(0,Q.jsx)(`span`,{children:n.error}),(0,Q.jsx)(V,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-xs`,onClick:()=>void l(),children:n.retry})]}):g.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.emptyState}):(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:g.map(e=>(0,Q.jsx)(Ue,{share:e,t:n,language:r,onRevoked:()=>void l(),onExtended:()=>void l()},e.id))}),t[40]=a,t[41]=s,t[42]=g,t[43]=c,t[44]=r,t[45]=l,t[46]=n,t[47]=N):N=t[47];let P;t[48]!==b||t[49]!==l||t[50]!==f||t[51]!==n?(P=b>0&&f&&(0,Q.jsx)(We,{t:n,onCleaned:()=>void l()}),t[48]=b,t[49]=l,t[50]=f,t[51]=n,t[52]=P):P=t[52];let F;t[53]!==M||t[54]!==N||t[55]!==P?(F=(0,Q.jsxs)(q,{children:[M,N,P]}),t[53]=M,t[54]=N,t[55]=P,t[56]=F):F=t[56];let I;return t[57]!==F||t[58]!==S?(I=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[S,F]}),t[57]=F,t[58]=S,t[59]=I):I=t[59],I}function Fe(e,t){return(0,Q.jsx)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(T,{className:`h-4 w-2/3`}),(0,Q.jsx)(T,{className:`mt-2 h-3 w-1/2`})]}),(0,Q.jsx)(T,{className:`h-7 w-20 rounded-md`})]})},t)}function Ie(e){return!e}function Le(e){return e.expired||e.revoked}function Re(e){return!e.expired&&!e.revoked}function ze(e){return!e.expired&&!e.revoked}var Be={expanded:!0,path:``,isDirectory:!1,agentId:``,ttlMs:864e5,maxViews:null,description:``,directoryMode:`browse`,creating:!1,result:null,errorMsg:null,resultDialogOpen:!1,pickerOpen:!1};function Ve({t:e,onCreated:t}){let[n,r]=(0,J.useReducer)(m,Be),{expanded:i,path:a,isDirectory:s,agentId:c,ttlMs:l,maxViews:u,description:d,directoryMode:f,creating:p,result:h,errorMsg:g,resultDialogOpen:_,pickerOpen:v}=n,y=(0,J.useCallback)(async()=>{if(a.trim()){r({type:`patch`,patch:{creating:!0,errorMsg:null,result:null}});try{r({type:`patch`,patch:{result:(await F({path:a.trim(),ttlMs:l,maxViews:u,description:d.trim()||void 0,...c?{agentId:c}:{},...s?{kind:`directory`,directoryMode:f}:{}})).payload,resultDialogOpen:!0}}),t()}catch(e){r({type:`patch`,patch:{errorMsg:e instanceof Error?e.message:String(e)}})}finally{r({type:`patch`,patch:{creating:!1}})}}},[a,s,c,l,u,d,f,t]),b=(0,J.useCallback)(()=>{r({type:`patch`,patch:{path:``,isDirectory:!1,agentId:``,description:``,maxViews:null,ttlMs:864e5,directoryMode:`browse`,result:null,errorMsg:null}})},[]);return i?(0,Q.jsxs)(q,{children:[(0,Q.jsx)(`h2`,{className:`mb-1 text-sm font-semibold text-fg`,children:e.createTitle}),(0,Q.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:e.createHint}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.pathLabel}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:o(`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,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,children:s?`📁`:`📄`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:a,children:a})]}):(0,Q.jsx)(`span`,{className:`truncate`,children:e.pathPlaceholder})}),(0,Q.jsxs)(V,{type:`button`,variant:`ghost`,onClick:()=>r({type:`patch`,patch:{pickerOpen:!0}}),children:[(0,Q.jsx)(C,{className:`size-4`}),a?e.pathBrowseChange:e.pathBrowse]})]})]}),s?(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.directoryModeLabel}),(0,Q.jsxs)(M,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:f,onChange:e=>r({type:`patch`,patch:{directoryMode:e.target.value===`zip-only`?`zip-only`:`browse`}}),children:[(0,Q.jsx)(E,{value:`browse`,children:e.directoryModeBrowse}),(0,Q.jsx)(E,{value:`zip-only`,children:e.directoryModeZipOnly})]})]}):null,(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.ttlLabel}),(0,Q.jsx)(M,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:l,onChange:e=>r({type:`patch`,patch:{ttlMs:Number(e.target.value)}}),children:Ae.map(t=>(0,Q.jsx)(E,{value:t.value,children:e.ttlOptions[t.key]},t.key))})]}),(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.maxViewsLabel}),(0,Q.jsxs)(M,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:u??`unlimited`,onChange:e=>r({type:`patch`,patch:{maxViews:e.target.value===`unlimited`?null:Number(e.target.value)}}),children:[(0,Q.jsx)(E,{value:`unlimited`,children:e.maxViewsUnlimited}),(0,Q.jsx)(E,{value:`1`,children:`1`}),(0,Q.jsx)(E,{value:`5`,children:`5`}),(0,Q.jsx)(E,{value:`10`,children:`10`}),(0,Q.jsx)(E,{value:`50`,children:`50`}),(0,Q.jsx)(E,{value:`100`,children:`100`})]})]})]}),(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.descriptionLabel}),(0,Q.jsx)(`input`,{type:`text`,className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:outline-none focus:ring-2 focus:ring-accent`,placeholder:e.descriptionPlaceholder,value:d,onChange:e=>r({type:`patch`,patch:{description:e.target.value}})})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,Q.jsxs)(V,{type:`button`,disabled:p||!a.trim(),onClick:()=>void y(),children:[p?(0,Q.jsx)(x,{className:`size-4 animate-spin`}):(0,Q.jsx)(D,{className:`size-4`}),p?e.creating:e.createButton]}),(0,Q.jsx)(V,{type:`button`,variant:`ghost`,onClick:()=>{b(),r({type:`patch`,patch:{expanded:!1}})},children:e.cancel})]}),g&&(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:g})]}),(0,Q.jsx)(B,{open:_,onOpenChange:e=>{r({type:`patch`,patch:{resultDialogOpen:e,...e?{}:{result:null}}})},result:h}),(0,Q.jsx)(Se,{open:v,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,Q.jsxs)(V,{type:`button`,onClick:()=>r({type:`patch`,patch:{expanded:!0}}),className:`self-start`,children:[(0,Q.jsx)(D,{className:`size-4`}),e.createTitle]})}var He={revokeOpen:!1,revoking:!1,linksOpen:!1,urlCopied:!1,copyFailed:!1,extending:!1};function Ue({share:e,t,language:n,onRevoked:r,onExtended:i}){let[c,l]=(0,J.useReducer)(m,He),{revokeOpen:u,revoking:d,linksOpen:f,urlCopied:p,copyFailed:h,extending:g}=c,_=!e.expired&&!e.revoked,v=e.revoked?t.statusRevoked:e.expired?t.statusExpired:t.statusActive,y=e.revoked?`text-red-600 dark:text-red-400`:e.expired?`text-fg-subtle`:`text-emerald-600 dark:text-emerald-400`,b=(0,J.useCallback)(async()=>{l({type:`patch`,patch:{revokeOpen:!1,revoking:!0}});try{await I(e.id),r()}catch{}finally{l({type:`patch`,patch:{revoking:!1}})}},[e.id,r]),S=(0,J.useCallback)(async()=>{if(l({type:`patch`,patch:{linksOpen:!0,copyFailed:!1}}),!await s(e.shareUrl)){l({type:`patch`,patch:{copyFailed:!0}}),window.setTimeout(()=>l({type:`patch`,patch:{copyFailed:!1}}),2500);return}l({type:`patch`,patch:{urlCopied:!0}}),window.setTimeout(()=>l({type:`patch`,patch:{urlCopied:!1}}),2e3)},[e.shareUrl]),T=(0,J.useCallback)(async()=>{l({type:`patch`,patch:{extending:!0}});try{await R(e.id,864e5),i()}catch{}finally{l({type:`patch`,patch:{extending:!1}})}},[e.id,i]),E=`share-links-${e.id}`;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:o(`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":f,"aria-controls":E,onClick:()=>l({type:`patch`,patch:{linksOpen:!f}}),children:[(0,Q.jsx)(ie,{className:o(`mt-0.5 size-4 shrink-0 text-fg-muted transition-transform`,f?`rotate-0`:`-rotate-90`),"aria-hidden":!0}),(0,Q.jsx)(C,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.fileName}),(0,Q.jsx)(`span`,{className:o(`text-xs font-medium`,y),children:v})]}),(0,Q.jsx)(`p`,{className:`truncate text-xs text-fg-subtle`,children:e.workspaceRelativePath}),(0,Q.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,Q.jsx)(`span`,{children:Oe(e.fileSize)}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(j,{className:`size-3`}),e.expired?n===`zh`?`已过期`:`expired`:ke(e.expiresAt,n)]}),(0,Q.jsxs)(`span`,{children:[t.views,`: `,e.downloadCount,e.maxViews!==null&&` ${t.viewsOf} ${e.maxViews}`]}),e.description&&(0,Q.jsx)(`span`,{className:`italic text-fg-subtle`,children:e.description})]})]})]}),(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:_&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(V,{type:`button`,variant:`ghost`,className:`px-2 py-1`,title:t.copyUrl,onClick:()=>void S(),children:p?(0,Q.jsx)(a,{className:`size-3.5 text-emerald-500`}):(0,Q.jsx)(A,{className:`size-3.5`})}),(0,Q.jsx)(V,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:()=>void T(),disabled:g,title:t.extend,children:g?(0,Q.jsx)(x,{className:`size-3.5 animate-spin`}):(0,Q.jsx)(j,{className:`size-3.5`})}),(0,Q.jsx)(V,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-red-600 hover:text-red-700 dark:text-red-400`,onClick:()=>l({type:`patch`,patch:{revokeOpen:!0}}),disabled:d,children:d?(0,Q.jsx)(x,{className:`size-3.5 animate-spin`}):(0,Q.jsx)(k,{className:`size-3.5`})})]})})]}),_&&f?(0,Q.jsxs)(`div`,{id:E,className:`mt-3 bg-surface-base/45 py-3 pl-7 pr-3`,children:[(0,Q.jsx)(z,{shareUrl:e.shareUrl,lanUrl:e.lanUrl,reachability:e.reachability,compact:!0}),h?(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-red-600 dark:text-red-400`,children:t.copyFailed}):null,(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)(L,{reachability:e.reachability})})]}):null]}),(0,Q.jsx)(w,{open:u,title:t.revokeConfirmTitle,description:t.revokeConfirmBody,confirmLabel:t.revokeConfirmLabel,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void b(),onCancel:()=>l({type:`patch`,patch:{revokeOpen:!1}})})]})}function We({t:e,onCleaned:t}){let[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(!1),o=(0,J.useCallback)(async()=>{r(!1),a(!0);try{await ae(),t()}catch{}finally{a(!1)}},[t]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Q.jsxs)(V,{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,Q.jsx)(x,{className:`size-3.5 animate-spin`}):(0,Q.jsx)(k,{className:`size-3.5`}),e.cleanExpired]})}),(0,Q.jsx)(w,{open:n,title:e.cleanExpiredConfirmTitle,description:e.cleanExpiredConfirmBody,confirmLabel:e.cleanExpiredConfirmLabel,cancelLabel:e.cancel,destructive:!0,onConfirm:()=>void o(),onCancel:()=>r(!1)})]})}export{je 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-Bjvw7jtg.js";import{Nr as r}from"./index-BzPwnXho.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};