@taskforcehq/taskforce 0.3.328 → 0.3.330
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/dist/Taskforce.module.css +523 -79
- package/dist/TaskforceCore.js +237 -230
- package/dist/annotatedAttachments/AnnotatedAttachmentSessionStore.js +1 -1
- package/dist/cli.js +34 -0
- package/dist/cliCloudTargetGuard.d.ts +5 -0
- package/dist/cliCloudTargetGuard.js +11 -0
- package/dist/components/features/AiProfilesModule.js +3 -5
- package/dist/components/features/AnnotatedAttachmentWorkspace.js +24 -8
- package/dist/components/features/TaskSettings.d.ts +12 -1
- package/dist/components/features/TaskSettings.js +217 -54
- package/dist/components/features/TaskforceAgentsModule.d.ts +1 -2
- package/dist/components/features/TaskforceAgentsModule.js +586 -116
- package/dist/components/features/agentCapabilities/AgentCapabilitiesPrototype.d.ts +1 -1
- package/dist/components/features/agentConnections/AgentConnectionControl.d.ts +15 -0
- package/dist/components/features/agentConnections/AgentConnectionControl.js +125 -0
- package/dist/components/features/agentConnections/ModelConnectionsPanel.d.ts +18 -0
- package/dist/components/features/agentConnections/ModelConnectionsPanel.js +393 -0
- package/dist/components/features/agentConnections/modelConnectionsApi.d.ts +65 -0
- package/dist/components/features/agentConnections/modelConnectionsApi.js +129 -0
- package/dist/components/features/planning/PlanningModule.js +2 -5
- package/dist/components/features/planning/PlanningTaskOrderList.d.ts +1 -1
- package/dist/components/features/planning/PlanningTaskOrderList.js +17 -6
- package/dist/components/features/planning/planningTaskArrangement.d.ts +1 -0
- package/dist/components/features/planning/planningTaskArrangement.js +5 -5
- package/dist/components/features/taskforceAgentAssignments/AgentBehaviorAssignments.js +15 -24
- package/dist/components/features/taskforceAgentEditorModel.d.ts +2 -1
- package/dist/components/features/taskforceAgentEditorModel.js +5 -1
- package/dist/components/features/workflowManager/workflowManagerApi.d.ts +1 -1
- package/dist/components/features/workflowManager/workflowManagerApi.js +3 -0
- package/dist/components/task/TaskCard.d.ts +5 -0
- package/dist/components/task/TaskCard.js +65 -10
- package/dist/components/task/TaskImageReviews.js +14 -5
- package/dist/components/task/TaskKanban.d.ts +6 -1
- package/dist/components/task/TaskKanban.js +152 -6
- package/dist/components/task/TaskList.d.ts +5 -0
- package/dist/components/task/TaskList.js +3 -3
- package/dist/components/task/TaskWorkflowAssignmentField.js +68 -10
- package/dist/components/ui/PasswordInput.d.ts +6 -0
- package/dist/components/ui/PasswordInput.js +11 -0
- package/dist/components/ui/TopNoticeLayer.js +1 -1
- package/dist/components/views/AppShellHeader.js +32 -11
- package/dist/components/views/PlanComparisonPage.js +12 -0
- package/dist/components/views/StandaloneLayout.js +32 -55
- package/dist/components/views/WidgetView.js +3 -3
- package/dist/components/views/panels/PlanningDrawer.js +5 -12
- package/dist/components/views/standalone/modals/AccountSettingsModal.js +26 -17
- package/dist/components/views/standalone/modals/SyncStatusModal.d.ts +4 -3
- package/dist/components/views/standalone/modals/SyncStatusModal.js +33 -38
- package/dist/config/envSchema.js +60 -1
- package/dist/config/localServiceRuntimeContract.d.ts +13 -0
- package/dist/config/localServiceRuntimeContract.js +135 -0
- package/dist/core/AiProfileService.js +46 -8
- package/dist/core/DeletedTaskLifecycleService.d.ts +1 -0
- package/dist/core/DeletedTaskLifecycleService.js +37 -6
- package/dist/core/McpTokenService.d.ts +23 -1
- package/dist/core/McpTokenService.js +93 -10
- package/dist/core/TaskAttachmentLinksDurableMutationService.d.ts +3 -2
- package/dist/core/TaskAttachmentLinksDurableMutationService.js +33 -9
- package/dist/core/TaskChecklistCommandService.d.ts +27 -0
- package/dist/core/TaskChecklistCommandService.js +83 -5
- package/dist/core/TaskLifecycleCommandService.d.ts +3 -1
- package/dist/core/TaskLifecycleCommandService.js +6 -2
- package/dist/core/Taskforce.d.ts +94 -2
- package/dist/core/Taskforce.js +760 -36
- package/dist/core/types.d.ts +14 -0
- package/dist/documentReviews/commandService.d.ts +2 -1
- package/dist/documentReviews/commandService.js +6 -3
- package/dist/hooks/sync/orchestratorShared.d.ts +1 -0
- package/dist/hooks/sync/orchestratorShared.js +2 -0
- package/dist/hooks/sync/useDurableLocalOutboxDrain.d.ts +1 -1
- package/dist/hooks/sync/useDurableTaskCreateMutation.js +1 -1
- package/dist/hooks/sync/useDurableTaskMetadataMutation.d.ts +1 -0
- package/dist/hooks/sync/useDurableTaskMetadataMutation.js +1 -0
- package/dist/hooks/sync/useDurableTaskStatusMutation.d.ts +1 -0
- package/dist/hooks/sync/useLocalSyncCoordinatorSnapshot.d.ts +3 -0
- package/dist/hooks/sync/useLocalSyncCoordinatorSnapshot.js +85 -9
- package/dist/hooks/sync/useSyncStatusControls.d.ts +4 -1
- package/dist/hooks/sync/useSyncStatusControls.js +47 -11
- package/dist/hooks/tasks/taskHttpMutation.js +1 -0
- package/dist/hooks/tasks/useCloudTaskSearch.d.ts +12 -0
- package/dist/hooks/tasks/useCloudTaskSearch.js +71 -0
- package/dist/hooks/tasks/useTaskDescriptionImageDraftRecovery.d.ts +16 -0
- package/dist/hooks/tasks/useTaskDescriptionImageDraftRecovery.js +197 -0
- package/dist/hooks/tasks/useTaskEditorNavigation.d.ts +16 -3
- package/dist/hooks/tasks/useTaskEditorNavigation.js +72 -13
- package/dist/hooks/tasks/useTaskFormActions.d.ts +6 -0
- package/dist/hooks/tasks/useTaskFormActions.js +65 -12
- package/dist/hooks/ui/useSettingsModel.d.ts +24 -2
- package/dist/hooks/ui/useSettingsModel.js +13 -2
- package/dist/hooks/ui/useSettingsPersistence.d.ts +12 -1
- package/dist/hooks/ui/useSettingsPersistence.js +74 -47
- package/dist/hooks/useFilterSort.d.ts +7 -3
- package/dist/hooks/useFilterSort.js +15 -5
- package/dist/hooks/useSyncOrchestrator.d.ts +3 -0
- package/dist/hooks/useSyncOrchestrator.js +111 -2
- package/dist/hooks/useTaskData.d.ts +40 -1
- package/dist/hooks/useTaskData.js +240 -9
- package/dist/hooks/useTaskMutations.d.ts +12 -2
- package/dist/hooks/useTaskMutations.js +266 -52
- package/dist/hooks/useTaskforce.d.ts +39 -9
- package/dist/hooks/useTaskforce.js +359 -40
- package/dist/hooks/useUiNotice.d.ts +4 -0
- package/dist/hooks/useUiNotice.js +4 -0
- package/dist/mcp/adminWorkspaceRegistrar.js +3 -3
- package/dist/mcp/clientRegistry.d.ts +2 -2
- package/dist/mcp/clientRegistry.js +1 -1
- package/dist/mcp/documentAssetRegistrar.js +53 -41
- package/dist/mcp/documentHelpers.d.ts +1 -0
- package/dist/mcp/documentHelpers.js +7 -3
- package/dist/mcp/durableTaskMutationRouter.d.ts +4 -1
- package/dist/mcp/durableTaskMutationRouter.js +10 -0
- package/dist/mcp/durableTaskRelationshipMutationRouter.js +4 -0
- package/dist/mcp/httpProtocolRouting.d.ts +10 -0
- package/dist/mcp/httpProtocolRouting.js +19 -0
- package/dist/mcp/localCliHealth.d.ts +2 -2
- package/dist/mcp/localCliHealth.js +2 -2
- package/dist/mcp/localServiceProxy.d.ts +1 -0
- package/dist/mcp/localServiceProxy.js +530 -68
- package/dist/mcp/planningAttachmentCommandAdapter.d.ts +3 -1
- package/dist/mcp/planningAttachmentCommandAdapter.js +20 -2
- package/dist/mcp/runtime.d.ts +54 -79
- package/dist/mcp/runtime.js +556 -139
- package/dist/mcp/taskPlanningRegistrar.js +64 -42
- package/dist/mcp/toolCallCompatibility.js +38 -1
- package/dist/mcp/toolCatalog.d.ts +1 -0
- package/dist/mcp/toolProfiles.d.ts +2 -0
- package/dist/mcp/toolProfiles.js +10 -0
- package/dist/mcp/toolRegistry.d.ts +1 -0
- package/dist/mcp/toolRegistry.js +1 -0
- package/dist/mcp/workflowExecutionRegistrar.js +4 -4
- package/dist/migrations/taskSchemaMigrations.d.ts +5 -0
- package/dist/migrations/taskSchemaMigrations.js +427 -0
- package/dist/runtime/appGateDefinitions.d.ts +30 -6
- package/dist/runtime/appGateDefinitions.js +6 -6
- package/dist/runtime/appGates.d.ts +13 -13
- package/dist/runtime/appGates.js +36 -13
- package/dist/runtime/nodeAppGates.d.ts +8 -0
- package/dist/runtime/nodeAppGates.js +27 -0
- package/dist/server/cloudCollectionRead.d.ts +1 -1
- package/dist/server/cloudCollectionRead.js +2 -2
- package/dist/server/index.d.ts +6 -0
- package/dist/server/index.js +123 -14
- package/dist/server/localDatabaseIdentity.js +4 -1
- package/dist/server/localServiceLease.d.ts +3 -0
- package/dist/server/localServiceLease.js +11 -2
- package/dist/server/localServiceSessions.d.ts +14 -17
- package/dist/server/localServiceSessions.js +308 -94
- package/dist/server/localWorkspaceSyncServerRuntime.js +12 -7
- package/dist/server/rateLimit.d.ts +1 -0
- package/dist/server/rateLimit.js +4 -0
- package/dist/server/realtimeSyncWs.js +36 -12
- package/dist/server/routes/admin.d.ts +4 -0
- package/dist/server/routes/admin.js +113 -3
- package/dist/server/routes/agentRoles.js +3 -2
- package/dist/server/routes/agentSkills.js +3 -2
- package/dist/server/routes/agents.d.ts +7 -0
- package/dist/server/routes/agents.js +394 -39
- package/dist/server/routes/annotatedAttachments.js +3 -2
- package/dist/server/routes/auth.js +3 -1
- package/dist/server/routes/billing.js +5 -1
- package/dist/server/routes/durableTaskHttpRouters.d.ts +11 -2
- package/dist/server/routes/executorPhaseAApprovals.d.ts +19 -0
- package/dist/server/routes/executorPhaseAApprovals.js +140 -0
- package/dist/server/routes/executorPhaseAIssuerRedemptions.d.ts +11 -0
- package/dist/server/routes/executorPhaseAIssuerRedemptions.js +24 -0
- package/dist/server/routes/githubReviewEvidence.d.ts +19 -0
- package/dist/server/routes/githubReviewEvidence.js +116 -0
- package/dist/server/routes/localService.d.ts +15 -4
- package/dist/server/routes/localService.js +138 -40
- package/dist/server/routes/modelConnections.d.ts +24 -0
- package/dist/server/routes/modelConnections.js +205 -0
- package/dist/server/routes/primitives.d.ts +2 -0
- package/dist/server/routes/shared.d.ts +19 -0
- package/dist/server/routes/shared.js +95 -19
- package/dist/server/routes/sync.js +1 -0
- package/dist/server/routes/syncAuxRoutes.js +9 -2
- package/dist/server/routes/syncPullApplyRoutes.js +23 -4
- package/dist/server/routes/syncPushRoutes.d.ts +1 -0
- package/dist/server/routes/syncPushRoutes.js +1 -0
- package/dist/server/routes/syncV3FeedRoutes.js +27 -16
- package/dist/server/routes/syncV3LocalCaptureRoutes.js +28 -2
- package/dist/server/routes/syncV3LocalFeedApplyRoutes.d.ts +1 -0
- package/dist/server/routes/syncV3LocalFeedApplyRoutes.js +26 -0
- package/dist/server/routes/syncV3OperationRoutes.js +45 -9
- package/dist/server/routes/tasks.js +124 -13
- package/dist/server/routes/workflows.js +9 -1
- package/dist/server/routes/workspaces.js +43 -1
- package/dist/server/routes.js +59 -0
- package/dist/server/workspaceDeletionAdmission.d.ts +23 -0
- package/dist/server/workspaceDeletionAdmission.js +50 -0
- package/dist/service/localServiceCli.js +16 -0
- package/dist/service/localServiceClientLifecycle.js +36 -10
- package/dist/services/codexAppServerModelGateway.d.ts +161 -0
- package/dist/services/codexAppServerModelGateway.js +663 -0
- package/dist/services/codexDeviceCodeLoginManager.d.ts +39 -0
- package/dist/services/codexDeviceCodeLoginManager.js +265 -0
- package/dist/services/codexModelProviderConnectionLifecycle.d.ts +8 -0
- package/dist/services/codexModelProviderConnectionLifecycle.js +73 -0
- package/dist/services/executorPhaseAApprovalRuntime.d.ts +14 -0
- package/dist/services/executorPhaseAApprovalRuntime.js +24 -0
- package/dist/services/executorPhaseAApprovalService.d.ts +40 -0
- package/dist/services/executorPhaseAApprovalService.js +609 -0
- package/dist/services/executorPhaseADriftEvaluator.d.ts +78 -0
- package/dist/services/executorPhaseADriftEvaluator.js +93 -0
- package/dist/services/executorPhaseAIssuerCore.d.ts +126 -0
- package/dist/services/executorPhaseAIssuerCore.js +295 -0
- package/dist/services/executorPhaseAIssuerRedemptionService.d.ts +34 -0
- package/dist/services/executorPhaseAIssuerRedemptionService.js +158 -0
- package/dist/services/githubReviewEvidenceRuntime.d.ts +14 -0
- package/dist/services/githubReviewEvidenceRuntime.js +30 -0
- package/dist/services/githubReviewEvidenceService.d.ts +93 -0
- package/dist/services/githubReviewEvidenceService.js +336 -0
- package/dist/services/modelGateway.d.ts +7 -0
- package/dist/services/modelProviderConnectionService.d.ts +71 -0
- package/dist/services/modelProviderConnectionService.js +279 -0
- package/dist/services/modelProviderCredentialHome.d.ts +32 -0
- package/dist/services/modelProviderCredentialHome.js +271 -0
- package/dist/services/ownerScopedModelConnectionGateway.d.ts +12 -0
- package/dist/services/ownerScopedModelConnectionGateway.js +30 -0
- package/dist/services/taskforceAgentConnectionBindingService.d.ts +66 -0
- package/dist/services/taskforceAgentConnectionBindingService.js +185 -0
- package/dist/services/taskforceAgentMcpBridge.d.ts +8 -2
- package/dist/services/taskforceAgentMcpBridge.js +30 -27
- package/dist/shared/adminEdgeProxy.d.ts +5 -0
- package/dist/shared/adminEdgeProxy.js +94 -0
- package/dist/shared/adminProxySessionCookies.d.ts +16 -0
- package/dist/shared/adminProxySessionCookies.js +86 -0
- package/dist/shared/aiProfileColors.d.ts +31 -1
- package/dist/shared/aiProfileColors.js +14 -6
- package/dist/shared/executorPhaseAApprovalGoldenVector.json +269 -0
- package/dist/shared/executorPhaseAApprovalReceipt.d.ts +112 -0
- package/dist/shared/executorPhaseAApprovalReceipt.js +58 -0
- package/dist/shared/executorPhaseAApprovalTrustPolicy.json +10 -0
- package/dist/shared/executorPhaseADriftContracts.d.ts +37 -0
- package/dist/shared/executorPhaseADriftContracts.js +63 -0
- package/dist/shared/executorPhaseAIssuerContracts.d.ts +75 -0
- package/dist/shared/executorPhaseAIssuerContracts.js +90 -0
- package/dist/shared/executorPhaseARunAuthorization.d.ts +120 -0
- package/dist/shared/executorPhaseARunAuthorization.js +232 -0
- package/dist/shared/executorPhaseASchemaValidation.d.ts +7 -0
- package/dist/shared/executorPhaseASchemaValidation.js +53 -0
- package/dist/shared/executorPhaseASchemas/approval-receipt.schema.json +106 -0
- package/dist/shared/executorPhaseASchemas/drift-attestation.schema.json +54 -0
- package/dist/shared/executorPhaseASchemas/drift-request.schema.json +47 -0
- package/dist/shared/executorPhaseASchemas/foundation-manifest.schema.json +29 -0
- package/dist/shared/executorPhaseASchemas/issuer-audit-record.schema.json +24 -0
- package/dist/shared/executorPhaseASchemas/issuer-proof.schema.json +43 -0
- package/dist/shared/executorPhaseASchemas/issuer-redemption-request.schema.json +18 -0
- package/dist/shared/executorPhaseASchemas/issuer-redemption-response.schema.json +39 -0
- package/dist/shared/executorPhaseASchemas/logical-envelope.schema.json +149 -0
- package/dist/shared/executorPhaseASchemas/preflight-report.schema.json +216 -0
- package/dist/shared/executorPhaseASchemas/run-capability.schema.json +111 -0
- package/dist/shared/executorPhaseASchemas/sender-proof.schema.json +37 -0
- package/dist/shared/executorPhaseASchemas/workload-grant.schema.json +68 -0
- package/dist/shared/executorPhaseASchemas/workload-jwt-claims.schema.json +67 -0
- package/dist/shared/executorPhaseATiming.d.ts +1 -0
- package/dist/shared/executorPhaseATiming.js +1 -0
- package/dist/shared/planningIdentity.js +1 -1
- package/dist/shared/productLogoKeys.d.ts +2 -0
- package/dist/shared/productLogoKeys.js +18 -0
- package/dist/shared/taskforceAgentDefinition.d.ts +0 -1
- package/dist/shared/taskforceAgentDefinition.js +6 -3
- package/dist/shared/taskforceAgentModels.d.ts +1 -0
- package/dist/shared/taskforceAgentModels.js +36 -3
- package/dist/shared/userFeatureGrants.d.ts +4 -0
- package/dist/shared/userFeatureGrants.js +7 -0
- package/dist/storage/executorPhaseAApprovalReceiptStore.d.ts +37 -0
- package/dist/storage/executorPhaseAApprovalReceiptStore.js +81 -0
- package/dist/storage/executorPhaseARunAuthorizationStore.d.ts +103 -0
- package/dist/storage/executorPhaseARunAuthorizationStore.js +492 -0
- package/dist/storage/githubReviewEvidenceInstallationStore.d.ts +26 -0
- package/dist/storage/githubReviewEvidenceInstallationStore.js +89 -0
- package/dist/storage/modelProviderConnectionStore.d.ts +99 -0
- package/dist/storage/modelProviderConnectionStore.js +446 -0
- package/dist/storage/postgresAdapter.d.ts +24 -3
- package/dist/storage/postgresAdapter.js +117 -14
- package/dist/storage/postgresWorker.js +22 -5
- package/dist/storage/postgresWorkerProtocol.d.ts +30 -0
- package/dist/storage/postgresWorkerProtocol.js +30 -0
- package/dist/storage/taskforceAgentConnectionBindingStore.d.ts +31 -0
- package/dist/storage/taskforceAgentConnectionBindingStore.js +84 -0
- package/dist/sync/cloudSyncApi.d.ts +4 -1
- package/dist/sync/cloudSyncApi.js +7 -2
- package/dist/sync/contentSyncState.d.ts +1 -1
- package/dist/sync/coordinator/localSyncExecutionPermitStore.d.ts +1 -0
- package/dist/sync/coordinator/localSyncExecutionPermitStore.js +67 -30
- package/dist/sync/coordinator/localWorkspaceSyncPendingV2PushProgress.d.ts +10 -0
- package/dist/sync/coordinator/localWorkspaceSyncPendingV2PushProgress.js +29 -0
- package/dist/sync/coordinator/localWorkspaceSyncRunner.js +6 -2
- package/dist/sync/coordinator/localWorkspaceSyncRunnerState.d.ts +15 -1
- package/dist/sync/coordinator/localWorkspaceSyncRunnerState.js +99 -2
- package/dist/sync/coordinator/workspaceSyncCredentialBroker.d.ts +1 -0
- package/dist/sync/coordinator/workspaceSyncCredentialBroker.js +33 -4
- package/dist/sync/engine/workspaceSyncContentLifecycleAdapter.d.ts +2 -1
- package/dist/sync/engine/workspaceSyncContentVersionStore.d.ts +38 -0
- package/dist/sync/engine/workspaceSyncContentVersionStore.js +50 -1
- package/dist/sync/engine/workspaceSyncEngineBrowserGatewayRemoteServices.js +20 -2
- package/dist/sync/engine/workspaceSyncEngineLifecyclePolicy.js +6 -6
- package/dist/sync/engine/workspaceSyncEngineLocalServices.d.ts +4 -0
- package/dist/sync/engine/workspaceSyncEngineLocalServices.js +11 -0
- package/dist/sync/engine/workspaceSyncEnginePushCompletion.d.ts +14 -0
- package/dist/sync/engine/workspaceSyncEnginePushCompletion.js +84 -0
- package/dist/sync/engine/workspaceSyncEngineRecovery.js +1 -0
- package/dist/sync/engine/workspaceSyncEngineRemoteServices.d.ts +11 -0
- package/dist/sync/engine/workspaceSyncEngineRemoteServices.js +2 -1
- package/dist/sync/engine/workspaceSyncEngineRuntime.d.ts +1 -0
- package/dist/sync/engine/workspaceSyncEngineRuntime.js +1 -0
- package/dist/sync/engine/workspaceSyncEngineServerRemoteServices.js +31 -4
- package/dist/sync/engine/workspaceSyncEngineServerRunnerOperations.d.ts +3 -1
- package/dist/sync/engine/workspaceSyncEngineServerRunnerOperations.js +134 -43
- package/dist/sync/engine/workspaceSyncEngineServerSnapshotReader.js +6 -0
- package/dist/sync/engine/workspaceSyncEngineTransfers.d.ts +1 -1
- package/dist/sync/engine/workspaceSyncEngineTransfers.js +11 -4
- package/dist/sync/engine/workspaceSyncV2ChangeDispatcher.d.ts +1 -0
- package/dist/sync/engine/workspaceSyncV2ChangeDispatcher.js +29 -0
- package/dist/sync/syncApplyHandlers.d.ts +2 -0
- package/dist/sync/syncApplyHandlers.js +10 -1
- package/dist/sync/syncService.d.ts +17 -0
- package/dist/sync/syncService.js +87 -19
- package/dist/sync/taskforceAgentSyncAuthorization.d.ts +16 -0
- package/dist/sync/taskforceAgentSyncAuthorization.js +20 -0
- package/dist/sync/v3/combinedFeedCapability.js +8 -0
- package/dist/sync/v3/durableInitiativeMutationRouter.js +18 -10
- package/dist/sync/v3/durableOperationReplay.d.ts +14 -0
- package/dist/sync/v3/durableOperationReplay.js +18 -0
- package/dist/sync/v3/durableTaskAttachmentLinksMutationRouter.d.ts +2 -0
- package/dist/sync/v3/durableTaskAttachmentLinksMutationRouter.js +14 -1
- package/dist/sync/v3/durableTaskChecklistMutationRouter.d.ts +4 -1
- package/dist/sync/v3/durableTaskChecklistMutationRouter.js +62 -15
- package/dist/sync/v3/durableTaskCommentMutationRouter.js +3 -0
- package/dist/sync/v3/durableTaskHttpBulkMutationRouter.d.ts +1 -0
- package/dist/sync/v3/durableTaskHttpBulkMutationRouter.js +30 -8
- package/dist/sync/v3/durableTaskHttpRootMutationRouter.d.ts +5 -3
- package/dist/sync/v3/durableTaskHttpRootMutationRouter.js +37 -2
- package/dist/sync/v3/durableTaxonomyMutationRouter.js +5 -0
- package/dist/sync/v3/durableWorkflowRuntimeMutationRouter.d.ts +11 -0
- package/dist/sync/v3/durableWorkflowRuntimeMutationRouter.js +39 -10
- package/dist/sync/v3/durableWorkstreamMutationRouter.js +18 -10
- package/dist/sync/v3/durableWorkstreamTaskOrderMutationRouter.js +16 -5
- package/dist/sync/v3/localOutboxDispatchRuntime.js +2 -2
- package/dist/sync/v3/localTaskAttachmentLinksOutboxService.d.ts +2 -0
- package/dist/sync/v3/localTaskAttachmentLinksOutboxService.js +47 -7
- package/dist/sync/v3/localTaskChecklistOutboxHandler.js +16 -2
- package/dist/sync/v3/localTaskChecklistOutboxService.d.ts +4 -0
- package/dist/sync/v3/localTaskChecklistOutboxService.js +14 -1
- package/dist/sync/v3/localTaskCreateOutboxService.js +15 -6
- package/dist/sync/v3/localTaskMetadataClient.d.ts +1 -0
- package/dist/sync/v3/localTaskMetadataClient.js +1 -0
- package/dist/sync/v3/localTaskMetadataOutboxHandler.js +5 -1
- package/dist/sync/v3/localTaskMetadataOutboxService.d.ts +2 -0
- package/dist/sync/v3/localTaskMetadataOutboxService.js +7 -0
- package/dist/sync/v3/localTaskRestoreOutboxService.js +14 -6
- package/dist/sync/v3/localTaskStatusClient.d.ts +1 -0
- package/dist/sync/v3/localTaskStatusClient.js +6 -1
- package/dist/sync/v3/localTaskStatusOutboxService.d.ts +10 -0
- package/dist/sync/v3/localTaskStatusOutboxService.js +272 -24
- package/dist/sync/v3/syncDurabilityStore.d.ts +41 -0
- package/dist/sync/v3/syncDurabilityStore.js +199 -13
- package/dist/sync/v3/taskAttachmentLinksMutationService.d.ts +6 -4
- package/dist/sync/v3/taskAttachmentLinksMutationService.js +19 -10
- package/dist/sync/v3/taskChecklistMutationService.d.ts +15 -2
- package/dist/sync/v3/taskChecklistMutationService.js +48 -1
- package/dist/sync/v3/taskCreateMutationService.d.ts +2 -2
- package/dist/sync/v3/taskCreateMutationService.js +7 -4
- package/dist/sync/v3/taskMetadataMutationService.d.ts +3 -0
- package/dist/sync/v3/taskMetadataMutationService.js +4 -0
- package/dist/sync/v3/taskRestoreMutationService.d.ts +2 -2
- package/dist/sync/v3/taskRestoreMutationService.js +7 -4
- package/dist/sync/v3/taskStatusMutationService.d.ts +31 -1
- package/dist/sync/v3/taskStatusMutationService.js +123 -3
- package/dist/sync/v3/workflowAssignmentSync.d.ts +6 -0
- package/dist/sync/v3/workflowAssignmentSync.js +30 -0
- package/dist/sync/v3/workspaceSyncJournalReader.js +1 -1
- package/dist/sync/v3/workspaceSyncOperationRetentionService.d.ts +16 -0
- package/dist/sync/v3/workspaceSyncOperationRetentionService.js +83 -0
- package/dist/sync/v3/workspaceSyncV2ProjectionExclusions.d.ts +1 -1
- package/dist/sync/v3/workspaceSyncV2ProjectionExclusions.js +13 -3
- package/dist/sync/v3/workspaceSyncV3AttachmentApplyObligationStore.d.ts +11 -0
- package/dist/sync/v3/workspaceSyncV3AttachmentApplyObligationStore.js +27 -10
- package/dist/sync/v3/workspaceSyncV3AttachmentAssetHydration.d.ts +2 -1
- package/dist/sync/v3/workspaceSyncV3AttachmentAssetHydration.js +52 -10
- package/dist/sync/v3/workspaceSyncV3CloudOperationHandler.d.ts +1 -0
- package/dist/sync/v3/workspaceSyncV3CloudOperationHandler.js +18 -3
- package/dist/sync/v3/workspaceSyncV3CombinedFeedOrchestrator.js +8 -3
- package/dist/sync/v3/workspaceSyncV3CombinedLocalApply.js +51 -10
- package/dist/sync/v3/workspaceSyncV3CombinedRepairBaseline.d.ts +14 -0
- package/dist/sync/v3/workspaceSyncV3CombinedRepairBaseline.js +49 -25
- package/dist/sync/v3/workspaceSyncV3CombinedRepairMaterialization.d.ts +13 -4
- package/dist/sync/v3/workspaceSyncV3CombinedRepairMaterialization.js +124 -57
- package/dist/sync/v3/workspaceSyncV3CombinedRepairSnapshot.d.ts +20 -0
- package/dist/sync/v3/workspaceSyncV3CombinedRepairSnapshot.js +106 -30
- package/dist/sync/v3/workspaceSyncV3CombinedWireContract.d.ts +4 -1
- package/dist/sync/v3/workspaceSyncV3CombinedWireContract.js +34 -0
- package/dist/sync/v3/workspaceSyncV3CoverageRegistry.js +12 -0
- package/dist/sync/v3/workspaceSyncV3FeedProfile.d.ts +1 -1
- package/dist/sync/v3/workspaceSyncV3LegacyBoundaryAttestation.d.ts +1 -0
- package/dist/sync/v3/workspaceSyncV3LegacyBoundaryAttestation.js +23 -10
- package/dist/sync/v3/workspaceSyncV3NestedTaskApply.d.ts +3 -0
- package/dist/sync/v3/workspaceSyncV3NestedTaskApply.js +64 -13
- package/dist/sync/v3/workspaceSyncV3NestedTaskCodecs.d.ts +9 -0
- package/dist/sync/v3/workspaceSyncV3NestedTaskCodecs.js +26 -0
- package/dist/sync/v3/workspaceSyncV3NestedTaskProjection.d.ts +15 -5
- package/dist/sync/v3/workspaceSyncV3NestedTaskProjection.js +50 -14
- package/dist/sync/v3/workspaceSyncV3NestedTaskRepairSnapshot.d.ts +2 -1
- package/dist/sync/v3/workspaceSyncV3NestedTaskRepairSnapshot.js +11 -3
- package/dist/sync/v3/workspaceSyncV3OperationProtocol.d.ts +5 -0
- package/dist/sync/v3/workspaceSyncV3OperatorDiagnostics.d.ts +7 -0
- package/dist/sync/v3/workspaceSyncV3OperatorDiagnostics.js +55 -9
- package/dist/sync/v3/workspaceSyncV3RepairSnapshotRetentionService.d.ts +17 -0
- package/dist/sync/v3/workspaceSyncV3RepairSnapshotRetentionService.js +64 -0
- package/dist/sync/v3/workspaceSyncV3TaskCommentAudit.js +9 -2
- package/dist/sync/v3/workspaceSyncV3TaskCoverCoverage.d.ts +7 -0
- package/dist/sync/v3/workspaceSyncV3TaskCoverCoverage.js +37 -0
- package/dist/sync/v3/workspaceSyncV3TaskCoverWireContract.d.ts +6 -0
- package/dist/sync/v3/workspaceSyncV3TaskCoverWireContract.js +9 -0
- package/dist/sync/v3/workspaceSyncV3WorkflowTaskCoverCoverage.d.ts +7 -0
- package/dist/sync/v3/workspaceSyncV3WorkflowTaskCoverCoverage.js +33 -0
- package/dist/sync/v3/workspaceSyncV3WorkflowTaskCoverWireContract.d.ts +7 -0
- package/dist/sync/v3/workspaceSyncV3WorkflowTaskCoverWireContract.js +8 -0
- package/dist/sync/workspacePullFeed.js +2 -1
- package/dist/sync/workspaceRepair.d.ts +8 -2
- package/dist/sync/workspaceRepair.js +222 -6
- package/dist/sync/workspaceSyncModel.d.ts +21 -0
- package/dist/sync/workspaceSyncModel.js +35 -7
- package/dist/sync/workspaceSyncState.d.ts +1 -0
- package/dist/sync/workspaceSyncV2SnapshotBuilder.d.ts +6 -0
- package/dist/sync/workspaceSyncV2SnapshotBuilder.js +5 -0
- package/dist/types.d.ts +47 -1
- package/dist/types.js +6 -0
- package/dist/ui/assets/AiIdentityRosterCard-OcSz1PkK.js +1 -0
- package/dist/ui/assets/AiProfilesModule-ByhYW5Xi.js +1 -0
- package/dist/ui/assets/AnnotatedAttachmentWorkspace-BTM6nIg_.js +3 -0
- package/dist/ui/assets/AnnotatedAttachmentWorkspace-TzYu7pkG.css +1 -0
- package/dist/ui/assets/{AssetTraySortControl-Kf1pelSy.js → AssetTraySortControl-DabEG8L4.js} +1 -1
- package/dist/ui/assets/{ContextAttachmentManager-B8boOs6Q.js → ContextAttachmentManager-Coa8yVGM.js} +2 -2
- package/dist/ui/assets/{DocumentWorkspace-DXH4XUsB.js → DocumentWorkspace-BB0qhdix.js} +1 -1
- package/dist/ui/assets/{EntityActivityTimeline-BtSTq0ON.js → EntityActivityTimeline-CZ8x4UJE.js} +1 -1
- package/dist/ui/assets/PlanningModule-pRPjR7v5.js +1 -0
- package/dist/ui/assets/PlansPage-D86pZSSl.js +1 -0
- package/dist/ui/assets/TaskContextUpload-BVIkU9yT.js +1 -0
- package/dist/ui/assets/TaskSettings-Cv1mNhv_.js +12 -0
- package/dist/ui/assets/TaskforceAgentsModule-b-8R25cJ.css +1 -0
- package/dist/ui/assets/TaskforceAgentsModule-gmH-PD2q.js +24 -0
- package/dist/ui/assets/{WorkflowManagerModule-DWFspC-o.js → WorkflowManagerModule-DbfnHJ-f.js} +1 -1
- package/dist/ui/assets/index-BZ-hdZSk.css +1 -0
- package/dist/ui/assets/index-CTsDBaef.js +7 -0
- package/dist/ui/assets/{vendor-icons-BkFLXavV.js → vendor-icons-Bsq-mcEn.js} +1 -1
- package/dist/ui/branding/logos/letterhead_dark.png +0 -0
- package/dist/ui/branding/logos/letterhead_light.png +0 -0
- package/dist/ui/branding/logos/signature_dark.png +0 -0
- package/dist/ui/branding/logos/signature_light.png +0 -0
- package/dist/ui/index.html +3 -3
- package/dist/utils/aiProfileDefaultLogo.js +16 -48
- package/dist/utils/httpSetCookie.d.ts +1 -0
- package/dist/utils/httpSetCookie.js +4 -1
- package/dist/utils/localRuntimeUrl.d.ts +1 -0
- package/dist/utils/localRuntimeUrl.js +14 -0
- package/dist/utils/productLogoRegistry.d.ts +2 -0
- package/dist/utils/productLogoRegistry.js +36 -0
- package/dist/utils/syncStatusPresentation.d.ts +4 -0
- package/dist/utils/syncStatusPresentation.js +17 -0
- package/dist/utils/taskActivity.d.ts +3 -2
- package/dist/utils/taskActivity.js +19 -2
- package/dist/utils/taskEditorReconciliation.d.ts +40 -0
- package/dist/utils/taskEditorReconciliation.js +217 -0
- package/dist/utils/taskEvents.d.ts +2 -0
- package/dist/utils/taskNormalization.d.ts +1 -0
- package/dist/utils/taskNormalization.js +39 -0
- package/dist/utils/taskSearch.js +2 -2
- package/dist/utils/uiNotice.d.ts +4 -0
- package/dist/utils/workspaceSyncPresentation.d.ts +1 -1
- package/dist/utils/workspaceSyncPresentation.js +23 -17
- package/package.json +36 -6
- package/dist/ui/assets/AiIdentityRosterCard-MZs7lVED.js +0 -1
- package/dist/ui/assets/AiProfilesModule-C3i0LOxe.js +0 -1
- package/dist/ui/assets/AnnotatedAttachmentWorkspace-CBRZ8rca.css +0 -1
- package/dist/ui/assets/AnnotatedAttachmentWorkspace-DVZk5Tln.js +0 -3
- package/dist/ui/assets/PlanningModule-BPVyEa-f.js +0 -1
- package/dist/ui/assets/PlansPage-ChqgxALc.js +0 -1
- package/dist/ui/assets/TaskContextUpload-CB3ol0sN.js +0 -1
- package/dist/ui/assets/TaskSettings-g4ECKNOz.js +0 -12
- package/dist/ui/assets/TaskforceAgentsModule-BazdUwxZ.js +0 -21
- package/dist/ui/assets/TaskforceAgentsModule-D6IC0S7Q.css +0 -1
- package/dist/ui/assets/index-BUplSsv_.js +0 -7
- package/dist/ui/assets/index-gz2EXuoK.css +0 -1
package/dist/utils/uiNotice.d.ts
CHANGED
|
@@ -5,6 +5,10 @@ export interface UiNotice {
|
|
|
5
5
|
ttlMs?: number;
|
|
6
6
|
actionLabel?: string;
|
|
7
7
|
onAction?: () => void;
|
|
8
|
+
actionPrimary?: boolean;
|
|
9
|
+
secondaryActionLabel?: string;
|
|
10
|
+
onSecondaryAction?: () => void;
|
|
11
|
+
dismissible?: boolean;
|
|
8
12
|
ownerKey?: string;
|
|
9
13
|
}
|
|
10
14
|
export declare function resolveUiNoticeTtl(tone: UiNoticeTone, ttlMs?: number): number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LocalSyncCoordinatorStatusResponse } from '../sync/coordinator/localSyncCoordinatorBrowserClient';
|
|
2
|
-
export type HeaderWorkspaceSyncStatus = 'off' | 'syncing' | 'attention' | 'healthy';
|
|
2
|
+
export type HeaderWorkspaceSyncStatus = 'off' | 'checking' | 'syncing' | 'attention' | 'healthy';
|
|
3
3
|
type WorkspaceSyncBlockedReason = 'cloud-auth-unconfigured' | 'runtime-not-local' | 'sync-disabled' | 'invalid-workspace' | 'repair-active' | 'attach-cloud' | 'provision-local' | 'auth-required' | 'push-in-flight' | 'pull-in-flight' | 'retry-pending' | 'lease-held';
|
|
4
4
|
interface ResolveHeaderWorkspaceSyncPresentationInput {
|
|
5
5
|
runtimeMode: 'local' | 'cloud';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolveLocalWorkspaceSyncPendingV2PushProgress } from '../sync/coordinator/localWorkspaceSyncPendingV2PushProgress';
|
|
1
2
|
export function isWorkspaceSyncAuthenticationError(message) {
|
|
2
3
|
return /\btaskforce session is invalid\b|\bauthenticated taskforce session is required\b/i
|
|
3
4
|
.test(message || '');
|
|
@@ -7,23 +8,20 @@ export function resolveCoordinatorWorkspaceSyncPresentation(source) {
|
|
|
7
8
|
return null;
|
|
8
9
|
const snapshot = source.snapshot;
|
|
9
10
|
if (source.phase !== 'ready') {
|
|
10
|
-
if (snapshot?.state.ownershipMode === 'browser-gateway' && source.phase !== 'error') {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
11
|
const unavailable = source.phase === 'error';
|
|
14
12
|
const authenticationRequired = isWorkspaceSyncAuthenticationError(source.errorMessage);
|
|
15
13
|
return {
|
|
16
14
|
header: {
|
|
17
|
-
actionable:
|
|
18
|
-
status: unavailable ? 'attention' : '
|
|
15
|
+
actionable: unavailable,
|
|
16
|
+
status: unavailable ? 'attention' : 'checking',
|
|
19
17
|
syncEnabledLabel: 'unknown',
|
|
20
18
|
summary: unavailable
|
|
21
19
|
? 'The shared sync coordinator status is unavailable.'
|
|
22
20
|
: 'Reading shared sync coordinator status.',
|
|
23
21
|
recommendedAction: unavailable
|
|
24
22
|
? authenticationRequired
|
|
25
|
-
? 'Sign out and sign back in
|
|
26
|
-
: '
|
|
23
|
+
? 'Sign out and sign back in so automatic sync can resume.'
|
|
24
|
+
: 'Wait for automatic recovery. If the coordinator remains unavailable, restart the local server.'
|
|
27
25
|
: 'Wait for the coordinator status check to finish.',
|
|
28
26
|
lastError: source.errorMessage || (unavailable ? 'Coordinator status unavailable.' : 'None'),
|
|
29
27
|
},
|
|
@@ -61,8 +59,16 @@ export function resolveCoordinatorWorkspaceSyncPresentation(source) {
|
|
|
61
59
|
const recoveryObligations = snapshot.permits.recoveryObligations;
|
|
62
60
|
const pendingV2Push = checkpoint?.pendingV2Push || null;
|
|
63
61
|
const pushBatchProgress = pendingV2Push?.lastBatchProgress || null;
|
|
64
|
-
const
|
|
65
|
-
|
|
62
|
+
const effectivePushProgress = resolveLocalWorkspaceSyncPendingV2PushProgress(pendingV2Push);
|
|
63
|
+
const pendingV2PushChangeCount = effectivePushProgress?.remainingChanges
|
|
64
|
+
?? Math.max(0, (pendingV2Push?.frozenPayload.changes.length || 0)
|
|
65
|
+
- (pushBatchProgress?.completedChanges || 0));
|
|
66
|
+
const settledPushBatches = effectivePushProgress?.settledBatches
|
|
67
|
+
?? pushBatchProgress?.completedBatches
|
|
68
|
+
?? 0;
|
|
69
|
+
const totalPushBatches = effectivePushProgress?.effectiveTotalBatches
|
|
70
|
+
?? pushBatchProgress?.totalBatches
|
|
71
|
+
?? 0;
|
|
66
72
|
const contentPushBlocked = Boolean(pushBatchProgress
|
|
67
73
|
&& (pushBatchProgress.failureDomain === 'content'
|
|
68
74
|
|| pushBatchProgress.failureDomain === 'mixed')
|
|
@@ -95,7 +101,7 @@ export function resolveCoordinatorWorkspaceSyncPresentation(source) {
|
|
|
95
101
|
else if (runnerUnavailable) {
|
|
96
102
|
status = 'attention';
|
|
97
103
|
summary = 'The shared sync runner is unavailable.';
|
|
98
|
-
recommendedAction = '
|
|
104
|
+
recommendedAction = 'Wait for automatic recovery. If the runner does not recover, restart the local server.';
|
|
99
105
|
}
|
|
100
106
|
else if (attachmentApplyOpen > 0) {
|
|
101
107
|
status = 'attention';
|
|
@@ -120,7 +126,7 @@ export function resolveCoordinatorWorkspaceSyncPresentation(source) {
|
|
|
120
126
|
summary = `${pushBatchProgress.failedChangeCount} ${failedChangeKind} ${pushBatchProgress.failedChangeCount === 1 ? 'change is' : 'changes are'} waiting to retry; ${pendingV2PushChangeCount} total push ${pendingV2PushChangeCount === 1 ? 'change remains' : 'changes remain'}.`;
|
|
121
127
|
recommendedAction = checkpoint && !checkpoint.syncEnabled
|
|
122
128
|
? 'Turn on sync to resume the bounded content retry.'
|
|
123
|
-
: 'Wait for the scheduled content retry
|
|
129
|
+
: 'Wait for the scheduled content retry.';
|
|
124
130
|
}
|
|
125
131
|
else if (checkpoint && !checkpoint.syncEnabled) {
|
|
126
132
|
status = 'off';
|
|
@@ -131,12 +137,12 @@ export function resolveCoordinatorWorkspaceSyncPresentation(source) {
|
|
|
131
137
|
else if (runnerError && !runnerOperationActive) {
|
|
132
138
|
status = 'attention';
|
|
133
139
|
summary = checkpoint?.lastError || 'The shared sync runner reported an error.';
|
|
134
|
-
recommendedAction = '
|
|
140
|
+
recommendedAction = 'Wait for the automatic retry. If the same issue returns, press Repair.';
|
|
135
141
|
}
|
|
136
142
|
else if (retryWait) {
|
|
137
143
|
status = 'attention';
|
|
138
144
|
summary = 'Sync is waiting for a scheduled retry.';
|
|
139
|
-
recommendedAction = 'Wait for the retry
|
|
145
|
+
recommendedAction = 'Wait for the scheduled retry.';
|
|
140
146
|
}
|
|
141
147
|
else if (baselineUnknown) {
|
|
142
148
|
status = 'attention';
|
|
@@ -208,7 +214,7 @@ export function resolveCoordinatorWorkspaceSyncPresentation(source) {
|
|
|
208
214
|
label: 'Content push backlog',
|
|
209
215
|
value: contentPushBlocked
|
|
210
216
|
? `${pushBatchProgress.failedChangeCount} blocked ${pushBatchProgress.failureDomain === 'content' ? 'content' : 'push'} ${pushBatchProgress.failedChangeCount === 1 ? 'change' : 'changes'}; ${pendingV2PushChangeCount} total push ${pendingV2PushChangeCount === 1 ? 'change remains' : 'changes remain'}; `
|
|
211
|
-
+ `${
|
|
217
|
+
+ `${settledPushBatches}/${totalPushBatches} batches settled`
|
|
212
218
|
: 'None',
|
|
213
219
|
},
|
|
214
220
|
{
|
|
@@ -227,7 +233,7 @@ function resolveBlockedReasonPresentation(reason) {
|
|
|
227
233
|
case 'auth-required':
|
|
228
234
|
return {
|
|
229
235
|
summary: 'Sync is paused until you sign in again.',
|
|
230
|
-
recommendedAction: 'Sign in
|
|
236
|
+
recommendedAction: 'Sign in so automatic sync can resume.'
|
|
231
237
|
};
|
|
232
238
|
case 'attach-cloud':
|
|
233
239
|
return {
|
|
@@ -242,12 +248,12 @@ function resolveBlockedReasonPresentation(reason) {
|
|
|
242
248
|
case 'repair-active':
|
|
243
249
|
return {
|
|
244
250
|
summary: 'Repair is already running for this workspace.',
|
|
245
|
-
recommendedAction: 'Wait for repair to finish
|
|
251
|
+
recommendedAction: 'Wait for repair to finish.'
|
|
246
252
|
};
|
|
247
253
|
case 'retry-pending':
|
|
248
254
|
return {
|
|
249
255
|
summary: 'Sync hit a temporary problem and is waiting for its scheduled retry.',
|
|
250
|
-
recommendedAction: 'Wait for the automatic retry
|
|
256
|
+
recommendedAction: 'Wait for the automatic retry.'
|
|
251
257
|
};
|
|
252
258
|
case 'lease-held':
|
|
253
259
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taskforcehq/taskforce",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.330",
|
|
4
4
|
"description": "Shared task and planning workspace for humans collaborating with AI (public beta)",
|
|
5
5
|
"author": "Taskforce HQ <hello@taskforcehq.ai> (https://taskforcehq.ai)",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -61,12 +61,13 @@
|
|
|
61
61
|
"build:app": "vite build --config vite.config.standalone.ts",
|
|
62
62
|
"build:ui": "npm run build:app",
|
|
63
63
|
"check:verified": "sh scripts/run-validation-command.sh",
|
|
64
|
-
"check:deploy-preflight": "npm run build",
|
|
64
|
+
"check:deploy-preflight": "npm run build && npm run build:site && npm run build:admin",
|
|
65
65
|
"hooks:install": "git config core.hooksPath .githooks",
|
|
66
66
|
"build": "shx rm -rf dist && tsc && shx cp src/Taskforce.module.css dist/Taskforce.module.css && shx mkdir -p dist/styles && shx cp src/styles/fonts.css dist/styles/fonts.css && shx mkdir -p dist/assets/fonts && shx cp src/assets/fonts/*.woff2 dist/assets/fonts/ && shx mkdir -p dist/public && shx cp -r src/assets/images/* dist/public/ && shx cp -r src/assets/favicon/* dist/public/ && shx chmod +x dist/cli.js && npm run build:ui",
|
|
67
67
|
"mcp": "node dist/cli.js mcp",
|
|
68
68
|
"gen:mcp-contract": "node --import tsx scripts/generate-mcp-contract.ts",
|
|
69
69
|
"check:mcp-contract": "node --import tsx scripts/generate-mcp-contract.ts --check",
|
|
70
|
+
"measure:agent-prefix-cost": "node scripts/measure-agent-prefix-cost.mjs",
|
|
70
71
|
"cleanup:legacy-ai-avatars": "node --import tsx scripts/cleanup-legacy-ai-profile-avatar-assets.ts",
|
|
71
72
|
"db:export:postgres": "node scripts/export-sqlite-to-postgres.mjs",
|
|
72
73
|
"check:localization-strings": "node scripts/check-localization-strings.mjs",
|
|
@@ -87,7 +88,7 @@
|
|
|
87
88
|
"test:sync:recovery:coordinator": "vitest run src/test/syncRecoveryGate.test.ts src/test/syncRecoveryCoordinatorOwnership.test.ts src/test/syncRecoveryExecutionPermitExpiry.test.ts",
|
|
88
89
|
"test:sqlite:multiprocess": "TASKFORCE_SQLITE_MULTIPROCESS_GATE=true vitest run src/storage/sqliteWalMultiprocess.integration.test.ts",
|
|
89
90
|
"test:mcp:shared-local:gate-b": "npm run build && TASKFORCE_SHARED_LOCAL_MCP_GATE_B=true vitest run src/mcp/proxyServerBoundary.test.ts src/mcp/sharedLocalService.acceptance.test.ts",
|
|
90
|
-
"test:mcp:shared-local:gate-c": "npm run build && TASKFORCE_SHARED_LOCAL_OPEN_GATE_C=true vitest run src/service/localServiceClientLifecycle.test.ts src/server/localServiceLease.test.ts src/service/localServiceOpen.test.ts src/service/localServiceOpen.acceptance.test.ts",
|
|
91
|
+
"test:mcp:shared-local:gate-c": "npm run build && TASKFORCE_SHARED_LOCAL_OPEN_GATE_C=true vitest run --exclude '.worktrees/**' src/service/localServiceClientLifecycle.test.ts src/server/localServiceLease.test.ts src/service/localServiceOpen.test.ts src/service/localServiceOpen.acceptance.test.ts",
|
|
91
92
|
"test:mcp:shared-local:gate-d": "vitest run src/mcp/sharedLocalService.gateD.acceptance.test.ts",
|
|
92
93
|
"gate:mcp:shared-local:d:init": "node --import tsx scripts/run-shared-local-mcp-gate-d.ts --init",
|
|
93
94
|
"gate:mcp:shared-local:d:prerequisites": "node --import tsx scripts/run-shared-local-mcp-gate-d.ts --run-prerequisites",
|
|
@@ -103,6 +104,17 @@
|
|
|
103
104
|
"test:soak:stress": "SYNC_SOAK_PROFILE=stress sh scripts/run-soak.sh",
|
|
104
105
|
"test:soak:overnight": "SYNC_SOAK_PROFILE=overnight sh scripts/run-soak.sh",
|
|
105
106
|
"test:aqr:contract": "vitest run scripts/aqr/execution-capsule.test.ts",
|
|
107
|
+
"test:aqr:sync-coverage": "vitest run scripts/aqr/sync-coverage-contract.test.ts",
|
|
108
|
+
"test:aqr:multi-client": "vitest run scripts/aqr/multi-client-replay.test.ts scripts/aqr/qa-multi-client-adapter.test.ts",
|
|
109
|
+
"test:aqr:convergence": "vitest run scripts/aqr/convergence-oracle.test.ts",
|
|
110
|
+
"test:aqr:pr-sync-gate:contract": "vitest run scripts/aqr/pr-sync-gate.test.ts",
|
|
111
|
+
"test:aqr:pr-sync-gate": "node --import tsx scripts/aqr/pr-sync-gate.ts",
|
|
112
|
+
"test:aqr:sync-fault-matrix:contract": "vitest run scripts/aqr/sync-fault-matrix.test.ts",
|
|
113
|
+
"test:aqr:sync-fault-matrix": "node --import tsx scripts/aqr/sync-fault-matrix.ts",
|
|
114
|
+
"test:aqr:cloud-writers:contract": "vitest run scripts/aqr/cloud-writer-acceptance.test.ts",
|
|
115
|
+
"test:aqr:cloud-writers": "node --import tsx scripts/aqr/cloud-writer-acceptance.ts",
|
|
116
|
+
"test:aqr:remote-sync:contract": "vitest run scripts/aqr/remote-sync-run.test.ts && node --test scripts/aqr/reap-digitalocean-runners.test.mjs",
|
|
117
|
+
"test:aqr:remote-sync": "node --import tsx scripts/aqr/remote-sync-run.ts",
|
|
106
118
|
"aqr:smoke": "node --import tsx scripts/run-aqr-capsule.ts --contract-smoke",
|
|
107
119
|
"test:e2e:realtime": "sh scripts/run-e2e-realtime.sh",
|
|
108
120
|
"test:e2e:realtime:release": "npm run test:e2e:realtime -- tests/e2e/attachment-sync.spec.ts tests/e2e/realtime-multiclient.spec.ts tests/e2e/realtime-reconnect.spec.ts",
|
|
@@ -110,13 +122,14 @@
|
|
|
110
122
|
"test:e2e:realtime:multiclient": "npm run test:e2e:realtime -- tests/e2e/realtime-multiclient.spec.ts",
|
|
111
123
|
"test:e2e:realtime:reconnect": "npm run test:e2e:realtime -- tests/e2e/realtime-reconnect.spec.ts",
|
|
112
124
|
"test:e2e:sync-coordinator": "SYNC_COORDINATOR_CANARY_ENABLED=true npm run test:e2e:realtime -- tests/e2e/sync-coordinator-multiclient.spec.ts",
|
|
113
|
-
"test:e2e:sync-coordinator:workspace-switch": "SYNC_COORDINATOR_WORKSPACE_SWITCH_CANARY_ENABLED=true npm run test:e2e:realtime -- tests/e2e/sync-coordinator-workspace-switch.spec.ts",
|
|
125
|
+
"test:e2e:sync-coordinator:workspace-switch": "SYNC_SOAK_CLOUD_BASE_URL=${SYNC_SOAK_CLOUD_BASE_URL:-https://staging-app.taskforcehq.ai} SYNC_COORDINATOR_WORKSPACE_SWITCH_CANARY_ENABLED=true npm run test:e2e:realtime -- tests/e2e/sync-coordinator-workspace-switch.spec.ts",
|
|
114
126
|
"test:e2e:sync-coordinator:process": "npm run test:e2e:realtime -- tests/e2e/sync-coordinator-process-ownership.spec.ts",
|
|
115
127
|
"test:e2e:realtime:durable-task-metadata": "npm run test:e2e:realtime -- tests/e2e/durable-task-metadata-canary.spec.ts",
|
|
116
128
|
"test:e2e:realtime:durable-task-create": "npm run test:e2e:realtime -- tests/e2e/durable-task-create-canary.spec.ts",
|
|
117
129
|
"test:e2e:realtime:durable-initiative": "npm run test:e2e:realtime -- tests/e2e/durable-initiative-canary.spec.ts",
|
|
118
130
|
"test:e2e:realtime:durable-initiative-feed": "SYNC_V3_INITIATIVE_FEED_CANARY_ENABLED=true npm run test:e2e:realtime:durable-initiative",
|
|
119
131
|
"test:e2e:realtime:durable-combined-feed": "SYNC_V3_COMBINED_CANARY_ENABLED=true npm run test:e2e:realtime -- tests/e2e/durable-combined-feed-canary.spec.ts",
|
|
132
|
+
"test:e2e:realtime:durable-workflow-runtime-v8": "SYNC_V3_WORKFLOW_RUNTIME_V8_CANARY_ENABLED=true npm run test:e2e:realtime -- tests/e2e/durable-workflow-runtime-v8-canary.spec.ts",
|
|
120
133
|
"test:e2e:onboarding": "npx playwright test -c playwright.e2e.config.ts tests/e2e/auth-runtime.spec.ts tests/e2e/billing-runtime.spec.ts",
|
|
121
134
|
"test:billing:deterministic": "npx vitest run src/server/routes/billing.test.ts src/components/views/PlansPage.test.tsx src/components/views/PlanComparisonPage.test.tsx src/migrations/billingSchemaParity.test.ts",
|
|
122
135
|
"test:billing:runtime:mock": "npx playwright test -c playwright.e2e.config.ts tests/e2e/billing-runtime.spec.ts",
|
|
@@ -130,6 +143,8 @@
|
|
|
130
143
|
"mailpit:down": "docker compose -f docker-compose.mailpit.yml down",
|
|
131
144
|
"mailpit:check": "node scripts/check-mailpit.mjs",
|
|
132
145
|
"qa:railway:check": "node scripts/check-railway-qa-access.mjs",
|
|
146
|
+
"verify:performance-deploy": "node scripts/wait-for-performance-deploy.mjs",
|
|
147
|
+
"test:performance-deploy-verifier": "node --test scripts/wait-for-performance-deploy.test.mjs",
|
|
133
148
|
"playwright:interactive": "playwright test -c playwright.interactive.config.ts tests/e2e/interactive.smoke.spec.ts",
|
|
134
149
|
"playwright:interactive:headed": "playwright test --headed -c playwright.interactive.config.ts tests/e2e/interactive.smoke.spec.ts",
|
|
135
150
|
"playwright:planning": "playwright test -c playwright.interactive.config.ts tests/e2e/planning-workspace.interactive.spec.ts",
|
|
@@ -143,9 +158,18 @@
|
|
|
143
158
|
"check:mcp-smoke": "node scripts/check-cloud-mcp.mjs",
|
|
144
159
|
"check:mcp-connection": "node scripts/check-authenticated-mcp.mjs",
|
|
145
160
|
"check:mcp-latency": "node scripts/run-mcp-latency-gate.mjs",
|
|
161
|
+
"baseline:mcp:s1:cloud": "sh scripts/run-mcp-s1-cloud-baseline.sh",
|
|
162
|
+
"baseline:mcp:s1:assemble": "node scripts/assemble-mcp-s1-baseline.mjs",
|
|
163
|
+
"test:mcp:s1-baseline": "node --test scripts/run-mcp-latency-gate.test.mjs scripts/run-mcp-s1-cloud-baseline.test.mjs scripts/assemble-mcp-s1-baseline.test.mjs",
|
|
164
|
+
"test:mcp:conformance:2025": "node --import tsx scripts/run-mcp-conformance-gate.ts --requirements 2025-11-25",
|
|
165
|
+
"test:mcp:conformance:2026": "node --import tsx scripts/run-mcp-conformance-gate.ts --requirements 2026-07-28",
|
|
166
|
+
"test:mcp:conformance": "npm run test:mcp:conformance:2025 && npm run test:mcp:conformance:2026",
|
|
167
|
+
"test:mcp:conformance:contract": "vitest run tests/mcp/conformance/gateEvidence.test.ts tests/mcp/conformance/httpHarness.test.ts tests/mcp/conformance/stdioCompanion.test.ts",
|
|
146
168
|
"check:cloud-performance": "sh scripts/run-cloud-performance-gate.sh",
|
|
147
169
|
"check:committed-mcp-secrets": "node scripts/check-committed-mcp-secrets.mjs",
|
|
148
170
|
"test:committed-mcp-secrets": "node --test scripts/check-committed-mcp-secrets.test.mjs",
|
|
171
|
+
"executor-capability-probe": "node scripts/executor-capability-probe.mjs",
|
|
172
|
+
"test:executor-capability-probe": "node --test scripts/executor-capability-policy.test.mjs scripts/executor-capability-probe.test.mjs scripts/executor-phase-a-evidence-envelope.test.mjs scripts/executor-provider-tunnel.test.mjs",
|
|
149
173
|
"check:native-deps": "node scripts/check-native-deps.cjs",
|
|
150
174
|
"model-gateway:smoke": "node --import tsx scripts/model-gateway-smoke.ts",
|
|
151
175
|
"model-gateway:mantle-smoke": "node --import tsx scripts/model-gateway-mantle-smoke.ts",
|
|
@@ -166,11 +190,17 @@
|
|
|
166
190
|
"dependencies": {
|
|
167
191
|
"@aws-sdk/client-bedrock-runtime": "^3.1075.0",
|
|
168
192
|
"@iarna/toml": "^2.2.5",
|
|
169
|
-
"@modelcontextprotocol/
|
|
193
|
+
"@modelcontextprotocol/client": "^2.0.0",
|
|
194
|
+
"@modelcontextprotocol/core": "^2.0.0",
|
|
195
|
+
"@modelcontextprotocol/node": "^2.0.0",
|
|
196
|
+
"@modelcontextprotocol/server": "^2.0.0",
|
|
197
|
+
"@openai/codex": "0.148.0-alpha.9",
|
|
170
198
|
"@smithy/hash-node": "^4.4.2",
|
|
171
199
|
"ajv": "~8.18.0",
|
|
172
200
|
"better-sqlite3": "^12.6.2",
|
|
173
201
|
"chokidar": "^3.6.0",
|
|
202
|
+
"json-canonicalize": "2.0.0",
|
|
203
|
+
"lucide-react": "^0.474.0",
|
|
174
204
|
"nodemailer": "^9.0.3",
|
|
175
205
|
"openai": "^6.45.0",
|
|
176
206
|
"pg": "^8.18.0",
|
|
@@ -184,6 +214,7 @@
|
|
|
184
214
|
"@dnd-kit/core": "^6.3.1",
|
|
185
215
|
"@dnd-kit/sortable": "^10.0.0",
|
|
186
216
|
"@dnd-kit/utilities": "^3.2.2",
|
|
217
|
+
"@modelcontextprotocol/conformance": "0.2.0-alpha.11",
|
|
187
218
|
"@playwright/test": "^1.58.2",
|
|
188
219
|
"@testing-library/jest-dom": "^6.9.1",
|
|
189
220
|
"@testing-library/react": "^16.3.2",
|
|
@@ -197,7 +228,6 @@
|
|
|
197
228
|
"concurrently": "^8.2.2",
|
|
198
229
|
"html2canvas": "^1.4.1",
|
|
199
230
|
"jsdom": "^27.4.0",
|
|
200
|
-
"lucide-react": "^0.474.0",
|
|
201
231
|
"react": "^19.0.0",
|
|
202
232
|
"react-dom": "^19.0.0",
|
|
203
233
|
"react-markdown": "^9.1.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{V as C,t as a}from"./index-BUplSsv_.js";import{j as i}from"./vendor-react-CKJs5o3c.js";const l=["red-500","orange-500","amber-500","green-700","teal-700","sky-500","sky-700","blue-500","indigo-700","violet-500"];function y(e){const r=String(e||"ai").trim().toLowerCase();let s=2166136261;for(let t=0;t<r.length;t+=1)s^=r.charCodeAt(t),s=Math.imul(s,16777619);const o=l[(s>>>0)%l.length];return C[o].toLowerCase()}function $(e){const[r,s=""]=e.split("#"),o=r.includes("?")?"&":"?";return`${r}${o}taskforceCloud=1${s?`#${s}`:""}`}function A(e){return/^https?:\/\//i.test(e)?e:$(e)}function N({name:e,username:r,subtitle:s,avatar:o,selected:t,disabled:n=!1,onSelect:c,ariaLabel:d,avatarVariant:u="portrait",avatarClassName:f="",avatarStyle:p,className:m="",topUtility:h,bottomUtility:P,footer:x}){return i.jsxs("button",{type:"button",className:`${a.aiProfileGroup} ${t?a.aiProfileGroupSelected:""} ${m}`.trim(),onClick:c,disabled:n,"aria-label":d,"aria-pressed":t,children:[h,P,i.jsxs("span",{className:a.aiProfileGroupHeader,children:[i.jsx("span",{className:`${a.aiProfileGroupAvatar} ${u==="logo"?a.aiProfileGroupAvatarLogo:""} ${f}`.trim(),style:p,"aria-hidden":"true",children:o}),i.jsxs("span",{className:a.aiProfileGroupIdentity,children:[i.jsx("span",{className:a.aiProfileName,children:e}),r?i.jsxs("span",{className:a.aiProfileHandle,children:["@",r]}):null,i.jsx("span",{className:a.aiProfileRole,children:s}),x]})]})]})}export{N as A,y as a,l as b,A as r,$ as w};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as f,j as a}from"./vendor-react-CKJs5o3c.js";import{ac as Qe,ad as re,O as Ue,ae as ea,af as W,t as r,U as aa,V as ra,ag as ta,ah as Re,W as ia,ai as oa,aj as te,ak as Me,al as la,Y as sa,X as Ee,$ as b,a0 as ke}from"./index-BUplSsv_.js";import{A as na,b as ca,r as Ce}from"./AiIdentityRosterCard-MZs7lVED.js";import{ay as da,ai as fa,U as ua,w as pa,Z as J,J as Le,ax as ma,aC as va}from"./vendor-icons-BkFLXavV.js";import"./vendor-markdown-_lhNCyq-.js";import"./vendor-dnd-CJ-AjP-Y.js";import"./vendor-router-AqJMU8Lz.js";const ga=["chat_app","ide","cli","coding_tool","taskforce_agent","agent","unclassified"];function L(o){return typeof o.avatarUrl=="string"&&o.avatarUrl.trim().length>0}function ie(o){return o?Ee(o.avatarUrl,o.avatarRevision,o.avatarUpdatedAt):""}function ha(o){return o?Ee(o.avatarSourceUrl,o.avatarRevision,o.avatarUpdatedAt):""}function ya(o){return o.find(L)||o[0]}function Pa({profile:o,className:g=""}){const A=ie(o),$=W(o),{activeImageUrl:T,handleImageError:Y}=sa(A,$);return T?a.jsx("img",{src:T,alt:"",className:g,onError:Y}):a.jsx(Le,{size:22})}function K(o){const g=te(o);return g?`taskforce-agent:${g}`:`${o.seatScope||"unknown"}:${o.name.trim().toLowerCase()}`}function oe(o){const g=o.providerMetadata?.taskforce;return!!(g&&typeof g=="object"&&!Array.isArray(g)&&String(g.taskforceAgentId||"").trim())}function Aa(o){return oe(o)?"taskforce_agent":Me(o.surfaceType)}function Te(o){return o==="taskforce_agent"?"Taskforce Agents":la(o)}function Sa(o){return oe(o)?"Taskforce Agent":o.surfaceType?Re(o.surfaceType):""}function xa(o){const g=Math.max(0,o-1);return`${g} duplicate${g===1?"":"s"}`}function we(o){return!o||typeof o!="object"?null:{used:Math.max(0,Number(o.used||0)),limit:o.limit===null||o.limit===void 0?null:Math.max(0,Number(o.limit||0)),remaining:o.remaining===null||o.remaining===void 0?null:Math.max(0,Number(o.remaining||0))}}function De(o,g){const A=g?.variant==="inline"?`${r.aiProfileSeatScopeIcon} ${r.aiProfileSeatScopeIconInline}`:g?.variant==="detail"?`${r.aiProfileSeatScopeIcon} ${r.aiProfileSeatScopeIconDetail}`:r.aiProfileSeatScopeIcon;return o==="cloud_metered"?a.jsx("span",{className:`${A} ${r.aiProfileSeatScopeIconCloud}`,title:"Cloud MCP","aria-label":"Cloud MCP",children:a.jsx(ma,{size:20})}):o==="local_unmetered"?a.jsx("span",{className:`${A} ${r.aiProfileSeatScopeIconLocal}`,title:"Local MCP","aria-label":"Local MCP",children:a.jsx(va,{size:20})}):null}function Ta({workspaceId:o,runtimeMode:g="local",cloudAuthConfigured:A=!1,authSessionResolved:$=!1,isAuthenticated:T=!1,cloudAiProfileSeatUsage:Y=null,agentTrayOpen:X=!1,onCloseAgentTray:$e,mcpSettingsNode:le=null,resolveCloudAuthUrl:B,theme:Be="dark",onNotice:w}){const[N,O]=f.useState([]),[Oe,Fe]=f.useState(null),[Ge,se]=f.useState(!1),[S,F]=f.useState(null),[G,D]=f.useState(null),[ne,Z]=f.useState(null),[_e,ce]=f.useState(!1),[U,_]=f.useState(null),[de,fe]=f.useState(null),[ue,z]=f.useState(!1),[ze,P]=f.useState(null),[He,x]=f.useState(null),[R,pe]=f.useState(null),[me,k]=f.useState({}),[ve,ge]=f.useState(!1),[q,he]=f.useState(!1),[ye,Pe]=f.useState(null),C=f.useCallback(async()=>{if(o){se(!0);try{const e=`/api/taskforce/workspace/assignee-options?workspaceId=${encodeURIComponent(o)}&kind=agent`,t=await fetch(e,{credentials:"include"}),l=t.ok?await t.json().catch(()=>({})):{},s=we(l?.aiProfileSeatUsage),d=Array.isArray(l?.assignees)?l.assignees.filter(i=>i.kind==="agent").map(i=>({id:String(i.value||""),name:String(i.label||i.value||"Unknown Agent"),username:String(i.username||i.value||""),icon:String(i.icon||"Bot"),color:String(i.color||"#6B7280"),colorSource:typeof i.colorSource=="string"?i.colorSource:null,colorUpdatedAt:typeof i.colorUpdatedAt=="string"?i.colorUpdatedAt:null,avatarUrl:typeof i.avatarUrl=="string"?i.avatarUrl:null,avatarSourceUrl:typeof i.avatarSourceUrl=="string"?i.avatarSourceUrl:null,avatarRevision:Number.isFinite(Number(i.avatarRevision))?Math.max(0,Math.floor(Number(i.avatarRevision))):0,avatarUpdatedAt:typeof i.avatarUpdatedAt=="string"?i.avatarUpdatedAt:null,kind:String(i.kind||"agent"),description:typeof i.description=="string"?i.description:null,role:typeof i.role=="string"?i.role:null,provider:typeof i.provider=="string"?i.provider:null,model:typeof i.model=="string"?i.model:null,surfaceType:re(i.surfaceType),seatScope:Qe(i.seatScope),providerMetadata:i.providerMetadata&&typeof i.providerMetadata=="object"&&!Array.isArray(i.providerMetadata)?i.providerMetadata:null,archivedAt:typeof i.archivedAt=="string"?i.archivedAt:null,createdAt:String(i.createdAt||""),updatedAt:String(i.updatedAt||i.createdAt||""),lastActiveAt:typeof i.lastActiveAt=="string"?i.lastActiveAt:null})):[];O(d),Fe(s),D(i=>i&&!d.some(u=>u.id===i.profileId)?null:i),Z(i=>i&&!d.some(u=>u.id===i.profileId)?null:i)}finally{se(!1)}}},[o]);f.useEffect(()=>{C()},[C]),f.useEffect(()=>{const e=t=>{const l=t.detail;(String(l?.workspaceId||"").trim()||"default")===o&&l?.origin!=="ai-profiles-module"&&C()};return window.addEventListener(Ue,e),()=>window.removeEventListener(Ue,e)},[C,o]);const H=f.useMemo(()=>{const e=new Map;for(const t of N){const l=Aa(t);e.has(l)||e.set(l,new Map);const s=e.get(l),d=K(t);s.has(d)||s.set(d,[]),s.get(d).push(t)}return ga.map(t=>({section:t,label:Te(t),groups:Array.from(e.get(t)?.entries()||[]).map(([l,s])=>({groupId:`${t}:${l}`,section:t,sectionLabel:Te(t),profiles:s,primaryProfile:ya(s)}))})).filter(t=>t.groups.length>0)},[N]),j=f.useMemo(()=>H.flatMap(e=>e.groups),[H]),n=f.useMemo(()=>j.find(e=>e.groupId===U)||j[0]||null,[j,U]),p=f.useMemo(()=>N.find(e=>e.id===de)||null,[N,de]),Ae=p&&me[p.id]||null,Se=n&&me[n.primaryProfile.id]||null;f.useEffect(()=>{if(!j.length){U!==null&&_(null);return}(!U||!j.some(e=>e.groupId===U))&&_(j[0].groupId)},[j,U]);const Ve=async(e,t)=>{D(null);try{const l=await fetch("/api/taskforce/workspace/ai-profiles/merge",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({keepId:e,mergeId:t})}),s=await l.json().catch(()=>({}));if(!l.ok){w?.(String(s?.error||"Failed to merge AI profiles."),"error");return}F(null),w?.("AI profiles merged.","success"),await C(),b({workspaceId:o,profileId:e,reason:"merge",origin:"ai-profiles-module"})}catch{w?.("Failed to merge AI profiles.","error")}},xe=async e=>{if(window.confirm(`Remove ${e.name} from the active roster? This frees an AI profile seat and preserves task and comment history.`)){D(null);try{const l=await fetch("/api/taskforce/workspace/ai-profiles/archive",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({profileId:e.id,reason:"manual_archive"})}),s=await l.json().catch(()=>({}));if(!l.ok){D({profileId:e.id,message:String(s?.error||"Failed to remove AI profile from roster.")});return}(S?.keepId===e.id||S?.mergeId===e.id)&&F(null),w?.("AI profile removed from active roster.","success"),await C(),b({workspaceId:o,profileId:e.id,reason:"archive",origin:"ai-profiles-module"})}catch{D({profileId:e.id,message:"Failed to remove AI profile from roster."})}}},Je=async(e,t)=>{const l=re(t),s=new Set(e.profiles.map(u=>u.surfaceType??"")),d=l??"";if(s.size===1&&s.has(d))return;ce(!0),Z(null);const i=[];try{for(const c of e.profiles){const m=await fetch("/api/taskforce/workspace/ai-profiles/surface-type",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({profileId:c.id,surfaceType:l})}),v=await m.json().catch(()=>({}));if(!m.ok||!v?.profile)throw new Error(String(v?.error||"Failed to update AI profile category."));const I=v.profile;i.push({...c,surfaceType:re(I.surfaceType),updatedAt:typeof I.updatedAt=="string"?I.updatedAt:c.updatedAt})}const u=new Map(i.map(c=>[c.id,c]));O(c=>c.map(m=>u.get(m.id)||m));const h=u.get(e.primaryProfile.id)||{...e.primaryProfile,surfaceType:l},y=Me(h.surfaceType);_(`${y}:${K(h)}`),w?.("AI profile category updated.","success");for(const c of i)b({workspaceId:o,profileId:c.id,reason:"update",origin:"ai-profiles-module"})}catch(u){Z({profileId:e.primaryProfile.id,message:String(u?.message||"Failed to update AI profile category.")})}finally{ce(!1)}},je=async(e,t,l=!1)=>{he(!0),Pe(null);try{const s=K(e.primaryProfile),d=N.filter(c=>K(c)===s),i=await fetch("/api/taskforce/workspace/ai-profiles/color",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({profileIds:d.map(c=>c.id),color:t,reset:l})}),u=await i.text();let h={};try{h=u?JSON.parse(u):{}}catch{h={}}if(!i.ok){const c=i.status===404?"Color updates are unavailable in the running Taskforce server. Restart Taskforce and try again.":`Failed to update AI profile color (HTTP ${i.status}).`;throw new Error(String(h.error||c))}if(!Array.isArray(h.profiles))throw new Error("Taskforce returned an invalid response while updating the AI profile color.");const y=new Map(h.profiles.map(c=>[String(c.id),c]));O(c=>c.map(m=>{const v=y.get(m.id);return v?{...m,color:String(v.color||m.color),colorSource:v.colorSource??m.colorSource,colorUpdatedAt:v.colorUpdatedAt??m.colorUpdatedAt,updatedAt:v.updatedAt??m.updatedAt}:m})),ge(!1);for(const c of d)b({workspaceId:o,profileId:c.id,reason:"update",origin:"ai-profiles-module"})}catch(s){Pe(String(s?.message||"Failed to update AI profile color."))}finally{he(!1)}},Ie=e=>new Promise((t,l)=>{const s=new FileReader;s.onload=()=>t(String(s.result||"")),s.onerror=()=>l(new Error("Failed to read image file.")),s.readAsDataURL(e)}),Q=e=>{const t=String(e?.id||"").trim();t&&O(l=>l.map(s=>s.id===t?{...s,avatarUrl:typeof e.avatarUrl=="string"?e.avatarUrl:null,avatarSourceUrl:typeof e.avatarSourceUrl=="string"?e.avatarSourceUrl:null,avatarRevision:Number.isFinite(Number(e.avatarRevision))?Math.max(0,Math.floor(Number(e.avatarRevision))):s.avatarRevision,avatarUpdatedAt:typeof e.avatarUpdatedAt=="string"?e.avatarUpdatedAt:s.avatarUpdatedAt,updatedAt:typeof e.updatedAt=="string"?e.updatedAt:s.updatedAt}:s))},Ke=async(e,t,l,s=!1)=>{const d=await Ie(t),i=l?await Ie(l):null,u={profileId:e,preserveExistingSource:s,displayImage:{dataUrl:d,mimeType:t.type||"application/octet-stream",originalName:t.name||"display-avatar"}};l&&i&&(u.sourceImage={dataUrl:i,mimeType:l.type||"application/octet-stream",originalName:l.name||"source-avatar"});const h=await fetch("/api/taskforce/workspace/ai-profiles/avatar/upload",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)}),y=await h.json().catch(()=>({}));if(!h.ok||!y?.profile)throw new Error(String(y?.error||"Failed to update AI profile avatar."));Q(y.profile),b({workspaceId:o,profileId:e,reason:"avatar",origin:"ai-profiles-module"})},We=async e=>{const t=await fetch("/api/taskforce/workspace/ai-profiles/avatar",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({profileId:e,avatarUrl:null,avatarSourceUrl:null})}),l=await t.json().catch(()=>({}));if(!t.ok||!l?.profile)throw new Error(String(l?.error||"Failed to update AI profile avatar."));Q(l.profile),b({workspaceId:o,profileId:e,reason:"avatar",origin:"ai-profiles-module"})},Ye=async e=>{if(R)return!1;const t=te(e),l=L(e);if(l&&!window.confirm(`Replace the existing avatar for ${e.name}?`))return!1;const s=t?"":window.prompt("Optional visual direction (300 characters maximum). Leave blank to use the profile details.","");if(s===null)return!1;const d=g==="local";if(d&&(!A||!$||!T||!B))return P("Sign in to Taskforce Cloud to generate profile avatars."),x(null),!1;pe(e.id),P(null),x(null),k(i=>({...i,[e.id]:{error:null,notice:null}}));try{const i=t?`/api/taskforce/agents/${encodeURIComponent(t)}/avatar/generate`:"/api/taskforce/workspace/ai-profiles/avatar/generate",u=d&&B?B(i):i,h=await fetch(u,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{workspaceId:o}:{workspaceId:o,profileId:e.id,visualDirection:s.slice(0,300),replaceExisting:l})}),y=await h.text().catch(()=>"");let c={};if(y&&!/^\s*(?:<!doctype\s+html|<html\b)/i.test(y))try{c=JSON.parse(y)}catch{c={}}if(!h.ok||!c?.profile&&!c?.agent)throw new Error(String(c?.error||(h.status?`Unable to generate avatar. HTTP ${h.status}.`:"Unable to generate avatar.")));const m=c.profile||{id:e.id,avatarUrl:c.agent?.avatarUrl??null,avatarSourceUrl:c.agent?.avatarSourceUrl??null,avatarRevision:c.agent?.avatarRevision??0,avatarUpdatedAt:c.agent?.avatarUpdatedAt??null},v=d&&B?{...m,avatarUrl:m.avatarUrl?Ce(m.avatarUrl):m.avatarUrl,avatarSourceUrl:m.avatarSourceUrl?Ce(m.avatarSourceUrl):m.avatarSourceUrl}:m;return Q(v),k(d?I=>({...I,[e.id]:{error:null,notice:`Generated photo for ${e.name} was saved in Taskforce Cloud. The local copy will be retained when sync runs.`}}):I=>({...I,[e.id]:{error:null,notice:`Generated photo for ${e.name} was saved.`}})),b({workspaceId:o,profileId:e.id,reason:"avatar",origin:"ai-profiles-module",...t?{taskforceAgentAvatar:{agentId:t,avatarUrl:typeof v.avatarUrl=="string"?v.avatarUrl:null,avatarSourceUrl:typeof v.avatarSourceUrl=="string"?v.avatarSourceUrl:null,avatarRevision:Number.isFinite(Number(v.avatarRevision))?Math.max(0,Math.floor(Number(v.avatarRevision))):0,avatarUpdatedAt:typeof v.avatarUpdatedAt=="string"?v.avatarUpdatedAt:null}}:{}}),!0}catch(i){return k(u=>({...u,[e.id]:{error:String(i?.message||"Unable to generate profile avatar."),notice:null}})),!1}finally{pe(null)}},Xe=async(e,t,l)=>{if(!p)return!1;if(!e.type.startsWith("image/"))return P("AI profile photo must be an image file."),!1;z(!0),P(null),x(null),k(s=>{const d={...s};return delete d[p.id],d});try{const s=await ke(e,{maxBytes:5242880});if(s.exceededLimit)throw new Error(e.type==="image/gif"?"Animated GIF AI profile photos must be 5 MB or smaller.":"AI profile photo must be 5 MB or smaller.");const d=s.file;let i=null;if(t){const u=await ke(t,{maxBytes:5242880});if(u.exceededLimit)throw new Error(t.type==="image/gif"?"Animated GIF AI profile photos must be 5 MB or smaller.":"AI profile source photo must be 5 MB or smaller.");i=u.file}return await Ke(p.id,d,i,l?.preserveExistingSource===!0),!0}catch(s){return P(String(s?.message||"Failed to update AI profile photo.")),!1}finally{z(!1)}},Ze=async()=>{if(p){z(!0),P(null),x(null),k(e=>{const t={...e};return delete t[p.id],t});try{await We(p.id),x("Profile photo removed.")}catch(e){P(String(e?.message||"Failed to remove AI profile photo."))}finally{z(!1)}}},M=e=>{const t=String(e||"").trim();if(!t)return"Unknown";const l=Date.parse(t);return Number.isFinite(l)?new Date(l).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"}):t},be=f.useMemo(()=>{if(!n)return{attributes:[],dates:[]};const e=n.primaryProfile,t=l=>l||"Not set";return{attributes:[{label:"Category",value:Sa(e)},{label:"Connection",value:e.seatScope?ea(e.seatScope):""},{label:"Provider",value:e.provider||""},{label:"Model",value:e.model||""}].map(l=>({...l,value:t(l.value)})),dates:[{label:"Status",value:e.archivedAt?"Retired":"Active"},{label:"Recruited",value:M(e.createdAt)},{label:"Last updated",value:M(e.updatedAt)},{label:"Last active",value:M(e.lastActiveAt)}].map(l=>({...l,value:t(l.value)}))}},[n]),qe=!!n&&n.profiles.length>1,E=!!n&&!L(n.primaryProfile)&&!!W(n.primaryProfile),Ne=A&&$&&!T,V=A?we(Y):Oe,ee=Ne?"Log into account for Cloud AI Profiles":V?`${V.used}/${V.limit===null?"Unlimited":V.limit}`:null,ae=!!le;return a.jsxs("section",{className:`${r.agentsModuleRoot} ${ae?r.agentsModuleWithTray:""} ${ae&&X?r.agentsModuleTrayOpen:""}`.trim(),children:[ae&&a.jsxs("aside",{className:`${r.agentTrayPanel} ${X?r.agentTrayPanelOpen:""}`.trim(),"aria-label":"AI Profile MCP settings tray","aria-hidden":!X,children:[a.jsxs("div",{className:r.agentTrayHeader,children:[a.jsxs("span",{className:r.agentTrayTitle,children:[a.jsx(da,{size:14}),"MCP Settings"]}),a.jsx("button",{type:"button",className:"tf-control-icon",onClick:$e,title:"Collapse AI Profile tray","aria-label":"Collapse AI Profile tray",children:a.jsx(fa,{size:16})})]}),a.jsx("div",{className:`${r.agentTrayContent} tf-scrollbar tf-scrollbar--track-transparent`,children:a.jsx("div",{className:r.agentTrayContentInner,children:le})})]}),a.jsx("div",{className:r.agentsModuleContent,children:a.jsxs("div",{className:r.aiProfilesExplorer,children:[a.jsxs("aside",{className:r.aiProfilesRosterPanel,"aria-label":"AI profile roster",children:[a.jsx("div",{className:r.taskforceAgentRosterHeader,children:a.jsxs("span",{className:r.taskforceAgentRosterTitle,children:[a.jsx(ua,{size:14}),"AI Profiles"]})}),ee&&a.jsx("div",{className:r.aiProfilesRosterSummary,children:a.jsx("div",{className:r.aiProfileSeatSummary,children:Ne?ee:`Registered Cloud AI Profiles: ${ee}`})}),Ge?a.jsxs("div",{className:r.aiProfilesRosterState,role:"status","aria-live":"polite",children:[a.jsx(pa,{size:13,className:r.spinner})," Loading profiles…"]}):N.length===0?a.jsx("div",{className:r.aiProfilesRosterState,children:"No AI profiles registered yet."}):H.length>0?a.jsx("div",{className:`${r.aiProfilesListPane} tf-scrollbar tf-scrollbar--track-transparent tf-tray-scroll-viewport`,children:a.jsx("div",{className:r.aiProfilesList,children:H.map(e=>a.jsxs("div",{className:r.aiProfilesSection,children:[a.jsx("div",{className:r.aiProfilesSectionHeader,children:e.label}),e.groups.map(t=>{const l=n?.groupId===t.groupId,s=t.primaryProfile,d=!L(s)&&!!W(s);return a.jsx(na,{name:s.name,username:s.username,subtitle:s.role||"Role not set",selected:l,onSelect:()=>_(t.groupId),avatarVariant:d?"logo":"portrait",avatar:a.jsx(Pa,{profile:s}),avatarStyle:{color:s.color},className:t.profiles.length>1?r.aiProfileGroupDuplicate:"",topUtility:De(s.seatScope),bottomUtility:a.jsx("span",{className:r.aiProfileGroupSignatureSwatch,style:{backgroundColor:s.color},title:`Signature color ${s.color}`,"aria-hidden":"true"}),footer:t.profiles.length>1?a.jsxs("span",{className:r.aiProfileDuplicateBadge,children:[a.jsx(J,{size:11})," ",xa(t.profiles.length)]}):null},t.groupId)})]},e.section))})}):null]}),a.jsx("main",{className:`${r.aiProfilesDetailViewport} tf-scrollbar`,"aria-label":"AI profile details",children:n&&a.jsx("div",{className:r.aiProfileDetailPane,children:a.jsxs("div",{className:r.aiProfileDetailCard,children:[De(n.primaryProfile.seatScope,{variant:"detail"}),a.jsxs("div",{className:r.aiProfileDetailHero,children:[a.jsx(aa,{label:"Edit AI profile photo",imageUrl:ie(n.primaryProfile),fallbackImageUrl:W(n.primaryProfile),fallback:a.jsx(Le,{size:38}),accentColor:E?null:n.primaryProfile.color,size:176,width:E?176:153,height:E?176:207,radius:E?0:6,editBadgeSize:28,editIconSize:14,loading:R===n.primaryProfile.id,loadingLabel:`Generating ${n.primaryProfile.name} photo`,error:!!Se?.error,errorLabel:Se?.error||"Profile photo generation failed",className:`${r.aiProfileDetailAvatar} ${E?r.aiProfileDetailAvatarLogo:""}`.trim(),onClick:()=>{P(null),x(null),fe(n.primaryProfile.id)}}),a.jsxs("div",{className:r.aiProfileDetailHeading,children:[a.jsx("div",{className:r.aiProfileDetailTitleRow,children:a.jsx("h5",{className:r.aiProfileDetailTitle,children:n.primaryProfile.name})}),a.jsxs("div",{className:r.aiProfileDetailMetaRow,children:[a.jsxs("span",{className:r.aiProfileDetailHandle,children:["@",n.primaryProfile.username]}),n.profiles.length>1&&a.jsxs("span",{className:r.aiProfileDetailLinkedCount,children:[n.profiles.length," linked"]})]}),a.jsxs("div",{className:r.aiProfileDetailRole,children:["Role: ",n.primaryProfile.role||"Not set"]}),n.primaryProfile.description&&a.jsx("div",{className:r.aiProfileDetailDescription,children:n.primaryProfile.description}),a.jsxs("div",{className:r.aiProfileSignatureColor,children:[a.jsx("span",{children:"Signature color"}),a.jsxs("button",{type:"button",className:r.aiProfileSignatureColorButton,onClick:()=>ge(e=>!e),disabled:q,"aria-expanded":ve,"aria-label":"Change signature color",children:[a.jsx("span",{className:r.aiProfileSignatureSwatch,style:{backgroundColor:n.primaryProfile.color},"aria-hidden":"true"}),a.jsx("span",{children:n.primaryProfile.color})]})]}),ve&&a.jsxs("div",{className:r.aiProfileColorPicker,"aria-label":"Signature color options",children:[ca.map(e=>{const t=ra[e];return a.jsx("button",{type:"button",className:r.aiProfileColorOption,style:{backgroundColor:t},"aria-label":`Use ${e}`,"aria-pressed":n.primaryProfile.color.toLowerCase()===t.toLowerCase(),disabled:q,onClick:()=>{je(n,t)}},e)}),a.jsx("button",{type:"button",className:r.secondaryHeaderBtn,disabled:q,onClick:()=>{je(n,void 0,!0)},children:"Reset"})]}),ye&&a.jsx("div",{className:r.aiProfileInlineError,children:ye})]})]}),a.jsxs("div",{className:r.aiProfileDetailDataList,children:[a.jsx("div",{className:r.aiProfileDetailDataGroup,children:be.attributes.map(e=>a.jsxs("div",{className:r.aiProfileDetailDataRow,children:[a.jsx("span",{className:r.aiProfileDetailDataLabel,children:e.label}),e.label==="Category"&&!oe(n.primaryProfile)?a.jsx("span",{className:r.aiProfileDetailDataValue,children:a.jsxs("select",{className:r.aiProfileStatusSelect,"aria-label":"Agent category",value:n.primaryProfile.surfaceType??"",disabled:_e,onChange:t=>{Je(n,t.target.value)},children:[a.jsx("option",{value:"",children:"Unclassified"}),ta.map(t=>a.jsx("option",{value:t,children:Re(t)},t))]})}):a.jsx("span",{className:r.aiProfileDetailDataValue,children:e.value})]},e.label))}),a.jsx("div",{className:`${r.aiProfileDetailDataGroup} ${r.aiProfileDetailDateGroup}`,children:be.dates.map(e=>a.jsxs("div",{className:r.aiProfileDetailDataRow,children:[a.jsx("span",{className:r.aiProfileDetailDataLabel,children:e.label}),e.label==="Status"?a.jsx("span",{className:r.aiProfileDetailDataValue,children:a.jsxs("select",{className:r.aiProfileStatusSelect,"aria-label":"Agent roster status",value:n.primaryProfile.archivedAt?"retired":"active",onChange:t=>{t.target.value==="retire"&&xe(n.primaryProfile)},children:[a.jsx("option",{value:"active",children:"Active"}),n.primaryProfile.archivedAt?a.jsx("option",{value:"retired",children:"Retired"}):a.jsx("option",{value:"retire",children:"Retire from roster"})]})}):a.jsx("span",{className:r.aiProfileDetailDataValue,children:e.value})]},e.label))})]}),ne?.profileId===n.primaryProfile.id&&a.jsxs("div",{className:r.aiProfileInlineError,role:"alert",children:[a.jsx(J,{size:12}),a.jsx("span",{children:ne.message})]}),qe?a.jsxs("div",{className:r.aiProfileInstanceSection,children:[a.jsxs("div",{className:r.aiProfileInstanceSectionHeader,children:[a.jsx("span",{children:"Profile instances"}),a.jsx("span",{className:r.settingsHint,children:"Choose a keeper here if duplicates need to be merged."})]}),a.jsx("div",{className:r.aiProfileInstanceList,children:n.profiles.map(e=>a.jsxs("div",{className:r.aiProfileInstanceCard,children:[a.jsxs("div",{className:r.aiProfileInstanceTopRow,children:[a.jsxs("div",{children:[a.jsxs("div",{className:r.aiProfileInstanceName,children:["@",e.username]}),a.jsx("div",{className:r.aiProfileIdChip,children:e.id})]}),S?.keepId===e.id&&a.jsx("span",{className:r.aiProfileKeepBadge,children:"Keeping"})]}),a.jsxs("div",{className:r.aiProfileInstanceMeta,children:[a.jsxs("span",{children:["Created ",M(e.createdAt)]}),a.jsxs("span",{children:["Updated ",M(e.updatedAt)]})]}),S?.keepId!==e.id&&a.jsx("button",{className:r.secondaryHeaderBtn,title:"Keep this profile, merge others into it",onClick:()=>{const t=n.profiles.find(l=>l.id!==e.id)?.id;t&&F({keepId:e.id,mergeId:t})},children:"Keep this"}),G?.profileId===e.id&&a.jsxs("div",{className:r.aiProfileInlineError,role:"alert",children:[a.jsx(J,{size:12}),a.jsx("span",{children:G.message})]}),a.jsx("button",{className:r.aiProfileDangerTextButton,title:"Remove this profile from the active roster",onClick:()=>{xe(e)},children:"Remove from roster"})]},e.id))}),S&&n.profiles.some(e=>e.id===S.keepId)&&a.jsxs("div",{className:r.aiProfileMergeActions,children:[a.jsx("button",{className:r.dangerBtn,onClick:()=>{Ve(S.keepId,S.mergeId)},children:"Merge duplicates"}),a.jsx("button",{className:r.secondaryHeaderBtn,onClick:()=>F(null),children:"Cancel"})]})]}):a.jsxs("div",{className:r.aiProfileIdFooter,children:[a.jsx("div",{className:r.aiProfileIdFooterValue,children:n.primaryProfile.id}),G?.profileId===n.primaryProfile.id&&a.jsxs("div",{className:r.aiProfileInlineError,role:"alert",children:[a.jsx(J,{size:12}),a.jsx("span",{children:G.message})]})]})]})})})]})}),a.jsx(ia,{isOpen:!!p,theme:Be,title:"Edit AI Profile Photo",currentImageUrl:ie(p),editorImageUrl:ha(p),fallbackInitial:(p?.name||"AI").charAt(0).toUpperCase(),accept:"image/png,image/jpeg,image/webp,image/gif",busy:ue,generating:R===p?.id,generateLabel:p&&L(p)?"Regenerate":"Generate",hasPendingImage:!1,canRemove:!!p?.avatarUrl,error:ze||Ae?.error||null,notice:He||Ae?.notice||null,onClose:()=>{ue||(fe(null),P(null),x(null))},onApplyImage:Xe,onGenerateImage:p&&(!R||R===p.id)&&(oa(p)||te(p))?()=>Ye(p):void 0,onRemoveImage:Ze},p?.id||"ai-profile-avatar-closed")]})}export{Ta as AiProfilesModule};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
._shell_1tt0t_1{--image-tray-width: min(332px, calc(100vw - 96px) );position:relative;align-self:stretch;width:100%;box-sizing:border-box;display:grid;grid-template-columns:minmax(220px,270px) minmax(0,1fr) minmax(220px,270px);gap:12px;height:100%;min-height:0;padding:12px;background:radial-gradient(circle at top left,color-mix(in srgb,var(--brand-primary) 8%,transparent),transparent 26%),linear-gradient(180deg,color-mix(in srgb,var(--surface-page) 84%,var(--surface-panel)) 0%,var(--surface-page) 100%)}._shellWithImageTray_1tt0t_18{transition:padding-left .22s cubic-bezier(.4,0,.2,1)}._shellImageTrayOpen_1tt0t_22{padding-left:calc(var(--image-tray-width) + 12px)}._imageTrayPanel_1tt0t_26{position:absolute;top:0;bottom:0;left:0;width:var(--image-tray-width);min-width:260px;max-width:332px;display:flex;flex-direction:column;padding:0 12px;box-sizing:border-box;border-right:1px solid var(--border-primary);background:var(--bg-secondary);overflow:hidden;transform:translate(-100%);opacity:0;visibility:hidden;pointer-events:none;z-index:34;box-shadow:4px 0 18px #080a1829;transition:transform .22s cubic-bezier(.4,0,.2,1),opacity .16s ease,visibility 0s linear .22s}._imageTrayPanelOpen_1tt0t_50{transform:translate(0);opacity:1;visibility:visible;pointer-events:auto;transition:transform .22s cubic-bezier(.4,0,.2,1),opacity .16s ease,visibility 0s linear 0s}._imageTrayHeader_1tt0t_58{position:sticky;top:0;z-index:12;display:flex;align-items:center;justify-content:space-between;gap:.75rem;padding:12px 0 10px;border-bottom:1px solid var(--border-default);background:var(--bg-secondary);box-shadow:0 10px 16px color-mix(in srgb,var(--bg-secondary) 90%,transparent);flex-shrink:0}._imageTrayTitle_1tt0t_73{flex:1;display:flex;align-items:center;gap:6px;font-size:.78rem;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:var(--text-secondary)}._imageTraySearch_1tt0t_85{position:relative;padding:12px 0 0;flex-shrink:0}._imageTraySearchIcon_1tt0t_91{position:absolute;left:10px;top:50%;transform:translateY(-50%);color:var(--text-muted);pointer-events:none}._imageTraySearchInput_1tt0t_100{width:100%;padding:7px 8px 7px 28px;background:color-mix(in srgb,var(--surface-inset) 88%,transparent);border:1px solid var(--border-default);border-radius:var(--radius-md);color:var(--text-primary);font-size:.75rem;font-family:inherit;outline:none;box-sizing:border-box}._imageTraySearchInput_1tt0t_100:focus{border-color:var(--brand-primary)}._imageTraySortControlRow_1tt0t_117{display:flex;justify-content:flex-end;padding:6px 0 4px;flex-shrink:0}._imageTrayList_1tt0t_124{display:flex;flex-direction:column;gap:.375rem;flex:1;overflow-y:auto;min-height:0;padding:12px 0;scrollbar-width:thin;scrollbar-color:var(--scrollbar-thumb) var(--scrollbar-track)}._imageTrayState_1tt0t_136,._imageTrayStateError_1tt0t_137{padding:24px 16px;font-size:.75rem;color:var(--text-muted);text-align:center;line-height:1.5}._imageTrayStateError_1tt0t_137{color:var(--status-error)}._imageTrayItem_1tt0t_149{width:100%;display:flex;align-items:flex-start;gap:8px;padding:.55rem .65rem;border-radius:var(--radius-md);border:1px solid var(--border-default);background:color-mix(in srgb,var(--surface-inset) 88%,transparent);cursor:pointer;text-align:left;transition:background var(--transition-base),border-color var(--transition-base),box-shadow var(--transition-base),transform var(--transition-base);font-family:inherit;color:var(--text-primary);min-width:0}._imageTrayItem_1tt0t_149:hover{background:color-mix(in srgb,var(--surface-hover) 72%,transparent);transform:translateY(-1px)}._imageTrayItemActive_1tt0t_171{border-color:var(--brand-primary-border);background:color-mix(in srgb,var(--brand-primary-soft) 94%,transparent);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--brand-primary-border) 42%,transparent)}._imageTrayItemActive_1tt0t_171:hover{background:color-mix(in srgb,var(--brand-primary-soft) 92%,transparent)}._imageTrayThumb_1tt0t_181{width:34px;height:34px;flex-shrink:0;border-radius:6px;overflow:hidden;background:var(--surface-inset);border:1px solid var(--border-subtle)}._imageTrayThumb_1tt0t_181 img{width:100%;height:100%;object-fit:cover;display:block}._imageTrayItemBody_1tt0t_198{display:flex;flex-direction:column;gap:.25rem;min-width:0;flex:1}._imageTrayItemTitle_1tt0t_206,._imageTrayItemTask_1tt0t_207,._imageTrayItemMetaDetails_1tt0t_208{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._imageTrayItemTitle_1tt0t_206{display:block;max-width:100%;font-size:.875rem;font-weight:700;line-height:1.28;color:var(--text-primary)}._imageTrayItemTask_1tt0t_207{display:block;max-width:100%;font-size:.75rem;line-height:1.35;color:color-mix(in srgb,var(--text-secondary) 92%,transparent)}._imageTrayItemMeta_1tt0t_208{display:flex;align-items:center;justify-content:space-between;gap:8px;width:100%;font-size:.72rem;line-height:1.35;color:color-mix(in srgb,var(--text-secondary) 82%,transparent)}._imageTrayItemMetaDetails_1tt0t_208{min-width:0}._imageTrayItemReference_1tt0t_246{flex-shrink:0;font-size:.7rem;font-weight:700;color:var(--text-secondary)}._panel_1tt0t_253{min-height:0;border-radius:var(--radius-sm);box-shadow:0 18px 38px #0f172a14}._sessionPanel_1tt0t_259,._detailPanel_1tt0t_260{display:flex;flex-direction:column;overflow:hidden}._sessionContextBar_1tt0t_266{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:58px;padding:12px 16px;border-bottom:1px solid var(--border-default);background:color-mix(in srgb,var(--surface-inset) 88%,transparent)}._sessionContextLeft_1tt0t_277,._sessionContextRight_1tt0t_278{display:flex;align-items:center;min-width:0}._sessionContextLeft_1tt0t_277{flex:1}._sessionContextRight_1tt0t_278{justify-content:flex-end;min-width:118px}._sessionContextLabel_1tt0t_293{font-size:.84rem;font-weight:600;color:var(--text-secondary)}._sessionContextSpacer_1tt0t_299{width:118px;height:32px}._canvasPanel_1tt0t_304{display:flex;flex-direction:column;min-height:0;overflow:hidden}._canvasWorkspace_1tt0t_311{display:grid;grid-template-columns:auto minmax(0,1fr);min-height:0;flex:1}._canvasMain_1tt0t_318{display:flex;flex-direction:column;min-width:0;min-height:0}._panelHeader_1tt0t_325{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:16px;border-bottom:1px solid var(--border-default)}._panelHeaderText_1tt0t_334{min-width:0}._panelTitle_1tt0t_338{font-size:1rem}._canvasHeading_1tt0t_342{min-width:0}._sessionActions_1tt0t_346{display:inline-flex;align-items:center;gap:8px;margin-left:auto;flex-shrink:0}._taskLinkModalBody_1tt0t_354{display:flex;flex-direction:column;gap:12px}._taskLinkModalBody_1tt0t_354>p{margin:0}._taskLinkList_1tt0t_364{display:flex;flex-direction:column;gap:6px;max-height:280px;overflow:auto}._taskLinkOption_1tt0t_372{display:flex;flex-direction:column;align-items:flex-start;gap:3px;width:100%;padding:10px 12px;border:1px solid var(--border-default);border-radius:var(--radius-sm);color:inherit;text-align:left;cursor:pointer}._taskLinkOption_1tt0t_372:hover:not(:disabled),._taskLinkOptionActive_1tt0t_387{border-color:var(--accent-primary)}._taskLinkOption_1tt0t_372:disabled{cursor:default}._taskLinkOptionTitle_1tt0t_395{font-weight:600}._taskLinkActions_1tt0t_399{display:flex;justify-content:flex-end;gap:8px}._sessionList_1tt0t_405,._annotationList_1tt0t_406{display:flex;flex:1 1 auto;flex-direction:column;gap:6px;min-height:0;padding:8px;overflow:auto}._markerHelpModalBody_1tt0t_416{display:flex;flex-direction:column;gap:14px}._openImageModalBody_1tt0t_422{display:flex;flex-direction:column;gap:12px}._openImageField_1tt0t_428{width:100%}._openImageActions_1tt0t_432{display:flex;justify-content:flex-end;gap:8px}._markerHelpItem_1tt0t_438{display:flex;flex-direction:column;gap:6px;padding:12px 14px;border-radius:var(--radius-md)}._markerHelpHeader_1tt0t_446{display:flex;align-items:baseline;justify-content:space-between;gap:12px}._markerHelpItem_1tt0t_438 p{margin:0;line-height:1.45}._markerHelpExample_1tt0t_458{font-weight:600}._sessionCard_1tt0t_462,._annotationCard_1tt0t_463{display:flex;flex-direction:column;gap:6px;padding:10px;border-radius:var(--radius-sm);text-align:left;transition:border-color var(--transition-base),box-shadow var(--transition-base),opacity var(--transition-base),transform var(--transition-base)}._sessionEmptyState_1tt0t_477{display:flex;flex-direction:column;gap:8px;padding:8px 2px 0}._sessionCardButton_1tt0t_484{display:flex;flex-direction:column;gap:8px;padding:0;border:0;background:transparent;text-align:left}._annotationCardButton_1tt0t_494{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;gap:8px;padding:0;border:0;background:transparent;text-align:left}._sessionCardBody_1tt0t_506{display:flex;flex-direction:column;gap:8px}._sessionCardActive_1tt0t_512,._annotationCardActive_1tt0t_513{border-color:var(--button-tile-active-border);box-shadow:0 0 0 1px transparent,0 12px 28px var(--brand-primary-glow-soft)}._annotationCardActive_1tt0t_513{border-color:var(--annotation-card-accent, var(--button-tile-active-border));box-shadow:0 0 0 1px color-mix(in srgb,var(--annotation-card-accent, var(--brand-primary)) 30%,transparent),0 12px 28px color-mix(in srgb,var(--annotation-card-accent, var(--brand-primary)) 18%,transparent)}._sessionCard_1tt0t_462:hover,._annotationCard_1tt0t_463:hover{transform:translateY(-1px)}._annotationMeta_1tt0t_528{display:flex;align-items:center;justify-content:space-between;gap:4px}._annotationDragHandle_1tt0t_535{display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;width:18px;height:20px;margin-left:-2px;padding:0;border:0;border-radius:var(--radius-sm);background:transparent;color:var(--text-helper);cursor:grab}._annotationDragHandle_1tt0t_535:hover,._annotationDragHandle_1tt0t_535:focus-visible{background:var(--surface-hover);color:var(--text-primary)}._annotationDragHandle_1tt0t_535:active{cursor:grabbing}._annotationCardDragging_1tt0t_561{opacity:.16}._annotationDragOverlay_1tt0t_565{width:min(100%,320px);opacity:.94;box-shadow:0 16px 32px color-mix(in srgb,var(--surface-page) 55%,transparent);pointer-events:none}._annotationDragOverlayGrip_1tt0t_572{color:var(--text-helper)}._annotationDragOverlayTitle_1tt0t_576{flex:1 1 auto;min-width:0;text-align:left}._annotationInstructionPreview_1tt0t_582{display:-webkit-box;overflow:hidden;-webkit-line-clamp:4;-webkit-box-orient:vertical;line-height:1.45}._annotationPreviewFooter_1tt0t_590{display:flex;align-items:center;justify-content:flex-start;min-height:16px}._annotationInstructionEditor_1tt0t_597,._annotationTypeField_1tt0t_603{display:flex;flex-direction:column;gap:8px}._annotationGeometryDetails_1tt0t_609{padding-top:8px;border-top:1px solid var(--border-default)}._annotationGeometryDetails_1tt0t_609>summary{cursor:pointer}._annotationGeometryFields_1tt0t_618{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-top:8px}._annotationGeometryField_1tt0t_618{display:flex;flex-direction:column;gap:4px}._annotationGeometryLabel_1tt0t_631{margin:0;text-transform:uppercase}._annotationGeometryInput_1tt0t_636{min-width:0;text-align:right}._annotationInstructionButton_1tt0t_641{display:block;width:100%;padding:0;border:0;background:transparent;text-align:left}._annotationInstructionField_1tt0t_650{min-height:92px}._sessionMeta_1tt0t_654{display:flex;flex-direction:column;align-items:flex-start;gap:4px}._sessionTitle_1tt0t_661,._annotationTitle_1tt0t_662{font-size:.98rem;font-weight:700;color:var(--text-primary)}._sessionTimestamp_1tt0t_668,._annotationKind_1tt0t_669{text-transform:capitalize}._annotationInstructionTypeIcon_1tt0t_673{display:inline-flex;align-items:center;justify-content:center}._sessionInstructionPreview_1tt0t_679{line-height:1.45;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden}._sessionInstructionEditor_1tt0t_687{display:flex;flex-direction:column;gap:8px}._sessionCardFooter_1tt0t_693{display:flex;align-items:center;justify-content:flex-end;gap:8px}._toolRail_1tt0t_700{display:flex;flex-wrap:wrap;gap:8px;padding:0;border-bottom:1px solid var(--border-default);background:color-mix(in srgb,var(--surface-inset) 92%,transparent)}._canvasToolRail_1tt0t_709{display:flex;flex-direction:column;align-items:center;gap:8px;padding:0;border-right:1px solid var(--border-default);background:color-mix(in srgb,var(--surface-inset) 94%,transparent)}._toolGroup_1tt0t_719{display:inline-flex;flex-wrap:wrap;gap:8px;align-items:center;padding:4px;border:1px solid var(--border-default);border-radius:16px;background:var(--surface-panel)}._toolbarCluster_1tt0t_730{display:inline-flex;flex-wrap:wrap;gap:8px;align-items:center}._toolbarViewportCluster_1tt0t_737{margin-left:44px}._toolbarSeparator_1tt0t_741{width:1px;align-self:stretch;background:var(--border-default)}._toolBtn_1tt0t_747{white-space:nowrap}._toolRailButton_1tt0t_751{display:inline-flex;align-items:center;justify-content:center;width:44px;height:44px;padding:0;border-radius:var(--radius-md)}._toolbarButton_1tt0t_761{min-height:44px;border-radius:var(--radius-md)}._toolBtnActive_1tt0t_766{background:var(--button-tile-active-bg);border-color:var(--button-tile-active-border);color:var(--button-tile-active-text);box-shadow:0 0 0 1px transparent,0 8px 24px var(--brand-primary-glow-soft)}._toolbarActions_1tt0t_773{display:inline-flex;flex-wrap:wrap;align-items:center;gap:8px;flex:1 1 auto;min-width:0}._toolbarSelectionActions_1tt0t_782{display:inline-flex;align-items:center;gap:8px;min-width:44px;flex-wrap:wrap}._toolbarColorPicker_1tt0t_790{position:relative}._colorPickerButton_1tt0t_794{min-width:44px;padding:0}._colorPickerSwatch_1tt0t_799{width:24px;height:24px;border-radius:var(--radius-sm);border:2px solid color-mix(in srgb,var(--surface-panel) 88%,transparent);box-shadow:inset 0 0 0 1px #0f172a1f}._colorPickerPopover_1tt0t_807{position:absolute;top:calc(100% + 8px);left:0;z-index:3;display:grid;grid-template-columns:repeat(3,1fr);gap:8px;padding:10px;border:1px solid var(--border-default);border-radius:var(--radius-md);background:var(--surface-panel);box-shadow:0 18px 32px #0f172a24}._colorOption_1tt0t_822{width:24px;height:24px;padding:0;border:2px solid transparent;border-radius:var(--radius-sm);cursor:pointer;box-shadow:inset 0 0 0 1px #0f172a24}._colorOptionActive_1tt0t_832{border-color:color-mix(in srgb,var(--surface-panel) 78%,var(--brand-primary));box-shadow:inset 0 0 0 1px #0f172a24,0 0 0 2px color-mix(in srgb,var(--brand-primary) 24%,transparent)}._toolbarUtilities_1tt0t_839{margin-left:auto;display:inline-flex;flex-wrap:wrap;align-items:center;gap:8px}._iconButton_1tt0t_847{flex-shrink:0}._primaryBtn_1tt0t_851,._ghostBtn_1tt0t_852,._payloadBtn_1tt0t_853,._backToTaskBtn_1tt0t_854{white-space:nowrap}._backToTaskBtn_1tt0t_854{padding:7px 10px;color:var(--text-secondary);font-size:.88rem;font-weight:600}._backToTaskBtn_1tt0t_854:hover,._backToTaskBtn_1tt0t_854:focus-visible{color:var(--text-primary)}._payloadBtn_1tt0t_853{font-weight:700}._canvasScroller_1tt0t_874{position:relative;flex:1;min-height:0;overflow:auto;display:block;scrollbar-gutter:stable;background:linear-gradient(45deg,color-mix(in srgb,var(--surface-inset) 66%,var(--border-default)) 25%,transparent 25%),linear-gradient(-45deg,color-mix(in srgb,var(--surface-inset) 66%,var(--border-default)) 25%,transparent 25%),linear-gradient(45deg,transparent 75%,color-mix(in srgb,var(--surface-inset) 66%,var(--border-default)) 75%),linear-gradient(-45deg,transparent 75%,color-mix(in srgb,var(--surface-inset) 66%,var(--border-default)) 75%);background-size:22px 22px;background-position:0 0,0 11px,11px -11px,-11px 0}._canvasFrame_1tt0t_890{position:relative;display:grid;place-items:center;width:max-content;min-width:100%;min-height:100%}._canvasMedia_1tt0t_899{position:relative;display:block;flex-shrink:0;margin:0 auto;overflow:hidden}._canvasStatusOverlay_1tt0t_907{position:absolute;inset:0;z-index:2;display:flex;align-items:center;justify-content:center;padding:24px;background:color-mix(in srgb,var(--surface-scrim) 68%,transparent);pointer-events:none}._canvasStatusCard_1tt0t_919{display:inline-flex;align-items:center;gap:10px;padding:12px 16px;border:1px solid color-mix(in srgb,var(--border-strong) 44%,white);border-radius:var(--radius-md);background:#0f172ac7;color:#fff;box-shadow:0 18px 30px #0f172a38;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px)}._canvasImage_1tt0t_932{display:block;width:100%;height:100%;-webkit-user-select:none;user-select:none}._overlay_1tt0t_939{position:absolute;inset:0;cursor:crosshair}._overlaySelect_1tt0t_945{cursor:default}._overlayPan_1tt0t_949{cursor:grab}._overlaySvg_1tt0t_953{position:absolute;inset:0;display:block;width:100%;height:100%;pointer-events:none}._overlayHitLayer_1tt0t_962{position:absolute;inset:0;display:block;width:100%;height:100%;pointer-events:auto}._arrowHitArea_1tt0t_971{stroke:transparent;stroke-width:24;pointer-events:stroke;cursor:move}._canvasHandleHit_1tt0t_978{fill:transparent;pointer-events:all;cursor:grab;outline:none}._canvasResizeHandleHit_1tt0t_985{cursor:nwse-resize}._canvasHandleVisible_1tt0t_989{--canvas-handle-fill: var(--brand-primary);--canvas-handle-outline: var(--surface-elevated);--canvas-handle-shadow: 0 6px 12px rgba(15, 23, 42, .18);fill:var(--canvas-handle-fill);stroke:var(--canvas-handle-outline);stroke-width:3;vector-effect:non-scaling-stroke;filter:drop-shadow(var(--canvas-handle-shadow));pointer-events:none}._canvasHandleHit_1tt0t_978:focus-visible+._canvasHandleVisible_1tt0t_989{stroke:color-mix(in srgb,var(--brand-primary) 72%,var(--surface-elevated));stroke-width:4}._pin_1tt0t_1006,._note_1tt0t_1007{position:absolute;transform:translate(-50%,-50%);display:inline-flex;align-items:center;justify-content:center;min-width:28px;min-height:28px;border:2px solid var(--surface-elevated);border-radius:999px;box-shadow:0 8px 18px #0f172a38;color:#fff;font-size:.74rem;font-weight:800;pointer-events:auto}._annotationNumberBadge_1tt0t_1024{position:absolute;display:inline-flex;align-items:center;justify-content:center;min-width:28px;min-height:28px;padding:0 8px;border:2px solid var(--surface-elevated);border-radius:999px;box-shadow:0 8px 18px #0f172a38;color:#fff;font-size:.74rem;font-weight:800;line-height:1;pointer-events:none;z-index:2}._note_1tt0t_1007{min-width:38px;padding:0 10px;border-radius:999px}._box_1tt0t_1049{position:absolute;border:2px solid;border-radius:var(--radius-sm);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--surface-elevated) 34%,transparent);background:color-mix(in srgb,var(--surface-elevated) 10%,transparent);pointer-events:auto}._boxNumberBadge_1tt0t_1058{top:0;left:0;transform:translate(-28%,-36%)}._arrowNumberBadge_1tt0t_1064{transform:translate(-50%,-50%)}._boxSurface_1tt0t_1068{position:absolute;inset:0;border:0;background:transparent;cursor:move}._boxSurface_1tt0t_1068:focus-visible{outline:2px solid color-mix(in srgb,var(--brand-primary) 34%,var(--surface-elevated));outline-offset:2px}._selected_1tt0t_1081{outline:3px solid color-mix(in srgb,var(--surface-elevated) 92%,transparent);outline-offset:1px}._fieldGroup_1tt0t_1086{display:flex;flex-direction:column;gap:8px;padding:14px 16px}._detailPanel_1tt0t_260 ._fieldGroup_1tt0t_1086{padding-top:12px;padding-bottom:12px}._textInput_1tt0t_1098,._textArea_1tt0t_1099,._select_1tt0t_1081{width:100%;box-sizing:border-box;font:inherit;font-size:.8125rem;line-height:1.5}._sessionTitleInput_1tt0t_1108{font-size:1rem;font-weight:600}._sessionInstructionField_1tt0t_1113{min-height:112px}._textArea_1tt0t_1099{min-height:110px;resize:vertical}._detailEmpty_1tt0t_1122,._emptyState_1tt0t_1123,._errorState_1tt0t_1124{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;min-height:240px;padding:24px;text-align:center}._payloadModalBody_1tt0t_1135{display:flex;flex-direction:column;gap:12px;min-height:0}._payloadModalToolbar_1tt0t_1142{display:flex;align-items:center;justify-content:space-between;gap:12px}._payloadViewToggle_1tt0t_1149,._payloadModalActions_1tt0t_1150{display:inline-flex;flex-wrap:wrap;align-items:center;gap:8px}._payloadModalPreview_1tt0t_1157{margin:0;min-height:360px;max-height:min(70vh,720px);padding:16px;overflow:auto;scrollbar-gutter:stable;white-space:pre-wrap;word-break:break-word;font-size:.78rem;line-height:1.55;border-radius:var(--radius-md);color:var(--text-body)}._statusBar_1tt0t_1172{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px 16px;border-top:1px solid var(--border-default);color:var(--text-secondary);font-size:.82rem;background:color-mix(in srgb,var(--surface-panel) 88%,var(--surface-inset))}._annotationSummary_1tt0t_1184{font-size:.82rem;line-height:1.5}@media(max-width:1180px){._shell_1tt0t_1{grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(320px,1fr) auto;gap:12px;padding:12px}._sessionContextBar_1tt0t_266,._panelHeader_1tt0t_325,._toolRail_1tt0t_700,._statusBar_1tt0t_1172,._payloadModalToolbar_1tt0t_1142,._markerHelpHeader_1tt0t_446{flex-wrap:wrap}._sessionContextRight_1tt0t_278,._sessionContextLeft_1tt0t_277,._canvasHeading_1tt0t_342{min-width:0}._sessionContextRight_1tt0t_278{width:100%;justify-content:flex-start}._toolbarActions_1tt0t_773{width:100%;margin-left:0}._toolbarUtilities_1tt0t_839{margin-left:0}._toolGroup_1tt0t_719{max-width:100%}._canvasWorkspace_1tt0t_311{grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr)}._toolbarViewportCluster_1tt0t_737{margin-left:0}._canvasToolRail_1tt0t_709{flex-direction:row;justify-content:flex-start;overflow-x:auto;padding:0;border-right:0;border-bottom:1px solid var(--border-default)}._statusBar_1tt0t_1172{align-items:flex-start}._detailEmpty_1tt0t_1122,._emptyState_1tt0t_1123,._errorState_1tt0t_1124{min-height:180px}}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{j as t,r as s,R as en}from"./vendor-react-CKJs5o3c.js";import{u as Rs,a as wa,D as As,c as Es,S as Ps,v as Ms,C as Bs,f as Fs,s as Ds,K as Os,P as Hs,d as zs}from"./vendor-dnd-CJ-AjP-Y.js";import{R as Us,f as le,e as tn,h as Gs,t as Ia,M as nn}from"./index-BUplSsv_.js";import{s as Ks,A as Vs}from"./AssetTraySortControl-Kf1pelSy.js";import{aE as Sa,ai as Ws,S as Ys,a5 as qs,V as Xs,q as Js,t as Zs,af as En,r as Ca,a6 as Qs,w as Na,aP as er,R as tr,aQ as nr,aR as ar,aS as sr,aT as rr,aU as Bn,C as Fn,aV as or,aW as Ba,aX as Fa,aY as Da,aZ as Oa,u as Dn,Q as Ta}from"./vendor-icons-BkFLXavV.js";import"./vendor-markdown-_lhNCyq-.js";import"./vendor-router-AqJMU8Lz.js";function ir({copied:r,disabled:l=!1,label:h,onClick:g,title:v="Copy image reference",ariaLabel:_,className:D=""}){return t.jsx(Us,{copied:r,disabled:l,label:"",onClick:g,title:v,ariaLabel:_,className:D,children:h})}const lr="_shell_1tt0t_1",cr="_shellWithImageTray_1tt0t_18",dr="_shellImageTrayOpen_1tt0t_22",ur="_imageTrayPanel_1tt0t_26",mr="_imageTrayPanelOpen_1tt0t_50",fr="_imageTrayHeader_1tt0t_58",hr="_imageTrayTitle_1tt0t_73",pr="_imageTraySearch_1tt0t_85",gr="_imageTraySearchIcon_1tt0t_91",yr="_imageTraySearchInput_1tt0t_100",br="_imageTraySortControlRow_1tt0t_117",xr="_imageTrayList_1tt0t_124",vr="_imageTrayState_1tt0t_136",_r="_imageTrayStateError_1tt0t_137",kr="_imageTrayItem_1tt0t_149",wr="_imageTrayItemActive_1tt0t_171",Ir="_imageTrayThumb_1tt0t_181",Sr="_imageTrayItemBody_1tt0t_198",Cr="_imageTrayItemTitle_1tt0t_206",Nr="_imageTrayItemTask_1tt0t_207",Tr="_imageTrayItemMetaDetails_1tt0t_208",jr="_imageTrayItemMeta_1tt0t_208",$r="_imageTrayItemReference_1tt0t_246",Lr="_panel_1tt0t_253",Rr="_sessionPanel_1tt0t_259",Ar="_detailPanel_1tt0t_260",Er="_sessionContextBar_1tt0t_266",Pr="_sessionContextLeft_1tt0t_277",Mr="_sessionContextRight_1tt0t_278",Br="_sessionContextLabel_1tt0t_293",Fr="_sessionContextSpacer_1tt0t_299",Dr="_canvasPanel_1tt0t_304",Or="_canvasWorkspace_1tt0t_311",Hr="_canvasMain_1tt0t_318",zr="_panelHeader_1tt0t_325",Ur="_panelHeaderText_1tt0t_334",Gr="_panelTitle_1tt0t_338",Kr="_canvasHeading_1tt0t_342",Vr="_sessionActions_1tt0t_346",Wr="_taskLinkModalBody_1tt0t_354",Yr="_taskLinkList_1tt0t_364",qr="_taskLinkOption_1tt0t_372",Xr="_taskLinkOptionActive_1tt0t_387",Jr="_taskLinkOptionTitle_1tt0t_395",Zr="_taskLinkActions_1tt0t_399",Qr="_sessionList_1tt0t_405",eo="_annotationList_1tt0t_406",to="_markerHelpModalBody_1tt0t_416",no="_openImageModalBody_1tt0t_422",ao="_openImageField_1tt0t_428",so="_openImageActions_1tt0t_432",ro="_markerHelpItem_1tt0t_438",oo="_markerHelpHeader_1tt0t_446",io="_markerHelpExample_1tt0t_458",lo="_sessionCard_1tt0t_462",co="_annotationCard_1tt0t_463",uo="_sessionEmptyState_1tt0t_477",mo="_sessionCardButton_1tt0t_484",fo="_annotationCardButton_1tt0t_494",ho="_sessionCardBody_1tt0t_506",po="_sessionCardActive_1tt0t_512",go="_annotationCardActive_1tt0t_513",yo="_annotationMeta_1tt0t_528",bo="_annotationDragHandle_1tt0t_535",xo="_annotationCardDragging_1tt0t_561",vo="_annotationDragOverlay_1tt0t_565",_o="_annotationDragOverlayGrip_1tt0t_572",ko="_annotationDragOverlayTitle_1tt0t_576",wo="_annotationInstructionPreview_1tt0t_582",Io="_annotationPreviewFooter_1tt0t_590",So="_annotationInstructionEditor_1tt0t_597",Co="_annotationTypeField_1tt0t_603",No="_annotationGeometryDetails_1tt0t_609",To="_annotationGeometryFields_1tt0t_618",jo="_annotationGeometryField_1tt0t_618",$o="_annotationGeometryLabel_1tt0t_631",Lo="_annotationGeometryInput_1tt0t_636",Ro="_annotationInstructionButton_1tt0t_641",Ao="_annotationInstructionField_1tt0t_650",Eo="_sessionMeta_1tt0t_654",Po="_sessionTitle_1tt0t_661",Mo="_annotationTitle_1tt0t_662",Bo="_sessionTimestamp_1tt0t_668",Fo="_annotationKind_1tt0t_669",Do="_annotationInstructionTypeIcon_1tt0t_673",Oo="_sessionInstructionPreview_1tt0t_679",Ho="_sessionInstructionEditor_1tt0t_687",zo="_sessionCardFooter_1tt0t_693",Uo="_toolRail_1tt0t_700",Go="_canvasToolRail_1tt0t_709",Ko="_toolbarCluster_1tt0t_730",Vo="_toolbarViewportCluster_1tt0t_737",Wo="_toolbarSeparator_1tt0t_741",Yo="_toolBtn_1tt0t_747",qo="_toolRailButton_1tt0t_751",Xo="_toolbarButton_1tt0t_761",Jo="_toolBtnActive_1tt0t_766",Zo="_toolbarActions_1tt0t_773",Qo="_toolbarSelectionActions_1tt0t_782",ei="_toolbarColorPicker_1tt0t_790",ti="_colorPickerButton_1tt0t_794",ni="_colorPickerSwatch_1tt0t_799",ai="_colorPickerPopover_1tt0t_807",si="_colorOption_1tt0t_822",ri="_colorOptionActive_1tt0t_832",oi="_toolbarUtilities_1tt0t_839",ii="_iconButton_1tt0t_847",li="_ghostBtn_1tt0t_852",ci="_payloadBtn_1tt0t_853",di="_backToTaskBtn_1tt0t_854",ui="_canvasScroller_1tt0t_874",mi="_canvasFrame_1tt0t_890",fi="_canvasMedia_1tt0t_899",hi="_canvasStatusOverlay_1tt0t_907",pi="_canvasStatusCard_1tt0t_919",gi="_canvasImage_1tt0t_932",yi="_overlay_1tt0t_939",bi="_overlaySelect_1tt0t_945",xi="_overlayPan_1tt0t_949",vi="_overlaySvg_1tt0t_953",_i="_overlayHitLayer_1tt0t_962",ki="_arrowHitArea_1tt0t_971",wi="_canvasHandleHit_1tt0t_978",Ii="_canvasResizeHandleHit_1tt0t_985",Si="_canvasHandleVisible_1tt0t_989",Ci="_pin_1tt0t_1006",Ni="_note_1tt0t_1007",Ti="_annotationNumberBadge_1tt0t_1024",ji="_box_1tt0t_1049",$i="_boxNumberBadge_1tt0t_1058",Li="_arrowNumberBadge_1tt0t_1064",Ri="_boxSurface_1tt0t_1068",Ai="_selected_1tt0t_1081",Ei="_textInput_1tt0t_1098",Pi="_textArea_1tt0t_1099",Mi="_select_1tt0t_1081",Bi="_sessionTitleInput_1tt0t_1108",Fi="_sessionInstructionField_1tt0t_1113",Di="_detailEmpty_1tt0t_1122",Oi="_emptyState_1tt0t_1123",Hi="_payloadModalBody_1tt0t_1135",zi="_payloadModalToolbar_1tt0t_1142",Ui="_payloadViewToggle_1tt0t_1149",Gi="_payloadModalActions_1tt0t_1150",Ki="_payloadModalPreview_1tt0t_1157",Vi="_statusBar_1tt0t_1172",Wi="_annotationSummary_1tt0t_1184",n={shell:lr,shellWithImageTray:cr,shellImageTrayOpen:dr,imageTrayPanel:ur,imageTrayPanelOpen:mr,imageTrayHeader:fr,imageTrayTitle:hr,imageTraySearch:pr,imageTraySearchIcon:gr,imageTraySearchInput:yr,imageTraySortControlRow:br,imageTrayList:xr,imageTrayState:vr,imageTrayStateError:_r,imageTrayItem:kr,imageTrayItemActive:wr,imageTrayThumb:Ir,imageTrayItemBody:Sr,imageTrayItemTitle:Cr,imageTrayItemTask:Nr,imageTrayItemMetaDetails:Tr,imageTrayItemMeta:jr,imageTrayItemReference:$r,panel:Lr,sessionPanel:Rr,detailPanel:Ar,sessionContextBar:Er,sessionContextLeft:Pr,sessionContextRight:Mr,sessionContextLabel:Br,sessionContextSpacer:Fr,canvasPanel:Dr,canvasWorkspace:Or,canvasMain:Hr,panelHeader:zr,panelHeaderText:Ur,panelTitle:Gr,canvasHeading:Kr,sessionActions:Vr,taskLinkModalBody:Wr,taskLinkList:Yr,taskLinkOption:qr,taskLinkOptionActive:Xr,taskLinkOptionTitle:Jr,taskLinkActions:Zr,sessionList:Qr,annotationList:eo,markerHelpModalBody:to,openImageModalBody:no,openImageField:ao,openImageActions:so,markerHelpItem:ro,markerHelpHeader:oo,markerHelpExample:io,sessionCard:lo,annotationCard:co,sessionEmptyState:uo,sessionCardButton:mo,annotationCardButton:fo,sessionCardBody:ho,sessionCardActive:po,annotationCardActive:go,annotationMeta:yo,annotationDragHandle:bo,annotationCardDragging:xo,annotationDragOverlay:vo,annotationDragOverlayGrip:_o,annotationDragOverlayTitle:ko,annotationInstructionPreview:wo,annotationPreviewFooter:Io,annotationInstructionEditor:So,annotationTypeField:Co,annotationGeometryDetails:No,annotationGeometryFields:To,annotationGeometryField:jo,annotationGeometryLabel:$o,annotationGeometryInput:Lo,annotationInstructionButton:Ro,annotationInstructionField:Ao,sessionMeta:Eo,sessionTitle:Po,annotationTitle:Mo,sessionTimestamp:Bo,annotationKind:Fo,annotationInstructionTypeIcon:Do,sessionInstructionPreview:Oo,sessionInstructionEditor:Ho,sessionCardFooter:zo,toolRail:Uo,canvasToolRail:Go,toolbarCluster:Ko,toolbarViewportCluster:Vo,toolbarSeparator:Wo,toolBtn:Yo,toolRailButton:qo,toolbarButton:Xo,toolBtnActive:Jo,toolbarActions:Zo,toolbarSelectionActions:Qo,toolbarColorPicker:ei,colorPickerButton:ti,colorPickerSwatch:ni,colorPickerPopover:ai,colorOption:si,colorOptionActive:ri,toolbarUtilities:oi,iconButton:ii,ghostBtn:li,payloadBtn:ci,backToTaskBtn:di,canvasScroller:ui,canvasFrame:mi,canvasMedia:fi,canvasStatusOverlay:hi,canvasStatusCard:pi,canvasImage:gi,overlay:yi,overlaySelect:bi,overlayPan:xi,overlaySvg:vi,overlayHitLayer:_i,arrowHitArea:ki,canvasHandleHit:wi,canvasResizeHandleHit:Ii,canvasHandleVisible:Si,pin:Ci,note:Ni,annotationNumberBadge:Ti,box:ji,boxNumberBadge:$i,arrowNumberBadge:Li,boxSurface:Ri,selected:Ai,textInput:Ei,textArea:Pi,select:Mi,sessionTitleInput:Bi,sessionInstructionField:Fi,detailEmpty:Di,emptyState:Oi,payloadModalBody:Hi,payloadModalToolbar:zi,payloadViewToggle:Ui,payloadModalActions:Gi,payloadModalPreview:Ki,statusBar:Vi,annotationSummary:Wi};function Yi({id:r,children:l}){return t.jsx(t.Fragment,{children:l(zs({id:r}))})}const ja=[{value:"review",label:"Review"},{value:"change",label:"Change"},{value:"question",label:"Question"}],$a=[{value:"select",label:"Select",icon:or},{value:"pin",label:"Pin",icon:Ba},{value:"box",label:"Box",icon:Fa},{value:"arrow",label:"Arrow",icon:Da},{value:"text-note",label:"Note",icon:Oa}],qi=200,La={pin:Ba,box:Fa,arrow:Da,"text-note":Oa},Ra={pin:"Pin",box:"Box",arrow:"Arrow","text-note":"Note"},Xi={review:Bn,change:Dn,question:Fn,issue:Fn,idea:Bn},an={select:{short:"Select and edit existing markers.",detail:"Use Select to click, drag, reorder, resize, and update markers that are already on the image.",example:"Example: move an existing marker after the screenshot changes."},pin:{short:"Mark a precise spot.",detail:"Use Pin when feedback points to one exact location instead of a broader area.",example:'Example: "This icon is misaligned by 2px."'},box:{short:"Mark an area or component.",detail:"Use Box when the feedback applies to a whole region, card, panel, or bounded UI block.",example:'Example: "This whole card needs tighter padding and a stronger border."'},arrow:{short:"Show direction or relationship.",detail:"Use Arrow when you need to show movement, attachment, flow, or source-to-target intent.",example:'Example: "This tooltip should anchor to this button, not the panel."'},"text-note":{short:"Add a comment-style point marker.",detail:"Use Note when you want a point marker that reads more like a comment or open question.",example:'Example: "Ask design whether this badge should stay."'}},Tt={question:"#0f766e",change:"#2563eb",issue:"#dc2626",idea:"#d97706",review:"#7c3aed"},Ji=["#7c3aed","#2563eb","#0f766e","#dc2626","#d97706","#111827"],ye="review";function et(r){const l=String(r.displayName||"").trim();return l?`${l} review`:"Annotated session"}function Ha(){return`annotation-${Math.random().toString(36).slice(2,10)}`}function I(r){return!Number.isFinite(r)||r<=0?0:r>=1?1:r}function Ee(r){return I(Math.max(.02,r))}function Re(r){return r?[String(r.taskId||"").trim(),String(r.assetId||"").trim(),String(r.path||"").trim()].join("::"):""}function za(r){if(!(r instanceof HTMLElement))return!1;const l=r.tagName.toLowerCase();return r.isContentEditable?!0:l==="input"||l==="textarea"||l==="select"}function Zi(r){if(!(r instanceof HTMLElement))return!1;if(za(r))return!0;const l=r.tagName.toLowerCase();return l==="button"||l==="a"||r.getAttribute("role")==="button"}function Ae(r){return r.map((l,h)=>({...l,order:h}))}function Pn(r){if(!r)return"Unsaved";const l=new Date(r);return Number.isNaN(l.getTime())?"Unsaved":l.toLocaleString()}function Qi(r){const l=typeof r=="number"&&Number.isFinite(r)?Math.max(0,r):0;return l<1024?`${l}B`:l<1024*1024?`${(l/1024).toFixed(1)}KB`:`${(l/(1024*1024)).toFixed(1)}MB`}function el(r){if(!r)return"";const l=new Date(r);if(Number.isNaN(l.getTime()))return"";const g=new Date().getTime()-l.getTime(),v=Math.floor(g/(1e3*60*60*24));return v<=0?"Today":v===1?"Yesterday":v<7?`${v}d ago`:v<30?`${Math.floor(v/7)}w ago`:l.toLocaleDateString()}function sn(r){const l=String(r.createdByActor?.label||"").trim();return l||null}function tl(r){const l=String(r||"").trim().replace(/\s+/g," ");return l?l.length>110?`${l.slice(0,107)}...`:l:""}function Aa(r,l,h,g=Tt[ye]){const v={id:Ha(),order:0,instruction:"",markerType:ye,color:g};if(r==="pin")return{...v,kind:r,x:l.x,y:l.y};if(r==="text-note")return{...v,kind:r,x:l.x,y:l.y};if(r==="box"){const D=h||l;return{...v,kind:r,x:I(Math.min(l.x,D.x)),y:I(Math.min(l.y,D.y)),width:Ee(Math.abs(D.x-l.x)),height:Ee(Math.abs(D.y-l.y))}}const _=h||l;return{...v,kind:"arrow",x:l.x,y:l.y,x2:_.x,y2:_.y}}function rn(r){return r.color?r.color:Tt[r.markerType||ye]}function nl(r,l){const h=Math.max(l.width,1),g=Math.max(l.height,1),v=r.x*h,_=r.y*g,D=r.x2*h,de=r.y2*g,ue=D-v,jt=de-_,Pe=Math.hypot(ue,jt)||1,tt=ue/Pe,Me=jt/Pe,W=Math.max(10,Math.min(16,Pe-2)),Se=W*.62,nt=D-tt*W,Ce=de-Me*W,at=-Me,$=tt;return{shaftX1:v,shaftY1:_,shaftX2:nt,shaftY2:Ce,headPoints:[`${D},${de}`,`${nt+at*Se},${Ce+$*Se}`,`${nt-at*Se},${Ce-$*Se}`].join(" ")}}function al(r,l){return{...r,markerType:l,color:r.color||Tt[l]}}function sl(r,l){return{...r,id:Ha(),order:l}}function rl(r,l){const h=String(r||"").trim()||(l?et(l):"Annotated session");return/\bcopy$/i.test(h)?`${h} 2`:`${h} copy`}function ol(r,l,h){if(l===h||l<0||h<0||l>=r.length||h>=r.length)return r;const g=[...r],[v]=g.splice(l,1);return v?(g.splice(h,0,v),Ae(g)):r}function ce(r){return String(Math.round(I(r)*1e3)/10)}function il(r){const l=Number.parseFloat(r);return Number.isFinite(l)?I(l/100):null}function ll(r,l,h){return r.kind==="pin"||r.kind==="text-note"?l==="x"||l==="y"?{...r,[l]:I(h)}:r:r.kind==="box"?l==="x"||l==="y"?{...r,[l]:I(h)}:l==="width"||l==="height"?{...r,[l]:Ee(h)}:r:l==="x"||l==="y"||l==="x2"||l==="y2"?{...r,[l]:I(h)}:r}function cl(r){return r.kind==="pin"||r.kind==="text-note"?[{key:"x",label:"X",value:ce(r.x)},{key:"y",label:"Y",value:ce(r.y)}]:r.kind==="box"?[{key:"x",label:"X",value:ce(r.x)},{key:"y",label:"Y",value:ce(r.y)},{key:"width",label:"Width",value:ce(r.width)},{key:"height",label:"Height",value:ce(r.height)}]:[{key:"x",label:"Start X",value:ce(r.x)},{key:"y",label:"Start Y",value:ce(r.y)},{key:"x2",label:"End X",value:ce(r.x2)},{key:"y2",label:"End Y",value:ce(r.y2)}]}function dl(r){if(!r)return null;const l=Math.round(r.x*100),h=Math.round(r.y*100),g=Math.round(r.width*100),v=Math.round(r.height*100);return`crop ${l}%, ${h}% size ${g}% x ${v}%`}function Mn(r){return Number.isFinite(r)?Math.min(4,Math.max(.25,Number(r.toFixed(2)))):1}function Ea(r){const l=[`Annotated attachment: ${r.title||r.image.displayName}`,`Image: ${r.image.displayName}`,`Image Reference: ${r.image.referenceLabel||r.image.assetId}`,`Task ID: ${r.taskId}`,r.globalInstruction?`Global instruction: ${r.globalInstruction}`:"Global instruction: None provided.","Markers:"];return r.annotations.length===0?(l.push("0. No markers."),l.join(`
|
|
2
|
-
`)):(r.annotations.forEach((h,g)=>{const v=h.markerType||ye,_=dl(h.cropHint);l.push(`${g+1}. ${h.kind} (${v})`),l.push(`Instruction: ${h.instruction||"No marker instruction."}`),_&&l.push(`Region: ${_}`)}),l.join(`
|
|
3
|
-
`))}function on(r){return{title:r.title,globalInstruction:r.globalInstruction,annotations:Ae(r.annotations)}}function Pa(r){return JSON.stringify(on(r))}function Ma(r){const l=JSON.parse(r);return on({title:String(l?.title||""),globalInstruction:String(l?.globalInstruction||""),annotations:Array.isArray(l?.annotations)?l.annotations:[]})}function ul(r,l){return on({title:r?.title||l,globalInstruction:r?.globalInstruction||"",annotations:r?.annotations||[]})}function vl({runtimeMode:r="local",apiBaseUrl:l="",cloudAuthBaseUrl:h="",workspaceId:g="default",sessionLoadReady:v=!0,requestedTarget:_=null,requestedSessionId:D=null,requestedOpenVersion:de=0,imageTrayOpen:ue,onCloseImageTray:jt,resolveTaskReferenceLabel:Pe,resolveImageReferenceLabel:tt,onRequestedTargetHandled:Me,onOpenTarget:W,onContextChange:Se,viewportByContextKey:nt,onViewportChange:Ce,onBackToTask:at}){const $=r==="cloud"&&(h||l)||"",[Ua,$t]=s.useState(_),[Lt,Be]=s.useState([]),[y,Fe]=s.useState(null),[ln,st]=s.useState(!1),[De,rt]=s.useState(""),[Oe,ot]=s.useState(""),[R,me]=s.useState([]),[A,Z]=s.useState(null),[it,Q]=s.useState(!1),[On,cn]=s.useState(null),[Rt,Hn]=s.useState(Tt[ye]),[At,Et]=s.useState(!1),[E,He]=s.useState("select"),[Ga,Ne]=s.useState(!1),[Pt,zn]=s.useState(!1),[ee,te]=s.useState(!1),[Un,f]=s.useState(null),[Y,B]=s.useState("saved"),[ml,z]=s.useState(null),[Mt,Gn]=s.useState(!1),[fe,dn]=s.useState(null),[be,un]=s.useState(!1),[Ka,mn]=s.useState(!1),[fn,Kn]=s.useState("json"),[Va,Bt]=s.useState(!1),[hn,Vn]=s.useState(""),[pn,Wa]=s.useState([]),[Ft,Wn]=s.useState(!1),[ze,Yn]=s.useState(!1),[Dt,gn]=s.useState(!1),[Ot,yn]=s.useState(!1),[Ya,qn]=s.useState(!1),[qa,Ht]=s.useState(!1),[bn,zt]=s.useState(""),[lt,Xn]=s.useState(!1),[xn,Xa]=s.useState([]),[Ut,Ja]=s.useState(""),[vn,Za]=s.useState("updated"),[_n,Qa]=s.useState("desc"),[es,Jn]=s.useState(!1),[Zn,Qn]=s.useState(null),[q,ct]=s.useState(!1),[dt,ut]=s.useState(!1),[P,mt]=s.useState(1),[ts,ft]=s.useState(!1),[ns,ht]=s.useState(!1),[Gt,ea]=s.useState(!1),[T,pt]=s.useState({width:0,height:0}),ta=s.useRef(null),ne=s.useRef(null),kn=s.useRef(null),na=s.useRef(null),xe=s.useRef(D),he=s.useRef(""),Kt=s.useRef(0),wn=s.useRef(""),Te=s.useRef(0),Vt=s.useRef(null),aa=s.useRef(0),ve=s.useRef(!1),gt=s.useRef(null),In=s.useRef(null),_e=s.useRef(null),O=s.useRef(""),F=s.useRef(""),Wt=s.useRef(null),ae=s.useRef(null),Sn=s.useRef(!1),Ue=s.useRef(!1),Yt=s.useRef(null),yt=s.useRef(null),bt=s.useRef(null),Cn=s.useRef(null),xt=s.useRef(null),Ge=s.useRef(!1),Ke=s.useRef(!0),sa=s.useRef(""),ra=s.useRef(Ce),je=s.useRef(null),Ve=s.useRef(null),We=s.useRef(null),Ye=s.useRef(null),ke=s.useRef(null),se=s.useRef(null),oa=s.useRef(null),ia=s.useRef(null),Nn=s.useRef(new Map),b=s.useMemo(()=>Lt.find(e=>e.id===y)||null,[y,Lt]),U=s.useMemo(()=>`workspaceId=${encodeURIComponent(String(g||"default").trim()||"default")}`,[g]),j=s.useMemo(()=>({"x-taskforce-workspace-id":String(g||"default").trim()||"default"}),[g]),pe=s.useMemo(()=>R.find(e=>e.id===A)||null,[R,A]),vt=s.useMemo(()=>R.find(e=>e.id===On)||null,[On,R]),as=Rs(wa(Hs,{activationConstraint:{distance:6}}),wa(Os,{coordinateGetter:Ds})),re=s.useMemo(()=>Re(_),[_]),ge=typeof W=="function",d=ge?_:Ua,K=s.useMemo(()=>{const e=Re(d);return e?`${e}::${y||""}`:""},[d,y]),_t=K?nt?.[K]??null:null,qt=s.useMemo(()=>{const e=String(b?.taskId||"").trim();if(!e)return"";const a=Pe?.(e).trim()||"";if(a)return a;const o=String(d?.taskId||"").trim(),i=String(d?.taskReferenceLabel||"").trim();return e===o&&i&&i!==e?i:e},[d?.taskId,d?.taskReferenceLabel,Pe,b?.taskId]),la=s.useMemo(()=>{const e=hn.trim().toLowerCase();return e?pn.filter(a=>[a.title,a.referenceLabel,a.id].filter(Boolean).join(" ").toLowerCase().includes(e)):pn},[pn,hn]),kt=s.useMemo(()=>{const e=String(d?.assetId||"").trim();if(!e)return"";const a=tt?.(e).trim()||"";return a||String(d?.imageReferenceLabel||"").trim()},[d?.assetId,d?.imageReferenceLabel,tt]),Tn=pe?.color||Rt,ca=s.useMemo(()=>on({title:De,globalInstruction:Oe,annotations:R}),[R,Oe,De]),qe=s.useMemo(()=>Pa(ca),[ca]),da=qe!==F.current,x=s.useMemo(()=>({width:Math.max(T.width*P,0),height:Math.max(T.height*P,0)}),[T.height,T.width,P]),Xe=s.useMemo(()=>({visibleRadius:7,hitRadius:11}),[]),jn=s.useMemo(()=>`0 0 ${Math.max(x.width,1)} ${Math.max(x.height,1)}`,[x.height,x.width]),wt=typeof ue=="boolean",ua=s.useMemo(()=>{const e=Ut.trim().toLowerCase();let a=xn;return e&&(a=xn.filter(o=>[o.displayName,o.originalFilename,o.imageReferenceLabel,o.taskReferenceLabel,o.assetId].filter(Boolean).join(" ").toLowerCase().includes(e))),Ks(a,vn,_n)},[xn,Ut,vn,_n]),Je=s.useMemo(()=>{const e=ne.current;return e?P>1||x.width>e.clientWidth+1||x.height>e.clientHeight+1:P>1},[x.height,x.width,P]),$n=`${Math.round(P*100)}%`,X=Je&&(ts||ns),Ln=s.useMemo(()=>{const e=new Map;return R.forEach((a,o)=>{e.set(a.id,o+1)}),e},[R]);s.useEffect(()=>{xe.current=D},[D]),s.useEffect(()=>{const e=na.current;if(!e||!A||it)return;e.focus();const a=e.value.length;e.setSelectionRange(a,a)},[it,A]),s.useEffect(()=>{_e.current=y},[y]),s.useEffect(()=>{ra.current=Ce},[Ce]);const Xt=s.useCallback(()=>{xt.current!==null&&(window.clearTimeout(xt.current),xt.current=null);const e=Cn.current;Cn.current=null,e&&K&&ra.current?.(K,e)},[K]),oe=s.useCallback(e=>{if(Ge.current||!K)return;const a=ne.current;a&&(Cn.current={zoomLevel:e??P,scrollLeft:Math.max(0,Math.round(a.scrollLeft)),scrollTop:Math.max(0,Math.round(a.scrollTop))},xt.current===null&&(xt.current=window.setTimeout(Xt,qi)))},[K,Xt,P]),It=s.useCallback(()=>{const e=ne.current;if(!e||e.clientWidth<=0||e.clientHeight<=0||T.width<=0||T.height<=0)return;const a=Mn(Math.min(e.clientWidth/T.width,e.clientHeight/T.height)),o=T.width*a,i=T.height*a;Ke.current=!0,Ge.current=!0,mt(a),window.requestAnimationFrame(()=>{e.scrollLeft=Math.max(0,(o-e.clientWidth)/2),e.scrollTop=Math.max(0,(i-e.clientHeight)/2),oe(a),window.requestAnimationFrame(()=>{Ge.current=!1})})},[T.height,T.width,oe]);s.useEffect(()=>()=>{oe(),Xt()},[K,Xt,oe]),s.useEffect(()=>{st(!1)},[y]),s.useEffect(()=>{if(!pe){Et(!1);return}Hn(pe.color||Tt[pe.markerType||ye])},[pe]);const Jt=s.useCallback(async e=>{const a=typeof performance<"u"?performance.now():Date.now(),o=await le(`/api/taskforce/annotated-attachments/sessions?${U}`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",...j},body:JSON.stringify({taskId:e.taskId,baseImageAssetId:e.assetId,title:et(e),globalInstruction:"",annotations:[]})},$),i=await o.json().catch(()=>({}));if(!o.ok)throw new Error(String(i?.error||"Failed to create session."));const c=i?.session;if(!c?.id)throw new Error("Failed to create session.");return tn("annotated_session_create_completed",{assetId:e.assetId,taskId:e.taskId||null,sessionId:c.id,durationMs:Math.round((typeof performance<"u"?performance.now():Date.now())-a),debugTimings:i?.debugTimings||null,serverTiming:typeof o.headers?.get=="function"&&o.headers.get("server-timing")||null}),c},[j,$,U]),ma=s.useCallback(e=>new Promise((a,o)=>{const i=new FileReader;i.onload=()=>a(typeof i.result=="string"?i.result:""),i.onerror=()=>o(i.error||new Error("Failed to read clipboard image.")),i.readAsDataURL(e)}),[]),L=s.useCallback(()=>{gt.current!==null&&(window.clearTimeout(gt.current),gt.current=null),bt.current!==null&&(window.clearTimeout(bt.current),bt.current=null)},[]),Ze=s.useCallback(e=>{rt(e.title),ot(e.globalInstruction),me(e.annotations),Z(a=>a&&e.annotations.some(o=>o.id===a)?a:null)},[]),we=s.useCallback((e,a)=>{const o=et(a||d||{assetId:e.baseImageAssetId,displayName:"Annotated session"}),i=ul(e,o),c=Pa(i);ve.current=!0,L(),Ze(i),F.current=c,O.current=c,Wt.current=null,Ue.current=!1,Yt.current=null,yt.current=null,z(null),B("saved"),te(!1)},[d,Ze,L]),St=s.useCallback(e=>{ve.current=!0,L(),Be([]),Fe(null),Ne(!1),st(!1),rt(et(e)),ot(""),me([]),Z(null),Q(!1),F.current="",O.current="",Wt.current=null,Ue.current=!1,Yt.current=null,yt.current=null,dn(null),mn(!1),z(null),B("saved"),te(!1)},[L]),$e=s.useCallback(async(e,a,o)=>{const i=_e.current;if(!i)return!0;if(e===F.current)return ae.current||(z(null),B("saved")),!0;if(ae.current){if(Ue.current=!0,!o?.waitForInFlight||!await ae.current)return!1;const p=O.current;return p===F.current?!0:$e(p,a,o)}L();const c=Ma(e);Yt.current=i,Wt.current=e,te(!0),f(null),z(null),B("saving");const m=(async()=>{try{const u=await le(`/api/taskforce/annotated-attachments/sessions/${encodeURIComponent(i)}?${U}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json",...j},body:JSON.stringify(c)},$),p=await u.json().catch(()=>({}));if(!u.ok)throw new Error(String(p?.error||"Failed to save session."));const k=p?.session;if(!k?.id)throw new Error("Failed to save session.");Be(Nt=>{const N=Nt.findIndex(Qt=>Qt.id===k.id);if(N===-1)return[k,...Nt];const Ie=[...Nt];return Ie[N]=k,Ie}),F.current=e,yt.current=null,z(null);const w=_e.current===k.id,C=O.current,G=C!==e,Le=Ue.current||G;return Ue.current=!1,w&&!Le?(ve.current=!0,Ze(c),B("saved")):!Le&&C===F.current?B("saved"):B("pending"),!0}catch(u){const p=u instanceof Error?u.message:"Failed to save session.";return f(p),z(p),B("error"),yt.current!==e&&_e.current===i&&O.current===e&&(yt.current=e,bt.current=window.setTimeout(()=>{bt.current=null,!(_e.current!==i||O.current!==e)&&$e(e,a,{waitForInFlight:!0})},1500)),!1}finally{Wt.current=null,ae.current=null,Yt.current=null,te(!1)}})();ae.current=m;const S=await m;if(S){const u=O.current;if(u!==F.current)return $e(u,a,o)}return S},[Ze,L,j,$,U]),fa=s.useCallback(e=>{if(_e.current){if(O.current===F.current){z(null),ae.current||B("saved");return}Y!=="saving"&&B("pending"),L(),gt.current=window.setTimeout(()=>{gt.current=null,$e(O.current,"structure")},e)}},[L,$e,Y]),J=s.useCallback(e=>{In.current=e},[]),M=s.useCallback(async e=>{L();const a=O.current;return!_e.current||a===F.current?(z(null),ae.current||B("saved"),!0):$e(a,e,{waitForInFlight:!0})},[L,$e]),ss=s.useCallback(()=>{const e=F.current;e&&(L(),ve.current=!0,Ze(Ma(e)),z(null),B("saved"),f(null))},[Ze,L]),V=s.useCallback(async(e,a)=>{const o=typeof performance<"u"?performance.now():Date.now(),i=JSON.stringify({targetKey:Re(e),requestedSessionId:a?.requestedSessionId??null,autoCreateIfEmpty:a?.autoCreateIfEmpty===!0});if(Vt.current===i)return;const c=Te.current+1;Te.current=c,Vt.current=i,zn(!0),f(null);try{const m=new URLSearchParams;g&&m.set("workspaceId",g),e.taskId&&m.set("taskId",e.taskId),m.set("imageAssetId",e.assetId);const S=await le(`/api/taskforce/annotated-attachments/sessions?${m.toString()}`,{credentials:"include",headers:j,cache:"no-store"},$),u=await S.json().catch(()=>({}));if(!S.ok)throw new Error(String(u?.error||"Failed to load annotated attachment sessions."));const p=Array.isArray(u?.sessions)?u.sessions:[];if(tn("annotated_sessions_loaded",{assetId:e.assetId,taskId:e.taskId||null,requestedSessionId:a?.requestedSessionId??null,autoCreateIfEmpty:a?.autoCreateIfEmpty===!0,sessionCount:p.length,durationMs:Math.round((typeof performance<"u"?performance.now():Date.now())-o),serverTiming:typeof S.headers?.get=="function"&&S.headers.get("server-timing")||null}),p.length===0&&a?.autoCreateIfEmpty&&String(e.assetId||"").trim()){const C=a?.requestedSessionId??xe.current;if(xe.current=null,C&&f("The previously selected annotation session could not be restored."),Te.current!==c)return;const G=await Jt(e);if(tn("annotated_sessions_auto_created_after_empty_load",{assetId:e.assetId,taskId:e.taskId||null,sessionId:G.id,totalDurationMs:Math.round((typeof performance<"u"?performance.now():Date.now())-o)}),Te.current!==c)return;Be([G]),Fe(G.id),Ne(!1),we(G,e);return}if(Te.current!==c)return;Be(p),Ne(p.length===0);const k=a?.requestedSessionId??xe.current;xe.current=null;const w=p.find(C=>C.id===k)||p[0]||null;k&&!w&&f("The previously selected annotation session could not be restored."),Fe(w?.id||null),w?we(w,e):(ve.current=!0,L(),rt(et(e)),ot(""),me([]),Z(null),Q(!1),F.current="",O.current="",z(null),B("saved"))}catch(m){if(Te.current!==c)return;f(m instanceof Error?m.message:"Failed to load sessions.")}finally{Vt.current===i&&(Vt.current=null),Te.current===c&&zn(!1)}},[L,Jt,j,$,we,g]),ha=s.useCallback(async()=>{Jn(!0),Qn(null);try{const e=new URLSearchParams;e.set("workspaceId",String(g||"default").trim()||"default");const a=await le(`/api/taskforce/annotated-attachments/images?${e.toString()}`,{credentials:"include",headers:j,cache:"no-store"},$),o=await a.json().catch(()=>({}));if(!a.ok)throw new Error(String(o?.error||"Failed to load images."));Xa(Array.isArray(o?.images)?o.images:[])}catch(e){Qn(e instanceof Error?e.message:"Failed to load images.")}finally{Jn(!1)}},[j,$,g]),rs=s.useCallback(async()=>{if(typeof navigator>"u"||!navigator.clipboard||typeof navigator.clipboard.read!="function"){f("Clipboard image paste is not supported in this environment.");return}ea(!0),f(null),aa.current=Date.now()+2e3;try{const a=(await navigator.clipboard.read()).find(k=>k.types.some(w=>w.startsWith("image/"))),o=a?.types.find(k=>k.startsWith("image/"))||"";if(!a||!o)throw new Error("No image found on the clipboard.");const i=await a.getType(o),c=await ma(i);if(!c)throw new Error("Failed to read clipboard image.");const m=o==="image/jpeg"?"jpg":o==="image/webp"?"webp":o==="image/gif"?"gif":"png",S=await fetch("/api/taskforce/context-upload",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",...j},body:JSON.stringify({file:c,originalName:`pasted-image.${m}`,workspaceId:String(g||"default").trim()||"default"})}),u=await S.json().catch(()=>({}));if(!S.ok||!u?.success||typeof u?.assetId!="string"||typeof u?.path!="string")throw new Error(String(u?.error||"Failed to paste image into Image Notes."));const p={assetId:u.assetId,imageReferenceLabel:typeof u?.referenceLabel=="string"?u.referenceLabel:void 0,path:u.path,displayName:typeof u?.displayName=="string"&&u.displayName.trim().length>0?u.displayName.trim():"Pasted image"};xe.current=null,ge?(he.current="",W?.(p,{sessionId:null})):($t(p),he.current=Re(p),V(p,{autoCreateIfEmpty:!0}))}catch(e){f(e instanceof Error?e.message:"Failed to paste image.")}finally{ea(!1)}},[ge,V,W,ma,j,g]),os=s.useCallback(async()=>{const e=bn.trim();if(!e){f("Enter an image reference to open.");return}Xn(!0),f(null);try{const a=new URLSearchParams({workspaceId:String(g||"default").trim()||"default"}),o=await le(`/api/taskforce/annotated-attachments/images/${encodeURIComponent(e)}?${a.toString()}`,{method:"GET",credentials:"include",headers:j}),i=await o.json().catch(()=>({}));if(!o.ok||!i?.target||typeof i.target.assetId!="string"||typeof i.target.path!="string")throw new Error(String(i?.error||"Failed to open image reference."));const c={assetId:i.target.assetId,path:i.target.path,displayName:typeof i.target.displayName=="string"&&i.target.displayName.trim().length>0?i.target.displayName.trim():"Image attachment",taskId:typeof i.target.taskId=="string"&&i.target.taskId.trim().length>0?i.target.taskId.trim():void 0,taskReferenceLabel:typeof i.target.taskReferenceLabel=="string"&&i.target.taskReferenceLabel.trim().length>0?i.target.taskReferenceLabel.trim():void 0,imageReferenceLabel:typeof i.target.imageReferenceLabel=="string"&&i.target.imageReferenceLabel.trim().length>0?i.target.imageReferenceLabel.trim():void 0};xe.current=null,Ht(!1),zt(""),ge?(he.current="",W?.(c,{sessionId:null})):($t(c),he.current=Re(c),V(c,{autoCreateIfEmpty:!0}))}catch(a){f(a instanceof Error?a.message:"Failed to open image reference.")}finally{Xn(!1)}},[ge,V,W,bn,j,g]),is=s.useCallback(async e=>{if(!e.assetId||!e.path||!await M("session-switch"))return;const o={assetId:e.assetId,path:e.path,displayName:String(e.displayName||e.originalFilename||"Image attachment").trim()||"Image attachment",...e.taskId?{taskId:e.taskId}:{},...e.taskReferenceLabel?{taskReferenceLabel:e.taskReferenceLabel}:{},...e.imageReferenceLabel?{imageReferenceLabel:e.imageReferenceLabel}:{}};xe.current=null,f(null),ge?(he.current="",W?.(o,{sessionId:null})):($t(o),he.current=Re(o),St(o),V(o,{autoCreateIfEmpty:!0}))},[M,ge,V,W,St]),Zt=s.useCallback(e=>{Be(a=>{const o=a.findIndex(c=>c.id===e.id);if(o===-1)return[e,...a];const i=[...a];return i[o]=e,i}),Fe(e.id),we(e,d)},[d,we]),pa=s.useCallback(e=>{Be(a=>{const o=a.filter(c=>c.id!==e),i=o[0]||null;return Fe(i?.id||null),i?we(i,d):(ve.current=!0,L(),rt(et(d||{displayName:"Annotated session"})),ot(""),me([]),Z(null),Q(!1),F.current="",O.current="",z(null),B("saved")),o})},[d,L,we]);s.useEffect(()=>{if(!_)return;if(ge||$t(a=>a&&Re(a)===re&&a.taskReferenceLabel===_.taskReferenceLabel&&a.imageReferenceLabel===_.imageReferenceLabel&&a.displayName===_.displayName?a:_),!v){re&&(re!==he.current||de!==Kt.current)&&re!==wn.current&&(St(_),wn.current=re,Kt.current=de,tn("annotated_sessions_load_deferred",{assetId:_.assetId,taskId:_.taskId||null,requestedTargetKey:re})),Me?.();return}re&&(re!==he.current||de!==Kt.current)&&(St(_),he.current=re,Kt.current=de,wn.current="",V(_,{autoCreateIfEmpty:!0})),Me?.()},[ge,V,Me,de,_,re,St,D,v]),s.useEffect(()=>{d&&Se?.({target:d,sessionId:y})},[d,Se,y]),s.useEffect(()=>{if(!d||typeof document>"u"||!v)return;const e=()=>{Date.now()<aa.current||O.current!==F.current||ee||Pt||V(d,{requestedSessionId:y})},a=()=>{document.visibilityState==="visible"&&e()};return document.addEventListener("visibilitychange",a),()=>{document.removeEventListener("visibilitychange",a)}},[d,V,Pt,ee,y,v]),s.useEffect(()=>{if(!d?.path){ct(!1),ut(!1),pt({width:0,height:0});return}ct(!0),ut(!1),pt({width:0,height:0}),mt(1),Ke.current=!0,ft(!1),ht(!1)},[d?.path]),s.useEffect(()=>{if(!q)return;const e=kn.current;!e||!e.complete||e.naturalWidth<=0||e.naturalHeight<=0||(pt({width:e.naturalWidth,height:e.naturalHeight}),ct(!1),ut(!1))},[d?.path,q]),s.useEffect(()=>{Je||(ft(!1),ht(!1))},[Je]),s.useEffect(()=>{if(!y||!K||q||dt||T.width<=0||T.height<=0||sa.current===K)return;if(sa.current=K,!_t){It();return}Ke.current=!1,Ge.current=!0;const e=Mn(_t.zoomLevel);mt(e),window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>{const a=ne.current;a&&(a.scrollLeft=Math.max(0,_t.scrollLeft),a.scrollTop=Math.max(0,_t.scrollTop)),Ge.current=!1})})},[K,dt,q,T.height,T.width,It,_t,y]),s.useEffect(()=>{const e=ne.current;if(!e||T.width<=0||T.height<=0)return;const a=new ResizeObserver(()=>{Ke.current&&It()});return a.observe(e),()=>a.disconnect()},[It,T.height,T.width]),s.useEffect(()=>{dn(null)},[y]),s.useEffect(()=>{if(O.current=qe,ve.current){ve.current=!1;return}if(!y){L(),z(null),B("saved");return}if(qe===F.current){L(),ae.current||(z(null),B("saved"));return}const e=In.current;if(In.current=null,Y==="error"&&e===null)return;const a=e??600;if(ae.current){Ue.current=!0,B("pending");return}fa(a)},[L,qe,Y,fa,y]),s.useEffect(()=>{y&&(ae.current||qe===F.current&&Y!=="error"&&Y!=="saved"&&(z(null),B("saved")))},[qe,Y,y]),s.useEffect(()=>{!wt||!ue||ha()},[ha,ue,wt]),s.useEffect(()=>{if(typeof window>"u")return;const e=a=>{O.current!==F.current&&(a.preventDefault(),a.returnValue="")};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[]),s.useEffect(()=>{if(typeof document>"u")return;const e=()=>{document.visibilityState==="hidden"&&M("visibility-hidden")};return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[M]),s.useEffect(()=>{if(!At||typeof document>"u")return;const e=a=>{const o=a.target;o instanceof Node&&(oa.current?.contains(o)||Et(!1))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[At]),s.useEffect(()=>{if(!ln||typeof document>"u")return;const e=a=>{const o=a.target;o instanceof Node&&(ia.current?.contains(o)||st(!1))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[ln]),s.useEffect(()=>()=>{L()},[L]),s.useEffect(()=>{if(!be)return;const e=window.setTimeout(()=>un(!1),2e3);return()=>window.clearTimeout(e)},[be]),s.useEffect(()=>{if(!Dt)return;const e=window.setTimeout(()=>gn(!1),2e3);return()=>window.clearTimeout(e)},[Dt]),s.useEffect(()=>{if(!Ot)return;const e=window.setTimeout(()=>yn(!1),2e3);return()=>window.clearTimeout(e)},[Ot]);const ie=s.useCallback((e,a,o=300)=>{me(i=>Ae(i.map(c=>c.id===e?a(c):c))),J(o)},[J]),ls=s.useCallback(e=>{pe&&(ie(pe.id,a=>({...a,color:e})),Hn(e),Et(!1))},[pe,ie]),ga=s.useCallback(async()=>{if(!(!d||!await M("session-switch"))){te(!0),f(null);try{const a=await Jt(d);Ne(!1),await V(d,{requestedSessionId:a.id,autoCreateIfEmpty:!1}),He("select")}catch(a){f(a instanceof Error?a.message:"Failed to create session."),Ne(!0)}finally{te(!1)}}},[d,Jt,M,V]),cs=s.useCallback(e=>{if(e!=="select"&&!b){ft(!1),f("No session exists for this image yet."),Ne(!0);return}f(null),Ne(!1),ft(!1),He(e)},[b]),ds=s.useCallback(async()=>{if(!(!d||!b||!await M("duplicate"))){te(!0),f(null);try{const a=Ae(R.map((m,S)=>sl(m,S))),o=await le(`/api/taskforce/annotated-attachments/sessions?${U}`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",...j},body:JSON.stringify({taskId:d.taskId,baseImageAssetId:d.assetId,title:rl(De||b.title,d),globalInstruction:Oe,annotations:a})},$),i=await o.json().catch(()=>({}));if(!o.ok)throw new Error(String(i?.error||"Failed to duplicate session."));const c=i?.session;if(!c?.id)throw new Error("Failed to duplicate session.");Zt(c),He("select")}catch(a){f(a instanceof Error?a.message:"Failed to duplicate session.")}finally{te(!1)}}},[d,R,Oe,De,Zt,M,j,$,b,U]),us=s.useCallback(async()=>M("manual"),[M]),ya=s.useCallback(async()=>{if(y){Gn(!0),f(null);try{const e=await le(`/api/taskforce/annotated-attachments/sessions/${encodeURIComponent(y)}/payload?${U}`,{credentials:"include",headers:j},$),a=await e.json().catch(()=>({}));if(!e.ok)throw new Error(String(a?.error||"Failed to load payload preview."));dn(a?.payload||null)}catch(e){f(e instanceof Error?e.message:"Failed to load payload preview.")}finally{Gn(!1)}}},[j,$,y,U]),ms=s.useCallback(()=>{y&&M("payload-preview").then(e=>{e&&(mn(!0),ya())})},[M,ya,y]),ba=s.useCallback(async e=>{if(!fe||!navigator.clipboard||typeof navigator.clipboard.writeText!="function"){f("Clipboard copy is not available in this browser.");return}try{const a=e==="json"?JSON.stringify(fe,null,2):Ea(fe);await navigator.clipboard.writeText(a),un(e)}catch(a){f(a instanceof Error?a.message:"Failed to copy payload content."),un(!1)}},[fe]),fs=s.useCallback(async()=>{if(!qt||!navigator.clipboard||typeof navigator.clipboard.writeText!="function"){f("Clipboard copy is not available in this browser.");return}try{await navigator.clipboard.writeText(qt),gn(!0)}catch(e){f(e instanceof Error?e.message:"Failed to copy task id."),gn(!1)}},[qt]),hs=s.useCallback(async()=>{if(!(!b||Ft)){Bt(!0),Vn(""),Wn(!0),f(null);try{const e=await le(`/api/taskforce/tasks?${U}`,{credentials:"include",headers:j},$),a=await e.json().catch(()=>({}));if(!e.ok)throw new Error(String(a?.error||"Failed to load tasks."));Wa(Array.isArray(a?.tasks)?a.tasks:[])}catch(e){f(e instanceof Error?e.message:"Failed to load tasks.")}finally{Wn(!1)}}},[j,$,b,Ft,U]),Rn=s.useCallback(async e=>{const a=_e.current;if(!(!a||Sn.current)){Sn.current=!0,Yn(!0);try{if(!await M("task-link"))return;f(null);const i=await le(`/api/taskforce/annotated-attachments/sessions/${encodeURIComponent(a)}?${U}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json",...j},body:JSON.stringify({taskId:e||""})},$),c=await i.json().catch(()=>({}));if(!i.ok)throw new Error(String(c?.error||"Failed to update session task."));const m=c?.session;if(!m?.id)throw new Error("Failed to update session task.");Zt(m),Bt(!1)}catch(o){f(o instanceof Error?o.message:"Failed to update session task.")}finally{Sn.current=!1,Yn(!1)}}},[Zt,M,j,$,U]),ps=s.useCallback(async()=>{if(!kt||!navigator.clipboard||typeof navigator.clipboard.writeText!="function"){f("Clipboard copy is not available in this browser.");return}try{await navigator.clipboard.writeText(kt),yn(!0)}catch(e){f(e instanceof Error?e.message:"Failed to copy image reference."),yn(!1)}},[kt]),gs=s.useCallback(async()=>{if(!y||!await M("delete-session"))return;const a=(b?.title||"Untitled session").trim()||"Untitled session";if(window.confirm(`Delete the annotated attachment session "${a}"?`)){te(!0),f(null);try{const o=await le(`/api/taskforce/annotated-attachments/sessions/${encodeURIComponent(y)}?${U}`,{method:"DELETE",credentials:"include",headers:j},$),i=await o.json().catch(()=>({}));if(!o.ok)throw new Error(String(i?.error||"Failed to delete session."));pa(y),He("select")}catch(o){f(o instanceof Error?o.message:"Failed to delete session.")}finally{te(!1)}}},[M,pa,j,$,b,y,U]),xa=s.useCallback(()=>{A&&(me(e=>Ae(e.filter(a=>a.id!==A))),Z(null),Q(!1),J(300))},[J,A]),An=s.useCallback(()=>{A&&window.confirm("Delete this marker? This cannot be undone.")&&xa()},[xa,A]),Ct=s.useCallback(e=>{Z(e),Q(!1),window.requestAnimationFrame(()=>{Nn.current.get(e)?.scrollIntoView?.({block:"nearest",behavior:"smooth"})})},[]),ys=s.useCallback(e=>{if(A===e&&!it){Q(!0);return}Ct(e)},[it,Ct,A]),Qe=s.useCallback(e=>{Ke.current=!1;const a=Mn(e),o=ne.current;if(!o||a===P){mt(a),window.requestAnimationFrame(()=>oe(a));return}const i=(o.scrollLeft+o.clientWidth/2)*(a/P)-o.clientWidth/2,c=(o.scrollTop+o.clientHeight/2)*(a/P)-o.clientHeight/2;mt(a),window.requestAnimationFrame(()=>{o.scrollLeft=Math.max(0,i),o.scrollTop=Math.max(0,c),oe(a)})},[oe,P]),bs=s.useCallback(()=>{Qe(P+.25)},[Qe,P]),xs=s.useCallback(()=>{Qe(P-.25)},[Qe,P]),vs=s.useCallback(()=>{Qe(1);const e=ne.current;e&&window.requestAnimationFrame(()=>{e.scrollLeft=0,e.scrollTop=0,oe(1)})},[Qe,oe]),va=s.useCallback((e,a)=>{e!==a&&me(o=>{const i=o.findIndex(m=>m.id===e),c=o.findIndex(m=>m.id===a);return i===-1||c===-1?o:(J(300),ol(o,i,c))})},[J]),_s=s.useCallback(e=>{cn(String(e.active.id))},[]),ks=s.useCallback(e=>{const a=String(e.active.id),o=e.over?String(e.over.id):null;o&&a!==o&&va(a,o),cn(null)},[va]);s.useEffect(()=>{if(!A)return;const e=a=>{a.key!=="Delete"&&a.key!=="Backspace"||za(a.target)||(a.preventDefault(),An())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[An,A]),s.useEffect(()=>{const e=i=>{i.code==="Space"&&Je&&(Zi(i.target)||(i.preventDefault(),ht(!0)))},a=i=>{i.code==="Space"&&ht(!1)},o=()=>{ht(!1)};return window.addEventListener("keydown",e),window.addEventListener("keyup",a),window.addEventListener("blur",o),()=>{window.removeEventListener("keydown",e),window.removeEventListener("keyup",a),window.removeEventListener("blur",o)}},[Je]);const H=s.useCallback(e=>{const a=ta.current?.getBoundingClientRect();return!a||a.width<=0||a.height<=0?null:{x:I((e.clientX-a.left)/a.width),y:I((e.clientY-a.top)/a.height)}},[]),ws=s.useCallback(e=>{if(X){const i=ne.current;if(!i)return;se.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,scrollLeft:i.scrollLeft,scrollTop:i.scrollTop},e.currentTarget.setPointerCapture(e.pointerId),e.preventDefault();return}if(!y)return;if(E==="select"){Z(null),Q(!1);return}const a=H(e);if(!a)return;if(E==="pin"||E==="text-note"){const i=Aa(E,a,a,Rt);me(c=>Ae([...c,i])),Z(i.id),Q(!1),J(300),He("select");return}je.current=a;const o=Aa(E,a,a,Rt);ke.current={annotationId:o.id,kind:E},e.currentTarget.setPointerCapture?.(e.pointerId),me(i=>Ae([...i,o])),Z(o.id),Q(!1),J(300)},[Rt,X,J,H,y,E]),Is=s.useCallback(e=>{if(se.current?.pointerId===e.pointerId){e.currentTarget.releasePointerCapture?.(e.pointerId);return}if(!je.current||!ke.current||E!=="box"&&E!=="arrow")return;const a=H(e);je.current=null,ke.current=null,e.currentTarget.releasePointerCapture?.(e.pointerId),a&&He("select")},[H,E]),_a=s.useCallback((e,a)=>{if(E!=="select"||X)return;const o=H(e);o&&(Ve.current={annotationId:a.id,originPointer:o,originAnnotation:a},Z(a.id),e.stopPropagation())},[X,H,E]),Ss=s.useCallback(e=>{if(se.current?.pointerId===e.pointerId){const u=ne.current;if(!u)return;const p=e.clientX-se.current.startX,k=e.clientY-se.current.startY;u.scrollLeft=se.current.scrollLeft-p,u.scrollTop=se.current.scrollTop-k;return}if(ke.current&&je.current){const u=H(e);if(!u)return;const{annotationId:p,kind:k}=ke.current,w=je.current;ie(p,C=>k==="box"&&C.kind==="box"?{...C,x:I(Math.min(w.x,u.x)),y:I(Math.min(w.y,u.y)),width:Ee(Math.abs(u.x-w.x)),height:Ee(Math.abs(u.y-w.y))}:k==="arrow"&&C.kind==="arrow"?{...C,x:w.x,y:w.y,x2:u.x,y2:u.y}:C);return}if(We.current){const u=H(e);if(!u)return;const{annotationId:p,originPointer:k,originAnnotation:w}=We.current,C=u.x-k.x,G=u.y-k.y;ie(p,()=>({...w,width:Ee(w.width+C),height:Ee(w.height+G)}));return}if(Ye.current){const u=H(e);if(!u)return;const{annotationId:p,endpoint:k,originPointer:w,originAnnotation:C}=Ye.current,G=u.x-w.x,Le=u.y-w.y;ie(p,()=>k==="tail"?{...C,x:I(C.x+G),y:I(C.y+Le)}:{...C,x2:I(C.x2+G),y2:I(C.y2+Le)});return}if(!Ve.current)return;const a=H(e);if(!a)return;const{annotationId:o,originPointer:i,originAnnotation:c}=Ve.current,m=a.x-i.x,S=a.y-i.y;ie(o,()=>c.kind==="pin"||c.kind==="text-note"?{...c,x:I(c.x+m),y:I(c.y+S)}:c.kind==="box"?{...c,x:I(c.x+m),y:I(c.y+S)}:{...c,x:I(c.x+m),y:I(c.y+S),x2:I(c.x2+m),y2:I(c.y2+S)})},[H,ie]),Cs=s.useCallback(()=>{je.current=null,Ve.current=null,We.current=null,Ye.current=null,ke.current=null,se.current=null},[]),Ns=s.useCallback(()=>{je.current=null,Ve.current=null,We.current=null,Ye.current=null,ke.current=null,se.current=null},[]),Ts=s.useCallback(()=>{Ve.current=null,We.current=null,Ye.current=null,ke.current=null,se.current=null},[]),js=s.useCallback((e,a)=>{if(E!=="select"||X)return;const o=H(e);o&&(We.current={annotationId:a.id,originPointer:o,originAnnotation:a},e.stopPropagation())},[X,H,E]),ka=s.useCallback((e,a,o)=>{if(E!=="select"||X)return;const i=H(e);i&&(Ye.current={annotationId:a.id,originPointer:i,originAnnotation:a,endpoint:o},e.stopPropagation())},[X,H,E]),$s=b?.updatedAt?Pn(b.updatedAt):"Not saved yet";return t.jsxs("div",{className:`${n.shell} ${wt?n.shellWithImageTray:""} ${wt&&ue?n.shellImageTrayOpen:""}`.trim(),children:[wt?t.jsxs("aside",{className:`${n.imageTrayPanel} ${ue?n.imageTrayPanelOpen:""}`.trim(),"aria-label":"Image tray","aria-hidden":!ue,children:[t.jsxs("div",{className:n.imageTrayHeader,children:[t.jsxs("span",{className:n.imageTrayTitle,children:[t.jsx(Sa,{size:14}),"Images"]}),t.jsx("button",{type:"button",className:"tf-control-icon",onClick:jt,title:"Collapse image tray","aria-label":"Collapse image tray",children:t.jsx(Ws,{size:16})})]}),t.jsxs("div",{className:n.imageTraySearch,children:[t.jsx(Ys,{size:12,className:n.imageTraySearchIcon}),t.jsx("input",{type:"text",placeholder:"Search images...",value:Ut,onChange:e=>Ja(e.target.value),className:n.imageTraySearchInput})]}),t.jsx("div",{className:n.imageTraySortControlRow,children:t.jsx(Vs,{field:vn,order:_n,onFieldChange:Za,onOrderChange:Qa})}),t.jsx("div",{className:`tf-scrollbar tf-tray-scroll-viewport ${n.imageTrayList}`,children:es?t.jsx("div",{className:n.imageTrayState,children:"Loading images..."}):Zn?t.jsx("div",{className:n.imageTrayStateError,children:Zn}):ua.length===0?t.jsx("div",{className:n.imageTrayState,children:Ut.trim()?"No images match your search.":"No images found."}):ua.map(e=>{const a=d?.assetId===e.assetId,o=typeof e.attachmentCount=="number"&&Number.isFinite(e.attachmentCount)?Math.max(0,e.attachmentCount):0,i=typeof e.sessionCount=="number"&&Number.isFinite(e.sessionCount)?Math.max(0,e.sessionCount):0,c=o>1?`${o} tasks linked`:o===1?e.taskReferenceLabel||"1 task linked":"Unattached",m=String(e.displayName||e.originalFilename||"Image attachment").trim()||"Image attachment";return t.jsxs("button",{type:"button",className:`${n.imageTrayItem} ${a?n.imageTrayItemActive:""}`.trim(),onClick:()=>{is(e)},title:m,children:[t.jsx("span",{className:n.imageTrayThumb,children:t.jsx("img",{src:e.path,alt:"",loading:"lazy"})}),t.jsxs("span",{className:n.imageTrayItemBody,children:[t.jsx("span",{className:n.imageTrayItemTitle,children:m}),t.jsx("span",{className:n.imageTrayItemTask,children:c}),t.jsxs("span",{className:n.imageTrayItemMeta,children:[t.jsxs("span",{className:n.imageTrayItemMetaDetails,children:[Qi(e.sizeBytes),e.updatedAt?t.jsxs(t.Fragment,{children:[" · ",el(e.updatedAt)]}):null,i>0?t.jsxs(t.Fragment,{children:[" · ",i," session",i===1?"":"s"]}):null]}),e.imageReferenceLabel?t.jsx("span",{className:n.imageTrayItemReference,children:e.imageReferenceLabel}):null]})]})]},e.assetId)})})]}):null,t.jsxs("section",{className:`tf-surface-panel ${n.panel} ${n.sessionPanel}`,children:[t.jsx("div",{className:n.sessionContextBar,children:b?.taskId?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:n.sessionContextLeft,children:at?t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${n.ghostBtn} ${n.backToTaskBtn}`,onClick:()=>{M("back-to-task").then(e=>{e&&b.taskId&&at(b.taskId)})},"aria-label":"Back to task",title:"Back to task",children:t.jsx(qs,{size:16})}):t.jsx("div",{className:n.sessionContextSpacer,"aria-hidden":"true"})}),t.jsxs("div",{className:n.sessionContextRight,children:[t.jsx(Gs,{copied:Dt,onClick:()=>{fs()},title:"Copy task id",ariaLabel:Dt?"Copied task id":"Copy task id",label:qt}),t.jsx("button",{type:"button",className:`tf-control-icon ${n.iconButton}`,onClick:()=>{Rn(null)},disabled:ze,"aria-label":"Unlink session from task",title:"Unlink session from task",children:t.jsx(Xs,{size:16})})]})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:n.sessionContextLeft,children:t.jsx("span",{className:`tf-label-micro ${n.sessionContextLabel}`,children:"Unattached session"})}),t.jsx("div",{className:n.sessionContextRight,children:t.jsx("div",{className:n.sessionContextSpacer,"aria-hidden":"true"})})]})}),t.jsxs("div",{className:n.panelHeader,children:[t.jsxs("div",{className:n.panelHeaderText,children:[t.jsx("div",{className:`tf-heading-card ${n.panelTitle}`,children:"Sessions"}),d?null:t.jsx("div",{className:"tf-text-secondary",children:"Open an image attachment to begin"})]}),t.jsxs("div",{className:n.sessionActions,children:[t.jsx("button",{type:"button",className:`tf-control-icon ${n.iconButton}`,onClick:()=>{hs()},disabled:!b||Ft||ze,"aria-label":b?.taskId?"Change linked task":"Link session to task",title:b?.taskId?"Change linked task":"Link session to task",children:t.jsx(Js,{size:16})}),t.jsx("button",{type:"button",className:`tf-control-icon ${n.iconButton}`,onClick:()=>{ga()},disabled:!d||ee,"aria-label":"Create session",title:"Create session",children:t.jsx(Zs,{size:16})})]})]}),d?Pt?t.jsx("div",{className:n.emptyState,children:t.jsx("p",{className:"tf-empty-copy",children:"Loading sessions…"})}):t.jsx("div",{className:`tf-scrollbar ${n.sessionList}`,children:Lt.length===0?t.jsxs("div",{className:n.sessionEmptyState,children:[t.jsx("div",{className:`tf-heading-card ${n.sessionTitle}`,children:"No sessions yet"}),t.jsx("div",{className:`tf-text-secondary ${n.annotationSummary}`,children:"Create the first annotation session for this image."})]}):Lt.map(e=>{const a=y===e.id,o=a&&ln,i=tl(a?Oe:e.globalInstruction),c=(a?De:e.title)||"Untitled session";return t.jsxs("div",{className:`tf-surface-elevated ${n.sessionCard} ${a?n.sessionCardActive:""}`,ref:a?ia:void 0,onBlur:o?m=>{const S=m.relatedTarget;S instanceof Node&&m.currentTarget.contains(S)||st(!1)}:void 0,children:[o?t.jsxs("div",{className:n.sessionCardBody,children:[t.jsxs("div",{className:n.sessionMeta,children:[t.jsx("label",{className:"tf-field-label",htmlFor:"annotated-session-title",children:"Session title"}),t.jsx("input",{id:"annotated-session-title",className:`tf-field-shell ${n.textInput} ${n.sessionTitleInput}`,value:De,onChange:m=>{rt(m.target.value),J(600)},placeholder:"Session title"}),t.jsx("span",{className:`tf-text-meta ${n.sessionTimestamp}`,children:Pn(e.updatedAt)})]}),sn(e)?t.jsxs("div",{className:`tf-text-secondary ${n.sessionCreator}`,children:["Created by ",sn(e)]}):null,t.jsxs("div",{className:n.sessionInstructionEditor,children:[t.jsx("label",{className:"tf-field-label",htmlFor:"annotated-session-instruction",children:"Session instruction"}),t.jsx("textarea",{id:"annotated-session-instruction",className:`tf-field-shell ${n.textArea} ${n.sessionInstructionField}`,value:Oe,onChange:m=>{ot(m.target.value),J(600)},placeholder:"Add overall instructions, context, or framing for this session."})]}),t.jsxs("div",{className:`tf-text-secondary ${n.annotationSummary}`,children:[e.annotations.length," annotation",e.annotations.length===1?"":"s"]})]}):t.jsxs("button",{type:"button",className:n.sessionCardButton,onClick:()=>{if(a){st(!0);return}M("session-switch").then(m=>{m&&(Fe(e.id),we(e,d))})},"aria-pressed":a,children:[t.jsxs("div",{className:n.sessionMeta,children:[t.jsx("span",{className:`tf-heading-card ${n.sessionTitle}`,children:c}),t.jsx("span",{className:`tf-text-meta ${n.sessionTimestamp}`,children:Pn(e.updatedAt)})]}),sn(e)?t.jsxs("div",{className:`tf-text-secondary ${n.sessionCreator}`,children:["Created by ",sn(e)]}):null,i?t.jsx("div",{className:`tf-text-secondary ${n.sessionInstructionPreview}`,children:i}):null,t.jsxs("div",{className:`tf-text-secondary ${n.annotationSummary}`,children:[e.annotations.length," annotation",e.annotations.length===1?"":"s"]})]}),a?t.jsx("div",{className:n.sessionCardFooter,children:t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:`tf-button-ghost ${n.toolRailButton} ${n.iconButton}`,onClick:()=>{ds()},disabled:ee,"aria-label":"Duplicate session",title:`Duplicate session "${c}"`,children:t.jsx(En,{size:16})}),t.jsx("button",{type:"button",className:`tf-button-ghost ${n.toolRailButton} ${n.iconButton}`,onClick:()=>{gs()},disabled:ee,"aria-label":"Delete session",title:`Delete session "${c}"`,children:t.jsx(Ca,{size:16})})]})}):null]},e.id)})}):t.jsxs("div",{className:n.emptyState,children:[t.jsx("strong",{className:"tf-empty-title",children:"No image selected"}),t.jsx("p",{className:"tf-empty-copy",children:"Open an image attachment from a task to start an annotated session."})]})]}),t.jsxs("section",{className:`tf-surface-panel ${n.panel} ${n.canvasPanel}`,children:[t.jsxs("div",{className:n.panelHeader,children:[t.jsxs("div",{className:n.canvasHeading,children:[t.jsx("div",{className:"tf-heading-card",children:d?.displayName||"Annotated attachment"}),t.jsx("div",{className:"tf-text-secondary",children:b?`${R.length} markers · ${$s}`:"Pick or create a session"})]}),kt?t.jsx(ir,{copied:Ot,onClick:()=>{ps()},title:d?.displayName||"Annotated attachment",ariaLabel:Ot?"Copied image reference":"Copy image reference",label:kt}):null]}),t.jsxs("div",{className:n.toolRail,children:[t.jsxs("div",{className:`${n.toolbarCluster} ${n.toolbarViewportCluster}`,children:[t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${n.ghostBtn} ${n.toolbarButton}`,onClick:()=>{us()},disabled:!b||ee||!da&&Y!=="error","aria-label":ee?"Saving session":"Save session",title:ee?"Saving session":"Save session",children:t.jsx(Qs,{size:18})}),t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${n.ghostBtn} ${n.toolbarButton}`,onClick:()=>Ht(!0),disabled:lt,"aria-label":"Open image",title:"Open image",children:t.jsx(Sa,{size:18})}),t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${n.ghostBtn} ${n.toolbarButton}`,onClick:()=>{rs()},disabled:Gt,"aria-label":Gt?"Pasting image":"Paste image",title:Gt?"Pasting image":"Paste image",children:Gt?t.jsx(Na,{size:18,className:Ia.spin}):t.jsx(er,{size:18})}),t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${n.ghostBtn} ${n.toolbarButton}`,onClick:()=>{b&&ss()},disabled:!b||!da,"aria-label":"Reset unsaved changes",title:"Reset unsaved changes",children:t.jsx(tr,{size:18})}),t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${n.ghostBtn} ${n.toolbarButton}`,onClick:It,disabled:!d||q||T.width<=0||T.height<=0,"aria-label":"Fit image to viewport",title:"Fit image to viewport",children:t.jsx(nr,{size:18})}),t.jsx("button",{type:"button",className:`tf-button-ghost ${n.toolRailButton} ${n.iconButton}`,onClick:xs,disabled:!d||q||P<=.25,"aria-label":"Zoom out",children:t.jsx(ar,{size:18})}),t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${n.ghostBtn} ${n.toolbarButton}`,onClick:vs,disabled:!d||q||P===1,"aria-label":`Reset zoom to 100 percent (currently ${$n})`,title:`Reset zoom to 100% (currently ${$n})`,children:t.jsx("span",{children:$n})}),t.jsx("button",{type:"button",className:`tf-button-ghost ${n.toolRailButton} ${n.iconButton}`,onClick:bs,disabled:!d||q||P>=4,"aria-label":"Zoom in",children:t.jsx(sr,{size:18})}),t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${n.toolBtn} ${n.toolbarButton} ${X?n.toolBtnActive:""}`,onClick:()=>ft(e=>!e),disabled:!d||q||!Je,"aria-label":"Pan canvas",title:"Pan canvas",children:t.jsx(rr,{size:18})})]}),t.jsx("span",{className:n.toolbarSeparator,"aria-hidden":"true"}),t.jsxs("div",{className:n.toolbarActions,children:[t.jsx("div",{className:n.toolbarSelectionActions,children:pe?t.jsxs(t.Fragment,{children:[t.jsxs("div",{ref:oa,className:n.toolbarColorPicker,children:[t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${n.ghostBtn} ${n.toolbarButton} ${n.colorPickerButton}`,onClick:()=>Et(e=>!e),"aria-label":"Marker color","aria-expanded":At,title:"Marker color",children:t.jsx("span",{className:n.colorPickerSwatch,style:{backgroundColor:Tn},"aria-hidden":"true"})}),At?t.jsx("div",{className:n.colorPickerPopover,role:"menu","aria-label":"Marker color options",children:Ji.map(e=>t.jsx("button",{type:"button",className:`${n.colorOption} ${Tn===e?n.colorOptionActive:""}`,style:{backgroundColor:e},onClick:()=>ls(e),"aria-label":`Use marker color ${e}`,"aria-pressed":Tn===e},e))}):null]}),t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${n.ghostBtn} ${n.toolbarButton}`,onClick:An,"aria-label":"Delete marker",title:"Delete selected marker",children:t.jsx(Ca,{size:18})})]}):null}),t.jsxs("div",{className:n.toolbarUtilities,children:[t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${n.ghostBtn} ${n.payloadBtn} ${n.toolbarButton}`,onClick:ms,disabled:!b||Mt,"aria-label":Mt?"Loading payload preview":"Preview payload",title:Mt?"Loading payload preview":"Preview payload",children:t.jsx(Bn,{size:18})}),t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${n.ghostBtn} ${n.toolbarButton}`,onClick:()=>qn(!0),"aria-label":"How to use marker tools",title:"How to use marker tools",children:t.jsx(Fn,{size:18})})]})]})]}),t.jsxs("div",{className:n.canvasWorkspace,children:[t.jsx("div",{className:n.canvasToolRail,"aria-label":"Annotation tools",children:$a.map(e=>{const a=e.icon;return t.jsx("button",{type:"button",className:`tf-button-ghost ${n.toolRailButton} ${E===e.value?n.toolBtnActive:""}`,onClick:()=>cs(e.value),disabled:!d,title:e.label,"aria-label":`${e.label} tool. ${an[e.value].short}`,children:t.jsx(a,{size:18})},e.value)})}),t.jsx("div",{className:n.canvasMain,children:t.jsx("div",{ref:ne,className:`tf-scrollbar ${n.canvasScroller}`,onScroll:()=>{Ge.current||(Ke.current=!1),oe()},children:d?t.jsxs(t.Fragment,{children:[q&&!dt?t.jsx("div",{className:n.canvasStatusOverlay,"aria-live":"polite",children:t.jsxs("div",{className:n.canvasStatusCard,children:[t.jsx(Na,{size:20,className:Ia.spinner}),t.jsx("span",{children:"Loading image…"})]})}):null,dt?t.jsx("div",{className:n.canvasStatusOverlay,"aria-live":"polite",children:t.jsx("div",{className:n.canvasStatusCard,children:t.jsx("span",{children:"Image failed to load."})})}):null,t.jsx("div",{className:n.canvasFrame,children:t.jsxs("div",{className:n.canvasMedia,style:{width:x.width?`${x.width}px`:void 0,height:x.height?`${x.height}px`:void 0},children:[t.jsx("img",{ref:kn,src:d.path,alt:d.displayName,className:n.canvasImage,onLoad:()=>{const e=kn.current;pt({width:e?.naturalWidth||0,height:e?.naturalHeight||0}),ct(!1),ut(!1)},onError:()=>{pt({width:0,height:0}),ct(!1),ut(!0)}}),!q&&!dt&&b?t.jsxs("div",{ref:ta,className:`${n.overlay} ${E==="select"?n.overlaySelect:""} ${X?n.overlayPan:""}`,onPointerDown:ws,onPointerMove:Ss,onPointerUp:e=>{Is(e),Ts()},"data-testid":"annotated-attachment-overlay",onPointerLeave:Cs,onPointerCancel:Ns,children:[t.jsx("svg",{className:n.overlaySvg,viewBox:jn,preserveAspectRatio:"none","aria-hidden":"true",children:R.filter(e=>e.kind==="arrow").map(e=>{const a=nl(e,x),o=rn(e),i=A===e.id;return t.jsxs(en.Fragment,{children:[i?t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:a.shaftX1,y1:a.shaftY1,x2:a.shaftX2,y2:a.shaftY2,stroke:"color-mix(in srgb, var(--surface-elevated) 92%, transparent)",strokeWidth:14,strokeLinecap:"round"}),t.jsx("polygon",{points:a.headPoints,fill:o,stroke:"color-mix(in srgb, var(--surface-elevated) 92%, transparent)",strokeWidth:4,strokeLinejoin:"round"})]}):null,t.jsx("line",{x1:a.shaftX1,y1:a.shaftY1,x2:a.shaftX2,y2:a.shaftY2,stroke:o,strokeWidth:i?10:6,strokeLinecap:"round"}),t.jsx("polygon",{points:a.headPoints,fill:o})]},e.id)})}),t.jsx("svg",{className:n.overlayHitLayer,viewBox:jn,preserveAspectRatio:"none",children:R.filter(e=>e.kind==="arrow").map(e=>t.jsxs(en.Fragment,{children:[t.jsx("line",{x1:e.x*x.width,y1:e.y*x.height,x2:e.x2*x.width,y2:e.y2*x.height,className:n.arrowHitArea,"data-testid":`annotated-arrow-hit-${e.id}`,"aria-label":`Arrow marker ${Ln.get(e.id)||0}`,onPointerDown:a=>_a(a,e),onClick:a=>{a.stopPropagation(),Ct(e.id)}}),A===e.id?t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:e.x*x.width,cy:e.y*x.height,r:Xe.hitRadius,className:n.canvasHandleHit,role:"button",tabIndex:0,"aria-label":"Move arrow tail",onPointerDown:a=>ka(a,e,"tail")}),t.jsx("circle",{cx:e.x*x.width,cy:e.y*x.height,r:Xe.visibleRadius,className:n.canvasHandleVisible,"aria-hidden":"true"}),t.jsx("circle",{cx:e.x2*x.width,cy:e.y2*x.height,r:Xe.hitRadius,className:n.canvasHandleHit,role:"button",tabIndex:0,"aria-label":"Move arrow tip",onPointerDown:a=>ka(a,e,"tip")}),t.jsx("circle",{cx:e.x2*x.width,cy:e.y2*x.height,r:Xe.visibleRadius,className:n.canvasHandleVisible,"aria-hidden":"true"})]}):null]},`hit-${e.id}`))}),R.filter(e=>e.kind==="arrow").map(e=>t.jsx("div",{className:`${n.annotationNumberBadge} ${n.arrowNumberBadge}`,style:{left:`${(e.x+e.x2)/2*100}%`,top:`${(e.y+e.y2)/2*100}%`,backgroundColor:rn(e)},"aria-hidden":"true",children:Ln.get(e.id)||0},`arrow-number-${e.id}`)),R.filter(e=>e.kind!=="arrow").map(e=>{const a=rn(e),o=Ln.get(e.id)||0,i={onPointerDown:c=>_a(c,e),onClick:c=>{c.stopPropagation(),Ct(e.id)}};return e.kind==="pin"?t.jsx("button",{type:"button",...i,className:`${n.pin} ${A===e.id?n.selected:""}`,style:{left:`${e.x*100}%`,top:`${e.y*100}%`,backgroundColor:a},children:o},e.id):e.kind==="text-note"?t.jsx("button",{type:"button",...i,className:`${n.note} ${A===e.id?n.selected:""}`,style:{left:`${e.x*100}%`,top:`${e.y*100}%`,backgroundColor:a},children:o},e.id):t.jsxs("div",{className:`${n.box} ${A===e.id?n.selected:""}`,style:{left:`${e.x*100}%`,top:`${e.y*100}%`,width:`${e.width*100}%`,height:`${e.height*100}%`,borderColor:a},children:[t.jsx("span",{className:`${n.annotationNumberBadge} ${n.boxNumberBadge}`,style:{backgroundColor:a},"aria-hidden":"true",children:o}),t.jsx("button",{type:"button",...i,className:n.boxSurface,"aria-label":`Box marker ${o}`})]},e.id)}),t.jsx("svg",{className:n.overlaySvg,viewBox:jn,preserveAspectRatio:"none",children:R.filter(e=>e.kind==="box"&&A===e.id).map(e=>t.jsxs(en.Fragment,{children:[t.jsx("circle",{cx:(e.x+e.width)*x.width,cy:(e.y+e.height)*x.height,r:Xe.hitRadius,className:`${n.canvasHandleHit} ${n.canvasResizeHandleHit}`,role:"button",tabIndex:0,"aria-label":"Resize box marker",onPointerDown:a=>js(a,e)}),t.jsx("circle",{cx:(e.x+e.width)*x.width,cy:(e.y+e.height)*x.height,r:Xe.visibleRadius,className:n.canvasHandleVisible,"aria-hidden":"true"})]},`box-handle-${e.id}`))})]}):null]})})]}):t.jsx("div",{className:n.emptyState,children:t.jsx("p",{className:"tf-empty-copy",children:"Select an image attachment to annotate."})})})})]}),t.jsxs("div",{className:n.statusBar,children:[t.jsx("span",{children:Y==="error"?"Save failed. Retry now.":Y==="saving"||Y==="pending"?"Saving…":"Saved"}),Un?t.jsx("span",{children:Un}):t.jsx("span",{children:b?X?"Drag on the image to pan.":E==="select"?"Select a marker to edit it.":`Click on the image to place a ${E}.`:"Create a session to begin placing markers on this image."}),d&&!b&&Ga?t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${n.ghostBtn} ${n.toolbarButton}`,onClick:()=>{ga()},disabled:ee||Pt,children:ee?"Creating…":"Create one now"}):null]})]}),t.jsx("section",{className:`tf-surface-panel ${n.panel} ${n.detailPanel}`,children:b?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:n.panelHeader,children:t.jsxs("div",{className:n.panelHeaderText,children:[t.jsx("div",{className:`tf-heading-card ${n.panelTitle}`,children:"Markers"}),t.jsxs("div",{className:"tf-text-secondary",children:[R.length," in this session"]})]})}),t.jsxs(As,{sensors:as,collisionDetection:Es,onDragStart:_s,onDragEnd:ks,onDragCancel:()=>cn(null),children:[t.jsx("div",{className:`tf-scrollbar ${n.annotationList}`,children:R.length===0?t.jsx("div",{className:n.detailEmpty,children:t.jsx("p",{className:"tf-empty-copy",children:"Add a marker on the image to begin."})}):t.jsx(Ps,{items:R.map(e=>e.id),strategy:Ms,children:R.map((e,a)=>{const o=La[e.kind],i=Ra[e.kind],c=`${i} ${a+1}`,m=Xi[e.markerType||ye],S=ja.find(k=>k.value===(e.markerType||ye))?.label||"Review",u=A===e.id,p=u&&!it;return t.jsx(Yi,{id:e.id,children:({attributes:k,listeners:w,setNodeRef:C,transform:G,transition:Le,isDragging:Nt})=>t.jsxs("div",{className:`tf-surface-elevated ${n.annotationCard} ${u?n.annotationCardActive:""} ${Nt?n.annotationCardDragging:""}`,ref:N=>{C(N),N?Nn.current.set(e.id,N):Nn.current.delete(e.id)},style:{...u?{"--annotation-card-accent":rn(e)}:{},transform:Bs.Transform.toString(G),transition:Le},onBlur:N=>{N.currentTarget.contains(N.relatedTarget)||Q(!0)},children:[t.jsxs("div",{className:n.annotationMeta,children:[t.jsx("button",{type:"button",className:n.annotationDragHandle,"aria-label":`Reorder ${c}`,title:"Drag to reorder. Press Space, then use the arrow keys to reorder with the keyboard.",...k,...w,children:t.jsx(Ta,{size:16})}),t.jsx("button",{type:"button",className:n.annotationCardButton,onClick:()=>{ys(e.id)},"aria-label":i,"aria-expanded":p,children:t.jsx("span",{className:`tf-heading-card ${n.annotationTitle}`,children:c})}),t.jsx("span",{className:`tf-text-meta ${n.annotationKind}`,"aria-hidden":"true",children:t.jsx(o,{size:16})})]}),p?t.jsxs("div",{className:n.annotationInstructionEditor,children:[t.jsx("label",{className:"tf-field-label",htmlFor:"annotated-marker-instruction",children:"Marker instruction"}),t.jsx("textarea",{id:"annotated-marker-instruction",ref:u?na:null,className:`tf-field-shell ${n.textArea} ${n.annotationInstructionField}`,value:e.instruction,onChange:N=>{ie(e.id,Ie=>({...Ie,instruction:N.target.value}),600)},onBlur:()=>{M("text")},placeholder:"What should the AI focus on for this marker?"}),t.jsxs("div",{className:n.annotationTypeField,children:[t.jsx("label",{className:"tf-field-label",htmlFor:"annotated-marker-type",children:"Instruction type"}),t.jsx("select",{id:"annotated-marker-type",className:`tf-field-shell ${n.select}`,value:e.markerType||ye,onChange:N=>{ie(e.id,Ie=>al(Ie,N.target.value))},children:ja.map(N=>t.jsx("option",{value:N.value,children:N.label},N.value))})]}),t.jsxs("details",{className:n.annotationGeometryDetails,children:[t.jsx("summary",{className:"tf-field-label",children:"Precise placement"}),t.jsx("div",{className:n.annotationGeometryFields,"aria-label":"Marker geometry percent controls",children:cl(e).map(N=>t.jsxs("label",{className:n.annotationGeometryField,children:[t.jsx("span",{className:`tf-text-meta ${n.annotationGeometryLabel}`,children:N.label}),t.jsx("input",{className:`tf-field-shell ${n.annotationGeometryInput}`,type:"number",min:0,max:100,step:.1,value:N.value,onChange:Ie=>{const Qt=il(Ie.target.value);Qt!==null&&ie(e.id,Ls=>ll(Ls,N.key,Qt))},"aria-label":`${N.label} percent`})]},N.key))})]})]}):t.jsx("button",{type:"button",className:n.annotationInstructionButton,onClick:()=>{Ct(e.id)},"aria-label":`Edit ${i} instruction`,children:t.jsxs("div",{className:n.annotationInstructionEditor,children:[e.instruction.trim()?t.jsx("div",{className:`tf-text-secondary ${n.annotationInstructionPreview}`,children:e.instruction.trim()}):null,t.jsx("div",{className:n.annotationPreviewFooter,children:t.jsx("span",{className:`tf-text-meta ${n.annotationInstructionTypeIcon}`,"aria-label":`Instruction type: ${S}`,title:S,children:t.jsx(m,{size:16})})})]})})]})},e.id)})})}),t.jsx(Fs,{children:vt?t.jsxs("div",{className:`tf-surface-elevated ${n.annotationCard} ${n.annotationDragOverlay}`,"data-testid":"annotation-drag-overlay",children:[t.jsxs("div",{className:n.annotationMeta,children:[t.jsx(Ta,{size:16,className:n.annotationDragOverlayGrip}),t.jsx("span",{className:`tf-heading-card ${n.annotationTitle} ${n.annotationDragOverlayTitle}`,children:Ra[vt.kind]}),t.jsx("span",{className:`tf-text-meta ${n.annotationKind}`,"aria-hidden":"true",children:en.createElement(La[vt.kind],{size:16})})]}),vt.instruction.trim()?t.jsx("div",{className:`tf-text-secondary ${n.annotationInstructionPreview}`,children:vt.instruction.trim()}):null]}):null})]})]}):t.jsxs("div",{className:n.emptyState,children:[t.jsx("strong",{className:"tf-empty-title",children:"No active session"}),t.jsx("p",{className:"tf-empty-copy",children:"Create or select a session to edit annotations."})]})}),t.jsx(nn,{isOpen:qa,onClose:()=>{lt||(Ht(!1),zt(""))},title:"Open Image",size:"sm",children:t.jsxs("form",{className:n.openImageModalBody,onSubmit:e=>{e.preventDefault(),os()},children:[t.jsx("label",{className:"tf-field-label",htmlFor:"annotated-open-image-reference",children:"Image reference number"}),t.jsx("input",{id:"annotated-open-image-reference",className:`tf-field-shell ${n.textInput} ${n.openImageField}`,value:bn,onChange:e=>zt(e.target.value),placeholder:"I-24",autoFocus:!0}),t.jsxs("div",{className:n.openImageActions,children:[t.jsx("button",{type:"button",className:"tf-button-ghost tf-button-compact",onClick:()=>{Ht(!1),zt("")},disabled:lt,children:"Cancel"}),t.jsx("button",{type:"submit",className:"tf-button-primary tf-button-compact",disabled:lt,children:lt?"Opening…":"Open"})]})]})}),t.jsx(nn,{isOpen:Ya,onClose:()=>qn(!1),title:"How To Use Markers",size:"md",children:t.jsx("div",{className:n.markerHelpModalBody,children:$a.filter(e=>e.value!=="select").map(e=>t.jsxs("div",{className:`tf-surface-inset ${n.markerHelpItem}`,children:[t.jsxs("div",{className:n.markerHelpHeader,children:[t.jsx("strong",{className:"tf-heading-card",children:e.label}),t.jsx("span",{className:"tf-text-meta",children:an[e.value].short})]}),t.jsx("p",{className:"tf-text-secondary",children:an[e.value].detail}),t.jsx("p",{className:`tf-text-body ${n.markerHelpExample}`,children:an[e.value].example})]},e.value))})}),t.jsx(nn,{isOpen:Va,onClose:()=>{ze||Bt(!1)},title:"Link Session to Task",size:"sm",children:t.jsxs("div",{className:n.taskLinkModalBody,children:[t.jsx("p",{className:"tf-text-secondary",children:"This links the review session only. The image stays unattached."}),t.jsx("input",{className:`tf-field-shell ${n.textInput}`,value:hn,onChange:e=>Vn(e.target.value),placeholder:"Search tasks...","aria-label":"Search tasks",autoFocus:!0}),Ft?t.jsx("div",{className:n.detailEmpty,children:t.jsx("p",{className:"tf-empty-copy",children:"Loading tasks…"})}):la.length===0?t.jsx("div",{className:n.detailEmpty,children:t.jsx("p",{className:"tf-empty-copy",children:"No tasks match your search."})}):t.jsx("div",{className:`tf-scrollbar ${n.taskLinkList}`,children:la.map(e=>{const a=String(e.referenceLabel||e.id).trim()||e.id,o=e.id===b?.taskId;return t.jsxs("button",{type:"button",className:`tf-surface-elevated ${n.taskLinkOption} ${o?n.taskLinkOptionActive:""}`,onClick:()=>{Rn(e.id)},disabled:ze||o,children:[t.jsx("span",{className:n.taskLinkOptionTitle,children:e.title}),t.jsxs("span",{className:"tf-text-meta",children:[a,o?" · Linked":""]})]},e.id)})}),t.jsxs("div",{className:n.taskLinkActions,children:[t.jsx("button",{type:"button",className:"tf-button-ghost tf-button-compact",onClick:()=>Bt(!1),disabled:ze,children:"Cancel"}),b?.taskId?t.jsx("button",{type:"button",className:"tf-button-ghost tf-button-compact",onClick:()=>{Rn(null)},disabled:ze,children:"Unlink"}):null]})]})}),t.jsx(nn,{isOpen:Ka,onClose:()=>mn(!1),title:"AI Payload",size:"lg",children:t.jsxs("div",{className:n.payloadModalBody,children:[t.jsxs("div",{className:n.payloadModalToolbar,children:[t.jsxs("div",{className:n.payloadViewToggle,children:[t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${n.toolBtn} ${fn==="json"?n.toolBtnActive:""}`,onClick:()=>Kn("json"),children:"JSON"}),t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${n.toolBtn} ${fn==="brief"?n.toolBtnActive:""}`,onClick:()=>Kn("brief"),children:"AI Brief"})]}),t.jsxs("div",{className:n.payloadModalActions,children:[t.jsxs("button",{type:"button",className:`tf-button-ghost tf-button-compact ${n.ghostBtn}`,onClick:()=>{ba("json")},disabled:!fe,"aria-label":be==="json"?"Copied JSON":"Copy JSON",title:be==="json"?"Copied JSON":"Copy JSON",children:[be==="json"?t.jsx(Dn,{size:16}):t.jsx(En,{size:16}),t.jsx("span",{children:"JSON"})]}),t.jsxs("button",{type:"button",className:`tf-button-ghost tf-button-compact ${n.ghostBtn}`,onClick:()=>{ba("brief")},disabled:!fe,"aria-label":be==="brief"?"Copied AI Brief":"Copy AI Brief",title:be==="brief"?"Copied AI Brief":"Copy AI Brief",children:[be==="brief"?t.jsx(Dn,{size:16}):t.jsx(En,{size:16}),t.jsx("span",{children:"AI Brief"})]})]})]}),Mt?t.jsx("div",{className:n.detailEmpty,children:t.jsx("p",{className:"tf-empty-copy",children:"Loading payload…"})}):fe?t.jsx("pre",{className:`tf-surface-inset tf-scrollbar ${n.payloadModalPreview}`,children:fn==="json"?JSON.stringify(fe,null,2):Ea(fe)}):t.jsx("div",{className:n.detailEmpty,children:t.jsx("p",{className:"tf-empty-copy",children:"Load a payload preview to inspect the current session contract."})})]})})]})}export{vl as AnnotatedAttachmentWorkspaceShell};
|