@xopcai/xopc 0.0.313 → 0.0.315

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 (696) hide show
  1. package/dist/browser-ext/dist/assets/{auth-C3yV1y_l.js → auth-DKo-NMUY.js} +18 -1
  2. package/dist/browser-ext/dist/background.js +68 -2
  3. package/dist/browser-ext/dist/sidepanel.html +1 -1
  4. package/dist/browser-ext/dist/sidepanel.js +1 -1
  5. package/dist/browser-ext/manifest.json +1 -1
  6. package/dist/extensions/feishu/src/adapters/cli-login.js +3 -3
  7. package/dist/extensions/feishu/src/outbound/media-load.js +1 -1
  8. package/dist/extensions/telegram/src/inbound-processor.js +1 -1
  9. package/dist/extensions/telegram/src/outbound-sender.js +1 -1
  10. package/dist/extensions/telegram/src/plugin.js +2 -2
  11. package/dist/extensions/telegram/xopc.extension.json +1 -1
  12. package/dist/extensions/weixin/src/api/api.js +2 -2
  13. package/dist/extensions/weixin/src/auth/accounts.js +12 -12
  14. package/dist/extensions/weixin/src/messaging/debug-mode.js +5 -5
  15. package/dist/extensions/weixin/src/messaging/inbound.js +11 -11
  16. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-C73s_EYF.js → agent-avatar-dicebear-BbFOF2SH.js} +1 -1
  17. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-D9T-QGmd.js +1 -0
  18. package/dist/gateway/static/root/assets/agents-Ds5sQcPd.js +1 -0
  19. package/dist/gateway/static/root/assets/{api-Com7kQuw.js → api-BzloAiIG.js} +1 -1
  20. package/dist/gateway/static/root/assets/{app-link-CKueEVbT.js → app-link-nL8iPwEr.js} +1 -1
  21. package/dist/gateway/static/root/assets/{app-management-settings-panel-DSo_SV6G.js → app-management-settings-panel-BpUHskXq.js} +1 -1
  22. package/dist/gateway/static/root/assets/appearance-settings-CQd5Vo6f.js +1 -0
  23. package/dist/gateway/static/root/assets/apps-page-B7VIsfye.js +1 -0
  24. package/dist/gateway/static/root/assets/{archive-plugin-BWueu3Qt.js → archive-plugin-BM4O6WfL.js} +1 -1
  25. package/dist/gateway/static/root/assets/{attachment-load-DYV25sAC.js → attachment-load-Cdn9MYmI.js} +1 -1
  26. package/dist/gateway/static/root/assets/{automations-page-Du8AkHrH.js → automations-page-DnRx-Ra4.js} +1 -1
  27. package/dist/gateway/static/root/assets/automations-workspace-B5s10G5F.js +7 -0
  28. package/dist/gateway/static/root/assets/{binary-plugins-rahoUE_-.js → binary-plugins-dkhUf4bm.js} +1 -1
  29. package/dist/gateway/static/root/assets/{block-editor-CVbiuQ90.js → block-editor-BTzqEuAy.js} +29 -29
  30. package/dist/gateway/static/root/assets/{browser-automation-inputs-CAC4w9KM.js → browser-automation-inputs-Bowij-nJ.js} +1 -1
  31. package/dist/gateway/static/root/assets/{browser-automations-page-B3-fdrAr.js → browser-automations-page-CQ7SYTQj.js} +2 -2
  32. package/dist/gateway/static/root/assets/browser-settings-page-vqLoPOOg.js +3 -0
  33. package/dist/gateway/static/root/assets/capabilities-D0S3DuAD.js +1 -0
  34. package/dist/gateway/static/root/assets/capabilities-settings-panel-DI68WGYd.js +8 -0
  35. package/dist/gateway/static/root/assets/channels-settings-Cimssy-S.js +1 -0
  36. package/dist/gateway/static/root/assets/{chat-terminal-dock-98GzKJ0K.js → chat-terminal-dock-DzgFHd6l.js} +2 -2
  37. package/dist/gateway/static/root/assets/{computer-settings-page-CB3mySQb.js → computer-settings-page-380_vIqO.js} +1 -1
  38. package/dist/gateway/static/root/assets/{connector-service-page-ZlbIXdey.js → connector-service-page-DILFakXb.js} +1 -1
  39. package/dist/gateway/static/root/assets/connectors-page-COmFp9HC.js +2 -0
  40. package/dist/gateway/static/root/assets/conversation-identity-Cw0n9uzK.js +1 -0
  41. package/dist/gateway/static/root/assets/{date-picker-WW3fY-ng.js → date-picker-CRVun-T5.js} +1 -1
  42. package/dist/gateway/static/root/assets/{dependency-picker-D1QgzM_s.js → dependency-picker-BoWqt5yU.js} +1 -1
  43. package/dist/gateway/static/root/assets/{desktop-pet-D0MtbTwu.js → desktop-pet-DPlkBjft.js} +1 -1
  44. package/dist/gateway/static/root/assets/desktop-pet-settings-D7FgfX_K.js +1 -0
  45. package/dist/gateway/static/root/assets/device-pairing-wizard-BP6yxut8.js +1 -0
  46. package/dist/gateway/static/root/assets/{extension-debug-page-BOtWAAGM.js → extension-debug-page-CT_QkSN_.js} +1 -1
  47. package/dist/gateway/static/root/assets/{extension-page-FULvawj8.js → extension-page-BF1NdcKP.js} +1 -1
  48. package/dist/gateway/static/root/assets/{extension-settings-page-Dzh6lE26.js → extension-settings-page-CKQVZ3Xc.js} +1 -1
  49. package/dist/gateway/static/root/assets/files-BK6enEvD.js +1 -0
  50. package/dist/gateway/static/root/assets/{gateway-config-swr-D7SG_ECs.js → gateway-config-swr-BPsZPoAT.js} +1 -1
  51. package/dist/gateway/static/root/assets/gateway-settings-3bIy7XMr.js +1 -0
  52. package/dist/gateway/static/root/assets/{gateway-startup-retry-CrHz00-9.js → gateway-startup-retry-cG6EqUJw.js} +1 -1
  53. package/dist/gateway/static/root/assets/home-page-DFNDLFgv.js +1 -0
  54. package/dist/gateway/static/root/assets/{image-generation-api-DGiHzeLb.js → image-generation-api-DI_QutIx.js} +1 -1
  55. package/dist/gateway/static/root/assets/{imports-page-DiJrgu9D.js → imports-page-BUG6G72F.js} +1 -1
  56. package/dist/gateway/static/root/assets/index-BCi8nfxs.js +89 -0
  57. package/dist/gateway/static/root/assets/index-DWgd1VK2.css +1 -0
  58. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DZ60sucF.js → keyboard-shortcuts-settings-qnG-4FJs.js} +1 -1
  59. package/dist/gateway/static/root/assets/local-app-workbench-page-B3iJWhjN.js +2 -0
  60. package/dist/gateway/static/root/assets/{local-apps-page-Cx2YuI8E.js → local-apps-page-BpEGeURS.js} +1 -1
  61. package/dist/gateway/static/root/assets/{locale-store-vZTDIqJB.js → locale-store-BlgpZORR.js} +1 -1
  62. package/dist/gateway/static/root/assets/logs-page-0QPGj-5c.js +2 -0
  63. package/dist/gateway/static/root/assets/management-settings-Sl0wwidS.js +1 -0
  64. package/dist/gateway/static/root/assets/{markdown-view-DJfzcZCW.js → markdown-view-BzjjpL2H.js} +1 -1
  65. package/dist/gateway/static/root/assets/{media-plugins-COpQGcN3.js → media-plugins-Bzkdhotn.js} +1 -1
  66. package/dist/gateway/static/root/assets/messages-2GhUD7SC.js +3 -0
  67. package/dist/gateway/static/root/assets/note-detail-panel-BXtD71j1.js +5 -0
  68. package/dist/gateway/static/root/assets/notes-page-DNY4vW-u.js +8 -0
  69. package/dist/gateway/static/root/assets/page-context-capture-button-CFt4hXQ6.js +1 -0
  70. package/dist/gateway/static/root/assets/{page-tabs-nARdLZcP.js → page-tabs-Dz_x22MQ.js} +1 -1
  71. package/dist/gateway/static/root/assets/{preview-open-alternatives-BEJg3fTq.js → preview-open-alternatives-C1mkgFAl.js} +1 -1
  72. package/dist/gateway/static/root/assets/product-delivery-chCjIpvu.js +1 -0
  73. package/dist/gateway/static/root/assets/{product-open-page-CR4Lehku.js → product-open-page-DHZgzSDV.js} +1 -1
  74. package/dist/gateway/static/root/assets/project-detail-page-D3NhZ7ZZ.js +1 -0
  75. package/dist/gateway/static/root/assets/projects-page-CEr8DX9I.js +1 -0
  76. package/dist/gateway/static/root/assets/{registry-api-CF-nJ5MG.js → registry-api-DMW2apOO.js} +1 -1
  77. package/dist/gateway/static/root/assets/remote-access-hub-Db-B-Mf3.js +1 -0
  78. package/dist/gateway/static/root/assets/runtime-tools-settings-panel-DEJi0BLL.js +5 -0
  79. package/dist/gateway/static/root/assets/scenes-page-BUUX-PnI.js +2 -0
  80. package/dist/gateway/static/root/assets/{schema-form-DOsDKbWU.js → schema-form-RVltVpuG.js} +1 -1
  81. package/dist/gateway/static/root/assets/schemas-88fK3zzl.js +64 -0
  82. package/dist/gateway/static/root/assets/sessions-page-Rm4H2okS.js +1 -0
  83. package/dist/gateway/static/root/assets/settings-advanced-gate-VxPItcOG.js +1 -0
  84. package/dist/gateway/static/root/assets/{settings-form-section-kIV5M-9G.js → settings-form-section-BkBO7woF.js} +1 -1
  85. package/dist/gateway/static/root/assets/{settings-page-layout-B39PogyD.js → settings-page-layout-lLvHc-zF.js} +1 -1
  86. package/dist/gateway/static/root/assets/{settings-page-C2TS9mvq.js → settings-page-zl0XY203.js} +1 -1
  87. package/dist/gateway/static/root/assets/setup-status-panel-Difrpr4T.js +1 -0
  88. package/dist/gateway/static/root/assets/{share-preview-page-CMbgRZ7w.js → share-preview-page-NC4Gj867.js} +1 -1
  89. package/dist/gateway/static/root/assets/shares-settings-DPLvEcB-.js +1 -0
  90. package/dist/gateway/static/root/assets/skill-reload-api-CKdLCf_-.js +1 -0
  91. package/dist/gateway/static/root/assets/{skills-page-DV4FX1ev.js → skills-page-CzekvBNQ.js} +1 -1
  92. package/dist/gateway/static/root/assets/{skills-page.utils-C-2lmZHk.js → skills-page.utils-BLeiN245.js} +1 -1
  93. package/dist/gateway/static/root/assets/{system-settings-panel-CQ1Z6i28.js → system-settings-panel-Bp75s9nl.js} +1 -1
  94. package/dist/gateway/static/root/assets/task-detail-page-Bh8H4FYR.js +1 -0
  95. package/dist/gateway/static/root/assets/tasks-CDR_RVbQ.js +1 -0
  96. package/dist/gateway/static/root/assets/{tunnel-api-tn6H0D44.js → tunnel-api-BDiaC6an.js} +1 -1
  97. package/dist/gateway/static/root/assets/turn-outcome-D0SnyZ3Z.js +1 -0
  98. package/dist/gateway/static/root/assets/{use-autosave-CkEM9tXu.js → use-autosave-C_ntK_Zu.js} +1 -1
  99. package/dist/gateway/static/root/assets/user-model-page-C7gFCGAV.js +2 -0
  100. package/dist/gateway/static/root/assets/{voice-api-key-field-d0Fawetf.js → voice-api-key-field-D4cfuMp1.js} +1 -1
  101. package/dist/gateway/static/root/assets/{voice-config-api-D_8zU7Li.js → voice-config-api-Cjvd6maH.js} +1 -1
  102. package/dist/gateway/static/root/assets/{work-discovery-overlay-C5FFSieF.js → work-discovery-overlay-Ce6ToB0O.js} +1 -1
  103. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-q5ammR4k.js → workflow-run-setup-panel-C80nrmKi.js} +2 -2
  104. package/dist/gateway/static/root/assets/workflows-page-CVQjo3RI.js +6 -0
  105. package/dist/gateway/static/root/index.html +16 -16
  106. package/dist/package.js +1 -1
  107. package/dist/packages/computer-control-contract/src/index.js +10 -1
  108. package/dist/packages/gateway-contract/src/app-context.js +55 -0
  109. package/dist/packages/gateway-contract/src/automations.js +16 -17
  110. package/dist/packages/gateway-contract/src/capabilities.js +1078 -0
  111. package/dist/packages/gateway-contract/src/extension-capabilities.js +26 -0
  112. package/dist/packages/gateway-contract/src/home.js +3 -3
  113. package/dist/packages/gateway-contract/src/index.js +8 -0
  114. package/dist/packages/gateway-contract/src/product-delivery.js +19 -4
  115. package/dist/packages/gateway-contract/src/scenes.js +199 -0
  116. package/dist/packages/gateway-contract/src/task-runs.js +8 -4
  117. package/dist/packages/gateway-contract/src/tasks.js +5 -4
  118. package/dist/packages/realtime-client/src/index.js +17 -4
  119. package/dist/src/agent/agent-manager.d.ts +1 -0
  120. package/dist/src/agent/agent-manager.js +19 -18
  121. package/dist/src/agent/agent-scope.js +2 -2
  122. package/dist/src/agent/background-review/run-background-review.js +4 -4
  123. package/dist/src/agent/child-agent-factory.d.ts +2 -0
  124. package/dist/src/agent/child-agent-factory.js +5 -0
  125. package/dist/src/agent/coding/repository-instructions.js +1 -1
  126. package/dist/src/agent/commands/approved-verification.d.ts +14 -0
  127. package/dist/src/agent/commands/approved-verification.js +48 -0
  128. package/dist/src/agent/context/coordinator.js +2 -2
  129. package/dist/src/agent/context/execution-context.js +4 -4
  130. package/dist/src/agent/context/execution-scope.js +4 -3
  131. package/dist/src/agent/context/project-context.js +5 -4
  132. package/dist/src/agent/data-acquisition/service.js +1 -1
  133. package/dist/src/agent/embedded/index.js +2 -2
  134. package/dist/src/agent/embedded/model-runtime.js +1 -1
  135. package/dist/src/agent/embedded/run-for-session.js +4 -4
  136. package/dist/src/agent/embedded/run-turn.js +4 -4
  137. package/dist/src/agent/embedded/session-tool-result-guard.js +3 -3
  138. package/dist/src/agent/embedded/tool-result-truncation.js +1 -1
  139. package/dist/src/agent/external-tools/cliProvider.js +126 -78
  140. package/dist/src/agent/external-tools/composio-provider.d.ts +1 -1
  141. package/dist/src/agent/external-tools/composio-provider.js +73 -15
  142. package/dist/src/agent/external-tools/endpoint-provider.js +14 -1
  143. package/dist/src/agent/external-tools/gateway-tools.js +1 -1
  144. package/dist/src/agent/external-tools/mcp-provider.js +2 -2
  145. package/dist/src/agent/image/generation/openai-images-provider.js +1 -1
  146. package/dist/src/agent/image/generation/providers/dashscope.js +1 -1
  147. package/dist/src/agent/image/generation/providers/fal.js +1 -1
  148. package/dist/src/agent/image/generation/providers/google.js +1 -1
  149. package/dist/src/agent/image/generation/runtime.js +1 -1
  150. package/dist/src/agent/image/index.js +1 -1
  151. package/dist/src/agent/image/load-image-media.js +1 -1
  152. package/dist/src/agent/image/tool-model-config.js +1 -1
  153. package/dist/src/agent/inbound/attachment-pipeline.js +1 -1
  154. package/dist/src/agent/inbound/inbound-loop.js +2 -2
  155. package/dist/src/agent/inbound/turn-dispatcher.d.ts +2 -0
  156. package/dist/src/agent/inbound/turn-dispatcher.js +2 -1
  157. package/dist/src/agent/index.js +1 -1
  158. package/dist/src/agent/mcp/bundle-mcp-gateway.d.ts +39 -0
  159. package/dist/src/agent/mcp/bundle-mcp-gateway.js +33 -2
  160. package/dist/src/agent/mcp/bundle-mcp-runtime.js +12 -1
  161. package/dist/src/agent/mcp/bundle-mcp-types.d.ts +2 -1
  162. package/dist/src/agent/mcp/index.js +2 -2
  163. package/dist/src/agent/mcp/mcp-resource-id.d.ts +6 -0
  164. package/dist/src/agent/mcp/mcp-resource-id.js +19 -0
  165. package/dist/src/agent/mcp/mcp-transport.js +1 -1
  166. package/dist/src/agent/mcp/oauth/mcp-oauth-store.js +1 -1
  167. package/dist/src/agent/memory/compaction-chunks.d.ts +6 -1
  168. package/dist/src/agent/memory/compaction-chunks.js +16 -3
  169. package/dist/src/agent/memory/compaction-ledger.d.ts +3 -1
  170. package/dist/src/agent/memory/compaction-ledger.js +31 -18
  171. package/dist/src/agent/memory/compaction-request.d.ts +2 -0
  172. package/dist/src/agent/memory/compaction-request.js +6 -1
  173. package/dist/src/agent/memory/compaction.d.ts +19 -1
  174. package/dist/src/agent/memory/compaction.js +112 -30
  175. package/dist/src/agent/memory/context-recovery.js +1 -1
  176. package/dist/src/agent/memory/index.js +2 -2
  177. package/dist/src/agent/orchestration/agent-orchestrator.js +5 -5
  178. package/dist/src/agent/prompt/service-prompt-builder.js +2 -2
  179. package/dist/src/agent/sandbox/exec-policy.js +1 -1
  180. package/dist/src/agent/service/direct-turn-helpers.js +5 -5
  181. package/dist/src/agent/service/process-direct-one-shot.js +1 -1
  182. package/dist/src/agent/service/process-direct-streaming.d.ts +3 -0
  183. package/dist/src/agent/service/process-direct-streaming.js +21 -12
  184. package/dist/src/agent/service/webchat-tts.js +1 -1
  185. package/dist/src/agent/service.js +22 -21
  186. package/dist/src/agent/service.types.d.ts +1 -0
  187. package/dist/src/agent/session/session-inspector.js +1 -1
  188. package/dist/src/agent/skills/config.js +2 -0
  189. package/dist/src/agent/skills/filesystem-watcher.js +1 -1
  190. package/dist/src/agent/skills/format-skills-prompt.js +14 -1
  191. package/dist/src/agent/skills/hub-lock.js +1 -1
  192. package/dist/src/agent/skills/hub-pull.js +3 -3
  193. package/dist/src/agent/skills/index.js +16 -8
  194. package/dist/src/agent/skills/marketplace/adapters/store/adapter.js +1 -1
  195. package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.js +1 -1
  196. package/dist/src/agent/skills/types.d.ts +1 -1
  197. package/dist/src/agent/source-context/app-context.d.ts +4 -0
  198. package/dist/src/agent/source-context/app-context.js +36 -0
  199. package/dist/src/agent/source-context/browser-tab.d.ts +3 -0
  200. package/dist/src/agent/source-context/browser-tab.js +29 -0
  201. package/dist/src/agent/source-context/file-context.d.ts +3 -0
  202. package/dist/src/agent/source-context/file-context.js +64 -0
  203. package/dist/src/agent/source-context/index.d.ts +4 -0
  204. package/dist/src/agent/source-context/index.js +5 -1
  205. package/dist/src/agent/source-context/injector.js +2 -1
  206. package/dist/src/agent/source-context/mcp-resource-context.d.ts +8 -0
  207. package/dist/src/agent/source-context/mcp-resource-context.js +30 -0
  208. package/dist/src/agent/source-context/session-context.d.ts +8 -0
  209. package/dist/src/agent/source-context/session-context.js +33 -0
  210. package/dist/src/agent/source-context/types.d.ts +12 -2
  211. package/dist/src/agent/source-context/types.js +3 -2
  212. package/dist/src/agent/tasks/task-judge-service.js +6 -5
  213. package/dist/src/agent/tool-manuals/computer.d.ts +1 -1
  214. package/dist/src/agent/tool-manuals/computer.js +1 -1
  215. package/dist/src/agent/tools/automation-tool.d.ts +12 -1
  216. package/dist/src/agent/tools/automation-tool.js +106 -32
  217. package/dist/src/agent/tools/create-share-tool.js +4 -4
  218. package/dist/src/agent/tools/dataBatch.js +1 -1
  219. package/dist/src/agent/tools/delegate-tool.js +3 -3
  220. package/dist/src/agent/tools/delegation-parent-policy.js +1 -1
  221. package/dist/src/agent/tools/executor.js +1 -1
  222. package/dist/src/agent/tools/factory.d.ts +1 -0
  223. package/dist/src/agent/tools/factory.js +22 -17
  224. package/dist/src/agent/tools/fetch-text.js +1 -1
  225. package/dist/src/agent/tools/image-generate-tool.js +3 -3
  226. package/dist/src/agent/tools/index.js +6 -6
  227. package/dist/src/agent/tools/list-dir.js +1 -1
  228. package/dist/src/agent/tools/publish-artifacts.js +2 -2
  229. package/dist/src/agent/tools/read.js +2 -2
  230. package/dist/src/agent/tools/review-workspace.js +1 -1
  231. package/dist/src/agent/tools/scoped-workspace-tools.d.ts +8 -0
  232. package/dist/src/agent/tools/scoped-workspace-tools.js +81 -0
  233. package/dist/src/agent/tools/send-media.js +2 -2
  234. package/dist/src/agent/tools/skills-tools.js +1 -1
  235. package/dist/src/agent/tools/user-context-tool.js +1 -1
  236. package/dist/src/agent/tools/write.js +2 -2
  237. package/dist/src/agent/tools/xopc-use-tool.d.ts +6 -3
  238. package/dist/src/agent/tools/xopc-use-tool.js +997 -908
  239. package/dist/src/agent/workflow/subagent-runner.js +2 -1
  240. package/dist/src/agent-config/index.js +2 -2
  241. package/dist/src/agent-config/schema.d.ts +5 -0
  242. package/dist/src/agent-config/schema.js +14 -10
  243. package/dist/src/ai-assist/text-assist.js +1 -1
  244. package/dist/src/auth/credentials.js +2 -2
  245. package/dist/src/auth/oauth/xopc-cloud.js +1 -1
  246. package/dist/src/auth/profiles/store.js +1 -1
  247. package/dist/src/auth/sync-provider-auth.js +2 -2
  248. package/dist/src/automations/api/routes.js +244 -164
  249. package/dist/src/automations/capabilities/drafts.d.ts +4 -0
  250. package/dist/src/automations/capabilities/drafts.js +95 -0
  251. package/dist/src/automations/capabilities/read.d.ts +4 -0
  252. package/dist/src/automations/capabilities/read.js +119 -0
  253. package/dist/src/automations/capabilities/write.d.ts +349 -0
  254. package/dist/src/automations/capabilities/write.js +172 -0
  255. package/dist/src/automations/domain/index.js +2 -2
  256. package/dist/src/automations/domain/validation.d.ts +77 -77
  257. package/dist/src/automations/domain/validation.js +9 -6
  258. package/dist/src/automations/draft/automation-draft-validator.d.ts +2 -2
  259. package/dist/src/automations/index.js +6 -6
  260. package/dist/src/automations/service/automation-service.d.ts +31 -0
  261. package/dist/src/automations/service/automation-service.js +213 -75
  262. package/dist/src/automations/service/index.js +2 -2
  263. package/dist/src/automations/storage/automation-repository.d.ts +2 -0
  264. package/dist/src/automations/storage/automation-repository.js +9 -1
  265. package/dist/src/automations/storage/automation-run-repository.d.ts +4 -1
  266. package/dist/src/automations/storage/automation-run-repository.js +16 -3
  267. package/dist/src/automations/storage/index.js +3 -3
  268. package/dist/src/browser/automations/schema.d.ts +1 -1
  269. package/dist/src/browser/automations/service.d.ts +1 -1
  270. package/dist/src/browser/observation/format.js +4 -0
  271. package/dist/src/browser/providers/browser-ext-install.js +1 -1
  272. package/dist/src/capabilities/adapters/http.d.ts +4 -0
  273. package/dist/src/capabilities/adapters/http.js +44 -0
  274. package/dist/src/capabilities/readiness/from-config.js +11 -7
  275. package/dist/src/capabilities/runtime/app-context.d.ts +3 -0
  276. package/dist/src/capabilities/runtime/app-context.js +72 -0
  277. package/dist/src/capabilities/runtime/atomic-operations.d.ts +11 -0
  278. package/dist/src/capabilities/runtime/atomic-operations.js +34 -0
  279. package/dist/src/capabilities/runtime/dispatcher.d.ts +67 -0
  280. package/dist/src/capabilities/runtime/dispatcher.js +170 -0
  281. package/dist/src/capabilities/runtime/errors.d.ts +6 -0
  282. package/dist/src/capabilities/runtime/errors.js +11 -0
  283. package/dist/src/capabilities/runtime/external-operations.d.ts +16 -0
  284. package/dist/src/capabilities/runtime/external-operations.js +92 -0
  285. package/dist/src/capabilities/runtime/product.d.ts +12 -0
  286. package/dist/src/capabilities/runtime/product.js +69 -0
  287. package/dist/src/capabilities/runtime/settings.d.ts +3 -0
  288. package/dist/src/capabilities/runtime/settings.js +27 -0
  289. package/dist/src/capabilities/store-connector.js +1 -1
  290. package/dist/src/channels/attachments/voice-stt-webchat.js +2 -2
  291. package/dist/src/channels/index.js +2 -2
  292. package/dist/src/channels/pairing/allow-from-file.js +9 -9
  293. package/dist/src/channels/pairing/pairing-store.js +6 -6
  294. package/dist/src/chat-commands/agent-edit.js +1 -1
  295. package/dist/src/chat-commands/builtins/config.js +1 -1
  296. package/dist/src/chat-commands/builtins/review.js +1 -1
  297. package/dist/src/chat-commands/builtins/thinking.js +1 -1
  298. package/dist/src/chat-commands/builtins/tts.js +1 -1
  299. package/dist/src/chat-commands/builtins/understanding.js +1 -1
  300. package/dist/src/chat-commands/builtins/workflow.js +2 -2
  301. package/dist/src/chat-commands/context.js +2 -2
  302. package/dist/src/chat-commands/index.js +2 -2
  303. package/dist/src/cli/cli-log-level-preset.d.ts +2 -0
  304. package/dist/src/cli/cli-log-level-preset.js +4 -0
  305. package/dist/src/cli/command-catalog.js +4 -0
  306. package/dist/src/cli/command-loaders.js +1 -0
  307. package/dist/src/cli/command-manifest.js +4 -0
  308. package/dist/src/cli/commands/agent.js +7 -7
  309. package/dist/src/cli/commands/agents.js +1 -1
  310. package/dist/src/cli/commands/config.js +1 -1
  311. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  312. package/dist/src/cli/commands/doctor/checks/provider-auth.js +3 -3
  313. package/dist/src/cli/commands/extension-dev.js +1 -1
  314. package/dist/src/cli/commands/extension.js +1 -1
  315. package/dist/src/cli/commands/gateway/shared.js +1 -1
  316. package/dist/src/cli/commands/gateway/token.js +1 -1
  317. package/dist/src/cli/commands/image.js +1 -1
  318. package/dist/src/cli/commands/init.js +1 -1
  319. package/dist/src/cli/commands/mcp.d.ts +1 -0
  320. package/dist/src/cli/commands/mcp.js +51 -0
  321. package/dist/src/cli/commands/models.js +1 -1
  322. package/dist/src/cli/commands/onboard.js +1 -1
  323. package/dist/src/cli/commands/project.js +2 -2
  324. package/dist/src/cli/commands/runtime.js +1 -1
  325. package/dist/src/cli/commands/skills.js +2 -2
  326. package/dist/src/cli/commands/tunnel.js +3 -3
  327. package/dist/src/cli/extension-cli-register.js +4 -4
  328. package/dist/src/cli/utils/gateway-client.js +1 -1
  329. package/dist/src/computer/broker.d.ts +0 -1
  330. package/dist/src/computer/broker.js +4 -6
  331. package/dist/src/computer/evaluation-harness.d.ts +45 -0
  332. package/dist/src/computer/evaluation-harness.js +108 -0
  333. package/dist/src/computer/model-adapter.d.ts +37 -2
  334. package/dist/src/computer/model-adapter.js +333 -42
  335. package/dist/src/computer/model-policy.d.ts +4 -1
  336. package/dist/src/computer/model-policy.js +11 -3
  337. package/dist/src/computer/release-gate.d.ts +22 -0
  338. package/dist/src/computer/release-gate.js +19 -0
  339. package/dist/src/computer/runtime.js +16 -12
  340. package/dist/src/computer/task-state.d.ts +1 -0
  341. package/dist/src/computer/task-state.js +1 -0
  342. package/dist/src/config/index.js +5 -5
  343. package/dist/src/config/loader.js +2 -2
  344. package/dist/src/config/models-json.d.ts +6 -0
  345. package/dist/src/config/models-json.js +3 -3
  346. package/dist/src/config/schema.d.ts +4 -0
  347. package/dist/src/config/schema.js +4 -10
  348. package/dist/src/connectors/cli/authorization.js +1 -1
  349. package/dist/src/connectors/cli/runtime.js +1 -1
  350. package/dist/src/connectors/composio-sessions.d.ts +4 -2
  351. package/dist/src/connectors/composio-sessions.js +11 -10
  352. package/dist/src/connectors/composio.js +11 -9
  353. package/dist/src/connectors/connected-source-understanding.js +2 -2
  354. package/dist/src/connectors/connection-recovery-service.js +5 -5
  355. package/dist/src/connectors/health.js +1 -1
  356. package/dist/src/discussions/action-tasks.js +2 -1
  357. package/dist/src/discussions/live-worker.js +1 -1
  358. package/dist/src/discussions/recording.js +1 -1
  359. package/dist/src/discussions/sealer.js +1 -1
  360. package/dist/src/execution-environments/local-worktree-manager.d.ts +1 -0
  361. package/dist/src/execution-environments/local-worktree-manager.js +13 -2
  362. package/dist/src/extensions/activation-context.js +3 -3
  363. package/dist/src/extensions/api.js +3 -3
  364. package/dist/src/extensions/bundled-extension-activation.js +1 -1
  365. package/dist/src/extensions/index.js +1 -1
  366. package/dist/src/extensions/loader.js +1 -1
  367. package/dist/src/extensions/lockfile.js +1 -1
  368. package/dist/src/extensions/normalize-manifest.js +6 -1
  369. package/dist/src/extensions/sdk/index.js +1 -1
  370. package/dist/src/extensions/sdk/media.js +1 -1
  371. package/dist/src/extensions/types/manifest.d.ts +3 -0
  372. package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
  373. package/dist/src/gateway/agents-admin.js +4 -4
  374. package/dist/src/gateway/chat-stream/mapper.js +3 -2
  375. package/dist/src/gateway/device-routes.js +2 -2
  376. package/dist/src/gateway/file-path-classifier.js +2 -2
  377. package/dist/src/gateway/global-defaults-admin.js +1 -1
  378. package/dist/src/gateway/hono/app.js +3 -3
  379. package/dist/src/gateway/hono/lib/config-payload.d.ts +1 -0
  380. package/dist/src/gateway/hono/lib/config-payload.js +3 -3
  381. package/dist/src/gateway/hono/middleware/scopes.js +1 -1
  382. package/dist/src/gateway/hono/routes/agent-stream.js +2 -2
  383. package/dist/src/gateway/hono/routes/agents.js +1 -1
  384. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +6 -3
  385. package/dist/src/gateway/hono/routes/browser.js +33 -1
  386. package/dist/src/gateway/hono/routes/capability-operations.d.ts +3 -0
  387. package/dist/src/gateway/hono/routes/capability-operations.js +52 -0
  388. package/dist/src/gateway/hono/routes/commands-skills.js +3 -3
  389. package/dist/src/gateway/hono/routes/config-patch/gateway.js +1 -1
  390. package/dist/src/gateway/hono/routes/config-patch/misc.js +1 -1
  391. package/dist/src/gateway/hono/routes/devices.js +0 -16
  392. package/dist/src/gateway/hono/routes/endpoint-tools.js +86 -30
  393. package/dist/src/gateway/hono/routes/home.js +1 -1
  394. package/dist/src/gateway/hono/routes/imports.js +1 -1
  395. package/dist/src/gateway/hono/routes/lazy-bundles.js +16 -0
  396. package/dist/src/gateway/hono/routes/local-app-capabilities.d.ts +4 -0
  397. package/dist/src/gateway/hono/routes/local-app-capabilities.js +41 -0
  398. package/dist/src/gateway/hono/routes/local-apps.js +41 -9
  399. package/dist/src/gateway/hono/routes/mcp.js +33 -2
  400. package/dist/src/gateway/hono/routes/media.js +1 -1
  401. package/dist/src/gateway/hono/routes/models.js +7 -7
  402. package/dist/src/gateway/hono/routes/notes.js +216 -147
  403. package/dist/src/gateway/hono/routes/projects.js +219 -376
  404. package/dist/src/gateway/hono/routes/scenes.js +188 -75
  405. package/dist/src/gateway/hono/routes/session-input-handler.d.ts +64 -16
  406. package/dist/src/gateway/hono/routes/session-input-handler.js +49 -7
  407. package/dist/src/gateway/hono/routes/sessions.js +18 -1
  408. package/dist/src/gateway/hono/routes/shares.js +3 -3
  409. package/dist/src/gateway/hono/routes/site-shares.js +1 -1
  410. package/dist/src/gateway/hono/routes/tasks.js +182 -326
  411. package/dist/src/gateway/hono/routes/user-model-refresh.js +1 -1
  412. package/dist/src/gateway/hono/routes/user-model.js +4 -4
  413. package/dist/src/gateway/hono/routes/voice.js +7 -7
  414. package/dist/src/gateway/hono/routes/workflows.js +3 -3
  415. package/dist/src/gateway/lock.js +11 -11
  416. package/dist/src/gateway/media-access.js +3 -2
  417. package/dist/src/gateway/mobile-privacy.js +2 -2
  418. package/dist/src/gateway/ports.js +6 -6
  419. package/dist/src/gateway/scenes/host.js +14 -3
  420. package/dist/src/gateway/scenes/mailContext.js +1 -1
  421. package/dist/src/gateway/scenes/slackThreadSource.d.ts +41 -0
  422. package/dist/src/gateway/scenes/slackThreadSource.js +168 -0
  423. package/dist/src/gateway/security/gateway-scopes.d.ts +1 -1
  424. package/dist/src/gateway/security/gateway-scopes.js +5 -0
  425. package/dist/src/gateway/server.js +1 -1
  426. package/dist/src/gateway/service/agent-runner.d.ts +1 -1
  427. package/dist/src/gateway/service/agent-runner.js +2 -2
  428. package/dist/src/gateway/service/app-context-access.d.ts +7 -0
  429. package/dist/src/gateway/service/app-context-access.js +70 -0
  430. package/dist/src/gateway/service/config-coordinator.js +4 -4
  431. package/dist/src/gateway/service/marketplace-service.js +3 -3
  432. package/dist/src/gateway/service/run-gateway-agent.js +13 -4
  433. package/dist/src/gateway/service/session-input-coordinator.d.ts +1 -1
  434. package/dist/src/gateway/service/session-input-coordinator.js +56 -17
  435. package/dist/src/gateway/service/sessions-api.d.ts +1 -0
  436. package/dist/src/gateway/service/sessions-api.js +4 -1
  437. package/dist/src/gateway/service/task-conversation-query-service.d.ts +3 -1
  438. package/dist/src/gateway/service/task-conversation-query-service.js +32 -3
  439. package/dist/src/gateway/service.d.ts +3 -0
  440. package/dist/src/gateway/service.js +130 -39
  441. package/dist/src/gateway/session-context-summary.js +3 -2
  442. package/dist/src/gateway/workspace-editor-path.js +2 -2
  443. package/dist/src/gateway/workspace-file-search.js +25 -12
  444. package/dist/src/heartbeat/index.js +1 -1
  445. package/dist/src/i18n/share-tool-bundle.js +2 -2
  446. package/dist/src/imports/runtime.js +1 -1
  447. package/dist/src/{tasks/task-outbox-dispatcher.d.ts → infra/domain-outbox-dispatcher.d.ts} +2 -2
  448. package/dist/src/{tasks/task-outbox-dispatcher.js → infra/domain-outbox-dispatcher.js} +10 -9
  449. package/dist/src/infra/gateway-processes.js +2 -2
  450. package/dist/src/infra/operation-context.d.ts +2 -0
  451. package/dist/src/infra/operation-context.js +16 -0
  452. package/dist/src/infra/path-env.js +3 -3
  453. package/dist/src/infra/update-global.js +10 -10
  454. package/dist/src/local-apps/capabilities/contracts.d.ts +2 -0
  455. package/dist/src/local-apps/capabilities/contracts.js +32 -0
  456. package/dist/src/local-apps/capabilities/read.d.ts +3 -0
  457. package/dist/src/local-apps/capabilities/read.js +48 -0
  458. package/dist/src/local-apps/capabilities/runtime.d.ts +16 -0
  459. package/dist/src/local-apps/capabilities/runtime.js +66 -0
  460. package/dist/src/local-apps/capabilities/write.d.ts +3 -0
  461. package/dist/src/local-apps/capabilities/write.js +35 -0
  462. package/dist/src/local-apps/release-lock.d.ts +2 -0
  463. package/dist/src/local-apps/release-lock.js +20 -0
  464. package/dist/src/local-apps/runtime-entry.d.ts +0 -2
  465. package/dist/src/local-apps/runtime-entry.js +1 -14
  466. package/dist/src/local-apps/scaffold.js +4 -1
  467. package/dist/src/local-apps/service.d.ts +24 -1
  468. package/dist/src/local-apps/service.js +187 -44
  469. package/dist/src/local-apps/store.js +0 -2
  470. package/dist/src/mcp/capability-server.d.ts +4 -0
  471. package/dist/src/mcp/capability-server.js +96 -0
  472. package/dist/src/mcp/channel-bridge.js +1 -1
  473. package/dist/src/mcp/gateway-http-client.d.ts +7 -0
  474. package/dist/src/mcp/gateway-http-client.js +27 -5
  475. package/dist/src/media-understanding/openai-compatible-audio.js +1 -1
  476. package/dist/src/notes/agent-context.js +4 -4
  477. package/dist/src/notes/capabilities/read.d.ts +3 -0
  478. package/dist/src/notes/capabilities/read.js +96 -0
  479. package/dist/src/notes/capabilities/write.d.ts +7 -0
  480. package/dist/src/notes/capabilities/write.js +152 -0
  481. package/dist/src/notes/index.js +1 -1
  482. package/dist/src/notes/service.d.ts +12 -4
  483. package/dist/src/notes/service.js +188 -175
  484. package/dist/src/notes/store.d.ts +14 -9
  485. package/dist/src/notes/store.js +81 -21
  486. package/dist/src/notifications/service.d.ts +1 -0
  487. package/dist/src/notifications/service.js +5 -0
  488. package/dist/src/projects/capabilities/read.d.ts +3 -0
  489. package/dist/src/projects/capabilities/read.js +81 -0
  490. package/dist/src/projects/capabilities/write.d.ts +9 -0
  491. package/dist/src/projects/capabilities/write.js +260 -0
  492. package/dist/src/projects/index.js +2 -2
  493. package/dist/src/projects/project-change-events.d.ts +2 -0
  494. package/dist/src/projects/project-change-events.js +18 -0
  495. package/dist/src/projects/project-service.d.ts +11 -0
  496. package/dist/src/projects/project-service.js +121 -42
  497. package/dist/src/projects/project-skill-service.js +2 -2
  498. package/dist/src/projects/project-store.js +12 -2
  499. package/dist/src/projects/project-workspace-creation.d.ts +3 -0
  500. package/dist/src/projects/project-workspace-creation.js +45 -0
  501. package/dist/src/projects/workspace-project.js +6 -0
  502. package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
  503. package/dist/src/providers/index.js +2 -2
  504. package/dist/src/providers/model-catalog-persistence.js +1 -1
  505. package/dist/src/providers/model-catalog-types.d.ts +2 -1
  506. package/dist/src/providers/model-reference-auditor.js +5 -5
  507. package/dist/src/providers/model-registry.js +1 -1
  508. package/dist/src/providers/model-supplements.js +13 -3
  509. package/dist/src/providers/presentation.js +3 -3
  510. package/dist/src/providers/register-runtime-providers.js +1 -1
  511. package/dist/src/providers/xopc-cloud-model-source.js +4 -2
  512. package/dist/src/realtime/runtime.js +4 -0
  513. package/dist/src/remote-access/exposure-manager.js +1 -1
  514. package/dist/src/scenes/capabilities/read.d.ts +3 -0
  515. package/dist/src/scenes/capabilities/read.js +187 -0
  516. package/dist/src/scenes/capabilities/write.d.ts +3 -0
  517. package/dist/src/scenes/capabilities/write.js +151 -0
  518. package/dist/src/scenes/contracts.d.ts +2 -105
  519. package/dist/src/scenes/contracts.js +3 -88
  520. package/dist/src/scenes/execution.d.ts +1 -1
  521. package/dist/src/scenes/httpServices.d.ts +2 -0
  522. package/dist/src/scenes/inbox.d.ts +1 -0
  523. package/dist/src/scenes/inbox.js +7 -7
  524. package/dist/src/scenes/preferences.d.ts +3 -24
  525. package/dist/src/scenes/preferences.js +8 -30
  526. package/dist/src/scenes/repository.d.ts +1 -0
  527. package/dist/src/scenes/repository.js +7 -3
  528. package/dist/src/scenes/resultNotifications.js +2 -2
  529. package/dist/src/scenes/schedule.d.ts +1 -8
  530. package/dist/src/scenes/schedule.js +3 -15
  531. package/dist/src/scenes/service.d.ts +6 -0
  532. package/dist/src/scenes/service.js +29 -25
  533. package/dist/src/scenes/taskFollowUp/agentExecutor.d.ts +36 -0
  534. package/dist/src/scenes/taskFollowUp/agentExecutor.js +149 -0
  535. package/dist/src/scenes/taskFollowUp/branchInventory.d.ts +38 -0
  536. package/dist/src/scenes/taskFollowUp/branchInventory.js +70 -0
  537. package/dist/src/scenes/taskFollowUp/contracts.d.ts +91 -0
  538. package/dist/src/scenes/taskFollowUp/contracts.js +100 -0
  539. package/dist/src/scenes/taskFollowUp/resources.d.ts +19 -0
  540. package/dist/src/scenes/taskFollowUp/resources.js +97 -0
  541. package/dist/src/scenes/taskFollowUp/service.d.ts +810 -0
  542. package/dist/src/scenes/taskFollowUp/service.js +710 -0
  543. package/dist/src/scenes/taskFollowUp/workspaceFingerprint.d.ts +2 -0
  544. package/dist/src/scenes/taskFollowUp/workspaceFingerprint.js +46 -0
  545. package/dist/src/scenes/templates.d.ts +2 -2
  546. package/dist/src/scenes/templates.js +1 -1
  547. package/dist/src/session/client-history.d.ts +2 -1
  548. package/dist/src/session/client-history.js +3 -2
  549. package/dist/src/session/index.js +2 -2
  550. package/dist/src/session/session-find.d.ts +17 -0
  551. package/dist/src/session/session-find.js +56 -0
  552. package/dist/src/session/session-title.js +1 -1
  553. package/dist/src/session/store.d.ts +4 -0
  554. package/dist/src/session/store.js +46 -10
  555. package/dist/src/session/thinking-resolve.js +1 -1
  556. package/dist/src/share/note-share-revocation.d.ts +3 -0
  557. package/dist/src/share/note-share-revocation.js +26 -0
  558. package/dist/src/share/share-store.js +1 -1
  559. package/dist/src/share/share-thumbnail.js +1 -1
  560. package/dist/src/share/site-proxy.js +1 -1
  561. package/dist/src/share/site-share-store.js +1 -1
  562. package/dist/src/storage/sqlite/connection.js +9 -9
  563. package/dist/src/storage/sqlite/endpoint-tool-invocation-repository.d.ts +15 -1
  564. package/dist/src/storage/sqlite/endpoint-tool-invocation-repository.js +39 -6
  565. package/dist/src/storage/sqlite/index.d.ts +1 -1
  566. package/dist/src/storage/sqlite/index.js +2 -2
  567. package/dist/src/storage/sqlite/migrations/190_scene_development.sql +37 -0
  568. package/dist/src/storage/sqlite/migrations/191_scene_task_follow_up.sql +27 -0
  569. package/dist/src/storage/sqlite/migrations/192_capability_operations.sql +20 -0
  570. package/dist/src/storage/sqlite/migrations/193_note_file_cleanup.sql +8 -0
  571. package/dist/src/storage/sqlite/migrations/194_capability_external_outcomes.sql +11 -0
  572. package/dist/src/storage/sqlite/migrations/195_automation_deleted_revisions.sql +4 -0
  573. package/dist/src/storage/sqlite/migrations/196_automation_run_requests.sql +23 -0
  574. package/dist/src/storage/sqlite/migrations/197_note_deletion_cleanup.sql +8 -0
  575. package/dist/src/storage/sqlite/migrations/198_project_workspace_creation.sql +7 -0
  576. package/dist/src/storage/sqlite/migrations/199_scene_resource_events.sql +488 -0
  577. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  578. package/dist/src/storage/sqlite/migrations/runner.js +6 -3
  579. package/dist/src/storage/sqlite/schema.js +1 -1
  580. package/dist/src/storage/sqlite/transaction.d.ts +5 -0
  581. package/dist/src/storage/sqlite/transaction.js +34 -3
  582. package/dist/src/tasks/capabilities/management.d.ts +195 -0
  583. package/dist/src/tasks/capabilities/management.js +111 -0
  584. package/dist/src/tasks/capabilities/read.d.ts +2 -0
  585. package/dist/src/tasks/capabilities/read.js +141 -0
  586. package/dist/src/tasks/capabilities/relations.d.ts +204 -0
  587. package/dist/src/tasks/capabilities/relations.js +140 -0
  588. package/dist/src/tasks/capabilities/runs.d.ts +2 -0
  589. package/dist/src/tasks/capabilities/runs.js +89 -0
  590. package/dist/src/tasks/capabilities/write.d.ts +207 -0
  591. package/dist/src/tasks/capabilities/write.js +107 -0
  592. package/dist/src/tasks/execution-context.js +1 -1
  593. package/dist/src/tasks/home-query-service.js +5 -4
  594. package/dist/src/tasks/index.d.ts +0 -1
  595. package/dist/src/tasks/index.js +9 -9
  596. package/dist/src/tasks/project-operating-view-service.js +2 -1
  597. package/dist/src/tasks/task-application-service.d.ts +1 -0
  598. package/dist/src/tasks/task-application-service.js +4 -3
  599. package/dist/src/tasks/task-change-events.js +5 -3
  600. package/dist/src/tasks/task-context-assembler.js +3 -2
  601. package/dist/src/tasks/task-deletion-service.js +2 -1
  602. package/dist/src/tasks/task-dependency-service.js +2 -1
  603. package/dist/src/tasks/task-handoff-service.js +3 -2
  604. package/dist/src/tasks/task-read-model-projector.js +2 -1
  605. package/dist/src/tasks/task-repository.d.ts +12 -7
  606. package/dist/src/tasks/task-repository.js +175 -154
  607. package/dist/src/tasks/task-run-coordinator.js +2 -1
  608. package/dist/src/tasks/task-run-dispatcher.js +2 -1
  609. package/dist/src/tasks/task-run-repository.d.ts +1 -0
  610. package/dist/src/tasks/task-run-repository.js +29 -14
  611. package/dist/src/tasks/task-signal-service.js +2 -1
  612. package/dist/src/tui/backends/embedded-backend.js +10 -10
  613. package/dist/src/tui/backends/gateway-realtime-backend.js +2 -2
  614. package/dist/src/tui/extension-host/load-extensions.js +1 -1
  615. package/dist/src/tui/tui-command-formatters.js +1 -1
  616. package/dist/src/tui/tui-commands.js +6 -6
  617. package/dist/src/tui/tui-picker-overlay.js +1 -1
  618. package/dist/src/tui/tui-skills-autocomplete.js +1 -1
  619. package/dist/src/tui/tui-startup-resources.js +4 -4
  620. package/dist/src/tui/tui.js +3 -3
  621. package/dist/src/tunnel/gateway-lifecycle.js +1 -1
  622. package/dist/src/user-context/config.d.ts +13 -0
  623. package/dist/src/user-context/config.js +2 -0
  624. package/dist/src/voice/local/runtime-worker.js +1 -1
  625. package/dist/src/voice/platform-catalog.d.ts +1 -1
  626. package/dist/src/voice/realtime/memory-context.js +3 -3
  627. package/dist/src/voice/realtime/runtime.js +3 -3
  628. package/dist/src/voice/stt/index.js +2 -2
  629. package/dist/src/voice/stt/preflight.js +1 -1
  630. package/dist/src/voice/stt/providers/alibaba-transcription.js +1 -1
  631. package/dist/src/voice/stt/providers/local-transcription.js +1 -1
  632. package/dist/src/voice/stt/providers/xopc-cloud-transcription.js +1 -1
  633. package/dist/src/voice/stt/transcribe-core.js +1 -1
  634. package/dist/src/voice/tts/audio.js +1 -1
  635. package/dist/src/voice/tts/factory.js +1 -1
  636. package/dist/src/voice/tts/index.js +1 -1
  637. package/dist/src/voice/tts/payload.js +1 -1
  638. package/dist/src/voice/tts/providers/xopc-cloud-speech.js +1 -1
  639. package/dist/src/work-discovery/incremental-repository.js +1 -1
  640. package/dist/src/work-discovery/index.js +1 -1
  641. package/dist/src/work-discovery/repository.d.ts +1 -1
  642. package/dist/src/work-discovery/repository.js +3 -2
  643. package/dist/src/work-discovery/service.d.ts +4 -0
  644. package/dist/src/work-discovery/service.js +40 -15
  645. package/dist/src/workflows/context/workflow-context.js +3 -2
  646. package/dist/src/workflows/service/workflow-run-service.js +7 -6
  647. package/dist/src/workflows/service/workflow-session-bridge.js +1 -1
  648. package/package.json +8 -4
  649. package/skills/THIRD_PARTY_NOTICES.md +2 -2
  650. package/skills/documents/xlsx/SKILL.md +5 -0
  651. package/skills/engineering/build-xopc-local-app/SKILL.md +2 -0
  652. package/skills/tools/find-skills/SKILL.md +3 -0
  653. package/dist/gateway/static/root/assets/activity-store-CS_SAPwP.js +0 -1
  654. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-9w_YVThL.js +0 -1
  655. package/dist/gateway/static/root/assets/agents-Bspu1pT2.js +0 -1
  656. package/dist/gateway/static/root/assets/appearance-settings-Jgvx-RKL.js +0 -1
  657. package/dist/gateway/static/root/assets/apps-page-403o57-3.js +0 -1
  658. package/dist/gateway/static/root/assets/automations-workspace-Dpju5KT_.js +0 -7
  659. package/dist/gateway/static/root/assets/browser-settings-page-C0HJrpr1.js +0 -3
  660. package/dist/gateway/static/root/assets/capabilities-settings-panel-BanM86OX.js +0 -8
  661. package/dist/gateway/static/root/assets/channels-settings-Bhh0F9pO.js +0 -1
  662. package/dist/gateway/static/root/assets/connectors-page-BTqjm6eD.js +0 -2
  663. package/dist/gateway/static/root/assets/desktop-pet-settings-BI_sQTR_.js +0 -1
  664. package/dist/gateway/static/root/assets/device-pairing-wizard-BoPCEIm5.js +0 -1
  665. package/dist/gateway/static/root/assets/files-Be5viEFY.js +0 -1
  666. package/dist/gateway/static/root/assets/gateway-realtime-mpOw3R4d.js +0 -1
  667. package/dist/gateway/static/root/assets/gateway-realtime-store-Z-ErSgkD.js +0 -1
  668. package/dist/gateway/static/root/assets/gateway-settings-Bq82yXVh.js +0 -1
  669. package/dist/gateway/static/root/assets/home-page-BD1v6Uee.js +0 -1
  670. package/dist/gateway/static/root/assets/index-Ah5XDhOL.js +0 -79
  671. package/dist/gateway/static/root/assets/index-CV5b1pD1.css +0 -1
  672. package/dist/gateway/static/root/assets/local-app-workbench-page-BF8x3bgh.js +0 -2
  673. package/dist/gateway/static/root/assets/logs-page-B4vMUM7D.js +0 -2
  674. package/dist/gateway/static/root/assets/management-settings-Cg0UjJpy.js +0 -1
  675. package/dist/gateway/static/root/assets/messages-CRH2my19.js +0 -3
  676. package/dist/gateway/static/root/assets/note-detail-panel-CWVIGctd.js +0 -5
  677. package/dist/gateway/static/root/assets/notes-page-CcTzMI1K.js +0 -8
  678. package/dist/gateway/static/root/assets/product-delivery-CrAI8ZEa.js +0 -1
  679. package/dist/gateway/static/root/assets/project-detail-page-BNYoV9Ac.js +0 -1
  680. package/dist/gateway/static/root/assets/projects-page-CcKnYQqm.js +0 -1
  681. package/dist/gateway/static/root/assets/remote-access-hub-HIvwD5Xn.js +0 -1
  682. package/dist/gateway/static/root/assets/runtime-tools-settings-panel-CFE2oX_l.js +0 -5
  683. package/dist/gateway/static/root/assets/scenes-page-BGKdg4uS.js +0 -1
  684. package/dist/gateway/static/root/assets/schemas-BaskVM5g.js +0 -64
  685. package/dist/gateway/static/root/assets/sessions-page-tn99saMj.js +0 -1
  686. package/dist/gateway/static/root/assets/settings-advanced-gate-Cx_uvwqz.js +0 -1
  687. package/dist/gateway/static/root/assets/setup-status-panel-1kYYg3BH.js +0 -1
  688. package/dist/gateway/static/root/assets/shares-settings-Du7BfwId.js +0 -1
  689. package/dist/gateway/static/root/assets/skill-reload-api-BMhhXxRZ.js +0 -1
  690. package/dist/gateway/static/root/assets/task-detail-page-vFn3xdlZ.js +0 -1
  691. package/dist/gateway/static/root/assets/theme-store-DdURyZ1M.js +0 -1
  692. package/dist/gateway/static/root/assets/user-model-page-uK9sxPUH.js +0 -2
  693. package/dist/gateway/static/root/assets/workflows-page-DIyd5AC9.js +0 -6
  694. package/skills/creative/algorithmic-art/SKILL.md +0 -44
  695. package/skills/creative/algorithmic-art/templates/generator-template.js +0 -27
  696. package/skills/creative/algorithmic-art/templates/viewer.html +0 -27
