libre-webui 0.25.0 → 0.26.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 +32 -22
- package/backend/dist/index.d.ts.map +1 -1
- package/backend/dist/index.js +26 -4
- package/backend/dist/index.js.map +1 -1
- package/backend/dist/middleware/auth.d.ts +7 -0
- package/backend/dist/middleware/auth.d.ts.map +1 -1
- package/backend/dist/middleware/auth.js +26 -0
- package/backend/dist/middleware/auth.js.map +1 -1
- package/backend/dist/middleware/index.d.ts +20 -0
- package/backend/dist/middleware/index.d.ts.map +1 -1
- package/backend/dist/middleware/index.js +105 -2
- package/backend/dist/middleware/index.js.map +1 -1
- package/backend/dist/models/personaModel.d.ts.map +1 -1
- package/backend/dist/models/personaModel.js +2 -0
- package/backend/dist/models/personaModel.js.map +1 -1
- package/backend/dist/observability/otel.d.ts +40 -0
- package/backend/dist/observability/otel.d.ts.map +1 -0
- package/backend/dist/observability/otel.js +337 -0
- package/backend/dist/observability/otel.js.map +1 -0
- package/backend/dist/observability/requestContext.d.ts +14 -0
- package/backend/dist/observability/requestContext.d.ts.map +1 -0
- package/backend/dist/observability/requestContext.js +21 -0
- package/backend/dist/observability/requestContext.js.map +1 -0
- package/backend/dist/persistence/chatGenerationTypes.d.ts +9 -0
- package/backend/dist/persistence/chatGenerationTypes.d.ts.map +1 -1
- package/backend/dist/persistence/extensionTypes.d.ts +13 -0
- package/backend/dist/persistence/extensionTypes.d.ts.map +1 -1
- package/backend/dist/persistence/extensionTypes.js.map +1 -1
- package/backend/dist/persistence/index.d.ts +1 -1
- package/backend/dist/persistence/index.d.ts.map +1 -1
- package/backend/dist/persistence/index.js.map +1 -1
- package/backend/dist/persistence/postgresAgentFoundationMigration.d.ts +9 -0
- package/backend/dist/persistence/postgresAgentFoundationMigration.d.ts.map +1 -0
- package/backend/dist/persistence/postgresAgentFoundationMigration.js +164 -0
- package/backend/dist/persistence/postgresAgentFoundationMigration.js.map +1 -0
- package/backend/dist/persistence/postgresExtensionRepositories.d.ts.map +1 -1
- package/backend/dist/persistence/postgresExtensionRepositories.js +46 -2
- package/backend/dist/persistence/postgresExtensionRepositories.js.map +1 -1
- package/backend/dist/persistence/postgresMediaEnterpriseOpsMigration.d.ts +10 -0
- package/backend/dist/persistence/postgresMediaEnterpriseOpsMigration.d.ts.map +1 -0
- package/backend/dist/persistence/postgresMediaEnterpriseOpsMigration.js +148 -0
- package/backend/dist/persistence/postgresMediaEnterpriseOpsMigration.js.map +1 -0
- package/backend/dist/persistence/postgresMigrationRegistry.d.ts.map +1 -1
- package/backend/dist/persistence/postgresMigrationRegistry.js +10 -0
- package/backend/dist/persistence/postgresMigrationRegistry.js.map +1 -1
- package/backend/dist/persistence/postgresNotesV2Migration.d.ts +4 -0
- package/backend/dist/persistence/postgresNotesV2Migration.d.ts.map +1 -0
- package/backend/dist/persistence/postgresNotesV2Migration.js +57 -0
- package/backend/dist/persistence/postgresNotesV2Migration.js.map +1 -0
- package/backend/dist/persistence/postgresResourceRepositories.d.ts.map +1 -1
- package/backend/dist/persistence/postgresResourceRepositories.js +1646 -11
- package/backend/dist/persistence/postgresResourceRepositories.js.map +1 -1
- package/backend/dist/persistence/postgresSkillFilesMigration.d.ts +9 -0
- package/backend/dist/persistence/postgresSkillFilesMigration.d.ts.map +1 -0
- package/backend/dist/persistence/postgresSkillFilesMigration.js +50 -0
- package/backend/dist/persistence/postgresSkillFilesMigration.js.map +1 -0
- package/backend/dist/persistence/postgresTeamCollaborationMigration.d.ts +10 -0
- package/backend/dist/persistence/postgresTeamCollaborationMigration.d.ts.map +1 -0
- package/backend/dist/persistence/postgresTeamCollaborationMigration.js +161 -0
- package/backend/dist/persistence/postgresTeamCollaborationMigration.js.map +1 -0
- package/backend/dist/persistence/resourceTypes.d.ts +541 -3
- package/backend/dist/persistence/resourceTypes.d.ts.map +1 -1
- package/backend/dist/persistence/resourceTypes.js.map +1 -1
- package/backend/dist/persistence/sqliteExtensionRepositories.d.ts.map +1 -1
- package/backend/dist/persistence/sqliteExtensionRepositories.js +26 -4
- package/backend/dist/persistence/sqliteExtensionRepositories.js.map +1 -1
- package/backend/dist/persistence/sqliteMigrations.d.ts +9 -0
- package/backend/dist/persistence/sqliteMigrations.d.ts.map +1 -1
- package/backend/dist/persistence/sqliteMigrations.js +1196 -29
- package/backend/dist/persistence/sqliteMigrations.js.map +1 -1
- package/backend/dist/persistence/sqliteResourceRepositories.d.ts.map +1 -1
- package/backend/dist/persistence/sqliteResourceRepositories.js +1523 -134
- package/backend/dist/persistence/sqliteResourceRepositories.js.map +1 -1
- package/backend/dist/persistence/sqliteToPostgresMigration.d.ts.map +1 -1
- package/backend/dist/persistence/sqliteToPostgresMigration.js +257 -3
- package/backend/dist/persistence/sqliteToPostgresMigration.js.map +1 -1
- package/backend/dist/platform/jobs/domainJobContracts.d.ts +8 -0
- package/backend/dist/platform/jobs/domainJobContracts.d.ts.map +1 -1
- package/backend/dist/platform/jobs/domainJobContracts.js +8 -0
- package/backend/dist/platform/jobs/domainJobContracts.js.map +1 -1
- package/backend/dist/platform/jobs/domainJobHandlers.d.ts.map +1 -1
- package/backend/dist/platform/jobs/domainJobHandlers.js +310 -3
- package/backend/dist/platform/jobs/domainJobHandlers.js.map +1 -1
- package/backend/dist/platform/jobs/embeddedDurableJobWorker.d.ts.map +1 -1
- package/backend/dist/platform/jobs/embeddedDurableJobWorker.js +4 -2
- package/backend/dist/platform/jobs/embeddedDurableJobWorker.js.map +1 -1
- package/backend/dist/platform/jobs/postgresDurableJobWorker.d.ts.map +1 -1
- package/backend/dist/platform/jobs/postgresDurableJobWorker.js +4 -2
- package/backend/dist/platform/jobs/postgresDurableJobWorker.js.map +1 -1
- package/backend/dist/platform/storage/pgVectorStore.d.ts +2 -1
- package/backend/dist/platform/storage/pgVectorStore.d.ts.map +1 -1
- package/backend/dist/platform/storage/pgVectorStore.js +51 -0
- package/backend/dist/platform/storage/pgVectorStore.js.map +1 -1
- package/backend/dist/platform/storage/platformDomainRepositories.d.ts +8 -2
- package/backend/dist/platform/storage/platformDomainRepositories.d.ts.map +1 -1
- package/backend/dist/platform/storage/postgresPlatformDomainRepositories.d.ts.map +1 -1
- package/backend/dist/platform/storage/postgresPlatformDomainRepositories.js +25 -4
- package/backend/dist/platform/storage/postgresPlatformDomainRepositories.js.map +1 -1
- package/backend/dist/platform/storage/sqliteEncryptedVectorStore.d.ts +2 -1
- package/backend/dist/platform/storage/sqliteEncryptedVectorStore.d.ts.map +1 -1
- package/backend/dist/platform/storage/sqliteEncryptedVectorStore.js +35 -0
- package/backend/dist/platform/storage/sqliteEncryptedVectorStore.js.map +1 -1
- package/backend/dist/platform/storage/sqlitePlatformDomainRepositories.d.ts.map +1 -1
- package/backend/dist/platform/storage/sqlitePlatformDomainRepositories.js +26 -3
- package/backend/dist/platform/storage/sqlitePlatformDomainRepositories.js.map +1 -1
- package/backend/dist/platform/storage/vectorStore.d.ts +14 -0
- package/backend/dist/platform/storage/vectorStore.d.ts.map +1 -1
- package/backend/dist/platform/storage/vectorStore.js.map +1 -1
- package/backend/dist/routes/access.d.ts.map +1 -1
- package/backend/dist/routes/access.js +84 -3
- package/backend/dist/routes/access.js.map +1 -1
- package/backend/dist/routes/calendar.d.ts.map +1 -1
- package/backend/dist/routes/calendar.js +125 -22
- package/backend/dist/routes/calendar.js.map +1 -1
- package/backend/dist/routes/channels.d.ts +3 -0
- package/backend/dist/routes/channels.d.ts.map +1 -0
- package/backend/dist/routes/channels.js +447 -0
- package/backend/dist/routes/channels.js.map +1 -0
- package/backend/dist/routes/chat.d.ts.map +1 -1
- package/backend/dist/routes/chat.js +195 -7
- package/backend/dist/routes/chat.js.map +1 -1
- package/backend/dist/routes/costs.d.ts +3 -0
- package/backend/dist/routes/costs.d.ts.map +1 -0
- package/backend/dist/routes/costs.js +191 -0
- package/backend/dist/routes/costs.js.map +1 -0
- package/backend/dist/routes/documents.d.ts.map +1 -1
- package/backend/dist/routes/documents.js +64 -21
- package/backend/dist/routes/documents.js.map +1 -1
- package/backend/dist/routes/evaluations.d.ts +3 -0
- package/backend/dist/routes/evaluations.d.ts.map +1 -0
- package/backend/dist/routes/evaluations.js +352 -0
- package/backend/dist/routes/evaluations.js.map +1 -0
- package/backend/dist/routes/imageGen.d.ts.map +1 -1
- package/backend/dist/routes/imageGen.js +2 -1
- package/backend/dist/routes/imageGen.js.map +1 -1
- package/backend/dist/routes/media.d.ts.map +1 -1
- package/backend/dist/routes/media.js +228 -7
- package/backend/dist/routes/media.js.map +1 -1
- package/backend/dist/routes/notes.d.ts.map +1 -1
- package/backend/dist/routes/notes.js +149 -36
- package/backend/dist/routes/notes.js.map +1 -1
- package/backend/dist/routes/notifications.d.ts +3 -0
- package/backend/dist/routes/notifications.d.ts.map +1 -0
- package/backend/dist/routes/notifications.js +213 -0
- package/backend/dist/routes/notifications.js.map +1 -0
- package/backend/dist/routes/openaiCompat.d.ts +3 -0
- package/backend/dist/routes/openaiCompat.d.ts.map +1 -0
- package/backend/dist/routes/openaiCompat.js +314 -0
- package/backend/dist/routes/openaiCompat.js.map +1 -0
- package/backend/dist/routes/personas.js +1 -1
- package/backend/dist/routes/personas.js.map +1 -1
- package/backend/dist/routes/prompts.d.ts +3 -0
- package/backend/dist/routes/prompts.d.ts.map +1 -0
- package/backend/dist/routes/prompts.js +173 -0
- package/backend/dist/routes/prompts.js.map +1 -0
- package/backend/dist/routes/search.d.ts.map +1 -1
- package/backend/dist/routes/search.js +29 -1
- package/backend/dist/routes/search.js.map +1 -1
- package/backend/dist/routes/skills.d.ts +3 -0
- package/backend/dist/routes/skills.d.ts.map +1 -0
- package/backend/dist/routes/skills.js +246 -0
- package/backend/dist/routes/skills.js.map +1 -0
- package/backend/dist/routes/stt.d.ts.map +1 -1
- package/backend/dist/routes/stt.js +2 -1
- package/backend/dist/routes/stt.js.map +1 -1
- package/backend/dist/routes/tools.d.ts +3 -0
- package/backend/dist/routes/tools.d.ts.map +1 -0
- package/backend/dist/routes/tools.js +359 -0
- package/backend/dist/routes/tools.js.map +1 -0
- package/backend/dist/routes/tts.d.ts.map +1 -1
- package/backend/dist/routes/tts.js +63 -8
- package/backend/dist/routes/tts.js.map +1 -1
- package/backend/dist/routes/voiceAccess.d.ts +3 -0
- package/backend/dist/routes/voiceAccess.d.ts.map +1 -0
- package/backend/dist/routes/voiceAccess.js +102 -0
- package/backend/dist/routes/voiceAccess.js.map +1 -0
- package/backend/dist/services/apiTokenService.d.ts +2 -2
- package/backend/dist/services/apiTokenService.d.ts.map +1 -1
- package/backend/dist/services/apiTokenService.js +7 -0
- package/backend/dist/services/apiTokenService.js.map +1 -1
- package/backend/dist/services/authorizationService.d.ts +8 -4
- package/backend/dist/services/authorizationService.d.ts.map +1 -1
- package/backend/dist/services/authorizationService.js +31 -1
- package/backend/dist/services/authorizationService.js.map +1 -1
- package/backend/dist/services/automationSchedulerService.d.ts.map +1 -1
- package/backend/dist/services/automationSchedulerService.js +33 -3
- package/backend/dist/services/automationSchedulerService.js.map +1 -1
- package/backend/dist/services/automationService.d.ts +4 -1
- package/backend/dist/services/automationService.d.ts.map +1 -1
- package/backend/dist/services/automationService.js +25 -2
- package/backend/dist/services/automationService.js.map +1 -1
- package/backend/dist/services/builtinToolsService.d.ts +20 -0
- package/backend/dist/services/builtinToolsService.d.ts.map +1 -0
- package/backend/dist/services/builtinToolsService.js +661 -0
- package/backend/dist/services/builtinToolsService.js.map +1 -0
- package/backend/dist/services/calendarService.d.ts +74 -0
- package/backend/dist/services/calendarService.d.ts.map +1 -0
- package/backend/dist/services/calendarService.js +339 -0
- package/backend/dist/services/calendarService.js.map +1 -0
- package/backend/dist/services/channelService.d.ts +195 -0
- package/backend/dist/services/channelService.d.ts.map +1 -0
- package/backend/dist/services/channelService.js +1057 -0
- package/backend/dist/services/channelService.js.map +1 -0
- package/backend/dist/services/chatRequestService.d.ts.map +1 -1
- package/backend/dist/services/chatRequestService.js +29 -1
- package/backend/dist/services/chatRequestService.js.map +1 -1
- package/backend/dist/services/chatService.d.ts +61 -1
- package/backend/dist/services/chatService.d.ts.map +1 -1
- package/backend/dist/services/chatService.js +218 -1
- package/backend/dist/services/chatService.js.map +1 -1
- package/backend/dist/services/chatToolRuntimeService.d.ts +55 -0
- package/backend/dist/services/chatToolRuntimeService.d.ts.map +1 -0
- package/backend/dist/services/chatToolRuntimeService.js +389 -0
- package/backend/dist/services/chatToolRuntimeService.js.map +1 -0
- package/backend/dist/services/costGovernanceService.d.ts +102 -0
- package/backend/dist/services/costGovernanceService.d.ts.map +1 -0
- package/backend/dist/services/costGovernanceService.js +463 -0
- package/backend/dist/services/costGovernanceService.js.map +1 -0
- package/backend/dist/services/dataArchiveService.d.ts +6 -0
- package/backend/dist/services/dataArchiveService.d.ts.map +1 -1
- package/backend/dist/services/dataArchiveService.js +23 -4
- package/backend/dist/services/dataArchiveService.js.map +1 -1
- package/backend/dist/services/documentService.d.ts +58 -1
- package/backend/dist/services/documentService.d.ts.map +1 -1
- package/backend/dist/services/documentService.js +289 -84
- package/backend/dist/services/documentService.js.map +1 -1
- package/backend/dist/services/durableChatGenerationService.d.ts +9 -0
- package/backend/dist/services/durableChatGenerationService.d.ts.map +1 -1
- package/backend/dist/services/durableChatGenerationService.js +152 -11
- package/backend/dist/services/durableChatGenerationService.js.map +1 -1
- package/backend/dist/services/evaluationService.d.ts +111 -0
- package/backend/dist/services/evaluationService.d.ts.map +1 -0
- package/backend/dist/services/evaluationService.js +403 -0
- package/backend/dist/services/evaluationService.js.map +1 -0
- package/backend/dist/services/galleryService.d.ts +6 -0
- package/backend/dist/services/galleryService.d.ts.map +1 -1
- package/backend/dist/services/galleryService.js +26 -0
- package/backend/dist/services/galleryService.js.map +1 -1
- package/backend/dist/services/mcpClientService.d.ts +29 -0
- package/backend/dist/services/mcpClientService.d.ts.map +1 -0
- package/backend/dist/services/mcpClientService.js +189 -0
- package/backend/dist/services/mcpClientService.js.map +1 -0
- package/backend/dist/services/noteService.d.ts +71 -0
- package/backend/dist/services/noteService.d.ts.map +1 -0
- package/backend/dist/services/noteService.js +397 -0
- package/backend/dist/services/noteService.js.map +1 -0
- package/backend/dist/services/notificationService.d.ts +55 -0
- package/backend/dist/services/notificationService.d.ts.map +1 -0
- package/backend/dist/services/notificationService.js +308 -0
- package/backend/dist/services/notificationService.js.map +1 -0
- package/backend/dist/services/openApiToolService.d.ts +38 -0
- package/backend/dist/services/openApiToolService.d.ts.map +1 -0
- package/backend/dist/services/openApiToolService.js +254 -0
- package/backend/dist/services/openApiToolService.js.map +1 -0
- package/backend/dist/services/personaService.d.ts +18 -2
- package/backend/dist/services/personaService.d.ts.map +1 -1
- package/backend/dist/services/personaService.js +113 -4
- package/backend/dist/services/personaService.js.map +1 -1
- package/backend/dist/services/pluginImageGenerationService.d.ts +19 -0
- package/backend/dist/services/pluginImageGenerationService.d.ts.map +1 -1
- package/backend/dist/services/pluginImageGenerationService.js +121 -0
- package/backend/dist/services/pluginImageGenerationService.js.map +1 -1
- package/backend/dist/services/pluginService.d.ts +7 -0
- package/backend/dist/services/pluginService.d.ts.map +1 -1
- package/backend/dist/services/pluginService.js +8 -2
- package/backend/dist/services/pluginService.js.map +1 -1
- package/backend/dist/services/promptService.d.ts +74 -0
- package/backend/dist/services/promptService.d.ts.map +1 -0
- package/backend/dist/services/promptService.js +513 -0
- package/backend/dist/services/promptService.js.map +1 -0
- package/backend/dist/services/resourceGrantService.d.ts.map +1 -1
- package/backend/dist/services/resourceGrantService.js +62 -17
- package/backend/dist/services/resourceGrantService.js.map +1 -1
- package/backend/dist/services/searchService.d.ts +29 -0
- package/backend/dist/services/searchService.d.ts.map +1 -0
- package/backend/dist/services/searchService.js +0 -0
- package/backend/dist/services/searchService.js.map +1 -0
- package/backend/dist/services/securityAuditService.d.ts.map +1 -1
- package/backend/dist/services/securityAuditService.js +2 -1
- package/backend/dist/services/securityAuditService.js.map +1 -1
- package/backend/dist/services/sharedResourceAccess.d.ts +25 -0
- package/backend/dist/services/sharedResourceAccess.d.ts.map +1 -0
- package/backend/dist/services/sharedResourceAccess.js +59 -0
- package/backend/dist/services/sharedResourceAccess.js.map +1 -0
- package/backend/dist/services/skillService.d.ts +137 -0
- package/backend/dist/services/skillService.d.ts.map +1 -0
- package/backend/dist/services/skillService.js +852 -0
- package/backend/dist/services/skillService.js.map +1 -0
- package/backend/dist/services/toolAccessService.d.ts +9 -0
- package/backend/dist/services/toolAccessService.d.ts.map +1 -0
- package/backend/dist/services/toolAccessService.js +60 -0
- package/backend/dist/services/toolAccessService.js.map +1 -0
- package/backend/dist/services/toolApprovalService.d.ts +34 -0
- package/backend/dist/services/toolApprovalService.d.ts.map +1 -0
- package/backend/dist/services/toolApprovalService.js +188 -0
- package/backend/dist/services/toolApprovalService.js.map +1 -0
- package/backend/dist/services/toolGatewayService.d.ts +53 -0
- package/backend/dist/services/toolGatewayService.d.ts.map +1 -0
- package/backend/dist/services/toolGatewayService.js +249 -0
- package/backend/dist/services/toolGatewayService.js.map +1 -0
- package/backend/dist/services/toolServerService.d.ts +57 -0
- package/backend/dist/services/toolServerService.d.ts.map +1 -0
- package/backend/dist/services/toolServerService.js +521 -0
- package/backend/dist/services/toolServerService.js.map +1 -0
- package/backend/dist/services/voiceAccessService.d.ts +10 -0
- package/backend/dist/services/voiceAccessService.d.ts.map +1 -0
- package/backend/dist/services/voiceAccessService.js +74 -0
- package/backend/dist/services/voiceAccessService.js.map +1 -0
- package/backend/dist/services/voiceProfileService.d.ts +20 -0
- package/backend/dist/services/voiceProfileService.d.ts.map +1 -1
- package/backend/dist/services/voiceProfileService.js +60 -0
- package/backend/dist/services/voiceProfileService.js.map +1 -1
- package/backend/dist/storage.d.ts +28 -1
- package/backend/dist/storage.d.ts.map +1 -1
- package/backend/dist/storage.js +100 -1
- package/backend/dist/storage.js.map +1 -1
- package/backend/dist/storageMappers.d.ts +2 -2
- package/backend/dist/storageMappers.d.ts.map +1 -1
- package/backend/dist/storageMappers.js.map +1 -1
- package/backend/dist/types/index.d.ts +197 -2
- package/backend/dist/types/index.d.ts.map +1 -1
- package/backend/dist/types/index.js.map +1 -1
- package/backend/dist/types/tools.d.ts +137 -0
- package/backend/dist/types/tools.d.ts.map +1 -0
- package/backend/dist/types/tools.js +25 -0
- package/backend/dist/types/tools.js.map +1 -0
- package/backend/dist/utils/chatDocumentContext.d.ts +26 -1
- package/backend/dist/utils/chatDocumentContext.d.ts.map +1 -1
- package/backend/dist/utils/chatDocumentContext.js +87 -18
- package/backend/dist/utils/chatDocumentContext.js.map +1 -1
- package/backend/dist/utils/documentExtraction.d.ts +69 -0
- package/backend/dist/utils/documentExtraction.d.ts.map +1 -0
- package/backend/dist/utils/documentExtraction.js +545 -0
- package/backend/dist/utils/documentExtraction.js.map +1 -0
- package/backend/dist/utils/hybridRetrieval.d.ts +34 -0
- package/backend/dist/utils/hybridRetrieval.d.ts.map +1 -0
- package/backend/dist/utils/hybridRetrieval.js +119 -0
- package/backend/dist/utils/hybridRetrieval.js.map +1 -0
- package/backend/dist/utils/icsCalendar.d.ts +27 -0
- package/backend/dist/utils/icsCalendar.d.ts.map +1 -0
- package/backend/dist/utils/icsCalendar.js +313 -0
- package/backend/dist/utils/icsCalendar.js.map +1 -0
- package/backend/dist/utils/imageEditUpload.d.ts +29 -0
- package/backend/dist/utils/imageEditUpload.d.ts.map +1 -0
- package/backend/dist/utils/imageEditUpload.js +82 -0
- package/backend/dist/utils/imageEditUpload.js.map +1 -0
- package/backend/dist/utils/logRedaction.d.ts +2 -0
- package/backend/dist/utils/logRedaction.d.ts.map +1 -0
- package/backend/dist/utils/logRedaction.js +66 -0
- package/backend/dist/utils/logRedaction.js.map +1 -0
- package/backend/dist/utils/logger.d.ts +3 -0
- package/backend/dist/utils/logger.d.ts.map +1 -1
- package/backend/dist/utils/logger.js +63 -20
- package/backend/dist/utils/logger.js.map +1 -1
- package/backend/dist/utils/pluginChatAdapter.d.ts +5 -1
- package/backend/dist/utils/pluginChatAdapter.d.ts.map +1 -1
- package/backend/dist/utils/pluginChatAdapter.js +83 -0
- package/backend/dist/utils/pluginChatAdapter.js.map +1 -1
- package/backend/dist/utils/pluginDefinitionTrust.js +1 -1
- package/backend/dist/utils/resourceLimits.d.ts +61 -2
- package/backend/dist/utils/resourceLimits.d.ts.map +1 -1
- package/backend/dist/utils/resourceLimits.js +59 -0
- package/backend/dist/utils/resourceLimits.js.map +1 -1
- package/backend/dist/utils/toolEgress.d.ts +22 -0
- package/backend/dist/utils/toolEgress.d.ts.map +1 -0
- package/backend/dist/utils/toolEgress.js +157 -0
- package/backend/dist/utils/toolEgress.js.map +1 -0
- package/backend/dist/utils/websocketMessages.d.ts +6 -0
- package/backend/dist/utils/websocketMessages.d.ts.map +1 -1
- package/backend/dist/utils/websocketMessages.js +8 -0
- package/backend/dist/utils/websocketMessages.js.map +1 -1
- package/backend/dist/utils/zipArchive.d.ts +32 -0
- package/backend/dist/utils/zipArchive.d.ts.map +1 -0
- package/backend/dist/utils/zipArchive.js +171 -0
- package/backend/dist/utils/zipArchive.js.map +1 -0
- package/backend/dist/websocketServer.d.ts.map +1 -1
- package/backend/dist/websocketServer.js +142 -35
- package/backend/dist/websocketServer.js.map +1 -1
- package/backend/package.json +1 -1
- package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
- package/frontend/dist/assets/index-BPsH9FII.js +80 -0
- package/frontend/dist/assets/index-BtXF0Oxa.css +1 -0
- package/frontend/dist/index.html +18 -18
- package/frontend/dist/js/{ArtifactContainer-CpUi6ekF.js → ArtifactContainer-CIoFoMv8.js} +1 -1
- package/frontend/dist/js/{ArtifactDemoPage-BeNs3gHp.js → ArtifactDemoPage-D0JEIAbZ.js} +1 -1
- package/frontend/dist/js/{ArtifactSandboxFrame-qsj_Y3LV.js → ArtifactSandboxFrame-REazyIrx.js} +2 -2
- package/frontend/dist/js/ArtifactSlideOutPanel-A-i94ghF.js +1 -0
- package/frontend/dist/js/AutomationsPage-Dow_lbIf.js +1 -0
- package/frontend/dist/js/{Button-BPf_pOxH.js → Button-C0r3J9G_.js} +1 -1
- package/frontend/dist/js/CalendarPage-DLjasZOd.js +1 -0
- package/frontend/dist/js/ChannelsPage-C8hvTD7J.js +1 -0
- package/frontend/dist/js/ChatPage-BAgBHUES.js +16 -0
- package/frontend/dist/js/EvaluationsPage-Bm8FRoeX.js +2 -0
- package/frontend/dist/js/{FirstTimeSetup-Df0YJni3.js → FirstTimeSetup-BxJapNul.js} +1 -1
- package/frontend/dist/js/GalleryPage-DHz9DkK7.js +1 -0
- package/frontend/dist/js/HomePage-BqNy-FWX.js +1 -0
- package/frontend/dist/js/LibreClawPage-BDzDILjY.js +1 -0
- package/frontend/dist/js/{ModelManagerModals-DcLGYN3l.js → ModelManagerModals-DX9eT5r2.js} +1 -1
- package/frontend/dist/js/ModelSelector-ol8mK2ja.js +1 -0
- package/frontend/dist/js/NotesPage-DzHEx2O4.js +3 -0
- package/frontend/dist/js/{OptimizedSyntaxHighlighter-Dz7D1LPB.js → OptimizedSyntaxHighlighter-CZNPwN0i.js} +1 -1
- package/frontend/dist/js/PersonasPage-M_WKH2a9.js +13 -0
- package/frontend/dist/js/PluginUsagePage-Ctoka6JZ.js +1 -0
- package/frontend/dist/js/RichMessageContent-BqgafH4p.js +3 -0
- package/frontend/dist/js/SettingsModal-R9EDadAV.js +19 -0
- package/frontend/dist/js/{SettingsToggle-woG_WebF.js → SettingsToggle-BIVyfGjl.js} +1 -1
- package/frontend/dist/js/SystemPage-aOkrSuY7.js +1 -0
- package/frontend/dist/js/UserManagementPage-BOuaX3ay.js +1 -0
- package/frontend/dist/js/WorkPage-DxZISerQ.js +6 -0
- package/frontend/dist/js/api-6bSMtSNh.js +14 -0
- package/frontend/dist/js/{appStore-0JnCUlEq.js → appStore-CdObhQBb.js} +2 -2
- package/frontend/dist/js/ar-DT_VLBO3.js +2 -0
- package/frontend/dist/js/{authStore-DbMdvNgJ.js → authStore-DbqqrfZv.js} +3 -3
- package/frontend/dist/js/{babel-BsYoxD-7.js → babel-DSqqk5kt.js} +1 -1
- package/frontend/dist/js/bn-BrvEqhGA.js +2 -0
- package/frontend/dist/js/chatStore-DbZPJNsu.js +3 -0
- package/frontend/dist/js/{config-DSOYQ9a3.js → config-8KdgjtEx.js} +1 -1
- package/frontend/dist/js/cs-BthnM_YI.js +2 -0
- package/frontend/dist/js/da-DCth-6_j.js +2 -0
- package/frontend/dist/js/de-BBWt0gJ_.js +2 -0
- package/frontend/dist/js/es-DuslOPqM.js +2 -0
- package/frontend/dist/js/{estree-BcnBcOAx.js → estree-BU5-LV_1.js} +3 -3
- package/frontend/dist/js/evaluationsApi-CwZJsgeG.js +1 -0
- package/frontend/dist/js/fr-DZAeg46S.js +2 -0
- package/frontend/dist/js/hi-ijDSiY77.js +2 -0
- package/frontend/dist/js/{html-DkY55Jys.js → html-DeoAy2bo.js} +2 -2
- package/frontend/dist/js/id-BS6qS0oq.js +2 -0
- package/frontend/dist/js/is-CO2PMDte.js +2 -0
- package/frontend/dist/js/it-ChhxT4hs.js +2 -0
- package/frontend/dist/js/ja-cyeqUeJN.js +2 -0
- package/frontend/dist/js/ko-CfqHTLXj.js +2 -0
- package/frontend/dist/js/{markdown-IZSI9DXw.js → markdown-DOLsYkBY.js} +3 -3
- package/frontend/dist/js/markdown-core-BK7WVOb7.js +32 -0
- package/frontend/dist/js/{markdown-math-DK846gXU.js → markdown-math-e1ByS3KY.js} +5 -5
- package/frontend/dist/js/{messageCodeStyles-BFNR9Wv6.js → messageCodeStyles-DhVgizF-.js} +2 -2
- package/frontend/dist/js/ms-DZ5pACe1.js +2 -0
- package/frontend/dist/js/nl-BsRsnOVp.js +2 -0
- package/frontend/dist/js/pl-DXSTAW4M.js +2 -0
- package/frontend/dist/js/{postcss-BJ0okz7n.js → postcss-Bg15EcFE.js} +1 -1
- package/frontend/dist/js/pt-DmDx0JxB.js +2 -0
- package/frontend/dist/js/{react-vendor-C5yShNlM.js → react-vendor-BG_HPV6X.js} +1 -1
- package/frontend/dist/js/router-vendor-CbexJIsv.js +1 -0
- package/frontend/dist/js/ru-d2g8EWfY.js +2 -0
- package/frontend/dist/js/{standalone-Csw3jfJ_.js → standalone-BO5pzI8_.js} +3 -3
- package/frontend/dist/js/sv-CIhYUTVQ.js +2 -0
- package/frontend/dist/js/{syntax-highlight-3EEX6CGL.js → syntax-highlight-DcR9Vhb7.js} +3 -3
- package/frontend/dist/js/th-B3wSxanB.js +2 -0
- package/frontend/dist/js/tr-R4UGgPOY.js +2 -0
- package/frontend/dist/js/{typescript-CnF4UVx7.js → typescript-6GJ8APmn.js} +1 -1
- package/frontend/dist/js/ui-CV0LYmkM.js +2 -0
- package/frontend/dist/js/ui-vendor-CWjIBW-z.js +177 -0
- package/frontend/dist/js/uk-BzUF4Vkt.js +2 -0
- package/frontend/dist/js/{useTranslation-Bho4HCyg.js → useTranslation-5b5UhAc9.js} +1 -1
- package/frontend/dist/js/{utils-D9W1Lnkn.js → utils-BGrdX9ie.js} +1 -1
- package/frontend/dist/js/{utils-vendor-DWh39_3x.js → utils-vendor-9bQ62WeD.js} +1 -1
- package/frontend/dist/js/vi-CKc6Fg4h.js +2 -0
- package/frontend/dist/js/{workApi-C3uy9EDT.js → workApi-BruWTlHM.js} +3 -3
- package/frontend/dist/js/{yaml-DzT5hBSH.js → yaml-DUeWcOOH.js} +2 -2
- package/frontend/dist/js/zh-CXL-kDe8.js +2 -0
- package/package.json +2 -2
- package/plugins/openai.json +52 -9
- package/frontend/dist/assets/index-6o-Hc2wS.js +0 -41
- package/frontend/dist/assets/index-D-pM957b.css +0 -1
- package/frontend/dist/js/ArtifactSlideOutPanel-CSFRluWA.js +0 -1
- package/frontend/dist/js/AutomationsPage-KUeWoZNv.js +0 -1
- package/frontend/dist/js/CalendarPage-D9I972w8.js +0 -1
- package/frontend/dist/js/ChatPage-CmBx4oAL.js +0 -16
- package/frontend/dist/js/GalleryPage-bLCrdJN_.js +0 -1
- package/frontend/dist/js/HomePage-Uc6PEg-U.js +0 -1
- package/frontend/dist/js/LibreClawPage-CG63DHg1.js +0 -1
- package/frontend/dist/js/ModelSelector-yxJC64rM.js +0 -1
- package/frontend/dist/js/ModelsPage-1R_TxgmJ.js +0 -2
- package/frontend/dist/js/NotesPage-L65j5HoW.js +0 -1
- package/frontend/dist/js/PersonasPage-CKeBpHIH.js +0 -13
- package/frontend/dist/js/PluginUsagePage-BX1SKMbW.js +0 -1
- package/frontend/dist/js/RichMessageContent-DiySVYGB.js +0 -3
- package/frontend/dist/js/SettingsModal-68SG1uZ2.js +0 -1
- package/frontend/dist/js/SystemPage-CytpZiQV.js +0 -1
- package/frontend/dist/js/UserManagementPage-BzJBvZiS.js +0 -1
- package/frontend/dist/js/WorkPage-C8gr0QJe.js +0 -6
- package/frontend/dist/js/api-BDtqBtqw.js +0 -14
- package/frontend/dist/js/ar-CSpi37Gr.js +0 -2
- package/frontend/dist/js/bn-CyH1BeDD.js +0 -2
- package/frontend/dist/js/chatStore-CHQ2uINS.js +0 -3
- package/frontend/dist/js/cs-Cv2NfRK5.js +0 -2
- package/frontend/dist/js/da-D6D6IvPK.js +0 -2
- package/frontend/dist/js/de-BNoJJTrT.js +0 -2
- package/frontend/dist/js/es-kzo9C7q_.js +0 -2
- package/frontend/dist/js/fr-CjHYvJRp.js +0 -2
- package/frontend/dist/js/hi-BU98AdCQ.js +0 -2
- package/frontend/dist/js/id-CpdedejX.js +0 -2
- package/frontend/dist/js/is-Cp5dDWBH.js +0 -2
- package/frontend/dist/js/it-CuH_cK4U.js +0 -2
- package/frontend/dist/js/ja-BWXXXiHn.js +0 -2
- package/frontend/dist/js/ko-DQgv2M1t.js +0 -2
- package/frontend/dist/js/markdown-core-BmPPZiuD.js +0 -31
- package/frontend/dist/js/ms-DCcRoIcX.js +0 -2
- package/frontend/dist/js/nl-CbKR1_EU.js +0 -2
- package/frontend/dist/js/pl-CRyJZccn.js +0 -2
- package/frontend/dist/js/pt-BXYmHFGH.js +0 -2
- package/frontend/dist/js/router-vendor-DGFGM3EP.js +0 -1
- package/frontend/dist/js/ru-M9SyZG4b.js +0 -2
- package/frontend/dist/js/sv-DJ486LTU.js +0 -2
- package/frontend/dist/js/th-Ch7gKtZv.js +0 -2
- package/frontend/dist/js/tr-ClehWhSC.js +0 -2
- package/frontend/dist/js/ui-CC-K19wO.js +0 -2
- package/frontend/dist/js/ui-vendor-B1UgO3vd.js +0 -177
- package/frontend/dist/js/uk-BqAd5zHF.js +0 -2
- package/frontend/dist/js/vi-D9gjlDVB.js +0 -2
- package/frontend/dist/js/zh-DKTyHkiR.js +0 -2
package/frontend/dist/js/{ArtifactSandboxFrame-qsj_Y3LV.js → ArtifactSandboxFrame-REazyIrx.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-BK7WVOb7.js";import{t as r}from"./logger-DSXjF4ye.js";import{t as i}from"./config-8KdgjtEx.js";var a=e(t(),1),o=`allow-scripts allow-forms allow-modals allow-popups allow-pointer-lock allow-downloads`,s=`clipboard-read; clipboard-write; fullscreen; gamepad`,c=`libre-artifact:render`;function l(e,t){if(!t||e.source!==t.contentWindow)return!1;let n=e.origin,r=typeof window>`u`?void 0:window.location?.origin;if(typeof n==`string`&&n!==``&&n!==`null`&&n!==r)return!1;let i=e.data;return!!i&&i?.type===`libre-artifact:ready`}function u(e,t){e?.contentWindow?.postMessage({type:c,html:t},`*`)}var d=`
|
|
2
2
|
body {
|
|
3
3
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
4
4
|
margin: 0;
|
|
@@ -38,7 +38,7 @@ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{m as t,p as n}from"./m
|
|
|
38
38
|
</head>
|
|
39
39
|
<body>${e}</body>
|
|
40
40
|
</html>`}function g(e,t,n=`Artifact`){let r=window.open(``,`_blank`);if(!r)return null;r.opener=null;let{document:i}=r;i.title=n,i.documentElement.style.width=`100%`,i.documentElement.style.height=`100%`,i.body.style.width=`100%`,i.body.style.height=`100%`,i.body.style.margin=`0`,i.body.replaceChildren();let a=i.createElement(`iframe`);return a.title=n,a.src=t,a.setAttribute(`sandbox`,o),a.setAttribute(`allow`,s),a.style.width=`100%`,a.style.height=`100%`,a.style.border=`0`,r.addEventListener(`message`,t=>{l(t,a)&&u(a,e)}),i.body.appendChild(a),r}function _(e,t){let n=e;/<head[\s>]/i.test(n)||(n=n.replace(/<html([^>]*)>/i,`<html$1><head></head>`));let r=[];return/<meta\s+charset=/i.test(n)||r.push(`<meta charset="UTF-8">`),/<meta\s+name=["']viewport["']/i.test(n)||r.push(`<meta name="viewport" content="width=device-width, initial-scale=1.0">`),/<base\s/i.test(n)||r.push(`<base target="_blank">`),/<title[\s>]/i.test(n)||r.push(`<title>${S(t)}</title>`),r.length===0?n:v(n,`\n ${r.join(`
|
|
41
|
-
`)}`)}function v(e,t){let n=/<head(\s[^>]*)?>/i;return n.test(e)?e.replace(n,e=>`${e}${t}`):`${t}\n${e}`}function y(e,t){return/<\/head>/i.test(e)?e.replace(/<\/head>/i,`${t}</head>`):/<html[^>]*>/i.test(e)?e.replace(/<html([^>]*)>/i,`<html$1><head>${t}</head>`):`${t}${e}`}function b(e,t){return/<\/body>/i.test(e)?e.replace(/<\/body>/i,`${t}</body>`):`${e}${t}`}function x(e){return S(e)}function S(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}var C=`${i.replace(/\/+$/,``)}/artifacts/sandbox`,ee=window.location.protocol===`file:`?new URL(C).origin:window.location.origin,te=`/artifact-runtime`,w=`runtime`,T=`react`,E=`babel`,D=`tailwind`,O=`fonts`,k={react:T,"react-dom":T,"react-dom/client":T,"react/jsx-runtime":T,"react/jsx-dev-runtime":T,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`},ne=[w,T,E,D],re=[w,`mermaid`],A=[{pattern:/cdn\.tailwindcss\.com/i,bundle:D},{pattern:/(?:^|\/)tailwindcss(?:@[\d.]+)?(?:\/|$)/i,bundle:D},{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:O},{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:T},{pattern:/(?:^|\/)react(?:@[\d.]+)?(?:\/|$|\?)/i,bundle:T},{pattern:/babel(?:-standalone|\/standalone)/i,bundle:E}],j=`__libreArtifactRuntime`;function ie(e){if(k[e])return e;let t=A.find(({pattern:t})=>t.test(e))?.bundle??Object.values(k).find(t=>e.startsWith(`${t}/`));return t?Object.entries(k).find(([,e])=>e===t)?.[0]??null:null}function ae(e){let t=new Set,n=e.matchAll(/(?:from|import|require)\s*\(?\s*['"`]([^'"`]+)['"`]/g);for(let[,e]of n){let n=ie(e);n&&t.add(k[n])}return[...t]}var M=/\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 N(e){let t=[...e.matchAll(/class\s*=\s*("|')(.*?)\1/gi)].map(e=>e[2]).join(` `);return new Set(t.match(M)??[]).size>=3}function P(e){let t=new Set;for(let[n,r]of Object.entries(k)){let i=n.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);RegExp(`(?:from|import|require)\\s*\\(?\\s*['"\`]${i}['"\`]`).test(e)&&t.add(r)}return[...t]}function F(e){return A.find(({pattern:t})=>t.test(e))?.bundle??null}function I(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 L(e){let t=new Set;for(let n of I(e)){let e=F(n);e&&t.add(e)}return[...t]}var R=`
|
|
41
|
+
`)}`)}function v(e,t){let n=/<head(\s[^>]*)?>/i;return n.test(e)?e.replace(n,e=>`${e}${t}`):`${t}\n${e}`}function y(e,t){return/<\/head>/i.test(e)?e.replace(/<\/head>/i,`${t}</head>`):/<html[^>]*>/i.test(e)?e.replace(/<html([^>]*)>/i,`<html$1><head>${t}</head>`):`${t}${e}`}function b(e,t){return/<\/body>/i.test(e)?e.replace(/<\/body>/i,`${t}</body>`):`${e}${t}`}function x(e){return S(e)}function S(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}var C=`${i.replace(/\/+$/,``)}/artifacts/sandbox`,ee=window.location.protocol===`file:`?new URL(C).origin:window.location.origin,te=`/artifact-runtime`,w=`runtime`,T=`react`,E=`babel`,D=`tailwind`,O=`fonts`,k={react:T,"react-dom":T,"react-dom/client":T,"react/jsx-runtime":T,"react/jsx-dev-runtime":T,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`},ne=[w,T,E,D],re=[w,`mermaid`],A=[{pattern:/cdn\.tailwindcss\.com/i,bundle:D},{pattern:/(?:^|\/)tailwindcss(?:@[\d.]+)?(?:\/|$)/i,bundle:D},{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:O},{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:T},{pattern:/(?:^|\/)react(?:@[\d.]+)?(?:\/|$|\?)/i,bundle:T},{pattern:/babel(?:-standalone|\/standalone)/i,bundle:E}],j=`__libreArtifactRuntime`;function ie(e){if(k[e])return e;let t=A.find(({pattern:t})=>t.test(e))?.bundle??Object.values(k).find(t=>e.startsWith(`${t}/`));return t?Object.entries(k).find(([,e])=>e===t)?.[0]??null:null}function ae(e){let t=new Set,n=e.matchAll(/(?:from|import|require)\s*\(?\s*['"`]([^'"`]+)['"`]/g);for(let[,e]of n){let n=ie(e);n&&t.add(k[n])}return[...t]}var M=/\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 N(e){let t=[...e.matchAll(/class\s*=\s*("|')(.*?)\1/gi)].map(e=>e[2]).join(` `);return new Set(t.match(M)??[]).size>=3}function P(e){let t=new Set;for(let[n,r]of Object.entries(k)){let i=n.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);RegExp(`(?:from|import|require)\\s*\\(?\\s*['"\`]${i}['"\`]`).test(e)&&t.add(r)}return[...t]}function F(e){return A.find(({pattern:t})=>t.test(e))?.bundle??null}function I(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 L(e){let t=new Set;for(let n of I(e)){let e=F(n);e&&t.add(e)}return[...t]}var R=`18534bc526e00f62`,z=new Map;function B(e){let t=z.get(e);if(t)return t;let n=fetch(`${ee}${te}/${e}.js?v=${R}`,{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(()=>z.delete(e)),z.set(e,n),n}async function V(e){let t=await Promise.all(e.map(B));return Object.fromEntries(e.map((e,n)=>[e,t[n]]))}function H(e){return e===`html`||e===`react`||e===`mermaid`?e:null}var U=`
|
|
42
42
|
html, body { margin: 0; min-height: 100%; }
|
|
43
43
|
body {
|
|
44
44
|
background: #ffffff;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-BK7WVOb7.js";import{n as r}from"./react-vendor-BG_HPV6X.js";import{t as i}from"./useTranslation-5b5UhAc9.js";import{t as a}from"./utils-BGrdX9ie.js";import{t as ee,w as o}from"./chatStore-DbZPJNsu.js";import{Cn as s,In as te,Ln as ne,Ut as re,Vt as ie,an as c,dn as ae,gn as oe,h as l,n as u,pn as d,wn as f,yn as p,zn as se}from"./ui-vendor-CWjIBW-z.js";import{t as m}from"./logger-DSXjF4ye.js";import{t as ce}from"./appStore-CdObhQBb.js";import{t as h}from"./Button-C0r3J9G_.js";import{t as g}from"./OptimizedSyntaxHighlighter-CZNPwN0i.js";import{a as le,i as ue,l as de,n as _,o as fe,r as v,t as pe}from"./ArtifactSandboxFrame-REazyIrx.js";var y=e(t(),1),me=r(),b=n(),x=m(`components:artifact-slide-out-panel`),S=320,C=.9,w=600,T=()=>{let{t:e,i18n:t}=i(),n=o(t.language),{artifactPanelOpen:r,artifactPanelArtifact:m,openArtifactPanel:T,closeArtifactPanel:E,theme:D}=ce(),O=ee(e=>e.currentSession),k=y.useMemo(()=>{if(!m)return[];let e=m.title.trim().toLowerCase(),t=(O?.messages??[]).flatMap(e=>e.artifacts??[]).filter(t=>t.title.trim().toLowerCase()===e);return t.some(e=>e.id===m.id)?t:[...t,m]},[O,m]),A=k.findIndex(e=>e.id===m?.id),[he,j]=(0,y.useState)(!1),[M,N]=(0,y.useState)(`preview`),[P,F]=(0,y.useState)(w),[I,L]=(0,y.useState)(!1),R=(0,y.useRef)(null),z=(0,y.useRef)(null),B=(0,y.useRef)(0),V=(0,y.useRef)(0),H=(0,y.useRef)(null),U=(0,y.useRef)(null),W=(0,y.useRef)(P),G=m?.id??null;G!==z.current&&(z.current=G,M!==`preview`&&N(`preview`));let K=(0,y.useCallback)(e=>{W.current=e,U.current===null&&(U.current=window.requestAnimationFrame(()=>{U.current=null,F(W.current)}))},[]),q=(0,y.useCallback)(()=>{H.current=null,L(!1),U.current!==null&&(window.cancelAnimationFrame(U.current),U.current=null,F(W.current))},[]),ge=(0,y.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),H.current=e.pointerId,V.current=P,B.current=e.clientX,W.current=P,e.currentTarget.setPointerCapture(e.pointerId),L(!0)},[P]),J=(0,y.useCallback)(e=>{if(!I||H.current!==null&&e.pointerId!==H.current)return;e.preventDefault();let t=(B.current-e.clientX)*(n?-1:1),r=window.innerWidth*C,i=Math.min(r,Math.max(S,V.current+t));K(i)},[I,n,K]);if((0,y.useEffect)(()=>{if(!I){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=``}},[I,J,q]),(0,y.useEffect)(()=>{let e=()=>{let e=window.innerWidth*C;P>e&&F(e)};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[P]),(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r&&E()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r,E]),(0,y.useEffect)(()=>{let e=e=>{I||R.current&&!R.current.contains(e.target)&&r&&E()},t=setTimeout(()=>{window.addEventListener(`mousedown`,e)},100);return()=>{clearTimeout(t),window.removeEventListener(`mousedown`,e)}},[r,E,I]),!m)return null;let Y=m,_e=async e=>{try{await navigator.clipboard.writeText(e),j(!0),setTimeout(()=>j(!1),2e3)}catch(e){x.error(`Failed to copy:`,e)}},ve=()=>{let e=Y.type===`html`?le(Y.content,Y.title):Y.content,t=new Blob([e],{type:ye(Y.type)}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`${Y.title}.${be(Y.type)}`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)},ye=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`}},be=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`}},xe=()=>{switch(Y.type){case`html`:return(0,b.jsx)(re,{className:`h-5 w-5`});case`react`:return(0,b.jsx)(s,{className:`h-5 w-5`});case`svg`:return(0,b.jsx)(c,{className:`h-5 w-5`});case`code`:return(0,b.jsx)(s,{className:`h-5 w-5`});default:return(0,b.jsx)(c,{className:`h-5 w-5`})}},X=()=>(0,b.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,b.jsxs)(`div`,{className:`max-w-sm text-center`,children:[(0,b.jsx)(l,{className:`h-8 w-8 text-primary-500 mx-auto mb-3`}),(0,b.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`artifacts.previewUnavailable`)}),(0,b.jsx)(`p`,{className:`mt-1 text-sm text-gray-600 dark:text-gray-400`,children:e(`artifacts.previewUnavailableDescription`)}),(0,b.jsxs)(h,{variant:`outline`,size:`sm`,onClick:()=>N(`code`),className:`mt-4`,children:[(0,b.jsx)(f,{className:`h-3.5 w-3.5 me-1.5`}),e(`artifacts.code`)]})]})}),Se=async()=>{try{let e=await v(_(Y.type)??`html`,Y.content,Y.title,{colorScheme:D.mode===`dark`?`dark`:`light`});de(e,ue,Y.title)}catch(e){x.error(`Failed to open the artifact preview:`,e)}},Z=e=>Y.content.trim()?(0,b.jsx)(pe,{content:Y.content,title:Y.title,kind:e,colorScheme:D.mode===`dark`?`dark`:`light`,className:a(`w-full h-full border-0 rounded-lg bg-white`,I&&`pointer-events-none`),fallback:X()}):X(),Ce=()=>(0,b.jsx)(`iframe`,{"data-testid":`artifact-svg-preview`,srcDoc:fe(Y.content,Y.title),className:`w-full h-full border-0 rounded-lg bg-white`,sandbox:``,title:Y.title}),Q=()=>(0,b.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,b.jsx)(g,{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:D.mode===`dark`,className:`!m-0 !rounded-lg !h-full`,children:Y.content})}),we=()=>{try{let e=JSON.parse(Y.content),t=JSON.stringify(e,null,2);return(0,b.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,b.jsx)(g,{language:`json`,isDark:D.mode===`dark`,className:`!m-0 !rounded-lg !h-full`,children:t})})}catch{return(0,b.jsx)(`div`,{className:`w-full h-full flex items-center justify-center bg-gray-50 dark:bg-dark-100 rounded-lg`,children:(0,b.jsxs)(`div`,{className:`text-center`,children:[(0,b.jsx)(l,{className:`h-8 w-8 text-primary-500 mx-auto mb-2`}),(0,b.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-dark-600`,children:e(`artifacts.invalidJson`)})]})})}},Te=()=>{if(M===`code`)return Q();switch(Y.type){case`html`:return Z(`html`);case`react`:return Z(`react`);case`mermaid`:return Z(`mermaid`);case`svg`:return Ce();case`json`:return we();default:return Q()}},Ee=()=>Y.type===`html`||Y.type===`svg`||Y.type===`react`||Y.type===`mermaid`,$=typeof window<`u`&&window.innerWidth<640,De=$?`100%`:`${P}px`,Oe=(0,b.jsxs)(b.Fragment,{children:[(0,b.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`)}),I&&(0,b.jsx)(`div`,{className:`fixed inset-0 z-[55] cursor-col-resize select-none`,"aria-hidden":`true`}),(0,b.jsxs)(`div`,{ref:R,"data-testid":`artifact-slide-out-panel`,style:{width:De},className:a(`fixed top-0 end-0 h-full 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,b.jsxs)(`div`,{onPointerDown:ge,"data-testid":`artifact-resize-handle`,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,b.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`,I&&`bg-primary-500 h-24`)}),(0,b.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`,I&&`opacity-100`),children:(0,b.jsx)(ie,{className:`h-4 w-4`})})]}),(0,b.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-gray-200 dark:border-dark-200`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[(0,b.jsx)(`div`,{className:`text-gray-600 dark:text-gray-400 flex-shrink-0`,children:xe()}),(0,b.jsx)(`h2`,{className:`font-semibold text-gray-900 dark:text-gray-100 truncate`,children:Y.title}),(0,b.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:Y.type.toUpperCase()})]}),(0,b.jsx)(h,{variant:`ghost`,size:`sm`,onClick:E,className:`h-8 w-8 p-0 hover:bg-gray-100 dark:hover:bg-dark-200 flex-shrink-0`,title:e(`artifacts.closePanelEsc`),children:(0,b.jsx)(u,{className:`h-5 w-5`})})]}),(0,b.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b border-gray-100 dark:border-dark-200 bg-gray-50 dark:bg-dark-100/50`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1`,children:[k.length>1&&A!==-1&&(0,b.jsxs)(`div`,{className:`me-1 flex items-center gap-0.5`,children:[(0,b.jsx)(h,{variant:`ghost`,size:`sm`,disabled:A===0,onClick:()=>T(k[A-1]),className:`h-8 w-8 p-0`,title:e(`artifacts.previousVersion`),children:(0,b.jsx)(ne,{className:`h-3.5 w-3.5 rtl:rotate-180`})}),(0,b.jsx)(`span`,{className:`whitespace-nowrap text-xs tabular-nums text-gray-500 dark:text-dark-600`,children:e(`artifacts.versionOf`,{current:A+1,total:k.length})}),(0,b.jsx)(h,{variant:`ghost`,size:`sm`,disabled:A===k.length-1,onClick:()=>T(k[A+1]),className:`h-8 w-8 p-0`,title:e(`artifacts.nextVersion`),children:(0,b.jsx)(te,{className:`h-3.5 w-3.5 rtl:rotate-180`})})]}),Ee()&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(h,{variant:M===`preview`?`primary`:`ghost`,size:`sm`,onClick:()=>N(`preview`),className:`h-8 px-3 text-xs`,title:e(`artifacts.previewMode`),children:[(0,b.jsx)(ae,{className:`h-3.5 w-3.5 me-1.5`}),e(`artifacts.preview`)]}),(0,b.jsxs)(h,{variant:M===`code`?`primary`:`ghost`,size:`sm`,onClick:()=>N(`code`),className:`h-8 px-3 text-xs`,title:e(`artifacts.codeMode`),children:[(0,b.jsx)(f,{className:`h-3.5 w-3.5 me-1.5`}),e(`artifacts.code`)]})]})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,b.jsx)(h,{variant:`ghost`,size:`sm`,onClick:()=>_e(Y.content),className:`h-8 px-3 text-xs hover:bg-gray-100 dark:hover:bg-dark-200`,title:e(`artifacts.copyContent`),children:he?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(se,{className:`h-3.5 w-3.5 me-1.5 text-green-500`}),e(`artifacts.copied`)]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(p,{className:`h-3.5 w-3.5 me-1.5`}),e(`artifacts.copyButton`)]})}),(0,b.jsxs)(h,{variant:`ghost`,size:`sm`,onClick:ve,className:`h-8 px-3 text-xs hover:bg-gray-100 dark:hover:bg-dark-200`,title:e(`artifacts.download`),children:[(0,b.jsx)(oe,{className:`h-3.5 w-3.5 me-1.5`}),e(`artifacts.download`)]}),_(Y.type)&&(0,b.jsxs)(h,{variant:`ghost`,size:`sm`,onClick:()=>Se(),className:`h-8 px-3 text-xs hover:bg-gray-100 dark:hover:bg-dark-200`,title:e(`artifacts.openInNewWindow`),children:[(0,b.jsx)(d,{className:`h-3.5 w-3.5 me-1.5`}),e(`artifacts.open`)]})]})]}),Y.description&&(0,b.jsx)(`div`,{className:`px-4 py-3 border-b border-gray-100 dark:border-dark-200`,children:(0,b.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:Y.description})}),(0,b.jsx)(`div`,{className:`flex-1 p-4 overflow-hidden`,children:Te()}),(0,b.jsx)(`div`,{className:`px-4 py-2 border-t border-gray-100 dark:border-dark-200 bg-gray-50 dark:bg-dark-100/50`,children:(0,b.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,b.jsxs)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[e(`artifacts.created`),`:`,` `,new Date(Y.createdAt).toLocaleString()]}),!$&&(0,b.jsx)(`div`,{className:`text-xs text-gray-400 dark:text-dark-500`,children:e(`artifacts.dragEdgeToResize`)})]})})]})]});return(0,me.createPortal)(Oe,document.body)};export{T as ArtifactSlideOutPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-BK7WVOb7.js";import{n as r}from"./react-vendor-BG_HPV6X.js";import{f as i}from"./router-vendor-CbexJIsv.js";import{t as a}from"./useTranslation-5b5UhAc9.js";import{r as o,t as s}from"./utils-BGrdX9ie.js";import{t as c}from"./chatStore-DbZPJNsu.js";import{An as l,Dt as u,En as d,On as f,Q as p,X as m,_ as h,hn as g,kn as _,n as v,q as y,rt as b,t as x,tt as S,ur as C}from"./ui-vendor-CWjIBW-z.js";import{t as w}from"./logger-DSXjF4ye.js";import{w as T}from"./api-6bSMtSNh.js";import{t as E}from"./Button-C0r3J9G_.js";import"./ui-CV0LYmkM.js";import{c as D,d as O,l as k,n as A}from"./calendarDates-Co3o_05Y.js";var j=e(t(),1),M=r(),N=(e,t,n)=>new Intl.DateTimeFormat(n,{hour:`numeric`,minute:`2-digit`}).format(new Date(2024,0,1,e,t)),P=(e,t)=>new Intl.DateTimeFormat(t,{weekday:`long`}).format(new Date(2024,0,7+e)),F=(e,t,n)=>new Intl.DateTimeFormat(n,{month:`long`,day:`numeric`}).format(new Date(2024,e-1,t));function I(e,t,n){switch(e.kind){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:N(e.hour,e.minute,t)});case`weekly`:return n(`automations.trigger.weekly`,{day:P(e.dayOfWeek,t),time:N(e.hour,e.minute,t)});case`monthly`:return n(`automations.trigger.monthly`,{day:e.dayOfMonth,time:N(e.hour,e.minute,t)});case`yearly`:return n(`automations.trigger.yearly`,{date:F(e.month,e.dayOfMonth,t),time:N(e.hour,e.minute,t)})}}function L(e,t,n){return e.map(e=>I(e,t,n)).join(` · `)}function R(e){let t=(e,t,n)=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=t&&e<=n;switch(e.kind){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 z=n(),B=[`once`,`hourly`,`daily`,`weekly`,`monthly`,`yearly`],V=`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`,H=(e,t)=>`${String(e).padStart(2,`0`)}:${String(t).padStart(2,`0`)}`,U=e=>{switch(e){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 W({trigger:e,onChange:t,onRemove:n}){let{t:r,i18n:i}=a(),o=O(i.language,`short`),s=new Intl.DateTimeFormat(i.language,{month:`long`}),c=n=>{let[r,i]=(n||`00:00`).split(`:`).map(Number);e.kind!==`hourly`&&e.kind!==`once`&&t({...e,hour:r,minute:i})},l=e.kind!==`once`&&e.kind!==`hourly`?(0,z.jsx)(`input`,{type:`time`,"aria-label":r(`automations.form.time`),value:H(e.hour,e.minute),onChange:e=>c(e.target.value),className:V}):null;return(0,z.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,z.jsx)(d,{className:`h-3.5 w-3.5 shrink-0 text-gray-400 dark:text-dark-500`}),(0,z.jsx)(`select`,{"aria-label":r(`automations.form.frequency`),value:e.kind,onChange:e=>t(U(e.target.value)),className:V,"data-testid":`automation-trigger-kind`,children:B.map(e=>(0,z.jsx)(`option`,{value:e,children:r(`automations.kind.${e}`)},e))}),e.kind===`once`&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`input`,{type:`date`,"aria-label":r(`calendar.date`),value:D(e.at),onChange:n=>t({...e,at:A(n.target.value,k(e.at))}),className:V}),(0,z.jsx)(`input`,{type:`time`,"aria-label":r(`automations.form.time`),value:k(e.at),onChange:n=>t({...e,at:A(D(e.at),n.target.value)}),className:V})]}),e.kind===`hourly`&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`label`,{className:`flex items-center gap-1 text-[12px] text-gray-500 dark:text-dark-500`,children:[r(`automations.form.minute`),(0,z.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:`${V} w-16`})]}),(0,z.jsxs)(`label`,{className:`flex items-center gap-1 text-[12px] text-gray-500 dark:text-dark-500`,children:[r(`automations.form.fromHour`),(0,z.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:`${V} w-16`})]}),(0,z.jsxs)(`label`,{className:`flex items-center gap-1 text-[12px] text-gray-500 dark:text-dark-500`,children:[r(`automations.form.toHour`),(0,z.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:`${V} w-16`})]})]}),e.kind===`weekly`&&(0,z.jsx)(`select`,{"aria-label":r(`automations.form.weekday`),value:e.dayOfWeek,onChange:n=>t({...e,dayOfWeek:Number(n.target.value)}),className:V,children:o.map((e,t)=>(0,z.jsx)(`option`,{value:t,children:e},e))}),(e.kind===`monthly`||e.kind===`yearly`)&&(0,z.jsxs)(`label`,{className:`flex items-center gap-1 text-[12px] text-gray-500 dark:text-dark-500`,children:[r(`automations.form.dayOfMonth`),(0,z.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:`${V} w-16`})]}),e.kind===`yearly`&&(0,z.jsx)(`select`,{"aria-label":r(`automations.form.month`),value:e.month,onChange:n=>t({...e,month:Number(n.target.value)}),className:V,children:Array.from({length:12},(e,t)=>(0,z.jsx)(`option`,{value:t+1,children:s.format(new Date(2024,t,1))},t+1))}),l,n&&(0,z.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,z.jsx)(h,{className:`h-3.5 w-3.5`})})]})}var G=`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`,K=`mb-1 block text-[11px] font-medium uppercase tracking-wide text-gray-400 dark:text-dark-500`,q=e=>e.isPlugin&&e.pluginId?`plugin:${e.pluginId}`:e.isAgent&&e.agentId?`agent:${e.agentId}`:`ollama`;function ee({open:e,automation:t,initial:n,models:r,saving:i,onClose:a,onSave:o}){return e?(0,z.jsx)(J,{automation:t,initial:n,models:r,saving:i,onClose:a,onSave:o},t?.id??n?.name??`new`):null}function J({automation:e,initial:t,models:n,saving:r,onClose:i,onSave:o}){let{t:s}=a(),[c,l]=(0,j.useState)(e?.name??t?.name??``),[u,d]=(0,j.useState)(e?.instructions??t?.instructions??``),[f,p]=(0,j.useState)(e?.triggers??t?.triggers??[{kind:`daily`,hour:8,minute:0}]),[h,g]=(0,j.useState)(e?.model??``),[_,y]=(0,j.useState)(e?.notify??`app`),b=c.trim().length>0&&u.trim().length>0&&f.length>0&&f.every(R);return(0,M.createPortal)((0,z.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,z.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`automation-modal-title`,"data-testid":`automation-modal`,className:`max-h-[90vh] w-full max-w-lg overflow-y-auto rounded-3xl border border-black/[0.07] bg-white p-6 shadow-[0_24px_80px_rgba(0,0,0,0.24)] animate-scale-in scrollbar-thin dark:border-white/[0.08] dark:bg-dark-25`,onClick:e=>e.stopPropagation(),children:[(0,z.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,z.jsx)(`h3`,{id:`automation-modal-title`,className:`text-lg font-medium tracking-[-0.02em] text-gray-950 dark:text-dark-950`,children:s(e?`automations.editAutomation`:`automations.newAutomation`)}),(0,z.jsx)(`button`,{onClick:i,"aria-label":s(`common.close`),className:`rounded-xl p-2 transition-colors hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,z.jsx)(v,{size:20,className:`text-gray-500`})})]}),(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{htmlFor:`automation-name`,className:K,children:s(`automations.form.name`)}),(0,z.jsx)(`input`,{id:`automation-name`,"data-testid":`automation-name`,type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:s(`automations.form.namePlaceholder`),className:G,maxLength:200,autoFocus:!0})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:K,children:s(`automations.form.triggers`)}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[f.map((e,t)=>(0,z.jsx)(W,{trigger:e,onChange:e=>p(n=>n.map((n,r)=>r===t?e:n)),onRemove:f.length>1?()=>p(e=>e.filter((e,n)=>n!==t)):void 0},t)),f.length<5&&(0,z.jsxs)(`button`,{type:`button`,onClick:()=>p(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,z.jsx)(m,{className:`h-3.5 w-3.5`}),s(`automations.form.addTrigger`)]})]})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{htmlFor:`automation-instructions`,className:K,children:s(`automations.form.instructions`)}),(0,z.jsx)(`textarea`,{id:`automation-instructions`,"data-testid":`automation-instructions`,value:u,onChange:e=>d(e.target.value),placeholder:s(`automations.form.instructionsPlaceholder`),rows:5,className:G,maxLength:2e4})]}),(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{htmlFor:`automation-model`,className:K,children:s(`automations.form.model`)}),(0,z.jsxs)(`select`,{id:`automation-model`,value:h,onChange:e=>g(e.target.value),className:G,children:[(0,z.jsx)(`option`,{value:``,children:s(`automations.form.modelAuto`)}),n.map(e=>(0,z.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{htmlFor:`automation-notify`,className:K,children:s(`automations.form.notification`)}),(0,z.jsxs)(`select`,{id:`automation-notify`,value:_,onChange:e=>y(e.target.value),className:G,children:[(0,z.jsx)(`option`,{value:`app`,children:s(`automations.form.notifyApp`)}),(0,z.jsx)(`option`,{value:`off`,children:s(`automations.form.notifyOff`)})]})]})]}),(0,z.jsxs)(`div`,{className:`flex justify-end gap-3 border-t border-gray-200 pt-4 dark:border-dark-300`,children:[(0,z.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:s(`common.cancel`)}),(0,z.jsx)(`button`,{onClick:()=>{if(!b)return;let e=n.find(e=>e.name===h);o({name:c.trim(),instructions:u.trim(),triggers:f,...e?{provider:q(e),model:e.name}:{},notify:_})},disabled:r||!b,"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:s(r?`common.saving`:`common.save`)})]})]})]})}),document.body)}function te({days:e,locale:t}){let{t:n}=a(),r=e.reduce((e,t)=>e+t.succeeded,0),i=e.reduce((e,t)=>e+t.failed,0),o=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,z.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,z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,z.jsx)(`p`,{className:`text-[12px] font-medium text-gray-700 dark:text-dark-700`,children:n(`automations.runHistory`)}),(0,z.jsxs)(`p`,{className:`text-[11px] text-gray-400 dark:text-dark-500`,children:[(0,z.jsxs)(`span`,{className:`text-emerald-600 dark:text-emerald-400`,children:[r,` `,n(`automations.succeeded`)]}),` · `,(0,z.jsxs)(`span`,{className:`text-red-500 dark:text-red-400`,children:[i,` `,n(`automations.failed`)]})]})]}),(0,z.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,z.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/o*48)),i=Math.round(e.failed/n*r);return(0,z.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,z.jsx)(`div`,{className:`w-full bg-emerald-500/80`,style:{height:r-i}}),i>0&&(0,z.jsx)(`div`,{className:`w-full bg-red-500/80`,style:{height:i}})]},t)})})]})}var ne=[{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}]}],Y=w(`pages:automations`),X=()=>{let{t:e,i18n:t}=a(),n=i(),r=c(e=>e.models),d=c(e=>e.loadModels),[v,w]=(0,j.useState)(`automations`),[D,O]=(0,j.useState)([]),[k,A]=(0,j.useState)([]),[M,N]=(0,j.useState)(null),[P,F]=(0,j.useState)(!0),[I,R]=(0,j.useState)(!1),[B,V]=(0,j.useState)(null),[H,U]=(0,j.useState)(null),[W,G]=(0,j.useState)(!1),[K,q]=(0,j.useState)(null),[J,X]=(0,j.useState)(0),Q=(0,j.useCallback)(()=>X(e=>e+1),[]);(0,j.useEffect)(()=>{let t=!1;return Promise.all([T.getAutomations(),T.getRuns(),T.getRunsSummary()]).then(([e,n,r])=>{t||(e.success&&e.data&&O(e.data),n.success&&n.data&&A(n.data),r.success&&r.data&&N(r.data))}).catch(n=>{t||(Y.error(`Failed to load automations:`,n),C.error(e(`automations.loadFailed`)))}).finally(()=>{t||F(!1)}),()=>{t=!0}},[J,e]),(0,j.useEffect)(()=>{r.length===0&&d({quiet:!0})},[r.length,d]),(0,j.useEffect)(()=>{v===`runs`&&T.markRunsSeen().then(()=>T.getRunsSummary()).then(e=>{e.success&&e.data&&N(e.data)}).catch(()=>void 0)},[v,k.length]);let re=()=>{V(null),U(null),R(!0)},ie=t=>{V(null),U({name:e(`automations.templates.${t.id}.name`),instructions:t.instructions,triggers:t.triggers}),R(!0)},ae=e=>{V(e),U(null),q(null),R(!0)},oe=async t=>{G(!0);try{let n=B?await T.updateAutomation(B.id,t):await T.createAutomation(t);n.success?(R(!1),Q()):C.error(n.error||e(`automations.saveFailed`))}catch(t){Y.error(`Failed to save automation:`,t),C.error(e(`automations.saveFailed`))}finally{G(!1)}},$=async(t,n)=>{q(null);try{n===`pause`?await T.pauseAutomation(t.id):n===`resume`?await T.resumeAutomation(t.id):n===`run`?(await T.runAutomationNow(t.id),C.success(e(`automations.runQueued`))):await T.deleteAutomation(t.id),Q()}catch(t){Y.error(`Automation ${n} failed:`,t),C.error(e(`automations.actionFailed`))}},se=e=>e.status===`succeeded`?(0,z.jsx)(l,{className:`h-4 w-4 text-emerald-500`}):e.status===`failed`?(0,z.jsx)(f,{className:`h-4 w-4 text-red-500`}):(0,z.jsx)(u,{className:`h-4 w-4 animate-spin text-gray-400`}),ce=t=>D.find(e=>e.id===t)?.name??e(`automations.deletedAutomation`);return(0,z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-testid":`automations-page`,children:[(0,z.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,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(`h1`,{className:`text-sm font-semibold text-gray-900 dark:text-dark-900`,children:e(`automations.title`)}),(0,z.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,z.jsx)(`button`,{onClick:()=>w(t),"data-testid":`automations-tab-${t}`,className:s(`rounded-[10px] px-2.5 py-1 text-[12px] font-medium transition-colors`,v===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,z.jsxs)(E,{size:`sm`,onClick:re,"data-testid":`automation-new`,className:`h-7 gap-1 px-2.5 text-[12px]`,children:[(0,z.jsx)(m,{className:`h-3.5 w-3.5`}),e(`automations.newAutomation`)]})]}),(0,z.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 overflow-y-auto px-4 py-4 scrollbar-thin`,children:[v===`automations`?P?null:D.length===0?(0,z.jsxs)(`div`,{className:`px-3 py-16 text-center`,children:[(0,z.jsx)(x,{className:`mx-auto mb-2 h-6 w-6 text-gray-300 dark:text-dark-400`}),(0,z.jsx)(`p`,{className:`text-sm text-gray-400 dark:text-dark-500`,children:e(`automations.empty`)})]}):(0,z.jsx)(`div`,{className:`mx-auto w-full max-w-3xl space-y-2`,children:D.map(n=>(0,z.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,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`p`,{className:`truncate text-[14px] font-medium text-gray-900 dark:text-dark-900`,children:n.name}),(0,z.jsx)(`span`,{className:s(`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,z.jsxs)(`p`,{className:`mt-0.5 truncate text-[12px] text-gray-500 dark:text-dark-500`,children:[L(n.triggers,t.language,e),n.nextRunAt&&(0,z.jsxs)(z.Fragment,{children:[` · `,e(`automations.nextRun`,{when:new Intl.DateTimeFormat(t.language,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}).format(n.nextRunAt)})]})]})]}),(0,z.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,z.jsx)(`button`,{onClick:()=>q(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,z.jsx)(g,{className:`h-4 w-4`})}),K===n.id&&(0,z.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,z.jsx)(Z,{icon:S,label:e(`common.edit`),onClick:()=>ae(n)}),n.status===`active`?(0,z.jsx)(Z,{icon:b,label:e(`automations.pause`),onClick:()=>$(n,`pause`)}):(0,z.jsx)(Z,{icon:p,label:e(`automations.resume`),onClick:()=>$(n,`resume`)}),(0,z.jsx)(Z,{icon:y,label:e(`automations.runNow`),onClick:()=>$(n,`run`)}),(0,z.jsx)(Z,{icon:h,label:e(`common.delete`),destructive:!0,onClick:()=>$(n,`delete`)})]})]})]})},n.id))}):null,v===`automations`&&!P&&(0,z.jsxs)(`div`,{className:`mx-auto mt-8 w-full max-w-3xl`,children:[(0,z.jsx)(`p`,{className:`mb-2 text-[11px] font-medium uppercase tracking-wide text-gray-400 dark:text-dark-500`,children:e(`automations.templatesTitle`)}),(0,z.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:ne.map(n=>(0,z.jsxs)(`button`,{type:`button`,onClick:()=>ie(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,z.jsx)(`p`,{className:`text-[13px] font-medium text-gray-900 dark:text-dark-900`,children:e(`automations.templates.${n.id}.name`)}),(0,z.jsx)(`p`,{className:`mt-0.5 text-[12px] text-gray-500 dark:text-dark-500`,children:e(`automations.templates.${n.id}.description`)}),(0,z.jsx)(`p`,{className:`mt-1.5 text-[11px] text-gray-400 dark:text-dark-500`,children:L(n.triggers,t.language,e)})]},n.id))})]}),v===`runs`&&(0,z.jsxs)(`div`,{className:`mx-auto w-full max-w-3xl space-y-4`,children:[M&&(0,z.jsx)(te,{days:M.days,locale:t.language}),k.length===0?(0,z.jsxs)(`div`,{className:`px-3 py-12 text-center`,children:[(0,z.jsx)(_,{className:`mx-auto mb-2 h-6 w-6 text-gray-300 dark:text-dark-400`}),(0,z.jsx)(`p`,{className:`text-sm text-gray-400 dark:text-dark-500`,children:e(`automations.noRuns`)})]}):(0,z.jsx)(`div`,{className:`space-y-1`,"data-testid":`automation-run-list`,children:k.map(r=>(0,z.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:[se(r),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`p`,{className:`truncate text-[13px] text-gray-900 dark:text-dark-900`,children:ce(r.automationId)}),(0,z.jsxs)(`p`,{className:`truncate text-[11px] text-gray-400 dark:text-dark-500`,children:[o(r.scheduledFor,t.language),r.error&&(0,z.jsxs)(z.Fragment,{children:[` · `,(0,z.jsx)(`span`,{className:`text-red-500`,children:r.error})]})]})]}),r.sessionId&&(0,z.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.id))})]})]}),(0,z.jsx)(ee,{open:I,automation:B,initial:H,models:r,saving:W,onClose:()=>R(!1),onSave:e=>void oe(e)})]})};function Z({icon:e,label:t,destructive:n,onClick:r}){return(0,z.jsxs)(`button`,{onClick:r,className:s(`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,z.jsx)(e,{className:`h-3.5 w-3.5`}),t]})}export{X as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime-hePW80VL.js";import{
|
|
1
|
+
import"./rolldown-runtime-hePW80VL.js";import{_ as e,g as t}from"./markdown-core-BK7WVOb7.js";import{t as n}from"./utils-BGrdX9ie.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-BK7WVOb7.js";import{n as r}from"./react-vendor-BG_HPV6X.js";import{f as i}from"./router-vendor-CbexJIsv.js";import{t as a}from"./useTranslation-5b5UhAc9.js";import{t as o}from"./utils-BGrdX9ie.js";import{In as s,L as c,Ln as l,X as u,_ as d,f,gn as p,n as m,ur as h}from"./ui-vendor-CWjIBW-z.js";import{t as g}from"./logger-DSXjF4ye.js";import{D as _,w as v}from"./api-6bSMtSNh.js";import{t as y}from"./Button-C0r3J9G_.js";import"./ui-CV0LYmkM.js";import{b}from"../assets/index-BPsH9FII.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=n(),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:o(`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:s,i18n:c}=a(),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,a=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:o(`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:o(`flex h-6 w-6 items-center justify-center rounded-full text-[12px]`,a?`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:s(`calendar.more`,{n:p})})]})]},l)})})]})}var R=48;function ee({anchor:e,events:t,dayCount:n=7,onDayClick:r,onEventClick:i}){let{i18n:s}=a(),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(s.language,{hour:`numeric`}),[s.language]),d=(0,M.useMemo)(()=>new Intl.DateTimeFormat(s.language,{weekday:`short`,day:`numeric`}),[s.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:o(`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,s.language)} ${e.title}`,onClick:()=>i(e)},e.id))},`${e.toISOString()}-${t}`)})]},t))]})})}var z=r(),B=e=>!e||e.kind===`once`||e.kind===`hourly`?`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:o,onDelete:s}){let{t:c}=a(),l=e?.startAt??t,[u,f]=(0,M.useState)(e?.title??``),[p,h]=(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;o({title:u.trim(),notes:p.trim()?p.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=>f(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:p,onChange:e=>h(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)(d,{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=g(`pages:calendar`),K=()=>{let{t:e,i18n:t}=a(),n=i(),[r,d]=(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)(null),q=M.useRef(null),J=(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]),[Y,ne]=(0,M.useState)(0),X=(0,M.useCallback)(()=>ne(e=>e+1),[]);(0,M.useEffect)(()=>{_.getCalendars().then(e=>{e.success&&e.data&&V(e.data)}).catch(e=>G.error(`Failed to load calendars:`,e))},[Y]),(0,M.useEffect)(()=>{let t=!1;return _.getEvents(J.from,J.to).then(e=>{t||e.success&&e.data&&w(e.data)}).catch(n=>{t||(G.error(`Failed to load calendar events:`,n),h.error(e(`calendar.loadFailed`)))}),Promise.all([v.getOccurrences(J.from,J.to),v.getRuns({from:J.from,to:J.to}),v.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}},[J.from,J.to,Y,e]);let Z=(0,M.useMemo)(()=>[...C,...T].sort((e,t)=>e.startAt-t.startAt),[C,T]),Q=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)},re=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`){h(e(`calendar.sharedReadOnly`));return}if(t.baseEventId){let e=C.find(e=>e.id===t.baseEventId);P(e??t)}else P(t);k(!0)},ie=async t=>{z(!0);try{let n=j?await _.updateEvent(j.id,t):await _.createEvent(t);n.success?(k(!1),X()):h.error(n.error||e(`calendar.saveFailed`))}catch(t){G.error(`Failed to save calendar event:`,t),h.error(e(`calendar.saveFailed`))}finally{z(!1)}},ae=async()=>{if(j){z(!0);try{let t=await _.deleteEvent(j.id);t.success?(k(!1),X()):h.error(t.error||e(`calendar.deleteFailed`))}catch(t){G.error(`Failed to delete calendar event:`,t),h.error(e(`calendar.deleteFailed`))}finally{z(!1)}}},oe=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)),se=async()=>{let t=H.trim();t&&((await _.createCalendar({name:t}).catch(()=>void 0))?.success?(U(``),X()):h.error(e(`calendar.calendarSaveFailed`)))},ce=async t=>{try{let e=await _.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),h.error(e(`calendar.exportFailed`))}},le=async t=>{try{let n=await t.text(),r=await _.importIcs(n);r.success&&r.data?(h.success(e(`calendar.importResult`,{total:r.data.imported})),X()):h.error(r.error||e(`calendar.importFailed`))}catch(t){G.error(`Failed to import the calendar:`,t),h.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 items-center gap-2`,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:oe})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,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`,{onClick:()=>d(t),"data-testid":`calendar-view-${t}`,className:o(`rounded-[10px] px-2.5 py-1 text-[12px] font-medium transition-colors`,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:()=>Q(-1),className:`h-7 w-7 p-0`,title:e(`calendar.previous`),children:(0,N.jsx)(l,{className:`h-4 w-4`})}),(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:()=>Q(1),className:`h-7 w-7 p-0`,title:e(`calendar.next`),children:(0,N.jsx)(s,{className:`h-4 w-4`})})]}),(0,N.jsxs)(y,{size:`sm`,onClick:()=>$(g),"data-testid":`calendar-new-event`,className:`h-7 gap-1 px-2.5 text-[12px]`,children:[(0,N.jsx)(u,{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 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 rounded-full`,style:{backgroundColor:t.color??`#8b8b8b`}}),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:()=>K(t),className:`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 _.deleteCalendar(t.id).then(X),className:`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.jsx)(`input`,{type:`text`,value:H,onChange:e=>U(e.target.value),onKeyDown:e=>{e.key===`Enter`&&se()},placeholder:e(`calendar.newCalendarPlaceholder`),className:`w-36 rounded-full border border-dashed border-black/[0.12] bg-transparent px-2.5 py-1 text-xs text-gray-700 placeholder:text-gray-400 focus:outline-none dark:border-white/[0.16] dark:text-dark-800`,"data-testid":`calendar-new-calendar`}),(0,N.jsxs)(`div`,{className:`ms-auto flex items-center gap-1`,children:[(0,N.jsx)(`input`,{ref:q,type:`file`,accept:`.ics,text/calendar`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&le(t),e.target.value=``}}),(0,N.jsxs)(y,{size:`sm`,variant:`ghost`,onClick:()=>q.current?.click(),className:`h-7 gap-1 px-2 text-[12px]`,"data-testid":`calendar-import`,children:[(0,N.jsx)(f,{className:`h-3.5 w-3.5`}),e(`calendar.importIcs`)]}),(0,N.jsxs)(y,{size:`sm`,variant:`ghost`,onClick:()=>void ce(),className:`h-7 gap-1 px-2 text-[12px]`,"data-testid":`calendar-export`,children:[(0,N.jsx)(p,{className:`h-3.5 w-3.5`}),e(`calendar.exportIcs`)]})]})]}),r===`month`?(0,N.jsx)(L,{year:g.getFullYear(),monthIndex:g.getMonth(),events:Z,onDayClick:e=>$(e),onEventClick:re}):(0,N.jsx)(ee,{anchor:g,events:Z,dayCount:r===`day`?1:7,onDayClick:(e,t)=>$(e,t),onEventClick:re}),W&&(0,N.jsx)(b,{resourceType:`calendar`,resourceId:W.id,resourceLabel:W.name,onClose:()=>K(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 ie(e),onDelete:()=>void ae()})]})};export{K as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-BK7WVOb7.js";import{i as r}from"./router-vendor-CbexJIsv.js";import{t as i}from"./useTranslation-5b5UhAc9.js";import{r as a,t as o}from"./utils-BGrdX9ie.js";import{t as s}from"./chatStore-DbZPJNsu.js";import{$ as c,B as l,Dt as u,Tt as d,V as f,X as p,Xn as ee,_ as te,bt as m,it as ne,n as h,rr as re,s as ie,tt as ae,un as oe,ur as g,xn as _,yt as v,zn as y,zt as b}from"./ui-vendor-CWjIBW-z.js";import{t as x}from"./logger-DSXjF4ye.js";import{E as S}from"./api-6bSMtSNh.js";import{n as se}from"./authStore-DbqqrfZv.js";import{t as C}from"./Button-C0r3J9G_.js";import{i as w,n as T,r as E}from"./ui-CV0LYmkM.js";import{y as ce}from"../assets/index-BPsH9FII.js";var D=e(t(),1),O=n(),le=[`👍`,`🎉`,`❤️`,`😄`,`👀`,`🚀`],ue=({message:e,currentUserId:t,canModerate:n,actions:r,compact:s=!1})=>{let{t:l,i18n:d}=i(),[f,p]=(0,D.useState)(!1),[m,re]=(0,D.useState)(e.content),[ie,g]=(0,D.useState)(!1),_=e.authorKind===`model`,b=!_&&e.author?.userId===t&&!e.deleted,x=_?e.model??l(`channels.modelAuthor`):e.author?.username??l(`channels.unknownAuthor`);return(0,O.jsxs)(`div`,{className:o(`group relative rounded-xl px-2.5 py-1.5 hover:bg-black/[0.025] dark:hover:bg-white/[0.03]`,s&&`px-2 py-1`),"data-testid":`channel-message`,children:[(0,O.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[_&&(0,O.jsx)(ee,{className:`h-3.5 w-3.5 shrink-0 self-center text-primary-500`}),(0,O.jsx)(`span`,{className:o(`shrink-0 text-[13px] font-semibold`,_?`text-primary-600 dark:text-primary-400`:`text-gray-900 dark:text-dark-900`),children:x}),(0,O.jsx)(`span`,{className:`shrink-0 text-[11px] text-gray-400 dark:text-dark-500`,children:a(e.createdAt,d.language)}),e.editedAt&&!e.deleted&&(0,O.jsx)(`span`,{className:`shrink-0 text-[10px] text-gray-400 dark:text-dark-500`,children:l(`channels.edited`)}),e.pinnedAt&&(0,O.jsx)(c,{className:`h-3 w-3 shrink-0 text-amber-500`})]}),e.deleted?(0,O.jsx)(`p`,{className:`text-[13px] italic text-gray-400 dark:text-dark-500`,children:l(`channels.deletedMessage`)}):f?(0,O.jsxs)(`div`,{className:`mt-1 flex items-end gap-1.5`,children:[(0,O.jsx)(`textarea`,{value:m,onChange:e=>re(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,O.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,O.jsx)(y,{className:`h-3.5 w-3.5`})}),(0,O.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,O.jsx)(h,{className:`h-3.5 w-3.5`})})]}):(0,O.jsxs)(O.Fragment,{children:[e.pending?(0,O.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[13px] text-gray-400 dark:text-dark-500`,children:[(0,O.jsx)(u,{className:`h-3.5 w-3.5 animate-spin`}),l(`channels.modelThinking`)]}):e.error?(0,O.jsx)(`p`,{className:`text-[13px] text-red-500`,children:e.error}):(0,O.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-[13px] leading-relaxed text-gray-800 dark:text-dark-800`,children:e.content}),(e.attachments?.length??0)>0&&(0,O.jsx)(`div`,{className:`mt-1 space-y-1`,children:e.attachments.map(e=>(0,O.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,O.jsx)(ne,{className:`h-3 w-3`}),(0,O.jsx)(`span`,{className:`min-w-0 truncate`,children:e.filename})]},e.id))})]}),(e.reactions?.length??0)>0&&(0,O.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:e.reactions.map(t=>(0,O.jsxs)(`button`,{type:`button`,onClick:()=>void r.onReact(e,t.emoji,t.mine),className:o(`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))}),!s&&(e.replyCount??0)>0&&r.onReply&&(0,O.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,O.jsx)(v,{className:`h-3 w-3`}),l(`channels.replyCount`,{total:e.replyCount})]}),!e.deleted&&!f&&(0,O.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,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>g(e=>!e),className:`rounded p-1 text-gray-400 hover:text-gray-700 dark:hover:text-dark-800`,title:l(`channels.react`),"data-testid":`channel-react`,children:(0,O.jsx)(oe,{className:`h-3.5 w-3.5`})}),ie&&(0,O.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,O.jsx)(`button`,{type:`button`,onClick:()=>{let n=!!e.reactions?.find(e=>e.emoji===t)?.mine;r.onReact(e,t,n),g(!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,O.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:l(`channels.reply`),"data-testid":`channel-reply`,children:(0,O.jsx)(v,{className:`h-3.5 w-3.5`})}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>void r.onPin(e),className:`rounded p-1 text-gray-400 hover:text-amber-500`,title:e.pinnedAt?l(`channels.unpin`):l(`channels.pin`),"data-testid":`channel-pin`,children:(0,O.jsx)(c,{className:`h-3.5 w-3.5`})}),b&&(0,O.jsx)(`button`,{type:`button`,onClick:()=>{re(e.content),p(!0)},className:`rounded p-1 text-gray-400 hover:text-gray-700 dark:hover:text-dark-800`,title:l(`channels.edit`),"data-testid":`channel-edit`,children:(0,O.jsx)(ae,{className:`h-3.5 w-3.5`})}),(b||n)&&(0,O.jsx)(`button`,{type:`button`,onClick:()=>void r.onDelete(e),className:`rounded p-1 text-gray-400 hover:text-red-500`,title:l(`channels.deleteMessage`),"data-testid":`channel-delete-message`,children:(0,O.jsx)(te,{className:`h-3.5 w-3.5`})})]})]})},k=x(`pages:channels`),de=e=>e.type===`dm`?(0,O.jsx)(m,{className:`h-3.5 w-3.5 shrink-0`}):e.type===`private`?(0,O.jsx)(d,{className:`h-3.5 w-3.5 shrink-0`}):(0,O.jsx)(b,{className:`h-3.5 w-3.5 shrink-0`}),fe=e=>e.type===`dm`?e.dmPeer?.username??`…`:e.name,pe=()=>{let{t:e}=i(),t=se(e=>e.user),n=s(e=>e.models),[a,d]=(0,D.useState)([]),[te,ae]=(0,D.useState)(null),[oe,y]=(0,D.useState)(!1),[b,x]=(0,D.useState)(!0),[w,T]=(0,D.useState)(null),[E,le]=(0,D.useState)(null),[pe,A]=(0,D.useState)([]),[ve,ye]=(0,D.useState)([]),[j,M]=(0,D.useState)(null),[N,P]=(0,D.useState)(null),[be,F]=(0,D.useState)([]),[I,L]=(0,D.useState)(``),[R,xe]=(0,D.useState)(``),[z,Se]=(0,D.useState)(!1),[B,V]=(0,D.useState)(null),[Ce,H]=(0,D.useState)(!1),[we,U]=(0,D.useState)(!1),[W,Te]=(0,D.useState)(``),[Ee,G]=(0,D.useState)(!1),De=(0,D.useRef)(null),Oe=(0,D.useRef)(null),[ke,Ae]=r(),K=(0,D.useMemo)(()=>a.find(e=>e.id===w)??null,[a,w]),[je,Me]=(0,D.useState)(null);w!==je&&(Me(w),le(null),P(null),M(null));let q=K?.role===`owner`,J=(0,D.useCallback)(()=>{S.listMine().then(e=>{e.success&&e.data&&d(e.data)}).catch(e=>k.error(`Failed to load channels:`,e)).finally(()=>x(!1))},[]);(0,D.useEffect)(()=>{J();let e=window.setInterval(J,3e4);return()=>window.clearInterval(e)},[J]);let Y=ke.get(`channel`);Y&&w!==Y&&T(Y),(0,D.useEffect)(()=>{Y&&Ae({},{replace:!0})},[Y,Ae]);let X=(0,D.useCallback)(e=>{S.listMessages(e,{limit:100}).then(e=>{e.success&&e.data&&le(e.data)}).catch(e=>k.error(`Failed to load messages:`,e))},[]),Ne=(0,D.useRef)(null);(0,D.useEffect)(()=>{Ne.current=N},[N]);let Pe=(0,D.useCallback)(e=>{X(e),S.markRead(e);let t=Ne.current;t&&S.thread(t).then(e=>{e.success&&e.data&&F(e.data)})},[X]);(0,D.useEffect)(()=>{if(!w)return;X(w),S.markRead(w).then(J);let e=new AbortController;return ce({path:`/channels/${w}/events`,signal:e.signal,onEvent:()=>Pe(w)}),()=>e.abort()},[w,X,J,Pe]);let Fe=E?.length??0;(0,D.useEffect)(()=>{let e=Oe.current;e&&(e.scrollTop=e.scrollHeight)},[Fe,w]),(0,D.useEffect)(()=>{!w||!j||(j===`members`?S.listMembers(w).then(e=>{e.success&&e.data&&A(e.data)}):S.listPins(w).then(e=>{e.success&&e.data&&ye(e.data)}))},[w,j]),(0,D.useEffect)(()=>{N&&S.thread(N).then(e=>{e.success&&e.data&&F(e.data)})},[N]);let Ie=()=>{y(!0),S.listPublic().then(e=>{e.success&&e.data&&ae(e.data)})},Z=async t=>{if(!w||z)return;let n=I.trim();if(!(!n&&!B)){Se(!0);try{let r=await S.postMessage(w,{content:n,...t?{parentId:t}:{},...B?{attachmentIds:[B.id]}:{},...R?{mentionModel:R}:{}});if(r.success){if(L(``),V(null),xe(``),X(w),t){let e=await S.thread(t);e.success&&e.data&&F(e.data)}}else g.error(r.error||e(`channels.sendFailed`))}catch(t){k.error(`Failed to send message:`,t),g.error(e(`channels.sendFailed`))}finally{Se(!1)}}},Le=async t=>{if(w)try{let n=await S.uploadAttachment(w,t);n.success&&n.data?V({id:n.data.id,filename:n.data.filename}):g.error(n.error||e(`channels.uploadFailed`))}catch(t){k.error(`Failed to upload attachment:`,t),g.error(e(`channels.uploadFailed`))}},Re=async()=>{if(!(!w||!W.trim()))if((await S.addMember(w,W.trim()).catch(()=>void 0))?.success){Te(``);let t=await S.listMembers(w);t.success&&t.data&&A(t.data),g.success(e(`channels.memberAdded`))}else g.error(e(`channels.memberAddFailed`))},Q={onReply:e=>P(e.id),onEdit:async(e,t)=>{(await S.editMessage(e.id,t).catch(()=>void 0))?.success&&w&&X(w)},onDelete:async e=>{(await S.deleteMessage(e.id).catch(()=>void 0))?.success&&w&&X(w)},onPin:async e=>{await S.setPinned(e.id,!e.pinnedAt).catch(()=>void 0),w&&X(w)},onReact:async(e,t,n)=>{n?await S.removeReaction(e.id,t).catch(()=>void 0):await S.addReaction(e.id,t).catch(()=>void 0),w&&X(w)},onDownload:async(e,t)=>{try{let n=await S.downloadAttachment(e),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=t,i.click(),URL.revokeObjectURL(r)}catch(e){k.error(`Failed to download attachment:`,e)}}},$=be[0];return(0,O.jsxs)(`div`,{className:`flex h-full min-h-0`,children:[(0,O.jsxs)(`aside`,{className:o(`flex w-64 shrink-0 flex-col border-r border-black/[0.06] dark:border-white/[0.06]`,w?`hidden md:flex`:`flex`),"data-testid":`channel-rail`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-1 px-3 py-2.5`,children:[(0,O.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,O.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,O.jsx)(_,{className:`h-4 w-4`})}),(0,O.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,O.jsx)(m,{className:`h-4 w-4`})}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>H(!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,O.jsx)(p,{className:`h-4 w-4`})})]}),(0,O.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-2 pb-3 scrollbar-thin`,children:b?(0,O.jsx)(u,{className:`mx-auto mt-6 h-4 w-4 animate-spin text-gray-400`}):a.length===0?(0,O.jsx)(`p`,{className:`px-2 pt-6 text-center text-xs text-gray-400 dark:text-dark-500`,children:e(`channels.empty`)}):a.map(e=>(0,O.jsxs)(`button`,{type:`button`,onClick:()=>T(e.id),className:o(`flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-[13px]`,w===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,O.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:fe(e)}),(e.unreadCount??0)>0&&(0,O.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,O.jsx)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:K?(0,O.jsxs)(O.Fragment,{children:[(0,O.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,O.jsx)(`button`,{type:`button`,onClick:()=>T(null),className:`rounded-md p-1 text-gray-500 hover:bg-black/[0.04] md:hidden dark:text-dark-600`,children:(0,O.jsx)(re,{className:`h-4 w-4`})}),de(K),(0,O.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,O.jsx)(`button`,{type:`button`,onClick:()=>M(j===`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,O.jsx)(c,{className:`h-4 w-4`})}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>M(j===`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,O.jsx)(ie,{className:`h-4 w-4`})}),q&&K.type!==`dm`&&(0,O.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,O.jsx)(l,{className:`h-4 w-4`})})]}),(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,O.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:E===null?(0,O.jsx)(u,{className:`mx-auto mt-6 h-4 w-4 animate-spin text-gray-400`}):E.length===0?(0,O.jsx)(`p`,{className:`pt-8 text-center text-xs text-gray-400 dark:text-dark-500`,children:e(`channels.noMessages`)}):E.map(e=>(0,O.jsx)(ue,{message:e,currentUserId:t?.id,canModerate:q,actions:Q},e.id))}),(0,O.jsxs)(`div`,{className:`border-t border-black/[0.06] p-3 dark:border-white/[0.06]`,children:[B&&(0,O.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,O.jsx)(ne,{className:`h-3.5 w-3.5`}),(0,O.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:B.filename}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>V(null),className:`text-gray-400 hover:text-red-500`,children:(0,O.jsx)(h,{className:`h-3.5 w-3.5`})})]}),(0,O.jsxs)(`div`,{className:`flex items-end gap-1.5`,children:[(0,O.jsx)(`input`,{ref:De,type:`file`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&Le(t),e.target.value=``}}),(0,O.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,O.jsx)(ne,{className:`h-4 w-4`})}),(0,O.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(ee,{className:o(`h-4 w-4`,R?`text-primary-500`:`text-gray-400 dark:text-dark-500`)}),(0,O.jsxs)(`select`,{value:R,onChange:e=>xe(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,O.jsx)(`option`,{value:``,children:e(`channels.noModel`)}),n.map(e=>(0,O.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),(0,O.jsx)(`textarea`,{value:I,onChange:e=>L(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Z())},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,O.jsx)(C,{size:`sm`,disabled:z||!I.trim()&&!B,onClick:()=>void Z(),"data-testid":`channel-send`,children:z?(0,O.jsx)(u,{className:`h-4 w-4 animate-spin`}):(0,O.jsx)(f,{className:`h-4 w-4`})})]})]})]}),N&&(0,O.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,O.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,O.jsx)(`span`,{className:`flex-1 text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-dark-600`,children:e(`channels.thread`)}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>P(null),className:`rounded-md p-1 text-gray-400 hover:bg-black/[0.04] dark:hover:bg-white/[0.06]`,children:(0,O.jsx)(h,{className:`h-3.5 w-3.5`})})]}),(0,O.jsx)(`div`,{className:`min-h-0 flex-1 space-y-1 overflow-y-auto px-3 py-2 scrollbar-thin`,children:be.map(e=>(0,O.jsx)(ue,{message:e,currentUserId:t?.id,canModerate:q,actions:{...Q,onReply:void 0},compact:!0},e.id))}),(0,O.jsxs)(`div`,{className:`flex items-end gap-1.5 border-t border-black/[0.06] p-2 dark:border-white/[0.06]`,children:[(0,O.jsx)(`textarea`,{value:I,onChange:e=>L(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),$&&Z($.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,O.jsx)(C,{size:`sm`,disabled:z||!I.trim(),onClick:()=>$&&void Z($.id),children:(0,O.jsx)(f,{className:`h-3.5 w-3.5`})})]})]}),j&&(0,O.jsxs)(`aside`,{className:`flex w-72 shrink-0 flex-col border-l border-black/[0.06] dark:border-white/[0.06]`,"data-testid":`channel-${j}-panel`,children:[(0,O.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,O.jsx)(`span`,{className:`flex-1 text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-dark-600`,children:e(j===`members`?`channels.members`:`channels.pins`)}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>M(null),className:`rounded-md p-1 text-gray-400 hover:bg-black/[0.04] dark:hover:bg-white/[0.06]`,children:(0,O.jsx)(h,{className:`h-3.5 w-3.5`})})]}),(0,O.jsx)(`div`,{className:`min-h-0 flex-1 space-y-1.5 overflow-y-auto px-3 py-2 scrollbar-thin`,children:j===`members`?(0,O.jsxs)(O.Fragment,{children:[q&&K.type===`private`&&(0,O.jsxs)(`div`,{className:`mb-2 flex gap-1.5`,children:[(0,O.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,O.jsx)(C,{size:`sm`,disabled:!W.trim(),onClick:()=>void Re(),"data-testid":`channel-invite-submit`,children:(0,O.jsx)(p,{className:`h-3.5 w-3.5`})})]}),pe.map(n=>(0,O.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,O.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n.username}),(0,O.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,O.jsx)(`button`,{type:`button`,onClick:()=>void S.removeMember(K.id,n.userId).then(()=>A(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,O.jsx)(h,{className:`h-3 w-3`})})]},n.userId)),!q&&K.type!==`dm`&&(0,O.jsx)(C,{size:`sm`,variant:`ghost`,className:`mt-2 w-full text-red-500`,onClick:()=>void S.removeMember(K.id,t?.id??``).then(()=>{T(null),J()}),"data-testid":`channel-leave`,children:e(`channels.leave`)})]}):ve.length===0?(0,O.jsx)(`p`,{className:`pt-4 text-center text-xs text-gray-400 dark:text-dark-500`,children:e(`channels.noPins`)}):ve.map(e=>(0,O.jsx)(ue,{message:e,currentUserId:t?.id,canModerate:q,actions:Q,compact:!0},e.id))})]})]})]}):(0,O.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-2 text-gray-400 dark:text-dark-500`,children:[(0,O.jsx)(v,{className:`h-8 w-8`}),(0,O.jsx)(`p`,{className:`text-sm`,children:e(`channels.selectPrompt`)})]})}),Ce&&(0,O.jsx)(me,{onClose:()=>H(!1),onCreated:e=>{H(!1),J(),T(e.id)}}),we&&(0,O.jsx)(he,{onClose:()=>U(!1),onOpened:e=>{U(!1),J(),T(e.id)}}),oe&&(0,O.jsx)(ge,{channels:te,onClose:()=>y(!1),onJoined:e=>{y(!1),J(),T(e)}}),Ee&&K&&(0,O.jsx)(_e,{channel:K,onClose:()=>G(!1),onChanged:()=>{G(!1),J()},onDeleted:()=>{G(!1),T(null),J()}})]})},me=({onClose:e,onCreated:t})=>{let{t:n}=i(),[r,a]=(0,D.useState)(``),[o,s]=(0,D.useState)(`public`),[c,l]=(0,D.useState)(``),[u,d]=(0,D.useState)(!1);return(0,O.jsxs)(T,{titleId:`create-channel-title`,title:n(`channels.newChannel`),onClose:e,testId:`create-channel-modal`,footer:(0,O.jsx)(C,{size:`sm`,disabled:u||!r.trim(),onClick:()=>{d(!0),S.create({type:o,name:r.trim(),...c.trim()?{description:c.trim()}:{}}).then(e=>{e.success&&e.data?t(e.data):g.error(e.error||n(`channels.createFailed`))}).catch(()=>g.error(n(`channels.createFailed`))).finally(()=>d(!1))},"data-testid":`create-channel-submit`,children:n(`channels.create`)}),children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`label`,{className:w,children:n(`channels.nameLabel`)}),(0,O.jsx)(`input`,{className:E,value:r,onChange:e=>a(e.target.value),"data-testid":`create-channel-name`})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`label`,{className:w,children:n(`channels.typeLabel`)}),(0,O.jsxs)(`select`,{className:E,value:o,onChange:e=>s(e.target.value),"data-testid":`create-channel-type`,children:[(0,O.jsx)(`option`,{value:`public`,children:n(`channels.typePublic`)}),(0,O.jsx)(`option`,{value:`private`,children:n(`channels.typePrivate`)})]})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`label`,{className:w,children:n(`channels.descriptionLabel`)}),(0,O.jsx)(`textarea`,{className:E,rows:2,value:c,onChange:e=>l(e.target.value)})]})]})},he=({onClose:e,onOpened:t})=>{let{t:n}=i(),[r,a]=(0,D.useState)(``),[o,s]=(0,D.useState)(!1),c=()=>{r.trim()&&(s(!0),S.openDm(r.trim()).then(e=>{e.success&&e.data?t(e.data):g.error(e.error||n(`channels.dmFailed`))}).catch(()=>g.error(n(`channels.dmFailed`))).finally(()=>s(!1)))};return(0,O.jsx)(T,{titleId:`open-dm-title`,title:n(`channels.newDm`),subtitle:n(`channels.dmHint`),onClose:e,testId:`open-dm-modal`,footer:(0,O.jsx)(C,{size:`sm`,disabled:o||!r.trim(),onClick:c,"data-testid":`open-dm-submit`,children:n(`channels.openDm`)}),children:(0,O.jsx)(`input`,{className:E,value:r,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&c()},placeholder:n(`channels.dmPlaceholder`),"data-testid":`open-dm-username`})})},ge=({channels:e,onClose:t,onJoined:n})=>{let{t:r}=i();return(0,O.jsx)(T,{titleId:`browse-channels-title`,title:r(`channels.browsePublic`),onClose:t,testId:`browse-channels-modal`,children:e===null?(0,O.jsx)(u,{className:`mx-auto h-4 w-4 animate-spin text-gray-400`}):e.length===0?(0,O.jsx)(`p`,{className:`text-center text-xs text-gray-400 dark:text-dark-500`,children:r(`channels.noPublic`)}):e.map(e=>(0,O.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,O.jsx)(b,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}),(0,O.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] text-gray-800 dark:text-dark-800`,children:e.name}),e.isMember?(0,O.jsx)(`span`,{className:`text-[11px] text-gray-400`,children:r(`channels.joined`)}):(0,O.jsx)(C,{size:`sm`,onClick:()=>void S.join(e.id).then(()=>n(e.id)),"data-testid":`browse-channel-join`,children:r(`channels.join`)})]},e.id))})},_e=({channel:e,onClose:t,onChanged:n,onDeleted:r})=>{let{t:a}=i(),[o,s]=(0,D.useState)(e.name),[c,l]=(0,D.useState)(e.description??``),[u,d]=(0,D.useState)(!1);return(0,O.jsxs)(T,{titleId:`channel-settings-title`,title:a(`channels.settings`),onClose:t,testId:`channel-settings-modal`,footer:(0,O.jsxs)(`div`,{className:`flex w-full items-center justify-between`,children:[(0,O.jsx)(C,{size:`sm`,variant:`ghost`,className:`text-red-500`,onClick:()=>void S.delete(e.id).then(e=>{e.success&&r()}),"data-testid":`channel-delete`,children:a(`channels.delete`)}),(0,O.jsx)(C,{size:`sm`,disabled:u||!o.trim(),onClick:()=>{d(!0),S.update(e.id,{name:o.trim(),description:c.trim()}).then(e=>{e.success&&n()}).finally(()=>d(!1))},"data-testid":`channel-settings-save`,children:a(`channels.save`)})]}),children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`label`,{className:w,children:a(`channels.nameLabel`)}),(0,O.jsx)(`input`,{className:E,value:o,onChange:e=>s(e.target.value)})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`label`,{className:w,children:a(`channels.descriptionLabel`)}),(0,O.jsx)(`textarea`,{className:E,rows:2,value:c,onChange:e=>l(e.target.value)})]})]})};export{pe as default};
|