botmux 3.13.0 → 3.14.0
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.
- package/README.en.md +1 -1
- package/README.md +25 -1
- package/dist/.runtime-build-id +1 -1
- package/dist/adapters/adopt-route.d.ts +58 -0
- package/dist/adapters/adopt-route.d.ts.map +1 -1
- package/dist/adapters/adopt-route.js +136 -0
- package/dist/adapters/adopt-route.js.map +1 -1
- package/dist/adapters/backend/capabilities.js +1 -1
- package/dist/adapters/backend/capabilities.js.map +1 -1
- package/dist/adapters/backend/herdr-backend.d.ts +1 -1
- package/dist/adapters/backend/herdr-backend.d.ts.map +1 -1
- package/dist/adapters/backend/herdr-backend.js +2 -1
- package/dist/adapters/backend/herdr-backend.js.map +1 -1
- package/dist/adapters/backend/riff-backend.d.ts +97 -0
- package/dist/adapters/backend/riff-backend.d.ts.map +1 -1
- package/dist/adapters/backend/riff-backend.js +380 -66
- package/dist/adapters/backend/riff-backend.js.map +1 -1
- package/dist/adapters/backend/sandbox.d.ts +8 -0
- package/dist/adapters/backend/sandbox.d.ts.map +1 -1
- package/dist/adapters/backend/sandbox.js +16 -2
- package/dist/adapters/backend/sandbox.js.map +1 -1
- package/dist/adapters/backend/tmux-backend.d.ts +12 -13
- package/dist/adapters/backend/tmux-backend.d.ts.map +1 -1
- package/dist/adapters/backend/tmux-backend.js +113 -53
- package/dist/adapters/backend/tmux-backend.js.map +1 -1
- package/dist/adapters/backend/tmux-pipe-backend.d.ts +4 -3
- package/dist/adapters/backend/tmux-pipe-backend.d.ts.map +1 -1
- package/dist/adapters/backend/tmux-pipe-backend.js +12 -9
- package/dist/adapters/backend/tmux-pipe-backend.js.map +1 -1
- package/dist/adapters/backend/zellij-backend.d.ts +2 -3
- package/dist/adapters/backend/zellij-backend.d.ts.map +1 -1
- package/dist/adapters/backend/zellij-backend.js +6 -13
- package/dist/adapters/backend/zellij-backend.js.map +1 -1
- package/dist/adapters/backend/zellij-observe-backend.d.ts +2 -1
- package/dist/adapters/backend/zellij-observe-backend.d.ts.map +1 -1
- package/dist/adapters/backend/zellij-observe-backend.js +6 -3
- package/dist/adapters/backend/zellij-observe-backend.js.map +1 -1
- package/dist/adapters/backend/zmx-backend.d.ts.map +1 -1
- package/dist/adapters/backend/zmx-backend.js +40 -18
- package/dist/adapters/backend/zmx-backend.js.map +1 -1
- package/dist/adapters/cli/claude-code.d.ts.map +1 -1
- package/dist/adapters/cli/claude-code.js +12 -1
- package/dist/adapters/cli/claude-code.js.map +1 -1
- package/dist/adapters/cli/codex.d.ts.map +1 -1
- package/dist/adapters/cli/codex.js +3 -2
- package/dist/adapters/cli/codex.js.map +1 -1
- package/dist/adapters/cli/dsh.d.ts +4 -0
- package/dist/adapters/cli/dsh.d.ts.map +1 -0
- package/dist/adapters/cli/dsh.js +96 -0
- package/dist/adapters/cli/dsh.js.map +1 -0
- package/dist/adapters/cli/fs-policy.d.ts.map +1 -1
- package/dist/adapters/cli/fs-policy.js +5 -0
- package/dist/adapters/cli/fs-policy.js.map +1 -1
- package/dist/adapters/cli/opencode.d.ts +52 -1
- package/dist/adapters/cli/opencode.d.ts.map +1 -1
- package/dist/adapters/cli/opencode.js +117 -76
- package/dist/adapters/cli/opencode.js.map +1 -1
- package/dist/adapters/cli/opencode2.d.ts +4 -0
- package/dist/adapters/cli/opencode2.d.ts.map +1 -0
- package/dist/adapters/cli/opencode2.js +137 -0
- package/dist/adapters/cli/opencode2.js.map +1 -0
- package/dist/adapters/cli/read-isolation.d.ts +1 -1
- package/dist/adapters/cli/read-isolation.d.ts.map +1 -1
- package/dist/adapters/cli/read-isolation.js +5 -2
- package/dist/adapters/cli/read-isolation.js.map +1 -1
- package/dist/adapters/cli/registry.d.ts +7 -1
- package/dist/adapters/cli/registry.d.ts.map +1 -1
- package/dist/adapters/cli/registry.js +19 -6
- package/dist/adapters/cli/registry.js.map +1 -1
- package/dist/adapters/cli/shared-hints.d.ts.map +1 -1
- package/dist/adapters/cli/shared-hints.js +13 -0
- package/dist/adapters/cli/shared-hints.js.map +1 -1
- package/dist/adapters/cli/types.d.ts +24 -3
- package/dist/adapters/cli/types.d.ts.map +1 -1
- package/dist/adapters/hook-command.d.ts +8 -0
- package/dist/adapters/hook-command.d.ts.map +1 -1
- package/dist/adapters/hook-command.js +11 -0
- package/dist/adapters/hook-command.js.map +1 -1
- package/dist/adapters/hook-installer.d.ts +16 -1
- package/dist/adapters/hook-installer.d.ts.map +1 -1
- package/dist/adapters/hook-installer.js +232 -2
- package/dist/adapters/hook-installer.js.map +1 -1
- package/dist/bot-registry.d.ts +116 -8
- package/dist/bot-registry.d.ts.map +1 -1
- package/dist/bot-registry.js +52 -4
- package/dist/bot-registry.js.map +1 -1
- package/dist/cli/pm2-start-transaction.d.ts +14 -0
- package/dist/cli/pm2-start-transaction.d.ts.map +1 -1
- package/dist/cli/pm2-start-transaction.js +25 -9
- package/dist/cli/pm2-start-transaction.js.map +1 -1
- package/dist/cli/restart-failure-notification.d.ts +54 -0
- package/dist/cli/restart-failure-notification.d.ts.map +1 -0
- package/dist/cli/restart-failure-notification.js +142 -0
- package/dist/cli/restart-failure-notification.js.map +1 -0
- package/dist/cli/restart-failure-owner.d.ts +20 -0
- package/dist/cli/restart-failure-owner.d.ts.map +1 -0
- package/dist/cli/restart-failure-owner.js +27 -0
- package/dist/cli/restart-failure-owner.js.map +1 -0
- package/dist/cli/restart-shutdown-preflight.d.ts +24 -0
- package/dist/cli/restart-shutdown-preflight.d.ts.map +1 -0
- package/dist/cli/restart-shutdown-preflight.js +105 -0
- package/dist/cli/restart-shutdown-preflight.js.map +1 -0
- package/dist/cli/send-dispatch.d.ts +26 -0
- package/dist/cli/send-dispatch.d.ts.map +1 -1
- package/dist/cli/send-dispatch.js +30 -0
- package/dist/cli/send-dispatch.js.map +1 -1
- package/dist/cli.d.ts +4 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +665 -399
- package/dist/cli.js.map +1 -1
- package/dist/codex-app-runner.js +38 -15
- package/dist/codex-app-runner.js.map +1 -1
- package/dist/codex-rpc-lifecycle.d.ts +14 -2
- package/dist/codex-rpc-lifecycle.d.ts.map +1 -1
- package/dist/codex-rpc-lifecycle.js +13 -3
- package/dist/codex-rpc-lifecycle.js.map +1 -1
- package/dist/core/ask-broker.d.ts +3 -0
- package/dist/core/ask-broker.d.ts.map +1 -1
- package/dist/core/ask-broker.js +29 -7
- package/dist/core/ask-broker.js.map +1 -1
- package/dist/core/ask-hook/registry.d.ts.map +1 -1
- package/dist/core/ask-hook/registry.js +4 -0
- package/dist/core/ask-hook/registry.js.map +1 -1
- package/dist/core/ask-types.d.ts +5 -1
- package/dist/core/ask-types.d.ts.map +1 -1
- package/dist/core/ask-types.js.map +1 -1
- package/dist/core/browser-restart.d.ts +112 -0
- package/dist/core/browser-restart.d.ts.map +1 -0
- package/dist/core/browser-restart.js +233 -0
- package/dist/core/browser-restart.js.map +1 -0
- package/dist/core/command-handler.d.ts +19 -11
- package/dist/core/command-handler.d.ts.map +1 -1
- package/dist/core/command-handler.js +237 -43
- package/dist/core/command-handler.js.map +1 -1
- package/dist/core/current-turn-provenance.d.ts.map +1 -1
- package/dist/core/current-turn-provenance.js +7 -27
- package/dist/core/current-turn-provenance.js.map +1 -1
- package/dist/core/dashboard-ipc-server.d.ts.map +1 -1
- package/dist/core/dashboard-ipc-server.js +317 -10
- package/dist/core/dashboard-ipc-server.js.map +1 -1
- package/dist/core/dispatch-registry.d.ts.map +1 -1
- package/dist/core/dispatch-registry.js +6 -0
- package/dist/core/dispatch-registry.js.map +1 -1
- package/dist/core/dispatch-report-binding.d.ts +31 -0
- package/dist/core/dispatch-report-binding.d.ts.map +1 -0
- package/dist/core/dispatch-report-binding.js +88 -0
- package/dist/core/dispatch-report-binding.js.map +1 -0
- package/dist/core/doc-comment-prompt.d.ts +2 -0
- package/dist/core/doc-comment-prompt.d.ts.map +1 -1
- package/dist/core/doc-comment-prompt.js +6 -0
- package/dist/core/doc-comment-prompt.js.map +1 -1
- package/dist/core/host-overload-alert.d.ts +25 -1
- package/dist/core/host-overload-alert.d.ts.map +1 -1
- package/dist/core/host-overload-alert.js +69 -8
- package/dist/core/host-overload-alert.js.map +1 -1
- package/dist/core/local-terminal-opener.js +1 -1
- package/dist/core/local-terminal-opener.js.map +1 -1
- package/dist/core/managed-origin-capability.d.ts +7 -6
- package/dist/core/managed-origin-capability.d.ts.map +1 -1
- package/dist/core/managed-origin-capability.js +32 -1
- package/dist/core/managed-origin-capability.js.map +1 -1
- package/dist/core/passthrough-commands.d.ts.map +1 -1
- package/dist/core/passthrough-commands.js +3 -2
- package/dist/core/passthrough-commands.js.map +1 -1
- package/dist/core/plugins/materializer.d.ts.map +1 -1
- package/dist/core/plugins/materializer.js +1 -0
- package/dist/core/plugins/materializer.js.map +1 -1
- package/dist/core/producer-quiescence.d.ts +70 -0
- package/dist/core/producer-quiescence.d.ts.map +1 -0
- package/dist/core/producer-quiescence.js +90 -0
- package/dist/core/producer-quiescence.js.map +1 -0
- package/dist/core/raw-command-write-options.d.ts +10 -0
- package/dist/core/raw-command-write-options.d.ts.map +1 -0
- package/dist/core/raw-command-write-options.js +23 -0
- package/dist/core/raw-command-write-options.js.map +1 -0
- package/dist/core/raw-command-writer.d.ts +4 -0
- package/dist/core/raw-command-writer.d.ts.map +1 -1
- package/dist/core/raw-command-writer.js +15 -6
- package/dist/core/raw-command-writer.js.map +1 -1
- package/dist/core/reply-target.d.ts +11 -0
- package/dist/core/reply-target.d.ts.map +1 -1
- package/dist/core/reply-target.js +22 -7
- package/dist/core/reply-target.js.map +1 -1
- package/dist/core/report-session-relay.d.ts +53 -0
- package/dist/core/report-session-relay.d.ts.map +1 -0
- package/dist/core/report-session-relay.js +116 -0
- package/dist/core/report-session-relay.js.map +1 -0
- package/dist/core/session-discovery.d.ts +5 -0
- package/dist/core/session-discovery.d.ts.map +1 -1
- package/dist/core/session-discovery.js +13 -0
- package/dist/core/session-discovery.js.map +1 -1
- package/dist/core/session-group-birth.d.ts +7 -0
- package/dist/core/session-group-birth.d.ts.map +1 -0
- package/dist/core/session-group-birth.js +145 -0
- package/dist/core/session-group-birth.js.map +1 -0
- package/dist/core/session-manager.d.ts +16 -21
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +140 -21
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/trigger-session.d.ts.map +1 -1
- package/dist/core/trigger-session.js +18 -3
- package/dist/core/trigger-session.js.map +1 -1
- package/dist/core/types.d.ts +18 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/core/worker-pool.d.ts +63 -11
- package/dist/core/worker-pool.d.ts.map +1 -1
- package/dist/core/worker-pool.js +241 -13
- package/dist/core/worker-pool.js.map +1 -1
- package/dist/daemon.d.ts +33 -0
- package/dist/daemon.d.ts.map +1 -1
- package/dist/daemon.js +900 -137
- package/dist/daemon.js.map +1 -1
- package/dist/dashboard/auth.d.ts +20 -0
- package/dist/dashboard/auth.d.ts.map +1 -1
- package/dist/dashboard/auth.js +86 -1
- package/dist/dashboard/auth.js.map +1 -1
- package/dist/dashboard/bot-payload.d.ts +5 -0
- package/dist/dashboard/bot-payload.d.ts.map +1 -1
- package/dist/dashboard/bot-payload.js +4 -1
- package/dist/dashboard/bot-payload.js.map +1 -1
- package/dist/dashboard/federation-spoke-api.d.ts.map +1 -1
- package/dist/dashboard/federation-spoke-api.js +27 -3
- package/dist/dashboard/federation-spoke-api.js.map +1 -1
- package/dist/dashboard/feedback-analytics-api.d.ts +6 -0
- package/dist/dashboard/feedback-analytics-api.d.ts.map +1 -0
- package/dist/dashboard/feedback-analytics-api.js +39 -0
- package/dist/dashboard/feedback-analytics-api.js.map +1 -0
- package/dist/dashboard/session-action-timeout.d.ts +3 -0
- package/dist/dashboard/session-action-timeout.d.ts.map +1 -0
- package/dist/dashboard/session-action-timeout.js +12 -0
- package/dist/dashboard/session-action-timeout.js.map +1 -0
- package/dist/dashboard/vc-consumer-profiles-api.d.ts +9 -3
- package/dist/dashboard/vc-consumer-profiles-api.d.ts.map +1 -1
- package/dist/dashboard/vc-consumer-profiles-api.js +2 -1
- package/dist/dashboard/vc-consumer-profiles-api.js.map +1 -1
- package/dist/dashboard/web/app.d.ts.map +1 -1
- package/dist/dashboard/web/app.js +48 -5
- package/dist/dashboard/web/app.js.map +1 -1
- package/dist/dashboard/web/bot-defaults-page.d.ts +4 -0
- package/dist/dashboard/web/bot-defaults-page.d.ts.map +1 -1
- package/dist/dashboard/web/bot-defaults-page.js +273 -36
- package/dist/dashboard/web/bot-defaults-page.js.map +1 -1
- package/dist/dashboard/web/bot-defaults.d.ts +6 -0
- package/dist/dashboard/web/bot-defaults.d.ts.map +1 -1
- package/dist/dashboard/web/bot-defaults.js.map +1 -1
- package/dist/dashboard/web/dashboard-routes.d.ts.map +1 -1
- package/dist/dashboard/web/dashboard-routes.js +1 -0
- package/dist/dashboard/web/dashboard-routes.js.map +1 -1
- package/dist/dashboard/web/feedback-page.d.ts +3 -0
- package/dist/dashboard/web/feedback-page.d.ts.map +1 -0
- package/dist/dashboard/web/feedback-page.js +34 -0
- package/dist/dashboard/web/feedback-page.js.map +1 -0
- package/dist/dashboard/web/groups-page.d.ts.map +1 -1
- package/dist/dashboard/web/groups-page.js +7 -2
- package/dist/dashboard/web/groups-page.js.map +1 -1
- package/dist/dashboard/web/i18n.d.ts.map +1 -1
- package/dist/dashboard/web/i18n.js +114 -22
- package/dist/dashboard/web/i18n.js.map +1 -1
- package/dist/dashboard/web/team-federation-page.d.ts.map +1 -1
- package/dist/dashboard/web/team-federation-page.js +26 -2
- package/dist/dashboard/web/team-federation-page.js.map +1 -1
- package/dist/dashboard/web/team-federation.d.ts +19 -0
- package/dist/dashboard/web/team-federation.d.ts.map +1 -1
- package/dist/dashboard/web/team-federation.js +3 -0
- package/dist/dashboard/web/team-federation.js.map +1 -1
- package/dist/dashboard/web/update-action.d.ts +8 -0
- package/dist/dashboard/web/update-action.d.ts.map +1 -1
- package/dist/dashboard/web/update-action.js +10 -0
- package/dist/dashboard/web/update-action.js.map +1 -1
- package/dist/dashboard/web/vc-consumer-profiles-section.d.ts.map +1 -1
- package/dist/dashboard/web/vc-consumer-profiles-section.js +58 -9
- package/dist/dashboard/web/vc-consumer-profiles-section.js.map +1 -1
- package/dist/dashboard-web/app.js +1 -1
- package/dist/dashboard-web/chunks/bot-defaults-page-4RENHE7J.js +10 -0
- package/dist/dashboard-web/chunks/chunk-2WQDS65D.js +1 -0
- package/dist/dashboard-web/chunks/{chunk-CU4SUKK3.js → chunk-6O7KXFD2.js} +1 -1
- package/dist/dashboard-web/chunks/chunk-G5XGBCM6.js +1 -0
- package/dist/dashboard-web/chunks/{chunk-6JTZJRQJ.js → chunk-Q2MT4VWH.js} +15 -15
- package/dist/dashboard-web/chunks/{chunk-5QJB24I2.js → chunk-U3ZFSO7E.js} +1 -1
- package/dist/dashboard-web/chunks/connectors-page-2KZO5KSJ.js +1 -0
- package/dist/dashboard-web/chunks/feedback-page-CLVTOLLO.js +1 -0
- package/dist/dashboard-web/chunks/groups-page-HLASRTSY.js +8 -0
- package/dist/dashboard-web/chunks/{insights-page-EVGGJI5L.js → insights-page-4RPU2CRU.js} +1 -1
- package/dist/dashboard-web/chunks/{monitor-room-HRGR2ENP.js → monitor-room-OTKQ2CXK.js} +1 -1
- package/dist/dashboard-web/chunks/monitoring-page-IJPUB6JT.js +2 -0
- package/dist/dashboard-web/chunks/office-page-QSR3J44Y.js +1 -0
- package/dist/dashboard-web/chunks/overview-page-6OK63V4V.js +1 -0
- package/dist/dashboard-web/chunks/roles-page-6NWJMOB5.js +1 -0
- package/dist/dashboard-web/chunks/schedules-page-6I3LNXD4.js +1 -0
- package/dist/dashboard-web/chunks/{sessions-page-DXBCDWCS.js → sessions-page-B2TXGJDO.js} +1 -1
- package/dist/dashboard-web/chunks/settings-page-6KJADSC6.js +2 -0
- package/dist/dashboard-web/chunks/{skills-page-2QAVB2SA.js → skills-page-M2Q6L5CB.js} +1 -1
- package/dist/dashboard-web/chunks/team-federation-page-7I7FDE3B.js +1 -0
- package/dist/dashboard-web/chunks/{v3-page-AY35LKCX.js → v3-page-HQXRL65L.js} +1 -1
- package/dist/dashboard-web/chunks/whiteboards-page-LQKC4TAZ.js +1 -0
- package/dist/dashboard-web/style.css +35 -0
- package/dist/dashboard.js +199 -12
- package/dist/dashboard.js.map +1 -1
- package/dist/desktop/shared/shell-path-probes.d.ts +1 -1
- package/dist/desktop/shared/shell-path-probes.js +2 -2
- package/dist/desktop/shared/shell-path-probes.js.map +1 -1
- package/dist/dsh-runner.d.ts +3 -0
- package/dist/dsh-runner.d.ts.map +1 -0
- package/dist/dsh-runner.js +666 -0
- package/dist/dsh-runner.js.map +1 -0
- package/dist/global-config.d.ts +24 -0
- package/dist/global-config.d.ts.map +1 -1
- package/dist/global-config.js +35 -0
- package/dist/global-config.js.map +1 -1
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +25 -6
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/zh.d.ts.map +1 -1
- package/dist/i18n/zh.js +25 -6
- package/dist/i18n/zh.js.map +1 -1
- package/dist/im/lark/ask-card.d.ts +3 -1
- package/dist/im/lark/ask-card.d.ts.map +1 -1
- package/dist/im/lark/ask-card.js +61 -5
- package/dist/im/lark/ask-card.js.map +1 -1
- package/dist/im/lark/card-builder.d.ts.map +1 -1
- package/dist/im/lark/card-builder.js +13 -6
- package/dist/im/lark/card-builder.js.map +1 -1
- package/dist/im/lark/card-handler.d.ts +2 -1
- package/dist/im/lark/card-handler.d.ts.map +1 -1
- package/dist/im/lark/card-handler.js +145 -5
- package/dist/im/lark/card-handler.js.map +1 -1
- package/dist/im/lark/event-dispatcher.d.ts +18 -0
- package/dist/im/lark/event-dispatcher.d.ts.map +1 -1
- package/dist/im/lark/event-dispatcher.js +36 -9
- package/dist/im/lark/event-dispatcher.js.map +1 -1
- package/dist/im/lark/md-card.d.ts +18 -0
- package/dist/im/lark/md-card.d.ts.map +1 -1
- package/dist/im/lark/md-card.js +21 -0
- package/dist/im/lark/md-card.js.map +1 -1
- package/dist/im/lark/relay-target-routing.d.ts.map +1 -1
- package/dist/im/lark/relay-target-routing.js +3 -2
- package/dist/im/lark/relay-target-routing.js.map +1 -1
- package/dist/im/lark/reply-mode-command.d.ts.map +1 -1
- package/dist/im/lark/reply-mode-command.js +19 -8
- package/dist/im/lark/reply-mode-command.js.map +1 -1
- package/dist/im/lark/skill-feedback-card.d.ts +15 -0
- package/dist/im/lark/skill-feedback-card.d.ts.map +1 -0
- package/dist/im/lark/skill-feedback-card.js +149 -0
- package/dist/im/lark/skill-feedback-card.js.map +1 -0
- package/dist/services/bot-config-store.d.ts +10 -1
- package/dist/services/bot-config-store.d.ts.map +1 -1
- package/dist/services/bot-config-store.js +103 -3
- package/dist/services/bot-config-store.js.map +1 -1
- package/dist/services/bridge-fallback-gate.d.ts +14 -0
- package/dist/services/bridge-fallback-gate.d.ts.map +1 -1
- package/dist/services/bridge-fallback-gate.js +15 -0
- package/dist/services/bridge-fallback-gate.js.map +1 -1
- package/dist/services/codex-reasoning-effort.d.ts +9 -0
- package/dist/services/codex-reasoning-effort.d.ts.map +1 -0
- package/dist/services/codex-reasoning-effort.js +23 -0
- package/dist/services/codex-reasoning-effort.js.map +1 -0
- package/dist/services/codex-service-tier.d.ts +1 -1
- package/dist/services/codex-service-tier.d.ts.map +1 -1
- package/dist/services/codex-transcript.d.ts +9 -0
- package/dist/services/codex-transcript.d.ts.map +1 -1
- package/dist/services/codex-transcript.js +13 -6
- package/dist/services/codex-transcript.js.map +1 -1
- package/dist/services/feed-group-tagger.d.ts +15 -0
- package/dist/services/feed-group-tagger.d.ts.map +1 -0
- package/dist/services/feed-group-tagger.js +348 -0
- package/dist/services/feed-group-tagger.js.map +1 -0
- package/dist/services/feedback-analytics.d.ts +82 -0
- package/dist/services/feedback-analytics.d.ts.map +1 -0
- package/dist/services/feedback-analytics.js +95 -0
- package/dist/services/feedback-analytics.js.map +1 -0
- package/dist/services/feedback-outbox.d.ts +24 -0
- package/dist/services/feedback-outbox.d.ts.map +1 -0
- package/dist/services/feedback-outbox.js +12 -0
- package/dist/services/feedback-outbox.js.map +1 -0
- package/dist/services/feedback-policy-resolver.d.ts +56 -0
- package/dist/services/feedback-policy-resolver.d.ts.map +1 -0
- package/dist/services/feedback-policy-resolver.js +156 -0
- package/dist/services/feedback-policy-resolver.js.map +1 -0
- package/dist/services/feedback-policy.d.ts +41 -0
- package/dist/services/feedback-policy.d.ts.map +1 -0
- package/dist/services/feedback-policy.js +102 -0
- package/dist/services/feedback-policy.js.map +1 -0
- package/dist/services/feedback-webhook-dispatcher.d.ts +76 -0
- package/dist/services/feedback-webhook-dispatcher.d.ts.map +1 -0
- package/dist/services/feedback-webhook-dispatcher.js +237 -0
- package/dist/services/feedback-webhook-dispatcher.js.map +1 -0
- package/dist/services/grant-prefs-store.d.ts +3 -0
- package/dist/services/grant-prefs-store.d.ts.map +1 -1
- package/dist/services/grant-prefs-store.js +30 -1
- package/dist/services/grant-prefs-store.js.map +1 -1
- package/dist/services/groups-store.d.ts +14 -0
- package/dist/services/groups-store.d.ts.map +1 -1
- package/dist/services/groups-store.js +23 -0
- package/dist/services/groups-store.js.map +1 -1
- package/dist/services/local-cli-opener.d.ts +1 -1
- package/dist/services/local-cli-opener.d.ts.map +1 -1
- package/dist/services/local-cli-opener.js +2 -0
- package/dist/services/local-cli-opener.js.map +1 -1
- package/dist/services/prompt-context-store.d.ts +29 -0
- package/dist/services/prompt-context-store.d.ts.map +1 -0
- package/dist/services/prompt-context-store.js +205 -0
- package/dist/services/prompt-context-store.js.map +1 -0
- package/dist/services/session-group-avatar.d.ts +6 -0
- package/dist/services/session-group-avatar.d.ts.map +1 -0
- package/dist/services/session-group-avatar.js +96 -0
- package/dist/services/session-group-avatar.js.map +1 -0
- package/dist/services/session-group-title.d.ts +47 -0
- package/dist/services/session-group-title.d.ts.map +1 -0
- package/dist/services/session-group-title.js +226 -0
- package/dist/services/session-group-title.js.map +1 -0
- package/dist/services/session-groups-store.d.ts +30 -0
- package/dist/services/session-groups-store.d.ts.map +1 -0
- package/dist/services/session-groups-store.js +132 -0
- package/dist/services/session-groups-store.js.map +1 -0
- package/dist/services/session-store.d.ts +58 -0
- package/dist/services/session-store.d.ts.map +1 -1
- package/dist/services/session-store.js +174 -0
- package/dist/services/session-store.js.map +1 -1
- package/dist/services/skill-feedback-store.d.ts +252 -0
- package/dist/services/skill-feedback-store.d.ts.map +1 -0
- package/dist/services/skill-feedback-store.js +795 -0
- package/dist/services/skill-feedback-store.js.map +1 -0
- package/dist/services/skill-registry-store.d.ts +23 -0
- package/dist/services/skill-registry-store.d.ts.map +1 -1
- package/dist/services/skill-registry-store.js +93 -7
- package/dist/services/skill-registry-store.js.map +1 -1
- package/dist/services/team-store.d.ts +4 -0
- package/dist/services/team-store.d.ts.map +1 -1
- package/dist/services/team-store.js +16 -0
- package/dist/services/team-store.js.map +1 -1
- package/dist/services/traex-transcript.d.ts +32 -4
- package/dist/services/traex-transcript.d.ts.map +1 -1
- package/dist/services/traex-transcript.js +116 -8
- package/dist/services/traex-transcript.js.map +1 -1
- package/dist/services/trigger-types.d.ts +1 -1
- package/dist/services/trigger-types.d.ts.map +1 -1
- package/dist/services/trigger-types.js +2 -2
- package/dist/services/trigger-types.js.map +1 -1
- package/dist/services/turn-completion-events.d.ts +57 -0
- package/dist/services/turn-completion-events.d.ts.map +1 -0
- package/dist/services/turn-completion-events.js +179 -0
- package/dist/services/turn-completion-events.js.map +1 -0
- package/dist/services/vc-meeting-consumer-isolation.d.ts +21 -12
- package/dist/services/vc-meeting-consumer-isolation.d.ts.map +1 -1
- package/dist/services/vc-meeting-consumer-isolation.js +25 -19
- package/dist/services/vc-meeting-consumer-isolation.js.map +1 -1
- package/dist/services/vc-meeting-consumer-profile-bootstrap.d.ts +8 -2
- package/dist/services/vc-meeting-consumer-profile-bootstrap.d.ts.map +1 -1
- package/dist/services/vc-meeting-consumer-profile-bootstrap.js +18 -10
- package/dist/services/vc-meeting-consumer-profile-bootstrap.js.map +1 -1
- package/dist/setup/bot-config-editor.d.ts.map +1 -1
- package/dist/setup/bot-config-editor.js +6 -0
- package/dist/setup/bot-config-editor.js.map +1 -1
- package/dist/setup/cli-availability.d.ts +2 -1
- package/dist/setup/cli-availability.d.ts.map +1 -1
- package/dist/setup/cli-availability.js +2 -1
- package/dist/setup/cli-availability.js.map +1 -1
- package/dist/setup/cli-selection.d.ts +8 -0
- package/dist/setup/cli-selection.d.ts.map +1 -1
- package/dist/setup/cli-selection.js +31 -0
- package/dist/setup/cli-selection.js.map +1 -1
- package/dist/setup/ensure-fonts.d.ts +5 -0
- package/dist/setup/ensure-fonts.d.ts.map +1 -1
- package/dist/setup/ensure-fonts.js +26 -1
- package/dist/setup/ensure-fonts.js.map +1 -1
- package/dist/setup/lark-scopes.json +3 -1
- package/dist/setup/open-platform-automation.d.ts +1 -1
- package/dist/setup/open-platform-automation.d.ts.map +1 -1
- package/dist/setup/open-platform-automation.js +15 -3
- package/dist/setup/open-platform-automation.js.map +1 -1
- package/dist/skills/definitions.d.ts +1 -1
- package/dist/skills/definitions.d.ts.map +1 -1
- package/dist/skills/definitions.js +9 -2
- package/dist/skills/definitions.js.map +1 -1
- package/dist/types.d.ts +10 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/user-token.d.ts +38 -0
- package/dist/utils/user-token.d.ts.map +1 -1
- package/dist/utils/user-token.js +76 -1
- package/dist/utils/user-token.js.map +1 -1
- package/dist/utils/web-terminal-scroll.d.ts +27 -0
- package/dist/utils/web-terminal-scroll.d.ts.map +1 -0
- package/dist/utils/web-terminal-scroll.js +60 -0
- package/dist/utils/web-terminal-scroll.js.map +1 -0
- package/dist/vc-agent/polling-source.d.ts +70 -0
- package/dist/vc-agent/polling-source.d.ts.map +1 -1
- package/dist/vc-agent/polling-source.js +115 -0
- package/dist/vc-agent/polling-source.js.map +1 -1
- package/dist/worker.js +237 -76
- package/dist/worker.js.map +1 -1
- package/dist/workflows/definition.d.ts +22 -22
- package/dist/workflows/events/payloads.d.ts +8 -8
- package/dist/workflows/events/schema.d.ts +20 -20
- package/dist/workflows/migration/v2-run-archive-schema.d.ts +20 -20
- package/package.json +1 -1
- package/dist/dashboard-web/chunks/bot-defaults-page-NQJFJ45Z.js +0 -10
- package/dist/dashboard-web/chunks/chunk-KEEYQ3WF.js +0 -1
- package/dist/dashboard-web/chunks/connectors-page-HADHZXXZ.js +0 -1
- package/dist/dashboard-web/chunks/groups-page-5TYF46RS.js +0 -8
- package/dist/dashboard-web/chunks/monitoring-page-LBU7TTTW.js +0 -2
- package/dist/dashboard-web/chunks/office-page-DF6RRBMN.js +0 -1
- package/dist/dashboard-web/chunks/overview-page-ZB6QH2EX.js +0 -1
- package/dist/dashboard-web/chunks/roles-page-ZBZGHIIF.js +0 -1
- package/dist/dashboard-web/chunks/schedules-page-NQVQC3QY.js +0 -1
- package/dist/dashboard-web/chunks/settings-page-E7NN4NVQ.js +0 -2
- package/dist/dashboard-web/chunks/team-federation-page-VGWL53AE.js +0 -1
- package/dist/dashboard-web/chunks/whiteboards-page-BNWUU4KG.js +0 -1
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{a as be,b as ye,c as we,d as ke}from"./chunk-R3FXBFQH.js";import{a as he,b as ve}from"./chunk-WLIVBPJC.js";import{a as me}from"./chunk-ZJVTGU5X.js";import{c as fe}from"./chunk-KEEYQ3WF.js";import{c as Y,g as Q,h as le,m as ce,n as ue,o as de,p as pe,q as ge}from"./chunk-5CJMHTT4.js";import{A as ae,c as q,d as V,u as K,x as ne}from"./chunk-6JTZJRQJ.js";import{a as se}from"./chunk-SYC6D5XU.js";import{a as Oe,d as ie}from"./chunk-5THX4DI2.js";import{c as X}from"./chunk-7SZRL6FY.js";var l=X(Oe(),1);var De=/^[A-Za-z0-9._-]{1,64}$/,Se=6,Pe=30;function ee(o,t){return we(o,t)}function Ie(o,t,r=Pe){let n=Number.isFinite(r)?Math.max(1,Math.floor(r)):Pe,a=o.length,u=Math.max(1,Math.ceil(a/n)),i=Number.isFinite(t)?Math.floor(t):1,f=Math.min(u,Math.max(1,i)),b=(f-1)*n,C=Math.min(a,b+n);return{rows:o.slice(b,C),page:f,totalPages:u,from:a===0?0:b+1,to:C,total:a}}async function Ce(o,t,r){if(o.length===0)return[];let n=new Array(o.length),a=0,u=Math.min(Math.max(1,t),o.length);return await Promise.all(Array.from({length:u},async()=>{for(;a<o.length;){let i=a++;n[i]=await r(o[i])}})),n}function te(o){return De.test(o)&&o!=="."&&o!==".."}function oe(o){let t=String(o??"").trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64);return te(t)?t:"profile"}async function Z(){let t=await(await fetch("/api/role-profiles")).json().catch(()=>({}));return Array.isArray(t.profiles)?t.profiles:[]}async function Ne(o){let t=await Z(),r=await Ce(t,Se,async i=>{try{let b=await(await fetch(`/api/role-profiles/${encodeURIComponent(i.profileId)}`)).json().catch(()=>({}));return[i.profileId,Array.isArray(b.entries)?b.entries:[]]}catch{return[i.profileId,[]]}}),n=new Set,a=[];for(let i of o.chats??[])for(let f of i.memberBots??[]){if(!f?.inChat||!f?.hasRole||!f?.larkAppId)continue;let b=ee(f.larkAppId,i.chatId);n.has(b)||(n.add(b),a.push({chatId:i.chatId,larkAppId:f.larkAppId}))}let u=await ke(a);return{profiles:t,entriesById:new Map(r),groupRoleContentByBot:u,loaded:!0}}async function Ge(o){let t=(o.memberBots??[]).filter(r=>r?.inChat&&r?.larkAppId);return Ce(t,Se,async r=>{try{let a=await(await fetch(`/api/roles/${encodeURIComponent(r.larkAppId)}/${encodeURIComponent(o.chatId)}`)).json().catch(()=>({})),u=a?.hasEffectiveRole??a?.hasRole,i="effectiveContent"in a?a.effectiveContent:a.content,f=u?String(i??"").trim():"",b=a?.effectiveSource==="chat"||a?.effectiveSource==="team"?a.effectiveSource:null;return{larkAppId:r.larkAppId,botName:r.botName,content:f,status:f?b??"chat":"empty"}}catch{return{larkAppId:r.larkAppId,botName:r.botName,content:"",status:"error"}}})}function Re(o,t){return o.filter(r=>!t||!t.has(r.larkAppId))}function Ae(o,t){let r=t.q.trim().toLowerCase();return o.filter(n=>!r||(n.name??"").toLowerCase().includes(r)||n.chatId.toLowerCase().includes(r)||(n.ownerId??"").toLowerCase().includes(r)).filter(n=>!t.missingOnly||(n.memberBots??[]).some(a=>!a.inChat))}function xe(o,t){if(t.size===0)return!0;let r=o?.memberBots??[];for(let n of t)if(!r.some(a=>a.larkAppId===n&&a.inChat))return!1;return!0}function Be(o){let t=Array.isArray(o)?o:[],r=t.filter(n=>!!n?.ok).length;return{rows:t,okCount:r,failed:t.length-r}}function Te(o,t,r){let n=String(o??"").trim();if(!n)return null;if(r)return{kind:"warn",text:K("groups.roleProfileBootstrapFailed",{name:n,reason:String(r)})};let a=typeof t=="string"&&t.trim()?t.trim():"";return a?{kind:"ok",text:K("groups.roleProfileBootstrapSent",{name:n,messageId:a})}:{kind:"ok",text:K("groups.roleProfileBootstrapDone",{name:n})}}function Ee(o,t,r,n,a){let u=new Set(n);a&&u.add(a);let i={chatId:t,name:r,ownerId:a??null,memberBots:o.bots.map(f=>({larkAppId:f.larkAppId,botName:f.botName,inChat:u.has(f.larkAppId),oncallChat:null}))};return{bots:o.bots,chats:[i,...o.chats.filter(f=>f.chatId!==t)]}}var e=X(ie(),1);function Le(){return{profiles:[],entriesById:new Map,groupRoleContentByBot:new Map,loaded:!1}}function Fe(o){let t={};for(let r of ne(o).split(";")){if(!r)continue;let n=r.indexOf(":");n<=0||(t[r.slice(0,n)]=r.slice(n+1))}return t}function Ue(o){let t=o.chat,r=t.avatar??ae(t.chatId),[n,a]=(0,l.useState)(!1);(0,l.useEffect)(()=>{a(!1)},[r]);let u=t.name??t.chatId,i=!!r&&!n;return(0,e.jsx)("span",{className:`orb-avatar orb-square orb-avatar-sm${i?" orb-has-img":""}`,style:Fe(u),"aria-hidden":"true",children:i?(0,e.jsx)("img",{className:"orb-img",src:r,alt:"",decoding:"async",referrerPolicy:"no-referrer",onError:()=>a(!0)}):null})}function re(o){return(0,e.jsxs)("p",{className:"hint-warn",children:[(0,e.jsx)("strong",{children:o.title}),(0,e.jsx)("br",{}),(0,e.jsx)("small",{children:String(o.reason??"unknown")})]})}function $e(o){let t=Re(o.bots,o.excludeIds),r=o.tr;return(0,e.jsx)(ve,{bots:t,selected:o.selected,onToggle:o.onToggle,searchPlaceholder:r("botPicker.searchPlaceholder"),noMatchLabel:r("botPicker.noMatch"),emptyLabel:r("botPicker.empty"),selectedCountLabel:n=>r("botPicker.selectedCount",{n:String(n)})})}function je(o){let t=o.summary;return t.rows.length?(0,e.jsxs)("div",{className:t.failed?"hint-warn":"hint-ok",children:[(0,e.jsxs)("strong",{children:["\u6DFB\u52A0\u7ED3\u679C\uFF1A\u6210\u529F ",t.okCount,"/",t.rows.length,t.failed?`\uFF0C\u5931\u8D25 ${t.failed}`:""]}),(0,e.jsx)("ul",{children:t.rows.map((r,n)=>{let a=String(r?.id??"?");return(0,e.jsxs)("li",{children:[(0,e.jsx)("code",{children:a}),": ",r?.ok?"OK":`failed (${String(r?.error??"unknown")})`]},`${a}-${n}`)})})]}):(0,e.jsx)("p",{className:"hint-warn",children:"\u6CA1\u6709\u8FD4\u56DE\u6DFB\u52A0\u7ED3\u679C\u3002"})}function He(o){let{chat:t,context:r,tr:n}=o;if(!r.profiles.length||!r.loaded)return null;let a=new Map;for(let b of t.memberBots??[])b?.inChat&&a.set(b.larkAppId,r.groupRoleContentByBot.get(ee(b.larkAppId,t.chatId))??null);if(!be(a))return null;let i=ye(t.memberBots??[],r.profiles,r.entriesById,a)[0];if(!i)return(0,e.jsx)("div",{className:"g-profile-status muted",children:n("groups.profileStatusUnmatched")});let f=i.kind==="full"?"groups.profileStatusFullChat":"groups.profileStatusPartial";return(0,e.jsx)("div",{className:`g-profile-status ${i.kind}`,children:n(f,{name:i.profileId,matched:i.matched,total:i.total,chat:i.chatMatched})})}function _e(o){return o?o.error?"error":o.inChat?"in":"out":"unknown"}function We(o,t){switch(o){case"in":return t("groups.botStatusIn");case"out":return t("groups.botStatusOut");case"error":return t("groups.botStatusError");default:return t("groups.botStatusUnknown")}}function Je(o){let t=new Map((o.chat.memberBots??[]).map(r=>[r.larkAppId,r]));return(0,e.jsx)("div",{className:"groups-bot-strip","aria-label":o.tr("groups.botCoverage"),children:o.bots.map(r=>{let n=t.get(r.larkAppId),a=_e(n),u=We(a,o.tr),i=r.botName??r.larkAppId;return(0,e.jsxs)("span",{className:`groups-bot-pill groups-bot-${a}`,title:`${i}: ${u}${n?.error?` (${String(n.error)})`:""}`,children:[(0,e.jsx)("i",{"aria-hidden":"true"}),(0,e.jsx)("span",{className:"groups-bot-name",children:i}),(0,e.jsx)("span",{className:"groups-bot-state",children:u})]},r.larkAppId)})})}var qe=(0,l.memo)(function(t){let{chat:r,tr:n}=t,u=(r.memberBots??[]).filter(i=>i.inChat).length;return(0,e.jsxs)(ue,{kind:"group",className:"groups-list-row","data-chat":r.chatId,children:[(0,e.jsx)(Ue,{chat:r}),(0,e.jsxs)(de,{children:[(0,e.jsxs)("div",{className:"groups-row-head",children:[(0,e.jsx)("b",{children:r.name??r.chatId}),(0,e.jsxs)("span",{className:"groups-row-meta",children:[(0,e.jsx)("span",{className:"groups-row-tag",children:(0,e.jsx)("code",{children:r.chatId})}),r.ownerId?(0,e.jsxs)("span",{className:"groups-row-tag groups-row-owner-tag",children:[(0,e.jsx)("span",{children:n("groups.owner")}),(0,e.jsx)("code",{children:r.ownerId})]}):null]})]}),(0,e.jsx)(He,{chat:r,context:t.roleContext,tr:n})]}),(0,e.jsx)("span",{className:"groups-row-count",children:n("groups.memberSummary",{count:u,total:t.bots.length})}),(0,e.jsxs)("div",{className:"groups-row-lower",children:[(0,e.jsx)(Je,{chat:r,bots:t.bots,tr:n}),(0,e.jsxs)(pe,{children:[(0,e.jsx)(Q,{className:"add-bots",onClick:()=>t.onAddBots(r),children:n("groups.addBots")}),(0,e.jsx)("button",{className:"save-profile",type:"button",onClick:()=>t.onSaveProfile(r),children:n("groups.saveAsProfile")}),(0,e.jsx)("button",{className:"manage-chat",type:"button",onClick:()=>t.onManage(r),children:n("groups.manage")})]})]})]})});function ze(o){let{tr:t}=o,[r,n]=(0,l.useState)(!1),[a,u]=(0,l.useState)(null),[i,f]=(0,l.useState)(null),[b,C]=(0,l.useState)(!1),[m,S]=(0,l.useState)(new Set),[P,d]=(0,l.useState)(""),[w,v]=(0,l.useState)([]),[k,N]=(0,l.useState)(""),[L,x]=(0,l.useState)(""),[O,j]=(0,l.useState)(""),[$,W]=(0,l.useState)(!0),[A,B]=(0,l.useState)(""),[F,J]=(0,l.useState)(!1),[D,I]=(0,l.useState)(""),[p,G]=(0,l.useState)("");(0,l.useEffect)(()=>{let h=!0;return fetch("/api/feed-groups").then(async y=>{let s=await y.json().catch(()=>({}));if(!y.ok||!s.ok)throw new Error(s.message??s.error??`HTTP ${y.status}`);h&&(v(Array.isArray(s.groups)?s.groups:[]),N(typeof s.larkAppId=="string"?s.larkAppId:""))}).catch(y=>{h&&B(y instanceof Error?y.message:String(y))}).finally(()=>{h&&W(!1)}),()=>{h=!1}},[]),(0,l.useEffect)(()=>{if(!D)return;let h=!0,y=window.setInterval(()=>{fetch("/api/feed-groups").then(async s=>{let c=await s.json().catch(()=>({}));!s.ok||!c.ok||!h||(v(Array.isArray(c.groups)?c.groups:[]),N(typeof c.larkAppId=="string"?c.larkAppId:""),B(""),I(""),G(""))}).catch(()=>{})},1e3);return()=>{h=!1,window.clearInterval(y)}},[D]);async function U(){let h=k?`?larkAppId=${encodeURIComponent(k)}`:"",y=await fetch(`/api/feed-groups/auth-url${h}`),s=await y.json().catch(()=>({}));if(!y.ok||!s.authUrl){u({title:"\u65E0\u6CD5\u53D1\u8D77\u6807\u7B7E\u6388\u6743",reason:s.error??`HTTP ${y.status}`});return}I(String(s.authUrl)),G("")}async function H(h){J(!0);try{let y=await fetch("/api/feed-groups/oauth-callback",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({callbackUrl:h.trim()})}),s=await y.json().catch(()=>({}));if(!y.ok||!s.ok)throw new Error(s.message??s.error??`HTTP ${y.status}`);let c=await fetch("/api/feed-groups"),g=await c.json().catch(()=>({}));if(!c.ok||!g.ok)throw new Error(g.message??g.error??`HTTP ${c.status}`);v(Array.isArray(g.groups)?g.groups:[]),N(typeof g.larkAppId=="string"?g.larkAppId:""),B(""),I(""),G("")}catch(y){u({title:"\u6807\u7B7E\u6388\u6743\u5931\u8D25",reason:y instanceof Error?y.message:String(y)})}finally{J(!1)}}async function _(h){h.preventDefault();let y=new FormData(h.currentTarget),s=String(y.get("name")??"").trim(),c=String(y.get("bindWorkingDir")??"").trim(),g=String(y.get("roleProfileId")??"").trim(),R=[...m];if(R.length===0){u({title:"\u8BF7\u9009\u62E9 bot",reason:"\u81F3\u5C11\u9009\u62E9\u4E00\u4E2A bot \u540E\u518D\u521B\u5EFA\u7FA4\u804A\u3002"});return}n(!0),u(null);try{let T=await fetch("/api/groups/create",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({name:s||void 0,larkAppIds:R,bindWorkingDir:c||void 0,roleProfileId:g||void 0,feedGroupId:L||void 0,newFeedGroupName:O||void 0,feedGroupAppId:L||O?k:void 0})}),E=await T.json().catch(()=>({ok:!1,error:`HTTP ${T.status}`}));E.ok&&E.chatId?(f(E),o.onCreated(E,R,s)):(u({title:"\u521B\u5EFA\u5931\u8D25",reason:E.error??`HTTP ${T.status}`}),n(!1))}catch(T){u({title:"\u7F51\u7EDC\u9519\u8BEF",reason:T}),n(!1)}}if(i){let h=String(i.chatId),y=typeof i.shareLink=="string"&&i.shareLink?i.shareLink:`https://applink.feishu.cn/client/chat/open?openChatId=${encodeURIComponent(h)}`,s=i.invalidBotIds??[],c=i.invalidUserIds??[],g=Array.isArray(i.oncallBindings)?i.oncallBindings:[],R=g.filter(M=>M?.ok).length,T=g.filter(M=>!M?.ok),E=Te(typeof i.roleProfileId=="string"?i.roleProfileId:"",i.roleProfileBootstrapMessageId,i.roleProfileBootstrapError);return(0,e.jsxs)("article",{className:"g-create-dialog g-create-success",children:[(0,e.jsx)("header",{children:(0,e.jsx)("h3",{children:t("groups.successTitle")})}),(0,e.jsxs)("p",{children:[(0,e.jsx)("b",{children:"chatId:"})," ",(0,e.jsx)("code",{children:h})," ",(0,e.jsx)("button",{type:"button","data-copy":h,onClick:()=>{me(h,t("sessions.copy")).then(M=>{M&&(C(!0),o.setTimer(()=>C(!1),800))})},children:t(b?"sessions.copied":"sessions.copy")})]}),(0,e.jsxs)("p",{children:[(0,e.jsx)("b",{children:"\u521B\u5EFA\u8005:"})," ",(0,e.jsx)("code",{children:String(i.creator??"?")})]}),i.feedGroupId?(0,e.jsxs)("p",{className:"hint-ok",children:["\u5DF2\u52A0\u5165\u98DE\u4E66\u6807\u7B7E",i.feedGroupName?`\u300C${String(i.feedGroupName)}\u300D`:"","\u3002"]}):null,i.feedGroupError?(0,e.jsxs)("p",{className:"hint-warn",children:["\u7FA4\u804A\u5DF2\u521B\u5EFA\uFF0C\u4F46\u6807\u7B7E\u8BBE\u7F6E\u5931\u8D25\uFF1A",String(i.feedGroupError)]}):null,(0,e.jsx)(Ve,{resp:i}),g.length>0?T.length===0?(0,e.jsxs)("p",{className:"hint-ok",children:["\u5DF2\u7ED1\u5B9A\u76EE\u5F55\uFF1A",(0,e.jsx)("code",{children:String(i.bindResolvedPath??"")}),"\uFF08",R,"/",g.length," bots\uFF09"]}):(0,e.jsxs)("p",{className:"hint-warn",children:["\u76EE\u5F55\u7ED1\u5B9A\u90E8\u5206\u5931\u8D25\uFF1A\u6210\u529F ",R,"/",g.length,"\u3002",T.map((M,z)=>(0,e.jsxs)("span",{children:[(0,e.jsx)("br",{}),(0,e.jsx)("code",{children:String(M?.larkAppId??"?")}),": ",String(M?.error??"unknown")]},`${M?.larkAppId??"?"}-${z}`))]}):null,E?(0,e.jsx)("p",{className:E.kind==="ok"?"hint-ok":"hint-warn",children:E.text}):null,s.length||c.length?(0,e.jsxs)("ul",{children:[s.length?(0,e.jsxs)("li",{children:["\u65E0\u6548 bot id: ",(0,e.jsx)("code",{children:s.join(", ")})]}):null,c.length?(0,e.jsxs)("li",{children:["\u65E0\u6548\u7528\u6237 open_id: ",(0,e.jsx)("code",{children:c.join(", ")})]}):null]}):null,(0,e.jsxs)("div",{className:"actions",children:[(0,e.jsx)("button",{type:"button",id:"g-create-close",onClick:o.onClose,children:t("sessions.dismiss")}),(0,e.jsx)("a",{className:"btn-link primary",href:y,target:"_blank",rel:"noopener",children:t("groups.openGroup")})]})]})}return(0,e.jsxs)("article",{className:"g-create-dialog",children:[(0,e.jsxs)("header",{className:"g-create-head",children:[(0,e.jsx)("h3",{children:t("groups.createTitle")}),(0,e.jsx)("p",{children:t("groups.createHelp")})]}),(0,e.jsxs)("form",{id:"g-createform",className:"g-create-form",onSubmit:h=>{_(h)},children:[(0,e.jsxs)("fieldset",{className:"g-modal-field g-create-bots",children:[(0,e.jsx)("legend",{children:t("groups.botPicker")}),(0,e.jsx)("div",{className:"g-bot-picker",children:(0,e.jsx)($e,{bots:o.bots,tr:t,selected:m,onToggle:(h,y)=>S(s=>{let c=new Set(s);return y?c.add(h):c.delete(h),c})})})]}),(0,e.jsxs)("div",{className:"g-create-fields",children:[(0,e.jsxs)("fieldset",{className:"g-modal-field",children:[(0,e.jsx)("legend",{children:t("groups.name")}),(0,e.jsx)("input",{type:"text",name:"name",placeholder:t("groups.namePlaceholder"),maxLength:60})]}),(0,e.jsxs)("fieldset",{className:"g-modal-field",children:[(0,e.jsx)("legend",{children:t("groups.bindDir")}),(0,e.jsx)("input",{type:"text",name:"bindWorkingDir",placeholder:"e.g. ~/projects/botmux"}),(0,e.jsx)("small",{children:t("groups.bindDirHelp")})]}),(0,e.jsxs)("fieldset",{className:"g-modal-field g-profile-field",children:[(0,e.jsx)("legend",{children:t("groups.roleProfile")}),(0,e.jsx)("input",{type:"hidden",name:"roleProfileId",value:P}),(0,e.jsx)(ge,{className:"g-profile-menu",ariaLabel:t("groups.roleProfile"),label:P||t("groups.roleProfileNone"),value:P,options:[{value:"",label:t("groups.roleProfileNone")},...o.roleProfiles.map(h=>({value:h.profileId,label:h.profileId}))],onChange:d}),(0,e.jsx)("small",{children:t("groups.roleProfileHelp")})]}),(0,e.jsxs)("fieldset",{className:"g-modal-field g-feed-group-field",children:[(0,e.jsx)("legend",{children:"\u98DE\u4E66\u6807\u7B7E\uFF08\u53EF\u9009\uFF09"}),(0,e.jsx)("input",{type:"hidden",name:"feedGroupId",value:L}),(0,e.jsx)(he,{groups:w,selectedId:L,newName:O,disabled:$||!!A,onChange:(h,y)=>{x(h),j(y)}}),(0,e.jsx)("small",{children:"\u5C55\u5F00\u540E\u53EF\u5728\u7B2C\u4E00\u884C\u8F93\u5165\u65B0\u6807\u7B7E\u540D\u79F0\uFF0C\u6216\u9009\u62E9\u4E0B\u65B9\u5DF2\u6709\u6807\u7B7E\u3002"}),$?(0,e.jsx)("small",{children:"\u6B63\u5728\u8BFB\u53D6\u98DE\u4E66\u6807\u7B7E\u2026"}):null,A?(0,e.jsxs)("div",{className:"hint-warn-inline",children:[(0,e.jsx)("small",{children:A})," ",(0,e.jsx)("button",{type:"button",disabled:F,onClick:()=>{U()},children:F?"\u6B63\u5728\u5B8C\u6210\u6388\u6743\u2026":"\u7ACB\u5373\u6388\u6743"}),(0,e.jsx)("small",{children:" \u6388\u6743\u540E\u4F1A\u5F39\u7A97\u63D0\u793A\u4F60\u7C98\u8D34\u56DE\u8C03\u5730\u5740\u3002"})]}):null,!$&&!A&&w.length===0?(0,e.jsx)("small",{children:"\u5F53\u524D\u6CA1\u6709\u6807\u7B7E\uFF0C\u53EF\u76F4\u63A5\u521B\u5EFA\u4E00\u4E2A\u3002"}):null]})]}),D?(0,e.jsx)("div",{className:"feed-group-auth-overlay",children:(0,e.jsxs)("section",{className:"feed-group-auth-card",role:"dialog","aria-modal":"true","aria-labelledby":"feed-group-auth-title",children:[(0,e.jsx)("h3",{id:"feed-group-auth-title",children:"\u6388\u6743\u98DE\u4E66\u6807\u7B7E"}),(0,e.jsxs)("p",{children:["\u70B9\u51FB\u4E0B\u9762\u7684\u6309\u94AE\uFF0C\u5728\u98DE\u4E66\u9875\u9762\u786E\u8BA4\u6388\u6743\u3002\u5982\u679C BotMux \u4E0E\u6D4F\u89C8\u5668\u5728\u540C\u4E00\u53F0\u7535\u8111\uFF0C\u786E\u8BA4\u540E\u4F1A\u81EA\u52A8\u5B8C\u6210\u6388\u6743\u3002\u5982\u679C BotMux \u8FD0\u884C\u5728\u8FDC\u7A0B\u865A\u62DF\u673A\u4E0A\uFF0C\u6D4F\u89C8\u5668\u4F1A\u56E0\u65E0\u6CD5\u8BBF\u95EE\u672C\u673A\u5730\u5740 ",(0,e.jsx)("code",{children:"127.0.0.1:9768"})," \u800C\u663E\u793A\u201C\u65E0\u6CD5\u8BBF\u95EE\u201D\uFF1B\u6B64\u65F6\u8BF7\u590D\u5236\u5730\u5740\u680F\u4E2D\u7684\u5B8C\u6574\u94FE\u63A5\u5E76\u7C98\u8D34\u5230\u4E0B\u65B9\u3002"]}),(0,e.jsx)("button",{type:"button",className:"primary feed-group-auth-open",onClick:()=>window.open(D,"_blank","noopener"),children:"\u8DF3\u8F6C\u98DE\u4E66\u6388\u6743"}),(0,e.jsxs)("label",{children:[(0,e.jsx)("span",{children:"\u8BF7\u628A\u70B9\u51FB\u6388\u6743\u540E\u7684\u5B8C\u6574\u94FE\u63A5\u7C98\u8D34\u5728\u8FD9\u91CC"}),(0,e.jsx)("input",{type:"url",value:p,placeholder:"http://127.0.0.1:9768/callback?code=\u2026&state=\u2026",onChange:h=>G(h.currentTarget.value)})]}),(0,e.jsxs)("div",{className:"actions",children:[(0,e.jsx)("button",{type:"button",onClick:()=>{I(""),G("")},children:"\u53D6\u6D88"}),(0,e.jsx)("button",{type:"button",className:"primary",disabled:!p.trim()||F,onClick:()=>{H(p)},children:F?"\u6B63\u5728\u5B8C\u6210\u6388\u6743\u2026":"\u5B8C\u6210\u6388\u6743"})]})]})}):null,(0,e.jsx)("div",{className:"g-create-status","data-create-status":!0,"aria-live":"polite",children:a?(0,e.jsx)(re,{...a}):null}),(0,e.jsxs)("div",{className:"actions g-create-actions",children:[(0,e.jsx)("button",{type:"button",id:"g-create-cancel",onClick:o.onClose,children:t("groups.cancel")}),(0,e.jsx)("button",{type:"submit",className:"primary",disabled:r,children:r?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("i",{className:"button-spinner","aria-hidden":"true"}),t("groups.createSubmitting")]}):t("groups.createSubmit")})]})]})]})}function Ve(o){let t=o.resp,r=t.autoInvitedOpenId,n=!!t.autoInviteRejected,a=t.ownerTransferredTo,u=t.transferError,i=t.notifyMessageId,f=t.notifyError;return r?(0,e.jsxs)("p",{className:"hint-ok",children:["\u5DF2\u81EA\u52A8\u9080\u8BF7\u4F60\uFF08",(0,e.jsx)("code",{children:r}),"\uFF09\u4F5C\u4E3A\u6210\u5458\u3002",a?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("br",{}),(0,e.jsx)("small",{children:"\u7FA4\u4E3B\u5DF2\u4ECE\u673A\u5668\u4EBA\u8F6C\u8BA9\u7ED9\u4F60\u3002"})]}):null,u?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("br",{}),(0,e.jsxs)("small",{className:"hint-warn-inline",children:["\u26A0 \u81EA\u52A8\u8F6C\u8BA9\u7FA4\u4E3B\u5931\u8D25\uFF08",u,"\uFF09\uFF0C\u4F60\u73B0\u5728\u662F\u6210\u5458\u4F46\u7FA4\u4E3B\u4ECD\u662F\u673A\u5668\u4EBA\u3002"]})]}):null,i?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("br",{}),(0,e.jsxs)("small",{children:["\u673A\u5668\u4EBA\u5DF2\u5728\u7FA4\u91CC @ \u4E86\u4F60\uFF08\u6D88\u606F id ",(0,e.jsx)("code",{children:i}),"\uFF09\uFF0C\u770B\u98DE\u4E66\u901A\u77E5\u5C31\u80FD\u8FDB\u7FA4\u3002"]})]}):null,f?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("br",{}),(0,e.jsxs)("small",{className:"hint-warn-inline",children:["\u26A0 \u81EA\u52A8 @ \u901A\u77E5\u5931\u8D25\uFF08",f,"\uFF09\uFF0C\u65B0\u7FA4\u53EF\u80FD\u4E0D\u4F1A\u4E3B\u52A8\u51FA\u73B0\u5728\u4F60\u4FA7\u8FB9\u680F\uFF0C\u5EFA\u8BAE\u4ECE\u4E0B\u9762\u6309\u94AE\u8DF3\u8FDB\u53BB\u3002"]})]}):null]}):n?(0,e.jsxs)("p",{className:"hint-warn",children:["\u98DE\u4E66\u62D2\u7EDD\u4E86\u81EA\u52A8\u9080\u8BF7\uFF08\u4F60\u7684 open_id \u5728\u521B\u5EFA\u8005 bot \u7684 scope \u4E0B\u4E0D\u53EF\u7528\uFF09\u3002",(0,e.jsx)("strong",{children:"\u4F60\u76EE\u524D\u4E0D\u662F\u65B0\u7FA4\u6210\u5458"}),"\uFF0C\u9700\u8981\u8BA9\u7FA4\u91CC\u7684\u67D0\u4E2A\u673A\u5668\u4EBA\u624B\u52A8\u628A\u4F60\u52A0\u8FDB\u6765\u3002"]}):(0,e.jsxs)("p",{className:"hint-warn",children:["\u6CA1\u5728 dashboard \u7F13\u5B58\u91CC\u627E\u5230 ownerOpenId\uFF0C",(0,e.jsx)("strong",{children:"\u6CA1\u6709\u81EA\u52A8\u9080\u8BF7\u4F60"}),"\u3002\u70B9\u5F00\u4E0B\u9762\u94FE\u63A5\u524D\uFF0C\u5148\u8BA9\u7FA4\u91CC\u4EFB\u4E00\u673A\u5668\u4EBA\u624B\u52A8\u628A\u4F60\u52A0\u8FDB\u53BB\u3002"]})}function Ke(o){let{chat:t,tr:r}=o,[n,a]=(0,l.useState)(!1),[u,i]=(0,l.useState)(null),[f,b]=(0,l.useState)(null),[C,m]=(0,l.useState)(new Set),S=(0,l.useMemo)(()=>new Set((t.memberBots??[]).filter(d=>d.inChat).map(d=>d.larkAppId)),[t]);async function P(d){d.preventDefault();let w=[...C];if(w.length===0){i({title:"\u8BF7\u9009\u62E9 bot",reason:"\u81F3\u5C11\u9009\u62E9\u4E00\u4E2A bot \u540E\u518D\u6DFB\u52A0\u3002"}),b(null);return}a(!0),i(null),b(null);try{let k=await(await fetch(`/api/groups/${encodeURIComponent(t.chatId)}/add-bots`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({larkAppIds:w})})).json();if(k.error==="no_proxy_bot")i({title:"\u65E0\u6CD5\u6DFB\u52A0 bot",reason:"\u5F53\u524D\u7FA4\u91CC\u6CA1\u6709\u53EF\u4EE3\u7406\u64CD\u4F5C\u7684 bot\u3002\u8BF7\u5148\u5728\u98DE\u4E66\u91CC\u624B\u52A8\u62C9\u5165\u4E00\u4E2A bot\uFF0C\u7136\u540E\u91CD\u8BD5\u3002"});else if(k.result){let N=Be(k.result);try{await o.onReloadGroups({force:!0}),b({result:N})}catch(L){b({result:N,refreshError:`\u6DFB\u52A0\u7ED3\u679C\u5DF2\u8FD4\u56DE\uFF0C\u4F46\u5237\u65B0\u7FA4\u7EC4\u5217\u8868\u5931\u8D25\uFF1A${L}`})}}else i({title:"\u54CD\u5E94\u5F02\u5E38",reason:JSON.stringify(k)})}catch(v){i({title:"\u7F51\u7EDC\u9519\u8BEF",reason:v})}finally{a(!1)}}return(0,e.jsxs)("article",{className:"g-add-bots-dialog",children:[(0,e.jsx)("header",{children:(0,e.jsxs)("h3",{children:[r("groups.addBots")," \xB7 ",t.name??t.chatId]})}),(0,e.jsx)("p",{children:r("groups.createHelp")}),(0,e.jsxs)("form",{id:"g-addform",onSubmit:d=>{P(d)},children:[(0,e.jsx)($e,{bots:o.bots,excludeIds:S,tr:r,selected:C,onToggle:(d,w)=>m(v=>{let k=new Set(v);return w?k.add(d):k.delete(d),k})}),(0,e.jsxs)("div",{"data-add-status":!0,"aria-live":"polite",children:[u?(0,e.jsx)(re,{...u}):null,f?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(je,{summary:f.result}),f.refreshError?(0,e.jsx)(re,{title:"\u5237\u65B0\u5931\u8D25",reason:f.refreshError}):null]}):null]}),(0,e.jsxs)("div",{className:"actions",children:[(0,e.jsx)("button",{type:"button",id:"g-cancel",onClick:o.onClose,children:r("groups.cancel")}),(0,e.jsx)("button",{type:"submit",className:"primary",disabled:n,children:n?"Adding...":r("groups.addBots")})]})]})]})}function Ze(o){let{tr:t}=o,[r,n]=(0,l.useState)([]),[a,u]=(0,l.useState)([]),[i,f]=(0,l.useState)(!0),[b,C]=(0,l.useState)(null),m=(0,l.useMemo)(()=>[...a].sort((p,G)=>p.profileId.localeCompare(G.profileId)),[a]),S=m.length>0,P=r.filter(p=>p.status==="empty").length,d=r.filter(p=>p.status==="error").length,w=!i&&!b&&r.length>0&&d===0,[v,k]=(0,l.useState)("new"),[N,L]=(0,l.useState)(o.suggestedProfileId),[x,O]=(0,l.useState)(""),[j,$]=(0,l.useState)(!1),[W,A]=(0,l.useState)(null),B=v==="overwrite"?x:N.trim(),F=t(v==="overwrite"?"groups.saveProfileOverwriteSubmit":"groups.saveProfileSubmit"),J=b||(i?t("groups.saveProfilePreparing"):d?t("groups.saveProfileFailedLoadSummary",{count:d}):r.length?P?t("groups.saveProfileEntrySummaryWithEmpty",{count:r.length,emptyCount:P}):t("groups.saveProfileEntrySummary",{count:r.length}):t("groups.saveProfileNoRoles"));(0,l.useEffect)(()=>{let p=!0;return f(!0),C(null),A(null),(async()=>{try{let[G,U]=await Promise.all([Ge(o.chat),Z().catch(()=>[])]);if(!p)return;let H=[...U].sort((_,h)=>_.profileId.localeCompare(h.profileId));n(G),u(U),O(_=>H.some(h=>h.profileId===_)?_:H[0]?.profileId??"")}catch(G){if(!p)return;n([]),u([]),O(""),C(G instanceof Error?G.message:String(G))}finally{p&&f(!1)}})(),()=>{p=!1}},[o.chat]);async function D(p){if(p.preventDefault(),!!w){if(!te(B)){A({text:t("groups.saveProfileInvalid"),className:"error"});return}$(!0),A({text:t("groups.saveProfileSaving")});try{let U=(await Promise.all(r.map(async H=>(await fetch(`/api/role-profiles/${encodeURIComponent(B)}/${encodeURIComponent(H.larkAppId)}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({content:H.content,allowEmpty:!0})})).ok))).filter(Boolean).length;if(U!==r.length){A({text:t("groups.saveProfileFailed",{saved:U,total:r.length}),className:"error"}),$(!1);return}A({text:t("groups.saveProfileDone",{name:B,count:U}),className:"ok"}),await o.onRefreshRoleContext(),o.setTimer(o.onClose,700)}catch(G){A({text:String(G),className:"error"}),$(!1)}}}function I(p){p==="overwrite"&&!S||(k(p),A(null))}return(0,e.jsxs)("article",{className:"g-save-profile-dialog",children:[(0,e.jsxs)("header",{children:[(0,e.jsx)("h3",{children:t("groups.saveProfileTitle")}),(0,e.jsx)("p",{children:t("groups.saveProfileIntro",{name:o.chat.name??o.chat.chatId,count:i?"-":r.length})})]}),(0,e.jsxs)("form",{id:"g-save-profile-form",onSubmit:p=>{D(p)},children:[(0,e.jsxs)("section",{className:"g-save-profile-panel",children:[(0,e.jsxs)("div",{className:"g-save-profile-section-head",children:[(0,e.jsx)("span",{children:t("groups.saveProfileScope")}),(0,e.jsx)("small",{children:t("groups.saveProfileScopeHelp")})]}),(0,e.jsxs)("div",{className:"g-save-profile-stats",children:[(0,e.jsxs)("span",{children:[t("groups.saveProfileBotCount")," ",(0,e.jsx)("strong",{children:i?"-":r.length})]}),d?(0,e.jsxs)("span",{className:"warn",children:[t("groups.saveProfileLoadFailed")," ",(0,e.jsx)("strong",{children:d})]}):null]}),(0,e.jsx)("div",{className:"g-save-profile-entry-list",children:i?(0,e.jsx)("div",{className:"g-save-profile-loading",children:(0,e.jsx)(Y,{label:t("common.loading")})}):b?(0,e.jsx)("div",{className:"g-save-profile-empty",children:b}):r.length?r.map(p=>(0,e.jsxs)("div",{className:`g-save-profile-entry ${p.status==="error"?"error":""}`,children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("strong",{children:p.botName??p.larkAppId}),(0,e.jsx)("code",{children:p.larkAppId})]}),(0,e.jsx)("span",{className:`g-save-profile-entry-status ${p.status==="error"?"error":"ok"}`,children:t(p.status==="error"?"groups.saveProfileStatus.error":"groups.saveProfileStatus.entry")})]},p.larkAppId)):(0,e.jsx)("div",{className:"g-save-profile-empty",children:t("groups.saveProfileNoRoles")})})]}),(0,e.jsxs)("div",{className:"form-row",children:[(0,e.jsx)("span",{children:t("groups.saveProfileMode")}),(0,e.jsxs)("div",{className:"g-save-profile-switch",role:"tablist","aria-label":t("groups.saveProfileMode"),children:[(0,e.jsx)("button",{type:"button",className:v==="new"?"active":"","data-save-profile-mode":"new","aria-pressed":v==="new",onClick:()=>I("new"),children:t("groups.saveProfileNew")}),(0,e.jsx)("button",{type:"button",className:v==="overwrite"?"active":"","data-save-profile-mode":"overwrite","aria-pressed":v==="overwrite",disabled:!S,onClick:()=>I("overwrite"),children:t("groups.saveProfileOverwrite")})]})]}),(0,e.jsxs)("label",{className:"form-row","data-profile-mode-row":"new",hidden:v!=="new",children:[(0,e.jsx)("span",{children:t("groups.saveProfileIdLabel")}),(0,e.jsx)("input",{type:"text",name:"profileId",value:N,maxLength:64,autoComplete:"off",onChange:p=>{L(p.currentTarget.value),A(null)}}),(0,e.jsx)("small",{children:t("groups.saveProfileInvalid")})]}),(0,e.jsxs)("div",{className:"form-row","data-profile-mode-row":"overwrite",hidden:v!=="overwrite",children:[(0,e.jsx)("span",{children:t("groups.saveProfileExistingLabel")}),S?(0,e.jsx)("div",{className:"g-save-profile-picker",children:m.map(p=>(0,e.jsxs)("button",{type:"button",className:`g-save-profile-pick ${p.profileId===x?"selected":""}`,"data-profile-id":p.profileId,"aria-pressed":p.profileId===x,onClick:()=>{O(p.profileId),k("overwrite"),A(null)},children:[(0,e.jsx)("span",{children:p.profileId}),(0,e.jsx)("small",{children:t("groups.saveProfileExistingMeta",{count:p.entryCount??0})})]},p.profileId))}):(0,e.jsx)("div",{className:"g-save-profile-summary warn",children:t("groups.saveProfileExistingEmpty")}),(0,e.jsx)("small",{children:t("groups.saveProfileOverwriteHelp")})]}),(0,e.jsxs)("div",{className:"g-save-profile-target",children:[(0,e.jsx)("span",{children:t("groups.saveProfileTarget")}),(0,e.jsx)("code",{"data-save-profile-target":!0,children:B||"-"}),(0,e.jsx)("small",{"data-save-profile-target-mode":!0,children:t(v==="overwrite"?"groups.saveProfileTargetOverwrite":"groups.saveProfileTargetNew")})]}),(0,e.jsx)("div",{className:`g-save-profile-summary ${w?"":"warn"}`,children:J}),(0,e.jsx)("div",{className:`g-save-profile-status ${W?.className??""}`,"data-save-profile-status":!0,children:W?.text??""}),(0,e.jsxs)("div",{className:"actions",children:[(0,e.jsx)("button",{type:"button",id:"g-save-profile-cancel",onClick:o.onClose,children:t("groups.cancel")}),(0,e.jsx)("button",{type:"submit",className:"primary",disabled:!w||j||v==="overwrite"&&!x,children:j?t("groups.saveProfileSaving"):F})]})]})]})}function Xe(o){let{member:t,tr:r}=o,n=(0,l.useRef)(null),[a,u]=(0,l.useState)(!!t.oncallChat),[i,f]=(0,l.useState)(t.oncallChat?.workingDir??""),[b,C]=(0,l.useState)(!1),[m,S]=(0,l.useState)(null);async function P(){S(null);let d=i.trim();if(a&&!d){S({text:r("groups.needWorkingDir"),className:"hint-warn-inline"});return}C(!0);try{let w=`/api/groups/${encodeURIComponent(o.chat.chatId)}/oncall/${encodeURIComponent(t.larkAppId)}`,v=a?await fetch(w,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({workingDir:d})}):await fetch(w,{method:"DELETE"}),k=await v.json().catch(()=>({}));if(v.ok&&k.ok){S({text:a?`\u2713 \u5DF2\u7ED1\u5B9A \u2192 ${k.resolvedPath??d}`:"\u2713 \u5DF2\u89E3\u7ED1",className:"hint-ok"});try{await o.onSaved()}catch{}}else S({text:`\u2717 ${k.error??v.status}`,className:"hint-warn-inline"})}catch(w){S({text:`\u2717 ${w?.message??w}`,className:"hint-warn-inline"})}finally{C(!1)}}return(0,e.jsxs)("div",{className:"oncall-row","data-bot":t.larkAppId,children:[(0,e.jsxs)("label",{className:"checkbox-row",children:[(0,e.jsx)("input",{type:"checkbox","data-action":"toggle",checked:a,onChange:d=>{u(d.currentTarget.checked),d.currentTarget.checked&&window.setTimeout(()=>n.current?.focus(),0)}}),(0,e.jsx)("strong",{children:t.botName??t.larkAppId}),(0,e.jsxs)("small",{children:["(",t.larkAppId,")"]})]}),(0,e.jsxs)("div",{className:"oncall-row-body",children:[(0,e.jsx)("input",{ref:n,type:"text","data-input":"workingDir",placeholder:"e.g. /root/iserver/botmux",value:i,disabled:!a,onChange:d=>f(d.currentTarget.value)}),(0,e.jsx)("button",{type:"button","data-action":"save",disabled:b,onClick:()=>{P()},children:r("groups.save")}),(0,e.jsx)("span",{className:`oncall-status ${m?.className??""}`,"data-status":!0,children:m?.text??""})]})]})}function Ye(o){let{chat:t,tr:r}=o,n=(t.memberBots??[]).filter(m=>m.inChat),a=typeof t.ownerId=="string"?t.ownerId:"",[u,i]=(0,l.useState)(()=>new Set);function f(m,S){i(P=>{let d=new Set(P);return S?d.add(m):d.delete(m),d})}async function b(){let m=[...u];if(m.length===0){alert("\u81F3\u5C11\u9009\u4E00\u4E2A\u673A\u5668\u4EBA");return}if(confirm(`\u786E\u5B9A\u8BA9 ${m.length} \u4E2A\u673A\u5668\u4EBA\u9000\u51FA\u7FA4\u804A\uFF1F\u8BE5 bot \u5728\u6B64\u7FA4\u7684\u4F1A\u8BDD\u4F1A\u4E00\u5E76\u5173\u95ED\u3002`))try{let P=await(await fetch(`/api/groups/${encodeURIComponent(t.chatId)}/leave`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({larkAppIds:m})})).json(),d=(P.result??[]).map(w=>{if(!w.ok)return`${w.larkAppId}: \u5931\u8D25 (${w.error??"unknown"})`;let v=w.closedSessions??[],k=v.filter(x=>!x.ok).length,N=v.length-k,L=v.length===0?"":k===0?`\uFF08\u5173\u95ED ${N} \u4E2A\u4F1A\u8BDD\uFF09`:`\uFF08\u5173\u95ED ${N} \u4E2A\uFF0C${k} \u4E2A\u5931\u8D25\uFF09`;return`${w.larkAppId}: OK${L}`}).join(`
|
|
2
|
-
`);alert(d||`Unexpected: ${JSON.stringify(P)}`),await o.onReloadGroups({force:!0})}catch(S){alert("Network error: "+S)}finally{o.onClose()}}async function C(){if(n.length===0||!confirm(`\u786E\u5B9A\u89E3\u6563\u7FA4\u804A\u300C${t.name??t.chatId}\u300D\uFF1F\u6B64\u64CD\u4F5C\u4E0D\u53EF\u6062\u590D\uFF0C\u672C\u7FA4\u6240\u6709\u673A\u5668\u4EBA\u4F1A\u8BDD\u4E5F\u4F1A\u4E00\u5E76\u5173\u95ED\u3002`))return;let m=[...n].sort((P,d)=>(d.larkAppId===a?1:0)-(P.larkAppId===a?1:0)),S=[];for(let P of m)try{let d=await fetch(`/api/groups/${encodeURIComponent(t.chatId)}/disband`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({larkAppId:P.larkAppId})}),w=await d.json();if(w.ok){let v=w.closedSessions??[],k=v.filter(x=>!x.ok).length,N=v.length-k,L=v.length===0?"":k===0?`
|
|
3
|
-
\u5173\u95ED\u4E86 ${N} \u4E2A\u4F1A\u8BDD\u3002`:`
|
|
4
|
-
\u5173\u95ED\u4E86 ${N} \u4E2A\u4F1A\u8BDD\uFF0C${k} \u4E2A\u4F1A\u8BDD\u5173\u95ED\u5931\u8D25\u3002`;alert(`\u5DF2\u89E3\u6563\uFF08\u7531 ${P.botName??P.larkAppId} \u6267\u884C\uFF09${L}`),await o.onReloadGroups({force:!0}),o.onClose();return}S.push(`${P.botName??P.larkAppId}: ${w.error??d.status}`)}catch(d){S.push(`${P.botName??P.larkAppId}: ${d}`)}alert(`\u6240\u6709\u5728\u7FA4\u673A\u5668\u4EBA\u5747\u65E0\u6CD5\u89E3\u6563\uFF1A
|
|
5
|
-
${S.join(`
|
|
6
|
-
`)}
|
|
7
|
-
|
|
8
|
-
\u5EFA\u8BAE\u6539\u7528\u300C\u9000\u51FA\u7FA4\u804A\u300D\u3002`)}return(0,e.jsxs)("article",{className:"g-manage-dialog",children:[(0,e.jsx)("header",{children:(0,e.jsx)("h3",{children:r("groups.manageTitle",{name:t.name??t.chatId})})}),(0,e.jsxs)("div",{className:"g-manage-meta",children:[(0,e.jsxs)("span",{children:[(0,e.jsx)("b",{children:"chatId"}),(0,e.jsx)("code",{children:t.chatId})]}),(0,e.jsxs)("span",{children:[(0,e.jsx)("b",{children:r("groups.owner")}),(0,e.jsx)("code",{children:t.ownerId??r("common.unknown")})]})]}),(0,e.jsxs)("fieldset",{children:[(0,e.jsx)("legend",{children:r("groups.oncall")}),(0,e.jsx)("p",{children:(0,e.jsx)("small",{children:r("groups.oncallHelp")})}),n.length===0?(0,e.jsx)("p",{className:"empty",children:"\u6CA1\u6709\u673A\u5668\u4EBA\u5728\u7FA4\u91CC"}):n.map(m=>(0,e.jsx)(Xe,{chat:t,member:m,tr:r,onSaved:async()=>{await o.onReloadGroups({force:!0})}},m.larkAppId))]}),(0,e.jsxs)("fieldset",{children:[(0,e.jsx)("legend",{children:r("groups.leaveTitle")}),n.length===0?(0,e.jsx)("p",{className:"empty",children:"\u6CA1\u6709\u673A\u5668\u4EBA\u5728\u7FA4\u91CC"}):(0,e.jsx)("div",{className:"g-leave-picker",children:n.map(m=>(0,e.jsxs)("label",{className:"checkbox-row",children:[(0,e.jsx)("input",{type:"checkbox",name:"leave-bot",value:m.larkAppId,checked:u.has(m.larkAppId),onChange:S=>f(m.larkAppId,S.currentTarget.checked)}),(0,e.jsxs)("span",{className:"checkbox-row-main",children:[(0,e.jsx)("strong",{children:m.botName??m.larkAppId}),m.larkAppId===a?(0,e.jsx)("small",{children:"\xB7 \u7FA4\u4E3B"}):null]})]},m.larkAppId))})]}),(0,e.jsx)("p",{className:"g-manage-danger-hint",children:r("groups.dangerHint")}),(0,e.jsxs)("div",{className:"actions",children:[(0,e.jsx)("button",{type:"button",onClick:o.onClose,children:r("sessions.dismiss")}),(0,e.jsx)("button",{id:"g-leave-btn",type:"button",disabled:n.length===0,onClick:()=>{b()},children:r("groups.leaveSelected")}),(0,e.jsx)("button",{id:"g-disband-btn",type:"button",className:"contrast",disabled:n.length===0,onClick:()=>{C()},children:r("groups.disband")})]})]})}function Qe(o){let t=(0,l.useRef)(null);(0,l.useEffect)(()=>{let a=t.current;if(!a)return;let u=()=>o.onClose();return a.addEventListener("close",u),()=>a.removeEventListener("close",u)},[o.onClose]),(0,l.useEffect)(()=>{let a=t.current;a&&(o.dialog&&!a.open&&a.showModal(),!o.dialog&&a.open&&a.close())},[o.dialog]);let r=null;o.dialog?.type==="create"?r=(0,e.jsx)(ze,{bots:o.snapshot.bots,roleProfiles:o.dialog.roleProfiles,tr:o.tr,onClose:o.onClose,onCreated:o.onCreated,setTimer:o.setTimer}):o.dialog?.type==="add-bots"?r=(0,e.jsx)(Ke,{chat:o.dialog.chat,bots:o.snapshot.bots,tr:o.tr,onClose:o.onClose,onReloadGroups:o.onReloadGroups}):o.dialog?.type==="save-profile"?r=(0,e.jsx)(Ze,{chat:o.dialog.chat,suggestedProfileId:o.dialog.suggestedProfileId,tr:o.tr,onClose:o.onClose,onRefreshRoleContext:o.onRefreshRoleContext,setTimer:o.setTimer}):o.dialog?.type==="manage"&&(r=(0,e.jsx)(Ye,{chat:o.dialog.chat,tr:o.tr,onClose:o.onClose,onReloadGroups:o.onReloadGroups}));let n=o.dialog?.type==="create"?"groups-create-modal":void 0;return(0,e.jsx)("dialog",{id:"g-drawer",className:n,ref:t,onMouseDown:a=>{a.target===a.currentTarget&&a.currentTarget.close()},children:r})}function et(){let o=fe(),t=(0,l.useRef)(!1),r=(0,l.useRef)(q),n=(0,l.useRef)(new Set),a=(0,l.useRef)(new Map),u=(0,l.useRef)(0),[i,f]=(0,l.useState)(q),[b,C]=(0,l.useState)(()=>Le()),[m,S]=(0,l.useState)({q:"",missingOnly:!1}),[P,d]=(0,l.useState)(!0),[w,v]=(0,l.useState)(null),[k,N]=(0,l.useState)(!1),[L,x]=(0,l.useState)(null),[O,j]=(0,l.useState)(1),$=(0,l.useCallback)(s=>{f(c=>{let g=typeof s=="function"?s(c):s;return r.current=g,g})},[]),W=(0,l.useCallback)((s,c)=>{let g=window.setTimeout(()=>{n.current.delete(g),t.current&&s()},c);return n.current.add(g),g},[]),A=(0,l.useCallback)(s=>new Promise(c=>{let g=window.setTimeout(()=>{n.current.delete(g),a.current.delete(g),c()},s);n.current.add(g),a.current.set(g,c)}),[]),B=(0,l.useCallback)(async s=>{let c=++u.current;try{let g=await Ne(s??r.current);t.current&&c===u.current&&C(g)}catch{t.current&&c===u.current&&C({...Le(),loaded:!0})}},[]),F=(0,l.useCallback)(async s=>{let c=await V({force:s?.force});return t.current&&($(c),v(null),B(c)),c},[B,$]),J=(0,l.useCallback)(async(s,c)=>{let g=[600,1200,1200,1200,1200,1200];for(let R of g){if(await A(R),!t.current)return;let T;try{T=await V({force:!0})}catch{continue}if(!t.current)return;let E=(T.chats??[]).find(M=>M.chatId===s);if(E&&xe(E,c)){$(T),B(T);return}}},[A,B,$]);(0,l.useEffect)(()=>(t.current=!0,(async()=>{d(!0);try{await F()}catch(s){t.current&&($(q),v(s instanceof Error?s.message:String(s)),B(q))}finally{t.current&&d(!1)}})(),()=>{t.current=!1,u.current+=1;for(let s of n.current)window.clearTimeout(s);n.current.clear();for(let s of a.current.values())s();a.current.clear()}),[F]);let D=(0,l.useMemo)(()=>Ae(i.chats,m),[i.chats,m]),I=(0,l.useMemo)(()=>Ie(D,O),[D,O]);(0,l.useEffect)(()=>{O!==I.page&&j(I.page)},[O,I.page]);async function p(){N(!0);try{await F({force:!0})}catch(s){v(s instanceof Error?s.message:String(s))}finally{t.current&&N(!1)}}async function G(){if(r.current.bots.length===0){alert(o("groups.noBotsOnline"));return}let s=[];try{s=await Z()}catch{}t.current&&x({type:"create",roleProfiles:s})}function U(s,c,g){let R=String(s.chatId),T=Array.isArray(s.invalidBotIds)?s.invalidBotIds:[],E=c.filter(Me=>!T.includes(Me)),M=new Set(E);typeof s.creator=="string"&&s.creator&&M.add(s.creator);let z=Ee(r.current,R,g||R,E,s.creator);$(z),B(z),J(R,M).catch(()=>{})}let H=(0,l.useCallback)(s=>{let c=new Set((s.memberBots??[]).filter(R=>R.inChat).map(R=>R.larkAppId));if(!r.current.bots.filter(R=>!c.has(R.larkAppId)).length){alert("All configured bots are already in this chat.");return}x({type:"add-bots",chat:s})},[]),_=(0,l.useCallback)(s=>{let c=oe(s.name??""),g=c==="profile"?oe(s.chatId):c;x({type:"save-profile",chat:s,suggestedProfileId:g})},[]),h=(0,l.useCallback)(s=>{x({type:"manage",chat:s})},[]);function y(s){let c=document.getElementById("g-body");c&&(c.scrollTop=0),j(s)}return(0,e.jsxs)("section",{className:"page groups-page",children:[(0,e.jsxs)("div",{className:"page-heading",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"eyebrow",children:o("nav.groups")}),(0,e.jsx)("h1",{children:o("groups.title")})]}),(0,e.jsx)("div",{className:"page-heading-actions",children:(0,e.jsx)(Q,{id:"g-create",className:"page-primary-action",onClick:()=>{G()},children:o("groups.create")})})]}),(0,e.jsxs)("form",{id:"g-filters",className:"filters dashboard-toolbar groups-toolbar",onSubmit:s=>s.preventDefault(),children:[(0,e.jsx)("input",{type:"search",name:"q",placeholder:o("groups.search"),value:m.q,onChange:s=>{let c=s.currentTarget.value;j(1),S(g=>({...g,q:c}))}}),(0,e.jsxs)("label",{className:"filter-toggle",children:[(0,e.jsx)("input",{type:"checkbox",name:"missing",checked:m.missingOnly,onChange:s=>{let c=s.currentTarget.checked;j(1),S(g=>({...g,missingOnly:c}))}}),(0,e.jsx)("span",{className:"filter-toggle-label",children:o("groups.missingOnly")}),(0,e.jsx)("span",{className:"filter-toggle-switch","aria-hidden":"true"})]}),(0,e.jsx)("span",{className:"groups-toolbar-spacer","aria-hidden":"true"}),(0,e.jsxs)("span",{className:"groups-toolbar-count",children:[o("groups.matrixTitle")," ",P?"-/-":`${D.length}/${i.chats.length}`]}),(0,e.jsx)(le,{id:"g-refresh",label:o("groups.refresh"),busy:k,disabled:k,onClick:()=>{p()}})]}),w?(0,e.jsxs)("p",{className:"hint-warn",children:["\u52A0\u8F7D\u7FA4\u7EC4\u5931\u8D25\uFF1A",w]}):null,(0,e.jsx)("section",{className:"overview-block groups-matrix-section",children:P?(0,e.jsx)("div",{id:"g-loading",children:(0,e.jsx)(Y,{label:o("common.loading")})}):(0,e.jsxs)("div",{className:"groups-list-wrap",id:"g-table-wrap",children:[D.length===0?(0,e.jsx)("div",{className:"empty groups-list-empty",id:"g-body",children:o("groups.empty")}):(0,e.jsx)(ce,{id:"g-body",className:"groups-list",children:I.rows.map(s=>(0,e.jsx)(qe,{chat:s,bots:i.bots,roleContext:b,tr:o,onAddBots:H,onSaveProfile:_,onManage:h},s.chatId))}),D.length>0&&I.totalPages>1?(0,e.jsxs)("nav",{className:"groups-pagination","aria-label":o("groups.paginationLabel"),children:[(0,e.jsx)("span",{className:"groups-pagination-status","aria-live":"polite",children:o("groups.pageStatus",{page:I.page,pages:I.totalPages,from:I.from,to:I.to,total:I.total})}),(0,e.jsxs)("div",{className:"groups-pagination-actions",children:[(0,e.jsx)("button",{type:"button",disabled:I.page<=1,onClick:()=>y(I.page-1),children:o("groups.prevPage")}),(0,e.jsx)("button",{type:"button",disabled:I.page>=I.totalPages,onClick:()=>y(I.page+1),children:o("groups.nextPage")})]})]}):null]})}),(0,e.jsx)(Qe,{dialog:L,snapshot:i,tr:o,onClose:()=>x(null),onCreated:U,onReloadGroups:F,onRefreshRoleContext:()=>B(),setTimer:W})]})}function ft(o){return se(o,(0,e.jsx)(et,{}))}export{Ke as AddBotsDialog,ft as renderGroupsPage};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{c as k}from"./chunk-KEEYQ3WF.js";import{c as G,d as f,j as _,m as H,n as T,o as D,p as A}from"./chunk-5CJMHTT4.js";import"./chunk-6JTZJRQJ.js";import{a as U}from"./chunk-SYC6D5XU.js";import{a as Y,d as K}from"./chunk-5THX4DI2.js";import{c as $}from"./chunk-7SZRL6FY.js";var g=$(Y(),1);var e=$(K(),1);function b(n){let s=Number(n);return!Number.isFinite(s)||s<=0?"-":s>=1024**3?`${(s/1024**3).toFixed(1)} GiB`:s>=1024**2?`${(s/1024**2).toFixed(0)} MiB`:`${Math.max(1,Math.round(s/1024))} KiB`}function N(n){let s=Number(n);return Number.isFinite(s)?`${s.toFixed(1)}%`:"-"}function S(n,s){return s?N(n):"-"}function q(n){return n?.cpuReady!==!1}function d(n){let s=Number(n);return Number.isFinite(s)?String(s):"-"}function E(n){let s=Number(n);if(!Number.isFinite(s)||s<0)return"-";if(s===0)return"0s";if(s<6e4)return`${Math.max(1,Math.floor(s/1e3))}s`;let r=Math.floor(s/6e4);if(r<60)return`${Math.max(1,r)}m`;let t=Math.floor(r/60),o=r%60;return o?`${t}h ${o}m`:`${t}h`}function Z(n){return n==="fresh"||n==="stale"||n==="unsupported"?n:"unknown"}function j(n){return n?`${n.botName||"-"} \xB7 ${n.title||n.sessionId}`:"-"}function W(n,s){return s==="cpu"?Number(n.current?.cpu1mPct??n.current?.cpuPct??0):s==="rss"?Number(n.current?.rssBytes??0):s==="growth"?Number(n.current?.rssGrowth5mBytes??0):s==="bot"?n.botName??"":n.status??""}function ee(n,s){return[...n].sort((r,t)=>{let o=W(r,s),u=W(t,s);return typeof o=="number"&&typeof u=="number"?u-o||r.sessionId.localeCompare(t.sessionId):String(o).localeCompare(String(u))||r.sessionId.localeCompare(t.sessionId)})}function V(n,s){return s==="bytes"?b(n):N(n)}function F(n,s,r){let t=(n??[]).filter(Number.isFinite);if(t.length<2)return r("monitoring.chartNoData");let o=t[0],u=Number.isFinite(s)?Number(s):Date.now(),a=Math.max(0,u-o),m=Math.max(1,Math.round(a/6e4));if(m<60)return r("monitoring.chartMinutesAgo",{value:m});let p=Math.round(m/60);return p<48?r("monitoring.chartHoursAgo",{value:p}):r("monitoring.chartDaysAgo",{value:Math.round(p/24)})}function C(n){let s=(n??[]).filter(Number.isFinite);return s.length?s[s.length-1]:void 0}function R({values:n,timestamps:s,unit:r="pct",startLabel:t,endLabel:o,emptyLabel:u,className:a}){let m=(n??[]).filter(Number.isFinite),p=m.length?Math.min(...m):0,x=m.length?Math.max(...m):0,w=x-p,c=m.length>1?m.map((L,i)=>{let l=i/(m.length-1)*100,h=w>0?100-(L-p)/w*100:50;return`${l},${h}`}).join(" "):"",P=c?`0,100 ${c} 100,100`:"",B=c?c.split(" "):[],v=B.length?B[B.length-1].split(",").map(Number):null;return(0,e.jsxs)("div",{className:["resource-chart",a].filter(Boolean).join(" "),children:[(0,e.jsxs)("div",{className:"resource-chart-y","aria-hidden":"true",children:[(0,e.jsx)("span",{children:m.length?V(x,r):"-"}),(0,e.jsx)("span",{children:m.length?V(p,r):"-"})]}),(0,e.jsxs)("div",{className:"resource-chart-plot",children:[(0,e.jsxs)("div",{className:"resource-spark-wrap",children:[(0,e.jsxs)("svg",{className:"resource-spark",viewBox:"0 0 100 100",preserveAspectRatio:"none","aria-label":m.length>1?void 0:u,children:[(0,e.jsx)("line",{x1:"0",y1:"12",x2:"100",y2:"12",className:"resource-grid-line"}),(0,e.jsx)("line",{x1:"0",y1:"50",x2:"100",y2:"50",className:"resource-grid-line"}),(0,e.jsx)("line",{x1:"0",y1:"88",x2:"100",y2:"88",className:"resource-grid-line"}),P?(0,e.jsx)("polygon",{className:"resource-spark-area",points:P}):null,c?(0,e.jsx)("polyline",{points:c}):null]}),v&&Number.isFinite(v[0])&&Number.isFinite(v[1])?(0,e.jsx)("span",{className:"resource-spark-dot","aria-hidden":"true",style:{left:`${v[0]}%`,top:`${v[1]}%`}}):null]}),(0,e.jsxs)("div",{className:"resource-chart-x","aria-hidden":"true",children:[(0,e.jsx)("span",{children:m.length>1?t:u}),(0,e.jsx)("span",{children:m.length>1?o:""})]})]})]})}function I(n){let s=r=>r instanceof Element&&!!r.closest(".ui-info-tip");return(0,e.jsx)("section",{className:"metric-card","data-resource-expandable":"",role:"button",tabIndex:0,"aria-label":n.label,onClick:r=>{s(r.target)||n.onOpen()},onKeyDown:r=>{s(r.target)||r.key!=="Enter"&&r.key!==" "||(r.preventDefault(),n.onOpen())},children:n.children})}function M(n){return(0,e.jsx)("article",{className:"resource-trend-cell","data-resource-expandable":"",role:"button",tabIndex:0,"aria-label":n.label,onClick:n.onOpen,onKeyDown:s=>{s.key!=="Enter"&&s.key!==" "||(s.preventDefault(),n.onOpen())},children:n.children})}function te(n){let s=k(),r=(0,g.useRef)(null);return(0,g.useEffect)(()=>{let t=r.current;if(t)if(n.detail){if(!t.open)try{t.showModal()}catch{}}else t.open&&t.close()},[n.detail]),(0,g.useEffect)(()=>()=>{let t=r.current;t?.open&&t.close()},[]),(0,e.jsx)("dialog",{ref:r,className:"resource-detail-modal",onCancel:t=>{t.preventDefault(),n.onClose()},onClose:n.onClose,onClick:t=>{t.target===t.currentTarget&&n.onClose()},children:n.detail?(0,e.jsxs)("article",{className:"resource-detail-modal-card",children:[(0,e.jsxs)("header",{className:"resource-detail-modal-head",children:[(0,e.jsx)("h3",{children:n.detail.title}),(0,e.jsx)("button",{type:"button",className:"resource-detail-modal-close","aria-label":s("monitoring.modalClose"),title:s("monitoring.modalClose"),onClick:n.onClose})]}),(0,e.jsxs)("div",{className:"resource-detail-modal-body",children:[(0,e.jsxs)("section",{className:"resource-detail-summary",children:[(0,e.jsx)("strong",{children:n.detail.value}),(0,e.jsx)("p",{children:n.detail.detail})]}),n.detail.chart?(0,e.jsx)(R,{className:"resource-detail-chart",values:n.detail.chart.values,timestamps:n.detail.chart.timestamps,unit:n.detail.chart.unit,startLabel:n.detail.chart.startLabel,endLabel:n.detail.chart.endLabel,emptyLabel:n.detail.chart.emptyLabel}):(0,e.jsx)("p",{className:"resource-detail-empty",children:n.detail.emptyText})]})]}):null})}function ne({reasons:n}){return(0,e.jsx)("span",{className:"resource-reasons",children:(n??[]).join(", ")||"-"})}function y({label:n,value:s,tone:r}){return(0,e.jsxs)("span",{className:`resource-pill${r?` ${r}`:""}`,children:[(0,e.jsx)("span",{children:n}),(0,e.jsx)("b",{children:s})]})}function se({bots:n,cpuReady:s=!0}){let r=k();return(0,e.jsx)("div",{className:"resource-list-shell",children:(0,e.jsx)(H,{className:"resource-runtime-list",children:n.length?n.map(t=>{let o=t.runtime?.sessions,u=t.runtime?.daemonStatus??t.daemonStatus??"unknown",a=u==="online"?"ok":u==="offline"?"off":"warn";return(0,e.jsxs)(T,{className:"resource-list-item resource-bot-item",children:[(0,e.jsxs)(D,{children:[(0,e.jsx)("strong",{title:t.botName,children:t.botName}),(0,e.jsxs)("span",{children:[r("monitoring.sessionsCount")," ",d(o?.total??t.sessions?.count)]})]}),(0,e.jsx)(A,{children:(0,e.jsxs)("div",{className:"resource-pill-group",children:[(0,e.jsx)(y,{label:r("monitoring.daemon"),value:u,tone:a}),(0,e.jsx)(y,{label:r("monitoring.working"),value:d(o?.working),tone:"accent"}),(0,e.jsx)(y,{label:r("monitoring.starting"),value:d(o?.starting)}),(0,e.jsx)(y,{label:r("monitoring.cpu"),value:S(t.total?.cpuPct,s)}),(0,e.jsx)(y,{label:r("monitoring.rss"),value:b(t.total?.rssBytes)})]})})]},t.larkAppId)}):(0,e.jsx)("li",{className:"empty",children:r("overview.noSessions")})})})}function re({sessions:n,cpuReady:s=!0}){let r=k();return(0,e.jsx)("div",{className:"resource-list-shell resource-session-shell",children:(0,e.jsx)(H,{className:"resource-runtime-list resource-session-list",children:n.length?n.map(t=>(0,e.jsxs)(T,{className:`resource-list-item resource-session-item${t.tracked?" is-tracked":""}`,children:[(0,e.jsxs)(D,{children:[(0,e.jsx)("strong",{title:t.title||t.sessionId,children:t.title||t.sessionId}),(0,e.jsxs)("span",{title:t.sessionId,children:[t.botName," \xB7 ",t.sessionId]})]}),(0,e.jsx)(A,{children:(0,e.jsxs)("div",{className:"resource-pill-group",children:[(0,e.jsx)(y,{label:r("monitoring.cpu"),value:S(t.current?.cpu1mPct??t.current?.cpuPct,s),tone:"accent"}),(0,e.jsx)(y,{label:r("monitoring.rss"),value:b(t.current?.rssBytes)}),(0,e.jsx)(y,{label:r("monitoring.growth"),value:b(t.current?.rssGrowth5mBytes)}),(0,e.jsx)(y,{label:r("monitoring.confidence"),value:t.confidence??"unknown",tone:t.tracked?"ok":void 0}),(0,e.jsxs)("span",{className:"resource-pill resource-rank-pill",children:[(0,e.jsx)("span",{children:r("monitoring.rank")}),(0,e.jsx)(ne,{reasons:t.rankReasons})]})]})})]},t.sessionId)):(0,e.jsx)("li",{className:"empty",children:r("overview.noSessions")})})})}function oe({current:n}){let s=k(),r=n.runtime,t=q(n),o=Z(r?.sampleHealth?.status),u=r?.daemons?.total,a=r?.daemons?.online,m=r?.daemons?.offline??(Number.isFinite(Number(u))&&Number.isFinite(Number(a))?Math.max(0,Number(u)-Number(a)):void 0),p=r?.sessions?.total,x=r?.sessions?.working,w=r?.sessions?.starting;return(0,e.jsxs)("section",{className:"overview-block resource-block",children:[(0,e.jsx)(f,{title:s("monitoring.runtimeHealth")}),(0,e.jsx)("section",{className:"panel runtime-health-panel",children:(0,e.jsxs)("div",{className:"runtime-health-grid",children:[(0,e.jsxs)("section",{className:"metric-card runtime-health-card",children:[(0,e.jsx)("span",{children:s("monitoring.sampleHealth")}),(0,e.jsx)("strong",{children:(0,e.jsx)("span",{className:`runtime-status-pill ${o}`,children:s(`monitoring.sample.${o}`)})}),(0,e.jsxs)("small",{children:[s("monitoring.sampleAge")," ",E(r?.sampleHealth?.ageMs)]})]}),(0,e.jsxs)("section",{className:"metric-card runtime-health-card",children:[(0,e.jsx)("span",{children:s("monitoring.daemonHealth")}),(0,e.jsxs)("strong",{children:[d(a),"/",d(u)]}),(0,e.jsxs)("small",{children:[d(m)," ",s("monitoring.offline")]})]}),(0,e.jsxs)("section",{className:"metric-card runtime-health-card",children:[(0,e.jsx)("span",{children:s("monitoring.sessionHealth")}),(0,e.jsx)("strong",{children:d(p)}),(0,e.jsxs)("small",{children:[s("monitoring.working")," ",d(x)," \xB7 ",s("monitoring.starting")," ",d(w)]})]}),(0,e.jsxs)("section",{className:"metric-card runtime-health-card",children:[(0,e.jsx)("span",{children:s("monitoring.resourcePressure")}),(0,e.jsx)("strong",{children:S(n.host?.cpuPct,t)}),(0,e.jsxs)("small",{children:[s("monitoring.hostMemory")," ",N(n.host?.memUsedPct)," \xB7 RSS ",b(n.botmux?.rssBytes)]})]})]})})]})}function ae({runtime:n}){let s=k(),r=n?.sessions,t=r?.longestRunning,o=r?.longestWaiting;return(0,e.jsxs)("section",{className:"overview-block resource-block",children:[(0,e.jsx)(f,{title:s("monitoring.sessionPressure")}),(0,e.jsx)("section",{className:"panel runtime-session-pressure",children:(0,e.jsxs)("div",{className:"runtime-session-grid",children:[(0,e.jsxs)("section",{className:"metric-card runtime-session-card",children:[(0,e.jsx)("span",{children:s("monitoring.statusDistribution")}),(0,e.jsx)("strong",{children:d(r?.total)}),(0,e.jsxs)("small",{children:[s("monitoring.working")," ",d(r?.working)," \xB7 ",s("monitoring.starting")," ",d(r?.starting)," \xB7 ",s("monitoring.waiting")," ",d(r?.waiting)," \xB7 ",s("monitoring.idle")," ",d(r?.idle)," \xB7 ",s("monitoring.unknown")," ",d(r?.unknown)]})]}),(0,e.jsxs)("section",{className:"metric-card runtime-session-card",children:[(0,e.jsx)("span",{children:s("monitoring.longestRunning")}),(0,e.jsx)("strong",{children:j(t)}),(0,e.jsx)("small",{children:E(t?.durationMs)})]}),(0,e.jsxs)("section",{className:"metric-card runtime-session-card",children:[(0,e.jsx)("span",{children:s("monitoring.longestWaiting")}),(0,e.jsx)("strong",{children:j(o)}),(0,e.jsx)("small",{children:E(o?.durationMs)})]}),(0,e.jsxs)("section",{className:"metric-card runtime-session-card",children:[(0,e.jsx)("span",{children:s("monitoring.unattributedSessions")}),(0,e.jsx)("strong",{children:d(r?.unattributed)}),(0,e.jsx)("small",{children:s("monitoring.unattributedHint")})]})]})})]})}function ie({initialCurrent:n=null,initialHistory:s=null,poll:r=!0}={}){let t=k(),[o,u]=(0,g.useState)(n),[a,m]=(0,g.useState)(s),[p,x]=(0,g.useState)("cpu"),[w,c]=(0,g.useState)(null);(0,g.useEffect)(()=>{if(!r)return;let l=!1;async function h(){try{let[z,J]=await Promise.all([fetch("/api/resources/current",{cache:"no-store"}),fetch("/api/resources/history?range=3h",{cache:"no-store"})]),[Q,X]=await Promise.all([z.json(),J.json()]);l||(u(Q),m(X))}catch{l||(u({supported:!1,reason:"fetch_failed",bots:[],sessions:[]}),m({supported:!1,bots:[],sessions:[]}))}}h();let O=window.setInterval(()=>{h()},1e4);return()=>{l=!0,window.clearInterval(O)}},[r]);let P=o!==null&&a!==null,B=(0,g.useMemo)(()=>ee(o?.sessions??[],p),[o?.sessions,p]),v=o?.supported!==!1,L=q(o),i={hostStartLabel:F(a?.host?.timestamps,o?.sampledAt,t),botmuxStartLabel:F(a?.botmux?.timestamps,o?.sampledAt,t),endLabel:t("monitoring.chartNow"),emptyLabel:t("monitoring.chartNoData")};return(0,e.jsxs)("section",{className:"page resource-page",children:[(0,e.jsx)("div",{className:"page-heading",children:(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"eyebrow",children:t("monitoring.eyebrow")}),(0,e.jsx)("h1",{children:t("monitoring.runtimeTitle")})]})}),P?null:(0,e.jsx)(G,{label:t("common.loading")}),P?(0,e.jsxs)(e.Fragment,{children:[o?(0,e.jsx)(oe,{current:o}):null,v?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("section",{className:"overview-block resource-block resource-pressure-block",children:[(0,e.jsx)(f,{title:t("monitoring.resourcePressure")}),(0,e.jsx)("section",{className:"panel resource-pressure",children:(0,e.jsxs)("div",{className:"resource-metrics runtime-pressure-grid",children:[(0,e.jsxs)(I,{label:t("monitoring.hostCpu"),onOpen:()=>c({title:t("monitoring.hostCpu"),value:S(o?.host?.cpuPct,L),detail:`load ${Number(o?.host?.load1??0).toFixed(2)}`,chart:{values:a?.host?.cpuPct,timestamps:a?.host?.timestamps,unit:"pct",startLabel:i.hostStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsx)("span",{children:t("monitoring.hostCpu")}),(0,e.jsx)("strong",{children:S(o?.host?.cpuPct,L)}),(0,e.jsxs)("small",{children:["load ",Number(o?.host?.load1??0).toFixed(2)]})]}),(0,e.jsxs)(I,{label:t("monitoring.hostMemory"),onOpen:()=>c({title:t("monitoring.hostMemory"),value:N(o?.host?.memUsedPct),detail:t("monitoring.memoryOnly"),chart:{values:a?.host?.memUsedPct,timestamps:a?.host?.timestamps,unit:"pct",startLabel:i.hostStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsx)("span",{children:t("monitoring.hostMemory")}),(0,e.jsx)("strong",{children:N(o?.host?.memUsedPct)}),(0,e.jsx)("small",{children:t("monitoring.memoryOnly")})]}),(0,e.jsxs)(I,{label:t("monitoring.botmuxRss"),onOpen:()=>c({title:t("monitoring.botmuxRss"),value:b(o?.botmux?.rssBytes),detail:o?.botmuxBreakdown?`${t("monitoring.botmuxSelf")} ${b((o.botmuxBreakdown.daemon.rssBytes??0)+(o.botmuxBreakdown.worker.rssBytes??0))}
|
|
2
|
-
${t("monitoring.botmuxCli")} ${b(o.botmuxBreakdown.cli.rssBytes)}`:S(o?.botmux?.cpuPct,L),chart:{values:a?.botmux?.rssBytes,timestamps:a?.botmux?.timestamps,unit:"bytes",startLabel:i.botmuxStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsxs)("div",{className:"metric-label-with-help",children:[(0,e.jsx)("span",{children:t("monitoring.botmuxRss")}),(0,e.jsx)(_,{label:t("monitoring.rssHelpLabel"),children:t("monitoring.rssHelp")})]}),(0,e.jsx)("strong",{children:b(o?.botmux?.rssBytes)}),o?.botmuxBreakdown&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("small",{className:"metric-breakdown",children:[t("monitoring.botmuxSelf")," ",b((o.botmuxBreakdown.daemon.rssBytes??0)+(o.botmuxBreakdown.worker.rssBytes??0)),(0,e.jsxs)("span",{className:"metric-breakdown-detail",children:[" (",t("monitoring.botmuxDaemon")," ",b(o.botmuxBreakdown.daemon.rssBytes)," \xB7 ",t("monitoring.botmuxWorker")," ",b(o.botmuxBreakdown.worker.rssBytes),")"]})]}),(0,e.jsxs)("small",{className:"metric-breakdown",children:[t("monitoring.botmuxCli")," ",b(o.botmuxBreakdown.cli.rssBytes)]})]})]}),(0,e.jsxs)(I,{label:t("monitoring.trackedSessions"),onOpen:()=>c({title:t("monitoring.trackedSessions"),value:d(o?.rankings?.tracked?.length),detail:`${t("monitoring.currentSessions")} ${(o?.sessions??[]).length}`,emptyText:t("monitoring.trackedSessionHint")}),children:[(0,e.jsx)("span",{children:t("monitoring.trackedSessions")}),(0,e.jsx)("strong",{children:o?.rankings?.tracked?.length??0}),(0,e.jsxs)("small",{children:[t("monitoring.currentSessions")," ",(o?.sessions??[]).length]})]})]})})]}),(0,e.jsxs)("section",{className:"overview-block resource-block",children:[(0,e.jsx)(f,{title:t("monitoring.trends")}),(0,e.jsx)("section",{className:"panel resource-trends",children:(0,e.jsxs)("div",{className:"resource-trend-grid",children:[(0,e.jsxs)(M,{label:t("monitoring.trendHostCpu"),onOpen:()=>c({title:t("monitoring.trendHostCpu"),value:N(C(a?.host?.cpuPct)),detail:`load ${Number(o?.host?.load1??0).toFixed(2)}`,chart:{values:a?.host?.cpuPct,timestamps:a?.host?.timestamps,unit:"pct",startLabel:i.hostStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsx)("b",{children:t("monitoring.trendHostCpu")}),(0,e.jsx)(R,{values:a?.host?.cpuPct,timestamps:a?.host?.timestamps,unit:"pct",startLabel:i.hostStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel})]}),(0,e.jsxs)(M,{label:t("monitoring.trendHostMemory"),onOpen:()=>c({title:t("monitoring.trendHostMemory"),value:N(C(a?.host?.memUsedPct)),detail:t("monitoring.memoryOnly"),chart:{values:a?.host?.memUsedPct,timestamps:a?.host?.timestamps,unit:"pct",startLabel:i.hostStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsx)("b",{children:t("monitoring.trendHostMemory")}),(0,e.jsx)(R,{values:a?.host?.memUsedPct,timestamps:a?.host?.timestamps,unit:"pct",startLabel:i.hostStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel})]}),(0,e.jsxs)(M,{label:t("monitoring.trendBotmuxCpu"),onOpen:()=>c({title:t("monitoring.trendBotmuxCpu"),value:N(C(a?.botmux?.cpuPct)),detail:t("monitoring.botRuntime"),chart:{values:a?.botmux?.cpuPct,timestamps:a?.botmux?.timestamps,unit:"pct",startLabel:i.botmuxStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsx)("b",{children:t("monitoring.trendBotmuxCpu")}),(0,e.jsx)(R,{values:a?.botmux?.cpuPct,timestamps:a?.botmux?.timestamps,unit:"pct",startLabel:i.botmuxStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel})]}),(0,e.jsxs)(M,{label:t("monitoring.botmuxRss"),onOpen:()=>c({title:t("monitoring.botmuxRss"),value:b(C(a?.botmux?.rssBytes)),detail:t("monitoring.memoryOnly"),chart:{values:a?.botmux?.rssBytes,timestamps:a?.botmux?.timestamps,unit:"bytes",startLabel:i.botmuxStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsx)("b",{children:t("monitoring.botmuxRss")}),(0,e.jsx)(R,{values:a?.botmux?.rssBytes,timestamps:a?.botmux?.timestamps,unit:"bytes",startLabel:i.botmuxStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel})]})]})})]})]}):(0,e.jsx)("section",{className:"panel resource-unavailable",children:(0,e.jsxs)("div",{className:"resource-unavailable-card",children:[(0,e.jsx)("span",{className:"resource-unavailable-status","aria-hidden":"true"}),(0,e.jsxs)("div",{className:"resource-unavailable-copy",children:[(0,e.jsx)("span",{children:t("monitoring.unsupportedKicker")}),(0,e.jsx)("h2",{children:t("monitoring.unsupportedTitle")}),(0,e.jsx)("p",{children:t("monitoring.unsupportedHint")})]}),(0,e.jsxs)("div",{className:"resource-unavailable-tags","aria-label":t("monitoring.unsupported"),children:[(0,e.jsx)("span",{children:t("monitoring.unsupportedRuntimeOk")}),(0,e.jsx)("span",{children:t("monitoring.unsupportedResourceOnly")})]})]})}),o?(0,e.jsx)(ae,{runtime:o.runtime}):null,v?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("section",{className:"overview-block resource-block",children:[(0,e.jsx)(f,{title:t("monitoring.botRuntime")}),(0,e.jsx)("section",{className:"panel",children:(0,e.jsx)(se,{bots:o?.bots??[],cpuReady:L})})]}),(0,e.jsxs)("section",{className:"overview-block resource-block",children:[(0,e.jsx)(f,{title:t("monitoring.sessions"),children:(0,e.jsx)("div",{className:"resource-sortbar resource-sortbar-inline dashboard-toolbar",role:"group","aria-label":t("monitoring.sort"),children:(0,e.jsx)("div",{className:"segmented resource-sort-switch",children:["cpu","rss","growth","bot","status"].map(l=>(0,e.jsx)("button",{type:"button",className:p===l?"active":void 0,"aria-pressed":p===l,onClick:()=>x(l),children:t(`monitoring.sort.${l}`)},l))})})}),(0,e.jsx)("section",{className:"panel",children:(0,e.jsx)(re,{sessions:B,cpuReady:L})})]}),(0,e.jsxs)("section",{className:"overview-block resource-block",children:[(0,e.jsx)(f,{title:t("monitoring.trackedSessionTrends")}),(0,e.jsx)("section",{className:"panel",children:(0,e.jsxs)("div",{className:"resource-trend-grid",children:[(a?.sessions??[]).map(l=>{let h=`${l.botName} \xB7 ${l.title||l.sessionId}`,O=F(l.series?.timestamps,o?.sampledAt,t);return(0,e.jsxs)(M,{label:h,onOpen:()=>c({title:h,value:b(C(l.series?.rssBytes)),detail:l.sessionId,chart:{values:l.series?.rssBytes,timestamps:l.series?.timestamps,unit:"bytes",startLabel:O,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsx)("b",{title:h,children:h}),(0,e.jsx)(R,{values:l.series?.rssBytes,timestamps:l.series?.timestamps,unit:"bytes",startLabel:O,endLabel:i.endLabel,emptyLabel:i.emptyLabel})]},l.sessionId)}),(a?.sessions??[]).length?null:(0,e.jsx)("div",{className:"empty",children:t("monitoring.noTrackedHistory")})]})})]})]}):null]}):null,(0,e.jsx)(te,{detail:w,onClose:()=>c(null)})]})}function ce(n){return U(n,(0,e.jsx)(ie,{}))}export{ie as MonitoringPage,re as SessionResourceTable,ce as renderMonitoringPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as w}from"./chunk-KEEYQ3WF.js";import"./chunk-6JTZJRQJ.js";import{a as p}from"./chunk-SYC6D5XU.js";import{a as S,d as x}from"./chunk-5THX4DI2.js";import{c as g}from"./chunk-7SZRL6FY.js";var n=g(S(),1);var e=g(x(),1),u=78222186;function y(t){return(t/1048576).toFixed(0)}function T(){let t=w(),[i,a]=(0,n.useState)(null),[c,l]=(0,n.useState)(""),[m,h]=(0,n.useState)(!1),d=(0,n.useRef)(null),r=(0,n.useRef)(!1),v=()=>{d.current&&(clearTimeout(d.current),d.current=null)};async function f(){if(!r.current)try{let s=await fetch("/api/game/status");if(r.current)return;if(!s.ok){a({state:"absent",received:0,total:u});return}let o=await s.json();if(r.current)return;a(o),typeof o.proxy=="string"&&l(o.proxy),o.state==="downloading"&&(d.current=setTimeout(()=>{f()},700))}catch{r.current||(d.current=setTimeout(()=>{f()},1500))}}(0,n.useEffect)(()=>(r.current=!1,f(),()=>{r.current=!0,v()}),[]);async function b(){v(),h(!0),a({state:"downloading",received:0,total:u});try{let s=await fetch("/api/game/download",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({proxy:c.trim()})});if(r.current)return;if(!s.ok)throw new Error(`HTTP ${s.status}`);let o=await s.json();if(r.current)return;a(o),typeof o.proxy=="string"&&l(o.proxy),o.state==="downloading"&&(d.current=setTimeout(()=>{f()},700))}catch(s){if(r.current)return;a({state:"error",received:0,total:u,error:s instanceof Error?s.message:String(s)})}finally{r.current||h(!1)}}return i?.state==="ready"?(0,e.jsx)("div",{className:"office-frame-shell",children:(0,e.jsx)("iframe",{className:"office-game-frame",src:"/game/index.html",title:"HD2D Office",allow:"autoplay"})}):(0,e.jsx)(P,{status:i??{state:"absent",received:0,total:u},title:t("nav.office"),proxy:c,starting:m,onProxyChange:l,onStart:()=>{b()}})}function P(t){let i=t.status.total||u,a=(0,n.useMemo)(()=>i?Math.min(100,Math.round(t.status.received/i*100)):0,[t.status.received,i]),c=t.status.state==="downloading",l=t.status.state==="error";return(0,e.jsxs)("div",{style:{margin:"auto",textAlign:"center",maxWidth:440,padding:32,color:"var(--fg,#e6e6e6)"},children:[(0,e.jsx)("h1",{style:{fontSize:18,fontWeight:600,lineHeight:1.2,margin:"0 0 8px"},children:t.title}),(0,e.jsxs)("div",{style:{fontSize:13,opacity:.7,lineHeight:1.7,marginBottom:20},children:["\u628A\u6BCF\u4E2A\u4F1A\u8BDD\u53D8\u6210\u529E\u516C\u5BA4\u91CC\u7684\u4E00\u4E2A\u673A\u5668\u4EBA\uFF0C\u5B9E\u65F6\u6620\u5C04\u5C4F\u5E55\u72B6\u6001\u3002",(0,e.jsx)("br",{}),"\u9996\u6B21\u8FDB\u5165\u9700\u4E0B\u8F7D\u7EA6 ",y(i)," MB \u6E38\u620F\u8D44\u6E90\uFF08\u4EC5\u4E00\u6B21\uFF0C\u4E4B\u540E\u672C\u5730\u7F13\u5B58\uFF09\u3002"]}),l?(0,e.jsxs)("div",{style:{color:"#e06c75",fontSize:12,marginBottom:14},children:["\u4E0A\u6B21\u4E0B\u8F7D\u5931\u8D25\uFF1A",t.status.error??"\u672A\u77E5\u9519\u8BEF",(0,e.jsx)("br",{}),(0,e.jsx)("span",{style:{opacity:.7},children:"\u586B\u4EE3\u7406\u540E\u70B9\u91CD\u8BD5"})]}):null,c?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{style:{background:"var(--surface-muted)",borderRadius:"var(--radius-lg)",height:10,overflow:"hidden",marginBottom:10},children:(0,e.jsx)("div",{style:{height:"100%",width:`${a}%`,background:"var(--accent)",transition:"width .3s"}})}),(0,e.jsxs)("div",{style:{fontSize:12,opacity:.7},children:["\u4E0B\u8F7D\u4E2D... ",y(t.status.received)," / ",y(i)," MB\uFF08",a,"%\uFF09"]})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("input",{id:"hd2d-proxy",className:"office-proxy-input",type:"text",value:t.proxy,onChange:m=>t.onProxyChange(m.currentTarget.value),placeholder:"HTTP \u4EE3\u7406\uFF08\u53EF\u9009\uFF0C\u5982 http://127.0.0.1:7890\uFF09"}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.5,marginBottom:14,textAlign:"left"},children:"\u8FDE\u4E0D\u4E0A GitHub \u65F6\u586B\u4EE3\u7406\uFF08\u4EC5\u7528\u4E8E\u4E0B\u8F7D\u672C\u8D44\u6E90\uFF0C\u4F1A\u8BB0\u4F4F\uFF09\u3002\u7559\u7A7A\u8D70\u76F4\u8FDE/\u7CFB\u7EDF\u4EE3\u7406\u73AF\u5883\u53D8\u91CF\u3002"}),(0,e.jsxs)("button",{id:"hd2d-load",type:"button",className:"page-primary-action office-load-button",disabled:t.starting,onClick:t.onStart,children:[l?"\u91CD\u8BD5":"\u52A0\u8F7D\u529E\u516C\u5BA4","\uFF08\u7EA6 ",y(i)," MB\uFF09"]})]})]})}function B(t){let i={maxWidth:t.style.maxWidth,padding:t.style.padding,flex:t.style.flex,minHeight:t.style.minHeight,minWidth:t.style.minWidth,display:t.style.display,overflow:t.style.overflow};t.style.maxWidth="none",t.style.padding="0",t.style.flex="1 1 auto",t.style.minHeight="0",t.style.minWidth="0",t.style.display="flex",t.style.overflow="hidden";let a=p(t,(0,e.jsx)(T,{}));return()=>{a(),t.style.maxWidth=i.maxWidth,t.style.padding=i.padding,t.style.flex=i.flex,t.style.minHeight=i.minHeight,t.style.minWidth=i.minWidth,t.style.display=i.display,t.style.overflow=i.overflow}}export{B as renderOfficePage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as Q,b as ee}from"./chunk-5QJB24I2.js";import{a as j,c as N}from"./chunk-KEEYQ3WF.js";import{b as x,d as T,e as k,f as I,k as X,m as O,n as P,o as _,p as G,r as J}from"./chunk-5CJMHTT4.js";import{D as q,F as H,G as V,H as M,I as g,J as A,w as L,y as $,z as C}from"./chunk-6JTZJRQJ.js";import{a as W}from"./chunk-SYC6D5XU.js";import{a as re,d as K}from"./chunk-5THX4DI2.js";import{c as E}from"./chunk-7SZRL6FY.js";var r=E(re(),1);var t=E(K(),1),le=new Set(["working","analyzing","active","starting"]),ce=new Set(["idle","dormant"]),te="botmux.overview.teamExpanded",ne="botmux.overview.activeSort",z=5,B=1,ve=260;function de(){try{return window.localStorage.getItem(te)==="1"}catch{return!1}}function me(e){try{window.localStorage.setItem(te,e?"1":"0")}catch{}}function ue(e){return e==="attention"?"attention":"time"}function pe(){try{return ue(window.localStorage.getItem(ne))}catch{return"time"}}function we(e){try{window.localStorage.setItem(ne,e)}catch{}}function fe(e,o){let s=(i,a)=>Number(a.lastMessageAt??0)-Number(i.lastMessageAt??0);return o==="attention"?[...e].sort((i,a)=>{let v=g(i)?0:1,c=g(a)?0:1;if(v!==c)return v-c;if(v===0){let d=A(i)-A(a);if(d!==0)return d}return s(i,a)}):[...e].sort(s)}function ge(e){return String(e??"unknown").toLowerCase().replace(/[^a-z0-9_-]/g,"-")}function Se(e,o){let s=String(e??"unknown"),i=`sessions.status.${s}`,a=o(i);return a===i?s:a}function he(e){if(!e)return B*z;let o=window.getComputedStyle(e).gridTemplateColumns.split(/\s+/).filter(i=>Number.parseFloat(i)>0);return Math.max(1,o.length||z)*B}function be(e,o){if(!e)return;let s=document.querySelector(".sidebar");if(!s||window.matchMedia("(max-width: 980px)").matches){e.style.removeProperty(o);return}let i=s.getBoundingClientRect().bottom,a=e.getBoundingClientRect().top,c=`${Math.max(ve,Math.round(i-a))}px`;e.style.getPropertyValue(o)!==c&&e.style.setProperty(o,c)}function Ae({card:e}){let o=N(),s=$(e.larkAppId,e.brand),i=!e.online&&e.active.length===0,a=e.attention.length>0,v=e.busy.length>0,c=a?"warn":v?"busy":i?"off":"ok",d;if(a){let u=[...e.attention].sort((h,f)=>A(h)-A(f))[0];d=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:(M(u.title)||u.sessionId).slice(0,60)})," \xB7 ",g(u)??""]})}else if(v){let u=[...e.busy].sort((h,f)=>Number(f.lastMessageAt??0)-Number(h.lastMessageAt??0))[0];d=(0,t.jsx)("b",{children:(M(u.title)||u.sessionId).slice(0,60)})}else i?d=o("overview.botOffline"):d=o("overview.botIdle");let S=a?(0,t.jsx)("span",{className:"tag tag-warn",children:o("overview.botNeedsYou")}):v?(0,t.jsx)("span",{className:"tag tag-run",children:o("overview.botBusy",{count:e.busy.length})}):i?(0,t.jsx)("span",{className:"tag tag-off",children:o("overview.botOff")}):(0,t.jsx)("span",{className:"tag tag-ok",children:o("overview.botReady")});return(0,t.jsxs)("article",{className:`mate${a?" mate-attn":""}${i?" mate-off":""}`,children:[s?(0,t.jsx)("a",{className:"mate-console",href:s,target:"_blank",rel:"noopener noreferrer","data-tip":o("overview.botConsole"),"aria-label":o("overview.botConsole"),children:(0,t.jsx)("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M7 17 17 7M9 7h8v8"})})}):null,(0,t.jsxs)("div",{className:"mate-top",children:[(0,t.jsx)(x,{html:C({name:e.botName,larkAppId:e.larkAppId,avatarUrl:e.botAvatarUrl,dot:c})}),(0,t.jsxs)("div",{className:"mate-id",children:[(0,t.jsx)("b",{children:e.botName}),(0,t.jsx)("span",{className:"mate-role",children:e.cliId})]})]}),(0,t.jsx)("div",{className:"mate-task",children:d}),(0,t.jsxs)("div",{className:"mate-foot",children:[S,(0,t.jsx)("span",{children:e.lastActiveAt?o("overview.lastActive",{time:L(e.lastActiveAt)}):o("common.never")})]})]})}function Ne({session:e}){let o=N(),s=H(e),i=String(e.status??"unknown"),a=g(e);return(0,t.jsxs)(P,{kind:"session",children:[(0,t.jsx)(x,{html:C({name:s,larkAppId:e.larkAppId,size:"sm"})}),(0,t.jsxs)(_,{children:[(0,t.jsx)("b",{children:(M(e.title)||e.sessionId).slice(0,64)}),(0,t.jsxs)("span",{children:[s," \xB7 ",V(e)??e.cliId??"unknown"," \xB7 ",L(e.lastMessageAt)]})]}),(0,t.jsx)(G,{children:a?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("a",{className:"overview-list-action",href:"#/sessions",children:o("strip.handle")}),(0,t.jsx)("span",{className:"status overview-list-status status-attention",children:a})]}):(0,t.jsx)("span",{className:`status overview-list-status status-${ge(i)}`,children:Se(i,o)})})]})}function ye({schedule:e,timeZone:o}){let s=e.nextRunAt?new Date(e.nextRunAt).toLocaleString(void 0,o?{timeZone:o,timeZoneName:"short"}:void 0):"-";return(0,t.jsxs)(P,{kind:"schedule",children:[(0,t.jsxs)(_,{children:[(0,t.jsx)("strong",{children:e.name??e.id}),(0,t.jsxs)("span",{children:[H(e)," \xB7 ",e.parsed?.display??""]})]}),(0,t.jsx)("span",{className:"overview-list-meta",children:(0,t.jsx)(X,{text:s,showPopover:!1,durationMs:2600})})]})}function Me({mode:e,onModeChange:o}){let s=N(),i=s(e==="attention"?"overview.sortAttentionFirst":"overview.sortByTime");return(0,t.jsx)(J,{className:"overview-active-sort-menu",label:i,value:e,options:[{value:"time",label:s("overview.sortByTime")},{value:"attention",label:s("overview.sortAttentionFirst")}],onChange:o})}function Te(){let e=N(),o=(0,r.useRef)(null),s=(0,r.useRef)(null),i=(0,r.useRef)(null),[a,v]=(0,r.useState)(de),[c,d]=(0,r.useState)(pe),[S,u]=(0,r.useState)(B*z),[h,f]=(0,r.useState)(0),{sessions:y,schedules:D,scheduleTimeZone:oe}=j(n=>({sessions:[...n.sessions.values()],schedules:[...n.schedules.values()],scheduleTimeZone:n.scheduleTimeZone}));(0,r.useEffect)(()=>{let n=0,m=()=>{window.cancelAnimationFrame(n),n=window.requestAnimationFrame(()=>{let w=he(o.current);u(l=>l===w?l:w)})};m();let p=typeof ResizeObserver>"u"||!o.current?null:new ResizeObserver(m);return p&&o.current&&p.observe(o.current),window.addEventListener("resize",m),()=>{window.cancelAnimationFrame(n),p?.disconnect(),window.removeEventListener("resize",m)}},[]),(0,r.useEffect)(()=>{Q().then(()=>f(n=>n+1)),q().then(()=>f(n=>n+1))},[]);let F=(0,r.useMemo)(()=>y.filter(n=>n.status!=="closed"),[y]),b=(0,r.useMemo)(()=>ee(y),[y,h]),U=a?b:b.slice(0,S),Y=(0,r.useMemo)(()=>fe(F.filter(n=>g(n)||le.has(n.status)||ce.has(n.status)),c).slice(0,7),[F,c]),R=(0,r.useMemo)(()=>D.filter(n=>n.nextRunAt).sort((n,m)=>Date.parse(n.nextRunAt)-Date.parse(m.nextRunAt)).slice(0,5),[D]);(0,r.useEffect)(()=>{let n=[{el:s.current,propertyName:"--active-sessions-min-height"},{el:i.current,propertyName:"--schedules-panel-min-height"}].filter(l=>!!l.el);if(!n.length)return;let m=0,p=()=>{window.cancelAnimationFrame(m),m=window.requestAnimationFrame(()=>{for(let l of n)be(l.el,l.propertyName)})};p();let w=typeof ResizeObserver>"u"?null:new ResizeObserver(p);if(w){for(let ae of n)w.observe(ae.el);let l=document.querySelector(".sidebar"),Z=n[0].el.closest(".page");l&&w.observe(l),Z&&w.observe(Z)}return window.addEventListener("resize",p),()=>{window.cancelAnimationFrame(m),w?.disconnect(),window.removeEventListener("resize",p);for(let l of n)l.el.style.removeProperty(l.propertyName)}},[a,S,b.length,R.length]);let se=()=>{v(n=>(me(!n),!n))},ie=n=>{d(n),we(n)};return(0,t.jsxs)("section",{className:"page hero-page",children:[(0,t.jsx)("div",{className:"page-heading",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"eyebrow",children:e("app.subtitle")}),(0,t.jsx)("h1",{children:e("overview.title")})]})}),(0,t.jsxs)("div",{className:"overview-layout",children:[(0,t.jsxs)("div",{className:"overview-main",children:[(0,t.jsxs)("section",{className:"overview-block team-section",children:[(0,t.jsx)(T,{title:e("overview.team"),count:e("overview.teamCount",{count:b.length}),hint:e("overview.teamHint"),children:(0,t.jsx)(I,{children:(0,t.jsx)(k,{href:"#/bot-defaults",children:e("overview.viewAllPlain")})})}),(0,t.jsx)("div",{className:"team-grid",id:"team-grid",ref:o,children:U.length?U.map(n=>(0,t.jsx)(Ae,{card:n},n.larkAppId??n.botName)):(0,t.jsx)("div",{className:"empty",children:e("overview.noSessions")})}),b.length>S?(0,t.jsx)("button",{type:"button",className:"team-toggle",id:"team-toggle",onClick:se,children:e(a?"overview.teamCollapse":"overview.teamExpand")}):null]}),(0,t.jsxs)("section",{className:"overview-block",children:[(0,t.jsx)(T,{title:e("overview.activeSessions"),children:(0,t.jsxs)(I,{children:[(0,t.jsx)(Me,{mode:c,onModeChange:ie}),(0,t.jsx)(k,{href:"#/sessions",children:e("overview.viewAllPlain")})]})}),(0,t.jsx)("section",{className:"panel active-sessions-panel",ref:s,children:(0,t.jsx)(O,{id:"recent-sessions",children:Y.length?Y.map(n=>(0,t.jsx)(Ne,{session:n},n.sessionId)):(0,t.jsx)("li",{className:"empty",children:e("overview.noSessions")})})})]})]}),(0,t.jsx)("aside",{className:"overview-side",children:(0,t.jsxs)("section",{className:"overview-block",children:[(0,t.jsx)(T,{title:e("overview.nextSchedules"),children:(0,t.jsx)(k,{href:"#/schedules",children:e("overview.viewAllPlain")})}),(0,t.jsx)("section",{className:"panel schedules-panel",ref:i,children:(0,t.jsx)(O,{id:"next-schedules",children:R.length?R.map(n=>(0,t.jsx)(ye,{schedule:n,timeZone:oe},n.id)):(0,t.jsx)("li",{className:"empty",children:e("overview.noSchedules")})})})]})})]})]})}function He(e){e.classList.add("overview-root");let o=W(e,(0,t.jsx)(Te,{}));return()=>{o(),e.classList.remove("overview-root")}}export{He as renderOverviewPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as Gt,b as Ft,c as $t,d as Ot}from"./chunk-R3FXBFQH.js";import{c as Dt}from"./chunk-KEEYQ3WF.js";import{b as Bt,c as ce,h as $e,q as Oe}from"./chunk-5CJMHTT4.js";import{D as At,z as Et}from"./chunk-6JTZJRQJ.js";import{a as Fe}from"./chunk-SYC6D5XU.js";import{a as bn,d as _t}from"./chunk-5THX4DI2.js";import{c as Ge}from"./chunk-7SZRL6FY.js";var a=Ge(bn(),1);function jt(t,n){let r=n.trim().toLowerCase();return r?t.filter(o=>o.openId.toLowerCase().includes(r)||o.name.toLowerCase().includes(r)||o.memberType.toLowerCase().includes(r)):t}function Ut(t){return[...new Set([...t].filter(Boolean))]}function Ht(t){let n=new Set(t.targetIds.filter(Boolean));if(t.mode==="all_except_excluded"){let o=new Set(t.exclude);for(let c of n)o.delete(c),t.listening||o.add(c);return{include:[],exclude:Ut(o)}}let r=new Set(t.include);for(let o of n)r.delete(o),t.listening&&r.add(o);return{include:Ut(r),exclude:[]}}function Ue(t){let n=t.targetIds.filter(Boolean);if(n.length===0)return t.mode==="all_except_excluded"?"listen":"ignore";let r=new Set;if(t.mode==="all_except_excluded"){let o=new Set(t.exclude);for(let c of n)r.add(o.has(c)?"ignore":"listen")}else{let o=new Set(t.include);for(let c of n)r.add(o.has(c)?"listen":"ignore")}return r.size===1?[...r][0]:"mixed"}function Vt(t,n,r){let o={};for(let c of t){if(!c)continue;let m=n(c),f=m==="user"||m==="bot"?m:r?.[c];(f==="user"||f==="bot")&&(o[c]=f)}return o}var O=32768,qt=Math.floor(O*.95),pe=32768,Kt=Math.floor(pe*.95),je=5,He=20,hn=/^[A-Za-z0-9._-]{1,64}$/;function Ve(t){return hn.test(t)&&t!=="."&&t!==".."}function Wt(t=location.hash){let[,n=""]=t.split("?");return new URLSearchParams(n).get("chatId")?.trim()||null}function qe(t,n){return $t(t,n)}function we(t){return new TextEncoder().encode(t).length}function Yt(t){return t.memberBots.filter(n=>n.inChat&&n.hasRole).length}function zt(t){return t.memberBots.filter(n=>n.inChat).length}function me(t,n){return n?t.find(r=>r.larkAppId===n):void 0}function Jt(t,n){let r=n.toLowerCase();return r?t.filter(o=>{let c=o.chatId.toLowerCase().includes(r)||(o.name??"").toLowerCase().includes(r),m=o.memberBots.some(f=>f.larkAppId.toLowerCase().includes(r)||(f.botName??"").toLowerCase().includes(r));return c||m}):t}function Xt(t,n){let r=n.toLowerCase();return t.filter(o=>!r||o.profileId.toLowerCase().includes(r))}async function x(t){return t.json().catch(()=>({}))}async function Qt(){let t=await fetch("/api/groups"),n=await x(t);return{bots:(n.bots??[]).map(r=>({larkAppId:r.larkAppId,botName:r.botName??r.larkAppId,botAvatarUrl:r.botAvatarUrl})),groups:(n.chats??[]).map(r=>({chatId:r.chatId,name:r.name??r.chatId,memberBots:(r.memberBots??[]).map(o=>({larkAppId:o.larkAppId,botName:o.botName??o.larkAppId,inChat:o.inChat??!1,hasRole:o.hasRole??!1,hasMessageListener:o.hasMessageListener??!1,oncallChat:o.oncallChat??null}))}))}}async function Zt(){let t=await fetch("/api/role-profiles");return(await x(t)).profiles??[]}async function q(t){let n=await fetch(`/api/role-profiles/${encodeURIComponent(t)}`);return(await x(n)).entries??[]}async function Ke(t,n){let r=await fetch(`/api/roles/${encodeURIComponent(t)}/${encodeURIComponent(n)}`);return x(r)}async function er(t,n,r,o,c){return(await fetch(`/api/roles/${encodeURIComponent(t)}/${encodeURIComponent(n)}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({content:r,injectMode:o,dispatchCompletionEnabled:c})})).ok}async function tr(t,n,r){return(await fetch(`/api/roles/${encodeURIComponent(t)}/${encodeURIComponent(n)}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({injectMode:r})})).ok}async function rr(t,n,r){return(await fetch(`/api/roles/${encodeURIComponent(t)}/${encodeURIComponent(n)}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({dispatchCompletionEnabled:r})})).ok}async function nr(t,n){return(await fetch(`/api/roles/${encodeURIComponent(t)}/${encodeURIComponent(n)}`,{method:"DELETE"})).ok}async function We(t,n){let r=await fetch(`/api/message-listeners/${encodeURIComponent(t)}/${encodeURIComponent(n)}`);return(await x(r)).listener??{enabled:!1,prompt:"",messagePolicy:{scope:"top_level"}}}async function sr(t,n,r){return(await fetch(`/api/message-listeners/${encodeURIComponent(t)}/${encodeURIComponent(n)}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify(r)})).ok}async function or(t,n){return(await fetch(`/api/message-listeners/${encodeURIComponent(t)}/${encodeURIComponent(n)}`,{method:"DELETE"})).ok}function Se(t){return Number.isFinite(t)?Math.min(He,Math.max(1,Math.floor(t))):je}function ue(t){return String(t).padStart(2,"0")}function lr(t){if(!t)return"";let n=Number(t);if(!Number.isFinite(n)||n<=0)return"";let r=n<1e12?n*1e3:n,o=new Date(r);return Number.isFinite(o.getTime())?[o.getFullYear(),"-",ue(o.getMonth()+1),"-",ue(o.getDate())," ",ue(o.getHours()),":",ue(o.getMinutes()),":",ue(o.getSeconds())].join(""):""}async function ir(t,n,r,o){let c=await fetch(`/api/message-listeners/${encodeURIComponent(t)}/${encodeURIComponent(n)}/preview`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({listener:r,limit:Se(o)})}),m=await x(c);return{ok:c.ok&&m.ok!==!1,requestedLimit:m.requestedLimit??Se(o),matches:m.matches??[],error:m.error}}async function ar(t,n,r,o){let c=await fetch(`/api/message-listeners/${encodeURIComponent(t)}/${encodeURIComponent(n)}/run-preview`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({listener:r,limit:Se(o)})}),m=await x(c);return{ok:c.ok&&m.ok!==!1,requestedLimit:m.requestedLimit??Se(o),matches:m.matches??[],results:m.results,error:m.error}}async function dr(t,n,r){let o=await fetch(`/api/message-listeners/${encodeURIComponent(t)}/${encodeURIComponent(n)}/run-preview/${encodeURIComponent(r)}`),c=await x(o);return{ok:o.ok&&c.ok!==!1,runId:c.runId,results:c.results,error:c.error}}async function cr(t,n){let r=await fetch(`/api/groups/${encodeURIComponent(t)}/${encodeURIComponent(n)}/members-display`);return(await x(r)).members??[]}async function ur(t,n){let r=await fetch(`/api/role-profiles/${encodeURIComponent(t)}/${encodeURIComponent(n)}`);return x(r)}async function pr(t,n,r){return(await fetch(`/api/role-profiles/${encodeURIComponent(t)}/${encodeURIComponent(n)}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({content:r,allowEmpty:!0})})).ok}async function mr(t,n){return(await fetch(`/api/role-profiles/${encodeURIComponent(t)}/${encodeURIComponent(n)}`,{method:"DELETE"})).ok}async function fr(t,n){let r=await Promise.all(n.map(async f=>{try{let p=await fetch(`/api/role-profiles/${encodeURIComponent(f.profileId)}`),v=await x(p);return[f.profileId,Array.isArray(v.entries)?v.entries:[]]}catch{return[f.profileId,[]]}})),o=new Set,c=[];for(let f of t)for(let p of f.memberBots){if(!p.inChat||!p.hasRole)continue;let v=qe(p.larkAppId,f.chatId);o.has(v)||(o.add(v),c.push({larkAppId:p.larkAppId,chatId:f.chatId}))}let m=await Ot(c);return{entriesByProfile:new Map(r),effectiveRolesByBot:m}}async function gr(t){let n=await fetch(`/api/role-profiles/${encodeURIComponent(t.profileId)}/apply`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({chatId:t.chatId,larkAppId:t.larkAppId,force:t.force,preview:t.preview})}),r=await x(n);return{larkAppId:t.larkAppId,ok:n.ok&&r.ok!==!1,status:n.status,error:r.error,wouldRefuse:r.wouldRefuse}}var e=Ge(_t(),1),hr=["text","post","image","interactive"],K={enabled:!1,prompt:"",senderPolicy:{mode:"include_only",includeSenderTypes:["user"],excludeSelf:!0},messagePolicy:{includeMsgTypes:[...hr],scope:"top_level"}};function ze(t){let n=t?.senderPolicy?.mode==="include_only"?"include_only":"all_except_excluded";return{enabled:t?.enabled===!0,name:t?.name??"",replyCardTitle:t?.replyCardTitle??"",workingDir:t?.workingDir??"",prompt:t?.prompt??"",senderPolicy:{mode:n,includeSenderOpenIds:[...t?.senderPolicy?.includeSenderOpenIds??[]],excludeSenderOpenIds:[...t?.senderPolicy?.excludeSenderOpenIds??[]],...t?.senderPolicy?.excludeSenderKinds?{excludeSenderKinds:{...t.senderPolicy.excludeSenderKinds}}:{},includeSenderTypes:[...t?.senderPolicy?.includeSenderTypes??K.senderPolicy?.includeSenderTypes??[]],excludeSenderTypes:[...t?.senderPolicy?.excludeSenderTypes??[]],excludeSelf:t?.senderPolicy?.excludeSelf!==!1},messagePolicy:{includeMsgTypes:[...t?.messagePolicy?.includeMsgTypes??K.messagePolicy?.includeMsgTypes??[]],scope:"top_level"}}}function yr(t){return!!t&&t.prompt.trim().length>0}function Pn(t){return t.memberBots.some(n=>n.inChat&&(n.hasRole||n.hasMessageListener))}function Ye(t,n){return t?.name||n}function In(t,n){let r=new Map;for(let o of t??[])r.set(o.messageId,o);for(let o of n)r.set(o.messageId,{...r.get(o.messageId),...o});return[...r.values()]}function Sn(t,n){return!n||t==="failed"?"error":t==="replied"?"ok":t==="running"?"running":"triggered"}function wn(t,n=[]){return ze(t??K)}function xn(){let t=(0,a.useRef)(!0);return(0,a.useEffect)(()=>(t.current=!0,()=>{t.current=!1}),[]),t}function Rn(){let t=(0,a.useRef)(new Set);return(0,a.useEffect)(()=>()=>{for(let n of t.current)window.clearTimeout(n);t.current.clear()},[]),(0,a.useCallback)((n,r)=>{let o=window.setTimeout(()=>{t.current.delete(o),n()},r);return t.current.add(o),o},[])}function Pr(t){return(0,e.jsx)(Bt,{html:Et({name:t.bot.botName,larkAppId:t.bot.larkAppId,avatarUrl:t.bot.botAvatarUrl,size:"sm"})})}function Ir(t){let n=Dt(),r=xn(),o=Rn(),[c,m]=(0,a.useState)([]),[f,p]=(0,a.useState)([]),[v,T]=(0,a.useState)([]),[xe,R]=(0,a.useState)({entriesByProfile:new Map,effectiveRolesByBot:new Map}),[W,A]=(0,a.useState)(!1),[Re,Y]=(0,a.useState)(!0),[ke,_]=(0,a.useState)(!0),[F,k]=(0,a.useState)(""),[z,ge]=(0,a.useState)(""),[U,B]=(0,a.useState)(()=>new Set),[g,ye]=(0,a.useState)(null),[y,J]=(0,a.useState)(null),[d,b]=(0,a.useState)(null),[I,M]=(0,a.useState)(""),[X,Q]=(0,a.useState)("every"),[ve,Z]=(0,a.useState)(!1),[Je,Xe]=(0,a.useState)(!1),[Qe,Ze]=(0,a.useState)(!1),[Sr,et]=(0,a.useState)(!1),[wr,tt]=(0,a.useState)(!1),[xr,Ne]=(0,a.useState)(null),[Rr,rt]=(0,a.useState)(null),[kr,nt]=(0,a.useState)(null),[j,st]=(0,a.useState)("role"),[Nr,Lr]=(0,a.useState)(null),[P,D]=(0,a.useState)(()=>ze(K)),[Le,ot]=(0,a.useState)([]),[Tr,lt]=(0,a.useState)(!1),[Mr,it]=(0,a.useState)(!1),[at,dt]=(0,a.useState)(!1),[Te,ct]=(0,a.useState)(!1),[Cr,G]=(0,a.useState)(null),[Me,Er]=(0,a.useState)(je),[Ar,be]=(0,a.useState)({kind:"idle"}),ee=(0,a.useRef)(null),ut=(0,a.useRef)(0),[S,_r]=(0,a.useState)(null),[C,pt]=(0,a.useState)(null),[te,re]=(0,a.useState)([]),[ne,he]=(0,a.useState)(""),[$,se]=(0,a.useState)(null),[mt,Br]=(0,a.useState)(!1),[ft,gt]=(0,a.useState)(()=>new Set),[yt,vt]=(0,a.useState)(!1),[bt,ht]=(0,a.useState)(!1),[Dr,Ce]=(0,a.useState)(null),[Gr,oe]=(0,a.useState)({kind:"idle"}),H=(0,a.useRef)(0),le=(0,a.useRef)(0),Pt=(0,a.useRef)(null),Ee=g?c.find(s=>s.chatId===g):void 0,Fr=Ee&&y?Ee.memberBots.find(s=>s.larkAppId===y):void 0,Ae=C?f.find(s=>s.larkAppId===C):void 0,$r=me(te,C),_e=$?c.find(s=>s.chatId===$):void 0,Pe=_e?.memberBots.filter(s=>s.inChat)??[],Or=Pe.map(s=>s.larkAppId).join("\0"),Ur=te.map(s=>s.larkAppId).sort().join("\0"),jr=(0,a.useMemo)(()=>Jt(c,F),[c,F]),Hr=(0,a.useMemo)(()=>Xt(v,z),[v,z]),Be=we(I),De=we(ne),It=we(P.prompt),St=(0,a.useMemo)(()=>{let s=new Map;for(let l of Le)s.set(l.openId,l);return s},[Le]),N=(0,a.useCallback)((s,l,i=!1)=>{let u=Date.now()+Math.random();s({text:l,isError:i,id:u}),o(()=>{s(h=>h?.id===u?null:h)},i?3e3:2e3)},[o]),L=(0,a.useCallback)(async(s,l)=>{try{let i=await fr(s,l);if(!r.current)return;R(i),A(!0)}catch{if(!r.current)return;R({entriesByProfile:new Map,effectiveRolesByBot:new Map}),A(!0)}},[r]),E=(0,a.useCallback)(async()=>{let s=await Qt();return r.current&&(m(s.groups),p(s.bots)),s},[r]),ie=(0,a.useCallback)(async()=>{let s=await Zt();return r.current&&T(s),s},[r]),ae=(0,a.useCallback)((s,l=[])=>{let i=wn(s??K,l);Lr(s),D(i)},[]),wt=(0,a.useCallback)(async(s,l,i)=>{lt(!0),it(!0),ot([]);try{let[u,h]=await Promise.all([We(s,l).catch(()=>ze(K)),cr(s,l).catch(()=>[])]);if(!r.current||i!==H.current)return;ae(yr(u)?u:null,h),ot(h),G(null)}finally{r.current&&i===H.current&&(lt(!1),it(!1))}},[r,ae]),xt=(0,a.useCallback)(async()=>{Y(!0),_(!0),A(!1);try{let s=await E();if(!r.current)return;let l=await ie();if(!r.current||(await At(),!r.current))return;if(B(new Set(s.groups.filter(Pn).map(i=>i.chatId))),t.tab==="profiles"){let i=Wt();se(u=>u||(i&&s.groups.some(h=>h.chatId===i)?i:s.groups[0]?.chatId??null))}else se(i=>i??s.groups[0]?.chatId??null);Y(!1),_(!1),L(s.groups,l)}catch{if(!r.current)return;Y(!1),_(!1),A(!0)}},[r,t.tab,E,ie,L]);(0,a.useEffect)(()=>{xt()},[xt]),(0,a.useEffect)(()=>()=>{ut.current+=1,ee.current=null},[]),(0,a.useEffect)(()=>{$||c.length===0||se(c[0].chatId)},[c,$]),(0,a.useEffect)(()=>{let s=new Set(Pe.filter(l=>!!me(te,l.larkAppId)).map(l=>l.larkAppId));gt(s),oe({kind:"idle"})},[Ur,Or]);async function Vr(s,l){let i=++H.current;ye(s),J(l),Ne(null),rt(null),nt(null),G(null),ae(null);let u=await Ke(l,s);!r.current||i!==H.current||(b(u),M(u.content??""),Q(u.injectMode==="once"?"once":"every"),Z(u.dispatchCompletionEnabled===!0),await wt(l,s,i))}async function qr(){let s=await E();if(r.current&&(L(s.groups,v),g&&y)){let l=++H.current,i=await Ke(y,g);if(!r.current||l!==H.current)return;b(i),M(i.content??""),Q(i.injectMode==="once"?"once":"every"),Z(i.dispatchCompletionEnabled===!0),await wt(y,g,l)}}async function Kr(){if(!(!g||!y)){Xe(!0);try{let s=await er(y,g,I,X,ve);if(!r.current)return;if(s){let l=await E();if(!r.current)return;b(i=>i&&{...i,content:I,hasRole:!0,injectMode:X,dispatchCompletionEnabled:ve}),L(l.groups,v),N(Ne,n("roles.saved"))}else N(Ne,I.trim().length===0?n("roles.emptyError"):n("roles.saveFailed"),!0)}finally{r.current&&Xe(!1)}}}async function Wr(){if(!(!g||!y)&&confirm(n("roles.confirmDelete"))){Ze(!0);try{let s=await nr(y,g);if(!r.current)return;if(s){let l=await E();if(!r.current)return;ye(null),J(null),b(null),M(""),Q("every"),Z(!1),L(l.groups,v)}}finally{r.current&&Ze(!1)}}}async function Yr(s){if(!g||!y)return;let l=X;Q(s),et(!0);try{let i=await tr(y,g,s);if(!r.current)return;i||Q(l),N(rt,n(i?"roles.saved":"roles.saveFailed"),!i)}finally{r.current&&et(!1)}}async function zr(s){if(!g||!y)return;let l=ve;Z(s),tt(!0);try{let i=await rr(y,g,s);if(!r.current)return;i||Z(l),N(nt,n(i?"roles.saved":"roles.saveFailed"),!i)}finally{r.current&&tt(!1)}}function Jr(s){D(l=>({...l,...s}))}function Xr(s){D(l=>({...l,senderPolicy:{...l.senderPolicy??{},...s}}))}function Qr(s){D(l=>({...l,messagePolicy:{...l.messagePolicy??{scope:"top_level"},...s,scope:"top_level"}}))}function Zr(s,l){D(i=>{let u=new Set(i.senderPolicy?.includeSenderTypes??[]);if(l)u.add(s);else{if(u.size<=1&&u.has(s))return i;u.delete(s)}return{...i,senderPolicy:{...i.senderPolicy??{},includeSenderTypes:[...u]}}})}function en(s,l){D(i=>{let u=new Set(i.messagePolicy?.includeMsgTypes??[]);if(l)u.add(s);else{if(u.size<=1&&u.has(s))return i;u.delete(s)}return{...i,messagePolicy:{...i.messagePolicy??{scope:"top_level"},includeMsgTypes:[...u],scope:"top_level"}}})}function Rt(s,l){D(i=>{let u=i.senderPolicy?.mode==="all_except_excluded"?"all_except_excluded":"include_only",h=Ht({mode:u,include:i.senderPolicy?.includeSenderOpenIds??[],exclude:i.senderPolicy?.excludeSenderOpenIds??[],targetIds:s,listening:l});return{...i,senderPolicy:{...i.senderPolicy??{},mode:u,includeSenderOpenIds:h.include,excludeSenderOpenIds:h.exclude}}})}function tn(s,l){Rt([s],l)}function rn(s,l){Rt(s,l)}function nn(s){D(l=>({...l,senderPolicy:{...l.senderPolicy??{},mode:s,includeSenderOpenIds:[...l.senderPolicy?.includeSenderOpenIds??[]],excludeSenderOpenIds:[...l.senderPolicy?.excludeSenderOpenIds??[]]}}))}function kt(){let s=P.senderPolicy??{},l=P.messagePolicy??{},i=s.mode==="all_except_excluded"?"all_except_excluded":"include_only",u=[...new Set(s.includeSenderOpenIds??[])].filter(Boolean),h=[...new Set(s.excludeSenderOpenIds??[])].filter(Boolean),de=Vt(h,Ie=>St.get(Ie)?.memberType,s.excludeSenderKinds),w=[...new Set(s.includeSenderTypes??[])].filter(Ie=>Ie==="user"||Ie==="bot"),Ct=[...new Set(l.includeMsgTypes??[])].filter(Boolean);return{enabled:P.enabled,...P.name?.trim()?{name:P.name.trim()}:{},...P.replyCardTitle?.trim()?{replyCardTitle:P.replyCardTitle.trim()}:{},...P.workingDir?.trim()?{workingDir:P.workingDir.trim()}:{},prompt:P.prompt.trim(),senderPolicy:{mode:i,...i==="include_only"&&u.length>0?{includeSenderOpenIds:u}:{},...i==="all_except_excluded"&&h.length>0?{excludeSenderOpenIds:h}:{},...i==="all_except_excluded"&&Object.keys(de).length>0?{excludeSenderKinds:de}:{},...w.length>0?{includeSenderTypes:w}:{},excludeSelf:s.excludeSelf!==!1},messagePolicy:{...Ct.length>0?{includeMsgTypes:Ct}:{},scope:"top_level"}}}function sn(){return P.prompt.trim()?P.senderPolicy?.mode!=="all_except_excluded"&&(P.senderPolicy?.includeSenderOpenIds?.length??0)===0?(N(G,n("roles.listenerSenderRequired"),!0),null):{...kt(),enabled:!0}:(N(G,n("roles.listenerPromptRequired"),!0),null)}async function Nt(s){if(!g||!y)return;let l=sn();if(!l)return;let i=s?"run":"preview";be({kind:"loading",mode:i});try{let u=s?await ar(y,g,l,Me):await ir(y,g,l,Me);if(!r.current)return;be(u.ok?{kind:"result",response:u,mode:i}:{kind:"error",text:u.error||n("roles.listenerPreviewFailed")}),u.ok&&s&&u.runId&&on(u.runId)}catch(u){if(!r.current)return;be({kind:"error",text:u instanceof Error?u.message:n("roles.listenerPreviewFailed")})}}function on(s){if(!g||!y)return;let l=++ut.current;ee.current={runId:s,token:l};let i=async()=>{if(!r.current)return;let u=ee.current;if(!(!u||u.runId!==s||u.token!==l||!g||!y))try{let h=await dr(y,g,s);if(!r.current)return;if(h.ok&&h.results){let de=h.results;be(w=>w.kind!=="result"||w.mode!=="run"||w.response.runId!==s?w:{...w,response:{...w.response,results:In(w.response.results,de)}}),de.some(w=>w.state==="triggered"||w.state==="running")?o(i,1500):ee.current?.runId===s&&(ee.current=null)}}catch{o(i,2500)}};o(i,1500)}async function ln(){if(!(!g||!y)){if(!P.enabled&&!P.prompt.trim()){await Lt(!1);return}if(P.enabled){if(!P.prompt.trim()){N(G,n("roles.listenerPromptRequired"),!0);return}if(P.senderPolicy?.mode!=="all_except_excluded"&&(P.senderPolicy?.includeSenderOpenIds?.length??0)===0){N(G,n("roles.listenerSenderRequired"),!0);return}}dt(!0);try{let s=await sr(y,g,kt());if(!r.current)return;if(s){let l=await E();if(!r.current)return;let i=await We(y,g);if(!r.current)return;ae(yr(i)?i:null),L(l.groups,v)}N(G,n(s?"roles.saved":"roles.saveFailed"),!s)}finally{r.current&&dt(!1)}}}async function Lt(s=!0){if(!(!g||!y)&&!(s&&!confirm(n("roles.listenerConfirmDelete")))){ct(!0);try{let l=await or(y,g);if(!r.current)return;if(l){let i=await E();if(!r.current)return;ae(null),L(i.groups,v)}N(G,n(l?"roles.saved":"roles.saveFailed"),!l)}finally{r.current&&ct(!1)}}}async function Tt(s){let l=s.trim();if(!Ve(l))return;let i=++le.current;_r(l),pt(null),he(""),oe({kind:"idle"}),se(h=>h??c[0]?.chatId??null);let u=await q(l);!r.current||i!==le.current||(re(u),Ce(null))}async function an(s){if(!S)return;let l=++le.current;pt(s);let i=await ur(S,s);if(!r.current||l!==le.current)return;he(i.content??"");let u=await q(S);!r.current||l!==le.current||(re(u),Ce(null))}async function dn(){let s=await E();if(!r.current)return;let l=await ie();if(r.current){if(S){let i=await q(S);if(!r.current)return;re(i)}L(s.groups,l)}}async function cn(){let s=Pt.current,l=s?.value.trim()??"";if(l){if(!Ve(l)){s?.setCustomValidity(n("roles.profileIdInvalid")),s?.reportValidity();return}s?.setCustomValidity(""),await Tt(l),r.current&&(location.hash.startsWith("#/roles/profile")||(location.hash="#/roles/profile"))}}async function un(){if(!(!S||!C)){vt(!0);try{let s=await pr(S,C,ne);if(!r.current)return;let l=await ie();if(!r.current)return;let i=await q(S);if(!r.current)return;re(i),L(c,l),N(Ce,n(s?"roles.saved":"roles.saveFailed"),!s)}finally{r.current&&vt(!1)}}}async function pn(){if(!(!S||!C)&&confirm(n("roles.confirmDeleteProfileEntry"))){ht(!0);try{if(await mr(S,C),!r.current)return;he("");let s=await ie();if(!r.current)return;let l=await q(S);if(!r.current)return;re(l),L(c,s)}finally{r.current&&ht(!1)}}}function mn(s,l){gt(i=>{let u=new Set(i);return l?u.add(s):u.delete(s),u})}async function Mt(s){if(!S)return;let l=$??c[0]?.chatId;if(!l)return;let i=[...ft];if(i.length===0){oe({kind:"text",text:n("roles.applyPickBots")});return}oe({kind:"text",text:"..."});let u=await Promise.all(i.map(h=>gr({profileId:S,chatId:l,larkAppId:h,force:mt,preview:s})));if(r.current&&(oe({kind:"results",preview:s,results:u}),!s)){let h=await E();if(!r.current)return;L(h.groups,v)}}let fn=Je||Be>O||I.trim().length===0,gn=at||Te||It>pe||P.enabled&&P.prompt.trim().length===0,yn=yt||De>O||ne.trim().length===0,V=t.tab==="profiles",vn=(0,e.jsxs)("nav",{className:"roles-subnav insight-tabs",role:"tablist","aria-label":n("roles.title"),children:[(0,e.jsx)("a",{href:"#/roles",className:`itab${V?"":" on"}`,role:"tab","aria-selected":!V,children:n("roles.tabGroups")}),(0,e.jsx)("a",{href:"#/roles/profile",className:`itab${V?" on":""}`,role:"tab","aria-selected":V,children:n("roles.tabProfiles")})]});return(0,e.jsxs)("section",{className:"page roles-page",children:[(0,e.jsxs)("div",{className:"page-heading roles-heading",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"eyebrow",children:n("nav.roles")}),(0,e.jsx)("h1",{children:n("roles.title")})]}),(0,e.jsx)("div",{className:"page-heading-actions",children:vn})]}),(0,e.jsxs)("div",{id:"roles-by-group-view",className:"roles-layout",hidden:V,children:[(0,e.jsxs)("div",{className:"roles-tree-panel",children:[(0,e.jsxs)("div",{className:"roles-tree-header dashboard-toolbar",children:[(0,e.jsx)("input",{type:"search",id:"roles-search",placeholder:n("roles.search"),value:F,onChange:s=>k(s.target.value)}),(0,e.jsx)($e,{id:"roles-refresh",label:n("roles.refresh"),onClick:()=>{qr()}})]}),(0,e.jsx)("div",{id:"roles-tree",className:"roles-tree",children:Re?(0,e.jsx)(ce,{label:n("common.loading")}):(0,e.jsx)(Ln,{groups:jr,profiles:v,context:xe,contextLoaded:W,expandedGroups:U,selectedGroupId:g,selectedBotId:y,tr:n,onToggleGroup:s=>B(l=>kn(l,s)),onSelectBot:(s,l)=>{Vr(s,l)}})})]}),(0,e.jsx)("div",{className:"roles-editor-panel",children:!g||!y?(0,e.jsx)("div",{id:"roles-editor-empty",className:"roles-editor-empty",children:n("roles.selectHint")}):(0,e.jsxs)("div",{id:"roles-editor-form",className:"roles-editor-form",children:[(0,e.jsxs)("div",{className:"roles-editor-head",children:[(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"roles-editor-breadcrumb",children:[(0,e.jsx)("span",{id:"roles-editor-group-name",children:Ee?.name??g}),(0,e.jsx)("span",{className:"roles-breadcrumb-sep",children:"\u203A"}),(0,e.jsx)("span",{id:"roles-editor-bot-name",children:Fr?.botName??y})]}),(0,e.jsx)("div",{className:"roles-editor-meta",children:(0,e.jsxs)("span",{id:"roles-editor-chat-id",className:"roles-editor-meta-line",children:[g," \xB7 ",y]})})]}),(0,e.jsx)("div",{className:"roles-editor-actions roles-editor-head-actions",children:j==="role"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",id:"roles-delete",className:"danger",style:{display:d?.hasRole?"":"none"},disabled:Qe,onClick:()=>{Wr()},children:Qe?"...":n("roles.delete")}),(0,e.jsx)("button",{type:"button",id:"roles-save",className:"primary",disabled:fn,onClick:()=>{Kr()},children:Je?"...":n("roles.save")})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",id:"roles-listener-delete",className:"danger",style:{display:Nr?"":"none"},disabled:Te,onClick:()=>{Lt()},children:Te?"...":n("roles.delete")}),(0,e.jsx)("button",{type:"button",id:"roles-listener-save",className:"primary",disabled:gn,onClick:()=>{ln()},children:at?"...":n("roles.save")})]})})]}),(0,e.jsxs)("div",{className:"roles-editor-switch segmented",role:"tablist","aria-label":n("roles.editorTabs"),children:[(0,e.jsx)("button",{type:"button",className:j==="role"?"active":"","aria-pressed":j==="role",onClick:()=>st("role"),children:n("roles.roleTab")}),(0,e.jsx)("button",{type:"button",className:j==="listener"?"active":"","aria-pressed":j==="listener",onClick:()=>st("listener"),children:n("roles.listenerTab")})]}),j==="role"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"roles-editor-inject",children:[(0,e.jsx)("span",{className:"roles-field-label",children:n("roles.injectModeLabel")}),(0,e.jsx)(Oe,{id:"roles-editor-inject-mode",className:"roles-inline-menu",ariaLabel:n("roles.injectModeLabel"),disabled:Sr,label:n(X==="once"?"roles.injectModeOnce":"roles.injectModeEvery"),value:X,options:[{value:"every",label:n("roles.injectModeEvery")},{value:"once",label:n("roles.injectModeOnce")}],onChange:s=>{Yr(s==="once"?"once":"every")}}),(0,e.jsx)("span",{className:"roles-editor-inject-hint",children:n("roles.injectModeHint")}),(0,e.jsx)(fe,{flash:Rr})]}),(0,e.jsxs)("div",{className:"roles-editor-inject",children:[(0,e.jsx)("span",{className:"roles-field-label",children:n("roles.dispatchCompletionLabel")}),(0,e.jsxs)("label",{className:"filter-toggle roles-listener-enabled",children:[(0,e.jsx)("input",{id:"roles-editor-dispatch-completion-enabled",type:"checkbox",checked:ve,disabled:wr,onChange:s=>{zr(s.currentTarget.checked)}}),(0,e.jsx)("span",{className:"filter-toggle-switch","aria-hidden":"true"}),(0,e.jsx)("span",{className:"filter-toggle-label",children:n("roles.dispatchCompletionEnabled")})]}),(0,e.jsx)("span",{className:"roles-editor-inject-hint",children:n("roles.dispatchCompletionHint")}),(0,e.jsx)(fe,{flash:kr})]}),(0,e.jsx)("textarea",{id:"roles-editor-textarea",placeholder:n("roles.editorPlaceholder"),rows:14,value:I,onChange:s=>M(s.target.value)}),(0,e.jsxs)("div",{className:"roles-editor-footer",children:[(0,e.jsxs)("span",{id:"roles-editor-bytecount",className:vr(Be),children:[Be," / ",O," bytes"]}),(0,e.jsx)(fe,{flash:xr})]}),(0,e.jsx)(br,{content:I,tr:n,id:"roles-preview"})]}):(0,e.jsx)(Mn,{listener:P,members:Le,memberById:St,promptByteLen:It,loading:Tr,membersLoading:Mr,flash:Cr,tr:n,onPatch:Jr,onSenderPolicyPatch:Xr,onMessagePolicyPatch:Qr,onToggleSenderType:Zr,onToggleMsgType:en,onSetTargetPolicy:tn,onSetTargetsPolicy:rn,onSetSenderMode:nn,previewLimit:Me,previewStatus:Ar,onPreviewLimitChange:Er,onPreview:()=>{Nt(!1)},onRunPreview:()=>{Nt(!0)}})]})})]}),(0,e.jsxs)("div",{id:"roles-profiles-view",className:"roles-layout roles-profiles-layout",hidden:!V,children:[(0,e.jsxs)("div",{className:"roles-tree-panel",children:[(0,e.jsxs)("div",{className:"roles-tree-header roles-profile-create dashboard-toolbar",children:[(0,e.jsx)("input",{type:"text",id:"roles-profile-id",placeholder:n("roles.profileIdPlaceholder"),maxLength:64,ref:Pt,onChange:s=>s.currentTarget.setCustomValidity("")}),(0,e.jsx)("button",{type:"button",id:"roles-profile-select",onClick:()=>{cn()},children:n("roles.openProfile")})]}),(0,e.jsxs)("div",{className:"roles-tree-header dashboard-toolbar",children:[(0,e.jsx)("input",{type:"search",id:"roles-profile-search",placeholder:n("roles.profileSearch"),value:z,onChange:s=>ge(s.target.value)}),(0,e.jsx)($e,{id:"roles-profile-refresh",label:n("roles.refresh"),onClick:()=>{dn()}})]}),(0,e.jsx)("div",{id:"roles-profile-list",className:"roles-tree",children:ke?(0,e.jsx)(ce,{label:n("common.loading")}):(0,e.jsx)(An,{profiles:Hr,selectedProfileId:S,tr:n,onSelect:s=>{Tt(s)}})})]}),(0,e.jsx)("div",{className:"roles-editor-panel",children:S?(0,e.jsxs)("div",{id:"roles-profile-detail",className:"roles-editor-form roles-profile-detail",children:[(0,e.jsx)("div",{className:"roles-profile-title",children:(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"roles-editor-breadcrumb",children:[(0,e.jsx)("span",{children:S}),Ae?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"roles-breadcrumb-sep",children:"\u203A"}),(0,e.jsx)("span",{children:Ae.botName??Ae.larkAppId})]}):null]}),(0,e.jsx)("div",{className:"roles-editor-meta-line",children:n("roles.profileRuntimeHint")})]})}),(0,e.jsxs)("div",{className:"roles-profile-grid",children:[(0,e.jsxs)("div",{className:"roles-profile-bots",children:[(0,e.jsx)("div",{className:"roles-profile-section-title",children:n("roles.profileBots")}),(0,e.jsx)("div",{className:"roles-profile-bot-list",children:f.map(s=>{let l=!!me(te,s.larkAppId),i=C===s.larkAppId;return(0,e.jsxs)("div",{className:`roles-bot-row roles-profile-bot-row ${i?"selected":""}`,"data-profile-bot-id":s.larkAppId,onClick:()=>{an(s.larkAppId)},children:[(0,e.jsx)(Pr,{bot:s}),(0,e.jsxs)("div",{className:"roles-bot-info",children:[(0,e.jsx)("div",{className:"roles-bot-name",children:s.botName??s.larkAppId}),(0,e.jsx)("div",{className:"roles-bot-id",children:s.larkAppId})]}),(0,e.jsx)("span",{className:`roles-badge ${l?"has-role":"no-role"}`,children:n(l?"roles.configured":"roles.unconfigured")})]},s.larkAppId)})})]}),(0,e.jsx)("div",{className:"roles-profile-editor",children:C?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"roles-profile-editor-head",children:[(0,e.jsxs)("span",{id:"roles-profile-bytecount",className:vr(De),children:[De," / ",O," bytes"]}),(0,e.jsxs)("div",{className:"roles-editor-actions roles-editor-head-actions",children:[(0,e.jsx)("button",{type:"button",id:"roles-profile-delete",className:"danger",style:{display:$r?"":"none"},disabled:bt,onClick:()=>{pn()},children:bt?"...":n("roles.delete")}),(0,e.jsx)("button",{type:"button",id:"roles-profile-save",className:"primary",disabled:yn,onClick:()=>{un()},children:yt?"...":n("roles.saveEntry")})]})]}),(0,e.jsx)("textarea",{id:"roles-profile-textarea",placeholder:n("roles.profileEditorPlaceholder"),rows:12,value:ne,onChange:s=>he(s.target.value)}),(0,e.jsx)("div",{className:"roles-editor-footer",children:(0,e.jsx)(fe,{flash:Dr})}),(0,e.jsx)(br,{content:ne,tr:n,id:"roles-profile-preview"})]}):(0,e.jsx)("div",{className:"roles-editor-empty roles-profile-inline-empty",children:n("roles.profileBotSelectHint")})})]}),(0,e.jsxs)("div",{className:"roles-profile-apply",children:[(0,e.jsx)("div",{className:"roles-profile-section-title",children:n("roles.applyToGroup")}),(0,e.jsxs)("div",{className:"roles-profile-apply-controls",children:[(0,e.jsx)(Oe,{id:"roles-profile-apply-group",className:"roles-apply-group-menu",ariaLabel:n("roles.applyToGroup"),disabled:c.length===0,label:_e?.name??$??n("roles.noChats"),value:$??"",options:c.map(s=>({value:s.chatId,label:s.name??s.chatId})),onChange:s=>se(s)}),(0,e.jsxs)("label",{className:"roles-profile-force",children:[(0,e.jsx)("input",{type:"checkbox",id:"roles-profile-apply-force",checked:mt,onChange:s=>Br(s.target.checked)})," ",n("roles.applyForce")]})]}),(0,e.jsx)("div",{id:"roles-profile-apply-bots",children:!_e||Pe.length===0?(0,e.jsx)("div",{className:"roles-empty",children:n("roles.noChats")}):Pe.map(s=>{let l=!!me(te,s.larkAppId);return(0,e.jsxs)("label",{className:"checkbox-row roles-profile-apply-bot",children:[(0,e.jsx)("input",{type:"checkbox",name:"profile-apply-bot",value:s.larkAppId,checked:ft.has(s.larkAppId),onChange:i=>mn(s.larkAppId,i.target.checked)}),(0,e.jsx)("span",{children:s.botName??s.larkAppId}),(0,e.jsx)("small",{children:n(l?"roles.configured":"roles.profileMissing")})]},s.larkAppId)})}),(0,e.jsxs)("div",{className:"roles-editor-actions",children:[(0,e.jsx)("button",{type:"button",id:"roles-profile-preview-apply",onClick:()=>{Mt(!0)},children:n("roles.previewApply")}),(0,e.jsx)("button",{type:"button",id:"roles-profile-apply",className:"primary",onClick:()=>{Mt(!1)},children:n("roles.applyProfile")})]}),(0,e.jsx)("div",{id:"roles-profile-apply-status",className:"roles-profile-status",children:(0,e.jsx)(_n,{status:Gr,bots:f,tr:n})})]})]}):(0,e.jsx)("div",{id:"roles-profile-empty",className:"roles-editor-empty",children:n("roles.profileSelectHint")})})]})]})}function kn(t,n){let r=new Set(t);return r.has(n)?r.delete(n):r.add(n),r}function vr(t){return`roles-bytecount ${t>qt?"warn":""} ${t>O?"over":""}`}function Nn(t){return`roles-bytecount ${t>Kt?"warn":""} ${t>pe?"over":""}`}function fe(t){return t.flash?(0,e.jsxs)("span",{className:`roles-saved-flash ${t.flash.isError?"roles-save-error":""}`,children:[" ",t.flash.text]}):null}function Ln(t){let{tr:n}=t;return t.groups.length===0?(0,e.jsx)("div",{className:"roles-empty",children:n("roles.noChats")}):(0,e.jsx)(e.Fragment,{children:t.groups.map(r=>{let o=t.expandedGroups.has(r.chatId),c=r.memberBots.filter(p=>p.inChat),m=Yt(r),f=zt(r);return(0,e.jsxs)("div",{className:"roles-group-section",children:[(0,e.jsxs)("div",{className:`roles-group-row ${o?"expanded":""} ${t.selectedGroupId===r.chatId&&!t.selectedBotId?"selected":""}`,"data-group-id":r.chatId,onClick:()=>t.onToggleGroup(r.chatId),children:[(0,e.jsx)("span",{className:"roles-group-arrow",children:o?"\u25BE":"\u25B8"}),(0,e.jsx)("span",{className:"roles-group-icon","aria-hidden":"true",children:(0,e.jsxs)("svg",{viewBox:"0 0 16 16",children:[(0,e.jsx)("circle",{cx:"5.6",cy:"5.8",r:"2.4"}),(0,e.jsx)("path",{d:"M1.8 13.2c.5-2.4 2-3.6 3.8-3.6s3.3 1.2 3.8 3.6"}),(0,e.jsx)("circle",{cx:"11",cy:"6.8",r:"1.9"}),(0,e.jsx)("path",{d:"M9.8 12.6c.4-1.7 1.5-2.6 2.8-2.6 1 0 1.9.5 2.4 1.6"})]})}),(0,e.jsxs)("div",{className:"roles-group-info",children:[(0,e.jsx)("div",{className:"roles-group-name",children:r.name??r.chatId}),(0,e.jsxs)("div",{className:"roles-group-meta",children:[m,"/",f," ",n("roles.botsWithRoles")]}),(0,e.jsx)(Tn,{group:r,profiles:t.profiles,context:t.context,loaded:t.contextLoaded,tr:n})]}),(0,e.jsx)("span",{className:"roles-group-chevron"})]}),(0,e.jsx)("div",{className:"roles-bot-list",children:o?c.map(p=>{let v=t.selectedGroupId===r.chatId&&t.selectedBotId===p.larkAppId;return(0,e.jsxs)("div",{className:`roles-bot-row ${v?"selected":""}`,"data-group-id":r.chatId,"data-bot-id":p.larkAppId,onClick:T=>{T.stopPropagation(),t.onSelectBot(r.chatId,p.larkAppId)},children:[(0,e.jsx)("span",{className:"roles-bot-indent"}),(0,e.jsx)(Pr,{bot:p}),(0,e.jsxs)("div",{className:"roles-bot-info",children:[(0,e.jsx)("div",{className:"roles-bot-name",children:p.botName}),(0,e.jsx)("div",{className:"roles-bot-id",children:p.larkAppId})]}),(0,e.jsxs)("div",{className:"roles-bot-badges",children:[(0,e.jsx)("span",{className:`roles-badge ${p.hasRole?"has-role":"no-role"}`,children:p.hasRole?n("roles.configured"):n("roles.unconfigured")}),p.hasMessageListener?(0,e.jsx)("span",{className:"roles-badge has-listener",children:n("roles.listenerBadge")}):null]})]},p.larkAppId)}):null})]},r.chatId)})})}function Tn(t){let{group:n,profiles:r,context:o,loaded:c,tr:m}=t;if(!r.length||!c)return null;let f=new Map;for(let T of n.memberBots)T.inChat&&f.set(T.larkAppId,o.effectiveRolesByBot.get(qe(T.larkAppId,n.chatId))??null);if(!Gt(f))return null;let p=Ft(n.memberBots,r,o.entriesByProfile,f)[0];if(!p)return(0,e.jsx)("div",{className:"roles-profile-match muted",children:m("groups.profileStatusUnmatched")});let v=p.kind==="full"?"groups.profileStatusFullChat":"groups.profileStatusPartial";return(0,e.jsx)("div",{className:`roles-profile-match ${p.kind}`,children:m(v,{name:p.profileId,matched:p.matched,total:p.total,chat:p.chatMatched})})}function Mn(t){let{listener:n,tr:r}=t,[o,c]=(0,a.useState)("members"),[m,f]=(0,a.useState)(""),[p,v]=(0,a.useState)(()=>new Set),T=new Set(n.senderPolicy?.includeSenderTypes??[]),xe=new Set(n.messagePolicy?.includeMsgTypes??[]),R=n.senderPolicy?.mode==="all_except_excluded"?"all_except_excluded":"include_only",W=new Set(n.senderPolicy?.includeSenderOpenIds??[]),A=new Set(n.senderPolicy?.excludeSenderOpenIds??[]),Re=[...[...R==="all_except_excluded"?A:W].filter(d=>!t.memberById.has(d))],Y=[...t.members.filter(d=>d.memberType!=="bot"),...Re.map(d=>({openId:d,name:d,memberType:"unknown"}))],ke=t.members.filter(d=>d.memberType==="bot"),_=o==="bots"?ke:Y,F=jt(_,m),k=F.map(d=>d.openId),z=k.filter(d=>p.has(d)),ge=k.length>0&&z.length===k.length,U=[...p].filter(d=>_.some(b=>b.openId===d)),B=U.length>0?U:k,g=Ue({mode:R,include:[...W],exclude:[...A],targetIds:B});(0,a.useEffect)(()=>{f(""),v(new Set)},[o]),(0,a.useEffect)(()=>{let d=new Set(_.map(b=>b.openId));v(b=>{let I=new Set([...b].filter(M=>d.has(M)));return I.size===b.size?b:I})},[_]);let ye=(d,b)=>{v(I=>{let M=new Set(I);return b?M.add(d):M.delete(d),M})},y=()=>{v(d=>{let b=new Set(d);if(ge)for(let I of k)b.delete(I);else for(let I of k)b.add(I);return b})},J=d=>{B.length!==0&&t.onSetTargetsPolicy(B,d)};return(0,e.jsxs)("div",{className:"roles-listener-editor",children:[t.loading?(0,e.jsx)(ce,{label:r("common.loading")}):null,(0,e.jsxs)("label",{className:"filter-toggle roles-listener-enabled",children:[(0,e.jsx)("input",{type:"checkbox",checked:n.enabled,onChange:d=>t.onPatch({enabled:d.currentTarget.checked})}),(0,e.jsx)("span",{className:"filter-toggle-switch","aria-hidden":"true"}),(0,e.jsx)("span",{className:"filter-toggle-label",children:r("roles.listenerEnabled")})]}),(0,e.jsx)("p",{className:"roles-listener-scope-help",children:r("roles.listenerScopeHelp")}),(0,e.jsxs)("div",{className:"roles-listener-grid",children:[(0,e.jsxs)("label",{className:"roles-listener-field",children:[(0,e.jsx)("span",{className:"roles-field-label",children:r("roles.listenerName")}),(0,e.jsx)("input",{type:"text",value:n.name??"",placeholder:r("roles.listenerNamePlaceholder"),onChange:d=>t.onPatch({name:d.currentTarget.value})})]}),(0,e.jsxs)("label",{className:"roles-listener-field",children:[(0,e.jsx)("span",{className:"roles-field-label",children:r("roles.listenerReplyCardTitle")}),(0,e.jsx)("input",{type:"text",value:n.replyCardTitle??"",placeholder:r("roles.listenerReplyCardTitlePlaceholder"),onChange:d=>t.onPatch({replyCardTitle:d.currentTarget.value})})]}),(0,e.jsxs)("label",{className:"roles-listener-field",children:[(0,e.jsx)("span",{className:"roles-field-label",children:r("roles.listenerWorkingDir")}),(0,e.jsx)("input",{type:"text",value:n.workingDir??"",placeholder:r("roles.listenerWorkingDirPlaceholder"),onChange:d=>t.onPatch({workingDir:d.currentTarget.value})})]})]}),(0,e.jsxs)("div",{className:"roles-listener-policy-row",children:[(0,e.jsxs)("div",{className:"roles-listener-policy",children:[(0,e.jsx)("div",{className:"roles-field-label",children:r("roles.listenerSenderTypes")}),(0,e.jsxs)("label",{className:"roles-listener-chip",children:[(0,e.jsx)("input",{type:"checkbox",checked:T.has("user"),onChange:d=>t.onToggleSenderType("user",d.currentTarget.checked)}),(0,e.jsx)("span",{children:r("roles.listenerSenderUser")})]}),(0,e.jsxs)("label",{className:"roles-listener-chip",children:[(0,e.jsx)("input",{type:"checkbox",checked:T.has("bot"),onChange:d=>t.onToggleSenderType("bot",d.currentTarget.checked)}),(0,e.jsx)("span",{children:r("roles.listenerSenderBot")})]})]}),(0,e.jsxs)("div",{className:"roles-listener-policy",children:[(0,e.jsx)("div",{className:"roles-field-label",children:r("roles.listenerMessageTypes")}),hr.map(d=>(0,e.jsxs)("label",{className:"roles-listener-chip",children:[(0,e.jsx)("input",{type:"checkbox",checked:xe.has(d),onChange:b=>t.onToggleMsgType(d,b.currentTarget.checked)}),(0,e.jsx)("span",{children:d})]},d))]}),(0,e.jsxs)("label",{className:"roles-listener-checkbox",children:[(0,e.jsx)("input",{type:"checkbox",checked:n.senderPolicy?.excludeSelf!==!1,onChange:d=>t.onSenderPolicyPatch({excludeSelf:d.currentTarget.checked})}),(0,e.jsx)("span",{children:r("roles.listenerExcludeSelf")})]})]}),(0,e.jsx)("div",{className:"roles-listener-policy-row",children:(0,e.jsxs)("div",{className:"roles-listener-policy",children:[(0,e.jsx)("div",{className:"roles-field-label",children:r("roles.listenerSenderMode")}),(0,e.jsxs)("div",{className:"roles-listener-target-tabs segmented",role:"tablist","aria-label":r("roles.listenerSenderMode"),children:[(0,e.jsx)("button",{type:"button",className:R==="include_only"?"active":"","aria-pressed":R==="include_only",onClick:()=>t.onSetSenderMode("include_only"),children:r("roles.listenerSenderModeInclude")}),(0,e.jsx)("button",{type:"button",className:R==="all_except_excluded"?"active":"","aria-pressed":R==="all_except_excluded",onClick:()=>t.onSetSenderMode("all_except_excluded"),children:r("roles.listenerSenderModeAllExcept")})]}),(0,e.jsx)("small",{className:"roles-listener-scope-help",children:r(R==="all_except_excluded"?"roles.listenerSenderModeAllExceptHelp":"roles.listenerSenderModeIncludeHelp")})]})}),(0,e.jsxs)("label",{className:"roles-listener-field",children:[(0,e.jsx)("span",{className:"roles-field-label",children:r("roles.listenerPrompt")}),(0,e.jsx)("textarea",{id:"roles-listener-prompt",placeholder:r("roles.listenerPromptPlaceholder"),rows:9,value:n.prompt,onChange:d=>t.onPatch({prompt:d.currentTarget.value})})]}),(0,e.jsxs)("div",{className:"roles-editor-footer",children:[(0,e.jsxs)("span",{id:"roles-listener-bytecount",className:Nn(t.promptByteLen),children:[t.promptByteLen," / ",pe," bytes"]}),(0,e.jsx)(fe,{flash:t.flash})]}),(0,e.jsxs)("div",{className:"roles-listener-preview-panel",children:[(0,e.jsxs)("div",{className:"roles-listener-preview-head",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"roles-profile-section-title",children:r("roles.listenerPreviewTitle")}),(0,e.jsx)("small",{children:r("roles.listenerPreviewHint")})]}),(0,e.jsxs)("div",{className:"roles-listener-preview-actions",children:[(0,e.jsxs)("label",{children:[(0,e.jsx)("span",{children:r("roles.listenerPreviewCount")}),(0,e.jsx)("select",{value:t.previewLimit,onChange:d=>t.onPreviewLimitChange(Number(d.currentTarget.value)),children:Array.from({length:He},(d,b)=>b+1).map(d=>(0,e.jsx)("option",{value:d,children:d},d))})]}),(0,e.jsx)("button",{type:"button",onClick:t.onPreview,disabled:t.previewStatus.kind==="loading",children:t.previewStatus.kind==="loading"&&t.previewStatus.mode==="preview"?"...":r("roles.listenerPreviewButton")}),(0,e.jsx)("button",{type:"button",className:"primary",onClick:t.onRunPreview,disabled:t.previewStatus.kind==="loading",children:t.previewStatus.kind==="loading"&&t.previewStatus.mode==="run"?"...":r("roles.listenerRunPreviewButton")})]})]}),(0,e.jsx)(Cn,{status:t.previewStatus,tr:r})]}),(0,e.jsxs)("div",{className:"roles-listener-members",children:[(0,e.jsxs)("div",{className:"roles-listener-members-head",children:[(0,e.jsx)("div",{className:"roles-profile-section-title",children:r("roles.listenerFilters")}),(0,e.jsx)("small",{children:t.membersLoading?r("common.loading"):r("roles.listenerMembersHint")})]}),(0,e.jsxs)("div",{className:"roles-listener-target-tabs segmented",role:"tablist","aria-label":r("roles.listenerFilters"),children:[(0,e.jsx)("button",{type:"button",className:o==="members"?"active":"","aria-pressed":o==="members",onClick:()=>c("members"),children:r("roles.listenerMembers")}),(0,e.jsx)("button",{type:"button",className:o==="bots"?"active":"","aria-pressed":o==="bots",onClick:()=>c("bots"),children:r("roles.listenerBots")})]}),(0,e.jsxs)("div",{className:"roles-listener-filter-toolbar",children:[(0,e.jsx)("input",{type:"search",value:m,placeholder:r("roles.listenerSearchPlaceholder"),onChange:d=>f(d.currentTarget.value)}),m?(0,e.jsx)("button",{type:"button",className:"roles-listener-clear-search",onClick:()=>f(""),"aria-label":r("roles.listenerClearSearch"),children:"\xD7"}):null,(0,e.jsx)("button",{type:"button",className:"roles-listener-select-all",disabled:k.length===0,onClick:y,children:r(ge?"roles.listenerClearVisible":"roles.listenerSelectVisible",{count:k.length})})]}),(0,e.jsxs)("div",{className:"roles-listener-bulkbar",children:[(0,e.jsxs)("span",{children:[U.length>0?r("roles.listenerSelectedCount",{count:U.length}):r("roles.listenerFilteredCount",{count:k.length}),g==="mixed"?` \xB7 ${r("roles.listenerMixedMode")}`:""]}),(0,e.jsxs)("div",{className:"roles-listener-member-actions",role:"group","aria-label":r("roles.listenerBulkActions"),children:[(0,e.jsx)("button",{type:"button",className:g==="listen"?"active":"","aria-pressed":g==="listen",disabled:B.length===0,onClick:()=>J(!0),children:r("roles.listenerTargetListen")}),(0,e.jsx)("button",{type:"button",className:g==="ignore"?"active":"","aria-pressed":g==="ignore",disabled:B.length===0,onClick:()=>J(!1),children:r("roles.listenerTargetIgnore")})]})]}),(0,e.jsx)("div",{className:"roles-listener-member-list",children:F.length===0?(0,e.jsx)("div",{className:"roles-empty",children:r(o==="bots"?"roles.listenerBotsEmpty":"roles.listenerMembersEmpty")}):F.map(d=>{let b=Ue({mode:R,include:[...W],exclude:[...A],targetIds:[d.openId]});return(0,e.jsxs)("div",{className:"roles-listener-member",children:[(0,e.jsx)("label",{className:"roles-listener-member-select","aria-label":Ye(d,d.openId),children:(0,e.jsx)("input",{type:"checkbox",checked:p.has(d.openId),onChange:I=>ye(d.openId,I.currentTarget.checked)})}),(0,e.jsxs)("div",{className:"roles-listener-member-main",children:[(0,e.jsx)("strong",{children:Ye(d,d.openId)}),(0,e.jsx)("span",{children:d.openId})]}),(0,e.jsxs)("div",{className:"roles-listener-member-actions",role:"group","aria-label":Ye(d,d.openId),children:[(0,e.jsx)("button",{type:"button",className:b==="listen"?"active":"","aria-pressed":b==="listen",onClick:()=>t.onSetTargetPolicy(d.openId,!0),children:r("roles.listenerTargetListen")}),(0,e.jsx)("button",{type:"button",className:b==="ignore"?"active":"","aria-pressed":b==="ignore",onClick:()=>t.onSetTargetPolicy(d.openId,!1),children:r("roles.listenerTargetIgnore")})]})]},d.openId)})})]})]})}function br(t){return(0,e.jsx)("div",{id:t.id,className:"roles-preview",children:t.content.trim()?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("strong",{children:t.tr("roles.preview")}),(0,e.jsx)("pre",{children:t.content})]}):(0,e.jsx)("small",{children:t.tr("roles.previewEmpty")})})}function Cn(t){let{status:n,tr:r}=t;if(n.kind==="idle")return(0,e.jsx)("div",{className:"roles-listener-preview-empty",children:r("roles.listenerPreviewEmpty")});if(n.kind==="loading")return(0,e.jsx)(ce,{label:r("common.loading")});if(n.kind==="error")return(0,e.jsx)("div",{className:"roles-listener-preview-error",children:n.text});let o=n.response.matches??[],m=(n.response.results??[]).reduce((f,p)=>{let v=p.ok?p.state??"triggered":"failed";return f[v]=(f[v]??0)+1,f},{});return(0,e.jsxs)("div",{className:"roles-listener-preview-results",children:[(0,e.jsx)("div",{className:"roles-listener-preview-summary",children:n.mode==="run"?r("roles.listenerRunPreviewSummary",{count:o.length,triggered:m.triggered??0,running:m.running??0,replied:m.replied??0,failed:m.failed??0}):r("roles.listenerPreviewSummary",{count:o.length})}),o.length===0?(0,e.jsx)("div",{className:"roles-listener-preview-empty",children:r("roles.listenerPreviewNoMatches")}):(0,e.jsx)("div",{className:"roles-listener-preview-list",children:o.map(f=>(0,e.jsx)(En,{item:f,result:n.response.results?.find(p=>p.messageId===f.messageId),tr:r},f.messageId))})]})}function En(t){let n=t.item.messageText.length>300?`${t.item.messageText.slice(0,300)}...`:t.item.messageText,r=t.item.senderName||t.item.senderOpenId||t.item.senderType,o=lr(t.item.createTime);return(0,e.jsxs)("div",{className:"roles-listener-preview-item",children:[(0,e.jsxs)("div",{className:"roles-listener-preview-meta",children:[(0,e.jsx)("span",{children:t.item.msgType}),(0,e.jsx)("span",{children:t.item.senderType}),t.item.senderOpenId?(0,e.jsx)("span",{children:t.item.senderOpenId}):null,(0,e.jsx)("span",{children:t.item.messageId}),t.result?(0,e.jsx)("span",{className:Sn(t.result.state,t.result.ok),children:t.tr(`roles.listenerRunPreviewState.${t.result.ok?t.result.state??"triggered":"failed"}`)}):null]}),t.result?.sessionId||t.result?.replyMessageId||t.result?.error?(0,e.jsxs)("div",{className:"roles-listener-preview-run-detail",children:[t.result.sessionId?(0,e.jsx)("span",{children:t.result.sessionId}):null,t.result.replyMessageId?(0,e.jsx)("span",{children:t.result.replyMessageId}):null,t.result.error?(0,e.jsx)("strong",{children:t.result.error}):null]}):null,(0,e.jsxs)("div",{className:"roles-listener-preview-sender",children:[(0,e.jsx)("span",{children:t.tr("roles.listenerPreviewSender")}),(0,e.jsx)("strong",{children:r})]}),o?(0,e.jsxs)("div",{className:"roles-listener-preview-time",children:[(0,e.jsx)("span",{children:t.tr("roles.listenerPreviewTime")}),(0,e.jsx)("strong",{children:o})]}):null,t.item.messageTitle?(0,e.jsxs)("div",{className:"roles-listener-preview-title",children:[(0,e.jsx)("span",{children:t.tr("roles.listenerPreviewMessageTitle")}),(0,e.jsx)("strong",{children:t.item.messageTitle})]}):null,(0,e.jsx)("div",{className:"roles-listener-preview-content-label",children:t.tr("roles.listenerPreviewContent")}),(0,e.jsx)("pre",{children:n})]})}function An(t){let{tr:n}=t;return t.profiles.length===0?(0,e.jsx)("div",{className:"roles-empty",children:n("roles.profileEmpty")}):(0,e.jsx)(e.Fragment,{children:t.profiles.map(r=>{let o=t.selectedProfileId===r.profileId,c=(r.botEntries??[]).some(m=>m.hasEntry);return(0,e.jsxs)("div",{className:`roles-profile-row ${o?"selected":""}`,"data-profile-id":r.profileId,onClick:()=>t.onSelect(r.profileId),children:[(0,e.jsxs)("div",{className:"roles-profile-row-main",children:[(0,e.jsx)("div",{className:"roles-profile-name",children:r.profileId}),(0,e.jsxs)("div",{className:"roles-group-meta",children:[r.entryCount," ",n("roles.profileEntries")]})]}),(0,e.jsx)("span",{className:`roles-badge ${c?"has-role":"no-role"}`,children:n(c?"roles.configured":"roles.profileMissing")})]},r.profileId)})})}function _n(t){let{status:n,bots:r,tr:o}=t;return n.kind==="idle"?null:n.kind==="text"?(0,e.jsx)(e.Fragment,{children:n.text}):(0,e.jsx)(e.Fragment,{children:n.results.map(c=>{let f=r.find(v=>v.larkAppId===c.larkAppId)?.botName??c.larkAppId,p=c.ok?n.preview?c.wouldRefuse?o("roles.applyWouldRefuse"):o("roles.applyPreviewOk"):o("roles.applyOk"):`${o("roles.applyFailed")}: ${String(c.error??`HTTP ${c.status}`)}`;return(0,e.jsxs)("div",{children:[f,": ",p]},c.larkAppId)})})}function qn(t){return Fe(t,(0,e.jsx)(Ir,{tab:"groups"}))}function Kn(t){return Fe(t,(0,e.jsx)(Ir,{tab:"profiles"}))}export{Kn as renderRoleProfilesPage,qn as renderRolesPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as G,c as F}from"./chunk-KEEYQ3WF.js";import{g as _,m as B,n as K,o as U,p as j,q as J}from"./chunk-5CJMHTT4.js";import{D as H,G as M}from"./chunk-6JTZJRQJ.js";import{a as q}from"./chunk-SYC6D5XU.js";import{a as Q,d as Z}from"./chunk-5THX4DI2.js";import{c as L}from"./chunk-7SZRL6FY.js";var a=L(Q(),1);var e=L(Z(),1),W=1e3;function V(t,l){if(!t)return"\u2014";try{return new Date(t).toLocaleString(void 0,l?{timeZone:l,timeZoneName:"short"}:void 0)}catch{return t}}function X(t,l){let n=l.q.toLowerCase();return t.filter(o=>!l.kind||o.parsed?.kind===l.kind).filter(o=>!l.enabledOnly||o.enabled).filter(o=>!n||JSON.stringify(o).toLowerCase().includes(n)).sort((o,r)=>{if(o.enabled!==r.enabled)return o.enabled?-1:1;let w=o.nextRunAt?Date.parse(o.nextRunAt):1/0,p=r.nextRunAt?Date.parse(r.nextRunAt):1/0;return w-p})}function O(t){return t.deliver==="local"?"local":t.executionPosition==="new-topic"?"new-topic":t.executionPosition==="topic"?t.rootMessageId?"thread":"chat":t.executionPosition==="top-level"?"chat":t.deliver==="new-topic"?"new-topic":t.scope==="chat"?"chat":t.rootMessageId?"thread":"chat"}function Y(t,l){let n=O(t);return l(n==="local"?"schedules.deliveryLocal":n==="new-topic"?"schedules.deliveryNewTopic":n==="thread"?"schedules.deliveryThread":"schedules.deliveryTopLevel")}function ee(t){return t.repeat?`${t.repeat.completed}/${t.repeat.times??"\u221E"}`:"\u2014"}function le(t){return new Promise(l=>window.setTimeout(l,t))}function te(t){let{schedule:l,scheduleTimeZone:n,tr:o}=t,r=M(l),w=String(l.parsed?.kind??"unknown"),p=l.enabled?"pause":"resume",N=`${l.id}:${p}`,b=`${l.id}:run`;return(0,e.jsxs)(K,{kind:"schedule",className:"schedule-list-row","data-id":l.id,children:[(0,e.jsxs)(U,{children:[(0,e.jsxs)("div",{className:"schedule-row-head",children:[(0,e.jsx)("b",{children:l.name??l.id}),(0,e.jsx)("span",{className:`schedule-state ${l.enabled?"enabled":"paused"}`,children:l.enabled?o("schedules.enabled"):o("schedules.paused")})]}),(0,e.jsxs)("div",{className:"schedule-row-meta",children:[(0,e.jsx)("span",{children:l.botName??l.larkAppId??"-"}),(0,e.jsx)("span",{children:"\xB7"}),(0,e.jsx)("code",{children:l.parsed?.display??"?"})]}),(0,e.jsxs)("div",{className:"schedule-chip-strip",children:[(0,e.jsx)("span",{children:w}),l.chatId?(0,e.jsxs)("span",{className:"schedule-chat-chip",title:r?`${r} \xB7 ${String(l.chatId)}`:String(l.chatId),children:[o("schedules.form.chat"),": ",r??l.chatId]}):null,(0,e.jsxs)("span",{children:[o("schedules.delivery"),": ",Y(l,o)]}),l.silent?(0,e.jsxs)("span",{children:["\u{1F507} ",o("schedules.silent")]}):null,(0,e.jsxs)("span",{children:[o("schedules.next"),": ",V(l.nextRunAt,n)]}),(0,e.jsxs)("span",{children:[o("schedules.last"),": ",V(l.lastRunAt,n)]}),l.lastStatus==="error"?(0,e.jsxs)("span",{className:"schedule-error-chip",title:typeof l.lastError=="string"?l.lastError:void 0,children:["\u26A0 ",o("schedules.error"),": ",typeof l.lastError=="string"&&l.lastError.length>60?l.lastError.slice(0,60)+"\u2026":l.lastError??o("schedules.errorUnknown")]}):null,(0,e.jsxs)("span",{children:[o("schedules.repeat"),": ",ee(l)]})]})]}),(0,e.jsx)(j,{children:(0,e.jsxs)("div",{className:"schedule-actions",children:[(0,e.jsx)(oe,{op:"run",label:o("schedules.runNow"),pending:t.pending===b,feedback:t.feedback[b]??null,onClick:()=>t.onAction(l.id,"run")}),(0,e.jsx)(ce,{checked:!!l.enabled,pending:t.pending===N,feedback:t.feedback[N]??null,tr:o,onClick:()=>t.onAction(l.id,p)}),(0,e.jsx)("button",{type:"button",className:"schedule-action-button schedule-edit-button",onClick:()=>t.onEdit(l),title:o("schedules.edit"),children:(0,e.jsx)("span",{className:"schedule-action-label",children:o("schedules.edit")})}),(0,e.jsx)("button",{type:"button",className:"schedule-action-button schedule-delete-button",onClick:()=>t.onDelete(l),title:o("schedules.delete"),children:(0,e.jsx)("span",{className:"schedule-action-label",children:o("schedules.delete")})})]})})]})}function se(){let t=F(),{scheduleRows:l,scheduleTimeZone:n}=G(s=>({scheduleRows:[...s.schedules.values()],scheduleTimeZone:s.scheduleTimeZone})),[o,r]=(0,a.useState)({q:"",kind:"",enabledOnly:!1}),[w,p]=(0,a.useState)(null),[N,b]=(0,a.useState)({}),k=(0,a.useRef)(new Map),[P,y]=(0,a.useState)(!1),[u,T]=(0,a.useState)(null),[S,A]=(0,a.useState)(null),[C,E]=(0,a.useState)([]),[,I]=(0,a.useState)(0);(0,a.useEffect)(()=>{fetch("/api/bots").then(s=>s.json()).then(s=>{Array.isArray(s?.bots)&&E(s.bots)}).catch(()=>{})},[]),(0,a.useEffect)(()=>{H().then(()=>I(s=>s+1))},[]);let R=(0,a.useMemo)(()=>X(l,o),[l,o]);(0,a.useEffect)(()=>()=>{k.current.forEach(s=>window.clearTimeout(s)),k.current.clear()},[]);function m(s,c){b(f=>({...f,[s]:c}));let d=k.current.get(s);d&&window.clearTimeout(d);let v=window.setTimeout(()=>{b(f=>{let h={...f};return delete h[s],h}),k.current.delete(s)},c==="success"?1600:2200);k.current.set(s,v)}async function x(s,c){let d=`${s}:${c}`,v=performance.now(),f="success";p(d);try{let h=await fetch(`/api/schedules/${encodeURIComponent(s)}/${c}`,{method:"POST"}),D=await h.json().catch(()=>({}));if(!h.ok||D.ok===!1)throw new Error(`Failed: ${h.status} ${D?.error??""}`.trim())}catch{f="error"}finally{if(c==="run"){let h=W-(performance.now()-v);h>0&&await le(h)}m(d,f),p(h=>h===d?null:h)}}function g(){T(null),A(null),y(!0)}function $(s){T(s),A(null),y(!0)}async function i(s){if(!window.confirm(t("schedules.deleteConfirm")))return;let c=`${s.id}:delete`;p(c);try{let d=await fetch(`/api/schedules/${encodeURIComponent(s.id)}`,{method:"DELETE"}),v=await d.json().catch(()=>({}));if(!d.ok||v.ok===!1)throw new Error(v?.error??`HTTP ${d.status}`);m(c,"success")}catch{m(c,"error")}finally{p(d=>d===c?null:d)}}async function z(s){A(null);try{let c=u?`/api/schedules/${encodeURIComponent(u.id)}`:"/api/schedules",d=u?"PATCH":"POST",v=u?{name:s.name,schedule:s.schedule,prompt:s.prompt,silent:s.silent,...s.updateExecutionPosition?{executionPosition:s.executionPosition,rootMessageId:s.rootMessageId,topicTitle:s.topicTitle}:{}}:{name:s.name,schedule:s.schedule,prompt:s.prompt,silent:s.silent,executionPosition:s.executionPosition,rootMessageId:s.rootMessageId,topicTitle:s.topicTitle,chatId:s.chatId,larkAppId:s.larkAppId},f=await fetch(c,{method:d,headers:{"Content-Type":"application/json"},body:JSON.stringify(v)}),h=await f.json().catch(()=>({}));if(!f.ok||h.ok===!1)throw new Error(h?.error??`HTTP ${f.status}`);y(!1)}catch(c){A(c instanceof Error?c.message:String(c))}}return(0,e.jsxs)("section",{className:"page schedules-page",children:[(0,e.jsxs)("div",{className:"page-heading",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"eyebrow",children:t("nav.schedules")}),(0,e.jsx)("h1",{children:t("schedules.title")})]}),(0,e.jsx)(_,{onClick:g,disabled:C.length===0,children:t("schedules.create")})]}),(0,e.jsxs)("form",{id:"sched-filters",className:"filters dashboard-toolbar",children:[(0,e.jsx)("input",{type:"search",name:"q",placeholder:t("schedules.search"),value:o.q,onChange:s=>{let c=s.currentTarget.value;r(d=>({...d,q:c}))}}),(0,e.jsx)(J,{id:"sched-kind-menu",ariaLabel:t("schedules.anyKind"),label:o.kind||t("schedules.anyKind"),value:o.kind,options:[{value:"",label:t("schedules.anyKind")},{value:"cron",label:"cron"},{value:"interval",label:"interval"},{value:"once",label:"once"}],onChange:s=>r(c=>({...c,kind:s}))}),(0,e.jsxs)("label",{className:"filter-toggle",children:[(0,e.jsx)("input",{type:"checkbox",name:"enabled",checked:o.enabledOnly,onChange:s=>{let c=s.currentTarget.checked;r(d=>({...d,enabledOnly:c}))}}),(0,e.jsx)("span",{className:"filter-toggle-label",children:t("schedules.enabledOnly")}),(0,e.jsx)("span",{className:"filter-toggle-switch","aria-hidden":"true"})]}),(0,e.jsx)("span",{className:"schedules-toolbar-spacer","aria-hidden":"true"}),(0,e.jsxs)("span",{className:"schedules-toolbar-count",children:[R.length,"/",l.length]})]}),(0,e.jsx)("section",{className:"overview-block schedules-list-section",children:(0,e.jsx)("div",{className:"schedules-list-wrap",children:R.length===0?(0,e.jsx)("div",{id:"schedules-tbody",className:"empty schedules-list-empty",children:t("schedules.empty")}):(0,e.jsx)(B,{id:"schedules-tbody",className:"schedules-list",children:R.map(s=>(0,e.jsx)(te,{schedule:s,scheduleTimeZone:n,pending:w,feedback:N,tr:t,onAction:(c,d)=>{x(c,d)},onEdit:$,onDelete:c=>{i(c)}},s.id))})})}),P?(0,e.jsx)(ae,{editing:u,error:S,bots:C,tr:t,onClose:()=>y(!1),onSubmit:s=>{z(s)}}):null]})}function ne(t,l,n,o,r){return n?r(t==="run"?"schedules.running":"schedules.saving"):o==="success"?r(t==="run"?"schedules.runDone":"schedules.saved"):o==="error"?r("schedules.failed"):l}function oe(t){let l=F(),n=t.feedback?` is-${t.feedback}`:"";return(0,e.jsx)("button",{type:"button",className:`schedule-action-button${t.pending?" is-pending":""}${n}`,"data-op":t.op,disabled:t.pending,onClick:t.onClick,children:(0,e.jsx)("span",{className:"schedule-action-label",children:ne(t.op,t.label,t.pending,t.feedback,l)})})}function ce(t){let l=t.feedback==="error"?t.tr("schedules.failed"):t.checked?t.tr("schedules.enabled"):t.tr("schedules.paused");return(0,e.jsxs)("button",{type:"button",className:`schedule-enabled-switch${t.checked?" is-on":""}${t.pending?" is-pending":""}${t.feedback?` is-${t.feedback}`:""}`,"aria-pressed":t.checked,disabled:t.pending,onClick:t.onClick,children:[(0,e.jsx)("span",{className:"schedule-enabled-switch-label",children:l}),(0,e.jsx)("span",{className:"schedule-enabled-switch-track","aria-hidden":"true",children:(0,e.jsx)("span",{})})]})}function he(t){return q(t,(0,e.jsx)(se,{}))}function ae(t){let{editing:l,tr:n,bots:o}=t,[r,w]=(0,a.useState)(l?.name??""),[p,N]=(0,a.useState)(l?.schedule??""),[b,k]=(0,a.useState)(l?.prompt??""),[P,y]=(0,a.useState)(l?.silent===!0),[u,T]=(0,a.useState)(l&&O(l)==="thread"?"topic":l&&O(l)==="new-topic"?"new-topic":"top-level"),[S,A]=(0,a.useState)(l?.rootMessageId??""),[C,E]=(0,a.useState)(l?.topicTitle??""),[I,R]=(0,a.useState)(l?.chatId??""),[m,x]=(0,a.useState)(l?.larkAppId??o[0]?.larkAppId??""),g=l?.deliver==="local";(0,a.useEffect)(()=>{!l&&!m&&o.length>0&&x(o[0].larkAppId)},[l,m,o]);function $(i){i.preventDefault(),!(!l&&!m)&&(!g&&u==="topic"&&!S.trim()||t.onSubmit({name:r,schedule:p,prompt:b,silent:P,executionPosition:u,rootMessageId:S.trim(),topicTitle:C.trim(),updateExecutionPosition:!g,chatId:I,larkAppId:m}))}return(0,e.jsx)("div",{className:"schedule-form-overlay",onClick:t.onClose,children:(0,e.jsxs)("div",{className:"schedule-form-dialog",role:"dialog","aria-modal":"true",onClick:i=>i.stopPropagation(),children:[(0,e.jsx)("h2",{children:n(l?"schedules.edit":"schedules.create")}),(0,e.jsxs)("form",{onSubmit:$,className:"schedule-form",children:[l?null:(0,e.jsxs)("label",{className:"schedule-form-field",children:[(0,e.jsx)("span",{className:"schedule-form-label",children:n("schedules.form.bot")}),(0,e.jsx)("select",{value:m,onChange:i=>x(i.target.value),required:!0,children:o.map(i=>(0,e.jsx)("option",{value:i.larkAppId,children:i.botName??i.larkAppId},i.larkAppId))})]}),(0,e.jsxs)("label",{className:"schedule-form-field",children:[(0,e.jsx)("span",{className:"schedule-form-label",children:n("schedules.form.name")}),(0,e.jsx)("input",{type:"text",value:r,onChange:i=>w(i.target.value),required:!0,autoFocus:!0})]}),(0,e.jsxs)("label",{className:"schedule-form-field",children:[(0,e.jsx)("span",{className:"schedule-form-label",children:n("schedules.form.schedule")}),(0,e.jsx)("input",{type:"text",value:p,onChange:i=>N(i.target.value),placeholder:n("schedules.form.scheduleHelp"),required:!0}),(0,e.jsx)("small",{className:"schedule-form-help",children:n("schedules.form.scheduleHelp")})]}),(0,e.jsxs)("label",{className:"schedule-form-field",children:[(0,e.jsx)("span",{className:"schedule-form-label",children:n("schedules.form.prompt")}),(0,e.jsx)("textarea",{value:b,onChange:i=>k(i.target.value),rows:4,required:!0}),(0,e.jsx)("small",{className:"schedule-form-help",children:n("schedules.form.promptHelp")})]}),l?(0,e.jsxs)("div",{className:"schedule-form-field",children:[(0,e.jsx)("span",{className:"schedule-form-label",children:n("schedules.form.chat")}),(0,e.jsx)("code",{title:I,children:M(l)??I})]}):(0,e.jsxs)("label",{className:"schedule-form-field",children:[(0,e.jsx)("span",{className:"schedule-form-label",children:n("schedules.form.chat")}),(0,e.jsx)("input",{type:"text",value:I,onChange:i=>R(i.target.value),placeholder:"oc_...",required:!0})]}),g?(0,e.jsxs)("div",{className:"schedule-form-field",children:[(0,e.jsx)("span",{className:"schedule-form-label",children:n("schedules.form.deliver")}),(0,e.jsxs)("div",{className:"schedule-form-placement",children:[(0,e.jsx)("strong",{children:n("schedules.deliveryLocal")}),(0,e.jsx)("small",{className:"schedule-form-help",children:n("schedules.form.localHelp")})]})]}):(0,e.jsxs)("div",{className:"schedule-form-field",children:[(0,e.jsx)("span",{className:"schedule-form-label",children:n("schedules.form.deliver")}),(0,e.jsxs)("div",{className:"schedule-form-radio-group",children:[(0,e.jsxs)("label",{children:[(0,e.jsx)("input",{type:"radio",name:"executionPosition",value:"top-level",checked:u==="top-level",onChange:()=>T("top-level")}),n("schedules.deliveryTopLevel")]}),(0,e.jsxs)("label",{children:[(0,e.jsx)("input",{type:"radio",name:"executionPosition",value:"topic",checked:u==="topic",onChange:()=>T("topic")}),n("schedules.deliveryThread")]}),(0,e.jsxs)("label",{children:[(0,e.jsx)("input",{type:"radio",name:"executionPosition",value:"new-topic",checked:u==="new-topic",onChange:()=>{T("new-topic"),y(!1)}}),n("schedules.deliveryNewTopic")]})]}),(0,e.jsx)("small",{className:"schedule-form-help",children:n(u==="top-level"?"schedules.form.topLevelHelp":u==="topic"?"schedules.form.topicHelp":"schedules.form.newTopicHelp")})]}),!g&&u==="topic"?(0,e.jsxs)("label",{className:"schedule-form-field",children:[(0,e.jsx)("span",{className:"schedule-form-label",children:n("schedules.form.topicRoot")}),(0,e.jsx)("input",{type:"text",value:S,onChange:i=>A(i.target.value),placeholder:"om_...",required:!0}),(0,e.jsx)("small",{className:"schedule-form-help",children:n("schedules.form.topicRootHelp")})]}):null,!g&&u==="new-topic"?(0,e.jsxs)("label",{className:"schedule-form-field",children:[(0,e.jsx)("span",{className:"schedule-form-label",children:n("schedules.form.topicTitle")}),(0,e.jsx)("input",{type:"text",value:C,onChange:i=>E(i.target.value),placeholder:n("schedules.form.topicTitlePlaceholder"),maxLength:200}),(0,e.jsxs)("small",{className:"schedule-form-help schedule-form-help-with-count",children:[n("schedules.form.topicTitleHelp"),(0,e.jsxs)("span",{children:[Array.from(C).length,"/200"]})]})]}):null,(0,e.jsxs)("label",{className:"schedule-form-field schedule-form-toggle",children:[(0,e.jsx)("input",{type:"checkbox",checked:P,onChange:i=>y(i.target.checked)}),(0,e.jsxs)("span",{children:[n("schedules.form.silent"),(0,e.jsx)("small",{className:"schedule-form-help",children:n("schedules.form.silentHelp")})]})]}),u==="new-topic"&&P?(0,e.jsx)("p",{className:"schedule-form-help",children:n("schedules.form.silentNewTopicConflict")}):null,t.error?(0,e.jsx)("p",{className:"schedule-form-error",children:t.error}):null,(0,e.jsxs)("div",{className:"schedule-form-actions",children:[(0,e.jsx)("button",{type:"button",className:"schedule-form-cancel",onClick:t.onClose,children:n("schedules.form.cancel")}),(0,e.jsx)("button",{type:"submit",className:"schedule-form-submit",disabled:!l&&!m||!g&&u==="topic"&&!S.trim(),children:n(l?"schedules.form.save":"schedules.form.create")})]})]})]})})}export{X as filterSchedules,V as fmtScheduleDate,he as renderSchedulesPage,O as scheduleExecutionPlacement};
|