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
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/SettingsModal-R9EDadAV.js","js/rolldown-runtime-hePW80VL.js","js/markdown-core-BK7WVOb7.js","js/router-vendor-CbexJIsv.js","js/useTranslation-5b5UhAc9.js","js/utils-BGrdX9ie.js","js/utils-vendor-9bQ62WeD.js","js/chatStore-DbZPJNsu.js","js/i18next-DgmgtwsV.js","js/ui-vendor-CWjIBW-z.js","js/logger-DSXjF4ye.js","js/api-6bSMtSNh.js","js/config-8KdgjtEx.js","js/workApi-BruWTlHM.js","js/imageGenModels-Dx_QMLJQ.js","js/authStore-DbqqrfZv.js","js/appStore-CdObhQBb.js","js/messageCodeStyles-DhVgizF-.js","js/Button-C0r3J9G_.js","js/ui-CV0LYmkM.js","js/react-vendor-BG_HPV6X.js","js/SettingsToggle-BIVyfGjl.js","js/thinking-DwlkTfPX.js","js/HomePage-BqNy-FWX.js","js/work-DVgm81bJ.js","js/ChatPage-BAgBHUES.js","js/welcomePrompts-to5mv_gx.js","js/ArtifactSandboxFrame-REazyIrx.js","js/ArtifactContainer-CIoFoMv8.js","js/OptimizedSyntaxHighlighter-CZNPwN0i.js","js/syntax-highlight-DcR9Vhb7.js","js/evaluationsApi-CwZJsgeG.js","js/ModelSelector-ol8mK2ja.js","js/PersonasPage-M_WKH2a9.js","js/GalleryPage-DHz9DkK7.js","js/NotesPage-DzHEx2O4.js","js/RichMessageContent-BqgafH4p.js","js/markdown-math-e1ByS3KY.js","assets/markdown-math-Ddr6Z9Sf.css","js/CalendarPage-DLjasZOd.js","js/calendarDates-Co3o_05Y.js","js/AutomationsPage-Dow_lbIf.js","js/LibreClawPage-BDzDILjY.js","js/ChannelsPage-C8hvTD7J.js","js/WorkPage-DxZISerQ.js","js/UserManagementPage-BOuaX3ay.js","js/PluginUsagePage-Ctoka6JZ.js","js/EvaluationsPage-Bm8FRoeX.js","js/SystemPage-aOkrSuY7.js","js/ArtifactDemoPage-D0JEIAbZ.js","js/ArtifactSlideOutPanel-A-i94ghF.js","js/FirstTimeSetup-BxJapNul.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"../js/rolldown-runtime-hePW80VL.js";import{_ as t,g as n,l as r}from"../js/markdown-core-BK7WVOb7.js";import{n as i,t as a}from"../js/react-vendor-BG_HPV6X.js";import{_ as o,a as s,b as c,c as l,d as u,f as d,g as f,h as p,l as m,m as h,n as g,o as _,r as v,s as y,t as b,v as x,x as S,y as C}from"../js/router-vendor-CbexJIsv.js";import{t as w}from"../js/useTranslation-5b5UhAc9.js";import{a as T,i as E,o as D,r as O,s as k,t as A}from"../js/utils-BGrdX9ie.js";import{C as j,h as M,p as N,t as P,u as F,w as ee,x as I}from"../js/chatStore-DbZPJNsu.js";import{$ as L,$n as te,Bn as ne,Bt as R,C as re,Ct as z,Dn as ie,Dt as B,E as ae,Gn as V,H as oe,Hn as se,Ht as ce,I as le,In as ue,J as de,Jn as fe,Jt as pe,L as me,Lt as he,N as ge,Nt as H,Ot as _e,Pt as ve,Qt as ye,R as be,Rn as xe,Un as Se,Vn as Ce,X as we,Xn as Te,Yt as Ee,Zn as De,_ as Oe,_n as ke,_t as Ae,an as je,ar as Me,at as Ne,c as Pe,cr as Fe,ct as Ie,dn as Le,dt as Re,en as ze,et as Be,f as Ve,fn as He,h as Ue,hn as We,k as Ge,l as Ke,lr as U,lt as qe,m as Je,n as Ye,nt as Xe,ot as Ze,pn as Qe,r as $e,s as et,t as tt,ur as W,vt as nt,w as rt,wt as it,z as at,zn as ot}from"../js/ui-vendor-CWjIBW-z.js";import{a as st,o as ct,t as lt}from"../js/utils-vendor-9bQ62WeD.js";import{i as ut,t as dt}from"../js/logger-DSXjF4ye.js";import{t as ft}from"../js/config-8KdgjtEx.js";import{C as pt,F as mt,I as ht,M as gt,O as _t,T as vt,_ as yt,d as bt,v as xt,w as St}from"../js/api-6bSMtSNh.js";import{l as Ct,n as G,o as wt,r as K,u as Tt}from"../js/authStore-DbqqrfZv.js";import{t as Et}from"../js/appStore-CdObhQBb.js";import{n as Dt}from"../js/welcomePrompts-to5mv_gx.js";import{l as Ot}from"../js/messageCodeStyles-DhVgizF-.js";import{t as kt}from"../js/Button-C0r3J9G_.js";import{n as At,r as jt,v as Mt}from"../js/ui-CV0LYmkM.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Nt=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Pt,Ft,It,Lt=new(Pt=new WeakMap,Ft=new WeakMap,It=new WeakMap,class extends Nt{constructor(){super(),c(this,Pt,void 0),c(this,Ft,void 0),c(this,It,void 0),x(It,this,e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}})}onSubscribe(){o(Ft,this)||this.setEventListener(o(It,this))}onUnsubscribe(){this.hasListeners()||(o(Ft,this)?.call(this),x(Ft,this,void 0))}setEventListener(e){x(It,this,e),o(Ft,this)?.call(this),x(Ft,this,e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()}))}setFocused(e){o(Pt,this)!==e&&(x(Pt,this,e),this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof o(Pt,this)==`boolean`?o(Pt,this):globalThis.document?.visibilityState!==`hidden`}}),Rt,zt,Bt={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Vt=new(Rt=new WeakMap,zt=new WeakMap,class{constructor(){c(this,Rt,Bt),c(this,zt,!1)}setTimeoutProvider(e){x(Rt,this,e)}setTimeout(e,t){return o(Rt,this).setTimeout(e,t)}clearTimeout(e){o(Rt,this).clearTimeout(e)}setInterval(e,t){return o(Rt,this).setInterval(e,t)}clearInterval(e){o(Rt,this).clearInterval(e)}});function Ht(e){setTimeout(e,0)}var Ut=typeof window>`u`||`Deno`in globalThis;function Wt(){}function Gt(e,t){return typeof e==`function`?e(t):e}function Kt(e){return typeof e==`number`&&e>=0&&e!==1/0}function qt(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Jt(e,t){return typeof e==`function`?e(t):e}function Yt(e,t){return typeof e==`function`?e(t):e}function Xt(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==Qt(o,t.options))return!1}else if(!en(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function Zt(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if($t(t.options.mutationKey)!==$t(a))return!1}else if(!en(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Qt(e,t){return(t?.queryKeyHashFn||$t)(e)}function $t(e){return JSON.stringify(e,(e,t)=>on(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function en(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)&&Array.isArray(t)){for(let n=0;n<t.length;n++)if(!en(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!en(e[r],t[r]))return!1;return!0}return!1}var tn=Object.prototype.hasOwnProperty;function nn(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=an(e)&&an(t);if(!r&&!(on(e)&&on(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:tn.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=nn(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function rn(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function an(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function on(e){if(!sn(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!sn(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function sn(e){return Object.prototype.toString.call(e)===`[object Object]`}function cn(e){return new Promise(t=>{Vt.setTimeout(t,e)})}function ln(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:nn(e,t)}function un(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function dn(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var fn=Symbol();function pn(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===fn?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function mn(e,t){return typeof e==`function`?e(...t):!!e}function hn(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??(i=t()),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var gn=(()=>{let e=()=>Ut;return{isServer(){return e()},setIsServer(t){e=t}}})();function _n(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var vn=Ht;function yn(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=vn,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var q=yn(),bn,xn,Sn,Cn=new(bn=new WeakMap,xn=new WeakMap,Sn=new WeakMap,class extends Nt{constructor(){super(),c(this,bn,!0),c(this,xn,void 0),c(this,Sn,void 0),x(Sn,this,e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}})}onSubscribe(){o(xn,this)||this.setEventListener(o(Sn,this))}onUnsubscribe(){this.hasListeners()||(o(xn,this)?.call(this),x(xn,this,void 0))}setEventListener(e){x(Sn,this,e),o(xn,this)?.call(this),x(xn,this,e(this.setOnline.bind(this)))}setOnline(e){o(bn,this)!==e&&(x(bn,this,e),this.listeners.forEach(t=>{t(e)}))}isOnline(){return o(bn,this)}});function wn(e){return Math.min(1e3*2**e,3e4)}function Tn(e){return(e??`online`)!==`online`||Cn.isOnline()}var En=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function Dn(e){let t=!1,n=0,r,i=_n(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new En(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>Lt.isFocused()&&(e.networkMode===`always`||Cn.isOnline())&&e.canRun(),u=()=>Tn(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(gn.isServer()?0:3),o=e.retryDelay??wn,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){f(r);return}n++,e.onFail?.(n,r),cn(s).then(()=>l()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var On,kn=(On=new WeakMap,class{constructor(){c(this,On,void 0)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Kt(this.gcTime)&&x(On,this,Vt.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(gn.isServer()?1/0:3e5))}clearGcTimeout(){o(On,this)!==void 0&&(Vt.clearTimeout(o(On,this)),x(On,this,void 0))}});function An(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{hn(e,()=>t.signal,()=>n=!0)},u=pn(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?dn:un;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?Mn:jn,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:jn(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function jn(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Mn(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function Nn(e,t){return t?jn(e,t)!=null:!1}function Pn(e,t){return!t||!e.getPreviousPageParam?!1:Mn(e,t)!=null}function Fn(e,t){S(e,t),t.add(e)}var In,Ln,Rn,zn,Bn,Vn,Hn,Un,Wn,Gn=(In=new WeakMap,Ln=new WeakMap,Rn=new WeakMap,zn=new WeakMap,Bn=new WeakMap,Vn=new WeakMap,Hn=new WeakMap,Un=new WeakMap,Wn=new WeakSet,class extends kn{constructor(e){super(),Fn(this,Wn),c(this,In,void 0),c(this,Ln,void 0),c(this,Rn,void 0),c(this,zn,void 0),c(this,Bn,void 0),c(this,Vn,void 0),c(this,Hn,void 0),c(this,Un,void 0),x(Un,this,!1),x(Hn,this,e.defaultOptions),this.setOptions(e.options),this.observers=[],x(Bn,this,e.client),x(zn,this,o(Bn,this).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,x(Ln,this,Xn(this.options)),this.state=e.state??o(Ln,this),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return o(In,this)}get promise(){return o(Vn,this)?.promise}setOptions(e){if(this.options={...o(Hn,this),...e},e?._type&&x(In,this,e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=Xn(this.options);e.data!==void 0&&(this.setState(Yn(e.data,e.dataUpdatedAt)),x(Ln,this,e))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&o(zn,this).remove(this)}setData(e,t){let n=ln(this.state.data,e,this.options);return C(Wn,this,qn).call(this,{data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){C(Wn,this,qn).call(this,{type:`setState`,state:e})}cancel(e){let t=o(Vn,this)?.promise;return o(Vn,this)?.cancel(e),t?t.then(Wt).catch(Wt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return o(Ln,this)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>Yt(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===fn||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>Jt(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!qt(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),o(Vn,this)?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),o(Vn,this)?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),o(zn,this).notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(o(Vn,this)&&(o(Un,this)||C(Wn,this,Kn).call(this)?o(Vn,this).cancel({revert:!0}):o(Vn,this).cancelRetry()),this.scheduleGc()),o(zn,this).notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||C(Wn,this,qn).call(this,{type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&o(Vn,this)?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(o(Vn,this))return o(Vn,this).continueRetry(),o(Vn,this).promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(x(Un,this,!0),n.signal)})},i=()=>{let e=pn(this.options,t),n=(()=>{let e={client:o(Bn,this),queryKey:this.queryKey,meta:this.meta};return r(e),e})();return x(Un,this,!1),this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:o(Bn,this),state:this.state,fetchFn:i};return r(e),e})();(o(In,this)===`infinite`?An(this.options.pages):this.options.behavior)?.onFetch(a,this),x(Rn,this,this.state),(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&C(Wn,this,qn).call(this,{type:`fetch`,meta:a.fetchOptions?.meta}),x(Vn,this,Dn({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof En&&e.revert&&this.setState({...o(Rn,this),fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{C(Wn,this,qn).call(this,{type:`failed`,failureCount:e,error:t})},onPause:()=>{C(Wn,this,qn).call(this,{type:`pause`})},onContinue:()=>{C(Wn,this,qn).call(this,{type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0}));try{let e=await o(Vn,this).start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),o(zn,this).config.onSuccess?.(e,this),o(zn,this).config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof En){if(e.silent)return o(Vn,this).promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw C(Wn,this,qn).call(this,{type:`error`,error:e}),o(zn,this).config.onError?.(e,this),o(zn,this).config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}});function Kn(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}function qn(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...Jn(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...Yn(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return x(Rn,this,e.manual?n:void 0),n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),q.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),o(zn,this).notify({query:this,type:`updated`,action:e})})}function Jn(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Tn(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function Yn(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function Xn(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var Zn,J,Qn,$n,er,tr,nr,rr,ir,ar,or,sr,cr,lr,ur,Y,dr=(Zn=new WeakMap,J=new WeakMap,Qn=new WeakMap,$n=new WeakMap,er=new WeakMap,tr=new WeakMap,nr=new WeakMap,rr=new WeakMap,ir=new WeakMap,ar=new WeakMap,or=new WeakMap,sr=new WeakMap,cr=new WeakMap,lr=new WeakMap,ur=new WeakMap,Y=new WeakSet,class extends Nt{constructor(e,t){super(),Fn(this,Y),c(this,Zn,void 0),c(this,J,void 0),c(this,Qn,void 0),c(this,$n,void 0),c(this,er,void 0),c(this,tr,void 0),c(this,nr,void 0),c(this,rr,void 0),c(this,ir,void 0),c(this,ar,void 0),c(this,or,void 0),c(this,sr,void 0),c(this,cr,void 0),c(this,lr,void 0),c(this,ur,new Set),this.options=t,x(Zn,this,e),x(rr,this,null),x(nr,this,_n()),this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(o(J,this).addObserver(this),Sr(o(J,this),this.options)?C(Y,this,fr).call(this):this.updateResult(),C(Y,this,gr).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Cr(o(J,this),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Cr(o(J,this),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,C(Y,this,_r).call(this),C(Y,this,vr).call(this),o(J,this).removeObserver(this)}setOptions(e){let t=this.options,n=o(J,this);if(this.options=o(Zn,this).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof Yt(this.options.enabled,o(J,this))!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);C(Y,this,yr).call(this),o(J,this).setOptions(this.options),t._defaulted&&!rn(this.options,t)&&o(Zn,this).getQueryCache().notify({type:`observerOptionsUpdated`,query:o(J,this),observer:this});let r=this.hasListeners();r&&wr(o(J,this),n,this.options,t)&&C(Y,this,fr).call(this),this.updateResult(),r&&(o(J,this)!==n||Yt(this.options.enabled,o(J,this))!==Yt(t.enabled,o(J,this))||Jt(this.options.staleTime,o(J,this))!==Jt(t.staleTime,o(J,this)))&&C(Y,this,pr).call(this);let i=C(Y,this,mr).call(this);r&&(o(J,this)!==n||Yt(this.options.enabled,o(J,this))!==Yt(t.enabled,o(J,this))||i!==o(lr,this))&&C(Y,this,hr).call(this,i)}getOptimisticResult(e){let t=o(Zn,this).getQueryCache().build(o(Zn,this),e),n=this.createResult(t,e);return Er(this,n)&&(x($n,this,n),x(tr,this,this.options),x(er,this,o(J,this).state)),n}getCurrentResult(){return o($n,this)}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&o(nr,this).status===`pending`&&o(nr,this).reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){o(ur,this).add(e)}getCurrentQuery(){return o(J,this)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=o(Zn,this).defaultQueryOptions(e),n=o(Zn,this).getQueryCache().build(o(Zn,this),t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return C(Y,this,fr).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),o($n,this)))}createResult(e,t){let n=o(J,this),r=this.options,i=o($n,this),a=o(er,this),s=o(tr,this),c=e===n?o(Qn,this):e.state,{state:l}=e,u={...l},d=!1,f;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&Sr(e,t),o=i&&wr(e,n,t,r);(a||o)&&(u={...u,...Jn(l.data,e.options)}),t._optimisticResults===`isRestoring`&&(u.fetchStatus=`idle`)}let{error:p,errorUpdatedAt:m,status:h}=u;f=u.data;let g=!1;if(t.placeholderData!==void 0&&f===void 0&&h===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===s?.placeholderData?(e=i.data,g=!0):e=typeof t.placeholderData==`function`?t.placeholderData(o(or,this)?.state.data,o(or,this)):t.placeholderData,e!==void 0&&(h=`success`,f=ln(i?.data,e,t),d=!0)}if(t.select&&f!==void 0&&!g)if(i&&f===a?.data&&t.select===o(ir,this))f=o(ar,this);else try{x(ir,this,t.select),f=t.select(f),f=ln(i?.data,f,t),x(ar,this,f),x(rr,this,null)}catch(e){x(rr,this,e)}o(rr,this)&&(p=o(rr,this),f=o(ar,this),m=Date.now(),h=`error`);let _=u.fetchStatus===`fetching`,v=h===`pending`,y=h===`error`,b=v&&_,S=f!==void 0,C={status:h,fetchStatus:u.fetchStatus,isPending:v,isSuccess:h===`success`,isError:y,isInitialLoading:b,isLoading:b,data:f,dataUpdatedAt:u.dataUpdatedAt,error:p,errorUpdatedAt:m,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:u.dataUpdateCount>c.dataUpdateCount||u.errorUpdateCount>c.errorUpdateCount,isFetching:_,isRefetching:_&&!v,isLoadingError:y&&!S,isPaused:u.fetchStatus===`paused`,isPlaceholderData:d,isRefetchError:y&&S,isStale:Tr(e,t),refetch:this.refetch,promise:o(nr,this),isEnabled:Yt(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=C.data!==void 0,r=C.status===`error`&&!t,i=e=>{r?e.reject(C.error):t&&e.resolve(C.data)},a=()=>{let e=x(nr,this,C.promise=_n());i(e)},s=o(nr,this);switch(s.status){case`pending`:e.queryHash===n.queryHash&&i(s);break;case`fulfilled`:(r||C.data!==s.value)&&a();break;case`rejected`:(!r||C.error!==s.reason)&&a()}}return C}updateResult(){let e=o($n,this),t=this.createResult(o(J,this),this.options);x(er,this,o(J,this).state),x(tr,this,this.options),o(er,this).data!==void 0&&x(or,this,o(J,this)),!rn(t,e)&&(x($n,this,t),C(Y,this,br).call(this,{listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!o(ur,this).size)return!0;let r=new Set(n??o(ur,this));return this.options.throwOnError&&r.add(`error`),Object.keys(o($n,this)).some(t=>{let n=t;return o($n,this)[n]!==e[n]&&r.has(n)})})()}))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&C(Y,this,gr).call(this)}});function fr(e){C(Y,this,yr).call(this);let t=o(J,this).fetch(this.options,e);return e?.throwOnError||(t=t.catch(Wt)),t}function pr(){C(Y,this,_r).call(this);let e=Jt(this.options.staleTime,o(J,this));if(gn.isServer()||o($n,this).isStale||!Kt(e))return;let t=qt(o($n,this).dataUpdatedAt,e)+1;x(sr,this,Vt.setTimeout(()=>{o($n,this).isStale||this.updateResult()},t))}function mr(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(o(J,this)):this.options.refetchInterval)??!1}function hr(e){C(Y,this,vr).call(this),x(lr,this,e),!(gn.isServer()||Yt(this.options.enabled,o(J,this))===!1||!Kt(o(lr,this))||o(lr,this)===0)&&x(cr,this,Vt.setInterval(()=>{(this.options.refetchIntervalInBackground||Lt.isFocused())&&C(Y,this,fr).call(this)},o(lr,this)))}function gr(){C(Y,this,pr).call(this),C(Y,this,hr).call(this,C(Y,this,mr).call(this))}function _r(){o(sr,this)!==void 0&&(Vt.clearTimeout(o(sr,this)),x(sr,this,void 0))}function vr(){o(cr,this)!==void 0&&(Vt.clearInterval(o(cr,this)),x(cr,this,void 0))}function yr(){let e=o(Zn,this).getQueryCache().build(o(Zn,this),this.options);if(e===o(J,this))return;let t=o(J,this);x(J,this,e),x(Qn,this,e.state),this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}function br(e){q.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(o($n,this))}),o(Zn,this).getQueryCache().notify({query:o(J,this),type:`observerResultsUpdated`})})}function xr(e,t){return Yt(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||Yt(t.retryOnMount,e)!==!1)}function Sr(e,t){return xr(e,t)||e.state.data!==void 0&&Cr(e,t,t.refetchOnMount)}function Cr(e,t,n){if(Yt(t.enabled,e)!==!1&&Jt(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&Tr(e,t)}return!1}function wr(e,t,n,r){return(e!==t||Yt(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&Tr(e,n)}function Tr(e,t){return Yt(t.enabled,e)!==!1&&e.isStaleByTime(Jt(t.staleTime,e))}function Er(e,t){return!rn(e.getCurrentResult(),t)}var Dr,Or,kr,Ar,jr,Mr=(Dr=new WeakMap,Or=new WeakMap,kr=new WeakMap,Ar=new WeakMap,jr=new WeakSet,class extends kn{constructor(e){super(),Fn(this,jr),c(this,Dr,void 0),c(this,Or,void 0),c(this,kr,void 0),c(this,Ar,void 0),x(Dr,this,e.client),this.mutationId=e.mutationId,x(kr,this,e.mutationCache),x(Or,this,[]),this.state=e.state||Pr(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){o(Or,this).includes(e)||(o(Or,this).push(e),this.clearGcTimeout(),o(kr,this).notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){x(Or,this,o(Or,this).filter(t=>t!==e)),this.scheduleGc(),o(kr,this).notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){o(Or,this).length||(this.state.status===`pending`?this.scheduleGc():o(kr,this).remove(this))}continue(){return o(Ar,this)?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{C(jr,this,Nr).call(this,{type:`continue`})},n={client:o(Dr,this),meta:this.options.meta,mutationKey:this.options.mutationKey};x(Ar,this,Dn({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{C(jr,this,Nr).call(this,{type:`failed`,failureCount:e,error:t})},onPause:()=>{C(jr,this,Nr).call(this,{type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>o(kr,this).canRun(this)}));let r=this.state.status===`pending`,i=!o(Ar,this).canStart();try{if(r)t();else{C(jr,this,Nr).call(this,{type:`pending`,variables:e,isPaused:i}),o(kr,this).config.onMutate&&await o(kr,this).config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&C(jr,this,Nr).call(this,{type:`pending`,context:t,variables:e,isPaused:i})}let a=await o(Ar,this).start();return await o(kr,this).config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await o(kr,this).config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),C(jr,this,Nr).call(this,{type:`success`,data:a}),a}catch(t){try{await o(kr,this).config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await o(kr,this).config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw C(jr,this,Nr).call(this,{type:`error`,error:t}),t}finally{o(kr,this).runNext(this)}}});function Nr(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),q.batch(()=>{o(Or,this).forEach(t=>{t.onMutationUpdate(e)}),o(kr,this).notify({mutation:this,type:`updated`,action:e})})}function Pr(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Fr,Ir,Lr,Rr=(Fr=new WeakMap,Ir=new WeakMap,Lr=new WeakMap,class extends Nt{constructor(e={}){super(),c(this,Fr,void 0),c(this,Ir,void 0),c(this,Lr,void 0),this.config=e,x(Fr,this,new Set),x(Ir,this,new Map),x(Lr,this,0)}build(e,t,n){var r;let i=new Mr({client:e,mutationCache:this,mutationId:x(Lr,this,(r=o(Lr,this),++r)),options:e.defaultMutationOptions(t),state:n});return this.add(i),i}add(e){o(Fr,this).add(e);let t=zr(e);if(typeof t==`string`){let n=o(Ir,this).get(t);n?n.push(e):o(Ir,this).set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(o(Fr,this).delete(e)){let t=zr(e);if(typeof t==`string`){let n=o(Ir,this).get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&o(Ir,this).delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=zr(e);if(typeof t==`string`){let n=o(Ir,this).get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=zr(e);return typeof t==`string`?(o(Ir,this).get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){q.batch(()=>{o(Fr,this).forEach(e=>{this.notify({type:`removed`,mutation:e})}),o(Fr,this).clear(),o(Ir,this).clear()})}getAll(){return Array.from(o(Fr,this))}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Zt(t,e))}findAll(e={}){return this.getAll().filter(t=>Zt(e,t))}notify(e){q.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return q.batch(()=>Promise.all(e.map(e=>e.continue().catch(Wt))))}});function zr(e){return e.options.scope?.id}var Br,Vr=(Br=new WeakMap,class extends Nt{constructor(e={}){super(),c(this,Br,void 0),this.config=e,x(Br,this,new Map)}build(e,t,n){let r=t.queryKey,i=t.queryHash??Qt(r,t),a=this.get(i);return a||(a=new Gn({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){o(Br,this).has(e.queryHash)||(o(Br,this).set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=o(Br,this).get(e.queryHash);t&&(e.destroy(),t===e&&o(Br,this).delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){q.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return o(Br,this).get(e)}getAll(){return[...o(Br,this).values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Xt(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>Xt(e,t)):t}notify(e){q.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){q.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){q.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}}),X,Hr,Ur,Wr,Gr,Kr,qr,Jr,Yr=(X=new WeakMap,Hr=new WeakMap,Ur=new WeakMap,Wr=new WeakMap,Gr=new WeakMap,Kr=new WeakMap,qr=new WeakMap,Jr=new WeakMap,class{constructor(e={}){c(this,X,void 0),c(this,Hr,void 0),c(this,Ur,void 0),c(this,Wr,void 0),c(this,Gr,void 0),c(this,Kr,void 0),c(this,qr,void 0),c(this,Jr,void 0),x(X,this,e.queryCache||new Vr),x(Hr,this,e.mutationCache||new Rr),x(Ur,this,e.defaultOptions||{}),x(Wr,this,new Map),x(Gr,this,new Map),x(Kr,this,0)}mount(){var e;x(Kr,this,(e=o(Kr,this),e++,e)),o(Kr,this)===1&&(x(qr,this,Lt.subscribe(async e=>{e&&(await this.resumePausedMutations(),o(X,this).onFocus())})),x(Jr,this,Cn.subscribe(async e=>{e&&(await this.resumePausedMutations(),o(X,this).onOnline())})))}unmount(){var e;x(Kr,this,(e=o(Kr,this),e--,e)),o(Kr,this)===0&&(o(qr,this)?.call(this),x(qr,this,void 0),o(Jr,this)?.call(this),x(Jr,this,void 0))}isFetching(e){return o(X,this).findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return o(Hr,this).findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return o(X,this).get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=o(X,this).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Jt(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return o(X,this).findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=o(X,this).get(r.queryHash)?.state.data,a=Gt(t,i);if(a!==void 0)return o(X,this).build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return q.batch(()=>o(X,this).findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return o(X,this).get(t.queryHash)?.state}removeQueries(e){let t=o(X,this);q.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=o(X,this);return q.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=q.batch(()=>o(X,this).findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(Wt).catch(Wt)}invalidateQueries(e,t={}){return q.batch(()=>(o(X,this).findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=q.batch(()=>o(X,this).findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(Wt)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(Wt)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=o(X,this).build(this,t);return n.isStaleByTime(Jt(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Wt).catch(Wt)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Wt).catch(Wt)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return Cn.isOnline()?o(Hr,this).resumePausedMutations():Promise.resolve()}getQueryCache(){return o(X,this)}getMutationCache(){return o(Hr,this)}getDefaultOptions(){return o(Ur,this)}setDefaultOptions(e){x(Ur,this,e)}setQueryDefaults(e,t){o(Wr,this).set($t(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...o(Wr,this).values()],n={};return t.forEach(t=>{en(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){o(Gr,this).set($t(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...o(Gr,this).values()],n={};return t.forEach(t=>{en(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...o(Ur,this).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Qt(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===fn&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...o(Ur,this).mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){o(X,this).clear(),o(Hr,this).clear()}}),Z=e(t(),1),Q=n(),Xr=Z.createContext(void 0),Zr=e=>{let t=Z.useContext(Xr);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},Qr=({client:e,children:t})=>(Z.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,Q.jsx)(Xr.Provider,{value:e,children:t})),$r=Z.createContext(!1),ei=()=>Z.useContext($r);$r.Provider;function ti(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var ni=Z.createContext(ti()),ri=()=>Z.useContext(ni),ii=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?mn(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},ai=e=>{Z.useEffect(()=>{e.clearReset()},[e])},oi=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||mn(n,[e.error,r])),si=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},ci=(e,t)=>e.isLoading&&e.isFetching&&!t,li=(e,t)=>e?.suspense&&t.isPending,ui=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function di(e,t,n){let r=ei(),i=ri(),a=Zr(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,si(o),ii(o,i,s),ai(i);let l=!a.getQueryCache().get(o.queryHash),[u]=Z.useState(()=>new t(a,o)),d=u.getOptimisticResult(o),f=!r&&c;if(Z.useSyncExternalStore(Z.useCallback(e=>{let t=f?u.subscribe(q.batchCalls(e)):Wt;return u.updateResult(),t},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),Z.useEffect(()=>{u.setOptions(o)},[o,u]),li(o,d))throw ui(o,u,i);if(oi({result:d,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw d.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,d),o.experimental_prefetchInRender&&!gn.isServer()&&ci(d,r)&&(l?ui(o,u,i):s?.promise)?.catch(Wt).finally(()=>{u.updateResult()}),o.notifyOnChangeProps?d:u.trackResult(d)}function fi(e,t){return di(e,dr,t)}var pi=e(a(),1),mi={id:`home`,kind:`home`,path:`/`},hi=[`/calendar`,`/automations`,`/channels`,`/personas`,`/gallery`,`/agents`,`/users`,`/usage`,`/system`,`/artifacts`],gi=e=>{if(e===`/`||e===`/home`)return mi;if(e===`/chat`)return{id:`chat:new`,kind:`chat`,path:`/chat`};let t=e.match(/^\/c\/([^/]+)$/);if(t)return{id:`chat:${t[1]}`,kind:`chat`,path:e};if(e===`/work`)return{id:`work:new`,kind:`work`,path:`/work`};let n=e.match(/^\/work\/([^/]+)$/);return n?{id:`work:${n[1]}`,kind:`work`,path:e}:hi.includes(e)?{id:`page:${e}`,kind:`page`,path:e}:null},_i=e=>[mi,...e.filter(e=>e.id!==mi.id)],vi=ct()(lt((e,t)=>({tabs:[mi],activeTabId:mi.id,syncWithPath:t=>{let n=gi(t);n&&e(e=>{let t=_i(e.tabs),r=t.find(e=>e.id===n.id);if(r)return{tabs:t,activeTabId:r.id};let i=t.find(t=>t.id===e.activeTabId);return i&&i.kind===n.kind&&i.id.endsWith(`:new`)&&!n.id.endsWith(`:new`)?{tabs:t.map(e=>e.id===i.id?n:e),activeTabId:n.id}:{tabs:[...t,n],activeTabId:n.id}})},closeTab:e=>t().closeTabs([e]),closeTabs:(n,r)=>{let i=t(),a=_i(i.tabs),o=new Set(n.filter(e=>e!==mi.id&&a.some(t=>t.id===e)));if(o.size===0)return null;let s=a.findIndex(e=>e.id===i.activeTabId),c=a.filter(e=>!o.has(e.id));if(!o.has(i.activeTabId))return e({tabs:c}),null;let l=r?c.find(e=>e.id===r):void 0,u=a.slice(0,Math.max(0,s)).reverse().find(e=>!o.has(e.id)),d=l??u??c[0]??mi;return e({tabs:c,activeTabId:d.id}),d},reset:()=>e({tabs:[mi],activeTabId:mi.id})}),{name:`libre-webui-tabs`,merge:(e,t)=>{let n=e??{},r=Array.isArray(n.tabs)?_i(n.tabs.filter(e=>!!e&&typeof e.id==`string`&&typeof e.path==`string`&&gi(e.path)?.id===e.id)):t.tabs,i=r.some(e=>e.id===n.activeTabId)?n.activeTabId:mi.id;return{...t,tabs:r,activeTabId:i}}})),yi=i(),bi=dt(`components:avatar-upload`),xi=({value:e,onChange:t,className:n=``})=>{let{t:r}=w(),i=(0,Z.useRef)(null),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),l=async e=>{if(!e.type.startsWith(`image/`)){W.error(r(`user.avatar.invalidFile`));return}if(e.size>2097152){W.error(r(`user.avatar.fileTooLarge`));return}o(!0);try{let n=new FileReader;n.onload=e=>{let n=e.target?.result;t(n),W.success(r(`user.avatar.uploaded`))},n.onerror=()=>{W.error(r(`user.avatar.readFailed`))},n.readAsDataURL(e)}catch(e){bi.error(`Failed to upload avatar:`,e),W.error(r(`user.avatar.uploadFailed`))}finally{o(!1)}},u=e=>{let t=e.target.files?.[0];t&&l(t)},d=e=>{e.preventDefault(),c(!0)},f=e=>{e.preventDefault(),c(!1)},p=e=>{e.preventDefault(),c(!1);let t=e.dataTransfer.files?.[0];t&&l(t)},m=()=>{t(``),W.success(r(`user.avatar.removed`))},h=()=>e||null;return(0,Q.jsx)(`div`,{className:`space-y-4 ${n}`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-600 mb-2`,children:r(`user.avatar.label`)}),(0,Q.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,Q.jsx)(`div`,{className:`flex-shrink-0`,children:(0,Q.jsx)(`div`,{className:`w-20 h-20 rounded-full overflow-hidden bg-gray-100 dark:bg-dark-200 border-2 border-gray-300 dark:border-dark-300 flex items-center justify-center`,children:h()?(0,Q.jsx)(`img`,{src:h(),alt:`Avatar preview`,className:`w-full h-full object-cover`}):(0,Q.jsx)(Pe,{className:`h-8 w-8 text-gray-400 dark:text-gray-500`})})}),(0,Q.jsxs)(`div`,{className:`flex-1 space-y-3`,children:[e?(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 p-3 bg-gray-50 dark:bg-dark-200 rounded-lg`,children:[(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:r(`user.avatar.customAvatar`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:r(`user.avatar.clickToChange`)})]}),(0,Q.jsx)(kt,{variant:`ghost`,size:`sm`,onClick:m,className:`text-red-600 hover:text-red-700 hover:bg-red-50 dark:text-red-400 dark:hover:text-red-300 dark:hover:bg-red-900/20`,children:(0,Q.jsx)(Ye,{className:`h-4 w-4`})})]}):(0,Q.jsxs)(`div`,{className:`border-2 border-dashed rounded-lg p-4 text-center cursor-pointer transition-colors ${s?`border-primary-500 bg-primary-50 dark:bg-primary-900/20`:`border-gray-300 dark:border-gray-600 hover:border-gray-400 dark:hover:border-gray-500`}`,onDragOver:d,onDragLeave:f,onDrop:p,onClick:()=>i.current?.click(),children:[(0,Q.jsx)(Ve,{className:`h-8 w-8 mx-auto text-gray-400 dark:text-gray-500 mb-2`}),(0,Q.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:r(`user.avatar.uploadAvatarImage`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-2`,children:r(`user.avatar.dragAndDrop`)}),(0,Q.jsxs)(kt,{variant:`outline`,size:`sm`,disabled:a,className:`mx-auto`,children:[(0,Q.jsx)(Ve,{className:`h-4 w-4 mr-2`}),r(a?`user.avatar.uploading`:`user.avatar.chooseImage`)]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1`,children:r(`user.avatar.enterImageUrl`)}),(0,Q.jsx)(`input`,{type:`url`,value:e,onChange:e=>t(e.target.value),className:`w-full px-3 py-2 text-sm border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800`,placeholder:`https://example.com/avatar.jpg`})]})]})]}),(0,Q.jsx)(`input`,{ref:i,type:`file`,accept:`image/*`,onChange:u,className:`hidden`}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:r(`user.avatar.supportedFormats`)})]})})};function Si({open:e,value:t,saving:n,onChange:r,onClose:i,onSave:a}){let{t:o}=w();return e?(0,yi.createPortal)((0,Q.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,Q.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`avatar-modal-title`,className:`bg-white dark:bg-dark-25 rounded-3xl shadow-[0_24px_80px_rgba(0,0,0,0.24)] p-6 w-full max-w-md border border-black/[0.07] dark:border-white/[0.08] animate-scale-in`,onClick:e=>e.stopPropagation(),children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,Q.jsx)(`h3`,{id:`avatar-modal-title`,className:`text-lg font-medium tracking-[-0.02em] text-gray-950 dark:text-dark-950`,children:o(`user.avatar.title`)}),(0,Q.jsx)(`button`,{onClick:i,className:`p-2 hover:bg-gray-100 dark:hover:bg-dark-200 rounded-xl transition-colors`,children:(0,Q.jsx)(Ye,{size:20,className:`text-gray-500`})})]}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(xi,{value:t,onChange:r}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-3 pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`button`,{onClick:i,className:`px-4 py-2 text-sm font-medium text-gray-700 dark:text-dark-700 hover:bg-gray-100 dark:hover:bg-dark-200 rounded-xl transition-colors`,children:o(`common.cancel`)}),(0,Q.jsx)(`button`,{onClick:a,disabled:n,className:`px-4 py-2 text-sm font-medium text-white bg-gray-950 hover:bg-gray-800 dark:bg-white dark:text-gray-950 dark:hover:bg-gray-100 disabled:opacity-50 disabled:cursor-not-allowed rounded-xl transition-colors`,children:o(n?`common.saving`:`common.save`)})]})]})]})}),document.body):null}var Ci={sm:`text-[1.0625rem] leading-none`,md:`text-[1.625rem] leading-none`,lg:`text-[2.5rem] leading-none`},wi=({className:e,size:t=`md`,wordmark:n=!0})=>(0,Q.jsxs)(`span`,{dir:`ltr`,className:A(`libre-brand inline-flex items-baseline whitespace-nowrap`,Ci[t],e),children:[`Libre`,n&&(0,Q.jsx)(`span`,{className:`ms-1 font-normal tracking-[-0.035em]`,children:`WebUI`})]}),Ti={sm:`h-6 w-6`,md:`h-8 w-8`,lg:`h-12 w-12`},Ei=({className:e,size:t=`md`,label:n=`Libre WebUI`})=>(0,Q.jsxs)(`svg`,{viewBox:`0 0 64 64`,className:A(`shrink-0`,Ti[t],e),role:n?`img`:`presentation`,"aria-label":n??void 0,"aria-hidden":!n||void 0,focusable:`false`,children:[(0,Q.jsx)(`path`,{d:`M 11.5 18.0 L 11.5 32 A 20.5 20.5 0 0 0 50.58 40.66`,fill:`none`,stroke:`currentColor`,strokeWidth:`11`,strokeLinecap:`round`}),(0,Q.jsx)(`path`,{d:`M 50.58 18.0 L 50.58 25.66`,fill:`none`,stroke:`currentColor`,strokeWidth:`11`,strokeLinecap:`round`})]}),Di=()=>{let{theme:e,toggleTheme:t}=Et(),n=e.mode===`light`?`dark`:`light`,r=e.mode===`light`?(0,Q.jsx)(Re,{className:`h-4 w-4 text-ink-muted transition-colors duration-150 group-hover:text-ink motion-reduce:transition-none`,strokeWidth:1.75,"aria-hidden":`true`}):(0,Q.jsx)(re,{className:`h-4 w-4 text-ink-muted transition-colors duration-150 group-hover:text-ink motion-reduce:transition-none`,strokeWidth:1.75,"aria-hidden":`true`}),i=`Switch to ${n} mode`;return(0,Q.jsx)(kt,{variant:`ghost`,size:`sm`,onClick:t,className:`h-9 w-9 rounded-full p-0`,"aria-label":i,title:`${i} (⌘D)`,children:r})};function Oi({sidebarCompact:e,isElectron:t,showWork:n,activeMode:r,selectedModel:i,modelCount:a,onToggleCompact:o,onStartWork:s,onCreateSession:c}){let{t:l}=w(),u=!i||a===0,d=u?l(`chat.model.noModelsTooltip`):``,f=`flex h-9 w-9 items-center justify-center rounded-full text-ink transition-colors hover:bg-interactive-hover outline-none focus-visible:ring-2 focus-visible:ring-primary-500/30 touch-manipulation`;return e?(0,Q.jsxs)(`div`,{className:A(`flex flex-col items-center gap-3 px-2 pt-4 pb-2`,t&&`pt-10`),children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:o,className:A(f,`group`),title:l(`sidebar.expandSidebar`),"aria-label":l(`sidebar.expandSidebar`),"data-testid":`sidebar-rail-expand`,children:[(0,Q.jsx)(Ei,{size:`sm`,label:null,className:`h-6 w-6 p-0 text-ink group-hover:hidden`}),(0,Q.jsx)(Ze,{className:`hidden h-[18px] w-[18px] group-hover:block rtl:rotate-180`})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:c,disabled:u,className:A(f,u&&`opacity-40`),title:u?d:l(`chat.session.chat`),"aria-label":l(`chat.session.chat`),"aria-pressed":r===`chat`,"data-testid":`sidebar-chat-button`,children:(0,Q.jsx)(nt,{className:`h-[18px] w-[18px]`})}),n&&(0,Q.jsx)(`button`,{type:`button`,onClick:s,className:f,title:l(`chat.session.work`),"aria-label":l(`chat.session.work`),"aria-pressed":r===`work`,"data-testid":`sidebar-work-button`,children:(0,Q.jsx)(V,{className:`h-[18px] w-[18px]`})}),(0,Q.jsx)(`button`,{type:`button`,"data-testid":`sidebar-search-button`,onClick:()=>window.dispatchEvent(new Event(`libre:open-palette`)),title:l(`palette.search`,`Search`),"aria-label":l(`palette.search`,`Search`),className:f,children:(0,Q.jsx)(oe,{className:`h-[18px] w-[18px]`})})]}):(0,Q.jsxs)(`div`,{className:A(`px-3 pb-2 pt-2`,t&&`pt-10`),children:[(0,Q.jsxs)(`div`,{className:`mb-2 flex h-[52px] min-w-0 items-center justify-between ps-1`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-ink`,children:[(0,Q.jsx)(Ei,{size:`sm`,label:null}),(0,Q.jsx)(wi,{size:`sm`,className:`tracking-[-0.035em]`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,Q.jsx)(`div`,{className:`hidden sm:block`,children:(0,Q.jsx)(Di,{})}),(0,Q.jsx)(`button`,{type:`button`,onClick:o,className:`flex h-7 w-7 items-center justify-center rounded-full text-ink-muted transition-colors hover:bg-interactive-hover hover:text-ink outline-none focus-visible:ring-2 focus-visible:ring-primary-500/30 touch-manipulation`,title:l(`sidebar.toggleSize`),"aria-label":l(`sidebar.toggleSize`),"data-testid":`sidebar-toggle-size`,children:(0,Q.jsx)(Ze,{className:`h-4 w-4 rtl:rotate-180`})})]})]}),(0,Q.jsxs)(`div`,{className:A(`grid w-full gap-2`,!n&&`grid-cols-1`,n&&`grid-cols-2`),"data-testid":`sidebar-create-actions`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:c,disabled:u,className:A(`flex h-[38px] items-center justify-center gap-1.5 rounded-xl border text-sm font-medium transition-colors touch-manipulation outline-none focus-visible:ring-2 focus-visible:ring-primary-500/30`,r===`chat`?`border-transparent bg-nav-active text-ink`:`border-line bg-surface-raised text-ink hover:bg-hover-solid dark:border-white/[0.12] dark:bg-dark-25 dark:hover:bg-dark-300`,u&&`opacity-50`),title:u?d:l(`chat.session.chat`),"aria-label":l(`chat.session.chat`),"aria-pressed":r===`chat`,"data-testid":`sidebar-chat-button`,children:[(0,Q.jsx)(nt,{className:`h-4 w-4`}),l(`chat.session.chat`)]}),n&&(0,Q.jsxs)(`button`,{type:`button`,onClick:s,className:A(`flex h-[38px] items-center justify-center gap-1.5 rounded-xl border text-sm font-medium transition-colors touch-manipulation outline-none focus-visible:ring-2 focus-visible:ring-primary-500/30`,r===`work`?`border-transparent bg-nav-active text-ink`:`border-line bg-surface-raised text-ink hover:bg-hover-solid dark:border-white/[0.12] dark:bg-dark-25 dark:hover:bg-dark-300`),title:l(`chat.session.work`),"aria-label":l(`chat.session.work`),"aria-pressed":r===`work`,"data-testid":`sidebar-work-button`,children:[(0,Q.jsx)(V,{className:`h-4 w-4`}),l(`chat.session.work`)]})]}),(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`sidebar-search-button`,onClick:()=>window.dispatchEvent(new Event(`libre:open-palette`)),title:l(`palette.search`,`Search`),"aria-label":l(`palette.search`,`Search`),className:`mt-1.5 flex h-[34px] w-full items-center gap-2 rounded-xl px-2.5 text-sm text-ink-muted transition-colors hover:bg-interactive-hover hover:text-ink outline-none focus-visible:ring-2 focus-visible:ring-primary-500/30 touch-manipulation`,children:[(0,Q.jsx)(oe,{className:`h-4 w-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1 text-start`,children:l(`palette.search`,`Search`)}),(0,Q.jsxs)(`span`,{className:`font-mono text-[10px] tracking-wide text-ink-subtle`,children:[T()?`⌘`:`Ctrl`,`K`]})]})]})}var ki=[{path:`/channels`,icon:Ae,labelKey:`sidebar.navigation.channels`},{path:`/notes`,icon:qe,labelKey:`sidebar.navigation.notes`},{path:`/calendar`,icon:Se,labelKey:`sidebar.navigation.calendar`},{path:`/automations`,icon:tt,labelKey:`sidebar.navigation.automations`},{path:`/personas`,icon:Pe,labelKey:`sidebar.navigation.personas`},{path:`/gallery`,icon:Ge,labelKey:`sidebar.navigation.imagine`},{path:`/agents`,icon:Te,labelKey:`sidebar.navigation.agents`}];function Ai({sidebarCompact:e,activePath:t,showAgents:n,unseenRunCount:r=0,onMobileNavigate:i}){let{t:a}=w();return(0,Q.jsx)(`div`,{className:A(`pb-3`,e?`px-2`:`px-3`),children:(0,Q.jsx)(`nav`,{"data-testid":`sidebar-navigation`,"aria-label":a(`sidebar.navigation.exploreLabel`,`Explore`),className:A(`flex gap-1`,e?`flex-col items-center`:`items-center`),children:ki.filter(e=>e.path!==`/agents`||n).map(({path:n,icon:o,labelKey:s})=>{let c=t===n,l=a(s);return(0,Q.jsxs)(b,{to:n,onClick:i,title:l,"aria-label":l,"aria-current":c?`page`:void 0,className:A(`relative flex items-center justify-center rounded-xl transition-colors duration-150 touch-manipulation outline-none focus-visible:ring-2 focus-visible:ring-primary-500/30`,e?`h-9 w-9`:`h-9 flex-1`,c?`bg-nav-active text-ink`:`text-ink-muted hover:bg-interactive-hover hover:text-ink`),children:[e&&c&&(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`absolute -start-2 h-5 w-0.5 rounded-full bg-primary-500 shadow-[0_0_12px_rgb(var(--color-primary-500)/0.55)]`}),(0,Q.jsx)(o,{className:`h-[18px] w-[18px] shrink-0`}),n===`/automations`&&r>0&&(0,Q.jsx)(`span`,{"data-testid":`automations-unseen-badge`,className:`absolute -end-0.5 -top-0.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-primary-500 px-0.5 text-[9px] font-semibold leading-none text-white`,children:r>9?`9+`:r})]},n)})})})}var ji=dt(`share-dialog`),Mi=({resourceType:e,resourceId:t,resourceLabel:n,onClose:r})=>{let{t:i}=w(),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(`user`),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(`read`),[p,m]=(0,Z.useState)(!1),h=(0,Z.useCallback)(()=>{_t.listGrants(e,t).then(e=>{e.success&&Array.isArray(e.data)&&o(e.data)}).catch(e=>ji.error(`Failed to load shares:`,e))},[e,t]);(0,Z.useEffect)(()=>{h()},[h]);let g=async()=>{let n=l.trim();if(n){m(!0);try{let r=s===`user`?await _t.resolvePrincipal(n):await _t.resolveGroup(n);if(!r.success||!r.data){W.error(i(s===`user`?`share.userNotFound`:`share.groupNotFound`));return}let a=await _t.createGrant({resourceType:e,resourceId:t,principalType:s,principalId:r.data.id,permission:d});a.success?(u(``),h(),W.success(i(`share.added`,{name:n}))):W.error(a.error||i(`share.failed`))}catch(e){ji.error(`Failed to share resource:`,e),W.error(i(`share.failed`))}finally{m(!1)}}},_=async e=>{try{(await _t.deleteGrant(e)).success&&h()}catch(e){ji.error(`Failed to revoke share:`,e)}};return(0,Q.jsxs)(At,{titleId:`share-dialog-title`,title:i(`share.title`,{name:n}),subtitle:i(`share.subtitle`),onClose:r,testId:`share-dialog`,children:[(0,Q.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,Q.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),className:`${jt} w-auto`,"data-testid":`share-principal-kind`,children:[(0,Q.jsx)(`option`,{value:`user`,children:i(`share.kindUser`)}),(0,Q.jsx)(`option`,{value:`group`,children:i(`share.kindGroup`)})]}),(0,Q.jsx)(`input`,{type:`text`,value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&g()},placeholder:i(s===`user`?`share.usernamePlaceholder`:`share.groupPlaceholder`),className:`${jt} min-w-0 flex-1`,"data-testid":`share-principal-name`}),(0,Q.jsxs)(`select`,{value:d,onChange:e=>f(e.target.value),className:`${jt} w-auto`,"data-testid":`share-permission`,children:[(0,Q.jsx)(`option`,{value:`read`,children:i(`share.permissionRead`)}),(0,Q.jsx)(`option`,{value:`write`,children:i(`share.permissionWrite`)})]}),(0,Q.jsx)(kt,{size:`sm`,disabled:p||!l.trim(),onClick:()=>void g(),"data-testid":`share-submit`,children:p?(0,Q.jsx)(B,{className:`h-3.5 w-3.5 animate-spin`}):i(`share.action`)})]}),a===null?(0,Q.jsx)(B,{className:`mx-auto h-4 w-4 animate-spin text-gray-400`}):a.length===0?(0,Q.jsx)(`p`,{className:`text-center text-xs text-gray-400 dark:text-dark-500`,children:i(`share.empty`)}):(0,Q.jsx)(`div`,{className:`space-y-2`,children:a.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-black/[0.06] px-2.5 py-2 dark:border-white/[0.08]`,"data-testid":`share-item`,children:[e.principalType===`group`?(0,Q.jsx)(et,{className:`h-3.5 w-3.5 shrink-0 text-gray-400 dark:text-dark-500`}):(0,Q.jsx)(me,{className:`h-3.5 w-3.5 shrink-0 text-gray-400 dark:text-dark-500`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] text-gray-800 dark:text-dark-800`,children:e.principalName??e.principalId}),(0,Q.jsx)(`span`,{className:`shrink-0 text-[11px] uppercase text-gray-400 dark:text-dark-500`,children:e.permission}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void _(e.id),className:`rounded-md p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,title:i(`share.revoke`),children:(0,Q.jsx)(Ye,{className:`h-3.5 w-3.5`})})]},e.id))}),(0,Q.jsx)(`p`,{className:`text-[11px] leading-relaxed text-gray-400 dark:text-dark-500`,children:i(`share.hint`)})]})};function Ni({top:e,left:t,title:n,timestamp:r,children:i}){let{i18n:a}=w();return(0,yi.createPortal)((0,Q.jsxs)(`div`,{role:`tooltip`,className:`pointer-events-none fixed z-[70] hidden w-72 rounded-2xl border border-black/[0.07] bg-surface/95 p-3.5 shadow-[0_16px_48px_rgba(15,23,42,0.18)] backdrop-blur-xl animate-scale-in dark:border-white/[0.09] dark:bg-dark-100/95 md:block`,style:{top:Math.max(8,Math.min(e,window.innerHeight-220)),left:t},children:[(0,Q.jsx)(`p`,{className:`mb-1 truncate text-[13px] font-semibold text-gray-900 dark:text-dark-900`,children:n}),(0,Q.jsx)(`p`,{className:`mb-2 text-[10px] tabular-nums text-gray-400 dark:text-dark-500`,children:O(r,a.language)}),i]}),document.body)}function Pi(e){let t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=864e5;return e>=n?`today`:e>=n-r?`yesterday`:e>=n-7*r?`previous7Days`:e>=n-30*r?`previous30Days`:`older`}var Fi=[`today`,`yesterday`,`previous7Days`,`previous30Days`,`older`];function Ii(e){let t=e.trim().split(/\s+/u).filter(Boolean);return t.length===0?`•`:t.length===1?Array.from(t[0]).slice(0,2).join(``).toLocaleUpperCase():`${Array.from(t[0])[0]}${Array.from(t[t.length-1])[0]}`.toLocaleUpperCase()}function Li({preview:e}){let{t}=w(),{session:n}=e,r=n.messages.find(e=>e.role===`user`&&e.content.trim()),i=n.messages.find(e=>e.role===`assistant`&&e.content.trim());return(0,Q.jsxs)(Ni,{top:e.top,left:e.left,title:n.title,timestamp:n.updatedAt,children:[r&&(0,Q.jsx)(`div`,{className:`mb-1.5 flex justify-end`,children:(0,Q.jsx)(`p`,{dir:`auto`,className:`max-w-[85%] rounded-xl rounded-ee-sm bg-gray-900 px-2.5 py-1.5 text-[11px] leading-snug text-white dark:bg-dark-300`,children:k(r.content,110)})}),i&&(0,Q.jsx)(`p`,{dir:`auto`,className:`text-[11px] leading-snug text-gray-600 dark:text-dark-700`,children:k(i.content.replace(/\s+/g,` `),180)}),!r&&!i&&(0,Q.jsx)(`p`,{className:`text-[11px] italic text-gray-400 dark:text-dark-500`,children:t(`chat.session.noChats`)})]})}function Ri({sessions:e,personas:t,currentSessionId:n,generatingTitleForSession:r,sidebarCompact:i,editingSessionId:a,editingTitle:o,onEditingTitleChange:s,onSelectSession:c,onStartEditing:l,onSaveEdit:u,onCancelEdit:d,onDeleteSession:f,onArchiveSession:p,onTogglePinSession:m,folders:h=[],onCreateFolder:g,onRenameFolder:_,onDeleteFolder:v,onMoveSession:y,onExpandSidebar:b}){let{t:x,i18n:S}=w(),[C,T]=(0,Z.useState)(null),[E,D]=(0,Z.useState)(null),j=(0,Z.useRef)(null),M=E?e.find(e=>e.id===E)??null:null;(0,Z.useEffect)(()=>()=>{j.current!==null&&window.clearTimeout(j.current)},[]);let N=()=>{j.current!==null&&(window.clearTimeout(j.current),j.current=null),T(null)},P=(e,t)=>{let n=window.matchMedia(`(hover: hover) and (pointer: fine)`).matches;i||window.innerWidth<768||!n||(j.current!==null&&window.clearTimeout(j.current),j.current=window.setTimeout(()=>{let n=t.getBoundingClientRect();T({session:e,top:n.top,left:n.right+10})},500))},[F,ee]=(0,Z.useState)(()=>new Set),[I,te]=(0,Z.useState)(!1),[ne,R]=(0,Z.useState)(``),[re,z]=(0,Z.useState)(null),[ie,ae]=(0,Z.useState)(null),[V,oe]=(0,Z.useState)(null),se=ie?e.find(e=>e.id===ie)??null:null,ce=()=>{ae(null),oe(null)},le=e=>{let t=se;ce(),!(!t||!y)&&(t.folderId??null)!==e&&y(t.id,e)},de=(e,t)=>({onDragOver:t=>{ie&&(t.preventDefault(),t.dataTransfer.dropEffect=`move`,V!==e&&oe(e))},onDragLeave:()=>{V===e&&oe(null)},onDrop:e=>{e.preventDefault(),le(t)}}),[fe,pe]=(0,Z.useState)(null),[he,ge]=(0,Z.useState)(null),H=he?e.find(e=>e.id===he.sessionId)??null:null;(0,Z.useEffect)(()=>{if(!he)return;let e=e=>{e.key===`Escape`&&ge(null)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[he]);let _e=(e,t)=>{if(t.stopPropagation(),N(),he?.sessionId===e.id){ge(null);return}let n=t.currentTarget.getBoundingClientRect();ge({sessionId:e.id,top:Math.max(8,Math.min(n.bottom+6,window.innerHeight-340-8)),left:Math.max(8,Math.min(n.right-208,window.innerWidth-208-8))})},ve=e=>{let t=window.location.protocol===`file:`?`${window.location.pathname}#/c/${e.id}`:`/c/${e.id}`;window.open(t,`_blank`,`noopener,noreferrer`)},be=e=>{ee(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Se=()=>{let e=ne.trim();te(!1),R(``),e&&g&&g(e)},Ce=e=>{let t=ne.trim();z(null),R(``),t&&_&&_(e,t)},we=new Set(h.map(e=>e.id)),Te=e.filter(e=>e.pinned),Ee=e.filter(e=>!e.pinned),De=Ee.filter(e=>!e.folderId||!we.has(e.folderId)),ke=[...Te.length>0?[{key:`pinned`,labelKey:`pinned`,sessions:Te}]:[],...h.map(e=>({key:`folder:${e.id}`,folder:e,sessions:Ee.filter(t=>t.folderId===e.id)})),...Fi.map(e=>({key:e,labelKey:e,sessions:De.filter(t=>Pi(t.updatedAt)===e)})).filter(e=>e.sessions.length>0)],Ae=[...e].sort((e,t)=>t.updatedAt-e.updatedAt);return(0,Q.jsxs)(`div`,{"data-testid":`sidebar-session-scroll-region`,className:`scroll-region min-h-0 flex-1 scrollbar-thin border-t border-black/[0.05] dark:border-white/[0.05]`,style:{willChange:`scroll-position`},children:[(0,Q.jsxs)(`div`,{className:A(`px-3 py-3`,i&&`px-2`),children:[!i&&e.length>0&&(0,Q.jsxs)(`div`,{className:`mb-1 flex h-7 items-center justify-between px-1.5`,children:[(0,Q.jsx)(`h3`,{className:`text-xs font-medium text-ink-subtle`,children:x(`chat.session.chats`)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[g&&(0,Q.jsx)(`button`,{onClick:()=>{te(!0),R(``)},className:`flex h-6 w-6 items-center justify-center rounded-md text-ink-subtle transition-colors hover:bg-interactive-hover hover:text-ink`,title:x(`chat.session.folder.new`),children:(0,Q.jsx)(ze,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`span`,{className:`text-[10px] tabular-nums text-ink-subtle font-medium`,children:e.length})]})]}),!i&&I&&(0,Q.jsx)(`div`,{className:`mb-2 px-1`,children:(0,Q.jsx)(Mt,{value:ne,onChange:e=>R(e.target.value),onKeyDown:e=>{e.key===`Enter`?Se():e.key===`Escape`&&(te(!1),R(``))},onBlur:Se,placeholder:x(`chat.session.folder.namePlaceholder`),className:`h-8 text-sm`,autoFocus:!0})}),i?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:b,"data-testid":`sidebar-mobile-chats`,"aria-label":`${x(`chat.session.chats`)} (${e.length})`,title:x(`chat.session.chats`),className:`relative flex h-12 w-12 items-center justify-center rounded-xl text-gray-500 outline-none transition-colors hover:bg-white/70 hover:text-gray-950 focus-visible:ring-2 focus-visible:ring-primary-500/30 dark:text-dark-600 dark:hover:bg-dark-200 dark:hover:text-dark-950 md:hidden`,children:[(0,Q.jsx)(nt,{className:`h-[18px] w-[18px]`}),e.length>0&&(0,Q.jsx)(`span`,{className:`absolute -end-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-md bg-primary-500 px-1 text-[9px] font-semibold tabular-nums text-white shadow-sm`,children:e.length>99?`99+`:e.length})]}),(0,Q.jsx)(`div`,{"data-testid":`sidebar-compact-session-list`,className:`flex w-full flex-col items-center gap-1`,children:Ae.map(e=>{let t=n===e.id;return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>c(e),"data-testid":`sidebar-compact-session`,"aria-current":t?`page`:void 0,"aria-label":e.title,title:e.title,className:A(`relative flex h-12 w-12 items-center justify-center rounded-xl outline-none transition-colors focus-visible:ring-2 focus-visible:ring-primary-500/30`,t?`bg-gray-950 text-white ring-1 ring-black/10 shadow-[0_8px_24px_-14px_rgba(0,0,0,0.7)] dark:bg-white dark:text-gray-950 dark:ring-white/20 dark:shadow-[0_8px_24px_-14px_rgba(255,255,255,0.45)]`:`text-gray-500 hover:bg-white/70 hover:text-gray-950 dark:text-dark-600 dark:hover:bg-dark-200 dark:hover:text-dark-950`),children:[t&&(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`absolute -start-2 h-5 w-0.5 rounded-full bg-gray-950 shadow-[0_0_10px_rgba(0,0,0,0.35)] dark:bg-white dark:shadow-[0_0_10px_rgba(255,255,255,0.35)]`}),(0,Q.jsx)(`span`,{className:`font-mono text-[11px] font-semibold tracking-[-0.03em]`,children:Ii(e.title)}),r===e.id&&(0,Q.jsx)(`span`,{className:`absolute end-1.5 top-1.5 h-1.5 w-1.5 animate-pulse rounded-full bg-primary-500`})]},e.id)})})]}):e.length===0?(0,Q.jsxs)(`div`,{className:A(`text-center py-8`,i?`px-1`:`px-2`),children:[(0,Q.jsx)(`div`,{className:A(`mx-auto mb-3 bg-white/70 dark:bg-dark-200 rounded-xl flex items-center justify-center ring-1 ring-black/[0.04] dark:ring-white/[0.05]`,i?`w-8 h-8`:`w-12 h-12`),children:(0,Q.jsx)(nt,{className:A(`text-gray-400 dark:text-gray-500`,i?`h-4 w-4`:`h-5 w-5`)})}),!i&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-gray-600 dark:text-dark-600`,children:x(`chat.session.noChats`)}),(0,Q.jsx)(`p`,{className:`text-xs mt-1 text-gray-400 dark:text-dark-500`,children:x(`chat.session.createFirst`)})]})]}):(0,Q.jsx)(`div`,{className:A(`space-y-2`,i&&`space-y-1`),children:ke.map(e=>(0,Q.jsxs)(`div`,{children:[!i&&e.folder&&(0,Q.jsx)(`div`,{...de(`folder:${e.folder.id}`,e.folder.id),className:A(`group/folder mb-0.5 flex h-[34px] items-center justify-between rounded-lg px-2 transition-colors hover:bg-interactive-hover`,V===`folder:${e.folder.id}`&&`bg-primary-500/10 ring-1 ring-primary-500/40`),children:re===e.folder.id?(0,Q.jsx)(Mt,{value:ne,onChange:e=>R(e.target.value),onKeyDown:t=>{t.key===`Enter`?Ce(e.folder.id):t.key===`Escape`&&(z(null),R(``))},onBlur:()=>Ce(e.folder.id),className:`h-7 text-sm`,autoFocus:!0}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{onClick:()=>be(e.folder.id),className:`flex min-w-0 flex-1 items-center gap-1.5 text-sm text-ink transition-colors`,"aria-expanded":!F.has(e.folder.id),children:[F.has(e.folder.id)?(0,Q.jsx)(ue,{className:`h-3.5 w-3.5 shrink-0 text-ink-subtle rtl:rotate-180`}):(0,Q.jsx)(xe,{className:`h-3.5 w-3.5 shrink-0 text-ink-subtle`}),(0,Q.jsx)(ye,{className:`h-4 w-4 shrink-0 text-ink-subtle`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.folder.name}),(0,Q.jsx)(`span`,{className:`text-[10px] font-medium tabular-nums text-ink-subtle`,children:e.sessions.length})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-0.5 opacity-0 transition-opacity group-hover/folder:opacity-100`,children:[_&&(0,Q.jsx)(`button`,{onClick:()=>{z(e.folder.id),R(e.folder.name)},className:`rounded-md p-0.5 text-gray-400 hover:text-gray-700 dark:text-dark-500 dark:hover:text-dark-800`,title:x(`chat.session.renameChat`),children:(0,Q.jsx)(Xe,{className:`h-3 w-3`})}),v&&(0,Q.jsx)(`button`,{onClick:()=>{window.confirm(x(`chat.session.folder.deleteConfirm`))&&v(e.folder.id)},className:`rounded-md p-0.5 text-gray-400 hover:text-red-500 dark:text-dark-500 dark:hover:text-red-400`,title:x(`chat.session.folder.delete`),children:(0,Q.jsx)(Oe,{className:`h-3 w-3`})})]})]})}),!i&&!e.folder&&(0,Q.jsx)(`p`,{...de(`group:${e.key}`,null),className:A(`mb-0.5 mt-1 rounded-md px-2 text-[11px] font-medium text-ink-subtle transition-colors`,V===`group:${e.key}`&&se?.folderId&&`bg-primary-500/10 ring-1 ring-primary-500/40 text-primary-600 dark:text-primary-400`),children:x(`chat.session.groups.${e.labelKey}`)}),e.folder&&F.has(e.folder.id)?null:(0,Q.jsx)(`div`,{className:A(`space-y-0.5`,i&&`space-y-1`),children:e.sessions.map(e=>{let t=n===e.id,l=he?.sessionId===e.id;return(0,Q.jsx)(`div`,{draggable:!i&&!!y&&a!==e.id,onDragStart:t=>{N(),ge(null),ae(e.id),t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,e.id)},onDragEnd:ce,className:A(`group relative cursor-pointer transition-colors duration-150 touch-manipulation outline-none`,i?`rounded-xl p-1 flex items-center justify-center`:`rounded-lg px-2`,t?`bg-interactive-active`:`hover:bg-interactive-hover`,ie===e.id&&`opacity-40`),onClick:()=>{N(),c(e)},onMouseEnter:t=>P(e,t.currentTarget),onMouseLeave:N,title:i?`${e.title} - ${e.model}`:void 0,children:i?(0,Q.jsx)(`div`,{className:`flex items-center justify-center w-full h-10`,children:(0,Q.jsx)(`div`,{className:A(`flex h-9 w-9 items-center justify-center rounded-xl text-[11px] font-semibold uppercase transition-colors`,r===e.id?`bg-white text-primary-600 animate-pulse dark:bg-dark-200 dark:text-primary-400`:t?`bg-gray-950 text-white dark:bg-white dark:text-gray-950`:`bg-white/70 text-gray-500 ring-1 ring-black/[0.04] dark:bg-dark-200/70 dark:text-dark-600 dark:ring-white/[0.05]`),children:e.title.trim().charAt(0)||`•`})}):a===e.id?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(Mt,{value:o,onChange:e=>s(e.target.value),onKeyDown:t=>{t.key===`Enter`?u(e.id):t.key===`Escape`&&d()},className:`text-sm h-8`,autoFocus:!0}),(0,Q.jsx)(kt,{variant:`ghost`,size:`sm`,onClick:()=>u(e.id),className:`h-8 w-8 p-0 shrink-0 hover:bg-gray-100 dark:hover:bg-dark-300 active:bg-gray-200 dark:active:bg-dark-400 touch-manipulation`,children:(0,Q.jsx)(ot,{className:`h-3 w-3`})}),(0,Q.jsx)(kt,{variant:`ghost`,size:`sm`,onClick:d,className:`h-8 w-8 p-0 shrink-0 hover:bg-gray-100 dark:hover:bg-dark-300 active:bg-gray-200 dark:active:bg-dark-400 touch-manipulation`,children:(0,Q.jsx)(Ye,{className:`h-3 w-3`})})]}):(0,Q.jsxs)(`div`,{className:`flex h-8 w-full items-center`,children:[(0,Q.jsx)(`h3`,{className:`min-w-0 flex-1 truncate text-sm leading-5 text-ink`,title:e.title,children:r===e.id?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,title:x(`chat.session.generatingTitle`),children:[(0,Q.jsx)(B,{className:`h-3.5 w-3.5 shrink-0 animate-spin text-ink-subtle`}),(0,Q.jsx)(`span`,{className:`truncate`,children:k(e.title,40)})]}):k(e.title,40)}),(0,Q.jsx)(`span`,{dir:`auto`,className:A(`ms-2 shrink-0 text-xs leading-5 tabular-nums text-ink-subtle max-sm:hidden`,`sm:group-hover:hidden sm:group-focus-within:hidden`,l&&`sm:hidden`),children:O(e.updatedAt,S.language)}),(0,Q.jsx)(kt,{variant:`ghost`,size:`sm`,onClick:t=>{t.stopPropagation(),N(),D(e.id)},className:`h-8 w-8 shrink-0 rounded-lg p-0 touch-manipulation sm:hidden`,title:x(`palette.actions`),"aria-label":x(`palette.actions`),"data-testid":`sidebar-session-actions-mobile`,children:(0,Q.jsx)(We,{className:`h-4 w-4`})}),(0,Q.jsx)(`div`,{className:A(`hidden shrink-0`,`sm:group-hover:block sm:group-focus-within:block`,l&&`sm:block`),children:(0,Q.jsx)(kt,{variant:`ghost`,size:`sm`,onClick:t=>_e(e,t),className:A(`h-6 w-6 rounded-md p-0 text-ink-subtle hover:text-ink hover:bg-transparent touch-manipulation`,l&&`text-ink`),title:x(`palette.actions`),"aria-label":x(`palette.actions`),"aria-haspopup":`menu`,"aria-expanded":l,"data-testid":`sidebar-session-actions`,children:(0,Q.jsx)(We,{className:`h-4 w-4`})})})]})},e.id)})})]},e.key))})]}),C&&(0,Q.jsx)(Li,{preview:C}),he&&H&&(0,yi.createPortal)((0,Q.jsxs)(`div`,{className:`fixed inset-0 z-[75] hidden sm:block`,children:[(0,Q.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":x(`common.close`),className:`absolute inset-0 cursor-default`,onClick:()=>ge(null)}),(0,Q.jsxs)(`div`,{role:`menu`,"aria-label":H.title,"data-testid":`sidebar-session-menu`,className:`absolute overflow-y-auto rounded-xl border border-black/[0.04] bg-surface-overlay p-1 shadow-lv3 animate-scale-in dark:border-white/[0.06]`,style:{top:he.top,left:he.left,width:208,maxHeight:340},children:[(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{ge(null),ve(H)},className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-start text-[13px] text-ink hover:bg-interactive-hover`,children:[(0,Q.jsx)(Qe,{className:`h-3.5 w-3.5 shrink-0`}),x(`chat.session.openNewTab`)]}),(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:e=>{ge(null),l(H,e)},className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-start text-[13px] text-ink hover:bg-interactive-hover`,children:[(0,Q.jsx)(Xe,{className:`h-3.5 w-3.5 shrink-0`}),x(`chat.session.renameChat`)]}),m&&(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{ge(null),m(H.id,!H.pinned)},className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-start text-[13px] text-ink hover:bg-interactive-hover`,children:[H.pinned?(0,Q.jsx)(Be,{className:`h-3.5 w-3.5 shrink-0`}):(0,Q.jsx)(L,{className:`h-3.5 w-3.5 shrink-0`}),H.pinned?x(`chat.session.unpinChat`):x(`chat.session.pinChat`)]}),!H.shared&&!H.isPrivate&&(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{ge(null),pe(H)},className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-start text-[13px] text-ink hover:bg-interactive-hover`,"data-testid":`session-share`,children:[(0,Q.jsx)(me,{className:`h-3.5 w-3.5 shrink-0`}),x(`chat.session.shareChat`)]}),p&&(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:e=>{ge(null),p(H.id,e)},className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-start text-[13px] text-ink hover:bg-interactive-hover`,children:[(0,Q.jsx)(Me,{className:`h-3.5 w-3.5 shrink-0`}),x(`chat.session.archiveChat`)]}),y&&h.length>0&&(0,Q.jsxs)(`div`,{className:`mt-1 border-t border-black/[0.06] pt-1 dark:border-white/[0.07]`,children:[(0,Q.jsx)(`p`,{className:`px-2.5 py-1 text-[10px] font-semibold uppercase tracking-[0.12em] text-gray-400 dark:text-dark-500 rtl:tracking-normal`,children:x(`chat.session.folder.move`)}),h.map(e=>(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{ge(null),y(H.id,e.id)},className:A(`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-start text-[13px] text-ink hover:bg-interactive-hover`,H.folderId===e.id&&`text-primary-600 dark:text-primary-400`),children:[(0,Q.jsx)(ye,{className:`h-3.5 w-3.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.name})]},e.id)),H.folderId&&(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{ge(null),y(H.id,null)},className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-start text-[13px] text-ink-muted hover:bg-interactive-hover`,children:[(0,Q.jsx)(Ye,{className:`h-3.5 w-3.5 shrink-0`}),x(`chat.session.folder.remove`)]})]}),(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:e=>{ge(null),f(H.id,e)},className:`mt-1 flex w-full items-center gap-2.5 rounded-lg border-t border-black/[0.06] px-2.5 py-2 text-start text-[13px] text-red-500 hover:bg-red-50 dark:border-white/[0.07] dark:hover:bg-red-900/20`,children:[(0,Q.jsx)(Oe,{className:`h-3.5 w-3.5 shrink-0`}),x(`chat.session.deleteChat`)]})]})]}),document.body),fe&&(0,Q.jsx)(Mi,{resourceType:`session`,resourceId:fe.id,resourceLabel:fe.title,onClose:()=>pe(null)}),M&&(0,yi.createPortal)((0,Q.jsxs)(`div`,{className:`fixed inset-0 z-[80] sm:hidden`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-black/35 backdrop-blur-[2px]`,onClick:()=>D(null),"aria-label":x(`common.close`)}),(0,Q.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":x(`palette.actions`),className:`absolute inset-x-3 bottom-3 rounded-2xl border border-black/[0.08] bg-surface p-2 shadow-[0_20px_70px_rgba(0,0,0,0.3)] dark:border-white/[0.09] dark:bg-dark-100`,"data-testid":`sidebar-session-actions-sheet`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-2 pb-2 pt-1`,children:[(0,Q.jsx)(`p`,{className:`min-w-0 truncate text-sm font-semibold text-gray-900 dark:text-dark-900`,children:M.title}),(0,Q.jsx)(kt,{variant:`ghost`,size:`sm`,onClick:()=>D(null),className:`h-9 w-9 shrink-0 rounded-xl p-0`,title:x(`common.close`),"aria-label":x(`common.close`),children:(0,Q.jsx)(Ye,{className:`h-4 w-4`})})]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:e=>{D(null),l(M,e)},className:`flex min-h-11 w-full items-center gap-3 rounded-xl px-3 py-2 text-start text-sm text-ink hover:bg-interactive-hover`,children:[(0,Q.jsx)(Xe,{className:`h-4 w-4 shrink-0`}),x(`chat.session.renameChat`)]}),m&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{D(null),m(M.id,!M.pinned)},className:`flex min-h-11 w-full items-center gap-3 rounded-xl px-3 py-2 text-start text-sm text-ink hover:bg-interactive-hover`,children:[M.pinned?(0,Q.jsx)(Be,{className:`h-4 w-4 shrink-0`}):(0,Q.jsx)(L,{className:`h-4 w-4 shrink-0`}),M.pinned?x(`chat.session.unpinChat`):x(`chat.session.pinChat`)]}),p&&(0,Q.jsxs)(`button`,{type:`button`,onClick:e=>{D(null),p(M.id,e)},className:`flex min-h-11 w-full items-center gap-3 rounded-xl px-3 py-2 text-start text-sm text-ink hover:bg-interactive-hover`,children:[(0,Q.jsx)(Me,{className:`h-4 w-4 shrink-0`}),x(`chat.session.archiveChat`)]}),y&&h.length>0&&(0,Q.jsxs)(`div`,{className:`mt-1 border-t border-black/[0.06] pt-1 dark:border-white/[0.07]`,children:[(0,Q.jsx)(`p`,{className:`px-3 py-1 text-[10px] font-semibold uppercase tracking-[0.12em] text-gray-400 dark:text-dark-500`,children:x(`chat.session.folder.move`)}),h.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{D(null),y(M.id,e.id)},className:A(`flex min-h-11 w-full items-center gap-3 rounded-xl px-3 py-2 text-start text-sm text-ink hover:bg-interactive-hover`,M.folderId===e.id&&`text-primary-600 dark:text-primary-400`),children:[(0,Q.jsx)(ye,{className:`h-4 w-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.name})]},e.id)),M.folderId&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{D(null),y(M.id,null)},className:`flex min-h-11 w-full items-center gap-3 rounded-xl px-3 py-2 text-start text-sm text-gray-500 hover:bg-gray-100 dark:text-dark-600 dark:hover:bg-dark-200`,children:[(0,Q.jsx)(Ye,{className:`h-4 w-4 shrink-0`}),x(`chat.session.folder.remove`)]})]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:e=>{D(null),f(M.id,e)},className:`mt-1 flex min-h-11 w-full items-center gap-3 rounded-xl border-t border-black/[0.06] px-3 py-2 text-start text-sm text-red-500 hover:bg-red-50 dark:border-white/[0.07] dark:hover:bg-red-900/20`,children:[(0,Q.jsx)(Oe,{className:`h-4 w-4 shrink-0`}),x(`chat.session.deleteChat`)]})]})]}),document.body)]})}var zi=[{id:`users`,to:`/users`,icon:Pe,labelKey:`user.menu.userManagement`},{id:`system`,to:`/system`,icon:at,labelKey:`user.menu.system`},{id:`usage`,to:`/usage`,icon:Ce,labelKey:`user.menu.usageAnalytics`},{id:`evaluations`,to:`/evaluations`,icon:Je,labelKey:`user.menu.evaluations`}];function Bi({user:e,size:t}){let n=t===`sm`?`w-7 h-7`:`w-8 h-8`,r=t===`sm`?`text-xs`:`text-sm`;return e.avatar?(0,Q.jsx)(`img`,{src:e.avatar,alt:e.username,className:`${n} rounded-full object-cover ring-1 ring-black/10 dark:ring-white/10`,title:`${e.username} (${e.role})`}):(0,Q.jsx)(`div`,{className:`${n} bg-gray-950 dark:bg-white rounded-full flex items-center justify-center`,title:`${e.username} (${e.role})`,children:(0,Q.jsx)(`span`,{className:`text-white dark:text-gray-950 ${r} font-medium`,children:e.username.charAt(0).toUpperCase()})})}function Vi({requiresAuth:e,user:t,isAdmin:n,pendingApprovalCount:r,sidebarCompact:i,userMenuOpen:a,userMenuRef:o,pinnedShortcuts:s,onToggleShortcutPin:c,onToggleUserMenu:l,onOpenSettings:u,onOpenAvatar:d,onLogout:f,onMobileNavigate:p,onCloseUserMenu:m}){let{t:h}=w();if(!e||!t)return null;let g=n?zi.filter(e=>s.includes(e.id)):[],_=()=>n&&zi.map(e=>{let t=s.includes(e.id),n=h(t?`user.menu.unpinShortcut`:`user.menu.pinShortcut`);return(0,Q.jsxs)(`div`,{className:`group/shortcut relative`,children:[(0,Q.jsxs)(b,{to:e.to,onClick:()=>{m(),p()},className:`flex w-full items-center gap-3 px-3 py-2.5 pe-9 text-[13px] text-ink transition-colors duration-150 hover:bg-interactive-hover`,children:[(0,Q.jsx)(e.icon,{className:`h-4 w-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 text-start`,children:h(e.labelKey)}),e.id===`users`&&r>0&&(0,Q.jsx)(`span`,{className:`rounded-md bg-error-500 px-1.5 py-0.5 text-[10px] font-semibold text-white`,children:r>99?`99+`:r})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>c(e.id),className:A(`absolute end-2 top-1/2 -translate-y-1/2 rounded-md p-1 text-ink-subtle transition-[color,opacity] hover:text-ink focus-visible:opacity-100`,t?`opacity-100 text-primary-600 dark:text-primary-400 hover:text-primary-500`:`opacity-0 group-hover/shortcut:opacity-100`),title:n,"aria-label":`${n}: ${h(e.labelKey)}`,"aria-pressed":t,"data-testid":`sidebar-shortcut-pin-${e.id}`,children:t?(0,Q.jsx)(Be,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(L,{className:`h-3.5 w-3.5`})})]},e.id)});return(0,Q.jsx)(`div`,{className:A(`border-t border-black/[0.04] dark:border-white/[0.06]`,`p-2`),children:i?(0,Q.jsxs)(`div`,{className:`relative flex flex-col items-center gap-1`,ref:o,children:[g.map(e=>(0,Q.jsxs)(b,{to:e.to,onClick:p,className:`relative flex h-9 w-9 items-center justify-center rounded-full text-ink outline-none transition-colors hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-primary-500/30`,title:h(e.labelKey),"aria-label":h(e.labelKey),"data-testid":`sidebar-rail-pinned-${e.id}`,children:[(0,Q.jsx)(e.icon,{className:`h-[18px] w-[18px]`}),e.id===`users`&&r>0&&(0,Q.jsx)(`span`,{className:`absolute -end-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-md bg-error-500 px-1 text-[9px] font-semibold text-white shadow-sm`,children:r>99?`99+`:r})]},e.id)),(0,Q.jsx)(`button`,{type:`button`,onClick:u,className:`flex h-9 w-9 items-center justify-center rounded-full text-ink outline-none transition-colors hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-primary-500/30`,title:h(`user.menu.settings`),"aria-label":h(`user.menu.settings`),"data-testid":`sidebar-rail-settings-button`,children:(0,Q.jsx)(be,{className:`h-[18px] w-[18px]`})}),(0,Q.jsxs)(`button`,{type:`button`,onClick:l,className:`relative flex h-9 w-9 items-center justify-center rounded-full outline-none transition-colors hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-primary-500/30`,"aria-label":t.username,"aria-expanded":a,title:t.username,"data-testid":`sidebar-rail-user-menu-button`,children:[(0,Q.jsx)(Bi,{user:t,size:`sm`}),r>0&&(0,Q.jsx)(`span`,{"data-testid":`pending-user-notification-badge`,className:`absolute -end-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-md bg-error-500 px-1 text-[9px] font-semibold text-white shadow-sm`,"aria-label":h(`userManager.approval.notificationBadge`,{count:r,defaultValue:`{{count}} pending user approvals`}),children:r>99?`99+`:r})]}),a&&(0,Q.jsxs)(`div`,{"data-testid":`sidebar-user-menu`,className:`scroll-region absolute bottom-0 start-full z-[70] ms-3 w-64 max-h-[calc(100dvh-1rem)] overflow-y-auto rounded-xl border border-black/[0.04] bg-surface-overlay py-1 shadow-lv3 animate-scale-in scrollbar-thin dark:border-white/[0.06]`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{d(t.avatar||``),m()},className:`flex w-full items-center gap-2.5 border-b border-gray-100 px-3 py-2.5 text-start transition-colors hover:bg-gray-100/70 dark:border-dark-200/50 dark:hover:bg-dark-200/70`,children:[(0,Q.jsx)(Bi,{user:t,size:`md`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block truncate text-sm font-medium text-gray-900 dark:text-gray-100`,children:t.username}),(0,Q.jsx)(`span`,{className:`block truncate text-xs text-gray-500 dark:text-gray-400`,children:h(`user.menu.changePicture`)})]}),(0,Q.jsx)(se,{className:`h-4 w-4 shrink-0 text-gray-400`})]}),(0,Q.jsxs)(`div`,{className:`py-1`,children:[_(),(0,Q.jsx)(`div`,{className:`my-1 border-t border-gray-100 dark:border-dark-200/50`}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{u(),m()},className:`flex w-full items-center gap-3 px-3 py-2.5 text-start text-[13px] text-ink transition-colors hover:bg-interactive-hover`,children:[(0,Q.jsx)(be,{className:`h-4 w-4 shrink-0`}),h(`user.menu.settings`)]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{f(),m()},className:`flex w-full items-center gap-3 px-3 py-2.5 text-start text-[13px] text-red-600 transition-colors hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20`,children:[(0,Q.jsx)(it,{className:`h-4 w-4 shrink-0`}),h(`user.menu.logout`)]})]})]})]}):(0,Q.jsxs)(`div`,{className:`relative`,ref:o,children:[g.map(e=>(0,Q.jsxs)(b,{to:e.to,onClick:p,className:`flex h-[34px] w-full items-center gap-2 rounded-xl px-2.5 text-start text-sm text-ink transition-colors duration-150 hover:bg-interactive-hover touch-manipulation outline-none focus-visible:ring-2 focus-visible:ring-primary-500/30`,"data-testid":`sidebar-pinned-${e.id}`,children:[(0,Q.jsx)(e.icon,{className:`h-4 w-4 shrink-0 text-ink-muted`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:h(e.labelKey)}),e.id===`users`&&r>0&&(0,Q.jsx)(`span`,{className:`rounded-md bg-error-500 px-1.5 py-0.5 text-[10px] font-semibold text-white`,children:r>99?`99+`:r})]},e.id)),(0,Q.jsxs)(`button`,{type:`button`,onClick:u,className:`flex h-[34px] w-full items-center gap-2 rounded-xl px-2.5 text-start text-sm text-ink transition-colors duration-150 hover:bg-interactive-hover touch-manipulation outline-none focus-visible:ring-2 focus-visible:ring-primary-500/30`,"data-testid":`sidebar-settings-button`,children:[(0,Q.jsx)(be,{className:`h-4 w-4 shrink-0 text-ink-muted`}),h(`user.menu.settings`)]}),(0,Q.jsxs)(`button`,{onClick:l,className:`relative h-[38px] w-full rounded-xl px-2.5 hover:bg-interactive-hover transition-colors duration-150 text-start touch-manipulation outline-none focus-visible:ring-2 focus-visible:ring-primary-500/30`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Bi,{user:t,size:`sm`}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,Q.jsx)(`p`,{className:`truncate text-sm text-ink`,children:t.username}),t.role===`admin`&&(0,Q.jsx)(ge,{size:11,className:`shrink-0 text-ink-subtle`})]}),(0,Q.jsx)(ue,{className:A(`h-4 w-4 text-ink-subtle transition-transform duration-150 rtl:rotate-180`,a&&`rotate-90 rtl:rotate-90`)})]}),n&&r>0&&(0,Q.jsx)(`span`,{"data-testid":`pending-user-notification-badge`,className:`absolute -end-1 -top-1 flex h-5 min-w-5 items-center justify-center rounded-full bg-error-500 px-1 text-[10px] font-semibold text-white shadow-subtle`,"aria-label":h(`userManager.approval.notificationBadge`,{count:r,defaultValue:`{{count}} pending user approvals`}),children:r>99?`99+`:r})]}),a&&(0,Q.jsxs)(`div`,{"data-testid":`sidebar-user-menu`,className:`scroll-region absolute bottom-full left-0 right-0 z-50 mb-2 max-h-[calc(100dvh-1rem)] rounded-xl border border-black/[0.04] bg-surface-overlay py-1 shadow-lv3 animate-scale-in scrollbar-thin dark:border-white/[0.06]`,children:[(0,Q.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-100 dark:border-dark-200/50`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,Q.jsx)(Bi,{user:t,size:`md`}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:t.username}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:t.email||h(`user.profile.noEmail`)})]})]})}),(0,Q.jsxs)(`div`,{className:`py-1`,children:[(0,Q.jsxs)(`button`,{onClick:()=>{d(t.avatar||``),m()},className:`w-full flex items-center gap-3 px-3 py-2.5 text-[13px] text-ink hover:bg-interactive-hover transition-colors duration-150 text-start`,children:[(0,Q.jsx)(se,{className:`h-4 w-4 shrink-0`}),h(`user.menu.changePicture`)]}),_(),(0,Q.jsx)(`div`,{className:`border-t border-gray-100 dark:border-dark-200/50 my-1`}),(0,Q.jsxs)(`button`,{onClick:()=>{u(),m()},className:`w-full flex items-center gap-3 px-3 py-2.5 text-[13px] text-ink hover:bg-interactive-hover transition-colors duration-150 text-start`,children:[(0,Q.jsx)(be,{className:`h-4 w-4 shrink-0`}),h(`user.menu.settings`)]}),(0,Q.jsxs)(`button`,{onClick:()=>{f(),m()},className:`w-full flex items-center gap-3 px-3 py-2.5 text-[13px] text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors duration-150 text-start`,children:[(0,Q.jsx)(it,{className:`h-4 w-4 shrink-0`}),h(`user.menu.logout`)]})]})]})]})})}var Hi=()=>{let e=localStorage.getItem(`auth-token`);return e?{Authorization:`Bearer ${e}`}:{}},Ui=8,Wi=2e3,Gi=(e,t)=>new Promise(n=>{let r=setTimeout(n,e);t.addEventListener(`abort`,()=>{clearTimeout(r),n()},{once:!0})}),Ki=async e=>{let t=0,n=0;for(;!e.signal.aborted&&n<Ui;)try{let r=await fetch(`${ft}${e.path}?after=${t}`,{headers:{Accept:`text/event-stream`,...Hi()},credentials:`same-origin`,signal:e.signal});if(!r.ok||!r.body){n+=1,await Gi(Wi,e.signal);continue}n=0;let i=r.body.getReader(),a=new TextDecoder,o=``;try{for(;;){let{done:n,value:r}=await i.read();o+=a.decode(r,{stream:!n}).replace(/\r\n/g,`
|
|
3
|
+
`);let s=o.indexOf(`
|
|
4
|
+
|
|
5
|
+
`);for(;s>=0;){let n=o.slice(0,s);o=o.slice(s+2),s=o.indexOf(`
|
|
6
|
+
|
|
7
|
+
`);let r,i=[];for(let e of n.split(`
|
|
8
|
+
`))e.startsWith(`id:`)&&(r=Number(e.slice(3).trim())),e.startsWith(`data:`)&&i.push(e.slice(5).trimStart());if(!(!Number.isSafeInteger(r)||i.length===0)){t=r;try{e.onEvent(JSON.parse(i.join(`
|
|
9
|
+
`)))}catch{}}}if(n)break}}finally{await i.cancel().catch(()=>void 0),i.releaseLock()}}catch{if(e.signal.aborted)return;n+=1,await Gi(Wi,e.signal)}},qi=dt(`notification-bell`),Ji=({sidebarCompact:e})=>{let{t,i18n:n}=w(),r=d(),[i,a]=(0,Z.useState)(0),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(null),u=(0,Z.useRef)(null),f=(0,Z.useCallback)(()=>{vt.unreadCount().then(e=>{e.success&&e.data&&a(e.data.count)}).catch(e=>qi.debug(`Unread poll failed:`,e))},[]);(0,Z.useEffect)(()=>{f();let e=window.setInterval(f,6e4),t=new AbortController;return Ki({path:`/notifications/events`,signal:t.signal,onEvent:()=>f()}),()=>{window.clearInterval(e),t.abort()}},[f]);let p=()=>{s(!0),vt.list({limit:50}).then(e=>{e.success&&e.data&&l(e.data)}).catch(e=>qi.error(`Failed to load notifications:`,e))},m=e=>{vt.markRead(e.id).then(f),s(!1),e.href&&r(e.href)};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>o?s(!1):p(),className:A(`relative flex items-center gap-2 rounded-lg text-[13px] text-gray-600 hover:bg-black/[0.04] dark:text-dark-700 dark:hover:bg-white/[0.06]`,e?`mx-auto h-9 w-9 justify-center`:`mx-2 px-2 py-1.5`),title:t(`notifications.title`),"aria-label":t(`notifications.title`),"data-testid":`notification-bell`,children:[(0,Q.jsx)(te,{className:`h-4 w-4 shrink-0`}),!e&&(0,Q.jsx)(`span`,{children:t(`notifications.title`)}),i>0&&(0,Q.jsx)(`span`,{className:A(`rounded-full bg-primary-500 px-1.5 text-[10px] font-semibold leading-4 text-white`,e&&`absolute -right-0.5 -top-0.5`),"data-testid":`notification-unread-badge`,children:i>99?`99+`:i})]}),o&&(0,yi.createPortal)((0,Q.jsx)(`div`,{className:`fixed inset-0 z-[2147483646]`,onClick:()=>s(!1),children:(0,Q.jsxs)(`div`,{ref:u,role:`dialog`,"aria-label":t(`notifications.title`),className:`absolute bottom-16 left-4 flex max-h-[70vh] w-80 flex-col overflow-hidden rounded-2xl border border-black/[0.08] bg-white shadow-[0_18px_60px_rgba(0,0,0,0.22)] dark:border-white/[0.1] dark:bg-dark-25`,onClick:e=>e.stopPropagation(),"data-testid":`notification-panel`,children:[(0,Q.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,Q.jsx)(`span`,{className:`flex-1 text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-dark-600`,children:t(`notifications.title`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void vt.markAllRead().then(()=>{f(),l(e=>e&&e.map(e=>({...e,readAt:e.readAt??Date.now()})))}),className:`rounded-md p-1 text-gray-400 hover:text-gray-700 dark:hover:text-dark-800`,title:t(`notifications.markAllRead`),"data-testid":`notification-mark-all`,children:(0,Q.jsx)(ne,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>s(!1),className:`rounded-md p-1 text-gray-400 hover:text-gray-700 dark:hover:text-dark-800`,children:(0,Q.jsx)(Ye,{className:`h-3.5 w-3.5`})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto scrollbar-thin`,children:c===null?(0,Q.jsx)(B,{className:`mx-auto my-6 h-4 w-4 animate-spin text-gray-400`}):c.length===0?(0,Q.jsx)(`p`,{className:`py-8 text-center text-xs text-gray-400 dark:text-dark-500`,children:t(`notifications.empty`)}):c.map(e=>(0,Q.jsxs)(`div`,{className:A(`group flex cursor-pointer items-start gap-2 border-b border-black/[0.04] px-3 py-2.5 last:border-b-0 hover:bg-black/[0.03] dark:border-white/[0.04] dark:hover:bg-white/[0.04]`,!e.readAt&&`bg-primary-500/[0.04]`),onClick:()=>m(e),"data-testid":`notification-item`,children:[(0,Q.jsx)(`span`,{className:A(`mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full`,e.readAt?`bg-transparent`:`bg-primary-500`)}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`text-[13px] font-medium leading-snug text-gray-900 dark:text-dark-900`,children:e.title}),e.body&&(0,Q.jsx)(`p`,{className:`mt-0.5 truncate text-[12px] text-gray-500 dark:text-dark-600`,children:e.body}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-[11px] text-gray-400 dark:text-dark-500`,children:O(e.createdAt,n.language)})]}),!e.readAt&&(0,Q.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),vt.markRead(e.id).then(()=>{f(),l(t=>t&&t.map(t=>t.id===e.id?{...t,readAt:Date.now()}:t))})},className:`hidden rounded p-1 text-gray-400 hover:text-emerald-600 group-hover:block`,title:t(`notifications.markRead`),"data-testid":`notification-mark-read`,children:(0,Q.jsx)(ot,{className:`h-3.5 w-3.5`})})]},e.id))})]})}),document.body)]})},Yi={idle:{labelKey:`work.statusLabels.idle`,label:`Idle`,color:`rgb(255, 255, 255)`,animated:!1},preparing:{labelKey:`work.statusLabels.thinking`,label:`Thinking`,color:`rgb(48, 121, 255)`,animated:!0},running:{labelKey:`work.statusLabels.thinking`,label:`Thinking`,color:`rgb(48, 121, 255)`,animated:!0},completed:{labelKey:`work.statusLabels.complete`,label:`Complete`,color:`rgb(76, 212, 117)`,animated:!1},needs_input:{labelKey:`work.statusLabels.needsInput`,label:`Needs input`,color:`rgb(255, 204, 0)`,animated:!1},cancelled:{labelKey:`work.statusLabels.needsInput`,label:`Needs input`,color:`rgb(255, 204, 0)`,animated:!1},failed:{labelKey:`work.statusLabels.error`,label:`Error`,color:`rgb(255, 61, 129)`,animated:!1}};function Xi(e){let t=e.trim().split(/\s+/u).filter(Boolean);return t.length===0?`•`:t.length===1?Array.from(t[0]).slice(0,2).join(``).toLocaleUpperCase():`${Array.from(t[0])[0]}${Array.from(t[t.length-1])[0]}`.toLocaleUpperCase()}function Zi({preview:e}){let{t}=w(),{task:n}=e,r=Yi[n.status],i=t(r.labelKey,{defaultValue:r.label});return(0,Q.jsxs)(Ni,{top:e.top,left:e.left,title:n.title||t(`work.tasks.untitled`,{defaultValue:`Untitled task`}),timestamp:n.updatedAt,children:[(0,Q.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[11px] leading-snug text-gray-600 dark:text-dark-700`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:A(`h-2 w-2 shrink-0 rounded-full`,r.animated&&`animate-pulse`),style:{backgroundColor:r.color}}),i]}),(0,Q.jsx)(`p`,{className:`mt-1.5 truncate font-mono text-[10px] text-gray-400 dark:text-dark-500`,children:n.model}),n.hostPath&&(0,Q.jsx)(`p`,{className:`mt-1 truncate font-mono text-[10px] text-gray-400 dark:text-dark-500`,title:n.hostPath,children:n.hostPath})]})}var Qi=208,$i=180;function ea({tasks:e,currentTaskId:t,loading:n,actionLoading:r,sidebarCompact:i,onSelectTask:a,onDeleteTask:o,onExpandSidebar:s}){let{t:c,i18n:l}=w(),u=[...e].sort((e,t)=>t.updatedAt-e.updatedAt),[d,f]=(0,Z.useState)(null),p=(0,Z.useRef)(null),[m,h]=(0,Z.useState)(null),g=m?e.find(e=>e.id===m)??null:null;(0,Z.useEffect)(()=>()=>{p.current!==null&&window.clearTimeout(p.current)},[]);let _=()=>{p.current!==null&&(window.clearTimeout(p.current),p.current=null),f(null)},v=(e,t)=>{let n=window.matchMedia(`(hover: hover) and (pointer: fine)`).matches;i||window.innerWidth<768||!n||(p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{let n=t.getBoundingClientRect();f({task:e,top:n.top,left:n.right+10})},500))},[y,b]=(0,Z.useState)(null),x=y?e.find(e=>e.id===y.taskId)??null:null;(0,Z.useEffect)(()=>{if(!y)return;let e=e=>{e.key===`Escape`&&b(null)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[y]);let S=(e,t)=>{if(t.stopPropagation(),_(),y?.taskId===e.id){b(null);return}let n=t.currentTarget.getBoundingClientRect();b({taskId:e.id,top:Math.max(8,Math.min(n.bottom+6,window.innerHeight-$i-8)),left:Math.max(8,Math.min(n.right-Qi,window.innerWidth-Qi-8))})},C=e=>{let t=window.location.protocol===`file:`?`${window.location.pathname}#/work/${e.id}`:`/work/${e.id}`;window.open(t,`_blank`,`noopener,noreferrer`)},T=e=>e.title||c(`work.tasks.untitled`,{defaultValue:`Untitled task`});return(0,Q.jsxs)(`div`,{"data-testid":`sidebar-work-task-scroll-region`,className:`scroll-region min-h-0 flex-1 border-t border-black/[0.05] scrollbar-thin dark:border-white/[0.05]`,style:{willChange:`scroll-position`},children:[(0,Q.jsxs)(`div`,{className:A(`px-3 py-3`,i&&`px-2`),children:[!i&&e.length>0&&(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center justify-between px-1`,children:[(0,Q.jsx)(`h3`,{className:`text-xs font-medium text-ink-subtle`,children:c(`work.tasks.title`,{defaultValue:`Work tasks`})}),(0,Q.jsx)(`span`,{className:`text-[10px] font-medium tabular-nums text-gray-400 dark:text-dark-500`,children:e.length})]}),i?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:s,"data-testid":`sidebar-mobile-work-tasks`,"aria-label":`${c(`work.tasks.title`,{defaultValue:`Work tasks`})} (${e.length})`,title:c(`work.tasks.title`,{defaultValue:`Work tasks`}),className:`relative flex h-12 w-12 items-center justify-center rounded-xl text-gray-500 outline-none transition-colors hover:bg-white/70 hover:text-gray-950 focus-visible:ring-2 focus-visible:ring-primary-500/30 dark:text-dark-600 dark:hover:bg-dark-200 dark:hover:text-dark-950 md:hidden`,children:[(0,Q.jsx)(V,{className:`h-[18px] w-[18px]`}),e.length>0&&(0,Q.jsx)(`span`,{className:`absolute -end-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-md bg-primary-500 px-1 text-[9px] font-semibold tabular-nums text-white shadow-sm`,children:e.length>99?`99+`:e.length})]}),(0,Q.jsx)(`div`,{"data-testid":`sidebar-compact-work-task-list`,className:`flex w-full flex-col items-center gap-1`,children:u.map(e=>{let n=t===e.id,r=Yi[e.status],i=T(e);return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>a(e.id),"data-testid":`sidebar-compact-work-task`,"aria-current":n?`page`:void 0,"aria-label":i,title:i,className:A(`relative flex h-12 w-12 items-center justify-center rounded-xl outline-none transition-colors focus-visible:ring-2 focus-visible:ring-primary-500/30`,n?`bg-primary-500/10 text-primary-700 ring-1 ring-primary-500/10 dark:bg-primary-500/15 dark:text-primary-300 dark:ring-primary-400/10`:`text-gray-500 hover:bg-white/70 hover:text-gray-950 dark:text-dark-600 dark:hover:bg-dark-200 dark:hover:text-dark-950`),children:[n&&(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`absolute -start-2 h-5 w-0.5 rounded-full bg-primary-500 shadow-[0_0_12px_rgb(var(--color-primary-500)/0.55)]`}),(0,Q.jsx)(`span`,{className:`font-mono text-[11px] font-semibold tracking-[-0.03em]`,children:Xi(i)}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:A(`absolute bottom-1.5 end-1.5 h-2 w-2 rounded-full border-2 border-gray-100 dark:border-dark-50`,r.animated&&`animate-pulse`,e.status===`idle`&&`ring-1 ring-black/20 dark:ring-white/20`),style:{backgroundColor:r.color}})]},e.id)})})]}):n&&e.length===0?(0,Q.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex items-center justify-center py-10 text-gray-400 dark:text-dark-500`,children:[(0,Q.jsx)(B,{"aria-hidden":`true`,className:`h-5 w-5 animate-spin`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:c(`work.tasks.loading`,{defaultValue:`Loading Work tasks`})})]}):e.length===0?(0,Q.jsxs)(`div`,{className:A(`py-8 text-center`,i?`px-1`:`px-2`),children:[(0,Q.jsx)(`div`,{className:A(`mx-auto mb-3 flex items-center justify-center rounded-xl bg-white/70 ring-1 ring-black/[0.04] dark:bg-dark-200 dark:ring-white/[0.05]`,i?`h-8 w-8`:`h-12 w-12`),children:(0,Q.jsx)(V,{className:A(`text-gray-400 dark:text-gray-500`,i?`h-4 w-4`:`h-5 w-5`)})}),!i&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-gray-600 dark:text-dark-600`,children:c(`work.tasks.emptyTitle`,{defaultValue:`No Work tasks yet`})}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-gray-400 dark:text-dark-500`,children:c(`work.tasks.empty`,{defaultValue:`Your Work tasks will appear here after you send the first message.`})})]})]}):(0,Q.jsx)(`div`,{"data-testid":`sidebar-work-task-list`,className:`space-y-0.5`,children:e.map(e=>{let n=t===e.id,r=Yi[e.status],i=c(r.labelKey,{defaultValue:r.label}),o=y?.taskId===e.id;return(0,Q.jsx)(`div`,{"data-testid":`sidebar-work-task-item`,"data-task-id":e.id,"aria-current":n?`page`:void 0,className:A(`group relative cursor-pointer rounded-lg px-2 transition-colors duration-150 outline-none touch-manipulation`,n?`bg-interactive-active`:`hover:bg-interactive-hover`),onClick:()=>{_(),a(e.id)},onMouseEnter:t=>v(e,t.currentTarget),onMouseLeave:_,children:(0,Q.jsxs)(`div`,{className:`flex h-8 w-full items-center`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`sidebar-work-task-status`,"data-status-label":i,className:A(`me-2 h-2 w-2 shrink-0 rounded-full`,r.animated&&`animate-pulse`,e.status===`idle`&&`ring-1 ring-black/20 dark:ring-white/20`),style:{backgroundColor:r.color}}),(0,Q.jsxs)(`h3`,{dir:`auto`,className:`min-w-0 flex-1 truncate text-sm leading-5 text-ink`,title:T(e),children:[k(T(e),40),(0,Q.jsx)(`span`,{className:`sr-only`,children:c(`work.tasks.status`,{defaultValue:`Status: {{status}}`,status:i})})]}),(0,Q.jsx)(`span`,{dir:`auto`,className:A(`ms-2 shrink-0 text-xs leading-5 tabular-nums text-ink-subtle max-sm:hidden`,`sm:group-hover:hidden sm:group-focus-within:hidden`,o&&`sm:hidden`),children:O(e.updatedAt,l.language)}),(0,Q.jsx)(kt,{variant:`ghost`,size:`sm`,onClick:t=>{t.stopPropagation(),_(),h(e.id)},className:`h-8 w-8 shrink-0 rounded-lg p-0 touch-manipulation sm:hidden`,title:c(`palette.actions`),"aria-label":c(`palette.actions`),"data-testid":`sidebar-work-task-actions-mobile`,children:(0,Q.jsx)(We,{className:`h-4 w-4`})}),(0,Q.jsx)(`div`,{className:A(`hidden shrink-0`,`sm:group-hover:block sm:group-focus-within:block`,o&&`sm:block`),children:(0,Q.jsx)(kt,{variant:`ghost`,size:`sm`,onClick:t=>S(e,t),className:A(`h-6 w-6 rounded-md p-0 text-ink-subtle hover:text-ink hover:bg-transparent touch-manipulation`,o&&`text-ink`),title:c(`palette.actions`),"aria-label":c(`palette.actions`),"aria-haspopup":`menu`,"aria-expanded":o,"data-testid":`sidebar-work-task-actions`,children:(0,Q.jsx)(We,{className:`h-4 w-4`})})})]})},e.id)})})]}),d&&(0,Q.jsx)(Zi,{preview:d}),y&&x&&(0,yi.createPortal)((0,Q.jsxs)(`div`,{className:`fixed inset-0 z-[75] hidden sm:block`,children:[(0,Q.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":c(`common.close`),className:`absolute inset-0 cursor-default`,onClick:()=>b(null)}),(0,Q.jsxs)(`div`,{role:`menu`,"aria-label":T(x),"data-testid":`sidebar-work-task-menu`,className:`absolute overflow-y-auto rounded-xl border border-black/[0.04] bg-surface-overlay p-1 shadow-lv3 animate-scale-in dark:border-white/[0.06]`,style:{top:y.top,left:y.left,width:Qi,maxHeight:$i},children:[(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{b(null),C(x)},className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-start text-[13px] text-ink hover:bg-interactive-hover`,children:[(0,Q.jsx)(Qe,{className:`h-3.5 w-3.5 shrink-0`}),c(`chat.session.openNewTab`)]}),(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,disabled:r,"data-testid":`sidebar-work-task-delete`,onClick:()=>{b(null),o(x)},className:`mt-1 flex w-full items-center gap-2.5 rounded-lg border-t border-black/[0.06] px-2.5 py-2 text-start text-[13px] text-red-500 hover:bg-red-50 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/[0.07] dark:hover:bg-red-900/20`,children:[(0,Q.jsx)(Oe,{className:`h-3.5 w-3.5 shrink-0`}),c(`work.tasks.delete`,{defaultValue:`Delete task`})]})]})]}),document.body),g&&(0,yi.createPortal)((0,Q.jsxs)(`div`,{className:`fixed inset-0 z-[80] sm:hidden`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-black/35 backdrop-blur-[2px]`,onClick:()=>h(null),"aria-label":c(`common.close`)}),(0,Q.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":c(`palette.actions`),className:`absolute inset-x-3 bottom-3 rounded-2xl border border-black/[0.08] bg-surface p-2 shadow-[0_20px_70px_rgba(0,0,0,0.3)] dark:border-white/[0.09] dark:bg-dark-100`,"data-testid":`sidebar-work-task-actions-sheet`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-2 pb-2 pt-1`,children:[(0,Q.jsx)(`p`,{className:`min-w-0 truncate text-sm font-semibold text-gray-900 dark:text-dark-900`,children:T(g)}),(0,Q.jsx)(kt,{variant:`ghost`,size:`sm`,onClick:()=>h(null),className:`h-9 w-9 shrink-0 rounded-xl p-0`,title:c(`common.close`),"aria-label":c(`common.close`),children:(0,Q.jsx)(Ye,{className:`h-4 w-4`})})]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{h(null),C(g)},className:`flex w-full items-center gap-3 rounded-xl px-3 py-3 text-start text-sm text-ink hover:bg-interactive-hover`,children:[(0,Q.jsx)(Qe,{className:`h-4 w-4 shrink-0`}),c(`chat.session.openNewTab`)]}),(0,Q.jsxs)(`button`,{type:`button`,disabled:r,onClick:()=>{h(null),o(g)},className:`flex w-full items-center gap-3 rounded-xl px-3 py-3 text-start text-sm text-red-500 hover:bg-red-50 disabled:cursor-not-allowed disabled:opacity-40 dark:hover:bg-red-900/20`,children:[(0,Q.jsx)(Oe,{className:`h-4 w-4 shrink-0`}),c(`work.tasks.delete`,{defaultValue:`Delete task`})]})]})]}),document.body)]})}var ta=new Map;function na(e,t,n=``){let r=ta.get(e);if(n){if((!r||r.state===`none`)&&(ta.set(e,{state:`open`,startedAt:Date.now()}),!t))return;let n=ta.get(e);t&&n?.state===`open`&&ta.set(e,{state:`done`,durationMs:Date.now()-n.startedAt});return}if(r&&r.state!==`open`||!t)return;let i=D(t);if(!r){i.thinkingComplete?ta.set(e,{state:`none`}):ta.set(e,{state:`open`,startedAt:Date.now()});return}i.thinkingComplete&&ta.set(e,{state:`done`,durationMs:Date.now()-r.startedAt})}function ra(e){let t=ta.get(e);if(t){if(t.state===`done`)return t.durationMs;if(t.state===`open`)return Date.now()-t.startedAt}}function ia(e){let t=ta.get(e);if(ta.delete(e),t){if(t.state===`done`)return t.durationMs;if(t.state===`open`)return Date.now()-t.startedAt}}function aa(e){let t=e/1e3;if(t<.95)return`${Math.max(.1,Math.round(t*10)/10)}s`;if(t<60)return`${Math.round(t)}s`;let n=Math.floor(t/60),r=Math.round(t%60);return r>0?`${n}m ${r}s`:`${n}m`}var oa=(e,t)=>{P.setState(n=>{let r=n=>n&&n.id===e?{...n,settings:{...n.settings,...t.length>0?{promptQueue:t}:{promptQueue:void 0}}}:n;return{currentSession:r(n.currentSession),sessions:n.sessions.map(e=>r(e))}})},sa=(e,t)=>{t?.add(e.assistantMessageId),e.cancelRequested=!0,e.jobId&&e.abort.abort()},ca=async e=>{if(!e.cancelledMessageIds.has(e.assistantMessageId))return!1;try{let t=await(e.cancelByIdentity??va)(e.sessionId,e.assistantMessageId);await e.settle(t)}catch(t){e.onError?.(t)}return!0},la=e=>{e.retainForContinuation||e.cancelledMessageIds.delete(e.assistantMessageId)},ua=async(e,t,n={})=>{if(e.jobId=t.jobId,!e.cancelRequested)return`stream`;e.abort.abort();let[,r]=await Promise.allSettled([(n.byJob??_a)(t.jobId),(n.byIdentity??va)(e.sessionId,e.assistantMessageId)]);if(r.status===`rejected`)throw r.reason;return r.value.completed?`completed`:`cancelled`},da=async e=>{let t=await e.loadSession(e.sessionId);if(t.id!==e.sessionId)throw Error(`Reloaded chat session does not match the completed turn.`);if(!t.messages.find(t=>t.id===e.assistantMessageId&&t.role===`assistant`))throw Error(`Completed assistant message is absent from chat storage.`);return e.applySession(t),t},fa=async e=>{try{let t=await e.json(),n=typeof t.error==`string`?t.error:typeof t.message==`string`?t.message:void 0;if(n)return Error(n)}catch{}return Error(`Chat event request failed with status ${e.status}.`)},pa=()=>{let e=localStorage.getItem(`auth-token`);return e?{Authorization:`Bearer ${e}`}:{}},ma=async e=>{let t=await fetch(`${ft}/chat/sessions/${encodeURIComponent(e.sessionId)}/generations`,{method:`POST`,headers:{"Content-Type":`application/json`,...pa()},credentials:`same-origin`,signal:e.signal,body:JSON.stringify({message:e.message,images:e.images,userMessageId:e.userMessageId,assistantMessageId:e.assistantMessageId,options:e.options,webSearch:e.webSearch,tools:e.tools===!0,...e.toolSelection?{toolSelection:e.toolSelection}:{},regenerate:e.regenerate===!0,originalMessageId:e.originalMessageId,...e.modelOverride?{modelOverride:e.modelOverride}:{},...e.compare?{compare:!0}:{}})});if(!t.ok)throw await fa(t);let n=await t.json();if(!n.data?.jobId)throw Error(`Chat generation response did not include a durable job.`);return n.data},ha=async(e,t)=>{if(!e.body)throw Error(`Chat event stream has no response body.`);let n=e.body.getReader(),r=new TextDecoder,i=``,a=0,o=!1,s=e=>{let n,r=[];for(let t of e.split(`
|
|
10
|
+
`))t.startsWith(`id:`)&&(n=Number(t.slice(3).trim())),t.startsWith(`data:`)&&r.push(t.slice(5).trimStart());if(!Number.isSafeInteger(n)||!r.length)return;let i=JSON.parse(r.join(`
|
|
11
|
+
`)),s=n,c=i.type===`done`||i.type===`error`;t(s,i),a=s,o=c};try{for(;;){let{done:e,value:t}=await n.read();i+=r.decode(t,{stream:!e}).replace(/\r\n/g,`
|
|
12
|
+
`);let a=i.indexOf(`
|
|
13
|
+
|
|
14
|
+
`);for(;a>=0;)s(i.slice(0,a)),i=i.slice(a+2),a=i.indexOf(`
|
|
15
|
+
|
|
16
|
+
`);if(e||o)break}}finally{await n.cancel().catch(()=>void 0),n.releaseLock()}return{cursor:a,terminal:o}},ga=async e=>{let t=0,n=0;for(;!e.signal.aborted;){let r=new URL(`${ft}/chat/sessions/${encodeURIComponent(e.sessionId)}/events`,window.location.origin);r.searchParams.set(`after`,String(t)),r.searchParams.set(`generation`,e.assistantMessageId);try{let i=await fetch(r,{headers:{Accept:`text/event-stream`,...pa()},credentials:`same-origin`,cache:`no-store`,signal:e.signal});if(!i.ok)throw await fa(i);if((await ha(i,(n,r)=>{e.onEvent(r),t=n})).terminal)return;n=0}catch(t){if(e.signal.aborted||(n+=1,n>8))throw t}await new Promise((t,r)=>{let i=window.setTimeout(()=>{e.signal.removeEventListener(`abort`,a),t()},Math.min(5e3,n*500+250)),a=()=>{window.clearTimeout(i),e.signal.removeEventListener(`abort`,a),r(e.signal.reason??Error(`Chat stream cancelled`))};e.signal.addEventListener(`abort`,a,{once:!0})})}},_a=async e=>{let t=await fetch(`${ft}/jobs/${encodeURIComponent(e)}/cancel`,{method:`POST`,headers:pa(),credentials:`same-origin`});if(!t.ok)throw await fa(t)},va=async(e,t)=>{let n=await fetch(`${ft}/chat/sessions/${encodeURIComponent(e)}/generations/${encodeURIComponent(t)}/cancel`,{method:`POST`,headers:pa(),credentials:`same-origin`});if(!n.ok)throw await fa(n);let r=(await n.json()).data;if(!r)throw Error(`Chat cancellation response did not include a decision.`);let i=typeof r.jobId==`string`?r.jobId:void 0;if(r.completed!==!0&&r.pending!==!0&&!i)throw Error(`Chat cancellation response did not include a decision.`);return{completed:r.completed===!0,pending:r.pending===!0,...i?{jobId:i}:{},...typeof r.state==`string`?{state:r.state}:{}}},$=dt(`use-chat`),ya=new Set([`New Chat`,`New Demo Session`]),ba=e=>!e||ya.has(e),xa=e=>{let[t,n]=(0,Z.useState)(``),[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)([]),[d,f]=(0,Z.useState)([]),[p,m]=(0,Z.useState)(null),{addMessage:h,updateMessage:g,updateMessageWithStatistics:_,applySessionTitle:v,setGeneratingTitleForSession:y,removeMessage:b}=P(),{setIsGenerating:x}=Et(),S=(0,Z.useRef)(null),C=(0,Z.useRef)(new Map),w=(0,Z.useRef)(null),T=(0,Z.useRef)(new Set),D=(0,Z.useRef)(null),O=(0,Z.useRef)(null),k=(0,Z.useRef)(null),A=(0,Z.useRef)(!1),j=(0,Z.useRef)(null),N=(0,Z.useRef)(``),F=(0,Z.useRef)(``),ee=(0,Z.useRef)(0),I=(0,Z.useRef)(void 0),L=(0,Z.useRef)(null),te=(0,Z.useRef)(``),ne=(0,Z.useRef)(``),R=(0,Z.useCallback)(()=>{L.current!==null&&typeof window<`u`&&window.cancelAnimationFrame(L.current),L.current=null},[]),re=(0,Z.useCallback)((e,t=!1,r=``)=>{if(te.current=e,ne.current=r,t||typeof window>`u`){R(),n(e),i(r);return}L.current===null&&(L.current=window.requestAnimationFrame(()=>{L.current=null,n(te.current),i(ne.current)}))},[R]),z=(0,Z.useCallback)(()=>{R(),te.current=``,ne.current=``,n(``),i(``)},[R]),ie=(0,Z.useCallback)(e=>{P.setState(t=>({sessions:t.sessions.some(t=>t.id===e.id)?t.sessions.map(t=>t.id===e.id?e:t):[e,...t.sessions],currentSession:t.currentSession?.id===e.id?e:t.currentSession}))},[]),B=(0,Z.useCallback)(async(e,t)=>{await da({sessionId:e,assistantMessageId:t,loadSession:async e=>{let t=await gt.getSession(e);if(!t.success||!t.data)throw Error(t.error||`Completed chat session could not be reloaded.`);return t.data},applySession:ie})},[ie]),ae=(0,Z.useCallback)(async(e,t,n,r={})=>{n.completed?await B(e,t):b(e,t),la({assistantMessageId:t,cancelledMessageIds:T.current,decision:n,retainForContinuation:r.retainForContinuation})},[B,b]),V=(0,Z.useCallback)(()=>{k.current=null,A.current=!1,j.current=null},[]),oe=(0,Z.useCallback)(async e=>{let t=Et.getState().preferences.titleSettings,n=k.current,r=A.current&&j.current===e;if($.debug(`Auto-title check:`,{firstMessage:n,autoTitle:t?.autoTitle,taskModel:t?.taskModel,shouldGenerateTitle:r}),!n||!r||!t?.autoTitle||!t?.taskModel){V();return}V(),$.debug(`Triggering auto-title generation...`),y(e);try{let r=await gt.generateTitle(e,t.taskModel,n,t.taskProviderType,t.taskProviderId);if($.debug(`Title generation response:`,r),!r.success||!r.data?.title)throw Error(r.error||`Title generation returned no title`);v(e,r.data.title,r.data.updatedAt),r.data.source===`fallback`?W.error(`Could not generate a title; using the message preview`):W.success(`Chat title generated`)}catch(e){$.error(`Failed to generate title:`,e),W.error(`Failed to generate chat title`)}finally{y(null)}},[v,V,y]);(0,Z.useEffect)(()=>{let t=T.current;return()=>{let n=w.current,r=O.current;if(r){let e=!r.jobId;sa(r,t),va(r.sessionId,r.assistantMessageId).then(t=>ae(r.sessionId,r.assistantMessageId,t,{retainForContinuation:e})).catch(e=>$.error(`Failed to cancel durable chat generation:`,e)),r.jobId&&_a(r.jobId).catch(e=>$.error(`Failed to cancel durable chat generation:`,e)),O.current=null}n&&e&&!r&&K.send({type:`chat_cancel`,data:{sessionId:e,assistantMessageId:n}}),K.offMessage(`user_message`),K.offMessage(`assistant_chunk`),K.offMessage(`assistant_complete`),K.offMessage(`assistant_cancelled`),K.offMessage(`tool_status`),K.offMessage(`error`)}},[e,ae]),(0,Z.useEffect)(()=>{if(!e){K.offMessage(`user_message`),K.offMessage(`assistant_chunk`),K.offMessage(`assistant_complete`),K.offMessage(`assistant_cancelled`),K.offMessage(`tool_status`),K.offMessage(`tool_event`),K.offMessage(`error`);return}return K.onMessage(`user_message`,()=>{}),K.onMessage(`assistant_chunk`,t=>{let n=t,r=n.messageId||w.current;r&&T.current.has(r)||r&&w.current&&r!==w.current||r&&(typeof n.total==`string`?N.current=n.total:typeof n.content==`string`&&(N.current+=n.content),typeof n.thinkingTotal==`string`?F.current=n.thinkingTotal:typeof n.thinking==`string`&&(F.current+=n.thinking),na(r,N.current,F.current),re(N.current,n.done,F.current),I.current&&clearTimeout(I.current),I.current=setTimeout(()=>{g(e,r,N.current),ee.current=Date.now()},n.done?0:200))}),K.onMessage(`tool_status`,e=>{let t=e;u(e=>e.find(e=>e.toolCallId===t.toolCallId)?e.map(e=>e.toolCallId===t.toolCallId?{...e,phase:t.phase}:e):[...e,{toolCallId:t.toolCallId,name:t.name,phase:t.phase,startedAt:Date.now()}])}),K.onMessage(`tool_event`,e=>{let t=e;if(!(!t.type||!t.messageId)&&!(w.current&&t.messageId!==w.current)){if(t.type===`chat.tool-call.v1`&&t.toolCall){let e=t.toolCall;f(t=>t.find(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e]);return}if(t.type===`chat.tool-result.v1`&&t.toolCallId){f(e=>e.map(e=>e.id===t.toolCallId?{...e,status:t.status??e.status,resultPreview:t.preview,isError:t.isError===!0,finishedAt:Date.now()}:e)),m(e=>e&&e.toolCall.id===t.toolCallId?null:e);return}if(t.type===`chat.approval.v1`&&t.approvalId&&t.toolCall){let e=t.toolCall;f(t=>t.find(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e]),m({approvalId:t.approvalId,messageId:t.messageId,toolCall:e,expiresAt:t.expiresAt??Date.now()+12e4})}}}),K.onMessage(`assistant_complete`,t=>{let n=t;$.debug(`Hook: Received assistant_complete for session:`,e,`messageId:`,n.messageId,`with statistics:`,!!n.statistics);let r=n.messageId||w.current,i=!r||r===w.current;if(r&&T.current.delete(r),!i){if(n.truncated&&r){B(e,r);return}r&&_(e,r,n.content,n.statistics,n.providerMetadata,n.thinking);return}if(c(!1),z(),x(!1),u([]),f([]),m(null),n&&r){let t=N.current||n.content,i=F.current||n.thinking,a=ia(r),o=n.statistics?.thinking_duration_ms===void 0&&a!==void 0?{...n.statistics,thinking_duration_ms:a}:n.statistics;_(e,r,t,o,n.providerMetadata,i)}oe(e),w.current=null,N.current=``,F.current=``,window.setTimeout(()=>{S.current?.()},0),I.current&&clearTimeout(I.current),ee.current=0}),K.onMessage(`assistant_cancelled`,t=>{let n=t,r=n.assistantMessageId;!r||n.sessionId!==e||T.current.has(r)&&(T.current.delete(r),b(e,r),w.current===r&&(c(!1),z(),o(null),x(!1),u([]),f([]),m(null),w.current=null,N.current=``,F.current=``))}),K.onMessage(`error`,e=>{let t=e;if(c(!1),z(),x(!1),f([]),m(null),w.current=null,F.current=``,t.code===`SESSION_NOT_FOUND`){$.warn(`Session not found, redirecting to create new session...`),W.error(`Session not found. Creating a new session...`),window.location.href=`/`;return}W.error(t.error),V()}),c(!1),z(),w.current=null,F.current=``,()=>{I.current&&clearTimeout(I.current),R()}},[e,g,_,x,re,z,R,oe,V,b,B]);let se=(0,Z.useCallback)(async(t,n,r,i,a,s,l)=>{if(!e||!t.trim()&&(!n||n.length===0))return;let u;try{let d=P.getState(),p=d.currentSession,_={model:p?.personaId?`persona:${p.personaId}`:p?.model||``,providerType:p?.providerType,providerId:p?.providerId};if(!M(d.models,_)){W.error(`Select an available model before sending`);return}x(!0),c(!0),z(),f([]),m(null),N.current=``,F.current=``,I.current&&clearTimeout(I.current),ee.current=Date.now();let v=p?.isPrivate===!0,y=p?.messages?.some(e=>e.role===`user`);!v&&!y&&ba(p?.title)?(k.current=t.trim(),A.current=!0,j.current=e):(k.current=null,A.current=!1,j.current=null);let b=E();h(e,{id:b,role:`user`,content:t.trim(),images:n});let S=E();if(u=S,w.current=S,F.current=``,o(S),h(e,{role:`assistant`,content:``,id:S}),ut()){let n=`Demo response for: ${t.trim()}`;D.current=window.setTimeout(()=>{D.current=null,!T.current.has(S)&&(g(e,S,n),c(!1),z(),o(null),x(!1),oe(e),w.current=null,N.current=``,F.current=``)},500);return}if(!v){let o=new AbortController,c={sessionId:e,assistantMessageId:S,abort:o};O.current=c;let u=await ua(c,await ma({sessionId:e,message:t.trim(),images:n,userMessageId:b,assistantMessageId:S,options:{...p?.settings?.generationOptions??{},...r===void 0?{}:{format:r}},webSearch:i===!0,tools:a===!0,...a===!0&&s?{toolSelection:s}:{},signal:o.signal}));if(u!==`stream`){await ae(e,S,{completed:u===`completed`,pending:!1,state:u===`completed`?`succeeded`:`cancelled`}),O.current===c&&(O.current=null);return}for(let i of l??[]){let a=E(),o=new AbortController;C.current.set(a,o),P.getState().addPendingComparison({sessionId:e,assistantMessageId:a,model:i.model}),(async()=>{try{await ma({sessionId:e,message:t.trim(),images:n,userMessageId:b,assistantMessageId:a,options:{...p?.settings?.generationOptions??{},...r===void 0?{}:{format:r}},webSearch:!1,compare:!0,modelOverride:i,signal:o.signal}),await ga({sessionId:e,assistantMessageId:a,signal:o.signal,onEvent:t=>{t.type===`done`?B(e,a):t.type===`error`&&W.error(`${i.model}: ${String(t.error??`generation failed`)}`)}})}catch(e){o.signal.aborted||($.error(`Comparison generation failed:`,e),W.error(`${i.model}: ${e instanceof Error?e.message:`comparison failed`}`))}finally{C.current.delete(a),P.getState().removePendingComparison(a)}})()}await ga({sessionId:e,assistantMessageId:S,signal:o.signal,onEvent:t=>{t.type===`chunk`?K.dispatchMessage(`assistant_chunk`,t):t.type===`done`?K.dispatchMessage(`assistant_complete`,t):typeof t.type==`string`&&(t.type.startsWith(`chat.tool`)||t.type.startsWith(`chat.approval`))?K.dispatchMessage(`tool_event`,t):t.type===`error`&&K.dispatchMessage(`error`,{...t,sessionId:e})}}),O.current?.assistantMessageId===S&&(O.current=null);return}K.isConnected||await K.connect();let L=v?p?.messages?.filter(e=>e.role!==`system`&&e.id!==S).map(e=>({role:e.role,content:e.content,thinking:e.thinking,images:e.images,providerMetadata:e.providerMetadata})):void 0;K.send({type:`chat_stream`,data:{sessionId:e,content:t.trim(),images:n,format:r,options:p?.settings?.generationOptions??{},assistantMessageId:S,isPrivate:v,...i===!0?{webSearch:!0}:{},...a===!0&&!v?{tools:!0}:{},...a===!0&&!v&&s?{toolSelection:s}:{},...v?{model:p?.model,providerType:p?.providerType,providerId:p?.providerId,messageHistory:L}:{}}})}catch(t){let n=u;if(n&&await ca({sessionId:e,assistantMessageId:n,cancelledMessageIds:T.current,settle:t=>ae(e,n,t),onError:e=>$.error(`Failed to resolve cancelled durable chat generation:`,e)})){O.current?.assistantMessageId===n&&(O.current=null);return}if(t instanceof DOMException&&t.name===`AbortError`)return;$.error(`Failed to send message:`,t),c(!1),z(),o(null),x(!1),w.current=null,F.current=``,W.error(`Failed to send message`)}},[e,h,g,x,z,oe,ae,B]),ce=(0,Z.useCallback)(()=>{let t=w.current;if(t)if(T.current.add(t),D.current!==null)window.clearTimeout(D.current),D.current=null,b(e,t),T.current.delete(t);else if(O.current?.assistantMessageId===t){let n=O.current,r=!n.jobId;sa(n),va(e,t).then(async i=>{await ae(e,t,i,{retainForContinuation:r}),O.current===n&&(O.current=null)}).catch(e=>$.error(`Failed to cancel durable chat generation:`,e)),n.jobId&&_a(n.jobId).catch(e=>$.error(`Failed to cancel durable chat generation:`,e))}else K.send({type:`chat_cancel`,data:{sessionId:e,assistantMessageId:t}})||(b(e,t),T.current.delete(t));I.current&&(clearTimeout(I.current),I.current=void 0),c(!1),z(),o(null),x(!1),w.current=null,N.current=``,F.current=``,V()},[x,z,b,e,V,ae]),le=(0,Z.useCallback)(async()=>{let t=P.getState(),n=t.currentSession;if(!n||!e)return;if(!M(t.models,{model:n.personaId?`persona:${n.personaId}`:n.model,providerType:n.providerType,providerId:n.providerId})){W.error(`Select an available model before regenerating`);return}let r=n.messages,i=-1,a=-1;for(let e=r.length-1;e>=0;e--)if(r[e].role===`assistant`){a=e;break}if(a>0){for(let e=a-1;e>=0;e--)if(r[e].role===`user`){i=e;break}}if(i===-1||a===-1){W.error(`No message to regenerate`);return}let s=r[i],l=r[a],u;try{x(!0),c(!0),z(),N.current=``,F.current=``,I.current&&clearTimeout(I.current),ee.current=Date.now();let t=E();u=t,w.current=t,F.current=``,o(t),h(e,{role:`assistant`,content:``,id:t,parentId:l.parentId||l.id,branchIndex:l.siblingCount||1,isActive:!0});let i=n.isPrivate===!0;if(!i){let r=new AbortController,i={sessionId:e,assistantMessageId:t,abort:r};O.current=i;let a=await ua(i,await ma({sessionId:e,message:s.content,images:s.images,userMessageId:s.id,assistantMessageId:t,options:n.settings?.generationOptions??{},webSearch:!1,regenerate:!0,originalMessageId:l.id,signal:r.signal}));if(a!==`stream`){await ae(e,t,{completed:a===`completed`,pending:!1,state:a===`completed`?`succeeded`:`cancelled`}),O.current===i&&(O.current=null);return}await ga({sessionId:e,assistantMessageId:t,signal:r.signal,onEvent:t=>{t.type===`chunk`?K.dispatchMessage(`assistant_chunk`,t):t.type===`done`?K.dispatchMessage(`assistant_complete`,t):t.type===`error`&&K.dispatchMessage(`error`,{...t,sessionId:e})}}),O.current?.assistantMessageId===t&&(O.current=null);return}K.isConnected||await K.connect();let a=i?r.filter(e=>e.role!==`system`).map(e=>({role:e.role,content:e.content,thinking:e.thinking,images:e.images,providerMetadata:e.providerMetadata})):void 0;K.send({type:`chat_stream`,data:{sessionId:e,content:s.content,images:s.images,options:n.settings?.generationOptions??{},assistantMessageId:t,regenerate:!0,originalMessageId:l.id,isPrivate:i,...i?{model:n.model,providerType:n.providerType,providerId:n.providerId,messageHistory:a}:{}}})}catch(t){let n=u;if(n&&await ca({sessionId:e,assistantMessageId:n,cancelledMessageIds:T.current,settle:t=>ae(e,n,t),onError:e=>$.error(`Failed to resolve cancelled durable chat regeneration:`,e)})){O.current?.assistantMessageId===n&&(O.current=null);return}$.error(`Failed to regenerate message:`,t),n&&b(e,n);try{let t=await gt.getSession(e);t.success&&t.data&&ie(t.data)}catch(e){$.error(`Failed to reload session after regenerate:`,e)}c(!1),z(),o(null),x(!1),w.current=null,F.current=``,W.error(`Failed to regenerate message`)}},[e,x,z,h,b,ie,ae]),ue=(0,Z.useCallback)(async t=>{let n=P.getState().currentSession;if(!n||!e)return;let r=n.messages.find(e=>e.id===t);if(!r){W.error(`Message not found`);return}if(r.isActive!==!1)return;let i=r.parentId||r.id,a=r.branchIndex||0;try{let r=await gt.switchMessageBranch(e,t,a);if(r.success&&r.data){let r=n.messages.map(e=>e.id===i||e.parentId===i?{...e,isActive:e.id===t}:e),o={...n,messages:r,updatedAt:Date.now()};P.setState(t=>({sessions:t.sessions.map(t=>t.id===e?o:t),currentSession:o})),W.success(`Switched to variant ${a+1}`)}else W.error(r.error||`Failed to select branch`)}catch(e){$.error(`Failed to select branch:`,e),W.error(`Failed to select branch`)}},[e]),de=(0,Z.useCallback)(async(t,n)=>{if(!e||!n.trim())return;let r=P.getState(),i=r.currentSession;if(!i||i.id!==e)return;let a=i.messages.findIndex(e=>e.id===t);if(a===-1||i.messages[a].role!==`user`)return;let o=i.messages[a];try{if(!i.isPrivate){let n=await gt.truncateMessagesFrom(e,t);if(!n.success)throw Error(n.error||`Failed to truncate session`)}r.truncateMessagesFrom(e,t),await se(n,o.images)}catch(e){$.error(`Failed to edit message:`,e),W.error(`Failed to edit message`)}},[e,se]),fe=(0,Z.useCallback)(async(e,t,n)=>{try{await bt.decideApproval(e,t,n),m(t=>t&&t.approvalId===e?null:t)}catch(e){$.error(`Failed to record the tool decision:`,e),W.error(`The tool decision could not be recorded`)}},[]),pe=(0,Z.useCallback)(async()=>{if(!e)return;let t=P.getState().currentSession;if(!t||t.id!==e||t.isPrivate||Et.getState().isGenerating)return;let n=t.settings?.promptQueue;if(!(!n||n.length===0))try{let t=await gt.claimQueuedPrompt(e,n[0].id);if(!t.success||!t.data)return;oa(e,t.data.queue),await se(t.data.entry.content)}catch(e){$.error(`Prompt queue drain failed:`,e)}},[e,se]);return(0,Z.useEffect)(()=>{S.current=pe},[pe]),(0,Z.useEffect)(()=>{if(!e)return;let t=window.setTimeout(()=>{S.current?.()},400);return()=>window.clearTimeout(t)},[e]),{sendMessage:se,stopGeneration:ce,cancelComparison:(0,Z.useCallback)(async t=>{if(e){C.current.get(t)?.abort();try{await va(e,t)}catch(e){$.error(`Failed to cancel the comparison generation:`,e)}finally{P.getState().removePendingComparison(t)}}},[e]),regenerateLastMessage:le,editAndResendMessage:de,selectBranch:ue,isStreaming:s,streamingMessage:t,streamingThinking:r,streamingMessageId:a,toolActivities:l,activeToolCalls:d,pendingToolApproval:p,decideToolApproval:fe}};function Sa(e){let{t}=w(),n=(0,Z.useRef)(null),r=fi({queryKey:[`users`,`pending-approvals`],enabled:e,queryFn:async()=>{let e=await ht.getPendingApprovals();if(!e.success||!e.data)throw Error(e.message||`Could not load pending accounts`);return e.data},refetchInterval:6e4,refetchOnWindowFocus:!0});return(0,Z.useEffect)(()=>{if(!r.data)return;let e=n.current,i=e?!!(r.data.count>e.count||r.data.latestCreatedAt&&r.data.latestCreatedAt!==e.latestCreatedAt):r.data.count>0;n.current=r.data,i&&U(t(`userManager.approval.notification`,{count:r.data.count,defaultValue:`{{count}} registration(s) are waiting for your approval.`}),{icon:`👤`})},[r.data,t]),{...r,pendingApprovalCount:r.data?.count??0}}function Ca(e){let{t}=w(),n=(0,Z.useRef)(null),r=fi({queryKey:[`automations`,`runs-summary`],enabled:e,queryFn:async()=>{let e=await St.getRunsSummary();if(!e.success||!e.data)throw Error(e.error||`Could not load automation runs`);return e.data},refetchInterval:6e4,refetchOnWindowFocus:!0});return(0,Z.useEffect)(()=>{if(!r.data)return;let e=n.current,i=r.data.unseenCount;e!==null&&i>e&&U(t(`automations.finishedNotification`,{n:i}),{icon:`⚡`}),n.current=i},[r.data,t]),{...r,unseenRunCount:r.data?.unseenCount??0}}var wa=dt(`components:sidebar`),Ta=Z.lazy(()=>s(()=>import(`../js/SettingsModal-R9EDadAV.js`).then(e=>({default:e.SettingsModal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]))),Ea=({isOpen:e,onClose:t,className:n})=>{let{t:r}=w(),i=u(),a=d(),{sessions:o,deleteSession:s,updateSessionTitle:c,setSessionArchived:l,setSessionPinned:f,folders:p,loadFolders:m,createFolder:h,renameFolder:g,deleteFolder:_,moveSessionToFolder:v,selectedModel:y,models:b,currentSession:x,generatingTitleForSession:S,personas:C}=P(),T=Tt(e=>e.tasks),E=Tt(e=>e.loadingTasks),D=Tt(e=>e.actionLoading),O=Tt(e=>e.deleteTask),{user:k,isAdmin:j,systemInfo:M,setUser:N,canUseWork:F,canUseAgents:ee}=G(),{backgroundImage:I,sidebarCompact:L,toggleSidebarCompact:te,isGenerating:ne,pinnedAdminShortcuts:R,toggleAdminShortcut:re}=Et(),z=S??(ne&&x&&ba(x.title)?x.id:null),ie=j(),{pendingApprovalCount:B}=Sa(!!(k&&ie&&M?.requiresAuth)),{unseenRunCount:ae}=Ca(!!(k||M?.requiresAuth===!1)),[V,oe]=(0,Z.useState)(null),[se,ce]=(0,Z.useState)(``),[le,ue]=(0,Z.useState)(!1),[de,fe]=(0,Z.useState)(!1),[pe,me]=(0,Z.useState)(!1),[he,ge]=(0,Z.useState)(``),[H,_e]=(0,Z.useState)(!1),ve=(0,Z.useRef)(null),ye=(0,Z.useRef)(null),be=i.pathname.match(/^\/c\/([^/]+)$/)?.[1]||x?.id,xe=()=>{window.innerWidth<768&&!L&&te()},Se=()=>{Ot(`selection`),te()},Ce=()=>{let{setCurrentSession:e}=P.getState();Dt(),e(null),sessionStorage.setItem(`forceWelcomeScreen`,`true`)};(0,Z.useEffect)(()=>{let e=e=>{ve.current&&!ve.current.contains(e.target)&&fe(!1)};if(de)return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[de]),(0,Z.useEffect)(()=>{let t=t=>{ye.current&&!ye.current.contains(t.target)&&window.innerWidth<768&&e&&!L&&te()};if(e&&!L&&window.innerWidth<768)return document.addEventListener(`mousedown`,t),()=>document.removeEventListener(`mousedown`,t)},[e,L,te]);let we=async()=>{_e(!0);try{let e=await ht.updateMyAvatar(he||null);e.success&&e.data?(N(e.data),U.success(r(`user.avatar.updated`)),me(!1)):U.error(e.message||r(`user.avatar.updateFailed`))}catch(e){wa.error(`Failed to update avatar:`,e),U.error(r(`user.avatar.updateFailed`))}finally{_e(!1)}},Te=()=>{Ot(`impact`),Ce(),a(`/chat`,{replace:!0}),xe()},Ee=()=>{Ot(`impact`),Tt.getState().clearError(),a(`/work`),xe()},De=e=>{Ot(`selection`),a(`/c/${e.id}`,{replace:!0}),xe()},Oe=e=>{Ot(`selection`),a(`/work/${e}`,{replace:!0}),xe()},ke=async e=>{if(window.confirm(r(`work.tasks.deleteConfirm`,{defaultValue:`Delete “{{title}}” and its workspace permanently?`,title:e.title||r(`work.tasks.untitled`,{defaultValue:`Untitled task`})}))){Ot(`warning`);try{await O(e.id),wt(e.id),vi.getState().closeTab(`work:${e.id}`),Ve===e.id&&a(`/work`,{replace:!0,state:{deletedWorkTaskId:e.id}})}catch(e){wa.error(`Failed to delete Work task:`,e),U.error(r(`work.toasts.deleteFailed`,{defaultValue:`Could not delete this Work task.`}))}}},Ae=async(e,t)=>{if(t.stopPropagation(),wa.debug(`Delete session clicked:`,e),window.confirm(r(`chat.session.deleteConfirm`))){Ot(`warning`);try{wa.debug(`Attempting to delete session:`,e);let t=be===e;if(await s(e),wa.debug(`Session deleted successfully`),vi.getState().closeTab(`chat:${e}`),t){let t=o.filter(t=>t.id!==e);t.length>0?a(`/c/${t[0].id}`,{replace:!0}):a(`/`,{replace:!0})}}catch(e){wa.error(`Error deleting session:`,e)}}};(0,Z.useEffect)(()=>{m()},[m]);let je=async(e,t)=>{if(t.stopPropagation(),await l(e,!0),vi.getState().closeTab(`chat:${e}`),be===e){let t=o.filter(t=>t.id!==e&&!t.archived);t.length>0?a(`/c/${t[0].id}`,{replace:!0}):a(`/`,{replace:!0})}},Me=(e,t)=>{f(e,t)},Ne=(e,t)=>{t.stopPropagation(),oe(e.id),ce(e.title)},Pe=async e=>{se.trim()&&await c(e,se.trim()),oe(null),ce(``)},Fe=()=>{oe(null),ce(``)},Ie=async()=>{try{await mt.logout();let{logout:e}=G.getState();e(),a(`/login`),U.success(r(`auth.logout.success`))}catch(e){wa.error(`Logout error:`,e);let{logout:t}=G.getState();t(),a(`/login`)}},Le=()=>{ue(!0),xe()},Re=e=>{ge(e),me(!0)},ze=window.location.protocol===`file:`,Be=i.pathname===`/work`||i.pathname.startsWith(`/work/`),Ve=i.pathname.match(/^\/work\/([^/]+)$/)?.[1]||null,He=i.pathname===`/`||i.pathname===`/chat`||i.pathname.startsWith(`/c/`),Ue=F();return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{ref:ye,"data-testid":`sidebar`,className:A(`fixed inset-y-0 start-0 z-50 max-lg:border-e border-black/[0.04] dark:border-white/[0.06] transform transition-[width,transform,background-color] duration-200 ease-out shadow-[0_24px_80px_rgba(15,23,42,0.12)]`,L?`w-16`:`w-72 max-sm:w-[calc(100vw-4.5rem)] max-sm:max-w-80`,e?`translate-x-0`:`ltr:-translate-x-full rtl:translate-x-full`,`lg:shadow-none`,I?`bg-sidebar/75 backdrop-blur-xl`:`bg-sidebar`,`overscroll-behavior-contain`,n),style:{WebkitOverflowScrolling:`touch`},children:[ze&&(0,Q.jsx)(`div`,{className:`absolute top-0 start-16 end-0 h-8 z-[60]`,style:{WebkitAppRegion:`drag`}}),(0,Q.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,Q.jsx)(Oi,{sidebarCompact:L,isElectron:ze,showWork:Ue,activeMode:Be?`work`:He?`chat`:null,selectedModel:y,modelCount:b.length,onToggleCompact:Se,onStartWork:Ee,onCreateSession:Te}),!L&&(0,Q.jsx)(Ai,{sidebarCompact:L,activePath:i.pathname,showAgents:ee(),unseenRunCount:ae,onMobileNavigate:xe}),Be&&Ue?(0,Q.jsx)(ea,{tasks:T,currentTaskId:Ve,loading:E,actionLoading:D,sidebarCompact:L,onSelectTask:Oe,onDeleteTask:e=>void ke(e),onExpandSidebar:Se}):(0,Q.jsx)(Ri,{sessions:o.filter(e=>!e.archived),personas:C,currentSessionId:be,generatingTitleForSession:z,sidebarCompact:L,editingSessionId:V,editingTitle:se,onEditingTitleChange:ce,onSelectSession:De,onStartEditing:Ne,onSaveEdit:Pe,onCancelEdit:Fe,onDeleteSession:Ae,onArchiveSession:je,onTogglePinSession:Me,folders:p,onCreateFolder:e=>void h(e),onRenameFolder:(e,t)=>void g(e,t),onDeleteFolder:e=>void _(e),onMoveSession:(e,t)=>void v(e,t),onExpandSidebar:Se}),(0,Q.jsx)(Ji,{sidebarCompact:L}),(0,Q.jsx)(Vi,{requiresAuth:M?.requiresAuth,user:k,isAdmin:ie,pendingApprovalCount:B,sidebarCompact:L,userMenuOpen:de,userMenuRef:ve,pinnedShortcuts:R,onToggleShortcutPin:re,onToggleUserMenu:()=>fe(e=>!e),onOpenSettings:Le,onOpenAvatar:Re,onLogout:Ie,onMobileNavigate:xe,onCloseUserMenu:()=>fe(!1)})]})]}),le&&(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(Ta,{isOpen:le,onClose:()=>ue(!1)})}),(0,Q.jsx)(Si,{open:pe,value:he,saving:H,onChange:ge,onClose:()=>me(!1),onSave:we})]})},Da=({children:e,requireAuth:t=!0,requireAdmin:n=!1,requireWork:r=!1,requireAgents:i=!1})=>{let{isAuthenticated:a,user:o,systemInfo:s,isLoading:c,canUseWork:l}=G();return u(),c?(0,Q.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gray-50 dark:bg-dark-50`,children:(0,Q.jsx)(`div`,{className:`w-8 h-8 border-4 border-gray-200 dark:border-dark-300 border-t-primary-500 dark:border-t-primary-400 rounded-full animate-spin`})}):i&&s?.agentsEnabled!==!0?(0,Q.jsx)(_,{to:`/`,replace:!0}):s&&!s.requiresAuth?(0,Q.jsx)(Q.Fragment,{children:e}):t&&!a?(0,Q.jsx)(_,{to:`/login`,replace:!0}):n&&(!o||o.role!==`admin`)||r&&!l()?(0,Q.jsx)(_,{to:`/`,replace:!0}):(0,Q.jsx)(Q.Fragment,{children:e})},Oa=dt(`components:error-boundary`),ka=({error:e})=>{let{t}=w();return(0,Q.jsx)(`div`,{className:`min-h-screen bg-gray-50 dark:bg-dark-50 flex items-center justify-center p-4 text-gray-900 dark:text-dark-800`,children:(0,Q.jsx)(`div`,{className:`w-full max-w-md rounded-2xl border border-gray-200 dark:border-dark-300 bg-white/95 dark:bg-dark-100/95 shadow-card backdrop-blur-sm`,children:(0,Q.jsxs)(`div`,{className:`p-6 text-center`,children:[(0,Q.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-2xl bg-primary-100 text-primary-700 dark:bg-primary-900/35 dark:text-primary-300 ring-1 ring-primary-200 dark:ring-primary-800/60`,children:(0,Q.jsx)(Ue,{className:`h-6 w-6`})}),(0,Q.jsx)(`h1`,{className:`mb-2 text-xl font-semibold text-gray-950 dark:text-dark-950`,children:t(`errorBoundary.title`)}),(0,Q.jsx)(`p`,{className:`mb-5 text-sm leading-6 text-gray-600 dark:text-dark-600`,children:t(`errorBoundary.description`)}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:justify-center`,children:[(0,Q.jsxs)(`button`,{onClick:()=>window.location.reload(),className:`inline-flex items-center justify-center gap-2 rounded-xl bg-primary-600 px-4 py-2.5 text-sm font-medium text-white shadow-sm transition-all hover:bg-primary-700 hover:shadow-md focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 dark:focus:ring-offset-dark-100`,children:[(0,Q.jsx)(de,{className:`h-4 w-4`}),t(`errorBoundary.tryAgain`)]}),(0,Q.jsxs)(`button`,{onClick:()=>{window.location.assign(`/`)},className:`inline-flex items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white px-4 py-2.5 text-sm font-medium text-gray-700 shadow-sm transition-all hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 dark:border-dark-300 dark:bg-dark-50 dark:text-dark-700 dark:hover:bg-dark-200 dark:focus:ring-offset-dark-100`,children:[(0,Q.jsx)(he,{className:`h-4 w-4`}),t(`common.home`,`Home`)]})]}),!1]})})})},Aa=()=>{let e=h();(0,Z.useEffect)(()=>{Oa.error(`Route error screen caught an error:`,e)},[e]);let t=e instanceof Error?e:p(e)?Error(`${e.status} ${e.statusText}`):Error(String(e));return(0,Q.jsx)(ka,{error:t})},ja=class extends Z.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){Oa.error(`ErrorBoundary caught an error:`,e,t)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:(0,Q.jsx)(ka,{error:this.state.error}):this.props.children}},Ma=({notes:e,onDismiss:t})=>{let{t:n}=w();return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`fixed inset-0 z-[60] bg-black/55 backdrop-blur-sm transition-opacity duration-200`,onClick:t}),(0,Q.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center p-4`,role:`dialog`,"aria-modal":`true`,"aria-label":n(`whatsNew.title`),onMouseDown:e=>{e.target===e.currentTarget&&t()},children:(0,Q.jsxs)(`div`,{className:`flex max-h-[82vh] w-full max-w-2xl flex-col rounded-3xl border border-gray-200/80 bg-surface/95 shadow-2xl backdrop-blur-xl animate-scale-in dark:border-white/10 dark:bg-dark-25/95`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between px-6 pb-3 pt-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-xl font-semibold tracking-[-0.02em] text-gray-950 dark:text-dark-950`,children:n(`whatsNew.title`)}),(0,Q.jsxs)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:[n(`whatsNew.releaseNotes`),` · v`,e.version,` · `,e.date]})]}),(0,Q.jsx)(`button`,{onClick:t,className:`rounded-full p-2 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-900 dark:text-dark-600 dark:hover:bg-white/[0.06] dark:hover:text-dark-900`,title:n(`common.close`),children:(0,Q.jsx)(Ye,{className:`h-4 w-4`})})]}),(0,Q.jsx)(`div`,{className:`scroll-region min-h-0 flex-1 overflow-y-auto px-6 py-3 scrollbar-thin`,children:(0,Q.jsx)(r,{components:{h3:({children:e})=>(0,Q.jsx)(`h3`,{className:`mb-2 mt-5 text-[11px] font-semibold uppercase tracking-[0.1em] text-primary-600 first:mt-0 dark:text-primary-400`,children:e}),ul:({children:e})=>(0,Q.jsx)(`ul`,{className:`space-y-2.5`,children:e}),li:({children:e})=>(0,Q.jsxs)(`li`,{className:`flex gap-2 text-[13.5px] leading-relaxed text-gray-700 dark:text-dark-700`,children:[(0,Q.jsx)(`span`,{className:`mt-[7px] h-1 w-1 shrink-0 rounded-full bg-gray-300 dark:bg-dark-400`}),(0,Q.jsx)(`span`,{className:`min-w-0`,children:e})]}),strong:({children:e})=>(0,Q.jsx)(`strong`,{className:`font-semibold text-gray-900 dark:text-dark-900`,children:e}),a:({children:e,href:t})=>(0,Q.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`text-primary-600 underline decoration-primary-300 underline-offset-2 hover:text-primary-700 dark:text-primary-400`,children:e}),code:({children:e})=>(0,Q.jsx)(`code`,{className:`rounded-md border border-gray-200 bg-gray-100 px-1 py-0.5 font-mono text-[0.85em] text-gray-800 dark:border-dark-300 dark:bg-dark-200 dark:text-dark-800`,children:e}),p:({children:e})=>(0,Q.jsx)(`p`,{className:`mb-2 text-[13.5px] leading-relaxed text-gray-700 dark:text-dark-700`,children:e})},children:e.body})}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-gray-200/70 px-6 py-4 dark:border-white/[0.08]`,children:[(0,Q.jsxs)(`a`,{href:`https://github.com/libre-webui/libre-webui`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex min-w-0 items-center gap-1.5 text-xs text-gray-500 transition-colors hover:text-gray-900 dark:text-dark-500 dark:hover:text-dark-900`,children:[(0,Q.jsx)(rt,{className:`h-3.5 w-3.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate`,children:n(`whatsNew.starAsk`)})]}),(0,Q.jsx)(kt,{onClick:t,size:`sm`,children:n(`whatsNew.cta`)})]})]})})]})},Na=`libre-webui:whats-new-seen`;function Pa(){let e={version:`0.26.0`,date:`2026-08-20`,body:`Models that use tools under your approval, retrieval that cites its sources, channels and sharing for teams, hands-free voice conversations, image editing — and the cost controls, evaluations, observability, and high-availability certification to run all of it in production. Everything built since 0.25.0 lands here at once.
|
|
17
|
+
|
|
18
|
+
### ✨ New Features
|
|
19
|
+
|
|
20
|
+
#### Agents and tools
|
|
21
|
+
|
|
22
|
+
- **Models use tools, with your approval.** A chat can now run multiple tool rounds inside a single reply: the model calls a tool, reads the result, and continues — through Ollama and every OpenAI-style provider. Each call is shown as it happens, and side-effecting tools wait for your explicit approval before they run.
|
|
23
|
+
- **Bring your own tools.** Register any OpenAPI service or MCP server as a tool source; its operations become tools the model can call, with per-user credentials and an egress guard between the model and your network. A safe public demo preset is included to try the flow end to end.
|
|
24
|
+
- **Prompts, Skills, and Tools workspaces.** Saved prompts open from a slash menu in the composer; skills are folders of instructions and companion files the model can load on demand — write your own, or import from remote skill stores. All three live in the settings panel with starter templates, beside the model manager.
|
|
25
|
+
- **Knowledge tools with citations.** The model can list and read your documents mid-conversation, and its answers cite the exact source passages they came from.
|
|
26
|
+
|
|
27
|
+
#### Knowledge and chat
|
|
28
|
+
|
|
29
|
+
- **Richer document ingestion.** Word, PowerPoint, and Excel files extract with page, slide, and sheet provenance — with no new native dependencies — and re-uploading an unchanged file is detected instead of re-indexed.
|
|
30
|
+
- **Hybrid retrieval.** Keyword ranking (BM25) fuses with vector similarity, so exact identifiers and rare terms are found even when embeddings miss them. Because content stays encrypted at rest, ranking happens in memory over decrypted candidates the requester is allowed to see — there is deliberately no plaintext index on disk.
|
|
31
|
+
- **Answers cite their sources.** RAG replies carry source citations down to the page or slide, and a chat can attach a document in full-context mode when you want the model to read the whole thing.
|
|
32
|
+
- **Notes grow up.** Revision history with restore, file attachments, pinning, per-user sharing (view or edit), Markdown export, and an AI edit sidebar that previews every proposal as a diff — applying snapshots the previous version first, so any AI edit can be undone. The preview also renders inline SVG and basic HTML, sanitized.
|
|
33
|
+
- **Queue prompts while a reply streams.** Follow-up messages wait in an editable queue and send one at a time when the model finishes.
|
|
34
|
+
- **Ask several models at once.** A comparison fan-out sends the same message to additional models and labels each reply, so you can judge them side by side in the conversation.
|
|
35
|
+
- **Fork a whole chat.** Duplicate a conversation with its full history and provenance recorded, and take the copy in a different direction.
|
|
36
|
+
- **Search everything from the palette.** Cmd-K now searches across your chats, notes, and documents — scoped to what you can access, without a plaintext index.
|
|
37
|
+
- **An OpenAI-compatible API.** \`/v1/chat/completions\` and friends work with scoped API tokens, so existing OpenAI-style clients and SDKs can point at your instance for stateless inference.
|
|
38
|
+
|
|
39
|
+
#### Team collaboration
|
|
40
|
+
|
|
41
|
+
- **Channels.** Public, private, and direct-message channels with threads, reactions, and file attachments — and @model mentions that bring an AI reply into the conversation under the asking member's identity. Delivery rides the same durable event ledger as everything else; the database rows are the truth.
|
|
42
|
+
- **Share nearly anything.** Grant-based sharing for chats, personas, prompts, skills, and knowledge collections, per user, with view or edit roles. Shared knowledge answers retrieval queries for grantees immediately, and revocation is just as immediate.
|
|
43
|
+
- **A notification inbox.** Durable in-app notifications with live delivery, plus signed outgoing webhooks so other systems can react to events — envelopes are redacted and retried sensibly.
|
|
44
|
+
- **Calendars for more than one person.** Share a calendar with view or write access, color-code several of them, import and export ICS, and get single-fire reminders per occurrence. The model gains calendar tools, so an automation or chat can read and write events.
|
|
45
|
+
|
|
46
|
+
#### Voice and media
|
|
47
|
+
|
|
48
|
+
- **Hands-free voice mode.** A turn-based voice conversation: speak, the model answers aloud, and the turn returns to you — with an on-screen overlay showing exactly what state the exchange is in.
|
|
49
|
+
- **Voice governance.** Administrators set access modes for speech-to-text, text-to-speech, voice mode, and voice cloning independently. Saved voices carry a consent lifecycle — consent is recorded, revocable (the receipt is kept), and every transfer of voice data to a provider is receipted.
|
|
50
|
+
- **Edit images, not just generate them.** Inpaint with a mask, edit with an instruction, or composite multiple images — through the same approval and gallery flow as generation.
|
|
51
|
+
- **The gallery cleans up after itself.** An optional retention sweep removes old generated media, and long-running media jobs notify you when they finish.
|
|
52
|
+
|
|
53
|
+
#### Running it in production
|
|
54
|
+
|
|
55
|
+
- **Costs and budgets.** Versioned per-model tariffs price real usage, a cost analytics view breaks spending down, and hard budgets stop generation when a period's limit is reached — with alert notifications on the way there.
|
|
56
|
+
- **An evaluation platform.** Thumbs feedback on replies, blind arena battles between models with an Elo leaderboard computed from votes, and repeatable evaluation runs over saved sets — all admin-managed.
|
|
57
|
+
- **Observability you can plug in.** Structured JSON logs with request correlation ids and secret redaction, and an opt-in OpenTelemetry export speaking OTLP/HTTP with zero new dependencies — spans cover HTTP requests and durable jobs.
|
|
58
|
+
- **Certified high availability.** The Helm chart supports referencing an existing Secret instead of inlining credentials, ships optional NetworkPolicies for app and workers, and the three-replica failover drill that gates releases is now documented as the HA certification.
|
|
59
|
+
|
|
60
|
+
### 🔧 Improvements
|
|
61
|
+
|
|
62
|
+
- The Prompts, Skills, Tools, and Model Manager surfaces live inside the settings panel, reachable from the command palette.
|
|
63
|
+
- Every document picker shares one upload accept contract, so the accepted file types are identical everywhere and pinned by test.
|
|
64
|
+
- The frontend clears every react-hooks lint warning — imperative engines (like the voice controller) now live outside components by design.
|
|
65
|
+
- Schema migrations (SQLite v16–v20, PostgreSQL v15–v19) create the agents, notes, team, and media/enterprise tables; applied automatically on upgrade.
|
|
66
|
+
|
|
67
|
+
### 🐛 Bug Fixes
|
|
68
|
+
|
|
69
|
+
- **Lexical retrieval stops admitting junk.** A candidate must fully contain every part of at least one query word — compound identifiers no longer let two shared fragments smuggle an irrelevant chunk through rank fusion.
|
|
70
|
+
- **The v18 migration applies cleanly on upgraded databases.** A preflight check misread an index on a pre-existing table as missing schema and blocked the team migration.
|
|
71
|
+
- **Composer menus tell the truth.** Slash and skill menus work on the welcome screen, stay live while typing, and the tool picker reflects what is actually enabled.
|
|
72
|
+
|
|
73
|
+
### 🌍 Translations
|
|
74
|
+
|
|
75
|
+
- All new interface text across the agent, knowledge, team, voice, media, and operations surfaces — roughly 350 new keys — is translated in all 25 languages.
|
|
76
|
+
|
|
77
|
+
### 📚 Documentation
|
|
78
|
+
|
|
79
|
+
- New guides for tools and the tool gateway, skills, prompts, sharing, channels, notifications, team calendars, voice governance, image editing, costs and budgets, evaluations, observability, and the high-availability certification — plus worked examples for every tool, and honest boundary pages for what each system deliberately does not do yet.`},[t,n]=(0,Z.useState)(()=>{if(!e||typeof window>`u`)return!1;try{return window.localStorage.getItem(Na)!==e.version}catch{return!1}});return(0,Z.useEffect)(()=>{let e=()=>n(!0);return window.addEventListener(`libre:open-whats-new`,e),()=>window.removeEventListener(`libre:open-whats-new`,e)},[]),{open:t,dismiss:()=>{if(n(!1),e)try{window.localStorage.setItem(Na,e.version)}catch{}},notes:e}}var Fa=({message:e=`This is a demo version for presentation purposes only. The Ollama backend is not connected.`,onDismiss:t,className:n})=>{let[r,i]=(0,Z.useState)(!1),{t:a}=w();return r?null:(0,Q.jsx)(`div`,{className:A(`bg-gray-950 text-white dark:bg-white dark:text-gray-950`,`border-b border-black/10 dark:border-white/10`,`px-4 py-2`,n),children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between max-w-6xl mx-auto gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[(0,Q.jsx)(`div`,{className:`flex-shrink-0`,children:(0,Q.jsx)(ve,{className:`h-4 w-4 text-white/65 dark:text-gray-950/60`})}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,Q.jsx)(`p`,{className:`shrink-0 text-xs font-semibold tracking-wide`,children:a(`demoMode.title`)}),(0,Q.jsx)(`p`,{className:`hidden truncate text-xs text-white/60 dark:text-gray-950/60 sm:block`,children:e})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 ml-4`,children:[(0,Q.jsxs)(kt,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-white/70 hover:bg-white/10 hover:text-white dark:text-gray-950/70 dark:hover:bg-black/[0.06] dark:hover:text-gray-950`,onClick:()=>window.open(`https://github.com/libre-webui/libre-webui`,`_blank`),title:`View on GitHub`,children:[(0,Q.jsx)(Qe,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`ml-1 hidden sm:inline`,children:a(`demoMode.github`)})]}),(0,Q.jsx)(kt,{variant:`ghost`,size:`sm`,onClick:()=>{i(!0),t?.()},className:`h-8 w-8 p-0 text-white/70 hover:bg-white/10 hover:text-white dark:text-gray-950/70 dark:hover:bg-black/[0.06] dark:hover:text-gray-950`,title:`Dismiss`,children:(0,Q.jsx)(Ye,{className:`h-4 w-4`})})]})]})})},Ia=()=>{let{preferences:e,backgroundImage:t}=Et(),n=e.backgroundSettings||{enabled:!1,imageUrl:``,blurAmount:10,opacity:.6},r=t||n.imageUrl;return!n.enabled||!r?null:(0,Q.jsx)(`div`,{"data-testid":`app-background`,className:`fixed inset-0 pointer-events-none z-0`,style:{backgroundImage:`url(${r})`,backgroundSize:`cover`,backgroundPosition:`center`,backgroundRepeat:`no-repeat`,filter:`blur(${n.blurAmount}px)`,opacity:n.opacity,transform:`scale(1.1)`}})},La=e=>{Dt(),P.getState().setCurrentSession(null),sessionStorage.setItem(`forceWelcomeScreen`,`true`),e(`/chat`)},Ra=e=>{Dt(),P.getState().setCurrentSession(null),sessionStorage.removeItem(`pendingMessage`),sessionStorage.setItem(`forceWelcomeScreen`,`true`),e(`/chat?incognito=1`)},za=e=>{Tt.getState().clearError(),e(`/work`)},Ba={"/notes":{icon:qe,labelKey:`sidebar.navigation.notes`},"/calendar":{icon:Se,labelKey:`sidebar.navigation.calendar`},"/automations":{icon:tt,labelKey:`sidebar.navigation.automations`},"/channels":{icon:Ae,labelKey:`sidebar.navigation.channels`},"/personas":{icon:Pe,labelKey:`sidebar.navigation.personas`},"/gallery":{icon:Ge,labelKey:`sidebar.navigation.imagine`},"/agents":{icon:Te,labelKey:`sidebar.navigation.agents`},"/users":{icon:et,labelKey:`sidebar.navigation.userManagement`},"/usage":{icon:Ce,labelKey:`usageAnalytics.title`},"/system":{icon:at,labelKey:`systemPage.title`},"/artifacts":{icon:Ie,labelKey:`tabs.artifacts`}},Va=e=>e.kind===`home`?he:e.kind===`chat`?nt:e.kind===`work`?V:Ba[e.path]?.icon??Ie,Ha=()=>T()?`⌘`:`Ctrl`,Ua=new Set([`/agents`,`/users`,`/usage`,`/system`]),Wa=(e,t)=>e.kind===`work`?!t:Ua.has(e.path),Ga=()=>{let{t:e}=w(),t=u(),n=d(),r=vi(e=>e.tabs),i=vi(e=>e.activeTabId),a=vi(e=>e.syncWithPath),o=vi(e=>e.closeTab),s=vi(e=>e.closeTabs),c=P(e=>e.sessions),l=P(e=>e.currentSession),f=Tt(e=>e.tasks),{systemInfo:p,isAdmin:m,canUseWork:h,canUseAgents:g}=G(),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(null),C=(0,Z.useRef)(null),T=(0,Z.useRef)(null),E=(0,Z.useRef)(null),D=(0,Z.useRef)(null),O=(0,Z.useRef)(null),k=m(),j=p?.requiresAuth===!1||k,M=h(),N=j?r:r.filter(e=>!Wa(e,M));(0,Z.useEffect)(()=>{a(t.pathname)},[t.pathname,a]),(0,Z.useEffect)(()=>{(O.current?.querySelector(`[data-active="true"]`))?.scrollIntoView({block:`nearest`,inline:`nearest`})},[N.length,i]),(0,Z.useEffect)(()=>{if(!p||j)return;let e=r.filter(e=>Wa(e,M)).map(e=>e.id);if(e.length===0)return;let t=s(e,`home`);t&&n(t.path,{replace:!0})},[s,n,j,M,p,r]),(0,Z.useEffect)(()=>{if(!_&&!x)return;let e=e=>{let t=e.target;!C.current?.contains(t)&&!T.current?.contains(t)&&!D.current?.contains(t)&&(v(!1),S(null))},t=e=>{e.key===`Escape`&&(v(!1),S(null))};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[x,_]),(0,Z.useEffect)(()=>{if(!_)return;let e=()=>{let e=E.current;if(!e)return;let t=e.getBoundingClientRect(),n=e.closest(`[data-testid="app-shell-content"]`)?.getBoundingClientRect(),r=n?.left??0,i=n?.right??window.innerWidth,a=r+8,o=i-8,s=Math.max(0,Math.min(224,o-a)),c=o-t.left>=s?t.left:t.right-s,l=Math.max(a,Math.min(c,o-s));b({left:l,top:t.bottom+4,width:s})};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[_]),(0,Z.useEffect)(()=>{x&&D.current?.querySelector(`[role="menuitem"]:not(:disabled)`)?.focus()},[x]);let F=t=>{if(t.kind===`home`)return e(`tabs.home`,`Home`);if(t.kind===`chat`){if(t.id===`chat:new`)return l?.isPrivate?e(`chat.session.incognito`,`Incognito Chat`):e(`tabs.newChat`,`New Chat`);let n=t.id.slice(5);return c.find(e=>e.id===n)?.title||e(`tabs.chat`,`Chat`)}if(t.kind===`work`){if(t.id===`work:new`)return e(`tabs.work`,`Work`);let n=t.id.slice(5);return f.find(e=>e.id===n)?.title||e(`tabs.work`,`Work`)}let n=Ba[t.path];return n?e(n.labelKey,t.path.slice(1)):t.path.slice(1)},ee=(e,t)=>{e.stopPropagation(),e.preventDefault();let r=o(t.id);r&&n(r.path)},I=(e,t,n)=>{v(!1),S({tabId:e.id,x:Math.max(8,Math.min(t,window.innerWidth-224-8)),y:Math.max(8,Math.min(n,window.innerHeight-176-8))})},L=(e,t)=>{e.preventDefault(),e.stopPropagation(),I(t,e.clientX,e.clientY)},te=(e,t)=>{if(e.key!==`ContextMenu`&&!(e.shiftKey&&e.key===`F10`))return;e.preventDefault();let n=e.currentTarget.getBoundingClientRect();I(t,n.left+12,n.bottom+4)},ne=e=>{let t=Array.from(D.current?.querySelectorAll(`[role="menuitem"]:not(:disabled)`)??[]);if(t.length===0)return;let n=t.indexOf(document.activeElement),r=n;if(e.key===`ArrowDown`)r=(n+1+t.length)%t.length;else if(e.key===`ArrowUp`)r=(n-1+t.length)%t.length;else if(e.key===`Home`)r=0;else if(e.key===`End`)r=t.length-1;else return;e.preventDefault(),t[r]?.focus()},R=(e,t)=>{let r=s(e,t);S(null),r&&n(r.path)},re=[{key:`chat`,label:e(`tabs.newChat`,`New Chat`),icon:nt,shortcut:`${Ha()}⇧O`,action:()=>La(n)},{key:`incognito-chat`,label:e(`chat.session.incognito`,`Incognito Chat`),icon:Ee,action:()=>Ra(n)},...M?[{key:`work`,label:e(`tabs.newWork`,`New Work`),icon:V,shortcut:`${Ha()}⇧U`,action:()=>za(n)}]:[],...[`/channels`,`/notes`,`/calendar`,`/automations`,`/personas`,`/gallery`].map(t=>({key:t,label:e(Ba[t].labelKey,t.slice(1)),icon:Ba[t].icon,action:()=>n(t)})),...g()?[{key:`/agents`,label:e(Ba[`/agents`].labelKey,`Agents`),icon:Ba[`/agents`].icon,separatorBefore:!0,action:()=>n(`/agents`)}]:[],...k?[`/users`,`/system`,`/usage`].map(t=>({key:t,label:e(Ba[t].labelKey,t.slice(1)),icon:Ba[t].icon,action:()=>n(t)})):[]],z=x?N.find(e=>e.id===x.tabId):void 0,ie=z?N.findIndex(e=>e.id===z.id):-1,B=z?N.filter(e=>e.id!==`home`&&e.id!==z.id).map(e=>e.id):[],oe=ie>=0?N.slice(ie+1).filter(e=>e.id!==`home`).map(e=>e.id):[],se=N.filter(e=>e.id!==`home`).map(e=>e.id);return(0,Q.jsxs)(`div`,{"data-testid":`app-tab-bar`,className:`relative z-20 flex h-9 flex-none items-center gap-1 px-1 pb-1 lg:px-0`,children:[(0,Q.jsx)(`div`,{ref:O,role:`tablist`,"aria-label":e(`tabs.label`,`Open tabs`),className:`flex min-w-0 items-center gap-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:N.map(t=>{let r=t.id===`chat:new`&&l?.isPrivate?Ee:Va(t),a=t.id===i;return(0,Q.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":a,"data-active":a||void 0,"data-tab-id":t.id,"data-testid":`app-tab`,title:F(t),onClick:()=>n(t.path),onContextMenu:e=>L(e,t),onKeyDown:e=>te(e,t),onAuxClick:e=>{e.button===1&&t.id!==`home`&&ee(e,t)},className:A(`group flex h-7 min-w-0 flex-none items-center gap-1.5 rounded-lg border text-[13px] transition-colors duration-150 outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40`,t.id===`home`?`px-2.5`:`ps-2.5 pe-1`,a?`border-black/[0.06] bg-gray-50 text-gray-950 shadow-subtle dark:border-white/[0.07] dark:bg-dark-100 dark:text-dark-950`:`border-transparent text-gray-500 hover:bg-white/60 hover:text-gray-900 dark:text-dark-600 dark:hover:bg-dark-200/60 dark:hover:text-dark-900`),children:[(0,Q.jsx)(r,{className:`h-3.5 w-3.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`max-w-[9rem] truncate`,children:F(t)}),t.id!==`home`&&(0,Q.jsx)(`span`,{role:`button`,tabIndex:-1,"aria-label":e(`tabs.close`,`Close tab`),"data-testid":`app-tab-close`,onClick:e=>ee(e,t),className:A(`flex h-5 w-5 shrink-0 items-center justify-center rounded-md text-gray-400 transition-opacity hover:bg-black/[0.06] hover:text-gray-700 dark:text-dark-500 dark:hover:bg-white/[0.08] dark:hover:text-dark-800`,a?`opacity-100`:`sm:opacity-0 sm:group-hover:opacity-100 sm:group-focus-visible:opacity-100`),children:(0,Q.jsx)(Ye,{className:`h-3 w-3`})})]},t.id)})}),x&&z&&(0,yi.createPortal)((0,Q.jsxs)(`div`,{ref:D,role:`menu`,"aria-label":e(`tabs.actions`,`Tab actions`),"data-testid":`app-tab-context-menu`,onContextMenu:e=>e.preventDefault(),onKeyDown:ne,className:`fixed z-[100] w-56 rounded-xl border border-line bg-surface-overlay/95 p-1 shadow-overlay backdrop-blur-xl animate-fade-in motion-reduce:animate-none`,style:{left:x.x,top:x.y},children:[(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`app-tab-context-close`,disabled:z.id===`home`,onClick:()=>{let e=o(z.id);S(null),e&&n(e.path)},className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-[13px] text-ink-muted transition-colors hover:bg-black/[0.05] hover:text-ink disabled:cursor-not-allowed disabled:opacity-40 dark:hover:bg-white/[0.06]`,children:[(0,Q.jsx)(Ye,{className:`h-4 w-4 shrink-0`}),(0,Q.jsx)(`span`,{children:e(`tabs.close`,`Close tab`)})]}),(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`app-tab-context-close-others`,disabled:B.length===0,onClick:()=>R(B,z.id),className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-[13px] text-ink-muted transition-colors hover:bg-black/[0.05] hover:text-ink disabled:cursor-not-allowed disabled:opacity-40 dark:hover:bg-white/[0.06]`,children:[(0,Q.jsx)(ae,{className:`h-4 w-4 shrink-0`}),(0,Q.jsx)(`span`,{children:e(`tabs.closeOthers`,`Close other tabs`)})]}),(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`app-tab-context-close-right`,disabled:oe.length===0,onClick:()=>R(oe,z.id),className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-[13px] text-ink-muted transition-colors hover:bg-black/[0.05] hover:text-ink disabled:cursor-not-allowed disabled:opacity-40 dark:hover:bg-white/[0.06]`,children:[(0,Q.jsx)(Ne,{className:`h-4 w-4 shrink-0`}),(0,Q.jsx)(`span`,{children:e(`tabs.closeRight`,`Close tabs to the right`)})]}),(0,Q.jsx)(`div`,{className:`mx-2 my-1 h-px bg-line`,role:`separator`}),(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`app-tab-context-close-all`,disabled:se.length===0,onClick:()=>R(se,`home`),className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-[13px] text-ink-muted transition-colors hover:bg-black/[0.05] hover:text-ink disabled:cursor-not-allowed disabled:opacity-40 dark:hover:bg-white/[0.06]`,children:[(0,Q.jsx)(_e,{className:`h-4 w-4 shrink-0`}),(0,Q.jsx)(`span`,{children:e(`tabs.closeAll`,`Close all tabs`)})]})]}),document.body),(0,Q.jsxs)(`div`,{className:`relative flex-none`,ref:C,children:[(0,Q.jsx)(`button`,{ref:E,type:`button`,"aria-label":e(`tabs.new`,`New tab`),"aria-expanded":_,"data-testid":`app-tab-new`,onClick:()=>v(e=>!e),className:`flex h-7 w-7 items-center justify-center rounded-lg text-gray-500 transition-colors hover:bg-white/60 hover:text-gray-900 dark:text-dark-600 dark:hover:bg-dark-200/60 dark:hover:text-dark-900 outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40`,children:(0,Q.jsx)(we,{className:`h-4 w-4`})}),_&&y&&(0,yi.createPortal)((0,Q.jsx)(`div`,{ref:T,role:`menu`,"data-testid":`app-tab-new-menu`,className:`fixed z-[100] max-h-[calc(100dvh-4rem)] overflow-y-auto rounded-xl border border-line bg-surface-overlay/95 p-1 shadow-overlay backdrop-blur-xl animate-fade-in motion-reduce:animate-none`,style:y,children:re.map(e=>(0,Q.jsxs)(Z.Fragment,{children:[e.separatorBefore&&(0,Q.jsx)(`div`,{className:`mx-2 my-1 h-px bg-line`,role:`separator`}),(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{v(!1),e.action()},className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-[13px] text-ink-muted transition-colors hover:bg-black/[0.05] hover:text-ink dark:hover:bg-white/[0.06]`,children:[(0,Q.jsx)(e.icon,{className:`h-4 w-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-start`,children:e.label}),e.shortcut&&(0,Q.jsx)(`span`,{className:`font-mono text-[10px] tracking-wide text-ink-subtle`,children:e.shortcut})]})]},e.key))}),document.body)]})]})},Ka=24;function qa(e,t){let n=e.toLowerCase(),r=t.toLowerCase();if(!n)return{score:0,ranges:[]};let i=r.indexOf(n);if(i!==-1)return{score:100+(i===0||/[\s\-_/.]/.test(r[i-1])?40:0)-Math.min(i,20)-Math.min(r.length-n.length,10)/10,ranges:[[i,i+n.length]]};let a=[],o=0,s=0;for(let e=0;e<n.length;e++){let t=r.indexOf(n[e],s);if(t===-1)return null;let i=a.length>0&&t===s,c=t===0||/[\s\-_/.]/.test(r[t-1]);o+=2+(i?4:0)+(c?6:0),i||(o-=Math.min(t-s,6)/2);let l=a[a.length-1];l&&l[1]===t?l[1]=t+1:a.push([t,t+1]),s=t+1}return{score:o,ranges:a}}function Ja({text:e,ranges:t}){if(t.length===0)return(0,Q.jsx)(Q.Fragment,{children:e});let n=[],r=0;return t.forEach(([t,i],a)=>{t>r&&n.push(e.slice(r,t)),n.push((0,Q.jsx)(`span`,{className:`font-semibold text-ink`,children:e.slice(t,i)},a)),r=i}),r<e.length&&n.push(e.slice(r)),(0,Q.jsx)(Q.Fragment,{children:n})}var Ya=({onOpenSettings:e,onOpenSettingsTab:t})=>{let{t:n,i18n:r}=w(),i=d(),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(0),f=(0,Z.useRef)(null),p=(0,Z.useRef)(null),m=P(e=>e.sessions),h=Tt(e=>e.tasks),g=Et(e=>e.toggleTheme),{canUseWork:_,canUseAgents:v}=G(),y=_(),b=v(),x=T()?`⌘`:`Ctrl`;(0,Z.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),c(``),u(0),o(e=>!e))},t=()=>{c(``),u(0),o(!0)};return document.addEventListener(`keydown`,e,!0),window.addEventListener(`libre:open-palette`,t),()=>{document.removeEventListener(`keydown`,e,!0),window.removeEventListener(`libre:open-palette`,t)}},[]),(0,Z.useEffect)(()=>{if(!a)return;let e=window.requestAnimationFrame(()=>f.current?.focus());return()=>window.cancelAnimationFrame(e)},[a]);let S=(0,Z.useCallback)(()=>o(!1),[]),[C,E]=(0,Z.useState)(null);C!==null&&(!a||s.trim().length<3)&&E(null),(0,Z.useEffect)(()=>{let e=s.trim();if(!a||e.length<3)return;let t=!1,n=window.setTimeout(()=>{pt.searchApp(e).then(e=>{!t&&e.success&&e.data&&E(e.data)}).catch(()=>{})},300);return()=>{t=!0,window.clearTimeout(n)}},[s,a]);let D=(0,Z.useMemo)(()=>{let a=n(`palette.actions`,`Actions`),o=[{id:`action:new-chat`,section:a,label:n(`tabs.newChat`,`New Chat`),icon:nt,hint:`${x}⇧O`,keywords:`new chat conversation start`,run:()=>La(i)},{id:`action:incognito-chat`,section:a,label:n(`chat.session.incognito`,`Incognito Chat`),icon:Ee,keywords:`incognito private temporary ghost`,run:()=>Ra(i)},...y?[{id:`action:new-work`,section:a,label:n(`tabs.newWork`,`New Work`),icon:V,hint:`${x}⇧U`,keywords:`new work task workspace`,run:()=>za(i)}]:[],{id:`action:home`,section:a,label:n(`tabs.home`,`Home`),icon:he,run:()=>i(`/`)},{id:`action:models`,section:a,label:n(`sidebar.navigation.models`,`Models`),icon:ke,keywords:`models ollama providers llm`,run:()=>t(`model-manager`)},{id:`action:personas`,section:a,label:n(`sidebar.navigation.personas`,`Personas`),icon:Pe,run:()=>i(`/personas`)},{id:`action:gallery`,section:a,label:n(`sidebar.navigation.imagine`,`Imagine`),icon:Ge,keywords:`imagine images generation gallery pictures`,run:()=>i(`/gallery`)},{id:`action:calendar`,section:a,label:n(`sidebar.navigation.calendar`,`Calendar`),icon:Se,keywords:`calendar events schedule agenda`,run:()=>i(`/calendar`)},{id:`action:channels`,section:a,label:n(`sidebar.navigation.channels`,`Channels`),icon:Ae,keywords:`channels team messages dm direct chat rooms`,run:()=>i(`/channels`)},{id:`action:automations`,section:a,label:n(`sidebar.navigation.automations`,`Automations`),icon:tt,keywords:`automations schedule cron recurring routines`,run:()=>i(`/automations`)},{id:`action:prompts`,section:a,label:n(`sidebar.navigation.prompts`,`Prompts`),icon:De,keywords:`prompts templates slash snippets library`,run:()=>t(`prompts`)},{id:`action:skills`,section:a,label:n(`sidebar.navigation.skills`,`Skills`),icon:ce,keywords:`skills instructions playbooks load_skill`,run:()=>t(`skills`)},{id:`action:tools`,section:a,label:n(`sidebar.navigation.tools`,`Tools`),icon:$e,keywords:`tools servers mcp openapi integrations approvals`,run:()=>t(`tools`)},...b?[{id:`action:agents`,section:a,label:n(`sidebar.navigation.agents`,`Agents`),icon:Te,run:()=>i(`/agents`)}]:[],{id:`action:settings`,section:a,label:n(`palette.settings`,`Settings`),icon:be,hint:`${x},`,keywords:`settings preferences configuration options`,run:e},{id:`action:theme`,section:a,label:n(`palette.toggleTheme`,`Toggle theme`),icon:Re,hint:`${x}D`,keywords:`theme dark light mode appearance`,run:g}],s=[...m].sort((e,t)=>t.updatedAt-e.updatedAt).map(e=>({id:`session:${e.id}`,section:n(`palette.chats`,`Chats`),label:e.title||n(`tabs.chat`,`Chat`),icon:nt,hint:O(e.updatedAt,r.language),keywords:e.model,run:()=>i(`/c/${e.id}`)})),c=y?[...h].sort((e,t)=>new Date(t.updatedAt).getTime()-new Date(e.updatedAt).getTime()).map(e=>({id:`work:${e.id}`,section:n(`palette.work`,`Work`),label:e.title||n(`work.tasks.untitled`,`Untitled task`),icon:V,hint:e.status,run:()=>i(`/work/${e.id}`)})):[];return[...o,...s,...c]},[n,x,i,e,t,g,m,h,y,b,r.language]),k=(0,Z.useMemo)(()=>{let e=s.trim();if(!e){let e=D.filter(e=>e.id.startsWith(`action:`)),t=D.filter(e=>e.id.startsWith(`session:`)).slice(0,6),n=D.filter(e=>e.id.startsWith(`work:`)).slice(0,4);return[...e,...t,...n].map(e=>({item:e,ranges:[]}))}let r=D.flatMap(t=>{let n=qa(e,t.label);if(n)return[{item:t,...n}];let r=t.keywords?qa(e,t.keywords):null;return r?[{item:t,score:r.score-30,ranges:[]}]:[]}),a=new Map;r.forEach(({item:e,score:t})=>{let n=a.get(e.section);(n===void 0||t>n)&&a.set(e.section,t)});let o=r.sort((e,t)=>(a.get(t.item.section)??0)-(a.get(e.item.section)??0)||e.item.section.localeCompare(t.item.section)||t.score-e.score).slice(0,Ka).map(({item:e,ranges:t})=>({item:e,ranges:t}));if(!C)return o;let c=new Set(o.filter(e=>e.item.id.startsWith(`session:`)).map(e=>e.item.id.slice(8))),l=[...C.sessions.filter(e=>!c.has(e.sessionId)).map(e=>({id:`deep-session:${e.sessionId}:${e.messageId}`,section:n(`palette.messages`,`Messages`),label:e.title||n(`tabs.chat`,`Chat`),icon:nt,hint:e.snippet,run:()=>i(`/c/${e.sessionId}`)})),...C.notes.map(e=>({id:`deep-note:${e.noteId}`,section:n(`palette.notes`,`Notes`),label:e.title||n(`notes.untitled`,`Untitled`),icon:qe,hint:e.snippet,run:()=>i(`/notes?note=${encodeURIComponent(e.noteId)}`)})),...C.documents.map(e=>({id:`deep-document:${e.documentId}`,section:n(`palette.documents`,`Documents`),label:e.filename,icon:je,hint:e.snippet,run:()=>t(`documents`)}))];return[...o,...l.map(e=>({item:e,ranges:[]}))]},[D,s,C,n,i,t]);(0,Z.useEffect)(()=>{(p.current?.querySelector(`[data-selected="true"]`))?.scrollIntoView({block:`nearest`})},[l,k.length]);let j=e=>{e&&(S(),e.run())};return a?(0,yi.createPortal)((0,Q.jsx)(`div`,{"data-testid":`command-palette`,className:`fixed inset-0 z-[120] flex items-center justify-center bg-black/25 px-4 backdrop-blur-[2px] dark:bg-black/45`,onMouseDown:e=>{e.target===e.currentTarget&&S()},children:(0,Q.jsxs)(`div`,{className:`flex h-[min(34rem,76vh)] w-full max-w-2xl flex-col overflow-hidden rounded-2xl border border-line bg-surface-overlay/95 shadow-overlay backdrop-blur-xl animate-scale-in motion-reduce:animate-none`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2.5 border-b border-line px-4`,children:[(0,Q.jsx)(oe,{className:`h-4 w-4 shrink-0 text-ink-subtle`}),(0,Q.jsx)(`input`,{ref:f,"data-testid":`command-palette-input`,value:s,onChange:e=>{c(e.target.value),u(0)},onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),S()):e.key===`ArrowDown`?(e.preventDefault(),u(e=>Math.min(k.length-1,e+1))):e.key===`ArrowUp`?(e.preventDefault(),u(e=>Math.max(0,e-1))):e.key===`Enter`&&(e.preventDefault(),j(k[l]?.item))},placeholder:n(`palette.placeholder`,`Search chats, Work, actions…`),className:`h-[3.25rem] w-full bg-transparent text-[15px] text-ink outline-none placeholder:text-ink-subtle`}),(0,Q.jsx)(`kbd`,{className:`shrink-0 rounded-md border border-line px-1.5 py-0.5 font-mono text-[10px] text-ink-subtle`,children:`esc`})]}),(0,Q.jsxs)(`div`,{ref:p,className:`min-h-0 flex-1 overflow-y-auto p-2 scrollbar-thin`,children:[k.length===0&&(0,Q.jsx)(`p`,{className:`px-3 py-6 text-center text-sm text-ink-subtle`,children:n(`palette.empty`,`No matches.`)}),k.map(({item:e,ranges:t},n)=>{let r=n===0||e.section!==k[n-1].item.section;return(0,Q.jsxs)(Z.Fragment,{children:[r&&(0,Q.jsx)(`p`,{className:`px-2.5 pb-1 pt-2.5 text-[10px] font-medium uppercase tracking-[0.08em] text-ink-subtle first:pt-1`,children:e.section}),(0,Q.jsxs)(`button`,{type:`button`,"data-selected":n===l||void 0,onMouseEnter:()=>u(n),onClick:()=>j(e),className:A(`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-start text-sm transition-colors`,n===l?`bg-black/[0.05] text-ink dark:bg-white/[0.07]`:`text-ink-muted`),children:[(0,Q.jsx)(e.icon,{className:`h-4 w-4 shrink-0 text-ink-subtle`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:(0,Q.jsx)(Ja,{text:e.label,ranges:t})}),e.hint&&(0,Q.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-ink-subtle`,children:e.hint})]})]},e.id)})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-t border-line px-4 py-2 text-[10px] text-ink-subtle`,children:[(0,Q.jsx)(`span`,{className:`inline-flex items-center gap-1`,children:(0,Q.jsx)(`kbd`,{className:`rounded-md border border-line px-1.5 py-0.5 font-mono`,children:`↑↓`})}),(0,Q.jsx)(`span`,{className:`inline-flex items-center gap-1`,children:(0,Q.jsx)(`kbd`,{className:`rounded-md border border-line px-1.5 py-0.5 font-mono`,children:`↵`})}),(0,Q.jsx)(`span`,{className:`ms-auto inline-flex items-center gap-1`,children:(0,Q.jsx)(`kbd`,{className:`rounded-md border border-line px-1.5 py-0.5 font-mono`,children:`esc`})})]})]})}),document.body):null},Xa=dt(`user-service`),Za=class{static async initializeAuth(){let{setLoading:e,setSystemInfo:t,login:n}=G.getState();try{e(!0),Xa.debug(`Starting auth initialization...`),Xa.debug(`Fetching system info...`);let r=await mt.getSystemInfo();Xa.debug(`System info response:`,r),r.success&&r.data?(Xa.debug(`Setting system info:`,r.data),t(r.data)):Xa.error(`System info response failed:`,r);let i=localStorage.getItem(`auth-token`);if(i)try{let e=(await s(async()=>{let{default:e}=await import(`../js/utils-vendor-9bQ62WeD.js`).then(e=>e.i);return{default:e}},__vite__mapDeps([6,1,2]))).default,t=e.defaults.headers.common;e.defaults.headers.common.Authorization=`Bearer ${i}`;let r=await mt.verifyToken();if(r.success&&r.data){let e=G.getState().systemInfo;e&&n(r.data,i,e)}e.defaults.headers.common=t}catch(e){Xa.error(`Token verification failed:`,e),localStorage.removeItem(`auth-token`)}}catch(e){Xa.error(`Auth initialization error:`,e)}finally{e(!1)}}};st.interceptors.request.use(e=>{let t=localStorage.getItem(`auth-token`);return t&&(e.headers.Authorization=`Bearer ${t}`),e},e=>Promise.reject(e)),st.interceptors.response.use(e=>e,e=>{if(e.response?.status===401){localStorage.removeItem(`auth-token`);let{logout:e}=G.getState();e();let t=window.location.protocol===`file:`;window.location.href=t?`#/login`:`/login`}return Promise.reject(e)});var Qa=dt(`initialize`),$a=()=>{let e=(0,Z.useRef)(!1),t=(0,Z.useRef)(!1),{loadSessions:n,loadModels:r,loadPreferences:i,setSelectedModel:a,models:o,ollamaConnected:s}=P(),{loadPreferences:c}=Et(),{loadPlugins:l,plugins:u}=Ct(),d=G(e=>e.isAuthenticated);(0,Z.useEffect)(()=>{e.current||t.current||(async()=>{t.current=!0;try{Qa.debug(`Initializing Libre WebUI...`),await Za.initializeAuth();let t=G.getState();if(t.requiresAuth()&&!t.isAuthenticated){Qa.debug(`Authentication required; deferring protected app initialization`);return}try{!(await xt.checkHealth()).success&&!ut()&&W.error(`Ollama service is not available. Plugin models may still be used.`)}catch(e){Qa.warn(`Ollama health check failed; continuing provider initialization:`,e),ut()||W.error(`Ollama service is not available. Plugin models may still be used.`)}await Promise.all([c(),i()]),await Promise.all([r(),n(),l()]),e.current=!0,Qa.debug(`Libre WebUI initialized successfully`)}catch(t){ut()?(await Promise.all([c(),i()]),await Promise.all([r(),n(),l()]),e.current=!0):(Qa.error(`Failed to initialize app:`,t),W.error(`Failed to connect to the backend service`))}finally{t.current=!1}})()},[d,c,i,r,n,l]),(0,Z.useEffect)(()=>{if(o.length>0){let e=o.filter(e=>!e.name.includes(`embed`))[0]||o[0],{selectedModel:t,selectedProviderType:n,selectedProviderId:r}=P.getState();if(t){if(!N(o,{model:t,providerType:n,providerId:r})&&n!==`ollama`&&n!==`plugin`){let t=F(e);Qa.debug(`Legacy selected model not available, falling back to:`,t.model),a(t.model,t.providerType,t.providerId)}}else{let t=F(e);Qa.debug(`No model selected, using first available:`,t.model),a(t.model,t.providerType,t.providerId)}}},[o,a]),(0,Z.useEffect)(()=>{e.current&&(Qa.debug(`Plugin availability changed, reloading models...`),r())},[u,r]),(0,Z.useEffect)(()=>{let e=0,t=()=>{if(document.visibilityState!==`visible`)return;let t=G.getState();if(t.requiresAuth()&&!t.isAuthenticated)return;let n=Date.now();n-e<1e4||(e=n,t.refreshWorkAccess())};return window.addEventListener(`focus`,t),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`focus`,t),document.removeEventListener(`visibilitychange`,t)}},[]),(0,Z.useEffect)(()=>{let e=()=>{Qa.debug(`Installed models changed, reloading models...`),r()};return window.addEventListener(yt,e),()=>window.removeEventListener(yt,e)},[r]),(0,Z.useEffect)(()=>{if(s)return;let e=G.getState();if(e.requiresAuth()&&!e.isAuthenticated)return;let t=()=>{document.visibilityState===`visible`&&(Qa.debug(`Provider offline at startup, re-checking availability...`),r({quiet:!0}))},n=o.some(e=>!e.isPersona)?void 0:window.setInterval(t,1e4);return window.addEventListener(`focus`,t),()=>{n!==void 0&&window.clearInterval(n),window.removeEventListener(`focus`,t)}},[s,o,r])},eo=(e,t=!0)=>{let n=(0,Z.useCallback)(n=>{if(!t)return;let r=n.target;if(r.tagName===`INPUT`||r.tagName===`TEXTAREA`||r.contentEditable===`true`||r.isContentEditable)return;if(n.key===`?`||n.key===`/`&&n.shiftKey){let t=e.find(e=>e.key===`?`);if(t){n.preventDefault(),n.stopPropagation(),t.action();return}}let i=e.find(e=>{let t=e.key.toLowerCase()===n.key.toLowerCase(),r=!!e.metaKey,i=n.metaKey||n.ctrlKey,a=!r||i,o=!e.ctrlKey||n.ctrlKey,s=!!e.shiftKey===n.shiftKey,c=!!e.altKey===n.altKey;return t&&a&&o&&s&&c});i&&(n.preventDefault(),n.stopPropagation(),i.action())},[e,t]);(0,Z.useEffect)(()=>{if(t)return document.addEventListener(`keydown`,n),()=>{document.removeEventListener(`keydown`,n)}},[n,t])},to=new Set([`.`,`!`,`?`,`。`,`!`,`?`,`…`]),no=new Set([`。`,`!`,`?`]),ro=new Set([`"`,`'`,`’`,`”`,`»`,`)`,`]`,`}`]),io=new Set([`,`,`;`,`:`,`—`,`–`,`,`,`;`,`:`,`、`,`
|
|
80
|
+
`]),ao=new Set(`a.m,apr,aug,dec,dr,e.g,etc,feb,fri,i.e,jan,jr,jul,jun,mar,mr,mrs,ms,nov,oct,p.m,prof,sep,sept,sr,st,vs`.split(`,`)),oo=(e,t)=>{if(!Number.isFinite(e)||e<1)throw RangeError(`${t} must be a positive number`);return Math.floor(e)},so=e=>{let t=oo(e.maxChars??360,`maxChars`),n=oo(e.targetChars??Math.min(240,t),`targetChars`),r=oo(e.minChars??Math.min(48,n),`minChars`);if(n>t)throw RangeError(`targetChars cannot exceed maxChars`);if(r>n)throw RangeError(`minChars cannot exceed targetChars`);return{...e,targetChars:n,maxChars:t,minChars:r}},co=e=>{let t=Intl;if(t.Segmenter)try{return new t.Segmenter(e,{granularity:`sentence`})}catch{return}},lo=e=>e!==void 0&&/\s/u.test(e),uo=(e,t,n)=>{let r=e.slice(t,n).match(/([\p{L}.]+)\.$/u)?.[1]?.toLocaleLowerCase();return r?!!(ao.has(r)||/^\p{L}$/u.test(r)||/^(?:\p{L}\.)+\p{L}$/u.test(r)):!1};function fo(e){let t=[],n=0,r=0;for(;r<e.length;){let i=e[r];if(!to.has(i)){r+=1;continue}if(i===`.`&&/\d/u.test(e[r-1]??``)&&/\d/u.test(e[r+1]??``)){r+=1;continue}let a=r+1;for(;a<e.length&&to.has(e[a]);)a+=1;let o=a;for(;o<e.length&&ro.has(e[o]);)o+=1;let s=o===e.length||lo(e[o])||no.has(i),c=i===`.`&&o<e.length&&uo(e,n,a);if(s&&!c){let i=e.slice(n,o).trim();for(i&&t.push(i),n=o;n<e.length&&lo(e[n]);)n+=1;r=n;continue}r=a}let i=e.slice(n).trim();return i&&t.push(i),t}function po(e,t={}){if(!e.trim())return[];let n=t.segmenter===!1?void 0:t.segmenter??co(t.locale);if(!n)return fo(e);try{let t=Array.from(n.segment(e),e=>e.segment.trim()).filter(Boolean);return t.length>0?t:fo(e)}catch{return fo(e)}}var mo=(e,t)=>{let n=Math.min(Math.max(1,t),e.length),r=e.charCodeAt(n-1);return r>=55296&&r<=56319&&n<e.length&&--n,Math.max(1,n)},ho=(e,t,n)=>{let r=mo(e,t),i=Math.max(1,n);for(let t=r-1;t>=i;--t)if(io.has(e[t]))return t+1;for(let t=r-1;t>=i;--t)if(lo(e[t]))return t},go=(e,t,n)=>{let r=Math.min(e.length-1,n);for(let n=Math.max(1,t);n<=r;n+=1)if(io.has(e[n]))return n+1;for(let n=Math.max(1,t);n<=r;n+=1)if(lo(e[n]))return n},_o=(e,t,n)=>{let r=[],i=e.trim();for(;i.length>t;){let e=Math.min(t,Math.max(n,i.length-n)),a=ho(i,e,Math.min(n,Math.floor(e/2)))??mo(i,e),o=i.slice(0,a).trim();o&&r.push(o),i=i.slice(a).trimStart()}return i&&r.push(i),r},vo=e=>e.reduce((e,t,n)=>e+t.length+ +!!n,0),yo=e=>e.join(` `),bo=(e,{targetChars:t,maxChars:n,minChars:r})=>{if(e.length<2)return;let i=e.length-1,a=e[i];if(a.length>=r)return;let o=`${e[i-1]} ${a}`;if(o.length<=n){e.splice(i-1,2,o);return}let s=Math.max(r,o.length-n),c=Math.min(n,o.length-r);if(s>c)return;let l=Math.min(c,Math.max(s,t)),u=ho(o,l,s)??go(o,l,c);if(!u)return;let d=o.slice(0,u).trim(),f=o.slice(u).trim();d.length>=r&&d.length<=n&&f.length>=r&&f.length<=n&&e.splice(i-1,2,d,f)};function xo(e,t={}){let n=so(t),r=po(e,n);if(r.length===0)return[];let i=r.flatMap(e=>_o(e,n.maxChars,n.minChars)),a=[],o=[];for(let e of i){if(o.length===0){o=[e];continue}let t=vo(o),r=t+1+e.length,i=Math.abs(n.targetChars-t),s=Math.abs(n.targetChars-r);r<=n.maxChars&&(r<=n.targetChars||t<n.minChars||e.length<n.minChars||s<=i)?o.push(e):(a.push(o),o=[e])}o.length>0&&a.push(o);let s=a.map(yo);return bo(s,n),s}var So=class extends Error{constructor(){super(`Audio playback needs a click or key press before it can start`),this.name=`TTSPlaybackBlockedError`}},Co=(e,t)=>e instanceof Error?e:Error(t),wo=e=>{let t=e instanceof Error?e.message:`TTS playback cancelled`;if(typeof DOMException<`u`)return new DOMException(t,`AbortError`);let n=Error(t);return n.name=`AbortError`,n},To=e=>typeof e==`object`&&e&&`name`in e?String(e.name):void 0,Eo=e=>To(e)===`AbortError`,Do=e=>{let t=To(e);return t===`TTSPlaybackBlockedError`||t===`NotAllowedError`},Oo=(e,t,n)=>Math.min(n,Math.max(t,Math.floor(e))),ko=e=>{try{e?.()}catch{}},Ao=()=>{let e=globalThis,t=e.AudioContext??e.webkitAudioContext;if(!t)return null;try{return new t}catch{return null}},jo=null,Mo=()=>(jo?.state===`closed`&&(jo=null),!jo&&(jo=Ao(),!jo)?null:(jo.state,jo));function No(){let e=Mo();if(!e)return Promise.resolve(`unsupported`);if(!e.state||e.state===`running`)return Promise.resolve(`ready`);if(!e.resume||e.state===`closed`)return Promise.resolve(`blocked`);let t;try{t=e.resume()}catch{return Promise.resolve(`blocked`)}return Promise.resolve(t).then(()=>{let t=e.state;return!t||t===`running`?`ready`:`blocked`},()=>`blocked`)}function Po(){if(typeof document>`u`)return()=>void 0;let e=!1,t=()=>{e||(e=!0,document.removeEventListener(`pointerdown`,n,!0),document.removeEventListener(`keydown`,n,!0))},n=e=>{e instanceof KeyboardEvent&&[`Alt`,`Control`,`Meta`,`Shift`].includes(e.key)||No().then(e=>{(e===`ready`||e===`unsupported`)&&t()})};return document.addEventListener(`pointerdown`,n,!0),document.addEventListener(`keydown`,n,!0),t}var Fo=e=>{let t=globalThis.Audio;if(!t)throw Error(`Audio playback is not supported in this environment`);return new t(e)},Io={create(e){if(typeof URL.createObjectURL!=`function`)throw Error(`Blob audio URLs are not supported in this environment`);return URL.createObjectURL(e)},revoke(e){URL.revokeObjectURL(e)}},Lo=class{constructor(e,t,n,r,i,a){f(this,`batches`,void 0),f(this,`generate`,void 0),f(this,`concurrency`,void 0),f(this,`maxAhead`,void 0),f(this,`signal`,void 0),f(this,`onFailure`,void 0),f(this,`nextIndex`,0),f(this,`consumedCount`,0),f(this,`results`,void 0),f(this,`waiters`,new Set),f(this,`failure`,void 0),this.batches=e,this.generate=t,this.concurrency=n,this.maxAhead=r,this.signal=i,this.onFailure=a,this.results=Array(e.length);let o=Math.min(n,e.length);for(let e=0;e<o;e+=1)this.runWorker()}async get(e){for(;;){if(this.failure)throw this.failure;if(this.signal.aborted)throw wo(this.signal.reason);let t=this.results[e];if(t)return this.results[e]=void 0,this.consumedCount=Math.max(this.consumedCount,e+1),this.notify(),t.blob;await new Promise(e=>{let t=()=>{this.waiters.delete(t),this.signal.removeEventListener(`abort`,t),e()};this.waiters.add(t),this.signal.addEventListener(`abort`,t,{once:!0})})}}notify(){for(let e of[...this.waiters])e()}async runWorker(){for(;!this.signal.aborted&&!this.failure;){let e=await this.claimNextIndex();if(e===void 0)return;try{let t=await this.generate(this.batches[e],{index:e,total:this.batches.length,signal:this.signal});if(this.signal.aborted||this.failure)return;if(!t||typeof t.arrayBuffer!=`function`)throw TypeError(`The TTS generator did not return a Blob`);this.results[e]={blob:t},this.notify()}catch(t){if(this.signal.aborted||this.failure)return;this.failure=Co(t,`Failed to generate TTS batch ${e+1}`),this.onFailure(this.failure),this.notify();return}}}async claimNextIndex(){for(;!this.signal.aborted&&!this.failure;){if(this.nextIndex>=this.batches.length)return;if(this.nextIndex<this.consumedCount+this.maxAhead){let e=this.nextIndex;return this.nextIndex+=1,e}await new Promise(e=>{let t=()=>{this.waiters.delete(t),this.signal.removeEventListener(`abort`,t),e()};this.waiters.add(t),this.signal.addEventListener(`abort`,t,{once:!0})})}}},Ro=class{constructor(e){f(this,`options`,void 0),f(this,`controller`,new AbortController),f(this,`concurrency`,void 0),f(this,`initialBufferSize`,void 0),f(this,`scheduleLeadSeconds`,void 0),f(this,`externalAbortListener`,void 0),f(this,`audioContext`,null),f(this,`activeAudio`,null),f(this,`sources`,new Set),f(this,`started`,!1),f(this,`used`,!1),f(this,`cancelled`,!1),f(this,`fatalError`,void 0),f(this,`currentState`,`idle`),f(this,`ownsAudioContext`,!1),this.options=e,this.concurrency=Oo(e.concurrency??3,1,3),this.initialBufferSize=Math.max(1,Math.floor(e.initialBufferSize??2)),this.scheduleLeadSeconds=Math.max(0,e.scheduleLeadSeconds??.03),e.signal&&(this.externalAbortListener=()=>{this.cancelled=!0,this.abort(e.signal?.reason)},e.signal.aborted?this.externalAbortListener():e.signal.addEventListener(`abort`,this.externalAbortListener,{once:!0}))}get state(){return this.currentState}get signal(){return this.controller.signal}cancel(e){this.currentState!==`ended`&&this.currentState!==`error`&&this.currentState!==`cancelled`&&(this.cancelled=!0,this.abort(e),this.stopActivePlayback())}async play(e){if(this.used)throw Error(`A TTSPlaybackSession can only be played once`);this.used=!0;let t=e.map(e=>e.trim()).filter(Boolean);if(t.length===0){this.setState(`ended`),ko(this.options.onEnd),this.removeExternalAbortListener();return}try{this.throwIfStopped(),this.setState(`loading`),this.options.audioContextFactory?(this.ownsAudioContext=!0,this.audioContext=this.options.audioContextFactory()):this.audioContext=Mo(),this.audioContext&&await this.ensureAudioContextReady(this.audioContext),this.throwIfStopped(),this.setState(`generating`);let e=new Lo(t,this.options.generate,this.concurrency,Math.max(this.concurrency,this.initialBufferSize),this.controller.signal,e=>{this.fatalError=e,this.abort(e)});this.audioContext?await this.playWithWebAudio(e,t.length):await this.playWithHtmlAudio(e,t.length),this.throwIfStopped(),this.setState(`ended`),await this.cleanup(),ko(this.options.onEnd)}catch(e){let t=this.fatalError??Co(e,`TTS playback failed`),n=this.cancelled&&!this.fatalError,r=!n&&Do(t);if(this.setState(n?`cancelled`:r?`blocked`:`error`),this.controller.signal.aborted||this.abort(t),await this.cleanup(),n)throw wo(this.controller.signal.reason);if(r)throw ko(this.options.onBlocked),t;try{this.options.onError?.(t)}catch{}throw t}}abort(e){this.controller.signal.aborted||this.controller.abort(e)}throwIfStopped(){if(this.fatalError)throw this.fatalError;if(this.controller.signal.aborted)throw wo(this.controller.signal.reason)}setState(e){if(this.currentState!==e){this.currentState=e;try{this.options.onStateChange?.(e)}catch{}}}async ensureAudioContextReady(e){if(!e.state||e.state===`running`){this.ownsAudioContext;return}if(e.state===`closed`)throw Error(`Audio output was closed before playback started`);if(!e.resume)throw new So;try{await this.raceAbort(e.resume())}catch(e){throw Eo(e)?e:(this.ownsAudioContext,new So)}if(e.state&&e.state!==`running`)throw this.ownsAudioContext,new So;this.ownsAudioContext}markStarted(){this.started||(this.started=!0,this.setState(`playing`),ko(this.options.onStart))}markBuffering(){!this.started&&this.currentState===`generating`&&this.setState(`buffering`)}async playWithWebAudio(e,t){let n=this.audioContext;if(!n)throw Error(`Web Audio context is unavailable`);let r=Math.min(Math.max(2,this.initialBufferSize),t),i=[];for(let t=0;t<r;t+=1)i.push(await this.decode(e,n,t));let a=n.currentTime+this.scheduleLeadSeconds,o=[],s=e=>{this.throwIfStopped();let t=n.createBufferSource();t.buffer=e,t.connect(n.destination),this.sources.add(t);let r=new Promise(e=>{t.onended=()=>{t.onended=null,this.sources.delete(t);try{t.disconnect?.()}catch{}e()}}),i=Math.max(a,n.currentTime+this.scheduleLeadSeconds);t.start(i),this.markStarted(),a=i+Math.max(0,e.duration),o.push(r)};for(let e of i)s(e);for(let i=r;i<t;i+=1){let t=this.decode(e,n,i),a=o[i-r],[,c]=await this.raceAbort(Promise.all([a,t]));s(c)}await this.raceAbort(Promise.all(o).then(()=>void 0))}async decode(e,t,n){let r=await e.get(n);this.markBuffering(),this.throwIfStopped();let i=await this.raceAbort(r.arrayBuffer());return this.throwIfStopped(),this.raceAbort(t.decodeAudioData(i))}async playWithHtmlAudio(e,t){let n=Math.min(this.initialBufferSize,t),r=[];for(let t=0;t<n;t+=1)r.push(await e.get(t)),this.markBuffering();for(let i=0;i<t;i+=1){this.throwIfStopped();let t=i<n?r[i]:await e.get(i);await this.playHtmlBlob(t)}}async playHtmlBlob(e){let t=this.options.objectUrlFactory??Io,n=t.create(e),r=null;try{r=(this.options.audioElementFactory??Fo)(n),this.activeAudio=r;let e=new Promise((e,t)=>{if(!r)return t(Error(`Failed to create an audio element`));r.onended=e,r.onerror=()=>t(Error(`TTS audio playback failed`))});await this.raceAbort(r.play()),this.markStarted(),await this.raceAbort(e)}finally{r&&(r.onended=null,r.onerror=null,this.activeAudio===r&&(this.activeAudio=null),r.removeAttribute?.(`src`),r.load?.()),t.revoke(n)}}raceAbort(e){return this.controller.signal.aborted?Promise.reject(this.fatalError??wo(this.controller.signal.reason)):new Promise((t,n)=>{let r=()=>{this.controller.signal.removeEventListener(`abort`,r),n(this.fatalError??wo(this.controller.signal.reason))};this.controller.signal.addEventListener(`abort`,r,{once:!0}),e.then(e=>{this.controller.signal.removeEventListener(`abort`,r),t(e)},e=>{this.controller.signal.removeEventListener(`abort`,r),n(e)})})}stopActivePlayback(){for(let e of this.sources)try{e.stop()}catch{}this.activeAudio&&(this.activeAudio.pause(),this.activeAudio.currentTime=0)}async cleanup(){this.stopActivePlayback();for(let e of this.sources){e.onended=null;try{e.disconnect?.()}catch{}}this.sources.clear();let e=this.audioContext;if(this.audioContext=null,this.ownsAudioContext&&e?.close)try{await e.close()}catch{}this.removeExternalAbortListener()}removeExternalAbortListener(){this.options.signal&&this.externalAbortListener&&(this.options.signal.removeEventListener(`abort`,this.externalAbortListener),this.externalAbortListener=void 0)}},zo=e=>new Ro(e),Bo=null;function Vo(e){return Bo!==e&&Bo?.cancel(),Bo=e,()=>{Bo===e&&(Bo=null)}}var Ho=dt(`components:git-hub-auth-button`),Uo=()=>{let{t:e}=w(),[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{(async()=>{try{let e=await fetch(`${ft}/auth/oauth/github/status`,{method:`GET`,credentials:`include`});if(e.ok){let t=await e.json();i(t.configured||!1),Ho.debug(`GitHub OAuth configured:`,t.configured)}else Ho.debug(`GitHub OAuth status check failed`),i(!1)}catch(e){Ho.debug(`GitHub OAuth not configured:`,e),i(!1)}})()},[]),r?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{if(!r||t)return;n(!0);let e=`${ft}/auth/oauth/github`;window.location.href=e},disabled:t,className:`flex h-11 w-full items-center justify-center rounded-xl border border-line bg-surface-raised px-4 text-sm font-medium text-ink shadow-subtle transition-colors hover:border-line-strong hover:bg-surface-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:ring-offset-canvas disabled:cursor-not-allowed disabled:opacity-40 motion-reduce:transition-none`,children:t?(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[(0,Q.jsx)(B,{size:16,className:`me-2 animate-spin`}),e(`auth.oauth.connectingTo`,{provider:e(`auth.oauth.github`)})]}):(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[(0,Q.jsx)(pe,{size:16,className:`me-2`}),e(`auth.oauth.continueWith`,{provider:e(`auth.oauth.github`)})]})}):null},Wo=dt(`components:hugging-face-auth-button`),Go=()=>{let{t:e}=w(),[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{(async()=>{try{let e=await fetch(`${ft}/auth/oauth/huggingface/status`,{method:`GET`,credentials:`include`});if(e.ok){let t=await e.json();i(t.configured||!1),Wo.debug(`Hugging Face OAuth configured:`,t.configured)}else Wo.debug(`Hugging Face OAuth status check failed`),i(!1)}catch(e){Wo.debug(`Hugging Face OAuth not configured:`,e),i(!1)}})()},[]),r?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{if(!r||t)return;n(!0);let e=`${ft}/auth/oauth/huggingface`;window.location.href=e},disabled:t,className:`flex h-11 w-full items-center justify-center rounded-xl border border-line bg-surface-raised px-4 text-sm font-medium text-ink shadow-subtle transition-colors hover:border-line-strong hover:bg-surface-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:ring-offset-canvas disabled:cursor-not-allowed disabled:opacity-40 motion-reduce:transition-none`,children:t?(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[(0,Q.jsx)(B,{size:16,className:`me-2 animate-spin`}),e(`auth.oauth.connectingTo`,{provider:e(`auth.oauth.huggingFace`)})]}):(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[(0,Q.jsx)(`span`,{className:`me-2 text-base`,children:`🤗`}),e(`auth.oauth.continueWith`,{provider:e(`auth.oauth.huggingFace`)})]})}):null},Ko=({displayName:e})=>{let{t}=w(),[n,r]=(0,Z.useState)(!1),i=e||t(`auth.oidc.defaultProviderName`,`Single sign-on`);return(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{n||(r(!0),window.location.href=`${ft}/auth/oauth/oidc`)},disabled:n,className:`flex h-11 w-full items-center justify-center rounded-xl border border-line bg-surface-raised px-4 text-sm font-medium text-ink shadow-subtle transition-colors hover:border-line-strong hover:bg-surface-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:ring-offset-canvas disabled:cursor-not-allowed disabled:opacity-40 motion-reduce:transition-none`,children:n?(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[(0,Q.jsx)(B,{size:16,className:`me-2 animate-spin`}),t(`auth.oauth.connectingTo`,{provider:i})]}):(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[(0,Q.jsx)(H,{size:16,className:`me-2`}),t(`auth.oauth.continueWith`,{provider:i})]})})},qo=dt(`hooks:oauth-providers`),Jo=async e=>{try{let t=await fetch(`${ft}/auth/oauth/${e}/status`,{method:`GET`,credentials:`include`});if(!t.ok)return{configured:!1};let n=await t.json();return{configured:!!n.configured,displayName:typeof n.displayName==`string`?n.displayName:void 0}}catch(t){return qo.debug(`${e} OAuth not configured:`,t),{configured:!1}}},Yo=()=>{let[e,t]=(0,Z.useState)({github:!1,huggingface:!1,oidc:!1}),[n,r]=(0,Z.useState)(void 0);return(0,Z.useEffect)(()=>{let e=!0;return Promise.all([Jo(`github`),Jo(`huggingface`),Jo(`oidc`)]).then(([n,i,a])=>{e&&(t({github:n.configured,huggingface:i.configured,oidc:a.configured}),r(a.displayName))}),()=>{e=!1}},[]),{...e,oidcDisplayName:n,hasAny:e.github||e.huggingface||e.oidc}},Xo=dt(`components:turnstile-widget`),Zo=`https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit`,Qo=null,$o=()=>window.turnstile?Promise.resolve():Qo||(Qo=new Promise((e,t)=>{let n=document.querySelector(`script[src="${Zo}"]`);if(n){n.addEventListener(`load`,()=>e(),{once:!0}),n.addEventListener(`error`,t,{once:!0});return}let r=document.createElement(`script`);r.src=Zo,r.async=!0,r.defer=!0,r.onload=()=>e(),r.onerror=t,document.head.appendChild(r)}),Qo),es=({siteKey:e,action:t,disabled:n=!1,errorMessage:r,onTokenChange:i})=>{let a=(0,Z.useRef)(null),o=(0,Z.useRef)(null),[s,c]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{let n=!1,r=a.current;return i(``),$o().then(()=>{n||!r||!window.turnstile||(r.innerHTML=``,o.current=window.turnstile.render(r,{sitekey:e,theme:`auto`,size:`flexible`,action:t,callback:e=>i(e),"expired-callback":()=>i(``),"error-callback":()=>i(``)}))}).catch(e=>{Xo.error(`Turnstile script failed to load:`,e),n||c(!0)}),()=>{n=!0,i(``),o.current&&window.turnstile?.remove?window.turnstile.remove(o.current):r&&(r.innerHTML=``),o.current=null}},[t,i,e]),(0,Z.useEffect)(()=>{n&&o.current&&(window.turnstile?.reset(o.current),i(``))},[n,i]),s?(0,Q.jsx)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/50 dark:bg-red-950/30 dark:text-red-300`,children:r}):(0,Q.jsx)(`div`,{className:`rounded-lg border border-accent-200 bg-accent-50/40 p-3 transition-opacity dark:border-accent-800/70 dark:bg-accent-950/20 ${n?`pointer-events-none opacity-60`:``}`,"aria-label":`Security verification`,children:(0,Q.jsx)(`div`,{ref:a,className:`min-h-[65px]`})})},ts=dt(`components:login-form`),ns={username:`demo`,password:`demo`},rs=({onLogin:e,onShowSignup:t,initialApprovalPending:n=!1,bare:r=!1})=>{let{t:i}=w(),a=ut(),o=Yo(),[s,c]=(0,Z.useState)(a?ns.username:``),[l,u]=(0,Z.useState)(a?ns.password:``),[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(n),[v,y]=(0,Z.useState)(``),b=d(),{login:x,systemInfo:S}=G(),C=S?.turnstile?.siteKey,T=!!(S?.turnstile?.enabled&&C&&!a),E=(0,Z.useCallback)(e=>{y(e)},[]),D=(0,Z.useMemo)(()=>m||T&&!v,[m,T,v]),O=async t=>{t.preventDefault();let n=a?ns.username:s.trim(),r=a?ns.password:l;if(!n||!r){U.error(i(`auth.login.enterBoth`));return}if(T&&!v){U.error(i(`auth.login.verificationFailed`,`Security verification failed. Please refresh and try again.`));return}h(!0),_(!1);try{localStorage.removeItem(`auth-token`);let t=await mt.login({username:n,password:r,turnstileToken:v});t.success&&t.data?(x(t.data.user,t.data.token,t.data.systemInfo),U.success(i(`auth.login.loginSuccess`)),e?.(),b(`/`)):U.error(t.message||i(`auth.login.loginFailed`))}catch(e){ts.error(`Login error:`,e);let t=e;t.response?.data?.code===`ACCOUNT_PENDING`?(_(!0),U.error(t.response.data.message||i(`auth.login.approvalPending`,`Your account is waiting for administrator approval.`))):U.error(i(`auth.login.checkCredentials`))}finally{y(``),h(!1)}},k=e=>{if(e.key===`Enter`){let t=e.currentTarget.form;t&&t.requestSubmit()}};return(0,Q.jsxs)(`div`,{className:A(`mx-auto w-full max-w-md`,!r&&`rounded-3xl border border-line bg-surface-raised p-6 shadow-card sm:p-8`),children:[(0,Q.jsxs)(`div`,{className:A(`mb-8`,r?`text-start`:`text-center`),children:[(0,Q.jsx)(`h1`,{className:`mb-2 text-3xl font-light tracking-[-0.04em] text-ink`,children:i(`auth.login.title`)}),(0,Q.jsx)(`p`,{className:`text-sm leading-6 text-ink-muted`,children:i(`auth.login.subtitle`)})]}),(0,Q.jsxs)(`form`,{onSubmit:O,className:`space-y-5`,children:[g&&(0,Q.jsxs)(`div`,{"data-testid":`login-approval-pending`,role:`status`,className:`flex gap-3 rounded-xl border border-warning-500/30 bg-warning-500/10 p-3 text-start`,children:[(0,Q.jsx)(ie,{"aria-hidden":`true`,className:`mt-0.5 h-4 w-4 shrink-0 text-warning-700 dark:text-warning-400`}),(0,Q.jsx)(`p`,{className:`text-xs leading-5 text-ink-muted`,children:i(`auth.login.approvalPending`,`Your account is waiting for administrator approval.`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`username`,className:`mb-2 block text-sm font-medium text-ink`,children:i(`auth.login.username`)}),(0,Q.jsx)(`input`,{id:`username`,type:`text`,value:s,onChange:e=>c(e.target.value),onKeyDown:k,className:`h-11 w-full rounded-xl border border-line bg-surface px-3 text-sm text-ink shadow-subtle outline-none transition-[border-color,box-shadow,background-color] placeholder:text-ink-muted focus:border-line-strong focus:ring-2 focus:ring-primary-500/35 disabled:cursor-not-allowed disabled:bg-surface-subtle disabled:text-ink-muted motion-reduce:transition-none`,placeholder:i(`auth.login.usernamePlaceholder`),required:!0,disabled:m||a})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`password`,className:`mb-2 block text-sm font-medium text-ink`,children:i(`auth.login.password`)}),(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`input`,{id:`password`,type:f?`text`:`password`,value:l,onChange:e=>u(e.target.value),onKeyDown:k,className:`h-11 w-full rounded-xl border border-line bg-surface px-3 pe-11 text-sm text-ink shadow-subtle outline-none transition-[border-color,box-shadow,background-color] placeholder:text-ink-muted focus:border-line-strong focus:ring-2 focus:ring-primary-500/35 disabled:cursor-not-allowed disabled:bg-surface-subtle disabled:text-ink-muted motion-reduce:transition-none`,placeholder:i(`auth.login.passwordPlaceholder`),required:!0,disabled:m||a}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>p(!f),className:`absolute inset-y-0 end-0 flex items-center pe-3 text-ink-muted transition-colors hover:text-ink disabled:cursor-not-allowed disabled:opacity-50`,disabled:m||a,"aria-label":f?`Hide characters`:`Reveal characters`,children:f?(0,Q.jsx)(He,{size:20}):(0,Q.jsx)(Le,{size:20})})]})]}),T&&C&&(0,Q.jsx)(es,{siteKey:C,action:`login`,disabled:m,errorMessage:i(`auth.login.verificationFailed`,`Security verification failed. Please refresh and try again.`),onTokenChange:E}),(0,Q.jsx)(`button`,{type:`submit`,disabled:D,className:`flex h-11 w-full items-center justify-center rounded-xl border border-transparent bg-ink px-4 text-sm font-medium text-ink-inverse shadow-subtle transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:ring-offset-canvas disabled:cursor-not-allowed disabled:opacity-40 motion-reduce:transition-none`,children:m?(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[(0,Q.jsx)(`div`,{className:`me-2 h-4 w-4 animate-spin rounded-full border-b-2 border-current`}),i(`auth.login.signingIn`)]}):(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[(0,Q.jsx)(z,{size:16,className:`me-2`}),i(`auth.login.signIn`)]})})]}),!a&&(0,Q.jsxs)(Q.Fragment,{children:[o.hasAny&&(0,Q.jsxs)(`div`,{className:`mt-6`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,Q.jsx)(`div`,{className:`w-full border-t border-line`})}),(0,Q.jsx)(`div`,{className:`relative flex justify-center text-sm`,children:(0,Q.jsx)(`span`,{className:A(`px-2 text-ink-muted`,r?`bg-canvas`:`bg-surface-raised`),children:i(`common.or`)})})]}),(0,Q.jsxs)(`div`,{className:`mt-6 space-y-3`,children:[o.github&&(0,Q.jsx)(Uo,{}),o.huggingface&&(0,Q.jsx)(Go,{}),o.oidc&&(0,Q.jsx)(Ko,{displayName:o.oidcDisplayName})]})]}),t&&(0,Q.jsx)(`div`,{className:`mt-6 text-center`,children:(0,Q.jsxs)(`p`,{className:`text-sm text-ink-muted`,children:[i(`auth.login.noAccount`),` `,(0,Q.jsx)(`button`,{onClick:t,className:`font-medium text-primary-600 transition-colors hover:text-primary-700 dark:text-primary-400 dark:hover:text-primary-300`,children:i(`auth.login.signUpHere`)})]})})]})]})},is=`Use at least 12 characters, no more than 72 UTF-8 bytes, with uppercase, lowercase, and a number.`,as=e=>e.length<12?`Password must be at least 12 characters.`:new TextEncoder().encode(e).length>72?`Password must be no more than 72 UTF-8 bytes.`:/[A-Z]/.test(e)?/[a-z]/.test(e)?/[0-9]/.test(e)?null:`Password must contain a number.`:`Password must contain a lowercase letter.`:`Password must contain an uppercase letter.`,os=dt(`components:signup-form`),ss=({onSignup:e,onBackToLogin:t,bare:n=!1})=>{let{t:r}=w(),[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(``),[u,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(``),C=d(),{login:T,systemInfo:E}=G(),D=E?.turnstile?.siteKey,O=!!(E?.turnstile?.enabled&&D),k=(0,Z.useCallback)(e=>{S(e)},[]),j=(0,Z.useMemo)(()=>_||O&&!x,[_,O,x]),M=async t=>{if(t.preventDefault(),!i.trim()||!c.trim()){U.error(r(`auth.signup.usernameRequired`));return}if(c!==u){U.error(r(`auth.signup.passwordMismatch`));return}let n=as(c);if(n){U.error(n);return}if(O&&!x){U.error(r(`auth.signup.tryAgain`));return}v(!0);try{let t=await mt.signup({username:i,password:c,email:o,turnstileToken:x});if(t.success&&t.data){if(!(`token`in t.data)){b(!0),U.success(r(`auth.signup.approvalPending`,`Registration received. An administrator must approve your account.`));return}T(t.data.user,t.data.token,t.data.systemInfo),U.success(r(`auth.signup.signupSuccess`)),e?.(),C(`/`)}else U.error(t.message||r(`auth.signup.signupFailed`))}catch(e){os.error(`Signup error:`,e),U.error(r(`auth.signup.tryAgain`))}finally{S(``),v(!1)}},N=e=>{if(e.key===`Enter`){let t=e.currentTarget.form;t&&t.requestSubmit()}};return y?(0,Q.jsxs)(`div`,{"data-testid":`signup-approval-pending`,className:A(`mx-auto w-full max-w-md text-center`,!n&&`rounded-3xl border border-line bg-surface-raised p-6 shadow-card sm:p-8`),children:[(0,Q.jsx)(`div`,{className:`mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-warning-500/15 text-warning-700 dark:text-warning-400`,children:(0,Q.jsx)(ie,{"aria-hidden":`true`,className:`h-6 w-6`})}),(0,Q.jsx)(`h1`,{className:`mt-5 text-3xl font-light tracking-[-0.04em] text-ink`,children:r(`auth.signup.awaitingApproval`,`Awaiting approval`)}),(0,Q.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-ink-muted`,children:r(`auth.signup.awaitingApprovalDescription`,`Your account has been created, but an administrator must activate it before you can sign in.`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:t,className:`mt-6 inline-flex h-11 w-full items-center justify-center rounded-xl border border-line bg-surface px-4 text-sm font-medium text-ink shadow-subtle transition-colors hover:bg-surface-raised`,children:r(`auth.signup.backToSignIn`,`Back to sign in`)})]}):(0,Q.jsxs)(`div`,{className:A(`mx-auto w-full max-w-md`,!n&&`rounded-3xl border border-line bg-surface-raised p-6 shadow-card sm:p-8`),children:[(0,Q.jsxs)(`div`,{className:A(`mb-8`,n?`text-start`:`text-center`),children:[(0,Q.jsx)(`h1`,{className:`mb-2 text-3xl font-light tracking-[-0.04em] text-ink`,children:r(`auth.signup.title`)}),(0,Q.jsx)(`p`,{className:`text-sm leading-6 text-ink-muted`,children:r(`auth.signup.subtitle`)})]}),(0,Q.jsxs)(`form`,{onSubmit:M,className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`username`,className:`mb-2 block text-sm font-medium text-ink`,children:r(`auth.signup.username`)}),(0,Q.jsx)(`input`,{id:`username`,type:`text`,value:i,onChange:e=>a(e.target.value),onKeyDown:N,className:`h-11 w-full rounded-xl border border-line bg-surface px-3 text-sm text-ink shadow-subtle outline-none transition-[border-color,box-shadow,background-color] placeholder:text-ink-muted focus:border-line-strong focus:ring-2 focus:ring-primary-500/35 disabled:cursor-not-allowed disabled:opacity-50 motion-reduce:transition-none`,placeholder:r(`auth.signup.usernamePlaceholder`),required:!0,disabled:_})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`label`,{htmlFor:`email`,className:`mb-2 block text-sm font-medium text-ink`,children:[r(`auth.signup.email`),` `,(0,Q.jsxs)(`span`,{className:`text-ink-muted`,children:[`(`,r(`common.optional`),`)`]})]}),(0,Q.jsx)(`input`,{id:`email`,type:`email`,value:o,onChange:e=>s(e.target.value),onKeyDown:N,className:`h-11 w-full rounded-xl border border-line bg-surface px-3 text-sm text-ink shadow-subtle outline-none transition-[border-color,box-shadow,background-color] placeholder:text-ink-muted focus:border-line-strong focus:ring-2 focus:ring-primary-500/35 disabled:cursor-not-allowed disabled:opacity-50 motion-reduce:transition-none`,placeholder:r(`auth.signup.emailPlaceholder`),disabled:_})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`password`,className:`mb-2 block text-sm font-medium text-ink`,children:r(`auth.signup.password`)}),(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`input`,{id:`password`,type:p?`text`:`password`,value:c,onChange:e=>l(e.target.value),onKeyDown:N,className:`h-11 w-full rounded-xl border border-line bg-surface px-3 pe-11 text-sm text-ink shadow-subtle outline-none transition-[border-color,box-shadow,background-color] placeholder:text-ink-muted focus:border-line-strong focus:ring-2 focus:ring-primary-500/35 disabled:cursor-not-allowed disabled:opacity-50 motion-reduce:transition-none`,placeholder:r(`auth.signup.passwordPlaceholder`),required:!0,disabled:_}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>m(!p),className:`absolute inset-y-0 end-0 flex items-center pe-3 text-ink-muted transition-colors hover:text-ink disabled:cursor-not-allowed disabled:opacity-50`,disabled:_,"aria-label":p?`Hide characters`:`Reveal characters`,children:p?(0,Q.jsx)(He,{size:20}):(0,Q.jsx)(Le,{size:20})})]}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-xs text-ink-muted`,children:is})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`confirmPassword`,className:`mb-2 block text-sm font-medium text-ink`,children:r(`auth.signup.confirmPassword`)}),(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`input`,{id:`confirmPassword`,type:h?`text`:`password`,value:u,onChange:e=>f(e.target.value),onKeyDown:N,className:`h-11 w-full rounded-xl border border-line bg-surface px-3 pe-11 text-sm text-ink shadow-subtle outline-none transition-[border-color,box-shadow,background-color] placeholder:text-ink-muted focus:border-line-strong focus:ring-2 focus:ring-primary-500/35 disabled:cursor-not-allowed disabled:opacity-50 motion-reduce:transition-none`,placeholder:r(`auth.signup.confirmPasswordPlaceholder`),required:!0,disabled:_}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>g(!h),className:`absolute inset-y-0 end-0 flex items-center pe-3 text-ink-muted transition-colors hover:text-ink disabled:cursor-not-allowed disabled:opacity-50`,disabled:_,"aria-label":h?`Hide confirmation`:`Reveal confirmation`,children:h?(0,Q.jsx)(He,{size:20}):(0,Q.jsx)(Le,{size:20})})]})]}),O&&D&&(0,Q.jsx)(es,{siteKey:D,action:`signup`,disabled:_,errorMessage:r(`auth.signup.tryAgain`),onTokenChange:k}),(0,Q.jsx)(`button`,{type:`submit`,disabled:j,className:`flex h-11 w-full items-center justify-center rounded-xl border border-transparent bg-ink px-4 text-sm font-medium text-ink-inverse shadow-subtle transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:ring-offset-canvas disabled:cursor-not-allowed disabled:opacity-40 motion-reduce:transition-none`,children:_?(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[(0,Q.jsx)(`div`,{className:`me-2 h-4 w-4 animate-spin rounded-full border-b-2 border-current`}),r(`auth.signup.creatingAccount`)]}):(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[(0,Q.jsx)(Ke,{size:16,className:`me-2`}),r(`auth.signup.createAccount`)]})})]}),(0,Q.jsx)(Uo,{}),(0,Q.jsx)(`div`,{className:`mt-6 text-center`,children:(0,Q.jsxs)(`p`,{className:`text-sm text-ink-muted`,children:[r(`auth.signup.hasAccount`),` `,(0,Q.jsx)(`button`,{onClick:t,className:`font-medium text-primary-600 transition-colors hover:text-primary-700 dark:text-primary-400 dark:hover:text-primary-300`,children:r(`auth.signup.signInHere`)})]})})]})};function cs(e,t=`0.26.0`){return t?.trim()||e?.trim()||``}var ls=()=>{let{t:e}=w(),t=d(),n=u(),{isAuthenticated:r,requiresAuth:i,systemInfo:a}=G(),[o,s]=(0,Z.useState)(!1),c=i(),l=a?.signupEnabled??!0,f=new URLSearchParams(n.search).get(`approval`)===`pending`;if((0,Z.useEffect)(()=>{(r||!c)&&t(`/`)},[c,r,t]),r||!c)return null;let p=[{icon:le,title:e(`auth.highlights.local.title`,`Local first`),body:e(`auth.highlights.local.body`,`Your conversations and files stay on the machine you run this on.`)},{icon:fe,title:e(`auth.highlights.providers.title`,`Any provider`),body:e(`auth.highlights.providers.body`,`Local models through Ollama, plus the remote providers you choose to add.`)},{icon:R,title:e(`auth.highlights.work.title`,`Isolated Work`),body:e(`auth.highlights.work.body`,`Give a model a sandboxed workspace with files, a terminal, and a preview.`)}],m=cs(a?.version);return(0,Q.jsxs)(`div`,{className:`relative min-h-screen overflow-y-auto bg-canvas text-ink`,children:[(0,Q.jsxs)(`header`,{className:`absolute inset-x-0 top-0 z-10 flex h-14 items-center justify-between px-5 sm:px-8`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-ink lg:invisible`,children:[(0,Q.jsx)(Ei,{size:`sm`,label:null}),(0,Q.jsx)(wi,{size:`sm`})]}),(0,Q.jsx)(Di,{})]}),(0,Q.jsxs)(`main`,{className:`grid min-h-screen lg:grid-cols-2`,children:[(0,Q.jsxs)(`section`,{className:`relative hidden flex-col justify-between border-e border-line bg-surface px-10 py-12 lg:flex xl:px-16`,children:[(0,Q.jsxs)(`div`,{className:`relative z-10 flex items-center gap-3.5 text-ink`,children:[(0,Q.jsx)(Ei,{size:`lg`,label:null}),(0,Q.jsx)(wi,{size:`lg`})]}),(0,Q.jsxs)(`div`,{className:`relative z-10 max-w-lg`,children:[(0,Q.jsx)(`p`,{className:`text-[2.6rem] font-light leading-[1.05] tracking-[-0.04em] text-ink xl:text-5xl`,children:e(`auth.tagline`,`Your AI stack should answer to you.`)}),(0,Q.jsx)(`ul`,{className:`mt-10 space-y-5`,children:p.map(e=>(0,Q.jsxs)(`li`,{className:`flex gap-3`,children:[(0,Q.jsx)(e.icon,{"aria-hidden":`true`,className:`mt-0.5 h-4 w-4 shrink-0 text-ink-subtle`}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`text-[13px] font-medium text-ink`,children:e.title}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-[13px] leading-relaxed text-ink-muted`,children:e.body})]})]},e.title))})]}),(0,Q.jsxs)(`div`,{className:`relative z-10 space-y-1 font-mono text-[11px] text-ink-subtle`,children:[(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`a`,{href:`https://librewebui.org`,target:`_blank`,rel:`noopener noreferrer`,className:`transition-colors hover:text-ink`,children:`librewebui.org`}),` · `,(0,Q.jsx)(`a`,{href:`https://docs.librewebui.org`,target:`_blank`,rel:`noopener noreferrer`,className:`transition-colors hover:text-ink`,children:`docs.librewebui.org`})]}),(0,Q.jsxs)(`p`,{"data-testid":`app-version`,children:[m?`v${m}`:``,m?` · `:``,e(`auth.selfHosted`,`Self-hosted · Apache 2.0`),` · `,(0,Q.jsx)(`a`,{href:`https://kroonen.ai`,target:`_blank`,rel:`noopener noreferrer`,className:`transition-colors hover:text-ink`,children:`kroonen.ai`})]})]})]}),(0,Q.jsx)(`section`,{className:`flex items-center justify-center px-5 pb-12 pt-24 sm:px-8 lg:px-12 lg:py-12`,children:(0,Q.jsx)(`div`,{className:`w-full max-w-sm`,children:o&&l?(0,Q.jsx)(ss,{bare:!0,onBackToLogin:()=>s(!1),onSignup:()=>s(!1)}):(0,Q.jsx)(rs,{bare:!0,initialApprovalPending:f,onShowSignup:l?()=>s(!0):void 0})})})]})]})},us=window.location.protocol===`file:`,ds=()=>us?(0,Q.jsx)(`div`,{className:`absolute top-0 left-0 right-0 h-8 z-50`,style:{WebkitAppRegion:`drag`}}):null,fs=dt(`app`),ps=Z.lazy(()=>s(()=>import(`../js/HomePage-BqNy-FWX.js`),__vite__mapDeps([23,1,2,3,4,5,6,7,8,9,10,11,12,13,15,16,24]))),ms=Z.lazy(()=>s(()=>import(`../js/ChatPage-BAgBHUES.js`),__vite__mapDeps([25,1,2,20,3,4,5,6,7,8,9,10,11,12,13,15,16,26,17,18,19,27,22,28,29,30,31,32]))),hs=Z.lazy(()=>s(()=>import(`../js/PersonasPage-M_WKH2a9.js`),__vite__mapDeps([33,1,2,4,5,6,7,3,8,9,10,11,12,13,16,18,19,20,17]))),gs=Z.lazy(()=>s(()=>import(`../js/GalleryPage-DHz9DkK7.js`),__vite__mapDeps([34,1,2,20,4,5,6,9,10,11,12,13,3,14,16,18,19,17]))),_s=Z.lazy(()=>s(()=>import(`../js/NotesPage-DzHEx2O4.js`),__vite__mapDeps([35,1,2,3,4,5,6,7,8,9,10,11,12,13,18,19,20,16,17,36,37,38]))),vs=Z.lazy(()=>s(()=>import(`../js/CalendarPage-DLjasZOd.js`),__vite__mapDeps([39,1,2,20,3,4,5,6,9,10,11,12,13,18,19,16,17,40]))),ys=Z.lazy(()=>s(()=>import(`../js/AutomationsPage-Dow_lbIf.js`),__vite__mapDeps([41,1,2,20,3,4,5,6,7,8,9,10,11,12,13,18,19,16,17,40]))),bs=Z.lazy(()=>s(()=>import(`../js/LibreClawPage-BDzDILjY.js`),__vite__mapDeps([42,1,2,8,4,5,6,9,10,11,12,13,3,18,19,20,16,17]))),xs=Z.lazy(()=>s(()=>import(`../js/ChannelsPage-C8hvTD7J.js`),__vite__mapDeps([43,1,2,3,4,5,6,7,8,9,10,11,12,13,15,16,18,19,20,17]))),Ss=Z.lazy(()=>s(()=>import(`../js/WorkPage-DxZISerQ.js`),__vite__mapDeps([44,1,2,3,4,5,6,7,8,9,10,11,12,13,15,16,18,19,20,17,36,37,38,32,24]))),Cs=Z.lazy(()=>s(()=>import(`../js/UserManagementPage-BOuaX3ay.js`),__vite__mapDeps([45,1,2,4,5,6,9,10,13,3,12,11,15,7,8,16,18,19,20,17,21]))),ws=Z.lazy(()=>s(()=>import(`../js/PluginUsagePage-Ctoka6JZ.js`),__vite__mapDeps([46,1,2,4,5,6,9,13,3,10,12,11,18,19,20,16,17]))),Ts=Z.lazy(()=>s(()=>import(`../js/EvaluationsPage-Bm8FRoeX.js`),__vite__mapDeps([47,1,2,4,5,6,7,3,8,9,10,11,12,13,18,19,20,16,17,31]))),Es=Z.lazy(()=>s(()=>import(`../js/SystemPage-aOkrSuY7.js`),__vite__mapDeps([48,1,2,4,5,6,9,13,3,10,12,11,18,19,20,16,17]))),Ds=Z.lazy(()=>s(()=>import(`../js/ArtifactDemoPage-D0JEIAbZ.js`),__vite__mapDeps([49,1,2,18,5,6,19,20,3,4,9,16,10,17,28,29,30,27,12]))),Os=Z.lazy(()=>s(()=>import(`../js/SettingsModal-R9EDadAV.js`).then(e=>({default:e.SettingsModal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]))),ks=Z.lazy(()=>s(()=>import(`../js/ArtifactSlideOutPanel-A-i94ghF.js`).then(e=>({default:e.ArtifactSlideOutPanel})),__vite__mapDeps([50,1,2,20,4,5,6,7,3,8,9,10,11,12,13,16,18,29,30,27]))),As=Z.lazy(()=>s(()=>import(`../js/FirstTimeSetup-BxJapNul.js`).then(e=>({default:e.FirstTimeSetup})),__vite__mapDeps([51,1,2,4,5,6,9,10,11,12,13,3,15,7,8,16]))),js=()=>{let{t:e}=w();return(0,Q.jsx)(`div`,{className:`flex h-full min-h-screen items-center justify-center bg-gray-50 dark:bg-dark-100`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,Q.jsx)(`div`,{className:`h-8 w-8 rounded-full border-4 border-gray-200 border-t-primary-500 animate-spin dark:border-dark-300 dark:border-t-primary-400`}),(0,Q.jsx)(`div`,{className:`text-gray-600 dark:text-dark-600`,children:e(`common.loading`)})]})})},Ms=({isOpen:e,compact:t})=>(0,Q.jsx)(`div`,{"aria-hidden":`true`,className:A(`hidden lg:block flex-shrink-0 transition-[width] duration-200 ease-out`,e?t?`w-16`:`w-72`:`w-0`)}),Ns=({hasBackground:e,sidebarOpen:t,sidebarCompact:n,onCloseSidebar:r,showDemoBanner:i,demoMessage:a,children:o})=>(0,Q.jsxs)(`div`,{className:A(`flex h-dvh min-h-0 text-ink relative overflow-hidden`,e?`bg-sidebar/60`:`bg-sidebar`),children:[(0,Q.jsx)(ds,{}),(0,Q.jsx)(Ia,{}),(0,Q.jsx)(Ea,{isOpen:t,onClose:r}),(0,Q.jsx)(Ms,{isOpen:t,compact:n}),(0,Q.jsxs)(`div`,{"data-testid":`app-shell-content`,className:A(`flex-1 basis-0 flex min-h-0 flex-col min-w-0 transition-[margin,background-color] duration-200 ease-out relative z-10 lg:pb-2 lg:pe-2`,us?`pt-8`:`lg:pt-1.5`,t&&n?`max-lg:ms-16`:`max-lg:ms-0`,e?`bg-white/10 dark:bg-dark-50/10`:`bg-transparent`),children:[i&&(0,Q.jsx)(Fa,{message:a}),(0,Q.jsx)(Ga,{}),(0,Q.jsx)(`main`,{className:A(`min-h-0 flex-1 overflow-hidden lg:rounded-[1.5rem] lg:border lg:border-black/[0.06] dark:lg:border-white/[0.07] lg:shadow-[0_1px_2px_rgba(0,0,0,0.03),0_18px_60px_rgba(15,23,42,0.04)]`,e?`bg-white/30 dark:bg-dark-50/35 backdrop-blur-sm`:`bg-canvas`),children:(0,Q.jsx)(ja,{children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(js,{}),children:o})})})]})]}),Ps=[{path:`*`,element:(0,Q.jsx)(()=>{let{t:e,i18n:t}=w(),n=d(),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(void 0),[s,c]=(0,Z.useState)(0),[l,u]=(0,Z.useState)(!1),{sidebarOpen:f,sidebarCompact:p,setSidebarOpen:h,setSidebarCompact:g,toggleSidebar:_,toggleSidebarCompact:v,toggleTheme:b,backgroundImage:x,preferences:S,artifactPanelOpen:C,closeArtifactPanel:T}=Et(),{systemInfo:E,isLoading:D,user:O,isAuthenticated:k}=G(),{isDemoMode:A,demoConfig:j}=Et(),M=E?.requiresAuth===!1||k,N=Pa();Z.useEffect(()=>{if(!(!S.ttsSettings?.enabled||!S.ttsSettings.autoPlay))return Po()},[S.ttsSettings?.autoPlay,S.ttsSettings?.enabled]);let[P,F]=Z.useState(!1),I=Z.useRef(!1);Z.useEffect(()=>{(async()=>{if(I.current){fs.debug(`OAuth already processing, skipping...`);return}if(fs.debug(`Starting OAuth callback processing...`),I.current=!0,new URLSearchParams(window.location.search).get(`auth`)===`success`){try{let e=await fetch(`${ft}/auth/oauth/exchange`,{method:`POST`,credentials:`include`});if(e.ok){let t=await e.json();if(t.success&&t.data){let{login:e}=G.getState();e(t.data.user,t.data.token,t.data.systemInfo),fs.debug(`OAuth login successful`),W.success(`OAuth login successful!`)}else W.error(`Failed to complete OAuth authentication`)}else W.error(`OAuth authentication verification failed`)}catch(e){fs.error(`OAuth processing error:`,e),W.error(`OAuth authentication failed`)}window.history.replaceState({},document.title,window.location.pathname)}fs.debug(`OAuth processing completed`),F(!0),I.current=!1})()},[]),$a();let L=()=>{if(x)return!0;let e=S.backgroundSettings;return e?.enabled&&e?.imageUrl};eo([{key:`b`,metaKey:!0,action:()=>{window.innerWidth>=1024?f?v():(g(!1),_()):(!f&&p&&g(!1),_())},description:e(`keyboard.toggleSidebar`)},{key:`,`,metaKey:!0,action:()=>{o(void 0),i(!0)},description:e(`keyboard.openSettings`)},{key:`o`,metaKey:!0,shiftKey:!0,action:()=>La(n),description:e(`keyboard.newChat`)},{key:`u`,metaKey:!0,shiftKey:!0,action:()=>{G.getState().canUseWork()&&za(n)},description:e(`keyboard.newWork`)},{key:`d`,metaKey:!0,action:b,description:e(`keyboard.toggleDarkMode`)},{key:`?`,action:()=>{o(`shortcuts`),i(!0)},description:e(`keyboard.showShortcuts`)},{key:`Escape`,action:()=>i(!1),description:e(`keyboard.closeModals`)}],M),Z.useEffect(()=>{if(M)return;let e=window.requestAnimationFrame(()=>{i(!1),T()});return()=>window.cancelAnimationFrame(e)},[T,M]),Z.useEffect(()=>{if(!M){K.disconnect();return}return K.connect().catch(fs.error),()=>{K.disconnect()}},[M]),Z.useEffect(()=>{if(!E&&!D&&s<15){let e=setTimeout(async()=>{c(e=>e+1);try{await Za.initializeAuth()}catch{}},2e3);return()=>clearTimeout(e)}},[E,D,s]);let te=!l&&E?.requiresAuth===!0&&E?.hasUsers===!1;return D?(0,Q.jsxs)(`div`,{className:`min-h-screen bg-gray-50 dark:bg-dark-50 flex flex-col justify-center py-12 sm:px-6 lg:px-8`,children:[(0,Q.jsx)(`div`,{className:`sm:mx-auto sm:w-full sm:max-w-md`,children:(0,Q.jsx)(`div`,{className:`flex flex-col items-center`,children:(0,Q.jsx)(Ei,{size:`lg`,className:`text-gray-900 dark:text-gray-100`})})}),(0,Q.jsx)(`div`,{className:`mt-8 flex flex-col items-center gap-4`,children:(0,Q.jsx)(`div`,{className:`w-8 h-8 border-4 border-gray-300 dark:border-gray-600 border-t-primary-500 dark:border-t-primary-400 rounded-full animate-spin`})})]}):E?te&&!l?(0,Q.jsx)(ja,{children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(js,{}),children:(0,Q.jsx)(As,{onComplete:()=>{u(!0)}})})}):P?(0,Q.jsxs)(Q.Fragment,{children:[E&&!E.requiresAuth?(0,Q.jsx)(Ns,{hasBackground:!!L(),sidebarOpen:f,sidebarCompact:p,onCloseSidebar:()=>h(!1),showDemoBanner:A&&j.showBanner,demoMessage:j.message,children:(0,Q.jsxs)(m,{children:[(0,Q.jsx)(y,{path:`/`,element:(0,Q.jsx)(ps,{})}),(0,Q.jsx)(y,{path:`/chat`,element:(0,Q.jsx)(ms,{})}),(0,Q.jsx)(y,{path:`/c/:sessionId`,element:(0,Q.jsx)(ms,{})}),(0,Q.jsx)(y,{path:`/personas`,element:(0,Q.jsx)(hs,{})}),(0,Q.jsx)(y,{path:`/gallery`,element:(0,Q.jsx)(gs,{})}),(0,Q.jsx)(y,{path:`/notes`,element:(0,Q.jsx)(_s,{})}),(0,Q.jsx)(y,{path:`/calendar`,element:(0,Q.jsx)(vs,{})}),(0,Q.jsx)(y,{path:`/automations`,element:(0,Q.jsx)(ys,{})}),(0,Q.jsx)(y,{path:`/channels`,element:(0,Q.jsx)(xs,{})}),(0,Q.jsx)(y,{path:`/work`,element:(0,Q.jsx)(Da,{requireWork:!0,children:(0,Q.jsx)(Ss,{})})}),(0,Q.jsx)(y,{path:`/work/:taskId`,element:(0,Q.jsx)(Da,{requireWork:!0,children:(0,Q.jsx)(Ss,{})})}),(0,Q.jsx)(y,{path:`/agents`,element:(0,Q.jsx)(Da,{requireAdmin:!0,requireAgents:!0,children:(0,Q.jsx)(bs,{})})}),(0,Q.jsx)(y,{path:`/usage`,element:(0,Q.jsx)(Da,{requireAdmin:!0,children:(0,Q.jsx)(ws,{})})}),(0,Q.jsx)(y,{path:`/evaluations`,element:(0,Q.jsx)(Ts,{})}),(0,Q.jsx)(y,{path:`/system`,element:(0,Q.jsx)(Da,{requireAdmin:!0,children:(0,Q.jsx)(Es,{})})}),(0,Q.jsx)(y,{path:`/login`,element:(0,Q.jsx)(ls,{})})]})}):(0,Q.jsxs)(m,{children:[(0,Q.jsx)(y,{path:`/login`,element:(0,Q.jsx)(ls,{})}),(0,Q.jsx)(y,{path:`/*`,element:(0,Q.jsx)(Da,{children:(0,Q.jsx)(Ns,{hasBackground:!!L(),sidebarOpen:f,sidebarCompact:p,onCloseSidebar:()=>h(!1),showDemoBanner:A&&j.showBanner,demoMessage:j.message,children:(0,Q.jsxs)(m,{children:[(0,Q.jsx)(y,{path:`/`,element:(0,Q.jsx)(ps,{})}),(0,Q.jsx)(y,{path:`/chat`,element:(0,Q.jsx)(ms,{})}),(0,Q.jsx)(y,{path:`/c/:sessionId`,element:(0,Q.jsx)(ms,{})}),(0,Q.jsx)(y,{path:`/personas`,element:(0,Q.jsx)(hs,{})}),(0,Q.jsx)(y,{path:`/gallery`,element:(0,Q.jsx)(gs,{})}),(0,Q.jsx)(y,{path:`/notes`,element:(0,Q.jsx)(_s,{})}),(0,Q.jsx)(y,{path:`/calendar`,element:(0,Q.jsx)(vs,{})}),(0,Q.jsx)(y,{path:`/automations`,element:(0,Q.jsx)(ys,{})}),(0,Q.jsx)(y,{path:`/channels`,element:(0,Q.jsx)(xs,{})}),(0,Q.jsx)(y,{path:`/work`,element:(0,Q.jsx)(Da,{requireWork:!0,children:(0,Q.jsx)(Ss,{})})}),(0,Q.jsx)(y,{path:`/work/:taskId`,element:(0,Q.jsx)(Da,{requireWork:!0,children:(0,Q.jsx)(Ss,{})})}),(0,Q.jsx)(y,{path:`/agents`,element:(0,Q.jsx)(Da,{requireAdmin:!0,requireAgents:!0,children:(0,Q.jsx)(bs,{})})}),(0,Q.jsx)(y,{path:`/artifacts`,element:(0,Q.jsx)(Ds,{})}),(0,Q.jsx)(y,{path:`/usage`,element:(0,Q.jsx)(Da,{requireAdmin:!0,children:(0,Q.jsx)(ws,{})})}),(0,Q.jsx)(y,{path:`/evaluations`,element:(0,Q.jsx)(Ts,{})}),(0,Q.jsx)(y,{path:`/system`,element:(0,Q.jsx)(Da,{requireAdmin:!0,children:(0,Q.jsx)(Es,{})})}),(0,Q.jsx)(y,{path:`/users`,element:(0,Q.jsx)(Da,{requireAdmin:!0,children:(0,Q.jsx)(Cs,{})})})]})})})})]}),M&&r&&(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(Os,{isOpen:r,initialTab:a,onClose:()=>i(!1)})}),M&&N.open&&N.notes&&(0,Q.jsx)(Ma,{notes:N.notes,onDismiss:N.dismiss}),M&&C&&(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(ks,{})}),(0,Q.jsx)(Fe,{position:ee(t.language)?`top-left`:`top-right`,toastOptions:{duration:4e3,className:`animate-slide-up`,style:{background:`var(--toast-bg)`,color:`var(--toast-color)`,border:`1px solid var(--toast-border)`,borderRadius:`0.75rem`,boxShadow:`0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)`,cursor:`pointer`},success:{iconTheme:{primary:`rgb(var(--color-primary-600))`,secondary:`#ffffff`}},error:{iconTheme:{primary:`rgb(var(--color-primary-600))`,secondary:`#ffffff`}}},containerStyle:{top:80,insetInlineEnd:20}}),M&&(0,Q.jsx)(Ya,{onOpenSettings:()=>{o(void 0),i(!0)},onOpenSettingsTab:e=>{o(e),i(!0)}})]}):(0,Q.jsx)(`div`,{className:`min-h-screen bg-gray-50 dark:bg-dark-50 flex items-center justify-center`,children:(0,Q.jsx)(`div`,{className:`w-8 h-8 border-4 border-gray-300 dark:border-gray-600 border-t-primary-500 dark:border-t-primary-400 rounded-full animate-spin`})}):(0,Q.jsx)(`div`,{className:`min-h-screen bg-gray-50 dark:bg-dark-50 flex items-center justify-center p-4`,children:(0,Q.jsxs)(`div`,{className:`text-center`,children:[(0,Q.jsx)(`div`,{className:`mb-8`,children:(0,Q.jsx)(Ei,{size:`lg`,className:`mx-auto text-gray-900 dark:text-white`})}),(0,Q.jsx)(`div`,{className:`flex justify-center mb-4`,children:(0,Q.jsx)(`div`,{className:`w-8 h-8 border-4 border-gray-300 dark:border-dark-300 border-t-primary-500 dark:border-t-primary-400 rounded-full animate-spin`})}),(0,Q.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600 text-sm`,children:s>0?`Connecting to backend... (${s}/15)`:`Starting up...`})]})})},{}),errorElement:(0,Q.jsx)(Aa,{})}],Fs=us?v(Ps):g(Ps),Is=()=>(0,Q.jsx)(ja,{children:(0,Q.jsx)(l,{router:Fs})}),Ls=new Yr({defaultOptions:{queries:{staleTime:3e4,refetchOnWindowFocus:!1,retry:1}}});j.catch(()=>{I(`en`)}).then(()=>{pi.createRoot(document.getElementById(`root`)).render((0,Q.jsx)(Z.StrictMode,{children:(0,Q.jsx)(Qr,{client:Ls,children:(0,Q.jsx)(Is,{})})}))});export{Pn as A,xi as C,dr as D,Zr as E,Fn as O,wi as S,di as T,ra as _,Vo as a,Mi as b,Eo as c,Ra as d,La as f,aa as g,oa as h,es as i,Nn as k,Do as l,xa as m,is as n,xo as o,za as p,as as r,zo as s,cs as t,No as u,Yi as v,fi as w,Ei as x,Ki as y};
|