@taskforcehq/taskforce 0.3.305 → 0.3.306

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 (337) hide show
  1. package/dist/Taskforce.module.css +295 -89
  2. package/dist/TaskforceCore.js +215 -43
  3. package/dist/TaskforceCore.test.js +433 -28
  4. package/dist/assets/fonts/CourierPrime-Bold.woff2 +0 -0
  5. package/dist/assets/fonts/CourierPrime-BoldItalic.woff2 +0 -0
  6. package/dist/assets/fonts/CourierPrime-Italic.woff2 +0 -0
  7. package/dist/assets/fonts/CourierPrime-Regular.woff2 +0 -0
  8. package/dist/assets/fonts/Noir_medium.woff2 +0 -0
  9. package/dist/assets/fonts/Noir_regular.woff2 +0 -0
  10. package/dist/assets/fonts/RussoOne-Regular.woff2 +0 -0
  11. package/dist/assets/fonts/SpecialElite-Regular.woff2 +0 -0
  12. package/dist/compat/workspaceSyncCompat.js +46 -2
  13. package/dist/compat/workspaceSyncCompat.test.js +38 -1
  14. package/dist/components/context/ContextAttachmentManager.d.ts +14 -0
  15. package/dist/components/context/ContextAttachmentManager.js +549 -0
  16. package/dist/components/features/AgentsModule.d.ts +10 -1
  17. package/dist/components/features/AgentsModule.js +260 -15
  18. package/dist/components/features/AgentsModule.test.js +255 -5
  19. package/dist/components/features/DocumentViewer.d.ts +5 -1
  20. package/dist/components/features/DocumentViewer.js +60 -3
  21. package/dist/components/features/DocumentWorkspace.js +1 -1
  22. package/dist/components/features/DocumentWorkspace.test.js +33 -0
  23. package/dist/components/features/documentWorkspaceModel.d.ts +1 -1
  24. package/dist/components/task/TaskCard.js +19 -28
  25. package/dist/components/task/TaskCard.test.js +38 -3
  26. package/dist/components/task/TaskContextUpload.js +4 -526
  27. package/dist/components/task/TaskForm.js +85 -90
  28. package/dist/components/task/TaskForm.test.js +110 -8
  29. package/dist/components/task/TaskKanban.d.ts +2 -1
  30. package/dist/components/task/TaskKanban.js +94 -13
  31. package/dist/components/task/TaskKanban.test.js +36 -0
  32. package/dist/components/ui/EditableAvatarButton.d.ts +18 -0
  33. package/dist/components/ui/EditableAvatarButton.js +18 -0
  34. package/dist/components/views/PlanComparisonPage.d.ts +9 -1
  35. package/dist/components/views/PlanComparisonPage.js +70 -14
  36. package/dist/components/views/PlanComparisonPage.test.js +238 -0
  37. package/dist/components/views/PlansPage.js +127 -36
  38. package/dist/components/views/PlansPage.test.js +294 -12
  39. package/dist/components/views/StandaloneLayout.js +283 -533
  40. package/dist/components/views/panels/PlanningDrawer.d.ts +8 -1
  41. package/dist/components/views/panels/PlanningDrawer.js +18 -11
  42. package/dist/components/views/panels/PlanningDrawer.test.d.ts +1 -0
  43. package/dist/components/views/panels/PlanningDrawer.test.js +141 -0
  44. package/dist/components/views/planningScope.d.ts +20 -0
  45. package/dist/components/views/planningScope.js +25 -0
  46. package/dist/components/views/planningScope.test.d.ts +1 -0
  47. package/dist/components/views/planningScope.test.js +60 -0
  48. package/dist/components/views/standalone/modals/AccountHubModal.d.ts +26 -1
  49. package/dist/components/views/standalone/modals/AccountHubModal.js +76 -2
  50. package/dist/components/views/standalone/modals/AccountHubModal.test.js +20 -3
  51. package/dist/components/views/standalone/modals/AvatarImageManagerModal.d.ts +20 -0
  52. package/dist/components/views/standalone/modals/AvatarImageManagerModal.js +127 -0
  53. package/dist/components/views/standalone/modals/EditProfileModal.d.ts +2 -9
  54. package/dist/components/views/standalone/modals/EditProfileModal.js +3 -2
  55. package/dist/components/views/standalone/modals/SyncEnableWarningModal.d.ts +9 -0
  56. package/dist/components/views/standalone/modals/SyncEnableWarningModal.js +6 -0
  57. package/dist/components/views/standalone/modals/SyncEnableWarningModal.test.d.ts +1 -0
  58. package/dist/components/views/standalone/modals/SyncEnableWarningModal.test.js +24 -0
  59. package/dist/components/views/standalone/modals/SyncStatusModal.d.ts +2 -1
  60. package/dist/components/views/standalone/modals/SyncStatusModal.js +2 -2
  61. package/dist/core/AiProfileService.d.ts +39 -2
  62. package/dist/core/AiProfileService.js +639 -73
  63. package/dist/core/AiProfileService.test.js +19 -1
  64. package/dist/core/AiProfiles.test.js +566 -7
  65. package/dist/core/AttachmentLinkService.js +57 -15
  66. package/dist/core/AuthIdentityService.d.ts +107 -0
  67. package/dist/core/AuthIdentityService.js +284 -0
  68. package/dist/core/AuthTokenService.d.ts +4 -0
  69. package/dist/core/AuthTokenService.js +34 -6
  70. package/dist/core/AuthTokenService.test.js +3 -3
  71. package/dist/core/EntitlementsPolicy.test.js +2 -2
  72. package/dist/core/GlobalSettingsService.js +115 -6
  73. package/dist/core/PlanEntitlementService.d.ts +23 -2
  74. package/dist/core/PlanEntitlementService.js +343 -57
  75. package/dist/core/PlanFeatureCatalog.test.d.ts +1 -0
  76. package/dist/core/PlanFeatureCatalog.test.js +84 -0
  77. package/dist/core/PlanVersionPolicy.test.js +35 -2
  78. package/dist/core/PlanningEntities.test.js +52 -0
  79. package/dist/core/SignupMonetizationSettings.test.js +199 -27
  80. package/dist/core/SyncReconciliationService.js +2 -65
  81. package/dist/core/SystemAdmin.test.js +42 -42
  82. package/dist/core/TaskAttachmentsCanonical.test.js +51 -1
  83. package/dist/core/Taskforce.d.ts +225 -14
  84. package/dist/core/Taskforce.js +765 -192
  85. package/dist/core/Taskforce.listTasksSlim.test.d.ts +1 -0
  86. package/dist/core/Taskforce.listTasksSlim.test.js +91 -0
  87. package/dist/core/UserProfileAvatarDrafts.test.js +30 -3
  88. package/dist/core/WorkspaceLifecycleService.js +0 -5
  89. package/dist/core/WorkspacePermissions.test.js +25 -1
  90. package/dist/core/WorkspacePlanMode.test.js +117 -16
  91. package/dist/core/shared.d.ts +1 -1
  92. package/dist/core/shared.js +5 -1
  93. package/dist/core/types.d.ts +68 -2
  94. package/dist/hooks/auth/useTaskforceAuthBootstrap.js +26 -1
  95. package/dist/hooks/sync/bootstrap.js +2 -0
  96. package/dist/hooks/sync/controlPlane.d.ts +37 -0
  97. package/dist/hooks/sync/controlPlane.js +78 -0
  98. package/dist/hooks/sync/controlPlane.test.d.ts +1 -0
  99. package/dist/hooks/sync/controlPlane.test.js +121 -0
  100. package/dist/hooks/sync/lifecyclePolicy.d.ts +45 -0
  101. package/dist/hooks/sync/lifecyclePolicy.js +93 -0
  102. package/dist/hooks/sync/lifecyclePolicy.test.d.ts +1 -0
  103. package/dist/hooks/sync/lifecyclePolicy.test.js +124 -0
  104. package/dist/hooks/sync/orchestratorShared.d.ts +10 -1
  105. package/dist/hooks/sync/orchestratorShared.js +68 -47
  106. package/dist/hooks/sync/orchestratorShared.test.js +50 -1
  107. package/dist/hooks/sync/pullLifecycle.d.ts +31 -0
  108. package/dist/hooks/sync/pullLifecycle.js +24 -0
  109. package/dist/hooks/sync/pullLifecycle.test.d.ts +1 -0
  110. package/dist/hooks/sync/pullLifecycle.test.js +80 -0
  111. package/dist/hooks/sync/recovery.d.ts +16 -2
  112. package/dist/hooks/sync/recovery.js +171 -53
  113. package/dist/hooks/sync/recovery.test.d.ts +1 -0
  114. package/dist/hooks/sync/recovery.test.js +292 -0
  115. package/dist/hooks/sync/transfers.d.ts +15 -3
  116. package/dist/hooks/sync/transfers.js +179 -62
  117. package/dist/hooks/sync/transfers.test.d.ts +1 -0
  118. package/dist/hooks/sync/transfers.test.js +396 -0
  119. package/dist/hooks/sync/useRecentSyncEvents.d.ts +21 -0
  120. package/dist/hooks/sync/useRecentSyncEvents.js +92 -0
  121. package/dist/hooks/sync/useRecentSyncEvents.test.d.ts +1 -0
  122. package/dist/hooks/sync/useRecentSyncEvents.test.js +124 -0
  123. package/dist/hooks/sync/useSyncStatusActions.d.ts +30 -0
  124. package/dist/hooks/sync/useSyncStatusActions.js +88 -0
  125. package/dist/hooks/sync/useSyncStatusActions.test.d.ts +1 -0
  126. package/dist/hooks/sync/useSyncStatusActions.test.js +133 -0
  127. package/dist/hooks/sync/useSyncStatusControls.d.ts +25 -0
  128. package/dist/hooks/sync/useSyncStatusControls.js +60 -0
  129. package/dist/hooks/sync/useSyncStatusControls.test.d.ts +1 -0
  130. package/dist/hooks/sync/useSyncStatusControls.test.js +88 -0
  131. package/dist/hooks/useSyncOrchestrator.aiProfiles.test.js +12 -0
  132. package/dist/hooks/useSyncOrchestrator.d.ts +9 -2
  133. package/dist/hooks/useSyncOrchestrator.js +359 -178
  134. package/dist/hooks/useSyncOrchestrator.retry-closure.test.js +407 -0
  135. package/dist/hooks/useTaskData.js +8 -3
  136. package/dist/hooks/useTaskData.test.js +45 -0
  137. package/dist/hooks/useTaskforce.d.ts +60 -2
  138. package/dist/hooks/useTaskforce.js +549 -240
  139. package/dist/hooks/useTaskforce.runtime-routing.test.d.ts +1 -0
  140. package/dist/hooks/useTaskforce.runtime-routing.test.js +152 -0
  141. package/dist/hooks/useTaskforce.sync-behavior.test.js +2380 -212
  142. package/dist/hooks/useWorkspaceSyncController.d.ts +1 -0
  143. package/dist/hooks/useWorkspaceSyncController.js +6 -1
  144. package/dist/hooks/workspace/useTaskforceWorkspaceBootstrap.d.ts +16 -0
  145. package/dist/hooks/workspace/useTaskforceWorkspaceBootstrap.js +316 -35
  146. package/dist/localization/locales/en-US.d.ts +0 -1
  147. package/dist/localization/locales/en-US.js +0 -1
  148. package/dist/localization/locales/es-419.js +0 -1
  149. package/dist/localization/locales/pt-BR.js +0 -1
  150. package/dist/mcp/documentAssetRegistrar.js +3 -3
  151. package/dist/mcp/runtime.d.ts +2 -0
  152. package/dist/mcp/runtime.js +131 -64
  153. package/dist/mcp/runtime.test.js +291 -12
  154. package/dist/migrations/taskSchemaMigrations.d.ts +1 -1
  155. package/dist/migrations/taskSchemaMigrations.js +171 -61
  156. package/dist/migrations/taskSchemaMigrations.test.js +15 -0
  157. package/dist/resources/templates/workflow-sources/workflowDocs.mjs +6 -6
  158. package/dist/resources/templates/workflows/collaborate.yaml +1 -1
  159. package/dist/resources/templates/workflows/evaluate.yaml +2 -2
  160. package/dist/resources/templates/workflows/plan.yaml +1 -1
  161. package/dist/resources/templates/workflows/review.yaml +2 -2
  162. package/dist/server/annotatedAttachmentsRoutes.test.js +3 -3
  163. package/dist/server/auth/providers/apple.d.ts +33 -0
  164. package/dist/server/auth/providers/apple.js +82 -0
  165. package/dist/server/auth/providers/appleClientSecret.d.ts +37 -0
  166. package/dist/server/auth/providers/appleClientSecret.js +65 -0
  167. package/dist/server/auth/providers/github.d.ts +26 -0
  168. package/dist/server/auth/providers/github.js +86 -0
  169. package/dist/server/auth/providers/google.d.ts +21 -0
  170. package/dist/server/auth/providers/google.js +56 -0
  171. package/dist/server/auth/providers/types.d.ts +21 -0
  172. package/dist/server/auth/providers/types.js +1 -0
  173. package/dist/server/auth.d.ts +2 -0
  174. package/dist/server/auth.js +6 -3
  175. package/dist/server/documentReviewRoutes.test.js +36 -3
  176. package/dist/server/index.cookieProxy.test.js +1 -0
  177. package/dist/server/index.d.ts +12 -0
  178. package/dist/server/index.js +120 -9
  179. package/dist/server/index.rateLimit.test.js +3 -0
  180. package/dist/server/index.test.js +106 -3
  181. package/dist/server/routes/admin.d.ts +3 -0
  182. package/dist/server/routes/admin.js +272 -19
  183. package/dist/server/routes/auth.d.ts +15 -2
  184. package/dist/server/routes/auth.js +994 -57
  185. package/dist/server/routes/authSupport.d.ts +1 -1
  186. package/dist/server/routes/authSupport.js +1 -1
  187. package/dist/server/routes/billing.js +361 -35
  188. package/dist/server/routes/billing.test.js +592 -12
  189. package/dist/server/routes/documents.d.ts +1 -0
  190. package/dist/server/routes/documents.js +172 -70
  191. package/dist/server/routes/shared.d.ts +28 -2
  192. package/dist/server/routes/shared.js +69 -4
  193. package/dist/server/routes/sync.integration.test.js +437 -39
  194. package/dist/server/routes/sync.js +61 -605
  195. package/dist/server/routes/syncAuxRoutes.d.ts +15 -0
  196. package/dist/server/routes/syncAuxRoutes.js +91 -0
  197. package/dist/server/routes/syncAuxRoutes.test.d.ts +1 -0
  198. package/dist/server/routes/syncAuxRoutes.test.js +158 -0
  199. package/dist/server/routes/syncPullApplyRoutes.d.ts +36 -0
  200. package/dist/server/routes/syncPullApplyRoutes.js +204 -0
  201. package/dist/server/routes/syncPushRoutes.d.ts +24 -0
  202. package/dist/server/routes/syncPushRoutes.js +212 -0
  203. package/dist/server/routes/syncRouteGuards.d.ts +36 -0
  204. package/dist/server/routes/syncRouteGuards.js +67 -0
  205. package/dist/server/routes/syncRouteGuards.test.d.ts +1 -0
  206. package/dist/server/routes/syncRouteGuards.test.js +94 -0
  207. package/dist/server/routes/syncRouteTypes.d.ts +13 -0
  208. package/dist/server/routes/syncRouteTypes.js +1 -0
  209. package/dist/server/routes/syncSnapshotRoutes.d.ts +66 -0
  210. package/dist/server/routes/syncSnapshotRoutes.js +180 -0
  211. package/dist/server/routes/tasks.js +43 -1
  212. package/dist/server/routes/workspaces.js +36 -5
  213. package/dist/server/routes.js +60 -3
  214. package/dist/server/routes.test.js +1824 -171
  215. package/dist/services/workflowExportSnapshots.test.js +2 -0
  216. package/dist/shared/aiProfileSeatScope.d.ts +5 -0
  217. package/dist/shared/aiProfileSeatScope.js +21 -0
  218. package/dist/shared/passwordPolicy.d.ts +13 -0
  219. package/dist/shared/passwordPolicy.js +84 -0
  220. package/dist/shared/passwordPolicy.test.d.ts +1 -0
  221. package/dist/shared/passwordPolicy.test.js +34 -0
  222. package/dist/storage/workspaceAssetStore.d.ts +15 -3
  223. package/dist/storage/workspaceAssetStore.js +132 -44
  224. package/dist/storage/workspaceAssetStore.test.js +93 -6
  225. package/dist/styles/fonts.css +70 -0
  226. package/dist/sync/collaborationSyncPayload.d.ts +6 -1
  227. package/dist/sync/collaborationSyncPayload.js +17 -11
  228. package/dist/sync/collaborationSyncPayload.test.js +13 -1
  229. package/dist/sync/contentSyncState.d.ts +4 -8
  230. package/dist/sync/contentSyncState.js +17 -70
  231. package/dist/sync/syncApplyHandlers.d.ts +7 -0
  232. package/dist/sync/syncApplyHandlers.js +28 -13
  233. package/dist/sync/syncApplyHandlers.test.js +70 -3
  234. package/dist/sync/syncFieldSemantics.d.ts +12 -0
  235. package/dist/sync/syncFieldSemantics.js +55 -0
  236. package/dist/sync/syncResourceAdapters.d.ts +44 -0
  237. package/dist/sync/syncResourceAdapters.js +77 -0
  238. package/dist/sync/syncService.d.ts +5 -0
  239. package/dist/sync/syncService.js +52 -0
  240. package/dist/sync/syncService.test.js +57 -3
  241. package/dist/sync/taskSyncChangeKey.d.ts +2 -0
  242. package/dist/sync/taskSyncChangeKey.js +143 -0
  243. package/dist/sync/taskSyncPayload.js +3 -8
  244. package/dist/sync/workspacePullFeed.js +4 -3
  245. package/dist/sync/workspacePullFeed.test.js +43 -0
  246. package/dist/sync/workspaceRepair.js +5 -2
  247. package/dist/sync/workspaceSyncModel.d.ts +45 -0
  248. package/dist/sync/workspaceSyncModel.js +183 -28
  249. package/dist/sync/workspaceSyncModel.test.js +291 -12
  250. package/dist/sync/workspaceSyncState.d.ts +17 -0
  251. package/dist/sync/workspaceSyncState.js +2 -1
  252. package/dist/sync/workspaceSyncSurface.js +3 -8
  253. package/dist/types.d.ts +17 -0
  254. package/dist/ui/assets/AgentsModule-DrLawwNl.js +1 -0
  255. package/dist/ui/assets/{AnnotatedAttachmentWorkspace-BG6P_GVW.js → AnnotatedAttachmentWorkspace-Z9_whf7F.js} +1 -1
  256. package/dist/ui/assets/CourierPrime-Bold-BuLj_dpw.woff2 +0 -0
  257. package/dist/ui/assets/CourierPrime-BoldItalic-BrK2pUkZ.woff2 +0 -0
  258. package/dist/ui/assets/CourierPrime-Italic-DFUZK5Ey.woff2 +0 -0
  259. package/dist/ui/assets/CourierPrime-Regular-BsKphzVf.woff2 +0 -0
  260. package/dist/ui/assets/DocumentWorkspace-B03MaSkw.js +252 -0
  261. package/dist/ui/assets/DocumentWorkspace-Dhdso07p.css +1 -0
  262. package/dist/ui/assets/{InitiativesModule-Dhm7M8e7.js → InitiativesModule-9E6ParrY.js} +1 -1
  263. package/dist/ui/assets/Noir_medium-bxQwKGzB.woff2 +0 -0
  264. package/dist/ui/assets/Noir_regular-ojf2kxlG.woff2 +0 -0
  265. package/dist/ui/assets/PlansPage-CvfnMiWq.css +1 -0
  266. package/dist/ui/assets/PlansPage-DRXscYxH.js +1 -0
  267. package/dist/ui/assets/RussoOne-Regular-Cu_qq_qC.woff2 +0 -0
  268. package/dist/ui/assets/SpecialElite-Regular-Di6gSvAS.woff2 +0 -0
  269. package/dist/ui/assets/{TaskSettings-ln0aF7xc.js → TaskSettings-DZX4jk7e.js} +1 -1
  270. package/dist/ui/assets/{WorkflowsModule-BcS4afRn.js → WorkflowsModule-BA7jcEpH.js} +1 -1
  271. package/dist/ui/assets/index-9eT8e0Lu.css +1 -0
  272. package/dist/ui/assets/index-C6k75jr8.js +6 -0
  273. package/dist/ui/assets/{vendor-icons-BSUaRwF8.js → vendor-icons-DuEd_65c.js} +1 -1
  274. package/dist/ui/fonts/CourierPrime-Bold.ttf +0 -0
  275. package/dist/ui/fonts/CourierPrime-Bold.woff2 +0 -0
  276. package/dist/ui/fonts/CourierPrime-BoldItalic.ttf +0 -0
  277. package/dist/ui/fonts/CourierPrime-BoldItalic.woff2 +0 -0
  278. package/dist/ui/fonts/CourierPrime-Italic.ttf +0 -0
  279. package/dist/ui/fonts/CourierPrime-Italic.woff2 +0 -0
  280. package/dist/ui/fonts/CourierPrime-Regular.ttf +0 -0
  281. package/dist/ui/fonts/CourierPrime-Regular.woff2 +0 -0
  282. package/dist/ui/fonts/Noir_medium.otf +0 -0
  283. package/dist/ui/fonts/Noir_medium.woff2 +0 -0
  284. package/dist/ui/fonts/Noir_regular.otf +0 -0
  285. package/dist/ui/fonts/Noir_regular.woff2 +0 -0
  286. package/dist/ui/fonts/RussoOne-Regular.woff2 +0 -0
  287. package/dist/ui/fonts/SpecialElite-Regular.ttf +0 -0
  288. package/dist/ui/fonts/SpecialElite-Regular.woff2 +0 -0
  289. package/dist/ui/index.html +3 -3
  290. package/dist/utils/accountProfileSummaryCache.d.ts +5 -0
  291. package/dist/utils/assignees.d.ts +2 -0
  292. package/dist/utils/assignees.js +2 -0
  293. package/dist/utils/avatarUpload.d.ts +27 -0
  294. package/dist/utils/avatarUpload.js +132 -0
  295. package/dist/utils/avatarUpload.test.d.ts +1 -0
  296. package/dist/utils/avatarUpload.test.js +40 -0
  297. package/dist/utils/bootstrapTrace.d.ts +7 -0
  298. package/dist/utils/bootstrapTrace.js +29 -0
  299. package/dist/utils/commercialLifecyclePresentation.js +3 -0
  300. package/dist/utils/contextAssetEvents.d.ts +2 -0
  301. package/dist/utils/syncEventDetails.d.ts +3 -0
  302. package/dist/utils/syncEventDetails.js +64 -0
  303. package/dist/utils/syncEventDetails.test.d.ts +1 -0
  304. package/dist/utils/syncEventDetails.test.js +23 -0
  305. package/dist/utils/syncEventPresentation.d.ts +15 -0
  306. package/dist/utils/syncEventPresentation.js +129 -0
  307. package/dist/utils/syncEventPresentation.test.d.ts +1 -0
  308. package/dist/utils/syncEventPresentation.test.js +64 -0
  309. package/dist/utils/syncStatusPresentation.d.ts +72 -0
  310. package/dist/utils/syncStatusPresentation.js +217 -0
  311. package/dist/utils/syncStatusPresentation.test.d.ts +1 -0
  312. package/dist/utils/syncStatusPresentation.test.js +164 -0
  313. package/dist/utils/taskActivity.d.ts +2 -0
  314. package/dist/utils/taskActivity.js +228 -22
  315. package/dist/utils/taskActivity.test.js +119 -8
  316. package/dist/utils/workspaceSyncPresentation.d.ts +4 -0
  317. package/dist/utils/workspaceSyncPresentation.js +68 -2
  318. package/dist/utils/workspaceSyncPresentation.test.js +36 -1
  319. package/package.json +3 -2
  320. package/scripts/export-sqlite-to-postgres.mjs +7 -9
  321. package/scripts/run-e2e-realtime.sh +17 -3
  322. package/scripts/run-smoke.sh +17 -5
  323. package/scripts/run-soak.sh +17 -5
  324. package/src/resources/templates/workflow-sources/workflowDocs.mjs +6 -6
  325. package/src/resources/templates/workflows/collaborate.yaml +1 -1
  326. package/src/resources/templates/workflows/evaluate.yaml +2 -2
  327. package/src/resources/templates/workflows/plan.yaml +1 -1
  328. package/src/resources/templates/workflows/review.yaml +2 -2
  329. package/dist/ui/assets/AgentsModule-N2MnQBZk.js +0 -1
  330. package/dist/ui/assets/DocumentWorkspace-B3nV_Gc5.css +0 -1
  331. package/dist/ui/assets/DocumentWorkspace-DRbDMwh8.js +0 -252
  332. package/dist/ui/assets/PlansPage-C2dd2n1X.css +0 -1
  333. package/dist/ui/assets/PlansPage-Cq0zXj3I.js +0 -1
  334. package/dist/ui/assets/RussoOne-Regular-C3BxZIj7.ttf +0 -0
  335. package/dist/ui/assets/index-C2-OXZV7.css +0 -1
  336. package/dist/ui/assets/index-DcSI5F86.js +0 -6
  337. package/scripts/migrate-planning-model.ts +0 -233
