@taskforcehq/taskforce 0.3.327 → 0.3.328
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Taskforce.module.css +24 -53
- package/dist/components/activity/EntityActivityTimeline.js +15 -5
- package/dist/components/context/AttachmentPreviewHost.js +1 -1
- package/dist/components/context/ContextAttachmentManager.d.ts +3 -0
- package/dist/components/context/ContextAttachmentManager.js +116 -20
- package/dist/components/features/planning/PlanningEntitySummary.d.ts +3 -1
- package/dist/components/features/planning/PlanningEntitySummary.js +3 -2
- package/dist/components/features/planning/PlanningLinkPicker.d.ts +3 -1
- package/dist/components/features/planning/PlanningLinkPicker.js +5 -3
- package/dist/components/features/planning/PlanningModule.js +26 -9
- package/dist/components/features/planning/PlanningVisualIdentity.d.ts +14 -0
- package/dist/components/features/planning/PlanningVisualIdentity.js +106 -0
- package/dist/components/features/planning/planningWorkspaceModel.d.ts +11 -0
- package/dist/components/task/TaskActionHeader.d.ts +2 -1
- package/dist/components/task/TaskActionHeader.js +2 -2
- package/dist/components/task/TaskCard.js +37 -4
- package/dist/components/task/TaskContextUpload.d.ts +3 -0
- package/dist/components/task/TaskContextUpload.js +2 -2
- package/dist/components/task/TaskForm.d.ts +4 -0
- package/dist/components/task/TaskForm.js +32 -7
- package/dist/components/task/TaskImageReviews.js +16 -16
- package/dist/components/task/TaskStatusActions.js +11 -2
- package/dist/components/task/TaskWorkstreamPicker.js +2 -1
- package/dist/components/ui/DocumentTypeIcon.d.ts +7 -0
- package/dist/components/ui/DocumentTypeIcon.js +8 -0
- package/dist/components/ui/TaxonomyDropdown.d.ts +9 -1
- package/dist/components/ui/TaxonomyDropdown.js +30 -3
- package/dist/components/views/StandaloneLayout.js +62 -9
- package/dist/components/views/WidgetView.js +8 -5
- package/dist/components/views/panels/PlanningDrawer.d.ts +7 -1
- package/dist/components/views/panels/PlanningDrawer.js +48 -44
- package/dist/config/envSchema.js +1 -0
- package/dist/config/localServiceCloudTarget.d.ts +10 -0
- package/dist/config/localServiceCloudTarget.js +76 -0
- package/dist/core/AiProfileService.d.ts +1 -0
- package/dist/core/AiProfileService.js +2 -1
- package/dist/core/AttachmentLinkService.js +7 -4
- package/dist/core/DeletedTaskLifecycleService.d.ts +4 -0
- package/dist/core/DeletedTaskLifecycleService.js +21 -0
- package/dist/core/McpTokenService.d.ts +4 -0
- package/dist/core/McpTokenService.js +52 -0
- package/dist/core/TaskAttachmentLinksDurableMutationService.d.ts +5 -0
- package/dist/core/TaskAttachmentLinksDurableMutationService.js +20 -11
- package/dist/core/Taskforce.d.ts +63 -1
- package/dist/core/Taskforce.js +558 -73
- package/dist/core/types.d.ts +2 -1
- package/dist/documentReviews/DocumentReviewCommentStore.d.ts +11 -0
- package/dist/documentReviews/DocumentReviewCommentStore.js +35 -2
- package/dist/documentReviews/service.d.ts +4 -0
- package/dist/documentReviews/service.js +141 -46
- package/dist/hooks/tasks/useTaskFormActions.d.ts +3 -0
- package/dist/hooks/tasks/useTaskFormActions.js +33 -7
- package/dist/hooks/useTaskforce.d.ts +59 -50
- package/dist/hooks/useTaskforce.js +103 -1
- package/dist/mcp/canonicalAssetHelpers.d.ts +13 -0
- package/dist/mcp/canonicalAssetHelpers.js +39 -5
- package/dist/mcp/collaborationRegistrar.js +15 -13
- package/dist/mcp/documentAssetRegistrar.js +16 -9
- package/dist/mcp/localServiceProxy.js +4 -1
- package/dist/mcp/runtime.d.ts +16 -0
- package/dist/mcp/runtime.js +566 -171
- package/dist/mcp/taskAttachmentCommandAdapter.d.ts +2 -0
- package/dist/mcp/taskAttachmentCommandAdapter.js +14 -8
- package/dist/mcp/taskPlanningRegistrar.js +42 -34
- package/dist/mcp/toolRegistry.js +2 -2
- package/dist/migrations/taskSchemaMigrations.js +35 -0
- package/dist/runtime/appGateDefinitions.d.ts +2 -2
- package/dist/runtime/appGateDefinitions.js +2 -2
- package/dist/server/appAccess.d.ts +12 -0
- package/dist/server/appAccess.js +21 -0
- package/dist/server/authorizedWorkspaceAccess.d.ts +12 -0
- package/dist/server/authorizedWorkspaceAccess.js +40 -0
- package/dist/server/cloudCollectionRead.d.ts +25 -0
- package/dist/server/cloudCollectionRead.js +120 -0
- package/dist/server/cloudCollectionReadPool.d.ts +52 -0
- package/dist/server/cloudCollectionReadPool.js +140 -0
- package/dist/server/cloudCollectionReadWorker.d.ts +1 -0
- package/dist/server/cloudCollectionReadWorker.js +36 -0
- package/dist/server/index.d.ts +3 -11
- package/dist/server/index.js +53 -40
- package/dist/server/localServiceLease.d.ts +3 -0
- package/dist/server/localServiceLease.js +9 -1
- package/dist/server/routes/documents.d.ts +5 -2
- package/dist/server/routes/documents.js +160 -13
- package/dist/server/routes/durableTaskHttpRouters.d.ts +2 -0
- package/dist/server/routes/durableTaskHttpRouters.js +2 -2
- package/dist/server/routes/localService.js +2 -0
- package/dist/server/routes/primitives.d.ts +2 -0
- package/dist/server/routes/shared.d.ts +24 -0
- package/dist/server/routes/shared.js +114 -18
- package/dist/server/routes/sync.js +22 -0
- package/dist/server/routes/syncV3FeedRoutes.js +4 -2
- package/dist/server/routes/syncV3LocalCaptureRoutes.js +20 -2
- package/dist/server/routes/syncV3OperationRoutes.js +17 -2
- package/dist/server/routes/tasks.js +199 -89
- package/dist/server/routes.js +35 -7
- package/dist/service/localServiceCli.js +36 -25
- package/dist/service/localServiceClientLifecycle.js +67 -6
- package/dist/shared/planningIdentity.d.ts +20 -0
- package/dist/shared/planningIdentity.js +79 -0
- package/dist/storage/postgresAdapter.js +4 -0
- package/dist/storage/postgresRequestDiagnostics.d.ts +8 -0
- package/dist/storage/postgresRequestDiagnostics.js +24 -0
- package/dist/storage/workspaceAssetStore.d.ts +32 -0
- package/dist/storage/workspaceAssetStore.js +70 -0
- package/dist/sync/coordinator/localSyncExecutionPermitStore.d.ts +16 -0
- package/dist/sync/coordinator/localSyncExecutionPermitStore.js +70 -22
- package/dist/sync/coordinator/workspaceSyncTransportGateway.js +4 -2
- package/dist/sync/engine/workspaceSyncEngineRemoteServices.d.ts +5 -0
- package/dist/sync/engine/workspaceSyncEngineServerRemoteServices.d.ts +1 -1
- package/dist/sync/engine/workspaceSyncEngineServerRemoteServices.js +15 -0
- package/dist/sync/engine/workspaceSyncEngineServerRunnerOperations.js +26 -3
- package/dist/sync/engine/workspaceSyncV2ChangeDispatcher.js +2 -0
- package/dist/sync/syncApplyHandlers.d.ts +3 -1
- package/dist/sync/syncApplyHandlers.js +29 -0
- package/dist/sync/syncService.js +9 -0
- package/dist/sync/taskSyncPayload.d.ts +1 -0
- package/dist/sync/taskSyncPayload.js +6 -0
- package/dist/sync/v3/durableTaskAttachmentLinksMutationRouter.d.ts +1 -0
- package/dist/sync/v3/durableTaskAttachmentLinksMutationRouter.js +21 -3
- package/dist/sync/v3/durableTaskHttpBulkMutationRouter.js +17 -4
- package/dist/sync/v3/localInitiativeOutboxService.js +4 -2
- package/dist/sync/v3/localOutboxDispatcher.js +5 -1
- package/dist/sync/v3/localTaskAttachmentLinksOutboxHandler.js +12 -2
- package/dist/sync/v3/localTaskAttachmentLinksOutboxService.d.ts +1 -0
- package/dist/sync/v3/localTaskAttachmentLinksOutboxService.js +15 -3
- package/dist/sync/v3/localWorkstreamOutboxService.js +4 -2
- package/dist/sync/v3/syncDurabilityStore.d.ts +8 -0
- package/dist/sync/v3/syncDurabilityStore.js +171 -33
- package/dist/sync/v3/taskAttachmentLinksMutationService.d.ts +1 -0
- package/dist/sync/v3/taskAttachmentLinksMutationService.js +18 -2
- package/dist/sync/v3/taskMetadataCoexistence.js +4 -0
- package/dist/sync/v3/workspaceSyncV2ProjectionExclusions.js +1 -9
- package/dist/sync/v3/workspaceSyncV3CloudOperationHandler.js +1 -0
- package/dist/sync/v3/workspaceSyncV3CombinedFeedOrchestrator.js +7 -1
- package/dist/sync/v3/workspaceSyncV3CombinedLocalApply.js +15 -3
- package/dist/sync/v3/workspaceSyncV3CombinedRepairBaseline.d.ts +4 -0
- package/dist/sync/v3/workspaceSyncV3CombinedRepairBaseline.js +29 -6
- package/dist/sync/v3/workspaceSyncV3CombinedRepairMaterialization.d.ts +1 -0
- package/dist/sync/v3/workspaceSyncV3CombinedRepairMaterialization.js +29 -7
- package/dist/sync/v3/workspaceSyncV3CombinedRepairSnapshot.js +62 -7
- package/dist/sync/v3/workspaceSyncV3OperationProtocol.d.ts +1 -0
- package/dist/sync/v3/workspaceSyncV3RepairSqlBatching.d.ts +2 -0
- package/dist/sync/v3/workspaceSyncV3RepairSqlBatching.js +10 -0
- package/dist/sync/v3/workspaceSyncV3TaskRootProjection.d.ts +1 -1
- package/dist/sync/v3/workspaceSyncV3TaskRootProjection.js +1 -1
- package/dist/sync/workspacePullFeed.d.ts +6 -1
- package/dist/sync/workspacePullFeed.js +172 -161
- package/dist/sync/workspaceSyncModel.d.ts +11 -0
- package/dist/sync/workspaceSyncModel.js +27 -2
- package/dist/types.d.ts +8 -0
- package/dist/ui/assets/{AiIdentityRosterCard-DB1BLO_j.js → AiIdentityRosterCard-MZs7lVED.js} +1 -1
- package/dist/ui/assets/{AiProfilesModule-DPxQeF9N.js → AiProfilesModule-C3i0LOxe.js} +1 -1
- package/dist/ui/assets/{AnnotatedAttachmentWorkspace-DHNYaNg6.js → AnnotatedAttachmentWorkspace-DVZk5Tln.js} +1 -1
- package/dist/ui/assets/AssetTraySortControl-Kf1pelSy.js +1 -0
- package/dist/ui/assets/ContextAttachmentManager-B8boOs6Q.js +3 -0
- package/dist/ui/assets/{DocumentWorkspace-BC7sy5TG.js → DocumentWorkspace-DXH4XUsB.js} +4 -4
- package/dist/ui/assets/EntityActivityTimeline-BtSTq0ON.js +1 -0
- package/dist/ui/assets/PlanningModule-BPVyEa-f.js +1 -0
- package/dist/ui/assets/PlanningModule-CoIR9hbV.css +1 -0
- package/dist/ui/assets/{PlansPage-BVH_NfgT.js → PlansPage-ChqgxALc.js} +1 -1
- package/dist/ui/assets/TaskContextUpload-CB3ol0sN.js +1 -0
- package/dist/ui/assets/TaskContextUpload-qmBeUw3u.css +1 -0
- package/dist/ui/assets/{TaskSettings-xVsxSa0g.js → TaskSettings-g4ECKNOz.js} +1 -1
- package/dist/ui/assets/{TaskforceAgentsModule-CkAxW19K.js → TaskforceAgentsModule-BazdUwxZ.js} +1 -1
- package/dist/ui/assets/WorkflowManagerModule-DWFspC-o.js +1 -0
- package/dist/ui/assets/index-BUplSsv_.js +7 -0
- package/dist/ui/assets/index-gz2EXuoK.css +1 -0
- package/dist/ui/assets/{vendor-icons-B8ZNsH1g.js → vendor-icons-BkFLXavV.js} +1 -1
- package/dist/ui/index.html +3 -3
- package/dist/utils/constants.d.ts +2 -2
- package/dist/utils/constants.js +1 -1
- package/dist/utils/contextAttachmentUpload.d.ts +2 -0
- package/dist/utils/contextAttachmentUpload.js +7 -0
- package/dist/utils/contextFiles.d.ts +1 -1
- package/dist/utils/contextFiles.js +4 -4
- package/package.json +6 -1
- package/dist/ui/assets/AssetTraySortControl-DphbyHVc.js +0 -1
- package/dist/ui/assets/ContextAttachmentManager-CMxSzHqc.js +0 -3
- package/dist/ui/assets/EntityActivityTimeline-pJ2ZjZ-k.js +0 -1
- package/dist/ui/assets/PlanningModule-CeTqXMMz.css +0 -1
- package/dist/ui/assets/PlanningModule-t5GbvVR9.js +0 -1
- package/dist/ui/assets/TaskContextUpload-Ds4LnDzV.css +0 -1
- package/dist/ui/assets/TaskContextUpload-bl4fOOUz.js +0 -1
- package/dist/ui/assets/WorkflowManagerModule-BKqIGVnF.js +0 -1
- package/dist/ui/assets/index-BzJlVnNS.css +0 -1
- package/dist/ui/assets/index-Cx7vZJHL.js +0 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{R as ue,j as e,r as s,s as Ds}from"./vendor-react-CKJs5o3c.js";import{i as vn,j as et,k as tt,m as Gn,f as U,t as me,o as Qn,p as Jn,q as $s,s as Ms,u as Bs,R as Ls,v as Lt,M as Fs,w as Yn,x as Xn,y as Zn}from"./index-Cx7vZJHL.js";import{A as Ps,a as zs}from"./AssetTraySortControl-DphbyHVc.js";import{t as Os,Z as Hs,S as Ws,aG as Vs,R as dn,aC as Us,aH as Ks,aI as qs,$ as un,n as Gs,aa as mn,X as hn,aJ as es,d as Ft,j as ht,aK as Qs,aL as Js,a as Ys,i as Xs,aM as Zs,aN as er,aO as tr,y as ut,aP as nr,aF as Bt,x as sr,w as rr,aQ as ts,D as ar,aR as or,T as ns,P as ir,f as lr,o as cr,B as dr,U as ur,aS as mr}from"./vendor-icons-B8ZNsH1g.js";import"./vendor-markdown-_lhNCyq-.js";import"./vendor-dnd-CJ-AjP-Y.js";import"./vendor-router-AqJMU8Lz.js";const hr="_index_1ya8h_1",fr="_header_1ya8h_8",pr="_title_1ya8h_23",vr="_search_1ya8h_35",wr="_searchIcon_1ya8h_41",gr="_searchInput_1ya8h_50",yr="_sortControlRow_1ya8h_67",br="_filters_1ya8h_74",_r="_filtersHeader_1ya8h_83",xr="_filtersTitle_1ya8h_90",Cr="_filterControls_1ya8h_102",kr="_list_1ya8h_114",Sr="_state_1ya8h_126",Rr="_stateError_1ya8h_134",jr="_item_1ya8h_141",Nr="_itemActive_1ya8h_163",Tr="_itemIcon_1ya8h_173",Er="_pinButton_1ya8h_183",Ar="_pinButtonActive_1ya8h_205",Ir="_itemBody_1ya8h_209",Dr="_itemTitle_1ya8h_217",$r="_itemTask_1ya8h_229",Mr="_itemBadge_1ya8h_240",Br="_itemMeta_1ya8h_253",Lr="_itemMetaDetails_1ya8h_264",Fr="_itemMetaReference_1ya8h_271",E={index:hr,header:fr,title:pr,search:vr,searchIcon:wr,searchInput:gr,sortControlRow:yr,filters:br,filtersHeader:_r,filtersTitle:xr,filterControls:Cr,list:kr,state:Sr,stateError:Rr,item:jr,itemActive:Nr,itemIcon:Tr,pinButton:Er,pinButtonActive:Ar,itemBody:Ir,itemTitle:Dr,itemTask:$r,itemBadge:Mr,itemMeta:Br,itemMetaDetails:Lr,itemMetaReference:Fr};function fn(n){let l=n;try{l=decodeURIComponent(n)}catch{l=n}return l.trim().replace(/\\/g,"/").replace(/^\/+/,"").replace(/^\.\//,"").replace(/^\.taskforce\//,"")}function Xe(n,l){const h=String(l||"").trim();if(!h)return n;const i=n.includes("?")?"&":"?";return`${n}${i}workspaceId=${encodeURIComponent(h)}`}function Pr(n,l){return!!(n===l||n.endsWith(`/${l}`)||l.endsWith(`/${n}`))}function ss(n){const l=fn(String(n||""));if(!l)return null;const h=l.match(/(^|\/)(asset-[a-f0-9]{32})(?=[^/]*$)/i);return h?.[2]?h[2].toLowerCase():null}function is(n){return Array.isArray(n.targets)?n.targets.length:typeof n.attachmentCount=="number"&&Number.isFinite(n.attachmentCount)?Math.max(0,Math.floor(n.attachmentCount)):n.taskId?1:0}function wn(n){return Array.isArray(n.targets)?n.targets.length>0?"attached":"unattached":n.attachmentState==="attached"||n.attachmentState==="unattached"?n.attachmentState:is(n)>0?"attached":"unattached"}function zr(n,l,h,i){const d=l.trim().toLowerCase();return n.filter(c=>{const b=[vn(c),c.title,c.originalFilename,c.referenceLabel,c.referenceNumber].filter(j=>j!=null).join(" ").toLowerCase(),k=d.length===0||b.includes(d),S=h.length===0||h.includes(c.docType),I=wn(c),T=i.length===0||i.includes(I);return k&&S&&T})}function Or({docType:n}){switch(n){case"implementation-plan":return e.jsx(Gs,{size:13});case"review":return e.jsx(un,{size:13});case"walkthrough":return e.jsx(qs,{size:13});default:return e.jsx(Ks,{size:13})}}function Hr(n){return n<1024?`${n}B`:n<1024*1024?`${(n/1024).toFixed(1)}KB`:`${(n/(1024*1024)).toFixed(1)}MB`}function Wr(n){if(!n)return"";const l=new Date(n),i=new Date().getTime()-l.getTime(),d=Math.floor(i/(1e3*60*60*24));return d===0?"Today":d===1?"Yesterday":d<7?`${d}d ago`:d<30?`${Math.floor(d/7)}w ago`:l.toLocaleDateString()}function Vr(n,l){n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),l())}function an(n,l=!1){return n==="initiative"?l?"initiatives":"initiative":n==="workstream"?l?"workstreams":"workstream":l?"tasks":"task"}function Ur(n,l){const h=n.targets;if(Array.isArray(h)){if(h.length===0)return null;const c=[...new Map(h.map(b=>[`${b.targetType}:${b.targetId}`,b])).values()];if(h.length!==c.length){if(c.length===1){const b=c[0],k=b.title||b.referenceLabel||an(b.targetType);return`${h.length} links to ${k}`}return`${h.length} links across ${c.length} items`}if(c.length===1){const b=c[0];return b.title||b.referenceLabel||`1 ${an(b.targetType)} linked`}return new Set(c.map(b=>b.targetType)).size===1?`${c.length} ${an(c[0].targetType,!0)} linked`:`${c.length} items linked`}const i=is(n),d=n.taskId?l.get(n.taskId):null;return i>1?`${i} tasks linked`:i===1?d?.title||"1 task linked":null}function Kr({documents:n,selectedDocId:l,loading:h,error:i,searchQuery:d,sortField:c,sortOrder:p,pinnedDocIds:b=[],onTogglePinnedDoc:k,taskById:S,onSearchChange:I,onSelect:T,onCloseTray:j,onSortFieldChange:Q,onSortOrderChange:J,hasActiveFilters:$,typeFilters:ie,attachmentFilters:z,onTypeFiltersChange:N,onAttachmentFiltersChange:H,listScrollTop:Y=0,onListScrollChange:X}){const L=ue.useRef(null),x=ue.useRef(null),R=ue.useRef(null),O=ue.useRef(X);ue.useEffect(()=>{O.current=X},[X]),ue.useEffect(()=>{const w=L.current;if(!w)return;const re=Math.max(0,Math.round(Y));Math.abs(w.scrollTop-re)<=1||(w.scrollTop=re)},[n.length,i,Y,h]),ue.useEffect(()=>()=>{R.current!==null&&(window.clearTimeout(R.current),R.current=null)},[]);const W=ue.useCallback(()=>{R.current!==null&&(window.clearTimeout(R.current),R.current=null);const w=x.current;x.current=null,w!==null&&O.current?.(w)},[]),K=ue.useCallback(w=>{x.current=Math.max(0,Math.round(w)),R.current===null&&(R.current=window.setTimeout(W,200))},[W]),le=+(ie.length!==et.length)+ +(z.length!==tt.length),Ne=`${le} active document ${le===1?"filter":"filters"}`,we=()=>{N(et.map(w=>w.value)),H(tt.map(w=>w.value))};return e.jsxs("div",{className:E.index,children:[e.jsxs("div",{className:E.header,children:[e.jsxs("span",{className:E.title,children:[e.jsx(Os,{size:14}),"Documents"]}),j?e.jsx("button",{type:"button",className:"tf-control-icon",onClick:j,title:"Collapse document tray","aria-label":"Collapse document tray",children:e.jsx(Hs,{size:16})}):null]}),e.jsxs("div",{className:E.search,children:[e.jsx(Ws,{size:12,className:E.searchIcon}),e.jsx("input",{type:"text",placeholder:"Search documents…",value:d,onChange:w=>I(w.target.value),className:E.searchInput})]}),e.jsx("div",{className:E.sortControlRow,children:e.jsx(Ps,{field:c,order:p,onFieldChange:Q,onOrderChange:J})}),e.jsxs("section",{className:E.filters,"aria-label":"Document filters",children:[e.jsxs("div",{className:E.filtersHeader,children:[e.jsxs("span",{className:E.filtersTitle,children:[e.jsx(Vs,{size:12,"aria-hidden":"true"}),"Filters",le>0?e.jsx("span",{className:"tf-chip-count","aria-label":Ne,children:le}):null]}),e.jsx("button",{type:"button",className:"tf-control-icon",onClick:we,disabled:le===0,"aria-label":"Reset document filters",title:"Reset document filters",children:e.jsx(dn,{size:13,"aria-hidden":"true"})})]}),e.jsxs("div",{className:E.filterControls,children:[e.jsx(Gn,{label:"Attachment",options:tt,selected:z,onChange:w=>H(w),variant:"value",containerStyle:{minWidth:0}}),e.jsx(Gn,{label:"Type",options:et,selected:ie,onChange:w=>N(w),variant:"value",containerStyle:{minWidth:0}})]})]}),e.jsxs("div",{ref:L,className:`${E.list} tf-scrollbar tf-tray-scroll-viewport`,"data-testid":"doc-index-list",onScroll:w=>K(w.currentTarget.scrollTop),children:[h&&e.jsx("div",{className:E.state,children:"Loading documents…"}),!h&&i&&e.jsx("div",{className:E.stateError,children:i}),!h&&!i&&n.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&&n.map(w=>{const re=w.assetId===l,A=b.includes(w.assetId),M=vn(w),q=wn(w),Ce=Ur(w,S);return e.jsxs("div",{role:"button",tabIndex:0,className:`${E.item} ${re?E.itemActive:""}`,onClick:()=>T(w),onKeyDown:fe=>Vr(fe,()=>T(w)),children:[e.jsx("div",{className:E.itemIcon,children:e.jsx(Or,{docType:w.docType})}),e.jsxs("div",{className:E.itemBody,children:[e.jsx("span",{className:E.itemTitle,title:M,children:M}),q==="unattached"&&e.jsx("span",{className:E.itemBadge,children:"Unattached"}),Ce&&e.jsx("span",{className:E.itemTask,title:Ce,children:Ce}),e.jsxs("span",{className:E.itemMeta,children:[e.jsxs("span",{className:E.itemMetaDetails,children:[Hr(w.sizeBytes),w.updatedAt&&e.jsxs(e.Fragment,{children:[" · ",Wr(w.updatedAt)]})]}),w.referenceLabel&&e.jsx("span",{className:E.itemMetaReference,children:w.referenceLabel})]})]}),k?e.jsx("button",{type:"button",className:`${E.pinButton} ${A?E.pinButtonActive:""}`.trim(),"aria-label":A?"Unpin document":"Pin document",title:A?`Unpin ${M}`:`Pin ${M}`,"aria-pressed":A,onClick:fe=>{fe.stopPropagation(),k(w.assetId)},onKeyDown:fe=>fe.stopPropagation(),children:e.jsx(Us,{size:14,fill:A?"currentColor":"none"})}):null]},w.assetId)})]})]})}const qr="_viewer_1glbl_1",Gr="_viewerMonochrome_1glbl_10",Qr="_metaDocumentName_1glbl_10",Jr="_viewerEditMode_1glbl_14",Yr="_meta_1glbl_10",Xr="_metaLeft_1glbl_30",Zr="_metaRenameRow_1glbl_49",ea="_typeBadge_1glbl_56",ta="_typeBadgeImplementationPlan_1glbl_71",na="_typeBadgeReview_1glbl_77",sa="_typeBadgeWalkthrough_1glbl_83",ra="_metaTaskName_1glbl_89",aa="_statusBadge_1glbl_98",oa="_metaDate_1glbl_113",ia="_metaSize_1glbl_114",la="_actions_1glbl_122",ca="_actionBtn_1glbl_129",da="_dangerBtn_1glbl_156",ua="_generateBtn_1glbl_167",ma="_editBtn_1glbl_178",ha="_saveBtn_1glbl_189",fa="_layoutToggle_1glbl_205",pa="_layoutBtn_1glbl_213",va="_layoutBtnActive_1glbl_229",wa="_saveStatus_1glbl_234",ga="_saveStatusSaved_1glbl_241",ya="_saveStatusError_1glbl_245",ba="_unsaved_1glbl_250",_a="_viewerContent_1glbl_256",xa="_viewerBody_1glbl_265",Ca="_viewerBodyFullWidth_1glbl_274",ka="_viewerMain_1glbl_278",Sa="_reviewRail_1glbl_286",Ra="_reviewSection_1glbl_292",ja="_reviewHeader_1glbl_299",Na="_reviewHeaderTop_1glbl_309",Ta="_reviewHeaderActions_1glbl_316",Ea="_reviewCloseButton_1glbl_322",Aa="_reviewEyebrow_1glbl_326",Ia="_reviewSubtitle_1glbl_334",Da="_reviewMetadataRow_1glbl_341",$a="_reviewMetadata_1glbl_341",Ma="_reviewSessionTitle_1glbl_355",Ba="_reviewEmptyHeading_1glbl_356",La="_reviewSessionDetails_1glbl_366",Fa="_reviewVersionDetails_1glbl_375",Pa="_reviewDraftNotice_1glbl_383",za="_reviewVersionNotice_1glbl_384",Oa="_reviewControls_1glbl_406",Ha="_reviewCreateButton_1glbl_415",Wa="_reviewResolutionAction_1glbl_416",Va="_reviewSelect_1glbl_431",Ua="_reviewTitleEditRow_1glbl_438",Ka="_reviewTitleInput_1glbl_444",qa="_reviewWorkspace_1glbl_451",Ga="_reviewThread_1glbl_459",Qa="_reviewNewCommentsBar_1glbl_469",Ja="_reviewEmptyState_1glbl_477",Ya="_reviewComment_1glbl_490",Xa="_reviewCommentThread_1glbl_511",Za="_reviewReplies_1glbl_517",eo="_reviewReply_1glbl_526",to="_reviewThreadActions_1glbl_531",no="_reviewReplyComposer_1glbl_540",so="_reviewReplyInput_1glbl_548",ro="_reviewReplyComposerActions_1glbl_553",ao="_reviewCommentHeader_1glbl_559",oo="_reviewCommentAvatar_1glbl_566",io="_reviewCommentAuthor_1glbl_578",lo="_reviewCommentTime_1glbl_588",co="_reviewCommentActions_1glbl_594",uo="_reviewCommentHeaderControls_1glbl_600",mo="_reviewCommentAction_1glbl_594",ho="_reviewCommentDeleteAction_1glbl_616",fo="_reviewAnchorLabel_1glbl_622",po="_reviewAnchorRow_1glbl_637",vo="_reviewAnchorMoved_1glbl_645",wo="_reviewAnchorUnresolved_1glbl_646",go="_reviewAnchorUnknown_1glbl_647",yo="_reviewCommentBody_1glbl_675",bo="_reviewCommentEditor_1glbl_691",_o="_reviewCommentEditInput_1glbl_698",xo="_reviewComposerArea_1glbl_703",Co="_reviewComposerRow_1glbl_713",ko="_reviewComposerInput_1glbl_719",So="_reviewSendButton_1glbl_728",Ro="_reviewComposerHint_1glbl_735",jo="_reviewResolvedComposer_1glbl_740",No="_reviewResolvedIcon_1glbl_751",To="_reviewResolvedCopy_1glbl_762",Eo="_reviewAnchorChip_1glbl_776",Ao="_reviewAnchorSnippet_1glbl_789",Io="_reviewAnchorClear_1glbl_799",Do="_viewerState_1glbl_814",$o="_viewerStateError_1glbl_821",Mo="_editorArea_1glbl_828",Bo="_editorPane_1glbl_834",Lo="_editorLayoutSplit_1glbl_842",Fo="_previewPane_1glbl_843",Po="_editorLayoutEditor_1glbl_847",zo="_editorLayoutPreview_1glbl_848",Oo="_editorPaneLabel_1glbl_852",Ho="_editorTextarea_1glbl_864",Wo="_markdownSurface_1glbl_906",Vo="_readerSurface_1glbl_911",Uo="_attachModalBody_1glbl_1040",Ko="_attachModalCopy_1glbl_1047",qo="_attachModalError_1glbl_1054",Go="_attachTaskList_1glbl_1067",Qo="_attachTaskRow_1glbl_1076",Jo="_attachTaskTitle_1glbl_1103",Yo="_attachTaskInfo_1glbl_1109",Xo="_attachTaskReference_1glbl_1117",Zo="_attachTaskMeta_1glbl_1124",ei="_attachEmptyState_1glbl_1131",a={viewer:qr,viewerMonochrome:Gr,metaDocumentName:Qr,viewerEditMode:Jr,meta:Yr,metaLeft:Xr,metaRenameRow:Zr,typeBadge:ea,typeBadgeImplementationPlan:ta,typeBadgeReview:na,typeBadgeWalkthrough:sa,metaTaskName:ra,statusBadge:aa,metaDate:oa,metaSize:ia,actions:la,actionBtn:ca,dangerBtn:da,generateBtn:ua,editBtn:ma,saveBtn:ha,layoutToggle:fa,layoutBtn:pa,layoutBtnActive:va,saveStatus:wa,saveStatusSaved:ga,saveStatusError:ya,unsaved:ba,viewerContent:_a,viewerBody:xa,viewerBodyFullWidth:Ca,viewerMain:ka,reviewRail:Sa,reviewSection:Ra,reviewHeader:ja,reviewHeaderTop:Na,reviewHeaderActions:Ta,reviewCloseButton:Ea,reviewEyebrow:Aa,reviewSubtitle:Ia,reviewMetadataRow:Da,reviewMetadata:$a,reviewSessionTitle:Ma,reviewEmptyHeading:Ba,reviewSessionDetails:La,reviewVersionDetails:Fa,reviewDraftNotice:Pa,reviewVersionNotice:za,reviewControls:Oa,reviewCreateButton:Ha,reviewResolutionAction:Wa,reviewSelect:Va,reviewTitleEditRow:Ua,reviewTitleInput:Ka,reviewWorkspace:qa,reviewThread:Ga,reviewNewCommentsBar:Qa,reviewEmptyState:Ja,reviewComment:Ya,reviewCommentThread:Xa,reviewReplies:Za,reviewReply:eo,reviewThreadActions:to,reviewReplyComposer:no,reviewReplyInput:so,reviewReplyComposerActions:ro,reviewCommentHeader:ao,reviewCommentAvatar:oo,reviewCommentAuthor:io,reviewCommentTime:lo,reviewCommentActions:co,reviewCommentHeaderControls:uo,reviewCommentAction:mo,reviewCommentDeleteAction:ho,reviewAnchorLabel:fo,reviewAnchorRow:po,reviewAnchorMoved:vo,reviewAnchorUnresolved:wo,reviewAnchorUnknown:go,reviewCommentBody:yo,reviewCommentEditor:bo,reviewCommentEditInput:_o,reviewComposerArea:xo,reviewComposerRow:Co,reviewComposerInput:ko,reviewSendButton:So,reviewComposerHint:Ro,reviewResolvedComposer:jo,reviewResolvedIcon:No,reviewResolvedCopy:To,reviewAnchorChip:Eo,reviewAnchorSnippet:Ao,reviewAnchorClear:Io,viewerState:Do,viewerStateError:$o,editorArea:Mo,editorPane:Bo,editorLayoutSplit:Lo,previewPane:Fo,editorLayoutEditor:Po,editorLayoutPreview:zo,editorPaneLabel:Oo,editorTextarea:Ho,markdownSurface:Wo,readerSurface:Vo,attachModalBody:Uo,attachModalCopy:Ko,attachModalError:qo,attachTaskList:Go,attachTaskRow:Qo,attachTaskTitle:Jo,attachTaskInfo:Yo,attachTaskReference:Xo,attachTaskMeta:Zo,attachEmptyState:ei},ti="_overlay_1unik_1",ni="_modal_1unik_12",si="_header_1unik_16",ri="_title_1unik_20",ai="_docName_1unik_24",oi="_body_1unik_34",ii="_state_1unik_41",li="_stateError_1unik_52",ci="_stateDone_1unik_63",di="_toolbar_1unik_84",ui="_toolbarCount_1unik_95",mi="_toolbarActions_1unik_100",hi="_tree_1unik_105",fi="_taskRow_1unik_113",pi="_taskRowDimmed_1unik_126",vi="_taskCheck_1unik_130",wi="_taskExpandBtn_1unik_139",gi="_taskExpandSpacer_1unik_155",yi="_taskTitle_1unik_160",bi="_taskBadge_1unik_169",_i="_footer_1unik_179",D={overlay:ti,modal:ni,header:si,title:ri,docName:ai,body:oi,state:ii,stateError:li,stateDone:ci,toolbar:di,toolbarCount:ui,toolbarActions:mi,tree:hi,taskRow:fi,taskRowDimmed:pi,taskCheck:vi,taskExpandBtn:wi,taskExpandSpacer:gi,taskTitle:yi,taskBadge:bi,footer:_i},xi={1:"Low",2:"Medium",3:"High"};function ft(n,l){return n.map(h=>({...h,selected:l,children:ft(h.children,l)}))}function ls(n,l,h){return n.map(i=>i.idempotencyKey===l?{...i,selected:h,children:ft(i.children,h)}:{...i,children:ls(i.children,l,h)})}function pn(n){let l=0;for(const h of n)h.selected&&l++,l+=pn(h.children);return l}function cs({node:n,depth:l,onToggle:h}){const[i,d]=s.useState(!0),c=n.children.length>0,p=l*20;return e.jsxs("div",{children:[e.jsxs("div",{className:`${D.taskRow} ${n.selected?"":D.taskRowDimmed}`,style:{paddingLeft:`${12+p}px`},children:[e.jsx("button",{className:D.taskCheck,onClick:()=>h(n.idempotencyKey,!n.selected),title:n.selected?"Deselect":"Select",children:n.selected?e.jsx(Qs,{size:14,style:{color:"var(--brand-primary-strong)"}}):e.jsx(Js,{size:14,style:{color:"var(--text-muted)"}})}),c?e.jsx("button",{className:D.taskExpandBtn,onClick:()=>d(b=>!b),children:i?e.jsx(Ys,{size:12}):e.jsx(Xs,{size:12})}):e.jsx("span",{className:D.taskExpandSpacer}),e.jsx("span",{className:D.taskTitle,title:n.description||void 0,children:n.title}),e.jsx("span",{className:D.taskBadge,style:{color:Qn(n.type),borderColor:Qn(n.type)},children:n.type}),e.jsx("span",{className:D.taskBadge,style:{color:Jn(n.priority),borderColor:Jn(n.priority)},children:xi[n.priority]})]}),c&&i&&e.jsx("div",{children:n.children.map(b=>e.jsx(cs,{node:b,depth:l+1,onToggle:h},b.idempotencyKey))})]})}function Ci({content:n,docTitle:l,apiBaseUrl:h="",onClose:i,onGenerated:d}){const[c,p]=s.useState("preview"),[b,k]=s.useState(null),[S,I]=s.useState([]),[T,j]=s.useState(!0),[Q,J]=s.useState(0),[$,ie]=s.useState(null),z=s.useRef(null);s.useEffect(()=>{let x=!1;return j(!0),k(null),U("/api/taskforce/documents/generate-tasks/preview",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n})},h).then(R=>R.json()).then(R=>{if(!x){if(R.error)throw new Error(R.error);I(R.tasks||[]),p("preview")}}).catch(R=>{x||(k(R?.message||"Failed to parse plan"),p("error"))}).finally(()=>{x||j(!1)}),()=>{x=!0}},[n,h]);const N=s.useCallback((x,R)=>{I(O=>ls(O,x,R))},[]),H=()=>I(x=>ft(x,!0)),Y=()=>I(x=>ft(x,!1)),X=pn(S),L=async()=>{p("generating"),ie(null);try{const x=JSON.stringify({tasks:S});z.current?.requestBody!==x&&(z.current={requestBody:x,operationId:$s()});const O={method:"POST",credentials:"include",headers:{"Content-Type":"application/json","x-taskforce-operation-id":z.current.operationId},body:x};let W;try{W=await U("/api/taskforce/documents/generate-tasks/commit",O,h)}catch{W=await U("/api/taskforce/documents/generate-tasks/commit",O,h)}const K=await W.json().catch(()=>({}));if(!W.ok)throw new Error(K.error||`Generation failed (${W.status})`);z.current=null,J(K.created??0),p("done"),d(K.created??0)}catch(x){ie(x?.message||"Generation failed"),p("error")}};return e.jsx("div",{className:D.overlay,onClick:x=>{x.target===x.currentTarget&&i()},children:e.jsxs("div",{className:`tf-surface-modal tf-modal-shell ${D.modal}`,children:[e.jsxs("div",{className:`tf-modal-header ${D.header}`,children:[e.jsxs("div",{className:`tf-modal-title ${D.title}`,children:[e.jsx(mn,{size:16,style:{color:"var(--brand-primary-strong)"}}),"Generate Tasks from Plan"]}),e.jsx("span",{className:D.docName,children:l}),e.jsx("button",{className:"tf-control-icon",onClick:i,title:"Close",children:e.jsx(hn,{size:16})})]}),e.jsxs("div",{className:D.body,children:[T&&e.jsxs("div",{className:D.state,children:[e.jsx(es,{size:20,className:me.docSpinning}),"Parsing plan…"]}),!T&&c==="error"&&e.jsxs("div",{className:D.stateError,children:[e.jsx(Ft,{size:16}),b||$||"An error occurred"]}),!T&&c==="done"&&e.jsxs("div",{className:D.stateDone,children:[e.jsx(ht,{size:24,style:{color:"var(--status-success)"}}),e.jsxs("strong",{children:[Q," task",Q!==1?"s":""," created"]}),e.jsx("p",{children:"Tasks are now in your board. Switch to the Kanban or Hierarchy view to see them."})]}),!T&&(c==="preview"||c==="confirm"||c==="generating")&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:D.toolbar,children:[e.jsxs("span",{className:D.toolbarCount,children:[X," of ",pn(ft(S,!0))," tasks selected"]}),e.jsxs("div",{className:D.toolbarActions,children:[e.jsx("button",{className:"tf-control-icon",onClick:H,children:"Select all"}),e.jsx("button",{className:"tf-control-icon",onClick:Y,children:"Deselect all"})]})]}),S.length===0?e.jsx("div",{className:D.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:`${D.tree} tf-scrollbar`,children:S.map(x=>e.jsx(cs,{node:x,depth:0,onToggle:N},x.idempotencyKey))})]})]}),!T&&c!=="done"&&c!=="error"&&e.jsxs("div",{className:D.footer,children:[e.jsx("button",{className:"tf-button-secondary",onClick:i,children:"Cancel"}),e.jsx("button",{className:"tf-button-primary",onClick:L,disabled:X===0||c==="generating",children:c==="generating"?e.jsxs(e.Fragment,{children:[e.jsx(es,{size:13,className:me.docSpinning})," Generating…"]}):e.jsxs(e.Fragment,{children:[e.jsx(mn,{size:13})," Generate ",X," task",X!==1?"s":""]})})]}),!T&&c==="done"&&e.jsx("div",{className:D.footer,children:e.jsx("button",{className:"tf-button-primary",onClick:i,children:"Done"})})]})})}const ki={"implementation-plan":"Implementation Plan",review:"Review",walkthrough:"Walkthrough",planning:"Planning",other:"Document"},Si={"implementation-plan":a.typeBadgeImplementationPlan,review:a.typeBadgeReview,walkthrough:a.typeBadgeWalkthrough,planning:void 0,other:void 0},Ri={editor:a.editorLayoutEditor,split:a.editorLayoutSplit,preview:a.editorLayoutPreview},ji=1500,Ni=80,on="Document refresh failed; showing the previous saved version.",ln="A newer saved version is available. Cancel editing to reload it before saving.",cn="__new-review__",Ti=`
|
|
1
|
+
import{R as ue,j as e,r as s,s as Ds}from"./vendor-react-CKJs5o3c.js";import{i as vn,j as et,k as tt,m as Gn,f as U,t as me,o as Jn,p as Qn,q as $s,s as Ms,u as Bs,R as Ls,v as Lt,M as Fs,w as Yn,x as Xn,y as Zn}from"./index-BUplSsv_.js";import{A as Ps,a as zs}from"./AssetTraySortControl-Kf1pelSy.js";import{a0 as Os,ai as Hs,S as Ws,a_ as Vs,R as dn,aW as Us,a$ as Ks,g as qs,ak as un,N as Gs,au as mn,X as hn,b0 as es,s as Ft,y as ht,b1 as Js,b2 as Qs,a as Ys,x as Xs,b3 as Zs,b4 as er,b5 as tr,a7 as ut,b6 as nr,aZ as Bt,a6 as sr,a5 as rr,b7 as ts,a1 as ar,b8 as or,r as ns,t as ir,A as lr,O as cr,J as dr,K as ur,b9 as mr}from"./vendor-icons-BkFLXavV.js";import"./vendor-markdown-_lhNCyq-.js";import"./vendor-dnd-CJ-AjP-Y.js";import"./vendor-router-AqJMU8Lz.js";const hr="_index_1ya8h_1",fr="_header_1ya8h_8",pr="_title_1ya8h_23",vr="_search_1ya8h_35",wr="_searchIcon_1ya8h_41",gr="_searchInput_1ya8h_50",yr="_sortControlRow_1ya8h_67",br="_filters_1ya8h_74",_r="_filtersHeader_1ya8h_83",xr="_filtersTitle_1ya8h_90",Cr="_filterControls_1ya8h_102",kr="_list_1ya8h_114",Sr="_state_1ya8h_126",Rr="_stateError_1ya8h_134",jr="_item_1ya8h_141",Nr="_itemActive_1ya8h_163",Tr="_itemIcon_1ya8h_173",Er="_pinButton_1ya8h_183",Ar="_pinButtonActive_1ya8h_205",Ir="_itemBody_1ya8h_209",Dr="_itemTitle_1ya8h_217",$r="_itemTask_1ya8h_229",Mr="_itemBadge_1ya8h_240",Br="_itemMeta_1ya8h_253",Lr="_itemMetaDetails_1ya8h_264",Fr="_itemMetaReference_1ya8h_271",E={index:hr,header:fr,title:pr,search:vr,searchIcon:wr,searchInput:gr,sortControlRow:yr,filters:br,filtersHeader:_r,filtersTitle:xr,filterControls:Cr,list:kr,state:Sr,stateError:Rr,item:jr,itemActive:Nr,itemIcon:Tr,pinButton:Er,pinButtonActive:Ar,itemBody:Ir,itemTitle:Dr,itemTask:$r,itemBadge:Mr,itemMeta:Br,itemMetaDetails:Lr,itemMetaReference:Fr};function fn(n){let l=n;try{l=decodeURIComponent(n)}catch{l=n}return l.trim().replace(/\\/g,"/").replace(/^\/+/,"").replace(/^\.\//,"").replace(/^\.taskforce\//,"")}function Xe(n,l){const h=String(l||"").trim();if(!h)return n;const i=n.includes("?")?"&":"?";return`${n}${i}workspaceId=${encodeURIComponent(h)}`}function Pr(n,l){return!!(n===l||n.endsWith(`/${l}`)||l.endsWith(`/${n}`))}function ss(n){const l=fn(String(n||""));if(!l)return null;const h=l.match(/(^|\/)(asset-[a-f0-9]{32})(?=[^/]*$)/i);return h?.[2]?h[2].toLowerCase():null}function is(n){return Array.isArray(n.targets)?n.targets.length:typeof n.attachmentCount=="number"&&Number.isFinite(n.attachmentCount)?Math.max(0,Math.floor(n.attachmentCount)):n.taskId?1:0}function wn(n){return Array.isArray(n.targets)?n.targets.length>0?"attached":"unattached":n.attachmentState==="attached"||n.attachmentState==="unattached"?n.attachmentState:is(n)>0?"attached":"unattached"}function zr(n,l,h,i){const d=l.trim().toLowerCase();return n.filter(c=>{const b=[vn(c),c.title,c.originalFilename,c.referenceLabel,c.referenceNumber].filter(j=>j!=null).join(" ").toLowerCase(),k=d.length===0||b.includes(d),S=h.length===0||h.includes(c.docType),I=wn(c),T=i.length===0||i.includes(I);return k&&S&&T})}function Or({docType:n}){switch(n){case"implementation-plan":return e.jsx(Gs,{size:13});case"review":return e.jsx(un,{size:13});case"walkthrough":return e.jsx(qs,{size:13});default:return e.jsx(Ks,{size:13})}}function Hr(n){return n<1024?`${n}B`:n<1024*1024?`${(n/1024).toFixed(1)}KB`:`${(n/(1024*1024)).toFixed(1)}MB`}function Wr(n){if(!n)return"";const l=new Date(n),i=new Date().getTime()-l.getTime(),d=Math.floor(i/(1e3*60*60*24));return d===0?"Today":d===1?"Yesterday":d<7?`${d}d ago`:d<30?`${Math.floor(d/7)}w ago`:l.toLocaleDateString()}function Vr(n,l){n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),l())}function an(n,l=!1){return n==="initiative"?l?"initiatives":"initiative":n==="workstream"?l?"workstreams":"workstream":l?"tasks":"task"}function Ur(n,l){const h=n.targets;if(Array.isArray(h)){if(h.length===0)return null;const c=[...new Map(h.map(b=>[`${b.targetType}:${b.targetId}`,b])).values()];if(h.length!==c.length){if(c.length===1){const b=c[0],k=b.title||b.referenceLabel||an(b.targetType);return`${h.length} links to ${k}`}return`${h.length} links across ${c.length} items`}if(c.length===1){const b=c[0];return b.title||b.referenceLabel||`1 ${an(b.targetType)} linked`}return new Set(c.map(b=>b.targetType)).size===1?`${c.length} ${an(c[0].targetType,!0)} linked`:`${c.length} items linked`}const i=is(n),d=n.taskId?l.get(n.taskId):null;return i>1?`${i} tasks linked`:i===1?d?.title||"1 task linked":null}function Kr({documents:n,selectedDocId:l,loading:h,error:i,searchQuery:d,sortField:c,sortOrder:p,pinnedDocIds:b=[],onTogglePinnedDoc:k,taskById:S,onSearchChange:I,onSelect:T,onCloseTray:j,onSortFieldChange:J,onSortOrderChange:Q,hasActiveFilters:$,typeFilters:ie,attachmentFilters:z,onTypeFiltersChange:N,onAttachmentFiltersChange:H,listScrollTop:Y=0,onListScrollChange:X}){const L=ue.useRef(null),x=ue.useRef(null),R=ue.useRef(null),O=ue.useRef(X);ue.useEffect(()=>{O.current=X},[X]),ue.useEffect(()=>{const w=L.current;if(!w)return;const re=Math.max(0,Math.round(Y));Math.abs(w.scrollTop-re)<=1||(w.scrollTop=re)},[n.length,i,Y,h]),ue.useEffect(()=>()=>{R.current!==null&&(window.clearTimeout(R.current),R.current=null)},[]);const W=ue.useCallback(()=>{R.current!==null&&(window.clearTimeout(R.current),R.current=null);const w=x.current;x.current=null,w!==null&&O.current?.(w)},[]),K=ue.useCallback(w=>{x.current=Math.max(0,Math.round(w)),R.current===null&&(R.current=window.setTimeout(W,200))},[W]),le=+(ie.length!==et.length)+ +(z.length!==tt.length),Ne=`${le} active document ${le===1?"filter":"filters"}`,we=()=>{N(et.map(w=>w.value)),H(tt.map(w=>w.value))};return e.jsxs("div",{className:E.index,children:[e.jsxs("div",{className:E.header,children:[e.jsxs("span",{className:E.title,children:[e.jsx(Os,{size:14}),"Documents"]}),j?e.jsx("button",{type:"button",className:"tf-control-icon",onClick:j,title:"Collapse document tray","aria-label":"Collapse document tray",children:e.jsx(Hs,{size:16})}):null]}),e.jsxs("div",{className:E.search,children:[e.jsx(Ws,{size:12,className:E.searchIcon}),e.jsx("input",{type:"text",placeholder:"Search documents…",value:d,onChange:w=>I(w.target.value),className:E.searchInput})]}),e.jsx("div",{className:E.sortControlRow,children:e.jsx(Ps,{field:c,order:p,onFieldChange:J,onOrderChange:Q})}),e.jsxs("section",{className:E.filters,"aria-label":"Document filters",children:[e.jsxs("div",{className:E.filtersHeader,children:[e.jsxs("span",{className:E.filtersTitle,children:[e.jsx(Vs,{size:12,"aria-hidden":"true"}),"Filters",le>0?e.jsx("span",{className:"tf-chip-count","aria-label":Ne,children:le}):null]}),e.jsx("button",{type:"button",className:"tf-control-icon",onClick:we,disabled:le===0,"aria-label":"Reset document filters",title:"Reset document filters",children:e.jsx(dn,{size:13,"aria-hidden":"true"})})]}),e.jsxs("div",{className:E.filterControls,children:[e.jsx(Gn,{label:"Attachment",options:tt,selected:z,onChange:w=>H(w),variant:"value",containerStyle:{minWidth:0}}),e.jsx(Gn,{label:"Type",options:et,selected:ie,onChange:w=>N(w),variant:"value",containerStyle:{minWidth:0}})]})]}),e.jsxs("div",{ref:L,className:`${E.list} tf-scrollbar tf-tray-scroll-viewport`,"data-testid":"doc-index-list",onScroll:w=>K(w.currentTarget.scrollTop),children:[h&&e.jsx("div",{className:E.state,children:"Loading documents…"}),!h&&i&&e.jsx("div",{className:E.stateError,children:i}),!h&&!i&&n.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&&n.map(w=>{const re=w.assetId===l,A=b.includes(w.assetId),M=vn(w),q=wn(w),Ce=Ur(w,S);return e.jsxs("div",{role:"button",tabIndex:0,className:`${E.item} ${re?E.itemActive:""}`,onClick:()=>T(w),onKeyDown:fe=>Vr(fe,()=>T(w)),children:[e.jsx("div",{className:E.itemIcon,children:e.jsx(Or,{docType:w.docType})}),e.jsxs("div",{className:E.itemBody,children:[e.jsx("span",{className:E.itemTitle,title:M,children:M}),q==="unattached"&&e.jsx("span",{className:E.itemBadge,children:"Unattached"}),Ce&&e.jsx("span",{className:E.itemTask,title:Ce,children:Ce}),e.jsxs("span",{className:E.itemMeta,children:[e.jsxs("span",{className:E.itemMetaDetails,children:[Hr(w.sizeBytes),w.updatedAt&&e.jsxs(e.Fragment,{children:[" · ",Wr(w.updatedAt)]})]}),w.referenceLabel&&e.jsx("span",{className:E.itemMetaReference,children:w.referenceLabel})]})]}),k?e.jsx("button",{type:"button",className:`${E.pinButton} ${A?E.pinButtonActive:""}`.trim(),"aria-label":A?"Unpin document":"Pin document",title:A?`Unpin ${M}`:`Pin ${M}`,"aria-pressed":A,onClick:fe=>{fe.stopPropagation(),k(w.assetId)},onKeyDown:fe=>fe.stopPropagation(),children:e.jsx(Us,{size:14,fill:A?"currentColor":"none"})}):null]},w.assetId)})]})]})}const qr="_viewer_1glbl_1",Gr="_viewerMonochrome_1glbl_10",Jr="_metaDocumentName_1glbl_10",Qr="_viewerEditMode_1glbl_14",Yr="_meta_1glbl_10",Xr="_metaLeft_1glbl_30",Zr="_metaRenameRow_1glbl_49",ea="_typeBadge_1glbl_56",ta="_typeBadgeImplementationPlan_1glbl_71",na="_typeBadgeReview_1glbl_77",sa="_typeBadgeWalkthrough_1glbl_83",ra="_metaTaskName_1glbl_89",aa="_statusBadge_1glbl_98",oa="_metaDate_1glbl_113",ia="_metaSize_1glbl_114",la="_actions_1glbl_122",ca="_actionBtn_1glbl_129",da="_dangerBtn_1glbl_156",ua="_generateBtn_1glbl_167",ma="_editBtn_1glbl_178",ha="_saveBtn_1glbl_189",fa="_layoutToggle_1glbl_205",pa="_layoutBtn_1glbl_213",va="_layoutBtnActive_1glbl_229",wa="_saveStatus_1glbl_234",ga="_saveStatusSaved_1glbl_241",ya="_saveStatusError_1glbl_245",ba="_unsaved_1glbl_250",_a="_viewerContent_1glbl_256",xa="_viewerBody_1glbl_265",Ca="_viewerBodyFullWidth_1glbl_274",ka="_viewerMain_1glbl_278",Sa="_reviewRail_1glbl_286",Ra="_reviewSection_1glbl_292",ja="_reviewHeader_1glbl_299",Na="_reviewHeaderTop_1glbl_309",Ta="_reviewHeaderActions_1glbl_316",Ea="_reviewCloseButton_1glbl_322",Aa="_reviewEyebrow_1glbl_326",Ia="_reviewSubtitle_1glbl_334",Da="_reviewMetadataRow_1glbl_341",$a="_reviewMetadata_1glbl_341",Ma="_reviewSessionTitle_1glbl_355",Ba="_reviewEmptyHeading_1glbl_356",La="_reviewSessionDetails_1glbl_366",Fa="_reviewVersionDetails_1glbl_375",Pa="_reviewDraftNotice_1glbl_383",za="_reviewVersionNotice_1glbl_384",Oa="_reviewControls_1glbl_406",Ha="_reviewCreateButton_1glbl_415",Wa="_reviewResolutionAction_1glbl_416",Va="_reviewSelect_1glbl_431",Ua="_reviewTitleEditRow_1glbl_438",Ka="_reviewTitleInput_1glbl_444",qa="_reviewWorkspace_1glbl_451",Ga="_reviewThread_1glbl_459",Ja="_reviewNewCommentsBar_1glbl_469",Qa="_reviewEmptyState_1glbl_477",Ya="_reviewComment_1glbl_490",Xa="_reviewCommentThread_1glbl_511",Za="_reviewReplies_1glbl_517",eo="_reviewReply_1glbl_526",to="_reviewThreadActions_1glbl_531",no="_reviewReplyComposer_1glbl_540",so="_reviewReplyInput_1glbl_548",ro="_reviewReplyComposerActions_1glbl_553",ao="_reviewCommentHeader_1glbl_559",oo="_reviewCommentAvatar_1glbl_566",io="_reviewCommentAuthor_1glbl_578",lo="_reviewCommentTime_1glbl_588",co="_reviewCommentActions_1glbl_594",uo="_reviewCommentHeaderControls_1glbl_600",mo="_reviewCommentAction_1glbl_594",ho="_reviewCommentDeleteAction_1glbl_616",fo="_reviewAnchorLabel_1glbl_622",po="_reviewAnchorRow_1glbl_637",vo="_reviewAnchorMoved_1glbl_645",wo="_reviewAnchorUnresolved_1glbl_646",go="_reviewAnchorUnknown_1glbl_647",yo="_reviewCommentBody_1glbl_675",bo="_reviewCommentEditor_1glbl_691",_o="_reviewCommentEditInput_1glbl_698",xo="_reviewComposerArea_1glbl_703",Co="_reviewComposerRow_1glbl_713",ko="_reviewComposerInput_1glbl_719",So="_reviewSendButton_1glbl_728",Ro="_reviewComposerHint_1glbl_735",jo="_reviewResolvedComposer_1glbl_740",No="_reviewResolvedIcon_1glbl_751",To="_reviewResolvedCopy_1glbl_762",Eo="_reviewAnchorChip_1glbl_776",Ao="_reviewAnchorSnippet_1glbl_789",Io="_reviewAnchorClear_1glbl_799",Do="_viewerState_1glbl_814",$o="_viewerStateError_1glbl_821",Mo="_editorArea_1glbl_828",Bo="_editorPane_1glbl_834",Lo="_editorLayoutSplit_1glbl_842",Fo="_previewPane_1glbl_843",Po="_editorLayoutEditor_1glbl_847",zo="_editorLayoutPreview_1glbl_848",Oo="_editorPaneLabel_1glbl_852",Ho="_editorTextarea_1glbl_864",Wo="_markdownSurface_1glbl_906",Vo="_readerSurface_1glbl_911",Uo="_attachModalBody_1glbl_1040",Ko="_attachModalCopy_1glbl_1047",qo="_attachModalError_1glbl_1054",Go="_attachTaskList_1glbl_1067",Jo="_attachTaskRow_1glbl_1076",Qo="_attachTaskTitle_1glbl_1103",Yo="_attachTaskInfo_1glbl_1109",Xo="_attachTaskReference_1glbl_1117",Zo="_attachTaskMeta_1glbl_1124",ei="_attachEmptyState_1glbl_1131",a={viewer:qr,viewerMonochrome:Gr,metaDocumentName:Jr,viewerEditMode:Qr,meta:Yr,metaLeft:Xr,metaRenameRow:Zr,typeBadge:ea,typeBadgeImplementationPlan:ta,typeBadgeReview:na,typeBadgeWalkthrough:sa,metaTaskName:ra,statusBadge:aa,metaDate:oa,metaSize:ia,actions:la,actionBtn:ca,dangerBtn:da,generateBtn:ua,editBtn:ma,saveBtn:ha,layoutToggle:fa,layoutBtn:pa,layoutBtnActive:va,saveStatus:wa,saveStatusSaved:ga,saveStatusError:ya,unsaved:ba,viewerContent:_a,viewerBody:xa,viewerBodyFullWidth:Ca,viewerMain:ka,reviewRail:Sa,reviewSection:Ra,reviewHeader:ja,reviewHeaderTop:Na,reviewHeaderActions:Ta,reviewCloseButton:Ea,reviewEyebrow:Aa,reviewSubtitle:Ia,reviewMetadataRow:Da,reviewMetadata:$a,reviewSessionTitle:Ma,reviewEmptyHeading:Ba,reviewSessionDetails:La,reviewVersionDetails:Fa,reviewDraftNotice:Pa,reviewVersionNotice:za,reviewControls:Oa,reviewCreateButton:Ha,reviewResolutionAction:Wa,reviewSelect:Va,reviewTitleEditRow:Ua,reviewTitleInput:Ka,reviewWorkspace:qa,reviewThread:Ga,reviewNewCommentsBar:Ja,reviewEmptyState:Qa,reviewComment:Ya,reviewCommentThread:Xa,reviewReplies:Za,reviewReply:eo,reviewThreadActions:to,reviewReplyComposer:no,reviewReplyInput:so,reviewReplyComposerActions:ro,reviewCommentHeader:ao,reviewCommentAvatar:oo,reviewCommentAuthor:io,reviewCommentTime:lo,reviewCommentActions:co,reviewCommentHeaderControls:uo,reviewCommentAction:mo,reviewCommentDeleteAction:ho,reviewAnchorLabel:fo,reviewAnchorRow:po,reviewAnchorMoved:vo,reviewAnchorUnresolved:wo,reviewAnchorUnknown:go,reviewCommentBody:yo,reviewCommentEditor:bo,reviewCommentEditInput:_o,reviewComposerArea:xo,reviewComposerRow:Co,reviewComposerInput:ko,reviewSendButton:So,reviewComposerHint:Ro,reviewResolvedComposer:jo,reviewResolvedIcon:No,reviewResolvedCopy:To,reviewAnchorChip:Eo,reviewAnchorSnippet:Ao,reviewAnchorClear:Io,viewerState:Do,viewerStateError:$o,editorArea:Mo,editorPane:Bo,editorLayoutSplit:Lo,previewPane:Fo,editorLayoutEditor:Po,editorLayoutPreview:zo,editorPaneLabel:Oo,editorTextarea:Ho,markdownSurface:Wo,readerSurface:Vo,attachModalBody:Uo,attachModalCopy:Ko,attachModalError:qo,attachTaskList:Go,attachTaskRow:Jo,attachTaskTitle:Qo,attachTaskInfo:Yo,attachTaskReference:Xo,attachTaskMeta:Zo,attachEmptyState:ei},ti="_overlay_1unik_1",ni="_modal_1unik_12",si="_header_1unik_16",ri="_title_1unik_20",ai="_docName_1unik_24",oi="_body_1unik_34",ii="_state_1unik_41",li="_stateError_1unik_52",ci="_stateDone_1unik_63",di="_toolbar_1unik_84",ui="_toolbarCount_1unik_95",mi="_toolbarActions_1unik_100",hi="_tree_1unik_105",fi="_taskRow_1unik_113",pi="_taskRowDimmed_1unik_126",vi="_taskCheck_1unik_130",wi="_taskExpandBtn_1unik_139",gi="_taskExpandSpacer_1unik_155",yi="_taskTitle_1unik_160",bi="_taskBadge_1unik_169",_i="_footer_1unik_179",D={overlay:ti,modal:ni,header:si,title:ri,docName:ai,body:oi,state:ii,stateError:li,stateDone:ci,toolbar:di,toolbarCount:ui,toolbarActions:mi,tree:hi,taskRow:fi,taskRowDimmed:pi,taskCheck:vi,taskExpandBtn:wi,taskExpandSpacer:gi,taskTitle:yi,taskBadge:bi,footer:_i},xi={1:"Low",2:"Medium",3:"High"};function ft(n,l){return n.map(h=>({...h,selected:l,children:ft(h.children,l)}))}function ls(n,l,h){return n.map(i=>i.idempotencyKey===l?{...i,selected:h,children:ft(i.children,h)}:{...i,children:ls(i.children,l,h)})}function pn(n){let l=0;for(const h of n)h.selected&&l++,l+=pn(h.children);return l}function cs({node:n,depth:l,onToggle:h}){const[i,d]=s.useState(!0),c=n.children.length>0,p=l*20;return e.jsxs("div",{children:[e.jsxs("div",{className:`${D.taskRow} ${n.selected?"":D.taskRowDimmed}`,style:{paddingLeft:`${12+p}px`},children:[e.jsx("button",{className:D.taskCheck,onClick:()=>h(n.idempotencyKey,!n.selected),title:n.selected?"Deselect":"Select",children:n.selected?e.jsx(Js,{size:14,style:{color:"var(--brand-primary-strong)"}}):e.jsx(Qs,{size:14,style:{color:"var(--text-muted)"}})}),c?e.jsx("button",{className:D.taskExpandBtn,onClick:()=>d(b=>!b),children:i?e.jsx(Ys,{size:12}):e.jsx(Xs,{size:12})}):e.jsx("span",{className:D.taskExpandSpacer}),e.jsx("span",{className:D.taskTitle,title:n.description||void 0,children:n.title}),e.jsx("span",{className:D.taskBadge,style:{color:Jn(n.type),borderColor:Jn(n.type)},children:n.type}),e.jsx("span",{className:D.taskBadge,style:{color:Qn(n.priority),borderColor:Qn(n.priority)},children:xi[n.priority]})]}),c&&i&&e.jsx("div",{children:n.children.map(b=>e.jsx(cs,{node:b,depth:l+1,onToggle:h},b.idempotencyKey))})]})}function Ci({content:n,docTitle:l,apiBaseUrl:h="",onClose:i,onGenerated:d}){const[c,p]=s.useState("preview"),[b,k]=s.useState(null),[S,I]=s.useState([]),[T,j]=s.useState(!0),[J,Q]=s.useState(0),[$,ie]=s.useState(null),z=s.useRef(null);s.useEffect(()=>{let x=!1;return j(!0),k(null),U("/api/taskforce/documents/generate-tasks/preview",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n})},h).then(R=>R.json()).then(R=>{if(!x){if(R.error)throw new Error(R.error);I(R.tasks||[]),p("preview")}}).catch(R=>{x||(k(R?.message||"Failed to parse plan"),p("error"))}).finally(()=>{x||j(!1)}),()=>{x=!0}},[n,h]);const N=s.useCallback((x,R)=>{I(O=>ls(O,x,R))},[]),H=()=>I(x=>ft(x,!0)),Y=()=>I(x=>ft(x,!1)),X=pn(S),L=async()=>{p("generating"),ie(null);try{const x=JSON.stringify({tasks:S});z.current?.requestBody!==x&&(z.current={requestBody:x,operationId:$s()});const O={method:"POST",credentials:"include",headers:{"Content-Type":"application/json","x-taskforce-operation-id":z.current.operationId},body:x};let W;try{W=await U("/api/taskforce/documents/generate-tasks/commit",O,h)}catch{W=await U("/api/taskforce/documents/generate-tasks/commit",O,h)}const K=await W.json().catch(()=>({}));if(!W.ok)throw new Error(K.error||`Generation failed (${W.status})`);z.current=null,Q(K.created??0),p("done"),d(K.created??0)}catch(x){ie(x?.message||"Generation failed"),p("error")}};return e.jsx("div",{className:D.overlay,onClick:x=>{x.target===x.currentTarget&&i()},children:e.jsxs("div",{className:`tf-surface-modal tf-modal-shell ${D.modal}`,children:[e.jsxs("div",{className:`tf-modal-header ${D.header}`,children:[e.jsxs("div",{className:`tf-modal-title ${D.title}`,children:[e.jsx(mn,{size:16,style:{color:"var(--brand-primary-strong)"}}),"Generate Tasks from Plan"]}),e.jsx("span",{className:D.docName,children:l}),e.jsx("button",{className:"tf-control-icon",onClick:i,title:"Close",children:e.jsx(hn,{size:16})})]}),e.jsxs("div",{className:D.body,children:[T&&e.jsxs("div",{className:D.state,children:[e.jsx(es,{size:20,className:me.docSpinning}),"Parsing plan…"]}),!T&&c==="error"&&e.jsxs("div",{className:D.stateError,children:[e.jsx(Ft,{size:16}),b||$||"An error occurred"]}),!T&&c==="done"&&e.jsxs("div",{className:D.stateDone,children:[e.jsx(ht,{size:24,style:{color:"var(--status-success)"}}),e.jsxs("strong",{children:[J," task",J!==1?"s":""," created"]}),e.jsx("p",{children:"Tasks are now in your board. Switch to the Kanban or Hierarchy view to see them."})]}),!T&&(c==="preview"||c==="confirm"||c==="generating")&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:D.toolbar,children:[e.jsxs("span",{className:D.toolbarCount,children:[X," of ",pn(ft(S,!0))," tasks selected"]}),e.jsxs("div",{className:D.toolbarActions,children:[e.jsx("button",{className:"tf-control-icon",onClick:H,children:"Select all"}),e.jsx("button",{className:"tf-control-icon",onClick:Y,children:"Deselect all"})]})]}),S.length===0?e.jsx("div",{className:D.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:`${D.tree} tf-scrollbar`,children:S.map(x=>e.jsx(cs,{node:x,depth:0,onToggle:N},x.idempotencyKey))})]})]}),!T&&c!=="done"&&c!=="error"&&e.jsxs("div",{className:D.footer,children:[e.jsx("button",{className:"tf-button-secondary",onClick:i,children:"Cancel"}),e.jsx("button",{className:"tf-button-primary",onClick:L,disabled:X===0||c==="generating",children:c==="generating"?e.jsxs(e.Fragment,{children:[e.jsx(es,{size:13,className:me.docSpinning})," Generating…"]}):e.jsxs(e.Fragment,{children:[e.jsx(mn,{size:13})," Generate ",X," task",X!==1?"s":""]})})]}),!T&&c==="done"&&e.jsx("div",{className:D.footer,children:e.jsx("button",{className:"tf-button-primary",onClick:i,children:"Done"})})]})})}const ki={"implementation-plan":"Implementation Plan",review:"Review",walkthrough:"Walkthrough",planning:"Planning",other:"Document"},Si={"implementation-plan":a.typeBadgeImplementationPlan,review:a.typeBadgeReview,walkthrough:a.typeBadgeWalkthrough,planning:void 0,other:void 0},Ri={editor:a.editorLayoutEditor,split:a.editorLayoutSplit,preview:a.editorLayoutPreview},ji=1500,Ni=80,on="Document refresh failed; showing the previous saved version.",ln="A newer saved version is available. Cancel editing to reload it before saving.",cn="__new-review__",Ti=`
|
|
2
2
|
@page {
|
|
3
3
|
margin: 0.94in 1.02in 1in;
|
|
4
4
|
}
|
|
@@ -254,8 +254,8 @@ body {
|
|
|
254
254
|
</head>
|
|
255
255
|
<body>${l}</body>
|
|
256
256
|
</html>`}async function Di(n,l){try{await l.fonts?.ready}catch{}await new Promise(h=>{const i=n.requestAnimationFrame?.bind(n)??(d=>window.setTimeout(()=>d(0),0));i(()=>i(()=>h()))})}function $i(n){return window.setTimeout(n,ji)}function rs(n){try{return new Date(n).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return n}}function as(n){if(!n)return null;if(n.kind==="document")return"Whole document";if(n.kind==="quote"){const l=n.quote?.replace(/\s+/g," ").trim()||"";return l?`Selected: “${l.length>72?`${l.slice(0,69).trimEnd()}…`:l}”`:"Selected text"}return n.kind==="line-range"?n.startLine===n.endLine?`Line ${n.startLine}`:`Lines ${n.startLine}-${n.endLine}`:null}function Mi(n){return n.authorActor?.label?n.authorActor.label:n.authorActorId==="user"||n.authorActorId==="human"?"You":n.authorActorId?n.authorActorId:"Reviewer"}function Ze(n){return n.replace(/\s+/g," ").trim()}function Bi(n,l,h=l){if(!n)return"unknown";if(n.kind==="document")return"valid";if(l===null)return"unknown";if(n.kind==="line-range"){const j=l.split(`
|
|
257
|
-
`).length;return n.startLine>=1&&n.endLine>=n.startLine&&n.endLine<=j?"valid":"unresolved"}const i=Ze(n.quote||"");if(!i||h===null)return"unknown";const d=Ze(h),c=[];let p=0;for(;p<=d.length-i.length;){const j=d.indexOf(i,p);if(j<0)break;c.push(j),p=j+i.length}if(c.length===0)return"unresolved";const b=typeof n.occurrenceIndex=="number"&&Number.isInteger(n.occurrenceIndex)&&n.occurrenceIndex>=0,k=Ze(n.prefix||""),S=Ze(n.suffix||""),I=j=>{const
|
|
257
|
+
`).length;return n.startLine>=1&&n.endLine>=n.startLine&&n.endLine<=j?"valid":"unresolved"}const i=Ze(n.quote||"");if(!i||h===null)return"unknown";const d=Ze(h),c=[];let p=0;for(;p<=d.length-i.length;){const j=d.indexOf(i,p);if(j<0)break;c.push(j),p=j+i.length}if(c.length===0)return"unresolved";const b=typeof n.occurrenceIndex=="number"&&Number.isInteger(n.occurrenceIndex)&&n.occurrenceIndex>=0,k=Ze(n.prefix||""),S=Ze(n.suffix||""),I=j=>{const J=d.slice(0,j).trimEnd(),Q=d.slice(j+i.length).trimStart();return(!k||J.endsWith(k))&&(!S||Q.startsWith(S))};if(b){const j=c[n.occurrenceIndex];return j===void 0?"moved":I(j)?"valid":"moved"}if(!k&&!S)return c.length===1?"valid":"unknown";const T=c.filter(I);return T.length===1?"valid":T.length===0?"moved":"unknown"}function Li(n,l){if(!l)return 0;let h=0,i=0;for(;i>=0&&(i=n.indexOf(l,i),!(i<0));)h+=1,i+=l.length;return h}function Fi(n,l,h){const i=document.createTreeWalker(n,NodeFilter.SHOW_TEXT);let d=i.nextNode(),c=0;for(;d;){const p=d.textContent||"";if(d===l)return c+Math.max(0,Math.min(h,p.length));c+=p.length,d=i.nextNode()}return null}function Pi(n,l,h){const i=h.replace(/\s+/g," ").trim();if(!i)return null;const d=n.textContent||"",c=Ze(d),p=[];let b=c.indexOf(i);for(;b>=0;)p.push(b),b=c.indexOf(i,b+i.length);let k=null;const S=Fi(n,l.startContainer,l.startOffset);if(S!==null){const Q=Ze(d.slice(0,S));k=Li(Q,i)}const I=k!==null&&k>=0&&k<p.length?k:p.length===1?0:null,T=I!==null?p[I]:p[0]??-1;if(T<0)return{kind:"quote",quote:i,occurrenceIndex:k};const j=c.slice(Math.max(0,T-40),T).trim()||null,J=c.slice(T+i.length,T+i.length+40).trim()||null;return{kind:"quote",quote:i,occurrenceIndex:I,prefix:j,suffix:J}}function zi(n,l,h){if(l<0)return n;const i=n.split(`
|
|
258
258
|
`);let d=-1;const c=/^(\s*(?:[-*+]|\d+\.)\s+)\[( |x|X)\](.*)$/,p=h?"x":" ";return i.map(k=>{const S=k.match(c);return!S||(d+=1,d!==l)?k:`${S[1]}[${p}]${S[3]}`}).join(`
|
|
259
|
-
`)}function Oi({doc:n,taskTitle:l,tasks:h=[],apiBaseUrl:i="",workspaceId:d=null,onSaved:c,onDeleted:p,onBackToTask:b,taskReferences:k,enableTaskGeneration:S=!1,initialScrollTop:I=0,onScrollTopChange:T}){const j=vn(n),[Q,J]=s.useState(j),$=Q,ie=Ms({...n,title:Q}),z=Bs(n),[N,H]=s.useState(null),Y=s.useRef(null);Y.current=N;const[X,L]=s.useState(null),[x,R]=s.useState(null),[O,W]=s.useState(!1),[K,le]=s.useState(null),[Ne,we]=s.useState(!1),[w,re]=s.useState(!1),[A,M]=s.useState([]),[q,Ce]=s.useState(!1),[fe,B]=s.useState(null),[Me,nt]=s.useState(null),[He,ge]=s.useState({}),[g,F]=s.useState(!1),[Be,ce]=s.useState(!1),[st,Te]=s.useState(!1),[Ee,pe]=s.useState(""),[de,ve]=s.useState(null),[Ae,ke]=s.useState(""),[ae,ye]=s.useState(null),[Le,Se]=s.useState(""),[P,pt]=s.useState(!0),[oe,vt]=s.useState(!1),be=s.useRef(null),We=Me||cn,Re=He[We]?.body||"",_e=He[We]?.anchor||null,Pt=s.useCallback(t=>{ge(r=>{const o=be.current||cn;return{...r,[o]:{body:t,anchor:r[o]?.anchor||null}}})},[]),_=s.useCallback(t=>{ge(r=>{const o=be.current||cn;return{...r,[o]:{body:r[o]?.body||"",anchor:t}}})},[]),[y,V]=s.useState(!1),ee=s.useRef(!1);ee.current=y;const[G,Ie]=s.useState(""),[te,zt]=s.useState("split"),[De,Z]=s.useState({type:"idle"}),[rt,at]=s.useState(!1),[ds,Ot]=s.useState(!1),[gn,us]=s.useState(!1),[wt,yn]=s.useState(!1),[gt,Fe]=s.useState(!1),[ms,yt]=s.useState(!1),[bn,_n]=s.useState(""),[Ht,Wt]=s.useState(null),[xn,bt]=s.useState(null),[Vt,Ve]=s.useState($),Ue=n.editable!==!1,ot=wn(n),hs=!!n.assetId,_t=y&&G!==(N??""),Ut=s.useRef(null),Kt=s.useRef(null),Cn=s.useRef(null),qt=s.useRef(null),Ke=s.useRef(null),xt=s.useRef(null),kn=s.useRef(null),Sn=s.useRef(null),Rn=s.useRef(null),jn=s.useRef(null),Gt=s.useRef(null),Nn=s.useRef(null),Tn=s.useRef(null),Qt=s.useRef(new Map),qe=s.useRef(null),it=s.useRef([]),Ge=s.useRef(!1),Qe=s.useRef(0),Jt=s.useRef(null),Pe=s.useRef(null),lt=s.useRef(0),Ct=s.useRef(0),kt=s.useRef(null),Je=s.useRef(null),St=s.useRef(null),ct=s.useRef(null),En=s.useRef(""),An=s.useRef(T),f=A.find(t=>t.id===Me)||A[0]||null,fs=f?.comments.map(t=>t.id).join("|")||"",In=f?.threadCount??f?.comments.filter(t=>!t.parentCommentId).length??0,ze=f?.unresolvedThreadCount??f?.comments.filter(t=>!t.parentCommentId&&t.threadStatus!=="resolved").length??0,Rt=f?.status==="open"&&ze>0,Dn=h.filter(t=>{const r=bn.trim().toLowerCase();return r?t.title.toLowerCase().includes(r)||String(t.referenceLabel||"").trim().toLowerCase().includes(r):!0}),Yt=s.useCallback(()=>{_(null),pt(!1)},[_]),$n=s.useCallback(()=>{const t=qe.current;qe.current=null,t&&window.setTimeout(()=>{Qt.current.get(t)?.focus()},0)},[]),jt=s.useCallback(()=>{ye(null),Se(""),$n()},[$n]),Nt=s.useCallback(()=>{const t=Sn.current;return t?t.scrollHeight-t.scrollTop-t.clientHeight<=Ni:!0},[]),ps=s.useCallback(()=>{Nt()&&ce(!1)},[Nt]),Xt=s.useCallback((t="smooth")=>{const r=kn.current;typeof r?.scrollIntoView=="function"&&r.scrollIntoView({block:"end",behavior:t}),ce(!1)},[]),$e=s.useCallback(t=>{be.current=t,Ge.current=t!==null,ce(!1),ye(null),Se(""),qe.current=null,nt(t)},[]);s.useEffect(()=>{be.current=Me},[Me]),s.useEffect(()=>{it.current=A},[A]),s.useEffect(()=>{if(typeof window.matchMedia!="function")return;const t=window.matchMedia("(max-width: 1100px)"),r=()=>vt(t.matches);return r(),t.addEventListener?.("change",r),()=>t.removeEventListener?.("change",r)},[]),s.useEffect(()=>{if(!oe||!P)return;const t=Rn.current;if(!t)return;const r=["button:not([disabled])","select:not([disabled])","textarea:not([disabled])","input:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(","),o=window.requestAnimationFrame(()=>jn.current?.focus()),u=m=>{if(m.key==="Escape"){m.preventDefault(),Yt();return}if(m.key!=="Tab")return;const v=Array.from(t.querySelectorAll(r));if(v.length===0){m.preventDefault();return}const C=v[0],se=v[v.length-1];m.shiftKey&&document.activeElement===C?(m.preventDefault(),se.focus()):!m.shiftKey&&document.activeElement===se&&(m.preventDefault(),C.focus())};return document.addEventListener("keydown",u),()=>{window.cancelAnimationFrame(o),document.removeEventListener("keydown",u),t.contains(document.activeElement)&&Gt.current?.focus()}},[Yt,oe,P]);const Tt=s.useCallback(async(t,r)=>{const o=++Qe.current,u=Y.current===null;u&&W(!0),le(null);try{const m=await U(n.apiUrl,{credentials:"same-origin"},i);if(!m.ok)throw new Error(`Failed to load document (${m.status})`);const v=await m.text();if(o!==Qe.current)return;if(ee.current&&Y.current!==null){Pe.current={revision:r,version:t},at(!0),Z({type:"error",message:ln});return}H(v),ee.current||Ie(v),R(t),Jt.current=r,Pe.current=null,at(!1),Z(C=>C.type==="error"&&C.message===on?{type:"idle"}:C)}catch(m){if(o!==Qe.current)return;u?le(m?.message||"Failed to load document"):Z({type:"error",message:on})}finally{u&&o===Qe.current&&W(!1)}},[i,n.apiUrl]),Zt=s.useCallback(async t=>{const r=t?.silent===!0;if(r&&kt.current!==null)return;const o=++lt.current,u=Ct.current;if(!n.assetId){it.current=[],M([]),$e(null),B(null);return}r||(kt.current=o,Ce(!0),B(null));try{const m=await U(`/api/taskforce/document-reviews/sessions?assetId=${encodeURIComponent(n.assetId)}`,{credentials:"include"},i),v=await m.json().catch(()=>({}));if(!m.ok)throw new Error(v.error||`Failed to load reviews (${m.status})`);if(o!==lt.current||u!==Ct.current)return;const C=Array.isArray(v.sessions)?v.sessions:[],se=it.current,he=be.current,je=he&&C.some(Ye=>Ye.id===he)?he:C[0]?.id??null;if(r&&je){const Ye=se.find(xe=>xe.id===je)||null,rn=C.find(xe=>xe.id===je)||null,Dt=new Set(Ye?.comments.map(xe=>xe.id)||[]),$t=rn?.comments.some(xe=>!Dt.has(xe.id))===!0;Ye&&$t&&(Nt()?Ge.current=!0:ce(!0))}it.current=C,M(C),je!==he&&$e(je)}catch(m){if(o!==lt.current||u!==Ct.current)return;r||(it.current=[],B(m?.message||"Failed to load reviews"),M([]),$e(null))}finally{!r&&kt.current===o&&(kt.current=null,Ce(!1))}},[i,n.assetId,Nt,$e]),ne=s.useCallback(()=>{Ct.current+=1,lt.current+=1},[]),en=s.useCallback(async()=>{if(!n.assetId||g)return null;F(!0),B(null);try{const t=await U("/api/taskforce/document-reviews/sessions",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({assetId:n.assetId,title:`Review ${A.length+1}`})},i),r=await t.json().catch(()=>({}));if(!t.ok)throw new Error(r.error||`Failed to create review (${t.status})`);const o=r.session||null;if(!o)throw new Error("Review session payload missing.");return ne(),M(u=>[o,...u.filter(m=>m.id!==o.id)]),$e(o.id),o}catch(t){return B(t?.message||"Failed to create review"),null}finally{F(!1)}},[i,n.assetId,ne,g,A.length,$e]),tn=n.assetId,dt=`${n.updatedAt||""}:${n.version||""}`;s.useEffect(()=>{Qe.current+=1,lt.current+=1,Y.current=null,H(null),V(!1),at(!1),Jt.current=null,Pe.current=null,Z({type:"idle"}),Fe(!1),we(!1),re(!1),R(null),ge({}),L(null),ce(!1),Te(!1),pe(""),ve(null),ke(""),ye(null),Se(""),qe.current=null},[tn]),s.useEffect(()=>{const t=typeof n.version=="number"&&Number.isFinite(n.version)?Math.max(1,Math.floor(n.version)):null;if(ee.current&&Y.current!==null&&Jt.current!==dt){Qe.current+=1,Pe.current={revision:dt,version:t},at(!0),Z({type:"error",message:ln});return}Pe.current={revision:dt,version:t},Tt(t,dt)},[tn,dt,Tt]),s.useEffect(()=>{Zt()},[tn]),s.useEffect(()=>{if(y||!rt)return;const t=Pe.current;t&&(at(!1),Tt(t.version,t.revision))},[y,Tt,rt]),s.useEffect(()=>{J(j),Ve(j)},[j]),s.useEffect(()=>{y||!Je.current||!A.some(r=>r.comments.some(o=>o.anchor?.kind==="quote"))||L(Je.current.textContent||"")},[N,y,A]),s.useEffect(()=>{!f||!Ge.current||(Ge.current=!1,Xt("auto"))},[fs,f?.id,Xt]),s.useEffect(()=>{pe(f?.title?.trim()||""),Te(!1)},[f?.id,f?.title]),s.useEffect(()=>{ye(null),Se(""),qe.current=null},[f?.id]),s.useEffect(()=>{ae&&Tn.current?.focus()},[ae]),s.useEffect(()=>{An.current=T},[T]);const Et=s.useCallback(()=>{ct.current!==null&&(window.clearTimeout(ct.current),ct.current=null);const t=St.current;St.current=null,t!==null&&An.current?.(t)},[]),vs=s.useCallback(t=>{St.current=Math.max(0,Math.round(t)),ct.current===null&&(ct.current=window.setTimeout(Et,200))},[Et]);s.useEffect(()=>()=>{const t=qt.current?.scrollTop;typeof t=="number"&&(St.current=Math.max(0,Math.round(t))),Et()},[n.assetId,Et]),s.useEffect(()=>{if(y||O||K||N===null)return;const t=qt.current;if(!t||En.current===n.assetId)return;En.current=n.assetId;const r=Math.max(0,Math.round(I||0));window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>{const o=Math.max(0,t.scrollHeight-t.clientHeight);t.scrollTop=Math.min(r,o)})})},[N,n.assetId,y,I,K,O]),s.useEffect(()=>{gt&&window.setTimeout(()=>{Kt.current?.focus(),Kt.current?.select()},0)},[gt]),s.useEffect(()=>{if(!n.assetId)return;const t=()=>{document.visibilityState==="visible"&&Zt({silent:!0})},r=window.setInterval(t,15e3);return window.addEventListener("focus",t),document.addEventListener("visibilitychange",t),()=>{window.clearInterval(r),window.removeEventListener("focus",t),document.removeEventListener("visibilitychange",t)}},[n.assetId,Zt]),s.useEffect(()=>{if(!y)return;const t=r=>{(r.metaKey||r.ctrlKey)&&r.key==="s"&&(r.preventDefault(),Mn())};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[y,G]);const Oe=s.useCallback(()=>{xt.current!==null&&(window.clearTimeout(xt.current),xt.current=null),Ke.current&&(Ke.current.remove(),Ke.current=null)},[]);s.useEffect(()=>()=>{Oe()},[Oe]);const At=s.useCallback(t=>{if(!y||te!=="split")return;const r=Ut.current,o=Cn.current;if(!r||!o)return;const u=t==="editor"?r:o,m=t==="editor"?o:r,v=Math.max(u.scrollHeight-u.clientHeight,0),C=Math.max(m.scrollHeight-m.clientHeight,0),se=v<=0?0:u.scrollTop/v,he=C*se;Math.abs(m.scrollTop-he)<=1||(m.scrollTop=he)},[y,te]);s.useEffect(()=>{!y||te!=="split"||At("editor")},[G,y,te,At]);const ws=()=>{if(Ue){if(Pe.current){Z({type:"error",message:on});return}Je.current&&L(Je.current.textContent||""),Ie(N??""),Z({type:"idle"}),V(!0),setTimeout(()=>Ut.current?.focus(),50)}},gs=()=>{_t&&!window.confirm("Discard unsaved changes?")||(V(!1),Ie(N??""),Z({type:"idle"}))},Mn=s.useCallback(async()=>{if(Ue){if(rt){Z({type:"error",message:ln});return}if(De.type!=="saving"){Z({type:"saving"});try{const t=await U(Xe("/api/taskforce/documents/save",d),{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({fsPath:n.fsPath,content:G})},i),r=await t.json().catch(()=>({}));if(!t.ok)throw new Error(r.error||`Save failed (${t.status})`);const o=r.updatedAt||new Date().toISOString(),u=typeof r.version=="number"&&Number.isFinite(r.version)?Math.max(1,Math.floor(r.version)):null;H(G),R(u),Z({type:"saved",savedAt:o}),c?.(o),V(!1)}catch(t){Z({type:"error",message:t?.message||"Save failed"})}}}},[i,n.fsPath,G,De.type,c,Ue,rt,d]),ys=s.useCallback(()=>{const t=y?G:N??"";if(!t.trim())return;Oe();const r=document.createElement("iframe");r.setAttribute("aria-hidden","true"),r.tabIndex=-1,r.style.position="fixed",r.style.right="0",r.style.bottom="0",r.style.width="0",r.style.height="0",r.style.border="0",r.style.opacity="0",r.style.pointerEvents="none",document.body.appendChild(r),Ke.current=r;const o=r.contentWindow,u=r.contentDocument;if(!o||!u){Oe();return}u.open(),u.write(Ii(t)),u.close();let m=!1;const v=async()=>{m||Ke.current!==r||(m=!0,await Di(o,u),Ke.current===r&&(o.focus(),o.print(),xt.current=$i(Oe)))};o.addEventListener("afterprint",Oe,{once:!0}),v()},[Oe,N,G,y]),bs=async()=>{const t=n.apiUrl,r=new URL(Yn(t,i),window.location.origin).toString();try{await navigator.clipboard.writeText(r)}catch{const o=document.createElement("textarea");o.value=r,document.body.appendChild(o),o.select(),document.execCommand("copy"),document.body.removeChild(o)}we(!0),setTimeout(()=>we(!1),2e3)},_s=s.useCallback(async()=>{if(z){try{await navigator.clipboard.writeText(z)}catch{const t=document.createElement("textarea");t.value=z,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}re(!0),setTimeout(()=>re(!1),2e3)}},[z]),xs=()=>{const t=n.apiUrl.includes("?")?"&":"?",r=Yn(`${n.apiUrl}${t}download=1&filename=${encodeURIComponent(ie)}`,i),o=document.createElement("a");o.href=r,o.click()},nn=s.useCallback(async()=>{if(!n.assetId)return;const t=Vt.trim();if(!t){Ve($),Fe(!1);return}if(t===$){Fe(!1);return}const r=await U(Xe(`/api/taskforce/documents/${encodeURIComponent(n.assetId)}`,d),{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:t})},i),o=await r.json().catch(()=>({}));if(!r.ok){window.alert(o.error||`Rename failed (${r.status})`);return}J(t),Ve(t),Fe(!1),c?.(o.updatedAt||new Date().toISOString())},[i,n.assetId,c,$,Vt,d]),Cs=s.useCallback(t=>{if(t.key==="Enter"){t.preventDefault(),nn();return}t.key==="Escape"&&(t.preventDefault(),Ve($),Fe(!1))},[nn,$]),ks=s.useCallback(async()=>{if(!n.assetId||wt)return;const t=ot==="attached",r=Math.max(0,Number(n.attachmentCount||0)),o=t?`Delete "${$}" everywhere?
|
|
259
|
+
`)}function Oi({doc:n,taskTitle:l,tasks:h=[],apiBaseUrl:i="",workspaceId:d=null,onSaved:c,onDeleted:p,onBackToTask:b,taskReferences:k,enableTaskGeneration:S=!1,initialScrollTop:I=0,onScrollTopChange:T}){const j=vn(n),[J,Q]=s.useState(j),$=J,ie=Ms({...n,title:J}),z=Bs(n),[N,H]=s.useState(null),Y=s.useRef(null);Y.current=N;const[X,L]=s.useState(null),[x,R]=s.useState(null),[O,W]=s.useState(!1),[K,le]=s.useState(null),[Ne,we]=s.useState(!1),[w,re]=s.useState(!1),[A,M]=s.useState([]),[q,Ce]=s.useState(!1),[fe,B]=s.useState(null),[Me,nt]=s.useState(null),[He,ge]=s.useState({}),[g,F]=s.useState(!1),[Be,ce]=s.useState(!1),[st,Te]=s.useState(!1),[Ee,pe]=s.useState(""),[de,ve]=s.useState(null),[Ae,ke]=s.useState(""),[ae,ye]=s.useState(null),[Le,Se]=s.useState(""),[P,pt]=s.useState(!0),[oe,vt]=s.useState(!1),be=s.useRef(null),We=Me||cn,Re=He[We]?.body||"",_e=He[We]?.anchor||null,Pt=s.useCallback(t=>{ge(r=>{const o=be.current||cn;return{...r,[o]:{body:t,anchor:r[o]?.anchor||null}}})},[]),_=s.useCallback(t=>{ge(r=>{const o=be.current||cn;return{...r,[o]:{body:r[o]?.body||"",anchor:t}}})},[]),[y,V]=s.useState(!1),ee=s.useRef(!1);ee.current=y;const[G,Ie]=s.useState(""),[te,zt]=s.useState("split"),[De,Z]=s.useState({type:"idle"}),[rt,at]=s.useState(!1),[ds,Ot]=s.useState(!1),[gn,us]=s.useState(!1),[wt,yn]=s.useState(!1),[gt,Fe]=s.useState(!1),[ms,yt]=s.useState(!1),[bn,_n]=s.useState(""),[Ht,Wt]=s.useState(null),[xn,bt]=s.useState(null),[Vt,Ve]=s.useState($),Ue=n.editable!==!1,ot=wn(n),hs=!!n.assetId,_t=y&&G!==(N??""),Ut=s.useRef(null),Kt=s.useRef(null),Cn=s.useRef(null),qt=s.useRef(null),Ke=s.useRef(null),xt=s.useRef(null),kn=s.useRef(null),Sn=s.useRef(null),Rn=s.useRef(null),jn=s.useRef(null),Gt=s.useRef(null),Nn=s.useRef(null),Tn=s.useRef(null),Jt=s.useRef(new Map),qe=s.useRef(null),it=s.useRef([]),Ge=s.useRef(!1),Je=s.useRef(0),Qt=s.useRef(null),Pe=s.useRef(null),lt=s.useRef(0),Ct=s.useRef(0),kt=s.useRef(null),Qe=s.useRef(null),St=s.useRef(null),ct=s.useRef(null),En=s.useRef(""),An=s.useRef(T),f=A.find(t=>t.id===Me)||A[0]||null,fs=f?.comments.map(t=>t.id).join("|")||"",In=f?.threadCount??f?.comments.filter(t=>!t.parentCommentId).length??0,ze=f?.unresolvedThreadCount??f?.comments.filter(t=>!t.parentCommentId&&t.threadStatus!=="resolved").length??0,Rt=f?.status==="open"&&ze>0,Dn=h.filter(t=>{const r=bn.trim().toLowerCase();return r?t.title.toLowerCase().includes(r)||String(t.referenceLabel||"").trim().toLowerCase().includes(r):!0}),Yt=s.useCallback(()=>{_(null),pt(!1)},[_]),$n=s.useCallback(()=>{const t=qe.current;qe.current=null,t&&window.setTimeout(()=>{Jt.current.get(t)?.focus()},0)},[]),jt=s.useCallback(()=>{ye(null),Se(""),$n()},[$n]),Nt=s.useCallback(()=>{const t=Sn.current;return t?t.scrollHeight-t.scrollTop-t.clientHeight<=Ni:!0},[]),ps=s.useCallback(()=>{Nt()&&ce(!1)},[Nt]),Xt=s.useCallback((t="smooth")=>{const r=kn.current;typeof r?.scrollIntoView=="function"&&r.scrollIntoView({block:"end",behavior:t}),ce(!1)},[]),$e=s.useCallback(t=>{be.current=t,Ge.current=t!==null,ce(!1),ye(null),Se(""),qe.current=null,nt(t)},[]);s.useEffect(()=>{be.current=Me},[Me]),s.useEffect(()=>{it.current=A},[A]),s.useEffect(()=>{if(typeof window.matchMedia!="function")return;const t=window.matchMedia("(max-width: 1100px)"),r=()=>vt(t.matches);return r(),t.addEventListener?.("change",r),()=>t.removeEventListener?.("change",r)},[]),s.useEffect(()=>{if(!oe||!P)return;const t=Rn.current;if(!t)return;const r=["button:not([disabled])","select:not([disabled])","textarea:not([disabled])","input:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(","),o=window.requestAnimationFrame(()=>jn.current?.focus()),u=m=>{if(m.key==="Escape"){m.preventDefault(),Yt();return}if(m.key!=="Tab")return;const v=Array.from(t.querySelectorAll(r));if(v.length===0){m.preventDefault();return}const C=v[0],se=v[v.length-1];m.shiftKey&&document.activeElement===C?(m.preventDefault(),se.focus()):!m.shiftKey&&document.activeElement===se&&(m.preventDefault(),C.focus())};return document.addEventListener("keydown",u),()=>{window.cancelAnimationFrame(o),document.removeEventListener("keydown",u),t.contains(document.activeElement)&&Gt.current?.focus()}},[Yt,oe,P]);const Tt=s.useCallback(async(t,r)=>{const o=++Je.current,u=Y.current===null;u&&W(!0),le(null);try{const m=await U(n.apiUrl,{credentials:"same-origin"},i);if(!m.ok)throw new Error(`Failed to load document (${m.status})`);const v=await m.text();if(o!==Je.current)return;if(ee.current&&Y.current!==null){Pe.current={revision:r,version:t},at(!0),Z({type:"error",message:ln});return}H(v),ee.current||Ie(v),R(t),Qt.current=r,Pe.current=null,at(!1),Z(C=>C.type==="error"&&C.message===on?{type:"idle"}:C)}catch(m){if(o!==Je.current)return;u?le(m?.message||"Failed to load document"):Z({type:"error",message:on})}finally{u&&o===Je.current&&W(!1)}},[i,n.apiUrl]),Zt=s.useCallback(async t=>{const r=t?.silent===!0;if(r&&kt.current!==null)return;const o=++lt.current,u=Ct.current;if(!n.assetId){it.current=[],M([]),$e(null),B(null);return}r||(kt.current=o,Ce(!0),B(null));try{const m=await U(`/api/taskforce/document-reviews/sessions?assetId=${encodeURIComponent(n.assetId)}`,{credentials:"include"},i),v=await m.json().catch(()=>({}));if(!m.ok)throw new Error(v.error||`Failed to load reviews (${m.status})`);if(o!==lt.current||u!==Ct.current)return;const C=Array.isArray(v.sessions)?v.sessions:[],se=it.current,he=be.current,je=he&&C.some(Ye=>Ye.id===he)?he:C[0]?.id??null;if(r&&je){const Ye=se.find(xe=>xe.id===je)||null,rn=C.find(xe=>xe.id===je)||null,Dt=new Set(Ye?.comments.map(xe=>xe.id)||[]),$t=rn?.comments.some(xe=>!Dt.has(xe.id))===!0;Ye&&$t&&(Nt()?Ge.current=!0:ce(!0))}it.current=C,M(C),je!==he&&$e(je)}catch(m){if(o!==lt.current||u!==Ct.current)return;r||(it.current=[],B(m?.message||"Failed to load reviews"),M([]),$e(null))}finally{!r&&kt.current===o&&(kt.current=null,Ce(!1))}},[i,n.assetId,Nt,$e]),ne=s.useCallback(()=>{Ct.current+=1,lt.current+=1},[]),en=s.useCallback(async()=>{if(!n.assetId||g)return null;F(!0),B(null);try{const t=await U("/api/taskforce/document-reviews/sessions",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({assetId:n.assetId,title:`Review ${A.length+1}`})},i),r=await t.json().catch(()=>({}));if(!t.ok)throw new Error(r.error||`Failed to create review (${t.status})`);const o=r.session||null;if(!o)throw new Error("Review session payload missing.");return ne(),M(u=>[o,...u.filter(m=>m.id!==o.id)]),$e(o.id),o}catch(t){return B(t?.message||"Failed to create review"),null}finally{F(!1)}},[i,n.assetId,ne,g,A.length,$e]),tn=n.assetId,dt=`${n.updatedAt||""}:${n.version||""}`;s.useEffect(()=>{Je.current+=1,lt.current+=1,Y.current=null,H(null),V(!1),at(!1),Qt.current=null,Pe.current=null,Z({type:"idle"}),Fe(!1),we(!1),re(!1),R(null),ge({}),L(null),ce(!1),Te(!1),pe(""),ve(null),ke(""),ye(null),Se(""),qe.current=null},[tn]),s.useEffect(()=>{const t=typeof n.version=="number"&&Number.isFinite(n.version)?Math.max(1,Math.floor(n.version)):null;if(ee.current&&Y.current!==null&&Qt.current!==dt){Je.current+=1,Pe.current={revision:dt,version:t},at(!0),Z({type:"error",message:ln});return}Pe.current={revision:dt,version:t},Tt(t,dt)},[tn,dt,Tt]),s.useEffect(()=>{Zt()},[tn]),s.useEffect(()=>{if(y||!rt)return;const t=Pe.current;t&&(at(!1),Tt(t.version,t.revision))},[y,Tt,rt]),s.useEffect(()=>{Q(j),Ve(j)},[j]),s.useEffect(()=>{y||!Qe.current||!A.some(r=>r.comments.some(o=>o.anchor?.kind==="quote"))||L(Qe.current.textContent||"")},[N,y,A]),s.useEffect(()=>{!f||!Ge.current||(Ge.current=!1,Xt("auto"))},[fs,f?.id,Xt]),s.useEffect(()=>{pe(f?.title?.trim()||""),Te(!1)},[f?.id,f?.title]),s.useEffect(()=>{ye(null),Se(""),qe.current=null},[f?.id]),s.useEffect(()=>{ae&&Tn.current?.focus()},[ae]),s.useEffect(()=>{An.current=T},[T]);const Et=s.useCallback(()=>{ct.current!==null&&(window.clearTimeout(ct.current),ct.current=null);const t=St.current;St.current=null,t!==null&&An.current?.(t)},[]),vs=s.useCallback(t=>{St.current=Math.max(0,Math.round(t)),ct.current===null&&(ct.current=window.setTimeout(Et,200))},[Et]);s.useEffect(()=>()=>{const t=qt.current?.scrollTop;typeof t=="number"&&(St.current=Math.max(0,Math.round(t))),Et()},[n.assetId,Et]),s.useEffect(()=>{if(y||O||K||N===null)return;const t=qt.current;if(!t||En.current===n.assetId)return;En.current=n.assetId;const r=Math.max(0,Math.round(I||0));window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>{const o=Math.max(0,t.scrollHeight-t.clientHeight);t.scrollTop=Math.min(r,o)})})},[N,n.assetId,y,I,K,O]),s.useEffect(()=>{gt&&window.setTimeout(()=>{Kt.current?.focus(),Kt.current?.select()},0)},[gt]),s.useEffect(()=>{if(!n.assetId)return;const t=()=>{document.visibilityState==="visible"&&Zt({silent:!0})},r=window.setInterval(t,15e3);return window.addEventListener("focus",t),document.addEventListener("visibilitychange",t),()=>{window.clearInterval(r),window.removeEventListener("focus",t),document.removeEventListener("visibilitychange",t)}},[n.assetId,Zt]),s.useEffect(()=>{if(!y)return;const t=r=>{(r.metaKey||r.ctrlKey)&&r.key==="s"&&(r.preventDefault(),Mn())};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[y,G]);const Oe=s.useCallback(()=>{xt.current!==null&&(window.clearTimeout(xt.current),xt.current=null),Ke.current&&(Ke.current.remove(),Ke.current=null)},[]);s.useEffect(()=>()=>{Oe()},[Oe]);const At=s.useCallback(t=>{if(!y||te!=="split")return;const r=Ut.current,o=Cn.current;if(!r||!o)return;const u=t==="editor"?r:o,m=t==="editor"?o:r,v=Math.max(u.scrollHeight-u.clientHeight,0),C=Math.max(m.scrollHeight-m.clientHeight,0),se=v<=0?0:u.scrollTop/v,he=C*se;Math.abs(m.scrollTop-he)<=1||(m.scrollTop=he)},[y,te]);s.useEffect(()=>{!y||te!=="split"||At("editor")},[G,y,te,At]);const ws=()=>{if(Ue){if(Pe.current){Z({type:"error",message:on});return}Qe.current&&L(Qe.current.textContent||""),Ie(N??""),Z({type:"idle"}),V(!0),setTimeout(()=>Ut.current?.focus(),50)}},gs=()=>{_t&&!window.confirm("Discard unsaved changes?")||(V(!1),Ie(N??""),Z({type:"idle"}))},Mn=s.useCallback(async()=>{if(Ue){if(rt){Z({type:"error",message:ln});return}if(De.type!=="saving"){Z({type:"saving"});try{const t=await U(Xe("/api/taskforce/documents/save",d),{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({fsPath:n.fsPath,content:G})},i),r=await t.json().catch(()=>({}));if(!t.ok)throw new Error(r.error||`Save failed (${t.status})`);const o=r.updatedAt||new Date().toISOString(),u=typeof r.version=="number"&&Number.isFinite(r.version)?Math.max(1,Math.floor(r.version)):null;H(G),R(u),Z({type:"saved",savedAt:o}),c?.(o),V(!1)}catch(t){Z({type:"error",message:t?.message||"Save failed"})}}}},[i,n.fsPath,G,De.type,c,Ue,rt,d]),ys=s.useCallback(()=>{const t=y?G:N??"";if(!t.trim())return;Oe();const r=document.createElement("iframe");r.setAttribute("aria-hidden","true"),r.tabIndex=-1,r.style.position="fixed",r.style.right="0",r.style.bottom="0",r.style.width="0",r.style.height="0",r.style.border="0",r.style.opacity="0",r.style.pointerEvents="none",document.body.appendChild(r),Ke.current=r;const o=r.contentWindow,u=r.contentDocument;if(!o||!u){Oe();return}u.open(),u.write(Ii(t)),u.close();let m=!1;const v=async()=>{m||Ke.current!==r||(m=!0,await Di(o,u),Ke.current===r&&(o.focus(),o.print(),xt.current=$i(Oe)))};o.addEventListener("afterprint",Oe,{once:!0}),v()},[Oe,N,G,y]),bs=async()=>{const t=n.apiUrl,r=new URL(Yn(t,i),window.location.origin).toString();try{await navigator.clipboard.writeText(r)}catch{const o=document.createElement("textarea");o.value=r,document.body.appendChild(o),o.select(),document.execCommand("copy"),document.body.removeChild(o)}we(!0),setTimeout(()=>we(!1),2e3)},_s=s.useCallback(async()=>{if(z){try{await navigator.clipboard.writeText(z)}catch{const t=document.createElement("textarea");t.value=z,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}re(!0),setTimeout(()=>re(!1),2e3)}},[z]),xs=()=>{const t=n.apiUrl.includes("?")?"&":"?",r=Yn(`${n.apiUrl}${t}download=1&filename=${encodeURIComponent(ie)}`,i),o=document.createElement("a");o.href=r,o.click()},nn=s.useCallback(async()=>{if(!n.assetId)return;const t=Vt.trim();if(!t){Ve($),Fe(!1);return}if(t===$){Fe(!1);return}const r=await U(Xe(`/api/taskforce/documents/${encodeURIComponent(n.assetId)}`,d),{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:t})},i),o=await r.json().catch(()=>({}));if(!r.ok){window.alert(o.error||`Rename failed (${r.status})`);return}Q(t),Ve(t),Fe(!1),c?.(o.updatedAt||new Date().toISOString())},[i,n.assetId,c,$,Vt,d]),Cs=s.useCallback(t=>{if(t.key==="Enter"){t.preventDefault(),nn();return}t.key==="Escape"&&(t.preventDefault(),Ve($),Fe(!1))},[nn,$]),ks=s.useCallback(async()=>{if(!n.assetId||wt)return;const t=ot==="attached",r=Math.max(0,Number(n.attachmentCount||0)),o=t?`Delete "${$}" everywhere?
|
|
260
260
|
|
|
261
|
-
This will remove it from ${r} linked task${r===1?"":"s"} and soft-delete the document across sync.`:`Permanently delete "${$}" from storage?`;if(window.confirm(o)){yn(!0);try{const u=await U(Xe(`/api/taskforce/documents/${encodeURIComponent(n.assetId)}`,d),{method:"DELETE",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{forceDetach:!0}:{})},i),m=await u.json().catch(()=>({}));if(!u.ok)throw new Error(m.error||`Delete failed (${u.status})`);p?.()}catch(u){window.alert(u?.message||"Delete failed")}finally{yn(!1)}}},[i,ot,wt,n.assetId,n.attachmentCount,p,$,d]),Ss=s.useCallback(()=>{_n(""),bt(null),Wt(null),yt(!0)},[]),Rs=s.useCallback(async t=>{if(n.assetId){bt(null),Wt(t);try{const r=await U(Xe(`/api/taskforce/documents/${encodeURIComponent(n.assetId)}/attach`,d),{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetType:"task",targetId:t})},i),o=await r.json().catch(()=>({}));if(!r.ok)throw new Error(o.error||`Attach failed (${r.status})`);if(o.alreadyAttached){bt("This document is already attached to that task.");return}yt(!1),c?.(new Date().toISOString())}catch(r){bt(r?.message||"Failed to attach document.")}finally{Wt(null)}}},[i,n.assetId,c,d]),js=s.useCallback(async()=>{if(!(!f||g)){F(!0),B(null);try{const t=f.status==="resolved"?"open":"resolved",r=await U(`/api/taskforce/document-reviews/sessions/${encodeURIComponent(f.id)}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:t})},i),o=await r.json().catch(()=>({}));if(!r.ok)throw new Error(o.error||`Failed to update review (${r.status})`);const u=o.session||null;if(!u)throw new Error("Review session payload missing.");ne(),M(m=>m.map(v=>v.id===u.id?u:v))}catch(t){B(t?.message||"Failed to update review")}finally{F(!1)}}},[f,i,ne,g]),It=s.useCallback(()=>{window.setTimeout(()=>Nn.current?.focus(),0)},[]),Bn=s.useCallback(()=>{pe(f?.title||""),Te(!1),It()},[f,It]),Ns=s.useCallback(async()=>{if(!f||g)return;const t=Ee.trim();F(!0),B(null);try{const r=await U(`/api/taskforce/document-reviews/sessions/${encodeURIComponent(f.id)}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:t||null})},i),o=await r.json().catch(()=>({}));if(!r.ok)throw new Error(o.error||`Failed to update review (${r.status})`);const u=o.session||null;if(!u)throw new Error("Review session payload missing.");ne(),M(m=>m.map(v=>v.id===u.id?u:v)),Te(!1),It()}catch(r){B(r?.message||"Failed to update review")}finally{F(!1)}},[f,i,ne,It,g,Ee]),Ln=y?G:N??"",Fn=s.useCallback(()=>{if(y||!P)return;const t=typeof window.getSelection=="function"?window.getSelection():null,r=t?.toString().replace(/\s+/g," ").trim()||"";if(!t||!r)return;const o=t.rangeCount>0?t.getRangeAt(0):null,u=Je.current;if(!o||!u)return;const m=o.commonAncestorContainer,v=m.nodeType===Node.TEXT_NODE?m.parentNode:m;if(!(v instanceof Node)||!u.contains(v))return;const C=Pi(u,o,r);C&&_(C)},[y,_,P]),Pn=s.useCallback(()=>{pt(t=>{const r=!t;return r||_(null),r})},[_]),zn=s.useCallback(async()=>{const t=Re.trim();if(!t||g)return;let r=f;if(r||(r=await en()),!!r){F(!0),B(null);try{const o=await U(`/api/taskforce/document-reviews/sessions/${encodeURIComponent(r.id)}/comments`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:t,anchor:_e||{kind:"document"}})},i),u=await o.json().catch(()=>({}));if(!o.ok)throw new Error(u.error||`Failed to add comment (${o.status})`);const m=u.session||null;if(!m)throw new Error("Review session payload missing.");ne(),Ge.current=!0,ce(!1),M(v=>{const C=v.filter(se=>se.id!==m.id);return[m,...C]}),$e(m.id),ge(v=>{const C={...v};return delete C[We],delete C[m.id],C})}catch(o){B(o?.message||"Failed to add comment")}finally{F(!1)}}},[f,i,en,_e,g,Re,We,ne,$e]),Ts=s.useCallback((t,r)=>{ve(t),ke(r)},[]),Es=s.useCallback(async()=>{if(!f||!de||g)return;const t=Ae.trim();if(t){F(!0),B(null);try{const r=await U(`/api/taskforce/document-reviews/sessions/${encodeURIComponent(f.id)}/comments/${encodeURIComponent(de)}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:t})},i),o=await r.json().catch(()=>({}));if(!r.ok)throw new Error(o.error||`Failed to update comment (${r.status})`);const u=o.session||null;if(!u)throw new Error("Review session payload missing.");ne(),M(m=>m.map(v=>v.id===u.id?u:v)),ve(null),ke("")}catch(r){B(r?.message||"Failed to update comment")}finally{F(!1)}}},[f,i,Ae,de,ne,g]),As=s.useCallback(async t=>{if(!f||g)return;const o=(f.comments.find(v=>v.id===t)||null)?.parentCommentId?0:f.comments.filter(v=>v.parentCommentId===t).length,u=o>0,m=u?`Delete this thread and its ${o} ${o===1?"reply":"replies"}? This cannot be undone.`:"Delete this review comment?";if(window.confirm(m)){F(!0),B(null);try{const v=await U(`/api/taskforce/document-reviews/sessions/${encodeURIComponent(f.id)}/comments/${encodeURIComponent(t)}${u?"?cascade=true":""}`,{method:"DELETE",credentials:"include"},i),C=await v.json().catch(()=>({}));if(!v.ok)throw new Error(C.error||`Failed to delete comment (${v.status})`);const se=C.session||null;if(!se)throw new Error("Review session payload missing.");ne(),M(he=>he.map(je=>je.id===se.id?se:je)),de===t&&(ve(null),ke(""))}catch(v){B(v?.message||"Failed to delete comment")}finally{F(!1)}}},[f,i,de,ne,g]),On=s.useCallback(async t=>{if(!f||g||ae!==t)return;const r=Le.trim();if(r){F(!0),B(null);try{const o=await U(`/api/taskforce/document-reviews/sessions/${encodeURIComponent(f.id)}/comments/${encodeURIComponent(t)}/replies`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:r})},i),u=await o.json().catch(()=>({}));if(!o.ok)throw new Error(u.error||`Failed to add reply (${o.status})`);const m=u.session||null;if(!m)throw new Error("Review session payload missing.");ne(),Ge.current=!0,ce(!1),M(v=>v.map(C=>C.id===m.id?m:C)),jt()}catch(o){B(o?.message||"Failed to add reply")}finally{F(!1)}}},[f,i,jt,ne,ae,Le,g]),Hn=s.useCallback(async(t,r)=>{if(!(!f||g)){F(!0),B(null);try{const o=await U(`/api/taskforce/document-reviews/sessions/${encodeURIComponent(f.id)}/comments/${encodeURIComponent(t)}/thread-status`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:r})},i),u=await o.json().catch(()=>({}));if(!o.ok)throw new Error(u.error||`Failed to update thread (${o.status})`);const m=u.session||null;if(!m)throw new Error("Review session payload missing.");ne(),M(v=>v.map(C=>C.id===m.id?m:C)),ye(null),Se("")}catch(o){B(o?.message||"Failed to update thread")}finally{F(!1)}}},[f,i,ne,g]),Wn=(t,r=!1)=>{const o=t.authorActor?.kind==="ai",u=as(t.anchor),m=Bi(t.anchor,N,X),v=o?dr:ur,C=de===t.id,se=t.permissions?.canEdit===!0,he=t.permissions?.canDelete===!0,je=t.permissions?.canReply===!0,Ye=t.permissions?.canResolve===!0,rn=t.permissions?.canReopen===!0,Dt=Date.parse(t.createdAt),$t=Date.parse(t.updatedAt),xe=Number.isFinite(Dt)&&Number.isFinite($t)&&$t>Dt;return e.jsxs("article",{"data-review-comment-id":t.id,"data-conversation-role":o?"assistant":"user",style:t.authorActor?.color?{"--review-accent":t.authorActor.color}:void 0,className:`${a.reviewComment} ${r?a.reviewReply:""}`,children:[e.jsxs("div",{className:a.reviewCommentHeader,children:[e.jsx("span",{className:a.reviewCommentAvatar,style:t.authorActor?.color?{color:t.authorActor.color}:void 0,"aria-hidden":"true",children:e.jsx(v,{size:13,strokeWidth:1.7})}),e.jsx("span",{className:a.reviewCommentAuthor,children:Mi(t)}),e.jsxs("time",{className:a.reviewCommentTime,dateTime:t.updatedAt,title:xe?`Edited ${mt(t.updatedAt)}; originally posted ${mt(t.createdAt)}`:mt(t.createdAt),children:[xe?"Edited · ":"",rs(t.updatedAt)]}),(!r&&t.threadStatus==="resolved"||se||he||C)&&e.jsxs("span",{className:a.reviewCommentHeaderControls,children:[!r&&t.threadStatus==="resolved"&&e.jsx("span",{className:"tf-chip-success",children:"Resolved"}),(se||he||C)&&e.jsxs("span",{className:a.reviewCommentActions,children:[!C&&se&&e.jsx("button",{type:"button",className:`tf-control-icon ${a.reviewCommentAction}`,onClick:()=>Ts(t.id,t.body),disabled:g,"aria-label":"Edit comment",title:"Edit comment",children:e.jsx(ut,{size:13})}),C&&e.jsx("button",{type:"button",className:"tf-button-ghost tf-button-compact",onClick:()=>{ve(null),ke("")},disabled:g,children:"Cancel"}),he&&e.jsx("button",{type:"button",className:`tf-control-icon ${a.reviewCommentAction} ${a.reviewCommentDeleteAction}`,onClick:()=>{As(t.id)},disabled:g,"aria-label":"Delete comment",title:"Delete comment",children:e.jsx(ns,{size:13})})]})]})]}),u&&e.jsxs("span",{className:a.reviewAnchorRow,children:[e.jsx("span",{className:a.reviewAnchorLabel,title:t.anchor?.kind==="quote"?t.anchor.quote:void 0,children:u}),m!=="valid"&&e.jsx("span",{className:m==="moved"?a.reviewAnchorMoved:m==="unresolved"?a.reviewAnchorUnresolved:a.reviewAnchorUnknown,title:m==="moved"?"The quoted text still exists, but its saved location or context changed.":m==="unresolved"?"This anchor no longer resolves in the saved document.":"There is not enough saved context to verify this anchor.",children:m==="moved"?"Moved":m==="unresolved"?"Unresolved":"Unknown"})]}),e.jsx("div",{className:a.reviewCommentBody,children:C?e.jsxs("div",{className:a.reviewCommentEditor,children:[e.jsx("textarea",{className:`tf-field-shell ${a.reviewCommentEditInput}`,value:Ae,onChange:Mt=>ke(Mt.target.value),disabled:g,"aria-label":"Edit comment text"}),e.jsx("button",{type:"button",className:"tf-button-primary tf-button-compact",onClick:()=>{Es()},disabled:g||!Ae.trim(),children:"Save comment"})]}):e.jsx(Lt,{variant:"conversation",taskReferences:k,children:t.body})}),!r&&e.jsxs("div",{className:a.reviewThreadActions,children:[je&&e.jsxs("button",{ref:Mt=>{Mt?Qt.current.set(t.id,Mt):Qt.current.delete(t.id)},type:"button",className:"tf-button-ghost tf-button-compact",onClick:()=>{qe.current=t.id,ye(t.id),Se("")},disabled:g,children:[e.jsx(mr,{size:13}),"Reply"]}),Ye&&e.jsxs("button",{type:"button",className:"tf-button-ghost tf-button-compact",onClick:()=>{Hn(t.id,"resolved")},disabled:g,children:[e.jsx(ht,{size:13}),"Resolve"]}),rn&&e.jsxs("button",{type:"button",className:"tf-button-ghost tf-button-compact",onClick:()=>{Hn(t.id,"open")},disabled:g,children:[e.jsx(dn,{size:13}),"Reopen"]})]})]},t.id)},Vn=s.useCallback(async t=>{if(!Ue)return!1;Z({type:"saving"});try{const r=await U(Xe("/api/taskforce/documents/save",d),{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({fsPath:n.fsPath,content:t})},i),o=await r.json().catch(()=>({}));if(!r.ok)throw new Error(o.error||`Save failed (${r.status})`);const u=o.updatedAt||new Date().toISOString();return H(t),Ie(t),Z({type:"saved",savedAt:u}),c?.(u),!0}catch(r){return Z({type:"error",message:r?.message||"Save failed"}),!1}},[i,n.fsPath,c,Ue,d]),Is=s.useCallback((t,r)=>{const o=y?G:N??"",u=zi(o,t,r);if(u!==o){if(y){Ie(u),Z(m=>m.type==="saving"?m:{type:"idle"});return}Vn(u)}},[N,G,y,Vn]);let Un=-1;const sn=t=>!t||!Array.isArray(t.children)?!1:t.children.some(r=>r?r.type==="element"&&r.tagName==="input"&&r.properties?.type==="checkbox"?!0:sn(r):!1),Kn=t=>!t||!Array.isArray(t.children)?!1:t.children.some(r=>typeof r?.checked=="boolean"?!0:sn(r)),qn={input({type:t,checked:r,node:o,...u}){if(t!=="checkbox")return e.jsx("input",{type:t,checked:r,...u});Un+=1;const m=Un;return e.jsx("input",{...u,type:"checkbox",checked:!!r,disabled:!1,onClick:v=>v.stopPropagation(),onChange:v=>Is(m,v.currentTarget.checked)})},ul({children:t,node:r,...o}){const u=Kn(r);return e.jsx("ul",{...o,"data-task-list":u?"true":void 0,children:t})},ol({children:t,node:r,...o}){const u=Kn(r);return e.jsx("ol",{...o,"data-task-list":u?"true":void 0,children:t})},li({children:t,node:r,...o}){const u=typeof r?.checked=="boolean"||sn(r);return e.jsx("li",{...o,"data-task-item":u?"true":void 0,children:t})}};return e.jsxs("div",{className:`${a.viewer} ${y?a.viewerEditMode:""} ${gn?a.viewerMonochrome:""}`,children:[e.jsxs("div",{className:a.meta,children:[e.jsxs("div",{className:a.metaLeft,children:[e.jsxs("span",{className:`${a.typeBadge} ${Si[n.docType]??""}`,children:[e.jsx(Zs,{size:10}),ki[n.docType]]}),gt?e.jsx("div",{className:a.metaRenameRow,children:e.jsx("input",{ref:Kt,type:"text",className:me.input,value:Vt,onChange:t=>Ve(t.target.value),onBlur:()=>{nn()},onKeyDown:Cs})}):e.jsx("span",{className:a.metaDocumentName,title:$,onDoubleClick:()=>{n.assetId&&(Ve($),Fe(!0))},children:$}),l&&e.jsx("span",{className:a.metaTaskName,title:`From task: ${l}`,children:l}),ot==="unattached"&&e.jsx("span",{className:a.statusBadge,children:"Unattached"}),n.updatedAt&&e.jsxs("span",{className:a.metaDate,title:mt(n.updatedAt),children:[e.jsx(er,{size:11}),mt(n.updatedAt)]}),e.jsxs("span",{className:a.metaSize,children:[e.jsx(tr,{size:11}),Ei(n.sizeBytes)]}),z&&e.jsx(Ls,{label:z,copied:w,onClick:()=>{_s()},title:$}),De.type==="saved"&&e.jsxs("span",{className:`${a.saveStatus} ${a.saveStatusSaved}`,children:[e.jsx(ht,{size:11}),"Saved"]}),De.type==="error"&&e.jsxs("span",{className:`${a.saveStatus} ${a.saveStatusError}`,title:De.message,children:[e.jsx(Ft,{size:11}),De.message||"Save failed"]}),_t&&De.type!=="saving"&&e.jsx("span",{className:a.unsaved,children:"Unsaved changes"})]}),e.jsx("div",{className:a.actions,children:y?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:a.layoutToggle,children:[e.jsx("button",{className:`${a.layoutBtn} ${te==="editor"?a.layoutBtnActive:""}`,onClick:()=>zt("editor"),title:"Editor only",children:e.jsx(ut,{size:12})}),e.jsx("button",{className:`${a.layoutBtn} ${te==="split"?a.layoutBtnActive:""}`,onClick:()=>zt("split"),title:"Split view",children:e.jsx(nr,{size:12})}),e.jsx("button",{className:`${a.layoutBtn} ${te==="preview"?a.layoutBtnActive:""}`,onClick:()=>zt("preview"),title:"Preview only",children:e.jsx(un,{size:12})})]}),e.jsxs("button",{ref:Gt,className:a.actionBtn,onClick:Pn,title:P?"Hide review and comments":"Show review and comments",children:[e.jsx(Bt,{size:13}),P?"Hide Review":"Show Review"]}),e.jsxs("button",{className:a.actionBtn,onClick:gs,title:"Discard changes",children:[e.jsx(hn,{size:13}),"Cancel"]}),e.jsxs("button",{className:`${a.actionBtn} ${a.saveBtn}`,onClick:Mn,disabled:De.type==="saving"||!_t||rt,title:"Save (Ctrl+S)",children:[e.jsx(sr,{size:13}),De.type==="saving"?"Saving…":"Save"]})]}):e.jsxs(e.Fragment,{children:[n.taskId&&b&&e.jsxs("button",{className:a.actionBtn,onClick:()=>b(n.taskId),title:"Back to task","aria-label":"Back to task",children:[e.jsx(rr,{size:13}),"Back to task"]}),n.assetId&&e.jsxs("button",{className:a.actionBtn,onClick:()=>Fe(t=>!t),title:"Rename document",children:[e.jsx(ut,{size:13}),gt?"Close Rename":"Rename"]}),Ue&&e.jsxs("button",{className:`${a.actionBtn} ${a.editBtn}`,onClick:ws,title:"Edit document",children:[e.jsx(ut,{size:13}),"Edit"]}),n.assetId&&e.jsxs("button",{className:a.actionBtn,onClick:Ss,title:"Attach document to a task",children:[e.jsx(ts,{size:13}),"Attach"]}),e.jsxs("button",{ref:Gt,className:a.actionBtn,onClick:Pn,title:P?"Hide review and comments":"Show review and comments",children:[e.jsx(Bt,{size:13}),P?"Hide Review":"Show Review"]}),e.jsxs("button",{className:a.actionBtn,onClick:bs,title:"Copy link",children:[e.jsx(ts,{size:13}),Ne?"Copied!":"Copy link"]}),e.jsxs("button",{className:a.actionBtn,onClick:xs,title:"Download .md",children:[e.jsx(ar,{size:13}),"Download"]}),e.jsxs("button",{className:a.actionBtn,onClick:ys,title:"Print document. In the print dialog, disable headers and footers for the cleanest output.",children:[e.jsx(or,{size:13}),"Print"]}),e.jsxs("button",{className:a.actionBtn,onClick:()=>us(t=>!t),title:"Toggle black and white style",children:[e.jsx(un,{size:13}),gn?"Color":"B/W"]}),S&&n.docType==="implementation-plan"&&!y&&e.jsxs("button",{className:`${a.actionBtn} ${a.generateBtn}`,onClick:()=>Ot(!0),title:"Generate tasks from this plan",children:[e.jsx(mn,{size:13}),"Generate Tasks"]}),hs&&e.jsxs("button",{className:`${a.actionBtn} ${a.dangerBtn}`,onClick:()=>{ks()},disabled:wt,title:ot==="attached"?"Remove this document from linked tasks and delete it":"Permanently delete this unattached document",children:[e.jsx(ns,{size:13}),wt?"Deleting…":ot==="attached"?"Delete & Unlink":"Delete Permanently"]})]})})]}),O&&e.jsx("div",{className:a.viewerState,children:"Loading…"}),!O&&K&&e.jsx("div",{className:a.viewerStateError,children:K}),!O&&!K&&e.jsxs("div",{className:`${a.viewerBody} ${P?"":a.viewerBodyFullWidth}`,children:[y?e.jsxs("div",{className:`${a.editorArea} ${a.viewerMain} ${Ri[te]}`,children:[(te==="editor"||te==="split")&&e.jsxs("div",{className:a.editorPane,children:[e.jsx("div",{className:a.editorPaneLabel,children:"Markdown"}),e.jsx("textarea",{ref:Ut,className:`${a.editorTextarea} tf-scrollbar`,value:G,onScroll:()=>At("editor"),onChange:t=>{Ie(t.target.value),Z(r=>r.type==="saving"?r:{type:"idle"})},spellCheck:!0,placeholder:"Write markdown here…"})]}),(te==="preview"||te==="split")&&e.jsxs("div",{className:a.previewPane,children:[e.jsx("div",{className:a.editorPaneLabel,children:"Preview"}),e.jsx("div",{ref:Cn,className:`${me.docMarkdown} ${a.markdownSurface}`,"data-testid":"doc-preview-scroll",onScroll:()=>At("preview"),children:e.jsx(Lt,{variant:"document",taskReferences:k,documentOverrides:qn,children:Ln})})]})]}):e.jsx("div",{ref:qt,className:`${a.viewerContent} ${a.viewerMain} tf-scrollbar`,"data-testid":"doc-viewer-scroll",onScroll:t=>vs(t.currentTarget.scrollTop),children:e.jsx("div",{ref:Je,className:`${me.docMarkdown} ${a.markdownSurface} ${a.readerSurface}`,"data-testid":"doc-reader-surface",onMouseUp:P?Fn:void 0,onKeyUp:P?Fn:void 0,children:e.jsx(Lt,{variant:"document",taskReferences:k,documentOverrides:qn,children:Ln})})}),P&&e.jsx("aside",{ref:Rn,className:a.reviewRail,role:oe?"dialog":void 0,"aria-modal":oe?!0:void 0,"aria-label":oe?"Review and comments":void 0,children:e.jsxs("section",{className:a.reviewSection,"aria-label":"Review and comments",children:[e.jsxs("div",{className:a.reviewHeader,children:[e.jsxs("div",{className:a.reviewHeaderTop,children:[e.jsx("span",{className:a.reviewEyebrow,children:"Review"}),e.jsxs("div",{className:a.reviewHeaderActions,children:[f&&e.jsx("span",{className:f.status==="resolved"?"tf-chip-success":"tf-chip-warning",role:"status","aria-live":"polite",children:f.status==="resolved"?"Resolved":"Open"}),e.jsx("button",{ref:jn,type:"button",className:`tf-control-icon ${a.reviewCloseButton}`,onClick:Yt,"aria-label":"Close review",title:"Close review",children:e.jsx(hn,{size:15})})]})]}),f?e.jsxs(e.Fragment,{children:[st?e.jsxs("div",{className:a.reviewTitleEditRow,children:[e.jsx("input",{type:"text",className:`tf-field-shell ${a.reviewTitleInput}`,value:Ee,onChange:t=>pe(t.target.value),onKeyDown:t=>{t.key==="Escape"&&(t.preventDefault(),t.stopPropagation(),Bn())},placeholder:"Untitled review","aria-label":"Review title",autoFocus:!0}),e.jsx("button",{type:"button",className:"tf-button-primary tf-button-compact",onClick:()=>{Ns()},disabled:g,children:"Save"}),e.jsx("button",{type:"button",className:"tf-button-ghost tf-button-compact",onClick:Bn,disabled:g,children:"Cancel"})]}):e.jsx("h2",{className:a.reviewSessionTitle,children:f.title?.trim()||"Untitled review"}),e.jsxs("div",{className:a.reviewMetadataRow,children:[e.jsxs("div",{className:a.reviewMetadata,children:[e.jsxs("div",{className:a.reviewSessionDetails,children:[e.jsxs("span",{children:[In," ",In===1?"thread":"threads",f.status==="open"&&ze>0?` · ${ze} open`:""]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{children:["Updated ",rs(f.updatedAt)]})]}),(f.documentVersion||x)&&e.jsxs("div",{className:a.reviewVersionDetails,children:[e.jsxs("span",{children:["Review ",f.documentVersion?`v${f.documentVersion}`:"version unknown"]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{children:["Document ",x?`v${x}`:"version unknown"]})]})]}),e.jsx("button",{ref:Nn,type:"button",className:"tf-control-icon tf-control-icon-compact",onClick:()=>Te(!0),disabled:g,"aria-label":"Rename review",title:"Rename review",children:e.jsx(ut,{size:13})})]}),y&&e.jsx("div",{className:a.reviewDraftNotice,role:"status",children:_t?"Comments reference the saved document. Unsaved edits are not part of this review.":"Comments reference the saved document while you edit."}),!y&&f.documentVersion&&x&&f.documentVersion!==x&&e.jsxs("div",{className:a.reviewVersionNotice,role:"status",children:[e.jsx(Ft,{size:13,"aria-hidden":"true"}),e.jsxs("span",{children:["Review covers document v",f.documentVersion,"; current document is v",x,"."]})]})]}):e.jsxs("div",{children:[e.jsx("h2",{className:a.reviewEmptyHeading,children:"No active review"}),e.jsx("p",{className:a.reviewSubtitle,children:"Start a review to collect feedback on this document."})]}),e.jsxs("div",{className:a.reviewControls,role:"group","aria-label":"Review controls",children:[e.jsxs("select",{className:`tf-field-shell ${a.reviewSelect}`,value:f?.id||"",onChange:t=>$e(t.target.value||null),disabled:g||A.length===0,"aria-label":"Select review session",children:[A.length===0&&e.jsx("option",{value:"",children:"No review"}),A.map(t=>e.jsx("option",{value:t.id,children:t.title?.trim()||"Untitled review"},t.id))]}),e.jsx("button",{type:"button",className:`tf-control-icon ${a.reviewCreateButton}`,onClick:()=>{en()},disabled:g||!n.assetId,"aria-label":"New review",title:"New Review",children:e.jsx(ir,{size:15})}),f&&e.jsxs("button",{type:"button",className:`tf-button-secondary tf-button-compact ${a.reviewResolutionAction}`,onClick:()=>{Rt||js()},disabled:g,"aria-disabled":Rt||void 0,"aria-label":Rt?`Resolve review unavailable: resolve ${ze} open thread${ze===1?"":"s"} first`:f.status==="resolved"?"Reopen review":"Resolve review",title:Rt?`Resolve ${ze} open thread${ze===1?"":"s"} first`:f.status==="resolved"?"Reopen review":"Resolve review",children:[f.status==="resolved"?e.jsx(dn,{size:13}):e.jsx(ht,{size:13}),f.status==="resolved"?"Reopen":"Resolve"]})]})]}),fe&&e.jsx("div",{className:a.viewerStateError,children:fe}),e.jsxs("div",{className:a.reviewWorkspace,children:[e.jsxs("div",{ref:Sn,className:`${a.reviewThread} tf-scrollbar`,"data-testid":"review-thread",onScroll:ps,children:[q&&e.jsx("div",{className:a.reviewEmptyState,children:"Loading review comments…"}),!q&&!f&&e.jsxs("div",{className:a.reviewEmptyState,children:[e.jsx(Bt,{size:20}),e.jsx("span",{children:"Start a review to collect comments for this document."})]}),!q&&f&&f.comments.length===0&&e.jsxs("div",{className:a.reviewEmptyState,children:[e.jsx(Bt,{size:20}),e.jsx("span",{children:"No comments yet. Add the first review note."})]}),!q&&f&&f.comments.filter(t=>!t.parentCommentId).map(t=>{const r=f.comments.filter(o=>o.parentCommentId===t.id);return e.jsxs("section",{className:a.reviewCommentThread,children:[Wn(t),r.length>0&&e.jsx("div",{className:a.reviewReplies,children:r.map(o=>Wn(o,!0))}),ae===t.id&&e.jsxs("div",{className:a.reviewReplyComposer,onKeyDown:o=>{o.key==="Escape"&&(o.preventDefault(),o.stopPropagation(),jt())},children:[e.jsx("textarea",{ref:Tn,className:`tf-field-shell ${a.reviewReplyInput}`,value:Le,onChange:o=>Se(o.target.value),placeholder:"Write a reply…",disabled:g,"aria-label":"Reply text",onKeyDown:o=>{o.key==="Enter"&&!o.shiftKey&&(o.preventDefault(),On(t.id))}}),e.jsxs("div",{className:a.reviewReplyComposerActions,children:[e.jsx("button",{type:"button",className:"tf-button-ghost tf-button-compact",onClick:jt,disabled:g,children:"Cancel"}),e.jsx("button",{type:"button",className:"tf-button-primary tf-button-compact",onClick:()=>{On(t.id)},disabled:g||!Le.trim(),children:"Reply"})]})]})]},t.id)}),e.jsx("div",{ref:kn})]}),Be&&f&&e.jsx("div",{className:a.reviewNewCommentsBar,"aria-live":"polite",children:e.jsxs("button",{type:"button",className:"tf-button-secondary tf-button-compact",onClick:()=>Xt(),children:[e.jsx(lr,{size:13}),"New comments"]})}),f?.status==="resolved"?e.jsxs("div",{className:a.reviewResolvedComposer,children:[e.jsx("span",{className:a.reviewResolvedIcon,"aria-hidden":"true",children:e.jsx(ht,{size:16})}),e.jsxs("div",{className:a.reviewResolvedCopy,children:[e.jsx("strong",{children:"Review resolved"}),e.jsx("span",{children:"Reopen it to add more comments."})]})]}):e.jsxs("div",{className:a.reviewComposerArea,children:[_e&&e.jsxs("div",{className:a.reviewAnchorChip,children:[e.jsx("span",{children:_e.kind==="quote"?"Selected text":as(_e)||"Selected text"}),"quote"in _e&&_e.quote&&e.jsxs("span",{className:a.reviewAnchorSnippet,children:['"',_e.quote,'"']}),e.jsx("button",{type:"button",className:a.reviewAnchorClear,onClick:()=>_(null),"aria-label":"Clear selected text",children:"Clear"})]}),e.jsxs("div",{className:a.reviewComposerRow,children:[e.jsx("textarea",{className:`tf-field-shell ${a.reviewComposerInput}`,placeholder:_e?"Add a comment for the selected text…":"Add a comment for this document review…",value:Re,onChange:t=>Pt(t.target.value),disabled:g,onKeyDown:t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),zn())}}),e.jsx("button",{type:"button",className:`tf-button-primary ${a.reviewSendButton}`,onClick:()=>{zn()},disabled:g||!Re.trim(),"aria-label":"Send review comment",title:"Send review comment",children:e.jsx(cr,{size:15})})]}),e.jsx("span",{className:a.reviewComposerHint,children:"Enter to send · Shift + Enter for a new line"})]})]})]})})]}),S&&ds&&N!==null&&e.jsx(Ci,{content:N,docTitle:n.title,apiBaseUrl:i,onClose:()=>Ot(!1),onGenerated:t=>Ot(!1)}),e.jsx(Fs,{isOpen:ms,onClose:()=>{Ht||yt(!1)},title:"Attach document",size:"md",footer:e.jsx("button",{className:a.actionBtn,onClick:()=>yt(!1),disabled:!!Ht,children:"Close"}),children:e.jsxs("div",{className:a.attachModalBody,children:[e.jsx("p",{className:a.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:me.input,placeholder:"Search tasks…",value:bn,onChange:t=>_n(t.target.value)}),xn&&e.jsxs("div",{className:a.attachModalError,children:[e.jsx(Ft,{size:14}),e.jsx("span",{children:xn})]}),e.jsx("div",{className:`${a.attachTaskList} tf-scrollbar`,children:Dn.length===0?e.jsx("div",{className:a.attachEmptyState,children:h.length===0?"No tasks are available in this workspace.":"No tasks match your search."}):Dn.map(t=>{const r=n.taskId===t.id,o=Ht===t.id;return e.jsxs("button",{type:"button",className:a.attachTaskRow,disabled:o,onClick:()=>{Rs(t.id)},children:[e.jsxs("span",{className:a.attachTaskInfo,children:[e.jsx("span",{className:a.attachTaskTitle,children:t.title}),t.referenceLabel&&e.jsx("span",{className:a.attachTaskReference,children:t.referenceLabel})]}),e.jsx("span",{className:a.attachTaskMeta,children:o?"Attaching…":r?"Attached":"Attach"})]},t.id)})})]})})]})}function os(n){return typeof n=="string"?n.trim().replace(/\/+$/,""):""}function Hi(n){return n.runtimeMode==="local"?"":os(n.apiBaseUrl)||os(n.cloudAuthBaseUrl)||""}function Wi({runtimeMode:n="local",workspaceId:l=null,apiBaseUrl:h="",cloudAuthBaseUrl:i="",typeFilters:d,attachmentFilters:c,onTypeFiltersChange:p,onAttachmentFiltersChange:b,sortField:k,sortOrder:S,onSortFieldChange:I,onSortOrderChange:T,pinnedDocIds:j,onPinnedDocIdsChange:Q,selectedDocId:J,onSelectedDocIdChange:$,searchQuery:ie,onSearchQueryChange:z,requestedDocPath:N=null,requestedDocAssetId:H=null,onRequestedDocHandled:Y,selectionReady:X=!0}){const[L,x]=s.useState([]),[R,O]=s.useState(!0),[W,K]=s.useState(null),[le,Ne]=s.useState(null),[we,w]=s.useState(""),[re,A]=s.useState("updated"),[M,q]=s.useState("desc"),[Ce,fe]=s.useState([]),[B,Me]=s.useState(()=>et.map(_=>_.value)),[nt,He]=s.useState(()=>tt.map(_=>_.value)),ge=Hi({runtimeMode:n,apiBaseUrl:h,cloudAuthBaseUrl:i}),g=String(l||"").trim(),F=Xe("/api/taskforce/documents",l),Be=d??B,ce=c??nt,st=p??Me,Te=b??He,Ee=k??re,pe=S??M,de=J!==void 0?J:le,ve=ie!==void 0?ie:we,Ae=I??A,ke=T??q,ae=j??Ce,ye=Q??fe,Le=s.useRef(ae),Se=s.useRef(ye);Le.current=ae,Se.current=ye;const P=$??Ne,pt=z??w,oe=s.useCallback(async()=>{O(!0),K(null);try{const _=await U(F,{credentials:"include"},ge);if(!_.ok)throw new Error(`Failed to load documents (${_.status})`);const y=await _.json(),V=Array.isArray(y.documents)?y.documents:[];V.length,x(V);const ee=new Set(V.map(te=>te.assetId)),G=Le.current,Ie=G.filter(te=>ee.has(te));Ie.length!==G.length&&Se.current(Ie)}catch(_){K(_?.message||"Failed to load documents"),_?.message}finally{O(!1)}},[ge,F,n]);s.useEffect(()=>{oe()},[oe]),s.useEffect(()=>{if(typeof window>"u")return;const _=y=>{const V=y.detail||{},ee=String(V.workspaceId||"").trim();g&&ee&&ee!==g||oe()};return window.addEventListener(Xn,_),()=>{window.removeEventListener(Xn,_)}},[oe,g]),s.useEffect(()=>{if(typeof window>"u")return;const _=y=>{const V=y.detail,ee=String(V?.workspaceId||"").trim();g&&ee&&ee!==g||oe()};return window.addEventListener(Zn,_),()=>{window.removeEventListener(Zn,_)}},[oe,g]);const vt=s.useMemo(()=>zr(L,ve,Be,ce),[ce,L,ve,Be]),be=s.useMemo(()=>{const _=zs(vt,Ee,pe),y=new Set(ae);return[..._.filter(V=>y.has(V.assetId)),..._.filter(V=>!y.has(V.assetId))]},[vt,ae,Ee,pe]),We=s.useCallback(_=>{ye(ae.includes(_)?ae.filter(y=>y!==_):[...ae,_].slice(-50))},[ye,ae]),Re=s.useMemo(()=>de?L.find(_=>_.assetId===de)??null:null,[L,de]);s.useEffect(()=>{if(!N&&!H||L.length===0)return;const _=N?fn(N):"",y=String(H||"").trim().toLowerCase()||ss(N),V=L.find(ee=>{const G=String(ee.assetId||"").trim().toLowerCase()||ss(ee.fsPath);return y&&G&&G===y?!0:_?Pr(fn(ee.fsPath),_):!1});V&&(P(V.assetId),Y?.())},[L,P,Y,H,N]),s.useEffect(()=>{if(!(R||W)&&!((N||H)&&!Re)&&X){if(be.length===0){de!==null&&P(null);return}Re&&be.some(_=>_.assetId===Re.assetId)||P(be[0].assetId)}},[W,be,P,R,H,N,Re,de,X]);const _e=s.useCallback(async()=>{P(null),await oe()},[oe,P]),Pt=ve.trim().length>0||Be.length!==et.length||ce.length!==tt.length;return{documentApiBaseUrl:ge,documents:L,filteredDocs:be,loading:R,error:W,selectedDoc:Re,searchQuery:ve,typeFilters:Be,attachmentFilters:ce,hasActiveFilters:Pt,sortField:Ee,sortOrder:pe,setSortField:Ae,setSortOrder:ke,setSearchQuery:pt,pinnedDocIds:ae,togglePinnedDoc:We,handleTypeFiltersChange:st,handleAttachmentFiltersChange:Te,fetchDocuments:oe,selectDoc:_=>P(_?.assetId??null),handleDeleteSelected:_e}}const Vi=et.map(n=>n.value),Ui=tt.map(n=>n.value);function Ki({tasks:n,apiBaseUrl:l="",workspaceId:h=null,documents:i,loading:d,error:c,selectedDoc:p,searchQuery:b,hasActiveFilters:k,documentTrayOpen:S,sortField:I,sortOrder:T,pinnedDocIds:j=[],onTogglePinnedDoc:Q,onSearchChange:J,onSelectDoc:$,onRefresh:ie,onCloseDocumentTray:z,onDeleteSelected:N,onSortFieldChange:H,onSortOrderChange:Y,typeFilters:X=Vi,attachmentFilters:L=Ui,onTypeFiltersChange:x=()=>{},onAttachmentFiltersChange:R=()=>{},onBackToTask:O,taskReferences:W,enableTaskGeneration:K=!1,documentScrollByDocId:le,onDocumentScrollChange:Ne,documentListScrollTop:we,onDocumentListScrollChange:w}){const re=new Map(n.map(q=>[q.id,q])),A=typeof S=="boolean",M=e.jsx(Kr,{documents:i,selectedDocId:p?.assetId??null,loading:d,error:c,searchQuery:b,sortField:I,sortOrder:T,pinnedDocIds:j,onTogglePinnedDoc:Q,onSearchChange:J,onSelect:q=>$(q),onCloseTray:A?z:void 0,onSortFieldChange:H,onSortOrderChange:Y,typeFilters:X,attachmentFilters:L,onTypeFiltersChange:x,onAttachmentFiltersChange:R,taskById:re,hasActiveFilters:k,listScrollTop:we,onListScrollChange:w});return e.jsxs("div",{className:`${me.docWorkspace} ${A?me.docWorkspaceTrayMode:""} ${A&&S?me.docWorkspaceTrayOpen:""}`.trim(),children:[A?e.jsx("div",{className:`${me.docTrayPanel} ${S?me.docTrayPanelOpen:""}`.trim(),"aria-hidden":!S,children:M}):e.jsx("div",{className:me.docIndexPanel,children:M}),e.jsx("div",{className:me.docViewerPanel,children:p?e.jsx(Oi,{doc:p,taskTitle:p.taskId?re.get(p.taskId)?.title??null:null,tasks:n,apiBaseUrl:l,workspaceId:h,onSaved:q=>ie(),onDeleted:()=>{N()},onBackToTask:O,taskReferences:W,enableTaskGeneration:K,initialScrollTop:le?.[p.assetId]??0,onScrollTopChange:q=>Ne?.(p.assetId,q)}):!d&&e.jsx("div",{className:me.docViewerEmpty,children:e.jsx("p",{className:"tf-empty-copy",children:i.length===0?"No documents match your current filters.":"Select a document to view it."})})})]})}function el({tasks:n,runtimeMode:l="local",workspaceId:h=null,apiBaseUrl:i="",cloudAuthBaseUrl:d="",typeFilters:c,attachmentFilters:p,onTypeFiltersChange:b,onAttachmentFiltersChange:k,sortField:S,sortOrder:I,onSortFieldChange:T,onSortOrderChange:j,pinnedDocIds:Q,onPinnedDocIdsChange:J,searchQuery:$,onSearchQueryChange:ie,selectedDocId:z,onSelectedDocIdChange:N,selectionReady:H=!0,documentScrollByDocId:Y,onDocumentScrollChange:X,documentListScrollTop:L,onDocumentListScrollChange:x,documentTrayOpen:R,onCloseDocumentTray:O,requestedDocPath:W=null,requestedDocAssetId:K=null,onRequestedDocHandled:le,onBackToTask:Ne,taskReferences:we,enableTaskGeneration:w=!1}){const{documentApiBaseUrl:re,filteredDocs:A,loading:M,error:q,selectedDoc:Ce,searchQuery:fe,typeFilters:B,attachmentFilters:Me,hasActiveFilters:nt,sortField:He,sortOrder:ge,setSortField:g,setSortOrder:F,setSearchQuery:Be,handleTypeFiltersChange:ce,handleAttachmentFiltersChange:st,pinnedDocIds:Te,togglePinnedDoc:Ee,fetchDocuments:pe,selectDoc:de,handleDeleteSelected:ve}=Wi({runtimeMode:l,workspaceId:h,apiBaseUrl:i,cloudAuthBaseUrl:d,typeFilters:c,attachmentFilters:p,onTypeFiltersChange:b,onAttachmentFiltersChange:k,sortField:S,sortOrder:I,onSortFieldChange:T,onSortOrderChange:j,pinnedDocIds:Q,onPinnedDocIdsChange:J,searchQuery:$,onSearchQueryChange:ie,selectedDocId:z,onSelectedDocIdChange:N,selectionReady:H,requestedDocPath:W,requestedDocAssetId:K,onRequestedDocHandled:le}),Ae=ue.useRef(R);return ue.useEffect(()=>{const ke=Ae.current===!0;Ae.current=R,!(R!==!0||ke)&&pe()},[R,pe]),e.jsx(Ki,{tasks:n,apiBaseUrl:re,workspaceId:h,documents:A,loading:M,error:q,selectedDoc:Ce,searchQuery:fe,typeFilters:B,attachmentFilters:Me,hasActiveFilters:nt,documentTrayOpen:R,sortField:He,sortOrder:ge,pinnedDocIds:Te,onTogglePinnedDoc:Ee,onSearchChange:Be,onTypeFiltersChange:ce,onAttachmentFiltersChange:st,onSelectDoc:de,onRefresh:pe,onCloseDocumentTray:O,onDeleteSelected:ve,onSortFieldChange:g,onSortOrderChange:F,onBackToTask:Ne,taskReferences:we,enableTaskGeneration:w,documentScrollByDocId:Y,onDocumentScrollChange:X,documentListScrollTop:L,onDocumentListScrollChange:x})}export{tt as DOCUMENT_ATTACHMENT_FILTER_OPTIONS,et as DOCUMENT_TYPE_FILTER_OPTIONS,Ki as DocumentWorkspace,el as DocumentWorkspaceShell};
|
|
261
|
+
This will remove it from ${r} linked task${r===1?"":"s"} and soft-delete the document across sync.`:`Permanently delete "${$}" from storage?`;if(window.confirm(o)){yn(!0);try{const u=await U(Xe(`/api/taskforce/documents/${encodeURIComponent(n.assetId)}`,d),{method:"DELETE",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{forceDetach:!0}:{})},i),m=await u.json().catch(()=>({}));if(!u.ok)throw new Error(m.error||`Delete failed (${u.status})`);p?.()}catch(u){window.alert(u?.message||"Delete failed")}finally{yn(!1)}}},[i,ot,wt,n.assetId,n.attachmentCount,p,$,d]),Ss=s.useCallback(()=>{_n(""),bt(null),Wt(null),yt(!0)},[]),Rs=s.useCallback(async t=>{if(n.assetId){bt(null),Wt(t);try{const r=await U(Xe(`/api/taskforce/documents/${encodeURIComponent(n.assetId)}/attach`,d),{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetType:"task",targetId:t})},i),o=await r.json().catch(()=>({}));if(!r.ok)throw new Error(o.error||`Attach failed (${r.status})`);if(o.alreadyAttached){bt("This document is already attached to that task.");return}yt(!1),c?.(new Date().toISOString())}catch(r){bt(r?.message||"Failed to attach document.")}finally{Wt(null)}}},[i,n.assetId,c,d]),js=s.useCallback(async()=>{if(!(!f||g)){F(!0),B(null);try{const t=f.status==="resolved"?"open":"resolved",r=await U(`/api/taskforce/document-reviews/sessions/${encodeURIComponent(f.id)}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:t})},i),o=await r.json().catch(()=>({}));if(!r.ok)throw new Error(o.error||`Failed to update review (${r.status})`);const u=o.session||null;if(!u)throw new Error("Review session payload missing.");ne(),M(m=>m.map(v=>v.id===u.id?u:v))}catch(t){B(t?.message||"Failed to update review")}finally{F(!1)}}},[f,i,ne,g]),It=s.useCallback(()=>{window.setTimeout(()=>Nn.current?.focus(),0)},[]),Bn=s.useCallback(()=>{pe(f?.title||""),Te(!1),It()},[f,It]),Ns=s.useCallback(async()=>{if(!f||g)return;const t=Ee.trim();F(!0),B(null);try{const r=await U(`/api/taskforce/document-reviews/sessions/${encodeURIComponent(f.id)}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:t||null})},i),o=await r.json().catch(()=>({}));if(!r.ok)throw new Error(o.error||`Failed to update review (${r.status})`);const u=o.session||null;if(!u)throw new Error("Review session payload missing.");ne(),M(m=>m.map(v=>v.id===u.id?u:v)),Te(!1),It()}catch(r){B(r?.message||"Failed to update review")}finally{F(!1)}},[f,i,ne,It,g,Ee]),Ln=y?G:N??"",Fn=s.useCallback(()=>{if(y||!P)return;const t=typeof window.getSelection=="function"?window.getSelection():null,r=t?.toString().replace(/\s+/g," ").trim()||"";if(!t||!r)return;const o=t.rangeCount>0?t.getRangeAt(0):null,u=Qe.current;if(!o||!u)return;const m=o.commonAncestorContainer,v=m.nodeType===Node.TEXT_NODE?m.parentNode:m;if(!(v instanceof Node)||!u.contains(v))return;const C=Pi(u,o,r);C&&_(C)},[y,_,P]),Pn=s.useCallback(()=>{pt(t=>{const r=!t;return r||_(null),r})},[_]),zn=s.useCallback(async()=>{const t=Re.trim();if(!t||g)return;let r=f;if(r||(r=await en()),!!r){F(!0),B(null);try{const o=await U(`/api/taskforce/document-reviews/sessions/${encodeURIComponent(r.id)}/comments`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:t,anchor:_e||{kind:"document"}})},i),u=await o.json().catch(()=>({}));if(!o.ok)throw new Error(u.error||`Failed to add comment (${o.status})`);const m=u.session||null;if(!m)throw new Error("Review session payload missing.");ne(),Ge.current=!0,ce(!1),M(v=>{const C=v.filter(se=>se.id!==m.id);return[m,...C]}),$e(m.id),ge(v=>{const C={...v};return delete C[We],delete C[m.id],C})}catch(o){B(o?.message||"Failed to add comment")}finally{F(!1)}}},[f,i,en,_e,g,Re,We,ne,$e]),Ts=s.useCallback((t,r)=>{ve(t),ke(r)},[]),Es=s.useCallback(async()=>{if(!f||!de||g)return;const t=Ae.trim();if(t){F(!0),B(null);try{const r=await U(`/api/taskforce/document-reviews/sessions/${encodeURIComponent(f.id)}/comments/${encodeURIComponent(de)}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:t})},i),o=await r.json().catch(()=>({}));if(!r.ok)throw new Error(o.error||`Failed to update comment (${r.status})`);const u=o.session||null;if(!u)throw new Error("Review session payload missing.");ne(),M(m=>m.map(v=>v.id===u.id?u:v)),ve(null),ke("")}catch(r){B(r?.message||"Failed to update comment")}finally{F(!1)}}},[f,i,Ae,de,ne,g]),As=s.useCallback(async t=>{if(!f||g)return;const o=(f.comments.find(v=>v.id===t)||null)?.parentCommentId?0:f.comments.filter(v=>v.parentCommentId===t).length,u=o>0,m=u?`Delete this thread and its ${o} ${o===1?"reply":"replies"}? This cannot be undone.`:"Delete this review comment?";if(window.confirm(m)){F(!0),B(null);try{const v=await U(`/api/taskforce/document-reviews/sessions/${encodeURIComponent(f.id)}/comments/${encodeURIComponent(t)}${u?"?cascade=true":""}`,{method:"DELETE",credentials:"include"},i),C=await v.json().catch(()=>({}));if(!v.ok)throw new Error(C.error||`Failed to delete comment (${v.status})`);const se=C.session||null;if(!se)throw new Error("Review session payload missing.");ne(),M(he=>he.map(je=>je.id===se.id?se:je)),de===t&&(ve(null),ke(""))}catch(v){B(v?.message||"Failed to delete comment")}finally{F(!1)}}},[f,i,de,ne,g]),On=s.useCallback(async t=>{if(!f||g||ae!==t)return;const r=Le.trim();if(r){F(!0),B(null);try{const o=await U(`/api/taskforce/document-reviews/sessions/${encodeURIComponent(f.id)}/comments/${encodeURIComponent(t)}/replies`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:r})},i),u=await o.json().catch(()=>({}));if(!o.ok)throw new Error(u.error||`Failed to add reply (${o.status})`);const m=u.session||null;if(!m)throw new Error("Review session payload missing.");ne(),Ge.current=!0,ce(!1),M(v=>v.map(C=>C.id===m.id?m:C)),jt()}catch(o){B(o?.message||"Failed to add reply")}finally{F(!1)}}},[f,i,jt,ne,ae,Le,g]),Hn=s.useCallback(async(t,r)=>{if(!(!f||g)){F(!0),B(null);try{const o=await U(`/api/taskforce/document-reviews/sessions/${encodeURIComponent(f.id)}/comments/${encodeURIComponent(t)}/thread-status`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:r})},i),u=await o.json().catch(()=>({}));if(!o.ok)throw new Error(u.error||`Failed to update thread (${o.status})`);const m=u.session||null;if(!m)throw new Error("Review session payload missing.");ne(),M(v=>v.map(C=>C.id===m.id?m:C)),ye(null),Se("")}catch(o){B(o?.message||"Failed to update thread")}finally{F(!1)}}},[f,i,ne,g]),Wn=(t,r=!1)=>{const o=t.authorActor?.kind==="ai",u=as(t.anchor),m=Bi(t.anchor,N,X),v=o?dr:ur,C=de===t.id,se=t.permissions?.canEdit===!0,he=t.permissions?.canDelete===!0,je=t.permissions?.canReply===!0,Ye=t.permissions?.canResolve===!0,rn=t.permissions?.canReopen===!0,Dt=Date.parse(t.createdAt),$t=Date.parse(t.updatedAt),xe=Number.isFinite(Dt)&&Number.isFinite($t)&&$t>Dt;return e.jsxs("article",{"data-review-comment-id":t.id,"data-conversation-role":o?"assistant":"user",style:t.authorActor?.color?{"--review-accent":t.authorActor.color}:void 0,className:`${a.reviewComment} ${r?a.reviewReply:""}`,children:[e.jsxs("div",{className:a.reviewCommentHeader,children:[e.jsx("span",{className:a.reviewCommentAvatar,style:t.authorActor?.color?{color:t.authorActor.color}:void 0,"aria-hidden":"true",children:e.jsx(v,{size:13,strokeWidth:1.7})}),e.jsx("span",{className:a.reviewCommentAuthor,children:Mi(t)}),e.jsxs("time",{className:a.reviewCommentTime,dateTime:t.updatedAt,title:xe?`Edited ${mt(t.updatedAt)}; originally posted ${mt(t.createdAt)}`:mt(t.createdAt),children:[xe?"Edited · ":"",rs(t.updatedAt)]}),(!r&&t.threadStatus==="resolved"||se||he||C)&&e.jsxs("span",{className:a.reviewCommentHeaderControls,children:[!r&&t.threadStatus==="resolved"&&e.jsx("span",{className:"tf-chip-success",children:"Resolved"}),(se||he||C)&&e.jsxs("span",{className:a.reviewCommentActions,children:[!C&&se&&e.jsx("button",{type:"button",className:`tf-control-icon ${a.reviewCommentAction}`,onClick:()=>Ts(t.id,t.body),disabled:g,"aria-label":"Edit comment",title:"Edit comment",children:e.jsx(ut,{size:13})}),C&&e.jsx("button",{type:"button",className:"tf-button-ghost tf-button-compact",onClick:()=>{ve(null),ke("")},disabled:g,children:"Cancel"}),he&&e.jsx("button",{type:"button",className:`tf-control-icon ${a.reviewCommentAction} ${a.reviewCommentDeleteAction}`,onClick:()=>{As(t.id)},disabled:g,"aria-label":"Delete comment",title:"Delete comment",children:e.jsx(ns,{size:13})})]})]})]}),u&&e.jsxs("span",{className:a.reviewAnchorRow,children:[e.jsx("span",{className:a.reviewAnchorLabel,title:t.anchor?.kind==="quote"?t.anchor.quote:void 0,children:u}),m!=="valid"&&e.jsx("span",{className:m==="moved"?a.reviewAnchorMoved:m==="unresolved"?a.reviewAnchorUnresolved:a.reviewAnchorUnknown,title:m==="moved"?"The quoted text still exists, but its saved location or context changed.":m==="unresolved"?"This anchor no longer resolves in the saved document.":"There is not enough saved context to verify this anchor.",children:m==="moved"?"Moved":m==="unresolved"?"Unresolved":"Unknown"})]}),e.jsx("div",{className:a.reviewCommentBody,children:C?e.jsxs("div",{className:a.reviewCommentEditor,children:[e.jsx("textarea",{className:`tf-field-shell ${a.reviewCommentEditInput}`,value:Ae,onChange:Mt=>ke(Mt.target.value),disabled:g,"aria-label":"Edit comment text"}),e.jsx("button",{type:"button",className:"tf-button-primary tf-button-compact",onClick:()=>{Es()},disabled:g||!Ae.trim(),children:"Save comment"})]}):e.jsx(Lt,{variant:"conversation",taskReferences:k,children:t.body})}),!r&&e.jsxs("div",{className:a.reviewThreadActions,children:[je&&e.jsxs("button",{ref:Mt=>{Mt?Jt.current.set(t.id,Mt):Jt.current.delete(t.id)},type:"button",className:"tf-button-ghost tf-button-compact",onClick:()=>{qe.current=t.id,ye(t.id),Se("")},disabled:g,children:[e.jsx(mr,{size:13}),"Reply"]}),Ye&&e.jsxs("button",{type:"button",className:"tf-button-ghost tf-button-compact",onClick:()=>{Hn(t.id,"resolved")},disabled:g,children:[e.jsx(ht,{size:13}),"Resolve"]}),rn&&e.jsxs("button",{type:"button",className:"tf-button-ghost tf-button-compact",onClick:()=>{Hn(t.id,"open")},disabled:g,children:[e.jsx(dn,{size:13}),"Reopen"]})]})]},t.id)},Vn=s.useCallback(async t=>{if(!Ue)return!1;Z({type:"saving"});try{const r=await U(Xe("/api/taskforce/documents/save",d),{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({fsPath:n.fsPath,content:t})},i),o=await r.json().catch(()=>({}));if(!r.ok)throw new Error(o.error||`Save failed (${r.status})`);const u=o.updatedAt||new Date().toISOString();return H(t),Ie(t),Z({type:"saved",savedAt:u}),c?.(u),!0}catch(r){return Z({type:"error",message:r?.message||"Save failed"}),!1}},[i,n.fsPath,c,Ue,d]),Is=s.useCallback((t,r)=>{const o=y?G:N??"",u=zi(o,t,r);if(u!==o){if(y){Ie(u),Z(m=>m.type==="saving"?m:{type:"idle"});return}Vn(u)}},[N,G,y,Vn]);let Un=-1;const sn=t=>!t||!Array.isArray(t.children)?!1:t.children.some(r=>r?r.type==="element"&&r.tagName==="input"&&r.properties?.type==="checkbox"?!0:sn(r):!1),Kn=t=>!t||!Array.isArray(t.children)?!1:t.children.some(r=>typeof r?.checked=="boolean"?!0:sn(r)),qn={input({type:t,checked:r,node:o,...u}){if(t!=="checkbox")return e.jsx("input",{type:t,checked:r,...u});Un+=1;const m=Un;return e.jsx("input",{...u,type:"checkbox",checked:!!r,disabled:!1,onClick:v=>v.stopPropagation(),onChange:v=>Is(m,v.currentTarget.checked)})},ul({children:t,node:r,...o}){const u=Kn(r);return e.jsx("ul",{...o,"data-task-list":u?"true":void 0,children:t})},ol({children:t,node:r,...o}){const u=Kn(r);return e.jsx("ol",{...o,"data-task-list":u?"true":void 0,children:t})},li({children:t,node:r,...o}){const u=typeof r?.checked=="boolean"||sn(r);return e.jsx("li",{...o,"data-task-item":u?"true":void 0,children:t})}};return e.jsxs("div",{className:`${a.viewer} ${y?a.viewerEditMode:""} ${gn?a.viewerMonochrome:""}`,children:[e.jsxs("div",{className:a.meta,children:[e.jsxs("div",{className:a.metaLeft,children:[e.jsxs("span",{className:`${a.typeBadge} ${Si[n.docType]??""}`,children:[e.jsx(Zs,{size:10}),ki[n.docType]]}),gt?e.jsx("div",{className:a.metaRenameRow,children:e.jsx("input",{ref:Kt,type:"text",className:me.input,value:Vt,onChange:t=>Ve(t.target.value),onBlur:()=>{nn()},onKeyDown:Cs})}):e.jsx("span",{className:a.metaDocumentName,title:$,onDoubleClick:()=>{n.assetId&&(Ve($),Fe(!0))},children:$}),l&&e.jsx("span",{className:a.metaTaskName,title:`From task: ${l}`,children:l}),ot==="unattached"&&e.jsx("span",{className:a.statusBadge,children:"Unattached"}),n.updatedAt&&e.jsxs("span",{className:a.metaDate,title:mt(n.updatedAt),children:[e.jsx(er,{size:11}),mt(n.updatedAt)]}),e.jsxs("span",{className:a.metaSize,children:[e.jsx(tr,{size:11}),Ei(n.sizeBytes)]}),z&&e.jsx(Ls,{label:z,copied:w,onClick:()=>{_s()},title:$}),De.type==="saved"&&e.jsxs("span",{className:`${a.saveStatus} ${a.saveStatusSaved}`,children:[e.jsx(ht,{size:11}),"Saved"]}),De.type==="error"&&e.jsxs("span",{className:`${a.saveStatus} ${a.saveStatusError}`,title:De.message,children:[e.jsx(Ft,{size:11}),De.message||"Save failed"]}),_t&&De.type!=="saving"&&e.jsx("span",{className:a.unsaved,children:"Unsaved changes"})]}),e.jsx("div",{className:a.actions,children:y?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:a.layoutToggle,children:[e.jsx("button",{className:`${a.layoutBtn} ${te==="editor"?a.layoutBtnActive:""}`,onClick:()=>zt("editor"),title:"Editor only",children:e.jsx(ut,{size:12})}),e.jsx("button",{className:`${a.layoutBtn} ${te==="split"?a.layoutBtnActive:""}`,onClick:()=>zt("split"),title:"Split view",children:e.jsx(nr,{size:12})}),e.jsx("button",{className:`${a.layoutBtn} ${te==="preview"?a.layoutBtnActive:""}`,onClick:()=>zt("preview"),title:"Preview only",children:e.jsx(un,{size:12})})]}),e.jsxs("button",{ref:Gt,className:a.actionBtn,onClick:Pn,title:P?"Hide review and comments":"Show review and comments",children:[e.jsx(Bt,{size:13}),P?"Hide Review":"Show Review"]}),e.jsxs("button",{className:a.actionBtn,onClick:gs,title:"Discard changes",children:[e.jsx(hn,{size:13}),"Cancel"]}),e.jsxs("button",{className:`${a.actionBtn} ${a.saveBtn}`,onClick:Mn,disabled:De.type==="saving"||!_t||rt,title:"Save (Ctrl+S)",children:[e.jsx(sr,{size:13}),De.type==="saving"?"Saving…":"Save"]})]}):e.jsxs(e.Fragment,{children:[n.taskId&&b&&e.jsxs("button",{className:a.actionBtn,onClick:()=>b(n.taskId),title:"Back to task","aria-label":"Back to task",children:[e.jsx(rr,{size:13}),"Back to task"]}),n.assetId&&e.jsxs("button",{className:a.actionBtn,onClick:()=>Fe(t=>!t),title:"Rename document",children:[e.jsx(ut,{size:13}),gt?"Close Rename":"Rename"]}),Ue&&e.jsxs("button",{className:`${a.actionBtn} ${a.editBtn}`,onClick:ws,title:"Edit document",children:[e.jsx(ut,{size:13}),"Edit"]}),n.assetId&&e.jsxs("button",{className:a.actionBtn,onClick:Ss,title:"Attach document to a task",children:[e.jsx(ts,{size:13}),"Attach"]}),e.jsxs("button",{ref:Gt,className:a.actionBtn,onClick:Pn,title:P?"Hide review and comments":"Show review and comments",children:[e.jsx(Bt,{size:13}),P?"Hide Review":"Show Review"]}),e.jsxs("button",{className:a.actionBtn,onClick:bs,title:"Copy link",children:[e.jsx(ts,{size:13}),Ne?"Copied!":"Copy link"]}),e.jsxs("button",{className:a.actionBtn,onClick:xs,title:"Download .md",children:[e.jsx(ar,{size:13}),"Download"]}),e.jsxs("button",{className:a.actionBtn,onClick:ys,title:"Print document. In the print dialog, disable headers and footers for the cleanest output.",children:[e.jsx(or,{size:13}),"Print"]}),e.jsxs("button",{className:a.actionBtn,onClick:()=>us(t=>!t),title:"Toggle black and white style",children:[e.jsx(un,{size:13}),gn?"Color":"B/W"]}),S&&n.docType==="implementation-plan"&&!y&&e.jsxs("button",{className:`${a.actionBtn} ${a.generateBtn}`,onClick:()=>Ot(!0),title:"Generate tasks from this plan",children:[e.jsx(mn,{size:13}),"Generate Tasks"]}),hs&&e.jsxs("button",{className:`${a.actionBtn} ${a.dangerBtn}`,onClick:()=>{ks()},disabled:wt,title:ot==="attached"?"Remove this document from linked tasks and delete it":"Permanently delete this unattached document",children:[e.jsx(ns,{size:13}),wt?"Deleting…":ot==="attached"?"Delete & Unlink":"Delete Permanently"]})]})})]}),O&&e.jsx("div",{className:a.viewerState,children:"Loading…"}),!O&&K&&e.jsx("div",{className:a.viewerStateError,children:K}),!O&&!K&&e.jsxs("div",{className:`${a.viewerBody} ${P?"":a.viewerBodyFullWidth}`,children:[y?e.jsxs("div",{className:`${a.editorArea} ${a.viewerMain} ${Ri[te]}`,children:[(te==="editor"||te==="split")&&e.jsxs("div",{className:a.editorPane,children:[e.jsx("div",{className:a.editorPaneLabel,children:"Markdown"}),e.jsx("textarea",{ref:Ut,className:`${a.editorTextarea} tf-scrollbar`,value:G,onScroll:()=>At("editor"),onChange:t=>{Ie(t.target.value),Z(r=>r.type==="saving"?r:{type:"idle"})},spellCheck:!0,placeholder:"Write markdown here…"})]}),(te==="preview"||te==="split")&&e.jsxs("div",{className:a.previewPane,children:[e.jsx("div",{className:a.editorPaneLabel,children:"Preview"}),e.jsx("div",{ref:Cn,className:`${me.docMarkdown} ${a.markdownSurface}`,"data-testid":"doc-preview-scroll",onScroll:()=>At("preview"),children:e.jsx(Lt,{variant:"document",taskReferences:k,documentOverrides:qn,children:Ln})})]})]}):e.jsx("div",{ref:qt,className:`${a.viewerContent} ${a.viewerMain} tf-scrollbar`,"data-testid":"doc-viewer-scroll",onScroll:t=>vs(t.currentTarget.scrollTop),children:e.jsx("div",{ref:Qe,className:`${me.docMarkdown} ${a.markdownSurface} ${a.readerSurface}`,"data-testid":"doc-reader-surface",onMouseUp:P?Fn:void 0,onKeyUp:P?Fn:void 0,children:e.jsx(Lt,{variant:"document",taskReferences:k,documentOverrides:qn,children:Ln})})}),P&&e.jsx("aside",{ref:Rn,className:a.reviewRail,role:oe?"dialog":void 0,"aria-modal":oe?!0:void 0,"aria-label":oe?"Review and comments":void 0,children:e.jsxs("section",{className:a.reviewSection,"aria-label":"Review and comments",children:[e.jsxs("div",{className:a.reviewHeader,children:[e.jsxs("div",{className:a.reviewHeaderTop,children:[e.jsx("span",{className:a.reviewEyebrow,children:"Review"}),e.jsxs("div",{className:a.reviewHeaderActions,children:[f&&e.jsx("span",{className:f.status==="resolved"?"tf-chip-success":"tf-chip-warning",role:"status","aria-live":"polite",children:f.status==="resolved"?"Resolved":"Open"}),e.jsx("button",{ref:jn,type:"button",className:`tf-control-icon ${a.reviewCloseButton}`,onClick:Yt,"aria-label":"Close review",title:"Close review",children:e.jsx(hn,{size:15})})]})]}),f?e.jsxs(e.Fragment,{children:[st?e.jsxs("div",{className:a.reviewTitleEditRow,children:[e.jsx("input",{type:"text",className:`tf-field-shell ${a.reviewTitleInput}`,value:Ee,onChange:t=>pe(t.target.value),onKeyDown:t=>{t.key==="Escape"&&(t.preventDefault(),t.stopPropagation(),Bn())},placeholder:"Untitled review","aria-label":"Review title",autoFocus:!0}),e.jsx("button",{type:"button",className:"tf-button-primary tf-button-compact",onClick:()=>{Ns()},disabled:g,children:"Save"}),e.jsx("button",{type:"button",className:"tf-button-ghost tf-button-compact",onClick:Bn,disabled:g,children:"Cancel"})]}):e.jsx("h2",{className:a.reviewSessionTitle,children:f.title?.trim()||"Untitled review"}),e.jsxs("div",{className:a.reviewMetadataRow,children:[e.jsxs("div",{className:a.reviewMetadata,children:[e.jsxs("div",{className:a.reviewSessionDetails,children:[e.jsxs("span",{children:[In," ",In===1?"thread":"threads",f.status==="open"&&ze>0?` · ${ze} open`:""]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{children:["Updated ",rs(f.updatedAt)]})]}),(f.documentVersion||x)&&e.jsxs("div",{className:a.reviewVersionDetails,children:[e.jsxs("span",{children:["Review ",f.documentVersion?`v${f.documentVersion}`:"version unknown"]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{children:["Document ",x?`v${x}`:"version unknown"]})]})]}),e.jsx("button",{ref:Nn,type:"button",className:"tf-control-icon tf-control-icon-compact",onClick:()=>Te(!0),disabled:g,"aria-label":"Rename review",title:"Rename review",children:e.jsx(ut,{size:13})})]}),y&&e.jsx("div",{className:a.reviewDraftNotice,role:"status",children:_t?"Comments reference the saved document. Unsaved edits are not part of this review.":"Comments reference the saved document while you edit."}),!y&&f.documentVersion&&x&&f.documentVersion!==x&&e.jsxs("div",{className:a.reviewVersionNotice,role:"status",children:[e.jsx(Ft,{size:13,"aria-hidden":"true"}),e.jsxs("span",{children:["Review covers document v",f.documentVersion,"; current document is v",x,"."]})]})]}):e.jsxs("div",{children:[e.jsx("h2",{className:a.reviewEmptyHeading,children:"No active review"}),e.jsx("p",{className:a.reviewSubtitle,children:"Start a review to collect feedback on this document."})]}),e.jsxs("div",{className:a.reviewControls,role:"group","aria-label":"Review controls",children:[e.jsxs("select",{className:`tf-field-shell ${a.reviewSelect}`,value:f?.id||"",onChange:t=>$e(t.target.value||null),disabled:g||A.length===0,"aria-label":"Select review session",children:[A.length===0&&e.jsx("option",{value:"",children:"No review"}),A.map(t=>e.jsx("option",{value:t.id,children:t.title?.trim()||"Untitled review"},t.id))]}),e.jsx("button",{type:"button",className:`tf-control-icon ${a.reviewCreateButton}`,onClick:()=>{en()},disabled:g||!n.assetId,"aria-label":"New review",title:"New Review",children:e.jsx(ir,{size:15})}),f&&e.jsxs("button",{type:"button",className:`tf-button-secondary tf-button-compact ${a.reviewResolutionAction}`,onClick:()=>{Rt||js()},disabled:g,"aria-disabled":Rt||void 0,"aria-label":Rt?`Resolve review unavailable: resolve ${ze} open thread${ze===1?"":"s"} first`:f.status==="resolved"?"Reopen review":"Resolve review",title:Rt?`Resolve ${ze} open thread${ze===1?"":"s"} first`:f.status==="resolved"?"Reopen review":"Resolve review",children:[f.status==="resolved"?e.jsx(dn,{size:13}):e.jsx(ht,{size:13}),f.status==="resolved"?"Reopen":"Resolve"]})]})]}),fe&&e.jsx("div",{className:a.viewerStateError,children:fe}),e.jsxs("div",{className:a.reviewWorkspace,children:[e.jsxs("div",{ref:Sn,className:`${a.reviewThread} tf-scrollbar`,"data-testid":"review-thread",onScroll:ps,children:[q&&e.jsx("div",{className:a.reviewEmptyState,children:"Loading review comments…"}),!q&&!f&&e.jsxs("div",{className:a.reviewEmptyState,children:[e.jsx(Bt,{size:20}),e.jsx("span",{children:"Start a review to collect comments for this document."})]}),!q&&f&&f.comments.length===0&&e.jsxs("div",{className:a.reviewEmptyState,children:[e.jsx(Bt,{size:20}),e.jsx("span",{children:"No comments yet. Add the first review note."})]}),!q&&f&&f.comments.filter(t=>!t.parentCommentId).map(t=>{const r=f.comments.filter(o=>o.parentCommentId===t.id);return e.jsxs("section",{className:a.reviewCommentThread,children:[Wn(t),r.length>0&&e.jsx("div",{className:a.reviewReplies,children:r.map(o=>Wn(o,!0))}),ae===t.id&&e.jsxs("div",{className:a.reviewReplyComposer,onKeyDown:o=>{o.key==="Escape"&&(o.preventDefault(),o.stopPropagation(),jt())},children:[e.jsx("textarea",{ref:Tn,className:`tf-field-shell ${a.reviewReplyInput}`,value:Le,onChange:o=>Se(o.target.value),placeholder:"Write a reply…",disabled:g,"aria-label":"Reply text",onKeyDown:o=>{o.key==="Enter"&&!o.shiftKey&&(o.preventDefault(),On(t.id))}}),e.jsxs("div",{className:a.reviewReplyComposerActions,children:[e.jsx("button",{type:"button",className:"tf-button-ghost tf-button-compact",onClick:jt,disabled:g,children:"Cancel"}),e.jsx("button",{type:"button",className:"tf-button-primary tf-button-compact",onClick:()=>{On(t.id)},disabled:g||!Le.trim(),children:"Reply"})]})]})]},t.id)}),e.jsx("div",{ref:kn})]}),Be&&f&&e.jsx("div",{className:a.reviewNewCommentsBar,"aria-live":"polite",children:e.jsxs("button",{type:"button",className:"tf-button-secondary tf-button-compact",onClick:()=>Xt(),children:[e.jsx(lr,{size:13}),"New comments"]})}),f?.status==="resolved"?e.jsxs("div",{className:a.reviewResolvedComposer,children:[e.jsx("span",{className:a.reviewResolvedIcon,"aria-hidden":"true",children:e.jsx(ht,{size:16})}),e.jsxs("div",{className:a.reviewResolvedCopy,children:[e.jsx("strong",{children:"Review resolved"}),e.jsx("span",{children:"Reopen it to add more comments."})]})]}):e.jsxs("div",{className:a.reviewComposerArea,children:[_e&&e.jsxs("div",{className:a.reviewAnchorChip,children:[e.jsx("span",{children:_e.kind==="quote"?"Selected text":as(_e)||"Selected text"}),"quote"in _e&&_e.quote&&e.jsxs("span",{className:a.reviewAnchorSnippet,children:['"',_e.quote,'"']}),e.jsx("button",{type:"button",className:a.reviewAnchorClear,onClick:()=>_(null),"aria-label":"Clear selected text",children:"Clear"})]}),e.jsxs("div",{className:a.reviewComposerRow,children:[e.jsx("textarea",{className:`tf-field-shell ${a.reviewComposerInput}`,placeholder:_e?"Add a comment for the selected text…":"Add a comment for this document review…",value:Re,onChange:t=>Pt(t.target.value),disabled:g,onKeyDown:t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),zn())}}),e.jsx("button",{type:"button",className:`tf-button-primary ${a.reviewSendButton}`,onClick:()=>{zn()},disabled:g||!Re.trim(),"aria-label":"Send review comment",title:"Send review comment",children:e.jsx(cr,{size:15})})]}),e.jsx("span",{className:a.reviewComposerHint,children:"Enter to send · Shift + Enter for a new line"})]})]})]})})]}),S&&ds&&N!==null&&e.jsx(Ci,{content:N,docTitle:n.title,apiBaseUrl:i,onClose:()=>Ot(!1),onGenerated:t=>Ot(!1)}),e.jsx(Fs,{isOpen:ms,onClose:()=>{Ht||yt(!1)},title:"Attach document",size:"md",footer:e.jsx("button",{className:a.actionBtn,onClick:()=>yt(!1),disabled:!!Ht,children:"Close"}),children:e.jsxs("div",{className:a.attachModalBody,children:[e.jsx("p",{className:a.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:me.input,placeholder:"Search tasks…",value:bn,onChange:t=>_n(t.target.value)}),xn&&e.jsxs("div",{className:a.attachModalError,children:[e.jsx(Ft,{size:14}),e.jsx("span",{children:xn})]}),e.jsx("div",{className:`${a.attachTaskList} tf-scrollbar`,children:Dn.length===0?e.jsx("div",{className:a.attachEmptyState,children:h.length===0?"No tasks are available in this workspace.":"No tasks match your search."}):Dn.map(t=>{const r=n.taskId===t.id,o=Ht===t.id;return e.jsxs("button",{type:"button",className:a.attachTaskRow,disabled:o,onClick:()=>{Rs(t.id)},children:[e.jsxs("span",{className:a.attachTaskInfo,children:[e.jsx("span",{className:a.attachTaskTitle,children:t.title}),t.referenceLabel&&e.jsx("span",{className:a.attachTaskReference,children:t.referenceLabel})]}),e.jsx("span",{className:a.attachTaskMeta,children:o?"Attaching…":r?"Attached":"Attach"})]},t.id)})})]})})]})}function os(n){return typeof n=="string"?n.trim().replace(/\/+$/,""):""}function Hi(n){return n.runtimeMode==="local"?"":os(n.apiBaseUrl)||os(n.cloudAuthBaseUrl)||""}function Wi({runtimeMode:n="local",workspaceId:l=null,apiBaseUrl:h="",cloudAuthBaseUrl:i="",typeFilters:d,attachmentFilters:c,onTypeFiltersChange:p,onAttachmentFiltersChange:b,sortField:k,sortOrder:S,onSortFieldChange:I,onSortOrderChange:T,pinnedDocIds:j,onPinnedDocIdsChange:J,selectedDocId:Q,onSelectedDocIdChange:$,searchQuery:ie,onSearchQueryChange:z,requestedDocPath:N=null,requestedDocAssetId:H=null,onRequestedDocHandled:Y,selectionReady:X=!0}){const[L,x]=s.useState([]),[R,O]=s.useState(!0),[W,K]=s.useState(null),[le,Ne]=s.useState(null),[we,w]=s.useState(""),[re,A]=s.useState("updated"),[M,q]=s.useState("desc"),[Ce,fe]=s.useState([]),[B,Me]=s.useState(()=>et.map(_=>_.value)),[nt,He]=s.useState(()=>tt.map(_=>_.value)),ge=Hi({runtimeMode:n,apiBaseUrl:h,cloudAuthBaseUrl:i}),g=String(l||"").trim(),F=Xe("/api/taskforce/documents",l),Be=d??B,ce=c??nt,st=p??Me,Te=b??He,Ee=k??re,pe=S??M,de=Q!==void 0?Q:le,ve=ie!==void 0?ie:we,Ae=I??A,ke=T??q,ae=j??Ce,ye=J??fe,Le=s.useRef(ae),Se=s.useRef(ye);Le.current=ae,Se.current=ye;const P=$??Ne,pt=z??w,oe=s.useCallback(async()=>{O(!0),K(null);try{const _=await U(F,{credentials:"include"},ge);if(!_.ok)throw new Error(`Failed to load documents (${_.status})`);const y=await _.json(),V=Array.isArray(y.documents)?y.documents:[];V.length,x(V);const ee=new Set(V.map(te=>te.assetId)),G=Le.current,Ie=G.filter(te=>ee.has(te));Ie.length!==G.length&&Se.current(Ie)}catch(_){K(_?.message||"Failed to load documents"),_?.message}finally{O(!1)}},[ge,F,n]);s.useEffect(()=>{oe()},[oe]),s.useEffect(()=>{if(typeof window>"u")return;const _=y=>{const V=y.detail||{},ee=String(V.workspaceId||"").trim();g&&ee&&ee!==g||oe()};return window.addEventListener(Xn,_),()=>{window.removeEventListener(Xn,_)}},[oe,g]),s.useEffect(()=>{if(typeof window>"u")return;const _=y=>{const V=y.detail,ee=String(V?.workspaceId||"").trim();g&&ee&&ee!==g||oe()};return window.addEventListener(Zn,_),()=>{window.removeEventListener(Zn,_)}},[oe,g]);const vt=s.useMemo(()=>zr(L,ve,Be,ce),[ce,L,ve,Be]),be=s.useMemo(()=>{const _=zs(vt,Ee,pe),y=new Set(ae);return[..._.filter(V=>y.has(V.assetId)),..._.filter(V=>!y.has(V.assetId))]},[vt,ae,Ee,pe]),We=s.useCallback(_=>{ye(ae.includes(_)?ae.filter(y=>y!==_):[...ae,_].slice(-50))},[ye,ae]),Re=s.useMemo(()=>de?L.find(_=>_.assetId===de)??null:null,[L,de]);s.useEffect(()=>{if(!N&&!H||L.length===0)return;const _=N?fn(N):"",y=String(H||"").trim().toLowerCase()||ss(N),V=L.find(ee=>{const G=String(ee.assetId||"").trim().toLowerCase()||ss(ee.fsPath);return y&&G&&G===y?!0:_?Pr(fn(ee.fsPath),_):!1});V&&(P(V.assetId),Y?.())},[L,P,Y,H,N]),s.useEffect(()=>{if(!(R||W)&&!((N||H)&&!Re)&&X){if(be.length===0){de!==null&&P(null);return}Re&&be.some(_=>_.assetId===Re.assetId)||P(be[0].assetId)}},[W,be,P,R,H,N,Re,de,X]);const _e=s.useCallback(async()=>{P(null),await oe()},[oe,P]),Pt=ve.trim().length>0||Be.length!==et.length||ce.length!==tt.length;return{documentApiBaseUrl:ge,documents:L,filteredDocs:be,loading:R,error:W,selectedDoc:Re,searchQuery:ve,typeFilters:Be,attachmentFilters:ce,hasActiveFilters:Pt,sortField:Ee,sortOrder:pe,setSortField:Ae,setSortOrder:ke,setSearchQuery:pt,pinnedDocIds:ae,togglePinnedDoc:We,handleTypeFiltersChange:st,handleAttachmentFiltersChange:Te,fetchDocuments:oe,selectDoc:_=>P(_?.assetId??null),handleDeleteSelected:_e}}const Vi=et.map(n=>n.value),Ui=tt.map(n=>n.value);function Ki({tasks:n,apiBaseUrl:l="",workspaceId:h=null,documents:i,loading:d,error:c,selectedDoc:p,searchQuery:b,hasActiveFilters:k,documentTrayOpen:S,sortField:I,sortOrder:T,pinnedDocIds:j=[],onTogglePinnedDoc:J,onSearchChange:Q,onSelectDoc:$,onRefresh:ie,onCloseDocumentTray:z,onDeleteSelected:N,onSortFieldChange:H,onSortOrderChange:Y,typeFilters:X=Vi,attachmentFilters:L=Ui,onTypeFiltersChange:x=()=>{},onAttachmentFiltersChange:R=()=>{},onBackToTask:O,taskReferences:W,enableTaskGeneration:K=!1,documentScrollByDocId:le,onDocumentScrollChange:Ne,documentListScrollTop:we,onDocumentListScrollChange:w}){const re=new Map(n.map(q=>[q.id,q])),A=typeof S=="boolean",M=e.jsx(Kr,{documents:i,selectedDocId:p?.assetId??null,loading:d,error:c,searchQuery:b,sortField:I,sortOrder:T,pinnedDocIds:j,onTogglePinnedDoc:J,onSearchChange:Q,onSelect:q=>$(q),onCloseTray:A?z:void 0,onSortFieldChange:H,onSortOrderChange:Y,typeFilters:X,attachmentFilters:L,onTypeFiltersChange:x,onAttachmentFiltersChange:R,taskById:re,hasActiveFilters:k,listScrollTop:we,onListScrollChange:w});return e.jsxs("div",{className:`${me.docWorkspace} ${A?me.docWorkspaceTrayMode:""} ${A&&S?me.docWorkspaceTrayOpen:""}`.trim(),children:[A?e.jsx("div",{className:`${me.docTrayPanel} ${S?me.docTrayPanelOpen:""}`.trim(),"aria-hidden":!S,children:M}):e.jsx("div",{className:me.docIndexPanel,children:M}),e.jsx("div",{className:me.docViewerPanel,children:p?e.jsx(Oi,{doc:p,taskTitle:p.taskId?re.get(p.taskId)?.title??null:null,tasks:n,apiBaseUrl:l,workspaceId:h,onSaved:q=>ie(),onDeleted:()=>{N()},onBackToTask:O,taskReferences:W,enableTaskGeneration:K,initialScrollTop:le?.[p.assetId]??0,onScrollTopChange:q=>Ne?.(p.assetId,q)}):!d&&e.jsx("div",{className:me.docViewerEmpty,children:e.jsx("p",{className:"tf-empty-copy",children:i.length===0?"No documents match your current filters.":"Select a document to view it."})})})]})}function el({tasks:n,runtimeMode:l="local",workspaceId:h=null,apiBaseUrl:i="",cloudAuthBaseUrl:d="",typeFilters:c,attachmentFilters:p,onTypeFiltersChange:b,onAttachmentFiltersChange:k,sortField:S,sortOrder:I,onSortFieldChange:T,onSortOrderChange:j,pinnedDocIds:J,onPinnedDocIdsChange:Q,searchQuery:$,onSearchQueryChange:ie,selectedDocId:z,onSelectedDocIdChange:N,selectionReady:H=!0,documentScrollByDocId:Y,onDocumentScrollChange:X,documentListScrollTop:L,onDocumentListScrollChange:x,documentTrayOpen:R,onCloseDocumentTray:O,requestedDocPath:W=null,requestedDocAssetId:K=null,onRequestedDocHandled:le,onBackToTask:Ne,taskReferences:we,enableTaskGeneration:w=!1}){const{documentApiBaseUrl:re,filteredDocs:A,loading:M,error:q,selectedDoc:Ce,searchQuery:fe,typeFilters:B,attachmentFilters:Me,hasActiveFilters:nt,sortField:He,sortOrder:ge,setSortField:g,setSortOrder:F,setSearchQuery:Be,handleTypeFiltersChange:ce,handleAttachmentFiltersChange:st,pinnedDocIds:Te,togglePinnedDoc:Ee,fetchDocuments:pe,selectDoc:de,handleDeleteSelected:ve}=Wi({runtimeMode:l,workspaceId:h,apiBaseUrl:i,cloudAuthBaseUrl:d,typeFilters:c,attachmentFilters:p,onTypeFiltersChange:b,onAttachmentFiltersChange:k,sortField:S,sortOrder:I,onSortFieldChange:T,onSortOrderChange:j,pinnedDocIds:J,onPinnedDocIdsChange:Q,searchQuery:$,onSearchQueryChange:ie,selectedDocId:z,onSelectedDocIdChange:N,selectionReady:H,requestedDocPath:W,requestedDocAssetId:K,onRequestedDocHandled:le}),Ae=ue.useRef(R);return ue.useEffect(()=>{const ke=Ae.current===!0;Ae.current=R,!(R!==!0||ke)&&pe()},[R,pe]),e.jsx(Ki,{tasks:n,apiBaseUrl:re,workspaceId:h,documents:A,loading:M,error:q,selectedDoc:Ce,searchQuery:fe,typeFilters:B,attachmentFilters:Me,hasActiveFilters:nt,documentTrayOpen:R,sortField:He,sortOrder:ge,pinnedDocIds:Te,onTogglePinnedDoc:Ee,onSearchChange:Be,onTypeFiltersChange:ce,onAttachmentFiltersChange:st,onSelectDoc:de,onRefresh:pe,onCloseDocumentTray:O,onDeleteSelected:ve,onSortFieldChange:g,onSortOrderChange:F,onBackToTask:Ne,taskReferences:we,enableTaskGeneration:w,documentScrollByDocId:Y,onDocumentScrollChange:X,documentListScrollTop:L,onDocumentListScrollChange:x})}export{tt as DOCUMENT_ATTACHMENT_FILTER_OPTIONS,et as DOCUMENT_TYPE_FILTER_OPTIONS,Ki as DocumentWorkspace,el as DocumentWorkspaceShell};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{R as x,j as n}from"./vendor-react-CKJs5o3c.js";import{aT as q,aU as z,v as G,aV as J,aW as Q,aX as V}from"./index-BUplSsv_.js";import"./vendor-icons-BkFLXavV.js";import"./vendor-markdown-_lhNCyq-.js";import"./vendor-dnd-CJ-AjP-Y.js";import"./vendor-router-AqJMU8Lz.js";const Y="_thread_1di31_1",Z="_empty_1di31_7",tt="_item_1di31_17",et="_comment_1di31_24",nt="_event_1di31_31",ot="_eventSystem_1di31_39",rt="_header_1di31_43",at="_eventMain_1di31_57",st="_author_1di31_64",it="_time_1di31_79",ct="_commentText_1di31_86",mt="_commentOtherActor_1di31_97",dt="_commentSystem_1di31_112",lt="_commentCurrentActor_1di31_125",ht="_eventText_1di31_140",vt="_eventChanges_1di31_148",ut="_eventChange_1di31_148",e={thread:Y,empty:Z,item:tt,comment:et,event:nt,eventSystem:ot,header:rt,eventMain:at,author:st,time:it,commentText:ct,commentOtherActor:mt,commentSystem:dt,commentCurrentActor:lt,eventText:ht,eventChanges:vt,eventChange:ut};function At({activity:p,comments:j,formatFieldValue:A,resolveActorPresentation:i,currentActorId:_,taskReferences:w,emptyMessage:B="No activity yet.",listClassName:M,emptyClassName:O,listRef:P,endRef:K,onScroll:W,targetEntryId:H,targetEntryRef:b}){const T=x.useMemo(()=>q({activity:p,comments:j}),[p,j]),c=String(_||"").trim().toLowerCase(),m=String(H||"").trim(),g=c!==""&&c!=="anonymous",f=x.useMemo(()=>g?i({actorId:_,actorType:"human",fallbackKind:"member"}):null,[_,g,i]),d=String(f?.label||"").trim(),l=d.toLowerCase(),S=!!(f?.kind==="member"&&d&&l!=="you"&&l!=="user"&&l!=="human"&&l!==c),L=x.useCallback(t=>{const r=String(t.label||"").trim().toLowerCase(),a=r==="you"||r==="user"||r==="human";return t.isCurrentActorHint===!0&&S&&a?d:t.label},[d,S]);return n.jsxs("div",{ref:P,className:[e.thread,M].filter(Boolean).join(" "),onScroll:W,children:[T.length===0?n.jsx("div",{className:[e.empty,O].filter(Boolean).join(" "),children:B}):null,T.map(t=>{const r=!!(m&&(t.id===m||t.type==="comment"&&t.comment.id===m||t.type==="event"&&t.event.id===m));if(t.type==="comment"){const o=i({actorId:t.comment.author,actorType:t.comment.actor?.kind==="ai"?"ai":t.comment.actor?.kind==="human"?"human":null,actorProfile:t.comment.actor||null}),s=o.kind==="agent"?"agent":o.kind==="system"?"system":"member",v=String(t.comment.author||"").trim().toLowerCase(),u=String(t.comment.actor?.id||"").trim().toLowerCase(),$=[v,u].map(X=>String(X||"").trim().toLowerCase()).filter(Boolean),C=g?!!(u&&u!=="user"&&u!=="human"||v&&v!=="user"&&v!=="human")?$.includes(c):o.isCurrentActorHint===!0:s==="member",E=C?L(o):o.label,{ActorIcon:D}=o,y=o.kind==="system"?void 0:o.color,F=y?{"--conversation-accent":y}:void 0;return n.jsxs("div",{ref:r?b:void 0,tabIndex:r?-1:void 0,"data-activity-entry-id":t.id,"data-activity-targeted":r?"true":void 0,"data-conversation-role":s==="agent"?"assistant":s==="system"?"system":"user","data-conversation-side":C?"outgoing":"incoming",style:F,className:[e.item,e.comment,s==="system"?e.commentSystem:"",C?e.commentCurrentActor:e.commentOtherActor].join(" "),children:[n.jsxs("div",{className:e.header,children:[n.jsxs("span",{className:e.author,style:y?{color:y}:void 0,title:o.description,"aria-label":o.description?`${E}. ${o.description}`:void 0,children:[n.jsx(D,{size:12,strokeWidth:1.5}),E]}),n.jsx("time",{className:e.time,dateTime:t.comment.timestamp,children:z(t.comment.timestamp,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})]}),n.jsx("div",{className:e.commentText,children:n.jsx(G,{variant:"conversation",taskReferences:w,children:t.comment.text})})]},t.id)}const a=i({actorId:t.event.actor,actorType:t.event.actorType,actorProfile:t.event.actorProfile||null,fallbackKind:"system"}),R=L(a),{ActorIcon:U}=a,N=a.color,h=Object.entries(t.event.details?.changes||{}),k=J(t.event),I=h.length>1&&k?h.filter(([o])=>o!==k):h.length>1?h:[];return n.jsx("div",{ref:r?b:void 0,tabIndex:r?-1:void 0,"data-activity-entry-id":t.id,"data-activity-targeted":r?"true":void 0,className:[e.item,e.event,a.kind==="system"?e.eventSystem:""].filter(Boolean).join(" "),children:n.jsxs("div",{className:e.eventMain,children:[n.jsxs("span",{className:e.author,style:N?{color:N}:void 0,children:[n.jsx(U,{size:12,strokeWidth:1.5}),R]}),n.jsxs("div",{className:e.eventText,children:[n.jsx("div",{children:Q(t.event,A)}),I.length>0?n.jsx("div",{className:e.eventChanges,children:I.map(([o,s])=>n.jsx("div",{className:e.eventChange,children:V(o,s,A)},o))}):null]}),n.jsx("time",{className:e.time,dateTime:t.event.createdAt,children:z(t.event.createdAt,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})]})},t.id)}),n.jsx("div",{ref:K})]})}export{At as EntityActivityTimeline};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{R as a,j as t}from"./vendor-react-CKJs5o3c.js";import{am as Pe,an as We,ao as De,ap as Fe,aq as ke,ar as le,T as He,as as me,at as ne,au as Y,av as U,aw as q,ax as Be,ay as Me,az as Ue,aA as Ge,aB as Ve,aC as Ke,aD as Ce,aE as Ee,aF as ce,aG as Se,aH as qe,aI as Qe,aJ as Je,aK as Xe,aL as Ye}from"./index-BUplSsv_.js";import{w as re,Z as we,R as oe,aj as Ze,ak as et,S as tt,X as xe,al as it,ah as nt,t as ae,ai as be,V as se,q as at,Y as st,a7 as rt}from"./vendor-icons-BkFLXavV.js";import"./vendor-markdown-_lhNCyq-.js";import"./vendor-dnd-CJ-AjP-Y.js";import"./vendor-router-AqJMU8Lz.js";const ot="_module_3zich_1",lt="_columns_3zich_15",ct="_column_3zich_15",dt="_columnHeader_3zich_36",ut="_columnHeadingGroup_3zich_49",ht="_paneHeading_3zich_56",vt="_responsiveBack_3zich_60",pt="_sectionLabel_3zich_64",ft="_sectionHeadingRow_3zich_68",yt="_headerActions_3zich_81",gt="_portfolioControls_3zich_87",kt="_searchRow_3zich_95",mt="_searchShell_3zich_101",wt="_clearSearch_3zich_139",xt="_controlActive_3zich_160",bt="_filterPanel_3zich_166",jt="_filterField_3zich_177",_t="_filterLabel_3zich_184",Ct="_filterDropdown_3zich_190",Et="_sortTrigger_3zich_204",St="_scrollRegion_3zich_217",It="_selectedEntityContext_3zich_227",Nt="_selectedEntityContextArchived_3zich_237",At="_selectedEntityReferenceRow_3zich_242",Rt="_selectedEntityReferenceIdentity_3zich_257",Ot="_selectedEntityReferenceActions_3zich_264",zt="_workspaceEditor_3zich_278",Tt="_workspaceEditorField_3zich_294",Lt="_workspaceEditorActions_3zich_337",$t="_selectedEntityDescription_3zich_348",Pt="_selectedEntityDescriptionMarkdown_3zich_355",Wt="_selectedEntityOwnerField_3zich_361",Dt="_selectedEntityOwnerDropdown_3zich_373",Ft="_selectedEntityDetailsSection_3zich_377",Ht="_activityTimelineList_3zich_382",Bt="_activityTimelineEmpty_3zich_389",Mt="_visuallyHidden_3zich_393",Ut="_entityCard_3zich_405",Gt="_entityCardTopRow_3zich_426",Vt="_entityCardBody_3zich_433",Kt="_entityCardContentButton_3zich_437",qt="_entityCardSelected_3zich_447",Qt="_entityCardArchived_3zich_455",Jt="_relationshipPickerRow_3zich_460",Xt="_relationshipRecovery_3zich_466",Yt="_empty_3zich_488",Zt="_centerState_3zich_495",ei="_inlineError_3zich_509",ti="_spinner_3zich_524",ii="_columnPortfolio_3zich_543",ni="_columnActive_3zich_544",ai="_columnWorkstreams_3zich_545",si="_columnTasks_3zich_550",ri="_workspaceEditorIdentity_3zich_592",n={module:ot,columns:lt,column:ct,columnHeader:dt,columnHeadingGroup:ut,paneHeading:ht,responsiveBack:vt,sectionLabel:pt,sectionHeadingRow:ft,headerActions:yt,portfolioControls:gt,searchRow:kt,searchShell:mt,clearSearch:wt,controlActive:xt,filterPanel:bt,filterField:jt,filterLabel:_t,filterDropdown:Ct,sortTrigger:Et,scrollRegion:St,selectedEntityContext:It,selectedEntityContextArchived:Nt,selectedEntityReferenceRow:At,selectedEntityReferenceIdentity:Rt,selectedEntityReferenceActions:Ot,workspaceEditor:zt,workspaceEditorField:Tt,workspaceEditorActions:Lt,selectedEntityDescription:$t,selectedEntityDescriptionMarkdown:Pt,selectedEntityOwnerField:Wt,selectedEntityOwnerDropdown:Dt,selectedEntityDetailsSection:Ft,activityTimelineList:Ht,activityTimelineEmpty:Bt,visuallyHidden:Mt,entityCard:Ut,entityCardTopRow:Gt,entityCardBody:Vt,entityCardContentButton:Kt,entityCardSelected:qt,entityCardArchived:Qt,relationshipPickerRow:Jt,relationshipRecovery:Xt,empty:Yt,centerState:Zt,inlineError:ei,spinner:ti,columnPortfolio:ii,columnActive:ni,columnWorkstreams:ai,columnTasks:si,workspaceEditorIdentity:ri};function Z({entityType:e,mode:l,initialTitle:j="",initialDescription:m="",ownerOptions:p,fixedInitiativeId:f,formId:S,showActions:I=!0,onSavingChange:_,onCancel:A,onSave:T}){const w=e==="initiative"?"Initiative":"Workstream",H=a.useId(),$=a.useId(),P=a.useId(),y=a.useRef(null),[G,B]=a.useState(j),[C,g]=a.useState(m),[M,W]=a.useState(""),[k,L]=a.useState(null),[E,R]=a.useState(null),[c,b]=a.useState(null),[D,F]=a.useState(null),[x,N]=a.useState(!1);a.useEffect(()=>{y.current?.focus()},[]);const O=async u=>{if(u.preventDefault(),x)return;const h=G.trim();if(!h){b(`${w} title is required.`),y.current?.focus();return}b(null),F(null),N(!0),_?.(!0);try{await T({title:h,description:C.trim()||null,...l==="create"?{ownerId:M.trim()||null}:{},...e==="workstream"&&l==="create"?{initiativeId:f||null}:{},...l==="create"&&(k||E)?{icon:k,color:E}:{}})}catch(z){F(z instanceof Error?z.message:`Failed to save ${w.toLowerCase()}.`)}finally{N(!1),_?.(!1)}};return t.jsxs("form",{id:S,className:n.workspaceEditor,onSubmit:u=>{O(u)},onKeyDown:u=>{u.key!=="Escape"||x||(u.preventDefault(),A())},noValidate:!0,children:[l==="create"?t.jsxs("div",{className:n.workspaceEditorIdentity,children:[t.jsx(Ce,{entityType:e,entityId:"create-preview",icon:k,color:E||"blue",size:"detail",onChange:u=>{Object.prototype.hasOwnProperty.call(u,"icon")&&L(u.icon??null),Object.prototype.hasOwnProperty.call(u,"color")&&R(u.color??null)}}),t.jsx("span",{children:"Choose an icon and color"})]}):null,t.jsxs("div",{className:n.workspaceEditorField,children:[t.jsxs("label",{htmlFor:H,children:[w," title"]}),t.jsx("input",{ref:y,id:H,value:G,disabled:x,required:!0,"aria-invalid":c?"true":void 0,"aria-describedby":c?$:void 0,onChange:u=>{B(u.target.value),c&&b(null)},placeholder:e==="initiative"?"Enter initiative title":"Enter workstream title"}),c?t.jsx("p",{id:$,className:"tf-text-error",children:c}):null]}),t.jsxs("div",{className:n.workspaceEditorField,children:[t.jsxs("label",{htmlFor:P,children:[w," description"]}),t.jsx("textarea",{id:P,value:C,disabled:x,rows:5,onChange:u=>g(u.target.value),placeholder:e==="initiative"?"Describe the broader outcome this initiative is meant to achieve.":"Describe the lane of work this workstream will coordinate."})]}),l==="create"&&p?t.jsxs("div",{className:n.workspaceEditorField,children:[t.jsxs("span",{children:[w," owner"]}),t.jsx(le,{value:M,options:p,onChange:W,disabled:x,ariaLabel:`${w} owner`,className:`${Ee.control} ${n.selectedEntityOwnerDropdown}`})]}):null,D?t.jsx("p",{className:"tf-text-error",role:"alert",children:D}):null,I?t.jsxs("div",{className:n.workspaceEditorActions,children:[t.jsx("button",{type:"button",className:"tf-button-secondary tf-button-compact",onClick:A,disabled:x,children:"Cancel"}),t.jsxs("button",{type:"submit",className:"tf-button-primary tf-button-compact",disabled:x,children:[x?t.jsx(re,{size:14,className:n.spinner,"aria-hidden":"true"}):null,l==="create"?`Create ${w}`:"Save"]})]}):null]})}function oi({initiative:e,ownerOption:l,ownerOptions:j,workstreamCount:m,selected:p,onSelect:f,onChangeOwner:S,onChangeIdentity:I}){return t.jsxs("div",{className:`${n.entityCard} ${e.isArchived?n.entityCardArchived:""} ${p?n.entityCardSelected:""}`.trim(),children:[t.jsx(ce,{label:q(e),entityType:"initiative",entityName:e.title,interactive:!1}),t.jsx("div",{className:n.entityCardBody,children:t.jsx("div",{role:"button",tabIndex:0,className:n.entityCardContentButton,onClick:f,onKeyDown:_=>{_.key!=="Enter"&&_.key!==" "||(_.preventDefault(),f())},"aria-pressed":p,children:t.jsx(Se,{item:e,entityType:"initiative",workstreamCount:m,ownerOption:l,ownerOptions:j,onChangeOwner:S,onChangeIdentity:I})})})]})}function je({workstream:e,ownerOption:l,ownerOptions:j,selected:m,onSelect:p,onChangeOwner:f,onChangeIdentity:S,referenceAction:I,feedback:_}){const A=U(e);return t.jsxs("div",{className:`${n.entityCard} ${e.isArchived?n.entityCardArchived:""} ${m?n.entityCardSelected:""}`.trim(),children:[t.jsxs("div",{className:n.entityCardTopRow,children:[I,t.jsx(ce,{label:A||"Reference pending",entityType:"workstream",entityName:e.title,interactive:!1,pending:!A})]}),_,t.jsx("div",{className:n.entityCardBody,children:t.jsx("div",{role:"button",tabIndex:0,className:n.entityCardContentButton,onClick:p,onKeyDown:T=>{T.key!=="Enter"&&T.key!==" "||(T.preventDefault(),p())},"aria-pressed":m,children:t.jsx(Se,{item:e,entityType:"workstream",ownerOption:l,ownerOptions:j,onChangeOwner:f,onChangeIdentity:S})})})]})}function _e({item:e,entityType:l,ownerOptions:j,onChangeOwner:m,onChangeIdentity:p,workspaceId:f,currentActorId:S,taskReferences:I,hydrationState:_,onRetryHydration:A,onAddContextFile:T,onRemoveContextFile:w,onUpdateContextCaption:H,onUpdate:$,onArchive:P,onUnarchive:y,referenceAction:G,relationshipActions:B,relationshipContent:C}){const g=l==="initiative"?"Initiative":"Workstream",M=l==="initiative"?q(e):U(e),[W,k]=a.useState(String(e.ownerId||"")),[L,E]=a.useState(!1),[R,c]=a.useState(!1),[b,D]=a.useState(!1),[F,x]=a.useState(!1),[N,O]=a.useState(!1),u=a.useId(),h=qe({entityType:l,isArchived:e.isArchived,taskCount:e.taskCount,completedTaskCount:e.completedTaskCount,archiveReady:e.archiveReady,activeWorkstreamCount:e.archiveActiveWorkstreamCount}),z=h.mode==="archived"?`Unarchive ${g.toLowerCase()}`:h.mode==="blocked"?`Archive unavailable — active ${h.remainingKind==="task"?"tasks":"workstreams"} remain`:h.mode==="checking"?"Archive availability is still loading":`Archive ${g.toLowerCase()}`;a.useEffect(()=>{k(String(e.ownerId||"")),E(!1)},[e.id,e.ownerId]),a.useEffect(()=>{c(!1),D(!1),x(!1),O(!1)},[e.id]);const J=async d=>{if(!m||e.isArchived||L||d===W)return;const s=W;k(d),E(!0);try{await m(d)}catch{k(s)}finally{E(!1)}},Q=async()=>{if(N)return;if(h.mode==="ready"){x(!0);return}const d=h.mode==="archived"?y:P;if(!(!d||h.mode==="blocked"||h.mode==="checking")){O(!0);try{await d()}finally{O(!1)}}},r=async()=>{if(!(!P||N)){O(!0);try{await P()!==!1&&x(!1)}finally{O(!1)}}};return t.jsxs("section",{className:`${n.selectedEntityContext} ${e.isArchived?n.selectedEntityContextArchived:""}`.trim(),"aria-label":`Selected ${g.toLowerCase()}`,"aria-busy":_?.status==="loading",children:[t.jsxs("div",{className:n.selectedEntityReferenceRow,children:[t.jsxs("div",{className:n.selectedEntityReferenceIdentity,children:[t.jsx(Ce,{entityType:l,entityId:e.id,icon:e.icon,color:e.color,size:"detail",disabled:!!e.isArchived,onChange:p?d=>p(l,e.id,d):void 0}),G,t.jsx(ce,{label:M||"Reference pending",entityType:l,entityName:e.title,interactive:!1,pending:!M})]}),t.jsxs("div",{className:n.selectedEntityReferenceActions,children:[t.jsx("span",{children:g}),B,!R&&(P||y)?t.jsx("button",{type:"button",className:"tf-control-icon",disabled:N||h.mode==="blocked"||h.mode==="checking"||(h.mode==="archived"?!y:!P),onClick:()=>{Q()},"aria-label":z,title:z,"aria-expanded":h.mode==="ready"?F:void 0,children:h.mode==="archived"?t.jsx(oe,{size:14,"aria-hidden":"true"}):t.jsx(st,{size:14,"aria-hidden":"true"})}):null,!R&&!e.isArchived&&$?t.jsx("button",{type:"button",className:"tf-control-icon",onClick:()=>c(!0),"aria-label":`Edit ${g.toLowerCase()}`,title:`Edit ${g.toLowerCase()}`,children:t.jsx(rt,{size:14,"aria-hidden":"true"})}):null,R?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"tf-button-secondary tf-button-compact",onClick:()=>c(!1),disabled:b,children:"Cancel"}),t.jsx("button",{type:"submit",form:u,className:"tf-button-primary tf-button-compact",disabled:b,children:"Save"})]}):null]})]}),F&&h.mode==="ready"?t.jsx(Qe,{entityType:l,title:e.title,activeTaskCount:e.archiveActiveTaskCount,activeWorkstreamCount:e.archiveActiveWorkstreamCount,busy:N,onCancel:()=>x(!1),onConfirm:()=>{r()}}):null,C,R&&$?t.jsx(Z,{entityType:l,mode:"edit",formId:u,showActions:!1,onSavingChange:D,initialTitle:e.title,initialDescription:e.description||"",onCancel:()=>c(!1),onSave:async d=>{await $(d),c(!1)}},`${l}:${e.id}`):t.jsxs(t.Fragment,{children:[t.jsx("h3",{className:"tf-heading-card",children:e.title}),t.jsx(Je,{description:e.description,label:g,taskReferences:I,className:`${n.selectedEntityDescription} tf-scrollbar`.trim(),markdownClassName:n.selectedEntityDescriptionMarkdown})]}),t.jsxs("div",{className:n.selectedEntityOwnerField,children:[t.jsx("span",{children:"Owner"}),t.jsx(le,{value:W,options:j,onChange:d=>{J(d)},disabled:!m||!!e.isArchived||L,ariaLabel:`${g} owner`,className:`${Ee.control} ${n.selectedEntityOwnerDropdown}`})]}),t.jsx("div",{className:n.selectedEntityDetailsSection,children:t.jsx(Xe,{entityType:l,entityId:e.id,referenceLabel:l==="initiative"?q(e):U(e),workspaceId:f,attachments:e.attachments,readOnly:!!e.isArchived,defaultExpanded:!1,onAddAttachment:!e.isArchived&&T?d=>T(l,e.id,d):void 0,onRemoveAttachment:!e.isArchived&&w?d=>w(l,e.id,d):void 0,onUpdateAttachmentCaption:!e.isArchived&&H?(d,s)=>H(l,e.id,d,s):void 0})}),t.jsx("div",{className:n.selectedEntityDetailsSection,children:t.jsx(Ye,{entityType:l,item:e,assigneeOptions:j,currentActorId:S,taskReferences:I,defaultExpanded:!1,listClassName:n.activityTimelineList,emptyClassName:n.activityTimelineEmpty,hydrationState:_,onRetryHydration:A})})]})}function pi({model:e}){const[l,j]=a.useState(null),[m,p]=a.useState(null),[f,S]=a.useState("portfolio"),[I,_]=a.useState(""),[A,T]=a.useState("all"),[w,H]=a.useState("default"),[$,P]=a.useState(!1),[y,G]=a.useState(!1),B=e.taskArrangeMode||"execution",[C,g]=a.useState(null),[M,W]=a.useState(!1),[k,L]=a.useState(null),[E,R]=a.useState(null),[c,b]=a.useState(!1),D=a.useRef(null),F=a.useRef(null),x=a.useRef(null),N=a.useRef(null),O=a.useRef(null),u=a.useMemo(()=>new Map(e.assigneeOptions.filter(i=>!String(i.archivedAt||"").trim()).map(i=>[String(i.value),i])),[e.assigneeOptions]),h=a.useMemo(()=>{const i=String(e.currentOwnerId||"").trim(),o=i?Pe(e.assigneeOptions,i).find(v=>v.value===i):void 0;return[{value:"all",label:"All owners",icon:"Users",color:"var(--text-secondary)",kind:"unassigned"},...i?[{...o,value:"mine",label:"Owned by me",icon:o?.icon||"User",color:o?.color||"var(--text-secondary)",kind:o?.kind||"member"}]:[],{value:"unassigned",label:"Unassigned",icon:De,color:We,kind:"unassigned"}]},[e.assigneeOptions,e.currentOwnerId]),z=a.useMemo(()=>Fe({initiatives:e.initiatives,standaloneWorkstreams:e.standaloneWorkstreams,showArchivedPlanning:y,searchQuery:I,ownerFilter:A,currentOwnerId:String(e.currentOwnerId||""),sort:w}),[e.currentOwnerId,e.initiatives,e.standaloneWorkstreams,A,I,y,w]),J=a.useMemo(()=>z.initiatives.map(({initiative:i})=>i),[z.initiatives]),Q=z.standaloneWorkstreams,r=a.useMemo(()=>e.initiatives.find(i=>i.id===l)??null,[e.initiatives,l]),d=a.useMemo(()=>[...e.initiatives.flatMap(i=>i.allWorkstreams??i.workstreams),...e.standaloneWorkstreams],[e.initiatives,e.standaloneWorkstreams]),s=a.useMemo(()=>d.find(i=>i.id===m)??null,[d,m]),ee=r?(r.allWorkstreams??r.workstreams).filter(i=>y||!i.isArchived):s&&!s.initiativeId?[s]:[],te=a.useMemo(()=>ke((s?.tasks??[]).filter(i=>y||!i.isArchived),B),[s?.tasks,y,B]),de=a.useMemo(()=>new Set((r?.allWorkstreams??r?.workstreams??[]).map(i=>i.id)),[r]),ue=a.useMemo(()=>new Set((s?.tasks??[]).map(i=>i.id)),[s]),Ie=a.useMemo(()=>e.linkOptions.workstreams.filter(i=>!de.has(i.id)),[de,e.linkOptions.workstreams]),Ne=a.useMemo(()=>e.linkOptions.tasks.filter(i=>!ue.has(i.id)),[ue,e.linkOptions.tasks]),V=s?"workstream":r?"initiative":null,K=s?.id||r?.id||null,he=V&&K?e.hydrationStateByEntity?.[`${V}:${K}`]:void 0,ve=a.useMemo(()=>e.initiatives.some(o=>o.isArchived)?!0:[...e.initiatives.flatMap(o=>o.allWorkstreams??o.workstreams),...e.standaloneWorkstreams].some(o=>o.isArchived||(o.tasks??[]).some(v=>v.isArchived)),[e.initiatives,e.standaloneWorkstreams]);a.useEffect(()=>{const i=O.current;if(i){if(i.entityType==="initiative"){if(!e.initiatives.some(o=>o.id===i.entityId))return;O.current=null,j(i.entityId),p(null),N.current="workstreams",S("workstreams");return}d.some(o=>o.id===i.entityId)&&(O.current=null,j(i.initiativeId||null),p(i.entityId),N.current="tasks",S("tasks"))}},[d,e.initiatives]),a.useEffect(()=>{l&&!r&&(j(null),p(null),S("portfolio"))},[r,l]),a.useEffect(()=>{m&&!s&&(p(null),S(r?"workstreams":"portfolio"))},[r,s,m]),a.useEffect(()=>{!e.hydrateEntity||!V||!K||e.hydrateEntity(V,K)},[e.hydrateEntity,K,V]),a.useEffect(()=>{W(!1),L(null),R(null),b(!1)},[K,V]),a.useLayoutEffect(()=>{if(N.current!==f)return;(f==="portfolio"?D.current:f==="workstreams"?F.current:x.current)?.focus({preventScroll:!0}),N.current=null},[f]);const X=i=>{if(i===f){(i==="portfolio"?D.current:i==="workstreams"?F.current:x.current)?.focus({preventScroll:!0});return}N.current=i,S(i)},Ae=i=>{j(i),p(null),X("workstreams")},pe=i=>{i.initiativeId||j(null),p(i.id),X("tasks")},Re=()=>{X(r?"workstreams":"portfolio")},Oe=z.hasCriteria||w!=="default",ze=()=>{_(""),T("all"),H("default")},ie=async i=>{if(!C||!e.createEntity)return;const o=await e.createEntity(C.entityType,i);O.current={entityType:C.entityType,entityId:o.id,initiativeId:C.initiativeId},g(null)},fe=async(i,o)=>{if(c)return;const v=i==="workstream"?e.attachWorkstreamToInitiative:e.attachTaskToWorkstream,ge=i==="workstream"?r?.id:s?.id;if(!(!v||!ge)){b(!0);try{await v(ge,o.referenceLabel)}finally{b(!1)}}},Te=async i=>{if(!(!s||!e.assignWorkstreamToInitiative||c)){b(!0);try{await e.assignWorkstreamToInitiative(s.id,i.referenceLabel)!==!1&&(j(i.id),W(!1))}finally{b(!1)}}},Le=async()=>{if(!(!k||c)){b(!0);try{if(k.entityType==="workstream"){if(!e.assignWorkstreamToInitiative)return;const i=r?q(r):null;if(await e.assignWorkstreamToInitiative(k.id,null)===!1)return;R({pane:k.id===s?.id?"tasks":"workstreams",message:`${k.referenceLabel} removed from its initiative.`,onUndo:async()=>{if(!i)return;await e.assignWorkstreamToInitiative?.(k.id,i)!==!1&&R(null)}})}else{if(!e.assignTaskToWorkstream||!s)return;const i=s.id;if(await e.assignTaskToWorkstream(k.id,null)===!1)return;R({pane:"tasks",message:`${k.referenceLabel} removed from this workstream.`,onUndo:async()=>{await e.assignTaskToWorkstream?.(k.id,i)!==!1&&R(null)}})}L(null)}finally{b(!1)}}},$e=async()=>{if(!(!E||c)){b(!0);try{await E.onUndo()}finally{b(!1)}}},ye=E?t.jsxs("div",{className:n.relationshipRecovery,role:"status",children:[t.jsx("span",{children:E.message}),t.jsx("button",{type:"button",className:"tf-button-ghost tf-button-compact",disabled:c,onClick:()=>{$e()},children:c?"Restoring…":"Undo"})]}):null;return e.loadState.status==="loading"&&e.initiatives.length===0&&e.standaloneWorkstreams.length===0?t.jsxs("main",{className:n.centerState,"aria-busy":"true","aria-label":"Loading planning workspace",children:[t.jsx(re,{size:22,className:n.spinner}),t.jsx("span",{children:"Loading planning…"})]}):e.loadState.status==="error"&&e.initiatives.length===0&&e.standaloneWorkstreams.length===0?t.jsxs("main",{className:n.centerState,role:"alert",children:[t.jsx(we,{size:22}),t.jsx("strong",{children:"Planning could not be loaded."}),t.jsx("span",{children:e.loadState.error}),t.jsxs("button",{type:"button",className:"tf-button-secondary tf-button-compact",onClick:e.retry,disabled:e.loadState.isRefreshing,children:[e.loadState.isRefreshing?t.jsx(re,{size:15,className:n.spinner}):t.jsx(oe,{size:15}),"Retry"]})]}):t.jsxs("main",{className:n.module,"aria-label":"Planning workspace","aria-busy":e.loadState.isRefreshing,children:[e.loadState.isRefreshing?t.jsx("span",{className:n.visuallyHidden,role:"status","aria-live":"polite",children:"Refreshing planning"}):null,(e.loadState.status==="partial"||e.loadState.status==="error")&&t.jsxs("div",{className:n.inlineError,role:"alert",children:[t.jsx(we,{size:16}),t.jsx("span",{children:e.loadState.error||"Some planning information could not be loaded."}),t.jsx("button",{type:"button",className:"tf-button-secondary tf-button-compact",onClick:e.retry,children:"Retry"})]}),t.jsxs("div",{className:n.columns,"data-active-pane":f,children:[t.jsxs("section",{className:`${n.column} ${n.columnPortfolio} ${f==="portfolio"?n.columnActive:""}`.trim(),"aria-labelledby":"planning-portfolio-heading",children:[t.jsxs("div",{className:n.columnHeader,children:[t.jsx("h2",{ref:D,id:"planning-portfolio-heading",className:`tf-heading-section ${n.paneHeading}`,tabIndex:-1,children:"Portfolio"}),t.jsxs("div",{className:n.headerActions,children:[t.jsx("span",{children:J.length+Q.length}),t.jsx("button",{type:"button",className:`tf-control-icon ${y?n.controlActive:""}`.trim(),onClick:()=>G(i=>!i),disabled:!ve,"aria-label":y?"Hide archived planning items":"Show archived planning items","aria-pressed":y,title:ve?y?"Hide archived planning items":"Show archived planning items":"No archived planning items",children:y?t.jsx(Ze,{size:15,"aria-hidden":"true"}):t.jsx(et,{size:15,"aria-hidden":"true"})})]})]}),t.jsxs("div",{className:n.portfolioControls,children:[t.jsxs("div",{className:n.searchRow,children:[t.jsxs("div",{className:n.searchShell,children:[t.jsx(tt,{size:14,"aria-hidden":"true"}),t.jsx("input",{type:"search",value:I,onChange:i=>_(i.target.value),placeholder:"Search initiatives and workstreams","aria-label":"Search planning"}),I?t.jsx("button",{type:"button",className:n.clearSearch,onClick:()=>_(""),"aria-label":"Clear planning search",title:"Clear search",children:t.jsx(xe,{size:13,"aria-hidden":"true"})}):null]}),t.jsx("button",{type:"button",className:`tf-control-icon ${$||A!=="all"||w!=="default"?n.controlActive:""}`.trim(),"aria-label":"Filter and sort planning",title:"Filter and sort planning","aria-expanded":$,"aria-controls":"planning-workspace-navigator-options",onClick:()=>P(i=>!i),children:t.jsx(it,{size:15,"aria-hidden":"true"})})]}),$?t.jsxs("div",{id:"planning-workspace-navigator-options",className:n.filterPanel,children:[t.jsxs("div",{className:n.filterField,children:[t.jsx("span",{className:n.filterLabel,children:"Owner"}),t.jsx(le,{value:A,options:e.assigneeOptions,leadingOptions:h,includeUnassigned:!1,onChange:T,disabled:!1,ariaLabel:"Filter planning by owner",className:n.filterDropdown})]}),t.jsxs("div",{className:n.filterField,children:[t.jsx("span",{className:n.filterLabel,children:"Sort"}),t.jsx(He,{value:w,options:me,onChange:i=>H(String(i)),ariaLabel:"Sort planning",className:n.filterDropdown,portalPanel:!0,panelAlign:"start",triggerContent:t.jsxs("span",{className:n.sortTrigger,children:[t.jsx(nt,{size:14,"aria-hidden":"true"}),t.jsx("span",{children:me.find(i=>i.value===w)?.label})]}),renderOptionContent:i=>i.label})]}),t.jsx("button",{type:"button",className:"tf-control-icon",onClick:ze,disabled:!Oe,"aria-label":"Reset planning filters and sort",title:"Reset planning filters and sort",children:t.jsx(oe,{size:14,"aria-hidden":"true"})})]}):null]}),t.jsxs("div",{className:n.scrollRegion,children:[t.jsxs("div",{className:n.sectionHeadingRow,children:[t.jsx("h3",{className:`tf-heading-section ${n.sectionLabel}`,children:"Initiatives"}),e.createEntity?t.jsx("button",{type:"button",className:"tf-control-icon",onClick:()=>g({entityType:"initiative"}),"aria-label":"Create initiative",title:"Create initiative",children:t.jsx(ae,{size:15,"aria-hidden":"true"})}):null]}),C?.entityType==="initiative"?t.jsx(Z,{entityType:"initiative",mode:"create",ownerOptions:e.assigneeOptions,onCancel:()=>g(null),onSave:ie}):null,z.initiatives.map(({initiative:i,workstreams:o})=>t.jsx(oi,{initiative:i,workstreamCount:o.length,ownerOption:i.ownerId?u.get(i.ownerId):void 0,ownerOptions:e.assigneeOptions,selected:l===i.id,onSelect:()=>Ae(i.id),onChangeOwner:e.changeOwner?v=>e.changeOwner?.("initiative",i.id,v==="unassigned"?"":v):void 0,onChangeIdentity:e.changeIdentity?v=>e.changeIdentity?.("initiative",i.id,v):void 0},i.id)),t.jsxs("div",{className:n.sectionHeadingRow,children:[t.jsx("h3",{className:`tf-heading-section ${n.sectionLabel}`,children:"Standalone workstreams"}),e.createEntity?t.jsx("button",{type:"button",className:"tf-control-icon",onClick:()=>g({entityType:"workstream",initiativeId:null}),"aria-label":"Create standalone workstream",title:"Create standalone workstream",children:t.jsx(ae,{size:15,"aria-hidden":"true"})}):null]}),C?.entityType==="workstream"&&!C.initiativeId?t.jsx(Z,{entityType:"workstream",mode:"create",ownerOptions:e.assigneeOptions,fixedInitiativeId:null,onCancel:()=>g(null),onSave:ie}):null,Q.map(i=>t.jsx(je,{workstream:i,ownerOption:i.ownerId?u.get(i.ownerId):void 0,ownerOptions:e.assigneeOptions,selected:m===i.id,onSelect:()=>pe(i),onChangeOwner:e.changeOwner?o=>e.changeOwner?.("workstream",i.id,o==="unassigned"?"":o):void 0,onChangeIdentity:e.changeIdentity?o=>e.changeIdentity?.("workstream",i.id,o):void 0},i.id)),J.length===0&&Q.length===0&&t.jsx("p",{className:`tf-text-helper ${n.empty}`,children:z.hasCriteria?"No planning matches.":"No planning items yet."})]})]}),t.jsxs("section",{className:`${n.column} ${n.columnWorkstreams} ${f==="workstreams"?n.columnActive:""}`.trim(),"aria-labelledby":"planning-workstreams-heading",children:[t.jsxs("div",{className:n.columnHeader,children:[t.jsxs("div",{className:n.columnHeadingGroup,children:[t.jsx("button",{type:"button",className:`tf-control-icon ${n.responsiveBack}`.trim(),onClick:()=>X("portfolio"),"aria-label":"Back to Portfolio",title:"Back to Portfolio",children:t.jsx(be,{size:15,"aria-hidden":"true"})}),t.jsxs("h2",{ref:F,id:"planning-workstreams-heading",className:`tf-heading-section ${n.paneHeading}`,tabIndex:-1,children:["Workstreams (",ee.length,")"]})]}),t.jsx("div",{className:n.headerActions,children:r&&e.createEntity?t.jsx("button",{type:"button",className:"tf-control-icon",onClick:()=>g({entityType:"workstream",initiativeId:r.id}),"aria-label":`Create workstream in ${r.title}`,title:"Create workstream",children:t.jsx(ae,{size:15,"aria-hidden":"true"})}):null})]}),t.jsxs("div",{className:n.scrollRegion,children:[r?t.jsxs(t.Fragment,{children:[t.jsx(_e,{item:r,entityType:"initiative",ownerOptions:e.assigneeOptions,onChangeOwner:e.changeOwner?i=>e.changeOwner?.("initiative",r.id,i):void 0,onChangeIdentity:e.changeIdentity,workspaceId:e.currentWorkspaceId,currentActorId:e.currentOwnerId,taskReferences:e.taskReferences,hydrationState:s?void 0:he,onRetryHydration:e.hydrateEntity?()=>{e.hydrateEntity?.("initiative",r.id)}:void 0,onAddContextFile:e.addContextFile,onRemoveContextFile:e.removeContextFile,onUpdateContextCaption:e.updateContextCaption,onUpdate:e.updateEntity?i=>e.updateEntity("initiative",r.id,i):void 0,onArchive:e.archiveEntity?()=>e.archiveEntity("initiative",r.id):void 0,onUnarchive:e.unarchiveEntity?()=>e.unarchiveEntity("initiative",r.id):void 0}),t.jsx(ne,{options:Ie,entityLabel:"workstream",onSelect:i=>fe("workstream",i),disabled:!e.attachWorkstreamToInitiative||c})]}):null,C?.entityType==="workstream"&&C.initiativeId===r?.id?t.jsx(Z,{entityType:"workstream",mode:"create",ownerOptions:e.assigneeOptions,fixedInitiativeId:r.id,onCancel:()=>g(null),onSave:ie}):null,ee.map(i=>t.jsx(je,{workstream:i,ownerOption:i.ownerId?u.get(i.ownerId):void 0,ownerOptions:e.assigneeOptions,selected:m===i.id,onSelect:()=>pe(i),onChangeOwner:e.changeOwner?o=>e.changeOwner?.("workstream",i.id,o==="unassigned"?"":o):void 0,onChangeIdentity:e.changeIdentity?o=>e.changeIdentity?.("workstream",i.id,o):void 0,referenceAction:r?t.jsx(Y,{disabled:!e.assignWorkstreamToInitiative||c,onClick:()=>L({entityType:"workstream",id:i.id,referenceLabel:U(i),title:i.title,parentLabel:r?`${q(r)} ${r.title}`.trim():"its initiative"}),title:`Unlink ${U(i)||i.title} from initiative`,ariaLabel:`Unlink ${U(i)||i.title} from initiative`,children:t.jsx(se,{size:14,"aria-hidden":"true"})}):void 0},i.id)),r&&E?.pane==="workstreams"?ye:null,ee.length===0&&t.jsx("p",{className:`tf-text-helper ${n.empty}`,children:"Select an initiative or standalone workstream."})]})]}),t.jsxs("section",{className:`${n.column} ${n.columnTasks} ${f==="tasks"?n.columnActive:""}`.trim(),"aria-labelledby":"planning-tasks-heading",children:[t.jsx("div",{className:n.columnHeader,children:t.jsxs("div",{className:n.columnHeadingGroup,children:[t.jsx("button",{type:"button",className:`tf-control-icon ${n.responsiveBack}`.trim(),onClick:Re,"aria-label":r?"Back to Workstreams":"Back to Portfolio",title:r?"Back to Workstreams":"Back to Portfolio",children:t.jsx(be,{size:15,"aria-hidden":"true"})}),t.jsxs("h2",{ref:x,id:"planning-tasks-heading",className:`tf-heading-section ${n.paneHeading}`,tabIndex:-1,children:["Tasks (",te.length,")"]})]})}),t.jsxs("div",{className:n.scrollRegion,children:[s?t.jsxs(t.Fragment,{children:[t.jsx(_e,{item:s,entityType:"workstream",ownerOptions:e.assigneeOptions,onChangeOwner:e.changeOwner?i=>e.changeOwner?.("workstream",s.id,i):void 0,workspaceId:e.currentWorkspaceId,currentActorId:e.currentOwnerId,taskReferences:e.taskReferences,hydrationState:he,onRetryHydration:e.hydrateEntity?()=>{e.hydrateEntity?.("workstream",s.id)}:void 0,onAddContextFile:e.addContextFile,onRemoveContextFile:e.removeContextFile,onUpdateContextCaption:e.updateContextCaption,onUpdate:e.updateEntity?i=>e.updateEntity("workstream",s.id,i):void 0,onArchive:e.archiveEntity?()=>e.archiveEntity("workstream",s.id):void 0,onUnarchive:e.unarchiveEntity?()=>e.unarchiveEntity("workstream",s.id):void 0,referenceAction:s.initiativeId?t.jsx(Y,{disabled:!e.assignWorkstreamToInitiative||c,onClick:()=>{L({entityType:"workstream",id:s.id,referenceLabel:U(s),title:s.title,parentLabel:r?`${q(r)} ${r.title}`.trim():"its initiative"})},title:"Unlink workstream from initiative",ariaLabel:"Unlink workstream from initiative",children:t.jsx(se,{size:14,"aria-hidden":"true"})}):t.jsx(Y,{disabled:!e.assignWorkstreamToInitiative||c,onClick:()=>W(i=>!i),title:"Link initiative",ariaLabel:"Link initiative",ariaExpanded:M,children:t.jsx(at,{size:14,"aria-hidden":"true"})}),relationshipContent:t.jsx(t.Fragment,{children:!s.initiativeId&&M?t.jsxs("div",{className:n.relationshipPickerRow,children:[t.jsx(ne,{options:e.linkOptions.initiatives,entityLabel:"initiative",onSelect:Te,disabled:c}),t.jsx("button",{type:"button",className:"tf-control-icon tf-control-icon-compact",disabled:c,onClick:()=>W(!1),title:"Cancel initiative link","aria-label":"Cancel initiative link",children:t.jsx(xe,{size:14,"aria-hidden":"true"})})]}):null})}),t.jsx(ne,{options:Ne,entityLabel:"task",onSelect:i=>fe("task",i),disabled:!e.attachTaskToWorkstream||c}),e.setTaskArrangeMode?t.jsx(Be,{value:B,onChange:e.setTaskArrangeMode}):null]}):null,t.jsx(Me,{tasks:te,mode:B,onReorder:s&&e.reorderWorkstreamTasks?i=>e.reorderWorkstreamTasks?.(s.id,Ve(ke(s.tasks??[],"execution"),i)):void 0,children:i=>{const o=Ue(i);return t.jsx(Ge,{task:i,assigneeOption:i.assignee?u.get(i.assignee):void 0,assigneeOptions:e.assigneeOptions,showStatusLabel:e.showTaskCardStatusLabel,onOpen:()=>e.openTask(i.id),onAssigneeChange:e.setTaskAssignee?v=>e.setTaskAssignee?.(i.id,v):void 0,onStatusChange:e.setTaskStatus?v=>e.setTaskStatus?.(i.id,v):void 0,referenceInteractive:!1,referenceAction:t.jsx(Y,{disabled:!e.assignTaskToWorkstream||c,onClick:v=>{v.stopPropagation(),L({entityType:"task",id:i.id,referenceLabel:o||i.id,title:i.title,parentLabel:s?`${U(s)} ${s.title}`.trim():"its workstream"})},title:`Unlink ${o||i.title} from workstream`,ariaLabel:`Unlink ${o||i.title} from workstream`,children:t.jsx(se,{size:14,"aria-hidden":"true"})})},i.id)}}),s&&E?.pane==="tasks"?ye:null,!s&&t.jsx("p",{className:`tf-text-helper ${n.empty}`,children:"Select a workstream."}),s&&te.length===0&&t.jsx("p",{className:`tf-text-helper ${n.empty}`,children:"No tasks are linked to this workstream."})]})]})]}),t.jsx(Ke,{item:k,busy:c,theme:e.theme,onCancel:()=>L(null),onConfirm:()=>{Le()}})]})}export{pi as PlanningModule};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._module_3zich_1{container-name:planning-workspace;container-type:inline-size;display:flex;flex:1;width:100%;min-width:0;min-height:0;flex-direction:column;overflow:hidden;color:var(--text-primary);background:var(--surface-page)}._columns_3zich_15{display:grid;grid-template-columns:repeat(3,minmax(240px,1fr));flex:1;min-height:0;overflow-x:auto}._column_3zich_15{display:flex;min-width:240px;min-height:0;flex-direction:column;border-right:1px solid var(--border-primary);background:color-mix(in srgb,var(--surface-panel) 65%,var(--surface-elevated))}._column_3zich_15:last-child{border-right:0}._columnHeader_3zich_36{height:58px;min-height:58px;flex:0 0 58px;box-sizing:border-box;padding:12px 16px;display:flex;align-items:center;justify-content:space-between;gap:12px;border-bottom:1px solid var(--border-primary)}._columnHeadingGroup_3zich_49{min-width:0;display:flex;align-items:center;gap:8px}._paneHeading_3zich_56:focus{outline:none}._responsiveBack_3zich_60{display:none}._sectionLabel_3zich_64{margin:0}._sectionHeadingRow_3zich_68{min-height:32px;display:flex;align-items:center;justify-content:space-between;gap:8px}._columnHeader_3zich_36 span{color:var(--text-muted);font-size:12px}._headerActions_3zich_81{display:flex;align-items:center;gap:8px}._portfolioControls_3zich_87{padding:10px 12px;display:flex;flex-direction:column;gap:8px;border-bottom:1px solid var(--border-primary)}._searchRow_3zich_95{display:flex;align-items:center;gap:8px}._searchShell_3zich_101{min-width:0;height:34px;flex:1;padding:0 7px 0 9px;display:flex;align-items:center;gap:7px;border:1px solid var(--border-default);border-radius:var(--radius-md);color:var(--text-secondary);background:color-mix(in srgb,var(--surface-inset) 82%,transparent)}._searchShell_3zich_101:focus-within{border-color:var(--brand-primary-border);box-shadow:0 0 0 2px color-mix(in srgb,var(--brand-primary-border) 24%,transparent)}._searchShell_3zich_101 input{min-width:0;flex:1;border:0;outline:0;color:var(--text-primary);background:transparent;font:inherit;font-size:12px}._searchShell_3zich_101 input::placeholder{color:var(--text-helper)}._searchShell_3zich_101 input::-webkit-search-cancel-button{appearance:none}._clearSearch_3zich_139{width:24px;height:24px;flex:0 0 24px;padding:0;display:inline-flex;align-items:center;justify-content:center;border:0;border-radius:6px;color:var(--text-secondary);background:transparent;cursor:pointer}._clearSearch_3zich_139:hover,._clearSearch_3zich_139:focus-visible{color:var(--text-primary);background:var(--surface-hover)}._controlActive_3zich_160{border-color:var(--brand-primary-border);color:var(--brand-primary);background:var(--brand-primary-soft)}._filterPanel_3zich_166{padding:8px;display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr) auto;align-items:end;gap:8px;border:1px solid var(--border-default);border-radius:var(--radius-md);background:color-mix(in srgb,var(--surface-panel) 74%,transparent)}._filterField_3zich_177{min-width:0;display:flex;flex-direction:column;gap:4px}._filterLabel_3zich_184{color:var(--text-secondary);font-size:11px;font-weight:650}._filterDropdown_3zich_190{width:100%}._filterDropdown_3zich_190 .taxonomyDropdownButton{min-height:32px;padding:4px 6px;font-size:12px}._filterDropdown_3zich_190 .taxonomyDropdownButtonContent{min-height:22px}._sortTrigger_3zich_204{min-width:0;display:flex;align-items:center;gap:7px}._sortTrigger_3zich_204 span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._scrollRegion_3zich_217{display:flex;min-height:0;flex:1;flex-direction:column;gap:8px;padding:12px 12px 20px;overflow-y:auto}._selectedEntityContext_3zich_227{padding:12px;display:flex;flex-direction:column;gap:8px;border:1px solid var(--border-primary);border-radius:var(--radius-md);background:var(--surface-elevated)}._selectedEntityContextArchived_3zich_237{opacity:.7;filter:saturate(.45)}._selectedEntityReferenceRow_3zich_242{display:flex;align-items:center;justify-content:space-between;gap:8px}._selectedEntityReferenceRow_3zich_242>span:last-child{color:var(--text-muted);font-size:11px;font-weight:650;letter-spacing:.04em;text-transform:uppercase}._selectedEntityReferenceIdentity_3zich_257{min-width:0;display:inline-flex;align-items:center;gap:8px}._selectedEntityReferenceActions_3zich_264{display:flex;align-items:center;gap:8px}._selectedEntityReferenceActions_3zich_264>span{color:var(--text-muted);font-size:11px;font-weight:650;letter-spacing:.04em;text-transform:uppercase}._workspaceEditor_3zich_278{padding:12px;display:flex;flex-direction:column;gap:10px;border:1px solid var(--brand-primary-border);border-radius:var(--radius-md);background:var(--surface-elevated)}._selectedEntityContext_3zich_227 ._workspaceEditor_3zich_278{padding:0;border:0;background:transparent}._workspaceEditorField_3zich_294{display:flex;flex-direction:column;gap:5px}._workspaceEditorField_3zich_294>label,._workspaceEditorField_3zich_294>span{color:var(--text-secondary);font-size:11px;font-weight:650}._workspaceEditorField_3zich_294 input,._workspaceEditorField_3zich_294 textarea{width:100%;border:1px solid var(--border-default);border-radius:var(--radius-md);color:var(--text-primary);background:var(--surface-inset);font:inherit;font-size:12px}._workspaceEditorField_3zich_294 input{min-height:34px;padding:6px 8px}._workspaceEditorField_3zich_294 textarea{min-height:108px;padding:8px;resize:vertical;line-height:1.45}._workspaceEditorField_3zich_294 input:focus,._workspaceEditorField_3zich_294 textarea:focus{border-color:var(--brand-primary-border);outline:0;box-shadow:0 0 0 2px color-mix(in srgb,var(--brand-primary-border) 24%,transparent)}._workspaceEditorActions_3zich_337{display:flex;align-items:center;justify-content:flex-end;gap:8px}._selectedEntityContext_3zich_227 h3{margin:0}._selectedEntityDescription_3zich_348{max-height:clamp(120px,22vh,260px);padding:8px 10px;border:1px solid var(--border-primary);background:var(--task-card-surface)}._selectedEntityDescriptionMarkdown_3zich_355{color:var(--text-secondary);font-size:12px;line-height:1.55}._selectedEntityOwnerField_3zich_361{display:flex;flex-direction:column;gap:4px}._selectedEntityOwnerField_3zich_361>span{color:var(--text-secondary);font-size:11px;font-weight:650}._selectedEntityOwnerDropdown_3zich_373{width:100%}._selectedEntityDetailsSection_3zich_377{padding-top:9px;border-top:1px solid var(--border-primary)}._activityTimelineList_3zich_382{margin-top:8px;display:flex;flex-direction:column;gap:8px}._activityTimelineEmpty_3zich_389{padding:14px 0 4px}._visuallyHidden_3zich_393{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}._entityCard_3zich_405{width:100%;padding:12px;display:flex;flex-direction:column;align-items:stretch;gap:7px;border:1px solid var(--border-primary);border-radius:var(--radius-md);color:var(--text-primary);background:var(--task-card-surface);text-align:left}._entityCard_3zich_405:hover{border-color:var(--brand-primary-border);background:linear-gradient(var(--surface-hover),var(--surface-hover)),var(--task-card-surface)}._entityCardTopRow_3zich_426{min-width:0;display:flex;align-items:center;gap:8px}._entityCardBody_3zich_433{width:100%}._entityCardContentButton_3zich_437{width:100%;padding:0;border:0;color:inherit;background:transparent;text-align:left;cursor:pointer}._entityCardSelected_3zich_447{border-color:var(--brand-primary-border);background:var(--planning-card-selected-overlay),var(--task-card-surface);box-shadow:inset 3px 0 0 var(--brand-primary)}._entityCardArchived_3zich_455{opacity:.7;filter:saturate(.45)}._relationshipPickerRow_3zich_460{display:flex;align-items:center;gap:8px}._relationshipRecovery_3zich_466{padding:8px;display:flex;align-items:center;justify-content:space-between;gap:8px;border:1px solid var(--border-default);border-radius:var(--radius-md);color:var(--text-secondary);background:var(--surface-inset);font-size:12px}._relationshipRecovery_3zich_466>span{min-width:0;flex:1}._sectionLabel_3zich_64{padding:10px 4px 2px}._empty_3zich_488{margin:auto;padding:24px;font-style:italic;text-align:center}._centerState_3zich_495{display:flex;min-height:0;flex:1;align-items:center;justify-content:center;flex-direction:column;gap:10px;padding:32px;color:var(--text-secondary);background:var(--surface-page);text-align:center}._inlineError_3zich_509{padding:9px 16px;display:flex;align-items:center;gap:8px;border-bottom:1px solid var(--border-primary);color:var(--text-secondary);background:var(--surface-elevated);font-size:13px}._inlineError_3zich_509 button{margin-left:auto}._spinner_3zich_524{animation:_spin_3zich_524 .9s linear infinite}@keyframes _spin_3zich_524{to{transform:rotate(360deg)}}@container planning-workspace (max-width: 1050px){._columns_3zich_15{grid-template-columns:repeat(2,minmax(0,1fr));overflow-x:hidden}._column_3zich_15{min-width:0;display:none}._columnPortfolio_3zich_543,._columnActive_3zich_544,._columns_3zich_15[data-active-pane=portfolio] ._columnWorkstreams_3zich_545{display:flex}._columnWorkstreams_3zich_545,._columnTasks_3zich_550{border-right:0}._columns_3zich_15[data-active-pane=tasks] ._columnTasks_3zich_550 ._responsiveBack_3zich_60{display:inline-flex}}@container planning-workspace (max-width: 680px){._columns_3zich_15{grid-template-columns:minmax(0,1fr)}._columnPortfolio_3zich_543,._columnActive_3zich_544,._columns_3zich_15[data-active-pane=portfolio] ._columnWorkstreams_3zich_545{display:none}._columnActive_3zich_544{display:flex;border-right:0}._columnWorkstreams_3zich_545._columnActive_3zich_544 ._responsiveBack_3zich_60,._columnTasks_3zich_550._columnActive_3zich_544 ._responsiveBack_3zich_60{display:inline-flex}._filterPanel_3zich_166{grid-template-columns:minmax(0,1fr) auto}._filterField_3zich_177{grid-column:1 / -1}._filterPanel_3zich_166>button{grid-column:2}}._workspaceEditorIdentity_3zich_592{display:flex;align-items:center;gap:var(--space-sm);color:var(--text-helper);font-size:.78rem}
|