@taskforcehq/taskforce 0.3.328 → 0.3.329

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.
Files changed (264) hide show
  1. package/dist/Taskforce.module.css +233 -34
  2. package/dist/TaskforceCore.js +237 -230
  3. package/dist/annotatedAttachments/AnnotatedAttachmentSessionStore.js +1 -1
  4. package/dist/cli.js +34 -0
  5. package/dist/cliCloudTargetGuard.d.ts +5 -0
  6. package/dist/cliCloudTargetGuard.js +11 -0
  7. package/dist/components/features/AnnotatedAttachmentWorkspace.js +24 -8
  8. package/dist/components/features/TaskSettings.d.ts +12 -1
  9. package/dist/components/features/TaskSettings.js +147 -40
  10. package/dist/components/features/agentCapabilities/AgentCapabilitiesPrototype.d.ts +1 -1
  11. package/dist/components/features/planning/PlanningModule.js +2 -5
  12. package/dist/components/features/planning/PlanningTaskOrderList.d.ts +1 -1
  13. package/dist/components/features/planning/PlanningTaskOrderList.js +17 -6
  14. package/dist/components/features/planning/planningTaskArrangement.d.ts +1 -0
  15. package/dist/components/features/planning/planningTaskArrangement.js +5 -5
  16. package/dist/components/features/taskforceAgentEditorModel.js +3 -1
  17. package/dist/components/task/TaskCard.d.ts +5 -0
  18. package/dist/components/task/TaskCard.js +65 -10
  19. package/dist/components/task/TaskImageReviews.js +14 -5
  20. package/dist/components/task/TaskKanban.d.ts +6 -1
  21. package/dist/components/task/TaskKanban.js +152 -6
  22. package/dist/components/task/TaskList.d.ts +5 -0
  23. package/dist/components/task/TaskList.js +3 -3
  24. package/dist/components/ui/PasswordInput.d.ts +6 -0
  25. package/dist/components/ui/PasswordInput.js +11 -0
  26. package/dist/components/ui/TopNoticeLayer.js +1 -1
  27. package/dist/components/views/AppShellHeader.js +32 -11
  28. package/dist/components/views/PlanComparisonPage.js +12 -0
  29. package/dist/components/views/StandaloneLayout.js +7 -31
  30. package/dist/components/views/WidgetView.js +3 -3
  31. package/dist/components/views/panels/PlanningDrawer.js +5 -12
  32. package/dist/components/views/standalone/modals/AccountSettingsModal.js +26 -17
  33. package/dist/config/envSchema.js +12 -0
  34. package/dist/config/localServiceRuntimeContract.d.ts +13 -0
  35. package/dist/config/localServiceRuntimeContract.js +135 -0
  36. package/dist/core/AiProfileService.js +46 -8
  37. package/dist/core/DeletedTaskLifecycleService.d.ts +1 -0
  38. package/dist/core/DeletedTaskLifecycleService.js +37 -6
  39. package/dist/core/TaskAttachmentLinksDurableMutationService.d.ts +3 -2
  40. package/dist/core/TaskAttachmentLinksDurableMutationService.js +33 -9
  41. package/dist/core/Taskforce.d.ts +62 -2
  42. package/dist/core/Taskforce.js +635 -32
  43. package/dist/core/types.d.ts +6 -0
  44. package/dist/hooks/sync/useDurableLocalOutboxDrain.d.ts +1 -1
  45. package/dist/hooks/sync/useDurableTaskCreateMutation.js +1 -1
  46. package/dist/hooks/sync/useDurableTaskMetadataMutation.d.ts +1 -0
  47. package/dist/hooks/sync/useDurableTaskMetadataMutation.js +1 -0
  48. package/dist/hooks/sync/useDurableTaskStatusMutation.d.ts +1 -0
  49. package/dist/hooks/tasks/taskHttpMutation.js +1 -0
  50. package/dist/hooks/tasks/useCloudTaskSearch.d.ts +12 -0
  51. package/dist/hooks/tasks/useCloudTaskSearch.js +71 -0
  52. package/dist/hooks/tasks/useTaskDescriptionImageDraftRecovery.d.ts +16 -0
  53. package/dist/hooks/tasks/useTaskDescriptionImageDraftRecovery.js +197 -0
  54. package/dist/hooks/tasks/useTaskEditorNavigation.d.ts +16 -3
  55. package/dist/hooks/tasks/useTaskEditorNavigation.js +72 -13
  56. package/dist/hooks/tasks/useTaskFormActions.d.ts +6 -0
  57. package/dist/hooks/tasks/useTaskFormActions.js +65 -12
  58. package/dist/hooks/ui/useSettingsModel.d.ts +24 -2
  59. package/dist/hooks/ui/useSettingsModel.js +13 -2
  60. package/dist/hooks/ui/useSettingsPersistence.d.ts +12 -1
  61. package/dist/hooks/ui/useSettingsPersistence.js +74 -47
  62. package/dist/hooks/useFilterSort.d.ts +7 -3
  63. package/dist/hooks/useFilterSort.js +15 -5
  64. package/dist/hooks/useTaskData.d.ts +10 -1
  65. package/dist/hooks/useTaskData.js +216 -7
  66. package/dist/hooks/useTaskMutations.d.ts +10 -2
  67. package/dist/hooks/useTaskMutations.js +223 -43
  68. package/dist/hooks/useTaskforce.d.ts +37 -9
  69. package/dist/hooks/useTaskforce.js +349 -39
  70. package/dist/hooks/useUiNotice.d.ts +4 -0
  71. package/dist/hooks/useUiNotice.js +4 -0
  72. package/dist/mcp/adminWorkspaceRegistrar.js +3 -3
  73. package/dist/mcp/documentAssetRegistrar.js +44 -35
  74. package/dist/mcp/documentHelpers.d.ts +1 -0
  75. package/dist/mcp/documentHelpers.js +7 -3
  76. package/dist/mcp/runtime.js +172 -42
  77. package/dist/mcp/taskPlanningRegistrar.js +41 -38
  78. package/dist/mcp/toolCallCompatibility.js +38 -1
  79. package/dist/mcp/toolCatalog.d.ts +1 -0
  80. package/dist/migrations/taskSchemaMigrations.js +12 -0
  81. package/dist/runtime/appGateDefinitions.d.ts +30 -6
  82. package/dist/runtime/appGateDefinitions.js +6 -6
  83. package/dist/runtime/appGates.d.ts +12 -13
  84. package/dist/runtime/appGates.js +29 -13
  85. package/dist/runtime/nodeAppGates.d.ts +8 -0
  86. package/dist/runtime/nodeAppGates.js +27 -0
  87. package/dist/server/cloudCollectionRead.d.ts +1 -1
  88. package/dist/server/cloudCollectionRead.js +2 -2
  89. package/dist/server/index.d.ts +3 -0
  90. package/dist/server/index.js +15 -3
  91. package/dist/server/localServiceLease.d.ts +3 -0
  92. package/dist/server/localServiceLease.js +9 -1
  93. package/dist/server/localWorkspaceSyncServerRuntime.js +10 -3
  94. package/dist/server/rateLimit.d.ts +1 -0
  95. package/dist/server/rateLimit.js +4 -0
  96. package/dist/server/realtimeSyncWs.js +36 -12
  97. package/dist/server/routes/admin.js +1 -0
  98. package/dist/server/routes/agentRoles.js +3 -2
  99. package/dist/server/routes/agentSkills.js +3 -2
  100. package/dist/server/routes/agents.js +118 -16
  101. package/dist/server/routes/annotatedAttachments.js +3 -2
  102. package/dist/server/routes/auth.js +3 -1
  103. package/dist/server/routes/durableTaskHttpRouters.d.ts +9 -2
  104. package/dist/server/routes/localService.js +2 -0
  105. package/dist/server/routes/primitives.d.ts +2 -0
  106. package/dist/server/routes/syncAuxRoutes.js +5 -2
  107. package/dist/server/routes/syncPullApplyRoutes.js +23 -4
  108. package/dist/server/routes/syncV3FeedRoutes.js +18 -16
  109. package/dist/server/routes/syncV3LocalCaptureRoutes.js +28 -2
  110. package/dist/server/routes/syncV3LocalFeedApplyRoutes.d.ts +1 -0
  111. package/dist/server/routes/syncV3LocalFeedApplyRoutes.js +26 -0
  112. package/dist/server/routes/syncV3OperationRoutes.js +10 -0
  113. package/dist/server/routes/tasks.js +103 -11
  114. package/dist/server/routes/workspaces.js +43 -1
  115. package/dist/server/workspaceDeletionAdmission.d.ts +23 -0
  116. package/dist/server/workspaceDeletionAdmission.js +50 -0
  117. package/dist/service/localServiceCli.js +16 -0
  118. package/dist/service/localServiceClientLifecycle.js +36 -10
  119. package/dist/services/codexAppServerModelGateway.d.ts +112 -0
  120. package/dist/services/codexAppServerModelGateway.js +438 -0
  121. package/dist/services/taskforceAgentMcpBridge.d.ts +7 -1
  122. package/dist/services/taskforceAgentMcpBridge.js +23 -3
  123. package/dist/shared/taskforceAgentDefinition.js +7 -1
  124. package/dist/shared/taskforceAgentModels.d.ts +1 -0
  125. package/dist/shared/taskforceAgentModels.js +30 -1
  126. package/dist/storage/postgresAdapter.d.ts +20 -3
  127. package/dist/storage/postgresAdapter.js +106 -14
  128. package/dist/storage/postgresWorker.js +13 -4
  129. package/dist/storage/postgresWorkerProtocol.d.ts +29 -0
  130. package/dist/storage/postgresWorkerProtocol.js +30 -0
  131. package/dist/sync/cloudSyncApi.d.ts +4 -1
  132. package/dist/sync/cloudSyncApi.js +7 -2
  133. package/dist/sync/contentSyncState.d.ts +1 -1
  134. package/dist/sync/coordinator/localSyncExecutionPermitStore.d.ts +1 -0
  135. package/dist/sync/coordinator/localSyncExecutionPermitStore.js +7 -1
  136. package/dist/sync/coordinator/localWorkspaceSyncRunner.js +6 -2
  137. package/dist/sync/engine/workspaceSyncEngineBrowserGatewayRemoteServices.js +20 -2
  138. package/dist/sync/engine/workspaceSyncEngineLocalServices.d.ts +4 -0
  139. package/dist/sync/engine/workspaceSyncEngineLocalServices.js +11 -0
  140. package/dist/sync/engine/workspaceSyncEngineRemoteServices.d.ts +11 -0
  141. package/dist/sync/engine/workspaceSyncEngineRemoteServices.js +2 -1
  142. package/dist/sync/engine/workspaceSyncEngineServerRemoteServices.js +31 -4
  143. package/dist/sync/engine/workspaceSyncEngineServerRunnerOperations.d.ts +3 -1
  144. package/dist/sync/engine/workspaceSyncEngineServerRunnerOperations.js +25 -8
  145. package/dist/sync/engine/workspaceSyncEngineTransfers.d.ts +1 -1
  146. package/dist/sync/engine/workspaceSyncEngineTransfers.js +8 -3
  147. package/dist/sync/syncService.d.ts +2 -0
  148. package/dist/sync/syncService.js +4 -1
  149. package/dist/sync/v3/combinedFeedCapability.js +4 -0
  150. package/dist/sync/v3/durableTaskAttachmentLinksMutationRouter.d.ts +2 -0
  151. package/dist/sync/v3/durableTaskAttachmentLinksMutationRouter.js +11 -1
  152. package/dist/sync/v3/durableTaskChecklistMutationRouter.d.ts +2 -0
  153. package/dist/sync/v3/durableTaskChecklistMutationRouter.js +4 -0
  154. package/dist/sync/v3/durableTaskHttpBulkMutationRouter.d.ts +1 -0
  155. package/dist/sync/v3/durableTaskHttpBulkMutationRouter.js +30 -8
  156. package/dist/sync/v3/durableTaskHttpRootMutationRouter.d.ts +5 -3
  157. package/dist/sync/v3/durableTaskHttpRootMutationRouter.js +27 -2
  158. package/dist/sync/v3/localTaskAttachmentLinksOutboxService.d.ts +2 -0
  159. package/dist/sync/v3/localTaskAttachmentLinksOutboxService.js +47 -7
  160. package/dist/sync/v3/localTaskCreateOutboxService.js +15 -6
  161. package/dist/sync/v3/localTaskMetadataClient.d.ts +1 -0
  162. package/dist/sync/v3/localTaskMetadataClient.js +1 -0
  163. package/dist/sync/v3/localTaskMetadataOutboxHandler.js +5 -1
  164. package/dist/sync/v3/localTaskMetadataOutboxService.d.ts +2 -0
  165. package/dist/sync/v3/localTaskMetadataOutboxService.js +7 -0
  166. package/dist/sync/v3/localTaskRestoreOutboxService.js +14 -6
  167. package/dist/sync/v3/localTaskStatusClient.d.ts +1 -0
  168. package/dist/sync/v3/localTaskStatusClient.js +6 -1
  169. package/dist/sync/v3/localTaskStatusOutboxService.d.ts +2 -0
  170. package/dist/sync/v3/localTaskStatusOutboxService.js +54 -13
  171. package/dist/sync/v3/syncDurabilityStore.d.ts +7 -0
  172. package/dist/sync/v3/syncDurabilityStore.js +31 -11
  173. package/dist/sync/v3/taskAttachmentLinksMutationService.d.ts +6 -4
  174. package/dist/sync/v3/taskAttachmentLinksMutationService.js +19 -10
  175. package/dist/sync/v3/taskChecklistMutationService.d.ts +4 -2
  176. package/dist/sync/v3/taskChecklistMutationService.js +4 -0
  177. package/dist/sync/v3/taskCreateMutationService.d.ts +2 -2
  178. package/dist/sync/v3/taskCreateMutationService.js +7 -4
  179. package/dist/sync/v3/taskMetadataMutationService.d.ts +3 -0
  180. package/dist/sync/v3/taskMetadataMutationService.js +4 -0
  181. package/dist/sync/v3/taskRestoreMutationService.d.ts +2 -2
  182. package/dist/sync/v3/taskRestoreMutationService.js +7 -4
  183. package/dist/sync/v3/taskStatusMutationService.d.ts +2 -0
  184. package/dist/sync/v3/taskStatusMutationService.js +4 -0
  185. package/dist/sync/v3/workflowAssignmentSync.d.ts +1 -0
  186. package/dist/sync/v3/workflowAssignmentSync.js +3 -0
  187. package/dist/sync/v3/workspaceSyncV2ProjectionExclusions.d.ts +1 -1
  188. package/dist/sync/v3/workspaceSyncV2ProjectionExclusions.js +13 -3
  189. package/dist/sync/v3/workspaceSyncV3AttachmentApplyObligationStore.d.ts +11 -0
  190. package/dist/sync/v3/workspaceSyncV3AttachmentApplyObligationStore.js +27 -10
  191. package/dist/sync/v3/workspaceSyncV3AttachmentAssetHydration.d.ts +2 -1
  192. package/dist/sync/v3/workspaceSyncV3AttachmentAssetHydration.js +52 -10
  193. package/dist/sync/v3/workspaceSyncV3CloudOperationHandler.js +9 -1
  194. package/dist/sync/v3/workspaceSyncV3CombinedFeedOrchestrator.js +8 -3
  195. package/dist/sync/v3/workspaceSyncV3CombinedLocalApply.js +51 -10
  196. package/dist/sync/v3/workspaceSyncV3CombinedRepairBaseline.d.ts +7 -0
  197. package/dist/sync/v3/workspaceSyncV3CombinedRepairBaseline.js +30 -18
  198. package/dist/sync/v3/workspaceSyncV3CombinedRepairMaterialization.d.ts +9 -4
  199. package/dist/sync/v3/workspaceSyncV3CombinedRepairMaterialization.js +98 -47
  200. package/dist/sync/v3/workspaceSyncV3CombinedRepairSnapshot.d.ts +10 -0
  201. package/dist/sync/v3/workspaceSyncV3CombinedRepairSnapshot.js +58 -21
  202. package/dist/sync/v3/workspaceSyncV3CombinedWireContract.d.ts +3 -1
  203. package/dist/sync/v3/workspaceSyncV3CombinedWireContract.js +18 -0
  204. package/dist/sync/v3/workspaceSyncV3CoverageRegistry.js +6 -0
  205. package/dist/sync/v3/workspaceSyncV3FeedProfile.d.ts +1 -1
  206. package/dist/sync/v3/workspaceSyncV3LegacyBoundaryAttestation.d.ts +1 -0
  207. package/dist/sync/v3/workspaceSyncV3LegacyBoundaryAttestation.js +23 -10
  208. package/dist/sync/v3/workspaceSyncV3NestedTaskApply.d.ts +3 -0
  209. package/dist/sync/v3/workspaceSyncV3NestedTaskApply.js +64 -13
  210. package/dist/sync/v3/workspaceSyncV3NestedTaskCodecs.d.ts +9 -0
  211. package/dist/sync/v3/workspaceSyncV3NestedTaskCodecs.js +26 -0
  212. package/dist/sync/v3/workspaceSyncV3NestedTaskProjection.d.ts +15 -5
  213. package/dist/sync/v3/workspaceSyncV3NestedTaskProjection.js +50 -14
  214. package/dist/sync/v3/workspaceSyncV3NestedTaskRepairSnapshot.d.ts +2 -1
  215. package/dist/sync/v3/workspaceSyncV3NestedTaskRepairSnapshot.js +11 -3
  216. package/dist/sync/v3/workspaceSyncV3OperationProtocol.d.ts +2 -0
  217. package/dist/sync/v3/workspaceSyncV3OperatorDiagnostics.d.ts +2 -0
  218. package/dist/sync/v3/workspaceSyncV3OperatorDiagnostics.js +19 -7
  219. package/dist/sync/v3/workspaceSyncV3TaskCommentAudit.js +9 -2
  220. package/dist/sync/v3/workspaceSyncV3TaskCoverCoverage.d.ts +7 -0
  221. package/dist/sync/v3/workspaceSyncV3TaskCoverCoverage.js +37 -0
  222. package/dist/sync/v3/workspaceSyncV3TaskCoverWireContract.d.ts +6 -0
  223. package/dist/sync/v3/workspaceSyncV3TaskCoverWireContract.js +9 -0
  224. package/dist/sync/workspacePullFeed.js +2 -1
  225. package/dist/sync/workspaceRepair.d.ts +3 -0
  226. package/dist/sync/workspaceRepair.js +67 -6
  227. package/dist/types.d.ts +47 -1
  228. package/dist/types.js +6 -0
  229. package/dist/ui/assets/{AiIdentityRosterCard-MZs7lVED.js → AiIdentityRosterCard-BZM4aQnM.js} +1 -1
  230. package/dist/ui/assets/AiProfilesModule-BbAEWtHH.js +1 -0
  231. package/dist/ui/assets/AnnotatedAttachmentWorkspace-B68Wg-RV.js +3 -0
  232. package/dist/ui/assets/AnnotatedAttachmentWorkspace-TzYu7pkG.css +1 -0
  233. package/dist/ui/assets/{AssetTraySortControl-Kf1pelSy.js → AssetTraySortControl-C8Rztyal.js} +1 -1
  234. package/dist/ui/assets/{ContextAttachmentManager-B8boOs6Q.js → ContextAttachmentManager-Cj3c7X9y.js} +2 -2
  235. package/dist/ui/assets/{DocumentWorkspace-DXH4XUsB.js → DocumentWorkspace-B5uvzems.js} +1 -1
  236. package/dist/ui/assets/{EntityActivityTimeline-BtSTq0ON.js → EntityActivityTimeline-BVFvCB5R.js} +1 -1
  237. package/dist/ui/assets/PlanningModule-B5DWQOGz.js +1 -0
  238. package/dist/ui/assets/PlansPage-AY4cGWco.js +1 -0
  239. package/dist/ui/assets/TaskContextUpload-DZxTVesW.js +1 -0
  240. package/dist/ui/assets/TaskSettings-BeWAuyZj.js +12 -0
  241. package/dist/ui/assets/{TaskforceAgentsModule-BazdUwxZ.js → TaskforceAgentsModule-BifCYtjR.js} +6 -6
  242. package/dist/ui/assets/{WorkflowManagerModule-DWFspC-o.js → WorkflowManagerModule-DEr5di_r.js} +1 -1
  243. package/dist/ui/assets/index-I5zhdtgt.js +7 -0
  244. package/dist/ui/assets/index-VRFsx3wz.css +1 -0
  245. package/dist/ui/assets/{vendor-icons-BkFLXavV.js → vendor-icons-D9Lpw-j4.js} +1 -1
  246. package/dist/ui/index.html +3 -3
  247. package/dist/utils/taskActivity.d.ts +3 -2
  248. package/dist/utils/taskActivity.js +19 -2
  249. package/dist/utils/taskEditorReconciliation.d.ts +40 -0
  250. package/dist/utils/taskEditorReconciliation.js +217 -0
  251. package/dist/utils/taskNormalization.d.ts +1 -0
  252. package/dist/utils/taskNormalization.js +39 -0
  253. package/dist/utils/taskSearch.js +2 -2
  254. package/dist/utils/uiNotice.d.ts +4 -0
  255. package/package.json +16 -4
  256. package/dist/ui/assets/AiProfilesModule-C3i0LOxe.js +0 -1
  257. package/dist/ui/assets/AnnotatedAttachmentWorkspace-CBRZ8rca.css +0 -1
  258. package/dist/ui/assets/AnnotatedAttachmentWorkspace-DVZk5Tln.js +0 -3
  259. package/dist/ui/assets/PlanningModule-BPVyEa-f.js +0 -1
  260. package/dist/ui/assets/PlansPage-ChqgxALc.js +0 -1
  261. package/dist/ui/assets/TaskContextUpload-CB3ol0sN.js +0 -1
  262. package/dist/ui/assets/TaskSettings-g4ECKNOz.js +0 -12
  263. package/dist/ui/assets/index-BUplSsv_.js +0 -7
  264. package/dist/ui/assets/index-gz2EXuoK.css +0 -1