@@ -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{c as i,d as a,f as o,g as s,l as c,m as l,t as u,u as d}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as f}from"./popover-select-B-GDnZO9.js";import{t as p}from"./x-B_N4OPjy.js";import{a as m,c as h,n as g,r as _}from"./locale-store-vZTDIqJB.js";import{a as v,i as y,n as b,o as x,r as S,s as C,t as w}from"./dist-BGTk37IG.js";import{a as T,i as E,n as D}from"./vendor-swr-BIWyz7Rc.js";import{t as O}from"./button-CS04eWY9.js";import{t as k}from"./skeleton-BwbyijEw.js";import{Bt as A,Cc as j,Ml as M,Nu as N,Qi as P,Tu as ee,Yu as te,do as F,hc as ne,jc as I}from"./index-Ah5XDhOL.js";var L=e(t(),1),R=n(),z=e=>m(_(`/api/scenes${e}`)),B=(e,t,n,r)=>m(_(`/api/scenes${e}`),{method:t,body:n===void 0?void 0:JSON.stringify(n),headers:r?{"Idempotency-Key":r}:void 0});function V(e,t){let n=e?.status;return n===401?t?`登录已失效,请重新登录后查看场景。`:`Your session expired. Sign in again to view scenes.`:n===503?t?`场景服务暂不可用,请检查服务状态后重试。`:`The scene service is unavailable. Check the Gateway and retry.`:n===409?t?`内容已被更新,请刷新后重新确认。`:`This content changed. Refresh and review it before trying again.`:(e?.body?.missing)?.some(e=>e.startsWith(`model_`))?t?`请先在模型设置中选择可用模型并配置凭据,然后重试。`:`Choose an available model and configure its credentials in model settings, then retry.`:n===422?t?`设置或授权不完整,请检查数据来源和范围。`:`Setup or permission is incomplete. Check the source and scope.`:n===404?t?`找不到这个场景或结果,请返回场景列表。`:`Scene or result not found. Return to the scenes list.`:t?`操作未完成,请检查连接后重试。你的输入仍保留在当前页面。`:`Could not finish. Check your connection and retry. Your input is still on this page.`}var H=r();function re(e){let t=(0,R.c)(49),{activationId:n,zh:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={refreshInterval:15e3},t[0]=i):i=t[0];let a=E(`/diagnostics`,z,i),o,s,c,l,d,f,p,m,h,g,_;if(t[1]!==n||t[2]!==a.data||t[3]!==r){c=Symbol.for(`react.early_return_sentinel`);bb0:{let e=a.data?.activations.find(e=>e.id===n);if(!e){c=null;break bb0}let i;t[15]===r?i=t[16]:(i=e=>e==null?r?`未设置`:`Not scheduled`:new Date(e).toLocaleString(r?`zh-CN`:`en`),t[15]=r,t[16]=i);let v=i,y;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(y={needs_permission:[`邮件授权已失效,请重新连接账号。`,`Mail permission expired. Reconnect the account.`],source_rate_limited:[`邮件服务暂时限流,将自动重试。`,`Mail service rate limited. A retry is scheduled.`],source_timeout:[`读取邮件超时,将自动重试。`,`Mail read timed out. A retry is scheduled.`],unchanged_result:[`资料未变化,已保留原成果和反馈。`,`Context unchanged. The existing result and feedback were preserved.`],source_not_ready:[`来源暂不可用,请检查连接器授权;稍后会重试。`,`Source unavailable. Check connector access; a retry is scheduled.`],daily_budget:[`已达每日模型调用上限,将在预算恢复后继续。`,`Daily model limit reached. Checks resume after the budget resets.`],execution_failed:[`检查失败,请检查模型凭据和服务连接,再点“现在检查”。`,`Check failed. Verify model credentials and connectivity, then check again.`],invalid_model_result:[`模型返回的格式不符合此场景要求,结果未发布;请重试或更换模型。`,`The model returned an unsupported result. Nothing was published; retry or choose another model.`],empty_input:[`请先填写安排和约束。`,`Provide arrangements and constraints first.`],source_changed:[`来源已变化,旧草稿未发布;可重新检查。`,`Source changed. The stale draft was withheld; check again.`],execution_aborted:[`检查已中断,可在服务恢复后重新检查。`,`Check interrupted. Retry after the service resumes.`]},t[17]=y):y=t[17];let b=y,x=[e.next_schedule_at,e.next_deadline_check_at,e.retry_at].filter(ie),S=e.source_reason??e.last_reason;l=`space-y-2 rounded-xl border border-edge p-4 text-sm text-fg-muted`,d=(0,H.jsxs)(`p`,{children:[r?`最近发起检查`:`Last check started`,`: `,e.last_check_at==null?r?`尚未检查`:`Not checked yet`:v(e.last_check_at)]});let C=r?`下次定时检查`:`Next scheduled check`,w=e.status!==`active`||a.data?.checksPaused?r?`当前不会自动检查`:`Automatic checks inactive`:x.length?`${Math.min(...x)<=Date.now()?r?`等待执行,原定 `:`Pending, scheduled for `:``}${v(Math.min(...x))}`:r?`暂无待执行检查`:`No check scheduled`;t[18]!==C||t[19]!==w?(f=(0,H.jsxs)(`p`,{children:[C,`: `,w]}),t[18]=C,t[19]=w,t[20]=f):f=t[20],p=e.deadline_at!=null&&(0,H.jsxs)(`p`,{children:[r?`邮件跟进截止时间`:`Mail follow-up deadline`,`: `,v(e.deadline_at)]}),m=e.source_reason&&e.source_attempt_at!=null&&(0,H.jsxs)(`p`,{children:[r?`最近尝试读取邮件`:`Last mail read attempt`,`: `,v(e.source_attempt_at),` · `,r?`连续失败`:`Consecutive failures`,`: `,e.source_failures]}),h=e.source_reason&&(0,H.jsx)(u,{to:`/connectors`,className:`inline-block text-accent underline`,children:r?`检查连接器授权`:`Check connector access`}),g=e.source_success_at!=null&&(0,H.jsxs)(`p`,{children:[r?`最近成功读取邮件`:`Last successful mail read`,`: `,v(e.source_success_at)]}),_=S&&b[S]&&(0,H.jsx)(`p`,{role:`status`,children:b[S][+!r]});let T=r?`当前场景模型`:`Current scene model`,E=a.data.currentModel??(r?`配置不可用`:`Configuration unavailable`);t[21]!==T||t[22]!==E?(o=(0,H.jsxs)(`p`,{children:[T,`: `,E]}),t[21]=T,t[22]=E,t[23]=o):o=t[23],s=e.source_reason&&e.status===`active`&&!a.data?.checksPaused&&e.source_retry_at!=null&&(0,H.jsxs)(`p`,{children:[r?`来源重试时间`:`Source retry`,`: `,v(e.source_retry_at)]})}t[1]=n,t[2]=a.data,t[3]=r,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=d,t[9]=f,t[10]=p,t[11]=m,t[12]=h,t[13]=g,t[14]=_}else o=t[4],s=t[5],c=t[6],l=t[7],d=t[8],f=t[9],p=t[10],m=t[11],h=t[12],g=t[13],_=t[14];if(c!==Symbol.for(`react.early_return_sentinel`))return c;let v=r?`所有场景待检查`:`Pending checks across scenes`,y;t[24]!==a.data.pendingChecks||t[25]!==v?(y=(0,H.jsxs)(`p`,{children:[v,`: `,a.data.pendingChecks]}),t[24]=a.data.pendingChecks,t[25]=v,t[26]=y):y=t[26];let b=r?`最近 7 天所有场景的模型用量`:`Model usage across scenes in the last 7 days`,x=a.data.lastSevenDays.modelCalls,S=r?`次调用`:`calls`,C=a.data.lastSevenDays.tokens,w=r?`估算费用`:`estimated cost`,T;t[27]===a.data.lastSevenDays.estimatedCost?T=t[28]:(T=a.data.lastSevenDays.estimatedCost.toFixed(4),t[27]=a.data.lastSevenDays.estimatedCost,t[28]=T);let D;t[29]!==a.data.lastSevenDays.modelCalls||t[30]!==a.data.lastSevenDays.tokens||t[31]!==b||t[32]!==S||t[33]!==w||t[34]!==T?(D=(0,H.jsxs)(`p`,{children:[b,`: `,x,` `,S,` · `,C,` tokens · `,w,` $`,T]}),t[29]=a.data.lastSevenDays.modelCalls,t[30]=a.data.lastSevenDays.tokens,t[31]=b,t[32]=S,t[33]=w,t[34]=T,t[35]=D):D=t[35];let O;return t[36]!==o||t[37]!==s||t[38]!==y||t[39]!==l||t[40]!==D||t[41]!==d||t[42]!==f||t[43]!==p||t[44]!==m||t[45]!==h||t[46]!==g||t[47]!==_?(O=(0,H.jsxs)(`section`,{className:l,children:[d,f,p,m,h,g,_,o,s,y,D]}),t[36]=o,t[37]=s,t[38]=y,t[39]=l,t[40]=D,t[41]=d,t[42]=f,t[43]=p,t[44]=m,t[45]=h,t[46]=g,t[47]=_,t[48]=O):O=t[48],O}function ie(e){return e!=null}function U(e){let t=(0,R.c)(13),{dirty:n,zh:r}=e,a;t[0]===n?a=t[1]:(a=e=>{n&&(e.preventDefault(),e.returnValue=``)},t[0]=n,t[1]=a),i(a);let o=c(n),s=o.state===`blocked`,l=r?`放弃未保存的更改?`:`Discard unsaved changes?`,u=r?`当前内容尚未保存,现在离开将丢失这些更改。`:`Your changes have not been saved. Leaving now will discard them.`,d=r?`放弃并离开`:`Discard and leave`,f=r?`继续编辑`:`Keep editing`,p,m;t[2]===o?(p=t[3],m=t[4]):(p=()=>{o.state===`blocked`&&o.proceed()},m=()=>{o.state===`blocked`&&o.reset()},t[2]=o,t[3]=p,t[4]=m);let h;return t[5]!==s||t[6]!==l||t[7]!==u||t[8]!==d||t[9]!==f||t[10]!==p||t[11]!==m?(h=(0,H.jsx)(P,{open:s,title:l,description:u,confirmLabel:d,cancelLabel:f,destructive:!0,overlayClassName:`z-[100]`,contentClassName:`z-[101]`,onConfirm:p,onCancel:m}),t[5]=s,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=p,t[11]=m,t[12]=h):h=t[12],h}function ae({zh:e}){let[t,n]=(0,L.useState)(!1),[r,i]=(0,L.useState)(!1),[a,o]=(0,L.useState)(),[s,c]=(0,L.useState)(!1);async function l(){n(!0),o(void 0),c(!1);try{if(await Notification.requestPermission()!==`granted`){c(!0);return}let{publicKey:t}=await B(`/browser/prepare`,`POST`);await navigator.serviceWorker.register(`/notification-sw.js`);let n=await navigator.serviceWorker.ready,r=Uint8Array.from(atob(t.replace(/-/g,`+`).replace(/_/g,`/`)),e=>e.charCodeAt(0)),a=await n.pushManager.getSubscription(),o=a?.options.applicationServerKey;a&&(!o||!new Uint8Array(o).every((e,t)=>e===r[t])||o.byteLength!==r.byteLength)&&(await a.unsubscribe(),a=null),a??=await n.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:r}),await B(`/browser/subscriptions`,`POST`,{...a.toJSON(),expirationTime:a.expirationTime,language:e?`zh`:`en`}),i(!0)}catch(e){o(e)}finally{n(!1)}}let u=A()&&`PushManager`in window;return(0,H.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-3`,children:[(0,H.jsx)(O,{disabled:t||!u,onClick:()=>void l(),children:r?e?`刷新此浏览器提醒订阅`:`Refresh this browser subscription`:e?`开启页面关闭后的浏览器提醒`:`Enable reminders when this page is closed`}),r&&(0,H.jsx)(`p`,{role:`status`,children:e?`此浏览器已订阅。服务需持续运行;送达取决于浏览器和系统权限。`:`Subscribed. The Gateway must remain running; delivery depends on browser and system permissions.`}),(!u||s)&&(0,H.jsx)(`p`,{className:`text-fg-muted`,children:e?`当前环境或通知权限不支持后台提醒。成果仍会保留在场景收件箱;可在支持推送的 HTTPS 浏览器中开启。`:`Background reminders are unavailable here. Results remain in your scene inbox. Use a push-capable HTTPS browser and allow notifications.`}),a!=null&&(0,H.jsx)(`p`,{role:`alert`,className:`text-danger`,children:V(a,e)})]})}function oe(e){let t=(0,R.c)(23),{zh:n,open:r,onOpenChange:i,onCloseAutoFocus:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,H.jsx)(v,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),t[0]=o):o=t[0];let s;t[1]===a?s=t[2]:(s=e=>{e.preventDefault(),a()},t[1]=a,t[2]=s);let c=n?`检查与提醒设置`:`Checks and reminders`,l;t[3]===c?l=t[4]:(l=(0,H.jsx)(C,{className:`text-base font-semibold text-fg`,children:c}),t[3]=c,t[4]=l);let u=n?`适用于所有场景,设置更改后自动保存。`:`Applies to all scenes. Changes are saved automatically.`,d;t[5]===u?d=t[6]:(d=(0,H.jsx)(y,{className:`mt-1 text-sm text-fg-muted`,children:u}),t[5]=u,t[6]=d);let f;t[7]!==l||t[8]!==d?(f=(0,H.jsxs)(`div`,{className:`shrink-0 border-b border-edge p-4 sm:px-6`,children:[l,d]}),t[7]=l,t[8]=d,t[9]=f):f=t[9];let p;t[10]===n?p=t[11]:(p=(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4 sm:p-6`,children:(0,H.jsx)(se,{zh:n})}),t[10]=n,t[11]=p);let m=n?`关闭`:`Close`,h;t[12]===m?h=t[13]:(h=(0,H.jsx)(`div`,{className:`flex shrink-0 justify-end border-t border-edge p-4 sm:px-6`,children:(0,H.jsx)(b,{asChild:!0,children:(0,H.jsx)(O,{type:`button`,variant:`secondary`,children:m})})}),t[12]=m,t[13]=h);let g;t[14]!==h||t[15]!==s||t[16]!==f||t[17]!==p?(g=(0,H.jsxs)(x,{children:[o,(0,H.jsxs)(S,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(40rem,calc(100dvh-2rem))] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float focus:outline-none`,onCloseAutoFocus:s,children:[f,p,h]})]}),t[14]=h,t[15]=s,t[16]=f,t[17]=p,t[18]=g):g=t[18];let _;return t[19]!==i||t[20]!==r||t[21]!==g?(_=(0,H.jsx)(w,{open:r,onOpenChange:i,children:g}),t[19]=i,t[20]=r,t[21]=g,t[22]=_):_=t[22],_}function se({zh:e}){let t=E(`/preferences`,z),[n,r]=(0,L.useState)(!1),[i,a]=(0,L.useState)();async function o(e){if(!(!t.data||n)){r(!0),a(void 0);try{let n=await B(`/preferences`,`PATCH`,{...e,expectedRevision:t.data.revision});await t.mutate(n,!1)}catch(e){a(e),await t.mutate()}finally{r(!1)}}}if(!t.data)return t.error?(0,H.jsx)(`p`,{role:`alert`,children:V(t.error,e)}):(0,H.jsx)(k,{className:`h-32 w-full`});let s=t.data,c=`w-24 rounded-md border border-edge bg-surface-panel px-2 py-1 text-fg`;return(0,H.jsxs)(`div`,{className:`space-y-4 text-sm`,children:[(0,H.jsx)(`p`,{className:`text-fg-muted`,children:e?`设备休眠或服务关闭时不会检查;服务恢复后继续。草稿不会自动发送。`:`Checks require the device and Gateway to stay running. Drafts are never sent automatically.`}),[[`checksPaused`,e?`暂停所有检查`:`Pause all checks`],[`notificationsMuted`,e?`静音提醒(继续检查并保留成果)`:`Mute reminders (continue checks and keep results)`],[`suppressWhileViewing`,e?`查看成果时不重复提醒`:`Avoid reminders while viewing a result`],[`digestEnabled`,e?`汇总为每日摘要`:`Use a daily digest`]].map(([e,t])=>(0,H.jsxs)(`label`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:s[e],disabled:n,onChange:t=>void o({[e]:t.target.checked})}),t]},e)),(0,H.jsxs)(`label`,{className:`flex flex-wrap items-center gap-2`,children:[e?`时区`:`Timezone`,(0,H.jsx)(`input`,{defaultValue:s.timezone,disabled:n,className:`${c} w-48`,onBlur:e=>{e.target.value!==s.timezone&&o({timezone:e.target.value})}},s.timezone)]}),[[`quietStartHour`,e?`免打扰开始(小时)`:`Quiet hours start`,23],[`quietEndHour`,e?`免打扰结束(小时)`:`Quiet hours end`,23],[`dailyNotificationLimit`,e?`每日提醒上限`:`Daily reminder limit`,30],...s.digestEnabled?[[`digestHour`,e?`摘要时间(小时)`:`Digest hour`,23],[`digestMinute`,e?`摘要时间(分钟)`:`Digest minute`,59]]:[]].map(([e,t,r])=>(0,H.jsxs)(`label`,{className:`flex flex-wrap items-center gap-2`,children:[t,(0,H.jsx)(`input`,{type:`number`,min:0,max:r,defaultValue:s[e],disabled:n,className:c,onBlur:t=>{let n=Number(t.target.value);t.target.value&&Number.isInteger(n)&&n>=0&&n<=r&&n!==s[e]&&o({[e]:n})}},s[e])]},e)),(0,H.jsxs)(`label`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`input`,{type:`checkbox`,disabled:n,checked:s.preferredChannel===`browser`,onChange:e=>void o({preferredChannel:e.target.checked?`browser`:`in_app`})}),e?`允许浏览器后台提醒`:`Allow background browser reminders`]}),(0,H.jsx)(ae,{zh:e}),i!=null&&(0,H.jsx)(`p`,{role:`alert`,className:`text-danger`,children:V(i,e)}),s.checksPausedUntil&&(0,H.jsx)(O,{disabled:n,onClick:()=>void o({checksPausedUntil:null}),children:e?`取消定时暂停`:`Clear timed pause`})]})}function W({item:e,zh:t,onChange:n}){let r=(0,L.useRef)(null);(0,L.useEffect)(()=>{let t=crypto.randomUUID(),n=!1,i=()=>{B(`/presence`,`POST`,{clientId:t,surface:`web`,presentationId:e.id,visible:n&&document.visibilityState===`visible`&&document.hasFocus()}).catch(()=>void 0)},a=new IntersectionObserver(([e])=>{n=e.isIntersecting,i()},{threshold:.5});r.current&&a.observe(r.current);let o=setInterval(i,2e4);return document.addEventListener(`visibilitychange`,i),window.addEventListener(`focus`,i),window.addEventListener(`blur`,i),()=>{a.disconnect(),clearInterval(o),document.removeEventListener(`visibilitychange`,i),window.removeEventListener(`focus`,i),window.removeEventListener(`blur`,i),n=!1,i()}},[e.id]);let[i,a]=(0,L.useState)(!1),o=`/presentations/${encodeURIComponent(e.id)}`,s=E(e.readOnly?null:`${o}/feedback`,z),{mutate:c}=T(),[l,u]=(0,L.useState)(!1),[d,f]=(0,L.useState)(),p=async e=>{if(s.data){u(!0),f(void 0);try{let t=s.data.feedback?.note??``,n=await B(`${o}/feedback`,`POST`,{expectedRevision:s.data.feedback?.revision??0,rating:e});await s.mutate({feedback:{rating:e,note:t,revision:n.revision}},{revalidate:!1}),c(`/metrics`)}catch(e){f(e),s.mutate()}finally{u(!1)}}},m=async()=>{u(!0),f(void 0);try{await B(o,`PATCH`,{read:e.status!==`read`}),n()}catch(e){f(e)}finally{u(!1)}};return(0,H.jsxs)(`article`,{ref:r,className:`space-y-3 rounded-xl border border-edge bg-surface-panel p-4 sm:p-6`,children:[e.createdAt!=null&&(0,H.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[t?`生成于`:`Generated`,` `,new Date(e.createdAt).toLocaleString(t?`zh-CN`:`en`)]}),e.sourceHealth?.reason&&(0,H.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t?`邮件来源暂不可用,这份成果尚未核实最新邮件,请检查连接器授权后重试。`:`Mail is unavailable. This result has not been checked against the latest messages. Check connector access and retry.`}),(0,H.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm leading-relaxed text-fg`,children:e.content.summary}),(0,H.jsx)(O,{variant:`ghost`,onClick:()=>{navigator.clipboard.writeText(e.content.summary).then(()=>a(!0)).catch(f)},children:i?t?`已复制`:`Copied`:t?`复制成果`:`Copy result`}),(0,H.jsx)(`div`,{className:`space-y-1 text-xs text-fg-muted`,children:e.sources?.length?e.sources.map(e=>(0,H.jsxs)(`p`,{children:[(0,H.jsx)(`a`,{className:`text-accent underline`,href:e.href,target:e.kind===`mail`?`_blank`:void 0,rel:`noreferrer`,children:e.kind===`notes`?t?`查看场景资料`:`View scene notes`:e.title||(t?`查看原邮件`:`View original email`)}),e.sender&&` · ${e.sender}`]},e.href)):(0,H.jsx)(`p`,{children:t?`来源详情暂不可用`:`Source details unavailable`})}),e.readOnly?(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`这份成果已结束、过期或延后,仅供查阅。`:`This result is resolved, expired or snoozed, and is available for reference.`}):(0,H.jsxs)(H.Fragment,{children:[s.error?(0,H.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[V(s.error,t),(0,H.jsx)(O,{onClick:()=>void s.mutate(),children:t?`重新加载`:`Reload`})]}):s.data?(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[`useful`,`not_useful`].map(e=>(0,H.jsx)(O,{disabled:l,"aria-pressed":s.data?.feedback?.rating===e,onClick:()=>void p(e),children:e===`useful`?t?`对我有帮助`:`Helpful`:t?`没有帮助`:`Not helpful`},e))}):(0,H.jsx)(k,{className:`h-11 w-48`}),(0,H.jsx)(O,{disabled:l,variant:`ghost`,onClick:()=>void m(),children:e.status===`read`?t?`标为未读`:`Mark unread`:t?`标为已读`:`Mark read`})]}),!!d&&(0,H.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:V(d,t)})]})}var G=`min-h-11 w-full rounded-md border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`;function K({activation:e,zh:t,onDirty:n,onChanged:r}){let i=`/activations/${e.id}/schedules`,a=E(i,z),o=E(`/templates/${e.templateKey}/versions/${e.templateVersion}`,z),[s,c]=(0,L.useState)(null),[l,u]=(0,L.useState)(),d=()=>{a.mutate(),o.mutate()};if(a.error||o.error)return(0,H.jsxs)(`div`,{role:`alert`,children:[(0,H.jsx)(`p`,{children:V(a.error??o.error,t)}),(0,H.jsx)(O,{onClick:d,children:t?`重新加载`:`Reload`})]});if(!a.data||!o.data)return(0,H.jsx)(k,{className:`h-32 w-full`});let f=o.data.template.triggers.find(e=>e.type===`schedule`);if(!f)return null;let p=a.data.schedules.find(e=>e.triggerKey===f.id);return(0,H.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-edge p-4 sm:p-6`,children:[(0,H.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t?`检查时间`:`Review schedule`}),p?(0,H.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[e.status===`active`?t?`下次检查:`:`Next check: `:t?`当前不会定时检查。已保存时间:`:`Not scheduling while inactive. Saved time: `,new Intl.DateTimeFormat(t?`zh-CN`:`en`,{dateStyle:`medium`,timeStyle:`short`,timeZone:p.schedule.timeZone}).format(p.nextDueAt),` · `,p.schedule.timeZone]}):(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`尚未设置定时检查。只有你点“现在检查”才会执行周期复盘。`:`No recurring schedule yet. Use Check now for a manual review.`}),!!l&&(0,H.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:V(l,t)}),s?(0,H.jsx)(ce,{initial:s.cursor,zh:t,onCancel:()=>{c(null),n(!1)},onSave:async e=>{u(void 0);try{await B(`${i}/${encodeURIComponent(f.id)}`,`PATCH`,{expectedRevision:s.cursor?.revision??0,schedule:e}),c(null),n(!1),await a.mutate(),r?.()}catch(e){throw u(e),e}}}):(0,H.jsx)(O,{disabled:e.status!==`active`,onClick:()=>{u(void 0),c({cursor:p}),n(!0)},children:p?t?`修改时间`:`Edit schedule`:t?`设置时间`:`Set schedule`}),(0,H.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t?`没有值得关注的新变化时保持安静。暂停场景会停止定时检查。`:`Stays quiet when there is no useful change. Pause the scene to stop scheduled checks.`})]})}function ce({initial:e,zh:t,onSave:n,onCancel:r}){let[i,a]=(0,L.useState)(e?.schedule.weekdays??[0]),[o,s]=(0,L.useState)(`${String(e?.schedule.hour??18).padStart(2,`0`)}:${String(e?.schedule.minute??0).padStart(2,`0`)}`),[c,l]=(0,L.useState)(e?.schedule.timeZone??Intl.DateTimeFormat().resolvedOptions().timeZone),[u,d]=(0,L.useState)(!1),[f,p]=(0,L.useState)(!1),m=async e=>{e.preventDefault();try{new Intl.DateTimeFormat(`en`,{timeZone:c})}catch{p(!0);return}if(!i.length||!/^\d{2}:\d{2}$/.test(o)){p(!0);return}p(!1),d(!0);try{let[e,t]=o.split(`:`).map(Number);await n({weekdays:i,hour:e,minute:t,timeZone:c})}catch{}finally{d(!1)}};return(0,H.jsx)(`form`,{onSubmit:e=>void m(e),children:(0,H.jsxs)(`fieldset`,{disabled:u,className:`space-y-4`,children:[(0,H.jsxs)(`fieldset`,{children:[(0,H.jsx)(`legend`,{className:`mb-2 text-sm font-medium text-fg`,children:t?`每周检查日`:`Days of the week`}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(t?[`周日`,`周一`,`周二`,`周三`,`周四`,`周五`,`周六`]:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`]).map((e,t)=>(0,H.jsxs)(`label`,{className:`flex min-h-11 items-center gap-2 rounded-md border border-edge px-3 text-sm text-fg`,children:[(0,H.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:i.includes(t),onChange:e=>a(n=>e.target.checked?[...n,t].sort():n.filter(e=>e!==t))}),e]},t))})]}),(0,H.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,H.jsxs)(`label`,{className:`grid gap-2 text-sm font-medium text-fg`,children:[t?`当地时间`:`Local time`,(0,H.jsx)(`input`,{type:`time`,required:!0,value:o,onChange:e=>s(e.target.value),className:G})]}),(0,H.jsxs)(`label`,{className:`grid gap-2 text-sm font-medium text-fg`,children:[t?`时区(例如 Asia/Shanghai)`:`Time zone (for example Asia/Shanghai)`,(0,H.jsx)(`input`,{required:!0,maxLength:100,value:c,onChange:e=>l(e.target.value),className:G,spellCheck:!1})]})]}),f&&(0,H.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:t?`请选择至少一天,并填写有效时间和时区。`:`Choose at least one day and enter a valid time and time zone.`}),(0,H.jsxs)(`div`,{className:`flex gap-3`,children:[(0,H.jsx)(O,{type:`submit`,disabled:u,children:u?t?`正在保存…`:`Saving…`:t?`保存时间`:`Save schedule`}),(0,H.jsx)(O,{type:`button`,onClick:r,children:t?`取消`:`Cancel`})]})]})})}function le({value:e,disabled:t,zh:n,onChange:r}){let i=E(`/sources/mail/accounts`,z),[a,o]=(0,L.useState)(``),[s,c]=(0,L.useState)(``),[l,d]=(0,L.useState)([]),[p,m]=(0,L.useState)(!1),[h,g]=(0,L.useState)(!1),[_,v]=(0,L.useState)(),y=a||i.data?.accounts[0]?.id||``;async function b(){m(!0),v(void 0),d([]),g(!0),r({id:``,accountId:``,subject:``,sender:``});try{d((await B(`/sources/mail/search`,`POST`,{accountId:y,query:s})).sources)}catch(e){v(e)}finally{m(!1)}}if(i.error)return(0,H.jsxs)(`div`,{role:`alert`,className:`space-y-2 text-sm text-danger`,children:[(0,H.jsx)(`p`,{children:V(i.error,n)}),(0,H.jsx)(O,{onClick:()=>void i.mutate(),children:n?`重新加载`:`Reload`})]});if(!i.data)return(0,H.jsx)(k,{className:`h-24 w-full`});let x=e=>`${e.subject||(n?`无主题邮件`:`Untitled mail`)} · ${e.sender||e.accountId}`;return(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`搜索会读取所选 Gmail 账号的匹配邮件;开启后只持续跟进选定线程,不发送邮件,也不需要开启后台学习。`:`Search reads matching mail in your selected Gmail account. The scene follows only the selected thread, never sends mail, and requires no background learning.`}),(0,H.jsx)(f,{value:y,disabled:t||p,ariaLabel:n?`邮箱账号`:`Mail account`,placeholder:n?`选择账号`:`Choose account`,allowEmpty:!1,options:i.data.accounts.map(e=>({value:e.id,label:e.label})),onChange:e=>{o(e),d([]),r({id:``,accountId:``,subject:``,sender:``})}}),(0,H.jsxs)(`label`,{className:`grid gap-2 text-sm`,children:[n?`主题、发件人或 Gmail 搜索条件`:`Subject, sender, or Gmail query`,(0,H.jsx)(`input`,{value:s,maxLength:500,disabled:t||p,onChange:e=>c(e.target.value),className:`rounded-md border border-edge bg-surface-panel px-3 py-2`,placeholder:n?`例如 from:alice@example.com`:`e.g. from:alice@example.com`})]}),(0,H.jsx)(O,{type:`button`,disabled:t||p||!y||!s.trim(),onClick:()=>void b(),children:p?n?`正在搜索…`:`Searching…`:n?`搜索邮件`:`Search mail`}),(0,H.jsx)(f,{value:e,disabled:t||p,ariaLabel:n?`要跟进的邮件`:`Mail to follow`,placeholder:n?`选择邮件线程`:`Choose a thread`,allowEmpty:!1,options:l.map(e=>({value:e.id,label:x(e)})),onChange:e=>{let t=l.find(t=>t.id===e);t&&r(t)}}),!i.data.accounts.length&&(0,H.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[n?`请连接 Gmail,并允许读取及后台检查;要求每次确认或仅限指定 Agent 的账号暂不支持。`:`Connect Gmail and allow background reads. Accounts requiring confirmation for every read or restricted to specific agents are not supported yet.`,` `,(0,H.jsx)(u,{className:`text-accent underline`,to:`/connectors`,children:n?`管理连接`:`Manage connections`})]}),h&&!p&&!_&&!l.length&&(0,H.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:n?`没有找到匹配线程,请调整搜索条件。`:`No matching threads. Try a different query.`}),_!=null&&(0,H.jsx)(`p`,{role:`alert`,className:`text-danger`,children:V(_,n)})]})}function ue({activation:e,zh:t,onDirty:n,onChanged:r}){let i=`/activations/${e.id}/work-items`,a=E(i,z),[o,s]=(0,L.useState)(null),[c,l]=(0,L.useState)(),[u,d]=(0,L.useState)(!1),f=()=>{s(null),n(!1),a.mutate(),r()};if(a.error)return(0,H.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[V(a.error,t),(0,H.jsx)(O,{onClick:()=>void a.mutate(),children:t?`重新加载`:`Reload`})]});if(!a.data)return(0,H.jsx)(k,{className:`h-32 w-full`});let p=a.data.workItems[0],m=async e=>{if(p){d(!0),l(void 0);try{await B(`/work-items/${p.id}`,`PATCH`,{expectedRevision:p.revision,status:e}),f()}catch(e){l(e)}finally{d(!1)}}};return(0,H.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-edge p-4 sm:p-6`,children:[(0,H.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t?`这封邮件的跟进时间`:`Follow-up deadline`}),(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:p?`${p.status===`watching`?t?`留意回复,到时检查`:`Watching replies; check at deadline`:p.status===`paused`?t?`已暂停跟进`:`Follow-up paused`:t?`已结束跟进`:`Follow-up ended`} · ${new Intl.DateTimeFormat(t?`zh-CN`:`en`,{dateStyle:`medium`,timeStyle:`short`}).format(p.dueAt)}`:t?`设置一个时间;此前有新回复时会重新判断是否还需要跟进。`:`Choose a deadline. New replies before then trigger a review of whether follow-up is still needed.`}),!!c&&(0,H.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:V(c,t)}),o?(0,H.jsx)(de,{initial:o.item?.dueAt,zh:t,onCancel:()=>{s(null),n(!1)},onSave:async t=>{l(void 0);try{o.item?await B(`/work-items/${o.item.id}`,`PATCH`,{expectedRevision:o.item.revision,dueAt:t,status:`watching`}):e.scope.kind===`objects`&&await B(i,`POST`,{subjectId:e.scope.ids[0],accountId:e.permissions.accountIds[0],dueAt:t}),f()}catch(e){throw l(e),e}}}):(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[p?.status!==`completed`&&(0,H.jsx)(O,{disabled:u||e.status!==`active`,onClick:()=>{s({item:p}),n(!0),l(void 0)},children:p?t?`重新设置跟进时间`:`Reschedule follow-up`:t?`设置跟进时间`:`Set deadline`}),p?.status===`watching`&&(0,H.jsx)(O,{disabled:u,onClick:()=>void m(`paused`),children:t?`暂停这次跟进`:`Pause follow-up`}),p&&p.status!==`completed`&&(0,H.jsx)(O,{disabled:u,onClick:()=>void m(`completed`),children:t?`结束这次跟进`:`End follow-up`})]}),(0,H.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t?`结束跟进只停止检查,不表示邮件已发送或事情已经解决。`:`Ending stops checks; it does not mean a message was sent or the matter resolved.`})]})}function de({initial:e,zh:t,onSave:n,onCancel:r}){let[i,a]=(0,L.useState)(()=>{if(!e)return``;let t=new Date(e);return new Date(e-t.getTimezoneOffset()*6e4).toISOString().slice(0,16)}),[o,s]=(0,L.useState)(!1),[c,l]=(0,L.useState)(!1),u=async e=>{e.preventDefault();let t=new Date(i).getTime();if(!Number.isFinite(t)||t<=Date.now()){l(!0);return}l(!1),s(!0);try{await n(t)}catch{}finally{s(!1)}};return(0,H.jsx)(`form`,{onSubmit:e=>void u(e),children:(0,H.jsxs)(`fieldset`,{disabled:o,className:`space-y-3`,children:[(0,H.jsxs)(`label`,{className:`grid gap-2 text-sm font-medium text-fg`,children:[t?`跟进时间(当前设备时区)`:`Deadline (device time zone)`,(0,H.jsx)(`input`,{required:!0,type:`datetime-local`,value:i,onChange:e=>a(e.target.value),className:`min-h-11 w-full min-w-0 rounded-md border border-edge bg-surface-panel px-3 py-2 text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`})]}),c&&(0,H.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:t?`请选择未来的有效时间。`:`Choose a valid future time.`}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(O,{type:`submit`,disabled:o,children:o?t?`正在保存…`:`Saving…`:t?`保存跟进时间`:`Save deadline`}),(0,H.jsx)(O,{type:`button`,onClick:r,children:t?`取消`:`Cancel`})]})]})})}var q=`min-h-11 w-full rounded-md border border-edge bg-surface-panel px-3 py-2 text-base text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent sm:text-sm`,J=`min-w-0 rounded-xl border border-edge bg-surface-panel p-4 sm:p-6`,Y=`grid gap-2 text-sm font-medium text-fg`;function X(e,t){return{needs_setup:[`待完成设置`,`Finish setup`],active:[`已开启`,`Active`],paused:[`已暂停`,`Paused`],completed:[`已完成`,`Completed`],archived:[`已归档`,`Archived`],running:[`正在检查`,`Checking`],succeeded:[`已准备成果`,`Result ready`],skipped:[`无需新行动`,`No new action`],retry_wait:[`等待来源或预算`,`Waiting for source or budget`],failed:[`检查失败`,`Check failed`],cancelled:[`已取消`,`Cancelled`]}[e]?.[+!t]??e}function Z(){let e=(0,R.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,H.jsxs)(`div`,{className:`space-y-4`,"aria-busy":`true`,children:[(0,H.jsx)(k,{className:`h-8 w-48`}),(0,H.jsx)(k,{className:`h-40 w-full`}),(0,H.jsx)(k,{className:`h-32 w-full`})]}),e[0]=t):t=e[0],t}function Q(e){let t=(0,R.c)(24),{error:n,retry:r}=e,i=g(fe)===`zh`;if(n?.status===503){let e=i?`场景尚未开放`:`Scenes are not available yet`,r;t[0]===e?r=t[1]:(r=(0,H.jsx)(`h1`,{className:`text-xl font-semibold text-fg`,children:e}),t[0]=e,t[1]=r);let a;t[2]!==n||t[3]!==i?(a=V(n,i),t[2]=n,t[3]=i,t[4]=a):a=t[4];let o;t[5]===a?o=t[6]:(o=(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a}),t[5]=a,t[6]=o);let s=i?`返回对话`:`Back to chat`,c;t[7]===s?c=t[8]:(c=(0,H.jsx)(O,{asChild:!0,children:(0,H.jsx)(u,{to:`/chat`,children:s})}),t[7]=s,t[8]=c);let l;return t[9]!==r||t[10]!==o||t[11]!==c?(l=(0,H.jsxs)(`section`,{className:`${J} space-y-3`,children:[r,o,c]}),t[9]=r,t[10]=o,t[11]=c,t[12]=l):l=t[12],l}let a;t[13]!==n||t[14]!==i?(a=V(n,i),t[13]=n,t[14]=i,t[15]=a):a=t[15];let o;t[16]===a?o=t[17]:(o=(0,H.jsx)(`p`,{className:`text-sm text-danger`,children:a}),t[16]=a,t[17]=o);let s;t[18]!==r||t[19]!==i?(s=r&&(0,H.jsxs)(O,{onClick:r,children:[(0,H.jsx)(I,{size:16,"aria-hidden":`true`}),i?`重新加载`:`Reload`]}),t[18]=r,t[19]=i,t[20]=s):s=t[20];let c;return t[21]!==o||t[22]!==s?(c=(0,H.jsxs)(`div`,{role:`alert`,className:`space-y-3 rounded-xl border border-edge p-4`,children:[o,s]}),t[21]=o,t[22]=s,t[23]=c):c=t[23],c}function fe(e){return e.language}function pe(){let e=(0,R.c)(5),t=h(ge);if(h(he)){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,H.jsx)(Q,{error:{status:401}}),e[0]=t):t=e[0],t}let n=t??`anonymous`,r,i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r={provider:me},i=(0,H.jsx)(_e,{}),e[1]=r,e[2]=i):(r=e[1],i=e[2]);let a;return e[3]===n?a=e[4]:(a=(0,H.jsx)(D,{value:r,children:i},n),e[3]=n,e[4]=a),a}function me(){return new Map}function he(e){return e.tokenExpired}function ge(e){return e.conversationId}function _e(){let e=(0,R.c)(20),{activationId:t,templateKey:n}=l(),r=a(`/scenes/inbox`),i=g(be)===`zh`,[o,c]=(0,L.useState)(!1),f=(0,L.useRef)(null),p=d(),[m]=s(),h=t&&p.state?.fromSceneInbox===!0?`/scenes/inbox${typeof p.state.inboxSearch==`string`?p.state.inboxSearch:``}`:void 0,_=F(ye),v=F(ve),y,b;e[0]!==v||e[1]!==_||e[2]!==i?(y=()=>{let e=i?`把需要持续留意的事交给 AI,把时间留给自己。`:`Let AI look after recurring needs, leaving more time for you.`,t=i?`查看全部成果`:`View all results`,n=i?`检查与提醒设置`:`Checks and reminders`;return _({startExtra:null,main:(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:i?`场景`:`Scenes`}),(0,H.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,title:e,children:e})]}),end:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(O,{asChild:!0,variant:`secondary`,className:`h-9`,children:(0,H.jsxs)(u,{"data-scene-inbox":!0,to:`/scenes/inbox`,"aria-label":t,title:t,children:[(0,H.jsx)(M,{className:`size-4`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`hidden sm:inline`,children:t})]})}),(0,H.jsx)(O,{ref:f,type:`button`,variant:`ghost`,className:`size-9 p-0`,"aria-label":n,title:n,"aria-haspopup":`dialog`,onClick:()=>c(!0),children:(0,H.jsx)(j,{className:`size-4`,"aria-hidden":`true`})})]})}),()=>v()},b=[v,_,i],e[0]=v,e[1]=_,e[2]=i,e[3]=y,e[4]=b):(y=e[3],b=e[4]),(0,L.useLayoutEffect)(y,b);let x;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,H.jsx)(`main`,{className:`h-full overflow-y-auto bg-surface-panel p-4 sm:p-8`,children:(0,H.jsx)(`div`,{className:`mx-auto max-w-3xl space-y-6`,children:(0,H.jsx)(Se,{})})}),e[5]=x):x=e[5];let S;e[6]!==t||e[7]!==r||e[8]!==h||e[9]!==m||e[10]!==n||e[11]!==i?(S=(t||n||r)&&(0,H.jsx)(xe,{titleText:r?m.has(`digest`)?i?`摘要中的成果`:`Results in this digest`:i?`场景成果`:`Scene results`:t?i?`场景详情`:`Scene details`:i?`了解并开启`:`Explore and start`,closeLabel:r?i?`关闭场景成果`:`Close scene results`:t?i?`关闭场景详情`:`Close scene details`:i?`关闭场景设置`:`Close scene setup`,backTo:h,backLabel:i?`返回成果`:`Back to results`,restoreSelector:r?`[data-scene-inbox]`:t?`[data-scene-id="${CSS.escape(t)}"]`:`[data-scene-template="${CSS.escape(n)}"]`,children:r?(0,H.jsx)($,{}):t?(0,H.jsx)(De,{id:t}):(0,H.jsx)(Ee,{templateKey:n})},t??n??`inbox`),e[6]=t,e[7]=r,e[8]=h,e[9]=m,e[10]=n,e[11]=i,e[12]=S):S=e[12];let C;e[13]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>f.current?.focus(),e[13]=C):C=e[13];let w;e[14]!==o||e[15]!==i?(w=(0,H.jsx)(oe,{zh:i,open:o,onOpenChange:c,onCloseAutoFocus:C}),e[14]=o,e[15]=i,e[16]=w):w=e[16];let T;return e[17]!==S||e[18]!==w?(T=(0,H.jsxs)(H.Fragment,{children:[x,S,w]}),e[17]=S,e[18]=w,e[19]=T):T=e[19],T}function ve(e){return e.clearPageHeader}function ye(e){return e.setPageHeader}function be(e){return e.language}function xe(e){let t=(0,R.c)(29),{titleText:n,closeLabel:r,restoreSelector:i,backTo:a,backLabel:s,children:c}=e,l=o(),d=(0,L.useRef)(null),f;t[0]===l?f=t[1]:(f=()=>l(`/scenes`,{replace:!0}),t[0]=l,t[1]=f);let m=f,h;t[2]===m?h=t[3]:(h=e=>{e||m()},t[2]=m,t[3]=h);let g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,H.jsx)(v,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),t[4]=g):g=t[4];let _;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(_=e=>{e.preventDefault(),d.current?.focus()},t[5]=_):_=t[5];let y;t[6]===i?y=t[7]:(y=e=>{e.preventDefault(),document.querySelector(i)?.focus()},t[6]=i,t[7]=y);let T;t[8]!==s||t[9]!==a?(T=a&&(0,H.jsx)(O,{asChild:!0,variant:`ghost`,className:`size-9 shrink-0 p-0`,children:(0,H.jsx)(u,{to:a,replace:!0,"aria-label":s,title:s,children:(0,H.jsx)(te,{size:18,"aria-hidden":`true`})})}),t[8]=s,t[9]=a,t[10]=T):T=t[10];let E;t[11]===n?E=t[12]:(E=(0,H.jsx)(C,{ref:d,tabIndex:-1,className:`min-w-0 flex-1 text-base font-semibold text-fg outline-none`,children:n}),t[11]=n,t[12]=E);let D;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,H.jsx)(p,{size:18,"aria-hidden":`true`}),t[13]=D):D=t[13];let k;t[14]===r?k=t[15]:(k=(0,H.jsx)(b,{asChild:!0,children:(0,H.jsx)(O,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":r,title:r,children:D})}),t[14]=r,t[15]=k);let A;t[16]!==T||t[17]!==E||t[18]!==k?(A=(0,H.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-edge px-4 py-3 sm:px-6`,children:[T,E,k]}),t[16]=T,t[17]=E,t[18]=k,t[19]=A):A=t[19];let j;t[20]===c?j=t[21]:(j=(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 sm:p-6`,children:(0,H.jsx)(`div`,{className:`space-y-6`,children:c})}),t[20]=c,t[21]=j);let M;t[22]!==A||t[23]!==j||t[24]!==y?(M=(0,H.jsxs)(x,{children:[g,(0,H.jsxs)(S,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(52rem,calc(100dvh-2rem))] w-[min(52rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float focus:outline-none`,"aria-describedby":void 0,onOpenAutoFocus:_,onCloseAutoFocus:y,children:[A,j]})]}),t[22]=A,t[23]=j,t[24]=y,t[25]=M):M=t[25];let N;return t[26]!==M||t[27]!==h?(N=(0,H.jsx)(w,{open:!0,onOpenChange:h,children:M}),t[26]=M,t[27]=h,t[28]=N):N=t[28],N}function Se(){let e=(0,R.c)(48),{activationId:t}=l(),n=g(Ce)===`zh`,[r,i]=s(),a;e[0]===r?a=e[1]:(a=r.get(`after`)??``,e[0]=r,e[1]=a);let o=a,c=E(`/templates`,z),d=E(`/activations?limit=20&afterId=${encodeURIComponent(o)}`,z),f=d.mutate,p,m;if(e[2]!==t||e[3]!==f?(p=()=>{t||f()},m=[t,f],e[2]=t,e[3]=f,e[4]=p,e[5]=m):(p=e[4],m=e[5]),(0,L.useEffect)(p,m),c.error||d.error){let t=c.error??d.error,n;e[6]!==d||e[7]!==c?(n=()=>{c.mutate(),d.mutate()},e[6]=d,e[7]=c,e[8]=n):n=e[8];let r;return e[9]!==t||e[10]!==n?(r=(0,H.jsx)(Q,{error:t,retry:n}),e[9]=t,e[10]=n,e[11]=r):r=e[11],r}if(!c.data||!d.data){let t;return e[12]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,H.jsx)(Z,{}),e[12]=t):t=e[12],t}let h=n?`你想先轻松一点的事`:`Where could you use a little help?`,_;e[13]===h?_=e[14]:(_=(0,H.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:h}),e[13]=h,e[14]=_);let v;if(e[15]!==c.data.templates||e[16]!==n){let t;e[18]===n?t=e[19]:(t=e=>(0,H.jsxs)(`article`,{className:`${J} space-y-3`,children:[(0,H.jsx)(ne,{className:`text-fg-muted`,size:20,"aria-hidden":`true`}),(0,H.jsx)(`h3`,{className:`text-balance font-medium text-fg`,children:e.title}),(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.description}),(0,H.jsx)(O,{asChild:!0,children:(0,H.jsx)(u,{"data-scene-template":e.key,to:`/scenes/new/${encodeURIComponent(e.key)}?version=${encodeURIComponent(e.version)}`,children:n?`了解并开启`:`Explore and start`})})]},`${e.key}:${e.version}`),e[18]=n,e[19]=t),v=c.data.templates.map(t),e[15]=c.data.templates,e[16]=n,e[17]=v}else v=e[17];let y;e[20]===v?y=e[21]:(y=(0,H.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:v}),e[20]=v,e[21]=y);let b;e[22]!==_||e[23]!==y?(b=(0,H.jsxs)(`section`,{className:`space-y-3`,children:[_,y]}),e[22]=_,e[23]=y,e[24]=b):b=e[24];let x=n?`我的场景`:`My scenes`,S;e[25]===x?S=e[26]:(S=(0,H.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:x}),e[25]=x,e[26]=S);let C;e[27]!==d.data.activations||e[28]!==n?(C=d.data.activations.length?d.data.activations.map(e=>(0,H.jsxs)(u,{to:`/scenes/${e.id}`,"data-scene-id":e.id,className:`${J} block space-y-2 transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,H.jsx)(`p`,{className:`break-words font-medium text-fg`,children:e.goal}),(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:X(e.status===`active`&&e.setupMissing?.length?`needs_setup`:e.status,n)})]},e.id)):(0,H.jsxs)(`div`,{className:`${J} space-y-2`,children:[(0,H.jsx)(N,{"aria-hidden":`true`,className:`text-fg-muted`}),(0,H.jsx)(`p`,{className:`text-fg`,children:n?`还没有开启场景`:`No scenes yet`}),(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`从上面选择一件你希望 AI 帮忙照看的事。`:`Choose something above that you would like AI to look after.`})]}),e[27]=d.data.activations,e[28]=n,e[29]=C):C=e[29];let w;e[30]!==o||e[31]!==i||e[32]!==n?(w=o&&(0,H.jsx)(O,{onClick:()=>i({}),children:n?`返回第一页`:`First page`}),e[30]=o,e[31]=i,e[32]=n,e[33]=w):w=e[33];let T;e[34]!==d.data.nextCursor||e[35]!==i||e[36]!==n?(T=d.data.nextCursor&&(0,H.jsx)(O,{onClick:()=>i({after:d.data.nextCursor}),children:n?`下一页`:`Next page`}),e[34]=d.data.nextCursor,e[35]=i,e[36]=n,e[37]=T):T=e[37];let D;e[38]!==w||e[39]!==T?(D=(0,H.jsxs)(`div`,{className:`flex gap-3`,children:[w,T]}),e[38]=w,e[39]=T,e[40]=D):D=e[40];let k;e[41]!==C||e[42]!==D||e[43]!==S?(k=(0,H.jsxs)(`section`,{className:`space-y-3`,children:[S,C,D]}),e[41]=C,e[42]=D,e[43]=S,e[44]=k):k=e[44];let A;return e[45]!==k||e[46]!==b?(A=(0,H.jsxs)(H.Fragment,{children:[b,k]}),e[45]=k,e[46]=b,e[47]=A):A=e[47],A}function Ce(e){return e.language}function we(e){let t=(0,R.c)(20),{zh:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={refreshInterval:15e3,shouldRetryOnError:!1},t[0]=r):r=t[0];let i=E(`/metrics`,z,r),a;t[1]===n?a=t[2]:(a=n?[`有帮助的成果`,`没有帮助的成果`,`带来帮助的场景`]:[`Helpful results`,`Unhelpful results`,`Scenes that helped`],t[1]=n,t[2]=a);let o=a,s,c,l,u;if(t[3]!==o||t[4]!==i||t[5]!==n){let e=i.data?[i.data.usefulOutcomes,i.data.unhelpfulOutcomes,i.data.scenesWithUsefulOutcomes]:[],r=new Intl.NumberFormat(n?`zh-CN`:`en`);s=`${J} space-y-3`,c=n?`反馈概览`:`Feedback overview`;let a=n?`最近 7 天的反馈`:`Feedback in the last 7 days`;t[10]===a?l=t[11]:(l=(0,H.jsx)(`h2`,{className:`text-balance text-base font-semibold text-fg`,children:a}),t[10]=a,t[11]=l),u=i.error?(0,H.jsxs)(`div`,{role:`alert`,className:`space-y-2`,children:[(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`暂时无法加载统计,仍可查看和评价成果。`:`Stats are unavailable. You can still view and rate results.`}),(0,H.jsx)(O,{disabled:i.isValidating,onClick:()=>void i.mutate(),children:n?`重新加载统计`:`Reload stats`})]}):(0,H.jsx)(`dl`,{className:`grid gap-4 sm:grid-cols-3`,"aria-busy":!i.data,children:o.map((t,n)=>(0,H.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,H.jsx)(`dt`,{className:`text-sm text-fg-muted`,children:t}),(0,H.jsx)(`dd`,{className:`text-xl font-semibold tabular-nums text-fg`,children:i.data?r.format(e[n]):(0,H.jsx)(k,{className:`h-7 w-12`})})]},t))}),t[3]=o,t[4]=i,t[5]=n,t[6]=s,t[7]=c,t[8]=l,t[9]=u}else s=t[6],c=t[7],l=t[8],u=t[9];let d=n?`按你这段时间的明确反馈统计,每份成果取最新评价。已读和检查成功不计入,也不代表已采纳或节省时间。`:`Counts your explicit feedback during this period, using the latest rating per result. Reads and successful checks do not count. This does not measure adoption or time saved.`,f;t[12]===d?f=t[13]:(f=(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d}),t[12]=d,t[13]=f);let p;return t[14]!==s||t[15]!==c||t[16]!==l||t[17]!==u||t[18]!==f?(p=(0,H.jsxs)(`section`,{className:s,"aria-label":c,children:[l,u,f]}),t[14]=s,t[15]=c,t[16]=l,t[17]=u,t[18]=f,t[19]=p):p=t[19],p}function $(){let e=(0,R.c)(42),t=g(Te)===`zh`,[n,r]=s(),i;e[0]===n?i=e[1]:(i=n.get(`after`)??``,e[0]=n,e[1]=i);let a=i,o;e[2]===n?o=e[3]:(o=n.get(`digest`),e[2]=n,e[3]=o);let c=o,l;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(l={refreshInterval:15e3},e[4]=l):l=e[4];let d=E(`${c?`/digests/${encodeURIComponent(c)}`:`/outcomes`}?limit=20&afterId=${encodeURIComponent(a)}`,z,l);if(d.error){let t;e[5]===d?t=e[6]:(t=()=>void d.mutate(),e[5]=d,e[6]=t);let n;return e[7]!==d.error||e[8]!==t?(n=(0,H.jsx)(Q,{error:d.error,retry:t}),e[7]=d.error,e[8]=t,e[9]=n):n=e[9],n}if(!d.data){let t;return e[10]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,H.jsx)(Z,{}),e[10]=t):t=e[10],t}let f=t?`集中查看各个场景准备的成果,告诉 AI 哪些对你有帮助。`:`Review results across your scenes and tell AI what helps.`,p;e[11]===f?p=e[12]:(p=(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:f}),e[11]=f,e[12]=p);let m;e[13]===t?m=e[14]:(m=(0,H.jsx)(we,{zh:t}),e[13]=t,e[14]=m);let h=t?`成果列表`:`Results list`,_;e[15]!==c||e[16]!==n||e[17]!==d||e[18]!==t?(_=d.data.outcomes.length?d.data.outcomes.map(e=>(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(W,{item:e,zh:t,onChange:()=>void d.mutate()}),(0,H.jsx)(O,{asChild:!0,variant:`ghost`,children:(0,H.jsx)(u,{state:{fromSceneInbox:!0,inboxSearch:`?${n.toString()}`},to:`/scenes/${encodeURIComponent(e.activationId)}`,children:t?`查看所属场景`:`View scene`})})]},e.id)):(0,H.jsxs)(`div`,{className:`${J} space-y-3`,children:[(0,H.jsx)(M,{size:32,"aria-hidden":`true`,className:`text-fg-muted`}),(0,H.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t?`这里还没有成果`:`No results here yet`}),(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:c?t?`这份摘要中的成果目前不可查看,可能已被撤回。`:`Results in this digest are currently unavailable and may have been withdrawn.`:t?`回到场景,提供资料并检查一次;有新成果时会出现在这里。`:`Open a scene, provide context and run a check. New results will appear here.`})]}),e[15]=c,e[16]=n,e[17]=d,e[18]=t,e[19]=_):_=e[19];let v;e[20]!==h||e[21]!==_?(v=(0,H.jsx)(`section`,{className:`space-y-4`,"aria-label":h,children:_}),e[20]=h,e[21]=_,e[22]=v):v=e[22];let y=t?`成果分页`:`Results pages`,b;e[23]!==a||e[24]!==c||e[25]!==r||e[26]!==t?(b=a&&(0,H.jsx)(O,{onClick:()=>r(c?{digest:c}:{}),children:t?`返回第一页`:`First page`}),e[23]=a,e[24]=c,e[25]=r,e[26]=t,e[27]=b):b=e[27];let x;e[28]!==c||e[29]!==d.data.nextCursor||e[30]!==r||e[31]!==t?(x=d.data.nextCursor&&(0,H.jsx)(O,{onClick:()=>r({...c?{digest:c}:{},after:d.data.nextCursor}),children:t?`下一页`:`Next page`}),e[28]=c,e[29]=d.data.nextCursor,e[30]=r,e[31]=t,e[32]=x):x=e[32];let S;e[33]!==b||e[34]!==x||e[35]!==y?(S=(0,H.jsxs)(`nav`,{className:`flex flex-wrap gap-3`,"aria-label":y,children:[b,x]}),e[33]=b,e[34]=x,e[35]=y,e[36]=S):S=e[36];let C;return e[37]!==S||e[38]!==p||e[39]!==m||e[40]!==v?(C=(0,H.jsxs)(H.Fragment,{children:[p,m,v,S]}),e[37]=S,e[38]=p,e[39]=m,e[40]=v,e[41]=C):C=e[41],C}function Te(e){return e.language}function Ee({templateKey:e}){let t=g(e=>e.language)===`zh`,[n]=s(),r=o(),i=n.get(`version`)??`1.0.0`,a=E(`/templates/${encodeURIComponent(e)}/versions/${encodeURIComponent(i)}`,z),[c,l]=(0,L.useState)(``),[u,d]=(0,L.useState)(``),[f,p]=(0,L.useState)(``),[m,h]=(0,L.useState)(!1),[_,v]=(0,L.useState)(!1),[y,b]=(0,L.useState)(),[x,S]=(0,L.useState)(!1),C=(0,L.useRef)({content:``,id:``}),w=(0,L.useRef)(``),T=!!(c||f||m)&&!x;if((0,L.useEffect)(()=>{x&&r(w.current,{replace:!0})},[x,r]),a.error)return(0,H.jsx)(Q,{error:a.error,retry:()=>void a.mutate()});if(!a.data)return(0,H.jsx)(Z,{});let D=a.data.template,k=D.contextProviders.includes(`mail`),A=async t=>{t.preventDefault(),v(!0),b(void 0);let n={templateKey:e,templateVersion:i,goal:c,scope:k?{kind:`objects`,ids:[f.trim()]}:{kind:`personal`},permissions:{accountIds:k?[u.trim()]:[],contextProviders:D.contextProviders,effectHandlers:[]}},r=JSON.stringify(n);C.current.content!==r&&(C.current={content:r,id:crypto.randomUUID()});try{w.current=`/scenes/${(await B(`/activations`,`POST`,n,C.current.id)).activation.id}`,S(!0)}catch(e){b(e)}finally{v(!1)}};return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(U,{dirty:T,zh:t}),(0,H.jsxs)(`header`,{children:[(0,H.jsx)(`h1`,{className:`text-wrap text-xl font-semibold text-fg`,children:D.title}),(0,H.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:D.description})]}),(0,H.jsx)(`form`,{onSubmit:e=>void A(e),className:`${J} space-y-5`,children:(0,H.jsxs)(`fieldset`,{disabled:_||x,className:`space-y-5`,children:[(0,H.jsxs)(`label`,{className:Y,children:[t?`希望它持续帮你做好什么?`:`What should it keep helping you with?`,(0,H.jsx)(`textarea`,{required:!0,maxLength:4e3,rows:3,value:c,onChange:e=>l(e.target.value),className:q,autoComplete:`off`})]}),k&&(0,H.jsx)(le,{value:f,disabled:_||x,zh:t,onChange:e=>{d(e.accountId),p(e.id),h(!1)}}),(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`只准备草稿和建议,不发送消息、不执行外部写操作。下一步需补齐资料和检查时间;完成后才会自动检查。`:`Prepares drafts and suggestions only. No messages or external writes. Next, complete the context and timing settings for automatic checks.`}),(0,H.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm text-fg`,children:[(0,H.jsx)(`input`,{required:!0,type:`checkbox`,className:`ui-checkbox`,checked:m,onChange:e=>h(e.target.checked)}),t?`确认以上范围,允许读取我提供的资料。`:`I confirm this scope and allow reading the information I provide.`]}),!!y&&(0,H.jsx)(Q,{error:y}),(0,H.jsx)(O,{type:`submit`,variant:`primary`,disabled:_||x||k&&!f,children:_?t?`正在开启…`:`Starting…`:t?`继续设置`:`Continue setup`})]})})]})}function De({id:e}){let t=g(e=>e.language)===`zh`,[n]=s(),r=n.get(`result`),i=`/activations/${encodeURIComponent(e)}`,[a,o]=(0,L.useState)(``),[c,l]=(0,L.useState)(``),u=E(i,z,{refreshInterval:15e3}),d=E(`${i}/runs?limit=20&afterId=${encodeURIComponent(a)}`,z,{refreshInterval:5e3}),f=E(`/outcomes?limit=20&activationId=${encodeURIComponent(e)}&afterId=${encodeURIComponent(c)}`,z,{refreshInterval:5e3}),[p,m]=(0,L.useState)(!1),[h,_]=(0,L.useState)(),[v,y]=(0,L.useState)(!1),b=(0,L.useRef)(null),[x,S]=(0,L.useState)(!1),[C,w]=(0,L.useState)(!1),[T,D]=(0,L.useState)(!1),k=x||C||T,A=async e=>{if(u.data){m(!0),_(void 0),y(!1);try{e?(b.current??=crypto.randomUUID(),await B(`${i}/checks`,`POST`,void 0,b.current),b.current=null,y(!0),o(``),l(``)):await B(i,`PATCH`,{expectedRevision:u.data.activation.revision,status:u.data.activation.status===`active`?`paused`:`active`}),await Promise.all([u.mutate(),d.mutate(),f.mutate()])}catch(e){_(e)}finally{m(!1)}}};if(u.error)return(0,H.jsx)(Q,{error:u.error,retry:()=>void u.mutate()});if(!u.data)return(0,H.jsx)(Z,{});let j=u.data.activation;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(U,{dirty:k,zh:t}),(0,H.jsxs)(`header`,{className:`space-y-3`,children:[(0,H.jsx)(`h1`,{className:`break-words text-wrap text-xl font-semibold text-fg`,children:j.goal}),(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:X(j.status===`active`&&j.setupMissing?.length?`needs_setup`:j.status,t)}),(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`只准备建议和成果,不自动发送或写入外部系统。`:`Prepares suggestions and results. Does not send or write to external systems.`}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,H.jsx)(O,{variant:`primary`,disabled:p||j.status!==`active`,onClick:()=>void A(!0),children:p?t?`处理中…`:`Working…`:t?`现在检查`:`Check now`}),[`active`,`paused`,`needs_setup`].includes(j.status)&&(0,H.jsxs)(O,{disabled:p,onClick:()=>void A(!1),children:[(0,H.jsx)(ee,{size:16,"aria-hidden":`true`}),j.status===`active`?t?`暂停场景`:`Pause scene`:t?`检查设置并恢复`:`Review setup and resume`]})]}),[`active`,`paused`].includes(j.status)&&(0,H.jsx)(O,{disabled:p,variant:`ghost`,onClick:()=>{m(!0),B(i,`PATCH`,{expectedRevision:j.revision,status:`completed`}).then(()=>Promise.all([u.mutate(),f.mutate(),d.mutate()])).catch(_).finally(()=>m(!1))},children:t?`结束场景(保留成果)`:`End scene (keep results)`}),v&&(0,H.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t?`检查已排队;没有新变化时不会生成新卡片。`:`Check queued. No new card is created when nothing has changed.`})]}),h&&(0,H.jsx)(Q,{error:h,retry:()=>{u.mutate(),_(void 0)}}),j.status===`active`&&!!j.setupMissing?.length&&(0,H.jsxs)(`section`,{role:`status`,className:J,children:[(0,H.jsx)(`h2`,{className:`font-medium text-fg`,children:t?`完成以下设置后,场景才会自动检查`:`Complete setup for automatic checks`}),(0,H.jsx)(`ul`,{className:`mt-2 list-inside list-disc text-sm text-fg-muted`,children:j.setupMissing.map(e=>(0,H.jsx)(`li`,{children:{notes:t?`填写安排和约束`:`Provide arrangements and constraints`,schedule:t?`设置周期检查时间`:`Set a recurring review time`,deadline:t?`设置邮件跟进截止时间`:`Set a mail follow-up deadline`}[e]},e))})]}),(0,H.jsx)(re,{activationId:e,zh:t}),[`active`,`paused`,`needs_setup`].includes(j.status)&&(0,H.jsx)(Oe,{activation:j,zh:t,onDirty:D,onSaved:()=>{u.mutate(),f.mutate(),d.mutate()}},j.revision),j.permissions.contextProviders.includes(`user_notes`)&&(0,H.jsx)(Ae,{path:i,zh:t,onDirty:S,onSaved:()=>{u.mutate(),f.mutate(),d.mutate()}}),j.templateKey===`mail-follow-up`?(0,H.jsx)(ue,{activation:j,zh:t,onDirty:w,onChanged:()=>{u.mutate(),f.mutate(),d.mutate()}}):(0,H.jsx)(K,{activation:j,zh:t,onDirty:w,onChanged:()=>void u.mutate()}),r&&(0,H.jsx)(ke,{activationId:e,presentationId:r,zh:t}),(0,H.jsxs)(`section`,{className:`space-y-3`,children:[(0,H.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t?`最近成果`:`Recent results`}),f.error?(0,H.jsx)(Q,{error:f.error,retry:()=>void f.mutate()}):f.data?f.data.outcomes.filter(t=>t.activationId===e).length===0?(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`还没有新成果。提供资料后,可以先检查一次。`:`No new results yet. Provide context and try a check.`}):f.data.outcomes.map(e=>(0,H.jsx)(W,{item:e,zh:t,onChange:()=>void f.mutate()},e.id)):(0,H.jsx)(Z,{}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[c&&(0,H.jsx)(O,{onClick:()=>l(``),children:t?`最近成果`:`Latest results`}),f.data?.nextCursor&&(0,H.jsx)(O,{onClick:()=>l(f.data.nextCursor),children:t?`更早成果`:`Earlier results`})]})]}),(0,H.jsxs)(`section`,{className:`space-y-3`,children:[(0,H.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t?`检查记录`:`Check history`}),d.error?(0,H.jsx)(Q,{error:d.error,retry:()=>void d.mutate()}):d.data?d.data.runs.length===0?(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`尚未执行检查。`:`No checks yet.`}):(0,H.jsx)(`ul`,{className:`divide-y divide-edge`,children:d.data.runs.map(e=>(0,H.jsxs)(`li`,{className:`flex flex-wrap justify-between gap-2 py-3 text-sm`,children:[(0,H.jsxs)(`span`,{className:`text-fg`,children:[X(e.status,t),e.reason===`empty_input`?t?`:请先提供资料`:`: provide context first`:``]}),(0,H.jsx)(`time`,{className:`text-fg-muted`,dateTime:new Date(e.createdAt).toISOString(),children:new Intl.DateTimeFormat(t?`zh-CN`:`en`,{dateStyle:`medium`,timeStyle:`short`}).format(e.createdAt)})]},e.id))}):(0,H.jsx)(Z,{}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[a&&(0,H.jsx)(O,{onClick:()=>o(``),children:t?`最近检查`:`Latest checks`}),d.data?.nextCursor&&(0,H.jsx)(O,{onClick:()=>o(d.data.nextCursor),children:t?`更早检查`:`Earlier checks`})]})]})]})}function Oe(e){let t=(0,R.c)(39),{activation:n,zh:r,onDirty:i,onSaved:a}=e,[o,s]=(0,L.useState)(n.goal),[c,l]=(0,L.useState)(!1),[u,d]=(0,L.useState)(),f,p;t[0]!==n.goal||t[1]!==o||t[2]!==i?(f=()=>(i(o!==n.goal),()=>i(!1)),p=[o,n.goal,i],t[0]=n.goal,t[1]=o,t[2]=i,t[3]=f,t[4]=p):(f=t[3],p=t[4]),(0,L.useEffect)(f,p);let m=r?`修改目标`:`Edit goal`,h;t[5]===m?h=t[6]:(h=(0,H.jsx)(`summary`,{className:`cursor-pointer`,children:m}),t[5]=m,t[6]=h);let g=r?`保存后暂停检查并撤回旧建议。确认设置后恢复;邮件跟进时间需另行恢复。`:`Saving pauses checks and withdraws previous suggestions. Review settings before resuming, including mail deadlines.`,_;t[7]===g?_=t[8]:(_=(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:g}),t[7]=g,t[8]=_);let v=r?`新目标`:`New goal`,y;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>s(e.target.value),t[9]=y):y=t[9];let b;t[10]===o?b=t[11]:(b=(0,H.jsx)(`textarea`,{value:o,maxLength:4e3,onChange:y,className:q}),t[10]=o,t[11]=b);let x;t[12]!==v||t[13]!==b?(x=(0,H.jsxs)(`label`,{className:Y,children:[v,b]}),t[12]=v,t[13]=b,t[14]=x):x=t[14];let S;t[15]!==n.goal||t[16]!==c||t[17]!==o?(S=c||!o.trim()||o===n.goal,t[15]=n.goal,t[16]=c,t[17]=o,t[18]=S):S=t[18];let C;t[19]!==n.id||t[20]!==n.permissions||t[21]!==n.revision||t[22]!==n.scope||t[23]!==o||t[24]!==a?(C=()=>{l(!0),d(void 0),B(`/activations/${n.id}`,`PATCH`,{expectedRevision:n.revision,goal:o,scope:n.scope,permissions:n.permissions}).then(a).catch(d).finally(()=>l(!1))},t[19]=n.id,t[20]=n.permissions,t[21]=n.revision,t[22]=n.scope,t[23]=o,t[24]=a,t[25]=C):C=t[25];let w=r?`保存目标`:`Save goal`,T;t[26]!==S||t[27]!==C||t[28]!==w?(T=(0,H.jsx)(O,{disabled:S,onClick:C,children:w}),t[26]=S,t[27]=C,t[28]=w,t[29]=T):T=t[29];let E;t[30]!==u||t[31]!==r?(E=u!=null&&(0,H.jsx)(`p`,{role:`alert`,className:`text-danger`,children:V(u,r)}),t[30]=u,t[31]=r,t[32]=E):E=t[32];let D;return t[33]!==x||t[34]!==T||t[35]!==E||t[36]!==h||t[37]!==_?(D=(0,H.jsxs)(`details`,{className:`${J} space-y-3`,children:[h,_,x,T,E]}),t[33]=x,t[34]=T,t[35]=E,t[36]=h,t[37]=_,t[38]=D):D=t[38],D}function ke(e){let t=(0,R.c)(15),{activationId:n,presentationId:r,zh:i}=e,a=E(`/presentations/${encodeURIComponent(r)}`,z);if(a.error){let e;return t[0]===a.error?e=t[1]:(e=(0,H.jsx)(Q,{error:a.error}),t[0]=a.error,t[1]=e),e}if(!a.data){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,H.jsx)(Z,{}),t[2]=e):e=t[2],e}if(a.data.outcome.activationId!==n){let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,H.jsx)(Q,{error:{status:404}}),t[3]=e):e=t[3],e}let o=i?`通知中的成果`:`Result from notification`,s;t[4]===o?s=t[5]:(s=(0,H.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:o}),t[4]=o,t[5]=s);let c;t[6]===a?c=t[7]:(c=()=>void a.mutate(),t[6]=a,t[7]=c);let l;t[8]!==a.data.outcome||t[9]!==c||t[10]!==i?(l=(0,H.jsx)(W,{item:a.data.outcome,zh:i,onChange:c},a.data.outcome.id),t[8]=a.data.outcome,t[9]=c,t[10]=i,t[11]=l):l=t[11];let u;return t[12]!==s||t[13]!==l?(u=(0,H.jsxs)(`section`,{className:`space-y-3`,children:[s,l]}),t[12]=s,t[13]=l,t[14]=u):u=t[14],u}function Ae({path:e,zh:t,onSaved:n,onDirty:r}){let i=E(`${e}/notes`,z,{revalidateOnFocus:!1}),[a,o]=(0,L.useState)(null),[s,c]=(0,L.useState)(!1),[l,u]=(0,L.useState)(),d=a!==null&&a.content!==i.data?.notes.content;if((0,L.useEffect)(()=>(r(d),()=>r(!1)),[d,r]),i.error)return(0,H.jsx)(Q,{error:i.error,retry:()=>void i.mutate()});if(!i.data)return(0,H.jsx)(Z,{});let f=async t=>{t.preventDefault(),c(!0),u(void 0);try{let{content:t,revision:r,validUntil:s}=a??i.data.notes,c=await B(`${e}/notes`,`PATCH`,{expectedRevision:r,content:t,validUntil:s});await i.mutate({notes:{content:t.trim(),revision:c.revision,validUntil:s}},{revalidate:!1}),o(null),n()}catch(e){u(e)}finally{c(!1)}};return(0,H.jsxs)(`form`,{onSubmit:e=>void f(e),className:`${J} space-y-3`,children:[(0,H.jsxs)(`label`,{className:Y,children:[t?`你愿意提供的安排和约束`:`Arrangements and constraints you choose to share`,(0,H.jsx)(`textarea`,{disabled:s,rows:5,maxLength:32e3,className:q,value:a?.content??i.data.notes.content,onChange:e=>o(t=>({...t??i.data.notes,content:e.target.value})),autoComplete:`off`})]}),(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`只用于这个场景,不会因此访问其他家庭成员的数据。修改资料会撤回旧计划。`:`Used only in this scene. Does not grant access to other family members. Editing withdraws the previous plan.`}),!!l&&(0,H.jsx)(Q,{error:l}),(0,H.jsx)(O,{type:`submit`,disabled:s||!d,children:s?t?`正在保存…`:`Saving…`:t?`保存资料`:`Save context`}),d&&(0,H.jsx)(O,{type:`button`,disabled:s,variant:`ghost`,onClick:()=>{o(null),u(void 0),i.mutate()},children:t?`放弃修改并重新加载`:`Discard edits and reload`})]})}export{pe as ScenesPage};
@@ -1,64 +0,0 @@
1
- var e;function t(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var n=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},r=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(e=globalThis).__zod_globalConfig??(e.__zod_globalConfig={});var i=globalThis.__zod_globalConfig;function a(e){return e&&Object.assign(i,e),i}function o(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function s(e,t){return typeof t==`bigint`?t.toString():t}function c(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function l(e){return e==null}function u(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function d(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var f=Symbol(`evaluating`);function p(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==f)return r===void 0&&(r=f,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function m(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function h(...e){let t={};for(let n of e)Object.assign(t,Object.getOwnPropertyDescriptors(n));return Object.defineProperties({},t)}function ee(e){return JSON.stringify(e)}function te(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var ne=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function g(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var re=c(()=>{if(i.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function _(e){if(g(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(g(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function ie(e){return _(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var ae=new Set([`string`,`number`,`symbol`]);function v(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function y(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function b(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function oe(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var se={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function ce(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return y(e,h(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return m(this,`shape`,e),e},checks:[]}))}function le(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return y(e,h(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return m(this,`shape`,r),r},checks:[]}))}function ue(e,t){if(!_(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return y(e,h(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return m(this,`shape`,n),n}}))}function de(e,t){if(!_(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return y(e,h(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return m(this,`shape`,n),n}}))}function fe(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return y(e,h(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return m(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function pe(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return y(t,h(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return m(this,`shape`,i),i},checks:[]}))}function me(e,t,n){return y(t,h(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return m(this,`shape`,i),i}}))}function x(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function he(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function S(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function C(e){return typeof e==`string`?e:e?.message}function w(e,t,n){let r=e.message?e.message:C(e.inst?._zod.def?.error?.(e))??C(t?.error?.(e))??C(n.customError?.(e))??C(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function T(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function E(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var ge=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,s,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},_e=t(`$ZodError`,ge),ve=t(`$ZodError`,ge,{Parent:Error});function ye(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function be(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}var D=e=>(t,r,i,o)=>{let s=i?{...i,async:!1}:{async:!1},c=t._zod.run({value:r,issues:[]},s);if(c instanceof Promise)throw new n;if(c.issues.length){let t=new(o?.Err??e)(c.issues.map(e=>w(e,s,a())));throw ne(t,o?.callee),t}return c.value},O=e=>async(t,n,r,i)=>{let o=r?{...r,async:!0}:{async:!0},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let t=new(i?.Err??e)(s.issues.map(e=>w(e,o,a())));throw ne(t,i?.callee),t}return s.value},k=e=>(t,r,i)=>{let o=i?{...i,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new n;return s.issues.length?{success:!1,error:new(e??_e)(s.issues.map(e=>w(e,o,a())))}:{success:!0,data:s.value}},xe=k(ve),A=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(e=>w(e,i,a())))}:{success:!0,data:o.value}},Se=A(ve),Ce=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return D(e)(t,n,i)},we=e=>(t,n,r)=>D(e)(t,n,r),Te=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return O(e)(t,n,i)},Ee=e=>async(t,n,r)=>O(e)(t,n,r),De=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return k(e)(t,n,i)},Oe=e=>(t,n,r)=>k(e)(t,n,r),ke=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return A(e)(t,n,i)},Ae=e=>async(t,n,r)=>A(e)(t,n,r),je=/^[cC][0-9a-z]{6,}$/,Me=/^[0-9a-z]+$/,Ne=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Pe=/^[0-9a-vA-V]{20}$/,Fe=/^[A-Za-z0-9]{27}$/,Ie=/^[a-zA-Z0-9_-]{21}$/,Le=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Re=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,ze=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Be=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Ve=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function He(){return new RegExp(Ve,`u`)}var Ue=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,We=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Ge=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Ke=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,qe=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Je=/^[A-Za-z0-9_-]*$/,Ye=/^https?$/,Xe=/^\+[1-9]\d{6,14}$/,Ze=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,Qe=RegExp(`^${Ze}$`);function $e(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function et(e){return RegExp(`^${$e(e)}$`)}function tt(e){let t=$e({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${Ze}T(?:${r})$`)}var nt=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},rt=/^-?\d+$/,it=/^-?\d+(?:\.\d+)?$/,at=/^(?:true|false)$/i,ot=/^[^A-Z]*$/,st=/^[^a-z]*$/,j=t(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ct={number:`number`,bigint:`bigint`,object:`date`},lt=t(`$ZodCheckLessThan`,(e,t)=>{j.init(e,t);let n=ct[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ut=t(`$ZodCheckGreaterThan`,(e,t)=>{j.init(e,t);let n=ct[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),dt=t(`$ZodCheckMultipleOf`,(e,t)=>{j.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):d(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),ft=t(`$ZodCheckNumberFormat`,(e,t)=>{j.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=se[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=rt)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),pt=t(`$ZodCheckMaxLength`,(e,t)=>{var n;j.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!l(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=T(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),mt=t(`$ZodCheckMinLength`,(e,t)=>{var n;j.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!l(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=T(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ht=t(`$ZodCheckLengthEquals`,(e,t)=>{var n;j.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!l(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=T(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),M=t(`$ZodCheckStringFormat`,(e,t)=>{var n,r;j.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),gt=t(`$ZodCheckRegex`,(e,t)=>{M.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),_t=t(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=ot,M.init(e,t)}),vt=t(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=st,M.init(e,t)}),yt=t(`$ZodCheckIncludes`,(e,t)=>{j.init(e,t);let n=v(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),bt=t(`$ZodCheckStartsWith`,(e,t)=>{j.init(e,t);let n=RegExp(`^${v(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),xt=t(`$ZodCheckEndsWith`,(e,t)=>{j.init(e,t);let n=RegExp(`.*${v(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),St=t(`$ZodCheckOverwrite`,(e,t)=>{j.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Ct=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
2
- `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
3
- `))}},wt={major:4,minor:4,patch:3},N=t(`$ZodType`,(e,t)=>{var r;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=wt;let i=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&i.unshift(e);for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,r)=>{let i=x(e),a;for(let o of t){if(o._zod.def.when){if(he(e)||!o._zod.def.when(e))continue}else if(i)continue;let t=e.issues.length,s=o._zod.check(e);if(s instanceof Promise&&r?.async===!1)throw new n;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,e.issues.length!==t&&(i||=x(e,t))});else{if(e.issues.length===t)continue;i||=x(e,t)}}return a?a.then(()=>e):e},r=(r,a,o)=>{if(x(r))return r.aborted=!0,r;let s=t(a,i,o);if(s instanceof Promise){if(o.async===!1)throw new n;return s.then(t=>e._zod.parse(t,o))}return e._zod.parse(s,o)};e._zod.run=(a,o)=>{if(o.skipChecks)return e._zod.parse(a,o);if(o.direction===`backward`){let t=e._zod.parse({value:a.value,issues:[]},{...o,skipChecks:!0});return t instanceof Promise?t.then(e=>r(e,a,o)):r(t,a,o)}let s=e._zod.parse(a,o);if(s instanceof Promise){if(o.async===!1)throw new n;return s.then(e=>t(e,i,o))}return t(s,i,o)}}p(e,`~standard`,()=>({validate:t=>{try{let n=xe(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Se(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),P=t(`$ZodString`,(e,t)=>{N.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??nt(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),F=t(`$ZodStringFormat`,(e,t)=>{M.init(e,t),P.init(e,t)}),Tt=t(`$ZodGUID`,(e,t)=>{t.pattern??=Re,F.init(e,t)}),Et=t(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=ze(e)}else t.pattern??=ze();F.init(e,t)}),Dt=t(`$ZodEmail`,(e,t)=>{t.pattern??=Be,F.init(e,t)}),Ot=t(`$ZodURL`,(e,t)=>{F.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===Ye.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),kt=t(`$ZodEmoji`,(e,t)=>{t.pattern??=He(),F.init(e,t)}),At=t(`$ZodNanoID`,(e,t)=>{t.pattern??=Ie,F.init(e,t)}),jt=t(`$ZodCUID`,(e,t)=>{t.pattern??=je,F.init(e,t)}),Mt=t(`$ZodCUID2`,(e,t)=>{t.pattern??=Me,F.init(e,t)}),Nt=t(`$ZodULID`,(e,t)=>{t.pattern??=Ne,F.init(e,t)}),Pt=t(`$ZodXID`,(e,t)=>{t.pattern??=Pe,F.init(e,t)}),Ft=t(`$ZodKSUID`,(e,t)=>{t.pattern??=Fe,F.init(e,t)}),It=t(`$ZodISODateTime`,(e,t)=>{t.pattern??=tt(t),F.init(e,t)}),Lt=t(`$ZodISODate`,(e,t)=>{t.pattern??=Qe,F.init(e,t)}),Rt=t(`$ZodISOTime`,(e,t)=>{t.pattern??=et(t),F.init(e,t)}),zt=t(`$ZodISODuration`,(e,t)=>{t.pattern??=Le,F.init(e,t)}),Bt=t(`$ZodIPv4`,(e,t)=>{t.pattern??=Ue,F.init(e,t),e._zod.bag.format=`ipv4`}),Vt=t(`$ZodIPv6`,(e,t)=>{t.pattern??=We,F.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),Ht=t(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Ge,F.init(e,t)}),Ut=t(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Ke,F.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function Wt(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var Gt=t(`$ZodBase64`,(e,t)=>{t.pattern??=qe,F.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{Wt(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function Kt(e){if(!Je.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Wt(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var qt=t(`$ZodBase64URL`,(e,t)=>{t.pattern??=Je,F.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{Kt(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Jt=t(`$ZodE164`,(e,t)=>{t.pattern??=Xe,F.init(e,t)});function Yt(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var Xt=t(`$ZodJWT`,(e,t)=>{F.init(e,t),e._zod.check=n=>{Yt(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Zt=t(`$ZodNumber`,(e,t)=>{N.init(e,t),e._zod.pattern=e._zod.bag.pattern??it,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Qt=t(`$ZodNumberFormat`,(e,t)=>{ft.init(e,t),Zt.init(e,t)}),$t=t(`$ZodBoolean`,(e,t)=>{N.init(e,t),e._zod.pattern=at,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),en=t(`$ZodUnknown`,(e,t)=>{N.init(e,t),e._zod.parse=e=>e}),tn=t(`$ZodNever`,(e,t)=>{N.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function nn(e,t,n){e.issues.length&&t.issues.push(...S(n,e.issues)),t.value[n]=e.value}var rn=t(`$ZodArray`,(e,t)=>{N.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>nn(t,n,e))):nn(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function I(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...S(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function an(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=oe(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function on(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>I(e,n,i,t,u,d))):I(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var sn=t(`$ZodObject`,(e,t)=>{if(N.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=c(()=>an(t));p(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=g,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>I(n,t,e,s,r,i))):I(a,t,e,s,r,i)}return i?on(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),cn=t(`$ZodObjectJIT`,(e,t)=>{sn.init(e,t);let n=e._zod.parse,r=c(()=>an(t)),a=e=>{let t=new Ct([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=ee(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=ee(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
4
- if (${n}.issues.length) {
5
- if (${o} in input) {
6
- payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
7
- ...iss,
8
- path: iss.path ? [${o}, ...iss.path] : [${o}]
9
- })));
10
- }
11
- }
12
-
13
- if (${n}.value === undefined) {
14
- if (${o} in input) {
15
- newResult[${o}] = undefined;
16
- }
17
- } else {
18
- newResult[${o}] = ${n}.value;
19
- }
20
-
21
- `):c?t.write(`
22
- if (${n}.issues.length) {
23
- payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
24
- ...iss,
25
- path: iss.path ? [${o}, ...iss.path] : [${o}]
26
- })));
27
- }
28
-
29
- if (${n}.value === undefined) {
30
- if (${o} in input) {
31
- newResult[${o}] = undefined;
32
- }
33
- } else {
34
- newResult[${o}] = ${n}.value;
35
- }
36
-
37
- `):t.write(`
38
- const ${n}_present = ${o} in input;
39
- if (${n}.issues.length) {
40
- payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
41
- ...iss,
42
- path: iss.path ? [${o}, ...iss.path] : [${o}]
43
- })));
44
- }
45
- if (!${n}_present && !${n}.issues.length) {
46
- payload.issues.push({
47
- code: "invalid_type",
48
- expected: "nonoptional",
49
- input: undefined,
50
- path: [${o}]
51
- });
52
- }
53
-
54
- if (${n}_present) {
55
- if (${n}.value === undefined) {
56
- newResult[${o}] = undefined;
57
- } else {
58
- newResult[${o}] = ${n}.value;
59
- }
60
- }
61
-
62
- `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},o,s=g,l=!i.jitless,u=l&&re.value,d=t.catchall,f;e._zod.parse=(i,c)=>{f??=r.value;let p=i.value;return s(p)?l&&u&&c?.async===!1&&c.jitless!==!0?(o||=a(t.shape),i=o(i,c),d?on([],p,i,c,f,e):i):n(i,c):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function ln(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!x(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>w(e,r,a())))}),t)}var un=t(`$ZodUnion`,(e,t)=>{N.init(e,t),p(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),p(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),p(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),p(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>u(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>ln(t,r,e,i)):ln(o,r,e,i)}}),dn=t(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,un.init(e,t);let n=e._zod.parse;p(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=c(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!g(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),fn=t(`$ZodIntersection`,(e,t)=>{N.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>pn(e,t,n)):pn(e,i,a)}});function L(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(_(e)&&_(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=L(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=L(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function pn(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),x(e))return e;let o=L(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var mn=t(`$ZodTuple`,(e,t)=>{N.init(e,t);let n=t.items;e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({input:a,inst:e,expected:`tuple`,code:`invalid_type`}),r;r.value=[];let o=[],s=hn(n,`optin`),c=hn(n,`optout`);if(!t.rest){if(a.length<s)return r.issues.push({code:`too_small`,minimum:s,inclusive:!0,input:a,inst:e,origin:`array`}),r;a.length>n.length&&r.issues.push({code:`too_big`,maximum:n.length,inclusive:!0,input:a,inst:e,origin:`array`})}let l=Array(n.length);for(let e=0;e<n.length;e++){let t=n[e]._zod.run({value:a[e],issues:[]},i);t instanceof Promise?o.push(t.then(t=>{l[e]=t})):l[e]=t}if(t.rest){let e=n.length-1,s=a.slice(n.length);for(let n of s){e++;let a=t.rest._zod.run({value:n,issues:[]},i);a instanceof Promise?o.push(a.then(t=>gn(t,r,e))):gn(a,r,e)}}return o.length?Promise.all(o).then(()=>_n(l,r,n,a,c)):_n(l,r,n,a,c)}});function hn(e,t){for(let n=e.length-1;n>=0;n--)if(e[n]._zod[t]!==`optional`)return n+1;return 0}function gn(e,t,n){e.issues.length&&t.issues.push(...S(n,e.issues)),t.value[n]=e.value}function _n(e,t,n,r,i){for(let a=0;a<n.length;a++){let n=e[a],o=a<r.length;if(n.issues.length){if(!o&&a>=i){t.value.length=a;break}t.issues.push(...S(a,n.issues))}t.value[a]=n.value}for(let e=t.value.length-1;e>=r.length&&n[e]._zod.optout===`optional`&&t.value[e]===void 0;e--)t.value.length=e;return t}var vn=t(`$ZodRecord`,(e,t)=>{N.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!_(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let o=[],s=t.keyType._zod.values;if(s){n.value={};let c=new Set;for(let l of s)if(typeof l==`string`||typeof l==`number`||typeof l==`symbol`){c.add(typeof l==`number`?l.toString():l);let s=t.keyType._zod.run({value:l,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>w(e,r,a())),input:l,path:[l],inst:e});continue}let u=s.value,d=t.valueType._zod.run({value:i[l],issues:[]},r);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&n.issues.push(...S(l,e.issues)),n.value[u]=e.value})):(d.issues.length&&n.issues.push(...S(l,d.issues)),n.value[u]=d.value)}let l;for(let e in i)c.has(e)||(l??=[],l.push(e));l&&l.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:l})}else{n.value={};for(let s of Reflect.ownKeys(i)){if(s===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,s))continue;let c=t.keyType._zod.run({value:s,issues:[]},r);if(c instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof s==`string`&&it.test(s)&&c.issues.length){let e=t.keyType._zod.run({value:Number(s),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(c=e)}if(c.issues.length){t.mode===`loose`?n.value[s]=i[s]:n.issues.push({code:`invalid_key`,origin:`record`,issues:c.issues.map(e=>w(e,r,a())),input:s,path:[s],inst:e});continue}let l=t.valueType._zod.run({value:i[s],issues:[]},r);l instanceof Promise?o.push(l.then(e=>{e.issues.length&&n.issues.push(...S(s,e.issues)),n.value[c.value]=e.value})):(l.issues.length&&n.issues.push(...S(s,l.issues)),n.value[c.value]=l.value)}}return o.length?Promise.all(o).then(()=>n):n}}),yn=t(`$ZodEnum`,(e,t)=>{N.init(e,t);let n=o(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>ae.has(typeof e)).map(e=>typeof e==`string`?v(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),bn=t(`$ZodLiteral`,(e,t)=>{if(N.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?v(e):e?v(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),xn=t(`$ZodTransform`,(e,t)=>{N.init(e,t),e._zod.optin=`optional`,e._zod.parse=(i,a)=>{if(a.direction===`backward`)throw new r(e.constructor.name);let o=t.transform(i.value,i);if(a.async)return(o instanceof Promise?o:Promise.resolve(o)).then(e=>(i.value=e,i.fallback=!0,i));if(o instanceof Promise)throw new n;return i.value=o,i.fallback=!0,i}});function Sn(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Cn=t(`$ZodOptional`,(e,t)=>{N.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,p(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),p(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${u(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>Sn(e,r)):Sn(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),wn=t(`$ZodExactOptional`,(e,t)=>{Cn.init(e,t),p(e._zod,`values`,()=>t.innerType._zod.values),p(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Tn=t(`$ZodNullable`,(e,t)=>{N.init(e,t),p(e._zod,`optin`,()=>t.innerType._zod.optin),p(e._zod,`optout`,()=>t.innerType._zod.optout),p(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${u(e.source)}|null)$`):void 0}),p(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),En=t(`$ZodDefault`,(e,t)=>{N.init(e,t),e._zod.optin=`optional`,p(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Dn(e,t)):Dn(r,t)}});function Dn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var On=t(`$ZodPrefault`,(e,t)=>{N.init(e,t),e._zod.optin=`optional`,p(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),kn=t(`$ZodNonOptional`,(e,t)=>{N.init(e,t),p(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>An(t,e)):An(i,e)}});function An(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var jn=t(`$ZodCatch`,(e,t)=>{N.init(e,t),e._zod.optin=`optional`,p(e._zod,`optout`,()=>t.innerType._zod.optout),p(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>w(e,n,a()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>w(e,n,a()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Mn=t(`$ZodPipe`,(e,t)=>{N.init(e,t),p(e._zod,`values`,()=>t.in._zod.values),p(e._zod,`optin`,()=>t.in._zod.optin),p(e._zod,`optout`,()=>t.out._zod.optout),p(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>R(e,t.in,n)):R(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>R(e,t.out,n)):R(r,t.out,n)}});function R(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var Nn=t(`$ZodReadonly`,(e,t)=>{N.init(e,t),p(e._zod,`propValues`,()=>t.innerType._zod.propValues),p(e._zod,`values`,()=>t.innerType._zod.values),p(e._zod,`optin`,()=>t.innerType?._zod?.optin),p(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Pn):Pn(r)}});function Pn(e){return e.value=Object.freeze(e.value),e}var Fn=t(`$ZodCustom`,(e,t)=>{j.init(e,t),N.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>In(t,n,r,e));In(i,n,r,e)}});function In(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(E(e))}}var Ln,Rn=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function zn(){return new Rn}(Ln=globalThis).__zod_globalRegistry??(Ln.__zod_globalRegistry=zn());var z=globalThis.__zod_globalRegistry;function Bn(e,t){return new e({type:`string`,...b(t)})}function Vn(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...b(t)})}function Hn(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...b(t)})}function Un(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...b(t)})}function Wn(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...b(t)})}function Gn(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...b(t)})}function Kn(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...b(t)})}function qn(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...b(t)})}function Jn(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...b(t)})}function Yn(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...b(t)})}function Xn(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...b(t)})}function Zn(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...b(t)})}function Qn(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...b(t)})}function $n(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...b(t)})}function er(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...b(t)})}function tr(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...b(t)})}function nr(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...b(t)})}function rr(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...b(t)})}function ir(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...b(t)})}function ar(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...b(t)})}function or(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...b(t)})}function sr(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...b(t)})}function cr(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...b(t)})}function lr(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...b(t)})}function ur(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...b(t)})}function dr(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...b(t)})}function fr(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...b(t)})}function pr(e,t){return new e({type:`number`,checks:[],...b(t)})}function mr(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...b(t)})}function hr(e,t){return new e({type:`boolean`,...b(t)})}function gr(e){return new e({type:`unknown`})}function _r(e,t){return new e({type:`never`,...b(t)})}function vr(e,t){return new lt({check:`less_than`,...b(t),value:e,inclusive:!1})}function B(e,t){return new lt({check:`less_than`,...b(t),value:e,inclusive:!0})}function yr(e,t){return new ut({check:`greater_than`,...b(t),value:e,inclusive:!1})}function V(e,t){return new ut({check:`greater_than`,...b(t),value:e,inclusive:!0})}function br(e,t){return new dt({check:`multiple_of`,...b(t),value:e})}function xr(e,t){return new pt({check:`max_length`,...b(t),maximum:e})}function H(e,t){return new mt({check:`min_length`,...b(t),minimum:e})}function Sr(e,t){return new ht({check:`length_equals`,...b(t),length:e})}function Cr(e,t){return new gt({check:`string_format`,format:`regex`,...b(t),pattern:e})}function wr(e){return new _t({check:`string_format`,format:`lowercase`,...b(e)})}function Tr(e){return new vt({check:`string_format`,format:`uppercase`,...b(e)})}function Er(e,t){return new yt({check:`string_format`,format:`includes`,...b(t),includes:e})}function Dr(e,t){return new bt({check:`string_format`,format:`starts_with`,...b(t),prefix:e})}function Or(e,t){return new xt({check:`string_format`,format:`ends_with`,...b(t),suffix:e})}function U(e){return new St({check:`overwrite`,tx:e})}function kr(e){return U(t=>t.normalize(e))}function Ar(){return U(e=>e.trim())}function jr(){return U(e=>e.toLowerCase())}function Mr(){return U(e=>e.toUpperCase())}function Nr(){return U(e=>te(e))}function Pr(e,t,n){return new e({type:`array`,element:t,...b(n)})}function Fr(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...b(n)})}function Ir(e,t){let n=Lr(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(E(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(E(r))}},e(t.value,t)),t);return n}function Lr(e,t){let n=new j({check:`custom`,...b(t)});return n._zod.check=e,n}function Rr(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??z,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function W(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,W(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&G(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function zr(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
63
-
64
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Br(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:K(t,`input`,e.processors),output:K(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function G(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return G(r.element,n);if(r.type===`set`)return G(r.valueType,n);if(r.type===`lazy`)return G(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return G(r.innerType,n);if(r.type===`intersection`)return G(r.left,n)||G(r.right,n);if(r.type===`record`||r.type===`map`)return G(r.keyType,n)||G(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:G(r.in,n)||G(r.out,n);if(r.type===`object`){for(let e in r.shape)if(G(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(G(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(G(e,n))return!0;return!!(r.rest&&G(r.rest,n))}return!1}var Vr=(e,t={})=>n=>{let r=Rr({...n,processors:t});return W(e,r),zr(r,e),Br(r,e)},K=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Rr({...i??{},target:a,io:t,processors:n});return W(e,o),zr(o,e),Br(o,e)},Hr={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Ur=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Hr[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Wr=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},Gr=(e,t,n,r)=>{n.type=`boolean`},Kr=(e,t,n,r)=>{n.not={}},qr=(e,t,n,r)=>{let i=e._zod.def,a=o(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Jr=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},Yr=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Xr=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Zr=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=W(a.element,t,{...r,path:[...r.path,`items`]})},Qr=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=W(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=W(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},$r=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>W(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},ei=(e,t,n,r)=>{let i=e._zod.def,a=W(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=W(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},ti=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>W(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?W(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:d}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof d==`number`&&(i.maxItems=d)},ni=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=W(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=W(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=W(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},ri=(e,t,n,r)=>{let i=e._zod.def,a=W(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},ii=(e,t,n,r)=>{let i=e._zod.def;W(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ai=(e,t,n,r)=>{let i=e._zod.def;W(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},oi=(e,t,n,r)=>{let i=e._zod.def;W(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},si=(e,t,n,r)=>{let i=e._zod.def;W(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},ci=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;W(o,t,r);let s=t.seen.get(e);s.ref=o},li=(e,t,n,r)=>{let i=e._zod.def;W(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},ui=(e,t,n,r)=>{let i=e._zod.def;W(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},di=t(`ZodISODateTime`,(e,t)=>{It.init(e,t),X.init(e,t)});function fi(e){return lr(di,e)}var pi=t(`ZodISODate`,(e,t)=>{Lt.init(e,t),X.init(e,t)});function mi(e){return ur(pi,e)}var hi=t(`ZodISOTime`,(e,t)=>{Rt.init(e,t),X.init(e,t)});function gi(e){return dr(hi,e)}var _i=t(`ZodISODuration`,(e,t)=>{zt.init(e,t),X.init(e,t)});function vi(e){return fr(_i,e)}var q=t(`ZodError`,(e,t)=>{_e.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>be(e,t)},flatten:{value:t=>ye(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,s,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,s,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),yi=D(q),bi=O(q),xi=k(q),Si=A(q),Ci=Ce(q),wi=we(q),Ti=Te(q),Ei=Ee(q),Di=De(q),Oi=Oe(q),ki=ke(q),Ai=Ae(q),ji=new WeakMap;function J(e,t,n){let r=Object.getPrototypeOf(e),i=ji.get(r);if(i||(i=new Set,ji.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var Y=t(`ZodType`,(e,t)=>(N.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:K(e,`input`),output:K(e,`output`)}}),e.toJSONSchema=Vr(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>yi(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>xi(e,t,n),e.parseAsync=async(t,n)=>bi(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Si(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Ci(e,t,n),e.decode=(t,n)=>wi(e,t,n),e.encodeAsync=async(t,n)=>Ti(e,t,n),e.decodeAsync=async(t,n)=>Ei(e,t,n),e.safeEncode=(t,n)=>Di(e,t,n),e.safeDecode=(t,n)=>Oi(e,t,n),e.safeEncodeAsync=async(t,n)=>ki(e,t,n),e.safeDecodeAsync=async(t,n)=>Ai(e,t,n),J(e,`ZodType`,{check(...e){let t=this.def;return this.clone(h(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return y(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Ja(e,t))},superRefine(e,t){return this.check(Ya(e,t))},overwrite(e){return this.check(U(e))},optional(){return Aa(this)},exactOptional(){return Ma(this)},nullable(){return Pa(this)},nullish(){return Aa(Pa(this))},nonoptional(e){return Ba(this,e)},array(){return ua(this)},or(e){return ha([this,e])},and(e){return ya(this,e)},transform(e){return Wa(this,Oa(e))},default(e){return Ia(this,e)},prefault(e){return Ra(this,e)},catch(e){return Ha(this,e)},pipe(e){return Wa(this,e)},readonly(){return Ka(this)},describe(e){let t=this.clone();return z.add(t,{description:e}),t},meta(...e){if(e.length===0)return z.get(this);let t=this.clone();return z.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return z.get(e)?.description},configurable:!0}),e)),Mi=t(`_ZodString`,(e,t)=>{P.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ur(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,J(e,`_ZodString`,{regex(...e){return this.check(Cr(...e))},includes(...e){return this.check(Er(...e))},startsWith(...e){return this.check(Dr(...e))},endsWith(...e){return this.check(Or(...e))},min(...e){return this.check(H(...e))},max(...e){return this.check(xr(...e))},length(...e){return this.check(Sr(...e))},nonempty(...e){return this.check(H(1,...e))},lowercase(e){return this.check(wr(e))},uppercase(e){return this.check(Tr(e))},trim(){return this.check(Ar())},normalize(...e){return this.check(kr(...e))},toLowerCase(){return this.check(jr())},toUpperCase(){return this.check(Mr())},slugify(){return this.check(Nr())}})}),Ni=t(`ZodString`,(e,t)=>{P.init(e,t),Mi.init(e,t),e.email=t=>e.check(Vn(Fi,t)),e.url=t=>e.check(qn(Ri,t)),e.jwt=t=>e.check(cr($i,t)),e.emoji=t=>e.check(Jn(zi,t)),e.guid=t=>e.check(Hn(Ii,t)),e.uuid=t=>e.check(Un(Z,t)),e.uuidv4=t=>e.check(Wn(Z,t)),e.uuidv6=t=>e.check(Gn(Z,t)),e.uuidv7=t=>e.check(Kn(Z,t)),e.nanoid=t=>e.check(Yn(Bi,t)),e.guid=t=>e.check(Hn(Ii,t)),e.cuid=t=>e.check(Xn(Vi,t)),e.cuid2=t=>e.check(Zn(Hi,t)),e.ulid=t=>e.check(Qn(Ui,t)),e.base64=t=>e.check(ar(Xi,t)),e.base64url=t=>e.check(or(Zi,t)),e.xid=t=>e.check($n(Wi,t)),e.ksuid=t=>e.check(er(Gi,t)),e.ipv4=t=>e.check(tr(Ki,t)),e.ipv6=t=>e.check(nr(qi,t)),e.cidrv4=t=>e.check(rr(Ji,t)),e.cidrv6=t=>e.check(ir(Yi,t)),e.e164=t=>e.check(sr(Qi,t)),e.datetime=t=>e.check(fi(t)),e.date=t=>e.check(mi(t)),e.time=t=>e.check(gi(t)),e.duration=t=>e.check(vi(t))});function Pi(e){return Bn(Ni,e)}var X=t(`ZodStringFormat`,(e,t)=>{F.init(e,t),Mi.init(e,t)}),Fi=t(`ZodEmail`,(e,t)=>{Dt.init(e,t),X.init(e,t)}),Ii=t(`ZodGUID`,(e,t)=>{Tt.init(e,t),X.init(e,t)}),Z=t(`ZodUUID`,(e,t)=>{Et.init(e,t),X.init(e,t)});function Li(e){return Un(Z,e)}var Ri=t(`ZodURL`,(e,t)=>{Ot.init(e,t),X.init(e,t)}),zi=t(`ZodEmoji`,(e,t)=>{kt.init(e,t),X.init(e,t)}),Bi=t(`ZodNanoID`,(e,t)=>{At.init(e,t),X.init(e,t)}),Vi=t(`ZodCUID`,(e,t)=>{jt.init(e,t),X.init(e,t)}),Hi=t(`ZodCUID2`,(e,t)=>{Mt.init(e,t),X.init(e,t)}),Ui=t(`ZodULID`,(e,t)=>{Nt.init(e,t),X.init(e,t)}),Wi=t(`ZodXID`,(e,t)=>{Pt.init(e,t),X.init(e,t)}),Gi=t(`ZodKSUID`,(e,t)=>{Ft.init(e,t),X.init(e,t)}),Ki=t(`ZodIPv4`,(e,t)=>{Bt.init(e,t),X.init(e,t)}),qi=t(`ZodIPv6`,(e,t)=>{Vt.init(e,t),X.init(e,t)}),Ji=t(`ZodCIDRv4`,(e,t)=>{Ht.init(e,t),X.init(e,t)}),Yi=t(`ZodCIDRv6`,(e,t)=>{Ut.init(e,t),X.init(e,t)}),Xi=t(`ZodBase64`,(e,t)=>{Gt.init(e,t),X.init(e,t)}),Zi=t(`ZodBase64URL`,(e,t)=>{qt.init(e,t),X.init(e,t)}),Qi=t(`ZodE164`,(e,t)=>{Jt.init(e,t),X.init(e,t)}),$i=t(`ZodJWT`,(e,t)=>{Xt.init(e,t),X.init(e,t)}),ea=t(`ZodNumber`,(e,t)=>{Zt.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wr(e,t,n,r),J(e,`ZodNumber`,{gt(e,t){return this.check(yr(e,t))},gte(e,t){return this.check(V(e,t))},min(e,t){return this.check(V(e,t))},lt(e,t){return this.check(vr(e,t))},lte(e,t){return this.check(B(e,t))},max(e,t){return this.check(B(e,t))},int(e){return this.check(ra(e))},safe(e){return this.check(ra(e))},positive(e){return this.check(yr(0,e))},nonnegative(e){return this.check(V(0,e))},negative(e){return this.check(vr(0,e))},nonpositive(e){return this.check(B(0,e))},multipleOf(e,t){return this.check(br(e,t))},step(e,t){return this.check(br(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function ta(e){return pr(ea,e)}var na=t(`ZodNumberFormat`,(e,t)=>{Qt.init(e,t),ea.init(e,t)});function ra(e){return mr(na,e)}var ia=t(`ZodBoolean`,(e,t)=>{$t.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gr(e,t,n,r)});function aa(e){return hr(ia,e)}var oa=t(`ZodUnknown`,(e,t)=>{en.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Q(){return gr(oa)}var sa=t(`ZodNever`,(e,t)=>{tn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Kr(e,t,n,r)});function ca(e){return _r(sa,e)}var la=t(`ZodArray`,(e,t)=>{rn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zr(e,t,n,r),e.element=t.element,J(e,`ZodArray`,{min(e,t){return this.check(H(e,t))},nonempty(e){return this.check(H(1,e))},max(e,t){return this.check(xr(e,t))},length(e,t){return this.check(Sr(e,t))},unwrap(){return this.element}})});function ua(e,t){return Pr(la,e,t)}var da=t(`ZodObject`,(e,t)=>{cn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qr(e,t,n,r),p(e,`shape`,()=>t.shape),J(e,`ZodObject`,{keyof(){return wa(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Q()})},loose(){return this.clone({...this._zod.def,catchall:Q()})},strict(){return this.clone({...this._zod.def,catchall:ca()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return ue(this,e)},safeExtend(e){return de(this,e)},merge(e){return fe(this,e)},pick(e){return ce(this,e)},omit(e){return le(this,e)},partial(...e){return pe(ka,this,e[0])},required(...e){return me(za,this,e[0])}})});function fa(e,t){return new da({type:`object`,shape:e??{},...b(t)})}function pa(e,t){return new da({type:`object`,shape:e,catchall:ca(),...b(t)})}var ma=t(`ZodUnion`,(e,t)=>{un.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$r(e,t,n,r),e.options=t.options});function ha(e,t){return new ma({type:`union`,options:e,...b(t)})}var ga=t(`ZodDiscriminatedUnion`,(e,t)=>{ma.init(e,t),dn.init(e,t)});function _a(e,t,n){return new ga({type:`union`,options:t,discriminator:e,...b(n)})}var va=t(`ZodIntersection`,(e,t)=>{fn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ei(e,t,n,r)});function ya(e,t){return new va({type:`intersection`,left:e,right:t})}var ba=t(`ZodTuple`,(e,t)=>{mn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ti(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})});function xa(e,t,n){let r=t instanceof N;return new ba({type:`tuple`,items:e,rest:r?t:null,...b(r?n:t)})}var Sa=t(`ZodRecord`,(e,t)=>{vn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ni(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Ca(e,t,n){return!t||!t._zod?new Sa({type:`record`,keyType:Pi(),valueType:e,...b(t)}):new Sa({type:`record`,keyType:e,valueType:t,...b(n)})}var $=t(`ZodEnum`,(e,t)=>{yn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qr(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new $({...t,checks:[],...b(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new $({...t,checks:[],...b(r),entries:i})}});function wa(e,t){return new $({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...b(t)})}var Ta=t(`ZodLiteral`,(e,t)=>{bn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jr(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Ea(e,t){return new Ta({type:`literal`,values:Array.isArray(e)?e:[e],...b(t)})}var Da=t(`ZodTransform`,(e,t)=>{xn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xr(e,t,n,r),e._zod.parse=(n,i)=>{if(i.direction===`backward`)throw new r(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(E(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(E(t))}};let a=t.transform(n.value,n);return a instanceof Promise?a.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=a,n.fallback=!0,n)}});function Oa(e){return new Da({type:`transform`,transform:e})}var ka=t(`ZodOptional`,(e,t)=>{Cn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ui(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Aa(e){return new ka({type:`optional`,innerType:e})}var ja=t(`ZodExactOptional`,(e,t)=>{wn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ui(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ma(e){return new ja({type:`optional`,innerType:e})}var Na=t(`ZodNullable`,(e,t)=>{Tn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ri(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Pa(e){return new Na({type:`nullable`,innerType:e})}var Fa=t(`ZodDefault`,(e,t)=>{En.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ai(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Ia(e,t){return new Fa({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():ie(t)}})}var La=t(`ZodPrefault`,(e,t)=>{On.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ra(e,t){return new La({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():ie(t)}})}var za=t(`ZodNonOptional`,(e,t)=>{kn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ii(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ba(e,t){return new za({type:`nonoptional`,innerType:e,...b(t)})}var Va=t(`ZodCatch`,(e,t)=>{jn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>si(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ha(e,t){return new Va({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Ua=t(`ZodPipe`,(e,t)=>{Mn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ci(e,t,n,r),e.in=t.in,e.out=t.out});function Wa(e,t){return new Ua({type:`pipe`,in:e,out:t})}var Ga=t(`ZodReadonly`,(e,t)=>{Nn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>li(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ka(e){return new Ga({type:`readonly`,innerType:e})}var qa=t(`ZodCustom`,(e,t)=>{Fn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yr(e,t,n,r)});function Ja(e,t={}){return Fr(qa,e,t)}function Ya(e,t){return Ir(e,t)}export{Ea as a,Ca as c,xa as d,ha as f,fi as h,_a as i,pa as l,Li as m,ua as n,ta as o,Q as p,aa as r,fa as s,wa as t,Pi as u};
@@ -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{g as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{n as a,r as o}from"./popover-select-B-GDnZO9.js";import{t as s}from"./download-Dk-ZjtO6.js";import{t as c}from"./plus-Q2yW6OE7.js";import{t as l}from"./x-B_N4OPjy.js";import{t as u}from"./cn-JdwAhgNB.js";import{a as d,c as f,n as p,r as m}from"./locale-store-vZTDIqJB.js";import{t as h}from"./messages-CRH2my19.js";import{a as g,n as _,o as v,r as y,s as ee,t as te}from"./dist-BGTk37IG.js";import{i as ne}from"./vendor-swr-BIWyz7Rc.js";import{t as b}from"./button-CS04eWY9.js";import{n as x,r as S}from"./gateway-config-swr-D7SG_ECs.js";import{t as C}from"./skeleton-BwbyijEw.js";import{i as w,o as T}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as E,t as D}from"./registry-api-CF-nJ5MG.js";import{Ca as O,Cl as k,Ec as A,El as j,F as M,Hc as re,It as N,Lt as P,Qu as F,Sc as I,To as L,Vc as R,Ws as z,Zu as ie,_a as B,ba as V,bs as H,cu as U,ea as ae,ga as oe,ha as se,il as ce,ma as W,na as le,nl as ue,pa as de,ql as fe,si as G,ta as K,tc as pe,ua as me,va as he,wa as ge,wl as _e,xa as ve,xu as ye,ya as be,ys as q}from"./index-Ah5XDhOL.js";import{n as xe,r as Se}from"./settings-page-layout-B39PogyD.js";import{n as Ce,t as J}from"./settings-form-section-kIV5M-9G.js";import{n as Y,t as we}from"./use-autosave-CkEM9tXu.js";import{t as Te}from"./page-tabs-nARdLZcP.js";import{t as Ee}from"./settings-advanced-gate-Cx_uvwqz.js";var X=e(t(),1),De=n(),Z=r();function Oe(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 ke(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Ae(e){let t=(0,De.c)(113),{session:n,variant:r,labels:i,sessionAgentId:a,sessionAgentAvatar:o,onOpen:c,onAction:l}=e,d;t[0]!==i.unnamedSession||t[1]!==n.name?(d=n.name?.trim()||i.unnamedSession,t[0]=i.unnamedSession,t[1]=n.name,t[2]=d):d=t[2];let f=d,m=p(Pe),g;t[3]!==m||t[4]!==n?(g=W(n,h(m).sidebar.sessionFilters),t[3]=m,t[4]=n,t[5]=g):g=t[5];let _=g,v;t[6]===n.name?v=t[7]:(v=n.name?.trim(),t[6]=n.name,t[7]=v);let y=!!v,ee=n.status===`archived`,te=n.status===`pinned`,ne=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,b;t[8]===ne?b=t[9]:(b=u(`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`,ne),t[8]=ne,t[9]=b);let x;t[10]===c?x=t[11]:(x=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},t[10]=c,t[11]=x);let S=r===`list`&&`sm:py-3`,C;t[12]===S?C=t[13]:(C=u(`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[12]=S,t[13]=C);let w;t[14]===n?w=t[15]:(w=(0,Z.jsx)(de,{sourceChannel:n.sourceChannel,session:n,className:`size-3.5`}),t[14]=n,t[15]=w);let T;t[16]===_?T=t[17]:(T=(0,Z.jsx)(`span`,{className:`truncate text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:_}),t[16]=_,t[17]=T);let E;t[18]!==T||t[19]!==w?(E=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[w,T]}),t[18]=T,t[19]=w,t[20]=E):E=t[20];let D;t[21]===te?D=t[22]:(D=te?(0,Z.jsx)(re,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[21]=te,t[22]=D);let O;t[23]===n.updatedAt?O=t[24]:(O=Oe(n.updatedAt),t[23]=n.updatedAt,t[24]=O);let k;t[25]===O?k=t[26]:(k=(0,Z.jsx)(`span`,{children:O}),t[25]=O,t[26]=k);let A;t[27]!==D||t[28]!==k?(A=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,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]!==C?(j=(0,Z.jsxs)(`div`,{className:C,children:[E,A]}),t[30]=E,t[31]=A,t[32]=C,t[33]=j):j=t[33];let N=r===`list`&&`sm:py-3`,P;t[34]===N?P=t[35]:(P=u(`min-w-0 flex-1 px-3 py-2`,N),t[34]=N,t[35]=P);let I=r===`list`&&`sm:items-start`,L;t[36]===I?L=t[37]:(L=u(`flex gap-3`,I),t[36]=I,t[37]=L);let B;t[38]!==o||t[39]!==a?(B=(0,Z.jsx)(M,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}),t[38]=o,t[39]=a,t[40]=B):B=t[40];let V;t[41]===f?V=t[42]:(V=(0,Z.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:f,children:f}),t[41]=f,t[42]=V);let H;t[43]!==n.key||t[44]!==y?(H=y?(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[43]=n.key,t[44]=y,t[45]=H):H=t[45];let U;t[46]!==V||t[47]!==H?(U=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[V,H]}),t[46]=V,t[47]=H,t[48]=U):U=t[48];let ae;t[49]!==L||t[50]!==B||t[51]!==U?(ae=(0,Z.jsxs)(`div`,{className:L,children:[B,U]}),t[49]=L,t[50]=B,t[51]=U,t[52]=ae):ae=t[52];let oe;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,Z.jsx)(ce,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[53]=oe):oe=t[53];let se;t[54]===n.messageCount?se=t[55]:(se=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[oe,n.messageCount]}),t[54]=n.messageCount,t[55]=se);let le;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,Z.jsx)(z,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[56]=le):le=t[56];let ue;t[57]===n.estimatedTokens?ue=t[58]:(ue=ke(n.estimatedTokens),t[57]=n.estimatedTokens,t[58]=ue);let fe;t[59]===ue?fe=t[60]:(fe=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[le,ue]}),t[59]=ue,t[60]=fe);let G;t[61]!==se||t[62]!==fe?(G=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[se,fe]}),t[61]=se,t[62]=fe,t[63]=G):G=t[63];let K;t[64]===n.tags?K=t[65]:(K=n.tags.length>0?(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(Ne),n.tags.length>3?(0,Z.jsxs)(`span`,{className:`text-[11px] text-fg-disabled`,children:[`+`,n.tags.length-3]}):null]}):null,t[64]=n.tags,t[65]=K);let me;t[66]!==P||t[67]!==ae||t[68]!==G||t[69]!==K?(me=(0,Z.jsxs)(`div`,{className:P,children:[ae,G,K]}),t[66]=P,t[67]=ae,t[68]=G,t[69]=K,t[70]=me):me=t[70];let he;t[71]===l?he=t[72]:(he=()=>l(`continue`),t[71]=l,t[72]=he);let ge;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,Z.jsx)(ce,{className:`size-4`,strokeWidth:1.75}),t[73]=ge):ge=t[73];let _e;t[74]!==i.continueChat||t[75]!==he?(_e=(0,Z.jsx)(`button`,{type:`button`,className:q,title:i.continueChat,"aria-label":i.continueChat,onClick:he,children:ge}),t[74]=i.continueChat,t[75]=he,t[76]=_e):_e=t[76];let ve;t[77]!==ee||t[78]!==i.archive||t[79]!==i.unarchive||t[80]!==l?(ve=ee?(0,Z.jsx)(`button`,{type:`button`,className:q,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>l(`unarchive`),children:(0,Z.jsx)(F,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:q,title:i.archive,"aria-label":i.archive,onClick:()=>l(`archive`),children:(0,Z.jsx)(ie,{className:`size-4`,strokeWidth:1.75})}),t[77]=ee,t[78]=i.archive,t[79]=i.unarchive,t[80]=l,t[81]=ve):ve=t[81];let ye;t[82]!==te||t[83]!==i.pin||t[84]!==i.unpin||t[85]!==l?(ye=te?(0,Z.jsx)(`button`,{type:`button`,className:q,title:i.unpin,"aria-label":i.unpin,onClick:()=>l(`unpin`),children:(0,Z.jsx)(R,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:q,title:i.pin,"aria-label":i.pin,onClick:()=>l(`pin`),children:(0,Z.jsx)(re,{className:`size-4`,strokeWidth:1.75})}),t[82]=te,t[83]=i.pin,t[84]=i.unpin,t[85]=l,t[86]=ye):ye=t[86];let be;t[87]===l?be=t[88]:(be=()=>l(`export`),t[87]=l,t[88]=be);let xe;t[89]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,Z.jsx)(s,{className:`size-4`,strokeWidth:1.75}),t[89]=xe):xe=t[89];let Se;t[90]!==i.export||t[91]!==be?(Se=(0,Z.jsx)(`button`,{type:`button`,className:q,title:i.export,"aria-label":i.export,onClick:be,children:xe}),t[90]=i.export,t[91]=be,t[92]=Se):Se=t[92];let Ce;t[93]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=u(q,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[93]=Ce):Ce=t[93];let J;t[94]===l?J=t[95]:(J=()=>l(`delete`),t[94]=l,t[95]=J);let Y;t[96]===Symbol.for(`react.memo_cache_sentinel`)?(Y=(0,Z.jsx)(pe,{className:`size-4`,strokeWidth:1.75}),t[96]=Y):Y=t[96];let we;t[97]!==i.delete||t[98]!==J?(we=(0,Z.jsx)(`button`,{type:`button`,className:Ce,title:i.delete,"aria-label":i.delete,onClick:J,children:Y}),t[97]=i.delete,t[98]=J,t[99]=we):we=t[99];let Te;t[100]!==_e||t[101]!==ve||t[102]!==ye||t[103]!==Se||t[104]!==we?(Te=(0,Z.jsxs)(`div`,{role:`group`,className:`m-1 mt-0 flex flex-wrap items-center gap-0.5 rounded-lg bg-surface-hover/35 p-1.5`,onClick:Me,onKeyDown:je,children:[_e,ve,ye,Se,we]}),t[100]=_e,t[101]=ve,t[102]=ye,t[103]=Se,t[104]=we,t[105]=Te):Te=t[105];let Ee;return t[106]!==c||t[107]!==j||t[108]!==me||t[109]!==Te||t[110]!==b||t[111]!==x?(Ee=(0,Z.jsxs)(`div`,{role:`button`,tabIndex:0,className:b,onClick:c,onKeyDown:x,children:[j,me,Te]}),t[106]=c,t[107]=j,t[108]=me,t[109]=Te,t[110]=b,t[111]=x,t[112]=Ee):Ee=t[112],Ee}function je(e){return e.stopPropagation()}function Me(e){return e.stopPropagation()}function Ne(e){return(0,Z.jsx)(`span`,{className:`max-w-full break-words rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e},e)}function Pe(e){return e.language}function Fe(e,t){return e.routing?.agentId?.trim().toLowerCase()||t.trim().toLowerCase()||`main`}function Ie(e,t){return t.find(t=>t.id===e)?.avatar}var Le={enabled:!0,triggerThreshold:.8,reserveTokens:8192,minMessagesBeforeCompact:10,keepRecentTokens:2e4,recentTurnsPreserve:3,summaryMaxTokens:16e3,summaryChunkTokens:24e3,summaryTimeoutMs:18e4,summaryRetries:2,qualityGuard:!0,gapAudit:!0,minToolResultKeepChars:1e3,maxActiveTranscriptBytes:2e6,postCompactionSections:[`Session Startup`,`Red Lines`]};function Re(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ze(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 Be(e){let t=Re(e)?e:{},n=Re(t.userContext)?t.userContext:{},r=Re(n.contextPlanning)?n.contextPlanning:{},i=Re(r.compaction)?r.compaction:{},a=Le,o=typeof i.model==`string`&&i.model.trim()?i.model.trim():void 0,s=Array.isArray(i.postCompactionSections)&&i.postCompactionSections.length<=12&&i.postCompactionSections.every(e=>typeof e==`string`&&e.trim())?[...new Set(i.postCompactionSections.map(e=>e.trim()))]:[...a.postCompactionSections];return{enabled:typeof i.enabled==`boolean`?i.enabled:a.enabled,triggerThreshold:ze(i.triggerThreshold,a.triggerThreshold,.1,.98),reserveTokens:Q(i.reserveTokens,a.reserveTokens,1024),minMessagesBeforeCompact:Q(i.minMessagesBeforeCompact,a.minMessagesBeforeCompact,2),keepRecentTokens:Q(i.keepRecentTokens,a.keepRecentTokens,1e3),recentTurnsPreserve:Q(i.recentTurnsPreserve,a.recentTurnsPreserve,1,12),summaryMaxTokens:Q(i.summaryMaxTokens,a.summaryMaxTokens,256),summaryChunkTokens:Q(i.summaryChunkTokens,a.summaryChunkTokens,1e3),summaryTimeoutMs:Q(i.summaryTimeoutMs,a.summaryTimeoutMs,1e3,6e5),summaryRetries:Q(i.summaryRetries,a.summaryRetries,0,5),qualityGuard:typeof i.qualityGuard==`boolean`?i.qualityGuard:a.qualityGuard,gapAudit:typeof i.gapAudit==`boolean`?i.gapAudit:a.gapAudit,...o?{model:o}:{},minToolResultKeepChars:Q(i.minToolResultKeepChars,a.minToolResultKeepChars,200),maxActiveTranscriptBytes:Q(i.maxActiveTranscriptBytes,a.maxActiveTranscriptBytes,64e3),postCompactionSections:s}}function Ve(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 He(e){let t={...e,...e.model?.trim()?{model:e.model.trim()}:{}};return e.model?.trim()||delete t.model,{userContext:{contextPlanning:{compaction:t}}}}async function Ue(e){await d(m(`/api/config`),{method:`PATCH`,body:JSON.stringify(He(e))}),await x()}var We=128e3,Ge={balanced:Le,preserve:{...Le,triggerThreshold:.88,keepRecentTokens:32e3,recentTurnsPreserve:5,maxActiveTranscriptBytes:4e6},early:{...Le,triggerThreshold:.65,reserveTokens:12e3,minMessagesBeforeCompact:6,keepRecentTokens:12e3,recentTurnsPreserve:2}},Ke=ae();function qe(){return u(`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`,L,`dark:border-edge`)}function Je(e){let{enabled:t,model:n,postCompactionSections:r,...i}=e;return JSON.stringify(i)}function Ye(e){let t=Je(e);for(let[e,n]of Object.entries(Ge))if(t===Je(n))return e;return`custom`}function Xe(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,De.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=qe(),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 Ze(e){let t=(0,De.c)(19),{label:n,hint:r,checked:i,disabled:a,onChange:o}=e,s=a?`cursor-not-allowed opacity-55`:`cursor-pointer`,c;t[0]===s?c=t[1]:(c=u(`flex items-start gap-2 text-sm text-fg`,s),t[0]=s,t[1]=c);let l;t[2]===o?l=t[3]:(l=e=>o(e.target.checked),t[2]=o,t[3]=l);let d;t[4]!==i||t[5]!==a||t[6]!==l?(d=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:i,disabled:a,onChange:l}),t[4]=i,t[5]=a,t[6]=l,t[7]=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]!==c||t[16]!==d||t[17]!==m?(h=(0,Z.jsxs)(`label`,{className:c,children:[d,m]}),t[15]=c,t[16]=d,t[17]=m,t[18]=h):h=t[18],h}function Qe({hasToken:e}){let t=h(p(e=>e.language)).sessions.compaction,{data:n,isLoading:r}=S(e),{data:i=[],isLoading:a}=ne(e?D:null,E,{revalidateOnFocus:!1}),o=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:Be(n.payload.config),[n]),[s,d]=(0,X.useReducer)(Ke,{form:null,baseline:null}),[f,m]=(0,X.useState)(``),g=(0,X.useRef)(!1),_=(0,X.useRef)(s.form);_.current=s.form;let v=(0,X.useRef)(null);K({enabled:e,parsed:o,dirty:g.current,trackedParsedRef:v,dispatch:d,onResetDirty:()=>{g.current=!1}});let y=s.form,ee=s.baseline,te=!!(y&&ee&&JSON.stringify(y)!==JSON.stringify(ee)),x=(0,X.useCallback)(e=>{g.current=!0,d({type:`patch`,patch:e})},[]),w=(0,X.useCallback)(e=>({enabled:t.enabled,triggerThreshold:t.triggerThreshold,reserveTokens:t.reserveTokens,minMessagesBeforeCompact:t.minMessagesBeforeCompact,keepRecentTokens:t.keepRecentTokens,recentTurnsPreserve:t.recentTurnsPreserve,summaryMaxTokens:t.summaryMaxTokens,summaryChunkTokens:t.summaryChunkTokens,summaryTimeoutMs:t.summaryTimeoutSeconds,summaryRetries:t.summaryRetries,qualityGuard:t.qualityGuard,gapAudit:t.gapAudit,model:t.summaryModel,minToolResultKeepChars:t.minToolResultKeepChars,maxActiveTranscriptBytes:t.maxActiveTranscriptMb,postCompactionSections:t.postCompactionSections})[e],[t]),T=we({value:y,dirty:te,onSave:(0,X.useCallback)(async e=>{try{await Ue(e),d({type:`saved`,value:e}),g.current=!!(_.current&&JSON.stringify(_.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError]),validate:e=>{let n=Ve(e);return n?t.invalidValue.replace(`{{field}}`,w(n)):null}});if(!e||!y)return r?(0,Z.jsx)(J,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(C,{className:`h-5 w-48`}),(0,Z.jsx)(C,{className:`h-20 w-full rounded-xl`}),(0,Z.jsx)(C,{className:`h-36 w-full rounded-xl`})]})}):null;let O=Ye(y),k=Math.max(0,We-y.reserveTokens),A=Math.min(Math.floor(We*y.triggerThreshold),k),j=Math.min(100,A/We*100),M=Math.min(100,k/We*100),re=y.model?i.find(e=>e.id===y.model):void 0,N=re?.contextWindow&&y.summaryChunkTokens+y.summaryMaxTokens+4096>re.contextWindow,P=y.keepRecentTokens+y.reserveTokens>A,F=Math.round(y.summaryTimeoutMs*(y.summaryRetries+1)/1e3),I=e=>{let t=Ge[e];x({...t,...y.model?{model:y.model}:{model:void 0},postCompactionSections:y.postCompactionSections})},L={balanced:{title:t.presetBalanced,hint:t.presetBalancedHint},preserve:{title:t.presetPreserve,hint:t.presetPreserveHint},early:{title:t.presetEarly,hint:t.presetEarlyHint}},R=()=>{let e=f.trim();!e||y.postCompactionSections.includes(e)||y.postCompactionSections.length>=12||(x({postCompactionSections:[...y.postCompactionSections,e]}),m(``))};return(0,Z.jsxs)(J,{onBlurCapture:T.onBlurCapture,children:[(0,Z.jsx)(Ce,{icon:ue,title:t.title,subtitle:t.hint,trailing:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(Y,{status:T.status,error:T.error}),(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm font-medium text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:y.enabled,onChange:e=>x({enabled:e.target.checked})}),y.enabled?t.enabled:t.disabled]})]})}),T.error?(0,Z.jsx)(`p`,{className:`mb-4 rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700 dark:bg-red-950/40 dark:text-red-300`,role:`alert`,children:T.error}):null,y.enabled?null:(0,Z.jsx)(`p`,{className:`mb-4 rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 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})]}),O===`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":O===e,className:u(`rounded-xl bg-surface-base/55 px-3 py-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,H.transition,H.focusRingPanel,O===e?`bg-accent-soft text-accent-fg shadow-surface`:`text-fg hover:bg-surface-hover`),onClick:()=>I(e),children:[(0,Z.jsx)(`span`,{className:`block text-sm font-medium`,children:L[e].title}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:L[e].hint})]},e))})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,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:Xe(A)})]}),(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:`${j}%`}})})]}),(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:Xe(k)})]}),(0,Z.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-fg-subtle`,style:{width:`${M}%`}})})]})]}),(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=>x({triggerThreshold:e/100})}),(0,Z.jsx)($,{id:`compaction-reserve-tokens`,label:t.reserveTokens,hint:t.reserveTokensHint.replace(`{{tokens}}`,Xe(y.reserveTokens)),value:y.reserveTokens,min:1024,step:1024,onChange:e=>x({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=>x({recentTurnsPreserve:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-keep-recent-tokens`,label:t.keepRecentTokens,hint:t.keepRecentTokensHint.replace(`{{tokens}}`,Xe(y.keepRecentTokens)),value:y.keepRecentTokens,min:1e3,step:1e3,onChange:e=>x({keepRecentTokens:Math.floor(e)})})]}),P?(0,Z.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 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)(G,{value:y.model??``,disabled:!y.enabled,placeholder:t.summaryModelInherited,searchPlaceholder:t.summaryModelSearch,noMatches:t.summaryModelNoMatches,models:i,modelsLoading:a,className:`min-w-0 flex-1 justify-between`,contentAlign:`start`,showProviderSettingsFooter:!0,onChange:e=>x({model:e})}),y.model?(0,Z.jsx)(b,{type:`button`,variant:`secondary`,onClick:()=>x({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)(Ze,{label:t.qualityGuard,hint:t.qualityGuardHint,checked:y.qualityGuard,onChange:e=>x({qualityGuard:e})}),(0,Z.jsx)(Ze,{label:t.gapAudit,hint:t.gapAuditHint,checked:y.gapAudit,onChange:e=>x({gapAudit:e})})]}),y.qualityGuard?null:(0,Z.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.qualityGuardWarning}),(0,Z.jsx)(Ee,{children:(0,Z.jsxs)(`div`,{className:`space-y-5 rounded-xl bg-surface-base/45 p-4`,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=>x({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=>x({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=>x({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=>x({summaryChunkTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-timeout`,label:t.summaryTimeoutSeconds,hint:t.summaryTimeoutSecondsHint.replace(`{{seconds}}`,String(F)),value:y.summaryTimeoutMs/1e3,min:1,max:600,onChange:e=>x({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=>x({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=>x({minToolResultKeepChars:Math.floor(e)})})]}),N?(0,Z.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.summaryBudgetWarning}):null,(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,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:u(`text-fg-muted hover:text-fg`,H.press),"aria-label":t.removeSection.replace(`{{section}}`,e),onClick:()=>x({postCompactionSections:y.postCompactionSections.filter(t=>t!==e)}),children:(0,Z.jsx)(l,{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:qe(),value:f,maxLength:120,disabled:y.postCompactionSections.length>=12,placeholder:t.postCompactionSectionsPlaceholder,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),R())}}),(0,Z.jsxs)(b,{type:`button`,variant:`secondary`,disabled:!f.trim()||y.postCompactionSections.length>=12,onClick:R,children:[(0,Z.jsx)(c,{className:`size-4`,"aria-hidden":!0}),t.addSection]})]})]})]})})]})]})}function $e(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function et(e){return e===`main`||e===`per-peer`||e===`per-channel-peer`||e===`per-account-channel-peer`?e:`main`}function tt(e){let t=$e(e)?e:{},n=$e(t.session)?t.session:{},r=$e(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:et(n.dmScope),pruneAfterDays:i,maxEntries:a}}async function nt(e){await d(m(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),x()}function rt(){return u(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,L,`dark:border-edge`)}var it=ae();function at({hasToken:e}){let t=h(p(e=>e.language)).sessions.config,{data:n,isLoading:r}=S(e),i=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:tt(n.payload.config),[n]),[s,c]=(0,X.useReducer)(it,{form:null,baseline:null}),l=s.form,u=s.baseline,d=(0,X.useRef)(!1),f=(0,X.useRef)(l);f.current=l;let m=(0,X.useRef)(null);K({enabled:e,parsed:i,dirty:d.current,trackedParsedRef:m,dispatch:c,onResetDirty:()=>{d.current=!1}});let g=!!(l&&u&&JSON.stringify(l)!==JSON.stringify(u)),_=(0,X.useCallback)(e=>{d.current=!0,c({type:`patch`,patch:e})},[]),v=we({value:l,dirty:g,onSave:(0,X.useCallback)(async e=>{try{await nt(e),c({type:`saved`,value:e}),d.current=!!(f.current&&JSON.stringify(f.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});return!e||!l?r?(0,Z.jsx)(J,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(C,{className:`h-5 w-40`}),(0,Z.jsx)(C,{className:`h-24 w-full rounded-xl`})]})}):null:(0,Z.jsxs)(J,{onBlurCapture:v.onBlurCapture,children:[(0,Z.jsx)(Ce,{icon:U,title:t.title,subtitle:t.hint,trailing:(0,Z.jsx)(Y,{status:v.status,error:v.error})}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.dmScope}),(0,Z.jsxs)(a,{className:rt(),value:l.dmScope,onChange:e=>_({dmScope:e.target.value}),children:[(0,Z.jsx)(o,{value:`main`,children:t.dmScopeMain}),(0,Z.jsx)(o,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Z.jsx)(o,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Z.jsx)(o,{value:`per-account-channel-peer`,children:t.dmScopePerAccountChannelPeer})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.dmScopeHint})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.pruneAfterDays}),(0,Z.jsx)(`input`,{type:`number`,min:0,className:rt(),value:l.pruneAfterDays??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();_({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:rt(),value:l.maxEntries??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();_({maxEntries:t===``?null:Math.max(1,Math.floor(Number(t)||1))})}})]})]})]})}function ot(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 st(e){let t=(0,De.c)(60),{open:n,loading:r,session:i,sessionAgentId:a,sessionAgentAvatar:o,labels:s,onClose:c,onArchive:d,onUnarchive:f,onPin:p,onUnpin:m,onExport:h,onDelete:ne}=e,x=i?.status===`archived`,S=i?.status===`pinned`,C;t[0]===c?C=t[1]:(C=e=>!e&&c(),t[0]=c,t[1]=C);let E;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Z.jsx)(g,{className:u(`xopc-dialog-overlay fixed inset-0 bg-scrim`,T)}),t[2]=E):E=t[2];let D;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(D=u(`xopc-drawer-right fixed right-0 top-0 flex size-full max-w-lg flex-col border-l border-edge bg-surface-overlay shadow-popover outline-none`,w,`dark:border-edge`),t[3]=D):D=t[3];let O;t[4]!==i||t[5]!==o||t[6]!==a?(O=i&&a?(0,Z.jsx)(M,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}):null,t[4]=i,t[5]=o,t[6]=a,t[7]=O):O=t[7];let k;t[8]!==s.unnamedSession||t[9]!==i?.name?(k=i?.name?.trim()||s.unnamedSession,t[8]=s.unnamedSession,t[9]=i?.name,t[10]=k):k=t[10];let A;t[11]===k?A=t[12]:(A=(0,Z.jsx)(ee,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:k}),t[11]=k,t[12]=A);let j;t[13]!==O||t[14]!==A?(j=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[O,A]}),t[13]=O,t[14]=A,t[15]=j):j=t[15];let re;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,Z.jsx)(l,{className:`size-5`,strokeWidth:1.75}),t[16]=re):re=t[16];let N;t[17]===s.close?N=t[18]:(N=(0,Z.jsx)(_,{asChild:!0,children:(0,Z.jsx)(b,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":s.close,children:re})}),t[17]=s.close,t[18]=N);let P;t[19]!==j||t[20]!==N?(P=(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:[j,N]}),t[19]=j,t[20]=N,t[21]=P):P=t[21];let F;t[22]!==s.detailLoading||t[23]!==s.detailMessages||t[24]!==r||t[25]!==i?(F=r?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.detailLoading}):i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`dl`,{className:`mb-4 grid gap-2 text-xs text-fg-muted`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-fg-disabled`,children:`Key`}),(0,Z.jsx)(`dd`,{className:`mt-0.5 break-all font-mono text-fg`,children:i.key})]}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-4`,children:(0,Z.jsxs)(`span`,{children:[i.messageCount,` msgs · `,i.estimatedTokens,` tok`]})})]}),(0,Z.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:s.detailMessages}),(0,Z.jsx)(`ul`,{className:`space-y-3`,children:i.messages.map(ct)})]}):null,t[22]=s.detailLoading,t[23]=s.detailMessages,t[24]=r,t[25]=i,t[26]=F):F=t[26];let I;t[27]===F?I=t[28]:(I=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:F}),t[27]=F,t[28]=I);let L;t[29]!==s.detailExport||t[30]!==h?(L=(0,Z.jsx)(b,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:h,children:s.detailExport}),t[29]=s.detailExport,t[30]=h,t[31]=L):L=t[31];let R;t[32]!==x||t[33]!==s.archive||t[34]!==s.unarchive||t[35]!==d||t[36]!==f?(R=x?(0,Z.jsx)(b,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:f,children:s.unarchive}):(0,Z.jsx)(b,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:d,children:s.archive}),t[32]=x,t[33]=s.archive,t[34]=s.unarchive,t[35]=d,t[36]=f,t[37]=R):R=t[37];let z;t[38]!==S||t[39]!==s.pin||t[40]!==s.unpin||t[41]!==p||t[42]!==m?(z=S?(0,Z.jsx)(b,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:m,children:s.unpin}):(0,Z.jsx)(b,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:p,children:s.pin}),t[38]=S,t[39]=s.pin,t[40]=s.unpin,t[41]=p,t[42]=m,t[43]=z):z=t[43];let ie;t[44]!==s.delete||t[45]!==ne?(ie=(0,Z.jsx)(b,{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:ne,children:s.delete}),t[44]=s.delete,t[45]=ne,t[46]=ie):ie=t[46];let B;t[47]!==L||t[48]!==R||t[49]!==z||t[50]!==ie?(B=(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:[L,R,z,ie]})}),t[47]=L,t[48]=R,t[49]=z,t[50]=ie,t[51]=B):B=t[51];let V;t[52]!==P||t[53]!==I||t[54]!==B?(V=(0,Z.jsxs)(v,{children:[E,(0,Z.jsxs)(y,{className:D,"aria-describedby":void 0,children:[P,I,B]})]}),t[52]=P,t[53]=I,t[54]=B,t[55]=V):V=t[55];let H;return t[56]!==n||t[57]!==C||t[58]!==V?(H=(0,Z.jsx)(te,{open:n,onOpenChange:C,children:V}),t[56]=n,t[57]=C,t[58]=V,t[59]=H):H=t[59],H}function ct(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:ot(e.content)})]},`${e.timestamp??``}-${e.role}-${ot(e.content).slice(0,24)}`)}var lt=20;function ut(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var dt=new Set([`all`,`active`,`pinned`,`archived`]),ft=new Set([`grid`,`list`]),pt=[`sessions`,`settings`];function mt(e){return e&&pt.includes(e)?e:`sessions`}function ht(e,t){return t===`sessions`?e.tabsSessions:e.tabsSettings}function gt(e,t){return t===`sessions`?e.tabsSessionsHint:e.tabsSettingsHint}function _t(e){let t=(0,De.c)(7),{s:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=pt.map(e=>({id:e,label:ht(n,e),icon:e===`sessions`?j:I})),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)(Te,{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 vt(e){let t=(0,De.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-xl bg-surface-hover/20 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:ht(n,r)}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:gt(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 yt(e){let t=e.get(`status`),n=e.get(`view`);return{searchInput:e.get(`q`)??``,debouncedSearch:(e.get(`q`)??``).trim(),statusFilter:dt.has(t)?t:`all`,viewMode:ft.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 bt(){let e=h(p(e=>e.language)),t=e.sessions,n=f(e=>e.conversationId),r=!!n,{data:a,mutate:o}=ne(r?[`gateway-chat-agents`,n]:null,me,{revalidateOnFocus:!1}),s=a?.defaultId??`main`,c=a?.items??[],[l,d]=i(),m=mt(l.get(`tab`)),_=(0,X.useCallback)(e=>{let t=new URLSearchParams(l);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),d(t,{replace:!0})},[l,d]),[x,S]=(0,X.useReducer)(le,l,yt),{searchInput:C,debouncedSearch:E,statusFilter:D,viewMode:M,channelFilter:F,sessions:I,loading:L,error:R,hasMore:z,stats:U,detailOpen:ae,detailLoading:ce,detailSession:W,confirmOpen:ue,confirmKey:de}=x;(0,X.useEffect)(()=>{let e=setTimeout(()=>{let e=C.trim();E!==e&&S({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[C,E]);let G=l.toString(),K=(0,X.useRef)(G);if(K.current!==G){K.current=G;let e=l.get(`q`)??``,t=l.get(`status`),n=l.get(`view`),r=(l.get(`channel`)??``).trim(),i=dt.has(t)?t:`all`,a=ft.has(n)?n:`grid`,o=e.trim();S({type:`patch`,patch:{...C===e?{}:{searchInput:e},...E===o?{}:{debouncedSearch:o},...D===i?{}:{statusFilter:i},...M===a?{}:{viewMode:a},...F===r?{}:{channelFilter:r}}})}(0,X.useEffect)(()=>{let e=new URLSearchParams(l),t=E.trim();t?e.set(`q`,t):e.delete(`q`),D===`all`?e.delete(`status`):e.set(`status`,D),M===`grid`?e.delete(`view`):e.set(`view`,M),F?e.set(`channel`,F):e.delete(`channel`),e.toString()!==l.toString()&&d(e,{replace:!0})},[E,l,d,D,M,F]),(0,X.useEffect)(()=>{if(!r||m!==`sessions`)return;let e=!1;return(async()=>{S({type:`patch`,patch:{loading:!0,error:null}});try{let t=await V({limit:lt,offset:0,...E?{search:E}:{},...D===`all`?{}:{status:D},...F?{channel:F}:{}});if(e)return;S({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||S({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||S({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,m,E,D,F,t.loadError]),(0,X.useEffect)(()=>{!r||m!==`sessions`||be().then(e=>S({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,m]),(0,X.useEffect)(()=>{if(!r||m!==`sessions`)return;let e=()=>void o();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,m,o]),(0,X.useEffect)(()=>{if(!r||m!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||S({type:`patch`,patch:{sessions:I.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:W&&W.key===t.key?{...W,name:t.name}:W}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,m,I,W]);let pe=(0,X.useCallback)(async()=>{if(!(!r||L||!z)){S({type:`patch`,patch:{loading:!0,error:null}});try{let e=await V({limit:lt,offset:I.length,...E?{search:E}:{},...D===`all`?{}:{status:D},...F?{channel:F}:{}});S({type:`patch`,patch:{sessions:[...I,...e.items],hasMore:e.hasMore}})}catch(e){S({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{S({type:`patch`,patch:{loading:!1}})}}},[r,L,z,I.length,E,D,F,t.loadError]),q=(0,X.useCallback)((e,t)=>{S({type:`patch`,patch:{sessions:I.map(n=>n.key===e?{...n,status:t}:n),detailSession:W&&W.key===e?{...W,status:t}:W}})},[I,W]),Ce=(0,X.useCallback)(async e=>{S({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{S({type:`patch`,patch:{detailSession:await he(e)}})}catch{S({type:`patch`,patch:{detailOpen:!1}})}finally{S({type:`patch`,patch:{detailLoading:!1}})}},[]),J=e=>{Ce(e)},Y=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:e},bubbles:!0}));return}if(t===`delete`){S({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await se(e),q(e,`archived`);break;case`unarchive`:await O(e),q(e,`active`);break;case`pin`:await ve(e),q(e,`pinned`);break;case`unpin`:await ge(e),q(e,`active`);break;case`export`:{let t=await B(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}be().then(e=>S({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},we=async e=>{try{await oe(e),S({type:`patch`,patch:{sessions:I.filter(t=>t.key!==e),detailSession:W?.key===e?null:W,...W?.key===e?{detailOpen:!1}:{}}}),be().then(e=>S({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:j},{key:`active`,label:t.filterActive,icon:ye},{key:`pinned`,label:t.filterPinned,icon:re},{key:`archived`,label:t.filterArchived,icon:ie}],Oe=(()=>{let e=Object.entries(U?.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)(Se,{gap:`gap-6`,children:[(0,Z.jsx)(xe,{title:t.title}),(0,Z.jsx)(_t,{s:t,activeTab:m,onChange:_}),(0,Z.jsx)(vt,{s:t,id:`settings`,activeTab:m,plain:!0,children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(Qe,{hasToken:r}),(0,Z.jsx)(at,{hasToken:r})]})}),(0,Z.jsxs)(vt,{s:t,id:`sessions`,activeTab:m,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":D===e,onClick:()=>S({type:`patch`,patch:{statusFilter:e}}),className:u(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,H.transition,H.focusRingPanel,D===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 min-h-11 w-full min-w-0 items-center gap-2 rounded-xl bg-surface-base focus-within:ring-2 focus-within:ring-accent px-3 py-2 transition-colors lg:max-w-md dark:bg-surface-hover/40`,children:[(0,Z.jsx)(A,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`input`,{type:`search`,value:C,onChange:e=>S({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"aria-label":t.searchPlaceholder,"data-debounced-query":E||void 0,className:`min-w-0 flex-1 border-0 bg-transparent text-base sm: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:()=>S({type:`patch`,patch:{channelFilter:``}}),className:u(`touch-target inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,H.transition,H.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}),Oe.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":F===e,onClick:()=>S({type:`patch`,patch:{channelFilter:e}}),className:u(`touch-target inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,H.transition,H.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,U?.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:U.byChannel[e]})]},e))]}),U?(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[U.totalSessions,t.totalSessions],[U.activeSessions,t.activeSessions],[U.pinnedSessions,t.pinnedSessions],[U.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,R?(0,Z.jsx)(`div`,{className:`rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700 dark:bg-red-950/40 dark:text-red-300`,children:R}):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:ut(t.sessionCount,{count:I.length})}),(0,Z.jsxs)(`div`,{className:P,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,Z.jsx)(b,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":M===`grid`,onClick:()=>S({type:`patch`,patch:{viewMode:`grid`}}),className:u(N,`size-7 p-0`,M===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,M===`grid`&&`text-accent-fg`),children:(0,Z.jsx)(_e,{className:`size-3.5`,strokeWidth:1.5})}),(0,Z.jsx)(b,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":M===`list`,onClick:()=>S({type:`patch`,patch:{viewMode:`list`}}),className:u(N,`size-9 p-0`,M===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,M===`list`&&`text-accent-fg`),children:(0,Z.jsx)(k,{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)(fe,{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)(b,{variant:`primary`,className:`mt-6`,onClick:()=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:``},bubbles:!0}))},children:t.startNewChat})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:u(`grid min-w-0 gap-3`,M===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":E||void 0,children:I.map(e=>{let t=Fe(e,s);return(0,Z.jsx)(Ae,{session:e,variant:M,labels:Te,sessionAgentId:t,sessionAgentAvatar:Ie(t,c),onOpen:()=>J(e.key),onAction:t=>void Y(e.key,t)},e.key)})}),z?(0,Z.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Z.jsx)(b,{type:`button`,variant:`secondary`,disabled:L,onClick:()=>void pe(),children:t.loadMore})}):null]})]})]}),(0,Z.jsx)(st,{open:ae,loading:ce,session:W,sessionAgentId:W?Fe(W,s):void 0,sessionAgentAvatar:W?Ie(Fe(W,s),c):void 0,labels:Ee,onClose:()=>{S({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>W&&void Y(W.key,`archive`),onUnarchive:()=>W&&void Y(W.key,`unarchive`),onPin:()=>W&&void Y(W.key,`pin`),onUnpin:()=>W&&void Y(W.key,`unpin`),onExport:()=>W&&void Y(W.key,`export`),onDelete:()=>W&&S({type:`patch`,patch:{confirmKey:W.key,confirmOpen:!0}})}),(0,Z.jsx)(te,{open:ue,onOpenChange:e=>S({type:`patch`,patch:{confirmOpen:e}}),children:(0,Z.jsxs)(v,{children:[(0,Z.jsx)(g,{className:u(`xopc-dialog-overlay fixed inset-0 bg-scrim`,T)}),(0,Z.jsxs)(y,{className:u(`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-overlay p-4 shadow-popover dark:border-edge`,w),children:[(0,Z.jsx)(ee,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:de?ut(t.deleteSessionMessage,{name:I.find(e=>e.key===de)?.name?.trim()||e.chat.newSession}):``}),(0,Z.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Z.jsx)(b,{type:`button`,variant:`secondary`,onClick:()=>S({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Z.jsx)(b,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{de&&we(de),S({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{bt as SessionsPage};
@@ -1 +0,0 @@
1
- import{mn as e}from"./index-Ah5XDhOL.js";function t(t){let{children:n,fallback:r}=t,i=r===void 0?null:r;return e()?n:i}export{t};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as a}from"./circle-check-C23XjkUj.js";import{t as o}from"./cn-JdwAhgNB.js";import{a as s,c,n as l,r as u}from"./locale-store-vZTDIqJB.js";import{t as d}from"./messages-CRH2my19.js";import{i as f}from"./vendor-swr-BIWyz7Rc.js";import{r as p}from"./gateway-config-swr-D7SG_ECs.js";import{n as m}from"./electron-env-Dit0bHgy.js";import{n as h}from"./gateway-realtime-store-Z-ErSgkD.js";import{n as g,t as _}from"./registry-api-CF-nJ5MG.js";import{$u as v,Au as y,Ot as b,Su as x,bs as S,di as C,ec as w,fl as ee,jc as te,jl as T,lc as E,xo as D,xu as O}from"./index-Ah5XDhOL.js";import{n as k,r as A}from"./settings-page-layout-B39PogyD.js";import{n as j,t as M}from"./settings-form-section-kIV5M-9G.js";import{n as N}from"./settings-loading-skeleton-CAmWMaOT.js";import{t as P}from"./settings-advanced-gate-Cx_uvwqz.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`&&D(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.defaults,r=n&&typeof n==`object`&&!Array.isArray(n)?n.models:void 0;if(!r||typeof r!=`object`||Array.isArray(r))return``;let i=r.chat;if(!i||typeof i!=`object`||Array.isArray(i))return``;let a=i.primary;return typeof a==`string`?a.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 ne(e){if(!e||typeof e!=`object`)return{enabled:!1,driverKind:`extension`};let t=e.browser;if(!t||typeof t!=`object`||Array.isArray(t))return{enabled:!1,driverKind:`extension`};let n=t,r=n.driver&&typeof n.driver==`object`&&!Array.isArray(n.driver)?n.driver:void 0;return{enabled:n.enabled===!0,driverKind:typeof r?.kind==`string`&&r.kind.trim()?r.kind.trim():`extension`}}function B(e){return e?`pass`:`fail`}function V(e){if(e===`tool-runtimes`)return`/settings/runtimes`;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 H(e){return{fail:4,warn:3,skip:2,pass:1}[e]}function U(e,t){let n=e.match(/^Run(?::|\s)(.*)$/i);if(n?.[1])return t.runCommand(n[1].trim());let r=e.match(/^Install(?::|\s)(.*)$/i);if(r?.[1])return t.installCommand(r[1].trim());let i=e.match(/^Start(?::|\s)(.*)$/i);return i?.[1]?t.startCommand(i[1].trim()):e}function W(e,t){if(!t)return e;let n=e.message;if(e.id===`tool-runtimes`){let r=e.message.match(/^(.*) runtime is not installed\.$/),i=e.message.match(/^(.*) runtime installation is invalid\.$/);r?.[1]?n=t.runtimeMissing(r[1]):i?.[1]&&(n=t.runtimeInvalid(i[1]))}else if(e.id===`gateway-service`)if(e.message===`Gateway is not installed as a system service.`)n=t.gatewayNotInstalled;else{let r=e.message.match(/^Service backend unavailable: (.*)$/),i=e.message.match(/^Gateway service is installed but not running \(status: (.*)\)\.$/);r?.[1]?n=t.gatewayUnavailable(r[1]):i?.[1]&&(n=t.gatewayNotRunning(i[1]))}else e.id===`provider-auth`&&e.message===`No API keys detected for configured providers.`&&(n=t.providerAuthMissing);return{...e,label:t.labels[e.id]??e.label,message:n,hints:e.hints.map(e=>U(e,t))}}function G(e,t){return e.filter(e=>e.status===`fail`||e.status===`warn`).map(e=>{let n=W(e,t);return{id:n.id,label:n.label,status:n.status,message:n.message,hints:n.hints,path:V(n.id),source:`doctor`}}).toSorted((e,t)=>H(t.status)-H(e.status)||e.label.localeCompare(t.label))}function K(e){let t=new Map(e.doctorChecks.map(e=>[e.id,e])),n=[];for(let r of[`security-audit`,`channel-config`,`channel-pairing-pending`,`gateway-health`]){let i=t.get(r);if(i){let t=W(i,e.copy);n.push({id:t.id,label:t.label,status:t.status,message:t.message,path:V(t.id)})}}if(e.logsHealth){let t=e.logsHealth.stats?.errorsLast24h??0;n.push({id:`logs-health`,label:e.copy?.labels[`logs-health`]??`Logs`,status:e.logsHealth.shuttingDown||t>0?`warn`:`pass`,message:e.copy?e.logsHealth.shuttingDown?e.copy.logsShuttingDown:t>0?e.copy.logsErrors(t):e.copy.logsHealthy: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??[]){let r=t.message;if(e.copy){r={"Local Chromium is installed.":e.copy.chromiumInstalled,"Local Chromium is not installed.":e.copy.chromiumNotInstalled,"Chrome extension bridge is connected.":e.copy.extensionConnected,"Chrome extension needs refresh.":e.copy.extensionNeedsRefresh,"Chrome extension is installed but not connected.":e.copy.extensionNotConnected,"Chrome extension is not installed.":e.copy.extensionNotInstalled}[t.message]??t.message;let n=t.message.match(/^Browser driver "(.*)" is configured\.$/);n?.[1]&&(r=e.copy.browserDriverConfigured(n[1]))}n.push({...t,label:e.copy?.labels[t.id]??t.label,message:r})}return n}function re(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??[]).filter(t=>!e.isElectron||t.id!==`gateway-service`),d=G(u,e.labels.diagnostics),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:B(s),title:`Gateway`,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline,path:`/settings/gateway`},{id:`provider`,status:B(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:B(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=K({doctorChecks:u,logsHealth:e.logsHealth,browserDiagnostics:e.browserDiagnostics,copy:e.labels.diagnostics});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 ie(e){return ne(e)}function ae(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 oe(){return u(`/api/doctor`)}async function se(){return((await s(oe())).checks??[]).map(ae).filter(e=>e!==null)}function ce(){return u(`/api/logs/health`)}async function le(){return s(ce())}function q(e){return e?`pass`:`warn`}function ue(e){return e?.enabled?[`setup-browser-diagnostics`,e]:null}async function J(e){if(!e.enabled)return[];if(e.driverKind===`playwright`){let e=await s(u(`/api/browser/playwright/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-playwright`,label:`Browser: Playwright`,status:q(t),message:t?`Local Chromium is installed.`:e.payload?.reason??`Local Chromium is not installed.`,path:`/settings/agent-browser`}]}if(e.driverKind===`extension`){let e=await s(u(`/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:`/settings/agent-browser`}]}return[{id:`browser-playwright`,label:`Browser`,status:`skip`,message:`Browser driver "${e.driverKind}" is configured.`,path:`/settings/agent-browser`}]}function Y(){let e=(0,I.c)(95),t=c(ge),n=l(he),r;e[0]===n?r=e[1]:(r=d(n),e[0]=n,e[1]=r);let i=r,a=i.setupStatus.labels,o=i.setupStatus.diagnostics,s=h(me),{data:u,error:v,isLoading:y,mutate:x}=p(!!t),S;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(S={revalidateOnFocus:!1},e[2]=S):S=e[2];let{data:C,error:w,isLoading:ee,mutate:te}=f(t?`setup-checklist-skills`:null,pe,S),T;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(T={revalidateOnFocus:!1},e[3]=T):T=e[3];let{data:E,error:D,isLoading:O,mutate:k}=f(t?`setup-checklist-provider-meta`:null,b,T),A;e[4]===t?A=e[5]:(A=t?oe():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}=f(A,se,j),L;e[7]===t?L=e[8]:(L=t?ce():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:ne,mutate:B}=f(L,le,R);u?.payload?.config;let V=u?.payload?.config,H;e[10]===V?H=e[11]:(H=ie(V),e[10]=V,e[11]=H);let U=t?H:null,W;e[12]===U?W=e[13]:(W=ue(U),e[12]=U,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:ae,mutate:q}=f(W,fe,G),J;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(J={revalidateOnFocus:!1},e[15]=J):J=e[15],f(t?_:null,g,J);let Y=!t||!y&&!ee&&!O&&!P&&!ne&&!ae,X=!!(v||w||D||N),_e;bb0:{if(!t||!Y){_e=null;break bb0}let n=C?.catalog?.length??0,r;if(e[16]!==K||e[17]!==u?.payload?.config||e[18]!==o.browserDriverConfigured||e[19]!==o.chromiumInstalled||e[20]!==o.chromiumNotInstalled||e[21]!==o.extensionConnected||e[22]!==o.extensionNeedsRefresh||e[23]!==o.extensionNotConnected||e[24]!==o.extensionNotInstalled||e[25]!==o.gatewayNotInstalled||e[26]!==o.gatewayNotRunning||e[27]!==o.gatewayUnavailable||e[28]!==o.installCommand||e[29]!==o.labels||e[30]!==o.logsErrors||e[31]!==o.logsHealthy||e[32]!==o.logsShuttingDown||e[33]!==o.providerAuthMissing||e[34]!==o.runCommand||e[35]!==o.runtimeInvalid||e[36]!==o.runtimeMissing||e[37]!==o.startCommand||e[38]!==M||e[39]!==a.channelConfigured||e[40]!==a.channelMissing||e[41]!==a.gatewayOffline||e[42]!==a.gatewayOnline||e[43]!==a.modelConfigured||e[44]!==a.modelMissing||e[45]!==a.providersConfigured||e[46]!==a.providersMetaReady||e[47]!==a.providersMissing||e[48]!==a.skillsConfigured||e[49]!==a.skillsMissing||e[50]!==z||e[51]!==i.setupStatus.requiredCompleteMessage||e[52]!==E||e[53]!==s||e[54]!==n||e[55]!==t){let c=E?.filter(de).length??0,l=E?.length??0,d;e[57]===a.providersConfigured?d=e[58]:(d=e=>a.providersConfigured.replace(`{{count}}`,String(e)),e[57]=a.providersConfigured,e[58]=d);let f;e[59]===a.providersMetaReady?f=e[60]:(f=(e,t)=>a.providersMetaReady.replace(`{{configured}}`,String(e)).replace(`{{total}}`,String(t)),e[59]=a.providersMetaReady,e[60]=f);let p;e[61]===a.modelConfigured?p=e[62]:(p=e=>a.modelConfigured.replace(`{{model}}`,e),e[61]=a.modelConfigured,e[62]=p);let h;e[63]===a.skillsConfigured?h=e[64]:(h=e=>a.skillsConfigured.replace(`{{count}}`,String(e)),e[63]=a.skillsConfigured,e[64]=h);let g;e[65]===o.runtimeMissing?g=e[66]:(g=e=>o.runtimeMissing.replace(`{{runtimes}}`,e),e[65]=o.runtimeMissing,e[66]=g);let _;e[67]===o.runtimeInvalid?_=e[68]:(_=e=>o.runtimeInvalid.replace(`{{runtimes}}`,e),e[67]=o.runtimeInvalid,e[68]=_);let v;e[69]===o.gatewayUnavailable?v=e[70]:(v=e=>o.gatewayUnavailable.replace(`{{detail}}`,e),e[69]=o.gatewayUnavailable,e[70]=v);let y;e[71]===o.gatewayNotRunning?y=e[72]:(y=e=>o.gatewayNotRunning.replace(`{{status}}`,e),e[71]=o.gatewayNotRunning,e[72]=y);let b;e[73]===o.runCommand?b=e[74]:(b=e=>o.runCommand.replace(`{{command}}`,e),e[73]=o.runCommand,e[74]=b);let x;e[75]===o.installCommand?x=e[76]:(x=e=>o.installCommand.replace(`{{command}}`,e),e[75]=o.installCommand,e[76]=x);let S;e[77]===o.startCommand?S=e[78]:(S=e=>o.startCommand.replace(`{{command}}`,e),e[77]=o.startCommand,e[78]=S);let C;e[79]===o.logsErrors?C=e[80]:(C=e=>o.logsErrors.replace(`{{count}}`,String(e)),e[79]=o.logsErrors,e[80]=C);let w;e[81]===o.browserDriverConfigured?w=e[82]:(w=e=>o.browserDriverConfigured.replace(`{{driver}}`,e),e[81]=o.browserDriverConfigured,e[82]=w),r=re({isElectron:m(),hasToken:!!t,realtimeConnected:s,config:u?.payload?.config,skillCount:n,providerMeta:l>0?{configured:c,total:l}:null,doctorChecks:M,logsHealth:z,browserDiagnostics:K,labels:{gatewayOnline:a.gatewayOnline,gatewayOffline:a.gatewayOffline,providersConfigured:d,providersMetaReady:f,providersMissing:a.providersMissing,modelConfigured:p,modelMissing:a.modelMissing,channelConfigured:a.channelConfigured,channelMissing:a.channelMissing,skillsConfigured:h,skillsMissing:a.skillsMissing,readyToChat:i.setupStatus.requiredCompleteMessage,diagnostics:{labels:o.labels,runtimeMissing:g,runtimeInvalid:_,gatewayNotInstalled:o.gatewayNotInstalled,gatewayUnavailable:v,gatewayNotRunning:y,providerAuthMissing:o.providerAuthMissing,runCommand:b,installCommand:x,startCommand:S,logsHealthy:o.logsHealthy,logsShuttingDown:o.logsShuttingDown,logsErrors:C,chromiumInstalled:o.chromiumInstalled,chromiumNotInstalled:o.chromiumNotInstalled,extensionConnected:o.extensionConnected,extensionNeedsRefresh:o.extensionNeedsRefresh,extensionNotConnected:o.extensionNotConnected,extensionNotInstalled:o.extensionNotInstalled,browserDriverConfigured:w}}}),e[16]=K,e[17]=u?.payload?.config,e[18]=o.browserDriverConfigured,e[19]=o.chromiumInstalled,e[20]=o.chromiumNotInstalled,e[21]=o.extensionConnected,e[22]=o.extensionNeedsRefresh,e[23]=o.extensionNotConnected,e[24]=o.extensionNotInstalled,e[25]=o.gatewayNotInstalled,e[26]=o.gatewayNotRunning,e[27]=o.gatewayUnavailable,e[28]=o.installCommand,e[29]=o.labels,e[30]=o.logsErrors,e[31]=o.logsHealthy,e[32]=o.logsShuttingDown,e[33]=o.providerAuthMissing,e[34]=o.runCommand,e[35]=o.runtimeInvalid,e[36]=o.runtimeMissing,e[37]=o.startCommand,e[38]=M,e[39]=a.channelConfigured,e[40]=a.channelMissing,e[41]=a.gatewayOffline,e[42]=a.gatewayOnline,e[43]=a.modelConfigured,e[44]=a.modelMissing,e[45]=a.providersConfigured,e[46]=a.providersMetaReady,e[47]=a.providersMissing,e[48]=a.skillsConfigured,e[49]=a.skillsMissing,e[50]=z,e[51]=i.setupStatus.requiredCompleteMessage,e[52]=E,e[53]=s,e[54]=n,e[55]=t,e[56]=r}else r=e[56];_e=r}let Z=_e,Q;e[83]!==q||e[84]!==x||e[85]!==F||e[86]!==B||e[87]!==k||e[88]!==te?(Q=async()=>{await Promise.all([x(),te(),k(),F(),B(),q()])},e[83]=q,e[84]=x,e[85]=F,e[86]=B,e[87]=k,e[88]=te,e[89]=Q):Q=e[89];let ve=Q,$;return e[90]!==X||e[91]!==Y||e[92]!==ve||e[93]!==Z?($={ready:Y,error:X,snapshot:Z,refresh:ve},e[90]=X,e[91]=Y,e[92]=ve,e[93]=Z,e[94]=$):$=e[94],$}function de(e){return e.configured}function fe(e){let[,t]=e;return J(t)}function pe(){return C()}function me(e){return e.connectionState===`connected`}function he(e){return e.language}function ge(e){return e.conversationId}var X=r();function _e(e){return e===`pass`?`bg-success-soft text-success`:e===`warn`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`fail`?`bg-red-500/10 text-red-700 dark:text-red-300`:`bg-surface-hover text-fg-muted`}function Z(e){return e===`pass`?a:e===`warn`?w:e===`fail`?x:T}function Q(e,t){return e===`blocked`?{icon:x,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:w,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:O,className:`bg-surface-hover/50 text-fg`,title:t.health.setupTitle,body:t.health.setupBody,action:t.health.continueSetup,targetId:`next-steps`}:{icon:a,className:`bg-success-soft text-success`,title:t.health.readyTitle,body:t.health.readyBody,action:t.health.startChat,actionPath:`/chat`}}function ve(e){let t=(0,I.c)(46),{tier:n,issueCount:r,onRunDoctor:a,ready:s,doctorRunning:c,doctorRunState:u}=e,f=l($),p,m,h,g,_,v,b,x,C;if(t[0]!==r||t[1]!==f||t[2]!==n){m=d(f).setupStatus;let e=Q(n,m),a=e.icon,s=`targetId`in e&&typeof e.targetId==`string`?e.targetId:null,c=`actionPath`in e&&typeof e.actionPath==`string`?e.actionPath:`/chat`;p=s?(0,X.jsxs)(`button`,{type:`button`,onClick:()=>document.getElementById(s)?.scrollIntoView({block:`start`,behavior:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`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,X.jsx)(y,{className:`size-4`,"aria-hidden":!0})]}):(0,X.jsxs)(i,{to:c,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,X.jsx)(y,{className:`size-4`,"aria-hidden":!0})]}),C=o(`rounded-xl p-4`,e.className),x=`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,v=`flex min-w-0 gap-3`,b=(0,X.jsx)(a,{className:`mt-0.5 size-5 shrink-0`,"aria-hidden":!0}),h=`min-w-0`,g=(0,X.jsx)(`h2`,{className:`text-base font-semibold`,children:e.title}),_=r>0?(0,X.jsx)(`p`,{className:`mt-1 text-sm opacity-80`,children:m.health.issueCount.replace(`{{count}}`,String(r))}):null,t[0]=r,t[1]=f,t[2]=n,t[3]=p,t[4]=m,t[5]=h,t[6]=g,t[7]=_,t[8]=v,t[9]=b,t[10]=x,t[11]=C}else p=t[3],m=t[4],h=t[5],g=t[6],_=t[7],v=t[8],b=t[9],x=t[10],C=t[11];let w;t[12]!==h||t[13]!==g||t[14]!==_?(w=(0,X.jsxs)(`div`,{className:h,children:[g,_]}),t[12]=h,t[13]=g,t[14]=_,t[15]=w):w=t[15];let T;t[16]!==v||t[17]!==b||t[18]!==w?(T=(0,X.jsxs)(`div`,{className:v,children:[b,w]}),t[16]=v,t[17]=b,t[18]=w,t[19]=T):T=t[19];let E;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(E=o(`inline-flex items-center gap-2 rounded-lg bg-surface-base/70 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`,S.press),t[20]=E):E=t[20];let D=!s||c,O;t[21]===c?O=t[22]:(O=c?(0,X.jsx)(ee,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,X.jsx)(te,{className:`size-4`,"aria-hidden":!0}),t[21]=c,t[22]=O);let k=c?m.health.runDoctorRunning:m.health.runDoctor,A;t[23]!==c||t[24]!==a||t[25]!==D||t[26]!==O||t[27]!==k?(A=(0,X.jsxs)(`button`,{type:`button`,className:E,onClick:a,disabled:D,"aria-busy":c,children:[O,k]}),t[23]=c,t[24]=a,t[25]=D,t[26]=O,t[27]=k,t[28]=A):A=t[28];let j;t[29]!==p||t[30]!==A?(j=(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[p,A]}),t[29]=p,t[30]=A,t[31]=j):j=t[31];let M;t[32]!==j||t[33]!==x||t[34]!==T?(M=(0,X.jsxs)(`div`,{className:x,children:[T,j]}),t[32]=j,t[33]=x,t[34]=T,t[35]=M):M=t[35];let N;t[36]!==u||t[37]!==c||t[38]!==m.health.doctorCompleteMessage||t[39]!==m.health.doctorFailedMessage||t[40]!==m.health.doctorRunningMessage?(N=c||u!==`idle`?(0,X.jsx)(`p`,{className:`mt-3 text-xs opacity-75`,role:`status`,"aria-live":`polite`,children:c?m.health.doctorRunningMessage:u===`success`?m.health.doctorCompleteMessage:m.health.doctorFailedMessage}):null,t[36]=u,t[37]=c,t[38]=m.health.doctorCompleteMessage,t[39]=m.health.doctorFailedMessage,t[40]=m.health.doctorRunningMessage,t[41]=N):N=t[41];let P;return t[42]!==M||t[43]!==N||t[44]!==C?(P=(0,X.jsxs)(`section`,{className:C,children:[M,N]}),t[42]=M,t[43]=N,t[44]=C,t[45]=P):P=t[45],P}function $(e){return e.language}function ye(e){let t=(0,I.c)(26),{issue:n,fixLabel:r}=e,a;t[0]===n.status?a=t[1]:(a=Z(n.status),t[0]=n.status,t[1]=a);let o=a,s;t[2]===o?s=t[3]:(s=(0,X.jsx)(o,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=o,t[3]=s);let c;t[4]===n.label?c=t[5]:(c=(0,X.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:n.label}),t[4]=n.label,t[5]=c);let l;t[6]===n.message?l=t[7]:(l=(0,X.jsx)(`span`,{className:`mt-1 block text-sm text-fg-muted`,children:n.message}),t[6]=n.message,t[7]=l);let u;t[8]===n.hints[0]?u=t[9]:(u=n.hints[0]?(0,X.jsx)(`span`,{className:`mt-1 block truncate text-xs text-fg-subtle`,children:n.hints[0]}):null,t[8]=n.hints[0],t[9]=u);let d;t[10]!==c||t[11]!==l||t[12]!==u?(d=(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[c,l,u]}),t[10]=c,t[11]=l,t[12]=u,t[13]=d):d=t[13];let f;t[14]!==r||t[15]!==n.path?(f=n.path?(0,X.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs font-medium text-accent-fg`,children:[r,(0,X.jsx)(y,{className:`size-4`,"aria-hidden":!0})]}):null,t[14]=r,t[15]=n.path,t[16]=f):f=t[16];let p;t[17]!==s||t[18]!==d||t[19]!==f?(p=(0,X.jsxs)(X.Fragment,{children:[s,d,f]}),t[17]=s,t[18]=d,t[19]=f,t[20]=p):p=t[20];let m=p;if(n.path){let e;return t[21]!==m||t[22]!==n.path?(e=(0,X.jsx)(i,{to:n.path,className:`flex items-start gap-3 px-1 py-3 hover:bg-surface-hover/30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:m}),t[21]=m,t[22]=n.path,t[23]=e):e=t[23],e}let h;return t[24]===m?h=t[25]:(h=(0,X.jsx)(`div`,{className:`flex items-start gap-3 px-1 py-3`,children:m}),t[24]=m,t[25]=h),h}function be(e){let t=(0,I.c)(27),{item:n,labels:r}=e,a;t[0]===n.status?a=t[1]:(a=Z(n.status),t[0]=n.status,t[1]=a);let s=a,c=r[n.id]??n.title,l;t[2]===n.status?l=t[3]:(l=o(`flex size-7 shrink-0 items-center justify-center rounded-full`,_e(n.status)),t[2]=n.status,t[3]=l);let u;t[4]===s?u=t[5]:(u=(0,X.jsx)(s,{className:`size-4`,"aria-hidden":!0}),t[4]=s,t[5]=u);let d;t[6]!==l||t[7]!==u?(d=(0,X.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,X.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,X.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,X.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,X.jsx)(y,{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,X.jsxs)(X.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,X.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,X.jsx)(`div`,{className:`flex items-center gap-3 rounded-lg p-3`,children:_}),t[25]=_,t[26]=v),v}function xe(e){let t=(0,I.c)(23),{signal:n,fixLabel:r}=e,a;t[0]===n.status?a=t[1]:(a=Z(n.status),t[0]=n.status,t[1]=a);let o=a,s;t[2]===o?s=t[3]:(s=(0,X.jsx)(o,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=o,t[3]=s);let c;t[4]===n.label?c=t[5]:(c=(0,X.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:n.label}),t[4]=n.label,t[5]=c);let l;t[6]===n.message?l=t[7]:(l=(0,X.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.message}),t[6]=n.message,t[7]=l);let u;t[8]!==c||t[9]!==l?(u=(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10];let d;t[11]!==r||t[12]!==n.path?(d=n.path?(0,X.jsx)(`span`,{className:`sr-only`,children:r}):null,t[11]=r,t[12]=n.path,t[13]=d):d=t[13];let f;t[14]!==s||t[15]!==u||t[16]!==d?(f=(0,X.jsxs)(X.Fragment,{children:[s,u,d]}),t[14]=s,t[15]=u,t[16]=d,t[17]=f):f=t[17];let p=f;if(n.path){let e;return t[18]!==p||t[19]!==n.path?(e=(0,X.jsx)(i,{to:n.path,className:`flex min-w-0 items-start gap-2 px-1 py-3 hover:bg-surface-hover/30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:p}),t[18]=p,t[19]=n.path,t[20]=e):e=t[20],e}let m;return t[21]===p?m=t[22]:(m=(0,X.jsx)(`div`,{className:`flex min-w-0 items-start gap-2 px-1 py-3`,children:p}),t[21]=p,t[22]=m),m}function Se(){let e=d(l(e=>e.language)).setupStatus,{ready:t,error:n,snapshot:r,refresh:i}=Y(),[a,o]=(0,F.useState)(!1),[s,c]=(0,F.useState)(`idle`),u=r?.diagnosticSignals.filter(e=>e.status===`fail`||e.status===`warn`)??[],f=async()=>{if(!(a||!t)){o(!0),c(`idle`);try{await i(),c(`success`)}catch{c(`error`)}finally{o(!1)}}};return(0,X.jsxs)(A,{gap:`gap-6`,children:[(0,X.jsx)(k,{title:e.title}),n?(0,X.jsx)(`p`,{className:`rounded-xl bg-red-50 px-4 py-3 text-sm text-red-700 dark:bg-red-950/30 dark:text-red-300`,children:e.loadError}):null,!t||!r?(0,X.jsx)(N,{sections:2}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ve,{tier:r.healthTier,issueCount:r.issues.length,ready:t,onRunDoctor:()=>void f(),doctorRunning:a,doctorRunState:s}),(0,X.jsxs)(M,{id:`next-steps`,children:[(0,X.jsx)(j,{icon:r.issues.length?w:v,title:e.nextStepsTitle}),r.issues.length?(0,X.jsx)(`div`,{className:`mt-3 flex flex-col gap-1 [&>*]:rounded-lg [&>*]:bg-surface-base/45 [&>*]:px-3`,children:r.issues.slice(0,8).map(t=>(0,X.jsx)(ye,{issue:t,fixLabel:e.fixIssue},`${t.source}:${t.id}`))}):(0,X.jsx)(`div`,{className:`mt-3 flex flex-col gap-1 [&>*]:bg-surface-base/45`,children:r.readiness.map(t=>(0,X.jsx)(be,{item:t,labels:e.readinessLabels},t.id))})]}),(0,X.jsx)(P,{children:(0,X.jsxs)(M,{children:[(0,X.jsx)(j,{icon:E,title:e.diagnosticsTitle}),u.length?(0,X.jsx)(`div`,{className:`mt-3 flex flex-col gap-1 [&>*]:rounded-lg [&>*]:bg-surface-base/45 [&>*]:px-3`,children:u.map(t=>(0,X.jsx)(xe,{signal:t,fixLabel:e.fixIssue},t.id))}):(0,X.jsx)(`p`,{className:`mt-3 py-2 text-sm text-fg-muted`,children:r.diagnosticSignals.length?e.diagnosticsAllClear:e.diagnosticsEmpty})]})})]})]})}export{Se as SetupStatusPanel};