libre-webui 0.39.0 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/backend/dist/persistence/extensionTypes.d.ts +2 -0
- package/backend/dist/persistence/extensionTypes.d.ts.map +1 -1
- package/backend/dist/persistence/extensionTypes.js.map +1 -1
- package/backend/dist/persistence/postgresExtensionRepositories.d.ts.map +1 -1
- package/backend/dist/persistence/postgresExtensionRepositories.js +6 -0
- package/backend/dist/persistence/postgresExtensionRepositories.js.map +1 -1
- package/backend/dist/persistence/sqliteExtensionRepositories.d.ts.map +1 -1
- package/backend/dist/persistence/sqliteExtensionRepositories.js +7 -0
- package/backend/dist/persistence/sqliteExtensionRepositories.js.map +1 -1
- package/backend/dist/routes/email.d.ts.map +1 -1
- package/backend/dist/routes/email.js +51 -1
- package/backend/dist/routes/email.js.map +1 -1
- package/backend/dist/routes/tts.d.ts.map +1 -1
- package/backend/dist/routes/tts.js +6 -1
- package/backend/dist/routes/tts.js.map +1 -1
- package/backend/dist/routes/work.d.ts.map +1 -1
- package/backend/dist/routes/work.js +98 -9
- package/backend/dist/routes/work.js.map +1 -1
- package/backend/dist/services/agentCliService.d.ts +15 -1
- package/backend/dist/services/agentCliService.d.ts.map +1 -1
- package/backend/dist/services/agentCliService.js +159 -25
- package/backend/dist/services/agentCliService.js.map +1 -1
- package/backend/dist/services/authorizationService.d.ts +1 -1
- package/backend/dist/services/authorizationService.d.ts.map +1 -1
- package/backend/dist/services/authorizationService.js +18 -1
- package/backend/dist/services/authorizationService.js.map +1 -1
- package/backend/dist/services/codexOAuthService.d.ts +11 -0
- package/backend/dist/services/codexOAuthService.d.ts.map +1 -1
- package/backend/dist/services/codexOAuthService.js +33 -7
- package/backend/dist/services/codexOAuthService.js.map +1 -1
- package/backend/dist/services/emailService.d.ts +17 -3
- package/backend/dist/services/emailService.d.ts.map +1 -1
- package/backend/dist/services/emailService.js +73 -11
- package/backend/dist/services/emailService.js.map +1 -1
- package/backend/dist/services/kiroLoginDatabase.d.ts +15 -0
- package/backend/dist/services/kiroLoginDatabase.d.ts.map +1 -0
- package/backend/dist/services/kiroLoginDatabase.js +104 -0
- package/backend/dist/services/kiroLoginDatabase.js.map +1 -0
- package/backend/dist/services/pluginCredentialsService.d.ts +3 -0
- package/backend/dist/services/pluginCredentialsService.d.ts.map +1 -1
- package/backend/dist/services/pluginCredentialsService.js +18 -5
- package/backend/dist/services/pluginCredentialsService.js.map +1 -1
- package/backend/dist/services/pluginService.d.ts +9 -0
- package/backend/dist/services/pluginService.d.ts.map +1 -1
- package/backend/dist/services/pluginService.js +40 -16
- package/backend/dist/services/pluginService.js.map +1 -1
- package/backend/dist/services/titleGenerationService.d.ts +10 -1
- package/backend/dist/services/titleGenerationService.d.ts.map +1 -1
- package/backend/dist/services/titleGenerationService.js +53 -15
- package/backend/dist/services/titleGenerationService.js.map +1 -1
- package/backend/dist/services/workAgentAccessService.d.ts +21 -0
- package/backend/dist/services/workAgentAccessService.d.ts.map +1 -0
- package/backend/dist/services/workAgentAccessService.js +94 -0
- package/backend/dist/services/workAgentAccessService.js.map +1 -0
- package/backend/dist/services/workAgentCatalog.d.ts +38 -0
- package/backend/dist/services/workAgentCatalog.d.ts.map +1 -0
- package/backend/dist/services/workAgentCatalog.js +173 -0
- package/backend/dist/services/workAgentCatalog.js.map +1 -0
- package/backend/dist/services/workAgentCliRunner.d.ts +56 -0
- package/backend/dist/services/workAgentCliRunner.d.ts.map +1 -0
- package/backend/dist/services/workAgentCliRunner.js +403 -0
- package/backend/dist/services/workAgentCliRunner.js.map +1 -0
- package/backend/dist/services/workAgentHostLogins.d.ts +181 -0
- package/backend/dist/services/workAgentHostLogins.d.ts.map +1 -0
- package/backend/dist/services/workAgentHostLogins.js +982 -0
- package/backend/dist/services/workAgentHostLogins.js.map +1 -0
- package/backend/dist/services/workAgentService.d.ts +15 -0
- package/backend/dist/services/workAgentService.d.ts.map +1 -1
- package/backend/dist/services/workAgentService.js +218 -0
- package/backend/dist/services/workAgentService.js.map +1 -1
- package/backend/dist/services/workAgentStream.d.ts +57 -0
- package/backend/dist/services/workAgentStream.d.ts.map +1 -0
- package/backend/dist/services/workAgentStream.js +378 -0
- package/backend/dist/services/workAgentStream.js.map +1 -0
- package/backend/dist/services/workAgentToolchainService.d.ts +51 -0
- package/backend/dist/services/workAgentToolchainService.d.ts.map +1 -0
- package/backend/dist/services/workAgentToolchainService.js +337 -0
- package/backend/dist/services/workAgentToolchainService.js.map +1 -0
- package/backend/dist/services/workAgents.d.ts +44 -0
- package/backend/dist/services/workAgents.d.ts.map +1 -0
- package/backend/dist/services/workAgents.js +142 -0
- package/backend/dist/services/workAgents.js.map +1 -0
- package/backend/dist/services/workEgressProxy.d.ts +138 -0
- package/backend/dist/services/workEgressProxy.d.ts.map +1 -0
- package/backend/dist/services/workEgressProxy.js +561 -0
- package/backend/dist/services/workEgressProxy.js.map +1 -0
- package/backend/dist/services/workEgressRelay.d.ts +68 -0
- package/backend/dist/services/workEgressRelay.d.ts.map +1 -0
- package/backend/dist/services/workEgressRelay.js +315 -0
- package/backend/dist/services/workEgressRelay.js.map +1 -0
- package/backend/dist/services/workEventService.d.ts.map +1 -1
- package/backend/dist/services/workEventService.js +3 -1
- package/backend/dist/services/workEventService.js.map +1 -1
- package/backend/dist/services/workKubernetesDriver.d.ts +2 -1
- package/backend/dist/services/workKubernetesDriver.d.ts.map +1 -1
- package/backend/dist/services/workKubernetesDriver.js +45 -0
- package/backend/dist/services/workKubernetesDriver.js.map +1 -1
- package/backend/dist/services/workModelProviderService.d.ts.map +1 -1
- package/backend/dist/services/workModelProviderService.js +15 -1
- package/backend/dist/services/workModelProviderService.js.map +1 -1
- package/backend/dist/services/workRuntimeDriver.d.ts +32 -1
- package/backend/dist/services/workRuntimeDriver.d.ts.map +1 -1
- package/backend/dist/services/workRuntimeDriver.js +80 -4
- package/backend/dist/services/workRuntimeDriver.js.map +1 -1
- package/backend/dist/services/workRuntimeService.d.ts +5 -0
- package/backend/dist/services/workRuntimeService.d.ts.map +1 -1
- package/backend/dist/services/workRuntimeService.js +243 -84
- package/backend/dist/services/workRuntimeService.js.map +1 -1
- package/backend/dist/services/workRuntimeShared.d.ts +9 -0
- package/backend/dist/services/workRuntimeShared.d.ts.map +1 -1
- package/backend/dist/services/workRuntimeShared.js +17 -0
- package/backend/dist/services/workRuntimeShared.js.map +1 -1
- package/backend/dist/services/workTaskService.d.ts +2 -2
- package/backend/dist/services/workTaskService.d.ts.map +1 -1
- package/backend/dist/services/workTaskService.js +8 -5
- package/backend/dist/services/workTaskService.js.map +1 -1
- package/backend/dist/types/work.d.ts +10 -1
- package/backend/dist/types/work.d.ts.map +1 -1
- package/backend/dist/utils/bedrockMantle.d.ts +9 -1
- package/backend/dist/utils/bedrockMantle.d.ts.map +1 -1
- package/backend/dist/utils/bedrockMantle.js +34 -3
- package/backend/dist/utils/bedrockMantle.js.map +1 -1
- package/backend/dist/utils/emailMarkdown.js +3 -3
- package/backend/dist/utils/emailMarkdown.js.map +1 -1
- package/backend/dist/utils/pluginChatAdapter.d.ts.map +1 -1
- package/backend/dist/utils/pluginChatAdapter.js +16 -4
- package/backend/dist/utils/pluginChatAdapter.js.map +1 -1
- package/backend/dist/utils/pluginDefinitionTrust.d.ts +7 -0
- package/backend/dist/utils/pluginDefinitionTrust.d.ts.map +1 -1
- package/backend/dist/utils/pluginDefinitionTrust.js +51 -3
- package/backend/dist/utils/pluginDefinitionTrust.js.map +1 -1
- package/backend/dist/utils/x509.d.ts +28 -0
- package/backend/dist/utils/x509.d.ts.map +1 -0
- package/backend/dist/utils/x509.js +206 -0
- package/backend/dist/utils/x509.js.map +1 -0
- package/backend/package.json +4 -4
- package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
- package/frontend/dist/artifact-runtime/framer-motion.js +3 -3
- package/frontend/dist/artifact-runtime/lucide-react.js +1 -1
- package/frontend/dist/artifact-runtime/mermaid.js +327 -327
- package/frontend/dist/assets/index-DtS3qhdq.css +2 -0
- package/frontend/dist/assets/index-KsiiOLzU.js +87 -0
- package/frontend/dist/assets/markdown-math-Ngnvt50Q.css +1 -0
- package/frontend/dist/assets/xterm-B1njb2Cr.css +1 -0
- package/frontend/dist/index.html +30 -29
- package/frontend/dist/js/ArtifactContainer-ZRc3iGTP.js +1 -0
- package/frontend/dist/js/{ArtifactDemoPage-Ddpy2O_v.js → ArtifactDemoPage-D5tBk02B.js} +1 -1
- package/frontend/dist/js/{ArtifactSandboxFrame-CdsAqv8H.js → ArtifactSandboxFrame-DFBbDNYt.js} +1 -1
- package/frontend/dist/js/ArtifactSlideOutPanel-JxYwQhb3.js +1 -0
- package/frontend/dist/js/AutomationModal-d2KdJtri.js +1 -0
- package/frontend/dist/js/AutomationsPage-C9zK5Svl.js +1 -0
- package/frontend/dist/js/AvatarUpload-Cxdp4Imm.js +1 -0
- package/frontend/dist/js/Button-Dh2UJA-B.js +1 -0
- package/frontend/dist/js/CalendarPage-Di0wpPHv.js +1 -0
- package/frontend/dist/js/ChannelsPage-D4I12rSV.js +1 -0
- package/frontend/dist/js/ChatPage-BPVykNDN.js +14 -0
- package/frontend/dist/js/ConnectModels-D4bfRr_C.js +1 -0
- package/frontend/dist/js/EvaluationsPage-BHNu-Yuv.js +2 -0
- package/frontend/dist/js/FirstTimeSetup-DwAazkKS.js +1 -0
- package/frontend/dist/js/GalleryPage-CiWQz3MO.js +1 -0
- package/frontend/dist/js/HomePage--BXg7yYq.js +1 -0
- package/frontend/dist/js/LanguageSwitcher-BytOonLT.js +1 -0
- package/frontend/dist/js/ModelManagerModals-luKNvxGZ.js +1 -0
- package/frontend/dist/js/NotesPage-BmSY4zjn.js +3 -0
- package/frontend/dist/js/PasswordStrengthMeter-Dnvy9FTf.js +1 -0
- package/frontend/dist/js/PersonasPage-D4lLqYL7.js +13 -0
- package/frontend/dist/js/PluginUsagePage-BrAUsPF1.js +1 -0
- package/frontend/dist/js/RichMessageContent-BLr0i8PB.js +1 -0
- package/frontend/dist/js/{RichMessageContent-BfYbVBFz.js → RichMessageContent-JqidvjnA.js} +3 -3
- package/frontend/dist/js/SettingsModal-BHsYfMHh.js +19 -0
- package/frontend/dist/js/SettingsToggle-CkLLtFbz.js +1 -0
- package/frontend/dist/js/ShareDialog-LLptgA-s.js +1 -0
- package/frontend/dist/js/StrandsPage-Bygb-VLO.js +1 -0
- package/frontend/dist/js/SystemPage-BNRBHrES.js +1 -0
- package/frontend/dist/js/{TurnstileWidget-tI50c7Kc.js → TurnstileWidget-7oVjbntG.js} +1 -1
- package/frontend/dist/js/{UserManagementPage-UvPjA9RP.js → UserManagementPage-M2ZhkF7m.js} +1 -1
- package/frontend/dist/js/UserManagementPanel-DBZKnZ-G.js +1 -0
- package/frontend/dist/js/WhatsNewModal-C65J_hEe.js +1 -0
- package/frontend/dist/js/WorkPage-WQ3tojri.js +7 -0
- package/frontend/dist/js/{api-BrHW-VGd.js → api-Bnbon_Rp.js} +4 -2
- package/frontend/dist/js/api-CtbDCatP.js +1 -0
- package/frontend/dist/js/{appNavigation-B6xYIgLi.js → appNavigation-C4WPz06g.js} +1 -1
- package/frontend/dist/js/appStore-BeRY0hZe.js +2 -0
- package/frontend/dist/js/appVersion-JNHbZTzT.js +1 -0
- package/frontend/dist/js/ar-D4ACicTy.js +2 -0
- package/frontend/dist/js/{authStore-DjAsRpNL.js → authStore-Ccdoy8Vq.js} +3 -3
- package/frontend/dist/js/authStore-DTSwmAtW.js +1 -0
- package/frontend/dist/js/bn-U-J9oKiN.js +2 -0
- package/frontend/dist/js/chatStore-BV17ffDe.js +3 -0
- package/frontend/dist/js/{client-DppLngAs.js → client-CGDIO9t6.js} +2 -2
- package/frontend/dist/js/{composerStyles-C83jssgZ.js → composerStyles-BEx0XAp6.js} +1 -1
- package/frontend/dist/js/{config-4_s8hdqO.js → config-DYZVxv3t.js} +1 -1
- package/frontend/dist/js/confirmStore-CKkUtP9c.js +1 -0
- package/frontend/dist/js/cs-DqF3kKON.js +2 -0
- package/frontend/dist/js/da-BY_ue7IH.js +2 -0
- package/frontend/dist/js/de-ByqcjDDi.js +2 -0
- package/frontend/dist/js/es-PpY8rAbj.js +2 -0
- package/frontend/dist/js/{evaluationsApi-DyuW7IJ_.js → evaluationsApi-VwEJ0x8J.js} +1 -1
- package/frontend/dist/js/fr-B8kAmhGd.js +2 -0
- package/frontend/dist/js/hi-pOpOSvWK.js +2 -0
- package/frontend/dist/js/id-bRK07dZm.js +2 -0
- package/frontend/dist/js/is-BObnLGvi.js +2 -0
- package/frontend/dist/js/it-Dgcq9Mkn.js +2 -0
- package/frontend/dist/js/ja-BhkyZZKR.js +2 -0
- package/frontend/dist/js/ko-D-xfOA2T.js +2 -0
- package/frontend/dist/js/liveAnnouncerStore-B6mS-JWC.js +1 -0
- package/frontend/dist/js/logger-B4-E6SY8.js +1 -0
- package/frontend/dist/js/markdown-math-BtrScp6v.js +261 -0
- package/frontend/dist/js/markdownMath-DPjkFHpu.js +1 -0
- package/frontend/dist/js/messageCodeStyles-CHTEQi80.js +2 -0
- package/frontend/dist/js/ms-DLFQvNh-.js +2 -0
- package/frontend/dist/js/nl-BWFqTL4u.js +2 -0
- package/frontend/dist/js/pl-Cr0-8RBA.js +2 -0
- package/frontend/dist/js/pt-DpNh0tQT.js +2 -0
- package/frontend/dist/js/{router-vendor-DqMnEJWK.js → router-vendor-CKl1g8Qt.js} +1 -1
- package/frontend/dist/js/ru-VPEPKfbU.js +2 -0
- package/frontend/dist/js/{strandsApi-BFbeEpAY.js → strandsApi-D6XECW3U.js} +1 -1
- package/frontend/dist/js/sv-Bb41KZL-.js +2 -0
- package/frontend/dist/js/{teamEventStream-DsAS6P4m.js → teamEventStream-C5Zk1VDu.js} +1 -1
- package/frontend/dist/js/th-D8ahJkLy.js +2 -0
- package/frontend/dist/js/tr-LxdOSx7H.js +2 -0
- package/frontend/dist/js/ui-CU8ko29F.js +2 -0
- package/frontend/dist/js/ui-vendor-Bk_S1tZa.js +1 -0
- package/frontend/dist/js/uk-MWQC7_0z.js +2 -0
- package/frontend/dist/js/useChat-D02w6J_J.js +13 -0
- package/frontend/dist/js/useDictation-mEvTPNBJ.js +1 -0
- package/frontend/dist/js/vi-DZIXswgY.js +2 -0
- package/frontend/dist/js/{work-CdbmBok5.js → work-BP_ujNmK.js} +1 -1
- package/frontend/dist/js/workAnnouncements-C2Cd6YCk.js +1 -0
- package/frontend/dist/js/workApi-BL1yHp4v.js +5 -0
- package/frontend/dist/js/workApi-D5BcMUUb.js +1 -0
- package/frontend/dist/js/zh-Cpymo7dg.js +2 -0
- package/package.json +9 -4
- package/plugins/anthropic.json +1 -0
- package/plugins/bedrock.json +2 -1
- package/plugins/codex-oauth.json +1 -0
- package/frontend/dist/assets/index-D99DS5c6.js +0 -57
- package/frontend/dist/assets/index-Dz1JufgZ.css +0 -1
- package/frontend/dist/assets/markdown-math-DzFXvcrH.css +0 -1
- package/frontend/dist/assets/xterm-B8QFf3JU.css +0 -1
- package/frontend/dist/js/ArtifactContainer-Cn7X9HGm.js +0 -1
- package/frontend/dist/js/ArtifactSlideOutPanel-cVd9X80o.js +0 -1
- package/frontend/dist/js/AutomationModal-B4UaWjkk.js +0 -1
- package/frontend/dist/js/AutomationsPage-huCrvLUp.js +0 -1
- package/frontend/dist/js/AvatarUpload-CG-w6Mpt.js +0 -1
- package/frontend/dist/js/Button-j68Q8KVh.js +0 -1
- package/frontend/dist/js/CalendarPage-CZXT1w99.js +0 -1
- package/frontend/dist/js/ChannelsPage-DbtdHnSL.js +0 -1
- package/frontend/dist/js/ChatPage-BZE65kiq.js +0 -14
- package/frontend/dist/js/ConnectModels-DD4bLgdq.js +0 -1
- package/frontend/dist/js/EvaluationsPage-Dq53LaXd.js +0 -2
- package/frontend/dist/js/FirstTimeSetup-BoJIfuQT.js +0 -1
- package/frontend/dist/js/GalleryPage-DKwqeB2A.js +0 -1
- package/frontend/dist/js/HomePage-C8bCJfls.js +0 -1
- package/frontend/dist/js/LanguageSwitcher-B_YyU5JG.js +0 -1
- package/frontend/dist/js/ModelManagerModals-BzjZ-QwL.js +0 -1
- package/frontend/dist/js/NotesPage-CnaAp_w_.js +0 -3
- package/frontend/dist/js/PasswordStrengthMeter-DI4RDv67.js +0 -1
- package/frontend/dist/js/PersonasPage-CH3GUKph.js +0 -13
- package/frontend/dist/js/PluginUsagePage-d54K2gAj.js +0 -1
- package/frontend/dist/js/RichMessageContent-CDxxs3Tt.js +0 -1
- package/frontend/dist/js/SettingsModal-BvtJcvow.js +0 -19
- package/frontend/dist/js/SettingsToggle-DrJ0Bapi.js +0 -1
- package/frontend/dist/js/ShareDialog-DaSxkTKS.js +0 -1
- package/frontend/dist/js/StrandsPage-BQwz0mWq.js +0 -1
- package/frontend/dist/js/SystemPage-BqNZoFxR.js +0 -1
- package/frontend/dist/js/UserManagementPanel-C3T1ReJJ.js +0 -1
- package/frontend/dist/js/WhatsNewModal-CLcU2Ugk.js +0 -1
- package/frontend/dist/js/WorkPage-BpjGn--1.js +0 -8
- package/frontend/dist/js/api-K_hhqPdx.js +0 -1
- package/frontend/dist/js/appStore-DkRdQQeY.js +0 -2
- package/frontend/dist/js/appVersion-BVtSqLVj.js +0 -1
- package/frontend/dist/js/ar-XTZGEtBr.js +0 -2
- package/frontend/dist/js/authStore-DBS6Kbvh.js +0 -1
- package/frontend/dist/js/bn-JiK7ZWmy.js +0 -2
- package/frontend/dist/js/chatStore-DpVxt9VX.js +0 -3
- package/frontend/dist/js/cs-D8ju18CO.js +0 -2
- package/frontend/dist/js/da-BJWcAoUc.js +0 -2
- package/frontend/dist/js/de-CLJLmy69.js +0 -2
- package/frontend/dist/js/es-BvqHEL-3.js +0 -2
- package/frontend/dist/js/fr-B8ZoZomI.js +0 -2
- package/frontend/dist/js/goober.modern-BaHbaW3_.js +0 -1
- package/frontend/dist/js/hi-AzJLALo-.js +0 -2
- package/frontend/dist/js/id-DZYGQhvC.js +0 -2
- package/frontend/dist/js/is-Da_kvtzW.js +0 -2
- package/frontend/dist/js/it-B90zSlqn.js +0 -2
- package/frontend/dist/js/ja-DU_K1GOr.js +0 -2
- package/frontend/dist/js/ko-DicfoO-e.js +0 -2
- package/frontend/dist/js/logger-BR4forr_.js +0 -1
- package/frontend/dist/js/markdown-math-DxPfMKvO.js +0 -261
- package/frontend/dist/js/markdownMath-CsfRQAcz.js +0 -1
- package/frontend/dist/js/messageCodeStyles-CuQPkfEK.js +0 -2
- package/frontend/dist/js/ms-CfH7wjUY.js +0 -2
- package/frontend/dist/js/nl-ELlOz-B3.js +0 -2
- package/frontend/dist/js/pl-33dayyUk.js +0 -2
- package/frontend/dist/js/pt-aIXSQPCT.js +0 -2
- package/frontend/dist/js/ru-BSvGtBtW.js +0 -2
- package/frontend/dist/js/sv-B7KOz81W.js +0 -2
- package/frontend/dist/js/th-DgpjGxvA.js +0 -2
- package/frontend/dist/js/tr-BQTbl2h-.js +0 -2
- package/frontend/dist/js/ui-Aq8MP7Ph.js +0 -2
- package/frontend/dist/js/ui-vendor-DVTj_sKN.js +0 -1
- package/frontend/dist/js/uk-JLymloot.js +0 -2
- package/frontend/dist/js/useChat-D3ZAGz70.js +0 -10
- package/frontend/dist/js/useDictation-B6l8QzeM.js +0 -1
- package/frontend/dist/js/vi-BXdLOJ8q.js +0 -2
- package/frontend/dist/js/workApi-D1xtiG3Q.js +0 -1
- package/frontend/dist/js/workApi-UPxumrEF.js +0 -5
- package/frontend/dist/js/workModels-BM2Zyiba.js +0 -1
- package/frontend/dist/js/zh-gdUf9sXa.js +0 -2
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,r as n,t as r}from"./react-vendor-CR5VJ85Q.js";import{t as i}from"./useTranslation-Boi0fB1B.js";import{t as a}from"./utils-B-Bhh1pF.js";import{Rn as o,Tr as s,et as c,n as l,v as u}from"./ui-vendor-DVTj_sKN.js";import{T as d}from"./api-BrHW-VGd.js";import{t as f}from"./workApi-UPxumrEF.js";import{t as p}from"./useDialogFocus-zSGHkpE4.js";import{c as m,d as h,l as g,n as _}from"./calendarDates-Co3o_05Y.js";var v=e(t(),1),y=n(),b=[`channel-mention`,`channel-dm`,`channel-invite`,`share`,`calendar-reminder`,`media-ready`,`media-failed`,`budget-alert`,`work-run-finished`,`work-run-attention`,`work-takeover`,`work-approval`,`system`],x=e=>e.length>0&&e.every(e=>e.kind===`event`),S=(e,t,n)=>new Intl.DateTimeFormat(n,{hour:`numeric`,minute:`2-digit`}).format(new Date(2024,0,1,e,t)),C=(e,t)=>new Intl.DateTimeFormat(t,{weekday:`long`}).format(new Date(2024,0,7+e)),w=(e,t,n)=>new Intl.DateTimeFormat(n,{month:`long`,day:`numeric`}).format(new Date(2024,e-1,t));function T(e,t,n){switch(e.kind){case`event`:return n(e.match?`automations.trigger.eventMatching`:`automations.trigger.event`,{event:n(`automations.triggers.events.${e.event}`),match:e.match??``});case`once`:return n(`automations.trigger.once`,{when:new Intl.DateTimeFormat(t,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(e.at))});case`hourly`:{let t=e.startHour!==void 0||e.endHour!==void 0?` (${e.startHour??0}–${e.endHour??23})`:``;return n(`automations.trigger.hourly`,{minute:String(e.minute).padStart(2,`0`)})+t}case`daily`:return n(`automations.trigger.daily`,{time:S(e.hour,e.minute,t)});case`weekly`:return n(`automations.trigger.weekly`,{day:C(e.dayOfWeek,t),time:S(e.hour,e.minute,t)});case`monthly`:return n(`automations.trigger.monthly`,{day:e.dayOfMonth,time:S(e.hour,e.minute,t)});case`yearly`:return n(`automations.trigger.yearly`,{date:w(e.month,e.dayOfMonth,t),time:S(e.hour,e.minute,t)})}}function E(e,t,n){return e.map(e=>T(e,t,n)).join(` · `)}function D(e){let t=(e,t,n)=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=t&&e<=n;switch(e.kind){case`event`:return b.includes(e.event)&&(e.match===void 0||typeof e.match==`string`&&e.match.length<=200);case`once`:return t(e.at,0,864e13);case`hourly`:return t(e.minute,0,59)&&(e.startHour===void 0||t(e.startHour,0,23))&&(e.endHour===void 0||t(e.endHour,0,23))&&(e.startHour===void 0||e.endHour===void 0||e.endHour>=e.startHour);case`daily`:return t(e.hour,0,23)&&t(e.minute,0,59);case`weekly`:return t(e.dayOfWeek,0,6)&&t(e.hour,0,23)&&t(e.minute,0,59);case`monthly`:return t(e.dayOfMonth,1,31)&&t(e.hour,0,23)&&t(e.minute,0,59);case`yearly`:return t(e.month,1,12)&&t(e.dayOfMonth,1,31)&&t(e.hour,0,23)&&t(e.minute,0,59);default:return!1}}var O=r(),k=[`event`,`once`,`hourly`,`daily`,`weekly`,`monthly`,`yearly`],A=`rounded-lg border border-black/[0.08] bg-white px-2 py-1 text-[13px] text-gray-900 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.08] dark:bg-dark-100 dark:text-dark-900`,j=(e,t)=>`${String(e).padStart(2,`0`)}:${String(t).padStart(2,`0`)}`,M=e=>{switch(e){case`event`:return{kind:`event`,event:`channel-mention`};case`once`:{let e=new Date;return e.setHours(e.getHours()+1,0,0,0),{kind:`once`,at:e.getTime()}}case`hourly`:return{kind:`hourly`,minute:0};case`daily`:return{kind:`daily`,hour:8,minute:0};case`weekly`:return{kind:`weekly`,dayOfWeek:1,hour:9,minute:0};case`monthly`:return{kind:`monthly`,dayOfMonth:1,hour:9,minute:0};case`yearly`:return{kind:`yearly`,month:1,dayOfMonth:1,hour:9,minute:0}}};function N({trigger:e,onChange:t,onRemove:n}){let{t:r,i18n:a}=i(),s=h(a.language,`short`),c=new Intl.DateTimeFormat(a.language,{month:`long`}),l=n=>{let[r,i]=(n||`00:00`).split(`:`).map(Number);e.kind!==`hourly`&&e.kind!==`once`&&e.kind!==`event`&&t({...e,hour:r,minute:i})},d=e.kind!==`once`&&e.kind!==`hourly`&&e.kind!==`event`?(0,O.jsx)(`input`,{type:`time`,"aria-label":r(`automations.form.time`),value:j(e.hour,e.minute),onChange:e=>l(e.target.value),className:A}):null;return(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-xl border border-black/[0.06] bg-black/[0.02] px-2.5 py-2 dark:border-white/[0.06] dark:bg-white/[0.03]`,"data-testid":`automation-trigger`,children:[(0,O.jsx)(o,{className:`h-3.5 w-3.5 shrink-0 text-gray-400 dark:text-dark-500`}),(0,O.jsx)(`select`,{"aria-label":r(`automations.form.frequency`),value:e.kind,onChange:e=>t(M(e.target.value)),className:A,"data-testid":`automation-trigger-kind`,children:k.map(e=>(0,O.jsx)(`option`,{value:e,children:r(`automations.kind.${e}`)},e))}),e.kind===`event`&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`select`,{"aria-label":r(`automations.form.event`),value:e.event,onChange:n=>t({...e,event:n.target.value}),className:A,"data-testid":`automation-trigger-event`,children:b.map(e=>(0,O.jsx)(`option`,{value:e,children:r(`automations.triggers.events.${e}`)},e))}),(0,O.jsx)(`input`,{type:`text`,"aria-label":r(`automations.form.eventMatch`),placeholder:r(`automations.form.eventMatchPlaceholder`),value:e.match??``,onChange:n=>t({...e,match:n.target.value.slice(0,200)}),className:`${A} min-w-0 flex-1`,"data-testid":`automation-trigger-match`})]}),e.kind===`once`&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`input`,{type:`date`,"aria-label":r(`calendar.date`),value:m(e.at),onChange:n=>t({...e,at:_(n.target.value,g(e.at))}),className:A}),(0,O.jsx)(`input`,{type:`time`,"aria-label":r(`automations.form.time`),value:g(e.at),onChange:n=>t({...e,at:_(m(e.at),n.target.value)}),className:A})]}),e.kind===`hourly`&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`label`,{className:`flex items-center gap-1 text-[12px] text-gray-500 dark:text-dark-500`,children:[r(`automations.form.minute`),(0,O.jsx)(`input`,{type:`number`,min:0,max:59,value:e.minute,onChange:n=>t({...e,minute:Math.min(59,Math.max(0,Number(n.target.value)))}),className:`${A} w-16`})]}),(0,O.jsxs)(`label`,{className:`flex items-center gap-1 text-[12px] text-gray-500 dark:text-dark-500`,children:[r(`automations.form.fromHour`),(0,O.jsx)(`input`,{type:`number`,min:0,max:23,value:e.startHour??0,onChange:n=>t({...e,startHour:Math.min(23,Math.max(0,Number(n.target.value)))}),className:`${A} w-16`})]}),(0,O.jsxs)(`label`,{className:`flex items-center gap-1 text-[12px] text-gray-500 dark:text-dark-500`,children:[r(`automations.form.toHour`),(0,O.jsx)(`input`,{type:`number`,min:0,max:23,value:e.endHour??23,onChange:n=>t({...e,endHour:Math.min(23,Math.max(0,Number(n.target.value)))}),className:`${A} w-16`})]})]}),e.kind===`weekly`&&(0,O.jsx)(`select`,{"aria-label":r(`automations.form.weekday`),value:e.dayOfWeek,onChange:n=>t({...e,dayOfWeek:Number(n.target.value)}),className:A,children:s.map((e,t)=>(0,O.jsx)(`option`,{value:t,children:e},e))}),(e.kind===`monthly`||e.kind===`yearly`)&&(0,O.jsxs)(`label`,{className:`flex items-center gap-1 text-[12px] text-gray-500 dark:text-dark-500`,children:[r(`automations.form.dayOfMonth`),(0,O.jsx)(`input`,{type:`number`,min:1,max:31,value:e.dayOfMonth,onChange:n=>t({...e,dayOfMonth:Math.min(31,Math.max(1,Number(n.target.value)))}),className:`${A} w-16`})]}),e.kind===`yearly`&&(0,O.jsx)(`select`,{"aria-label":r(`automations.form.month`),value:e.month,onChange:n=>t({...e,month:Number(n.target.value)}),className:A,children:Array.from({length:12},(e,t)=>(0,O.jsx)(`option`,{value:t+1,children:c.format(new Date(2024,t,1))},t+1))}),d,n&&(0,O.jsx)(`button`,{type:`button`,onClick:n,"aria-label":r(`common.delete`),className:`ms-auto rounded-md p-1 text-red-500 transition-colors hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,O.jsx)(u,{className:`h-3.5 w-3.5`})})]})}var P=`w-full rounded-lg border border-black/[0.08] bg-white px-2.5 py-1.5 text-[13px] text-gray-900 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.08] dark:bg-dark-100 dark:text-dark-900`,F=`mb-1 block text-[11px] font-medium uppercase tracking-wide text-gray-400 dark:text-dark-500`,I=e=>e.isPlugin&&e.pluginId?`plugin:${e.pluginId}`:e.isAgent&&e.agentId?`agent:${e.agentId}`:`ollama`;function L({open:e,automation:t,initial:n,fixedWorkTaskId:r,models:i,saving:a,onClose:o,onSave:s}){return e?(0,O.jsx)(R,{automation:t,initial:n,fixedWorkTaskId:r,models:i,saving:a,onClose:o,onSave:s},t?.id??n?.name??`new`):null}function R({automation:e,initial:t,fixedWorkTaskId:n,models:r,saving:o,onClose:u,onSave:m}){let{t:h}=i(),g=(0,v.useRef)(null);p(g,{onClose:u});let _=!!(n??e?.workTaskId),[b,S]=(0,v.useState)(e?.name??t?.name??``),[C,w]=(0,v.useState)(e?.instructions??t?.instructions??``),[T,E]=(0,v.useState)(e?.triggers??t?.triggers??[{kind:`daily`,hour:8,minute:0}]),[k,A]=(0,v.useState)(e?.model??``),[j,M]=(0,v.useState)(e?.notify??`app`),[L,R]=(0,v.useState)(e?.target??`chat`),[z,B]=(0,v.useState)(e?.workPolicyId??``),[V,H]=(0,v.useState)([]);(0,v.useEffect)(()=>{if(L!==`work`||_)return;let e=!1;return f.listPolicies().then(t=>{!e&&t.success&&Array.isArray(t.data)&&H(t.data)}).catch(()=>void 0),()=>{e=!0}},[L,_]);let[U,W]=(0,v.useState)(e?.webhookEnabled===!0),[G,K]=(0,v.useState)(null),[q,J]=(0,v.useState)(!1),Y=async()=>{if(e){J(!0);try{let t=await d.rotateWebhookSecret(e.id);if(!t.success||!t.data)throw Error(t.error);W(!0),K(t.data)}catch{s.error(h(`automations.webhook.failed`,{defaultValue:`Could not update the webhook.`}))}finally{J(!1)}}},X=async()=>{if(e){J(!0);try{let t=await d.disableWebhook(e.id);if(!t.success)throw Error(t.error);W(!1),K(null)}catch{s.error(h(`automations.webhook.failed`,{defaultValue:`Could not update the webhook.`}))}finally{J(!1)}}},Z=b.trim().length>0&&C.trim().length>0&&T.length>0&&T.every(D);return(0,y.createPortal)((0,O.jsx)(`div`,{className:`fixed inset-0 z-[2147483647] flex items-center justify-center bg-gray-950/55 p-4 backdrop-blur-md`,onClick:u,children:(0,O.jsx)(`div`,{ref:g,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`automation-modal-title`,tabIndex:-1,"data-testid":`automation-modal`,className:`flex max-h-[90vh] w-full max-w-lg flex-col overflow-hidden rounded-3xl border border-black/[0.07] bg-white shadow-[0_24px_80px_rgba(0,0,0,0.24)] animate-scale-in dark:border-white/[0.08] dark:bg-dark-25`,onClick:e=>e.stopPropagation(),children:(0,O.jsxs)(`div`,{"data-testid":`automation-scroll-region`,className:`min-h-0 overflow-y-auto p-6 scrollbar-thin`,children:[(0,O.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,O.jsx)(`h3`,{id:`automation-modal-title`,className:`text-lg font-medium tracking-[-0.02em] text-gray-950 dark:text-dark-950`,children:h(e?`automations.editAutomation`:`automations.newAutomation`)}),(0,O.jsx)(`button`,{onClick:u,"aria-label":h(`common.close`),className:`rounded-xl p-2 transition-colors hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,O.jsx)(l,{size:20,className:`text-gray-500`})})]}),(0,O.jsxs)(`div`,{className:`space-y-4`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`label`,{htmlFor:`automation-name`,className:F,children:h(`automations.form.name`)}),(0,O.jsx)(`input`,{id:`automation-name`,"data-testid":`automation-name`,type:`text`,value:b,onChange:e=>S(e.target.value),placeholder:h(`automations.form.namePlaceholder`),className:P,maxLength:200,autoFocus:!0})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`span`,{className:F,children:h(`automations.form.triggers`)}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[T.map((e,t)=>(0,O.jsx)(N,{trigger:e,onChange:e=>E(n=>n.map((n,r)=>r===t?e:n)),onRemove:T.length>1?()=>E(e=>e.filter((e,n)=>n!==t)):void 0},t)),x(T)&&(0,O.jsx)(`p`,{"data-testid":`automation-event-only-hint`,className:`text-[12px] text-gray-500 dark:text-dark-500`,children:h(`automations.form.eventOnlyHint`)}),T.length<5&&(0,O.jsxs)(`button`,{type:`button`,onClick:()=>E(e=>[...e,{kind:`daily`,hour:8,minute:0}]),"data-testid":`automation-add-trigger`,className:`flex items-center gap-1.5 rounded-lg px-2 py-1 text-[12px] font-medium text-primary-600 transition-colors hover:bg-primary-500/10 dark:text-primary-400`,children:[(0,O.jsx)(c,{className:`h-3.5 w-3.5`}),h(`automations.form.addTrigger`)]})]})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`label`,{htmlFor:`automation-instructions`,className:F,children:h(`automations.form.instructions`)}),(0,O.jsx)(`textarea`,{id:`automation-instructions`,"data-testid":`automation-instructions`,value:C,onChange:e=>w(e.target.value),placeholder:h(`automations.form.instructionsPlaceholder`),rows:5,className:P,maxLength:2e4})]}),_&&(0,O.jsx)(`p`,{"data-testid":`automation-task-bound-note`,className:`rounded-lg bg-primary-500/10 px-3 py-2 text-[12px] leading-relaxed text-primary-700 dark:text-primary-300`,children:h(`automations.form.taskBoundNote`,{defaultValue:`This routine runs inside the agent's own workspace and conversation, with the agent's model and runtime.`})}),(0,O.jsxs)(`div`,{className:a(`grid grid-cols-2 gap-3`,_&&`hidden`),children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`label`,{htmlFor:`automation-target`,className:F,children:h(`automations.form.target`)}),(0,O.jsxs)(`select`,{id:`automation-target`,"data-testid":`automation-target`,value:L,onChange:e=>R(e.target.value),className:P,children:[(0,O.jsx)(`option`,{value:`chat`,children:h(`automations.form.targetChat`)}),(0,O.jsx)(`option`,{value:`work`,children:h(`automations.form.targetWork`)})]})]}),L===`work`&&V.length>0&&(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`label`,{htmlFor:`automation-work-policy`,className:F,children:h(`automations.form.workPolicy`)}),(0,O.jsxs)(`select`,{id:`automation-work-policy`,"data-testid":`automation-work-policy`,value:z,onChange:e=>B(e.target.value),className:P,children:[(0,O.jsx)(`option`,{value:``,children:h(`automations.form.workPolicyDefault`)}),V.map(e=>(0,O.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]})]}),(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,O.jsxs)(`div`,{className:a(_&&`hidden`),children:[(0,O.jsx)(`label`,{htmlFor:`automation-model`,className:F,children:h(`automations.form.model`)}),(0,O.jsxs)(`select`,{id:`automation-model`,value:k,onChange:e=>A(e.target.value),className:P,children:[(0,O.jsx)(`option`,{value:``,children:h(`automations.form.modelAuto`)}),r.map(e=>(0,O.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`label`,{htmlFor:`automation-notify`,className:F,children:h(`automations.form.notification`)}),(0,O.jsxs)(`select`,{id:`automation-notify`,value:j,onChange:e=>M(e.target.value),className:P,children:[(0,O.jsx)(`option`,{value:`app`,children:h(`automations.form.notifyApp`)}),(0,O.jsx)(`option`,{value:`off`,children:h(`automations.form.notifyOff`)})]})]})]}),e&&(0,O.jsxs)(`div`,{"data-testid":`automation-webhook`,className:`rounded-xl border border-gray-200 p-3 dark:border-dark-300`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:h(`automations.webhook.title`,{defaultValue:`Webhook trigger`})}),(0,O.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-dark-600`,children:U?h(`automations.webhook.enabledHint`,{defaultValue:`External systems can fire this automation with the secret. Rotating invalidates the previous secret.`}):h(`automations.webhook.disabledHint`,{defaultValue:`Let an external system (CI, cron, home automation) fire this automation with a POST and a secret.`})})]}),(0,O.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,"data-testid":`automation-webhook-rotate`,onClick:()=>void Y(),disabled:q,className:`rounded-lg border border-gray-200 px-2.5 py-1.5 text-xs font-medium text-gray-700 transition-colors hover:bg-gray-100 disabled:opacity-50 dark:border-dark-300 dark:text-dark-700 dark:hover:bg-dark-200`,children:U?h(`automations.webhook.rotate`,{defaultValue:`Rotate secret`}):h(`automations.webhook.enable`,{defaultValue:`Enable`})}),U&&(0,O.jsx)(`button`,{type:`button`,"data-testid":`automation-webhook-disable`,onClick:()=>void X(),disabled:q,className:`rounded-lg border border-gray-200 px-2.5 py-1.5 text-xs font-medium text-gray-700 transition-colors hover:bg-gray-100 disabled:opacity-50 dark:border-dark-300 dark:text-dark-700 dark:hover:bg-dark-200`,children:h(`automations.webhook.disable`,{defaultValue:`Disable`})})]})]}),G&&(0,O.jsxs)(`div`,{"data-testid":`automation-webhook-secret`,className:`mt-2 space-y-1 rounded-lg bg-gray-50 p-2 dark:bg-dark-100`,children:[(0,O.jsx)(`p`,{className:`text-[11px] text-gray-500 dark:text-dark-600`,children:h(`automations.webhook.revealHint`,{defaultValue:`Shown once. Send it as a Bearer token or an X-Libre-Webhook-Secret header.`})}),(0,O.jsxs)(`code`,{dir:`ltr`,className:`block break-all font-mono text-xs text-gray-800 dark:text-gray-200`,children:[`POST `,G.path]}),(0,O.jsx)(`code`,{dir:`ltr`,className:`block break-all font-mono text-xs text-gray-800 dark:text-gray-200`,children:G.secret})]})]}),(0,O.jsxs)(`div`,{className:`flex justify-end gap-3 border-t border-gray-200 pt-4 dark:border-dark-300`,children:[(0,O.jsx)(`button`,{onClick:u,"data-testid":`automation-cancel`,className:`rounded-xl px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-100 dark:text-dark-700 dark:hover:bg-dark-200`,children:h(`common.cancel`)}),(0,O.jsx)(`button`,{onClick:()=>{if(!Z)return;if(_){m({name:b.trim(),instructions:C.trim(),triggers:T,notify:j,target:`work`,workTaskId:n??e?.workTaskId});return}let t=r.find(e=>e.name===k);m({name:b.trim(),instructions:C.trim(),triggers:T,...t?{provider:I(t),model:t.name}:{},notify:j,target:L,...L===`work`&&z?{workPolicyId:z}:{}})},disabled:o||!Z,"data-testid":`automation-save`,className:`rounded-xl bg-gray-950 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-gray-800 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-white dark:text-gray-950 dark:hover:bg-gray-100`,children:h(o?`common.saving`:`common.save`)})]})]})]})})}),document.body)}export{E as n,x as r,L as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-vendor-CR5VJ85Q.js";import{d as r}from"./router-vendor-DqMnEJWK.js";import{t as i}from"./logger-BR4forr_.js";import{t as a}from"./chatStore-DpVxt9VX.js";import{t as o}from"./useTranslation-Boi0fB1B.js";import{i as s,t as c}from"./utils-B-Bhh1pF.js";import{Dn as l,Hn as u,Lt as ee,Tr as d,Un as f,Vn as te,X as p,ct as m,et as h,ot as g,rt as _,t as v,v as y}from"./ui-vendor-DVTj_sKN.js";import{t as b}from"./Button-j68Q8KVh.js";import{T as x}from"./api-BrHW-VGd.js";import"./ui-Aq8MP7Ph.js";import{n as S,r as C,t as w}from"./AutomationModal-B4UaWjkk.js";var T=e(t(),1),E=n();function D({days:e,locale:t}){let{t:n}=o(),r=e.reduce((e,t)=>e+t.succeeded,0),i=e.reduce((e,t)=>e+t.failed,0),a=Math.max(1,...e.map(e=>e.succeeded+e.failed)),s=new Intl.DateTimeFormat(t,{month:`short`,day:`numeric`}),c=new Date,l=e=>s.format(new Date(c.getFullYear(),c.getMonth(),c.getDate()-29+e));return(0,E.jsxs)(`div`,{className:`rounded-2xl border border-black/[0.06] bg-white/60 px-4 py-3 dark:border-white/[0.07] dark:bg-dark-100/60`,"data-testid":`automation-run-strip`,children:[(0,E.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,E.jsx)(`p`,{className:`text-[12px] font-medium text-gray-700 dark:text-dark-700`,children:n(`automations.runHistory`)}),(0,E.jsxs)(`p`,{className:`text-[11px] text-gray-400 dark:text-dark-500`,children:[(0,E.jsxs)(`span`,{className:`text-emerald-600 dark:text-emerald-400`,children:[r,` `,n(`automations.succeeded`)]}),` · `,(0,E.jsxs)(`span`,{className:`text-red-500 dark:text-red-400`,children:[i,` `,n(`automations.failed`)]})]})]}),(0,E.jsx)(`div`,{className:`flex h-12 items-end gap-[3px]`,children:e.map((e,t)=>{let n=e.succeeded+e.failed;if(n===0)return(0,E.jsx)(`div`,{title:l(t),className:`h-[3px] flex-1 rounded-sm bg-black/[0.06] dark:bg-white/[0.08]`},t);let r=Math.max(6,Math.round(n/a*48)),i=Math.round(e.failed/n*r);return(0,E.jsxs)(`div`,{title:`${l(t)}: ${e.succeeded}✓ ${e.failed}✗`,className:`flex flex-1 flex-col justify-end overflow-hidden rounded-sm`,style:{height:r},children:[(0,E.jsx)(`div`,{className:`w-full bg-emerald-500/80`,style:{height:r-i}}),i>0&&(0,E.jsx)(`div`,{className:`w-full bg-red-500/80`,style:{height:i}})]},t)})})]})}var O=[{id:`morningBrief`,instructions:`Put together my morning brief: the top world, business, and tech headlines from the last 24 hours with one-line summaries, and one story worth reading in depth and why. Keep the whole thing scannable.`,triggers:[{kind:`daily`,hour:7,minute:30}]},{id:`newsDigest`,instructions:`Summarize the most important AI news from the last 24 hours: model releases, notable research papers, funding rounds, and policy changes. For each item add one sentence on why it matters. Skip minor product updates and rumors.`,triggers:[{kind:`daily`,hour:8,minute:0}]},{id:`weeklyReview`,instructions:`Help me wrap the week: prompt me to reflect on what I accomplished, what is still open, and what the top priorities for next week should be. Structure it as a short template I can fill in.`,triggers:[{kind:`weekly`,dayOfWeek:5,hour:16,minute:0}]},{id:`monthlyReport`,instructions:`Draft a monthly status report outline: key accomplishments, metrics to review, risks, and goals for the next month. Leave placeholders where my specifics belong.`,triggers:[{kind:`monthly`,dayOfMonth:1,hour:9,minute:0}]}],k=i(`pages:automations`),A=()=>{let{t:e,i18n:t}=o(),n=r(),i=a(e=>e.models),A=a(e=>e.loadModels),[M,N]=(0,T.useState)(`automations`),[P,F]=(0,T.useState)([]),[I,L]=(0,T.useState)([]),[R,z]=(0,T.useState)(null),[B,V]=(0,T.useState)(!0),[H,U]=(0,T.useState)(!1),[W,G]=(0,T.useState)(null),[K,q]=(0,T.useState)(null),[J,Y]=(0,T.useState)(!1),[X,Z]=(0,T.useState)(null),[ne,re]=(0,T.useState)(0),Q=(0,T.useCallback)(()=>re(e=>e+1),[]);(0,T.useEffect)(()=>{let t=!1;return Promise.all([x.getAutomations(),x.getRuns(),x.getRunsSummary()]).then(([e,n,r])=>{t||(e.success&&e.data&&F(e.data),n.success&&n.data&&L(n.data),r.success&&r.data&&z(r.data))}).catch(n=>{t||(k.error(`Failed to load automations:`,n),d.error(e(`automations.loadFailed`)))}).finally(()=>{t||V(!1)}),()=>{t=!0}},[ne,e]),(0,T.useEffect)(()=>{i.length===0&&A({quiet:!0})},[i.length,A]),(0,T.useEffect)(()=>{M===`runs`&&x.markRunsSeen().then(()=>x.getRunsSummary()).then(e=>{e.success&&e.data&&z(e.data)}).catch(()=>void 0)},[M,I.length]);let ie=()=>{G(null),q(null),U(!0)},ae=t=>{G(null),q({name:e(`automations.templates.${t.id}.name`),instructions:t.instructions,triggers:t.triggers}),U(!0)},oe=e=>{G(e),q(null),Z(null),U(!0)},se=async t=>{Y(!0);try{let n=W?await x.updateAutomation(W.id,t):await x.createAutomation(t);n.success?(U(!1),Q()):d.error(n.error||e(`automations.saveFailed`))}catch(t){k.error(`Failed to save automation:`,t),d.error(e(`automations.saveFailed`))}finally{Y(!1)}},$=async(t,n)=>{Z(null);try{n===`pause`?await x.pauseAutomation(t.id):n===`resume`?await x.resumeAutomation(t.id):n===`run`?(await x.runAutomationNow(t.id),d.success(e(`automations.runQueued`))):await x.deleteAutomation(t.id),Q()}catch(t){k.error(`Automation ${n} failed:`,t),d.error(e(`automations.actionFailed`))}},ce=e=>e.status===`succeeded`?(0,E.jsx)(f,{className:`h-4 w-4 text-emerald-500`}):e.status===`failed`?(0,E.jsx)(te,{className:`h-4 w-4 text-red-500`}):(0,E.jsx)(ee,{className:`h-4 w-4 animate-spin text-gray-400`}),le=t=>P.find(e=>e.id===t)?.name??e(`automations.deletedAutomation`);return(0,E.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-testid":`automations-page`,children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-b border-black/[0.06] px-4 py-3 dark:border-white/[0.07]`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,E.jsx)(`h1`,{className:`text-sm font-semibold text-gray-900 dark:text-dark-900`,children:e(`automations.title`)}),(0,E.jsx)(`div`,{className:`flex items-center rounded-xl bg-black/[0.04] p-0.5 dark:bg-white/[0.06]`,children:[`automations`,`runs`].map(t=>(0,E.jsx)(`button`,{onClick:()=>N(t),"data-testid":`automations-tab-${t}`,className:c(`rounded-[10px] px-2.5 py-1 text-[12px] font-medium transition-colors`,M===t?`bg-white text-gray-900 shadow-sm dark:bg-dark-200 dark:text-dark-900`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),children:e(`automations.tab.${t}`)},t))})]}),(0,E.jsxs)(b,{size:`sm`,onClick:ie,"data-testid":`automation-new`,className:`h-7 gap-1 px-2.5 text-[12px]`,children:[(0,E.jsx)(h,{className:`h-3.5 w-3.5`}),e(`automations.newAutomation`)]})]}),(0,E.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 overflow-y-auto px-4 py-4 scrollbar-thin`,children:[M===`automations`?B?null:P.length===0?(0,E.jsxs)(`div`,{className:`px-3 py-16 text-center`,children:[(0,E.jsx)(v,{className:`mx-auto mb-2 h-6 w-6 text-gray-300 dark:text-dark-400`}),(0,E.jsx)(`p`,{className:`text-sm text-gray-400 dark:text-dark-500`,children:e(`automations.empty`)})]}):(0,E.jsx)(`div`,{className:`mx-auto w-full max-w-3xl space-y-2`,children:P.map(n=>(0,E.jsx)(`div`,{"data-testid":`automation-row`,className:`rounded-2xl border border-black/[0.06] bg-white/60 px-4 py-3 dark:border-white/[0.07] dark:bg-dark-100/60`,children:(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,E.jsxs)(`div`,{className:`min-w-0`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(`p`,{className:`truncate text-[14px] font-medium text-gray-900 dark:text-dark-900`,children:n.name}),(0,E.jsx)(`span`,{className:c(`rounded-full px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide`,n.status===`active`?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`:`bg-gray-500/10 text-gray-500 dark:text-dark-500`),children:e(`automations.status.${n.status}`)})]}),(0,E.jsxs)(`p`,{className:`mt-0.5 truncate text-[12px] text-gray-500 dark:text-dark-500`,children:[S(n.triggers,t.language,e),!C(n.triggers)&&n.nextRunAt&&(0,E.jsxs)(E.Fragment,{children:[` · `,e(`automations.nextRun`,{when:new Intl.DateTimeFormat(t.language,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}).format(n.nextRunAt)})]})]})]}),(0,E.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,E.jsx)(`button`,{onClick:()=>Z(e=>e===n.id?null:n.id),"aria-label":e(`automations.actions`),"data-testid":`automation-menu`,className:`rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-black/[0.04] hover:text-gray-700 dark:hover:bg-white/[0.06] dark:hover:text-dark-800`,children:(0,E.jsx)(l,{className:`h-4 w-4`})}),X===n.id&&(0,E.jsxs)(`div`,{className:`absolute end-0 top-8 z-20 w-44 rounded-xl border border-black/[0.07] bg-white p-1 shadow-lg dark:border-white/[0.08] dark:bg-dark-100`,children:[(0,E.jsx)(j,{icon:g,label:e(`common.edit`),onClick:()=>oe(n)}),n.status===`active`?(0,E.jsx)(j,{icon:m,label:e(`automations.pause`),onClick:()=>$(n,`pause`)}):(0,E.jsx)(j,{icon:_,label:e(`automations.resume`),onClick:()=>$(n,`resume`)}),(0,E.jsx)(j,{icon:p,label:e(`automations.runNow`),onClick:()=>$(n,`run`)}),(0,E.jsx)(j,{icon:y,label:e(`common.delete`),destructive:!0,onClick:()=>$(n,`delete`)})]})]})]})},n.id))}):null,M===`automations`&&!B&&(0,E.jsxs)(`div`,{className:`mx-auto mt-8 w-full max-w-3xl`,children:[(0,E.jsx)(`p`,{className:`mb-2 text-[11px] font-medium uppercase tracking-wide text-gray-400 dark:text-dark-500`,children:e(`automations.templatesTitle`)}),(0,E.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:O.map(n=>(0,E.jsxs)(`button`,{type:`button`,onClick:()=>ae(n),"data-testid":`automation-template`,className:`rounded-2xl border border-black/[0.06] bg-white/40 px-4 py-3 text-start transition-colors hover:bg-white/80 dark:border-white/[0.07] dark:bg-dark-100/40 dark:hover:bg-dark-100/80`,children:[(0,E.jsx)(`p`,{className:`text-[13px] font-medium text-gray-900 dark:text-dark-900`,children:e(`automations.templates.${n.id}.name`)}),(0,E.jsx)(`p`,{className:`mt-0.5 text-[12px] text-gray-500 dark:text-dark-500`,children:e(`automations.templates.${n.id}.description`)}),(0,E.jsx)(`p`,{className:`mt-1.5 text-[11px] text-gray-400 dark:text-dark-500`,children:S(n.triggers,t.language,e)})]},n.id))})]}),M===`runs`&&(0,E.jsxs)(`div`,{className:`mx-auto w-full max-w-3xl space-y-4`,children:[R&&(0,E.jsx)(D,{days:R.days,locale:t.language}),I.length===0?(0,E.jsxs)(`div`,{className:`px-3 py-12 text-center`,children:[(0,E.jsx)(u,{className:`mx-auto mb-2 h-6 w-6 text-gray-300 dark:text-dark-400`}),(0,E.jsx)(`p`,{className:`text-sm text-gray-400 dark:text-dark-500`,children:e(`automations.noRuns`)})]}):(0,E.jsx)(`div`,{className:`space-y-1`,"data-testid":`automation-run-list`,children:I.map(r=>(0,E.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-black/[0.05] bg-white/50 px-3 py-2 dark:border-white/[0.06] dark:bg-dark-100/50`,children:[ce(r),(0,E.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,E.jsx)(`p`,{className:`truncate text-[13px] text-gray-900 dark:text-dark-900`,children:le(r.automationId)}),(0,E.jsxs)(`p`,{className:`truncate text-[11px] text-gray-400 dark:text-dark-500`,children:[s(r.scheduledFor,t.language),r.error&&(0,E.jsxs)(E.Fragment,{children:[` · `,(0,E.jsx)(`span`,{className:`text-red-500`,children:r.error})]})]})]}),r.sessionId&&(0,E.jsx)(`button`,{onClick:()=>n(`/c/${r.sessionId}`),"data-testid":`automation-run-open`,className:`shrink-0 rounded-lg px-2.5 py-1 text-[12px] font-medium text-primary-600 transition-colors hover:bg-primary-500/10 dark:text-primary-400`,children:e(`automations.openChat`)}),r.workTaskId&&(0,E.jsx)(`button`,{onClick:()=>n(`/work/${r.workTaskId}`),"data-testid":`automation-run-open-task`,className:`shrink-0 rounded-lg px-2.5 py-1 text-[12px] font-medium text-primary-600 transition-colors hover:bg-primary-500/10 dark:text-primary-400`,children:e(`automations.openTask`)})]},r.id))})]})]}),(0,E.jsx)(w,{open:H,automation:W,initial:K,models:i,saving:J,onClose:()=>U(!1),onSave:e=>void se(e)})]})};function j({icon:e,label:t,destructive:n,onClick:r}){return(0,E.jsxs)(`button`,{onClick:r,className:c(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-start text-[13px] transition-colors`,n?`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20`:`text-gray-700 hover:bg-black/[0.04] dark:text-dark-700 dark:hover:bg-white/[0.06]`),children:[(0,E.jsx)(e,{className:`h-3.5 w-3.5`}),t]})}export{A as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-vendor-CR5VJ85Q.js";import{t as r}from"./logger-BR4forr_.js";import{t as i}from"./useTranslation-Boi0fB1B.js";import{Tr as a,c as o,n as s,p as c}from"./ui-vendor-DVTj_sKN.js";import{t as l}from"./Button-j68Q8KVh.js";import"./ui-Aq8MP7Ph.js";var u=e(t(),1),d=n(),f=r(`components:avatar-upload`),p=({value:e,onChange:t,className:n=``})=>{let{t:r}=i(),p=(0,u.useRef)(null),[m,h]=(0,u.useState)(!1),[g,_]=(0,u.useState)(!1),v=async e=>{if(!e.type.startsWith(`image/`)){a.error(r(`user.avatar.invalidFile`));return}if(e.size>2097152){a.error(r(`user.avatar.fileTooLarge`));return}h(!0);try{let n=new FileReader;n.onload=e=>{let n=e.target?.result;t(n),a.success(r(`user.avatar.uploaded`))},n.onerror=()=>{a.error(r(`user.avatar.readFailed`))},n.readAsDataURL(e)}catch(e){f.error(`Failed to upload avatar:`,e),a.error(r(`user.avatar.uploadFailed`))}finally{h(!1)}},y=e=>{let t=e.target.files?.[0];t&&v(t)},b=e=>{e.preventDefault(),_(!0)},x=e=>{e.preventDefault(),_(!1)},S=e=>{e.preventDefault(),_(!1);let t=e.dataTransfer.files?.[0];t&&v(t)},C=()=>{t(``),a.success(r(`user.avatar.removed`))},w=()=>e||null;return(0,d.jsx)(`div`,{className:`space-y-4 ${n}`,children:(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-600 mb-2`,children:r(`user.avatar.label`)}),(0,d.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,d.jsx)(`div`,{className:`flex-shrink-0`,children:(0,d.jsx)(`div`,{className:`w-20 h-20 rounded-full overflow-hidden bg-gray-100 dark:bg-dark-200 border-2 border-gray-300 dark:border-dark-300 flex items-center justify-center`,children:w()?(0,d.jsx)(`img`,{src:w(),alt:`Avatar preview`,className:`w-full h-full object-cover`}):(0,d.jsx)(o,{className:`h-8 w-8 text-gray-400 dark:text-gray-500`})})}),(0,d.jsxs)(`div`,{className:`flex-1 space-y-3`,children:[e?(0,d.jsxs)(`div`,{className:`flex items-center gap-3 p-3 bg-gray-50 dark:bg-dark-200 rounded-lg`,children:[(0,d.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,d.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:r(`user.avatar.customAvatar`)}),(0,d.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:r(`user.avatar.clickToChange`)})]}),(0,d.jsx)(l,{variant:`ghost`,size:`sm`,onClick:C,className:`text-red-600 hover:text-red-700 hover:bg-red-50 dark:text-red-400 dark:hover:text-red-300 dark:hover:bg-red-900/20`,children:(0,d.jsx)(s,{className:`h-4 w-4`})})]}):(0,d.jsxs)(`div`,{className:`border-2 border-dashed rounded-lg p-4 text-center cursor-pointer transition-colors ${g?`border-primary-500 bg-primary-50 dark:bg-primary-900/20`:`border-gray-300 dark:border-gray-600 hover:border-gray-400 dark:hover:border-gray-500`}`,onDragOver:b,onDragLeave:x,onDrop:S,onClick:()=>p.current?.click(),children:[(0,d.jsx)(c,{className:`h-8 w-8 mx-auto text-gray-400 dark:text-gray-500 mb-2`}),(0,d.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:r(`user.avatar.uploadAvatarImage`)}),(0,d.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-2`,children:r(`user.avatar.dragAndDrop`)}),(0,d.jsxs)(l,{variant:`outline`,size:`sm`,disabled:m,className:`mx-auto`,children:[(0,d.jsx)(c,{className:`h-4 w-4 mr-2`}),r(m?`user.avatar.uploading`:`user.avatar.chooseImage`)]})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`label`,{className:`block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1`,children:r(`user.avatar.enterImageUrl`)}),(0,d.jsx)(`input`,{type:`url`,value:e,onChange:e=>t(e.target.value),className:`w-full px-3 py-2 text-sm border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800`,placeholder:`https://example.com/avatar.jpg`})]})]})]}),(0,d.jsx)(`input`,{ref:p,type:`file`,accept:`image/*`,onChange:y,className:`hidden`}),(0,d.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:r(`user.avatar.supportedFormats`)})]})})};export{p as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./rolldown-runtime-hePW80VL.js";import{i as e,t}from"./react-vendor-CR5VJ85Q.js";import{t as n}from"./utils-B-Bhh1pF.js";e();var r=t(),i=({variant:e=`primary`,size:t=`md`,loading:i=!1,disabled:a,children:o,className:s,...c})=>(0,r.jsxs)(`button`,{className:n(`group relative inline-flex select-none items-center justify-center rounded-xl border font-medium tracking-[-0.01em] transition-[background-color,border-color,color,box-shadow,opacity] duration-150 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:ring-offset-canvas dark:focus-visible:ring-primary-400 disabled:cursor-not-allowed disabled:opacity-40 motion-reduce:transition-none`,{primary:`border-transparent bg-ink text-ink-inverse shadow-subtle hover:opacity-90`,secondary:`border-line bg-surface-raised text-ink shadow-subtle hover:border-line-strong hover:bg-surface-subtle`,outline:`border-line bg-transparent text-ink hover:border-line-strong hover:bg-surface-subtle`,ghost:`border-transparent bg-transparent text-ink-muted shadow-none hover:bg-surface-subtle hover:text-ink`,danger:`border-transparent bg-error-600 text-white shadow-subtle hover:bg-error-700 dark:bg-error-500 dark:text-ink-inverse dark:hover:bg-error-400`}[e],{sm:`h-8 px-3 text-sm gap-1.5`,md:`h-10 px-4 text-sm gap-2`,lg:`h-11 px-5 text-base gap-2.5`}[t],s),disabled:a||i,"aria-busy":i||void 0,...c,children:[i&&(0,r.jsxs)(`svg`,{className:`mr-2 h-4 w-4 animate-spin`,"aria-hidden":`true`,fill:`none`,viewBox:`0 0 24 24`,children:[(0,r.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,r.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`})]}),o]});export{i as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,r as n,t as r}from"./react-vendor-CR5VJ85Q.js";import{d as i}from"./router-vendor-DqMnEJWK.js";import{t as a}from"./logger-BR4forr_.js";import{t as o}from"./useTranslation-Boi0fB1B.js";import{t as s}from"./utils-B-Bhh1pF.js";import{B as c,On as l,Tr as u,Xn as d,Yn as f,et as p,n as m,p as h,v as g}from"./ui-vendor-DVTj_sKN.js";import{t as _}from"./Button-j68Q8KVh.js";import{O as v,T as y}from"./api-BrHW-VGd.js";import"./ui-Aq8MP7Ph.js";import{t as b}from"./ShareDialog-DaSxkTKS.js";import{a as x,c as S,d as C,i as w,l as T,n as E,o as D,r as O,s as k,t as A,u as j}from"./calendarDates-Co3o_05Y.js";var M=e(t(),1),N=r(),P={event:`bg-primary-500/15 text-primary-700 hover:bg-primary-500/25 dark:text-primary-300`,automation:`bg-amber-500/15 text-amber-700 hover:bg-amber-500/25 dark:text-amber-300`,runSucceeded:`bg-emerald-500/15 text-emerald-700 hover:bg-emerald-500/25 dark:text-emerald-300`,runFailed:`bg-red-500/15 text-red-700 hover:bg-red-500/25 dark:text-red-300`};function F({event:e,label:t,onClick:n}){return(0,N.jsx)(`button`,{type:`button`,"data-testid":`calendar-event-chip`,"data-variant":e.variant??`event`,title:e.title,onClick:e=>{e.stopPropagation(),n()},className:s(`w-full truncate rounded-md px-1.5 py-0.5 text-start text-[11px] leading-4 transition-colors`,P[e.variant??`event`],e.baseEventId&&`opacity-75`),children:t})}var I=3;function L({year:e,monthIndex:t,events:n,onDayClick:r,onEventClick:i}){let{t:a,i18n:c}=o(),l=(0,M.useMemo)(()=>O(e,t),[e,t]),u=new Date,d=(0,M.useMemo)(()=>{let e=new Map;for(let t of n){let n=new Date(t.startAt),r=`${n.getFullYear()}-${n.getMonth()}-${n.getDate()}`,i=e.get(r);i?i.push(t):e.set(r,[t])}return e},[n]),f=(0,M.useMemo)(()=>C(c.language),[c.language]);return(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-testid":`calendar-month-grid`,children:[(0,N.jsx)(`div`,{className:`grid grid-cols-7 border-b border-black/[0.06] dark:border-white/[0.07]`,children:f.map(e=>(0,N.jsx)(`div`,{className:`px-2 py-1.5 text-center text-[11px] font-medium uppercase tracking-wide text-gray-400 dark:text-dark-500`,children:e},e))}),(0,N.jsx)(`div`,{className:`grid min-h-0 flex-1 grid-cols-7 grid-rows-6`,children:l.map(e=>{let n=e.getMonth()===t,o=w(e,u),l=`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`,f=d.get(l)??[],p=f.length-I;return(0,N.jsxs)(`div`,{role:`gridcell`,"data-testid":`calendar-day-cell`,onClick:()=>r(e),className:s(`flex min-h-0 cursor-pointer flex-col gap-0.5 border-b border-e border-black/[0.04] p-1 transition-colors hover:bg-black/[0.02] dark:border-white/[0.04] dark:hover:bg-white/[0.03]`,!n&&`opacity-40`),children:[(0,N.jsx)(`span`,{className:s(`flex h-6 w-6 items-center justify-center rounded-full text-[12px]`,o?`bg-primary-500 font-semibold text-white`:`text-gray-600 dark:text-dark-600`),children:e.getDate()}),(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-0.5 overflow-hidden`,children:[f.slice(0,I).map(e=>(0,N.jsx)(F,{event:e,label:e.allDay?e.title:`${k(e.startAt,c.language)} ${e.title}`,onClick:()=>i(e)},e.id)),p>0&&(0,N.jsx)(`span`,{className:`px-1 text-[10px] text-gray-400 dark:text-dark-500`,children:a(`calendar.more`,{n:p})})]})]},l)})})]})}var R=48;function ee({anchor:e,events:t,dayCount:n=7,onDayClick:r,onEventClick:i}){let{i18n:a}=o(),c=(0,M.useMemo)(()=>n===1?[new Date(e.getFullYear(),e.getMonth(),e.getDate())]:j(e),[e,n]),l=new Date,u=(0,M.useMemo)(()=>new Intl.DateTimeFormat(a.language,{hour:`numeric`}),[a.language]),d=(0,M.useMemo)(()=>new Intl.DateTimeFormat(a.language,{weekday:`short`,day:`numeric`}),[a.language]),f=e=>t.filter(t=>t.allDay&&w(new Date(t.startAt),e)),p=e=>t.filter(t=>!t.allDay&&w(new Date(t.startAt),e));return(0,N.jsx)(`div`,{className:`scroll-region min-h-0 flex-1 overflow-y-auto scrollbar-thin`,"data-testid":`calendar-week-grid`,children:(0,N.jsxs)(`div`,{className:`grid grid-cols-[3.5rem_repeat(7,1fr)]`,children:[(0,N.jsx)(`div`,{className:`sticky top-0 z-10 border-b border-black/[0.06] bg-surface dark:border-white/[0.07]`}),c.map(e=>(0,N.jsxs)(`div`,{className:`sticky top-0 z-10 border-b border-e border-black/[0.06] bg-surface px-1 py-1.5 dark:border-white/[0.07]`,children:[(0,N.jsx)(`span`,{className:s(`block truncate text-center text-[11px] font-medium`,w(e,l)?`text-primary-600 dark:text-primary-400`:`text-gray-500 dark:text-dark-500`),children:d.format(e)}),(0,N.jsx)(`div`,{className:`mt-0.5 space-y-0.5`,children:f(e).map(e=>(0,N.jsx)(F,{event:e,label:e.title,onClick:()=>i(e)},e.id))})]},e.toISOString())),Array.from({length:24},(e,t)=>(0,N.jsxs)(M.Fragment,{children:[(0,N.jsx)(`div`,{className:`relative border-b border-black/[0.04] pe-1.5 text-end text-[10px] text-gray-400 dark:border-white/[0.04] dark:text-dark-500`,children:(0,N.jsx)(`span`,{className:`relative -top-1.5`,children:t>0?u.format(new Date(2024,0,1,t)):``})}),c.map(e=>{let n=p(e).filter(e=>new Date(e.startAt).getHours()===t);return(0,N.jsx)(`div`,{onClick:()=>r(e,t),style:{height:R},className:`cursor-pointer space-y-0.5 overflow-hidden border-b border-e border-black/[0.04] p-0.5 transition-colors hover:bg-black/[0.02] dark:border-white/[0.04] dark:hover:bg-white/[0.03]`,children:n.map(e=>(0,N.jsx)(F,{event:e,label:`${k(e.startAt,a.language)} ${e.title}`,onClick:()=>i(e)},e.id))},`${e.toISOString()}-${t}`)})]},t))]})})}var z=n(),B=e=>!e||e.kind===`once`||e.kind===`hourly`||e.kind===`event`?`none`:e.kind,V=(e,t)=>{let n=new Date(t),r=n.getHours(),i=n.getMinutes();switch(e){case`daily`:return{kind:`daily`,hour:r,minute:i};case`weekly`:return{kind:`weekly`,dayOfWeek:n.getDay(),hour:r,minute:i};case`monthly`:return{kind:`monthly`,dayOfMonth:n.getDate(),hour:r,minute:i};case`yearly`:return{kind:`yearly`,month:n.getMonth()+1,dayOfMonth:n.getDate(),hour:r,minute:i};default:return null}},H=`w-full rounded-lg border border-black/[0.08] bg-white px-2.5 py-1.5 text-[13px] text-gray-900 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.08] dark:bg-dark-100 dark:text-dark-900`,U=`mb-1 block text-[11px] font-medium uppercase tracking-wide text-gray-400 dark:text-dark-500`;function te({open:e,event:t,initialStartAt:n,calendars:r,saving:i,onClose:a,onSave:o,onDelete:s}){return e?(0,N.jsx)(W,{event:t,initialStartAt:n,calendars:r,saving:i,onClose:a,onSave:o,onDelete:s},`${t?.id??`new`}:${n}`):null}function W({event:e,initialStartAt:t,calendars:n,saving:r,onClose:i,onSave:a,onDelete:s}){let{t:c}=o(),l=e?.startAt??t,[u,d]=(0,M.useState)(e?.title??``),[f,p]=(0,M.useState)(e?.notes??``),[h,_]=(0,M.useState)(S(l)),[v,y]=(0,M.useState)(e?T(l):`09:00`),[b,x]=(0,M.useState)(e?.endAt===void 0?``:T(e.endAt)),[C,w]=(0,M.useState)(e?.allDay??!1),[D,O]=(0,M.useState)(B(e?.recurrence)),[k,A]=(0,M.useState)(e?.calendarId??``),[j,P]=(0,M.useState)(e?.reminderMinutes===void 0?``:String(e.reminderMinutes)),F=()=>{if(!u.trim()||!h)return;let e=E(h,C?``:v),t=!C&&b?E(h,b):null;a({title:u.trim(),notes:f.trim()?f.trim():void 0,startAt:e,endAt:t!==null&&t>e?t:null,allDay:C,recurrence:V(D,e),calendarId:k||null,reminderMinutes:j?Number(j):null})},I=[{value:``,label:c(`calendar.reminderNone`)},{value:`5`,label:c(`calendar.reminderMinutes`,{minutes:5})},{value:`15`,label:c(`calendar.reminderMinutes`,{minutes:15})},{value:`30`,label:c(`calendar.reminderMinutes`,{minutes:30})},{value:`60`,label:c(`calendar.reminderHour`)},{value:`1440`,label:c(`calendar.reminderDay`)}],L=[{value:`none`,label:c(`calendar.repeatNone`)},{value:`daily`,label:c(`calendar.repeatDaily`)},{value:`weekly`,label:c(`calendar.repeatWeekly`)},{value:`monthly`,label:c(`calendar.repeatMonthly`)},{value:`yearly`,label:c(`calendar.repeatYearly`)}];return(0,z.createPortal)((0,N.jsx)(`div`,{className:`fixed inset-0 z-[2147483647] flex items-center justify-center bg-gray-950/55 p-4 backdrop-blur-md`,onClick:i,children:(0,N.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`calendar-event-modal-title`,"data-testid":`calendar-event-modal`,className:`w-full max-w-md rounded-3xl border border-black/[0.07] bg-white p-6 shadow-[0_24px_80px_rgba(0,0,0,0.24)] animate-scale-in dark:border-white/[0.08] dark:bg-dark-25`,onClick:e=>e.stopPropagation(),children:[(0,N.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,N.jsx)(`h3`,{id:`calendar-event-modal-title`,className:`text-lg font-medium tracking-[-0.02em] text-gray-950 dark:text-dark-950`,children:c(e?`calendar.editEvent`:`calendar.newEvent`)}),(0,N.jsx)(`button`,{onClick:i,"aria-label":c(`common.close`),className:`rounded-xl p-2 transition-colors hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,N.jsx)(m,{size:20,className:`text-gray-500`})})]}),(0,N.jsxs)(`div`,{className:`space-y-3`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{htmlFor:`calendar-event-title`,className:U,children:c(`calendar.eventTitle`)}),(0,N.jsx)(`input`,{id:`calendar-event-title`,"data-testid":`calendar-event-title`,type:`text`,value:u,onChange:e=>d(e.target.value),placeholder:c(`calendar.titlePlaceholder`),className:H,maxLength:200,autoFocus:!0})]}),(0,N.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{htmlFor:`calendar-event-date`,className:U,children:c(`calendar.date`)}),(0,N.jsx)(`input`,{id:`calendar-event-date`,type:`date`,value:h,onChange:e=>_(e.target.value),className:H})]}),(0,N.jsx)(`div`,{className:`flex items-end pb-1.5`,children:(0,N.jsxs)(`label`,{className:`flex items-center gap-2 text-[13px] text-gray-700 dark:text-dark-700`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:C,onChange:e=>w(e.target.checked),className:`h-4 w-4 rounded accent-primary-500`}),c(`calendar.allDay`)]})})]}),!C&&(0,N.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{htmlFor:`calendar-event-start`,className:U,children:c(`calendar.start`)}),(0,N.jsx)(`input`,{id:`calendar-event-start`,type:`time`,value:v,onChange:e=>y(e.target.value),className:H})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{htmlFor:`calendar-event-end`,className:U,children:c(`calendar.end`)}),(0,N.jsx)(`input`,{id:`calendar-event-end`,type:`time`,value:b,onChange:e=>x(e.target.value),className:H})]})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{htmlFor:`calendar-event-repeat`,className:U,children:c(`calendar.repeat`)}),(0,N.jsx)(`select`,{id:`calendar-event-repeat`,value:D,onChange:e=>O(e.target.value),className:H,children:L.map(e=>(0,N.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{htmlFor:`calendar-event-notes`,className:U,children:c(`calendar.notes`)}),(0,N.jsx)(`textarea`,{id:`calendar-event-notes`,value:f,onChange:e=>p(e.target.value),rows:3,className:H,maxLength:1e4})]}),(0,N.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:U,children:c(`calendar.calendarLabel`)}),(0,N.jsxs)(`select`,{value:k,onChange:e=>A(e.target.value),className:H,"data-testid":`calendar-event-calendar`,children:[(0,N.jsx)(`option`,{value:``,children:c(`calendar.personalCalendar`)}),n.map(e=>(0,N.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:U,children:c(`calendar.reminderLabel`)}),(0,N.jsx)(`select`,{value:j,onChange:e=>P(e.target.value),className:H,"data-testid":`calendar-event-reminder`,children:I.map(e=>(0,N.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]}),(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-gray-200 pt-4 dark:border-dark-300`,children:[e&&s?(0,N.jsxs)(`button`,{onClick:s,"data-testid":`calendar-event-delete`,className:`flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium text-red-600 transition-colors hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20`,children:[(0,N.jsx)(g,{className:`h-4 w-4`}),c(`common.delete`)]}):(0,N.jsx)(`span`,{}),(0,N.jsxs)(`div`,{className:`flex gap-3`,children:[(0,N.jsx)(`button`,{onClick:i,className:`rounded-xl px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-100 dark:text-dark-700 dark:hover:bg-dark-200`,children:c(`common.cancel`)}),(0,N.jsx)(`button`,{onClick:F,disabled:r||!u.trim(),"data-testid":`calendar-event-save`,className:`rounded-xl bg-gray-950 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-gray-800 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-white dark:text-gray-950 dark:hover:bg-gray-100`,children:c(r?`common.saving`:`common.save`)})]})]})]})]})}),document.body)}var G=a(`pages:calendar`),K=()=>{let{t:e,i18n:t}=o(),n=i(),[r,a]=(0,M.useState)(`month`),[g,S]=(0,M.useState)(()=>new Date),[C,w]=(0,M.useState)([]),[T,E]=(0,M.useState)([]),[O,k]=(0,M.useState)(!1),[j,P]=(0,M.useState)(null),[F,I]=(0,M.useState)(()=>Date.now()),[R,z]=(0,M.useState)(!1),[B,V]=(0,M.useState)([]),[H,U]=(0,M.useState)(``),[W,K]=(0,M.useState)(!1),[q,J]=(0,M.useState)(null),Y=M.useRef(null),X=(0,M.useMemo)(()=>{if(r===`month`){let e=new Date(g.getFullYear(),g.getMonth(),1),t=D(e);return{from:t.getTime(),to:A(t,42).getTime()}}if(r===`day`){let e=new Date(g.getFullYear(),g.getMonth(),g.getDate());return{from:e.getTime(),to:A(e,1).getTime()}}let e=D(g);return{from:e.getTime(),to:A(e,7).getTime()}},[g,r]),[Z,ne]=(0,M.useState)(0),Q=(0,M.useCallback)(()=>ne(e=>e+1),[]);(0,M.useEffect)(()=>{v.getCalendars().then(e=>{e.success&&e.data&&V(e.data)}).catch(e=>G.error(`Failed to load calendars:`,e))},[Z]),(0,M.useEffect)(()=>{let t=!1;return v.getEvents(X.from,X.to).then(e=>{t||e.success&&e.data&&w(e.data)}).catch(n=>{t||(G.error(`Failed to load calendar events:`,n),u.error(e(`calendar.loadFailed`)))}),Promise.all([y.getOccurrences(X.from,X.to),y.getRuns({from:X.from,to:X.to}),y.getAutomations()]).then(([n,r,i])=>{if(t)return;let a=Date.now(),o=t=>i.data?.find(e=>e.id===t)?.name??e(`automations.deletedAutomation`),s=[];for(let e of n.data??[])e.at<=a||s.push({id:`automation:${e.automationId}:${e.at}`,title:e.name,startAt:e.at,allDay:!1,createdAt:e.at,updatedAt:e.at,variant:`automation`});for(let e of r.data??[])(e.status===`succeeded`||e.status===`failed`)&&s.push({id:`run:${e.id}`,title:o(e.automationId),startAt:e.scheduledFor,allDay:!1,createdAt:e.createdAt,updatedAt:e.createdAt,variant:e.status===`succeeded`?`runSucceeded`:`runFailed`,...e.sessionId?{sessionId:e.sessionId}:{}});E(s)}).catch(e=>{t||G.error(`Failed to project automations onto the calendar:`,e)}),()=>{t=!0}},[X.from,X.to,Z,e]);let re=(0,M.useMemo)(()=>[...C,...T].sort((e,t)=>e.startAt-t.startAt),[C,T]),ie=e=>{S(t=>r===`month`?new Date(t.getFullYear(),t.getMonth()+e,1):A(t,e*(r===`day`?1:7)))},$=(e,t=9)=>{P(null),I(new Date(e.getFullYear(),e.getMonth(),e.getDate(),t,0).getTime()),k(!0)},ae=t=>{if(t.variant===`runSucceeded`||t.variant===`runFailed`){t.sessionId?n(`/c/${t.sessionId}`):n(`/automations`);return}if(t.variant===`automation`){n(`/automations`);return}if(t.shared&&t.shared.permission!==`write`){u(e(`calendar.sharedReadOnly`));return}if(t.baseEventId){let e=C.find(e=>e.id===t.baseEventId);P(e??t)}else P(t);k(!0)},oe=async t=>{z(!0);try{let n=j?await v.updateEvent(j.id,t):await v.createEvent(t);n.success?(k(!1),Q()):u.error(n.error||e(`calendar.saveFailed`))}catch(t){G.error(`Failed to save calendar event:`,t),u.error(e(`calendar.saveFailed`))}finally{z(!1)}},se=async()=>{if(j){z(!0);try{let t=await v.deleteEvent(j.id);t.success?(k(!1),Q()):u.error(t.error||e(`calendar.deleteFailed`))}catch(t){G.error(`Failed to delete calendar event:`,t),u.error(e(`calendar.deleteFailed`))}finally{z(!1)}}},ce=r===`month`?x(g.getFullYear(),g.getMonth(),t.language):new Intl.DateTimeFormat(t.language,{month:`long`,day:`numeric`,year:`numeric`}).format(r===`day`?g:D(g)),le=async()=>{let t=H.trim();if(!t||W)return;K(!0);let n=await v.createCalendar({name:t}).catch(()=>void 0);K(!1),n?.success?(U(``),Q()):u.error(e(`calendar.calendarSaveFailed`))},ue=async t=>{try{let e=await v.exportIcs(t),n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=`calendar.ics`,r.click(),URL.revokeObjectURL(n)}catch(t){G.error(`Failed to export the calendar:`,t),u.error(e(`calendar.exportFailed`))}},de=async t=>{try{let n=await t.text(),r=await v.importIcs(n);r.success&&r.data?(u.success(e(`calendar.importResult`,{total:r.data.imported})),Q()):u.error(r.error||e(`calendar.importFailed`))}catch(t){G.error(`Failed to import the calendar:`,t),u.error(e(`calendar.importFailed`))}};return(0,N.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-testid":`calendar-page`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-b border-black/[0.06] px-4 py-3 dark:border-white/[0.07]`,children:[(0,N.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,N.jsx)(`h1`,{className:`text-sm font-semibold text-gray-900 dark:text-dark-900`,children:e(`calendar.title`)}),(0,N.jsx)(`span`,{className:`text-sm text-gray-500 dark:text-dark-500`,"data-testid":`calendar-range-label`,children:ce})]}),(0,N.jsxs)(`div`,{className:`flex w-full min-w-0 flex-wrap items-center gap-2 sm:w-auto`,children:[(0,N.jsx)(`div`,{className:`flex items-center rounded-xl bg-black/[0.04] p-0.5 dark:bg-white/[0.06]`,children:[`month`,`week`,`day`].map(t=>(0,N.jsx)(`button`,{type:`button`,onClick:()=>a(t),"aria-pressed":r===t,"data-testid":`calendar-view-${t}`,className:s(`rounded-[10px] px-2.5 py-1 text-[12px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:ring-offset-canvas`,r===t?`bg-white text-gray-900 shadow-sm dark:bg-dark-200 dark:text-dark-900`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),children:e(`calendar.${t}`)},t))}),(0,N.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,N.jsx)(_,{size:`sm`,variant:`ghost`,onClick:()=>ie(-1),className:`h-7 w-7 p-0`,title:e(`calendar.previous`),"aria-label":e(`calendar.previous`),children:(0,N.jsx)(d,{className:`h-4 w-4 rtl:rotate-180`})}),(0,N.jsx)(_,{size:`sm`,variant:`ghost`,onClick:()=>S(new Date),className:`h-7 px-2 text-[12px]`,children:e(`calendar.today`)}),(0,N.jsx)(_,{size:`sm`,variant:`ghost`,onClick:()=>ie(1),className:`h-7 w-7 p-0`,title:e(`calendar.next`),"aria-label":e(`calendar.next`),children:(0,N.jsx)(f,{className:`h-4 w-4 rtl:rotate-180`})})]}),(0,N.jsxs)(_,{size:`sm`,onClick:()=>$(g),"data-testid":`calendar-new-event`,className:`h-7 gap-1 px-2.5 text-[12px]`,children:[(0,N.jsx)(p,{className:`h-3.5 w-3.5`}),e(`calendar.newEvent`)]})]})]}),(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 border-b border-black/[0.06] px-4 py-2 dark:border-white/[0.07]`,children:[B.map(t=>(0,N.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1.5 rounded-full border border-black/[0.08] px-2.5 py-1 text-xs text-gray-700 dark:border-white/[0.1] dark:text-dark-800`,"data-testid":`calendar-chip`,children:[(0,N.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:t.color??`#8b8b8b`}}),(0,N.jsx)(`span`,{className:`truncate`,title:t.name,children:t.name}),t.shared?(0,N.jsx)(`span`,{className:`text-[10px] uppercase text-gray-400 dark:text-dark-500`,children:e(`calendar.sharedBadge`)}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`button`,{onClick:()=>J(t),className:`shrink-0 text-gray-400 hover:text-primary-500 dark:text-dark-500`,title:e(`calendar.shareCalendar`),"data-testid":`calendar-share`,children:(0,N.jsx)(c,{className:`h-3 w-3`})}),(0,N.jsx)(`button`,{onClick:()=>void v.deleteCalendar(t.id).then(Q),className:`shrink-0 text-gray-400 hover:text-red-500 dark:text-dark-500`,title:e(`common.delete`),children:(0,N.jsx)(m,{className:`h-3 w-3`})})]})]},t.id)),(0,N.jsxs)(`form`,{className:`flex min-w-0 max-w-full items-center gap-1`,onSubmit:e=>{e.preventDefault(),le()},children:[(0,N.jsx)(`input`,{type:`text`,value:H,disabled:W,onChange:e=>U(e.target.value),placeholder:e(`calendar.newCalendarPlaceholder`),"aria-label":e(`calendar.newCalendarPlaceholder`),className:`min-w-0 w-36 rounded-full border border-dashed border-black/[0.12] bg-transparent px-2.5 py-1 text-base text-gray-700 placeholder:text-gray-400 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:ring-offset-canvas dark:border-white/[0.16] dark:text-dark-800 sm:text-xs`,"data-testid":`calendar-new-calendar`}),(0,N.jsx)(_,{type:`submit`,size:`sm`,variant:`ghost`,disabled:!H.trim(),loading:W,className:`h-7 shrink-0 px-2 text-xs`,"data-testid":`calendar-create-calendar`,children:e(`common.save`)})]}),(0,N.jsxs)(`div`,{className:`ms-auto flex items-center gap-1`,children:[(0,N.jsx)(`input`,{ref:Y,type:`file`,accept:`.ics,text/calendar`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&de(t),e.target.value=``}}),(0,N.jsxs)(_,{size:`sm`,variant:`ghost`,onClick:()=>Y.current?.click(),className:`h-7 gap-1 px-2 text-[12px]`,"data-testid":`calendar-import`,children:[(0,N.jsx)(h,{className:`h-3.5 w-3.5`}),e(`calendar.importIcs`)]}),(0,N.jsxs)(_,{size:`sm`,variant:`ghost`,onClick:()=>void ue(),className:`h-7 gap-1 px-2 text-[12px]`,"data-testid":`calendar-export`,children:[(0,N.jsx)(l,{className:`h-3.5 w-3.5`}),e(`calendar.exportIcs`)]})]})]}),r===`month`?(0,N.jsx)(L,{year:g.getFullYear(),monthIndex:g.getMonth(),events:re,onDayClick:e=>$(e),onEventClick:ae}):(0,N.jsx)(ee,{anchor:g,events:re,dayCount:r===`day`?1:7,onDayClick:(e,t)=>$(e,t),onEventClick:ae}),q&&(0,N.jsx)(b,{resourceType:`calendar`,resourceId:q.id,resourceLabel:q.name,onClose:()=>J(null)}),(0,N.jsx)(te,{open:O,event:j,initialStartAt:F,calendars:B.filter(e=>!e.shared||e.shared.permission===`write`),saving:R,onClose:()=>k(!1),onSave:e=>void oe(e),onDelete:()=>void se()})]})};export{K as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-vendor-CR5VJ85Q.js";import{i as r}from"./router-vendor-DqMnEJWK.js";import{t as i}from"./logger-BR4forr_.js";import{t as a}from"./chatStore-DpVxt9VX.js";import{t as o}from"./useTranslation-Boi0fB1B.js";import{i as s,t as c}from"./utils-B-Bhh1pF.js";import{Dt as l,Ft as u,H as d,Lt as f,Nn as p,Qn as ee,Sn as te,Tr as m,W as h,Xt as g,Yn as _,Zn as v,cr as ne,et as y,gr as re,it as b,kt as ie,lt as ae,n as x,ot as S,r as C,s as oe,v as w}from"./ui-vendor-DVTj_sKN.js";import{t as T}from"./Button-j68Q8KVh.js";import{D as E}from"./api-BrHW-VGd.js";import{t as se}from"./authStore-DjAsRpNL.js";import{i as D,n as O,r as k}from"./ui-Aq8MP7Ph.js";import{t as ce}from"./teamEventStream-DsAS6P4m.js";var A=e(t(),1),j=n(),le=[`👍`,`🎉`,`❤️`,`😄`,`👀`,`🚀`],ue=180,M=({calls:e})=>{let{t}=o(),[n,r]=(0,A.useState)(!1),i=e.some(e=>e.status===`denied`);return(0,j.jsxs)(`div`,{className:`mt-1`,"data-testid":`channel-tool-calls`,children:[(0,j.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),"aria-expanded":n,className:`flex items-center gap-1 text-[11px] font-medium text-gray-500 hover:text-gray-700 dark:text-dark-600 dark:hover:text-dark-800`,"data-testid":`channel-tool-calls-toggle`,children:[n?(0,j.jsx)(v,{className:`h-3 w-3`}):(0,j.jsx)(_,{className:`h-3 w-3`}),(0,j.jsx)(C,{className:`h-3 w-3`}),t(`channels.toolCalls.summary`,{total:e.length})]}),n&&(0,j.jsxs)(`div`,{className:`mt-1 space-y-1`,children:[e.map(e=>(0,j.jsxs)(`div`,{className:`rounded-lg border border-black/[0.06] px-2 py-1 dark:border-white/[0.08]`,"data-testid":`channel-tool-call`,children:[(0,j.jsxs)(`div`,{className:`flex items-baseline gap-1.5`,children:[(0,j.jsx)(`span`,{dir:`ltr`,className:`min-w-0 truncate text-[11px] font-medium text-gray-700 dark:text-dark-800`,children:e.name}),(0,j.jsx)(`span`,{className:c(`shrink-0 text-[10px]`,e.status===`succeeded`?`text-emerald-600 dark:text-emerald-400`:e.status===`denied`?`text-amber-600 dark:text-amber-400`:e.status===`failed`?`text-red-500`:`text-gray-400 dark:text-dark-500`),children:t(`tools.callStatus.${e.status}`)})]}),e.resultPreview&&(0,j.jsx)(`p`,{dir:`ltr`,className:`mt-0.5 whitespace-pre-wrap break-words font-mono text-[10px] leading-snug text-gray-500 dark:text-dark-600`,children:e.resultPreview.slice(0,ue)})]},e.id)),i&&(0,j.jsx)(`p`,{className:`text-[10px] text-gray-400 dark:text-dark-500`,children:t(`channels.toolCalls.deniedHint`)})]})]})},N=({message:e,currentUserId:t,canModerate:n,actions:r,compact:i=!1})=>{let{t:a,i18n:u}=o(),[d,p]=(0,A.useState)(!1),[m,h]=(0,A.useState)(e.content),[g,_]=(0,A.useState)(!1),v=e.authorKind===`model`,y=!v&&e.author?.userId===t&&!e.deleted,re=v?e.model??a(`channels.modelAuthor`):e.author?.username??a(`channels.unknownAuthor`);return(0,j.jsxs)(`div`,{className:c(`group relative rounded-xl px-2.5 py-1.5 hover:bg-black/[0.025] dark:hover:bg-white/[0.03]`,i&&`px-2 py-1`),"data-testid":`channel-message`,children:[(0,j.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[v&&(0,j.jsx)(ne,{className:`h-3.5 w-3.5 shrink-0 self-center text-primary-500`}),(0,j.jsx)(`span`,{className:c(`shrink-0 text-[13px] font-semibold`,v?`text-primary-600 dark:text-primary-400`:`text-gray-900 dark:text-dark-900`),children:re}),(0,j.jsx)(`span`,{className:`shrink-0 text-[11px] text-gray-400 dark:text-dark-500`,children:s(e.createdAt,u.language)}),e.editedAt&&!e.deleted&&(0,j.jsx)(`span`,{className:`shrink-0 text-[10px] text-gray-400 dark:text-dark-500`,children:a(`channels.edited`)}),e.pinnedAt&&(0,j.jsx)(b,{className:`h-3 w-3 shrink-0 text-amber-500`})]}),e.deleted?(0,j.jsx)(`p`,{className:`text-[13px] italic text-gray-400 dark:text-dark-500`,children:a(`channels.deletedMessage`)}):d?(0,j.jsxs)(`div`,{className:`mt-1 flex items-end gap-1.5`,children:[(0,j.jsx)(`textarea`,{value:m,onChange:e=>h(e.target.value),rows:2,className:`min-w-0 flex-1 resize-none rounded-lg border border-black/[0.08] bg-transparent px-2 py-1 text-[13px] focus:outline-none dark:border-white/[0.1] dark:text-dark-900`,"data-testid":`channel-message-edit`}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>{r.onEdit(e,m),p(!1)},className:`rounded-md p-1.5 text-emerald-600 hover:bg-emerald-50 dark:hover:bg-emerald-900/20`,children:(0,j.jsx)(ee,{className:`h-3.5 w-3.5`})}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>p(!1),className:`rounded-md p-1.5 text-gray-400 hover:bg-black/[0.04] dark:hover:bg-white/[0.06]`,children:(0,j.jsx)(x,{className:`h-3.5 w-3.5`})})]}):(0,j.jsxs)(j.Fragment,{children:[e.pending?(0,j.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[13px] text-gray-400 dark:text-dark-500`,children:[(0,j.jsx)(f,{className:`h-3.5 w-3.5 animate-spin`}),a(`channels.modelThinking`)]}):e.error?(0,j.jsx)(`p`,{className:`text-[13px] text-red-500`,children:e.error}):(0,j.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-[13px] leading-relaxed text-gray-800 dark:text-dark-800`,children:e.content}),v&&(e.toolCalls?.length??0)>0&&(0,j.jsx)(M,{calls:e.toolCalls}),(e.attachments?.length??0)>0&&(0,j.jsx)(`div`,{className:`mt-1 space-y-1`,children:e.attachments.map(e=>(0,j.jsxs)(`button`,{type:`button`,onClick:()=>void r.onDownload(e.id,e.filename),className:`flex items-center gap-1.5 rounded-lg border border-black/[0.06] px-2 py-1 text-[12px] text-gray-600 hover:bg-black/[0.03] dark:border-white/[0.08] dark:text-dark-700 dark:hover:bg-white/[0.04]`,"data-testid":`channel-attachment`,children:[(0,j.jsx)(ae,{className:`h-3 w-3`}),(0,j.jsx)(`span`,{className:`min-w-0 truncate`,children:e.filename})]},e.id))})]}),(e.reactions?.length??0)>0&&(0,j.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:e.reactions.map(t=>(0,j.jsxs)(`button`,{type:`button`,onClick:()=>void r.onReact(e,t.emoji,t.mine),className:c(`rounded-full border px-1.5 py-0.5 text-[11px]`,t.mine?`border-primary-400/50 bg-primary-500/10 text-primary-600 dark:text-primary-400`:`border-black/[0.08] text-gray-600 hover:bg-black/[0.03] dark:border-white/[0.1] dark:text-dark-700`),"data-testid":`channel-reaction`,children:[t.emoji,` `,t.count]},t.emoji))}),!i&&(e.replyCount??0)>0&&r.onReply&&(0,j.jsxs)(`button`,{type:`button`,onClick:()=>r.onReply(e),className:`mt-1 flex items-center gap-1 text-[11px] font-medium text-primary-600 hover:underline dark:text-primary-400`,"data-testid":`channel-reply-count`,children:[(0,j.jsx)(l,{className:`h-3 w-3`}),a(`channels.replyCount`,{total:e.replyCount})]}),!e.deleted&&!d&&(0,j.jsxs)(`div`,{className:`absolute -top-2.5 right-2 hidden items-center gap-0.5 rounded-lg border border-black/[0.08] bg-white px-1 py-0.5 shadow-sm group-hover:flex dark:border-white/[0.1] dark:bg-dark-50`,children:[(0,j.jsxs)(`div`,{className:`relative`,children:[(0,j.jsx)(`button`,{type:`button`,onClick:()=>_(e=>!e),className:`rounded p-1 text-gray-400 hover:text-gray-700 dark:hover:text-dark-800`,title:a(`channels.react`),"data-testid":`channel-react`,children:(0,j.jsx)(te,{className:`h-3.5 w-3.5`})}),g&&(0,j.jsx)(`div`,{className:`absolute right-0 top-6 z-10 flex gap-0.5 rounded-lg border border-black/[0.08] bg-white p-1 shadow-md dark:border-white/[0.1] dark:bg-dark-50`,children:le.map(t=>(0,j.jsx)(`button`,{type:`button`,onClick:()=>{let n=!!e.reactions?.find(e=>e.emoji===t)?.mine;r.onReact(e,t,n),_(!1)},className:`rounded p-0.5 text-sm hover:bg-black/[0.05] dark:hover:bg-white/[0.08]`,children:t},t))})]}),r.onReply&&!e.parentId&&(0,j.jsx)(`button`,{type:`button`,onClick:()=>r.onReply(e),className:`rounded p-1 text-gray-400 hover:text-gray-700 dark:hover:text-dark-800`,title:a(`channels.reply`),"data-testid":`channel-reply`,children:(0,j.jsx)(l,{className:`h-3.5 w-3.5`})}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>void r.onPin(e),className:`rounded p-1 text-gray-400 hover:text-amber-500`,title:e.pinnedAt?a(`channels.unpin`):a(`channels.pin`),"data-testid":`channel-pin`,children:(0,j.jsx)(b,{className:`h-3.5 w-3.5`})}),y&&(0,j.jsx)(`button`,{type:`button`,onClick:()=>{h(e.content),p(!0)},className:`rounded p-1 text-gray-400 hover:text-gray-700 dark:hover:text-dark-800`,title:a(`channels.edit`),"data-testid":`channel-edit`,children:(0,j.jsx)(S,{className:`h-3.5 w-3.5`})}),(y||n)&&(0,j.jsx)(`button`,{type:`button`,onClick:()=>void r.onDelete(e),className:`rounded p-1 text-gray-400 hover:text-red-500`,title:a(`channels.deleteMessage`),"data-testid":`channel-delete-message`,children:(0,j.jsx)(w,{className:`h-3.5 w-3.5`})})]})]})},P=i(`pages:channels`),de=e=>e.type===`dm`?(0,j.jsx)(ie,{className:`h-3.5 w-3.5 shrink-0`}):e.type===`private`?(0,j.jsx)(u,{className:`h-3.5 w-3.5 shrink-0`}):(0,j.jsx)(g,{className:`h-3.5 w-3.5 shrink-0`}),fe=e=>e.type===`dm`?e.dmPeer?.username??`…`:e.name,F=()=>{let{t:e}=o(),t=se(e=>e.user),n=a(e=>e.models),[i,s]=(0,A.useState)([]),[u,ee]=(0,A.useState)(null),[te,g]=(0,A.useState)(!1),[_,v]=(0,A.useState)(!0),[S,C]=(0,A.useState)(null),[w,D]=(0,A.useState)(null),[O,k]=(0,A.useState)([]),[le,ue]=(0,A.useState)([]),[M,F]=(0,A.useState)(null),[I,_e]=(0,A.useState)(null),[ve,L]=(0,A.useState)([]),[R,z]=(0,A.useState)(``),[B,ye]=(0,A.useState)(``),[V,be]=(0,A.useState)(!1),[H,xe]=(0,A.useState)(null),[Se,Ce]=(0,A.useState)(!1),[we,U]=(0,A.useState)(!1),[W,Te]=(0,A.useState)(``),[Ee,G]=(0,A.useState)(!1),De=(0,A.useRef)(null),Oe=(0,A.useRef)(null),[ke,Ae]=r(),K=(0,A.useMemo)(()=>i.find(e=>e.id===S)??null,[i,S]),[je,Me]=(0,A.useState)(null);S!==je&&(Me(S),D(null),_e(null),F(null));let q=K?.role===`owner`,J=(0,A.useCallback)(()=>{E.listMine().then(e=>{e.success&&e.data&&s(e.data)}).catch(e=>P.error(`Failed to load channels:`,e)).finally(()=>v(!1))},[]);(0,A.useEffect)(()=>{J();let e=window.setInterval(J,3e4);return()=>window.clearInterval(e)},[J]);let Y=ke.get(`channel`);Y&&S!==Y&&C(Y),(0,A.useEffect)(()=>{Y&&Ae({},{replace:!0})},[Y,Ae]);let X=(0,A.useRef)(null);(0,A.useLayoutEffect)(()=>(X.current=S?{channelId:S,requestId:0}:null,()=>{X.current=null}),[S]);let Z=(0,A.useCallback)(e=>{let t=X.current;if(!t||t.channelId!==e)return;let n=++t.requestId;E.listMessages(e,{limit:100}).then(e=>{X.current===t&&t.requestId===n&&e.success&&e.data&&D(e.data)}).catch(e=>P.error(`Failed to load messages:`,e))},[]),Ne=(0,A.useRef)(null);(0,A.useEffect)(()=>{Ne.current=I},[I]);let Pe=(0,A.useCallback)(e=>{Z(e),E.markRead(e);let t=Ne.current;t&&E.thread(t).then(e=>{e.success&&e.data&&L(e.data)})},[Z]);(0,A.useEffect)(()=>{if(!S)return;Z(S),E.markRead(S).then(J);let e=new AbortController;return ce({path:`/channels/${S}/events`,signal:e.signal,onEvent:()=>Pe(S)}),()=>e.abort()},[S,Z,J,Pe]);let Fe=w?.length??0;(0,A.useEffect)(()=>{let e=Oe.current;e&&(e.scrollTop=e.scrollHeight)},[Fe,S]),(0,A.useEffect)(()=>{S&&M&&(M===`members`?E.listMembers(S).then(e=>{e.success&&e.data&&k(e.data)}):E.listPins(S).then(e=>{e.success&&e.data&&ue(e.data)}))},[S,M]),(0,A.useEffect)(()=>{I&&E.thread(I).then(e=>{e.success&&e.data&&L(e.data)})},[I]);let Ie=()=>{g(!0),E.listPublic().then(e=>{e.success&&e.data&&ee(e.data)})},Q=async t=>{if(!S||V)return;let n=R.trim();if(n||H){be(!0);try{let r=await E.postMessage(S,{content:n,...t?{parentId:t}:{},...H?{attachmentIds:[H.id]}:{},...B?{mentionModel:B}:{}});if(r.success){if(z(``),xe(null),ye(``),Z(S),t){let e=await E.thread(t);e.success&&e.data&&L(e.data)}}else m.error(r.error||e(`channels.sendFailed`))}catch(t){P.error(`Failed to send message:`,t),m.error(e(`channels.sendFailed`))}finally{be(!1)}}},Le=async t=>{if(S)try{let n=await E.uploadAttachment(S,t);n.success&&n.data?xe({id:n.data.id,filename:n.data.filename}):m.error(n.error||e(`channels.uploadFailed`))}catch(t){P.error(`Failed to upload attachment:`,t),m.error(e(`channels.uploadFailed`))}},Re=async()=>{if(S&&W.trim()){if((await E.addMember(S,W.trim()).catch(()=>void 0))?.success){Te(``);let t=await E.listMembers(S);t.success&&t.data&&k(t.data),m.success(e(`channels.memberAdded`))}else m.error(e(`channels.memberAddFailed`))}},ze={onReply:e=>_e(e.id),onEdit:async(e,t)=>{(await E.editMessage(e.id,t).catch(()=>void 0))?.success&&S&&Z(S)},onDelete:async e=>{(await E.deleteMessage(e.id).catch(()=>void 0))?.success&&S&&Z(S)},onPin:async e=>{await E.setPinned(e.id,!e.pinnedAt).catch(()=>void 0),S&&Z(S)},onReact:async(e,t,n)=>{n?await E.removeReaction(e.id,t).catch(()=>void 0):await E.addReaction(e.id,t).catch(()=>void 0),S&&Z(S)},onDownload:async(e,t)=>{try{let n=await E.downloadAttachment(e),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=t,i.click(),URL.revokeObjectURL(r)}catch(e){P.error(`Failed to download attachment:`,e)}}},$=ve[0];return(0,j.jsxs)(`div`,{className:`flex h-full min-h-0`,children:[(0,j.jsxs)(`aside`,{className:c(`flex w-64 shrink-0 flex-col border-r border-black/[0.06] dark:border-white/[0.06]`,S?`hidden md:flex`:`flex`),"data-testid":`channel-rail`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-1 px-3 py-2.5`,children:[(0,j.jsx)(`h1`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-gray-900 dark:text-dark-900`,children:e(`channels.title`)}),(0,j.jsx)(`button`,{type:`button`,onClick:Ie,title:e(`channels.browsePublic`),className:`rounded-md p-1.5 text-gray-500 hover:bg-black/[0.04] dark:text-dark-600 dark:hover:bg-white/[0.06]`,"data-testid":`channels-browse`,children:(0,j.jsx)(p,{className:`h-4 w-4`})}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>U(!0),title:e(`channels.newDm`),className:`rounded-md p-1.5 text-gray-500 hover:bg-black/[0.04] dark:text-dark-600 dark:hover:bg-white/[0.06]`,"data-testid":`channels-new-dm`,children:(0,j.jsx)(ie,{className:`h-4 w-4`})}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>Ce(!0),title:e(`channels.newChannel`),className:`rounded-md p-1.5 text-gray-500 hover:bg-black/[0.04] dark:text-dark-600 dark:hover:bg-white/[0.06]`,"data-testid":`channels-new`,children:(0,j.jsx)(y,{className:`h-4 w-4`})})]}),(0,j.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-2 pb-3 scrollbar-thin`,children:_?(0,j.jsx)(f,{className:`mx-auto mt-6 h-4 w-4 animate-spin text-gray-400`}):i.length===0?(0,j.jsx)(`p`,{className:`px-2 pt-6 text-center text-xs text-gray-400 dark:text-dark-500`,children:e(`channels.empty`)}):i.map(e=>(0,j.jsxs)(`button`,{type:`button`,onClick:()=>C(e.id),className:c(`flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-[13px]`,S===e.id?`bg-black/[0.05] text-gray-900 dark:bg-white/[0.08] dark:text-dark-900`:`text-gray-600 hover:bg-black/[0.03] dark:text-dark-700 dark:hover:bg-white/[0.04]`),"data-testid":`channel-item`,children:[de(e),(0,j.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:fe(e)}),(e.unreadCount??0)>0&&(0,j.jsx)(`span`,{className:`rounded-full bg-primary-500 px-1.5 text-[10px] font-semibold leading-4 text-white`,"data-testid":`channel-unread`,children:e.unreadCount})]},e.id))})]}),(0,j.jsx)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:K?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-black/[0.06] px-4 py-2.5 dark:border-white/[0.06]`,children:[(0,j.jsx)(`button`,{type:`button`,onClick:()=>C(null),className:`rounded-md p-1 text-gray-500 hover:bg-black/[0.04] md:hidden dark:text-dark-600`,children:(0,j.jsx)(re,{className:`h-4 w-4`})}),de(K),(0,j.jsx)(`h2`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-gray-900 dark:text-dark-900`,"data-testid":`channel-title`,children:fe(K)}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>F(M===`pins`?null:`pins`),title:e(`channels.pins`),className:`rounded-md p-1.5 text-gray-500 hover:bg-black/[0.04] dark:text-dark-600 dark:hover:bg-white/[0.06]`,"data-testid":`channel-pins-toggle`,children:(0,j.jsx)(b,{className:`h-4 w-4`})}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>F(M===`members`?null:`members`),title:e(`channels.members`),className:`rounded-md p-1.5 text-gray-500 hover:bg-black/[0.04] dark:text-dark-600 dark:hover:bg-white/[0.06]`,"data-testid":`channel-members-toggle`,children:(0,j.jsx)(oe,{className:`h-4 w-4`})}),q&&K.type!==`dm`&&(0,j.jsx)(`button`,{type:`button`,onClick:()=>G(!0),title:e(`channels.settings`),className:`rounded-md p-1.5 text-gray-500 hover:bg-black/[0.04] dark:text-dark-600 dark:hover:bg-white/[0.06]`,"data-testid":`channel-settings`,children:(0,j.jsx)(d,{className:`h-4 w-4`})})]}),(0,j.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,j.jsx)(`div`,{ref:Oe,className:`min-h-0 flex-1 space-y-1 overflow-y-auto px-4 py-3 scrollbar-thin`,"data-testid":`channel-timeline`,children:w===null?(0,j.jsx)(f,{className:`mx-auto mt-6 h-4 w-4 animate-spin text-gray-400`}):w.length===0?(0,j.jsx)(`p`,{className:`pt-8 text-center text-xs text-gray-400 dark:text-dark-500`,children:e(`channels.noMessages`)}):w.map(e=>(0,j.jsx)(N,{message:e,currentUserId:t?.id,canModerate:q,actions:ze},e.id))}),(0,j.jsxs)(`div`,{className:`border-t border-black/[0.06] p-3 dark:border-white/[0.06]`,children:[H&&(0,j.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 rounded-lg border border-black/[0.06] px-2.5 py-1.5 text-xs text-gray-600 dark:border-white/[0.08] dark:text-dark-700`,children:[(0,j.jsx)(ae,{className:`h-3.5 w-3.5`}),(0,j.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:H.filename}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>xe(null),className:`text-gray-400 hover:text-red-500`,children:(0,j.jsx)(x,{className:`h-3.5 w-3.5`})})]}),(0,j.jsxs)(`div`,{className:`flex items-end gap-1.5`,children:[(0,j.jsx)(`input`,{ref:De,type:`file`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&Le(t),e.target.value=``}}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>De.current?.click(),title:e(`channels.attach`),className:`rounded-md p-2 text-gray-500 hover:bg-black/[0.04] dark:text-dark-600 dark:hover:bg-white/[0.06]`,"data-testid":`channel-attach`,children:(0,j.jsx)(ae,{className:`h-4 w-4`})}),(0,j.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,j.jsx)(ne,{className:c(`h-4 w-4`,B?`text-primary-500`:`text-gray-400 dark:text-dark-500`)}),(0,j.jsxs)(`select`,{value:B,onChange:e=>ye(e.target.value),className:`max-w-[130px] rounded-md border border-black/[0.08] bg-transparent px-1 py-1 text-[11px] text-gray-600 focus:outline-none dark:border-white/[0.1] dark:bg-dark-100 dark:text-dark-700`,title:e(`channels.askModel`),"data-testid":`channel-mention-model`,children:[(0,j.jsx)(`option`,{value:``,children:e(`channels.noModel`)}),n.map(e=>(0,j.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),(0,j.jsx)(`textarea`,{value:R,onChange:e=>z(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Q())},rows:1,placeholder:e(`channels.composerPlaceholder`),className:`max-h-32 min-w-0 flex-1 resize-none rounded-xl border border-black/[0.08] bg-transparent px-3 py-2 text-[13px] text-gray-900 placeholder:text-gray-400 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.1] dark:text-dark-900`,"data-testid":`channel-composer`}),(0,j.jsx)(T,{size:`sm`,disabled:V||!R.trim()&&!H,onClick:()=>void Q(),"data-testid":`channel-send`,children:V?(0,j.jsx)(f,{className:`h-4 w-4 animate-spin`}):(0,j.jsx)(h,{className:`h-4 w-4`})})]})]})]}),I&&(0,j.jsxs)(`aside`,{className:`flex w-80 shrink-0 flex-col border-l border-black/[0.06] dark:border-white/[0.06]`,"data-testid":`channel-thread`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-black/[0.06] px-3 py-2 dark:border-white/[0.06]`,children:[(0,j.jsx)(`span`,{className:`flex-1 text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-dark-600`,children:e(`channels.thread`)}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>_e(null),className:`rounded-md p-1 text-gray-400 hover:bg-black/[0.04] dark:hover:bg-white/[0.06]`,children:(0,j.jsx)(x,{className:`h-3.5 w-3.5`})})]}),(0,j.jsx)(`div`,{className:`min-h-0 flex-1 space-y-1 overflow-y-auto px-3 py-2 scrollbar-thin`,children:ve.map(e=>(0,j.jsx)(N,{message:e,currentUserId:t?.id,canModerate:q,actions:{...ze,onReply:void 0},compact:!0},e.id))}),(0,j.jsxs)(`div`,{className:`flex items-end gap-1.5 border-t border-black/[0.06] p-2 dark:border-white/[0.06]`,children:[(0,j.jsx)(`textarea`,{value:R,onChange:e=>z(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),$&&Q($.id))},rows:1,placeholder:e(`channels.replyPlaceholder`),className:`min-w-0 flex-1 resize-none rounded-lg border border-black/[0.08] bg-transparent px-2.5 py-1.5 text-[13px] text-gray-900 focus:outline-none dark:border-white/[0.1] dark:text-dark-900`,"data-testid":`channel-thread-composer`}),(0,j.jsx)(T,{size:`sm`,disabled:V||!R.trim(),onClick:()=>$&&void Q($.id),children:(0,j.jsx)(h,{className:`h-3.5 w-3.5`})})]})]}),M&&(0,j.jsxs)(`aside`,{className:`flex w-72 shrink-0 flex-col border-l border-black/[0.06] dark:border-white/[0.06]`,"data-testid":`channel-${M}-panel`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-black/[0.06] px-3 py-2 dark:border-white/[0.06]`,children:[(0,j.jsx)(`span`,{className:`flex-1 text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-dark-600`,children:e(M===`members`?`channels.members`:`channels.pins`)}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>F(null),className:`rounded-md p-1 text-gray-400 hover:bg-black/[0.04] dark:hover:bg-white/[0.06]`,children:(0,j.jsx)(x,{className:`h-3.5 w-3.5`})})]}),(0,j.jsx)(`div`,{className:`min-h-0 flex-1 space-y-1.5 overflow-y-auto px-3 py-2 scrollbar-thin`,children:M===`members`?(0,j.jsxs)(j.Fragment,{children:[q&&K.type===`private`&&(0,j.jsxs)(`div`,{className:`mb-2 flex gap-1.5`,children:[(0,j.jsx)(`input`,{type:`text`,value:W,onChange:e=>Te(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Re()},placeholder:e(`channels.invitePlaceholder`),className:`min-w-0 flex-1 rounded-lg border border-black/[0.08] bg-transparent px-2 py-1 text-xs focus:outline-none dark:border-white/[0.1] dark:text-dark-800`,"data-testid":`channel-invite-name`}),(0,j.jsx)(T,{size:`sm`,disabled:!W.trim(),onClick:()=>void Re(),"data-testid":`channel-invite-submit`,children:(0,j.jsx)(y,{className:`h-3.5 w-3.5`})})]}),O.map(n=>(0,j.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg px-2 py-1.5 text-[13px] text-gray-700 dark:text-dark-800`,"data-testid":`channel-member`,children:[(0,j.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n.username}),(0,j.jsx)(`span`,{className:`text-[10px] uppercase text-gray-400 dark:text-dark-500`,children:n.role===`owner`?e(`channels.roleOwner`):``}),q&&n.userId!==t?.id&&K.type!==`dm`&&(0,j.jsx)(`button`,{type:`button`,onClick:()=>void E.removeMember(K.id,n.userId).then(()=>k(e=>e.filter(e=>e.userId!==n.userId))),className:`rounded p-0.5 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,title:e(`channels.removeMember`),children:(0,j.jsx)(x,{className:`h-3 w-3`})})]},n.userId)),!q&&K.type!==`dm`&&(0,j.jsx)(T,{size:`sm`,variant:`ghost`,className:`mt-2 w-full text-red-500`,onClick:()=>void E.removeMember(K.id,t?.id??``).then(()=>{C(null),J()}),"data-testid":`channel-leave`,children:e(`channels.leave`)})]}):le.length===0?(0,j.jsx)(`p`,{className:`pt-4 text-center text-xs text-gray-400 dark:text-dark-500`,children:e(`channels.noPins`)}):le.map(e=>(0,j.jsx)(N,{message:e,currentUserId:t?.id,canModerate:q,actions:ze,compact:!0},e.id))})]})]})]}):(0,j.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-2 text-gray-400 dark:text-dark-500`,children:[(0,j.jsx)(l,{className:`h-8 w-8`}),(0,j.jsx)(`p`,{className:`text-sm`,children:e(`channels.selectPrompt`)})]})}),Se&&(0,j.jsx)(pe,{onClose:()=>Ce(!1),onCreated:e=>{Ce(!1),J(),C(e.id)}}),we&&(0,j.jsx)(me,{onClose:()=>U(!1),onOpened:e=>{U(!1),J(),C(e.id)}}),te&&(0,j.jsx)(he,{channels:u,onClose:()=>g(!1),onJoined:e=>{g(!1),J(),C(e)}}),Ee&&K&&(0,j.jsx)(ge,{channel:K,onClose:()=>G(!1),onChanged:()=>{G(!1),J()},onDeleted:()=>{G(!1),C(null),J()}})]})},pe=({onClose:e,onCreated:t})=>{let{t:n}=o(),[r,i]=(0,A.useState)(``),[a,s]=(0,A.useState)(`public`),[c,l]=(0,A.useState)(``),[u,d]=(0,A.useState)(!1);return(0,j.jsxs)(O,{titleId:`create-channel-title`,title:n(`channels.newChannel`),onClose:e,testId:`create-channel-modal`,footer:(0,j.jsx)(T,{size:`sm`,disabled:u||!r.trim(),onClick:()=>{d(!0),E.create({type:a,name:r.trim(),...c.trim()?{description:c.trim()}:{}}).then(e=>{e.success&&e.data?t(e.data):m.error(e.error||n(`channels.createFailed`))}).catch(()=>m.error(n(`channels.createFailed`))).finally(()=>d(!1))},"data-testid":`create-channel-submit`,children:n(`channels.create`)}),children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{className:D,children:n(`channels.nameLabel`)}),(0,j.jsx)(`input`,{className:k,value:r,onChange:e=>i(e.target.value),"data-testid":`create-channel-name`})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{className:D,children:n(`channels.typeLabel`)}),(0,j.jsxs)(`select`,{className:k,value:a,onChange:e=>s(e.target.value),"data-testid":`create-channel-type`,children:[(0,j.jsx)(`option`,{value:`public`,children:n(`channels.typePublic`)}),(0,j.jsx)(`option`,{value:`private`,children:n(`channels.typePrivate`)})]})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{className:D,children:n(`channels.descriptionLabel`)}),(0,j.jsx)(`textarea`,{className:k,rows:2,value:c,onChange:e=>l(e.target.value)})]})]})},me=({onClose:e,onOpened:t})=>{let{t:n}=o(),[r,i]=(0,A.useState)(``),[a,s]=(0,A.useState)(!1),c=()=>{r.trim()&&(s(!0),E.openDm(r.trim()).then(e=>{e.success&&e.data?t(e.data):m.error(e.error||n(`channels.dmFailed`))}).catch(()=>m.error(n(`channels.dmFailed`))).finally(()=>s(!1)))};return(0,j.jsx)(O,{titleId:`open-dm-title`,title:n(`channels.newDm`),subtitle:n(`channels.dmHint`),onClose:e,testId:`open-dm-modal`,footer:(0,j.jsx)(T,{size:`sm`,disabled:a||!r.trim(),onClick:c,"data-testid":`open-dm-submit`,children:n(`channels.openDm`)}),children:(0,j.jsx)(`input`,{className:k,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&c()},placeholder:n(`channels.dmPlaceholder`),"data-testid":`open-dm-username`})})},he=({channels:e,onClose:t,onJoined:n})=>{let{t:r}=o();return(0,j.jsx)(O,{titleId:`browse-channels-title`,title:r(`channels.browsePublic`),onClose:t,testId:`browse-channels-modal`,children:e===null?(0,j.jsx)(f,{className:`mx-auto h-4 w-4 animate-spin text-gray-400`}):e.length===0?(0,j.jsx)(`p`,{className:`text-center text-xs text-gray-400 dark:text-dark-500`,children:r(`channels.noPublic`)}):e.map(e=>(0,j.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-black/[0.06] px-3 py-2 dark:border-white/[0.08]`,"data-testid":`browse-channel-item`,children:[(0,j.jsx)(g,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}),(0,j.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] text-gray-800 dark:text-dark-800`,children:e.name}),e.isMember?(0,j.jsx)(`span`,{className:`text-[11px] text-gray-400`,children:r(`channels.joined`)}):(0,j.jsx)(T,{size:`sm`,onClick:()=>void E.join(e.id).then(()=>n(e.id)),"data-testid":`browse-channel-join`,children:r(`channels.join`)})]},e.id))})},ge=({channel:e,onClose:t,onChanged:n,onDeleted:r})=>{let{t:i}=o(),[a,s]=(0,A.useState)(e.name),[c,l]=(0,A.useState)(e.description??``),[u,d]=(0,A.useState)(!1);return(0,j.jsxs)(O,{titleId:`channel-settings-title`,title:i(`channels.settings`),onClose:t,testId:`channel-settings-modal`,footer:(0,j.jsxs)(`div`,{className:`flex w-full items-center justify-between`,children:[(0,j.jsx)(T,{size:`sm`,variant:`ghost`,className:`text-red-500`,onClick:()=>void E.delete(e.id).then(e=>{e.success&&r()}),"data-testid":`channel-delete`,children:i(`channels.delete`)}),(0,j.jsx)(T,{size:`sm`,disabled:u||!a.trim(),onClick:()=>{d(!0),E.update(e.id,{name:a.trim(),description:c.trim()}).then(e=>{e.success&&n()}).finally(()=>d(!1))},"data-testid":`channel-settings-save`,children:i(`channels.save`)})]}),children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{className:D,children:i(`channels.nameLabel`)}),(0,j.jsx)(`input`,{className:k,value:a,onChange:e=>s(e.target.value)})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{className:D,children:i(`channels.descriptionLabel`)}),(0,j.jsx)(`textarea`,{className:k,rows:2,value:c,onChange:e=>l(e.target.value)})]})]})};export{F as default};
|