@markus-global/cli 0.9.0-rc.9 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/markus.mjs +2 -1
  2. package/dist/web-ui/assets/{CommentInput-BlbZ7VKo.js → CommentInput-Ccv0KCzc.js} +1 -1
  3. package/dist/web-ui/assets/{ContentRenderer-D6n8VYjL.js → ContentRenderer-BbN7QT3E.js} +2 -2
  4. package/dist/web-ui/assets/{Deliverables-DFihiLvd.js → Deliverables-Dzfujlqv.js} +2 -2
  5. package/dist/web-ui/assets/{Notifications-CbwE8lT2.js → Notifications-DMI9cmK5.js} +1 -1
  6. package/dist/web-ui/assets/{Search-eMMUXLb0.js → Search-Va12fH-V.js} +1 -1
  7. package/dist/web-ui/assets/{Settings-DKruJGh_.js → Settings-D_0MEUGb.js} +2 -2
  8. package/dist/web-ui/assets/{Store-Cb1Q7wEI.js → Store-dRlOlppM.js} +1 -1
  9. package/dist/web-ui/assets/{Team-s6EFtfAR.js → Team-D8m98W3b.js} +5 -5
  10. package/dist/web-ui/assets/{Work-DV7d24C8.js → Work-C6pfFbRU.js} +1 -1
  11. package/dist/web-ui/assets/{arc-C-VcFS_X.js → arc-w52qYN0j.js} +1 -1
  12. package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-CYwXeNHD.js → architectureDiagram-3BPJPVTR-Dq5t04Vy.js} +1 -1
  13. package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-BG_vaJkh.js → blockDiagram-GPEHLZMM-dMSQ7RYP.js} +1 -1
  14. package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-DfIroxLR.js → c4Diagram-AAUBKEIU-yG4K-xPW.js} +1 -1
  15. package/dist/web-ui/assets/channel-0x_SxlyN.js +1 -0
  16. package/dist/web-ui/assets/{chunk-2J33WTMH-BfXujWee.js → chunk-2J33WTMH-BMCCyFP7.js} +1 -1
  17. package/dist/web-ui/assets/{chunk-4BX2VUAB-DxkdXCR9.js → chunk-4BX2VUAB-DrZE__0f.js} +1 -1
  18. package/dist/web-ui/assets/{chunk-55IACEB6-BNOpIjcl.js → chunk-55IACEB6-BHAPJ9Eo.js} +1 -1
  19. package/dist/web-ui/assets/{chunk-727SXJPM-ByySw2Un.js → chunk-727SXJPM-Ctfjl9vK.js} +1 -1
  20. package/dist/web-ui/assets/{chunk-AQP2D5EJ-C4zpNm_k.js → chunk-AQP2D5EJ-SVZPGzSA.js} +1 -1
  21. package/dist/web-ui/assets/{chunk-FMBD7UC4-rTKzVtCG.js → chunk-FMBD7UC4-DeTpOrnv.js} +1 -1
  22. package/dist/web-ui/assets/{chunk-ND2GUHAM-MhvsO0MJ.js → chunk-ND2GUHAM-CudW1r3G.js} +1 -1
  23. package/dist/web-ui/assets/{chunk-QZHKN3VN-BbpDM55y.js → chunk-QZHKN3VN-CJSQIoVy.js} +1 -1
  24. package/dist/web-ui/assets/classDiagram-4FO5ZUOK-D4o-x8Tr.js +1 -0
  25. package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-D4o-x8Tr.js +1 -0
  26. package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-C2DA6Xk1.js → cose-bilkent-S5V4N54A-CcCOSPt7.js} +1 -1
  27. package/dist/web-ui/assets/{dagre-BM42HDAG-BIImdzAe.js → dagre-BM42HDAG-F3l9565T.js} +1 -1
  28. package/dist/web-ui/assets/{diagram-2AECGRRQ-DXl3aQAG.js → diagram-2AECGRRQ-B5Ep5hBX.js} +1 -1
  29. package/dist/web-ui/assets/{diagram-5GNKFQAL-DarT3ln2.js → diagram-5GNKFQAL-Ba-Xi40Z.js} +1 -1
  30. package/dist/web-ui/assets/{diagram-KO2AKTUF-QpkTwtOZ.js → diagram-KO2AKTUF-nq3nvV52.js} +1 -1
  31. package/dist/web-ui/assets/{diagram-LMA3HP47-54jA3rmw.js → diagram-LMA3HP47-BLQG5suI.js} +1 -1
  32. package/dist/web-ui/assets/{diagram-OG6HWLK6-Bb3En4QH.js → diagram-OG6HWLK6-BZwEfL_A.js} +1 -1
  33. package/dist/web-ui/assets/{erDiagram-TEJ5UH35-BcUL0A8p.js → erDiagram-TEJ5UH35-x0d6Urzc.js} +1 -1
  34. package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-gmCdiIuO.js → flowDiagram-I6XJVG4X-Bps4iInm.js} +1 -1
  35. package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-CtI76YKw.js → ganttDiagram-6RSMTGT7-BQhqabZG.js} +1 -1
  36. package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-Dvt2H1c6.js → gitGraphDiagram-PVQCEYII-CZsFUtiG.js} +1 -1
  37. package/dist/web-ui/assets/{index-BozwNihZ.css → index-BDWvYwl1.css} +1 -1
  38. package/dist/web-ui/assets/{index-F0uqyKAR.js → index-BVZKeNvh.js} +57 -57
  39. package/dist/web-ui/assets/{infoDiagram-5YYISTIA-WyExWpd-.js → infoDiagram-5YYISTIA-bUkRpixn.js} +1 -1
  40. package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-Cv8QZTF8.js → ishikawaDiagram-YF4QCWOH-C71uSHjN.js} +1 -1
  41. package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-C-DXeYnj.js → journeyDiagram-JHISSGLW-CH4cq7H3.js} +1 -1
  42. package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-DJ0APtBD.js → kanban-definition-UN3LZRKU-B1plHCmn.js} +1 -1
  43. package/dist/web-ui/assets/{mermaid.core-_6cI_drV.js → mermaid.core-BtKFJxef.js} +5 -5
  44. package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-pxPEjBcg.js → mindmap-definition-RKZ34NQL-BRinAMnx.js} +1 -1
  45. package/dist/web-ui/assets/{pieDiagram-4H26LBE5-BMPbfvEL.js → pieDiagram-4H26LBE5-B8r7cm8D.js} +1 -1
  46. package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-CnXtRQO7.js → quadrantDiagram-W4KKPZXB-BlYE_3Bv.js} +1 -1
  47. package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-CeMb4Hop.js → requirementDiagram-4Y6WPE33-XHqns5Oh.js} +1 -1
  48. package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-D5DVvSZz.js → sankeyDiagram-5OEKKPKP--WceN9u7.js} +1 -1
  49. package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-DK7EUoQ-.js → sequenceDiagram-3UESZ5HK-NXQDJA2d.js} +1 -1
  50. package/dist/web-ui/assets/{stateDiagram-AJRCARHV-j3_M8LL8.js → stateDiagram-AJRCARHV-Cs8Vl8wX.js} +1 -1
  51. package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-Cmof_fUq.js +1 -0
  52. package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-I1cAzAI3.js → timeline-definition-PNZ67QCA-V9TBhcGA.js} +1 -1
  53. package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-DXlwr6Ld.js → vennDiagram-CIIHVFJN-BkrjAkwE.js} +1 -1
  54. package/dist/web-ui/assets/{wardley-L42UT6IY-C8FHfe6H.js → wardley-L42UT6IY-DnYl7xFk.js} +1 -1
  55. package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-jGyDoBHX.js → wardleyDiagram-YWT4CUSO-Bgjk8gUy.js} +1 -1
  56. package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-C-XR4OZf.js → xychartDiagram-2RQKCTM6-DVv-I1Er.js} +1 -1
  57. package/dist/web-ui/index.html +2 -2
  58. package/package.json +1 -1
  59. package/dist/web-ui/assets/channel-DjCsgjVT.js +0 -1
  60. package/dist/web-ui/assets/classDiagram-4FO5ZUOK-CiVlDkMa.js +0 -1
  61. package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-CiVlDkMa.js +0 -1
  62. package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-7i3ifJzo.js +0 -1
package/dist/markus.mjs CHANGED
@@ -61480,10 +61480,11 @@ async function persistImageResult(img, index) {
61480
61480
  const ext = guessImageExt(img.url, img.base64);
61481
61481
  const filepath = join14(mediaDir("images"), `img-${Date.now()}-${index}.${ext}`);
61482
61482
  writeFileSync11(filepath, bytes);
61483
+ const mdPath = filepath.replace(/\\/g, "/");
61483
61484
  return {
61484
61485
  filePath: filepath,
61485
61486
  revisedPrompt: img.revisedPrompt,
61486
- markdown: `![generated image](${filepath})`
61487
+ markdown: `![generated image](${mdPath})`
61487
61488
  };
61488
61489
  }
