@jingyi0605/codingns 0.9.0 → 0.9.6
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/bin/codingns.mjs +75 -0
- package/dist/public/assets/{AdaptiveButlerPage-B17QiMyT.js → AdaptiveButlerPage-khJQh6a_.js} +2 -2
- package/dist/public/assets/{App-CFBwDUNA.js → App-If9gThKM.js} +6 -6
- package/dist/public/assets/{BootstrapPage-W5wU3BPh.js → BootstrapPage-DcfYtoLC.js} +1 -1
- package/dist/public/assets/{ConversationPage-DQLX1bUh.js → ConversationPage-Bfb7GLTM.js} +1 -1
- package/dist/public/assets/{DesktopDetachPreviewPage-DTPeuAW-.js → DesktopDetachPreviewPage-CXUPMcBz.js} +1 -1
- package/dist/public/assets/{DesktopModal-6ii53_Y9.js → DesktopModal-bMdI1jEe.js} +1 -1
- package/dist/public/assets/DesktopWindowPage-D1xwgS-7.js +2 -0
- package/dist/public/assets/FileContextPanel-C4syif3B.js +1 -0
- package/dist/public/assets/GitSidebar-DduL9aTV.js +6 -0
- package/dist/public/assets/MobileCreateSessionSheet-DWPBsEx8.js +1 -0
- package/dist/public/assets/{MobileSheet-opTWyRe1.js → MobileSheet-BXvQPkxt.js} +1 -1
- package/dist/public/assets/{MobileTopHeaderFrame-BbNON3Y4.js → MobileTopHeaderFrame-vdYOyaaB.js} +1 -1
- package/dist/public/assets/{MobileWorkspaceSwitcherHeader-BZEzPeMj.js → MobileWorkspaceSwitcherHeader-DT330cAx.js} +1 -1
- package/dist/public/assets/{PluginAccessOverview-mQDmAljp.js → PluginAccessOverview-C77TeZTK.js} +1 -1
- package/dist/public/assets/{PluginContainerPage-CcxUJpM4.js → PluginContainerPage-DdSwOCw-.js} +1 -1
- package/dist/public/assets/{PluginDetailPage-D5--ACIt.js → PluginDetailPage-BK1yTzvO.js} +1 -1
- package/dist/public/assets/{PluginsListPage-D_oJxYXT.js → PluginsListPage-DAAwSc6W.js} +1 -1
- package/dist/public/assets/{RelayConnectEntryPage-DROxpnkv.js → RelayConnectEntryPage-4Yyo2p8b.js} +1 -1
- package/dist/public/assets/{ServerSettingsModal-CUUOPqSe.js → ServerSettingsModal-C_DEisHs.js} +1 -1
- package/dist/public/assets/{SessionIndexPage-C2Jxh6Gp.js → SessionIndexPage-DyMikN_x.js} +1 -1
- package/dist/public/assets/SettingsPage-CDAVsPr3.js +2 -0
- package/dist/public/assets/TerminalManagerPanel-4OR47vcf.js +1 -0
- package/dist/public/assets/{TerminalPage-CwWyFDj8.js → TerminalPage-Pvx396YX.js} +1 -1
- package/dist/public/assets/{TerminalRuntimeFallbackModal-CSVVbO8r.js → TerminalRuntimeFallbackModal-KvG6k4AQ.js} +1 -1
- package/dist/public/assets/{ToolFilesPage-QBEY8oCf.js → ToolFilesPage-DrYHk0N-.js} +1 -1
- package/dist/public/assets/{ToolGitPage-BKoZ2l9v.js → ToolGitPage-Dz1q-Ns_.js} +1 -1
- package/dist/public/assets/{ToolProcessesPage-BOH0ib4G.js → ToolProcessesPage-CRhphOmM.js} +1 -1
- package/dist/public/assets/{ToolsHomePage-BcMZ3BCQ.js → ToolsHomePage-BJSDLR6T.js} +1 -1
- package/dist/public/assets/{WorkbenchLandingPage-B5zoppEl.js → WorkbenchLandingPage-BlkxdOLC.js} +1 -1
- package/dist/public/assets/WorkbenchLayout-D-U7ghT0.js +1022 -0
- package/dist/public/assets/{WorkbenchModal-NGmPgqaE.js → WorkbenchModal-xbx1o6MO.js} +1 -1
- package/dist/public/assets/WorkbenchShellRoute-DyWSCHz_.js +1 -0
- package/dist/public/assets/WorkbenchShellRoute-htbkGbtW.css +1 -0
- package/dist/public/assets/WorkspaceDebugDetailPage-B4ol2_a5.js +1 -0
- package/dist/public/assets/WorkspaceDetailPage-DMakfmHR.js +1 -0
- package/dist/public/assets/WorkspaceHomePage-tmCafatd.js +1 -0
- package/dist/public/assets/{client-runtime-manager-DXbI9K1K.js → client-runtime-manager-Bwau7p1v.js} +1 -1
- package/dist/public/assets/index-DmUJ8tIw.css +1 -0
- package/dist/public/assets/index-_OCkVmfl.js +50 -0
- package/dist/public/assets/{login-direct-candidate-resolver-DkKyFtQJ.js → login-direct-candidate-resolver-CKUQ07IA.js} +1 -1
- package/dist/public/assets/{plugin-permission-copy-CzN269Bk.js → plugin-permission-copy-DIVk5jNp.js} +1 -1
- package/dist/public/assets/{plugins-api-Bv9DHpLF.js → plugins-api-DHJVvPZw.js} +1 -1
- package/dist/public/assets/{preferences-service-D2ISL2Zz.js → preferences-service-CyxxeBmS.js} +1 -1
- package/dist/public/assets/{relay-entry-Bg0OisQy.js → relay-entry-B5GmiOrR.js} +1 -1
- package/dist/public/assets/{terminal-runtime-meta-C8t-CIDF.js → terminal-runtime-meta-DBsyT35T.js} +1 -1
- package/dist/public/assets/useRegisteredDebugTemplates-wCGD2SLW.js +1 -0
- package/dist/public/assets/workbench-navigation-RyUjchbD.js +1 -0
- package/dist/public/index.html +2 -2
- package/dist/server/config/env.d.ts +1 -0
- package/dist/server/config/env.js +3 -0
- package/dist/server/config/env.js.map +1 -1
- package/dist/server/modules/affairs-indexer/core/src/parser/parser-skip-repository.js.map +1 -1
- package/dist/server/modules/affairs-indexer/core/src/repositories/catalog-repository.d.ts +1 -0
- package/dist/server/modules/affairs-indexer/core/src/repositories/catalog-repository.js +31 -0
- package/dist/server/modules/affairs-indexer/core/src/repositories/catalog-repository.js.map +1 -1
- package/dist/server/modules/affairs-indexer/core/src/repositories/catalog-write-repository.js.map +1 -1
- package/dist/server/modules/affairs-indexer/core/src/services/dirty/dirty-scope-resolver.d.ts +1 -0
- package/dist/server/modules/affairs-indexer/core/src/services/dirty/dirty-scope-resolver.js +1 -0
- package/dist/server/modules/affairs-indexer/core/src/services/dirty/dirty-scope-resolver.js.map +1 -1
- package/dist/server/modules/affairs-indexer/core/src/services/export/export-builder.js +4 -1
- package/dist/server/modules/affairs-indexer/core/src/services/export/export-builder.js.map +1 -1
- package/dist/server/modules/affairs-indexer/core/src/services/search/search-index-builder.js +140 -16
- package/dist/server/modules/affairs-indexer/core/src/services/search/search-index-builder.js.map +1 -1
- package/dist/server/modules/affairs-indexer/core/src/sqlite/detect-catalog-schema.js +2 -2
- package/dist/server/modules/affairs-indexer/core/src/sqlite/detect-catalog-schema.js.map +1 -1
- package/dist/server/modules/affairs-indexer/core/src/sqlite/open-database.d.ts +20 -3
- package/dist/server/modules/affairs-indexer/core/src/sqlite/open-database.js +3 -3
- package/dist/server/modules/affairs-indexer/core/src/sqlite/open-database.js.map +1 -1
- package/dist/server/modules/assistant-capability/assistant-capability-controller.d.ts +1 -1
- package/dist/server/modules/assistant-capability/assistant-capability-controller.js +8 -7
- package/dist/server/modules/assistant-capability/assistant-capability-controller.js.map +1 -1
- package/dist/server/modules/assistant-capability/assistant-capability-service.d.ts +14 -13
- package/dist/server/modules/assistant-capability/assistant-capability-service.js +27 -24
- package/dist/server/modules/assistant-capability/assistant-capability-service.js.map +1 -1
- package/dist/server/modules/auth/auth-controller.d.ts +27 -1
- package/dist/server/modules/auth/auth-controller.js +20 -0
- package/dist/server/modules/auth/auth-controller.js.map +1 -1
- package/dist/server/modules/auth/auth-service.d.ts +32 -1
- package/dist/server/modules/auth/auth-service.js +217 -2
- package/dist/server/modules/auth/auth-service.js.map +1 -1
- package/dist/server/modules/bootstrap/bootstrap-service.js +1 -0
- package/dist/server/modules/bootstrap/bootstrap-service.js.map +1 -1
- package/dist/server/modules/butler/assistant-automation-service.d.ts +1 -1
- package/dist/server/modules/butler/assistant-automation-service.js +9 -10
- package/dist/server/modules/butler/assistant-automation-service.js.map +1 -1
- package/dist/server/modules/butler/assistant-sandbox-cleanup-scheduler.d.ts +32 -0
- package/dist/server/modules/butler/assistant-sandbox-cleanup-scheduler.js +93 -0
- package/dist/server/modules/butler/assistant-sandbox-cleanup-scheduler.js.map +1 -0
- package/dist/server/modules/butler/assistant-sandbox-service.d.ts +69 -0
- package/dist/server/modules/butler/assistant-sandbox-service.js +399 -0
- package/dist/server/modules/butler/assistant-sandbox-service.js.map +1 -0
- package/dist/server/modules/butler/butler-action-context-service.js +2 -2
- package/dist/server/modules/butler/butler-action-context-service.js.map +1 -1
- package/dist/server/modules/butler/butler-control-action-service.d.ts +5 -5
- package/dist/server/modules/butler/butler-control-action-service.js +19 -19
- package/dist/server/modules/butler/butler-control-action-service.js.map +1 -1
- package/dist/server/modules/butler/butler-control-session-service.d.ts +1 -1
- package/dist/server/modules/butler/butler-control-session-service.js +27 -26
- package/dist/server/modules/butler/butler-control-session-service.js.map +1 -1
- package/dist/server/modules/butler/butler-control-timer-service.js +4 -5
- package/dist/server/modules/butler/butler-control-timer-service.js.map +1 -1
- package/dist/server/modules/butler/butler-controller.d.ts +2 -2
- package/dist/server/modules/butler/butler-controller.js +19 -17
- package/dist/server/modules/butler/butler-controller.js.map +1 -1
- package/dist/server/modules/butler/butler-follow-up-service.d.ts +3 -0
- package/dist/server/modules/butler/butler-follow-up-service.js +11 -1
- package/dist/server/modules/butler/butler-follow-up-service.js.map +1 -1
- package/dist/server/modules/butler/butler-inbox-service.d.ts +3 -0
- package/dist/server/modules/butler/butler-inbox-service.js +14 -2
- package/dist/server/modules/butler/butler-inbox-service.js.map +1 -1
- package/dist/server/modules/butler/butler-profile-service.d.ts +5 -5
- package/dist/server/modules/butler/butler-profile-service.js +17 -16
- package/dist/server/modules/butler/butler-profile-service.js.map +1 -1
- package/dist/server/modules/butler/butler-project-service.d.ts +7 -6
- package/dist/server/modules/butler/butler-project-service.js +35 -21
- package/dist/server/modules/butler/butler-project-service.js.map +1 -1
- package/dist/server/modules/butler/butler-session-service.d.ts +5 -2
- package/dist/server/modules/butler/butler-session-service.js +51 -27
- package/dist/server/modules/butler/butler-session-service.js.map +1 -1
- package/dist/server/modules/butler/butler-session-summary-service.d.ts +2 -2
- package/dist/server/modules/butler/butler-session-summary-service.js +23 -9
- package/dist/server/modules/butler/butler-session-summary-service.js.map +1 -1
- package/dist/server/modules/butler/context-aggregator.js +9 -9
- package/dist/server/modules/butler/context-aggregator.js.map +1 -1
- package/dist/server/modules/butler/patrol-execution-service.d.ts +0 -1
- package/dist/server/modules/butler/patrol-execution-service.js +6 -12
- package/dist/server/modules/butler/patrol-execution-service.js.map +1 -1
- package/dist/server/modules/channels/wechat-claw-client.d.ts +51 -0
- package/dist/server/modules/channels/wechat-claw-client.js +245 -0
- package/dist/server/modules/channels/wechat-claw-client.js.map +1 -0
- package/dist/server/modules/file/file-controller.d.ts +11 -2
- package/dist/server/modules/file/file-controller.js +404 -17
- package/dist/server/modules/file/file-controller.js.map +1 -1
- package/dist/server/modules/file/file-search-service.js +200 -12
- package/dist/server/modules/file/file-search-service.js.map +1 -1
- package/dist/server/modules/file/runtime/codingns-workspace-bridge.js +18 -5
- package/dist/server/modules/file/workspace-file-bridge-service.d.ts +9 -0
- package/dist/server/modules/file/workspace-file-bridge-service.js +3 -0
- package/dist/server/modules/file/workspace-file-bridge-service.js.map +1 -1
- package/dist/server/modules/file/workspace-file-bridge-watch-service.d.ts +9 -0
- package/dist/server/modules/file/workspace-file-bridge-watch-service.js +28 -0
- package/dist/server/modules/file/workspace-file-bridge-watch-service.js.map +1 -1
- package/dist/server/modules/sessions/session-controller.js +3 -3
- package/dist/server/modules/sessions/session-controller.js.map +1 -1
- package/dist/server/modules/sessions/session-history-service.d.ts +8 -3
- package/dist/server/modules/sessions/session-history-service.js +126 -11
- package/dist/server/modules/sessions/session-history-service.js.map +1 -1
- package/dist/server/modules/sessions/session-live-runtime-service.js +25 -15
- package/dist/server/modules/sessions/session-live-runtime-service.js.map +1 -1
- package/dist/server/modules/sessions/session-permission-request-service.js +28 -15
- package/dist/server/modules/sessions/session-permission-request-service.js.map +1 -1
- package/dist/server/modules/tasks/task-types.d.ts +1 -0
- package/dist/server/modules/tasks/task-types.js +1 -0
- package/dist/server/modules/tasks/task-types.js.map +1 -1
- package/dist/server/modules/workbench/affairs-assistant-session-snapshot-service.d.ts +1 -1
- package/dist/server/modules/workbench/affairs-assistant-session-snapshot-service.js +22 -5
- package/dist/server/modules/workbench/affairs-assistant-session-snapshot-service.js.map +1 -1
- package/dist/server/modules/workbench/workbench-controller.d.ts +5 -0
- package/dist/server/modules/workbench/workbench-controller.js +20 -0
- package/dist/server/modules/workbench/workbench-controller.js.map +1 -1
- package/dist/server/modules/workbench/workbench-service.d.ts +6 -6
- package/dist/server/modules/workbench/workbench-service.js +42 -45
- package/dist/server/modules/workbench/workbench-service.js.map +1 -1
- package/dist/server/modules/workspace/affairs-library-controller.d.ts +8 -0
- package/dist/server/modules/workspace/affairs-library-controller.js +11 -0
- package/dist/server/modules/workspace/affairs-library-controller.js.map +1 -1
- package/dist/server/modules/workspace/affairs-library-preview-link-service.d.ts +6 -0
- package/dist/server/modules/workspace/affairs-library-preview-link-service.js +12 -2
- package/dist/server/modules/workspace/affairs-library-preview-link-service.js.map +1 -1
- package/dist/server/modules/workspace/affairs-library-service.d.ts +12 -1
- package/dist/server/modules/workspace/affairs-library-service.js +294 -96
- package/dist/server/modules/workspace/affairs-library-service.js.map +1 -1
- package/dist/server/modules/workspace/affairs-lightweight-session-controller.d.ts +8 -0
- package/dist/server/modules/workspace/affairs-lightweight-session-controller.js +55 -8
- package/dist/server/modules/workspace/affairs-lightweight-session-controller.js.map +1 -1
- package/dist/server/modules/workspace/affairs-lightweight-session-service.d.ts +13 -0
- package/dist/server/modules/workspace/affairs-lightweight-session-service.js +167 -21
- package/dist/server/modules/workspace/affairs-lightweight-session-service.js.map +1 -1
- package/dist/server/modules/workspace/affairs-tag-controller.d.ts +3 -0
- package/dist/server/modules/workspace/affairs-tag-controller.js +5 -0
- package/dist/server/modules/workspace/affairs-tag-controller.js.map +1 -1
- package/dist/server/modules/workspace/affairs-tag-service.d.ts +34 -1
- package/dist/server/modules/workspace/affairs-tag-service.js +568 -4
- package/dist/server/modules/workspace/affairs-tag-service.js.map +1 -1
- package/dist/server/modules/workspace/teable-api-client.d.ts +118 -0
- package/dist/server/modules/workspace/teable-api-client.js +142 -0
- package/dist/server/modules/workspace/teable-api-client.js.map +1 -0
- package/dist/server/modules/workspace/teable-catalog-controller.d.ts +18 -0
- package/dist/server/modules/workspace/teable-catalog-controller.js +17 -0
- package/dist/server/modules/workspace/teable-catalog-controller.js.map +1 -0
- package/dist/server/modules/workspace/teable-catalog-service.d.ts +36 -0
- package/dist/server/modules/workspace/teable-catalog-service.js +124 -0
- package/dist/server/modules/workspace/teable-catalog-service.js.map +1 -0
- package/dist/server/modules/workspace/teable-credential-service.d.ts +8 -0
- package/dist/server/modules/workspace/teable-credential-service.js +37 -0
- package/dist/server/modules/workspace/teable-credential-service.js.map +1 -0
- package/dist/server/modules/workspace/teable-field-mapping-controller.d.ts +25 -0
- package/dist/server/modules/workspace/teable-field-mapping-controller.js +31 -0
- package/dist/server/modules/workspace/teable-field-mapping-controller.js.map +1 -0
- package/dist/server/modules/workspace/teable-field-mapping-service.d.ts +38 -0
- package/dist/server/modules/workspace/teable-field-mapping-service.js +215 -0
- package/dist/server/modules/workspace/teable-field-mapping-service.js.map +1 -0
- package/dist/server/modules/workspace/teable-global-binding-controller.d.ts +22 -0
- package/dist/server/modules/workspace/teable-global-binding-controller.js +25 -0
- package/dist/server/modules/workspace/teable-global-binding-controller.js.map +1 -0
- package/dist/server/modules/workspace/teable-global-binding-service.d.ts +35 -0
- package/dist/server/modules/workspace/teable-global-binding-service.js +151 -0
- package/dist/server/modules/workspace/teable-global-binding-service.js.map +1 -0
- package/dist/server/modules/workspace/teable-mirror-sync-controller.d.ts +29 -0
- package/dist/server/modules/workspace/teable-mirror-sync-controller.js +50 -0
- package/dist/server/modules/workspace/teable-mirror-sync-controller.js.map +1 -0
- package/dist/server/modules/workspace/teable-mirror-sync-service.d.ts +157 -0
- package/dist/server/modules/workspace/teable-mirror-sync-service.js +917 -0
- package/dist/server/modules/workspace/teable-mirror-sync-service.js.map +1 -0
- package/dist/server/modules/workspace/teable-runtime-controller.d.ts +58 -0
- package/dist/server/modules/workspace/teable-runtime-controller.js +60 -0
- package/dist/server/modules/workspace/teable-runtime-controller.js.map +1 -0
- package/dist/server/modules/workspace/teable-runtime-service.d.ts +96 -0
- package/dist/server/modules/workspace/teable-runtime-service.js +362 -0
- package/dist/server/modules/workspace/teable-runtime-service.js.map +1 -0
- package/dist/server/modules/workspace/teable-workbench-sync-config-controller.d.ts +22 -0
- package/dist/server/modules/workspace/teable-workbench-sync-config-controller.js +20 -0
- package/dist/server/modules/workspace/teable-workbench-sync-config-controller.js.map +1 -0
- package/dist/server/modules/workspace/teable-workbench-sync-config-service.d.ts +22 -0
- package/dist/server/modules/workspace/teable-workbench-sync-config-service.js +159 -0
- package/dist/server/modules/workspace/teable-workbench-sync-config-service.js.map +1 -0
- package/dist/server/modules/workspace/workspace-controller.d.ts +1 -1
- package/dist/server/modules/workspace/workspace-controller.js +7 -7
- package/dist/server/modules/workspace/workspace-controller.js.map +1 -1
- package/dist/server/modules/workspace/workspace-service.d.ts +7 -0
- package/dist/server/modules/workspace/workspace-service.js +151 -10
- package/dist/server/modules/workspace/workspace-service.js.map +1 -1
- package/dist/server/routes/affairs.d.ts +9 -1
- package/dist/server/routes/affairs.js +120 -1
- package/dist/server/routes/affairs.js.map +1 -1
- package/dist/server/routes/auth.js +6 -0
- package/dist/server/routes/auth.js.map +1 -1
- package/dist/server/routes/workbench.js +15 -0
- package/dist/server/routes/workbench.js.map +1 -1
- package/dist/server/routes/workspaces.js +51 -41
- package/dist/server/routes/workspaces.js.map +1 -1
- package/dist/server/server/create-server.d.ts +18 -0
- package/dist/server/server/create-server.js +99 -7
- package/dist/server/server/create-server.js.map +1 -1
- package/dist/server/server/start-host.js +20 -0
- package/dist/server/server/start-host.js.map +1 -1
- package/dist/server/shared/http/request-diagnostics.d.ts +56 -0
- package/dist/server/shared/http/request-diagnostics.js +256 -0
- package/dist/server/shared/http/request-diagnostics.js.map +1 -0
- package/dist/server/storage/repositories/assistant-sandbox-workspace-repository.d.ts +18 -0
- package/dist/server/storage/repositories/assistant-sandbox-workspace-repository.js +191 -0
- package/dist/server/storage/repositories/assistant-sandbox-workspace-repository.js.map +1 -0
- package/dist/server/storage/repositories/auth-token-repository.d.ts +1 -0
- package/dist/server/storage/repositories/auth-token-repository.js +8 -0
- package/dist/server/storage/repositories/auth-token-repository.js.map +1 -1
- package/dist/server/storage/repositories/auth-user-repository.d.ts +50 -0
- package/dist/server/storage/repositories/auth-user-repository.js +198 -27
- package/dist/server/storage/repositories/auth-user-repository.js.map +1 -1
- package/dist/server/storage/repositories/butler-control-session-repository.d.ts +4 -1
- package/dist/server/storage/repositories/butler-control-session-repository.js +55 -8
- package/dist/server/storage/repositories/butler-control-session-repository.js.map +1 -1
- package/dist/server/storage/repositories/butler-profile-repository.d.ts +2 -1
- package/dist/server/storage/repositories/butler-profile-repository.js +35 -6
- package/dist/server/storage/repositories/butler-profile-repository.js.map +1 -1
- package/dist/server/storage/repositories/butler-project-repository.d.ts +2 -0
- package/dist/server/storage/repositories/butler-project-repository.js +38 -4
- package/dist/server/storage/repositories/butler-project-repository.js.map +1 -1
- package/dist/server/storage/repositories/butler-session-repository.d.ts +2 -1
- package/dist/server/storage/repositories/butler-session-repository.js +35 -6
- package/dist/server/storage/repositories/butler-session-repository.js.map +1 -1
- package/dist/server/storage/repositories/session-binding-repository.d.ts +3 -0
- package/dist/server/storage/repositories/session-binding-repository.js +70 -2
- package/dist/server/storage/repositories/session-binding-repository.js.map +1 -1
- package/dist/server/storage/repositories/session-index-repository.js +7 -5
- package/dist/server/storage/repositories/session-index-repository.js.map +1 -1
- package/dist/server/storage/repositories/user-affairs-library-setting-repository.js +8 -5
- package/dist/server/storage/repositories/user-affairs-library-setting-repository.js.map +1 -1
- package/dist/server/storage/repositories/user-teable-credential-repository.d.ts +9 -0
- package/dist/server/storage/repositories/user-teable-credential-repository.js +45 -0
- package/dist/server/storage/repositories/user-teable-credential-repository.js.map +1 -0
- package/dist/server/storage/repositories/user-teable-field-mapping-repository.d.ts +10 -0
- package/dist/server/storage/repositories/user-teable-field-mapping-repository.js +69 -0
- package/dist/server/storage/repositories/user-teable-field-mapping-repository.js.map +1 -0
- package/dist/server/storage/repositories/user-teable-global-setting-repository.d.ts +8 -0
- package/dist/server/storage/repositories/user-teable-global-setting-repository.js +52 -0
- package/dist/server/storage/repositories/user-teable-global-setting-repository.js.map +1 -0
- package/dist/server/storage/repositories/user-teable-mirror-record-mapping-repository.d.ts +9 -0
- package/dist/server/storage/repositories/user-teable-mirror-record-mapping-repository.js +66 -0
- package/dist/server/storage/repositories/user-teable-mirror-record-mapping-repository.js.map +1 -0
- package/dist/server/storage/repositories/user-teable-mirror-table-binding-repository.d.ts +9 -0
- package/dist/server/storage/repositories/user-teable-mirror-table-binding-repository.js +67 -0
- package/dist/server/storage/repositories/user-teable-mirror-table-binding-repository.js.map +1 -0
- package/dist/server/storage/repositories/user-teable-sync-log-repository.d.ts +14 -0
- package/dist/server/storage/repositories/user-teable-sync-log-repository.js +97 -0
- package/dist/server/storage/repositories/user-teable-sync-log-repository.js.map +1 -0
- package/dist/server/storage/repositories/user-teable-workbench-sync-config-repository.d.ts +8 -0
- package/dist/server/storage/repositories/user-teable-workbench-sync-config-repository.js +55 -0
- package/dist/server/storage/repositories/user-teable-workbench-sync-config-repository.js.map +1 -0
- package/dist/server/storage/repositories/workspace-repository.d.ts +3 -1
- package/dist/server/storage/repositories/workspace-repository.js +24 -10
- package/dist/server/storage/repositories/workspace-repository.js.map +1 -1
- package/dist/server/storage/sqlite/client.js +692 -1
- package/dist/server/storage/sqlite/client.js.map +1 -1
- package/dist/server/storage/sqlite/schema.sql +200 -10
- package/dist/server/types/domain.d.ts +114 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-session-store.js +34 -7
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-session-store.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.js +3 -7
- package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/sqlite/node-sqlite.d.ts +22 -3
- package/node_modules/@codingns/session-sync-core/dist/sqlite/node-sqlite.js +29 -2
- package/node_modules/@codingns/session-sync-core/dist/sqlite/node-sqlite.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/package.json +3 -1
- package/package.json +1 -1
- package/dist/public/assets/DesktopWindowPage-D0blSuKd.js +0 -2
- package/dist/public/assets/FileContextPanel-BrKO8Xt6.js +0 -1
- package/dist/public/assets/GitSidebar-BdwiDtOr.js +0 -6
- package/dist/public/assets/MobileCreateSessionSheet-Cx_dBiBb.js +0 -1
- package/dist/public/assets/SettingsPage-BlAZCHsy.js +0 -2
- package/dist/public/assets/TerminalManagerPanel-CjzbiWjl.js +0 -1
- package/dist/public/assets/WorkbenchLayout-CikJBS62.js +0 -1019
- package/dist/public/assets/WorkbenchShellRoute-BbbSOiZw.js +0 -1
- package/dist/public/assets/WorkbenchShellRoute-DT3VMjWD.css +0 -1
- package/dist/public/assets/WorkspaceDebugDetailPage-CVivdPx5.js +0 -1
- package/dist/public/assets/WorkspaceDetailPage-DgOSjscR.js +0 -1
- package/dist/public/assets/WorkspaceHomePage-HPa7M_Vh.js +0 -1
- package/dist/public/assets/index-BxJPQpFM.css +0 -1
- package/dist/public/assets/index-CeXGOT_T.js +0 -50
- package/dist/public/assets/useRegisteredDebugTemplates-Bol3NVfN.js +0 -1
- package/dist/public/assets/workbench-navigation-B7IjRQd8.js +0 -1
package/dist/public/assets/{AdaptiveButlerPage-B17QiMyT.js → AdaptiveButlerPage-khJQh6a_.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as t,t as l,b as u}from"./index-CeXGOT_T.js";import{r as $s,f as Kn,b6 as Hs,a0 as Bs,b7 as Hl,b8 as N,b9 as fn,aO as Bl,ba as _s,a4 as _l,a5 as Vl,bb as Vs,bc as zs,bd as gn,be as xn,bf as zl,bg as Ws,ai as qs,B as vn,bh as Ks,bi as Yn,aL as Wl,aM as ql,ax as Kl,aN as Yl,s as Zl,q as Hn,bj as Xl,bk as Bn,bl as _n,bm as Gl,aZ as Ys,o as Zs,p as fl}from"./WorkbenchLayout-CikJBS62.js";import{e as Xs,c as Ql,u as Jl,f as es,h as Gs}from"./App-CFBwDUNA.js";import{a as dn,A as gl,e as Vn,B as Qs}from"./workbench-navigation-B7IjRQd8.js";import{W as rt}from"./WorkbenchModal-NGmPgqaE.js";import{s as ts}from"./butler-records-events-DgWCG364.js";import{M as Js}from"./MobileSheet-opTWyRe1.js";import{M as eo}from"./MobileWorkspaceSwitcherHeader-BZEzPeMj.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./DesktopModal-6ii53_Y9.js";import"./relay-entry-Bg0OisQy.js";import"./MobileTopHeaderFrame-BbNON3Y4.js";function ns(){return t.jsxs("section",{className:"butler-loading-panel",role:"status","aria-live":"polite",children:[t.jsxs("div",{className:"butler-loading-orb","aria-hidden":"true",children:[t.jsx("span",{className:"butler-loading-ring butler-loading-ring-primary"}),t.jsx("span",{className:"butler-loading-ring butler-loading-ring-secondary"}),t.jsx("span",{className:"butler-loading-core"})]}),t.jsxs("div",{className:"butler-loading-copy",children:[t.jsx("h1",{children:l("shell.butlerLoadingTitle")}),t.jsx("p",{children:l("shell.butlerLoadingDescription")})]})]})}const zn={"risk-first":["risk","blocker","verification"],"blocker-first":["blocker","risk","verification"],"verification-first":["verification","risk","blocker"],"progress-first":["progress","risk","blocker"]},ls=300,to=1500,no=1500,lo=480*60*1e3,Wn=["codex","claude-code"],Fn={displayName:"",agentsMode:"inline",agentsFilePath:"",agentsContent:"",personaTone:"direct",personaLanguage:"zh-CN",personaSummaryStyle:"brief",focusRiskPreference:"conservative",reportPriorityPreset:"risk-first",summaryDebounceSeconds:ls},so=[{value:60,labelKey:"shell.butlerSummaryDebounceOption1Minute"},{value:180,labelKey:"shell.butlerSummaryDebounceOption3Minutes"},{value:300,labelKey:"shell.butlerSummaryDebounceOption5Minutes"},{value:600,labelKey:"shell.butlerSummaryDebounceOption10Minutes"},{value:900,labelKey:"shell.butlerSummaryDebounceOption15Minutes"},{value:1800,labelKey:"shell.butlerSummaryDebounceOption30Minutes"}],Ae={builder:["🧠","🤖","🦾","🛠️","⚙️","🧩","🚀","🛰️","🔧","💡"],analyst:["🦉","🧭","🔍","📚","🧪","📐","🗂️","📝","🧮","📊"],direct:["🦅","🛡️","⚡","🎯","🪓","🧱","🔨","📌","🧰","🏹"],steady:["🐢","🐘","🦬","🦫","🌲","⛰️","🪨","🧺","🧷","🕰️"],friendly:["🐼","🦊","🐻","🐶","🐱","🐹","🐰","🦄","🌼","🍀"],default:["🧠","🤖","🦉","🧩","📚","💡","🛠️","🚀","🌟","🪄","🧭","🔮"]};function oo(e){if(typeof document>"u")return!1;const n=document.createElement("textarea");n.value=e,n.setAttribute("readonly","true"),n.style.position="fixed",n.style.opacity="0",n.style.pointerEvents="none",document.body.appendChild(n),n.focus(),n.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(n)}}async function io(e){var n;if(typeof navigator<"u"&&((n=navigator.clipboard)!=null&&n.writeText))try{await navigator.clipboard.writeText(e);return}catch{}if(!oo(e))throw new Error(l("conversation.copyContentFailed"))}function ro(){var il,rl,al,ul,cl,dl,ml,bl,hl;const e=Xs(),n=$s(e),{workspaceId:s=""}=Ql(),o=Jl(),{showToast:i}=es(),{navigationGroups:d,requestNavigationRefresh:c,setAuxiliaryPanel:f}=Kn(),h=u.useRef(null),j=u.useRef(null),[y,L]=u.useState(Hs),[$,D]=u.useState(!1),[k,_]=u.useState(Fn),[J,ee]=u.useState(!1),[te,Y]=u.useState(0),[U,re]=u.useState([]),[H,Ee]=u.useState([]),[nl,Ce]=u.useState([]),[Rt,ce]=u.useState([]),[ze,Te]=u.useState([]),[ne,O]=u.useState([]),[de,Ne]=u.useState([]),[Ie,We]=u.useState(!1),[kt,qe]=u.useState(!1),[Lt,Et]=u.useState(!1),[Ke,Mt]=u.useState(!1),[me,Ye]=u.useState(null),[Re,le]=u.useState(null),[Ze,he]=u.useState(null),[Ft,p]=u.useState(null),[M,Pt]=u.useState(!1),[R,at]=u.useState(""),[fe,Z]=u.useState(null),[ae,w]=u.useState(null),[Sn,ut]=u.useState(null),[ye,ct]=u.useState(null),[jn,ke]=u.useState(!1),[Dt,Xe]=u.useState(null),[dt,Ge]=u.useState(null),[mt,bt]=u.useState(null),[Qe,Je]=u.useState(null),[ht,z]=u.useState(null),[ft,gt]=u.useState(null),[et,tt]=u.useState(null),[An,Ut]=u.useState(()=>Date.now()),{items:Ot}=Bs(!0),xt=u.useRef(null),$t=u.useRef(null),se=u.useRef(null),Ht=u.useId(),[Bt,nt]=u.useState({itemId:null,kind:null});(!h.current||j.current!==s)&&(h.current=new Hl(s),j.current=s);const S=h.current,ge=N(S,a=>a.loading),W=N(S,a=>a.sending),pe=N(S,a=>a.switchingProvider),ue=N(S,a=>a.initialized),C=N(S,a=>a.profile),q=N(S,a=>a.activeProvider),g=N(S,a=>a.controlSession),_t=N(S,a=>a.capabilities),F=N(S,a=>a.overview),lt=N(S,a=>a.events),Me=N(S,a=>a.messages),Fe=N(S,a=>a.historyState),wn=N(S,a=>a.loadingOlderMessages),Vt=N(S,a=>a.hasOlderMessages),Pe=N(S,a=>a.runtimeHasActiveRun),De=N(S,a=>a.runtimeCanInterrupt),Cn=N(S,a=>a.contextUsage),vt=N(S,a=>a.permissionRequests),Le=N(S,a=>a.error),zt=u.useRef(null),Wt=u.useRef(null),yt=u.useRef(!1),pt=u.useRef(new Set),Se=((il=C==null?void 0:C.displayName)==null?void 0:il.trim())||y.displayName.trim()||l("shell.butlerEntry"),St=u.useMemo(()=>ui({displayName:Se,providerId:(C==null?void 0:C.providerId)??y.providerId,tone:(C==null?void 0:C.persona.tone)??y.personaTone}),[Se,y.personaTone,y.providerId,C==null?void 0:C.persona.tone,C==null?void 0:C.providerId]),jt=u.useMemo(()=>H.filter(a=>qn(a.status)).slice(0,3),[H]),qt=u.useMemo(()=>So(g,Pe),[g,Pe]),Ue=po((g==null?void 0:g.session.sessionId)??null,qt),Tn=Ue||W,Nn=Ue||W,In=De===!0||W?!0:De??!1,Kt=u.useMemo(()=>{if(!g||Ue)return null;const a=ze.filter(T=>T.status==="active"&&T.controlSessionId===g.id).map(T=>({kind:"timer",timer:T})),m=new Set(ze.filter(T=>T.status==="active"&&T.controlSessionId===g.id).map(T=>T.id)),x=ne.filter(T=>T.status==="active"&&T.controlSessionId===g.id&&!!T.nextRunAt&&!m.has(T.id)).map(T=>({kind:"automation",automation:T}));return[...a,...x].sort((T,B)=>I(It(T))-I(It(B)))[0]??null},[ne,g,ze,Ue]),V=yo(Kt),Yt=u.useMemo(()=>((F==null?void 0:F.projects)??[]).map(a=>a.id).sort(),[F==null?void 0:F.projects]),Rn=((rl=d.find(a=>a.workspace.id===s))==null?void 0:rl.workspace.name)??null,Zt=u.useMemo(()=>new Map(((F==null?void 0:F.projects)??[]).map(a=>[a.id,a.name])),[F==null?void 0:F.projects]),Xt=u.useMemo(()=>new Map(d.map(a=>[a.workspace.id,a.workspace.name])),[d]),At=u.useMemo(()=>new Map(d.flatMap(a=>a.sessions.map(m=>{var x;return[m.sessionId,((x=m.title)==null?void 0:x.trim())||l("common.unknown")]}))),[d]),P=u.useMemo(()=>me?ne.find(a=>a.id===me)??null:null,[ne,me]),Gt=u.useMemo(()=>me?de.filter(a=>a.automationId===me).sort((a,m)=>I(m.createdAt)-I(a.createdAt)).slice(0,8):[],[de,me]);u.useEffect(()=>{me&&!P&&(Ye(null),le(null))},[P,me]);const st=u.useMemo(()=>new Map(d.flatMap(a=>a.sessions.map(m=>[m.sessionId,a.workspace.id]))),[d]);u.useEffect(()=>{if(Ut(Date.now()),!V)return;const a=window.setInterval(()=>{Ut(Date.now())},1e3);return()=>{window.clearInterval(a)}},[V]);const Oe=u.useCallback(async()=>{if(!ue){ce([]);return}try{const a=await fn();ce(a.items)}catch(a){i({title:l("shell.butlerSidebarLoadFailed"),description:a instanceof Error?a.message:void 0,tone:"error"})}},[ue,i]),wt=u.useCallback(()=>{qe(!0)},[]),Ct=u.useCallback(()=>{Et(!0)},[]),Tt=u.useCallback(()=>{Mt(!0)},[]),Qt=u.useCallback(()=>{M||Oe(),Pt(a=>!a)},[M,Oe]),be=u.useCallback(()=>{Pt(!1),at("")},[]),r=u.useCallback(async()=>{if(!(!fe||ae)){w(fe.id);try{await Bl(fe.session.sessionId),fe.id===(g==null?void 0:g.id)&&await S.openControlSession(""),be(),Z(null),await Oe(),c(),i({title:l("shell.deleteSessionSuccess"),tone:"success"})}catch(a){i({title:a instanceof Error?a.message:l("shell.deleteSessionFailed"),tone:"error"})}finally{w(null)}}},[g==null?void 0:g.id,fe,ae,be,Oe,c,i,S]);u.useEffect(()=>{if(!M){at("");return}const a=window.requestAnimationFrame(()=>{var m,x;(m=se.current)==null||m.focus(),(x=se.current)==null||x.select()});return()=>{window.cancelAnimationFrame(a)}},[M]),u.useEffect(()=>{if(!M)return;const a=x=>{var B,He;const T=x.target;(B=xt.current)!=null&&B.contains(T)||(He=$t.current)!=null&&He.contains(T)||be()},m=x=>{x.key==="Escape"&&(x.preventDefault(),be())};return document.addEventListener("pointerdown",a),document.addEventListener("keydown",m),()=>{document.removeEventListener("pointerdown",a),document.removeEventListener("keydown",m)}},[M,be]);const b=u.useCallback(a=>{_(m=>({...m,...a}))},[]),v=u.useCallback(async a=>{qe(!1),ut(a),ct(null),Xe(null),ke(!0);try{const m=await _s(a);ct(m.task)}catch(m){Xe(m instanceof Error?m.message:l("shell.butlerAutomationRoundLoadFailed"))}finally{ke(!1)}},[]),A=u.useCallback(async a=>{Ge(a.id);try{const m=await _l(a.id);Ee(x=>yl(x,m.task)),i({title:l("conversation.butlerFollowUpStopped"),description:l("conversation.butlerFollowUpStoppedDescription"),tone:"success"}),await S.reloadEventsAndOverview(),c()}catch(m){i({title:l("conversation.butlerFollowUpStopFailed"),description:m instanceof Error?m.message:void 0,tone:"error"})}finally{Ge(null)}},[c,i,S]),K=u.useCallback(async a=>{bt(a.id);try{await Vl(a.projectId,a.id),i({title:l("conversation.butlerVerificationStopped"),description:l("conversation.butlerVerificationStoppedDescription"),tone:"success"}),await S.reloadEventsAndOverview(),c()}catch(m){i({title:l("conversation.butlerVerificationStopFailed"),description:m instanceof Error?m.message:void 0,tone:"error"})}finally{bt(null)}},[c,i,S]),je=u.useCallback(async a=>{nt({itemId:a.id,kind:"analyze"});try{const m=await Vs(a.id);re(x=>vl(x,m.item)),ce(x=>Uo(x,m.controlSession)),await S.adoptControlSession(m.controlSession),i({title:l("shell.butlerTodoAnalyzeQueued"),tone:"success"})}catch(m){i({title:l("shell.butlerTodoAnalyzeFailed"),description:m instanceof Error?m.message:void 0,tone:"error"})}finally{nt({itemId:null,kind:null})}},[i]),X=u.useCallback(async a=>{nt({itemId:a.id,kind:"start"});try{const m=await zs(a.id);re(x=>vl(x,m.item)),m.followUpTask&&Ee(x=>yl(x,m.followUpTask)),c(),i({title:l("shell.butlerTodoStartSessionSucceeded"),tone:"success"}),o(dn(m.item.workspaceId,m.session.sessionId))}catch(m){i({title:l("shell.butlerTodoStartSessionFailed"),description:m instanceof Error?m.message:void 0,tone:"error"})}finally{nt({itemId:null,kind:null})}},[o,c,i]),xe=u.useCallback(a=>{var x;const m=(x=a.assistantState.linkedSessionId)==null?void 0:x.trim();m&&o(dn(a.workspaceId,m))},[o]),$e=u.useCallback(async a=>{var x;const m=(x=a.assistantState.generatedPrompt)==null?void 0:x.trim();if(m)try{await io(m),i({title:l("shell.butlerTodoCopyPromptSucceeded"),tone:"success"})}catch(T){i({title:T instanceof Error?T.message:l("conversation.copyContentFailed"),tone:"error"})}},[i]),G=u.useCallback(async a=>{gt(a);try{const m=await gn(a);Te(x=>pl(x,m.timer)),i({title:l("shell.butlerControlTimerCancelSucceeded"),tone:"success"})}catch(m){i({title:l("shell.butlerControlTimerCancelFailed"),description:m instanceof Error?m.message:void 0,tone:"error"})}finally{gt(null)}},[i]),ot=u.useCallback(async a=>{Je(a);try{const m=await xn(a);O(x=>rn(x,m.payload.automation)),i({title:l("shell.butlerControlTimerCancelSucceeded"),tone:"success"})}catch(m){i({title:l("shell.butlerControlTimerCancelFailed"),description:m instanceof Error?m.message:void 0,tone:"error"})}finally{Je(null)}},[i]),Jt=u.useCallback(a=>{const m=ne.find(x=>x.id===a);m&&(Ye(a),le(Al(m)))},[ne]),kn=u.useCallback(async()=>{if(!P||!Re)return;let a;try{a=ai(P,Re)}catch(m){i({title:l("shell.butlerAutomationSaveFailed"),description:m instanceof Error?m.message:void 0,tone:"error"});return}he(P.id);try{const m=await zl(P.id,a);O(x=>rn(x,m.payload.automation)),Ye(m.payload.automation.id),le(Al(m.payload.automation)),i({title:l("shell.butlerAutomationSaveSucceeded"),tone:"success"})}catch(m){i({title:l("shell.butlerAutomationSaveFailed"),description:m instanceof Error?m.message:void 0,tone:"error"})}finally{he(null)}},[Re,P,i]),Ln=u.useCallback(async a=>{const m=a.content.trim();if(!m){i({title:l("shell.butlerControlTimerExecuteNowFailed"),tone:"error"});return}tt(a.id);try{const x=await gn(a.id);Te(T=>pl(T,x.timer)),await S.sendMessage(m),c(),i({title:l("shell.butlerControlTimerExecuteNowSucceeded"),tone:"success"})}catch(x){i({title:l("shell.butlerControlTimerExecuteNowFailed"),description:x instanceof Error?x.message:void 0,tone:"error"})}finally{tt(null)}},[c,i,S]),en=u.useCallback(async a=>{z(a);try{const m=await Ws(a);O(x=>rn(x,m.payload.automation)),i({title:l("shell.butlerControlTimerCancelSucceeded"),tone:"success"})}catch(m){i({title:l("shell.butlerControlTimerCancelFailed"),description:m instanceof Error?m.message:void 0,tone:"error"})}finally{z(null)}},[i]),En=u.useCallback(async a=>{if(a.kind==="timer"){await G(a.timer.id);return}await ot(a.automation.id)},[ot,G]),oe=u.useCallback(async a=>{if(a.kind==="timer"){await G(a.timer.id);return}await en(a.automation.id)},[G,en]),Rs=u.useCallback(async a=>{if(a.kind==="timer"){await Ln(a.timer);return}if(a.automation.triggerType!=="once")return;const m=a.automation.actionConfig.content.trim();if(!m){i({title:l("shell.butlerControlTimerExecuteNowFailed"),tone:"error"});return}tt(a.automation.id);try{await xn(a.automation.id),O(x=>rn(x,{...a.automation,status:"cancelled",nextRunAt:null,cancelledAt:new Date().toISOString(),updatedAt:new Date().toISOString()})),await S.sendMessage(m),c(),i({title:l("shell.butlerControlTimerExecuteNowSucceeded"),tone:"success"})}catch(x){i({title:l("shell.butlerControlTimerExecuteNowFailed"),description:x instanceof Error?x.message:void 0,tone:"error"})}finally{tt(null)}},[c,i,S]),ks=u.useCallback(a=>{const m=yn(a),x=(m?st.get(m):null)||Zn(a)||s;!m||!x||o(dn(x,m))},[o,st,s]),ll=u.useCallback(async()=>{if(C){if(!k.displayName.trim()){i({title:l("shell.butlerInitNameRequired"),tone:"warning"});return}ee(!0);try{await S.updateProfile({displayName:k.displayName.trim(),agentsMode:k.agentsMode,agentsFilePath:k.agentsMode==="file"?k.agentsFilePath:null,agentsContent:k.agentsContent,persona:{tone:k.personaTone,language:k.personaLanguage,summaryStyle:k.personaSummaryStyle},focus:{...C.focus,riskPreference:k.focusRiskPreference,reportPriority:zn[k.reportPriorityPreset],summaryDebounceSeconds:k.summaryDebounceSeconds}}),i({title:l("shell.butlerSettingsSaved"),tone:"success"})}catch(a){i({title:l("shell.butlerSettingsSaveFailed"),description:a instanceof Error?a.message:void 0,tone:"error"})}finally{ee(!1)}}},[C,k,i,S]);u.useEffect(()=>{S.initialize()},[S]),u.useEffect(()=>{var m,x;const a=JSON.stringify({workspaceId:s,activeProvider:q,controlSessionId:(g==null?void 0:g.id)??null,sessionId:((m=g==null?void 0:g.session)==null?void 0:m.sessionId)??null,messages:Me.length,historyState:Fe,runtimeHasActiveRun:Pe,runtimeCanInterrupt:De,loading:ge,sending:W,switchingProvider:pe,error:Le});zt.current!==a&&(zt.current=a,qs("butler.page.timeline_state",{workspaceId:s,activeProvider:q,controlSessionId:(g==null?void 0:g.id)??null,sessionId:((x=g==null?void 0:g.session)==null?void 0:x.sessionId)??null,messages:Me.length,historyState:Fe,runtimeHasActiveRun:Pe,runtimeCanInterrupt:De,loading:ge,sending:W,switchingProvider:pe,error:Le??null}))},[s,q,g==null?void 0:g.id,(al=g==null?void 0:g.session)==null?void 0:al.sessionId,Me.length,Fe,Pe,De,ge,W,pe,Le]),u.useEffect(()=>{Le&&i({title:l("shell.butlerLoadFailed"),description:Le,tone:"error"})},[Le,i]),u.useEffect(()=>{var T;const a=((T=g==null?void 0:g.session)==null?void 0:T.sessionId)??null;if(Wt.current!==a&&(Wt.current=a,yt.current=!1,pt.current=new Set),!a)return;const m=vt.filter(B=>B.status==="pending"),x=new Set(m.map(B=>B.id));yt.current&&m.forEach(B=>{var He,nn,ln;pt.current.has(B.id)||i({id:`butler-permission-request-${B.id}`,title:l("conversation.permissionRequestToastTitle"),description:l("conversation.backgroundPermissionToastDescription",{title:((He=g==null?void 0:g.title)==null?void 0:He.trim())||((ln=(nn=g==null?void 0:g.session)==null?void 0:nn.title)==null?void 0:ln.trim())||Se,requestTitle:B.title}),tone:"warning",durationMs:8e3})}),pt.current=x,yt.current=!0},[Se,(ul=g==null?void 0:g.session)==null?void 0:ul.sessionId,(cl=g==null?void 0:g.session)==null?void 0:cl.title,g==null?void 0:g.title,vt,i]),u.useEffect(()=>{if(!C){_(Fn);return}_({displayName:C.displayName,agentsMode:C.agentsMode,agentsFilePath:li(C),agentsContent:C.agentsContent,personaTone:C.persona.tone,personaLanguage:C.persona.language,personaSummaryStyle:C.persona.summaryStyle,focusRiskPreference:C.focus.riskPreference,reportPriorityPreset:ni(C.focus.reportPriority),summaryDebounceSeconds:C.focus.summaryDebounceSeconds??Fn.summaryDebounceSeconds})},[C]),u.useEffect(()=>{if(!ue){re([]),Ee([]),Ce([]),ce([]),Te([]),O([]),Ne([]);return}let a=!1;async function m(){try{const[B,He,nn,ln,Ds,Us,Os]=await Promise.all([Zl(),Hn(),fn(),Xl(),Bn({limit:100}),_n({limit:100}),Promise.all(Yt.map(Mn=>Gl(Mn)))]);a||(re(B.items),Ee(He.items),ce(nn.items),Te(ln.items),O(Ds.payload.items),Ne(Us.payload.items),Ce(Os.flatMap(Mn=>Mn.items)))}catch(B){if(a)return;re([]),Ee([]),Ce([]),ce([]),Te([]),O([]),Ne([]),i({title:l("shell.butlerSidebarLoadFailed"),description:B instanceof Error?B.message:void 0,tone:"error"})}}m();function x(){m()}const T=window.setInterval(()=>{m()},15e3);return window.addEventListener(vn,x),()=>{a=!0,window.clearInterval(T),window.removeEventListener(vn,x)}},[ue,Yt,i]),u.useEffect(()=>ts(()=>{S.reloadEventsAndOverview()}),[S]);const it=u.useMemo(()=>di(Ot,[y.providerId,(C==null?void 0:C.providerId)??null,q]),[q,y.providerId,C==null?void 0:C.providerId,Ot]),tn=u.useMemo(()=>it.filter(a=>a.enabled),[it]),Ls=((dl=it.find(a=>a.value===q))==null?void 0:dl.enabled)??!0,Es=it.some(a=>a.enabled&&a.value!==q);u.useEffect(()=>{ue||tn.length===0||tn.some(a=>a.value===y.providerId)||L(a=>{var m;return{...a,providerId:((m=tn[0])==null?void 0:m.value)??a.providerId}})},[tn,y.providerId,ue]),u.useMemo(()=>[{value:"inline",label:l("shell.butlerAgentsModeInline")},{value:"file",label:l("shell.butlerAgentsModeFile")}],[]),u.useMemo(()=>[{value:"direct",label:l("shell.butlerToneDirect")},{value:"steady",label:l("shell.butlerToneSteady")},{value:"friendly",label:l("shell.butlerToneFriendly")}],[]),u.useMemo(()=>[{value:"zh-CN",label:l("shell.butlerLanguageZhCn")},{value:"en-US",label:l("shell.butlerLanguageEnUs")},{value:"bilingual",label:l("shell.butlerLanguageBilingual")}],[]),u.useMemo(()=>[{value:"brief",label:l("shell.butlerSummaryBrief")},{value:"structured",label:l("shell.butlerSummaryStructured")},{value:"thorough",label:l("shell.butlerSummaryThorough")}],[]),u.useMemo(()=>[{value:"conservative",label:l("shell.butlerRiskConservative")},{value:"balanced",label:l("shell.butlerRiskBalanced")},{value:"proactive",label:l("shell.butlerRiskProactive")}],[]),u.useMemo(()=>[{value:"risk-first",label:l("shell.butlerReportRiskFirst")},{value:"blocker-first",label:l("shell.butlerReportBlockerFirst")},{value:"verification-first",label:l("shell.butlerReportVerificationFirst")},{value:"progress-first",label:l("shell.butlerReportProgressFirst")}],[]);const sl=u.useMemo(()=>t.jsx(ao,{overview:F,events:lt,inboxItems:U,followUpTasks:H,assistantAutomations:ne,assistantAutomationRuns:de,cancellingFollowUpTaskId:dt,cancellingVerificationId:mt,cancellingAutomationId:Qe,controlSession:g,settingsForm:k,savingSettings:J,onOpenFollowUpHistory:wt,onOpenVerificationHistory:Ct,onOpenAutomationHistory:Tt,onOpenAutomationDetail:Jt,onOpenFollowUpDetail:v,onCancelFollowUpTask:A,onCancelVerificationRun:K,onCancelAutomation:ot,onAnalyzeTodo:je,onStartTodoSession:X,onOpenTodoSession:xe,onCopyTodoPrompt:$e,todoActionState:Bt,onSettingsFormChange:b,onSaveSettings:()=>{ll()}}),[lt,je,ot,$e,Tt,Jt,wt,Ct,H,v,xe,ll,b,X,ne,de,U,Qe,dt,mt,g,F,A,K,J,k,Bt]);u.useEffect(()=>{if(!ue){f(null);return}return f(sl),()=>{f(null)}},[ue,f,sl]);async function Ms(a){a.preventDefault();const m=y.displayName.trim();if(!m){i({title:l("shell.butlerInitNameRequired"),tone:"warning"});return}const x={displayName:m,providerId:y.providerId,agentsMode:y.agentsMode,persona:{tone:y.personaTone,language:y.personaLanguage,summaryStyle:y.personaSummaryStyle},focus:{projectIds:[],riskPreference:y.focusRiskPreference,reportPriority:zn[y.reportPriorityPreset],summaryDebounceSeconds:ls}};D(!0);try{await S.initializeProfile(x),i({title:l("shell.butlerInitSuccess"),tone:"success"})}catch(T){i({title:l("shell.butlerInitFailed"),description:T instanceof Error?T.message:void 0,tone:"error"})}finally{D(!1)}}async function Fs(a){if(a!==q)try{await S.switchProvider(a),ol(a),i({title:l("shell.butlerProviderSwitched"),description:l("shell.butlerProviderSwitchedDescription",{provider:bi(it,a)}),tone:"success"})}catch(m){i({title:l("shell.butlerProviderSwitchFailed"),description:m instanceof Error?m.message:void 0,tone:"error"})}}async function Ps(){try{ol(q),await S.startFreshSession(),i({title:l("shell.butlerNewSessionStarted"),tone:"success"})}catch(a){i({title:l("shell.butlerNewSessionFailed"),description:a instanceof Error?a.message:void 0,tone:"error"})}}function ol(a){Y(m=>m+1),o(Vn(s),{replace:!0}),a&&c()}return ge&&!ue&&!$?t.jsx("main",{className:"workbench-page butler-page-shell butler-loading-shell",children:t.jsx(ns,{})}):ue?t.jsxs(t.Fragment,{children:[t.jsxs("main",{className:"workbench-page conversation-page-shell butler-page-shell butler-chat-workspace",children:[t.jsxs("header",{className:"workbench-auxiliary-header butler-main-header","data-window-drag-handle":"conversation-header","data-tauri-drag-region":n,children:[t.jsx("div",{className:"butler-header-main","data-tauri-drag-region":n,children:t.jsxs("div",{className:"butler-header-analysis-anchor",onMouseEnter:()=>{We(!0)},onMouseLeave:()=>{We(!1)},children:[t.jsx("div",{className:"butler-chat-avatar","aria-hidden":"true",children:t.jsx("span",{children:St})}),t.jsx("div",{className:"butler-main-heading",children:t.jsx("h1",{tabIndex:0,"data-tauri-drag-region":n,onFocus:()=>{We(!0)},onBlur:()=>{We(!1)},children:Se})}),Ie?t.jsxs("div",{className:"butler-header-analysis-popover",role:"status","aria-live":"polite",children:[t.jsx("strong",{children:l("conversation.butlerAnalysisTitle")}),jt.length>0?jt.map(a=>t.jsxs("div",{className:"butler-header-analysis-item",children:[t.jsxs("p",{children:[l("conversation.butlerAnalysisObjectiveLabel"),":",a.objective]}),t.jsxs("p",{children:[l("conversation.butlerAnalysisStatusLabel"),":",Xn(a.status)]}),t.jsxs("p",{children:[l("conversation.butlerAnalysisSummaryLabel"),":",a.lastAutomationSummary||a.waitingReason||l("conversation.butlerAnalysisEmpty")]})]},a.id)):t.jsx("p",{children:l("conversation.butlerAnalysisEmpty")})]}):null]})}),t.jsxs("div",{className:"butler-toolbar-cluster",children:[t.jsx("div",{className:"butler-provider-switcher",children:t.jsx("select",{"aria-label":l("shell.butlerProviderLabel"),value:q,disabled:!Es||pe||W,onChange:a=>{Fs(a.target.value)},children:it.map(a=>t.jsx("option",{value:a.value,disabled:!a.enabled,children:a.label},a.value))})}),t.jsx("button",{type:"button",className:"terminal-tab-control butler-header-icon-button","aria-label":l("shell.butlerNewSessionAction"),title:l("shell.butlerNewSessionAction"),disabled:ge||W||pe||!Ls,onClick:()=>{Ps()},children:t.jsx("span",{className:"terminal-toolbar-icon","aria-hidden":"true",children:t.jsx(hi,{})})}),t.jsxs("div",{className:"butler-session-history-anchor",ref:xt,children:[t.jsx("button",{type:"button",className:"terminal-tab-control butler-header-icon-button","aria-label":l("shell.butlerHistoryAction"),"aria-haspopup":"dialog","aria-expanded":M,"aria-controls":M?"butler-control-history-popover":void 0,title:l("shell.butlerHistoryAction"),disabled:ge||W||pe,onClick:()=>{Qt()},children:t.jsx("span",{className:"terminal-toolbar-icon butler-history-toolbar-icon","aria-hidden":"true",children:t.jsx(fi,{})})}),t.jsx(Yn,{open:M,id:"butler-control-history-popover",className:"butler-session-history-popover",anchorRef:xt,popoverRef:$t,labelledBy:Ht,maxWidth:420,gap:10,viewportPadding:14,children:t.jsx(bo,{sessions:Rt,activeControlSessionId:(g==null?void 0:g.id)??null,labelId:Ht,query:R,searchInputRef:se,onQueryChange:at,deletingSessionId:ae,onSelectSession:async a=>{if(a.id===(g==null?void 0:g.id)){be();return}await S.openControlSession(a.id),be()},onDeleteSession:a=>{be(),Z(a)}})})]})]})]}),t.jsx("section",{className:"butler-main-column",children:t.jsxs("div",{className:"butler-conversation-shell",children:[t.jsx(Wl,{requests:vt,replyingRequestId:Ft,onReply:async(a,m)=>{p(a);try{await S.replyPermissionRequest(a,m)}catch(x){i({title:l("conversation.permissionRequestReplyFailed"),description:x instanceof Error?x.message:void 0,tone:"error"})}finally{p(null)}}}),t.jsx(ql,{sessionId:(ml=g==null?void 0:g.session)==null?void 0:ml.sessionId,items:Kl({messages:Me}),historyState:Fe,loadingOlderMessages:wn,hasOlderMessages:Vt,provider:q,assistantAvatar:t.jsx("span",{className:"butler-message-avatar","aria-hidden":"true",children:St}),onLoadOlderMessages:()=>{S.loadOlderMessages()},onRetryMessage:a=>{const m=Me.find(x=>x.clientRequestId===a);if(m!=null&&m.content.trim()){S.sendMessage(m.content);return}S.retryMessage(a)}}),V?t.jsx(vo,{schedule:V,currentWorkspaceId:s,currentWorkspaceName:Rn,projectNameById:Zt,workspaceNameById:Xt,sessionTitleById:At,sessionWorkspaceIdById:st,countdownNow:An,cancelling:V.kind==="timer"?ft===V.timer.id:Qe===V.automation.id,skippingWait:V.kind==="automation"&&ht===V.automation.id,executingNow:et===No(V),onCancel:()=>{En(V)},onSkipWait:()=>{oe(V)},onExecuteNow:()=>{Rs(V)},onOpenSession:()=>{ks(V)}}):null,t.jsx("div",{className:"butler-composer-shell",children:t.jsx(Yl,{capabilities:_t,draftStorageId:`butler:${q}:${te}`,placeholder:l("shell.butlerComposerPlaceholder",{displayName:Se}),hasActiveRun:Tn,canInterrupt:In,contextUsage:Cn,isSubmitting:W||pe,isRunning:Nn,onInterrupt:async()=>{await S.interrupt(),c()},onSend:async(a,m)=>{var x;(((x=m==null?void 0:m.attachments)==null?void 0:x.length)??0)>0&&i({title:l("shell.butlerAttachmentUnsupported"),tone:"warning"}),await S.sendMessage(a,{model:(m==null?void 0:m.model)??null,reasoningLevel:(m==null?void 0:m.reasoningLevel)??null,permissionMode:null}),c()}})})]},`timeline:${q}:${te}`)})]}),t.jsxs(rt,{open:fe!==null,title:l("shell.deleteSessionConfirmTitle"),description:l("shell.deleteSessionConfirmDescription"),onClose:()=>{ae||Z(null)},children:[t.jsx("p",{className:"workbench-section-empty",children:fe?os(fe):""}),t.jsxs("div",{className:"workbench-modal-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:!!ae,onClick:()=>Z(null),children:l("common.cancel")}),t.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:!!ae,onClick:()=>{r()},children:ae?l("common.loading"):l("shell.deleteSessionAction")})]})]}),t.jsx(rt,{open:kt,title:l("shell.butlerFollowUpHistoryTitle"),description:l("shell.butlerFollowUpHistoryDescription"),onClose:()=>{qe(!1)},children:t.jsx(xo,{tasks:H.filter(a=>!qn(a.status)),cancellingTaskId:dt,onOpenFollowUpDetail:v,onCancelFollowUpTask:A,onClose:()=>{qe(!1)}})}),t.jsx(rt,{open:Lt,title:l("shell.butlerVerificationHistoryTitle"),description:l("shell.butlerVerificationHistoryDescription"),onClose:()=>{Et(!1)},children:t.jsx(Po,{items:us((F==null?void 0:F.verifications)??[],"history"),cancellingVerificationId:mt,onCancelVerificationRun:K})}),t.jsx(rt,{open:Ke,title:l("shell.butlerAutomationHistoryTitle"),description:l("shell.butlerAutomationHistoryDescription"),onClose:()=>{Mt(!1)},children:t.jsx(Do,{taskItems:rs(ne,F,"history"),runItems:as(ne,de,F,"history")})}),t.jsx(rt,{open:P!==null,title:l("shell.butlerAutomationDetailTitle"),description:((bl=P==null?void 0:P.title)==null?void 0:bl.trim())||(P==null?void 0:P.actionConfig.content.trim())||l("shell.butlerAutomationDetailDescription"),className:"butler-automation-detail-modal",onClose:()=>{Ye(null),le(null),he(null)},children:P&&Re?t.jsx(wo,{automation:P,editorState:Re,saving:Ze===P.id,projectName:Gn(P,Zt),targetSessionTitle:ri(P,At),recentRuns:Gt,onEditorChange:a=>{le(m=>m&&{...m,...a})},onSave:()=>{kn()}}):null}),t.jsx(rt,{open:Sn!==null,title:l("shell.butlerAutomationRoundDetailsTitle"),description:((hl=ye==null?void 0:ye.sessionTitle)==null?void 0:hl.trim())||(ye==null?void 0:ye.projectName)||l("shell.butlerAutomationRoundDetailsDescription"),onClose:()=>{ut(null),ct(null),Xe(null),ke(!1)},children:t.jsx(Fo,{task:ye,loading:jn,error:Dt})})]}):t.jsx("main",{className:"workbench-page butler-page-shell butler-init-shell",children:t.jsx(Ks,{form:y,onChange:L,submitting:ge||$,submitLabel:ge||$?l("shell.butlerInitSubmitting"):l("shell.butlerInitSubmit"),previewName:Se,previewAvatar:St,onSubmit:Ms})})}function ao(e){const[n,s]=u.useState("info"),o=[{id:"info",label:l("shell.butlerSidebarInfoTab")},{id:"automation",label:l("shell.butlerSidebarAutomationTab")},{id:"settings",label:l("shell.butlerSidebarSettingsTab")}],i=n==="info"?t.jsx(uo,{overview:e.overview,inboxItems:e.inboxItems,followUpTasks:e.followUpTasks,cancellingFollowUpTaskId:e.cancellingFollowUpTaskId,cancellingVerificationId:e.cancellingVerificationId,onOpenFollowUpHistory:e.onOpenFollowUpHistory,onOpenVerificationHistory:e.onOpenVerificationHistory,onOpenFollowUpDetail:e.onOpenFollowUpDetail,onCancelFollowUpTask:e.onCancelFollowUpTask,onCancelVerificationRun:e.onCancelVerificationRun,onAnalyzeTodo:e.onAnalyzeTodo,onStartTodoSession:e.onStartTodoSession,onOpenTodoSession:e.onOpenTodoSession,onCopyTodoPrompt:e.onCopyTodoPrompt,todoActionState:e.todoActionState}):n==="automation"?t.jsx(co,{overview:e.overview,automations:e.assistantAutomations,runs:e.assistantAutomationRuns,cancellingAutomationId:e.cancellingAutomationId,onOpenAutomationHistory:e.onOpenAutomationHistory,onOpenAutomationDetail:e.onOpenAutomationDetail,onCancelAutomation:e.onCancelAutomation}):t.jsx(To,{settingsForm:e.settingsForm,savingSettings:e.savingSettings,onSettingsFormChange:e.onSettingsFormChange,onSaveSettings:e.onSaveSettings});return t.jsxs("div",{className:"butler-side-column",children:[t.jsx("div",{className:"workbench-auxiliary-header butler-side-header",children:t.jsx("div",{className:"workbench-info-tabs butler-side-tabs",role:"tablist","aria-label":l("shell.butlerSidebarTabsLabel"),children:o.map(d=>t.jsx("button",{type:"button",role:"tab","aria-selected":n===d.id,className:n===d.id?"workbench-info-tab active":"workbench-info-tab",onClick:()=>{s(d.id)},children:d.label},d.id))})}),t.jsx("div",{className:"butler-side-content",children:i})]})}function uo(e){var i;const n=u.useMemo(()=>e.followUpTasks.filter(d=>qn(d.status)),[e.followUpTasks]),s=u.useMemo(()=>{var d;return us(((d=e.overview)==null?void 0:d.verifications)??[],"active")},[(i=e.overview)==null?void 0:i.verifications]),o=u.useMemo(()=>e.inboxItems.filter(d=>d.status!=="closed"),[e.inboxItems]);return t.jsxs(t.Fragment,{children:[t.jsx(go,{tasks:n,cancellingTaskId:e.cancellingFollowUpTaskId,onOpenFollowUpHistory:e.onOpenFollowUpHistory,onOpenFollowUpDetail:e.onOpenFollowUpDetail,onCancelFollowUpTask:e.onCancelFollowUpTask}),t.jsx(ss,{title:l("shell.butlerInfoVerificationRecordsTitle"),items:s,emptyText:l("shell.butlerInfoVerificationRecordsEmpty"),actionLabel:l("shell.butlerFollowUpHistoryAction"),onAction:e.onOpenVerificationHistory,cancellingVerificationId:e.cancellingVerificationId,onCancelVerificationRun:e.onCancelVerificationRun}),t.jsx(mo,{title:l("shell.butlerInfoTodoRecordsTitle"),items:o,emptyText:l("shell.butlerInfoTodoRecordsEmpty"),todoActionState:e.todoActionState,onAnalyzeTodo:e.onAnalyzeTodo,onStartTodoSession:e.onStartTodoSession,onOpenTodoSession:e.onOpenTodoSession,onCopyTodoPrompt:e.onCopyTodoPrompt})]})}function co(e){const n=u.useMemo(()=>rs(e.automations,e.overview,"active"),[e.automations,e.overview]),s=u.useMemo(()=>as(e.automations,e.runs,e.overview,"active"),[e.automations,e.overview,e.runs]);return t.jsxs(t.Fragment,{children:[t.jsx(jo,{items:n,cancellingAutomationId:e.cancellingAutomationId,onCancelAutomation:e.onCancelAutomation,onOpenAutomationDetail:e.onOpenAutomationDetail,emptyText:l("shell.butlerAutomationTasksEmpty"),actionLabel:l("shell.butlerFollowUpHistoryAction"),onAction:e.onOpenAutomationHistory}),t.jsx(Ao,{items:s,emptyText:l("shell.butlerAutomationRunsEmpty"),onOpenAutomationDetail:e.onOpenAutomationDetail})]})}function ss(e){return t.jsxs("section",{className:"butler-side-card",children:[t.jsxs("header",{children:[t.jsx("h2",{children:e.title}),e.actionLabel&&e.onAction?t.jsx("button",{type:"button",className:"secondary-button butler-side-header-action",onClick:e.onAction,children:e.actionLabel}):null]}),e.items.length>0?t.jsx("div",{className:"butler-record-list",children:e.items.map(n=>t.jsxs("article",{className:"butler-follow-up-status-card",children:[t.jsxs("header",{className:"butler-follow-up-status-header",children:[t.jsxs("div",{className:"butler-follow-up-status-title-group",children:[t.jsx("strong",{children:n.title}),n.subtitle?t.jsx("span",{children:n.subtitle}):null]}),n.status?t.jsx("span",{className:"butler-automation-status-badge","data-status":n.verification?Zo(n.verification.status):"active",children:n.status}):null]}),t.jsx("div",{className:"butler-follow-up-status-body",children:t.jsx("p",{children:n.content})}),n.meta||e.onCancelVerificationRun&&n.verification?t.jsxs("footer",{className:"butler-follow-up-status-footer",children:[t.jsx("span",{children:n.meta??""}),n.verification&&e.onCancelVerificationRun?t.jsx("button",{type:"button",className:"secondary-button butler-follow-up-status-action",disabled:e.cancellingVerificationId===n.verification.id||!Ko(n.verification),onClick:()=>{var s;n.verification&&((s=e.onCancelVerificationRun)==null||s.call(e,n.verification))},children:e.cancellingVerificationId===n.verification.id?l("conversation.butlerVerificationStopping"):l("conversation.butlerStopVerificationAction")}):null]}):null]},n.id))}):t.jsx("p",{className:"butler-secondary-text",children:e.emptyText})]})}function mo(e){return t.jsxs("section",{className:"butler-side-card",children:[t.jsx("header",{children:t.jsx("h2",{children:e.title})}),e.items.length>0?t.jsx("div",{className:"butler-record-list",children:e.items.map(n=>{var f,h;const s=e.todoActionState.itemId===n.id?e.todoActionState.kind:null,o=!!((f=n.assistantState.generatedPrompt)!=null&&f.trim()),i=!!((h=n.assistantState.linkedSessionId)!=null&&h.trim()),d=n.assistantState.lifecycleStage==="analyzing",c=i||o&&!d&&n.status!=="closed";return t.jsxs("article",{className:"butler-todo-card",children:[t.jsxs("header",{className:"butler-todo-card-header",children:[t.jsxs("div",{children:[t.jsx("strong",{children:n.title}),t.jsx("span",{children:n.projectName})]}),t.jsxs("div",{className:"butler-todo-card-badges",children:[t.jsx("span",{className:"butler-inline-badge",children:si(n.status)}),t.jsx("span",{className:"butler-inline-badge",children:Xo(n.assistantState.lifecycleStage)})]})]}),t.jsx("p",{children:n.content}),t.jsx("p",{className:"butler-secondary-text",children:n.assistantState.lastError||n.assistantState.analysisSummary||l("shell.butlerTodoLifecycleEmpty")}),o?t.jsx("div",{className:"butler-todo-prompt-preview",children:t.jsxs("details",{className:"butler-todo-prompt-preview-details",children:[t.jsx("summary",{children:l("shell.butlerTodoPromptPreviewAction")}),t.jsx("pre",{children:n.assistantState.generatedPrompt})]})}):null,t.jsxs("div",{className:"butler-todo-card-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:s!==null||n.status==="closed"||d,onClick:()=>{e.onAnalyzeTodo(n)},children:s==="analyze"?l("shell.butlerTodoAnalyzeRunning"):d?l("shell.butlerTodoAnalyzeRunning"):o?l("shell.butlerTodoReanalyzeAction"):l("shell.butlerTodoAnalyzeAction")}),t.jsx("button",{type:"button",className:"secondary-button",disabled:s!==null||!c,onClick:()=>{if(i){e.onOpenTodoSession(n);return}e.onStartTodoSession(n)},children:s==="start"?l("shell.butlerTodoStartSessionRunning"):i?l("shell.butlerTodoOpenSessionAction"):d?l("shell.butlerTodoWaitForPromptAction"):o?l("shell.butlerTodoStartSessionAction"):l("shell.butlerTodoAnalyzeFirstAction")}),t.jsx("button",{type:"button",className:"secondary-button",disabled:!o,onClick:()=>{e.onCopyTodoPrompt(n)},children:l("shell.butlerTodoCopyPromptAction")})]})]},n.id)})}):t.jsx("p",{className:"butler-secondary-text",children:e.emptyText})]})}function bo(e){const n=u.useDeferredValue(e.query),s=u.useMemo(()=>{const c=n.trim().toLowerCase();return e.sessions.map(f=>{const h=os(f),j=ho(f,h),y=I(f.updatedAt),L=[h,j,f.sessionId].join(`
|
|
2
|
-
`).toLowerCase();return{session:f,title:h,preview:j,updatedAtMs:y,active:y>0&&Date.now()-y<=lo,searchText:L}}).filter(f=>!c||f.searchText.includes(c)).sort((f,h)=>h.updatedAtMs-f.updatedAtMs)},[n,e.sessions]),o=s.filter(c=>c.active),i=s.filter(c=>!c.active),d=n.trim().length>0;return t.jsxs("div",{className:"butler-session-history-panel",children:[t.jsx("div",{className:"butler-session-history-header",children:t.jsxs("div",{className:"butler-card-header-copy",children:[t.jsx("strong",{id:e.labelId,children:l("shell.butlerHistoryTitle")}),t.jsx("p",{children:l("shell.butlerHistoryDescription")})]})}),t.jsxs("label",{className:"butler-session-history-search",children:[t.jsx("span",{className:"butler-session-history-search-icon","aria-hidden":"true",children:t.jsx(fo,{})}),t.jsx("input",{ref:e.searchInputRef,type:"search","aria-label":l("shell.butlerHistorySearchLabel"),placeholder:l("shell.butlerHistorySearchPlaceholder"),value:e.query,onChange:c=>{e.onQueryChange(c.target.value)}})]}),s.length===0?t.jsx("p",{className:"butler-secondary-text",children:d?l("shell.butlerHistorySearchEmpty"):l("shell.butlerHistoryEmpty")}):t.jsxs("div",{className:"butler-session-history-list",children:[o.length>0?t.jsxs("div",{className:"butler-session-history-section",children:[t.jsx("div",{className:"butler-session-history-divider",children:t.jsx("span",{children:l("shell.butlerHistoryActiveSection")})}),t.jsx(gl,{compact:!0,className:"butler-session-history-section-list",role:"list",children:o.map(c=>t.jsx(xl,{session:c.session,title:c.title,preview:c.preview,selected:c.session.id===e.activeControlSessionId,deleting:e.deletingSessionId===c.session.id,onSelectSession:e.onSelectSession,onDeleteSession:e.onDeleteSession},c.session.id))})]}):null,i.length>0?t.jsxs("div",{className:"butler-session-history-section",children:[t.jsx("div",{className:"butler-session-history-divider","data-muted":o.length>0,children:t.jsx("span",{children:l("shell.butlerHistoryInactiveSection")})}),t.jsx(gl,{compact:!0,className:"butler-session-history-section-list",role:"list",children:i.map(c=>t.jsx(xl,{session:c.session,title:c.title,preview:c.preview,selected:c.session.id===e.activeControlSessionId,deleting:e.deletingSessionId===c.session.id,onSelectSession:e.onSelectSession,onDeleteSession:e.onDeleteSession},c.session.id))})]}):null]})]})}function xl(e){return t.jsx(Qs,{as:"div",role:"listitem",className:"butler-session-history-item",selected:e.selected,tabIndex:0,style:{paddingTop:"13px",paddingRight:"0",paddingBottom:"12px",paddingLeft:"24px"},label:t.jsx("span",{className:"butler-session-history-item-title",title:e.title,children:e.title}),description:t.jsx("span",{className:"butler-session-history-item-preview",title:e.preview,children:e.preview}),trailing:t.jsxs("div",{className:"butler-session-history-item-trailing",children:[t.jsx("time",{className:"butler-session-history-item-time",dateTime:e.session.updatedAt,children:ti(e.session.updatedAt)}),t.jsx("button",{type:"button",className:"secondary-button workbench-danger-button butler-session-history-delete-button",disabled:e.deleting,"aria-label":l("shell.butlerHistoryDeleteAction"),onClick:n=>{n.stopPropagation(),e.onDeleteSession(e.session)},children:e.deleting?l("common.loading"):l("shell.deleteSessionAction")})]}),"aria-current":e.selected?"true":void 0,onClick:()=>{e.onSelectSession(e.session)},onKeyDown:n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),e.onSelectSession(e.session))}})}function os(e){var n,s,o;return((n=e.title)==null?void 0:n.trim())||((s=e.session.title)==null?void 0:s.trim())||((o=e.lastSummary)==null?void 0:o.trim())||e.sessionId}function ho(e,n){var i,d;const s=(i=e.lastSummary)==null?void 0:i.trim();if(s)return s;const o=(d=e.session.title)==null?void 0:d.trim();return o&&o!==n?o:e.sessionId}function fo(){return t.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",focusable:"false",children:t.jsx("path",{fill:"currentColor",d:"M6.75 1.75a5 5 0 1 0 3.16 8.875l3.61 3.608a.75.75 0 1 0 1.06-1.06l-3.608-3.61A5 5 0 0 0 6.75 1.75Zm-3.5 5a3.5 3.5 0 1 1 7 0 3.5 3.5 0 0 1-7 0Z"})})}function go(e){const n=u.useMemo(()=>[...e.tasks].sort((s,o)=>I(Ve(o))-I(Ve(s))).slice(0,5),[e.tasks]);return t.jsxs("section",{className:"butler-side-card",children:[t.jsxs("header",{children:[t.jsx("div",{className:"butler-card-header-copy",children:t.jsx("h2",{children:l("shell.butlerInfoFollowUpRecordsTitle")})}),t.jsx("button",{type:"button",className:"secondary-button butler-side-header-action",onClick:e.onOpenFollowUpHistory,children:l("shell.butlerFollowUpHistoryAction")})]}),n.length>0?t.jsx("div",{className:"butler-record-list",children:n.map(s=>t.jsx(is,{task:s,cancelling:e.cancellingTaskId===s.id,onOpenFollowUpDetail:e.onOpenFollowUpDetail,onCancelFollowUpTask:e.onCancelFollowUpTask},s.id))}):t.jsx("p",{className:"butler-secondary-text",children:l("shell.butlerInfoFollowUpRecordsEmpty")})]})}function xo(e){const n=u.useMemo(()=>[...e.tasks].sort((s,o)=>I(Ve(o))-I(Ve(s))),[e.tasks]);return t.jsx("div",{className:"butler-follow-up-history-panel",children:n.length>0?t.jsx("div",{className:"butler-record-list",children:n.map(s=>t.jsx(is,{task:s,cancelling:e.cancellingTaskId===s.id,onOpenFollowUpDetail:async o=>{e.onClose(),await e.onOpenFollowUpDetail(o)},onCancelFollowUpTask:e.onCancelFollowUpTask},s.id))}):t.jsx("p",{className:"butler-secondary-text",children:l("shell.butlerInfoFollowUpRecordsEmpty")})})}function is(e){var i,d,c;const{task:n}=e,s=((i=n.sessionTitle)==null?void 0:i.trim())||n.projectName,o=((d=n.waitingReason)==null?void 0:d.trim())||((c=n.lastAutomationSummary)==null?void 0:c.trim())||n.objective;return t.jsxs("article",{className:"butler-follow-up-status-card",children:[t.jsxs("header",{className:"butler-follow-up-status-header",children:[t.jsxs("div",{className:"butler-follow-up-status-title-group",children:[t.jsx("strong",{children:s}),t.jsx("span",{children:n.projectName})]}),t.jsx("span",{className:"butler-automation-status-badge","data-status":n.status,children:Xn(n.status)})]}),t.jsx("div",{className:"butler-follow-up-status-body",children:t.jsx("p",{children:o})}),t.jsxs("footer",{className:"butler-follow-up-status-footer",children:[t.jsx("span",{children:ie(Ve(n))}),t.jsxs("div",{className:"butler-inline-actions",children:[e.onCancelFollowUpTask&&qo(n)?t.jsx("button",{type:"button",className:"secondary-button butler-follow-up-status-action",disabled:e.cancelling,onClick:()=>{e.onCancelFollowUpTask(n)},children:e.cancelling?l("conversation.butlerFollowUpStopping"):l("conversation.butlerStopFollowUpAction")}):null,t.jsx("button",{type:"button",className:"secondary-button butler-follow-up-status-action",onClick:()=>{e.onOpenFollowUpDetail(n.id)},children:l("shell.butlerAutomationViewRoundsAction")})]})]})]})}function vo(e){const n=u.useId(),s=u.useId(),o=u.useRef(null),i=u.useRef(null),[d,c]=u.useState(!1),f=Lo(e.schedule,e.countdownNow),h=Ro(e.schedule,e.countdownNow),j=ko(e.schedule,e.countdownNow),y=Bo(e.schedule,e.projectNameById,e.workspaceNameById,e.currentWorkspaceId,e.currentWorkspaceName),L=Vo(e.schedule,e.sessionTitleById),$=Eo(e.schedule),D=!!(yn(e.schedule)&&(e.sessionWorkspaceIdById.has(yn(e.schedule))||Zn(e.schedule))),k=Io(e.schedule),_=Mo(e.schedule),J=k?e.executingNow?l("shell.butlerControlTimerExecutingNow"):l("shell.butlerControlTimerExecuteNowAction"):e.skippingWait?l("shell.butlerControlTimerCancelling"):l("shell.butlerControlTimerCancelAction"),ee=k?e.cancelling?l("shell.butlerControlTimerCancelling"):l("shell.butlerControlTimerStopAction"):e.cancelling?l("shell.butlerControlTimerCancelling"):l("shell.butlerControlTimerCancelOperationAction");return u.useEffect(()=>{if(!d)return;const te=U=>{var re,H;(re=o.current)!=null&&re.contains(U.target)||(H=i.current)!=null&&H.contains(U.target)||c(!1)},Y=U=>{U.key==="Escape"&&c(!1)};return document.addEventListener("pointerdown",te),document.addEventListener("keydown",Y),()=>{document.removeEventListener("pointerdown",te),document.removeEventListener("keydown",Y)}},[d]),t.jsx("section",{className:"butler-control-timer-banner","aria-live":"polite",children:t.jsxs("div",{className:"butler-control-timer-banner-shell",children:[t.jsxs("div",{className:"butler-control-timer-banner-copy",children:[t.jsxs("div",{className:"butler-control-timer-banner-status",children:[t.jsx("span",{className:"butler-control-timer-pulse","aria-hidden":"true"}),t.jsx("span",{className:"butler-control-timer-banner-caption",children:_})]}),t.jsxs("div",{className:"butler-control-timer-display-panel",children:[t.jsx("p",{className:"butler-control-timer-banner-lead",children:h}),t.jsx("p",{className:"butler-control-timer-display-clock",children:f}),t.jsx("p",{className:"butler-control-timer-banner-tail",children:j})]}),t.jsxs("div",{className:"butler-control-timer-banner-meta",children:[t.jsxs("div",{className:"butler-control-timer-banner-meta-card","data-kind":"workspace",children:[t.jsx("span",{children:l("shell.butlerControlTimerWorkspaceLabel")}),t.jsx("strong",{title:y,children:y})]}),t.jsxs("div",{className:"butler-control-timer-banner-meta-card","data-kind":"session",children:[t.jsx("span",{children:l("shell.butlerControlTimerSessionLabel")}),D?t.jsx("button",{type:"button",className:"butler-control-timer-session-link",title:L,"aria-label":`${l("shell.butlerControlTimerSessionLabel")}:${L}`,onClick:e.onOpenSession,children:L}):t.jsx("strong",{title:L,children:L})]})]})]}),t.jsxs("div",{className:"butler-control-timer-banner-actions",children:[t.jsxs("div",{className:"butler-control-timer-banner-detail",ref:o,children:[t.jsx("button",{id:n,type:"button",className:"butler-control-timer-banner-detail-button","aria-label":l("shell.butlerControlTimerDetailAction"),"aria-haspopup":"dialog","aria-expanded":d,"aria-controls":d?s:void 0,title:l("shell.butlerControlTimerDetailAction"),onClick:()=>{c(te=>!te)},children:t.jsx("span",{className:"butler-control-timer-banner-detail-icon","aria-hidden":"true",children:t.jsx(zo,{})})}),t.jsx(Yn,{open:d,id:s,className:"butler-control-timer-banner-detail-popover",anchorRef:o,popoverRef:i,labelledBy:n,children:t.jsxs("div",{children:[t.jsx("strong",{children:l("shell.butlerControlTimerPromptTitle")}),t.jsx("p",{children:$})]})})]}),t.jsx("button",{type:"button",className:"secondary-button butler-control-timer-banner-action",disabled:e.cancelling||e.executingNow||e.skippingWait,onClick:k?e.onExecuteNow:e.onSkipWait,children:J}),t.jsx("button",{type:"button",className:"secondary-button butler-control-timer-banner-action",disabled:e.cancelling||e.executingNow||e.skippingWait,onClick:e.onCancel,children:ee})]}),k?t.jsx("p",{className:"butler-control-timer-banner-note",children:l("shell.butlerControlTimerActionNote")}):null]})})}function yo(e){const[n,s]=u.useState(e),o=u.useRef(null);return u.useEffect(()=>{if(e){o.current!==null&&(window.clearTimeout(o.current),o.current=null),s(e);return}!n||o.current!==null||(o.current=window.setTimeout(()=>{o.current=null,s(null)},to))},[e,n]),u.useEffect(()=>()=>{o.current!==null&&window.clearTimeout(o.current)},[]),e??n}function po(e,n){const[s,o]=u.useState(n),i=u.useRef(null);return u.useEffect(()=>{i.current!==null&&(window.clearTimeout(i.current),i.current=null),o(n)},[e]),u.useEffect(()=>{if(n){i.current!==null&&(window.clearTimeout(i.current),i.current=null),o(!0);return}!s||i.current!==null||(i.current=window.setTimeout(()=>{i.current=null,o(!1)},no))},[n,s]),u.useEffect(()=>()=>{i.current!==null&&window.clearTimeout(i.current)},[]),s}function So(e,n){return n===!0?!0:e?e.session.activityState==="running"||e.session.runningState==="starting"||e.session.runningState==="running"||e.session.runningState==="reconnecting":!1}function jo(e){return t.jsxs("section",{className:"butler-side-card",children:[t.jsxs("header",{children:[t.jsx("h2",{children:l("shell.butlerAutomationTasksTitle")}),e.actionLabel&&e.onAction?t.jsx("button",{type:"button",className:"secondary-button butler-side-header-action",onClick:e.onAction,children:e.actionLabel}):null]}),e.items.length>0?t.jsx("div",{className:"butler-automation-overview-list",children:e.items.map(n=>t.jsxs("article",{className:"butler-automation-card butler-automation-overview-card","data-kind":"task",children:[t.jsxs("header",{className:"butler-automation-card-header",children:[t.jsxs("div",{className:"butler-automation-card-title-group",children:[t.jsx("strong",{children:n.title}),t.jsx("span",{children:n.projectName})]}),t.jsx("span",{className:"butler-automation-status-badge","data-status":n.status,children:n.statusLabel})]}),t.jsxs("div",{className:"butler-automation-overview-inline",children:[t.jsx("span",{className:"butler-automation-overview-chip",children:n.taskTypeLabel}),t.jsxs("span",{className:"butler-automation-overview-inline-meta",children:[l("shell.butlerAutomationTaskNextRunLabel")," · ",ie(n.nextRunAt)]}),t.jsxs("span",{className:"butler-automation-overview-inline-meta",children:[l("shell.butlerAutomationTaskLastRunLabel")," · ",ie(n.lastRunAt)]})]}),t.jsxs("footer",{className:"butler-automation-card-footer",children:[n.automationId?t.jsx("button",{type:"button",className:"secondary-button butler-automation-card-action",onClick:()=>{e.onOpenAutomationDetail(n.automationId)},children:l("shell.butlerAutomationOpenDetailsAction")}):null,n.automationId&&n.status==="active"?t.jsx("button",{type:"button",className:"secondary-button butler-automation-card-action",disabled:e.cancellingAutomationId===n.automationId,onClick:()=>{e.onCancelAutomation(n.automationId)},children:e.cancellingAutomationId===n.automationId?l("shell.butlerControlTimerCancelling"):l("shell.butlerControlTimerStopAction")}):null]})]},n.id))}):t.jsx("p",{className:"butler-secondary-text",children:e.emptyText})]})}function Ao(e){return t.jsxs("section",{className:"butler-side-card",children:[t.jsx("header",{children:t.jsx("h2",{children:l("shell.butlerAutomationRunsTitle")})}),e.items.length>0?t.jsx("div",{className:"butler-automation-overview-list",children:e.items.map(n=>t.jsxs("article",{className:"butler-automation-card butler-automation-overview-card","data-kind":"run",children:[t.jsxs("header",{className:"butler-automation-card-header",children:[t.jsxs("div",{className:"butler-automation-card-title-group",children:[t.jsx("strong",{children:n.title}),t.jsx("span",{children:n.projectName})]}),t.jsx("span",{className:"butler-automation-status-badge","data-status":n.status,children:n.statusLabel})]}),t.jsxs("div",{className:"butler-automation-overview-inline",children:[t.jsx("span",{className:"butler-automation-overview-chip",children:n.sourceLabel}),t.jsxs("span",{className:"butler-automation-overview-inline-meta",children:[l("shell.butlerAutomationRunProcessedAtLabel")," · ",ie(n.createdAt)]})]}),t.jsx("footer",{className:"butler-automation-card-footer",children:t.jsx("button",{type:"button",className:"secondary-button butler-automation-card-action",onClick:()=>{e.onOpenAutomationDetail(n.automationId)},children:l("shell.butlerAutomationOpenDetailsAction")})})]},n.id))}):t.jsx("p",{className:"butler-secondary-text",children:e.emptyText})]})}function wo(e){return t.jsxs("div",{className:"butler-automation-detail-shell",children:[t.jsxs("section",{className:"butler-automation-detail-summary-grid",children:[t.jsxs("div",{className:"butler-automation-detail-summary-card",children:[t.jsx("span",{children:l("shell.butlerAutomationTaskTypeLabel")}),t.jsx("strong",{children:ms(e.automation.triggerType)})]}),t.jsxs("div",{className:"butler-automation-detail-summary-card",children:[t.jsx("span",{children:l("shell.butlerAutomationStatusLabel")}),t.jsx("strong",{children:fs(e.automation.status)})]}),t.jsxs("div",{className:"butler-automation-detail-summary-card",children:[t.jsx("span",{children:l("shell.butlerAutomationTaskNextRunLabel")}),t.jsx("strong",{children:ie(e.automation.nextRunAt)})]}),t.jsxs("div",{className:"butler-automation-detail-summary-card",children:[t.jsx("span",{children:l("shell.butlerAutomationTaskLastRunLabel")}),t.jsx("strong",{children:ie(e.automation.lastRunAt||e.automation.updatedAt)})]}),t.jsxs("div",{className:"butler-automation-detail-summary-card",children:[t.jsx("span",{children:l("shell.butlerControlTimerWorkspaceLabel")}),t.jsx("strong",{children:e.projectName})]}),e.targetSessionTitle?t.jsxs("div",{className:"butler-automation-detail-summary-card",children:[t.jsx("span",{children:l("shell.butlerAutomationTargetSessionLabel")}),t.jsx("strong",{children:e.targetSessionTitle})]}):null]}),t.jsxs("section",{className:"butler-side-card butler-automation-detail-section",children:[t.jsx("header",{children:t.jsx("h2",{children:l("shell.butlerAutomationDetailTitle")})}),t.jsxs("div",{className:"butler-automation-detail-form-grid",children:[t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationTitleLabel")}),t.jsx("input",{className:"butler-form-control",value:e.editorState.title,disabled:e.saving,onChange:n=>{e.onEditorChange({title:n.target.value})}})]}),t.jsxs("label",{className:"butler-form-field butler-form-field-wide",children:[t.jsx("span",{children:l("shell.butlerAutomationPromptLabel")}),t.jsx("textarea",{className:"butler-form-control butler-automation-detail-textarea",value:e.editorState.content,disabled:e.saving,onChange:n=>{e.onEditorChange({content:n.target.value})}})]}),t.jsxs("label",{className:"butler-automation-detail-toggle",children:[t.jsx("input",{type:"checkbox",checked:e.editorState.includeTriggerContext,disabled:e.saving,onChange:n=>{e.onEditorChange({includeTriggerContext:n.target.checked})}}),t.jsx("span",{children:l("shell.butlerAutomationIncludeTriggerContextLabel")})]}),t.jsx(Co,{automation:e.automation,editorState:e.editorState,saving:e.saving,onEditorChange:e.onEditorChange})]}),t.jsx("div",{className:"butler-automation-detail-actions",children:t.jsx("button",{type:"button",className:"primary-button",disabled:e.saving,onClick:e.onSave,children:e.saving?l("shell.butlerAutomationSaving"):l("shell.butlerAutomationSaveAction")})})]}),t.jsxs("section",{className:"butler-side-card butler-automation-detail-section",children:[t.jsx("header",{children:t.jsx("h2",{children:l("shell.butlerAutomationRunsTitle")})}),e.recentRuns.length>0?t.jsx("div",{className:"butler-automation-detail-run-list",children:e.recentRuns.map(n=>{var s,o;return t.jsxs("article",{className:"butler-automation-detail-run-card",children:[t.jsxs("header",{children:[t.jsx("strong",{children:l("shell.butlerAutomationRoundLabel",{round:n.runSeq})}),t.jsx("span",{className:"butler-automation-status-badge","data-status":hs(n.status),children:gs(n.status)})]}),t.jsxs("div",{className:"butler-automation-detail-run-meta",children:[t.jsx("span",{children:bs(n.triggerType)}),t.jsx("span",{children:ie(n.finishedAt||n.startedAt||n.createdAt)})]}),t.jsx("p",{children:((s=n.summary)==null?void 0:s.trim())||((o=n.error)==null?void 0:o.trim())||l("shell.butlerAutomationRunEmptySummary")})]},n.id)})}):t.jsx("p",{className:"butler-secondary-text",children:l("shell.butlerAutomationRunsEmpty")})]})]})}function Co(e){const{triggerConfig:n}=e.automation;return n.type==="once"?t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationDueAtLabel")}),t.jsx("input",{type:"datetime-local",className:"butler-form-control",value:e.editorState.dueAt,disabled:e.saving,onChange:s=>{e.onEditorChange({dueAt:s.target.value})}})]}):n.type==="interval"?t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationEverySecondsLabel")}),t.jsx("input",{inputMode:"numeric",className:"butler-form-control",value:e.editorState.everySeconds,disabled:e.saving,onChange:s=>{e.onEditorChange({everySeconds:s.target.value})}})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationEveryMinutesLabel")}),t.jsx("input",{inputMode:"numeric",className:"butler-form-control",value:e.editorState.everyMinutes,disabled:e.saving,onChange:s=>{e.onEditorChange({everyMinutes:s.target.value})}})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationEveryHoursLabel")}),t.jsx("input",{inputMode:"numeric",className:"butler-form-control",value:e.editorState.everyHours,disabled:e.saving,onChange:s=>{e.onEditorChange({everyHours:s.target.value})}})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationStopAtLabel")}),t.jsx("input",{type:"datetime-local",className:"butler-form-control",value:e.editorState.stopAt,disabled:e.saving,onChange:s=>{e.onEditorChange({stopAt:s.target.value})}})]})]}):n.type==="cron"?t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationCronMinuteLabel")}),t.jsx("input",{inputMode:"numeric",className:"butler-form-control",value:e.editorState.cronMinute,disabled:e.saving,onChange:s=>{e.onEditorChange({cronMinute:s.target.value})}})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationCronHourLabel")}),t.jsx("input",{inputMode:"numeric",className:"butler-form-control",value:e.editorState.cronHour,disabled:e.saving,onChange:s=>{e.onEditorChange({cronHour:s.target.value})}})]}),t.jsxs("label",{className:"butler-form-field butler-form-field-wide",children:[t.jsx("span",{children:l("shell.butlerAutomationCronDaysOfWeekLabel")}),t.jsx("input",{className:"butler-form-control",value:e.editorState.cronDaysOfWeek,disabled:e.saving,onChange:s=>{e.onEditorChange({cronDaysOfWeek:s.target.value})}})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationStopAtLabel")}),t.jsx("input",{type:"datetime-local",className:"butler-form-control",value:e.editorState.stopAt,disabled:e.saving,onChange:s=>{e.onEditorChange({stopAt:s.target.value})}})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationPollIntervalLabel")}),t.jsx("input",{inputMode:"numeric",className:"butler-form-control",value:e.editorState.pollIntervalSeconds,disabled:e.saving,onChange:s=>{e.onEditorChange({pollIntervalSeconds:s.target.value})}})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationMaxChecksLabel")}),t.jsx("input",{inputMode:"numeric",className:"butler-form-control",value:e.editorState.maxChecks,disabled:e.saving,onChange:s=>{e.onEditorChange({maxChecks:s.target.value})}})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationExpiresAtLabel")}),t.jsx("input",{type:"datetime-local",className:"butler-form-control",value:e.editorState.expiresAt,disabled:e.saving,onChange:s=>{e.onEditorChange({expiresAt:s.target.value})}})]})]})}function To(e){return t.jsxs("section",{className:"butler-side-card butler-settings-panel",children:[t.jsx("header",{children:t.jsx("h2",{children:l("shell.butlerSettingsTitle")})}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerDisplayNameLabel")}),t.jsx("input",{"aria-label":l("shell.butlerDisplayNameLabel"),className:"butler-form-control",value:e.settingsForm.displayName,disabled:e.savingSettings,onChange:n=>{e.onSettingsFormChange({displayName:n.target.value})}})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAgentsModeLabel")}),t.jsxs("select",{"aria-label":l("shell.butlerAgentsModeLabel"),className:"butler-form-control",value:e.settingsForm.agentsMode,disabled:e.savingSettings,onChange:n=>{e.onSettingsFormChange({agentsMode:n.target.value})},children:[t.jsx("option",{value:"inline",children:l("shell.butlerAgentsModeInline")}),t.jsx("option",{value:"file",children:l("shell.butlerAgentsModeFile")})]}),t.jsx("small",{children:e.settingsForm.agentsMode==="file"?l("shell.butlerAgentsModeFileDescription"):l("shell.butlerAgentsModeInlineDescription")})]}),e.settingsForm.agentsMode==="file"?t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAgentsFilePathLabel")}),t.jsx("input",{"aria-label":l("shell.butlerAgentsFilePathLabel"),className:"butler-form-control butler-settings-file-path",value:e.settingsForm.agentsFilePath,readOnly:!0,disabled:e.savingSettings})]}):null,t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAgentsContentLabel")}),t.jsx("textarea",{"aria-label":l("shell.butlerAgentsContentLabel"),className:"butler-form-control butler-settings-agents-editor",rows:10,value:e.settingsForm.agentsContent,disabled:e.savingSettings,placeholder:l("shell.butlerAgentsContentPlaceholder"),onChange:n=>{e.onSettingsFormChange({agentsContent:n.target.value})}}),t.jsx("small",{children:l("shell.butlerAgentsContentHint")})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerPersonaToneLabel")}),t.jsxs("select",{"aria-label":l("shell.butlerPersonaToneLabel"),className:"butler-form-control",value:e.settingsForm.personaTone,disabled:e.savingSettings,onChange:n=>{e.onSettingsFormChange({personaTone:n.target.value})},children:[t.jsx("option",{value:"direct",children:l("shell.butlerToneDirect")}),t.jsx("option",{value:"steady",children:l("shell.butlerToneSteady")}),t.jsx("option",{value:"friendly",children:l("shell.butlerToneFriendly")})]})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerPersonaLanguageLabel")}),t.jsxs("select",{"aria-label":l("shell.butlerPersonaLanguageLabel"),className:"butler-form-control",value:e.settingsForm.personaLanguage,disabled:e.savingSettings,onChange:n=>{e.onSettingsFormChange({personaLanguage:n.target.value})},children:[t.jsx("option",{value:"zh-CN",children:l("shell.butlerLanguageZhCn")}),t.jsx("option",{value:"en-US",children:l("shell.butlerLanguageEnUs")}),t.jsx("option",{value:"bilingual",children:l("shell.butlerLanguageBilingual")})]})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerPersonaSummaryStyleLabel")}),t.jsxs("select",{"aria-label":l("shell.butlerPersonaSummaryStyleLabel"),className:"butler-form-control",value:e.settingsForm.personaSummaryStyle,disabled:e.savingSettings,onChange:n=>{e.onSettingsFormChange({personaSummaryStyle:n.target.value})},children:[t.jsx("option",{value:"brief",children:l("shell.butlerSummaryBrief")}),t.jsx("option",{value:"structured",children:l("shell.butlerSummaryStructured")}),t.jsx("option",{value:"thorough",children:l("shell.butlerSummaryThorough")})]})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerFocusRiskPreferenceLabel")}),t.jsxs("select",{"aria-label":l("shell.butlerFocusRiskPreferenceLabel"),className:"butler-form-control",value:e.settingsForm.focusRiskPreference,disabled:e.savingSettings,onChange:n=>{e.onSettingsFormChange({focusRiskPreference:n.target.value})},children:[t.jsx("option",{value:"conservative",children:l("shell.butlerRiskConservative")}),t.jsx("option",{value:"balanced",children:l("shell.butlerRiskBalanced")}),t.jsx("option",{value:"proactive",children:l("shell.butlerRiskProactive")})]})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerReportPriorityPresetLabel")}),t.jsxs("select",{"aria-label":l("shell.butlerReportPriorityPresetLabel"),className:"butler-form-control",value:e.settingsForm.reportPriorityPreset,disabled:e.savingSettings,onChange:n=>{e.onSettingsFormChange({reportPriorityPreset:n.target.value})},children:[t.jsx("option",{value:"risk-first",children:l("shell.butlerReportRiskFirst")}),t.jsx("option",{value:"blocker-first",children:l("shell.butlerReportBlockerFirst")}),t.jsx("option",{value:"verification-first",children:l("shell.butlerReportVerificationFirst")}),t.jsx("option",{value:"progress-first",children:l("shell.butlerReportProgressFirst")})]})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerSummaryDebounceLabel")}),t.jsx("select",{"aria-label":l("shell.butlerSummaryDebounceLabel"),className:"butler-form-control",value:String(e.settingsForm.summaryDebounceSeconds),disabled:e.savingSettings,onChange:n=>{e.onSettingsFormChange({summaryDebounceSeconds:Number(n.target.value)})},children:so.map(n=>t.jsx("option",{value:n.value,children:l(n.labelKey)},n.value))})]}),t.jsx("div",{className:"butler-inline-actions",children:t.jsx("button",{type:"button",className:"primary-button",disabled:e.savingSettings,onClick:e.onSaveSettings,children:e.savingSettings?l("shell.butlerSettingsSaving"):l("shell.butlerSettingsSaveAction")})})]})}function ie(e){if(!e)return"-";const n=new Date(e);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(void 0,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(n)}function Ve(e){return e.updatedAt||e.lastAutomationAt||e.lastCheckedAt||e.createdAt}function No(e){return e.kind==="timer"?e.timer.id:e.automation.id}function It(e){return e.kind==="timer"?e.timer.dueAt:e.automation.nextRunAt}function Zn(e){var n,s,o,i,d,c;return e.kind==="timer"?((o=(s=(n=e.timer.controlSession)==null?void 0:n.session)==null?void 0:s.workspaceId)==null?void 0:o.trim())||null:((c=(d=(i=e.automation.controlSession)==null?void 0:i.session)==null?void 0:d.workspaceId)==null?void 0:c.trim())||null}function yn(e){var n,s,o,i,d,c,f,h,j,y,L;return e.kind==="timer"?((n=e.timer.targetSessionId)==null?void 0:n.trim())||((i=(o=(s=e.timer.controlSession)==null?void 0:s.session)==null?void 0:o.sessionId)==null?void 0:i.trim())||((d=e.timer.sessionId)==null?void 0:d.trim())||null:((c=e.automation.actionConfig.targetSessionId)==null?void 0:c.trim())||((j=(h=(f=e.automation.controlSession)==null?void 0:f.session)==null?void 0:h.sessionId)==null?void 0:j.trim())||((L=(y=e.automation.controlSession)==null?void 0:y.sessionId)==null?void 0:L.trim())||null}function Io(e){return e.kind==="timer"||e.automation.triggerType==="once"}function Ro(e,n){const s=I(It(e));return!s||s<=n?l("shell.butlerControlTimerCountdownDueLead"):l("shell.butlerControlTimerCountdownLead")}function ko(e,n){const s=I(It(e));return!s||s<=n?l("shell.butlerControlTimerCountdownDueTail"):l("shell.butlerControlTimerCountdownTail")}function Lo(e,n){const s=I(It(e));return!s||s<=n?"00:00":Wo(s-n)}function Eo(e){return e.kind==="timer"?$o(e.timer):e.automation.actionConfig.content.trim()||l("conversation.butlerAnalysisEmpty")}function Mo(e){if(e.kind==="timer")return l("shell.butlerControlTimerTypeOnce");switch(e.automation.triggerType){case"once":return l("shell.butlerControlTimerTypeOnce");case"interval":case"cron":return l("shell.butlerControlTimerTypeRepeat");case"condition":return l("shell.butlerControlTimerTypeConditional");default:return l("shell.butlerControlTimerTypeOther")}}function rs(e,n,s="active"){const o=new Map(((n==null?void 0:n.projects)??[]).map(d=>[d.id,d.name]));return e.filter(d=>s==="history"?d.status!=="active":d.status==="active").map(d=>({id:`assistant-automation:${d.id}`,automationId:d.id,kind:"assistant_automation",title:xs(d),projectName:Gn(d,o),status:ii(d.status),taskTypeLabel:ms(d.triggerType),statusLabel:fs(d.status),nextRunAt:d.nextRunAt,lastRunAt:d.lastRunAt||d.updatedAt})).sort((d,c)=>{const f=I(d.nextRunAt),h=I(c.nextRunAt);return f!==h?f===0?1:h===0?-1:f-h:I(c.lastRunAt)-I(d.lastRunAt)}).slice(0,10)}function as(e,n,s,o="active"){const i=h=>h==="active"||h==="waiting_user",d=new Map(((s==null?void 0:s.projects)??[]).map(h=>[h.id,h.name])),c=new Map(e.map(h=>[h.id,h]));return n.map(h=>{const j=c.get(h.automationId);return{run:h,automation:j,normalizedStatus:hs(h.status)}}).filter(({automation:h})=>!!h).filter(({normalizedStatus:h})=>o==="history"?!i(h):i(h)).map(({run:h,automation:j,normalizedStatus:y})=>{var L,$;return{id:`assistant-automation-run:${h.id}`,automationId:h.automationId,kind:"assistant_automation_run",title:xs(j),projectName:Gn(j,d),status:y,sourceLabel:bs(h.triggerType),statusLabel:gs(h.status),summary:((L=h.summary)==null?void 0:L.trim())||(($=h.error)==null?void 0:$.trim())||l("shell.butlerAutomationRunEmptySummary"),createdAt:h.finishedAt||h.startedAt||h.createdAt}}).sort((h,j)=>I(j.createdAt)-I(h.createdAt)).slice(0,12)}function Fo(e){if(e.loading)return t.jsx("p",{className:"butler-secondary-text",children:l("shell.butlerAutomationRoundLoading")});if(e.error)return t.jsx("p",{className:"butler-secondary-text",children:e.error});if(!e.task)return t.jsx("p",{className:"butler-secondary-text",children:l("shell.butlerAutomationRoundEmpty")});const n=[...e.task.rounds??[]].sort((s,o)=>I(o.createdAt)-I(s.createdAt));return t.jsxs("div",{className:"butler-follow-up-rounds",children:[t.jsxs("div",{className:"butler-follow-up-round-summary",children:[t.jsx("strong",{children:e.task.objective}),t.jsx("span",{children:l("conversation.butlerCurrentFollowUpProgress",{current:e.task.autoContinueCount,max:e.task.maxAutoContinueCount??5})})]}),n.length>0?t.jsx("div",{className:"butler-follow-up-round-list",children:n.map(s=>t.jsxs("article",{className:"butler-follow-up-round-card",children:[t.jsxs("header",{className:"butler-follow-up-round-header",children:[t.jsxs("div",{children:[t.jsx("strong",{children:l("shell.butlerAutomationRoundLabel",{round:s.roundNumber})}),t.jsx("span",{children:oi(s.kind)})]}),t.jsx("span",{children:ie(s.createdAt)})]}),t.jsxs("div",{className:"butler-follow-up-round-body",children:[t.jsxs("p",{children:[l("shell.butlerAutomationRoundProcessedAtLabel"),":",ie(s.createdAt)]}),t.jsxs("p",{children:[l("shell.butlerAutomationRoundStatusLabel"),":",Xn(s.status)]}),s.observedRunningState?t.jsxs("p",{children:[l("shell.butlerAutomationRoundObservedStateLabel"),":",s.observedRunningState]}):null,t.jsxs("p",{children:[l("shell.butlerAutomationRoundSummaryLabel"),":",s.summary||l("conversation.butlerAnalysisEmpty")]}),s.waitingReason?t.jsxs("p",{children:[l("shell.butlerAutomationRoundWaitingReasonLabel"),":",s.waitingReason]}):null,s.continuePrompt?t.jsxs("p",{children:[l("shell.butlerAutomationRoundPromptLabel"),":",s.continuePrompt]}):null]})]},`${s.roundNumber}:${s.createdAt}`))}):t.jsx("p",{className:"butler-secondary-text",children:l("shell.butlerAutomationRoundEmpty")})]})}function Po(e){return e.items.length===0?t.jsx("p",{className:"butler-secondary-text",children:l("shell.butlerVerificationHistoryEmpty")}):t.jsx(ss,{title:l("shell.butlerInfoVerificationRecordsTitle"),items:e.items,emptyText:l("shell.butlerVerificationHistoryEmpty"),cancellingVerificationId:e.cancellingVerificationId,onCancelVerificationRun:e.onCancelVerificationRun})}function Do(e){return e.taskItems.length===0&&e.runItems.length===0?t.jsx("p",{className:"butler-secondary-text",children:l("shell.butlerAutomationHistoryEmpty")}):t.jsxs("div",{className:"butler-record-list",children:[e.taskItems.map(n=>t.jsxs("article",{className:"butler-automation-card",children:[t.jsxs("header",{className:"butler-automation-card-header",children:[t.jsxs("div",{className:"butler-automation-card-title-group",children:[t.jsx("strong",{children:n.title}),t.jsx("span",{children:n.projectName})]}),t.jsx("span",{className:"butler-automation-status-badge","data-status":n.status,children:n.statusLabel})]}),t.jsxs("div",{className:"butler-automation-card-body",children:[t.jsxs("div",{className:"butler-automation-row",children:[t.jsx("span",{children:l("shell.butlerAutomationTaskTypeLabel")}),t.jsx("strong",{children:n.taskTypeLabel})]}),t.jsxs("div",{className:"butler-automation-row",children:[t.jsx("span",{children:l("shell.butlerAutomationTaskLastRunLabel")}),t.jsx("strong",{children:ie(n.lastRunAt)})]})]}),t.jsxs("footer",{className:"butler-automation-card-footer",children:[t.jsx("span",{children:l("shell.butlerAutomationTaskNextRunLabel")}),t.jsx("strong",{children:ie(n.nextRunAt)})]})]},n.id)),e.runItems.map(n=>t.jsxs("article",{className:"butler-automation-card",children:[t.jsxs("header",{className:"butler-automation-card-header",children:[t.jsxs("div",{className:"butler-automation-card-title-group",children:[t.jsx("strong",{children:n.title}),t.jsx("span",{children:n.projectName})]}),t.jsx("span",{className:"butler-automation-status-badge","data-status":n.status,children:n.statusLabel})]}),t.jsxs("div",{className:"butler-automation-card-body",children:[t.jsxs("div",{className:"butler-automation-row",children:[t.jsx("span",{children:l("shell.butlerAutomationRunSourceLabel")}),t.jsx("strong",{children:n.sourceLabel})]}),t.jsxs("div",{className:"butler-automation-row",children:[t.jsx("span",{children:l("shell.butlerAutomationRunSummaryLabel")}),t.jsx("strong",{children:n.summary})]})]}),t.jsxs("footer",{className:"butler-automation-card-footer",children:[t.jsx("span",{children:l("shell.butlerAutomationRunProcessedAtLabel")}),t.jsx("strong",{children:ie(n.createdAt)})]})]},n.id))]})}function us(e,n){return[...e].filter(s=>n==="history"?!jl(s.status):jl(s.status)).sort((s,o)=>I(Pn(o))-I(Pn(s))).slice(0,5).map(s=>{var o,i;return{id:s.id,title:((o=s.targetRef)==null?void 0:o.trim())||s.verificationType,subtitle:s.verificationType,status:Yo(s.status),content:((i=s.summary)==null?void 0:i.trim())||l("shell.butlerInfoVerificationFallback",{status:s.status}),meta:ie(Pn(s)),verification:s}})}function vl(e,n){const s=e.filter(o=>o.id!==n.id);return[n,...s].sort((o,i)=>I(i.updatedAt)-I(o.updatedAt))}function yl(e,n){const s=e.filter(o=>o.id!==n.id);return[n,...s].sort((o,i)=>I(Ve(i))-I(Ve(o)))}function Uo(e,n){const s=e.filter(o=>o.id!==n.id);return[n,...s].sort((o,i)=>I(i.updatedAt)-I(o.updatedAt))}function pl(e,n){const s=e.filter(o=>o.id!==n.id);return[n,...s].sort((o,i)=>I(Sl(i))-I(Sl(o)))}function qn(e){return e==="active"||e==="waiting_user"}function Sl(e){return e.dueAt||e.triggeredAt||e.cancelledAt||e.updatedAt||e.createdAt}function Oo(e){var n,s,o,i,d,c;return((n=e.title)==null?void 0:n.trim())||((o=(s=e.controlSession)==null?void 0:s.title)==null?void 0:o.trim())||((c=(d=(i=e.controlSession)==null?void 0:i.session)==null?void 0:d.title)==null?void 0:c.trim())||e.content.trim()}function $o(e){return e.content.trim()||Oo(e)}function Ho(e,n,s,o,i){var f,h,j,y;const d=(f=e.projectId)==null?void 0:f.trim();if(d&&n.has(d))return n.get(d);const c=((y=(j=(h=e.controlSession)==null?void 0:h.session)==null?void 0:j.workspaceId)==null?void 0:y.trim())||o.trim();return c?s.has(c)?s.get(c):c===o.trim()&&(i!=null&&i.trim())?i.trim():l("shell.butlerControlTimerUnknownWorkspace"):l("shell.butlerControlTimerUnknownWorkspace")}function Bo(e,n,s,o,i){var f;if(e.kind==="timer")return Ho(e.timer,n,s,o,i);const d=(f=e.automation.projectId)==null?void 0:f.trim();if(d&&n.has(d))return n.get(d);const c=Zn(e)||o.trim();return c?s.has(c)?s.get(c):c===o.trim()&&(i!=null&&i.trim())?i.trim():l("shell.butlerControlTimerUnknownWorkspace"):l("shell.butlerControlTimerUnknownWorkspace")}function _o(e,n){var i,d,c,f,h,j,y;const s=(i=e.targetSessionId)==null?void 0:i.trim();if(s&&n.has(s))return n.get(s);if((f=(c=(d=e.controlSession)==null?void 0:d.session)==null?void 0:c.title)!=null&&f.trim())return e.controlSession.session.title.trim();const o=((y=(j=(h=e.controlSession)==null?void 0:h.session)==null?void 0:j.sessionId)==null?void 0:y.trim())||e.sessionId.trim();return o&&n.has(o)?n.get(o):l("shell.butlerControlTimerUnknownSession")}function Vo(e,n){var o,i,d;if(e.kind==="timer")return _o(e.timer,n);const s=yn(e);return s&&n.has(s)?n.get(s):(d=(i=(o=e.automation.controlSession)==null?void 0:o.session)==null?void 0:i.title)!=null&&d.trim()?e.automation.controlSession.session.title.trim():l("shell.butlerControlTimerUnknownSession")}function zo(){return t.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",focusable:"false",children:t.jsx("path",{fill:"currentColor",d:"M8 1.25a6.75 6.75 0 1 0 0 13.5A6.75 6.75 0 0 0 8 1.25Zm0 1.5a5.25 5.25 0 1 1 0 10.5A5.25 5.25 0 0 1 8 2.75Zm0 2.5a.875.875 0 1 0 0 1.75a.875.875 0 0 0 0-1.75Zm-.875 3.125a.625.625 0 1 0 0 1.25h.25v1.75h-.25a.625.625 0 1 0 0 1.25h1.75a.625.625 0 1 0 0-1.25h-.25V9a.625.625 0 0 0-.625-.625h-.875Z"})})}function Wo(e){const n=Math.max(0,Math.ceil(e/1e3)),s=Math.floor(n/3600),o=Math.floor(n%3600/60),i=n%60;return s>0?`${String(s).padStart(2,"0")}:${String(o).padStart(2,"0")}:${String(i).padStart(2,"0")}`:`${String(o).padStart(2,"0")}:${String(i).padStart(2,"0")}`}function jl(e){return e==="queued"||e==="running"}function qo(e){return e.status==="active"||e.status==="waiting_user"}function Ko(e){return e.status==="queued"||e.status==="running"}function Yo(e){switch(e){case"queued":case"running":return l("shell.butlerAutomationStatusActive");case"passed":case"skipped":return l("shell.butlerAutomationStatusCompleted");case"failed":return l("shell.butlerAutomationStatusFailed");case"cancelled":return l("shell.butlerAutomationStatusCancelled");default:return e}}function Zo(e){return e==="failed"?"failed":e==="cancelled"?"cancelled":e==="passed"||e==="skipped"?"completed":"active"}function Xo(e){switch(e){case"analyzing":return l("shell.butlerTodoLifecycleAnalyzing");case"analyzed":return l("shell.butlerTodoLifecycleAnalyzed");case"session_created":return l("shell.butlerTodoLifecycleSessionCreated");case"follow_up_active":return l("shell.butlerTodoLifecycleFollowUpActive");case"completed":return l("shell.butlerTodoLifecycleCompleted");case"failed":return l("shell.butlerTodoLifecycleFailed");case"pending":default:return l("shell.butlerTodoLifecyclePending")}}function Pn(e){return e.finishedAt||e.startedAt||e.createdAt}function I(e){if(!e)return 0;const n=new Date(e).getTime();return Number.isNaN(n)?0:n}function Be(e){return typeof e=="number"&&Number.isFinite(e)?String(e):""}function Go(e){const n=e.trim();return n||null}function sn(e){if(!e)return"";const n=new Date(e);if(Number.isNaN(n.getTime()))return"";const s=n.getFullYear(),o=String(n.getMonth()+1).padStart(2,"0"),i=String(n.getDate()).padStart(2,"0"),d=String(n.getHours()).padStart(2,"0"),c=String(n.getMinutes()).padStart(2,"0");return`${s}-${o}-${i}T${d}:${c}`}function mn(e,n){const s=e.trim();if(!s)return null;const o=Date.parse(s);if(Number.isNaN(o))throw new Error(`${n}${l("shell.butlerAutomationInvalidDateSuffix")}`);return new Date(o).toISOString()}function Qo(e,n){const s=mn(e,n);if(!s)throw new Error(`${n}${l("shell.butlerAutomationRequiredSuffix")}`);return s}function cs(e,n){const s=e.trim();if(!s)throw new Error(`${n}${l("shell.butlerAutomationRequiredSuffix")}`);const o=Number.parseInt(s,10);if(!Number.isInteger(o))throw new Error(`${n}${l("shell.butlerAutomationInvalidNumberSuffix")}`);return o}function ds(e,n){const s=e.trim();if(!s)return null;const o=Number.parseInt(s,10);if(!Number.isInteger(o))throw new Error(`${n}${l("shell.butlerAutomationInvalidNumberSuffix")}`);return o}function on(e,n){const s=ds(e,n);if(s===null)return null;if(s<=0)throw new Error(`${n}${l("shell.butlerAutomationInvalidPositiveNumberSuffix")}`);return s}function Jo(e,n){const s=cs(e,n);if(s<=0)throw new Error(`${n}${l("shell.butlerAutomationInvalidPositiveNumberSuffix")}`);return s}function ei(e){const n=e.trim();if(!n)return null;const s=n.split(",").map(o=>Number.parseInt(o.trim(),10)).filter(o=>Number.isInteger(o));if(s.length===0||s.some(o=>o<0||o>6))throw new Error(l("shell.butlerAutomationCronDaysValidation"));return Array.from(new Set(s)).sort((o,i)=>o-i)}function ti(e){const n=I(e);return n<=0?"-":new Intl.DateTimeFormat("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(n))}function ni(e){for(const[n,s]of Object.entries(zn))if(s.length===e.length&&s.every((o,i)=>o===e[i]))return n;return"risk-first"}function li(e){var o;if((o=e.agentsFilePath)!=null&&o.trim())return e.agentsFilePath.trim();const n=e.workspacePath.includes("\\")?"\\":"/";return`${e.workspacePath.replace(/[\\/]+$/,"")}${n}AGENTS.md`}function si(e){switch(e){case"pending":return l("shell.butlerInfoTodoPending");case"in_progress":return l("shell.butlerInfoTodoInProgress");case"closed":return l("shell.butlerInfoTodoClosed");default:return l("shell.butlerInfoTodoPending")}}function Xn(e){switch(e){case"active":return l("shell.butlerAutomationStatusActive");case"waiting_user":return l("shell.butlerAutomationStatusWaitingUser");case"completed":return l("shell.butlerAutomationStatusCompleted");case"failed":return l("shell.butlerAutomationStatusFailed");case"cancelled":return l("shell.butlerAutomationStatusCancelled");default:return l("shell.butlerAutomationStatusActive")}}function oi(e){switch(e){case"started":return l("shell.butlerAutomationRoundKindStarted");case"continue":return l("shell.butlerAutomationRoundKindContinue");case"queued":return l("shell.butlerAutomationRoundKindQueued");case"waiting_user":return l("shell.butlerAutomationRoundKindWaitingUser");case"completed":return l("shell.butlerAutomationRoundKindCompleted");case"failed":return l("shell.butlerAutomationRoundKindFailed");case"cancelled":return l("shell.butlerAutomationRoundKindCancelled");case"limit_reached":return l("shell.butlerAutomationRoundKindLimitReached");default:return e}}function ms(e){switch(e){case"once":return l("shell.butlerAutomationTaskTypeControlTimer");case"interval":return l("shell.butlerAutomationTaskTypeInterval");case"cron":return l("shell.butlerAutomationTaskTypeCron");case"condition":return l("shell.butlerAutomationTaskTypeFollowUp");default:return l("shell.butlerAutomationTaskTypeControlTimer")}}function bs(e){return e==="interval"||e==="cron"?l("shell.butlerAutomationRunSourcePatrol"):e==="once"?l("shell.butlerAutomationRunSourceControlTimer"):l("shell.butlerAutomationRunSourceFollowUp")}function hs(e){switch(e){case"failed":return"failed";case"cancelled":return"cancelled";case"completed":case"passed":case"succeeded":return"completed";case"waiting_user":return"waiting_user";case"active":case"queued":case"running":default:return"active"}}function ii(e){switch(e){case"failed":return"failed";case"cancelled":return"cancelled";case"completed":return"completed";case"paused":return"waiting_user";case"active":default:return"active"}}function fs(e){switch(e){case"completed":return l("shell.butlerAutomationStatusCompleted");case"failed":return l("shell.butlerAutomationStatusFailed");case"cancelled":return l("shell.butlerAutomationStatusCancelled");case"paused":return l("shell.butlerAutomationStatusWaitingUser");case"active":default:return l("shell.butlerAutomationStatusActive")}}function gs(e){switch(e){case"succeeded":return l("shell.butlerAutomationStatusCompleted");case"failed":return l("shell.butlerAutomationStatusFailed");case"cancelled":case"skipped":return l("shell.butlerAutomationStatusCancelled");case"queued":case"running":default:return l("shell.butlerAutomationStatusActive")}}function xs(e){var n,s;return((n=e.title)==null?void 0:n.trim())||((s=e.actionConfig.targetSessionId)==null?void 0:s.trim())||e.actionConfig.content.trim()||e.id}function Gn(e,n){var s,o;return e.projectId&&n.has(e.projectId)?n.get(e.projectId):((o=(s=e.controlSession)==null?void 0:s.session)==null?void 0:o.workspaceId)||l("shell.butlerControlTimerNoProject")}function ri(e,n){var o,i,d;const s=(o=e.actionConfig.targetSessionId)==null?void 0:o.trim();return s&&n.has(s)?n.get(s):(d=(i=e.controlSession)==null?void 0:i.title)!=null&&d.trim()?e.controlSession.title.trim():s||null}function Al(e){var s;const n={title:((s=e.title)==null?void 0:s.trim())||"",content:e.actionConfig.content,includeTriggerContext:e.actionConfig.includeTriggerContext,dueAt:"",everySeconds:"",everyMinutes:"",everyHours:"",stopAt:"",cronMinute:"",cronHour:"",cronDaysOfWeek:"",pollIntervalSeconds:"",expiresAt:"",maxChecks:""};return e.triggerConfig.type==="once"?n.dueAt=sn(e.triggerConfig.dueAt):e.triggerConfig.type==="interval"?(n.everySeconds=Be(e.triggerConfig.seconds),n.everyMinutes=Be(e.triggerConfig.minutes),n.everyHours=Be(e.triggerConfig.hours),n.stopAt=sn(e.triggerConfig.stopAt)):e.triggerConfig.type==="cron"?(n.cronMinute=Be(e.triggerConfig.minute),n.cronHour=Be(e.triggerConfig.hour),n.cronDaysOfWeek=(e.triggerConfig.daysOfWeek??[]).join(","),n.stopAt=sn(e.triggerConfig.stopAt)):(n.pollIntervalSeconds=Be(e.triggerConfig.pollIntervalSeconds),n.expiresAt=sn(e.triggerConfig.expiresAt),n.maxChecks=Be(e.triggerConfig.maxChecks)),n}function ai(e,n){const s={title:Go(n.title),content:n.content.trim(),includeTriggerContext:n.includeTriggerContext};if(!s.content)throw new Error(l("shell.butlerAutomationPromptRequired"));return e.triggerConfig.type==="once"?{...s,dueAt:Qo(n.dueAt,l("shell.butlerAutomationDueAtLabel"))}:e.triggerConfig.type==="interval"?{...s,everySeconds:on(n.everySeconds,l("shell.butlerAutomationEverySecondsLabel")),everyMinutes:on(n.everyMinutes,l("shell.butlerAutomationEveryMinutesLabel")),everyHours:on(n.everyHours,l("shell.butlerAutomationEveryHoursLabel")),stopAt:mn(n.stopAt,l("shell.butlerAutomationStopAtLabel"))}:e.triggerConfig.type==="cron"?{...s,cronMinute:cs(n.cronMinute,l("shell.butlerAutomationCronMinuteLabel")),cronHour:ds(n.cronHour,l("shell.butlerAutomationCronHourLabel")),cronDaysOfWeek:ei(n.cronDaysOfWeek),stopAt:mn(n.stopAt,l("shell.butlerAutomationStopAtLabel"))}:{...s,pollIntervalSeconds:Jo(n.pollIntervalSeconds,l("shell.butlerAutomationPollIntervalLabel")),expiresAt:mn(n.expiresAt,l("shell.butlerAutomationExpiresAtLabel")),maxChecks:on(n.maxChecks,l("shell.butlerAutomationMaxChecksLabel"))}}function rn(e,n){const s=e.filter(o=>o.id!==n.id);return[n,...s].sort((o,i)=>I(wl(i))-I(wl(o)))}function wl(e){return e.updatedAt||e.lastRunAt||e.nextRunAt||e.createdAt}function ui(e){const s=`${e.displayName.trim()}:${e.providerId}:${e.tone}`,o=ci(e);if(!s)return Ae.default[0];const i=Array.from(s).reduce((d,c)=>{const f=c.codePointAt(0)??0;return d+f},0);return o[i%o.length]}function ci(e){const n=e.displayName.trim().toLowerCase();return/(bot|ai|智能|助手|助理|管家|buddy|helper)/.test(n)?Ae.builder:/(书|学|知|研|析|查|review|audit|scan)/.test(n)?Ae.analyst:e.tone==="friendly"?Ae.friendly:e.tone==="steady"?Ae.steady:e.tone==="direct"?e.providerId==="claude-code"?Ae.analyst:Ae.direct:e.providerId==="claude-code"?Ae.analyst:Ae.default}function Dn(e){switch(e){case"claude-code":return"Claude Code";case"codex":default:return"Codex"}}function di(e,n){const s=(e==null?void 0:e.flatMap(i=>{if(!mi(i.provider))return[];const d=i.provider,c=i.displayName||Dn(d);return[{value:d,label:i.enabled?c:`${c} (${l("settings.skillTargetDisabledTag")})`,enabled:i.enabled}]}))??Wn.map(i=>({value:i,label:Dn(i),enabled:!0})),o=new Map(s.map(i=>[i.value,i]));for(const i of n)!i||o.has(i)||o.set(i,{value:i,label:`${Dn(i)} (${l("settings.skillTargetDisabledTag")})`,enabled:!1});return Wn.map(i=>o.get(i)).filter(i=>!!i)}function mi(e){return Wn.includes(e)}function bi(e,n){var s;return((s=e.find(o=>o.value===n))==null?void 0:s.label)??n}function hi(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),t.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function fi(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"8.25",fill:"none"}),t.jsx("path",{d:"M12 8.4v4.1l2.75 1.9",fill:"none"})]})}const vs="mobile.butler.active-tab",bn=["info","automation","settings"],gi=15e3,Qn=56,Jn=1.2,Cl=360,xi=1500,vi=1500;function yi(e){const[n,s]=u.useState(e),o=u.useRef(null);return u.useEffect(()=>{if(e){o.current!==null&&(window.clearTimeout(o.current),o.current=null),s(e);return}!n||o.current!==null||(o.current=window.setTimeout(()=>{o.current=null,s(null)},xi))},[e,n]),u.useEffect(()=>()=>{o.current!==null&&window.clearTimeout(o.current)},[]),e??n}function pi(e,n){const[s,o]=u.useState(n),i=u.useRef(null);return u.useEffect(()=>{i.current!==null&&(window.clearTimeout(i.current),i.current=null),o(n)},[e]),u.useEffect(()=>{if(n){i.current!==null&&(window.clearTimeout(i.current),i.current=null),o(!0);return}!s||i.current!==null||(i.current=window.setTimeout(()=>{i.current=null,o(!1)},vi))},[n,s]),u.useEffect(()=>()=>{i.current!==null&&window.clearTimeout(i.current)},[]),s}function Si(e,n){return n===!0?!0:e?e.session.activityState==="running"||e.session.runningState==="starting"||e.session.runningState==="running"||e.session.runningState==="reconnecting":!1}function ji(){if(typeof window>"u")return"info";try{const e=window.localStorage.getItem(vs);return e==="automation"||e==="settings"?e:"info"}catch{return"info"}}function Ai(e){var n,s,o;return((n=e.title)==null?void 0:n.trim())||((s=e.session.title)==null?void 0:s.trim())||((o=e.lastSummary)==null?void 0:o.trim())||e.sessionId}function wi(e,n){return e==="settings"?"settings":e==="automation"?"automation":e==="info"?"info":n}function Ci(e,n,s){if(!n)return{closeSidebar:!1,nextTab:e};const o=s.x-n.x,i=s.y-n.y;if(Math.abs(o)<Qn)return{closeSidebar:!1,nextTab:e};if(Math.abs(o)<Math.abs(i)*Jn)return{closeSidebar:!1,nextTab:e};const d=bn.indexOf(e);if(o>0&&d===0)return{closeSidebar:!0,nextTab:e};const c=o<0?Math.min(bn.length-1,d+1):Math.max(0,d-1);return{closeSidebar:!1,nextTab:bn[c]??e}}function Ti(e,n){if(!e)return null;const s=n.x-e.x,o=n.y-e.y;return Math.abs(s)<Qn||Math.abs(s)<Math.abs(o)*Jn?null:s>0?"list":"sidebar"}function Un(e){return e instanceof Element?!!e.closest("input, textarea, select, option, label, button, a, [contenteditable='true'], [data-mobile-butler-gesture='ignore']"):!1}function Ni(){var Xt,At,P,Gt,st,Oe,wt,Ct,Tt,Qt,be;const{workspaceId:e=""}=Ql(),n=Gs(),s=Jl(),{showToast:o}=es(),{navigationGroups:i,requestNavigationRefresh:d,selectWorkspace:c}=Kn(),f=((Xt=i.find(r=>r.workspace.id===e))==null?void 0:Xt.workspace)??null,h=u.useMemo(()=>new Map(i.map(r=>[r.workspace.id,r.workspace.name])),[i]),j=u.useMemo(()=>new Map(i.flatMap(r=>r.sessions.map(b=>{var v;return[b.sessionId,((v=b.title)==null?void 0:v.trim())||l("common.unknown")]}))),[i]),y=u.useMemo(()=>new Map(i.flatMap(r=>r.sessions.map(b=>[b.sessionId,r.workspace.id]))),[i]),L=new URLSearchParams(n.search).get("tab"),$=u.useRef(ji()),D=wi(L,$.current),k=u.useRef(null),_=u.useRef(null),J=u.useRef(null),ee=u.useRef(null),te=u.useRef(null),[Y,U]=u.useState(null),[re,H]=u.useState(null),[Ee,nl]=u.useState(null),[Ce,Rt]=u.useState(null),[ce,ze]=u.useState(null),[Te,ne]=u.useState(null),[O,de]=u.useState(null),[Ne,Ie]=u.useState(null),[We,kt]=u.useState(null),[qe,Lt]=u.useState(null),[Et,Ke]=u.useState(null),[Mt,me]=u.useState(null),[Ye,Re]=u.useState(()=>Date.now()),[le,Ze]=u.useState(null),[he,Ft]=u.useState(null),[p,M]=u.useState({loading:!0,initialized:!1,profile:null,overview:null,followUpTasks:[],inboxItems:[],patrolPlans:[],controlSessions:[],controlTimers:[],assistantAutomations:[],assistantAutomationRuns:[]}),Pt=u.useMemo(()=>{var r;return new Map((((r=p.overview)==null?void 0:r.projects)??[]).map(b=>[b.id,b.name]))},[(At=p.overview)==null?void 0:At.projects]);(!ee.current||te.current!==e)&&(ee.current=new Hl(e),te.current=e);const R=ee.current,at=N(R,r=>r.loading),fe=N(R,r=>r.initialized),Z=N(R,r=>r.profile),ae=N(R,r=>r.activeProvider),w=N(R,r=>r.controlSession),Sn=N(R,r=>r.capabilities),ut=N(R,r=>r.messages),ye=N(R,r=>r.historyState),ct=N(R,r=>r.loadingOlderMessages),jn=N(R,r=>r.hasOlderMessages),ke=N(R,r=>r.sending),Dt=N(R,r=>r.runtimeHasActiveRun),Xe=N(R,r=>r.runtimeCanInterrupt),dt=N(R,r=>r.contextUsage),Ge=N(R,r=>r.permissionRequests),{composerPortalTarget:mt}=Ys(),bt=u.useRef(null),Qe=u.useRef(null),Je=u.useRef(!1),ht=u.useRef(new Set);u.useEffect(()=>{if($.current=D,!(typeof window>"u"))try{window.localStorage.setItem(vs,D)}catch{}},[D]),u.useEffect(()=>{if(L===D)return;const r=new URLSearchParams(n.search);r.set("tab",D),s({pathname:n.pathname,search:`?${r.toString()}`},{replace:!0})},[D,n.pathname,n.search,s,L]),u.useEffect(()=>{e&&c(e)},[c,e]),u.useEffect(()=>{e&&R.initialize()},[R,e]),u.useEffect(()=>{var K,je,X,xe,$e;const r=((K=w==null?void 0:w.session)==null?void 0:K.sessionId)??null;if(Qe.current!==r&&(Qe.current=r,Je.current=!1,ht.current=new Set),!r)return;const b=Ge.filter(G=>G.status==="pending"),v=new Set(b.map(G=>G.id)),A=((je=w==null?void 0:w.title)==null?void 0:je.trim())||((xe=(X=w==null?void 0:w.session)==null?void 0:X.title)==null?void 0:xe.trim())||(($e=Z==null?void 0:Z.displayName)==null?void 0:$e.trim())||l("shell.butlerEntry");Je.current&&b.forEach(G=>{ht.current.has(G.id)||o({id:`mobile-butler-permission-request-${G.id}`,title:l("conversation.permissionRequestToastTitle"),description:l("conversation.backgroundPermissionToastDescription",{title:A,requestTitle:G.title}),tone:"warning",durationMs:8e3})}),ht.current=v,Je.current=!0},[(P=w==null?void 0:w.session)==null?void 0:P.sessionId,(Gt=w==null?void 0:w.session)==null?void 0:Gt.title,w==null?void 0:w.title,Ge,Z==null?void 0:Z.displayName,o]),u.useEffect(()=>{if(!e){M({loading:!1,initialized:!1,profile:null,overview:null,followUpTasks:[],inboxItems:[],patrolPlans:[],controlSessions:[],controlTimers:[],assistantAutomations:[],assistantAutomationRuns:[]});return}let r=!1;async function b(je){M(X=>({...X,loading:!0}));try{const X=await Zs();if(!X.initialized||!X.profile){r||M({loading:!1,initialized:!1,profile:null,overview:null,followUpTasks:[],inboxItems:[],patrolPlans:[],controlSessions:[],controlTimers:[],assistantAutomations:[],assistantAutomationRuns:[]});return}const[xe,$e,G,ot,Jt,kn,Ln]=await Promise.all([fl(),Hn(),Zl({workspaceId:e}),fn(),Xl(),Bn({limit:100}),_n({limit:100})]),en=xe.overview.projects.filter(oe=>oe.workspaceId===e).map(oe=>oe.id),En=await Promise.all(en.map(oe=>Gl(oe)));if(r)return;M({loading:!1,initialized:!0,profile:X.profile,overview:xe.overview,followUpTasks:$e.items.filter(oe=>oe.workspaceId===e),inboxItems:G.items.filter(oe=>oe.status!=="closed"),patrolPlans:En.flatMap(oe=>oe.items),controlSessions:ot.items,controlTimers:Jt.items,assistantAutomations:kn.payload.items,assistantAutomationRuns:Ln.payload.items})}catch(X){if(r)return;M(xe=>({...xe,loading:!1})),je&&o({title:l("shell.butlerLoadFailed"),description:X instanceof Error?X.message:void 0,tone:"error"})}}b(!0);const v=window.setInterval(()=>{b(!1)},gi),A=ts(()=>{b(!1)}),K=()=>{b(!1)};return window.addEventListener(vn,K),()=>{r=!0,window.clearInterval(v),A(),window.removeEventListener(vn,K)}},[o,e]);const z=u.useMemo(()=>{var r;return new Set((((r=p.overview)==null?void 0:r.projects)??[]).filter(b=>b.workspaceId===e).map(b=>b.id))},[(st=p.overview)==null?void 0:st.projects,e]),ft=u.useMemo(()=>p.controlTimers.filter(r=>{var b,v;return r.projectId?z.has(r.projectId):((v=(b=r.controlSession)==null?void 0:b.session)==null?void 0:v.workspaceId)===e}),[p.controlTimers,e,z]),gt=u.useMemo(()=>p.followUpTasks.filter(r=>Rl(r.status)),[p.followUpTasks]),et=u.useMemo(()=>{var r;return(((r=p.overview)==null?void 0:r.verifications)??[]).filter(b=>b.projectId?z.has(b.projectId):!1)},[(Oe=p.overview)==null?void 0:Oe.verifications,z]),tt=u.useMemo(()=>[...gt].sort((r,b)=>E(ve(b))-E(ve(r))).slice(0,4),[gt]),An=u.useMemo(()=>Nl(et,"active"),[et]),Ut=u.useMemo(()=>Nl(et,"history"),[et]),Ot=u.useMemo(()=>Di(p.inboxItems.filter(r=>r.status!=="closed")).slice(0,4),[p.inboxItems]),xt=u.useMemo(()=>Ml(p.assistantAutomations,p.overview,z,"active"),[p.assistantAutomations,p.overview,z]),$t=u.useMemo(()=>Fl(p.assistantAutomations,p.assistantAutomationRuns,p.overview,z,"active"),[p.assistantAutomations,p.assistantAutomationRuns,p.overview,z]),se=u.useMemo(()=>O?p.assistantAutomations.find(r=>r.id===O)??null:null,[O,p.assistantAutomations]),Ht=u.useMemo(()=>O?p.assistantAutomationRuns.filter(r=>r.automationId===O).sort((r,b)=>E(b.createdAt)-E(r.createdAt)).slice(0,6):[],[O,p.assistantAutomationRuns]);u.useEffect(()=>{O&&!se&&(de(null),Ie(null))},[se,O]);const Bt=u.useMemo(()=>[...p.followUpTasks].filter(r=>!Rl(r.status)).sort((r,b)=>E(ve(b))-E(ve(r))).slice(0,8),[p.followUpTasks]),nt=u.useMemo(()=>Ml(p.assistantAutomations,p.overview,z,"history"),[p.assistantAutomations,p.overview,z]),S=u.useMemo(()=>Fl(p.assistantAutomations,p.assistantAutomationRuns,p.overview,z,"history"),[p.assistantAutomations,p.assistantAutomationRuns,p.overview,z]),ge=u.useMemo(()=>Si(w,Dt),[w,Dt]),W=pi((w==null?void 0:w.session.sessionId)??null,ge),pe=W||ke,ue=W||ke,C=Xe===!0||ke?!0:Xe??!1,q=u.useMemo(()=>{if(!w||W)return null;const r=ft.filter(A=>A.status==="active"&&A.controlSessionId===w.id).map(A=>({kind:"timer",timer:A})),b=new Set(ft.filter(A=>A.status==="active"&&A.controlSessionId===w.id).map(A=>A.id)),v=p.assistantAutomations.filter(A=>A.status==="active"&&A.controlSessionId===w.id&&!!A.nextRunAt&&!b.has(A.id)).map(A=>({kind:"automation",automation:A}));return[...r,...v].sort((A,K)=>E(pn(A))-E(pn(K)))[0]??null},[w,W,p.assistantAutomations,ft]),g=yi(q),_t=p.loading||at,F=!_t&&(!p.initialized||!fe||!p.profile),lt=((wt=Z==null?void 0:Z.displayName)==null?void 0:wt.trim())||((Tt=(Ct=p.profile)==null?void 0:Ct.displayName)==null?void 0:Tt.trim())||l("shell.butlerEntry"),Me=!w&&ut.length===0,Fe=!F&&Y===null;u.useEffect(()=>{if(Re(Date.now()),!g)return;const r=window.setInterval(()=>{Re(Date.now())},1e3);return()=>{window.clearInterval(r)}},[g]),u.useEffect(()=>{Y!=="sidebar"&&H(null)},[Y]);const wn=re==="follow_up"?t.jsx(Tl,{title:l("shell.butlerFollowUpHistoryTitle"),description:l("shell.butlerFollowUpHistoryDescription"),emptyText:l("shell.butlerInfoFollowUpRecordsEmpty"),onClose:()=>H(null),items:Bt.map(r=>{var b,v,A;return{id:r.id,title:((b=r.sessionTitle)==null?void 0:b.trim())||r.projectName,subtitle:r.projectName,status:Pl(r.status),content:((v=r.waitingReason)==null?void 0:v.trim())||((A=r.lastAutomationSummary)==null?void 0:A.trim())||r.objective||l("shell.butlerInfoFollowUpFallback",{updatedAt:Q(ve(r))}),meta:Q(ve(r)),actionLabel:an(r.status)?Ce===r.id?l("conversation.butlerFollowUpStopping"):l("conversation.butlerStopFollowUpAction"):null,actionDisabled:Ce===r.id,onAction:an(r.status)?()=>{qt(r)}:void 0}})}):re==="verification"?t.jsx(Tl,{title:l("shell.butlerVerificationHistoryTitle"),description:l("shell.butlerVerificationHistoryDescription"),emptyText:l("shell.butlerVerificationHistoryEmpty"),onClose:()=>H(null),items:Ut.map((r,b)=>({id:`${r.title}:${b}`,title:r.title,subtitle:r.subtitle,status:r.status,content:r.content,meta:r.meta,actionLabel:r.verification&&Ll(r.verification.status)?ce===r.verification.id?l("conversation.butlerVerificationStopping"):l("conversation.butlerStopVerificationAction"):null,actionDisabled:r.verification?ce===r.verification.id:!1,onAction:r.verification?()=>{Ue(r.verification)}:void 0}))}):re==="automation"?t.jsx(Mi,{taskItems:nt,runItems:S,onClose:()=>H(null)}):D==="info"?t.jsxs(t.Fragment,{children:[t.jsx(Nt,{title:l("shell.butlerInfoFollowUpRecordsTitle"),emptyText:l("shell.butlerInfoFollowUpRecordsEmpty"),actionLabel:l("shell.butlerFollowUpHistoryAction"),onAction:()=>H("follow_up"),items:tt.map(r=>{var b,v,A;return{id:r.id,title:((b=r.sessionTitle)==null?void 0:b.trim())||r.projectName,subtitle:r.projectName,status:Pl(r.status),content:((v=r.waitingReason)==null?void 0:v.trim())||((A=r.lastAutomationSummary)==null?void 0:A.trim())||r.objective||l("shell.butlerInfoFollowUpFallback",{updatedAt:Q(ve(r))}),meta:Q(ve(r)),actionLabel:an(r.status)?Ce===r.id?l("conversation.butlerFollowUpStopping"):l("conversation.butlerStopFollowUpAction"):null,actionDisabled:Ce===r.id,onAction:an(r.status)?()=>{qt(r)}:void 0}})}),t.jsx(Nt,{title:l("shell.butlerInfoVerificationRecordsTitle"),emptyText:l("shell.butlerInfoVerificationRecordsEmpty"),actionLabel:l("shell.butlerFollowUpHistoryAction"),onAction:()=>H("verification"),items:An.map((r,b)=>({id:`${r.title}:${b}`,title:r.title,subtitle:r.subtitle,status:r.status,content:r.content,meta:r.meta,actionLabel:r.verification&&Ll(r.verification.status)?ce===r.verification.id?l("conversation.butlerVerificationStopping"):l("conversation.butlerStopVerificationAction"):null,actionDisabled:r.verification?ce===r.verification.id:!1,onAction:r.verification?()=>{Ue(r.verification)}:void 0}))}),t.jsx(Ei,{title:l("shell.butlerInfoTodoRecordsTitle"),emptyText:l("shell.butlerInfoTodoRecordsEmpty"),items:Ot.map((r,b)=>({id:`${r.title}:${b}`,title:r.title,content:r.content}))})]}):D==="automation"?t.jsxs(t.Fragment,{children:[t.jsx(Ri,{items:xt,emptyText:l("shell.butlerAutomationTasksEmpty"),actionLabel:l("shell.butlerFollowUpHistoryAction"),onAction:()=>H("automation"),selectedAutomationId:O,cancellingAutomationId:Te,onSelectAutomation:Nn,onCancelAutomation:r=>{Kt(r)}}),se&&Ne?t.jsx(ki,{automation:se,editorState:Ne,saving:We===se.id,recentRuns:Ht,workspaceNameById:h,sessionTitleById:j,onClose:()=>{de(null),Ie(null)},onEditorChange:r=>{Ie(b=>b&&{...b,...r})},onSave:()=>{In()}}):null,t.jsx(Nt,{title:l("shell.butlerAutomationRunsTitle"),emptyText:l("shell.butlerAutomationRunsEmpty"),items:$t.map(r=>({id:r.id,title:r.title,subtitle:r.projectName,status:r.statusLabel,content:`${r.sourceLabel} · ${r.summary}`,meta:Q(r.createdAt)}))})]}):t.jsxs("section",{className:"mobile-feature-panel surface-card mobile-butler-record-section",children:[t.jsx("div",{className:"mobile-feature-section-header",children:t.jsx("div",{children:t.jsx("h2",{children:l("shell.butlerSidebarSettingsTab")})})}),t.jsxs("div",{className:"mobile-butler-settings-summary",children:[t.jsx(we,{label:l("shell.butlerDisplayNameLabel"),value:lt}),t.jsx(we,{label:l("shell.butlerProviderLabel"),value:$l(ae)}),t.jsx(we,{label:l("shell.mobileButlerAssistantWorkspaceLabel"),value:((Qt=p.profile)==null?void 0:Qt.workspacePath)??(f==null?void 0:f.path)??"-"})]})]});Pi(bt,Ee,Fe,`${e}:${Y??"none"}`);function Vt(r){r!==D&&(H(null),s(Vn(e,r),{replace:!0}))}function Pe(r){if(r.changedTouches.length!==1){k.current=null;return}if(Un(r.target)){k.current=null;return}const b=r.changedTouches[0];k.current={x:b.clientX,y:b.clientY}}function De(r){if(r.changedTouches.length!==1)return;const b=k.current;k.current=null;const v=r.changedTouches[0],A=Ti(b,{x:v.clientX,y:v.clientY});A&&U(A)}function Cn(r){if(r.changedTouches.length!==1){_.current=null;return}if(Un(r.target)){_.current=null;return}const b=r.changedTouches[0];_.current={x:b.clientX,y:b.clientY}}function vt(r){const b=_.current;if(_.current=null,!b||r.changedTouches.length!==1)return;const v=r.changedTouches[0],A=v.clientX-b.x,K=v.clientY-b.y;A>-Qn||Math.abs(A)<Math.abs(K)*Jn||U(null)}function Le(r){if(r.changedTouches.length!==1){J.current=null;return}if(Un(r.target)){J.current=null;return}const b=r.changedTouches[0];J.current={x:b.clientX,y:b.clientY}}function zt(r){const b=J.current;if(J.current=null,r.changedTouches.length!==1)return;const v=r.changedTouches[0],A=Ci(D,b,{x:v.clientX,y:v.clientY});if(A.closeSidebar){U(null);return}A.nextTab!==D&&Vt(A.nextTab)}async function Wt(r){await R.openControlSession(r),U(null)}async function yt(){const r=await fn();M(b=>({...b,controlSessions:r.items}))}async function pt(){if(!(!le||he)){Ft(le.id);try{await Bl(le.session.sessionId),le.id===(w==null?void 0:w.id)&&await R.openControlSession(""),Ze(null),await yt(),d(),U(null),o({title:l("shell.deleteSessionSuccess"),tone:"success"})}catch(r){o({title:r instanceof Error?r.message:l("shell.deleteSessionFailed"),tone:"error"})}finally{Ft(null)}}}async function Se(){await R.startFreshSession(),U(null),d()}async function St(r,b){var v;(((v=b==null?void 0:b.attachments)==null?void 0:v.length)??0)>0&&o({title:l("shell.butlerAttachmentUnsupported"),tone:"warning"}),await R.sendMessage(r,{model:(b==null?void 0:b.model)??null,reasoningLevel:(b==null?void 0:b.reasoningLevel)??null,permissionMode:null}),d()}async function jt(){const[r,b,v,A]=await Promise.all([fl(),Hn(),Bn({limit:100}),_n({limit:100})]);await R.reloadEventsAndOverview(),M(K=>({...K,overview:r.overview,followUpTasks:b.items.filter(je=>je.workspaceId===e),assistantAutomations:v.payload.items,assistantAutomationRuns:A.payload.items}))}async function qt(r){Rt(r.id);try{const b=await _l(r.id);M(v=>({...v,followUpTasks:Ui(v.followUpTasks,b.task)})),await jt(),d(),o({title:l("conversation.butlerFollowUpStopped"),description:l("conversation.butlerFollowUpStoppedDescription"),tone:"success"})}catch(b){o({title:l("conversation.butlerFollowUpStopFailed"),description:b instanceof Error?b.message:void 0,tone:"error"})}finally{Rt(null)}}async function Ue(r){ze(r.id);try{await Vl(r.projectId,r.id),await jt(),d(),o({title:l("conversation.butlerVerificationStopped"),description:l("conversation.butlerVerificationStoppedDescription"),tone:"success"})}catch(b){o({title:l("conversation.butlerVerificationStopFailed"),description:b instanceof Error?b.message:void 0,tone:"error"})}finally{ze(null)}}async function Tn(r){Lt(r);try{const b=await gn(r);M(v=>({...v,controlTimers:Il(v.controlTimers,b.timer)})),o({title:l("shell.butlerControlTimerCancelSucceeded"),tone:"success"})}catch(b){o({title:l("shell.butlerControlTimerCancelFailed"),description:b instanceof Error?b.message:void 0,tone:"error"})}finally{Lt(null)}}function Nn(r){if(O===r){de(null),Ie(null);return}const b=p.assistantAutomations.find(v=>v.id===r);b&&(de(r),Ie(Dl(b)))}async function In(){if(!se||!Ne)return;let r;try{r=tr(se,Ne)}catch(b){o({title:l("shell.butlerAutomationSaveFailed"),description:b instanceof Error?b.message:void 0,tone:"error"});return}kt(se.id);try{const b=await zl(se.id,r);M(v=>({...v,assistantAutomations:On(v.assistantAutomations,b.payload.automation)})),de(b.payload.automation.id),Ie(Dl(b.payload.automation)),o({title:l("shell.butlerAutomationSaveSucceeded"),tone:"success"})}catch(b){o({title:l("shell.butlerAutomationSaveFailed"),description:b instanceof Error?b.message:void 0,tone:"error"})}finally{kt(null)}}async function Kt(r){ne(r);try{const b=await xn(r);M(v=>({...v,assistantAutomations:On(v.assistantAutomations,b.payload.automation)})),o({title:l("shell.butlerControlTimerCancelSucceeded"),tone:"success"})}catch(b){o({title:l("shell.butlerControlTimerCancelFailed"),description:b instanceof Error?b.message:void 0,tone:"error"})}finally{ne(null)}}async function V(r){const b=r.content.trim();if(!b){o({title:l("shell.butlerControlTimerExecuteNowFailed"),tone:"error"});return}Ke(r.id);try{const v=await gn(r.id);M(A=>({...A,controlTimers:Il(A.controlTimers,v.timer)})),await R.sendMessage(b),d(),o({title:l("shell.butlerControlTimerExecuteNowSucceeded"),tone:"success"})}catch(v){o({title:l("shell.butlerControlTimerExecuteNowFailed"),description:v instanceof Error?v.message:void 0,tone:"error"})}finally{Ke(null)}}async function Yt(r){if(r.kind==="timer"){await Tn(r.timer.id);return}await Kt(r.automation.id)}async function Rn(r){if(r.kind==="timer"){await V(r.timer);return}if(r.automation.triggerType!=="once")return;const b=r.automation.actionConfig.content.trim();if(!b){o({title:l("shell.butlerControlTimerExecuteNowFailed"),tone:"error"});return}Ke(r.automation.id);try{await xn(r.automation.id),M(v=>({...v,assistantAutomations:On(v.assistantAutomations,{...r.automation,status:"cancelled",nextRunAt:null,cancelledAt:new Date().toISOString(),updatedAt:new Date().toISOString()})})),await R.sendMessage(b),d(),o({title:l("shell.butlerControlTimerExecuteNowSucceeded"),tone:"success"})}catch(v){o({title:l("shell.butlerControlTimerExecuteNowFailed"),description:v instanceof Error?v.message:void 0,tone:"error"})}finally{Ke(null)}}function Zt(r){const b=tl(r),v=(b?y.get(b):null)||el(r)||e;!b||!v||(U(null),s(dn(v,b)))}return f?t.jsxs("main",{ref:bt,className:"mobile-feature-page mobile-page-fixed-root mobile-butler-page mobile-butler-page-shell","data-mobile-butler-drawer":Y??"none",children:[t.jsx(eo,{currentWorkspace:f,workspaces:i.map(r=>r.workspace),heading:l("shell.mobileButlerEntry"),triggerLabel:f.name,onSelectWorkspace:r=>{c(r),s(Vn(r,D))},trailing:t.jsxs("div",{className:"mobile-butler-header-trailing","data-mobile-butler-gesture":"ignore",children:[t.jsxs("div",{className:"mobile-butler-hero-top mobile-butler-toolbar-identity",children:[t.jsx("div",{className:"mobile-butler-hero-badge",children:"AI"}),t.jsxs("div",{className:"mobile-butler-hero-copy",children:[t.jsx("strong",{children:lt}),t.jsx("span",{children:$l(ae)})]})]}),t.jsxs("div",{className:"mobile-butler-toolbar-actions",children:[t.jsx("button",{type:"button",className:"mobile-butler-toolbar-button","aria-label":l("shell.butlerHistoryAction"),title:l("shell.butlerHistoryAction"),onClick:()=>U("list"),children:"≡"}),t.jsx("button",{type:"button",className:"mobile-butler-toolbar-button","aria-label":l("shell.butlerSidebarTabsLabel"),title:l("shell.butlerSidebarTabsLabel"),onClick:()=>U("sidebar"),children:"ⓘ"})]})]})}),t.jsxs("div",{className:"mobile-butler-stage-shell",children:[Y?t.jsx("button",{type:"button",className:"mobile-butler-drawer-scrim","aria-label":l("common.close"),onClick:()=>U(null)}):null,t.jsxs("aside",{className:"mobile-butler-drawer mobile-butler-drawer-list",style:{width:`min(88vw, ${Cl}px)`},onTouchStart:Cn,onTouchEnd:vt,children:[t.jsxs("div",{className:"mobile-butler-drawer-header",children:[t.jsxs("div",{children:[t.jsx("h2",{children:l("shell.butlerHistoryTitle")}),t.jsx("p",{children:l("shell.butlerHistoryDescription")})]}),t.jsx("button",{type:"button",className:"mobile-butler-toolbar-button","aria-label":l("shell.butlerNewSessionAction"),onClick:()=>{Se()},children:"+"})]}),t.jsx("div",{className:"mobile-butler-list-body",children:t.jsx(Fi,{activeControlSessionId:(w==null?void 0:w.id)??null,deletingSessionId:he,sessions:p.controlSessions,onSelectSession:r=>{Wt(r)},onDeleteSession:r=>{Ze(r)}})})]}),t.jsx("div",{className:"mobile-butler-main-stage",onTouchStart:Pe,onTouchEnd:De,children:_t?t.jsx("section",{className:"mobile-butler-loading-shell",children:t.jsx(ns,{})}):F?t.jsxs("section",{className:"mobile-butler-empty-panel",children:[t.jsx("h2",{children:l("shell.mobileButlerEmptyTitle")}),t.jsx("p",{children:l("shell.mobileButlerEmptyBody")})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"mobile-butler-chat-body",children:[t.jsx(Wl,{requests:Ge,replyingRequestId:Mt,onReply:async(r,b)=>{me(r);try{await R.replyPermissionRequest(r,b)}catch(v){o({title:l("conversation.permissionRequestReplyFailed"),description:v instanceof Error?v.message:void 0,tone:"error"})}finally{me(null)}}}),Me?t.jsxs("section",{className:"mobile-butler-empty-panel",children:[t.jsx("h2",{children:l("shell.butlerConversationTitle")}),t.jsx("p",{children:l("shell.butlerProjectSyncEmptyState")})]}):t.jsx("div",{className:"conversation-timeline-shell mobile-butler-timeline-shell",children:t.jsx(ql,{sessionId:(be=w==null?void 0:w.session)==null?void 0:be.sessionId,items:Kl({messages:ut}),historyState:ye,loadingOlderMessages:ct,hasOlderMessages:jn,provider:ae,onLoadOlderMessages:()=>{R.loadOlderMessages()},onRetryMessage:r=>{R.retryMessage(r)}})})]}),g?t.jsx(Ii,{schedule:g,currentWorkspaceId:e,currentWorkspaceName:(f==null?void 0:f.name)??null,projectNameById:Pt,workspaceNameById:h,sessionTitleById:j,sessionWorkspaceIdById:y,countdownNow:Ye,cancelling:g.kind==="timer"?qe===g.timer.id:Te===g.automation.id,executingNow:Et===Ki(g),onCancel:()=>{Yt(g)},onExecuteNow:()=>{Rn(g)},onOpenSession:()=>{Zt(g)}}):null,Fe?t.jsx("div",{className:"mobile-butler-chat-composer","data-mobile-butler-gesture":"ignore",children:t.jsx(Yl,{capabilities:Sn,draftStorageId:`mobile-butler:${e}:${ae}`,panelRef:nl,portalContainer:mt,placeholder:l("shell.butlerComposerPlaceholder",{displayName:lt}),hasActiveRun:pe,canInterrupt:C,contextUsage:dt,isSubmitting:ke,isRunning:ue,onInterrupt:async()=>{await R.interrupt(),d()},onSend:async(r,b)=>{await St(r,b)}})}):null]})}),t.jsx("aside",{className:"mobile-butler-drawer mobile-butler-drawer-sidebar",style:{width:`min(88vw, ${Cl}px)`},onTouchStart:Le,onTouchEnd:zt,children:t.jsxs("div",{className:"mobile-butler-sidebar-shell",children:[t.jsx("div",{className:"mobile-butler-segmented-shell","data-mobile-butler-gesture":"ignore",children:t.jsx("div",{className:"mobile-butler-segmented-control",role:"tablist","aria-label":l("shell.butlerSidebarTabsLabel"),children:bn.map(r=>{const b=D===r,v=r==="info"?l("shell.butlerSidebarInfoTab"):r==="automation"?l("shell.butlerSidebarAutomationTab"):l("shell.butlerSidebarSettingsTab");return t.jsx("button",{type:"button",role:"tab",className:"mobile-butler-segmented-button","aria-selected":b,onClick:()=>{Vt(r)},children:v},r)})})}),t.jsx("div",{className:"mobile-page-top-body mobile-butler-body mobile-butler-sidebar-body",children:wn})]})})]}),t.jsx(Js,{open:le!==null,title:l("shell.deleteSessionConfirmTitle"),description:l("shell.deleteSessionConfirmDescription"),height:"auto",onClose:()=>{he||Ze(null)},footer:t.jsxs("div",{className:"workbench-modal-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:!!he,onClick:()=>Ze(null),children:l("common.cancel")}),t.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:!!he,onClick:()=>{pt()},children:he?l("common.loading"):l("shell.deleteSessionAction")})]}),children:t.jsx("p",{className:"mobile-butler-empty-text",children:le?Ai(le):""})})]}):t.jsx("main",{className:"mobile-feature-page mobile-page-scroll-root",children:t.jsxs("article",{className:"mobile-feature-empty surface-card",children:[t.jsx("h1",{children:l("shell.workspaceDetailMissingTitle")}),t.jsx("p",{children:l("shell.workspaceDetailMissingBody")})]})})}function Ii(e){const n=u.useId(),s=u.useId(),o=u.useRef(null),i=u.useRef(null),[d,c]=u.useState(!1),f=Zi(e.schedule,e.countdownNow),h=Xi(e.schedule,e.countdownNow),j=_i(e.schedule,e.projectNameById,e.workspaceNameById,e.currentWorkspaceId,e.currentWorkspaceName),y=zi(e.schedule,e.sessionTitleById),L=Gi(e.schedule),$=tl(e.schedule),D=!!($&&(e.sessionWorkspaceIdById.has($)||el(e.schedule))),k=Yi(e.schedule);return u.useEffect(()=>{if(!d)return;const _=ee=>{var te,Y;(te=o.current)!=null&&te.contains(ee.target)||(Y=i.current)!=null&&Y.contains(ee.target)||c(!1)},J=ee=>{ee.key==="Escape"&&c(!1)};return document.addEventListener("pointerdown",_),document.addEventListener("keydown",J),()=>{document.removeEventListener("pointerdown",_),document.removeEventListener("keydown",J)}},[d]),t.jsxs("section",{className:"mobile-feature-panel surface-card mobile-butler-timer-banner","aria-live":"polite",children:[t.jsxs("div",{className:"mobile-butler-timer-status",children:[t.jsx("span",{className:"mobile-butler-timer-pulse","aria-hidden":"true"}),t.jsx("span",{className:"mobile-butler-timer-caption",children:l("shell.butlerControlTimerBannerTitle")})]}),t.jsxs("div",{className:"mobile-butler-timer-display-panel",children:[t.jsx("p",{className:"mobile-butler-timer-display-clock",children:h}),t.jsx("p",{className:"mobile-butler-timer-countdown",children:f})]}),t.jsxs("div",{className:"mobile-butler-timer-meta",children:[t.jsxs("div",{className:"mobile-butler-timer-meta-card",children:[t.jsx("span",{children:l("shell.butlerControlTimerWorkspaceLabel")}),t.jsx("strong",{title:j,children:j})]}),t.jsxs("div",{className:"mobile-butler-timer-meta-card",children:[t.jsx("span",{children:l("shell.butlerControlTimerSessionLabel")}),D?t.jsx("button",{type:"button",className:"mobile-butler-timer-session-link",title:y,"aria-label":`${l("shell.butlerControlTimerSessionLabel")}:${y}`,style:{padding:0,border:"none",background:"transparent",color:"inherit",font:"inherit",fontWeight:600,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",cursor:"pointer",textDecoration:"underline"},onClick:e.onOpenSession,children:y}):t.jsx("strong",{title:y,children:y})]})]}),t.jsxs("div",{className:"mobile-butler-timer-actions",children:[t.jsxs("div",{className:"mobile-butler-timer-detail",ref:o,children:[t.jsx("button",{id:n,type:"button",className:"mobile-butler-timer-detail-button","aria-label":l("shell.butlerControlTimerDetailAction"),"aria-haspopup":"dialog","aria-expanded":d,"aria-controls":d?s:void 0,title:l("shell.butlerControlTimerDetailAction"),onClick:()=>{c(_=>!_)},children:t.jsx("span",{className:"mobile-butler-timer-detail-icon","aria-hidden":"true",children:t.jsx(Wi,{})})}),t.jsx(Yn,{open:d,id:s,className:"mobile-butler-timer-detail-popover",anchorRef:o,popoverRef:i,labelledBy:n,maxWidth:288,gap:8,viewportPadding:12,children:t.jsxs("div",{children:[t.jsx("strong",{children:l("shell.butlerControlTimerPromptTitle")}),t.jsx("p",{children:L})]})})]}),k?t.jsx("button",{type:"button",className:"secondary-button mobile-butler-timer-action",disabled:e.cancelling||e.executingNow,onClick:e.onExecuteNow,children:e.executingNow?l("shell.butlerControlTimerExecutingNow"):l("shell.butlerControlTimerExecuteNowAction")}):null,t.jsx("button",{type:"button",className:"secondary-button mobile-butler-timer-action",disabled:e.cancelling||e.executingNow,onClick:e.onCancel,children:e.cancelling?l("shell.butlerControlTimerCancelling"):l("shell.butlerControlTimerStopAction")})]}),k?t.jsx("p",{className:"mobile-butler-timer-note",children:l("shell.butlerControlTimerActionNote")}):null]})}function we({label:e,value:n}){return t.jsxs("div",{className:"mobile-butler-info-metric",children:[t.jsx("span",{children:e}),t.jsx("strong",{title:n,children:n})]})}function Ri(e){return t.jsxs("section",{className:"mobile-feature-panel surface-card mobile-butler-record-section",children:[t.jsxs("div",{className:"mobile-feature-section-header",children:[t.jsxs("div",{children:[t.jsx("h2",{children:l("shell.butlerAutomationTasksTitle")}),t.jsx("p",{children:l("shell.butlerAutomationMobileOverviewDescription")})]}),t.jsxs("div",{className:"mobile-feature-section-actions",children:[e.actionLabel&&e.onAction?t.jsx("button",{type:"button",className:"mobile-butler-section-action",onClick:e.onAction,children:e.actionLabel}):null,t.jsx("span",{className:"mobile-feature-counter",children:e.items.length})]})]}),e.items.length>0?t.jsx("div",{className:"mobile-butler-automation-grid",children:e.items.map(n=>t.jsxs("article",{className:"mobile-butler-automation-card","data-selected":e.selectedAutomationId===n.automationId,children:[t.jsxs("header",{className:"mobile-butler-record-header",children:[t.jsxs("div",{className:"mobile-butler-record-copy",children:[t.jsx("strong",{children:n.title}),t.jsx("span",{children:n.projectName})]}),t.jsx("span",{className:"mobile-butler-record-badge",children:n.statusLabel})]}),t.jsxs("div",{className:"mobile-butler-automation-chip-row",children:[t.jsx("span",{className:"mobile-butler-automation-chip",children:n.taskTypeLabel}),n.targetSessionTitle?t.jsx("span",{className:"mobile-butler-automation-chip",children:n.targetSessionTitle}):null]}),t.jsxs("div",{className:"mobile-butler-automation-metric-grid",children:[t.jsxs("div",{className:"mobile-butler-automation-metric",children:[t.jsx("span",{children:l("shell.butlerAutomationTaskNextRunLabel")}),t.jsx("strong",{children:Q(n.nextRunAt)})]}),t.jsxs("div",{className:"mobile-butler-automation-metric",children:[t.jsx("span",{children:l("shell.butlerAutomationTaskLastRunLabel")}),t.jsx("strong",{children:Q(n.lastRunAt)})]})]}),t.jsx("p",{className:"mobile-butler-automation-summary",children:n.promptPreview}),n.lastResultSummary?t.jsx("p",{className:"mobile-butler-automation-footnote",children:n.lastResultSummary}):null,t.jsxs("footer",{className:"mobile-butler-record-footer",children:[t.jsx("button",{type:"button",className:"secondary-button mobile-butler-record-action",onClick:()=>{n.automationId&&e.onSelectAutomation(n.automationId)},children:e.selectedAutomationId===n.automationId?l("shell.butlerAutomationCollapseDetailsAction"):l("shell.butlerAutomationOpenDetailsAction")}),n.automationId&&n.status==="active"?t.jsx("button",{type:"button",className:"secondary-button mobile-butler-record-action",disabled:e.cancellingAutomationId===n.automationId,onClick:()=>{e.onCancelAutomation(n.automationId)},children:e.cancellingAutomationId===n.automationId?l("shell.butlerControlTimerCancelling"):l("shell.butlerControlTimerStopAction")}):null]})]},n.id))}):t.jsx("p",{className:"mobile-butler-empty-text",children:e.emptyText})]})}function ki(e){var o,i,d;const n=(o=e.automation.projectId)!=null&&o.trim()?e.workspaceNameById.get(((d=(i=e.automation.controlSession)==null?void 0:i.session)==null?void 0:d.workspaceId)??""):null,s=Cs(e.automation,e.sessionTitleById);return t.jsxs("section",{className:"mobile-feature-panel surface-card mobile-butler-record-section mobile-butler-automation-detail-panel",children:[t.jsxs("div",{className:"mobile-feature-section-header",children:[t.jsxs("div",{children:[t.jsx("h2",{children:l("shell.butlerAutomationDetailTitle")}),t.jsx("p",{children:l("shell.butlerAutomationDetailDescription")})]}),t.jsx("button",{type:"button",className:"mobile-butler-section-action",onClick:e.onClose,children:l("common.close")})]}),t.jsxs("div",{className:"mobile-butler-automation-detail-summary",children:[t.jsx(we,{label:l("shell.butlerAutomationTaskTypeLabel"),value:ys(e.automation.triggerType)}),t.jsx(we,{label:l("shell.butlerAutomationStatusLabel"),value:Ss(e.automation.status)}),t.jsx(we,{label:l("shell.butlerAutomationTaskNextRunLabel"),value:Q(e.automation.nextRunAt)}),t.jsx(we,{label:l("shell.butlerAutomationTaskLastRunLabel"),value:Q(e.automation.lastRunAt||e.automation.updatedAt)}),n?t.jsx(we,{label:l("shell.mobileButlerAssistantWorkspaceLabel"),value:n}):null,s?t.jsx(we,{label:l("shell.butlerAutomationTargetSessionLabel"),value:s}):null]}),t.jsxs("div",{className:"mobile-butler-automation-form-grid",children:[t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationTitleLabel")}),t.jsx("input",{className:"butler-form-control",value:e.editorState.title,disabled:e.saving,onChange:c=>{e.onEditorChange({title:c.target.value})}})]}),t.jsxs("label",{className:"butler-form-field butler-form-field-wide",children:[t.jsx("span",{children:l("shell.butlerAutomationPromptLabel")}),t.jsx("textarea",{className:"butler-form-control mobile-butler-automation-textarea",value:e.editorState.content,disabled:e.saving,onChange:c=>{e.onEditorChange({content:c.target.value})}})]}),t.jsxs("label",{className:"mobile-butler-automation-toggle",children:[t.jsx("input",{type:"checkbox",checked:e.editorState.includeTriggerContext,disabled:e.saving,onChange:c=>{e.onEditorChange({includeTriggerContext:c.target.checked})}}),t.jsx("span",{children:l("shell.butlerAutomationIncludeTriggerContextLabel")})]}),t.jsx(Li,{automation:e.automation,editorState:e.editorState,saving:e.saving,onEditorChange:e.onEditorChange})]}),e.recentRuns.length>0?t.jsxs("div",{className:"mobile-butler-automation-detail-runs",children:[t.jsxs("div",{className:"mobile-feature-section-header",children:[t.jsx("div",{children:t.jsx("h2",{children:l("shell.butlerAutomationRunsTitle")})}),t.jsx("span",{className:"mobile-feature-counter",children:e.recentRuns.length})]}),t.jsx("div",{className:"mobile-butler-record-list",children:e.recentRuns.map(c=>{var f,h;return t.jsxs("article",{className:"mobile-butler-record-card",children:[t.jsxs("header",{className:"mobile-butler-record-header",children:[t.jsxs("div",{className:"mobile-butler-record-copy",children:[t.jsx("strong",{children:l("shell.butlerAutomationRoundLabel",{round:c.runSeq})}),t.jsx("span",{children:ps(c.triggerType)})]}),t.jsx("span",{className:"mobile-butler-record-badge",children:js(c.status)})]}),t.jsx("p",{children:((f=c.summary)==null?void 0:f.trim())||((h=c.error)==null?void 0:h.trim())||l("shell.butlerAutomationRunEmptySummary")}),t.jsx("footer",{className:"mobile-butler-record-footer",children:t.jsx("span",{children:Q(c.createdAt)})})]},c.id)})})]}):null,t.jsxs("footer",{className:"mobile-butler-automation-detail-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:e.saving,onClick:e.onClose,children:l("common.close")}),t.jsx("button",{type:"button",className:"primary-button",disabled:e.saving,onClick:e.onSave,children:e.saving?l("shell.butlerAutomationSaving"):l("shell.butlerAutomationSaveAction")})]})]})}function Li(e){const{triggerConfig:n}=e.automation;return n.type==="once"?t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationDueAtLabel")}),t.jsx("input",{type:"datetime-local",className:"butler-form-control",value:e.editorState.dueAt,disabled:e.saving,onChange:s=>{e.onEditorChange({dueAt:s.target.value})}})]}):n.type==="interval"?t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationEverySecondsLabel")}),t.jsx("input",{inputMode:"numeric",className:"butler-form-control",value:e.editorState.everySeconds,disabled:e.saving,onChange:s=>{e.onEditorChange({everySeconds:s.target.value})}})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationEveryMinutesLabel")}),t.jsx("input",{inputMode:"numeric",className:"butler-form-control",value:e.editorState.everyMinutes,disabled:e.saving,onChange:s=>{e.onEditorChange({everyMinutes:s.target.value})}})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationEveryHoursLabel")}),t.jsx("input",{inputMode:"numeric",className:"butler-form-control",value:e.editorState.everyHours,disabled:e.saving,onChange:s=>{e.onEditorChange({everyHours:s.target.value})}})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationStopAtLabel")}),t.jsx("input",{type:"datetime-local",className:"butler-form-control",value:e.editorState.stopAt,disabled:e.saving,onChange:s=>{e.onEditorChange({stopAt:s.target.value})}})]})]}):n.type==="cron"?t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationCronMinuteLabel")}),t.jsx("input",{inputMode:"numeric",className:"butler-form-control",value:e.editorState.cronMinute,disabled:e.saving,onChange:s=>{e.onEditorChange({cronMinute:s.target.value})}})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationCronHourLabel")}),t.jsx("input",{inputMode:"numeric",className:"butler-form-control",value:e.editorState.cronHour,disabled:e.saving,onChange:s=>{e.onEditorChange({cronHour:s.target.value})}})]}),t.jsxs("label",{className:"butler-form-field butler-form-field-wide",children:[t.jsx("span",{children:l("shell.butlerAutomationCronDaysOfWeekLabel")}),t.jsx("input",{className:"butler-form-control",value:e.editorState.cronDaysOfWeek,disabled:e.saving,onChange:s=>{e.onEditorChange({cronDaysOfWeek:s.target.value})}})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationStopAtLabel")}),t.jsx("input",{type:"datetime-local",className:"butler-form-control",value:e.editorState.stopAt,disabled:e.saving,onChange:s=>{e.onEditorChange({stopAt:s.target.value})}})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationPollIntervalLabel")}),t.jsx("input",{inputMode:"numeric",className:"butler-form-control",value:e.editorState.pollIntervalSeconds,disabled:e.saving,onChange:s=>{e.onEditorChange({pollIntervalSeconds:s.target.value})}})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationMaxChecksLabel")}),t.jsx("input",{inputMode:"numeric",className:"butler-form-control",value:e.editorState.maxChecks,disabled:e.saving,onChange:s=>{e.onEditorChange({maxChecks:s.target.value})}})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationExpiresAtLabel")}),t.jsx("input",{type:"datetime-local",className:"butler-form-control",value:e.editorState.expiresAt,disabled:e.saving,onChange:s=>{e.onEditorChange({expiresAt:s.target.value})}})]})]})}function Nt(e){return t.jsxs("section",{className:"mobile-feature-panel surface-card mobile-butler-record-section",children:[t.jsxs("div",{className:"mobile-feature-section-header",children:[t.jsx("div",{children:t.jsx("h2",{children:e.title})}),t.jsxs("div",{className:"mobile-feature-section-actions",children:[e.actionLabel&&e.onAction?t.jsx("button",{type:"button",className:"mobile-butler-section-action",onClick:e.onAction,children:e.actionLabel}):null,t.jsx("span",{className:"mobile-feature-counter",children:e.items.length})]})]}),e.items.length>0?t.jsx("div",{className:"mobile-butler-record-list",children:e.items.map(n=>t.jsxs("article",{className:"mobile-butler-record-card",children:[t.jsxs("header",{className:"mobile-butler-record-header",children:[t.jsxs("div",{className:"mobile-butler-record-copy",children:[t.jsx("strong",{children:n.title}),n.subtitle?t.jsx("span",{children:n.subtitle}):null]}),n.status?t.jsx("span",{className:"mobile-butler-record-badge",children:n.status}):null]}),t.jsx("p",{children:n.content}),n.meta||n.actionLabel?t.jsxs("footer",{className:"mobile-butler-record-footer",children:[n.meta?t.jsx("span",{children:n.meta}):t.jsx("span",{}),n.actionLabel&&n.onAction?t.jsx("button",{type:"button",className:"secondary-button mobile-butler-record-action",disabled:n.actionDisabled,onClick:n.onAction,children:n.actionLabel}):null]}):null]},n.id))}):t.jsx("p",{className:"mobile-butler-empty-text",children:e.emptyText})]})}function Ei(e){return t.jsxs("section",{className:"mobile-feature-panel surface-card mobile-butler-record-section mobile-butler-record-section-compact",children:[t.jsxs("div",{className:"mobile-feature-section-header",children:[t.jsx("div",{children:t.jsx("h2",{children:e.title})}),e.actionLabel&&e.onAction?t.jsx("button",{type:"button",className:"mobile-butler-section-action",onClick:e.onAction,children:e.actionLabel}):null]}),e.items.length>0?t.jsx("div",{className:"mobile-butler-record-list mobile-butler-record-list-compact",children:e.items.map(n=>t.jsxs("article",{className:"mobile-butler-compact-record",children:[t.jsx("span",{children:n.title}),t.jsx("strong",{children:n.content})]},n.id))}):t.jsx("p",{className:"mobile-butler-empty-text",children:e.emptyText})]})}function Tl(e){return t.jsxs("section",{className:"mobile-feature-panel surface-card mobile-butler-record-section",children:[t.jsxs("div",{className:"mobile-feature-section-header",children:[t.jsxs("div",{children:[t.jsx("h2",{children:e.title}),t.jsx("p",{children:e.description})]}),t.jsx("button",{type:"button",className:"mobile-butler-section-action",onClick:e.onClose,children:l("common.close")})]}),e.items.length>0?t.jsx("div",{className:"mobile-butler-record-list",children:e.items.map(n=>t.jsxs("article",{className:"mobile-butler-record-card",children:[t.jsxs("header",{className:"mobile-butler-record-header",children:[t.jsxs("div",{className:"mobile-butler-record-copy",children:[t.jsx("strong",{children:n.title}),n.subtitle?t.jsx("span",{children:n.subtitle}):null]}),n.status?t.jsx("span",{className:"mobile-butler-record-badge",children:n.status}):null]}),t.jsx("p",{children:n.content}),n.meta||n.actionLabel?t.jsxs("footer",{className:"mobile-butler-record-footer",children:[n.meta?t.jsx("span",{children:n.meta}):t.jsx("span",{}),n.actionLabel&&n.onAction?t.jsx("button",{type:"button",className:"secondary-button mobile-butler-record-action",disabled:n.actionDisabled,onClick:n.onAction,children:n.actionLabel}):null]}):null]},n.id))}):t.jsx("p",{className:"mobile-butler-empty-text",children:e.emptyText})]})}function Mi(e){return t.jsxs("div",{className:"mobile-butler-history-stack",children:[t.jsxs("section",{className:"mobile-feature-panel surface-card mobile-butler-record-section",children:[t.jsxs("div",{className:"mobile-feature-section-header",children:[t.jsxs("div",{children:[t.jsx("h2",{children:l("shell.butlerAutomationHistoryTitle")}),t.jsx("p",{children:l("shell.butlerAutomationHistoryDescription")})]}),t.jsx("button",{type:"button",className:"mobile-butler-section-action",onClick:e.onClose,children:l("common.close")})]}),e.taskItems.length===0&&e.runItems.length===0?t.jsx("p",{className:"mobile-butler-empty-text",children:l("shell.butlerAutomationHistoryEmpty")}):null]}),e.taskItems.length>0?t.jsx(Nt,{title:l("shell.butlerAutomationTasksTitle"),emptyText:l("shell.butlerAutomationHistoryEmpty"),items:e.taskItems.map(n=>({id:n.id,title:n.title,subtitle:n.projectName,status:n.statusLabel,content:`${l("shell.butlerAutomationTaskTypeLabel")} · ${n.taskTypeLabel}`,meta:`${l("shell.butlerAutomationTaskLastRunLabel")} · ${Q(n.lastRunAt)}`}))}):null,e.runItems.length>0?t.jsx(Nt,{title:l("shell.butlerAutomationRunsTitle"),emptyText:l("shell.butlerAutomationHistoryEmpty"),items:e.runItems.map(n=>({id:n.id,title:n.title,subtitle:n.projectName,status:n.statusLabel,content:`${n.sourceLabel} · ${n.summary}`,meta:Q(n.createdAt)}))}):null]})}function Fi(e){return e.sessions.length===0?t.jsx("p",{className:"mobile-butler-empty-text",children:l("shell.butlerHistoryEmpty")}):t.jsx("div",{className:"mobile-butler-record-list",children:e.sessions.map(n=>{var i,d,c,f,h;const s=n.id===e.activeControlSessionId,o=((i=n.title)==null?void 0:i.trim())||((d=n.session.title)==null?void 0:d.trim())||((c=n.lastSummary)==null?void 0:c.trim())||n.sessionId;return t.jsxs("article",{className:"mobile-butler-record-card mobile-butler-history-card","data-active":s,children:[t.jsxs("header",{className:"mobile-butler-record-header",children:[t.jsxs("div",{className:"mobile-butler-record-copy",children:[t.jsx("strong",{children:o}),t.jsx("span",{children:Q(n.updatedAt)})]}),s?t.jsx("span",{className:"mobile-butler-record-badge",children:l("shell.butlerCurrentSessionBadge")}):null]}),t.jsx("p",{children:((f=n.lastSummary)==null?void 0:f.trim())||((h=n.session.title)==null?void 0:h.trim())||n.sessionId}),t.jsxs("footer",{className:"mobile-butler-record-footer",children:[t.jsx("button",{type:"button",className:"secondary-button mobile-butler-record-action",onClick:()=>{e.onSelectSession(n.id)},children:s?l("shell.butlerCurrentSessionBadge"):l("shell.butlerHistoryOpenAction")}),t.jsx("button",{type:"button",className:"secondary-button workbench-danger-button mobile-butler-record-action",disabled:e.deletingSessionId===n.id,"aria-label":l("shell.butlerHistoryDeleteAction"),onClick:()=>{e.onDeleteSession(n)},children:e.deletingSessionId===n.id?l("common.loading"):l("shell.deleteSessionAction")})]})]},n.id)})})}function Pi(e,n,s,o){u.useEffect(()=>{const i=e.current;if(!s||!i){i&&i.style.removeProperty("--mobile-conversation-composer-height");return}if(!n){i.style.removeProperty("--mobile-conversation-composer-height");return}const d=i,c=n;function f(){!e.current||!c.isConnected||d.style.setProperty("--mobile-conversation-composer-height",`${c.offsetHeight}px`)}f();const h=typeof ResizeObserver<"u"?new ResizeObserver(f):null;return h==null||h.observe(c),window.addEventListener("resize",f),()=>{h==null||h.disconnect(),window.removeEventListener("resize",f),i.style.removeProperty("--mobile-conversation-composer-height")}},[n,s,o,e])}function Nl(e,n){return[...e].filter(s=>n==="history"?!kl(s.status):kl(s.status)).sort((s,o)=>E($n(o))-E($n(s))).slice(0,4).map(s=>{var o,i;return{id:s.id,title:((o=s.targetRef)==null?void 0:o.trim())||s.verificationType,subtitle:s.verificationType,status:Oi(s.status),content:((i=s.summary)==null?void 0:i.trim())||l("shell.butlerInfoVerificationFallback",{status:s.status}),meta:Q($n(s)),verification:{id:s.id,projectId:s.projectId,status:s.status}}})}function Di(e){return e.map(n=>({title:n.title,content:`${n.projectName} · ${qi(n.status)}`}))}function Il(e,n){const s=e.filter(o=>o.id!==n.id);return[n,...s].sort((o,i)=>E(El(i))-E(El(o)))}function On(e,n){const s=e.filter(o=>o.id!==n.id);return[n,...s].sort((o,i)=>E(Ul(i))-E(Ul(o)))}function Ui(e,n){const s=e.filter(o=>o.id!==n.id);return[n,...s].sort((o,i)=>E(ve(i))-E(ve(o)))}function Rl(e){return e==="active"||e==="waiting_user"}function an(e){return e==="active"||e==="waiting_user"}function kl(e){return e==="queued"||e==="running"}function Ll(e){return e==="queued"||e==="running"}function Oi(e){switch(e){case"queued":case"running":return l("shell.butlerAutomationStatusActive");case"passed":case"skipped":return l("shell.butlerAutomationStatusCompleted");case"failed":return l("shell.butlerAutomationStatusFailed");case"cancelled":return l("shell.butlerAutomationStatusCancelled");default:return e}}function El(e){return e.dueAt||e.triggeredAt||e.cancelledAt||e.updatedAt||e.createdAt}function $i(e){var n,s,o,i,d,c;return((n=e.title)==null?void 0:n.trim())||((o=(s=e.controlSession)==null?void 0:s.title)==null?void 0:o.trim())||((c=(d=(i=e.controlSession)==null?void 0:i.session)==null?void 0:d.title)==null?void 0:c.trim())||e.content.trim()}function Hi(e){return e.content.trim()||$i(e)}function Bi(e,n,s,o,i){var f,h,j,y;const d=(f=e.projectId)==null?void 0:f.trim();if(d&&n.has(d))return n.get(d);const c=((y=(j=(h=e.controlSession)==null?void 0:h.session)==null?void 0:j.workspaceId)==null?void 0:y.trim())||o.trim();return c?s.has(c)?s.get(c):c===o.trim()&&(i!=null&&i.trim())?i.trim():l("shell.butlerControlTimerUnknownWorkspace"):l("shell.butlerControlTimerUnknownWorkspace")}function _i(e,n,s,o,i){var f;if(e.kind==="timer")return Bi(e.timer,n,s,o,i);const d=(f=e.automation.projectId)==null?void 0:f.trim();if(d&&n.has(d))return n.get(d);const c=el(e)||o.trim();return c?s.has(c)?s.get(c):c===o.trim()&&(i!=null&&i.trim())?i.trim():l("shell.butlerControlTimerUnknownWorkspace"):l("shell.butlerControlTimerUnknownWorkspace")}function Vi(e,n){var i,d,c,f,h,j,y;const s=(i=e.targetSessionId)==null?void 0:i.trim();if(s&&n.has(s))return n.get(s);if((f=(c=(d=e.controlSession)==null?void 0:d.session)==null?void 0:c.title)!=null&&f.trim())return e.controlSession.session.title.trim();const o=((y=(j=(h=e.controlSession)==null?void 0:h.session)==null?void 0:j.sessionId)==null?void 0:y.trim())||e.sessionId.trim();return o&&n.has(o)?n.get(o):l("shell.butlerControlTimerUnknownSession")}function zi(e,n){var o,i,d;if(e.kind==="timer")return Vi(e.timer,n);const s=tl(e);return s&&n.has(s)?n.get(s):(d=(i=(o=e.automation.controlSession)==null?void 0:o.session)==null?void 0:i.title)!=null&&d.trim()?e.automation.controlSession.session.title.trim():l("shell.butlerControlTimerUnknownSession")}function Wi(){return t.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",focusable:"false",children:t.jsx("path",{fill:"currentColor",d:"M8 1.25a6.75 6.75 0 1 0 0 13.5A6.75 6.75 0 0 0 8 1.25Zm0 1.5a5.25 5.25 0 1 1 0 10.5A5.25 5.25 0 0 1 8 2.75Zm0 2.5a.875.875 0 1 0 0 1.75a.875.875 0 0 0 0-1.75Zm-.875 3.125a.625.625 0 1 0 0 1.25h.25v1.75h-.25a.625.625 0 1 0 0 1.25h1.75a.625.625 0 1 0 0-1.25h-.25V9a.625.625 0 0 0-.625-.625h-.875Z"})})}function Ml(e,n,s,o="active"){const i=new Map(((n==null?void 0:n.projects)??[]).filter(c=>s.has(c.id)).map(c=>[c.id,c.name]));return e.filter(c=>Ts(c,s,n)).filter(c=>o==="history"?c.status!=="active":c.status==="active").map(c=>{var f,h;return{id:`assistant-automation:${c.id}`,automationId:c.id,kind:"assistant_automation",title:As(c),projectName:ws(c,i),status:Ji(c.status),taskTypeLabel:ys(c.triggerType),statusLabel:Ss(c.status),nextRunAt:c.nextRunAt,lastRunAt:c.lastRunAt||c.updatedAt,promptPreview:er(c.actionConfig.content),lastResultSummary:((f=c.lastRunSummary)==null?void 0:f.trim())||((h=c.lastError)==null?void 0:h.trim())||null,targetSessionTitle:Cs(c)}}).sort((c,f)=>{const h=E(c.nextRunAt),j=E(f.nextRunAt);return h!==j?h===0?1:j===0?-1:h-j:E(f.lastRunAt)-E(c.lastRunAt)}).slice(0,8)}function Fl(e,n,s,o,i="active"){const d=new Map(((s==null?void 0:s.projects)??[]).filter(h=>o.has(h.id)).map(h=>[h.id,h.name])),c=new Map(e.filter(h=>Ts(h,o,s)).map(h=>[h.id,h]));return n.map(h=>({run:h,automation:c.get(h.automationId),normalizedStatus:Qi(h.status)})).filter(({automation:h})=>!!h).filter(({normalizedStatus:h})=>i==="history"?!Ol(h):Ol(h)).map(({run:h,automation:j,normalizedStatus:y})=>{var L,$;return{id:`assistant-automation-run:${h.id}`,kind:"assistant_automation_run",title:As(j),projectName:ws(j,d),status:y,sourceLabel:ps(h.triggerType),statusLabel:js(h.status),summary:((L=h.summary)==null?void 0:L.trim())||(($=h.error)==null?void 0:$.trim())||l("shell.butlerAutomationRunEmptySummary"),createdAt:h.finishedAt||h.startedAt||h.createdAt}}).sort((h,j)=>E(j.createdAt)-E(h.createdAt)).slice(0,10)}function qi(e){switch(e){case"pending":return l("shell.butlerInfoTodoPending");case"in_progress":return l("shell.butlerInfoTodoInProgress");case"closed":return l("shell.butlerInfoTodoClosed");default:return l("shell.butlerInfoTodoPending")}}function ve(e){return e.updatedAt||e.lastAutomationAt||e.lastCheckedAt||e.createdAt}function Ki(e){return e.kind==="timer"?e.timer.id:e.automation.id}function pn(e){return e.kind==="timer"?e.timer.dueAt:e.automation.nextRunAt}function el(e){var n,s,o,i,d,c;return e.kind==="timer"?((o=(s=(n=e.timer.controlSession)==null?void 0:n.session)==null?void 0:s.workspaceId)==null?void 0:o.trim())||null:((c=(d=(i=e.automation.controlSession)==null?void 0:i.session)==null?void 0:d.workspaceId)==null?void 0:c.trim())||null}function tl(e){var n,s,o,i,d,c,f,h,j,y,L;return e.kind==="timer"?((n=e.timer.targetSessionId)==null?void 0:n.trim())||((i=(o=(s=e.timer.controlSession)==null?void 0:s.session)==null?void 0:o.sessionId)==null?void 0:i.trim())||((d=e.timer.sessionId)==null?void 0:d.trim())||null:((c=e.automation.actionConfig.targetSessionId)==null?void 0:c.trim())||((j=(h=(f=e.automation.controlSession)==null?void 0:f.session)==null?void 0:h.sessionId)==null?void 0:j.trim())||((L=(y=e.automation.controlSession)==null?void 0:y.sessionId)==null?void 0:L.trim())||null}function Yi(e){return e.kind==="timer"||e.automation.triggerType==="once"}function Zi(e,n){const s=E(pn(e));return!s||s<=n?l("shell.butlerControlTimerCountdownDueNow"):l("shell.butlerControlTimerCountdownActive",{duration:ir(s-n)})}function Xi(e,n){const s=E(pn(e));return!s||s<=n?"00:00":rr(s-n)}function Gi(e){return e.kind==="timer"?Hi(e.timer):e.automation.actionConfig.content.trim()||l("conversation.butlerAnalysisEmpty")}function Pl(e){switch(e){case"active":return l("shell.butlerAutomationStatusActive");case"waiting_user":return l("shell.butlerAutomationStatusWaitingUser");case"completed":return l("shell.butlerAutomationStatusCompleted");case"failed":return l("shell.butlerAutomationStatusFailed");case"cancelled":return l("shell.butlerAutomationStatusCancelled");default:return l("shell.butlerAutomationStatusActive")}}function ys(e){switch(e){case"once":return l("shell.butlerAutomationTaskTypeControlTimer");case"interval":return l("shell.butlerAutomationTaskTypeInterval");case"cron":return l("shell.butlerAutomationTaskTypeCron");case"condition":return l("shell.butlerAutomationTaskTypeFollowUp");default:return l("shell.butlerAutomationTaskTypeControlTimer")}}function ps(e){return e==="interval"||e==="cron"?l("shell.butlerAutomationRunSourcePatrol"):e==="once"?l("shell.butlerAutomationRunSourceControlTimer"):l("shell.butlerAutomationRunSourceFollowUp")}function Qi(e){switch(e){case"failed":return"failed";case"cancelled":return"cancelled";case"completed":case"passed":case"succeeded":return"completed";case"waiting_user":return"waiting_user";case"active":case"queued":case"running":default:return"active"}}function Ji(e){switch(e){case"failed":return"failed";case"cancelled":return"cancelled";case"completed":return"completed";case"paused":return"waiting_user";case"active":default:return"active"}}function Ss(e){switch(e){case"completed":return l("shell.butlerAutomationStatusCompleted");case"failed":return l("shell.butlerAutomationStatusFailed");case"cancelled":return l("shell.butlerAutomationStatusCancelled");case"paused":return l("shell.butlerAutomationStatusWaitingUser");case"active":default:return l("shell.butlerAutomationStatusActive")}}function js(e){switch(e){case"succeeded":return l("shell.butlerAutomationStatusCompleted");case"failed":return l("shell.butlerAutomationStatusFailed");case"cancelled":case"skipped":return l("shell.butlerAutomationStatusCancelled");case"queued":case"running":default:return l("shell.butlerAutomationStatusActive")}}function As(e){var n,s;return((n=e.title)==null?void 0:n.trim())||((s=e.actionConfig.targetSessionId)==null?void 0:s.trim())||e.actionConfig.content.trim()||e.id}function ws(e,n){var s,o;return e.projectId&&n.has(e.projectId)?n.get(e.projectId):((o=(s=e.controlSession)==null?void 0:s.session)==null?void 0:o.workspaceId)||l("shell.butlerControlTimerNoProject")}function Cs(e,n=new Map){var o,i,d,c;const s=(o=e.actionConfig.targetSessionId)==null?void 0:o.trim();return s&&n.has(s)?n.get(s):(c=(d=(i=e.controlSession)==null?void 0:i.session)==null?void 0:d.title)!=null&&c.trim()?e.controlSession.session.title.trim():s||null}function er(e){const n=e.replace(/\s+/g," ").trim();return n?n.length<=72?n:`${n.slice(0,72)}...`:l("conversation.butlerAnalysisEmpty")}function Dl(e){var s;const n={title:((s=e.title)==null?void 0:s.trim())||"",content:e.actionConfig.content,includeTriggerContext:e.actionConfig.includeTriggerContext,dueAt:"",everySeconds:"",everyMinutes:"",everyHours:"",stopAt:"",cronMinute:"",cronHour:"",cronDaysOfWeek:"",pollIntervalSeconds:"",expiresAt:"",maxChecks:""};return e.triggerConfig.type==="once"?n.dueAt=un(e.triggerConfig.dueAt):e.triggerConfig.type==="interval"?(n.everySeconds=_e(e.triggerConfig.seconds),n.everyMinutes=_e(e.triggerConfig.minutes),n.everyHours=_e(e.triggerConfig.hours),n.stopAt=un(e.triggerConfig.stopAt)):e.triggerConfig.type==="cron"?(n.cronMinute=_e(e.triggerConfig.minute),n.cronHour=_e(e.triggerConfig.hour),n.cronDaysOfWeek=(e.triggerConfig.daysOfWeek??[]).join(","),n.stopAt=un(e.triggerConfig.stopAt)):(n.pollIntervalSeconds=_e(e.triggerConfig.pollIntervalSeconds),n.expiresAt=un(e.triggerConfig.expiresAt),n.maxChecks=_e(e.triggerConfig.maxChecks)),n}function tr(e,n){const s={title:nr(n.title),content:n.content.trim(),includeTriggerContext:n.includeTriggerContext};if(!s.content)throw new Error(l("shell.butlerAutomationPromptRequired"));return e.triggerConfig.type==="once"?{...s,dueAt:lr(n.dueAt,l("shell.butlerAutomationDueAtLabel"))}:e.triggerConfig.type==="interval"?{...s,everySeconds:cn(n.everySeconds,l("shell.butlerAutomationEverySecondsLabel")),everyMinutes:cn(n.everyMinutes,l("shell.butlerAutomationEveryMinutesLabel")),everyHours:cn(n.everyHours,l("shell.butlerAutomationEveryHoursLabel")),stopAt:hn(n.stopAt,l("shell.butlerAutomationStopAtLabel"))}:e.triggerConfig.type==="cron"?{...s,cronMinute:Ns(n.cronMinute,l("shell.butlerAutomationCronMinuteLabel")),cronHour:Is(n.cronHour,l("shell.butlerAutomationCronHourLabel")),cronDaysOfWeek:or(n.cronDaysOfWeek),stopAt:hn(n.stopAt,l("shell.butlerAutomationStopAtLabel"))}:{...s,pollIntervalSeconds:sr(n.pollIntervalSeconds,l("shell.butlerAutomationPollIntervalLabel")),expiresAt:hn(n.expiresAt,l("shell.butlerAutomationExpiresAtLabel")),maxChecks:cn(n.maxChecks,l("shell.butlerAutomationMaxChecksLabel"))}}function Ul(e){return e.updatedAt||e.lastRunAt||e.nextRunAt||e.createdAt}function Ts(e,n,s){var i,d,c;if(e.projectId&&n.has(e.projectId))return!0;const o=(c=(d=(i=e.controlSession)==null?void 0:i.session)==null?void 0:d.workspaceId)==null?void 0:c.trim();return o?((s==null?void 0:s.projects)??[]).some(f=>f.workspaceId===o&&n.has(f.id)):!1}function Ol(e){return e==="active"||e==="waiting_user"}function $n(e){return e.finishedAt||e.startedAt||e.createdAt}function E(e){if(!e)return 0;const n=new Date(e).getTime();return Number.isNaN(n)?0:n}function _e(e){return typeof e=="number"&&Number.isFinite(e)?String(e):""}function nr(e){const n=e.trim();return n||null}function un(e){if(!e)return"";const n=new Date(e);if(Number.isNaN(n.getTime()))return"";const s=n.getFullYear(),o=String(n.getMonth()+1).padStart(2,"0"),i=String(n.getDate()).padStart(2,"0"),d=String(n.getHours()).padStart(2,"0"),c=String(n.getMinutes()).padStart(2,"0");return`${s}-${o}-${i}T${d}:${c}`}function hn(e,n){const s=e.trim();if(!s)return null;const o=Date.parse(s);if(Number.isNaN(o))throw new Error(`${n}${l("shell.butlerAutomationInvalidDateSuffix")}`);return new Date(o).toISOString()}function lr(e,n){const s=hn(e,n);if(!s)throw new Error(`${n}${l("shell.butlerAutomationRequiredSuffix")}`);return s}function Ns(e,n){const s=e.trim();if(!s)throw new Error(`${n}${l("shell.butlerAutomationRequiredSuffix")}`);const o=Number.parseInt(s,10);if(!Number.isInteger(o))throw new Error(`${n}${l("shell.butlerAutomationInvalidNumberSuffix")}`);return o}function Is(e,n){const s=e.trim();if(!s)return null;const o=Number.parseInt(s,10);if(!Number.isInteger(o))throw new Error(`${n}${l("shell.butlerAutomationInvalidNumberSuffix")}`);return o}function cn(e,n){const s=Is(e,n);if(s===null)return null;if(s<=0)throw new Error(`${n}${l("shell.butlerAutomationInvalidPositiveNumberSuffix")}`);return s}function sr(e,n){const s=Ns(e,n);if(s<=0)throw new Error(`${n}${l("shell.butlerAutomationInvalidPositiveNumberSuffix")}`);return s}function or(e){const n=e.trim();if(!n)return null;const s=n.split(",").map(o=>Number.parseInt(o.trim(),10)).filter(o=>Number.isInteger(o));if(s.length===0||s.some(o=>o<0||o>6))throw new Error(l("shell.butlerAutomationCronDaysValidation"));return Array.from(new Set(s)).sort((o,i)=>o-i)}function Q(e){if(!e)return"-";const n=new Date(e);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(n)}function ir(e){const n=Math.max(1,Math.ceil(e/1e3)),s=Math.floor(n/3600),o=Math.floor(n%3600/60),i=n%60,d=(c,f)=>new Intl.NumberFormat(void 0,{style:"unit",unit:f,unitDisplay:"narrow"}).format(c);return s>0?[d(s,"hour"),d(Math.max(o,0),"minute")].join(" "):o>0?[d(o,"minute"),d(i,"second")].join(" "):d(i,"second")}function rr(e){const n=Math.max(0,Math.ceil(e/1e3)),s=Math.floor(n/3600),o=Math.floor(n%3600/60),i=n%60;return s>0?`${String(s).padStart(2,"0")}:${String(o).padStart(2,"0")}:${String(i).padStart(2,"0")}`:`${String(o).padStart(2,"0")}:${String(i).padStart(2,"0")}`}function $l(e){switch(e){case"claude-code":return"Claude Code";case"codex":default:return"Codex"}}function Sr(){const{shellMode:e}=Kn();return e==="mobile"?t.jsx(Ni,{}):t.jsx(ro,{})}export{Sr as AdaptiveButlerPage};
|
|
1
|
+
import{j as t,t as l,b as u}from"./index-_OCkVmfl.js";import{r as $s,b as Kn,b0 as Hs,z as Bs,b1 as Hl,b2 as N,b3 as fn,as as Bl,b4 as _s,E as _l,H as Vl,b5 as Vs,b6 as zs,b7 as gn,b8 as xn,b9 as zl,ba as Ws,Y as qs,aL as vn,bb as Ks,bc as Yn,ap as Wl,aq as ql,ab as Kl,ar as Yl,aR as Xl,aQ as Hn,bd as Zl,be as Bn,bf as _n,bg as Ql,aF as Ys,aO as Xs,aP as fl}from"./WorkbenchLayout-D-U7ghT0.js";import{e as Zs,c as Gl,u as Jl,f as es,h as Qs}from"./App-If9gThKM.js";import{e as dn,u as gl,D as Vn,v as Gs}from"./workbench-navigation-RyUjchbD.js";import{W as rt}from"./WorkbenchModal-xbx1o6MO.js";import{s as ts}from"./butler-records-events-DgWCG364.js";import{M as Js}from"./MobileSheet-BXvQPkxt.js";import{M as eo}from"./MobileWorkspaceSwitcherHeader-DT330cAx.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./DesktopModal-bMdI1jEe.js";import"./relay-entry-B5GmiOrR.js";import"./MobileTopHeaderFrame-vdYOyaaB.js";function ns(){return t.jsxs("section",{className:"butler-loading-panel",role:"status","aria-live":"polite",children:[t.jsxs("div",{className:"butler-loading-orb","aria-hidden":"true",children:[t.jsx("span",{className:"butler-loading-ring butler-loading-ring-primary"}),t.jsx("span",{className:"butler-loading-ring butler-loading-ring-secondary"}),t.jsx("span",{className:"butler-loading-core"})]}),t.jsxs("div",{className:"butler-loading-copy",children:[t.jsx("h1",{children:l("shell.butlerLoadingTitle")}),t.jsx("p",{children:l("shell.butlerLoadingDescription")})]})]})}const zn={"risk-first":["risk","blocker","verification"],"blocker-first":["blocker","risk","verification"],"verification-first":["verification","risk","blocker"],"progress-first":["progress","risk","blocker"]},ls=300,to=1500,no=1500,lo=480*60*1e3,Wn=["codex","claude-code"],Fn={displayName:"",agentsMode:"inline",agentsFilePath:"",agentsContent:"",personaTone:"direct",personaLanguage:"zh-CN",personaSummaryStyle:"brief",focusRiskPreference:"conservative",reportPriorityPreset:"risk-first",summaryDebounceSeconds:ls},so=[{value:60,labelKey:"shell.butlerSummaryDebounceOption1Minute"},{value:180,labelKey:"shell.butlerSummaryDebounceOption3Minutes"},{value:300,labelKey:"shell.butlerSummaryDebounceOption5Minutes"},{value:600,labelKey:"shell.butlerSummaryDebounceOption10Minutes"},{value:900,labelKey:"shell.butlerSummaryDebounceOption15Minutes"},{value:1800,labelKey:"shell.butlerSummaryDebounceOption30Minutes"}],Ae={builder:["🧠","🤖","🦾","🛠️","⚙️","🧩","🚀","🛰️","🔧","💡"],analyst:["🦉","🧭","🔍","📚","🧪","📐","🗂️","📝","🧮","📊"],direct:["🦅","🛡️","⚡","🎯","🪓","🧱","🔨","📌","🧰","🏹"],steady:["🐢","🐘","🦬","🦫","🌲","⛰️","🪨","🧺","🧷","🕰️"],friendly:["🐼","🦊","🐻","🐶","🐱","🐹","🐰","🦄","🌼","🍀"],default:["🧠","🤖","🦉","🧩","📚","💡","🛠️","🚀","🌟","🪄","🧭","🔮"]};function oo(e){if(typeof document>"u")return!1;const n=document.createElement("textarea");n.value=e,n.setAttribute("readonly","true"),n.style.position="fixed",n.style.opacity="0",n.style.pointerEvents="none",document.body.appendChild(n),n.focus(),n.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(n)}}async function io(e){var n;if(typeof navigator<"u"&&((n=navigator.clipboard)!=null&&n.writeText))try{await navigator.clipboard.writeText(e);return}catch{}if(!oo(e))throw new Error(l("conversation.copyContentFailed"))}function ro(){var il,rl,al,ul,cl,dl,ml,bl,hl;const e=Zs(),n=$s(e),{workspaceId:s=""}=Gl(),o=Jl(),{showToast:i}=es(),{navigationGroups:d,requestNavigationRefresh:c,setAuxiliaryPanel:f}=Kn(),h=u.useRef(null),j=u.useRef(null),[y,L]=u.useState(Hs),[$,D]=u.useState(!1),[k,_]=u.useState(Fn),[J,ee]=u.useState(!1),[te,Y]=u.useState(0),[U,re]=u.useState([]),[H,Ee]=u.useState([]),[nl,Ce]=u.useState([]),[Rt,ce]=u.useState([]),[ze,Te]=u.useState([]),[ne,O]=u.useState([]),[de,Ne]=u.useState([]),[Ie,We]=u.useState(!1),[kt,qe]=u.useState(!1),[Lt,Et]=u.useState(!1),[Ke,Mt]=u.useState(!1),[me,Ye]=u.useState(null),[Re,le]=u.useState(null),[Xe,he]=u.useState(null),[Ft,p]=u.useState(null),[M,Pt]=u.useState(!1),[R,at]=u.useState(""),[fe,X]=u.useState(null),[ae,w]=u.useState(null),[Sn,ut]=u.useState(null),[ye,ct]=u.useState(null),[jn,ke]=u.useState(!1),[Dt,Ze]=u.useState(null),[dt,Qe]=u.useState(null),[mt,bt]=u.useState(null),[Ge,Je]=u.useState(null),[ht,z]=u.useState(null),[ft,gt]=u.useState(null),[et,tt]=u.useState(null),[An,Ut]=u.useState(()=>Date.now()),{items:Ot}=Bs(!0),xt=u.useRef(null),$t=u.useRef(null),se=u.useRef(null),Ht=u.useId(),[Bt,nt]=u.useState({itemId:null,kind:null});(!h.current||j.current!==s)&&(h.current=new Hl(s),j.current=s);const S=h.current,ge=N(S,a=>a.loading),W=N(S,a=>a.sending),pe=N(S,a=>a.switchingProvider),ue=N(S,a=>a.initialized),C=N(S,a=>a.profile),q=N(S,a=>a.activeProvider),g=N(S,a=>a.controlSession),_t=N(S,a=>a.capabilities),F=N(S,a=>a.overview),lt=N(S,a=>a.events),Me=N(S,a=>a.messages),Fe=N(S,a=>a.historyState),wn=N(S,a=>a.loadingOlderMessages),Vt=N(S,a=>a.hasOlderMessages),Pe=N(S,a=>a.runtimeHasActiveRun),De=N(S,a=>a.runtimeCanInterrupt),Cn=N(S,a=>a.contextUsage),vt=N(S,a=>a.permissionRequests),Le=N(S,a=>a.error),zt=u.useRef(null),Wt=u.useRef(null),yt=u.useRef(!1),pt=u.useRef(new Set),Se=((il=C==null?void 0:C.displayName)==null?void 0:il.trim())||y.displayName.trim()||l("shell.butlerEntry"),St=u.useMemo(()=>ui({displayName:Se,providerId:(C==null?void 0:C.providerId)??y.providerId,tone:(C==null?void 0:C.persona.tone)??y.personaTone}),[Se,y.personaTone,y.providerId,C==null?void 0:C.persona.tone,C==null?void 0:C.providerId]),jt=u.useMemo(()=>H.filter(a=>qn(a.status)).slice(0,3),[H]),qt=u.useMemo(()=>So(g,Pe),[g,Pe]),Ue=po((g==null?void 0:g.session.sessionId)??null,qt),Tn=Ue||W,Nn=Ue||W,In=De===!0||W?!0:De??!1,Kt=u.useMemo(()=>{if(!g||Ue)return null;const a=ze.filter(T=>T.status==="active"&&T.controlSessionId===g.id).map(T=>({kind:"timer",timer:T})),m=new Set(ze.filter(T=>T.status==="active"&&T.controlSessionId===g.id).map(T=>T.id)),x=ne.filter(T=>T.status==="active"&&T.controlSessionId===g.id&&!!T.nextRunAt&&!m.has(T.id)).map(T=>({kind:"automation",automation:T}));return[...a,...x].sort((T,B)=>I(It(T))-I(It(B)))[0]??null},[ne,g,ze,Ue]),V=yo(Kt),Yt=u.useMemo(()=>((F==null?void 0:F.projects)??[]).map(a=>a.id).sort(),[F==null?void 0:F.projects]),Rn=((rl=d.find(a=>a.workspace.id===s))==null?void 0:rl.workspace.name)??null,Xt=u.useMemo(()=>new Map(((F==null?void 0:F.projects)??[]).map(a=>[a.id,a.name])),[F==null?void 0:F.projects]),Zt=u.useMemo(()=>new Map(d.map(a=>[a.workspace.id,a.workspace.name])),[d]),At=u.useMemo(()=>new Map(d.flatMap(a=>a.sessions.map(m=>{var x;return[m.sessionId,((x=m.title)==null?void 0:x.trim())||l("common.unknown")]}))),[d]),P=u.useMemo(()=>me?ne.find(a=>a.id===me)??null:null,[ne,me]),Qt=u.useMemo(()=>me?de.filter(a=>a.automationId===me).sort((a,m)=>I(m.createdAt)-I(a.createdAt)).slice(0,8):[],[de,me]);u.useEffect(()=>{me&&!P&&(Ye(null),le(null))},[P,me]);const st=u.useMemo(()=>new Map(d.flatMap(a=>a.sessions.map(m=>[m.sessionId,a.workspace.id]))),[d]);u.useEffect(()=>{if(Ut(Date.now()),!V)return;const a=window.setInterval(()=>{Ut(Date.now())},1e3);return()=>{window.clearInterval(a)}},[V]);const Oe=u.useCallback(async()=>{if(!ue){ce([]);return}try{const a=await fn();ce(a.items)}catch(a){i({title:l("shell.butlerSidebarLoadFailed"),description:a instanceof Error?a.message:void 0,tone:"error"})}},[ue,i]),wt=u.useCallback(()=>{qe(!0)},[]),Ct=u.useCallback(()=>{Et(!0)},[]),Tt=u.useCallback(()=>{Mt(!0)},[]),Gt=u.useCallback(()=>{M||Oe(),Pt(a=>!a)},[M,Oe]),be=u.useCallback(()=>{Pt(!1),at("")},[]),r=u.useCallback(async()=>{if(!(!fe||ae)){w(fe.id);try{await Bl(fe.session.sessionId),fe.id===(g==null?void 0:g.id)&&await S.openControlSession(""),be(),X(null),await Oe(),c(),i({title:l("shell.deleteSessionSuccess"),tone:"success"})}catch(a){i({title:a instanceof Error?a.message:l("shell.deleteSessionFailed"),tone:"error"})}finally{w(null)}}},[g==null?void 0:g.id,fe,ae,be,Oe,c,i,S]);u.useEffect(()=>{if(!M){at("");return}const a=window.requestAnimationFrame(()=>{var m,x;(m=se.current)==null||m.focus(),(x=se.current)==null||x.select()});return()=>{window.cancelAnimationFrame(a)}},[M]),u.useEffect(()=>{if(!M)return;const a=x=>{var B,He;const T=x.target;(B=xt.current)!=null&&B.contains(T)||(He=$t.current)!=null&&He.contains(T)||be()},m=x=>{x.key==="Escape"&&(x.preventDefault(),be())};return document.addEventListener("pointerdown",a),document.addEventListener("keydown",m),()=>{document.removeEventListener("pointerdown",a),document.removeEventListener("keydown",m)}},[M,be]);const b=u.useCallback(a=>{_(m=>({...m,...a}))},[]),v=u.useCallback(async a=>{qe(!1),ut(a),ct(null),Ze(null),ke(!0);try{const m=await _s(a);ct(m.task)}catch(m){Ze(m instanceof Error?m.message:l("shell.butlerAutomationRoundLoadFailed"))}finally{ke(!1)}},[]),A=u.useCallback(async a=>{Qe(a.id);try{const m=await _l(a.id);Ee(x=>yl(x,m.task)),i({title:l("conversation.butlerFollowUpStopped"),description:l("conversation.butlerFollowUpStoppedDescription"),tone:"success"}),await S.reloadEventsAndOverview(),c()}catch(m){i({title:l("conversation.butlerFollowUpStopFailed"),description:m instanceof Error?m.message:void 0,tone:"error"})}finally{Qe(null)}},[c,i,S]),K=u.useCallback(async a=>{bt(a.id);try{await Vl(a.projectId,a.id),i({title:l("conversation.butlerVerificationStopped"),description:l("conversation.butlerVerificationStoppedDescription"),tone:"success"}),await S.reloadEventsAndOverview(),c()}catch(m){i({title:l("conversation.butlerVerificationStopFailed"),description:m instanceof Error?m.message:void 0,tone:"error"})}finally{bt(null)}},[c,i,S]),je=u.useCallback(async a=>{nt({itemId:a.id,kind:"analyze"});try{const m=await Vs(a.id);re(x=>vl(x,m.item)),ce(x=>Uo(x,m.controlSession)),await S.adoptControlSession(m.controlSession),i({title:l("shell.butlerTodoAnalyzeQueued"),tone:"success"})}catch(m){i({title:l("shell.butlerTodoAnalyzeFailed"),description:m instanceof Error?m.message:void 0,tone:"error"})}finally{nt({itemId:null,kind:null})}},[i]),Z=u.useCallback(async a=>{nt({itemId:a.id,kind:"start"});try{const m=await zs(a.id);re(x=>vl(x,m.item)),m.followUpTask&&Ee(x=>yl(x,m.followUpTask)),c(),i({title:l("shell.butlerTodoStartSessionSucceeded"),tone:"success"}),o(dn(m.item.workspaceId,m.session.sessionId))}catch(m){i({title:l("shell.butlerTodoStartSessionFailed"),description:m instanceof Error?m.message:void 0,tone:"error"})}finally{nt({itemId:null,kind:null})}},[o,c,i]),xe=u.useCallback(a=>{var x;const m=(x=a.assistantState.linkedSessionId)==null?void 0:x.trim();m&&o(dn(a.workspaceId,m))},[o]),$e=u.useCallback(async a=>{var x;const m=(x=a.assistantState.generatedPrompt)==null?void 0:x.trim();if(m)try{await io(m),i({title:l("shell.butlerTodoCopyPromptSucceeded"),tone:"success"})}catch(T){i({title:T instanceof Error?T.message:l("conversation.copyContentFailed"),tone:"error"})}},[i]),Q=u.useCallback(async a=>{gt(a);try{const m=await gn(a);Te(x=>pl(x,m.timer)),i({title:l("shell.butlerControlTimerCancelSucceeded"),tone:"success"})}catch(m){i({title:l("shell.butlerControlTimerCancelFailed"),description:m instanceof Error?m.message:void 0,tone:"error"})}finally{gt(null)}},[i]),ot=u.useCallback(async a=>{Je(a);try{const m=await xn(a);O(x=>rn(x,m.payload.automation)),i({title:l("shell.butlerControlTimerCancelSucceeded"),tone:"success"})}catch(m){i({title:l("shell.butlerControlTimerCancelFailed"),description:m instanceof Error?m.message:void 0,tone:"error"})}finally{Je(null)}},[i]),Jt=u.useCallback(a=>{const m=ne.find(x=>x.id===a);m&&(Ye(a),le(Al(m)))},[ne]),kn=u.useCallback(async()=>{if(!P||!Re)return;let a;try{a=ai(P,Re)}catch(m){i({title:l("shell.butlerAutomationSaveFailed"),description:m instanceof Error?m.message:void 0,tone:"error"});return}he(P.id);try{const m=await zl(P.id,a);O(x=>rn(x,m.payload.automation)),Ye(m.payload.automation.id),le(Al(m.payload.automation)),i({title:l("shell.butlerAutomationSaveSucceeded"),tone:"success"})}catch(m){i({title:l("shell.butlerAutomationSaveFailed"),description:m instanceof Error?m.message:void 0,tone:"error"})}finally{he(null)}},[Re,P,i]),Ln=u.useCallback(async a=>{const m=a.content.trim();if(!m){i({title:l("shell.butlerControlTimerExecuteNowFailed"),tone:"error"});return}tt(a.id);try{const x=await gn(a.id);Te(T=>pl(T,x.timer)),await S.sendMessage(m),c(),i({title:l("shell.butlerControlTimerExecuteNowSucceeded"),tone:"success"})}catch(x){i({title:l("shell.butlerControlTimerExecuteNowFailed"),description:x instanceof Error?x.message:void 0,tone:"error"})}finally{tt(null)}},[c,i,S]),en=u.useCallback(async a=>{z(a);try{const m=await Ws(a);O(x=>rn(x,m.payload.automation)),i({title:l("shell.butlerControlTimerCancelSucceeded"),tone:"success"})}catch(m){i({title:l("shell.butlerControlTimerCancelFailed"),description:m instanceof Error?m.message:void 0,tone:"error"})}finally{z(null)}},[i]),En=u.useCallback(async a=>{if(a.kind==="timer"){await Q(a.timer.id);return}await ot(a.automation.id)},[ot,Q]),oe=u.useCallback(async a=>{if(a.kind==="timer"){await Q(a.timer.id);return}await en(a.automation.id)},[Q,en]),Rs=u.useCallback(async a=>{if(a.kind==="timer"){await Ln(a.timer);return}if(a.automation.triggerType!=="once")return;const m=a.automation.actionConfig.content.trim();if(!m){i({title:l("shell.butlerControlTimerExecuteNowFailed"),tone:"error"});return}tt(a.automation.id);try{await xn(a.automation.id),O(x=>rn(x,{...a.automation,status:"cancelled",nextRunAt:null,cancelledAt:new Date().toISOString(),updatedAt:new Date().toISOString()})),await S.sendMessage(m),c(),i({title:l("shell.butlerControlTimerExecuteNowSucceeded"),tone:"success"})}catch(x){i({title:l("shell.butlerControlTimerExecuteNowFailed"),description:x instanceof Error?x.message:void 0,tone:"error"})}finally{tt(null)}},[c,i,S]),ks=u.useCallback(a=>{const m=yn(a),x=(m?st.get(m):null)||Xn(a)||s;!m||!x||o(dn(x,m))},[o,st,s]),ll=u.useCallback(async()=>{if(C){if(!k.displayName.trim()){i({title:l("shell.butlerInitNameRequired"),tone:"warning"});return}ee(!0);try{await S.updateProfile({displayName:k.displayName.trim(),agentsMode:k.agentsMode,agentsFilePath:k.agentsMode==="file"?k.agentsFilePath:null,agentsContent:k.agentsContent,persona:{tone:k.personaTone,language:k.personaLanguage,summaryStyle:k.personaSummaryStyle},focus:{...C.focus,riskPreference:k.focusRiskPreference,reportPriority:zn[k.reportPriorityPreset],summaryDebounceSeconds:k.summaryDebounceSeconds}}),i({title:l("shell.butlerSettingsSaved"),tone:"success"})}catch(a){i({title:l("shell.butlerSettingsSaveFailed"),description:a instanceof Error?a.message:void 0,tone:"error"})}finally{ee(!1)}}},[C,k,i,S]);u.useEffect(()=>{S.initialize()},[S]),u.useEffect(()=>{var m,x;const a=JSON.stringify({workspaceId:s,activeProvider:q,controlSessionId:(g==null?void 0:g.id)??null,sessionId:((m=g==null?void 0:g.session)==null?void 0:m.sessionId)??null,messages:Me.length,historyState:Fe,runtimeHasActiveRun:Pe,runtimeCanInterrupt:De,loading:ge,sending:W,switchingProvider:pe,error:Le});zt.current!==a&&(zt.current=a,qs("butler.page.timeline_state",{workspaceId:s,activeProvider:q,controlSessionId:(g==null?void 0:g.id)??null,sessionId:((x=g==null?void 0:g.session)==null?void 0:x.sessionId)??null,messages:Me.length,historyState:Fe,runtimeHasActiveRun:Pe,runtimeCanInterrupt:De,loading:ge,sending:W,switchingProvider:pe,error:Le??null}))},[s,q,g==null?void 0:g.id,(al=g==null?void 0:g.session)==null?void 0:al.sessionId,Me.length,Fe,Pe,De,ge,W,pe,Le]),u.useEffect(()=>{Le&&i({title:l("shell.butlerLoadFailed"),description:Le,tone:"error"})},[Le,i]),u.useEffect(()=>{var T;const a=((T=g==null?void 0:g.session)==null?void 0:T.sessionId)??null;if(Wt.current!==a&&(Wt.current=a,yt.current=!1,pt.current=new Set),!a)return;const m=vt.filter(B=>B.status==="pending"),x=new Set(m.map(B=>B.id));yt.current&&m.forEach(B=>{var He,nn,ln;pt.current.has(B.id)||i({id:`butler-permission-request-${B.id}`,title:l("conversation.permissionRequestToastTitle"),description:l("conversation.backgroundPermissionToastDescription",{title:((He=g==null?void 0:g.title)==null?void 0:He.trim())||((ln=(nn=g==null?void 0:g.session)==null?void 0:nn.title)==null?void 0:ln.trim())||Se,requestTitle:B.title}),tone:"warning",durationMs:8e3})}),pt.current=x,yt.current=!0},[Se,(ul=g==null?void 0:g.session)==null?void 0:ul.sessionId,(cl=g==null?void 0:g.session)==null?void 0:cl.title,g==null?void 0:g.title,vt,i]),u.useEffect(()=>{if(!C){_(Fn);return}_({displayName:C.displayName,agentsMode:C.agentsMode,agentsFilePath:li(C),agentsContent:C.agentsContent,personaTone:C.persona.tone,personaLanguage:C.persona.language,personaSummaryStyle:C.persona.summaryStyle,focusRiskPreference:C.focus.riskPreference,reportPriorityPreset:ni(C.focus.reportPriority),summaryDebounceSeconds:C.focus.summaryDebounceSeconds??Fn.summaryDebounceSeconds})},[C]),u.useEffect(()=>{if(!ue){re([]),Ee([]),Ce([]),ce([]),Te([]),O([]),Ne([]);return}let a=!1;async function m(){try{const[B,He,nn,ln,Ds,Us,Os]=await Promise.all([Xl(),Hn(),fn(),Zl(),Bn({limit:100}),_n({limit:100}),Promise.all(Yt.map(Mn=>Ql(Mn)))]);a||(re(B.items),Ee(He.items),ce(nn.items),Te(ln.items),O(Ds.payload.items),Ne(Us.payload.items),Ce(Os.flatMap(Mn=>Mn.items)))}catch(B){if(a)return;re([]),Ee([]),Ce([]),ce([]),Te([]),O([]),Ne([]),i({title:l("shell.butlerSidebarLoadFailed"),description:B instanceof Error?B.message:void 0,tone:"error"})}}m();function x(){m()}const T=window.setInterval(()=>{m()},15e3);return window.addEventListener(vn,x),()=>{a=!0,window.clearInterval(T),window.removeEventListener(vn,x)}},[ue,Yt,i]),u.useEffect(()=>ts(()=>{S.reloadEventsAndOverview()}),[S]);const it=u.useMemo(()=>di(Ot,[y.providerId,(C==null?void 0:C.providerId)??null,q]),[q,y.providerId,C==null?void 0:C.providerId,Ot]),tn=u.useMemo(()=>it.filter(a=>a.enabled),[it]),Ls=((dl=it.find(a=>a.value===q))==null?void 0:dl.enabled)??!0,Es=it.some(a=>a.enabled&&a.value!==q);u.useEffect(()=>{ue||tn.length===0||tn.some(a=>a.value===y.providerId)||L(a=>{var m;return{...a,providerId:((m=tn[0])==null?void 0:m.value)??a.providerId}})},[tn,y.providerId,ue]),u.useMemo(()=>[{value:"inline",label:l("shell.butlerAgentsModeInline")},{value:"file",label:l("shell.butlerAgentsModeFile")}],[]),u.useMemo(()=>[{value:"direct",label:l("shell.butlerToneDirect")},{value:"steady",label:l("shell.butlerToneSteady")},{value:"friendly",label:l("shell.butlerToneFriendly")}],[]),u.useMemo(()=>[{value:"zh-CN",label:l("shell.butlerLanguageZhCn")},{value:"en-US",label:l("shell.butlerLanguageEnUs")},{value:"bilingual",label:l("shell.butlerLanguageBilingual")}],[]),u.useMemo(()=>[{value:"brief",label:l("shell.butlerSummaryBrief")},{value:"structured",label:l("shell.butlerSummaryStructured")},{value:"thorough",label:l("shell.butlerSummaryThorough")}],[]),u.useMemo(()=>[{value:"conservative",label:l("shell.butlerRiskConservative")},{value:"balanced",label:l("shell.butlerRiskBalanced")},{value:"proactive",label:l("shell.butlerRiskProactive")}],[]),u.useMemo(()=>[{value:"risk-first",label:l("shell.butlerReportRiskFirst")},{value:"blocker-first",label:l("shell.butlerReportBlockerFirst")},{value:"verification-first",label:l("shell.butlerReportVerificationFirst")},{value:"progress-first",label:l("shell.butlerReportProgressFirst")}],[]);const sl=u.useMemo(()=>t.jsx(ao,{overview:F,events:lt,inboxItems:U,followUpTasks:H,assistantAutomations:ne,assistantAutomationRuns:de,cancellingFollowUpTaskId:dt,cancellingVerificationId:mt,cancellingAutomationId:Ge,controlSession:g,settingsForm:k,savingSettings:J,onOpenFollowUpHistory:wt,onOpenVerificationHistory:Ct,onOpenAutomationHistory:Tt,onOpenAutomationDetail:Jt,onOpenFollowUpDetail:v,onCancelFollowUpTask:A,onCancelVerificationRun:K,onCancelAutomation:ot,onAnalyzeTodo:je,onStartTodoSession:Z,onOpenTodoSession:xe,onCopyTodoPrompt:$e,todoActionState:Bt,onSettingsFormChange:b,onSaveSettings:()=>{ll()}}),[lt,je,ot,$e,Tt,Jt,wt,Ct,H,v,xe,ll,b,Z,ne,de,U,Ge,dt,mt,g,F,A,K,J,k,Bt]);u.useEffect(()=>{if(!ue){f(null);return}return f(sl),()=>{f(null)}},[ue,f,sl]);async function Ms(a){a.preventDefault();const m=y.displayName.trim();if(!m){i({title:l("shell.butlerInitNameRequired"),tone:"warning"});return}const x={displayName:m,providerId:y.providerId,agentsMode:y.agentsMode,persona:{tone:y.personaTone,language:y.personaLanguage,summaryStyle:y.personaSummaryStyle},focus:{projectIds:[],riskPreference:y.focusRiskPreference,reportPriority:zn[y.reportPriorityPreset],summaryDebounceSeconds:ls}};D(!0);try{await S.initializeProfile(x),i({title:l("shell.butlerInitSuccess"),tone:"success"})}catch(T){i({title:l("shell.butlerInitFailed"),description:T instanceof Error?T.message:void 0,tone:"error"})}finally{D(!1)}}async function Fs(a){if(a!==q)try{await S.switchProvider(a),ol(a),i({title:l("shell.butlerProviderSwitched"),description:l("shell.butlerProviderSwitchedDescription",{provider:bi(it,a)}),tone:"success"})}catch(m){i({title:l("shell.butlerProviderSwitchFailed"),description:m instanceof Error?m.message:void 0,tone:"error"})}}async function Ps(){try{ol(q),await S.startFreshSession(),i({title:l("shell.butlerNewSessionStarted"),tone:"success"})}catch(a){i({title:l("shell.butlerNewSessionFailed"),description:a instanceof Error?a.message:void 0,tone:"error"})}}function ol(a){Y(m=>m+1),o(Vn(s),{replace:!0}),a&&c()}return ge&&!ue&&!$?t.jsx("main",{className:"workbench-page butler-page-shell butler-loading-shell",children:t.jsx(ns,{})}):ue?t.jsxs(t.Fragment,{children:[t.jsxs("main",{className:"workbench-page conversation-page-shell butler-page-shell butler-chat-workspace",children:[t.jsxs("header",{className:"workbench-auxiliary-header butler-main-header","data-window-drag-handle":"conversation-header","data-tauri-drag-region":n,children:[t.jsx("div",{className:"butler-header-main","data-tauri-drag-region":n,children:t.jsxs("div",{className:"butler-header-analysis-anchor",onMouseEnter:()=>{We(!0)},onMouseLeave:()=>{We(!1)},children:[t.jsx("div",{className:"butler-chat-avatar","aria-hidden":"true",children:t.jsx("span",{children:St})}),t.jsx("div",{className:"butler-main-heading",children:t.jsx("h1",{tabIndex:0,"data-tauri-drag-region":n,onFocus:()=>{We(!0)},onBlur:()=>{We(!1)},children:Se})}),Ie?t.jsxs("div",{className:"butler-header-analysis-popover",role:"status","aria-live":"polite",children:[t.jsx("strong",{children:l("conversation.butlerAnalysisTitle")}),jt.length>0?jt.map(a=>t.jsxs("div",{className:"butler-header-analysis-item",children:[t.jsxs("p",{children:[l("conversation.butlerAnalysisObjectiveLabel"),":",a.objective]}),t.jsxs("p",{children:[l("conversation.butlerAnalysisStatusLabel"),":",Zn(a.status)]}),t.jsxs("p",{children:[l("conversation.butlerAnalysisSummaryLabel"),":",a.lastAutomationSummary||a.waitingReason||l("conversation.butlerAnalysisEmpty")]})]},a.id)):t.jsx("p",{children:l("conversation.butlerAnalysisEmpty")})]}):null]})}),t.jsxs("div",{className:"butler-toolbar-cluster",children:[t.jsx("div",{className:"butler-provider-switcher",children:t.jsx("select",{"aria-label":l("shell.butlerProviderLabel"),value:q,disabled:!Es||pe||W,onChange:a=>{Fs(a.target.value)},children:it.map(a=>t.jsx("option",{value:a.value,disabled:!a.enabled,children:a.label},a.value))})}),t.jsx("button",{type:"button",className:"terminal-tab-control butler-header-icon-button","aria-label":l("shell.butlerNewSessionAction"),title:l("shell.butlerNewSessionAction"),disabled:ge||W||pe||!Ls,onClick:()=>{Ps()},children:t.jsx("span",{className:"terminal-toolbar-icon","aria-hidden":"true",children:t.jsx(hi,{})})}),t.jsxs("div",{className:"butler-session-history-anchor",ref:xt,children:[t.jsx("button",{type:"button",className:"terminal-tab-control butler-header-icon-button","aria-label":l("shell.butlerHistoryAction"),"aria-haspopup":"dialog","aria-expanded":M,"aria-controls":M?"butler-control-history-popover":void 0,title:l("shell.butlerHistoryAction"),disabled:ge||W||pe,onClick:()=>{Gt()},children:t.jsx("span",{className:"terminal-toolbar-icon butler-history-toolbar-icon","aria-hidden":"true",children:t.jsx(fi,{})})}),t.jsx(Yn,{open:M,id:"butler-control-history-popover",className:"butler-session-history-popover",anchorRef:xt,popoverRef:$t,labelledBy:Ht,maxWidth:420,gap:10,viewportPadding:14,children:t.jsx(bo,{sessions:Rt,activeControlSessionId:(g==null?void 0:g.id)??null,labelId:Ht,query:R,searchInputRef:se,onQueryChange:at,deletingSessionId:ae,onSelectSession:async a=>{if(a.id===(g==null?void 0:g.id)){be();return}await S.openControlSession(a.id),be()},onDeleteSession:a=>{be(),X(a)}})})]})]})]}),t.jsx("section",{className:"butler-main-column",children:t.jsxs("div",{className:"butler-conversation-shell",children:[t.jsx(Wl,{requests:vt,replyingRequestId:Ft,onReply:async(a,m)=>{p(a);try{await S.replyPermissionRequest(a,m)}catch(x){i({title:l("conversation.permissionRequestReplyFailed"),description:x instanceof Error?x.message:void 0,tone:"error"})}finally{p(null)}}}),t.jsx(ql,{sessionId:(ml=g==null?void 0:g.session)==null?void 0:ml.sessionId,items:Kl({messages:Me}),historyState:Fe,loadingOlderMessages:wn,hasOlderMessages:Vt,provider:q,assistantAvatar:t.jsx("span",{className:"butler-message-avatar","aria-hidden":"true",children:St}),onLoadOlderMessages:()=>{S.loadOlderMessages()},onRetryMessage:a=>{const m=Me.find(x=>x.clientRequestId===a);if(m!=null&&m.content.trim()){S.sendMessage(m.content);return}S.retryMessage(a)}}),V?t.jsx(vo,{schedule:V,currentWorkspaceId:s,currentWorkspaceName:Rn,projectNameById:Xt,workspaceNameById:Zt,sessionTitleById:At,sessionWorkspaceIdById:st,countdownNow:An,cancelling:V.kind==="timer"?ft===V.timer.id:Ge===V.automation.id,skippingWait:V.kind==="automation"&&ht===V.automation.id,executingNow:et===No(V),onCancel:()=>{En(V)},onSkipWait:()=>{oe(V)},onExecuteNow:()=>{Rs(V)},onOpenSession:()=>{ks(V)}}):null,t.jsx("div",{className:"butler-composer-shell",children:t.jsx(Yl,{capabilities:_t,draftStorageId:`butler:${q}:${te}`,placeholder:l("shell.butlerComposerPlaceholder",{displayName:Se}),hasActiveRun:Tn,canInterrupt:In,contextUsage:Cn,isSubmitting:W||pe,isRunning:Nn,onInterrupt:async()=>{await S.interrupt(),c()},onSend:async(a,m)=>{var x;(((x=m==null?void 0:m.attachments)==null?void 0:x.length)??0)>0&&i({title:l("shell.butlerAttachmentUnsupported"),tone:"warning"}),await S.sendMessage(a,{model:(m==null?void 0:m.model)??null,reasoningLevel:(m==null?void 0:m.reasoningLevel)??null,permissionMode:null}),c()}})})]},`timeline:${q}:${te}`)})]}),t.jsxs(rt,{open:fe!==null,title:l("shell.deleteSessionConfirmTitle"),description:l("shell.deleteSessionConfirmDescription"),onClose:()=>{ae||X(null)},children:[t.jsx("p",{className:"workbench-section-empty",children:fe?os(fe):""}),t.jsxs("div",{className:"workbench-modal-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:!!ae,onClick:()=>X(null),children:l("common.cancel")}),t.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:!!ae,onClick:()=>{r()},children:ae?l("common.loading"):l("shell.deleteSessionAction")})]})]}),t.jsx(rt,{open:kt,title:l("shell.butlerFollowUpHistoryTitle"),description:l("shell.butlerFollowUpHistoryDescription"),onClose:()=>{qe(!1)},children:t.jsx(xo,{tasks:H.filter(a=>!qn(a.status)),cancellingTaskId:dt,onOpenFollowUpDetail:v,onCancelFollowUpTask:A,onClose:()=>{qe(!1)}})}),t.jsx(rt,{open:Lt,title:l("shell.butlerVerificationHistoryTitle"),description:l("shell.butlerVerificationHistoryDescription"),onClose:()=>{Et(!1)},children:t.jsx(Po,{items:us((F==null?void 0:F.verifications)??[],"history"),cancellingVerificationId:mt,onCancelVerificationRun:K})}),t.jsx(rt,{open:Ke,title:l("shell.butlerAutomationHistoryTitle"),description:l("shell.butlerAutomationHistoryDescription"),onClose:()=>{Mt(!1)},children:t.jsx(Do,{taskItems:rs(ne,F,"history"),runItems:as(ne,de,F,"history")})}),t.jsx(rt,{open:P!==null,title:l("shell.butlerAutomationDetailTitle"),description:((bl=P==null?void 0:P.title)==null?void 0:bl.trim())||(P==null?void 0:P.actionConfig.content.trim())||l("shell.butlerAutomationDetailDescription"),className:"butler-automation-detail-modal",onClose:()=>{Ye(null),le(null),he(null)},children:P&&Re?t.jsx(wo,{automation:P,editorState:Re,saving:Xe===P.id,projectName:Qn(P,Xt),targetSessionTitle:ri(P,At),recentRuns:Qt,onEditorChange:a=>{le(m=>m&&{...m,...a})},onSave:()=>{kn()}}):null}),t.jsx(rt,{open:Sn!==null,title:l("shell.butlerAutomationRoundDetailsTitle"),description:((hl=ye==null?void 0:ye.sessionTitle)==null?void 0:hl.trim())||(ye==null?void 0:ye.projectName)||l("shell.butlerAutomationRoundDetailsDescription"),onClose:()=>{ut(null),ct(null),Ze(null),ke(!1)},children:t.jsx(Fo,{task:ye,loading:jn,error:Dt})})]}):t.jsx("main",{className:"workbench-page butler-page-shell butler-init-shell",children:t.jsx(Ks,{form:y,onChange:L,submitting:ge||$,submitLabel:ge||$?l("shell.butlerInitSubmitting"):l("shell.butlerInitSubmit"),previewName:Se,previewAvatar:St,onSubmit:Ms})})}function ao(e){const[n,s]=u.useState("info"),o=[{id:"info",label:l("shell.butlerSidebarInfoTab")},{id:"automation",label:l("shell.butlerSidebarAutomationTab")},{id:"settings",label:l("shell.butlerSidebarSettingsTab")}],i=n==="info"?t.jsx(uo,{overview:e.overview,inboxItems:e.inboxItems,followUpTasks:e.followUpTasks,cancellingFollowUpTaskId:e.cancellingFollowUpTaskId,cancellingVerificationId:e.cancellingVerificationId,onOpenFollowUpHistory:e.onOpenFollowUpHistory,onOpenVerificationHistory:e.onOpenVerificationHistory,onOpenFollowUpDetail:e.onOpenFollowUpDetail,onCancelFollowUpTask:e.onCancelFollowUpTask,onCancelVerificationRun:e.onCancelVerificationRun,onAnalyzeTodo:e.onAnalyzeTodo,onStartTodoSession:e.onStartTodoSession,onOpenTodoSession:e.onOpenTodoSession,onCopyTodoPrompt:e.onCopyTodoPrompt,todoActionState:e.todoActionState}):n==="automation"?t.jsx(co,{overview:e.overview,automations:e.assistantAutomations,runs:e.assistantAutomationRuns,cancellingAutomationId:e.cancellingAutomationId,onOpenAutomationHistory:e.onOpenAutomationHistory,onOpenAutomationDetail:e.onOpenAutomationDetail,onCancelAutomation:e.onCancelAutomation}):t.jsx(To,{settingsForm:e.settingsForm,savingSettings:e.savingSettings,onSettingsFormChange:e.onSettingsFormChange,onSaveSettings:e.onSaveSettings});return t.jsxs("div",{className:"butler-side-column",children:[t.jsx("div",{className:"workbench-auxiliary-header butler-side-header",children:t.jsx("div",{className:"workbench-info-tabs butler-side-tabs",role:"tablist","aria-label":l("shell.butlerSidebarTabsLabel"),children:o.map(d=>t.jsx("button",{type:"button",role:"tab","aria-selected":n===d.id,className:n===d.id?"workbench-info-tab active":"workbench-info-tab",onClick:()=>{s(d.id)},children:d.label},d.id))})}),t.jsx("div",{className:"butler-side-content",children:i})]})}function uo(e){var i;const n=u.useMemo(()=>e.followUpTasks.filter(d=>qn(d.status)),[e.followUpTasks]),s=u.useMemo(()=>{var d;return us(((d=e.overview)==null?void 0:d.verifications)??[],"active")},[(i=e.overview)==null?void 0:i.verifications]),o=u.useMemo(()=>e.inboxItems.filter(d=>d.status!=="closed"),[e.inboxItems]);return t.jsxs(t.Fragment,{children:[t.jsx(go,{tasks:n,cancellingTaskId:e.cancellingFollowUpTaskId,onOpenFollowUpHistory:e.onOpenFollowUpHistory,onOpenFollowUpDetail:e.onOpenFollowUpDetail,onCancelFollowUpTask:e.onCancelFollowUpTask}),t.jsx(ss,{title:l("shell.butlerInfoVerificationRecordsTitle"),items:s,emptyText:l("shell.butlerInfoVerificationRecordsEmpty"),actionLabel:l("shell.butlerFollowUpHistoryAction"),onAction:e.onOpenVerificationHistory,cancellingVerificationId:e.cancellingVerificationId,onCancelVerificationRun:e.onCancelVerificationRun}),t.jsx(mo,{title:l("shell.butlerInfoTodoRecordsTitle"),items:o,emptyText:l("shell.butlerInfoTodoRecordsEmpty"),todoActionState:e.todoActionState,onAnalyzeTodo:e.onAnalyzeTodo,onStartTodoSession:e.onStartTodoSession,onOpenTodoSession:e.onOpenTodoSession,onCopyTodoPrompt:e.onCopyTodoPrompt})]})}function co(e){const n=u.useMemo(()=>rs(e.automations,e.overview,"active"),[e.automations,e.overview]),s=u.useMemo(()=>as(e.automations,e.runs,e.overview,"active"),[e.automations,e.overview,e.runs]);return t.jsxs(t.Fragment,{children:[t.jsx(jo,{items:n,cancellingAutomationId:e.cancellingAutomationId,onCancelAutomation:e.onCancelAutomation,onOpenAutomationDetail:e.onOpenAutomationDetail,emptyText:l("shell.butlerAutomationTasksEmpty"),actionLabel:l("shell.butlerFollowUpHistoryAction"),onAction:e.onOpenAutomationHistory}),t.jsx(Ao,{items:s,emptyText:l("shell.butlerAutomationRunsEmpty"),onOpenAutomationDetail:e.onOpenAutomationDetail})]})}function ss(e){return t.jsxs("section",{className:"butler-side-card",children:[t.jsxs("header",{children:[t.jsx("h2",{children:e.title}),e.actionLabel&&e.onAction?t.jsx("button",{type:"button",className:"secondary-button butler-side-header-action",onClick:e.onAction,children:e.actionLabel}):null]}),e.items.length>0?t.jsx("div",{className:"butler-record-list",children:e.items.map(n=>t.jsxs("article",{className:"butler-follow-up-status-card",children:[t.jsxs("header",{className:"butler-follow-up-status-header",children:[t.jsxs("div",{className:"butler-follow-up-status-title-group",children:[t.jsx("strong",{children:n.title}),n.subtitle?t.jsx("span",{children:n.subtitle}):null]}),n.status?t.jsx("span",{className:"butler-automation-status-badge","data-status":n.verification?Xo(n.verification.status):"active",children:n.status}):null]}),t.jsx("div",{className:"butler-follow-up-status-body",children:t.jsx("p",{children:n.content})}),n.meta||e.onCancelVerificationRun&&n.verification?t.jsxs("footer",{className:"butler-follow-up-status-footer",children:[t.jsx("span",{children:n.meta??""}),n.verification&&e.onCancelVerificationRun?t.jsx("button",{type:"button",className:"secondary-button butler-follow-up-status-action",disabled:e.cancellingVerificationId===n.verification.id||!Ko(n.verification),onClick:()=>{var s;n.verification&&((s=e.onCancelVerificationRun)==null||s.call(e,n.verification))},children:e.cancellingVerificationId===n.verification.id?l("conversation.butlerVerificationStopping"):l("conversation.butlerStopVerificationAction")}):null]}):null]},n.id))}):t.jsx("p",{className:"butler-secondary-text",children:e.emptyText})]})}function mo(e){return t.jsxs("section",{className:"butler-side-card",children:[t.jsx("header",{children:t.jsx("h2",{children:e.title})}),e.items.length>0?t.jsx("div",{className:"butler-record-list",children:e.items.map(n=>{var f,h;const s=e.todoActionState.itemId===n.id?e.todoActionState.kind:null,o=!!((f=n.assistantState.generatedPrompt)!=null&&f.trim()),i=!!((h=n.assistantState.linkedSessionId)!=null&&h.trim()),d=n.assistantState.lifecycleStage==="analyzing",c=i||o&&!d&&n.status!=="closed";return t.jsxs("article",{className:"butler-todo-card",children:[t.jsxs("header",{className:"butler-todo-card-header",children:[t.jsxs("div",{children:[t.jsx("strong",{children:n.title}),t.jsx("span",{children:n.projectName})]}),t.jsxs("div",{className:"butler-todo-card-badges",children:[t.jsx("span",{className:"butler-inline-badge",children:si(n.status)}),t.jsx("span",{className:"butler-inline-badge",children:Zo(n.assistantState.lifecycleStage)})]})]}),t.jsx("p",{children:n.content}),t.jsx("p",{className:"butler-secondary-text",children:n.assistantState.lastError||n.assistantState.analysisSummary||l("shell.butlerTodoLifecycleEmpty")}),o?t.jsx("div",{className:"butler-todo-prompt-preview",children:t.jsxs("details",{className:"butler-todo-prompt-preview-details",children:[t.jsx("summary",{children:l("shell.butlerTodoPromptPreviewAction")}),t.jsx("pre",{children:n.assistantState.generatedPrompt})]})}):null,t.jsxs("div",{className:"butler-todo-card-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:s!==null||n.status==="closed"||d,onClick:()=>{e.onAnalyzeTodo(n)},children:s==="analyze"?l("shell.butlerTodoAnalyzeRunning"):d?l("shell.butlerTodoAnalyzeRunning"):o?l("shell.butlerTodoReanalyzeAction"):l("shell.butlerTodoAnalyzeAction")}),t.jsx("button",{type:"button",className:"secondary-button",disabled:s!==null||!c,onClick:()=>{if(i){e.onOpenTodoSession(n);return}e.onStartTodoSession(n)},children:s==="start"?l("shell.butlerTodoStartSessionRunning"):i?l("shell.butlerTodoOpenSessionAction"):d?l("shell.butlerTodoWaitForPromptAction"):o?l("shell.butlerTodoStartSessionAction"):l("shell.butlerTodoAnalyzeFirstAction")}),t.jsx("button",{type:"button",className:"secondary-button",disabled:!o,onClick:()=>{e.onCopyTodoPrompt(n)},children:l("shell.butlerTodoCopyPromptAction")})]})]},n.id)})}):t.jsx("p",{className:"butler-secondary-text",children:e.emptyText})]})}function bo(e){const n=u.useDeferredValue(e.query),s=u.useMemo(()=>{const c=n.trim().toLowerCase();return e.sessions.map(f=>{const h=os(f),j=ho(f,h),y=I(f.updatedAt),L=[h,j,f.sessionId].join(`
|
|
2
|
+
`).toLowerCase();return{session:f,title:h,preview:j,updatedAtMs:y,active:y>0&&Date.now()-y<=lo,searchText:L}}).filter(f=>!c||f.searchText.includes(c)).sort((f,h)=>h.updatedAtMs-f.updatedAtMs)},[n,e.sessions]),o=s.filter(c=>c.active),i=s.filter(c=>!c.active),d=n.trim().length>0;return t.jsxs("div",{className:"butler-session-history-panel",children:[t.jsx("div",{className:"butler-session-history-header",children:t.jsxs("div",{className:"butler-card-header-copy",children:[t.jsx("strong",{id:e.labelId,children:l("shell.butlerHistoryTitle")}),t.jsx("p",{children:l("shell.butlerHistoryDescription")})]})}),t.jsxs("label",{className:"butler-session-history-search",children:[t.jsx("span",{className:"butler-session-history-search-icon","aria-hidden":"true",children:t.jsx(fo,{})}),t.jsx("input",{ref:e.searchInputRef,type:"search","aria-label":l("shell.butlerHistorySearchLabel"),placeholder:l("shell.butlerHistorySearchPlaceholder"),value:e.query,onChange:c=>{e.onQueryChange(c.target.value)}})]}),s.length===0?t.jsx("p",{className:"butler-secondary-text",children:d?l("shell.butlerHistorySearchEmpty"):l("shell.butlerHistoryEmpty")}):t.jsxs("div",{className:"butler-session-history-list",children:[o.length>0?t.jsxs("div",{className:"butler-session-history-section",children:[t.jsx("div",{className:"butler-session-history-divider",children:t.jsx("span",{children:l("shell.butlerHistoryActiveSection")})}),t.jsx(gl,{compact:!0,className:"butler-session-history-section-list",role:"list",children:o.map(c=>t.jsx(xl,{session:c.session,title:c.title,preview:c.preview,selected:c.session.id===e.activeControlSessionId,deleting:e.deletingSessionId===c.session.id,onSelectSession:e.onSelectSession,onDeleteSession:e.onDeleteSession},c.session.id))})]}):null,i.length>0?t.jsxs("div",{className:"butler-session-history-section",children:[t.jsx("div",{className:"butler-session-history-divider","data-muted":o.length>0,children:t.jsx("span",{children:l("shell.butlerHistoryInactiveSection")})}),t.jsx(gl,{compact:!0,className:"butler-session-history-section-list",role:"list",children:i.map(c=>t.jsx(xl,{session:c.session,title:c.title,preview:c.preview,selected:c.session.id===e.activeControlSessionId,deleting:e.deletingSessionId===c.session.id,onSelectSession:e.onSelectSession,onDeleteSession:e.onDeleteSession},c.session.id))})]}):null]})]})}function xl(e){return t.jsx(Gs,{as:"div",role:"listitem",className:"butler-session-history-item",selected:e.selected,tabIndex:0,style:{paddingTop:"13px",paddingRight:"0",paddingBottom:"12px",paddingLeft:"24px"},label:t.jsx("span",{className:"butler-session-history-item-title",title:e.title,children:e.title}),description:t.jsx("span",{className:"butler-session-history-item-preview",title:e.preview,children:e.preview}),trailing:t.jsxs("div",{className:"butler-session-history-item-trailing",children:[t.jsx("time",{className:"butler-session-history-item-time",dateTime:e.session.updatedAt,children:ti(e.session.updatedAt)}),t.jsx("button",{type:"button",className:"secondary-button workbench-danger-button butler-session-history-delete-button",disabled:e.deleting,"aria-label":l("shell.butlerHistoryDeleteAction"),onClick:n=>{n.stopPropagation(),e.onDeleteSession(e.session)},children:e.deleting?l("common.loading"):l("shell.deleteSessionAction")})]}),"aria-current":e.selected?"true":void 0,onClick:()=>{e.onSelectSession(e.session)},onKeyDown:n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),e.onSelectSession(e.session))}})}function os(e){var n,s,o;return((n=e.title)==null?void 0:n.trim())||((s=e.session.title)==null?void 0:s.trim())||((o=e.lastSummary)==null?void 0:o.trim())||e.sessionId}function ho(e,n){var i,d;const s=(i=e.lastSummary)==null?void 0:i.trim();if(s)return s;const o=(d=e.session.title)==null?void 0:d.trim();return o&&o!==n?o:e.sessionId}function fo(){return t.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",focusable:"false",children:t.jsx("path",{fill:"currentColor",d:"M6.75 1.75a5 5 0 1 0 3.16 8.875l3.61 3.608a.75.75 0 1 0 1.06-1.06l-3.608-3.61A5 5 0 0 0 6.75 1.75Zm-3.5 5a3.5 3.5 0 1 1 7 0 3.5 3.5 0 0 1-7 0Z"})})}function go(e){const n=u.useMemo(()=>[...e.tasks].sort((s,o)=>I(Ve(o))-I(Ve(s))).slice(0,5),[e.tasks]);return t.jsxs("section",{className:"butler-side-card",children:[t.jsxs("header",{children:[t.jsx("div",{className:"butler-card-header-copy",children:t.jsx("h2",{children:l("shell.butlerInfoFollowUpRecordsTitle")})}),t.jsx("button",{type:"button",className:"secondary-button butler-side-header-action",onClick:e.onOpenFollowUpHistory,children:l("shell.butlerFollowUpHistoryAction")})]}),n.length>0?t.jsx("div",{className:"butler-record-list",children:n.map(s=>t.jsx(is,{task:s,cancelling:e.cancellingTaskId===s.id,onOpenFollowUpDetail:e.onOpenFollowUpDetail,onCancelFollowUpTask:e.onCancelFollowUpTask},s.id))}):t.jsx("p",{className:"butler-secondary-text",children:l("shell.butlerInfoFollowUpRecordsEmpty")})]})}function xo(e){const n=u.useMemo(()=>[...e.tasks].sort((s,o)=>I(Ve(o))-I(Ve(s))),[e.tasks]);return t.jsx("div",{className:"butler-follow-up-history-panel",children:n.length>0?t.jsx("div",{className:"butler-record-list",children:n.map(s=>t.jsx(is,{task:s,cancelling:e.cancellingTaskId===s.id,onOpenFollowUpDetail:async o=>{e.onClose(),await e.onOpenFollowUpDetail(o)},onCancelFollowUpTask:e.onCancelFollowUpTask},s.id))}):t.jsx("p",{className:"butler-secondary-text",children:l("shell.butlerInfoFollowUpRecordsEmpty")})})}function is(e){var i,d,c;const{task:n}=e,s=((i=n.sessionTitle)==null?void 0:i.trim())||n.projectName,o=((d=n.waitingReason)==null?void 0:d.trim())||((c=n.lastAutomationSummary)==null?void 0:c.trim())||n.objective;return t.jsxs("article",{className:"butler-follow-up-status-card",children:[t.jsxs("header",{className:"butler-follow-up-status-header",children:[t.jsxs("div",{className:"butler-follow-up-status-title-group",children:[t.jsx("strong",{children:s}),t.jsx("span",{children:n.projectName})]}),t.jsx("span",{className:"butler-automation-status-badge","data-status":n.status,children:Zn(n.status)})]}),t.jsx("div",{className:"butler-follow-up-status-body",children:t.jsx("p",{children:o})}),t.jsxs("footer",{className:"butler-follow-up-status-footer",children:[t.jsx("span",{children:ie(Ve(n))}),t.jsxs("div",{className:"butler-inline-actions",children:[e.onCancelFollowUpTask&&qo(n)?t.jsx("button",{type:"button",className:"secondary-button butler-follow-up-status-action",disabled:e.cancelling,onClick:()=>{e.onCancelFollowUpTask(n)},children:e.cancelling?l("conversation.butlerFollowUpStopping"):l("conversation.butlerStopFollowUpAction")}):null,t.jsx("button",{type:"button",className:"secondary-button butler-follow-up-status-action",onClick:()=>{e.onOpenFollowUpDetail(n.id)},children:l("shell.butlerAutomationViewRoundsAction")})]})]})]})}function vo(e){const n=u.useId(),s=u.useId(),o=u.useRef(null),i=u.useRef(null),[d,c]=u.useState(!1),f=Lo(e.schedule,e.countdownNow),h=Ro(e.schedule,e.countdownNow),j=ko(e.schedule,e.countdownNow),y=Bo(e.schedule,e.projectNameById,e.workspaceNameById,e.currentWorkspaceId,e.currentWorkspaceName),L=Vo(e.schedule,e.sessionTitleById),$=Eo(e.schedule),D=!!(yn(e.schedule)&&(e.sessionWorkspaceIdById.has(yn(e.schedule))||Xn(e.schedule))),k=Io(e.schedule),_=Mo(e.schedule),J=k?e.executingNow?l("shell.butlerControlTimerExecutingNow"):l("shell.butlerControlTimerExecuteNowAction"):e.skippingWait?l("shell.butlerControlTimerCancelling"):l("shell.butlerControlTimerCancelAction"),ee=k?e.cancelling?l("shell.butlerControlTimerCancelling"):l("shell.butlerControlTimerStopAction"):e.cancelling?l("shell.butlerControlTimerCancelling"):l("shell.butlerControlTimerCancelOperationAction");return u.useEffect(()=>{if(!d)return;const te=U=>{var re,H;(re=o.current)!=null&&re.contains(U.target)||(H=i.current)!=null&&H.contains(U.target)||c(!1)},Y=U=>{U.key==="Escape"&&c(!1)};return document.addEventListener("pointerdown",te),document.addEventListener("keydown",Y),()=>{document.removeEventListener("pointerdown",te),document.removeEventListener("keydown",Y)}},[d]),t.jsx("section",{className:"butler-control-timer-banner","aria-live":"polite",children:t.jsxs("div",{className:"butler-control-timer-banner-shell",children:[t.jsxs("div",{className:"butler-control-timer-banner-copy",children:[t.jsxs("div",{className:"butler-control-timer-banner-status",children:[t.jsx("span",{className:"butler-control-timer-pulse","aria-hidden":"true"}),t.jsx("span",{className:"butler-control-timer-banner-caption",children:_})]}),t.jsxs("div",{className:"butler-control-timer-display-panel",children:[t.jsx("p",{className:"butler-control-timer-banner-lead",children:h}),t.jsx("p",{className:"butler-control-timer-display-clock",children:f}),t.jsx("p",{className:"butler-control-timer-banner-tail",children:j})]}),t.jsxs("div",{className:"butler-control-timer-banner-meta",children:[t.jsxs("div",{className:"butler-control-timer-banner-meta-card","data-kind":"workspace",children:[t.jsx("span",{children:l("shell.butlerControlTimerWorkspaceLabel")}),t.jsx("strong",{title:y,children:y})]}),t.jsxs("div",{className:"butler-control-timer-banner-meta-card","data-kind":"session",children:[t.jsx("span",{children:l("shell.butlerControlTimerSessionLabel")}),D?t.jsx("button",{type:"button",className:"butler-control-timer-session-link",title:L,"aria-label":`${l("shell.butlerControlTimerSessionLabel")}:${L}`,onClick:e.onOpenSession,children:L}):t.jsx("strong",{title:L,children:L})]})]})]}),t.jsxs("div",{className:"butler-control-timer-banner-actions",children:[t.jsxs("div",{className:"butler-control-timer-banner-detail",ref:o,children:[t.jsx("button",{id:n,type:"button",className:"butler-control-timer-banner-detail-button","aria-label":l("shell.butlerControlTimerDetailAction"),"aria-haspopup":"dialog","aria-expanded":d,"aria-controls":d?s:void 0,title:l("shell.butlerControlTimerDetailAction"),onClick:()=>{c(te=>!te)},children:t.jsx("span",{className:"butler-control-timer-banner-detail-icon","aria-hidden":"true",children:t.jsx(zo,{})})}),t.jsx(Yn,{open:d,id:s,className:"butler-control-timer-banner-detail-popover",anchorRef:o,popoverRef:i,labelledBy:n,children:t.jsxs("div",{children:[t.jsx("strong",{children:l("shell.butlerControlTimerPromptTitle")}),t.jsx("p",{children:$})]})})]}),t.jsx("button",{type:"button",className:"secondary-button butler-control-timer-banner-action",disabled:e.cancelling||e.executingNow||e.skippingWait,onClick:k?e.onExecuteNow:e.onSkipWait,children:J}),t.jsx("button",{type:"button",className:"secondary-button butler-control-timer-banner-action",disabled:e.cancelling||e.executingNow||e.skippingWait,onClick:e.onCancel,children:ee})]}),k?t.jsx("p",{className:"butler-control-timer-banner-note",children:l("shell.butlerControlTimerActionNote")}):null]})})}function yo(e){const[n,s]=u.useState(e),o=u.useRef(null);return u.useEffect(()=>{if(e){o.current!==null&&(window.clearTimeout(o.current),o.current=null),s(e);return}!n||o.current!==null||(o.current=window.setTimeout(()=>{o.current=null,s(null)},to))},[e,n]),u.useEffect(()=>()=>{o.current!==null&&window.clearTimeout(o.current)},[]),e??n}function po(e,n){const[s,o]=u.useState(n),i=u.useRef(null);return u.useEffect(()=>{i.current!==null&&(window.clearTimeout(i.current),i.current=null),o(n)},[e]),u.useEffect(()=>{if(n){i.current!==null&&(window.clearTimeout(i.current),i.current=null),o(!0);return}!s||i.current!==null||(i.current=window.setTimeout(()=>{i.current=null,o(!1)},no))},[n,s]),u.useEffect(()=>()=>{i.current!==null&&window.clearTimeout(i.current)},[]),s}function So(e,n){return n===!0?!0:e?e.session.activityState==="running"||e.session.runningState==="starting"||e.session.runningState==="running"||e.session.runningState==="reconnecting":!1}function jo(e){return t.jsxs("section",{className:"butler-side-card",children:[t.jsxs("header",{children:[t.jsx("h2",{children:l("shell.butlerAutomationTasksTitle")}),e.actionLabel&&e.onAction?t.jsx("button",{type:"button",className:"secondary-button butler-side-header-action",onClick:e.onAction,children:e.actionLabel}):null]}),e.items.length>0?t.jsx("div",{className:"butler-automation-overview-list",children:e.items.map(n=>t.jsxs("article",{className:"butler-automation-card butler-automation-overview-card","data-kind":"task",children:[t.jsxs("header",{className:"butler-automation-card-header",children:[t.jsxs("div",{className:"butler-automation-card-title-group",children:[t.jsx("strong",{children:n.title}),t.jsx("span",{children:n.projectName})]}),t.jsx("span",{className:"butler-automation-status-badge","data-status":n.status,children:n.statusLabel})]}),t.jsxs("div",{className:"butler-automation-overview-inline",children:[t.jsx("span",{className:"butler-automation-overview-chip",children:n.taskTypeLabel}),t.jsxs("span",{className:"butler-automation-overview-inline-meta",children:[l("shell.butlerAutomationTaskNextRunLabel")," · ",ie(n.nextRunAt)]}),t.jsxs("span",{className:"butler-automation-overview-inline-meta",children:[l("shell.butlerAutomationTaskLastRunLabel")," · ",ie(n.lastRunAt)]})]}),t.jsxs("footer",{className:"butler-automation-card-footer",children:[n.automationId?t.jsx("button",{type:"button",className:"secondary-button butler-automation-card-action",onClick:()=>{e.onOpenAutomationDetail(n.automationId)},children:l("shell.butlerAutomationOpenDetailsAction")}):null,n.automationId&&n.status==="active"?t.jsx("button",{type:"button",className:"secondary-button butler-automation-card-action",disabled:e.cancellingAutomationId===n.automationId,onClick:()=>{e.onCancelAutomation(n.automationId)},children:e.cancellingAutomationId===n.automationId?l("shell.butlerControlTimerCancelling"):l("shell.butlerControlTimerStopAction")}):null]})]},n.id))}):t.jsx("p",{className:"butler-secondary-text",children:e.emptyText})]})}function Ao(e){return t.jsxs("section",{className:"butler-side-card",children:[t.jsx("header",{children:t.jsx("h2",{children:l("shell.butlerAutomationRunsTitle")})}),e.items.length>0?t.jsx("div",{className:"butler-automation-overview-list",children:e.items.map(n=>t.jsxs("article",{className:"butler-automation-card butler-automation-overview-card","data-kind":"run",children:[t.jsxs("header",{className:"butler-automation-card-header",children:[t.jsxs("div",{className:"butler-automation-card-title-group",children:[t.jsx("strong",{children:n.title}),t.jsx("span",{children:n.projectName})]}),t.jsx("span",{className:"butler-automation-status-badge","data-status":n.status,children:n.statusLabel})]}),t.jsxs("div",{className:"butler-automation-overview-inline",children:[t.jsx("span",{className:"butler-automation-overview-chip",children:n.sourceLabel}),t.jsxs("span",{className:"butler-automation-overview-inline-meta",children:[l("shell.butlerAutomationRunProcessedAtLabel")," · ",ie(n.createdAt)]})]}),t.jsx("footer",{className:"butler-automation-card-footer",children:t.jsx("button",{type:"button",className:"secondary-button butler-automation-card-action",onClick:()=>{e.onOpenAutomationDetail(n.automationId)},children:l("shell.butlerAutomationOpenDetailsAction")})})]},n.id))}):t.jsx("p",{className:"butler-secondary-text",children:e.emptyText})]})}function wo(e){return t.jsxs("div",{className:"butler-automation-detail-shell",children:[t.jsxs("section",{className:"butler-automation-detail-summary-grid",children:[t.jsxs("div",{className:"butler-automation-detail-summary-card",children:[t.jsx("span",{children:l("shell.butlerAutomationTaskTypeLabel")}),t.jsx("strong",{children:ms(e.automation.triggerType)})]}),t.jsxs("div",{className:"butler-automation-detail-summary-card",children:[t.jsx("span",{children:l("shell.butlerAutomationStatusLabel")}),t.jsx("strong",{children:fs(e.automation.status)})]}),t.jsxs("div",{className:"butler-automation-detail-summary-card",children:[t.jsx("span",{children:l("shell.butlerAutomationTaskNextRunLabel")}),t.jsx("strong",{children:ie(e.automation.nextRunAt)})]}),t.jsxs("div",{className:"butler-automation-detail-summary-card",children:[t.jsx("span",{children:l("shell.butlerAutomationTaskLastRunLabel")}),t.jsx("strong",{children:ie(e.automation.lastRunAt||e.automation.updatedAt)})]}),t.jsxs("div",{className:"butler-automation-detail-summary-card",children:[t.jsx("span",{children:l("shell.butlerControlTimerWorkspaceLabel")}),t.jsx("strong",{children:e.projectName})]}),e.targetSessionTitle?t.jsxs("div",{className:"butler-automation-detail-summary-card",children:[t.jsx("span",{children:l("shell.butlerAutomationTargetSessionLabel")}),t.jsx("strong",{children:e.targetSessionTitle})]}):null]}),t.jsxs("section",{className:"butler-side-card butler-automation-detail-section",children:[t.jsx("header",{children:t.jsx("h2",{children:l("shell.butlerAutomationDetailTitle")})}),t.jsxs("div",{className:"butler-automation-detail-form-grid",children:[t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationTitleLabel")}),t.jsx("input",{className:"butler-form-control",value:e.editorState.title,disabled:e.saving,onChange:n=>{e.onEditorChange({title:n.target.value})}})]}),t.jsxs("label",{className:"butler-form-field butler-form-field-wide",children:[t.jsx("span",{children:l("shell.butlerAutomationPromptLabel")}),t.jsx("textarea",{className:"butler-form-control butler-automation-detail-textarea",value:e.editorState.content,disabled:e.saving,onChange:n=>{e.onEditorChange({content:n.target.value})}})]}),t.jsxs("label",{className:"butler-automation-detail-toggle",children:[t.jsx("input",{type:"checkbox",checked:e.editorState.includeTriggerContext,disabled:e.saving,onChange:n=>{e.onEditorChange({includeTriggerContext:n.target.checked})}}),t.jsx("span",{children:l("shell.butlerAutomationIncludeTriggerContextLabel")})]}),t.jsx(Co,{automation:e.automation,editorState:e.editorState,saving:e.saving,onEditorChange:e.onEditorChange})]}),t.jsx("div",{className:"butler-automation-detail-actions",children:t.jsx("button",{type:"button",className:"primary-button",disabled:e.saving,onClick:e.onSave,children:e.saving?l("shell.butlerAutomationSaving"):l("shell.butlerAutomationSaveAction")})})]}),t.jsxs("section",{className:"butler-side-card butler-automation-detail-section",children:[t.jsx("header",{children:t.jsx("h2",{children:l("shell.butlerAutomationRunsTitle")})}),e.recentRuns.length>0?t.jsx("div",{className:"butler-automation-detail-run-list",children:e.recentRuns.map(n=>{var s,o;return t.jsxs("article",{className:"butler-automation-detail-run-card",children:[t.jsxs("header",{children:[t.jsx("strong",{children:l("shell.butlerAutomationRoundLabel",{round:n.runSeq})}),t.jsx("span",{className:"butler-automation-status-badge","data-status":hs(n.status),children:gs(n.status)})]}),t.jsxs("div",{className:"butler-automation-detail-run-meta",children:[t.jsx("span",{children:bs(n.triggerType)}),t.jsx("span",{children:ie(n.finishedAt||n.startedAt||n.createdAt)})]}),t.jsx("p",{children:((s=n.summary)==null?void 0:s.trim())||((o=n.error)==null?void 0:o.trim())||l("shell.butlerAutomationRunEmptySummary")})]},n.id)})}):t.jsx("p",{className:"butler-secondary-text",children:l("shell.butlerAutomationRunsEmpty")})]})]})}function Co(e){const{triggerConfig:n}=e.automation;return n.type==="once"?t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationDueAtLabel")}),t.jsx("input",{type:"datetime-local",className:"butler-form-control",value:e.editorState.dueAt,disabled:e.saving,onChange:s=>{e.onEditorChange({dueAt:s.target.value})}})]}):n.type==="interval"?t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationEverySecondsLabel")}),t.jsx("input",{inputMode:"numeric",className:"butler-form-control",value:e.editorState.everySeconds,disabled:e.saving,onChange:s=>{e.onEditorChange({everySeconds:s.target.value})}})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationEveryMinutesLabel")}),t.jsx("input",{inputMode:"numeric",className:"butler-form-control",value:e.editorState.everyMinutes,disabled:e.saving,onChange:s=>{e.onEditorChange({everyMinutes:s.target.value})}})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationEveryHoursLabel")}),t.jsx("input",{inputMode:"numeric",className:"butler-form-control",value:e.editorState.everyHours,disabled:e.saving,onChange:s=>{e.onEditorChange({everyHours:s.target.value})}})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationStopAtLabel")}),t.jsx("input",{type:"datetime-local",className:"butler-form-control",value:e.editorState.stopAt,disabled:e.saving,onChange:s=>{e.onEditorChange({stopAt:s.target.value})}})]})]}):n.type==="cron"?t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationCronMinuteLabel")}),t.jsx("input",{inputMode:"numeric",className:"butler-form-control",value:e.editorState.cronMinute,disabled:e.saving,onChange:s=>{e.onEditorChange({cronMinute:s.target.value})}})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationCronHourLabel")}),t.jsx("input",{inputMode:"numeric",className:"butler-form-control",value:e.editorState.cronHour,disabled:e.saving,onChange:s=>{e.onEditorChange({cronHour:s.target.value})}})]}),t.jsxs("label",{className:"butler-form-field butler-form-field-wide",children:[t.jsx("span",{children:l("shell.butlerAutomationCronDaysOfWeekLabel")}),t.jsx("input",{className:"butler-form-control",value:e.editorState.cronDaysOfWeek,disabled:e.saving,onChange:s=>{e.onEditorChange({cronDaysOfWeek:s.target.value})}})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationStopAtLabel")}),t.jsx("input",{type:"datetime-local",className:"butler-form-control",value:e.editorState.stopAt,disabled:e.saving,onChange:s=>{e.onEditorChange({stopAt:s.target.value})}})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationPollIntervalLabel")}),t.jsx("input",{inputMode:"numeric",className:"butler-form-control",value:e.editorState.pollIntervalSeconds,disabled:e.saving,onChange:s=>{e.onEditorChange({pollIntervalSeconds:s.target.value})}})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationMaxChecksLabel")}),t.jsx("input",{inputMode:"numeric",className:"butler-form-control",value:e.editorState.maxChecks,disabled:e.saving,onChange:s=>{e.onEditorChange({maxChecks:s.target.value})}})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationExpiresAtLabel")}),t.jsx("input",{type:"datetime-local",className:"butler-form-control",value:e.editorState.expiresAt,disabled:e.saving,onChange:s=>{e.onEditorChange({expiresAt:s.target.value})}})]})]})}function To(e){return t.jsxs("section",{className:"butler-side-card butler-settings-panel",children:[t.jsx("header",{children:t.jsx("h2",{children:l("shell.butlerSettingsTitle")})}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerDisplayNameLabel")}),t.jsx("input",{"aria-label":l("shell.butlerDisplayNameLabel"),className:"butler-form-control",value:e.settingsForm.displayName,disabled:e.savingSettings,onChange:n=>{e.onSettingsFormChange({displayName:n.target.value})}})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAgentsModeLabel")}),t.jsxs("select",{"aria-label":l("shell.butlerAgentsModeLabel"),className:"butler-form-control",value:e.settingsForm.agentsMode,disabled:e.savingSettings,onChange:n=>{e.onSettingsFormChange({agentsMode:n.target.value})},children:[t.jsx("option",{value:"inline",children:l("shell.butlerAgentsModeInline")}),t.jsx("option",{value:"file",children:l("shell.butlerAgentsModeFile")})]}),t.jsx("small",{children:e.settingsForm.agentsMode==="file"?l("shell.butlerAgentsModeFileDescription"):l("shell.butlerAgentsModeInlineDescription")})]}),e.settingsForm.agentsMode==="file"?t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAgentsFilePathLabel")}),t.jsx("input",{"aria-label":l("shell.butlerAgentsFilePathLabel"),className:"butler-form-control butler-settings-file-path",value:e.settingsForm.agentsFilePath,readOnly:!0,disabled:e.savingSettings})]}):null,t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAgentsContentLabel")}),t.jsx("textarea",{"aria-label":l("shell.butlerAgentsContentLabel"),className:"butler-form-control butler-settings-agents-editor",rows:10,value:e.settingsForm.agentsContent,disabled:e.savingSettings,placeholder:l("shell.butlerAgentsContentPlaceholder"),onChange:n=>{e.onSettingsFormChange({agentsContent:n.target.value})}}),t.jsx("small",{children:l("shell.butlerAgentsContentHint")})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerPersonaToneLabel")}),t.jsxs("select",{"aria-label":l("shell.butlerPersonaToneLabel"),className:"butler-form-control",value:e.settingsForm.personaTone,disabled:e.savingSettings,onChange:n=>{e.onSettingsFormChange({personaTone:n.target.value})},children:[t.jsx("option",{value:"direct",children:l("shell.butlerToneDirect")}),t.jsx("option",{value:"steady",children:l("shell.butlerToneSteady")}),t.jsx("option",{value:"friendly",children:l("shell.butlerToneFriendly")})]})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerPersonaLanguageLabel")}),t.jsxs("select",{"aria-label":l("shell.butlerPersonaLanguageLabel"),className:"butler-form-control",value:e.settingsForm.personaLanguage,disabled:e.savingSettings,onChange:n=>{e.onSettingsFormChange({personaLanguage:n.target.value})},children:[t.jsx("option",{value:"zh-CN",children:l("shell.butlerLanguageZhCn")}),t.jsx("option",{value:"en-US",children:l("shell.butlerLanguageEnUs")}),t.jsx("option",{value:"bilingual",children:l("shell.butlerLanguageBilingual")})]})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerPersonaSummaryStyleLabel")}),t.jsxs("select",{"aria-label":l("shell.butlerPersonaSummaryStyleLabel"),className:"butler-form-control",value:e.settingsForm.personaSummaryStyle,disabled:e.savingSettings,onChange:n=>{e.onSettingsFormChange({personaSummaryStyle:n.target.value})},children:[t.jsx("option",{value:"brief",children:l("shell.butlerSummaryBrief")}),t.jsx("option",{value:"structured",children:l("shell.butlerSummaryStructured")}),t.jsx("option",{value:"thorough",children:l("shell.butlerSummaryThorough")})]})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerFocusRiskPreferenceLabel")}),t.jsxs("select",{"aria-label":l("shell.butlerFocusRiskPreferenceLabel"),className:"butler-form-control",value:e.settingsForm.focusRiskPreference,disabled:e.savingSettings,onChange:n=>{e.onSettingsFormChange({focusRiskPreference:n.target.value})},children:[t.jsx("option",{value:"conservative",children:l("shell.butlerRiskConservative")}),t.jsx("option",{value:"balanced",children:l("shell.butlerRiskBalanced")}),t.jsx("option",{value:"proactive",children:l("shell.butlerRiskProactive")})]})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerReportPriorityPresetLabel")}),t.jsxs("select",{"aria-label":l("shell.butlerReportPriorityPresetLabel"),className:"butler-form-control",value:e.settingsForm.reportPriorityPreset,disabled:e.savingSettings,onChange:n=>{e.onSettingsFormChange({reportPriorityPreset:n.target.value})},children:[t.jsx("option",{value:"risk-first",children:l("shell.butlerReportRiskFirst")}),t.jsx("option",{value:"blocker-first",children:l("shell.butlerReportBlockerFirst")}),t.jsx("option",{value:"verification-first",children:l("shell.butlerReportVerificationFirst")}),t.jsx("option",{value:"progress-first",children:l("shell.butlerReportProgressFirst")})]})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerSummaryDebounceLabel")}),t.jsx("select",{"aria-label":l("shell.butlerSummaryDebounceLabel"),className:"butler-form-control",value:String(e.settingsForm.summaryDebounceSeconds),disabled:e.savingSettings,onChange:n=>{e.onSettingsFormChange({summaryDebounceSeconds:Number(n.target.value)})},children:so.map(n=>t.jsx("option",{value:n.value,children:l(n.labelKey)},n.value))})]}),t.jsx("div",{className:"butler-inline-actions",children:t.jsx("button",{type:"button",className:"primary-button",disabled:e.savingSettings,onClick:e.onSaveSettings,children:e.savingSettings?l("shell.butlerSettingsSaving"):l("shell.butlerSettingsSaveAction")})})]})}function ie(e){if(!e)return"-";const n=new Date(e);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(void 0,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(n)}function Ve(e){return e.updatedAt||e.lastAutomationAt||e.lastCheckedAt||e.createdAt}function No(e){return e.kind==="timer"?e.timer.id:e.automation.id}function It(e){return e.kind==="timer"?e.timer.dueAt:e.automation.nextRunAt}function Xn(e){var n,s,o,i,d,c;return e.kind==="timer"?((o=(s=(n=e.timer.controlSession)==null?void 0:n.session)==null?void 0:s.workspaceId)==null?void 0:o.trim())||null:((c=(d=(i=e.automation.controlSession)==null?void 0:i.session)==null?void 0:d.workspaceId)==null?void 0:c.trim())||null}function yn(e){var n,s,o,i,d,c,f,h,j,y,L;return e.kind==="timer"?((n=e.timer.targetSessionId)==null?void 0:n.trim())||((i=(o=(s=e.timer.controlSession)==null?void 0:s.session)==null?void 0:o.sessionId)==null?void 0:i.trim())||((d=e.timer.sessionId)==null?void 0:d.trim())||null:((c=e.automation.actionConfig.targetSessionId)==null?void 0:c.trim())||((j=(h=(f=e.automation.controlSession)==null?void 0:f.session)==null?void 0:h.sessionId)==null?void 0:j.trim())||((L=(y=e.automation.controlSession)==null?void 0:y.sessionId)==null?void 0:L.trim())||null}function Io(e){return e.kind==="timer"||e.automation.triggerType==="once"}function Ro(e,n){const s=I(It(e));return!s||s<=n?l("shell.butlerControlTimerCountdownDueLead"):l("shell.butlerControlTimerCountdownLead")}function ko(e,n){const s=I(It(e));return!s||s<=n?l("shell.butlerControlTimerCountdownDueTail"):l("shell.butlerControlTimerCountdownTail")}function Lo(e,n){const s=I(It(e));return!s||s<=n?"00:00":Wo(s-n)}function Eo(e){return e.kind==="timer"?$o(e.timer):e.automation.actionConfig.content.trim()||l("conversation.butlerAnalysisEmpty")}function Mo(e){if(e.kind==="timer")return l("shell.butlerControlTimerTypeOnce");switch(e.automation.triggerType){case"once":return l("shell.butlerControlTimerTypeOnce");case"interval":case"cron":return l("shell.butlerControlTimerTypeRepeat");case"condition":return l("shell.butlerControlTimerTypeConditional");default:return l("shell.butlerControlTimerTypeOther")}}function rs(e,n,s="active"){const o=new Map(((n==null?void 0:n.projects)??[]).map(d=>[d.id,d.name]));return e.filter(d=>s==="history"?d.status!=="active":d.status==="active").map(d=>({id:`assistant-automation:${d.id}`,automationId:d.id,kind:"assistant_automation",title:xs(d),projectName:Qn(d,o),status:ii(d.status),taskTypeLabel:ms(d.triggerType),statusLabel:fs(d.status),nextRunAt:d.nextRunAt,lastRunAt:d.lastRunAt||d.updatedAt})).sort((d,c)=>{const f=I(d.nextRunAt),h=I(c.nextRunAt);return f!==h?f===0?1:h===0?-1:f-h:I(c.lastRunAt)-I(d.lastRunAt)}).slice(0,10)}function as(e,n,s,o="active"){const i=h=>h==="active"||h==="waiting_user",d=new Map(((s==null?void 0:s.projects)??[]).map(h=>[h.id,h.name])),c=new Map(e.map(h=>[h.id,h]));return n.map(h=>{const j=c.get(h.automationId);return{run:h,automation:j,normalizedStatus:hs(h.status)}}).filter(({automation:h})=>!!h).filter(({normalizedStatus:h})=>o==="history"?!i(h):i(h)).map(({run:h,automation:j,normalizedStatus:y})=>{var L,$;return{id:`assistant-automation-run:${h.id}`,automationId:h.automationId,kind:"assistant_automation_run",title:xs(j),projectName:Qn(j,d),status:y,sourceLabel:bs(h.triggerType),statusLabel:gs(h.status),summary:((L=h.summary)==null?void 0:L.trim())||(($=h.error)==null?void 0:$.trim())||l("shell.butlerAutomationRunEmptySummary"),createdAt:h.finishedAt||h.startedAt||h.createdAt}}).sort((h,j)=>I(j.createdAt)-I(h.createdAt)).slice(0,12)}function Fo(e){if(e.loading)return t.jsx("p",{className:"butler-secondary-text",children:l("shell.butlerAutomationRoundLoading")});if(e.error)return t.jsx("p",{className:"butler-secondary-text",children:e.error});if(!e.task)return t.jsx("p",{className:"butler-secondary-text",children:l("shell.butlerAutomationRoundEmpty")});const n=[...e.task.rounds??[]].sort((s,o)=>I(o.createdAt)-I(s.createdAt));return t.jsxs("div",{className:"butler-follow-up-rounds",children:[t.jsxs("div",{className:"butler-follow-up-round-summary",children:[t.jsx("strong",{children:e.task.objective}),t.jsx("span",{children:l("conversation.butlerCurrentFollowUpProgress",{current:e.task.autoContinueCount,max:e.task.maxAutoContinueCount??5})})]}),n.length>0?t.jsx("div",{className:"butler-follow-up-round-list",children:n.map(s=>t.jsxs("article",{className:"butler-follow-up-round-card",children:[t.jsxs("header",{className:"butler-follow-up-round-header",children:[t.jsxs("div",{children:[t.jsx("strong",{children:l("shell.butlerAutomationRoundLabel",{round:s.roundNumber})}),t.jsx("span",{children:oi(s.kind)})]}),t.jsx("span",{children:ie(s.createdAt)})]}),t.jsxs("div",{className:"butler-follow-up-round-body",children:[t.jsxs("p",{children:[l("shell.butlerAutomationRoundProcessedAtLabel"),":",ie(s.createdAt)]}),t.jsxs("p",{children:[l("shell.butlerAutomationRoundStatusLabel"),":",Zn(s.status)]}),s.observedRunningState?t.jsxs("p",{children:[l("shell.butlerAutomationRoundObservedStateLabel"),":",s.observedRunningState]}):null,t.jsxs("p",{children:[l("shell.butlerAutomationRoundSummaryLabel"),":",s.summary||l("conversation.butlerAnalysisEmpty")]}),s.waitingReason?t.jsxs("p",{children:[l("shell.butlerAutomationRoundWaitingReasonLabel"),":",s.waitingReason]}):null,s.continuePrompt?t.jsxs("p",{children:[l("shell.butlerAutomationRoundPromptLabel"),":",s.continuePrompt]}):null]})]},`${s.roundNumber}:${s.createdAt}`))}):t.jsx("p",{className:"butler-secondary-text",children:l("shell.butlerAutomationRoundEmpty")})]})}function Po(e){return e.items.length===0?t.jsx("p",{className:"butler-secondary-text",children:l("shell.butlerVerificationHistoryEmpty")}):t.jsx(ss,{title:l("shell.butlerInfoVerificationRecordsTitle"),items:e.items,emptyText:l("shell.butlerVerificationHistoryEmpty"),cancellingVerificationId:e.cancellingVerificationId,onCancelVerificationRun:e.onCancelVerificationRun})}function Do(e){return e.taskItems.length===0&&e.runItems.length===0?t.jsx("p",{className:"butler-secondary-text",children:l("shell.butlerAutomationHistoryEmpty")}):t.jsxs("div",{className:"butler-record-list",children:[e.taskItems.map(n=>t.jsxs("article",{className:"butler-automation-card",children:[t.jsxs("header",{className:"butler-automation-card-header",children:[t.jsxs("div",{className:"butler-automation-card-title-group",children:[t.jsx("strong",{children:n.title}),t.jsx("span",{children:n.projectName})]}),t.jsx("span",{className:"butler-automation-status-badge","data-status":n.status,children:n.statusLabel})]}),t.jsxs("div",{className:"butler-automation-card-body",children:[t.jsxs("div",{className:"butler-automation-row",children:[t.jsx("span",{children:l("shell.butlerAutomationTaskTypeLabel")}),t.jsx("strong",{children:n.taskTypeLabel})]}),t.jsxs("div",{className:"butler-automation-row",children:[t.jsx("span",{children:l("shell.butlerAutomationTaskLastRunLabel")}),t.jsx("strong",{children:ie(n.lastRunAt)})]})]}),t.jsxs("footer",{className:"butler-automation-card-footer",children:[t.jsx("span",{children:l("shell.butlerAutomationTaskNextRunLabel")}),t.jsx("strong",{children:ie(n.nextRunAt)})]})]},n.id)),e.runItems.map(n=>t.jsxs("article",{className:"butler-automation-card",children:[t.jsxs("header",{className:"butler-automation-card-header",children:[t.jsxs("div",{className:"butler-automation-card-title-group",children:[t.jsx("strong",{children:n.title}),t.jsx("span",{children:n.projectName})]}),t.jsx("span",{className:"butler-automation-status-badge","data-status":n.status,children:n.statusLabel})]}),t.jsxs("div",{className:"butler-automation-card-body",children:[t.jsxs("div",{className:"butler-automation-row",children:[t.jsx("span",{children:l("shell.butlerAutomationRunSourceLabel")}),t.jsx("strong",{children:n.sourceLabel})]}),t.jsxs("div",{className:"butler-automation-row",children:[t.jsx("span",{children:l("shell.butlerAutomationRunSummaryLabel")}),t.jsx("strong",{children:n.summary})]})]}),t.jsxs("footer",{className:"butler-automation-card-footer",children:[t.jsx("span",{children:l("shell.butlerAutomationRunProcessedAtLabel")}),t.jsx("strong",{children:ie(n.createdAt)})]})]},n.id))]})}function us(e,n){return[...e].filter(s=>n==="history"?!jl(s.status):jl(s.status)).sort((s,o)=>I(Pn(o))-I(Pn(s))).slice(0,5).map(s=>{var o,i;return{id:s.id,title:((o=s.targetRef)==null?void 0:o.trim())||s.verificationType,subtitle:s.verificationType,status:Yo(s.status),content:((i=s.summary)==null?void 0:i.trim())||l("shell.butlerInfoVerificationFallback",{status:s.status}),meta:ie(Pn(s)),verification:s}})}function vl(e,n){const s=e.filter(o=>o.id!==n.id);return[n,...s].sort((o,i)=>I(i.updatedAt)-I(o.updatedAt))}function yl(e,n){const s=e.filter(o=>o.id!==n.id);return[n,...s].sort((o,i)=>I(Ve(i))-I(Ve(o)))}function Uo(e,n){const s=e.filter(o=>o.id!==n.id);return[n,...s].sort((o,i)=>I(i.updatedAt)-I(o.updatedAt))}function pl(e,n){const s=e.filter(o=>o.id!==n.id);return[n,...s].sort((o,i)=>I(Sl(i))-I(Sl(o)))}function qn(e){return e==="active"||e==="waiting_user"}function Sl(e){return e.dueAt||e.triggeredAt||e.cancelledAt||e.updatedAt||e.createdAt}function Oo(e){var n,s,o,i,d,c;return((n=e.title)==null?void 0:n.trim())||((o=(s=e.controlSession)==null?void 0:s.title)==null?void 0:o.trim())||((c=(d=(i=e.controlSession)==null?void 0:i.session)==null?void 0:d.title)==null?void 0:c.trim())||e.content.trim()}function $o(e){return e.content.trim()||Oo(e)}function Ho(e,n,s,o,i){var f,h,j,y;const d=(f=e.projectId)==null?void 0:f.trim();if(d&&n.has(d))return n.get(d);const c=((y=(j=(h=e.controlSession)==null?void 0:h.session)==null?void 0:j.workspaceId)==null?void 0:y.trim())||o.trim();return c?s.has(c)?s.get(c):c===o.trim()&&(i!=null&&i.trim())?i.trim():l("shell.butlerControlTimerUnknownWorkspace"):l("shell.butlerControlTimerUnknownWorkspace")}function Bo(e,n,s,o,i){var f;if(e.kind==="timer")return Ho(e.timer,n,s,o,i);const d=(f=e.automation.projectId)==null?void 0:f.trim();if(d&&n.has(d))return n.get(d);const c=Xn(e)||o.trim();return c?s.has(c)?s.get(c):c===o.trim()&&(i!=null&&i.trim())?i.trim():l("shell.butlerControlTimerUnknownWorkspace"):l("shell.butlerControlTimerUnknownWorkspace")}function _o(e,n){var i,d,c,f,h,j,y;const s=(i=e.targetSessionId)==null?void 0:i.trim();if(s&&n.has(s))return n.get(s);if((f=(c=(d=e.controlSession)==null?void 0:d.session)==null?void 0:c.title)!=null&&f.trim())return e.controlSession.session.title.trim();const o=((y=(j=(h=e.controlSession)==null?void 0:h.session)==null?void 0:j.sessionId)==null?void 0:y.trim())||e.sessionId.trim();return o&&n.has(o)?n.get(o):l("shell.butlerControlTimerUnknownSession")}function Vo(e,n){var o,i,d;if(e.kind==="timer")return _o(e.timer,n);const s=yn(e);return s&&n.has(s)?n.get(s):(d=(i=(o=e.automation.controlSession)==null?void 0:o.session)==null?void 0:i.title)!=null&&d.trim()?e.automation.controlSession.session.title.trim():l("shell.butlerControlTimerUnknownSession")}function zo(){return t.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",focusable:"false",children:t.jsx("path",{fill:"currentColor",d:"M8 1.25a6.75 6.75 0 1 0 0 13.5A6.75 6.75 0 0 0 8 1.25Zm0 1.5a5.25 5.25 0 1 1 0 10.5A5.25 5.25 0 0 1 8 2.75Zm0 2.5a.875.875 0 1 0 0 1.75a.875.875 0 0 0 0-1.75Zm-.875 3.125a.625.625 0 1 0 0 1.25h.25v1.75h-.25a.625.625 0 1 0 0 1.25h1.75a.625.625 0 1 0 0-1.25h-.25V9a.625.625 0 0 0-.625-.625h-.875Z"})})}function Wo(e){const n=Math.max(0,Math.ceil(e/1e3)),s=Math.floor(n/3600),o=Math.floor(n%3600/60),i=n%60;return s>0?`${String(s).padStart(2,"0")}:${String(o).padStart(2,"0")}:${String(i).padStart(2,"0")}`:`${String(o).padStart(2,"0")}:${String(i).padStart(2,"0")}`}function jl(e){return e==="queued"||e==="running"}function qo(e){return e.status==="active"||e.status==="waiting_user"}function Ko(e){return e.status==="queued"||e.status==="running"}function Yo(e){switch(e){case"queued":case"running":return l("shell.butlerAutomationStatusActive");case"passed":case"skipped":return l("shell.butlerAutomationStatusCompleted");case"failed":return l("shell.butlerAutomationStatusFailed");case"cancelled":return l("shell.butlerAutomationStatusCancelled");default:return e}}function Xo(e){return e==="failed"?"failed":e==="cancelled"?"cancelled":e==="passed"||e==="skipped"?"completed":"active"}function Zo(e){switch(e){case"analyzing":return l("shell.butlerTodoLifecycleAnalyzing");case"analyzed":return l("shell.butlerTodoLifecycleAnalyzed");case"session_created":return l("shell.butlerTodoLifecycleSessionCreated");case"follow_up_active":return l("shell.butlerTodoLifecycleFollowUpActive");case"completed":return l("shell.butlerTodoLifecycleCompleted");case"failed":return l("shell.butlerTodoLifecycleFailed");case"pending":default:return l("shell.butlerTodoLifecyclePending")}}function Pn(e){return e.finishedAt||e.startedAt||e.createdAt}function I(e){if(!e)return 0;const n=new Date(e).getTime();return Number.isNaN(n)?0:n}function Be(e){return typeof e=="number"&&Number.isFinite(e)?String(e):""}function Qo(e){const n=e.trim();return n||null}function sn(e){if(!e)return"";const n=new Date(e);if(Number.isNaN(n.getTime()))return"";const s=n.getFullYear(),o=String(n.getMonth()+1).padStart(2,"0"),i=String(n.getDate()).padStart(2,"0"),d=String(n.getHours()).padStart(2,"0"),c=String(n.getMinutes()).padStart(2,"0");return`${s}-${o}-${i}T${d}:${c}`}function mn(e,n){const s=e.trim();if(!s)return null;const o=Date.parse(s);if(Number.isNaN(o))throw new Error(`${n}${l("shell.butlerAutomationInvalidDateSuffix")}`);return new Date(o).toISOString()}function Go(e,n){const s=mn(e,n);if(!s)throw new Error(`${n}${l("shell.butlerAutomationRequiredSuffix")}`);return s}function cs(e,n){const s=e.trim();if(!s)throw new Error(`${n}${l("shell.butlerAutomationRequiredSuffix")}`);const o=Number.parseInt(s,10);if(!Number.isInteger(o))throw new Error(`${n}${l("shell.butlerAutomationInvalidNumberSuffix")}`);return o}function ds(e,n){const s=e.trim();if(!s)return null;const o=Number.parseInt(s,10);if(!Number.isInteger(o))throw new Error(`${n}${l("shell.butlerAutomationInvalidNumberSuffix")}`);return o}function on(e,n){const s=ds(e,n);if(s===null)return null;if(s<=0)throw new Error(`${n}${l("shell.butlerAutomationInvalidPositiveNumberSuffix")}`);return s}function Jo(e,n){const s=cs(e,n);if(s<=0)throw new Error(`${n}${l("shell.butlerAutomationInvalidPositiveNumberSuffix")}`);return s}function ei(e){const n=e.trim();if(!n)return null;const s=n.split(",").map(o=>Number.parseInt(o.trim(),10)).filter(o=>Number.isInteger(o));if(s.length===0||s.some(o=>o<0||o>6))throw new Error(l("shell.butlerAutomationCronDaysValidation"));return Array.from(new Set(s)).sort((o,i)=>o-i)}function ti(e){const n=I(e);return n<=0?"-":new Intl.DateTimeFormat("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(n))}function ni(e){for(const[n,s]of Object.entries(zn))if(s.length===e.length&&s.every((o,i)=>o===e[i]))return n;return"risk-first"}function li(e){var o;if((o=e.agentsFilePath)!=null&&o.trim())return e.agentsFilePath.trim();const n=e.workspacePath.includes("\\")?"\\":"/";return`${e.workspacePath.replace(/[\\/]+$/,"")}${n}AGENTS.md`}function si(e){switch(e){case"pending":return l("shell.butlerInfoTodoPending");case"in_progress":return l("shell.butlerInfoTodoInProgress");case"closed":return l("shell.butlerInfoTodoClosed");default:return l("shell.butlerInfoTodoPending")}}function Zn(e){switch(e){case"active":return l("shell.butlerAutomationStatusActive");case"waiting_user":return l("shell.butlerAutomationStatusWaitingUser");case"completed":return l("shell.butlerAutomationStatusCompleted");case"failed":return l("shell.butlerAutomationStatusFailed");case"cancelled":return l("shell.butlerAutomationStatusCancelled");default:return l("shell.butlerAutomationStatusActive")}}function oi(e){switch(e){case"started":return l("shell.butlerAutomationRoundKindStarted");case"continue":return l("shell.butlerAutomationRoundKindContinue");case"queued":return l("shell.butlerAutomationRoundKindQueued");case"waiting_user":return l("shell.butlerAutomationRoundKindWaitingUser");case"completed":return l("shell.butlerAutomationRoundKindCompleted");case"failed":return l("shell.butlerAutomationRoundKindFailed");case"cancelled":return l("shell.butlerAutomationRoundKindCancelled");case"limit_reached":return l("shell.butlerAutomationRoundKindLimitReached");default:return e}}function ms(e){switch(e){case"once":return l("shell.butlerAutomationTaskTypeControlTimer");case"interval":return l("shell.butlerAutomationTaskTypeInterval");case"cron":return l("shell.butlerAutomationTaskTypeCron");case"condition":return l("shell.butlerAutomationTaskTypeFollowUp");default:return l("shell.butlerAutomationTaskTypeControlTimer")}}function bs(e){return e==="interval"||e==="cron"?l("shell.butlerAutomationRunSourcePatrol"):e==="once"?l("shell.butlerAutomationRunSourceControlTimer"):l("shell.butlerAutomationRunSourceFollowUp")}function hs(e){switch(e){case"failed":return"failed";case"cancelled":return"cancelled";case"completed":case"passed":case"succeeded":return"completed";case"waiting_user":return"waiting_user";case"active":case"queued":case"running":default:return"active"}}function ii(e){switch(e){case"failed":return"failed";case"cancelled":return"cancelled";case"completed":return"completed";case"paused":return"waiting_user";case"active":default:return"active"}}function fs(e){switch(e){case"completed":return l("shell.butlerAutomationStatusCompleted");case"failed":return l("shell.butlerAutomationStatusFailed");case"cancelled":return l("shell.butlerAutomationStatusCancelled");case"paused":return l("shell.butlerAutomationStatusWaitingUser");case"active":default:return l("shell.butlerAutomationStatusActive")}}function gs(e){switch(e){case"succeeded":return l("shell.butlerAutomationStatusCompleted");case"failed":return l("shell.butlerAutomationStatusFailed");case"cancelled":case"skipped":return l("shell.butlerAutomationStatusCancelled");case"queued":case"running":default:return l("shell.butlerAutomationStatusActive")}}function xs(e){var n,s;return((n=e.title)==null?void 0:n.trim())||((s=e.actionConfig.targetSessionId)==null?void 0:s.trim())||e.actionConfig.content.trim()||e.id}function Qn(e,n){var s,o;return e.projectId&&n.has(e.projectId)?n.get(e.projectId):((o=(s=e.controlSession)==null?void 0:s.session)==null?void 0:o.workspaceId)||l("shell.butlerControlTimerNoProject")}function ri(e,n){var o,i,d;const s=(o=e.actionConfig.targetSessionId)==null?void 0:o.trim();return s&&n.has(s)?n.get(s):(d=(i=e.controlSession)==null?void 0:i.title)!=null&&d.trim()?e.controlSession.title.trim():s||null}function Al(e){var s;const n={title:((s=e.title)==null?void 0:s.trim())||"",content:e.actionConfig.content,includeTriggerContext:e.actionConfig.includeTriggerContext,dueAt:"",everySeconds:"",everyMinutes:"",everyHours:"",stopAt:"",cronMinute:"",cronHour:"",cronDaysOfWeek:"",pollIntervalSeconds:"",expiresAt:"",maxChecks:""};return e.triggerConfig.type==="once"?n.dueAt=sn(e.triggerConfig.dueAt):e.triggerConfig.type==="interval"?(n.everySeconds=Be(e.triggerConfig.seconds),n.everyMinutes=Be(e.triggerConfig.minutes),n.everyHours=Be(e.triggerConfig.hours),n.stopAt=sn(e.triggerConfig.stopAt)):e.triggerConfig.type==="cron"?(n.cronMinute=Be(e.triggerConfig.minute),n.cronHour=Be(e.triggerConfig.hour),n.cronDaysOfWeek=(e.triggerConfig.daysOfWeek??[]).join(","),n.stopAt=sn(e.triggerConfig.stopAt)):(n.pollIntervalSeconds=Be(e.triggerConfig.pollIntervalSeconds),n.expiresAt=sn(e.triggerConfig.expiresAt),n.maxChecks=Be(e.triggerConfig.maxChecks)),n}function ai(e,n){const s={title:Qo(n.title),content:n.content.trim(),includeTriggerContext:n.includeTriggerContext};if(!s.content)throw new Error(l("shell.butlerAutomationPromptRequired"));return e.triggerConfig.type==="once"?{...s,dueAt:Go(n.dueAt,l("shell.butlerAutomationDueAtLabel"))}:e.triggerConfig.type==="interval"?{...s,everySeconds:on(n.everySeconds,l("shell.butlerAutomationEverySecondsLabel")),everyMinutes:on(n.everyMinutes,l("shell.butlerAutomationEveryMinutesLabel")),everyHours:on(n.everyHours,l("shell.butlerAutomationEveryHoursLabel")),stopAt:mn(n.stopAt,l("shell.butlerAutomationStopAtLabel"))}:e.triggerConfig.type==="cron"?{...s,cronMinute:cs(n.cronMinute,l("shell.butlerAutomationCronMinuteLabel")),cronHour:ds(n.cronHour,l("shell.butlerAutomationCronHourLabel")),cronDaysOfWeek:ei(n.cronDaysOfWeek),stopAt:mn(n.stopAt,l("shell.butlerAutomationStopAtLabel"))}:{...s,pollIntervalSeconds:Jo(n.pollIntervalSeconds,l("shell.butlerAutomationPollIntervalLabel")),expiresAt:mn(n.expiresAt,l("shell.butlerAutomationExpiresAtLabel")),maxChecks:on(n.maxChecks,l("shell.butlerAutomationMaxChecksLabel"))}}function rn(e,n){const s=e.filter(o=>o.id!==n.id);return[n,...s].sort((o,i)=>I(wl(i))-I(wl(o)))}function wl(e){return e.updatedAt||e.lastRunAt||e.nextRunAt||e.createdAt}function ui(e){const s=`${e.displayName.trim()}:${e.providerId}:${e.tone}`,o=ci(e);if(!s)return Ae.default[0];const i=Array.from(s).reduce((d,c)=>{const f=c.codePointAt(0)??0;return d+f},0);return o[i%o.length]}function ci(e){const n=e.displayName.trim().toLowerCase();return/(bot|ai|智能|助手|助理|管家|buddy|helper)/.test(n)?Ae.builder:/(书|学|知|研|析|查|review|audit|scan)/.test(n)?Ae.analyst:e.tone==="friendly"?Ae.friendly:e.tone==="steady"?Ae.steady:e.tone==="direct"?e.providerId==="claude-code"?Ae.analyst:Ae.direct:e.providerId==="claude-code"?Ae.analyst:Ae.default}function Dn(e){switch(e){case"claude-code":return"Claude Code";case"codex":default:return"Codex"}}function di(e,n){const s=(e==null?void 0:e.flatMap(i=>{if(!mi(i.provider))return[];const d=i.provider,c=i.displayName||Dn(d);return[{value:d,label:i.enabled?c:`${c} (${l("settings.skillTargetDisabledTag")})`,enabled:i.enabled}]}))??Wn.map(i=>({value:i,label:Dn(i),enabled:!0})),o=new Map(s.map(i=>[i.value,i]));for(const i of n)!i||o.has(i)||o.set(i,{value:i,label:`${Dn(i)} (${l("settings.skillTargetDisabledTag")})`,enabled:!1});return Wn.map(i=>o.get(i)).filter(i=>!!i)}function mi(e){return Wn.includes(e)}function bi(e,n){var s;return((s=e.find(o=>o.value===n))==null?void 0:s.label)??n}function hi(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),t.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function fi(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"8.25",fill:"none"}),t.jsx("path",{d:"M12 8.4v4.1l2.75 1.9",fill:"none"})]})}const vs="mobile.butler.active-tab",bn=["info","automation","settings"],gi=15e3,Gn=56,Jn=1.2,Cl=360,xi=1500,vi=1500;function yi(e){const[n,s]=u.useState(e),o=u.useRef(null);return u.useEffect(()=>{if(e){o.current!==null&&(window.clearTimeout(o.current),o.current=null),s(e);return}!n||o.current!==null||(o.current=window.setTimeout(()=>{o.current=null,s(null)},xi))},[e,n]),u.useEffect(()=>()=>{o.current!==null&&window.clearTimeout(o.current)},[]),e??n}function pi(e,n){const[s,o]=u.useState(n),i=u.useRef(null);return u.useEffect(()=>{i.current!==null&&(window.clearTimeout(i.current),i.current=null),o(n)},[e]),u.useEffect(()=>{if(n){i.current!==null&&(window.clearTimeout(i.current),i.current=null),o(!0);return}!s||i.current!==null||(i.current=window.setTimeout(()=>{i.current=null,o(!1)},vi))},[n,s]),u.useEffect(()=>()=>{i.current!==null&&window.clearTimeout(i.current)},[]),s}function Si(e,n){return n===!0?!0:e?e.session.activityState==="running"||e.session.runningState==="starting"||e.session.runningState==="running"||e.session.runningState==="reconnecting":!1}function ji(){if(typeof window>"u")return"info";try{const e=window.localStorage.getItem(vs);return e==="automation"||e==="settings"?e:"info"}catch{return"info"}}function Ai(e){var n,s,o;return((n=e.title)==null?void 0:n.trim())||((s=e.session.title)==null?void 0:s.trim())||((o=e.lastSummary)==null?void 0:o.trim())||e.sessionId}function wi(e,n){return e==="settings"?"settings":e==="automation"?"automation":e==="info"?"info":n}function Ci(e,n,s){if(!n)return{closeSidebar:!1,nextTab:e};const o=s.x-n.x,i=s.y-n.y;if(Math.abs(o)<Gn)return{closeSidebar:!1,nextTab:e};if(Math.abs(o)<Math.abs(i)*Jn)return{closeSidebar:!1,nextTab:e};const d=bn.indexOf(e);if(o>0&&d===0)return{closeSidebar:!0,nextTab:e};const c=o<0?Math.min(bn.length-1,d+1):Math.max(0,d-1);return{closeSidebar:!1,nextTab:bn[c]??e}}function Ti(e,n){if(!e)return null;const s=n.x-e.x,o=n.y-e.y;return Math.abs(s)<Gn||Math.abs(s)<Math.abs(o)*Jn?null:s>0?"list":"sidebar"}function Un(e){return e instanceof Element?!!e.closest("input, textarea, select, option, label, button, a, [contenteditable='true'], [data-mobile-butler-gesture='ignore']"):!1}function Ni(){var Zt,At,P,Qt,st,Oe,wt,Ct,Tt,Gt,be;const{workspaceId:e=""}=Gl(),n=Qs(),s=Jl(),{showToast:o}=es(),{navigationGroups:i,requestNavigationRefresh:d,selectWorkspace:c}=Kn(),f=((Zt=i.find(r=>r.workspace.id===e))==null?void 0:Zt.workspace)??null,h=u.useMemo(()=>new Map(i.map(r=>[r.workspace.id,r.workspace.name])),[i]),j=u.useMemo(()=>new Map(i.flatMap(r=>r.sessions.map(b=>{var v;return[b.sessionId,((v=b.title)==null?void 0:v.trim())||l("common.unknown")]}))),[i]),y=u.useMemo(()=>new Map(i.flatMap(r=>r.sessions.map(b=>[b.sessionId,r.workspace.id]))),[i]),L=new URLSearchParams(n.search).get("tab"),$=u.useRef(ji()),D=wi(L,$.current),k=u.useRef(null),_=u.useRef(null),J=u.useRef(null),ee=u.useRef(null),te=u.useRef(null),[Y,U]=u.useState(null),[re,H]=u.useState(null),[Ee,nl]=u.useState(null),[Ce,Rt]=u.useState(null),[ce,ze]=u.useState(null),[Te,ne]=u.useState(null),[O,de]=u.useState(null),[Ne,Ie]=u.useState(null),[We,kt]=u.useState(null),[qe,Lt]=u.useState(null),[Et,Ke]=u.useState(null),[Mt,me]=u.useState(null),[Ye,Re]=u.useState(()=>Date.now()),[le,Xe]=u.useState(null),[he,Ft]=u.useState(null),[p,M]=u.useState({loading:!0,initialized:!1,profile:null,overview:null,followUpTasks:[],inboxItems:[],patrolPlans:[],controlSessions:[],controlTimers:[],assistantAutomations:[],assistantAutomationRuns:[]}),Pt=u.useMemo(()=>{var r;return new Map((((r=p.overview)==null?void 0:r.projects)??[]).map(b=>[b.id,b.name]))},[(At=p.overview)==null?void 0:At.projects]);(!ee.current||te.current!==e)&&(ee.current=new Hl(e),te.current=e);const R=ee.current,at=N(R,r=>r.loading),fe=N(R,r=>r.initialized),X=N(R,r=>r.profile),ae=N(R,r=>r.activeProvider),w=N(R,r=>r.controlSession),Sn=N(R,r=>r.capabilities),ut=N(R,r=>r.messages),ye=N(R,r=>r.historyState),ct=N(R,r=>r.loadingOlderMessages),jn=N(R,r=>r.hasOlderMessages),ke=N(R,r=>r.sending),Dt=N(R,r=>r.runtimeHasActiveRun),Ze=N(R,r=>r.runtimeCanInterrupt),dt=N(R,r=>r.contextUsage),Qe=N(R,r=>r.permissionRequests),{composerPortalTarget:mt}=Ys(),bt=u.useRef(null),Ge=u.useRef(null),Je=u.useRef(!1),ht=u.useRef(new Set);u.useEffect(()=>{if($.current=D,!(typeof window>"u"))try{window.localStorage.setItem(vs,D)}catch{}},[D]),u.useEffect(()=>{if(L===D)return;const r=new URLSearchParams(n.search);r.set("tab",D),s({pathname:n.pathname,search:`?${r.toString()}`},{replace:!0})},[D,n.pathname,n.search,s,L]),u.useEffect(()=>{e&&c(e)},[c,e]),u.useEffect(()=>{e&&R.initialize()},[R,e]),u.useEffect(()=>{var K,je,Z,xe,$e;const r=((K=w==null?void 0:w.session)==null?void 0:K.sessionId)??null;if(Ge.current!==r&&(Ge.current=r,Je.current=!1,ht.current=new Set),!r)return;const b=Qe.filter(Q=>Q.status==="pending"),v=new Set(b.map(Q=>Q.id)),A=((je=w==null?void 0:w.title)==null?void 0:je.trim())||((xe=(Z=w==null?void 0:w.session)==null?void 0:Z.title)==null?void 0:xe.trim())||(($e=X==null?void 0:X.displayName)==null?void 0:$e.trim())||l("shell.butlerEntry");Je.current&&b.forEach(Q=>{ht.current.has(Q.id)||o({id:`mobile-butler-permission-request-${Q.id}`,title:l("conversation.permissionRequestToastTitle"),description:l("conversation.backgroundPermissionToastDescription",{title:A,requestTitle:Q.title}),tone:"warning",durationMs:8e3})}),ht.current=v,Je.current=!0},[(P=w==null?void 0:w.session)==null?void 0:P.sessionId,(Qt=w==null?void 0:w.session)==null?void 0:Qt.title,w==null?void 0:w.title,Qe,X==null?void 0:X.displayName,o]),u.useEffect(()=>{if(!e){M({loading:!1,initialized:!1,profile:null,overview:null,followUpTasks:[],inboxItems:[],patrolPlans:[],controlSessions:[],controlTimers:[],assistantAutomations:[],assistantAutomationRuns:[]});return}let r=!1;async function b(je){M(Z=>({...Z,loading:!0}));try{const Z=await Xs();if(!Z.initialized||!Z.profile){r||M({loading:!1,initialized:!1,profile:null,overview:null,followUpTasks:[],inboxItems:[],patrolPlans:[],controlSessions:[],controlTimers:[],assistantAutomations:[],assistantAutomationRuns:[]});return}const[xe,$e,Q,ot,Jt,kn,Ln]=await Promise.all([fl(),Hn(),Xl({workspaceId:e}),fn(),Zl(),Bn({limit:100}),_n({limit:100})]),en=xe.overview.projects.filter(oe=>oe.workspaceId===e).map(oe=>oe.id),En=await Promise.all(en.map(oe=>Ql(oe)));if(r)return;M({loading:!1,initialized:!0,profile:Z.profile,overview:xe.overview,followUpTasks:$e.items.filter(oe=>oe.workspaceId===e),inboxItems:Q.items.filter(oe=>oe.status!=="closed"),patrolPlans:En.flatMap(oe=>oe.items),controlSessions:ot.items,controlTimers:Jt.items,assistantAutomations:kn.payload.items,assistantAutomationRuns:Ln.payload.items})}catch(Z){if(r)return;M(xe=>({...xe,loading:!1})),je&&o({title:l("shell.butlerLoadFailed"),description:Z instanceof Error?Z.message:void 0,tone:"error"})}}b(!0);const v=window.setInterval(()=>{b(!1)},gi),A=ts(()=>{b(!1)}),K=()=>{b(!1)};return window.addEventListener(vn,K),()=>{r=!0,window.clearInterval(v),A(),window.removeEventListener(vn,K)}},[o,e]);const z=u.useMemo(()=>{var r;return new Set((((r=p.overview)==null?void 0:r.projects)??[]).filter(b=>b.workspaceId===e).map(b=>b.id))},[(st=p.overview)==null?void 0:st.projects,e]),ft=u.useMemo(()=>p.controlTimers.filter(r=>{var b,v;return r.projectId?z.has(r.projectId):((v=(b=r.controlSession)==null?void 0:b.session)==null?void 0:v.workspaceId)===e}),[p.controlTimers,e,z]),gt=u.useMemo(()=>p.followUpTasks.filter(r=>Rl(r.status)),[p.followUpTasks]),et=u.useMemo(()=>{var r;return(((r=p.overview)==null?void 0:r.verifications)??[]).filter(b=>b.projectId?z.has(b.projectId):!1)},[(Oe=p.overview)==null?void 0:Oe.verifications,z]),tt=u.useMemo(()=>[...gt].sort((r,b)=>E(ve(b))-E(ve(r))).slice(0,4),[gt]),An=u.useMemo(()=>Nl(et,"active"),[et]),Ut=u.useMemo(()=>Nl(et,"history"),[et]),Ot=u.useMemo(()=>Di(p.inboxItems.filter(r=>r.status!=="closed")).slice(0,4),[p.inboxItems]),xt=u.useMemo(()=>Ml(p.assistantAutomations,p.overview,z,"active"),[p.assistantAutomations,p.overview,z]),$t=u.useMemo(()=>Fl(p.assistantAutomations,p.assistantAutomationRuns,p.overview,z,"active"),[p.assistantAutomations,p.assistantAutomationRuns,p.overview,z]),se=u.useMemo(()=>O?p.assistantAutomations.find(r=>r.id===O)??null:null,[O,p.assistantAutomations]),Ht=u.useMemo(()=>O?p.assistantAutomationRuns.filter(r=>r.automationId===O).sort((r,b)=>E(b.createdAt)-E(r.createdAt)).slice(0,6):[],[O,p.assistantAutomationRuns]);u.useEffect(()=>{O&&!se&&(de(null),Ie(null))},[se,O]);const Bt=u.useMemo(()=>[...p.followUpTasks].filter(r=>!Rl(r.status)).sort((r,b)=>E(ve(b))-E(ve(r))).slice(0,8),[p.followUpTasks]),nt=u.useMemo(()=>Ml(p.assistantAutomations,p.overview,z,"history"),[p.assistantAutomations,p.overview,z]),S=u.useMemo(()=>Fl(p.assistantAutomations,p.assistantAutomationRuns,p.overview,z,"history"),[p.assistantAutomations,p.assistantAutomationRuns,p.overview,z]),ge=u.useMemo(()=>Si(w,Dt),[w,Dt]),W=pi((w==null?void 0:w.session.sessionId)??null,ge),pe=W||ke,ue=W||ke,C=Ze===!0||ke?!0:Ze??!1,q=u.useMemo(()=>{if(!w||W)return null;const r=ft.filter(A=>A.status==="active"&&A.controlSessionId===w.id).map(A=>({kind:"timer",timer:A})),b=new Set(ft.filter(A=>A.status==="active"&&A.controlSessionId===w.id).map(A=>A.id)),v=p.assistantAutomations.filter(A=>A.status==="active"&&A.controlSessionId===w.id&&!!A.nextRunAt&&!b.has(A.id)).map(A=>({kind:"automation",automation:A}));return[...r,...v].sort((A,K)=>E(pn(A))-E(pn(K)))[0]??null},[w,W,p.assistantAutomations,ft]),g=yi(q),_t=p.loading||at,F=!_t&&(!p.initialized||!fe||!p.profile),lt=((wt=X==null?void 0:X.displayName)==null?void 0:wt.trim())||((Tt=(Ct=p.profile)==null?void 0:Ct.displayName)==null?void 0:Tt.trim())||l("shell.butlerEntry"),Me=!w&&ut.length===0,Fe=!F&&Y===null;u.useEffect(()=>{if(Re(Date.now()),!g)return;const r=window.setInterval(()=>{Re(Date.now())},1e3);return()=>{window.clearInterval(r)}},[g]),u.useEffect(()=>{Y!=="sidebar"&&H(null)},[Y]);const wn=re==="follow_up"?t.jsx(Tl,{title:l("shell.butlerFollowUpHistoryTitle"),description:l("shell.butlerFollowUpHistoryDescription"),emptyText:l("shell.butlerInfoFollowUpRecordsEmpty"),onClose:()=>H(null),items:Bt.map(r=>{var b,v,A;return{id:r.id,title:((b=r.sessionTitle)==null?void 0:b.trim())||r.projectName,subtitle:r.projectName,status:Pl(r.status),content:((v=r.waitingReason)==null?void 0:v.trim())||((A=r.lastAutomationSummary)==null?void 0:A.trim())||r.objective||l("shell.butlerInfoFollowUpFallback",{updatedAt:G(ve(r))}),meta:G(ve(r)),actionLabel:an(r.status)?Ce===r.id?l("conversation.butlerFollowUpStopping"):l("conversation.butlerStopFollowUpAction"):null,actionDisabled:Ce===r.id,onAction:an(r.status)?()=>{qt(r)}:void 0}})}):re==="verification"?t.jsx(Tl,{title:l("shell.butlerVerificationHistoryTitle"),description:l("shell.butlerVerificationHistoryDescription"),emptyText:l("shell.butlerVerificationHistoryEmpty"),onClose:()=>H(null),items:Ut.map((r,b)=>({id:`${r.title}:${b}`,title:r.title,subtitle:r.subtitle,status:r.status,content:r.content,meta:r.meta,actionLabel:r.verification&&Ll(r.verification.status)?ce===r.verification.id?l("conversation.butlerVerificationStopping"):l("conversation.butlerStopVerificationAction"):null,actionDisabled:r.verification?ce===r.verification.id:!1,onAction:r.verification?()=>{Ue(r.verification)}:void 0}))}):re==="automation"?t.jsx(Mi,{taskItems:nt,runItems:S,onClose:()=>H(null)}):D==="info"?t.jsxs(t.Fragment,{children:[t.jsx(Nt,{title:l("shell.butlerInfoFollowUpRecordsTitle"),emptyText:l("shell.butlerInfoFollowUpRecordsEmpty"),actionLabel:l("shell.butlerFollowUpHistoryAction"),onAction:()=>H("follow_up"),items:tt.map(r=>{var b,v,A;return{id:r.id,title:((b=r.sessionTitle)==null?void 0:b.trim())||r.projectName,subtitle:r.projectName,status:Pl(r.status),content:((v=r.waitingReason)==null?void 0:v.trim())||((A=r.lastAutomationSummary)==null?void 0:A.trim())||r.objective||l("shell.butlerInfoFollowUpFallback",{updatedAt:G(ve(r))}),meta:G(ve(r)),actionLabel:an(r.status)?Ce===r.id?l("conversation.butlerFollowUpStopping"):l("conversation.butlerStopFollowUpAction"):null,actionDisabled:Ce===r.id,onAction:an(r.status)?()=>{qt(r)}:void 0}})}),t.jsx(Nt,{title:l("shell.butlerInfoVerificationRecordsTitle"),emptyText:l("shell.butlerInfoVerificationRecordsEmpty"),actionLabel:l("shell.butlerFollowUpHistoryAction"),onAction:()=>H("verification"),items:An.map((r,b)=>({id:`${r.title}:${b}`,title:r.title,subtitle:r.subtitle,status:r.status,content:r.content,meta:r.meta,actionLabel:r.verification&&Ll(r.verification.status)?ce===r.verification.id?l("conversation.butlerVerificationStopping"):l("conversation.butlerStopVerificationAction"):null,actionDisabled:r.verification?ce===r.verification.id:!1,onAction:r.verification?()=>{Ue(r.verification)}:void 0}))}),t.jsx(Ei,{title:l("shell.butlerInfoTodoRecordsTitle"),emptyText:l("shell.butlerInfoTodoRecordsEmpty"),items:Ot.map((r,b)=>({id:`${r.title}:${b}`,title:r.title,content:r.content}))})]}):D==="automation"?t.jsxs(t.Fragment,{children:[t.jsx(Ri,{items:xt,emptyText:l("shell.butlerAutomationTasksEmpty"),actionLabel:l("shell.butlerFollowUpHistoryAction"),onAction:()=>H("automation"),selectedAutomationId:O,cancellingAutomationId:Te,onSelectAutomation:Nn,onCancelAutomation:r=>{Kt(r)}}),se&&Ne?t.jsx(ki,{automation:se,editorState:Ne,saving:We===se.id,recentRuns:Ht,workspaceNameById:h,sessionTitleById:j,onClose:()=>{de(null),Ie(null)},onEditorChange:r=>{Ie(b=>b&&{...b,...r})},onSave:()=>{In()}}):null,t.jsx(Nt,{title:l("shell.butlerAutomationRunsTitle"),emptyText:l("shell.butlerAutomationRunsEmpty"),items:$t.map(r=>({id:r.id,title:r.title,subtitle:r.projectName,status:r.statusLabel,content:`${r.sourceLabel} · ${r.summary}`,meta:G(r.createdAt)}))})]}):t.jsxs("section",{className:"mobile-feature-panel surface-card mobile-butler-record-section",children:[t.jsx("div",{className:"mobile-feature-section-header",children:t.jsx("div",{children:t.jsx("h2",{children:l("shell.butlerSidebarSettingsTab")})})}),t.jsxs("div",{className:"mobile-butler-settings-summary",children:[t.jsx(we,{label:l("shell.butlerDisplayNameLabel"),value:lt}),t.jsx(we,{label:l("shell.butlerProviderLabel"),value:$l(ae)}),t.jsx(we,{label:l("shell.mobileButlerAssistantWorkspaceLabel"),value:((Gt=p.profile)==null?void 0:Gt.workspacePath)??(f==null?void 0:f.path)??"-"})]})]});Pi(bt,Ee,Fe,`${e}:${Y??"none"}`);function Vt(r){r!==D&&(H(null),s(Vn(e,r),{replace:!0}))}function Pe(r){if(r.changedTouches.length!==1){k.current=null;return}if(Un(r.target)){k.current=null;return}const b=r.changedTouches[0];k.current={x:b.clientX,y:b.clientY}}function De(r){if(r.changedTouches.length!==1)return;const b=k.current;k.current=null;const v=r.changedTouches[0],A=Ti(b,{x:v.clientX,y:v.clientY});A&&U(A)}function Cn(r){if(r.changedTouches.length!==1){_.current=null;return}if(Un(r.target)){_.current=null;return}const b=r.changedTouches[0];_.current={x:b.clientX,y:b.clientY}}function vt(r){const b=_.current;if(_.current=null,!b||r.changedTouches.length!==1)return;const v=r.changedTouches[0],A=v.clientX-b.x,K=v.clientY-b.y;A>-Gn||Math.abs(A)<Math.abs(K)*Jn||U(null)}function Le(r){if(r.changedTouches.length!==1){J.current=null;return}if(Un(r.target)){J.current=null;return}const b=r.changedTouches[0];J.current={x:b.clientX,y:b.clientY}}function zt(r){const b=J.current;if(J.current=null,r.changedTouches.length!==1)return;const v=r.changedTouches[0],A=Ci(D,b,{x:v.clientX,y:v.clientY});if(A.closeSidebar){U(null);return}A.nextTab!==D&&Vt(A.nextTab)}async function Wt(r){await R.openControlSession(r),U(null)}async function yt(){const r=await fn();M(b=>({...b,controlSessions:r.items}))}async function pt(){if(!(!le||he)){Ft(le.id);try{await Bl(le.session.sessionId),le.id===(w==null?void 0:w.id)&&await R.openControlSession(""),Xe(null),await yt(),d(),U(null),o({title:l("shell.deleteSessionSuccess"),tone:"success"})}catch(r){o({title:r instanceof Error?r.message:l("shell.deleteSessionFailed"),tone:"error"})}finally{Ft(null)}}}async function Se(){await R.startFreshSession(),U(null),d()}async function St(r,b){var v;(((v=b==null?void 0:b.attachments)==null?void 0:v.length)??0)>0&&o({title:l("shell.butlerAttachmentUnsupported"),tone:"warning"}),await R.sendMessage(r,{model:(b==null?void 0:b.model)??null,reasoningLevel:(b==null?void 0:b.reasoningLevel)??null,permissionMode:null}),d()}async function jt(){const[r,b,v,A]=await Promise.all([fl(),Hn(),Bn({limit:100}),_n({limit:100})]);await R.reloadEventsAndOverview(),M(K=>({...K,overview:r.overview,followUpTasks:b.items.filter(je=>je.workspaceId===e),assistantAutomations:v.payload.items,assistantAutomationRuns:A.payload.items}))}async function qt(r){Rt(r.id);try{const b=await _l(r.id);M(v=>({...v,followUpTasks:Ui(v.followUpTasks,b.task)})),await jt(),d(),o({title:l("conversation.butlerFollowUpStopped"),description:l("conversation.butlerFollowUpStoppedDescription"),tone:"success"})}catch(b){o({title:l("conversation.butlerFollowUpStopFailed"),description:b instanceof Error?b.message:void 0,tone:"error"})}finally{Rt(null)}}async function Ue(r){ze(r.id);try{await Vl(r.projectId,r.id),await jt(),d(),o({title:l("conversation.butlerVerificationStopped"),description:l("conversation.butlerVerificationStoppedDescription"),tone:"success"})}catch(b){o({title:l("conversation.butlerVerificationStopFailed"),description:b instanceof Error?b.message:void 0,tone:"error"})}finally{ze(null)}}async function Tn(r){Lt(r);try{const b=await gn(r);M(v=>({...v,controlTimers:Il(v.controlTimers,b.timer)})),o({title:l("shell.butlerControlTimerCancelSucceeded"),tone:"success"})}catch(b){o({title:l("shell.butlerControlTimerCancelFailed"),description:b instanceof Error?b.message:void 0,tone:"error"})}finally{Lt(null)}}function Nn(r){if(O===r){de(null),Ie(null);return}const b=p.assistantAutomations.find(v=>v.id===r);b&&(de(r),Ie(Dl(b)))}async function In(){if(!se||!Ne)return;let r;try{r=tr(se,Ne)}catch(b){o({title:l("shell.butlerAutomationSaveFailed"),description:b instanceof Error?b.message:void 0,tone:"error"});return}kt(se.id);try{const b=await zl(se.id,r);M(v=>({...v,assistantAutomations:On(v.assistantAutomations,b.payload.automation)})),de(b.payload.automation.id),Ie(Dl(b.payload.automation)),o({title:l("shell.butlerAutomationSaveSucceeded"),tone:"success"})}catch(b){o({title:l("shell.butlerAutomationSaveFailed"),description:b instanceof Error?b.message:void 0,tone:"error"})}finally{kt(null)}}async function Kt(r){ne(r);try{const b=await xn(r);M(v=>({...v,assistantAutomations:On(v.assistantAutomations,b.payload.automation)})),o({title:l("shell.butlerControlTimerCancelSucceeded"),tone:"success"})}catch(b){o({title:l("shell.butlerControlTimerCancelFailed"),description:b instanceof Error?b.message:void 0,tone:"error"})}finally{ne(null)}}async function V(r){const b=r.content.trim();if(!b){o({title:l("shell.butlerControlTimerExecuteNowFailed"),tone:"error"});return}Ke(r.id);try{const v=await gn(r.id);M(A=>({...A,controlTimers:Il(A.controlTimers,v.timer)})),await R.sendMessage(b),d(),o({title:l("shell.butlerControlTimerExecuteNowSucceeded"),tone:"success"})}catch(v){o({title:l("shell.butlerControlTimerExecuteNowFailed"),description:v instanceof Error?v.message:void 0,tone:"error"})}finally{Ke(null)}}async function Yt(r){if(r.kind==="timer"){await Tn(r.timer.id);return}await Kt(r.automation.id)}async function Rn(r){if(r.kind==="timer"){await V(r.timer);return}if(r.automation.triggerType!=="once")return;const b=r.automation.actionConfig.content.trim();if(!b){o({title:l("shell.butlerControlTimerExecuteNowFailed"),tone:"error"});return}Ke(r.automation.id);try{await xn(r.automation.id),M(v=>({...v,assistantAutomations:On(v.assistantAutomations,{...r.automation,status:"cancelled",nextRunAt:null,cancelledAt:new Date().toISOString(),updatedAt:new Date().toISOString()})})),await R.sendMessage(b),d(),o({title:l("shell.butlerControlTimerExecuteNowSucceeded"),tone:"success"})}catch(v){o({title:l("shell.butlerControlTimerExecuteNowFailed"),description:v instanceof Error?v.message:void 0,tone:"error"})}finally{Ke(null)}}function Xt(r){const b=tl(r),v=(b?y.get(b):null)||el(r)||e;!b||!v||(U(null),s(dn(v,b)))}return f?t.jsxs("main",{ref:bt,className:"mobile-feature-page mobile-page-fixed-root mobile-butler-page mobile-butler-page-shell","data-mobile-butler-drawer":Y??"none",children:[t.jsx(eo,{currentWorkspace:f,workspaces:i.map(r=>r.workspace),heading:l("shell.mobileButlerEntry"),triggerLabel:f.name,onSelectWorkspace:r=>{c(r),s(Vn(r,D))},trailing:t.jsxs("div",{className:"mobile-butler-header-trailing","data-mobile-butler-gesture":"ignore",children:[t.jsxs("div",{className:"mobile-butler-hero-top mobile-butler-toolbar-identity",children:[t.jsx("div",{className:"mobile-butler-hero-badge",children:"AI"}),t.jsxs("div",{className:"mobile-butler-hero-copy",children:[t.jsx("strong",{children:lt}),t.jsx("span",{children:$l(ae)})]})]}),t.jsxs("div",{className:"mobile-butler-toolbar-actions",children:[t.jsx("button",{type:"button",className:"mobile-butler-toolbar-button","aria-label":l("shell.butlerHistoryAction"),title:l("shell.butlerHistoryAction"),onClick:()=>U("list"),children:"≡"}),t.jsx("button",{type:"button",className:"mobile-butler-toolbar-button","aria-label":l("shell.butlerSidebarTabsLabel"),title:l("shell.butlerSidebarTabsLabel"),onClick:()=>U("sidebar"),children:"ⓘ"})]})]})}),t.jsxs("div",{className:"mobile-butler-stage-shell",children:[Y?t.jsx("button",{type:"button",className:"mobile-butler-drawer-scrim","aria-label":l("common.close"),onClick:()=>U(null)}):null,t.jsxs("aside",{className:"mobile-butler-drawer mobile-butler-drawer-list",style:{width:`min(88vw, ${Cl}px)`},onTouchStart:Cn,onTouchEnd:vt,children:[t.jsxs("div",{className:"mobile-butler-drawer-header",children:[t.jsxs("div",{children:[t.jsx("h2",{children:l("shell.butlerHistoryTitle")}),t.jsx("p",{children:l("shell.butlerHistoryDescription")})]}),t.jsx("button",{type:"button",className:"mobile-butler-toolbar-button","aria-label":l("shell.butlerNewSessionAction"),onClick:()=>{Se()},children:"+"})]}),t.jsx("div",{className:"mobile-butler-list-body",children:t.jsx(Fi,{activeControlSessionId:(w==null?void 0:w.id)??null,deletingSessionId:he,sessions:p.controlSessions,onSelectSession:r=>{Wt(r)},onDeleteSession:r=>{Xe(r)}})})]}),t.jsx("div",{className:"mobile-butler-main-stage",onTouchStart:Pe,onTouchEnd:De,children:_t?t.jsx("section",{className:"mobile-butler-loading-shell",children:t.jsx(ns,{})}):F?t.jsxs("section",{className:"mobile-butler-empty-panel",children:[t.jsx("h2",{children:l("shell.mobileButlerEmptyTitle")}),t.jsx("p",{children:l("shell.mobileButlerEmptyBody")})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"mobile-butler-chat-body",children:[t.jsx(Wl,{requests:Qe,replyingRequestId:Mt,onReply:async(r,b)=>{me(r);try{await R.replyPermissionRequest(r,b)}catch(v){o({title:l("conversation.permissionRequestReplyFailed"),description:v instanceof Error?v.message:void 0,tone:"error"})}finally{me(null)}}}),Me?t.jsxs("section",{className:"mobile-butler-empty-panel",children:[t.jsx("h2",{children:l("shell.butlerConversationTitle")}),t.jsx("p",{children:l("shell.butlerProjectSyncEmptyState")})]}):t.jsx("div",{className:"conversation-timeline-shell mobile-butler-timeline-shell",children:t.jsx(ql,{sessionId:(be=w==null?void 0:w.session)==null?void 0:be.sessionId,items:Kl({messages:ut}),historyState:ye,loadingOlderMessages:ct,hasOlderMessages:jn,provider:ae,onLoadOlderMessages:()=>{R.loadOlderMessages()},onRetryMessage:r=>{R.retryMessage(r)}})})]}),g?t.jsx(Ii,{schedule:g,currentWorkspaceId:e,currentWorkspaceName:(f==null?void 0:f.name)??null,projectNameById:Pt,workspaceNameById:h,sessionTitleById:j,sessionWorkspaceIdById:y,countdownNow:Ye,cancelling:g.kind==="timer"?qe===g.timer.id:Te===g.automation.id,executingNow:Et===Ki(g),onCancel:()=>{Yt(g)},onExecuteNow:()=>{Rn(g)},onOpenSession:()=>{Xt(g)}}):null,Fe?t.jsx("div",{className:"mobile-butler-chat-composer","data-mobile-butler-gesture":"ignore",children:t.jsx(Yl,{capabilities:Sn,draftStorageId:`mobile-butler:${e}:${ae}`,panelRef:nl,portalContainer:mt,placeholder:l("shell.butlerComposerPlaceholder",{displayName:lt}),hasActiveRun:pe,canInterrupt:C,contextUsage:dt,isSubmitting:ke,isRunning:ue,onInterrupt:async()=>{await R.interrupt(),d()},onSend:async(r,b)=>{await St(r,b)}})}):null]})}),t.jsx("aside",{className:"mobile-butler-drawer mobile-butler-drawer-sidebar",style:{width:`min(88vw, ${Cl}px)`},onTouchStart:Le,onTouchEnd:zt,children:t.jsxs("div",{className:"mobile-butler-sidebar-shell",children:[t.jsx("div",{className:"mobile-butler-segmented-shell","data-mobile-butler-gesture":"ignore",children:t.jsx("div",{className:"mobile-butler-segmented-control",role:"tablist","aria-label":l("shell.butlerSidebarTabsLabel"),children:bn.map(r=>{const b=D===r,v=r==="info"?l("shell.butlerSidebarInfoTab"):r==="automation"?l("shell.butlerSidebarAutomationTab"):l("shell.butlerSidebarSettingsTab");return t.jsx("button",{type:"button",role:"tab",className:"mobile-butler-segmented-button","aria-selected":b,onClick:()=>{Vt(r)},children:v},r)})})}),t.jsx("div",{className:"mobile-page-top-body mobile-butler-body mobile-butler-sidebar-body",children:wn})]})})]}),t.jsx(Js,{open:le!==null,title:l("shell.deleteSessionConfirmTitle"),description:l("shell.deleteSessionConfirmDescription"),height:"auto",onClose:()=>{he||Xe(null)},footer:t.jsxs("div",{className:"workbench-modal-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:!!he,onClick:()=>Xe(null),children:l("common.cancel")}),t.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:!!he,onClick:()=>{pt()},children:he?l("common.loading"):l("shell.deleteSessionAction")})]}),children:t.jsx("p",{className:"mobile-butler-empty-text",children:le?Ai(le):""})})]}):t.jsx("main",{className:"mobile-feature-page mobile-page-scroll-root",children:t.jsxs("article",{className:"mobile-feature-empty surface-card",children:[t.jsx("h1",{children:l("shell.workspaceDetailMissingTitle")}),t.jsx("p",{children:l("shell.workspaceDetailMissingBody")})]})})}function Ii(e){const n=u.useId(),s=u.useId(),o=u.useRef(null),i=u.useRef(null),[d,c]=u.useState(!1),f=Xi(e.schedule,e.countdownNow),h=Zi(e.schedule,e.countdownNow),j=_i(e.schedule,e.projectNameById,e.workspaceNameById,e.currentWorkspaceId,e.currentWorkspaceName),y=zi(e.schedule,e.sessionTitleById),L=Qi(e.schedule),$=tl(e.schedule),D=!!($&&(e.sessionWorkspaceIdById.has($)||el(e.schedule))),k=Yi(e.schedule);return u.useEffect(()=>{if(!d)return;const _=ee=>{var te,Y;(te=o.current)!=null&&te.contains(ee.target)||(Y=i.current)!=null&&Y.contains(ee.target)||c(!1)},J=ee=>{ee.key==="Escape"&&c(!1)};return document.addEventListener("pointerdown",_),document.addEventListener("keydown",J),()=>{document.removeEventListener("pointerdown",_),document.removeEventListener("keydown",J)}},[d]),t.jsxs("section",{className:"mobile-feature-panel surface-card mobile-butler-timer-banner","aria-live":"polite",children:[t.jsxs("div",{className:"mobile-butler-timer-status",children:[t.jsx("span",{className:"mobile-butler-timer-pulse","aria-hidden":"true"}),t.jsx("span",{className:"mobile-butler-timer-caption",children:l("shell.butlerControlTimerBannerTitle")})]}),t.jsxs("div",{className:"mobile-butler-timer-display-panel",children:[t.jsx("p",{className:"mobile-butler-timer-display-clock",children:h}),t.jsx("p",{className:"mobile-butler-timer-countdown",children:f})]}),t.jsxs("div",{className:"mobile-butler-timer-meta",children:[t.jsxs("div",{className:"mobile-butler-timer-meta-card",children:[t.jsx("span",{children:l("shell.butlerControlTimerWorkspaceLabel")}),t.jsx("strong",{title:j,children:j})]}),t.jsxs("div",{className:"mobile-butler-timer-meta-card",children:[t.jsx("span",{children:l("shell.butlerControlTimerSessionLabel")}),D?t.jsx("button",{type:"button",className:"mobile-butler-timer-session-link",title:y,"aria-label":`${l("shell.butlerControlTimerSessionLabel")}:${y}`,style:{padding:0,border:"none",background:"transparent",color:"inherit",font:"inherit",fontWeight:600,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",cursor:"pointer",textDecoration:"underline"},onClick:e.onOpenSession,children:y}):t.jsx("strong",{title:y,children:y})]})]}),t.jsxs("div",{className:"mobile-butler-timer-actions",children:[t.jsxs("div",{className:"mobile-butler-timer-detail",ref:o,children:[t.jsx("button",{id:n,type:"button",className:"mobile-butler-timer-detail-button","aria-label":l("shell.butlerControlTimerDetailAction"),"aria-haspopup":"dialog","aria-expanded":d,"aria-controls":d?s:void 0,title:l("shell.butlerControlTimerDetailAction"),onClick:()=>{c(_=>!_)},children:t.jsx("span",{className:"mobile-butler-timer-detail-icon","aria-hidden":"true",children:t.jsx(Wi,{})})}),t.jsx(Yn,{open:d,id:s,className:"mobile-butler-timer-detail-popover",anchorRef:o,popoverRef:i,labelledBy:n,maxWidth:288,gap:8,viewportPadding:12,children:t.jsxs("div",{children:[t.jsx("strong",{children:l("shell.butlerControlTimerPromptTitle")}),t.jsx("p",{children:L})]})})]}),k?t.jsx("button",{type:"button",className:"secondary-button mobile-butler-timer-action",disabled:e.cancelling||e.executingNow,onClick:e.onExecuteNow,children:e.executingNow?l("shell.butlerControlTimerExecutingNow"):l("shell.butlerControlTimerExecuteNowAction")}):null,t.jsx("button",{type:"button",className:"secondary-button mobile-butler-timer-action",disabled:e.cancelling||e.executingNow,onClick:e.onCancel,children:e.cancelling?l("shell.butlerControlTimerCancelling"):l("shell.butlerControlTimerStopAction")})]}),k?t.jsx("p",{className:"mobile-butler-timer-note",children:l("shell.butlerControlTimerActionNote")}):null]})}function we({label:e,value:n}){return t.jsxs("div",{className:"mobile-butler-info-metric",children:[t.jsx("span",{children:e}),t.jsx("strong",{title:n,children:n})]})}function Ri(e){return t.jsxs("section",{className:"mobile-feature-panel surface-card mobile-butler-record-section",children:[t.jsxs("div",{className:"mobile-feature-section-header",children:[t.jsxs("div",{children:[t.jsx("h2",{children:l("shell.butlerAutomationTasksTitle")}),t.jsx("p",{children:l("shell.butlerAutomationMobileOverviewDescription")})]}),t.jsxs("div",{className:"mobile-feature-section-actions",children:[e.actionLabel&&e.onAction?t.jsx("button",{type:"button",className:"mobile-butler-section-action",onClick:e.onAction,children:e.actionLabel}):null,t.jsx("span",{className:"mobile-feature-counter",children:e.items.length})]})]}),e.items.length>0?t.jsx("div",{className:"mobile-butler-automation-grid",children:e.items.map(n=>t.jsxs("article",{className:"mobile-butler-automation-card","data-selected":e.selectedAutomationId===n.automationId,children:[t.jsxs("header",{className:"mobile-butler-record-header",children:[t.jsxs("div",{className:"mobile-butler-record-copy",children:[t.jsx("strong",{children:n.title}),t.jsx("span",{children:n.projectName})]}),t.jsx("span",{className:"mobile-butler-record-badge",children:n.statusLabel})]}),t.jsxs("div",{className:"mobile-butler-automation-chip-row",children:[t.jsx("span",{className:"mobile-butler-automation-chip",children:n.taskTypeLabel}),n.targetSessionTitle?t.jsx("span",{className:"mobile-butler-automation-chip",children:n.targetSessionTitle}):null]}),t.jsxs("div",{className:"mobile-butler-automation-metric-grid",children:[t.jsxs("div",{className:"mobile-butler-automation-metric",children:[t.jsx("span",{children:l("shell.butlerAutomationTaskNextRunLabel")}),t.jsx("strong",{children:G(n.nextRunAt)})]}),t.jsxs("div",{className:"mobile-butler-automation-metric",children:[t.jsx("span",{children:l("shell.butlerAutomationTaskLastRunLabel")}),t.jsx("strong",{children:G(n.lastRunAt)})]})]}),t.jsx("p",{className:"mobile-butler-automation-summary",children:n.promptPreview}),n.lastResultSummary?t.jsx("p",{className:"mobile-butler-automation-footnote",children:n.lastResultSummary}):null,t.jsxs("footer",{className:"mobile-butler-record-footer",children:[t.jsx("button",{type:"button",className:"secondary-button mobile-butler-record-action",onClick:()=>{n.automationId&&e.onSelectAutomation(n.automationId)},children:e.selectedAutomationId===n.automationId?l("shell.butlerAutomationCollapseDetailsAction"):l("shell.butlerAutomationOpenDetailsAction")}),n.automationId&&n.status==="active"?t.jsx("button",{type:"button",className:"secondary-button mobile-butler-record-action",disabled:e.cancellingAutomationId===n.automationId,onClick:()=>{e.onCancelAutomation(n.automationId)},children:e.cancellingAutomationId===n.automationId?l("shell.butlerControlTimerCancelling"):l("shell.butlerControlTimerStopAction")}):null]})]},n.id))}):t.jsx("p",{className:"mobile-butler-empty-text",children:e.emptyText})]})}function ki(e){var o,i,d;const n=(o=e.automation.projectId)!=null&&o.trim()?e.workspaceNameById.get(((d=(i=e.automation.controlSession)==null?void 0:i.session)==null?void 0:d.workspaceId)??""):null,s=Cs(e.automation,e.sessionTitleById);return t.jsxs("section",{className:"mobile-feature-panel surface-card mobile-butler-record-section mobile-butler-automation-detail-panel",children:[t.jsxs("div",{className:"mobile-feature-section-header",children:[t.jsxs("div",{children:[t.jsx("h2",{children:l("shell.butlerAutomationDetailTitle")}),t.jsx("p",{children:l("shell.butlerAutomationDetailDescription")})]}),t.jsx("button",{type:"button",className:"mobile-butler-section-action",onClick:e.onClose,children:l("common.close")})]}),t.jsxs("div",{className:"mobile-butler-automation-detail-summary",children:[t.jsx(we,{label:l("shell.butlerAutomationTaskTypeLabel"),value:ys(e.automation.triggerType)}),t.jsx(we,{label:l("shell.butlerAutomationStatusLabel"),value:Ss(e.automation.status)}),t.jsx(we,{label:l("shell.butlerAutomationTaskNextRunLabel"),value:G(e.automation.nextRunAt)}),t.jsx(we,{label:l("shell.butlerAutomationTaskLastRunLabel"),value:G(e.automation.lastRunAt||e.automation.updatedAt)}),n?t.jsx(we,{label:l("shell.mobileButlerAssistantWorkspaceLabel"),value:n}):null,s?t.jsx(we,{label:l("shell.butlerAutomationTargetSessionLabel"),value:s}):null]}),t.jsxs("div",{className:"mobile-butler-automation-form-grid",children:[t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationTitleLabel")}),t.jsx("input",{className:"butler-form-control",value:e.editorState.title,disabled:e.saving,onChange:c=>{e.onEditorChange({title:c.target.value})}})]}),t.jsxs("label",{className:"butler-form-field butler-form-field-wide",children:[t.jsx("span",{children:l("shell.butlerAutomationPromptLabel")}),t.jsx("textarea",{className:"butler-form-control mobile-butler-automation-textarea",value:e.editorState.content,disabled:e.saving,onChange:c=>{e.onEditorChange({content:c.target.value})}})]}),t.jsxs("label",{className:"mobile-butler-automation-toggle",children:[t.jsx("input",{type:"checkbox",checked:e.editorState.includeTriggerContext,disabled:e.saving,onChange:c=>{e.onEditorChange({includeTriggerContext:c.target.checked})}}),t.jsx("span",{children:l("shell.butlerAutomationIncludeTriggerContextLabel")})]}),t.jsx(Li,{automation:e.automation,editorState:e.editorState,saving:e.saving,onEditorChange:e.onEditorChange})]}),e.recentRuns.length>0?t.jsxs("div",{className:"mobile-butler-automation-detail-runs",children:[t.jsxs("div",{className:"mobile-feature-section-header",children:[t.jsx("div",{children:t.jsx("h2",{children:l("shell.butlerAutomationRunsTitle")})}),t.jsx("span",{className:"mobile-feature-counter",children:e.recentRuns.length})]}),t.jsx("div",{className:"mobile-butler-record-list",children:e.recentRuns.map(c=>{var f,h;return t.jsxs("article",{className:"mobile-butler-record-card",children:[t.jsxs("header",{className:"mobile-butler-record-header",children:[t.jsxs("div",{className:"mobile-butler-record-copy",children:[t.jsx("strong",{children:l("shell.butlerAutomationRoundLabel",{round:c.runSeq})}),t.jsx("span",{children:ps(c.triggerType)})]}),t.jsx("span",{className:"mobile-butler-record-badge",children:js(c.status)})]}),t.jsx("p",{children:((f=c.summary)==null?void 0:f.trim())||((h=c.error)==null?void 0:h.trim())||l("shell.butlerAutomationRunEmptySummary")}),t.jsx("footer",{className:"mobile-butler-record-footer",children:t.jsx("span",{children:G(c.createdAt)})})]},c.id)})})]}):null,t.jsxs("footer",{className:"mobile-butler-automation-detail-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:e.saving,onClick:e.onClose,children:l("common.close")}),t.jsx("button",{type:"button",className:"primary-button",disabled:e.saving,onClick:e.onSave,children:e.saving?l("shell.butlerAutomationSaving"):l("shell.butlerAutomationSaveAction")})]})]})}function Li(e){const{triggerConfig:n}=e.automation;return n.type==="once"?t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationDueAtLabel")}),t.jsx("input",{type:"datetime-local",className:"butler-form-control",value:e.editorState.dueAt,disabled:e.saving,onChange:s=>{e.onEditorChange({dueAt:s.target.value})}})]}):n.type==="interval"?t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationEverySecondsLabel")}),t.jsx("input",{inputMode:"numeric",className:"butler-form-control",value:e.editorState.everySeconds,disabled:e.saving,onChange:s=>{e.onEditorChange({everySeconds:s.target.value})}})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationEveryMinutesLabel")}),t.jsx("input",{inputMode:"numeric",className:"butler-form-control",value:e.editorState.everyMinutes,disabled:e.saving,onChange:s=>{e.onEditorChange({everyMinutes:s.target.value})}})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationEveryHoursLabel")}),t.jsx("input",{inputMode:"numeric",className:"butler-form-control",value:e.editorState.everyHours,disabled:e.saving,onChange:s=>{e.onEditorChange({everyHours:s.target.value})}})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationStopAtLabel")}),t.jsx("input",{type:"datetime-local",className:"butler-form-control",value:e.editorState.stopAt,disabled:e.saving,onChange:s=>{e.onEditorChange({stopAt:s.target.value})}})]})]}):n.type==="cron"?t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationCronMinuteLabel")}),t.jsx("input",{inputMode:"numeric",className:"butler-form-control",value:e.editorState.cronMinute,disabled:e.saving,onChange:s=>{e.onEditorChange({cronMinute:s.target.value})}})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationCronHourLabel")}),t.jsx("input",{inputMode:"numeric",className:"butler-form-control",value:e.editorState.cronHour,disabled:e.saving,onChange:s=>{e.onEditorChange({cronHour:s.target.value})}})]}),t.jsxs("label",{className:"butler-form-field butler-form-field-wide",children:[t.jsx("span",{children:l("shell.butlerAutomationCronDaysOfWeekLabel")}),t.jsx("input",{className:"butler-form-control",value:e.editorState.cronDaysOfWeek,disabled:e.saving,onChange:s=>{e.onEditorChange({cronDaysOfWeek:s.target.value})}})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationStopAtLabel")}),t.jsx("input",{type:"datetime-local",className:"butler-form-control",value:e.editorState.stopAt,disabled:e.saving,onChange:s=>{e.onEditorChange({stopAt:s.target.value})}})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationPollIntervalLabel")}),t.jsx("input",{inputMode:"numeric",className:"butler-form-control",value:e.editorState.pollIntervalSeconds,disabled:e.saving,onChange:s=>{e.onEditorChange({pollIntervalSeconds:s.target.value})}})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationMaxChecksLabel")}),t.jsx("input",{inputMode:"numeric",className:"butler-form-control",value:e.editorState.maxChecks,disabled:e.saving,onChange:s=>{e.onEditorChange({maxChecks:s.target.value})}})]}),t.jsxs("label",{className:"butler-form-field",children:[t.jsx("span",{children:l("shell.butlerAutomationExpiresAtLabel")}),t.jsx("input",{type:"datetime-local",className:"butler-form-control",value:e.editorState.expiresAt,disabled:e.saving,onChange:s=>{e.onEditorChange({expiresAt:s.target.value})}})]})]})}function Nt(e){return t.jsxs("section",{className:"mobile-feature-panel surface-card mobile-butler-record-section",children:[t.jsxs("div",{className:"mobile-feature-section-header",children:[t.jsx("div",{children:t.jsx("h2",{children:e.title})}),t.jsxs("div",{className:"mobile-feature-section-actions",children:[e.actionLabel&&e.onAction?t.jsx("button",{type:"button",className:"mobile-butler-section-action",onClick:e.onAction,children:e.actionLabel}):null,t.jsx("span",{className:"mobile-feature-counter",children:e.items.length})]})]}),e.items.length>0?t.jsx("div",{className:"mobile-butler-record-list",children:e.items.map(n=>t.jsxs("article",{className:"mobile-butler-record-card",children:[t.jsxs("header",{className:"mobile-butler-record-header",children:[t.jsxs("div",{className:"mobile-butler-record-copy",children:[t.jsx("strong",{children:n.title}),n.subtitle?t.jsx("span",{children:n.subtitle}):null]}),n.status?t.jsx("span",{className:"mobile-butler-record-badge",children:n.status}):null]}),t.jsx("p",{children:n.content}),n.meta||n.actionLabel?t.jsxs("footer",{className:"mobile-butler-record-footer",children:[n.meta?t.jsx("span",{children:n.meta}):t.jsx("span",{}),n.actionLabel&&n.onAction?t.jsx("button",{type:"button",className:"secondary-button mobile-butler-record-action",disabled:n.actionDisabled,onClick:n.onAction,children:n.actionLabel}):null]}):null]},n.id))}):t.jsx("p",{className:"mobile-butler-empty-text",children:e.emptyText})]})}function Ei(e){return t.jsxs("section",{className:"mobile-feature-panel surface-card mobile-butler-record-section mobile-butler-record-section-compact",children:[t.jsxs("div",{className:"mobile-feature-section-header",children:[t.jsx("div",{children:t.jsx("h2",{children:e.title})}),e.actionLabel&&e.onAction?t.jsx("button",{type:"button",className:"mobile-butler-section-action",onClick:e.onAction,children:e.actionLabel}):null]}),e.items.length>0?t.jsx("div",{className:"mobile-butler-record-list mobile-butler-record-list-compact",children:e.items.map(n=>t.jsxs("article",{className:"mobile-butler-compact-record",children:[t.jsx("span",{children:n.title}),t.jsx("strong",{children:n.content})]},n.id))}):t.jsx("p",{className:"mobile-butler-empty-text",children:e.emptyText})]})}function Tl(e){return t.jsxs("section",{className:"mobile-feature-panel surface-card mobile-butler-record-section",children:[t.jsxs("div",{className:"mobile-feature-section-header",children:[t.jsxs("div",{children:[t.jsx("h2",{children:e.title}),t.jsx("p",{children:e.description})]}),t.jsx("button",{type:"button",className:"mobile-butler-section-action",onClick:e.onClose,children:l("common.close")})]}),e.items.length>0?t.jsx("div",{className:"mobile-butler-record-list",children:e.items.map(n=>t.jsxs("article",{className:"mobile-butler-record-card",children:[t.jsxs("header",{className:"mobile-butler-record-header",children:[t.jsxs("div",{className:"mobile-butler-record-copy",children:[t.jsx("strong",{children:n.title}),n.subtitle?t.jsx("span",{children:n.subtitle}):null]}),n.status?t.jsx("span",{className:"mobile-butler-record-badge",children:n.status}):null]}),t.jsx("p",{children:n.content}),n.meta||n.actionLabel?t.jsxs("footer",{className:"mobile-butler-record-footer",children:[n.meta?t.jsx("span",{children:n.meta}):t.jsx("span",{}),n.actionLabel&&n.onAction?t.jsx("button",{type:"button",className:"secondary-button mobile-butler-record-action",disabled:n.actionDisabled,onClick:n.onAction,children:n.actionLabel}):null]}):null]},n.id))}):t.jsx("p",{className:"mobile-butler-empty-text",children:e.emptyText})]})}function Mi(e){return t.jsxs("div",{className:"mobile-butler-history-stack",children:[t.jsxs("section",{className:"mobile-feature-panel surface-card mobile-butler-record-section",children:[t.jsxs("div",{className:"mobile-feature-section-header",children:[t.jsxs("div",{children:[t.jsx("h2",{children:l("shell.butlerAutomationHistoryTitle")}),t.jsx("p",{children:l("shell.butlerAutomationHistoryDescription")})]}),t.jsx("button",{type:"button",className:"mobile-butler-section-action",onClick:e.onClose,children:l("common.close")})]}),e.taskItems.length===0&&e.runItems.length===0?t.jsx("p",{className:"mobile-butler-empty-text",children:l("shell.butlerAutomationHistoryEmpty")}):null]}),e.taskItems.length>0?t.jsx(Nt,{title:l("shell.butlerAutomationTasksTitle"),emptyText:l("shell.butlerAutomationHistoryEmpty"),items:e.taskItems.map(n=>({id:n.id,title:n.title,subtitle:n.projectName,status:n.statusLabel,content:`${l("shell.butlerAutomationTaskTypeLabel")} · ${n.taskTypeLabel}`,meta:`${l("shell.butlerAutomationTaskLastRunLabel")} · ${G(n.lastRunAt)}`}))}):null,e.runItems.length>0?t.jsx(Nt,{title:l("shell.butlerAutomationRunsTitle"),emptyText:l("shell.butlerAutomationHistoryEmpty"),items:e.runItems.map(n=>({id:n.id,title:n.title,subtitle:n.projectName,status:n.statusLabel,content:`${n.sourceLabel} · ${n.summary}`,meta:G(n.createdAt)}))}):null]})}function Fi(e){return e.sessions.length===0?t.jsx("p",{className:"mobile-butler-empty-text",children:l("shell.butlerHistoryEmpty")}):t.jsx("div",{className:"mobile-butler-record-list",children:e.sessions.map(n=>{var i,d,c,f,h;const s=n.id===e.activeControlSessionId,o=((i=n.title)==null?void 0:i.trim())||((d=n.session.title)==null?void 0:d.trim())||((c=n.lastSummary)==null?void 0:c.trim())||n.sessionId;return t.jsxs("article",{className:"mobile-butler-record-card mobile-butler-history-card","data-active":s,children:[t.jsxs("header",{className:"mobile-butler-record-header",children:[t.jsxs("div",{className:"mobile-butler-record-copy",children:[t.jsx("strong",{children:o}),t.jsx("span",{children:G(n.updatedAt)})]}),s?t.jsx("span",{className:"mobile-butler-record-badge",children:l("shell.butlerCurrentSessionBadge")}):null]}),t.jsx("p",{children:((f=n.lastSummary)==null?void 0:f.trim())||((h=n.session.title)==null?void 0:h.trim())||n.sessionId}),t.jsxs("footer",{className:"mobile-butler-record-footer",children:[t.jsx("button",{type:"button",className:"secondary-button mobile-butler-record-action",onClick:()=>{e.onSelectSession(n.id)},children:s?l("shell.butlerCurrentSessionBadge"):l("shell.butlerHistoryOpenAction")}),t.jsx("button",{type:"button",className:"secondary-button workbench-danger-button mobile-butler-record-action",disabled:e.deletingSessionId===n.id,"aria-label":l("shell.butlerHistoryDeleteAction"),onClick:()=>{e.onDeleteSession(n)},children:e.deletingSessionId===n.id?l("common.loading"):l("shell.deleteSessionAction")})]})]},n.id)})})}function Pi(e,n,s,o){u.useEffect(()=>{const i=e.current;if(!s||!i){i&&i.style.removeProperty("--mobile-conversation-composer-height");return}if(!n){i.style.removeProperty("--mobile-conversation-composer-height");return}const d=i,c=n;function f(){!e.current||!c.isConnected||d.style.setProperty("--mobile-conversation-composer-height",`${c.offsetHeight}px`)}f();const h=typeof ResizeObserver<"u"?new ResizeObserver(f):null;return h==null||h.observe(c),window.addEventListener("resize",f),()=>{h==null||h.disconnect(),window.removeEventListener("resize",f),i.style.removeProperty("--mobile-conversation-composer-height")}},[n,s,o,e])}function Nl(e,n){return[...e].filter(s=>n==="history"?!kl(s.status):kl(s.status)).sort((s,o)=>E($n(o))-E($n(s))).slice(0,4).map(s=>{var o,i;return{id:s.id,title:((o=s.targetRef)==null?void 0:o.trim())||s.verificationType,subtitle:s.verificationType,status:Oi(s.status),content:((i=s.summary)==null?void 0:i.trim())||l("shell.butlerInfoVerificationFallback",{status:s.status}),meta:G($n(s)),verification:{id:s.id,projectId:s.projectId,status:s.status}}})}function Di(e){return e.map(n=>({title:n.title,content:`${n.projectName} · ${qi(n.status)}`}))}function Il(e,n){const s=e.filter(o=>o.id!==n.id);return[n,...s].sort((o,i)=>E(El(i))-E(El(o)))}function On(e,n){const s=e.filter(o=>o.id!==n.id);return[n,...s].sort((o,i)=>E(Ul(i))-E(Ul(o)))}function Ui(e,n){const s=e.filter(o=>o.id!==n.id);return[n,...s].sort((o,i)=>E(ve(i))-E(ve(o)))}function Rl(e){return e==="active"||e==="waiting_user"}function an(e){return e==="active"||e==="waiting_user"}function kl(e){return e==="queued"||e==="running"}function Ll(e){return e==="queued"||e==="running"}function Oi(e){switch(e){case"queued":case"running":return l("shell.butlerAutomationStatusActive");case"passed":case"skipped":return l("shell.butlerAutomationStatusCompleted");case"failed":return l("shell.butlerAutomationStatusFailed");case"cancelled":return l("shell.butlerAutomationStatusCancelled");default:return e}}function El(e){return e.dueAt||e.triggeredAt||e.cancelledAt||e.updatedAt||e.createdAt}function $i(e){var n,s,o,i,d,c;return((n=e.title)==null?void 0:n.trim())||((o=(s=e.controlSession)==null?void 0:s.title)==null?void 0:o.trim())||((c=(d=(i=e.controlSession)==null?void 0:i.session)==null?void 0:d.title)==null?void 0:c.trim())||e.content.trim()}function Hi(e){return e.content.trim()||$i(e)}function Bi(e,n,s,o,i){var f,h,j,y;const d=(f=e.projectId)==null?void 0:f.trim();if(d&&n.has(d))return n.get(d);const c=((y=(j=(h=e.controlSession)==null?void 0:h.session)==null?void 0:j.workspaceId)==null?void 0:y.trim())||o.trim();return c?s.has(c)?s.get(c):c===o.trim()&&(i!=null&&i.trim())?i.trim():l("shell.butlerControlTimerUnknownWorkspace"):l("shell.butlerControlTimerUnknownWorkspace")}function _i(e,n,s,o,i){var f;if(e.kind==="timer")return Bi(e.timer,n,s,o,i);const d=(f=e.automation.projectId)==null?void 0:f.trim();if(d&&n.has(d))return n.get(d);const c=el(e)||o.trim();return c?s.has(c)?s.get(c):c===o.trim()&&(i!=null&&i.trim())?i.trim():l("shell.butlerControlTimerUnknownWorkspace"):l("shell.butlerControlTimerUnknownWorkspace")}function Vi(e,n){var i,d,c,f,h,j,y;const s=(i=e.targetSessionId)==null?void 0:i.trim();if(s&&n.has(s))return n.get(s);if((f=(c=(d=e.controlSession)==null?void 0:d.session)==null?void 0:c.title)!=null&&f.trim())return e.controlSession.session.title.trim();const o=((y=(j=(h=e.controlSession)==null?void 0:h.session)==null?void 0:j.sessionId)==null?void 0:y.trim())||e.sessionId.trim();return o&&n.has(o)?n.get(o):l("shell.butlerControlTimerUnknownSession")}function zi(e,n){var o,i,d;if(e.kind==="timer")return Vi(e.timer,n);const s=tl(e);return s&&n.has(s)?n.get(s):(d=(i=(o=e.automation.controlSession)==null?void 0:o.session)==null?void 0:i.title)!=null&&d.trim()?e.automation.controlSession.session.title.trim():l("shell.butlerControlTimerUnknownSession")}function Wi(){return t.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",focusable:"false",children:t.jsx("path",{fill:"currentColor",d:"M8 1.25a6.75 6.75 0 1 0 0 13.5A6.75 6.75 0 0 0 8 1.25Zm0 1.5a5.25 5.25 0 1 1 0 10.5A5.25 5.25 0 0 1 8 2.75Zm0 2.5a.875.875 0 1 0 0 1.75a.875.875 0 0 0 0-1.75Zm-.875 3.125a.625.625 0 1 0 0 1.25h.25v1.75h-.25a.625.625 0 1 0 0 1.25h1.75a.625.625 0 1 0 0-1.25h-.25V9a.625.625 0 0 0-.625-.625h-.875Z"})})}function Ml(e,n,s,o="active"){const i=new Map(((n==null?void 0:n.projects)??[]).filter(c=>s.has(c.id)).map(c=>[c.id,c.name]));return e.filter(c=>Ts(c,s,n)).filter(c=>o==="history"?c.status!=="active":c.status==="active").map(c=>{var f,h;return{id:`assistant-automation:${c.id}`,automationId:c.id,kind:"assistant_automation",title:As(c),projectName:ws(c,i),status:Ji(c.status),taskTypeLabel:ys(c.triggerType),statusLabel:Ss(c.status),nextRunAt:c.nextRunAt,lastRunAt:c.lastRunAt||c.updatedAt,promptPreview:er(c.actionConfig.content),lastResultSummary:((f=c.lastRunSummary)==null?void 0:f.trim())||((h=c.lastError)==null?void 0:h.trim())||null,targetSessionTitle:Cs(c)}}).sort((c,f)=>{const h=E(c.nextRunAt),j=E(f.nextRunAt);return h!==j?h===0?1:j===0?-1:h-j:E(f.lastRunAt)-E(c.lastRunAt)}).slice(0,8)}function Fl(e,n,s,o,i="active"){const d=new Map(((s==null?void 0:s.projects)??[]).filter(h=>o.has(h.id)).map(h=>[h.id,h.name])),c=new Map(e.filter(h=>Ts(h,o,s)).map(h=>[h.id,h]));return n.map(h=>({run:h,automation:c.get(h.automationId),normalizedStatus:Gi(h.status)})).filter(({automation:h})=>!!h).filter(({normalizedStatus:h})=>i==="history"?!Ol(h):Ol(h)).map(({run:h,automation:j,normalizedStatus:y})=>{var L,$;return{id:`assistant-automation-run:${h.id}`,kind:"assistant_automation_run",title:As(j),projectName:ws(j,d),status:y,sourceLabel:ps(h.triggerType),statusLabel:js(h.status),summary:((L=h.summary)==null?void 0:L.trim())||(($=h.error)==null?void 0:$.trim())||l("shell.butlerAutomationRunEmptySummary"),createdAt:h.finishedAt||h.startedAt||h.createdAt}}).sort((h,j)=>E(j.createdAt)-E(h.createdAt)).slice(0,10)}function qi(e){switch(e){case"pending":return l("shell.butlerInfoTodoPending");case"in_progress":return l("shell.butlerInfoTodoInProgress");case"closed":return l("shell.butlerInfoTodoClosed");default:return l("shell.butlerInfoTodoPending")}}function ve(e){return e.updatedAt||e.lastAutomationAt||e.lastCheckedAt||e.createdAt}function Ki(e){return e.kind==="timer"?e.timer.id:e.automation.id}function pn(e){return e.kind==="timer"?e.timer.dueAt:e.automation.nextRunAt}function el(e){var n,s,o,i,d,c;return e.kind==="timer"?((o=(s=(n=e.timer.controlSession)==null?void 0:n.session)==null?void 0:s.workspaceId)==null?void 0:o.trim())||null:((c=(d=(i=e.automation.controlSession)==null?void 0:i.session)==null?void 0:d.workspaceId)==null?void 0:c.trim())||null}function tl(e){var n,s,o,i,d,c,f,h,j,y,L;return e.kind==="timer"?((n=e.timer.targetSessionId)==null?void 0:n.trim())||((i=(o=(s=e.timer.controlSession)==null?void 0:s.session)==null?void 0:o.sessionId)==null?void 0:i.trim())||((d=e.timer.sessionId)==null?void 0:d.trim())||null:((c=e.automation.actionConfig.targetSessionId)==null?void 0:c.trim())||((j=(h=(f=e.automation.controlSession)==null?void 0:f.session)==null?void 0:h.sessionId)==null?void 0:j.trim())||((L=(y=e.automation.controlSession)==null?void 0:y.sessionId)==null?void 0:L.trim())||null}function Yi(e){return e.kind==="timer"||e.automation.triggerType==="once"}function Xi(e,n){const s=E(pn(e));return!s||s<=n?l("shell.butlerControlTimerCountdownDueNow"):l("shell.butlerControlTimerCountdownActive",{duration:ir(s-n)})}function Zi(e,n){const s=E(pn(e));return!s||s<=n?"00:00":rr(s-n)}function Qi(e){return e.kind==="timer"?Hi(e.timer):e.automation.actionConfig.content.trim()||l("conversation.butlerAnalysisEmpty")}function Pl(e){switch(e){case"active":return l("shell.butlerAutomationStatusActive");case"waiting_user":return l("shell.butlerAutomationStatusWaitingUser");case"completed":return l("shell.butlerAutomationStatusCompleted");case"failed":return l("shell.butlerAutomationStatusFailed");case"cancelled":return l("shell.butlerAutomationStatusCancelled");default:return l("shell.butlerAutomationStatusActive")}}function ys(e){switch(e){case"once":return l("shell.butlerAutomationTaskTypeControlTimer");case"interval":return l("shell.butlerAutomationTaskTypeInterval");case"cron":return l("shell.butlerAutomationTaskTypeCron");case"condition":return l("shell.butlerAutomationTaskTypeFollowUp");default:return l("shell.butlerAutomationTaskTypeControlTimer")}}function ps(e){return e==="interval"||e==="cron"?l("shell.butlerAutomationRunSourcePatrol"):e==="once"?l("shell.butlerAutomationRunSourceControlTimer"):l("shell.butlerAutomationRunSourceFollowUp")}function Gi(e){switch(e){case"failed":return"failed";case"cancelled":return"cancelled";case"completed":case"passed":case"succeeded":return"completed";case"waiting_user":return"waiting_user";case"active":case"queued":case"running":default:return"active"}}function Ji(e){switch(e){case"failed":return"failed";case"cancelled":return"cancelled";case"completed":return"completed";case"paused":return"waiting_user";case"active":default:return"active"}}function Ss(e){switch(e){case"completed":return l("shell.butlerAutomationStatusCompleted");case"failed":return l("shell.butlerAutomationStatusFailed");case"cancelled":return l("shell.butlerAutomationStatusCancelled");case"paused":return l("shell.butlerAutomationStatusWaitingUser");case"active":default:return l("shell.butlerAutomationStatusActive")}}function js(e){switch(e){case"succeeded":return l("shell.butlerAutomationStatusCompleted");case"failed":return l("shell.butlerAutomationStatusFailed");case"cancelled":case"skipped":return l("shell.butlerAutomationStatusCancelled");case"queued":case"running":default:return l("shell.butlerAutomationStatusActive")}}function As(e){var n,s;return((n=e.title)==null?void 0:n.trim())||((s=e.actionConfig.targetSessionId)==null?void 0:s.trim())||e.actionConfig.content.trim()||e.id}function ws(e,n){var s,o;return e.projectId&&n.has(e.projectId)?n.get(e.projectId):((o=(s=e.controlSession)==null?void 0:s.session)==null?void 0:o.workspaceId)||l("shell.butlerControlTimerNoProject")}function Cs(e,n=new Map){var o,i,d,c;const s=(o=e.actionConfig.targetSessionId)==null?void 0:o.trim();return s&&n.has(s)?n.get(s):(c=(d=(i=e.controlSession)==null?void 0:i.session)==null?void 0:d.title)!=null&&c.trim()?e.controlSession.session.title.trim():s||null}function er(e){const n=e.replace(/\s+/g," ").trim();return n?n.length<=72?n:`${n.slice(0,72)}...`:l("conversation.butlerAnalysisEmpty")}function Dl(e){var s;const n={title:((s=e.title)==null?void 0:s.trim())||"",content:e.actionConfig.content,includeTriggerContext:e.actionConfig.includeTriggerContext,dueAt:"",everySeconds:"",everyMinutes:"",everyHours:"",stopAt:"",cronMinute:"",cronHour:"",cronDaysOfWeek:"",pollIntervalSeconds:"",expiresAt:"",maxChecks:""};return e.triggerConfig.type==="once"?n.dueAt=un(e.triggerConfig.dueAt):e.triggerConfig.type==="interval"?(n.everySeconds=_e(e.triggerConfig.seconds),n.everyMinutes=_e(e.triggerConfig.minutes),n.everyHours=_e(e.triggerConfig.hours),n.stopAt=un(e.triggerConfig.stopAt)):e.triggerConfig.type==="cron"?(n.cronMinute=_e(e.triggerConfig.minute),n.cronHour=_e(e.triggerConfig.hour),n.cronDaysOfWeek=(e.triggerConfig.daysOfWeek??[]).join(","),n.stopAt=un(e.triggerConfig.stopAt)):(n.pollIntervalSeconds=_e(e.triggerConfig.pollIntervalSeconds),n.expiresAt=un(e.triggerConfig.expiresAt),n.maxChecks=_e(e.triggerConfig.maxChecks)),n}function tr(e,n){const s={title:nr(n.title),content:n.content.trim(),includeTriggerContext:n.includeTriggerContext};if(!s.content)throw new Error(l("shell.butlerAutomationPromptRequired"));return e.triggerConfig.type==="once"?{...s,dueAt:lr(n.dueAt,l("shell.butlerAutomationDueAtLabel"))}:e.triggerConfig.type==="interval"?{...s,everySeconds:cn(n.everySeconds,l("shell.butlerAutomationEverySecondsLabel")),everyMinutes:cn(n.everyMinutes,l("shell.butlerAutomationEveryMinutesLabel")),everyHours:cn(n.everyHours,l("shell.butlerAutomationEveryHoursLabel")),stopAt:hn(n.stopAt,l("shell.butlerAutomationStopAtLabel"))}:e.triggerConfig.type==="cron"?{...s,cronMinute:Ns(n.cronMinute,l("shell.butlerAutomationCronMinuteLabel")),cronHour:Is(n.cronHour,l("shell.butlerAutomationCronHourLabel")),cronDaysOfWeek:or(n.cronDaysOfWeek),stopAt:hn(n.stopAt,l("shell.butlerAutomationStopAtLabel"))}:{...s,pollIntervalSeconds:sr(n.pollIntervalSeconds,l("shell.butlerAutomationPollIntervalLabel")),expiresAt:hn(n.expiresAt,l("shell.butlerAutomationExpiresAtLabel")),maxChecks:cn(n.maxChecks,l("shell.butlerAutomationMaxChecksLabel"))}}function Ul(e){return e.updatedAt||e.lastRunAt||e.nextRunAt||e.createdAt}function Ts(e,n,s){var i,d,c;if(e.projectId&&n.has(e.projectId))return!0;const o=(c=(d=(i=e.controlSession)==null?void 0:i.session)==null?void 0:d.workspaceId)==null?void 0:c.trim();return o?((s==null?void 0:s.projects)??[]).some(f=>f.workspaceId===o&&n.has(f.id)):!1}function Ol(e){return e==="active"||e==="waiting_user"}function $n(e){return e.finishedAt||e.startedAt||e.createdAt}function E(e){if(!e)return 0;const n=new Date(e).getTime();return Number.isNaN(n)?0:n}function _e(e){return typeof e=="number"&&Number.isFinite(e)?String(e):""}function nr(e){const n=e.trim();return n||null}function un(e){if(!e)return"";const n=new Date(e);if(Number.isNaN(n.getTime()))return"";const s=n.getFullYear(),o=String(n.getMonth()+1).padStart(2,"0"),i=String(n.getDate()).padStart(2,"0"),d=String(n.getHours()).padStart(2,"0"),c=String(n.getMinutes()).padStart(2,"0");return`${s}-${o}-${i}T${d}:${c}`}function hn(e,n){const s=e.trim();if(!s)return null;const o=Date.parse(s);if(Number.isNaN(o))throw new Error(`${n}${l("shell.butlerAutomationInvalidDateSuffix")}`);return new Date(o).toISOString()}function lr(e,n){const s=hn(e,n);if(!s)throw new Error(`${n}${l("shell.butlerAutomationRequiredSuffix")}`);return s}function Ns(e,n){const s=e.trim();if(!s)throw new Error(`${n}${l("shell.butlerAutomationRequiredSuffix")}`);const o=Number.parseInt(s,10);if(!Number.isInteger(o))throw new Error(`${n}${l("shell.butlerAutomationInvalidNumberSuffix")}`);return o}function Is(e,n){const s=e.trim();if(!s)return null;const o=Number.parseInt(s,10);if(!Number.isInteger(o))throw new Error(`${n}${l("shell.butlerAutomationInvalidNumberSuffix")}`);return o}function cn(e,n){const s=Is(e,n);if(s===null)return null;if(s<=0)throw new Error(`${n}${l("shell.butlerAutomationInvalidPositiveNumberSuffix")}`);return s}function sr(e,n){const s=Ns(e,n);if(s<=0)throw new Error(`${n}${l("shell.butlerAutomationInvalidPositiveNumberSuffix")}`);return s}function or(e){const n=e.trim();if(!n)return null;const s=n.split(",").map(o=>Number.parseInt(o.trim(),10)).filter(o=>Number.isInteger(o));if(s.length===0||s.some(o=>o<0||o>6))throw new Error(l("shell.butlerAutomationCronDaysValidation"));return Array.from(new Set(s)).sort((o,i)=>o-i)}function G(e){if(!e)return"-";const n=new Date(e);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(n)}function ir(e){const n=Math.max(1,Math.ceil(e/1e3)),s=Math.floor(n/3600),o=Math.floor(n%3600/60),i=n%60,d=(c,f)=>new Intl.NumberFormat(void 0,{style:"unit",unit:f,unitDisplay:"narrow"}).format(c);return s>0?[d(s,"hour"),d(Math.max(o,0),"minute")].join(" "):o>0?[d(o,"minute"),d(i,"second")].join(" "):d(i,"second")}function rr(e){const n=Math.max(0,Math.ceil(e/1e3)),s=Math.floor(n/3600),o=Math.floor(n%3600/60),i=n%60;return s>0?`${String(s).padStart(2,"0")}:${String(o).padStart(2,"0")}:${String(i).padStart(2,"0")}`:`${String(o).padStart(2,"0")}:${String(i).padStart(2,"0")}`}function $l(e){switch(e){case"claude-code":return"Claude Code";case"codex":default:return"Codex"}}function Sr(){const{shellMode:e}=Kn();return e==="mobile"?t.jsx(Ni,{}):t.jsx(ro,{})}export{Sr as AdaptiveButlerPage};
|