@taskforcehq/taskforce 0.3.320 → 0.3.322
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/TaskforceCore.js +8 -3
- package/dist/hooks/workspace/useTaskforceWorkspaceBootstrap.js +29 -5
- package/dist/mcp/runtime.js +72 -10
- package/dist/mcp/taskPlanningRegistrar.js +1 -0
- package/dist/server/routes/admin.d.ts +1 -0
- package/dist/server/routes/admin.js +17 -0
- package/dist/ui/assets/{AgentsModule-BZG0WHDN.js → AgentsModule-7jpDeuVR.js} +1 -1
- package/dist/ui/assets/{AnnotatedAttachmentWorkspace-EQEzsETm.js → AnnotatedAttachmentWorkspace-BJLe8DFj.js} +1 -1
- package/dist/ui/assets/{ContextAttachmentManager-B3hESx6y.js → ContextAttachmentManager-AmEny3eI.js} +1 -1
- package/dist/ui/assets/{DocumentWorkspace-Z7bykYtA.js → DocumentWorkspace-Cqdq31Ha.js} +1 -1
- package/dist/ui/assets/{EntityActivityTimeline-B2aXkxiE.js → EntityActivityTimeline-BlS7DhA4.js} +1 -1
- package/dist/ui/assets/{InitiativesModule-CSzXelzW.js → InitiativesModule-C1qfO1uZ.js} +1 -1
- package/dist/ui/assets/{PlansPage-2vebpTBs.js → PlansPage-DFt5w-0Y.js} +1 -1
- package/dist/ui/assets/{TaskContextUpload-Bz06La5A.js → TaskContextUpload-zuro5gDT.js} +1 -1
- package/dist/ui/assets/{TaskSettings-4PbrcOqD.js → TaskSettings-CJPC2Bft.js} +1 -1
- package/dist/ui/assets/{WorkflowsModule-AyOzrP3y.js → WorkflowsModule-CEEGuxsf.js} +1 -1
- package/dist/ui/assets/documentReferences-Ca2P--i5.js +1 -0
- package/dist/ui/assets/index-CGDQY0nN.js +5 -0
- package/dist/ui/index.html +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/documentReferences-CKk8ylqA.js +0 -1
- package/dist/ui/assets/index-rB9GGUCz.js +0 -5
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{j as t,r as s,R as aa}from"./vendor-react-CKJs5o3c.js";import{R as Fn,f as ge,e as Rt,g as Hn,t as za,M as na}from"./index-rB9GGUCz.js";import{a7 as Ua,x as Dn,w as On,p as zn,P as Un,c as sa,T as Ga,r as Gn,h as Ka,an as Kn,R as Wn,ao as Yn,ap as Xn,aq as Vn,ar as ia,C as la,as as qn,at as Za,au as Qa,av as en,aw as tn,g as Jn,f as Zn,b as ca}from"./vendor-icons-CLnehDTw.js";import"./vendor-markdown-BUxTU7dS.js";import"./vendor-dnd-DRzYolkg.js";import"./vendor-router-BbWMxlnO.js";function Qn({copied:r,disabled:l=!1,label:f,onClick:p,title:b="Copy image reference",ariaLabel:x,className:L=""}){return t.jsx(Fn,{copied:r,disabled:l,label:"",onClick:p,title:b,ariaLabel:x,className:L,children:f})}const es="_shell_17mlo_1",ts="_shellWithImageTray_17mlo_18",as="_shellImageTrayOpen_17mlo_22",ns="_imageTrayPanel_17mlo_26",ss="_imageTrayPanelOpen_17mlo_50",rs="_imageTrayHeader_17mlo_58",os="_imageTrayTitle_17mlo_73",is="_imageTraySearch_17mlo_85",ls="_imageTraySearchIcon_17mlo_91",cs="_imageTraySearchInput_17mlo_100",ds="_imageTrayList_17mlo_117",us="_imageTrayState_17mlo_129",ms="_imageTrayStateError_17mlo_130",fs="_imageTrayItem_17mlo_142",hs="_imageTrayItemActive_17mlo_164",ps="_imageTrayThumb_17mlo_174",gs="_imageTrayItemBody_17mlo_191",ys="_imageTrayItemTitle_17mlo_199",bs="_imageTrayItemTask_17mlo_200",xs="_imageTrayItemMetaDetails_17mlo_201",vs="_imageTrayItemMeta_17mlo_201",_s="_imageTrayItemReference_17mlo_239",Is="_panel_17mlo_246",ws="_sessionPanel_17mlo_252",ks="_detailPanel_17mlo_253",Ss="_sessionContextBar_17mlo_259",Ns="_sessionContextLeft_17mlo_270",Cs="_sessionContextRight_17mlo_271",js="_sessionContextLabel_17mlo_286",Ts="_sessionContextSpacer_17mlo_292",$s="_canvasPanel_17mlo_297",Rs="_canvasWorkspace_17mlo_304",Ps="_canvasMain_17mlo_311",Bs="_panelHeader_17mlo_318",Es="_panelHeaderText_17mlo_327",As="_panelTitle_17mlo_331",Ms="_canvasHeading_17mlo_335",Ls="_sessionActions_17mlo_339",Fs="_sessionList_17mlo_347",Hs="_annotationList_17mlo_348",Ds="_markerHelpModalBody_17mlo_363",Os="_openImageModalBody_17mlo_369",zs="_openImageField_17mlo_375",Us="_openImageActions_17mlo_379",Gs="_markerHelpItem_17mlo_385",Ks="_markerHelpHeader_17mlo_393",Ws="_markerHelpExample_17mlo_405",Ys="_sessionCard_17mlo_409",Xs="_annotationCard_17mlo_410",Vs="_sessionEmptyState_17mlo_427",qs="_sessionCardButton_17mlo_434",Js="_annotationCardButton_17mlo_444",Zs="_sessionCardBody_17mlo_454",Qs="_sessionCardActive_17mlo_460",er="_annotationCardActive_17mlo_461",tr="_annotationMeta_17mlo_471",ar="_annotationInstructionPreview_17mlo_478",nr="_annotationPreviewFooter_17mlo_486",sr="_annotationInstructionEditor_17mlo_493",rr="_annotationTypeField_17mlo_499",or="_annotationInstructionButton_17mlo_505",ir="_annotationInstructionField_17mlo_514",lr="_sessionMeta_17mlo_518",cr="_sessionTitle_17mlo_525",dr="_annotationTitle_17mlo_526",ur="_sessionTimestamp_17mlo_532",mr="_annotationKind_17mlo_533",fr="_annotationInstructionTypeIcon_17mlo_537",hr="_sessionInstructionPreview_17mlo_543",pr="_sessionInstructionEditor_17mlo_551",gr="_sessionCardFooter_17mlo_557",yr="_toolRail_17mlo_564",br="_canvasToolRail_17mlo_573",xr="_toolbarCluster_17mlo_594",vr="_toolbarViewportCluster_17mlo_601",_r="_toolbarSeparator_17mlo_605",Ir="_toolBtn_17mlo_611",wr="_toolRailButton_17mlo_615",kr="_toolbarButton_17mlo_625",Sr="_toolBtnActive_17mlo_630",Nr="_toolbarActions_17mlo_637",Cr="_toolbarSelectionActions_17mlo_646",jr="_toolbarColorPicker_17mlo_654",Tr="_colorPickerButton_17mlo_658",$r="_colorPickerSwatch_17mlo_663",Rr="_colorPickerPopover_17mlo_671",Pr="_colorOption_17mlo_686",Br="_colorOptionActive_17mlo_696",Er="_toolbarUtilities_17mlo_703",Ar="_toolbarGeometryFields_17mlo_711",Mr="_toolbarGeometryField_17mlo_711",Lr="_toolbarGeometryLabel_17mlo_724",Fr="_toolbarGeometryInput_17mlo_730",Hr="_iconButton_17mlo_735",Dr="_ghostBtn_17mlo_740",Or="_payloadBtn_17mlo_741",zr="_backToTaskBtn_17mlo_742",Ur="_canvasScroller_17mlo_762",Gr="_canvasFrame_17mlo_778",Kr="_canvasMedia_17mlo_785",Wr="_canvasStatusOverlay_17mlo_793",Yr="_canvasStatusCard_17mlo_805",Xr="_canvasImage_17mlo_818",Vr="_overlay_17mlo_825",qr="_overlaySelect_17mlo_831",Jr="_overlayPan_17mlo_835",Zr="_overlaySvg_17mlo_839",Qr="_overlayHitLayer_17mlo_848",eo="_arrowHitArea_17mlo_857",to="_canvasHandleHit_17mlo_864",ao="_canvasResizeHandleHit_17mlo_871",no="_canvasHandleVisible_17mlo_875",so="_pin_17mlo_892",ro="_note_17mlo_893",oo="_annotationNumberBadge_17mlo_910",io="_box_17mlo_935",lo="_boxNumberBadge_17mlo_944",co="_arrowNumberBadge_17mlo_950",uo="_boxSurface_17mlo_954",mo="_selected_17mlo_967",fo="_textInput_17mlo_984",ho="_textArea_17mlo_985",po="_select_17mlo_967",go="_sessionTitleInput_17mlo_992",yo="_sessionInstructionField_17mlo_997",bo="_detailEmpty_17mlo_1006",xo="_emptyState_17mlo_1007",vo="_payloadModalBody_17mlo_1019",_o="_payloadModalToolbar_17mlo_1026",Io="_payloadViewToggle_17mlo_1033",wo="_payloadModalActions_17mlo_1034",ko="_payloadModalPreview_17mlo_1041",So="_statusBar_17mlo_1056",No="_annotationSummary_17mlo_1068",a={shell:es,shellWithImageTray:ts,shellImageTrayOpen:as,imageTrayPanel:ns,imageTrayPanelOpen:ss,imageTrayHeader:rs,imageTrayTitle:os,imageTraySearch:is,imageTraySearchIcon:ls,imageTraySearchInput:cs,imageTrayList:ds,imageTrayState:us,imageTrayStateError:ms,imageTrayItem:fs,imageTrayItemActive:hs,imageTrayThumb:ps,imageTrayItemBody:gs,imageTrayItemTitle:ys,imageTrayItemTask:bs,imageTrayItemMetaDetails:xs,imageTrayItemMeta:vs,imageTrayItemReference:_s,panel:Is,sessionPanel:ws,detailPanel:ks,sessionContextBar:Ss,sessionContextLeft:Ns,sessionContextRight:Cs,sessionContextLabel:js,sessionContextSpacer:Ts,canvasPanel:$s,canvasWorkspace:Rs,canvasMain:Ps,panelHeader:Bs,panelHeaderText:Es,panelTitle:As,canvasHeading:Ms,sessionActions:Ls,sessionList:Fs,annotationList:Hs,markerHelpModalBody:Ds,openImageModalBody:Os,openImageField:zs,openImageActions:Us,markerHelpItem:Gs,markerHelpHeader:Ks,markerHelpExample:Ws,sessionCard:Ys,annotationCard:Xs,sessionEmptyState:Vs,sessionCardButton:qs,annotationCardButton:Js,sessionCardBody:Zs,sessionCardActive:Qs,annotationCardActive:er,annotationMeta:tr,annotationInstructionPreview:ar,annotationPreviewFooter:nr,annotationInstructionEditor:sr,annotationTypeField:rr,annotationInstructionButton:or,annotationInstructionField:ir,sessionMeta:lr,sessionTitle:cr,annotationTitle:dr,sessionTimestamp:ur,annotationKind:mr,annotationInstructionTypeIcon:fr,sessionInstructionPreview:hr,sessionInstructionEditor:pr,sessionCardFooter:gr,toolRail:yr,canvasToolRail:br,toolbarCluster:xr,toolbarViewportCluster:vr,toolbarSeparator:_r,toolBtn:Ir,toolRailButton:wr,toolbarButton:kr,toolBtnActive:Sr,toolbarActions:Nr,toolbarSelectionActions:Cr,toolbarColorPicker:jr,colorPickerButton:Tr,colorPickerSwatch:$r,colorPickerPopover:Rr,colorOption:Pr,colorOptionActive:Br,toolbarUtilities:Er,toolbarGeometryFields:Ar,toolbarGeometryField:Mr,toolbarGeometryLabel:Lr,toolbarGeometryInput:Fr,iconButton:Hr,ghostBtn:Dr,payloadBtn:Or,backToTaskBtn:zr,canvasScroller:Ur,canvasFrame:Gr,canvasMedia:Kr,canvasStatusOverlay:Wr,canvasStatusCard:Yr,canvasImage:Xr,overlay:Vr,overlaySelect:qr,overlayPan:Jr,overlaySvg:Zr,overlayHitLayer:Qr,arrowHitArea:eo,canvasHandleHit:to,canvasResizeHandleHit:ao,canvasHandleVisible:no,pin:so,note:ro,annotationNumberBadge:oo,box:io,boxNumberBadge:lo,arrowNumberBadge:co,boxSurface:uo,selected:mo,textInput:fo,textArea:ho,select:po,sessionTitleInput:go,sessionInstructionField:yo,detailEmpty:bo,emptyState:xo,payloadModalBody:vo,payloadModalToolbar:_o,payloadViewToggle:Io,payloadModalActions:wo,payloadModalPreview:ko,statusBar:So,annotationSummary:No},Wa=[{value:"review",label:"Review"},{value:"change",label:"Change"},{value:"question",label:"Question"}],Ya=[{value:"select",label:"Select",icon:qn},{value:"pin",label:"Pin",icon:Za},{value:"box",label:"Box",icon:Qa},{value:"arrow",label:"Arrow",icon:en},{value:"text-note",label:"Note",icon:tn}],Co={pin:Za,box:Qa,arrow:en,"text-note":tn},jo={pin:"Pin",box:"Box",arrow:"Arrow","text-note":"Note"},To={review:ia,change:ca,question:la,issue:la,idea:ia},Pt={select:{short:"Select and edit existing markers.",detail:"Use Select to click, drag, reorder, resize, and update markers that are already on the image.",example:"Example: move an existing marker after the screenshot changes."},pin:{short:"Mark a precise spot.",detail:"Use Pin when feedback points to one exact location instead of a broader area.",example:'Example: "This icon is misaligned by 2px."'},box:{short:"Mark an area or component.",detail:"Use Box when the feedback applies to a whole region, card, panel, or bounded UI block.",example:'Example: "This whole card needs tighter padding and a stronger border."'},arrow:{short:"Show direction or relationship.",detail:"Use Arrow when you need to show movement, attachment, flow, or source-to-target intent.",example:'Example: "This tooltip should anchor to this button, not the panel."'},"text-note":{short:"Add a comment-style point marker.",detail:"Use Note when you want a point marker that reads more like a comment or open question.",example:'Example: "Ask design whether this badge should stay."'}},ct={question:"#0f766e",change:"#2563eb",issue:"#dc2626",idea:"#d97706",review:"#7c3aed"},$o=["#7c3aed","#2563eb","#0f766e","#dc2626","#d97706","#111827"],ce="review";function Ke(r){const l=String(r.displayName||"").trim();return l?`${l} review`:"Annotated session"}function an(){return`annotation-${Math.random().toString(36).slice(2,10)}`}function I(r){return!Number.isFinite(r)||r<=0?0:r>=1?1:r}function Se(r){return I(Math.max(.02,r))}function Ge(r){return r?[String(r.taskId||"").trim(),String(r.assetId||"").trim(),String(r.path||"").trim()].join("::"):""}function nn(r){if(!(r instanceof HTMLElement))return!1;const l=r.tagName.toLowerCase();return r.isContentEditable?!0:l==="input"||l==="textarea"||l==="select"}function Ro(r){if(!(r instanceof HTMLElement))return!1;if(nn(r))return!0;const l=r.tagName.toLowerCase();return l==="button"||l==="a"||r.getAttribute("role")==="button"}function ke(r){return r.map((l,f)=>({...l,order:f}))}function ra(r){if(!r)return"Unsaved";const l=new Date(r);return Number.isNaN(l.getTime())?"Unsaved":l.toLocaleString()}function Po(r){const l=typeof r=="number"&&Number.isFinite(r)?Math.max(0,r):0;return l<1024?`${l}B`:l<1024*1024?`${(l/1024).toFixed(1)}KB`:`${(l/(1024*1024)).toFixed(1)}MB`}function Bo(r){if(!r)return"";const l=new Date(r);if(Number.isNaN(l.getTime()))return"";const p=new Date().getTime()-l.getTime(),b=Math.floor(p/(1e3*60*60*24));return b<=0?"Today":b===1?"Yesterday":b<7?`${b}d ago`:b<30?`${Math.floor(b/7)}w ago`:l.toLocaleDateString()}function Bt(r){const l=String(r.createdByActor?.label||"").trim();return l||null}function Eo(r){const l=String(r||"").trim().replace(/\s+/g," ");return l?l.length>110?`${l.slice(0,107)}...`:l:""}function Xa(r,l,f,p=ct[ce]){const b={id:an(),order:0,instruction:"",markerType:ce,color:p};if(r==="pin")return{...b,kind:r,x:l.x,y:l.y};if(r==="text-note")return{...b,kind:r,x:l.x,y:l.y};if(r==="box"){const L=f||l;return{...b,kind:r,x:I(Math.min(l.x,L.x)),y:I(Math.min(l.y,L.y)),width:Se(Math.abs(L.x-l.x)),height:Se(Math.abs(L.y-l.y))}}const x=f||l;return{...b,kind:"arrow",x:l.x,y:l.y,x2:x.x,y2:x.y}}function oa(r){return r.color?r.color:ct[r.markerType||ce]}function Ao(r,l){const f=Math.max(l.width,1),p=Math.max(l.height,1),b=r.x*f,x=r.y*p,L=r.x2*f,ne=r.y2*p,se=L-b,dt=ne-x,Ne=Math.hypot(se,dt)||1,We=se/Ne,Ce=dt/Ne,G=Math.max(10,Math.min(16,Ne-2)),ye=G*.62,je=L-We*G,$=ne-Ce*G,ut=-Ce,be=We;return{shaftX1:b,shaftY1:x,shaftX2:je,shaftY2:$,headPoints:[`${L},${ne}`,`${je+ut*ye},${$+be*ye}`,`${je-ut*ye},${$-be*ye}`].join(" ")}}function Mo(r,l){return{...r,markerType:l,color:r.color||ct[l]}}function Lo(r,l){return{...r,id:an(),order:l}}function Fo(r,l){const f=String(r||"").trim()||(l?Ke(l):"Annotated session");return/\bcopy$/i.test(f)?`${f} 2`:`${f} copy`}function Ho(r,l,f){if(l===f||l<0||f<0||l>=r.length||f>=r.length)return r;const p=[...r],[b]=p.splice(l,1);return b?(p.splice(f,0,b),ke(p)):r}function ae(r){return String(Math.round(I(r)*1e3)/10)}function Do(r){const l=Number.parseFloat(r);return Number.isFinite(l)?I(l/100):null}function Oo(r,l,f){return r.kind==="pin"||r.kind==="text-note"?l==="x"||l==="y"?{...r,[l]:I(f)}:r:r.kind==="box"?l==="x"||l==="y"?{...r,[l]:I(f)}:l==="width"||l==="height"?{...r,[l]:Se(f)}:r:l==="x"||l==="y"||l==="x2"||l==="y2"?{...r,[l]:I(f)}:r}function zo(r){return r.kind==="pin"||r.kind==="text-note"?[{key:"x",label:"X",value:ae(r.x)},{key:"y",label:"Y",value:ae(r.y)}]:r.kind==="box"?[{key:"x",label:"X",value:ae(r.x)},{key:"y",label:"Y",value:ae(r.y)},{key:"width",label:"Width",value:ae(r.width)},{key:"height",label:"Height",value:ae(r.height)}]:[{key:"x",label:"Start X",value:ae(r.x)},{key:"y",label:"Start Y",value:ae(r.y)},{key:"x2",label:"End X",value:ae(r.x2)},{key:"y2",label:"End Y",value:ae(r.y2)}]}function Uo(r){if(!r)return null;const l=Math.round(r.x*100),f=Math.round(r.y*100),p=Math.round(r.width*100),b=Math.round(r.height*100);return`crop ${l}%, ${f}% size ${p}% x ${b}%`}function Go(r){return Number.isFinite(r)?Math.min(4,Math.max(.25,Number(r.toFixed(2)))):1}function Va(r){const l=[`Annotated attachment: ${r.title||r.image.displayName}`,`Image: ${r.image.displayName}`,`Image Reference: ${r.image.referenceLabel||r.image.assetId}`,`Task ID: ${r.taskId}`,r.globalInstruction?`Global instruction: ${r.globalInstruction}`:"Global instruction: None provided.","Markers:"];return r.annotations.length===0?(l.push("0. No markers."),l.join(`
|
|
1
|
+
import{j as t,r as s,R as aa}from"./vendor-react-CKJs5o3c.js";import{R as Fn,f as ge,e as Rt,g as Hn,t as za,M as na}from"./index-CGDQY0nN.js";import{a7 as Ua,x as Dn,w as On,p as zn,P as Un,c as sa,T as Ga,r as Gn,h as Ka,an as Kn,R as Wn,ao as Yn,ap as Xn,aq as Vn,ar as ia,C as la,as as qn,at as Za,au as Qa,av as en,aw as tn,g as Jn,f as Zn,b as ca}from"./vendor-icons-CLnehDTw.js";import"./vendor-markdown-BUxTU7dS.js";import"./vendor-dnd-DRzYolkg.js";import"./vendor-router-BbWMxlnO.js";function Qn({copied:r,disabled:l=!1,label:f,onClick:p,title:b="Copy image reference",ariaLabel:x,className:L=""}){return t.jsx(Fn,{copied:r,disabled:l,label:"",onClick:p,title:b,ariaLabel:x,className:L,children:f})}const es="_shell_17mlo_1",ts="_shellWithImageTray_17mlo_18",as="_shellImageTrayOpen_17mlo_22",ns="_imageTrayPanel_17mlo_26",ss="_imageTrayPanelOpen_17mlo_50",rs="_imageTrayHeader_17mlo_58",os="_imageTrayTitle_17mlo_73",is="_imageTraySearch_17mlo_85",ls="_imageTraySearchIcon_17mlo_91",cs="_imageTraySearchInput_17mlo_100",ds="_imageTrayList_17mlo_117",us="_imageTrayState_17mlo_129",ms="_imageTrayStateError_17mlo_130",fs="_imageTrayItem_17mlo_142",hs="_imageTrayItemActive_17mlo_164",ps="_imageTrayThumb_17mlo_174",gs="_imageTrayItemBody_17mlo_191",ys="_imageTrayItemTitle_17mlo_199",bs="_imageTrayItemTask_17mlo_200",xs="_imageTrayItemMetaDetails_17mlo_201",vs="_imageTrayItemMeta_17mlo_201",_s="_imageTrayItemReference_17mlo_239",Is="_panel_17mlo_246",ws="_sessionPanel_17mlo_252",ks="_detailPanel_17mlo_253",Ss="_sessionContextBar_17mlo_259",Ns="_sessionContextLeft_17mlo_270",Cs="_sessionContextRight_17mlo_271",js="_sessionContextLabel_17mlo_286",Ts="_sessionContextSpacer_17mlo_292",$s="_canvasPanel_17mlo_297",Rs="_canvasWorkspace_17mlo_304",Ps="_canvasMain_17mlo_311",Bs="_panelHeader_17mlo_318",Es="_panelHeaderText_17mlo_327",As="_panelTitle_17mlo_331",Ms="_canvasHeading_17mlo_335",Ls="_sessionActions_17mlo_339",Fs="_sessionList_17mlo_347",Hs="_annotationList_17mlo_348",Ds="_markerHelpModalBody_17mlo_363",Os="_openImageModalBody_17mlo_369",zs="_openImageField_17mlo_375",Us="_openImageActions_17mlo_379",Gs="_markerHelpItem_17mlo_385",Ks="_markerHelpHeader_17mlo_393",Ws="_markerHelpExample_17mlo_405",Ys="_sessionCard_17mlo_409",Xs="_annotationCard_17mlo_410",Vs="_sessionEmptyState_17mlo_427",qs="_sessionCardButton_17mlo_434",Js="_annotationCardButton_17mlo_444",Zs="_sessionCardBody_17mlo_454",Qs="_sessionCardActive_17mlo_460",er="_annotationCardActive_17mlo_461",tr="_annotationMeta_17mlo_471",ar="_annotationInstructionPreview_17mlo_478",nr="_annotationPreviewFooter_17mlo_486",sr="_annotationInstructionEditor_17mlo_493",rr="_annotationTypeField_17mlo_499",or="_annotationInstructionButton_17mlo_505",ir="_annotationInstructionField_17mlo_514",lr="_sessionMeta_17mlo_518",cr="_sessionTitle_17mlo_525",dr="_annotationTitle_17mlo_526",ur="_sessionTimestamp_17mlo_532",mr="_annotationKind_17mlo_533",fr="_annotationInstructionTypeIcon_17mlo_537",hr="_sessionInstructionPreview_17mlo_543",pr="_sessionInstructionEditor_17mlo_551",gr="_sessionCardFooter_17mlo_557",yr="_toolRail_17mlo_564",br="_canvasToolRail_17mlo_573",xr="_toolbarCluster_17mlo_594",vr="_toolbarViewportCluster_17mlo_601",_r="_toolbarSeparator_17mlo_605",Ir="_toolBtn_17mlo_611",wr="_toolRailButton_17mlo_615",kr="_toolbarButton_17mlo_625",Sr="_toolBtnActive_17mlo_630",Nr="_toolbarActions_17mlo_637",Cr="_toolbarSelectionActions_17mlo_646",jr="_toolbarColorPicker_17mlo_654",Tr="_colorPickerButton_17mlo_658",$r="_colorPickerSwatch_17mlo_663",Rr="_colorPickerPopover_17mlo_671",Pr="_colorOption_17mlo_686",Br="_colorOptionActive_17mlo_696",Er="_toolbarUtilities_17mlo_703",Ar="_toolbarGeometryFields_17mlo_711",Mr="_toolbarGeometryField_17mlo_711",Lr="_toolbarGeometryLabel_17mlo_724",Fr="_toolbarGeometryInput_17mlo_730",Hr="_iconButton_17mlo_735",Dr="_ghostBtn_17mlo_740",Or="_payloadBtn_17mlo_741",zr="_backToTaskBtn_17mlo_742",Ur="_canvasScroller_17mlo_762",Gr="_canvasFrame_17mlo_778",Kr="_canvasMedia_17mlo_785",Wr="_canvasStatusOverlay_17mlo_793",Yr="_canvasStatusCard_17mlo_805",Xr="_canvasImage_17mlo_818",Vr="_overlay_17mlo_825",qr="_overlaySelect_17mlo_831",Jr="_overlayPan_17mlo_835",Zr="_overlaySvg_17mlo_839",Qr="_overlayHitLayer_17mlo_848",eo="_arrowHitArea_17mlo_857",to="_canvasHandleHit_17mlo_864",ao="_canvasResizeHandleHit_17mlo_871",no="_canvasHandleVisible_17mlo_875",so="_pin_17mlo_892",ro="_note_17mlo_893",oo="_annotationNumberBadge_17mlo_910",io="_box_17mlo_935",lo="_boxNumberBadge_17mlo_944",co="_arrowNumberBadge_17mlo_950",uo="_boxSurface_17mlo_954",mo="_selected_17mlo_967",fo="_textInput_17mlo_984",ho="_textArea_17mlo_985",po="_select_17mlo_967",go="_sessionTitleInput_17mlo_992",yo="_sessionInstructionField_17mlo_997",bo="_detailEmpty_17mlo_1006",xo="_emptyState_17mlo_1007",vo="_payloadModalBody_17mlo_1019",_o="_payloadModalToolbar_17mlo_1026",Io="_payloadViewToggle_17mlo_1033",wo="_payloadModalActions_17mlo_1034",ko="_payloadModalPreview_17mlo_1041",So="_statusBar_17mlo_1056",No="_annotationSummary_17mlo_1068",a={shell:es,shellWithImageTray:ts,shellImageTrayOpen:as,imageTrayPanel:ns,imageTrayPanelOpen:ss,imageTrayHeader:rs,imageTrayTitle:os,imageTraySearch:is,imageTraySearchIcon:ls,imageTraySearchInput:cs,imageTrayList:ds,imageTrayState:us,imageTrayStateError:ms,imageTrayItem:fs,imageTrayItemActive:hs,imageTrayThumb:ps,imageTrayItemBody:gs,imageTrayItemTitle:ys,imageTrayItemTask:bs,imageTrayItemMetaDetails:xs,imageTrayItemMeta:vs,imageTrayItemReference:_s,panel:Is,sessionPanel:ws,detailPanel:ks,sessionContextBar:Ss,sessionContextLeft:Ns,sessionContextRight:Cs,sessionContextLabel:js,sessionContextSpacer:Ts,canvasPanel:$s,canvasWorkspace:Rs,canvasMain:Ps,panelHeader:Bs,panelHeaderText:Es,panelTitle:As,canvasHeading:Ms,sessionActions:Ls,sessionList:Fs,annotationList:Hs,markerHelpModalBody:Ds,openImageModalBody:Os,openImageField:zs,openImageActions:Us,markerHelpItem:Gs,markerHelpHeader:Ks,markerHelpExample:Ws,sessionCard:Ys,annotationCard:Xs,sessionEmptyState:Vs,sessionCardButton:qs,annotationCardButton:Js,sessionCardBody:Zs,sessionCardActive:Qs,annotationCardActive:er,annotationMeta:tr,annotationInstructionPreview:ar,annotationPreviewFooter:nr,annotationInstructionEditor:sr,annotationTypeField:rr,annotationInstructionButton:or,annotationInstructionField:ir,sessionMeta:lr,sessionTitle:cr,annotationTitle:dr,sessionTimestamp:ur,annotationKind:mr,annotationInstructionTypeIcon:fr,sessionInstructionPreview:hr,sessionInstructionEditor:pr,sessionCardFooter:gr,toolRail:yr,canvasToolRail:br,toolbarCluster:xr,toolbarViewportCluster:vr,toolbarSeparator:_r,toolBtn:Ir,toolRailButton:wr,toolbarButton:kr,toolBtnActive:Sr,toolbarActions:Nr,toolbarSelectionActions:Cr,toolbarColorPicker:jr,colorPickerButton:Tr,colorPickerSwatch:$r,colorPickerPopover:Rr,colorOption:Pr,colorOptionActive:Br,toolbarUtilities:Er,toolbarGeometryFields:Ar,toolbarGeometryField:Mr,toolbarGeometryLabel:Lr,toolbarGeometryInput:Fr,iconButton:Hr,ghostBtn:Dr,payloadBtn:Or,backToTaskBtn:zr,canvasScroller:Ur,canvasFrame:Gr,canvasMedia:Kr,canvasStatusOverlay:Wr,canvasStatusCard:Yr,canvasImage:Xr,overlay:Vr,overlaySelect:qr,overlayPan:Jr,overlaySvg:Zr,overlayHitLayer:Qr,arrowHitArea:eo,canvasHandleHit:to,canvasResizeHandleHit:ao,canvasHandleVisible:no,pin:so,note:ro,annotationNumberBadge:oo,box:io,boxNumberBadge:lo,arrowNumberBadge:co,boxSurface:uo,selected:mo,textInput:fo,textArea:ho,select:po,sessionTitleInput:go,sessionInstructionField:yo,detailEmpty:bo,emptyState:xo,payloadModalBody:vo,payloadModalToolbar:_o,payloadViewToggle:Io,payloadModalActions:wo,payloadModalPreview:ko,statusBar:So,annotationSummary:No},Wa=[{value:"review",label:"Review"},{value:"change",label:"Change"},{value:"question",label:"Question"}],Ya=[{value:"select",label:"Select",icon:qn},{value:"pin",label:"Pin",icon:Za},{value:"box",label:"Box",icon:Qa},{value:"arrow",label:"Arrow",icon:en},{value:"text-note",label:"Note",icon:tn}],Co={pin:Za,box:Qa,arrow:en,"text-note":tn},jo={pin:"Pin",box:"Box",arrow:"Arrow","text-note":"Note"},To={review:ia,change:ca,question:la,issue:la,idea:ia},Pt={select:{short:"Select and edit existing markers.",detail:"Use Select to click, drag, reorder, resize, and update markers that are already on the image.",example:"Example: move an existing marker after the screenshot changes."},pin:{short:"Mark a precise spot.",detail:"Use Pin when feedback points to one exact location instead of a broader area.",example:'Example: "This icon is misaligned by 2px."'},box:{short:"Mark an area or component.",detail:"Use Box when the feedback applies to a whole region, card, panel, or bounded UI block.",example:'Example: "This whole card needs tighter padding and a stronger border."'},arrow:{short:"Show direction or relationship.",detail:"Use Arrow when you need to show movement, attachment, flow, or source-to-target intent.",example:'Example: "This tooltip should anchor to this button, not the panel."'},"text-note":{short:"Add a comment-style point marker.",detail:"Use Note when you want a point marker that reads more like a comment or open question.",example:'Example: "Ask design whether this badge should stay."'}},ct={question:"#0f766e",change:"#2563eb",issue:"#dc2626",idea:"#d97706",review:"#7c3aed"},$o=["#7c3aed","#2563eb","#0f766e","#dc2626","#d97706","#111827"],ce="review";function Ke(r){const l=String(r.displayName||"").trim();return l?`${l} review`:"Annotated session"}function an(){return`annotation-${Math.random().toString(36).slice(2,10)}`}function I(r){return!Number.isFinite(r)||r<=0?0:r>=1?1:r}function Se(r){return I(Math.max(.02,r))}function Ge(r){return r?[String(r.taskId||"").trim(),String(r.assetId||"").trim(),String(r.path||"").trim()].join("::"):""}function nn(r){if(!(r instanceof HTMLElement))return!1;const l=r.tagName.toLowerCase();return r.isContentEditable?!0:l==="input"||l==="textarea"||l==="select"}function Ro(r){if(!(r instanceof HTMLElement))return!1;if(nn(r))return!0;const l=r.tagName.toLowerCase();return l==="button"||l==="a"||r.getAttribute("role")==="button"}function ke(r){return r.map((l,f)=>({...l,order:f}))}function ra(r){if(!r)return"Unsaved";const l=new Date(r);return Number.isNaN(l.getTime())?"Unsaved":l.toLocaleString()}function Po(r){const l=typeof r=="number"&&Number.isFinite(r)?Math.max(0,r):0;return l<1024?`${l}B`:l<1024*1024?`${(l/1024).toFixed(1)}KB`:`${(l/(1024*1024)).toFixed(1)}MB`}function Bo(r){if(!r)return"";const l=new Date(r);if(Number.isNaN(l.getTime()))return"";const p=new Date().getTime()-l.getTime(),b=Math.floor(p/(1e3*60*60*24));return b<=0?"Today":b===1?"Yesterday":b<7?`${b}d ago`:b<30?`${Math.floor(b/7)}w ago`:l.toLocaleDateString()}function Bt(r){const l=String(r.createdByActor?.label||"").trim();return l||null}function Eo(r){const l=String(r||"").trim().replace(/\s+/g," ");return l?l.length>110?`${l.slice(0,107)}...`:l:""}function Xa(r,l,f,p=ct[ce]){const b={id:an(),order:0,instruction:"",markerType:ce,color:p};if(r==="pin")return{...b,kind:r,x:l.x,y:l.y};if(r==="text-note")return{...b,kind:r,x:l.x,y:l.y};if(r==="box"){const L=f||l;return{...b,kind:r,x:I(Math.min(l.x,L.x)),y:I(Math.min(l.y,L.y)),width:Se(Math.abs(L.x-l.x)),height:Se(Math.abs(L.y-l.y))}}const x=f||l;return{...b,kind:"arrow",x:l.x,y:l.y,x2:x.x,y2:x.y}}function oa(r){return r.color?r.color:ct[r.markerType||ce]}function Ao(r,l){const f=Math.max(l.width,1),p=Math.max(l.height,1),b=r.x*f,x=r.y*p,L=r.x2*f,ne=r.y2*p,se=L-b,dt=ne-x,Ne=Math.hypot(se,dt)||1,We=se/Ne,Ce=dt/Ne,G=Math.max(10,Math.min(16,Ne-2)),ye=G*.62,je=L-We*G,$=ne-Ce*G,ut=-Ce,be=We;return{shaftX1:b,shaftY1:x,shaftX2:je,shaftY2:$,headPoints:[`${L},${ne}`,`${je+ut*ye},${$+be*ye}`,`${je-ut*ye},${$-be*ye}`].join(" ")}}function Mo(r,l){return{...r,markerType:l,color:r.color||ct[l]}}function Lo(r,l){return{...r,id:an(),order:l}}function Fo(r,l){const f=String(r||"").trim()||(l?Ke(l):"Annotated session");return/\bcopy$/i.test(f)?`${f} 2`:`${f} copy`}function Ho(r,l,f){if(l===f||l<0||f<0||l>=r.length||f>=r.length)return r;const p=[...r],[b]=p.splice(l,1);return b?(p.splice(f,0,b),ke(p)):r}function ae(r){return String(Math.round(I(r)*1e3)/10)}function Do(r){const l=Number.parseFloat(r);return Number.isFinite(l)?I(l/100):null}function Oo(r,l,f){return r.kind==="pin"||r.kind==="text-note"?l==="x"||l==="y"?{...r,[l]:I(f)}:r:r.kind==="box"?l==="x"||l==="y"?{...r,[l]:I(f)}:l==="width"||l==="height"?{...r,[l]:Se(f)}:r:l==="x"||l==="y"||l==="x2"||l==="y2"?{...r,[l]:I(f)}:r}function zo(r){return r.kind==="pin"||r.kind==="text-note"?[{key:"x",label:"X",value:ae(r.x)},{key:"y",label:"Y",value:ae(r.y)}]:r.kind==="box"?[{key:"x",label:"X",value:ae(r.x)},{key:"y",label:"Y",value:ae(r.y)},{key:"width",label:"Width",value:ae(r.width)},{key:"height",label:"Height",value:ae(r.height)}]:[{key:"x",label:"Start X",value:ae(r.x)},{key:"y",label:"Start Y",value:ae(r.y)},{key:"x2",label:"End X",value:ae(r.x2)},{key:"y2",label:"End Y",value:ae(r.y2)}]}function Uo(r){if(!r)return null;const l=Math.round(r.x*100),f=Math.round(r.y*100),p=Math.round(r.width*100),b=Math.round(r.height*100);return`crop ${l}%, ${f}% size ${p}% x ${b}%`}function Go(r){return Number.isFinite(r)?Math.min(4,Math.max(.25,Number(r.toFixed(2)))):1}function Va(r){const l=[`Annotated attachment: ${r.title||r.image.displayName}`,`Image: ${r.image.displayName}`,`Image Reference: ${r.image.referenceLabel||r.image.assetId}`,`Task ID: ${r.taskId}`,r.globalInstruction?`Global instruction: ${r.globalInstruction}`:"Global instruction: None provided.","Markers:"];return r.annotations.length===0?(l.push("0. No markers."),l.join(`
|
|
2
2
|
`)):(r.annotations.forEach((f,p)=>{const b=f.markerType||ce,x=Uo(f.cropHint);l.push(`${p+1}. ${f.kind} (${b})`),l.push(`Instruction: ${f.instruction||"No marker instruction."}`),x&&l.push(`Region: ${x}`)}),l.join(`
|
|
3
3
|
`))}function Et(r){return{title:r.title,globalInstruction:r.globalInstruction,annotations:ke(r.annotations)}}function qa(r){return JSON.stringify(Et(r))}function Ja(r){const l=JSON.parse(r);return Et({title:String(l?.title||""),globalInstruction:String(l?.globalInstruction||""),annotations:Array.isArray(l?.annotations)?l.annotations:[]})}function Ko(r,l){return Et({title:r?.title||l,globalInstruction:r?.globalInstruction||"",annotations:r?.annotations||[]})}function Qo({runtimeMode:r="local",apiBaseUrl:l="",cloudAuthBaseUrl:f="",workspaceId:p="default",sessionLoadReady:b=!0,requestedTarget:x=null,requestedSessionId:L=null,requestedOpenVersion:ne=0,imageTrayOpen:se,onCloseImageTray:dt,resolveTaskReferenceLabel:Ne,resolveImageReferenceLabel:We,onRequestedTargetHandled:Ce,onOpenTarget:G,onContextChange:ye,onBackToTask:je}){const $=r==="cloud"&&(f||l)||"",[ut,be]=s.useState(x),[mt,Te]=s.useState([]),[v,$e]=s.useState(null),[At,Ye]=s.useState(!1),[Re,Xe]=s.useState(""),[Pe,Ve]=s.useState(""),[j,re]=s.useState([]),[S,F]=s.useState(null),[ft,da]=s.useState(ct[ce]),[ht,pt]=s.useState(!1),[T,Be]=s.useState("select"),[sn,xe]=s.useState(!1),[gt,ua]=s.useState(!1),[V,q]=s.useState(!1),[ma,g]=s.useState(null),[K,R]=s.useState("saved"),[Wo,O]=s.useState(null),[yt,fa]=s.useState(!1),[oe,Mt]=s.useState(null),[de,Lt]=s.useState(!1),[rn,Ft]=s.useState(!1),[Ht,ha]=s.useState("json"),[bt,Dt]=s.useState(!1),[xt,Ot]=s.useState(!1),[on,pa]=s.useState(!1),[ln,vt]=s.useState(!1),[zt,_t]=s.useState(""),[qe,ga]=s.useState(!1),[Ut,cn]=s.useState([]),[It,dn]=s.useState(""),[un,ya]=s.useState(!1),[ba,xa]=s.useState(null),[ue,Je]=s.useState(!1),[Gt,Ze]=s.useState(!1),[P,Kt]=s.useState(1),[mn,Qe]=s.useState(!1),[fn,et]=s.useState(!1),[wt,va]=s.useState(!1),[kt,tt]=s.useState({width:0,height:0}),_a=s.useRef(null),Ee=s.useRef(null),Wt=s.useRef(null),Ia=s.useRef(null),me=s.useRef(L),ie=s.useRef(""),St=s.useRef(0),Yt=s.useRef(""),ve=s.useRef(0),Nt=s.useRef(null),wa=s.useRef(0),fe=s.useRef(!1),at=s.useRef(null),Xt=s.useRef(null),_e=s.useRef(null),H=s.useRef(""),A=s.useRef(""),Ct=s.useRef(null),J=s.useRef(null),Ae=s.useRef(!1),jt=s.useRef(null),nt=s.useRef(null),st=s.useRef(null),Ie=s.useRef(null),Me=s.useRef(null),Le=s.useRef(null),Fe=s.useRef(null),he=s.useRef(null),Z=s.useRef(null),ka=s.useRef(null),Sa=s.useRef(null),B=s.useMemo(()=>mt.find(e=>e.id===v)||null,[v,mt]),Q=s.useMemo(()=>`workspaceId=${encodeURIComponent(String(p||"default").trim()||"default")}`,[p]),E=s.useMemo(()=>({"x-taskforce-workspace-id":String(p||"default").trim()||"default"}),[p]),z=s.useMemo(()=>j.find(e=>e.id===S)||null,[j,S]),ee=s.useMemo(()=>Ge(x),[x]),le=typeof G=="function",d=le?x:ut,Tt=s.useMemo(()=>{const e=String(d?.taskId||"").trim();if(!e)return"";const n=Ne?.(e).trim()||"";if(n)return n;const o=String(d?.taskReferenceLabel||"").trim();return o&&o!==e?o:n||e},[d?.taskId,d?.taskReferenceLabel,Ne]),rt=s.useMemo(()=>{const e=String(d?.assetId||"").trim();if(!e)return"";const n=We?.(e).trim()||"";return n||String(d?.imageReferenceLabel||"").trim()},[d?.assetId,d?.imageReferenceLabel,We]),Vt=s.useMemo(()=>j.findIndex(e=>e.id===S),[j,S]),qt=z?.color||ft,Na=s.useMemo(()=>Et({title:Re,globalInstruction:Pe,annotations:j}),[j,Pe,Re]),He=s.useMemo(()=>qa(Na),[Na]),Ca=He!==A.current,y=s.useMemo(()=>({width:Math.max(kt.width*P,0),height:Math.max(kt.height*P,0)}),[kt.height,kt.width,P]),De=s.useMemo(()=>({visibleRadius:7,hitRadius:11}),[]),Jt=s.useMemo(()=>`0 0 ${Math.max(y.width,1)} ${Math.max(y.height,1)}`,[y.height,y.width]),ot=typeof se=="boolean",ja=s.useMemo(()=>{const e=It.trim().toLowerCase();return e?Ut.filter(n=>[n.displayName,n.originalFilename,n.imageReferenceLabel,n.taskReferenceLabel,n.assetId].filter(Boolean).join(" ").toLowerCase().includes(e)):Ut},[Ut,It]),Oe=s.useMemo(()=>{const e=Ee.current;return e?P>1||y.width>e.clientWidth+1||y.height>e.clientHeight+1:P>1},[y.height,y.width,P]),Zt=`${Math.round(P*100)}%`,W=Oe&&(mn||fn),Qt=s.useMemo(()=>{const e=new Map;return j.forEach((n,o)=>{e.set(n.id,o+1)}),e},[j]);s.useEffect(()=>{me.current=L},[L]),s.useEffect(()=>{const e=Ia.current;if(!e||!S)return;e.focus();const n=e.value.length;e.setSelectionRange(n,n)},[S]),s.useEffect(()=>{_e.current=v},[v]),s.useEffect(()=>{Ye(!1)},[v]),s.useEffect(()=>{if(!z){pt(!1);return}da(z.color||ct[z.markerType||ce])},[z]);const $t=s.useCallback(async e=>{const n=typeof performance<"u"?performance.now():Date.now(),o=await ge(`/api/taskforce/annotated-attachments/sessions?${Q}`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",...E},body:JSON.stringify({taskId:e.taskId,baseImageAssetId:e.assetId,title:Ke(e),globalInstruction:"",annotations:[]})},$),i=await o.json().catch(()=>({}));if(!o.ok)throw new Error(String(i?.error||"Failed to create session."));const c=i?.session;if(!c?.id)throw new Error("Failed to create session.");return Rt("annotated_session_create_completed",{assetId:e.assetId,taskId:e.taskId||null,sessionId:c.id,durationMs:Math.round((typeof performance<"u"?performance.now():Date.now())-n),debugTimings:i?.debugTimings||null,serverTiming:typeof o.headers?.get=="function"&&o.headers.get("server-timing")||null}),c},[E,$,Q]),Ta=s.useCallback(e=>new Promise((n,o)=>{const i=new FileReader;i.onload=()=>n(typeof i.result=="string"?i.result:""),i.onerror=()=>o(i.error||new Error("Failed to read clipboard image.")),i.readAsDataURL(e)}),[]),N=s.useCallback(()=>{at.current!==null&&(window.clearTimeout(at.current),at.current=null),st.current!==null&&(window.clearTimeout(st.current),st.current=null)},[]),ze=s.useCallback(e=>{Xe(e.title),Ve(e.globalInstruction),re(e.annotations),F(n=>n&&e.annotations.some(o=>o.id===n)?n:e.annotations[0]?.id||null)},[]),pe=s.useCallback((e,n)=>{const o=Ke(n||d||{assetId:e.baseImageAssetId,displayName:"Annotated session"}),i=Ko(e,o),c=qa(i);fe.current=!0,N(),ze(i),A.current=c,H.current=c,Ct.current=null,Ae.current=!1,jt.current=null,nt.current=null,O(null),R("saved"),q(!1)},[d,ze,N]),it=s.useCallback(e=>{fe.current=!0,N(),Te([]),$e(null),xe(!1),Ye(!1),Xe(Ke(e)),Ve(""),re([]),F(null),A.current="",H.current="",Ct.current=null,Ae.current=!1,jt.current=null,nt.current=null,Mt(null),Ft(!1),O(null),R("saved"),q(!1)},[N]),we=s.useCallback(async(e,n,o)=>{const i=_e.current;if(!i)return!0;if(e===A.current)return J.current||(O(null),R("saved")),!0;if(J.current){if(Ae.current=!0,!o?.waitForInFlight||!await J.current)return!1;const m=H.current;return m===A.current?!0:we(m,n,o)}N();const c=Ja(e);jt.current=i,Ct.current=e,q(!0),g(null),O(null),R("saving");const h=(async()=>{try{const u=await ge(`/api/taskforce/annotated-attachments/sessions/${encodeURIComponent(i)}?${Q}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json",...E},body:JSON.stringify(c)},$),m=await u.json().catch(()=>({}));if(!u.ok)throw new Error(String(m?.error||"Failed to save session."));const _=m?.session;if(!_?.id)throw new Error("Failed to save session.");Te(ta=>{const Da=ta.findIndex(Ln=>Ln.id===_.id);if(Da===-1)return[_,...ta];const Oa=[...ta];return Oa[Da]=_,Oa}),A.current=e,nt.current=null,O(null);const k=_e.current===_.id,C=H.current,X=C!==e,lt=Ae.current||X;return Ae.current=!1,k&&!lt?(fe.current=!0,ze(c),R("saved")):!lt&&C===A.current?R("saved"):R("pending"),!0}catch(u){const m=u instanceof Error?u.message:"Failed to save session.";return g(m),O(m),R("error"),nt.current!==e&&_e.current===i&&H.current===e&&(nt.current=e,st.current=window.setTimeout(()=>{st.current=null,!(_e.current!==i||H.current!==e)&&we(e,n,{waitForInFlight:!0})},1500)),!1}finally{Ct.current=null,J.current=null,jt.current=null,q(!1)}})();J.current=h;const w=await h;if(w){const u=H.current;if(u!==A.current)return we(u,n,o)}return w},[ze,N,E,$,Q]),$a=s.useCallback(e=>{if(_e.current){if(H.current===A.current){O(null),J.current||R("saved");return}K!=="saving"&&R("pending"),N(),at.current=window.setTimeout(()=>{at.current=null,we(H.current,"structure")},e)}},[N,we,K]),Y=s.useCallback(e=>{Xt.current=e},[]),M=s.useCallback(async e=>{N();const n=H.current;return!_e.current||n===A.current?(O(null),J.current||R("saved"),!0):we(n,e,{waitForInFlight:!0})},[N,we]),hn=s.useCallback(()=>{const e=A.current;e&&(N(),fe.current=!0,ze(Ja(e)),O(null),R("saved"),g(null))},[ze,N]),U=s.useCallback(async(e,n)=>{const o=typeof performance<"u"?performance.now():Date.now(),i=JSON.stringify({targetKey:Ge(e),requestedSessionId:n?.requestedSessionId??null,autoCreateIfEmpty:n?.autoCreateIfEmpty===!0});if(Nt.current===i)return;const c=ve.current+1;ve.current=c,Nt.current=i,ua(!0),g(null);try{const h=new URLSearchParams;p&&h.set("workspaceId",p),e.taskId&&h.set("taskId",e.taskId),h.set("imageAssetId",e.assetId);const w=await ge(`/api/taskforce/annotated-attachments/sessions?${h.toString()}`,{credentials:"include",headers:E,cache:"no-store"},$),u=await w.json().catch(()=>({}));if(!w.ok)throw new Error(String(u?.error||"Failed to load annotated attachment sessions."));const m=Array.isArray(u?.sessions)?u.sessions:[];if(Rt("annotated_sessions_loaded",{assetId:e.assetId,taskId:e.taskId||null,requestedSessionId:n?.requestedSessionId??null,autoCreateIfEmpty:n?.autoCreateIfEmpty===!0,sessionCount:m.length,durationMs:Math.round((typeof performance<"u"?performance.now():Date.now())-o),serverTiming:typeof w.headers?.get=="function"&&w.headers.get("server-timing")||null}),m.length===0&&n?.autoCreateIfEmpty&&String(e.assetId||"").trim()){const C=n?.requestedSessionId??me.current;if(me.current=null,C&&g("The previously selected annotation session could not be restored."),ve.current!==c)return;const X=await $t(e);if(Rt("annotated_sessions_auto_created_after_empty_load",{assetId:e.assetId,taskId:e.taskId||null,sessionId:X.id,totalDurationMs:Math.round((typeof performance<"u"?performance.now():Date.now())-o)}),ve.current!==c)return;Te([X]),$e(X.id),xe(!1),pe(X,e);return}if(ve.current!==c)return;Te(m),xe(m.length===0);const _=n?.requestedSessionId??me.current;me.current=null;const k=m.find(C=>C.id===_)||m[0]||null;_&&!k&&g("The previously selected annotation session could not be restored."),$e(k?.id||null),k?pe(k,e):(fe.current=!0,N(),Xe(Ke(e)),Ve(""),re([]),F(null),A.current="",H.current="",O(null),R("saved"))}catch(h){if(ve.current!==c)return;g(h instanceof Error?h.message:"Failed to load sessions.")}finally{Nt.current===i&&(Nt.current=null),ve.current===c&&ua(!1)}},[N,$t,E,$,pe,p]),Ra=s.useCallback(async()=>{ya(!0),xa(null);try{const e=new URLSearchParams;e.set("workspaceId",String(p||"default").trim()||"default");const n=await ge(`/api/taskforce/annotated-attachments/images?${e.toString()}`,{credentials:"include",headers:E,cache:"no-store"},$),o=await n.json().catch(()=>({}));if(!n.ok)throw new Error(String(o?.error||"Failed to load images."));cn(Array.isArray(o?.images)?o.images:[])}catch(e){xa(e instanceof Error?e.message:"Failed to load images.")}finally{ya(!1)}},[E,$,p]),pn=s.useCallback(async()=>{if(typeof navigator>"u"||!navigator.clipboard||typeof navigator.clipboard.read!="function"){g("Clipboard image paste is not supported in this environment.");return}va(!0),g(null),wa.current=Date.now()+2e3;try{const n=(await navigator.clipboard.read()).find(_=>_.types.some(k=>k.startsWith("image/"))),o=n?.types.find(_=>_.startsWith("image/"))||"";if(!n||!o)throw new Error("No image found on the clipboard.");const i=await n.getType(o),c=await Ta(i);if(!c)throw new Error("Failed to read clipboard image.");const h=o==="image/jpeg"?"jpg":o==="image/webp"?"webp":o==="image/gif"?"gif":"png",w=await fetch("/api/taskforce/context-upload",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",...E},body:JSON.stringify({file:c,originalName:`pasted-image.${h}`,workspaceId:String(p||"default").trim()||"default"})}),u=await w.json().catch(()=>({}));if(!w.ok||!u?.success||typeof u?.assetId!="string"||typeof u?.path!="string")throw new Error(String(u?.error||"Failed to paste image into Image Notes."));const m={assetId:u.assetId,imageReferenceLabel:typeof u?.referenceLabel=="string"?u.referenceLabel:void 0,path:u.path,displayName:typeof u?.displayName=="string"&&u.displayName.trim().length>0?u.displayName.trim():"Pasted image"};me.current=null,le?(ie.current="",G?.(m,{sessionId:null})):(be(m),ie.current=Ge(m),U(m,{autoCreateIfEmpty:!0}))}catch(e){g(e instanceof Error?e.message:"Failed to paste image.")}finally{va(!1)}},[le,U,G,Ta,E,p]),gn=s.useCallback(async()=>{const e=zt.trim();if(!e){g("Enter an image reference to open.");return}ga(!0),g(null);try{const n=new URLSearchParams({workspaceId:String(p||"default").trim()||"default"}),o=await ge(`/api/taskforce/annotated-attachments/images/${encodeURIComponent(e)}?${n.toString()}`,{method:"GET",credentials:"include",headers:E}),i=await o.json().catch(()=>({}));if(!o.ok||!i?.target||typeof i.target.assetId!="string"||typeof i.target.path!="string")throw new Error(String(i?.error||"Failed to open image reference."));const c={assetId:i.target.assetId,path:i.target.path,displayName:typeof i.target.displayName=="string"&&i.target.displayName.trim().length>0?i.target.displayName.trim():"Image attachment",taskId:typeof i.target.taskId=="string"&&i.target.taskId.trim().length>0?i.target.taskId.trim():void 0,taskReferenceLabel:typeof i.target.taskReferenceLabel=="string"&&i.target.taskReferenceLabel.trim().length>0?i.target.taskReferenceLabel.trim():void 0,imageReferenceLabel:typeof i.target.imageReferenceLabel=="string"&&i.target.imageReferenceLabel.trim().length>0?i.target.imageReferenceLabel.trim():void 0};me.current=null,vt(!1),_t(""),le?(ie.current="",G?.(c,{sessionId:null})):(be(c),ie.current=Ge(c),U(c,{autoCreateIfEmpty:!0}))}catch(n){g(n instanceof Error?n.message:"Failed to open image reference.")}finally{ga(!1)}},[le,U,G,zt,E,p]),yn=s.useCallback(async e=>{if(!e.assetId||!e.path||!await M("session-switch"))return;const o={assetId:e.assetId,path:e.path,displayName:String(e.displayName||e.originalFilename||"Image attachment").trim()||"Image attachment",...e.taskId?{taskId:e.taskId}:{},...e.taskReferenceLabel?{taskReferenceLabel:e.taskReferenceLabel}:{},...e.imageReferenceLabel?{imageReferenceLabel:e.imageReferenceLabel}:{}};me.current=null,g(null),le?(ie.current="",G?.(o,{sessionId:null})):(be(o),ie.current=Ge(o),it(o),U(o,{autoCreateIfEmpty:!0}))},[M,le,U,G,it]),Pa=s.useCallback(e=>{Te(n=>{const o=n.findIndex(c=>c.id===e.id);if(o===-1)return[e,...n];const i=[...n];return i[o]=e,i}),$e(e.id),pe(e,d)},[d,pe]),Ba=s.useCallback(e=>{Te(n=>{const o=n.filter(c=>c.id!==e),i=o[0]||null;return $e(i?.id||null),i?pe(i,d):(fe.current=!0,N(),Xe(Ke(d||{displayName:"Annotated session"})),Ve(""),re([]),F(null),A.current="",H.current="",O(null),R("saved")),o})},[d,N,pe]);s.useEffect(()=>{if(!x)return;if(le||be(n=>n&&Ge(n)===ee&&n.taskReferenceLabel===x.taskReferenceLabel&&n.imageReferenceLabel===x.imageReferenceLabel&&n.displayName===x.displayName?n:x),!b){ee&&(ee!==ie.current||ne!==St.current)&&ee!==Yt.current&&(it(x),Yt.current=ee,St.current=ne,Rt("annotated_sessions_load_deferred",{assetId:x.assetId,taskId:x.taskId||null,requestedTargetKey:ee})),Ce?.();return}ee&&(ee!==ie.current||ne!==St.current)&&(it(x),ie.current=ee,St.current=ne,Yt.current="",U(x,{autoCreateIfEmpty:!0})),Ce?.()},[le,U,Ce,ne,x,ee,it,L,b]),s.useEffect(()=>{d&&ye?.({target:d,sessionId:v})},[d,ye,v]),s.useEffect(()=>{if(!d||typeof document>"u"||!b)return;const e=()=>{Date.now()<wa.current||H.current!==A.current||V||gt||U(d,{requestedSessionId:v})},n=()=>{document.visibilityState==="visible"&&e()};return document.addEventListener("visibilitychange",n),()=>{document.removeEventListener("visibilitychange",n)}},[d,U,gt,V,v,b]),s.useEffect(()=>{if(!d?.path){Je(!1),Ze(!1),tt({width:0,height:0});return}Je(!0),Ze(!1),tt({width:0,height:0}),Kt(1),Qe(!1),et(!1)},[d?.path]),s.useEffect(()=>{if(!ue)return;const e=Wt.current;!e||!e.complete||e.naturalWidth<=0||e.naturalHeight<=0||(tt({width:e.naturalWidth,height:e.naturalHeight}),Je(!1),Ze(!1))},[d?.path,ue]),s.useEffect(()=>{Oe||(Qe(!1),et(!1))},[Oe]),s.useEffect(()=>{Mt(null)},[v]),s.useEffect(()=>{if(H.current=He,fe.current){fe.current=!1;return}if(!v){N(),O(null),R("saved");return}if(He===A.current){N(),J.current||(O(null),R("saved"));return}const e=Xt.current;if(Xt.current=null,K==="error"&&e===null)return;const n=e??600;if(J.current){Ae.current=!0,R("pending");return}$a(n)},[N,He,K,$a,v]),s.useEffect(()=>{v&&(J.current||He===A.current&&K!=="error"&&K!=="saved"&&(O(null),R("saved")))},[He,K,v]),s.useEffect(()=>{!ot||!se||Ra()},[Ra,se,ot]),s.useEffect(()=>{if(typeof window>"u")return;const e=n=>{H.current!==A.current&&(n.preventDefault(),n.returnValue="")};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[]),s.useEffect(()=>{if(typeof document>"u")return;const e=()=>{document.visibilityState==="hidden"&&M("visibility-hidden")};return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[M]),s.useEffect(()=>{if(!ht||typeof document>"u")return;const e=n=>{const o=n.target;o instanceof Node&&(ka.current?.contains(o)||pt(!1))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[ht]),s.useEffect(()=>{if(!At||typeof document>"u")return;const e=n=>{const o=n.target;o instanceof Node&&(Sa.current?.contains(o)||Ye(!1))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[At]),s.useEffect(()=>()=>{N()},[N]),s.useEffect(()=>{if(!de)return;const e=window.setTimeout(()=>Lt(!1),2e3);return()=>window.clearTimeout(e)},[de]),s.useEffect(()=>{if(!bt)return;const e=window.setTimeout(()=>Dt(!1),2e3);return()=>window.clearTimeout(e)},[bt]),s.useEffect(()=>{if(!xt)return;const e=window.setTimeout(()=>Ot(!1),2e3);return()=>window.clearTimeout(e)},[xt]);const te=s.useCallback((e,n,o=300)=>{re(i=>ke(i.map(c=>c.id===e?n(c):c))),Y(o)},[Y]),bn=s.useCallback(e=>{z&&(te(z.id,n=>({...n,color:e})),da(e),pt(!1))},[z,te]),Ea=s.useCallback(async()=>{if(!(!d||!await M("session-switch"))){q(!0),g(null);try{const n=await $t(d);xe(!1),await U(d,{requestedSessionId:n.id,autoCreateIfEmpty:!1}),Be("select")}catch(n){g(n instanceof Error?n.message:"Failed to create session."),xe(!0)}finally{q(!1)}}},[d,$t,M,U]),xn=s.useCallback(e=>{if(e!=="select"&&!B){Qe(!1),g("No session exists for this image yet."),xe(!0);return}g(null),xe(!1),Qe(!1),Be(e)},[B]),vn=s.useCallback(async()=>{if(!(!d||!B||!await M("duplicate"))){q(!0),g(null);try{const n=ke(j.map((h,w)=>Lo(h,w))),o=await ge(`/api/taskforce/annotated-attachments/sessions?${Q}`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",...E},body:JSON.stringify({taskId:d.taskId,baseImageAssetId:d.assetId,title:Fo(Re||B.title,d),globalInstruction:Pe,annotations:n})},$),i=await o.json().catch(()=>({}));if(!o.ok)throw new Error(String(i?.error||"Failed to duplicate session."));const c=i?.session;if(!c?.id)throw new Error("Failed to duplicate session.");Pa(c),Be("select")}catch(n){g(n instanceof Error?n.message:"Failed to duplicate session.")}finally{q(!1)}}},[d,j,Pe,Re,Pa,M,E,$,B,Q]),_n=s.useCallback(async()=>M("manual"),[M]),Aa=s.useCallback(async()=>{if(v){fa(!0),g(null);try{const e=await ge(`/api/taskforce/annotated-attachments/sessions/${encodeURIComponent(v)}/payload?${Q}`,{credentials:"include",headers:E},$),n=await e.json().catch(()=>({}));if(!e.ok)throw new Error(String(n?.error||"Failed to load payload preview."));Mt(n?.payload||null)}catch(e){g(e instanceof Error?e.message:"Failed to load payload preview.")}finally{fa(!1)}}},[E,$,v,Q]),In=s.useCallback(()=>{v&&M("payload-preview").then(e=>{e&&(Ft(!0),Aa())})},[M,Aa,v]),Ma=s.useCallback(async e=>{if(!oe||!navigator.clipboard||typeof navigator.clipboard.writeText!="function"){g("Clipboard copy is not available in this browser.");return}try{const n=e==="json"?JSON.stringify(oe,null,2):Va(oe);await navigator.clipboard.writeText(n),Lt(e)}catch(n){g(n instanceof Error?n.message:"Failed to copy payload content."),Lt(!1)}},[oe]),wn=s.useCallback(async()=>{if(!Tt||!navigator.clipboard||typeof navigator.clipboard.writeText!="function"){g("Clipboard copy is not available in this browser.");return}try{await navigator.clipboard.writeText(Tt),Dt(!0)}catch(e){g(e instanceof Error?e.message:"Failed to copy task id."),Dt(!1)}},[Tt]),kn=s.useCallback(async()=>{if(!rt||!navigator.clipboard||typeof navigator.clipboard.writeText!="function"){g("Clipboard copy is not available in this browser.");return}try{await navigator.clipboard.writeText(rt),Ot(!0)}catch(e){g(e instanceof Error?e.message:"Failed to copy image reference."),Ot(!1)}},[rt]),Sn=s.useCallback(async()=>{if(!v||!await M("delete-session"))return;const n=(B?.title||"Untitled session").trim()||"Untitled session";if(window.confirm(`Delete the annotated attachment session "${n}"?`)){q(!0),g(null);try{const o=await ge(`/api/taskforce/annotated-attachments/sessions/${encodeURIComponent(v)}?${Q}`,{method:"DELETE",credentials:"include",headers:E},$),i=await o.json().catch(()=>({}));if(!o.ok)throw new Error(String(i?.error||"Failed to delete session."));Ba(v),Be("select")}catch(o){g(o instanceof Error?o.message:"Failed to delete session.")}finally{q(!1)}}},[M,Ba,E,$,B,v,Q]),ea=s.useCallback(()=>{S&&(re(e=>ke(e.filter(n=>n.id!==S))),F(null),Y(300))},[Y,S]),Ue=s.useCallback(e=>{const n=Go(e),o=Ee.current;if(!o||n===P){Kt(n);return}const i=(o.scrollLeft+o.clientWidth/2)*(n/P)-o.clientWidth/2,c=(o.scrollTop+o.clientHeight/2)*(n/P)-o.clientHeight/2;Kt(n),window.requestAnimationFrame(()=>{o.scrollLeft=Math.max(0,i),o.scrollTop=Math.max(0,c)})},[P]),Nn=s.useCallback(()=>{Ue(P+.25)},[Ue,P]),Cn=s.useCallback(()=>{Ue(P-.25)},[Ue,P]),jn=s.useCallback(()=>{Ue(1);const e=Ee.current;e&&window.requestAnimationFrame(()=>{e.scrollLeft=0,e.scrollTop=0})},[Ue]),La=s.useCallback(e=>{S&&re(n=>{const o=n.findIndex(c=>c.id===S);if(o===-1)return n;const i=e==="up"?o-1:o+1;return i<0||i>=n.length?n:(Y(300),Ho(n,o,i))})},[Y,S]);s.useEffect(()=>{if(!S)return;const e=n=>{n.key==="Delete"&&(nn(n.target)||(n.preventDefault(),ea()))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[ea,S]),s.useEffect(()=>{const e=i=>{i.code==="Space"&&Oe&&(Ro(i.target)||(i.preventDefault(),et(!0)))},n=i=>{i.code==="Space"&&et(!1)},o=()=>{et(!1)};return window.addEventListener("keydown",e),window.addEventListener("keyup",n),window.addEventListener("blur",o),()=>{window.removeEventListener("keydown",e),window.removeEventListener("keyup",n),window.removeEventListener("blur",o)}},[Oe]);const D=s.useCallback(e=>{const n=_a.current?.getBoundingClientRect();return!n||n.width<=0||n.height<=0?null:{x:I((e.clientX-n.left)/n.width),y:I((e.clientY-n.top)/n.height)}},[]),Tn=s.useCallback(e=>{if(W){const i=Ee.current;if(!i)return;Z.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,scrollLeft:i.scrollLeft,scrollTop:i.scrollTop},e.currentTarget.setPointerCapture(e.pointerId),e.preventDefault();return}if(!v)return;if(T==="select"){F(null);return}const n=D(e);if(!n)return;if(T==="pin"||T==="text-note"){const i=Xa(T,n,n,ft);re(c=>ke([...c,i])),F(i.id),Y(300),Be("select");return}Ie.current=n;const o=Xa(T,n,n,ft);he.current={annotationId:o.id,kind:T},e.currentTarget.setPointerCapture?.(e.pointerId),re(i=>ke([...i,o])),F(o.id),Y(300)},[ft,W,Y,D,v,T]),$n=s.useCallback(e=>{if(Z.current?.pointerId===e.pointerId){e.currentTarget.releasePointerCapture?.(e.pointerId);return}if(!Ie.current||!he.current||T!=="box"&&T!=="arrow")return;const n=D(e);Ie.current=null,he.current=null,e.currentTarget.releasePointerCapture?.(e.pointerId),n&&Be("select")},[D,T]),Fa=s.useCallback((e,n)=>{if(T!=="select"||W)return;const o=D(e);o&&(Me.current={annotationId:n.id,originPointer:o,originAnnotation:n},F(n.id),e.stopPropagation())},[W,D,T]),Rn=s.useCallback(e=>{if(Z.current?.pointerId===e.pointerId){const u=Ee.current;if(!u)return;const m=e.clientX-Z.current.startX,_=e.clientY-Z.current.startY;u.scrollLeft=Z.current.scrollLeft-m,u.scrollTop=Z.current.scrollTop-_;return}if(he.current&&Ie.current){const u=D(e);if(!u)return;const{annotationId:m,kind:_}=he.current,k=Ie.current;te(m,C=>_==="box"&&C.kind==="box"?{...C,x:I(Math.min(k.x,u.x)),y:I(Math.min(k.y,u.y)),width:Se(Math.abs(u.x-k.x)),height:Se(Math.abs(u.y-k.y))}:_==="arrow"&&C.kind==="arrow"?{...C,x:k.x,y:k.y,x2:u.x,y2:u.y}:C);return}if(Le.current){const u=D(e);if(!u)return;const{annotationId:m,originPointer:_,originAnnotation:k}=Le.current,C=u.x-_.x,X=u.y-_.y;te(m,()=>({...k,width:Se(k.width+C),height:Se(k.height+X)}));return}if(Fe.current){const u=D(e);if(!u)return;const{annotationId:m,endpoint:_,originPointer:k,originAnnotation:C}=Fe.current,X=u.x-k.x,lt=u.y-k.y;te(m,()=>_==="tail"?{...C,x:I(C.x+X),y:I(C.y+lt)}:{...C,x2:I(C.x2+X),y2:I(C.y2+lt)});return}if(!Me.current)return;const n=D(e);if(!n)return;const{annotationId:o,originPointer:i,originAnnotation:c}=Me.current,h=n.x-i.x,w=n.y-i.y;te(o,()=>c.kind==="pin"||c.kind==="text-note"?{...c,x:I(c.x+h),y:I(c.y+w)}:c.kind==="box"?{...c,x:I(c.x+h),y:I(c.y+w)}:{...c,x:I(c.x+h),y:I(c.y+w),x2:I(c.x2+h),y2:I(c.y2+w)})},[D,te]),Pn=s.useCallback(()=>{Ie.current=null,Me.current=null,Le.current=null,Fe.current=null,he.current=null,Z.current=null},[]),Bn=s.useCallback(()=>{Ie.current=null,Me.current=null,Le.current=null,Fe.current=null,he.current=null,Z.current=null},[]),En=s.useCallback(()=>{Me.current=null,Le.current=null,Fe.current=null,he.current=null,Z.current=null},[]),An=s.useCallback((e,n)=>{if(T!=="select"||W)return;const o=D(e);o&&(Le.current={annotationId:n.id,originPointer:o,originAnnotation:n},F(n.id),e.stopPropagation())},[W,D,T]),Ha=s.useCallback((e,n,o)=>{if(T!=="select"||W)return;const i=D(e);i&&(Fe.current={annotationId:n.id,originPointer:i,originAnnotation:n,endpoint:o},F(n.id),e.stopPropagation())},[W,D,T]),Mn=B?.updatedAt?ra(B.updatedAt):"Not saved yet";return t.jsxs("div",{className:`${a.shell} ${ot?a.shellWithImageTray:""} ${ot&&se?a.shellImageTrayOpen:""}`.trim(),children:[ot?t.jsxs("aside",{className:`${a.imageTrayPanel} ${se?a.imageTrayPanelOpen:""}`.trim(),"aria-label":"Image tray","aria-hidden":!se,children:[t.jsxs("div",{className:a.imageTrayHeader,children:[t.jsxs("span",{className:a.imageTrayTitle,children:[t.jsx(Ua,{size:14}),"Images"]}),t.jsx("button",{type:"button",className:"tf-control-icon",onClick:dt,title:"Collapse image tray","aria-label":"Collapse image tray",children:t.jsx(Dn,{size:16})})]}),t.jsxs("div",{className:a.imageTraySearch,children:[t.jsx(On,{size:12,className:a.imageTraySearchIcon}),t.jsx("input",{type:"text",placeholder:"Search images...",value:It,onChange:e=>dn(e.target.value),className:a.imageTraySearchInput})]}),t.jsx("div",{className:`tf-scrollbar ${a.imageTrayList}`,children:un?t.jsx("div",{className:a.imageTrayState,children:"Loading images..."}):ba?t.jsx("div",{className:a.imageTrayStateError,children:ba}):ja.length===0?t.jsx("div",{className:a.imageTrayState,children:It.trim()?"No images match your search.":"No images found."}):ja.map(e=>{const n=d?.assetId===e.assetId,o=typeof e.attachmentCount=="number"&&Number.isFinite(e.attachmentCount)?Math.max(0,e.attachmentCount):0,i=typeof e.sessionCount=="number"&&Number.isFinite(e.sessionCount)?Math.max(0,e.sessionCount):0,c=o>1?`${o} tasks linked`:o===1?e.taskReferenceLabel||"1 task linked":"Unattached",h=String(e.displayName||e.originalFilename||"Image attachment").trim()||"Image attachment";return t.jsxs("button",{type:"button",className:`${a.imageTrayItem} ${n?a.imageTrayItemActive:""}`.trim(),onClick:()=>{yn(e)},title:h,children:[t.jsx("span",{className:a.imageTrayThumb,children:t.jsx("img",{src:e.path,alt:"",loading:"lazy"})}),t.jsxs("span",{className:a.imageTrayItemBody,children:[t.jsx("span",{className:a.imageTrayItemTitle,children:h}),t.jsx("span",{className:a.imageTrayItemTask,children:c}),t.jsxs("span",{className:a.imageTrayItemMeta,children:[t.jsxs("span",{className:a.imageTrayItemMetaDetails,children:[Po(e.sizeBytes),e.updatedAt?t.jsxs(t.Fragment,{children:[" · ",Bo(e.updatedAt)]}):null,i>0?t.jsxs(t.Fragment,{children:[" · ",i," session",i===1?"":"s"]}):null]}),e.imageReferenceLabel?t.jsx("span",{className:a.imageTrayItemReference,children:e.imageReferenceLabel}):null]})]})]},e.assetId)})})]}):null,t.jsxs("section",{className:`tf-surface-panel ${a.panel} ${a.sessionPanel}`,children:[t.jsx("div",{className:a.sessionContextBar,children:d?.taskId?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:a.sessionContextLeft,children:je?t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${a.ghostBtn} ${a.backToTaskBtn}`,onClick:()=>{M("back-to-task").then(e=>{e&&d.taskId&&je(d.taskId)})},"aria-label":"Back to task",title:"Back to task",children:t.jsx(zn,{size:16})}):t.jsx("div",{className:a.sessionContextSpacer,"aria-hidden":"true"})}),t.jsx("div",{className:a.sessionContextRight,children:t.jsx(Hn,{copied:bt,onClick:()=>{wn()},title:"Copy task id",ariaLabel:bt?"Copied task id":"Copy task id",label:Tt})})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:a.sessionContextLeft,children:t.jsx("span",{className:`tf-label-micro ${a.sessionContextLabel}`,children:"Unattached Image"})}),t.jsx("div",{className:a.sessionContextRight,children:t.jsx("div",{className:a.sessionContextSpacer,"aria-hidden":"true"})})]})}),t.jsxs("div",{className:a.panelHeader,children:[t.jsxs("div",{className:a.panelHeaderText,children:[t.jsx("div",{className:`tf-heading-card ${a.panelTitle}`,children:"Sessions"}),d?null:t.jsx("div",{className:"tf-text-secondary",children:"Open an image attachment to begin"})]}),t.jsx("div",{className:a.sessionActions,children:t.jsx("button",{type:"button",className:`tf-control-icon ${a.iconButton}`,onClick:()=>{Ea()},disabled:!d||V,"aria-label":"Create session",title:"Create session",children:t.jsx(Un,{size:16})})})]}),d?gt?t.jsx("div",{className:a.emptyState,children:t.jsx("p",{className:"tf-empty-copy",children:"Loading sessions…"})}):t.jsx("div",{className:`tf-scrollbar ${a.sessionList}`,children:mt.length===0?t.jsxs("div",{className:a.sessionEmptyState,children:[t.jsx("div",{className:`tf-heading-card ${a.sessionTitle}`,children:"No sessions yet"}),t.jsx("div",{className:`tf-text-secondary ${a.annotationSummary}`,children:"Create the first annotation session for this image."})]}):mt.map(e=>{const n=v===e.id,o=n&&At,i=Eo(n?Pe:e.globalInstruction),c=(n?Re:e.title)||"Untitled session";return t.jsxs("div",{className:`tf-surface-elevated ${a.sessionCard} ${n?a.sessionCardActive:""}`,ref:n?Sa:void 0,onBlur:o?h=>{const w=h.relatedTarget;w instanceof Node&&h.currentTarget.contains(w)||Ye(!1)}:void 0,children:[o?t.jsxs("div",{className:a.sessionCardBody,children:[t.jsxs("div",{className:a.sessionMeta,children:[t.jsx("label",{className:"tf-field-label",htmlFor:"annotated-session-title",children:"Session title"}),t.jsx("input",{id:"annotated-session-title",className:`tf-field-shell ${a.textInput} ${a.sessionTitleInput}`,value:Re,onChange:h=>{Xe(h.target.value),Y(600)},placeholder:"Session title"}),t.jsx("span",{className:`tf-text-meta ${a.sessionTimestamp}`,children:ra(e.updatedAt)})]}),Bt(e)?t.jsxs("div",{className:`tf-text-secondary ${a.sessionCreator}`,children:["Created by ",Bt(e)]}):null,t.jsxs("div",{className:a.sessionInstructionEditor,children:[t.jsx("label",{className:"tf-field-label",htmlFor:"annotated-session-instruction",children:"Session instruction"}),t.jsx("textarea",{id:"annotated-session-instruction",className:`tf-field-shell ${a.textArea} ${a.sessionInstructionField}`,value:Pe,onChange:h=>{Ve(h.target.value),Y(600)},placeholder:"Add overall instructions, context, or framing for this session."})]}),t.jsxs("div",{className:`tf-text-secondary ${a.annotationSummary}`,children:[e.annotations.length," annotation",e.annotations.length===1?"":"s"]})]}):t.jsxs("button",{type:"button",className:a.sessionCardButton,onClick:()=>{if(n){Ye(!0);return}M("session-switch").then(h=>{h&&($e(e.id),pe(e,d))})},"aria-pressed":n,children:[t.jsxs("div",{className:a.sessionMeta,children:[t.jsx("span",{className:`tf-heading-card ${a.sessionTitle}`,children:c}),t.jsx("span",{className:`tf-text-meta ${a.sessionTimestamp}`,children:ra(e.updatedAt)})]}),Bt(e)?t.jsxs("div",{className:`tf-text-secondary ${a.sessionCreator}`,children:["Created by ",Bt(e)]}):null,i?t.jsx("div",{className:`tf-text-secondary ${a.sessionInstructionPreview}`,children:i}):null,t.jsxs("div",{className:`tf-text-secondary ${a.annotationSummary}`,children:[e.annotations.length," annotation",e.annotations.length===1?"":"s"]})]}),n?t.jsx("div",{className:a.sessionCardFooter,children:t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:`tf-button-ghost ${a.toolRailButton} ${a.iconButton}`,onClick:()=>{vn()},disabled:V,"aria-label":"Duplicate session",title:`Duplicate session "${c}"`,children:t.jsx(sa,{size:16})}),t.jsx("button",{type:"button",className:`tf-button-ghost ${a.toolRailButton} ${a.iconButton}`,onClick:()=>{Sn()},disabled:V,"aria-label":"Delete session",title:`Delete session "${c}"`,children:t.jsx(Ga,{size:16})})]})}):null]},e.id)})}):t.jsxs("div",{className:a.emptyState,children:[t.jsx("strong",{className:"tf-empty-title",children:"No image selected"}),t.jsx("p",{className:"tf-empty-copy",children:"Open an image attachment from a task to start an annotated session."})]})]}),t.jsxs("section",{className:`tf-surface-panel ${a.panel} ${a.canvasPanel}`,children:[t.jsxs("div",{className:a.panelHeader,children:[t.jsxs("div",{className:a.canvasHeading,children:[t.jsx("div",{className:"tf-heading-card",children:d?.displayName||"Annotated attachment"}),t.jsx("div",{className:"tf-text-secondary",children:B?`${j.length} markers · ${Mn}`:"Pick or create a session"})]}),rt?t.jsx(Qn,{copied:xt,onClick:()=>{kn()},title:"Copy image reference",ariaLabel:xt?"Copied image reference":"Copy image reference",label:rt}):null]}),t.jsxs("div",{className:a.toolRail,children:[t.jsxs("div",{className:`${a.toolbarCluster} ${a.toolbarViewportCluster}`,children:[t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${a.ghostBtn} ${a.toolbarButton}`,onClick:()=>{_n()},disabled:!B||V||!Ca&&K!=="error","aria-label":V?"Saving session":"Save session",title:V?"Saving session":"Save session",children:t.jsx(Gn,{size:18})}),t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${a.ghostBtn} ${a.toolbarButton}`,onClick:()=>vt(!0),disabled:qe,"aria-label":"Open image",title:"Open image",children:t.jsx(Ua,{size:18})}),t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${a.ghostBtn} ${a.toolbarButton}`,onClick:()=>{pn()},disabled:wt,"aria-label":wt?"Pasting image":"Paste image",title:wt?"Pasting image":"Paste image",children:wt?t.jsx(Ka,{size:18,className:za.spin}):t.jsx(Kn,{size:18})}),t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${a.ghostBtn} ${a.toolbarButton}`,onClick:()=>{B&&hn()},disabled:!B||!Ca,"aria-label":"Reset unsaved changes",title:"Reset unsaved changes",children:t.jsx(Wn,{size:18})}),t.jsx("button",{type:"button",className:`tf-button-ghost ${a.toolRailButton} ${a.iconButton}`,onClick:Cn,disabled:!d||ue||P<=.25,"aria-label":"Zoom out",children:t.jsx(Yn,{size:18})}),t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${a.ghostBtn} ${a.toolbarButton}`,onClick:jn,disabled:!d||ue||P===1,"aria-label":`Reset zoom to 100 percent (currently ${Zt})`,title:`Reset zoom to 100% (currently ${Zt})`,children:t.jsx("span",{children:Zt})}),t.jsx("button",{type:"button",className:`tf-button-ghost ${a.toolRailButton} ${a.iconButton}`,onClick:Nn,disabled:!d||ue||P>=4,"aria-label":"Zoom in",children:t.jsx(Xn,{size:18})}),t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${a.toolBtn} ${a.toolbarButton} ${W?a.toolBtnActive:""}`,onClick:()=>Qe(e=>!e),disabled:!d||ue||!Oe,"aria-label":"Pan canvas",title:"Pan canvas",children:t.jsx(Vn,{size:18})})]}),t.jsx("span",{className:a.toolbarSeparator,"aria-hidden":"true"}),t.jsxs("div",{className:a.toolbarActions,children:[t.jsx("div",{className:a.toolbarSelectionActions,children:z?t.jsxs(t.Fragment,{children:[t.jsxs("div",{ref:ka,className:a.toolbarColorPicker,children:[t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${a.ghostBtn} ${a.toolbarButton} ${a.colorPickerButton}`,onClick:()=>pt(e=>!e),"aria-label":"Marker color","aria-expanded":ht,title:"Marker color",children:t.jsx("span",{className:a.colorPickerSwatch,style:{backgroundColor:qt},"aria-hidden":"true"})}),ht?t.jsx("div",{className:a.colorPickerPopover,role:"menu","aria-label":"Marker color options",children:$o.map(e=>t.jsx("button",{type:"button",className:`${a.colorOption} ${qt===e?a.colorOptionActive:""}`,style:{backgroundColor:e},onClick:()=>bn(e),"aria-label":`Use marker color ${e}`,"aria-pressed":qt===e},e))}):null]}),t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${a.ghostBtn} ${a.toolbarButton}`,onClick:ea,"aria-label":"Delete marker",title:"Delete selected marker",children:t.jsx(Ga,{size:18})}),t.jsx("div",{className:a.toolbarGeometryFields,"aria-label":"Marker geometry percent controls",children:zo(z).map(e=>t.jsxs("label",{className:a.toolbarGeometryField,children:[t.jsx("span",{className:`tf-text-meta ${a.toolbarGeometryLabel}`,children:e.label}),t.jsx("input",{className:`tf-field-shell ${a.toolbarGeometryInput}`,type:"number",min:0,max:100,step:.1,value:e.value,onChange:n=>{const o=Do(n.target.value);o!==null&&te(z.id,i=>Oo(i,e.key,o))},"aria-label":`${e.label} percent`})]},e.key))})]}):null}),t.jsxs("div",{className:a.toolbarUtilities,children:[t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${a.ghostBtn} ${a.payloadBtn} ${a.toolbarButton}`,onClick:In,disabled:!B||yt,"aria-label":yt?"Loading payload preview":"Preview payload",title:yt?"Loading payload preview":"Preview payload",children:t.jsx(ia,{size:18})}),t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${a.ghostBtn} ${a.toolbarButton}`,onClick:()=>pa(!0),"aria-label":"How to use marker tools",title:"How to use marker tools",children:t.jsx(la,{size:18})})]})]})]}),t.jsxs("div",{className:a.canvasWorkspace,children:[t.jsx("div",{className:a.canvasToolRail,"aria-label":"Annotation tools",children:Ya.map(e=>{const n=e.icon;return t.jsx("button",{type:"button",className:`tf-button-ghost ${a.toolRailButton} ${T===e.value?a.toolBtnActive:""}`,onClick:()=>xn(e.value),disabled:!d,title:e.label,"aria-label":`${e.label} tool. ${Pt[e.value].short}`,children:t.jsx(n,{size:18})},e.value)})}),t.jsx("div",{className:a.canvasMain,children:t.jsx("div",{ref:Ee,className:`tf-scrollbar ${a.canvasScroller}`,children:d?t.jsxs(t.Fragment,{children:[ue&&!Gt?t.jsx("div",{className:a.canvasStatusOverlay,"aria-live":"polite",children:t.jsxs("div",{className:a.canvasStatusCard,children:[t.jsx(Ka,{size:20,className:za.spinner}),t.jsx("span",{children:"Loading image…"})]})}):null,Gt?t.jsx("div",{className:a.canvasStatusOverlay,"aria-live":"polite",children:t.jsx("div",{className:a.canvasStatusCard,children:t.jsx("span",{children:"Image failed to load."})})}):null,t.jsx("div",{className:a.canvasFrame,children:t.jsxs("div",{className:a.canvasMedia,style:{width:y.width?`${y.width}px`:void 0,height:y.height?`${y.height}px`:void 0},children:[t.jsx("img",{ref:Wt,src:d.path,alt:d.displayName,className:a.canvasImage,onLoad:()=>{const e=Wt.current;tt({width:e?.naturalWidth||0,height:e?.naturalHeight||0}),Je(!1),Ze(!1)},onError:()=>{tt({width:0,height:0}),Je(!1),Ze(!0)}}),!ue&&!Gt&&B?t.jsxs("div",{ref:_a,className:`${a.overlay} ${T==="select"?a.overlaySelect:""} ${W?a.overlayPan:""}`,onPointerDown:Tn,onPointerMove:Rn,onPointerUp:e=>{$n(e),En()},"data-testid":"annotated-attachment-overlay",onPointerLeave:Pn,onPointerCancel:Bn,children:[t.jsx("svg",{className:a.overlaySvg,viewBox:Jt,preserveAspectRatio:"none","aria-hidden":"true",children:j.filter(e=>e.kind==="arrow").map(e=>{const n=Ao(e,y),o=oa(e),i=S===e.id;return t.jsxs(aa.Fragment,{children:[i?t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:n.shaftX1,y1:n.shaftY1,x2:n.shaftX2,y2:n.shaftY2,stroke:"color-mix(in srgb, var(--surface-elevated) 92%, transparent)",strokeWidth:14,strokeLinecap:"round"}),t.jsx("polygon",{points:n.headPoints,fill:o,stroke:"color-mix(in srgb, var(--surface-elevated) 92%, transparent)",strokeWidth:4,strokeLinejoin:"round"})]}):null,t.jsx("line",{x1:n.shaftX1,y1:n.shaftY1,x2:n.shaftX2,y2:n.shaftY2,stroke:o,strokeWidth:i?10:6,strokeLinecap:"round"}),t.jsx("polygon",{points:n.headPoints,fill:o})]},e.id)})}),t.jsx("svg",{className:a.overlayHitLayer,viewBox:Jt,preserveAspectRatio:"none",children:j.filter(e=>e.kind==="arrow").map(e=>t.jsxs(aa.Fragment,{children:[t.jsx("line",{x1:e.x*y.width,y1:e.y*y.height,x2:e.x2*y.width,y2:e.y2*y.height,className:a.arrowHitArea,"data-testid":`annotated-arrow-hit-${e.id}`,"aria-label":`Arrow marker ${Qt.get(e.id)||0}`,onPointerDown:n=>Fa(n,e),onClick:n=>{n.stopPropagation(),F(e.id)}}),S===e.id?t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:e.x*y.width,cy:e.y*y.height,r:De.hitRadius,className:a.canvasHandleHit,role:"button",tabIndex:0,"aria-label":"Move arrow tail",onPointerDown:n=>Ha(n,e,"tail")}),t.jsx("circle",{cx:e.x*y.width,cy:e.y*y.height,r:De.visibleRadius,className:a.canvasHandleVisible,"aria-hidden":"true"}),t.jsx("circle",{cx:e.x2*y.width,cy:e.y2*y.height,r:De.hitRadius,className:a.canvasHandleHit,role:"button",tabIndex:0,"aria-label":"Move arrow tip",onPointerDown:n=>Ha(n,e,"tip")}),t.jsx("circle",{cx:e.x2*y.width,cy:e.y2*y.height,r:De.visibleRadius,className:a.canvasHandleVisible,"aria-hidden":"true"})]}):null]},`hit-${e.id}`))}),j.filter(e=>e.kind==="arrow").map(e=>t.jsx("div",{className:`${a.annotationNumberBadge} ${a.arrowNumberBadge}`,style:{left:`${(e.x+e.x2)/2*100}%`,top:`${(e.y+e.y2)/2*100}%`,backgroundColor:oa(e)},"aria-hidden":"true",children:Qt.get(e.id)||0},`arrow-number-${e.id}`)),j.filter(e=>e.kind!=="arrow").map(e=>{const n=oa(e),o=Qt.get(e.id)||0,i={onPointerDown:c=>Fa(c,e),onClick:c=>{c.stopPropagation(),F(e.id)}};return e.kind==="pin"?t.jsx("button",{type:"button",...i,className:`${a.pin} ${S===e.id?a.selected:""}`,style:{left:`${e.x*100}%`,top:`${e.y*100}%`,backgroundColor:n},children:o},e.id):e.kind==="text-note"?t.jsx("button",{type:"button",...i,className:`${a.note} ${S===e.id?a.selected:""}`,style:{left:`${e.x*100}%`,top:`${e.y*100}%`,backgroundColor:n},children:o},e.id):t.jsxs("div",{className:`${a.box} ${S===e.id?a.selected:""}`,style:{left:`${e.x*100}%`,top:`${e.y*100}%`,width:`${e.width*100}%`,height:`${e.height*100}%`,borderColor:n},children:[t.jsx("span",{className:`${a.annotationNumberBadge} ${a.boxNumberBadge}`,style:{backgroundColor:n},"aria-hidden":"true",children:o}),t.jsx("button",{type:"button",...i,className:a.boxSurface,"aria-label":`Box marker ${o}`})]},e.id)}),t.jsx("svg",{className:a.overlaySvg,viewBox:Jt,preserveAspectRatio:"none",children:j.filter(e=>e.kind==="box"&&S===e.id).map(e=>t.jsxs(aa.Fragment,{children:[t.jsx("circle",{cx:(e.x+e.width)*y.width,cy:(e.y+e.height)*y.height,r:De.hitRadius,className:`${a.canvasHandleHit} ${a.canvasResizeHandleHit}`,role:"button",tabIndex:0,"aria-label":"Resize box marker",onPointerDown:n=>An(n,e)}),t.jsx("circle",{cx:(e.x+e.width)*y.width,cy:(e.y+e.height)*y.height,r:De.visibleRadius,className:a.canvasHandleVisible,"aria-hidden":"true"})]},`box-handle-${e.id}`))})]}):null]})})]}):t.jsx("div",{className:a.emptyState,children:t.jsx("p",{className:"tf-empty-copy",children:"Select an image attachment to annotate."})})})})]}),t.jsxs("div",{className:a.statusBar,children:[t.jsx("span",{children:K==="error"?"Save failed. Retry now.":K==="saving"||K==="pending"?"Saving…":"Saved"}),ma?t.jsx("span",{children:ma}):t.jsx("span",{children:B?W?"Drag on the image to pan.":T==="select"?"Select a marker to edit it.":`Click on the image to place a ${T}.`:"Create a session to begin placing markers on this image."}),d&&!B&&sn?t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${a.ghostBtn} ${a.toolbarButton}`,onClick:()=>{Ea()},disabled:V||gt,children:V?"Creating…":"Create one now"}):null]})]}),t.jsx("section",{className:`tf-surface-panel ${a.panel} ${a.detailPanel}`,children:B?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:a.panelHeader,children:[t.jsxs("div",{className:a.panelHeaderText,children:[t.jsx("div",{className:`tf-heading-card ${a.panelTitle}`,children:"Markers"}),t.jsxs("div",{className:"tf-text-secondary",children:[j.length," in this session"]})]}),t.jsxs("div",{className:a.sessionActions,children:[t.jsx("button",{type:"button",className:`tf-control-icon ${a.iconButton}`,onClick:()=>La("up"),disabled:!z||Vt<=0,"aria-label":"Move marker up",children:t.jsx(Jn,{size:16})}),t.jsx("button",{type:"button",className:`tf-control-icon ${a.iconButton}`,onClick:()=>La("down"),disabled:!z||Vt===-1||Vt>=j.length-1,"aria-label":"Move marker down",children:t.jsx(Zn,{size:16})})]})]}),t.jsx("div",{className:`tf-scrollbar ${a.annotationList}`,children:j.length===0?t.jsx("div",{className:a.detailEmpty,children:t.jsx("p",{className:"tf-empty-copy",children:"Add a marker on the image to begin."})}):j.map((e,n)=>{const o=Co[e.kind],i=jo[e.kind],c=`${i} ${n+1}`,h=To[e.markerType||ce],w=Wa.find(m=>m.value===(e.markerType||ce))?.label||"Review",u=S===e.id;return t.jsxs("div",{className:`tf-surface-elevated ${a.annotationCard} ${u?a.annotationCardActive:""}`,children:[t.jsx("button",{type:"button",className:a.annotationCardButton,onClick:()=>F(e.id),"aria-label":i,children:t.jsxs("div",{className:a.annotationMeta,children:[t.jsx("span",{className:`tf-heading-card ${a.annotationTitle}`,children:c}),t.jsx("span",{className:`tf-text-meta ${a.annotationKind}`,"aria-hidden":"true",children:t.jsx(o,{size:16})})]})}),u?t.jsxs("div",{className:a.annotationInstructionEditor,children:[t.jsx("label",{className:"tf-field-label",htmlFor:"annotated-marker-instruction",children:"Marker instruction"}),t.jsx("textarea",{id:"annotated-marker-instruction",ref:u?Ia:null,className:`tf-field-shell ${a.textArea} ${a.annotationInstructionField}`,value:e.instruction,onChange:m=>{te(e.id,_=>({..._,instruction:m.target.value}),600)},onBlur:()=>{M("text")},placeholder:"What should the AI focus on for this marker?"}),t.jsxs("div",{className:a.annotationTypeField,children:[t.jsx("label",{className:"tf-field-label",htmlFor:"annotated-marker-type",children:"Instruction type"}),t.jsx("select",{id:"annotated-marker-type",className:`tf-field-shell ${a.select}`,value:e.markerType||ce,onChange:m=>{te(e.id,_=>Mo(_,m.target.value))},children:Wa.map(m=>t.jsx("option",{value:m.value,children:m.label},m.value))})]})]}):t.jsx("button",{type:"button",className:a.annotationInstructionButton,onClick:()=>F(e.id),"aria-label":`Edit ${i} instruction`,children:t.jsxs("div",{className:a.annotationInstructionEditor,children:[t.jsx("div",{className:`tf-text-secondary ${a.annotationInstructionPreview}`,children:e.instruction.trim()||"No marker instruction yet."}),t.jsx("div",{className:a.annotationPreviewFooter,children:t.jsx("span",{className:`tf-text-meta ${a.annotationInstructionTypeIcon}`,"aria-label":`Instruction type: ${w}`,title:w,children:t.jsx(h,{size:16})})})]})})]},e.id)})})]}):t.jsxs("div",{className:a.emptyState,children:[t.jsx("strong",{className:"tf-empty-title",children:"No active session"}),t.jsx("p",{className:"tf-empty-copy",children:"Create or select a session to edit annotations."})]})}),t.jsx(na,{isOpen:ln,onClose:()=>{qe||(vt(!1),_t(""))},title:"Open Image",size:"sm",children:t.jsxs("form",{className:a.openImageModalBody,onSubmit:e=>{e.preventDefault(),gn()},children:[t.jsx("label",{className:"tf-field-label",htmlFor:"annotated-open-image-reference",children:"Image reference number"}),t.jsx("input",{id:"annotated-open-image-reference",className:`tf-field-shell ${a.textInput} ${a.openImageField}`,value:zt,onChange:e=>_t(e.target.value),placeholder:"I-24",autoFocus:!0}),t.jsxs("div",{className:a.openImageActions,children:[t.jsx("button",{type:"button",className:"tf-button-ghost tf-button-compact",onClick:()=>{vt(!1),_t("")},disabled:qe,children:"Cancel"}),t.jsx("button",{type:"submit",className:"tf-button-primary tf-button-compact",disabled:qe,children:qe?"Opening…":"Open"})]})]})}),t.jsx(na,{isOpen:on,onClose:()=>pa(!1),title:"How To Use Markers",size:"md",children:t.jsx("div",{className:a.markerHelpModalBody,children:Ya.filter(e=>e.value!=="select").map(e=>t.jsxs("div",{className:`tf-surface-inset ${a.markerHelpItem}`,children:[t.jsxs("div",{className:a.markerHelpHeader,children:[t.jsx("strong",{className:"tf-heading-card",children:e.label}),t.jsx("span",{className:"tf-text-meta",children:Pt[e.value].short})]}),t.jsx("p",{className:"tf-text-secondary",children:Pt[e.value].detail}),t.jsx("p",{className:`tf-text-body ${a.markerHelpExample}`,children:Pt[e.value].example})]},e.value))})}),t.jsx(na,{isOpen:rn,onClose:()=>Ft(!1),title:"AI Payload",size:"lg",children:t.jsxs("div",{className:a.payloadModalBody,children:[t.jsxs("div",{className:a.payloadModalToolbar,children:[t.jsxs("div",{className:a.payloadViewToggle,children:[t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${a.toolBtn} ${Ht==="json"?a.toolBtnActive:""}`,onClick:()=>ha("json"),children:"JSON"}),t.jsx("button",{type:"button",className:`tf-button-ghost tf-button-compact ${a.toolBtn} ${Ht==="brief"?a.toolBtnActive:""}`,onClick:()=>ha("brief"),children:"AI Brief"})]}),t.jsxs("div",{className:a.payloadModalActions,children:[t.jsxs("button",{type:"button",className:`tf-button-ghost tf-button-compact ${a.ghostBtn}`,onClick:()=>{Ma("json")},disabled:!oe,"aria-label":de==="json"?"Copied JSON":"Copy JSON",title:de==="json"?"Copied JSON":"Copy JSON",children:[de==="json"?t.jsx(ca,{size:16}):t.jsx(sa,{size:16}),t.jsx("span",{children:"JSON"})]}),t.jsxs("button",{type:"button",className:`tf-button-ghost tf-button-compact ${a.ghostBtn}`,onClick:()=>{Ma("brief")},disabled:!oe,"aria-label":de==="brief"?"Copied AI Brief":"Copy AI Brief",title:de==="brief"?"Copied AI Brief":"Copy AI Brief",children:[de==="brief"?t.jsx(ca,{size:16}):t.jsx(sa,{size:16}),t.jsx("span",{children:"AI Brief"})]})]})]}),yt?t.jsx("div",{className:a.detailEmpty,children:t.jsx("p",{className:"tf-empty-copy",children:"Loading payload…"})}):oe?t.jsx("pre",{className:`tf-surface-inset tf-scrollbar ${a.payloadModalPreview}`,children:Ht==="json"?JSON.stringify(oe,null,2):Va(oe)}):t.jsx("div",{className:a.detailEmpty,children:t.jsx("p",{className:"tf-empty-copy",children:"Load a payload preview to inspect the current session contract."})})]})})]})}export{Qo as AnnotatedAttachmentWorkspaceShell};
|
package/dist/ui/assets/{ContextAttachmentManager-B3hESx6y.js → ContextAttachmentManager-AmEny3eI.js}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as y,j as e}from"./vendor-react-CKJs5o3c.js";import{t as s,Z as Et,_ as St,$ as pt,a0 as dt,a1 as Lt}from"./index-
|
|
1
|
+
import{r as y,j as e}from"./vendor-react-CKJs5o3c.js";import{t as s,Z as Et,_ as St,$ as pt,a0 as dt,a1 as Lt}from"./index-CGDQY0nN.js";import{g as Dt}from"./documentReferences-Ca2P--i5.js";import{h as Pt,aM as K,c as X,m as Ut,aN as $t,aI as ut,T as ht,ax as Ft}from"./vendor-icons-CLnehDTw.js";import"./vendor-markdown-BUxTU7dS.js";import"./vendor-dnd-DRzYolkg.js";import"./vendor-router-BbWMxlnO.js";const gt=[".png",".jpg",".jpeg",".webp",".gif",".pdf",".txt",".md",".csv",".json",".doc",".docx",".html",".js",".ts",".tsx",".css",".py",".java",".go",".rs",".sh"].join(","),Rt=new Set(["image/png","image/jpeg","image/webp"]),zt=new Set(gt.split(",").map(o=>o.trim().toLowerCase())),Ot=10*1024*1024,_t=3500;function xt(o){const c=o.trim().toLowerCase(),m=c.lastIndexOf(".");return m===-1?"":c.slice(m)}function J(o){if(o.length===0)return"";const c=o.slice(0,3).join(", "),m=o.length-3;return m>0?`${c}, +${m} more`:c}function Bt(o){return`${o.name.trim().toLowerCase()}::${o.size}::${o.lastModified}`}function Mt(o){return new Promise((c,m)=>{const g=new FileReader;g.onload=()=>c(String(g.result||"")),g.onerror=()=>m(g.error||new Error("Failed to read file")),g.readAsDataURL(o)})}function L(o){return/\.(png|jpe?g|webp|gif)(\?|#|$)/i.test(o)}function Ht(o){const c=o.types;if(!c)return null;for(const m of Array.from(c)){const g=String(m||"").trim().toLowerCase();if(Rt.has(g))return g}return null}function ft(o,c){const m=o.includes("?")?"&":"?";return`${o}${m}download=1&filename=${encodeURIComponent(c)}`}function mt(o){return typeof o=="string"?o.split("/").pop()||"Context file":o.displayName||o.originalFilename||o.caption||o.fsPath||o.path.split("/").pop()||"Context file"}function Kt(o){const c=typeof o=="string"?[o]:[o.originalFilename,o.displayName,o.caption,o.fsPath,o.path];for(const g of c){if(!g)continue;const D=xt(g);if(D)return D.replace(".","").slice(0,5).toUpperCase()}const m=typeof o=="string"?o:o.path;return/^https?:\/\//i.test(m)?"LINK":"FILE"}function Qt(o){const{ownerType:c="task",ownerId:m,ownerReferenceLabel:g,workspaceId:D,attachments:N,onAddAttachment:Y,onRemoveAttachment:G,onUpdateAttachmentCaption:W}=o,v=y.useRef(null),[P,Z]=y.useState(!1),[V,C]=y.useState(null),[$,q]=y.useState(""),[F,A]=y.useState(null),[T,b]=y.useState(null),[R,yt]=y.useState(!1),[wt,z]=y.useState(!1),[Xt,O]=y.useState(0),I=y.useRef(new Set),Q=y.useRef(new Set),tt=t=>(t||"").trim(),U=(t,n)=>{const a=[],r=tt(t),p=tt(n);return r&&a.push(`path:${r}`),p&&a.push(`fs:${p}`),a},et=y.useMemo(()=>{const t=new Set;return N.forEach(n=>{if(typeof n=="string"){U(n).forEach(a=>t.add(a));return}U(n.path,n.fsPath).forEach(a=>t.add(a))}),t},[N]);y.useEffect(()=>{I.current=new Set(et)},[et]);const nt=(t,n)=>n.some(a=>t.has(a)),at=(t,n)=>n.forEach(a=>t.add(a)),E=String(D||"").trim(),j=String(m||"").trim(),st=c==="initiative"?"initiative":c==="workstream"?"workstream":"task",_={ownerType:c,ownerId:j||null,taskId:c==="task"&&j||null},B=(t="application/json")=>{const n={"Content-Type":t};return E&&(n["x-taskforce-workspace-id"]=E),n},ot=(t,n=!0,a=I.current)=>{const r=t.trim();if(!r||!/^https?:\/\//i.test(r))return"invalid";const i=r,f=U(i);if(nt(a,f))return"duplicate";const u=r.split(/[\\/]/).pop()||r;return Y({path:i,caption:u,timestamp:new Date().toISOString()}),at(a,f),n&&q(""),A(null),"added"};y.useEffect(()=>{if(!T)return;const t=window.setTimeout(()=>{b(null)},_t);return()=>window.clearTimeout(t)},[T]);const rt=async t=>{if(t.length===0)return;C(null),b(null);const n=t,a=[],r=[],p=[],i=[],f=new Set(Q.current);n.forEach(x=>{const h=xt(x.name);if(!zt.has(h)){a.push(x.name);return}if(x.size>Ot){r.push(x.name);return}const S=Bt(x);if(f.has(S)){p.push(x.name);return}f.add(S),i.push({file:x,fingerprint:S})});const u=[];if(a.length>0&&u.push(`${a.length} unsupported file${a.length===1?"":"s"} skipped: ${J(a)}.`),r.length>0&&u.push(`${r.length} file${r.length===1?"":"s"} over 10 MB skipped: ${J(r)}.`),p.length>0&&u.push(`${p.length} local duplicate file${p.length===1?"":"s"} skipped before upload: ${J(p)}.`),i.length===0){u.length>0&&b(u.join(" ")),v.current&&(v.current.value="");return}Z(!0);const k=new Set(I.current);let d=0;try{for(const{file:h,fingerprint:S}of i){let l=null;const lt=await fetch("/api/taskforce/context-upload/init",{method:"POST",headers:B(),body:JSON.stringify({originalName:h.name,mimeType:h.type||"application/octet-stream",size:h.size,..._,workspaceId:E||null})});if(lt.ok){const w=await lt.json();if(w?.success&&typeof w?.uploadUrl=="string"&&typeof w?.path=="string"){if(!(await fetch(w.uploadUrl,{method:String(w.method||"PUT"),headers:w.headers||{"Content-Type":h.type||"application/octet-stream"},body:h})).ok)throw new Error(`Upload failed for ${h.name}`);const H=await fetch("/api/taskforce/context-upload/finalize",{method:"POST",headers:B(),body:JSON.stringify({relativePath:w.relativePath,mimeType:h.type||"application/octet-stream",originalName:h.name,size:h.size,..._,workspaceId:E||null})});if(!H.ok){const It=await H.json().catch(()=>({}));throw new Error(It?.error||`Upload failed for ${h.name}`)}l=await H.json().catch(()=>null)}else w?.success&&typeof w?.path=="string"&&(l=w)}if(!l){const w=await Mt(h),M=await fetch("/api/taskforce/context-upload",{method:"POST",headers:B(),body:JSON.stringify({file:w,originalName:h.name,..._,workspaceId:E||null})});if(!M.ok)throw new Error(`Upload failed for ${h.name}`);l=await M.json()}if(!l?.success||!l?.path)throw new Error(`Upload failed for ${h.name}`);const ct=U(l.path,l.fsPath);if(nt(k,ct)){d+=1;continue}Y({path:l.path,fsPath:l.fsPath,caption:typeof l.caption=="string"&&l.caption.trim().length>0?l.caption:h.name,displayName:typeof l.displayName=="string"?l.displayName:void 0,originalFilename:typeof l.originalFilename=="string"?l.originalFilename:h.name,assetId:typeof l.assetId=="string"?l.assetId:void 0,referenceNumber:typeof l.referenceNumber=="number"?l.referenceNumber:null,referenceLabel:typeof l.referenceLabel=="string"?l.referenceLabel:void 0,taskId:c==="task"&&typeof l.taskId=="string"?l.taskId:null,timestamp:typeof l.timestamp=="string"&&l.timestamp.trim().length>0?l.timestamp:new Date().toISOString()}),Lt({workspaceId:E||"default",ownerType:c,ownerId:j||null,taskId:c==="task"&&j||null,reason:"upload"}),at(k,ct),Q.current.add(S)}const x=[...u];d>0&&x.push(`${d} duplicate file${d===1?"":"s"} skipped.`),b(x.length>0?x.join(" "):null),I.current=k}catch(x){C(x instanceof Error?x.message:"Failed to upload context file")}finally{Z(!1),v.current&&(v.current.value="")}},it=async t=>{!t||t.length===0||await rt(Array.from(t))},kt=async()=>{if(C(null),b(null),!navigator.clipboard||typeof navigator.clipboard.read!="function"){C("Clipboard image paste is not available in this browser.");return}try{const t=await navigator.clipboard.read(),n=[];for(const a of t){const r=Ht(a);if(!r)continue;const p=await a.getType(r),i=r.toLowerCase()==="image/png"?"png":r.toLowerCase()==="image/webp"?"webp":"jpg";n.push(new globalThis.File([p],`pasted-image-${Date.now()}.${i}`,{type:r}))}if(n.length===0){C("Clipboard does not currently contain a supported image.");return}await rt(n)}catch(t){C(t?.message||"Failed to read an image from the clipboard.")}},bt=t=>{const n=new Set,a=t.dataTransfer.getData("text/uri-list")||"",r=t.dataTransfer.getData("text/plain")||"",p=`${a}
|
|
2
2
|
${r}`.split(`
|
|
3
3
|
`).map(i=>i.trim()).filter(i=>!!i&&!i.startsWith("#"));for(const i of p){if(/^file:\/\//i.test(i)){try{const f=new URL(i),u=decodeURIComponent(f.pathname||"").trim();u&&n.add(u)}catch{}continue}n.add(i)}return Array.from(n)},jt=t=>{if(t.preventDefault(),t.stopPropagation(),z(!1),O(0),C(null),A(null),b(null),t.dataTransfer.files&&t.dataTransfer.files.length>0){it(t.dataTransfer.files);return}const n=bt(t);if(n.length===0){A("Drop a file or URL.");return}const a=new Set(I.current);let r=0,p=0,i=0;n.forEach(u=>{const k=ot(u,!1,a);k==="duplicate"&&(r+=1),k==="added"&&(p+=1),k==="invalid"&&(i+=1)});const f=[];r>0&&f.push(`${r} duplicate link${r===1?"":"s"} skipped.`),i>0&&f.push(`${i} local path${i===1?"":"s"} skipped. Upload files to attach them, or drop an http(s) URL to link.`),b(f.length>0?f.join(" "):p>0?null:T),I.current=a},Nt=t=>{t.preventDefault(),t.stopPropagation(),O(n=>n+1),z(!0)},Ct=t=>{t.preventDefault(),t.stopPropagation(),O(n=>{const a=Math.max(0,n-1);return a===0&&z(!1),a})},vt=t=>{t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect="copy"},At=N.filter(t=>{const n=typeof t=="string"?t:t.path;return L(n)}),Tt=N.filter(t=>{const n=typeof t=="string"?t:t.path;return!L(n)});return e.jsxs("div",{className:s.specialistSection,children:[e.jsx(Et,{label:"Context Documents",count:N.length,expanded:R,expandedTitle:"Hide context documents",collapsedTitle:"Show context documents",onToggle:()=>yt(!R)}),R&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:s.settingsHint,children:["Upload files into ",st," context storage, or add an external http(s) URL."]}),e.jsxs("div",{className:s.contextUploadPanel,children:[e.jsxs("div",{className:s.contextUploadActions,children:[e.jsxs("button",{type:"button",className:s.secondaryHeaderBtn,onClick:()=>v.current?.click(),disabled:P,children:[P?e.jsx(Pt,{size:12,className:s.spinner}):e.jsx(K,{size:12}),P?"Uploading...":"Upload File"]}),e.jsxs("button",{type:"button",className:s.secondaryHeaderBtn,onClick:()=>{kt()},disabled:P,children:[e.jsx(X,{size:12}),"Paste Image from Clipboard"]})]}),e.jsx("input",{ref:v,type:"file",accept:gt,multiple:!0,className:s.hiddenInput,onChange:t=>{it(t.target.files)}}),V&&e.jsx("div",{className:s.error,children:V}),e.jsxs("div",{className:s.contextLinkRow,children:[e.jsx("input",{type:"text",className:s.input,placeholder:"Add external URL (https://...)",value:$,onChange:t=>{q(t.target.value),F&&A(null),T&&b(null)}}),e.jsx("button",{type:"button",className:s.secondaryHeaderBtn,onClick:()=>{if(!$.trim()){A("Enter an http(s) URL to link.");return}const t=ot($,!0);if(t==="invalid"){A("Only external http(s) URLs can be linked here. Upload files to attach them.");return}t==="duplicate"?b(`Link already exists in ${st} context.`):t==="added"&&b(null)},children:"Add URL"})]}),e.jsxs("div",{className:`${s.contextDropzone} ${wt?s.contextDropzoneActive:""}`,onDragEnter:Nt,onDragLeave:Ct,onDragOver:vt,onDrop:jt,children:[e.jsx(K,{size:14}),e.jsx("span",{children:"Drop files or URLs here"})]})]}),T&&e.jsx("div",{className:s.contextNotice,children:T}),F&&e.jsx("div",{className:s.error,children:F}),At.length>0&&e.jsx("div",{className:s.attachmentGrid,children:N.map((t,n)=>{const a=typeof t=="string"?t:t.path;if(!L(a))return null;const r=typeof t=="string"?void 0:t.fsPath,p=typeof t=="string"?"":t.caption||"",i=mt(t),f=L(a),u=/^https?:\/\//i.test(a),k=c==="task"&&St(t);return e.jsxs("div",{className:s.attachmentCard,children:[e.jsxs("div",{className:s.attachmentPreviewContainer,children:[f?e.jsx("img",{src:a,alt:p||`Context file ${n}`,onClick:()=>{c==="task"&&pt(t,{taskId:j,taskReferenceLabel:g})||window.open(a,"_blank")},onError:d=>{d.target.style.display="none",d.target.parentElement.classList.add(s.brokenImage)}}):e.jsxs("button",{type:"button",className:s.contextFileLink,onClick:()=>{const d=c==="task"?typeof t=="string"?{path:t,taskId:j}:{...t,taskId:j}:t;dt(d,r)||window.open(a,"_blank")},title:"Open file",children:[e.jsx(K,{size:16}),e.jsx("span",{children:p||r||a.split("/").pop()||"Context file"})]}),e.jsxs("div",{className:s.brokenImagePlaceholder,children:[e.jsx(Ut,{size:16}),e.jsx("span",{children:"Preview unavailable"})]}),e.jsxs("div",{className:s.attachmentActions,children:[k&&e.jsx("button",{type:"button",className:s.attachmentActionBtn,onClick:d=>{d.stopPropagation(),pt(t,{taskId:j,taskReferenceLabel:g})},title:"Annotate",children:e.jsx($t,{size:12})}),r&&e.jsx("button",{type:"button",className:s.attachmentActionBtn,onClick:d=>{d.stopPropagation(),navigator.clipboard.writeText(r)},title:`Copy path: ${r}`,children:e.jsx(X,{size:12})}),!u&&e.jsx("button",{type:"button",className:s.attachmentActionBtn,onClick:d=>{d.stopPropagation(),window.open(ft(a,p||i),"_blank")},title:"Download",children:e.jsx(ut,{size:12})}),e.jsx("button",{type:"button",className:s.attachmentActionBtn,onClick:d=>{d.stopPropagation(),G(n)},title:"Delete",children:e.jsx(ht,{size:12})})]})]}),e.jsx("input",{type:"text",className:s.attachmentCaptionInput,placeholder:"Add a label...",value:p,onChange:d=>W(n,d.target.value)})]},n)})}),Tt.length>0&&e.jsx("div",{className:s.documentAttachmentList,children:N.map((t,n)=>{const a=typeof t=="string"?t:t.path;if(L(a))return null;const r=typeof t=="string"?void 0:t.fsPath,p=typeof t=="string"?"":t.caption||"",i=mt(t),f=Kt(t),u=typeof t=="string"?"":Dt(t),k=/^https?:\/\//i.test(a);return e.jsxs("div",{className:s.documentAttachmentItem,children:[e.jsxs("div",{className:s.documentAttachmentRow,children:[e.jsxs("button",{type:"button",className:s.documentAttachmentLink,onClick:()=>{const d=c==="task"?typeof t=="string"?{path:t,taskId:j}:{...t,taskId:j}:t;dt(d,r)||window.open(a,"_blank")},title:i,children:[e.jsxs("span",{className:s.documentAttachmentMain,children:[e.jsx("span",{className:s.documentAttachmentIcon,"aria-hidden":"true",children:e.jsx(Ft,{size:13})}),e.jsxs("span",{className:s.documentAttachmentText,children:[e.jsx("span",{className:s.documentAttachmentName,children:i}),u&&e.jsx("span",{className:s.taskIdBadge,children:u})]})]}),e.jsx("span",{className:s.documentAttachmentType,children:f})]}),e.jsxs("div",{className:s.documentAttachmentActions,children:[r&&e.jsx("button",{type:"button",className:s.documentAttachmentActionBtn,onClick:()=>{navigator.clipboard.writeText(r)},title:`Copy path: ${r}`,children:e.jsx(X,{size:12})}),!k&&e.jsx("button",{type:"button",className:s.documentAttachmentActionBtn,onClick:()=>{window.open(ft(a,p||i),"_blank")},title:"Download",children:e.jsx(ut,{size:12})}),e.jsx("button",{type:"button",className:s.documentAttachmentActionBtn,onClick:()=>G(n),title:"Delete",children:e.jsx(ht,{size:12})})]})]}),e.jsx("input",{type:"text",className:s.documentAttachmentCaptionInput,placeholder:"Add a label...",value:p,onChange:d=>W(n,d.target.value)})]},n)})})]})]})}export{Qt as ContextAttachmentManager};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e,r as i,s as an,R as ve}from"./vendor-react-CKJs5o3c.js";import{h as $e,f as P,t as L,i as yt,j as gt,k as sn,R as rn,m as M,M as on,n as xt,o as cn,q as ln}from"./index-rB9GGUCz.js";import{q as dn,x as un,w as mn,ax as hn,ay as pn,y as qe,i as fn,Z as Qe,X as Rt,az as _t,e as Ye,aA as At,aB as vn,aC as wn,a as kn,j as yn,aD as gn,aE as xn,aF as _n,t as Ee,aG as bn,r as Sn,p as jn,aH as bt,aw as Ve,aI as Cn,aJ as Nn,T as Tn,R as En,aK as Rn,B as An,U as In,S as $n}from"./vendor-icons-CLnehDTw.js";import{g as Ln}from"./documentReferences-CKk8ylqA.js";import{s as Dn,M as Re,r as Ae}from"./vendor-markdown-BUxTU7dS.js";import"./vendor-dnd-DRzYolkg.js";import"./vendor-router-BbWMxlnO.js";const Bn="_index_1sp0v_1",Mn="_header_1sp0v_8",Pn="_title_1sp0v_23",zn="_search_1sp0v_35",Fn="_searchIcon_1sp0v_41",On="_searchInput_1sp0v_50",Hn="_list_1sp0v_67",Wn="_state_1sp0v_79",Gn="_stateError_1sp0v_87",Kn="_item_1sp0v_94",Un="_itemActive_1sp0v_116",Jn="_itemIcon_1sp0v_126",Vn="_itemBody_1sp0v_136",qn="_itemTitle_1sp0v_144",Qn="_itemTask_1sp0v_156",Yn="_itemBadge_1sp0v_167",Xn="_itemMeta_1sp0v_180",Zn="_itemMetaDetails_1sp0v_191",ea="_itemMetaReference_1sp0v_198",A={index:Bn,header:Mn,title:Pn,search:zn,searchIcon:Fn,searchInput:On,list:Hn,state:Wn,stateError:Gn,item:Kn,itemActive:Un,itemIcon:Jn,itemBody:Vn,itemTitle:qn,itemTask:Qn,itemBadge:Yn,itemMeta:Xn,itemMetaDetails:Zn,itemMetaReference:ea};function Xe(t){let l=t;try{l=decodeURIComponent(t)}catch{l=t}return l.trim().replace(/\\/g,"/").replace(/^\/+/,"").replace(/^\.\//,"").replace(/^\.taskforce\//,"")}function ta(t,l){return!!(t===l||t.endsWith(`/${l}`)||l.endsWith(`/${t}`))}function St(t){const l=Xe(String(t||""));if(!l)return null;const m=l.match(/(^|\/)(asset-[a-f0-9]{32})(?=[^/]*$)/i);return m?.[2]?m[2].toLowerCase():null}function et(t){return t.attachmentState==="attached"||t.attachmentState==="unattached"?t.attachmentState:(typeof t.attachmentCount=="number"&&Number.isFinite(t.attachmentCount)?t.attachmentCount:0)>0||t.taskId?"attached":"unattached"}function na(t,l,m,s){const c=l.trim().toLowerCase();return t.filter(u=>{const y=`${$e(u)} ${u.originalFilename||""}`.toLowerCase(),v=c.length===0||y.includes(c),b=m.length===0||m.includes(u.docType),h=et(u),g=s.length===0||s.includes(h);return v&&b&&g})}function aa({docType:t}){switch(t){case"implementation-plan":return e.jsx(fn,{size:13});case"review":return e.jsx(qe,{size:13});case"walkthrough":return e.jsx(pn,{size:13});default:return e.jsx(hn,{size:13})}}function sa(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/(1024*1024)).toFixed(1)}MB`}function ra(t){if(!t)return"";const l=new Date(t),s=new Date().getTime()-l.getTime(),c=Math.floor(s/(1e3*60*60*24));return c===0?"Today":c===1?"Yesterday":c<7?`${c}d ago`:c<30?`${Math.floor(c/7)}w ago`:l.toLocaleDateString()}function ia(t,l){t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),l())}function oa({documents:t,selectedDocId:l,loading:m,error:s,searchQuery:c,taskById:u,onSearchChange:w,onSelect:y,onCloseTray:v,hasActiveFilters:b}){return e.jsxs("div",{className:A.index,children:[e.jsxs("div",{className:A.header,children:[e.jsxs("span",{className:A.title,children:[e.jsx(dn,{size:14}),"Documents"]}),v?e.jsx("button",{type:"button",className:"tf-control-icon",onClick:v,title:"Collapse document tray","aria-label":"Collapse document tray",children:e.jsx(un,{size:16})}):null]}),e.jsxs("div",{className:A.search,children:[e.jsx(mn,{size:12,className:A.searchIcon}),e.jsx("input",{type:"text",placeholder:"Search documents…",value:c,onChange:h=>w(h.target.value),className:A.searchInput})]}),e.jsxs("div",{className:`${A.list} tf-scrollbar`,children:[m&&e.jsx("div",{className:A.state,children:"Loading documents…"}),!m&&s&&e.jsx("div",{className:A.stateError,children:s}),!m&&!s&&t.length===0&&e.jsx("div",{className:A.state,children:b?"No documents match your filters.":"No documents found. Documents added as task attachments will appear here."}),!m&&t.map(h=>{const g=h.taskId?u.get(h.taskId):null,O=h.id===l,T=$e(h),C=et(h),D=typeof h.attachmentCount=="number"&&Number.isFinite(h.attachmentCount)?h.attachmentCount:h.taskId?1:0,E=D>1?`${D} tasks linked`:D===1?g?.title||"1 task linked":null;return e.jsxs("div",{role:"button",tabIndex:0,className:`${A.item} ${O?A.itemActive:""}`,onClick:()=>y(h),onKeyDown:I=>ia(I,()=>y(h)),children:[e.jsx("div",{className:A.itemIcon,children:e.jsx(aa,{docType:h.docType})}),e.jsxs("div",{className:A.itemBody,children:[e.jsx("span",{className:A.itemTitle,title:T,children:T}),C==="unattached"&&e.jsx("span",{className:A.itemBadge,children:"Unattached"}),E&&e.jsx("span",{className:A.itemTask,title:E,children:E}),e.jsxs("span",{className:A.itemMeta,children:[e.jsxs("span",{className:A.itemMetaDetails,children:[sa(h.sizeBytes),h.updatedAt&&e.jsxs(e.Fragment,{children:[" · ",ra(h.updatedAt)]})]}),h.referenceLabel&&e.jsx("span",{className:A.itemMetaReference,children:h.referenceLabel})]})]})]},h.id)})]})]})}function Ie(t){return function(l){return Dn(l,t)}}const ca="_viewer_v1pk0_1",la="_viewerMonochrome_v1pk0_10",da="_metaDocumentName_v1pk0_10",ua="_viewerEditMode_v1pk0_14",ma="_meta_v1pk0_10",ha="_metaLeft_v1pk0_30",pa="_metaRenameRow_v1pk0_49",fa="_typeBadge_v1pk0_56",va="_typeBadgeImplementationPlan_v1pk0_71",wa="_typeBadgeReview_v1pk0_77",ka="_typeBadgeWalkthrough_v1pk0_83",ya="_metaTaskName_v1pk0_89",ga="_statusBadge_v1pk0_98",xa="_metaDate_v1pk0_113",_a="_metaSize_v1pk0_114",ba="_actions_v1pk0_122",Sa="_actionBtn_v1pk0_129",ja="_dangerBtn_v1pk0_156",Ca="_generateBtn_v1pk0_167",Na="_editBtn_v1pk0_178",Ta="_saveBtn_v1pk0_189",Ea="_layoutToggle_v1pk0_205",Ra="_layoutBtn_v1pk0_213",Aa="_layoutBtnActive_v1pk0_229",Ia="_saveStatus_v1pk0_234",$a="_saveStatusSaved_v1pk0_241",La="_saveStatusError_v1pk0_245",Da="_unsaved_v1pk0_250",Ba="_viewerContent_v1pk0_256",Ma="_viewerBody_v1pk0_265",Pa="_viewerBodyFullWidth_v1pk0_273",za="_viewerMain_v1pk0_277",Fa="_reviewRail_v1pk0_285",Oa="_printHint_v1pk0_291",Ha="_reviewSection_v1pk0_298",Wa="_reviewHeader_v1pk0_307",Ga="_reviewTitle_v1pk0_315",Ka="_reviewSubtitle_v1pk0_324",Ua="_reviewControls_v1pk0_331",Ja="_reviewSelect_v1pk0_338",Va="_reviewSessionMeta_v1pk0_342",qa="_reviewStatusResolved_v1pk0_350",Qa="_reviewSessionLabel_v1pk0_356",Ya="_reviewTitleEditRow_v1pk0_361",Xa="_reviewSessionTimestamp_v1pk0_368",Za="_reviewAnchorLabel_v1pk0_372",es="_reviewComposer_v1pk0_378",ts="_reviewAnchorChip_v1pk0_385",ns="_reviewAnchorSnippet_v1pk0_398",as="_reviewAnchorClear_v1pk0_403",ss="_reviewCommentActions_v1pk0_416",rs="_reviewCommentAction_v1pk0_416",is="_reviewCommentEditor_v1pk0_437",os="_viewerState_v1pk0_443",cs="_viewerStateError_v1pk0_450",ls="_editorArea_v1pk0_457",ds="_editorPane_v1pk0_464",us="_editorLayoutSplit_v1pk0_472",ms="_previewPane_v1pk0_473",hs="_editorLayoutEditor_v1pk0_477",ps="_editorLayoutPreview_v1pk0_478",fs="_editorPaneLabel_v1pk0_482",vs="_editorTextarea_v1pk0_494",ws="_markdownSurface_v1pk0_536",ks="_attachModalBody_v1pk0_745",ys="_attachModalCopy_v1pk0_752",gs="_attachModalError_v1pk0_759",xs="_attachTaskList_v1pk0_772",_s="_attachTaskRow_v1pk0_781",bs="_attachTaskTitle_v1pk0_808",Ss="_attachTaskInfo_v1pk0_814",js="_attachTaskReference_v1pk0_822",Cs="_attachTaskMeta_v1pk0_829",Ns="_attachEmptyState_v1pk0_836",r={viewer:ca,viewerMonochrome:la,metaDocumentName:da,viewerEditMode:ua,meta:ma,metaLeft:ha,metaRenameRow:pa,typeBadge:fa,typeBadgeImplementationPlan:va,typeBadgeReview:wa,typeBadgeWalkthrough:ka,metaTaskName:ya,statusBadge:ga,metaDate:xa,metaSize:_a,actions:ba,actionBtn:Sa,dangerBtn:ja,generateBtn:Ca,editBtn:Na,saveBtn:Ta,layoutToggle:Ea,layoutBtn:Ra,layoutBtnActive:Aa,saveStatus:Ia,saveStatusSaved:$a,saveStatusError:La,unsaved:Da,viewerContent:Ba,viewerBody:Ma,viewerBodyFullWidth:Pa,viewerMain:za,reviewRail:Fa,printHint:Oa,reviewSection:Ha,reviewHeader:Wa,reviewTitle:Ga,reviewSubtitle:Ka,reviewControls:Ua,reviewSelect:Ja,reviewSessionMeta:Va,reviewStatusResolved:qa,reviewSessionLabel:Qa,reviewTitleEditRow:Ya,reviewSessionTimestamp:Xa,reviewAnchorLabel:Za,reviewComposer:es,reviewAnchorChip:ts,reviewAnchorSnippet:ns,reviewAnchorClear:as,reviewCommentActions:ss,reviewCommentAction:rs,reviewCommentEditor:is,viewerState:os,viewerStateError:cs,editorArea:ls,editorPane:ds,editorLayoutSplit:us,previewPane:ms,editorLayoutEditor:hs,editorLayoutPreview:ps,editorPaneLabel:fs,editorTextarea:vs,markdownSurface:ws,attachModalBody:ks,attachModalCopy:ys,attachModalError:gs,attachTaskList:xs,attachTaskRow:_s,attachTaskTitle:bs,attachTaskInfo:Ss,attachTaskReference:js,attachTaskMeta:Cs,attachEmptyState:Ns},Ts="_overlay_1unik_1",Es="_modal_1unik_12",Rs="_header_1unik_16",As="_title_1unik_20",Is="_docName_1unik_24",$s="_body_1unik_34",Ls="_state_1unik_41",Ds="_stateError_1unik_52",Bs="_stateDone_1unik_63",Ms="_toolbar_1unik_84",Ps="_toolbarCount_1unik_95",zs="_toolbarActions_1unik_100",Fs="_tree_1unik_105",Os="_taskRow_1unik_113",Hs="_taskRowDimmed_1unik_126",Ws="_taskCheck_1unik_130",Gs="_taskExpandBtn_1unik_139",Ks="_taskExpandSpacer_1unik_155",Us="_taskTitle_1unik_160",Js="_taskBadge_1unik_169",Vs="_footer_1unik_179",S={overlay:Ts,modal:Es,header:Rs,title:As,docName:Is,body:$s,state:Ls,stateError:Ds,stateDone:Bs,toolbar:Ms,toolbarCount:Ps,toolbarActions:zs,tree:Fs,taskRow:Os,taskRowDimmed:Hs,taskCheck:Ws,taskExpandBtn:Gs,taskExpandSpacer:Ks,taskTitle:Us,taskBadge:Js,footer:Vs},qs={1:"Low",2:"Medium",3:"High"};function we(t,l){return t.map(m=>({...m,selected:l,children:we(m.children,l)}))}function It(t,l,m){return t.map(s=>s.idempotencyKey===l?{...s,selected:m,children:we(s.children,m)}:{...s,children:It(s.children,l,m)})}function Ze(t){let l=0;for(const m of t)m.selected&&l++,l+=Ze(m.children);return l}function $t({node:t,depth:l,onToggle:m}){const[s,c]=i.useState(!0),u=t.children.length>0,w=l*20;return e.jsxs("div",{children:[e.jsxs("div",{className:`${S.taskRow} ${t.selected?"":S.taskRowDimmed}`,style:{paddingLeft:`${12+w}px`},children:[e.jsx("button",{className:S.taskCheck,onClick:()=>m(t.idempotencyKey,!t.selected),title:t.selected?"Deselect":"Select",children:t.selected?e.jsx(vn,{size:14,style:{color:"var(--brand-primary-strong)"}}):e.jsx(wn,{size:14,style:{color:"var(--text-muted)"}})}),u?e.jsx("button",{className:S.taskExpandBtn,onClick:()=>c(y=>!y),children:s?e.jsx(kn,{size:12}):e.jsx(yn,{size:12})}):e.jsx("span",{className:S.taskExpandSpacer}),e.jsx("span",{className:S.taskTitle,title:t.description||void 0,children:t.title}),e.jsx("span",{className:S.taskBadge,style:{color:yt(t.type),borderColor:yt(t.type)},children:t.type}),e.jsx("span",{className:S.taskBadge,style:{color:gt(t.priority),borderColor:gt(t.priority)},children:qs[t.priority]})]}),u&&s&&e.jsx("div",{children:t.children.map(y=>e.jsx($t,{node:y,depth:l+1,onToggle:m},y.idempotencyKey))})]})}function Qs({content:t,docTitle:l,apiBaseUrl:m="",onClose:s,onGenerated:c}){const[u,w]=i.useState("preview"),[y,v]=i.useState(null),[b,h]=i.useState([]),[g,O]=i.useState(!0),[T,C]=i.useState(0),[D,E]=i.useState(null);i.useEffect(()=>{let x=!1;return O(!0),v(null),P("/api/taskforce/documents/generate-tasks/preview",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t})},m).then(j=>j.json()).then(j=>{if(!x){if(j.error)throw new Error(j.error);h(j.tasks||[]),w("preview")}}).catch(j=>{x||(v(j?.message||"Failed to parse plan"),w("error"))}).finally(()=>{x||O(!1)}),()=>{x=!0}},[t,m]);const I=i.useCallback((x,j)=>{h(F=>It(F,x,j))},[]),z=()=>h(x=>we(x,!0)),H=()=>h(x=>we(x,!1)),q=Ze(b),Q=async()=>{w("generating"),E(null);try{const x=await P("/api/taskforce/documents/generate-tasks/commit",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({tasks:b})},m),j=await x.json().catch(()=>({}));if(!x.ok)throw new Error(j.error||`Generation failed (${x.status})`);C(j.created??0),w("done"),c(j.created??0)}catch(x){E(x?.message||"Generation failed"),w("error")}};return e.jsx("div",{className:S.overlay,onClick:x=>{x.target===x.currentTarget&&s()},children:e.jsxs("div",{className:`tf-surface-modal tf-modal-shell ${S.modal}`,children:[e.jsxs("div",{className:`tf-modal-header ${S.header}`,children:[e.jsxs("div",{className:`tf-modal-title ${S.title}`,children:[e.jsx(Qe,{size:16,style:{color:"var(--brand-primary-strong)"}}),"Generate Tasks from Plan"]}),e.jsx("span",{className:S.docName,children:l}),e.jsx("button",{className:"tf-control-icon",onClick:s,title:"Close",children:e.jsx(Rt,{size:16})})]}),e.jsxs("div",{className:S.body,children:[g&&e.jsxs("div",{className:S.state,children:[e.jsx(_t,{size:20,className:L.docSpinning}),"Parsing plan…"]}),!g&&u==="error"&&e.jsxs("div",{className:S.stateError,children:[e.jsx(Ye,{size:16}),y||D||"An error occurred"]}),!g&&u==="done"&&e.jsxs("div",{className:S.stateDone,children:[e.jsx(At,{size:24,style:{color:"var(--status-success)"}}),e.jsxs("strong",{children:[T," task",T!==1?"s":""," created"]}),e.jsx("p",{children:"Tasks are now in your board. Switch to the Kanban or Hierarchy view to see them."})]}),!g&&(u==="preview"||u==="confirm"||u==="generating")&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:S.toolbar,children:[e.jsxs("span",{className:S.toolbarCount,children:[q," of ",Ze(we(b,!0))," tasks selected"]}),e.jsxs("div",{className:S.toolbarActions,children:[e.jsx("button",{className:"tf-control-icon",onClick:z,children:"Select all"}),e.jsx("button",{className:"tf-control-icon",onClick:H,children:"Deselect all"})]})]}),b.length===0?e.jsx("div",{className:S.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:`${S.tree} tf-scrollbar`,children:b.map(x=>e.jsx($t,{node:x,depth:0,onToggle:I},x.idempotencyKey))})]})]}),!g&&u!=="done"&&u!=="error"&&e.jsxs("div",{className:S.footer,children:[e.jsx("button",{className:"tf-button-secondary",onClick:s,children:"Cancel"}),e.jsx("button",{className:"tf-button-primary",onClick:Q,disabled:q===0||u==="generating",children:u==="generating"?e.jsxs(e.Fragment,{children:[e.jsx(_t,{size:13,className:L.docSpinning})," Generating…"]}):e.jsxs(e.Fragment,{children:[e.jsx(Qe,{size:13})," Generate ",q," task",q!==1?"s":""]})})]}),!g&&u==="done"&&e.jsx("div",{className:S.footer,children:e.jsx("button",{className:"tf-button-primary",onClick:s,children:"Done"})})]})})}const Ys={"implementation-plan":"Implementation Plan",review:"Review",walkthrough:"Walkthrough",planning:"Planning",other:"Document"},Xs={"implementation-plan":r.typeBadgeImplementationPlan,review:r.typeBadgeReview,walkthrough:r.typeBadgeWalkthrough,planning:void 0,other:void 0},Zs={editor:r.editorLayoutEditor,split:r.editorLayoutSplit,preview:r.editorLayoutPreview},er=1500,tr=`
|
|
1
|
+
import{j as e,r as i,s as an,R as ve}from"./vendor-react-CKJs5o3c.js";import{h as $e,f as P,t as L,i as yt,j as gt,k as sn,R as rn,m as M,M as on,n as xt,o as cn,q as ln}from"./index-CGDQY0nN.js";import{q as dn,x as un,w as mn,ax as hn,ay as pn,y as qe,i as fn,Z as Qe,X as Rt,az as _t,e as Ye,aA as At,aB as vn,aC as wn,a as kn,j as yn,aD as gn,aE as xn,aF as _n,t as Ee,aG as bn,r as Sn,p as jn,aH as bt,aw as Ve,aI as Cn,aJ as Nn,T as Tn,R as En,aK as Rn,B as An,U as In,S as $n}from"./vendor-icons-CLnehDTw.js";import{g as Ln}from"./documentReferences-Ca2P--i5.js";import{s as Dn,M as Re,r as Ae}from"./vendor-markdown-BUxTU7dS.js";import"./vendor-dnd-DRzYolkg.js";import"./vendor-router-BbWMxlnO.js";const Bn="_index_1sp0v_1",Mn="_header_1sp0v_8",Pn="_title_1sp0v_23",zn="_search_1sp0v_35",Fn="_searchIcon_1sp0v_41",On="_searchInput_1sp0v_50",Hn="_list_1sp0v_67",Wn="_state_1sp0v_79",Gn="_stateError_1sp0v_87",Kn="_item_1sp0v_94",Un="_itemActive_1sp0v_116",Jn="_itemIcon_1sp0v_126",Vn="_itemBody_1sp0v_136",qn="_itemTitle_1sp0v_144",Qn="_itemTask_1sp0v_156",Yn="_itemBadge_1sp0v_167",Xn="_itemMeta_1sp0v_180",Zn="_itemMetaDetails_1sp0v_191",ea="_itemMetaReference_1sp0v_198",A={index:Bn,header:Mn,title:Pn,search:zn,searchIcon:Fn,searchInput:On,list:Hn,state:Wn,stateError:Gn,item:Kn,itemActive:Un,itemIcon:Jn,itemBody:Vn,itemTitle:qn,itemTask:Qn,itemBadge:Yn,itemMeta:Xn,itemMetaDetails:Zn,itemMetaReference:ea};function Xe(t){let l=t;try{l=decodeURIComponent(t)}catch{l=t}return l.trim().replace(/\\/g,"/").replace(/^\/+/,"").replace(/^\.\//,"").replace(/^\.taskforce\//,"")}function ta(t,l){return!!(t===l||t.endsWith(`/${l}`)||l.endsWith(`/${t}`))}function St(t){const l=Xe(String(t||""));if(!l)return null;const m=l.match(/(^|\/)(asset-[a-f0-9]{32})(?=[^/]*$)/i);return m?.[2]?m[2].toLowerCase():null}function et(t){return t.attachmentState==="attached"||t.attachmentState==="unattached"?t.attachmentState:(typeof t.attachmentCount=="number"&&Number.isFinite(t.attachmentCount)?t.attachmentCount:0)>0||t.taskId?"attached":"unattached"}function na(t,l,m,s){const c=l.trim().toLowerCase();return t.filter(u=>{const y=`${$e(u)} ${u.originalFilename||""}`.toLowerCase(),v=c.length===0||y.includes(c),b=m.length===0||m.includes(u.docType),h=et(u),g=s.length===0||s.includes(h);return v&&b&&g})}function aa({docType:t}){switch(t){case"implementation-plan":return e.jsx(fn,{size:13});case"review":return e.jsx(qe,{size:13});case"walkthrough":return e.jsx(pn,{size:13});default:return e.jsx(hn,{size:13})}}function sa(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/(1024*1024)).toFixed(1)}MB`}function ra(t){if(!t)return"";const l=new Date(t),s=new Date().getTime()-l.getTime(),c=Math.floor(s/(1e3*60*60*24));return c===0?"Today":c===1?"Yesterday":c<7?`${c}d ago`:c<30?`${Math.floor(c/7)}w ago`:l.toLocaleDateString()}function ia(t,l){t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),l())}function oa({documents:t,selectedDocId:l,loading:m,error:s,searchQuery:c,taskById:u,onSearchChange:w,onSelect:y,onCloseTray:v,hasActiveFilters:b}){return e.jsxs("div",{className:A.index,children:[e.jsxs("div",{className:A.header,children:[e.jsxs("span",{className:A.title,children:[e.jsx(dn,{size:14}),"Documents"]}),v?e.jsx("button",{type:"button",className:"tf-control-icon",onClick:v,title:"Collapse document tray","aria-label":"Collapse document tray",children:e.jsx(un,{size:16})}):null]}),e.jsxs("div",{className:A.search,children:[e.jsx(mn,{size:12,className:A.searchIcon}),e.jsx("input",{type:"text",placeholder:"Search documents…",value:c,onChange:h=>w(h.target.value),className:A.searchInput})]}),e.jsxs("div",{className:`${A.list} tf-scrollbar`,children:[m&&e.jsx("div",{className:A.state,children:"Loading documents…"}),!m&&s&&e.jsx("div",{className:A.stateError,children:s}),!m&&!s&&t.length===0&&e.jsx("div",{className:A.state,children:b?"No documents match your filters.":"No documents found. Documents added as task attachments will appear here."}),!m&&t.map(h=>{const g=h.taskId?u.get(h.taskId):null,O=h.id===l,T=$e(h),C=et(h),D=typeof h.attachmentCount=="number"&&Number.isFinite(h.attachmentCount)?h.attachmentCount:h.taskId?1:0,E=D>1?`${D} tasks linked`:D===1?g?.title||"1 task linked":null;return e.jsxs("div",{role:"button",tabIndex:0,className:`${A.item} ${O?A.itemActive:""}`,onClick:()=>y(h),onKeyDown:I=>ia(I,()=>y(h)),children:[e.jsx("div",{className:A.itemIcon,children:e.jsx(aa,{docType:h.docType})}),e.jsxs("div",{className:A.itemBody,children:[e.jsx("span",{className:A.itemTitle,title:T,children:T}),C==="unattached"&&e.jsx("span",{className:A.itemBadge,children:"Unattached"}),E&&e.jsx("span",{className:A.itemTask,title:E,children:E}),e.jsxs("span",{className:A.itemMeta,children:[e.jsxs("span",{className:A.itemMetaDetails,children:[sa(h.sizeBytes),h.updatedAt&&e.jsxs(e.Fragment,{children:[" · ",ra(h.updatedAt)]})]}),h.referenceLabel&&e.jsx("span",{className:A.itemMetaReference,children:h.referenceLabel})]})]})]},h.id)})]})]})}function Ie(t){return function(l){return Dn(l,t)}}const ca="_viewer_v1pk0_1",la="_viewerMonochrome_v1pk0_10",da="_metaDocumentName_v1pk0_10",ua="_viewerEditMode_v1pk0_14",ma="_meta_v1pk0_10",ha="_metaLeft_v1pk0_30",pa="_metaRenameRow_v1pk0_49",fa="_typeBadge_v1pk0_56",va="_typeBadgeImplementationPlan_v1pk0_71",wa="_typeBadgeReview_v1pk0_77",ka="_typeBadgeWalkthrough_v1pk0_83",ya="_metaTaskName_v1pk0_89",ga="_statusBadge_v1pk0_98",xa="_metaDate_v1pk0_113",_a="_metaSize_v1pk0_114",ba="_actions_v1pk0_122",Sa="_actionBtn_v1pk0_129",ja="_dangerBtn_v1pk0_156",Ca="_generateBtn_v1pk0_167",Na="_editBtn_v1pk0_178",Ta="_saveBtn_v1pk0_189",Ea="_layoutToggle_v1pk0_205",Ra="_layoutBtn_v1pk0_213",Aa="_layoutBtnActive_v1pk0_229",Ia="_saveStatus_v1pk0_234",$a="_saveStatusSaved_v1pk0_241",La="_saveStatusError_v1pk0_245",Da="_unsaved_v1pk0_250",Ba="_viewerContent_v1pk0_256",Ma="_viewerBody_v1pk0_265",Pa="_viewerBodyFullWidth_v1pk0_273",za="_viewerMain_v1pk0_277",Fa="_reviewRail_v1pk0_285",Oa="_printHint_v1pk0_291",Ha="_reviewSection_v1pk0_298",Wa="_reviewHeader_v1pk0_307",Ga="_reviewTitle_v1pk0_315",Ka="_reviewSubtitle_v1pk0_324",Ua="_reviewControls_v1pk0_331",Ja="_reviewSelect_v1pk0_338",Va="_reviewSessionMeta_v1pk0_342",qa="_reviewStatusResolved_v1pk0_350",Qa="_reviewSessionLabel_v1pk0_356",Ya="_reviewTitleEditRow_v1pk0_361",Xa="_reviewSessionTimestamp_v1pk0_368",Za="_reviewAnchorLabel_v1pk0_372",es="_reviewComposer_v1pk0_378",ts="_reviewAnchorChip_v1pk0_385",ns="_reviewAnchorSnippet_v1pk0_398",as="_reviewAnchorClear_v1pk0_403",ss="_reviewCommentActions_v1pk0_416",rs="_reviewCommentAction_v1pk0_416",is="_reviewCommentEditor_v1pk0_437",os="_viewerState_v1pk0_443",cs="_viewerStateError_v1pk0_450",ls="_editorArea_v1pk0_457",ds="_editorPane_v1pk0_464",us="_editorLayoutSplit_v1pk0_472",ms="_previewPane_v1pk0_473",hs="_editorLayoutEditor_v1pk0_477",ps="_editorLayoutPreview_v1pk0_478",fs="_editorPaneLabel_v1pk0_482",vs="_editorTextarea_v1pk0_494",ws="_markdownSurface_v1pk0_536",ks="_attachModalBody_v1pk0_745",ys="_attachModalCopy_v1pk0_752",gs="_attachModalError_v1pk0_759",xs="_attachTaskList_v1pk0_772",_s="_attachTaskRow_v1pk0_781",bs="_attachTaskTitle_v1pk0_808",Ss="_attachTaskInfo_v1pk0_814",js="_attachTaskReference_v1pk0_822",Cs="_attachTaskMeta_v1pk0_829",Ns="_attachEmptyState_v1pk0_836",r={viewer:ca,viewerMonochrome:la,metaDocumentName:da,viewerEditMode:ua,meta:ma,metaLeft:ha,metaRenameRow:pa,typeBadge:fa,typeBadgeImplementationPlan:va,typeBadgeReview:wa,typeBadgeWalkthrough:ka,metaTaskName:ya,statusBadge:ga,metaDate:xa,metaSize:_a,actions:ba,actionBtn:Sa,dangerBtn:ja,generateBtn:Ca,editBtn:Na,saveBtn:Ta,layoutToggle:Ea,layoutBtn:Ra,layoutBtnActive:Aa,saveStatus:Ia,saveStatusSaved:$a,saveStatusError:La,unsaved:Da,viewerContent:Ba,viewerBody:Ma,viewerBodyFullWidth:Pa,viewerMain:za,reviewRail:Fa,printHint:Oa,reviewSection:Ha,reviewHeader:Wa,reviewTitle:Ga,reviewSubtitle:Ka,reviewControls:Ua,reviewSelect:Ja,reviewSessionMeta:Va,reviewStatusResolved:qa,reviewSessionLabel:Qa,reviewTitleEditRow:Ya,reviewSessionTimestamp:Xa,reviewAnchorLabel:Za,reviewComposer:es,reviewAnchorChip:ts,reviewAnchorSnippet:ns,reviewAnchorClear:as,reviewCommentActions:ss,reviewCommentAction:rs,reviewCommentEditor:is,viewerState:os,viewerStateError:cs,editorArea:ls,editorPane:ds,editorLayoutSplit:us,previewPane:ms,editorLayoutEditor:hs,editorLayoutPreview:ps,editorPaneLabel:fs,editorTextarea:vs,markdownSurface:ws,attachModalBody:ks,attachModalCopy:ys,attachModalError:gs,attachTaskList:xs,attachTaskRow:_s,attachTaskTitle:bs,attachTaskInfo:Ss,attachTaskReference:js,attachTaskMeta:Cs,attachEmptyState:Ns},Ts="_overlay_1unik_1",Es="_modal_1unik_12",Rs="_header_1unik_16",As="_title_1unik_20",Is="_docName_1unik_24",$s="_body_1unik_34",Ls="_state_1unik_41",Ds="_stateError_1unik_52",Bs="_stateDone_1unik_63",Ms="_toolbar_1unik_84",Ps="_toolbarCount_1unik_95",zs="_toolbarActions_1unik_100",Fs="_tree_1unik_105",Os="_taskRow_1unik_113",Hs="_taskRowDimmed_1unik_126",Ws="_taskCheck_1unik_130",Gs="_taskExpandBtn_1unik_139",Ks="_taskExpandSpacer_1unik_155",Us="_taskTitle_1unik_160",Js="_taskBadge_1unik_169",Vs="_footer_1unik_179",S={overlay:Ts,modal:Es,header:Rs,title:As,docName:Is,body:$s,state:Ls,stateError:Ds,stateDone:Bs,toolbar:Ms,toolbarCount:Ps,toolbarActions:zs,tree:Fs,taskRow:Os,taskRowDimmed:Hs,taskCheck:Ws,taskExpandBtn:Gs,taskExpandSpacer:Ks,taskTitle:Us,taskBadge:Js,footer:Vs},qs={1:"Low",2:"Medium",3:"High"};function we(t,l){return t.map(m=>({...m,selected:l,children:we(m.children,l)}))}function It(t,l,m){return t.map(s=>s.idempotencyKey===l?{...s,selected:m,children:we(s.children,m)}:{...s,children:It(s.children,l,m)})}function Ze(t){let l=0;for(const m of t)m.selected&&l++,l+=Ze(m.children);return l}function $t({node:t,depth:l,onToggle:m}){const[s,c]=i.useState(!0),u=t.children.length>0,w=l*20;return e.jsxs("div",{children:[e.jsxs("div",{className:`${S.taskRow} ${t.selected?"":S.taskRowDimmed}`,style:{paddingLeft:`${12+w}px`},children:[e.jsx("button",{className:S.taskCheck,onClick:()=>m(t.idempotencyKey,!t.selected),title:t.selected?"Deselect":"Select",children:t.selected?e.jsx(vn,{size:14,style:{color:"var(--brand-primary-strong)"}}):e.jsx(wn,{size:14,style:{color:"var(--text-muted)"}})}),u?e.jsx("button",{className:S.taskExpandBtn,onClick:()=>c(y=>!y),children:s?e.jsx(kn,{size:12}):e.jsx(yn,{size:12})}):e.jsx("span",{className:S.taskExpandSpacer}),e.jsx("span",{className:S.taskTitle,title:t.description||void 0,children:t.title}),e.jsx("span",{className:S.taskBadge,style:{color:yt(t.type),borderColor:yt(t.type)},children:t.type}),e.jsx("span",{className:S.taskBadge,style:{color:gt(t.priority),borderColor:gt(t.priority)},children:qs[t.priority]})]}),u&&s&&e.jsx("div",{children:t.children.map(y=>e.jsx($t,{node:y,depth:l+1,onToggle:m},y.idempotencyKey))})]})}function Qs({content:t,docTitle:l,apiBaseUrl:m="",onClose:s,onGenerated:c}){const[u,w]=i.useState("preview"),[y,v]=i.useState(null),[b,h]=i.useState([]),[g,O]=i.useState(!0),[T,C]=i.useState(0),[D,E]=i.useState(null);i.useEffect(()=>{let x=!1;return O(!0),v(null),P("/api/taskforce/documents/generate-tasks/preview",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t})},m).then(j=>j.json()).then(j=>{if(!x){if(j.error)throw new Error(j.error);h(j.tasks||[]),w("preview")}}).catch(j=>{x||(v(j?.message||"Failed to parse plan"),w("error"))}).finally(()=>{x||O(!1)}),()=>{x=!0}},[t,m]);const I=i.useCallback((x,j)=>{h(F=>It(F,x,j))},[]),z=()=>h(x=>we(x,!0)),H=()=>h(x=>we(x,!1)),q=Ze(b),Q=async()=>{w("generating"),E(null);try{const x=await P("/api/taskforce/documents/generate-tasks/commit",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({tasks:b})},m),j=await x.json().catch(()=>({}));if(!x.ok)throw new Error(j.error||`Generation failed (${x.status})`);C(j.created??0),w("done"),c(j.created??0)}catch(x){E(x?.message||"Generation failed"),w("error")}};return e.jsx("div",{className:S.overlay,onClick:x=>{x.target===x.currentTarget&&s()},children:e.jsxs("div",{className:`tf-surface-modal tf-modal-shell ${S.modal}`,children:[e.jsxs("div",{className:`tf-modal-header ${S.header}`,children:[e.jsxs("div",{className:`tf-modal-title ${S.title}`,children:[e.jsx(Qe,{size:16,style:{color:"var(--brand-primary-strong)"}}),"Generate Tasks from Plan"]}),e.jsx("span",{className:S.docName,children:l}),e.jsx("button",{className:"tf-control-icon",onClick:s,title:"Close",children:e.jsx(Rt,{size:16})})]}),e.jsxs("div",{className:S.body,children:[g&&e.jsxs("div",{className:S.state,children:[e.jsx(_t,{size:20,className:L.docSpinning}),"Parsing plan…"]}),!g&&u==="error"&&e.jsxs("div",{className:S.stateError,children:[e.jsx(Ye,{size:16}),y||D||"An error occurred"]}),!g&&u==="done"&&e.jsxs("div",{className:S.stateDone,children:[e.jsx(At,{size:24,style:{color:"var(--status-success)"}}),e.jsxs("strong",{children:[T," task",T!==1?"s":""," created"]}),e.jsx("p",{children:"Tasks are now in your board. Switch to the Kanban or Hierarchy view to see them."})]}),!g&&(u==="preview"||u==="confirm"||u==="generating")&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:S.toolbar,children:[e.jsxs("span",{className:S.toolbarCount,children:[q," of ",Ze(we(b,!0))," tasks selected"]}),e.jsxs("div",{className:S.toolbarActions,children:[e.jsx("button",{className:"tf-control-icon",onClick:z,children:"Select all"}),e.jsx("button",{className:"tf-control-icon",onClick:H,children:"Deselect all"})]})]}),b.length===0?e.jsx("div",{className:S.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:`${S.tree} tf-scrollbar`,children:b.map(x=>e.jsx($t,{node:x,depth:0,onToggle:I},x.idempotencyKey))})]})]}),!g&&u!=="done"&&u!=="error"&&e.jsxs("div",{className:S.footer,children:[e.jsx("button",{className:"tf-button-secondary",onClick:s,children:"Cancel"}),e.jsx("button",{className:"tf-button-primary",onClick:Q,disabled:q===0||u==="generating",children:u==="generating"?e.jsxs(e.Fragment,{children:[e.jsx(_t,{size:13,className:L.docSpinning})," Generating…"]}):e.jsxs(e.Fragment,{children:[e.jsx(Qe,{size:13})," Generate ",q," task",q!==1?"s":""]})})]}),!g&&u==="done"&&e.jsx("div",{className:S.footer,children:e.jsx("button",{className:"tf-button-primary",onClick:s,children:"Done"})})]})})}const Ys={"implementation-plan":"Implementation Plan",review:"Review",walkthrough:"Walkthrough",planning:"Planning",other:"Document"},Xs={"implementation-plan":r.typeBadgeImplementationPlan,review:r.typeBadgeReview,walkthrough:r.typeBadgeWalkthrough,planning:void 0,other:void 0},Zs={editor:r.editorLayoutEditor,split:r.editorLayoutSplit,preview:r.editorLayoutPreview},er=1500,tr=`
|
|
2
2
|
@page {
|
|
3
3
|
margin: 0.94in 1.02in 1in;
|
|
4
4
|
}
|
package/dist/ui/assets/{EntityActivityTimeline-B2aXkxiE.js → EntityActivityTimeline-BlS7DhA4.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{R as k,j as t}from"./vendor-react-CKJs5o3c.js";import{S as A,U as N,V as E,W as I,X as S,Y as M}from"./index-
|
|
1
|
+
import{R as k,j as t}from"./vendor-react-CKJs5o3c.js";import{S as A,U as N,V as E,W as I,X as S,Y as M}from"./index-CGDQY0nN.js";import"./vendor-icons-CLnehDTw.js";import"./vendor-markdown-BUxTU7dS.js";import"./vendor-dnd-DRzYolkg.js";import"./vendor-router-BbWMxlnO.js";const $="_thread_1mrb3_1",z="_empty_1mrb3_7",P="_item_1mrb3_17",H="_comment_1mrb3_24",R="_commentAgent_1mrb3_28",B="_commentMember_1mrb3_32",W="_event_1mrb3_36",K="_eventSystem_1mrb3_43",w="_header_1mrb3_47",D="_eventHeader_1mrb3_64",F="_author_1mrb3_71",O="_time_1mrb3_79",U="_commentText_1mrb3_83",X="_eventText_1mrb3_123",Y="_eventChanges_1mrb3_129",q="_eventChange_1mrb3_129",e={thread:$,empty:z,item:P,comment:H,commentAgent:R,commentMember:B,event:W,eventSystem:K,header:w,eventHeader:D,author:F,time:O,commentText:U,eventText:X,eventChanges:Y,eventChange:q};function v(c,m){const r=c.replace("#","").trim();if(r.length!==3&&r.length!==6)return"";const i=r.length===3?r.split("").map(l=>l+l).join(""):r,a=Number.parseInt(i,16);if(Number.isNaN(a))return"";const _=a>>16&255,g=a>>8&255,u=a&255;return`rgba(${_}, ${g}, ${u}, ${m})`}function ee({activity:c,comments:m,formatFieldValue:r,resolveActorPresentation:i,onOpenTaskById:a,emptyMessage:_="No activity yet.",listClassName:g,emptyClassName:u,endRef:l}){const b=k.useMemo(()=>A({activity:c,comments:m}),[c,m]);return t.jsxs("div",{className:[e.thread,g].filter(Boolean).join(" "),children:[b.length===0?t.jsx("div",{className:[e.empty,u].filter(Boolean).join(" "),children:_}):null,b.map(n=>{if(n.type==="comment"){const o=i({actorId:n.comment.author,actorType:n.comment.actor?.kind==="ai"?"ai":n.comment.actor?.kind==="human"?"human":null,actorProfile:n.comment.actor||null}),x=o.kind==="agent"?"agent":"member",{ActorIcon:f}=o,s=o.color,T=s&&v(s,.35)?{background:`linear-gradient(135deg, ${v(s,.18)} 0%, ${v(s,.1)} 100%)`,borderColor:v(s,.35)}:void 0;return t.jsxs("div",{className:[e.item,e.comment,x==="agent"?e.commentAgent:e.commentMember].join(" "),children:[t.jsxs("div",{className:e.header,children:[t.jsxs("span",{className:e.author,style:s?{color:s}:void 0,children:[t.jsx(f,{size:12,strokeWidth:1.5}),o.label]}),t.jsx("span",{className:e.time,children:N(n.comment.timestamp,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})]}),t.jsx("div",{className:e.commentText,style:T,children:t.jsx(E,{onTaskIdClick:a,children:n.comment.text})})]},n.id)}const d=i({actorId:n.event.actor,actorType:n.event.actorType,actorProfile:n.event.actorProfile||null,fallbackKind:"system"}),{ActorIcon:C}=d,y=d.color,h=Object.entries(n.event.details?.changes||{}),p=I(n.event),j=h.length>1&&p?h.filter(([o])=>o!==p):h.length>1?h:[];return t.jsxs("div",{className:[e.item,e.event,d.kind==="system"?e.eventSystem:""].filter(Boolean).join(" "),children:[t.jsxs("div",{className:[e.header,e.eventHeader].join(" "),children:[t.jsxs("span",{className:e.author,style:y?{color:y}:void 0,children:[t.jsx(C,{size:12,strokeWidth:1.5}),d.label]}),t.jsx("span",{className:e.time,children:N(n.event.createdAt,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})]}),t.jsxs("div",{className:e.eventText,children:[t.jsx("div",{children:S(n.event,r)}),j.length>0?t.jsx("div",{className:e.eventChanges,children:j.map(([o,x])=>t.jsx("div",{className:e.eventChange,children:M(o,x,r)},o))}):null]})]},n.id)}),t.jsx("div",{ref:l})]})}export{ee as EntityActivityTimeline};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as i,j as s}from"./vendor-react-CKJs5o3c.js";import{t as e}from"./index-
|
|
1
|
+
import{r as i,j as s}from"./vendor-react-CKJs5o3c.js";import{t as e}from"./index-CGDQY0nN.js";import{h as g,Z as j,b as v,m as f}from"./vendor-icons-CLnehDTw.js";import"./vendor-markdown-BUxTU7dS.js";import"./vendor-dnd-DRzYolkg.js";import"./vendor-router-BbWMxlnO.js";function T({initiativeTemplates:n,onRefreshInitiativeTemplates:u,onCreateInitiativeFromTemplate:r}){const[a,o]=i.useState(""),[c,x]=i.useState(""),[d,m]=i.useState(!1),[l,p]=i.useState(null);return i.useEffect(()=>{if(!a&&n.length>0){const t=n[0];o(t.id)}},[n,a]),s.jsx("div",{className:`${e.standalonePage} ${e.standaloneContent}`,style:{overflow:"auto"},children:s.jsx("div",{className:e.settingsContent,style:{maxWidth:900,margin:"0 auto",width:"100%"},children:s.jsxs("div",{className:e.settingGroup,children:[s.jsxs("div",{className:e.settingTitleRow,children:[s.jsx("h2",{className:e.settingTitle,children:"Initiatives"}),s.jsx("button",{className:e.copyBtn,onClick:()=>{u?.()},children:"Refresh"})]}),s.jsx("p",{className:`${e.settingsHint} ${e.marginBottom12}`,children:"Create initiative-ready planning structures from reusable templates."}),s.jsxs("div",{className:e.exportItem,children:[s.jsx("label",{className:e.label,children:"Template"}),s.jsx("select",{className:e.input,value:a,onChange:t=>{const h=t.target.value;o(h)},children:n.map(t=>s.jsx("option",{value:t.id,children:t.name},t.id))})]}),s.jsxs("div",{className:`${e.exportItem} ${e.marginTop12}`,children:[s.jsx("label",{className:e.label,children:"Initiative Title"}),s.jsx("input",{className:e.input,placeholder:"e.g. Taskforce Public Beta Launch",value:c,onChange:t=>x(t.target.value)})]}),s.jsxs("button",{className:`${e.secondaryHeaderBtn} ${e.marginTop12}`,disabled:d||!a||!c.trim()||!r,onClick:async()=>{if(!r)return;m(!0);const t=await r({templateId:a,title:c.trim()});m(!1),p({type:t.success?"success":"error",message:t.success?"Initiative created from template.":t.error||"Failed to create initiative."})},children:[d?s.jsx(g,{size:14,className:e.spinner}):s.jsx(j,{size:14}),"Create Initiative"]}),l&&s.jsxs("div",{className:`${l.type==="success"?e.successMessage:e.errorMessage} ${e.marginTop12}`,children:[l.type==="success"?s.jsx(v,{size:14}):s.jsx(f,{size:14}),l.message]})]})})})}export{T as InitiativesModule};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as s,j as e}from"./vendor-react-CKJs5o3c.js";import{H as he,t as Oe,J as Ve,K as Pe,L as fe,N as be,O as Ke,Q as He}from"./index-rB9GGUCz.js";import{aL as qe,h as ze,U as Ye}from"./vendor-icons-CLnehDTw.js";import{u as We,a as Ge}from"./vendor-router-BbWMxlnO.js";import"./vendor-markdown-BUxTU7dS.js";import"./vendor-dnd-DRzYolkg.js";const Qe="_plansWrapper_nb8ab_1",Je="_contentFrame_nb8ab_24",Xe="_shellOwnsScroll_nb8ab_32",Ze="_withChrome_nb8ab_38",en="_siteVariant_nb8ab_42",nn="_title_nb8ab_56",tn="_subtitle_nb8ab_70",rn="_header_nb8ab_77",an="_planCard_nb8ab_92",sn="_grid_nb8ab_105",cn="_pricingNotes_nb8ab_113",on="_planName_nb8ab_122",ln="_featureText_nb8ab_129",un="_currentBadge_nb8ab_133",dn="_navAction_nb8ab_137",mn="_backBtn_nb8ab_138",pn="_priceRows_nb8ab_149",gn="_foundingBeta_nb8ab_153",fn="_cloudCapacityNote_nb8ab_172",bn="_headerBar_nb8ab_239",hn="_headerActions_nb8ab_248",yn="_debugMeta_nb8ab_299",_n="_planNoticeCard_nb8ab_362",Cn="_planDescription_nb8ab_373",Sn="_teamComingSoonCard_nb8ab_378",wn="_clickablePlanCard_nb8ab_397",vn="_activePlanCard_nb8ab_412",xn="_callToAction_nb8ab_476",Nn="_primaryCta_nb8ab_488",kn="_secondaryCta_nb8ab_499",Pn="_currentCta_nb8ab_511",In="_featuresList_nb8ab_525",An="_priceRow_nb8ab_149",jn="_regularPriceLine_nb8ab_549",Tn="_campaignPriceLine_nb8ab_550",Ln="_priceRowWithCampaign_nb8ab_557",Rn="_priceRowAmount_nb8ab_561",En="_regularPriceDiscounted_nb8ab_567",Bn="_priceRowInterval_nb8ab_573",$n="_campaignPriceLabel_nb8ab_582",Mn="_campaignPriceAmount_nb8ab_587",Un="_campaignPriceInterval_nb8ab_593",Dn="_ctaRow_nb8ab_598",Fn="_featureItem_nb8ab_604",On="_featureIcon_nb8ab_610",Vn="_featureLimitAccent_nb8ab_624",Kn="_featureLimitUnit_nb8ab_635",Hn="_featureTextBlock_nb8ab_641",qn="_featureDescription_nb8ab_647",zn="_emptyState_nb8ab_653",Yn="_marketingEmptyState_nb8ab_662",Wn="_emptyBadge_nb8ab_690",Gn="_emptyHighlights_nb8ab_705",Qn="_loader_nb8ab_727",Jn="_spinner_nb8ab_737",Xn="_statusBanner_nb8ab_790",Zn="_successBanner_nb8ab_798",et="_infoBanner_nb8ab_804",nt="_errorBanner_nb8ab_810",r={plansWrapper:Qe,contentFrame:Je,shellOwnsScroll:Xe,withChrome:Ze,siteVariant:en,title:nn,subtitle:tn,header:rn,planCard:an,grid:sn,pricingNotes:cn,planName:on,featureText:ln,currentBadge:un,navAction:dn,backBtn:mn,priceRows:pn,foundingBeta:gn,cloudCapacityNote:fn,headerBar:bn,headerActions:hn,debugMeta:yn,planNoticeCard:_n,planDescription:Cn,teamComingSoonCard:Sn,clickablePlanCard:wn,activePlanCard:vn,callToAction:xn,primaryCta:Nn,secondaryCta:kn,currentCta:Pn,featuresList:In,priceRow:An,regularPriceLine:jn,campaignPriceLine:Tn,priceRowWithCampaign:Ln,priceRowAmount:Rn,regularPriceDiscounted:En,priceRowInterval:Bn,campaignPriceLabel:$n,campaignPriceAmount:Mn,campaignPriceInterval:Un,ctaRow:Dn,featureItem:Fn,featureIcon:On,featureLimitAccent:Vn,featureLimitUnit:Kn,featureTextBlock:Hn,featureDescription:qn,emptyState:zn,marketingEmptyState:Yn,emptyBadge:Wn,emptyHighlights:Gn,loader:Qn,spinner:Jn,statusBanner:Xn,successBanner:Zn,infoBanner:et,errorBanner:nt};function tt(){const n=globalThis.__DEBUG_MODE__;return typeof n=="boolean"?n:!1}function rt(n){const a=String(n?.environment||"").trim(),o=String(n?.runtimeMode||"").trim();return!a&&!o?null:a&&o?`${a} (${o})`:a||o||null}const at=new Set(["a","b","br","em","i","li","ol","p","strong","u","ul"]);function it(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function st(n){const a=String(n||"").trim();if(!a)return"";if(typeof document>"u")return it(a);const o=document.createElement("template");o.innerHTML=a;const p=document.createElement("div"),l=_=>{if(_.nodeType===Node.TEXT_NODE)return document.createTextNode(_.textContent||"");if(_.nodeType!==Node.ELEMENT_NODE)return null;const E=_,I=E.tagName.toLowerCase();if(I==="script"||I==="style")return null;const $=Array.from(E.childNodes).map(l).filter(b=>!!b);if(!at.has(I)){const b=document.createDocumentFragment();for(const W of $)b.appendChild(W);return b}const x=document.createElement(I);if(I==="a"){const b=String(E.getAttribute("href")||"").trim();/^(https?:|mailto:|\/|#)/i.test(b)&&(x.setAttribute("href",b),x.setAttribute("rel","noopener noreferrer"))}for(const b of $)x.appendChild(b);return x};for(const _ of Array.from(o.content.childNodes)){const E=l(_);E&&p.appendChild(E)}return p.innerHTML}function ct(n,a){if(n==null||!a)return"Contact Sales";try{return new Intl.NumberFormat("en-US",{style:"currency",currency:a.toUpperCase(),minimumFractionDigits:0}).format(n/100)}catch{return`${a.toUpperCase()} ${n/100}`}}function ot(){return"$0"}function V(n){return n?n.pricingType==="free"?!0:n.unitAmount!=null&&n.currency!=null:!1}function Te(n){return n?n.pricingType==="free"?ot():ct(n.unitAmount,n.currency):"Unavailable"}function Le(n,a){return V(a)?{price:a,pricingAudience:"campaign"}:{price:n,pricingAudience:"public"}}function lt(n,a,o,p){const l=V(n)||V(o),_=V(a)||V(p);if(!l&&!_)return null;const E=(I,$,x)=>{if(!V(I)&&!V($))return null;const b=V($),W=x==="year"?"year":"month";return e.jsxs("div",{className:`${r.priceRow} ${b?r.priceRowWithCampaign:""}`,children:[V(I)?e.jsxs("div",{className:r.regularPriceLine,children:[e.jsx("span",{className:`${r.priceRowAmount} ${b?r.regularPriceDiscounted:""}`,children:Te(I)}),e.jsxs("span",{className:r.priceRowInterval,children:["/ ",W]})]}):null,b?e.jsxs("div",{className:r.campaignPriceLine,children:[e.jsx("span",{className:r.campaignPriceLabel,children:"Founding Offer:"}),e.jsx("span",{className:r.campaignPriceAmount,children:Te($)}),e.jsxs("span",{className:r.campaignPriceInterval,children:["/ ",W]})]}):null]},x)};return e.jsxs("div",{className:r.priceRows,children:[E(n,o,"month"),E(a,p,"year")]})}function Re(n){const a=[n.pricing.month,n.pricing.year].filter(Boolean);if(a.some(p=>p.pricingType==="free"))return 0;const o=a.map(p=>p.pricingType==="stripe"&&typeof p.unitAmount=="number"?p.unitAmount:null).filter(p=>p!=null);return o.length>0?Math.min(...o):Number.POSITIVE_INFINITY}function ut(n){return String(n||"").replace(/[_\-.]+/g," ").replace(/\b\w/g,a=>a.toUpperCase())}function Ie(n,a){const o=n?.[a],p=Number(o);return Number.isFinite(p)?Math.max(1,Math.floor(p)):null}function ve(n,a){return a!==1?n:n.replace(/\b([A-Za-z]+)ies\b$/,"$1y").replace(/\b([A-Za-z]+[^s\s])s\b$/,"$1")}function dt(n){return n<=1e3?{value:String(n),unit:"MB"}:{value:String(Math.round(n/1e3)),unit:"GB"}}function mt(n,a){const o=String(n.publicLabel||n.label||"").trim()||ut(n.featureKey),p=n.config&&typeof n.config=="object"?n.config:{};if(n.featureKey==="context.uploads"){const l=Ie(p,"storageLimitMb");if(l!==null){const _=dt(l);return{limitValue:_.value,limitUnit:_.unit,baseLabel:ve(o,l)}}}if(n.featureKey==="workspace.workspaces"){const l=Ie(p,"maxWorkspaces");if(l!==null)return{limitValue:String(l),limitUnit:null,baseLabel:ve(o,l)}}if(n.featureKey==="collaboration.ai_profiles"){const l=Ie(p,"maxAiProfiles");if(l!==null)return{limitValue:String(l),limitUnit:null,baseLabel:ve(o,l)}}if(n.featureKey==="collaboration.team_management"){const l=Number(a);if(Number.isFinite(l)&&l>0){const _=Math.floor(l);return{limitValue:String(_),limitUnit:null,baseLabel:ve(o,_)}}}return{limitValue:null,limitUnit:null,baseLabel:o}}function pt({heading:n,subtitle:a,variant:o="app",theme:p="dark",chrome:l,footer:_,isAuthenticated:E,authSessionResolved:I=!0,currentPlanId:$,currentPlanVersionId:x,currentEntitlementState:b,markCurrentPlan:W,canManageCurrentPlan:G=!0,pricingEndpoint:A,statusBanner:H,onBack:j,backLabel:T,backDisabled:M=!1,topActions:se,shellOwnsScroll:ye=!1,showPageBackButton:X=!0,showHeaderBarWithChrome:re=!1,preferPricingPageTitle:_e=!0,currentPlanCardActionMode:Ce="manage",fallbackPricingSource:f=null,onSelectPlan:q}){const[Z,Q]=s.useState([]),[ce,F]=s.useState(null),[N,L]=s.useState({pageTitle:null,pageDescription:null}),[oe,z]=s.useState(!0),[le,ue]=s.useState(null),[Se,ee]=s.useState(0);s.useEffect(()=>{let i=!0;return(async()=>{const D=String(A||"/api/taskforce/public/pricing").trim()||"/api/taskforce/public/pricing";i&&(z(!0),ue(null));try{const v=await fetch(D,{method:"GET",credentials:"include"}),u=await v.json().catch(()=>({}));if(v.ok){i&&(Q(Array.isArray(u?.plans)?u.plans:[]),F(u?.pricingSource&&typeof u.pricingSource=="object"?u.pricingSource:null),L({pageTitle:typeof u?.pageTitle=="string"&&u.pageTitle.trim()||null,pageDescription:typeof u?.pageDescription=="string"&&u.pageDescription.trim()||null}));return}throw new Error(String(u?.error||`Failed to load pricing (${v.status})`))}catch(v){if(i){const u=v instanceof Error?v.message:"Failed to load pricing";ue(u||"Failed to load pricing"),F(null),L({pageTitle:null,pageDescription:null})}}finally{i&&z(!1)}})(),()=>{i=!1}},[A,Se]);const J=s.useMemo(()=>[...Z].sort((i,U)=>{const D=Re(i),v=Re(U);if(D!==v)return D-v;const u=i.defaultVersion?.versionNumber||0,O=U.defaultVersion?.versionNumber||0;return u!==O?u-O:String(i.displayName||i.planId).localeCompare(String(U.displayName||U.planId))}),[Z]),de=s.useMemo(()=>rt(ce||f),[f,ce]),xe=String((_e?N.pageTitle:null)||n).trim()||n,me=String(N.pageDescription||a||"").trim(),w=s.useMemo(()=>st(me),[me]),ne=I,pe=`${r.plansWrapper} ${ye?r.shellOwnsScroll:"tf-scrollbar"} ${o==="site"?r.siteVariant:""} ${l?r.withChrome:""}`.trim(),B=i=>ye?e.jsxs(e.Fragment,{children:[l,i,_]}):e.jsxs("div",{className:Oe.standaloneWrapper,"data-theme":p,children:[l,i,_]});return B(oe?e.jsx(e.Fragment,{children:e.jsx("div",{className:pe,children:e.jsx("div",{className:r.contentFrame,children:e.jsxs("div",{className:r.loader,children:[e.jsx(ze,{size:48,className:r.spinner}),e.jsx("p",{children:"Loading plans..."})]})})})}):le?e.jsx(e.Fragment,{children:e.jsx("div",{className:pe,children:e.jsx("div",{className:r.contentFrame,children:e.jsxs("div",{className:r.emptyState,children:[e.jsx("h2",{children:"Connecting to plan pricing..."}),e.jsx("p",{children:le}),e.jsx("button",{className:r.backBtn,onClick:()=>ee(i=>i+1),children:"Retry"})]})})})}):e.jsx(e.Fragment,{children:e.jsx("div",{className:pe,children:e.jsxs("div",{className:r.contentFrame,children:[e.jsxs("div",{className:r.header,children:[(!l||re)&&(X||se)&&e.jsxs("div",{className:r.headerBar,children:[e.jsx("div",{children:X?e.jsx("button",{className:r.backBtn,onClick:j,disabled:M,children:T}):null}),e.jsx("div",{className:r.headerActions,children:se})]}),e.jsx("h1",{className:r.title,children:xe}),w&&e.jsx("div",{className:r.subtitle,dangerouslySetInnerHTML:{__html:w}}),tt()&&de?e.jsxs("p",{className:r.debugMeta,children:["Pricing source: ",de]}):null,H&&e.jsx("div",{className:`${r.statusBanner} ${H.type==="success"?r.successBanner:H.type==="info"?r.infoBanner:r.errorBanner}`,children:H.message})]}),e.jsxs("section",{className:r.foundingBeta,"aria-labelledby":"founding-beta-heading",children:[e.jsx("h2",{id:"founding-beta-heading",children:"Founding beta"}),e.jsx("p",{children:"Taskforce is in founding beta. You may run into rough edges while we improve cloud workspaces and agent workflows. Early members get access while the product is still forming, plus a direct role in shaping what comes next."})]}),J.length===0?e.jsxs("div",{className:`${r.emptyState} ${r.marketingEmptyState}`,children:[e.jsx("span",{className:r.emptyBadge,children:"Coming Soon"}),e.jsx("h2",{children:"Paid plans are getting their final polish."}),e.jsx("p",{children:"Taskforce pricing is on the way with flexible options for solo operators, teams, and larger rollouts. Check back soon for launch tiers, feature bundles, and early access details."}),e.jsxs("div",{className:r.emptyHighlights,"aria-label":"Upcoming pricing highlights",children:[e.jsx("span",{children:"Launch-ready tiers"}),e.jsx("span",{children:"Team billing controls"}),e.jsx("span",{children:"Feature-based packaging"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:r.grid,children:J.map(i=>{const U=i.pricing.month,D=i.pricing.year,v=i.campaignPricing?.month||null,u=i.campaignPricing?.year||null,O=Le(U,v),K=Le(D,u),Y=V(O.price),ae=V(K.price),ie=Y&&ae,k=String(i.defaultVersion?.planVersionId||"").trim(),Ne=he(b),ge=W??Ne,ke=!!(k&&x&&x===k)||!!(!x&&($&&$===i.planId)),te=ge&&ke&&b!=="canceled",t=Y?"month":ae?"year":null,c=t==="year"?K:O,y=Ce==="manage",g=Ce==="indicator",h=ne&&!!k&&(te?y&&G:!!t),m=()=>{if(k){if(te){if(!y||!G)return;q({planId:i.planId,planVersionId:k,interval:t||"month",pricingType:c.price?.pricingType||"stripe",pricingAudience:c.pricingAudience,isCurrentPlan:!0});return}t&&q({planId:i.planId,planVersionId:k,interval:t,pricingType:c.price?.pricingType||"stripe",pricingAudience:c.pricingAudience,isCurrentPlan:!1})}};return e.jsxs("div",{className:`${r.planCard} ${te?r.activePlanCard:""} ${h?r.clickablePlanCard:""}`,"data-testid":`plan-card-${i.planId}`,role:h?"button":void 0,tabIndex:h?0:void 0,onClick:h?m:void 0,onKeyDown:h?d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),m())}:void 0,children:[te&&e.jsx("span",{className:r.currentBadge,children:"Current Plan"}),e.jsx("h3",{className:r.planName,children:i.displayName}),lt(U,D,v,u),String(i.description||"").trim()&&e.jsx("p",{className:r.planDescription,children:String(i.description||"").trim()}),e.jsx("div",{className:r.featuresList,children:Array.isArray(i.features)&&i.features.length>0?i.features.map((d,S)=>e.jsxs("div",{className:r.featureItem,children:[e.jsx(qe,{className:r.featureIcon}),e.jsxs("div",{className:r.featureTextBlock,children:[(()=>{const{limitValue:P,limitUnit:C,baseLabel:R}=mt(d,i.defaultVersion?.seatLimit);return e.jsxs("span",{className:r.featureText,children:[P&&e.jsxs("span",{className:r.featureLimitAccent,children:[e.jsx("span",{children:P}),C?e.jsx("span",{className:r.featureLimitUnit,children:C}):null]}),e.jsx("span",{children:P?` ${R}`:R})]})})(),d.publicDescriptionVisible!==!1&&String(d.publicDescription||d.description||"").trim()&&e.jsx("span",{className:r.featureDescription,children:String(d.publicDescription||d.description||"").trim()})]})]},`${d.featureKey}-${S}`)):e.jsx("span",{className:r.featureText,children:"No additional features included"})}),te?y?e.jsx("button",{className:`${r.callToAction} ${r.currentCta}`,"data-testid":`plan-manage-${i.planId}`,onClick:d=>{d.stopPropagation(),G&&q({planId:i.planId,planVersionId:k,interval:t||"month",pricingType:c.price?.pricingType||"stripe",pricingAudience:c.pricingAudience,isCurrentPlan:!0})},disabled:!k||!G||!ne,children:E&&G?"Manage Plan":"Current Plan"}):g?e.jsx("button",{className:`${r.callToAction} ${r.currentCta}`,"data-testid":`plan-current-${i.planId}`,disabled:!0,children:"Current Plan"}):null:e.jsxs("div",{className:r.ctaRow,children:[Y?e.jsx("button",{className:`${r.callToAction} ${r.secondaryCta}`,"data-testid":`plan-select-${i.planId}-month`,onClick:d=>{d.stopPropagation(),q({planId:i.planId,planVersionId:k,interval:"month",pricingType:O.price?.pricingType||"stripe",pricingAudience:O.pricingAudience,isCurrentPlan:!1})},disabled:!k||!ne,children:ie?"Start Monthly":"Get Started"}):null,ae?e.jsx("button",{className:`${r.callToAction} ${r.primaryCta}`,"data-testid":`plan-select-${i.planId}-year`,onClick:d=>{d.stopPropagation(),q({planId:i.planId,planVersionId:k,interval:"year",pricingType:K.price?.pricingType||"stripe",pricingAudience:K.pricingAudience,isCurrentPlan:!1})},disabled:!k||!ne,children:ie?"Start Yearly":"Get Started"}):null]})]},i.planId)})}),e.jsxs("div",{className:r.pricingNotes,children:[e.jsx("p",{children:"Prices are listed in USD. Taxes may apply."}),e.jsx("p",{children:"Local install is free on every plan. Cloud limits apply only to hosted workspaces."})]}),e.jsxs("section",{className:`${r.foundingBeta} ${r.cloudCapacityNote}`,"aria-labelledby":"cloud-capacity-heading",children:[e.jsx("h2",{id:"cloud-capacity-heading",children:"Need more cloud capacity?"}),e.jsx("p",{children:"Pro users can request expanded limits for cloud workspaces, AI agents, and storage."}),e.jsxs("p",{children:["Contact ",e.jsx("a",{href:"mailto:support@taskforcehq.ai",children:"support@taskforcehq.ai"})," to discuss capacity needs."]})]}),e.jsxs("div",{className:`${r.planCard} ${r.planNoticeCard} ${r.teamComingSoonCard}`,children:[e.jsx("h2",{className:r.planName,children:"Team workspaces are coming soon."}),e.jsx("p",{className:r.planDescription,children:"Shared workspaces, collaborators, team agent rosters, admin controls, and larger cloud limits are in development."})]})]})]})})}))}const gt=1600,Ee=[0,500,1e3,2e3],ft=5e3,bt=45e3,ht="Choose a plan to continue.";function yt(n,a){if(n===401)return!0;const o=String(a||"").trim().toUpperCase();return o==="CHECKOUT_SESSION_INCOMPLETE"||o==="CHECKOUT_PLAN_VERSION_UNRESOLVED"}function _t(n){return n==="year"?"year":"month"}function Ct(n){return n==="campaign"?"campaign":"public"}function Ae(n){const a=String(n||"").trim().toLowerCase();return a==="year"?"year":a==="month"?"month":null}function Be(n){const a=String(n||"").trim();return a?a.replace(/\/+$/,""):""}function je(n={}){const a=new URLSearchParams;a.set("screen","plans");for(const[o,p]of Object.entries(n)){const l=String(p||"").trim();l&&a.set(o,l)}return`/?${a.toString()}`}function jt({isAuthenticated:n,authUserId:a,runtimeMode:o,authSessionResolved:p,currentTheme:l="dark",projectName:_,currentWorkspaceId:E,apiBaseUrl:I,connectedEnvironmentSource:$,resolveCloudAuthUrl:x,embedded:b=!1,shellOwnsScroll:W=!1,onAccountProfileSummaryChange:G,onContinueToTaskforce:A,continueBusy:H=!1}){const j=We(),T=Ge(),[M,se]=s.useState(null),[ye,X]=s.useState(!1),[re,_e]=s.useState(!1),[Ce,f]=s.useState(null),q=s.useRef(!1),Z=s.useRef(null),Q=s.useRef(null),ce=s.useRef(A),F=s.useMemo(()=>new URLSearchParams(T.search),[T.search]),N=String(F.get("checkout")||"").trim().toLowerCase(),L=String(F.get("gate")||"").trim().toLowerCase(),oe=String(F.get("planId")||"").trim(),z=String(F.get("planVersionId")||"").trim(),le=_t(F.get("interval")),ue=Ct(F.get("pricingAudience")),Se=Ae(F.get("interval")),ee=String(F.get("session_id")||"").trim(),J=s.useMemo(()=>Be(I),[I]),de=s.useMemo(()=>Be($),[$]),xe=s.useMemo(()=>({environment:Ve(de||J),runtimeMode:o==="cloud"?"cloud":"local"}),[J,de,o]),me=s.useCallback(t=>{const c=String(t||"").trim();return J?`${J}${c.startsWith("/")?c:`/${c}`}`:c},[J]),w=s.useCallback(t=>x?x(t):me(t),[me,x]),ne=s.useCallback(()=>{const t=new URLSearchParams(T.search);t.delete("screen"),t.delete("gate"),t.delete("checkout"),t.delete("planId"),t.delete("planVersionId"),t.delete("interval"),t.delete("pricingAudience");const c=t.toString();j(`/${c?`?${c}`:""}${T.hash||""}`)},[T.hash,T.search,j]),pe=s.useMemo(()=>w("/api/taskforce/public/pricing"),[w]),B=s.useMemo(()=>Pe(M,L),[M,L]),i=s.useMemo(()=>B.allowReturnToApp,[B.allowReturnToApp]),U=s.useMemo(()=>{const t=String(B.message||"").trim();return!t||t===ht?null:t},[B.message]),D=s.useCallback(()=>{const t=new URLSearchParams(T.search);t.delete("checkout"),t.delete("session_id"),t.delete("gate"),t.delete("planId"),t.delete("planVersionId"),t.delete("interval");const c=t.toString();j(`${T.pathname}${c?`?${c}`:""}${T.hash||""}`,{replace:!0})},[T.hash,T.pathname,T.search,j]),v=s.useCallback(()=>{Q.current!=null&&window.clearTimeout(Q.current),Q.current=window.setTimeout(()=>{D(),Q.current=null},gt)},[D]);s.useEffect(()=>{ce.current=A},[A]);const u=s.useCallback(async t=>{const c=w(fe);if(!n)return se(null),be(c,{identityKey:a}),null;try{const y=await Ke(c,{identityKey:a,force:t?.force===!0});return se(y),G?.(y),y}catch{return null}},[a,w,n,G]),O=s.useCallback((t,c,y)=>{const g=String(c||"").trim();if(y?.preferFallback&&g)return g;const h=Pe(t,L).message;return h||g||"Unable to confirm checkout completion."},[L]),K=s.useCallback((t,c)=>!Pe(t,c).allowReturnToApp,[]),Y=s.useCallback(async(t,c,y="public",g)=>{if(!t){f({type:"error",message:"Selected plan is missing a default plan version."});return}X(!0),f(null);try{const h=await fetch(w("/api/taskforce/billing/checkout-session"),{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({planVersionId:t,interval:c,pricingAudience:y})}),m=await h.json().catch(()=>({}));if(!h.ok){f({type:"error",message:String(m?.error||"Unable to start checkout for selected plan.")});return}const d=String(m?.checkoutState||"").trim().toLowerCase();if(d==="free"){f({type:"success",message:"Plan selected. Your access is ready."}),be(w(fe),{identityKey:a});const C=await u({force:!0}),R=String(C?.entitlementState||"").trim().toLowerCase();g?.autoContinueOnActivation===!0&&he(R)&&await A?.();return}if(d==="updated"){f({type:"success",message:String(m?.message||"Your subscription was updated successfully.")}),be(w(fe),{identityKey:a});const C=await u({force:!0}),R=String(C?.entitlementState||"").trim().toLowerCase();g?.autoContinueOnActivation===!0&&he(R)&&await A?.();return}if(d==="already_current_plan"){f({type:"success",message:String(m?.message||"You are already on this plan.")}),be(w(fe),{identityKey:a}),await u();return}const S=String(m?.returnBaseUrl||"").trim();if(o==="local"&&S)try{const C=window.location.origin,R=new URL(S,C).origin;if(R!==C){f({type:"error",message:`Checkout return is misconfigured for this runtime. Expected ${C} but got ${R}.`});return}}catch{f({type:"error",message:"Checkout return URL is invalid for this runtime."});return}const P=String(m?.url||"").trim();if(!P){f({type:"error",message:"Checkout did not return a redirect URL."});return}window.location.assign(P)}catch{f({type:"error",message:"Unable to start checkout for selected plan."})}finally{X(!1)}},[a,w,u,A,o]),ae=s.useCallback(async(t,c)=>{if(!t)return{confirmed:!1,errorMessage:"Checkout session is missing.",retryable:!1};const y=async()=>{be(w(fe),{identityKey:a});const g=await u({force:!0}),h=String(g?.entitlementState||"").trim().toLowerCase();if(!he(h))return!1;const m=oe,d=z,S=Se,P=String(g?.planId||"").trim(),C=String(g?.planVersionId||"").trim(),R=Ae(g?.billingInterval??null),we=c?.preConfirmationSummary??null,$e=String(we?.entitlementState||"").trim().toLowerCase(),Me=he($e),Ue=String(we?.planId||"").trim(),De=String(we?.planVersionId||"").trim(),Fe=Ae(we?.billingInterval??null);return m&&P&&P!==m||d&&C&&C!==d||S&&R&&R!==S||Me&&!(!!m&&P===m&&Ue!==P)&&!(!!d&&C===d&&De!==C)&&!(!!S&&R===S&&Fe!==R)?!1:(c?.autoContinueOnActivation===!0&&await ce.current?.(),!0)};try{const g=await fetch(w("/api/taskforce/billing/checkout-session/confirm"),{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:t})}),h=await g.json().catch(()=>({}));if(!g.ok){const m=String(h?.code||"").trim(),d=yt(g.status,m);return d&&await y()?{confirmed:!0}:{confirmed:!1,errorMessage:String(h?.error||"Unable to confirm checkout completion."),retryable:d}}return await y()?{confirmed:!0}:{confirmed:!0}}catch{return{confirmed:!1,errorMessage:"Unable to confirm checkout completion.",retryable:!0}}},[a,w,u,Se,oe,z]),ie=s.useCallback(async()=>{if(!n){j(`/login?mode=login&next=${encodeURIComponent(je())}`);return}X(!0),f({type:"info",message:"Opening billing portal..."});try{const t=await fetch(w("/api/taskforce/billing/portal-session"),{method:"POST",credentials:"include"}),c=await t.json().catch(()=>({}));if(!t.ok){f({type:"error",message:String(c?.error||"Failed to open billing portal.")});return}const y=String(c?.url||"").trim();if(!y){f({type:"error",message:"Portal session did not return a redirect URL."});return}window.location.assign(y)}catch{f({type:"error",message:"Failed to open billing portal."})}finally{X(!1)}},[w,n,j]),k=s.useCallback(async()=>{if(!(!A||re||H)){_e(!0);try{await A()}finally{_e(!1)}}},[re,H,A]);s.useEffect(()=>{u()},[u]),s.useEffect(()=>{i&&L==="missing_entitlement"&&D()},[D,L,i]),s.useEffect(()=>()=>{Q.current!=null&&window.clearTimeout(Q.current)},[]),s.useEffect(()=>{N!=="success"&&(Z.current=null)},[N]),s.useEffect(()=>{let t=!1;const c=new Set,y=async g=>{g<=0||await new Promise(h=>{const m=window.setTimeout(()=>{c.delete(m),h()},g);c.add(m)})};if(N==="success"){if(q.current=!0,f({type:"success",message:"Checkout completed successfully. Finalizing your plan..."}),!n&&!p)return()=>{t=!0,c.forEach(m=>window.clearTimeout(m)),c.clear()};if(!n)return f({type:"error",message:"Sign in to finish activating your plan."}),()=>{t=!0,c.forEach(m=>window.clearTimeout(m)),c.clear()};const h=ee||"__missing_session__";return Z.current===h?()=>{t=!0,c.forEach(m=>window.clearTimeout(m)),c.clear()}:((async()=>{const m=Date.now(),d=await u({force:!0});if(t)return;let S=ee?{confirmed:!1,errorMessage:"Unable to confirm checkout completion.",retryable:!0}:{confirmed:!1,errorMessage:"Checkout session is missing.",retryable:!1},P=0;for(;;){const C=P<Ee.length?Ee[P]:ft;if(P+=1,await y(C),t||(S=ee?await ae(ee,{autoContinueOnActivation:K(d,L),preConfirmationSummary:d}):{confirmed:!1,errorMessage:"Checkout session is missing.",retryable:!1},t))return;if(S.confirmed){Z.current=h,f({type:"success",message:"Checkout completed successfully."}),v();return}if(!S.retryable||Date.now()-m>=bt)break}if(!t&&!S.confirmed){const C=await u({force:!0});if(t)return;S.retryable||(Z.current=h),f({type:"error",message:O(C,S.errorMessage,{preferFallback:!S.retryable})}),S.retryable||v();return}})(),()=>{t=!0,c.forEach(m=>window.clearTimeout(m)),c.clear()})}if(N==="cancel"){(async()=>{const g=await u({force:!0});f({type:"error",message:O(g,"Checkout was canceled. No charge was made.")}),v()})();return}if((N==="start"||N==="free")&&n&&z&&!q.current){q.current=!0,(async()=>{const g=await u({force:!0});await Y(z,le,ue,{autoContinueOnActivation:K(g,L)})})();return}},[p,N,ae,L,n,u,le,z,ue,ee,O,v,K,Y]),s.useEffect(()=>{if(!(N==="success"||N==="cancel"||N==="start"||N==="free")){if(U){f({type:B.statusTone,message:U});return}f(t=>!t||t.type!=="error"?t:t.message===B.message?null:t)}},[N,U,B.message,B.statusTone]);const Ne=s.useCallback(async t=>{if(!n){const y=t.pricingType==="free"?"free":"start",g=je({checkout:y,planId:t.planId,planVersionId:t.planVersionId,interval:t.interval,pricingAudience:t.pricingAudience});j(`/login?mode=register&planId=${encodeURIComponent(t.planId)}&planVersionId=${encodeURIComponent(t.planVersionId)}&interval=${encodeURIComponent(t.interval)}&pricingAudience=${encodeURIComponent(t.pricingAudience)}&next=${encodeURIComponent(g)}`);return}if(t.isCurrentPlan){if(!M?.stripeCustomerId){f({type:"success",message:"Your current plan does not use Stripe billing."});return}await ie();return}const c=K(M,L);if(t.pricingType==="free"){await Y(t.planVersionId,t.interval,t.pricingAudience,{autoContinueOnActivation:c});return}await Y(t.planVersionId,t.interval,t.pricingAudience,{autoContinueOnActivation:c})},[M,L,n,j,ie,K,Y]),ge=s.useCallback(()=>{if(i&&A){k();return}if(b){ne();return}if(window.history.length>1){j(-1);return}j("/")},[ne,b,k,i,j,A]),ke=b?null:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:r.navAction,onClick:ge,disabled:H||re||n&&!i,children:i?"Take Me to Taskforce":"Back"}),n&&M?.stripeCustomerId&&e.jsx("button",{className:r.navAction,onClick:()=>{ie()},disabled:ye,children:"Manage billing"}),!n&&e.jsxs("button",{className:r.navAction,onClick:()=>j(`/login?mode=login&next=${encodeURIComponent(je())}`),children:[e.jsx(Ye,{size:16,style:{marginRight:"8px",verticalAlign:"text-bottom"}}),"Sign In"]})]}),te=b?null:e.jsx(He,{projectName:_,currentWorkspaceId:E,runtimeMode:o==="cloud"?"cloud":"local",theme:l,onBrandClick:ge,actions:ke});return e.jsx(pt,{chrome:te,heading:"Subscription Plans",subtitle:"Manage your subscription and explore available features. Your current plan is highlighted below.",variant:"site",theme:l,isAuthenticated:n,authSessionResolved:p,currentPlanId:String(M?.planId||oe||"").trim()||null,currentPlanVersionId:String(M?.planVersionId||z||"").trim()||null,currentEntitlementState:String(M?.entitlementState||"").trim()||null,markCurrentPlan:B.markCurrentPlan,canManageCurrentPlan:!!M?.stripeCustomerId,pricingEndpoint:pe,statusBanner:Ce,onBack:ge,backLabel:i?"Take Me to Taskforce":b?"Back to Board":"Back to App",backDisabled:H||re||n&&!i,topActions:null,shellOwnsScroll:W,showPageBackButton:!1,showHeaderBarWithChrome:!1,currentPlanCardActionMode:"manage",fallbackPricingSource:xe,onSelectPlan:Ne})}export{jt as PlansPage};
|
|
1
|
+
import{r as s,j as e}from"./vendor-react-CKJs5o3c.js";import{H as he,t as Oe,J as Ve,K as Pe,L as fe,N as be,O as Ke,Q as He}from"./index-CGDQY0nN.js";import{aL as qe,h as ze,U as Ye}from"./vendor-icons-CLnehDTw.js";import{u as We,a as Ge}from"./vendor-router-BbWMxlnO.js";import"./vendor-markdown-BUxTU7dS.js";import"./vendor-dnd-DRzYolkg.js";const Qe="_plansWrapper_nb8ab_1",Je="_contentFrame_nb8ab_24",Xe="_shellOwnsScroll_nb8ab_32",Ze="_withChrome_nb8ab_38",en="_siteVariant_nb8ab_42",nn="_title_nb8ab_56",tn="_subtitle_nb8ab_70",rn="_header_nb8ab_77",an="_planCard_nb8ab_92",sn="_grid_nb8ab_105",cn="_pricingNotes_nb8ab_113",on="_planName_nb8ab_122",ln="_featureText_nb8ab_129",un="_currentBadge_nb8ab_133",dn="_navAction_nb8ab_137",mn="_backBtn_nb8ab_138",pn="_priceRows_nb8ab_149",gn="_foundingBeta_nb8ab_153",fn="_cloudCapacityNote_nb8ab_172",bn="_headerBar_nb8ab_239",hn="_headerActions_nb8ab_248",yn="_debugMeta_nb8ab_299",_n="_planNoticeCard_nb8ab_362",Cn="_planDescription_nb8ab_373",Sn="_teamComingSoonCard_nb8ab_378",wn="_clickablePlanCard_nb8ab_397",vn="_activePlanCard_nb8ab_412",xn="_callToAction_nb8ab_476",Nn="_primaryCta_nb8ab_488",kn="_secondaryCta_nb8ab_499",Pn="_currentCta_nb8ab_511",In="_featuresList_nb8ab_525",An="_priceRow_nb8ab_149",jn="_regularPriceLine_nb8ab_549",Tn="_campaignPriceLine_nb8ab_550",Ln="_priceRowWithCampaign_nb8ab_557",Rn="_priceRowAmount_nb8ab_561",En="_regularPriceDiscounted_nb8ab_567",Bn="_priceRowInterval_nb8ab_573",$n="_campaignPriceLabel_nb8ab_582",Mn="_campaignPriceAmount_nb8ab_587",Un="_campaignPriceInterval_nb8ab_593",Dn="_ctaRow_nb8ab_598",Fn="_featureItem_nb8ab_604",On="_featureIcon_nb8ab_610",Vn="_featureLimitAccent_nb8ab_624",Kn="_featureLimitUnit_nb8ab_635",Hn="_featureTextBlock_nb8ab_641",qn="_featureDescription_nb8ab_647",zn="_emptyState_nb8ab_653",Yn="_marketingEmptyState_nb8ab_662",Wn="_emptyBadge_nb8ab_690",Gn="_emptyHighlights_nb8ab_705",Qn="_loader_nb8ab_727",Jn="_spinner_nb8ab_737",Xn="_statusBanner_nb8ab_790",Zn="_successBanner_nb8ab_798",et="_infoBanner_nb8ab_804",nt="_errorBanner_nb8ab_810",r={plansWrapper:Qe,contentFrame:Je,shellOwnsScroll:Xe,withChrome:Ze,siteVariant:en,title:nn,subtitle:tn,header:rn,planCard:an,grid:sn,pricingNotes:cn,planName:on,featureText:ln,currentBadge:un,navAction:dn,backBtn:mn,priceRows:pn,foundingBeta:gn,cloudCapacityNote:fn,headerBar:bn,headerActions:hn,debugMeta:yn,planNoticeCard:_n,planDescription:Cn,teamComingSoonCard:Sn,clickablePlanCard:wn,activePlanCard:vn,callToAction:xn,primaryCta:Nn,secondaryCta:kn,currentCta:Pn,featuresList:In,priceRow:An,regularPriceLine:jn,campaignPriceLine:Tn,priceRowWithCampaign:Ln,priceRowAmount:Rn,regularPriceDiscounted:En,priceRowInterval:Bn,campaignPriceLabel:$n,campaignPriceAmount:Mn,campaignPriceInterval:Un,ctaRow:Dn,featureItem:Fn,featureIcon:On,featureLimitAccent:Vn,featureLimitUnit:Kn,featureTextBlock:Hn,featureDescription:qn,emptyState:zn,marketingEmptyState:Yn,emptyBadge:Wn,emptyHighlights:Gn,loader:Qn,spinner:Jn,statusBanner:Xn,successBanner:Zn,infoBanner:et,errorBanner:nt};function tt(){const n=globalThis.__DEBUG_MODE__;return typeof n=="boolean"?n:!1}function rt(n){const a=String(n?.environment||"").trim(),o=String(n?.runtimeMode||"").trim();return!a&&!o?null:a&&o?`${a} (${o})`:a||o||null}const at=new Set(["a","b","br","em","i","li","ol","p","strong","u","ul"]);function it(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function st(n){const a=String(n||"").trim();if(!a)return"";if(typeof document>"u")return it(a);const o=document.createElement("template");o.innerHTML=a;const p=document.createElement("div"),l=_=>{if(_.nodeType===Node.TEXT_NODE)return document.createTextNode(_.textContent||"");if(_.nodeType!==Node.ELEMENT_NODE)return null;const E=_,I=E.tagName.toLowerCase();if(I==="script"||I==="style")return null;const $=Array.from(E.childNodes).map(l).filter(b=>!!b);if(!at.has(I)){const b=document.createDocumentFragment();for(const W of $)b.appendChild(W);return b}const x=document.createElement(I);if(I==="a"){const b=String(E.getAttribute("href")||"").trim();/^(https?:|mailto:|\/|#)/i.test(b)&&(x.setAttribute("href",b),x.setAttribute("rel","noopener noreferrer"))}for(const b of $)x.appendChild(b);return x};for(const _ of Array.from(o.content.childNodes)){const E=l(_);E&&p.appendChild(E)}return p.innerHTML}function ct(n,a){if(n==null||!a)return"Contact Sales";try{return new Intl.NumberFormat("en-US",{style:"currency",currency:a.toUpperCase(),minimumFractionDigits:0}).format(n/100)}catch{return`${a.toUpperCase()} ${n/100}`}}function ot(){return"$0"}function V(n){return n?n.pricingType==="free"?!0:n.unitAmount!=null&&n.currency!=null:!1}function Te(n){return n?n.pricingType==="free"?ot():ct(n.unitAmount,n.currency):"Unavailable"}function Le(n,a){return V(a)?{price:a,pricingAudience:"campaign"}:{price:n,pricingAudience:"public"}}function lt(n,a,o,p){const l=V(n)||V(o),_=V(a)||V(p);if(!l&&!_)return null;const E=(I,$,x)=>{if(!V(I)&&!V($))return null;const b=V($),W=x==="year"?"year":"month";return e.jsxs("div",{className:`${r.priceRow} ${b?r.priceRowWithCampaign:""}`,children:[V(I)?e.jsxs("div",{className:r.regularPriceLine,children:[e.jsx("span",{className:`${r.priceRowAmount} ${b?r.regularPriceDiscounted:""}`,children:Te(I)}),e.jsxs("span",{className:r.priceRowInterval,children:["/ ",W]})]}):null,b?e.jsxs("div",{className:r.campaignPriceLine,children:[e.jsx("span",{className:r.campaignPriceLabel,children:"Founding Offer:"}),e.jsx("span",{className:r.campaignPriceAmount,children:Te($)}),e.jsxs("span",{className:r.campaignPriceInterval,children:["/ ",W]})]}):null]},x)};return e.jsxs("div",{className:r.priceRows,children:[E(n,o,"month"),E(a,p,"year")]})}function Re(n){const a=[n.pricing.month,n.pricing.year].filter(Boolean);if(a.some(p=>p.pricingType==="free"))return 0;const o=a.map(p=>p.pricingType==="stripe"&&typeof p.unitAmount=="number"?p.unitAmount:null).filter(p=>p!=null);return o.length>0?Math.min(...o):Number.POSITIVE_INFINITY}function ut(n){return String(n||"").replace(/[_\-.]+/g," ").replace(/\b\w/g,a=>a.toUpperCase())}function Ie(n,a){const o=n?.[a],p=Number(o);return Number.isFinite(p)?Math.max(1,Math.floor(p)):null}function ve(n,a){return a!==1?n:n.replace(/\b([A-Za-z]+)ies\b$/,"$1y").replace(/\b([A-Za-z]+[^s\s])s\b$/,"$1")}function dt(n){return n<=1e3?{value:String(n),unit:"MB"}:{value:String(Math.round(n/1e3)),unit:"GB"}}function mt(n,a){const o=String(n.publicLabel||n.label||"").trim()||ut(n.featureKey),p=n.config&&typeof n.config=="object"?n.config:{};if(n.featureKey==="context.uploads"){const l=Ie(p,"storageLimitMb");if(l!==null){const _=dt(l);return{limitValue:_.value,limitUnit:_.unit,baseLabel:ve(o,l)}}}if(n.featureKey==="workspace.workspaces"){const l=Ie(p,"maxWorkspaces");if(l!==null)return{limitValue:String(l),limitUnit:null,baseLabel:ve(o,l)}}if(n.featureKey==="collaboration.ai_profiles"){const l=Ie(p,"maxAiProfiles");if(l!==null)return{limitValue:String(l),limitUnit:null,baseLabel:ve(o,l)}}if(n.featureKey==="collaboration.team_management"){const l=Number(a);if(Number.isFinite(l)&&l>0){const _=Math.floor(l);return{limitValue:String(_),limitUnit:null,baseLabel:ve(o,_)}}}return{limitValue:null,limitUnit:null,baseLabel:o}}function pt({heading:n,subtitle:a,variant:o="app",theme:p="dark",chrome:l,footer:_,isAuthenticated:E,authSessionResolved:I=!0,currentPlanId:$,currentPlanVersionId:x,currentEntitlementState:b,markCurrentPlan:W,canManageCurrentPlan:G=!0,pricingEndpoint:A,statusBanner:H,onBack:j,backLabel:T,backDisabled:M=!1,topActions:se,shellOwnsScroll:ye=!1,showPageBackButton:X=!0,showHeaderBarWithChrome:re=!1,preferPricingPageTitle:_e=!0,currentPlanCardActionMode:Ce="manage",fallbackPricingSource:f=null,onSelectPlan:q}){const[Z,Q]=s.useState([]),[ce,F]=s.useState(null),[N,L]=s.useState({pageTitle:null,pageDescription:null}),[oe,z]=s.useState(!0),[le,ue]=s.useState(null),[Se,ee]=s.useState(0);s.useEffect(()=>{let i=!0;return(async()=>{const D=String(A||"/api/taskforce/public/pricing").trim()||"/api/taskforce/public/pricing";i&&(z(!0),ue(null));try{const v=await fetch(D,{method:"GET",credentials:"include"}),u=await v.json().catch(()=>({}));if(v.ok){i&&(Q(Array.isArray(u?.plans)?u.plans:[]),F(u?.pricingSource&&typeof u.pricingSource=="object"?u.pricingSource:null),L({pageTitle:typeof u?.pageTitle=="string"&&u.pageTitle.trim()||null,pageDescription:typeof u?.pageDescription=="string"&&u.pageDescription.trim()||null}));return}throw new Error(String(u?.error||`Failed to load pricing (${v.status})`))}catch(v){if(i){const u=v instanceof Error?v.message:"Failed to load pricing";ue(u||"Failed to load pricing"),F(null),L({pageTitle:null,pageDescription:null})}}finally{i&&z(!1)}})(),()=>{i=!1}},[A,Se]);const J=s.useMemo(()=>[...Z].sort((i,U)=>{const D=Re(i),v=Re(U);if(D!==v)return D-v;const u=i.defaultVersion?.versionNumber||0,O=U.defaultVersion?.versionNumber||0;return u!==O?u-O:String(i.displayName||i.planId).localeCompare(String(U.displayName||U.planId))}),[Z]),de=s.useMemo(()=>rt(ce||f),[f,ce]),xe=String((_e?N.pageTitle:null)||n).trim()||n,me=String(N.pageDescription||a||"").trim(),w=s.useMemo(()=>st(me),[me]),ne=I,pe=`${r.plansWrapper} ${ye?r.shellOwnsScroll:"tf-scrollbar"} ${o==="site"?r.siteVariant:""} ${l?r.withChrome:""}`.trim(),B=i=>ye?e.jsxs(e.Fragment,{children:[l,i,_]}):e.jsxs("div",{className:Oe.standaloneWrapper,"data-theme":p,children:[l,i,_]});return B(oe?e.jsx(e.Fragment,{children:e.jsx("div",{className:pe,children:e.jsx("div",{className:r.contentFrame,children:e.jsxs("div",{className:r.loader,children:[e.jsx(ze,{size:48,className:r.spinner}),e.jsx("p",{children:"Loading plans..."})]})})})}):le?e.jsx(e.Fragment,{children:e.jsx("div",{className:pe,children:e.jsx("div",{className:r.contentFrame,children:e.jsxs("div",{className:r.emptyState,children:[e.jsx("h2",{children:"Connecting to plan pricing..."}),e.jsx("p",{children:le}),e.jsx("button",{className:r.backBtn,onClick:()=>ee(i=>i+1),children:"Retry"})]})})})}):e.jsx(e.Fragment,{children:e.jsx("div",{className:pe,children:e.jsxs("div",{className:r.contentFrame,children:[e.jsxs("div",{className:r.header,children:[(!l||re)&&(X||se)&&e.jsxs("div",{className:r.headerBar,children:[e.jsx("div",{children:X?e.jsx("button",{className:r.backBtn,onClick:j,disabled:M,children:T}):null}),e.jsx("div",{className:r.headerActions,children:se})]}),e.jsx("h1",{className:r.title,children:xe}),w&&e.jsx("div",{className:r.subtitle,dangerouslySetInnerHTML:{__html:w}}),tt()&&de?e.jsxs("p",{className:r.debugMeta,children:["Pricing source: ",de]}):null,H&&e.jsx("div",{className:`${r.statusBanner} ${H.type==="success"?r.successBanner:H.type==="info"?r.infoBanner:r.errorBanner}`,children:H.message})]}),e.jsxs("section",{className:r.foundingBeta,"aria-labelledby":"founding-beta-heading",children:[e.jsx("h2",{id:"founding-beta-heading",children:"Founding beta"}),e.jsx("p",{children:"Taskforce is in founding beta. You may run into rough edges while we improve cloud workspaces and agent workflows. Early members get access while the product is still forming, plus a direct role in shaping what comes next."})]}),J.length===0?e.jsxs("div",{className:`${r.emptyState} ${r.marketingEmptyState}`,children:[e.jsx("span",{className:r.emptyBadge,children:"Coming Soon"}),e.jsx("h2",{children:"Paid plans are getting their final polish."}),e.jsx("p",{children:"Taskforce pricing is on the way with flexible options for solo operators, teams, and larger rollouts. Check back soon for launch tiers, feature bundles, and early access details."}),e.jsxs("div",{className:r.emptyHighlights,"aria-label":"Upcoming pricing highlights",children:[e.jsx("span",{children:"Launch-ready tiers"}),e.jsx("span",{children:"Team billing controls"}),e.jsx("span",{children:"Feature-based packaging"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:r.grid,children:J.map(i=>{const U=i.pricing.month,D=i.pricing.year,v=i.campaignPricing?.month||null,u=i.campaignPricing?.year||null,O=Le(U,v),K=Le(D,u),Y=V(O.price),ae=V(K.price),ie=Y&&ae,k=String(i.defaultVersion?.planVersionId||"").trim(),Ne=he(b),ge=W??Ne,ke=!!(k&&x&&x===k)||!!(!x&&($&&$===i.planId)),te=ge&&ke&&b!=="canceled",t=Y?"month":ae?"year":null,c=t==="year"?K:O,y=Ce==="manage",g=Ce==="indicator",h=ne&&!!k&&(te?y&&G:!!t),m=()=>{if(k){if(te){if(!y||!G)return;q({planId:i.planId,planVersionId:k,interval:t||"month",pricingType:c.price?.pricingType||"stripe",pricingAudience:c.pricingAudience,isCurrentPlan:!0});return}t&&q({planId:i.planId,planVersionId:k,interval:t,pricingType:c.price?.pricingType||"stripe",pricingAudience:c.pricingAudience,isCurrentPlan:!1})}};return e.jsxs("div",{className:`${r.planCard} ${te?r.activePlanCard:""} ${h?r.clickablePlanCard:""}`,"data-testid":`plan-card-${i.planId}`,role:h?"button":void 0,tabIndex:h?0:void 0,onClick:h?m:void 0,onKeyDown:h?d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),m())}:void 0,children:[te&&e.jsx("span",{className:r.currentBadge,children:"Current Plan"}),e.jsx("h3",{className:r.planName,children:i.displayName}),lt(U,D,v,u),String(i.description||"").trim()&&e.jsx("p",{className:r.planDescription,children:String(i.description||"").trim()}),e.jsx("div",{className:r.featuresList,children:Array.isArray(i.features)&&i.features.length>0?i.features.map((d,S)=>e.jsxs("div",{className:r.featureItem,children:[e.jsx(qe,{className:r.featureIcon}),e.jsxs("div",{className:r.featureTextBlock,children:[(()=>{const{limitValue:P,limitUnit:C,baseLabel:R}=mt(d,i.defaultVersion?.seatLimit);return e.jsxs("span",{className:r.featureText,children:[P&&e.jsxs("span",{className:r.featureLimitAccent,children:[e.jsx("span",{children:P}),C?e.jsx("span",{className:r.featureLimitUnit,children:C}):null]}),e.jsx("span",{children:P?` ${R}`:R})]})})(),d.publicDescriptionVisible!==!1&&String(d.publicDescription||d.description||"").trim()&&e.jsx("span",{className:r.featureDescription,children:String(d.publicDescription||d.description||"").trim()})]})]},`${d.featureKey}-${S}`)):e.jsx("span",{className:r.featureText,children:"No additional features included"})}),te?y?e.jsx("button",{className:`${r.callToAction} ${r.currentCta}`,"data-testid":`plan-manage-${i.planId}`,onClick:d=>{d.stopPropagation(),G&&q({planId:i.planId,planVersionId:k,interval:t||"month",pricingType:c.price?.pricingType||"stripe",pricingAudience:c.pricingAudience,isCurrentPlan:!0})},disabled:!k||!G||!ne,children:E&&G?"Manage Plan":"Current Plan"}):g?e.jsx("button",{className:`${r.callToAction} ${r.currentCta}`,"data-testid":`plan-current-${i.planId}`,disabled:!0,children:"Current Plan"}):null:e.jsxs("div",{className:r.ctaRow,children:[Y?e.jsx("button",{className:`${r.callToAction} ${r.secondaryCta}`,"data-testid":`plan-select-${i.planId}-month`,onClick:d=>{d.stopPropagation(),q({planId:i.planId,planVersionId:k,interval:"month",pricingType:O.price?.pricingType||"stripe",pricingAudience:O.pricingAudience,isCurrentPlan:!1})},disabled:!k||!ne,children:ie?"Start Monthly":"Get Started"}):null,ae?e.jsx("button",{className:`${r.callToAction} ${r.primaryCta}`,"data-testid":`plan-select-${i.planId}-year`,onClick:d=>{d.stopPropagation(),q({planId:i.planId,planVersionId:k,interval:"year",pricingType:K.price?.pricingType||"stripe",pricingAudience:K.pricingAudience,isCurrentPlan:!1})},disabled:!k||!ne,children:ie?"Start Yearly":"Get Started"}):null]})]},i.planId)})}),e.jsxs("div",{className:r.pricingNotes,children:[e.jsx("p",{children:"Prices are listed in USD. Taxes may apply."}),e.jsx("p",{children:"Local install is free on every plan. Cloud limits apply only to hosted workspaces."})]}),e.jsxs("section",{className:`${r.foundingBeta} ${r.cloudCapacityNote}`,"aria-labelledby":"cloud-capacity-heading",children:[e.jsx("h2",{id:"cloud-capacity-heading",children:"Need more cloud capacity?"}),e.jsx("p",{children:"Pro users can request expanded limits for cloud workspaces, AI agents, and storage."}),e.jsxs("p",{children:["Contact ",e.jsx("a",{href:"mailto:support@taskforcehq.ai",children:"support@taskforcehq.ai"})," to discuss capacity needs."]})]}),e.jsxs("div",{className:`${r.planCard} ${r.planNoticeCard} ${r.teamComingSoonCard}`,children:[e.jsx("h2",{className:r.planName,children:"Team workspaces are coming soon."}),e.jsx("p",{className:r.planDescription,children:"Shared workspaces, collaborators, team agent rosters, admin controls, and larger cloud limits are in development."})]})]})]})})}))}const gt=1600,Ee=[0,500,1e3,2e3],ft=5e3,bt=45e3,ht="Choose a plan to continue.";function yt(n,a){if(n===401)return!0;const o=String(a||"").trim().toUpperCase();return o==="CHECKOUT_SESSION_INCOMPLETE"||o==="CHECKOUT_PLAN_VERSION_UNRESOLVED"}function _t(n){return n==="year"?"year":"month"}function Ct(n){return n==="campaign"?"campaign":"public"}function Ae(n){const a=String(n||"").trim().toLowerCase();return a==="year"?"year":a==="month"?"month":null}function Be(n){const a=String(n||"").trim();return a?a.replace(/\/+$/,""):""}function je(n={}){const a=new URLSearchParams;a.set("screen","plans");for(const[o,p]of Object.entries(n)){const l=String(p||"").trim();l&&a.set(o,l)}return`/?${a.toString()}`}function jt({isAuthenticated:n,authUserId:a,runtimeMode:o,authSessionResolved:p,currentTheme:l="dark",projectName:_,currentWorkspaceId:E,apiBaseUrl:I,connectedEnvironmentSource:$,resolveCloudAuthUrl:x,embedded:b=!1,shellOwnsScroll:W=!1,onAccountProfileSummaryChange:G,onContinueToTaskforce:A,continueBusy:H=!1}){const j=We(),T=Ge(),[M,se]=s.useState(null),[ye,X]=s.useState(!1),[re,_e]=s.useState(!1),[Ce,f]=s.useState(null),q=s.useRef(!1),Z=s.useRef(null),Q=s.useRef(null),ce=s.useRef(A),F=s.useMemo(()=>new URLSearchParams(T.search),[T.search]),N=String(F.get("checkout")||"").trim().toLowerCase(),L=String(F.get("gate")||"").trim().toLowerCase(),oe=String(F.get("planId")||"").trim(),z=String(F.get("planVersionId")||"").trim(),le=_t(F.get("interval")),ue=Ct(F.get("pricingAudience")),Se=Ae(F.get("interval")),ee=String(F.get("session_id")||"").trim(),J=s.useMemo(()=>Be(I),[I]),de=s.useMemo(()=>Be($),[$]),xe=s.useMemo(()=>({environment:Ve(de||J),runtimeMode:o==="cloud"?"cloud":"local"}),[J,de,o]),me=s.useCallback(t=>{const c=String(t||"").trim();return J?`${J}${c.startsWith("/")?c:`/${c}`}`:c},[J]),w=s.useCallback(t=>x?x(t):me(t),[me,x]),ne=s.useCallback(()=>{const t=new URLSearchParams(T.search);t.delete("screen"),t.delete("gate"),t.delete("checkout"),t.delete("planId"),t.delete("planVersionId"),t.delete("interval"),t.delete("pricingAudience");const c=t.toString();j(`/${c?`?${c}`:""}${T.hash||""}`)},[T.hash,T.search,j]),pe=s.useMemo(()=>w("/api/taskforce/public/pricing"),[w]),B=s.useMemo(()=>Pe(M,L),[M,L]),i=s.useMemo(()=>B.allowReturnToApp,[B.allowReturnToApp]),U=s.useMemo(()=>{const t=String(B.message||"").trim();return!t||t===ht?null:t},[B.message]),D=s.useCallback(()=>{const t=new URLSearchParams(T.search);t.delete("checkout"),t.delete("session_id"),t.delete("gate"),t.delete("planId"),t.delete("planVersionId"),t.delete("interval");const c=t.toString();j(`${T.pathname}${c?`?${c}`:""}${T.hash||""}`,{replace:!0})},[T.hash,T.pathname,T.search,j]),v=s.useCallback(()=>{Q.current!=null&&window.clearTimeout(Q.current),Q.current=window.setTimeout(()=>{D(),Q.current=null},gt)},[D]);s.useEffect(()=>{ce.current=A},[A]);const u=s.useCallback(async t=>{const c=w(fe);if(!n)return se(null),be(c,{identityKey:a}),null;try{const y=await Ke(c,{identityKey:a,force:t?.force===!0});return se(y),G?.(y),y}catch{return null}},[a,w,n,G]),O=s.useCallback((t,c,y)=>{const g=String(c||"").trim();if(y?.preferFallback&&g)return g;const h=Pe(t,L).message;return h||g||"Unable to confirm checkout completion."},[L]),K=s.useCallback((t,c)=>!Pe(t,c).allowReturnToApp,[]),Y=s.useCallback(async(t,c,y="public",g)=>{if(!t){f({type:"error",message:"Selected plan is missing a default plan version."});return}X(!0),f(null);try{const h=await fetch(w("/api/taskforce/billing/checkout-session"),{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({planVersionId:t,interval:c,pricingAudience:y})}),m=await h.json().catch(()=>({}));if(!h.ok){f({type:"error",message:String(m?.error||"Unable to start checkout for selected plan.")});return}const d=String(m?.checkoutState||"").trim().toLowerCase();if(d==="free"){f({type:"success",message:"Plan selected. Your access is ready."}),be(w(fe),{identityKey:a});const C=await u({force:!0}),R=String(C?.entitlementState||"").trim().toLowerCase();g?.autoContinueOnActivation===!0&&he(R)&&await A?.();return}if(d==="updated"){f({type:"success",message:String(m?.message||"Your subscription was updated successfully.")}),be(w(fe),{identityKey:a});const C=await u({force:!0}),R=String(C?.entitlementState||"").trim().toLowerCase();g?.autoContinueOnActivation===!0&&he(R)&&await A?.();return}if(d==="already_current_plan"){f({type:"success",message:String(m?.message||"You are already on this plan.")}),be(w(fe),{identityKey:a}),await u();return}const S=String(m?.returnBaseUrl||"").trim();if(o==="local"&&S)try{const C=window.location.origin,R=new URL(S,C).origin;if(R!==C){f({type:"error",message:`Checkout return is misconfigured for this runtime. Expected ${C} but got ${R}.`});return}}catch{f({type:"error",message:"Checkout return URL is invalid for this runtime."});return}const P=String(m?.url||"").trim();if(!P){f({type:"error",message:"Checkout did not return a redirect URL."});return}window.location.assign(P)}catch{f({type:"error",message:"Unable to start checkout for selected plan."})}finally{X(!1)}},[a,w,u,A,o]),ae=s.useCallback(async(t,c)=>{if(!t)return{confirmed:!1,errorMessage:"Checkout session is missing.",retryable:!1};const y=async()=>{be(w(fe),{identityKey:a});const g=await u({force:!0}),h=String(g?.entitlementState||"").trim().toLowerCase();if(!he(h))return!1;const m=oe,d=z,S=Se,P=String(g?.planId||"").trim(),C=String(g?.planVersionId||"").trim(),R=Ae(g?.billingInterval??null),we=c?.preConfirmationSummary??null,$e=String(we?.entitlementState||"").trim().toLowerCase(),Me=he($e),Ue=String(we?.planId||"").trim(),De=String(we?.planVersionId||"").trim(),Fe=Ae(we?.billingInterval??null);return m&&P&&P!==m||d&&C&&C!==d||S&&R&&R!==S||Me&&!(!!m&&P===m&&Ue!==P)&&!(!!d&&C===d&&De!==C)&&!(!!S&&R===S&&Fe!==R)?!1:(c?.autoContinueOnActivation===!0&&await ce.current?.(),!0)};try{const g=await fetch(w("/api/taskforce/billing/checkout-session/confirm"),{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:t})}),h=await g.json().catch(()=>({}));if(!g.ok){const m=String(h?.code||"").trim(),d=yt(g.status,m);return d&&await y()?{confirmed:!0}:{confirmed:!1,errorMessage:String(h?.error||"Unable to confirm checkout completion."),retryable:d}}return await y()?{confirmed:!0}:{confirmed:!0}}catch{return{confirmed:!1,errorMessage:"Unable to confirm checkout completion.",retryable:!0}}},[a,w,u,Se,oe,z]),ie=s.useCallback(async()=>{if(!n){j(`/login?mode=login&next=${encodeURIComponent(je())}`);return}X(!0),f({type:"info",message:"Opening billing portal..."});try{const t=await fetch(w("/api/taskforce/billing/portal-session"),{method:"POST",credentials:"include"}),c=await t.json().catch(()=>({}));if(!t.ok){f({type:"error",message:String(c?.error||"Failed to open billing portal.")});return}const y=String(c?.url||"").trim();if(!y){f({type:"error",message:"Portal session did not return a redirect URL."});return}window.location.assign(y)}catch{f({type:"error",message:"Failed to open billing portal."})}finally{X(!1)}},[w,n,j]),k=s.useCallback(async()=>{if(!(!A||re||H)){_e(!0);try{await A()}finally{_e(!1)}}},[re,H,A]);s.useEffect(()=>{u()},[u]),s.useEffect(()=>{i&&L==="missing_entitlement"&&D()},[D,L,i]),s.useEffect(()=>()=>{Q.current!=null&&window.clearTimeout(Q.current)},[]),s.useEffect(()=>{N!=="success"&&(Z.current=null)},[N]),s.useEffect(()=>{let t=!1;const c=new Set,y=async g=>{g<=0||await new Promise(h=>{const m=window.setTimeout(()=>{c.delete(m),h()},g);c.add(m)})};if(N==="success"){if(q.current=!0,f({type:"success",message:"Checkout completed successfully. Finalizing your plan..."}),!n&&!p)return()=>{t=!0,c.forEach(m=>window.clearTimeout(m)),c.clear()};if(!n)return f({type:"error",message:"Sign in to finish activating your plan."}),()=>{t=!0,c.forEach(m=>window.clearTimeout(m)),c.clear()};const h=ee||"__missing_session__";return Z.current===h?()=>{t=!0,c.forEach(m=>window.clearTimeout(m)),c.clear()}:((async()=>{const m=Date.now(),d=await u({force:!0});if(t)return;let S=ee?{confirmed:!1,errorMessage:"Unable to confirm checkout completion.",retryable:!0}:{confirmed:!1,errorMessage:"Checkout session is missing.",retryable:!1},P=0;for(;;){const C=P<Ee.length?Ee[P]:ft;if(P+=1,await y(C),t||(S=ee?await ae(ee,{autoContinueOnActivation:K(d,L),preConfirmationSummary:d}):{confirmed:!1,errorMessage:"Checkout session is missing.",retryable:!1},t))return;if(S.confirmed){Z.current=h,f({type:"success",message:"Checkout completed successfully."}),v();return}if(!S.retryable||Date.now()-m>=bt)break}if(!t&&!S.confirmed){const C=await u({force:!0});if(t)return;S.retryable||(Z.current=h),f({type:"error",message:O(C,S.errorMessage,{preferFallback:!S.retryable})}),S.retryable||v();return}})(),()=>{t=!0,c.forEach(m=>window.clearTimeout(m)),c.clear()})}if(N==="cancel"){(async()=>{const g=await u({force:!0});f({type:"error",message:O(g,"Checkout was canceled. No charge was made.")}),v()})();return}if((N==="start"||N==="free")&&n&&z&&!q.current){q.current=!0,(async()=>{const g=await u({force:!0});await Y(z,le,ue,{autoContinueOnActivation:K(g,L)})})();return}},[p,N,ae,L,n,u,le,z,ue,ee,O,v,K,Y]),s.useEffect(()=>{if(!(N==="success"||N==="cancel"||N==="start"||N==="free")){if(U){f({type:B.statusTone,message:U});return}f(t=>!t||t.type!=="error"?t:t.message===B.message?null:t)}},[N,U,B.message,B.statusTone]);const Ne=s.useCallback(async t=>{if(!n){const y=t.pricingType==="free"?"free":"start",g=je({checkout:y,planId:t.planId,planVersionId:t.planVersionId,interval:t.interval,pricingAudience:t.pricingAudience});j(`/login?mode=register&planId=${encodeURIComponent(t.planId)}&planVersionId=${encodeURIComponent(t.planVersionId)}&interval=${encodeURIComponent(t.interval)}&pricingAudience=${encodeURIComponent(t.pricingAudience)}&next=${encodeURIComponent(g)}`);return}if(t.isCurrentPlan){if(!M?.stripeCustomerId){f({type:"success",message:"Your current plan does not use Stripe billing."});return}await ie();return}const c=K(M,L);if(t.pricingType==="free"){await Y(t.planVersionId,t.interval,t.pricingAudience,{autoContinueOnActivation:c});return}await Y(t.planVersionId,t.interval,t.pricingAudience,{autoContinueOnActivation:c})},[M,L,n,j,ie,K,Y]),ge=s.useCallback(()=>{if(i&&A){k();return}if(b){ne();return}if(window.history.length>1){j(-1);return}j("/")},[ne,b,k,i,j,A]),ke=b?null:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:r.navAction,onClick:ge,disabled:H||re||n&&!i,children:i?"Take Me to Taskforce":"Back"}),n&&M?.stripeCustomerId&&e.jsx("button",{className:r.navAction,onClick:()=>{ie()},disabled:ye,children:"Manage billing"}),!n&&e.jsxs("button",{className:r.navAction,onClick:()=>j(`/login?mode=login&next=${encodeURIComponent(je())}`),children:[e.jsx(Ye,{size:16,style:{marginRight:"8px",verticalAlign:"text-bottom"}}),"Sign In"]})]}),te=b?null:e.jsx(He,{projectName:_,currentWorkspaceId:E,runtimeMode:o==="cloud"?"cloud":"local",theme:l,onBrandClick:ge,actions:ke});return e.jsx(pt,{chrome:te,heading:"Subscription Plans",subtitle:"Manage your subscription and explore available features. Your current plan is highlighted below.",variant:"site",theme:l,isAuthenticated:n,authSessionResolved:p,currentPlanId:String(M?.planId||oe||"").trim()||null,currentPlanVersionId:String(M?.planVersionId||z||"").trim()||null,currentEntitlementState:String(M?.entitlementState||"").trim()||null,markCurrentPlan:B.markCurrentPlan,canManageCurrentPlan:!!M?.stripeCustomerId,pricingEndpoint:pe,statusBanner:Ce,onBack:ge,backLabel:i?"Take Me to Taskforce":b?"Back to Board":"Back to App",backDisabled:H||re||n&&!i,topActions:null,shellOwnsScroll:W,showPageBackButton:!1,showHeaderBarWithChrome:!1,currentPlanCardActionMode:"manage",fallbackPricingSource:xe,onSelectPlan:Ne})}export{jt as PlansPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s}from"./vendor-react-CKJs5o3c.js";import{ContextAttachmentManager as c}from"./ContextAttachmentManager-
|
|
1
|
+
import{j as s}from"./vendor-react-CKJs5o3c.js";import{ContextAttachmentManager as c}from"./ContextAttachmentManager-AmEny3eI.js";import"./index-CGDQY0nN.js";import"./vendor-icons-CLnehDTw.js";import"./vendor-markdown-BUxTU7dS.js";import"./vendor-dnd-DRzYolkg.js";import"./vendor-router-BbWMxlnO.js";import"./documentReferences-Ca2P--i5.js";function R(t){const{taskId:e,taskReferenceLabel:o,workspaceId:n,apiBaseUrl:a,contextFiles:r,onAddContextFile:m,onRemoveContextFile:p,onUpdateContextCaption:i}=t;return s.jsx(c,{ownerType:"task",ownerId:e,ownerReferenceLabel:o,workspaceId:n,apiBaseUrl:a,attachments:r,onAddAttachment:m,onRemoveAttachment:p,onUpdateAttachmentCaption:i})}export{R as TaskContextUpload};
|