61489
61490
  function formatVideoToolResult(result) {
@@ -1 +1 @@
1
- import{j as t,u as T,r as a,e as ee}from"./index-F0uqyKAR.js";const te=1920,ne=10*1024*1024,W=5,re=.8;function se(l,u,i){return new Promise((g,f)=>{const y=new Image;y.onload=()=>{let{width:s,height:r}=y;if(s<=u&&r<=u){g(l);return}s>r?(r=Math.round(r*(u/s)),s=u):(s=Math.round(s*(u/r)),r=u);const x=document.createElement("canvas");x.width=s,x.height=r;const b=x.getContext("2d");if(!b){f(new Error("Failed to get canvas context"));return}b.drawImage(y,0,0,s,r),g(x.toDataURL("image/jpeg",i))},y.onerror=()=>f(new Error("Failed to load image")),y.src=l})}function ae({candidates:l,filter:u,anchorRef:i,onSelect:g,selectedIndex:f,onIndexChange:y}){const{t:s}=T("common"),[r,x]=a.useState(null),b=a.useRef(null),w=l.filter(d=>d.name.toLowerCase().includes(u));return a.useEffect(()=>{const d=i.current;if(!d)return;const h=d.getBoundingClientRect();x({top:h.top+window.scrollY-4,left:h.left+window.scrollX+8})},[i,u]),a.useEffect(()=>{if(!b.current||!r)return;if(b.current.getBoundingClientRect().top<8){const h=i.current;if(!h)return;const c=h.getBoundingClientRect();x({top:c.bottom+window.scrollY+4,left:r.left})}},[r,i]),a.useEffect(()=>{f>=w.length&&y(Math.max(0,w.length-1))},[w.length,f,y]),a.useEffect(()=>{if(!b.current)return;b.current.querySelector('[data-selected="true"]')?.scrollIntoView({block:"nearest"})},[f]),!r||w.length===0?null:ee.createPortal(t.jsxs("div",{ref:b,style:{position:"absolute",top:r.top,left:r.left,transform:"translateY(-100%)"},className:"w-60 bg-surface-overlay border border-border-default rounded-lg shadow-xl z-[9999] max-h-48 overflow-y-auto",children:[t.jsx("div",{className:"px-2.5 py-1.5 text-[10px] text-fg-tertiary font-medium uppercase tracking-wider border-b border-border-default",children:s("commentInput.mentionHeading")}),w.map((d,h)=>t.jsxs("button",{"data-selected":h===f,onMouseDown:c=>{c.preventDefault(),g(d)},onMouseEnter:()=>y(h),className:`w-full text-left px-3 py-2 text-xs flex items-center gap-2 transition-colors ${h===f?"bg-brand-500/15 text-brand-500":"hover:bg-surface-elevated"}`,children:[t.jsx("span",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-bold shrink-0 ${d.type==="human"?"bg-green-500/20 text-green-500":"bg-brand-500/20 text-brand-500"}`,children:d.name.slice(0,2).toUpperCase()}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-fg-primary font-medium",children:d.name}),t.jsx("span",{className:"text-fg-tertiary text-[10px] ml-1.5",children:d.subtitle??d.type})]}),d.type==="agent"&&t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${d.online?"bg-green-400":"bg-gray-500"}`})]},d.id))]}),document.body)}function oe(l){return/^\w+$/.test(l)?`@${l}`:`@[${l}]`}const K=/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu;function ie(l){const u=[];let i;for(K.lastIndex=0;(i=K.exec(l))!==null;)u.push(i[1]??i[2]);return u}function ce(l,u,i){const g=[];let f=0;const y=u.map(r=>r.name).sort((r,x)=>x.length-r.length);let s=0;for(;s<l.length;){const r=l.indexOf("@",s);if(r<0){g.push(t.jsx("span",{children:l.slice(s)},f++));break}if(r>s&&g.push(t.jsx("span",{children:l.slice(s,r)},f++)),l[r+1]==="["){const c=l.indexOf("]",r+2);if(c>r+2){const m=l.slice(r+2,c),j=u.find(k=>k.name.toLowerCase()===m.toLowerCase());g.push(t.jsxs("span",{className:`text-brand-500 font-medium ${i&&j?"cursor-pointer hover:underline":""}`,onClick:i&&j?k=>i(j,k):void 0,title:j?`${j.name} (${j.role})`:void 0,children:["@",m]},f++)),s=c+1;continue}}const x=l.slice(r+1),b=x.toLowerCase(),w=y.find(c=>b.startsWith(c.toLowerCase()));if(w){const c=u.find(m=>m.name.toLowerCase()===w.toLowerCase());g.push(t.jsxs("span",{className:`text-brand-500 font-medium ${i&&c?"cursor-pointer hover:underline":""}`,onClick:i&&c?m=>i(c,m):void 0,title:c?`${c.name} (${c.role})`:void 0,children:["@",w]},f++)),s=r+1+w.length;continue}const d=/^([\w\p{L}\p{N}]+)/u,h=x.match(d);if(h){const c=h[1],m=u.find(j=>j.name.toLowerCase()===c.toLowerCase());g.push(t.jsxs("span",{className:`text-brand-500 font-medium ${i&&m?"cursor-pointer hover:underline":""}`,onClick:i&&m?j=>i(m,j):void 0,title:m?`${m.name} (${m.role})`:void 0,children:["@",c]},f++)),s=r+1+c.length;continue}g.push(t.jsx("span",{children:"@"},f++)),s=r+1}return g.length>0?g:[t.jsx("span",{children:l},0)]}function de({agents:l,humans:u,onSubmit:i,placeholder:g,replyTo:f,onCancelReply:y}){const{t:s}=T("common"),[r,x]=a.useState(""),[b,w]=a.useState(!1),[d,h]=a.useState(null),[c,m]=a.useState(!1),[j,k]=a.useState(""),[C,S]=a.useState([]),[B,I]=a.useState(0),[N,M]=a.useState([]),[z,A]=a.useState(!1),F=a.useRef(null),U=a.useRef(null),L=a.useRef(null),$=a.useMemo(()=>{const e=(u??[]).map(n=>({id:n.id,name:n.name,type:"human",subtitle:n.role}));for(const n of l)e.push({id:n.id,name:n.name,type:"agent",subtitle:n.role,online:n.status==="idle"||n.status==="working"});return e},[l,u]),D=$.filter(e=>e.name.toLowerCase().includes(j)),E=a.useCallback(e=>{const n=Array.from(e).filter(o=>o.type.startsWith("image/"));if(n.length!==0)for(const o of n){if(o.size>ne)continue;const p=new FileReader;p.onload=()=>{const R=p.result;se(R,te,re).then(v=>{M(_=>_.length>=W?_:[..._,{id:`img_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,dataUrl:v,name:o.name}])})},p.readAsDataURL(o)}},[]),X=a.useCallback(e=>{M(n=>n.filter(o=>o.id!==e))},[]),Y=a.useCallback(e=>{const n=e.clipboardData?.files;if(n&&n.length>0){const o=Array.from(n).filter(p=>p.type.startsWith("image/"));o.length>0&&(e.preventDefault(),E(o))}},[E]),q=a.useCallback(e=>{e.preventDefault(),A(!1);const n=e.dataTransfer?.files;n&&n.length>0&&E(Array.from(n).filter(o=>o.type.startsWith("image/")))},[E]),G=a.useCallback(e=>{e.preventDefault(),A(!0)},[]),H=a.useCallback(()=>{A(!1)},[]),O=async()=>{if(!(!r.trim()&&N.length===0)){w(!0),h(null),L.current={content:r,mentions:[...C],images:[...N]};try{await i(r,C,[...N],f?.id),x(""),S([]),M([]),L.current=null,y?.()}catch(e){h(String(e instanceof Error?e.message:e)||s("commentInput.sendFailed"))}w(!1)}},Q=async()=>{if(!L.current)return;const{content:e,mentions:n,images:o}=L.current;w(!0),h(null);try{await i(e,n,o),x(""),S([]),M([]),L.current=null}catch(p){h(String(p instanceof Error?p.message:p)||s("commentInput.sendFailed"))}w(!1)},P=a.useCallback(e=>{x(n=>{const o=n.lastIndexOf("@"),p=oe(e.name);return o>=0?n.slice(0,o)+p+" ":n+p+" "}),C.includes(e.id)||S(n=>[...n,e.id]),m(!1),k(""),I(0),F.current?.focus()},[C]),V=e=>{x(e),h(null);const n=e.lastIndexOf("@");if(n>=0&&(n===0||e[n-1]===" ")){const p=e.slice(n+1).toLowerCase();if($.some(v=>v.name.toLowerCase().includes(p))){k(p),m(!0),I(0);return}}m(!1)},Z=e=>{if(c&&D.length>0){const n=e.key==="ArrowUp"||e.ctrlKey&&e.key==="p",o=e.key==="ArrowDown"||e.ctrlKey&&e.key==="n",p=e.key==="Enter"||e.key==="Tab",R=e.key==="Escape";if(n){e.preventDefault(),I(v=>(v-1+D.length)%D.length);return}if(o){e.preventDefault(),I(v=>(v+1)%D.length);return}if(p){e.preventDefault();const v=D[B];v&&P(v);return}if(R){e.preventDefault(),m(!1);return}}e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),O())},J=a.useCallback(()=>{setTimeout(()=>m(!1),200)},[]);return t.jsxs("div",{className:"relative",onDragOver:G,onDragLeave:H,onDrop:q,children:[z&&t.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-brand-500/10 rounded-lg border-2 border-dashed border-brand-500",children:t.jsx("span",{className:"text-sm text-brand-500 font-medium",children:s("commentInput.dragDropHint")})}),c&&t.jsx(ae,{candidates:$,filter:j,anchorRef:F,onSelect:P,selectedIndex:B,onIndexChange:I}),t.jsxs("div",{className:"border border-border-default rounded-lg bg-surface-elevated",children:[f&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 pt-2 pb-1 border-b border-border-default/50",children:[t.jsxs("div",{className:"flex-1 min-w-0 pl-2 border-l-2 border-brand-500/50",children:[t.jsx("span",{className:"text-[10px] font-medium text-brand-500",children:f.authorName}),t.jsx("p",{className:"text-[10px] text-fg-tertiary truncate",children:f.content})]}),t.jsx("button",{onClick:y,className:"text-fg-tertiary hover:text-fg-secondary shrink-0 p-0.5",children:t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),C.length>0&&t.jsx("div",{className:"flex gap-1 px-2.5 pt-2 flex-wrap",children:C.map(e=>{const n=$.find(o=>o.id===e);return t.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded-full ${n?.type==="human"?"bg-green-500/15 text-green-500":"bg-brand-500/15 text-brand-500"}`,children:["@",n?.name??e,t.jsx("button",{onClick:()=>S(o=>o.filter(p=>p!==e)),className:"hover:text-red-400",children:"×"})]},e)})}),t.jsx("textarea",{ref:F,value:r,onChange:e=>V(e.target.value),onKeyDown:Z,onBlur:J,onPaste:Y,placeholder:g??s("commentInput.placeholder"),rows:2,className:"w-full px-2.5 py-2 text-xs bg-transparent text-fg-primary placeholder-fg-tertiary outline-none resize-none"}),N.length>0&&t.jsx("div",{className:"flex items-center gap-1.5 px-2.5 pb-1.5 overflow-x-auto",children:N.map(e=>t.jsxs("div",{className:"relative group/img shrink-0",children:[t.jsx("img",{src:e.dataUrl,alt:e.name,className:"w-12 h-12 rounded-lg object-cover border border-border-default"}),t.jsx("button",{onClick:()=>X(e.id),className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-surface-secondary border border-gray-600 rounded-full flex items-center justify-center text-fg-secondary hover:text-red-500 hover:border-red-500 text-[10px] opacity-0 group-hover/img:opacity-100 transition-opacity",title:s("commentInput.removeImage"),children:"×"})]},e.id))}),d&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 pb-1.5",children:[t.jsx("span",{className:"text-[11px] text-red-400 flex-1 truncate",children:d}),t.jsxs("button",{onClick:Q,disabled:b,className:"text-[11px] text-amber-500 hover:text-amber-400 font-medium transition-colors flex items-center gap-1",children:[t.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("polyline",{points:"23 4 23 10 17 10"}),t.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),s("commentInput.retry")]})]}),t.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2",children:[t.jsx("button",{type:"button",onClick:()=>U.current?.click(),disabled:b||N.length>=W,className:"p-1 text-fg-tertiary hover:text-brand-500 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:s("commentInput.attachImage"),children:t.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),t.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),t.jsx("polyline",{points:"21 15 16 10 5 21"})]})}),t.jsx("input",{ref:U,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:e=>{e.target.files&&E(e.target.files),e.target.value=""}}),t.jsx("button",{onClick:O,disabled:!r.trim()&&N.length===0||b,className:"px-3 py-1 text-[11px] font-medium bg-brand-500 text-white rounded-md hover:bg-brand-600 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:s(b?"commentInput.sending":"commentInput.submit")})]})]}),t.jsx("p",{className:"mt-1 text-center text-[10px] text-fg-tertiary/80 select-none",children:s("aiDisclaimer")})]})}export{de as C,ie as p,ce as r};
1
+ import{j as t,u as T,r as a,e as ee}from"./index-BVZKeNvh.js";const te=1920,ne=10*1024*1024,W=5,re=.8;function se(l,u,i){return new Promise((g,f)=>{const y=new Image;y.onload=()=>{let{width:s,height:r}=y;if(s<=u&&r<=u){g(l);return}s>r?(r=Math.round(r*(u/s)),s=u):(s=Math.round(s*(u/r)),r=u);const x=document.createElement("canvas");x.width=s,x.height=r;const b=x.getContext("2d");if(!b){f(new Error("Failed to get canvas context"));return}b.drawImage(y,0,0,s,r),g(x.toDataURL("image/jpeg",i))},y.onerror=()=>f(new Error("Failed to load image")),y.src=l})}function ae({candidates:l,filter:u,anchorRef:i,onSelect:g,selectedIndex:f,onIndexChange:y}){const{t:s}=T("common"),[r,x]=a.useState(null),b=a.useRef(null),w=l.filter(d=>d.name.toLowerCase().includes(u));return a.useEffect(()=>{const d=i.current;if(!d)return;const h=d.getBoundingClientRect();x({top:h.top+window.scrollY-4,left:h.left+window.scrollX+8})},[i,u]),a.useEffect(()=>{if(!b.current||!r)return;if(b.current.getBoundingClientRect().top<8){const h=i.current;if(!h)return;const c=h.getBoundingClientRect();x({top:c.bottom+window.scrollY+4,left:r.left})}},[r,i]),a.useEffect(()=>{f>=w.length&&y(Math.max(0,w.length-1))},[w.length,f,y]),a.useEffect(()=>{if(!b.current)return;b.current.querySelector('[data-selected="true"]')?.scrollIntoView({block:"nearest"})},[f]),!r||w.length===0?null:ee.createPortal(t.jsxs("div",{ref:b,style:{position:"absolute",top:r.top,left:r.left,transform:"translateY(-100%)"},className:"w-60 bg-surface-overlay border border-border-default rounded-lg shadow-xl z-[9999] max-h-48 overflow-y-auto",children:[t.jsx("div",{className:"px-2.5 py-1.5 text-[10px] text-fg-tertiary font-medium uppercase tracking-wider border-b border-border-default",children:s("commentInput.mentionHeading")}),w.map((d,h)=>t.jsxs("button",{"data-selected":h===f,onMouseDown:c=>{c.preventDefault(),g(d)},onMouseEnter:()=>y(h),className:`w-full text-left px-3 py-2 text-xs flex items-center gap-2 transition-colors ${h===f?"bg-brand-500/15 text-brand-500":"hover:bg-surface-elevated"}`,children:[t.jsx("span",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-bold shrink-0 ${d.type==="human"?"bg-green-500/20 text-green-500":"bg-brand-500/20 text-brand-500"}`,children:d.name.slice(0,2).toUpperCase()}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-fg-primary font-medium",children:d.name}),t.jsx("span",{className:"text-fg-tertiary text-[10px] ml-1.5",children:d.subtitle??d.type})]}),d.type==="agent"&&t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${d.online?"bg-green-400":"bg-gray-500"}`})]},d.id))]}),document.body)}function oe(l){return/^\w+$/.test(l)?`@${l}`:`@[${l}]`}const K=/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu;function ie(l){const u=[];let i;for(K.lastIndex=0;(i=K.exec(l))!==null;)u.push(i[1]??i[2]);return u}function ce(l,u,i){const g=[];let f=0;const y=u.map(r=>r.name).sort((r,x)=>x.length-r.length);let s=0;for(;s<l.length;){const r=l.indexOf("@",s);if(r<0){g.push(t.jsx("span",{children:l.slice(s)},f++));break}if(r>s&&g.push(t.jsx("span",{children:l.slice(s,r)},f++)),l[r+1]==="["){const c=l.indexOf("]",r+2);if(c>r+2){const m=l.slice(r+2,c),j=u.find(k=>k.name.toLowerCase()===m.toLowerCase());g.push(t.jsxs("span",{className:`text-brand-500 font-medium ${i&&j?"cursor-pointer hover:underline":""}`,onClick:i&&j?k=>i(j,k):void 0,title:j?`${j.name} (${j.role})`:void 0,children:["@",m]},f++)),s=c+1;continue}}const x=l.slice(r+1),b=x.toLowerCase(),w=y.find(c=>b.startsWith(c.toLowerCase()));if(w){const c=u.find(m=>m.name.toLowerCase()===w.toLowerCase());g.push(t.jsxs("span",{className:`text-brand-500 font-medium ${i&&c?"cursor-pointer hover:underline":""}`,onClick:i&&c?m=>i(c,m):void 0,title:c?`${c.name} (${c.role})`:void 0,children:["@",w]},f++)),s=r+1+w.length;continue}const d=/^([\w\p{L}\p{N}]+)/u,h=x.match(d);if(h){const c=h[1],m=u.find(j=>j.name.toLowerCase()===c.toLowerCase());g.push(t.jsxs("span",{className:`text-brand-500 font-medium ${i&&m?"cursor-pointer hover:underline":""}`,onClick:i&&m?j=>i(m,j):void 0,title:m?`${m.name} (${m.role})`:void 0,children:["@",c]},f++)),s=r+1+c.length;continue}g.push(t.jsx("span",{children:"@"},f++)),s=r+1}return g.length>0?g:[t.jsx("span",{children:l},0)]}function de({agents:l,humans:u,onSubmit:i,placeholder:g,replyTo:f,onCancelReply:y}){const{t:s}=T("common"),[r,x]=a.useState(""),[b,w]=a.useState(!1),[d,h]=a.useState(null),[c,m]=a.useState(!1),[j,k]=a.useState(""),[C,S]=a.useState([]),[B,I]=a.useState(0),[N,M]=a.useState([]),[z,A]=a.useState(!1),F=a.useRef(null),U=a.useRef(null),L=a.useRef(null),$=a.useMemo(()=>{const e=(u??[]).map(n=>({id:n.id,name:n.name,type:"human",subtitle:n.role}));for(const n of l)e.push({id:n.id,name:n.name,type:"agent",subtitle:n.role,online:n.status==="idle"||n.status==="working"});return e},[l,u]),D=$.filter(e=>e.name.toLowerCase().includes(j)),E=a.useCallback(e=>{const n=Array.from(e).filter(o=>o.type.startsWith("image/"));if(n.length!==0)for(const o of n){if(o.size>ne)continue;const p=new FileReader;p.onload=()=>{const R=p.result;se(R,te,re).then(v=>{M(_=>_.length>=W?_:[..._,{id:`img_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,dataUrl:v,name:o.name}])})},p.readAsDataURL(o)}},[]),X=a.useCallback(e=>{M(n=>n.filter(o=>o.id!==e))},[]),Y=a.useCallback(e=>{const n=e.clipboardData?.files;if(n&&n.length>0){const o=Array.from(n).filter(p=>p.type.startsWith("image/"));o.length>0&&(e.preventDefault(),E(o))}},[E]),q=a.useCallback(e=>{e.preventDefault(),A(!1);const n=e.dataTransfer?.files;n&&n.length>0&&E(Array.from(n).filter(o=>o.type.startsWith("image/")))},[E]),G=a.useCallback(e=>{e.preventDefault(),A(!0)},[]),H=a.useCallback(()=>{A(!1)},[]),O=async()=>{if(!(!r.trim()&&N.length===0)){w(!0),h(null),L.current={content:r,mentions:[...C],images:[...N]};try{await i(r,C,[...N],f?.id),x(""),S([]),M([]),L.current=null,y?.()}catch(e){h(String(e instanceof Error?e.message:e)||s("commentInput.sendFailed"))}w(!1)}},Q=async()=>{if(!L.current)return;const{content:e,mentions:n,images:o}=L.current;w(!0),h(null);try{await i(e,n,o),x(""),S([]),M([]),L.current=null}catch(p){h(String(p instanceof Error?p.message:p)||s("commentInput.sendFailed"))}w(!1)},P=a.useCallback(e=>{x(n=>{const o=n.lastIndexOf("@"),p=oe(e.name);return o>=0?n.slice(0,o)+p+" ":n+p+" "}),C.includes(e.id)||S(n=>[...n,e.id]),m(!1),k(""),I(0),F.current?.focus()},[C]),V=e=>{x(e),h(null);const n=e.lastIndexOf("@");if(n>=0&&(n===0||e[n-1]===" ")){const p=e.slice(n+1).toLowerCase();if($.some(v=>v.name.toLowerCase().includes(p))){k(p),m(!0),I(0);return}}m(!1)},Z=e=>{if(c&&D.length>0){const n=e.key==="ArrowUp"||e.ctrlKey&&e.key==="p",o=e.key==="ArrowDown"||e.ctrlKey&&e.key==="n",p=e.key==="Enter"||e.key==="Tab",R=e.key==="Escape";if(n){e.preventDefault(),I(v=>(v-1+D.length)%D.length);return}if(o){e.preventDefault(),I(v=>(v+1)%D.length);return}if(p){e.preventDefault();const v=D[B];v&&P(v);return}if(R){e.preventDefault(),m(!1);return}}e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),O())},J=a.useCallback(()=>{setTimeout(()=>m(!1),200)},[]);return t.jsxs("div",{className:"relative",onDragOver:G,onDragLeave:H,onDrop:q,children:[z&&t.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-brand-500/10 rounded-lg border-2 border-dashed border-brand-500",children:t.jsx("span",{className:"text-sm text-brand-500 font-medium",children:s("commentInput.dragDropHint")})}),c&&t.jsx(ae,{candidates:$,filter:j,anchorRef:F,onSelect:P,selectedIndex:B,onIndexChange:I}),t.jsxs("div",{className:"border border-border-default rounded-lg bg-surface-elevated",children:[f&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 pt-2 pb-1 border-b border-border-default/50",children:[t.jsxs("div",{className:"flex-1 min-w-0 pl-2 border-l-2 border-brand-500/50",children:[t.jsx("span",{className:"text-[10px] font-medium text-brand-500",children:f.authorName}),t.jsx("p",{className:"text-[10px] text-fg-tertiary truncate",children:f.content})]}),t.jsx("button",{onClick:y,className:"text-fg-tertiary hover:text-fg-secondary shrink-0 p-0.5",children:t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),C.length>0&&t.jsx("div",{className:"flex gap-1 px-2.5 pt-2 flex-wrap",children:C.map(e=>{const n=$.find(o=>o.id===e);return t.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded-full ${n?.type==="human"?"bg-green-500/15 text-green-500":"bg-brand-500/15 text-brand-500"}`,children:["@",n?.name??e,t.jsx("button",{onClick:()=>S(o=>o.filter(p=>p!==e)),className:"hover:text-red-400",children:"×"})]},e)})}),t.jsx("textarea",{ref:F,value:r,onChange:e=>V(e.target.value),onKeyDown:Z,onBlur:J,onPaste:Y,placeholder:g??s("commentInput.placeholder"),rows:2,className:"w-full px-2.5 py-2 text-xs bg-transparent text-fg-primary placeholder-fg-tertiary outline-none resize-none"}),N.length>0&&t.jsx("div",{className:"flex items-center gap-1.5 px-2.5 pb-1.5 overflow-x-auto",children:N.map(e=>t.jsxs("div",{className:"relative group/img shrink-0",children:[t.jsx("img",{src:e.dataUrl,alt:e.name,className:"w-12 h-12 rounded-lg object-cover border border-border-default"}),t.jsx("button",{onClick:()=>X(e.id),className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-surface-secondary border border-gray-600 rounded-full flex items-center justify-center text-fg-secondary hover:text-red-500 hover:border-red-500 text-[10px] opacity-0 group-hover/img:opacity-100 transition-opacity",title:s("commentInput.removeImage"),children:"×"})]},e.id))}),d&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 pb-1.5",children:[t.jsx("span",{className:"text-[11px] text-red-400 flex-1 truncate",children:d}),t.jsxs("button",{onClick:Q,disabled:b,className:"text-[11px] text-amber-500 hover:text-amber-400 font-medium transition-colors flex items-center gap-1",children:[t.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("polyline",{points:"23 4 23 10 17 10"}),t.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),s("commentInput.retry")]})]}),t.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2",children:[t.jsx("button",{type:"button",onClick:()=>U.current?.click(),disabled:b||N.length>=W,className:"p-1 text-fg-tertiary hover:text-brand-500 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:s("commentInput.attachImage"),children:t.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),t.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),t.jsx("polyline",{points:"21 15 16 10 5 21"})]})}),t.jsx("input",{ref:U,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:e=>{e.target.files&&E(e.target.files),e.target.value=""}}),t.jsx("button",{onClick:O,disabled:!r.trim()&&N.length===0||b,className:"px-3 py-1 text-[11px] font-medium bg-brand-500 text-white rounded-md hover:bg-brand-600 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:s(b?"commentInput.sending":"commentInput.submit")})]})]}),t.jsx("p",{className:"mt-1 text-center text-[10px] text-fg-tertiary/80 select-none",children:s("aiDisclaimer")})]})}export{de as C,ie as p,ce as r};
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-F0uqyKAR.js","assets/index-BozwNihZ.css"])))=>i.map(i=>d[i]);
2
- import{j as i,r as s,_ as f}from"./index-F0uqyKAR.js";const b=s.lazy(()=>f(()=>import("./index-F0uqyKAR.js").then(e=>e.az),__vite__mapDeps([0,1])).then(e=>({default:e.MarkdownMessage})));function x(e){switch(e.split(".").pop()?.toLowerCase()){case"md":case"markdown":return"markdown";case"html":case"htm":return"html";case"json":return"json";case"csv":case"tsv":return"csv";default:return}}function w(e){const t=e.trimStart();if(/^<!doctype\s+html/i.test(t)||/^<html[\s>]/i.test(t))return"html";if(t.startsWith("{")||t.startsWith("["))try{return JSON.parse(e),"json"}catch{}}function E(e){if(e.format)return e.format;if(e.reference){const t=x(e.reference);if(t)return t}if(e.content){const t=w(e.content);if(t)return t}return"markdown"}function v({content:e,className:t,onSelection:r}){const c=s.useRef(null),[l,g]=s.useState(null);s.useEffect(()=>{const o=d=>{d.data?.type==="__htmlpreview_height"&&typeof d.data.height=="number"&&g(d.data.height),d.data?.type==="__htmlpreview_selection"&&r&&r(d.data)};return window.addEventListener("message",o),()=>window.removeEventListener("message",o)},[r]);const h=`<script>
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BVZKeNvh.js","assets/index-BDWvYwl1.css"])))=>i.map(i=>d[i]);
2
+ import{j as i,r as s,_ as f}from"./index-BVZKeNvh.js";const b=s.lazy(()=>f(()=>import("./index-BVZKeNvh.js").then(e=>e.az),__vite__mapDeps([0,1])).then(e=>({default:e.MarkdownMessage})));function x(e){switch(e.split(".").pop()?.toLowerCase()){case"md":case"markdown":return"markdown";case"html":case"htm":return"html";case"json":return"json";case"csv":case"tsv":return"csv";default:return}}function w(e){const t=e.trimStart();if(/^<!doctype\s+html/i.test(t)||/^<html[\s>]/i.test(t))return"html";if(t.startsWith("{")||t.startsWith("["))try{return JSON.parse(e),"json"}catch{}}function E(e){if(e.format)return e.format;if(e.reference){const t=x(e.reference);if(t)return t}if(e.content){const t=w(e.content);if(t)return t}return"markdown"}function v({content:e,className:t,onSelection:r}){const c=s.useRef(null),[l,g]=s.useState(null);s.useEffect(()=>{const o=d=>{d.data?.type==="__htmlpreview_height"&&typeof d.data.height=="number"&&g(d.data.height),d.data?.type==="__htmlpreview_selection"&&r&&r(d.data)};return window.addEventListener("message",o),()=>window.removeEventListener("message",o)},[r]);const h=`<script>
3
3
  (function(){
4
4
  function getXPath(el){
5
5
  if(!el||el.nodeType!==1)return'';
@@ -1,6 +1,6 @@
1
- import{u as st,j as e,r as s,e as rs,A as xt,w as ft,s as as,g as Ot,f as L,k as os,l as ls,m as zt,o as is,p as cs,q as ds,t as tt,v as us,R as xs,x as fs,y as ms,z as ps,a as hs,B as gs,C as bs,b as ys,D as vs,P as Te,M as js,n as Ge,E as ws}from"./index-F0uqyKAR.js";import{resolveFormat as ks,ContentRenderer as Ns}from"./ContentRenderer-D6n8VYjL.js";function Ne(c){return Array.isArray(c)?c.map(h=>String(h).trim()).filter(Boolean):typeof c=="string"&&c?c.split(",").map(h=>h.trim()).filter(Boolean):[]}function Ss(c){return c.files&&typeof c.files=="object"&&!Array.isArray(c.files)?c.files:null}function Ue({label:c,value:h}){return h?e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:c}),e.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:h})]}):null}function Ye({label:c,value:h,color:f}){if(!h)return null;const r={purple:"bg-brand-500/15 text-brand-500",cyan:"bg-blue-500/15 text-blue-600",indigo:"bg-brand-500/15 text-brand-500",gray:"bg-gray-500/15 text-fg-secondary",emerald:"bg-green-500/15 text-green-600"};return e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:c}),e.jsx("div",{className:`mt-0.5 px-2 py-0.5 rounded-full text-[10px] font-medium ${r[f]??r.gray} capitalize inline-block`,children:h})]})}function Nt({files:c}){const{t:h}=st(["builder","common"]),[f,r]=s.useState(Object.keys(c)[0]??""),v=Object.keys(c);return v.length===0?null:e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:h("builder:artifact.files",{count:v.length})}),e.jsxs("div",{className:"mt-1 bg-surface-elevated/50 rounded-lg border border-border-default/30 overflow-hidden",children:[e.jsx("div",{className:"flex gap-0.5 px-1.5 py-1 border-b border-border-default/30 overflow-x-auto",children:v.map(_=>e.jsx("button",{onClick:()=>r(_),className:`px-2 py-0.5 text-[10px] rounded whitespace-nowrap transition-colors ${f===_?"bg-brand-600/30 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:_},_))}),f&&c[f]!=null&&e.jsx("pre",{className:"p-2 text-[10px] text-fg-secondary max-h-[120px] overflow-auto whitespace-pre-wrap font-mono",children:c[f]})]})]})}function Cs({artifact:c,mode:h}){const{t:f}=st(["builder","common"]),r=Ss(c),v=c.agent,_=c.team,K=c.dependencies,z=c.displayName??c.name;if(h==="agent"){const U=v?.roleName,F=v?.agentRole,M=v?.llmProvider,q=v?.llmModel,E=Ne(K?.env),P=Ne(K?.skills);return e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx(Ue,{label:f("builder:artifact.name"),value:z}),e.jsx(Ue,{label:f("builder:artifact.description"),value:c.description}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[U&&e.jsx(Ye,{label:f("builder:artifact.baseTemplate"),value:U,color:"indigo"}),e.jsx(Ye,{label:f("builder:artifact.agentRole"),value:F,color:F==="manager"?"purple":"cyan"})]}),Ne(c.tags).length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:Ne(c.tags).map(k=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:k},k))}),(M||q)&&e.jsxs("div",{className:"flex gap-2",children:[M&&e.jsx(Ye,{label:f("builder:artifact.llmProvider"),value:M,color:"gray"}),q&&e.jsx(Ye,{label:f("builder:artifact.llmModel"),value:q,color:"gray"})]}),E.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:f("builder:artifact.requiredEnv")}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:E.map(k=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-amber-500/10 text-amber-600 rounded font-mono",children:k},k))})]}),P.length>0&&e.jsx(Ue,{label:f("builder:artifact.skills"),value:P.join(", ")}),r&&e.jsx(Nt,{files:r})]})}if(h==="team"){const F=_?.members??[];return e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx(Ue,{label:f("builder:artifact.name"),value:z}),e.jsx(Ue,{label:f("builder:artifact.description"),value:c.description}),e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsx(Ye,{label:f("builder:artifact.category"),value:c.category,color:"indigo"})}),Ne(c.tags).length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:Ne(c.tags).map(M=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:M},M))}),r&&e.jsx(Nt,{files:r}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:f("builder:artifact.members",{count:F.length})}),e.jsx("div",{className:"mt-1.5 space-y-1.5",children:F.map((M,q)=>e.jsxs("div",{className:"bg-surface-elevated/30 rounded-lg px-2 py-1.5 border border-border-default/20",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-5 h-5 rounded flex items-center justify-center text-[10px] font-bold ${M.role==="manager"?"bg-brand-500/20 text-brand-500":"bg-blue-500/20 text-blue-600"}`,children:M.role==="manager"?"★":q+1}),e.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:M.name}),typeof M.roleName=="string"&&M.roleName&&e.jsx("span",{className:"text-[10px] text-brand-500/70 font-mono",children:M.roleName}),e.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["x",String(M.count??1)]})]}),Ne(M.skills).length>0&&e.jsx("div",{className:"mt-1 ml-7 flex flex-wrap gap-1",children:Ne(M.skills).map(E=>e.jsx("span",{className:"px-1 py-0.5 text-[9px] bg-green-500/10 text-green-600 rounded font-mono",children:E},E))})]},q))})]})]})}return e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx(Ue,{label:f("builder:artifact.name"),value:z}),e.jsx(Ue,{label:f("builder:artifact.description"),value:c.description}),e.jsx("div",{className:"flex gap-2",children:e.jsx(Ye,{label:f("builder:artifact.category"),value:c.category,color:"indigo"})}),r&&e.jsx(Nt,{files:r}),Ne(c.tags).length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:Ne(c.tags).map(U=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:U},U))})]})}const Ut={agent:"🤖",project:"📁",requirement:"📋",task:"✅",deliverable:"📦",workflow:"⚙️"},Is=["project","requirement","task","deliverable","workflow","agent"];function Vt(c){return c.dataUrl.startsWith("data:image/")}function Ls(c,h){if(Vt({dataUrl:h}))return null;const f=c.split(".").pop()?.toLowerCase()??"";return{pdf:"📄",docx:"📝",doc:"📝",xlsx:"📊",xls:"📊",pptx:"📎",csv:"📊",json:"🔧",xml:"🔧",html:"🌐",epub:"📚"}[f]??"📁"}function Ms({value:c,onChange:h,onSend:f,disabled:r=!1,placeholder:v="",sending:_=!1,onStop:K,contextChips:z,mentionItems:U,pendingFiles:F,onAttach:M,onPaste:q,onDrop:E,onDragOver:P,onRemoveFile:k,replyTo:Z,onClearReply:ne,fileInputRef:ge,visionWarning:We,maxFiles:Fe=5,className:Se="",compact:oe=!1,onMentionChipsChange:fe}){const{t:be}=st(["team","common"]),G=s.useRef(null),le=s.useRef(null);s.useRef(null);const[ie,ce]=s.useState(!1),[ye,me]=s.useState(""),[Y,J]=s.useState(0),[ee,ve]=s.useState(null),[W,Ce]=s.useState([]),n=(U??[]).filter(o=>o.name.toLowerCase().includes(ye)),de=(()=>{if(n.length===0)return[];const o=new Map;for(const O of n){const A=O.type??"agent";o.has(A)||o.set(A,[]),o.get(A).push(O)}const D=[];for(const O of Is){const A=o.get(O);A?.length&&D.push({type:O,items:A})}return D})();s.useEffect(()=>{if(!ie||!G.current){ve(null);return}const o=G.current.getBoundingClientRect();ve({left:o.left+16,bottom:window.innerHeight-o.top+4})},[ie]);const Ee=s.useCallback(()=>{const o=le.current;o&&(o.style.height="auto",o.style.height=`${Math.min(o.scrollHeight,oe?80:120)}px`)},[oe]);s.useEffect(()=>{Ee()},[c,Ee]);const He=s.useCallback(o=>{if(h(o),!U?.length){ce(!1);return}const D=le.current?.selectionStart??o.length,O=o.slice(0,D),A=O.lastIndexOf("@");if(A>=0){const V=A===0?"":O[A-1];if(A===0||/[\s\n,,。!?!?;;::、()()\[\]【】]/.test(V)){const re=O.slice(A+1);if(!re.includes(" ")&&!re.includes(`
1
+ import{u as st,j as e,r as s,e as rs,A as xt,w as ft,s as as,g as Ot,f as L,k as os,l as ls,m as zt,o as is,p as cs,q as ds,t as tt,v as us,R as xs,x as fs,y as ms,z as ps,a as hs,B as gs,C as bs,b as ys,D as vs,P as Te,M as js,n as Ge,E as ws}from"./index-BVZKeNvh.js";import{resolveFormat as ks,ContentRenderer as Ns}from"./ContentRenderer-BbN7QT3E.js";function Ne(c){return Array.isArray(c)?c.map(h=>String(h).trim()).filter(Boolean):typeof c=="string"&&c?c.split(",").map(h=>h.trim()).filter(Boolean):[]}function Ss(c){return c.files&&typeof c.files=="object"&&!Array.isArray(c.files)?c.files:null}function Ue({label:c,value:h}){return h?e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:c}),e.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:h})]}):null}function Ye({label:c,value:h,color:f}){if(!h)return null;const r={purple:"bg-brand-500/15 text-brand-500",cyan:"bg-blue-500/15 text-blue-600",indigo:"bg-brand-500/15 text-brand-500",gray:"bg-gray-500/15 text-fg-secondary",emerald:"bg-green-500/15 text-green-600"};return e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:c}),e.jsx("div",{className:`mt-0.5 px-2 py-0.5 rounded-full text-[10px] font-medium ${r[f]??r.gray} capitalize inline-block`,children:h})]})}function Nt({files:c}){const{t:h}=st(["builder","common"]),[f,r]=s.useState(Object.keys(c)[0]??""),v=Object.keys(c);return v.length===0?null:e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:h("builder:artifact.files",{count:v.length})}),e.jsxs("div",{className:"mt-1 bg-surface-elevated/50 rounded-lg border border-border-default/30 overflow-hidden",children:[e.jsx("div",{className:"flex gap-0.5 px-1.5 py-1 border-b border-border-default/30 overflow-x-auto",children:v.map(_=>e.jsx("button",{onClick:()=>r(_),className:`px-2 py-0.5 text-[10px] rounded whitespace-nowrap transition-colors ${f===_?"bg-brand-600/30 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:_},_))}),f&&c[f]!=null&&e.jsx("pre",{className:"p-2 text-[10px] text-fg-secondary max-h-[120px] overflow-auto whitespace-pre-wrap font-mono",children:c[f]})]})]})}function Cs({artifact:c,mode:h}){const{t:f}=st(["builder","common"]),r=Ss(c),v=c.agent,_=c.team,K=c.dependencies,z=c.displayName??c.name;if(h==="agent"){const U=v?.roleName,F=v?.agentRole,M=v?.llmProvider,q=v?.llmModel,E=Ne(K?.env),P=Ne(K?.skills);return e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx(Ue,{label:f("builder:artifact.name"),value:z}),e.jsx(Ue,{label:f("builder:artifact.description"),value:c.description}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[U&&e.jsx(Ye,{label:f("builder:artifact.baseTemplate"),value:U,color:"indigo"}),e.jsx(Ye,{label:f("builder:artifact.agentRole"),value:F,color:F==="manager"?"purple":"cyan"})]}),Ne(c.tags).length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:Ne(c.tags).map(k=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:k},k))}),(M||q)&&e.jsxs("div",{className:"flex gap-2",children:[M&&e.jsx(Ye,{label:f("builder:artifact.llmProvider"),value:M,color:"gray"}),q&&e.jsx(Ye,{label:f("builder:artifact.llmModel"),value:q,color:"gray"})]}),E.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:f("builder:artifact.requiredEnv")}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:E.map(k=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-amber-500/10 text-amber-600 rounded font-mono",children:k},k))})]}),P.length>0&&e.jsx(Ue,{label:f("builder:artifact.skills"),value:P.join(", ")}),r&&e.jsx(Nt,{files:r})]})}if(h==="team"){const F=_?.members??[];return e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx(Ue,{label:f("builder:artifact.name"),value:z}),e.jsx(Ue,{label:f("builder:artifact.description"),value:c.description}),e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsx(Ye,{label:f("builder:artifact.category"),value:c.category,color:"indigo"})}),Ne(c.tags).length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:Ne(c.tags).map(M=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:M},M))}),r&&e.jsx(Nt,{files:r}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:f("builder:artifact.members",{count:F.length})}),e.jsx("div",{className:"mt-1.5 space-y-1.5",children:F.map((M,q)=>e.jsxs("div",{className:"bg-surface-elevated/30 rounded-lg px-2 py-1.5 border border-border-default/20",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-5 h-5 rounded flex items-center justify-center text-[10px] font-bold ${M.role==="manager"?"bg-brand-500/20 text-brand-500":"bg-blue-500/20 text-blue-600"}`,children:M.role==="manager"?"★":q+1}),e.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:M.name}),typeof M.roleName=="string"&&M.roleName&&e.jsx("span",{className:"text-[10px] text-brand-500/70 font-mono",children:M.roleName}),e.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["x",String(M.count??1)]})]}),Ne(M.skills).length>0&&e.jsx("div",{className:"mt-1 ml-7 flex flex-wrap gap-1",children:Ne(M.skills).map(E=>e.jsx("span",{className:"px-1 py-0.5 text-[9px] bg-green-500/10 text-green-600 rounded font-mono",children:E},E))})]},q))})]})]})}return e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx(Ue,{label:f("builder:artifact.name"),value:z}),e.jsx(Ue,{label:f("builder:artifact.description"),value:c.description}),e.jsx("div",{className:"flex gap-2",children:e.jsx(Ye,{label:f("builder:artifact.category"),value:c.category,color:"indigo"})}),r&&e.jsx(Nt,{files:r}),Ne(c.tags).length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:Ne(c.tags).map(U=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:U},U))})]})}const Ut={agent:"🤖",project:"📁",requirement:"📋",task:"✅",deliverable:"📦",workflow:"⚙️"},Is=["project","requirement","task","deliverable","workflow","agent"];function Vt(c){return c.dataUrl.startsWith("data:image/")}function Ls(c,h){if(Vt({dataUrl:h}))return null;const f=c.split(".").pop()?.toLowerCase()??"";return{pdf:"📄",docx:"📝",doc:"📝",xlsx:"📊",xls:"📊",pptx:"📎",csv:"📊",json:"🔧",xml:"🔧",html:"🌐",epub:"📚"}[f]??"📁"}function Ms({value:c,onChange:h,onSend:f,disabled:r=!1,placeholder:v="",sending:_=!1,onStop:K,contextChips:z,mentionItems:U,pendingFiles:F,onAttach:M,onPaste:q,onDrop:E,onDragOver:P,onRemoveFile:k,replyTo:Z,onClearReply:ne,fileInputRef:ge,visionWarning:We,maxFiles:Fe=5,className:Se="",compact:oe=!1,onMentionChipsChange:fe}){const{t:be}=st(["team","common"]),G=s.useRef(null),le=s.useRef(null);s.useRef(null);const[ie,ce]=s.useState(!1),[ye,me]=s.useState(""),[Y,J]=s.useState(0),[ee,ve]=s.useState(null),[W,Ce]=s.useState([]),n=(U??[]).filter(o=>o.name.toLowerCase().includes(ye)),de=(()=>{if(n.length===0)return[];const o=new Map;for(const O of n){const A=O.type??"agent";o.has(A)||o.set(A,[]),o.get(A).push(O)}const D=[];for(const O of Is){const A=o.get(O);A?.length&&D.push({type:O,items:A})}return D})();s.useEffect(()=>{if(!ie||!G.current){ve(null);return}const o=G.current.getBoundingClientRect();ve({left:o.left+16,bottom:window.innerHeight-o.top+4})},[ie]);const Ee=s.useCallback(()=>{const o=le.current;o&&(o.style.height="auto",o.style.height=`${Math.min(o.scrollHeight,oe?80:120)}px`)},[oe]);s.useEffect(()=>{Ee()},[c,Ee]);const He=s.useCallback(o=>{if(h(o),!U?.length){ce(!1);return}const D=le.current?.selectionStart??o.length,O=o.slice(0,D),A=O.lastIndexOf("@");if(A>=0){const V=A===0?"":O[A-1];if(A===0||/[\s\n,,。!?!?;;::、()()\[\]【】]/.test(V)){const re=O.slice(A+1);if(!re.includes(" ")&&!re.includes(`
2
2
  `)){ce(!0),me(re.toLowerCase()),J(0);return}}}ce(!1)},[h,U]),Ae=s.useCallback(o=>{const D=le.current?.selectionStart??c.length,A=c.slice(0,D).lastIndexOf("@"),V=c.slice(D),Q=c.slice(0,A)+V.replace(/^\s/,"");h(Q);const re={id:`mention_${Date.now()}_${o.id}`,entityId:o.id,name:o.name,entityType:o.type},Be=[...W,re];Ce(Be),fe?.(Be),ce(!1),J(0),requestAnimationFrame(()=>{const ue=A;le.current?.setSelectionRange(ue,ue),le.current?.focus()})},[c,h,W,fe]),Ie=s.useCallback(()=>{f(),Ce([]),fe?.([])},[f,fe]),X=s.useCallback(o=>{if(ie&&n.length>0){const D=o.key==="ArrowUp"||o.ctrlKey&&o.key==="p",O=o.key==="ArrowDown"||o.ctrlKey&&o.key==="n",A=o.key==="Enter"||o.key==="Tab",V=o.key==="Escape";if(D){o.preventDefault(),J(Q=>(Q-1+n.length)%n.length);return}if(O){o.preventDefault(),J(Q=>(Q+1)%n.length);return}if(A){o.preventDefault();const Q=n[Y];Q&&Ae(Q);return}if(V){o.preventDefault(),ce(!1);return}}o.key==="Enter"&&!o.shiftKey&&(o.preventDefault(),Ie())},[ie,n,Y,Ae,Ie]),je=F??[],Re=ie&&n.length>0&&ee&&rs.createPortal(e.jsx("div",{className:"fixed bg-surface-elevated border border-border-default rounded-lg shadow-xl overflow-hidden max-h-64 overflow-y-auto min-w-[220px]",style:{left:ee.left,bottom:ee.bottom,zIndex:9999},children:(()=>{let o=0;return de.map(D=>{const O=Ut[D.type],A=be(`page.mentionType.${D.type}`);return e.jsxs("div",{children:[e.jsxs("div",{className:"px-3 py-1 text-[10px] text-fg-tertiary font-medium uppercase tracking-wider border-b border-border-default bg-surface-secondary/50 flex items-center gap-1.5 sticky top-0",children:[e.jsx("span",{children:O}),e.jsx("span",{children:A})]}),D.items.map(V=>{const Q=o++;return e.jsxs("button",{ref:re=>{Q===Y&&re&&re.scrollIntoView({block:"nearest"})},onMouseDown:re=>{re.preventDefault(),Ae(V)},onMouseEnter:()=>J(Q),className:`w-full text-left px-4 py-2 text-sm flex items-center gap-2 transition-colors ${Q===Y?"bg-brand-500/15 text-brand-500":"text-fg-secondary hover:bg-surface-overlay"}`,children:[V.type==="agent"?e.jsx(xt,{name:V.name,avatarUrl:V.avatarUrl,size:20,bgClass:"bg-brand-500/20 text-brand-500"}):e.jsx("span",{className:"text-xs w-5 h-5 flex items-center justify-center shrink-0",children:O}),e.jsx("span",{className:"flex-1 min-w-0 truncate",children:V.name}),V.role&&e.jsx("span",{className:"text-[10px] text-fg-tertiary ml-auto shrink-0",children:V.role})]},V.id)})]},D.type)})})()}),document.body);return e.jsxs("div",{ref:G,className:`relative bg-surface-primary border border-border-default shadow-lg shadow-black/10 rounded-2xl p-3 ${Se}`,onDrop:E,onDragOver:P,children:[Re,(z&&z.length>0||W.length>0)&&e.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-2",children:[W.map(o=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-brand-500/10 border border-brand-500/30 text-xs text-brand-400 max-w-[200px]",children:[e.jsx("span",{className:"shrink-0 text-[10px]",children:Ut[o.entityType]}),e.jsx("span",{className:"truncate font-medium",children:o.name}),e.jsx("button",{onClick:()=>{const D=W.filter(O=>O.id!==o.id);Ce(D),fe?.(D)},className:"shrink-0 text-brand-400/60 hover:text-red-400 transition-colors",children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},o.id)),z?.map(o=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md bg-surface-elevated border border-border-default text-xs text-fg-secondary max-w-[200px]",children:[e.jsx("span",{className:"truncate",children:o.label}),o.onRemove&&e.jsx("button",{onClick:o.onRemove,className:"shrink-0 text-fg-tertiary hover:text-red-500 transition-colors",children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},o.id))]}),je.length>0&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 overflow-x-auto pb-1",children:[je.map(o=>e.jsxs("div",{className:"relative group/img shrink-0",children:[Vt(o)?e.jsx("img",{src:o.dataUrl,alt:o.name,className:"w-16 h-16 rounded-lg object-cover border border-border-default"}):e.jsxs("div",{className:"w-16 h-16 rounded-lg border border-border-default bg-surface-elevated flex flex-col items-center justify-center gap-0.5",title:o.name,children:[e.jsx("span",{className:"text-xl leading-none",children:Ls(o.name,o.dataUrl)}),e.jsx("span",{className:"text-[9px] text-fg-tertiary truncate max-w-[56px] px-0.5",children:o.name.split(".").pop()?.toUpperCase()})]}),k&&e.jsx("button",{onClick:()=>k(o.id),className:"absolute -top-1.5 -right-1.5 w-5 h-5 bg-surface-secondary border border-gray-600 rounded-full flex items-center justify-center text-fg-secondary hover:text-red-500 hover:border-red-500 text-xs opacity-0 group-hover/img:opacity-100 transition-opacity",children:"×"})]},o.id)),je.length<Fe&&M&&e.jsx("button",{onClick:M,className:"w-16 h-16 rounded-lg border border-dashed border-gray-600 flex items-center justify-center text-fg-tertiary hover:text-fg-secondary hover:border-gray-400 transition-colors shrink-0",title:be("page.addMoreFiles"),children:e.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M12 5v14M5 12h14"})})})]}),We&&e.jsxs("div",{className:"text-[10px] text-amber-500/80 mb-1.5 flex items-center gap-1",children:[e.jsx("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M12 9v4m0 4h.01M12 2L2 22h20L12 2z",strokeLinecap:"round",strokeLinejoin:"round"})}),be("page.visionWarning")]}),Z&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-3 py-1.5 bg-surface-elevated rounded-lg border border-border-default/50",children:[e.jsxs("div",{className:"flex-1 min-w-0 pl-2 border-l-2 border-brand-500/50",children:[e.jsx("span",{className:"text-[11px] font-medium text-brand-500",children:Z.sender}),e.jsx("p",{className:"text-[11px] text-fg-tertiary truncate",children:Z.text})]}),ne&&e.jsx("button",{onClick:ne,className:"text-fg-tertiary hover:text-fg-secondary shrink-0 p-0.5",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),e.jsxs("div",{className:"flex gap-2 items-end",children:[M&&e.jsx("button",{onClick:M,disabled:r,className:"px-2.5 py-2.5 text-fg-tertiary hover:text-fg-secondary disabled:opacity-40 transition-colors rounded-xl hover:bg-surface-elevated",title:be("page.attachFilesTitle"),children:e.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsx("textarea",{ref:le,value:c,onChange:o=>He(o.target.value),onKeyDown:X,onPaste:q,placeholder:v,disabled:r,rows:oe?1:2,className:"flex-1 px-4 py-3 bg-transparent rounded-xl text-sm outline-none disabled:opacity-40 transition-colors resize-none overflow-hidden leading-relaxed placeholder:text-fg-secondary",style:{minHeight:oe?"36px":"52px",maxHeight:oe?"80px":"120px"}}),_&&K&&e.jsx("button",{onClick:K,className:"px-3 py-2.5 bg-red-600 hover:bg-red-500 text-white text-sm rounded-xl transition-colors flex items-center gap-1.5",title:be("page.stopAgent"),children:e.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})})}),e.jsx("button",{onClick:Ie,disabled:r||!c.trim()&&je.length===0&&W.length===0,className:"px-5 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-xl transition-colors",children:be("common:send")})]})]})}function Ts({agentId:c,sessionId:h,agents:f,authUser:r,onClose:v,contextChips:_,extraMentionItems:K,width:z,className:U=""}){const{t:F}=st(["team","common"]),M=f.find(d=>d.id===c),q=M?.name??F("page.fallbackAgent"),E=r?.name??F("page.fallbackYou"),[P,k]=s.useState([]),[Z,ne]=s.useState(h??null),[ge,We]=s.useState(!0),[Fe,Se]=s.useState(!1),[oe,fe]=s.useState(""),[be,G]=s.useState([]),[le,ie]=s.useState([]),ce=s.useRef(null),ye=s.useRef(null),me=s.useRef(null),Y=s.useRef(!0),J=s.useRef(Z);J.current=Z;const ee=s.useMemo(()=>({today:F("page.dateToday"),yesterday:F("page.dateYesterday")}),[F]),ve=s.useMemo(()=>{const d=F("page.chatGreetings",{returnObjects:!0});return Array.isArray(d)&&d.length>0?d[Math.floor(Math.random()*d.length)]:""},[F]),W=s.useCallback((d="auto")=>{ye.current?.scrollIntoView({behavior:d})},[]);s.useEffect(()=>{let d=!1;return We(!0),k([]),(async()=>{try{let C=h??null;if(!C){const{sessions:H}=await L.sessions.listByAgent(c,10);C=H.find(R=>R.isMain)?.id??H[0]?.id??null}if(d)return;if(ne(C),C){const H=await L.sessions.getMessages(C,50);if(d)return;const T=H.messages.map(fs).filter(R=>R.sender!=="agent"||R.text||R.segments&&R.segments.length>0);k(T)}}catch{}d||We(!1)})(),()=>{d=!0}},[c,h]);const Ce=s.useRef(!0);s.useEffect(()=>{Ce.current&&!ge&&P.length>0&&requestAnimationFrame(()=>{requestAnimationFrame(()=>W())}),Ce.current=ge},[ge,P.length,W]),s.useEffect(()=>{!ge&&Y.current&&requestAnimationFrame(()=>W())},[P,W,ge]),s.useEffect(()=>ft.on("chat:proactive_message",N=>{const C=N.payload,H=C.agentId??"";if(H!==c)return;const T=C.targetUserId;if(T&&T!==r?.id)return;const R=C.message??"",pe=C.sessionId??"",te=C.messageId??"";if(!R||R==="[cancelled]"||R==="[Stream cancelled]"||pe&&J.current&&pe!==J.current)return;const S=C.metadata??{},he=S.role==="user",{cleaned:se,priority:Le}=as(R),l=!he&&(!!S.notifyUser||se!==R),g=typeof S.userText=="string"?S.userText:"",i=typeof S.userMessageId=="string"?S.userMessageId:"",x=typeof S.createdAt=="string"&&S.createdAt||(typeof N.timestamp=="string"?N.timestamp:void 0)||new Date().toISOString(),p=(()=>{try{return new Date(x).toLocaleTimeString()}catch{return new Date().toLocaleTimeString()}})(),b={id:te||`proactive_${Date.now()}`,sender:he?"user":"agent",text:se,time:p,rawCreatedAt:x,...he?{}:{agentName:C.agentName??q,agentId:H,...l?{isNotification:!0,notifyPriority:S.priority??Le}:{}}};k(j=>{if(j.some(y=>y.id===b.id))return j;let I=j;return!he&&g&&(I.some(w=>i&&w.id===i||w.sender==="user"&&w.text===g)||(I=Ot(I,{id:i||`feishu_user_${b.id}`,sender:"user",text:g,time:p,rawCreatedAt:x}))),Ot(I,b)})}),[c,q,r?.id]);const[n,de]=s.useState(!1),Ee=s.useCallback(()=>{const d=ce.current;if(!d)return;const N=d.scrollHeight-d.scrollTop-d.clientHeight<60;Y.current=N,de(!N)},[]),He=s.useCallback(()=>{me.current?.abort(),me.current=null,Se(!1),G([]),L.agents.cancelProcessing(c).catch(()=>{})},[c]),[Ae,Ie]=s.useState(null),[X,je]=s.useState(null),[Re,o]=s.useState(!1),D=s.useCallback(async(d,N)=>{let C=d?.trim()??"";if(!C){const l=[];if(le.length>0&&l.push(le.map(g=>`@[${g.name}](${g.entityType}:${g.entityId})`).join(" ")),_?.length)for(const g of _)l.push(`[${g.type}: ${g.label}]
3
3
  ${g.content}`);oe.trim()&&l.push(oe.trim()),C=l.join(`
4
4
 
5
5
  `)}if(!C)return;d||(fe(""),ie([])),Y.current=!0,Se(!0),G([]);const H=N!==void 0?N:Z,T=`a_${Date.now()}`,R=new Date().toISOString(),pe={id:`u_${Date.now()}`,sender:"user",text:C,time:new Date().toLocaleTimeString(),rawCreatedAt:R};k(l=>[...l,pe,{id:T,sender:"agent",text:"",time:new Date().toLocaleTimeString(),rawCreatedAt:R,segments:[]}]);let te=!1;const S=l=>{k(g=>{const i=[...g],x=i.findIndex(ae=>ae.id===T);if(x<0)return g;const p=i[x].segments??[],b=p[p.length-1],j=b?.type==="text"?b.thinking??"":"";let I="",y="",w=l;for(;w.length>0;)if(te){const ae=w.indexOf("</think>");ae>=0?(I+=w.slice(0,ae),w=w.slice(ae+8),te=!1):(I+=w,w="")}else{const ae=w.indexOf("<think>");ae>=0?(y+=w.slice(0,ae),w=w.slice(ae+7),te=!0):(y+=w,w="")}const xe=j+I||void 0,mt=b?.type==="text"?[...p.slice(0,-1),{type:"text",content:b.content+y,thinking:xe,createdAt:b.createdAt}]:[...p,{type:"text",content:y,thinking:xe,createdAt:new Date().toISOString()}];return i[x]={...i[x],text:i[x].text+y,segments:mt},i})},he=l=>{if(l.type==="session_start"&&l.sessionId){ne(l.sessionId);return}k(g=>{const i=[...g],x=i.findIndex(b=>b.id===T);if(x<0)return g;const p=[...i[x].committedSegments??[]];return l.type==="thinking_commit"?p.push({type:"text",content:"",thinking:l.content,createdAt:l.createdAt}):p.push({type:"text",content:l.content,createdAt:l.createdAt}),i[x]={...i[x],committedSegments:p},i})},se=l=>{l.phase!=="heartbeat"&&(l.phase==="start"?(G(g=>[...g,{...l,phase:"start",ts:Date.now()}]),k(g=>{const i=[...g],x=i.findIndex(w=>w.id===T);if(x<0)return g;const p=[...i[x].segments??[]],b=`${l.tool}_${Date.now()}`,j=new Date().toISOString();let I=!1;if(l.arguments)for(let w=p.length-1;w>=0;w--){const xe=p[w];if(xe.type==="tool"&&xe.tool===l.tool&&xe.status==="running"){p[w]={...xe,args:l.arguments},I=!0;break}}I||p.push({type:"tool",key:b,tool:l.tool,status:"running",args:l.arguments,createdAt:j});const y=[...i[x].committedSegments??[]];return l.arguments!==void 0&&y.push({type:"tool",key:b,tool:l.tool,status:"running",args:l.arguments,createdAt:j}),i[x]={...i[x],segments:p,committedSegments:y},i})):l.phase==="output"?k(g=>{const i=[...g],x=i.findIndex(b=>b.id===T);if(x<0)return g;const p=[...i[x].segments??[]];for(let b=p.length-1;b>=0;b--){const j=p[b];if(j.type==="tool"&&j.tool===l.tool&&j.status==="running"){p[b]={...j,liveOutput:ms(j.liveOutput,l.output??"")};break}}return i[x]={...i[x],segments:p},i}):l.phase==="subagent_progress"&&l.subagentEvent?k(g=>{const i=[...g],x=i.findIndex(b=>b.id===T);if(x<0)return g;const p=b=>{const j=[...b];for(let I=j.length-1;I>=0;I--){const y=j[I];if(y.type==="tool"&&(y.tool==="spawn_subagent"||y.tool==="spawn_subagents")&&y.status==="running"){j[I]={...y,subagentLogs:ps(y.subagentLogs,l.subagentEvent)};break}}return j};return i[x]={...i[x],segments:p(i[x].segments??[]),committedSegments:p(i[x].committedSegments??[])},i}):l.phase==="end"&&(G(g=>[...g,{...l,phase:"end",ts:Date.now()}]),k(g=>{const i=[...g],x=i.findIndex(y=>y.id===T);if(x<0)return g;const p=new Date().toISOString(),b=[...i[x].segments??[]];let j;for(let y=b.length-1;y>=0;y--){const w=b[y];if(w.type==="tool"&&w.tool===l.tool&&w.status==="running"){j=w.subagentLogs,b[y]={...w,status:l.success===!1?"error":"done",args:l.arguments,result:l.result,error:l.error,durationMs:l.durationMs,liveOutput:void 0,createdAt:p};break}}const I=[...i[x].committedSegments??[]];for(let y=I.length-1;y>=0;y--){const w=I[y];if(w.type==="tool"&&w.tool===l.tool&&w.status==="running"){I[y]={...w,status:l.success===!1?"error":"done",args:l.arguments,result:l.result,error:l.error,durationMs:l.durationMs,liveOutput:void 0,createdAt:p,subagentLogs:j??w.subagentLogs};break}}return i[x]={...i[x],segments:b,committedSegments:I},i})))},Le=new AbortController;me.current=Le;try{const l=await L.agents.messageStream(c,C,S,se,Le.signal,void 0,H,void 0,void 0,he);l.merged&&k(g=>g.filter(i=>i.id!==T)),!l.merged&&l.segments?.length&&k(g=>{const i=[...g],x=i.findIndex(j=>j.id===T);if(x<0)return g;const p=os(l.segments,i[x].segments);let b=l.content||i[x].text;return b||(b=p.filter(j=>j.type==="text").map(j=>j.content).join("")),i[x]={...i[x],text:b,segments:p,committedSegments:p},i}),!l.merged&&!l.segments?.length&&k(g=>{const i=[...g],x=i.findIndex(y=>y.id===T);if(x<0)return g;const p=i[x],b=p.committedSegments??[],I=b.filter(y=>y.type==="text"&&!!y.content).map(y=>y.content).join("")||l.content||p.text;return(b.length>0||I)&&(i[x]={...p,text:I,segments:b.length>0?b:p.segments}),i}),l.sessionId&&ne(l.sessionId)}catch(l){const g=l?.sessionId;g&&ne(g);const i=ls(l,F);k(i?x=>{const p=[...x],b=p.findIndex(j=>j.id===T);if(b>=0){const j=p[b].segments??[];p[b]={...p[b],text:i,isError:!0,segments:[...j,{type:"text",content:i}]}}return p}:x=>{const p=[...x],b=p.findIndex(j=>j.id===T);if(b>=0){const j=p[b];if(!(j.text||j.segments&&j.segments.length>0&&j.segments.some(y=>y.type==="text"&&(y.content||y.thinking)||y.type==="tool")))return x.filter(y=>y.id!==T);p[b]={...j,isStopped:!0}}return p})}k(l=>{const g=[...l],i=g.findIndex(x=>x.id===T);if(i>=0){const x=(g[i].segments??[]).map(p=>p.type==="tool"&&p.status==="running"?{...p,status:"stopped"}:p);g[i]={...g[i],segments:x}}return g}),Se(!1),G([]),me.current=null},[oe,c,Z,F,le,_]),O=s.useCallback(d=>{navigator.clipboard.writeText(d.text||"").then(()=>{Ie(d.id),setTimeout(()=>Ie(N=>N===d.id?null:N),1500)})},[]),A=async d=>{if(!(!X||!Z)){o(!0);try{const N=await L.agents.evolveFromMessage(c,{parentSessionId:Z,sourceMessageId:X.id.startsWith("a_")||X.id.startsWith("u_")?void 0:X.id,sourceText:(X.text||"").slice(0,500)||void 0,userNote:d.trim()||void 0});je(null),ne(N.sessionId),k([]),await D(N.seedPrompt,N.sessionId)}catch(N){console.error("evolve-from-message failed",N)}finally{o(!1)}}},V=P[P.length-1],Q=Fe&&V?.sender==="agent",re=s.useMemo(()=>{for(let d=P.length-1;d>=0;d--)if(P[d].sender==="agent")return P[d].id;return null},[P]),[Be,ue]=s.useState([]);s.useEffect(()=>{let d=!1;return(async()=>{const C=[];try{const[H,T,R,pe,te]=await Promise.all([L.projects.list().catch(()=>({projects:[]})),L.requirements.list().catch(()=>({requirements:[]})),L.tasks.list({pageSize:100}).catch(()=>({tasks:[]})),L.deliverables.search({limit:100}).catch(()=>({results:[]})),L.teams.list().catch(()=>({teams:[],ungrouped:[]}))]);for(const S of H.projects)C.push({id:S.id,name:S.name,type:"project",role:S.status});for(const S of T.requirements)C.push({id:S.id,name:S.title,type:"requirement",role:S.priority});for(const S of R.tasks)C.push({id:S.id,name:S.title,type:"task",role:S.status});for(const S of pe.results)C.push({id:S.id,name:S.title,type:"deliverable",role:S.type});for(const S of te.teams)try{const he=await L.workflows.list(S.id);for(const se of he.workflows)C.push({id:se.name,name:se.displayName||se.name,type:"workflow",role:`v${se.version}`})}catch{}}catch{}d||ue(C)})(),()=>{d=!0}},[]);const Ve=s.useMemo(()=>{const d=f.map(N=>({id:N.id,name:N.name,role:N.role,avatarUrl:N.avatarUrl,type:"agent"}));return[...Be,...d,...K??[]]},[f,Be,K]);return e.jsxs("div",{className:`flex flex-col bg-surface-primary border-l border-border-default ${U}`,style:z?{width:z}:{width:400},children:[e.jsxs("div",{className:"h-12 px-4 flex items-center gap-2 shrink-0 border-b border-border-default",children:[e.jsx(xt,{name:q,avatarUrl:M?.avatarUrl,size:24,bgClass:"bg-brand-500/15 text-brand-600",className:"rounded-md"}),e.jsx("span",{className:"text-sm font-medium text-fg-primary truncate flex-1",children:q}),v&&e.jsx("button",{onClick:v,className:"text-fg-tertiary hover:text-fg-secondary transition-colors p-1",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),e.jsxs("div",{ref:ce,className:"flex-1 overflow-y-auto px-3 py-3 space-y-3",onScroll:Ee,children:[ge?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("svg",{className:"animate-spin h-5 w-5 text-fg-tertiary",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}):P.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3",children:[e.jsx(xt,{name:q,avatarUrl:M?.avatarUrl,size:40,bgClass:"bg-brand-500/20 text-brand-500"}),e.jsx("p",{className:"text-fg-secondary text-sm font-medium",children:ve})]}):P.map((d,N)=>{const C=N>0?P[N-1]:null,H=zt(d.rawCreatedAt),T=C?zt(C.rawCreatedAt):"",R=!!(H&&T&&H!==T),pe=N===P.length-1,te=Q&&pe,S=te;return e.jsxs("div",{children:[R&&e.jsxs("div",{className:"flex items-center gap-3 py-1 my-1",children:[e.jsx("div",{className:"flex-1 h-px bg-border-default"}),e.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium uppercase tracking-wider shrink-0",children:is(d.rawCreatedAt,ee)}),e.jsx("div",{className:"flex-1 h-px bg-border-default"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"shrink-0 mt-0.5",children:e.jsx(xt,{name:d.sender==="user"?E:q,avatarUrl:d.sender==="user"?r?.avatarUrl:M?.avatarUrl,size:24,bgClass:d.sender==="user"?"bg-brand-600":"bg-brand-500/15 text-brand-600",className:"rounded-md"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-baseline gap-1.5",children:[e.jsx("span",{className:"text-xs font-medium text-fg-primary",children:d.sender==="user"?E:q}),e.jsx("span",{className:"text-[10px] text-fg-tertiary",children:cs(d.time,d.rawCreatedAt,ee)})]}),e.jsx("div",{className:`mt-0.5 ${d.sender==="agent"?"py-0.5":"bg-surface-secondary rounded-xl px-3 py-2 w-fit max-w-full"} ${S&&d.sender==="agent"?"streaming-bubble":""}`,children:d.sender==="user"?e.jsx("div",{className:"text-sm text-fg-secondary whitespace-pre-wrap",children:d.text}):d.segments&&d.segments.length>0?e.jsx(ds,{msg:d,isStreaming:te,liveActivities:te?be:[]}):d.isError||d.text.startsWith("⚠")?e.jsx("div",{className:"text-[13px] text-fg-tertiary leading-relaxed whitespace-pre-wrap",children:d.text.replace(/^⚠\s*/,"")}):e.jsx(tt,{content:d.text,className:"text-sm text-fg-secondary"})}),!te&&e.jsx(us,{msg:d,onCopy:O,onRemember:je,showRemember:!0,isCopied:Ae===d.id,isLastAgentMsg:d.id===re})]})]})]},d.id)}),e.jsx("div",{ref:ye})]}),X&&e.jsx(xs,{busy:Re,onConfirm:d=>{A(d)},onCancel:()=>{Re||je(null)}}),n&&e.jsx("div",{className:"flex justify-center -mt-10 relative z-10 pointer-events-none",children:e.jsx("button",{onClick:()=>W("smooth"),className:"pointer-events-auto w-8 h-8 rounded-full bg-surface-elevated border border-border-default shadow-md flex items-center justify-center text-fg-tertiary hover:text-fg-secondary transition-colors",title:F("page.scrollToBottom"),children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})})}),e.jsx("div",{className:"px-3 py-2 shrink-0 border-t border-border-default",children:e.jsx(Ms,{value:oe,onChange:fe,onSend:()=>{D()},disabled:!c,placeholder:F("page.placeholder.direct"),sending:Fe,onStop:He,contextChips:_,mentionItems:Ve,onMentionChipsChange:ie,compact:!0,className:"shadow-none border-0"})})]})}const Qe={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},Es=["file","directory"];function ut(c){return/^https?:\/\//i.test(c)}function As(c,h){const f=Date.now(),r=new Date(c).getTime(),v=f-r,_=Math.floor(v/6e4);if(_<1)return h("time.justNow");if(_<60)return h("time.minutesAgo",{count:_});const K=Math.floor(_/60);if(K<24)return h("time.hoursAgo",{count:K});const z=Math.floor(K/24);if(z===1)return h("time.yesterday");if(z<30)return h("time.daysAgo",{count:z});const U=Math.floor(z/30);return U<12?h("time.monthsAgo",{count:U}):h("time.yearsAgo",{count:Math.floor(U/12)})}const Pe={agent:{icon:"✦",color:"bg-brand-500/10 text-brand-500"},team:{icon:"◈",color:"bg-blue-500/10 text-blue-600"},skill:{icon:"⬡",color:"bg-amber-500/10 text-amber-600"}};function Ds({authUser:c,previewMode:h,previewData:f}={}){const{t:r}=st(["deliverables","common"]),v=hs(),_=gs(Te.DELIVERABLES),K=bs({side:"left",defaultWidth:384,minWidth:280,maxWidth:600,storageKey:"markus_deliverables_list"}),[z,U]=s.useState(!1),F=s.useRef(z);F.current=z,s.useEffect(()=>{if(!v)return;const t=()=>{F.current&&U(!1)};return window.addEventListener("popstate",t),()=>window.removeEventListener("popstate",t)},[v]);const M=100,q=5e3,[E,P]=s.useState(f?.items??[]),[k,Z]=s.useState(f?.items?.length??0),[ne,ge]=s.useState(!1),[We,Fe]=s.useState(f?.projects??[]),[Se,oe]=s.useState(f?.agents??[]),[fe,be]=s.useState([]),[G,le]=s.useState(!f),[ie,ce]=s.useState(""),[ye,me]=s.useState(""),[Y,J]=s.useState(""),[ee,ve]=s.useState(""),[W,Ce]=s.useState("date"),[n,de]=s.useState(()=>f?.initialSelectedId&&f.items?f.items.find(t=>t.id===f.initialSelectedId)??f.items[0]??null:f?.items?.[0]??null),[Ee,He]=s.useState(null),[Ae,Ie]=s.useState(""),[X,je]=s.useState(!0),[Re,o]=s.useState(()=>{const t=new Date,a=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`;return new Set([a])}),[D,O]=s.useState(!1),[A,V]=s.useState(!1),Q=s.useMemo(()=>[{id:"date"},{id:"project"},{id:"team"},{id:"agent"}],[]),re=s.useCallback(t=>{Ce(t)},[]),Be=ys(Q,W,re),ue=s.useRef(null),[Ve,d]=s.useState(null),[N,C]=s.useState("markdown"),[H,T]=s.useState(null),[R,pe]=s.useState(null),[te,S]=s.useState(!1),[he,se]=s.useState(!1),[Le,l]=s.useState(!1),[g,i]=s.useState(null),[x,p]=s.useState(""),[b,j]=s.useState(new Set),[I,y]=s.useState(!1),[w,xe]=s.useState(!1),[mt,ae]=s.useState([]),[Xe,qe]=s.useState(null),[Ke,_e]=s.useState(!1),[Ze,pt]=s.useState(""),[De,Oe]=s.useState(!1),[ht,Ct]=s.useState(!1),[gt,ze]=s.useState(null),bt=s.useRef(null),It=s.useCallback(t=>{t&&(t.style.height="auto",t.style.height=t.scrollHeight+"px")},[]),Lt=s.useRef(void 0);s.useEffect(()=>{It(bt.current)},[Ze,Ke,It]);const we=(t,a)=>{He({type:t,text:a}),setTimeout(()=>He(null),3e3)},Mt=async t=>{await ws(t)?(l(!0),setTimeout(()=>l(!1),1500)):we("error",r("detail.copyFailed"))},nt=s.useMemo(()=>new Map(Se.map(t=>[t.id,t])),[Se]),yt=s.useMemo(()=>new Map(We.map(t=>[t.id,t])),[We]),Tt=s.useMemo(()=>new Map(fe.map(t=>[t.id,t])),[fe]),rt=s.useCallback(t=>{if(!t||t==="default")return null;const a=yt.get(t)?.name;return!a||a==="default"?null:a},[yt]);s.useEffect(()=>{h||(L.projects.list().then(t=>Fe(t.projects)).catch(()=>{}),L.agents.list().then(t=>oe(t.agents??[])).catch(()=>{}),L.teams.list().then(t=>be(t.teams??[])).catch(()=>{}),L.system.storage().then(t=>p(t.dataDir+"/shared")).catch(()=>{}),L.deliverables.checkHealth().then(t=>j(new Set(t.missingFiles))).catch(()=>{}))},[h]),s.useEffect(()=>(Lt.current=setTimeout(()=>me(ie),300),()=>clearTimeout(Lt.current)),[ie]);const at=s.useMemo(()=>({q:ye||void 0,type:Y||void 0,artifactType:ee||void 0}),[ye,Y,ee]),ot=W==="date"?M:q,Me=s.useCallback(async()=>{le(!0),ue.current?.scrollTo({top:0,behavior:"instant"});try{const{results:t,total:a}=await L.deliverables.search({...at,offset:0,limit:ot});P(t),Z(a),de(u=>u&&t.some(m=>m.id===u.id)?u:null)}catch{P([]),Z(0),de(null)}le(!1)},[at,ot]),lt=s.useCallback(async()=>{if(!(ne||E.length>=k)){ge(!0);try{const{results:t,total:a}=await L.deliverables.search({...at,offset:E.length,limit:ot});P(u=>[...u,...t]),Z(a)}catch{}ge(!1)}},[at,ot,E.length,k,ne]);s.useEffect(()=>{h||Me()},[Me,h]),s.useEffect(()=>{!h||!f||(P(f.items??[]),Z(f.items?.length??0),Fe(f.projects??[]),oe(f.agents??[]),f.initialSelectedId&&de(f.items?.find(t=>t.id===f.initialSelectedId)??f.items?.[0]??null))},[h,f]);const Et=s.useRef(n);Et.current=n,s.useEffect(()=>{if(h||!_)return;const t=ft.on("deliverable:created",()=>Me()),a=ft.on("deliverable:updated",m=>{Me();const B=m.payload?.deliverableId;B&&Et.current?.id===B&&L.deliverables.get(B).then($=>{$.deliverable&&(de($.deliverable),Rt($.deliverable))}).catch(()=>{})}),u=ft.on("deliverable:removed",()=>Me());return()=>{t(),a(),u()}},[Me,_,h]);const it=s.useRef(null),vt=s.useRef(E);vt.current=E;const Je=s.useCallback(t=>{const a=m=>{de(m),v&&(U(!0),history.pushState({mobileDetail:Te.DELIVERABLES},"",window.location.hash))},u=vt.current.find(m=>m.id===t);if(u){a(u);return}L.deliverables.get(t).then(m=>{m.deliverable&&a(m.deliverable)}).catch(()=>{})},[v]);s.useEffect(()=>{if(h)return;const t=window.location.hash.slice(1).split("/"),a=vs(t[0])===Te.DELIVERABLES?t[1]:void 0,u=localStorage.getItem("markus_nav_openDeliverable")||a;u&&(localStorage.removeItem("markus_nav_openDeliverable"),vt.current.length>0?Je(u):it.current=u);const m=B=>{const $=B.detail;$?.params?.openDeliverable&&(localStorage.removeItem("markus_nav_openDeliverable"),Je($.params.openDeliverable))};return window.addEventListener("markus:navigate",m),()=>window.removeEventListener("markus:navigate",m)},[Je,h]),s.useEffect(()=>{const t=it.current;!t||E.length===0||(it.current=null,Je(t))},[E,Je]);const At=s.useCallback(()=>{const t=ue.current;!t||G||ne||E.length>=k||t.scrollHeight<=t.clientHeight+100&&lt()},[G,ne,E.length,k,lt]);s.useEffect(()=>{const t=ue.current;if(!t)return;const a=()=>{t.scrollTop+t.clientHeight>=t.scrollHeight-100&&lt()};return t.addEventListener("scroll",a,{passive:!0}),()=>t.removeEventListener("scroll",a)},[lt]),s.useEffect(()=>{At()},[At,X,Re]);const $e=s.useMemo(()=>{const t=new Map;for(const u of E){let m,B;if(W==="project"){const $=rt(u.projectId);m=$?u.projectId??"_none":"_none",B=$??r("noProject")}else if(W==="team"){const ke=(u.agentId?nt.get(u.agentId):void 0)?.teamId??"_none";m=ke,B=ke!=="_none"?Tt.get(ke)?.name??ke:r("noTeam")}else if(W==="agent")m=u.agentId??"_none",B=u.agentId?nt.get(u.agentId)?.name??u.agentId:r("common:unknown");else{const $=new Date(u.updatedAt);m=`${$.getFullYear()}-${String($.getMonth()+1).padStart(2,"0")}-${String($.getDate()).padStart(2,"0")}`,B=m}t.has(m)||t.set(m,{label:B,items:[]}),t.get(m).items.push(u)}const a=[...t.entries()];return W==="date"?a.sort((u,m)=>m[0].localeCompare(u[0])):a.sort((u,m)=>u[1].label.localeCompare(m[1].label)),a},[E,W,yt,nt,Tt,r]);s.useEffect(()=>{if(W==="date"&&X){const t=new Date,a=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`;o(new Set([a]))}else o(new Set)},[W]);const qt=async t=>{Ie("remove");try{await L.deliverables.remove(t.id),we("success",r("removed")),de(null),Me()}catch(a){we("error",r("common:error",{message:String(a)}))}Ie("")},Kt=()=>{Ge.navigate(Te.BUILDER)},Rt=async t=>{if(t.reference&&!ut(t.reference)){if(t.type==="directory"){se(!0);return}S(!0);try{const a=await L.files.preview(t.reference);if(a.type==="image"&&a.mimeType)T({src:`data:${a.mimeType};base64,${a.content}`,name:a.name});else if(a.type==="audio"||a.type==="video"){const u=a.streamUrl||(a.path?L.files.streamUrl(a.path):L.files.streamUrl(t.reference));pe({kind:a.type,src:u,name:a.name})}else a.type==="binary"?se(!0):typeof a.content=="string"?(d(a.content),C(ks({format:t.format,reference:t.reference,content:a.content}))):se(!0)}catch{d(null),t.type==="file"&&se(!0)}S(!1)}};s.useEffect(()=>{h||(d(null),C("markdown"),T(null),pe(null),se(!1),n&&Rt(n))},[n?.id,h]);const Bt=s.useCallback(t=>X!==Re.has(t),[X,Re]),Dt=$e.length>0&&$e.every(([t])=>Bt(t)),Gt=s.useCallback(t=>{o(a=>{const u=new Set(a);return u.has(t)?u.delete(t):u.add(t),u})},[]),$t=s.useCallback(t=>{o(a=>{if(a.has(t)===X)return a;const u=new Set(a);return X?u.add(t):u.delete(t),u})},[X]),Yt=s.useCallback(()=>{je(t=>!t),o(new Set)},[]),ct=!!(Y||ee||ye),Pt=s.useCallback(()=>{J(""),ve(""),ce(""),me("")},[]),et=s.useMemo(()=>$e.flatMap(([,t])=>t.items),[$e]);s.useEffect(()=>{h||v||G||n||it.current||et.length!==0&&de(et[0])},[h,v,G,n,et]);const jt=s.useRef(null);s.useEffect(()=>{if(!n){jt.current=null;return}if(jt.current===n.id)return;const t=$e.find(([,a])=>a.items.some(u=>u.id===n.id));t&&(jt.current=n.id,$t(t[0]))},[n?.id,$e,$t]);const Wt=s.useRef(null);s.useEffect(()=>{const t=a=>{if(a.target instanceof HTMLInputElement||a.target instanceof HTMLTextAreaElement){a.key==="Escape"&&(a.target.blur(),a.preventDefault());return}if((a.metaKey||a.ctrlKey)&&a.key==="f"){a.preventDefault(),Wt.current?.focus();return}if(a.key==="ArrowDown"||a.key==="ArrowUp"){a.preventDefault();const u=et;if(u.length===0)return;const m=n?u.findIndex($=>$.id===n.id):-1,B=a.key==="ArrowDown"?Math.min(m+1,u.length-1):Math.max(m-1,0);Ft(u[B])}};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[et,n]);const dt=s.useRef(null),Qt=s.useCallback(t=>{if(!v)return;const a=ue.current;!a||a.scrollTop>0||(dt.current={y:t.touches[0].clientY,scrollTop:a.scrollTop})},[v]),Xt=s.useCallback(t=>{if(!v||!dt.current||A)return;const a=t.changedTouches[0].clientY-dt.current.y;dt.current=null,a>80&&ue.current&&ue.current.scrollTop<=0&&(V(!0),Me().finally(()=>V(!1)))},[v,A,Me]),Ft=t=>{const a=()=>{de(t),ae([]),_e(!1),Oe(!1),v&&(xe(!1),U(!0),history.pushState({mobileDetail:Te.DELIVERABLES},"",window.location.hash))};De?ze({action:a}):a()},Zt=()=>{if(!De){const t=Ve??n?.summary??"";pt(t)}_e(!0)},Jt=()=>{De?ze({action:()=>{_e(!1),Oe(!1)}}):_e(!1)},_t=async()=>{if(!(!n?.reference||ht)){Ct(!0);try{await L.files.write(n.reference,Ze),d(Ze),Oe(!1),_e(!1),we("success",r("detail.saved"))}catch(t){we("error",r("detail.saveFailed")+": "+String(t))}Ct(!1)}},es=()=>{_e(!1),Oe(!1),ze(null)};s.useEffect(()=>{if(!De)return;const t=a=>{a.preventDefault()};return window.addEventListener("beforeunload",t),()=>window.removeEventListener("beforeunload",t)},[De]),s.useEffect(()=>{if(!De)return;const t=a=>{a.preventDefault(),a.stopImmediatePropagation(),ze({action:()=>{_e(!1),Oe(!1);const{page:u,params:m}=a.detail||{};u&&Ge.navigate(u,m)}})};return window.addEventListener("markus:navigate",t),()=>window.removeEventListener("markus:navigate",t)},[De]);const wt=s.useRef(!1);s.useEffect(()=>{if(!w){wt.current=!1;return}if(v||wt.current)return;const t=400,a=I?0:K.width??384;window.innerWidth-160-a-t<480&&!I&&y(!0)},[w,v,I,K.width]);const kt=s.useRef(null),ts=s.useCallback((t,a)=>{const u=t.length>30?`${t.slice(0,15)}…${t.slice(-12)}`:t,m=`sel_${Date.now()}`;let B;if(a){const $=n?.reference??"";B=["[html-selection]",`Text: "${t}"`,`CSS Selector: ${a.cssSelector}`,`XPath: ${a.xpath}`,$?`File: ${$}`:""].filter(Boolean).join(`
6
- `)}else B=t;ae($=>[...$,{id:m,label:a?`🌐 ${u}`:u,type:"selection",content:B,onRemove:()=>ae(ke=>ke.filter(ns=>ns.id!==m))}]),w||xe(!0),qe(null),window.getSelection()?.removeAllRanges()},[w,n?.reference]),ss=s.useCallback(t=>{if(!t.text.trim())return;const u=kt.current?.querySelector("iframe")?.getBoundingClientRect(),m=(u?.left??0)+t.rect.x+t.rect.width/2,B=(u?.top??0)+t.rect.y;qe({x:m,y:B,text:t.text,htmlMeta:{xpath:t.xpath,cssSelector:t.cssSelector}})},[]);return s.useEffect(()=>{const t=kt.current;if(!t)return;const a=()=>{requestAnimationFrame(()=>{const m=window.getSelection(),B=m?.toString().trim();if(!B||!m?.rangeCount){qe(null);return}const $=m.getRangeAt(0);if(!t.contains($.commonAncestorContainer)){qe(null);return}const ke=$.getBoundingClientRect();qe({x:ke.left+ke.width/2,y:ke.top,text:B})})},u=m=>{const B=document.getElementById("selection-toolbar");B&&B.contains(m.target)||qe(null)};return t.addEventListener("mouseup",a),document.addEventListener("mousedown",u),()=>{t.removeEventListener("mouseup",a),document.removeEventListener("mousedown",u)}},[]),e.jsxs("div",{className:"flex-1 overflow-hidden flex",children:[e.jsxs("div",{className:`${v?"flex-1 min-w-0":"shrink-0"} flex flex-col bg-surface-secondary rounded-xl m-1 mr-0`,style:v?z?{display:"none"}:void 0:I?{display:"none"}:{width:K.width},children:[e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between gap-2",children:e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[v&&e.jsx(js,{}),!v&&e.jsx("button",{onClick:()=>y(!0),className:"w-8 h-8 flex items-center justify-center rounded-lg transition-colors shrink-0 bg-brand-500/15 text-brand-500 hover:bg-brand-500/25",title:r("sidebar.collapse"),children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),e.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),e.jsxs("h2",{className:"text-sm font-semibold text-fg-secondary truncate",children:[r("title"),k>0&&e.jsxs("span",{className:"ml-1.5 text-fg-tertiary font-normal",children:["(",k,")"]})]})]})}),e.jsxs("div",{className:"relative",children:[e.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-fg-muted pointer-events-none",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("input",{ref:Wt,value:ie,onChange:t=>ce(t.target.value),placeholder:r("searchPlaceholder"),className:"w-full bg-surface-elevated border border-border-default rounded-lg pl-8 pr-8 py-2 text-sm text-fg-primary focus:border-brand-500 focus:outline-none transition-colors"}),ie&&e.jsx("button",{onClick:()=>{ce(""),me("")},className:"absolute right-2.5 top-1/2 -translate-y-1/2 w-4 h-4 flex items-center justify-center rounded-full bg-surface-overlay text-fg-tertiary hover:text-fg-secondary transition-colors",children:e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),x&&!v&&e.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1.5 bg-surface-elevated rounded-lg text-[10px] text-fg-tertiary",children:[e.jsx("span",{className:"truncate font-mono",children:x}),e.jsx("button",{onClick:()=>{L.system.openPath(x)},className:"shrink-0 underline hover:text-fg-secondary transition-colors",children:r("common:open")})]}),v&&e.jsxs("button",{onClick:()=>O(t=>!t),className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs transition-colors ${D||ct?"bg-brand-500/15 text-brand-500":"bg-surface-elevated text-fg-secondary"}`,children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),e.jsx("line",{x1:"8",y1:"12",x2:"20",y2:"12"}),e.jsx("line",{x1:"12",y1:"18",x2:"20",y2:"18"})]}),r("filters.filtersLabel"),ct&&e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-500"}),e.jsx("svg",{className:`w-3 h-3 ml-auto transition-transform ${D?"rotate-180":""}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),e.jsxs("div",{className:v&&!D?"hidden":"space-y-3",children:[e.jsxs("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide filter-pills-fade",children:[e.jsx(St,{label:r("filters.allTypes"),value:"",current:Y||ee||"",onClick:()=>{J(""),ve("")}}),Es.map(t=>e.jsx(St,{label:`${Qe[t]?.icon??""} ${t}`,value:t,current:Y,onClick:a=>{J(a),ve("")}},t)),["agent","team","skill"].map(t=>e.jsx(St,{label:`${Pe[t].icon} ${r(`artifactTypes.${t}`)}`,value:t,current:ee,onClick:a=>{ve(a),J("")}},t))]}),e.jsxs("div",{className:"flex gap-1.5 items-center",children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary",children:r("filters.group")}),["date","project","team","agent"].map(t=>e.jsx("button",{onClick:()=>{Ce(t)},className:`px-2 py-1 rounded text-xs transition-colors ${W===t?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:bg-surface-overlay"}`,children:r(`groupBy.${t}`)},t)),$e.length>1&&e.jsx("button",{onClick:Yt,className:"ml-auto px-1.5 py-1 rounded text-[10px] text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated transition-colors",title:r(Dt?"expandAllTooltip":"collapseAllTooltip"),children:r(Dt?"expandAll":"collapseAll")})]})]}),ct&&e.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[ye&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-500 text-[10px]",children:["“",ye,"”",e.jsx("button",{onClick:()=>{ce(""),me("")},className:"hover:text-brand-400",children:e.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),Y&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-500 text-[10px]",children:[Qe[Y]?.icon," ",Y,e.jsx("button",{onClick:()=>J(""),className:"hover:text-brand-400",children:e.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),ee&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-500 text-[10px]",children:[Pe[ee]?.icon," ",r(`artifactTypes.${ee}`),e.jsx("button",{onClick:()=>ve(""),className:"hover:text-brand-400",children:e.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),e.jsx("button",{onClick:Pt,className:"text-[10px] text-fg-tertiary hover:text-brand-500 ml-auto transition-colors",children:r("filters.clearAll")})]})]}),Ee&&e.jsx("div",{className:`mx-4 mt-2 px-3 py-1.5 text-xs rounded-lg ${Ee.type==="success"?"bg-green-500/15 text-green-600":"bg-red-500/15 text-red-500"}`,children:Ee.text}),e.jsxs("div",{ref:ue,className:"flex-1 overflow-y-auto p-2 space-y-1 transition-opacity duration-150",style:{opacity:G?.5:1},onTouchStart:v?t=>{Be.onTouchStart(t),Qt(t)}:void 0,onTouchEnd:v?t=>{Be.onTouchEnd(t),Xt(t)}:void 0,children:[A&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-2 text-brand-500",children:[e.jsx(Ht,{})," ",e.jsx("span",{className:"text-[10px]",children:r("filters.refreshing")})]}),G?e.jsx("div",{className:"p-4 space-y-3",children:[1,2,3].map(t=>e.jsxs("div",{className:"animate-pulse space-y-2",children:[e.jsx("div",{className:"h-4 bg-surface-elevated rounded w-3/4"}),e.jsx("div",{className:"h-3 bg-surface-elevated rounded w-1/2"})]},t))}):E.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-6 text-center",children:[e.jsx("svg",{className:"w-12 h-12 text-fg-muted mb-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),ct?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-fg-secondary",children:r("empty.noResults")}),e.jsx("p",{className:"text-xs text-fg-tertiary mt-1 mb-3",children:r("empty.noResultsHint")}),e.jsx("button",{onClick:Pt,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:r("filters.clearAll")})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-fg-secondary",children:r("empty.title")}),e.jsx("p",{className:"text-xs text-fg-tertiary mt-1 mb-3",children:r("empty.subtitle")}),e.jsx("button",{onClick:()=>Ge.navigate(Te.WORK),className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:r("empty.goToWork")})]})]}):$e.map(([t,a])=>{const u=Bt(t);return e.jsxs("div",{className:"mb-1",children:[e.jsxs("button",{onClick:()=>Gt(t),className:"w-full flex items-center gap-1.5 px-2 py-2 rounded-md hover:bg-surface-elevated/50 transition-colors group/header border-b border-border-subtle/50",children:[e.jsx("svg",{className:`w-3 h-3 text-fg-tertiary transition-transform duration-200 shrink-0 ${u?"":"rotate-90"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),e.jsx("span",{className:"text-[11px] font-semibold text-fg-tertiary uppercase tracking-wider truncate",children:a.label}),e.jsxs("span",{className:"text-[10px] text-fg-muted bg-surface-elevated px-1.5 py-0.5 rounded-full shrink-0",children:[a.items.length,E.length<k?"+":""]})]}),e.jsx("div",{className:`overflow-hidden transition-all duration-200 ${u?"max-h-0 opacity-0":"max-h-[5000px] opacity-100"}`,children:a.items.map(m=>e.jsx("button",{onClick:()=>Ft(m),className:`w-full text-left px-3 py-2 rounded-lg transition-all duration-150 ${n?.id===m.id?"bg-brand-600/15 border-l-2 border-l-brand-500 border-y border-r border-y-brand-500/20 border-r-brand-500/20":"hover:bg-surface-elevated/60 border-l-2 border-l-transparent border-y border-r border-transparent"}`,children:e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[m.artifactType&&Pe[m.artifactType]?e.jsx("span",{className:`text-[10px] px-1 py-0.5 rounded font-medium shrink-0 ${Pe[m.artifactType].color}`,children:Pe[m.artifactType].icon}):e.jsx("span",{className:`text-[10px] px-1 py-0.5 rounded font-medium uppercase shrink-0 ${Qe[m.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:Qe[m.type]?.icon??m.type.charAt(0)}),e.jsx("span",{className:"text-sm font-medium text-fg-primary truncate flex-1",children:m.title}),b.has(m.id)&&e.jsx("span",{className:"shrink-0 text-amber-500",title:r("detail.fileMissing"),children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}),e.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:As(m.updatedAt,r)})]})},m.id))})]},t)}),ne&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-fg-tertiary",children:[e.jsx(Ht,{})," ",e.jsx("span",{className:"text-[10px]",children:r("common:loadingMore")})]}),!G&&E.length>0&&e.jsx("div",{className:"text-center text-[10px] text-fg-tertiary py-2",children:E.length<k?r("count.partial",{loaded:E.length,total:k}):r("count.total",{total:k})})]})]}),!v&&e.jsx("div",{className:"w-2 shrink-0 cursor-col-resize group relative flex items-center justify-center hover:bg-brand-500/5 transition-colors",onMouseDown:K.onResizeStart,children:e.jsxs("div",{className:"flex flex-col gap-1 items-center opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("div",{className:"w-1 h-1 rounded-full bg-fg-muted"}),e.jsx("div",{className:"w-1 h-1 rounded-full bg-fg-muted"}),e.jsx("div",{className:"w-1 h-1 rounded-full bg-fg-muted"})]})}),(!v||z)&&e.jsxs("div",{className:"flex-1 overflow-hidden min-w-0 flex relative",children:[e.jsxs("div",{ref:kt,className:"flex-1 overflow-y-auto min-w-0",children:[I&&!v&&e.jsxs("div",{className:"sticky top-0 z-10 bg-surface-primary/80 backdrop-blur-sm px-4 py-2 flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{wt.current=!0,y(!1)},className:"w-8 h-8 flex items-center justify-center rounded-lg transition-colors shrink-0 text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated",title:r("sidebar.expand"),children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),e.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),e.jsx("span",{className:"text-sm font-medium text-fg-secondary truncate",children:n?.title??r("detail.details")})]}),v&&e.jsxs("div",{className:"sticky top-0 z-10 bg-surface-secondary px-4 py-2.5 flex items-center gap-2",children:[e.jsx("button",{onClick:()=>history.back(),className:"text-fg-secondary hover:text-fg-primary transition-colors p-1 -ml-1",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"15 18 9 12 15 6"})})}),e.jsx("span",{className:"text-sm font-medium truncate",children:n?.title??r("detail.details")})]}),n?e.jsxs("div",{className:"p-6 space-y-4",children:[!h&&b.has(n.id)&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-amber-500/10 border border-amber-500/20 rounded-lg text-amber-600 text-xs",children:[e.jsxs("svg",{className:"w-4 h-4 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),e.jsx("span",{children:r("detail.fileMissing")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("h2",{className:"text-xl font-semibold text-fg-primary",children:n.title}),!h&&e.jsx("button",{onClick:()=>i(n),disabled:!!Ae,className:"p-1.5 rounded-lg text-fg-tertiary hover:text-red-500 hover:bg-red-500/10 transition-colors disabled:opacity-50 shrink-0",title:r("common:remove"),children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"3 6 5 6 21 6"}),e.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:`px-2 py-0.5 rounded text-xs font-medium uppercase ${Qe[n.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:[Qe[n.type]?.icon??""," ",n.type]}),n.artifactType&&Pe[n.artifactType]&&e.jsxs("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${Pe[n.artifactType].color}`,children:[Pe[n.artifactType].icon," ",r("detail.builderWithType",{type:r(`artifactTypes.${n.artifactType}`)})]}),n.tags.length>0&&n.tags.map(t=>e.jsx("span",{className:"px-2 py-0.5 text-xs bg-surface-elevated text-fg-secondary rounded",children:t},t))]}),(n.taskId||n.agentId||rt(n.projectId))&&e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.taskId&&e.jsx("button",{onClick:()=>Ge.navigate(Te.WORK,{openTask:n.taskId}),className:"text-xs text-brand-500 hover:underline bg-brand-500/10 px-2 py-0.5 rounded",children:r("links.task",{id:`${n.taskId.slice(0,12)}...`})}),n.agentId&&e.jsx("button",{onClick:()=>Ge.navigate(Te.TEAM,{selectAgent:n.agentId}),className:"text-xs text-blue-600 hover:underline bg-blue-500/10 px-2 py-0.5 rounded",children:r("links.agent",{name:nt.get(n.agentId)?.name??n.agentId.slice(0,12)})}),rt(n.projectId)&&e.jsx("button",{onClick:()=>Ge.navigate(Te.WORK,{projectId:n.projectId}),className:"text-xs text-blue-600 hover:underline bg-blue-500/10 px-2 py-0.5 rounded",children:r("links.project",{name:rt(n.projectId)})})]}),(n.diffStats||n.testResults)&&e.jsxs("div",{className:"flex gap-3 flex-wrap",children:[n.diffStats&&e.jsxs("div",{className:"bg-surface-elevated rounded-lg px-3 py-2 text-xs flex items-center gap-2",children:[e.jsxs("span",{className:"text-fg-tertiary font-medium",children:[r("diffStats.title"),":"]}),e.jsx("span",{className:"text-fg-secondary",children:r("diffStats.files",{count:n.diffStats.filesChanged})}),e.jsxs("span",{className:"text-green-600",children:["+",n.diffStats.additions]}),e.jsxs("span",{className:"text-red-500",children:["-",n.diffStats.deletions]})]}),n.testResults&&e.jsxs("div",{className:"bg-surface-elevated rounded-lg px-3 py-2 text-xs flex items-center gap-2",children:[e.jsxs("span",{className:"text-fg-tertiary font-medium",children:[r("testResults.title"),":"]}),e.jsx("span",{className:"text-green-600",children:r("testResults.passed",{count:n.testResults.passed})}),e.jsx("span",{className:"text-red-500",children:r("testResults.failed",{count:n.testResults.failed})}),e.jsx("span",{className:"text-fg-secondary",children:r("testResults.skipped",{count:n.testResults.skipped})})]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-[10px] text-fg-tertiary flex-wrap",children:[e.jsxs("span",{children:[r("metadata.created")," ",new Date(n.createdAt).toLocaleString()]}),e.jsxs("span",{children:[r("metadata.updated")," ",new Date(n.updatedAt).toLocaleString()]}),e.jsx("span",{className:"text-fg-muted select-all",children:n.id.slice(0,12)})]}),n.reference&&!ut(n.reference)&&n.type==="file"&&e.jsxs("div",{className:"flex items-center gap-2 bg-surface-elevated rounded-lg px-3 py-2",children:[e.jsx("button",{onClick:()=>{L.files.reveal(n.reference).catch(()=>we("error",r("detail.failedToOpenBrowser")))},className:"text-xs font-mono text-brand-500 hover:text-brand-500 hover:underline truncate flex-1 text-left cursor-pointer",title:r("detail.openInFileBrowser"),children:n.reference}),e.jsx("button",{onClick:()=>{L.files.reveal(n.reference).catch(()=>we("error",r("detail.failedToOpenBrowser")))},className:"px-2 py-1 text-[10px] rounded bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",title:r("detail.revealInFinder"),children:r("common:open")}),e.jsx("button",{onClick:()=>Mt(n.reference),className:`px-2 py-1 text-[10px] rounded transition-colors shrink-0 ${Le?"bg-green-500/20 text-green-600":"bg-surface-overlay/50 text-fg-secondary hover:bg-surface-overlay"}`,title:r("detail.copyPath"),children:r(Le?"common:copied":"common:copy")})]}),n.reference&&!ut(n.reference)&&n.type!=="file"&&n.type!=="directory"&&e.jsx("span",{className:"text-xs text-fg-tertiary font-mono break-all",children:n.reference})]}),n.artifactType&&n.artifactData?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:e.jsx(Cs,{artifact:n.artifactData,mode:n.artifactType})}),n.reference&&e.jsxs("div",{className:"px-3 py-2 bg-surface-elevated rounded-lg",children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider block mb-1",children:r("detail.artifactDirectory")}),e.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all",children:n.reference})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx("button",{onClick:Kt,className:"flex-1 px-4 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-sm font-medium rounded-lg transition-colors",children:r("detail.openInBuilder")})}),n.summary&&e.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:e.jsx(tt,{content:n.summary,className:"text-fg-secondary text-sm"})})]}):n.reference&&ut(n.reference)?e.jsxs("div",{className:"space-y-4",children:[n.summary&&e.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:e.jsx(tt,{content:n.summary,className:"text-fg-secondary text-sm"})}),e.jsxs("div",{className:"flex flex-col items-center justify-center py-10",children:[e.jsxs("svg",{className:"w-10 h-10 text-fg-muted mb-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),e.jsx("p",{className:"text-xs text-fg-tertiary font-mono mb-4 px-4 text-center break-all select-all",children:n.reference}),e.jsx("button",{onClick:()=>window.open(n.reference,"_blank","noopener,noreferrer"),className:"px-6 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-sm font-medium rounded-lg transition-colors",children:r("detail.openUrl")})]})]}):n.type==="directory"&&n.reference?e.jsxs("div",{className:"space-y-4",children:[n.summary&&e.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:e.jsx(tt,{content:n.summary,className:"text-fg-secondary text-sm"})}),e.jsxs("div",{className:"flex flex-col items-center justify-center py-10",children:[e.jsx("svg",{className:"w-10 h-10 text-fg-muted mb-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})}),e.jsx("p",{className:"text-xs text-fg-tertiary font-mono mb-4 px-4 text-center break-all select-all",children:n.reference}),e.jsx("button",{onClick:()=>{L.files.reveal(n.reference).catch(()=>we("error",r("detail.failedToOpenBrowser")))},className:"px-6 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-sm font-medium rounded-lg transition-colors",children:r("detail.openInFileBrowser")})]})]}):e.jsxs("div",{className:"bg-surface-elevated rounded-xl overflow-hidden",children:[(Ve||n.summary)&&!te&&!H&&!he&&n.reference&&n.type==="file"&&(N==="markdown"||N==="text"||N==="html")&&e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border-subtle bg-surface-secondary/50",children:[e.jsx("button",{onClick:Jt,className:`px-3 py-1 rounded text-xs font-medium transition-colors ${Ke?"text-fg-tertiary hover:text-fg-secondary":"bg-brand-600/20 text-brand-500"}`,children:r("detail.preview")}),e.jsx("button",{onClick:Zt,className:`px-3 py-1 rounded text-xs font-medium transition-colors ${Ke?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:r("detail.edit")}),e.jsx("div",{className:"flex-1"}),Ke&&e.jsx("button",{onClick:_t,disabled:!De||ht,className:"px-3 py-1 rounded text-xs font-medium bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:r(ht?"detail.saving":"detail.save")})]}),e.jsx("div",{className:"p-5",children:te?e.jsxs("div",{className:"animate-pulse space-y-4",children:[e.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-full"}),e.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-5/6"}),e.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-4/6"}),e.jsx("div",{className:"h-32 bg-surface-overlay/40 rounded-lg w-full mt-2"}),e.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-3/4"}),e.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-2/3"})]}):H?e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("img",{src:H.src,alt:H.name,className:"max-w-full max-h-[60vh] rounded-lg object-contain"}),e.jsx("span",{className:"text-xs text-fg-tertiary",children:H.name})]}):R?e.jsxs("div",{className:"flex flex-col gap-3 py-4",children:[R.kind==="audio"?e.jsx("audio",{controls:!0,preload:"metadata",src:R.src,className:"w-full"}):e.jsx("video",{controls:!0,preload:"metadata",src:R.src,className:"w-full max-h-[60vh] rounded-lg bg-black"}),e.jsx("span",{className:"text-xs text-fg-tertiary",children:R.name})]}):Ve?Ke?e.jsx("div",{className:"animate-fadeIn",children:e.jsx("textarea",{ref:bt,value:Ze,onChange:t=>{pt(t.target.value),Oe(!0)},className:"w-full min-h-[120px] p-3 text-sm font-mono bg-surface-primary border border-border-subtle rounded-lg text-fg-secondary focus:outline-none focus:ring-1 focus:ring-brand-500/50 overflow-hidden",style:{resize:"none"},spellCheck:!1})},"edit"):e.jsx("div",{className:"animate-fadeIn",children:e.jsx(Ns,{content:Ve,format:N,className:"text-fg-secondary text-sm",onHtmlSelection:ss,basePath:n?.reference?n.reference.replace(/[/\\][^/\\]+$/,""):void 0})},"preview"):he?e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-fg-secondary",children:r("detail.cannotPreview",{type:n.type})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{L.files.reveal(n.reference).catch(()=>we("error",r("detail.failedToOpen")))},className:"text-xs bg-surface-elevated px-3 py-2 rounded text-brand-500 hover:text-brand-500 hover:underline flex-1 truncate text-left cursor-pointer font-mono",title:r("detail.openInFileBrowser"),children:n.reference}),e.jsx("button",{onClick:()=>{L.files.reveal(n.reference).catch(()=>we("error",r("detail.failedToOpen")))},className:"px-3 py-2 text-xs rounded-lg bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",children:r("common:open")}),e.jsx("button",{onClick:()=>Mt(n.reference),className:`px-3 py-2 text-xs rounded-lg transition-colors shrink-0 ${Le?"bg-green-500/20 text-green-600":"bg-surface-overlay/50 text-fg-secondary hover:bg-surface-overlay"}`,children:r(Le?"common:copied":"common:copy")})]})]}):n.summary?Ke?e.jsx("textarea",{ref:bt,value:Ze,onChange:t=>{pt(t.target.value),Oe(!0)},className:"w-full min-h-[120px] p-3 text-sm font-mono bg-surface-primary border border-border-subtle rounded-lg text-fg-secondary focus:outline-none focus:ring-1 focus:ring-brand-500/50 overflow-hidden",style:{resize:"none"},spellCheck:!1}):e.jsx(tt,{content:n.summary,className:"text-fg-secondary text-sm"}):e.jsx("p",{className:"text-sm text-fg-tertiary italic",children:r("detail.noContent")})})]})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center text-fg-tertiary space-y-3 max-w-xs",children:[e.jsx("div",{className:"w-16 h-16 mx-auto rounded-2xl bg-surface-elevated/60 flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-fg-muted",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})})}),e.jsx("p",{className:"text-sm text-fg-secondary",children:r("detail.selectToView")}),!v&&e.jsx("p",{className:"text-[10px] text-fg-muted",children:r("detail.keyboardHint")})]})})]}),n?.agentId&&!w&&!v&&e.jsx("button",{onClick:()=>xe(!0),className:"absolute bottom-6 right-6 w-12 h-12 rounded-full bg-brand-600 hover:bg-brand-500 text-white shadow-lg shadow-black/20 flex items-center justify-center transition-all hover:scale-105 z-20 animate-fab-in",title:r("chat.openChat"),children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),w&&n?.agentId&&!v&&e.jsx(Ts,{agentId:n.agentId,agents:Se,authUser:c,onClose:()=>{xe(!1),ae([])},contextChips:[{id:`deliverable_ctx_${n.id}`,label:`📦 ${n.title}`,type:"deliverable",content:`${r("chat.currentDeliverable")}: ${n.title} (id: ${n.id})`},...mt],width:400})]}),Xe&&e.jsx("div",{id:"selection-toolbar",className:"fixed z-50 -translate-x-1/2 -translate-y-full bg-surface-elevated border border-border-default rounded-lg shadow-xl overflow-hidden",style:{left:Xe.x,top:Xe.y-8},children:e.jsxs("button",{onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),ts(Xe.text,Xe.htmlMeta)},className:"px-3 py-1.5 text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-1.5 whitespace-nowrap",children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),r("contextMenu.addToConversation")]})}),g&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:()=>i(null),children:e.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 max-w-sm mx-4 shadow-2xl",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/15 flex items-center justify-center shrink-0",children:e.jsxs("svg",{className:"w-5 h-5 text-red-500",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"3 6 5 6 21 6"}),e.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-fg-primary",children:r("detail.confirmRemoveTitle")}),e.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:r("detail.confirmRemoveMessage",{name:g.title})})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>i(null),className:"px-4 py-1.5 text-xs text-fg-secondary hover:text-fg-primary border border-border-default hover:border-gray-600 rounded-lg transition-colors",children:r("common:cancel")}),e.jsx("button",{onClick:()=>{const t=g;i(null),qt(t)},disabled:!!Ae,className:"px-4 py-1.5 text-xs bg-red-600 hover:bg-red-500 text-white rounded-lg transition-colors disabled:opacity-50",children:r("common:remove")})]})]})}),gt&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:()=>ze(null),children:e.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 max-w-sm mx-4 shadow-2xl",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-amber-500/15 flex items-center justify-center shrink-0",children:e.jsx("svg",{className:"w-5 h-5 text-amber-500",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-fg-primary",children:r("detail.unsavedTitle")}),e.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:r("detail.unsavedMessage")})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>ze(null),className:"px-4 py-1.5 text-xs text-fg-secondary hover:text-fg-primary border border-border-default hover:border-gray-600 rounded-lg transition-colors",children:r("common:cancel")}),e.jsx("button",{onClick:()=>{es(),gt.action()},className:"px-4 py-1.5 text-xs text-fg-secondary hover:text-fg-primary border border-border-default hover:border-gray-600 rounded-lg transition-colors",children:r("detail.discard")}),e.jsx("button",{onClick:async()=>{await _t(),gt.action(),ze(null)},className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors",children:r("detail.saveAndLeave")})]})]})})]})}function St({label:c,value:h,current:f,onClick:r}){return e.jsx("button",{onClick:()=>r(f===h?"":h),className:`px-2 py-1 rounded text-xs whitespace-nowrap shrink-0 transition-colors ${f===h?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:bg-surface-overlay"}`,children:c})}function Ht(){return e.jsxs("svg",{className:"animate-spin h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}export{Ds as DeliverablesPage};
6
+ `)}else B=t;ae($=>[...$,{id:m,label:a?`🌐 ${u}`:u,type:"selection",content:B,onRemove:()=>ae(ke=>ke.filter(ns=>ns.id!==m))}]),w||xe(!0),qe(null),window.getSelection()?.removeAllRanges()},[w,n?.reference]),ss=s.useCallback(t=>{if(!t.text.trim())return;const u=kt.current?.querySelector("iframe")?.getBoundingClientRect(),m=(u?.left??0)+t.rect.x+t.rect.width/2,B=(u?.top??0)+t.rect.y;qe({x:m,y:B,text:t.text,htmlMeta:{xpath:t.xpath,cssSelector:t.cssSelector}})},[]);return s.useEffect(()=>{const t=kt.current;if(!t)return;const a=()=>{requestAnimationFrame(()=>{const m=window.getSelection(),B=m?.toString().trim();if(!B||!m?.rangeCount){qe(null);return}const $=m.getRangeAt(0);if(!t.contains($.commonAncestorContainer)){qe(null);return}const ke=$.getBoundingClientRect();qe({x:ke.left+ke.width/2,y:ke.top,text:B})})},u=m=>{const B=document.getElementById("selection-toolbar");B&&B.contains(m.target)||qe(null)};return t.addEventListener("mouseup",a),document.addEventListener("mousedown",u),()=>{t.removeEventListener("mouseup",a),document.removeEventListener("mousedown",u)}},[]),e.jsxs("div",{className:"flex-1 overflow-hidden flex",children:[e.jsxs("div",{className:`${v?"flex-1 min-w-0":"shrink-0"} flex flex-col bg-surface-secondary rounded-xl m-1 mr-0`,style:v?z?{display:"none"}:void 0:I?{display:"none"}:{width:K.width},children:[e.jsxs("div",{"data-electron-drag":!0,className:"p-4 space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between gap-2",children:e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[v&&e.jsx(js,{}),!v&&e.jsx("button",{onClick:()=>y(!0),className:"w-8 h-8 flex items-center justify-center rounded-lg transition-colors shrink-0 bg-brand-500/15 text-brand-500 hover:bg-brand-500/25",title:r("sidebar.collapse"),children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),e.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),e.jsxs("h2",{className:"text-sm font-semibold text-fg-secondary truncate",children:[r("title"),k>0&&e.jsxs("span",{className:"ml-1.5 text-fg-tertiary font-normal",children:["(",k,")"]})]})]})}),e.jsxs("div",{className:"relative",children:[e.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-fg-muted pointer-events-none",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("input",{ref:Wt,value:ie,onChange:t=>ce(t.target.value),placeholder:r("searchPlaceholder"),className:"w-full bg-surface-elevated border border-border-default rounded-lg pl-8 pr-8 py-2 text-sm text-fg-primary focus:border-brand-500 focus:outline-none transition-colors"}),ie&&e.jsx("button",{onClick:()=>{ce(""),me("")},className:"absolute right-2.5 top-1/2 -translate-y-1/2 w-4 h-4 flex items-center justify-center rounded-full bg-surface-overlay text-fg-tertiary hover:text-fg-secondary transition-colors",children:e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),x&&!v&&e.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1.5 bg-surface-elevated rounded-lg text-[10px] text-fg-tertiary",children:[e.jsx("span",{className:"truncate font-mono",children:x}),e.jsx("button",{onClick:()=>{L.system.openPath(x)},className:"shrink-0 underline hover:text-fg-secondary transition-colors",children:r("common:open")})]}),v&&e.jsxs("button",{onClick:()=>O(t=>!t),className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs transition-colors ${D||ct?"bg-brand-500/15 text-brand-500":"bg-surface-elevated text-fg-secondary"}`,children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),e.jsx("line",{x1:"8",y1:"12",x2:"20",y2:"12"}),e.jsx("line",{x1:"12",y1:"18",x2:"20",y2:"18"})]}),r("filters.filtersLabel"),ct&&e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-500"}),e.jsx("svg",{className:`w-3 h-3 ml-auto transition-transform ${D?"rotate-180":""}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),e.jsxs("div",{className:v&&!D?"hidden":"space-y-3",children:[e.jsxs("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide filter-pills-fade",children:[e.jsx(St,{label:r("filters.allTypes"),value:"",current:Y||ee||"",onClick:()=>{J(""),ve("")}}),Es.map(t=>e.jsx(St,{label:`${Qe[t]?.icon??""} ${t}`,value:t,current:Y,onClick:a=>{J(a),ve("")}},t)),["agent","team","skill"].map(t=>e.jsx(St,{label:`${Pe[t].icon} ${r(`artifactTypes.${t}`)}`,value:t,current:ee,onClick:a=>{ve(a),J("")}},t))]}),e.jsxs("div",{className:"flex gap-1.5 items-center",children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary",children:r("filters.group")}),["date","project","team","agent"].map(t=>e.jsx("button",{onClick:()=>{Ce(t)},className:`px-2 py-1 rounded text-xs transition-colors ${W===t?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:bg-surface-overlay"}`,children:r(`groupBy.${t}`)},t)),$e.length>1&&e.jsx("button",{onClick:Yt,className:"ml-auto px-1.5 py-1 rounded text-[10px] text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated transition-colors",title:r(Dt?"expandAllTooltip":"collapseAllTooltip"),children:r(Dt?"expandAll":"collapseAll")})]})]}),ct&&e.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[ye&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-500 text-[10px]",children:["“",ye,"”",e.jsx("button",{onClick:()=>{ce(""),me("")},className:"hover:text-brand-400",children:e.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),Y&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-500 text-[10px]",children:[Qe[Y]?.icon," ",Y,e.jsx("button",{onClick:()=>J(""),className:"hover:text-brand-400",children:e.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),ee&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-500 text-[10px]",children:[Pe[ee]?.icon," ",r(`artifactTypes.${ee}`),e.jsx("button",{onClick:()=>ve(""),className:"hover:text-brand-400",children:e.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),e.jsx("button",{onClick:Pt,className:"text-[10px] text-fg-tertiary hover:text-brand-500 ml-auto transition-colors",children:r("filters.clearAll")})]})]}),Ee&&e.jsx("div",{className:`mx-4 mt-2 px-3 py-1.5 text-xs rounded-lg ${Ee.type==="success"?"bg-green-500/15 text-green-600":"bg-red-500/15 text-red-500"}`,children:Ee.text}),e.jsxs("div",{ref:ue,className:"flex-1 overflow-y-auto p-2 space-y-1 transition-opacity duration-150",style:{opacity:G?.5:1},onTouchStart:v?t=>{Be.onTouchStart(t),Qt(t)}:void 0,onTouchEnd:v?t=>{Be.onTouchEnd(t),Xt(t)}:void 0,children:[A&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-2 text-brand-500",children:[e.jsx(Ht,{})," ",e.jsx("span",{className:"text-[10px]",children:r("filters.refreshing")})]}),G?e.jsx("div",{className:"p-4 space-y-3",children:[1,2,3].map(t=>e.jsxs("div",{className:"animate-pulse space-y-2",children:[e.jsx("div",{className:"h-4 bg-surface-elevated rounded w-3/4"}),e.jsx("div",{className:"h-3 bg-surface-elevated rounded w-1/2"})]},t))}):E.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-6 text-center",children:[e.jsx("svg",{className:"w-12 h-12 text-fg-muted mb-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),ct?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-fg-secondary",children:r("empty.noResults")}),e.jsx("p",{className:"text-xs text-fg-tertiary mt-1 mb-3",children:r("empty.noResultsHint")}),e.jsx("button",{onClick:Pt,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:r("filters.clearAll")})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-fg-secondary",children:r("empty.title")}),e.jsx("p",{className:"text-xs text-fg-tertiary mt-1 mb-3",children:r("empty.subtitle")}),e.jsx("button",{onClick:()=>Ge.navigate(Te.WORK),className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:r("empty.goToWork")})]})]}):$e.map(([t,a])=>{const u=Bt(t);return e.jsxs("div",{className:"mb-1",children:[e.jsxs("button",{onClick:()=>Gt(t),className:"w-full flex items-center gap-1.5 px-2 py-2 rounded-md hover:bg-surface-elevated/50 transition-colors group/header border-b border-border-subtle/50",children:[e.jsx("svg",{className:`w-3 h-3 text-fg-tertiary transition-transform duration-200 shrink-0 ${u?"":"rotate-90"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),e.jsx("span",{className:"text-[11px] font-semibold text-fg-tertiary uppercase tracking-wider truncate",children:a.label}),e.jsxs("span",{className:"text-[10px] text-fg-muted bg-surface-elevated px-1.5 py-0.5 rounded-full shrink-0",children:[a.items.length,E.length<k?"+":""]})]}),e.jsx("div",{className:`overflow-hidden transition-all duration-200 ${u?"max-h-0 opacity-0":"max-h-[5000px] opacity-100"}`,children:a.items.map(m=>e.jsx("button",{onClick:()=>Ft(m),className:`w-full text-left px-3 py-2 rounded-lg transition-all duration-150 ${n?.id===m.id?"bg-brand-600/15 border-l-2 border-l-brand-500 border-y border-r border-y-brand-500/20 border-r-brand-500/20":"hover:bg-surface-elevated/60 border-l-2 border-l-transparent border-y border-r border-transparent"}`,children:e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[m.artifactType&&Pe[m.artifactType]?e.jsx("span",{className:`text-[10px] px-1 py-0.5 rounded font-medium shrink-0 ${Pe[m.artifactType].color}`,children:Pe[m.artifactType].icon}):e.jsx("span",{className:`text-[10px] px-1 py-0.5 rounded font-medium uppercase shrink-0 ${Qe[m.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:Qe[m.type]?.icon??m.type.charAt(0)}),e.jsx("span",{className:"text-sm font-medium text-fg-primary truncate flex-1",children:m.title}),b.has(m.id)&&e.jsx("span",{className:"shrink-0 text-amber-500",title:r("detail.fileMissing"),children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}),e.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:As(m.updatedAt,r)})]})},m.id))})]},t)}),ne&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-fg-tertiary",children:[e.jsx(Ht,{})," ",e.jsx("span",{className:"text-[10px]",children:r("common:loadingMore")})]}),!G&&E.length>0&&e.jsx("div",{className:"text-center text-[10px] text-fg-tertiary py-2",children:E.length<k?r("count.partial",{loaded:E.length,total:k}):r("count.total",{total:k})})]})]}),!v&&e.jsx("div",{className:"w-2 shrink-0 cursor-col-resize group relative flex items-center justify-center hover:bg-brand-500/5 transition-colors",onMouseDown:K.onResizeStart,children:e.jsxs("div",{className:"flex flex-col gap-1 items-center opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("div",{className:"w-1 h-1 rounded-full bg-fg-muted"}),e.jsx("div",{className:"w-1 h-1 rounded-full bg-fg-muted"}),e.jsx("div",{className:"w-1 h-1 rounded-full bg-fg-muted"})]})}),(!v||z)&&e.jsxs("div",{"data-no-drag":!0,className:"flex-1 overflow-hidden min-w-0 flex relative self-stretch",children:[e.jsxs("div",{ref:kt,className:"flex-1 overflow-y-auto min-w-0 h-full",children:[I&&!v&&e.jsxs("div",{className:"sticky top-0 z-10 bg-surface-primary/80 backdrop-blur-sm px-4 py-2 flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{wt.current=!0,y(!1)},className:"w-8 h-8 flex items-center justify-center rounded-lg transition-colors shrink-0 text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated",title:r("sidebar.expand"),children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),e.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),e.jsx("span",{className:"text-sm font-medium text-fg-secondary truncate",children:n?.title??r("detail.details")})]}),v&&e.jsxs("div",{className:"sticky top-0 z-10 bg-surface-secondary px-4 py-2.5 flex items-center gap-2",children:[e.jsx("button",{onClick:()=>history.back(),className:"text-fg-secondary hover:text-fg-primary transition-colors p-1 -ml-1",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"15 18 9 12 15 6"})})}),e.jsx("span",{className:"text-sm font-medium truncate",children:n?.title??r("detail.details")})]}),n?e.jsxs("div",{className:"p-6 space-y-4",children:[!h&&b.has(n.id)&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-amber-500/10 border border-amber-500/20 rounded-lg text-amber-600 text-xs",children:[e.jsxs("svg",{className:"w-4 h-4 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),e.jsx("span",{children:r("detail.fileMissing")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("h2",{className:"text-xl font-semibold text-fg-primary",children:n.title}),!h&&e.jsx("button",{onClick:()=>i(n),disabled:!!Ae,className:"p-1.5 rounded-lg text-fg-tertiary hover:text-red-500 hover:bg-red-500/10 transition-colors disabled:opacity-50 shrink-0",title:r("common:remove"),children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"3 6 5 6 21 6"}),e.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:`px-2 py-0.5 rounded text-xs font-medium uppercase ${Qe[n.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:[Qe[n.type]?.icon??""," ",n.type]}),n.artifactType&&Pe[n.artifactType]&&e.jsxs("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${Pe[n.artifactType].color}`,children:[Pe[n.artifactType].icon," ",r("detail.builderWithType",{type:r(`artifactTypes.${n.artifactType}`)})]}),n.tags.length>0&&n.tags.map(t=>e.jsx("span",{className:"px-2 py-0.5 text-xs bg-surface-elevated text-fg-secondary rounded",children:t},t))]}),(n.taskId||n.agentId||rt(n.projectId))&&e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.taskId&&e.jsx("button",{onClick:()=>Ge.navigate(Te.WORK,{openTask:n.taskId}),className:"text-xs text-brand-500 hover:underline bg-brand-500/10 px-2 py-0.5 rounded",children:r("links.task",{id:`${n.taskId.slice(0,12)}...`})}),n.agentId&&e.jsx("button",{onClick:()=>Ge.navigate(Te.TEAM,{selectAgent:n.agentId}),className:"text-xs text-blue-600 hover:underline bg-blue-500/10 px-2 py-0.5 rounded",children:r("links.agent",{name:nt.get(n.agentId)?.name??n.agentId.slice(0,12)})}),rt(n.projectId)&&e.jsx("button",{onClick:()=>Ge.navigate(Te.WORK,{projectId:n.projectId}),className:"text-xs text-blue-600 hover:underline bg-blue-500/10 px-2 py-0.5 rounded",children:r("links.project",{name:rt(n.projectId)})})]}),(n.diffStats||n.testResults)&&e.jsxs("div",{className:"flex gap-3 flex-wrap",children:[n.diffStats&&e.jsxs("div",{className:"bg-surface-elevated rounded-lg px-3 py-2 text-xs flex items-center gap-2",children:[e.jsxs("span",{className:"text-fg-tertiary font-medium",children:[r("diffStats.title"),":"]}),e.jsx("span",{className:"text-fg-secondary",children:r("diffStats.files",{count:n.diffStats.filesChanged})}),e.jsxs("span",{className:"text-green-600",children:["+",n.diffStats.additions]}),e.jsxs("span",{className:"text-red-500",children:["-",n.diffStats.deletions]})]}),n.testResults&&e.jsxs("div",{className:"bg-surface-elevated rounded-lg px-3 py-2 text-xs flex items-center gap-2",children:[e.jsxs("span",{className:"text-fg-tertiary font-medium",children:[r("testResults.title"),":"]}),e.jsx("span",{className:"text-green-600",children:r("testResults.passed",{count:n.testResults.passed})}),e.jsx("span",{className:"text-red-500",children:r("testResults.failed",{count:n.testResults.failed})}),e.jsx("span",{className:"text-fg-secondary",children:r("testResults.skipped",{count:n.testResults.skipped})})]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-[10px] text-fg-tertiary flex-wrap",children:[e.jsxs("span",{children:[r("metadata.created")," ",new Date(n.createdAt).toLocaleString()]}),e.jsxs("span",{children:[r("metadata.updated")," ",new Date(n.updatedAt).toLocaleString()]}),e.jsx("span",{className:"text-fg-muted select-all",children:n.id.slice(0,12)})]}),n.reference&&!ut(n.reference)&&n.type==="file"&&e.jsxs("div",{className:"flex items-center gap-2 bg-surface-elevated rounded-lg px-3 py-2",children:[e.jsx("button",{onClick:()=>{L.files.reveal(n.reference).catch(()=>we("error",r("detail.failedToOpenBrowser")))},className:"text-xs font-mono text-brand-500 hover:text-brand-500 hover:underline truncate flex-1 text-left cursor-pointer",title:r("detail.openInFileBrowser"),children:n.reference}),e.jsx("button",{onClick:()=>{L.files.reveal(n.reference).catch(()=>we("error",r("detail.failedToOpenBrowser")))},className:"px-2 py-1 text-[10px] rounded bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",title:r("detail.revealInFinder"),children:r("common:open")}),e.jsx("button",{onClick:()=>Mt(n.reference),className:`px-2 py-1 text-[10px] rounded transition-colors shrink-0 ${Le?"bg-green-500/20 text-green-600":"bg-surface-overlay/50 text-fg-secondary hover:bg-surface-overlay"}`,title:r("detail.copyPath"),children:r(Le?"common:copied":"common:copy")})]}),n.reference&&!ut(n.reference)&&n.type!=="file"&&n.type!=="directory"&&e.jsx("span",{className:"text-xs text-fg-tertiary font-mono break-all",children:n.reference})]}),n.artifactType&&n.artifactData?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:e.jsx(Cs,{artifact:n.artifactData,mode:n.artifactType})}),n.reference&&e.jsxs("div",{className:"px-3 py-2 bg-surface-elevated rounded-lg",children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider block mb-1",children:r("detail.artifactDirectory")}),e.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all",children:n.reference})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx("button",{onClick:Kt,className:"flex-1 px-4 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-sm font-medium rounded-lg transition-colors",children:r("detail.openInBuilder")})}),n.summary&&e.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:e.jsx(tt,{content:n.summary,className:"text-fg-secondary text-sm"})})]}):n.reference&&ut(n.reference)?e.jsxs("div",{className:"space-y-4",children:[n.summary&&e.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:e.jsx(tt,{content:n.summary,className:"text-fg-secondary text-sm"})}),e.jsxs("div",{className:"flex flex-col items-center justify-center py-10",children:[e.jsxs("svg",{className:"w-10 h-10 text-fg-muted mb-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),e.jsx("p",{className:"text-xs text-fg-tertiary font-mono mb-4 px-4 text-center break-all select-all",children:n.reference}),e.jsx("button",{onClick:()=>window.open(n.reference,"_blank","noopener,noreferrer"),className:"px-6 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-sm font-medium rounded-lg transition-colors",children:r("detail.openUrl")})]})]}):n.type==="directory"&&n.reference?e.jsxs("div",{className:"space-y-4",children:[n.summary&&e.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:e.jsx(tt,{content:n.summary,className:"text-fg-secondary text-sm"})}),e.jsxs("div",{className:"flex flex-col items-center justify-center py-10",children:[e.jsx("svg",{className:"w-10 h-10 text-fg-muted mb-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})}),e.jsx("p",{className:"text-xs text-fg-tertiary font-mono mb-4 px-4 text-center break-all select-all",children:n.reference}),e.jsx("button",{onClick:()=>{L.files.reveal(n.reference).catch(()=>we("error",r("detail.failedToOpenBrowser")))},className:"px-6 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-sm font-medium rounded-lg transition-colors",children:r("detail.openInFileBrowser")})]})]}):e.jsxs("div",{className:"bg-surface-elevated rounded-xl overflow-hidden",children:[(Ve||n.summary)&&!te&&!H&&!he&&n.reference&&n.type==="file"&&(N==="markdown"||N==="text"||N==="html")&&e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border-subtle bg-surface-secondary/50",children:[e.jsx("button",{onClick:Jt,className:`px-3 py-1 rounded text-xs font-medium transition-colors ${Ke?"text-fg-tertiary hover:text-fg-secondary":"bg-brand-600/20 text-brand-500"}`,children:r("detail.preview")}),e.jsx("button",{onClick:Zt,className:`px-3 py-1 rounded text-xs font-medium transition-colors ${Ke?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:r("detail.edit")}),e.jsx("div",{className:"flex-1"}),Ke&&e.jsx("button",{onClick:_t,disabled:!De||ht,className:"px-3 py-1 rounded text-xs font-medium bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:r(ht?"detail.saving":"detail.save")})]}),e.jsx("div",{className:"p-5",children:te?e.jsxs("div",{className:"animate-pulse space-y-4",children:[e.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-full"}),e.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-5/6"}),e.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-4/6"}),e.jsx("div",{className:"h-32 bg-surface-overlay/40 rounded-lg w-full mt-2"}),e.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-3/4"}),e.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-2/3"})]}):H?e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("img",{src:H.src,alt:H.name,className:"max-w-full max-h-[60vh] rounded-lg object-contain"}),e.jsx("span",{className:"text-xs text-fg-tertiary",children:H.name})]}):R?e.jsxs("div",{className:"flex flex-col gap-3 py-4",children:[R.kind==="audio"?e.jsx("audio",{controls:!0,preload:"metadata",src:R.src,className:"w-full"}):e.jsx("video",{controls:!0,preload:"metadata",src:R.src,className:"w-full max-h-[60vh] rounded-lg bg-black"}),e.jsx("span",{className:"text-xs text-fg-tertiary",children:R.name})]}):Ve?Ke?e.jsx("div",{className:"animate-fadeIn",children:e.jsx("textarea",{ref:bt,value:Ze,onChange:t=>{pt(t.target.value),Oe(!0)},className:"w-full min-h-[120px] p-3 text-sm font-mono bg-surface-primary border border-border-subtle rounded-lg text-fg-secondary focus:outline-none focus:ring-1 focus:ring-brand-500/50 overflow-hidden",style:{resize:"none"},spellCheck:!1})},"edit"):e.jsx("div",{className:"animate-fadeIn",children:e.jsx(Ns,{content:Ve,format:N,className:"text-fg-secondary text-sm",onHtmlSelection:ss,basePath:n?.reference?n.reference.replace(/[/\\][^/\\]+$/,""):void 0})},"preview"):he?e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-fg-secondary",children:r("detail.cannotPreview",{type:n.type})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{L.files.reveal(n.reference).catch(()=>we("error",r("detail.failedToOpen")))},className:"text-xs bg-surface-elevated px-3 py-2 rounded text-brand-500 hover:text-brand-500 hover:underline flex-1 truncate text-left cursor-pointer font-mono",title:r("detail.openInFileBrowser"),children:n.reference}),e.jsx("button",{onClick:()=>{L.files.reveal(n.reference).catch(()=>we("error",r("detail.failedToOpen")))},className:"px-3 py-2 text-xs rounded-lg bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",children:r("common:open")}),e.jsx("button",{onClick:()=>Mt(n.reference),className:`px-3 py-2 text-xs rounded-lg transition-colors shrink-0 ${Le?"bg-green-500/20 text-green-600":"bg-surface-overlay/50 text-fg-secondary hover:bg-surface-overlay"}`,children:r(Le?"common:copied":"common:copy")})]})]}):n.summary?Ke?e.jsx("textarea",{ref:bt,value:Ze,onChange:t=>{pt(t.target.value),Oe(!0)},className:"w-full min-h-[120px] p-3 text-sm font-mono bg-surface-primary border border-border-subtle rounded-lg text-fg-secondary focus:outline-none focus:ring-1 focus:ring-brand-500/50 overflow-hidden",style:{resize:"none"},spellCheck:!1}):e.jsx(tt,{content:n.summary,className:"text-fg-secondary text-sm"}):e.jsx("p",{className:"text-sm text-fg-tertiary italic",children:r("detail.noContent")})})]})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center text-fg-tertiary space-y-3 max-w-xs",children:[e.jsx("div",{className:"w-16 h-16 mx-auto rounded-2xl bg-surface-elevated/60 flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-fg-muted",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})})}),e.jsx("p",{className:"text-sm text-fg-secondary",children:r("detail.selectToView")}),!v&&e.jsx("p",{className:"text-[10px] text-fg-muted",children:r("detail.keyboardHint")})]})})]}),n?.agentId&&!w&&!v&&e.jsx("button",{type:"button",onClick:()=>xe(!0),className:"absolute bottom-6 right-6 z-20 w-12 h-12 rounded-full bg-brand-600 hover:bg-brand-500 text-white shadow-lg shadow-black/20 flex items-center justify-center transition-transform hover:scale-105 animate-fab-in",title:r("chat.openChat"),children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),w&&n?.agentId&&!v&&e.jsx(Ts,{agentId:n.agentId,agents:Se,authUser:c,onClose:()=>{xe(!1),ae([])},contextChips:[{id:`deliverable_ctx_${n.id}`,label:`📦 ${n.title}`,type:"deliverable",content:`${r("chat.currentDeliverable")}: ${n.title} (id: ${n.id})`},...mt],width:400})]}),Xe&&e.jsx("div",{id:"selection-toolbar",className:"fixed z-50 -translate-x-1/2 -translate-y-full bg-surface-elevated border border-border-default rounded-lg shadow-xl overflow-hidden",style:{left:Xe.x,top:Xe.y-8},children:e.jsxs("button",{onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),ts(Xe.text,Xe.htmlMeta)},className:"px-3 py-1.5 text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-1.5 whitespace-nowrap",children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),r("contextMenu.addToConversation")]})}),g&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:()=>i(null),children:e.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 max-w-sm mx-4 shadow-2xl",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/15 flex items-center justify-center shrink-0",children:e.jsxs("svg",{className:"w-5 h-5 text-red-500",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"3 6 5 6 21 6"}),e.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-fg-primary",children:r("detail.confirmRemoveTitle")}),e.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:r("detail.confirmRemoveMessage",{name:g.title})})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>i(null),className:"px-4 py-1.5 text-xs text-fg-secondary hover:text-fg-primary border border-border-default hover:border-gray-600 rounded-lg transition-colors",children:r("common:cancel")}),e.jsx("button",{onClick:()=>{const t=g;i(null),qt(t)},disabled:!!Ae,className:"px-4 py-1.5 text-xs bg-red-600 hover:bg-red-500 text-white rounded-lg transition-colors disabled:opacity-50",children:r("common:remove")})]})]})}),gt&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:()=>ze(null),children:e.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 max-w-sm mx-4 shadow-2xl",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-amber-500/15 flex items-center justify-center shrink-0",children:e.jsx("svg",{className:"w-5 h-5 text-amber-500",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-fg-primary",children:r("detail.unsavedTitle")}),e.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:r("detail.unsavedMessage")})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>ze(null),className:"px-4 py-1.5 text-xs text-fg-secondary hover:text-fg-primary border border-border-default hover:border-gray-600 rounded-lg transition-colors",children:r("common:cancel")}),e.jsx("button",{onClick:()=>{es(),gt.action()},className:"px-4 py-1.5 text-xs text-fg-secondary hover:text-fg-primary border border-border-default hover:border-gray-600 rounded-lg transition-colors",children:r("detail.discard")}),e.jsx("button",{onClick:async()=>{await _t(),gt.action(),ze(null)},className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors",children:r("detail.saveAndLeave")})]})]})})]})}function St({label:c,value:h,current:f,onClick:r}){return e.jsx("button",{onClick:()=>r(f===h?"":h),className:`px-2 py-1 rounded text-xs whitespace-nowrap shrink-0 transition-colors ${f===h?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:bg-surface-overlay"}`,children:c})}function Ht(){return e.jsxs("svg",{className:"animate-spin h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}export{Ds as DeliverablesPage};
@@ -1 +1 @@
1
- import{u as l,a,j as e,M as t,N as n}from"./index-F0uqyKAR.js";function c({authUser:s}){const{t:i}=l("nav"),o=a();return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 h-14",children:[o&&e.jsx(t,{}),e.jsx("h2",{className:"text-base font-bold",children:i("notifications")})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(n,{collapsed:!1,userId:s?.id,embeddedMode:!0})})]})}export{c as NotificationsPage};
1
+ import{u as l,a,j as e,M as t,N as n}from"./index-BVZKeNvh.js";function c({authUser:s}){const{t:i}=l("nav"),o=a();return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 h-14",children:[o&&e.jsx(t,{}),e.jsx("h2",{className:"text-base font-bold",children:i("notifications")})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(n,{collapsed:!1,userId:s?.id,embeddedMode:!0})})]})}export{c as NotificationsPage};
@@ -1 +1 @@
1
- import{u as I,r as i,f as c,j as e,n as d,P as x,A as O}from"./index-F0uqyKAR.js";function D(){const{t:l}=I(["common","home","work"]),[u,y]=i.useState(""),[r,o]=i.useState("all"),[t,m]=i.useState({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]}),[h,b]=i.useState(!1),[w,p]=i.useState(!1),v=i.useRef(null),j=i.useRef(void 0);i.useEffect(()=>{setTimeout(()=>v.current?.focus(),100)},[]);const W=i.useCallback(async s=>{if(!s.trim()){m({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]}),p(!1);return}b(!0),p(!0);const n=s.toLowerCase();try{const[N,C,V,R,L,A]=await Promise.allSettled([c.agents.list(),c.tasks.list({search:s,pageSize:20}),c.requirements.list(),c.projects.list(),c.deliverables.search({q:s,limit:20}),c.teams.list()]),E=N.status==="fulfilled"?N.value.agents.filter(a=>a.name?.toLowerCase().includes(n)||a.role?.toLowerCase().includes(n)):[],M=C.status==="fulfilled"?C.value.tasks:[],H=V.status==="fulfilled"?V.value.requirements.filter(a=>a.title?.toLowerCase().includes(n)||a.description?.toLowerCase().includes(n)):[],T=R.status==="fulfilled"?R.value.projects.filter(a=>a.name?.toLowerCase().includes(n)||a.description?.toLowerCase().includes(n)):[],z=L.status==="fulfilled"?L.value.results:[],S=[];if(A.status==="fulfilled"){const a=await Promise.allSettled(A.value.teams.map(f=>c.workflows.list(f.id)));for(const f of a)if(f.status==="fulfilled")for(const g of f.value.workflows)(g.name.toLowerCase().includes(n)||(g.displayName||"").toLowerCase().includes(n)||g.description?.toLowerCase().includes(n))&&S.push(g)}m({agents:E,tasks:M,requirements:H,projects:T,deliverables:z,workflows:S})}catch{m({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]})}finally{b(!1)}},[]),B=s=>{y(s),j.current&&clearTimeout(j.current),j.current=setTimeout(()=>W(s),400)},q=[{id:"all",label:l("common:all",{defaultValue:"全部"})},{id:"agents",label:l("common:agents",{defaultValue:"智能体"})},{id:"tasks",label:l("common:tasks",{defaultValue:"任务"})},{id:"requirements",label:l("common:requirements",{defaultValue:"需求"})},{id:"projects",label:l("common:projects",{defaultValue:"项目"})},{id:"deliverables",label:l("common:deliverables",{defaultValue:"交付物"})},{id:"workflows",label:l("common:workflows",{defaultValue:"工作流"})}],k=t.agents.length>0||t.tasks.length>0||t.requirements.length>0||t.projects.length>0||t.deliverables.length>0||t.workflows.length>0;return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 px-4 pt-4 pb-2 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>d.navigate(x.HOME),className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors shrink-0",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M19 12H5"}),e.jsx("polyline",{points:"12 19 5 12 12 5"})]})}),e.jsxs("div",{className:"flex-1 relative",children:[e.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-fg-tertiary",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("input",{ref:v,value:u,onChange:s=>B(s.target.value),placeholder:l("common:search"),className:"w-full bg-surface-elevated border border-border-default rounded-xl pl-9 pr-3 py-2.5 text-sm text-fg-primary placeholder:text-fg-tertiary focus:border-brand-500 focus:outline-none transition-colors"}),u&&e.jsx("button",{onClick:()=>{y(""),m({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]}),p(!1),v.current?.focus()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-fg-tertiary hover:text-fg-secondary",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),e.jsx("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:q.map(s=>e.jsx("button",{onClick:()=>o(s.id),className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${r===s.id?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:s.label},s.id))})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-4",children:[h&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:l("common:loading")})}),!h&&w&&!k&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-3",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("p",{className:"text-sm text-fg-tertiary",children:l("common:noResults",{defaultValue:"没有找到相关结果"})})]}),!h&&k&&e.jsxs("div",{className:"space-y-4",children:[(r==="all"||r==="agents")&&t.agents.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:agents",{defaultValue:"智能体"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.agents.slice(0,8):t.agents).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.TEAM,{agentId:s.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx(O,{name:s.name||"Agent",avatarUrl:s.avatarUrl,size:32}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:s.name}),e.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:s.role||s.status})]}),e.jsx(P,{status:s.status})]},s.id))}),r==="all"&&t.agents.length>8&&e.jsxs("button",{onClick:()=>o("agents"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.agents.length,")"]})]}),(r==="all"||r==="tasks")&&t.tasks.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:tasks",{defaultValue:"任务"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.tasks.slice(0,8):t.tasks).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.WORK,{openTask:s.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx(K,{status:s.status}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-fg-primary truncate",children:s.title}),e.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[s.status," · ",s.priority||""]})]})]},s.id))}),r==="all"&&t.tasks.length>8&&e.jsxs("button",{onClick:()=>o("tasks"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.tasks.length,")"]})]}),(r==="all"||r==="requirements")&&t.requirements.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:requirements",{defaultValue:"需求"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.requirements.slice(0,8):t.requirements).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.WORK,{openRequirement:s.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center shrink-0 ${s.status==="approved"?"text-green-500 bg-green-500/15":s.status==="pending"?"text-amber-500 bg-amber-500/15":s.status==="rejected"?"text-red-500 bg-red-500/15":"text-fg-tertiary bg-surface-elevated"}`,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),e.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-fg-primary truncate",children:s.title}),e.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[s.status," · ",s.priority||""]})]})]},s.id))}),r==="all"&&t.requirements.length>8&&e.jsxs("button",{onClick:()=>o("requirements"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.requirements.length,")"]})]}),(r==="all"||r==="projects")&&t.projects.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:projects",{defaultValue:"项目"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.projects.slice(0,8):t.projects).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.WORK,{projectId:s.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-brand-500",children:e.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-fg-primary truncate",children:s.name}),s.description&&e.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:s.description})]})]},s.id))}),r==="all"&&t.projects.length>8&&e.jsxs("button",{onClick:()=>o("projects"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.projects.length,")"]})]}),(r==="all"||r==="deliverables")&&t.deliverables.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:deliverables",{defaultValue:"交付物"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.deliverables.slice(0,8):t.deliverables).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.DELIVERABLES,{openDeliverable:s.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-purple-500/15 flex items-center justify-center shrink-0",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-purple-500",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-fg-primary truncate",children:s.title}),e.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[s.type," · ",s.status]})]})]},s.id))}),r==="all"&&t.deliverables.length>8&&e.jsxs("button",{onClick:()=>o("deliverables"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.deliverables.length,")"]})]}),(r==="all"||r==="workflows")&&t.workflows.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:workflows",{defaultValue:"工作流"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.workflows.slice(0,8):t.workflows).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.WORK,{boardType:"workflows"}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-teal-500/15 flex items-center justify-center shrink-0",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-teal-500",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-fg-primary truncate",children:s.displayName||s.name}),e.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[s.stepCount," steps · v",s.version]})]})]},s.name))}),r==="all"&&t.workflows.length>8&&e.jsxs("button",{onClick:()=>o("workflows"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.workflows.length,")"]})]})]}),!h&&!w&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-3",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("p",{className:"text-sm text-fg-tertiary",children:l("common:search")})]})]})]})}function P({status:l}){const u=l==="active"||l==="idle"?"bg-green-500":l==="working"||l==="busy"?"bg-blue-500":"bg-gray-400";return e.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${u}`})}function K({status:l}){const u=l==="completed"?"text-green-500 bg-green-500/15":l==="in_progress"?"text-blue-500 bg-blue-500/15":l==="pending"?"text-amber-500 bg-amber-500/15":"text-fg-tertiary bg-surface-elevated";return e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center shrink-0 ${u}`,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M9 11l3 3L22 4"}),e.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})})}export{D as SearchPage};
1
+ import{u as I,r as i,f as c,j as e,n as d,P as x,A as O}from"./index-BVZKeNvh.js";function D(){const{t:l}=I(["common","home","work"]),[u,y]=i.useState(""),[r,o]=i.useState("all"),[t,m]=i.useState({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]}),[h,b]=i.useState(!1),[w,p]=i.useState(!1),v=i.useRef(null),j=i.useRef(void 0);i.useEffect(()=>{setTimeout(()=>v.current?.focus(),100)},[]);const W=i.useCallback(async s=>{if(!s.trim()){m({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]}),p(!1);return}b(!0),p(!0);const n=s.toLowerCase();try{const[N,C,V,R,L,A]=await Promise.allSettled([c.agents.list(),c.tasks.list({search:s,pageSize:20}),c.requirements.list(),c.projects.list(),c.deliverables.search({q:s,limit:20}),c.teams.list()]),E=N.status==="fulfilled"?N.value.agents.filter(a=>a.name?.toLowerCase().includes(n)||a.role?.toLowerCase().includes(n)):[],M=C.status==="fulfilled"?C.value.tasks:[],H=V.status==="fulfilled"?V.value.requirements.filter(a=>a.title?.toLowerCase().includes(n)||a.description?.toLowerCase().includes(n)):[],T=R.status==="fulfilled"?R.value.projects.filter(a=>a.name?.toLowerCase().includes(n)||a.description?.toLowerCase().includes(n)):[],z=L.status==="fulfilled"?L.value.results:[],S=[];if(A.status==="fulfilled"){const a=await Promise.allSettled(A.value.teams.map(f=>c.workflows.list(f.id)));for(const f of a)if(f.status==="fulfilled")for(const g of f.value.workflows)(g.name.toLowerCase().includes(n)||(g.displayName||"").toLowerCase().includes(n)||g.description?.toLowerCase().includes(n))&&S.push(g)}m({agents:E,tasks:M,requirements:H,projects:T,deliverables:z,workflows:S})}catch{m({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]})}finally{b(!1)}},[]),B=s=>{y(s),j.current&&clearTimeout(j.current),j.current=setTimeout(()=>W(s),400)},q=[{id:"all",label:l("common:all",{defaultValue:"全部"})},{id:"agents",label:l("common:agents",{defaultValue:"智能体"})},{id:"tasks",label:l("common:tasks",{defaultValue:"任务"})},{id:"requirements",label:l("common:requirements",{defaultValue:"需求"})},{id:"projects",label:l("common:projects",{defaultValue:"项目"})},{id:"deliverables",label:l("common:deliverables",{defaultValue:"交付物"})},{id:"workflows",label:l("common:workflows",{defaultValue:"工作流"})}],k=t.agents.length>0||t.tasks.length>0||t.requirements.length>0||t.projects.length>0||t.deliverables.length>0||t.workflows.length>0;return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 px-4 pt-4 pb-2 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>d.navigate(x.HOME),className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors shrink-0",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M19 12H5"}),e.jsx("polyline",{points:"12 19 5 12 12 5"})]})}),e.jsxs("div",{className:"flex-1 relative",children:[e.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-fg-tertiary",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("input",{ref:v,value:u,onChange:s=>B(s.target.value),placeholder:l("common:search"),className:"w-full bg-surface-elevated border border-border-default rounded-xl pl-9 pr-3 py-2.5 text-sm text-fg-primary placeholder:text-fg-tertiary focus:border-brand-500 focus:outline-none transition-colors"}),u&&e.jsx("button",{onClick:()=>{y(""),m({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]}),p(!1),v.current?.focus()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-fg-tertiary hover:text-fg-secondary",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),e.jsx("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:q.map(s=>e.jsx("button",{onClick:()=>o(s.id),className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${r===s.id?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:s.label},s.id))})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-4",children:[h&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:l("common:loading")})}),!h&&w&&!k&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-3",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("p",{className:"text-sm text-fg-tertiary",children:l("common:noResults",{defaultValue:"没有找到相关结果"})})]}),!h&&k&&e.jsxs("div",{className:"space-y-4",children:[(r==="all"||r==="agents")&&t.agents.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:agents",{defaultValue:"智能体"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.agents.slice(0,8):t.agents).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.TEAM,{agentId:s.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx(O,{name:s.name||"Agent",avatarUrl:s.avatarUrl,size:32}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:s.name}),e.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:s.role||s.status})]}),e.jsx(P,{status:s.status})]},s.id))}),r==="all"&&t.agents.length>8&&e.jsxs("button",{onClick:()=>o("agents"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.agents.length,")"]})]}),(r==="all"||r==="tasks")&&t.tasks.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:tasks",{defaultValue:"任务"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.tasks.slice(0,8):t.tasks).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.WORK,{openTask:s.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx(K,{status:s.status}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-fg-primary truncate",children:s.title}),e.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[s.status," · ",s.priority||""]})]})]},s.id))}),r==="all"&&t.tasks.length>8&&e.jsxs("button",{onClick:()=>o("tasks"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.tasks.length,")"]})]}),(r==="all"||r==="requirements")&&t.requirements.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:requirements",{defaultValue:"需求"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.requirements.slice(0,8):t.requirements).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.WORK,{openRequirement:s.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center shrink-0 ${s.status==="approved"?"text-green-500 bg-green-500/15":s.status==="pending"?"text-amber-500 bg-amber-500/15":s.status==="rejected"?"text-red-500 bg-red-500/15":"text-fg-tertiary bg-surface-elevated"}`,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),e.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-fg-primary truncate",children:s.title}),e.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[s.status," · ",s.priority||""]})]})]},s.id))}),r==="all"&&t.requirements.length>8&&e.jsxs("button",{onClick:()=>o("requirements"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.requirements.length,")"]})]}),(r==="all"||r==="projects")&&t.projects.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:projects",{defaultValue:"项目"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.projects.slice(0,8):t.projects).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.WORK,{projectId:s.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-brand-500",children:e.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-fg-primary truncate",children:s.name}),s.description&&e.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:s.description})]})]},s.id))}),r==="all"&&t.projects.length>8&&e.jsxs("button",{onClick:()=>o("projects"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.projects.length,")"]})]}),(r==="all"||r==="deliverables")&&t.deliverables.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:deliverables",{defaultValue:"交付物"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.deliverables.slice(0,8):t.deliverables).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.DELIVERABLES,{openDeliverable:s.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-purple-500/15 flex items-center justify-center shrink-0",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-purple-500",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-fg-primary truncate",children:s.title}),e.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[s.type," · ",s.status]})]})]},s.id))}),r==="all"&&t.deliverables.length>8&&e.jsxs("button",{onClick:()=>o("deliverables"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.deliverables.length,")"]})]}),(r==="all"||r==="workflows")&&t.workflows.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:workflows",{defaultValue:"工作流"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.workflows.slice(0,8):t.workflows).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.WORK,{boardType:"workflows"}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-teal-500/15 flex items-center justify-center shrink-0",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-teal-500",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-fg-primary truncate",children:s.displayName||s.name}),e.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[s.stepCount," steps · v",s.version]})]})]},s.name))}),r==="all"&&t.workflows.length>8&&e.jsxs("button",{onClick:()=>o("workflows"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.workflows.length,")"]})]})]}),!h&&!w&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-3",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("p",{className:"text-sm text-fg-tertiary",children:l("common:search")})]})]})]})}function P({status:l}){const u=l==="active"||l==="idle"?"bg-green-500":l==="working"||l==="busy"?"bg-blue-500":"bg-gray-400";return e.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${u}`})}function K({status:l}){const u=l==="completed"?"text-green-500 bg-green-500/15":l==="in_progress"?"text-blue-500 bg-blue-500/15":l==="pending"?"text-amber-500 bg-amber-500/15":"text-fg-tertiary bg-surface-elevated";return e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center shrink-0 ${u}`,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M9 11l3 3L22 4"}),e.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})})}export{D as SearchPage};