libre-webui 0.37.2 → 0.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -65
- package/backend/dist/db.js +1 -1
- package/backend/dist/index.d.ts.map +1 -1
- package/backend/dist/index.js +13 -36
- package/backend/dist/index.js.map +1 -1
- package/backend/dist/main.js +0 -12
- package/backend/dist/main.js.map +1 -1
- package/backend/dist/middleware/cors.d.ts.map +1 -1
- package/backend/dist/middleware/cors.js +5 -0
- package/backend/dist/middleware/cors.js.map +1 -1
- package/backend/dist/persistence/postgresExtensionRepositories.d.ts.map +1 -1
- package/backend/dist/persistence/postgresExtensionRepositories.js +2 -4
- package/backend/dist/persistence/postgresExtensionRepositories.js.map +1 -1
- package/backend/dist/persistence/postgresMigrationRegistry.d.ts.map +1 -1
- package/backend/dist/persistence/postgresMigrationRegistry.js +2 -0
- package/backend/dist/persistence/postgresMigrationRegistry.js.map +1 -1
- package/backend/dist/persistence/postgresWorkRunThinkMigration.d.ts +9 -0
- package/backend/dist/persistence/postgresWorkRunThinkMigration.d.ts.map +1 -0
- package/backend/dist/persistence/postgresWorkRunThinkMigration.js +39 -0
- package/backend/dist/persistence/postgresWorkRunThinkMigration.js.map +1 -0
- package/backend/dist/persistence/sqliteExtensionRepositories.d.ts.map +1 -1
- package/backend/dist/persistence/sqliteExtensionRepositories.js +2 -4
- package/backend/dist/persistence/sqliteExtensionRepositories.js.map +1 -1
- package/backend/dist/persistence/sqliteMigrations.d.ts.map +1 -1
- package/backend/dist/persistence/sqliteMigrations.js +20 -0
- package/backend/dist/persistence/sqliteMigrations.js.map +1 -1
- package/backend/dist/persistence/sqliteToPostgresMigration.d.ts.map +1 -1
- package/backend/dist/persistence/sqliteToPostgresMigration.js +1 -0
- package/backend/dist/persistence/sqliteToPostgresMigration.js.map +1 -1
- package/backend/dist/platform/workPersistence/postgresWorkPersistence.d.ts.map +1 -1
- package/backend/dist/platform/workPersistence/postgresWorkPersistence.js +3 -2
- package/backend/dist/platform/workPersistence/postgresWorkPersistence.js.map +1 -1
- package/backend/dist/platform/workPersistence/sqliteWorkPersistence.d.ts.map +1 -1
- package/backend/dist/platform/workPersistence/sqliteWorkPersistence.js +3 -3
- package/backend/dist/platform/workPersistence/sqliteWorkPersistence.js.map +1 -1
- package/backend/dist/platform/workPersistence/types.d.ts +5 -0
- package/backend/dist/platform/workPersistence/types.d.ts.map +1 -1
- package/backend/dist/platform/workPersistence/types.js.map +1 -1
- package/backend/dist/routes/agentCli.d.ts.map +1 -1
- package/backend/dist/routes/agentCli.js +8 -3
- package/backend/dist/routes/agentCli.js.map +1 -1
- package/backend/dist/routes/{cordis.d.ts → strands.d.ts} +1 -1
- package/backend/dist/routes/strands.d.ts.map +1 -0
- package/backend/dist/routes/strands.js +300 -0
- package/backend/dist/routes/strands.js.map +1 -0
- package/backend/dist/routes/work.d.ts.map +1 -1
- package/backend/dist/routes/work.js +26 -23
- package/backend/dist/routes/work.js.map +1 -1
- package/backend/dist/services/agentAccessService.d.ts +0 -5
- package/backend/dist/services/agentAccessService.d.ts.map +1 -1
- package/backend/dist/services/agentAccessService.js +7 -35
- package/backend/dist/services/agentAccessService.js.map +1 -1
- package/backend/dist/services/agentCliService.d.ts +16 -23
- package/backend/dist/services/agentCliService.d.ts.map +1 -1
- package/backend/dist/services/agentCliService.js +85 -112
- package/backend/dist/services/agentCliService.js.map +1 -1
- package/backend/dist/services/authService.d.ts +3 -3
- package/backend/dist/services/authService.d.ts.map +1 -1
- package/backend/dist/services/authService.js +3 -4
- package/backend/dist/services/authService.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 +17 -8
- package/backend/dist/services/authorizationService.js.map +1 -1
- package/backend/dist/services/followUpService.d.ts +4 -1
- package/backend/dist/services/followUpService.d.ts.map +1 -1
- package/backend/dist/services/followUpService.js +23 -2
- package/backend/dist/services/followUpService.js.map +1 -1
- package/backend/dist/services/pluginService.d.ts.map +1 -1
- package/backend/dist/services/pluginService.js +10 -6
- package/backend/dist/services/pluginService.js.map +1 -1
- package/backend/dist/services/pluginUsageService.d.ts +0 -34
- package/backend/dist/services/pluginUsageService.d.ts.map +1 -1
- package/backend/dist/services/pluginUsageService.js +0 -62
- package/backend/dist/services/pluginUsageService.js.map +1 -1
- package/backend/dist/services/strandsAccessService.d.ts +26 -0
- package/backend/dist/services/strandsAccessService.d.ts.map +1 -0
- package/backend/dist/services/strandsAccessService.js +95 -0
- package/backend/dist/services/strandsAccessService.js.map +1 -0
- package/backend/dist/services/thinkingSummaryService.d.ts +2 -3
- package/backend/dist/services/thinkingSummaryService.d.ts.map +1 -1
- package/backend/dist/services/thinkingSummaryService.js +13 -27
- package/backend/dist/services/thinkingSummaryService.js.map +1 -1
- package/backend/dist/services/titleGenerationService.d.ts +7 -18
- package/backend/dist/services/titleGenerationService.d.ts.map +1 -1
- package/backend/dist/services/titleGenerationService.js +15 -36
- package/backend/dist/services/titleGenerationService.js.map +1 -1
- package/backend/dist/services/workAgentService.d.ts +1 -1
- package/backend/dist/services/workAgentService.d.ts.map +1 -1
- package/backend/dist/services/workAgentService.js +17 -60
- package/backend/dist/services/workAgentService.js.map +1 -1
- package/backend/dist/services/workModelProviderService.d.ts +1 -4
- package/backend/dist/services/workModelProviderService.d.ts.map +1 -1
- package/backend/dist/services/workModelProviderService.js +60 -50
- package/backend/dist/services/workModelProviderService.js.map +1 -1
- package/backend/dist/services/workTaskService.d.ts +3 -2
- package/backend/dist/services/workTaskService.d.ts.map +1 -1
- package/backend/dist/services/workTaskService.js +11 -7
- package/backend/dist/services/workTaskService.js.map +1 -1
- package/backend/dist/strands/catalog.d.ts +57 -0
- package/backend/dist/strands/catalog.d.ts.map +1 -0
- package/backend/dist/strands/catalog.js +241 -0
- package/backend/dist/strands/catalog.js.map +1 -0
- package/backend/dist/strands/engine.d.ts +131 -0
- package/backend/dist/strands/engine.d.ts.map +1 -0
- package/backend/dist/strands/engine.js +477 -0
- package/backend/dist/strands/engine.js.map +1 -0
- package/backend/dist/strands/harness.d.ts +14 -0
- package/backend/dist/strands/harness.d.ts.map +1 -0
- package/backend/dist/strands/harness.js +41 -0
- package/backend/dist/strands/harness.js.map +1 -0
- package/backend/dist/strands/model.d.ts +24 -0
- package/backend/dist/strands/model.d.ts.map +1 -0
- package/backend/dist/strands/model.js +381 -0
- package/backend/dist/strands/model.js.map +1 -0
- package/backend/dist/strands/runtime.d.ts +4 -0
- package/backend/dist/strands/runtime.d.ts.map +1 -0
- package/backend/dist/{cordis/work-model.js → strands/runtime.js} +16 -12
- package/backend/dist/strands/runtime.js.map +1 -0
- package/backend/dist/strands/sandbox.d.ts +24 -0
- package/backend/dist/strands/sandbox.d.ts.map +1 -0
- package/backend/dist/strands/sandbox.js +156 -0
- package/backend/dist/strands/sandbox.js.map +1 -0
- package/backend/dist/strands/work-driver.d.ts +11 -0
- package/backend/dist/strands/work-driver.d.ts.map +1 -0
- package/backend/dist/strands/work-driver.js +443 -0
- package/backend/dist/strands/work-driver.js.map +1 -0
- package/backend/dist/strands/work-model.d.ts +7 -0
- package/backend/dist/strands/work-model.d.ts.map +1 -0
- package/backend/dist/strands/work-model.js +42 -0
- package/backend/dist/strands/work-model.js.map +1 -0
- package/backend/dist/types/work.d.ts +7 -11
- package/backend/dist/types/work.d.ts.map +1 -1
- package/backend/dist/types/work.js.map +1 -1
- package/backend/dist/utils/bedrockMantle.d.ts +46 -0
- package/backend/dist/utils/bedrockMantle.d.ts.map +1 -0
- package/backend/dist/utils/bedrockMantle.js +206 -0
- package/backend/dist/utils/bedrockMantle.js.map +1 -0
- package/backend/dist/utils/corsOriginPolicy.d.ts +10 -0
- package/backend/dist/utils/corsOriginPolicy.d.ts.map +1 -0
- package/backend/dist/utils/corsOriginPolicy.js +70 -0
- package/backend/dist/utils/corsOriginPolicy.js.map +1 -0
- package/backend/dist/utils/pluginChatAdapter.d.ts +36 -0
- package/backend/dist/utils/pluginChatAdapter.d.ts.map +1 -1
- package/backend/dist/utils/pluginChatAdapter.js +122 -47
- package/backend/dist/utils/pluginChatAdapter.js.map +1 -1
- package/backend/dist/utils/pluginDefinitionTrust.d.ts.map +1 -1
- package/backend/dist/utils/pluginDefinitionTrust.js +3 -2
- package/backend/dist/utils/pluginDefinitionTrust.js.map +1 -1
- package/backend/dist/utils/pluginValidation.d.ts +1 -1
- package/backend/dist/utils/pluginValidation.d.ts.map +1 -1
- package/backend/dist/utils/pluginValidation.js +11 -0
- package/backend/dist/utils/pluginValidation.js.map +1 -1
- package/backend/package.json +6 -36
- package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
- package/frontend/dist/artifact-runtime/babel.js +170 -170
- 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/mathjs.js +1 -1
- package/frontend/dist/artifact-runtime/mermaid.js +1 -1
- package/frontend/dist/artifact-runtime/plotly.js +1 -1
- package/frontend/dist/artifact-runtime/react.js +3 -3
- package/frontend/dist/assets/index-D99DS5c6.js +57 -0
- package/frontend/dist/assets/index-Dz1JufgZ.css +1 -0
- package/frontend/dist/assets/{markdown-math-D1Bj3pDB.css → markdown-math-DzFXvcrH.css} +1 -1
- package/frontend/dist/index.html +34 -34
- package/frontend/dist/js/{ArtifactContainer-D4v4l15L.js → ArtifactContainer-Cn7X9HGm.js} +1 -1
- package/frontend/dist/js/{ArtifactDemoPage-B2uaVpsi.js → ArtifactDemoPage-Ddpy2O_v.js} +1 -1
- package/frontend/dist/js/{ArtifactSandboxFrame-DlWJHI-r.js → ArtifactSandboxFrame-CdsAqv8H.js} +1 -1
- package/frontend/dist/js/{ArtifactSlideOutPanel-laZ98QKB.js → ArtifactSlideOutPanel-cVd9X80o.js} +1 -1
- package/frontend/dist/js/AutomationModal-B4UaWjkk.js +1 -0
- package/frontend/dist/js/AutomationsPage-huCrvLUp.js +1 -0
- package/frontend/dist/js/{AvatarUpload-KaBaTKoG.js → AvatarUpload-CG-w6Mpt.js} +1 -1
- package/frontend/dist/js/{Button-CGMYia4g.js → Button-j68Q8KVh.js} +1 -1
- package/frontend/dist/js/{CalendarPage-Dc7r-86c.js → CalendarPage-CZXT1w99.js} +1 -1
- package/frontend/dist/js/ChannelsPage-DbtdHnSL.js +1 -0
- package/frontend/dist/js/ChatPage-BZE65kiq.js +14 -0
- package/frontend/dist/js/ConnectModels-DD4bLgdq.js +1 -0
- package/frontend/dist/js/{EvaluationsPage-BB7sPhIR.js → EvaluationsPage-Dq53LaXd.js} +2 -2
- package/frontend/dist/js/{FirstTimeSetup-elqSi9JH.js → FirstTimeSetup-BoJIfuQT.js} +1 -1
- package/frontend/dist/js/GalleryPage-DKwqeB2A.js +1 -0
- package/frontend/dist/js/HomePage-C8bCJfls.js +1 -0
- package/frontend/dist/js/LanguageSwitcher-B_YyU5JG.js +1 -0
- package/frontend/dist/js/{Logo-HZvdAk2c.js → Logo-DnfVtjgj.js} +1 -1
- package/frontend/dist/js/{LogoMark-GJnfMXsk.js → LogoMark-BzObGdA9.js} +1 -1
- package/frontend/dist/js/{ModelManagerModals-Bk6OQzJI.js → ModelManagerModals-BzjZ-QwL.js} +1 -1
- package/frontend/dist/js/NotesPage-CnaAp_w_.js +3 -0
- package/frontend/dist/js/{OptimizedSyntaxHighlighter-CzzV6ONG.js → OptimizedSyntaxHighlighter-B0g8cxZQ.js} +1 -1
- package/frontend/dist/js/OptimizedSyntaxHighlighter-B_BbHeO1.js +1 -0
- package/frontend/dist/js/{PasswordStrengthMeter-DasfJa4P.js → PasswordStrengthMeter-DI4RDv67.js} +1 -1
- package/frontend/dist/js/{PersonasPage-CIJINcQK.js → PersonasPage-CH3GUKph.js} +2 -2
- package/frontend/dist/js/PluginUsagePage-d54K2gAj.js +1 -0
- package/frontend/dist/js/{RichMessageContent-DxCHlUlY.js → RichMessageContent-BfYbVBFz.js} +2 -2
- package/frontend/dist/js/RichMessageContent-CDxxs3Tt.js +1 -0
- package/frontend/dist/js/SettingsModal-BvtJcvow.js +19 -0
- package/frontend/dist/js/{SettingsToggle-oxvw7ulA.js → SettingsToggle-DrJ0Bapi.js} +1 -1
- package/frontend/dist/js/{ShareDialog-Bhpt_Y1N.js → ShareDialog-DaSxkTKS.js} +1 -1
- package/frontend/dist/js/StrandsPage-BQwz0mWq.js +1 -0
- package/frontend/dist/js/{SystemPage-BfhVXqar.js → SystemPage-BqNZoFxR.js} +1 -1
- package/frontend/dist/js/{TurnstileWidget-CVepEMEQ.js → TurnstileWidget-tI50c7Kc.js} +1 -1
- package/frontend/dist/js/{UserManagementPage-2yHv89ZA.js → UserManagementPage-UvPjA9RP.js} +1 -1
- package/frontend/dist/js/UserManagementPanel-C3T1ReJJ.js +1 -0
- package/frontend/dist/js/{WhatsNewModal-Dl69bG2T.js → WhatsNewModal-CLcU2Ugk.js} +1 -1
- package/frontend/dist/js/WorkPage-BpjGn--1.js +8 -0
- package/frontend/dist/js/api-BrHW-VGd.js +14 -0
- package/frontend/dist/js/api-K_hhqPdx.js +1 -0
- package/frontend/dist/js/{appNavigation-R8iKverf.js → appNavigation-B6xYIgLi.js} +1 -1
- package/frontend/dist/js/appStore-DkRdQQeY.js +2 -0
- package/frontend/dist/js/appVersion-BVtSqLVj.js +1 -0
- package/frontend/dist/js/ar-XTZGEtBr.js +2 -0
- package/frontend/dist/js/authStore-DBS6Kbvh.js +1 -0
- package/frontend/dist/js/{authStore-D8fc-Hl0.js → authStore-DjAsRpNL.js} +3 -3
- package/frontend/dist/js/bn-JiK7ZWmy.js +2 -0
- package/frontend/dist/js/chatStore-DpVxt9VX.js +3 -0
- package/frontend/dist/js/{client-BeJbHHWx.js → client-DppLngAs.js} +2 -2
- package/frontend/dist/js/{config-D6Kcp5n3.js → config-4_s8hdqO.js} +1 -1
- package/frontend/dist/js/cs-D8ju18CO.js +2 -0
- package/frontend/dist/js/da-BJWcAoUc.js +2 -0
- package/frontend/dist/js/de-CLJLmy69.js +2 -0
- package/frontend/dist/js/es-BvqHEL-3.js +2 -0
- package/frontend/dist/js/{evaluationsApi-2YwZBPk5.js → evaluationsApi-DyuW7IJ_.js} +1 -1
- package/frontend/dist/js/fr-B8ZoZomI.js +2 -0
- package/frontend/dist/js/hi-AzJLALo-.js +2 -0
- package/frontend/dist/js/id-DZYGQhvC.js +2 -0
- package/frontend/dist/js/is-Da_kvtzW.js +2 -0
- package/frontend/dist/js/it-B90zSlqn.js +2 -0
- package/frontend/dist/js/ja-DU_K1GOr.js +2 -0
- package/frontend/dist/js/ko-DicfoO-e.js +2 -0
- package/frontend/dist/js/{markdown-CZ1tYEW8.js → markdown-DU84620G.js} +1 -1
- package/frontend/dist/js/{markdown-core-KjS96SYW.js → markdown-core-Cyql92Hg.js} +1 -1
- package/frontend/dist/js/{markdown-html-DQEwrWcf.js → markdown-html-CUc2fCgY.js} +1 -1
- package/frontend/dist/js/{markdown-math-CKi32S5d.js → markdown-math-DxPfMKvO.js} +1 -1
- package/frontend/dist/js/{markdownHtml-lrXhxBhK.js → markdownHtml-KhS0cFNH.js} +1 -1
- package/frontend/dist/js/markdownMath-CsfRQAcz.js +1 -0
- package/frontend/dist/js/{messageCodeStyles-D4haBw80.js → messageCodeStyles-CuQPkfEK.js} +1 -1
- package/frontend/dist/js/ms-CfH7wjUY.js +2 -0
- package/frontend/dist/js/nl-ELlOz-B3.js +2 -0
- package/frontend/dist/js/pl-33dayyUk.js +2 -0
- package/frontend/dist/js/pt-aIXSQPCT.js +2 -0
- package/frontend/dist/js/react-vendor-CR5VJ85Q.js +9 -0
- package/frontend/dist/js/{router-vendor-HZm4FR0A.js → router-vendor-DqMnEJWK.js} +1 -1
- package/frontend/dist/js/ru-BSvGtBtW.js +2 -0
- package/frontend/dist/js/{standalone-DbyFjvTU.js → standalone-D_lg5NC9.js} +1 -1
- package/frontend/dist/js/strandsApi-BFbeEpAY.js +2 -0
- package/frontend/dist/js/sv-B7KOz81W.js +2 -0
- package/frontend/dist/js/{syntax-highlight-DNc3FFCa.js → syntax-highlight-D7dQ5s5-.js} +1 -1
- package/frontend/dist/js/{teamEventStream-omPy51va.js → teamEventStream-DsAS6P4m.js} +1 -1
- package/frontend/dist/js/th-DgpjGxvA.js +2 -0
- package/frontend/dist/js/tr-BQTbl2h-.js +2 -0
- package/frontend/dist/js/{ui-D5-4niRk.js → ui-Aq8MP7Ph.js} +2 -2
- package/frontend/dist/js/ui-vendor-DVTj_sKN.js +1 -0
- package/frontend/dist/js/uk-JLymloot.js +2 -0
- package/frontend/dist/js/{useChat-DnGClJeX.js → useChat-D3ZAGz70.js} +4 -4
- package/frontend/dist/js/useDialogFocus-zSGHkpE4.js +1 -0
- package/frontend/dist/js/useDictation-B6l8QzeM.js +1 -0
- package/frontend/dist/js/{useQuery-hWmQjdLu.js → useQuery-BTKpXudI.js} +1 -1
- package/frontend/dist/js/{useTranslation-B9kflK9S.js → useTranslation-Boi0fB1B.js} +1 -1
- package/frontend/dist/js/utils-B-Bhh1pF.js +1 -0
- package/frontend/dist/js/utils-vendor-DPJG-EG_.js +1 -0
- package/frontend/dist/js/vi-BXdLOJ8q.js +2 -0
- package/frontend/dist/js/{work-DmJpVPPO.js → work-CdbmBok5.js} +1 -1
- package/frontend/dist/js/workApi-D1xtiG3Q.js +1 -0
- package/frontend/dist/js/{workApi-C5InfT8x.js → workApi-UPxumrEF.js} +1 -1
- package/frontend/dist/js/workModels-BM2Zyiba.js +1 -0
- package/frontend/dist/js/zh-gdUf9sXa.js +2 -0
- package/package.json +11 -40
- package/plugins/anthropic.json +3 -1
- package/plugins/bedrock.json +86 -0
- package/plugins/openrouter.json +2 -0
- package/backend/dist/cordis/contracts.d.ts +0 -270
- package/backend/dist/cordis/contracts.d.ts.map +0 -1
- package/backend/dist/cordis/contracts.js +0 -32
- package/backend/dist/cordis/contracts.js.map +0 -1
- package/backend/dist/cordis/dsh/chat-model.d.ts +0 -16
- package/backend/dist/cordis/dsh/chat-model.d.ts.map +0 -1
- package/backend/dist/cordis/dsh/chat-model.js +0 -104
- package/backend/dist/cordis/dsh/chat-model.js.map +0 -1
- package/backend/dist/cordis/dsh/engine-plugin.d.ts +0 -186
- package/backend/dist/cordis/dsh/engine-plugin.d.ts.map +0 -1
- package/backend/dist/cordis/dsh/engine-plugin.js +0 -1116
- package/backend/dist/cordis/dsh/engine-plugin.js.map +0 -1
- package/backend/dist/cordis/dsh/librewebui-llm-adapter.d.ts +0 -175
- package/backend/dist/cordis/dsh/librewebui-llm-adapter.d.ts.map +0 -1
- package/backend/dist/cordis/dsh/librewebui-llm-adapter.js +0 -480
- package/backend/dist/cordis/dsh/librewebui-llm-adapter.js.map +0 -1
- package/backend/dist/cordis/dsh/model-identity.d.ts +0 -12
- package/backend/dist/cordis/dsh/model-identity.d.ts.map +0 -1
- package/backend/dist/cordis/dsh/model-identity.js +0 -87
- package/backend/dist/cordis/dsh/model-identity.js.map +0 -1
- package/backend/dist/cordis/dsh/native-provider-client.d.ts +0 -44
- package/backend/dist/cordis/dsh/native-provider-client.d.ts.map +0 -1
- package/backend/dist/cordis/dsh/native-provider-client.js +0 -524
- package/backend/dist/cordis/dsh/native-provider-client.js.map +0 -1
- package/backend/dist/cordis/dsh/native-provider-plugin.d.ts +0 -11
- package/backend/dist/cordis/dsh/native-provider-plugin.d.ts.map +0 -1
- package/backend/dist/cordis/dsh/native-provider-plugin.js +0 -416
- package/backend/dist/cordis/dsh/native-provider-plugin.js.map +0 -1
- package/backend/dist/cordis/dsh/native-provider-protocol.d.ts +0 -37
- package/backend/dist/cordis/dsh/native-provider-protocol.d.ts.map +0 -1
- package/backend/dist/cordis/dsh/native-provider-protocol.js +0 -325
- package/backend/dist/cordis/dsh/native-provider-protocol.js.map +0 -1
- package/backend/dist/cordis/dsh/provider-handler.d.ts +0 -36
- package/backend/dist/cordis/dsh/provider-handler.d.ts.map +0 -1
- package/backend/dist/cordis/dsh/provider-handler.js +0 -582
- package/backend/dist/cordis/dsh/provider-handler.js.map +0 -1
- package/backend/dist/cordis/dsh/session-files.d.ts +0 -9
- package/backend/dist/cordis/dsh/session-files.d.ts.map +0 -1
- package/backend/dist/cordis/dsh/session-files.js +0 -60
- package/backend/dist/cordis/dsh/session-files.js.map +0 -1
- package/backend/dist/cordis/dsh/session-settings.d.ts +0 -15
- package/backend/dist/cordis/dsh/session-settings.d.ts.map +0 -1
- package/backend/dist/cordis/dsh/session-settings.js +0 -51
- package/backend/dist/cordis/dsh/session-settings.js.map +0 -1
- package/backend/dist/cordis/dsh/work-driver.d.ts +0 -12
- package/backend/dist/cordis/dsh/work-driver.d.ts.map +0 -1
- package/backend/dist/cordis/dsh/work-driver.js +0 -402
- package/backend/dist/cordis/dsh/work-driver.js.map +0 -1
- package/backend/dist/cordis/dsh/workspace-policy.d.ts +0 -10
- package/backend/dist/cordis/dsh/workspace-policy.d.ts.map +0 -1
- package/backend/dist/cordis/dsh/workspace-policy.js +0 -44
- package/backend/dist/cordis/dsh/workspace-policy.js.map +0 -1
- package/backend/dist/cordis/host/composition.d.ts +0 -73
- package/backend/dist/cordis/host/composition.d.ts.map +0 -1
- package/backend/dist/cordis/host/composition.js +0 -205
- package/backend/dist/cordis/host/composition.js.map +0 -1
- package/backend/dist/cordis/host/config.d.ts +0 -159
- package/backend/dist/cordis/host/config.d.ts.map +0 -1
- package/backend/dist/cordis/host/config.js +0 -184
- package/backend/dist/cordis/host/config.js.map +0 -1
- package/backend/dist/cordis/host/host.d.ts +0 -74
- package/backend/dist/cordis/host/host.d.ts.map +0 -1
- package/backend/dist/cordis/host/host.js +0 -420
- package/backend/dist/cordis/host/host.js.map +0 -1
- package/backend/dist/cordis/host/loader-entry.d.ts +0 -41
- package/backend/dist/cordis/host/loader-entry.d.ts.map +0 -1
- package/backend/dist/cordis/host/loader-entry.js +0 -52
- package/backend/dist/cordis/host/loader-entry.js.map +0 -1
- package/backend/dist/cordis/host/model.d.ts +0 -45
- package/backend/dist/cordis/host/model.d.ts.map +0 -1
- package/backend/dist/cordis/host/model.js +0 -54
- package/backend/dist/cordis/host/model.js.map +0 -1
- package/backend/dist/cordis/host/privacy.d.ts +0 -8
- package/backend/dist/cordis/host/privacy.d.ts.map +0 -1
- package/backend/dist/cordis/host/privacy.js +0 -73
- package/backend/dist/cordis/host/privacy.js.map +0 -1
- package/backend/dist/cordis/index.d.ts +0 -14
- package/backend/dist/cordis/index.d.ts.map +0 -1
- package/backend/dist/cordis/index.js +0 -30
- package/backend/dist/cordis/index.js.map +0 -1
- package/backend/dist/cordis/runtime.d.ts +0 -97
- package/backend/dist/cordis/runtime.d.ts.map +0 -1
- package/backend/dist/cordis/runtime.js +0 -231
- package/backend/dist/cordis/runtime.js.map +0 -1
- package/backend/dist/cordis/work-model.d.ts +0 -7
- package/backend/dist/cordis/work-model.d.ts.map +0 -1
- package/backend/dist/cordis/work-model.js.map +0 -1
- package/backend/dist/routes/cordis.d.ts.map +0 -1
- package/backend/dist/routes/cordis.js +0 -440
- package/backend/dist/routes/cordis.js.map +0 -1
- package/backend/dist/routes/libreClaw.d.ts +0 -3
- package/backend/dist/routes/libreClaw.d.ts.map +0 -1
- package/backend/dist/routes/libreClaw.js +0 -200
- package/backend/dist/routes/libreClaw.js.map +0 -1
- package/backend/dist/services/cordisAccessService.d.ts +0 -56
- package/backend/dist/services/cordisAccessService.d.ts.map +0 -1
- package/backend/dist/services/cordisAccessService.js +0 -98
- package/backend/dist/services/cordisAccessService.js.map +0 -1
- package/backend/dist/services/libreClawService.d.ts +0 -105
- package/backend/dist/services/libreClawService.d.ts.map +0 -1
- package/backend/dist/services/libreClawService.js +0 -169
- package/backend/dist/services/libreClawService.js.map +0 -1
- package/frontend/dist/assets/index-C8_AByBq.css +0 -1
- package/frontend/dist/assets/index-DWLnkKwj.js +0 -16
- package/frontend/dist/js/AutomationModal-CjjiEZFA.js +0 -1
- package/frontend/dist/js/AutomationsPage-jnWmD58y.js +0 -1
- package/frontend/dist/js/ChannelsPage-DHPabX1e.js +0 -1
- package/frontend/dist/js/ChatPage-ZvGp-iqV.js +0 -14
- package/frontend/dist/js/ConnectModels-aUTD6s9B.js +0 -1
- package/frontend/dist/js/CordisPage-DZKcpPVj.js +0 -1
- package/frontend/dist/js/GalleryPage-CrlNRnkn.js +0 -1
- package/frontend/dist/js/HomePage-lR9h7_a1.js +0 -1
- package/frontend/dist/js/LanguageSwitcher-CWkbzpxT.js +0 -1
- package/frontend/dist/js/LibreClawPage-P19FnNlu.js +0 -1
- package/frontend/dist/js/NotesPage-DopG0M4B.js +0 -3
- package/frontend/dist/js/OptimizedSyntaxHighlighter-ajqwyBQm.js +0 -1
- package/frontend/dist/js/PluginUsagePage-Cj0mUxD8.js +0 -1
- package/frontend/dist/js/RichMessageContent-BZndQSJU.js +0 -1
- package/frontend/dist/js/SettingsModal-wAuFQOE4.js +0 -19
- package/frontend/dist/js/UserManagementPanel-BU95ZPOv.js +0 -1
- package/frontend/dist/js/WorkPage-CSderbeT.js +0 -8
- package/frontend/dist/js/api-CU-JXx2u.js +0 -1
- package/frontend/dist/js/api-DPXCtanG.js +0 -14
- package/frontend/dist/js/appStore-BD70bvas.js +0 -2
- package/frontend/dist/js/appVersion-C7sxqgMd.js +0 -1
- package/frontend/dist/js/ar-Cq-DrSYL.js +0 -2
- package/frontend/dist/js/authStore-FNKLFUQp.js +0 -1
- package/frontend/dist/js/bn-BqxLh-KL.js +0 -2
- package/frontend/dist/js/chatStore-CK5ojwft.js +0 -3
- package/frontend/dist/js/cordisApi-BS8QMSV4.js +0 -2
- package/frontend/dist/js/cs-D2DDNZf-.js +0 -2
- package/frontend/dist/js/da-BciY-TSG.js +0 -2
- package/frontend/dist/js/de-DjU_eXQ-.js +0 -2
- package/frontend/dist/js/es-ChIEs80I.js +0 -2
- package/frontend/dist/js/fr-Bi8BGRW4.js +0 -2
- package/frontend/dist/js/hi-BMsCnWg7.js +0 -2
- package/frontend/dist/js/i18next-DOICz7ZY.js +0 -1
- package/frontend/dist/js/id-CpcN1vhk.js +0 -2
- package/frontend/dist/js/is-DkUy2cmP.js +0 -2
- package/frontend/dist/js/it-BglK9DRZ.js +0 -2
- package/frontend/dist/js/ja-IrprzwLJ.js +0 -2
- package/frontend/dist/js/ko--wwEsMPi.js +0 -2
- package/frontend/dist/js/markdownMath-B0BpyFBS.js +0 -1
- package/frontend/dist/js/ms-BWj59y7-.js +0 -2
- package/frontend/dist/js/nl-D-QndW_A.js +0 -2
- package/frontend/dist/js/pl-Dw7d7iDV.js +0 -2
- package/frontend/dist/js/pt-BI53uHJw.js +0 -2
- package/frontend/dist/js/react-vendor-wiHys0m2.js +0 -9
- package/frontend/dist/js/ru-JKyTgPg9.js +0 -2
- package/frontend/dist/js/sv-BIkBLPSQ.js +0 -2
- package/frontend/dist/js/th-CZ_LcCU0.js +0 -2
- package/frontend/dist/js/tr-B265byx1.js +0 -2
- package/frontend/dist/js/ui-vendor-BhHHyHk3.js +0 -1
- package/frontend/dist/js/uk-VTAlChwf.js +0 -2
- package/frontend/dist/js/useDialogFocus-BPTG_Zmy.js +0 -1
- package/frontend/dist/js/useDictation-D7zVBjDJ.js +0 -1
- package/frontend/dist/js/utils-p8Gt72YP.js +0 -1
- package/frontend/dist/js/utils-vendor-DISWt2y9.js +0 -1
- package/frontend/dist/js/vi-D8rXh-53.js +0 -2
- package/frontend/dist/js/workApi-FV75LKJn.js +0 -1
- package/frontend/dist/js/workModels-MzU2Ab7l.js +0 -1
- package/frontend/dist/js/zh-BEGd9iBD.js +0 -2
- package/scripts/prepare-dsh-provider.mjs +0 -124
package/frontend/dist/index.html
CHANGED
|
@@ -89,46 +89,46 @@
|
|
|
89
89
|
name="twitter:image:alt"
|
|
90
90
|
content="Libre WebUI icon over a retro-futuristic cityscape"
|
|
91
91
|
/>
|
|
92
|
-
<script type="module" crossorigin src="/assets/index-
|
|
92
|
+
<script type="module" crossorigin src="/assets/index-D99DS5c6.js"></script>
|
|
93
93
|
<link rel="modulepreload" crossorigin href="/js/rolldown-runtime-hePW80VL.js">
|
|
94
|
-
<link rel="modulepreload" crossorigin href="/js/react-vendor-
|
|
95
|
-
<link rel="modulepreload" crossorigin href="/js/useQuery-
|
|
94
|
+
<link rel="modulepreload" crossorigin href="/js/react-vendor-CR5VJ85Q.js">
|
|
95
|
+
<link rel="modulepreload" crossorigin href="/js/useQuery-BTKpXudI.js">
|
|
96
96
|
<link rel="modulepreload" crossorigin href="/js/logger-BR4forr_.js">
|
|
97
|
-
<link rel="modulepreload" crossorigin href="/js/router-vendor-
|
|
98
|
-
<link rel="modulepreload" crossorigin href="/js/utils-vendor-
|
|
99
|
-
<link rel="modulepreload" crossorigin href="/js/utils-
|
|
100
|
-
<link rel="modulepreload" crossorigin href="/js/useTranslation-B9kflK9S.js">
|
|
101
|
-
<link rel="modulepreload" crossorigin href="/js/i18next-DOICz7ZY.js">
|
|
97
|
+
<link rel="modulepreload" crossorigin href="/js/router-vendor-DqMnEJWK.js">
|
|
98
|
+
<link rel="modulepreload" crossorigin href="/js/utils-vendor-DPJG-EG_.js">
|
|
99
|
+
<link rel="modulepreload" crossorigin href="/js/utils-B-Bhh1pF.js">
|
|
102
100
|
<link rel="modulepreload" crossorigin href="/js/goober.modern-BaHbaW3_.js">
|
|
103
|
-
<link rel="modulepreload" crossorigin href="/js/ui-vendor-
|
|
104
|
-
<link rel="modulepreload" crossorigin href="/js/config-
|
|
105
|
-
<link rel="modulepreload" crossorigin href="/js/client-
|
|
106
|
-
<link rel="modulepreload" crossorigin href="/js/
|
|
107
|
-
<link rel="modulepreload" crossorigin href="/js/
|
|
108
|
-
<link rel="modulepreload" crossorigin href="/js/
|
|
109
|
-
<link rel="modulepreload" crossorigin href="/js/
|
|
110
|
-
<link rel="modulepreload" crossorigin href="/js/
|
|
101
|
+
<link rel="modulepreload" crossorigin href="/js/ui-vendor-DVTj_sKN.js">
|
|
102
|
+
<link rel="modulepreload" crossorigin href="/js/config-4_s8hdqO.js">
|
|
103
|
+
<link rel="modulepreload" crossorigin href="/js/client-DppLngAs.js">
|
|
104
|
+
<link rel="modulepreload" crossorigin href="/js/strandsApi-BFbeEpAY.js">
|
|
105
|
+
<link rel="modulepreload" crossorigin href="/js/workApi-UPxumrEF.js">
|
|
106
|
+
<link rel="modulepreload" crossorigin href="/js/api-BrHW-VGd.js">
|
|
107
|
+
<link rel="modulepreload" crossorigin href="/js/chatStore-DpVxt9VX.js">
|
|
108
|
+
<link rel="modulepreload" crossorigin href="/js/useTranslation-Boi0fB1B.js">
|
|
109
|
+
<link rel="modulepreload" crossorigin href="/js/Button-j68Q8KVh.js">
|
|
110
|
+
<link rel="modulepreload" crossorigin href="/js/appStore-DkRdQQeY.js">
|
|
111
|
+
<link rel="modulepreload" crossorigin href="/js/authStore-DjAsRpNL.js">
|
|
111
112
|
<link rel="modulepreload" crossorigin href="/js/welcomePrompts-to5mv_gx.js">
|
|
112
|
-
<link rel="modulepreload" crossorigin href="/js/messageCodeStyles-
|
|
113
|
-
<link rel="modulepreload" crossorigin href="/js/
|
|
114
|
-
<link rel="modulepreload" crossorigin href="/js/
|
|
115
|
-
<link rel="modulepreload" crossorigin href="/js/
|
|
116
|
-
<link rel="modulepreload" crossorigin href="/js/
|
|
117
|
-
<link rel="modulepreload" crossorigin href="/js/
|
|
118
|
-
<link rel="modulepreload" crossorigin href="/js/
|
|
119
|
-
<link rel="modulepreload" crossorigin href="/js/
|
|
120
|
-
<link rel="modulepreload" crossorigin href="/js/
|
|
121
|
-
<link rel="modulepreload" crossorigin href="/js/
|
|
122
|
-
<link rel="modulepreload" crossorigin href="/js/workModels-MzU2Ab7l.js">
|
|
113
|
+
<link rel="modulepreload" crossorigin href="/js/messageCodeStyles-CuQPkfEK.js">
|
|
114
|
+
<link rel="modulepreload" crossorigin href="/js/useDialogFocus-zSGHkpE4.js">
|
|
115
|
+
<link rel="modulepreload" crossorigin href="/js/ui-Aq8MP7Ph.js">
|
|
116
|
+
<link rel="modulepreload" crossorigin href="/js/AvatarUpload-CG-w6Mpt.js">
|
|
117
|
+
<link rel="modulepreload" crossorigin href="/js/Logo-DnfVtjgj.js">
|
|
118
|
+
<link rel="modulepreload" crossorigin href="/js/LogoMark-BzObGdA9.js">
|
|
119
|
+
<link rel="modulepreload" crossorigin href="/js/ShareDialog-DaSxkTKS.js">
|
|
120
|
+
<link rel="modulepreload" crossorigin href="/js/teamEventStream-DsAS6P4m.js">
|
|
121
|
+
<link rel="modulepreload" crossorigin href="/js/work-CdbmBok5.js">
|
|
122
|
+
<link rel="modulepreload" crossorigin href="/js/workModels-BM2Zyiba.js">
|
|
123
123
|
<link rel="modulepreload" crossorigin href="/js/artifactHtml-DDmfpcB0.js">
|
|
124
|
-
<link rel="modulepreload" crossorigin href="/js/useChat-
|
|
125
|
-
<link rel="modulepreload" crossorigin href="/js/LanguageSwitcher-
|
|
126
|
-
<link rel="modulepreload" crossorigin href="/js/appNavigation-
|
|
124
|
+
<link rel="modulepreload" crossorigin href="/js/useChat-D3ZAGz70.js">
|
|
125
|
+
<link rel="modulepreload" crossorigin href="/js/LanguageSwitcher-B_YyU5JG.js">
|
|
126
|
+
<link rel="modulepreload" crossorigin href="/js/appNavigation-B6xYIgLi.js">
|
|
127
127
|
<link rel="modulepreload" crossorigin href="/js/ttsBatching-kFVEE3Ip.js">
|
|
128
|
-
<link rel="modulepreload" crossorigin href="/js/TurnstileWidget-
|
|
129
|
-
<link rel="modulepreload" crossorigin href="/js/PasswordStrengthMeter-
|
|
130
|
-
<link rel="modulepreload" crossorigin href="/js/appVersion-
|
|
131
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
128
|
+
<link rel="modulepreload" crossorigin href="/js/TurnstileWidget-tI50c7Kc.js">
|
|
129
|
+
<link rel="modulepreload" crossorigin href="/js/PasswordStrengthMeter-DI4RDv67.js">
|
|
130
|
+
<link rel="modulepreload" crossorigin href="/js/appVersion-BVtSqLVj.js">
|
|
131
|
+
<link rel="stylesheet" crossorigin href="/assets/index-Dz1JufgZ.css">
|
|
132
132
|
</head>
|
|
133
133
|
<body>
|
|
134
134
|
<div id="root"></div>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-vendor-wiHys0m2.js";import{t as r}from"./logger-BR4forr_.js";import{t as i}from"./useTranslation-B9kflK9S.js";import{t as a}from"./utils-p8Gt72YP.js";import{Cn as o,Fn as s,In as c,On as l,Qn as u,_n as d,g as f,jn as p,jt as m,tn as h}from"./ui-vendor-BhHHyHk3.js";import{t as g}from"./appStore-BD70bvas.js";import{t as _}from"./Button-CGMYia4g.js";import{i as v,r as y}from"./artifactHtml-DDmfpcB0.js";import{t as b}from"./OptimizedSyntaxHighlighter-CzzV6ONG.js";import{t as x}from"./ArtifactSandboxFrame-DlWJHI-r.js";var S=e(t(),1),C=n(),w=r(`components:artifact-renderer`),T=({artifact:e,className:t})=>{let{t:n}=i(),[r,T]=(0,S.useState)(!1),[E,D]=(0,S.useState)(`preview`),{theme:O,openArtifactPanel:k,artifactPanelOpen:A,artifactPanelArtifact:j}=g(),M=async e=>{try{await navigator.clipboard.writeText(e),T(!0),setTimeout(()=>T(!1),2e3)}catch(e){w.error(`Failed to copy:`,e)}},N=()=>{let t=e.type===`html`?y(e.content,e.title):e.content,n=new Blob([t],{type:P(e.type)}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${e.title}.${F(e.type)}`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)},P=e=>{switch(e){case`html`:return`text/html`;case`react`:return`text/javascript`;case`svg`:return`image/svg+xml`;case`css`:return`text/css`;case`json`:return`application/json`;default:return`text/plain`}},F=e=>{switch(e){case`html`:return`html`;case`react`:return`jsx`;case`svg`:return`svg`;case`css`:return`css`;case`json`:return`json`;default:return`txt`}},I=()=>{switch(e.type){case`html`:return(0,C.jsx)(h,{className:`h-4 w-4`});case`react`:return(0,C.jsx)(s,{className:`h-4 w-4`});case`svg`:return(0,C.jsx)(d,{className:`h-4 w-4`});case`code`:return(0,C.jsx)(s,{className:`h-4 w-4`});default:return(0,C.jsx)(d,{className:`h-4 w-4`})}},L=()=>(0,C.jsx)(`div`,{"data-testid":`artifact-html-fallback`,className:`w-full h-64 sm:h-80 lg:h-96 flex items-center justify-center bg-gray-50 dark:bg-dark-100 rounded-lg border border-gray-200 dark:border-dark-200 p-4`,children:(0,C.jsxs)(`div`,{className:`max-w-sm text-center`,children:[(0,C.jsx)(f,{className:`h-8 w-8 text-primary-500 mx-auto mb-3`}),(0,C.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:n(`artifacts.previewUnavailable`)}),(0,C.jsx)(`p`,{className:`mt-1 text-sm text-gray-600 dark:text-gray-400`,children:n(`artifacts.previewUnavailableDescription`)}),(0,C.jsxs)(_,{variant:`outline`,size:`sm`,onClick:()=>D(`code`),className:`mt-4`,children:[(0,C.jsx)(c,{className:`h-3.5 w-3.5 mr-1.5`}),n(`artifacts.code`)]})]})}),R=t=>e.content.trim()?(0,C.jsx)(x,{content:e.content,title:e.title,kind:t,colorScheme:O.mode===`light`?`light`:`dark`,className:`w-full h-64 sm:h-80 lg:h-96 border-0 rounded-lg`,fallback:L()}):L(),z=()=>(0,C.jsx)(`iframe`,{"data-testid":`artifact-svg-preview`,srcDoc:v(e.content,e.title),className:`w-full h-64 sm:h-80 lg:h-96 border-0 rounded-lg bg-white`,sandbox:``,title:e.title}),B=()=>(0,C.jsx)(`div`,{className:`relative max-h-64 sm:max-h-80 lg:max-h-96 overflow-auto`,children:(0,C.jsx)(b,{language:(()=>{if(e.language)return e.language;switch(e.type){case`html`:return`html`;case`react`:return`jsx`;case`svg`:return`xml`;case`json`:return`json`;default:return`text`}})(),isDark:O.mode!==`light`,className:`!m-0 !rounded-lg`,codeTheme:`night`,showLineNumbers:!0,backgroundColor:O.mode===`light`?void 0:`rgb(var(--color-dark-50))`,children:e.content})}),V=()=>{try{let t=JSON.parse(e.content),n=JSON.stringify(t,null,2);return(0,C.jsx)(`div`,{className:`relative max-h-64 sm:max-h-80 lg:max-h-96 overflow-auto`,children:(0,C.jsx)(b,{language:`json`,isDark:O.mode!==`light`,className:`!m-0 !rounded-lg`,codeTheme:`night`,showLineNumbers:!0,backgroundColor:O.mode===`light`?void 0:`rgb(var(--color-dark-50))`,children:n})})}catch{return(0,C.jsx)(`div`,{className:`w-full h-32 flex items-center justify-center bg-gray-50 dark:bg-dark-100 rounded-lg border border-gray-200 dark:border-dark-200`,children:(0,C.jsxs)(`div`,{className:`text-center`,children:[(0,C.jsx)(f,{className:`h-8 w-8 text-primary-500 mx-auto mb-2`}),(0,C.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-dark-600`,children:n(`artifacts.invalidJson`)})]})})}},H=()=>{if(E===`code`)return B();switch(e.type){case`html`:return R(`html`);case`react`:return R(`react`);case`mermaid`:return R(`mermaid`);case`svg`:return z();case`json`:return V();default:return B()}},U=()=>e.type===`html`||e.type===`svg`||e.type===`react`||e.type===`mermaid`;return A&&j!==null&&j.title.trim().toLowerCase()===e.title.trim().toLowerCase()?(0,C.jsxs)(`button`,{type:`button`,"data-testid":`artifact-collapsed-card`,onClick:()=>k(e),title:n(`artifacts.openInPanel`),className:a(`flex w-full max-w-full items-center gap-3 rounded-xl border border-gray-200 bg-white px-4 py-3 text-start shadow-sm transition-colors animate-fade-in`,`hover:bg-gray-50 dark:border-dark-200 dark:bg-dark-25 dark:hover:bg-dark-100`,t),children:[(0,C.jsx)(`div`,{className:`flex-shrink-0 text-gray-600 dark:text-gray-400`,children:I()}),(0,C.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-gray-900 dark:text-gray-100`,children:e.title}),(0,C.jsx)(`span`,{className:`flex-shrink-0 rounded-full bg-primary-50 px-2 py-1 text-xs font-medium text-primary-700 dark:bg-primary-900/20 dark:text-primary-300`,children:e.type.toUpperCase()}),(0,C.jsx)(m,{className:`h-4 w-4 flex-shrink-0 text-gray-400 dark:text-dark-500`})]}):(0,C.jsxs)(`div`,{className:a(`border border-gray-200 dark:border-dark-200 rounded-xl bg-white dark:bg-dark-25 shadow-lg transition-all duration-300 hover:shadow-xl`,`w-full max-w-full overflow-hidden animate-fade-in`,`max-h-[400px] flex flex-col`,t),children:[(0,C.jsxs)(`div`,{className:`px-1.5 py-1.5 sm:p-4 border-b border-gray-100 dark:border-dark-200 flex-shrink-0`,children:[(0,C.jsxs)(`div`,{className:`flex flex-col gap-2 sm:hidden`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(`div`,{className:`h-4 w-4 flex-shrink-0 flex items-center justify-center`,children:I()}),(0,C.jsx)(`h3`,{className:`font-medium text-gray-900 dark:text-gray-100 truncate text-sm leading-tight flex-1`,children:e.title})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[U()&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(_,{variant:E===`preview`?`primary`:`ghost`,size:`sm`,onClick:()=>D(`preview`),className:`h-5 px-0.5 text-xs`,title:n(`artifacts.previewMode`),children:(0,C.jsx)(o,{className:`h-2.5 w-2.5`})}),(0,C.jsx)(_,{variant:E===`code`?`primary`:`ghost`,size:`sm`,onClick:()=>D(`code`),className:`h-5 px-0.5 text-xs`,title:n(`artifacts.codeMode`),children:(0,C.jsx)(c,{className:`h-2.5 w-2.5`})}),(0,C.jsx)(`div`,{className:`w-px h-2 bg-gray-300 dark:bg-gray-600 mx-0.5`})]}),(0,C.jsx)(_,{variant:`ghost`,size:`sm`,onClick:()=>M(e.content),className:`h-5 w-5 p-0 hover:bg-gray-100 dark:hover:bg-dark-200 touch-manipulation`,title:n(`artifacts.copyContent`),children:r?(0,C.jsx)(u,{className:`h-2.5 w-2.5 text-green-500`}):(0,C.jsx)(p,{className:`h-2.5 w-2.5`})}),(0,C.jsx)(_,{variant:`ghost`,size:`sm`,onClick:N,className:`h-5 w-5 p-0 hover:bg-gray-100 dark:hover:bg-dark-200 touch-manipulation`,title:n(`artifacts.download`),children:(0,C.jsx)(l,{className:`h-2.5 w-2.5`})}),(0,C.jsx)(_,{variant:`ghost`,size:`sm`,onClick:()=>k(e),className:`h-5 w-5 p-0 hover:bg-gray-100 dark:hover:bg-dark-200 touch-manipulation border border-gray-200 dark:border-dark-300 hover:border-gray-300 dark:hover:border-dark-400`,title:n(`artifacts.openInPanel`),children:(0,C.jsx)(m,{className:`h-2.5 w-2.5`})})]})]}),(0,C.jsxs)(`div`,{className:`hidden sm:flex items-center justify-between gap-2`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 flex-1`,children:[(0,C.jsx)(`div`,{className:`flex-shrink-0`,children:I()}),(0,C.jsx)(`h3`,{className:`font-semibold text-gray-900 dark:text-gray-100 truncate`,children:e.title})]}),(0,C.jsx)(`span`,{className:`text-xs bg-primary-50 dark:bg-primary-900/20 text-primary-700 dark:text-primary-300 px-2 py-1 rounded-full font-medium flex-shrink-0`,children:e.type.toUpperCase()})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[U()&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(_,{variant:E===`preview`?`primary`:`ghost`,size:`sm`,onClick:()=>D(`preview`),className:`h-8 px-3 text-xs`,title:n(`artifacts.previewMode`),children:[(0,C.jsx)(o,{className:`h-3 w-3 mr-1`}),n(`artifacts.preview`)]}),(0,C.jsxs)(_,{variant:E===`code`?`primary`:`ghost`,size:`sm`,onClick:()=>D(`code`),className:`h-8 px-3 text-xs`,title:n(`artifacts.codeMode`),children:[(0,C.jsx)(c,{className:`h-3 w-3 mr-1`}),n(`artifacts.code`)]}),(0,C.jsx)(`div`,{className:`w-px h-4 bg-gray-300 dark:bg-gray-600 mx-1`})]}),(0,C.jsx)(_,{variant:`ghost`,size:`sm`,onClick:()=>M(e.content),className:`h-8 w-8 p-0 hover:bg-gray-100 dark:hover:bg-dark-200`,title:n(`artifacts.copyContent`),children:r?(0,C.jsx)(u,{className:`h-4 w-4 text-green-500`}):(0,C.jsx)(p,{className:`h-4 w-4`})}),(0,C.jsx)(_,{variant:`ghost`,size:`sm`,onClick:N,className:`h-8 w-8 p-0 hover:bg-gray-100 dark:hover:bg-dark-200`,title:n(`artifacts.download`),children:(0,C.jsx)(l,{className:`h-4 w-4`})}),(0,C.jsx)(_,{variant:`ghost`,size:`sm`,onClick:()=>k(e),className:`h-8 w-8 p-0 hover:bg-gray-100 dark:hover:bg-dark-200`,title:n(`artifacts.openInPanel`),children:(0,C.jsx)(m,{className:`h-4 w-4`})})]})]})]}),(0,C.jsxs)(`div`,{className:`p-4 flex-1 overflow-hidden min-h-0`,children:[e.description&&(0,C.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-4`,children:e.description}),(0,C.jsx)(`div`,{className:`h-full overflow-auto`,children:H()})]}),(0,C.jsx)(`div`,{className:`flex items-center justify-between p-3 border-t border-gray-100 dark:border-dark-200 bg-gray-50 dark:bg-dark-100/50 flex-shrink-0`,children:(0,C.jsxs)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[n(`artifacts.created`),`:`,` `,new Date(e.createdAt).toLocaleString()]})})]})},E=({artifacts:e,className:t})=>!e||e.length===0?null:(0,C.jsx)(`div`,{className:a(`space-y-3`,t),children:e.map(e=>(0,C.jsx)(T,{artifact:e},e.id))});export{E as t};
|
|
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{t as a}from"./utils-B-Bhh1pF.js";import{Cn as o,Fn as s,In as c,On as l,Qn as u,_n as d,g as f,jn as p,jt as m,tn as h}from"./ui-vendor-DVTj_sKN.js";import{t as g}from"./Button-j68Q8KVh.js";import{t as _}from"./appStore-DkRdQQeY.js";import{i as v,r as y}from"./artifactHtml-DDmfpcB0.js";import{t as b}from"./OptimizedSyntaxHighlighter-B0g8cxZQ.js";import{t as x}from"./ArtifactSandboxFrame-CdsAqv8H.js";var S=e(t(),1),C=n(),w=r(`components:artifact-renderer`),T=({artifact:e,className:t})=>{let{t:n}=i(),[r,T]=(0,S.useState)(!1),[E,D]=(0,S.useState)(`preview`),{theme:O,openArtifactPanel:k,artifactPanelOpen:A,artifactPanelArtifact:j}=_(),M=async e=>{try{await navigator.clipboard.writeText(e),T(!0),setTimeout(()=>T(!1),2e3)}catch(e){w.error(`Failed to copy:`,e)}},N=()=>{let t=e.type===`html`?y(e.content,e.title):e.content,n=new Blob([t],{type:P(e.type)}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${e.title}.${F(e.type)}`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)},P=e=>{switch(e){case`html`:return`text/html`;case`react`:return`text/javascript`;case`svg`:return`image/svg+xml`;case`css`:return`text/css`;case`json`:return`application/json`;default:return`text/plain`}},F=e=>{switch(e){case`html`:return`html`;case`react`:return`jsx`;case`svg`:return`svg`;case`css`:return`css`;case`json`:return`json`;default:return`txt`}},I=()=>{switch(e.type){case`html`:return(0,C.jsx)(h,{className:`h-4 w-4`});case`react`:return(0,C.jsx)(s,{className:`h-4 w-4`});case`svg`:return(0,C.jsx)(d,{className:`h-4 w-4`});case`code`:return(0,C.jsx)(s,{className:`h-4 w-4`});default:return(0,C.jsx)(d,{className:`h-4 w-4`})}},L=()=>(0,C.jsx)(`div`,{"data-testid":`artifact-html-fallback`,className:`w-full h-64 sm:h-80 lg:h-96 flex items-center justify-center bg-gray-50 dark:bg-dark-100 rounded-lg border border-gray-200 dark:border-dark-200 p-4`,children:(0,C.jsxs)(`div`,{className:`max-w-sm text-center`,children:[(0,C.jsx)(f,{className:`h-8 w-8 text-primary-500 mx-auto mb-3`}),(0,C.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:n(`artifacts.previewUnavailable`)}),(0,C.jsx)(`p`,{className:`mt-1 text-sm text-gray-600 dark:text-gray-400`,children:n(`artifacts.previewUnavailableDescription`)}),(0,C.jsxs)(g,{variant:`outline`,size:`sm`,onClick:()=>D(`code`),className:`mt-4`,children:[(0,C.jsx)(c,{className:`h-3.5 w-3.5 mr-1.5`}),n(`artifacts.code`)]})]})}),R=t=>e.content.trim()?(0,C.jsx)(x,{content:e.content,title:e.title,kind:t,colorScheme:O.mode===`light`?`light`:`dark`,className:`w-full h-64 sm:h-80 lg:h-96 border-0 rounded-lg`,fallback:L()}):L(),z=()=>(0,C.jsx)(`iframe`,{"data-testid":`artifact-svg-preview`,srcDoc:v(e.content,e.title),className:`w-full h-64 sm:h-80 lg:h-96 border-0 rounded-lg bg-white`,sandbox:``,title:e.title}),B=()=>(0,C.jsx)(`div`,{className:`relative max-h-64 sm:max-h-80 lg:max-h-96 overflow-auto`,children:(0,C.jsx)(b,{language:(()=>{if(e.language)return e.language;switch(e.type){case`html`:return`html`;case`react`:return`jsx`;case`svg`:return`xml`;case`json`:return`json`;default:return`text`}})(),isDark:O.mode!==`light`,className:`!m-0 !rounded-lg`,codeTheme:`night`,showLineNumbers:!0,backgroundColor:O.mode===`light`?void 0:`rgb(var(--color-dark-50))`,children:e.content})}),V=()=>{try{let t=JSON.parse(e.content),n=JSON.stringify(t,null,2);return(0,C.jsx)(`div`,{className:`relative max-h-64 sm:max-h-80 lg:max-h-96 overflow-auto`,children:(0,C.jsx)(b,{language:`json`,isDark:O.mode!==`light`,className:`!m-0 !rounded-lg`,codeTheme:`night`,showLineNumbers:!0,backgroundColor:O.mode===`light`?void 0:`rgb(var(--color-dark-50))`,children:n})})}catch{return(0,C.jsx)(`div`,{className:`w-full h-32 flex items-center justify-center bg-gray-50 dark:bg-dark-100 rounded-lg border border-gray-200 dark:border-dark-200`,children:(0,C.jsxs)(`div`,{className:`text-center`,children:[(0,C.jsx)(f,{className:`h-8 w-8 text-primary-500 mx-auto mb-2`}),(0,C.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-dark-600`,children:n(`artifacts.invalidJson`)})]})})}},H=()=>{if(E===`code`)return B();switch(e.type){case`html`:return R(`html`);case`react`:return R(`react`);case`mermaid`:return R(`mermaid`);case`svg`:return z();case`json`:return V();default:return B()}},U=()=>e.type===`html`||e.type===`svg`||e.type===`react`||e.type===`mermaid`;return A&&j!==null&&j.title.trim().toLowerCase()===e.title.trim().toLowerCase()?(0,C.jsxs)(`button`,{type:`button`,"data-testid":`artifact-collapsed-card`,onClick:()=>k(e),title:n(`artifacts.openInPanel`),className:a(`flex w-full max-w-full items-center gap-3 rounded-xl border border-gray-200 bg-white px-4 py-3 text-start shadow-sm transition-colors animate-fade-in`,`hover:bg-gray-50 dark:border-dark-200 dark:bg-dark-25 dark:hover:bg-dark-100`,t),children:[(0,C.jsx)(`div`,{className:`flex-shrink-0 text-gray-600 dark:text-gray-400`,children:I()}),(0,C.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-gray-900 dark:text-gray-100`,children:e.title}),(0,C.jsx)(`span`,{className:`flex-shrink-0 rounded-full bg-primary-50 px-2 py-1 text-xs font-medium text-primary-700 dark:bg-primary-900/20 dark:text-primary-300`,children:e.type.toUpperCase()}),(0,C.jsx)(m,{className:`h-4 w-4 flex-shrink-0 text-gray-400 dark:text-dark-500`})]}):(0,C.jsxs)(`div`,{className:a(`border border-gray-200 dark:border-dark-200 rounded-xl bg-white dark:bg-dark-25 shadow-lg transition-all duration-300 hover:shadow-xl`,`w-full max-w-full overflow-hidden animate-fade-in`,`max-h-[400px] flex flex-col`,t),children:[(0,C.jsxs)(`div`,{className:`px-1.5 py-1.5 sm:p-4 border-b border-gray-100 dark:border-dark-200 flex-shrink-0`,children:[(0,C.jsxs)(`div`,{className:`flex flex-col gap-2 sm:hidden`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(`div`,{className:`h-4 w-4 flex-shrink-0 flex items-center justify-center`,children:I()}),(0,C.jsx)(`h3`,{className:`font-medium text-gray-900 dark:text-gray-100 truncate text-sm leading-tight flex-1`,children:e.title})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[U()&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(g,{variant:E===`preview`?`primary`:`ghost`,size:`sm`,onClick:()=>D(`preview`),className:`h-5 px-0.5 text-xs`,title:n(`artifacts.previewMode`),children:(0,C.jsx)(o,{className:`h-2.5 w-2.5`})}),(0,C.jsx)(g,{variant:E===`code`?`primary`:`ghost`,size:`sm`,onClick:()=>D(`code`),className:`h-5 px-0.5 text-xs`,title:n(`artifacts.codeMode`),children:(0,C.jsx)(c,{className:`h-2.5 w-2.5`})}),(0,C.jsx)(`div`,{className:`w-px h-2 bg-gray-300 dark:bg-gray-600 mx-0.5`})]}),(0,C.jsx)(g,{variant:`ghost`,size:`sm`,onClick:()=>M(e.content),className:`h-5 w-5 p-0 hover:bg-gray-100 dark:hover:bg-dark-200 touch-manipulation`,title:n(`artifacts.copyContent`),children:r?(0,C.jsx)(u,{className:`h-2.5 w-2.5 text-green-500`}):(0,C.jsx)(p,{className:`h-2.5 w-2.5`})}),(0,C.jsx)(g,{variant:`ghost`,size:`sm`,onClick:N,className:`h-5 w-5 p-0 hover:bg-gray-100 dark:hover:bg-dark-200 touch-manipulation`,title:n(`artifacts.download`),children:(0,C.jsx)(l,{className:`h-2.5 w-2.5`})}),(0,C.jsx)(g,{variant:`ghost`,size:`sm`,onClick:()=>k(e),className:`h-5 w-5 p-0 hover:bg-gray-100 dark:hover:bg-dark-200 touch-manipulation border border-gray-200 dark:border-dark-300 hover:border-gray-300 dark:hover:border-dark-400`,title:n(`artifacts.openInPanel`),children:(0,C.jsx)(m,{className:`h-2.5 w-2.5`})})]})]}),(0,C.jsxs)(`div`,{className:`hidden sm:flex items-center justify-between gap-2`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 flex-1`,children:[(0,C.jsx)(`div`,{className:`flex-shrink-0`,children:I()}),(0,C.jsx)(`h3`,{className:`font-semibold text-gray-900 dark:text-gray-100 truncate`,children:e.title})]}),(0,C.jsx)(`span`,{className:`text-xs bg-primary-50 dark:bg-primary-900/20 text-primary-700 dark:text-primary-300 px-2 py-1 rounded-full font-medium flex-shrink-0`,children:e.type.toUpperCase()})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[U()&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(g,{variant:E===`preview`?`primary`:`ghost`,size:`sm`,onClick:()=>D(`preview`),className:`h-8 px-3 text-xs`,title:n(`artifacts.previewMode`),children:[(0,C.jsx)(o,{className:`h-3 w-3 mr-1`}),n(`artifacts.preview`)]}),(0,C.jsxs)(g,{variant:E===`code`?`primary`:`ghost`,size:`sm`,onClick:()=>D(`code`),className:`h-8 px-3 text-xs`,title:n(`artifacts.codeMode`),children:[(0,C.jsx)(c,{className:`h-3 w-3 mr-1`}),n(`artifacts.code`)]}),(0,C.jsx)(`div`,{className:`w-px h-4 bg-gray-300 dark:bg-gray-600 mx-1`})]}),(0,C.jsx)(g,{variant:`ghost`,size:`sm`,onClick:()=>M(e.content),className:`h-8 w-8 p-0 hover:bg-gray-100 dark:hover:bg-dark-200`,title:n(`artifacts.copyContent`),children:r?(0,C.jsx)(u,{className:`h-4 w-4 text-green-500`}):(0,C.jsx)(p,{className:`h-4 w-4`})}),(0,C.jsx)(g,{variant:`ghost`,size:`sm`,onClick:N,className:`h-8 w-8 p-0 hover:bg-gray-100 dark:hover:bg-dark-200`,title:n(`artifacts.download`),children:(0,C.jsx)(l,{className:`h-4 w-4`})}),(0,C.jsx)(g,{variant:`ghost`,size:`sm`,onClick:()=>k(e),className:`h-8 w-8 p-0 hover:bg-gray-100 dark:hover:bg-dark-200`,title:n(`artifacts.openInPanel`),children:(0,C.jsx)(m,{className:`h-4 w-4`})})]})]})]}),(0,C.jsxs)(`div`,{className:`p-4 flex-1 overflow-hidden min-h-0`,children:[e.description&&(0,C.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-4`,children:e.description}),(0,C.jsx)(`div`,{className:`h-full overflow-auto`,children:H()})]}),(0,C.jsx)(`div`,{className:`flex items-center justify-between p-3 border-t border-gray-100 dark:border-dark-200 bg-gray-50 dark:bg-dark-100/50 flex-shrink-0`,children:(0,C.jsxs)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[n(`artifacts.created`),`:`,` `,new Date(e.createdAt).toLocaleString()]})})]})},E=({artifacts:e,className:t})=>!e||e.length===0?null:(0,C.jsx)(`div`,{className:a(`space-y-3`,t),children:e.map(e=>(0,C.jsx)(T,{artifact:e},e.id))});export{E as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-vendor-
|
|
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"./Button-j68Q8KVh.js";import{o as i}from"./ui-Aq8MP7Ph.js";import{t as a}from"./ArtifactContainer-Cn7X9HGm.js";var o=e(t(),1),s=n(),c=[{id:`demo-html-1`,type:`html`,title:`Interactive Button Demo`,description:`A simple HTML page with interactive elements`,content:`<div style="text-align: center; padding: 20px;">
|
|
2
2
|
<h1 style="color: #333; font-family: Arial, sans-serif;">Welcome to Libre WebUI!</h1>
|
|
3
3
|
<p style="color: #666; font-size: 16px;">This is an interactive HTML artifact.</p>
|
|
4
4
|
<button
|
package/frontend/dist/js/{ArtifactSandboxFrame-DlWJHI-r.js → ArtifactSandboxFrame-CdsAqv8H.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-vendor-
|
|
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"./config-4_s8hdqO.js";import{a,l as o,n as s,o as c,r as l,t as u}from"./artifactHtml-DDmfpcB0.js";var d=e(t(),1),f=`${i.replace(/\/+$/,``)}/artifacts/sandbox`,p=window.location.protocol===`file:`?new URL(f).origin:window.location.origin,m=`/artifact-runtime`,h=`runtime`,g=`react`,_=`babel`,v=`tailwind`,y=`fonts`,b={react:g,"react-dom":g,"react-dom/client":g,"react/jsx-runtime":g,"react/jsx-dev-runtime":g,recharts:`recharts`,"lucide-react":`lucide-react`,d3:`d3`,three:`three`,papaparse:`papaparse`,lodash:`lodash`,"lodash-es":`lodash`,mermaid:`mermaid`,"chart.js":`chart`,"chart.js/auto":`chart`,tone:`tone`,mathjs:`mathjs`,"plotly.js":`plotly`,"plotly.js-dist-min":`plotly`,"framer-motion":`framer-motion`,"motion/react":`framer-motion`,motion:`framer-motion`,"three/addons/controls/OrbitControls.js":`three`,"three/examples/jsm/controls/OrbitControls.js":`three`},x=[h,g,_,v],S=[h,`mermaid`],C=[{pattern:/cdn\.tailwindcss\.com/i,bundle:v},{pattern:/(?:^|\/)tailwindcss(?:@[\d.]+)?(?:\/|$)/i,bundle:v},{pattern:/(?:^|\/)chart\.js(?:@[\d.]+)?(?:\/|$|\?)/i,bundle:`chart`},{pattern:/(?:^|\/)chart(?:\.min)?\.js(?:$|\?)/i,bundle:`chart`},{pattern:/(?:^|\/)d3(?:@[\d.]+)?(?:\/|$|\?)/i,bundle:`d3`},{pattern:/(?:^|\/)d3(?:\.min)?\.js(?:$|\?)/i,bundle:`d3`},{pattern:/(?:^|\/)three(?:@[\d.]+)?(?:\/|$|\?)/i,bundle:`three`},{pattern:/(?:^|\/)three(?:\.min)?\.js(?:$|\?)/i,bundle:`three`},{pattern:/papaparse/i,bundle:`papaparse`},{pattern:/(?:^|\/)lodash(?:@[\d.]+)?(?:\/|$|\?)/i,bundle:`lodash`},{pattern:/(?:^|\/)lodash(?:\.min)?\.js(?:$|\?)/i,bundle:`lodash`},{pattern:/fonts\.(?:googleapis|gstatic)\.com/i,bundle:y},{pattern:/mermaid/i,bundle:`mermaid`},{pattern:/(?:^|\/)tone(?:@[\d.]+)?(?:\/|$|\?)|tone(?:\.min)?\.js/i,bundle:`tone`},{pattern:/mathjs|math(?:\.min)?\.js/i,bundle:`mathjs`},{pattern:/plotly/i,bundle:`plotly`},{pattern:/framer-motion|(?:^|\/)motion(?:@[\d.]+)?(?:\/|$)/i,bundle:`framer-motion`},{pattern:/react-dom/i,bundle:g},{pattern:/(?:^|\/)react(?:@[\d.]+)?(?:\/|$|\?)/i,bundle:g},{pattern:/babel(?:-standalone|\/standalone)/i,bundle:_}],w=`__libreArtifactRuntime`;function T(e){if(b[e])return e;let t=C.find(({pattern:t})=>t.test(e))?.bundle??Object.values(b).find(t=>e.startsWith(`${t}/`));return t?Object.entries(b).find(([,e])=>e===t)?.[0]??null:null}function E(e){let t=new Set,n=e.matchAll(/(?:from|import|require)\s*\(?\s*['"`]([^'"`]+)['"`]/g);for(let[,e]of n){let n=T(e);n&&t.add(b[n])}return[...t]}var D=/\b(?:flex|grid|hidden|absolute|relative|(?:p|m|px|py|mx|my|mt|mb|ml|mr|gap|space)-\d|(?:w|h|max-w|min-h)-(?:\d|full|screen|auto)|text-(?:xs|sm|base|lg|xl|\dxl|center|left|right|white|black|gray-\d)|bg-(?:white|black|transparent|[a-z]+-\d)|rounded(?:-[a-z]+)?|shadow(?:-[a-z]+)?|border(?:-\d)?|items-(?:center|start|end)|justify-(?:center|between|around|end)|font-(?:bold|medium|semibold|light)|hover:[a-z-]+|(?:sm|md|lg|xl):[a-z-]+)\b/g;function O(e){let t=[...e.matchAll(/class\s*=\s*("|')(.*?)\1/gi)].map(e=>e[2]).join(` `);return new Set(t.match(D)??[]).size>=3}function k(e){let t=new Set;for(let[n,r]of Object.entries(b)){let i=n.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);RegExp(`(?:from|import|require)\\s*\\(?\\s*['"\`]${i}['"\`]`).test(e)&&t.add(r)}return[...t]}function A(e){return C.find(({pattern:t})=>t.test(e))?.bundle??null}function j(e){let t=new Set;for(let n of e.matchAll(/\b(?:src|href)\s*=\s*("|')(.*?)\1/gi))t.add(n[2]);for(let n of e.matchAll(/(?:from|import|require)\s*\(?\s*['"`]([^'"`]+)['"`]/g))t.add(n[1]);return[...t]}function M(e){let t=new Set;for(let n of j(e)){let e=A(n);e&&t.add(e)}return[...t]}var N=`35f90e513d3ddf5d`,P=new Map;function F(e){let t=P.get(e);if(t)return t;let n=fetch(`${p}${m}/${e}.js?v=${N}`,{credentials:`same-origin`,cache:`no-cache`}).then(t=>{if(!t.ok)throw Error(`The artifact runtime bundle "${e}" is unavailable (HTTP ${t.status}).`);return t.text()});return n.catch(()=>P.delete(e)),P.set(e,n),n}async function I(e){let t=await Promise.all(e.map(F));return Object.fromEntries(e.map((e,n)=>[e,t[n]]))}var L=`
|
|
2
2
|
html, body { margin: 0; min-height: 100%; }
|
|
3
3
|
body {
|
|
4
4
|
background: #ffffff;
|
package/frontend/dist/js/{ArtifactSlideOutPanel-laZ98QKB.js → ArtifactSlideOutPanel-cVd9X80o.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,r as n,t as r}from"./react-vendor-wiHys0m2.js";import{t as i}from"./logger-BR4forr_.js";import{t as ee}from"./useTranslation-B9kflK9S.js";import{t as a}from"./utils-p8Gt72YP.js";import{T as te,t as ne}from"./chatStore-CK5ojwft.js";import{$t as o,Cn as re,Fn as s,In as c,On as ie,Qn as ae,Xn as l,Yn as oe,_n as u,g as d,jn as se,n as ce,tn as le}from"./ui-vendor-BhHHyHk3.js";import{t as ue}from"./appStore-BD70bvas.js";import{t as f}from"./Button-CGMYia4g.js";import{i as de,r as p}from"./artifactHtml-DDmfpcB0.js";import{t as m}from"./OptimizedSyntaxHighlighter-CzzV6ONG.js";import{t as fe}from"./ArtifactSandboxFrame-DlWJHI-r.js";var h=e(t(),1),pe=n(),g=r(),me=i(`components:artifact-slide-out-panel`),_=320,he=.9,ge=400,_e=`(min-width: 768px)`,ve=`(min-width: 1024px)`,v=e=>{let[t,n]=(0,h.useState)(()=>typeof window<`u`&&window.matchMedia(e).matches);return(0,h.useEffect)(()=>{let t=window.matchMedia(e),r=()=>n(t.matches);return t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t},y=()=>{let{t:e,i18n:t}=ee(),n=te(t.language),{artifactPanelOpen:r,artifactPanelArtifact:i,openArtifactPanel:y,closeArtifactPanel:b,theme:x,artifactPanelWidth:S,setArtifactPanelWidth:C,artifactPanelResizing:w,setArtifactPanelResizing:T,sidebarOpen:E,sidebarCompact:D}=ue(),O=v(_e),k=v(ve)?E?D?64:288:0:E&&D?64:0,A=(0,h.useCallback)(()=>O?Math.max(_,window.innerWidth-k-ge):window.innerWidth*he,[O,k]),j=ne(e=>e.currentSession),M=h.useMemo(()=>{if(!i)return[];let e=i.title.trim().toLowerCase(),t=(j?.messages??[]).flatMap(e=>e.artifacts??[]).filter(t=>t.title.trim().toLowerCase()===e);return t.some(e=>e.id===i.id||e.content===i.content)?t:[...t,i]},[j,i]),N=M.findIndex(e=>e.id===i?.id);N===-1&&i&&(N=M.findIndex(e=>e.content===i.content));let[P,F]=(0,h.useState)(!1),[I,L]=(0,h.useState)(`preview`),R=(0,h.useRef)(null),z=(0,h.useRef)(null),B=(0,h.useRef)(0),V=(0,h.useRef)(0),H=(0,h.useRef)(null),U=(0,h.useRef)(null),W=(0,h.useRef)(S),G=i?.id??null;G!==z.current&&(z.current=G,I!==`preview`&&L(`preview`));let K=(0,h.useCallback)(e=>{W.current=e,U.current===null&&(U.current=window.requestAnimationFrame(()=>{U.current=null,C(W.current)}))},[C]),q=(0,h.useCallback)(()=>{H.current=null,T(!1),U.current!==null&&(window.cancelAnimationFrame(U.current),U.current=null,C(W.current))},[T,C]),ye=(0,h.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),H.current=e.pointerId,V.current=S,B.current=e.clientX,W.current=S,e.currentTarget.setPointerCapture(e.pointerId),T(!0)},[S,T]),J=(0,h.useCallback)(e=>{if(!w||H.current!==null&&e.pointerId!==H.current)return;e.preventDefault();let t=(B.current-e.clientX)*(n?-1:1),r=Math.min(A(),Math.max(_,V.current+t));K(r)},[w,n,K,A]);if((0,h.useEffect)(()=>{if(!w){document.body.style.userSelect=``,document.body.style.cursor=``;return}let e=e=>{(H.current===null||e.pointerId===H.current)&&q()};return window.addEventListener(`pointermove`,J,{passive:!1}),window.addEventListener(`pointerup`,e),window.addEventListener(`pointercancel`,e),window.addEventListener(`blur`,q),document.body.style.userSelect=`none`,document.body.style.cursor=`col-resize`,()=>{window.removeEventListener(`pointermove`,J),window.removeEventListener(`pointerup`,e),window.removeEventListener(`pointercancel`,e),window.removeEventListener(`blur`,q),document.body.style.userSelect=``,document.body.style.cursor=``}},[w,J,q]),(0,h.useEffect)(()=>{let e=()=>{let e=A();S>e&&C(e)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[S,C,A]),(0,h.useEffect)(()=>{if(O)return;let e=e=>{e.key===`Escape`&&r&&b()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r,b,O]),(0,h.useEffect)(()=>{if(O)return;let e=e=>{w||R.current&&!R.current.contains(e.target)&&r&&b()},t=setTimeout(()=>{window.addEventListener(`mousedown`,e)},100);return()=>{clearTimeout(t),window.removeEventListener(`mousedown`,e)}},[r,b,w,O]),!i)return null;let Y=i,be=async e=>{try{await navigator.clipboard.writeText(e),F(!0),setTimeout(()=>F(!1),2e3)}catch(e){me.error(`Failed to copy:`,e)}},xe=()=>{let e=Y.type===`html`?p(Y.content,Y.title):Y.content,t=new Blob([e],{type:Se(Y.type)}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`${Y.title}.${Ce(Y.type)}`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)},Se=e=>{switch(e){case`html`:return`text/html`;case`react`:return`text/javascript`;case`svg`:return`image/svg+xml`;case`css`:return`text/css`;case`json`:return`application/json`;default:return`text/plain`}},Ce=e=>{switch(e){case`html`:return`html`;case`react`:return`jsx`;case`svg`:return`svg`;case`css`:return`css`;case`json`:return`json`;default:return`txt`}},we=()=>{switch(Y.type){case`html`:return(0,g.jsx)(le,{className:`h-5 w-5`});case`react`:return(0,g.jsx)(s,{className:`h-5 w-5`});case`svg`:return(0,g.jsx)(u,{className:`h-5 w-5`});case`code`:return(0,g.jsx)(s,{className:`h-5 w-5`});default:return(0,g.jsx)(u,{className:`h-5 w-5`})}},X=()=>(0,g.jsx)(`div`,{"data-testid":`artifact-html-fallback`,className:`w-full h-full flex items-center justify-center bg-gray-50 dark:bg-dark-100 rounded-lg border border-gray-200 dark:border-dark-200 p-4`,children:(0,g.jsxs)(`div`,{className:`max-w-sm text-center`,children:[(0,g.jsx)(d,{className:`h-8 w-8 text-primary-500 mx-auto mb-3`}),(0,g.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`artifacts.previewUnavailable`)}),(0,g.jsx)(`p`,{className:`mt-1 text-sm text-gray-600 dark:text-gray-400`,children:e(`artifacts.previewUnavailableDescription`)}),(0,g.jsxs)(f,{variant:`outline`,size:`sm`,onClick:()=>L(`code`),className:`mt-4`,children:[(0,g.jsx)(c,{className:`h-3.5 w-3.5 me-1.5`}),e(`artifacts.code`)]})]})}),Z=e=>Y.content.trim()?(0,g.jsx)(fe,{content:Y.content,title:Y.title,kind:e,colorScheme:x.mode===`light`?`light`:`dark`,className:a(`w-full h-full border-0 rounded-lg bg-white`,w&&`pointer-events-none`),fallback:X()}):X(),Te=()=>(0,g.jsx)(`iframe`,{"data-testid":`artifact-svg-preview`,srcDoc:de(Y.content,Y.title),className:`w-full h-full border-0 rounded-lg bg-white`,sandbox:``,title:Y.title}),Q=()=>(0,g.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,g.jsx)(m,{language:(()=>{if(Y.language)return Y.language;switch(Y.type){case`html`:return`html`;case`react`:return`jsx`;case`svg`:return`xml`;case`json`:return`json`;default:return`text`}})(),isDark:x.mode!==`light`,className:`!m-0 !rounded-lg !h-full`,codeTheme:`night`,showLineNumbers:!0,backgroundColor:x.mode===`light`?void 0:`rgb(var(--color-dark-50))`,children:Y.content})}),Ee=()=>{try{let e=JSON.parse(Y.content),t=JSON.stringify(e,null,2);return(0,g.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,g.jsx)(m,{language:`json`,isDark:x.mode!==`light`,className:`!m-0 !rounded-lg !h-full`,codeTheme:`night`,showLineNumbers:!0,backgroundColor:x.mode===`light`?void 0:`rgb(var(--color-dark-50))`,children:t})})}catch{return(0,g.jsx)(`div`,{className:`w-full h-full flex items-center justify-center bg-gray-50 dark:bg-dark-100 rounded-lg`,children:(0,g.jsxs)(`div`,{className:`text-center`,children:[(0,g.jsx)(d,{className:`h-8 w-8 text-primary-500 mx-auto mb-2`}),(0,g.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-dark-600`,children:e(`artifacts.invalidJson`)})]})})}},De=()=>{if(I===`code`)return Q();switch(Y.type){case`html`:return Z(`html`);case`react`:return Z(`react`);case`mermaid`:return Z(`mermaid`);case`svg`:return Te();case`json`:return Ee();default:return Q()}},Oe=()=>Y.type===`html`||Y.type===`svg`||Y.type===`react`||Y.type===`mermaid`,$=typeof window<`u`&&window.innerWidth<640,ke=$?`100%`:`${S}px`,Ae=(0,g.jsxs)(g.Fragment,{children:[!O&&(0,g.jsx)(`div`,{className:a(`fixed inset-0 bg-black/30 dark:bg-black/50 z-40 transition-opacity duration-300`,r?`opacity-100`:`opacity-0 pointer-events-none`)}),w&&(0,g.jsx)(`div`,{className:a(`fixed inset-0 cursor-col-resize select-none`,O?`z-40`:`z-[55]`),"aria-hidden":`true`}),(0,g.jsxs)(`div`,{ref:R,"data-testid":`artifact-slide-out-panel`,style:{width:ke},className:a(`fixed top-0 end-0 h-full`,O?`z-30`:`z-50`,`bg-white dark:bg-dark-25`,`shadow-2xl border-s border-gray-200 dark:border-dark-200`,`flex flex-col`,`transform transition-transform duration-300 ease-out`,r?`translate-x-0`:`translate-x-full rtl:-translate-x-full`),children:[!$&&(0,g.jsxs)(`div`,{onPointerDown:ye,"data-testid":`artifact-resize-handle`,title:e(`artifacts.dragEdgeToResize`),className:a(`absolute start-0 top-0 bottom-0 w-4 -ms-2 cursor-col-resize z-[56]`,`flex items-center justify-center`,`touch-none select-none group`),children:[(0,g.jsx)(`div`,{className:a(`w-1 h-16 rounded-full transition-all duration-200`,`bg-gray-300 dark:bg-dark-300`,`group-hover:bg-primary-500 group-hover:h-24`,w&&`bg-primary-500 h-24`)}),(0,g.jsx)(`div`,{className:a(`absolute left-1/2 -translate-x-1/2 opacity-0 group-hover:opacity-100 transition-opacity`,`text-gray-400 dark:text-dark-500`,w&&`opacity-100`),children:(0,g.jsx)(o,{className:`h-4 w-4`})})]}),(0,g.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-gray-200 dark:border-dark-200 ps-3 pe-2 py-1.5`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 flex-1`,children:[(0,g.jsx)(`div`,{className:`text-gray-600 dark:text-gray-400 flex-shrink-0`,children:we()}),(0,g.jsx)(`h2`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100 truncate`,title:Y.description||`${e(`artifacts.created`)}: ${new Date(Y.createdAt).toLocaleString()}`,children:Y.title}),(0,g.jsx)(`span`,{className:`hidden sm:inline text-[10px] bg-primary-50 dark:bg-primary-900/20 text-primary-700 dark:text-primary-300 px-1.5 py-0.5 rounded-full font-medium flex-shrink-0`,children:Y.type.toUpperCase()})]}),M.length>1&&N!==-1&&(0,g.jsxs)(`div`,{className:`flex items-center gap-0.5 flex-shrink-0`,children:[(0,g.jsx)(f,{variant:`ghost`,size:`sm`,disabled:N===0,onClick:()=>y(M[N-1]),className:`h-7 w-7 p-0`,title:e(`artifacts.previousVersion`),children:(0,g.jsx)(l,{className:`h-3.5 w-3.5 rtl:rotate-180`})}),(0,g.jsx)(`span`,{className:`whitespace-nowrap text-xs tabular-nums text-gray-500 dark:text-dark-600`,children:e(`artifacts.versionOf`,{current:N+1,total:M.length})}),(0,g.jsx)(f,{variant:`ghost`,size:`sm`,disabled:N===M.length-1,onClick:()=>y(M[N+1]),className:`h-7 w-7 p-0`,title:e(`artifacts.nextVersion`),children:(0,g.jsx)(oe,{className:`h-3.5 w-3.5 rtl:rotate-180`})})]}),Oe()&&(0,g.jsxs)(`div`,{className:`flex items-center gap-0.5 flex-shrink-0`,children:[(0,g.jsxs)(f,{variant:I===`preview`?`primary`:`ghost`,size:`sm`,onClick:()=>L(`preview`),className:`h-7 px-2 text-xs`,title:e(`artifacts.previewMode`),children:[(0,g.jsx)(re,{className:`h-3.5 w-3.5 me-1`}),e(`artifacts.preview`)]}),(0,g.jsxs)(f,{variant:I===`code`?`primary`:`ghost`,size:`sm`,onClick:()=>L(`code`),className:`h-7 px-2 text-xs`,title:e(`artifacts.codeMode`),children:[(0,g.jsx)(c,{className:`h-3.5 w-3.5 me-1`}),e(`artifacts.code`)]})]}),(0,g.jsxs)(`div`,{className:`flex items-center gap-0.5 flex-shrink-0`,children:[(0,g.jsx)(f,{variant:`ghost`,size:`sm`,onClick:()=>be(Y.content),className:`h-7 w-7 p-0 hover:bg-gray-100 dark:hover:bg-dark-200`,title:e(`artifacts.copyContent`),children:P?(0,g.jsx)(ae,{className:`h-3.5 w-3.5 text-green-500`}):(0,g.jsx)(se,{className:`h-3.5 w-3.5`})}),(0,g.jsx)(f,{variant:`ghost`,size:`sm`,onClick:xe,className:`h-7 w-7 p-0 hover:bg-gray-100 dark:hover:bg-dark-200`,title:e(`artifacts.download`),children:(0,g.jsx)(ie,{className:`h-3.5 w-3.5`})}),(0,g.jsx)(f,{variant:`ghost`,size:`sm`,onClick:b,className:`h-7 w-7 p-0 hover:bg-gray-100 dark:hover:bg-dark-200`,title:e(O?`common.close`:`artifacts.closePanelEsc`),children:(0,g.jsx)(ce,{className:`h-4 w-4`})})]})]}),(0,g.jsx)(`div`,{className:`flex-1 p-2 overflow-hidden`,children:De()})]})]});return(0,pe.createPortal)(Ae,document.body)};export{y as ArtifactSlideOutPanel};
|
|
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"./logger-BR4forr_.js";import{T as ee,t as te}from"./chatStore-DpVxt9VX.js";import{t as ne}from"./useTranslation-Boi0fB1B.js";import{t as a}from"./utils-B-Bhh1pF.js";import{$t as o,Cn as re,Fn as s,In as c,On as ie,Qn as ae,Xn as l,Yn as oe,_n as u,g as d,jn as se,n as ce,tn as le}from"./ui-vendor-DVTj_sKN.js";import{t as f}from"./Button-j68Q8KVh.js";import{t as ue}from"./appStore-DkRdQQeY.js";import{i as de,r as p}from"./artifactHtml-DDmfpcB0.js";import{t as m}from"./OptimizedSyntaxHighlighter-B0g8cxZQ.js";import{t as fe}from"./ArtifactSandboxFrame-CdsAqv8H.js";var h=e(t(),1),pe=n(),g=r(),me=i(`components:artifact-slide-out-panel`),_=320,he=.9,ge=400,_e=`(min-width: 768px)`,ve=`(min-width: 1024px)`,v=e=>{let[t,n]=(0,h.useState)(()=>typeof window<`u`&&window.matchMedia(e).matches);return(0,h.useEffect)(()=>{let t=window.matchMedia(e),r=()=>n(t.matches);return t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t},y=()=>{let{t:e,i18n:t}=ne(),n=ee(t.language),{artifactPanelOpen:r,artifactPanelArtifact:i,openArtifactPanel:y,closeArtifactPanel:b,theme:x,artifactPanelWidth:S,setArtifactPanelWidth:C,artifactPanelResizing:w,setArtifactPanelResizing:T,sidebarOpen:E,sidebarCompact:D}=ue(),O=v(_e),k=v(ve)?E?D?64:288:0:E&&D?64:0,A=(0,h.useCallback)(()=>O?Math.max(_,window.innerWidth-k-ge):window.innerWidth*he,[O,k]),j=te(e=>e.currentSession),M=h.useMemo(()=>{if(!i)return[];let e=i.title.trim().toLowerCase(),t=(j?.messages??[]).flatMap(e=>e.artifacts??[]).filter(t=>t.title.trim().toLowerCase()===e);return t.some(e=>e.id===i.id||e.content===i.content)?t:[...t,i]},[j,i]),N=M.findIndex(e=>e.id===i?.id);N===-1&&i&&(N=M.findIndex(e=>e.content===i.content));let[P,F]=(0,h.useState)(!1),[I,L]=(0,h.useState)(`preview`),R=(0,h.useRef)(null),z=(0,h.useRef)(null),B=(0,h.useRef)(0),V=(0,h.useRef)(0),H=(0,h.useRef)(null),U=(0,h.useRef)(null),W=(0,h.useRef)(S),G=i?.id??null;G!==z.current&&(z.current=G,I!==`preview`&&L(`preview`));let K=(0,h.useCallback)(e=>{W.current=e,U.current===null&&(U.current=window.requestAnimationFrame(()=>{U.current=null,C(W.current)}))},[C]),q=(0,h.useCallback)(()=>{H.current=null,T(!1),U.current!==null&&(window.cancelAnimationFrame(U.current),U.current=null,C(W.current))},[T,C]),ye=(0,h.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),H.current=e.pointerId,V.current=S,B.current=e.clientX,W.current=S,e.currentTarget.setPointerCapture(e.pointerId),T(!0)},[S,T]),J=(0,h.useCallback)(e=>{if(!w||H.current!==null&&e.pointerId!==H.current)return;e.preventDefault();let t=(B.current-e.clientX)*(n?-1:1),r=Math.min(A(),Math.max(_,V.current+t));K(r)},[w,n,K,A]);if((0,h.useEffect)(()=>{if(!w){document.body.style.userSelect=``,document.body.style.cursor=``;return}let e=e=>{(H.current===null||e.pointerId===H.current)&&q()};return window.addEventListener(`pointermove`,J,{passive:!1}),window.addEventListener(`pointerup`,e),window.addEventListener(`pointercancel`,e),window.addEventListener(`blur`,q),document.body.style.userSelect=`none`,document.body.style.cursor=`col-resize`,()=>{window.removeEventListener(`pointermove`,J),window.removeEventListener(`pointerup`,e),window.removeEventListener(`pointercancel`,e),window.removeEventListener(`blur`,q),document.body.style.userSelect=``,document.body.style.cursor=``}},[w,J,q]),(0,h.useEffect)(()=>{let e=()=>{let e=A();S>e&&C(e)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[S,C,A]),(0,h.useEffect)(()=>{if(O)return;let e=e=>{e.key===`Escape`&&r&&b()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r,b,O]),(0,h.useEffect)(()=>{if(O)return;let e=e=>{w||R.current&&!R.current.contains(e.target)&&r&&b()},t=setTimeout(()=>{window.addEventListener(`mousedown`,e)},100);return()=>{clearTimeout(t),window.removeEventListener(`mousedown`,e)}},[r,b,w,O]),!i)return null;let Y=i,be=async e=>{try{await navigator.clipboard.writeText(e),F(!0),setTimeout(()=>F(!1),2e3)}catch(e){me.error(`Failed to copy:`,e)}},xe=()=>{let e=Y.type===`html`?p(Y.content,Y.title):Y.content,t=new Blob([e],{type:Se(Y.type)}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`${Y.title}.${Ce(Y.type)}`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)},Se=e=>{switch(e){case`html`:return`text/html`;case`react`:return`text/javascript`;case`svg`:return`image/svg+xml`;case`css`:return`text/css`;case`json`:return`application/json`;default:return`text/plain`}},Ce=e=>{switch(e){case`html`:return`html`;case`react`:return`jsx`;case`svg`:return`svg`;case`css`:return`css`;case`json`:return`json`;default:return`txt`}},we=()=>{switch(Y.type){case`html`:return(0,g.jsx)(le,{className:`h-5 w-5`});case`react`:return(0,g.jsx)(s,{className:`h-5 w-5`});case`svg`:return(0,g.jsx)(u,{className:`h-5 w-5`});case`code`:return(0,g.jsx)(s,{className:`h-5 w-5`});default:return(0,g.jsx)(u,{className:`h-5 w-5`})}},X=()=>(0,g.jsx)(`div`,{"data-testid":`artifact-html-fallback`,className:`w-full h-full flex items-center justify-center bg-gray-50 dark:bg-dark-100 rounded-lg border border-gray-200 dark:border-dark-200 p-4`,children:(0,g.jsxs)(`div`,{className:`max-w-sm text-center`,children:[(0,g.jsx)(d,{className:`h-8 w-8 text-primary-500 mx-auto mb-3`}),(0,g.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`artifacts.previewUnavailable`)}),(0,g.jsx)(`p`,{className:`mt-1 text-sm text-gray-600 dark:text-gray-400`,children:e(`artifacts.previewUnavailableDescription`)}),(0,g.jsxs)(f,{variant:`outline`,size:`sm`,onClick:()=>L(`code`),className:`mt-4`,children:[(0,g.jsx)(c,{className:`h-3.5 w-3.5 me-1.5`}),e(`artifacts.code`)]})]})}),Z=e=>Y.content.trim()?(0,g.jsx)(fe,{content:Y.content,title:Y.title,kind:e,colorScheme:x.mode===`light`?`light`:`dark`,className:a(`w-full h-full border-0 rounded-lg bg-white`,w&&`pointer-events-none`),fallback:X()}):X(),Te=()=>(0,g.jsx)(`iframe`,{"data-testid":`artifact-svg-preview`,srcDoc:de(Y.content,Y.title),className:`w-full h-full border-0 rounded-lg bg-white`,sandbox:``,title:Y.title}),Q=()=>(0,g.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,g.jsx)(m,{language:(()=>{if(Y.language)return Y.language;switch(Y.type){case`html`:return`html`;case`react`:return`jsx`;case`svg`:return`xml`;case`json`:return`json`;default:return`text`}})(),isDark:x.mode!==`light`,className:`!m-0 !rounded-lg !h-full`,codeTheme:`night`,showLineNumbers:!0,backgroundColor:x.mode===`light`?void 0:`rgb(var(--color-dark-50))`,children:Y.content})}),Ee=()=>{try{let e=JSON.parse(Y.content),t=JSON.stringify(e,null,2);return(0,g.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,g.jsx)(m,{language:`json`,isDark:x.mode!==`light`,className:`!m-0 !rounded-lg !h-full`,codeTheme:`night`,showLineNumbers:!0,backgroundColor:x.mode===`light`?void 0:`rgb(var(--color-dark-50))`,children:t})})}catch{return(0,g.jsx)(`div`,{className:`w-full h-full flex items-center justify-center bg-gray-50 dark:bg-dark-100 rounded-lg`,children:(0,g.jsxs)(`div`,{className:`text-center`,children:[(0,g.jsx)(d,{className:`h-8 w-8 text-primary-500 mx-auto mb-2`}),(0,g.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-dark-600`,children:e(`artifacts.invalidJson`)})]})})}},De=()=>{if(I===`code`)return Q();switch(Y.type){case`html`:return Z(`html`);case`react`:return Z(`react`);case`mermaid`:return Z(`mermaid`);case`svg`:return Te();case`json`:return Ee();default:return Q()}},Oe=()=>Y.type===`html`||Y.type===`svg`||Y.type===`react`||Y.type===`mermaid`,$=typeof window<`u`&&window.innerWidth<640,ke=$?`100%`:`${S}px`,Ae=(0,g.jsxs)(g.Fragment,{children:[!O&&(0,g.jsx)(`div`,{className:a(`fixed inset-0 bg-black/30 dark:bg-black/50 z-40 transition-opacity duration-300`,r?`opacity-100`:`opacity-0 pointer-events-none`)}),w&&(0,g.jsx)(`div`,{className:a(`fixed inset-0 cursor-col-resize select-none`,O?`z-40`:`z-[55]`),"aria-hidden":`true`}),(0,g.jsxs)(`div`,{ref:R,"data-testid":`artifact-slide-out-panel`,style:{width:ke},className:a(`fixed top-0 end-0 h-full`,O?`z-30`:`z-50`,`bg-white dark:bg-dark-25`,`shadow-2xl border-s border-gray-200 dark:border-dark-200`,`flex flex-col`,`transform transition-transform duration-300 ease-out`,r?`translate-x-0`:`translate-x-full rtl:-translate-x-full`),children:[!$&&(0,g.jsxs)(`div`,{onPointerDown:ye,"data-testid":`artifact-resize-handle`,title:e(`artifacts.dragEdgeToResize`),className:a(`absolute start-0 top-0 bottom-0 w-4 -ms-2 cursor-col-resize z-[56]`,`flex items-center justify-center`,`touch-none select-none group`),children:[(0,g.jsx)(`div`,{className:a(`w-1 h-16 rounded-full transition-all duration-200`,`bg-gray-300 dark:bg-dark-300`,`group-hover:bg-primary-500 group-hover:h-24`,w&&`bg-primary-500 h-24`)}),(0,g.jsx)(`div`,{className:a(`absolute left-1/2 -translate-x-1/2 opacity-0 group-hover:opacity-100 transition-opacity`,`text-gray-400 dark:text-dark-500`,w&&`opacity-100`),children:(0,g.jsx)(o,{className:`h-4 w-4`})})]}),(0,g.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-gray-200 dark:border-dark-200 ps-3 pe-2 py-1.5`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 flex-1`,children:[(0,g.jsx)(`div`,{className:`text-gray-600 dark:text-gray-400 flex-shrink-0`,children:we()}),(0,g.jsx)(`h2`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100 truncate`,title:Y.description||`${e(`artifacts.created`)}: ${new Date(Y.createdAt).toLocaleString()}`,children:Y.title}),(0,g.jsx)(`span`,{className:`hidden sm:inline text-[10px] bg-primary-50 dark:bg-primary-900/20 text-primary-700 dark:text-primary-300 px-1.5 py-0.5 rounded-full font-medium flex-shrink-0`,children:Y.type.toUpperCase()})]}),M.length>1&&N!==-1&&(0,g.jsxs)(`div`,{className:`flex items-center gap-0.5 flex-shrink-0`,children:[(0,g.jsx)(f,{variant:`ghost`,size:`sm`,disabled:N===0,onClick:()=>y(M[N-1]),className:`h-7 w-7 p-0`,title:e(`artifacts.previousVersion`),children:(0,g.jsx)(l,{className:`h-3.5 w-3.5 rtl:rotate-180`})}),(0,g.jsx)(`span`,{className:`whitespace-nowrap text-xs tabular-nums text-gray-500 dark:text-dark-600`,children:e(`artifacts.versionOf`,{current:N+1,total:M.length})}),(0,g.jsx)(f,{variant:`ghost`,size:`sm`,disabled:N===M.length-1,onClick:()=>y(M[N+1]),className:`h-7 w-7 p-0`,title:e(`artifacts.nextVersion`),children:(0,g.jsx)(oe,{className:`h-3.5 w-3.5 rtl:rotate-180`})})]}),Oe()&&(0,g.jsxs)(`div`,{className:`flex items-center gap-0.5 flex-shrink-0`,children:[(0,g.jsxs)(f,{variant:I===`preview`?`primary`:`ghost`,size:`sm`,onClick:()=>L(`preview`),className:`h-7 px-2 text-xs`,title:e(`artifacts.previewMode`),children:[(0,g.jsx)(re,{className:`h-3.5 w-3.5 me-1`}),e(`artifacts.preview`)]}),(0,g.jsxs)(f,{variant:I===`code`?`primary`:`ghost`,size:`sm`,onClick:()=>L(`code`),className:`h-7 px-2 text-xs`,title:e(`artifacts.codeMode`),children:[(0,g.jsx)(c,{className:`h-3.5 w-3.5 me-1`}),e(`artifacts.code`)]})]}),(0,g.jsxs)(`div`,{className:`flex items-center gap-0.5 flex-shrink-0`,children:[(0,g.jsx)(f,{variant:`ghost`,size:`sm`,onClick:()=>be(Y.content),className:`h-7 w-7 p-0 hover:bg-gray-100 dark:hover:bg-dark-200`,title:e(`artifacts.copyContent`),children:P?(0,g.jsx)(ae,{className:`h-3.5 w-3.5 text-green-500`}):(0,g.jsx)(se,{className:`h-3.5 w-3.5`})}),(0,g.jsx)(f,{variant:`ghost`,size:`sm`,onClick:xe,className:`h-7 w-7 p-0 hover:bg-gray-100 dark:hover:bg-dark-200`,title:e(`artifacts.download`),children:(0,g.jsx)(ie,{className:`h-3.5 w-3.5`})}),(0,g.jsx)(f,{variant:`ghost`,size:`sm`,onClick:b,className:`h-7 w-7 p-0 hover:bg-gray-100 dark:hover:bg-dark-200`,title:e(O?`common.close`:`artifacts.closePanelEsc`),children:(0,g.jsx)(ce,{className:`h-4 w-4`})})]})]}),(0,g.jsx)(`div`,{className:`flex-1 p-2 overflow-hidden`,children:De()})]})]});return(0,pe.createPortal)(Ae,document.body)};export{y as ArtifactSlideOutPanel};
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
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 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-vendor-
|
|
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 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime-hePW80VL.js";import{i as e,t}from"./react-vendor-
|
|
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 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,r as n,t as r}from"./react-vendor-wiHys0m2.js";import{d as i}from"./router-vendor-HZm4FR0A.js";import{t as a}from"./logger-BR4forr_.js";import{t as o}from"./useTranslation-B9kflK9S.js";import{t as s}from"./utils-p8Gt72YP.js";import{B as c,On as l,Xn as u,Yn as d,et as f,n as p,p as m,v as h,wr as g}from"./ui-vendor-BhHHyHk3.js";import{E as _,k as v}from"./api-DPXCtanG.js";import{t as y}from"./Button-CGMYia4g.js";import"./ui-D5-4niRk.js";import{t as b}from"./ShareDialog-Bhpt_Y1N.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,m]=(0,M.useState)(e?.notes??``),[g,_]=(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()||!g)return;let e=E(g,C?``:v),t=!C&&b?E(g,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)(p,{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:g,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=>m(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)(h,{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`),[h,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(h.getFullYear(),h.getMonth(),1),t=D(e);return{from:t.getTime(),to:A(t,42).getTime()}}if(r===`day`){let e=new Date(h.getFullYear(),h.getMonth(),h.getDate());return{from:e.getTime(),to:A(e,1).getTime()}}let e=D(h);return{from:e.getTime(),to:A(e,7).getTime()}},[h,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),g.error(e(`calendar.loadFailed`)))}),Promise.all([_.getOccurrences(X.from,X.to),_.getRuns({from:X.from,to:X.to}),_.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`){g(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()):g.error(n.error||e(`calendar.saveFailed`))}catch(t){G.error(`Failed to save calendar event:`,t),g.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()):g.error(t.error||e(`calendar.deleteFailed`))}catch(t){G.error(`Failed to delete calendar event:`,t),g.error(e(`calendar.deleteFailed`))}finally{z(!1)}}},ce=r===`month`?x(h.getFullYear(),h.getMonth(),t.language):new Intl.DateTimeFormat(t.language,{month:`long`,day:`numeric`,year:`numeric`}).format(r===`day`?h:D(h)),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()):g.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),g.error(e(`calendar.exportFailed`))}},de=async t=>{try{let n=await t.text(),r=await v.importIcs(n);r.success&&r.data?(g.success(e(`calendar.importResult`,{total:r.data.imported})),Q()):g.error(r.error||e(`calendar.importFailed`))}catch(t){G.error(`Failed to import the calendar:`,t),g.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)(y,{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)(u,{className:`h-4 w-4 rtl:rotate-180`})}),(0,N.jsx)(y,{size:`sm`,variant:`ghost`,onClick:()=>S(new Date),className:`h-7 px-2 text-[12px]`,children:e(`calendar.today`)}),(0,N.jsx)(y,{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)(d,{className:`h-4 w-4 rtl:rotate-180`})})]}),(0,N.jsxs)(y,{size:`sm`,onClick:()=>$(h),"data-testid":`calendar-new-event`,className:`h-7 gap-1 px-2.5 text-[12px]`,children:[(0,N.jsx)(f,{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)(p,{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)(y,{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)(y,{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)(m,{className:`h-3.5 w-3.5`}),e(`calendar.importIcs`)]}),(0,N.jsxs)(y,{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:h.getFullYear(),monthIndex:h.getMonth(),events:re,onDayClick:e=>$(e),onEventClick:ae}):(0,N.jsx)(ee,{anchor:h,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
|
+
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};
|
|
@@ -0,0 +1 @@
|
|
|
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};
|