@@ -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};
@@ -1 +0,0 @@
1
- import{R as a,j as t}from"./vendor-react-CKJs5o3c.js";import{am as Pe,an as We,ao as De,ap as Fe,aq as ke,ar as le,T as He,as as me,at as ne,au as Y,av as U,aw as q,ax as Be,ay as Me,az as Ue,aA as Ge,aB as Ve,aC as Ke,aD as Ce,aE as Ee,aF as ce,aG as Se,aH as qe,aI as Qe,aJ as Je,aK as Xe,aL as Ye}from"./index-BUplSsv_.js";import{w as re,Z as we,R as oe,aj as Ze,ak as et,S as tt,X as xe,al as it,ah as nt,t as ae,ai as be,V as se,q as at,Y as st,a7 as rt}from"./vendor-icons-BkFLXavV.js";import"./vendor-markdown-_lhNCyq-.js";import"./vendor-dnd-CJ-AjP-Y.js";import"./vendor-router-AqJMU8Lz.js";const ot="_module_3zich_1",lt="_columns_3zich_15",ct="_column_3zich_15",dt="_columnHeader_3zich_36",ut="_columnHeadingGroup_3zich_49",ht="_paneHeading_3zich_56",vt="_responsiveBack_3zich_60",pt="_sectionLabel_3zich_64",ft="_sectionHeadingRow_3zich_68",yt="_headerActions_3zich_81",gt="_portfolioControls_3zich_87",kt="_searchRow_3zich_95",mt="_searchShell_3zich_101",wt="_clearSearch_3zich_139",xt="_controlActive_3zich_160",bt="_filterPanel_3zich_166",jt="_filterField_3zich_177",_t="_filterLabel_3zich_184",Ct="_filterDropdown_3zich_190",Et="_sortTrigger_3zich_204",St="_scrollRegion_3zich_217",It="_selectedEntityContext_3zich_227",Nt="_selectedEntityContextArchived_3zich_237",At="_selectedEntityReferenceRow_3zich_242",Rt="_selectedEntityReferenceIdentity_3zich_257",Ot="_selectedEntityReferenceActions_3zich_264",zt="_workspaceEditor_3zich_278",Tt="_workspaceEditorField_3zich_294",Lt="_workspaceEditorActions_3zich_337",$t="_selectedEntityDescription_3zich_348",Pt="_selectedEntityDescriptionMarkdown_3zich_355",Wt="_selectedEntityOwnerField_3zich_361",Dt="_selectedEntityOwnerDropdown_3zich_373",Ft="_selectedEntityDetailsSection_3zich_377",Ht="_activityTimelineList_3zich_382",Bt="_activityTimelineEmpty_3zich_389",Mt="_visuallyHidden_3zich_393",Ut="_entityCard_3zich_405",Gt="_entityCardTopRow_3zich_426",Vt="_entityCardBody_3zich_433",Kt="_entityCardContentButton_3zich_437",qt="_entityCardSelected_3zich_447",Qt="_entityCardArchived_3zich_455",Jt="_relationshipPickerRow_3zich_460",Xt="_relationshipRecovery_3zich_466",Yt="_empty_3zich_488",Zt="_centerState_3zich_495",ei="_inlineError_3zich_509",ti="_spinner_3zich_524",ii="_columnPortfolio_3zich_543",ni="_columnActive_3zich_544",ai="_columnWorkstreams_3zich_545",si="_columnTasks_3zich_550",ri="_workspaceEditorIdentity_3zich_592",n={module:ot,columns:lt,column:ct,columnHeader:dt,columnHeadingGroup:ut,paneHeading:ht,responsiveBack:vt,sectionLabel:pt,sectionHeadingRow:ft,headerActions:yt,portfolioControls:gt,searchRow:kt,searchShell:mt,clearSearch:wt,controlActive:xt,filterPanel:bt,filterField:jt,filterLabel:_t,filterDropdown:Ct,sortTrigger:Et,scrollRegion:St,selectedEntityContext:It,selectedEntityContextArchived:Nt,selectedEntityReferenceRow:At,selectedEntityReferenceIdentity:Rt,selectedEntityReferenceActions:Ot,workspaceEditor:zt,workspaceEditorField:Tt,workspaceEditorActions:Lt,selectedEntityDescription:$t,selectedEntityDescriptionMarkdown:Pt,selectedEntityOwnerField:Wt,selectedEntityOwnerDropdown:Dt,selectedEntityDetailsSection:Ft,activityTimelineList:Ht,activityTimelineEmpty:Bt,visuallyHidden:Mt,entityCard:Ut,entityCardTopRow:Gt,entityCardBody:Vt,entityCardContentButton:Kt,entityCardSelected:qt,entityCardArchived:Qt,relationshipPickerRow:Jt,relationshipRecovery:Xt,empty:Yt,centerState:Zt,inlineError:ei,spinner:ti,columnPortfolio:ii,columnActive:ni,columnWorkstreams:ai,columnTasks:si,workspaceEditorIdentity:ri};function Z({entityType:e,mode:l,initialTitle:j="",initialDescription:m="",ownerOptions:p,fixedInitiativeId:f,formId:S,showActions:I=!0,onSavingChange:_,onCancel:A,onSave:T}){const w=e==="initiative"?"Initiative":"Workstream",H=a.useId(),$=a.useId(),P=a.useId(),y=a.useRef(null),[G,B]=a.useState(j),[C,g]=a.useState(m),[M,W]=a.useState(""),[k,L]=a.useState(null),[E,R]=a.useState(null),[c,b]=a.useState(null),[D,F]=a.useState(null),[x,N]=a.useState(!1);a.useEffect(()=>{y.current?.focus()},[]);const O=async u=>{if(u.preventDefault(),x)return;const h=G.trim();if(!h){b(`${w} title is required.`),y.current?.focus();return}b(null),F(null),N(!0),_?.(!0);try{await T({title:h,description:C.trim()||null,...l==="create"?{ownerId:M.trim()||null}:{},...e==="workstream"&&l==="create"?{initiativeId:f||null}:{},...l==="create"&&(k||E)?{icon:k,color:E}:{}})}catch(z){F(z instanceof Error?z.message:`Failed to save ${w.toLowerCase()}.`)}finally{N(!1),_?.(!1)}};return t.jsxs("form",{id:S,className:n.workspaceEditor,onSubmit:u=>{O(u)},onKeyDown:u=>{u.key!=="Escape"||x||(u.preventDefault(),A())},noValidate:!0,children:[l==="create"?t.jsxs("div",{className:n.workspaceEditorIdentity,children:[t.jsx(Ce,{entityType:e,entityId:"create-preview",icon:k,color:E||"blue",size:"detail",onChange:u=>{Object.prototype.hasOwnProperty.call(u,"icon")&&L(u.icon??null),Object.prototype.hasOwnProperty.call(u,"color")&&R(u.color??null)}}),t.jsx("span",{children:"Choose an icon and color"})]}):null,t.jsxs("div",{className:n.workspaceEditorField,children:[t.jsxs("label",{htmlFor:H,children:[w," title"]}),t.jsx("input",{ref:y,id:H,value:G,disabled:x,required:!0,"aria-invalid":c?"true":void 0,"aria-describedby":c?$:void 0,onChange:u=>{B(u.target.value),c&&b(null)},placeholder:e==="initiative"?"Enter initiative title":"Enter workstream title"}),c?t.jsx("p",{id:$,className:"tf-text-error",children:c}):null]}),t.jsxs("div",{className:n.workspaceEditorField,children:[t.jsxs("label",{htmlFor:P,children:[w," description"]}),t.jsx("textarea",{id:P,value:C,disabled:x,rows:5,onChange:u=>g(u.target.value),placeholder:e==="initiative"?"Describe the broader outcome this initiative is meant to achieve.":"Describe the lane of work this workstream will coordinate."})]}),l==="create"&&p?t.jsxs("div",{className:n.workspaceEditorField,children:[t.jsxs("span",{children:[w," owner"]}),t.jsx(le,{value:M,options:p,onChange:W,disabled:x,ariaLabel:`${w} owner`,className:`${Ee.control} ${n.selectedEntityOwnerDropdown}`})]}):null,D?t.jsx("p",{className:"tf-text-error",role:"alert",children:D}):null,I?t.jsxs("div",{className:n.workspaceEditorActions,children:[t.jsx("button",{type:"button",className:"tf-button-secondary tf-button-compact",onClick:A,disabled:x,children:"Cancel"}),t.jsxs("button",{type:"submit",className:"tf-button-primary tf-button-compact",disabled:x,children:[x?t.jsx(re,{size:14,className:n.spinner,"aria-hidden":"true"}):null,l==="create"?`Create ${w}`:"Save"]})]}):null]})}function oi({initiative:e,ownerOption:l,ownerOptions:j,workstreamCount:m,selected:p,onSelect:f,onChangeOwner:S,onChangeIdentity:I}){return t.jsxs("div",{className:`${n.entityCard} ${e.isArchived?n.entityCardArchived:""} ${p?n.entityCardSelected:""}`.trim(),children:[t.jsx(ce,{label:q(e),entityType:"initiative",entityName:e.title,interactive:!1}),t.jsx("div",{className:n.entityCardBody,children:t.jsx("div",{role:"button",tabIndex:0,className:n.entityCardContentButton,onClick:f,onKeyDown:_=>{_.key!=="Enter"&&_.key!==" "||(_.preventDefault(),f())},"aria-pressed":p,children:t.jsx(Se,{item:e,entityType:"initiative",workstreamCount:m,ownerOption:l,ownerOptions:j,onChangeOwner:S,onChangeIdentity:I})})})]})}function je({workstream:e,ownerOption:l,ownerOptions:j,selected:m,onSelect:p,onChangeOwner:f,onChangeIdentity:S,referenceAction:I,feedback:_}){const A=U(e);return t.jsxs("div",{className:`${n.entityCard} ${e.isArchived?n.entityCardArchived:""} ${m?n.entityCardSelected:""}`.trim(),children:[t.jsxs("div",{className:n.entityCardTopRow,children:[I,t.jsx(ce,{label:A||"Reference pending",entityType:"workstream",entityName:e.title,interactive:!1,pending:!A})]}),_,t.jsx("div",{className:n.entityCardBody,children:t.jsx("div",{role:"button",tabIndex:0,className:n.entityCardContentButton,onClick:p,onKeyDown:T=>{T.key!=="Enter"&&T.key!==" "||(T.preventDefault(),p())},"aria-pressed":m,children:t.jsx(Se,{item:e,entityType:"workstream",ownerOption:l,ownerOptions:j,onChangeOwner:f,onChangeIdentity:S})})})]})}function _e({item:e,entityType:l,ownerOptions:j,onChangeOwner:m,onChangeIdentity:p,workspaceId:f,currentActorId:S,taskReferences:I,hydrationState:_,onRetryHydration:A,onAddContextFile:T,onRemoveContextFile:w,onUpdateContextCaption:H,onUpdate:$,onArchive:P,onUnarchive:y,referenceAction:G,relationshipActions:B,relationshipContent:C}){const g=l==="initiative"?"Initiative":"Workstream",M=l==="initiative"?q(e):U(e),[W,k]=a.useState(String(e.ownerId||"")),[L,E]=a.useState(!1),[R,c]=a.useState(!1),[b,D]=a.useState(!1),[F,x]=a.useState(!1),[N,O]=a.useState(!1),u=a.useId(),h=qe({entityType:l,isArchived:e.isArchived,taskCount:e.taskCount,completedTaskCount:e.completedTaskCount,archiveReady:e.archiveReady,activeWorkstreamCount:e.archiveActiveWorkstreamCount}),z=h.mode==="archived"?`Unarchive ${g.toLowerCase()}`:h.mode==="blocked"?`Archive unavailable — active ${h.remainingKind==="task"?"tasks":"workstreams"} remain`:h.mode==="checking"?"Archive availability is still loading":`Archive ${g.toLowerCase()}`;a.useEffect(()=>{k(String(e.ownerId||"")),E(!1)},[e.id,e.ownerId]),a.useEffect(()=>{c(!1),D(!1),x(!1),O(!1)},[e.id]);const J=async d=>{if(!m||e.isArchived||L||d===W)return;const s=W;k(d),E(!0);try{await m(d)}catch{k(s)}finally{E(!1)}},Q=async()=>{if(N)return;if(h.mode==="ready"){x(!0);return}const d=h.mode==="archived"?y:P;if(!(!d||h.mode==="blocked"||h.mode==="checking")){O(!0);try{await d()}finally{O(!1)}}},r=async()=>{if(!(!P||N)){O(!0);try{await P()!==!1&&x(!1)}finally{O(!1)}}};return t.jsxs("section",{className:`${n.selectedEntityContext} ${e.isArchived?n.selectedEntityContextArchived:""}`.trim(),"aria-label":`Selected ${g.toLowerCase()}`,"aria-busy":_?.status==="loading",children:[t.jsxs("div",{className:n.selectedEntityReferenceRow,children:[t.jsxs("div",{className:n.selectedEntityReferenceIdentity,children:[t.jsx(Ce,{entityType:l,entityId:e.id,icon:e.icon,color:e.color,size:"detail",disabled:!!e.isArchived,onChange:p?d=>p(l,e.id,d):void 0}),G,t.jsx(ce,{label:M||"Reference pending",entityType:l,entityName:e.title,interactive:!1,pending:!M})]}),t.jsxs("div",{className:n.selectedEntityReferenceActions,children:[t.jsx("span",{children:g}),B,!R&&(P||y)?t.jsx("button",{type:"button",className:"tf-control-icon",disabled:N||h.mode==="blocked"||h.mode==="checking"||(h.mode==="archived"?!y:!P),onClick:()=>{Q()},"aria-label":z,title:z,"aria-expanded":h.mode==="ready"?F:void 0,children:h.mode==="archived"?t.jsx(oe,{size:14,"aria-hidden":"true"}):t.jsx(st,{size:14,"aria-hidden":"true"})}):null,!R&&!e.isArchived&&$?t.jsx("button",{type:"button",className:"tf-control-icon",onClick:()=>c(!0),"aria-label":`Edit ${g.toLowerCase()}`,title:`Edit ${g.toLowerCase()}`,children:t.jsx(rt,{size:14,"aria-hidden":"true"})}):null,R?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"tf-button-secondary tf-button-compact",onClick:()=>c(!1),disabled:b,children:"Cancel"}),t.jsx("button",{type:"submit",form:u,className:"tf-button-primary tf-button-compact",disabled:b,children:"Save"})]}):null]})]}),F&&h.mode==="ready"?t.jsx(Qe,{entityType:l,title:e.title,activeTaskCount:e.archiveActiveTaskCount,activeWorkstreamCount:e.archiveActiveWorkstreamCount,busy:N,onCancel:()=>x(!1),onConfirm:()=>{r()}}):null,C,R&&$?t.jsx(Z,{entityType:l,mode:"edit",formId:u,showActions:!1,onSavingChange:D,initialTitle:e.title,initialDescription:e.description||"",onCancel:()=>c(!1),onSave:async d=>{await $(d),c(!1)}},`${l}:${e.id}`):t.jsxs(t.Fragment,{children:[t.jsx("h3",{className:"tf-heading-card",children:e.title}),t.jsx(Je,{description:e.description,label:g,taskReferences:I,className:`${n.selectedEntityDescription} tf-scrollbar`.trim(),markdownClassName:n.selectedEntityDescriptionMarkdown})]}),t.jsxs("div",{className:n.selectedEntityOwnerField,children:[t.jsx("span",{children:"Owner"}),t.jsx(le,{value:W,options:j,onChange:d=>{J(d)},disabled:!m||!!e.isArchived||L,ariaLabel:`${g} owner`,className:`${Ee.control} ${n.selectedEntityOwnerDropdown}`})]}),t.jsx("div",{className:n.selectedEntityDetailsSection,children:t.jsx(Xe,{entityType:l,entityId:e.id,referenceLabel:l==="initiative"?q(e):U(e),workspaceId:f,attachments:e.attachments,readOnly:!!e.isArchived,defaultExpanded:!1,onAddAttachment:!e.isArchived&&T?d=>T(l,e.id,d):void 0,onRemoveAttachment:!e.isArchived&&w?d=>w(l,e.id,d):void 0,onUpdateAttachmentCaption:!e.isArchived&&H?(d,s)=>H(l,e.id,d,s):void 0})}),t.jsx("div",{className:n.selectedEntityDetailsSection,children:t.jsx(Ye,{entityType:l,item:e,assigneeOptions:j,currentActorId:S,taskReferences:I,defaultExpanded:!1,listClassName:n.activityTimelineList,emptyClassName:n.activityTimelineEmpty,hydrationState:_,onRetryHydration:A})})]})}function pi({model:e}){const[l,j]=a.useState(null),[m,p]=a.useState(null),[f,S]=a.useState("portfolio"),[I,_]=a.useState(""),[A,T]=a.useState("all"),[w,H]=a.useState("default"),[$,P]=a.useState(!1),[y,G]=a.useState(!1),B=e.taskArrangeMode||"execution",[C,g]=a.useState(null),[M,W]=a.useState(!1),[k,L]=a.useState(null),[E,R]=a.useState(null),[c,b]=a.useState(!1),D=a.useRef(null),F=a.useRef(null),x=a.useRef(null),N=a.useRef(null),O=a.useRef(null),u=a.useMemo(()=>new Map(e.assigneeOptions.filter(i=>!String(i.archivedAt||"").trim()).map(i=>[String(i.value),i])),[e.assigneeOptions]),h=a.useMemo(()=>{const i=String(e.currentOwnerId||"").trim(),o=i?Pe(e.assigneeOptions,i).find(v=>v.value===i):void 0;return[{value:"all",label:"All owners",icon:"Users",color:"var(--text-secondary)",kind:"unassigned"},...i?[{...o,value:"mine",label:"Owned by me",icon:o?.icon||"User",color:o?.color||"var(--text-secondary)",kind:o?.kind||"member"}]:[],{value:"unassigned",label:"Unassigned",icon:De,color:We,kind:"unassigned"}]},[e.assigneeOptions,e.currentOwnerId]),z=a.useMemo(()=>Fe({initiatives:e.initiatives,standaloneWorkstreams:e.standaloneWorkstreams,showArchivedPlanning:y,searchQuery:I,ownerFilter:A,currentOwnerId:String(e.currentOwnerId||""),sort:w}),[e.currentOwnerId,e.initiatives,e.standaloneWorkstreams,A,I,y,w]),J=a.useMemo(()=>z.initiatives.map(({initiative:i})=>i),[z.initiatives]),Q=z.standaloneWorkstreams,r=a.useMemo(()=>e.initiatives.find(i=>i.id===l)??null,[e.initiatives,l]),d=a.useMemo(()=>[...e.initiatives.flatMap(i=>i.allWorkstreams??i.workstreams),...e.standaloneWorkstreams],[e.initiatives,e.standaloneWorkstreams]),s=a.useMemo(()=>d.find(i=>i.id===m)??null,[d,m]),ee=r?(r.allWorkstreams??r.workstreams).filter(i=>y||!i.isArchived):s&&!s.initiativeId?[s]:[],te=a.useMemo(()=>ke((s?.tasks??[]).filter(i=>y||!i.isArchived),B),[s?.tasks,y,B]),de=a.useMemo(()=>new Set((r?.allWorkstreams??r?.workstreams??[]).map(i=>i.id)),[r]),ue=a.useMemo(()=>new Set((s?.tasks??[]).map(i=>i.id)),[s]),Ie=a.useMemo(()=>e.linkOptions.workstreams.filter(i=>!de.has(i.id)),[de,e.linkOptions.workstreams]),Ne=a.useMemo(()=>e.linkOptions.tasks.filter(i=>!ue.has(i.id)),[ue,e.linkOptions.tasks]),V=s?"workstream":r?"initiative":null,K=s?.id||r?.id||null,he=V&&K?e.hydrationStateByEntity?.[`${V}:${K}`]:void 0,ve=a.useMemo(()=>e.initiatives.some(o=>o.isArchived)?!0:[...e.initiatives.flatMap(o=>o.allWorkstreams??o.workstreams),...e.standaloneWorkstreams].some(o=>o.isArchived||(o.tasks??[]).some(v=>v.isArchived)),[e.initiatives,e.standaloneWorkstreams]);a.useEffect(()=>{const i=O.current;if(i){if(i.entityType==="initiative"){if(!e.initiatives.some(o=>o.id===i.entityId))return;O.current=null,j(i.entityId),p(null),N.current="workstreams",S("workstreams");return}d.some(o=>o.id===i.entityId)&&(O.current=null,j(i.initiativeId||null),p(i.entityId),N.current="tasks",S("tasks"))}},[d,e.initiatives]),a.useEffect(()=>{l&&!r&&(j(null),p(null),S("portfolio"))},[r,l]),a.useEffect(()=>{m&&!s&&(p(null),S(r?"workstreams":"portfolio"))},[r,s,m]),a.useEffect(()=>{!e.hydrateEntity||!V||!K||e.hydrateEntity(V,K)},[e.hydrateEntity,K,V]),a.useEffect(()=>{W(!1),L(null),R(null),b(!1)},[K,V]),a.useLayoutEffect(()=>{if(N.current!==f)return;(f==="portfolio"?D.current:f==="workstreams"?F.current:x.current)?.focus({preventScroll:!0}),N.current=null},[f]);const X=i=>{if(i===f){(i==="portfolio"?D.current:i==="workstreams"?F.current:x.current)?.focus({preventScroll:!0});return}N.current=i,S(i)},Ae=i=>{j(i),p(null),X("workstreams")},pe=i=>{i.initiativeId||j(null),p(i.id),X("tasks")},Re=()=>{X(r?"workstreams":"portfolio")},Oe=z.hasCriteria||w!=="default",ze=()=>{_(""),T("all"),H("default")},ie=async i=>{if(!C||!e.createEntity)return;const o=await e.createEntity(C.entityType,i);O.current={entityType:C.entityType,entityId:o.id,initiativeId:C.initiativeId},g(null)},fe=async(i,o)=>{if(c)return;const v=i==="workstream"?e.attachWorkstreamToInitiative:e.attachTaskToWorkstream,ge=i==="workstream"?r?.id:s?.id;if(!(!v||!ge)){b(!0);try{await v(ge,o.referenceLabel)}finally{b(!1)}}},Te=async i=>{if(!(!s||!e.assignWorkstreamToInitiative||c)){b(!0);try{await e.assignWorkstreamToInitiative(s.id,i.referenceLabel)!==!1&&(j(i.id),W(!1))}finally{b(!1)}}},Le=async()=>{if(!(!k||c)){b(!0);try{if(k.entityType==="workstream"){if(!e.assignWorkstreamToInitiative)return;const i=r?q(r):null;if(await e.assignWorkstreamToInitiative(k.id,null)===!1)return;R({pane:k.id===s?.id?"tasks":"workstreams",message:`${k.referenceLabel} removed from its initiative.`,onUndo:async()=>{if(!i)return;await e.assignWorkstreamToInitiative?.(k.id,i)!==!1&&R(null)}})}else{if(!e.assignTaskToWorkstream||!s)return;const i=s.id;if(await e.assignTaskToWorkstream(k.id,null)===!1)return;R({pane:"tasks",message:`${k.referenceLabel} removed from this workstream.`,onUndo:async()=>{await e.assignTaskToWorkstream?.(k.id,i)!==!1&&R(null)}})}L(null)}finally{b(!1)}}},$e=async()=>{if(!(!E||c)){b(!0);try{await E.onUndo()}finally{b(!1)}}},ye=E?t.jsxs("div",{className:n.relationshipRecovery,role:"status",children:[t.jsx("span",{children:E.message}),t.jsx("button",{type:"button",className:"tf-button-ghost tf-button-compact",disabled:c,onClick:()=>{$e()},children:c?"Restoring…":"Undo"})]}):null;return e.loadState.status==="loading"&&e.initiatives.length===0&&e.standaloneWorkstreams.length===0?t.jsxs("main",{className:n.centerState,"aria-busy":"true","aria-label":"Loading planning workspace",children:[t.jsx(re,{size:22,className:n.spinner}),t.jsx("span",{children:"Loading planning…"})]}):e.loadState.status==="error"&&e.initiatives.length===0&&e.standaloneWorkstreams.length===0?t.jsxs("main",{className:n.centerState,role:"alert",children:[t.jsx(we,{size:22}),t.jsx("strong",{children:"Planning could not be loaded."}),t.jsx("span",{children:e.loadState.error}),t.jsxs("button",{type:"button",className:"tf-button-secondary tf-button-compact",onClick:e.retry,disabled:e.loadState.isRefreshing,children:[e.loadState.isRefreshing?t.jsx(re,{size:15,className:n.spinner}):t.jsx(oe,{size:15}),"Retry"]})]}):t.jsxs("main",{className:n.module,"aria-label":"Planning workspace","aria-busy":e.loadState.isRefreshing,children:[e.loadState.isRefreshing?t.jsx("span",{className:n.visuallyHidden,role:"status","aria-live":"polite",children:"Refreshing planning"}):null,(e.loadState.status==="partial"||e.loadState.status==="error")&&t.jsxs("div",{className:n.inlineError,role:"alert",children:[t.jsx(we,{size:16}),t.jsx("span",{children:e.loadState.error||"Some planning information could not be loaded."}),t.jsx("button",{type:"button",className:"tf-button-secondary tf-button-compact",onClick:e.retry,children:"Retry"})]}),t.jsxs("div",{className:n.columns,"data-active-pane":f,children:[t.jsxs("section",{className:`${n.column} ${n.columnPortfolio} ${f==="portfolio"?n.columnActive:""}`.trim(),"aria-labelledby":"planning-portfolio-heading",children:[t.jsxs("div",{className:n.columnHeader,children:[t.jsx("h2",{ref:D,id:"planning-portfolio-heading",className:`tf-heading-section ${n.paneHeading}`,tabIndex:-1,children:"Portfolio"}),t.jsxs("div",{className:n.headerActions,children:[t.jsx("span",{children:J.length+Q.length}),t.jsx("button",{type:"button",className:`tf-control-icon ${y?n.controlActive:""}`.trim(),onClick:()=>G(i=>!i),disabled:!ve,"aria-label":y?"Hide archived planning items":"Show archived planning items","aria-pressed":y,title:ve?y?"Hide archived planning items":"Show archived planning items":"No archived planning items",children:y?t.jsx(Ze,{size:15,"aria-hidden":"true"}):t.jsx(et,{size:15,"aria-hidden":"true"})})]})]}),t.jsxs("div",{className:n.portfolioControls,children:[t.jsxs("div",{className:n.searchRow,children:[t.jsxs("div",{className:n.searchShell,children:[t.jsx(tt,{size:14,"aria-hidden":"true"}),t.jsx("input",{type:"search",value:I,onChange:i=>_(i.target.value),placeholder:"Search initiatives and workstreams","aria-label":"Search planning"}),I?t.jsx("button",{type:"button",className:n.clearSearch,onClick:()=>_(""),"aria-label":"Clear planning search",title:"Clear search",children:t.jsx(xe,{size:13,"aria-hidden":"true"})}):null]}),t.jsx("button",{type:"button",className:`tf-control-icon ${$||A!=="all"||w!=="default"?n.controlActive:""}`.trim(),"aria-label":"Filter and sort planning",title:"Filter and sort planning","aria-expanded":$,"aria-controls":"planning-workspace-navigator-options",onClick:()=>P(i=>!i),children:t.jsx(it,{size:15,"aria-hidden":"true"})})]}),$?t.jsxs("div",{id:"planning-workspace-navigator-options",className:n.filterPanel,children:[t.jsxs("div",{className:n.filterField,children:[t.jsx("span",{className:n.filterLabel,children:"Owner"}),t.jsx(le,{value:A,options:e.assigneeOptions,leadingOptions:h,includeUnassigned:!1,onChange:T,disabled:!1,ariaLabel:"Filter planning by owner",className:n.filterDropdown})]}),t.jsxs("div",{className:n.filterField,children:[t.jsx("span",{className:n.filterLabel,children:"Sort"}),t.jsx(He,{value:w,options:me,onChange:i=>H(String(i)),ariaLabel:"Sort planning",className:n.filterDropdown,portalPanel:!0,panelAlign:"start",triggerContent:t.jsxs("span",{className:n.sortTrigger,children:[t.jsx(nt,{size:14,"aria-hidden":"true"}),t.jsx("span",{children:me.find(i=>i.value===w)?.label})]}),renderOptionContent:i=>i.label})]}),t.jsx("button",{type:"button",className:"tf-control-icon",onClick:ze,disabled:!Oe,"aria-label":"Reset planning filters and sort",title:"Reset planning filters and sort",children:t.jsx(oe,{size:14,"aria-hidden":"true"})})]}):null]}),t.jsxs("div",{className:n.scrollRegion,children:[t.jsxs("div",{className:n.sectionHeadingRow,children:[t.jsx("h3",{className:`tf-heading-section ${n.sectionLabel}`,children:"Initiatives"}),e.createEntity?t.jsx("button",{type:"button",className:"tf-control-icon",onClick:()=>g({entityType:"initiative"}),"aria-label":"Create initiative",title:"Create initiative",children:t.jsx(ae,{size:15,"aria-hidden":"true"})}):null]}),C?.entityType==="initiative"?t.jsx(Z,{entityType:"initiative",mode:"create",ownerOptions:e.assigneeOptions,onCancel:()=>g(null),onSave:ie}):null,z.initiatives.map(({initiative:i,workstreams:o})=>t.jsx(oi,{initiative:i,workstreamCount:o.length,ownerOption:i.ownerId?u.get(i.ownerId):void 0,ownerOptions:e.assigneeOptions,selected:l===i.id,onSelect:()=>Ae(i.id),onChangeOwner:e.changeOwner?v=>e.changeOwner?.("initiative",i.id,v==="unassigned"?"":v):void 0,onChangeIdentity:e.changeIdentity?v=>e.changeIdentity?.("initiative",i.id,v):void 0},i.id)),t.jsxs("div",{className:n.sectionHeadingRow,children:[t.jsx("h3",{className:`tf-heading-section ${n.sectionLabel}`,children:"Standalone workstreams"}),e.createEntity?t.jsx("button",{type:"button",className:"tf-control-icon",onClick:()=>g({entityType:"workstream",initiativeId:null}),"aria-label":"Create standalone workstream",title:"Create standalone workstream",children:t.jsx(ae,{size:15,"aria-hidden":"true"})}):null]}),C?.entityType==="workstream"&&!C.initiativeId?t.jsx(Z,{entityType:"workstream",mode:"create",ownerOptions:e.assigneeOptions,fixedInitiativeId:null,onCancel:()=>g(null),onSave:ie}):null,Q.map(i=>t.jsx(je,{workstream:i,ownerOption:i.ownerId?u.get(i.ownerId):void 0,ownerOptions:e.assigneeOptions,selected:m===i.id,onSelect:()=>pe(i),onChangeOwner:e.changeOwner?o=>e.changeOwner?.("workstream",i.id,o==="unassigned"?"":o):void 0,onChangeIdentity:e.changeIdentity?o=>e.changeIdentity?.("workstream",i.id,o):void 0},i.id)),J.length===0&&Q.length===0&&t.jsx("p",{className:`tf-text-helper ${n.empty}`,children:z.hasCriteria?"No planning matches.":"No planning items yet."})]})]}),t.jsxs("section",{className:`${n.column} ${n.columnWorkstreams} ${f==="workstreams"?n.columnActive:""}`.trim(),"aria-labelledby":"planning-workstreams-heading",children:[t.jsxs("div",{className:n.columnHeader,children:[t.jsxs("div",{className:n.columnHeadingGroup,children:[t.jsx("button",{type:"button",className:`tf-control-icon ${n.responsiveBack}`.trim(),onClick:()=>X("portfolio"),"aria-label":"Back to Portfolio",title:"Back to Portfolio",children:t.jsx(be,{size:15,"aria-hidden":"true"})}),t.jsxs("h2",{ref:F,id:"planning-workstreams-heading",className:`tf-heading-section ${n.paneHeading}`,tabIndex:-1,children:["Workstreams (",ee.length,")"]})]}),t.jsx("div",{className:n.headerActions,children:r&&e.createEntity?t.jsx("button",{type:"button",className:"tf-control-icon",onClick:()=>g({entityType:"workstream",initiativeId:r.id}),"aria-label":`Create workstream in ${r.title}`,title:"Create workstream",children:t.jsx(ae,{size:15,"aria-hidden":"true"})}):null})]}),t.jsxs("div",{className:n.scrollRegion,children:[r?t.jsxs(t.Fragment,{children:[t.jsx(_e,{item:r,entityType:"initiative",ownerOptions:e.assigneeOptions,onChangeOwner:e.changeOwner?i=>e.changeOwner?.("initiative",r.id,i):void 0,onChangeIdentity:e.changeIdentity,workspaceId:e.currentWorkspaceId,currentActorId:e.currentOwnerId,taskReferences:e.taskReferences,hydrationState:s?void 0:he,onRetryHydration:e.hydrateEntity?()=>{e.hydrateEntity?.("initiative",r.id)}:void 0,onAddContextFile:e.addContextFile,onRemoveContextFile:e.removeContextFile,onUpdateContextCaption:e.updateContextCaption,onUpdate:e.updateEntity?i=>e.updateEntity("initiative",r.id,i):void 0,onArchive:e.archiveEntity?()=>e.archiveEntity("initiative",r.id):void 0,onUnarchive:e.unarchiveEntity?()=>e.unarchiveEntity("initiative",r.id):void 0}),t.jsx(ne,{options:Ie,entityLabel:"workstream",onSelect:i=>fe("workstream",i),disabled:!e.attachWorkstreamToInitiative||c})]}):null,C?.entityType==="workstream"&&C.initiativeId===r?.id?t.jsx(Z,{entityType:"workstream",mode:"create",ownerOptions:e.assigneeOptions,fixedInitiativeId:r.id,onCancel:()=>g(null),onSave:ie}):null,ee.map(i=>t.jsx(je,{workstream:i,ownerOption:i.ownerId?u.get(i.ownerId):void 0,ownerOptions:e.assigneeOptions,selected:m===i.id,onSelect:()=>pe(i),onChangeOwner:e.changeOwner?o=>e.changeOwner?.("workstream",i.id,o==="unassigned"?"":o):void 0,onChangeIdentity:e.changeIdentity?o=>e.changeIdentity?.("workstream",i.id,o):void 0,referenceAction:r?t.jsx(Y,{disabled:!e.assignWorkstreamToInitiative||c,onClick:()=>L({entityType:"workstream",id:i.id,referenceLabel:U(i),title:i.title,parentLabel:r?`${q(r)} ${r.title}`.trim():"its initiative"}),title:`Unlink ${U(i)||i.title} from initiative`,ariaLabel:`Unlink ${U(i)||i.title} from initiative`,children:t.jsx(se,{size:14,"aria-hidden":"true"})}):void 0},i.id)),r&&E?.pane==="workstreams"?ye:null,ee.length===0&&t.jsx("p",{className:`tf-text-helper ${n.empty}`,children:"Select an initiative or standalone workstream."})]})]}),t.jsxs("section",{className:`${n.column} ${n.columnTasks} ${f==="tasks"?n.columnActive:""}`.trim(),"aria-labelledby":"planning-tasks-heading",children:[t.jsx("div",{className:n.columnHeader,children:t.jsxs("div",{className:n.columnHeadingGroup,children:[t.jsx("button",{type:"button",className:`tf-control-icon ${n.responsiveBack}`.trim(),onClick:Re,"aria-label":r?"Back to Workstreams":"Back to Portfolio",title:r?"Back to Workstreams":"Back to Portfolio",children:t.jsx(be,{size:15,"aria-hidden":"true"})}),t.jsxs("h2",{ref:x,id:"planning-tasks-heading",className:`tf-heading-section ${n.paneHeading}`,tabIndex:-1,children:["Tasks (",te.length,")"]})]})}),t.jsxs("div",{className:n.scrollRegion,children:[s?t.jsxs(t.Fragment,{children:[t.jsx(_e,{item:s,entityType:"workstream",ownerOptions:e.assigneeOptions,onChangeOwner:e.changeOwner?i=>e.changeOwner?.("workstream",s.id,i):void 0,workspaceId:e.currentWorkspaceId,currentActorId:e.currentOwnerId,taskReferences:e.taskReferences,hydrationState:he,onRetryHydration:e.hydrateEntity?()=>{e.hydrateEntity?.("workstream",s.id)}:void 0,onAddContextFile:e.addContextFile,onRemoveContextFile:e.removeContextFile,onUpdateContextCaption:e.updateContextCaption,onUpdate:e.updateEntity?i=>e.updateEntity("workstream",s.id,i):void 0,onArchive:e.archiveEntity?()=>e.archiveEntity("workstream",s.id):void 0,onUnarchive:e.unarchiveEntity?()=>e.unarchiveEntity("workstream",s.id):void 0,referenceAction:s.initiativeId?t.jsx(Y,{disabled:!e.assignWorkstreamToInitiative||c,onClick:()=>{L({entityType:"workstream",id:s.id,referenceLabel:U(s),title:s.title,parentLabel:r?`${q(r)} ${r.title}`.trim():"its initiative"})},title:"Unlink workstream from initiative",ariaLabel:"Unlink workstream from initiative",children:t.jsx(se,{size:14,"aria-hidden":"true"})}):t.jsx(Y,{disabled:!e.assignWorkstreamToInitiative||c,onClick:()=>W(i=>!i),title:"Link initiative",ariaLabel:"Link initiative",ariaExpanded:M,children:t.jsx(at,{size:14,"aria-hidden":"true"})}),relationshipContent:t.jsx(t.Fragment,{children:!s.initiativeId&&M?t.jsxs("div",{className:n.relationshipPickerRow,children:[t.jsx(ne,{options:e.linkOptions.initiatives,entityLabel:"initiative",onSelect:Te,disabled:c}),t.jsx("button",{type:"button",className:"tf-control-icon tf-control-icon-compact",disabled:c,onClick:()=>W(!1),title:"Cancel initiative link","aria-label":"Cancel initiative link",children:t.jsx(xe,{size:14,"aria-hidden":"true"})})]}):null})}),t.jsx(ne,{options:Ne,entityLabel:"task",onSelect:i=>fe("task",i),disabled:!e.attachTaskToWorkstream||c}),e.setTaskArrangeMode?t.jsx(Be,{value:B,onChange:e.setTaskArrangeMode}):null]}):null,t.jsx(Me,{tasks:te,mode:B,onReorder:s&&e.reorderWorkstreamTasks?i=>e.reorderWorkstreamTasks?.(s.id,Ve(ke(s.tasks??[],"execution"),i)):void 0,children:i=>{const o=Ue(i);return t.jsx(Ge,{task:i,assigneeOption:i.assignee?u.get(i.assignee):void 0,assigneeOptions:e.assigneeOptions,showStatusLabel:e.showTaskCardStatusLabel,onOpen:()=>e.openTask(i.id),onAssigneeChange:e.setTaskAssignee?v=>e.setTaskAssignee?.(i.id,v):void 0,onStatusChange:e.setTaskStatus?v=>e.setTaskStatus?.(i.id,v):void 0,referenceInteractive:!1,referenceAction:t.jsx(Y,{disabled:!e.assignTaskToWorkstream||c,onClick:v=>{v.stopPropagation(),L({entityType:"task",id:i.id,referenceLabel:o||i.id,title:i.title,parentLabel:s?`${U(s)} ${s.title}`.trim():"its workstream"})},title:`Unlink ${o||i.title} from workstream`,ariaLabel:`Unlink ${o||i.title} from workstream`,children:t.jsx(se,{size:14,"aria-hidden":"true"})})},i.id)}}),s&&E?.pane==="tasks"?ye:null,!s&&t.jsx("p",{className:`tf-text-helper ${n.empty}`,children:"Select a workstream."}),s&&te.length===0&&t.jsx("p",{className:`tf-text-helper ${n.empty}`,children:"No tasks are linked to this workstream."})]})]})]}),t.jsx(Ke,{item:k,busy:c,theme:e.theme,onCancel:()=>L(null),onConfirm:()=>{Le()}})]})}export{pi as PlanningModule};
@@ -1 +0,0 @@
1
- import{r as s,j as e}from"./vendor-react-CKJs5o3c.js";import{aM as ye,t as Oe,aN as Ve,aO as ke,aP as ge,aQ as he,aR as Ke,aS as He}from"./index-BUplSsv_.js";import{bn as qe,w as ze,K as Ye}from"./vendor-icons-BkFLXavV.js";import{u as We,a as Ge}from"./vendor-router-AqJMU8Lz.js";import"./vendor-markdown-_lhNCyq-.js";import"./vendor-dnd-CJ-AjP-Y.js";const Qe="_plansWrapper_ojftl_1",Je="_contentFrame_ojftl_24",Xe="_shellOwnsScroll_ojftl_32",Ze="_withChrome_ojftl_38",et="_siteVariant_ojftl_42",tt="_title_ojftl_56",nt="_subtitle_ojftl_71",rt="_header_ojftl_78",at="_planCard_ojftl_93",it="_grid_ojftl_106",st="_pricingNotes_ojftl_114",ot="_planName_ojftl_123",ct="_featureText_ojftl_130",lt="_currentBadge_ojftl_134",ut="_navAction_ojftl_138",dt="_backBtn_ojftl_139",mt="_priceRows_ojftl_150",pt="_foundingBeta_ojftl_154",ft="_cloudCapacityNote_ojftl_176",gt="_headerBar_ojftl_258",ht="_headerActions_ojftl_267",yt="_debugMeta_ojftl_318",_t="_planNoticeCard_ojftl_381",Ct="_planDescription_ojftl_392",bt="_teamComingSoonCard_ojftl_397",St="_clickablePlanCard_ojftl_416",jt="_activePlanCard_ojftl_431",wt="_callToAction_ojftl_495",vt="_primaryCta_ojftl_507",xt="_secondaryCta_ojftl_518",Nt="_currentCta_ojftl_530",kt="_featuresList_ojftl_544",Pt="_priceRow_ojftl_150",It="_regularPriceLine_ojftl_568",At="_campaignPriceLine_ojftl_569",Tt="_priceRowWithCampaign_ojftl_576",Rt="_priceRowAmount_ojftl_580",Lt="_regularPriceDiscounted_ojftl_586",Et="_priceRowInterval_ojftl_592",Bt="_campaignPriceLabel_ojftl_601",$t="_campaignPriceAmount_ojftl_606",Mt="_campaignPriceInterval_ojftl_612",Ut="_ctaRow_ojftl_617",Dt="_featureItem_ojftl_623",Ft="_featureIcon_ojftl_629",Ot="_featureLimitAccent_ojftl_643",Vt="_featureLimitUnit_ojftl_654",Kt="_featureTextBlock_ojftl_660",Ht="_featureDescription_ojftl_666",qt="_emptyState_ojftl_672",zt="_marketingEmptyState_ojftl_681",Yt="_emptyBadge_ojftl_715",Wt="_emptyHighlights_ojftl_730",Gt="_loader_ojftl_752",Qt="_spinner_ojftl_762",Jt="_statusBanner_ojftl_815",Xt="_successBanner_ojftl_823",Zt="_infoBanner_ojftl_829",en="_errorBanner_ojftl_835",r={plansWrapper:Qe,contentFrame:Je,shellOwnsScroll:Xe,withChrome:Ze,siteVariant:et,title:tt,subtitle:nt,header:rt,planCard:at,grid:it,pricingNotes:st,planName:ot,featureText:ct,currentBadge:lt,navAction:ut,backBtn:dt,priceRows:mt,foundingBeta:pt,cloudCapacityNote:ft,headerBar:gt,headerActions:ht,debugMeta:yt,planNoticeCard:_t,planDescription:Ct,teamComingSoonCard:bt,clickablePlanCard:St,activePlanCard:jt,callToAction:wt,primaryCta:vt,secondaryCta:xt,currentCta:Nt,featuresList:kt,priceRow:Pt,regularPriceLine:It,campaignPriceLine:At,priceRowWithCampaign:Tt,priceRowAmount:Rt,regularPriceDiscounted:Lt,priceRowInterval:Et,campaignPriceLabel:Bt,campaignPriceAmount:$t,campaignPriceInterval:Mt,ctaRow:Ut,featureItem:Dt,featureIcon:Ft,featureLimitAccent:Ot,featureLimitUnit:Vt,featureTextBlock:Kt,featureDescription:Ht,emptyState:qt,marketingEmptyState:zt,emptyBadge:Yt,emptyHighlights:Wt,loader:Gt,spinner:Qt,statusBanner:Jt,successBanner:Xt,infoBanner:Zt,errorBanner:en};function tn(){const t=globalThis.__DEBUG_MODE__;return typeof t=="boolean"?t:!1}function nn(t){const a=String(t?.environment||"").trim(),c=String(t?.runtimeMode||"").trim();return!a&&!c?null:a&&c?`${a} (${c})`:a||c||null}const rn=new Set(["a","b","br","em","i","li","ol","p","strong","u","ul"]);function an(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function sn(t){const a=String(t||"").trim();if(!a)return"";if(typeof document>"u")return an(a);const c=document.createElement("template");c.innerHTML=a;const p=document.createElement("div"),l=C=>{if(C.nodeType===Node.TEXT_NODE)return document.createTextNode(C.textContent||"");if(C.nodeType!==Node.ELEMENT_NODE)return null;const E=C,P=E.tagName.toLowerCase();if(P==="script"||P==="style")return null;const $=Array.from(E.childNodes).map(l).filter(h=>!!h);if(!rn.has(P)){const h=document.createDocumentFragment();for(const W of $)h.appendChild(W);return h}const v=document.createElement(P);if(P==="a"){const h=String(E.getAttribute("href")||"").trim();/^(https?:|mailto:|\/|#)/i.test(h)&&(v.setAttribute("href",h),v.setAttribute("rel","noopener noreferrer"))}for(const h of $)v.appendChild(h);return v};for(const C of Array.from(c.content.childNodes)){const E=l(C);E&&p.appendChild(E)}return p.innerHTML}function on(t,a){if(t==null||!a)return"Contact Sales";try{return new Intl.NumberFormat("en-US",{style:"currency",currency:a.toUpperCase(),minimumFractionDigits:0}).format(t/100)}catch{return`${a.toUpperCase()} ${t/100}`}}function cn(){return"$0"}function V(t){return t?t.pricingType==="free"?!0:t.unitAmount!=null&&t.currency!=null:!1}function Te(t){return t?t.pricingType==="free"?cn():on(t.unitAmount,t.currency):"Unavailable"}function Re(t,a){return V(a)?{price:a,pricingAudience:"campaign"}:{price:t,pricingAudience:"public"}}function ln(t,a,c,p){const l=V(t)||V(c),C=V(a)||V(p);if(!l&&!C)return null;const E=(P,$,v)=>{if(!V(P)&&!V($))return null;const h=V($),W=v==="year"?"year":"month";return e.jsxs("div",{className:`${r.priceRow} ${h?r.priceRowWithCampaign:""}`,children:[V(P)?e.jsxs("div",{className:r.regularPriceLine,children:[e.jsx("span",{className:`${r.priceRowAmount} ${h?r.regularPriceDiscounted:""}`,children:Te(P)}),e.jsxs("span",{className:r.priceRowInterval,children:["/ ",W]})]}):null,h?e.jsxs("div",{className:r.campaignPriceLine,children:[e.jsx("span",{className:r.campaignPriceLabel,children:"Founding Offer:"}),e.jsx("span",{className:r.campaignPriceAmount,children:Te($)}),e.jsxs("span",{className:r.campaignPriceInterval,children:["/ ",W]})]}):null]},v)};return e.jsxs("div",{className:r.priceRows,children:[E(t,c,"month"),E(a,p,"year")]})}function Le(t){const a=[t.pricing.month,t.pricing.year].filter(Boolean);if(a.some(p=>p.pricingType==="free"))return 0;const c=a.map(p=>p.pricingType==="stripe"&&typeof p.unitAmount=="number"?p.unitAmount:null).filter(p=>p!=null);return c.length>0?Math.min(...c):Number.POSITIVE_INFINITY}function un(t){return String(t||"").replace(/[_\-.]+/g," ").replace(/\b\w/g,a=>a.toUpperCase())}function Pe(t,a){const c=t?.[a],p=Number(c);return Number.isFinite(p)?Math.max(1,Math.floor(p)):null}function we(t,a){return a!==1?t:t.replace(/\b([A-Za-z]+)ies\b$/,"$1y").replace(/\b([A-Za-z]+[^s\s])s\b$/,"$1")}function dn(t){return t<=1e3?{value:String(t),unit:"MB"}:{value:String(Math.round(t/1e3)),unit:"GB"}}function mn(t,a){const c=String(t.publicLabel||t.label||"").trim()||un(t.featureKey),p=t.config&&typeof t.config=="object"?t.config:{};if(t.featureKey==="context.uploads"){const l=Pe(p,"storageLimitMb");if(l!==null){const C=dn(l);return{limitValue:C.value,limitUnit:C.unit,baseLabel:we(c,l)}}}if(t.featureKey==="workspace.workspaces"){const l=Pe(p,"maxWorkspaces");if(l!==null)return{limitValue:String(l),limitUnit:null,baseLabel:we(c,l)}}if(t.featureKey==="collaboration.ai_profiles"){const l=Pe(p,"maxAiProfiles");if(l!==null)return{limitValue:String(l),limitUnit:null,baseLabel:we(c,l)}}if(t.featureKey==="collaboration.team_management"){const l=Number(a);if(Number.isFinite(l)&&l>0){const C=Math.floor(l);return{limitValue:String(C),limitUnit:null,baseLabel:we(c,C)}}}return{limitValue:null,limitUnit:null,baseLabel:c}}function pn({heading:t,subtitle:a,variant:c="app",theme:p="dark",chrome:l,footer:C,isAuthenticated:E,authSessionResolved:P=!0,currentPlanId:$,currentPlanVersionId:v,currentEntitlementState:h,markCurrentPlan:W,canManageCurrentPlan:G=!0,pricingEndpoint:I,statusBanner:H,onBack:A,backLabel:T,backDisabled:M=!1,topActions:se,shellOwnsScroll:_e=!1,showPageBackButton:X=!0,showHeaderBarWithChrome:re=!1,preferPricingPageTitle:Ce=!0,currentPlanCardActionMode:be="manage",fallbackPricingSource:g=null,onSelectPlan:q}){const[Z,Q]=s.useState([]),[oe,F]=s.useState(null),[x,R]=s.useState({pageTitle:null,pageDescription:null}),[ce,z]=s.useState(!0),[le,ue]=s.useState(null),[Se,ee]=s.useState(0);s.useEffect(()=>{let i=!0;return(async()=>{const D=String(I||"/api/taskforce/public/pricing").trim()||"/api/taskforce/public/pricing";i&&(z(!0),ue(null));try{const w=await fetch(D,{method:"GET",credentials:"include"}),u=await w.json().catch(()=>({}));if(w.ok){i&&(Q(Array.isArray(u?.plans)?u.plans:[]),F(u?.pricingSource&&typeof u.pricingSource=="object"?u.pricingSource:null),R({pageTitle:typeof u?.pageTitle=="string"&&u.pageTitle.trim()||null,pageDescription:typeof u?.pageDescription=="string"&&u.pageDescription.trim()||null}));return}throw new Error(String(u?.error||`Failed to load pricing (${w.status})`))}catch(w){if(i){const u=w instanceof Error?w.message:"Failed to load pricing";ue(u||"Failed to load pricing"),F(null),R({pageTitle:null,pageDescription:null})}}finally{i&&z(!1)}})(),()=>{i=!1}},[I,Se]);const J=s.useMemo(()=>[...Z].sort((i,U)=>{const D=Le(i),w=Le(U);if(D!==w)return D-w;const u=i.defaultVersion?.versionNumber||0,O=U.defaultVersion?.versionNumber||0;return u!==O?u-O:String(i.displayName||i.planId).localeCompare(String(U.displayName||U.planId))}),[Z]),de=s.useMemo(()=>nn(oe||g),[g,oe]),ve=String((Ce?x.pageTitle:null)||t).trim()||t,me=String(x.pageDescription||a||"").trim(),j=s.useMemo(()=>sn(me),[me]),te=P,pe=`${r.plansWrapper} ${_e?r.shellOwnsScroll:"tf-scrollbar"} ${c==="site"?r.siteVariant:""} ${l?r.withChrome:""}`.trim(),B=i=>_e?e.jsxs(e.Fragment,{children:[l,i,C]}):e.jsxs("div",{className:Oe.standaloneWrapper,"data-theme":p,children:[l,i,C]});return B(ce?e.jsx(e.Fragment,{children:e.jsx("div",{className:pe,children:e.jsx("div",{className:r.contentFrame,children:e.jsxs("div",{className:r.loader,children:[e.jsx(ze,{size:48,className:r.spinner}),e.jsx("p",{children:"Loading plans..."})]})})})}):le?e.jsx(e.Fragment,{children:e.jsx("div",{className:pe,children:e.jsx("div",{className:r.contentFrame,children:e.jsxs("div",{className:r.emptyState,children:[e.jsx("h2",{children:"Connecting to plan pricing..."}),e.jsx("p",{children:le}),e.jsx("button",{className:r.backBtn,onClick:()=>ee(i=>i+1),children:"Retry"})]})})})}):e.jsx(e.Fragment,{children:e.jsx("div",{className:pe,children:e.jsxs("div",{className:r.contentFrame,children:[e.jsxs("div",{className:r.header,children:[(!l||re)&&(X||se)&&e.jsxs("div",{className:r.headerBar,children:[e.jsx("div",{children:X?e.jsx("button",{className:r.backBtn,onClick:A,disabled:M,children:T}):null}),e.jsx("div",{className:r.headerActions,children:se})]}),e.jsx("h1",{className:r.title,children:ve}),j&&e.jsx("div",{className:r.subtitle,dangerouslySetInnerHTML:{__html:j}}),tn()&&de?e.jsxs("p",{className:r.debugMeta,children:["Pricing source: ",de]}):null,H&&e.jsx("div",{className:`${r.statusBanner} ${H.type==="success"?r.successBanner:H.type==="info"?r.infoBanner:r.errorBanner}`,children:H.message})]}),e.jsxs("section",{className:r.foundingBeta,"aria-labelledby":"founding-beta-heading",children:[e.jsx("h2",{id:"founding-beta-heading",children:"Founding beta"}),e.jsx("p",{children:"Taskforce is in founding beta. You may run into rough edges while we improve cloud workspaces and agent workflows. Early members get access while the product is still forming, plus a direct role in shaping what comes next."})]}),J.length===0?e.jsxs("div",{className:`${r.emptyState} ${r.marketingEmptyState}`,children:[e.jsx("span",{className:r.emptyBadge,children:"Coming Soon"}),e.jsx("h2",{children:"Paid plans are getting their final polish."}),e.jsx("p",{children:"Taskforce pricing is on the way with flexible options for solo operators, teams, and larger rollouts. Check back soon for launch tiers, feature bundles, and early access details."}),e.jsxs("div",{className:r.emptyHighlights,"aria-label":"Upcoming pricing highlights",children:[e.jsx("span",{children:"Launch-ready tiers"}),e.jsx("span",{children:"Team billing controls"}),e.jsx("span",{children:"Feature-based packaging"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:r.grid,children:J.map(i=>{const U=i.pricing.month,D=i.pricing.year,w=i.campaignPricing?.month||null,u=i.campaignPricing?.year||null,O=Re(U,w),K=Re(D,u),Y=V(O.price),ae=V(K.price),ie=Y&&ae,N=String(i.defaultVersion?.planVersionId||"").trim(),xe=ye(h),fe=W??xe,Ne=!!(N&&v&&v===N)||!!(!v&&($&&$===i.planId)),ne=fe&&Ne&&h!=="canceled",n=Y?"month":ae?"year":null,o=n==="year"?K:O,_=be==="manage",f=be==="indicator",y=te&&!!N&&(ne?_&&G:!!n),m=()=>{if(N){if(ne){if(!_||!G)return;q({planId:i.planId,planVersionId:N,interval:n||"month",pricingType:o.price?.pricingType||"stripe",pricingAudience:o.pricingAudience,isCurrentPlan:!0});return}n&&q({planId:i.planId,planVersionId:N,interval:n,pricingType:o.price?.pricingType||"stripe",pricingAudience:o.pricingAudience,isCurrentPlan:!1})}};return e.jsxs("div",{className:`${r.planCard} ${ne?r.activePlanCard:""} ${y?r.clickablePlanCard:""}`,"data-testid":`plan-card-${i.planId}`,role:y?"button":void 0,tabIndex:y?0:void 0,onClick:y?m:void 0,onKeyDown:y?d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),m())}:void 0,children:[ne&&e.jsx("span",{className:r.currentBadge,children:"Current Plan"}),e.jsx("h3",{className:r.planName,children:i.displayName}),ln(U,D,w,u),String(i.description||"").trim()&&e.jsx("p",{className:r.planDescription,children:String(i.description||"").trim()}),e.jsx("div",{className:r.featuresList,children:Array.isArray(i.features)&&i.features.length>0?i.features.map((d,S)=>e.jsxs("div",{className:r.featureItem,children:[e.jsx(qe,{className:r.featureIcon}),e.jsxs("div",{className:r.featureTextBlock,children:[(()=>{const{limitValue:k,limitUnit:b,baseLabel:L}=mn(d,i.defaultVersion?.seatLimit);return e.jsxs("span",{className:r.featureText,children:[k&&e.jsxs("span",{className:r.featureLimitAccent,children:[e.jsx("span",{children:k}),b?e.jsx("span",{className:r.featureLimitUnit,children:b}):null]}),e.jsx("span",{children:k?` ${L}`:L})]})})(),d.publicDescriptionVisible!==!1&&String(d.publicDescription||d.description||"").trim()&&e.jsx("span",{className:r.featureDescription,children:String(d.publicDescription||d.description||"").trim()})]})]},`${d.featureKey}-${S}`)):e.jsx("span",{className:r.featureText,children:"No additional features included"})}),ne?_?e.jsx("button",{className:`${r.callToAction} ${r.currentCta}`,"data-testid":`plan-manage-${i.planId}`,onClick:d=>{d.stopPropagation(),G&&q({planId:i.planId,planVersionId:N,interval:n||"month",pricingType:o.price?.pricingType||"stripe",pricingAudience:o.pricingAudience,isCurrentPlan:!0})},disabled:!N||!G||!te,children:E&&G?"Manage Plan":"Current Plan"}):f?e.jsx("button",{className:`${r.callToAction} ${r.currentCta}`,"data-testid":`plan-current-${i.planId}`,disabled:!0,children:"Current Plan"}):null:e.jsxs("div",{className:r.ctaRow,children:[Y?e.jsx("button",{className:`${r.callToAction} ${r.secondaryCta}`,"data-testid":`plan-select-${i.planId}-month`,onClick:d=>{d.stopPropagation(),q({planId:i.planId,planVersionId:N,interval:"month",pricingType:O.price?.pricingType||"stripe",pricingAudience:O.pricingAudience,isCurrentPlan:!1})},disabled:!N||!te,children:ie?"Start Monthly":"Get Started"}):null,ae?e.jsx("button",{className:`${r.callToAction} ${r.primaryCta}`,"data-testid":`plan-select-${i.planId}-year`,onClick:d=>{d.stopPropagation(),q({planId:i.planId,planVersionId:N,interval:"year",pricingType:K.price?.pricingType||"stripe",pricingAudience:K.pricingAudience,isCurrentPlan:!1})},disabled:!N||!te,children:ie?"Start Yearly":"Get Started"}):null]})]},i.planId)})}),e.jsxs("div",{className:r.pricingNotes,children:[e.jsx("p",{children:"Prices are listed in USD. Taxes may apply."}),e.jsx("p",{children:"Local install is free on every plan. Cloud limits apply only to hosted workspaces."})]}),e.jsxs("section",{className:`${r.foundingBeta} ${r.cloudCapacityNote}`,"aria-labelledby":"cloud-capacity-heading",children:[e.jsx("h2",{id:"cloud-capacity-heading",children:"Need more cloud capacity?"}),e.jsx("p",{children:"Pro users can request expanded limits for cloud workspaces, AI agents, and storage."}),e.jsxs("p",{children:["Contact ",e.jsx("a",{href:"mailto:support@taskforcehq.ai",children:"support@taskforcehq.ai"})," to discuss capacity needs."]})]}),e.jsxs("div",{className:`${r.planCard} ${r.planNoticeCard} ${r.teamComingSoonCard}`,children:[e.jsx("h2",{className:r.planName,children:"Team workspaces are coming soon."}),e.jsx("p",{className:r.planDescription,children:"Shared workspaces, collaborators, team agent rosters, admin controls, and larger cloud limits are in development."})]})]})]})})}))}const fn=1600,Ee=[0,500,1e3,2e3],gn=5e3,hn=45e3,yn="Choose a plan to continue.";function _n(t,a){if(t===401)return!0;const c=String(a||"").trim().toUpperCase();return c==="CHECKOUT_SESSION_INCOMPLETE"||c==="CHECKOUT_PLAN_VERSION_UNRESOLVED"}function Cn(t){return t==="year"?"year":"month"}function bn(t){return t==="campaign"?"campaign":"public"}function Ie(t){const a=String(t||"").trim().toLowerCase();return a==="year"?"year":a==="month"?"month":null}function Be(t){const a=String(t||"").trim();return a?a.replace(/\/+$/,""):""}function Ae(t={}){const a=new URLSearchParams;a.set("screen","plans");for(const[c,p]of Object.entries(t)){const l=String(p||"").trim();l&&a.set(c,l)}return`/?${a.toString()}`}function An({isAuthenticated:t,authUserId:a,runtimeMode:c,authSessionResolved:p,currentTheme:l="dark",projectName:C,currentWorkspaceId:E,apiBaseUrl:P,connectedEnvironmentSource:$,resolveCloudAuthUrl:v,embedded:h=!1,shellOwnsScroll:W=!1,onAccountProfileSummaryChange:G,onContinueToTaskforce:I,continueBusy:H=!1}){const A=We(),T=Ge(),[M,se]=s.useState(null),[_e,X]=s.useState(!1),[re,Ce]=s.useState(!1),[be,g]=s.useState(null),q=s.useRef(!1),Z=s.useRef(null),Q=s.useRef(null),oe=s.useRef(I),F=s.useMemo(()=>new URLSearchParams(T.search),[T.search]),x=String(F.get("checkout")||"").trim().toLowerCase(),R=String(F.get("gate")||"").trim().toLowerCase(),ce=String(F.get("planId")||"").trim(),z=String(F.get("planVersionId")||"").trim(),le=Cn(F.get("interval")),ue=bn(F.get("pricingAudience")),Se=Ie(F.get("interval")),ee=String(F.get("session_id")||"").trim(),J=s.useMemo(()=>Be(P),[P]),de=s.useMemo(()=>Be($),[$]),ve=s.useMemo(()=>({environment:Ve(de||J),runtimeMode:c==="cloud"?"cloud":"local"}),[J,de,c]),me=s.useCallback(n=>{const o=String(n||"").trim();return J?`${J}${o.startsWith("/")?o:`/${o}`}`:o},[J]),j=s.useCallback(n=>v?v(n):me(n),[me,v]),te=s.useCallback(()=>{const n=new URLSearchParams(T.search);n.delete("screen"),n.delete("gate"),n.delete("checkout"),n.delete("planId"),n.delete("planVersionId"),n.delete("interval"),n.delete("pricingAudience");const o=n.toString();A(`/${o?`?${o}`:""}${T.hash||""}`)},[T.hash,T.search,A]),pe=s.useMemo(()=>j("/api/taskforce/public/pricing"),[j]),B=s.useMemo(()=>ke(M,R),[M,R]),i=s.useMemo(()=>B.allowReturnToApp,[B.allowReturnToApp]),U=s.useMemo(()=>{const n=String(B.message||"").trim();return!n||n===yn?null:n},[B.message]),D=s.useCallback(()=>{const n=new URLSearchParams(T.search);n.delete("checkout"),n.delete("session_id"),n.delete("gate"),n.delete("planId"),n.delete("planVersionId"),n.delete("interval");const o=n.toString();A(`${T.pathname}${o?`?${o}`:""}${T.hash||""}`,{replace:!0})},[T.hash,T.pathname,T.search,A]),w=s.useCallback(()=>{Q.current!=null&&window.clearTimeout(Q.current),Q.current=window.setTimeout(()=>{D(),Q.current=null},fn)},[D]);s.useEffect(()=>{oe.current=I},[I]);const u=s.useCallback(async n=>{const o=j(ge);if(!t)return se(null),he(o,{identityKey:a}),null;try{const _=await Ke(o,{identityKey:a,force:n?.force===!0});return se(_),G?.(_),_}catch{return null}},[a,j,t,G]),O=s.useCallback((n,o,_)=>{const f=String(o||"").trim();if(_?.preferFallback&&f)return f;const y=ke(n,R).message;return y||f||"Unable to confirm checkout completion."},[R]),K=s.useCallback((n,o)=>!ke(n,o).allowReturnToApp,[]),Y=s.useCallback(async(n,o,_="public",f)=>{if(!n){g({type:"error",message:"Selected plan is missing a default plan version."});return}X(!0),g(null);try{const y=await fetch(j("/api/taskforce/billing/checkout-session"),{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({planVersionId:n,interval:o,pricingAudience:_})}),m=await y.json().catch(()=>({}));if(!y.ok){g({type:"error",message:String(m?.error||"Unable to start checkout for selected plan.")});return}const d=String(m?.checkoutState||"").trim().toLowerCase();if(d==="free"){g({type:"success",message:"Plan selected. Your access is ready."}),he(j(ge),{identityKey:a});const b=await u({force:!0}),L=String(b?.entitlementState||"").trim().toLowerCase();f?.autoContinueOnActivation===!0&&ye(L)&&await I?.();return}if(d==="updated"){g({type:"success",message:String(m?.message||"Your subscription was updated successfully.")}),he(j(ge),{identityKey:a});const b=await u({force:!0}),L=String(b?.entitlementState||"").trim().toLowerCase();f?.autoContinueOnActivation===!0&&ye(L)&&await I?.();return}if(d==="already_current_plan"){g({type:"success",message:String(m?.message||"You are already on this plan.")}),he(j(ge),{identityKey:a}),await u();return}const S=String(m?.returnBaseUrl||"").trim();if(c==="local"&&S)try{const b=window.location.origin,L=new URL(S,b).origin;if(L!==b){g({type:"error",message:`Checkout return is misconfigured for this runtime. Expected ${b} but got ${L}.`});return}}catch{g({type:"error",message:"Checkout return URL is invalid for this runtime."});return}const k=String(m?.url||"").trim();if(!k){g({type:"error",message:"Checkout did not return a redirect URL."});return}window.location.assign(k)}catch{g({type:"error",message:"Unable to start checkout for selected plan."})}finally{X(!1)}},[a,j,u,I,c]),ae=s.useCallback(async(n,o)=>{if(!n)return{confirmed:!1,errorMessage:"Checkout session is missing.",retryable:!1};const _=async()=>{he(j(ge),{identityKey:a});const f=await u({force:!0}),y=String(f?.entitlementState||"").trim().toLowerCase();if(!ye(y))return!1;const m=ce,d=z,S=Se,k=String(f?.planId||"").trim(),b=String(f?.planVersionId||"").trim(),L=Ie(f?.billingInterval??null),je=o?.preConfirmationSummary??null,$e=String(je?.entitlementState||"").trim().toLowerCase(),Me=ye($e),Ue=String(je?.planId||"").trim(),De=String(je?.planVersionId||"").trim(),Fe=Ie(je?.billingInterval??null);return m&&k&&k!==m||d&&b&&b!==d||S&&L&&L!==S||Me&&!(!!m&&k===m&&Ue!==k)&&!(!!d&&b===d&&De!==b)&&!(!!S&&L===S&&Fe!==L)?!1:(o?.autoContinueOnActivation===!0&&await oe.current?.(),!0)};try{const f=await fetch(j("/api/taskforce/billing/checkout-session/confirm"),{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:n})}),y=await f.json().catch(()=>({}));if(!f.ok){const m=String(y?.code||"").trim(),d=_n(f.status,m);return d&&await _()?{confirmed:!0}:{confirmed:!1,errorMessage:String(y?.error||"Unable to confirm checkout completion."),retryable:d}}return await _()?{confirmed:!0}:{confirmed:!0}}catch{return{confirmed:!1,errorMessage:"Unable to confirm checkout completion.",retryable:!0}}},[a,j,u,Se,ce,z]),ie=s.useCallback(async()=>{if(!t){A(`/login?mode=login&next=${encodeURIComponent(Ae())}`);return}X(!0),g({type:"info",message:"Opening billing portal..."});try{const n=await fetch(j("/api/taskforce/billing/portal-session"),{method:"POST",credentials:"include"}),o=await n.json().catch(()=>({}));if(!n.ok){g({type:"error",message:String(o?.error||"Failed to open billing portal.")});return}const _=String(o?.url||"").trim();if(!_){g({type:"error",message:"Portal session did not return a redirect URL."});return}window.location.assign(_)}catch{g({type:"error",message:"Failed to open billing portal."})}finally{X(!1)}},[j,t,A]),N=s.useCallback(async()=>{if(!(!I||re||H)){Ce(!0);try{await I()}finally{Ce(!1)}}},[re,H,I]);s.useEffect(()=>{u()},[u]),s.useEffect(()=>{i&&R==="missing_entitlement"&&D()},[D,R,i]),s.useEffect(()=>()=>{Q.current!=null&&window.clearTimeout(Q.current)},[]),s.useEffect(()=>{x!=="success"&&(Z.current=null)},[x]),s.useEffect(()=>{let n=!1;const o=new Set,_=async f=>{f<=0||await new Promise(y=>{const m=window.setTimeout(()=>{o.delete(m),y()},f);o.add(m)})};if(x==="success"){if(q.current=!0,g({type:"success",message:"Checkout completed successfully. Finalizing your plan..."}),!t&&!p)return()=>{n=!0,o.forEach(m=>window.clearTimeout(m)),o.clear()};if(!t)return g({type:"error",message:"Sign in to finish activating your plan."}),()=>{n=!0,o.forEach(m=>window.clearTimeout(m)),o.clear()};const y=ee||"__missing_session__";return Z.current===y?()=>{n=!0,o.forEach(m=>window.clearTimeout(m)),o.clear()}:((async()=>{const m=Date.now(),d=await u({force:!0});if(n)return;let S=ee?{confirmed:!1,errorMessage:"Unable to confirm checkout completion.",retryable:!0}:{confirmed:!1,errorMessage:"Checkout session is missing.",retryable:!1},k=0;for(;;){const b=k<Ee.length?Ee[k]:gn;if(k+=1,await _(b),n||(S=ee?await ae(ee,{autoContinueOnActivation:K(d,R),preConfirmationSummary:d}):{confirmed:!1,errorMessage:"Checkout session is missing.",retryable:!1},n))return;if(S.confirmed){Z.current=y,g({type:"success",message:"Checkout completed successfully."}),w();return}if(!S.retryable||Date.now()-m>=hn)break}if(!n&&!S.confirmed){const b=await u({force:!0});if(n)return;S.retryable||(Z.current=y),g({type:"error",message:O(b,S.errorMessage,{preferFallback:!S.retryable})}),S.retryable||w();return}})(),()=>{n=!0,o.forEach(m=>window.clearTimeout(m)),o.clear()})}if(x==="cancel"){(async()=>{const f=await u({force:!0});g({type:"error",message:O(f,"Checkout was canceled. No charge was made.")}),w()})();return}if((x==="start"||x==="free")&&t&&z&&!q.current){q.current=!0,(async()=>{const f=await u({force:!0});await Y(z,le,ue,{autoContinueOnActivation:K(f,R)})})();return}},[p,x,ae,R,t,u,le,z,ue,ee,O,w,K,Y]),s.useEffect(()=>{if(!(x==="success"||x==="cancel"||x==="start"||x==="free")){if(U){g({type:B.statusTone,message:U});return}g(n=>!n||n.type!=="error"?n:n.message===B.message?null:n)}},[x,U,B.message,B.statusTone]);const xe=s.useCallback(async n=>{if(!t){const _=n.pricingType==="free"?"free":"start",f=Ae({checkout:_,planId:n.planId,planVersionId:n.planVersionId,interval:n.interval,pricingAudience:n.pricingAudience});A(`/login?mode=register&planId=${encodeURIComponent(n.planId)}&planVersionId=${encodeURIComponent(n.planVersionId)}&interval=${encodeURIComponent(n.interval)}&pricingAudience=${encodeURIComponent(n.pricingAudience)}&next=${encodeURIComponent(f)}`);return}if(n.isCurrentPlan){if(!M?.stripeCustomerId){g({type:"success",message:"Your current plan does not use Stripe billing."});return}await ie();return}const o=K(M,R);if(n.pricingType==="free"){await Y(n.planVersionId,n.interval,n.pricingAudience,{autoContinueOnActivation:o});return}await Y(n.planVersionId,n.interval,n.pricingAudience,{autoContinueOnActivation:o})},[M,R,t,A,ie,K,Y]),fe=s.useCallback(()=>{if(i&&I){N();return}if(h){te();return}if(window.history.length>1){A(-1);return}A("/")},[te,h,N,i,A,I]),Ne=h?null:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:r.navAction,onClick:fe,disabled:H||re||t&&!i,children:i?"Take Me to Taskforce":"Back"}),t&&M?.stripeCustomerId&&e.jsx("button",{className:r.navAction,onClick:()=>{ie()},disabled:_e,children:"Manage billing"}),!t&&e.jsxs("button",{className:r.navAction,onClick:()=>A(`/login?mode=login&next=${encodeURIComponent(Ae())}`),children:[e.jsx(Ye,{size:16,style:{marginRight:"8px",verticalAlign:"text-bottom"}}),"Sign In"]})]}),ne=h?null:e.jsx(He,{projectName:C,currentWorkspaceId:E,runtimeMode:c==="cloud"?"cloud":"local",theme:l,onBrandClick:fe,actions:Ne});return e.jsx(pn,{chrome:ne,heading:"Subscription Plans",subtitle:"Manage your subscription and explore available features. Your current plan is highlighted below.",variant:"site",theme:l,isAuthenticated:t,authSessionResolved:p,currentPlanId:String(M?.planId||ce||"").trim()||null,currentPlanVersionId:String(M?.planVersionId||z||"").trim()||null,currentEntitlementState:String(M?.entitlementState||"").trim()||null,markCurrentPlan:B.markCurrentPlan,canManageCurrentPlan:!!M?.stripeCustomerId,pricingEndpoint:pe,statusBanner:be,onBack:fe,backLabel:i?"Take Me to Taskforce":h?"Back to Board":"Back to App",backDisabled:H||re||t&&!i,topActions:null,shellOwnsScroll:W,showPageBackButton:!1,showHeaderBarWithChrome:!1,currentPlanCardActionMode:"manage",fallbackPricingSource:ve,onSelectPlan:xe})}export{An as PlansPage};
@@ -1 +0,0 @@
1
- import{r as p,j as e}from"./vendor-react-CKJs5o3c.js";import{ContextAttachmentManager as _}from"./ContextAttachmentManager-B8boOs6Q.js";import{f as g,aY as x}from"./index-BUplSsv_.js";import{w as f,$ as y,aZ as j}from"./vendor-icons-BkFLXavV.js";import"./vendor-markdown-_lhNCyq-.js";import"./vendor-dnd-CJ-AjP-Y.js";import"./vendor-router-AqJMU8Lz.js";const C="_group_1y2qv_1",I="_list_1y2qv_9",k="_review_1y2qv_15",w="_icon_1y2qv_43",b="_openIcon_1y2qv_43",N="_copy_1y2qv_44",A="_kindLabel_1y2qv_45",L="_title_1y2qv_53",q="_loading_1y2qv_54",a={group:C,list:I,review:k,icon:w,openIcon:b,copy:N,kindLabel:A,title:L,loading:q};function R(o){return String(o.title||"").trim()||o.image?.displayName||"Image review"}function S({taskId:o,taskReferenceLabel:c,workspaceId:l,apiBaseUrl:r}){const[i,d]=p.useState(null);return p.useEffect(()=>{let s=!0;d(null);const t=new URLSearchParams({workspaceId:l,taskId:o});return g(`/api/taskforce/annotated-attachments/sessions?${t.toString()}`,{credentials:"include"},r).then(async n=>n.ok?n.json():{sessions:[]}).then(n=>{s&&d(Array.isArray(n?.sessions)?n.sessions:[])}).catch(()=>{s&&d([])}),()=>{s=!1}},[r,o,l]),i!==null&&i.length===0?null:e.jsx("section",{className:a.group,"aria-label":"Image reviews",children:i===null?e.jsxs("div",{className:a.loading,"aria-live":"polite",children:[e.jsx(f,{size:14})," Loading image reviews"]}):e.jsx("div",{className:a.list,children:i.map(s=>{const t=s.image,n=s.annotations.length,m=!!(t?.assetId&&t.apiUrl);return e.jsxs("button",{type:"button",className:a.review,disabled:!m,onClick:()=>{t&&x({assetId:t.assetId,path:t.apiUrl,displayName:t.displayName,referenceLabel:t.referenceLabel||void 0},{taskId:o,taskReferenceLabel:c,sessionId:s.id})},children:[e.jsx("span",{className:a.icon,children:e.jsx(y,{size:14})}),e.jsxs("span",{className:a.copy,children:[e.jsx("span",{className:a.kindLabel,children:"Image review session"}),e.jsx("span",{className:`${a.title} tf-heading-card`,children:R(s)}),e.jsxs("span",{className:"tf-text-meta",children:[n," ",n===1?"marker":"markers"]})]}),e.jsx(j,{className:a.openIcon,size:14,"aria-hidden":"true"})]},s.id)})})})}function O(o){const{taskId:c,taskReferenceLabel:l,workspaceId:r,apiBaseUrl:i,showImageReviews:d=!1,contextFiles:s,onAddContextFile:t,onRemoveContextFile:n,onUpdateContextCaption:m,cardCoverAssetId:u,onSetCardCover:h,cardCoverDisabled:v}=o;return e.jsx(_,{ownerType:"task",ownerId:c,ownerReferenceLabel:l,workspaceId:r,apiBaseUrl:i,attachments:s,onAddAttachment:t,onRemoveAttachment:n,onUpdateAttachmentCaption:m,cardCoverAssetId:u,onSetCardCover:h,cardCoverDisabled:v,supplementalContent:d&&c&&r?e.jsx(S,{taskId:c,taskReferenceLabel:l,workspaceId:r,apiBaseUrl:i}):null})}export{O as TaskContextUpload};