@@ -1,3 +1,3 @@
1
- import{j as t,r as a,R as qt}from"./vendor-react-CKJs5o3c.js";import{R as xs,f as Ce,e as Ct,g as vs,t as Bn,M as Jt}from"./index-DcSI5F86.js";import{q as _s,n as js,c as Zt,T as Tn,s as ks,a3 as ws,h as An,ak as Cs,R as Is,al as Ss,am as Ns,an as $s,ao as tn,C as nn,ap as Rs,aq as Dn,ar as zn,as as Un,at as Gn,g as Ps,f as Bs,b as sn}from"./vendor-icons-BSUaRwF8.js";import"./vendor-markdown-BUxTU7dS.js";import"./vendor-dnd-DRzYolkg.js";import"./vendor-router-BbWMxlnO.js";function Ts({copied:o,disabled:l=!1,label:m,onClick:g,title:w="Copy image reference",ariaLabel:y,className:M=""}){return t.jsx(xs,{copied:o,disabled:l,label:"",onClick:g,title:w,ariaLabel:y,className:M,children:m})}const As="_shell_sf7jc_1",Es="_panel_sf7jc_16",Ms="_sessionPanel_sf7jc_22",Ls="_detailPanel_sf7jc_23",Fs="_sessionContextBar_sf7jc_29",Hs="_sessionContextLeft_sf7jc_40",Os="_sessionContextRight_sf7jc_41",Ds="_sessionContextLabel_sf7jc_56",zs="_sessionContextSpacer_sf7jc_62",Us="_canvasPanel_sf7jc_67",Gs="_canvasWorkspace_sf7jc_74",Ys="_canvasMain_sf7jc_81",Ks="_panelHeader_sf7jc_88",Ws="_panelHeaderText_sf7jc_97",Xs="_panelTitle_sf7jc_101",Vs="_canvasHeading_sf7jc_105",qs="_sessionActions_sf7jc_109",Js="_sessionList_sf7jc_117",Zs="_annotationList_sf7jc_118",Qs="_markerHelpModalBody_sf7jc_133",ea="_openImageModalBody_sf7jc_139",ta="_openImageField_sf7jc_145",na="_openImageActions_sf7jc_149",sa="_markerHelpItem_sf7jc_155",aa="_markerHelpHeader_sf7jc_163",oa="_markerHelpExample_sf7jc_175",ra="_sessionCard_sf7jc_179",ia="_annotationCard_sf7jc_180",la="_sessionEmptyState_sf7jc_197",ca="_sessionCardButton_sf7jc_204",da="_annotationCardButton_sf7jc_214",ua="_sessionCardBody_sf7jc_224",fa="_sessionCardActive_sf7jc_230",ma="_annotationCardActive_sf7jc_231",pa="_annotationMeta_sf7jc_241",ha="_annotationInstructionPreview_sf7jc_248",ba="_annotationPreviewFooter_sf7jc_256",ga="_annotationInstructionEditor_sf7jc_263",ya="_annotationTypeField_sf7jc_269",xa="_annotationInstructionButton_sf7jc_275",va="_annotationInstructionField_sf7jc_284",_a="_sessionMeta_sf7jc_288",ja="_sessionTitle_sf7jc_295",ka="_annotationTitle_sf7jc_296",wa="_sessionTimestamp_sf7jc_302",Ca="_annotationKind_sf7jc_303",Ia="_annotationInstructionTypeIcon_sf7jc_307",Sa="_sessionInstructionPreview_sf7jc_313",Na="_sessionInstructionEditor_sf7jc_321",$a="_sessionCardFooter_sf7jc_327",Ra="_toolRail_sf7jc_334",Pa="_canvasToolRail_sf7jc_343",Ba="_toolbarCluster_sf7jc_364",Ta="_toolbarViewportCluster_sf7jc_371",Aa="_toolbarSeparator_sf7jc_375",Ea="_toolBtn_sf7jc_381",Ma="_toolRailButton_sf7jc_385",La="_toolbarButton_sf7jc_395",Fa="_toolBtnActive_sf7jc_400",Ha="_toolbarActions_sf7jc_407",Oa="_toolbarSelectionActions_sf7jc_416",Da="_toolbarColorPicker_sf7jc_424",za="_colorPickerButton_sf7jc_428",Ua="_colorPickerSwatch_sf7jc_433",Ga="_colorPickerPopover_sf7jc_441",Ya="_colorOption_sf7jc_456",Ka="_colorOptionActive_sf7jc_466",Wa="_toolbarUtilities_sf7jc_473",Xa="_toolbarGeometryFields_sf7jc_481",Va="_toolbarGeometryField_sf7jc_481",qa="_toolbarGeometryLabel_sf7jc_494",Ja="_toolbarGeometryInput_sf7jc_500",Za="_iconButton_sf7jc_505",Qa="_ghostBtn_sf7jc_510",eo="_payloadBtn_sf7jc_511",to="_backToTaskBtn_sf7jc_512",no="_canvasScroller_sf7jc_532",so="_canvasFrame_sf7jc_548",ao="_canvasMedia_sf7jc_555",oo="_canvasStatusOverlay_sf7jc_563",ro="_canvasStatusCard_sf7jc_575",io="_canvasImage_sf7jc_588",lo="_overlay_sf7jc_595",co="_overlaySelect_sf7jc_601",uo="_overlayPan_sf7jc_605",fo="_overlaySvg_sf7jc_609",mo="_overlayHitLayer_sf7jc_618",po="_arrowHitArea_sf7jc_627",ho="_canvasHandleHit_sf7jc_634",bo="_canvasResizeHandleHit_sf7jc_641",go="_canvasHandleVisible_sf7jc_645",yo="_pin_sf7jc_662",xo="_note_sf7jc_663",vo="_annotationNumberBadge_sf7jc_680",_o="_box_sf7jc_705",jo="_boxNumberBadge_sf7jc_714",ko="_arrowNumberBadge_sf7jc_720",wo="_boxSurface_sf7jc_724",Co="_selected_sf7jc_737",Io="_textInput_sf7jc_754",So="_textArea_sf7jc_755",No="_select_sf7jc_737",$o="_sessionTitleInput_sf7jc_762",Ro="_sessionInstructionField_sf7jc_767",Po="_detailEmpty_sf7jc_776",Bo="_emptyState_sf7jc_777",To="_payloadModalBody_sf7jc_789",Ao="_payloadModalToolbar_sf7jc_796",Eo="_payloadViewToggle_sf7jc_803",Mo="_payloadModalActions_sf7jc_804",Lo="_payloadModalPreview_sf7jc_811",Fo="_statusBar_sf7jc_826",Ho="_annotationSummary_sf7jc_838",s={shell:As,panel:Es,sessionPanel:Ms,detailPanel:Ls,sessionContextBar:Fs,sessionContextLeft:Hs,sessionContextRight:Os,sessionContextLabel:Ds,sessionContextSpacer:zs,canvasPanel:Us,canvasWorkspace:Gs,canvasMain:Ys,panelHeader:Ks,panelHeaderText:Ws,panelTitle:Xs,canvasHeading:Vs,sessionActions:qs,sessionList:Js,annotationList:Zs,markerHelpModalBody:Qs,openImageModalBody:ea,openImageField:ta,openImageActions:na,markerHelpItem:sa,markerHelpHeader:aa,markerHelpExample:oa,sessionCard:ra,annotationCard:ia,sessionEmptyState:la,sessionCardButton:ca,annotationCardButton:da,sessionCardBody:ua,sessionCardActive:fa,annotationCardActive:ma,annotationMeta:pa,annotationInstructionPreview:ha,annotationPreviewFooter:ba,annotationInstructionEditor:ga,annotationTypeField:ya,annotationInstructionButton:xa,annotationInstructionField:va,sessionMeta:_a,sessionTitle:ja,annotationTitle:ka,sessionTimestamp:wa,annotationKind:Ca,annotationInstructionTypeIcon:Ia,sessionInstructionPreview:Sa,sessionInstructionEditor:Na,sessionCardFooter:$a,toolRail:Ra,canvasToolRail:Pa,toolbarCluster:Ba,toolbarViewportCluster:Ta,toolbarSeparator:Aa,toolBtn:Ea,toolRailButton:Ma,toolbarButton:La,toolBtnActive:Fa,toolbarActions:Ha,toolbarSelectionActions:Oa,toolbarColorPicker:Da,colorPickerButton:za,colorPickerSwatch:Ua,colorPickerPopover:Ga,colorOption:Ya,colorOptionActive:Ka,toolbarUtilities:Wa,toolbarGeometryFields:Xa,toolbarGeometryField:Va,toolbarGeometryLabel:qa,toolbarGeometryInput:Ja,iconButton:Za,ghostBtn:Qa,payloadBtn:eo,backToTaskBtn:to,canvasScroller:no,canvasFrame:so,canvasMedia:ao,canvasStatusOverlay:oo,canvasStatusCard:ro,canvasImage:io,overlay:lo,overlaySelect:co,overlayPan:uo,overlaySvg:fo,overlayHitLayer:mo,arrowHitArea:po,canvasHandleHit:ho,canvasResizeHandleHit:bo,canvasHandleVisible:go,pin:yo,note:xo,annotationNumberBadge:vo,box:_o,boxNumberBadge:jo,arrowNumberBadge:ko,boxSurface:wo,selected:Co,textInput:Io,textArea:So,select:No,sessionTitleInput:$o,sessionInstructionField:Ro,detailEmpty:Po,emptyState:Bo,payloadModalBody:To,payloadModalToolbar:Ao,payloadViewToggle:Eo,payloadModalActions:Mo,payloadModalPreview:Lo,statusBar:Fo,annotationSummary:Ho},En=[{value:"review",label:"Review"},{value:"change",label:"Change"},{value:"question",label:"Question"}],Mn=[{value:"select",label:"Select",icon:Rs},{value:"pin",label:"Pin",icon:Dn},{value:"box",label:"Box",icon:zn},{value:"arrow",label:"Arrow",icon:Un},{value:"text-note",label:"Note",icon:Gn}],Oo={pin:Dn,box:zn,arrow:Un,"text-note":Gn},Do={pin:"Pin",box:"Box",arrow:"Arrow","text-note":"Note"},zo={review:tn,change:sn,question:nn,issue:nn,idea:tn},It={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."'}},it={question:"#0f766e",change:"#2563eb",issue:"#dc2626",idea:"#d97706",review:"#7c3aed"},Uo=["#7c3aed","#2563eb","#0f766e","#dc2626","#d97706","#111827"],re="review";function ze(o){const l=String(o.displayName||"").trim();return l?`${l} review`:"Annotated session"}function Yn(){return`annotation-${Math.random().toString(36).slice(2,10)}`}function _(o){return!Number.isFinite(o)||o<=0?0:o>=1?1:o}function Se(o){return _(Math.max(.02,o))}function rt(o){return o?[String(o.taskId||"").trim(),String(o.assetId||"").trim(),String(o.path||"").trim()].join("::"):""}function Go(o){if(!(o instanceof HTMLElement))return!1;const l=o.tagName.toLowerCase();return o.isContentEditable?!0:l==="input"||l==="textarea"||l==="select"}function Ie(o){return o.map((l,m)=>({...l,order:m}))}function Qt(o){if(!o)return"Unsaved";const l=new Date(o);return Number.isNaN(l.getTime())?"Unsaved":l.toLocaleString()}function St(o){const l=String(o.createdByActor?.label||"").trim();return l||null}function Yo(o){const l=String(o||"").trim().replace(/\s+/g," ");return l?l.length>110?`${l.slice(0,107)}...`:l:""}function Ln(o,l,m,g=it[re]){const w={id:Yn(),order:0,instruction:"",markerType:re,color:g};if(o==="pin")return{...w,kind:o,x:l.x,y:l.y};if(o==="text-note")return{...w,kind:o,x:l.x,y:l.y};if(o==="box"){const M=m||l;return{...w,kind:o,x:_(Math.min(l.x,M.x)),y:_(Math.min(l.y,M.y)),width:Se(Math.abs(M.x-l.x)),height:Se(Math.abs(M.y-l.y))}}const y=m||l;return{...w,kind:"arrow",x:l.x,y:l.y,x2:y.x,y2:y.y}}function en(o){return o.color?o.color:it[o.markerType||re]}function Ko(o,l){const m=Math.max(l.width,1),g=Math.max(l.height,1),w=o.x*m,y=o.y*g,M=o.x2*m,ne=o.y2*g,Ue=M-w,Ge=ne-y,me=Math.hypot(Ue,Ge)||1,ie=Ue/me,Ye=Ge/me,Ne=Math.max(10,Math.min(16,me-2)),T=Ne*.62,Ke=M-ie*Ne,pe=ne-Ye*Ne,he=-Ye,se=ie;return{shaftX1:w,shaftY1:y,shaftX2:Ke,shaftY2:pe,headPoints:[`${M},${ne}`,`${Ke+he*T},${pe+se*T}`,`${Ke-he*T},${pe-se*T}`].join(" ")}}function Wo(o,l){return{...o,markerType:l,color:o.color||it[l]}}function Xo(o,l){return{...o,id:Yn(),order:l}}function Vo(o,l){const m=String(o||"").trim()||(l?ze(l):"Annotated session");return/\bcopy$/i.test(m)?`${m} 2`:`${m} copy`}function qo(o,l,m){if(l===m||l<0||m<0||l>=o.length||m>=o.length)return o;const g=[...o],[w]=g.splice(l,1);return w?(g.splice(m,0,w),Ie(g)):o}function te(o){return String(Math.round(_(o)*1e3)/10)}function Jo(o){const l=Number.parseFloat(o);return Number.isFinite(l)?_(l/100):null}function Zo(o,l,m){return o.kind==="pin"||o.kind==="text-note"?l==="x"||l==="y"?{...o,[l]:_(m)}:o:o.kind==="box"?l==="x"||l==="y"?{...o,[l]:_(m)}:l==="width"||l==="height"?{...o,[l]:Se(m)}:o:l==="x"||l==="y"||l==="x2"||l==="y2"?{...o,[l]:_(m)}:o}function Qo(o){return o.kind==="pin"||o.kind==="text-note"?[{key:"x",label:"X",value:te(o.x)},{key:"y",label:"Y",value:te(o.y)}]:o.kind==="box"?[{key:"x",label:"X",value:te(o.x)},{key:"y",label:"Y",value:te(o.y)},{key:"width",label:"Width",value:te(o.width)},{key:"height",label:"Height",value:te(o.height)}]:[{key:"x",label:"Start X",value:te(o.x)},{key:"y",label:"Start Y",value:te(o.y)},{key:"x2",label:"End X",value:te(o.x2)},{key:"y2",label:"End Y",value:te(o.y2)}]}function er(o){if(!o)return null;const l=Math.round(o.x*100),m=Math.round(o.y*100),g=Math.round(o.width*100),w=Math.round(o.height*100);return`crop ${l}%, ${m}% size ${g}% x ${w}%`}function tr(o){return Number.isFinite(o)?Math.min(4,Math.max(.25,Number(o.toFixed(2)))):1}function Fn(o){const l=[`Annotated attachment: ${o.title||o.image.displayName}`,`Image: ${o.image.displayName}`,`Image Reference: ${o.image.referenceLabel||o.image.assetId}`,`Task ID: ${o.taskId}`,o.globalInstruction?`Global instruction: ${o.globalInstruction}`:"Global instruction: None provided.","Markers:"];return o.annotations.length===0?(l.push("0. No markers."),l.join(`
1
+ import{j as t,r as a,R as qt}from"./vendor-react-CKJs5o3c.js";import{R as xs,f as Ce,e as Ct,g as vs,t as Bn,M as Jt}from"./index-C6k75jr8.js";import{q as _s,n as js,c as Zt,T as Tn,s as ks,a5 as ws,h as An,am as Cs,R as Is,an as Ss,ao as Ns,ap as $s,aq as tn,C as nn,ar as Rs,as as Dn,at as zn,au as Un,av as Gn,g as Ps,f as Bs,b as sn}from"./vendor-icons-DuEd_65c.js";import"./vendor-markdown-BUxTU7dS.js";import"./vendor-dnd-DRzYolkg.js";import"./vendor-router-BbWMxlnO.js";function Ts({copied:o,disabled:l=!1,label:m,onClick:g,title:w="Copy image reference",ariaLabel:y,className:M=""}){return t.jsx(xs,{copied:o,disabled:l,label:"",onClick:g,title:w,ariaLabel:y,className:M,children:m})}const As="_shell_sf7jc_1",Es="_panel_sf7jc_16",Ms="_sessionPanel_sf7jc_22",Ls="_detailPanel_sf7jc_23",Fs="_sessionContextBar_sf7jc_29",Hs="_sessionContextLeft_sf7jc_40",Os="_sessionContextRight_sf7jc_41",Ds="_sessionContextLabel_sf7jc_56",zs="_sessionContextSpacer_sf7jc_62",Us="_canvasPanel_sf7jc_67",Gs="_canvasWorkspace_sf7jc_74",Ys="_canvasMain_sf7jc_81",Ks="_panelHeader_sf7jc_88",Ws="_panelHeaderText_sf7jc_97",Xs="_panelTitle_sf7jc_101",Vs="_canvasHeading_sf7jc_105",qs="_sessionActions_sf7jc_109",Js="_sessionList_sf7jc_117",Zs="_annotationList_sf7jc_118",Qs="_markerHelpModalBody_sf7jc_133",ea="_openImageModalBody_sf7jc_139",ta="_openImageField_sf7jc_145",na="_openImageActions_sf7jc_149",sa="_markerHelpItem_sf7jc_155",aa="_markerHelpHeader_sf7jc_163",oa="_markerHelpExample_sf7jc_175",ra="_sessionCard_sf7jc_179",ia="_annotationCard_sf7jc_180",la="_sessionEmptyState_sf7jc_197",ca="_sessionCardButton_sf7jc_204",da="_annotationCardButton_sf7jc_214",ua="_sessionCardBody_sf7jc_224",fa="_sessionCardActive_sf7jc_230",ma="_annotationCardActive_sf7jc_231",pa="_annotationMeta_sf7jc_241",ha="_annotationInstructionPreview_sf7jc_248",ba="_annotationPreviewFooter_sf7jc_256",ga="_annotationInstructionEditor_sf7jc_263",ya="_annotationTypeField_sf7jc_269",xa="_annotationInstructionButton_sf7jc_275",va="_annotationInstructionField_sf7jc_284",_a="_sessionMeta_sf7jc_288",ja="_sessionTitle_sf7jc_295",ka="_annotationTitle_sf7jc_296",wa="_sessionTimestamp_sf7jc_302",Ca="_annotationKind_sf7jc_303",Ia="_annotationInstructionTypeIcon_sf7jc_307",Sa="_sessionInstructionPreview_sf7jc_313",Na="_sessionInstructionEditor_sf7jc_321",$a="_sessionCardFooter_sf7jc_327",Ra="_toolRail_sf7jc_334",Pa="_canvasToolRail_sf7jc_343",Ba="_toolbarCluster_sf7jc_364",Ta="_toolbarViewportCluster_sf7jc_371",Aa="_toolbarSeparator_sf7jc_375",Ea="_toolBtn_sf7jc_381",Ma="_toolRailButton_sf7jc_385",La="_toolbarButton_sf7jc_395",Fa="_toolBtnActive_sf7jc_400",Ha="_toolbarActions_sf7jc_407",Oa="_toolbarSelectionActions_sf7jc_416",Da="_toolbarColorPicker_sf7jc_424",za="_colorPickerButton_sf7jc_428",Ua="_colorPickerSwatch_sf7jc_433",Ga="_colorPickerPopover_sf7jc_441",Ya="_colorOption_sf7jc_456",Ka="_colorOptionActive_sf7jc_466",Wa="_toolbarUtilities_sf7jc_473",Xa="_toolbarGeometryFields_sf7jc_481",Va="_toolbarGeometryField_sf7jc_481",qa="_toolbarGeometryLabel_sf7jc_494",Ja="_toolbarGeometryInput_sf7jc_500",Za="_iconButton_sf7jc_505",Qa="_ghostBtn_sf7jc_510",eo="_payloadBtn_sf7jc_511",to="_backToTaskBtn_sf7jc_512",no="_canvasScroller_sf7jc_532",so="_canvasFrame_sf7jc_548",ao="_canvasMedia_sf7jc_555",oo="_canvasStatusOverlay_sf7jc_563",ro="_canvasStatusCard_sf7jc_575",io="_canvasImage_sf7jc_588",lo="_overlay_sf7jc_595",co="_overlaySelect_sf7jc_601",uo="_overlayPan_sf7jc_605",fo="_overlaySvg_sf7jc_609",mo="_overlayHitLayer_sf7jc_618",po="_arrowHitArea_sf7jc_627",ho="_canvasHandleHit_sf7jc_634",bo="_canvasResizeHandleHit_sf7jc_641",go="_canvasHandleVisible_sf7jc_645",yo="_pin_sf7jc_662",xo="_note_sf7jc_663",vo="_annotationNumberBadge_sf7jc_680",_o="_box_sf7jc_705",jo="_boxNumberBadge_sf7jc_714",ko="_arrowNumberBadge_sf7jc_720",wo="_boxSurface_sf7jc_724",Co="_selected_sf7jc_737",Io="_textInput_sf7jc_754",So="_textArea_sf7jc_755",No="_select_sf7jc_737",$o="_sessionTitleInput_sf7jc_762",Ro="_sessionInstructionField_sf7jc_767",Po="_detailEmpty_sf7jc_776",Bo="_emptyState_sf7jc_777",To="_payloadModalBody_sf7jc_789",Ao="_payloadModalToolbar_sf7jc_796",Eo="_payloadViewToggle_sf7jc_803",Mo="_payloadModalActions_sf7jc_804",Lo="_payloadModalPreview_sf7jc_811",Fo="_statusBar_sf7jc_826",Ho="_annotationSummary_sf7jc_838",s={shell:As,panel:Es,sessionPanel:Ms,detailPanel:Ls,sessionContextBar:Fs,sessionContextLeft:Hs,sessionContextRight:Os,sessionContextLabel:Ds,sessionContextSpacer:zs,canvasPanel:Us,canvasWorkspace:Gs,canvasMain:Ys,panelHeader:Ks,panelHeaderText:Ws,panelTitle:Xs,canvasHeading:Vs,sessionActions:qs,sessionList:Js,annotationList:Zs,markerHelpModalBody:Qs,openImageModalBody:ea,openImageField:ta,openImageActions:na,markerHelpItem:sa,markerHelpHeader:aa,markerHelpExample:oa,sessionCard:ra,annotationCard:ia,sessionEmptyState:la,sessionCardButton:ca,annotationCardButton:da,sessionCardBody:ua,sessionCardActive:fa,annotationCardActive:ma,annotationMeta:pa,annotationInstructionPreview:ha,annotationPreviewFooter:ba,annotationInstructionEditor:ga,annotationTypeField:ya,annotationInstructionButton:xa,annotationInstructionField:va,sessionMeta:_a,sessionTitle:ja,annotationTitle:ka,sessionTimestamp:wa,annotationKind:Ca,annotationInstructionTypeIcon:Ia,sessionInstructionPreview:Sa,sessionInstructionEditor:Na,sessionCardFooter:$a,toolRail:Ra,canvasToolRail:Pa,toolbarCluster:Ba,toolbarViewportCluster:Ta,toolbarSeparator:Aa,toolBtn:Ea,toolRailButton:Ma,toolbarButton:La,toolBtnActive:Fa,toolbarActions:Ha,toolbarSelectionActions:Oa,toolbarColorPicker:Da,colorPickerButton:za,colorPickerSwatch:Ua,colorPickerPopover:Ga,colorOption:Ya,colorOptionActive:Ka,toolbarUtilities:Wa,toolbarGeometryFields:Xa,toolbarGeometryField:Va,toolbarGeometryLabel:qa,toolbarGeometryInput:Ja,iconButton:Za,ghostBtn:Qa,payloadBtn:eo,backToTaskBtn:to,canvasScroller:no,canvasFrame:so,canvasMedia:ao,canvasStatusOverlay:oo,canvasStatusCard:ro,canvasImage:io,overlay:lo,overlaySelect:co,overlayPan:uo,overlaySvg:fo,overlayHitLayer:mo,arrowHitArea:po,canvasHandleHit:ho,canvasResizeHandleHit:bo,canvasHandleVisible:go,pin:yo,note:xo,annotationNumberBadge:vo,box:_o,boxNumberBadge:jo,arrowNumberBadge:ko,boxSurface:wo,selected:Co,textInput:Io,textArea:So,select:No,sessionTitleInput:$o,sessionInstructionField:Ro,detailEmpty:Po,emptyState:Bo,payloadModalBody:To,payloadModalToolbar:Ao,payloadViewToggle:Eo,payloadModalActions:Mo,payloadModalPreview:Lo,statusBar:Fo,annotationSummary:Ho},En=[{value:"review",label:"Review"},{value:"change",label:"Change"},{value:"question",label:"Question"}],Mn=[{value:"select",label:"Select",icon:Rs},{value:"pin",label:"Pin",icon:Dn},{value:"box",label:"Box",icon:zn},{value:"arrow",label:"Arrow",icon:Un},{value:"text-note",label:"Note",icon:Gn}],Oo={pin:Dn,box:zn,arrow:Un,"text-note":Gn},Do={pin:"Pin",box:"Box",arrow:"Arrow","text-note":"Note"},zo={review:tn,change:sn,question:nn,issue:nn,idea:tn},It={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."'}},it={question:"#0f766e",change:"#2563eb",issue:"#dc2626",idea:"#d97706",review:"#7c3aed"},Uo=["#7c3aed","#2563eb","#0f766e","#dc2626","#d97706","#111827"],re="review";function ze(o){const l=String(o.displayName||"").trim();return l?`${l} review`:"Annotated session"}function Yn(){return`annotation-${Math.random().toString(36).slice(2,10)}`}function _(o){return!Number.isFinite(o)||o<=0?0:o>=1?1:o}function Se(o){return _(Math.max(.02,o))}function rt(o){return o?[String(o.taskId||"").trim(),String(o.assetId||"").trim(),String(o.path||"").trim()].join("::"):""}function Go(o){if(!(o instanceof HTMLElement))return!1;const l=o.tagName.toLowerCase();return o.isContentEditable?!0:l==="input"||l==="textarea"||l==="select"}function Ie(o){return o.map((l,m)=>({...l,order:m}))}function Qt(o){if(!o)return"Unsaved";const l=new Date(o);return Number.isNaN(l.getTime())?"Unsaved":l.toLocaleString()}function St(o){const l=String(o.createdByActor?.label||"").trim();return l||null}function Yo(o){const l=String(o||"").trim().replace(/\s+/g," ");return l?l.length>110?`${l.slice(0,107)}...`:l:""}function Ln(o,l,m,g=it[re]){const w={id:Yn(),order:0,instruction:"",markerType:re,color:g};if(o==="pin")return{...w,kind:o,x:l.x,y:l.y};if(o==="text-note")return{...w,kind:o,x:l.x,y:l.y};if(o==="box"){const M=m||l;return{...w,kind:o,x:_(Math.min(l.x,M.x)),y:_(Math.min(l.y,M.y)),width:Se(Math.abs(M.x-l.x)),height:Se(Math.abs(M.y-l.y))}}const y=m||l;return{...w,kind:"arrow",x:l.x,y:l.y,x2:y.x,y2:y.y}}function en(o){return o.color?o.color:it[o.markerType||re]}function Ko(o,l){const m=Math.max(l.width,1),g=Math.max(l.height,1),w=o.x*m,y=o.y*g,M=o.x2*m,ne=o.y2*g,Ue=M-w,Ge=ne-y,me=Math.hypot(Ue,Ge)||1,ie=Ue/me,Ye=Ge/me,Ne=Math.max(10,Math.min(16,me-2)),T=Ne*.62,Ke=M-ie*Ne,pe=ne-Ye*Ne,he=-Ye,se=ie;return{shaftX1:w,shaftY1:y,shaftX2:Ke,shaftY2:pe,headPoints:[`${M},${ne}`,`${Ke+he*T},${pe+se*T}`,`${Ke-he*T},${pe-se*T}`].join(" ")}}function Wo(o,l){return{...o,markerType:l,color:o.color||it[l]}}function Xo(o,l){return{...o,id:Yn(),order:l}}function Vo(o,l){const m=String(o||"").trim()||(l?ze(l):"Annotated session");return/\bcopy$/i.test(m)?`${m} 2`:`${m} copy`}function qo(o,l,m){if(l===m||l<0||m<0||l>=o.length||m>=o.length)return o;const g=[...o],[w]=g.splice(l,1);return w?(g.splice(m,0,w),Ie(g)):o}function te(o){return String(Math.round(_(o)*1e3)/10)}function Jo(o){const l=Number.parseFloat(o);return Number.isFinite(l)?_(l/100):null}function Zo(o,l,m){return o.kind==="pin"||o.kind==="text-note"?l==="x"||l==="y"?{...o,[l]:_(m)}:o:o.kind==="box"?l==="x"||l==="y"?{...o,[l]:_(m)}:l==="width"||l==="height"?{...o,[l]:Se(m)}:o:l==="x"||l==="y"||l==="x2"||l==="y2"?{...o,[l]:_(m)}:o}function Qo(o){return o.kind==="pin"||o.kind==="text-note"?[{key:"x",label:"X",value:te(o.x)},{key:"y",label:"Y",value:te(o.y)}]:o.kind==="box"?[{key:"x",label:"X",value:te(o.x)},{key:"y",label:"Y",value:te(o.y)},{key:"width",label:"Width",value:te(o.width)},{key:"height",label:"Height",value:te(o.height)}]:[{key:"x",label:"Start X",value:te(o.x)},{key:"y",label:"Start Y",value:te(o.y)},{key:"x2",label:"End X",value:te(o.x2)},{key:"y2",label:"End Y",value:te(o.y2)}]}function er(o){if(!o)return null;const l=Math.round(o.x*100),m=Math.round(o.y*100),g=Math.round(o.width*100),w=Math.round(o.height*100);return`crop ${l}%, ${m}% size ${g}% x ${w}%`}function tr(o){return Number.isFinite(o)?Math.min(4,Math.max(.25,Number(o.toFixed(2)))):1}function Fn(o){const l=[`Annotated attachment: ${o.title||o.image.displayName}`,`Image: ${o.image.displayName}`,`Image Reference: ${o.image.referenceLabel||o.image.assetId}`,`Task ID: ${o.taskId}`,o.globalInstruction?`Global instruction: ${o.globalInstruction}`:"Global instruction: None provided.","Markers:"];return o.annotations.length===0?(l.push("0. No markers."),l.join(`
2
2
  `)):(o.annotations.forEach((m,g)=>{const w=m.markerType||re,y=er(m.cropHint);l.push(`${g+1}. ${m.kind} (${w})`),l.push(`Instruction: ${m.instruction||"No marker instruction."}`),y&&l.push(`Region: ${y}`)}),l.join(`
3
3
  `))}function Nt(o){return{title:o.title,globalInstruction:o.globalInstruction,annotations:Ie(o.annotations)}}function Hn(o){return JSON.stringify(Nt(o))}function On(o){const l=JSON.parse(o);return Nt({title:String(l?.title||""),globalInstruction:String(l?.globalInstruction||""),annotations:Array.isArray(l?.annotations)?l.annotations:[]})}function nr(o,l){return Nt({title:o?.title||l,globalInstruction:o?.globalInstruction||"",annotations:o?.annotations||[]})}function dr({runtimeMode:o="local",apiBaseUrl:l="",cloudAuthBaseUrl:m="",workspaceId:g="default",sessionLoadReady:w=!0,requestedTarget:y=null,requestedSessionId:M=null,requestedOpenVersion:ne=0,resolveTaskReferenceLabel:Ue,resolveImageReferenceLabel:Ge,onRequestedTargetHandled:me,onOpenTarget:ie,onContextChange:Ye,onBackToTask:Ne}){const T=o==="cloud"&&(m||l)||"",[Ke,pe]=a.useState(y),[he,se]=a.useState([]),[x,$e]=a.useState(null),[$t,We]=a.useState(!1),[Re,Xe]=a.useState(""),[Pe,Ve]=a.useState(""),[N,ae]=a.useState([]),[C,L]=a.useState(null),[lt,an]=a.useState(it[re]),[ct,dt]=a.useState(!1),[$,Be]=a.useState("select"),[Kn,be]=a.useState(!1),[ut,on]=a.useState(!1),[W,X]=a.useState(!1),[rn,h]=a.useState(null),[U,R]=a.useState("saved"),[sr,D]=a.useState(null),[ft,ln]=a.useState(!1),[oe,Rt]=a.useState(null),[le,Pt]=a.useState(!1),[Wn,Bt]=a.useState(!1),[Tt,cn]=a.useState("json"),[mt,At]=a.useState(!1),[pt,Et]=a.useState(!1),[Xn,dn]=a.useState(!1),[Vn,ht]=a.useState(!1),[Mt,bt]=a.useState(""),[qe,un]=a.useState(!1),[ce,Je]=a.useState(!1),[Lt,Ze]=a.useState(!1),[P,Ft]=a.useState(1),[G,Qe]=a.useState(!1),[gt,fn]=a.useState(!1),[yt,et]=a.useState({width:0,height:0}),mn=a.useRef(null),Te=a.useRef(null),Ht=a.useRef(null),pn=a.useRef(null),ge=a.useRef(M),ye=a.useRef(""),xt=a.useRef(0),Ot=a.useRef(""),xe=a.useRef(0),vt=a.useRef(null),hn=a.useRef(0),de=a.useRef(!1),tt=a.useRef(null),Dt=a.useRef(null),ve=a.useRef(null),F=a.useRef(""),A=a.useRef(""),_t=a.useRef(null),V=a.useRef(null),Ae=a.useRef(!1),jt=a.useRef(null),nt=a.useRef(null),st=a.useRef(null),_e=a.useRef(null),Ee=a.useRef(null),Me=a.useRef(null),Le=a.useRef(null),ue=a.useRef(null),q=a.useRef(null),bn=a.useRef(null),gn=a.useRef(null),B=a.useMemo(()=>he.find(e=>e.id===x)||null,[x,he]),J=a.useMemo(()=>`workspaceId=${encodeURIComponent(String(g||"default").trim()||"default")}`,[g]),E=a.useMemo(()=>({"x-taskforce-workspace-id":String(g||"default").trim()||"default"}),[g]),z=a.useMemo(()=>N.find(e=>e.id===C)||null,[N,C]),Z=a.useMemo(()=>rt(y),[y]),je=typeof ie=="function",d=je?y:Ke,kt=a.useMemo(()=>{const e=String(d?.taskId||"").trim();if(!e)return"";const n=Ue?.(e).trim()||"";if(n)return n;const r=String(d?.taskReferenceLabel||"").trim();return r&&r!==e?r:n||e},[d?.taskId,d?.taskReferenceLabel,Ue]),at=a.useMemo(()=>{const e=String(d?.assetId||"").trim();if(!e)return"";const n=Ge?.(e).trim()||"";return n||String(d?.imageReferenceLabel||"").trim()},[d?.assetId,d?.imageReferenceLabel,Ge]),zt=a.useMemo(()=>N.findIndex(e=>e.id===C),[N,C]),Ut=z?.color||lt,yn=a.useMemo(()=>Nt({title:Re,globalInstruction:Pe,annotations:N}),[N,Pe,Re]),Fe=a.useMemo(()=>Hn(yn),[yn]),xn=Fe!==A.current,b=a.useMemo(()=>({width:Math.max(yt.width*P,0),height:Math.max(yt.height*P,0)}),[yt.height,yt.width,P]),He=a.useMemo(()=>({visibleRadius:7,hitRadius:11}),[]),Gt=a.useMemo(()=>`0 0 ${Math.max(b.width,1)} ${Math.max(b.height,1)}`,[b.height,b.width]),ke=a.useMemo(()=>{const e=Te.current;return e?P>1||b.width>e.clientWidth+1||b.height>e.clientHeight+1:P>1},[b.height,b.width,P]),Yt=`${Math.round(P*100)}%`,Kt=a.useMemo(()=>{const e=new Map;return N.forEach((n,r)=>{e.set(n.id,r+1)}),e},[N]);a.useEffect(()=>{ge.current=M},[M]),a.useEffect(()=>{const e=pn.current;if(!e||!C)return;e.focus();const n=e.value.length;e.setSelectionRange(n,n)},[C]),a.useEffect(()=>{ve.current=x},[x]),a.useEffect(()=>{We(!1)},[x]),a.useEffect(()=>{if(!z){dt(!1);return}an(z.color||it[z.markerType||re])},[z]);const wt=a.useCallback(async e=>{const n=typeof performance<"u"?performance.now():Date.now(),r=await Ce(`/api/taskforce/annotated-attachments/sessions?${J}`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",...E},body:JSON.stringify({taskId:e.taskId,baseImageAssetId:e.assetId,title:ze(e),globalInstruction:"",annotations:[]})},T),i=await r.json().catch(()=>({}));if(!r.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 Ct("annotated_session_create_completed",{assetId:e.assetId,taskId:e.taskId||null,sessionId:c.id,durationMs:Math.round((typeof performance<"u"?performance.now():Date.now())-n),debugTimings:i?.debugTimings||null,serverTiming:typeof r.headers?.get=="function"&&r.headers.get("server-timing")||null}),c},[E,T,J]),vn=a.useCallback(e=>new Promise((n,r)=>{const i=new FileReader;i.onload=()=>n(typeof i.result=="string"?i.result:""),i.onerror=()=>r(i.error||new Error("Failed to read clipboard image.")),i.readAsDataURL(e)}),[]),I=a.useCallback(()=>{tt.current!==null&&(window.clearTimeout(tt.current),tt.current=null),st.current!==null&&(window.clearTimeout(st.current),st.current=null)},[]),Oe=a.useCallback(e=>{Xe(e.title),Ve(e.globalInstruction),ae(e.annotations),L(n=>n&&e.annotations.some(r=>r.id===n)?n:e.annotations[0]?.id||null)},[]),fe=a.useCallback((e,n)=>{const r=ze(n||d||{assetId:e.baseImageAssetId,displayName:"Annotated session"}),i=nr(e,r),c=Hn(i);de.current=!0,I(),Oe(i),A.current=c,F.current=c,_t.current=null,Ae.current=!1,jt.current=null,nt.current=null,D(null),R("saved"),X(!1)},[d,Oe,I]),Wt=a.useCallback(e=>{de.current=!0,I(),se([]),$e(null),be(!1),We(!1),Xe(ze(e)),Ve(""),ae([]),L(null),A.current="",F.current="",_t.current=null,Ae.current=!1,jt.current=null,nt.current=null,Rt(null),Bt(!1),D(null),R("saved"),X(!1)},[I]),we=a.useCallback(async(e,n,r)=>{const i=ve.current;if(!i)return!0;if(e===A.current)return V.current||(D(null),R("saved")),!0;if(V.current){if(Ae.current=!0,!r?.waitForInFlight||!await V.current)return!1;const f=F.current;return f===A.current?!0:we(f,n,r)}I();const c=On(e);jt.current=i,_t.current=e,X(!0),h(null),D(null),R("saving");const p=(async()=>{try{const u=await Ce(`/api/taskforce/annotated-attachments/sessions/${encodeURIComponent(i)}?${J}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json",...E},body:JSON.stringify(c)},T),f=await u.json().catch(()=>({}));if(!u.ok)throw new Error(String(f?.error||"Failed to save session."));const v=f?.session;if(!v?.id)throw new Error("Failed to save session.");se(Vt=>{const Rn=Vt.findIndex(ys=>ys.id===v.id);if(Rn===-1)return[v,...Vt];const Pn=[...Vt];return Pn[Rn]=v,Pn}),A.current=e,nt.current=null,D(null);const k=ve.current===v.id,S=F.current,K=S!==e,ot=Ae.current||K;return Ae.current=!1,k&&!ot?(de.current=!0,Oe(c),R("saved")):!ot&&S===A.current?R("saved"):R("pending"),!0}catch(u){const f=u instanceof Error?u.message:"Failed to save session.";return h(f),D(f),R("error"),nt.current!==e&&ve.current===i&&F.current===e&&(nt.current=e,st.current=window.setTimeout(()=>{st.current=null,!(ve.current!==i||F.current!==e)&&we(e,n,{waitForInFlight:!0})},1500)),!1}finally{_t.current=null,V.current=null,jt.current=null,X(!1)}})();V.current=p;const j=await p;if(j){const u=F.current;if(u!==A.current)return we(u,n,r)}return j},[Oe,I,E,T,J]),_n=a.useCallback(e=>{if(ve.current){if(F.current===A.current){D(null),V.current||R("saved");return}U!=="saving"&&R("pending"),I(),tt.current=window.setTimeout(()=>{tt.current=null,we(F.current,"structure")},e)}},[I,we,U]),Y=a.useCallback(e=>{Dt.current=e},[]),H=a.useCallback(async e=>{I();const n=F.current;return!ve.current||n===A.current?(D(null),V.current||R("saved"),!0):we(n,e,{waitForInFlight:!0})},[I,we]),qn=a.useCallback(()=>{const e=A.current;e&&(I(),de.current=!0,Oe(On(e)),D(null),R("saved"),h(null))},[Oe,I]),Q=a.useCallback(async(e,n)=>{const r=typeof performance<"u"?performance.now():Date.now(),i=JSON.stringify({targetKey:rt(e),requestedSessionId:n?.requestedSessionId??null,autoCreateIfEmpty:n?.autoCreateIfEmpty===!0});if(vt.current===i)return;const c=xe.current+1;xe.current=c,vt.current=i,on(!0),h(null);try{const p=new URLSearchParams;g&&p.set("workspaceId",g),e.taskId&&p.set("taskId",e.taskId),p.set("imageAssetId",e.assetId);const j=await Ce(`/api/taskforce/annotated-attachments/sessions?${p.toString()}`,{credentials:"include",headers:E,cache:"no-store"},T),u=await j.json().catch(()=>({}));if(!j.ok)throw new Error(String(u?.error||"Failed to load annotated attachment sessions."));const f=Array.isArray(u?.sessions)?u.sessions:[];if(Ct("annotated_sessions_loaded",{assetId:e.assetId,taskId:e.taskId||null,requestedSessionId:n?.requestedSessionId??null,autoCreateIfEmpty:n?.autoCreateIfEmpty===!0,sessionCount:f.length,durationMs:Math.round((typeof performance<"u"?performance.now():Date.now())-r),serverTiming:typeof j.headers?.get=="function"&&j.headers.get("server-timing")||null}),f.length===0&&n?.autoCreateIfEmpty&&String(e.assetId||"").trim()){const S=n?.requestedSessionId??ge.current;if(ge.current=null,S&&h("The previously selected annotation session could not be restored."),xe.current!==c)return;const K=await wt(e);if(Ct("annotated_sessions_auto_created_after_empty_load",{assetId:e.assetId,taskId:e.taskId||null,sessionId:K.id,totalDurationMs:Math.round((typeof performance<"u"?performance.now():Date.now())-r)}),xe.current!==c)return;se([K]),$e(K.id),be(!1),fe(K,e);return}if(xe.current!==c)return;se(f),be(f.length===0);const v=n?.requestedSessionId??ge.current;ge.current=null;const k=f.find(S=>S.id===v)||f[0]||null;v&&!k&&h("The previously selected annotation session could not be restored."),$e(k?.id||null),k?fe(k,e):(de.current=!0,I(),Xe(ze(e)),Ve(""),ae([]),L(null),A.current="",F.current="",D(null),R("saved"))}catch(p){if(xe.current!==c)return;h(p instanceof Error?p.message:"Failed to load sessions.")}finally{vt.current===i&&(vt.current=null),xe.current===c&&on(!1)}},[I,wt,E,T,fe,g]),Jn=a.useCallback(async()=>{if(typeof navigator>"u"||!navigator.clipboard||typeof navigator.clipboard.read!="function"){h("Clipboard image paste is not supported in this environment.");return}fn(!0),h(null),hn.current=Date.now()+2e3;try{const n=(await navigator.clipboard.read()).find(v=>v.types.some(k=>k.startsWith("image/"))),r=n?.types.find(v=>v.startsWith("image/"))||"";if(!n||!r)throw new Error("No image found on the clipboard.");const i=await n.getType(r),c=await vn(i);if(!c)throw new Error("Failed to read clipboard image.");const p=r==="image/jpeg"?"jpg":r==="image/webp"?"webp":r==="image/gif"?"gif":"png",j=await fetch("/api/taskforce/context-upload",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",...E},body:JSON.stringify({file:c,originalName:`pasted-image.${p}`,workspaceId:String(g||"default").trim()||"default"})}),u=await j.json().catch(()=>({}));if(!j.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 f={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"};ge.current=null,je?(ye.current="",ie?.(f,{sessionId:null})):(pe(f),ye.current=rt(f),Q(f,{autoCreateIfEmpty:!0}))}catch(e){h(e instanceof Error?e.message:"Failed to paste image.")}finally{fn(!1)}},[je,Q,ie,vn,E,g]),Zn=a.useCallback(async()=>{const e=Mt.trim();if(!e){h("Enter an image reference to open.");return}un(!0),h(null);try{const n=new URLSearchParams({workspaceId:String(g||"default").trim()||"default"}),r=await Ce(`/api/taskforce/annotated-attachments/images/${encodeURIComponent(e)}?${n.toString()}`,{method:"GET",credentials:"include",headers:E}),i=await r.json().catch(()=>({}));if(!r.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};ge.current=null,ht(!1),bt(""),je?(ye.current="",ie?.(c,{sessionId:null})):(pe(c),ye.current=rt(c),Q(c,{autoCreateIfEmpty:!0}))}catch(n){h(n instanceof Error?n.message:"Failed to open image reference.")}finally{un(!1)}},[je,Q,ie,Mt,E,g]),jn=a.useCallback(e=>{se(n=>{const r=n.findIndex(c=>c.id===e.id);if(r===-1)return[e,...n];const i=[...n];return i[r]=e,i}),$e(e.id),fe(e,d)},[d,fe]),kn=a.useCallback(e=>{se(n=>{const r=n.filter(c=>c.id!==e),i=r[0]||null;return $e(i?.id||null),i?fe(i,d):(de.current=!0,I(),Xe(ze(d||{displayName:"Annotated session"})),Ve(""),ae([]),L(null),A.current="",F.current="",D(null),R("saved")),r})},[d,I,fe]);a.useEffect(()=>{if(!y)return;if(je||pe(n=>n&&rt(n)===Z&&n.taskReferenceLabel===y.taskReferenceLabel&&n.imageReferenceLabel===y.imageReferenceLabel&&n.displayName===y.displayName?n:y),!w){Z&&(Z!==ye.current||ne!==xt.current)&&Z!==Ot.current&&(Wt(y),Ot.current=Z,xt.current=ne,Ct("annotated_sessions_load_deferred",{assetId:y.assetId,taskId:y.taskId||null,requestedTargetKey:Z})),me?.();return}Z&&(Z!==ye.current||ne!==xt.current)&&(Wt(y),ye.current=Z,xt.current=ne,Ot.current="",Q(y,{autoCreateIfEmpty:!0})),me?.()},[je,Q,me,ne,y,Z,Wt,M,w]),a.useEffect(()=>{d&&Ye?.({target:d,sessionId:x})},[d,Ye,x]),a.useEffect(()=>{if(!d||typeof document>"u"||!w)return;const e=()=>{Date.now()<hn.current||F.current!==A.current||W||ut||Q(d,{requestedSessionId:x})},n=()=>{document.visibilityState==="visible"&&e()};return document.addEventListener("visibilitychange",n),()=>{document.removeEventListener("visibilitychange",n)}},[d,Q,ut,W,x,w]),a.useEffect(()=>{if(!d?.path){Je(!1),Ze(!1),et({width:0,height:0});return}Je(!0),Ze(!1),et({width:0,height:0}),Ft(1),Qe(!1)},[d?.path]),a.useEffect(()=>{if(!ce)return;const e=Ht.current;!e||!e.complete||e.naturalWidth<=0||e.naturalHeight<=0||(et({width:e.naturalWidth,height:e.naturalHeight}),Je(!1),Ze(!1))},[d?.path,ce]),a.useEffect(()=>{ke||Qe(!1)},[ke]),a.useEffect(()=>{Rt(null)},[x]),a.useEffect(()=>{if(F.current=Fe,de.current){de.current=!1;return}if(!x){I(),D(null),R("saved");return}if(Fe===A.current){I(),V.current||(D(null),R("saved"));return}const e=Dt.current;if(Dt.current=null,U==="error"&&e===null)return;const n=e??600;if(V.current){Ae.current=!0,R("pending");return}_n(n)},[I,Fe,U,_n,x]),a.useEffect(()=>{x&&(V.current||Fe===A.current&&U!=="error"&&U!=="saved"&&(D(null),R("saved")))},[Fe,U,x]),a.useEffect(()=>{if(typeof window>"u")return;const e=n=>{F.current!==A.current&&(n.preventDefault(),n.returnValue="")};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[]),a.useEffect(()=>{if(typeof document>"u")return;const e=()=>{document.visibilityState==="hidden"&&H("visibility-hidden")};return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[H]),a.useEffect(()=>{if(!ct||typeof document>"u")return;const e=n=>{const r=n.target;r instanceof Node&&(bn.current?.contains(r)||dt(!1))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[ct]),a.useEffect(()=>{if(!$t||typeof document>"u")return;const e=n=>{const r=n.target;r instanceof Node&&(gn.current?.contains(r)||We(!1))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[$t]),a.useEffect(()=>()=>{I()},[I]),a.useEffect(()=>{if(!le)return;const e=window.setTimeout(()=>Pt(!1),2e3);return()=>window.clearTimeout(e)},[le]),a.useEffect(()=>{if(!mt)return;const e=window.setTimeout(()=>At(!1),2e3);return()=>window.clearTimeout(e)},[mt]),a.useEffect(()=>{if(!pt)return;const e=window.setTimeout(()=>Et(!1),2e3);return()=>window.clearTimeout(e)},[pt]);const ee=a.useCallback((e,n,r=300)=>{ae(i=>Ie(i.map(c=>c.id===e?n(c):c))),Y(r)},[Y]),Qn=a.useCallback(e=>{z&&(ee(z.id,n=>({...n,color:e})),an(e),dt(!1))},[z,ee]),wn=a.useCallback(async()=>{if(!(!d||!await H("session-switch"))){X(!0),h(null);try{const n=await wt(d);be(!1),await Q(d,{requestedSessionId:n.id,autoCreateIfEmpty:!1}),Be("select")}catch(n){h(n instanceof Error?n.message:"Failed to create session."),be(!0)}finally{X(!1)}}},[d,wt,H,Q]),es=a.useCallback(e=>{if(e!=="select"&&!B){Qe(!1),h("No session exists for this image yet."),be(!0);return}h(null),be(!1),Qe(!1),Be(e)},[B]),ts=a.useCallback(async()=>{if(!(!d||!B||!await H("duplicate"))){X(!0),h(null);try{const n=Ie(N.map((p,j)=>Xo(p,j))),r=await Ce(`/api/taskforce/annotated-attachments/sessions?${J}`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",...E},body:JSON.stringify({taskId:d.taskId,baseImageAssetId:d.assetId,title:Vo(Re||B.title,d),globalInstruction:Pe,annotations:n})},T),i=await r.json().catch(()=>({}));if(!r.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.");jn(c),Be("select")}catch(n){h(n instanceof Error?n.message:"Failed to duplicate session.")}finally{X(!1)}}},[d,N,Pe,Re,jn,H,E,T,B,J]),ns=a.useCallback(async()=>H("manual"),[H]),Cn=a.useCallback(async()=>{if(x){ln(!0),h(null);try{const e=await Ce(`/api/taskforce/annotated-attachments/sessions/${encodeURIComponent(x)}/payload?${J}`,{credentials:"include",headers:E},T),n=await e.json().catch(()=>({}));if(!e.ok)throw new Error(String(n?.error||"Failed to load payload preview."));Rt(n?.payload||null)}catch(e){h(e instanceof Error?e.message:"Failed to load payload preview.")}finally{ln(!1)}}},[E,T,x,J]),ss=a.useCallback(()=>{x&&H("payload-preview").then(e=>{e&&(Bt(!0),Cn())})},[H,Cn,x]),In=a.useCallback(async e=>{if(!oe||!navigator.clipboard||typeof navigator.clipboard.writeText!="function"){h("Clipboard copy is not available in this browser.");return}try{const n=e==="json"?JSON.stringify(oe,null,2):Fn(oe);await navigator.clipboard.writeText(n),Pt(e)}catch(n){h(n instanceof Error?n.message:"Failed to copy payload content."),Pt(!1)}},[oe]),as=a.useCallback(async()=>{if(!kt||!navigator.clipboard||typeof navigator.clipboard.writeText!="function"){h("Clipboard copy is not available in this browser.");return}try{await navigator.clipboard.writeText(kt),At(!0)}catch(e){h(e instanceof Error?e.message:"Failed to copy task id."),At(!1)}},[kt]),os=a.useCallback(async()=>{if(!at||!navigator.clipboard||typeof navigator.clipboard.writeText!="function"){h("Clipboard copy is not available in this browser.");return}try{await navigator.clipboard.writeText(at),Et(!0)}catch(e){h(e instanceof Error?e.message:"Failed to copy image reference."),Et(!1)}},[at]),rs=a.useCallback(async()=>{if(!x||!await H("delete-session"))return;const n=(B?.title||"Untitled session").trim()||"Untitled session";if(window.confirm(`Delete the annotated attachment session "${n}"?`)){X(!0),h(null);try{const r=await Ce(`/api/taskforce/annotated-attachments/sessions/${encodeURIComponent(x)}?${J}`,{method:"DELETE",credentials:"include",headers:E},T),i=await r.json().catch(()=>({}));if(!r.ok)throw new Error(String(i?.error||"Failed to delete session."));kn(x),Be("select")}catch(r){h(r instanceof Error?r.message:"Failed to delete session.")}finally{X(!1)}}},[H,kn,E,T,B,x,J]),Xt=a.useCallback(()=>{C&&(ae(e=>Ie(e.filter(n=>n.id!==C))),L(null),Y(300))},[Y,C]),De=a.useCallback(e=>{const n=tr(e),r=Te.current;if(!r||n===P){Ft(n);return}const i=(r.scrollLeft+r.clientWidth/2)*(n/P)-r.clientWidth/2,c=(r.scrollTop+r.clientHeight/2)*(n/P)-r.clientHeight/2;Ft(n),window.requestAnimationFrame(()=>{r.scrollLeft=Math.max(0,i),r.scrollTop=Math.max(0,c)})},[P]),is=a.useCallback(()=>{De(P+.25)},[De,P]),ls=a.useCallback(()=>{De(P-.25)},[De,P]),cs=a.useCallback(()=>{De(1);const e=Te.current;e&&window.requestAnimationFrame(()=>{e.scrollLeft=0,e.scrollTop=0})},[De]),Sn=a.useCallback(e=>{C&&ae(n=>{const r=n.findIndex(c=>c.id===C);if(r===-1)return n;const i=e==="up"?r-1:r+1;return i<0||i>=n.length?n:(Y(300),qo(n,r,i))})},[Y,C]);a.useEffect(()=>{if(!C)return;const e=n=>{n.key==="Delete"&&(Go(n.target)||(n.preventDefault(),Xt()))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[Xt,C]);const O=a.useCallback(e=>{const n=mn.current?.getBoundingClientRect();return!n||n.width<=0||n.height<=0?null:{x:_((e.clientX-n.left)/n.width),y:_((e.clientY-n.top)/n.height)}},[]),ds=a.useCallback(e=>{if(G&&ke){const i=Te.current;if(!i)return;q.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(!x)return;if($==="select"){L(null);return}const n=O(e);if(!n)return;if($==="pin"||$==="text-note"){const i=Ln($,n,n,lt);ae(c=>Ie([...c,i])),L(i.id),Y(300),Be("select");return}_e.current=n;const r=Ln($,n,n,lt);ue.current={annotationId:r.id,kind:$},e.currentTarget.setPointerCapture?.(e.pointerId),ae(i=>Ie([...i,r])),L(r.id),Y(300)},[ke,lt,Y,G,O,x,$]),us=a.useCallback(e=>{if(q.current?.pointerId===e.pointerId){e.currentTarget.releasePointerCapture?.(e.pointerId);return}if(!_e.current||!ue.current||$!=="box"&&$!=="arrow")return;const n=O(e);_e.current=null,ue.current=null,e.currentTarget.releasePointerCapture?.(e.pointerId),n&&Be("select")},[O,$]),Nn=a.useCallback((e,n)=>{if($!=="select"||G)return;const r=O(e);r&&(Ee.current={annotationId:n.id,originPointer:r,originAnnotation:n},L(n.id),e.stopPropagation())},[G,O,$]),fs=a.useCallback(e=>{if(q.current?.pointerId===e.pointerId){const u=Te.current;if(!u)return;const f=e.clientX-q.current.startX,v=e.clientY-q.current.startY;u.scrollLeft=q.current.scrollLeft-f,u.scrollTop=q.current.scrollTop-v;return}if(ue.current&&_e.current){const u=O(e);if(!u)return;const{annotationId:f,kind:v}=ue.current,k=_e.current;ee(f,S=>v==="box"&&S.kind==="box"?{...S,x:_(Math.min(k.x,u.x)),y:_(Math.min(k.y,u.y)),width:Se(Math.abs(u.x-k.x)),height:Se(Math.abs(u.y-k.y))}:v==="arrow"&&S.kind==="arrow"?{...S,x:k.x,y:k.y,x2:u.x,y2:u.y}:S);return}if(Me.current){const u=O(e);if(!u)return;const{annotationId:f,originPointer:v,originAnnotation:k}=Me.current,S=u.x-v.x,K=u.y-v.y;ee(f,()=>({...k,width:Se(k.width+S),height:Se(k.height+K)}));return}if(Le.current){const u=O(e);if(!u)return;const{annotationId:f,endpoint:v,originPointer:k,originAnnotation:S}=Le.current,K=u.x-k.x,ot=u.y-k.y;ee(f,()=>v==="tail"?{...S,x:_(S.x+K),y:_(S.y+ot)}:{...S,x2:_(S.x2+K),y2:_(S.y2+ot)});return}if(!Ee.current)return;const n=O(e);if(!n)return;const{annotationId:r,originPointer:i,originAnnotation:c}=Ee.current,p=n.x-i.x,j=n.y-i.y;ee(r,()=>c.kind==="pin"||c.kind==="text-note"?{...c,x:_(c.x+p),y:_(c.y+j)}:c.kind==="box"?{...c,x:_(c.x+p),y:_(c.y+j)}:{...c,x:_(c.x+p),y:_(c.y+j),x2:_(c.x2+p),y2:_(c.y2+j)})},[O,ee]),ms=a.useCallback(()=>{_e.current=null,Ee.current=null,Me.current=null,Le.current=null,ue.current=null,q.current=null},[]),ps=a.useCallback(()=>{_e.current=null,Ee.current=null,Me.current=null,Le.current=null,ue.current=null,q.current=null},[]),hs=a.useCallback(()=>{Ee.current=null,Me.current=null,Le.current=null,ue.current=null,q.current=null},[]),bs=a.useCallback((e,n)=>{if($!=="select"||G)return;const r=O(e);r&&(Me.current={annotationId:n.id,originPointer:r,originAnnotation:n},L(n.id),e.stopPropagation())},[G,O,$]),$n=a.useCallback((e,n,r)=>{if($!=="select"||G)return;const i=O(e);i&&(Le.current={annotationId:n.id,originPointer:i,originAnnotation:n,endpoint:r},L(n.id),e.stopPropagation())},[G,O,$]),gs=B?.updatedAt?Qt(B.updatedAt):"Not saved yet";return t.jsxs("div",{className:s.shell,children:[t.jsxs("section",{className:`tf-surface-panel ${s.panel} ${s.sessionPanel}`,children:[t.jsx("div",{className:s.sessionContextBar,children:d?.taskId?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:s.sessionContextLeft,children:Ne?t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${s.ghostBtn} ${s.backToTaskBtn}`,onClick:()=>{H("back-to-task").then(e=>{e&&d.taskId&&Ne(d.taskId)})},"aria-label":"Back to task",title:"Back to task",children:t.jsx(_s,{size:16})}):t.jsx("div",{className:s.sessionContextSpacer,"aria-hidden":"true"})}),t.jsx("div",{className:s.sessionContextRight,children:t.jsx(vs,{copied:mt,onClick:()=>{as()},title:"Copy task id",ariaLabel:mt?"Copied task id":"Copy task id",label:kt})})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:s.sessionContextLeft,children:t.jsx("span",{className:`tf-label-micro ${s.sessionContextLabel}`,children:"Unattached Image"})}),t.jsx("div",{className:s.sessionContextRight,children:t.jsx("div",{className:s.sessionContextSpacer,"aria-hidden":"true"})})]})}),t.jsxs("div",{className:s.panelHeader,children:[t.jsxs("div",{className:s.panelHeaderText,children:[t.jsx("div",{className:`tf-heading-card ${s.panelTitle}`,children:"Sessions"}),d?null:t.jsx("div",{className:"tf-text-secondary",children:"Open an image attachment to begin"})]}),t.jsx("div",{className:s.sessionActions,children:t.jsx("button",{type:"button",className:`tf-control-icon ${s.iconButton}`,onClick:()=>{wn()},disabled:!d||W,"aria-label":"Create session",title:"Create session",children:t.jsx(js,{size:16})})})]}),d?ut?t.jsx("div",{className:s.emptyState,children:t.jsx("p",{className:"tf-empty-copy",children:"Loading sessions…"})}):t.jsx("div",{className:`tf-scrollbar ${s.sessionList}`,children:he.length===0?t.jsxs("div",{className:s.sessionEmptyState,children:[t.jsx("div",{className:`tf-heading-card ${s.sessionTitle}`,children:"No sessions yet"}),t.jsx("div",{className:`tf-text-secondary ${s.annotationSummary}`,children:"Create the first annotation session for this image."})]}):he.map(e=>{const n=x===e.id,r=n&&$t,i=Yo(n?Pe:e.globalInstruction),c=(n?Re:e.title)||"Untitled session";return t.jsxs("div",{className:`tf-surface-elevated ${s.sessionCard} ${n?s.sessionCardActive:""}`,ref:n?gn:void 0,onBlur:r?p=>{const j=p.relatedTarget;j instanceof Node&&p.currentTarget.contains(j)||We(!1)}:void 0,children:[r?t.jsxs("div",{className:s.sessionCardBody,children:[t.jsxs("div",{className:s.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 ${s.textInput} ${s.sessionTitleInput}`,value:Re,onChange:p=>{Xe(p.target.value),Y(600)},placeholder:"Session title"}),t.jsx("span",{className:`tf-text-meta ${s.sessionTimestamp}`,children:Qt(e.updatedAt)})]}),St(e)?t.jsxs("div",{className:`tf-text-secondary ${s.sessionCreator}`,children:["Created by ",St(e)]}):null,t.jsxs("div",{className:s.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 ${s.textArea} ${s.sessionInstructionField}`,value:Pe,onChange:p=>{Ve(p.target.value),Y(600)},placeholder:"Add overall instructions, context, or framing for this session."})]}),t.jsxs("div",{className:`tf-text-secondary ${s.annotationSummary}`,children:[e.annotations.length," annotation",e.annotations.length===1?"":"s"]})]}):t.jsxs("button",{type:"button",className:s.sessionCardButton,onClick:()=>{if(n){We(!0);return}H("session-switch").then(p=>{p&&($e(e.id),fe(e,d))})},"aria-pressed":n,children:[t.jsxs("div",{className:s.sessionMeta,children:[t.jsx("span",{className:`tf-heading-card ${s.sessionTitle}`,children:c}),t.jsx("span",{className:`tf-text-meta ${s.sessionTimestamp}`,children:Qt(e.updatedAt)})]}),St(e)?t.jsxs("div",{className:`tf-text-secondary ${s.sessionCreator}`,children:["Created by ",St(e)]}):null,i?t.jsx("div",{className:`tf-text-secondary ${s.sessionInstructionPreview}`,children:i}):null,t.jsxs("div",{className:`tf-text-secondary ${s.annotationSummary}`,children:[e.annotations.length," annotation",e.annotations.length===1?"":"s"]})]}),n?t.jsx("div",{className:s.sessionCardFooter,children:t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:`tf-button-ghost ${s.toolRailButton} ${s.iconButton}`,onClick:()=>{ts()},disabled:W,"aria-label":"Duplicate session",title:`Duplicate session "${c}"`,children:t.jsx(Zt,{size:16})}),t.jsx("button",{type:"button",className:`tf-button-ghost ${s.toolRailButton} ${s.iconButton}`,onClick:()=>{rs()},disabled:W,"aria-label":"Delete session",title:`Delete session "${c}"`,children:t.jsx(Tn,{size:16})})]})}):null]},e.id)})}):t.jsxs("div",{className:s.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 ${s.panel} ${s.canvasPanel}`,children:[t.jsxs("div",{className:s.panelHeader,children:[t.jsxs("div",{className:s.canvasHeading,children:[t.jsx("div",{className:"tf-heading-card",children:d?.displayName||"Annotated attachment"}),t.jsx("div",{className:"tf-text-secondary",children:B?`${N.length} markers · ${gs}`:"Pick or create a session"})]}),at?t.jsx(Ts,{copied:pt,onClick:()=>{os()},title:"Copy image reference",ariaLabel:pt?"Copied image reference":"Copy image reference",label:at}):null]}),t.jsxs("div",{className:s.toolRail,children:[t.jsxs("div",{className:`${s.toolbarCluster} ${s.toolbarViewportCluster}`,children:[t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${s.ghostBtn} ${s.toolbarButton}`,onClick:()=>{ns()},disabled:!B||W||!xn&&U!=="error","aria-label":W?"Saving session":"Save session",title:W?"Saving session":"Save session",children:t.jsx(ks,{size:18})}),t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${s.ghostBtn} ${s.toolbarButton}`,onClick:()=>ht(!0),disabled:qe,"aria-label":"Open image",title:"Open image",children:t.jsx(ws,{size:18})}),t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${s.ghostBtn} ${s.toolbarButton}`,onClick:()=>{Jn()},disabled:gt,"aria-label":gt?"Pasting image":"Paste image",title:gt?"Pasting image":"Paste image",children:gt?t.jsx(An,{size:18,className:Bn.spin}):t.jsx(Cs,{size:18})}),t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${s.ghostBtn} ${s.toolbarButton}`,onClick:()=>{B&&qn()},disabled:!B||!xn,"aria-label":"Reset unsaved changes",title:"Reset unsaved changes",children:t.jsx(Is,{size:18})}),t.jsx("button",{type:"button",className:`tf-button-ghost ${s.toolRailButton} ${s.iconButton}`,onClick:ls,disabled:!d||ce||P<=.25,"aria-label":"Zoom out",children:t.jsx(Ss,{size:18})}),t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${s.ghostBtn} ${s.toolbarButton}`,onClick:cs,disabled:!d||ce||P===1,"aria-label":`Reset zoom to 100 percent (currently ${Yt})`,title:`Reset zoom to 100% (currently ${Yt})`,children:t.jsx("span",{children:Yt})}),t.jsx("button",{type:"button",className:`tf-button-ghost ${s.toolRailButton} ${s.iconButton}`,onClick:is,disabled:!d||ce||P>=4,"aria-label":"Zoom in",children:t.jsx(Ns,{size:18})}),t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${s.toolBtn} ${s.toolbarButton} ${G?s.toolBtnActive:""}`,onClick:()=>Qe(e=>!e),disabled:!d||ce||!ke,"aria-label":"Pan canvas",title:"Pan canvas",children:t.jsx($s,{size:18})})]}),t.jsx("span",{className:s.toolbarSeparator,"aria-hidden":"true"}),t.jsxs("div",{className:s.toolbarActions,children:[t.jsx("div",{className:s.toolbarSelectionActions,children:z?t.jsxs(t.Fragment,{children:[t.jsxs("div",{ref:bn,className:s.toolbarColorPicker,children:[t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${s.ghostBtn} ${s.toolbarButton} ${s.colorPickerButton}`,onClick:()=>dt(e=>!e),"aria-label":"Marker color","aria-expanded":ct,title:"Marker color",children:t.jsx("span",{className:s.colorPickerSwatch,style:{backgroundColor:Ut},"aria-hidden":"true"})}),ct?t.jsx("div",{className:s.colorPickerPopover,role:"menu","aria-label":"Marker color options",children:Uo.map(e=>t.jsx("button",{type:"button",className:`${s.colorOption} ${Ut===e?s.colorOptionActive:""}`,style:{backgroundColor:e},onClick:()=>Qn(e),"aria-label":`Use marker color ${e}`,"aria-pressed":Ut===e},e))}):null]}),t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${s.ghostBtn} ${s.toolbarButton}`,onClick:Xt,"aria-label":"Delete marker",title:"Delete selected marker",children:t.jsx(Tn,{size:18})}),t.jsx("div",{className:s.toolbarGeometryFields,"aria-label":"Marker geometry percent controls",children:Qo(z).map(e=>t.jsxs("label",{className:s.toolbarGeometryField,children:[t.jsx("span",{className:`tf-text-meta ${s.toolbarGeometryLabel}`,children:e.label}),t.jsx("input",{className:`tf-field-shell ${s.toolbarGeometryInput}`,type:"number",min:0,max:100,step:.1,value:e.value,onChange:n=>{const r=Jo(n.target.value);r!==null&&ee(z.id,i=>Zo(i,e.key,r))},"aria-label":`${e.label} percent`})]},e.key))})]}):null}),t.jsxs("div",{className:s.toolbarUtilities,children:[t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${s.ghostBtn} ${s.payloadBtn} ${s.toolbarButton}`,onClick:ss,disabled:!B||ft,"aria-label":ft?"Loading payload preview":"Preview payload",title:ft?"Loading payload preview":"Preview payload",children:t.jsx(tn,{size:18})}),t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${s.ghostBtn} ${s.toolbarButton}`,onClick:()=>dn(!0),"aria-label":"How to use marker tools",title:"How to use marker tools",children:t.jsx(nn,{size:18})})]})]})]}),t.jsxs("div",{className:s.canvasWorkspace,children:[t.jsx("div",{className:s.canvasToolRail,"aria-label":"Annotation tools",children:Mn.map(e=>{const n=e.icon;return t.jsx("button",{type:"button",className:`tf-button-ghost ${s.toolRailButton} ${$===e.value?s.toolBtnActive:""}`,onClick:()=>es(e.value),disabled:!d,title:e.label,"aria-label":`${e.label} tool. ${It[e.value].short}`,children:t.jsx(n,{size:18})},e.value)})}),t.jsx("div",{className:s.canvasMain,children:t.jsx("div",{ref:Te,className:`tf-scrollbar ${s.canvasScroller}`,children:d?t.jsxs(t.Fragment,{children:[ce&&!Lt?t.jsx("div",{className:s.canvasStatusOverlay,"aria-live":"polite",children:t.jsxs("div",{className:s.canvasStatusCard,children:[t.jsx(An,{size:20,className:Bn.spinner}),t.jsx("span",{children:"Loading image…"})]})}):null,Lt?t.jsx("div",{className:s.canvasStatusOverlay,"aria-live":"polite",children:t.jsx("div",{className:s.canvasStatusCard,children:t.jsx("span",{children:"Image failed to load."})})}):null,t.jsx("div",{className:s.canvasFrame,children:t.jsxs("div",{className:s.canvasMedia,style:{width:b.width?`${b.width}px`:void 0,height:b.height?`${b.height}px`:void 0},children:[t.jsx("img",{ref:Ht,src:d.path,alt:d.displayName,className:s.canvasImage,onLoad:()=>{const e=Ht.current;et({width:e?.naturalWidth||0,height:e?.naturalHeight||0}),Je(!1),Ze(!1)},onError:()=>{et({width:0,height:0}),Je(!1),Ze(!0)}}),!ce&&!Lt&&B?t.jsxs("div",{ref:mn,className:`${s.overlay} ${$==="select"?s.overlaySelect:""} ${G&&ke?s.overlayPan:""}`,onPointerDown:ds,onPointerMove:fs,onPointerUp:e=>{us(e),hs()},"data-testid":"annotated-attachment-overlay",onPointerLeave:ms,onPointerCancel:ps,children:[t.jsx("svg",{className:s.overlaySvg,viewBox:Gt,preserveAspectRatio:"none","aria-hidden":"true",children:N.filter(e=>e.kind==="arrow").map(e=>{const n=Ko(e,b),r=en(e),i=C===e.id;return t.jsxs(qt.Fragment,{children:[i?t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:n.shaftX1,y1:n.shaftY1,x2:n.shaftX2,y2:n.shaftY2,stroke:"color-mix(in srgb, var(--surface-elevated) 92%, transparent)",strokeWidth:14,strokeLinecap:"round"}),t.jsx("polygon",{points:n.headPoints,fill:r,stroke:"color-mix(in srgb, var(--surface-elevated) 92%, transparent)",strokeWidth:4,strokeLinejoin:"round"})]}):null,t.jsx("line",{x1:n.shaftX1,y1:n.shaftY1,x2:n.shaftX2,y2:n.shaftY2,stroke:r,strokeWidth:i?10:6,strokeLinecap:"round"}),t.jsx("polygon",{points:n.headPoints,fill:r})]},e.id)})}),t.jsx("svg",{className:s.overlayHitLayer,viewBox:Gt,preserveAspectRatio:"none",children:N.filter(e=>e.kind==="arrow").map(e=>t.jsxs(qt.Fragment,{children:[t.jsx("line",{x1:e.x*b.width,y1:e.y*b.height,x2:e.x2*b.width,y2:e.y2*b.height,className:s.arrowHitArea,"data-testid":`annotated-arrow-hit-${e.id}`,"aria-label":`Arrow marker ${Kt.get(e.id)||0}`,onPointerDown:n=>Nn(n,e),onClick:n=>{n.stopPropagation(),L(e.id)}}),C===e.id?t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:e.x*b.width,cy:e.y*b.height,r:He.hitRadius,className:s.canvasHandleHit,role:"button",tabIndex:0,"aria-label":"Move arrow tail",onPointerDown:n=>$n(n,e,"tail")}),t.jsx("circle",{cx:e.x*b.width,cy:e.y*b.height,r:He.visibleRadius,className:s.canvasHandleVisible,"aria-hidden":"true"}),t.jsx("circle",{cx:e.x2*b.width,cy:e.y2*b.height,r:He.hitRadius,className:s.canvasHandleHit,role:"button",tabIndex:0,"aria-label":"Move arrow tip",onPointerDown:n=>$n(n,e,"tip")}),t.jsx("circle",{cx:e.x2*b.width,cy:e.y2*b.height,r:He.visibleRadius,className:s.canvasHandleVisible,"aria-hidden":"true"})]}):null]},`hit-${e.id}`))}),N.filter(e=>e.kind==="arrow").map(e=>t.jsx("div",{className:`${s.annotationNumberBadge} ${s.arrowNumberBadge}`,style:{left:`${(e.x+e.x2)/2*100}%`,top:`${(e.y+e.y2)/2*100}%`,backgroundColor:en(e)},"aria-hidden":"true",children:Kt.get(e.id)||0},`arrow-number-${e.id}`)),N.filter(e=>e.kind!=="arrow").map(e=>{const n=en(e),r=Kt.get(e.id)||0,i={onPointerDown:c=>Nn(c,e),onClick:c=>{c.stopPropagation(),L(e.id)}};return e.kind==="pin"?t.jsx("button",{type:"button",...i,className:`${s.pin} ${C===e.id?s.selected:""}`,style:{left:`${e.x*100}%`,top:`${e.y*100}%`,backgroundColor:n},children:r},e.id):e.kind==="text-note"?t.jsx("button",{type:"button",...i,className:`${s.note} ${C===e.id?s.selected:""}`,style:{left:`${e.x*100}%`,top:`${e.y*100}%`,backgroundColor:n},children:r},e.id):t.jsxs("div",{className:`${s.box} ${C===e.id?s.selected:""}`,style:{left:`${e.x*100}%`,top:`${e.y*100}%`,width:`${e.width*100}%`,height:`${e.height*100}%`,borderColor:n},children:[t.jsx("span",{className:`${s.annotationNumberBadge} ${s.boxNumberBadge}`,style:{backgroundColor:n},"aria-hidden":"true",children:r}),t.jsx("button",{type:"button",...i,className:s.boxSurface,"aria-label":`Box marker ${r}`})]},e.id)}),t.jsx("svg",{className:s.overlaySvg,viewBox:Gt,preserveAspectRatio:"none",children:N.filter(e=>e.kind==="box"&&C===e.id).map(e=>t.jsxs(qt.Fragment,{children:[t.jsx("circle",{cx:(e.x+e.width)*b.width,cy:(e.y+e.height)*b.height,r:He.hitRadius,className:`${s.canvasHandleHit} ${s.canvasResizeHandleHit}`,role:"button",tabIndex:0,"aria-label":"Resize box marker",onPointerDown:n=>bs(n,e)}),t.jsx("circle",{cx:(e.x+e.width)*b.width,cy:(e.y+e.height)*b.height,r:He.visibleRadius,className:s.canvasHandleVisible,"aria-hidden":"true"})]},`box-handle-${e.id}`))})]}):null]})})]}):t.jsx("div",{className:s.emptyState,children:t.jsx("p",{className:"tf-empty-copy",children:"Select an image attachment to annotate."})})})})]}),t.jsxs("div",{className:s.statusBar,children:[t.jsx("span",{children:U==="error"?"Save failed. Retry now.":U==="saving"||U==="pending"?"Saving…":"Saved"}),rn?t.jsx("span",{children:rn}):t.jsx("span",{children:B?G&&ke?"Drag on the image to pan.":$==="select"?"Select a marker to edit it.":`Click on the image to place a ${$}.`:"Create a session to begin placing markers on this image."}),d&&!B&&Kn?t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${s.ghostBtn} ${s.toolbarButton}`,onClick:()=>{wn()},disabled:W||ut,children:W?"Creating…":"Create one now"}):null]})]}),t.jsx("section",{className:`tf-surface-panel ${s.panel} ${s.detailPanel}`,children:B?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:s.panelHeader,children:[t.jsxs("div",{className:s.panelHeaderText,children:[t.jsx("div",{className:`tf-heading-card ${s.panelTitle}`,children:"Markers"}),t.jsxs("div",{className:"tf-text-secondary",children:[N.length," in this session"]})]}),t.jsxs("div",{className:s.sessionActions,children:[t.jsx("button",{type:"button",className:`tf-control-icon ${s.iconButton}`,onClick:()=>Sn("up"),disabled:!z||zt<=0,"aria-label":"Move marker up",children:t.jsx(Ps,{size:16})}),t.jsx("button",{type:"button",className:`tf-control-icon ${s.iconButton}`,onClick:()=>Sn("down"),disabled:!z||zt===-1||zt>=N.length-1,"aria-label":"Move marker down",children:t.jsx(Bs,{size:16})})]})]}),t.jsx("div",{className:`tf-scrollbar ${s.annotationList}`,children:N.length===0?t.jsx("div",{className:s.detailEmpty,children:t.jsx("p",{className:"tf-empty-copy",children:"Add a marker on the image to begin."})}):N.map((e,n)=>{const r=Oo[e.kind],i=Do[e.kind],c=`${i} ${n+1}`,p=zo[e.markerType||re],j=En.find(f=>f.value===(e.markerType||re))?.label||"Review",u=C===e.id;return t.jsxs("div",{className:`tf-surface-elevated ${s.annotationCard} ${u?s.annotationCardActive:""}`,children:[t.jsx("button",{type:"button",className:s.annotationCardButton,onClick:()=>L(e.id),"aria-label":i,children:t.jsxs("div",{className:s.annotationMeta,children:[t.jsx("span",{className:`tf-heading-card ${s.annotationTitle}`,children:c}),t.jsx("span",{className:`tf-text-meta ${s.annotationKind}`,"aria-hidden":"true",children:t.jsx(r,{size:16})})]})}),u?t.jsxs("div",{className:s.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?pn:null,className:`tf-field-shell ${s.textArea} ${s.annotationInstructionField}`,value:e.instruction,onChange:f=>{ee(e.id,v=>({...v,instruction:f.target.value}),600)},onBlur:()=>{H("text")},placeholder:"What should the AI focus on for this marker?"}),t.jsxs("div",{className:s.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 ${s.select}`,value:e.markerType||re,onChange:f=>{ee(e.id,v=>Wo(v,f.target.value))},children:En.map(f=>t.jsx("option",{value:f.value,children:f.label},f.value))})]})]}):t.jsx("button",{type:"button",className:s.annotationInstructionButton,onClick:()=>L(e.id),"aria-label":`Edit ${i} instruction`,children:t.jsxs("div",{className:s.annotationInstructionEditor,children:[t.jsx("div",{className:`tf-text-secondary ${s.annotationInstructionPreview}`,children:e.instruction.trim()||"No marker instruction yet."}),t.jsx("div",{className:s.annotationPreviewFooter,children:t.jsx("span",{className:`tf-text-meta ${s.annotationInstructionTypeIcon}`,"aria-label":`Instruction type: ${j}`,title:j,children:t.jsx(p,{size:16})})})]})})]},e.id)})})]}):t.jsxs("div",{className:s.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(Jt,{isOpen:Vn,onClose:()=>{qe||(ht(!1),bt(""))},title:"Open Image",size:"sm",children:t.jsxs("form",{className:s.openImageModalBody,onSubmit:e=>{e.preventDefault(),Zn()},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 ${s.textInput} ${s.openImageField}`,value:Mt,onChange:e=>bt(e.target.value),placeholder:"I-24",autoFocus:!0}),t.jsxs("div",{className:s.openImageActions,children:[t.jsx("button",{type:"button",className:"tf-button-ghost tf-button-compact",onClick:()=>{ht(!1),bt("")},disabled:qe,children:"Cancel"}),t.jsx("button",{type:"submit",className:"tf-button-primary tf-button-compact",disabled:qe,children:qe?"Opening…":"Open"})]})]})}),t.jsx(Jt,{isOpen:Xn,onClose:()=>dn(!1),title:"How To Use Markers",size:"md",children:t.jsx("div",{className:s.markerHelpModalBody,children:Mn.filter(e=>e.value!=="select").map(e=>t.jsxs("div",{className:`tf-surface-inset ${s.markerHelpItem}`,children:[t.jsxs("div",{className:s.markerHelpHeader,children:[t.jsx("strong",{className:"tf-heading-card",children:e.label}),t.jsx("span",{className:"tf-text-meta",children:It[e.value].short})]}),t.jsx("p",{className:"tf-text-secondary",children:It[e.value].detail}),t.jsx("p",{className:`tf-text-body ${s.markerHelpExample}`,children:It[e.value].example})]},e.value))})}),t.jsx(Jt,{isOpen:Wn,onClose:()=>Bt(!1),title:"AI Payload",size:"lg",children:t.jsxs("div",{className:s.payloadModalBody,children:[t.jsxs("div",{className:s.payloadModalToolbar,children:[t.jsxs("div",{className:s.payloadViewToggle,children:[t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${s.toolBtn} ${Tt==="json"?s.toolBtnActive:""}`,onClick:()=>cn("json"),children:"JSON"}),t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${s.toolBtn} ${Tt==="brief"?s.toolBtnActive:""}`,onClick:()=>cn("brief"),children:"AI Brief"})]}),t.jsxs("div",{className:s.payloadModalActions,children:[t.jsxs("button",{type:"button",className:`tf-button-ghost tf-button-compact ${s.ghostBtn}`,onClick:()=>{In("json")},disabled:!oe,"aria-label":le==="json"?"Copied JSON":"Copy JSON",title:le==="json"?"Copied JSON":"Copy JSON",children:[le==="json"?t.jsx(sn,{size:16}):t.jsx(Zt,{size:16}),t.jsx("span",{children:"JSON"})]}),t.jsxs("button",{type:"button",className:`tf-button-ghost tf-button-compact ${s.ghostBtn}`,onClick:()=>{In("brief")},disabled:!oe,"aria-label":le==="brief"?"Copied AI Brief":"Copy AI Brief",title:le==="brief"?"Copied AI Brief":"Copy AI Brief",children:[le==="brief"?t.jsx(sn,{size:16}):t.jsx(Zt,{size:16}),t.jsx("span",{children:"AI Brief"})]})]})]}),ft?t.jsx("div",{className:s.detailEmpty,children:t.jsx("p",{className:"tf-empty-copy",children:"Loading payload…"})}):oe?t.jsx("pre",{className:`tf-surface-inset tf-scrollbar ${s.payloadModalPreview}`,children:Tt==="json"?JSON.stringify(oe,null,2):Fn(oe)}):t.jsx("div",{className:s.detailEmpty,children:t.jsx("p",{className:"tf-empty-copy",children:"Load a payload preview to inspect the current session contract."})})]})})]})}export{dr as AnnotatedAttachmentWorkspaceShell};
@@ -0,0 +1,252 @@
1
+ import{j as e,r as i,s as nn,R as Ke}from"./vendor-react-CKJs5o3c.js";import{h as Re,t as P,f as L,i as yt,j as gt,k as an,m as sn,R as rn,n as B,M as on,o as bt,q as cn,s as ln}from"./index-C6k75jr8.js";import{r as dn,v as un,w as mn,l as hn,aw as fn,ax as Je,m as pn,Z as Ve,X as Et,ay as xt,e as Qe,az as At,aA as vn,aB as wn,a as yn,i as gn,aC as bn,aD as xn,aE as _n,u as Ne,aF as kn,s as Sn,aG as _t,av as Ue,D as Cn,aH as jn,T as Nn,R as Tn,aI as En,B as An,U as Rn,S as In}from"./vendor-icons-DuEd_65c.js";import{s as $n,M as Te,r as Ee}from"./vendor-markdown-BUxTU7dS.js";import"./vendor-dnd-DRzYolkg.js";import"./vendor-router-BbWMxlnO.js";const Dn="_index_18mna_1",Bn="_header_18mna_8",Ln="_title_18mna_17",Mn="_refreshBtn_18mna_26",Pn="_search_18mna_48",qn="_searchIcon_18mna_54",zn="_searchInput_18mna_63",Fn="_list_18mna_80",On="_state_18mna_89",Hn="_stateError_18mna_97",Wn="_item_18mna_104",Gn="_itemActive_18mna_124",Kn="_itemIcon_18mna_132",Un="_itemBody_18mna_142",Jn="_itemTitle_18mna_150",Vn="_itemTask_18mna_162",Qn="_itemBadge_18mna_172",Yn="_itemMeta_18mna_185",Xn="_itemMetaDetails_18mna_195",Zn="_itemMetaReference_18mna_202",E={index:Dn,header:Bn,title:Ln,refreshBtn:Mn,search:Pn,searchIcon:qn,searchInput:zn,list:Fn,state:On,stateError:Hn,item:Wn,itemActive:Gn,itemIcon:Kn,itemBody:Un,itemTitle:Jn,itemTask:Vn,itemBadge:Qn,itemMeta:Yn,itemMetaDetails:Xn,itemMetaReference:Zn};function Ye(t){let l=t;try{l=decodeURIComponent(t)}catch{l=t}return l.trim().replace(/\\/g,"/").replace(/^\/+/,"").replace(/^\.\//,"").replace(/^\.taskforce\//,"")}function ea(t,l){return!!(t===l||t.endsWith(`/${l}`)||l.endsWith(`/${t}`))}function kt(t){const l=Ye(String(t||""));if(!l)return null;const h=l.match(/(^|\/)(asset-[a-f0-9]{32})(?=[^/]*$)/i);return h?.[2]?h[2].toLowerCase():null}function Ze(t){return t.attachmentState==="attached"||t.attachmentState==="unattached"?t.attachmentState:(typeof t.attachmentCount=="number"&&Number.isFinite(t.attachmentCount)?t.attachmentCount:0)>0||t.taskId?"attached":"unattached"}function ta(t,l,h,s){const c=l.trim().toLowerCase();return t.filter(u=>{const w=`${Re(u)} ${u.originalFilename||""}`.toLowerCase(),y=c.length===0||w.includes(c),_=h.length===0||h.includes(u.docType),m=Ze(u),C=s.length===0||s.includes(m);return y&&_&&C})}function na({docType:t}){switch(t){case"implementation-plan":return e.jsx(pn,{size:13});case"review":return e.jsx(Je,{size:13});case"walkthrough":return e.jsx(fn,{size:13});default:return e.jsx(hn,{size:13})}}function aa(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/(1024*1024)).toFixed(1)}MB`}function sa(t){if(!t)return"";const l=new Date(t),s=new Date().getTime()-l.getTime(),c=Math.floor(s/(1e3*60*60*24));return c===0?"Today":c===1?"Yesterday":c<7?`${c}d ago`:c<30?`${Math.floor(c/7)}w ago`:l.toLocaleDateString()}function ra(t,l){t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),l())}function ia({documents:t,selectedDocId:l,loading:h,error:s,searchQuery:c,taskById:u,onSearchChange:p,onSelect:w,onRefresh:y,hasActiveFilters:_}){return e.jsxs("div",{className:E.index,children:[e.jsxs("div",{className:E.header,children:[e.jsxs("span",{className:E.title,children:[e.jsx(dn,{size:14}),"Documents"]}),e.jsx("button",{className:E.refreshBtn,onClick:y,title:"Refresh document list",disabled:h,children:e.jsx(un,{size:13,className:h?P.docSpinning:void 0})})]}),e.jsxs("div",{className:E.search,children:[e.jsx(mn,{size:12,className:E.searchIcon}),e.jsx("input",{type:"text",placeholder:"Search documents…",value:c,onChange:m=>p(m.target.value),className:E.searchInput})]}),e.jsxs("div",{className:`${E.list} tf-scrollbar`,children:[h&&e.jsx("div",{className:E.state,children:"Loading documents…"}),!h&&s&&e.jsx("div",{className:E.stateError,children:s}),!h&&!s&&t.length===0&&e.jsx("div",{className:E.state,children:_?"No documents match your filters.":"No documents found. Documents added as task attachments will appear here."}),!h&&t.map(m=>{const C=m.taskId?u.get(m.taskId):null,R=m.id===l,k=Re(m),A=Ze(m),q=typeof m.attachmentCount=="number"&&Number.isFinite(m.attachmentCount)?m.attachmentCount:m.taskId?1:0,I=q>1?`${q} tasks linked`:q===1?C?.title||"1 task linked":null;return e.jsxs("div",{role:"button",tabIndex:0,className:`${E.item} ${R?E.itemActive:""}`,onClick:()=>w(m),onKeyDown:M=>ra(M,()=>w(m)),children:[e.jsx("div",{className:E.itemIcon,children:e.jsx(na,{docType:m.docType})}),e.jsxs("div",{className:E.itemBody,children:[e.jsx("span",{className:E.itemTitle,title:k,children:k}),A==="unattached"&&e.jsx("span",{className:E.itemBadge,children:"Unattached"}),I&&e.jsx("span",{className:E.itemTask,title:I,children:I}),e.jsxs("span",{className:E.itemMeta,children:[e.jsxs("span",{className:E.itemMetaDetails,children:[aa(m.sizeBytes),m.updatedAt&&e.jsxs(e.Fragment,{children:[" · ",sa(m.updatedAt)]})]}),m.referenceLabel&&e.jsx("span",{className:E.itemMetaReference,children:m.referenceLabel})]})]})]},m.id)})]})]})}function Ae(t){return function(l){return $n(l,t)}}const oa="_viewer_ecebq_1",ca="_viewerMonochrome_ecebq_10",la="_metaDocumentName_ecebq_10",da="_viewerEditMode_ecebq_14",ua="_meta_ecebq_10",ma="_metaLeft_ecebq_30",ha="_metaRenameRow_ecebq_49",fa="_typeBadge_ecebq_56",pa="_typeBadgeImplementationPlan_ecebq_71",va="_typeBadgeReview_ecebq_77",wa="_typeBadgeWalkthrough_ecebq_83",ya="_metaTaskName_ecebq_89",ga="_statusBadge_ecebq_98",ba="_metaDate_ecebq_113",xa="_metaSize_ecebq_114",_a="_actions_ecebq_122",ka="_actionBtn_ecebq_129",Sa="_dangerBtn_ecebq_156",Ca="_generateBtn_ecebq_167",ja="_editBtn_ecebq_178",Na="_saveBtn_ecebq_189",Ta="_layoutToggle_ecebq_205",Ea="_layoutBtn_ecebq_213",Aa="_layoutBtnActive_ecebq_229",Ra="_saveStatus_ecebq_234",Ia="_saveStatusSaved_ecebq_241",$a="_saveStatusError_ecebq_245",Da="_unsaved_ecebq_250",Ba="_viewerContent_ecebq_256",La="_viewerBody_ecebq_265",Ma="_viewerBodyFullWidth_ecebq_273",Pa="_viewerMain_ecebq_277",qa="_reviewRail_ecebq_285",za="_printHint_ecebq_291",Fa="_reviewSection_ecebq_298",Oa="_reviewHeader_ecebq_307",Ha="_reviewTitle_ecebq_315",Wa="_reviewSubtitle_ecebq_324",Ga="_reviewControls_ecebq_331",Ka="_reviewSelect_ecebq_338",Ua="_reviewSessionMeta_ecebq_342",Ja="_reviewStatusResolved_ecebq_350",Va="_reviewSessionLabel_ecebq_356",Qa="_reviewTitleEditRow_ecebq_361",Ya="_reviewSessionTimestamp_ecebq_368",Xa="_reviewAnchorLabel_ecebq_372",Za="_reviewComposer_ecebq_378",es="_reviewAnchorChip_ecebq_385",ts="_reviewAnchorSnippet_ecebq_398",ns="_reviewAnchorClear_ecebq_403",as="_reviewCommentActions_ecebq_416",ss="_reviewCommentAction_ecebq_416",rs="_reviewCommentEditor_ecebq_437",is="_viewerState_ecebq_443",os="_viewerStateError_ecebq_450",cs="_editorArea_ecebq_457",ls="_editorPane_ecebq_464",ds="_editorLayoutSplit_ecebq_472",us="_previewPane_ecebq_473",ms="_editorLayoutEditor_ecebq_477",hs="_editorLayoutPreview_ecebq_478",fs="_editorPaneLabel_ecebq_482",ps="_editorTextarea_ecebq_494",vs="_markdownSurface_ecebq_536",ws="_attachModalBody_ecebq_745",ys="_attachModalCopy_ecebq_752",gs="_attachModalError_ecebq_759",bs="_attachTaskList_ecebq_772",xs="_attachTaskRow_ecebq_781",_s="_attachTaskTitle_ecebq_808",ks="_attachTaskMeta_ecebq_816",Ss="_attachEmptyState_ecebq_823",r={viewer:oa,viewerMonochrome:ca,metaDocumentName:la,viewerEditMode:da,meta:ua,metaLeft:ma,metaRenameRow:ha,typeBadge:fa,typeBadgeImplementationPlan:pa,typeBadgeReview:va,typeBadgeWalkthrough:wa,metaTaskName:ya,statusBadge:ga,metaDate:ba,metaSize:xa,actions:_a,actionBtn:ka,dangerBtn:Sa,generateBtn:Ca,editBtn:ja,saveBtn:Na,layoutToggle:Ta,layoutBtn:Ea,layoutBtnActive:Aa,saveStatus:Ra,saveStatusSaved:Ia,saveStatusError:$a,unsaved:Da,viewerContent:Ba,viewerBody:La,viewerBodyFullWidth:Ma,viewerMain:Pa,reviewRail:qa,printHint:za,reviewSection:Fa,reviewHeader:Oa,reviewTitle:Ha,reviewSubtitle:Wa,reviewControls:Ga,reviewSelect:Ka,reviewSessionMeta:Ua,reviewStatusResolved:Ja,reviewSessionLabel:Va,reviewTitleEditRow:Qa,reviewSessionTimestamp:Ya,reviewAnchorLabel:Xa,reviewComposer:Za,reviewAnchorChip:es,reviewAnchorSnippet:ts,reviewAnchorClear:ns,reviewCommentActions:as,reviewCommentAction:ss,reviewCommentEditor:rs,viewerState:is,viewerStateError:os,editorArea:cs,editorPane:ls,editorLayoutSplit:ds,previewPane:us,editorLayoutEditor:ms,editorLayoutPreview:hs,editorPaneLabel:fs,editorTextarea:ps,markdownSurface:vs,attachModalBody:ws,attachModalCopy:ys,attachModalError:gs,attachTaskList:bs,attachTaskRow:xs,attachTaskTitle:_s,attachTaskMeta:ks,attachEmptyState:Ss},Cs="_overlay_1unik_1",js="_modal_1unik_12",Ns="_header_1unik_16",Ts="_title_1unik_20",Es="_docName_1unik_24",As="_body_1unik_34",Rs="_state_1unik_41",Is="_stateError_1unik_52",$s="_stateDone_1unik_63",Ds="_toolbar_1unik_84",Bs="_toolbarCount_1unik_95",Ls="_toolbarActions_1unik_100",Ms="_tree_1unik_105",Ps="_taskRow_1unik_113",qs="_taskRowDimmed_1unik_126",zs="_taskCheck_1unik_130",Fs="_taskExpandBtn_1unik_139",Os="_taskExpandSpacer_1unik_155",Hs="_taskTitle_1unik_160",Ws="_taskBadge_1unik_169",Gs="_footer_1unik_179",j={overlay:Cs,modal:js,header:Ns,title:Ts,docName:Es,body:As,state:Rs,stateError:Is,stateDone:$s,toolbar:Ds,toolbarCount:Bs,toolbarActions:Ls,tree:Ms,taskRow:Ps,taskRowDimmed:qs,taskCheck:zs,taskExpandBtn:Fs,taskExpandSpacer:Os,taskTitle:Hs,taskBadge:Ws,footer:Gs},Ks={1:"Low",2:"Medium",3:"High"};function ve(t,l){return t.map(h=>({...h,selected:l,children:ve(h.children,l)}))}function Rt(t,l,h){return t.map(s=>s.idempotencyKey===l?{...s,selected:h,children:ve(s.children,h)}:{...s,children:Rt(s.children,l,h)})}function Xe(t){let l=0;for(const h of t)h.selected&&l++,l+=Xe(h.children);return l}function It({node:t,depth:l,onToggle:h}){const[s,c]=i.useState(!0),u=t.children.length>0,p=l*20;return e.jsxs("div",{children:[e.jsxs("div",{className:`${j.taskRow} ${t.selected?"":j.taskRowDimmed}`,style:{paddingLeft:`${12+p}px`},children:[e.jsx("button",{className:j.taskCheck,onClick:()=>h(t.idempotencyKey,!t.selected),title:t.selected?"Deselect":"Select",children:t.selected?e.jsx(vn,{size:14,style:{color:"var(--brand-primary-strong)"}}):e.jsx(wn,{size:14,style:{color:"var(--text-muted)"}})}),u?e.jsx("button",{className:j.taskExpandBtn,onClick:()=>c(w=>!w),children:s?e.jsx(yn,{size:12}):e.jsx(gn,{size:12})}):e.jsx("span",{className:j.taskExpandSpacer}),e.jsx("span",{className:j.taskTitle,title:t.description||void 0,children:t.title}),e.jsx("span",{className:j.taskBadge,style:{color:yt(t.type),borderColor:yt(t.type)},children:t.type}),e.jsx("span",{className:j.taskBadge,style:{color:gt(t.priority),borderColor:gt(t.priority)},children:Ks[t.priority]})]}),u&&s&&e.jsx("div",{children:t.children.map(w=>e.jsx(It,{node:w,depth:l+1,onToggle:h},w.idempotencyKey))})]})}function Us({content:t,docTitle:l,apiBaseUrl:h="",onClose:s,onGenerated:c}){const[u,p]=i.useState("preview"),[w,y]=i.useState(null),[_,m]=i.useState([]),[C,R]=i.useState(!0),[k,A]=i.useState(0),[q,I]=i.useState(null);i.useEffect(()=>{let b=!1;return R(!0),y(null),L("/api/taskforce/documents/generate-tasks/preview",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t})},h).then(N=>N.json()).then(N=>{if(!b){if(N.error)throw new Error(N.error);m(N.tasks||[]),p("preview")}}).catch(N=>{b||(y(N?.message||"Failed to parse plan"),p("error"))}).finally(()=>{b||R(!1)}),()=>{b=!0}},[t,h]);const M=i.useCallback((b,N)=>{m(D=>Rt(D,b,N))},[]),G=()=>m(b=>ve(b,!0)),X=()=>m(b=>ve(b,!1)),F=Xe(_),Z=async()=>{p("generating"),I(null);try{const b=await L("/api/taskforce/documents/generate-tasks/commit",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({tasks:_})},h),N=await b.json().catch(()=>({}));if(!b.ok)throw new Error(N.error||`Generation failed (${b.status})`);A(N.created??0),p("done"),c(N.created??0)}catch(b){I(b?.message||"Generation failed"),p("error")}};return e.jsx("div",{className:j.overlay,onClick:b=>{b.target===b.currentTarget&&s()},children:e.jsxs("div",{className:`tf-surface-modal tf-modal-shell ${j.modal}`,children:[e.jsxs("div",{className:`tf-modal-header ${j.header}`,children:[e.jsxs("div",{className:`tf-modal-title ${j.title}`,children:[e.jsx(Ve,{size:16,style:{color:"var(--brand-primary-strong)"}}),"Generate Tasks from Plan"]}),e.jsx("span",{className:j.docName,children:l}),e.jsx("button",{className:"tf-control-icon",onClick:s,title:"Close",children:e.jsx(Et,{size:16})})]}),e.jsxs("div",{className:j.body,children:[C&&e.jsxs("div",{className:j.state,children:[e.jsx(xt,{size:20,className:P.docSpinning}),"Parsing plan…"]}),!C&&u==="error"&&e.jsxs("div",{className:j.stateError,children:[e.jsx(Qe,{size:16}),w||q||"An error occurred"]}),!C&&u==="done"&&e.jsxs("div",{className:j.stateDone,children:[e.jsx(At,{size:24,style:{color:"var(--status-success)"}}),e.jsxs("strong",{children:[k," task",k!==1?"s":""," created"]}),e.jsx("p",{children:"Tasks are now in your board. Switch to the Kanban or Hierarchy view to see them."})]}),!C&&(u==="preview"||u==="confirm"||u==="generating")&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:j.toolbar,children:[e.jsxs("span",{className:j.toolbarCount,children:[F," of ",Xe(ve(_,!0))," tasks selected"]}),e.jsxs("div",{className:j.toolbarActions,children:[e.jsx("button",{className:"tf-control-icon",onClick:G,children:"Select all"}),e.jsx("button",{className:"tf-control-icon",onClick:X,children:"Deselect all"})]})]}),_.length===0?e.jsx("div",{className:j.state,children:"No tasks could be parsed from this document. Make sure the document uses ## H2 headings for phases and bullet points for tasks."}):e.jsx("div",{className:`${j.tree} tf-scrollbar`,children:_.map(b=>e.jsx(It,{node:b,depth:0,onToggle:M},b.idempotencyKey))})]})]}),!C&&u!=="done"&&u!=="error"&&e.jsxs("div",{className:j.footer,children:[e.jsx("button",{className:"tf-button-secondary",onClick:s,children:"Cancel"}),e.jsx("button",{className:"tf-button-primary",onClick:Z,disabled:F===0||u==="generating",children:u==="generating"?e.jsxs(e.Fragment,{children:[e.jsx(xt,{size:13,className:P.docSpinning})," Generating…"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ve,{size:13})," Generate ",F," task",F!==1?"s":""]})})]}),!C&&u==="done"&&e.jsx("div",{className:j.footer,children:e.jsx("button",{className:"tf-button-primary",onClick:s,children:"Done"})})]})})}const Js={"implementation-plan":"Implementation Plan",review:"Review",walkthrough:"Walkthrough",planning:"Planning",other:"Document"},Vs={"implementation-plan":r.typeBadgeImplementationPlan,review:r.typeBadgeReview,walkthrough:r.typeBadgeWalkthrough,planning:void 0,other:void 0},Qs={editor:r.editorLayoutEditor,split:r.editorLayoutSplit,preview:r.editorLayoutPreview},Ys=1500,Xs=`
2
+ @page {
3
+ margin: 0.94in 1.02in 1in;
4
+ }
5
+
6
+ html,
7
+ body {
8
+ margin: 0;
9
+ padding: 0;
10
+ background: #fff;
11
+ color: #111;
12
+ -webkit-print-color-adjust: exact;
13
+ print-color-adjust: exact;
14
+ }
15
+
16
+ body {
17
+ font: 12.15pt/1.66 Georgia, "Times New Roman", Times, serif;
18
+ letter-spacing: 0;
19
+ text-rendering: optimizeLegibility;
20
+ }
21
+
22
+ .tf-print-document {
23
+ max-width: 5.95in;
24
+ margin: 0 auto;
25
+ overflow: visible;
26
+ color: #171717;
27
+ }
28
+
29
+ .tf-print-document > :first-child {
30
+ margin-top: 0;
31
+ }
32
+
33
+ .tf-print-document > :last-child {
34
+ margin-bottom: 0;
35
+ }
36
+
37
+ .tf-print-document h1,
38
+ .tf-print-document h2,
39
+ .tf-print-document h3,
40
+ .tf-print-document h4 {
41
+ font-family: "Helvetica Neue", "Arial Nova", Arial, sans-serif;
42
+ color: #101010;
43
+ font-weight: 700;
44
+ line-height: 1.08;
45
+ letter-spacing: -0.03em;
46
+ break-after: avoid-page;
47
+ page-break-after: avoid;
48
+ }
49
+
50
+ .tf-print-document h1 {
51
+ font-size: 32pt;
52
+ font-weight: 800;
53
+ line-height: 0.98;
54
+ letter-spacing: -0.055em;
55
+ margin: 0 0 1.18em;
56
+ padding: 0 0 0.38em;
57
+ border-bottom: 2px solid #d8d8d8;
58
+ max-width: 84%;
59
+ }
60
+
61
+ .tf-print-document h1 + p,
62
+ .tf-print-document h1 + ul,
63
+ .tf-print-document h1 + ol {
64
+ margin-top: 0.4em;
65
+ }
66
+
67
+ .tf-print-document h2,
68
+ .tf-print-document h3,
69
+ .tf-print-document h4 {
70
+ margin-bottom: 0.28em;
71
+ }
72
+
73
+ .tf-print-document h2 {
74
+ font-size: 16.5pt;
75
+ font-weight: 750;
76
+ margin-top: 2.2em;
77
+ padding-bottom: 0.22em;
78
+ border-bottom: 1px solid #dfdfdf;
79
+ }
80
+
81
+ .tf-print-document h3 {
82
+ font-size: 13.3pt;
83
+ font-weight: 700;
84
+ margin-top: 1.48em;
85
+ }
86
+
87
+ .tf-print-document h4 {
88
+ font-size: 11.2pt;
89
+ font-weight: 700;
90
+ margin-top: 1.14em;
91
+ text-transform: uppercase;
92
+ letter-spacing: 0.08em;
93
+ }
94
+
95
+ .tf-print-document p,
96
+ .tf-print-document ul,
97
+ .tf-print-document ol,
98
+ .tf-print-document blockquote,
99
+ .tf-print-document table,
100
+ .tf-print-document pre,
101
+ .tf-print-document hr {
102
+ margin: 0.78em 0;
103
+ }
104
+
105
+ .tf-print-document ul,
106
+ .tf-print-document ol {
107
+ padding-left: 1.1em;
108
+ }
109
+
110
+ .tf-print-document li {
111
+ margin: 0.24em 0;
112
+ padding-left: 0.1em;
113
+ }
114
+
115
+ .tf-print-document li > ul,
116
+ .tf-print-document li > ol {
117
+ margin-top: 0.34em;
118
+ margin-bottom: 0.2em;
119
+ }
120
+
121
+ .tf-print-document a {
122
+ color: #121212;
123
+ text-decoration: underline;
124
+ text-underline-offset: 2px;
125
+ text-decoration-thickness: 0.65px;
126
+ }
127
+
128
+ .tf-print-document code {
129
+ font-family: "SFMono-Regular", "SF Mono", Consolas, "Liberation Mono", monospace;
130
+ font-size: 0.78em;
131
+ background: transparent;
132
+ color: #4a4a4a;
133
+ border: 0;
134
+ padding: 0;
135
+ border-radius: 0;
136
+ overflow-wrap: anywhere;
137
+ }
138
+
139
+ .tf-print-section-label {
140
+ font-family: "Helvetica Neue", "Arial Nova", Arial, sans-serif;
141
+ font-size: 10.7pt;
142
+ font-weight: 700;
143
+ line-height: 1.18;
144
+ letter-spacing: 0.12em;
145
+ text-transform: uppercase;
146
+ color: #191919;
147
+ margin-top: 2.2em;
148
+ margin-bottom: 0.58em;
149
+ padding-bottom: 0;
150
+ border-bottom: 0;
151
+ break-after: avoid-page;
152
+ page-break-after: avoid;
153
+ }
154
+
155
+ .tf-print-section-label strong {
156
+ font-weight: inherit;
157
+ }
158
+
159
+ .tf-print-document pre {
160
+ background: #fafafa;
161
+ border: 1px solid #e1e1e1;
162
+ border-radius: 6px;
163
+ padding: 10pt 11pt;
164
+ overflow: visible;
165
+ white-space: pre-wrap;
166
+ word-break: break-word;
167
+ break-inside: avoid-page;
168
+ page-break-inside: avoid;
169
+ }
170
+
171
+ .tf-print-document pre code {
172
+ background: transparent;
173
+ padding: 0;
174
+ border-radius: 0;
175
+ white-space: inherit;
176
+ word-break: inherit;
177
+ }
178
+
179
+ .tf-print-document blockquote {
180
+ border-left: 2px solid #9f9f9f;
181
+ color: #434343;
182
+ margin-left: 0;
183
+ padding-left: 9pt;
184
+ font-style: italic;
185
+ }
186
+
187
+ .tf-print-document table {
188
+ width: 100%;
189
+ border-collapse: collapse;
190
+ table-layout: fixed;
191
+ break-inside: auto;
192
+ page-break-inside: auto;
193
+ }
194
+
195
+ .tf-print-document thead {
196
+ display: table-header-group;
197
+ }
198
+
199
+ .tf-print-document tr {
200
+ break-inside: avoid-page;
201
+ page-break-inside: avoid;
202
+ }
203
+
204
+ .tf-print-document th,
205
+ .tf-print-document td {
206
+ border: 1px solid #dbdbdb;
207
+ padding: 6.5pt 7.5pt;
208
+ text-align: left;
209
+ vertical-align: top;
210
+ word-break: break-word;
211
+ background: #fff;
212
+ }
213
+
214
+ .tf-print-document th {
215
+ background: #f7f7f7;
216
+ color: #1e1e1e;
217
+ font-size: 9.4pt;
218
+ font-weight: 680;
219
+ letter-spacing: 0.018em;
220
+ text-transform: uppercase;
221
+ }
222
+
223
+ .tf-print-document hr {
224
+ border: 0;
225
+ border-top: 1px solid #e1e1e1;
226
+ }
227
+
228
+ .tf-print-document img {
229
+ max-width: 100%;
230
+ height: auto;
231
+ break-inside: avoid-page;
232
+ page-break-inside: avoid;
233
+ }
234
+
235
+ .tf-print-document input[type="checkbox"] {
236
+ accent-color: #111;
237
+ margin-right: 0.45em;
238
+ }
239
+ `;function Zs(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function St(t){return t?new Date(t).toLocaleString():"—"}function er(){const t=s=>!s||!Array.isArray(s.children)?!1:s.children.some(c=>c?c.type==="element"&&c.tagName==="input"&&c.properties?.type==="checkbox"?!0:t(c):!1),l=s=>!s||!Array.isArray(s.children)?!1:s.children.some(c=>typeof c?.checked=="boolean"?!0:t(c)),h=s=>{const c=Ke.Children.toArray(s).filter(y=>typeof y!="string"?!0:y.trim().length>0);if(c.length!==1)return null;const u=c[0];if(!Ke.isValidElement(u)||u.type!=="strong")return null;const p=u.props,w=Ke.Children.toArray(p.children).join("").trim();return w||null};return{input({type:s,checked:c,...u}){return s!=="checkbox"?e.jsx("input",{type:s,checked:c,...u}):e.jsx("input",{...u,type:"checkbox",checked:!!c,disabled:!0,readOnly:!0})},ul({children:s,node:c,...u}){const p=l(c);return e.jsx("ul",{...u,style:p?{paddingLeft:"1.2em"}:void 0,children:s})},ol({children:s,node:c,...u}){const p=l(c);return e.jsx("ol",{...u,style:p?{paddingLeft:"1.2em"}:void 0,children:s})},li({children:s,node:c,...u}){const p=typeof c?.checked=="boolean"||t(c);return e.jsx("li",{...u,style:p?{listStyleType:"none",listStyle:"none",marginLeft:0}:void 0,children:s})},p({children:s,...c}){const u=h(s);return u?e.jsx("p",{...c,className:"tf-print-section-label",children:u}):e.jsx("p",{...c,children:s})}}}function tr(t){const l=nn.renderToStaticMarkup(e.jsx("div",{className:"tf-print-document",children:e.jsx(Te,{remarkPlugins:[Ee],rehypePlugins:[Ae],components:er(),children:t})}));return`<!doctype html>
240
+ <html lang="en">
241
+ <head>
242
+ <meta charset="utf-8" />
243
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
244
+ <title>Taskforce print document</title>
245
+ <style>${Xs}</style>
246
+ </head>
247
+ <body>${l}</body>
248
+ </html>`}async function nr(t,l){try{await l.fonts?.ready}catch{}await new Promise(h=>{const s=t.requestAnimationFrame?.bind(t)??(c=>window.setTimeout(()=>c(0),0));s(()=>s(()=>h()))})}function ar(t){return window.setTimeout(t,Ys)}function Ct(t){try{return new Date(t).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return t}}function jt(t){return t?t.kind==="document"?"Entire document":t.kind==="quote"?t.quote?`Quote: "${t.quote}"`:"Quoted text":t.kind==="line-range"?t.startLine===t.endLine?`Line ${t.startLine}`:`Lines ${t.startLine}-${t.endLine}`:null:null}function sr(t){return t.authorActor?.label?t.authorActor.label:t.authorActorId==="user"||t.authorActorId==="human"?"You":t.authorActorId?t.authorActorId:"Reviewer"}function Nt(t){return t.replace(/\s+/g," ").trim()}function rr(t,l){if(!l)return 0;let h=0,s=0;for(;s>=0&&(s=t.indexOf(l,s),!(s<0));)h+=1,s+=l.length;return h}function ir(t,l,h){const s=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);let c=s.nextNode(),u=0;for(;c;){const p=c.textContent||"";if(c===l)return u+Math.max(0,Math.min(h,p.length));u+=p.length,c=s.nextNode()}return null}function or(t,l,h){const s=h.replace(/\s+/g," ").trim();if(!s)return null;const c=t.textContent||"",u=Nt(c),p=[];let w=u.indexOf(s);for(;w>=0;)p.push(w),w=u.indexOf(s,w+s.length);let y=null;const _=ir(t,l.startContainer,l.startOffset);if(_!==null){const A=Nt(c.slice(0,_));y=rr(A,s)}const m=y!==null&&y>=0&&y<p.length?y:p.length===1?0:null,C=m!==null?p[m]:p[0]??-1;if(C<0)return{kind:"quote",quote:s,occurrenceIndex:y};const R=u.slice(Math.max(0,C-40),C).trim()||null,k=u.slice(C+s.length,C+s.length+40).trim()||null;return{kind:"quote",quote:s,occurrenceIndex:m,prefix:R,suffix:k}}function cr(t,l,h){if(l<0)return t;const s=t.split(`
249
+ `);let c=-1;const u=/^(\s*(?:[-*+]|\d+\.)\s+)\[( |x|X)\](.*)$/,p=h?"x":" ";return s.map(y=>{const _=y.match(u);return!_||(c+=1,c!==l)?y:`${_[1]}[${p}]${_[3]}`}).join(`
250
+ `)}function lr({doc:t,taskTitle:l,tasks:h=[],apiBaseUrl:s="",onSaved:c,onDeleted:u,enableTaskGeneration:p=!1}){const w=Re(t),[y,_]=i.useState(w),m=y,C=an({...t,displayName:y}),R=sn(t),[k,A]=i.useState(null),[q,I]=i.useState(!1),[M,G]=i.useState(null),[X,F]=i.useState(!1),[Z,b]=i.useState(!1),[N,D]=i.useState([]),[V,ee]=i.useState(!1),[we,$]=i.useState(null),[te,O]=i.useState(null),[J,he]=i.useState(""),[S,g]=i.useState(!1),[z,K]=i.useState(null),[ie,ne]=i.useState(!1),[Ie,$e]=i.useState(""),[oe,fe]=i.useState(null),[ye,ce]=i.useState(""),[ae,$t]=i.useState(!0),[T,ge]=i.useState(!1),[H,le]=i.useState(""),[W,De]=i.useState("split"),[Q,U]=i.useState({type:"idle"}),[Dt,Be]=i.useState(!1),[et,Bt]=i.useState(!1),[be,tt]=i.useState(!1),[xe,se]=i.useState(!1),[Lt,_e]=i.useState(!1),[nt,at]=i.useState(""),[Le,Me]=i.useState(null),[st,ke]=i.useState(null),[Pe,de]=i.useState(m),ue=t.editable!==!1,pe=Ze(t),Mt=!!t.assetId,qe=T&&H!==(k??""),ze=i.useRef(null),Fe=i.useRef(null),rt=i.useRef(null),me=i.useRef(null),Se=i.useRef(null),it=i.useRef(null),ot=i.useRef(null),v=N.find(n=>n.id===te)||N[0]||null,ct=h.filter(n=>{const a=nt.trim().toLowerCase();return a?n.title.toLowerCase().includes(a):!0}),lt=i.useCallback(async()=>{I(!0),G(null),A(null);try{const n=await L(t.apiUrl,{credentials:"same-origin"},s);if(!n.ok)throw new Error(`Failed to load document (${n.status})`);const a=await n.text();A(a),le(a)}catch(n){G(n?.message||"Failed to load document")}finally{I(!1)}},[s,t.apiUrl]),Ce=i.useCallback(async n=>{if(!t.assetId){D([]),O(null),$(null);return}const a=n?.silent===!0;a||(ee(!0),$(null));try{const o=await L(`/api/taskforce/document-reviews/sessions?assetId=${encodeURIComponent(t.assetId)}`,{credentials:"include"},s),d=await o.json().catch(()=>({}));if(!o.ok)throw new Error(d.error||`Failed to load reviews (${o.status})`);const f=Array.isArray(d.sessions)?d.sessions:[];D(f),O(x=>x&&f.some(Y=>Y.id===x)?x:f[0]?.id??null)}catch(o){a||($(o?.message||"Failed to load reviews"),D([]),O(null))}finally{a||ee(!1)}},[s,t.assetId]),Oe=i.useCallback(async()=>{if(!t.assetId||S)return null;g(!0),$(null);try{const n=await L("/api/taskforce/document-reviews/sessions",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({assetId:t.assetId,title:`Review ${N.length+1}`})},s),a=await n.json().catch(()=>({}));if(!n.ok)throw new Error(a.error||`Failed to create review (${n.status})`);const o=a.session||null;if(!o)throw new Error("Review session payload missing.");return D(d=>[o,...d.filter(f=>f.id!==o.id)]),O(o.id),o}catch(n){return $(n?.message||"Failed to create review"),null}finally{g(!1)}},[s,t.assetId,S,N.length]);i.useEffect(()=>{lt(),Ce(),ge(!1),U({type:"idle"}),se(!1);const n=Re(t);_(n),de(n),F(!1),b(!1),he(""),K(null),ne(!1),$e(""),fe(null),ce("")},[t,lt,Ce]),i.useEffect(()=>{if(!v)return;const n=it.current;typeof n?.scrollIntoView=="function"&&n.scrollIntoView({block:"end"})},[v?.comments.length,v?.id]),i.useEffect(()=>{$e(v?.title?.trim()||""),ne(!1)},[v?.id,v?.title]),i.useEffect(()=>{xe&&window.setTimeout(()=>{Fe.current?.focus(),Fe.current?.select()},0)},[xe]),i.useEffect(()=>{if(!t.assetId||T)return;const n=()=>{document.visibilityState==="visible"&&Ce({silent:!0})},a=window.setInterval(n,15e3);return window.addEventListener("focus",n),document.addEventListener("visibilitychange",n),()=>{window.clearInterval(a),window.removeEventListener("focus",n),document.removeEventListener("visibilitychange",n)}},[t.assetId,T,Ce]),i.useEffect(()=>{if(!T)return;const n=a=>{(a.metaKey||a.ctrlKey)&&a.key==="s"&&(a.preventDefault(),dt())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[T,H]);const re=i.useCallback(()=>{Se.current!==null&&(window.clearTimeout(Se.current),Se.current=null),me.current&&(me.current.remove(),me.current=null)},[]);i.useEffect(()=>()=>{re()},[re]);const je=i.useCallback(n=>{if(!T||W!=="split")return;const a=ze.current,o=rt.current;if(!a||!o)return;const d=n==="editor"?a:o,f=n==="editor"?o:a,x=Math.max(d.scrollHeight-d.clientHeight,0),Y=Math.max(f.scrollHeight-f.clientHeight,0),Ge=x<=0?0:d.scrollTop/x,wt=Y*Ge;Math.abs(f.scrollTop-wt)<=1||(f.scrollTop=wt)},[T,W]);i.useEffect(()=>{!T||W!=="split"||je("editor")},[H,T,W,je]);const Pt=()=>{ue&&(le(k??""),U({type:"idle"}),ge(!0),setTimeout(()=>ze.current?.focus(),50))},qt=()=>{qe&&!window.confirm("Discard unsaved changes?")||(ge(!1),le(k??""),U({type:"idle"}))},dt=i.useCallback(async()=>{if(ue&&Q.type!=="saving"){U({type:"saving"});try{const n=await L("/api/taskforce/documents/save",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({fsPath:t.fsPath,content:H})},s),a=await n.json().catch(()=>({}));if(!n.ok)throw new Error(a.error||`Save failed (${n.status})`);const o=a.updatedAt||new Date().toISOString();A(H),U({type:"saved",savedAt:o}),c?.(o),ge(!1)}catch(n){U({type:"error",message:n?.message||"Save failed"})}}},[s,t.fsPath,H,Q.type,c,ue]),zt=i.useCallback(()=>{const n=T?H:k??"";if(!n.trim())return;re();const a=document.createElement("iframe");a.setAttribute("aria-hidden","true"),a.tabIndex=-1,a.style.position="fixed",a.style.right="0",a.style.bottom="0",a.style.width="0",a.style.height="0",a.style.border="0",a.style.opacity="0",a.style.pointerEvents="none",document.body.appendChild(a),me.current=a;const o=a.contentWindow,d=a.contentDocument;if(!o||!d){re();return}d.open(),d.write(tr(n)),d.close();let f=!1;const x=async()=>{f||me.current!==a||(f=!0,await nr(o,d),me.current===a&&(o.focus(),o.print(),Se.current=ar(re)))};o.addEventListener("afterprint",re,{once:!0}),x()},[re,k,H,T]),Ft=async()=>{const n=t.apiUrl,a=new URL(bt(n,s),window.location.origin).toString();try{await navigator.clipboard.writeText(a)}catch{const o=document.createElement("textarea");o.value=a,document.body.appendChild(o),o.select(),document.execCommand("copy"),document.body.removeChild(o)}F(!0),setTimeout(()=>F(!1),2e3)},Ot=i.useCallback(async()=>{if(R){try{await navigator.clipboard.writeText(R)}catch{const n=document.createElement("textarea");n.value=R,document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n)}b(!0),setTimeout(()=>b(!1),2e3)}},[R]),Ht=()=>{const n=t.apiUrl.includes("?")?"&":"?",a=bt(`${t.apiUrl}${n}download=1&filename=${encodeURIComponent(C)}`,s),o=document.createElement("a");o.href=a,o.click()},He=i.useCallback(async()=>{if(!t.assetId)return;const n=Pe.trim();if(!n){de(m),se(!1);return}if(n===m){se(!1);return}const a=await L(`/api/taskforce/documents/${encodeURIComponent(t.assetId)}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({displayName:n})},s),o=await a.json().catch(()=>({}));if(!a.ok){window.alert(o.error||`Rename failed (${a.status})`);return}_(n),de(n),se(!1),c?.(o.updatedAt||new Date().toISOString())},[s,t.assetId,c,m,Pe]),Wt=i.useCallback(n=>{if(n.key==="Enter"){n.preventDefault(),He();return}n.key==="Escape"&&(n.preventDefault(),de(m),se(!1))},[He,m]),Gt=i.useCallback(async()=>{if(!t.assetId||be)return;const n=pe==="attached",a=Math.max(0,Number(t.attachmentCount||0)),o=n?`Delete "${m}" everywhere?
251
+
252
+ This will remove it from ${a} linked task${a===1?"":"s"} and soft-delete the document across sync.`:`Permanently delete "${m}" from storage?`;if(window.confirm(o)){tt(!0);try{const d=await L(`/api/taskforce/documents/${encodeURIComponent(t.assetId)}`,{method:"DELETE",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(n?{forceDetach:!0}:{})},s),f=await d.json().catch(()=>({}));if(!d.ok)throw new Error(f.error||`Delete failed (${d.status})`);u?.()}catch(d){window.alert(d?.message||"Delete failed")}finally{tt(!1)}}},[s,pe,be,t.assetId,t.attachmentCount,u,m]),Kt=i.useCallback(()=>{at(""),ke(null),Me(null),_e(!0)},[]),Ut=i.useCallback(async n=>{if(t.assetId){ke(null),Me(n);try{const a=await L(`/api/taskforce/documents/${encodeURIComponent(t.assetId)}/attach`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetType:"task",targetId:n})},s),o=await a.json().catch(()=>({}));if(!a.ok)throw new Error(o.error||`Attach failed (${a.status})`);if(o.alreadyAttached){ke("This document is already attached to that task.");return}_e(!1),c?.(new Date().toISOString())}catch(a){ke(a?.message||"Failed to attach document.")}finally{Me(null)}}},[s,t.assetId,c]),Jt=i.useCallback(async()=>{if(!(!v||S)){g(!0),$(null);try{const n=v.status==="resolved"?"open":"resolved",a=await L(`/api/taskforce/document-reviews/sessions/${encodeURIComponent(v.id)}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:n})},s),o=await a.json().catch(()=>({}));if(!a.ok)throw new Error(o.error||`Failed to update review (${a.status})`);const d=o.session||null;if(!d)throw new Error("Review session payload missing.");D(f=>f.map(x=>x.id===d.id?d:x))}catch(n){$(n?.message||"Failed to update review")}finally{g(!1)}}},[v,s,S]),Vt=i.useCallback(async()=>{if(!v||S)return;const n=Ie.trim();g(!0),$(null);try{const a=await L(`/api/taskforce/document-reviews/sessions/${encodeURIComponent(v.id)}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:n||null})},s),o=await a.json().catch(()=>({}));if(!a.ok)throw new Error(o.error||`Failed to update review (${a.status})`);const d=o.session||null;if(!d)throw new Error("Review session payload missing.");D(f=>f.map(x=>x.id===d.id?d:x)),ne(!1)}catch(a){$(a?.message||"Failed to update review")}finally{g(!1)}},[v,s,S,Ie]),ut=T?H:k??"",Qt=i.useCallback(()=>{if(T||!ae)return;const n=typeof window.getSelection=="function"?window.getSelection():null,a=n?.toString().replace(/\s+/g," ").trim()||"";if(!n||!a)return;const o=n.rangeCount>0?n.getRangeAt(0):null,d=ot.current;if(!o||!d)return;const f=o.commonAncestorContainer,x=f.nodeType===Node.TEXT_NODE?f.parentNode:f;if(!(x instanceof Node)||!d.contains(x))return;const Y=or(d,o,a);Y&&K(Y)},[T,ae]),Yt=i.useCallback(()=>{$t(n=>{const a=!n;return a||K(null),a})},[]),mt=i.useCallback(async()=>{const n=J.trim();if(!n||S)return;let a=v;if(a||(a=await Oe()),!!a){g(!0),$(null);try{const o=await L(`/api/taskforce/document-reviews/sessions/${encodeURIComponent(a.id)}/comments`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:n,anchor:z||{kind:"document"}})},s),d=await o.json().catch(()=>({}));if(!o.ok)throw new Error(d.error||`Failed to add comment (${o.status})`);const f=d.session||null;if(!f)throw new Error("Review session payload missing.");D(x=>{const Y=x.filter(Ge=>Ge.id!==f.id);return[f,...Y]}),O(f.id),he(""),K(null)}catch(o){$(o?.message||"Failed to add comment")}finally{g(!1)}}},[v,s,Oe,z,S,J]),Xt=i.useCallback((n,a)=>{fe(n),ce(a)},[]),Zt=i.useCallback(async()=>{if(!v||!oe||S)return;const n=ye.trim();if(n){g(!0),$(null);try{const a=await L(`/api/taskforce/document-reviews/sessions/${encodeURIComponent(v.id)}/comments/${encodeURIComponent(oe)}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:n})},s),o=await a.json().catch(()=>({}));if(!a.ok)throw new Error(o.error||`Failed to update comment (${a.status})`);const d=o.session||null;if(!d)throw new Error("Review session payload missing.");D(f=>f.map(x=>x.id===d.id?d:x)),fe(null),ce("")}catch(a){$(a?.message||"Failed to update comment")}finally{g(!1)}}},[v,s,ye,oe,S]),en=i.useCallback(async n=>{if(!(!v||S)&&window.confirm("Delete this review comment?")){g(!0),$(null);try{const a=await L(`/api/taskforce/document-reviews/sessions/${encodeURIComponent(v.id)}/comments/${encodeURIComponent(n)}`,{method:"DELETE",credentials:"include"},s),o=await a.json().catch(()=>({}));if(!a.ok)throw new Error(o.error||`Failed to delete comment (${a.status})`);const d=o.session||null;if(!d)throw new Error("Review session payload missing.");D(f=>f.map(x=>x.id===d.id?d:x)),oe===n&&(fe(null),ce(""))}catch(a){$(a?.message||"Failed to delete comment")}finally{g(!1)}}},[v,s,oe,S]),ht=i.useCallback(async n=>{if(!ue)return!1;U({type:"saving"});try{const a=await L("/api/taskforce/documents/save",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({fsPath:t.fsPath,content:n})},s),o=await a.json().catch(()=>({}));if(!a.ok)throw new Error(o.error||`Save failed (${a.status})`);const d=o.updatedAt||new Date().toISOString();return A(n),le(n),U({type:"saved",savedAt:d}),c?.(d),!0}catch(a){return U({type:"error",message:a?.message||"Save failed"}),!1}},[s,t.fsPath,c,ue]),tn=i.useCallback((n,a)=>{const o=T?H:k??"",d=cr(o,n,a);if(d!==o){if(T){le(d),U(f=>f.type==="saving"?f:{type:"idle"});return}ht(d)}},[k,H,T,ht]);let ft=-1;const We=n=>!n||!Array.isArray(n.children)?!1:n.children.some(a=>a?a.type==="element"&&a.tagName==="input"&&a.properties?.type==="checkbox"?!0:We(a):!1),pt=n=>!n||!Array.isArray(n.children)?!1:n.children.some(a=>typeof a?.checked=="boolean"?!0:We(a)),vt={input({type:n,checked:a,...o}){if(n!=="checkbox")return e.jsx("input",{type:n,checked:a,...o});ft+=1;const d=ft;return e.jsx("input",{...o,type:"checkbox",checked:!!a,disabled:!1,onClick:f=>f.stopPropagation(),onChange:f=>tn(d,f.currentTarget.checked)})},ul({children:n,node:a,...o}){const d=pt(a);return e.jsx("ul",{...o,style:d?{paddingLeft:"1.25em"}:void 0,"data-task-list":d?"true":void 0,children:n})},ol({children:n,node:a,...o}){const d=pt(a);return e.jsx("ol",{...o,style:d?{paddingLeft:"1.25em"}:void 0,"data-task-list":d?"true":void 0,children:n})},li({children:n,node:a,...o}){const d=typeof a?.checked=="boolean"||We(a);return e.jsx("li",{...o,style:d?{listStyleType:"none",listStyle:"none",marginLeft:0}:void 0,"data-task-item":d?"true":void 0,children:n})}};return e.jsxs("div",{className:`${r.viewer} ${T?r.viewerEditMode:""} ${et?r.viewerMonochrome:""}`,children:[e.jsxs("div",{className:r.meta,children:[e.jsxs("div",{className:r.metaLeft,children:[e.jsxs("span",{className:`${r.typeBadge} ${Vs[t.docType]??""}`,children:[e.jsx(bn,{size:10}),Js[t.docType]]}),xe?e.jsx("div",{className:r.metaRenameRow,children:e.jsx("input",{ref:Fe,type:"text",className:P.input,value:Pe,onChange:n=>de(n.target.value),onBlur:()=>{He()},onKeyDown:Wt})}):e.jsx("span",{className:r.metaDocumentName,title:m,onDoubleClick:()=>{t.assetId&&(de(m),se(!0))},children:m}),l&&e.jsx("span",{className:r.metaTaskName,title:`From task: ${l}`,children:l}),pe==="unattached"&&e.jsx("span",{className:r.statusBadge,children:"Unattached"}),t.updatedAt&&e.jsxs("span",{className:r.metaDate,title:St(t.updatedAt),children:[e.jsx(xn,{size:11}),St(t.updatedAt)]}),e.jsxs("span",{className:r.metaSize,children:[e.jsx(_n,{size:11}),Zs(t.sizeBytes)]}),R&&e.jsx(rn,{label:R,copied:Z,onClick:()=>{Ot()},title:"Copy document reference"}),Q.type==="saved"&&e.jsxs("span",{className:`${r.saveStatus} ${r.saveStatusSaved}`,children:[e.jsx(At,{size:11}),"Saved"]}),Q.type==="error"&&e.jsxs("span",{className:`${r.saveStatus} ${r.saveStatusError}`,title:Q.message,children:[e.jsx(Qe,{size:11}),Q.message||"Save failed"]}),qe&&Q.type!=="saving"&&e.jsx("span",{className:r.unsaved,children:"Unsaved changes"})]}),e.jsx("div",{className:r.actions,children:T?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:r.layoutToggle,children:[e.jsx("button",{className:`${r.layoutBtn} ${W==="editor"?r.layoutBtnActive:""}`,onClick:()=>De("editor"),title:"Editor only",children:e.jsx(Ne,{size:12})}),e.jsx("button",{className:`${r.layoutBtn} ${W==="split"?r.layoutBtnActive:""}`,onClick:()=>De("split"),title:"Split view",children:e.jsx(kn,{size:12})}),e.jsx("button",{className:`${r.layoutBtn} ${W==="preview"?r.layoutBtnActive:""}`,onClick:()=>De("preview"),title:"Preview only",children:e.jsx(Je,{size:12})})]}),e.jsxs("button",{className:r.actionBtn,onClick:qt,title:"Discard changes",children:[e.jsx(Et,{size:13}),"Cancel"]}),e.jsxs("button",{className:`${r.actionBtn} ${r.saveBtn}`,onClick:dt,disabled:Q.type==="saving"||!qe,title:"Save (Ctrl+S)",children:[e.jsx(Sn,{size:13}),Q.type==="saving"?"Saving…":"Save"]})]}):e.jsxs(e.Fragment,{children:[t.assetId&&e.jsxs("button",{className:r.actionBtn,onClick:()=>se(n=>!n),title:"Rename document",children:[e.jsx(Ne,{size:13}),xe?"Close Rename":"Rename"]}),ue&&e.jsxs("button",{className:`${r.actionBtn} ${r.editBtn}`,onClick:Pt,title:"Edit document",children:[e.jsx(Ne,{size:13}),"Edit"]}),t.assetId&&e.jsxs("button",{className:r.actionBtn,onClick:Kt,title:"Attach document to a task",children:[e.jsx(_t,{size:13}),"Attach"]}),e.jsxs("button",{className:r.actionBtn,onClick:Yt,title:ae?"Hide review and comments":"Show review and comments",children:[e.jsx(Ue,{size:13}),ae?"Hide Review":"Show Review"]}),e.jsxs("button",{className:r.actionBtn,onClick:Ft,title:"Copy link",children:[e.jsx(_t,{size:13}),X?"Copied!":"Copy link"]}),e.jsxs("button",{className:r.actionBtn,onClick:Ht,title:"Download .md",children:[e.jsx(Cn,{size:13}),"Download"]}),e.jsxs("button",{className:r.actionBtn,onClick:zt,title:"Print",children:[e.jsx(jn,{size:13}),"Print"]}),e.jsxs("button",{className:r.actionBtn,onClick:()=>Bt(n=>!n),title:"Toggle black and white style",children:[e.jsx(Je,{size:13}),et?"Color":"B/W"]}),p&&t.docType==="implementation-plan"&&!T&&e.jsxs("button",{className:`${r.actionBtn} ${r.generateBtn}`,onClick:()=>Be(!0),title:"Generate tasks from this plan",children:[e.jsx(Ve,{size:13}),"Generate Tasks"]}),Mt&&e.jsxs("button",{className:`${r.actionBtn} ${r.dangerBtn}`,onClick:()=>{Gt()},disabled:be,title:pe==="attached"?"Remove this document from linked tasks and delete it":"Permanently delete this unattached document",children:[e.jsx(Nn,{size:13}),be?"Deleting…":pe==="attached"?"Delete & Unlink":"Delete Permanently"]})]})})]}),q&&e.jsx("div",{className:r.viewerState,children:"Loading…"}),!q&&M&&e.jsx("div",{className:r.viewerStateError,children:M}),!q&&!M&&(T?e.jsxs("div",{className:`${r.editorArea} ${Qs[W]}`,children:[(W==="editor"||W==="split")&&e.jsxs("div",{className:r.editorPane,children:[e.jsx("div",{className:r.editorPaneLabel,children:"Markdown"}),e.jsx("textarea",{ref:ze,className:`${r.editorTextarea} tf-scrollbar`,value:H,onScroll:()=>je("editor"),onChange:n=>{le(n.target.value),U(a=>a.type==="saving"?a:{type:"idle"})},spellCheck:!0,placeholder:"Write markdown here…"})]}),(W==="preview"||W==="split")&&e.jsxs("div",{className:r.previewPane,children:[e.jsx("div",{className:r.editorPaneLabel,children:"Preview"}),e.jsx("div",{ref:rt,className:`${P.docMarkdown} ${r.markdownSurface}`,"data-testid":"doc-preview-scroll",onScroll:()=>je("preview"),children:e.jsx(Te,{remarkPlugins:[Ee],rehypePlugins:[Ae],components:vt,children:ut})})]})]}):e.jsxs("div",{className:`${r.viewerBody} ${ae?"":r.viewerBodyFullWidth}`,children:[e.jsx("div",{className:`${r.viewerContent} ${r.viewerMain} tf-scrollbar`,children:e.jsx("div",{ref:ot,className:`${P.docMarkdown} ${r.markdownSurface}`,onMouseUp:ae?Qt:void 0,children:e.jsx(Te,{remarkPlugins:[Ee],rehypePlugins:[Ae],components:vt,children:ut})})}),ae&&e.jsx("aside",{className:r.reviewRail,children:e.jsxs("section",{className:r.reviewSection,"aria-label":"Review and comments",children:[e.jsxs("div",{className:r.reviewHeader,children:[e.jsxs("div",{children:[e.jsxs("div",{className:r.reviewTitle,children:[e.jsx(Ue,{size:14}),"Review & Comments"]}),e.jsx("p",{className:r.reviewSubtitle,children:"Comments stay attached to this document review session."})]}),e.jsxs("div",{className:r.reviewControls,children:[N.length>1&&e.jsx("select",{className:`${P.select} ${r.reviewSelect}`,value:v?.id||"",onChange:n=>O(n.target.value||null),"aria-label":"Select review session",children:N.map(n=>e.jsx("option",{value:n.id,children:n.title?.trim()||"Untitled review"},n.id))}),e.jsxs("button",{type:"button",className:r.actionBtn,onClick:()=>{Oe()},disabled:S||!t.assetId,children:[e.jsx(Ue,{size:13}),"Start Review"]}),v&&e.jsxs("button",{type:"button",className:r.actionBtn,onClick:()=>{Jt()},disabled:S,children:[v.status==="resolved"?e.jsx(Tn,{size:13}):e.jsx(En,{size:13}),v.status==="resolved"?"Reopen":"Resolve"]})]})]}),v&&e.jsxs("div",{className:r.reviewSessionMeta,children:[e.jsx("span",{className:`${r.statusBadge} ${v.status==="resolved"?r.reviewStatusResolved:""}`,children:v.status==="resolved"?"Resolved":"Open"}),ie?e.jsxs("div",{className:r.reviewTitleEditRow,children:[e.jsx("input",{type:"text",className:P.input,value:Ie,onChange:n=>$e(n.target.value),placeholder:"Untitled review"}),e.jsx("button",{type:"button",className:P.secondaryHeaderBtn,onClick:()=>{Vt()},disabled:S,children:"Save Title"})]}):e.jsx("span",{className:r.reviewSessionLabel,children:v.title?.trim()||"Untitled review"}),e.jsxs("span",{className:r.reviewSessionTimestamp,children:["Updated ",Ct(v.updatedAt)]}),!ie&&e.jsxs("button",{type:"button",className:r.actionBtn,onClick:()=>ne(!0),disabled:S,children:[e.jsx(Ne,{size:13}),"Rename Review"]})]}),we&&e.jsx("div",{className:r.viewerStateError,children:we}),e.jsxs("div",{className:B.commentPanel,children:[e.jsxs("div",{className:B.commentThread,children:[V&&e.jsx("div",{className:B.emptyComments,children:"Loading review comments…"}),!V&&!v&&e.jsx("div",{className:B.emptyComments,children:"Start a review to collect comments for this document."}),!V&&v&&v.comments.length===0&&e.jsx("div",{className:B.emptyComments,children:"No comments yet. Add the first review note for this document."}),!V&&v&&v.comments.map(n=>{const a=n.authorActor?.kind==="ai",o=jt(n.anchor),d=a?An:Rn,f=oe===n.id;return e.jsxs("div",{className:`${B.comment} ${a?B.commentAi:B.commentUser}`,children:[e.jsxs("div",{className:B.commentHeader,children:[e.jsxs("span",{className:B.commentAuthor,style:n.authorActor?.color?{color:n.authorActor.color}:void 0,children:[e.jsx(d,{size:12,strokeWidth:1.5}),sr(n)]}),e.jsx("span",{className:B.commentTime,children:Ct(n.updatedAt)}),e.jsxs("span",{className:r.reviewCommentActions,children:[!f&&e.jsx("button",{type:"button",className:r.reviewCommentAction,onClick:()=>Xt(n.id,n.body),disabled:S,children:"Edit"}),f&&e.jsx("button",{type:"button",className:r.reviewCommentAction,onClick:()=>{fe(null),ce("")},disabled:S,children:"Cancel"}),e.jsx("button",{type:"button",className:r.reviewCommentAction,onClick:()=>{en(n.id)},disabled:S,children:"Delete"})]})]}),o&&e.jsx("span",{className:r.reviewAnchorLabel,children:o}),e.jsx("div",{className:B.commentText,children:f?e.jsxs("div",{className:r.reviewCommentEditor,children:[e.jsx("textarea",{className:B.commentInput,value:ye,onChange:x=>ce(x.target.value),disabled:S}),e.jsx("button",{type:"button",className:P.secondaryHeaderBtn,onClick:()=>{Zt()},disabled:S||!ye.trim(),children:"Save Comment"})]}):e.jsx(Te,{remarkPlugins:[Ee],rehypePlugins:[Ae],children:n.body})})]},n.id)}),e.jsx("div",{ref:it})]}),e.jsxs("div",{className:B.commentInputArea,children:[e.jsxs("div",{className:r.reviewComposer,children:[z&&e.jsxs("div",{className:r.reviewAnchorChip,children:[e.jsx("span",{children:jt(z)||"Selected text"}),"quote"in z&&z.quote&&e.jsxs("span",{className:r.reviewAnchorSnippet,children:['"',z.quote,'"']}),e.jsx("button",{type:"button",className:r.reviewAnchorClear,onClick:()=>K(null),children:"Clear"})]}),e.jsx("textarea",{className:B.commentInput,placeholder:v?.status==="resolved"?"Reopen this review to add more comments…":z?"Add a comment for the selected text…":"Add a comment for this document review…",value:J,onChange:n=>he(n.target.value),disabled:S||v?.status==="resolved",onKeyDown:n=>{n.key==="Enter"&&!n.shiftKey&&(n.preventDefault(),mt())}})]}),e.jsx("button",{type:"button",className:B.sendCommentBtn,onClick:()=>{mt()},disabled:S||!J.trim()||v?.status==="resolved","aria-label":"Send review comment",title:"Send review comment",children:e.jsx(In,{size:15})})]})]})]})})]})),p&&Dt&&k!==null&&e.jsx(Us,{content:k,docTitle:t.title,apiBaseUrl:s,onClose:()=>Be(!1),onGenerated:n=>Be(!1)}),e.jsx(on,{isOpen:Lt,onClose:()=>{Le||_e(!1)},title:"Attach document",size:"md",footer:e.jsx("button",{className:r.actionBtn,onClick:()=>_e(!1),disabled:!!Le,children:"Close"}),children:e.jsxs("div",{className:r.attachModalBody,children:[e.jsx("p",{className:r.attachModalCopy,children:"Attach this document to a task from the document manager. Initiative and workstream targets can be enabled later on the same attachment model."}),e.jsx("input",{type:"text",className:P.input,placeholder:"Search tasks…",value:nt,onChange:n=>at(n.target.value)}),st&&e.jsxs("div",{className:r.attachModalError,children:[e.jsx(Qe,{size:14}),e.jsx("span",{children:st})]}),e.jsx("div",{className:`${r.attachTaskList} tf-scrollbar`,children:ct.length===0?e.jsx("div",{className:r.attachEmptyState,children:h.length===0?"No tasks are available in this workspace.":"No tasks match your search."}):ct.map(n=>{const a=t.taskId===n.id,o=Le===n.id;return e.jsxs("button",{type:"button",className:r.attachTaskRow,disabled:o,onClick:()=>{Ut(n.id)},children:[e.jsx("span",{className:r.attachTaskTitle,children:n.title}),e.jsx("span",{className:r.attachTaskMeta,children:o?"Attaching…":a?"Attached":"Attach"})]},n.id)})})]})}),!T&&e.jsx("div",{className:r.printHint,children:"For the cleanest output, disable browser Headers and footers in the print dialog."})]})}function Tt(t){return typeof t=="string"?t.trim().replace(/\/+$/,""):""}function dr(t){return t.runtimeMode==="local"?"":Tt(t.apiBaseUrl)||Tt(t.cloudAuthBaseUrl)||""}function ur({runtimeMode:t="local",apiBaseUrl:l="",cloudAuthBaseUrl:h="",typeFilters:s,attachmentFilters:c,onTypeFiltersChange:u,onAttachmentFiltersChange:p,requestedDocPath:w=null,requestedDocAssetId:y=null,onRequestedDocHandled:_}){const[m,C]=i.useState([]),[R,k]=i.useState(!0),[A,q]=i.useState(null),[I,M]=i.useState(null),[G,X]=i.useState(""),[F,Z]=i.useState(()=>cn.map(g=>g.value)),[b,N]=i.useState(()=>ln.map(g=>g.value)),D=dr({runtimeMode:t,apiBaseUrl:l,cloudAuthBaseUrl:h}),V=s??F,ee=c??b,we=u??Z,$=p??N,te=i.useCallback(async()=>{k(!0),q(null);try{const g=await L("/api/taskforce/documents",{credentials:"include"},D);if(!g.ok)throw new Error(`Failed to load documents (${g.status})`);const z=await g.json(),K=Array.isArray(z.documents)?z.documents:[];K.length,C(K)}catch(g){q(g?.message||"Failed to load documents"),g?.message}finally{k(!1)}},[D,t]);i.useEffect(()=>{te()},[te]);const O=i.useMemo(()=>ta(m,G,V,ee),[ee,m,G,V]),J=i.useMemo(()=>I?m.find(g=>g.id===I)??null:null,[m,I]);i.useEffect(()=>{if(!w&&!y||m.length===0)return;const g=w?Ye(w):"",z=String(y||"").trim().toLowerCase()||kt(w),K=m.find(ie=>{const ne=kt(ie.fsPath)||String(ie.assetId||"").trim().toLowerCase()||null;return z&&ne&&ne===z?!0:g?ea(Ye(ie.fsPath),g):!1});K&&(M(K.id),_?.())},[m,_,y,w]),i.useEffect(()=>{if(!((w||y)&&!J)){if(O.length===0){I!==null&&M(null);return}J&&O.some(g=>g.id===J.id)||M(O[0].id)}},[O,y,w,J,I]);const he=i.useCallback(async()=>{M(null),await te()},[te]),S=G.trim().length>0||V.length>0||ee.length>0;return{documentApiBaseUrl:D,documents:m,filteredDocs:O,loading:R,error:A,selectedDoc:J,searchQuery:G,typeFilters:V,attachmentFilters:ee,hasActiveFilters:S,setSearchQuery:X,handleTypeFiltersChange:we,handleAttachmentFiltersChange:$,fetchDocuments:te,selectDoc:g=>M(g?.id??null),handleDeleteSelected:he}}function mr({tasks:t,apiBaseUrl:l="",documents:h,loading:s,error:c,selectedDoc:u,searchQuery:p,hasActiveFilters:w,onSearchChange:y,onSelectDoc:_,onRefresh:m,onDeleteSelected:C,enableTaskGeneration:R=!1}){const k=new Map(t.map(A=>[A.id,A]));return e.jsxs("div",{className:P.docWorkspace,children:[e.jsx("div",{className:P.docIndexPanel,children:e.jsx(ia,{documents:h,selectedDocId:u?.id??null,loading:s,error:c,searchQuery:p,onSearchChange:y,onSelect:A=>_(A),onRefresh:m,taskById:k,hasActiveFilters:w})}),e.jsx("div",{className:P.docViewerPanel,children:u?e.jsx(lr,{doc:u,taskTitle:u.taskId?k.get(u.taskId)?.title??null:null,tasks:t,apiBaseUrl:l,onSaved:A=>m(),onDeleted:()=>{C()},enableTaskGeneration:R}):!s&&e.jsx("div",{className:P.docViewerEmpty,children:e.jsx("p",{className:"tf-empty-copy",children:h.length===0?"No documents match your current filters.":"Select a document to view it."})})})]})}function gr({tasks:t,runtimeMode:l="local",apiBaseUrl:h="",cloudAuthBaseUrl:s="",typeFilters:c,attachmentFilters:u,onTypeFiltersChange:p,onAttachmentFiltersChange:w,requestedDocPath:y=null,requestedDocAssetId:_=null,onRequestedDocHandled:m,enableTaskGeneration:C=!1}){const{documentApiBaseUrl:R,filteredDocs:k,loading:A,error:q,selectedDoc:I,searchQuery:M,hasActiveFilters:G,setSearchQuery:X,fetchDocuments:F,selectDoc:Z,handleDeleteSelected:b}=ur({runtimeMode:l,apiBaseUrl:h,cloudAuthBaseUrl:s,typeFilters:c,attachmentFilters:u,onTypeFiltersChange:p,onAttachmentFiltersChange:w,requestedDocPath:y,requestedDocAssetId:_,onRequestedDocHandled:m});return e.jsx(mr,{tasks:t,apiBaseUrl:R,documents:k,loading:A,error:q,selectedDoc:I,searchQuery:M,hasActiveFilters:G,onSearchChange:X,onSelectDoc:Z,onRefresh:F,onDeleteSelected:b,enableTaskGeneration:C})}export{ln as DOCUMENT_ATTACHMENT_FILTER_OPTIONS,cn as DOCUMENT_TYPE_FILTER_OPTIONS,mr as DocumentWorkspace,gr as DocumentWorkspaceShell};
@@ -0,0 +1 @@
1
+ ._index_18mna_1{display:flex;flex-direction:column;height:100%;min-height:0}._header_18mna_8{display:flex;align-items:center;justify-content:space-between;padding:14px 12px 10px;border-bottom:1px solid var(--border-subtle);flex-shrink:0}._title_18mna_17{display:flex;align-items:center;gap:6px;font-size:13px;font-weight:600;color:var(--text-primary)}._refreshBtn_18mna_26{background:transparent;border:none;color:var(--text-muted);cursor:pointer;padding:4px;border-radius:4px;display:flex;align-items:center;transition:color .15s,background .15s}._refreshBtn_18mna_26:hover{color:var(--text-primary);background:var(--bg-hover)}._refreshBtn_18mna_26:disabled{opacity:.5;cursor:not-allowed}._search_18mna_48{position:relative;padding:8px 10px;flex-shrink:0}._searchIcon_18mna_54{position:absolute;left:18px;top:50%;transform:translateY(-50%);color:var(--text-muted);pointer-events:none}._searchInput_18mna_63{width:100%;padding:6px 8px 6px 28px;background:var(--bg-primary);border:1px solid var(--border-subtle);border-radius:6px;color:var(--text-primary);font-size:12px;font-family:inherit;outline:none;box-sizing:border-box}._searchInput_18mna_63:focus{border-color:var(--brand-primary)}._list_18mna_80{flex:1;overflow-y:auto;min-height:0;padding:4px 0;scrollbar-width:thin;scrollbar-color:var(--scrollbar-thumb) var(--scrollbar-track)}._state_18mna_89{padding:24px 16px;font-size:12px;color:var(--text-muted);text-align:center;line-height:1.5}._stateError_18mna_97{padding:16px;font-size:12px;color:var(--status-error);text-align:center}._item_18mna_104{width:100%;display:flex;align-items:flex-start;gap:8px;padding:8px 12px;background:transparent;border:none;cursor:pointer;text-align:left;transition:background .12s;font-family:inherit;color:var(--text-primary);min-width:0}._item_18mna_104:hover{background:var(--bg-hover, rgba(255, 255, 255, .04))}._itemActive_18mna_124{background:var(--brand-primary-soft)}._itemActive_18mna_124:hover{background:color-mix(in srgb,var(--brand-primary) 18%,transparent)}._itemIcon_18mna_132{color:var(--text-muted);padding-top:1px;flex-shrink:0}._itemActive_18mna_124 ._itemIcon_18mna_132{color:var(--brand-primary-strong)}._itemBody_18mna_142{display:flex;flex-direction:column;gap:2px;min-width:0;flex:1}._itemTitle_18mna_150{display:block;max-width:100%;font-size:12px;font-weight:500;color:var(--text-primary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-transform:capitalize}._itemTask_18mna_162{display:block;max-width:100%;font-size:11px;color:var(--text-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}._itemBadge_18mna_172{display:inline-flex;align-items:center;width:fit-content;padding:2px 6px;border-radius:999px;border:1px solid color-mix(in srgb,var(--status-warning) 28%,transparent);background:color-mix(in srgb,var(--status-warning) 12%,transparent);color:color-mix(in srgb,var(--status-warning) 70%,white);font-size:10px;font-weight:600}._itemMeta_18mna_185{display:flex;align-items:center;justify-content:space-between;gap:8px;width:100%;font-size:10px;color:var(--text-muted)}._itemMetaDetails_18mna_195{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._itemMetaReference_18mna_202{flex-shrink:0;font-size:10px;font-weight:600;color:var(--text-secondary)}._viewer_ecebq_1{flex:1;display:flex;flex-direction:column;overflow:hidden;min-height:0;height:100%}._viewerMonochrome_ecebq_10 ._metaDocumentName_ecebq_10{color:#111!important}._viewerEditMode_ecebq_14{background:var(--bg-primary)}._meta_ecebq_10{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 20px;border-bottom:1px solid var(--border-subtle);background:var(--bg-secondary);flex-shrink:0;flex-wrap:wrap}._metaLeft_ecebq_30{display:flex;align-items:center;gap:12px;flex-wrap:wrap}._metaDocumentName_ecebq_10{font-size:14px;font-weight:700;color:var(--text-primary);max-width:min(26ch,100%);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;letter-spacing:-.015em;cursor:text}._metaRenameRow_ecebq_49{display:inline-flex;align-items:center;gap:8px;min-width:min(420px,100%)}._typeBadge_ecebq_56{display:inline-flex;align-items:center;gap:4px;padding:2px 8px;border-radius:999px;font-size:10px;font-weight:600;background:var(--brand-primary-soft);color:var(--brand-primary-strong);border:1px solid color-mix(in srgb,var(--brand-primary) 25%,transparent);text-transform:uppercase;letter-spacing:.3px}._typeBadgeImplementationPlan_ecebq_71{background:color-mix(in srgb,var(--status-info) 15%,transparent);color:color-mix(in srgb,var(--status-info) 55%,white);border-color:color-mix(in srgb,var(--status-info) 25%,transparent)}._typeBadgeReview_ecebq_77{background:color-mix(in srgb,var(--status-warning) 15%,transparent);color:color-mix(in srgb,var(--status-warning) 68%,white);border-color:color-mix(in srgb,var(--status-warning) 25%,transparent)}._typeBadgeWalkthrough_ecebq_83{background:color-mix(in srgb,var(--status-success) 15%,transparent);color:color-mix(in srgb,var(--status-success) 60%,white);border-color:color-mix(in srgb,var(--status-success) 25%,transparent)}._metaTaskName_ecebq_89{font-size:11px;color:var(--text-secondary);max-width:180px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}._statusBadge_ecebq_98{display:inline-flex;align-items:center;gap:4px;padding:2px 8px;border-radius:999px;border:1px solid color-mix(in srgb,var(--status-warning) 28%,transparent);background:color-mix(in srgb,var(--status-warning) 12%,transparent);color:color-mix(in srgb,var(--status-warning) 68%,white);font-size:10px;font-weight:600;letter-spacing:.2px;text-transform:uppercase}._metaDate_ecebq_113,._metaSize_ecebq_114{display:inline-flex;align-items:center;gap:4px;font-size:11px;color:var(--text-muted)}._actions_ecebq_122{display:flex;align-items:center;gap:6px;flex-shrink:0}._actionBtn_ecebq_129{display:inline-flex;align-items:center;gap:5px;padding:5px 10px;border-radius:6px;border:1px solid var(--border-subtle);background:transparent;color:var(--text-secondary);font-size:11px;font-family:inherit;cursor:pointer;transition:all .15s;white-space:nowrap}._actionBtn_ecebq_129:hover{background:var(--bg-hover);color:var(--text-primary);border-color:var(--border-primary)}._actionBtn_ecebq_129:disabled{opacity:.6;cursor:not-allowed}._dangerBtn_ecebq_156{border-color:color-mix(in srgb,var(--status-error) 35%,transparent)!important;color:color-mix(in srgb,var(--status-error) 45%,white)!important}._dangerBtn_ecebq_156:hover:not(:disabled){background:color-mix(in srgb,var(--status-error) 12%,transparent)!important;border-color:color-mix(in srgb,var(--status-error) 50%,transparent)!important;color:color-mix(in srgb,var(--status-error) 30%,white)!important}._generateBtn_ecebq_167{background:var(--brand-primary-soft)!important;border-color:var(--brand-primary-border)!important;color:var(--brand-primary-strong)!important}._generateBtn_ecebq_167:hover{background:color-mix(in srgb,var(--brand-primary) 24%,transparent)!important;color:color-mix(in srgb,var(--brand-primary-strong) 72%,white)!important}._editBtn_ecebq_178{color:var(--text-primary)!important;border-color:var(--border-primary)!important}._editBtn_ecebq_178:hover{background:color-mix(in srgb,var(--brand-primary) 10%,transparent)!important;border-color:var(--brand-primary-border)!important;color:var(--brand-primary-strong)!important}._saveBtn_ecebq_189{background:color-mix(in srgb,var(--brand-primary) 15%,transparent)!important;border-color:var(--brand-primary-border)!important;color:var(--brand-primary-strong)!important}._saveBtn_ecebq_189:hover:not(:disabled){background:color-mix(in srgb,var(--brand-primary) 25%,transparent)!important;color:color-mix(in srgb,var(--brand-primary-strong) 72%,white)!important}._saveBtn_ecebq_189:disabled{opacity:.4!important;cursor:not-allowed!important}._layoutToggle_ecebq_205{display:flex;background:var(--bg-primary);border:1px solid var(--border-subtle);border-radius:6px;overflow:hidden}._layoutBtn_ecebq_213{padding:5px 8px;background:transparent;border:none;color:var(--text-muted);cursor:pointer;display:flex;align-items:center;transition:all .12s}._layoutBtn_ecebq_213:hover{color:var(--text-primary);background:var(--bg-hover)}._layoutBtnActive_ecebq_229{color:var(--brand-primary-strong);background:var(--brand-primary-soft)}._saveStatus_ecebq_234{display:inline-flex;align-items:center;gap:4px;font-size:11px}._saveStatusSaved_ecebq_241{color:var(--status-success)}._saveStatusError_ecebq_245{color:var(--status-error);cursor:help}._unsaved_ecebq_250{font-size:11px;color:color-mix(in srgb,var(--status-warning) 70%,white);font-style:italic}._viewerContent_ecebq_256{flex:1;overflow-y:auto;padding:16px 24px 40px;min-height:0;scrollbar-width:thin;scrollbar-color:var(--scrollbar-thumb) var(--scrollbar-track)}._viewerBody_ecebq_265{flex:1;min-height:0;display:grid;grid-template-columns:minmax(0,1fr) 360px;align-items:stretch}._viewerBodyFullWidth_ecebq_273{grid-template-columns:minmax(0,1fr)}._viewerMain_ecebq_277{border-right:1px solid var(--border-subtle)}._viewerBodyFullWidth_ecebq_273 ._viewerMain_ecebq_277{border-right:none}._reviewRail_ecebq_285{min-height:0;overflow:hidden;background:color-mix(in srgb,var(--bg-secondary) 78%,transparent)}._printHint_ecebq_291{padding:0 24px 18px;color:var(--text-muted);font-size:11px;line-height:1.45}._reviewSection_ecebq_298{height:100%;min-height:0;padding:18px 18px 18px 16px;display:flex;flex-direction:column;gap:12px}._reviewHeader_ecebq_307{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;flex-wrap:wrap}._reviewTitle_ecebq_315{display:inline-flex;align-items:center;gap:8px;font-size:13px;font-weight:700;color:var(--text-primary)}._reviewSubtitle_ecebq_324{margin:4px 0 0;color:var(--text-muted);font-size:11px;line-height:1.45}._reviewControls_ecebq_331{display:flex;align-items:center;gap:8px;flex-wrap:wrap}._reviewSelect_ecebq_338{min-width:180px}._reviewSessionMeta_ecebq_342{display:flex;align-items:center;gap:10px;flex-wrap:wrap;font-size:11px}._reviewStatusResolved_ecebq_350{border-color:color-mix(in srgb,var(--status-success) 30%,transparent);background:color-mix(in srgb,var(--status-success) 12%,transparent);color:color-mix(in srgb,var(--status-success) 66%,white)}._reviewSessionLabel_ecebq_356{color:var(--text-secondary);font-weight:600}._reviewTitleEditRow_ecebq_361{display:inline-flex;align-items:center;gap:8px;flex-wrap:wrap}._reviewSessionTimestamp_ecebq_368{color:var(--text-muted)}._reviewAnchorLabel_ecebq_372{color:var(--text-muted);font-size:11px;padding:0 4px}._reviewComposer_ecebq_378{flex:1;display:flex;flex-direction:column;gap:8px}._reviewAnchorChip_ecebq_385{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:8px 10px;border:1px solid var(--border-subtle);border-radius:10px;background:var(--bg-secondary);color:var(--text-secondary);font-size:11px}._reviewAnchorSnippet_ecebq_398{color:var(--text-primary);font-style:italic}._reviewAnchorClear_ecebq_403{border:none;background:transparent;color:var(--brand-primary-strong);font:inherit;cursor:pointer;padding:0}._reviewAnchorClear_ecebq_403:hover{text-decoration:underline}._reviewCommentActions_ecebq_416{display:inline-flex;align-items:center;gap:6px;margin-left:auto}._reviewCommentAction_ecebq_416{border:none;background:transparent;color:var(--text-muted);font:inherit;cursor:pointer;padding:0}._reviewCommentAction_ecebq_416:hover{color:var(--text-primary);text-decoration:underline}._reviewCommentEditor_ecebq_437{display:flex;flex-direction:column;gap:8px}._viewerState_ecebq_443{padding:40px;text-align:center;color:var(--text-muted);font-size:13px}._viewerStateError_ecebq_450{padding:40px;text-align:center;color:var(--status-error);font-size:13px}._editorArea_ecebq_457{flex:1;display:flex;min-height:0;overflow:hidden}._editorPane_ecebq_464{flex:1;display:flex;flex-direction:column;min-width:0;border-right:1px solid var(--border-subtle)}._editorLayoutSplit_ecebq_472 ._editorPane_ecebq_464,._editorLayoutSplit_ecebq_472 ._previewPane_ecebq_473,._editorLayoutEditor_ecebq_477 ._editorPane_ecebq_464,._editorLayoutPreview_ecebq_478 ._previewPane_ecebq_473{flex:1}._editorPaneLabel_ecebq_482{padding:6px 12px;font-size:10px;font-weight:600;color:var(--text-muted);text-transform:uppercase;letter-spacing:.5px;border-bottom:1px solid var(--border-subtle);background:var(--bg-secondary);flex-shrink:0}._editorTextarea_ecebq_494{flex:1;width:100%;resize:none;background:var(--bg-primary);color:var(--text-primary);border:none;outline:none;padding:16px;font-family:Fira Code,Cascadia Code,JetBrains Mono,monospace;font-size:13px;line-height:1.65;tab-size:2;caret-color:var(--brand-primary-strong);scrollbar-width:thin;scrollbar-color:var(--scrollbar-thumb) var(--scrollbar-track);min-height:0;box-sizing:border-box}._editorTextarea_ecebq_494::selection{background:color-mix(in srgb,var(--brand-primary) 30%,transparent)}._previewPane_ecebq_473{flex:1;display:flex;flex-direction:column;min-width:0;overflow:hidden}._previewPane_ecebq_473 .docMarkdown{flex:1;overflow-y:auto;padding:16px 24px 40px;min-height:0;max-width:none;scrollbar-width:thin;scrollbar-color:var(--scrollbar-thumb) var(--scrollbar-track)}._markdownSurface_ecebq_536{color:var(--text-body);font-size:14px;line-height:1.7;max-width:800px}._markdownSurface_ecebq_536 h1,._markdownSurface_ecebq_536 h2,._markdownSurface_ecebq_536 h3,._markdownSurface_ecebq_536 h4{color:var(--text-primary);font-weight:700;margin:1.5em 0 .5em;line-height:1.3}._markdownSurface_ecebq_536 h1{font-size:1.6em}._markdownSurface_ecebq_536 h2{font-size:1.25em;border-bottom:1px solid var(--border-subtle);padding-bottom:.3em}._markdownSurface_ecebq_536 h3{font-size:1.1em}._markdownSurface_ecebq_536 p{margin:.8em 0}._markdownSurface_ecebq_536 a{color:var(--brand-primary-strong);text-decoration:underline;text-underline-offset:2px}._markdownSurface_ecebq_536 a:hover{color:color-mix(in srgb,var(--brand-primary-strong) 72%,white)}._markdownSurface_ecebq_536 code{font-family:Fira Code,Cascadia Code,monospace;font-size:.875em;background:var(--brand-primary-soft);padding:2px 5px;border-radius:4px;color:var(--code-inline-text, var(--brand-primary-strong))}._markdownSurface_ecebq_536 pre{background:var(--bg-primary);border:1px solid var(--border-subtle);border-radius:8px;padding:16px;overflow-x:auto;margin:1em 0}._markdownSurface_ecebq_536 pre code{background:none;padding:0;font-size:13px;color:var(--code-block-text, var(--text-body))}._markdownSurface_ecebq_536 blockquote{border-left:3px solid color-mix(in srgb,var(--brand-primary) 50%,transparent);padding-left:16px;margin:1em 0;color:var(--text-secondary);font-style:italic}._markdownSurface_ecebq_536 table{border-collapse:collapse;width:100%;margin:1em 0;font-size:13px}._markdownSurface_ecebq_536 th,._markdownSurface_ecebq_536 td{border:1px solid var(--border-subtle);padding:8px 12px;text-align:left}._markdownSurface_ecebq_536 th{background:var(--bg-secondary);font-weight:600;color:var(--text-secondary);font-size:11px;text-transform:uppercase;letter-spacing:.4px}._markdownSurface_ecebq_536 ul,._markdownSurface_ecebq_536 ol{padding-left:1.5em;margin:.5em 0}._markdownSurface_ecebq_536 li{margin:.3em 0}._markdownSurface_ecebq_536 li._task-list-item_ecebq_647,._markdownSurface_ecebq_536 li[data-task-item=true]{list-style:none}._markdownSurface_ecebq_536 li:has(input[type=checkbox]){list-style:none!important;list-style-type:none!important}._markdownSurface_ecebq_536 ul._contains-task-list_ecebq_657,._markdownSurface_ecebq_536 ol._contains-task-list_ecebq_657{padding-left:.25em}._markdownSurface_ecebq_536 ul:has(li input[type=checkbox]),._markdownSurface_ecebq_536 ol:has(li input[type=checkbox]){padding-left:1.25em!important}._markdownSurface_ecebq_536 li._task-list-item_ecebq_647>input[type=checkbox],._markdownSurface_ecebq_536 li[data-task-item=true]>input[type=checkbox]{margin-right:.45em;cursor:pointer;accent-color:var(--brand-primary-strong)}._markdownSurface_ecebq_536 hr{border:none;border-top:1px solid var(--border-subtle);margin:1.5em 0}._markdownSurface_ecebq_536 img{max-width:100%;border-radius:8px}._viewerMonochrome_ecebq_10 ._viewerContent_ecebq_256,._viewerMonochrome_ecebq_10 ._markdownSurface_ecebq_536{background:#fff!important}@media(max-width:1100px){._viewerBody_ecebq_265{grid-template-columns:minmax(0,1fr)}._viewerMain_ecebq_277{border-right:none;border-bottom:1px solid var(--border-subtle)}._reviewRail_ecebq_285{max-height:480px}._reviewSection_ecebq_298{padding:16px 24px 18px}}._viewerMonochrome_ecebq_10 ._markdownSurface_ecebq_536,._viewerMonochrome_ecebq_10 ._markdownSurface_ecebq_536 h1,._viewerMonochrome_ecebq_10 ._markdownSurface_ecebq_536 h2,._viewerMonochrome_ecebq_10 ._markdownSurface_ecebq_536 h3,._viewerMonochrome_ecebq_10 ._markdownSurface_ecebq_536 h4,._viewerMonochrome_ecebq_10 ._markdownSurface_ecebq_536 p,._viewerMonochrome_ecebq_10 ._markdownSurface_ecebq_536 li,._viewerMonochrome_ecebq_10 ._markdownSurface_ecebq_536 blockquote,._viewerMonochrome_ecebq_10 ._markdownSurface_ecebq_536 th,._viewerMonochrome_ecebq_10 ._markdownSurface_ecebq_536 td,._viewerMonochrome_ecebq_10 ._markdownSurface_ecebq_536 a{color:#111!important}._viewerMonochrome_ecebq_10 ._markdownSurface_ecebq_536 code{color:#111!important;background:#f2f2f2!important}._viewerMonochrome_ecebq_10 ._markdownSurface_ecebq_536 pre{background:#f7f7f7!important;border-color:#d7d7d7!important}._viewerMonochrome_ecebq_10 ._markdownSurface_ecebq_536 pre code,._viewerMonochrome_ecebq_10 ._markdownSurface_ecebq_536 code,._viewerMonochrome_ecebq_10 ._markdownSurface_ecebq_536 a,._viewerMonochrome_ecebq_10 ._metaTaskName_ecebq_89,._viewerMonochrome_ecebq_10 ._metaDate_ecebq_113,._viewerMonochrome_ecebq_10 ._metaSize_ecebq_114{color:#111!important}._attachModalBody_ecebq_745{display:flex;flex-direction:column;gap:12px;padding:8px 4px 4px}._attachModalCopy_ecebq_752{margin:0;color:var(--text-secondary);font-size:13px;line-height:1.5}._attachModalError_ecebq_759{display:flex;align-items:center;gap:8px;padding:10px 12px;border-radius:10px;border:1px solid var(--border-subtle);background:color-mix(in srgb,var(--status-danger) 10%,transparent);color:var(--status-danger);font-size:12px;font-weight:600}._attachTaskList_ecebq_772{display:flex;flex-direction:column;gap:8px;max-height:320px;overflow:auto;padding-right:2px}._attachTaskRow_ecebq_781{width:100%;display:flex;align-items:center;justify-content:space-between;gap:12px;padding:11px 12px;border-radius:12px;border:1px solid var(--border-subtle);background:var(--bg-elevated);color:var(--text-primary);text-align:left;cursor:pointer;transition:border-color .12s ease,transform .12s ease,background .12s ease}._attachTaskRow_ecebq_781:hover:not(:disabled){border-color:var(--brand-primary-strong);background:color-mix(in srgb,var(--brand-primary-strong) 8%,var(--bg-elevated));transform:translateY(-1px)}._attachTaskRow_ecebq_781:disabled{opacity:.72;cursor:wait}._attachTaskTitle_ecebq_808{min-width:0;flex:1;font-size:13px;font-weight:600;color:inherit}._attachTaskMeta_ecebq_816{flex-shrink:0;font-size:12px;font-weight:700;color:var(--text-secondary)}._attachEmptyState_ecebq_823{padding:18px 12px;border-radius:12px;border:1px dashed var(--border-subtle);color:var(--text-muted);text-align:center;font-size:13px}._overlay_1unik_1{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;background:#0000008c;z-index:2000;padding:1rem}._modal_1unik_12{width:min(720px,100%)}._header_1unik_16{align-items:flex-start}._title_1unik_20{font-size:1rem}._docName_1unik_24{font-size:.75rem;color:var(--text-secondary);max-width:14rem;text-align:right;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}._body_1unik_34{padding:.75rem 1rem 1rem;display:flex;flex-direction:column;gap:.75rem}._state_1unik_41{min-height:10rem;display:flex;align-items:center;justify-content:center;gap:.5rem;font-size:.875rem;color:var(--text-secondary);text-align:center}._stateError_1unik_52{min-height:10rem;display:flex;align-items:center;justify-content:center;gap:.5rem;font-size:.875rem;color:var(--status-error);text-align:center}._stateDone_1unik_63{min-height:10rem;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:.5rem;text-align:center}._stateDone_1unik_63 strong{color:var(--text-primary);font-size:1rem}._stateDone_1unik_63 p{margin:0;font-size:.8125rem;color:var(--text-secondary)}._toolbar_1unik_84{display:flex;align-items:center;justify-content:space-between;gap:.75rem;padding:.625rem .75rem;border:1px solid var(--border-default);border-radius:var(--radius-md);background:var(--surface-inset)}._toolbarCount_1unik_95{font-size:.75rem;color:var(--text-secondary)}._toolbarActions_1unik_100{display:flex;gap:.5rem}._tree_1unik_105{display:flex;flex-direction:column;gap:.125rem;max-height:22rem;overflow-y:auto}._taskRow_1unik_113{display:flex;align-items:center;gap:.375rem;padding:.4375rem .75rem;min-height:2.125rem;transition:background .1s}._taskRow_1unik_113:hover{background:#ffffff08}._taskRowDimmed_1unik_126{opacity:.4}._taskCheck_1unik_130{background:transparent;border:none;cursor:pointer;display:flex;padding:0;flex-shrink:0}._taskExpandBtn_1unik_139{background:transparent;border:none;color:var(--text-muted);cursor:pointer;display:flex;align-items:center;padding:0;flex-shrink:0;transition:color .1s}._taskExpandBtn_1unik_139:hover{color:var(--text-primary)}._taskExpandSpacer_1unik_155{width:12px;flex-shrink:0}._taskTitle_1unik_160{flex:1;font-size:.8125rem;color:var(--text-primary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}._taskBadge_1unik_169{font-size:.625rem;padding:.125rem .375rem;border-radius:var(--radius-sm);border:1px solid currentColor;opacity:.85;white-space:nowrap;flex-shrink:0}._footer_1unik_179{display:flex;align-items:center;justify-content:flex-end;gap:.625rem;padding:0 1rem 1rem}