@xopcai/xopc 0.0.90 → 0.0.92

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 (365) hide show
  1. package/README.md +36 -12
  2. package/README.zh-CN.md +36 -12
  3. package/dist/browser-ext/manifest.json +1 -1
  4. package/dist/extensions/feishu/src/outbound/media-load.js +1 -1
  5. package/dist/extensions/feishu/src/workflow-progress.js +1 -1
  6. package/dist/extensions/telegram/src/plugin.js +1 -1
  7. package/dist/extensions/telegram/src/routing-integration.js +2 -2
  8. package/dist/extensions/telegram/src/workflow-progress.js +1 -1
  9. package/dist/extensions/telegram/xopc.extension.json +1 -1
  10. package/dist/extensions/weixin/src/api/api.js +2 -2
  11. package/dist/extensions/weixin/src/auth/accounts.js +1 -1
  12. package/dist/extensions/weixin/src/cdn/upload.js +1 -1
  13. package/dist/extensions/weixin/src/media/data-url.js +1 -1
  14. package/dist/extensions/weixin/src/messaging/debug-mode.js +1 -1
  15. package/dist/extensions/weixin/src/messaging/inbound.js +1 -1
  16. package/dist/extensions/weixin/src/messaging/process-message.js +1 -1
  17. package/dist/extensions/weixin/src/plugin.js +1 -1
  18. package/dist/extensions/weixin/src/storage/sync-buf.js +1 -1
  19. package/dist/extensions/weixin/src/workflow-progress.js +1 -1
  20. package/dist/gateway/static/root/assets/Combination-HAlzriaz.js +41 -0
  21. package/dist/gateway/static/root/assets/agents-uwPn7ZW9.js +222 -0
  22. package/dist/gateway/static/root/assets/apps-page-CWKdhSPU.js +1 -0
  23. package/dist/gateway/static/root/assets/{attachment-preview-renderer-CpyoFbs4.js → attachment-preview-renderer-DBAxQXb-.js} +2 -2
  24. package/dist/gateway/static/root/assets/{attachment-process-heavy-CqVriadb.js → attachment-process-heavy-Csq3TrrP.js} +4 -4
  25. package/dist/gateway/static/root/assets/channels-settings-hEhW7Mbk.js +1 -0
  26. package/dist/gateway/static/root/assets/{channels-status-swr-BrtH2VzC.js → channels-status-swr-XzddfJW2.js} +1 -1
  27. package/dist/gateway/static/root/assets/copy-Dv6d4Dvw.js +1 -0
  28. package/dist/gateway/static/root/assets/{cron-api-CyqbgfHM.js → cron-api--I8LJ44S.js} +1 -1
  29. package/dist/gateway/static/root/assets/cron-page-B0kvgZGR.js +1 -0
  30. package/dist/gateway/static/root/assets/dist-CYgHMQO0.js +1 -0
  31. package/dist/gateway/static/root/assets/{extension-debug-page-D6Ak0STa.js → extension-debug-page-6cRP0nA9.js} +1 -1
  32. package/dist/gateway/static/root/assets/{extension-page-Q0P3d6DW.js → extension-page-DpwIkspI.js} +1 -1
  33. package/dist/gateway/static/root/assets/{extension-settings-page-CL55LwU_.js → extension-settings-page-DYbnQUxH.js} +1 -1
  34. package/dist/gateway/static/root/assets/{fetch-Dqa9iTWl.js → fetch-DTN0w7rV.js} +1 -1
  35. package/dist/gateway/static/root/assets/{field-primitives-HUR6JElP.js → field-primitives-CslW6HwD.js} +1 -1
  36. package/dist/gateway/static/root/assets/heartbeat-config-api-2UiKevxG.js +1 -0
  37. package/dist/gateway/static/root/assets/index-BUKUv7QW.css +1 -0
  38. package/dist/gateway/static/root/assets/{index-BYcGfwcE.js → index-DnevRVa6.js} +63 -59
  39. package/dist/gateway/static/root/assets/logs-page-sOP4TXJ4.js +1 -0
  40. package/dist/gateway/static/root/assets/note-detail-page-B91pLkEI.css +1 -0
  41. package/dist/gateway/static/root/assets/note-detail-page-DvW2qg4i.js +179 -0
  42. package/dist/gateway/static/root/assets/note-time-BEiibLJv.js +1 -0
  43. package/dist/gateway/static/root/assets/notes-page-BFQaquHU.js +1 -0
  44. package/dist/gateway/static/root/assets/{pdf-BnEvgIXZ.js → pdf-epILhEOn.js} +1 -1
  45. package/dist/gateway/static/root/assets/preload-helper-zJ_50EbN.js +1 -0
  46. package/dist/gateway/static/root/assets/sessions-page-CptjDKAX.js +1 -0
  47. package/dist/gateway/static/root/assets/settings-advanced-gate-BctKqHcf.js +2 -0
  48. package/dist/gateway/static/root/assets/{settings-form-section-a0qGVOlr.js → settings-form-section-QJh5ruel.js} +1 -1
  49. package/dist/gateway/static/root/assets/settings-page-V3p-hISB.js +2 -0
  50. package/dist/gateway/static/root/assets/share-preview-page-DBsvvbmD.js +2 -0
  51. package/dist/gateway/static/root/assets/skills-page-q2zPUJAR.js +2 -0
  52. package/dist/gateway/static/root/assets/{theme-store-C0Ehmdo5.js → theme-store-ht5iswWS.js} +1 -1
  53. package/dist/gateway/static/root/assets/toast-z0toXu32.js +1 -0
  54. package/dist/gateway/static/root/assets/url-CWWpfkq1.js +3 -0
  55. package/dist/gateway/static/root/assets/{utils-DRQryzdn.js → utils-DhPv9xoB.js} +1 -1
  56. package/dist/gateway/static/root/assets/vendor-codemirror-DYoKfS8f.js +45 -0
  57. package/dist/gateway/static/root/assets/voice-api-key-field-DLSKUipa.js +1 -0
  58. package/dist/gateway/static/root/assets/{workflow-page.utils-DnG8JBhV.js → workflow-page.utils-CJqnPWkW.js} +1 -1
  59. package/dist/gateway/static/root/assets/workflows-page-DRRQ1A0l.js +27 -0
  60. package/dist/gateway/static/root/index.html +10 -8
  61. package/dist/package.js +1 -1
  62. package/dist/src/agent/agent-manager.js +7 -7
  63. package/dist/src/agent/agent-scope.js +1 -1
  64. package/dist/src/agent/bootstrap/load-bootstrap-files.js +1 -1
  65. package/dist/src/agent/context/workspace-seed.js +2 -2
  66. package/dist/src/agent/goals/goal-run-store.js +4 -4
  67. package/dist/src/agent/goals/persistent-goal-service.js +1 -1
  68. package/dist/src/agent/goals/post-turn.js +2 -2
  69. package/dist/src/agent/image/load-image-media.js +2 -2
  70. package/dist/src/agent/ipc/bus.js +1 -1
  71. package/dist/src/agent/ipc/inbox.js +2 -2
  72. package/dist/src/agent/ipc/socket.js +1 -1
  73. package/dist/src/agent/mcp/bundle-mcp-config.d.ts +2 -9
  74. package/dist/src/agent/mcp/bundle-mcp-config.js +10 -34
  75. package/dist/src/agent/mcp/bundle-mcp-config.js.map +1 -1
  76. package/dist/src/agent/mcp/bundle-mcp-materialize.js +1 -1
  77. package/dist/src/agent/mcp/bundle-mcp-policy.js +2 -2
  78. package/dist/src/agent/mcp/bundle-mcp-policy.js.map +1 -1
  79. package/dist/src/agent/mcp/bundle-mcp-runtime.js +5 -5
  80. package/dist/src/agent/mcp/bundle-mcp-runtime.js.map +1 -1
  81. package/dist/src/agent/mcp/index.js +2 -2
  82. package/dist/src/agent/mcp/mcp-transport-config.js +1 -1
  83. package/dist/src/agent/mcp/mcp-transport.js +1 -1
  84. package/dist/src/agent/memory/builtin-memory-store.js +1 -1
  85. package/dist/src/agent/memory/dreaming/deep-promotion.js +1 -1
  86. package/dist/src/agent/memory/dreaming/events.js +1 -1
  87. package/dist/src/agent/memory/dreaming/last-run.js +1 -1
  88. package/dist/src/agent/memory/dreaming/light-sweep.js +1 -1
  89. package/dist/src/agent/memory/dreaming/preview.js +1 -1
  90. package/dist/src/agent/memory/dreaming/rem-patterns.js +1 -1
  91. package/dist/src/agent/memory/dreaming/short-term-store.js +1 -1
  92. package/dist/src/agent/memory/dreaming/utils.js +1 -1
  93. package/dist/src/agent/memory/plugin-discovery.js +1 -1
  94. package/dist/src/agent/models/manager.js +1 -1
  95. package/dist/src/agent/prompt/service-prompt-builder.js +2 -2
  96. package/dist/src/agent/reply/post-compaction-context.js +1 -1
  97. package/dist/src/agent/reply/workspace-boundary-read.js +1 -1
  98. package/dist/src/agent/sandbox/path-policy.js +2 -2
  99. package/dist/src/agent/service/build-direct-message-content.js +1 -1
  100. package/dist/src/agent/service.js +4 -4
  101. package/dist/src/agent/session/session-inspector.js +1 -1
  102. package/dist/src/agent/skills/config.js +1 -1
  103. package/dist/src/agent/skills/hub-hash.js +2 -2
  104. package/dist/src/agent/skills/hub-lock.js +1 -1
  105. package/dist/src/agent/skills/hub-pull.js +2 -2
  106. package/dist/src/agent/skills/index.js +1 -1
  107. package/dist/src/agent/skills/managed-store.js +1 -1
  108. package/dist/src/agent/skills/scanner.js +1 -1
  109. package/dist/src/agent/skills/skill-manage-ops.js +1 -1
  110. package/dist/src/agent/skills/skill-manager.js +1 -1
  111. package/dist/src/agent/tools/dreaming-tool.js +1 -1
  112. package/dist/src/agent/tools/factory.js +1 -1
  113. package/dist/src/agent/tools/image-generate-tool.js +1 -1
  114. package/dist/src/agent/tools/send-media.js +1 -1
  115. package/dist/src/agent/tools/skill-manage-tool.js +1 -1
  116. package/dist/src/agent/tools/workflow-tool.js +1 -1
  117. package/dist/src/agent/tools/write.js +1 -1
  118. package/dist/src/agent/workflow/catalog.js +1 -1
  119. package/dist/src/auth/credentials.js +3 -3
  120. package/dist/src/auth/profiles/store.js +1 -1
  121. package/dist/src/auth/sync-provider-auth.js +1 -1
  122. package/dist/src/browser/cache-dir-policy.js +1 -1
  123. package/dist/src/browser/cdp-local-launcher.js +2 -2
  124. package/dist/src/browser/providers/browser-ext-install.js +3 -3
  125. package/dist/src/browser/providers/cloakbrowser.js +4 -4
  126. package/dist/src/browser/providers/playwright-doctor.js +1 -1
  127. package/dist/src/browser/stealth.js +1 -1
  128. package/dist/src/channels/attachments/inbound-persist.js +1 -1
  129. package/dist/src/channels/attachments/outbound-tts-persist.js +1 -1
  130. package/dist/src/channels/outbound/persist-store.js +1 -1
  131. package/dist/src/channels/pairing/allow-from-file.js +1 -1
  132. package/dist/src/channels/pairing/pairing-store.js +2 -2
  133. package/dist/src/chat-commands/agent-edit.js +2 -2
  134. package/dist/src/chat-commands/builtins/config.js +2 -2
  135. package/dist/src/chat-commands/context.js +1 -1
  136. package/dist/src/cli/command-catalog.js +0 -4
  137. package/dist/src/cli/command-catalog.js.map +1 -1
  138. package/dist/src/cli/command-loaders.js +1 -2
  139. package/dist/src/cli/command-loaders.js.map +1 -1
  140. package/dist/src/cli/command-manifest.js +0 -4
  141. package/dist/src/cli/command-manifest.js.map +1 -1
  142. package/dist/src/cli/commands/config.js +1 -1
  143. package/dist/src/cli/commands/doctor/checks/config-health.js +1 -1
  144. package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
  145. package/dist/src/cli/commands/doctor/checks/session-integrity.js +2 -2
  146. package/dist/src/cli/commands/doctor/checks/state-integrity.js +1 -1
  147. package/dist/src/cli/commands/doctor/checks/workspace-status.js +1 -1
  148. package/dist/src/cli/commands/extension-dev.js +1 -1
  149. package/dist/src/cli/commands/extension-marketplace.js +1 -1
  150. package/dist/src/cli/commands/extension-pack.js +1 -1
  151. package/dist/src/cli/commands/gateway/logs.js +1 -1
  152. package/dist/src/cli/commands/image.js +1 -1
  153. package/dist/src/cli/commands/init.js +4 -4
  154. package/dist/src/cli/commands/onboard.js +1 -1
  155. package/dist/src/cli/utils/init-workspace-core.js +2 -2
  156. package/dist/src/commands/agents.config.js +1 -1
  157. package/dist/src/config/agent-profile.js +1 -1
  158. package/dist/src/config/gateway-bind.js +1 -1
  159. package/dist/src/config/index.d.ts +0 -1
  160. package/dist/src/config/index.js +6 -7
  161. package/dist/src/config/index.js.map +1 -1
  162. package/dist/src/config/loader.js +2 -2
  163. package/dist/src/config/models-json.js +2 -2
  164. package/dist/src/config/paths-state.js +1 -1
  165. package/dist/src/config/profile.js +2 -2
  166. package/dist/src/config/schema.d.ts +36 -6
  167. package/dist/src/config/schema.js +13 -11
  168. package/dist/src/config/schema.js.map +1 -1
  169. package/dist/src/config/workspace-path.js +1 -1
  170. package/dist/src/connectors/builtin-catalog.d.ts +2 -0
  171. package/dist/src/connectors/builtin-catalog.js +152 -0
  172. package/dist/src/connectors/builtin-catalog.js.map +1 -0
  173. package/dist/src/connectors/catalog.d.ts +5 -0
  174. package/dist/src/connectors/catalog.js +13 -0
  175. package/dist/src/connectors/catalog.js.map +1 -0
  176. package/dist/src/connectors/health.d.ts +3 -0
  177. package/dist/src/connectors/health.js +61 -0
  178. package/dist/src/connectors/health.js.map +1 -0
  179. package/dist/src/connectors/install.d.ts +5 -0
  180. package/dist/src/connectors/install.js +46 -0
  181. package/dist/src/connectors/install.js.map +1 -0
  182. package/dist/src/connectors/instances.d.ts +4 -0
  183. package/dist/src/connectors/instances.js +43 -0
  184. package/dist/src/connectors/instances.js.map +1 -0
  185. package/dist/src/connectors/materialize.d.ts +9 -0
  186. package/dist/src/connectors/materialize.js +76 -0
  187. package/dist/src/connectors/materialize.js.map +1 -0
  188. package/dist/src/connectors/oauth.d.ts +22 -0
  189. package/dist/src/connectors/oauth.js +99 -0
  190. package/dist/src/connectors/oauth.js.map +1 -0
  191. package/dist/src/connectors/providers.d.ts +9 -0
  192. package/dist/src/connectors/providers.js +20 -0
  193. package/dist/src/connectors/providers.js.map +1 -0
  194. package/dist/src/connectors/secret-store.d.ts +7 -0
  195. package/dist/src/connectors/secret-store.js +47 -0
  196. package/dist/src/connectors/secret-store.js.map +1 -0
  197. package/dist/src/connectors/types.d.ts +102 -0
  198. package/dist/src/connectors/types.js +1 -0
  199. package/dist/src/connectors/usage.d.ts +6 -0
  200. package/dist/src/connectors/usage.js +63 -0
  201. package/dist/src/connectors/usage.js.map +1 -0
  202. package/dist/src/cron/executor.js +2 -2
  203. package/dist/src/cron/persistence.js +1 -1
  204. package/dist/src/cron/run-log-store.js +1 -1
  205. package/dist/src/daemon/constants.js +1 -1
  206. package/dist/src/daemon/install-plan.js +2 -2
  207. package/dist/src/daemon/launchd.js +2 -2
  208. package/dist/src/daemon/schtasks.js +2 -2
  209. package/dist/src/daemon/systemd.js +2 -2
  210. package/dist/src/extensions/bundle-mcp.js +1 -1
  211. package/dist/src/extensions/discover-extensions.js +1 -1
  212. package/dist/src/extensions/health.js +1 -1
  213. package/dist/src/extensions/loader.js +1 -1
  214. package/dist/src/extensions/lockfile.js +2 -2
  215. package/dist/src/extensions/update.js +1 -1
  216. package/dist/src/gateway/agents-admin.js +3 -3
  217. package/dist/src/gateway/file-path-classifier.js +2 -2
  218. package/dist/src/gateway/heartbeat/service.js +1 -1
  219. package/dist/src/gateway/hono/lib/config-payload.d.ts +1 -0
  220. package/dist/src/gateway/hono/lib/config-payload.js +2 -1
  221. package/dist/src/gateway/hono/lib/config-payload.js.map +1 -1
  222. package/dist/src/gateway/hono/lib/extension-store.js +2 -2
  223. package/dist/src/gateway/hono/lib/static-ui.js +2 -2
  224. package/dist/src/gateway/hono/middleware/auth.js +1 -2
  225. package/dist/src/gateway/hono/middleware/auth.js.map +1 -1
  226. package/dist/src/gateway/hono/oauth.js +1 -1
  227. package/dist/src/gateway/hono/routes/agents.js +1 -1
  228. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
  229. package/dist/src/gateway/hono/routes/config-patch/gateway.d.ts +2 -2
  230. package/dist/src/gateway/hono/routes/config-patch/gateway.js +12 -0
  231. package/dist/src/gateway/hono/routes/config-patch/gateway.js.map +1 -1
  232. package/dist/src/gateway/hono/routes/config-patch/misc.js +1 -1
  233. package/dist/src/gateway/hono/routes/connectors.d.ts +3 -0
  234. package/dist/src/gateway/hono/routes/connectors.js +177 -0
  235. package/dist/src/gateway/hono/routes/connectors.js.map +1 -0
  236. package/dist/src/gateway/hono/routes/dreaming.js +1 -1
  237. package/dist/src/gateway/hono/routes/home.d.ts +12 -0
  238. package/dist/src/gateway/hono/routes/home.js +50 -0
  239. package/dist/src/gateway/hono/routes/home.js.map +1 -0
  240. package/dist/src/gateway/hono/routes/host-fs.js +2 -2
  241. package/dist/src/gateway/hono/routes/lazy-bundles.js +20 -4
  242. package/dist/src/gateway/hono/routes/lazy-bundles.js.map +1 -1
  243. package/dist/src/gateway/hono/routes/models.js +1 -1
  244. package/dist/src/gateway/hono/routes/notes.d.ts +3 -0
  245. package/dist/src/gateway/hono/routes/notes.js +305 -0
  246. package/dist/src/gateway/hono/routes/notes.js.map +1 -0
  247. package/dist/src/gateway/hono/routes/sessions.js.map +1 -1
  248. package/dist/src/gateway/hono/routes/shares.js +1 -1
  249. package/dist/src/gateway/hono/routes/workspace.js +4 -4
  250. package/dist/src/gateway/lock.js +3 -3
  251. package/dist/src/gateway/ports.js +1 -1
  252. package/dist/src/gateway/service/agent-runner.js +2 -2
  253. package/dist/src/gateway/service/marketplace-service.js +2 -2
  254. package/dist/src/gateway/service.d.ts +3 -0
  255. package/dist/src/gateway/service.js +11 -1
  256. package/dist/src/gateway/service.js.map +1 -1
  257. package/dist/src/gateway/workspace-fs-file-list.js +1 -1
  258. package/dist/src/gateway/workspace-ripgrep.d.ts +6 -0
  259. package/dist/src/gateway/workspace-ripgrep.js +62 -11
  260. package/dist/src/gateway/workspace-ripgrep.js.map +1 -1
  261. package/dist/src/heartbeat/index.js +1 -1
  262. package/dist/src/infra/brew.js +1 -1
  263. package/dist/src/infra/package-json.js +1 -1
  264. package/dist/src/infra/package-update-steps.js +1 -1
  265. package/dist/src/infra/path-env.js +2 -2
  266. package/dist/src/infra/restart.js +2 -2
  267. package/dist/src/infra/stable-node-path.js +1 -1
  268. package/dist/src/infra/update-check.js +1 -1
  269. package/dist/src/infra/update-global.js +1 -1
  270. package/dist/src/infra/update-lock.js +3 -3
  271. package/dist/src/infra/update-runner.js +1 -1
  272. package/dist/src/infra/update-startup.js +2 -2
  273. package/dist/src/infra/write-file-atomic.js +2 -2
  274. package/dist/src/mcp/channel-bridge.js +1 -1
  275. package/dist/src/mcp/channel-bridge.js.map +1 -1
  276. package/dist/src/notes/attachment-ref.d.ts +9 -0
  277. package/dist/src/notes/attachment-ref.js +27 -0
  278. package/dist/src/notes/attachment-ref.js.map +1 -0
  279. package/dist/src/notes/index.d.ts +4 -0
  280. package/dist/src/notes/index.js +4 -0
  281. package/dist/src/notes/note-attachment-sync.d.ts +7 -0
  282. package/dist/src/notes/note-attachment-sync.js +46 -0
  283. package/dist/src/notes/note-attachment-sync.js.map +1 -0
  284. package/dist/src/notes/note-index-meta.d.ts +14 -0
  285. package/dist/src/notes/note-index-meta.js +87 -0
  286. package/dist/src/notes/note-index-meta.js.map +1 -0
  287. package/dist/src/notes/paths.d.ts +5 -0
  288. package/dist/src/notes/paths.js +23 -0
  289. package/dist/src/notes/paths.js.map +1 -0
  290. package/dist/src/notes/service.d.ts +53 -0
  291. package/dist/src/notes/service.js +373 -0
  292. package/dist/src/notes/service.js.map +1 -0
  293. package/dist/src/notes/store.d.ts +34 -0
  294. package/dist/src/notes/store.js +342 -0
  295. package/dist/src/notes/store.js.map +1 -0
  296. package/dist/src/notes/types.d.ts +199 -0
  297. package/dist/src/notes/types.js +1 -0
  298. package/dist/src/providers/auth-runtime/auth-profile-store.js +1 -1
  299. package/dist/src/providers/index.js +2 -2
  300. package/dist/src/providers/model-registry.js +1 -1
  301. package/dist/src/session/config-store.js +2 -2
  302. package/dist/src/session/init-session-turn.js +2 -2
  303. package/dist/src/session/parity/jsonl-transcript-io.js +2 -2
  304. package/dist/src/session/parity/sessions-json-file.js +1 -1
  305. package/dist/src/session/parity/transcript-file-lock.js +2 -2
  306. package/dist/src/session/parity/transcript-paths.js +1 -1
  307. package/dist/src/session/resolve-session.js +4 -4
  308. package/dist/src/session/search-index-cache.js +1 -1
  309. package/dist/src/session/search-index.js +1 -1
  310. package/dist/src/session/session-title.js +2 -2
  311. package/dist/src/session/store.d.ts +2 -0
  312. package/dist/src/session/store.js +27 -7
  313. package/dist/src/session/store.js.map +1 -1
  314. package/dist/src/share/share-auto.js +2 -2
  315. package/dist/src/share/share-store.js +3 -3
  316. package/dist/src/share/share-thumbnail.js +2 -2
  317. package/dist/src/share/share-zip.js +1 -1
  318. package/dist/src/share/site-share-store.js +3 -3
  319. package/dist/src/share/site-static-serve.js +1 -1
  320. package/dist/src/tui/clipboard-image.js +3 -3
  321. package/dist/src/tui/theme-manager.js +1 -1
  322. package/dist/src/tui/tui-keybindings-file.js +1 -1
  323. package/dist/src/tui/tui-scoped-models.js +2 -2
  324. package/dist/src/tui/tui-settings.js +1 -1
  325. package/dist/src/tui/tui.js +3 -3
  326. package/dist/src/tunnel/frpc-binary.js +3 -3
  327. package/dist/src/tunnel/frpc-config.js +1 -1
  328. package/dist/src/tunnel/frpc-extract.js +1 -1
  329. package/dist/src/tunnel/tunnel-state.js +1 -1
  330. package/dist/src/utils/logger/audit.js +1 -1
  331. package/dist/src/utils/logger/log-store.js +1 -1
  332. package/dist/src/utils/logger/rotation.js +1 -1
  333. package/dist/src/voice/tts/audio.js +1 -1
  334. package/dist/src/voice/tts/providers/edge-speech.js +2 -2
  335. package/dist/src/workflows/store/event-store.js +1 -1
  336. package/dist/src/workflows/store/run-store.js +1 -1
  337. package/package.json +1 -1
  338. package/dist/gateway/static/root/assets/agents-cPvvYLXo.js +0 -222
  339. package/dist/gateway/static/root/assets/apps-page-Bk1_P5FJ.js +0 -1
  340. package/dist/gateway/static/root/assets/channels-settings-CZoeQwHz.js +0 -1
  341. package/dist/gateway/static/root/assets/cron-dreaming-jobs-Ip703-qM.js +0 -2
  342. package/dist/gateway/static/root/assets/cron-page-BpLdiQN8.js +0 -1
  343. package/dist/gateway/static/root/assets/dist-BTWC-BTN.js +0 -45
  344. package/dist/gateway/static/root/assets/dist-BpAiK86n.js +0 -1
  345. package/dist/gateway/static/root/assets/eye-DAfL1U7M.js +0 -1
  346. package/dist/gateway/static/root/assets/heartbeat-config-api-DusckjUX.js +0 -1
  347. package/dist/gateway/static/root/assets/index-V7MQ7834.css +0 -1
  348. package/dist/gateway/static/root/assets/logs-page-_HcZ2fgK.js +0 -1
  349. package/dist/gateway/static/root/assets/sessions-page-iezSMjho.js +0 -1
  350. package/dist/gateway/static/root/assets/settings-page-C9_nYQwM.js +0 -3
  351. package/dist/gateway/static/root/assets/share-preview-page-DExl7CJy.js +0 -2
  352. package/dist/gateway/static/root/assets/skills-page-BlgGD93t.js +0 -2
  353. package/dist/gateway/static/root/assets/url-fxyYANfA.js +0 -3
  354. package/dist/gateway/static/root/assets/vendor-codemirror-D0yxdRpg.js +0 -58
  355. package/dist/gateway/static/root/assets/voice-api-key-field-D0viACE2.js +0 -1
  356. package/dist/gateway/static/root/assets/workflows-page-BvMobnJP.js +0 -27
  357. package/dist/src/cli/commands/mcp.d.ts +0 -4
  358. package/dist/src/cli/commands/mcp.js +0 -85
  359. package/dist/src/cli/commands/mcp.js.map +0 -1
  360. package/dist/src/config/mcp-config.d.ts +0 -34
  361. package/dist/src/config/mcp-config.js +0 -116
  362. package/dist/src/config/mcp-config.js.map +0 -1
  363. package/dist/src/gateway/hono/routes/mcp.d.ts +0 -3
  364. package/dist/src/gateway/hono/routes/mcp.js +0 -99
  365. package/dist/src/gateway/hono/routes/mcp.js.map +0 -1
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{i,o as a,t as o}from"./url-fxyYANfA.js";import{a as s,i as c}from"./vendor-swr-BIWyz7Rc.js";import{a as l,i as u,n as d,o as f,r as p,s as m}from"./dist-BTWC-BTN.js";import{a as h,n as g,t as _}from"./fetch-Dqa9iTWl.js";import{$n as v,Aa as y,Ai as b,Bi as x,Ci as S,Fr as C,Ha as w,Ir as T,Jr as E,La as D,N as O,Qn as k,Rr as A,Xn as j,Yn as M,Zn as N,at as P,fn as F,pi as I,qa as L,sa as R,ui as z,ur as B,wa as V}from"./index-BYcGfwcE.js";var H=e(t(),1),U=n();function W(e){return e===`builtin`||e===`user`?e:`marketplace`}async function G(e){try{let t=await e.json();if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&typeof t.error.message==`string`)return t.error.message;if(typeof t.message==`string`)return t.message}catch{}return e.statusText||`HTTP ${e.status}`}async function ee(e){let t=await _(o(`/api/marketplace/packages/${encodeURIComponent(e.trim())}`),{cache:`no-store`});if(!t.ok)throw Error(await G(t));let n=await t.json();if(!n.ok||!n.payload?.id)throw Error(n.error??`Invalid response`);return n.payload}async function K(e){let t=await _(o(`/api/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await G(t));let n=await t.json();if(!n.ok||!n.payload?.extensionId)throw Error(n.error??`Invalid response`);return n.payload}async function q(e){let t=await _(o(`/api/extensions/bundled/activation`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e.extensionId.trim(),enabled:e.enabled})});if(!t.ok)throw Error(await G(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error?.message??`Invalid response`);return n.payload}async function J(e){let t=await _(o(`/api/marketplace/uninstall`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e})});if(!t.ok)throw Error(await G(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error??`Invalid response`);return n.payload}var Y=r();function X(e,t){let n=e.find(e=>e.id===t);return n?n.source===`bundled`?`bundled`:`user`:`absent`}var Z={q:``,debounced:``,detailPkg:null,rowBusy:null,actionError:null,restartHint:null};function te({className:e}){let t=a(i(e=>e.language)).appsPage,n=h(e=>!!e.token),r=j(),{mutate:l}=s(),[u,d]=(0,H.useReducer)(O,Z),{q:f,debounced:p,detailPkg:m,rowBusy:_,actionError:v,restartHint:y}=u,S=n?`marketplace-${p}`:null;(0,H.useEffect)(()=>{let e=window.setTimeout(()=>d({type:`patch`,patch:{debounced:f.trim()}}),300);return()=>window.clearTimeout(e)},[f]);let{data:C,isLoading:w,error:D}=c(S,async()=>g(p.length>0?o(`/api/marketplace?q=${encodeURIComponent(p)}`):o(`/api/marketplace`)),{revalidateOnFocus:!1}),k=(0,H.useCallback)(()=>{l(`gateway-extensions-list`),P()},[l]),A=(0,H.useCallback)(async(e,n)=>{d({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let r=await K({name:e,overwrite:n});k(),r.requiresGatewayRestart&&d({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw d({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceInstallFailed}}),e}finally{d({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceInstallFailed,t.marketplaceRestartHint,k]),M=(0,H.useCallback)(async e=>{d({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let n=await J(e);k(),n.requiresGatewayRestart&&d({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw d({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceUninstallFailed}}),e}finally{d({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceRestartHint,t.marketplaceUninstallFailed,k]),N=C?.extensions??[];return(0,Y.jsxs)(`div`,{className:T(`flex flex-col gap-4`,e),children:[(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsx)(I,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,Y.jsx)(`input`,{type:`search`,value:f,onChange:e=>d({type:`patch`,patch:{q:e.target.value}}),placeholder:t.marketplaceSearchPlaceholder,className:`ui-input h-10 w-full rounded-lg border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted`})]}),D?(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:D instanceof Error?D.message:t.marketplaceLoadFailed}):null,v?(0,Y.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:v}):null,y?(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:y}):null,w&&!C?(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`…`}):(0,Y.jsx)(`ul`,{className:`flex flex-col gap-3`,children:N.length===0?(0,Y.jsx)(`li`,{className:`text-sm text-fg-muted`,children:t.marketplaceEmpty}):N.map(e=>{let n=X(r,e.id),i=_===e.id;return(0,Y.jsx)(`li`,{className:`list-none`,children:(0,Y.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-label":`${e.name}, ${t.marketplaceDetailTitle}`,onClick:()=>d({type:`patch`,patch:{detailPkg:e.id}}),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),d({type:`patch`,patch:{detailPkg:e.id}}))},className:T(`flex w-full cursor-pointer flex-wrap items-start gap-3 rounded-xl border border-edge bg-surface-base p-4 text-left shadow-surface`,`transition-[transform,background-color,border-color,box-shadow] duration-150 ease-out`,`hover:border-edge-subtle hover:bg-surface-hover/40`,`active:scale-[0.992] active:bg-surface-hover/55`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`dark:hover:bg-surface-hover/25 dark:active:bg-surface-hover/35`),children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`h3`,{className:`font-semibold text-fg`,children:e.name}),e.verified?(0,Y.jsx)(V,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75,"aria-label":`Verified`}):null,e.version?(0,Y.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e.version}):null]}),e.description?(0,Y.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:e.description}):null,(0,Y.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:(e.categories??[]).map(e=>(0,Y.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-0.5 text-[11px] text-fg-muted`,children:e},e))}),(0,Y.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,Y.jsx)(b,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,Y.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:e.npmPackage})]})]}),(0,Y.jsx)(`div`,{role:`group`,className:`flex shrink-0 flex-col items-end gap-2 sm:min-w-[9rem]`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:n===`bundled`?(0,Y.jsx)(`span`,{className:`rounded-md bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.marketplaceBuiltin}):n===`user`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`text-[11px] font-medium text-fg-muted`,children:t.marketplaceInstalled}),(0,Y.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>{window.confirm(t.marketplaceUninstallConfirm)&&M(e.id).catch(()=>{})},className:T(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-xs font-medium text-fg`,`transition-colors active:scale-[0.98] active:bg-surface-hover/80`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[i?(0,Y.jsx)(x,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Y.jsx)(E,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t.marketplaceUninstall]})]}):(0,Y.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>{A(e.id,!1).catch(()=>{})},className:T(`inline-flex w-full items-center justify-center rounded-lg bg-accent px-3 py-2 text-xs font-medium text-white`,`shadow-surface transition-[transform,background-color] active:scale-[0.98]`,`hover:bg-accent-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,`disabled:pointer-events-none disabled:opacity-50`),children:[i?(0,Y.jsx)(x,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,t.marketplaceInstall]})})]})},e.id)})}),m?(0,Y.jsx)(ne,{packageName:m,copy:t,extensions:r,onClose:()=>d({type:`patch`,patch:{detailPkg:null}}),onInstall:A,onUninstall:M}):null]})}function ne(e){let t=(0,U.c)(61),{packageName:n,copy:r,extensions:i,onClose:a,onInstall:o,onUninstall:s}=e,[p,g]=(0,H.useState)(!1),_=h(oe)?`ext-mp-detail-${n}`:null,v;t[0]===n?v=t[1]:(v=async()=>ee(n),t[0]=n,t[1]=v);let y;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(y={revalidateOnFocus:!1},t[2]=y):y=t[2];let{data:b,error:S,isLoading:C}=c(_,v,y),O;t[3]!==i||t[4]!==n?(O=X(i,n),t[3]=i,t[4]=n,t[5]=O):O=t[5];let k=O,j=k===`user`,M;t[6]!==r.marketplaceNoReadme||t[7]!==b?(M=b?.readme?.trim()||(b?.description?.trim()?`### ${b.name}\n\n${b.description}`:`*${r.marketplaceNoReadme}*`),t[6]=r.marketplaceNoReadme,t[7]=b,t[8]=M):M=t[8];let N=M,P;t[9]===a?P=t[10]:(P=e=>!e&&a(),t[9]=a,t[10]=P);let I;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Y.jsx)(u,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[11]=I):I=t[11];let L;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Y.jsx)(D,{className:`size-5`}),t[12]=L):L=t[12];let R;t[13]!==r.detailBack||t[14]!==a?(R=(0,Y.jsx)(`button`,{type:`button`,onClick:a,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r.detailBack,children:L}),t[13]=r.detailBack,t[14]=a,t[15]=R):R=t[15];let z;t[16]===r.marketplaceDetailTitle?z=t[17]:(z=(0,Y.jsx)(m,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:r.marketplaceDetailTitle}),t[16]=r.marketplaceDetailTitle,t[17]=z);let B;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Y.jsx)(A,{className:`size-5`}),t[18]=B):B=t[18];let V;t[19]!==r.detailClose||t[20]!==a?(V=(0,Y.jsx)(`button`,{type:`button`,onClick:a,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r.detailClose,children:B}),t[19]=r.detailClose,t[20]=a,t[21]=V):V=t[21];let W;t[22]!==V||t[23]!==R||t[24]!==z?(W=(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[R,z,V]}),t[22]=V,t[23]=R,t[24]=z,t[25]=W):W=t[25];let G;t[26]!==r.marketplaceAuthor||t[27]!==r.marketplaceDetailLoadFailed||t[28]!==r.marketplaceDetailReadmeHeading||t[29]!==r.marketplaceDownloads||t[30]!==r.marketplaceVersion||t[31]!==b||t[32]!==S||t[33]!==C||t[34]!==N?(G=C&&!b?(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`…`}):S?(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.marketplaceDetailLoadFailed}):b?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:b.name}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:(0,Y.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:b.id})}),(0,Y.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceAuthor}),(0,Y.jsx)(`dd`,{children:b.author.username})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceVersion}),(0,Y.jsx)(`dd`,{children:b.latestVersion.version})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceDownloads}),(0,Y.jsx)(`dd`,{children:b.downloads})]})]}),b.readme?.trim()?(0,Y.jsx)(`h4`,{className:`mb-2 mt-6 text-sm font-semibold text-fg`,children:r.marketplaceDetailReadmeHeading}):null,(0,Y.jsx)(`div`,{className:`markdown-content min-w-0 break-words text-sm`,children:(0,Y.jsx)(F,{content:N})})]}):null,t[26]=r.marketplaceAuthor,t[27]=r.marketplaceDetailLoadFailed,t[28]=r.marketplaceDetailReadmeHeading,t[29]=r.marketplaceDownloads,t[30]=r.marketplaceVersion,t[31]=b,t[32]=S,t[33]=C,t[34]=N,t[35]=G):G=t[35];let K;t[36]===G?K=t[37]:(K=(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:G}),t[36]=G,t[37]=K);let q;t[38]!==p||t[39]!==r.marketplaceBuiltinGoBuiltin||t[40]!==r.marketplaceBuiltinManageHint||t[41]!==r.marketplaceInstall||t[42]!==r.marketplaceReinstall||t[43]!==r.marketplaceReinstallConfirm||t[44]!==r.marketplaceUninstall||t[45]!==r.marketplaceUninstallConfirm||t[46]!==b||t[47]!==k||t[48]!==a||t[49]!==o||t[50]!==s||t[51]!==n||t[52]!==j?(q=b?(0,Y.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:k===`bundled`?(0,Y.jsxs)(`div`,{className:`flex w-full flex-col items-stretch gap-2`,children:[(0,Y.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:r.marketplaceBuiltinManageHint}),(0,Y.jsx)(w,{to:`/apps?tab=builtin`,onClick:a,className:`inline-flex w-fit items-center justify-center rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:r.marketplaceBuiltinGoBuiltin})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`button`,{type:`button`,disabled:p,onClick:()=>{j&&!window.confirm(r.marketplaceReinstallConfirm)||(g(!0),o(n,j).catch(ie).finally(()=>g(!1)))},className:T(`inline-flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium`,`bg-accent text-white shadow-surface hover:bg-accent-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`disabled:pointer-events-none disabled:opacity-50`),children:[p?(0,Y.jsx)(x,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,j?r.marketplaceReinstall:r.marketplaceInstall]}),j?(0,Y.jsxs)(`button`,{type:`button`,disabled:p,onClick:()=>{window.confirm(r.marketplaceUninstallConfirm)&&(g(!0),s(n).then(()=>a()).catch(re).finally(()=>g(!1)))},className:T(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,Y.jsx)(E,{className:`size-4 shrink-0`,"aria-hidden":!0}),r.marketplaceUninstall]}):null]})}):null,t[38]=p,t[39]=r.marketplaceBuiltinGoBuiltin,t[40]=r.marketplaceBuiltinManageHint,t[41]=r.marketplaceInstall,t[42]=r.marketplaceReinstall,t[43]=r.marketplaceReinstallConfirm,t[44]=r.marketplaceUninstall,t[45]=r.marketplaceUninstallConfirm,t[46]=b,t[47]=k,t[48]=a,t[49]=o,t[50]=s,t[51]=n,t[52]=j,t[53]=q):q=t[53];let J;t[54]!==W||t[55]!==K||t[56]!==q?(J=(0,Y.jsxs)(l,{children:[I,(0,Y.jsxs)(d,{className:`fixed left-1/2 top-1/2 z-[131] flex max-h-[min(90vh,44rem)] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,onOpenAutoFocus:ae,children:[W,K,q]})]}),t[54]=W,t[55]=K,t[56]=q,t[57]=J):J=t[57];let Z;return t[58]!==J||t[59]!==P?(Z=(0,Y.jsx)(f,{defaultOpen:!0,onOpenChange:P,children:J}),t[58]=J,t[59]=P,t[60]=Z):Z=t[60],Z}function re(){}function ie(){}function ae(e){return e.preventDefault()}function oe(e){return!!e.token}function se(){let e=i(e=>e.language),t=a(e),n=B(e=>e.setPageHeader),r=B(e=>e.clearPageHeader),o=j(),s=N(),[c,l]=L(),u=W(c.get(`tab`)),d=c.get(`q`)??``,[f,p]=(0,H.useState)(u),[m,h]=(0,H.useState)(d),[g,_]=(0,H.useState)(null),v=c.toString(),y=(0,H.useRef)(v);if(y.current!==v){y.current=v;let e=W(c.get(`tab`)),t=c.get(`q`)??``;p(t=>t===e?t:e),h(e=>e===t?e:t)}(0,H.useEffect)(()=>{l(e=>{let t=new URLSearchParams(e),n=m.trim();return n?t.set(`q`,n):t.delete(`q`),f===`marketplace`?t.delete(`tab`):t.set(`tab`,f),t.toString()===e.toString()?e:t},{replace:!0})},[f,m,l]);let b=(0,H.useMemo)(()=>o.filter(e=>e.source===`bundled`),[o]),x=(0,H.useMemo)(()=>o.filter(e=>e.source!==`bundled`),[o]),S=f===`builtin`?b:x,C=(0,H.useMemo)(()=>{let t=m.trim().toLowerCase(),n=S;return t&&(n=n.filter(e=>(e.name??``).toLowerCase().includes(t)||e.id.toLowerCase().includes(t)||(e.description??``).toLowerCase().includes(t))),n.toSorted((t,n)=>t.hasUi===n.hasUi?(t.name||t.id).localeCompare(n.name||n.id,e):t.hasUi?-1:1)},[S,m,e]);if((0,H.useEffect)(()=>{_(e=>{if(!e)return e;let t=o.find(t=>t.id===e.id);return t?Q(e)===Q(t)&&e.active===t.active?e:t:null})},[o]),(0,H.useLayoutEffect)(()=>(n({startExtra:null,main:(0,Y.jsx)(`div`,{className:`w-full min-w-0 px-3 sm:px-5 xl:px-6`,children:(0,Y.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,children:t.appsPage.title})}),end:null}),()=>r()),[r,t.appsPage.title,n]),s&&f!==`marketplace`)return(0,Y.jsx)(pe,{});let w=f!==`marketplace`&&S.length>0;return(0,Y.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,Y.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[(0,Y.jsxs)(`header`,{className:`mb-6`,children:[(0,Y.jsx)(`h1`,{className:`text-xl font-semibold text-fg`,children:t.appsPage.title}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.appsPage.subtitle})]}),(0,Y.jsxs)(`div`,{className:`mb-5 flex flex-col gap-3 border-b border-edge-subtle pb-3 sm:flex-row sm:items-center sm:justify-between dark:border-edge-subtle`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-x-1 gap-y-1`,role:`tablist`,"aria-label":t.appsPage.appsNavAria,children:[(0,Y.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":f===`marketplace`,className:T(`relative max-w-full rounded-md px-3 py-2 text-left text-sm font-medium transition-colors sm:text-center`,f===`marketplace`?`text-fg`:`text-fg-muted hover:text-fg`,f===`marketplace`&&`after:absolute after:bottom-0 after:left-1/2 after:h-0.5 after:w-9 after:-translate-x-1/2 after:rounded-full after:bg-accent`),onClick:()=>p(`marketplace`),children:t.appsPage.tabMarketplace}),(0,Y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":f===`builtin`,className:T(`relative rounded-md px-3 py-2 text-sm font-medium transition-colors`,f===`builtin`?`text-fg`:`text-fg-muted hover:text-fg`,f===`builtin`&&`after:absolute after:bottom-0 after:left-1/2 after:h-0.5 after:w-9 after:-translate-x-1/2 after:rounded-full after:bg-accent`),onClick:()=>p(`builtin`),children:[t.appsPage.tabBuiltin,(0,Y.jsxs)(`span`,{className:`ml-1 tabular-nums text-fg-muted`,children:[`(`,b.length,`)`]})]}),(0,Y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":f===`user`,className:T(`relative rounded-md px-3 py-2 text-sm font-medium transition-colors`,f===`user`?`text-fg`:`text-fg-muted hover:text-fg`,f===`user`&&`after:absolute after:bottom-0 after:left-1/2 after:h-0.5 after:w-9 after:-translate-x-1/2 after:rounded-full after:bg-accent`),onClick:()=>p(`user`),children:[t.appsPage.tabUser,(0,Y.jsxs)(`span`,{className:`ml-1 tabular-nums text-fg-muted`,children:[`(`,x.length,`)`]})]})]}),w?(0,Y.jsxs)(`div`,{className:`relative w-full min-w-0 sm:max-w-xs`,children:[(0,Y.jsx)(I,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,Y.jsx)(`input`,{type:`search`,value:m,onChange:e=>h(e.target.value),placeholder:t.appsPage.searchPlaceholder,className:`w-full rounded-lg border border-edge bg-surface-base py-2 pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,autoComplete:`off`})]}):null]}),f===`marketplace`?(0,Y.jsx)(te,{}):f===`builtin`&&b.length===0?(0,Y.jsx)(he,{message:t.appsPage.emptyBuiltin}):f===`user`&&x.length===0?(0,Y.jsx)(he,{message:t.appsPage.emptyUser}):C.length===0?(0,Y.jsx)(`p`,{className:`rounded-xl border border-dashed border-edge-subtle bg-surface-hover/30 px-4 py-8 text-center text-sm text-fg-muted dark:bg-surface-hover/15`,children:t.appsPage.noSearchResults}):(0,Y.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:C.map(e=>(0,Y.jsx)(de,{extension:e,copy:t.appsPage,showSourceBadge:f===`user`,onOpen:()=>_(e)},e.id))})]}),g?(0,Y.jsx)(fe,{extension:g,copy:t.appsPage,onClose:()=>_(null)},g.id):null]})}function Q(e){return e.activationEligible??e.active}function ce(e,t){return e.source===`bundled`?t.providerBundled:e.source===`global`?t.providerGlobal:e.source===`workspace`?t.providerWorkspace:t.providerOther}function le(e,t){return e.source===`global`?t.badgeSourceGlobal:e.source===`workspace`?t.badgeSourceWorkspace:t.badgeSourceOther}function ue(e,t){let n=Q(e);return n&&e.active?t.runStateLive:n&&!e.active?t.runStatePendingOn:!n&&e.active?t.runStatePendingOff:t.runStateOff}function de(e){let t=(0,U.c)(45),{extension:n,copy:r,showSourceBadge:i,onOpen:a}=e,o;t[0]===n?o=t[1]:(o=Q(n),t[0]=n,t[1]=o);let s=o,c=n.hasUi?r.cardTooltipHasUi:r.cardTooltipNoUi,l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=T(`group flex w-full flex-col rounded-xl border border-edge bg-surface-base p-4 text-left shadow-sm transition-colors`,`hover:border-edge-subtle hover:bg-surface-hover/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`dark:hover:bg-surface-hover/25`),t[2]=l):l=t[2];let u=n.name||n.id,d;t[3]===u?d=t[4]:(d=u.charAt(0).toUpperCase(),t[3]=u,t[4]=d);let f;t[5]===d?f=t[6]:(f=(0,Y.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-base font-semibold text-accent-fg`,"aria-hidden":!0,children:d}),t[5]=d,t[6]=f);let p;t[7]===n.name?p=t[8]:(p=(0,Y.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[7]=n.name,t[8]=p);let m;t[9]===n.version?m=t[10]:(m=n.version?(0,Y.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[`v`,n.version]}):null,t[9]=n.version,t[10]=m);let h;t[11]!==p||t[12]!==m?(h=(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[p,m]}),t[11]=p,t[12]=m,t[13]=h):h=t[13];let g;t[14]!==r.statusEnabled||t[15]!==s?(g=s?(0,Y.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:[(0,Y.jsx)(y,{className:`size-3`,strokeWidth:2.5,"aria-hidden":!0}),r.statusEnabled]}):(0,Y.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-full border-2 border-accent text-accent`,"aria-hidden":!0,children:(0,Y.jsx)(S,{className:`size-4`,strokeWidth:2.5})}),t[14]=r.statusEnabled,t[15]=s,t[16]=g):g=t[16];let _;t[17]!==h||t[18]!==g?(_=(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[h,g]}),t[17]=h,t[18]=g,t[19]=_):_=t[19];let v;t[20]!==r.cardNoDescription||t[21]!==n.description?(v=n.description?.trim()||r.cardNoDescription,t[20]=r.cardNoDescription,t[21]=n.description,t[22]=v):v=t[22];let b;t[23]===v?b=t[24]:(b=(0,Y.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:v}),t[23]=v,t[24]=b);let x=n.hasUi?r.badgeKindUi:r.badgeKindBackend,C;t[25]!==x||t[26]!==c?(C=(0,Y.jsx)(`span`,{title:c,className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:x}),t[25]=x,t[26]=c,t[27]=C):C=t[27];let w;t[28]!==r||t[29]!==n||t[30]!==i?(w=n.source===`bundled`?(0,Y.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:r.badgeBundled}):i?(0,Y.jsx)(`span`,{title:ce(n,r),className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:le(n,r)}):null,t[28]=r,t[29]=n,t[30]=i,t[31]=w):w=t[31];let E;t[32]!==C||t[33]!==w?(E=(0,Y.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[C,w]}),t[32]=C,t[33]=w,t[34]=E):E=t[34];let D;t[35]!==_||t[36]!==b||t[37]!==E?(D=(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[_,b,E]}),t[35]=_,t[36]=b,t[37]=E,t[38]=D):D=t[38];let O;t[39]!==D||t[40]!==f?(O=(0,Y.jsxs)(`div`,{className:`flex gap-3`,children:[f,D]}),t[39]=D,t[40]=f,t[41]=O):O=t[41];let k;return t[42]!==a||t[43]!==O?(k=(0,Y.jsx)(`button`,{type:`button`,onClick:a,className:l,children:O}),t[42]=a,t[43]=O,t[44]=k):k=t[44],k}function fe({extension:e,copy:t,onClose:n}){let{mutate:r}=s(),[i,a]=(0,H.useState)(!1),[o,c]=(0,H.useState)(null),[h,g]=(0,H.useState)(!1),_=e.activationEligible===!0,y=(0,H.useCallback)(async()=>{if(e.source===`bundled`){c(null),g(!1),a(!0);try{let{requiresGatewayRestart:t}=await q({extensionId:e.id,enabled:!_});await r(`gateway-extensions-list`),P(),g(t)}catch(e){c(e instanceof Error?e.message:t.builtinToggleFailed)}finally{a(!1)}}},[_,t.builtinToggleFailed,e.id,e.source,r]),b=e.ui?.contributions?.pages??[],S=e.ui?.contributions?.settingsPanels??[],E=e.ui?.contributions?.chatWidgets??[],O=e.ui?.contributions?.sidebarPanels??[],j=b.find(e=>e.showInNav)??b[0],N=S[0],F=j?M(e.id,j):null,I=N?`/settings/ext/${e.id}/${N.id}`:e.hasConfigSchema||k(e)?`/settings/ext/${e.id}`:null;return(0,Y.jsx)(f,{defaultOpen:!0,onOpenChange:e=>!e&&n(),children:(0,Y.jsxs)(l,{children:[(0,Y.jsx)(u,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),(0,Y.jsxs)(d,{className:`fixed left-1/2 top-1/2 z-[131] flex max-h-[min(90vh,44rem)] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":t.detailBack,children:(0,Y.jsx)(D,{className:`size-5`})}),(0,Y.jsx)(m,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:t.detailTitle}),(0,Y.jsxs)(p,{className:`sr-only`,children:[e.name,` (`,e.id,`)`]}),(0,Y.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":t.detailClose,children:(0,Y.jsx)(A,{className:`size-5`})})]}),(0,Y.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-start gap-4`,children:[(0,Y.jsx)(`div`,{className:`flex size-16 shrink-0 items-center justify-center rounded-2xl bg-accent-soft text-xl font-semibold text-accent-fg`,"aria-hidden":!0,children:(e.name||e.id).charAt(0).toUpperCase()}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:e.name}),(0,Y.jsxs)(`p`,{className:`mt-0.5 text-sm text-fg-muted`,children:[t.detailProviderPrefix,` `,ce(e,t)]}),e.version?(0,Y.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[`v`,e.version]}):null]})]}),(0,Y.jsx)(`p`,{className:`mt-5 text-sm leading-relaxed text-fg`,children:e.description?.trim()||t.detailNoDescription}),e.hasUi?null:(0,Y.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.backendOnlyHint}),(0,Y.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:ue(e,t)}),e.source===`bundled`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`mt-4 rounded-lg border border-edge-subtle bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted dark:bg-surface-hover/20`,children:t.builtinConfigHint}),(0,Y.jsxs)(`div`,{className:`mt-3 rounded-lg border border-edge-subtle bg-surface-hover/40 p-3 dark:bg-surface-hover/20`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:t.builtinRuntimeToggle}),(0,Y.jsx)(C,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>void y(),className:`shrink-0 py-1.5 text-xs`,children:i?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(x,{className:`mr-1.5 size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}),t.builtinToggleBusy]}):_?t.builtinToggleDisable:t.builtinToggleEnable})]}),o?(0,Y.jsx)(`p`,{className:`mt-2 text-xs text-rose-600 dark:text-rose-400`,children:o}):null,h?(0,Y.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.builtinToggleRestartHint}):null]})]}):(0,Y.jsx)(`p`,{className:`mt-4 rounded-lg border border-edge-subtle bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted dark:bg-surface-hover/20`,children:t.cliManageHint}),e.hasUi&&(b.length>0||S.length>0||E.length>0)?(0,Y.jsxs)(`section`,{className:`mt-8`,children:[(0,Y.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-fg`,children:t.detailSectionFeatures}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,Y.jsx)($,{template:t.badgePages,count:b.length,hidden:b.length===0}),(0,Y.jsx)($,{template:t.badgeSettings,count:S.length,hidden:S.length===0}),(0,Y.jsx)($,{template:t.badgeWidgets,count:E.length,hidden:E.length===0}),(0,Y.jsx)($,{template:t.badgeSidebar,count:O.length,hidden:O.length===0})]})]}):null,v(e)&&(F||I)?(0,Y.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-2 border-t border-edge-subtle pt-4`,children:[F?(0,Y.jsxs)(w,{to:F,onClick:n,className:T(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,Y.jsx)(R,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.open]}):null,I?(0,Y.jsxs)(w,{to:I,onClick:n,className:T(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,Y.jsx)(z,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.openSettings]}):null]}):null,(0,Y.jsx)(`p`,{className:`mt-6 text-[11px] leading-relaxed text-fg-muted`,children:t.restartNote})]})]})]})})}function $(e){let t=(0,U.c)(6),{template:n,count:r,hidden:i}=e;if(i||r===0)return null;let a;if(t[0]!==r||t[1]!==n){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=/\{\{count\}\}/g,t[3]=e):e=t[3],a=n.replace(e,String(r)),t[0]=r,t[1]=n,t[2]=a}else a=t[2];let o;return t[4]===a?o=t[5]:(o=(0,Y.jsx)(`span`,{className:`inline-flex items-center rounded-md bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:a}),t[4]=a,t[5]=o),o}function pe(){let e=(0,U.c)(5),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Y.jsx)(`div`,{className:`mb-6 h-8 w-40 max-w-full animate-pulse rounded-md bg-surface-hover`}),n=(0,Y.jsx)(`div`,{className:`mb-2 h-4 w-full max-w-md animate-pulse rounded bg-surface-hover`}),r=(0,Y.jsx)(`div`,{className:`mb-5 h-9 w-full max-w-lg animate-pulse rounded-full bg-surface-hover`}),e[0]=t,e[1]=n,e[2]=r):(t=e[0],n=e[1],r=e[2]);let i;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=[`ap0`,`ap1`,`ap2`,`ap3`,`ap4`,`ap5`],e[3]=i):i=e[3];let a;return e[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Y.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,Y.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[t,n,r,(0,Y.jsx)(`div`,{className:`mt-6 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:i.map(me)})]})}),e[4]=a):a=e[4],a}function me(e){return(0,Y.jsx)(`div`,{className:`h-36 animate-pulse rounded-xl border border-edge bg-surface-base`},e)}function he(e){let t=(0,U.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Y.jsx)(`div`,{className:`flex min-h-[min(40vh,16rem)] flex-col items-center justify-center rounded-xl border border-dashed border-edge-subtle bg-surface-hover/40 px-4 py-12 text-center dark:bg-surface-hover/20`,children:(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{se as AppsPage};
@@ -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{i,o as a,t as o}from"./url-fxyYANfA.js";import{i as s}from"./vendor-swr-BIWyz7Rc.js";import{n as c,t as l}from"./eye-DAfL1U7M.js";import{a as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./dist-BTWC-BTN.js";import{a as _,n as v}from"./fetch-Dqa9iTWl.js";import{Aa as y,B as b,Bn as x,Cr as S,Dr as C,Er as w,Fr as T,Ft as E,Ga as D,Ir as O,It as k,Jn as A,Ka as j,Lt as M,Rr as N,Rt as P,Sr as F,Un as I,bi as L,br as ee,er as R,hr as te,jr as z,ka as ne,oa as re,qa as B,sa as V,st as H,ur as U,z as W}from"./index-BYcGfwcE.js";import{a as G,c as ie,i as K,o as ae,r as q,s as oe,t as J}from"./utils-DRQryzdn.js";import{n as Y,r as se,t as ce}from"./field-primitives-HUR6JElP.js";import{_ as le,a as ue,c as de,d as fe,f as pe,g as me,h as he,i as ge,l as _e,m as ve,n as ye,o as be,p as xe,r as X,s as Se,t as Ce,u as we,v as Te,y as Ee}from"./channels-status-swr-BrtH2VzC.js";var Z=e(t(),1),Q=n(),$=r();function De(e){switch(e){case`running`:return`bg-success-soft text-success`;case`offline`:return`bg-amber-100 text-amber-900 dark:bg-amber-950/60 dark:text-amber-200`;case`disabled`:return`bg-surface-hover text-fg-muted`;default:return`bg-surface-hover text-fg-muted`}}function Oe(e,t){switch(t){case`running`:return e.hubStatusRunning;case`offline`:return e.hubStatusOffline;case`disabled`:return e.hubStatusDisabled;default:return e.hubStatusNotConfigured}}function ke(e,t){switch(t){case`setup`:return e.hubSetupButton;case`fix`:return e.hubFixButton;case`pairing`:return e.hubPairingButton;default:return e.hubManageButton}}function Ae(e){let t=(0,Q.c)(62),{channelId:n,title:r,subtitle:i,vm:a,toggleDisabled:o,onOpen:s,onReviewPairing:c,onToggle:l,ch:u}=e,d=a.configured&&a.manageable,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=O(`flex h-full min-h-0 flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-panel p-4 shadow-sm transition-colors`,`hover:border-edge`),t[0]=f):f=t[0];let p=a.status===`running`?`bg-accent-soft`:`bg-surface-base`,m;t[1]===p?m=t[2]:(m=O(`flex size-11 shrink-0 items-center justify-center rounded-xl ring-1 ring-edge-subtle/40`,p),t[1]=p,t[2]=m);let h;t[3]===n?h=t[4]:(h=(0,$.jsx)(A,{sourceChannel:n,className:`size-5`}),t[3]=n,t[4]=h);let g;t[5]!==m||t[6]!==h?(g=(0,$.jsx)(`div`,{className:m,"aria-hidden":!0,children:h}),t[5]=m,t[6]=h,t[7]=g):g=t[7];let _;t[8]===r?_=t[9]:(_=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r}),t[8]=r,t[9]=_);let v;t[10]===a.status?v=t[11]:(v=O(`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium`,De(a.status)),t[10]=a.status,t[11]=v);let y;t[12]!==u||t[13]!==a.status?(y=Oe(u,a.status),t[12]=u,t[13]=a.status,t[14]=y):y=t[14];let b;t[15]!==v||t[16]!==y?(b=(0,$.jsx)(`span`,{className:v,children:y}),t[15]=v,t[16]=y,t[17]=b):b=t[17];let x;t[18]!==u||t[19]!==c||t[20]!==a.pendingPairing?(x=a.pendingPairing>0?(0,$.jsx)(`button`,{type:`button`,className:O(`inline-flex items-center rounded-full bg-amber-100 px-2 py-0.5 text-xs font-medium text-amber-900 dark:bg-amber-950/60 dark:text-amber-200`,C.press),onClick:e=>{e.stopPropagation(),c()},children:u.hubPairingPendingBadge.replace(`{{count}}`,String(a.pendingPairing))}):null,t[18]=u,t[19]=c,t[20]=a.pendingPairing,t[21]=x):x=t[21];let S;t[22]!==x||t[23]!==b?(S=(0,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1.5`,children:[b,x]}),t[22]=x,t[23]=b,t[24]=S):S=t[24];let w;t[25]!==S||t[26]!==_?(w=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[_,S]}),t[25]=S,t[26]=_,t[27]=w):w=t[27];let E;t[28]!==u||t[29]!==l||t[30]!==d||t[31]!==r||t[32]!==o||t[33]!==a.enabled?(E=d?(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":a.enabled,"aria-label":`${r} — ${u.enableChannelAria}`,disabled:o,className:O(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,C.press,a.enabled?`justify-end bg-accent`:`justify-start bg-surface-hover`,o&&`cursor-not-allowed opacity-50`),onClick:e=>{e.stopPropagation(),l(!a.enabled)},children:(0,$.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`})}):null,t[28]=u,t[29]=l,t[30]=d,t[31]=r,t[32]=o,t[33]=a.enabled,t[34]=E):E=t[34];let D;t[35]!==w||t[36]!==E||t[37]!==g?(D=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[g,w,E]}),t[35]=w,t[36]=E,t[37]=g,t[38]=D):D=t[38];let k;t[39]===i?k=t[40]:(k=(0,$.jsx)(`p`,{className:`line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:i}),t[39]=i,t[40]=k);let j;t[41]===a.summaryLines?j=t[42]:(j=a.summaryLines.length>0?(0,$.jsx)(`ul`,{className:`mt-1.5 space-y-0.5`,children:a.summaryLines.map(je)}):null,t[41]=a.summaryLines,t[42]=j);let M;t[43]!==k||t[44]!==j?(M=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[k,j]}),t[43]=k,t[44]=j,t[45]=M):M=t[45];let N;t[46]!==s||t[47]!==c||t[48]!==a.manageable||t[49]!==a.pendingPairing||t[50]!==a.primaryAction?(N=()=>{if(a.manageable&&(a.primaryAction===`pairing`||a.pendingPairing>0)){c();return}s()},t[46]=s,t[47]=c,t[48]=a.manageable,t[49]=a.pendingPairing,t[50]=a.primaryAction,t[51]=N):N=t[51];let P;t[52]!==u||t[53]!==a.primaryAction?(P=ke(u,a.primaryAction),t[52]=u,t[53]=a.primaryAction,t[54]=P):P=t[54];let F;t[55]!==N||t[56]!==P?(F=(0,$.jsx)(`div`,{className:`mt-auto`,children:(0,$.jsx)(T,{type:`button`,variant:`primary`,className:`w-full`,onClick:N,children:P})}),t[55]=N,t[56]=P,t[57]=F):F=t[57];let I;return t[58]!==D||t[59]!==M||t[60]!==F?(I=(0,$.jsxs)(`article`,{className:f,children:[D,M,F]}),t[58]=D,t[59]=M,t[60]=F,t[61]=I):I=t[61],I}function je(e){return(0,$.jsx)(`li`,{className:`text-xs text-fg-muted`,children:e},e)}function Me(e){let t=(0,Q.c)(17),{catalog:n,cards:r,ch:i,saving:a,onOpenChannel:o,onToggleChannel:s}=e,c;t[0]===r?c=t[1]:(c=new Map(r.map(Ne)),t[0]=r,t[1]=c);let l=c,u;if(t[2]!==l||t[3]!==n||t[4]!==i||t[5]!==o||t[6]!==s||t[7]!==a){let e;t[9]!==l||t[10]!==i||t[11]!==o||t[12]!==s||t[13]!==a?(e=e=>{let t=l.get(e.id);return t?(0,$.jsx)(`li`,{className:`h-full min-h-0`,children:(0,$.jsx)(Ae,{channelId:e.id,title:e.title,subtitle:e.subtitle,vm:t,toggleDisabled:a||!t.manageable,onOpen:()=>o(e.id),onReviewPairing:()=>o(e.id,{scrollToPairing:!0}),onToggle:t=>s(e.id,t),ch:i})},e.id):null},t[9]=l,t[10]=i,t[11]=o,t[12]=s,t[13]=a,t[14]=e):e=t[14],u=n.map(e),t[2]=l,t[3]=n,t[4]=i,t[5]=o,t[6]=s,t[7]=a,t[8]=u}else u=t[8];let d;return t[15]===u?d=t[16]:(d=(0,$.jsx)(`ul`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-[repeat(auto-fill,minmax(280px,1fr))]`,role:`list`,children:u}),t[15]=u,t[16]=d),d}function Ne(e){return[e.id,e]}var Pe=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function Fe(){let e=(0,Q.c)(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:O(`size-11 shrink-0 rounded-xl`,Pe)}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,$.jsx)(`div`,{className:O(`h-4 w-2/5`,Pe)}),(0,$.jsx)(`div`,{className:O(`h-5 w-16 rounded-full`,Pe)})]}),(0,$.jsx)(`div`,{className:O(`h-6 w-10 shrink-0 rounded-full`,Pe)})]}),e[1]=n):n=e[1];let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:O(`h-3 w-full`,Pe)}),(0,$.jsx)(`div`,{className:O(`h-3 w-[88%]`,Pe)})]}),e[2]=r):r=e[2];let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsxs)(`div`,{className:`flex h-full min-h-[13.5rem] flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-panel p-4 shadow-sm dark:border-edge-subtle`,"aria-hidden":!0,children:[n,r,(0,$.jsx)(`div`,{className:`mt-auto`,children:(0,$.jsx)(`div`,{className:O(`h-10 w-full rounded-lg`,Pe)})})]}),e[3]=i):i=e[3],i}function Ie(e){let t=(0,Q.c)(2),{count:n}=e,r=n===void 0?3:n,i;return t[0]===r?i=t[1]:(i=(0,$.jsx)(`ul`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,role:`list`,"aria-busy":!0,children:Array.from({length:r},Le)}),t[0]=r,t[1]=i),i}function Le(e,t){return(0,$.jsx)(`li`,{className:`h-full min-h-0`,children:(0,$.jsx)(Fe,{})},t)}function Re(e,t=!1){return e===`drawer`?O(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,W):O(`fixed left-1/2 top-1/2 flex max-h-[min(90vh,52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`max-h-[min(90vh,48rem)] w-[min(calc(100%-2rem),36rem)]`,W,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function ze(e){let t=(0,Q.c)(30),{presentation:n,open:r,onOpenChange:i,title:a,description:o,srTitle:s,srDescription:c,closeAriaLabel:l,children:_,footer:v,wide:y,headerExtra:x}=e,S=y===void 0?!1:y,C=n===`drawer`,E;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(d,{className:O(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,b)}),t[0]=E):E=t[0];let D;t[1]!==n||t[2]!==S?(D=Re(n,S),t[1]=n,t[2]=S,t[3]=D):D=t[3];let k;t[4]===s?k=t[5]:(k=s?(0,$.jsx)(h,{className:`sr-only`,children:s}):null,t[4]=s,t[5]=k);let A;t[6]===c?A=t[7]:(A=c?(0,$.jsx)(m,{className:`sr-only`,children:c}):null,t[6]=c,t[7]=A);let j;t[8]!==l||t[9]!==o||t[10]!==x||t[11]!==C||t[12]!==a?(j=C?(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,$.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,o?(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,$.jsx)(g,{asChild:!0,children:(0,$.jsx)(T,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":l,children:(0,$.jsx)(N,{className:`size-5`,strokeWidth:1.75})})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(g,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:O(w,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":l,children:(0,$.jsx)(N,{className:`size-4`})})}),x]}),t[8]=l,t[9]=o,t[10]=x,t[11]=C,t[12]=a,t[13]=j):j=t[13];let M=C?`px-4 py-4`:`p-6`,P;t[14]===M?P=t[15]:(P=O(`min-h-0 flex-1 overflow-y-auto`,M),t[14]=M,t[15]=P);let F;t[16]!==_||t[17]!==P?(F=(0,$.jsx)(`div`,{className:P,children:_}),t[16]=_,t[17]=P,t[18]=F):F=t[18];let I;t[19]!==v||t[20]!==D||t[21]!==k||t[22]!==A||t[23]!==j||t[24]!==F?(I=(0,$.jsxs)(u,{children:[E,(0,$.jsxs)(f,{className:D,onOpenAutoFocus:Be,children:[k,A,j,F,v]})]}),t[19]=v,t[20]=D,t[21]=k,t[22]=A,t[23]=j,t[24]=F,t[25]=I):I=t[25];let L;return t[26]!==i||t[27]!==r||t[28]!==I?(L=(0,$.jsx)(p,{open:r,onOpenChange:i,children:I}),t[26]=i,t[27]=r,t[28]=I,t[29]=L):L=t[29],L}function Be(e){return e.preventDefault()}function Ve(e){let t=(0,Q.c)(52),{open:n,onOpenChange:r,entry:i,vm:a,ch:o,language:s}=e,c=a.status===`running`?o.hubStatusRunning:a.status===`offline`?o.hubStatusOffline:a.status===`disabled`?o.hubStatusDisabled:o.hubStatusNotConfigured,l=i.title,u=i.subtitle,d=o.modalCancel,f;t[0]===i.title?f=t[1]:(f=(0,$.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-fg`,children:i.title}),t[0]=i.title,t[1]=f);let p;t[2]===i.subtitle?p=t[3]:(p=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:i.subtitle}),t[2]=i.subtitle,t[3]=p);let m;t[4]!==f||t[5]!==p?(m=(0,$.jsxs)(`div`,{className:`border-b border-edge-subtle px-6 pb-4 pt-6 dark:border-edge-subtle`,children:[f,p]}),t[4]=f,t[5]=p,t[6]=m):m=t[6];let h;t[7]===o.hubExtensionManageHint?h=t[8]:(h=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.hubExtensionManageHint}),t[7]=o.hubExtensionManageHint,t[8]=h);let g;t[9]===o.hubExtensionStatusLabel?g=t[10]:(g=(0,$.jsx)(`dt`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:o.hubExtensionStatusLabel}),t[9]=o.hubExtensionStatusLabel,t[10]=g);let _;t[11]===c?_=t[12]:(_=(0,$.jsx)(`dd`,{className:`mt-1 text-fg`,children:c}),t[11]=c,t[12]=_);let v;t[13]!==g||t[14]!==_?(v=(0,$.jsxs)(`div`,{children:[g,_]}),t[13]=g,t[14]=_,t[15]=v):v=t[15];let y;t[16]===o.hubExtensionEnabledLabel?y=t[17]:(y=(0,$.jsx)(`dt`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:o.hubExtensionEnabledLabel}),t[16]=o.hubExtensionEnabledLabel,t[17]=y);let b=a.enabled?o.hubExtensionYes:o.hubExtensionNo,x;t[18]===b?x=t[19]:(x=(0,$.jsx)(`dd`,{className:`mt-1 text-fg`,children:b}),t[18]=b,t[19]=x);let S;t[20]!==y||t[21]!==x?(S=(0,$.jsxs)(`div`,{children:[y,x]}),t[20]=y,t[21]=x,t[22]=S):S=t[22];let C;t[23]===o.hubExtensionConnectedLabel?C=t[24]:(C=(0,$.jsx)(`dt`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:o.hubExtensionConnectedLabel}),t[23]=o.hubExtensionConnectedLabel,t[24]=C);let w=a.connected?o.hubExtensionYes:o.hubExtensionNo,E;t[25]===w?E=t[26]:(E=(0,$.jsx)(`dd`,{className:`mt-1 text-fg`,children:w}),t[25]=w,t[26]=E);let D;t[27]!==C||t[28]!==E?(D=(0,$.jsxs)(`div`,{children:[C,E]}),t[27]=C,t[28]=E,t[29]=D):D=t[29];let O;t[30]!==v||t[31]!==S||t[32]!==D?(O=(0,$.jsxs)(`dl`,{className:`grid gap-3 text-sm`,children:[v,S,D]}),t[30]=v,t[31]=S,t[32]=D,t[33]=O):O=t[33];let k;t[34]===s?k=t[35]:(k=te(s,`channels`),t[34]=s,t[35]=k);let A;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(V,{className:`ml-2 size-3.5`}),t[36]=A):A=t[36];let j;t[37]!==o.hubViewDocs||t[38]!==k?(j=(0,$.jsx)(T,{type:`button`,variant:`secondary`,asChild:!0,children:(0,$.jsxs)(`a`,{href:k,target:`_blank`,rel:`noreferrer`,children:[o.hubViewDocs,A]})}),t[37]=o.hubViewDocs,t[38]=k,t[39]=j):j=t[39];let M;t[40]!==O||t[41]!==j||t[42]!==h?(M=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[h,O,j]}),t[40]=O,t[41]=j,t[42]=h,t[43]=M):M=t[43];let N;return t[44]!==o.modalCancel||t[45]!==i.subtitle||t[46]!==i.title||t[47]!==r||t[48]!==n||t[49]!==M||t[50]!==m?(N=(0,$.jsx)(ze,{presentation:`modal`,open:n,onOpenChange:r,srTitle:l,srDescription:u,closeAriaLabel:d,headerExtra:m,children:M}),t[44]=o.modalCancel,t[45]=i.subtitle,t[46]=i.title,t[47]=r,t[48]=n,t[49]=M,t[50]=m,t[51]=N):N=t[51],N}var He=(0,Z.memo)(function(e){let t=(0,Q.c)(15),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,$.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s=n.refresh,c=n.refresh,l=r&&`animate-spin`,u;t[3]===l?u=t[4]:(u=O(`size-4`,l),t[3]=l,t[4]=u);let d;t[5]===u?d=t[6]:(d=(0,$.jsx)(L,{className:u,"aria-hidden":!0}),t[5]=u,t[6]=d);let f;t[7]!==n.refresh||t[8]!==a||t[9]!==r||t[10]!==d?(f=(0,$.jsx)(T,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,disabled:r,title:s,"aria-label":c,onClick:a,children:d}),t[7]=n.refresh,t[8]=a,t[9]=r,t[10]=d,t[11]=f):f=t[11];let p;return t[12]!==o||t[13]!==f?(p=(0,$.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,f]}),t[12]=o,t[13]=f,t[14]=p):p=t[14],p});function Ue(e){let t=(0,Q.c)(27),{accountIds:n,routes:r,defaultAgentId:o,agentItems:s,disabled:c,onChange:l,ch:u}=e,d=i(We),f,p,m,h,g;if(t[0]!==n||t[1]!==s||t[2]!==u||t[3]!==o||t[4]!==c||t[5]!==d||t[6]!==l||t[7]!==r){g=Symbol.for(`react.early_return_sentinel`);bb0:{let e=a(d).agentsSettings;if(n.length===0){g=null;break bb0}let i=s.length>0?s:[{id:o}];m=`space-y-3 border-t border-edge-subtle pt-4 dark:border-edge`;let _;t[13]===u.agentRoutingTitle?_=t[14]:(_=(0,$.jsx)(Y,{children:u.agentRoutingTitle}),t[13]=u.agentRoutingTitle,t[14]=_);let v;t[15]===u.agentRoutingHint?v=t[16]:(v=(0,$.jsx)(ce,{children:u.agentRoutingHint}),t[15]=u.agentRoutingHint,t[16]=v),t[17]!==_||t[18]!==v?(h=(0,$.jsxs)(`div`,{children:[_,v]}),t[17]=_,t[18]=v,t[19]=h):h=t[19],f=`space-y-2`,p=n.map(t=>(0,$.jsxs)(`div`,{className:`grid grid-cols-1 items-start gap-2 rounded-lg border border-edge-subtle bg-surface-base px-3 py-2.5 sm:grid-cols-2 sm:items-center dark:border-edge`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.agentRoutingAccountLabel}),(0,$.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-sm text-fg`,title:t,children:t})]}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:`agent-route-${t}`,children:u.agentRoutingAgentLabel}),(0,$.jsx)(`select`,{id:`agent-route-${t}`,className:O(J(),z),disabled:c,value:(r[t]??o).toLowerCase(),onChange:e=>l(t,e.target.value),children:i.map(t=>(0,$.jsx)(`option`,{value:t.id,children:`${H(t,e)} (${t.id})`},t.id))})]})]},t))}t[0]=n,t[1]=s,t[2]=u,t[3]=o,t[4]=c,t[5]=d,t[6]=l,t[7]=r,t[8]=f,t[9]=p,t[10]=m,t[11]=h,t[12]=g}else f=t[8],p=t[9],m=t[10],h=t[11],g=t[12];if(g!==Symbol.for(`react.early_return_sentinel`))return g;let _;t[20]!==f||t[21]!==p?(_=(0,$.jsx)(`div`,{className:f,children:p}),t[20]=f,t[21]=p,t[22]=_):_=t[22];let v;return t[23]!==m||t[24]!==h||t[25]!==_?(v=(0,$.jsxs)(`div`,{className:m,children:[h,_]}),t[23]=m,t[24]=h,t[25]=_,t[26]=v):v=t[26],v}function We(e){return e.language}function Ge(e){return e===`telegram`?`pairing`:`open`}function Ke(e,t,n){return n?.dmPolicy?n.dmPolicy:t??Ge(e)}function qe(e,t){if(e===`telegram`){let e=Te(t);return e.length>0?e:[`default`]}if(e===`weixin`){let e=Ee(t);return e.length>0?e:[`default`]}let n=le(t);return n.length>0?n:[`default`]}function Je(e){return e?.enabled!==!1}function Ye(e,t,n){let r=t.accounts?.[n];return Ke(e,t.dmPolicy,r)}function Xe(e,t){return qe(e,t).some(n=>{let r=t.accounts?.[n];return Je(r)?Ye(e,t,n)===`pairing`:!1})}function Ze(e){return!e.configured||!e.channelEnabled||!e.usesPairing?0:e.summaryPending}function Qe(e){let{channel:t,accountId:n,messages:r,mutate:i,setCodeBySender:a,setBusySender:o,setFeedback:s}=e,c=(0,Z.useCallback)(async(e,t)=>{o(e),s(null);try{let n=await t();a(t=>{let n={...t};return delete n[e],n}),s({kind:`ok`,text:r.pairingApproved.replace(`{{id}}`,n.senderId)}),await i()}catch(e){let t=e instanceof Error?e.message:r.pairingInvalid;s({kind:`err`,text:t.includes(`PAIRING`)?r.pairingInvalid:t})}finally{o(null)}},[r.pairingApproved,r.pairingInvalid,i,o,a,s]);return{approveByCode:(0,Z.useCallback)((e,r)=>{let i=r.trim().toUpperCase();i&&c(e,()=>ue({channel:t,accountId:n,code:i}))},[n,t,c]),quickApprove:(0,Z.useCallback)(e=>{c(e,()=>ge({channel:t,accountId:n,senderId:e}))},[n,t,c])}}var $e=[`channels-pairing-requested`,`channels-pairing-refreshed`,`channels-pairing-approved`,`channels-pairing-revoked`,`channels-pairing-dismissed`],et=`channel-pairing-summary`;function tt(e){let t=()=>e();for(let e of $e)window.addEventListener(e,t);return()=>{for(let e of $e)window.removeEventListener(e,t)}}function nt(e,t){let n=(0,Q.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return tt(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,Z.useEffect)(i,a)}function rt(e){return`channel-pairing-${e}`}function it(e){requestAnimationFrame(()=>{document.getElementById(rt(e))?.scrollIntoView({behavior:`smooth`,block:`start`})})}function at(e,t){let n=Date.parse(e)-Date.now();if(!Number.isFinite(n))return e;let r=Math.max(1,Math.round(Math.abs(n)/6e4));if(n<=0)return t.startsWith(`zh`)?`已过期`:`expired`;if(r<60)return t.startsWith(`zh`)?`${r} 分钟后`:`in ${r} min`;let i=Math.round(r/60);return t.startsWith(`zh`)?`${i} 小时后`:`in ${i} h`}function ot(e,t){return`channel-pairing-${e}-${t}`}var st={codeBySender:{},busySender:null,dismissingId:null,revokingId:null,feedback:null};function ct(e,t){switch(t.type){case`setCodeBySender`:return{...e,codeBySender:t.updater(e.codeBySender)};case`setBusySender`:return{...e,busySender:t.value};case`setDismissingId`:return{...e,dismissingId:t.value};case`setRevokingId`:return{...e,revokingId:t.value};case`setFeedback`:return{...e,feedback:t.value};case`clearSenderCode`:{let n={...e.codeBySender};return delete n[t.senderId],{...e,codeBySender:n}}}}function lt({channel:e,accountIds:t,channelConfig:n,active:r,ch:i,language:a,onPairedChange:o}){let c=J,l=(0,Z.useMemo)(()=>{let e=(t??[`default`]).filter(Boolean);return e.length>0?e:[`default`]},[t]),u=(0,Z.useMemo)(()=>Xe(e,n),[e,n]),d=(0,Z.useCallback)(t=>Ye(e,n,t),[e,n]),[f,p]=(0,Z.useState)(l[0]??`default`),[m,h]=(0,Z.useState)(l);l!==m&&(h(l),l.includes(f)||p(l[0]??`default`));let[g,_]=(0,Z.useReducer)(ct,st),{codeBySender:v,busySender:y,dismissingId:b,revokingId:x,feedback:S}=g,C=d(f)===`pairing`,w=(0,Z.useRef)(o);w.current=o;let{data:E,error:D,isLoading:k,mutate:A}=s(r&&u&&C?ot(e,f):null,()=>de(e,f),{revalidateOnFocus:!0,onSuccess:e=>{w.current?.(e.paired.fromCredentials.length)}});nt((0,Z.useCallback)(()=>{A()},[A]),r&&u&&C);let j=E?.paired.fromCredentials??[],M=(0,Z.useCallback)(e=>{_({type:`setCodeBySender`,updater:typeof e==`function`?e:()=>e})},[]),P=(0,Z.useCallback)(e=>{_({type:`setBusySender`,value:typeof e==`function`?e(g.busySender):e})},[g.busySender]),F=(0,Z.useCallback)(e=>{_({type:`setFeedback`,value:typeof e==`function`?e(g.feedback):e})},[g.feedback]),{approveByCode:I,quickApprove:ee}=Qe({channel:e,accountId:f,messages:{pairingApproved:i.pairingApproved,pairingInvalid:i.pairingInvalid},mutate:A,setCodeBySender:M,setBusySender:P,setFeedback:F}),R=(0,Z.useCallback)(async t=>{_({type:`setDismissingId`,value:t}),_({type:`setFeedback`,value:null});try{await be({channel:e,accountId:f,senderId:t}),_({type:`clearSenderCode`,senderId:t}),_({type:`setFeedback`,value:{kind:`ok`,text:i.pairingDismissed.replace(`{{id}}`,t)}}),await A()}catch(e){_({type:`setFeedback`,value:{kind:`err`,text:e instanceof Error?e.message:i.pairingDismissError}})}finally{_({type:`setDismissingId`,value:null})}},[f,e,i.pairingDismissed,i.pairingDismissError,A]),te=(0,Z.useCallback)(async t=>{_({type:`setRevokingId`,value:t}),_({type:`setFeedback`,value:null});try{await me({channel:e,accountId:f,senderId:t}),_({type:`setFeedback`,value:{kind:`ok`,text:i.pairingRevoked.replace(`{{id}}`,t)}}),await A()}catch(e){_({type:`setFeedback`,value:{kind:`err`,text:e instanceof Error?e.message:i.pairingRevokeError}})}finally{_({type:`setRevokingId`,value:null})}},[f,e,i.pairingRevoked,i.pairingRevokeError,A]);if(!u)return null;if(!C)return(0,$.jsxs)(`div`,{id:rt(e),className:`space-y-2 rounded-xl border border-edge-subtle bg-surface-base/50 p-4 dark:border-edge`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:i.pairingTitle}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.pairingAccountNotPairing.replace(`{{account}}`,f)}),l.length>1?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Y,{children:i.pairingAccountLabel}),(0,$.jsx)(`select`,{className:c(),value:f,onChange:e=>p(e.target.value),children:l.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))})]}):null]});let z=E?.pending??[],ne=E?.paired.fromConfig??[];return(0,$.jsxs)(`div`,{id:rt(e),className:`space-y-3 rounded-xl border border-edge-subtle bg-surface-base/50 p-4 dark:border-edge`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:i.pairingTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:i.pairingSubtitle})]}),(0,$.jsx)(T,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":i.pairingRefresh,disabled:k,onClick:()=>void A(),children:(0,$.jsx)(L,{className:O(`size-4 text-fg-muted`,k&&`animate-spin`)})})]}),l.length>1?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Y,{children:i.pairingAccountLabel}),(0,$.jsx)(`select`,{className:c(),value:f,onChange:e=>p(e.target.value),children:l.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))})]}):null,(0,$.jsx)(ce,{children:i.pairingSetupHint}),D?(0,$.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:i.pairingLoadError}):null,S?(0,$.jsx)(`p`,{className:O(`text-xs`,S.kind===`ok`?`text-success`:`text-red-600 dark:text-red-400`),children:S.text}):null,(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Y,{children:i.pairingPendingTitle}),z.length>0?(0,$.jsx)(ce,{children:i.pairingQuickApproveHint}):null,z.length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.pairingPendingEmpty}):(0,$.jsx)(`ul`,{className:`space-y-2`,children:z.map(e=>{let t=v[e.senderId]??``,n=y===e.senderId,r=b===e.senderId;return(0,$.jsxs)(`li`,{className:O(`rounded-lg border bg-surface-panel p-3 dark:border-edge`,e.isStale?`border-amber-300/50 dark:border-amber-800/50`:`border-edge`),children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`font-mono text-xs text-fg`,children:e.senderId}),(0,$.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[e.isStale?(0,$.jsx)(`span`,{className:`text-amber-800 dark:text-amber-200`,children:i.pairingStaleItem}):null,e.isStale?` · `:null,i.pairingExpiresHint.replace(`{{time}}`,at(e.expiresAt,a))]})]}),e.codeLast4?(0,$.jsx)(`p`,{className:`mt-1 text-[11px] text-fg-muted`,children:i.pairingCodeHint.replace(`{{suffix}}`,e.codeLast4)}):null,(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,$.jsx)(T,{type:`button`,variant:`secondary`,className:`shrink-0 text-xs`,disabled:n||r,onClick:()=>void ee(e.senderId),children:n?i.pairingApproving:i.pairingQuickApprove}),(0,$.jsx)(`input`,{className:O(c(),`min-w-0 flex-1 font-mono text-xs uppercase`),value:t,autoComplete:`off`,spellCheck:!1,maxLength:8,placeholder:i.pairingCodePlaceholder,onChange:t=>M(n=>({...n,[e.senderId]:t.target.value.toUpperCase()})),onKeyDown:n=>{n.key===`Enter`&&I(e.senderId,t)}}),(0,$.jsx)(T,{type:`button`,variant:`primary`,className:`shrink-0 text-xs`,disabled:n||r||!t.trim(),onClick:()=>I(e.senderId,t),children:n?i.pairingApproving:i.pairingApprove}),(0,$.jsx)(T,{type:`button`,variant:`ghost`,className:`shrink-0 text-xs text-fg-muted hover:text-danger`,disabled:n||r,onClick:()=>void R(e.senderId),children:r?i.pairingDismissing:i.pairingDismiss})]})]},e.senderId)})})]}),(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-edge-subtle pt-3 dark:border-edge-subtle`,children:[(0,$.jsx)(Y,{children:i.pairedTitle}),(0,$.jsxs)(`div`,{className:`grid gap-3 text-xs sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-fg-muted`,children:i.pairedFromConfig}),(0,$.jsx)(`p`,{className:`mt-0.5 font-mono text-fg`,children:ne.length?ne.join(`, `):i.pairedEmpty})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-fg-muted`,children:i.pairedFromCredentials}),j.length===0?(0,$.jsx)(`p`,{className:`mt-0.5 font-mono text-fg`,children:i.pairedEmpty}):(0,$.jsx)(`ul`,{className:`mt-1 space-y-1`,children:j.map(e=>(0,$.jsxs)(`li`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`font-mono text-fg`,children:e}),(0,$.jsx)(T,{type:`button`,variant:`ghost`,className:`size-7 shrink-0 p-0 text-fg-muted hover:text-danger`,"aria-label":i.pairingRevokeAria.replace(`{{id}}`,e),disabled:x===e,onClick:()=>void te(e),children:(0,$.jsx)(N,{className:`size-3.5`})})]},e))})]})]})]})]})}function ut(e){let t=(0,Q.c)(347),{ch:n,form:r,baseline:i,showFeishuWebhookSecrets:a,setShowFeishuWebhookSecrets:o,feishuWebhookCopied:s,copyFeishuWebhookConfig:u,updateFeishu:d,updateChannelAgentRoute:f,feishuAccountsDraft:p,setFeishuAccountsDraft:m,feishuAccountsError:h,onFeishuAccountsBlur:g,dmOpts:_,groupOpts:v,chatAgents:b,saving:x,language:S,dialogOpen:C,pairingFocus:w}=e,E=w===void 0?!1:w,D=r.feishu,k;t[0]===D?k=t[1]:(k=le(D),t[0]=D,t[1]=k);let A=k,j;t[2]===A?j=t[3]:(j=A.length>0?A:[`default`],t[2]=A,t[3]=j);let M=j,N=i?.feishu?.appSecret??``,P;t[4]!==n.copied||t[5]!==n.copy||t[6]!==n.hide||t[7]!==n.show?(P=ee({show:n.show,hide:n.hide,copy:n.copy,copied:n.copied}),t[4]=n.copied,t[5]=n.copy,t[6]=n.hide,t[7]=n.show,t[8]=P):P=t[8];let I=P,L=(0,Z.useRef)(null),R,te;t[9]===E?(R=t[10],te=t[11]):(R=()=>{if(!E)return;let e=L.current;e&&(e.open=!0);let t=window.setTimeout(pt,80);return()=>window.clearTimeout(t)},te=[E],t[9]=E,t[10]=R,t[11]=te),(0,Z.useEffect)(R,te);let z;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(ne,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`}),t[12]=z):z=t[12];let B;t[13]===n.advancedShow?B=t[14]:(B=(0,$.jsx)(`summary`,{className:`cursor-pointer list-none rounded-xl px-3 py-2.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover group-open:rounded-b-none [&::-webkit-details-marker]:hidden`,children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[z,n.advancedShow]})}),t[13]=n.advancedShow,t[14]=B);let V;t[15]===n.feishuAdvancedHint?V=t[16]:(V=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:n.feishuAdvancedHint}),t[15]=n.feishuAdvancedHint,t[16]=V);let H;t[17]===d?H=t[18]:(H=e=>d({enabled:e.target.checked}),t[17]=d,t[18]=H);let U;t[19]!==D.enabled||t[20]!==H?(U=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:D.enabled,onChange:H}),t[19]=D.enabled,t[20]=H,t[21]=U):U=t[21];let W;t[22]===n.enableFeishuAria?W=t[23]:(W=(0,$.jsx)(`span`,{children:n.enableFeishuAria}),t[22]=n.enableFeishuAria,t[23]=W);let G;t[24]!==U||t[25]!==W?(G=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[U,W]}),t[24]=U,t[25]=W,t[26]=G):G=t[26];let ie;t[27]===d?ie=t[28]:(ie=e=>d({dmPolicy:e}),t[27]=d,t[28]=ie);let K;t[29]!==n.dmPolicy||t[30]!==_||t[31]!==D.dmPolicy||t[32]!==ie?(K=(0,$.jsx)(se,{label:n.dmPolicy,value:D.dmPolicy,onChange:ie,options:_}),t[29]=n.dmPolicy,t[30]=_,t[31]=D.dmPolicy,t[32]=ie,t[33]=K):K=t[33];let q;t[34]!==n||t[35]!==C||t[36]!==D||t[37]!==S||t[38]!==M?(q=(0,$.jsx)(lt,{channel:`feishu`,accountIds:M,channelConfig:D,active:C,ch:n,language:S}),t[34]=n,t[35]=C,t[36]=D,t[37]=S,t[38]=M,t[39]=q):q=t[39];let ue;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[40]=ue):ue=t[40];let de;t[41]===n.feishuAppId?de=t[42]:(de=(0,$.jsxs)(Y,{children:[n.feishuAppId,ue]}),t[41]=n.feishuAppId,t[42]=de);let fe;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(fe=O(J(),`min-w-0 flex-1 font-mono text-xs`),t[43]=fe):fe=t[43];let pe;t[44]===d?pe=t[45]:(pe=e=>d({appId:e.target.value}),t[44]=d,t[45]=pe);let me;t[46]!==D.appId||t[47]!==pe?(me=(0,$.jsx)(`input`,{className:fe,value:D.appId,onChange:pe,placeholder:`cli_xxx`}),t[46]=D.appId,t[47]=pe,t[48]=me):me=t[48];let he;t[49]===n.feishuAppIdDesc?he=t[50]:(he=(0,$.jsx)(ce,{children:n.feishuAppIdDesc}),t[49]=n.feishuAppIdDesc,t[50]=he);let ge;t[51]!==de||t[52]!==me||t[53]!==he?(ge=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[de,me,he]}),t[51]=de,t[52]=me,t[53]=he,t[54]=ge):ge=t[54];let _e;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[55]=_e):_e=t[55];let ve;t[56]===n.feishuAppSecret?ve=t[57]:(ve=(0,$.jsxs)(Y,{children:[n.feishuAppSecret,_e]}),t[56]=n.feishuAppSecret,t[57]=ve);let ye=D.appSecret,be;t[58]===d?be=t[59]:(be=e=>d({appSecret:e}),t[58]=d,t[59]=be);let xe;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(xe=O(J(),`text-xs`),t[60]=xe):xe=t[60];let X;t[61]!==N||t[62]!==D.appSecret||t[63]!==I||t[64]!==be?(X=(0,$.jsx)(F,{value:ye,onChange:be,placeholder:`••••••••`,labels:I,baselineValue:N,inputClassName:xe}),t[61]=N,t[62]=D.appSecret,t[63]=I,t[64]=be,t[65]=X):X=t[65];let Se;t[66]===n.feishuAppSecretDesc?Se=t[67]:(Se=(0,$.jsx)(ce,{children:n.feishuAppSecretDesc}),t[66]=n.feishuAppSecretDesc,t[67]=Se);let Ce;t[68]!==ve||t[69]!==X||t[70]!==Se?(Ce=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[ve,X,Se]}),t[68]=ve,t[69]=X,t[70]=Se,t[71]=Ce):Ce=t[71];let we;t[72]===n.feishuDomain?we=t[73]:(we=(0,$.jsx)(Y,{children:n.feishuDomain}),t[72]=n.feishuDomain,t[73]=we);let Te;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(Te=J(),t[74]=Te):Te=t[74];let Ee=String(D.domain||`feishu`),De;t[75]===d?De=t[76]:(De=e=>d({domain:e.target.value}),t[75]=d,t[76]=De);let Oe,ke;t[77]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=(0,$.jsx)(`option`,{value:`feishu`,children:`feishu`}),ke=(0,$.jsx)(`option`,{value:`lark`,children:`lark`}),t[77]=Oe,t[78]=ke):(Oe=t[77],ke=t[78]);let Ae;t[79]!==Ee||t[80]!==De?(Ae=(0,$.jsxs)(`select`,{className:Te,value:Ee,onChange:De,children:[Oe,ke]}),t[79]=Ee,t[80]=De,t[81]=Ae):Ae=t[81];let je;t[82]!==we||t[83]!==Ae?(je=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[we,Ae]}),t[82]=we,t[83]=Ae,t[84]=je):je=t[84];let Me;t[85]===n.connectionMode?Me=t[86]:(Me=(0,$.jsx)(Y,{children:n.connectionMode}),t[85]=n.connectionMode,t[86]=Me);let Ne;t[87]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=J(),t[87]=Ne):Ne=t[87];let Pe;t[88]===d?Pe=t[89]:(Pe=e=>d({connectionMode:e.target.value}),t[88]=d,t[89]=Pe);let Fe,Ie;t[90]===Symbol.for(`react.memo_cache_sentinel`)?(Fe=(0,$.jsx)(`option`,{value:`websocket`,children:`websocket`}),Ie=(0,$.jsx)(`option`,{value:`webhook`,children:`webhook`}),t[90]=Fe,t[91]=Ie):(Fe=t[90],Ie=t[91]);let Le;t[92]!==D.connectionMode||t[93]!==Pe?(Le=(0,$.jsxs)(`select`,{className:Ne,value:D.connectionMode,onChange:Pe,children:[Fe,Ie]}),t[92]=D.connectionMode,t[93]=Pe,t[94]=Le):Le=t[94];let Re;t[95]===n.connectionModeDesc?Re=t[96]:(Re=(0,$.jsx)(ce,{children:n.connectionModeDesc}),t[95]=n.connectionModeDesc,t[96]=Re);let ze;t[97]!==Me||t[98]!==Le||t[99]!==Re?(ze=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Me,Le,Re]}),t[97]=Me,t[98]=Le,t[99]=Re,t[100]=ze):ze=t[100];let Be;t[101]!==je||t[102]!==ze?(Be=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[je,ze]}),t[101]=je,t[102]=ze,t[103]=Be):Be=t[103];let Ve;t[104]!==n.copied||t[105]!==n.copy||t[106]!==n.encryptKey||t[107]!==n.encryptKeyDesc||t[108]!==n.hide||t[109]!==n.show||t[110]!==n.verificationToken||t[111]!==n.verificationTokenDesc||t[112]!==n.webhookHost||t[113]!==n.webhookPath||t[114]!==n.webhookPathDesc||t[115]!==n.webhookPort||t[116]!==n.webhookTitle||t[117]!==u||t[118]!==s||t[119]!==D.connectionMode||t[120]!==D.encryptKey||t[121]!==D.verificationToken||t[122]!==D.webhookHost||t[123]!==D.webhookPath||t[124]!==D.webhookPort||t[125]!==o||t[126]!==a||t[127]!==d?(Ve=D.connectionMode===`webhook`?(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.webhookTitle}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(T,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>o(ft),children:[a?(0,$.jsx)(re,{className:`size-3.5`}):(0,$.jsx)(l,{className:`size-3.5`}),a?n.hide:n.show]}),(0,$.jsxs)(T,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void u(),children:[s?(0,$.jsx)(y,{className:`size-3.5`}):(0,$.jsx)(c,{className:`size-3.5`}),s?n.copied:n.copy]})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Y,{children:n.verificationToken}),(0,$.jsx)(`input`,{className:O(J(),`min-w-0 flex-1 font-mono text-xs`),type:a?`text`:`password`,autoComplete:`off`,value:D.verificationToken??``,onChange:e=>d({verificationToken:e.target.value})}),(0,$.jsx)(ce,{children:n.verificationTokenDesc})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Y,{children:n.encryptKey}),(0,$.jsx)(`input`,{className:O(J(),`min-w-0 flex-1 font-mono text-xs`),type:a?`text`:`password`,autoComplete:`off`,value:D.encryptKey??``,onChange:e=>d({encryptKey:e.target.value})}),(0,$.jsx)(ce,{children:n.encryptKeyDesc})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,$.jsx)(Y,{children:n.webhookHost}),(0,$.jsx)(`input`,{className:O(J(),`min-w-0 flex-1 font-mono text-xs`),value:D.webhookHost??``,onChange:e=>d({webhookHost:e.target.value}),placeholder:`127.0.0.1`})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Y,{children:n.webhookPort}),(0,$.jsx)(`input`,{className:O(J(),`min-w-0 flex-1 font-mono text-xs`),type:`number`,inputMode:`numeric`,value:String(D.webhookPort??``),onChange:e=>d({webhookPort:Number(e.target.value||`0`)||0}),placeholder:`3000`})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,$.jsx)(Y,{children:n.webhookPath}),(0,$.jsx)(`input`,{className:O(J(),`min-w-0 flex-1 font-mono text-xs`),value:D.webhookPath??``,onChange:e=>d({webhookPath:e.target.value}),placeholder:`/feishu/events`}),(0,$.jsx)(ce,{children:n.webhookPathDesc})]})]}):null,t[104]=n.copied,t[105]=n.copy,t[106]=n.encryptKey,t[107]=n.encryptKeyDesc,t[108]=n.hide,t[109]=n.show,t[110]=n.verificationToken,t[111]=n.verificationTokenDesc,t[112]=n.webhookHost,t[113]=n.webhookPath,t[114]=n.webhookPathDesc,t[115]=n.webhookPort,t[116]=n.webhookTitle,t[117]=u,t[118]=s,t[119]=D.connectionMode,t[120]=D.encryptKey,t[121]=D.verificationToken,t[122]=D.webhookHost,t[123]=D.webhookPath,t[124]=D.webhookPort,t[125]=o,t[126]=a,t[127]=d,t[128]=Ve):Ve=t[128];let He;t[129]===n.renderMode?He=t[130]:(He=(0,$.jsx)(Y,{children:n.renderMode}),t[129]=n.renderMode,t[130]=He);let We;t[131]===Symbol.for(`react.memo_cache_sentinel`)?(We=J(),t[131]=We):We=t[131];let Ge;t[132]===d?Ge=t[133]:(Ge=e=>d({renderMode:e.target.value}),t[132]=d,t[133]=Ge);let Ke,qe,Je;t[134]===Symbol.for(`react.memo_cache_sentinel`)?(Ke=(0,$.jsx)(`option`,{value:`auto`,children:`auto`}),qe=(0,$.jsx)(`option`,{value:`raw`,children:`raw`}),Je=(0,$.jsx)(`option`,{value:`card`,children:`card`}),t[134]=Ke,t[135]=qe,t[136]=Je):(Ke=t[134],qe=t[135],Je=t[136]);let Ye;t[137]!==D.renderMode||t[138]!==Ge?(Ye=(0,$.jsxs)(`select`,{className:We,value:D.renderMode,onChange:Ge,children:[Ke,qe,Je]}),t[137]=D.renderMode,t[138]=Ge,t[139]=Ye):Ye=t[139];let Xe;t[140]!==He||t[141]!==Ye?(Xe=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[He,Ye]}),t[140]=He,t[141]=Ye,t[142]=Xe):Xe=t[142];let Ze;t[143]===n.reactionNotifications?Ze=t[144]:(Ze=(0,$.jsx)(Y,{children:n.reactionNotifications}),t[143]=n.reactionNotifications,t[144]=Ze);let Qe;t[145]===Symbol.for(`react.memo_cache_sentinel`)?(Qe=J(),t[145]=Qe):Qe=t[145];let $e;t[146]===d?$e=t[147]:($e=e=>d({reactionNotifications:e.target.value}),t[146]=d,t[147]=$e);let et,tt,nt;t[148]===Symbol.for(`react.memo_cache_sentinel`)?(et=(0,$.jsx)(`option`,{value:`off`,children:`off`}),tt=(0,$.jsx)(`option`,{value:`own`,children:`own`}),nt=(0,$.jsx)(`option`,{value:`all`,children:`all`}),t[148]=et,t[149]=tt,t[150]=nt):(et=t[148],tt=t[149],nt=t[150]);let rt;t[151]!==D.reactionNotifications||t[152]!==$e?(rt=(0,$.jsxs)(`select`,{className:Qe,value:D.reactionNotifications,onChange:$e,children:[et,tt,nt]}),t[151]=D.reactionNotifications,t[152]=$e,t[153]=rt):rt=t[153];let it;t[154]!==Ze||t[155]!==rt?(it=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Ze,rt]}),t[154]=Ze,t[155]=rt,t[156]=it):it=t[156];let at;t[157]!==Xe||t[158]!==it?(at=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Xe,it]}),t[157]=Xe,t[158]=it,t[159]=at):at=t[159];let ot;t[160]===d?ot=t[161]:(ot=e=>d({streaming:e.target.checked}),t[160]=d,t[161]=ot);let st;t[162]!==D.streaming||t[163]!==ot?(st=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:D.streaming,onChange:ot}),t[162]=D.streaming,t[163]=ot,t[164]=st):st=t[164];let ct;t[165]!==n.enableStreaming||t[166]!==st?(ct=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[st,n.enableStreaming]}),t[165]=n.enableStreaming,t[166]=st,t[167]=ct):ct=t[167];let ut;t[168]===n.groupPolicy?ut=t[169]:(ut=(0,$.jsx)(Y,{children:n.groupPolicy}),t[168]=n.groupPolicy,t[169]=ut);let mt;t[170]===Symbol.for(`react.memo_cache_sentinel`)?(mt=J(),t[170]=mt):mt=t[170];let ht=D.groupPolicy,gt;t[171]===d?gt=t[172]:(gt=e=>d({groupPolicy:e.target.value}),t[171]=d,t[172]=gt);let _t;t[173]===v?_t=t[174]:(_t=v.map(dt),t[173]=v,t[174]=_t);let vt;t[175]!==D.groupPolicy||t[176]!==gt||t[177]!==_t?(vt=(0,$.jsx)(`select`,{className:mt,value:ht,onChange:gt,children:_t}),t[175]=D.groupPolicy,t[176]=gt,t[177]=_t,t[178]=vt):vt=t[178];let yt;t[179]!==ut||t[180]!==vt?(yt=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[ut,vt]}),t[179]=ut,t[180]=vt,t[181]=yt):yt=t[181];let bt;t[182]===d?bt=t[183]:(bt=e=>d({requireMention:e.target.checked}),t[182]=d,t[183]=bt);let xt;t[184]!==D.requireMention||t[185]!==bt?(xt=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:D.requireMention,onChange:bt}),t[184]=D.requireMention,t[185]=bt,t[186]=xt):xt=t[186];let St;t[187]!==n.requireMention||t[188]!==xt?(St=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[xt,n.requireMention]}),t[187]=n.requireMention,t[188]=xt,t[189]=St):St=t[189];let Ct;t[190]===n.allowFromDm?Ct=t[191]:(Ct=(0,$.jsx)(Y,{children:n.allowFromDm}),t[190]=n.allowFromDm,t[191]=Ct);let wt;t[192]===Symbol.for(`react.memo_cache_sentinel`)?(wt=O(J(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[192]=wt):wt=t[192];let Tt;t[193]===D.allowFrom?Tt=t[194]:(Tt=ae(D.allowFrom),t[193]=D.allowFrom,t[194]=Tt);let Et;t[195]===d?Et=t[196]:(Et=e=>d({allowFrom:oe(e.target.value)}),t[195]=d,t[196]=Et);let Dt;t[197]!==Tt||t[198]!==Et?(Dt=(0,$.jsx)(`textarea`,{className:wt,rows:2,placeholder:`ou_xxx, on_xxx`,value:Tt,onChange:Et}),t[197]=Tt,t[198]=Et,t[199]=Dt):Dt=t[199];let Ot;t[200]===n.allowFromDmDesc?Ot=t[201]:(Ot=(0,$.jsx)(ce,{children:n.allowFromDmDesc}),t[200]=n.allowFromDmDesc,t[201]=Ot);let kt;t[202]!==Ct||t[203]!==Dt||t[204]!==Ot?(kt=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Ct,Dt,Ot]}),t[202]=Ct,t[203]=Dt,t[204]=Ot,t[205]=kt):kt=t[205];let At;t[206]===n.allowFromGroups?At=t[207]:(At=(0,$.jsx)(Y,{children:n.allowFromGroups}),t[206]=n.allowFromGroups,t[207]=At);let jt;t[208]===Symbol.for(`react.memo_cache_sentinel`)?(jt=O(J(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[208]=jt):jt=t[208];let Mt;t[209]===D.groupAllowFrom?Mt=t[210]:(Mt=ae(D.groupAllowFrom),t[209]=D.groupAllowFrom,t[210]=Mt);let Nt;t[211]===d?Nt=t[212]:(Nt=e=>d({groupAllowFrom:oe(e.target.value)}),t[211]=d,t[212]=Nt);let Pt;t[213]!==Mt||t[214]!==Nt?(Pt=(0,$.jsx)(`textarea`,{className:jt,rows:2,placeholder:`oc_xxx, oc_yyy`,value:Mt,onChange:Nt}),t[213]=Mt,t[214]=Nt,t[215]=Pt):Pt=t[215];let Ft;t[216]===n.allowFromGroupsDesc?Ft=t[217]:(Ft=(0,$.jsx)(ce,{children:n.allowFromGroupsDesc}),t[216]=n.allowFromGroupsDesc,t[217]=Ft);let It;t[218]!==At||t[219]!==Pt||t[220]!==Ft?(It=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[At,Pt,Ft]}),t[218]=At,t[219]=Pt,t[220]=Ft,t[221]=It):It=t[221];let Lt;t[222]===n.historyLimit?Lt=t[223]:(Lt=(0,$.jsx)(Y,{children:n.historyLimit}),t[222]=n.historyLimit,t[223]=Lt);let Rt;t[224]===Symbol.for(`react.memo_cache_sentinel`)?(Rt=O(J(),`min-w-0 flex-1 font-mono text-xs`),t[224]=Rt):Rt=t[224];let zt=String(D.historyLimit),Bt;t[225]===d?Bt=t[226]:(Bt=e=>d({historyLimit:Number(e.target.value||`0`)||0}),t[225]=d,t[226]=Bt);let Vt;t[227]!==zt||t[228]!==Bt?(Vt=(0,$.jsx)(`input`,{className:Rt,type:`number`,inputMode:`numeric`,value:zt,onChange:Bt}),t[227]=zt,t[228]=Bt,t[229]=Vt):Vt=t[229];let Ht;t[230]!==Lt||t[231]!==Vt?(Ht=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Lt,Vt]}),t[230]=Lt,t[231]=Vt,t[232]=Ht):Ht=t[232];let Ut;t[233]===n.textChunkLimit?Ut=t[234]:(Ut=(0,$.jsx)(Y,{children:n.textChunkLimit}),t[233]=n.textChunkLimit,t[234]=Ut);let Wt;t[235]===Symbol.for(`react.memo_cache_sentinel`)?(Wt=O(J(),`min-w-0 flex-1 font-mono text-xs`),t[235]=Wt):Wt=t[235];let Gt=String(D.textChunkLimit),Kt;t[236]===d?Kt=t[237]:(Kt=e=>d({textChunkLimit:Number(e.target.value||`0`)||0}),t[236]=d,t[237]=Kt);let qt;t[238]!==Gt||t[239]!==Kt?(qt=(0,$.jsx)(`input`,{className:Wt,type:`number`,inputMode:`numeric`,value:Gt,onChange:Kt}),t[238]=Gt,t[239]=Kt,t[240]=qt):qt=t[240];let Jt;t[241]!==Ut||t[242]!==qt?(Jt=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Ut,qt]}),t[241]=Ut,t[242]=qt,t[243]=Jt):Jt=t[243];let Yt;t[244]!==Jt||t[245]!==Ht?(Yt=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Ht,Jt]}),t[244]=Jt,t[245]=Ht,t[246]=Yt):Yt=t[246];let Xt;t[247]===n.feishuToolsTitle?Xt=t[248]:(Xt=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.feishuToolsTitle}),t[247]=n.feishuToolsTitle,t[248]=Xt);let Zt;t[249]===n.feishuToolDoc?Zt=t[250]:(Zt=[`doc`,n.feishuToolDoc],t[249]=n.feishuToolDoc,t[250]=Zt);let Qt;t[251]===n.feishuToolWiki?Qt=t[252]:(Qt=[`wiki`,n.feishuToolWiki],t[251]=n.feishuToolWiki,t[252]=Qt);let $t;t[253]===n.feishuToolDrive?$t=t[254]:($t=[`drive`,n.feishuToolDrive],t[253]=n.feishuToolDrive,t[254]=$t);let en;t[255]===n.feishuToolPerm?en=t[256]:(en=[`perm`,n.feishuToolPerm],t[255]=n.feishuToolPerm,t[256]=en);let tn;t[257]===n.feishuToolBitable?tn=t[258]:(tn=[`bitable`,n.feishuToolBitable],t[257]=n.feishuToolBitable,t[258]=tn);let nn;t[259]===n.feishuToolScopes?nn=t[260]:(nn=[`scopes`,n.feishuToolScopes],t[259]=n.feishuToolScopes,t[260]=nn);let rn;t[261]!==Zt||t[262]!==Qt||t[263]!==$t||t[264]!==en||t[265]!==tn||t[266]!==nn?(rn=[Zt,Qt,$t,en,tn,nn],t[261]=Zt,t[262]=Qt,t[263]=$t,t[264]=en,t[265]=tn,t[266]=nn,t[267]=rn):rn=t[267];let an=rn,on;t[268]!==D.tools||t[269]!==an||t[270]!==d?(on=(0,$.jsx)(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:an.map(e=>{let[t,n]=e;return(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:!!D.tools?.[t],onChange:e=>d({tools:{...D.tools,[t]:e.target.checked}})}),n]},t)})}),t[268]=D.tools,t[269]=an,t[270]=d,t[271]=on):on=t[271];let sn;t[272]===n.feishuToolsDesc?sn=t[273]:(sn=(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsx)(ce,{children:n.feishuToolsDesc})}),t[272]=n.feishuToolsDesc,t[273]=sn);let cn;t[274]!==Xt||t[275]!==on||t[276]!==sn?(cn=(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[Xt,on,sn]}),t[274]=Xt,t[275]=on,t[276]=sn,t[277]=cn):cn=t[277];let ln;t[278]===n.feishuActionsTitle?ln=t[279]:(ln=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.feishuActionsTitle}),t[278]=n.feishuActionsTitle,t[279]=ln);let un=!!D.actions?.reactions,dn;t[280]!==D.actions||t[281]!==d?(dn=e=>d({actions:{...D.actions,reactions:e.target.checked}}),t[280]=D.actions,t[281]=d,t[282]=dn):dn=t[282];let fn;t[283]!==un||t[284]!==dn?(fn=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:un,onChange:dn}),t[283]=un,t[284]=dn,t[285]=fn):fn=t[285];let pn;t[286]!==n.feishuActionReactions||t[287]!==fn?(pn=(0,$.jsxs)(`label`,{className:`mt-2 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[fn,n.feishuActionReactions]}),t[286]=n.feishuActionReactions,t[287]=fn,t[288]=pn):pn=t[288];let mn;t[289]!==ln||t[290]!==pn?(mn=(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[ln,pn]}),t[289]=ln,t[290]=pn,t[291]=mn):mn=t[291];let hn;t[292]===D?hn=t[293]:(hn=le(D),t[292]=D,t[293]=hn);let gn;t[294]===b?.items?gn=t[295]:(gn=b?.items??[],t[294]=b?.items,t[295]=gn);let _n;t[296]===f?_n=t[297]:(_n=(e,t)=>f(`feishu`,e,t),t[296]=f,t[297]=_n);let vn;t[298]!==n||t[299]!==r.channelAgentRoutes.feishu||t[300]!==r.defaultAgentId||t[301]!==x||t[302]!==hn||t[303]!==gn||t[304]!==_n?(vn=(0,$.jsx)(Ue,{accountIds:hn,routes:r.channelAgentRoutes.feishu,defaultAgentId:r.defaultAgentId,agentItems:gn,disabled:x,onChange:_n,ch:n}),t[298]=n,t[299]=r.channelAgentRoutes.feishu,t[300]=r.defaultAgentId,t[301]=x,t[302]=hn,t[303]=gn,t[304]=_n,t[305]=vn):vn=t[305];let yn;t[306]===n.multiAccountJson?yn=t[307]:(yn=(0,$.jsx)(Y,{children:n.multiAccountJson}),t[306]=n.multiAccountJson,t[307]=yn);let bn;t[308]===Symbol.for(`react.memo_cache_sentinel`)?(bn=O(J(),`min-h-[140px] resize-y font-mono text-xs`),t[308]=bn):bn=t[308];let xn;t[309]===m?xn=t[310]:(xn=e=>m(e.target.value),t[309]=m,t[310]=xn);let Sn;t[311]!==p||t[312]!==g||t[313]!==xn?(Sn=(0,$.jsx)(`textarea`,{className:bn,spellCheck:!1,value:p,onChange:xn,onBlur:g,placeholder:`{ "default": { "appId": "...", "appSecret": "...", "enabled": true } }`}),t[311]=p,t[312]=g,t[313]=xn,t[314]=Sn):Sn=t[314];let Cn;t[315]!==n.multiAccountJsonDesc||t[316]!==h?(Cn=h?(0,$.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:h}):(0,$.jsx)(ce,{children:n.multiAccountJsonDesc}),t[315]=n.multiAccountJsonDesc,t[316]=h,t[317]=Cn):Cn=t[317];let wn;t[318]!==yn||t[319]!==Sn||t[320]!==Cn?(wn=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[yn,Sn,Cn]}),t[318]=yn,t[319]=Sn,t[320]=Cn,t[321]=wn):wn=t[321];let Tn;t[322]!==Yt||t[323]!==cn||t[324]!==mn||t[325]!==vn||t[326]!==wn||t[327]!==ge||t[328]!==Ce||t[329]!==Be||t[330]!==Ve||t[331]!==at||t[332]!==ct||t[333]!==yt||t[334]!==St||t[335]!==kt||t[336]!==It?(Tn=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[ge,Ce,Be,Ve,at,ct,yt,St,kt,It,Yt,cn,mn,vn,wn]}),t[322]=Yt,t[323]=cn,t[324]=mn,t[325]=vn,t[326]=wn,t[327]=ge,t[328]=Ce,t[329]=Be,t[330]=Ve,t[331]=at,t[332]=ct,t[333]=yt,t[334]=St,t[335]=kt,t[336]=It,t[337]=Tn):Tn=t[337];let En;t[338]!==G||t[339]!==Tn||t[340]!==K||t[341]!==q||t[342]!==V?(En=(0,$.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle px-3 pb-3 pt-3 dark:border-edge-subtle`,children:[V,G,K,q,Tn]}),t[338]=G,t[339]=Tn,t[340]=K,t[341]=q,t[342]=V,t[343]=En):En=t[343];let Dn;return t[344]!==En||t[345]!==B?(Dn=(0,$.jsxs)(`details`,{ref:L,className:`group rounded-xl border border-edge-subtle bg-surface-base open:pb-3 dark:border-edge`,children:[B,En]}),t[344]=En,t[345]=B,t[346]=Dn):Dn=t[346],Dn}function dt(e){return(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value)}function ft(e){return!e}function pt(){return it(`feishu`)}var mt=e(X(),1);function ht(e){let t=(0,Q.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,$.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,$.jsx)(T,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,$.jsx)(T,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,$.jsx)(T,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,$.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==u?(y=(0,$.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,v]}),t[21]=v,t[22]=u,t[23]=y):y=t[23],y}var gt={width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}},_t={sessionKey:null,qrUrl:null};function vt({ch:e,onSetupSuccess:t,onOpenChange:n,closeOnSetupSuccess:r,moreSettings:i}){let[a,o]=(0,Z.useState)(`feishu`),[s,c]=(0,Z.useState)(0),[l,u]=(0,Z.useState)(null),d=(0,Z.useRef)(t),f=(0,Z.useRef)(n);d.current=t,f.current=n;let p=R(()=>we({domain:a}).then(e=>({sessionKey:e.sessionKey,qrUrl:e.qrUrl})),[s,a],{initial:_t,errorData:_t}),m=p.data.sessionKey,h=p.data.qrUrl,g=p.loading,_=p.error instanceof Error?p.error.message:p.error?String(p.error):null,v=l??_,y=(0,Z.useCallback)(e=>{u(null),o(e),c(e=>e+1)},[]);(0,Z.useEffect)(()=>{if(!m)return;let e=!1,t,n=async()=>{try{let n=await fe(m);if(e||n.phase===`polling`)return;if(n.phase===`done`){t!==void 0&&(window.clearInterval(t),t=void 0),p.setData(_t),n.ok?(r&&f.current(!1),d.current({appId:n.appId,domain:n.domain,openId:n.openId})):u(n.message);return}n.phase===`unknown`&&(t!==void 0&&window.clearInterval(t),u(n.message),p.setData(_t))}catch(n){e||(t!==void 0&&window.clearInterval(t),u(n instanceof Error?n.message:`Request failed`),p.setData(_t))}};return t=window.setInterval(()=>void n(),3e3),n(),()=>{e=!0,t!==void 0&&window.clearInterval(t)}},[m,r,p.setData]);let b=R(()=>mt.toDataURL(h,gt),[h],{enabled:!!h,initial:null,errorData:null}),x=b.data,S=b.error!==null&&!b.loading,w=!!(h&&m),E=!v&&!w;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`text-center`,children:[(0,$.jsx)(`p`,{className:`text-base font-semibold tracking-tight text-fg`,children:e.feishuQrModalTitle}),(0,$.jsx)(`p`,{className:`mt-1.5 text-sm text-fg-muted`,children:e.feishuQrModalSubtitle})]}),(0,$.jsxs)(`div`,{className:`mt-6 flex min-h-[17.5rem] flex-col items-center justify-center gap-3`,children:[v?(0,$.jsx)(`p`,{className:`text-center text-sm text-red-600 dark:text-red-400`,children:v}):null,!v&&(w||E)?(0,$.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:E?e.feishuQrStarting:e.feishuQrScanHint}),(0,$.jsxs)(`div`,{className:O(`relative flex size-52 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-edge-subtle bg-white p-3 dark:border-edge`,E&&`bg-surface-muted/40 dark:bg-surface-base`),children:[E?(0,$.jsx)(`div`,{className:`absolute inset-3 animate-pulse rounded-md bg-surface-muted dark:bg-surface-hover`,"aria-hidden":!0}):null,w&&h&&!v&&x&&!S?(0,$.jsx)(`img`,{src:x,alt:``,className:`relative z-[1] size-full object-contain`}):null,w&&h&&!v&&!x&&!S&&!E?(0,$.jsx)(`p`,{className:`relative z-[1] px-2 text-center text-sm text-fg-muted`,children:e.feishuQrEncoding}):null,w&&h&&!v&&S?(0,$.jsxs)(`div`,{className:`relative z-[1] flex size-full flex-col items-center justify-center gap-2 px-1`,children:[(0,$.jsx)(`p`,{className:`text-center text-xs text-fg-muted`,children:e.feishuQrImageError}),(0,$.jsxs)(`a`,{href:h,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent underline-offset-2 hover:underline`,children:[(0,$.jsx)(V,{className:`size-3 shrink-0`}),e.feishuQrOpenLink]})]}):null]})]}):null]}),(0,$.jsx)(`div`,{className:`mx-auto mt-4 flex w-full max-w-[20rem] justify-center px-1`,role:`group`,"aria-label":e.feishuRegionSwitchAria,children:(0,$.jsxs)(`div`,{className:`inline-flex w-full rounded-full border border-edge bg-surface-muted/60 p-1 dark:border-edge dark:bg-surface-base`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:g,className:O(`min-w-0 flex-1 rounded-full px-3 py-2 text-center text-sm font-medium transition-colors`,C.press,a===`feishu`?`bg-surface-panel text-fg shadow-sm dark:bg-surface-panel`:`text-fg-muted hover:text-fg`),onClick:()=>y(`feishu`),children:e.feishuRegionChina}),(0,$.jsx)(`button`,{type:`button`,disabled:g,className:O(`min-w-0 flex-1 rounded-full px-3 py-2 text-center text-sm font-medium transition-colors`,C.press,a===`lark`?`bg-surface-panel text-fg shadow-sm dark:bg-surface-panel`:`text-fg-muted hover:text-fg`),onClick:()=>y(`lark`),children:e.feishuRegionInternational})]})}),(0,$.jsx)(`div`,{className:`mt-6`,children:(0,$.jsx)(T,{type:`button`,variant:`secondary`,className:`h-11 w-full rounded-full border-0 bg-fg text-surface-panel hover:opacity-90 dark:bg-fg dark:text-surface-panel`,disabled:g,onClick:()=>y(a),children:g?e.feishuQrStarting:e.feishuQrRegenerate})}),i?(0,$.jsx)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:i}):null]})}function yt(e){let t=(0,Q.c)(26),{open:n,onOpenChange:r,ch:i,onSetupSuccess:a,moreSettings:o,settingsDirty:s,settingsSaving:c,onSettingsDiscard:l,onSettingsSave:u,presentation:d,closeOnSetupSuccess:f}=e,p=s===void 0?!1:s,m=c===void 0?!1:c,h=d===void 0?`modal`:d,g=f===void 0?!0:f,_;t[0]!==i||t[1]!==o||t[2]!==r||t[3]!==l||t[4]!==u||t[5]!==p||t[6]!==m?(_=o&&l&&u?(0,$.jsx)(ht,{ch:i,dirty:p,saving:m,showCancel:!1,onCancel:()=>r(!1),onDiscard:l,onSave:u}):void 0,t[0]=i,t[1]=o,t[2]=r,t[3]=l,t[4]=u,t[5]=p,t[6]=m,t[7]=_):_=t[7];let v;t[8]!==i||t[9]!==g||t[10]!==o||t[11]!==r||t[12]!==a||t[13]!==n?(v=n?(0,$.jsx)(vt,{ch:i,onSetupSuccess:a,onOpenChange:r,closeOnSetupSuccess:g,moreSettings:o},`active`):null,t[8]=i,t[9]=g,t[10]=o,t[11]=r,t[12]=a,t[13]=n,t[14]=v):v=t[14];let y;return t[15]!==i.feishuQrCloseAria||t[16]!==i.feishuQrModalSubtitle||t[17]!==i.feishuQrModalTitle||t[18]!==i.feishuSubtitle||t[19]!==i.feishuTitle||t[20]!==r||t[21]!==n||t[22]!==h||t[23]!==_||t[24]!==v?(y=(0,$.jsx)(ze,{presentation:h,open:n,onOpenChange:r,title:i.feishuTitle,description:i.feishuSubtitle,srTitle:i.feishuQrModalTitle,srDescription:i.feishuQrModalSubtitle,closeAriaLabel:i.feishuQrCloseAria,wide:!0,footer:_,children:v}),t[15]=i.feishuQrCloseAria,t[16]=i.feishuQrModalSubtitle,t[17]=i.feishuQrModalTitle,t[18]=i.feishuSubtitle,t[19]=i.feishuTitle,t[20]=r,t[21]=n,t[22]=h,t[23]=_,t[24]=v,t[25]=y):y=t[25],y}function bt(e){let t=(0,Q.c)(25),{ch:n,usesPairing:r,tokenReady:i,pairingComplete:a}=e;if(!r)return null;let o=i,s=a,c=!o,l=o&&!s,u;t[0]!==c||t[1]!==o?(u=(0,$.jsx)(xt,{done:o,current:c,index:1}),t[0]=c,t[1]=o,t[2]=u):u=t[2];let d=o&&`text-fg-muted`,f;t[3]===d?f=t[4]:(f=O(`text-fg`,d),t[3]=d,t[4]=f);let p;t[5]!==n.telegramSetupStepToken||t[6]!==f?(p=(0,$.jsx)(`span`,{className:f,children:n.telegramSetupStepToken}),t[5]=n.telegramSetupStepToken,t[6]=f,t[7]=p):p=t[7];let m;t[8]!==u||t[9]!==p?(m=(0,$.jsxs)(`li`,{className:`flex items-start gap-2`,children:[u,p]}),t[8]=u,t[9]=p,t[10]=m):m=t[10];let h;t[11]!==l||t[12]!==s?(h=(0,$.jsx)(xt,{done:s,current:l,index:2}),t[11]=l,t[12]=s,t[13]=h):h=t[13];let g=s&&`text-fg-muted`,_;t[14]===g?_=t[15]:(_=O(`text-fg`,g),t[14]=g,t[15]=_);let v;t[16]!==n.telegramSetupStepPairing||t[17]!==_?(v=(0,$.jsx)(`span`,{className:_,children:n.telegramSetupStepPairing}),t[16]=n.telegramSetupStepPairing,t[17]=_,t[18]=v):v=t[18];let y;t[19]!==h||t[20]!==v?(y=(0,$.jsxs)(`li`,{className:`flex items-start gap-2`,children:[h,v]}),t[19]=h,t[20]=v,t[21]=y):y=t[21];let b;return t[22]!==y||t[23]!==m?(b=(0,$.jsxs)(`ol`,{className:`space-y-2 rounded-xl border border-accent/25 bg-accent-soft/20 px-4 py-3 text-xs`,children:[m,y]}),t[22]=y,t[23]=m,t[24]=b):b=t[24],b}function xt(e){let t=(0,Q.c)(7),{done:n,current:r,index:i}=e,a=n&&`border-success bg-success text-white`,o=!n&&r&&`border-accent bg-accent text-white`,s=!n&&!r&&`border-edge text-fg-muted`,c;t[0]!==a||t[1]!==o||t[2]!==s?(c=O(`mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full border text-[10px] font-semibold`,a,o,s),t[0]=a,t[1]=o,t[2]=s,t[3]=c):c=t[3];let l=n?`✓`:String(i),u;return t[4]!==c||t[5]!==l?(u=(0,$.jsx)(`span`,{className:c,"aria-hidden":!0,children:l}),t[4]=c,t[5]=l,t[6]=u):u=t[6],u}function St(e){let t=(0,Q.c)(115),{tg:n,updateTelegram:r,ch:i,groupOpts:a,replyOpts:o,streamOpts:s,tgAccountsDraft:c,setTgAccountsDraft:l,tgAccountsError:u,onTgAccountsBlur:d}=e,f;t[0]===i.apiRoot?f=t[1]:(f=(0,$.jsx)(Y,{children:i.apiRoot}),t[0]=i.apiRoot,t[1]=f);let p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=J(),t[2]=p):p=t[2];let m;t[3]===r?m=t[4]:(m=e=>r({apiRoot:e.target.value}),t[3]=r,t[4]=m);let h;t[5]!==m||t[6]!==n.apiRoot?(h=(0,$.jsx)(`input`,{className:p,value:n.apiRoot,onChange:m,placeholder:`https://api.telegram.org`}),t[5]=m,t[6]=n.apiRoot,t[7]=h):h=t[7];let g;t[8]!==f||t[9]!==h?(g=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[f,h]}),t[8]=f,t[9]=h,t[10]=g):g=t[10];let _;t[11]===i.proxy?_=t[12]:(_=(0,$.jsx)(Y,{children:i.proxy}),t[11]=i.proxy,t[12]=_);let v;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(v=J(),t[13]=v):v=t[13];let y;t[14]===r?y=t[15]:(y=e=>r({proxy:e.target.value}),t[14]=r,t[15]=y);let b;t[16]!==y||t[17]!==n.proxy?(b=(0,$.jsx)(`input`,{className:v,value:n.proxy,onChange:y,placeholder:`http://proxy.example.com:8080`}),t[16]=y,t[17]=n.proxy,t[18]=b):b=t[18];let x;t[19]!==_||t[20]!==b?(x=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[_,b]}),t[19]=_,t[20]=b,t[21]=x):x=t[21];let S;t[22]===r?S=t[23]:(S=e=>r({groupPolicy:e}),t[22]=r,t[23]=S);let C;t[24]!==i.groupPolicy||t[25]!==a||t[26]!==S||t[27]!==n.groupPolicy?(C=(0,$.jsx)(se,{label:i.groupPolicy,value:n.groupPolicy,onChange:S,options:a}),t[24]=i.groupPolicy,t[25]=a,t[26]=S,t[27]=n.groupPolicy,t[28]=C):C=t[28];let w;t[29]===r?w=t[30]:(w=e=>r({replyToMode:e}),t[29]=r,t[30]=w);let T;t[31]!==i.replyToMode||t[32]!==o||t[33]!==w||t[34]!==n.replyToMode?(T=(0,$.jsx)(se,{label:i.replyToMode,value:n.replyToMode,onChange:w,options:o}),t[31]=i.replyToMode,t[32]=o,t[33]=w,t[34]=n.replyToMode,t[35]=T):T=t[35];let E;t[36]===r?E=t[37]:(E=e=>r({streamMode:e}),t[36]=r,t[37]=E);let D;t[38]!==i.streamMode||t[39]!==s||t[40]!==E||t[41]!==n.streamMode?(D=(0,$.jsx)(se,{label:i.streamMode,value:n.streamMode,onChange:E,options:s}),t[38]=i.streamMode,t[39]=s,t[40]=E,t[41]=n.streamMode,t[42]=D):D=t[42];let k;t[43]===i.allowFromGroups?k=t[44]:(k=(0,$.jsx)(Y,{children:i.allowFromGroups}),t[43]=i.allowFromGroups,t[44]=k);let A;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(A=O(J(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[45]=A):A=t[45];let j;t[46]===n.groupAllowFrom?j=t[47]:(j=ae(n.groupAllowFrom),t[46]=n.groupAllowFrom,t[47]=j);let M;t[48]===r?M=t[49]:(M=e=>r({groupAllowFrom:oe(e.target.value)}),t[48]=r,t[49]=M);let N;t[50]!==j||t[51]!==M?(N=(0,$.jsx)(`textarea`,{className:A,rows:2,placeholder:`-1001234567890`,value:j,onChange:M}),t[50]=j,t[51]=M,t[52]=N):N=t[52];let P;t[53]!==k||t[54]!==N?(P=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[k,N]}),t[53]=k,t[54]=N,t[55]=P):P=t[55];let F;t[56]===i.historyLimit?F=t[57]:(F=(0,$.jsx)(Y,{children:i.historyLimit}),t[56]=i.historyLimit,t[57]=F);let I;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(I=J(),t[58]=I):I=t[58];let L;t[59]===r?L=t[60]:(L=e=>r({historyLimit:parseInt(e.target.value,10)||50}),t[59]=r,t[60]=L);let ee;t[61]!==L||t[62]!==n.historyLimit?(ee=(0,$.jsx)(`input`,{type:`number`,min:10,max:200,className:I,value:n.historyLimit,onChange:L}),t[61]=L,t[62]=n.historyLimit,t[63]=ee):ee=t[63];let R;t[64]!==F||t[65]!==ee?(R=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[F,ee]}),t[64]=F,t[65]=ee,t[66]=R):R=t[66];let te;t[67]===i.textChunkLimit?te=t[68]:(te=(0,$.jsx)(Y,{children:i.textChunkLimit}),t[67]=i.textChunkLimit,t[68]=te);let z;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(z=J(),t[69]=z):z=t[69];let ne;t[70]===r?ne=t[71]:(ne=e=>r({textChunkLimit:parseInt(e.target.value,10)||4e3}),t[70]=r,t[71]=ne);let re;t[72]!==ne||t[73]!==n.textChunkLimit?(re=(0,$.jsx)(`input`,{type:`number`,min:1e3,max:1e4,step:100,className:z,value:n.textChunkLimit,onChange:ne}),t[72]=ne,t[73]=n.textChunkLimit,t[74]=re):re=t[74];let B;t[75]!==te||t[76]!==re?(B=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[te,re]}),t[75]=te,t[76]=re,t[77]=B):B=t[77];let V;t[78]!==R||t[79]!==B?(V=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[R,B]}),t[78]=R,t[79]=B,t[80]=V):V=t[80];let H;t[81]===r?H=t[82]:(H=e=>r({debug:e.target.checked}),t[81]=r,t[82]=H);let U;t[83]!==H||t[84]!==n.debug?(U=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:n.debug,onChange:H}),t[83]=H,t[84]=n.debug,t[85]=U):U=t[85];let W;t[86]!==i.telegramDebug||t[87]!==U?(W=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[U,i.telegramDebug]}),t[86]=i.telegramDebug,t[87]=U,t[88]=W):W=t[88];let G;t[89]===i.multiAccountJson?G=t[90]:(G=(0,$.jsx)(Y,{children:i.multiAccountJson}),t[89]=i.multiAccountJson,t[90]=G);let ie;t[91]===Symbol.for(`react.memo_cache_sentinel`)?(ie=O(J(),`min-h-[140px] resize-y font-mono text-xs`),t[91]=ie):ie=t[91];let K;t[92]===l?K=t[93]:(K=e=>l(e.target.value),t[92]=l,t[93]=K);let q;t[94]!==d||t[95]!==K||t[96]!==c?(q=(0,$.jsx)(`textarea`,{className:ie,spellCheck:!1,value:c,onChange:K,onBlur:d,placeholder:`{ "personal": { "accountId": "personal", "botToken": "...", ... } }`}),t[94]=d,t[95]=K,t[96]=c,t[97]=q):q=t[97];let le;t[98]!==i.multiAccountJsonDesc||t[99]!==u?(le=u?(0,$.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:u}):(0,$.jsx)(ce,{children:i.multiAccountJsonDesc}),t[98]=i.multiAccountJsonDesc,t[99]=u,t[100]=le):le=t[100];let ue;t[101]!==G||t[102]!==q||t[103]!==le?(ue=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[G,q,le]}),t[101]=G,t[102]=q,t[103]=le,t[104]=ue):ue=t[104];let de;return t[105]!==x||t[106]!==C||t[107]!==T||t[108]!==D||t[109]!==P||t[110]!==V||t[111]!==W||t[112]!==ue||t[113]!==g?(de=(0,$.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle pt-4 dark:border-edge`,children:[g,x,C,T,D,P,V,W,ue]}),t[105]=x,t[106]=C,t[107]=T,t[108]=D,t[109]=P,t[110]=V,t[111]=W,t[112]=ue,t[113]=g,t[114]=de):de=t[114],de}function Ct(e){let t=(0,Q.c)(151),{open:n,onOpenChange:r,presentation:i,ch:a,form:o,baseline:s,tgAdvanced:c,setTgAdvanced:l,updateTelegram:u,updateChannelAgentRoute:d,tgAccountsDraft:f,setTgAccountsDraft:p,tgAccountsError:m,onTgAccountsBlur:h,dmOpts:g,groupOpts:_,replyOpts:v,streamOpts:y,chatAgents:b,saving:x,dirty:S,save:C,discard:w,language:E,scrollToPairingOnOpen:D,closeOnSave:k}=e,A=i===void 0?`modal`:i,j=D===void 0?!1:D,M=k===void 0?!0:k,N=o.telegram,P;t[0]===s?P=t[1]:(P=s?ie(s.telegram):``,t[0]=s,t[1]=P);let I=P,L=ie(N),R;t[2]!==a.copied||t[3]!==a.copy||t[4]!==a.hide||t[5]!==a.show?(R=ee({show:a.show,hide:a.hide,copy:a.copy,copied:a.copied}),t[2]=a.copied,t[3]=a.copy,t[4]=a.hide,t[5]=a.show,t[6]=R):R=t[6];let te=R,[z,re]=(0,Z.useState)(0),B=!!L.trim()&&N.enabled,V;t[7]===N?V=t[8]:(V=Te(N),t[7]=N,t[8]=V);let H=V,U,W;t[9]!==n||t[10]!==j?(U=()=>{if(!n||!j)return;let e=window.setTimeout(Tt,80);return()=>window.clearTimeout(e)},W=[n,j],t[9]=n,t[10]=j,t[11]=U,t[12]=W):(U=t[11],W=t[12]),(0,Z.useEffect)(U,W);let G=a.telegramTitle,K=a.telegramSubtitle,q=a.telegramTitle,le=a.telegramSubtitle,ue=a.modalCancel,de;t[13]!==a.telegramSubtitle||t[14]!==a.telegramTitle||t[15]!==A?(de=A===`modal`?(0,$.jsxs)(`div`,{className:`border-b border-edge-subtle px-6 pb-4 pt-6 dark:border-edge-subtle`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-fg`,children:a.telegramTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a.telegramSubtitle})]}):void 0,t[13]=a.telegramSubtitle,t[14]=a.telegramTitle,t[15]=A,t[16]=de):de=t[16];let fe;t[17]===r?fe=t[18]:(fe=()=>r(!1),t[17]=r,t[18]=fe);let pe;t[19]!==M||t[20]!==r||t[21]!==C?(pe=async()=>{await C()&&M&&r(!1)},t[19]=M,t[20]=r,t[21]=C,t[22]=pe):pe=t[22];let me;t[23]!==a||t[24]!==S||t[25]!==w||t[26]!==x||t[27]!==fe||t[28]!==pe?(me=(0,$.jsx)(ht,{ch:a,dirty:S,saving:x,onCancel:fe,onDiscard:w,onSave:pe}),t[23]=a,t[24]=S,t[25]=w,t[26]=x,t[27]=fe,t[28]=pe,t[29]=me):me=t[29];let he;t[30]===u?he=t[31]:(he=e=>u({enabled:e.target.checked}),t[30]=u,t[31]=he);let ge;t[32]!==he||t[33]!==N.enabled?(ge=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:N.enabled,onChange:he}),t[32]=he,t[33]=N.enabled,t[34]=ge):ge=t[34];let _e;t[35]===a.enableTelegramAria?_e=t[36]:(_e=(0,$.jsx)(`span`,{children:a.enableTelegramAria}),t[35]=a.enableTelegramAria,t[36]=_e);let ve;t[37]!==ge||t[38]!==_e?(ve=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[ge,_e]}),t[37]=ge,t[38]=_e,t[39]=ve):ve=t[39];let ye;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[40]=ye):ye=t[40];let be;t[41]===a.telegramToken?be=t[42]:(be=(0,$.jsxs)(Y,{children:[a.telegramToken,ye]}),t[41]=a.telegramToken,t[42]=be);let xe;t[43]!==N.accounts||t[44]!==u?(xe=e=>{let t=N.accounts?.default??Se(`default`);u({accounts:{...N.accounts,default:{...t,accountId:`default`,botToken:e}}})},t[43]=N.accounts,t[44]=u,t[45]=xe):xe=t[45];let X;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(X=O(J(),`text-xs`),t[46]=X):X=t[46];let Ce;t[47]!==te||t[48]!==xe||t[49]!==I||t[50]!==L?(Ce=(0,$.jsx)(F,{value:L,onChange:xe,placeholder:`123456789:ABCdefGHIjklMNOpqrsTUVwxyz`,labels:te,baselineValue:I,inputClassName:X}),t[47]=te,t[48]=xe,t[49]=I,t[50]=L,t[51]=Ce):Ce=t[51];let we;t[52]===a.telegramTokenDesc?we=t[53]:(we=(0,$.jsx)(ce,{children:a.telegramTokenDesc}),t[52]=a.telegramTokenDesc,t[53]=we);let Ee;t[54]!==be||t[55]!==Ce||t[56]!==we?(Ee=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[be,Ce,we]}),t[54]=be,t[55]=Ce,t[56]=we,t[57]=Ee):Ee=t[57];let De;t[58]===N?De=t[59]:(De=Xe(`telegram`,N),t[58]=N,t[59]=De);let Oe=z>0,ke;t[60]!==a||t[61]!==De||t[62]!==Oe||t[63]!==B?(ke=(0,$.jsx)(bt,{ch:a,usesPairing:De,tokenReady:B,pairingComplete:Oe}),t[60]=a,t[61]=De,t[62]=Oe,t[63]=B,t[64]=ke):ke=t[64];let Ae;t[65]===u?Ae=t[66]:(Ae=e=>u({dmPolicy:e}),t[65]=u,t[66]=Ae);let je;t[67]!==a.dmPolicy||t[68]!==g||t[69]!==Ae||t[70]!==N.dmPolicy?(je=(0,$.jsx)(se,{label:a.dmPolicy,value:N.dmPolicy,onChange:Ae,options:g}),t[67]=a.dmPolicy,t[68]=g,t[69]=Ae,t[70]=N.dmPolicy,t[71]=je):je=t[71];let Me;t[72]!==a||t[73]!==E||t[74]!==n||t[75]!==re||t[76]!==N||t[77]!==H?(Me=(0,$.jsx)(lt,{channel:`telegram`,accountIds:H,channelConfig:N,active:n,ch:a,language:E,onPairedChange:re}),t[72]=a,t[73]=E,t[74]=n,t[75]=re,t[76]=N,t[77]=H,t[78]=Me):Me=t[78];let Ne;t[79]===a.allowFromDm?Ne=t[80]:(Ne=(0,$.jsx)(Y,{children:a.allowFromDm}),t[79]=a.allowFromDm,t[80]=Ne);let Pe;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=O(J(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[81]=Pe):Pe=t[81];let Fe;t[82]===N.allowFrom?Fe=t[83]:(Fe=ae(N.allowFrom),t[82]=N.allowFrom,t[83]=Fe);let Ie;t[84]===u?Ie=t[85]:(Ie=e=>u({allowFrom:oe(e.target.value)}),t[84]=u,t[85]=Ie);let Le;t[86]!==Fe||t[87]!==Ie?(Le=(0,$.jsx)(`textarea`,{className:Pe,rows:2,placeholder:`123456789, 987654321`,value:Fe,onChange:Ie}),t[86]=Fe,t[87]=Ie,t[88]=Le):Le=t[88];let Re;t[89]===a.allowFromDmDesc?Re=t[90]:(Re=(0,$.jsx)(ce,{children:a.allowFromDmDesc}),t[89]=a.allowFromDmDesc,t[90]=Re);let Be;t[91]!==Ne||t[92]!==Le||t[93]!==Re?(Be=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Ne,Le,Re]}),t[91]=Ne,t[92]=Le,t[93]=Re,t[94]=Be):Be=t[94];let Ve;t[95]===N?Ve=t[96]:(Ve=Te(N),t[95]=N,t[96]=Ve);let He;t[97]===b?.items?He=t[98]:(He=b?.items??[],t[97]=b?.items,t[98]=He);let We;t[99]===d?We=t[100]:(We=(e,t)=>d(`telegram`,e,t),t[99]=d,t[100]=We);let Ge;t[101]!==a||t[102]!==o.channelAgentRoutes.telegram||t[103]!==o.defaultAgentId||t[104]!==x||t[105]!==Ve||t[106]!==He||t[107]!==We?(Ge=(0,$.jsx)(Ue,{accountIds:Ve,routes:o.channelAgentRoutes.telegram,defaultAgentId:o.defaultAgentId,agentItems:He,disabled:x,onChange:We,ch:a}),t[101]=a,t[102]=o.channelAgentRoutes.telegram,t[103]=o.defaultAgentId,t[104]=x,t[105]=Ve,t[106]=He,t[107]=We,t[108]=Ge):Ge=t[108];let Ke;t[109]===l?Ke=t[110]:(Ke=()=>l(wt),t[109]=l,t[110]=Ke);let qe=c&&`rotate-180`,Je;t[111]===qe?Je=t[112]:(Je=O(`mr-1 size-4 transition-transform`,qe),t[111]=qe,t[112]=Je);let Ye;t[113]===Je?Ye=t[114]:(Ye=(0,$.jsx)(ne,{className:Je}),t[113]=Je,t[114]=Ye);let Ze=c?a.advancedHide:a.advancedShow,Qe;t[115]!==Ke||t[116]!==Ye||t[117]!==Ze?(Qe=(0,$.jsxs)(T,{type:`button`,variant:`ghost`,className:`-ml-2 h-auto justify-start px-2 py-1 text-sm text-fg-muted hover:text-fg`,onClick:Ke,children:[Ye,Ze]}),t[115]=Ke,t[116]=Ye,t[117]=Ze,t[118]=Qe):Qe=t[118];let $e;t[119]!==a||t[120]!==_||t[121]!==h||t[122]!==v||t[123]!==p||t[124]!==y||t[125]!==N||t[126]!==f||t[127]!==m||t[128]!==c||t[129]!==u?($e=c?(0,$.jsx)(St,{tg:N,updateTelegram:u,ch:a,groupOpts:_,replyOpts:v,streamOpts:y,tgAccountsDraft:f,setTgAccountsDraft:p,tgAccountsError:m,onTgAccountsBlur:h}):null,t[119]=a,t[120]=_,t[121]=h,t[122]=v,t[123]=p,t[124]=y,t[125]=N,t[126]=f,t[127]=m,t[128]=c,t[129]=u,t[130]=$e):$e=t[130];let et;t[131]!==Ee||t[132]!==ke||t[133]!==je||t[134]!==Me||t[135]!==Be||t[136]!==Ge||t[137]!==Qe||t[138]!==$e?(et=(0,$.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[Ee,ke,je,Me,Be,Ge,Qe,$e]}),t[131]=Ee,t[132]=ke,t[133]=je,t[134]=Me,t[135]=Be,t[136]=Ge,t[137]=Qe,t[138]=$e,t[139]=et):et=t[139];let tt;return t[140]!==a.modalCancel||t[141]!==a.telegramSubtitle||t[142]!==a.telegramTitle||t[143]!==r||t[144]!==n||t[145]!==A||t[146]!==de||t[147]!==me||t[148]!==ve||t[149]!==et?(tt=(0,$.jsxs)(ze,{presentation:A,open:n,onOpenChange:r,title:G,description:K,srTitle:q,srDescription:le,closeAriaLabel:ue,wide:!0,headerExtra:de,footer:me,children:[ve,et]}),t[140]=a.modalCancel,t[141]=a.telegramSubtitle,t[142]=a.telegramTitle,t[143]=r,t[144]=n,t[145]=A,t[146]=de,t[147]=me,t[148]=ve,t[149]=et,t[150]=tt):tt=t[150],tt}function wt(e){return!e}function Tt(){return it(`telegram`)}var Et=[{id:`telegram`,titleKey:`telegramTitle`,subtitleKey:`telegramSubtitle`},{id:`weixin`,titleKey:`weixinTitle`,subtitleKey:`weixinSubtitle`},{id:`feishu`,titleKey:`feishuTitle`,subtitleKey:`feishuSubtitle`}];function Dt(){return o(`/api/channels/meta`)}async function Ot(){return(await v(Dt())).payload?.channels??[]}var kt=new Map(Et.map(e=>[e.id,e])),At=new Map(Et.map((e,t)=>[e.id,t]));function jt(e,t){return{title:t[e.titleKey],subtitle:t[e.subtitleKey]}}function Mt(e,t){let n=new Map;for(let r of e??[]){let e=kt.get(r.id),i=e?jt(e,t):{title:r.label,subtitle:r.description||t.hubExtensionSubtitle};n.set(r.id,{id:r.id,title:i.title,subtitle:i.subtitle,manageable:r.manageable,order:r.order})}if(n.size===0)return Et.map((e,n)=>{let r=jt(e,t);return{id:e.id,title:r.title,subtitle:r.subtitle,manageable:!0,order:n}});for(let e of Et){if(n.has(e.id))continue;let r=jt(e,t);n.set(e.id,{id:e.id,title:r.title,subtitle:r.subtitle,manageable:!0,order:At.get(e.id)??0})}return Array.from(n.values()).sort((e,t)=>e.order===t.order?e.id.localeCompare(t.id):e.order-t.order)}function Nt(e,t){let n=(0,Q.c)(11),r;n[0]===e?r=n[1]:(r=e?Dt():null,n[0]=e,n[1]=r);let i;n[2]===Symbol.for(`react.memo_cache_sentinel`)?(i={revalidateOnFocus:!1},n[2]=i):i=n[2];let{data:a,error:o,isLoading:c,mutate:l}=s(r,Ot,i),u;n[3]!==t||n[4]!==a?(u=Mt(a,t),n[3]=t,n[4]=a,n[5]=u):u=n[5];let d=u,f;return n[6]!==d||n[7]!==o||n[8]!==c||n[9]!==l?(f={entries:d,isLoading:c,error:o,mutate:l},n[6]=d,n[7]=o,n[8]=c,n[9]=l,n[10]=f):f=n[10],f}function Pt(e,t){return e.find(e=>e.name===t)?.connected??!1}function Ft(e,t){return e.find(e=>e.name===t)?.enabled??!1}function It(e,t){let n=e&&typeof e==`object`?e.channels:void 0,r=n&&typeof n==`object`&&!Array.isArray(n)?n[t]:void 0;return!r||typeof r!=`object`?!1:Object.keys(r).length>0}function Lt(e,t,n){return e?t?n?`running`:`offline`:`disabled`:`not_configured`}function Rt(e,t,n){return n?e===`not_configured`?`setup`:t>0?`pairing`:e===`offline`?`fix`:`manage`:`manage`}function zt(e,t){return e.policy.dm[t]}function Bt(e,t){return e.hubSummaryAccountCount.replace(`{{count}}`,String(t))}function Vt(e,t){let n=t.telegram,r=[e.hubSummaryDm.replace(`{{policy}}`,zt(e,n.dmPolicy))],i=Te(n).length;return i>0&&r.push(Bt(e,i)),r}function Ht(e,t){let n=t.weixin,r=[e.hubSummaryDm.replace(`{{policy}}`,zt(e,n.dmPolicy))];r.push(e.hubSummaryStream.replace(`{{mode}}`,e.policy.stream[n.streamMode]));let i=Ee(n).length;return i>0&&r.push(Bt(e,i)),r}function Ut(e,t){let n=t.feishu,r=n.connectionMode===`webhook`?e.hubConnectionWebhook:e.hubConnectionWebsocket,i=[e.hubSummaryConnection.replace(`{{mode}}`,r)],a=le(n).length;return a>0&&i.push(Bt(e,a)),i}function Wt(e,t){return t[e]}function Gt(e){let{id:t,form:n,connected:r,pairingSummary:i,ch:a}=e,o=n.telegram,s=n.weixin,c=n.feishu,l=t===`telegram`?K(o):t===`weixin`?G(s):q(c),u=t===`telegram`?o.enabled:t===`weixin`?s.enabled:c.enabled,d=Ze({configured:l,channelEnabled:u,usesPairing:Xe(t,t===`telegram`?o:t===`weixin`?s:c),summaryPending:Wt(t,i).pending}),f=Lt(l,u,r);return{id:t,manageable:!0,configured:l,enabled:u,connected:r,status:f,summaryLines:l?t===`telegram`?Vt(a,n):t===`weixin`?Ht(a,n):Ut(a,n):[],pendingPairing:d,primaryAction:Rt(f,d,!0)}}function Kt(e){let{id:t,config:n,statuses:r,ch:i}=e,a=It(n,t),o=Ft(r,t),s=Pt(r,t);return{id:t,manageable:!1,configured:a,enabled:o,connected:s,status:Lt(a,o,s),summaryLines:a?[i.hubExtensionConfiguredHint]:[],pendingPairing:0,primaryAction:`manage`}}function qt(e){return M(e.id)?Gt({id:e.id,form:e.form,connected:Pt(e.statuses,e.id),pairingSummary:e.pairingSummary,ch:e.ch}):Kt({id:e.id,config:e.config,statuses:e.statuses,ch:e.ch})}function Jt(e){return e.catalogIds.map(t=>qt({id:t,form:e.form,config:e.config,statuses:e.statuses,pairingSummary:e.pairingSummary,ch:e.ch}))}var Yt=`channels-status`;function Xt(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function Zt(e){let t=t=>e(t.detail);return window.addEventListener(Yt,t),()=>window.removeEventListener(Yt,t)}function Qt(e,t){let n=(0,Q.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return Zt(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,Z.useEffect)(i,a)}var $t={telegram:{pending:0,stale:0,atCapacity:!1},feishu:{pending:0,stale:0,atCapacity:!1},weixin:{pending:0,stale:0,atCapacity:!1}};function en(e){let t=(0,Q.c)(8),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={revalidateOnFocus:!0},t[0]=n):n=t[0];let{data:r,mutate:i,isLoading:a,error:o}=s(e?et:null,_e,n),c;t[1]===i?c=t[2]:(c=()=>{i()},t[1]=i,t[2]=c);let l=c;nt(l,e);let u=r??$t,d;return t[3]!==o||t[4]!==a||t[5]!==l||t[6]!==u?(d={summary:u,isLoading:a,error:o,refresh:l},t[3]=o,t[4]=a,t[5]=l,t[6]=u,t[7]=d):d=t[7],d}var tn=3e4;function nn(e){let t=(0,Q.c)(25),{hasToken:n,form:r,ch:i}=e,{data:a,mutate:o}=I(n),{entries:c,mutate:l}=Nt(n,i),u;t[0]===n?u=t[1]:(u=n?Ce():null,t[0]=n,t[1]=u);let d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d={revalidateOnFocus:!0,refreshInterval:tn},t[2]=d):d=t[2];let{data:f,mutate:p}=s(u,ye,d),m;t[3]===f?m=t[4]:(m=f===void 0?[]:f,t[3]=f,t[4]=m);let h=m,g;t[5]===p?g=t[6]:(g=e=>{let t=Xt(e);if(t){p(t,{revalidate:!1});return}p()},t[5]=p,t[6]=g),Qt(g,n);let{summary:_,refresh:v}=en(n),y;t[7]===c?y=t[8]:(y=c.map(rn),t[7]=c,t[8]=y);let b=y,x=a?.payload?.config,S;bb0:{if(!r||b.length===0){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[9]=e):e=t[9],S=e;break bb0}let e;t[10]!==b||t[11]!==i||t[12]!==x||t[13]!==r||t[14]!==_||t[15]!==h?(e=Jt({catalogIds:b,form:r,config:x,statuses:h,pairingSummary:_,ch:i}),t[10]=b,t[11]=i,t[12]=x,t[13]=r,t[14]=_,t[15]=h,t[16]=e):e=t[16],S=e}let C=S,w;t[17]!==l||t[18]!==o||t[19]!==p||t[20]!==v?(w=()=>{p(),l(),o(),v()},t[17]=l,t[18]=o,t[19]=p,t[20]=v,t[21]=w):w=t[21];let T=w,E;return t[22]!==C||t[23]!==T?(E={cards:C,refreshAll:T},t[22]=C,t[23]=T,t[24]=E):E=t[24],E}function rn(e){return e.id}var an={form:null,baseline:null,tgAccountsDraft:``,tgAccountsError:``,wxAccountsDraft:``,wxAccountsError:``,feishuAccountsDraft:``,feishuAccountsError:``};function on(e){return{tgAccountsDraft:JSON.stringify(e.telegram.accounts??{},null,2),tgAccountsError:``,wxAccountsDraft:JSON.stringify(e.weixin.accounts??{},null,2),wxAccountsError:``,feishuAccountsDraft:JSON.stringify(e.feishu?.accounts??{},null,2),feishuAccountsError:``}}function sn(e,t){switch(t.type){case`reset`:return an;case`load`:{let e=structuredClone(t.payload);return{form:e,baseline:structuredClone(e),...on(e)}}case`commitSaved`:{let e=structuredClone(t.payload);return{form:e,baseline:structuredClone(e),...on(e)}}case`discard`:{if(!e.baseline)return e;let t=structuredClone(e.baseline);return{form:t,baseline:e.baseline,...on(t)}}case`updateTelegram`:return e.form?{...e,form:{...e.form,telegram:{...e.form.telegram,...t.patch}}}:e;case`updateWeixin`:return e.form?{...e,form:{...e.form,weixin:{...e.form.weixin,...t.patch}}}:e;case`updateFeishu`:return e.form?{...e,form:{...e.form,feishu:{...e.form.feishu,...t.patch}}}:e;case`updateChannelAgentRoute`:{if(!e.form)return e;let n=t.channel===`telegram`?`telegram`:t.channel===`weixin`?`weixin`:`feishu`;return{...e,form:{...e.form,channelAgentRoutes:{...e.form.channelAgentRoutes,[n]:{...e.form.channelAgentRoutes[n],[t.accountId]:t.agentId.trim().toLowerCase()}}}}}case`setTgAccountsDraft`:return{...e,tgAccountsDraft:t.value};case`setWxAccountsDraft`:return{...e,wxAccountsDraft:t.value};case`setFeishuAccountsDraft`:return{...e,feishuAccountsDraft:t.value};case`setTgAccountsError`:return{...e,tgAccountsError:t.value};case`setWxAccountsError`:return{...e,wxAccountsError:t.value};case`setFeishuAccountsError`:return{...e,feishuAccountsError:t.value};case`applyTgAccounts`:return e.form?{...e,form:{...e.form,telegram:{...e.form.telegram,accounts:t.accounts}},tgAccountsError:``}:e;case`applyWxAccounts`:return e.form?{...e,form:{...e.form,weixin:{...e.form.weixin,accounts:t.accounts}},wxAccountsError:``}:e;case`applyFeishuAccounts`:return e.form?{...e,form:{...e.form,feishu:{...e.form.feishu,accounts:t.accounts}},feishuAccountsError:``}:e;case`restoreForm`:return{...e,form:structuredClone(t.payload)}}}function cn(){let e=i(e=>e.language),t=a(e),n=t.channelsSettings,r=!!_(e=>e.token),o=(0,Z.useRef)(!1),[c,l]=(0,Z.useReducer)(sn,an),[u,d]=(0,Z.useState)({hasToken:r,parsed:null}),[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(null),[g,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(!1),[D,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(!1),[N,P]=(0,Z.useState)(!1),[F,L]=(0,Z.useState)(!1),[ee,R]=(0,Z.useState)(!1),{data:te}=s(r?`gateway-chat-agents-ch`:null,x,{revalidateOnFocus:!1}),{data:z,error:ne,isLoading:re,mutate:B}=I(r),V=(0,Z.useMemo)(()=>z?.payload?.config===void 0?null:ve(z.payload.config),[z]);(r!==u.hasToken||V!==u.parsed)&&(d({hasToken:r,parsed:V}),r?V!==null&&!o.current&&(l({type:`load`,payload:V}),v(!1)):(o.current=!1,l({type:`reset`}),v(!1)));let{form:H,baseline:U,tgAccountsDraft:W,tgAccountsError:G,wxAccountsDraft:K,wxAccountsError:ae,feishuAccountsDraft:q,feishuAccountsError:oe}=c,J=(0,Z.useMemo)(()=>!H||!U?!1:JSON.stringify(H)!==JSON.stringify(U),[H,U]),Y=!!(r&&re&&z===void 0&&!ne),se=ne instanceof Error?ne.message:ne?String(ne):null,ce=(0,Z.useCallback)((e,t,n)=>{o.current=!0,l({type:`updateChannelAgentRoute`,channel:e,accountId:t,agentId:n})},[]),le=(0,Z.useCallback)(e=>{o.current=!0,l({type:`updateTelegram`,patch:e})},[]),ue=(0,Z.useCallback)(e=>{o.current=!0,l({type:`updateWeixin`,patch:e})},[]),de=(0,Z.useCallback)(e=>{o.current=!0,l({type:`updateFeishu`,patch:e})},[]),fe=(0,Z.useCallback)(async()=>{if(!H||f)return!1;p(!0),h(null),v(!1);try{let e=await he(H);return o.current=!1,l({type:`commitSaved`,payload:e}),v(!0),window.setTimeout(()=>v(!1),2500),!0}catch(e){return h(e instanceof Error?e.message:n.saveError),!1}finally{p(!1)}},[H,f,n.saveError]),pe=(0,Z.useCallback)(()=>{U&&(o.current=!1,l({type:`discard`}),h(null),v(!1))},[U]),me=(0,Z.useCallback)(async(e,t)=>{if(!H||f)return;let r=H,i=e===`weixin`?{...H,weixin:{...H.weixin,enabled:t}}:e===`telegram`?{...H,telegram:{...H.telegram,enabled:t}}:{...H,feishu:{...H.feishu,enabled:t}};o.current=!0,l(e===`weixin`?{type:`updateWeixin`,patch:{enabled:t}}:e===`telegram`?{type:`updateTelegram`,patch:{enabled:t}}:{type:`updateFeishu`,patch:{enabled:t}}),p(!0),h(null);try{let e=await he(i);o.current=!1,l({type:`commitSaved`,payload:e})}catch(e){h(e instanceof Error?e.message:n.saveError),o.current=!0,l({type:`restoreForm`,payload:r})}finally{p(!1)}},[H,f,n.saveError]),ge=(0,Z.useCallback)(async()=>{let e=H?ie(H.telegram):``;e&&await S(e)&&(P(!0),window.setTimeout(()=>P(!1),2e3))},[H]),_e=(0,Z.useCallback)(e=>{de({appId:e.appId,domain:e.domain,enabled:!0}),B(),w(n.feishuQrSetupSuccess),window.setTimeout(()=>w(null),4e3)},[de,B,n.feishuQrSetupSuccess]),ye=(0,Z.useCallback)(async()=>{let e=H?.feishu?.appSecret;e&&await S(e)&&(L(!0),window.setTimeout(()=>L(!1),2e3))},[H]),be=(0,Z.useCallback)(async()=>{let e=H?.feishu;if(!e)return;let t={connectionMode:e.connectionMode,verificationToken:e.verificationToken||``,encryptKey:e.encryptKey||``,webhookHost:e.webhookHost||``,webhookPort:e.webhookPort||0,webhookPath:e.webhookPath||``};await S(JSON.stringify(t,null,2))&&(R(!0),window.setTimeout(()=>R(!1),2e3))},[H]);return{language:e,m:t,ch:n,hasToken:r,loading:Y,fetchError:se,mutate:B,form:H,baseline:U,dirty:J,saving:f,error:m,saveOk:g,weixinSuccessBanner:y,setWeixinSuccessBanner:b,feishuSetupSuccessBanner:C,tgAdvanced:T,setTgAdvanced:E,showToken:D,setShowToken:O,showFeishuSecret:k,setShowFeishuSecret:A,showFeishuWebhookSecrets:j,setShowFeishuWebhookSecrets:M,copied:N,feishuCopied:F,feishuWebhookCopied:ee,tgAccountsDraft:W,setTgAccountsDraft:(0,Z.useCallback)(e=>{l({type:`setTgAccountsDraft`,value:e})},[]),tgAccountsError:G,wxAccountsDraft:K,setWxAccountsDraft:(0,Z.useCallback)(e=>{l({type:`setWxAccountsDraft`,value:e})},[]),wxAccountsError:ae,feishuAccountsDraft:q,setFeishuAccountsDraft:(0,Z.useCallback)(e=>{l({type:`setFeishuAccountsDraft`,value:e})},[]),feishuAccountsError:oe,chatAgents:te,updateChannelAgentRoute:ce,updateTelegram:le,updateWeixin:ue,updateFeishu:de,save:fe,discard:pe,toggleChannelEnabled:me,copyToken:ge,handleFeishuQrSetupSuccess:_e,copyFeishuSecret:ye,copyFeishuWebhookConfig:be,onTgAccountsBlur:(0,Z.useCallback)(()=>{if(!H)return;let e=W.trim();if(!e){o.current=!0,l({type:`applyTgAccounts`,accounts:{}});return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);o.current=!0,l({type:`applyTgAccounts`,accounts:t})}catch(e){l({type:`setTgAccountsError`,value:e instanceof Error?e.message:n.jsonInvalid})}},[H,W,n.jsonObjectAccounts,n.jsonInvalid]),onWxAccountsBlur:(0,Z.useCallback)(()=>{if(!H)return;let e=K.trim();if(!e){o.current=!0,l({type:`applyWxAccounts`,accounts:{}});return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);o.current=!0,l({type:`applyWxAccounts`,accounts:t})}catch(e){l({type:`setWxAccountsError`,value:e instanceof Error?e.message:n.jsonInvalid})}},[H,K,n.jsonObjectAccounts,n.jsonInvalid]),onFeishuAccountsBlur:(0,Z.useCallback)(()=>{if(!H)return;let e=q.trim();if(!e){o.current=!0,l({type:`applyFeishuAccounts`,accounts:{}});return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);o.current=!0,l({type:`applyFeishuAccounts`,accounts:t})}catch(e){l({type:`setFeishuAccountsError`,value:e instanceof Error?e.message:n.jsonInvalid})}},[H,q,n.jsonObjectAccounts,n.jsonInvalid]),dmOpts:(0,Z.useMemo)(()=>[`pairing`,`allowlist`,`open`,`disabled`].map(e=>({value:e,label:n.policy.dm[e]})),[n.policy.dm]),groupOpts:(0,Z.useMemo)(()=>[`open`,`disabled`,`allowlist`].map(e=>({value:e,label:n.policy.group[e]})),[n.policy.group]),replyOpts:(0,Z.useMemo)(()=>[`off`,`first`,`all`].map(e=>({value:e,label:n.policy.reply[e]})),[n.policy.reply]),streamOpts:(0,Z.useMemo)(()=>[`off`,`partial`,`block`].map(e=>({value:e,label:n.policy.stream[e]})),[n.policy.stream])}}var ln={width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}},un={sessionKey:null,qrcodeUrl:null};function dn({ch:e,onLoginSuccess:t,onOpenChange:n,closeOnLoginSuccess:r,moreSettings:i}){let[a,o]=(0,Z.useState)(0),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(null),d=(0,Z.useRef)(t),f=(0,Z.useRef)(n);d.current=t,f.current=n;let p=R(()=>pe().then(e=>({sessionKey:e.sessionKey,qrcodeUrl:e.qrcodeUrl})),[a],{initial:un,errorData:un}),m=p.data.sessionKey,h=p.data.qrcodeUrl,g=p.loading,_=p.error instanceof Error?p.error.message:p.error?String(p.error):null,v=l??_,y=(0,Z.useCallback)(()=>{u(null),c(null),o(e=>e+1)},[]);(0,Z.useEffect)(()=>{if(!m)return;let t=!1,n,i=async()=>{try{let i=await xe(m);if(t)return;if(i.phase===`polling`){p.setData(e=>({...e,qrcodeUrl:i.qrcodeUrl})),c(i.qrStatus===`scaned`?e.weixinQrLoginScanned:null);return}if(i.phase===`done`){n!==void 0&&(window.clearInterval(n),n=void 0),p.setData(un),i.ok?(r&&f.current(!1),await d.current()):u(i.message);return}i.phase===`unknown`&&c(null)}catch(e){t||(n!==void 0&&window.clearInterval(n),u(e instanceof Error?e.message:`Request failed`),p.setData(un))}};return n=window.setInterval(()=>void i(),2e3),i(),()=>{t=!0,n!==void 0&&window.clearInterval(n)}},[m,e.weixinQrLoginScanned,r,p.setData]);let b=R(()=>mt.toDataURL(h,ln),[h],{enabled:!!h,initial:null,errorData:null}),x=b.data,S=b.error!==null&&!b.loading,C=!!(h&&m),w=!v&&!C;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`text-center`,children:[(0,$.jsx)(`p`,{className:`text-base font-semibold tracking-tight text-fg`,children:e.weixinQrModalTitle}),(0,$.jsx)(`p`,{className:`mt-1.5 text-sm text-fg-muted`,children:e.weixinQrModalSubtitle})]}),(0,$.jsxs)(`div`,{className:`mt-6 flex min-h-[17.5rem] flex-col items-center justify-center gap-3`,children:[v?(0,$.jsx)(`p`,{className:`text-center text-sm text-red-600 dark:text-red-400`,children:v}):null,!v&&(C||w)?(0,$.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,$.jsx)(`p`,{className:O(`min-h-[1.25rem] text-center text-sm`,s&&!w?`text-accent`:`text-fg-muted`),children:w?e.weixinQrLoginBusy:s??`\xA0`}),(0,$.jsxs)(`div`,{className:O(`relative flex size-52 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-edge-subtle bg-white p-3 dark:border-edge`,w&&`bg-surface-muted/40 dark:bg-surface-base`),children:[w?(0,$.jsx)(`div`,{className:`absolute inset-3 animate-pulse rounded-md bg-surface-muted dark:bg-surface-hover`,"aria-hidden":!0}):null,C&&h&&!v&&x&&!S?(0,$.jsx)(`img`,{src:x,alt:``,className:`relative z-[1] size-full object-contain`}):null,C&&h&&!v&&!x&&!S&&!w?(0,$.jsx)(`p`,{className:`relative z-[1] px-2 text-center text-sm text-fg-muted`,children:e.weixinQrEncoding}):null,C&&h&&!v&&S?(0,$.jsxs)(`div`,{className:`relative z-[1] flex size-full flex-col items-center justify-center gap-2 px-1`,children:[(0,$.jsx)(`p`,{className:`text-center text-xs text-fg-muted`,children:e.weixinQrImageError}),(0,$.jsxs)(`a`,{href:h,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent underline-offset-2 hover:underline`,children:[(0,$.jsx)(V,{className:`size-3 shrink-0`}),e.weixinQrOpenLink]})]}):null]})]}):null]}),(0,$.jsx)(`div`,{className:`mt-6`,children:(0,$.jsx)(T,{type:`button`,variant:`secondary`,className:`h-11 w-full rounded-full border-0 bg-fg text-surface-panel hover:opacity-90 dark:bg-fg dark:text-surface-panel`,disabled:g,onClick:y,children:g?e.weixinQrLoginBusy:e.weixinQrRegenerate})}),i?(0,$.jsx)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:i}):null]})}function fn(e){let t=(0,Q.c)(26),{open:n,onOpenChange:r,ch:i,onLoginSuccess:a,moreSettings:o,settingsDirty:s,settingsSaving:c,onSettingsDiscard:l,onSettingsSave:u,presentation:d,closeOnLoginSuccess:f}=e,p=s===void 0?!1:s,m=c===void 0?!1:c,h=d===void 0?`modal`:d,g=f===void 0?!0:f,_;t[0]!==i||t[1]!==o||t[2]!==r||t[3]!==l||t[4]!==u||t[5]!==p||t[6]!==m?(_=o&&l&&u?(0,$.jsx)(ht,{ch:i,dirty:p,saving:m,showCancel:!1,onCancel:()=>r(!1),onDiscard:l,onSave:u}):void 0,t[0]=i,t[1]=o,t[2]=r,t[3]=l,t[4]=u,t[5]=p,t[6]=m,t[7]=_):_=t[7];let v;t[8]!==i||t[9]!==g||t[10]!==o||t[11]!==a||t[12]!==r||t[13]!==n?(v=n?(0,$.jsx)(dn,{ch:i,onLoginSuccess:a,onOpenChange:r,closeOnLoginSuccess:g,moreSettings:o},`active`):null,t[8]=i,t[9]=g,t[10]=o,t[11]=a,t[12]=r,t[13]=n,t[14]=v):v=t[14];let y;return t[15]!==i.weixinQrModalCloseAria||t[16]!==i.weixinQrModalSubtitle||t[17]!==i.weixinQrModalTitle||t[18]!==i.weixinSubtitle||t[19]!==i.weixinTitle||t[20]!==r||t[21]!==n||t[22]!==h||t[23]!==_||t[24]!==v?(y=(0,$.jsx)(ze,{presentation:h,open:n,onOpenChange:r,title:i.weixinTitle,description:i.weixinSubtitle,srTitle:i.weixinQrModalTitle,srDescription:i.weixinQrModalSubtitle,closeAriaLabel:i.weixinQrModalCloseAria,wide:!0,footer:_,children:v}),t[15]=i.weixinQrModalCloseAria,t[16]=i.weixinQrModalSubtitle,t[17]=i.weixinQrModalTitle,t[18]=i.weixinSubtitle,t[19]=i.weixinTitle,t[20]=r,t[21]=n,t[22]=h,t[23]=_,t[24]=v,t[25]=y):y=t[25],y}function pn(e){let t=(0,Q.c)(108),{wx:n,updateWeixin:r,ch:i,streamOpts:a,wxAccountsDraft:o,setWxAccountsDraft:s,wxAccountsError:c,onWxAccountsBlur:l,channelAgentRoutesWx:u,defaultAgentId:d,agentItems:f,onAgentRouteChange:p,routingDisabled:m}=e,h;t[0]===i.weixinAllowFrom?h=t[1]:(h=(0,$.jsx)(Y,{children:i.weixinAllowFrom}),t[0]=i.weixinAllowFrom,t[1]=h);let g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g=O(J(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[2]=g):g=t[2];let _;t[3]===n.allowFrom?_=t[4]:(_=n.allowFrom.join(`, `),t[3]=n.allowFrom,t[4]=_);let v;t[5]===r?v=t[6]:(v=e=>r({allowFrom:e.target.value.split(/[,\n]/).flatMap(mn)}),t[5]=r,t[6]=v);let y;t[7]!==_||t[8]!==v?(y=(0,$.jsx)(`textarea`,{className:g,rows:2,placeholder:`wxid_..., openid_...`,value:_,onChange:v}),t[7]=_,t[8]=v,t[9]=y):y=t[9];let b;t[10]===i.weixinAllowFromDesc?b=t[11]:(b=(0,$.jsx)(ce,{children:i.weixinAllowFromDesc}),t[10]=i.weixinAllowFromDesc,t[11]=b);let x;t[12]!==h||t[13]!==y||t[14]!==b?(x=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[h,y,b]}),t[12]=h,t[13]=y,t[14]=b,t[15]=x):x=t[15];let S;t[16]===r?S=t[17]:(S=e=>r({streamMode:e}),t[16]=r,t[17]=S);let C;t[18]!==i.streamMode||t[19]!==a||t[20]!==S||t[21]!==n.streamMode?(C=(0,$.jsx)(se,{label:i.streamMode,value:n.streamMode,onChange:S,options:a}),t[18]=i.streamMode,t[19]=a,t[20]=S,t[21]=n.streamMode,t[22]=C):C=t[22];let w;t[23]===i.historyLimit?w=t[24]:(w=(0,$.jsx)(Y,{children:i.historyLimit}),t[23]=i.historyLimit,t[24]=w);let T;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(T=J(),t[25]=T):T=t[25];let E;t[26]===r?E=t[27]:(E=e=>r({historyLimit:parseInt(e.target.value,10)||50}),t[26]=r,t[27]=E);let D;t[28]!==E||t[29]!==n.historyLimit?(D=(0,$.jsx)(`input`,{type:`number`,min:10,max:200,className:T,value:n.historyLimit,onChange:E}),t[28]=E,t[29]=n.historyLimit,t[30]=D):D=t[30];let k;t[31]!==w||t[32]!==D?(k=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[w,D]}),t[31]=w,t[32]=D,t[33]=k):k=t[33];let A;t[34]===i.textChunkLimit?A=t[35]:(A=(0,$.jsx)(Y,{children:i.textChunkLimit}),t[34]=i.textChunkLimit,t[35]=A);let j;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(j=J(),t[36]=j):j=t[36];let M;t[37]===r?M=t[38]:(M=e=>r({textChunkLimit:parseInt(e.target.value,10)||4e3}),t[37]=r,t[38]=M);let N;t[39]!==M||t[40]!==n.textChunkLimit?(N=(0,$.jsx)(`input`,{type:`number`,min:1e3,max:1e4,step:100,className:j,value:n.textChunkLimit,onChange:M}),t[39]=M,t[40]=n.textChunkLimit,t[41]=N):N=t[41];let P;t[42]!==A||t[43]!==N?(P=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[A,N]}),t[42]=A,t[43]=N,t[44]=P):P=t[44];let F;t[45]!==k||t[46]!==P?(F=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[k,P]}),t[45]=k,t[46]=P,t[47]=F):F=t[47];let I;t[48]===i.weixinRouteTag?I=t[49]:(I=(0,$.jsx)(Y,{children:i.weixinRouteTag}),t[48]=i.weixinRouteTag,t[49]=I);let L;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(L=J(),t[50]=L):L=t[50];let ee;t[51]===r?ee=t[52]:(ee=e=>r({routeTag:e.target.value}),t[51]=r,t[52]=ee);let R;t[53]!==i.routeTagPlaceholder||t[54]!==ee||t[55]!==n.routeTag?(R=(0,$.jsx)(`input`,{className:L,value:n.routeTag,onChange:ee,placeholder:i.routeTagPlaceholder}),t[53]=i.routeTagPlaceholder,t[54]=ee,t[55]=n.routeTag,t[56]=R):R=t[56];let te;t[57]===i.weixinRouteTagDesc?te=t[58]:(te=(0,$.jsx)(ce,{children:i.weixinRouteTagDesc}),t[57]=i.weixinRouteTagDesc,t[58]=te);let z;t[59]!==I||t[60]!==R||t[61]!==te?(z=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[I,R,te]}),t[59]=I,t[60]=R,t[61]=te,t[62]=z):z=t[62];let ne;t[63]===r?ne=t[64]:(ne=e=>r({debug:e.target.checked}),t[63]=r,t[64]=ne);let re;t[65]!==ne||t[66]!==n.debug?(re=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:n.debug,onChange:ne}),t[65]=ne,t[66]=n.debug,t[67]=re):re=t[67];let B;t[68]!==i.weixinDebug||t[69]!==re?(B=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[re,i.weixinDebug]}),t[68]=i.weixinDebug,t[69]=re,t[70]=B):B=t[70];let V;t[71]===i.weixinDebugDesc?V=t[72]:(V=(0,$.jsx)(ce,{children:i.weixinDebugDesc}),t[71]=i.weixinDebugDesc,t[72]=V);let H;t[73]===i.weixinAccountsJson?H=t[74]:(H=(0,$.jsx)(Y,{children:i.weixinAccountsJson}),t[73]=i.weixinAccountsJson,t[74]=H);let U;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(U=O(J(),`min-h-[140px] resize-y font-mono text-xs`),t[75]=U):U=t[75];let W;t[76]===s?W=t[77]:(W=e=>s(e.target.value),t[76]=s,t[77]=W);let G;t[78]!==l||t[79]!==W||t[80]!==o?(G=(0,$.jsx)(`textarea`,{className:U,spellCheck:!1,value:o,onChange:W,onBlur:l,placeholder:`{ "personal": { "name": "...", "cdnBaseUrl": "...", "enabled": true } }`}),t[78]=l,t[79]=W,t[80]=o,t[81]=G):G=t[81];let ie;t[82]!==i.weixinAccountsJsonDesc||t[83]!==c?(ie=c?(0,$.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:c}):(0,$.jsx)(ce,{children:i.weixinAccountsJsonDesc}),t[82]=i.weixinAccountsJsonDesc,t[83]=c,t[84]=ie):ie=t[84];let K;t[85]!==H||t[86]!==G||t[87]!==ie?(K=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[H,G,ie]}),t[85]=H,t[86]=G,t[87]=ie,t[88]=K):K=t[88];let ae;t[89]===n?ae=t[90]:(ae=Ee(n),t[89]=n,t[90]=ae);let q;t[91]!==f||t[92]!==i||t[93]!==u||t[94]!==d||t[95]!==p||t[96]!==m||t[97]!==ae?(q=(0,$.jsx)(Ue,{accountIds:ae,routes:u,defaultAgentId:d,agentItems:f,disabled:m,onChange:p,ch:i}),t[91]=f,t[92]=i,t[93]=u,t[94]=d,t[95]=p,t[96]=m,t[97]=ae,t[98]=q):q=t[98];let oe;return t[99]!==F||t[100]!==z||t[101]!==B||t[102]!==V||t[103]!==K||t[104]!==q||t[105]!==x||t[106]!==C?(oe=(0,$.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle pt-4 dark:border-edge`,children:[x,C,F,z,B,V,K,q]}),t[99]=F,t[100]=z,t[101]=B,t[102]=V,t[103]=K,t[104]=q,t[105]=x,t[106]=C,t[107]=oe):oe=t[107],oe}function mn(e){let t=e.trim();return t?[t]:[]}function hn(e){let t=(0,Q.c)(60),{ch:n,wx:r,updateWeixin:i,dmOpts:a,streamOpts:o,wxAccountsDraft:s,setWxAccountsDraft:c,wxAccountsError:l,onWxAccountsBlur:u,form:d,chatAgents:f,onAgentRouteChange:p,saving:m,language:h,dialogOpen:g,pairingFocus:_}=e,v=_===void 0?!1:_,y;t[0]===r?y=t[1]:(y=Ee(r),t[0]=r,t[1]=y);let b=y,x;t[2]===b?x=t[3]:(x=b.length>0?b:[`default`],t[2]=b,t[3]=x);let S=x,C=(0,Z.useRef)(null),w,T;t[4]===v?(w=t[5],T=t[6]):(w=()=>{if(!v)return;let e=C.current;e&&(e.open=!0);let t=window.setTimeout(gn,80);return()=>window.clearTimeout(t)},T=[v],t[4]=v,t[5]=w,t[6]=T),(0,Z.useEffect)(w,T);let E;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(ne,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`}),t[7]=E):E=t[7];let D;t[8]===n.advancedShow?D=t[9]:(D=(0,$.jsx)(`summary`,{className:`cursor-pointer list-none rounded-xl px-3 py-2.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover group-open:rounded-b-none [&::-webkit-details-marker]:hidden`,children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[E,n.advancedShow]})}),t[8]=n.advancedShow,t[9]=D);let O;t[10]===n.weixinAdvancedHint?O=t[11]:(O=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:n.weixinAdvancedHint}),t[10]=n.weixinAdvancedHint,t[11]=O);let k;t[12]===i?k=t[13]:(k=e=>i({enabled:e.target.checked}),t[12]=i,t[13]=k);let A;t[14]!==k||t[15]!==r.enabled?(A=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.enabled,onChange:k}),t[14]=k,t[15]=r.enabled,t[16]=A):A=t[16];let j;t[17]===n.enableWeixinAria?j=t[18]:(j=(0,$.jsx)(`span`,{children:n.enableWeixinAria}),t[17]=n.enableWeixinAria,t[18]=j);let M;t[19]!==A||t[20]!==j?(M=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[A,j]}),t[19]=A,t[20]=j,t[21]=M):M=t[21];let N;t[22]===i?N=t[23]:(N=e=>i({dmPolicy:e}),t[22]=i,t[23]=N);let P;t[24]!==n.dmPolicy||t[25]!==a||t[26]!==N||t[27]!==r.dmPolicy?(P=(0,$.jsx)(se,{label:n.dmPolicy,value:r.dmPolicy,onChange:N,options:a}),t[24]=n.dmPolicy,t[25]=a,t[26]=N,t[27]=r.dmPolicy,t[28]=P):P=t[28];let F;t[29]!==n||t[30]!==g||t[31]!==h||t[32]!==S||t[33]!==r?(F=(0,$.jsx)(lt,{channel:`weixin`,accountIds:S,channelConfig:r,active:g,ch:n,language:h}),t[29]=n,t[30]=g,t[31]=h,t[32]=S,t[33]=r,t[34]=F):F=t[34];let I;t[35]===f?.items?I=t[36]:(I=f?.items??[],t[35]=f?.items,t[36]=I);let L;t[37]!==n||t[38]!==d.channelAgentRoutes.weixin||t[39]!==d.defaultAgentId||t[40]!==p||t[41]!==u||t[42]!==m||t[43]!==c||t[44]!==o||t[45]!==I||t[46]!==i||t[47]!==r||t[48]!==s||t[49]!==l?(L=(0,$.jsx)(`div`,{className:`[&>div]:border-0 [&>div]:pt-0`,children:(0,$.jsx)(pn,{wx:r,updateWeixin:i,ch:n,streamOpts:o,wxAccountsDraft:s,setWxAccountsDraft:c,wxAccountsError:l,onWxAccountsBlur:u,channelAgentRoutesWx:d.channelAgentRoutes.weixin,defaultAgentId:d.defaultAgentId,agentItems:I,onAgentRouteChange:p,routingDisabled:m})}),t[37]=n,t[38]=d.channelAgentRoutes.weixin,t[39]=d.defaultAgentId,t[40]=p,t[41]=u,t[42]=m,t[43]=c,t[44]=o,t[45]=I,t[46]=i,t[47]=r,t[48]=s,t[49]=l,t[50]=L):L=t[50];let ee;t[51]!==M||t[52]!==P||t[53]!==F||t[54]!==L||t[55]!==O?(ee=(0,$.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle px-3 pb-3 pt-3 dark:border-edge-subtle`,children:[O,M,P,F,L]}),t[51]=M,t[52]=P,t[53]=F,t[54]=L,t[55]=O,t[56]=ee):ee=t[56];let R;return t[57]!==ee||t[58]!==D?(R=(0,$.jsxs)(`details`,{ref:C,className:`group rounded-xl border border-edge-subtle bg-surface-base open:pb-3 dark:border-edge`,children:[D,ee]}),t[57]=ee,t[58]=D,t[59]=R):R=t[59],R}function gn(){return it(`weixin`)}function _n(){let e=D(),{channelId:t}=j(),[n]=B(),{language:r,m:i,ch:a,hasToken:o,loading:s,fetchError:c,mutate:l,form:u,baseline:d,dirty:f,saving:p,error:m,saveOk:h,weixinSuccessBanner:g,setWeixinSuccessBanner:_,feishuSetupSuccessBanner:v,tgAdvanced:y,setTgAdvanced:b,showToken:x,setShowToken:S,showFeishuSecret:C,setShowFeishuSecret:w,showFeishuWebhookSecrets:O,setShowFeishuWebhookSecrets:A,copied:N,feishuCopied:F,feishuWebhookCopied:I,tgAccountsDraft:L,setTgAccountsDraft:ee,tgAccountsError:R,wxAccountsDraft:z,setWxAccountsDraft:ne,wxAccountsError:re,feishuAccountsDraft:H,setFeishuAccountsDraft:U,feishuAccountsError:W,chatAgents:G,updateChannelAgentRoute:ie,updateTelegram:K,updateWeixin:ae,updateFeishu:q,save:oe,discard:J,toggleChannelEnabled:Y,copyToken:se,handleFeishuQrSetupSuccess:ce,copyFeishuSecret:le,copyFeishuWebhookConfig:ue,onTgAccountsBlur:de,onWxAccountsBlur:fe,onFeishuAccountsBlur:pe,dmOpts:me,groupOpts:he,replyOpts:ge,streamOpts:_e}=cn(),[ve,ye]=(0,Z.useState)(!1),{entries:be}=Nt(o,a),xe=(0,Z.useMemo)(()=>new Map(be.map(e=>[e.id,e])),[be]),X=P(t),Se=n.get(`pairing`)===`1`,Ce=!!(X&&xe.has(X)),{cards:we,refreshAll:Te}=nn({hasToken:o,form:u,ch:a}),Ee=X?xe.get(X):void 0,Q=X?we.find(e=>e.id===X):void 0;(0,Z.useEffect)(()=>{!X||be.length===0||xe.has(X)||e(E,{replace:!0})},[X,xe,be.length,e]);let De=(0,Z.useCallback)((t,n)=>{e(k(t,{pairing:n?.scrollToPairing}))},[e]),Oe=(0,Z.useCallback)(()=>{e(E)},[e]),ke=(0,Z.useCallback)(e=>{e||Oe()},[Oe]),Ae=(0,Z.useCallback)(async()=>{await l(),_(a.weixinQrLoginSuccess),window.setTimeout(()=>_(null),4e3)},[a.weixinQrLoginSuccess,l,_]),je=(0,Z.useCallback)(async()=>{ye(!0);try{Te(),await l()}finally{ye(!1)}},[l,Te]);if(!o)return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(vn,{hasToken:o,ch:a,refreshing:ve,saveOk:h,onRefresh:je}),(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:i.settingsSections.channels}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.needToken})]})]});if(s)return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(vn,{hasToken:o,ch:a,refreshing:ve,saveOk:h,onRefresh:je}),(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`h-7 w-40 animate-pulse rounded-md bg-surface-hover motion-reduce:animate-none dark:bg-surface-active/50`}),(0,$.jsx)(`div`,{className:`h-4 w-full max-w-md animate-pulse rounded-md bg-surface-hover motion-reduce:animate-none dark:bg-surface-active/50`})]}),(0,$.jsx)(Ie,{}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.loading})]})]});if(!u)return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(vn,{hasToken:o,ch:a,refreshing:ve,saveOk:h,onRefresh:je}),(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:m??c??a.loadError}),(0,$.jsx)(T,{type:`button`,variant:`secondary`,onClick:()=>void l(),children:a.retry})]})]});let Ne=u.weixin,Pe=Se&&X===`weixin`,Fe=Se&&X===`feishu`,Le=(0,$.jsx)(hn,{ch:a,wx:Ne,updateWeixin:ae,dmOpts:me,streamOpts:_e,wxAccountsDraft:z,setWxAccountsDraft:ne,wxAccountsError:re,onWxAccountsBlur:fe,form:u,chatAgents:G,onAgentRouteChange:(e,t)=>ie(`weixin`,e,t),saving:p,language:r,dialogOpen:Ce&&X===`weixin`,pairingFocus:Pe}),Re=(0,$.jsx)(ut,{ch:a,form:u,baseline:d,showFeishuSecret:C,setShowFeishuSecret:w,showFeishuWebhookSecrets:O,setShowFeishuWebhookSecrets:A,feishuCopied:F,feishuWebhookCopied:I,copyFeishuSecret:le,copyFeishuWebhookConfig:ue,updateFeishu:q,updateChannelAgentRoute:ie,feishuAccountsDraft:H,setFeishuAccountsDraft:U,feishuAccountsError:W,onFeishuAccountsBlur:pe,dmOpts:me,groupOpts:he,chatAgents:G,saving:p,language:r,dialogOpen:Ce&&X===`feishu`,pairingFocus:Fe});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(vn,{hasToken:o,ch:a,refreshing:ve,saveOk:h,onRefresh:je}),(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[(0,$.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:i.settingsSections.channels}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.subtitle}),(0,$.jsxs)(`a`,{href:te(r,`channels`),target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[a.docsLink,(0,$.jsx)(V,{className:`size-3.5`})]})]}),m?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:m}):null,g?(0,$.jsx)(`p`,{className:`text-xs text-accent`,children:g}):null,v?(0,$.jsx)(`div`,{className:`rounded-xl border border-success/30 bg-success-soft px-4 py-3 text-sm text-success`,children:v}):null,ve?(0,$.jsx)(Ie,{count:Math.max(be.length,3)}):(0,$.jsx)(Me,{catalog:be,cards:we,ch:a,saving:p,onOpenChannel:De,onToggleChannel:(e,t)=>{M(e)&&Y(e,t)}}),X===`weixin`?(0,$.jsx)(fn,{open:Ce,onOpenChange:ke,ch:a,onLoginSuccess:Ae,moreSettings:Le,settingsDirty:f,settingsSaving:p,onSettingsDiscard:J,onSettingsSave:oe}):null,X===`telegram`?(0,$.jsx)(Ct,{open:Ce,onOpenChange:e=>{e||Oe()},ch:a,form:u,baseline:d,tgAdvanced:y,setTgAdvanced:b,showToken:x,setShowToken:S,copied:N,copyToken:se,updateTelegram:K,updateChannelAgentRoute:ie,tgAccountsDraft:L,setTgAccountsDraft:ee,tgAccountsError:R,onTgAccountsBlur:de,dmOpts:me,groupOpts:he,replyOpts:ge,streamOpts:_e,chatAgents:G,saving:p,dirty:f,save:oe,discard:J,language:r,scrollToPairingOnOpen:Se,closeOnSave:!1}):null,X===`feishu`?(0,$.jsx)(yt,{open:Ce,onOpenChange:e=>{e||Oe()},ch:a,onSetupSuccess:ce,moreSettings:Re,settingsDirty:f,settingsSaving:p,onSettingsDiscard:J,onSettingsSave:oe}):null,Ee&&Q&&!Ee.manageable?(0,$.jsx)(Ve,{open:Ce,onOpenChange:e=>{e||Oe()},entry:Ee,vm:Q,ch:a,language:r}):null]})]})}function vn(e){let t=(0,Q.c)(11),{hasToken:n,ch:r,refreshing:i,saveOk:a,onRefresh:o}=e,s=U(bn),c=U(yn),l;t[0]!==r||t[1]!==o||t[2]!==i||t[3]!==a?(l=(0,$.jsx)(He,{ch:r,refreshing:i,saveOk:a,onRefresh:o}),t[0]=r,t[1]=o,t[2]=i,t[3]=a,t[4]=l):l=t[4];let u=l,d,f;return t[5]!==u||t[6]!==c||t[7]!==n||t[8]!==s?(d=()=>n?(s({startExtra:null,main:null,end:u}),()=>c()):(c(),()=>c()),f=[u,c,n,s],t[5]=u,t[6]=c,t[7]=n,t[8]=s,t[9]=d,t[10]=f):(d=t[9],f=t[10]),(0,Z.useLayoutEffect)(d,f),null}function yn(e){return e.clearPageHeader}function bn(e){return e.setPageHeader}export{_n as ChannelsSettingsPanel};
@@ -1,2 +0,0 @@
1
- import{t as e}from"./rolldown-runtime-aKtaBQYM.js";var t=e((e=>{Object.defineProperty(e,"__esModule",{value:!0})})),n=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CronField=void 0,e.CronField=class e{#e=!1;#t=!1;#n=!1;#r=[];options={rawValue:``};static get min(){throw Error(`min must be overridden`)}static get max(){throw Error(`max must be overridden`)}static get chars(){return Object.freeze([])}static get validChars(){return/^[?,*\dH/-]+$|^.*H\(\d+-\d+\)\/\d+.*$|^.*H\(\d+-\d+\).*$|^.*H\/\d+.*$/}static get constraints(){return{min:this.min,max:this.max,chars:this.chars,validChars:this.validChars}}constructor(t,n={rawValue:``}){if(!Array.isArray(t))throw Error(`${this.constructor.name} Validation error, values is not an array`);if(!(t.length>0))throw Error(`${this.constructor.name} Validation error, values contains no values`);this.options={...n,rawValue:n.rawValue??``},this.#r=t.sort(e.sorter),this.#n=this.options.wildcard===void 0?this.#i():this.options.wildcard,this.#e=this.options.rawValue.includes(`L`)||t.includes(`L`),this.#t=this.options.rawValue.includes(`?`)||t.includes(`?`)}get min(){return this.constructor.min}get max(){return this.constructor.max}get chars(){return this.constructor.chars}get hasLastChar(){return this.#e}get hasQuestionMarkChar(){return this.#t}get isWildcard(){return this.#n}get values(){return this.#r}static sorter(e,t){let n=typeof e==`number`,r=typeof t==`number`;return n&&r?e-t:!n&&!r?e.localeCompare(t):n?-1:1}static findNearestValueInList(e,t,n=!1){if(n){for(let n=e.length-1;n>=0;n--)if(e[n]<t)return e[n];return null}for(let n=0;n<e.length;n++)if(e[n]>t)return e[n];return null}findNearestValue(e,t=!1){return this.constructor.findNearestValueInList(this.values,e,t)}serialize(){return{wildcard:this.#n,values:this.#r}}validate(){let e,t=this.chars.length>0?` or chars ${this.chars.join(``)}`:``,n=e=>t=>RegExp(`^\\d{0,2}${t}$`).test(e);if(!this.#r.every(t=>(e=t,typeof t==`number`?t>=this.min&&t<=this.max:this.chars.some(n(t)))))throw Error(`${this.constructor.name} Validation error, got value ${e} expected range ${this.min}-${this.max}${t}`);let r=this.#r.find((e,t)=>this.#r.indexOf(e)!==t);if(r)throw Error(`${this.constructor.name} Validation error, duplicate values found: ${r}`)}#i(){return this.options.rawValue.length>0?[`*`,`?`].includes(this.options.rawValue):Array.from({length:this.max-this.min+1},(e,t)=>t+this.min).every(e=>this.#r.includes(e))}}})),r=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CronDayOfMonth=void 0;var t=n(),r=1,i=31,a=Object.freeze([`L`]);e.CronDayOfMonth=class extends t.CronField{static get min(){return r}static get max(){return i}static get chars(){return a}static get validChars(){return/^[?,*\dLH/-]+$|^.*H\(\d+-\d+\)\/\d+.*$|^.*H\(\d+-\d+\).*$|^.*H\/\d+.*$/}constructor(e,t){super(e,t),this.validate()}get values(){return super.values}}})),i=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CronDayOfWeek=void 0;var t=n(),r=0,i=7,a=Object.freeze([`L`]);e.CronDayOfWeek=class extends t.CronField{static get min(){return r}static get max(){return i}static get chars(){return a}static get validChars(){return/^[?,*\dLH#/-]+$|^.*H\(\d+-\d+\)\/\d+.*$|^.*H\(\d+-\d+\).*$|^.*H\/\d+.*$/}constructor(e,t){super(e,t),this.validate()}get values(){return super.values}get nthDay(){return this.options.nthDayOfWeek??0}}})),a=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CronHour=void 0;var t=n(),r=0,i=23,a=Object.freeze([]);e.CronHour=class extends t.CronField{static get min(){return r}static get max(){return i}static get chars(){return a}constructor(e,t){super(e,t),this.validate()}get values(){return super.values}}})),o=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CronMinute=void 0;var t=n(),r=0,i=59,a=Object.freeze([]);e.CronMinute=class extends t.CronField{static get min(){return r}static get max(){return i}static get chars(){return a}constructor(e,t){super(e,t),this.validate()}get values(){return super.values}}})),s=e((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=class extends Error{},n=class extends t{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}},r=class extends t{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}},i=class extends t{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}},a=class extends t{},o=class extends t{constructor(e){super(`Invalid unit ${e}`)}},s=class extends t{},c=class extends t{constructor(){super(`Zone is an abstract class`)}},l=`numeric`,u=`short`,d=`long`,f={year:l,month:l,day:l},p={year:l,month:u,day:l},m={year:l,month:u,day:l,weekday:u},h={year:l,month:d,day:l},g={year:l,month:d,day:l,weekday:d},_={hour:l,minute:l},v={hour:l,minute:l,second:l},y={hour:l,minute:l,second:l,timeZoneName:u},b={hour:l,minute:l,second:l,timeZoneName:d},x={hour:l,minute:l,hourCycle:`h23`},ee={hour:l,minute:l,second:l,hourCycle:`h23`},te={hour:l,minute:l,second:l,hourCycle:`h23`,timeZoneName:u},S={hour:l,minute:l,second:l,hourCycle:`h23`,timeZoneName:d},ne={year:l,month:l,day:l,hour:l,minute:l},re={year:l,month:l,day:l,hour:l,minute:l,second:l},ie={year:l,month:u,day:l,hour:l,minute:l},ae={year:l,month:u,day:l,hour:l,minute:l,second:l},oe={year:l,month:u,day:l,weekday:u,hour:l,minute:l},se={year:l,month:d,day:l,hour:l,minute:l,timeZoneName:u},ce={year:l,month:d,day:l,hour:l,minute:l,second:l,timeZoneName:u},le={year:l,month:d,day:l,weekday:d,hour:l,minute:l,timeZoneName:d},ue={year:l,month:d,day:l,weekday:d,hour:l,minute:l,second:l,timeZoneName:d},C=class{get type(){throw new c}get name(){throw new c}get ianaName(){return this.name}get isUniversal(){throw new c}offsetName(e,t){throw new c}formatOffset(e,t){throw new c}offset(e){throw new c}equals(e){throw new c}get isValid(){throw new c}},de=null,fe=class e extends C{static get instance(){return de===null&&(de=new e),de}get type(){return`system`}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:t,locale:n}){return Rt(e,t,n)}formatOffset(e,t){return Ht(this.offset(e),t)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return e.type===`system`}get isValid(){return!0}},pe=new Map;function me(e){let t=pe.get(e);return t===void 0&&(t=new Intl.DateTimeFormat(`en-US`,{hour12:!1,timeZone:e,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,era:`short`}),pe.set(e,t)),t}var he={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function ge(e,t){let n=e.format(t).replace(/\u200E/g,``),[,r,i,a,o,s,c,l]=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(n);return[a,r,i,o,s,c,l]}function _e(e,t){let n=e.formatToParts(t),r=[];for(let e=0;e<n.length;e++){let{type:t,value:i}=n[e],a=he[t];t===`era`?r[a]=i:M(a)||(r[a]=parseInt(i,10))}return r}var ve=new Map,w=class e extends C{static create(t){let n=ve.get(t);return n===void 0&&ve.set(t,n=new e(t)),n}static resetCache(){ve.clear(),pe.clear()}static isValidSpecifier(e){return this.isValidZone(e)}static isValidZone(e){if(!e)return!1;try{return new Intl.DateTimeFormat(`en-US`,{timeZone:e}).format(),!0}catch{return!1}}constructor(t){super(),this.zoneName=t,this.valid=e.isValidZone(t)}get type(){return`iana`}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(e,{format:t,locale:n}){return Rt(e,t,n,this.name)}formatOffset(e,t){return Ht(this.offset(e),t)}offset(e){if(!this.valid)return NaN;let t=new Date(e);if(isNaN(t))return NaN;let n=me(this.name),[r,i,a,o,s,c,l]=n.formatToParts?_e(n,t):ge(n,t);o===`BC`&&(r=-Math.abs(r)+1);let u=Pt({year:r,month:i,day:a,hour:s===24?0:s,minute:c,second:l,millisecond:0}),d=+t,f=d%1e3;return d-=f>=0?f:1e3+f,(u-d)/(60*1e3)}equals(e){return e.type===`iana`&&e.name===this.name}get isValid(){return this.valid}},ye={};function be(e,t={}){let n=JSON.stringify([e,t]),r=ye[n];return r||(r=new Intl.ListFormat(e,t),ye[n]=r),r}var xe=new Map;function Se(e,t={}){let n=JSON.stringify([e,t]),r=xe.get(n);return r===void 0&&(r=new Intl.DateTimeFormat(e,t),xe.set(n,r)),r}var Ce=new Map;function we(e,t={}){let n=JSON.stringify([e,t]),r=Ce.get(n);return r===void 0&&(r=new Intl.NumberFormat(e,t),Ce.set(n,r)),r}var Te=new Map;function Ee(e,t={}){let{base:n,...r}=t,i=JSON.stringify([e,r]),a=Te.get(i);return a===void 0&&(a=new Intl.RelativeTimeFormat(e,t),Te.set(i,a)),a}var De=null;function Oe(){return De||(De=new Intl.DateTimeFormat().resolvedOptions().locale,De)}var ke=new Map;function Ae(e){let t=ke.get(e);return t===void 0&&(t=new Intl.DateTimeFormat(e).resolvedOptions(),ke.set(e,t)),t}var je=new Map;function Me(e){let t=je.get(e);if(!t){let n=new Intl.Locale(e);t=`getWeekInfo`in n?n.getWeekInfo():n.weekInfo,`minimalDays`in t||(t={...He,...t}),je.set(e,t)}return t}function Ne(e){let t=e.indexOf(`-x-`);t!==-1&&(e=e.substring(0,t));let n=e.indexOf(`-u-`);if(n===-1)return[e];{let t,r;try{t=Se(e).resolvedOptions(),r=e}catch{let i=e.substring(0,n);t=Se(i).resolvedOptions(),r=i}let{numberingSystem:i,calendar:a}=t;return[r,i,a]}}function Pe(e,t,n){return n||t?(e.includes(`-u-`)||(e+=`-u`),n&&(e+=`-ca-${n}`),t&&(e+=`-nu-${t}`),e):e}function Fe(e){let t=[];for(let n=1;n<=12;n++){let r=$.utc(2009,n,1);t.push(e(r))}return t}function Ie(e){let t=[];for(let n=1;n<=7;n++){let r=$.utc(2016,11,13+n);t.push(e(r))}return t}function Le(e,t,n,r){let i=e.listingMode();return i===`error`?null:i===`en`?n(t):r(t)}function Re(e){return e.numberingSystem&&e.numberingSystem!==`latn`?!1:e.numberingSystem===`latn`||!e.locale||e.locale.startsWith(`en`)||Ae(e.locale).numberingSystem===`latn`}var ze=class{constructor(e,t,n){this.padTo=n.padTo||0,this.floor=n.floor||!1;let{padTo:r,floor:i,...a}=n;if(!t||Object.keys(a).length>0){let t={useGrouping:!1,...n};n.padTo>0&&(t.minimumIntegerDigits=n.padTo),this.inf=we(e,t)}}format(e){if(this.inf){let t=this.floor?Math.floor(e):e;return this.inf.format(t)}else return I(this.floor?Math.floor(e):jt(e,3),this.padTo)}},Be=class{constructor(e,t,n){this.opts=n,this.originalZone=void 0;let r;if(this.opts.timeZone)this.dt=e;else if(e.zone.type===`fixed`){let t=-1*(e.offset/60),n=t>=0?`Etc/GMT+${t}`:`Etc/GMT${t}`;e.offset!==0&&w.create(n).valid?(r=n,this.dt=e):(r=`UTC`,this.dt=e.offset===0?e:e.setZone(`UTC`).plus({minutes:e.offset}),this.originalZone=e.zone)}else e.zone.type===`system`?this.dt=e:e.zone.type===`iana`?(this.dt=e,r=e.zone.name):(r=`UTC`,this.dt=e.setZone(`UTC`).plus({minutes:e.offset}),this.originalZone=e.zone);let i={...this.opts};i.timeZone=i.timeZone||r,this.dtf=Se(t,i)}format(){return this.originalZone?this.formatToParts().map(({value:e})=>e).join(``):this.dtf.format(this.dt.toJSDate())}formatToParts(){let e=this.dtf.formatToParts(this.dt.toJSDate());return this.originalZone?e.map(e=>{if(e.type===`timeZoneName`){let t=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...e,value:t}}else return e}):e}resolvedOptions(){return this.dtf.resolvedOptions()}},Ve=class{constructor(e,t,n){this.opts={style:`long`,...n},!t&&Ct()&&(this.rtf=Ee(e,n))}format(e,t){return this.rtf?this.rtf.format(e,t):cn(t,e,this.opts.numeric,this.opts.style!==`long`)}formatToParts(e,t){return this.rtf?this.rtf.formatToParts(e,t):[]}},He={firstDay:1,minimalDays:4,weekend:[6,7]},T=class e{static fromOpts(t){return e.create(t.locale,t.numberingSystem,t.outputCalendar,t.weekSettings,t.defaultToEN)}static create(t,n,r,i,a=!1){let o=t||k.defaultLocale;return new e(o||(a?`en-US`:Oe()),n||k.defaultNumberingSystem,r||k.defaultOutputCalendar,Ot(i)||k.defaultWeekSettings,o)}static resetCache(){De=null,xe.clear(),Ce.clear(),Te.clear(),ke.clear(),je.clear()}static fromObject({locale:t,numberingSystem:n,outputCalendar:r,weekSettings:i}={}){return e.create(t,n,r,i)}constructor(e,t,n,r,i){let[a,o,s]=Ne(e);this.locale=a,this.numberingSystem=t||o||null,this.outputCalendar=n||s||null,this.weekSettings=r,this.intl=Pe(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=i,this.fastNumbersCached=null}get fastNumbers(){return this.fastNumbersCached??=Re(this),this.fastNumbersCached}listingMode(){let e=this.isEnglish(),t=(this.numberingSystem===null||this.numberingSystem===`latn`)&&(this.outputCalendar===null||this.outputCalendar===`gregory`);return e&&t?`en`:`intl`}clone(t){return!t||Object.getOwnPropertyNames(t).length===0?this:e.create(t.locale||this.specifiedLocale,t.numberingSystem||this.numberingSystem,t.outputCalendar||this.outputCalendar,Ot(t.weekSettings)||this.weekSettings,t.defaultToEN||!1)}redefaultToEN(e={}){return this.clone({...e,defaultToEN:!0})}redefaultToSystem(e={}){return this.clone({...e,defaultToEN:!1})}months(e,t=!1){return Le(this,e,qt,()=>{let n=this.intl===`ja`||this.intl.startsWith(`ja-`);t&=!n;let r=t?{month:e,day:`numeric`}:{month:e},i=t?`format`:`standalone`;if(!this.monthsCache[i][e]){let t=n?e=>this.dtFormatter(e,r).format():e=>this.extract(e,r,`month`);this.monthsCache[i][e]=Fe(t)}return this.monthsCache[i][e]})}weekdays(e,t=!1){return Le(this,e,Zt,()=>{let n=t?{weekday:e,year:`numeric`,month:`long`,day:`numeric`}:{weekday:e},r=t?`format`:`standalone`;return this.weekdaysCache[r][e]||(this.weekdaysCache[r][e]=Ie(e=>this.extract(e,n,`weekday`))),this.weekdaysCache[r][e]})}meridiems(){return Le(this,void 0,()=>Qt,()=>{if(!this.meridiemCache){let e={hour:`numeric`,hourCycle:`h12`};this.meridiemCache=[$.utc(2016,11,13,9),$.utc(2016,11,13,19)].map(t=>this.extract(t,e,`dayperiod`))}return this.meridiemCache})}eras(e){return Le(this,e,nn,()=>{let t={era:e};return this.eraCache[e]||(this.eraCache[e]=[$.utc(-40,1,1),$.utc(2017,1,1)].map(e=>this.extract(e,t,`era`))),this.eraCache[e]})}extract(e,t,n){let r=this.dtFormatter(e,t).formatToParts().find(e=>e.type.toLowerCase()===n);return r?r.value:null}numberFormatter(e={}){return new ze(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,t={}){return new Be(e,this.intl,t)}relFormatter(e={}){return new Ve(this.intl,this.isEnglish(),e)}listFormatter(e={}){return be(this.intl,e)}isEnglish(){return this.locale===`en`||this.locale.toLowerCase()===`en-us`||Ae(this.intl).locale.startsWith(`en-us`)}getWeekSettings(){return this.weekSettings?this.weekSettings:wt()?Me(this.locale):He}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(e){return this.locale===e.locale&&this.numberingSystem===e.numberingSystem&&this.outputCalendar===e.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}},Ue=null,E=class e extends C{static get utcInstance(){return Ue===null&&(Ue=new e(0)),Ue}static instance(t){return t===0?e.utcInstance:new e(t)}static parseSpecifier(t){if(t){let n=t.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(n)return new e(zt(n[1],n[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return`fixed`}get name(){return this.fixed===0?`UTC`:`UTC${Ht(this.fixed,`narrow`)}`}get ianaName(){return this.fixed===0?`Etc/UTC`:`Etc/GMT${Ht(-this.fixed,`narrow`)}`}offsetName(){return this.name}formatOffset(e,t){return Ht(this.fixed,t)}get isUniversal(){return!0}offset(){return this.fixed}equals(e){return e.type===`fixed`&&e.fixed===this.fixed}get isValid(){return!0}},We=class extends C{constructor(e){super(),this.zoneName=e}get type(){return`invalid`}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return``}offset(){return NaN}equals(){return!1}get isValid(){return!1}};function D(e,t){if(M(e)||e===null)return t;if(e instanceof C)return e;if(xt(e)){let n=e.toLowerCase();return n===`default`?t:n===`local`||n===`system`?fe.instance:n===`utc`||n===`gmt`?E.utcInstance:E.parseSpecifier(n)||w.create(e)}else if(N(e))return E.instance(e);else if(typeof e==`object`&&`offset`in e&&typeof e.offset==`function`)return e;else return new We(e)}var Ge={arab:`[٠-٩]`,arabext:`[۰-۹]`,bali:`[᭐-᭙]`,beng:`[০-৯]`,deva:`[०-९]`,fullwide:`[0-9]`,gujr:`[૦-૯]`,hanidec:`[〇|一|二|三|四|五|六|七|八|九]`,khmr:`[០-៩]`,knda:`[೦-೯]`,laoo:`[໐-໙]`,limb:`[᥆-᥏]`,mlym:`[൦-൯]`,mong:`[᠐-᠙]`,mymr:`[၀-၉]`,orya:`[୦-୯]`,tamldec:`[௦-௯]`,telu:`[౦-౯]`,thai:`[๐-๙]`,tibt:`[༠-༩]`,latn:`\\d`},Ke={arab:[1632,1641],arabext:[1776,1785],bali:[6992,7001],beng:[2534,2543],deva:[2406,2415],fullwide:[65296,65303],gujr:[2790,2799],khmr:[6112,6121],knda:[3302,3311],laoo:[3792,3801],limb:[6470,6479],mlym:[3430,3439],mong:[6160,6169],mymr:[4160,4169],orya:[2918,2927],tamldec:[3046,3055],telu:[3174,3183],thai:[3664,3673],tibt:[3872,3881]},qe=Ge.hanidec.replace(/[\[|\]]/g,``).split(``);function Je(e){let t=parseInt(e,10);if(isNaN(t)){t=``;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(e[n].search(Ge.hanidec)!==-1)t+=qe.indexOf(e[n]);else for(let e in Ke){let[n,i]=Ke[e];r>=n&&r<=i&&(t+=r-n)}}return parseInt(t,10)}else return t}var Ye=new Map;function Xe(){Ye.clear()}function O({numberingSystem:e},t=``){let n=e||`latn`,r=Ye.get(n);r===void 0&&(r=new Map,Ye.set(n,r));let i=r.get(t);return i===void 0&&(i=RegExp(`${Ge[n]}${t}`),r.set(t,i)),i}var Ze=()=>Date.now(),Qe=`system`,$e=null,et=null,tt=null,nt=60,rt,it=null,k=class{static get now(){return Ze}static set now(e){Ze=e}static set defaultZone(e){Qe=e}static get defaultZone(){return D(Qe,fe.instance)}static get defaultLocale(){return $e}static set defaultLocale(e){$e=e}static get defaultNumberingSystem(){return et}static set defaultNumberingSystem(e){et=e}static get defaultOutputCalendar(){return tt}static set defaultOutputCalendar(e){tt=e}static get defaultWeekSettings(){return it}static set defaultWeekSettings(e){it=Ot(e)}static get twoDigitCutoffYear(){return nt}static set twoDigitCutoffYear(e){nt=e%100}static get throwOnInvalid(){return rt}static set throwOnInvalid(e){rt=e}static resetCaches(){T.resetCache(),w.resetCache(),$.resetCache(),Xe()}},A=class{constructor(e,t){this.reason=e,this.explanation=t}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}},at=[0,31,59,90,120,151,181,212,243,273,304,334],ot=[0,31,60,91,121,152,182,213,244,274,305,335];function j(e,t){return new A(`unit out of range`,`you specified ${t} (of type ${typeof t}) as a ${e}, which is invalid`)}function st(e,t,n){let r=new Date(Date.UTC(e,t-1,n));e<100&&e>=0&&r.setUTCFullYear(r.getUTCFullYear()-1900);let i=r.getUTCDay();return i===0?7:i}function ct(e,t,n){return n+(Mt(e)?ot:at)[t-1]}function lt(e,t){let n=Mt(e)?ot:at,r=n.findIndex(e=>e<t),i=t-n[r];return{month:r+1,day:i}}function ut(e,t){return(e-t+7)%7+1}function dt(e,t=4,n=1){let{year:r,month:i,day:a}=e,o=ct(r,i,a),s=ut(st(r,i,a),n),c=Math.floor((o-s+14-t)/7),l;return c<1?(l=r-1,c=It(l,t,n)):c>It(r,t,n)?(l=r+1,c=1):l=r,{weekYear:l,weekNumber:c,weekday:s,...Ut(e)}}function ft(e,t=4,n=1){let{weekYear:r,weekNumber:i,weekday:a}=e,o=ut(st(r,1,t),n),s=z(r),c=i*7+a-o-7+t,l;c<1?(l=r-1,c+=z(l)):c>s?(l=r+1,c-=z(r)):l=r;let{month:u,day:d}=lt(l,c);return{year:l,month:u,day:d,...Ut(e)}}function pt(e){let{year:t,month:n,day:r}=e;return{year:t,ordinal:ct(t,n,r),...Ut(e)}}function mt(e){let{year:t,ordinal:n}=e,{month:r,day:i}=lt(t,n);return{year:t,month:r,day:i,...Ut(e)}}function ht(e,t){if(!M(e.localWeekday)||!M(e.localWeekNumber)||!M(e.localWeekYear)){if(!M(e.weekday)||!M(e.weekNumber)||!M(e.weekYear))throw new a(`Cannot mix locale-based week fields with ISO-based week fields`);return M(e.localWeekday)||(e.weekday=e.localWeekday),M(e.localWeekNumber)||(e.weekNumber=e.localWeekNumber),M(e.localWeekYear)||(e.weekYear=e.localWeekYear),delete e.localWeekday,delete e.localWeekNumber,delete e.localWeekYear,{minDaysInFirstWeek:t.getMinDaysInFirstWeek(),startOfWeek:t.getStartOfWeek()}}else return{minDaysInFirstWeek:4,startOfWeek:1}}function gt(e,t=4,n=1){let r=bt(e.weekYear),i=F(e.weekNumber,1,It(e.weekYear,t,n)),a=F(e.weekday,1,7);return r?i?a?!1:j(`weekday`,e.weekday):j(`week`,e.weekNumber):j(`weekYear`,e.weekYear)}function _t(e){let t=bt(e.year),n=F(e.ordinal,1,z(e.year));return t?n?!1:j(`ordinal`,e.ordinal):j(`year`,e.year)}function vt(e){let t=bt(e.year),n=F(e.month,1,12),r=F(e.day,1,Nt(e.year,e.month));return t?n?r?!1:j(`day`,e.day):j(`month`,e.month):j(`year`,e.year)}function yt(e){let{hour:t,minute:n,second:r,millisecond:i}=e,a=F(t,0,23)||t===24&&n===0&&r===0&&i===0,o=F(n,0,59),s=F(r,0,59),c=F(i,0,999);return a?o?s?c?!1:j(`millisecond`,i):j(`second`,r):j(`minute`,n):j(`hour`,t)}function M(e){return e===void 0}function N(e){return typeof e==`number`}function bt(e){return typeof e==`number`&&e%1==0}function xt(e){return typeof e==`string`}function St(e){return Object.prototype.toString.call(e)===`[object Date]`}function Ct(){try{return typeof Intl<`u`&&!!Intl.RelativeTimeFormat}catch{return!1}}function wt(){try{return typeof Intl<`u`&&!!Intl.Locale&&(`weekInfo`in Intl.Locale.prototype||`getWeekInfo`in Intl.Locale.prototype)}catch{return!1}}function Tt(e){return Array.isArray(e)?e:[e]}function Et(e,t,n){if(e.length!==0)return e.reduce((e,r)=>{let i=[t(r),r];return e&&n(e[0],i[0])===e[0]?e:i},null)[1]}function Dt(e,t){return t.reduce((t,n)=>(t[n]=e[n],t),{})}function P(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Ot(e){if(e==null)return null;if(typeof e!=`object`)throw new s(`Week settings must be an object`);if(!F(e.firstDay,1,7)||!F(e.minimalDays,1,7)||!Array.isArray(e.weekend)||e.weekend.some(e=>!F(e,1,7)))throw new s(`Invalid week settings`);return{firstDay:e.firstDay,minimalDays:e.minimalDays,weekend:Array.from(e.weekend)}}function F(e,t,n){return bt(e)&&e>=t&&e<=n}function kt(e,t){return e-t*Math.floor(e/t)}function I(e,t=2){let n=e<0,r;return r=n?`-`+(``+-e).padStart(t,`0`):(``+e).padStart(t,`0`),r}function L(e){if(!(M(e)||e===null||e===``))return parseInt(e,10)}function R(e){if(!(M(e)||e===null||e===``))return parseFloat(e)}function At(e){if(!(M(e)||e===null||e===``)){let t=parseFloat(`0.`+e)*1e3;return Math.floor(t)}}function jt(e,t,n=`round`){let r=10**t;switch(n){case`expand`:return e>0?Math.ceil(e*r)/r:Math.floor(e*r)/r;case`trunc`:return Math.trunc(e*r)/r;case`round`:return Math.round(e*r)/r;case`floor`:return Math.floor(e*r)/r;case`ceil`:return Math.ceil(e*r)/r;default:throw RangeError(`Value rounding ${n} is out of range`)}}function Mt(e){return e%4==0&&(e%100!=0||e%400==0)}function z(e){return Mt(e)?366:365}function Nt(e,t){let n=kt(t-1,12)+1,r=e+(t-n)/12;return n===2?Mt(r)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][n-1]}function Pt(e){let t=Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond);return e.year<100&&e.year>=0&&(t=new Date(t),t.setUTCFullYear(e.year,e.month-1,e.day)),+t}function Ft(e,t,n){return-ut(st(e,1,t),n)+t-1}function It(e,t=4,n=1){let r=Ft(e,t,n),i=Ft(e+1,t,n);return(z(e)-r+i)/7}function Lt(e){return e>99?e:e>k.twoDigitCutoffYear?1900+e:2e3+e}function Rt(e,t,n,r=null){let i=new Date(e),a={hourCycle:`h23`,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`};r&&(a.timeZone=r);let o={timeZoneName:t,...a},s=new Intl.DateTimeFormat(n,o).formatToParts(i).find(e=>e.type.toLowerCase()===`timezonename`);return s?s.value:null}function zt(e,t){let n=parseInt(e,10);Number.isNaN(n)&&(n=0);let r=parseInt(t,10)||0,i=n<0||Object.is(n,-0)?-r:r;return n*60+i}function Bt(e){let t=Number(e);if(typeof e==`boolean`||e===``||!Number.isFinite(t))throw new s(`Invalid unit value ${e}`);return t}function Vt(e,t){let n={};for(let r in e)if(P(e,r)){let i=e[r];if(i==null)continue;n[t(r)]=Bt(i)}return n}function Ht(e,t){let n=Math.trunc(Math.abs(e/60)),r=Math.trunc(Math.abs(e%60)),i=e>=0?`+`:`-`;switch(t){case`short`:return`${i}${I(n,2)}:${I(r,2)}`;case`narrow`:return`${i}${n}${r>0?`:${r}`:``}`;case`techie`:return`${i}${I(n,2)}${I(r,2)}`;default:throw RangeError(`Value format ${t} is out of range for property format`)}}function Ut(e){return Dt(e,[`hour`,`minute`,`second`,`millisecond`])}var Wt=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],Gt=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],Kt=[`J`,`F`,`M`,`A`,`M`,`J`,`J`,`A`,`S`,`O`,`N`,`D`];function qt(e){switch(e){case`narrow`:return[...Kt];case`short`:return[...Gt];case`long`:return[...Wt];case`numeric`:return[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`11`,`12`];case`2-digit`:return[`01`,`02`,`03`,`04`,`05`,`06`,`07`,`08`,`09`,`10`,`11`,`12`];default:return null}}var Jt=[`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`,`Sunday`],Yt=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],Xt=[`M`,`T`,`W`,`T`,`F`,`S`,`S`];function Zt(e){switch(e){case`narrow`:return[...Xt];case`short`:return[...Yt];case`long`:return[...Jt];case`numeric`:return[`1`,`2`,`3`,`4`,`5`,`6`,`7`];default:return null}}var Qt=[`AM`,`PM`],$t=[`Before Christ`,`Anno Domini`],en=[`BC`,`AD`],tn=[`B`,`A`];function nn(e){switch(e){case`narrow`:return[...tn];case`short`:return[...en];case`long`:return[...$t];default:return null}}function rn(e){return Qt[e.hour<12?0:1]}function an(e,t){return Zt(t)[e.weekday-1]}function on(e,t){return qt(t)[e.month-1]}function sn(e,t){return nn(t)[e.year<0?0:1]}function cn(e,t,n=`always`,r=!1){let i={years:[`year`,`yr.`],quarters:[`quarter`,`qtr.`],months:[`month`,`mo.`],weeks:[`week`,`wk.`],days:[`day`,`day`,`days`],hours:[`hour`,`hr.`],minutes:[`minute`,`min.`],seconds:[`second`,`sec.`]},a=[`hours`,`minutes`,`seconds`].indexOf(e)===-1;if(n===`auto`&&a){let n=e===`days`;switch(t){case 1:return n?`tomorrow`:`next ${i[e][0]}`;case-1:return n?`yesterday`:`last ${i[e][0]}`;case 0:return n?`today`:`this ${i[e][0]}`}}let o=Object.is(t,-0)||t<0,s=Math.abs(t),c=s===1,l=i[e],u=r?c?l[1]:l[2]||l[1]:c?i[e][0]:e;return o?`${s} ${u} ago`:`in ${s} ${u}`}function ln(e,t){let n=``;for(let r of e)r.literal?n+=r.val:n+=t(r.val);return n}var un={D:f,DD:p,DDD:h,DDDD:g,t:_,tt:v,ttt:y,tttt:b,T:x,TT:ee,TTT:te,TTTT:S,f:ne,ff:ie,fff:se,ffff:le,F:re,FF:ae,FFF:ce,FFFF:ue},B=class e{static create(t,n={}){return new e(t,n)}static parseFormat(e){let t=null,n=``,r=!1,i=[];for(let a=0;a<e.length;a++){let o=e.charAt(a);o===`'`?((n.length>0||r)&&i.push({literal:r||/^\s+$/.test(n),val:n===``?`'`:n}),t=null,n=``,r=!r):r||o===t?n+=o:(n.length>0&&i.push({literal:/^\s+$/.test(n),val:n}),n=o,t=o)}return n.length>0&&i.push({literal:r||/^\s+$/.test(n),val:n}),i}static macroTokenToFormatOpts(e){return un[e]}constructor(e,t){this.opts=t,this.loc=e,this.systemLoc=null}formatWithSystemDefault(e,t){return this.systemLoc===null&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(e,{...this.opts,...t}).format()}dtFormatter(e,t={}){return this.loc.dtFormatter(e,{...this.opts,...t})}formatDateTime(e,t){return this.dtFormatter(e,t).format()}formatDateTimeParts(e,t){return this.dtFormatter(e,t).formatToParts()}formatInterval(e,t){return this.dtFormatter(e.start,t).dtf.formatRange(e.start.toJSDate(),e.end.toJSDate())}resolvedOptions(e,t){return this.dtFormatter(e,t).resolvedOptions()}num(e,t=0,n=void 0){if(this.opts.forceSimple)return I(e,t);let r={...this.opts};return t>0&&(r.padTo=t),n&&(r.signDisplay=n),this.loc.numberFormatter(r).format(e)}formatDateTimeFromString(t,n){let r=this.loc.listingMode()===`en`,i=this.loc.outputCalendar&&this.loc.outputCalendar!==`gregory`,a=(e,n)=>this.loc.extract(t,e,n),o=e=>t.isOffsetFixed&&t.offset===0&&e.allowZ?`Z`:t.isValid?t.zone.formatOffset(t.ts,e.format):``,s=()=>r?rn(t):a({hour:`numeric`,hourCycle:`h12`},`dayperiod`),c=(e,n)=>r?on(t,e):a(n?{month:e}:{month:e,day:`numeric`},`month`),l=(e,n)=>r?an(t,e):a(n?{weekday:e}:{weekday:e,month:`long`,day:`numeric`},`weekday`),u=n=>{let r=e.macroTokenToFormatOpts(n);return r?this.formatWithSystemDefault(t,r):n},d=e=>r?sn(t,e):a({era:e},`era`);return ln(e.parseFormat(n),e=>{switch(e){case`S`:return this.num(t.millisecond);case`u`:case`SSS`:return this.num(t.millisecond,3);case`s`:return this.num(t.second);case`ss`:return this.num(t.second,2);case`uu`:return this.num(Math.floor(t.millisecond/10),2);case`uuu`:return this.num(Math.floor(t.millisecond/100));case`m`:return this.num(t.minute);case`mm`:return this.num(t.minute,2);case`h`:return this.num(t.hour%12==0?12:t.hour%12);case`hh`:return this.num(t.hour%12==0?12:t.hour%12,2);case`H`:return this.num(t.hour);case`HH`:return this.num(t.hour,2);case`Z`:return o({format:`narrow`,allowZ:this.opts.allowZ});case`ZZ`:return o({format:`short`,allowZ:this.opts.allowZ});case`ZZZ`:return o({format:`techie`,allowZ:this.opts.allowZ});case`ZZZZ`:return t.zone.offsetName(t.ts,{format:`short`,locale:this.loc.locale});case`ZZZZZ`:return t.zone.offsetName(t.ts,{format:`long`,locale:this.loc.locale});case`z`:return t.zoneName;case`a`:return s();case`d`:return i?a({day:`numeric`},`day`):this.num(t.day);case`dd`:return i?a({day:`2-digit`},`day`):this.num(t.day,2);case`c`:return this.num(t.weekday);case`ccc`:return l(`short`,!0);case`cccc`:return l(`long`,!0);case`ccccc`:return l(`narrow`,!0);case`E`:return this.num(t.weekday);case`EEE`:return l(`short`,!1);case`EEEE`:return l(`long`,!1);case`EEEEE`:return l(`narrow`,!1);case`L`:return i?a({month:`numeric`,day:`numeric`},`month`):this.num(t.month);case`LL`:return i?a({month:`2-digit`,day:`numeric`},`month`):this.num(t.month,2);case`LLL`:return c(`short`,!0);case`LLLL`:return c(`long`,!0);case`LLLLL`:return c(`narrow`,!0);case`M`:return i?a({month:`numeric`},`month`):this.num(t.month);case`MM`:return i?a({month:`2-digit`},`month`):this.num(t.month,2);case`MMM`:return c(`short`,!1);case`MMMM`:return c(`long`,!1);case`MMMMM`:return c(`narrow`,!1);case`y`:return i?a({year:`numeric`},`year`):this.num(t.year);case`yy`:return i?a({year:`2-digit`},`year`):this.num(t.year.toString().slice(-2),2);case`yyyy`:return i?a({year:`numeric`},`year`):this.num(t.year,4);case`yyyyyy`:return i?a({year:`numeric`},`year`):this.num(t.year,6);case`G`:return d(`short`);case`GG`:return d(`long`);case`GGGGG`:return d(`narrow`);case`kk`:return this.num(t.weekYear.toString().slice(-2),2);case`kkkk`:return this.num(t.weekYear,4);case`W`:return this.num(t.weekNumber);case`WW`:return this.num(t.weekNumber,2);case`n`:return this.num(t.localWeekNumber);case`nn`:return this.num(t.localWeekNumber,2);case`ii`:return this.num(t.localWeekYear.toString().slice(-2),2);case`iiii`:return this.num(t.localWeekYear,4);case`o`:return this.num(t.ordinal);case`ooo`:return this.num(t.ordinal,3);case`q`:return this.num(t.quarter);case`qq`:return this.num(t.quarter,2);case`X`:return this.num(Math.floor(t.ts/1e3));case`x`:return this.num(t.ts);default:return u(e)}})}formatDurationFromString(t,n){let r=this.opts.signMode===`negativeLargestOnly`?-1:1,i=e=>{switch(e[0]){case`S`:return`milliseconds`;case`s`:return`seconds`;case`m`:return`minutes`;case`h`:return`hours`;case`d`:return`days`;case`w`:return`weeks`;case`M`:return`months`;case`y`:return`years`;default:return null}},a=(e,t)=>n=>{let a=i(n);if(a){let i=t.isNegativeDuration&&a!==t.largestUnit?r:1,o;return o=this.opts.signMode===`negativeLargestOnly`&&a!==t.largestUnit?`never`:this.opts.signMode===`all`?`always`:`auto`,this.num(e.get(a)*i,n.length,o)}else return n},o=e.parseFormat(n),s=o.reduce((e,{literal:t,val:n})=>t?e:e.concat(n),[]),c=t.shiftTo(...s.map(i).filter(e=>e));return ln(o,a(c,{isNegativeDuration:c<0,largestUnit:Object.keys(c.values)[0]}))}},dn=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function V(...e){let t=e.reduce((e,t)=>e+t.source,``);return RegExp(`^${t}$`)}function H(...e){return t=>e.reduce(([e,n,r],i)=>{let[a,o,s]=i(t,r);return[{...e,...a},o||n,s]},[{},null,1]).slice(0,2)}function U(e,...t){if(e==null)return[null,null];for(let[n,r]of t){let t=n.exec(e);if(t)return r(t)}return[null,null]}function fn(...e){return(t,n)=>{let r={},i;for(i=0;i<e.length;i++)r[e[i]]=L(t[n+i]);return[r,null,n+i]}}var pn=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,mn=`(?:${pn.source}?(?:\\[(${dn.source})\\])?)?`,hn=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,gn=RegExp(`${hn.source}${mn}`),_n=RegExp(`(?:[Tt]${gn.source})?`),vn=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,yn=/(\d{4})-?W(\d\d)(?:-?(\d))?/,bn=/(\d{4})-?(\d{3})/,xn=fn(`weekYear`,`weekNumber`,`weekDay`),Sn=fn(`year`,`ordinal`),Cn=/(\d{4})-(\d\d)-(\d\d)/,wn=RegExp(`${hn.source} ?(?:${pn.source}|(${dn.source}))?`),Tn=RegExp(`(?: ${wn.source})?`);function W(e,t,n){let r=e[t];return M(r)?n:L(r)}function En(e,t){return[{year:W(e,t),month:W(e,t+1,1),day:W(e,t+2,1)},null,t+3]}function Dn(e,t){return[{hours:W(e,t,0),minutes:W(e,t+1,0),seconds:W(e,t+2,0),milliseconds:At(e[t+3])},null,t+4]}function On(e,t){let n=!e[t]&&!e[t+1],r=zt(e[t+1],e[t+2]);return[{},n?null:E.instance(r),t+3]}function kn(e,t){return[{},e[t]?w.create(e[t]):null,t+1]}var An=RegExp(`^T?${hn.source}$`),jn=/^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;function Mn(e){let[t,n,r,i,a,o,s,c,l]=e,u=t[0]===`-`,d=c&&c[0]===`-`,f=(e,t=!1)=>e!==void 0&&(t||e&&u)?-e:e;return[{years:f(R(n)),months:f(R(r)),weeks:f(R(i)),days:f(R(a)),hours:f(R(o)),minutes:f(R(s)),seconds:f(R(c),c===`-0`),milliseconds:f(At(l),d)}]}var Nn={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Pn(e,t,n,r,i,a,o){let s={year:t.length===2?Lt(L(t)):L(t),month:Gt.indexOf(n)+1,day:L(r),hour:L(i),minute:L(a)};return o&&(s.second=L(o)),e&&(s.weekday=e.length>3?Jt.indexOf(e)+1:Yt.indexOf(e)+1),s}var Fn=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function In(e){let[,t,n,r,i,a,o,s,c,l,u,d]=e,f=Pn(t,i,r,n,a,o,s),p;return p=c?Nn[c]:l?0:zt(u,d),[f,new E(p)]}function Ln(e){return e.replace(/\([^()]*\)|[\n\t]/g,` `).replace(/(\s\s+)/g,` `).trim()}var Rn=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,zn=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,Bn=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;function Vn(e){let[,t,n,r,i,a,o,s]=e;return[Pn(t,i,r,n,a,o,s),E.utcInstance]}function Hn(e){let[,t,n,r,i,a,o,s]=e;return[Pn(t,s,n,r,i,a,o),E.utcInstance]}var Un=V(vn,_n),Wn=V(yn,_n),Gn=V(bn,_n),Kn=V(gn),qn=H(En,Dn,On,kn),Jn=H(xn,Dn,On,kn),Yn=H(Sn,Dn,On,kn),Xn=H(Dn,On,kn);function Zn(e){return U(e,[Un,qn],[Wn,Jn],[Gn,Yn],[Kn,Xn])}function Qn(e){return U(Ln(e),[Fn,In])}function $n(e){return U(e,[Rn,Vn],[zn,Vn],[Bn,Hn])}function er(e){return U(e,[jn,Mn])}var tr=H(Dn);function nr(e){return U(e,[An,tr])}var rr=V(Cn,Tn),ir=V(wn),ar=H(Dn,On,kn);function or(e){return U(e,[rr,qn],[ir,ar])}var sr=`Invalid Duration`,cr={weeks:{days:7,hours:168,minutes:10080,seconds:10080*60,milliseconds:10080*60*1e3},days:{hours:24,minutes:1440,seconds:1440*60,milliseconds:1440*60*1e3},hours:{minutes:60,seconds:3600,milliseconds:3600*1e3},minutes:{seconds:60,milliseconds:60*1e3},seconds:{milliseconds:1e3}},lr={years:{quarters:4,months:12,weeks:52,days:365,hours:365*24,minutes:365*24*60,seconds:365*24*60*60,milliseconds:365*24*60*60*1e3},quarters:{months:3,weeks:13,days:91,hours:2184,minutes:2184*60,seconds:2184*60*60,milliseconds:2184*60*60*1e3},months:{weeks:4,days:30,hours:720,minutes:720*60,seconds:720*60*60,milliseconds:720*60*60*1e3},...cr},G=146097/400,ur=146097/4800,dr={years:{quarters:4,months:12,weeks:G/7,days:G,hours:G*24,minutes:G*24*60,seconds:G*24*60*60,milliseconds:G*24*60*60*1e3},quarters:{months:3,weeks:G/28,days:G/4,hours:G*24/4,minutes:G*24*60/4,seconds:G*24*60*60/4,milliseconds:G*24*60*60*1e3/4},months:{weeks:ur/7,days:ur,hours:ur*24,minutes:ur*24*60,seconds:ur*24*60*60,milliseconds:ur*24*60*60*1e3},...cr},K=[`years`,`quarters`,`months`,`weeks`,`days`,`hours`,`minutes`,`seconds`,`milliseconds`],fr=K.slice(0).reverse();function q(e,t,n=!1){return new J({values:n?t.values:{...e.values,...t.values||{}},loc:e.loc.clone(t.loc),conversionAccuracy:t.conversionAccuracy||e.conversionAccuracy,matrix:t.matrix||e.matrix})}function pr(e,t){let n=t.milliseconds??0;for(let r of fr.slice(1))t[r]&&(n+=t[r]*e[r].milliseconds);return n}function mr(e,t){let n=pr(e,t)<0?-1:1;K.reduceRight((r,i)=>{if(M(t[i]))return r;if(r){let a=t[r]*n,o=e[i][r],s=Math.floor(a/o);t[i]+=s*n,t[r]-=s*o*n}return i},null),K.reduce((n,r)=>{if(M(t[r]))return n;if(n){let i=t[n]%1;t[n]-=i,t[r]+=i*e[n][r]}return r},null)}function hr(e){let t={};for(let[n,r]of Object.entries(e))r!==0&&(t[n]=r);return t}var J=class e{constructor(e){let t=e.conversionAccuracy===`longterm`||!1,n=t?dr:lr;e.matrix&&(n=e.matrix),this.values=e.values,this.loc=e.loc||T.create(),this.conversionAccuracy=t?`longterm`:`casual`,this.invalid=e.invalid||null,this.matrix=n,this.isLuxonDuration=!0}static fromMillis(t,n){return e.fromObject({milliseconds:t},n)}static fromObject(t,n={}){if(typeof t!=`object`||!t)throw new s(`Duration.fromObject: argument expected to be an object, got ${t===null?`null`:typeof t}`);return new e({values:Vt(t,e.normalizeUnit),loc:T.fromObject(n),conversionAccuracy:n.conversionAccuracy,matrix:n.matrix})}static fromDurationLike(t){if(N(t))return e.fromMillis(t);if(e.isDuration(t))return t;if(typeof t==`object`)return e.fromObject(t);throw new s(`Unknown duration argument ${t} of type ${typeof t}`)}static fromISO(t,n){let[r]=er(t);return r?e.fromObject(r,n):e.invalid(`unparsable`,`the input "${t}" can't be parsed as ISO 8601`)}static fromISOTime(t,n){let[r]=nr(t);return r?e.fromObject(r,n):e.invalid(`unparsable`,`the input "${t}" can't be parsed as ISO 8601`)}static invalid(t,n=null){if(!t)throw new s(`need to specify a reason the Duration is invalid`);let r=t instanceof A?t:new A(t,n);if(k.throwOnInvalid)throw new i(r);return new e({invalid:r})}static normalizeUnit(e){let t={year:`years`,years:`years`,quarter:`quarters`,quarters:`quarters`,month:`months`,months:`months`,week:`weeks`,weeks:`weeks`,day:`days`,days:`days`,hour:`hours`,hours:`hours`,minute:`minutes`,minutes:`minutes`,second:`seconds`,seconds:`seconds`,millisecond:`milliseconds`,milliseconds:`milliseconds`}[e&&e.toLowerCase()];if(!t)throw new o(e);return t}static isDuration(e){return e&&e.isLuxonDuration||!1}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(e,t={}){let n={...t,floor:t.round!==!1&&t.floor!==!1};return this.isValid?B.create(this.loc,n).formatDurationFromString(this,e):sr}toHuman(e={}){if(!this.isValid)return sr;let t=e.showZeros!==!1,n=K.map(n=>{let r=this.values[n];return M(r)||r===0&&!t?null:this.loc.numberFormatter({style:`unit`,unitDisplay:`long`,...e,unit:n.slice(0,-1)}).format(r)}).filter(e=>e);return this.loc.listFormatter({type:`conjunction`,style:e.listStyle||`narrow`,...e}).format(n)}toObject(){return this.isValid?{...this.values}:{}}toISO(){if(!this.isValid)return null;let e=`P`;return this.years!==0&&(e+=this.years+`Y`),(this.months!==0||this.quarters!==0)&&(e+=this.months+this.quarters*3+`M`),this.weeks!==0&&(e+=this.weeks+`W`),this.days!==0&&(e+=this.days+`D`),(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)&&(e+=`T`),this.hours!==0&&(e+=this.hours+`H`),this.minutes!==0&&(e+=this.minutes+`M`),(this.seconds!==0||this.milliseconds!==0)&&(e+=jt(this.seconds+this.milliseconds/1e3,3)+`S`),e===`P`&&(e+=`T0S`),e}toISOTime(e={}){if(!this.isValid)return null;let t=this.toMillis();return t<0||t>=864e5?null:(e={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:`extended`,...e,includeOffset:!1},$.fromMillis(t,{zone:`UTC`}).toISOTime(e))}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.isValid?`Duration { values: ${JSON.stringify(this.values)} }`:`Duration { Invalid, reason: ${this.invalidReason} }`}toMillis(){return this.isValid?pr(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(t){if(!this.isValid)return this;let n=e.fromDurationLike(t),r={};for(let e of K)(P(n.values,e)||P(this.values,e))&&(r[e]=n.get(e)+this.get(e));return q(this,{values:r},!0)}minus(t){if(!this.isValid)return this;let n=e.fromDurationLike(t);return this.plus(n.negate())}mapUnits(e){if(!this.isValid)return this;let t={};for(let n of Object.keys(this.values))t[n]=Bt(e(this.values[n],n));return q(this,{values:t},!0)}get(t){return this[e.normalizeUnit(t)]}set(t){if(!this.isValid)return this;let n={...this.values,...Vt(t,e.normalizeUnit)};return q(this,{values:n})}reconfigure({locale:e,numberingSystem:t,conversionAccuracy:n,matrix:r}={}){let i={loc:this.loc.clone({locale:e,numberingSystem:t}),matrix:r,conversionAccuracy:n};return q(this,i)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;let e=this.toObject();return mr(this.matrix,e),q(this,{values:e},!0)}rescale(){if(!this.isValid)return this;let e=hr(this.normalize().shiftToAll().toObject());return q(this,{values:e},!0)}shiftTo(...t){if(!this.isValid||t.length===0)return this;t=t.map(t=>e.normalizeUnit(t));let n={},r={},i=this.toObject(),a;for(let e of K)if(t.indexOf(e)>=0){a=e;let t=0;for(let n in r)t+=this.matrix[n][e]*r[n],r[n]=0;N(i[e])&&(t+=i[e]);let o=Math.trunc(t);n[e]=o,r[e]=(t*1e3-o*1e3)/1e3}else N(i[e])&&(r[e]=i[e]);for(let e in r)r[e]!==0&&(n[a]+=e===a?r[e]:r[e]/this.matrix[a][e]);return mr(this.matrix,n),q(this,{values:n},!0)}shiftToAll(){return this.isValid?this.shiftTo(`years`,`months`,`weeks`,`days`,`hours`,`minutes`,`seconds`,`milliseconds`):this}negate(){if(!this.isValid)return this;let e={};for(let t of Object.keys(this.values))e[t]=this.values[t]===0?0:-this.values[t];return q(this,{values:e},!0)}removeZeros(){if(!this.isValid)return this;let e=hr(this.values);return q(this,{values:e},!0)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(e){if(!this.isValid||!e.isValid||!this.loc.equals(e.loc))return!1;function t(e,t){return e===void 0||e===0?t===void 0||t===0:e===t}for(let n of K)if(!t(this.values[n],e.values[n]))return!1;return!0}},gr=`Invalid Interval`;function _r(e,t){return!e||!e.isValid?vr.invalid(`missing or invalid start`):!t||!t.isValid?vr.invalid(`missing or invalid end`):t<e?vr.invalid(`end before start`,`The end of an interval must be after its start, but you had start=${e.toISO()} and end=${t.toISO()}`):null}var vr=class e{constructor(e){this.s=e.start,this.e=e.end,this.invalid=e.invalid||null,this.isLuxonInterval=!0}static invalid(t,n=null){if(!t)throw new s(`need to specify a reason the Interval is invalid`);let i=t instanceof A?t:new A(t,n);if(k.throwOnInvalid)throw new r(i);return new e({invalid:i})}static fromDateTimes(t,n){let r=_i(t),i=_i(n);return _r(r,i)??new e({start:r,end:i})}static after(t,n){let r=J.fromDurationLike(n),i=_i(t);return e.fromDateTimes(i,i.plus(r))}static before(t,n){let r=J.fromDurationLike(n),i=_i(t);return e.fromDateTimes(i.minus(r),i)}static fromISO(t,n){let[r,i]=(t||``).split(`/`,2);if(r&&i){let t,a;try{t=$.fromISO(r,n),a=t.isValid}catch{a=!1}let o,s;try{o=$.fromISO(i,n),s=o.isValid}catch{s=!1}if(a&&s)return e.fromDateTimes(t,o);if(a){let r=J.fromISO(i,n);if(r.isValid)return e.after(t,r)}else if(s){let t=J.fromISO(r,n);if(t.isValid)return e.before(o,t)}}return e.invalid(`unparsable`,`the input "${t}" can't be parsed as ISO 8601`)}static isInterval(e){return e&&e.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get lastDateTime(){return this.isValid&&this.e?this.e.minus(1):null}get isValid(){return this.invalidReason===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(e=`milliseconds`){return this.isValid?this.toDuration(e).get(e):NaN}count(e=`milliseconds`,t){if(!this.isValid)return NaN;let n=this.start.startOf(e,t),r;return r=t!=null&&t.useLocaleWeeks?this.end.reconfigure({locale:n.locale}):this.end,r=r.startOf(e,t),Math.floor(r.diff(n,e).get(e))+(r.valueOf()!==this.end.valueOf())}hasSame(e){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,e):!1}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(e){return this.isValid?this.s>e:!1}isBefore(e){return this.isValid?this.e<=e:!1}contains(e){return this.isValid?this.s<=e&&this.e>e:!1}set({start:t,end:n}={}){return this.isValid?e.fromDateTimes(t||this.s,n||this.e):this}splitAt(...t){if(!this.isValid)return[];let n=t.map(_i).filter(e=>this.contains(e)).sort((e,t)=>e.toMillis()-t.toMillis()),r=[],{s:i}=this,a=0;for(;i<this.e;){let t=n[a]||this.e,o=+t>+this.e?this.e:t;r.push(e.fromDateTimes(i,o)),i=o,a+=1}return r}splitBy(t){let n=J.fromDurationLike(t);if(!this.isValid||!n.isValid||n.as(`milliseconds`)===0)return[];let{s:r}=this,i=1,a,o=[];for(;r<this.e;){let t=this.start.plus(n.mapUnits(e=>e*i));a=+t>+this.e?this.e:t,o.push(e.fromDateTimes(r,a)),r=a,i+=1}return o}divideEqually(e){return this.isValid?this.splitBy(this.length()/e).slice(0,e):[]}overlaps(e){return this.e>e.s&&this.s<e.e}abutsStart(e){return this.isValid?+this.e==+e.s:!1}abutsEnd(e){return this.isValid?+e.e==+this.s:!1}engulfs(e){return this.isValid?this.s<=e.s&&this.e>=e.e:!1}equals(e){return!this.isValid||!e.isValid?!1:this.s.equals(e.s)&&this.e.equals(e.e)}intersection(t){if(!this.isValid)return this;let n=this.s>t.s?this.s:t.s,r=this.e<t.e?this.e:t.e;return n>=r?null:e.fromDateTimes(n,r)}union(t){if(!this.isValid)return this;let n=this.s<t.s?this.s:t.s,r=this.e>t.e?this.e:t.e;return e.fromDateTimes(n,r)}static merge(e){let[t,n]=e.sort((e,t)=>e.s-t.s).reduce(([e,t],n)=>t?t.overlaps(n)||t.abutsStart(n)?[e,t.union(n)]:[e.concat([t]),n]:[e,n],[[],null]);return n&&t.push(n),t}static xor(t){let n=null,r=0,i=[],a=t.map(e=>[{time:e.s,type:`s`},{time:e.e,type:`e`}]),o=Array.prototype.concat(...a).sort((e,t)=>e.time-t.time);for(let t of o)r+=t.type===`s`?1:-1,r===1?n=t.time:(n&&+n!=+t.time&&i.push(e.fromDateTimes(n,t.time)),n=null);return e.merge(i)}difference(...t){return e.xor([this].concat(t)).map(e=>this.intersection(e)).filter(e=>e&&!e.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} – ${this.e.toISO()})`:gr}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.isValid?`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`:`Interval { Invalid, reason: ${this.invalidReason} }`}toLocaleString(e=f,t={}){return this.isValid?B.create(this.s.loc.clone(t),e).formatInterval(this):gr}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:gr}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:gr}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:gr}toFormat(e,{separator:t=` – `}={}){return this.isValid?`${this.s.toFormat(e)}${t}${this.e.toFormat(e)}`:gr}toDuration(e,t){return this.isValid?this.e.diff(this.s,e,t):J.invalid(this.invalidReason)}mapEndpoints(t){return e.fromDateTimes(t(this.s),t(this.e))}},yr=class{static hasDST(e=k.defaultZone){let t=$.now().setZone(e).set({month:12});return!e.isUniversal&&t.offset!==t.set({month:6}).offset}static isValidIANAZone(e){return w.isValidZone(e)}static normalizeZone(e){return D(e,k.defaultZone)}static getStartOfWeek({locale:e=null,locObj:t=null}={}){return(t||T.create(e)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:e=null,locObj:t=null}={}){return(t||T.create(e)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:e=null,locObj:t=null}={}){return(t||T.create(e)).getWeekendDays().slice()}static months(e=`long`,{locale:t=null,numberingSystem:n=null,locObj:r=null,outputCalendar:i=`gregory`}={}){return(r||T.create(t,n,i)).months(e)}static monthsFormat(e=`long`,{locale:t=null,numberingSystem:n=null,locObj:r=null,outputCalendar:i=`gregory`}={}){return(r||T.create(t,n,i)).months(e,!0)}static weekdays(e=`long`,{locale:t=null,numberingSystem:n=null,locObj:r=null}={}){return(r||T.create(t,n,null)).weekdays(e)}static weekdaysFormat(e=`long`,{locale:t=null,numberingSystem:n=null,locObj:r=null}={}){return(r||T.create(t,n,null)).weekdays(e,!0)}static meridiems({locale:e=null}={}){return T.create(e).meridiems()}static eras(e=`short`,{locale:t=null}={}){return T.create(t,null,`gregory`).eras(e)}static features(){return{relative:Ct(),localeWeek:wt()}}};function br(e,t){let n=e=>e.toUTC(0,{keepLocalTime:!0}).startOf(`day`).valueOf(),r=n(t)-n(e);return Math.floor(J.fromMillis(r).as(`days`))}function xr(e,t,n){let r=[[`years`,(e,t)=>t.year-e.year],[`quarters`,(e,t)=>t.quarter-e.quarter+(t.year-e.year)*4],[`months`,(e,t)=>t.month-e.month+(t.year-e.year)*12],[`weeks`,(e,t)=>{let n=br(e,t);return(n-n%7)/7}],[`days`,br]],i={},a=e,o,s;for(let[c,l]of r)n.indexOf(c)>=0&&(o=c,i[c]=l(e,t),s=a.plus(i),s>t?(i[c]--,e=a.plus(i),e>t&&(s=e,i[c]--,e=a.plus(i))):e=s);return[e,i,s,o]}function Sr(e,t,n,r){let[i,a,o,s]=xr(e,t,n),c=t-i,l=n.filter(e=>[`hours`,`minutes`,`seconds`,`milliseconds`].indexOf(e)>=0);l.length===0&&(o<t&&(o=i.plus({[s]:1})),o!==i&&(a[s]=(a[s]||0)+c/(o-i)));let u=J.fromObject(a,r);return l.length>0?J.fromMillis(c,r).shiftTo(...l).plus(u):u}var Cr=`missing Intl.DateTimeFormat.formatToParts support`;function Y(e,t=e=>e){return{regex:e,deser:([e])=>t(Je(e))}}var wr=`[ \xA0]`,Tr=new RegExp(wr,`g`);function Er(e){return e.replace(/\./g,`\\.?`).replace(Tr,wr)}function Dr(e){return e.replace(/\./g,``).replace(Tr,` `).toLowerCase()}function X(e,t){return e===null?null:{regex:RegExp(e.map(Er).join(`|`)),deser:([n])=>e.findIndex(e=>Dr(n)===Dr(e))+t}}function Or(e,t){return{regex:e,deser:([,e,t])=>zt(e,t),groups:t}}function kr(e){return{regex:e,deser:([e])=>e}}function Ar(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,`\\$&`)}function jr(e,t){let n=O(t),r=O(t,`{2}`),i=O(t,`{3}`),a=O(t,`{4}`),o=O(t,`{6}`),s=O(t,`{1,2}`),c=O(t,`{1,3}`),l=O(t,`{1,6}`),u=O(t,`{1,9}`),d=O(t,`{2,4}`),f=O(t,`{4,6}`),p=e=>({regex:RegExp(Ar(e.val)),deser:([e])=>e,literal:!0}),m=(m=>{if(e.literal)return p(m);switch(m.val){case`G`:return X(t.eras(`short`),0);case`GG`:return X(t.eras(`long`),0);case`y`:return Y(l);case`yy`:return Y(d,Lt);case`yyyy`:return Y(a);case`yyyyy`:return Y(f);case`yyyyyy`:return Y(o);case`M`:return Y(s);case`MM`:return Y(r);case`MMM`:return X(t.months(`short`,!0),1);case`MMMM`:return X(t.months(`long`,!0),1);case`L`:return Y(s);case`LL`:return Y(r);case`LLL`:return X(t.months(`short`,!1),1);case`LLLL`:return X(t.months(`long`,!1),1);case`d`:return Y(s);case`dd`:return Y(r);case`o`:return Y(c);case`ooo`:return Y(i);case`HH`:return Y(r);case`H`:return Y(s);case`hh`:return Y(r);case`h`:return Y(s);case`mm`:return Y(r);case`m`:return Y(s);case`q`:return Y(s);case`qq`:return Y(r);case`s`:return Y(s);case`ss`:return Y(r);case`S`:return Y(c);case`SSS`:return Y(i);case`u`:return kr(u);case`uu`:return kr(s);case`uuu`:return Y(n);case`a`:return X(t.meridiems(),0);case`kkkk`:return Y(a);case`kk`:return Y(d,Lt);case`W`:return Y(s);case`WW`:return Y(r);case`E`:case`c`:return Y(n);case`EEE`:return X(t.weekdays(`short`,!1),1);case`EEEE`:return X(t.weekdays(`long`,!1),1);case`ccc`:return X(t.weekdays(`short`,!0),1);case`cccc`:return X(t.weekdays(`long`,!0),1);case`Z`:case`ZZ`:return Or(RegExp(`([+-]${s.source})(?::(${r.source}))?`),2);case`ZZZ`:return Or(RegExp(`([+-]${s.source})(${r.source})?`),2);case`z`:return kr(/[a-z_+-/]{1,256}?/i);case` `:return kr(/[^\S\n\r]/);default:return p(m)}})(e)||{invalidReason:Cr};return m.token=e,m}var Mr={year:{"2-digit":`yy`,numeric:`yyyyy`},month:{numeric:`M`,"2-digit":`MM`,short:`MMM`,long:`MMMM`},day:{numeric:`d`,"2-digit":`dd`},weekday:{short:`EEE`,long:`EEEE`},dayperiod:`a`,dayPeriod:`a`,hour12:{numeric:`h`,"2-digit":`hh`},hour24:{numeric:`H`,"2-digit":`HH`},minute:{numeric:`m`,"2-digit":`mm`},second:{numeric:`s`,"2-digit":`ss`},timeZoneName:{long:`ZZZZZ`,short:`ZZZ`}};function Nr(e,t,n){let{type:r,value:i}=e;if(r===`literal`){let e=/^\s+$/.test(i);return{literal:!e,val:e?` `:i}}let a=t[r],o=r;r===`hour`&&(o=t.hour12==null?t.hourCycle==null?n.hour12?`hour12`:`hour24`:t.hourCycle===`h11`||t.hourCycle===`h12`?`hour12`:`hour24`:t.hour12?`hour12`:`hour24`);let s=Mr[o];if(typeof s==`object`&&(s=s[a]),s)return{literal:!1,val:s}}function Pr(e){return[`^${e.map(e=>e.regex).reduce((e,t)=>`${e}(${t.source})`,``)}$`,e]}function Fr(e,t,n){let r=e.match(t);if(r){let e={},t=1;for(let i in n)if(P(n,i)){let a=n[i],o=a.groups?a.groups+1:1;!a.literal&&a.token&&(e[a.token.val[0]]=a.deser(r.slice(t,t+o))),t+=o}return[r,e]}else return[r,{}]}function Ir(e){let t=e=>{switch(e){case`S`:return`millisecond`;case`s`:return`second`;case`m`:return`minute`;case`h`:case`H`:return`hour`;case`d`:return`day`;case`o`:return`ordinal`;case`L`:case`M`:return`month`;case`y`:return`year`;case`E`:case`c`:return`weekday`;case`W`:return`weekNumber`;case`k`:return`weekYear`;case`q`:return`quarter`;default:return null}},n=null,r;return M(e.z)||(n=w.create(e.z)),M(e.Z)||(n||=new E(e.Z),r=e.Z),M(e.q)||(e.M=(e.q-1)*3+1),M(e.h)||(e.h<12&&e.a===1?e.h+=12:e.h===12&&e.a===0&&(e.h=0)),e.G===0&&e.y&&(e.y=-e.y),M(e.u)||(e.S=At(e.u)),[Object.keys(e).reduce((n,r)=>{let i=t(r);return i&&(n[i]=e[r]),n},{}),n,r]}var Lr=null;function Rr(){return Lr||=$.fromMillis(1555555555555),Lr}function zr(e,t){if(e.literal)return e;let n=Wr(B.macroTokenToFormatOpts(e.val),t);return n==null||n.includes(void 0)?e:n}function Br(e,t){return Array.prototype.concat(...e.map(e=>zr(e,t)))}var Vr=class{constructor(e,t){if(this.locale=e,this.format=t,this.tokens=Br(B.parseFormat(t),e),this.units=this.tokens.map(t=>jr(t,e)),this.disqualifyingUnit=this.units.find(e=>e.invalidReason),!this.disqualifyingUnit){let[e,t]=Pr(this.units);this.regex=RegExp(e,`i`),this.handlers=t}}explainFromTokens(e){if(this.isValid){let[t,n]=Fr(e,this.regex,this.handlers),[r,i,o]=n?Ir(n):[null,null,void 0];if(P(n,`a`)&&P(n,`H`))throw new a(`Can't include meridiem when specifying 24-hour format`);return{input:e,tokens:this.tokens,regex:this.regex,rawMatches:t,matches:n,result:r,zone:i,specificOffset:o}}else return{input:e,tokens:this.tokens,invalidReason:this.invalidReason}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}};function Hr(e,t,n){return new Vr(e,n).explainFromTokens(t)}function Ur(e,t,n){let{result:r,zone:i,specificOffset:a,invalidReason:o}=Hr(e,t,n);return[r,i,a,o]}function Wr(e,t){if(!e)return null;let n=B.create(t,e).dtFormatter(Rr()),r=n.formatToParts(),i=n.resolvedOptions();return r.map(t=>Nr(t,e,i))}var Gr=`Invalid DateTime`,Kr=864e13;function qr(e){return new A(`unsupported zone`,`the zone "${e.name}" is not supported`)}function Jr(e){return e.weekData===null&&(e.weekData=dt(e.c)),e.weekData}function Yr(e){return e.localWeekData===null&&(e.localWeekData=dt(e.c,e.loc.getMinDaysInFirstWeek(),e.loc.getStartOfWeek())),e.localWeekData}function Z(e,t){let n={ts:e.ts,zone:e.zone,c:e.c,o:e.o,loc:e.loc,invalid:e.invalid};return new $({...n,...t,old:n})}function Xr(e,t,n){let r=e-t*60*1e3,i=n.offset(r);if(t===i)return[r,t];r-=(i-t)*60*1e3;let a=n.offset(r);return i===a?[r,i]:[e-Math.min(i,a)*60*1e3,Math.max(i,a)]}function Zr(e,t){e+=t*60*1e3;let n=new Date(e);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:n.getUTCHours(),minute:n.getUTCMinutes(),second:n.getUTCSeconds(),millisecond:n.getUTCMilliseconds()}}function Qr(e,t,n){return Xr(Pt(e),t,n)}function $r(e,t){let n=e.o,r=e.c.year+Math.trunc(t.years),i=e.c.month+Math.trunc(t.months)+Math.trunc(t.quarters)*3,a={...e.c,year:r,month:i,day:Math.min(e.c.day,Nt(r,i))+Math.trunc(t.days)+Math.trunc(t.weeks)*7},o=J.fromObject({years:t.years-Math.trunc(t.years),quarters:t.quarters-Math.trunc(t.quarters),months:t.months-Math.trunc(t.months),weeks:t.weeks-Math.trunc(t.weeks),days:t.days-Math.trunc(t.days),hours:t.hours,minutes:t.minutes,seconds:t.seconds,milliseconds:t.milliseconds}).as(`milliseconds`),[s,c]=Xr(Pt(a),n,e.zone);return o!==0&&(s+=o,c=e.zone.offset(s)),{ts:s,o:c}}function Q(e,t,n,r,i,a){let{setZone:o,zone:s}=n;if(e&&Object.keys(e).length!==0||t){let r=t||s,i=$.fromObject(e,{...n,zone:r,specificOffset:a});return o?i:i.setZone(s)}else return $.invalid(new A(`unparsable`,`the input "${i}" can't be parsed as ${r}`))}function ei(e,t,n=!0){return e.isValid?B.create(T.create(`en-US`),{allowZ:n,forceSimple:!0}).formatDateTimeFromString(e,t):null}function ti(e,t,n){let r=e.c.year>9999||e.c.year<0,i=``;if(r&&e.c.year>=0&&(i+=`+`),i+=I(e.c.year,r?6:4),n===`year`)return i;if(t){if(i+=`-`,i+=I(e.c.month),n===`month`)return i;i+=`-`}else if(i+=I(e.c.month),n===`month`)return i;return i+=I(e.c.day),i}function ni(e,t,n,r,i,a,o){let s=!n||e.c.millisecond!==0||e.c.second!==0,c=``;switch(o){case`day`:case`month`:case`year`:break;default:if(c+=I(e.c.hour),o===`hour`)break;if(t){if(c+=`:`,c+=I(e.c.minute),o===`minute`)break;s&&(c+=`:`,c+=I(e.c.second))}else{if(c+=I(e.c.minute),o===`minute`)break;s&&(c+=I(e.c.second))}if(o===`second`)break;s&&(!r||e.c.millisecond!==0)&&(c+=`.`,c+=I(e.c.millisecond,3))}return i&&(e.isOffsetFixed&&e.offset===0&&!a?c+=`Z`:e.o<0?(c+=`-`,c+=I(Math.trunc(-e.o/60)),c+=`:`,c+=I(Math.trunc(-e.o%60))):(c+=`+`,c+=I(Math.trunc(e.o/60)),c+=`:`,c+=I(Math.trunc(e.o%60)))),a&&(c+=`[`+e.zone.ianaName+`]`),c}var ri={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},ii={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},ai={ordinal:1,hour:0,minute:0,second:0,millisecond:0},oi=[`year`,`month`,`day`,`hour`,`minute`,`second`,`millisecond`],si=[`weekYear`,`weekNumber`,`weekday`,`hour`,`minute`,`second`,`millisecond`],ci=[`year`,`ordinal`,`hour`,`minute`,`second`,`millisecond`];function li(e){let t={year:`year`,years:`year`,month:`month`,months:`month`,day:`day`,days:`day`,hour:`hour`,hours:`hour`,minute:`minute`,minutes:`minute`,quarter:`quarter`,quarters:`quarter`,second:`second`,seconds:`second`,millisecond:`millisecond`,milliseconds:`millisecond`,weekday:`weekday`,weekdays:`weekday`,weeknumber:`weekNumber`,weeksnumber:`weekNumber`,weeknumbers:`weekNumber`,weekyear:`weekYear`,weekyears:`weekYear`,ordinal:`ordinal`}[e.toLowerCase()];if(!t)throw new o(e);return t}function ui(e){switch(e.toLowerCase()){case`localweekday`:case`localweekdays`:return`localWeekday`;case`localweeknumber`:case`localweeknumbers`:return`localWeekNumber`;case`localweekyear`:case`localweekyears`:return`localWeekYear`;default:return li(e)}}function di(e){if(hi===void 0&&(hi=k.now()),e.type!==`iana`)return e.offset(hi);let t=e.name,n=gi.get(t);return n===void 0&&(n=e.offset(hi),gi.set(t,n)),n}function fi(e,t){let n=D(t.zone,k.defaultZone);if(!n.isValid)return $.invalid(qr(n));let r=T.fromObject(t),i,a;if(M(e.year))i=k.now();else{for(let t of oi)M(e[t])&&(e[t]=ri[t]);let t=vt(e)||yt(e);if(t)return $.invalid(t);let r=di(n);[i,a]=Qr(e,r,n)}return new $({ts:i,zone:n,loc:r,o:a})}function pi(e,t,n){let r=M(n.round)?!0:n.round,i=M(n.rounding)?`trunc`:n.rounding,a=(e,a)=>(e=jt(e,r||n.calendary?0:2,n.calendary?`round`:i),t.loc.clone(n).relFormatter(n).format(e,a)),o=r=>n.calendary?t.hasSame(e,r)?0:t.startOf(r).diff(e.startOf(r),r).get(r):t.diff(e,r).get(r);if(n.unit)return a(o(n.unit),n.unit);for(let e of n.units){let t=o(e);if(Math.abs(t)>=1)return a(t,e)}return a(e>t?-0:0,n.units[n.units.length-1])}function mi(e){let t={},n;return e.length>0&&typeof e[e.length-1]==`object`?(t=e[e.length-1],n=Array.from(e).slice(0,e.length-1)):n=Array.from(e),[t,n]}var hi,gi=new Map,$=class e{constructor(e){let t=e.zone||k.defaultZone,n=e.invalid||(Number.isNaN(e.ts)?new A(`invalid input`):null)||(t.isValid?null:qr(t));this.ts=M(e.ts)?k.now():e.ts;let r=null,i=null;if(!n)if(e.old&&e.old.ts===this.ts&&e.old.zone.equals(t))[r,i]=[e.old.c,e.old.o];else{let a=N(e.o)&&!e.old?e.o:t.offset(this.ts);r=Zr(this.ts,a),n=Number.isNaN(r.year)?new A(`invalid input`):null,r=n?null:r,i=n?null:a}this._zone=t,this.loc=e.loc||T.create(),this.invalid=n,this.weekData=null,this.localWeekData=null,this.c=r,this.o=i,this.isLuxonDateTime=!0}static now(){return new e({})}static local(){let[e,t]=mi(arguments),[n,r,i,a,o,s,c]=t;return fi({year:n,month:r,day:i,hour:a,minute:o,second:s,millisecond:c},e)}static utc(){let[e,t]=mi(arguments),[n,r,i,a,o,s,c]=t;return e.zone=E.utcInstance,fi({year:n,month:r,day:i,hour:a,minute:o,second:s,millisecond:c},e)}static fromJSDate(t,n={}){let r=St(t)?t.valueOf():NaN;if(Number.isNaN(r))return e.invalid(`invalid input`);let i=D(n.zone,k.defaultZone);return i.isValid?new e({ts:r,zone:i,loc:T.fromObject(n)}):e.invalid(qr(i))}static fromMillis(t,n={}){if(!N(t))throw new s(`fromMillis requires a numerical input, but received a ${typeof t} with value ${t}`);return t<-864e13||t>Kr?e.invalid(`Timestamp out of range`):new e({ts:t,zone:D(n.zone,k.defaultZone),loc:T.fromObject(n)})}static fromSeconds(t,n={}){if(N(t))return new e({ts:t*1e3,zone:D(n.zone,k.defaultZone),loc:T.fromObject(n)});throw new s(`fromSeconds requires a numerical input`)}static fromObject(t,n={}){t||={};let r=D(n.zone,k.defaultZone);if(!r.isValid)return e.invalid(qr(r));let i=T.fromObject(n),o=Vt(t,ui),{minDaysInFirstWeek:s,startOfWeek:c}=ht(o,i),l=k.now(),u=M(n.specificOffset)?r.offset(l):n.specificOffset,d=!M(o.ordinal),f=!M(o.year),p=!M(o.month)||!M(o.day),m=f||p,h=o.weekYear||o.weekNumber;if((m||d)&&h)throw new a(`Can't mix weekYear/weekNumber units with year/month/day or ordinals`);if(p&&d)throw new a(`Can't mix ordinal dates with month/day`);let g=h||o.weekday&&!m,_,v,y=Zr(l,u);g?(_=si,v=ii,y=dt(y,s,c)):d?(_=ci,v=ai,y=pt(y)):(_=oi,v=ri);let b=!1;for(let e of _){let t=o[e];M(t)?b?o[e]=v[e]:o[e]=y[e]:b=!0}let x=(g?gt(o,s,c):d?_t(o):vt(o))||yt(o);if(x)return e.invalid(x);let[ee,te]=Qr(g?ft(o,s,c):d?mt(o):o,u,r),S=new e({ts:ee,zone:r,o:te,loc:i});return o.weekday&&m&&t.weekday!==S.weekday?e.invalid(`mismatched weekday`,`you can't specify both a weekday of ${o.weekday} and a date of ${S.toISO()}`):S.isValid?S:e.invalid(S.invalid)}static fromISO(e,t={}){let[n,r]=Zn(e);return Q(n,r,t,`ISO 8601`,e)}static fromRFC2822(e,t={}){let[n,r]=Qn(e);return Q(n,r,t,`RFC 2822`,e)}static fromHTTP(e,t={}){let[n,r]=$n(e);return Q(n,r,t,`HTTP`,t)}static fromFormat(t,n,r={}){if(M(t)||M(n))throw new s(`fromFormat requires an input string and a format`);let{locale:i=null,numberingSystem:a=null}=r,[o,c,l,u]=Ur(T.fromOpts({locale:i,numberingSystem:a,defaultToEN:!0}),t,n);return u?e.invalid(u):Q(o,c,r,`format ${n}`,t,l)}static fromString(t,n,r={}){return e.fromFormat(t,n,r)}static fromSQL(e,t={}){let[n,r]=or(e);return Q(n,r,t,`SQL`,e)}static invalid(t,r=null){if(!t)throw new s(`need to specify a reason the DateTime is invalid`);let i=t instanceof A?t:new A(t,r);if(k.throwOnInvalid)throw new n(i);return new e({invalid:i})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,t={}){let n=Wr(e,T.fromObject(t));return n?n.map(e=>e?e.val:null).join(``):null}static expandFormat(e,t={}){return Br(B.parseFormat(e),T.fromObject(t)).map(e=>e.val).join(``)}static resetCache(){hi=void 0,gi.clear()}get(e){return this[e]}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this._zone}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?Jr(this).weekYear:NaN}get weekNumber(){return this.isValid?Jr(this).weekNumber:NaN}get weekday(){return this.isValid?Jr(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?Yr(this).weekday:NaN}get localWeekNumber(){return this.isValid?Yr(this).weekNumber:NaN}get localWeekYear(){return this.isValid?Yr(this).weekYear:NaN}get ordinal(){return this.isValid?pt(this.c).ordinal:NaN}get monthShort(){return this.isValid?yr.months(`short`,{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?yr.months(`long`,{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?yr.weekdays(`short`,{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?yr.weekdays(`long`,{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){return this.isValid?this.zone.offsetName(this.ts,{format:`short`,locale:this.locale}):null}get offsetNameLong(){return this.isValid?this.zone.offsetName(this.ts,{format:`long`,locale:this.locale}):null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){return this.isOffsetFixed?!1:this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed)return[this];let e=864e5,t=6e4,n=Pt(this.c),r=this.zone.offset(n-e),i=this.zone.offset(n+e),a=this.zone.offset(n-r*t),o=this.zone.offset(n-i*t);if(a===o)return[this];let s=n-a*t,c=n-o*t,l=Zr(s,a),u=Zr(c,o);return l.hour===u.hour&&l.minute===u.minute&&l.second===u.second&&l.millisecond===u.millisecond?[Z(this,{ts:s}),Z(this,{ts:c})]:[this]}get isInLeapYear(){return Mt(this.year)}get daysInMonth(){return Nt(this.year,this.month)}get daysInYear(){return this.isValid?z(this.year):NaN}get weeksInWeekYear(){return this.isValid?It(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?It(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(e={}){let{locale:t,numberingSystem:n,calendar:r}=B.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:t,numberingSystem:n,outputCalendar:r}}toUTC(e=0,t={}){return this.setZone(E.instance(e),t)}toLocal(){return this.setZone(k.defaultZone)}setZone(t,{keepLocalTime:n=!1,keepCalendarTime:r=!1}={}){if(t=D(t,k.defaultZone),t.equals(this.zone))return this;if(t.isValid){let e=this.ts;if(n||r){let n=t.offset(this.ts),r=this.toObject();[e]=Qr(r,n,t)}return Z(this,{ts:e,zone:t})}else return e.invalid(qr(t))}reconfigure({locale:e,numberingSystem:t,outputCalendar:n}={}){let r=this.loc.clone({locale:e,numberingSystem:t,outputCalendar:n});return Z(this,{loc:r})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;let t=Vt(e,ui),{minDaysInFirstWeek:n,startOfWeek:r}=ht(t,this.loc),i=!M(t.weekYear)||!M(t.weekNumber)||!M(t.weekday),o=!M(t.ordinal),s=!M(t.year),c=!M(t.month)||!M(t.day),l=s||c,u=t.weekYear||t.weekNumber;if((l||o)&&u)throw new a(`Can't mix weekYear/weekNumber units with year/month/day or ordinals`);if(c&&o)throw new a(`Can't mix ordinal dates with month/day`);let d;i?d=ft({...dt(this.c,n,r),...t},n,r):M(t.ordinal)?(d={...this.toObject(),...t},M(t.day)&&(d.day=Math.min(Nt(d.year,d.month),d.day))):d=mt({...pt(this.c),...t});let[f,p]=Qr(d,this.o,this.zone);return Z(this,{ts:f,o:p})}plus(e){if(!this.isValid)return this;let t=J.fromDurationLike(e);return Z(this,$r(this,t))}minus(e){if(!this.isValid)return this;let t=J.fromDurationLike(e).negate();return Z(this,$r(this,t))}startOf(e,{useLocaleWeeks:t=!1}={}){if(!this.isValid)return this;let n={},r=J.normalizeUnit(e);switch(r){case`years`:n.month=1;case`quarters`:case`months`:n.day=1;case`weeks`:case`days`:n.hour=0;case`hours`:n.minute=0;case`minutes`:n.second=0;case`seconds`:n.millisecond=0;break}if(r===`weeks`)if(t){let e=this.loc.getStartOfWeek(),{weekday:t}=this;t<e&&(n.weekNumber=this.weekNumber-1),n.weekday=e}else n.weekday=1;return r===`quarters`&&(n.month=(Math.ceil(this.month/3)-1)*3+1),this.set(n)}endOf(e,t){return this.isValid?this.plus({[e]:1}).startOf(e,t).minus(1):this}toFormat(e,t={}){return this.isValid?B.create(this.loc.redefaultToEN(t)).formatDateTimeFromString(this,e):Gr}toLocaleString(e=f,t={}){return this.isValid?B.create(this.loc.clone(t),e).formatDateTime(this):Gr}toLocaleParts(e={}){return this.isValid?B.create(this.loc.clone(e),e).formatDateTimeParts(this):[]}toISO({format:e=`extended`,suppressSeconds:t=!1,suppressMilliseconds:n=!1,includeOffset:r=!0,extendedZone:i=!1,precision:a=`milliseconds`}={}){if(!this.isValid)return null;a=li(a);let o=e===`extended`,s=ti(this,o,a);return oi.indexOf(a)>=3&&(s+=`T`),s+=ni(this,o,t,n,r,i,a),s}toISODate({format:e=`extended`,precision:t=`day`}={}){return this.isValid?ti(this,e===`extended`,li(t)):null}toISOWeekDate(){return ei(this,`kkkk-'W'WW-c`)}toISOTime({suppressMilliseconds:e=!1,suppressSeconds:t=!1,includeOffset:n=!0,includePrefix:r=!1,extendedZone:i=!1,format:a=`extended`,precision:o=`milliseconds`}={}){return this.isValid?(o=li(o),(r&&oi.indexOf(o)>=3?`T`:``)+ni(this,a===`extended`,t,e,n,i,o)):null}toRFC2822(){return ei(this,`EEE, dd LLL yyyy HH:mm:ss ZZZ`,!1)}toHTTP(){return ei(this.toUTC(),`EEE, dd LLL yyyy HH:mm:ss 'GMT'`)}toSQLDate(){return this.isValid?ti(this,!0):null}toSQLTime({includeOffset:e=!0,includeZone:t=!1,includeOffsetSpace:n=!0}={}){let r=`HH:mm:ss.SSS`;return(t||e)&&(n&&(r+=` `),t?r+=`z`:e&&(r+=`ZZ`)),ei(this,r,!0)}toSQL(e={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(e)}`:null}toString(){return this.isValid?this.toISO():Gr}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.isValid?`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`:`DateTime { Invalid, reason: ${this.invalidReason} }`}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(e={}){if(!this.isValid)return{};let t={...this.c};return e.includeConfig&&(t.outputCalendar=this.outputCalendar,t.numberingSystem=this.loc.numberingSystem,t.locale=this.loc.locale),t}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(e,t=`milliseconds`,n={}){if(!this.isValid||!e.isValid)return J.invalid(`created by diffing an invalid DateTime`);let r={locale:this.locale,numberingSystem:this.numberingSystem,...n},i=Tt(t).map(J.normalizeUnit),a=e.valueOf()>this.valueOf(),o=Sr(a?this:e,a?e:this,i,r);return a?o.negate():o}diffNow(t=`milliseconds`,n={}){return this.diff(e.now(),t,n)}until(e){return this.isValid?vr.fromDateTimes(this,e):this}hasSame(e,t,n){if(!this.isValid)return!1;let r=e.valueOf(),i=this.setZone(e.zone,{keepLocalTime:!0});return i.startOf(t,n)<=r&&r<=i.endOf(t,n)}equals(e){return this.isValid&&e.isValid&&this.valueOf()===e.valueOf()&&this.zone.equals(e.zone)&&this.loc.equals(e.loc)}toRelative(t={}){if(!this.isValid)return null;let n=t.base||e.fromObject({},{zone:this.zone}),r=t.padding?this<n?-t.padding:t.padding:0,i=[`years`,`months`,`days`,`hours`,`minutes`,`seconds`],a=t.unit;return Array.isArray(t.unit)&&(i=t.unit,a=void 0),pi(n,this.plus(r),{...t,numeric:`always`,units:i,unit:a})}toRelativeCalendar(t={}){return this.isValid?pi(t.base||e.fromObject({},{zone:this.zone}),this,{...t,numeric:`auto`,units:[`years`,`months`,`days`],calendary:!0}):null}static min(...t){if(!t.every(e.isDateTime))throw new s(`min requires all arguments be DateTimes`);return Et(t,e=>e.valueOf(),Math.min)}static max(...t){if(!t.every(e.isDateTime))throw new s(`max requires all arguments be DateTimes`);return Et(t,e=>e.valueOf(),Math.max)}static fromFormatExplain(e,t,n={}){let{locale:r=null,numberingSystem:i=null}=n;return Hr(T.fromOpts({locale:r,numberingSystem:i,defaultToEN:!0}),e,t)}static fromStringExplain(t,n,r={}){return e.fromFormatExplain(t,n,r)}static buildFormatParser(e,t={}){let{locale:n=null,numberingSystem:r=null}=t;return new Vr(T.fromOpts({locale:n,numberingSystem:r,defaultToEN:!0}),e)}static fromFormatParser(t,n,r={}){if(M(t)||M(n))throw new s(`fromFormatParser requires an input string and a format parser`);let{locale:i=null,numberingSystem:a=null}=r,o=T.fromOpts({locale:i,numberingSystem:a,defaultToEN:!0});if(!o.equals(n.locale))throw new s(`fromFormatParser called with a locale of ${o}, but the format parser was created for ${n.locale}`);let{result:c,zone:l,specificOffset:u,invalidReason:d}=n.explainFromTokens(t);return d?e.invalid(d):Q(c,l,r,`format ${n.format}`,t,u)}static get DATE_SHORT(){return f}static get DATE_MED(){return p}static get DATE_MED_WITH_WEEKDAY(){return m}static get DATE_FULL(){return h}static get DATE_HUGE(){return g}static get TIME_SIMPLE(){return _}static get TIME_WITH_SECONDS(){return v}static get TIME_WITH_SHORT_OFFSET(){return y}static get TIME_WITH_LONG_OFFSET(){return b}static get TIME_24_SIMPLE(){return x}static get TIME_24_WITH_SECONDS(){return ee}static get TIME_24_WITH_SHORT_OFFSET(){return te}static get TIME_24_WITH_LONG_OFFSET(){return S}static get DATETIME_SHORT(){return ne}static get DATETIME_SHORT_WITH_SECONDS(){return re}static get DATETIME_MED(){return ie}static get DATETIME_MED_WITH_SECONDS(){return ae}static get DATETIME_MED_WITH_WEEKDAY(){return oe}static get DATETIME_FULL(){return se}static get DATETIME_FULL_WITH_SECONDS(){return ce}static get DATETIME_HUGE(){return le}static get DATETIME_HUGE_WITH_SECONDS(){return ue}};function _i(e){if($.isDateTime(e))return e;if(e&&e.valueOf&&N(e.valueOf()))return $.fromJSDate(e);if(e&&typeof e==`object`)return $.fromObject(e);throw new s(`Unknown datetime argument: ${e}, of type ${typeof e}`)}e.DateTime=$,e.Duration=J,e.FixedOffsetZone=E,e.IANAZone=w,e.Info=yr,e.Interval=vr,e.InvalidZone=We,e.Settings=k,e.SystemZone=fe,e.VERSION=`3.7.2`,e.Zone=C})),c=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CronDate=e.DAYS_IN_MONTH=e.DateMathOp=e.TimeUnit=void 0;var t=s(),n;(function(e){e.Second=`Second`,e.Minute=`Minute`,e.Hour=`Hour`,e.Day=`Day`,e.Month=`Month`,e.Year=`Year`})(n||(e.TimeUnit=n={}));var r;(function(e){e.Add=`Add`,e.Subtract=`Subtract`})(r||(e.DateMathOp=r={})),e.DAYS_IN_MONTH=Object.freeze([31,29,31,30,31,30,31,31,30,31,30,31]);var i=class i{#e;#t=null;#n=null;#r={add:{[n.Year]:this.addYear.bind(this),[n.Month]:this.addMonth.bind(this),[n.Day]:this.addDay.bind(this),[n.Hour]:this.addHour.bind(this),[n.Minute]:this.addMinute.bind(this),[n.Second]:this.addSecond.bind(this)},subtract:{[n.Year]:this.subtractYear.bind(this),[n.Month]:this.subtractMonth.bind(this),[n.Day]:this.subtractDay.bind(this),[n.Hour]:this.subtractHour.bind(this),[n.Minute]:this.subtractMinute.bind(this),[n.Second]:this.subtractSecond.bind(this)}};constructor(e,n){let r={zone:n};if(e?e instanceof i?(this.#e=e.#e,this.#t=e.#t,this.#n=e.#n):e instanceof Date?this.#e=t.DateTime.fromJSDate(e,r):typeof e==`number`?this.#e=t.DateTime.fromMillis(e,r):(this.#e=t.DateTime.fromISO(e,r),this.#e.isValid||(this.#e=t.DateTime.fromRFC2822(e,r)),this.#e.isValid||(this.#e=t.DateTime.fromSQL(e,r)),this.#e.isValid||(this.#e=t.DateTime.fromFormat(e,`EEE, d MMM yyyy HH:mm:ss`,r))):this.#e=t.DateTime.local(),!this.#e.isValid)throw Error(`CronDate: unhandled timestamp: ${e}`);n&&n!==this.#e.zoneName&&(this.#e=this.#e.setZone(n))}static#i(e){return e%4==0&&e%100!=0||e%400==0}get dstStart(){return this.#t}set dstStart(e){this.#t=e}get dstEnd(){return this.#n}set dstEnd(e){this.#n=e}addYear(){this.#e=this.#e.plus({years:1})}addMonth(){this.#e=this.#e.plus({months:1}).startOf(`month`)}addDay(){this.#e=this.#e.plus({days:1}).startOf(`day`)}addHour(){this.#e=this.#e.plus({hours:1}).startOf(`hour`)}addMinute(){this.#e=this.#e.plus({minutes:1}).startOf(`minute`)}addSecond(){this.#e=this.#e.plus({seconds:1})}subtractYear(){this.#e=this.#e.minus({years:1})}subtractMonth(){this.#e=this.#e.minus({months:1}).endOf(`month`).startOf(`second`)}subtractDay(){this.#e=this.#e.minus({days:1}).endOf(`day`).startOf(`second`)}subtractHour(){this.#e=this.#e.minus({hours:1}).endOf(`hour`).startOf(`second`)}subtractMinute(){this.#e=this.#e.minus({minutes:1}).endOf(`minute`).startOf(`second`)}subtractSecond(){this.#e=this.#e.minus({seconds:1})}addUnit(e){this.#r.add[e]()}subtractUnit(e){this.#r.subtract[e]()}invokeDateOperation(e,t){if(e===r.Add){this.addUnit(t);return}if(e===r.Subtract){this.subtractUnit(t);return}throw Error(`Invalid verb: ${e}`)}getDate(){return this.#e.day}getFullYear(){return this.#e.year}getDay(){let e=this.#e.weekday;return e===7?0:e}getMonth(){return this.#e.month-1}getHours(){return this.#e.hour}getMinutes(){return this.#e.minute}getSeconds(){return this.#e.second}getMilliseconds(){return this.#e.millisecond}getUTCOffset(){return this.#e.offset}setStartOfDay(){this.#e=this.#e.startOf(`day`)}setEndOfDay(){this.#e=this.#e.endOf(`day`)}getTime(){return this.#e.valueOf()}getUTCDate(){return this.#a().day}getUTCFullYear(){return this.#a().year}getUTCDay(){let e=this.#a().weekday;return e===7?0:e}getUTCMonth(){return this.#a().month-1}getUTCHours(){return this.#a().hour}getUTCMinutes(){return this.#a().minute}getUTCSeconds(){return this.#a().second}toISOString(){return this.#e.toUTC().toISO()}toJSON(){return this.#e.toJSON()}setDate(e){this.#e=this.#e.set({day:e})}setFullYear(e){this.#e=this.#e.set({year:e})}setDay(e){this.#e=this.#e.set({weekday:e})}setMonth(e){this.#e=this.#e.set({month:e+1})}setHours(e){this.#e=this.#e.set({hour:e})}setMinutes(e){this.#e=this.#e.set({minute:e})}setSeconds(e){this.#e=this.#e.set({second:e})}setMilliseconds(e){this.#e=this.#e.set({millisecond:e})}toString(){return this.toDate().toString()}toDate(){return this.#e.toJSDate()}isLastDayOfMonth(){let{day:t,month:n}=this.#e;if(n===2){let r=i.#i(this.#e.year);return t===e.DAYS_IN_MONTH[n-1]-+!r}return t===e.DAYS_IN_MONTH[n-1]}isLastWeekdayOfMonth(){let{day:t,month:n}=this.#e,r;return r=n===2?e.DAYS_IN_MONTH[n-1]-+!i.#i(this.#e.year):e.DAYS_IN_MONTH[n-1],t>r-7}applyDateOperation(e,t,r){if(t===n.Month||t===n.Day){this.invokeDateOperation(e,t);return}let i=this.getHours();this.invokeDateOperation(e,t);let a=this.getHours(),o=a-i;o===2?r!==24&&(this.dstStart=a):o===0&&this.getMinutes()===0&&this.getSeconds()===0&&r!==24&&(this.dstEnd=a)}#a(){return this.#e.toUTC()}};e.CronDate=i,e.default=i})),l=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CronMonth=void 0;var t=c(),r=n(),i=1,a=12,o=Object.freeze([]);e.CronMonth=class extends r.CronField{static get min(){return i}static get max(){return a}static get chars(){return o}static get daysInMonth(){return t.DAYS_IN_MONTH}constructor(e,t){super(e,t),this.validate()}get values(){return super.values}}})),u=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CronSecond=void 0;var t=n(),r=0,i=59,a=Object.freeze([]);e.CronSecond=class extends t.CronField{static get min(){return r}static get max(){return i}static get chars(){return a}constructor(e,t){super(e,t),this.validate()}get values(){return super.values}}})),d=e((e=>{var s=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),c=e&&e.__exportStar||function(e,t){for(var n in e)n!==`default`&&!Object.prototype.hasOwnProperty.call(t,n)&&s(t,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),c(t(),e),c(r(),e),c(i(),e),c(n(),e),c(a(),e),c(o(),e),c(l(),e),c(u(),e)})),f=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CronFieldCollection=void 0;var t=d();e.CronFieldCollection=class e{#e;#t;#n;#r;#i;#a;static from(n,r){return new e({second:this.resolveField(t.CronSecond,n.second,r.second),minute:this.resolveField(t.CronMinute,n.minute,r.minute),hour:this.resolveField(t.CronHour,n.hour,r.hour),dayOfMonth:this.resolveField(t.CronDayOfMonth,n.dayOfMonth,r.dayOfMonth),month:this.resolveField(t.CronMonth,n.month,r.month),dayOfWeek:this.resolveField(t.CronDayOfWeek,n.dayOfWeek,r.dayOfWeek)})}static resolveField(e,n,r){return r?r instanceof t.CronField?r:new e(r):n}constructor({second:e,minute:n,hour:r,dayOfMonth:i,month:a,dayOfWeek:o}){if(!e)throw Error(`Validation error, Field second is missing`);if(!n)throw Error(`Validation error, Field minute is missing`);if(!r)throw Error(`Validation error, Field hour is missing`);if(!i)throw Error(`Validation error, Field dayOfMonth is missing`);if(!a)throw Error(`Validation error, Field month is missing`);if(!o)throw Error(`Validation error, Field dayOfWeek is missing`);if(a.values.length===1&&!i.hasLastChar&&!(parseInt(i.values[0],10)<=t.CronMonth.daysInMonth[a.values[0]-1]))throw Error(`Invalid explicit day of month definition`);this.#e=e,this.#t=n,this.#n=r,this.#i=a,this.#a=o,this.#r=i}get second(){return this.#e}get minute(){return this.#t}get hour(){return this.#n}get dayOfMonth(){return this.#r}get month(){return this.#i}get dayOfWeek(){return this.#a}static compactField(e){if(e.length===0)return[];let t=[],n;return e.forEach((e,r,i)=>{if(n===void 0){n={start:e,count:1};return}let a=i[r-1]||n.start,o=i[r+1];if(e===`L`||e===`W`){t.push(n),t.push({start:e,count:1}),n=void 0;return}if(n.step===void 0&&o!==void 0){let t=e-a;if(t<=o-e){n={...n,count:2,end:e,step:t};return}n.step=1}e-(n.end??0)===n.step?(n.count++,n.end=e):(n.count===1?t.push({start:n.start,count:1}):n.count===2?(t.push({start:n.start,count:1}),t.push({start:n.end??a,count:1})):t.push(n),n={start:e,count:1})}),n&&t.push(n),t}static#o(e,t,n){let r=t.step;return r?r===1&&t.start===e.min&&t.end&&t.end>=n?e.hasQuestionMarkChar?`?`:`*`:r!==1&&t.start===e.min&&t.end&&t.end>=n-r+1?`*/${r}`:null:null}static#s(e,t){let n=e.step;if(n===1)return`${e.start}-${e.end}`;let r=e.start===0?e.count-1:e.count;if(!n)throw Error(`Unexpected range step`);if(!e.end)throw Error(`Unexpected range end`);if(n*r>e.end){let t=(t,r)=>{if(typeof e.start!=`number`)throw Error(`Unexpected range start`);return r%n===0?e.start+r:null};if(typeof e.start!=`number`)throw Error(`Unexpected range start`);let r={length:e.end-e.start+1};return Array.from(r,t).filter(e=>e!==null).join(`,`)}return e.end===t-n+1?`${e.start}/${n}`:`${e.start}-${e.end}/${n}`}stringifyField(n){let r=n.max,i=n.values;if(n instanceof t.CronDayOfWeek){r=6;let e=this.#a.values;i=e[e.length-1]===7?e.slice(0,-1):e}n instanceof t.CronDayOfMonth&&(r=this.#i.values.length===1?t.CronMonth.daysInMonth[this.#i.values[0]-1]:n.max);let a=e.compactField(i);if(a.length===1){let t=e.#o(n,a[0],r);if(t)return t}return a.map(i=>{let a=i.count===1?i.start.toString():e.#s(i,r);return n instanceof t.CronDayOfWeek&&n.nthDay>0?`${a}#${n.nthDay}`:a}).join(`,`)}stringify(e=!1){let t=[];return e&&t.push(this.stringifyField(this.#e)),t.push(this.stringifyField(this.#t),this.stringifyField(this.#n),this.stringifyField(this.#r),this.stringifyField(this.#i),this.stringifyField(this.#a)),t.join(` `)}serialize(){return{second:this.#e.serialize(),minute:this.#t.serialize(),hour:this.#n.serialize(),dayOfMonth:this.#r.serialize(),month:this.#i.serialize(),dayOfWeek:this.#a.serialize()}}}})),p=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CronExpression=e.LOOPS_LIMIT_EXCEEDED_ERROR_MESSAGE=e.TIME_SPAN_OUT_OF_BOUNDS_ERROR_MESSAGE=void 0;var t=c();e.TIME_SPAN_OUT_OF_BOUNDS_ERROR_MESSAGE=`Out of the time span range`,e.LOOPS_LIMIT_EXCEEDED_ERROR_MESSAGE=`Invalid expression, loop limit exceeded`;var n=1e4,r=class r{#e;#t;#n;#r;#i;#a;#o=null;#s=!1;constructor(e,n){this.#e=n,this.#t=n.tz,this.#r=n.startDate?new t.CronDate(n.startDate,this.#t):null,this.#i=n.endDate?new t.CronDate(n.endDate,this.#t):null;let r=n.currentDate??n.startDate;if(r){let e=new t.CronDate(r,this.#t);this.#r&&e.getTime()<this.#r.getTime()?r=this.#r:this.#i&&e.getTime()>this.#i.getTime()&&(r=this.#i)}this.#n=new t.CronDate(r,this.#t),this.#a=e}get fields(){return this.#a}static fieldsToExpression(e,t){return new r(e,t||{})}static#c(e,t){return t.some(t=>t===e)}#l(e,t){return e[t?e.length-1:0]}#u(e){let n=`${e.getFullYear()}-${e.getMonth()+1}-${e.getDate()}`;if(this.#o===n)return this.#s;let r=new t.CronDate(e);r.setStartOfDay();let i=new t.CronDate(e);return i.setEndOfDay(),this.#o=n,this.#s=r.getUTCOffset()!==i.getUTCOffset(),this.#s}#d(e,n,r){let i=this.#a.second.values,a=e.getSeconds(),o=this.#a.second.findNearestValue(a,r);if(o!==null){e.setSeconds(o);return}e.applyDateOperation(n,t.TimeUnit.Minute,this.#a.hour.values.length),e.setSeconds(this.#l(i,r))}#f(e,n,r){let i=this.#a.minute.values,a=this.#a.second.values,o=e.getMinutes(),s=this.#a.minute.findNearestValue(o,r);if(s!==null){e.setMinutes(s),e.setSeconds(this.#l(a,r));return}e.applyDateOperation(n,t.TimeUnit.Hour,this.#a.hour.values.length),e.setMinutes(this.#l(i,r)),e.setSeconds(this.#l(a,r))}static#p(e,t){let n=t.isLastWeekdayOfMonth();return e.some(e=>{let r=parseInt(e.toString().charAt(0),10)%7;if(Number.isNaN(r))throw Error(`Invalid last weekday of the month expression: ${e}`);return t.getDay()===r&&n})}next(){return this.#_()}prev(){return this.#_(!0)}hasNext(){let e=this.#n;try{return this.#_(),!0}catch{return!1}finally{this.#n=e}}hasPrev(){let e=this.#n;try{return this.#_(!0),!0}catch{return!1}finally{this.#n=e}}take(e){let t=[];if(e>=0)for(let n=0;n<e;n++)try{t.push(this.next())}catch{return t}else for(let n=0;n>e;n--)try{t.push(this.prev())}catch{return t}return t}reset(e){this.#n=new t.CronDate(e||this.#e.currentDate)}stringify(e=!1){return this.#a.stringify(e)}includesDate(e){let{second:n,minute:r,hour:i,month:a}=this.#a,o=new t.CronDate(e,this.#t);return!(!n.values.includes(o.getSeconds())||!r.values.includes(o.getMinutes())||!i.values.includes(o.getHours())||!a.values.includes(o.getMonth()+1)||!this.#m(o)||this.#a.dayOfWeek.nthDay>0&&Math.ceil(o.getDate()/7)!==this.#a.dayOfWeek.nthDay)}toString(){return this.#e.expression||this.stringify(!0)}#m(e){let t=this.#a.dayOfMonth.isWildcard,n=!t,i=this.#a.dayOfWeek.isWildcard,a=!i,o=r.#c(e.getDate(),this.#a.dayOfMonth.values)||this.#a.dayOfMonth.hasLastChar&&e.isLastDayOfMonth(),s=r.#c(e.getDay(),this.#a.dayOfWeek.values)||this.#a.dayOfWeek.hasLastChar&&r.#p(this.#a.dayOfWeek.values,e);return!!(n&&a&&(o||s)||o&&!a||t&&!i&&s)}#h(e,n,i){let a=this.#a.hour.values,o=a,s=e.getHours(),c=r.#c(s,a),l=e.dstStart===s,u=e.dstEnd===s;if(l)return r.#c(s-1,a)?!0:(e.invokeDateOperation(n,t.TimeUnit.Hour),!1);if(u&&!i)return e.dstEnd=null,e.applyDateOperation(t.DateMathOp.Add,t.TimeUnit.Hour,o.length),!1;if(c)return!0;e.dstStart=null;let d=this.#a.hour.findNearestValue(s,i);if(d===null)return e.applyDateOperation(n,t.TimeUnit.Day,o.length),!1;if(this.#u(e)){let r=i?s-d:d-s;for(let i=0;i<r;i++)e.applyDateOperation(n,t.TimeUnit.Hour,o.length)}else e.setHours(d);return e.setMinutes(this.#l(this.#a.minute.values,i)),e.setSeconds(this.#l(this.#a.second.values,i)),!1}#g(t){if(!this.#r&&!this.#i)return;let n=t.getTime();if(this.#r&&n<this.#r.getTime()||this.#i&&n>this.#i.getTime())throw Error(e.TIME_SPAN_OUT_OF_BOUNDS_ERROR_MESSAGE)}#_(i=!1){let a=i?t.DateMathOp.Subtract:t.DateMathOp.Add,o=new t.CronDate(this.#n),s=o.getTime(),c=0;for(;++c<n;){if(this.#g(o),!this.#m(o)){o.applyDateOperation(a,t.TimeUnit.Day,this.#a.hour.values.length);continue}if(!(this.#a.dayOfWeek.nthDay<=0||Math.ceil(o.getDate()/7)===this.#a.dayOfWeek.nthDay)){o.applyDateOperation(a,t.TimeUnit.Day,this.#a.hour.values.length);continue}if(!r.#c(o.getMonth()+1,this.#a.month.values)){o.applyDateOperation(a,t.TimeUnit.Month,this.#a.hour.values.length);continue}if(this.#h(o,a,i)){if(!r.#c(o.getMinutes(),this.#a.minute.values)){this.#f(o,a,i);continue}if(!r.#c(o.getSeconds(),this.#a.second.values)){this.#d(o,a,i);continue}if(s===o.getTime()){(a===`Add`||o.getMilliseconds()===0)&&o.applyDateOperation(a,t.TimeUnit.Second,this.#a.hour.values.length);continue}break}}if(c>n)throw Error(e.LOOPS_LIMIT_EXCEEDED_ERROR_MESSAGE);return o.getMilliseconds()!==0&&o.setMilliseconds(0),this.#n=o,o}[Symbol.iterator](){return{next:()=>({value:this.#_(),done:!this.hasNext()})}}};e.CronExpression=r,e.default=r})),m=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.seededRandom=r;function t(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return()=>t>>>0}function n(e){return()=>{let t=e+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}function r(e){return n(e?t(e)():Math.floor(Math.random()*1e10))}})),h=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CronExpressionParser=e.DayOfWeek=e.Months=e.CronUnit=e.PredefinedExpressions=void 0;var t=f(),n=p(),r=m(),i=d(),a;(function(e){e[`@yearly`]=`0 0 0 1 1 *`,e[`@annually`]=`0 0 0 1 1 *`,e[`@monthly`]=`0 0 0 1 * *`,e[`@weekly`]=`0 0 0 * * 0`,e[`@daily`]=`0 0 0 * * *`,e[`@hourly`]=`0 0 * * * *`,e[`@minutely`]=`0 * * * * *`,e[`@secondly`]=`* * * * * *`,e[`@weekdays`]=`0 0 0 * * 1-5`,e[`@weekends`]=`0 0 0 * * 0,6`})(a||(e.PredefinedExpressions=a={}));var o;(function(e){e.Second=`Second`,e.Minute=`Minute`,e.Hour=`Hour`,e.DayOfMonth=`DayOfMonth`,e.Month=`Month`,e.DayOfWeek=`DayOfWeek`})(o||(e.CronUnit=o={}));var s;(function(e){e[e.jan=1]=`jan`,e[e.feb=2]=`feb`,e[e.mar=3]=`mar`,e[e.apr=4]=`apr`,e[e.may=5]=`may`,e[e.jun=6]=`jun`,e[e.jul=7]=`jul`,e[e.aug=8]=`aug`,e[e.sep=9]=`sep`,e[e.oct=10]=`oct`,e[e.nov=11]=`nov`,e[e.dec=12]=`dec`})(s||(e.Months=s={}));var c;(function(e){e[e.sun=0]=`sun`,e[e.mon=1]=`mon`,e[e.tue=2]=`tue`,e[e.wed=3]=`wed`,e[e.thu=4]=`thu`,e[e.fri=5]=`fri`,e[e.sat=6]=`sat`})(c||(e.DayOfWeek=c={})),e.CronExpressionParser=class e{static parse(s,c={}){let{strict:l=!1,hashSeed:u}=c,d=(0,r.seededRandom)(u);s=a[s]||s;let f=e.#e(s,l);if(!(f.dayOfMonth===`*`||f.dayOfWeek===`*`||!l))throw Error(`Cannot use both dayOfMonth and dayOfWeek together in strict mode!`);let p=e.#t(o.Second,f.second,i.CronSecond.constraints,d),m=e.#t(o.Minute,f.minute,i.CronMinute.constraints,d),h=e.#t(o.Hour,f.hour,i.CronHour.constraints,d),g=e.#t(o.Month,f.month,i.CronMonth.constraints,d),_=e.#t(o.DayOfMonth,f.dayOfMonth,i.CronDayOfMonth.constraints,d),{dayOfWeek:v,nthDayOfWeek:y}=e.#u(f.dayOfWeek),b=e.#t(o.DayOfWeek,v,i.CronDayOfWeek.constraints,d),x=new t.CronFieldCollection({second:new i.CronSecond(p,{rawValue:f.second}),minute:new i.CronMinute(m,{rawValue:f.minute}),hour:new i.CronHour(h,{rawValue:f.hour}),dayOfMonth:new i.CronDayOfMonth(_,{rawValue:f.dayOfMonth}),month:new i.CronMonth(g,{rawValue:f.month}),dayOfWeek:new i.CronDayOfWeek(b,{rawValue:f.dayOfWeek,nthDayOfWeek:y})});return new n.CronExpression(x,{...c,expression:s})}static#e(e,t){if(t&&!e.length)throw Error(`Invalid cron expression`);e||=`0 * * * * *`;let n=e.trim().split(/\s+/);if(t&&n.length<6)throw Error(`Invalid cron expression, expected 6 fields`);if(n.length>6)throw Error(`Invalid cron expression, too many fields`);let r=[`*`,`*`,`*`,`*`,`*`,`0`];n.length<r.length&&n.unshift(...r.slice(n.length));let[i,a,o,s,c,l]=n;return{second:i,minute:a,hour:o,dayOfMonth:s,month:c,dayOfWeek:l}}static#t(e,t,n,r){if((e===o.Month||e===o.DayOfWeek)&&(t=t.replace(/[a-z]{3}/gi,e=>{e=e.toLowerCase();let t=s[e]||c[e];if(t===void 0)throw Error(`Validation error, cannot resolve alias "${e}"`);return t.toString()})),!n.validChars.test(t))throw Error(`Invalid characters, got value: ${t}`);return t=this.#n(t,n),t=this.#r(t,n,r),this.#i(e,t,n)}static#n(e,t){return e.replace(/[*?]/g,t.min+`-`+t.max)}static#r(e,t,n){let r=n();return e.replace(/H(?:\((\d+)-(\d+)\))?(?:\/(\d+))?/g,(e,n,i,a)=>{if(n&&i&&a){let e=parseInt(n,10),o=parseInt(i,10),s=parseInt(a,10);if(e>o)throw Error(`Invalid range: ${e}-${o}, min > max`);if(s<=0)throw Error(`Invalid step: ${s}, must be positive`);let c=Math.max(e,t.min),l=Math.floor(r*s),u=[];for(let e=Math.floor(c/s)*s+l;e<=o;e+=s)e>=c&&u.push(e);return u.join(`,`)}else if(n&&i){let e=parseInt(n,10),t=parseInt(i,10);if(e>t)throw Error(`Invalid range: ${e}-${t}, min > max`);return String(Math.floor(r*(t-e+1))+e)}else if(a){let e=parseInt(a,10);if(e<=0)throw Error(`Invalid step: ${e}, must be positive`);let n=Math.floor(r*e),i=[];for(let r=Math.floor(t.min/e)*e+n;r<=t.max;r+=e)r>=t.min&&i.push(r);return i.join(`,`)}else return String(Math.floor(r*(t.max-t.min+1)+t.min))})}static#i(t,n,r){let i=[];function a(n,r){if(Array.isArray(n))i.push(...n);else if(e.#d(r,n))i.push(n);else{let e=parseInt(n.toString(),10);if(!(e>=r.min&&e<=r.max))throw Error(`Constraint error, got value ${n} expected range ${r.min}-${r.max}`);i.push(t===o.DayOfWeek?e%7:n)}}return n.split(`,`).forEach(n=>{if(!(n.length>0))throw Error(`Invalid list value format`);a(e.#a(t,n,r),r)}),i}static#a(t,n,r){let i=n.split(`/`);if(i.length>2)throw Error(`Invalid repeat: ${n}`);return i.length===2?(isNaN(parseInt(i[0],10))||(i[0]=`${i[0]}-${r.max}`),e.#l(t,i[0],parseInt(i[1],10),r)):e.#l(t,n,1,r)}static#o(e,t,n){if(!(!isNaN(e)&&!isNaN(t)&&e>=n.min&&t<=n.max))throw Error(`Constraint error, got range ${e}-${t} expected range ${n.min}-${n.max}`);if(e>t)throw Error(`Invalid range: ${e}-${t}, min(${e}) > max(${t})`)}static#s(e){if(!(!isNaN(e)&&e>0))throw Error(`Constraint error, cannot repeat at every ${e} time.`)}static#c(e,t,n,r){let i=[];e===o.DayOfWeek&&n%7==0&&i.push(0);for(let e=t;e<=n;e+=r)i.indexOf(e)===-1&&i.push(e);return i}static#l(e,t,n,r){let i=t.split(`-`);if(i.length<=1)return isNaN(+t)?t:+t;let[a,o]=i.map(e=>parseInt(e,10));return this.#o(a,o,r),this.#s(n),this.#c(e,a,o,n)}static#u(e){let t=e.split(`#`);if(t.length<=1)return{dayOfWeek:t[0]};let n=+t[t.length-1],r=e.match(/([,-/])/);if(r!==null)throw Error(`Constraint error, invalid dayOfWeek \`#\` and \`${r?.[0]}\` special characters are incompatible`);if(!(t.length<=2&&!isNaN(n)&&n>=1&&n<=5))throw Error(`Constraint error, invalid dayOfWeek occurrence number (#)`);return{dayOfWeek:t[0],nthDayOfWeek:n}}static#d(e,t){return e.chars.some(e=>t.toString().includes(e))}}})),g=e(((e,t)=>{t.exports={}})),_=e((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||(function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},e(t)};return function(r){if(r&&r.__esModule)return r;var i={};if(r!=null)for(var a=e(r),o=0;o<a.length;o++)a[o]!==`default`&&t(i,r,a[o]);return n(i,r),i}})();Object.defineProperty(e,"__esModule",{value:!0}),e.CronFileParser=void 0;var i=h();e.CronFileParser=class e{static async parseFile(t){let{readFile:n}=await Promise.resolve().then(()=>r(g())),i=await n(t,`utf8`);return e.#e(i)}static parseFileSync(t){let{readFileSync:n}=g(),r=n(t,`utf8`);return e.#e(r)}static#e(t){let n=t.split(`
2
- `),r={variables:{},expressions:[],errors:{}};for(let t of n){let n=t.trim();if(n.length===0||n.startsWith(`#`))continue;let i=n.match(/^(.*)=(.*)$/);if(i){let[,e,t]=i;r.variables[e]=t.replace(/["']/g,``);continue}try{let t=e.#t(n);r.expressions.push(t.interval)}catch(e){r.errors[n]=e}}return r}static#t(e){let t=e.split(` `);return{interval:i.CronExpressionParser.parse(t.slice(0,5).join(` `)),command:t.slice(5,t.length)}}}})),v=e((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.CronFileParser=e.CronExpressionParser=e.CronExpression=e.CronFieldCollection=e.CronDate=void 0;var r=h(),i=c();Object.defineProperty(e,"CronDate",{enumerable:!0,get:function(){return i.CronDate}});var a=f();Object.defineProperty(e,"CronFieldCollection",{enumerable:!0,get:function(){return a.CronFieldCollection}});var o=p();Object.defineProperty(e,"CronExpression",{enumerable:!0,get:function(){return o.CronExpression}});var s=h();Object.defineProperty(e,"CronExpressionParser",{enumerable:!0,get:function(){return s.CronExpressionParser}});var l=_();Object.defineProperty(e,"CronFileParser",{enumerable:!0,get:function(){return l.CronFileParser}}),n(d(),e),e.default=r.CronExpressionParser}))();function y(){let e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function b(e){return Array.isArray(e)?e.filter(e=>typeof e==`number`).sort((e,t)=>e-t):[]}function x(e){if(e.length<2)return null;let t=e[1]-e[0];if(t<=0)return null;for(let n=2;n<e.length;n++)if(e[n]-e[n-1]!==t)return null;return t}function ee(e){let t=[];for(let n=0;n<7;n++)e[n]&&t.push(n===6?0:n+1);return t.length===0?`1`:t.sort((e,t)=>e-t).join(`,`)}function te(e){let t=[!1,!1,!1,!1,!1,!1,!1];for(let n of e){let e=n===0||n===7?6:n-1;e>=0&&e<=6&&(t[e]=!0)}return t}function S(e){let t=e.trim(),n={mode:`custom`,intervalKind:`minutes`,onceDate:y(),intervalMinutes:5,intervalHours:2,minute:0,hour:9,weekDays:[!0,!0,!0,!0,!0,!1,!1],dayOfMonth:1,rawCron:t};if(!t)return{...n,mode:`interval`,rawCron:`*/5 * * * *`};try{let e=v.CronExpressionParser.parse(t).fields,r=b(e.minute.values),i=b(e.hour.values),a=b(e.dayOfMonth.values),o=b(e.month.values),s=b(e.dayOfWeek.values);if(r.length===60&&e.hour.isWildcard&&e.dayOfMonth.isWildcard&&e.month.isWildcard&&e.dayOfWeek.isWildcard)return{...n,mode:`interval`,intervalKind:`minutes`,intervalMinutes:1,rawCron:t};if(!e.minute.isWildcard&&e.hour.isWildcard&&e.dayOfMonth.isWildcard&&e.month.isWildcard&&e.dayOfWeek.isWildcard&&r.length>1){let e=x(r);if(e!=null&&e>0)return{...n,mode:`interval`,intervalKind:`minutes`,intervalMinutes:e,rawCron:t}}if(!e.minute.isWildcard&&r.length===1&&!e.hour.isWildcard&&i.length>1&&e.dayOfMonth.isWildcard&&e.month.isWildcard&&e.dayOfWeek.isWildcard){let e=x(i);if(e!=null&&e>0)return{...n,mode:`interval`,intervalKind:`hours`,intervalHours:e,minute:r[0],rawCron:t}}if(!e.minute.isWildcard&&r.length===1&&e.hour.isWildcard&&e.dayOfMonth.isWildcard&&e.month.isWildcard&&e.dayOfWeek.isWildcard&&i.length===24)return{...n,mode:`hourly`,minute:r[0],rawCron:t};if(r.length===1&&i.length===1&&a.length===1&&o.length===1&&!e.dayOfMonth.isWildcard&&!e.month.isWildcard&&e.dayOfWeek.isWildcard){let e=new Date().getFullYear(),s=o[0],c=a[0],l=`${e}-${String(s).padStart(2,`0`)}-${String(c).padStart(2,`0`)}`;return{...n,mode:`no_repeat`,minute:r[0],hour:i[0],onceDate:l,rawCron:t}}if(r.length===1&&i.length===1&&e.dayOfMonth.isWildcard&&e.month.isWildcard&&e.dayOfWeek.isWildcard)return{...n,mode:`daily`,minute:r[0],hour:i[0],rawCron:t};if(r.length===1&&i.length===1&&e.dayOfMonth.isWildcard&&e.month.isWildcard&&!e.dayOfWeek.isWildcard&&s.length>0)return{...n,mode:`weekly`,minute:r[0],hour:i[0],weekDays:te(s),rawCron:t};if(r.length===1&&i.length===1&&!e.dayOfMonth.isWildcard&&a.length===1&&e.month.isWildcard&&e.dayOfWeek.isWildcard)return{...n,mode:`monthly`,minute:r[0],hour:i[0],dayOfMonth:a[0],rawCron:t}}catch{}return n}function ne(e){let t=(e,t,n)=>Math.min(n,Math.max(t,e));switch(e.mode){case`custom`:return e.rawCron.trim()||`*/5 * * * *`;case`no_repeat`:{let n=e.onceDate.split(`-`);if(n.length===3){let r=t(parseInt(n[2],10),1,31),i=t(parseInt(n[1],10),1,12);return`${t(e.minute,0,59)} ${t(e.hour,0,23)} ${r} ${i} *`}return`0 9 1 1 *`}case`interval`:if(e.intervalKind===`hours`){let n=t(Math.round(e.intervalHours)||1,1,23);return`${t(e.minute,0,59)} */${n} * * *`}return`*/${t(Math.round(e.intervalMinutes)||5,1,59)} * * * *`;case`hourly`:return`${t(e.minute,0,59)} * * * *`;case`daily`:return`${t(e.minute,0,59)} ${t(e.hour,0,23)} * * *`;case`weekly`:return`${t(e.minute,0,59)} ${t(e.hour,0,23)} * * ${ee(e.weekDays)}`;case`monthly`:return`${t(e.minute,0,59)} ${t(e.hour,0,23)} ${t(Math.round(e.dayOfMonth)||1,1,31)} * *`;default:return`*/5 * * * *`}}function re(e,t,n){let r=new Date;return r.setHours(e,t,0,0),r.toLocaleTimeString(n,{hour:`numeric`,minute:`2-digit`})}function ie(e,t){let n=e===7?0:e;return new Date(Date.UTC(2023,0,1)+n*864e5).toLocaleDateString(t,{weekday:`short`,timeZone:`UTC`})}function ae(e,t){return e.length<=1?e[0]??``:t.startsWith(`zh`)?e.join(`、`):e.length===2?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(`, `)}, and ${e.at(-1)}`}function oe(e){return e.length===5&&e.every((e,t)=>e===t+1)}function se(e){if(e.length!==2)return!1;let t=[...e].sort((e,t)=>e-t);return t[0]===0&&t[1]===6}function ce(e,t,n,r){try{let i=v.CronExpressionParser.parse(e,{...r?.timezone?{tz:r.timezone}:{}}).fields,a=b(i.minute.values),o=b(i.hour.values),s=b(i.dayOfWeek.values),c=b(i.dayOfMonth.values);if(a.length===60&&i.hour.isWildcard&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard)return n.everyMinute;if(!i.minute.isWildcard&&i.hour.isWildcard&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard&&a.length>1){let e=x(a);if(e!=null&&e>0)return n.everyNMinutes.replace(`{{n}}`,String(e))}if(!i.minute.isWildcard&&a.length===1&&!i.hour.isWildcard&&o.length>1&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard){let e=x(o);if(e!=null&&e>0)return n.everyNHours.replace(`{{n}}`,String(e))}if(!i.minute.isWildcard&&a.length===1&&i.hour.isWildcard&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard&&o.length===24)return n.hourly;let l=!i.minute.isWildcard&&a.length===1&&!i.hour.isWildcard&&o.length===1?re(o[0],a[0],t):``;if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard)return n.dailyAt.replace(`{{time}}`,l);if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&oe(s))return n.weekdaysAt.replace(`{{time}}`,l);if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&se(s))return n.weekendsAt.replace(`{{time}}`,l);if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&s.length===1){let e=ie(s[0],t);return n.weeklyOn.replace(`{{day}}`,e).replace(`{{time}}`,l)}if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&s.length>1){let e=ae(s.map(e=>ie(e,t)),t);return n.daysAt.replace(`{{days}}`,e).replace(`{{time}}`,l)}return l&&!i.dayOfMonth.isWildcard&&c.length===1&&i.month.isWildcard&&i.dayOfWeek.isWildcard?n.monthlyAt.replace(`{{day}}`,String(c[0])).replace(`{{time}}`,l):n.customSchedule}catch{return null}}function le(e,t,n,r){let i=e.trim();return i?ce(i,t,n,r)||ue(r?.nextRun,t)||n.customSchedule:ue(r?.nextRun,t)||`—`}function ue(e,t){if(!e)return``;let n=new Date(e);return Number.isNaN(n.getTime())?``:n.toLocaleString(t,{weekday:`short`,hour:`numeric`,minute:`2-digit`})}function C(e,t){let n=e?.trim()||``;return n?n.length<=t?n:`${n.slice(0,t-1)}…`:`—`}function de(e){return e==null||!Number.isFinite(e)?`—`:e<1e3?`${Math.round(e)}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m ${Math.round(e%6e4/1e3)}s`}function fe(e){return new Date(e).toLocaleString()}function pe(e,t){let n=typeof e==`string`?new Date(e):e,r=new Date,i=n.getTime()-r.getTime();if(i<0)return t.overdue;if(i<6e4)return t.lessThanMinute;if(i<36e5){let e=Math.floor(i/6e4);return t.minutes.replace(`{{count}}`,String(e))}if(i<864e5){let e=Math.floor(i/36e5);return t.hours.replace(`{{count}}`,String(e))}return n.toLocaleString()}function me(e,t){let n=new Date(e),r=new Date().getTime()-n.getTime();if(r<0||r<6e4)return t.justNow;if(r<36e5){let e=Math.floor(r/6e4);return t.minutesAgo.replace(`{{count}}`,String(e))}if(r<864e5){let e=Math.floor(r/36e5);return t.hoursAgo.replace(`{{count}}`,String(e))}if(r<6048e5){let e=Math.floor(r/864e5);return t.daysAgo.replace(`{{count}}`,String(e))}return n.toLocaleDateString()}function he(e,t){let n=me(e.lastActive,t);return e.channel===`telegram`&&e.peerId?`${e.accountId??`default`} · ${e.peerKind??``} · ${e.peerId} · ${n}`:`${e.channel}: ${e.chatId} · ${n}`}function ge(e,t){if(e.delivery?.channel===`local`)return t;let n=e.delivery?.to??``,r=n.split(`:`);return r.length===3&&(r[1]===`dm`||r[1]===`group`)?`${r[0]} · ${r[1]} · ${r[2]}`:n}function _e(e,t){switch(e){case`running`:return t.running;case`success`:return t.success;case`failed`:return t.failed;case`cancelled`:return t.cancelled;default:return e}}function ve(e,t,n){return le(e.schedule||``,t,n,{timezone:e.timezone,nextRun:e.next_run})}var w=[3e4,6e4,3e5,6e5,9e5,18e5,36e5,72e5],ye=new Set(w);function be(e,t){switch(e){case 3e4:return t.every30s;case 6e4:return t.every1min;case 3e5:return t.every5min;case 6e5:return t.every10min;case 9e5:return t.every15min;case 18e5:return t.every30min;case 36e5:return t.every1h;case 72e5:return t.every2h;default:return null}}var xe={second:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`second`,unitDisplay:`long`}),minute:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`minute`,unitDisplay:`long`}),hour:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`hour`,unitDisplay:`long`})},Se={second:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`second`,unitDisplay:`long`}),minute:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`minute`,unitDisplay:`long`}),hour:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`hour`,unitDisplay:`long`})};function Ce(e,t){return e.startsWith(`zh`)?Se[t]:xe[t]}function we(e,t,n){let r=Math.max(1e3,Math.round(e));if(n&&ye.has(r)){let e=be(r,n);if(e)return e}let i=Math.max(1,Math.round(r/1e3));if(i<120)return Ce(t,`second`).format(i);let a=Math.round(i/60);if(a<120)return Ce(t,`minute`).format(a);let o=Math.round(a/60);return Ce(t,`hour`).format(o)}var Te=new Set([`__xopc_memory_dreaming_light_sweep__`,`__xopc_memory_dreaming_sweep__`,`__xopc_memory_dreaming_rem_sweep__`]);function Ee(e){let t=e.payload;if(t?.kind!==`agentTurn`)return!1;let n=t.message;return typeof n==`string`&&Te.has(n)}export{ge as a,he as c,C as d,le as f,_e as i,ve as l,S as m,we as n,de as o,ne as p,w as r,pe as s,Ee as t,fe as u};