@markus-global/cli 0.8.2-rc.0 → 0.8.2

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.
@@ -721,4 +721,4 @@ Minimum version required to store current data is: `+H+`.
721
721
  `)){H(!0),U(Ne.toLowerCase()),z(0);return}}}H(!1)},[n,u]),J=g.useCallback(ie=>{const pe=P.current?.selectionStart??e.length,ye=e.slice(0,pe).lastIndexOf("@"),me=e.slice(pe),re=e.slice(0,ye)+me.replace(/^\s/,"");n(re);const Ne={id:`mention_${Date.now()}_${ie.id}`,entityId:ie.id,name:ie.name,entityType:ie.type},Ae=[...W,Ne];ee(Ae),D?.(Ae),H(!1),z(0),requestAnimationFrame(()=>{const _e=ye;P.current?.setSelectionRange(_e,_e),P.current?.focus()})},[e,n,W,D]),Q=g.useCallback(()=>{r(),ee([]),D?.([])},[r,D]),ne=g.useCallback(ie=>{if(R&&F.length>0){const pe=ie.key==="ArrowUp"||ie.ctrlKey&&ie.key==="p",ge=ie.key==="ArrowDown"||ie.ctrlKey&&ie.key==="n",ye=ie.key==="Enter"||ie.key==="Tab",me=ie.key==="Escape";if(pe){ie.preventDefault(),z(re=>(re-1+F.length)%F.length);return}if(ge){ie.preventDefault(),z(re=>(re+1)%F.length);return}if(ye){ie.preventDefault();const re=F[E];re&&J(re);return}if(me){ie.preventDefault(),H(!1);return}}ie.key==="Enter"&&!ie.shiftKey&&(ie.preventDefault(),Q())},[R,F,E,J,Q]),te=m??[],Y=R&&F.length>0&&I&&Dl.createPortal(t.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:I.left,bottom:I.bottom,zIndex:9999},children:(()=>{let ie=0;return K.map(pe=>{const ge=r6[pe.type],ye=L(`page.mentionType.${pe.type}`);return t.jsxs("div",{children:[t.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:[t.jsx("span",{children:ge}),t.jsx("span",{children:ye})]}),pe.items.map(me=>{const re=ie++;return t.jsxs("button",{ref:Ne=>{re===E&&Ne&&Ne.scrollIntoView({block:"nearest"})},onMouseDown:Ne=>{Ne.preventDefault(),J(me)},onMouseEnter:()=>z(re),className:`w-full text-left px-4 py-2 text-sm flex items-center gap-2 transition-colors ${re===E?"bg-brand-500/15 text-brand-500":"text-fg-secondary hover:bg-surface-overlay"}`,children:[me.type==="agent"?t.jsx(lr,{name:me.name,avatarUrl:me.avatarUrl,size:20,bgClass:"bg-brand-500/20 text-brand-500"}):t.jsx("span",{className:"text-xs w-5 h-5 flex items-center justify-center shrink-0",children:ge}),t.jsx("span",{className:"flex-1 min-w-0 truncate",children:me.name}),me.role&&t.jsx("span",{className:"text-[10px] text-fg-tertiary ml-auto shrink-0",children:me.role})]},me.id)})]},pe.type)})})()}),document.body);return t.jsxs("div",{ref:O,className:`relative bg-surface-primary border border-border-default shadow-lg shadow-black/10 rounded-2xl p-3 ${T}`,onDrop:b,onDragOver:x,children:[Y,(d&&d.length>0||W.length>0)&&t.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-2",children:[W.map(ie=>t.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:[t.jsx("span",{className:"shrink-0 text-[10px]",children:r6[ie.entityType]}),t.jsx("span",{className:"truncate font-medium",children:ie.name}),t.jsx("button",{onClick:()=>{const pe=W.filter(ge=>ge.id!==ie.id);ee(pe),D?.(pe)},className:"shrink-0 text-brand-400/60 hover:text-red-400 transition-colors",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"})]})})]},ie.id)),d?.map(ie=>t.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:[t.jsx("span",{className:"truncate",children:ie.label}),ie.onRemove&&t.jsx("button",{onClick:ie.onRemove,className:"shrink-0 text-fg-tertiary hover:text-red-500 transition-colors",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"})]})})]},ie.id))]}),te.length>0&&t.jsxs("div",{className:"flex items-center gap-2 mb-2 overflow-x-auto pb-1",children:[te.map(ie=>t.jsxs("div",{className:"relative group/img shrink-0",children:[TT(ie)?t.jsx("img",{src:ie.dataUrl,alt:ie.name,className:"w-16 h-16 rounded-lg object-cover border border-border-default"}):t.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:ie.name,children:[t.jsx("span",{className:"text-xl leading-none",children:Cie(ie.name,ie.dataUrl)}),t.jsx("span",{className:"text-[9px] text-fg-tertiary truncate max-w-[56px] px-0.5",children:ie.name.split(".").pop()?.toUpperCase()})]}),v&&t.jsx("button",{onClick:()=>v(ie.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:"×"})]},ie.id)),te.length<j&&h&&t.jsx("button",{onClick:h,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:L("page.addMoreFiles"),children:t.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.jsx("path",{d:"M12 5v14M5 12h14"})})})]}),N&&t.jsxs("div",{className:"text-[10px] text-amber-500/80 mb-1.5 flex items-center gap-1",children:[t.jsx("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.jsx("path",{d:"M12 9v4m0 4h.01M12 2L2 22h20L12 2z",strokeLinecap:"round",strokeLinejoin:"round"})}),L("page.visionWarning")]}),k&&t.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:[t.jsxs("div",{className:"flex-1 min-w-0 pl-2 border-l-2 border-brand-500/50",children:[t.jsx("span",{className:"text-[11px] font-medium text-brand-500",children:k.sender}),t.jsx("p",{className:"text-[11px] text-fg-tertiary truncate",children:k.text})]}),C&&t.jsx("button",{onClick:C,className:"text-fg-tertiary hover:text-fg-secondary shrink-0 p-0.5",children:t.jsxs("svg",{width:"14",height:"14",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"})]})})]}),t.jsxs("div",{className:"flex gap-2 items-end",children:[h&&t.jsx("button",{onClick:h,disabled:s,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:L("page.attachFilesTitle"),children:t.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:t.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"})})}),t.jsx("textarea",{ref:P,value:e,onChange:ie=>B(ie.target.value),onKeyDown:ne,onPaste:p,placeholder:a,disabled:s,rows:M?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:M?"36px":"52px",maxHeight:M?"80px":"120px"}}),i&&l&&t.jsx("button",{onClick:l,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:L("page.stopAgent"),children:t.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})})}),t.jsx("button",{onClick:Q,disabled:s||!e.trim()&&te.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:L("common:send")})]})]})}function Aie({agentId:e,sessionId:n,agents:r,authUser:s,onClose:a,contextChips:i,extraMentionItems:l,width:d,className:u=""}){const{t:m}=ft(["team","common"]),h=r.find(pe=>pe.id===e),p=h?.name??m("page.fallbackAgent"),b=s?.name??m("page.fallbackYou"),[x,v]=g.useState([]),[k,C]=g.useState(n??null),[w,N]=g.useState(!0),[j,T]=g.useState(!1),[M,D]=g.useState(""),[L,O]=g.useState([]),[P,R]=g.useState([]),H=g.useRef(null),q=g.useRef(null),U=g.useRef(null),E=g.useRef(!0),z=g.useRef(k);z.current=k;const I=g.useMemo(()=>({today:m("page.dateToday"),yesterday:m("page.dateYesterday")}),[m]),_=g.useMemo(()=>{const pe=m("page.chatGreetings",{returnObjects:!0});return Array.isArray(pe)&&pe.length>0?pe[Math.floor(Math.random()*pe.length)]:""},[m]),W=g.useCallback((pe="auto")=>{q.current?.scrollIntoView({behavior:pe})},[]);g.useEffect(()=>{let pe=!1;return N(!0),v([]),(async()=>{try{let ye=n??null;if(!ye){const{sessions:me}=await ae.sessions.listByAgent(e,10);ye=me.find(Ne=>Ne.isMain)?.id??me[0]?.id??null}if(pe)return;if(C(ye),ye){const me=await ae.sessions.getMessages(ye,50);if(pe)return;const re=me.messages.map(eh).filter(Ne=>Ne.sender!=="agent"||Ne.text||Ne.segments&&Ne.segments.length>0);v(re)}}catch{}pe||N(!1)})(),()=>{pe=!0}},[e,n]);const ee=g.useRef(!0);g.useEffect(()=>{ee.current&&!w&&x.length>0&&requestAnimationFrame(()=>{requestAnimationFrame(()=>W())}),ee.current=w},[w,x.length,W]),g.useEffect(()=>{!w&&E.current&&requestAnimationFrame(()=>W())},[x,W,w]),g.useEffect(()=>un.on("chat:proactive_message",ge=>{const ye=ge.payload,me=ye.agentId??"";if(me!==e)return;const re=ye.targetUserId;if(re&&re!==s?.id)return;const Ne=ye.message??"",Ae=ye.sessionId??"";if(!Ne||Ne==="[cancelled]"||Ne==="[Stream cancelled]"||Ae&&z.current&&Ae!==z.current)return;const{cleaned:_e,priority:$e}=Qy(Ne),we=ye.metadata??{},ke=!!we.notifyUser||_e!==Ne,We={id:`proactive_${Date.now()}`,sender:"agent",text:_e,time:new Date().toLocaleTimeString(),agentName:ye.agentName??p,agentId:me,...ke?{isNotification:!0,notifyPriority:we.priority??$e}:{}};v(Fe=>[...Fe,We])}),[e,p,s?.id]);const[F,K]=g.useState(!1),Z=g.useCallback(()=>{const pe=H.current;if(!pe)return;const ge=pe.scrollHeight-pe.scrollTop-pe.clientHeight<60;E.current=ge,K(!ge)},[]),B=g.useCallback(()=>{U.current?.abort(),U.current=null,T(!1),O([]),ae.agents.cancelProcessing(e).catch(()=>{})},[e]),J=g.useCallback(async()=>{const pe=[];if(P.length>0&&pe.push(P.map(ke=>`@[${ke.name}](${ke.entityType}:${ke.entityId})`).join(" ")),i?.length)for(const ke of i)pe.push(`[${ke.type}: ${ke.label}]
722
722
  ${ke.content}`);M.trim()&&pe.push(M.trim());const ge=pe.join(`
723
723
 
724
- `);if(!ge)return;D(""),R([]),E.current=!0,T(!0),O([]);const ye=`a_${Date.now()}`,me={id:`u_${Date.now()}`,sender:"user",text:ge,time:new Date().toLocaleTimeString()},re=new Date().toISOString();v(ke=>[...ke,me,{id:ye,sender:"agent",text:"",time:new Date().toLocaleTimeString(),rawCreatedAt:re,segments:[]}]);let Ne=!1;const Ae=ke=>{v(We=>{const Fe=[...We],ue=Fe.findIndex(qe=>qe.id===ye);if(ue<0)return We;const ve=Fe[ue].segments??[],be=ve[ve.length-1],V=be?.type==="text"?be.thinking??"":"";let se="",Te="",xe=ke;for(;xe.length>0;)if(Ne){const qe=xe.indexOf("</think>");qe>=0?(se+=xe.slice(0,qe),xe=xe.slice(qe+8),Ne=!1):(se+=xe,xe="")}else{const qe=xe.indexOf("<think>");qe>=0?(Te+=xe.slice(0,qe),xe=xe.slice(qe+7),Ne=!0):(Te+=xe,xe="")}const Ge=V+se||void 0,Se=be?.type==="text"?[...ve.slice(0,-1),{type:"text",content:be.content+Te,thinking:Ge,createdAt:be.createdAt}]:[...ve,{type:"text",content:Te,thinking:Ge,createdAt:new Date().toISOString()}];return Fe[ue]={...Fe[ue],text:Fe[ue].text+Te,segments:Se},Fe})},_e=ke=>{if(ke.type==="session_start"&&ke.sessionId){C(ke.sessionId);return}v(We=>{const Fe=[...We],ue=Fe.findIndex(be=>be.id===ye);if(ue<0)return We;const ve=[...Fe[ue].committedSegments??[]];return ke.type==="thinking_commit"?ve.push({type:"text",content:"",thinking:ke.content,createdAt:ke.createdAt}):ve.push({type:"text",content:ke.content,createdAt:ke.createdAt}),Fe[ue]={...Fe[ue],committedSegments:ve},Fe})},$e=ke=>{ke.phase!=="heartbeat"&&(ke.phase==="start"?(O(We=>[...We,{...ke,phase:"start",ts:Date.now()}]),v(We=>{const Fe=[...We],ue=Fe.findIndex(xe=>xe.id===ye);if(ue<0)return We;const ve=[...Fe[ue].segments??[]],be=`${ke.tool}_${Date.now()}`,V=new Date().toISOString();let se=!1;if(ke.arguments)for(let xe=ve.length-1;xe>=0;xe--){const Ge=ve[xe];if(Ge.type==="tool"&&Ge.tool===ke.tool&&Ge.status==="running"){ve[xe]={...Ge,args:ke.arguments},se=!0;break}}se||ve.push({type:"tool",key:be,tool:ke.tool,status:"running",args:ke.arguments,createdAt:V});const Te=[...Fe[ue].committedSegments??[]];return ke.arguments!==void 0&&Te.push({type:"tool",key:be,tool:ke.tool,status:"running",args:ke.arguments,createdAt:V}),Fe[ue]={...Fe[ue],segments:ve,committedSegments:Te},Fe})):ke.phase==="output"?v(We=>{const Fe=[...We],ue=Fe.findIndex(be=>be.id===ye);if(ue<0)return We;const ve=[...Fe[ue].segments??[]];for(let be=ve.length-1;be>=0;be--){const V=ve[be];if(V.type==="tool"&&V.tool===ke.tool&&V.status==="running"){ve[be]={...V,liveOutput:(V.liveOutput??"")+(ke.output??"")};break}}return Fe[ue]={...Fe[ue],segments:ve},Fe}):ke.phase==="end"&&(O(We=>[...We,{...ke,phase:"end",ts:Date.now()}]),v(We=>{const Fe=[...We],ue=Fe.findIndex(se=>se.id===ye);if(ue<0)return We;const ve=new Date().toISOString(),be=[...Fe[ue].segments??[]];for(let se=be.length-1;se>=0;se--){const Te=be[se];if(Te.type==="tool"&&Te.tool===ke.tool&&Te.status==="running"){be[se]={...Te,status:ke.success===!1?"error":"done",args:ke.arguments,result:ke.result,error:ke.error,durationMs:ke.durationMs,liveOutput:void 0,createdAt:ve};break}}const V=[...Fe[ue].committedSegments??[]];for(let se=V.length-1;se>=0;se--){const Te=V[se];if(Te.type==="tool"&&Te.tool===ke.tool&&Te.status==="running"){V[se]={...Te,status:ke.success===!1?"error":"done",args:ke.arguments,result:ke.result,error:ke.error,durationMs:ke.durationMs,liveOutput:void 0,createdAt:ve};break}}return Fe[ue]={...Fe[ue],segments:be,committedSegments:V},Fe})))},we=new AbortController;U.current=we;try{const ke=await ae.agents.messageStream(e,ge,Ae,$e,we.signal,void 0,k,void 0,void 0,_e);ke.merged&&v(We=>We.filter(Fe=>Fe.id!==ye)),!ke.merged&&ke.segments?.length&&v(We=>{const Fe=[...We],ue=Fe.findIndex(V=>V.id===ye);if(ue<0)return We;const ve=ke.segments.map((V,se)=>V.type==="tool"?{type:"tool",key:`${V.tool}_${se}`,tool:V.tool,status:V.status,args:V.arguments,result:V.result,error:V.error,durationMs:V.durationMs,createdAt:V.createdAt}:{type:"text",content:V.content,thinking:V.thinking,createdAt:V.createdAt});let be=ke.content||Fe[ue].text;return be||(be=ve.filter(V=>V.type==="text").map(V=>V.content).join("")),Fe[ue]={...Fe[ue],text:be,segments:ve,committedSegments:ve},Fe}),!ke.merged&&!ke.segments?.length&&v(We=>{const Fe=[...We],ue=Fe.findIndex(Te=>Te.id===ye);if(ue<0)return We;const ve=Fe[ue],be=ve.committedSegments??[],se=be.filter(Te=>Te.type==="text"&&!!Te.content).map(Te=>Te.content).join("")||ke.content||ve.text;return(be.length>0||se)&&(Fe[ue]={...ve,text:se,segments:be.length>0?be:ve.segments}),Fe}),ke.sessionId&&C(ke.sessionId)}catch(ke){const We=ke?.sessionId;We&&C(We);const Fe=O1(ke,m);v(Fe?ue=>{const ve=[...ue],be=ve.findIndex(V=>V.id===ye);if(be>=0){const V=ve[be].segments??[];ve[be]={...ve[be],text:Fe,isError:!0,segments:[...V,{type:"text",content:Fe}]}}return ve}:ue=>{const ve=[...ue],be=ve.findIndex(V=>V.id===ye);if(be>=0){const V=ve[be];if(!(V.text||V.segments&&V.segments.length>0&&V.segments.some(Te=>Te.type==="text"&&(Te.content||Te.thinking)||Te.type==="tool")))return ue.filter(Te=>Te.id!==ye);ve[be]={...V,isStopped:!0}}return ve})}v(ke=>{const We=[...ke],Fe=We.findIndex(ue=>ue.id===ye);if(Fe>=0){const ue=(We[Fe].segments??[]).map(ve=>ve.type==="tool"&&ve.status==="running"?{...ve,status:"stopped"}:ve);We[Fe]={...We[Fe],segments:ue}}return We}),T(!1),O([]),U.current=null},[M,e,k,m,P,i]),Q=x[x.length-1],ne=j&&Q?.sender==="agent",[te,Y]=g.useState([]);g.useEffect(()=>{let pe=!1;return(async()=>{const ye=[];try{const[me,re,Ne,Ae,_e]=await Promise.all([ae.projects.list().catch(()=>({projects:[]})),ae.requirements.list().catch(()=>({requirements:[]})),ae.tasks.list({pageSize:100}).catch(()=>({tasks:[]})),ae.deliverables.search({limit:100}).catch(()=>({results:[]})),ae.teams.list().catch(()=>({teams:[],ungrouped:[]}))]);for(const $e of me.projects)ye.push({id:$e.id,name:$e.name,type:"project",role:$e.status});for(const $e of re.requirements)ye.push({id:$e.id,name:$e.title,type:"requirement",role:$e.priority});for(const $e of Ne.tasks)ye.push({id:$e.id,name:$e.title,type:"task",role:$e.status});for(const $e of Ae.results)ye.push({id:$e.id,name:$e.title,type:"deliverable",role:$e.type});for(const $e of _e.teams)try{const we=await ae.workflows.list($e.id);for(const ke of we.workflows)ye.push({id:ke.name,name:ke.displayName||ke.name,type:"workflow",role:`v${ke.version}`})}catch{}}catch{}pe||Y(ye)})(),()=>{pe=!0}},[]);const ie=g.useMemo(()=>{const pe=r.map(ge=>({id:ge.id,name:ge.name,role:ge.role,avatarUrl:ge.avatarUrl,type:"agent"}));return[...te,...pe,...l??[]]},[r,te,l]);return t.jsxs("div",{className:`flex flex-col bg-surface-primary border-l border-border-default ${u}`,style:d?{width:d}:{width:400},children:[t.jsxs("div",{className:"h-12 px-4 flex items-center gap-2 shrink-0 border-b border-border-default",children:[t.jsx(lr,{name:p,avatarUrl:h?.avatarUrl,size:24,bgClass:"bg-brand-500/15 text-brand-600",className:"rounded-md"}),t.jsx("span",{className:"text-sm font-medium text-fg-primary truncate flex-1",children:p}),a&&t.jsx("button",{onClick:a,className:"text-fg-tertiary hover:text-fg-secondary transition-colors p-1",children:t.jsxs("svg",{width:"16",height:"16",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"})]})})]}),t.jsxs("div",{ref:H,className:"flex-1 overflow-y-auto px-3 py-3 space-y-3",onScroll:Z,children:[w?t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsxs("svg",{className:"animate-spin h-5 w-5 text-fg-tertiary",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}):x.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3",children:[t.jsx(lr,{name:p,avatarUrl:h?.avatarUrl,size:40,bgClass:"bg-brand-500/20 text-brand-500"}),t.jsx("p",{className:"text-fg-secondary text-sm font-medium",children:_})]}):x.map((pe,ge)=>{const ye=ge>0?x[ge-1]:null,me=Th(pe.rawCreatedAt),re=ye?Th(ye.rawCreatedAt):"",Ne=me&&me!==re,Ae=ge===x.length-1,_e=ne&&Ae,$e=_e;return t.jsxs("div",{children:[Ne&&t.jsxs("div",{className:"flex items-center gap-3 py-1 my-1",children:[t.jsx("div",{className:"flex-1 h-px bg-border-default"}),t.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium uppercase tracking-wider shrink-0",children:d8(pe.rawCreatedAt,I)}),t.jsx("div",{className:"flex-1 h-px bg-border-default"})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("div",{className:"shrink-0 mt-0.5",children:t.jsx(lr,{name:pe.sender==="user"?b:p,avatarUrl:pe.sender==="user"?s?.avatarUrl:h?.avatarUrl,size:24,bgClass:pe.sender==="user"?"bg-brand-600":"bg-brand-500/15 text-brand-600",className:"rounded-md"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-baseline gap-1.5",children:[t.jsx("span",{className:"text-xs font-medium text-fg-primary",children:pe.sender==="user"?b:p}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:c8(pe.time,pe.rawCreatedAt,I)})]}),t.jsx("div",{className:`mt-0.5 ${pe.sender==="agent"?"py-0.5":"bg-surface-secondary rounded-xl px-3 py-2 w-fit max-w-full"} ${pe.isError?"border-b-2 border-red-500/60":""} ${$e&&pe.sender==="agent"?"streaming-bubble":""}`,children:pe.sender==="user"?t.jsx("div",{className:"text-sm text-fg-secondary whitespace-pre-wrap",children:pe.text}):pe.segments&&pe.segments.length>0?t.jsx(m8,{msg:pe,isStreaming:_e,liveActivities:_e?L:[],onViewModeChange:()=>{}}):t.jsx(Gr,{content:pe.text,className:"text-sm text-fg-secondary"})})]})]})]},pe.id)}),t.jsx("div",{ref:q})]}),F&&t.jsx("div",{className:"flex justify-center -mt-10 relative z-10 pointer-events-none",children:t.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:m("page.scrollToBottom"),children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"6 9 12 15 18 9"})})})}),t.jsx("div",{className:"px-3 py-2 shrink-0 border-t border-border-default",children:t.jsx(Tie,{value:M,onChange:D,onSend:J,disabled:!e,placeholder:m("page.placeholder.direct"),sending:j,onStop:B,contextChips:i,mentionItems:ie,onMentionChipsChange:R,compact:!0,className:"shadow-none border-0"})})]})}const e0={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},Eie={active:{color:"text-green-600 bg-green-500/10"},verified:{color:"text-blue-600 bg-blue-500/10"},outdated:{color:"text-red-500 bg-red-500/10"}},Mie=["file","directory"];function Hf(e){return/^https?:\/\//i.test(e)}const uc={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 s6({authUser:e,previewMode:n,previewData:r}={}){const{t:s}=ft(["deliverables","common"]),a=Os(),i=Qd(Oe.DELIVERABLES),l=M0({side:"left",defaultWidth:384,minWidth:280,maxWidth:600,storageKey:"markus_deliverables_list"}),[d,u]=g.useState(!1),m=g.useRef(d);m.current=d,g.useEffect(()=>{if(!a)return;const et=()=>{m.current&&u(!1)};return window.addEventListener("popstate",et),()=>window.removeEventListener("popstate",et)},[a]);const h=100,[p,b]=g.useState(r?.items??[]),[x,v]=g.useState(r?.items?.length??0),[k,C]=g.useState(!1),[w,N]=g.useState(r?.projects??[]),[j,T]=g.useState(r?.agents??[]),[M,D]=g.useState(!r),[L,O]=g.useState(""),[P,R]=g.useState(""),[H,q]=g.useState(""),[U,E]=g.useState(""),[z,I]=g.useState(""),[_,W]=g.useState(""),[ee,F]=g.useState(""),[K,Z]=g.useState("date"),[B,J]=g.useState(()=>r?.initialSelectedId&&r.items?r.items.find(et=>et.id===r.initialSelectedId)??r.items[0]??null:r?.items?.[0]??null),[Q,ne]=g.useState(null),[te,Y]=g.useState(""),[ie,pe]=g.useState(new Set),ge=g.useMemo(()=>[{id:"date"},{id:"project"},{id:"agent"},{id:"type"}],[]),ye=g.useCallback(et=>{Z(et),pe(new Set)},[]),me=zl(ge,K,ye),re=g.useRef(null),[Ne,Ae]=g.useState(null),[_e,$e]=g.useState("markdown"),[we,ke]=g.useState(null),[We,Fe]=g.useState(!1),[ue,ve]=g.useState(!1),[be,V]=g.useState(!1),[se,Te]=g.useState(null),[xe,Ge]=g.useState(""),[Se,qe]=g.useState(new Set),[st,dt]=g.useState(!1),[Me,Ke]=g.useState(!1),[pt,it]=g.useState([]),[Ye,At]=g.useState(null),Ot=g.useRef(void 0),en=(et,Mt)=>{ne({type:et,text:Mt}),setTimeout(()=>ne(null),3e3)},tn=async et=>{await Wy(et)?(V(!0),setTimeout(()=>V(!1),1500)):en("error",s("detail.copyFailed"))},kn=g.useMemo(()=>new Map(j.map(et=>[et.id,et])),[j]),Fn=g.useMemo(()=>new Map(w.map(et=>[et.id,et])),[w]),on=g.useCallback(et=>{if(!et||et==="default")return null;const Mt=Fn.get(et)?.name;return!Mt||Mt==="default"?null:Mt},[Fn]);g.useEffect(()=>{n||(ae.projects.list().then(et=>N(et.projects)).catch(()=>{}),ae.agents.list().then(et=>T(et.agents??[])).catch(()=>{}),ae.system.storage().then(et=>Ge(et.dataDir+"/shared")).catch(()=>{}),ae.deliverables.checkHealth().then(et=>qe(new Set(et.missingFiles))).catch(()=>{}))},[n]),g.useEffect(()=>(Ot.current=setTimeout(()=>R(L),300),()=>clearTimeout(Ot.current)),[L]);const vn=g.useMemo(()=>({q:P||void 0,projectId:U||void 0,agentId:z||void 0,type:H||void 0,status:_||void 0,artifactType:ee||void 0}),[P,U,z,H,_,ee]),xn=g.useCallback(async()=>{D(!0);try{const{results:et,total:Mt}=await ae.deliverables.search({...vn,offset:0,limit:h});b(et),v(Mt)}catch{b([]),v(0)}D(!1)},[vn]),$n=g.useCallback(async()=>{if(!(k||p.length>=x)){C(!0);try{const{results:et,total:Mt}=await ae.deliverables.search({...vn,offset:p.length,limit:h});b(Re=>[...Re,...et]),v(Mt)}catch{}C(!1)}},[vn,p.length,x,k]);g.useEffect(()=>{n||xn()},[xn,n]),g.useEffect(()=>{!n||!r||(b(r.items??[]),v(r.items?.length??0),N(r.projects??[]),T(r.agents??[]),r.initialSelectedId&&J(r.items?.find(et=>et.id===r.initialSelectedId)??r.items?.[0]??null))},[n,r]);const Ln=g.useRef(B);Ln.current=B,g.useEffect(()=>{if(n||!i)return;const et=un.on("deliverable:created",()=>xn()),Mt=un.on("deliverable:updated",tt=>{xn();const _t=tt.payload?.deliverableId;_t&&Ln.current?.id===_t&&ae.deliverables.get(_t).then(Ht=>{Ht.deliverable&&(J(Ht.deliverable),ar(Ht.deliverable))}).catch(()=>{})}),Re=un.on("deliverable:removed",()=>xn());return()=>{et(),Mt(),Re()}},[xn,i,n]);const Hr=g.useRef(null),wr=g.useRef(p);wr.current=p;const gr=g.useCallback(et=>{const Mt=tt=>{J(tt),a&&(u(!0),history.pushState({mobileDetail:Oe.DELIVERABLES},"",window.location.hash))},Re=wr.current.find(tt=>tt.id===et);if(Re){Mt(Re);return}ae.deliverables.get(et).then(tt=>{tt.deliverable&&Mt(tt.deliverable)}).catch(()=>{})},[a]);g.useEffect(()=>{if(n)return;const et=localStorage.getItem("markus_nav_openDeliverable");et&&(localStorage.removeItem("markus_nav_openDeliverable"),wr.current.length>0?gr(et):Hr.current=et);const Mt=Re=>{const tt=Re.detail;tt?.params?.openDeliverable&&(localStorage.removeItem("markus_nav_openDeliverable"),gr(tt.params.openDeliverable))};return window.addEventListener("markus:navigate",Mt),()=>window.removeEventListener("markus:navigate",Mt)},[gr,n]),g.useEffect(()=>{const et=Hr.current;!et||p.length===0||(Hr.current=null,gr(et))},[p,gr]);const Xr=g.useCallback(()=>{const et=re.current;!et||M||k||p.length>=x||et.scrollHeight<=et.clientHeight+100&&$n()},[M,k,p.length,x,$n]);g.useEffect(()=>{const et=re.current;if(!et)return;const Mt=()=>{et.scrollTop+et.clientHeight>=et.scrollHeight-100&&$n()};return et.addEventListener("scroll",Mt,{passive:!0}),()=>et.removeEventListener("scroll",Mt)},[$n]),g.useEffect(()=>{Xr()},[Xr,ie]);const kr=g.useMemo(()=>{const et=new Map;for(const Re of p){let tt,_t;if(K==="project"){const Ht=on(Re.projectId);tt=Ht?Re.projectId??"_none":"_none",_t=Ht??s("noProject")}else if(K==="agent")tt=Re.agentId??"_none",_t=Re.agentId?kn.get(Re.agentId)?.name??Re.agentId:s("common:unknown");else if(K==="type")tt=Re.type,_t=Re.type.charAt(0).toUpperCase()+Re.type.slice(1);else{const Ht=new Date(Re.updatedAt);tt=`${Ht.getFullYear()}-${String(Ht.getMonth()+1).padStart(2,"0")}-${String(Ht.getDate()).padStart(2,"0")}`,_t=tt}et.has(tt)||et.set(tt,{label:_t,items:[]}),et.get(tt).items.push(Re)}const Mt=[...et.entries()];return K==="date"?Mt.sort((Re,tt)=>tt[0].localeCompare(Re[0])):Mt.sort((Re,tt)=>Re[1].label.localeCompare(tt[1].label)),Mt},[p,K,Fn,kn,s]),Qn=async et=>{Y("remove");try{await ae.deliverables.remove(et.id),en("success",s("removed")),J(null),xn()}catch(Mt){en("error",s("common:error",{message:String(Mt)}))}Y("")},jr=()=>{vt.navigate(Oe.BUILDER)},ar=async et=>{if(et.reference&&!Hf(et.reference)){if(et.type==="directory"){ve(!0);return}Fe(!0);try{const Mt=await ae.files.preview(et.reference);Mt.type==="image"&&Mt.mimeType?ke({src:`data:${Mt.mimeType};base64,${Mt.content}`,name:Mt.name}):(Ae(Mt.content),$e(I8({format:et.format,reference:et.reference,content:Mt.content})))}catch{Ae(null),et.type==="file"&&ve(!0)}Fe(!1)}};g.useEffect(()=>{n||(Ae(null),$e("markdown"),ke(null),ve(!1),B&&ar(B))},[B?.id,n]);const An=g.useCallback(et=>{pe(Mt=>{const Re=new Set(Mt);return Re.has(et)?Re.delete(et):Re.add(et),Re})},[]),Rn=g.useCallback(()=>{ie.size===kr.length?pe(new Set):pe(new Set(kr.map(([et])=>et)))},[ie.size,kr]),Sr=et=>{J(et),it([]),a&&(Ke(!1),u(!0),history.pushState({mobileDetail:Oe.DELIVERABLES},"",window.location.hash))};g.useEffect(()=>{Me&&!a&&window.innerWidth<1280&&dt(!0)},[Me,a]);const In=g.useRef(null),zr=g.useCallback(et=>{const Mt=et.length>30?`${et.slice(0,15)}…${et.slice(-12)}`:et,Re=`sel_${Date.now()}`;it(tt=>[...tt,{id:Re,label:Mt,type:"selection",content:et,onRemove:()=>it(_t=>_t.filter(Ht=>Ht.id!==Re))}]),Me||Ke(!0),At(null),window.getSelection()?.removeAllRanges()},[Me]);return g.useEffect(()=>{const et=In.current;if(!et)return;const Mt=()=>{requestAnimationFrame(()=>{const tt=window.getSelection(),_t=tt?.toString().trim();if(!_t||!tt?.rangeCount){At(null);return}const Ht=tt.getRangeAt(0);if(!et.contains(Ht.commonAncestorContainer)){At(null);return}const qt=Ht.getBoundingClientRect();At({x:qt.left+qt.width/2,y:qt.top,text:_t})})},Re=tt=>{const _t=document.getElementById("selection-toolbar");_t&&_t.contains(tt.target)||At(null)};return et.addEventListener("mouseup",Mt),document.addEventListener("mousedown",Re),()=>{et.removeEventListener("mouseup",Mt),document.removeEventListener("mousedown",Re)}},[]),t.jsxs("div",{className:"flex-1 overflow-hidden flex",children:[t.jsxs("div",{className:`${a?"flex-1 min-w-0":"shrink-0"} flex flex-col bg-surface-secondary rounded-xl m-1 mr-0`,style:a?d?{display:"none"}:void 0:st?{display:"none"}:{width:l.width},children:[t.jsxs("div",{className:"p-4 space-y-3",children:[t.jsx("div",{className:"flex items-center justify-between gap-2",children:t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a&&t.jsx(Ac,{}),!a&&t.jsx("button",{onClick:()=>dt(!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:s("sidebar.collapse"),children:t.jsxs("svg",{width:"16",height:"16",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("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),t.jsxs("h2",{className:"text-sm font-semibold text-fg-secondary truncate",children:[s("title"),x>0&&t.jsxs("span",{className:"ml-1.5 text-fg-tertiary font-normal",children:["(",x,")"]})]})]})}),t.jsx("input",{value:L,onChange:et=>O(et.target.value),placeholder:s("searchPlaceholder"),className:"w-full bg-surface-elevated border border-border-default rounded-lg px-3 py-2 text-sm text-fg-primary focus:border-brand-500 focus:outline-none transition-colors"}),xe&&t.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:[t.jsx("span",{className:"truncate font-mono",children:xe}),t.jsx("button",{onClick:()=>{ae.system.openPath(xe)},className:"shrink-0 underline hover:text-fg-secondary transition-colors",children:s("common:open")})]}),t.jsxs("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:[t.jsx(t0,{label:s("filters.allTypes"),value:"",current:H||ee||"",onClick:()=>{q(""),F("")}}),Mie.map(et=>t.jsx(t0,{label:`${e0[et]?.icon??""} ${et}`,value:et,current:H,onClick:Mt=>{q(Mt),F("")}},et)),["agent","team","skill"].map(et=>t.jsx(t0,{label:`${uc[et].icon} ${s(`artifactTypes.${et}`)}`,value:et,current:ee,onClick:Mt=>{F(Mt),q("")}},et))]}),w.length>0&&t.jsxs("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:[t.jsx(t0,{label:s("filters.allProjects"),value:"",current:U,onClick:E}),w.map(et=>t.jsx(t0,{label:et.name,value:et.id,current:U,onClick:E},et.id))]}),t.jsxs("div",{className:"flex gap-1.5 items-center",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:s("filters.group")}),["date","project","agent","type"].map(et=>t.jsx("button",{onClick:()=>{Z(et),pe(new Set)},className:`px-2 py-1 rounded text-xs transition-colors ${K===et?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:bg-surface-overlay"}`,children:s(`groupBy.${et}`)},et)),kr.length>1&&t.jsx("button",{onClick:Rn,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:ie.size===kr.length?s("expandAllTooltip"):s("collapseAllTooltip"),children:ie.size===kr.length?s("expandAll"):s("collapseAll")})]})]}),Q&&t.jsx("div",{className:`mx-4 mt-2 px-3 py-1.5 text-xs rounded-lg ${Q.type==="success"?"bg-green-500/15 text-green-600":"bg-red-500/15 text-red-500"}`,children:Q.text}),t.jsxs("div",{ref:re,className:"flex-1 overflow-y-auto p-2 space-y-1",onTouchStart:a?me.onTouchStart:void 0,onTouchEnd:a?me.onTouchEnd:void 0,children:[M?t.jsx("div",{className:"p-4 space-y-3",children:[1,2,3].map(et=>t.jsxs("div",{className:"animate-pulse space-y-2",children:[t.jsx("div",{className:"h-4 bg-surface-elevated rounded w-3/4"}),t.jsx("div",{className:"h-3 bg-surface-elevated rounded w-1/2"})]},et))}):p.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-6 text-center",children:[t.jsx("svg",{className:"w-12 h-12 text-fg-muted mb-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:t.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"})}),t.jsx("p",{className:"text-sm text-fg-secondary",children:s("empty.title")}),t.jsx("p",{className:"text-xs text-fg-tertiary mt-1 mb-3",children:s("empty.subtitle")}),t.jsx("button",{onClick:()=>vt.navigate(Oe.WORK),className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:s("empty.goToWork")})]}):kr.map(([et,Mt])=>{const Re=ie.has(et);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>An(et),className:"w-full flex items-center gap-1.5 px-2 py-1.5 rounded-md hover:bg-surface-elevated/50 transition-colors group/header",children:[t.jsx("svg",{className:`w-3 h-3 text-fg-tertiary transition-transform duration-200 shrink-0 ${Re?"":"rotate-90"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),t.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider truncate",children:Mt.label}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:["(",Mt.items.length,")"]})]}),!Re&&Mt.items.map(tt=>t.jsx("button",{onClick:()=>Sr(tt),className:`w-full text-left px-3 py-2 rounded-lg transition-colors ${B?.id===tt.id?"bg-brand-600/20 border border-brand-500/30":"hover:bg-surface-elevated/60 border border-transparent"}`,children:t.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[tt.artifactType&&uc[tt.artifactType]?t.jsx("span",{className:`text-[10px] px-1 py-0.5 rounded font-medium shrink-0 ${uc[tt.artifactType].color}`,children:uc[tt.artifactType].icon}):t.jsx("span",{className:`text-[10px] px-1 py-0.5 rounded font-medium uppercase shrink-0 ${e0[tt.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:e0[tt.type]?.icon??tt.type.charAt(0)}),t.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:tt.title}),Se.has(tt.id)&&t.jsx("span",{className:"shrink-0 text-amber-500",title:s("detail.fileMissing"),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("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"}),t.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),t.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}),t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded shrink-0 ${Eie[tt.status]?.color??"bg-surface-elevated text-fg-tertiary"}`,children:s(`common:status.${tt.status}`,{defaultValue:tt.status})})]})},tt.id))]},et)}),k&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-fg-tertiary",children:[t.jsx(a6,{})," ",t.jsx("span",{className:"text-[10px]",children:s("common:loadingMore")})]}),!M&&p.length>0&&t.jsx("div",{className:"text-center text-[10px] text-fg-tertiary py-2",children:p.length<x?s("count.partial",{loaded:p.length,total:x}):s("count.total",{total:x})})]})]}),!a&&t.jsx("div",{className:"w-1.5 shrink-0 cursor-col-resize group relative flex items-center justify-center",onMouseDown:l.onResizeStart,children:t.jsx("div",{className:"w-px h-2/3 border-l border-dashed border-transparent group-hover:border-border-default group-active:border-fg-tertiary transition-colors"})}),(!a||d)&&t.jsxs("div",{className:"flex-1 overflow-hidden min-w-0 flex relative",children:[t.jsxs("div",{ref:In,className:"flex-1 overflow-y-auto min-w-0",children:[st&&!a&&t.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:[t.jsx("button",{onClick:()=>dt(!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:s("sidebar.expand"),children:t.jsxs("svg",{width:"16",height:"16",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("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),t.jsx("span",{className:"text-sm font-medium text-fg-secondary truncate",children:B?.title??s("detail.details")})]}),a&&t.jsxs("div",{className:"sticky top-0 z-10 bg-surface-secondary px-4 py-2.5 flex items-center gap-2",children:[t.jsx("button",{onClick:()=>history.back(),className:"text-fg-secondary hover:text-fg-primary transition-colors p-1 -ml-1",children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"15 18 9 12 15 6"})})}),t.jsx("span",{className:"text-sm font-medium truncate",children:B?.title??s("detail.details")})]}),B?t.jsxs("div",{className:"p-6 space-y-4",children:[!n&&Se.has(B.id)&&t.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:[t.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:[t.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"}),t.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),t.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),t.jsx("span",{children:s("detail.fileMissing")})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsx("h2",{className:"text-xl font-semibold text-fg-primary",children:B.title}),!n&&t.jsx("button",{onClick:()=>Te(B),disabled:!!te,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:s("common:remove"),children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.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"})]})})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("span",{className:`px-2 py-0.5 rounded text-xs font-medium uppercase ${e0[B.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:[e0[B.type]?.icon??""," ",B.type]}),B.artifactType&&uc[B.artifactType]&&t.jsxs("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${uc[B.artifactType].color}`,children:[uc[B.artifactType].icon," ",s("detail.builderWithType",{type:s(`artifactTypes.${B.artifactType}`)})]}),B.tags.length>0&&B.tags.map(et=>t.jsx("span",{className:"px-2 py-0.5 text-xs bg-surface-elevated text-fg-secondary rounded",children:et},et))]}),(B.taskId||B.agentId||on(B.projectId))&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[B.taskId&&t.jsx("button",{onClick:()=>vt.navigate(Oe.WORK,{openTask:B.taskId}),className:"text-xs text-brand-500 hover:underline bg-brand-500/10 px-2 py-0.5 rounded",children:s("links.task",{id:`${B.taskId.slice(0,12)}...`})}),B.agentId&&t.jsx("button",{onClick:()=>vt.navigate(Oe.TEAM,{selectAgent:B.agentId}),className:"text-xs text-blue-600 hover:underline bg-blue-500/10 px-2 py-0.5 rounded",children:s("links.agent",{name:kn.get(B.agentId)?.name??B.agentId.slice(0,12)})}),on(B.projectId)&&t.jsx("button",{onClick:()=>vt.navigate(Oe.WORK,{projectId:B.projectId}),className:"text-xs text-blue-600 hover:underline bg-blue-500/10 px-2 py-0.5 rounded",children:s("links.project",{name:on(B.projectId)})})]}),(B.diffStats||B.testResults)&&t.jsxs("div",{className:"flex gap-3 flex-wrap",children:[B.diffStats&&t.jsxs("div",{className:"bg-surface-elevated rounded-lg px-3 py-2 text-xs flex items-center gap-2",children:[t.jsxs("span",{className:"text-fg-tertiary font-medium",children:[s("diffStats.title"),":"]}),t.jsx("span",{className:"text-fg-secondary",children:s("diffStats.files",{count:B.diffStats.filesChanged})}),t.jsxs("span",{className:"text-green-600",children:["+",B.diffStats.additions]}),t.jsxs("span",{className:"text-red-500",children:["-",B.diffStats.deletions]})]}),B.testResults&&t.jsxs("div",{className:"bg-surface-elevated rounded-lg px-3 py-2 text-xs flex items-center gap-2",children:[t.jsxs("span",{className:"text-fg-tertiary font-medium",children:[s("testResults.title"),":"]}),t.jsx("span",{className:"text-green-600",children:s("testResults.passed",{count:B.testResults.passed})}),t.jsx("span",{className:"text-red-500",children:s("testResults.failed",{count:B.testResults.failed})}),t.jsx("span",{className:"text-fg-secondary",children:s("testResults.skipped",{count:B.testResults.skipped})})]})]}),t.jsxs("div",{className:"flex items-center gap-4 text-[10px] text-fg-tertiary flex-wrap",children:[t.jsxs("span",{children:[s("metadata.created")," ",new Date(B.createdAt).toLocaleDateString()]}),t.jsxs("span",{children:[s("metadata.updated")," ",new Date(B.updatedAt).toLocaleDateString()]}),t.jsx("span",{className:"text-fg-muted select-all",children:B.id.slice(0,12)})]}),B.reference&&!Hf(B.reference)&&B.type==="file"&&t.jsxs("div",{className:"flex items-center gap-2 bg-surface-elevated rounded-lg px-3 py-2",children:[t.jsx("button",{onClick:()=>{ae.files.reveal(B.reference).catch(()=>en("error",s("detail.failedToOpenBrowser")))},className:"text-xs font-mono text-brand-500 hover:text-brand-500 hover:underline truncate flex-1 text-left cursor-pointer",title:s("detail.openInFileBrowser"),children:B.reference}),t.jsx("button",{onClick:()=>{ae.files.reveal(B.reference).catch(()=>en("error",s("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:s("detail.revealInFinder"),children:s("common:open")}),t.jsx("button",{onClick:()=>tn(B.reference),className:`px-2 py-1 text-[10px] rounded transition-colors shrink-0 ${be?"bg-green-500/20 text-green-600":"bg-surface-overlay/50 text-fg-secondary hover:bg-surface-overlay"}`,title:s("detail.copyPath"),children:s(be?"common:copied":"common:copy")})]}),B.reference&&!Hf(B.reference)&&B.type!=="file"&&B.type!=="directory"&&t.jsx("span",{className:"text-xs text-fg-tertiary font-mono break-all",children:B.reference})]}),B.artifactType&&B.artifactData?t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:t.jsx(Nie,{artifact:B.artifactData,mode:B.artifactType})}),B.reference&&t.jsxs("div",{className:"px-3 py-2 bg-surface-elevated rounded-lg",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider block mb-1",children:s("detail.artifactDirectory")}),t.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all",children:B.reference})]}),t.jsx("div",{className:"flex gap-2",children:t.jsx("button",{onClick:jr,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:s("detail.openInBuilder")})}),B.summary&&t.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:t.jsx(Gr,{content:B.summary,className:"text-fg-secondary text-sm"})})]}):B.reference&&Hf(B.reference)?t.jsxs("div",{className:"space-y-4",children:[B.summary&&t.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:t.jsx(Gr,{content:B.summary,className:"text-fg-secondary text-sm"})}),t.jsxs("div",{className:"flex flex-col items-center justify-center py-10",children:[t.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:[t.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),t.jsx("polyline",{points:"15 3 21 3 21 9"}),t.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),t.jsx("p",{className:"text-xs text-fg-tertiary font-mono mb-4 px-4 text-center break-all select-all",children:B.reference}),t.jsx("button",{onClick:()=>window.open(B.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:s("detail.openUrl")})]})]}):B.type==="directory"&&B.reference?t.jsxs("div",{className:"space-y-4",children:[B.summary&&t.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:t.jsx(Gr,{content:B.summary,className:"text-fg-secondary text-sm"})}),t.jsxs("div",{className:"flex flex-col items-center justify-center py-10",children:[t.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:t.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"})}),t.jsx("p",{className:"text-xs text-fg-tertiary font-mono mb-4 px-4 text-center break-all select-all",children:B.reference}),t.jsx("button",{onClick:()=>{ae.files.reveal(B.reference).catch(()=>en("error",s("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:s("detail.openInFileBrowser")})]})]}):t.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:We?t.jsxs("div",{className:"flex items-center gap-2 text-fg-tertiary text-sm",children:[t.jsx(a6,{})," ",s("detail.loadingPreview")]}):we?t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx("img",{src:we.src,alt:we.name,className:"max-w-full max-h-[60vh] rounded-lg object-contain"}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:we.name})]}):Ne?t.jsx(tv,{content:Ne,format:_e,className:"text-fg-secondary text-sm"}):ue?t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"text-sm text-fg-secondary",children:s("detail.cannotPreview",{type:B.type})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:()=>{ae.files.reveal(B.reference).catch(()=>en("error",s("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:s("detail.openInFileBrowser"),children:B.reference}),t.jsx("button",{onClick:()=>{ae.files.reveal(B.reference).catch(()=>en("error",s("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:s("common:open")}),t.jsx("button",{onClick:()=>tn(B.reference),className:`px-3 py-2 text-xs rounded-lg transition-colors shrink-0 ${be?"bg-green-500/20 text-green-600":"bg-surface-overlay/50 text-fg-secondary hover:bg-surface-overlay"}`,children:s(be?"common:copied":"common:copy")})]})]}):B.summary?t.jsx(Gr,{content:B.summary,className:"text-fg-secondary text-sm"}):t.jsx("p",{className:"text-sm text-fg-tertiary italic",children:s("detail.noContent")})})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center h-full",children:t.jsxs("div",{className:"text-center text-fg-tertiary space-y-2",children:[t.jsx("svg",{className:"w-12 h-12 mx-auto text-fg-muted",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:t.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"})}),t.jsx("p",{className:"text-sm",children:s("detail.selectToView")})]})})]}),B?.agentId&&!Me&&!a&&t.jsx("button",{onClick:()=>Ke(!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",title:s("chat.openChat"),children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.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"})})}),Me&&B?.agentId&&!a&&t.jsx(Aie,{agentId:B.agentId,agents:j,authUser:e,onClose:()=>{Ke(!1),it([])},contextChips:[{id:`deliverable_ctx_${B.id}`,label:`📦 ${B.title}`,type:"deliverable",content:`${s("chat.currentDeliverable")}: ${B.title} (id: ${B.id})`},...pt],width:400})]}),Ye&&t.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:Ye.x,top:Ye.y-8},children:t.jsxs("button",{onMouseDown:et=>{et.preventDefault(),et.stopPropagation(),zr(Ye.text)},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:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.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"})}),s("contextMenu.addToConversation")]})}),se&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:()=>Te(null),children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 max-w-sm mx-4 shadow-2xl",onClick:et=>et.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[t.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/15 flex items-center justify-center shrink-0",children:t.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:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.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"})]})}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:s("detail.confirmRemoveTitle")}),t.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:s("detail.confirmRemoveMessage",{name:se.title})})]})]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{onClick:()=>Te(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:s("common:cancel")}),t.jsx("button",{onClick:()=>{const et=se;Te(null),Qn(et)},disabled:!!te,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:s("common:remove")})]})]})})]})}function t0({label:e,value:n,current:r,onClick:s}){return t.jsx("button",{onClick:()=>s(r===n?"":n),className:`px-2 py-1 rounded text-xs whitespace-nowrap shrink-0 transition-colors ${r===n?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:bg-surface-overlay"}`,children:e})}function a6(){return t.jsxs("svg",{className:"animate-spin h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}function Do(e){return e.toLocaleString()}function Cd(e){return e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function Rie(e){return e>=1024*1024*1024?`${(e/(1024*1024*1024)).toFixed(1)} GB`:e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${(e/1024).toFixed(1)} KB`:`${e} B`}function i6({authUser:e}){const{t:n}=ft(["reports","common"]),r=Os(),s=Qd(Oe.REPORTS),[a,i]=g.useState("weekly"),[l,d]=g.useState(null),[u,m]=g.useState(!0),[h,p]=g.useState(""),[b,x]=g.useState(null),[v,k]=g.useState([]),[C,w]=g.useState("totalTokens"),[N,j]=g.useState(!0),[T,M]=g.useState("generate"),[D,L]=g.useState([]),[O,P]=g.useState(null),[R,H]=g.useState([]),[q,U]=g.useState(""),[E,z]=g.useState(""),I=Y=>{z(Y),setTimeout(()=>z(""),3e3)},_=g.useCallback(async Y=>{m(!0),p("");try{const{report:ie}=await ae.reports.generate({period:Y,scope:"org",orgId:"default"});d(ie)}catch(ie){p(String(ie)),d(null)}m(!1)},[]),W=g.useCallback(()=>{ae.usage.summary().then(Y=>x(Y.usage)).catch(()=>{}),ae.usage.agents().then(Y=>k(Y.agents)).catch(()=>{})},[]),ee=g.useCallback(async()=>{try{const{reports:Y}=await ae.reports.list();L(Y)}catch{}},[]),F=g.useCallback(async Y=>{P(Y);try{const{feedback:ie}=await ae.reports.getFeedback(Y.id);H(ie)}catch{H([])}},[]);g.useEffect(()=>{_(a)},[a,_]),g.useEffect(()=>{if(!s)return;W();const Y=setInterval(W,3e4);return()=>clearInterval(Y)},[W,s]),g.useEffect(()=>{T==="history"&&ee()},[T,ee]);const K=g.useMemo(()=>[...v].sort((Y,ie)=>{const pe=Y[C],ge=ie[C];return N?ge-pe:pe-ge}),[v,C,N]),Z=v.reduce((Y,ie)=>Y+ie.estimatedCost,0),B=v.reduce((Y,ie)=>Y+ie.tokensUsedToday,0),J=v.reduce((Y,ie)=>Y+(ie.costToday??0),0),Q=Math.max(1,...v.map(Y=>Y.totalTokens)),ne=Y=>{C===Y?j(!N):(w(Y),j(!0))},te=g.useMemo(()=>({daily:n("period.today"),weekly:n("period.thisWeek"),monthly:n("period.thisMonth")}),[n]);return t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsxs("div",{className:"max-w-5xl mx-auto w-full p-6 space-y-6",children:[t.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-center md:justify-between",children:[t.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[r&&t.jsx(Ac,{}),t.jsx("h1",{className:"text-xl font-semibold text-fg-primary",children:n("title")}),t.jsxs("div",{className:"flex gap-1 bg-surface-elevated rounded-lg p-0.5",children:[t.jsx("button",{onClick:()=>M("generate"),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${T==="generate"?"bg-surface-overlay text-fg-primary shadow-sm":"text-fg-tertiary hover:text-fg-secondary"}`,children:n("tabs.generate")}),t.jsxs("button",{onClick:()=>M("history"),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${T==="history"?"bg-surface-overlay text-fg-primary shadow-sm":"text-fg-tertiary hover:text-fg-secondary"}`,children:[n("tabs.history"),D.length>0?` (${D.length})`:""]})]})]}),t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[E&&t.jsx("span",{className:"px-2.5 py-1 bg-green-500/10 text-green-600 text-xs rounded-lg",children:E}),T==="generate"&&t.jsx("div",{className:"flex gap-1 bg-surface-elevated rounded-lg p-0.5",children:["daily","weekly","monthly"].map(Y=>t.jsx("button",{onClick:()=>i(Y),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${a===Y?"bg-surface-overlay text-fg-primary shadow-sm":"text-fg-tertiary hover:text-fg-secondary"}`,children:n(`period.${Y}`)},Y))})]})]}),T==="history"&&!O&&t.jsx("section",{className:"bg-surface-elevated rounded-xl overflow-hidden",children:D.length===0?t.jsx("div",{className:"p-8 text-center text-fg-tertiary text-sm",children:n("noReportsYet")}):t.jsx("div",{className:"divide-y divide-border-default/50",children:D.map(Y=>t.jsxs("button",{onClick:()=>F(Y),className:"w-full text-left px-5 py-3 flex items-center gap-4 hover:bg-surface-elevated/30 transition-colors",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:n("reportType",{type:Y.type})}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:[new Date(Y.periodStart).toLocaleDateString()," — ",new Date(Y.periodEnd).toLocaleDateString()]})]}),Y.plan&&t.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium shrink-0 ${Y.plan.status==="approved"?"bg-green-500/10 text-green-600":Y.plan.status==="rejected"?"bg-red-500/10 text-red-500":"bg-amber-500/10 text-amber-600"}`,children:Y.plan.status==="pending"?n("upcomingPlan.planPending"):n("upcomingPlan.planStatus",{status:Y.plan.status})}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date(Y.generatedAt).toLocaleDateString()})]},Y.id))})}),T==="history"&&O&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>{P(null),H([])},className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:n("backToList")}),t.jsx("span",{className:"text-sm font-medium text-fg-primary",children:n("reportType",{type:O.type})}),t.jsxs("span",{className:"text-xs text-fg-tertiary",children:[new Date(O.periodStart).toLocaleDateString()," — ",new Date(O.periodEnd).toLocaleDateString()]})]}),O.metrics&&t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:n("taskMetrics.title")}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[t.jsx(Yi,{label:n("taskMetrics.completed"),value:O.metrics.tasksCompleted,color:"text-green-600"}),t.jsx(Yi,{label:n("taskMetrics.inProgress"),value:O.metrics.tasksInProgress,color:"text-brand-500"}),t.jsx(Yi,{label:n("taskMetrics.created"),value:O.metrics.tasksCreated,color:"text-blue-600"}),t.jsx(Yi,{label:n("taskMetrics.blocked"),value:O.metrics.tasksBlocked,color:"text-amber-600"}),t.jsx(Yi,{label:n("taskMetrics.failed"),value:O.metrics.tasksFailed,color:"text-red-500"})]})]}),O.costSummary&&t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:n("costOverview.title")}),t.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:O.costSummary.totalTokens.toLocaleString()}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:n("costOverview.totalTokens")})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:Cd(O.costSummary.totalEstimatedCost)}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:n("costOverview.estimatedCost")})]}),t.jsxs("div",{children:[t.jsxs("div",{className:`text-2xl font-bold ${O.costSummary.trend==="decreasing"?"text-green-600":O.costSummary.trend==="increasing"?"text-red-500":"text-fg-primary"}`,children:[O.costSummary.trend==="decreasing"?"↓":O.costSummary.trend==="increasing"?"↑":"→"," ",O.costSummary.trend]}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:n("costOverview.trend")})]})]}),O.costSummary.byAgent&&O.costSummary.byAgent.length>0&&t.jsx("div",{className:"mt-4 pt-3 border-t border-border-default/50 space-y-1.5",children:O.costSummary.byAgent.map((Y,ie)=>t.jsxs("div",{className:"flex items-center justify-between text-xs",children:[t.jsx("span",{className:"text-fg-secondary",children:Y.agentId}),t.jsx("span",{className:"text-fg-tertiary tabular-nums",children:n("costOverview.byAgentRow",{tokens:Do(Y.tokens),cost:Cd(Y.cost)})})]},ie))})]}),O.taskSummary&&t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5 overflow-hidden",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:n("taskSummary.title")}),t.jsxs("div",{className:"space-y-4 min-w-0",children:[O.taskSummary.completed.length>0&&t.jsx(kd,{title:n("taskSummary.completedCount",{count:O.taskSummary.completed.length}),color:"emerald",items:O.taskSummary.completed.map(Y=>({id:Y.id,label:Y.title,sub:Y.agent}))}),O.taskSummary.inProgress.length>0&&t.jsx(kd,{title:n("taskSummary.inProgressCount",{count:O.taskSummary.inProgress.length}),color:"indigo",items:O.taskSummary.inProgress.map(Y=>({id:Y.id,label:Y.title,sub:Y.agent}))}),O.taskSummary.blocked.length>0&&t.jsx(kd,{title:n("taskSummary.blockedCount",{count:O.taskSummary.blocked.length}),color:"amber",items:O.taskSummary.blocked.map(Y=>({id:Y.id,label:Y.title,sub:Y.reason||Y.agent}))}),O.taskSummary.completed.length===0&&O.taskSummary.inProgress.length===0&&O.taskSummary.blocked.length===0&&t.jsx("p",{className:"text-sm text-fg-tertiary",children:n("taskSummary.noTasksInPeriod")})]})]}),O.highlights&&O.highlights.length>0&&t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-2",children:n("highlights")}),t.jsx("ul",{className:"list-disc list-inside space-y-1 text-sm text-fg-secondary",children:O.highlights.map((Y,ie)=>t.jsx("li",{children:Y},ie))})]}),O.blockers&&O.blockers.length>0&&t.jsxs("section",{className:"bg-surface-secondary border border-amber-500/20 rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-amber-600 mb-2",children:n("blockers")}),t.jsx("ul",{className:"list-disc list-inside space-y-1 text-sm text-fg-secondary",children:O.blockers.map((Y,ie)=>t.jsx("li",{children:Y},ie))})]}),O.plan&&t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("h3",{className:"text-xs font-semibold text-fg-secondary",children:[n("upcomingPlan.title"),t.jsx("span",{className:`ml-2 px-1.5 py-0.5 rounded text-[10px] font-medium ${O.plan.status==="approved"?"bg-green-500/10 text-green-600":O.plan.status==="rejected"?"bg-red-500/10 text-red-500":"bg-amber-500/10 text-amber-600"}`,children:n(`common:status.${O.plan.status}`,{defaultValue:O.plan.status})})]}),O.plan.status==="pending"&&t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:async()=>{try{const{report:Y}=await ae.reports.approvePlan(O.id,{approvedBy:e?.id??"unknown"});P(Y),I(n("upcomingPlan.planApproved")),ee()}catch(Y){I(n("common:error",{message:String(Y)}))}},className:"px-3 py-1.5 text-xs font-medium bg-green-600 text-white rounded-lg hover:bg-green-500 transition-colors",children:n("upcomingPlan.approvePlan")}),t.jsx("button",{onClick:async()=>{const Y=prompt(n("upcomingPlan.rejectionReason"));if(Y)try{const{report:ie}=await ae.reports.rejectPlan(O.id,{rejectedBy:e?.id??"unknown",reason:Y});P(ie),I(n("upcomingPlan.planRejected")),ee()}catch(ie){I(n("common:error",{message:String(ie)}))}},className:"px-3 py-1.5 text-xs font-medium border border-border-default text-fg-secondary rounded-lg hover:bg-surface-overlay transition-colors",children:n("upcomingPlan.rejectPlan")})]})]}),O.plan.items&&O.plan.items.length>0&&t.jsx("div",{className:"space-y-1.5",children:O.plan.items.map((Y,ie)=>t.jsxs("div",{className:"flex items-center gap-2 text-sm text-fg-secondary",children:[t.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${Y.priority==="high"?"bg-red-500/10 text-red-500":Y.priority==="medium"?"bg-amber-500/10 text-amber-600":"bg-gray-500/10 text-fg-tertiary"}`,children:Y.priority}),t.jsx("span",{children:Y.title}),Y.assignee&&t.jsx("span",{className:"text-[10px] text-fg-tertiary ml-auto",children:Y.assignee})]},ie))})]}),!O.metrics&&!O.taskSummary&&!O.costSummary&&t.jsx("section",{className:"bg-surface-elevated rounded-xl p-8 text-center",children:t.jsx("p",{className:"text-sm text-fg-tertiary",children:n("noDetailedMetrics")})}),t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:n("feedback.title",{count:R.length})}),R.length>0&&t.jsx("div",{className:"space-y-2 mb-4",children:R.map(Y=>t.jsxs("div",{className:"p-3 bg-surface-elevated/50 rounded-lg",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary mb-1",children:[t.jsx("span",{className:"font-medium text-fg-secondary",children:Y.authorName}),t.jsx("span",{children:Y.type}),t.jsx("span",{children:new Date(Y.createdAt).toLocaleDateString()})]}),t.jsx("p",{className:"text-xs text-fg-secondary",children:Y.content})]},Y.id))}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{value:q,onChange:Y=>U(Y.target.value),placeholder:n("feedback.placeholder"),className:"flex-1 px-3 py-2 text-xs bg-surface-elevated border border-border-default rounded-lg text-fg-primary placeholder:text-fg-tertiary",onKeyDown:Y=>{Y.key==="Enter"&&q.trim()&&ae.reports.addFeedback(O.id,{author:e?.id??"unknown",type:"comment",content:q.trim()}).then(({feedback:ie})=>{H(pe=>[...pe,ie]),U(""),I(n("feedback.added"))}).catch(ie=>I(n("common:error",{message:String(ie)})))}}),t.jsx("button",{onClick:()=>{q.trim()&&ae.reports.addFeedback(O.id,{author:e?.id??"unknown",type:"comment",content:q.trim()}).then(({feedback:Y})=>{H(ie=>[...ie,Y]),U(""),I(n("feedback.added"))}).catch(Y=>I(n("common:error",{message:String(Y)})))},disabled:!q.trim(),className:"px-3 py-2 text-xs bg-brand-600 text-white rounded-lg hover:bg-brand-500 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:n("common:send")})]})]})]}),T==="generate"&&b&&t.jsxs("div",{className:`grid gap-4 ${b.storageBytes>0?"grid-cols-2 lg:grid-cols-4":"grid-cols-3"}`,children:[t.jsx(Ff,{label:n("usage.llmTokens"),value:Do(b.llmTokens),color:"text-brand-500"}),t.jsx(Ff,{label:n("usage.toolCalls"),value:Do(b.toolCalls),color:"text-blue-600"}),t.jsx(Ff,{label:n("usage.messages"),value:Do(b.messages),color:"text-green-600"}),b.storageBytes>0&&t.jsx(Ff,{label:n("usage.storage"),value:Rie(b.storageBytes),color:"text-amber-600"})]}),T==="generate"&&(u?t.jsx("div",{className:"flex items-center justify-center h-32 text-fg-tertiary text-sm",children:n("common:loading")}):h?t.jsx("div",{className:"flex items-center justify-center h-32 text-red-500 text-sm",children:h}):l?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[te[a]," · ",new Date(l.periodStart).toLocaleDateString()," — ",new Date(l.periodEnd).toLocaleDateString()]}),l.metrics&&t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:n("taskMetrics.title")}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[t.jsx(Yi,{label:n("taskMetrics.completed"),value:l.metrics.tasksCompleted,color:"text-green-600"}),t.jsx(Yi,{label:n("taskMetrics.inProgress"),value:l.metrics.tasksInProgress,color:"text-brand-500"}),t.jsx(Yi,{label:n("taskMetrics.created"),value:l.metrics.tasksCreated,color:"text-blue-600"}),t.jsx(Yi,{label:n("taskMetrics.blocked"),value:l.metrics.tasksBlocked,color:"text-amber-600"}),t.jsx(Yi,{label:n("taskMetrics.failed"),value:l.metrics.tasksFailed,color:"text-red-500"})]})]}),t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:n("costOverview.title")}),t.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:Cd(Z)}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:n("costOverview.estCostAllTime")})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:Do(B)}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:n("costOverview.tokensToday")})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:Cd(J)}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:n("costOverview.costToday")})]})]})]}),l.taskSummary&&t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:n("taskSummary.title")}),t.jsxs("div",{className:"space-y-4",children:[l.taskSummary.completed.length>0&&t.jsx(kd,{title:n("taskSummary.completedCount",{count:l.taskSummary.completed.length}),color:"emerald",items:l.taskSummary.completed.map(Y=>({id:Y.id,label:Y.title,sub:Y.agent}))}),l.taskSummary.inProgress.length>0&&t.jsx(kd,{title:n("taskSummary.inProgressCount",{count:l.taskSummary.inProgress.length}),color:"indigo",items:l.taskSummary.inProgress.map(Y=>({id:Y.id,label:Y.title,sub:Y.agent}))}),l.taskSummary.blocked.length>0&&t.jsx(kd,{title:n("taskSummary.blockedCount",{count:l.taskSummary.blocked.length}),color:"amber",items:l.taskSummary.blocked.map(Y=>({id:Y.id,label:Y.title,sub:Y.reason||Y.agent}))}),l.taskSummary.completed.length===0&&l.taskSummary.inProgress.length===0&&l.taskSummary.blocked.length===0&&t.jsx("p",{className:"text-sm text-fg-tertiary",children:n("taskSummary.noTasksInPeriod")})]})]})]}):null),T==="generate"&&t.jsxs("section",{className:"bg-surface-elevated rounded-xl overflow-hidden",children:[t.jsx("div",{className:"px-5 py-4 border-b border-border-default",children:t.jsx("h3",{className:"text-sm font-semibold text-fg-secondary",children:n("perAgentUsage.title")})}),v.length===0?t.jsx("div",{className:"p-8 text-center text-fg-tertiary text-sm",children:n("perAgentUsage.noData")}):t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-border-default text-xs text-fg-tertiary uppercase tracking-wider",children:[t.jsx("th",{className:"px-4 py-3 text-left font-medium",children:n("perAgentUsage.agent")}),t.jsx(n0,{label:n("perAgentUsage.totalTokens"),col:"totalTokens",current:C,desc:N,onSort:ne}),t.jsx(n0,{label:n("perAgentUsage.today"),col:"tokensUsedToday",current:C,desc:N,onSort:ne}),t.jsx(n0,{label:n("perAgentUsage.requests"),col:"requestCount",current:C,desc:N,onSort:ne}),t.jsx(n0,{label:n("perAgentUsage.toolCalls"),col:"toolCalls",current:C,desc:N,onSort:ne}),t.jsx(n0,{label:n("perAgentUsage.estCost"),col:"estimatedCost",current:C,desc:N,onSort:ne,align:"right"})]})}),t.jsx("tbody",{children:K.map(Y=>t.jsx(Iie,{agent:Y,maxTokens:Q},Y.agentId))}),t.jsx("tfoot",{children:t.jsxs("tr",{className:"border-t border-border-default bg-surface-elevated/30",children:[t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary",children:n("perAgentUsage.totalAgents",{count:v.length})}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:Do(v.reduce((Y,ie)=>Y+ie.totalTokens,0))}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:Do(B)}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:v.reduce((Y,ie)=>Y+ie.requestCount,0)}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:v.reduce((Y,ie)=>Y+ie.toolCalls,0)}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-right text-fg-secondary tabular-nums",children:Cd(Z)})]})})]})})]})]})})}function Yi({label:e,value:n,color:r}){return t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:`text-2xl font-bold ${r}`,children:n}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:e})]})}function kd({title:e,color:n,items:r}){return t.jsxs("div",{className:"min-w-0 overflow-hidden",children:[t.jsx("div",{className:`text-xs font-medium text-${n}-400 mb-1.5`,children:e}),t.jsx("div",{className:"space-y-1.5",children:r.map((s,a)=>t.jsxs("div",{className:`text-sm text-fg-secondary min-w-0 ${s.id?"cursor-pointer hover:text-fg-primary group":""}`,onClick:s.id?()=>vt.navigate(Oe.WORK,{openTask:s.id}):void 0,children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full bg-${n}-500 shrink-0`}),t.jsx("span",{className:`truncate min-w-0 ${s.id?"group-hover:text-brand-500 transition-colors":""}`,children:s.label})]}),s.sub&&s.sub!=="unassigned"&&t.jsx("div",{className:"text-[10px] text-fg-tertiary ml-3.5 mt-0.5 break-all line-clamp-2",children:s.sub})]},s.id??a))})]})}function Ff({label:e,value:n,color:r}){return t.jsxs("div",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsx("div",{className:"text-sm text-fg-secondary mb-2",children:e}),t.jsx("div",{className:`text-2xl font-bold ${r}`,children:n})]})}function n0({label:e,col:n,current:r,desc:s,onSort:a,align:i}){const l=r===n?s?"↓":"↑":"↕",d=r===n?"text-brand-500":"text-fg-muted";return t.jsxs("th",{className:`px-4 py-3 ${i==="right"?"text-right":"text-left"} font-medium cursor-pointer select-none hover:text-fg-secondary`,onClick:()=>a(n),children:[e,t.jsx("span",{className:`ml-1 ${d}`,children:l})]})}function Iie({agent:e,maxTokens:n}){const r=n>0?Math.min(100,e.totalTokens/n*100):0,s=e.status==="working"?"bg-blue-500":e.status==="idle"?"bg-green-500":e.status==="paused"?"bg-amber-500":e.status==="error"?"bg-red-500":"bg-gray-600";return t.jsxs("tr",{className:"border-b border-border-default/50 hover:bg-surface-elevated/30 transition-colors cursor-pointer",onClick:()=>vt.navigate(Oe.TEAM,{selectAgent:e.agentId}),children:[t.jsx("td",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex items-center gap-2.5",children:[t.jsx("div",{className:`w-2 h-2 rounded-full ${s}`}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary hover:text-brand-500 transition-colors",children:e.agentName}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:e.role})]})]})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"flex-1 bg-surface-elevated rounded-full h-1.5 overflow-hidden max-w-[120px]",children:t.jsx("div",{className:"h-full bg-brand-500 rounded-full",style:{width:`${r}%`}})}),t.jsx("span",{className:"text-sm text-fg-secondary tabular-nums",children:Do(e.totalTokens)})]})}),t.jsx("td",{className:"px-4 py-3 text-sm text-fg-secondary tabular-nums",children:Do(e.tokensUsedToday)}),t.jsx("td",{className:"px-4 py-3 text-sm text-fg-secondary tabular-nums",children:e.requestCount}),t.jsx("td",{className:"px-4 py-3 text-sm text-fg-secondary tabular-nums",children:e.toolCalls}),t.jsx("td",{className:"px-4 py-3 text-sm text-right text-fg-secondary tabular-nums",children:Cd(e.estimatedCost)})]})}const qf={urgent:"bg-red-500",high:"bg-amber-500",normal:"bg-blue-500",low:"bg-gray-400"},jd={approval_request:"M9 12l2 2 4-4 M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z",task_completed:"M22 11.08V12a10 10 0 1 1-5.93-9.14 M22 4L12 14.01l-3-3",task_created:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",task_review:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",task_failed:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",requirement_created:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7 M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z",requirement_decision:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",agent_report:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8",direct_message:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",group_message:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2 M9 7a4 4 0 1 0 0-8 4 4 0 0 0 0 8z M23 21v-2a4 4 0 0 0-3-3.87 M16 3.13a4 4 0 0 1 0 7.75",system:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"},o6={approval_request:"text-amber-500",task_completed:"text-green-500",task_failed:"text-red-500",task_created:"text-blue-500",task_review:"text-purple-500",requirement_created:"text-amber-500",requirement_decision:"text-green-500",agent_report:"text-blue-500",direct_message:"text-green-500",group_message:"text-brand-500",system:"text-fg-tertiary"};function Nd(e,n){const r=Date.now()-new Date(e).getTime(),s=Math.floor(r/6e4);if(s<1)return n("common:time.now");if(s<60)return n("common:time.minutesAgo",{count:s});const a=Math.floor(s/60);return a<24?n("common:time.hoursAgo",{count:a}):n("common:time.daysAgo",{count:Math.floor(a/24)})}function Uf(e,n){const r=e.actionType;if(r==="open_chat")return n("team:notifications.actionHints.openChat");if(r==="navigate")return n("team:notifications.actionHints.viewDetails");const s=e.metadata??{};switch(e.type){case"task_completed":case"task_created":case"task_review":case"task_failed":return s.taskId?n("team:notifications.actionHints.viewTask"):null;case"requirement_created":case"requirement_decision":return s.requirementId?n("team:notifications.actionHints.viewRequirement"):null;case"agent_report":return s.agentId?n("team:notifications.actionHints.viewAgent"):null;case"direct_message":return n("team:notifications.actionHints.openChat");case"group_message":return n("team:notifications.actionHints.openChat");case"approval_request":return n("team:notifications.actionHints.viewApproval");default:return s.taskId?n("team:notifications.actionHints.viewTask"):s.requirementId?n("team:notifications.actionHints.viewRequirement"):s.agentId?n("team:notifications.actionHints.viewAgent"):null}}function Die(){try{const e=new AudioContext,n=e.currentTime,r=e.createGain();r.connect(e.destination),r.gain.setValueAtTime(.15,n),r.gain.exponentialRampToValueAtTime(.01,n+.6);const s=e.createOscillator();s.type="sine",s.frequency.setValueAtTime(880,n),s.frequency.setValueAtTime(1174.66,n+.15),s.connect(r),s.start(n),s.stop(n+.6),s.onended=()=>e.close()}catch{}}function AT({collapsed:e,userId:n,embeddedMode:r,onClose:s,sidebarMode:a,isActive:i,label:l,iconPath:d}){const{t:u}=ft(["team","common"]),[m,h]=g.useState(!1),[p,b]=g.useState("approvals"),[x,v]=g.useState([]),[k,C]=g.useState([]),[w,N]=g.useState(null),[j,T]=g.useState(null),[M,D]=g.useState({}),[L,O]=g.useState(0),P=g.useRef(null),R=g.useRef(null),[H,q]=g.useState({top:0,left:0,width:448,maxHeight:576}),U=g.useRef(null),E=g.useRef(!1),[z,I]=g.useState(!0),[_,W]=g.useState(!1),ee=g.useRef(null),F=g.useRef("approvals"),K=30,Z=g.useCallback(async()=>{try{const[V,se]=await Promise.all([ae.notifications.list(n,!1,{limit:K,offset:0}),ae.approvals.list()]);if(v(V.notifications),O(V.unreadCount??V.notifications.filter(Te=>!Te.read).length),I(V.totalCount!=null?V.notifications.length<V.totalCount:V.notifications.length>=K),C(se.approvals),!E.current){const Te=se.approvals.filter(xe=>xe.status==="pending").length;U.current=Te,E.current=!0}}catch{}},[n]),B=g.useCallback(async()=>{if(!(_||!z)){W(!0);try{const V=await ae.notifications.list(n,!1,{limit:K,offset:x.length});V.notifications.length>0&&v(se=>[...se,...V.notifications.filter(Te=>!se.some(xe=>xe.id===Te.id))]),I(V.totalCount!=null?x.length+V.notifications.length<V.totalCount:V.notifications.length>=K)}catch{}W(!1)}},[n,x.length,_,z]),J=g.useCallback(V=>{const se=V.detail;if(!se)return;const{taskId:Te,requirementId:xe}=se;!Te&&!xe||v(Ge=>{const Se=Ge.filter(qe=>!qe.read&&(Te&&qe.metadata?.taskId===Te||xe&&qe.metadata?.requirementId===xe));if(Se.length===0)return Ge;for(const qe of Se)ae.notifications.markRead(qe.id).catch(()=>{});return O(qe=>Math.max(0,qe-Se.length)),Ge.map(qe=>Se.some(st=>st.id===qe.id)?{...qe,read:!0}:qe)})},[]);g.useEffect(()=>{Z();const V=setInterval(Z,6e4),se=()=>Z(),Te=()=>{h(!0),Z()};window.addEventListener("markus:notifications-changed",se),window.addEventListener("markus:mark-read-by-ref",J),window.addEventListener("markus:open-notifications",Te);const xe=un.on("notification:created",()=>Z()),Ge=un.on("approval:created",()=>Z());return()=>{clearInterval(V),window.removeEventListener("markus:notifications-changed",se),window.removeEventListener("markus:mark-read-by-ref",J),window.removeEventListener("markus:open-notifications",Te),xe(),Ge()}},[Z,J]);const Q=g.useCallback(()=>{if(!P.current)return;const V=P.current.getBoundingClientRect(),se=window.innerWidth,Te=window.innerHeight,xe=Math.min(448,se-16),Ge=Math.min(576,Te-16);let Se=V.right+8,qe=V.top;Se+xe>se-8&&(Se=Math.max(8,se-xe-8)),qe+Ge>Te-8&&(qe=Math.max(8,Te-Ge-8)),q({top:qe,left:Se,width:xe,maxHeight:Ge})},[]);g.useLayoutEffect(()=>{m&&Q()},[m,Q]),g.useEffect(()=>{if(m)return window.addEventListener("resize",Q),()=>window.removeEventListener("resize",Q)},[m,Q]),g.useEffect(()=>{if(!m)return;const V=se=>{P.current?.contains(se.target)||R.current?.contains(se.target)||h(!1)};return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[m]),g.useEffect(()=>{if(!m)return;const V=k.some(Te=>Te.status==="pending"),se=x.some(Te=>!Te.read);b(V&&!se?"approvals":!V&&se?"notifications":F.current)},[m]);const ne=new Set(k.filter(V=>V.status==="pending").map(V=>V.id)),te=new Set(k.map(V=>V.id)),Y=x.filter(V=>!(V.type==="approval_request"&&V.metadata?.approvalId&&te.has(V.metadata.approvalId))),ie=x.filter(V=>V.type==="approval_request"&&!V.read&&V.metadata?.approvalId&&ne.has(V.metadata.approvalId)).length,pe=Math.max(0,L-ie),ge=ne.size,ye=pe+ge;g.useEffect(()=>{U.current!==null&&ge>U.current&&Die(),U.current=ge},[ge]);const me=async V=>{await ae.notifications.markRead(V),v(se=>se.map(Te=>Te.id===V?{...Te,read:!0}:Te)),O(se=>Math.max(0,se-1))},re=V=>{const se=V.metadata??{},Te=V.actionType,xe=V.actionTarget;if(Te==="open_chat"&&xe)try{const Ge=typeof xe=="string"?JSON.parse(xe):xe;if(Ge.agentId){const Se={agentId:Ge.agentId};Ge.sessionId&&(Se.sessionId=Ge.sessionId),vt.navigate(Oe.TEAM,Se);return}}catch{}if(Te==="navigate"&&xe)try{const Ge=typeof xe=="string"?JSON.parse(xe):xe;if(Ge.path){if(Ge.path.startsWith("/team")){const Se={},qe=new URLSearchParams(Ge.path.split("?")[1]||"");for(const[st,dt]of qe.entries())Se[st]=dt;vt.navigate(Oe.TEAM,Se);return}if(Ge.path.startsWith("/work")){const Se={},qe=new URLSearchParams(Ge.path.split("?")[1]||"");for(const[st,dt]of qe.entries())Se[st]=dt;vt.navigate(Oe.WORK,Se);return}}}catch{}switch(V.type){case"approval_request":{const Ge=se.approvalId,Se=Ge?k.find(Me=>Me.id===Ge):void 0,qe=Se?.details?.taskId??se.taskId,st=Se?.details?.requirementId??se.requirementId,dt=Se?.details?.agentId??Se?.agentId;qe?vt.navigate(Oe.WORK,{openTask:qe}):st?vt.navigate(Oe.WORK,{openRequirement:st}):dt?vt.navigate(Oe.TEAM,{agentId:dt}):vt.navigate(Oe.WORK);break}case"task_completed":case"task_created":case"task_review":case"task_failed":se.taskId?vt.navigate(Oe.WORK,{openTask:se.taskId}):vt.navigate(Oe.WORK);break;case"requirement_created":case"requirement_decision":se.requirementId?vt.navigate(Oe.WORK,{openRequirement:se.requirementId}):vt.navigate(Oe.WORK);break;case"agent_report":case"system":{if(se.agentId){const Ge={agentId:se.agentId};se.sessionId&&(Ge.sessionId=se.sessionId),vt.navigate(Oe.TEAM,Ge)}else vt.navigate(Oe.TEAM);break}case"direct_message":{const Ge=se.senderId;Ge?vt.navigate(Oe.TEAM,{dm:Ge}):vt.navigate(Oe.TEAM);break}case"group_message":{const Ge=se.channel;Ge?vt.navigate(Oe.TEAM,{channel:Ge}):vt.navigate(Oe.TEAM);break}default:se.taskId?vt.navigate(Oe.WORK,{openTask:se.taskId}):se.requirementId?vt.navigate(Oe.WORK,{openRequirement:se.requirementId}):se.projectId?vt.navigate(Oe.WORK,{projectId:se.projectId}):se.agentId&&vt.navigate(Oe.TEAM,{agentId:se.agentId});break}},Ne=async V=>{V.read||me(V.id);const se=V.metadata??{},Te=se.taskId,xe=se.requirementId;if(Te||xe){const Ge=x.filter(Se=>Se.id!==V.id&&!Se.read&&(Te&&Se.metadata?.taskId===Te||xe&&Se.metadata?.requirementId===xe));for(const Se of Ge)me(Se.id)}re(V)},Ae=async(V,se,Te,xe)=>{N(V);try{const{approval:Ge}=await ae.approvals.respond(V,se,n,Te,xe);C(dt=>dt.map(Me=>Me.id===V?Ge:Me)),T(null),D(dt=>{const Me={...dt};return delete Me[V],Me});const Se=Ge.details?.taskId,qe=Ge.details?.requirementId,st=x.filter(dt=>!dt.read&&(dt.type==="approval_request"&&dt.metadata?.approvalId===V||Se&&dt.metadata?.taskId===Se||qe&&dt.metadata?.requirementId===qe));if(st.length>0){for(const Me of st)ae.notifications.markRead(Me.id).catch(()=>{});const dt=new Set(st.map(Me=>Me.id));v(Me=>Me.map(Ke=>dt.has(Ke.id)?{...Ke,read:!0}:Ke)),O(Me=>Math.max(0,Me-st.length))}Cl("/approvals"),Cl("/notifications"),Cl("/tasks"),Cl("/taskboard"),Cl("/requirements"),window.dispatchEvent(new CustomEvent("markus:data-changed")),window.dispatchEvent(new CustomEvent("markus:notifications-changed")),setTimeout(()=>Z(),800)}catch{}N(null)},_e=async()=>{try{if(!n)return;await ae.notifications.markAllRead(n),v(V=>V.map(se=>({...se,read:!0}))),O(0),Cl("/notifications")}catch{const V=Y.filter(se=>!se.read);await Promise.all(V.map(se=>ae.notifications.markRead(se.id))),v(se=>se.map(Te=>({...Te,read:!0}))),O(0),Cl("/notifications")}},$e=V=>{const se=V.details?.subType;return se==="requirement_resubmit"?u("team:notifications.approvalType.requirementResubmit"):se==="requirement"||V.details?.requirementId?u("team:notifications.approvalType.requirement"):se==="task_review"?u("team:notifications.approvalType.taskReview"):se==="task"||V.details?.taskId?u("team:notifications.approvalType.task"):V.details?.toolName?u("team:notifications.approvalType.toolExecution"):null},we=V=>{const se=[];se.push(V.agentName);const Te=V.details?.taskTitle,xe=V.details?.taskId;Te?se.push(Te):xe&&se.push(`Task ${xe.slice(0,8)}`);const Ge=V.details?.requirementId;return Ge&&!xe&&se.push(`Req ${Ge.slice(0,8)}`),se.join(" · ")},ke=[...k].sort((V,se)=>new Date(se.requestedAt).getTime()-new Date(V.requestedAt).getTime()),We=ke.filter(V=>V.status==="pending"),Fe=ke.filter(V=>V.status!=="pending"),ue=V=>{const se=V.details?.taskId,Te=V.details?.requirementId,xe=V.details?.agentId??V.agentId;se?vt.navigate(Oe.WORK,{openTask:se}):Te?vt.navigate(Oe.WORK,{openRequirement:Te}):xe?vt.navigate(Oe.TEAM,{agentId:xe}):vt.navigate(Oe.WORK)},ve=()=>{h(!1),s?.()},be=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex border-b border-border-default shrink-0",children:[t.jsxs("button",{onClick:()=>{b("approvals"),F.current="approvals"},className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${p==="approvals"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:[u("team:notifications.approvals"),ge>0?` (${ge})`:""]}),t.jsxs("button",{onClick:()=>{b("notifications"),F.current="notifications"},className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${p==="notifications"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:[u("team:notifications.notifications"),pe>0?` (${pe})`:""]}),t.jsx("button",{onClick:ve,className:"px-2 py-2 text-fg-tertiary hover:text-fg-primary transition-colors shrink-0",title:u("common:close"),children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M18 6L6 18"}),t.jsx("path",{d:"M6 6l12 12"})]})})]}),p==="notifications"&&L>0&&t.jsx("div",{className:"flex justify-end px-3 py-1.5 border-b border-border-default/50 shrink-0",children:t.jsx("button",{onClick:_e,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:u("team:notifications.markAllRead")})}),t.jsxs("div",{ref:ee,className:"flex-1 overflow-y-auto",onScroll:V=>{if(p!=="notifications"||!z||_)return;const se=V.currentTarget;se.scrollTop+se.clientHeight>=se.scrollHeight-80&&B()},children:[p==="approvals"&&(k.length===0?t.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:u("team:notifications.noApprovals")}):t.jsxs("div",{className:"divide-y divide-border-default/50",children:[We.map(V=>{const se=V.details?.command,Te=se?V.description.replace(/\s*Command:.*$/,""):V.description;return t.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[t.jsxs("div",{className:"cursor-pointer hover:bg-surface-overlay/50 -mx-3 -mt-3 px-3 pt-3 pb-1 rounded-t-md transition-colors",onClick:()=>ue(V),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-amber-500 mt-0.5 shrink-0",children:t.jsx("path",{d:jd.approval_request})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[$e(V)&&t.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:$e(V)}),t.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:V.title}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Nd(V.requestedAt,u)})]}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:V.agentName})]})]}),t.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:t.jsx(Gr,{content:Te,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),se&&t.jsx("pre",{className:"text-[11px] text-fg-primary bg-surface-overlay border border-border-default rounded-md px-2.5 py-2 overflow-x-auto whitespace-pre-wrap break-all font-mono leading-relaxed mt-2",children:se})]}),(()=>{const xe=V.details?.subType,Ge=xe==="task"||xe==="requirement"||xe==="requirement_resubmit",Se=V.options&&V.options.length>0,qe=(M[V.id]??"").trim();return Se?t.jsxs("div",{className:"space-y-1.5",children:[V.options.map((st,dt)=>t.jsxs("button",{disabled:w===V.id,onClick:()=>Ae(V.id,st.id!=="reject",qe||void 0,st.id),className:`w-full px-3 py-2 text-left text-[11px] font-medium rounded-md disabled:opacity-50 transition-colors flex items-center gap-2 ${st.id==="reject"||st.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:st.description,children:[t.jsx("span",{className:"w-5 h-5 rounded-full bg-white/20 flex items-center justify-center text-[10px] font-bold shrink-0",children:String.fromCharCode(65+dt)}),st.label]},st.id)),t.jsxs("div",{className:"flex gap-1.5 mt-1",children:[t.jsx("input",{type:"text",placeholder:u("team:notifications.freeformPlaceholder"),value:M[V.id]??"",onChange:st=>D(dt=>({...dt,[V.id]:st.target.value})),onKeyDown:st=>{st.key==="Enter"&&(M[V.id]??"").trim()&&Ae(V.id,!0,(M[V.id]??"").trim(),"custom")},className:"flex-1 px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),t.jsx("button",{disabled:w===V.id||!(M[V.id]??"").trim(),onClick:()=>Ae(V.id,!0,(M[V.id]??"").trim(),"custom"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors",children:u("common:send")})]})]}):Ge?t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("button",{disabled:w===V.id,onClick:()=>Ae(V.id,!0,void 0,"approve"),className:"px-3 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M20 6L9 17l-5-5"})}),u("common:approve")]}),t.jsxs("button",{disabled:w===V.id,onClick:()=>Ae(V.id,!1,void 0,"reject"),className:"px-3 py-1.5 text-[11px] font-medium bg-red-600/80 text-white rounded-md hover:bg-red-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M18 6L6 18"}),t.jsx("path",{d:"M6 6l12 12"})]}),u("common:reject")]}),j!==V.id&&t.jsxs("button",{disabled:w===V.id,onClick:()=>T(V.id),className:"px-3 py-1.5 text-[11px] font-medium border border-amber-500/50 text-amber-500 rounded-md hover:bg-amber-500/10 disabled:opacity-50 transition-colors inline-flex items-center gap-1.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("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),u("team:notifications.needsAdjustment")]})]}),j===V.id&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("input",{type:"text",autoFocus:!0,placeholder:u("team:notifications.adjustmentPlaceholder"),value:M[V.id]??"",onChange:st=>D(dt=>({...dt,[V.id]:st.target.value})),onKeyDown:st=>{st.key==="Enter"&&(M[V.id]??"").trim()&&Ae(V.id,!1,(M[V.id]??"").trim(),"needs_adjustment"),st.key==="Escape"&&T(null)},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-amber-500/50"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:w===V.id||!(M[V.id]??"").trim(),onClick:()=>Ae(V.id,!1,(M[V.id]??"").trim(),"needs_adjustment"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-amber-600 text-white rounded-md hover:bg-amber-700 disabled:opacity-50 transition-colors",children:u("team:notifications.confirmAdjustment")}),t.jsx("button",{onClick:()=>T(null),className:"px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay transition-colors",children:u("common:cancel")})]})]})]}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("input",{type:"text",placeholder:u("team:notifications.commentPlaceholder"),value:M[V.id]??"",onChange:st=>D(dt=>({...dt,[V.id]:st.target.value})),onKeyDown:st=>{st.key==="Enter"&&Ae(V.id,!0,qe||void 0,"approve")},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:w===V.id,onClick:()=>Ae(V.id,!0,qe||void 0,"approve"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors",children:u("common:approve")}),t.jsx("button",{disabled:w===V.id,onClick:()=>Ae(V.id,!1,qe||void 0,"reject"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay disabled:opacity-50 transition-colors",children:u("common:reject")})]})]})})()]},V.id)}),Fe.length>0&&t.jsxs(t.Fragment,{children:[We.length>0&&t.jsx("div",{className:"px-3 py-1.5 text-[10px] font-medium text-fg-tertiary uppercase tracking-wider bg-surface-overlay/30",children:u("team:notifications.approvalHistory")}),Fe.slice(0,50).map(V=>t.jsxs("button",{onClick:()=>ue(V),className:"w-full text-left px-3 py-2.5 hover:bg-surface-overlay/50 transition-colors group",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${V.status==="approved"?"bg-green-500":V.status==="cancelled"||V.status==="expired"?"bg-gray-400":"bg-red-500"}`}),$e(V)&&t.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium shrink-0",children:$e(V)}),t.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1 group-hover:text-fg-primary",children:V.title}),t.jsx("span",{className:`text-[10px] font-medium shrink-0 ${V.status==="approved"?"text-green-500":V.status==="cancelled"||V.status==="expired"?"text-fg-muted":"text-red-500"}`,children:u(`common:status.${V.status}`,{defaultValue:V.status})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 pl-3.5",children:[t.jsx("span",{className:"text-[10px] text-fg-muted truncate",children:we(V)}),t.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),t.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Nd(V.respondedAt??V.requestedAt,u)})]}),V.responseComment&&t.jsxs("p",{className:"text-[10px] text-fg-muted mt-0.5 pl-3.5 truncate",children:["“",V.responseComment,"”"]})]},V.id))]})]})),p==="notifications"&&(Y.length===0?t.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:u("team:notifications.noNotifications")}):t.jsxs("div",{className:"divide-y divide-border-default/50",children:[Y.map(V=>{const se=o6[V.type]??"text-fg-tertiary";return t.jsxs("div",{role:"button",tabIndex:0,onClick:()=>Ne(V),onKeyDown:Te=>{(Te.key==="Enter"||Te.key===" ")&&(Te.preventDefault(),Ne(V))},className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors cursor-pointer ${V.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[t.jsx("div",{className:"shrink-0 mt-0.5",children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:se,children:t.jsx("path",{d:jd[V.type]??jd.system})})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[!V.read&&t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${qf[V.priority]??qf.normal}`}),t.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:V.title})]}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:t.jsx(Gr,{content:V.body,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("span",{className:"text-[10px] text-fg-muted",children:Nd(V.createdAt,u)}),Uf(V,u)&&t.jsx("span",{className:`text-[10px] font-medium ${se}`,children:Uf(V,u)})]})]})]},V.id)}),_&&t.jsx("div",{className:"py-3 text-center",children:t.jsxs("svg",{className:"animate-spin h-4 w-4 text-fg-tertiary mx-auto",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})})]}))]})]});if(r){const V=["approvals","notifications"],se=V.indexOf(p),Te=(()=>{let xe=0,Ge=0;return{onTouchStart:Se=>{xe=Se.touches[0].clientX,Ge=Se.touches[0].clientY},onTouchEnd:Se=>{const qe=Se.changedTouches[0].clientX-xe,st=Se.changedTouches[0].clientY-Ge;Math.abs(qe)>60&&Math.abs(qe)>Math.abs(st)*1.5&&(qe<0&&se<V.length-1&&b(V[se+1]),qe>0&&se>0&&b(V[se-1]))}}})();return t.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[t.jsx("div",{className:"flex border-b border-border-default shrink-0",children:V.map(xe=>t.jsx("button",{onClick:()=>b(xe),className:`flex-1 px-3 py-3 text-sm font-medium transition-colors ${p===xe?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary"}`,children:xe==="approvals"?t.jsxs(t.Fragment,{children:[u("team:notifications.approvals"),ge>0?` (${ge})`:""]}):t.jsxs(t.Fragment,{children:[u("team:notifications.notifications"),pe>0?` (${pe})`:""]})},xe))}),p==="notifications"&&L>0&&t.jsx("div",{className:"flex justify-end px-3 py-1.5 border-b border-border-default/50 shrink-0",children:t.jsx("button",{onClick:_e,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:u("team:notifications.markAllRead")})}),t.jsx("div",{className:"flex-1 overflow-hidden relative",...Te,children:t.jsxs("div",{className:"flex h-full transition-transform duration-300 ease-out",style:{transform:`translateX(-${se*100}%)`},children:[t.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:k.length===0?t.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:u("team:notifications.noApprovals")}):t.jsxs("div",{className:"divide-y divide-border-default/50",children:[We.map(xe=>{const Ge=xe.details?.command,Se=Ge?xe.description.replace(/\s*Command:.*$/,""):xe.description;return t.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[t.jsxs("div",{className:"cursor-pointer hover:bg-surface-overlay/50 -mx-3 -mt-3 px-3 pt-3 pb-1 rounded-t-md transition-colors",onClick:()=>ue(xe),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-amber-500 mt-0.5 shrink-0",children:t.jsx("path",{d:jd.approval_request})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[$e(xe)&&t.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:$e(xe)}),t.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:xe.title}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Nd(xe.requestedAt,u)})]}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:xe.agentName})]})]}),t.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:t.jsx(Gr,{content:Se,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),Ge&&t.jsx("pre",{className:"text-[11px] text-fg-primary bg-surface-overlay border border-border-default rounded-md px-2.5 py-2 overflow-x-auto whitespace-pre-wrap break-all font-mono leading-relaxed mt-2",children:Ge})]}),(()=>{const qe=xe.details?.subType,st=qe==="task"||qe==="requirement"||qe==="requirement_resubmit",dt=xe.options&&xe.options.length>0,Me=(M[xe.id]??"").trim();return dt?t.jsxs("div",{className:"space-y-1.5",children:[xe.options.map((Ke,pt)=>t.jsxs("button",{disabled:w===xe.id,onClick:()=>Ae(xe.id,Ke.id!=="reject",Me||void 0,Ke.id),className:`w-full px-3 py-2 text-left text-[11px] font-medium rounded-md disabled:opacity-50 transition-colors flex items-center gap-2 ${Ke.id==="reject"||Ke.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:Ke.description,children:[t.jsx("span",{className:"w-5 h-5 rounded-full bg-white/20 flex items-center justify-center text-[10px] font-bold shrink-0",children:String.fromCharCode(65+pt)}),Ke.label]},Ke.id)),t.jsxs("div",{className:"flex gap-1.5 mt-1",children:[t.jsx("input",{type:"text",placeholder:u("team:notifications.freeformPlaceholder"),value:M[xe.id]??"",onChange:Ke=>D(pt=>({...pt,[xe.id]:Ke.target.value})),onKeyDown:Ke=>{Ke.key==="Enter"&&(M[xe.id]??"").trim()&&Ae(xe.id,!0,(M[xe.id]??"").trim(),"custom")},className:"flex-1 px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),t.jsx("button",{disabled:w===xe.id||!(M[xe.id]??"").trim(),onClick:()=>Ae(xe.id,!0,(M[xe.id]??"").trim(),"custom"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors",children:u("common:send")})]})]}):st?t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("button",{disabled:w===xe.id,onClick:()=>Ae(xe.id,!0,void 0,"approve"),className:"px-3 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M20 6L9 17l-5-5"})}),u("common:approve")]}),t.jsxs("button",{disabled:w===xe.id,onClick:()=>Ae(xe.id,!1,void 0,"reject"),className:"px-3 py-1.5 text-[11px] font-medium bg-red-600/80 text-white rounded-md hover:bg-red-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M18 6L6 18"}),t.jsx("path",{d:"M6 6l12 12"})]}),u("common:reject")]}),j!==xe.id&&t.jsxs("button",{disabled:w===xe.id,onClick:()=>T(xe.id),className:"px-3 py-1.5 text-[11px] font-medium border border-amber-500/50 text-amber-500 rounded-md hover:bg-amber-500/10 disabled:opacity-50 transition-colors inline-flex items-center gap-1.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("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),u("team:notifications.needsAdjustment")]})]}),j===xe.id&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("input",{type:"text",autoFocus:!0,placeholder:u("team:notifications.adjustmentPlaceholder"),value:M[xe.id]??"",onChange:Ke=>D(pt=>({...pt,[xe.id]:Ke.target.value})),onKeyDown:Ke=>{Ke.key==="Enter"&&(M[xe.id]??"").trim()&&Ae(xe.id,!1,(M[xe.id]??"").trim(),"needs_adjustment"),Ke.key==="Escape"&&T(null)},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-amber-500/50"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:w===xe.id||!(M[xe.id]??"").trim(),onClick:()=>Ae(xe.id,!1,(M[xe.id]??"").trim(),"needs_adjustment"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-amber-600 text-white rounded-md hover:bg-amber-700 disabled:opacity-50 transition-colors",children:u("team:notifications.confirmAdjustment")}),t.jsx("button",{onClick:()=>T(null),className:"px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay transition-colors",children:u("common:cancel")})]})]})]}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("input",{type:"text",placeholder:u("team:notifications.commentPlaceholder"),value:M[xe.id]??"",onChange:Ke=>D(pt=>({...pt,[xe.id]:Ke.target.value})),onKeyDown:Ke=>{Ke.key==="Enter"&&Ae(xe.id,!0,Me||void 0,"approve")},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:w===xe.id,onClick:()=>Ae(xe.id,!0,Me||void 0,"approve"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors",children:u("common:approve")}),t.jsx("button",{disabled:w===xe.id,onClick:()=>Ae(xe.id,!1,Me||void 0,"reject"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay disabled:opacity-50 transition-colors",children:u("common:reject")})]})]})})()]},xe.id)}),Fe.length>0&&t.jsxs(t.Fragment,{children:[We.length>0&&t.jsx("div",{className:"px-3 py-1.5 text-[10px] font-medium text-fg-tertiary uppercase tracking-wider bg-surface-overlay/30",children:u("team:notifications.approvalHistory")}),Fe.slice(0,50).map(xe=>t.jsxs("button",{onClick:()=>ue(xe),className:"w-full text-left px-3 py-2.5 hover:bg-surface-overlay/50 transition-colors",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${xe.status==="approved"?"bg-green-500":xe.status==="cancelled"||xe.status==="expired"?"bg-gray-400":"bg-red-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1",children:xe.title}),t.jsx("span",{className:`text-[10px] font-medium shrink-0 ${xe.status==="approved"?"text-green-500":xe.status==="cancelled"||xe.status==="expired"?"text-fg-muted":"text-red-500"}`,children:u(`common:status.${xe.status}`,{defaultValue:xe.status})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 pl-3.5",children:[t.jsx("span",{className:"text-[10px] text-fg-muted truncate",children:we(xe)}),t.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),t.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Nd(xe.respondedAt??xe.requestedAt,u)})]})]},xe.id))]})]})}),t.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:Y.length===0?t.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:u("team:notifications.noNotifications")}):t.jsx("div",{className:"divide-y divide-border-default/50",children:Y.slice(0,50).map(xe=>{const Ge=o6[xe.type]??"text-fg-tertiary";return t.jsxs("button",{onClick:()=>Ne(xe),className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors ${xe.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[t.jsx("div",{className:"shrink-0 mt-0.5",children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:Ge,children:t.jsx("path",{d:jd[xe.type]??jd.system})})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[!xe.read&&t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${qf[xe.priority]??qf.normal}`}),t.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:xe.title})]}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:t.jsx(Gr,{content:xe.body,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("span",{className:"text-[10px] text-fg-muted",children:Nd(xe.createdAt,u)}),Uf(xe,u)&&t.jsx("span",{className:`text-[10px] font-medium ${Ge}`,children:Uf(xe,u)})]})]})]},xe.id)})})})]})})]})}if(a){const V=d||"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9 M13.73 21a2 2 0 0 1-3.46 0";return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:P,onClick:()=>{h(!m),m||Z()},title:e?l||u("team:notifications.bellTitle"):void 0,className:`w-full flex items-center ${e?"flex-col justify-center px-1 py-1.5 gap-0.5":"gap-3 px-3 py-[7px]"} rounded-lg text-[13px] font-medium mb-0.5 transition-colors relative text-fg-primary ${m||i?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[t.jsx("svg",{width:e?16:18,height:e?16:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:t.jsx("path",{d:V})}),e?t.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:l}):t.jsx("span",{className:"truncate",children:l}),ye>0&&t.jsx("span",{className:`absolute ${e?"top-0.5 right-1":"top-1 left-[22px]"} min-w-[16px] h-4 px-1 rounded-full bg-red-500 text-white text-[10px] font-bold flex items-center justify-center leading-none`,children:ye>99?u("common:badgeOverLimit"):ye})]}),m&&Dl.createPortal(t.jsx("div",{ref:R,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:H.top,left:H.left,width:H.width,maxHeight:H.maxHeight},children:be}),document.body)]})}return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:P,onClick:()=>{h(!m),m||Z()},className:`relative flex items-center justify-center rounded-md transition-colors ${e?"w-8 h-8":"w-7 h-7"} ${m?"bg-surface-overlay text-fg-primary":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay"}`,title:u("team:notifications.bellTitle"),children:[t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),t.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),ye>0&&t.jsx("span",{className:"absolute -top-0.5 -right-0.5 min-w-[16px] h-4 px-1 rounded-full bg-red-500 text-white text-[10px] font-bold flex items-center justify-center leading-none",children:ye>99?u("common:badgeOverLimit"):ye})]}),m&&Dl.createPortal(t.jsx("div",{ref:R,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:H.top,left:H.left,width:H.width,maxHeight:H.maxHeight},children:be}),document.body)]})}function Lie({authUser:e}){const{t:n}=ft("nav"),r=Os();return t.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[t.jsxs("div",{className:"flex items-center gap-2 px-4 h-14",children:[r&&t.jsx(Ac,{}),t.jsx("h2",{className:"text-base font-bold",children:n("notifications")})]}),t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(AT,{collapsed:!1,userId:e?.id,embeddedMode:!0})})]})}function Pie(){const{t:e}=ft(["common","home","work"]),[n,r]=g.useState(""),[s,a]=g.useState("all"),[i,l]=g.useState({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]}),[d,u]=g.useState(!1),[m,h]=g.useState(!1),p=g.useRef(null),b=g.useRef(void 0);g.useEffect(()=>{setTimeout(()=>p.current?.focus(),100)},[]);const x=g.useCallback(async w=>{if(!w.trim()){l({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]}),h(!1);return}u(!0),h(!0);const N=w.toLowerCase();try{const[j,T,M,D,L,O]=await Promise.allSettled([ae.agents.list(),ae.tasks.list({search:w,pageSize:20}),ae.requirements.list(),ae.projects.list(),ae.deliverables.search({q:w,limit:20}),ae.teams.list()]),P=j.status==="fulfilled"?j.value.agents.filter(z=>z.name?.toLowerCase().includes(N)||z.role?.toLowerCase().includes(N)):[],R=T.status==="fulfilled"?T.value.tasks:[],H=M.status==="fulfilled"?M.value.requirements.filter(z=>z.title?.toLowerCase().includes(N)||z.description?.toLowerCase().includes(N)):[],q=D.status==="fulfilled"?D.value.projects.filter(z=>z.name?.toLowerCase().includes(N)||z.description?.toLowerCase().includes(N)):[],U=L.status==="fulfilled"?L.value.results:[],E=[];if(O.status==="fulfilled"){const z=await Promise.allSettled(O.value.teams.map(I=>ae.workflows.list(I.id)));for(const I of z)if(I.status==="fulfilled")for(const _ of I.value.workflows)(_.name.toLowerCase().includes(N)||(_.displayName||"").toLowerCase().includes(N)||_.description?.toLowerCase().includes(N))&&E.push(_)}l({agents:P,tasks:R,requirements:H,projects:q,deliverables:U,workflows:E})}catch{l({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]})}finally{u(!1)}},[]),v=w=>{r(w),b.current&&clearTimeout(b.current),b.current=setTimeout(()=>x(w),400)},k=[{id:"all",label:e("common:all",{defaultValue:"全部"})},{id:"agents",label:e("common:agents",{defaultValue:"智能体"})},{id:"tasks",label:e("common:tasks",{defaultValue:"任务"})},{id:"requirements",label:e("common:requirements",{defaultValue:"需求"})},{id:"projects",label:e("common:projects",{defaultValue:"项目"})},{id:"deliverables",label:e("common:deliverables",{defaultValue:"交付物"})},{id:"workflows",label:e("common:workflows",{defaultValue:"工作流"})}],C=i.agents.length>0||i.tasks.length>0||i.requirements.length>0||i.projects.length>0||i.deliverables.length>0||i.workflows.length>0;return t.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[t.jsxs("div",{className:"shrink-0 px-4 pt-4 pb-2 space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:()=>vt.navigate(Oe.HOME),className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors shrink-0",children:t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M19 12H5"}),t.jsx("polyline",{points:"12 19 5 12 12 5"})]})}),t.jsxs("div",{className:"flex-1 relative",children:[t.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:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),t.jsx("input",{ref:p,value:n,onChange:w=>v(w.target.value),placeholder:e("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"}),n&&t.jsx("button",{onClick:()=>{r(""),l({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]}),h(!1),p.current?.focus()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-fg-tertiary hover:text-fg-secondary",children:t.jsxs("svg",{width:"14",height:"14",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"})]})})]})]}),t.jsx("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:k.map(w=>t.jsx("button",{onClick:()=>a(w.id),className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${s===w.id?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:w.label},w.id))})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-4",children:[d&&t.jsx("div",{className:"flex items-center justify-center py-12",children:t.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:e("common:loading")})}),!d&&m&&!C&&t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[t.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:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),t.jsx("p",{className:"text-sm text-fg-tertiary",children:e("common:noResults",{defaultValue:"没有找到相关结果"})})]}),!d&&C&&t.jsxs("div",{className:"space-y-4",children:[(s==="all"||s==="agents")&&i.agents.length>0&&t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:e("common:agents",{defaultValue:"智能体"})}),t.jsx("div",{className:"space-y-1",children:(s==="all"?i.agents.slice(0,8):i.agents).map(w=>t.jsxs("button",{onClick:()=>vt.navigate(Oe.TEAM,{agentId:w.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:[t.jsx(lr,{name:w.name||"Agent",avatarUrl:w.avatarUrl,size:32}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:w.name}),t.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:w.role||w.status})]}),t.jsx(Oie,{status:w.status})]},w.id))}),s==="all"&&i.agents.length>8&&t.jsxs("button",{onClick:()=>a("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:[e("common:showAll",{defaultValue:"查看全部"})," (",i.agents.length,")"]})]}),(s==="all"||s==="tasks")&&i.tasks.length>0&&t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:e("common:tasks",{defaultValue:"任务"})}),t.jsx("div",{className:"space-y-1",children:(s==="all"?i.tasks.slice(0,8):i.tasks).map(w=>t.jsxs("button",{onClick:()=>vt.navigate(Oe.WORK,{openTask:w.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:[t.jsx(_ie,{status:w.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:w.title}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[w.status," · ",w.priority||""]})]})]},w.id))}),s==="all"&&i.tasks.length>8&&t.jsxs("button",{onClick:()=>a("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:[e("common:showAll",{defaultValue:"查看全部"})," (",i.tasks.length,")"]})]}),(s==="all"||s==="requirements")&&i.requirements.length>0&&t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:e("common:requirements",{defaultValue:"需求"})}),t.jsx("div",{className:"space-y-1",children:(s==="all"?i.requirements.slice(0,8):i.requirements).map(w=>t.jsxs("button",{onClick:()=>vt.navigate(Oe.WORK,{openRequirement:w.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:[t.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center shrink-0 ${w.status==="approved"?"text-green-500 bg-green-500/15":w.status==="pending"?"text-amber-500 bg-amber-500/15":w.status==="rejected"?"text-red-500 bg-red-500/15":"text-fg-tertiary bg-surface-elevated"}`,children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),t.jsx("polyline",{points:"14 2 14 8 20 8"}),t.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),t.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:w.title}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[w.status," · ",w.priority||""]})]})]},w.id))}),s==="all"&&i.requirements.length>8&&t.jsxs("button",{onClick:()=>a("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:[e("common:showAll",{defaultValue:"查看全部"})," (",i.requirements.length,")"]})]}),(s==="all"||s==="projects")&&i.projects.length>0&&t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:e("common:projects",{defaultValue:"项目"})}),t.jsx("div",{className:"space-y-1",children:(s==="all"?i.projects.slice(0,8):i.projects).map(w=>t.jsxs("button",{onClick:()=>vt.navigate(Oe.WORK,{projectId:w.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:[t.jsx("div",{className:"w-8 h-8 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-brand-500",children:t.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"})})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:w.name}),w.description&&t.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:w.description})]})]},w.id))}),s==="all"&&i.projects.length>8&&t.jsxs("button",{onClick:()=>a("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:[e("common:showAll",{defaultValue:"查看全部"})," (",i.projects.length,")"]})]}),(s==="all"||s==="deliverables")&&i.deliverables.length>0&&t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:e("common:deliverables",{defaultValue:"交付物"})}),t.jsx("div",{className:"space-y-1",children:(s==="all"?i.deliverables.slice(0,8):i.deliverables).map(w=>t.jsxs("button",{onClick:()=>vt.navigate(Oe.DELIVERABLES,{openDeliverable:w.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:[t.jsx("div",{className:"w-8 h-8 rounded-lg bg-purple-500/15 flex items-center justify-center shrink-0",children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-purple-500",children:[t.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),t.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:w.title}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[w.type," · ",w.status]})]})]},w.id))}),s==="all"&&i.deliverables.length>8&&t.jsxs("button",{onClick:()=>a("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:[e("common:showAll",{defaultValue:"查看全部"})," (",i.deliverables.length,")"]})]}),(s==="all"||s==="workflows")&&i.workflows.length>0&&t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:e("common:workflows",{defaultValue:"工作流"})}),t.jsx("div",{className:"space-y-1",children:(s==="all"?i.workflows.slice(0,8):i.workflows).map(w=>t.jsxs("button",{onClick:()=>vt.navigate(Oe.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:[t.jsx("div",{className:"w-8 h-8 rounded-lg bg-teal-500/15 flex items-center justify-center shrink-0",children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-teal-500",children:[t.jsx("circle",{cx:"12",cy:"12",r:"3"}),t.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"})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:w.displayName||w.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[w.stepCount," steps · v",w.version]})]})]},w.name))}),s==="all"&&i.workflows.length>8&&t.jsxs("button",{onClick:()=>a("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:[e("common:showAll",{defaultValue:"查看全部"})," (",i.workflows.length,")"]})]})]}),!d&&!m&&t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[t.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:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),t.jsx("p",{className:"text-sm text-fg-tertiary",children:e("common:search")})]})]})]})}function Oie({status:e}){const n=e==="active"||e==="idle"?"bg-green-500":e==="working"||e==="busy"?"bg-blue-500":e==="paused"?"bg-amber-500":"bg-gray-400";return t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${n}`})}function _ie({status:e}){const n=e==="completed"?"text-green-500 bg-green-500/15":e==="in_progress"?"text-blue-500 bg-blue-500/15":e==="pending"?"text-amber-500 bg-amber-500/15":"text-fg-tertiary bg-surface-elevated";return t.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center shrink-0 ${n}`,children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("path",{d:"M9 11l3 3L22 4"}),t.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})})}function l6({d:e,size:n=18}){return t.jsx("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:t.jsx("path",{d:e})})}function zie({currentPage:e,onNavigate:n,authUser:r,collapsed:s,onToggleCollapse:a}){const{t:i}=ft(["nav","common"]);return t.jsxs("aside",{className:"h-dvh bg-surface-secondary flex flex-col shrink-0 overflow-hidden",children:[t.jsx("div",{className:`flex items-center ${s?"px-2 py-3.5 justify-center":"px-4 h-14 justify-between"}`,children:t.jsxs("button",{onClick:a,title:i(s?"sidebar.expandSidebar":"sidebar.collapseSidebar"),className:"flex items-center gap-2.5 min-w-0 group",children:[t.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-8 h-8 rounded-lg shrink-0"}),!s&&t.jsx("span",{className:"text-[15px] font-bold tracking-tight text-fg-primary whitespace-nowrap",children:"Markus"})]})}),t.jsx("nav",{className:`${s?"p-1":"px-3 py-2"} flex-1 overflow-y-auto scrollbar-thin`,children:M$.map((l,d)=>{const u=R$.filter(h=>h.section===l.key&&h.id!==Oe.SETTINGS);if(u.length===0)return null;const m=i(`sections.${l.key}`);return t.jsx("div",{children:t.jsxs("div",{className:d>0?"mt-3":"",children:[!s&&m&&t.jsx("div",{className:"px-3 py-1.5 mb-1 text-[10px] font-semibold text-fg-muted uppercase tracking-[0.1em]",children:m}),s&&d>0&&t.jsx("div",{className:"my-3"}),u.map(h=>{if(h.id===Oe.NOTIFICATIONS)return t.jsx(AT,{sidebarMode:!0,collapsed:s,userId:r?.id,label:i(h.id),iconPath:Gf[h.id],isActive:e===h.id},h.id);const p=e===h.id;return t.jsxs("button",{onClick:()=>n(h.id),title:s?i(h.id):void 0,className:`w-full flex items-center ${s?"flex-col justify-center px-1 py-1.5 gap-0.5":"gap-3 px-3 py-[7px]"} rounded-lg text-[13px] font-medium mb-0.5 transition-colors text-fg-primary ${p?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[t.jsx(l6,{d:Gf[h.id]??"",size:s?16:18}),s?t.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:i(h.id)}):t.jsx("span",{className:"truncate",children:i(h.id)})]},h.id)})]})},l.key)})}),t.jsx("div",{className:`shrink-0 ${s?"p-1":"px-3 pb-2"}`,children:t.jsxs("button",{onClick:()=>n(Oe.SETTINGS),title:s?i(Oe.SETTINGS):void 0,className:`w-full flex items-center ${s?"flex-col justify-center px-1 py-1.5 gap-0.5":"gap-3 px-3 py-[7px]"} rounded-lg text-[13px] font-medium transition-colors text-fg-secondary hover:bg-surface-overlay/60`,children:[t.jsx(l6,{d:Gf[Oe.SETTINGS],size:s?16:18}),s?t.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:i(Oe.SETTINGS)}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"truncate",children:i(Oe.SETTINGS)}),t.jsxs("span",{className:"ml-auto text-[10px] text-fg-muted",children:["v","0.8.2-rc.0"]})]})]})})]})}function $ie({currentPage:e,onNavigate:n,userId:r}){const{t:s}=ft("nav"),[a,i]=g.useState(0),{counts:l}=l8({enabled:!0}),d=g.useMemo(()=>{let m=0;for(const h of Object.values(l))m+=h;return m},[l]),u=g.useCallback(async()=>{try{const m=await ae.notifications.list(r,!1);i(m.unreadCount??m.notifications.filter(h=>!h.read).length)}catch{}},[r]);return g.useEffect(()=>{u();const m=setInterval(u,15e3),h=()=>u();return window.addEventListener("markus:notifications-changed",h),()=>{clearInterval(m),window.removeEventListener("markus:notifications-changed",h)}},[u]),t.jsx("nav",{className:"fixed bottom-0 left-0 right-0 z-50 bg-surface-secondary flex items-stretch h-14 safe-area-bottom",children:I$.map(m=>{const h=m.group.includes(e),p=m.id===Oe.NOTIFICATIONS,b=m.id===Oe.TEAM;return t.jsxs("button",{onClick:()=>n(m.id),className:`flex-1 flex flex-col items-center justify-center gap-0.5 transition-colors ${h?"text-fg-primary":"text-fg-tertiary active:text-fg-secondary"}`,children:[t.jsxs("div",{className:"relative",children:[t.jsx("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:h?2:1.75,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:t.jsx("path",{d:Gf[m.id]})}),p&&a>0&&t.jsx("span",{className:"absolute -top-1.5 -right-2 min-w-[16px] h-4 px-1 flex items-center justify-center bg-red-500 text-white text-[9px] font-bold rounded-full leading-none",children:a>99?"99+":a}),b&&d>0&&t.jsx("span",{className:"absolute -top-1.5 -right-2 min-w-[16px] h-4 px-1 flex items-center justify-center bg-red-500 text-white text-[9px] font-bold rounded-full leading-none",children:d>99?"99+":d})]}),t.jsx("span",{className:`text-[10px] leading-tight ${h?"font-semibold":""}`,children:s(m.id)})]},m.id)})})}const ET=["builder","agents","teams","skills"];function Bie(){const e=localStorage.getItem("markus_nav_storeTab");return e&&(localStorage.removeItem("markus_nav_storeTab"),ET.includes(e))?e:"builder"}function Hie({authUser:e}){const{t:n}=ft(["nav","common"]),r=g.useMemo(()=>[{id:"builder",label:n("nav:builder")},{id:"agents",label:n("nav:tabs.agents")},{id:"teams",label:n("nav:tabs.teams")},{id:"skills",label:n("nav:tabs.skills")}],[n]),[s,a]=g.useState(Bie),i=zl(r,s,a);return g.useEffect(()=>{const l=d=>{const u=d.detail;u.params?.storeTab&&ET.includes(u.params.storeTab)&&a(u.params.storeTab)};return window.addEventListener("markus:navigate",l),()=>window.removeEventListener("markus:navigate",l)},[]),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:i.onTouchStart,onTouchEnd:i.onTouchEnd,children:[t.jsxs("div",{className:"flex items-center shrink-0 overflow-x-auto scrollbar-hide",children:[t.jsx(Ac,{className:"ml-2"}),r.map(l=>t.jsx("button",{onClick:()=>a(l.id),className:`flex-1 min-w-0 px-3 py-2.5 text-xs font-medium text-center whitespace-nowrap transition-colors border-b-2 ${s===l.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:l.label},l.id))]}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s==="builder"&&t.jsx(E8,{}),s==="agents"&&t.jsx(j8,{authUser:e}),s==="teams"&&t.jsx(C8,{}),s==="skills"&&t.jsx(T8,{})]})]})}const c6="usageType",Gb="profile";function Fie({onComplete:e,theme:n,onThemeChange:r,skipProfile:s}){const{t:a}=ft(["onboarding","common"]),[i,l]=g.useState(0),[d,u]=g.useState(""),[m,h]=g.useState(""),[p,b]=g.useState(""),[x,v]=g.useState(""),[k,C]=g.useState(!1),[w,N]=g.useState(""),[j,T]=g.useState(!1),[M,D]=g.useState(null);g.useEffect(()=>{ae.auth.me().then(({user:ge})=>{ge.name&&u(ge.name),ge.email&&h(ge.email),ge.avatarUrl&&D(ge.avatarUrl);const ye=ge.name||ge.email?.split("@")[0]||"";ye&&R(a("usageType.defaultOrgName",{name:ye}))}).catch(()=>{}),ae.hubOrgs.invitations().then(ge=>{ge.invitations?.length>0&&I(ge.invitations)}).catch(()=>{})},[]);const[L,O]=g.useState(null),[P,R]=g.useState(""),[H,q]=g.useState(!1),[U,E]=g.useState(!1),[z,I]=g.useState([]),[_,W]=g.useState(null),[ee,F]=g.useState(null),[K,Z]=g.useState(!0),B=async()=>{if(N(""),!d.trim()){N(a("profile.errors.nameRequired"));return}if(!m.trim()){N(a("profile.errors.emailRequired"));return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(m.trim())){N(a("profile.errors.emailInvalid"));return}if(p&&p.length<6){N(a("profile.errors.passwordTooShort"));return}if(p&&p!==x){N(a("profile.errors.passwordMismatch"));return}C(!0);try{await ae.auth.updateProfile(d.trim(),m.trim()),p&&await ae.auth.changePassword("",p),T(!0)}catch{N(a("profile.errors.saveFailed"))}finally{C(!1)}},J=[{value:"system",label:a("theme.system"),icon:"💻",desc:a("theme.systemDesc")},{value:"light",label:a("theme.light"),icon:"☀️",desc:a("theme.lightDesc")},{value:"dark",label:a("theme.dark"),icon:"🌊",desc:a("theme.darkDesc")},{value:"cyberpunk",label:a("theme.cyberpunk"),icon:"🔮",desc:a("theme.cyberpunkDesc")},{value:"mono",label:a("theme.mono"),icon:"⬛",desc:a("theme.monoDesc")}],Q=[{id:"welcome",title:a("welcome.title"),subtitle:a("welcome.subtitle"),content:t.jsx("p",{className:"text-fg-secondary text-sm leading-relaxed",children:t.jsx(N6,{i18nKey:"welcome.description",ns:"onboarding",components:{strong:t.jsx("strong",{className:"text-fg-primary"})}})})},{id:c6,title:a("usageType.title",{defaultValue:"How will you use Markus?"}),subtitle:a("usageType.subtitle",{defaultValue:"This helps us tailor your experience."}),content:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("button",{onClick:()=>{O("personal"),E(!0)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${L==="personal"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[t.jsx("span",{className:"text-2xl",children:"👤"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:a("usageType.personal",{defaultValue:"Personal"})}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:a("usageType.personalDesc",{defaultValue:"Individual use with your own AI agents."})})]})]}),t.jsxs("button",{onClick:()=>{O("organization"),E(!1)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${L==="organization"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[t.jsx("span",{className:"text-2xl",children:"🏢"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:a("usageType.organization",{defaultValue:"Team & Enterprise"})}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:a("usageType.organizationDesc",{defaultValue:"For teams sharing licenses and collaborating."})})]})]})]}),L==="organization"&&t.jsxs("div",{className:"space-y-4 mt-4",children:[z.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"text-xs text-fg-tertiary font-medium",children:a("usageType.pendingInvitations")}),z.map(ge=>t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 rounded-xl border border-amber-500/20 bg-amber-500/5",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:ge.orgName}),t.jsx("div",{className:"text-[11px] text-fg-tertiary",children:a("usageType.invitedBy",{name:ge.invitedBy})})]}),t.jsx("button",{onClick:async()=>{W(ge.orgId);try{await ae.hubOrgs.acceptInvitation(ge.orgId),F(ge.orgId),E(!0)}catch{}finally{W(null)}},disabled:_===ge.orgId||ee===ge.orgId,className:"px-3 py-1.5 text-xs rounded-lg bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white transition-colors",children:ee===ge.orgId?a("usageType.accepted"):_===ge.orgId?a("usageType.accepting"):a("usageType.acceptAndJoin")})]},ge.orgId)),t.jsx("div",{className:"text-[11px] text-fg-tertiary text-center pt-1",children:a("usageType.orCreateNew")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:a("usageType.orgNameLabel")}),t.jsx("input",{type:"text",value:P,onChange:ge=>{R(ge.target.value),E(!1)},placeholder:a("usageType.orgNamePlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),t.jsx("button",{onClick:async()=>{if(P.trim()){q(!0);try{const ye=(await ae.hubOrgs.mine()).orgs?.[0];ye?.id&&await ae.hubOrgs.update(ye.id,{name:P.trim()}),E(!0)}catch{}finally{q(!1)}}},disabled:H||!P.trim()||U,className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-xl transition-colors",children:a(H?"common:saving":U?"usageType.orgNameSaved":"usageType.setOrgName")})]})]})},{id:Gb,title:a("profile.title"),subtitle:a("profile.subtitle"),content:j?t.jsxs("div",{className:"flex items-center gap-3 bg-green-500/10 border border-green-500/30 rounded-xl p-4",children:[t.jsx("span",{className:"text-green-600 text-lg",children:"✓"}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-green-600",children:a("profile.saved")}),t.jsxs("div",{className:"text-xs text-fg-secondary mt-0.5",children:[d," · ",m]})]})]}):t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"flex justify-center",children:t.jsx(D6,{currentUrl:M,name:d,size:64,targetType:"user"})}),t.jsxs("div",{className:"space-y-1",children:[t.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[a("profile.nameLabel")," ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"text",value:d,onChange:ge=>u(ge.target.value),placeholder:a("profile.namePlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",autoFocus:!0})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[a("profile.emailLabel")," ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"email",value:m,onChange:ge=>h(ge.target.value),placeholder:a("profile.emailPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:a("profile.newPasswordLabel")}),t.jsx("input",{type:"password",value:p,onChange:ge=>b(ge.target.value),placeholder:a("profile.newPasswordPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),p&&t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:a("profile.confirmPasswordLabel")}),t.jsx("input",{type:"password",value:x,onChange:ge=>v(ge.target.value),placeholder:a("profile.confirmPasswordPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),w&&t.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:w}),t.jsx("button",{onClick:()=>{B()},disabled:k||!d.trim()||!m.trim(),className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-xl transition-colors",children:a(k?"common:saving":"profile.saveProfile")})]})},{id:"theme",title:a("theme.title"),subtitle:a("theme.subtitle"),content:t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"grid grid-cols-3 gap-3",children:J.map(ge=>t.jsxs("button",{onClick:()=>r(ge.value),className:`flex flex-col items-center gap-2 rounded-xl border-2 p-5 transition-all ${n===ge.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[t.jsx("span",{className:"text-2xl",children:ge.icon}),t.jsx("span",{className:"text-sm font-medium text-fg-primary",children:ge.label}),t.jsx("span",{className:"text-[11px] text-fg-tertiary leading-tight text-center",children:ge.desc})]},ge.value))}),t.jsxs("label",{className:"flex items-center gap-2.5 p-3 bg-surface-elevated/30 rounded-lg cursor-pointer group",children:[t.jsx("input",{type:"checkbox",checked:K,onChange:ge=>Z(ge.target.checked),className:"accent-brand-500 shrink-0"}),t.jsx("span",{className:"text-[11px] text-fg-tertiary",children:a("done.telemetry")})]})]})}],ne=s?Q.filter(ge=>ge.id!==Gb):Q,te=ne.findIndex(ge=>ge.id===c6),Y=ne.findIndex(ge=>ge.id===Gb),ie=()=>{i===te&&te>=0&&!L||i===te&&L==="organization"&&!U||i===Y&&Y>=0&&!j||(i<ne.length-1?l(i+1):(fetch("/api/settings/telemetry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:K})}).catch(()=>{}),e()))},pe=ne[i];return t.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4",children:t.jsx("div",{className:"w-full max-w-lg",children:t.jsxs("div",{className:"bg-surface-elevated rounded-2xl p-8",children:[t.jsx("div",{className:"flex gap-1.5 mb-8",children:ne.map((ge,ye)=>t.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${ye<=i?"bg-brand-500":"bg-surface-elevated"}`},ye))}),t.jsx("h2",{className:"text-2xl font-bold text-fg-primary",children:pe.title}),t.jsx("p",{className:"text-sm text-fg-secondary mt-1 mb-6",children:pe.subtitle}),pe.content,t.jsxs("div",{className:"flex justify-between mt-8",children:[i>0?t.jsx("button",{onClick:()=>l(i-1),className:"px-4 py-2 text-sm text-fg-secondary hover:text-fg-primary transition-colors",children:a("common:back")}):t.jsx("button",{onClick:e,className:"px-4 py-2 text-sm text-fg-tertiary hover:text-fg-secondary transition-colors",children:a("common:skip")}),t.jsxs("div",{className:"flex items-center gap-3",children:[te>=0&&i===te&&!L&&t.jsx("button",{onClick:()=>{O("personal"),E(!0),l(i+1)},className:"px-4 py-2 text-sm text-fg-tertiary hover:text-fg-secondary transition-colors",children:a("common:skip")}),Y>=0&&i===Y&&!j&&t.jsx("button",{onClick:()=>l(i+1),className:"px-4 py-2 text-sm text-fg-tertiary hover:text-fg-secondary transition-colors",children:a("common:skip")}),t.jsx("button",{onClick:ie,disabled:Y>=0&&i===Y&&!j||te>=0&&i===te&&(!L||L==="organization"&&!U),className:`px-6 py-2.5 text-white text-sm rounded-xl transition-colors ${Y>=0&&i===Y&&!j||te>=0&&i===te&&(!L||L==="organization"&&!U)?"bg-brand-600/40 cursor-not-allowed":"bg-brand-600 hover:bg-brand-500"}`,children:i===ne.length-1?a("getStarted"):a("common:next")})]})]})]})})})}function qie({onLogin:e,hasOwner:n,hasMultipleUsers:r}){const{t:s}=ft("auth"),[a,i]=g.useState(null),[l,d]=g.useState(""),[u,m]=g.useState(!1),[h,p]=g.useState(""),[b,x]=g.useState(""),v=async(w,N=!1)=>{d(""),i(w??"hub");try{await ja(w);const j=si(),T=qh();if(!j||!T){d(s("login.hubUnavailable"));return}const{user:M,needsOnboarding:D}=await ae.auth.hubLogin(j,T);e(M,D??!1,{fromHub:!0})}catch(j){const T=j instanceof Error?j.message:"";if(!T.includes("cancelled")){if(!N&&si())return v0(),v(w,!0);d(T||s("login.hubUnavailable"))}}finally{i(null)}},k=async w=>{if(w.preventDefault(),!(!h.trim()||!b)){d(""),i("local");try{const{user:N,needsOnboarding:j}=await ae.auth.login(h.trim(),b);e(N,j??!1)}catch{d(s("login.invalidCredentials"))}finally{i(null)}}},C=s(n?"login.welcomeBack":"login.getStarted");return t.jsxs("div",{className:"min-h-dvh bg-surface-primary flex flex-col items-center justify-center p-4 relative overflow-hidden",children:[t.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),t.jsxs("div",{className:"w-full max-w-sm relative z-10 flex-1 flex flex-col justify-center",children:[t.jsxs("div",{className:"text-center mb-8",children:[t.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),t.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),t.jsx("div",{className:"text-sm text-fg-tertiary",children:C})]}),t.jsx("div",{className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-4 shadow-2xl shadow-black/30",children:u?t.jsxs(t.Fragment,{children:[t.jsxs("form",{onSubmit:k,className:"space-y-3",children:[t.jsx("div",{className:"space-y-1",children:t.jsx("input",{type:"email",value:h,onChange:w=>p(w.target.value),autoComplete:"email",autoFocus:!0,placeholder:s("login.email"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors placeholder:text-fg-tertiary",required:!0})}),t.jsx("div",{className:"space-y-1",children:t.jsx("input",{type:"password",value:b,onChange:w=>x(w.target.value),autoComplete:"current-password",placeholder:s("login.password"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors placeholder:text-fg-tertiary",required:!0})}),l&&t.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:l}),n&&!r&&t.jsx("p",{className:"text-[11px] text-fg-tertiary",children:s("login.defaultCredentials")}),t.jsx("button",{type:"submit",disabled:a==="local"||!h||!b,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-medium rounded-xl transition-all",children:s(a==="local"?"login.signingIn":"login.signIn")})]}),t.jsx("div",{className:"pt-1 text-center",children:t.jsx("button",{onClick:()=>{m(!1),d("")},className:"text-xs text-fg-tertiary hover:text-fg-secondary transition-colors",children:s("login.backToHub")})})]}):t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:()=>v("google"),disabled:!!a,className:"w-full flex items-center justify-center gap-3 py-2.5 px-4 bg-surface-elevated hover:bg-surface-elevated/80 border border-border-default rounded-xl text-sm text-fg-primary font-medium transition-all disabled:opacity-50",children:[t.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",children:[t.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 01-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z"}),t.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),t.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),t.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),s(a==="google"?"login.connectingHub":"login.withGoogle")]}),t.jsxs("button",{onClick:()=>v("github"),disabled:!!a,className:"w-full flex items-center justify-center gap-3 py-2.5 px-4 bg-surface-elevated hover:bg-surface-elevated/80 border border-border-default rounded-xl text-sm text-fg-primary font-medium transition-all disabled:opacity-50",children:[t.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z"})}),s(a==="github"?"login.connectingHub":"login.withGithub")]}),t.jsxs("button",{onClick:()=>v("email"),disabled:!!a,className:"w-full flex items-center justify-center gap-3 py-2.5 px-4 bg-surface-elevated hover:bg-surface-elevated/80 border border-border-default rounded-xl text-sm text-fg-primary font-medium transition-all disabled:opacity-50",children:[t.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75"})}),s(a==="email"?"login.connectingHub":"login.withEmail")]}),t.jsx("p",{className:"text-center text-[11px] text-fg-tertiary pt-1",children:s("login.terms")}),l&&t.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:l}),t.jsx("div",{className:"pt-1 text-center",children:t.jsx("button",{onClick:()=>m(!0),className:"text-xs text-fg-tertiary hover:text-fg-secondary transition-colors",children:s("login.useLocalAccount")})})]})})]}),t.jsxs("div",{className:"relative z-10 flex flex-wrap items-center justify-center gap-x-5 gap-y-1 py-6 text-[11px] text-fg-tertiary",children:[t.jsx("a",{href:"https://markus.global",target:"_blank",rel:"noopener noreferrer",className:"hover:text-fg-secondary transition-colors",children:"markus.global"}),t.jsx("a",{href:"mailto:business@markus.global",className:"hover:text-fg-secondary transition-colors",children:s("login.contactSales")})]})]})}function Uie({token:e,onComplete:n}){const{t:r}=ft("auth"),[s,a]=g.useState(null),[i,l]=g.useState(""),[d,u]=g.useState(""),[m,h]=g.useState(""),[p,b]=g.useState(!1),[x,v]=g.useState(!1),[k,C]=g.useState(!1);g.useEffect(()=>{ae.auth.inviteInfo(e).then(N=>a(N)).catch(()=>C(!0))},[e]);const w=async N=>{if(N.preventDefault(),h(""),i.length<6){h(r("invite.passwordMinLength"));return}if(i!==d){h(r("invite.passwordsDoNotMatch"));return}b(!0);try{await ae.auth.setup(e,i),v(!0),setTimeout(()=>{window.location.hash="",n()},2e3)}catch{h(r("invite.error"))}finally{b(!1)}};return t.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[t.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),t.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[t.jsxs("div",{className:"text-center mb-8",children:[t.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),t.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),t.jsx("div",{className:"text-sm text-fg-tertiary",children:r("invite.subtitle")})]}),t.jsx("div",{className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-5 shadow-2xl shadow-black/30",children:k?t.jsxs("div",{className:"text-center space-y-3",children:[t.jsx("div",{className:"text-red-500 text-3xl",children:"⚠"}),t.jsx("p",{className:"text-sm text-fg-secondary",children:r("invite.invalidLink")}),t.jsx("button",{onClick:()=>{window.location.hash="",n()},className:"text-sm text-brand-500 hover:text-brand-400",children:r("login.signIn")})]}):x?t.jsxs("div",{className:"text-center space-y-3",children:[t.jsx("div",{className:"text-green-500 text-3xl",children:"✓"}),t.jsx("p",{className:"text-sm text-fg-secondary",children:r("invite.setupComplete")})]}):s?t.jsxs("form",{onSubmit:w,className:"space-y-5",children:[t.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:r("invite.greeting",{name:s.name})}),t.jsx("p",{className:"text-xs text-fg-tertiary text-center",children:s.email}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:r("invite.setPassword")}),t.jsx("input",{type:"password",value:i,onChange:N=>l(N.target.value),autoComplete:"new-password",autoFocus:!0,className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:r("invite.confirmPassword")}),t.jsx("input",{type:"password",value:d,onChange:N=>u(N.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),m&&t.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:m}),t.jsx("button",{type:"submit",disabled:p||!i||!d,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-medium rounded-xl transition-all shadow-md shadow-brand-900/40 hover:shadow-lg hover:shadow-brand-900/50",children:r(p?"invite.settingUp":"invite.setupAccount")})]}):t.jsx("div",{className:"text-center text-fg-tertiary text-sm animate-pulse py-4",children:"Loading…"})})]})]})}function Vie({onComplete:e,isFirstTime:n}){const{t:r}=ft("auth"),[s,a]=g.useState(""),[i,l]=g.useState(""),[d,u]=g.useState(""),[m,h]=g.useState(""),[p,b]=g.useState(!1),x=async v=>{if(v.preventDefault(),h(""),i.length<6){h(r("changePassword.passwordMinLength"));return}if(i!==d){h(r("changePassword.passwordsDoNotMatch"));return}b(!0);try{await ae.auth.changePassword(s,i),e()}catch{h(r("changePassword.failedToChange"))}finally{b(!1)}};return t.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[t.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),t.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[t.jsxs("div",{className:"text-center mb-8",children:[t.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),t.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),t.jsx("div",{className:"text-sm text-fg-tertiary",children:r("login.subtitle")})]}),t.jsxs("form",{onSubmit:x,className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-5 shadow-2xl shadow-black/30",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:r(n?"changePassword.setYourPassword":"changePassword.changePassword")}),n&&t.jsx("p",{className:"text-xs text-amber-600/80 text-center mt-2",children:r("changePassword.defaultPasswordWarning")})]}),!n&&t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:r("changePassword.currentPassword")}),t.jsx("input",{type:"password",value:s,onChange:v=>a(v.target.value),autoComplete:"current-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:r("changePassword.newPassword")}),t.jsx("input",{type:"password",value:i,onChange:v=>l(v.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0,minLength:6})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:r("changePassword.confirmNewPassword")}),t.jsx("input",{type:"password",value:d,onChange:v=>u(v.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),m&&t.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:m}),t.jsx("button",{type:"submit",disabled:p||!i||!d,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-medium rounded-xl transition-colors",children:r(p?"changePassword.saving":n?"changePassword.setPasswordAndContinue":"changePassword.changePassword")})]})]})]})}const lh={agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]},Wie={team:["agents","workflows","tasks","requirements","projects","deliverables"],work:["workflows","projects","requirements","tasks","agents","deliverables"],deliverables:["deliverables","agents","tasks","requirements","projects","workflows"]},Kie=["agents","tasks","requirements","projects","deliverables","workflows"];let d6="",u6="all",m6=lh,f6=!1;function Gie({onClose:e,currentPage:n}){const{t:r}=ft(["common","home","work"]),[s,a]=g.useState(d6),[i,l]=g.useState(u6),[d,u]=g.useState(m6),[m,h]=g.useState(!1),[p,b]=g.useState(f6),[x,v]=g.useState(-1);g.useEffect(()=>{d6=s},[s]),g.useEffect(()=>{u6=i},[i]),g.useEffect(()=>{m6=d},[d]),g.useEffect(()=>{f6=p},[p]);const k=g.useRef(null),C=g.useRef(void 0),w=g.useRef(null),N=g.useRef(null);g.useEffect(()=>{setTimeout(()=>{k.current?.focus(),k.current?.select()},100)},[]);const j=g.useCallback(async U=>{if(!U.trim()){u(lh),b(!1),v(-1);return}h(!0),b(!0),v(-1);const E=U.toLowerCase();try{const[z,I,_,W,ee,F]=await Promise.allSettled([ae.agents.list(),ae.tasks.list({search:U,pageSize:20}),ae.requirements.list(),ae.projects.list(),ae.deliverables.search({q:U,limit:20}),ae.teams.list()]),K=z.status==="fulfilled"?z.value.agents.filter(te=>te.name?.toLowerCase().includes(E)||te.role?.toLowerCase().includes(E)):[],Z=I.status==="fulfilled"?I.value.tasks:[],B=_.status==="fulfilled"?_.value.requirements.filter(te=>te.title?.toLowerCase().includes(E)||te.description?.toLowerCase().includes(E)):[],J=W.status==="fulfilled"?W.value.projects.filter(te=>te.name?.toLowerCase().includes(E)||te.description?.toLowerCase().includes(E)):[],Q=ee.status==="fulfilled"?ee.value.results:[],ne=[];if(F.status==="fulfilled"){const te=await Promise.allSettled(F.value.teams.map(Y=>ae.workflows.list(Y.id)));for(const Y of te)if(Y.status==="fulfilled")for(const ie of Y.value.workflows)(ie.name.toLowerCase().includes(E)||(ie.displayName||"").toLowerCase().includes(E)||ie.description?.toLowerCase().includes(E))&&ne.push(ie)}u({agents:K,tasks:Z,requirements:B,projects:J,deliverables:Q,workflows:ne})}catch{u(lh)}finally{h(!1)}},[]),T=U=>{a(U),C.current&&clearTimeout(C.current),C.current=setTimeout(()=>j(U),400)},M=g.useCallback((U,E)=>{e(),vt.navigate(U,E)},[e]),D=[{id:"all",label:r("common:all",{defaultValue:"全部"})},{id:"agents",label:r("common:agents",{defaultValue:"智能体"})},{id:"tasks",label:r("common:tasks",{defaultValue:"任务"})},{id:"requirements",label:r("common:requirements",{defaultValue:"需求"})},{id:"projects",label:r("common:projects",{defaultValue:"项目"})},{id:"deliverables",label:r("common:deliverables",{defaultValue:"交付物"})},{id:"workflows",label:r("common:workflows",{defaultValue:"工作流"})}],L=g.useMemo(()=>Wie[n||""]||Kie,[n]),O=g.useMemo(()=>{const U=[],E=i==="all"?8:void 0,z=I=>{if(i!=="all"&&i!==I)return;const _=d[I].length;if(I==="workflows"){const W=E?d.workflows.slice(0,E):d.workflows;for(const ee of W)U.push({id:ee.name,type:"workflow",page:Oe.WORK,params:{boardType:"workflows"}})}else{const W=d[I],ee=E?W.slice(0,E):W;for(const F of ee)switch(I){case"agents":U.push({id:F.id,type:"agent",page:Oe.TEAM,params:{agentId:F.id}});break;case"tasks":U.push({id:F.id,type:"task",page:Oe.WORK,params:{openTask:F.id}});break;case"requirements":U.push({id:F.id,type:"requirement",page:Oe.WORK,params:{openRequirement:F.id}});break;case"projects":U.push({id:F.id,type:"project",page:Oe.WORK,params:{projectId:F.id}});break;case"deliverables":U.push({id:F.id,type:"deliverable",page:Oe.DELIVERABLES,params:{openDeliverable:F.id}});break}}E&&_>E&&U.push({id:`more_${I}`,type:"showMore",page:"",expandCategory:I,totalCount:_})};for(const I of L)z(I);return U},[d,i,L]),P=g.useCallback(U=>{if(U.type==="showMore"&&U.expandCategory){l(U.expandCategory),v(-1);return}M(U.page,U.params)},[M]);g.useEffect(()=>{const U=N.current;if(!U||x<0)return;const E=U.querySelector(`[data-idx="${x}"]`);E&&E.scrollIntoView({block:"nearest"})},[x]);const R=g.useCallback(U=>{if(U.key==="Escape"){e();return}if(U.key==="Tab"){U.preventDefault();const I=D.map(ee=>ee.id),_=I.indexOf(i),W=U.shiftKey?_<=0?I.length-1:_-1:_>=I.length-1?0:_+1;l(I[W]),v(-1);return}const E=U.ctrlKey&&U.key==="n"||U.key==="ArrowDown",z=U.ctrlKey&&U.key==="p"||U.key==="ArrowUp";if(E||z){U.preventDefault(),v(I=>{const _=O.length-1;return _<0?-1:E?I>=_?0:I+1:I<=0?_:I-1});return}U.key==="Enter"&&(U.preventDefault(),x>=0&&x<O.length&&P(O[x]))},[e,O,x,P,D,i]);g.useEffect(()=>(document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)),[R]);const H=O.length>0;let q=0;return t.jsx("div",{ref:w,className:"fixed inset-0 bg-black/50 flex items-start justify-center z-50 pt-[8vh]",onClick:U=>{U.target===w.current&&e()},children:t.jsxs("div",{className:"bg-surface-primary border border-border-default rounded-2xl shadow-2xl w-full max-w-3xl max-h-[78vh] flex flex-col overflow-hidden animate-fadeIn",children:[t.jsxs("div",{className:"shrink-0 px-5 pt-4 pb-3 border-b border-border-default space-y-3",children:[t.jsxs("div",{className:"relative",children:[t.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:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),t.jsx("input",{ref:k,value:s,onChange:U=>T(U.target.value),placeholder:r("common:search"),className:"w-full bg-surface-elevated border border-border-default rounded-xl pl-9 pr-9 py-2.5 text-sm text-fg-primary placeholder:text-fg-tertiary focus:border-brand-500 focus:outline-none transition-colors"}),s&&t.jsx("button",{onClick:()=>{a(""),u(lh),b(!1),v(-1),k.current?.focus()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-fg-tertiary hover:text-fg-secondary",children:t.jsxs("svg",{width:"14",height:"14",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"})]})})]}),t.jsx("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:D.map(U=>t.jsx("button",{onClick:()=>{l(U.id),v(-1)},className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${i===U.id?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:U.label},U.id))})]}),t.jsxs("div",{ref:N,className:"flex-1 overflow-y-auto px-5 py-3",children:[m&&t.jsx("div",{className:"flex items-center justify-center py-8",children:t.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:r("common:loading")})}),!m&&p&&!H&&t.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[t.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-2",children:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),t.jsx("p",{className:"text-sm text-fg-tertiary",children:r("common:noResults",{defaultValue:"没有找到相关结果"})})]}),!m&&H&&t.jsx("div",{className:"space-y-4",children:L.map(U=>{if(i!=="all"&&i!==U)return null;const E=i==="all"?8:void 0,z=I=>{const _=q++,W=I==="agents"?d.agents.length:I==="tasks"?d.tasks.length:I==="requirements"?d.requirements.length:I==="projects"?d.projects.length:I==="workflows"?d.workflows.length:d.deliverables.length;return t.jsxs("button",{"data-idx":_,onClick:()=>{l(I),v(-1)},className:`mt-1 w-full text-xs py-1.5 rounded-lg transition-colors ${_===x?"bg-brand-600/15 ring-1 ring-brand-500/40 text-brand-500":"text-brand-500 hover:text-brand-400 hover:bg-surface-overlay"}`,children:[r("common:showAll",{defaultValue:"查看全部"})," (",W,")"]})};return U==="agents"&&d.agents.length>0?t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:r("common:agents",{defaultValue:"智能体"})}),t.jsx("div",{className:"space-y-0.5",children:(E?d.agents.slice(0,E):d.agents).map(I=>{const _=q++;return t.jsxs("button",{"data-idx":_,onClick:()=>M(Oe.TEAM,{agentId:I.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${_===x?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[t.jsx(lr,{name:I.name||"Agent",avatarUrl:I.avatarUrl,size:28}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:I.name}),t.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:I.role||I.status})]}),t.jsx(Yie,{status:I.status})]},I.id)})}),E&&d.agents.length>E&&z("agents")]},"agents"):U==="tasks"&&d.tasks.length>0?t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:r("common:tasks",{defaultValue:"任务"})}),t.jsx("div",{className:"space-y-0.5",children:(E?d.tasks.slice(0,E):d.tasks).map(I=>{const _=q++;return t.jsxs("button",{"data-idx":_,onClick:()=>M(Oe.WORK,{openTask:I.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${_===x?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[t.jsx(Xie,{status:I.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:I.title}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[I.status," · ",I.priority||""]})]})]},I.id)})}),E&&d.tasks.length>E&&z("tasks")]},"tasks"):U==="requirements"&&d.requirements.length>0?t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:r("common:requirements",{defaultValue:"需求"})}),t.jsx("div",{className:"space-y-0.5",children:(E?d.requirements.slice(0,E):d.requirements).map(I=>{const _=q++;return t.jsxs("button",{"data-idx":_,onClick:()=>M(Oe.WORK,{openRequirement:I.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${_===x?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[t.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${I.status==="approved"?"text-green-500 bg-green-500/15":I.status==="pending"?"text-amber-500 bg-amber-500/15":I.status==="rejected"?"text-red-500 bg-red-500/15":"text-fg-tertiary bg-surface-elevated"}`,children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),t.jsx("polyline",{points:"14 2 14 8 20 8"}),t.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),t.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:I.title}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[I.status," · ",I.priority||""]})]})]},I.id)})}),E&&d.requirements.length>E&&z("requirements")]},"requirements"):U==="projects"&&d.projects.length>0?t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:r("common:projects",{defaultValue:"项目"})}),t.jsx("div",{className:"space-y-0.5",children:(E?d.projects.slice(0,E):d.projects).map(I=>{const _=q++;return t.jsxs("button",{"data-idx":_,onClick:()=>M(Oe.WORK,{projectId:I.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${_===x?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[t.jsx("div",{className:"w-7 h-7 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-brand-500",children:t.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"})})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:I.name}),I.description&&t.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:I.description})]})]},I.id)})}),E&&d.projects.length>E&&z("projects")]},"projects"):U==="deliverables"&&d.deliverables.length>0?t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:r("common:deliverables",{defaultValue:"交付物"})}),t.jsx("div",{className:"space-y-0.5",children:(E?d.deliverables.slice(0,E):d.deliverables).map(I=>{const _=q++;return t.jsxs("button",{"data-idx":_,onClick:()=>M(Oe.DELIVERABLES,{openDeliverable:I.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${_===x?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[t.jsx("div",{className:"w-7 h-7 rounded-lg bg-purple-500/15 flex items-center justify-center shrink-0",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-purple-500",children:[t.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),t.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:I.title}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[I.type," · ",I.status]})]})]},I.id)})}),E&&d.deliverables.length>E&&z("deliverables")]},"deliverables"):U==="workflows"&&d.workflows.length>0?t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:r("common:workflows",{defaultValue:"工作流"})}),t.jsx("div",{className:"space-y-0.5",children:(E?d.workflows.slice(0,E):d.workflows).map(I=>{const _=q++;return t.jsxs("button",{"data-idx":_,onClick:()=>M(Oe.WORK,{boardType:"workflows"}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${_===x?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[t.jsx("div",{className:"w-7 h-7 rounded-lg bg-teal-500/15 flex items-center justify-center shrink-0",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-teal-500",children:[t.jsx("circle",{cx:"12",cy:"12",r:"3"}),t.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"})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:I.displayName||I.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[I.stepCount," steps · v",I.version]})]})]},I.name)})}),E&&d.workflows.length>E&&z("workflows")]},"workflows"):null})}),!m&&!p&&t.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[t.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-2",children:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),t.jsx("p",{className:"text-sm text-fg-tertiary",children:r("common:searchHint",{defaultValue:"输入关键词搜索"})})]})]}),t.jsxs("div",{className:"shrink-0 px-5 py-2 border-t border-border-default flex items-center gap-4 text-xs text-fg-tertiary flex-wrap",children:[t.jsxs("span",{children:[t.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:navigator.platform.toUpperCase().includes("MAC")?"Cmd+P":"Ctrl+P"})," ",r("common:toggle",{defaultValue:"唤起/关闭"})]}),t.jsxs("span",{children:[t.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Tab"})," ",r("common:switchTab",{defaultValue:"切换分类"})]}),t.jsxs("span",{children:[t.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"↑↓"})," ",r("common:navigate",{defaultValue:"导航"})]}),t.jsxs("span",{children:[t.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Enter"})," ",r("common:open",{defaultValue:"打开"})]}),t.jsxs("span",{children:[t.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Esc"})," ",r("common:close",{defaultValue:"关闭"})]})]})]})})}function Yie({status:e}){const n=e==="active"||e==="idle"?"bg-green-500":e==="working"||e==="busy"?"bg-blue-500":e==="paused"?"bg-amber-500":"bg-gray-400";return t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${n}`})}function Xie({status:e}){const n=e==="completed"?"text-green-500 bg-green-500/15":e==="in_progress"?"text-blue-500 bg-blue-500/15":e==="pending"?"text-amber-500 bg-amber-500/15":"text-fg-tertiary bg-surface-elevated";return t.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${n}`,children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("path",{d:"M9 11l3 3L22 4"}),t.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})})}const Qie={visibility:"hidden",position:"absolute",inset:0,pointerEvents:"none",zIndex:-1},Zie=g.memo(function({id:n,activePage:r,children:s}){const a=n===r;return t.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",style:a?void 0:Qie,children:s})},(e,n)=>{const r=e.id===e.activePage,s=n.id===n.activePage;return r!==s?!1:s?e.children===n.children:!0}),Yb={};function Jie(){const{t:e}=ft("common"),[n,r]=g.useState(fc),[s,a]=g.useState(()=>!localStorage.getItem("markus_onboarded")),[i,l]=g.useState(!0),d=Os(),u=WX(),m=M0({side:"left",defaultWidth:160,minWidth:140,maxWidth:400,collapsedWidth:64,storageKey:"markus_sidebar"}),[h,p]=g.useState(()=>new Set([fc()])),[b,x]=g.useState("loading"),[v,k]=g.useState(null),[C,w]=g.useState({hasOwner:!1,hasMultipleUsers:!1}),[N,j]=g.useState(!1),[T,M]=g.useState(!1),[D,L]=g.useState(null),[O,P]=g.useState(!1),[R,H]=g.useState(null),[q,U]=g.useState(()=>{const te=localStorage.getItem("markus_update_dismissed");return te||null}),[E,z]=g.useState(null),[I,_]=g.useState(!1),W=g.useCallback(()=>{ae.license.get().then(te=>{if(te.plan==="enterprise"){z(null);return}if(te.usage&&te.limits){const Y=te.limits.maxTeams>0&&te.usage.teams>=te.limits.maxTeams,ie=te.limits.maxToolCallsPerDay>0&&te.usage.toolCallsToday>=te.limits.maxToolCallsPerDay;Y||ie?(z({teams:Y||void 0,toolCalls:ie||void 0}),_(!1)):z(null)}}).catch(()=>{})},[]);g.useEffect(()=>{const te=()=>{document.visibilityState==="visible"&&W()};window.addEventListener("markus:check-license-limits",W),document.addEventListener("visibilitychange",te);const Y=setInterval(W,300*1e3);return()=>{window.removeEventListener("markus:check-license-limits",W),document.removeEventListener("visibilitychange",te),clearInterval(Y)}},[W]);const[ee,F]=g.useState(!1);g.useEffect(()=>{if(d)return;const te=navigator.platform.toUpperCase().includes("MAC"),Y=pe=>{te&&pe.metaKey&&!pe.ctrlKey&&pe.key==="p"?(pe.preventDefault(),F(ge=>!ge)):!te&&pe.ctrlKey&&!pe.metaKey&&pe.key==="p"&&(pe.preventDefault(),F(ge=>!ge))},ie=()=>F(!0);return document.addEventListener("keydown",Y),window.addEventListener("markus:open-search",ie),()=>{document.removeEventListener("keydown",Y),window.removeEventListener("markus:open-search",ie)}},[d]);const K=g.useCallback(te=>{let Y=pc(te);d?Y=E$[Y]??Y:Y===Oe.NOTIFICATIONS&&(Y=Oe.HOME);const ie=fc(),pe=window.location.hash.slice(1);pe!==ie?Yb[ie]=pe:delete Yb[ie];const ge=Y!==Oe.WORK?Yb[Y]:void 0;ge&&ge!==Y?(history.pushState(null,"","#"+Y),history.pushState(null,"","#"+ge)):history.pushState(null,"","#"+Y),window.dispatchEvent(new HashChangeEvent("hashchange")),r(Y),p(ye=>ye.has(Y)?ye:new Set([...ye,Y]))},[d]);g.useEffect(()=>{vt.setHandler(te=>K(te))},[K]);const Z=g.useCallback(()=>{fetch("/api/settings/llm").then(te=>te.ok?te.json():null).then(te=>{if(te?.providers){const Y=Object.values(te.providers).some(ie=>ie.configured);L(Y)}}).catch(()=>{})},[]);g.useEffect(()=>{const te=new URLSearchParams(window.location.search),Y=te.get("install");if(Y&&fc()!==Oe.STORE){const ge=te.get("type"),me=ge&&{agent:"agents",team:"teams",skill:"skills"}[ge]||"agents";localStorage.setItem("markus_nav_installItem",Y),localStorage.setItem("markus_nav_storeTab",me),te.delete("install"),te.delete("type");const re=te.toString();window.history.replaceState(null,"",window.location.pathname+(re?`?${re}`:"")+"#store"),setTimeout(()=>vt.navigate(Oe.STORE,{storeTab:me,installItem:Y}),300)}ae.auth.me().then(({user:ge})=>{x(ge),k(!0),un.connect(ge.id),Z(),ae.health().then(me=>{me.updateAvailable&&me.latestVersion&&H({latestVersion:me.latestVersion,currentVersion:me.version})}).catch(()=>{}),W();const ye=()=>{cc(Ua.builderArtifacts,()=>ae.builder.artifacts.list()),cc(Ua.builderAgents,()=>ae.agents.list()),cc(Ua.builderHubMyItems,()=>Cn.myItems()),cc(Ua.builderInstalled,()=>ae.builder.artifacts.installed()),cc(Ua.hubAgents,()=>Cn.search({type:"agent",limit:50})),cc(Ua.hubTeams,()=>Cn.search({type:"team",limit:50})),cc(Ua.hubSkills,()=>Cn.search({type:"skill",limit:50}))};typeof requestIdleCallback=="function"?requestIdleCallback(ye,{timeout:5e3}):setTimeout(ye,3e3)}).catch(()=>{x(null),ae.auth.status().then(({initialized:ge,hasOwner:ye,hasMultipleUsers:me})=>{k(ge),w({hasOwner:ye,hasMultipleUsers:me})}).catch(()=>k(!0))}),un.connect();const ie=un.on("notification",()=>{window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}),pe=()=>{const ge=fc();r(ge),p(ye=>ye.has(ge)?ye:new Set([...ye,ge]))};return window.addEventListener("hashchange",pe),window.addEventListener("popstate",pe),()=>{ie(),un.disconnect(),window.removeEventListener("hashchange",pe),window.removeEventListener("popstate",pe)}},[]);const B=b!=="loading"&&b!==null?b:void 0,J=g.useMemo(()=>d?{[Oe.HOME]:t.jsx(r4,{authUser:B}),[Oe.TEAM]:t.jsx(Ij,{authUser:B}),[Oe.BUILDER]:t.jsx(Hie,{authUser:B}),[Oe.SETTINGS]:t.jsx(f3,{theme:u.mode,onThemeChange:u.setMode,authUser:B,onLogout:()=>{ae.auth.logout().catch(()=>{}),v0(),x(null)},onUserUpdated:te=>x(te)}),[Oe.WORK]:t.jsx(t6,{authUser:B}),[Oe.DELIVERABLES]:t.jsx(s6,{authUser:B}),[Oe.NOTIFICATIONS]:t.jsx(Lie,{authUser:B}),[Oe.REPORTS]:t.jsx(i6,{authUser:B}),[Oe.SEARCH]:t.jsx(Pie,{})}:{[Oe.HOME]:t.jsx(r4,{authUser:B}),[Oe.TEAM]:t.jsx(Ij,{authUser:B}),[Oe.SETTINGS]:t.jsx(f3,{theme:u.mode,onThemeChange:u.setMode,authUser:B,onLogout:()=>{ae.auth.logout().catch(()=>{}),v0(),x(null)},onUserUpdated:te=>x(te)}),[Oe.STORE]:t.jsx(ZQ,{authUser:B}),[Oe.BUILDER]:t.jsx(E8,{authUser:B}),[Oe.WORK]:t.jsx(t6,{authUser:B}),[Oe.DELIVERABLES]:t.jsx(s6,{authUser:B}),[Oe.REPORTS]:t.jsx(i6,{authUser:B})},[B?.id,B?.role,u.mode,d]);if(b==="loading"||b===null&&v===null)return t.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center",children:t.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:e("loading")})});const ne=(typeof window<"u"?window.location.hash:"").match(/^#invite\?token=([a-f0-9]+)/);return ne?t.jsx(Uie,{token:ne[1],onComplete:()=>{window.location.hash="",localStorage.removeItem("markus_onboarded"),a(!0),j(!0),x("loading"),ae.auth.me().then(te=>x(te.user)).catch(()=>x(null))}}):b===null?t.jsx(qie,{hasOwner:C.hasOwner,hasMultipleUsers:C.hasMultipleUsers,onLogin:(te,Y,ie)=>{x(te),Y?(localStorage.removeItem("markus_onboarded"),a(!0),ie?.fromHub&&j(!0)):localStorage.getItem("markus_onboarded")||(localStorage.setItem("markus_onboarded","1"),a(!1))}}):T?t.jsx(Vie,{onComplete:()=>M(!1),isFirstTime:!0}):s?t.jsx(Fie,{theme:u.mode,onThemeChange:u.setMode,skipProfile:N,onComplete:()=>{localStorage.setItem("markus_onboarded","1"),a(!1),j(!1),Z(),K(Oe.HOME)}}):t.jsxs("div",{className:`flex h-dvh bg-surface-primary text-fg-primary overflow-x-hidden ${d?"flex-col":""}`,children:[!d&&n!==Oe.SETTINGS&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"relative z-40 shrink-0",style:{width:m.width},children:t.jsx(zie,{currentPage:n,onNavigate:te=>{K(te),l(!1)},authUser:b,collapsed:m.collapsed,onToggleCollapse:m.toggle})}),t.jsx("div",{className:`${m.collapsed?"w-0":"w-1.5 cursor-col-resize"} shrink-0 group relative z-10 flex items-center justify-center`,onMouseDown:m.collapsed?void 0:m.onResizeStart,children:!m.collapsed&&t.jsx("div",{className:"w-px h-2/3 border-l border-dashed border-transparent group-hover:border-border-default group-active:border-fg-tertiary transition-colors"})})]}),t.jsxs("div",{className:`flex-1 overflow-hidden flex flex-col min-w-0 ${d&&n!==Oe.SETTINGS&&n!==Oe.SEARCH?"pb-14":""}`,children:[D===!1&&!O&&n!==Oe.SETTINGS&&t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-amber-500/10 border-b border-amber-500/30 text-amber-600 text-sm shrink-0",children:[t.jsx("span",{className:d?"text-xs":"",children:e("llmBanner.message")}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>{window.location.hash="#settings/providers"},className:"px-3 py-1 bg-amber-700/50 hover:bg-amber-700/70 text-white text-xs rounded-lg transition-colors",children:e("llmBanner.goToSettings")}),t.jsx("button",{onClick:()=>P(!0),className:"text-amber-500 hover:text-amber-600 text-xs",children:e("dismiss")})]})]}),R&&q!==R.latestVersion&&t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-brand-500/10 border-b border-brand-500/30 text-brand-400 text-sm shrink-0",children:[t.jsx("span",{className:d?"text-xs":"",children:e("update.available",{latest:R.latestVersion,current:R.currentVersion})}),t.jsxs("span",{className:"flex items-center gap-3 shrink-0",children:[t.jsx("a",{href:"https://markus.global/download",target:"_blank",rel:"noopener noreferrer",className:"text-xs font-medium text-brand-400 hover:text-brand-300 transition-colors",children:e("update.download")}),t.jsx("button",{onClick:()=>{U(R.latestVersion),localStorage.setItem("markus_update_dismissed",R.latestVersion)},className:"text-fg-tertiary hover:text-fg-secondary text-xs shrink-0",children:e("dismiss")})]})]}),E&&!I&&n!==Oe.SETTINGS&&t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-orange-500/10 border-b border-orange-500/30 text-orange-400 text-sm shrink-0",children:[t.jsx("span",{className:d?"text-xs":"",children:E.teams&&E.toolCalls?e("license.limitReachedBoth"):E.teams?e("license.limitReachedTeams"):e("license.limitReachedToolCalls")}),t.jsxs("span",{className:"flex items-center gap-3 shrink-0",children:[t.jsx("button",{onClick:()=>{window.location.hash="settings/account"},className:"px-3 py-1 bg-orange-600/50 hover:bg-orange-600/70 text-white text-xs rounded-lg transition-colors",children:e("license.upgradeLicense")}),t.jsx("button",{onClick:()=>_(!0),className:"text-fg-tertiary hover:text-fg-secondary text-xs shrink-0",children:e("dismiss")})]})]}),t.jsx("main",{className:"flex-1 overflow-hidden flex flex-col relative",children:Object.keys(J).map(te=>h.has(te)?t.jsx(Zie,{id:te,activePage:n,children:J[te]},te):null)})]}),d&&n!==Oe.SETTINGS&&n!==Oe.SEARCH&&t.jsx($ie,{currentPage:n,onNavigate:K,userId:B?.id}),d&&t.jsx(P$,{authUser:B,onNavigate:K}),!d&&ee&&t.jsx(Gie,{onClose:()=>F(!1),currentPage:n})]})}nA.createRoot(document.getElementById("root")).render(t.jsx(g.StrictMode,{children:t.jsx(Jie,{})}));
724
+ `);if(!ge)return;D(""),R([]),E.current=!0,T(!0),O([]);const ye=`a_${Date.now()}`,me={id:`u_${Date.now()}`,sender:"user",text:ge,time:new Date().toLocaleTimeString()},re=new Date().toISOString();v(ke=>[...ke,me,{id:ye,sender:"agent",text:"",time:new Date().toLocaleTimeString(),rawCreatedAt:re,segments:[]}]);let Ne=!1;const Ae=ke=>{v(We=>{const Fe=[...We],ue=Fe.findIndex(qe=>qe.id===ye);if(ue<0)return We;const ve=Fe[ue].segments??[],be=ve[ve.length-1],V=be?.type==="text"?be.thinking??"":"";let se="",Te="",xe=ke;for(;xe.length>0;)if(Ne){const qe=xe.indexOf("</think>");qe>=0?(se+=xe.slice(0,qe),xe=xe.slice(qe+8),Ne=!1):(se+=xe,xe="")}else{const qe=xe.indexOf("<think>");qe>=0?(Te+=xe.slice(0,qe),xe=xe.slice(qe+7),Ne=!0):(Te+=xe,xe="")}const Ge=V+se||void 0,Se=be?.type==="text"?[...ve.slice(0,-1),{type:"text",content:be.content+Te,thinking:Ge,createdAt:be.createdAt}]:[...ve,{type:"text",content:Te,thinking:Ge,createdAt:new Date().toISOString()}];return Fe[ue]={...Fe[ue],text:Fe[ue].text+Te,segments:Se},Fe})},_e=ke=>{if(ke.type==="session_start"&&ke.sessionId){C(ke.sessionId);return}v(We=>{const Fe=[...We],ue=Fe.findIndex(be=>be.id===ye);if(ue<0)return We;const ve=[...Fe[ue].committedSegments??[]];return ke.type==="thinking_commit"?ve.push({type:"text",content:"",thinking:ke.content,createdAt:ke.createdAt}):ve.push({type:"text",content:ke.content,createdAt:ke.createdAt}),Fe[ue]={...Fe[ue],committedSegments:ve},Fe})},$e=ke=>{ke.phase!=="heartbeat"&&(ke.phase==="start"?(O(We=>[...We,{...ke,phase:"start",ts:Date.now()}]),v(We=>{const Fe=[...We],ue=Fe.findIndex(xe=>xe.id===ye);if(ue<0)return We;const ve=[...Fe[ue].segments??[]],be=`${ke.tool}_${Date.now()}`,V=new Date().toISOString();let se=!1;if(ke.arguments)for(let xe=ve.length-1;xe>=0;xe--){const Ge=ve[xe];if(Ge.type==="tool"&&Ge.tool===ke.tool&&Ge.status==="running"){ve[xe]={...Ge,args:ke.arguments},se=!0;break}}se||ve.push({type:"tool",key:be,tool:ke.tool,status:"running",args:ke.arguments,createdAt:V});const Te=[...Fe[ue].committedSegments??[]];return ke.arguments!==void 0&&Te.push({type:"tool",key:be,tool:ke.tool,status:"running",args:ke.arguments,createdAt:V}),Fe[ue]={...Fe[ue],segments:ve,committedSegments:Te},Fe})):ke.phase==="output"?v(We=>{const Fe=[...We],ue=Fe.findIndex(be=>be.id===ye);if(ue<0)return We;const ve=[...Fe[ue].segments??[]];for(let be=ve.length-1;be>=0;be--){const V=ve[be];if(V.type==="tool"&&V.tool===ke.tool&&V.status==="running"){ve[be]={...V,liveOutput:(V.liveOutput??"")+(ke.output??"")};break}}return Fe[ue]={...Fe[ue],segments:ve},Fe}):ke.phase==="end"&&(O(We=>[...We,{...ke,phase:"end",ts:Date.now()}]),v(We=>{const Fe=[...We],ue=Fe.findIndex(se=>se.id===ye);if(ue<0)return We;const ve=new Date().toISOString(),be=[...Fe[ue].segments??[]];for(let se=be.length-1;se>=0;se--){const Te=be[se];if(Te.type==="tool"&&Te.tool===ke.tool&&Te.status==="running"){be[se]={...Te,status:ke.success===!1?"error":"done",args:ke.arguments,result:ke.result,error:ke.error,durationMs:ke.durationMs,liveOutput:void 0,createdAt:ve};break}}const V=[...Fe[ue].committedSegments??[]];for(let se=V.length-1;se>=0;se--){const Te=V[se];if(Te.type==="tool"&&Te.tool===ke.tool&&Te.status==="running"){V[se]={...Te,status:ke.success===!1?"error":"done",args:ke.arguments,result:ke.result,error:ke.error,durationMs:ke.durationMs,liveOutput:void 0,createdAt:ve};break}}return Fe[ue]={...Fe[ue],segments:be,committedSegments:V},Fe})))},we=new AbortController;U.current=we;try{const ke=await ae.agents.messageStream(e,ge,Ae,$e,we.signal,void 0,k,void 0,void 0,_e);ke.merged&&v(We=>We.filter(Fe=>Fe.id!==ye)),!ke.merged&&ke.segments?.length&&v(We=>{const Fe=[...We],ue=Fe.findIndex(V=>V.id===ye);if(ue<0)return We;const ve=ke.segments.map((V,se)=>V.type==="tool"?{type:"tool",key:`${V.tool}_${se}`,tool:V.tool,status:V.status,args:V.arguments,result:V.result,error:V.error,durationMs:V.durationMs,createdAt:V.createdAt}:{type:"text",content:V.content,thinking:V.thinking,createdAt:V.createdAt});let be=ke.content||Fe[ue].text;return be||(be=ve.filter(V=>V.type==="text").map(V=>V.content).join("")),Fe[ue]={...Fe[ue],text:be,segments:ve,committedSegments:ve},Fe}),!ke.merged&&!ke.segments?.length&&v(We=>{const Fe=[...We],ue=Fe.findIndex(Te=>Te.id===ye);if(ue<0)return We;const ve=Fe[ue],be=ve.committedSegments??[],se=be.filter(Te=>Te.type==="text"&&!!Te.content).map(Te=>Te.content).join("")||ke.content||ve.text;return(be.length>0||se)&&(Fe[ue]={...ve,text:se,segments:be.length>0?be:ve.segments}),Fe}),ke.sessionId&&C(ke.sessionId)}catch(ke){const We=ke?.sessionId;We&&C(We);const Fe=O1(ke,m);v(Fe?ue=>{const ve=[...ue],be=ve.findIndex(V=>V.id===ye);if(be>=0){const V=ve[be].segments??[];ve[be]={...ve[be],text:Fe,isError:!0,segments:[...V,{type:"text",content:Fe}]}}return ve}:ue=>{const ve=[...ue],be=ve.findIndex(V=>V.id===ye);if(be>=0){const V=ve[be];if(!(V.text||V.segments&&V.segments.length>0&&V.segments.some(Te=>Te.type==="text"&&(Te.content||Te.thinking)||Te.type==="tool")))return ue.filter(Te=>Te.id!==ye);ve[be]={...V,isStopped:!0}}return ve})}v(ke=>{const We=[...ke],Fe=We.findIndex(ue=>ue.id===ye);if(Fe>=0){const ue=(We[Fe].segments??[]).map(ve=>ve.type==="tool"&&ve.status==="running"?{...ve,status:"stopped"}:ve);We[Fe]={...We[Fe],segments:ue}}return We}),T(!1),O([]),U.current=null},[M,e,k,m,P,i]),Q=x[x.length-1],ne=j&&Q?.sender==="agent",[te,Y]=g.useState([]);g.useEffect(()=>{let pe=!1;return(async()=>{const ye=[];try{const[me,re,Ne,Ae,_e]=await Promise.all([ae.projects.list().catch(()=>({projects:[]})),ae.requirements.list().catch(()=>({requirements:[]})),ae.tasks.list({pageSize:100}).catch(()=>({tasks:[]})),ae.deliverables.search({limit:100}).catch(()=>({results:[]})),ae.teams.list().catch(()=>({teams:[],ungrouped:[]}))]);for(const $e of me.projects)ye.push({id:$e.id,name:$e.name,type:"project",role:$e.status});for(const $e of re.requirements)ye.push({id:$e.id,name:$e.title,type:"requirement",role:$e.priority});for(const $e of Ne.tasks)ye.push({id:$e.id,name:$e.title,type:"task",role:$e.status});for(const $e of Ae.results)ye.push({id:$e.id,name:$e.title,type:"deliverable",role:$e.type});for(const $e of _e.teams)try{const we=await ae.workflows.list($e.id);for(const ke of we.workflows)ye.push({id:ke.name,name:ke.displayName||ke.name,type:"workflow",role:`v${ke.version}`})}catch{}}catch{}pe||Y(ye)})(),()=>{pe=!0}},[]);const ie=g.useMemo(()=>{const pe=r.map(ge=>({id:ge.id,name:ge.name,role:ge.role,avatarUrl:ge.avatarUrl,type:"agent"}));return[...te,...pe,...l??[]]},[r,te,l]);return t.jsxs("div",{className:`flex flex-col bg-surface-primary border-l border-border-default ${u}`,style:d?{width:d}:{width:400},children:[t.jsxs("div",{className:"h-12 px-4 flex items-center gap-2 shrink-0 border-b border-border-default",children:[t.jsx(lr,{name:p,avatarUrl:h?.avatarUrl,size:24,bgClass:"bg-brand-500/15 text-brand-600",className:"rounded-md"}),t.jsx("span",{className:"text-sm font-medium text-fg-primary truncate flex-1",children:p}),a&&t.jsx("button",{onClick:a,className:"text-fg-tertiary hover:text-fg-secondary transition-colors p-1",children:t.jsxs("svg",{width:"16",height:"16",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"})]})})]}),t.jsxs("div",{ref:H,className:"flex-1 overflow-y-auto px-3 py-3 space-y-3",onScroll:Z,children:[w?t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsxs("svg",{className:"animate-spin h-5 w-5 text-fg-tertiary",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}):x.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3",children:[t.jsx(lr,{name:p,avatarUrl:h?.avatarUrl,size:40,bgClass:"bg-brand-500/20 text-brand-500"}),t.jsx("p",{className:"text-fg-secondary text-sm font-medium",children:_})]}):x.map((pe,ge)=>{const ye=ge>0?x[ge-1]:null,me=Th(pe.rawCreatedAt),re=ye?Th(ye.rawCreatedAt):"",Ne=me&&me!==re,Ae=ge===x.length-1,_e=ne&&Ae,$e=_e;return t.jsxs("div",{children:[Ne&&t.jsxs("div",{className:"flex items-center gap-3 py-1 my-1",children:[t.jsx("div",{className:"flex-1 h-px bg-border-default"}),t.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium uppercase tracking-wider shrink-0",children:d8(pe.rawCreatedAt,I)}),t.jsx("div",{className:"flex-1 h-px bg-border-default"})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("div",{className:"shrink-0 mt-0.5",children:t.jsx(lr,{name:pe.sender==="user"?b:p,avatarUrl:pe.sender==="user"?s?.avatarUrl:h?.avatarUrl,size:24,bgClass:pe.sender==="user"?"bg-brand-600":"bg-brand-500/15 text-brand-600",className:"rounded-md"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-baseline gap-1.5",children:[t.jsx("span",{className:"text-xs font-medium text-fg-primary",children:pe.sender==="user"?b:p}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:c8(pe.time,pe.rawCreatedAt,I)})]}),t.jsx("div",{className:`mt-0.5 ${pe.sender==="agent"?"py-0.5":"bg-surface-secondary rounded-xl px-3 py-2 w-fit max-w-full"} ${pe.isError?"border-b-2 border-red-500/60":""} ${$e&&pe.sender==="agent"?"streaming-bubble":""}`,children:pe.sender==="user"?t.jsx("div",{className:"text-sm text-fg-secondary whitespace-pre-wrap",children:pe.text}):pe.segments&&pe.segments.length>0?t.jsx(m8,{msg:pe,isStreaming:_e,liveActivities:_e?L:[],onViewModeChange:()=>{}}):t.jsx(Gr,{content:pe.text,className:"text-sm text-fg-secondary"})})]})]})]},pe.id)}),t.jsx("div",{ref:q})]}),F&&t.jsx("div",{className:"flex justify-center -mt-10 relative z-10 pointer-events-none",children:t.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:m("page.scrollToBottom"),children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"6 9 12 15 18 9"})})})}),t.jsx("div",{className:"px-3 py-2 shrink-0 border-t border-border-default",children:t.jsx(Tie,{value:M,onChange:D,onSend:J,disabled:!e,placeholder:m("page.placeholder.direct"),sending:j,onStop:B,contextChips:i,mentionItems:ie,onMentionChipsChange:R,compact:!0,className:"shadow-none border-0"})})]})}const e0={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},Eie={active:{color:"text-green-600 bg-green-500/10"},verified:{color:"text-blue-600 bg-blue-500/10"},outdated:{color:"text-red-500 bg-red-500/10"}},Mie=["file","directory"];function Hf(e){return/^https?:\/\//i.test(e)}const uc={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 s6({authUser:e,previewMode:n,previewData:r}={}){const{t:s}=ft(["deliverables","common"]),a=Os(),i=Qd(Oe.DELIVERABLES),l=M0({side:"left",defaultWidth:384,minWidth:280,maxWidth:600,storageKey:"markus_deliverables_list"}),[d,u]=g.useState(!1),m=g.useRef(d);m.current=d,g.useEffect(()=>{if(!a)return;const et=()=>{m.current&&u(!1)};return window.addEventListener("popstate",et),()=>window.removeEventListener("popstate",et)},[a]);const h=100,[p,b]=g.useState(r?.items??[]),[x,v]=g.useState(r?.items?.length??0),[k,C]=g.useState(!1),[w,N]=g.useState(r?.projects??[]),[j,T]=g.useState(r?.agents??[]),[M,D]=g.useState(!r),[L,O]=g.useState(""),[P,R]=g.useState(""),[H,q]=g.useState(""),[U,E]=g.useState(""),[z,I]=g.useState(""),[_,W]=g.useState(""),[ee,F]=g.useState(""),[K,Z]=g.useState("date"),[B,J]=g.useState(()=>r?.initialSelectedId&&r.items?r.items.find(et=>et.id===r.initialSelectedId)??r.items[0]??null:r?.items?.[0]??null),[Q,ne]=g.useState(null),[te,Y]=g.useState(""),[ie,pe]=g.useState(new Set),ge=g.useMemo(()=>[{id:"date"},{id:"project"},{id:"agent"},{id:"type"}],[]),ye=g.useCallback(et=>{Z(et),pe(new Set)},[]),me=zl(ge,K,ye),re=g.useRef(null),[Ne,Ae]=g.useState(null),[_e,$e]=g.useState("markdown"),[we,ke]=g.useState(null),[We,Fe]=g.useState(!1),[ue,ve]=g.useState(!1),[be,V]=g.useState(!1),[se,Te]=g.useState(null),[xe,Ge]=g.useState(""),[Se,qe]=g.useState(new Set),[st,dt]=g.useState(!1),[Me,Ke]=g.useState(!1),[pt,it]=g.useState([]),[Ye,At]=g.useState(null),Ot=g.useRef(void 0),en=(et,Mt)=>{ne({type:et,text:Mt}),setTimeout(()=>ne(null),3e3)},tn=async et=>{await Wy(et)?(V(!0),setTimeout(()=>V(!1),1500)):en("error",s("detail.copyFailed"))},kn=g.useMemo(()=>new Map(j.map(et=>[et.id,et])),[j]),Fn=g.useMemo(()=>new Map(w.map(et=>[et.id,et])),[w]),on=g.useCallback(et=>{if(!et||et==="default")return null;const Mt=Fn.get(et)?.name;return!Mt||Mt==="default"?null:Mt},[Fn]);g.useEffect(()=>{n||(ae.projects.list().then(et=>N(et.projects)).catch(()=>{}),ae.agents.list().then(et=>T(et.agents??[])).catch(()=>{}),ae.system.storage().then(et=>Ge(et.dataDir+"/shared")).catch(()=>{}),ae.deliverables.checkHealth().then(et=>qe(new Set(et.missingFiles))).catch(()=>{}))},[n]),g.useEffect(()=>(Ot.current=setTimeout(()=>R(L),300),()=>clearTimeout(Ot.current)),[L]);const vn=g.useMemo(()=>({q:P||void 0,projectId:U||void 0,agentId:z||void 0,type:H||void 0,status:_||void 0,artifactType:ee||void 0}),[P,U,z,H,_,ee]),xn=g.useCallback(async()=>{D(!0);try{const{results:et,total:Mt}=await ae.deliverables.search({...vn,offset:0,limit:h});b(et),v(Mt)}catch{b([]),v(0)}D(!1)},[vn]),$n=g.useCallback(async()=>{if(!(k||p.length>=x)){C(!0);try{const{results:et,total:Mt}=await ae.deliverables.search({...vn,offset:p.length,limit:h});b(Re=>[...Re,...et]),v(Mt)}catch{}C(!1)}},[vn,p.length,x,k]);g.useEffect(()=>{n||xn()},[xn,n]),g.useEffect(()=>{!n||!r||(b(r.items??[]),v(r.items?.length??0),N(r.projects??[]),T(r.agents??[]),r.initialSelectedId&&J(r.items?.find(et=>et.id===r.initialSelectedId)??r.items?.[0]??null))},[n,r]);const Ln=g.useRef(B);Ln.current=B,g.useEffect(()=>{if(n||!i)return;const et=un.on("deliverable:created",()=>xn()),Mt=un.on("deliverable:updated",tt=>{xn();const _t=tt.payload?.deliverableId;_t&&Ln.current?.id===_t&&ae.deliverables.get(_t).then(Ht=>{Ht.deliverable&&(J(Ht.deliverable),ar(Ht.deliverable))}).catch(()=>{})}),Re=un.on("deliverable:removed",()=>xn());return()=>{et(),Mt(),Re()}},[xn,i,n]);const Hr=g.useRef(null),wr=g.useRef(p);wr.current=p;const gr=g.useCallback(et=>{const Mt=tt=>{J(tt),a&&(u(!0),history.pushState({mobileDetail:Oe.DELIVERABLES},"",window.location.hash))},Re=wr.current.find(tt=>tt.id===et);if(Re){Mt(Re);return}ae.deliverables.get(et).then(tt=>{tt.deliverable&&Mt(tt.deliverable)}).catch(()=>{})},[a]);g.useEffect(()=>{if(n)return;const et=localStorage.getItem("markus_nav_openDeliverable");et&&(localStorage.removeItem("markus_nav_openDeliverable"),wr.current.length>0?gr(et):Hr.current=et);const Mt=Re=>{const tt=Re.detail;tt?.params?.openDeliverable&&(localStorage.removeItem("markus_nav_openDeliverable"),gr(tt.params.openDeliverable))};return window.addEventListener("markus:navigate",Mt),()=>window.removeEventListener("markus:navigate",Mt)},[gr,n]),g.useEffect(()=>{const et=Hr.current;!et||p.length===0||(Hr.current=null,gr(et))},[p,gr]);const Xr=g.useCallback(()=>{const et=re.current;!et||M||k||p.length>=x||et.scrollHeight<=et.clientHeight+100&&$n()},[M,k,p.length,x,$n]);g.useEffect(()=>{const et=re.current;if(!et)return;const Mt=()=>{et.scrollTop+et.clientHeight>=et.scrollHeight-100&&$n()};return et.addEventListener("scroll",Mt,{passive:!0}),()=>et.removeEventListener("scroll",Mt)},[$n]),g.useEffect(()=>{Xr()},[Xr,ie]);const kr=g.useMemo(()=>{const et=new Map;for(const Re of p){let tt,_t;if(K==="project"){const Ht=on(Re.projectId);tt=Ht?Re.projectId??"_none":"_none",_t=Ht??s("noProject")}else if(K==="agent")tt=Re.agentId??"_none",_t=Re.agentId?kn.get(Re.agentId)?.name??Re.agentId:s("common:unknown");else if(K==="type")tt=Re.type,_t=Re.type.charAt(0).toUpperCase()+Re.type.slice(1);else{const Ht=new Date(Re.updatedAt);tt=`${Ht.getFullYear()}-${String(Ht.getMonth()+1).padStart(2,"0")}-${String(Ht.getDate()).padStart(2,"0")}`,_t=tt}et.has(tt)||et.set(tt,{label:_t,items:[]}),et.get(tt).items.push(Re)}const Mt=[...et.entries()];return K==="date"?Mt.sort((Re,tt)=>tt[0].localeCompare(Re[0])):Mt.sort((Re,tt)=>Re[1].label.localeCompare(tt[1].label)),Mt},[p,K,Fn,kn,s]),Qn=async et=>{Y("remove");try{await ae.deliverables.remove(et.id),en("success",s("removed")),J(null),xn()}catch(Mt){en("error",s("common:error",{message:String(Mt)}))}Y("")},jr=()=>{vt.navigate(Oe.BUILDER)},ar=async et=>{if(et.reference&&!Hf(et.reference)){if(et.type==="directory"){ve(!0);return}Fe(!0);try{const Mt=await ae.files.preview(et.reference);Mt.type==="image"&&Mt.mimeType?ke({src:`data:${Mt.mimeType};base64,${Mt.content}`,name:Mt.name}):(Ae(Mt.content),$e(I8({format:et.format,reference:et.reference,content:Mt.content})))}catch{Ae(null),et.type==="file"&&ve(!0)}Fe(!1)}};g.useEffect(()=>{n||(Ae(null),$e("markdown"),ke(null),ve(!1),B&&ar(B))},[B?.id,n]);const An=g.useCallback(et=>{pe(Mt=>{const Re=new Set(Mt);return Re.has(et)?Re.delete(et):Re.add(et),Re})},[]),Rn=g.useCallback(()=>{ie.size===kr.length?pe(new Set):pe(new Set(kr.map(([et])=>et)))},[ie.size,kr]),Sr=et=>{J(et),it([]),a&&(Ke(!1),u(!0),history.pushState({mobileDetail:Oe.DELIVERABLES},"",window.location.hash))};g.useEffect(()=>{Me&&!a&&window.innerWidth<1280&&dt(!0)},[Me,a]);const In=g.useRef(null),zr=g.useCallback(et=>{const Mt=et.length>30?`${et.slice(0,15)}…${et.slice(-12)}`:et,Re=`sel_${Date.now()}`;it(tt=>[...tt,{id:Re,label:Mt,type:"selection",content:et,onRemove:()=>it(_t=>_t.filter(Ht=>Ht.id!==Re))}]),Me||Ke(!0),At(null),window.getSelection()?.removeAllRanges()},[Me]);return g.useEffect(()=>{const et=In.current;if(!et)return;const Mt=()=>{requestAnimationFrame(()=>{const tt=window.getSelection(),_t=tt?.toString().trim();if(!_t||!tt?.rangeCount){At(null);return}const Ht=tt.getRangeAt(0);if(!et.contains(Ht.commonAncestorContainer)){At(null);return}const qt=Ht.getBoundingClientRect();At({x:qt.left+qt.width/2,y:qt.top,text:_t})})},Re=tt=>{const _t=document.getElementById("selection-toolbar");_t&&_t.contains(tt.target)||At(null)};return et.addEventListener("mouseup",Mt),document.addEventListener("mousedown",Re),()=>{et.removeEventListener("mouseup",Mt),document.removeEventListener("mousedown",Re)}},[]),t.jsxs("div",{className:"flex-1 overflow-hidden flex",children:[t.jsxs("div",{className:`${a?"flex-1 min-w-0":"shrink-0"} flex flex-col bg-surface-secondary rounded-xl m-1 mr-0`,style:a?d?{display:"none"}:void 0:st?{display:"none"}:{width:l.width},children:[t.jsxs("div",{className:"p-4 space-y-3",children:[t.jsx("div",{className:"flex items-center justify-between gap-2",children:t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a&&t.jsx(Ac,{}),!a&&t.jsx("button",{onClick:()=>dt(!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:s("sidebar.collapse"),children:t.jsxs("svg",{width:"16",height:"16",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("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),t.jsxs("h2",{className:"text-sm font-semibold text-fg-secondary truncate",children:[s("title"),x>0&&t.jsxs("span",{className:"ml-1.5 text-fg-tertiary font-normal",children:["(",x,")"]})]})]})}),t.jsx("input",{value:L,onChange:et=>O(et.target.value),placeholder:s("searchPlaceholder"),className:"w-full bg-surface-elevated border border-border-default rounded-lg px-3 py-2 text-sm text-fg-primary focus:border-brand-500 focus:outline-none transition-colors"}),xe&&t.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:[t.jsx("span",{className:"truncate font-mono",children:xe}),t.jsx("button",{onClick:()=>{ae.system.openPath(xe)},className:"shrink-0 underline hover:text-fg-secondary transition-colors",children:s("common:open")})]}),t.jsxs("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:[t.jsx(t0,{label:s("filters.allTypes"),value:"",current:H||ee||"",onClick:()=>{q(""),F("")}}),Mie.map(et=>t.jsx(t0,{label:`${e0[et]?.icon??""} ${et}`,value:et,current:H,onClick:Mt=>{q(Mt),F("")}},et)),["agent","team","skill"].map(et=>t.jsx(t0,{label:`${uc[et].icon} ${s(`artifactTypes.${et}`)}`,value:et,current:ee,onClick:Mt=>{F(Mt),q("")}},et))]}),w.length>0&&t.jsxs("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:[t.jsx(t0,{label:s("filters.allProjects"),value:"",current:U,onClick:E}),w.map(et=>t.jsx(t0,{label:et.name,value:et.id,current:U,onClick:E},et.id))]}),t.jsxs("div",{className:"flex gap-1.5 items-center",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:s("filters.group")}),["date","project","agent","type"].map(et=>t.jsx("button",{onClick:()=>{Z(et),pe(new Set)},className:`px-2 py-1 rounded text-xs transition-colors ${K===et?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:bg-surface-overlay"}`,children:s(`groupBy.${et}`)},et)),kr.length>1&&t.jsx("button",{onClick:Rn,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:ie.size===kr.length?s("expandAllTooltip"):s("collapseAllTooltip"),children:ie.size===kr.length?s("expandAll"):s("collapseAll")})]})]}),Q&&t.jsx("div",{className:`mx-4 mt-2 px-3 py-1.5 text-xs rounded-lg ${Q.type==="success"?"bg-green-500/15 text-green-600":"bg-red-500/15 text-red-500"}`,children:Q.text}),t.jsxs("div",{ref:re,className:"flex-1 overflow-y-auto p-2 space-y-1",onTouchStart:a?me.onTouchStart:void 0,onTouchEnd:a?me.onTouchEnd:void 0,children:[M?t.jsx("div",{className:"p-4 space-y-3",children:[1,2,3].map(et=>t.jsxs("div",{className:"animate-pulse space-y-2",children:[t.jsx("div",{className:"h-4 bg-surface-elevated rounded w-3/4"}),t.jsx("div",{className:"h-3 bg-surface-elevated rounded w-1/2"})]},et))}):p.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-6 text-center",children:[t.jsx("svg",{className:"w-12 h-12 text-fg-muted mb-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:t.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"})}),t.jsx("p",{className:"text-sm text-fg-secondary",children:s("empty.title")}),t.jsx("p",{className:"text-xs text-fg-tertiary mt-1 mb-3",children:s("empty.subtitle")}),t.jsx("button",{onClick:()=>vt.navigate(Oe.WORK),className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:s("empty.goToWork")})]}):kr.map(([et,Mt])=>{const Re=ie.has(et);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>An(et),className:"w-full flex items-center gap-1.5 px-2 py-1.5 rounded-md hover:bg-surface-elevated/50 transition-colors group/header",children:[t.jsx("svg",{className:`w-3 h-3 text-fg-tertiary transition-transform duration-200 shrink-0 ${Re?"":"rotate-90"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),t.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider truncate",children:Mt.label}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:["(",Mt.items.length,")"]})]}),!Re&&Mt.items.map(tt=>t.jsx("button",{onClick:()=>Sr(tt),className:`w-full text-left px-3 py-2 rounded-lg transition-colors ${B?.id===tt.id?"bg-brand-600/20 border border-brand-500/30":"hover:bg-surface-elevated/60 border border-transparent"}`,children:t.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[tt.artifactType&&uc[tt.artifactType]?t.jsx("span",{className:`text-[10px] px-1 py-0.5 rounded font-medium shrink-0 ${uc[tt.artifactType].color}`,children:uc[tt.artifactType].icon}):t.jsx("span",{className:`text-[10px] px-1 py-0.5 rounded font-medium uppercase shrink-0 ${e0[tt.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:e0[tt.type]?.icon??tt.type.charAt(0)}),t.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:tt.title}),Se.has(tt.id)&&t.jsx("span",{className:"shrink-0 text-amber-500",title:s("detail.fileMissing"),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("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"}),t.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),t.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}),t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded shrink-0 ${Eie[tt.status]?.color??"bg-surface-elevated text-fg-tertiary"}`,children:s(`common:status.${tt.status}`,{defaultValue:tt.status})})]})},tt.id))]},et)}),k&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-fg-tertiary",children:[t.jsx(a6,{})," ",t.jsx("span",{className:"text-[10px]",children:s("common:loadingMore")})]}),!M&&p.length>0&&t.jsx("div",{className:"text-center text-[10px] text-fg-tertiary py-2",children:p.length<x?s("count.partial",{loaded:p.length,total:x}):s("count.total",{total:x})})]})]}),!a&&t.jsx("div",{className:"w-1.5 shrink-0 cursor-col-resize group relative flex items-center justify-center",onMouseDown:l.onResizeStart,children:t.jsx("div",{className:"w-px h-2/3 border-l border-dashed border-transparent group-hover:border-border-default group-active:border-fg-tertiary transition-colors"})}),(!a||d)&&t.jsxs("div",{className:"flex-1 overflow-hidden min-w-0 flex relative",children:[t.jsxs("div",{ref:In,className:"flex-1 overflow-y-auto min-w-0",children:[st&&!a&&t.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:[t.jsx("button",{onClick:()=>dt(!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:s("sidebar.expand"),children:t.jsxs("svg",{width:"16",height:"16",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("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),t.jsx("span",{className:"text-sm font-medium text-fg-secondary truncate",children:B?.title??s("detail.details")})]}),a&&t.jsxs("div",{className:"sticky top-0 z-10 bg-surface-secondary px-4 py-2.5 flex items-center gap-2",children:[t.jsx("button",{onClick:()=>history.back(),className:"text-fg-secondary hover:text-fg-primary transition-colors p-1 -ml-1",children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"15 18 9 12 15 6"})})}),t.jsx("span",{className:"text-sm font-medium truncate",children:B?.title??s("detail.details")})]}),B?t.jsxs("div",{className:"p-6 space-y-4",children:[!n&&Se.has(B.id)&&t.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:[t.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:[t.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"}),t.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),t.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),t.jsx("span",{children:s("detail.fileMissing")})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsx("h2",{className:"text-xl font-semibold text-fg-primary",children:B.title}),!n&&t.jsx("button",{onClick:()=>Te(B),disabled:!!te,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:s("common:remove"),children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.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"})]})})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("span",{className:`px-2 py-0.5 rounded text-xs font-medium uppercase ${e0[B.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:[e0[B.type]?.icon??""," ",B.type]}),B.artifactType&&uc[B.artifactType]&&t.jsxs("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${uc[B.artifactType].color}`,children:[uc[B.artifactType].icon," ",s("detail.builderWithType",{type:s(`artifactTypes.${B.artifactType}`)})]}),B.tags.length>0&&B.tags.map(et=>t.jsx("span",{className:"px-2 py-0.5 text-xs bg-surface-elevated text-fg-secondary rounded",children:et},et))]}),(B.taskId||B.agentId||on(B.projectId))&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[B.taskId&&t.jsx("button",{onClick:()=>vt.navigate(Oe.WORK,{openTask:B.taskId}),className:"text-xs text-brand-500 hover:underline bg-brand-500/10 px-2 py-0.5 rounded",children:s("links.task",{id:`${B.taskId.slice(0,12)}...`})}),B.agentId&&t.jsx("button",{onClick:()=>vt.navigate(Oe.TEAM,{selectAgent:B.agentId}),className:"text-xs text-blue-600 hover:underline bg-blue-500/10 px-2 py-0.5 rounded",children:s("links.agent",{name:kn.get(B.agentId)?.name??B.agentId.slice(0,12)})}),on(B.projectId)&&t.jsx("button",{onClick:()=>vt.navigate(Oe.WORK,{projectId:B.projectId}),className:"text-xs text-blue-600 hover:underline bg-blue-500/10 px-2 py-0.5 rounded",children:s("links.project",{name:on(B.projectId)})})]}),(B.diffStats||B.testResults)&&t.jsxs("div",{className:"flex gap-3 flex-wrap",children:[B.diffStats&&t.jsxs("div",{className:"bg-surface-elevated rounded-lg px-3 py-2 text-xs flex items-center gap-2",children:[t.jsxs("span",{className:"text-fg-tertiary font-medium",children:[s("diffStats.title"),":"]}),t.jsx("span",{className:"text-fg-secondary",children:s("diffStats.files",{count:B.diffStats.filesChanged})}),t.jsxs("span",{className:"text-green-600",children:["+",B.diffStats.additions]}),t.jsxs("span",{className:"text-red-500",children:["-",B.diffStats.deletions]})]}),B.testResults&&t.jsxs("div",{className:"bg-surface-elevated rounded-lg px-3 py-2 text-xs flex items-center gap-2",children:[t.jsxs("span",{className:"text-fg-tertiary font-medium",children:[s("testResults.title"),":"]}),t.jsx("span",{className:"text-green-600",children:s("testResults.passed",{count:B.testResults.passed})}),t.jsx("span",{className:"text-red-500",children:s("testResults.failed",{count:B.testResults.failed})}),t.jsx("span",{className:"text-fg-secondary",children:s("testResults.skipped",{count:B.testResults.skipped})})]})]}),t.jsxs("div",{className:"flex items-center gap-4 text-[10px] text-fg-tertiary flex-wrap",children:[t.jsxs("span",{children:[s("metadata.created")," ",new Date(B.createdAt).toLocaleDateString()]}),t.jsxs("span",{children:[s("metadata.updated")," ",new Date(B.updatedAt).toLocaleDateString()]}),t.jsx("span",{className:"text-fg-muted select-all",children:B.id.slice(0,12)})]}),B.reference&&!Hf(B.reference)&&B.type==="file"&&t.jsxs("div",{className:"flex items-center gap-2 bg-surface-elevated rounded-lg px-3 py-2",children:[t.jsx("button",{onClick:()=>{ae.files.reveal(B.reference).catch(()=>en("error",s("detail.failedToOpenBrowser")))},className:"text-xs font-mono text-brand-500 hover:text-brand-500 hover:underline truncate flex-1 text-left cursor-pointer",title:s("detail.openInFileBrowser"),children:B.reference}),t.jsx("button",{onClick:()=>{ae.files.reveal(B.reference).catch(()=>en("error",s("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:s("detail.revealInFinder"),children:s("common:open")}),t.jsx("button",{onClick:()=>tn(B.reference),className:`px-2 py-1 text-[10px] rounded transition-colors shrink-0 ${be?"bg-green-500/20 text-green-600":"bg-surface-overlay/50 text-fg-secondary hover:bg-surface-overlay"}`,title:s("detail.copyPath"),children:s(be?"common:copied":"common:copy")})]}),B.reference&&!Hf(B.reference)&&B.type!=="file"&&B.type!=="directory"&&t.jsx("span",{className:"text-xs text-fg-tertiary font-mono break-all",children:B.reference})]}),B.artifactType&&B.artifactData?t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:t.jsx(Nie,{artifact:B.artifactData,mode:B.artifactType})}),B.reference&&t.jsxs("div",{className:"px-3 py-2 bg-surface-elevated rounded-lg",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider block mb-1",children:s("detail.artifactDirectory")}),t.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all",children:B.reference})]}),t.jsx("div",{className:"flex gap-2",children:t.jsx("button",{onClick:jr,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:s("detail.openInBuilder")})}),B.summary&&t.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:t.jsx(Gr,{content:B.summary,className:"text-fg-secondary text-sm"})})]}):B.reference&&Hf(B.reference)?t.jsxs("div",{className:"space-y-4",children:[B.summary&&t.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:t.jsx(Gr,{content:B.summary,className:"text-fg-secondary text-sm"})}),t.jsxs("div",{className:"flex flex-col items-center justify-center py-10",children:[t.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:[t.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),t.jsx("polyline",{points:"15 3 21 3 21 9"}),t.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),t.jsx("p",{className:"text-xs text-fg-tertiary font-mono mb-4 px-4 text-center break-all select-all",children:B.reference}),t.jsx("button",{onClick:()=>window.open(B.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:s("detail.openUrl")})]})]}):B.type==="directory"&&B.reference?t.jsxs("div",{className:"space-y-4",children:[B.summary&&t.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:t.jsx(Gr,{content:B.summary,className:"text-fg-secondary text-sm"})}),t.jsxs("div",{className:"flex flex-col items-center justify-center py-10",children:[t.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:t.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"})}),t.jsx("p",{className:"text-xs text-fg-tertiary font-mono mb-4 px-4 text-center break-all select-all",children:B.reference}),t.jsx("button",{onClick:()=>{ae.files.reveal(B.reference).catch(()=>en("error",s("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:s("detail.openInFileBrowser")})]})]}):t.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:We?t.jsxs("div",{className:"flex items-center gap-2 text-fg-tertiary text-sm",children:[t.jsx(a6,{})," ",s("detail.loadingPreview")]}):we?t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx("img",{src:we.src,alt:we.name,className:"max-w-full max-h-[60vh] rounded-lg object-contain"}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:we.name})]}):Ne?t.jsx(tv,{content:Ne,format:_e,className:"text-fg-secondary text-sm"}):ue?t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"text-sm text-fg-secondary",children:s("detail.cannotPreview",{type:B.type})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:()=>{ae.files.reveal(B.reference).catch(()=>en("error",s("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:s("detail.openInFileBrowser"),children:B.reference}),t.jsx("button",{onClick:()=>{ae.files.reveal(B.reference).catch(()=>en("error",s("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:s("common:open")}),t.jsx("button",{onClick:()=>tn(B.reference),className:`px-3 py-2 text-xs rounded-lg transition-colors shrink-0 ${be?"bg-green-500/20 text-green-600":"bg-surface-overlay/50 text-fg-secondary hover:bg-surface-overlay"}`,children:s(be?"common:copied":"common:copy")})]})]}):B.summary?t.jsx(Gr,{content:B.summary,className:"text-fg-secondary text-sm"}):t.jsx("p",{className:"text-sm text-fg-tertiary italic",children:s("detail.noContent")})})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center h-full",children:t.jsxs("div",{className:"text-center text-fg-tertiary space-y-2",children:[t.jsx("svg",{className:"w-12 h-12 mx-auto text-fg-muted",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:t.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"})}),t.jsx("p",{className:"text-sm",children:s("detail.selectToView")})]})})]}),B?.agentId&&!Me&&!a&&t.jsx("button",{onClick:()=>Ke(!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",title:s("chat.openChat"),children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.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"})})}),Me&&B?.agentId&&!a&&t.jsx(Aie,{agentId:B.agentId,agents:j,authUser:e,onClose:()=>{Ke(!1),it([])},contextChips:[{id:`deliverable_ctx_${B.id}`,label:`📦 ${B.title}`,type:"deliverable",content:`${s("chat.currentDeliverable")}: ${B.title} (id: ${B.id})`},...pt],width:400})]}),Ye&&t.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:Ye.x,top:Ye.y-8},children:t.jsxs("button",{onMouseDown:et=>{et.preventDefault(),et.stopPropagation(),zr(Ye.text)},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:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.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"})}),s("contextMenu.addToConversation")]})}),se&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:()=>Te(null),children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 max-w-sm mx-4 shadow-2xl",onClick:et=>et.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[t.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/15 flex items-center justify-center shrink-0",children:t.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:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.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"})]})}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:s("detail.confirmRemoveTitle")}),t.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:s("detail.confirmRemoveMessage",{name:se.title})})]})]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{onClick:()=>Te(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:s("common:cancel")}),t.jsx("button",{onClick:()=>{const et=se;Te(null),Qn(et)},disabled:!!te,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:s("common:remove")})]})]})})]})}function t0({label:e,value:n,current:r,onClick:s}){return t.jsx("button",{onClick:()=>s(r===n?"":n),className:`px-2 py-1 rounded text-xs whitespace-nowrap shrink-0 transition-colors ${r===n?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:bg-surface-overlay"}`,children:e})}function a6(){return t.jsxs("svg",{className:"animate-spin h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}function Do(e){return e.toLocaleString()}function Cd(e){return e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function Rie(e){return e>=1024*1024*1024?`${(e/(1024*1024*1024)).toFixed(1)} GB`:e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${(e/1024).toFixed(1)} KB`:`${e} B`}function i6({authUser:e}){const{t:n}=ft(["reports","common"]),r=Os(),s=Qd(Oe.REPORTS),[a,i]=g.useState("weekly"),[l,d]=g.useState(null),[u,m]=g.useState(!0),[h,p]=g.useState(""),[b,x]=g.useState(null),[v,k]=g.useState([]),[C,w]=g.useState("totalTokens"),[N,j]=g.useState(!0),[T,M]=g.useState("generate"),[D,L]=g.useState([]),[O,P]=g.useState(null),[R,H]=g.useState([]),[q,U]=g.useState(""),[E,z]=g.useState(""),I=Y=>{z(Y),setTimeout(()=>z(""),3e3)},_=g.useCallback(async Y=>{m(!0),p("");try{const{report:ie}=await ae.reports.generate({period:Y,scope:"org",orgId:"default"});d(ie)}catch(ie){p(String(ie)),d(null)}m(!1)},[]),W=g.useCallback(()=>{ae.usage.summary().then(Y=>x(Y.usage)).catch(()=>{}),ae.usage.agents().then(Y=>k(Y.agents)).catch(()=>{})},[]),ee=g.useCallback(async()=>{try{const{reports:Y}=await ae.reports.list();L(Y)}catch{}},[]),F=g.useCallback(async Y=>{P(Y);try{const{feedback:ie}=await ae.reports.getFeedback(Y.id);H(ie)}catch{H([])}},[]);g.useEffect(()=>{_(a)},[a,_]),g.useEffect(()=>{if(!s)return;W();const Y=setInterval(W,3e4);return()=>clearInterval(Y)},[W,s]),g.useEffect(()=>{T==="history"&&ee()},[T,ee]);const K=g.useMemo(()=>[...v].sort((Y,ie)=>{const pe=Y[C],ge=ie[C];return N?ge-pe:pe-ge}),[v,C,N]),Z=v.reduce((Y,ie)=>Y+ie.estimatedCost,0),B=v.reduce((Y,ie)=>Y+ie.tokensUsedToday,0),J=v.reduce((Y,ie)=>Y+(ie.costToday??0),0),Q=Math.max(1,...v.map(Y=>Y.totalTokens)),ne=Y=>{C===Y?j(!N):(w(Y),j(!0))},te=g.useMemo(()=>({daily:n("period.today"),weekly:n("period.thisWeek"),monthly:n("period.thisMonth")}),[n]);return t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsxs("div",{className:"max-w-5xl mx-auto w-full p-6 space-y-6",children:[t.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-center md:justify-between",children:[t.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[r&&t.jsx(Ac,{}),t.jsx("h1",{className:"text-xl font-semibold text-fg-primary",children:n("title")}),t.jsxs("div",{className:"flex gap-1 bg-surface-elevated rounded-lg p-0.5",children:[t.jsx("button",{onClick:()=>M("generate"),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${T==="generate"?"bg-surface-overlay text-fg-primary shadow-sm":"text-fg-tertiary hover:text-fg-secondary"}`,children:n("tabs.generate")}),t.jsxs("button",{onClick:()=>M("history"),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${T==="history"?"bg-surface-overlay text-fg-primary shadow-sm":"text-fg-tertiary hover:text-fg-secondary"}`,children:[n("tabs.history"),D.length>0?` (${D.length})`:""]})]})]}),t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[E&&t.jsx("span",{className:"px-2.5 py-1 bg-green-500/10 text-green-600 text-xs rounded-lg",children:E}),T==="generate"&&t.jsx("div",{className:"flex gap-1 bg-surface-elevated rounded-lg p-0.5",children:["daily","weekly","monthly"].map(Y=>t.jsx("button",{onClick:()=>i(Y),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${a===Y?"bg-surface-overlay text-fg-primary shadow-sm":"text-fg-tertiary hover:text-fg-secondary"}`,children:n(`period.${Y}`)},Y))})]})]}),T==="history"&&!O&&t.jsx("section",{className:"bg-surface-elevated rounded-xl overflow-hidden",children:D.length===0?t.jsx("div",{className:"p-8 text-center text-fg-tertiary text-sm",children:n("noReportsYet")}):t.jsx("div",{className:"divide-y divide-border-default/50",children:D.map(Y=>t.jsxs("button",{onClick:()=>F(Y),className:"w-full text-left px-5 py-3 flex items-center gap-4 hover:bg-surface-elevated/30 transition-colors",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:n("reportType",{type:Y.type})}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:[new Date(Y.periodStart).toLocaleDateString()," — ",new Date(Y.periodEnd).toLocaleDateString()]})]}),Y.plan&&t.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium shrink-0 ${Y.plan.status==="approved"?"bg-green-500/10 text-green-600":Y.plan.status==="rejected"?"bg-red-500/10 text-red-500":"bg-amber-500/10 text-amber-600"}`,children:Y.plan.status==="pending"?n("upcomingPlan.planPending"):n("upcomingPlan.planStatus",{status:Y.plan.status})}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date(Y.generatedAt).toLocaleDateString()})]},Y.id))})}),T==="history"&&O&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>{P(null),H([])},className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:n("backToList")}),t.jsx("span",{className:"text-sm font-medium text-fg-primary",children:n("reportType",{type:O.type})}),t.jsxs("span",{className:"text-xs text-fg-tertiary",children:[new Date(O.periodStart).toLocaleDateString()," — ",new Date(O.periodEnd).toLocaleDateString()]})]}),O.metrics&&t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:n("taskMetrics.title")}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[t.jsx(Yi,{label:n("taskMetrics.completed"),value:O.metrics.tasksCompleted,color:"text-green-600"}),t.jsx(Yi,{label:n("taskMetrics.inProgress"),value:O.metrics.tasksInProgress,color:"text-brand-500"}),t.jsx(Yi,{label:n("taskMetrics.created"),value:O.metrics.tasksCreated,color:"text-blue-600"}),t.jsx(Yi,{label:n("taskMetrics.blocked"),value:O.metrics.tasksBlocked,color:"text-amber-600"}),t.jsx(Yi,{label:n("taskMetrics.failed"),value:O.metrics.tasksFailed,color:"text-red-500"})]})]}),O.costSummary&&t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:n("costOverview.title")}),t.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:O.costSummary.totalTokens.toLocaleString()}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:n("costOverview.totalTokens")})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:Cd(O.costSummary.totalEstimatedCost)}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:n("costOverview.estimatedCost")})]}),t.jsxs("div",{children:[t.jsxs("div",{className:`text-2xl font-bold ${O.costSummary.trend==="decreasing"?"text-green-600":O.costSummary.trend==="increasing"?"text-red-500":"text-fg-primary"}`,children:[O.costSummary.trend==="decreasing"?"↓":O.costSummary.trend==="increasing"?"↑":"→"," ",O.costSummary.trend]}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:n("costOverview.trend")})]})]}),O.costSummary.byAgent&&O.costSummary.byAgent.length>0&&t.jsx("div",{className:"mt-4 pt-3 border-t border-border-default/50 space-y-1.5",children:O.costSummary.byAgent.map((Y,ie)=>t.jsxs("div",{className:"flex items-center justify-between text-xs",children:[t.jsx("span",{className:"text-fg-secondary",children:Y.agentId}),t.jsx("span",{className:"text-fg-tertiary tabular-nums",children:n("costOverview.byAgentRow",{tokens:Do(Y.tokens),cost:Cd(Y.cost)})})]},ie))})]}),O.taskSummary&&t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5 overflow-hidden",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:n("taskSummary.title")}),t.jsxs("div",{className:"space-y-4 min-w-0",children:[O.taskSummary.completed.length>0&&t.jsx(kd,{title:n("taskSummary.completedCount",{count:O.taskSummary.completed.length}),color:"emerald",items:O.taskSummary.completed.map(Y=>({id:Y.id,label:Y.title,sub:Y.agent}))}),O.taskSummary.inProgress.length>0&&t.jsx(kd,{title:n("taskSummary.inProgressCount",{count:O.taskSummary.inProgress.length}),color:"indigo",items:O.taskSummary.inProgress.map(Y=>({id:Y.id,label:Y.title,sub:Y.agent}))}),O.taskSummary.blocked.length>0&&t.jsx(kd,{title:n("taskSummary.blockedCount",{count:O.taskSummary.blocked.length}),color:"amber",items:O.taskSummary.blocked.map(Y=>({id:Y.id,label:Y.title,sub:Y.reason||Y.agent}))}),O.taskSummary.completed.length===0&&O.taskSummary.inProgress.length===0&&O.taskSummary.blocked.length===0&&t.jsx("p",{className:"text-sm text-fg-tertiary",children:n("taskSummary.noTasksInPeriod")})]})]}),O.highlights&&O.highlights.length>0&&t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-2",children:n("highlights")}),t.jsx("ul",{className:"list-disc list-inside space-y-1 text-sm text-fg-secondary",children:O.highlights.map((Y,ie)=>t.jsx("li",{children:Y},ie))})]}),O.blockers&&O.blockers.length>0&&t.jsxs("section",{className:"bg-surface-secondary border border-amber-500/20 rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-amber-600 mb-2",children:n("blockers")}),t.jsx("ul",{className:"list-disc list-inside space-y-1 text-sm text-fg-secondary",children:O.blockers.map((Y,ie)=>t.jsx("li",{children:Y},ie))})]}),O.plan&&t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("h3",{className:"text-xs font-semibold text-fg-secondary",children:[n("upcomingPlan.title"),t.jsx("span",{className:`ml-2 px-1.5 py-0.5 rounded text-[10px] font-medium ${O.plan.status==="approved"?"bg-green-500/10 text-green-600":O.plan.status==="rejected"?"bg-red-500/10 text-red-500":"bg-amber-500/10 text-amber-600"}`,children:n(`common:status.${O.plan.status}`,{defaultValue:O.plan.status})})]}),O.plan.status==="pending"&&t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:async()=>{try{const{report:Y}=await ae.reports.approvePlan(O.id,{approvedBy:e?.id??"unknown"});P(Y),I(n("upcomingPlan.planApproved")),ee()}catch(Y){I(n("common:error",{message:String(Y)}))}},className:"px-3 py-1.5 text-xs font-medium bg-green-600 text-white rounded-lg hover:bg-green-500 transition-colors",children:n("upcomingPlan.approvePlan")}),t.jsx("button",{onClick:async()=>{const Y=prompt(n("upcomingPlan.rejectionReason"));if(Y)try{const{report:ie}=await ae.reports.rejectPlan(O.id,{rejectedBy:e?.id??"unknown",reason:Y});P(ie),I(n("upcomingPlan.planRejected")),ee()}catch(ie){I(n("common:error",{message:String(ie)}))}},className:"px-3 py-1.5 text-xs font-medium border border-border-default text-fg-secondary rounded-lg hover:bg-surface-overlay transition-colors",children:n("upcomingPlan.rejectPlan")})]})]}),O.plan.items&&O.plan.items.length>0&&t.jsx("div",{className:"space-y-1.5",children:O.plan.items.map((Y,ie)=>t.jsxs("div",{className:"flex items-center gap-2 text-sm text-fg-secondary",children:[t.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${Y.priority==="high"?"bg-red-500/10 text-red-500":Y.priority==="medium"?"bg-amber-500/10 text-amber-600":"bg-gray-500/10 text-fg-tertiary"}`,children:Y.priority}),t.jsx("span",{children:Y.title}),Y.assignee&&t.jsx("span",{className:"text-[10px] text-fg-tertiary ml-auto",children:Y.assignee})]},ie))})]}),!O.metrics&&!O.taskSummary&&!O.costSummary&&t.jsx("section",{className:"bg-surface-elevated rounded-xl p-8 text-center",children:t.jsx("p",{className:"text-sm text-fg-tertiary",children:n("noDetailedMetrics")})}),t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:n("feedback.title",{count:R.length})}),R.length>0&&t.jsx("div",{className:"space-y-2 mb-4",children:R.map(Y=>t.jsxs("div",{className:"p-3 bg-surface-elevated/50 rounded-lg",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary mb-1",children:[t.jsx("span",{className:"font-medium text-fg-secondary",children:Y.authorName}),t.jsx("span",{children:Y.type}),t.jsx("span",{children:new Date(Y.createdAt).toLocaleDateString()})]}),t.jsx("p",{className:"text-xs text-fg-secondary",children:Y.content})]},Y.id))}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{value:q,onChange:Y=>U(Y.target.value),placeholder:n("feedback.placeholder"),className:"flex-1 px-3 py-2 text-xs bg-surface-elevated border border-border-default rounded-lg text-fg-primary placeholder:text-fg-tertiary",onKeyDown:Y=>{Y.key==="Enter"&&q.trim()&&ae.reports.addFeedback(O.id,{author:e?.id??"unknown",type:"comment",content:q.trim()}).then(({feedback:ie})=>{H(pe=>[...pe,ie]),U(""),I(n("feedback.added"))}).catch(ie=>I(n("common:error",{message:String(ie)})))}}),t.jsx("button",{onClick:()=>{q.trim()&&ae.reports.addFeedback(O.id,{author:e?.id??"unknown",type:"comment",content:q.trim()}).then(({feedback:Y})=>{H(ie=>[...ie,Y]),U(""),I(n("feedback.added"))}).catch(Y=>I(n("common:error",{message:String(Y)})))},disabled:!q.trim(),className:"px-3 py-2 text-xs bg-brand-600 text-white rounded-lg hover:bg-brand-500 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:n("common:send")})]})]})]}),T==="generate"&&b&&t.jsxs("div",{className:`grid gap-4 ${b.storageBytes>0?"grid-cols-2 lg:grid-cols-4":"grid-cols-3"}`,children:[t.jsx(Ff,{label:n("usage.llmTokens"),value:Do(b.llmTokens),color:"text-brand-500"}),t.jsx(Ff,{label:n("usage.toolCalls"),value:Do(b.toolCalls),color:"text-blue-600"}),t.jsx(Ff,{label:n("usage.messages"),value:Do(b.messages),color:"text-green-600"}),b.storageBytes>0&&t.jsx(Ff,{label:n("usage.storage"),value:Rie(b.storageBytes),color:"text-amber-600"})]}),T==="generate"&&(u?t.jsx("div",{className:"flex items-center justify-center h-32 text-fg-tertiary text-sm",children:n("common:loading")}):h?t.jsx("div",{className:"flex items-center justify-center h-32 text-red-500 text-sm",children:h}):l?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[te[a]," · ",new Date(l.periodStart).toLocaleDateString()," — ",new Date(l.periodEnd).toLocaleDateString()]}),l.metrics&&t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:n("taskMetrics.title")}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[t.jsx(Yi,{label:n("taskMetrics.completed"),value:l.metrics.tasksCompleted,color:"text-green-600"}),t.jsx(Yi,{label:n("taskMetrics.inProgress"),value:l.metrics.tasksInProgress,color:"text-brand-500"}),t.jsx(Yi,{label:n("taskMetrics.created"),value:l.metrics.tasksCreated,color:"text-blue-600"}),t.jsx(Yi,{label:n("taskMetrics.blocked"),value:l.metrics.tasksBlocked,color:"text-amber-600"}),t.jsx(Yi,{label:n("taskMetrics.failed"),value:l.metrics.tasksFailed,color:"text-red-500"})]})]}),t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:n("costOverview.title")}),t.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:Cd(Z)}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:n("costOverview.estCostAllTime")})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:Do(B)}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:n("costOverview.tokensToday")})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:Cd(J)}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:n("costOverview.costToday")})]})]})]}),l.taskSummary&&t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:n("taskSummary.title")}),t.jsxs("div",{className:"space-y-4",children:[l.taskSummary.completed.length>0&&t.jsx(kd,{title:n("taskSummary.completedCount",{count:l.taskSummary.completed.length}),color:"emerald",items:l.taskSummary.completed.map(Y=>({id:Y.id,label:Y.title,sub:Y.agent}))}),l.taskSummary.inProgress.length>0&&t.jsx(kd,{title:n("taskSummary.inProgressCount",{count:l.taskSummary.inProgress.length}),color:"indigo",items:l.taskSummary.inProgress.map(Y=>({id:Y.id,label:Y.title,sub:Y.agent}))}),l.taskSummary.blocked.length>0&&t.jsx(kd,{title:n("taskSummary.blockedCount",{count:l.taskSummary.blocked.length}),color:"amber",items:l.taskSummary.blocked.map(Y=>({id:Y.id,label:Y.title,sub:Y.reason||Y.agent}))}),l.taskSummary.completed.length===0&&l.taskSummary.inProgress.length===0&&l.taskSummary.blocked.length===0&&t.jsx("p",{className:"text-sm text-fg-tertiary",children:n("taskSummary.noTasksInPeriod")})]})]})]}):null),T==="generate"&&t.jsxs("section",{className:"bg-surface-elevated rounded-xl overflow-hidden",children:[t.jsx("div",{className:"px-5 py-4 border-b border-border-default",children:t.jsx("h3",{className:"text-sm font-semibold text-fg-secondary",children:n("perAgentUsage.title")})}),v.length===0?t.jsx("div",{className:"p-8 text-center text-fg-tertiary text-sm",children:n("perAgentUsage.noData")}):t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-border-default text-xs text-fg-tertiary uppercase tracking-wider",children:[t.jsx("th",{className:"px-4 py-3 text-left font-medium",children:n("perAgentUsage.agent")}),t.jsx(n0,{label:n("perAgentUsage.totalTokens"),col:"totalTokens",current:C,desc:N,onSort:ne}),t.jsx(n0,{label:n("perAgentUsage.today"),col:"tokensUsedToday",current:C,desc:N,onSort:ne}),t.jsx(n0,{label:n("perAgentUsage.requests"),col:"requestCount",current:C,desc:N,onSort:ne}),t.jsx(n0,{label:n("perAgentUsage.toolCalls"),col:"toolCalls",current:C,desc:N,onSort:ne}),t.jsx(n0,{label:n("perAgentUsage.estCost"),col:"estimatedCost",current:C,desc:N,onSort:ne,align:"right"})]})}),t.jsx("tbody",{children:K.map(Y=>t.jsx(Iie,{agent:Y,maxTokens:Q},Y.agentId))}),t.jsx("tfoot",{children:t.jsxs("tr",{className:"border-t border-border-default bg-surface-elevated/30",children:[t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary",children:n("perAgentUsage.totalAgents",{count:v.length})}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:Do(v.reduce((Y,ie)=>Y+ie.totalTokens,0))}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:Do(B)}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:v.reduce((Y,ie)=>Y+ie.requestCount,0)}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:v.reduce((Y,ie)=>Y+ie.toolCalls,0)}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-right text-fg-secondary tabular-nums",children:Cd(Z)})]})})]})})]})]})})}function Yi({label:e,value:n,color:r}){return t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:`text-2xl font-bold ${r}`,children:n}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:e})]})}function kd({title:e,color:n,items:r}){return t.jsxs("div",{className:"min-w-0 overflow-hidden",children:[t.jsx("div",{className:`text-xs font-medium text-${n}-400 mb-1.5`,children:e}),t.jsx("div",{className:"space-y-1.5",children:r.map((s,a)=>t.jsxs("div",{className:`text-sm text-fg-secondary min-w-0 ${s.id?"cursor-pointer hover:text-fg-primary group":""}`,onClick:s.id?()=>vt.navigate(Oe.WORK,{openTask:s.id}):void 0,children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full bg-${n}-500 shrink-0`}),t.jsx("span",{className:`truncate min-w-0 ${s.id?"group-hover:text-brand-500 transition-colors":""}`,children:s.label})]}),s.sub&&s.sub!=="unassigned"&&t.jsx("div",{className:"text-[10px] text-fg-tertiary ml-3.5 mt-0.5 break-all line-clamp-2",children:s.sub})]},s.id??a))})]})}function Ff({label:e,value:n,color:r}){return t.jsxs("div",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsx("div",{className:"text-sm text-fg-secondary mb-2",children:e}),t.jsx("div",{className:`text-2xl font-bold ${r}`,children:n})]})}function n0({label:e,col:n,current:r,desc:s,onSort:a,align:i}){const l=r===n?s?"↓":"↑":"↕",d=r===n?"text-brand-500":"text-fg-muted";return t.jsxs("th",{className:`px-4 py-3 ${i==="right"?"text-right":"text-left"} font-medium cursor-pointer select-none hover:text-fg-secondary`,onClick:()=>a(n),children:[e,t.jsx("span",{className:`ml-1 ${d}`,children:l})]})}function Iie({agent:e,maxTokens:n}){const r=n>0?Math.min(100,e.totalTokens/n*100):0,s=e.status==="working"?"bg-blue-500":e.status==="idle"?"bg-green-500":e.status==="paused"?"bg-amber-500":e.status==="error"?"bg-red-500":"bg-gray-600";return t.jsxs("tr",{className:"border-b border-border-default/50 hover:bg-surface-elevated/30 transition-colors cursor-pointer",onClick:()=>vt.navigate(Oe.TEAM,{selectAgent:e.agentId}),children:[t.jsx("td",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex items-center gap-2.5",children:[t.jsx("div",{className:`w-2 h-2 rounded-full ${s}`}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary hover:text-brand-500 transition-colors",children:e.agentName}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:e.role})]})]})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"flex-1 bg-surface-elevated rounded-full h-1.5 overflow-hidden max-w-[120px]",children:t.jsx("div",{className:"h-full bg-brand-500 rounded-full",style:{width:`${r}%`}})}),t.jsx("span",{className:"text-sm text-fg-secondary tabular-nums",children:Do(e.totalTokens)})]})}),t.jsx("td",{className:"px-4 py-3 text-sm text-fg-secondary tabular-nums",children:Do(e.tokensUsedToday)}),t.jsx("td",{className:"px-4 py-3 text-sm text-fg-secondary tabular-nums",children:e.requestCount}),t.jsx("td",{className:"px-4 py-3 text-sm text-fg-secondary tabular-nums",children:e.toolCalls}),t.jsx("td",{className:"px-4 py-3 text-sm text-right text-fg-secondary tabular-nums",children:Cd(e.estimatedCost)})]})}const qf={urgent:"bg-red-500",high:"bg-amber-500",normal:"bg-blue-500",low:"bg-gray-400"},jd={approval_request:"M9 12l2 2 4-4 M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z",task_completed:"M22 11.08V12a10 10 0 1 1-5.93-9.14 M22 4L12 14.01l-3-3",task_created:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",task_review:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",task_failed:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",requirement_created:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7 M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z",requirement_decision:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",agent_report:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8",direct_message:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",group_message:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2 M9 7a4 4 0 1 0 0-8 4 4 0 0 0 0 8z M23 21v-2a4 4 0 0 0-3-3.87 M16 3.13a4 4 0 0 1 0 7.75",system:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"},o6={approval_request:"text-amber-500",task_completed:"text-green-500",task_failed:"text-red-500",task_created:"text-blue-500",task_review:"text-purple-500",requirement_created:"text-amber-500",requirement_decision:"text-green-500",agent_report:"text-blue-500",direct_message:"text-green-500",group_message:"text-brand-500",system:"text-fg-tertiary"};function Nd(e,n){const r=Date.now()-new Date(e).getTime(),s=Math.floor(r/6e4);if(s<1)return n("common:time.now");if(s<60)return n("common:time.minutesAgo",{count:s});const a=Math.floor(s/60);return a<24?n("common:time.hoursAgo",{count:a}):n("common:time.daysAgo",{count:Math.floor(a/24)})}function Uf(e,n){const r=e.actionType;if(r==="open_chat")return n("team:notifications.actionHints.openChat");if(r==="navigate")return n("team:notifications.actionHints.viewDetails");const s=e.metadata??{};switch(e.type){case"task_completed":case"task_created":case"task_review":case"task_failed":return s.taskId?n("team:notifications.actionHints.viewTask"):null;case"requirement_created":case"requirement_decision":return s.requirementId?n("team:notifications.actionHints.viewRequirement"):null;case"agent_report":return s.agentId?n("team:notifications.actionHints.viewAgent"):null;case"direct_message":return n("team:notifications.actionHints.openChat");case"group_message":return n("team:notifications.actionHints.openChat");case"approval_request":return n("team:notifications.actionHints.viewApproval");default:return s.taskId?n("team:notifications.actionHints.viewTask"):s.requirementId?n("team:notifications.actionHints.viewRequirement"):s.agentId?n("team:notifications.actionHints.viewAgent"):null}}function Die(){try{const e=new AudioContext,n=e.currentTime,r=e.createGain();r.connect(e.destination),r.gain.setValueAtTime(.15,n),r.gain.exponentialRampToValueAtTime(.01,n+.6);const s=e.createOscillator();s.type="sine",s.frequency.setValueAtTime(880,n),s.frequency.setValueAtTime(1174.66,n+.15),s.connect(r),s.start(n),s.stop(n+.6),s.onended=()=>e.close()}catch{}}function AT({collapsed:e,userId:n,embeddedMode:r,onClose:s,sidebarMode:a,isActive:i,label:l,iconPath:d}){const{t:u}=ft(["team","common"]),[m,h]=g.useState(!1),[p,b]=g.useState("approvals"),[x,v]=g.useState([]),[k,C]=g.useState([]),[w,N]=g.useState(null),[j,T]=g.useState(null),[M,D]=g.useState({}),[L,O]=g.useState(0),P=g.useRef(null),R=g.useRef(null),[H,q]=g.useState({top:0,left:0,width:448,maxHeight:576}),U=g.useRef(null),E=g.useRef(!1),[z,I]=g.useState(!0),[_,W]=g.useState(!1),ee=g.useRef(null),F=g.useRef("approvals"),K=30,Z=g.useCallback(async()=>{try{const[V,se]=await Promise.all([ae.notifications.list(n,!1,{limit:K,offset:0}),ae.approvals.list()]);if(v(V.notifications),O(V.unreadCount??V.notifications.filter(Te=>!Te.read).length),I(V.totalCount!=null?V.notifications.length<V.totalCount:V.notifications.length>=K),C(se.approvals),!E.current){const Te=se.approvals.filter(xe=>xe.status==="pending").length;U.current=Te,E.current=!0}}catch{}},[n]),B=g.useCallback(async()=>{if(!(_||!z)){W(!0);try{const V=await ae.notifications.list(n,!1,{limit:K,offset:x.length});V.notifications.length>0&&v(se=>[...se,...V.notifications.filter(Te=>!se.some(xe=>xe.id===Te.id))]),I(V.totalCount!=null?x.length+V.notifications.length<V.totalCount:V.notifications.length>=K)}catch{}W(!1)}},[n,x.length,_,z]),J=g.useCallback(V=>{const se=V.detail;if(!se)return;const{taskId:Te,requirementId:xe}=se;!Te&&!xe||v(Ge=>{const Se=Ge.filter(qe=>!qe.read&&(Te&&qe.metadata?.taskId===Te||xe&&qe.metadata?.requirementId===xe));if(Se.length===0)return Ge;for(const qe of Se)ae.notifications.markRead(qe.id).catch(()=>{});return O(qe=>Math.max(0,qe-Se.length)),Ge.map(qe=>Se.some(st=>st.id===qe.id)?{...qe,read:!0}:qe)})},[]);g.useEffect(()=>{Z();const V=setInterval(Z,6e4),se=()=>Z(),Te=()=>{h(!0),Z()};window.addEventListener("markus:notifications-changed",se),window.addEventListener("markus:mark-read-by-ref",J),window.addEventListener("markus:open-notifications",Te);const xe=un.on("notification:created",()=>Z()),Ge=un.on("approval:created",()=>Z());return()=>{clearInterval(V),window.removeEventListener("markus:notifications-changed",se),window.removeEventListener("markus:mark-read-by-ref",J),window.removeEventListener("markus:open-notifications",Te),xe(),Ge()}},[Z,J]);const Q=g.useCallback(()=>{if(!P.current)return;const V=P.current.getBoundingClientRect(),se=window.innerWidth,Te=window.innerHeight,xe=Math.min(448,se-16),Ge=Math.min(576,Te-16);let Se=V.right+8,qe=V.top;Se+xe>se-8&&(Se=Math.max(8,se-xe-8)),qe+Ge>Te-8&&(qe=Math.max(8,Te-Ge-8)),q({top:qe,left:Se,width:xe,maxHeight:Ge})},[]);g.useLayoutEffect(()=>{m&&Q()},[m,Q]),g.useEffect(()=>{if(m)return window.addEventListener("resize",Q),()=>window.removeEventListener("resize",Q)},[m,Q]),g.useEffect(()=>{if(!m)return;const V=se=>{P.current?.contains(se.target)||R.current?.contains(se.target)||h(!1)};return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[m]),g.useEffect(()=>{if(!m)return;const V=k.some(Te=>Te.status==="pending"),se=x.some(Te=>!Te.read);b(V&&!se?"approvals":!V&&se?"notifications":F.current)},[m]);const ne=new Set(k.filter(V=>V.status==="pending").map(V=>V.id)),te=new Set(k.map(V=>V.id)),Y=x.filter(V=>!(V.type==="approval_request"&&V.metadata?.approvalId&&te.has(V.metadata.approvalId))),ie=x.filter(V=>V.type==="approval_request"&&!V.read&&V.metadata?.approvalId&&ne.has(V.metadata.approvalId)).length,pe=Math.max(0,L-ie),ge=ne.size,ye=pe+ge;g.useEffect(()=>{U.current!==null&&ge>U.current&&Die(),U.current=ge},[ge]);const me=async V=>{await ae.notifications.markRead(V),v(se=>se.map(Te=>Te.id===V?{...Te,read:!0}:Te)),O(se=>Math.max(0,se-1))},re=V=>{const se=V.metadata??{},Te=V.actionType,xe=V.actionTarget;if(Te==="open_chat"&&xe)try{const Ge=typeof xe=="string"?JSON.parse(xe):xe;if(Ge.agentId){const Se={agentId:Ge.agentId};Ge.sessionId&&(Se.sessionId=Ge.sessionId),vt.navigate(Oe.TEAM,Se);return}}catch{}if(Te==="navigate"&&xe)try{const Ge=typeof xe=="string"?JSON.parse(xe):xe;if(Ge.path){if(Ge.path.startsWith("/team")){const Se={},qe=new URLSearchParams(Ge.path.split("?")[1]||"");for(const[st,dt]of qe.entries())Se[st]=dt;vt.navigate(Oe.TEAM,Se);return}if(Ge.path.startsWith("/work")){const Se={},qe=new URLSearchParams(Ge.path.split("?")[1]||"");for(const[st,dt]of qe.entries())Se[st]=dt;vt.navigate(Oe.WORK,Se);return}}}catch{}switch(V.type){case"approval_request":{const Ge=se.approvalId,Se=Ge?k.find(Me=>Me.id===Ge):void 0,qe=Se?.details?.taskId??se.taskId,st=Se?.details?.requirementId??se.requirementId,dt=Se?.details?.agentId??Se?.agentId;qe?vt.navigate(Oe.WORK,{openTask:qe}):st?vt.navigate(Oe.WORK,{openRequirement:st}):dt?vt.navigate(Oe.TEAM,{agentId:dt}):vt.navigate(Oe.WORK);break}case"task_completed":case"task_created":case"task_review":case"task_failed":se.taskId?vt.navigate(Oe.WORK,{openTask:se.taskId}):vt.navigate(Oe.WORK);break;case"requirement_created":case"requirement_decision":se.requirementId?vt.navigate(Oe.WORK,{openRequirement:se.requirementId}):vt.navigate(Oe.WORK);break;case"agent_report":case"system":{if(se.agentId){const Ge={agentId:se.agentId};se.sessionId&&(Ge.sessionId=se.sessionId),vt.navigate(Oe.TEAM,Ge)}else vt.navigate(Oe.TEAM);break}case"direct_message":{const Ge=se.senderId;Ge?vt.navigate(Oe.TEAM,{dm:Ge}):vt.navigate(Oe.TEAM);break}case"group_message":{const Ge=se.channel;Ge?vt.navigate(Oe.TEAM,{channel:Ge}):vt.navigate(Oe.TEAM);break}default:se.taskId?vt.navigate(Oe.WORK,{openTask:se.taskId}):se.requirementId?vt.navigate(Oe.WORK,{openRequirement:se.requirementId}):se.projectId?vt.navigate(Oe.WORK,{projectId:se.projectId}):se.agentId&&vt.navigate(Oe.TEAM,{agentId:se.agentId});break}},Ne=async V=>{V.read||me(V.id);const se=V.metadata??{},Te=se.taskId,xe=se.requirementId;if(Te||xe){const Ge=x.filter(Se=>Se.id!==V.id&&!Se.read&&(Te&&Se.metadata?.taskId===Te||xe&&Se.metadata?.requirementId===xe));for(const Se of Ge)me(Se.id)}re(V)},Ae=async(V,se,Te,xe)=>{N(V);try{const{approval:Ge}=await ae.approvals.respond(V,se,n,Te,xe);C(dt=>dt.map(Me=>Me.id===V?Ge:Me)),T(null),D(dt=>{const Me={...dt};return delete Me[V],Me});const Se=Ge.details?.taskId,qe=Ge.details?.requirementId,st=x.filter(dt=>!dt.read&&(dt.type==="approval_request"&&dt.metadata?.approvalId===V||Se&&dt.metadata?.taskId===Se||qe&&dt.metadata?.requirementId===qe));if(st.length>0){for(const Me of st)ae.notifications.markRead(Me.id).catch(()=>{});const dt=new Set(st.map(Me=>Me.id));v(Me=>Me.map(Ke=>dt.has(Ke.id)?{...Ke,read:!0}:Ke)),O(Me=>Math.max(0,Me-st.length))}Cl("/approvals"),Cl("/notifications"),Cl("/tasks"),Cl("/taskboard"),Cl("/requirements"),window.dispatchEvent(new CustomEvent("markus:data-changed")),window.dispatchEvent(new CustomEvent("markus:notifications-changed")),setTimeout(()=>Z(),800)}catch{}N(null)},_e=async()=>{try{if(!n)return;await ae.notifications.markAllRead(n),v(V=>V.map(se=>({...se,read:!0}))),O(0),Cl("/notifications")}catch{const V=Y.filter(se=>!se.read);await Promise.all(V.map(se=>ae.notifications.markRead(se.id))),v(se=>se.map(Te=>({...Te,read:!0}))),O(0),Cl("/notifications")}},$e=V=>{const se=V.details?.subType;return se==="requirement_resubmit"?u("team:notifications.approvalType.requirementResubmit"):se==="requirement"||V.details?.requirementId?u("team:notifications.approvalType.requirement"):se==="task_review"?u("team:notifications.approvalType.taskReview"):se==="task"||V.details?.taskId?u("team:notifications.approvalType.task"):V.details?.toolName?u("team:notifications.approvalType.toolExecution"):null},we=V=>{const se=[];se.push(V.agentName);const Te=V.details?.taskTitle,xe=V.details?.taskId;Te?se.push(Te):xe&&se.push(`Task ${xe.slice(0,8)}`);const Ge=V.details?.requirementId;return Ge&&!xe&&se.push(`Req ${Ge.slice(0,8)}`),se.join(" · ")},ke=[...k].sort((V,se)=>new Date(se.requestedAt).getTime()-new Date(V.requestedAt).getTime()),We=ke.filter(V=>V.status==="pending"),Fe=ke.filter(V=>V.status!=="pending"),ue=V=>{const se=V.details?.taskId,Te=V.details?.requirementId,xe=V.details?.agentId??V.agentId;se?vt.navigate(Oe.WORK,{openTask:se}):Te?vt.navigate(Oe.WORK,{openRequirement:Te}):xe?vt.navigate(Oe.TEAM,{agentId:xe}):vt.navigate(Oe.WORK)},ve=()=>{h(!1),s?.()},be=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex border-b border-border-default shrink-0",children:[t.jsxs("button",{onClick:()=>{b("approvals"),F.current="approvals"},className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${p==="approvals"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:[u("team:notifications.approvals"),ge>0?` (${ge})`:""]}),t.jsxs("button",{onClick:()=>{b("notifications"),F.current="notifications"},className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${p==="notifications"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:[u("team:notifications.notifications"),pe>0?` (${pe})`:""]}),t.jsx("button",{onClick:ve,className:"px-2 py-2 text-fg-tertiary hover:text-fg-primary transition-colors shrink-0",title:u("common:close"),children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M18 6L6 18"}),t.jsx("path",{d:"M6 6l12 12"})]})})]}),p==="notifications"&&L>0&&t.jsx("div",{className:"flex justify-end px-3 py-1.5 border-b border-border-default/50 shrink-0",children:t.jsx("button",{onClick:_e,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:u("team:notifications.markAllRead")})}),t.jsxs("div",{ref:ee,className:"flex-1 overflow-y-auto",onScroll:V=>{if(p!=="notifications"||!z||_)return;const se=V.currentTarget;se.scrollTop+se.clientHeight>=se.scrollHeight-80&&B()},children:[p==="approvals"&&(k.length===0?t.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:u("team:notifications.noApprovals")}):t.jsxs("div",{className:"divide-y divide-border-default/50",children:[We.map(V=>{const se=V.details?.command,Te=se?V.description.replace(/\s*Command:.*$/,""):V.description;return t.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[t.jsxs("div",{className:"cursor-pointer hover:bg-surface-overlay/50 -mx-3 -mt-3 px-3 pt-3 pb-1 rounded-t-md transition-colors",onClick:()=>ue(V),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-amber-500 mt-0.5 shrink-0",children:t.jsx("path",{d:jd.approval_request})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[$e(V)&&t.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:$e(V)}),t.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:V.title}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Nd(V.requestedAt,u)})]}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:V.agentName})]})]}),t.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:t.jsx(Gr,{content:Te,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),se&&t.jsx("pre",{className:"text-[11px] text-fg-primary bg-surface-overlay border border-border-default rounded-md px-2.5 py-2 overflow-x-auto whitespace-pre-wrap break-all font-mono leading-relaxed mt-2",children:se})]}),(()=>{const xe=V.details?.subType,Ge=xe==="task"||xe==="requirement"||xe==="requirement_resubmit",Se=V.options&&V.options.length>0,qe=(M[V.id]??"").trim();return Se?t.jsxs("div",{className:"space-y-1.5",children:[V.options.map((st,dt)=>t.jsxs("button",{disabled:w===V.id,onClick:()=>Ae(V.id,st.id!=="reject",qe||void 0,st.id),className:`w-full px-3 py-2 text-left text-[11px] font-medium rounded-md disabled:opacity-50 transition-colors flex items-center gap-2 ${st.id==="reject"||st.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:st.description,children:[t.jsx("span",{className:"w-5 h-5 rounded-full bg-white/20 flex items-center justify-center text-[10px] font-bold shrink-0",children:String.fromCharCode(65+dt)}),st.label]},st.id)),t.jsxs("div",{className:"flex gap-1.5 mt-1",children:[t.jsx("input",{type:"text",placeholder:u("team:notifications.freeformPlaceholder"),value:M[V.id]??"",onChange:st=>D(dt=>({...dt,[V.id]:st.target.value})),onKeyDown:st=>{st.key==="Enter"&&(M[V.id]??"").trim()&&Ae(V.id,!0,(M[V.id]??"").trim(),"custom")},className:"flex-1 px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),t.jsx("button",{disabled:w===V.id||!(M[V.id]??"").trim(),onClick:()=>Ae(V.id,!0,(M[V.id]??"").trim(),"custom"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors",children:u("common:send")})]})]}):Ge?t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("button",{disabled:w===V.id,onClick:()=>Ae(V.id,!0,void 0,"approve"),className:"px-3 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M20 6L9 17l-5-5"})}),u("common:approve")]}),t.jsxs("button",{disabled:w===V.id,onClick:()=>Ae(V.id,!1,void 0,"reject"),className:"px-3 py-1.5 text-[11px] font-medium bg-red-600/80 text-white rounded-md hover:bg-red-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M18 6L6 18"}),t.jsx("path",{d:"M6 6l12 12"})]}),u("common:reject")]}),j!==V.id&&t.jsxs("button",{disabled:w===V.id,onClick:()=>T(V.id),className:"px-3 py-1.5 text-[11px] font-medium border border-amber-500/50 text-amber-500 rounded-md hover:bg-amber-500/10 disabled:opacity-50 transition-colors inline-flex items-center gap-1.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("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),u("team:notifications.needsAdjustment")]})]}),j===V.id&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("input",{type:"text",autoFocus:!0,placeholder:u("team:notifications.adjustmentPlaceholder"),value:M[V.id]??"",onChange:st=>D(dt=>({...dt,[V.id]:st.target.value})),onKeyDown:st=>{st.key==="Enter"&&(M[V.id]??"").trim()&&Ae(V.id,!1,(M[V.id]??"").trim(),"needs_adjustment"),st.key==="Escape"&&T(null)},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-amber-500/50"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:w===V.id||!(M[V.id]??"").trim(),onClick:()=>Ae(V.id,!1,(M[V.id]??"").trim(),"needs_adjustment"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-amber-600 text-white rounded-md hover:bg-amber-700 disabled:opacity-50 transition-colors",children:u("team:notifications.confirmAdjustment")}),t.jsx("button",{onClick:()=>T(null),className:"px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay transition-colors",children:u("common:cancel")})]})]})]}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("input",{type:"text",placeholder:u("team:notifications.commentPlaceholder"),value:M[V.id]??"",onChange:st=>D(dt=>({...dt,[V.id]:st.target.value})),onKeyDown:st=>{st.key==="Enter"&&Ae(V.id,!0,qe||void 0,"approve")},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:w===V.id,onClick:()=>Ae(V.id,!0,qe||void 0,"approve"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors",children:u("common:approve")}),t.jsx("button",{disabled:w===V.id,onClick:()=>Ae(V.id,!1,qe||void 0,"reject"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay disabled:opacity-50 transition-colors",children:u("common:reject")})]})]})})()]},V.id)}),Fe.length>0&&t.jsxs(t.Fragment,{children:[We.length>0&&t.jsx("div",{className:"px-3 py-1.5 text-[10px] font-medium text-fg-tertiary uppercase tracking-wider bg-surface-overlay/30",children:u("team:notifications.approvalHistory")}),Fe.slice(0,50).map(V=>t.jsxs("button",{onClick:()=>ue(V),className:"w-full text-left px-3 py-2.5 hover:bg-surface-overlay/50 transition-colors group",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${V.status==="approved"?"bg-green-500":V.status==="cancelled"||V.status==="expired"?"bg-gray-400":"bg-red-500"}`}),$e(V)&&t.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium shrink-0",children:$e(V)}),t.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1 group-hover:text-fg-primary",children:V.title}),t.jsx("span",{className:`text-[10px] font-medium shrink-0 ${V.status==="approved"?"text-green-500":V.status==="cancelled"||V.status==="expired"?"text-fg-muted":"text-red-500"}`,children:u(`common:status.${V.status}`,{defaultValue:V.status})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 pl-3.5",children:[t.jsx("span",{className:"text-[10px] text-fg-muted truncate",children:we(V)}),t.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),t.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Nd(V.respondedAt??V.requestedAt,u)})]}),V.responseComment&&t.jsxs("p",{className:"text-[10px] text-fg-muted mt-0.5 pl-3.5 truncate",children:["“",V.responseComment,"”"]})]},V.id))]})]})),p==="notifications"&&(Y.length===0?t.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:u("team:notifications.noNotifications")}):t.jsxs("div",{className:"divide-y divide-border-default/50",children:[Y.map(V=>{const se=o6[V.type]??"text-fg-tertiary";return t.jsxs("div",{role:"button",tabIndex:0,onClick:()=>Ne(V),onKeyDown:Te=>{(Te.key==="Enter"||Te.key===" ")&&(Te.preventDefault(),Ne(V))},className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors cursor-pointer ${V.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[t.jsx("div",{className:"shrink-0 mt-0.5",children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:se,children:t.jsx("path",{d:jd[V.type]??jd.system})})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[!V.read&&t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${qf[V.priority]??qf.normal}`}),t.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:V.title})]}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:t.jsx(Gr,{content:V.body,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("span",{className:"text-[10px] text-fg-muted",children:Nd(V.createdAt,u)}),Uf(V,u)&&t.jsx("span",{className:`text-[10px] font-medium ${se}`,children:Uf(V,u)})]})]})]},V.id)}),_&&t.jsx("div",{className:"py-3 text-center",children:t.jsxs("svg",{className:"animate-spin h-4 w-4 text-fg-tertiary mx-auto",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})})]}))]})]});if(r){const V=["approvals","notifications"],se=V.indexOf(p),Te=(()=>{let xe=0,Ge=0;return{onTouchStart:Se=>{xe=Se.touches[0].clientX,Ge=Se.touches[0].clientY},onTouchEnd:Se=>{const qe=Se.changedTouches[0].clientX-xe,st=Se.changedTouches[0].clientY-Ge;Math.abs(qe)>60&&Math.abs(qe)>Math.abs(st)*1.5&&(qe<0&&se<V.length-1&&b(V[se+1]),qe>0&&se>0&&b(V[se-1]))}}})();return t.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[t.jsx("div",{className:"flex border-b border-border-default shrink-0",children:V.map(xe=>t.jsx("button",{onClick:()=>b(xe),className:`flex-1 px-3 py-3 text-sm font-medium transition-colors ${p===xe?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary"}`,children:xe==="approvals"?t.jsxs(t.Fragment,{children:[u("team:notifications.approvals"),ge>0?` (${ge})`:""]}):t.jsxs(t.Fragment,{children:[u("team:notifications.notifications"),pe>0?` (${pe})`:""]})},xe))}),p==="notifications"&&L>0&&t.jsx("div",{className:"flex justify-end px-3 py-1.5 border-b border-border-default/50 shrink-0",children:t.jsx("button",{onClick:_e,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:u("team:notifications.markAllRead")})}),t.jsx("div",{className:"flex-1 overflow-hidden relative",...Te,children:t.jsxs("div",{className:"flex h-full transition-transform duration-300 ease-out",style:{transform:`translateX(-${se*100}%)`},children:[t.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:k.length===0?t.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:u("team:notifications.noApprovals")}):t.jsxs("div",{className:"divide-y divide-border-default/50",children:[We.map(xe=>{const Ge=xe.details?.command,Se=Ge?xe.description.replace(/\s*Command:.*$/,""):xe.description;return t.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[t.jsxs("div",{className:"cursor-pointer hover:bg-surface-overlay/50 -mx-3 -mt-3 px-3 pt-3 pb-1 rounded-t-md transition-colors",onClick:()=>ue(xe),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-amber-500 mt-0.5 shrink-0",children:t.jsx("path",{d:jd.approval_request})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[$e(xe)&&t.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:$e(xe)}),t.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:xe.title}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Nd(xe.requestedAt,u)})]}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:xe.agentName})]})]}),t.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:t.jsx(Gr,{content:Se,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),Ge&&t.jsx("pre",{className:"text-[11px] text-fg-primary bg-surface-overlay border border-border-default rounded-md px-2.5 py-2 overflow-x-auto whitespace-pre-wrap break-all font-mono leading-relaxed mt-2",children:Ge})]}),(()=>{const qe=xe.details?.subType,st=qe==="task"||qe==="requirement"||qe==="requirement_resubmit",dt=xe.options&&xe.options.length>0,Me=(M[xe.id]??"").trim();return dt?t.jsxs("div",{className:"space-y-1.5",children:[xe.options.map((Ke,pt)=>t.jsxs("button",{disabled:w===xe.id,onClick:()=>Ae(xe.id,Ke.id!=="reject",Me||void 0,Ke.id),className:`w-full px-3 py-2 text-left text-[11px] font-medium rounded-md disabled:opacity-50 transition-colors flex items-center gap-2 ${Ke.id==="reject"||Ke.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:Ke.description,children:[t.jsx("span",{className:"w-5 h-5 rounded-full bg-white/20 flex items-center justify-center text-[10px] font-bold shrink-0",children:String.fromCharCode(65+pt)}),Ke.label]},Ke.id)),t.jsxs("div",{className:"flex gap-1.5 mt-1",children:[t.jsx("input",{type:"text",placeholder:u("team:notifications.freeformPlaceholder"),value:M[xe.id]??"",onChange:Ke=>D(pt=>({...pt,[xe.id]:Ke.target.value})),onKeyDown:Ke=>{Ke.key==="Enter"&&(M[xe.id]??"").trim()&&Ae(xe.id,!0,(M[xe.id]??"").trim(),"custom")},className:"flex-1 px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),t.jsx("button",{disabled:w===xe.id||!(M[xe.id]??"").trim(),onClick:()=>Ae(xe.id,!0,(M[xe.id]??"").trim(),"custom"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors",children:u("common:send")})]})]}):st?t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("button",{disabled:w===xe.id,onClick:()=>Ae(xe.id,!0,void 0,"approve"),className:"px-3 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M20 6L9 17l-5-5"})}),u("common:approve")]}),t.jsxs("button",{disabled:w===xe.id,onClick:()=>Ae(xe.id,!1,void 0,"reject"),className:"px-3 py-1.5 text-[11px] font-medium bg-red-600/80 text-white rounded-md hover:bg-red-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M18 6L6 18"}),t.jsx("path",{d:"M6 6l12 12"})]}),u("common:reject")]}),j!==xe.id&&t.jsxs("button",{disabled:w===xe.id,onClick:()=>T(xe.id),className:"px-3 py-1.5 text-[11px] font-medium border border-amber-500/50 text-amber-500 rounded-md hover:bg-amber-500/10 disabled:opacity-50 transition-colors inline-flex items-center gap-1.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("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),u("team:notifications.needsAdjustment")]})]}),j===xe.id&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("input",{type:"text",autoFocus:!0,placeholder:u("team:notifications.adjustmentPlaceholder"),value:M[xe.id]??"",onChange:Ke=>D(pt=>({...pt,[xe.id]:Ke.target.value})),onKeyDown:Ke=>{Ke.key==="Enter"&&(M[xe.id]??"").trim()&&Ae(xe.id,!1,(M[xe.id]??"").trim(),"needs_adjustment"),Ke.key==="Escape"&&T(null)},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-amber-500/50"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:w===xe.id||!(M[xe.id]??"").trim(),onClick:()=>Ae(xe.id,!1,(M[xe.id]??"").trim(),"needs_adjustment"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-amber-600 text-white rounded-md hover:bg-amber-700 disabled:opacity-50 transition-colors",children:u("team:notifications.confirmAdjustment")}),t.jsx("button",{onClick:()=>T(null),className:"px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay transition-colors",children:u("common:cancel")})]})]})]}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("input",{type:"text",placeholder:u("team:notifications.commentPlaceholder"),value:M[xe.id]??"",onChange:Ke=>D(pt=>({...pt,[xe.id]:Ke.target.value})),onKeyDown:Ke=>{Ke.key==="Enter"&&Ae(xe.id,!0,Me||void 0,"approve")},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:w===xe.id,onClick:()=>Ae(xe.id,!0,Me||void 0,"approve"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors",children:u("common:approve")}),t.jsx("button",{disabled:w===xe.id,onClick:()=>Ae(xe.id,!1,Me||void 0,"reject"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay disabled:opacity-50 transition-colors",children:u("common:reject")})]})]})})()]},xe.id)}),Fe.length>0&&t.jsxs(t.Fragment,{children:[We.length>0&&t.jsx("div",{className:"px-3 py-1.5 text-[10px] font-medium text-fg-tertiary uppercase tracking-wider bg-surface-overlay/30",children:u("team:notifications.approvalHistory")}),Fe.slice(0,50).map(xe=>t.jsxs("button",{onClick:()=>ue(xe),className:"w-full text-left px-3 py-2.5 hover:bg-surface-overlay/50 transition-colors",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${xe.status==="approved"?"bg-green-500":xe.status==="cancelled"||xe.status==="expired"?"bg-gray-400":"bg-red-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1",children:xe.title}),t.jsx("span",{className:`text-[10px] font-medium shrink-0 ${xe.status==="approved"?"text-green-500":xe.status==="cancelled"||xe.status==="expired"?"text-fg-muted":"text-red-500"}`,children:u(`common:status.${xe.status}`,{defaultValue:xe.status})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 pl-3.5",children:[t.jsx("span",{className:"text-[10px] text-fg-muted truncate",children:we(xe)}),t.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),t.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Nd(xe.respondedAt??xe.requestedAt,u)})]})]},xe.id))]})]})}),t.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:Y.length===0?t.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:u("team:notifications.noNotifications")}):t.jsx("div",{className:"divide-y divide-border-default/50",children:Y.slice(0,50).map(xe=>{const Ge=o6[xe.type]??"text-fg-tertiary";return t.jsxs("button",{onClick:()=>Ne(xe),className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors ${xe.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[t.jsx("div",{className:"shrink-0 mt-0.5",children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:Ge,children:t.jsx("path",{d:jd[xe.type]??jd.system})})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[!xe.read&&t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${qf[xe.priority]??qf.normal}`}),t.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:xe.title})]}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:t.jsx(Gr,{content:xe.body,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("span",{className:"text-[10px] text-fg-muted",children:Nd(xe.createdAt,u)}),Uf(xe,u)&&t.jsx("span",{className:`text-[10px] font-medium ${Ge}`,children:Uf(xe,u)})]})]})]},xe.id)})})})]})})]})}if(a){const V=d||"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9 M13.73 21a2 2 0 0 1-3.46 0";return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:P,onClick:()=>{h(!m),m||Z()},title:e?l||u("team:notifications.bellTitle"):void 0,className:`w-full flex items-center ${e?"flex-col justify-center px-1 py-1.5 gap-0.5":"gap-3 px-3 py-[7px]"} rounded-lg text-[13px] font-medium mb-0.5 transition-colors relative text-fg-primary ${m||i?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[t.jsx("svg",{width:e?16:18,height:e?16:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:t.jsx("path",{d:V})}),e?t.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:l}):t.jsx("span",{className:"truncate",children:l}),ye>0&&t.jsx("span",{className:`absolute ${e?"top-0.5 right-1":"top-1 left-[22px]"} min-w-[16px] h-4 px-1 rounded-full bg-red-500 text-white text-[10px] font-bold flex items-center justify-center leading-none`,children:ye>99?u("common:badgeOverLimit"):ye})]}),m&&Dl.createPortal(t.jsx("div",{ref:R,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:H.top,left:H.left,width:H.width,maxHeight:H.maxHeight},children:be}),document.body)]})}return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:P,onClick:()=>{h(!m),m||Z()},className:`relative flex items-center justify-center rounded-md transition-colors ${e?"w-8 h-8":"w-7 h-7"} ${m?"bg-surface-overlay text-fg-primary":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay"}`,title:u("team:notifications.bellTitle"),children:[t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),t.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),ye>0&&t.jsx("span",{className:"absolute -top-0.5 -right-0.5 min-w-[16px] h-4 px-1 rounded-full bg-red-500 text-white text-[10px] font-bold flex items-center justify-center leading-none",children:ye>99?u("common:badgeOverLimit"):ye})]}),m&&Dl.createPortal(t.jsx("div",{ref:R,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:H.top,left:H.left,width:H.width,maxHeight:H.maxHeight},children:be}),document.body)]})}function Lie({authUser:e}){const{t:n}=ft("nav"),r=Os();return t.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[t.jsxs("div",{className:"flex items-center gap-2 px-4 h-14",children:[r&&t.jsx(Ac,{}),t.jsx("h2",{className:"text-base font-bold",children:n("notifications")})]}),t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(AT,{collapsed:!1,userId:e?.id,embeddedMode:!0})})]})}function Pie(){const{t:e}=ft(["common","home","work"]),[n,r]=g.useState(""),[s,a]=g.useState("all"),[i,l]=g.useState({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]}),[d,u]=g.useState(!1),[m,h]=g.useState(!1),p=g.useRef(null),b=g.useRef(void 0);g.useEffect(()=>{setTimeout(()=>p.current?.focus(),100)},[]);const x=g.useCallback(async w=>{if(!w.trim()){l({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]}),h(!1);return}u(!0),h(!0);const N=w.toLowerCase();try{const[j,T,M,D,L,O]=await Promise.allSettled([ae.agents.list(),ae.tasks.list({search:w,pageSize:20}),ae.requirements.list(),ae.projects.list(),ae.deliverables.search({q:w,limit:20}),ae.teams.list()]),P=j.status==="fulfilled"?j.value.agents.filter(z=>z.name?.toLowerCase().includes(N)||z.role?.toLowerCase().includes(N)):[],R=T.status==="fulfilled"?T.value.tasks:[],H=M.status==="fulfilled"?M.value.requirements.filter(z=>z.title?.toLowerCase().includes(N)||z.description?.toLowerCase().includes(N)):[],q=D.status==="fulfilled"?D.value.projects.filter(z=>z.name?.toLowerCase().includes(N)||z.description?.toLowerCase().includes(N)):[],U=L.status==="fulfilled"?L.value.results:[],E=[];if(O.status==="fulfilled"){const z=await Promise.allSettled(O.value.teams.map(I=>ae.workflows.list(I.id)));for(const I of z)if(I.status==="fulfilled")for(const _ of I.value.workflows)(_.name.toLowerCase().includes(N)||(_.displayName||"").toLowerCase().includes(N)||_.description?.toLowerCase().includes(N))&&E.push(_)}l({agents:P,tasks:R,requirements:H,projects:q,deliverables:U,workflows:E})}catch{l({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]})}finally{u(!1)}},[]),v=w=>{r(w),b.current&&clearTimeout(b.current),b.current=setTimeout(()=>x(w),400)},k=[{id:"all",label:e("common:all",{defaultValue:"全部"})},{id:"agents",label:e("common:agents",{defaultValue:"智能体"})},{id:"tasks",label:e("common:tasks",{defaultValue:"任务"})},{id:"requirements",label:e("common:requirements",{defaultValue:"需求"})},{id:"projects",label:e("common:projects",{defaultValue:"项目"})},{id:"deliverables",label:e("common:deliverables",{defaultValue:"交付物"})},{id:"workflows",label:e("common:workflows",{defaultValue:"工作流"})}],C=i.agents.length>0||i.tasks.length>0||i.requirements.length>0||i.projects.length>0||i.deliverables.length>0||i.workflows.length>0;return t.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[t.jsxs("div",{className:"shrink-0 px-4 pt-4 pb-2 space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:()=>vt.navigate(Oe.HOME),className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors shrink-0",children:t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M19 12H5"}),t.jsx("polyline",{points:"12 19 5 12 12 5"})]})}),t.jsxs("div",{className:"flex-1 relative",children:[t.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:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),t.jsx("input",{ref:p,value:n,onChange:w=>v(w.target.value),placeholder:e("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"}),n&&t.jsx("button",{onClick:()=>{r(""),l({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]}),h(!1),p.current?.focus()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-fg-tertiary hover:text-fg-secondary",children:t.jsxs("svg",{width:"14",height:"14",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"})]})})]})]}),t.jsx("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:k.map(w=>t.jsx("button",{onClick:()=>a(w.id),className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${s===w.id?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:w.label},w.id))})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-4",children:[d&&t.jsx("div",{className:"flex items-center justify-center py-12",children:t.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:e("common:loading")})}),!d&&m&&!C&&t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[t.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:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),t.jsx("p",{className:"text-sm text-fg-tertiary",children:e("common:noResults",{defaultValue:"没有找到相关结果"})})]}),!d&&C&&t.jsxs("div",{className:"space-y-4",children:[(s==="all"||s==="agents")&&i.agents.length>0&&t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:e("common:agents",{defaultValue:"智能体"})}),t.jsx("div",{className:"space-y-1",children:(s==="all"?i.agents.slice(0,8):i.agents).map(w=>t.jsxs("button",{onClick:()=>vt.navigate(Oe.TEAM,{agentId:w.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:[t.jsx(lr,{name:w.name||"Agent",avatarUrl:w.avatarUrl,size:32}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:w.name}),t.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:w.role||w.status})]}),t.jsx(Oie,{status:w.status})]},w.id))}),s==="all"&&i.agents.length>8&&t.jsxs("button",{onClick:()=>a("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:[e("common:showAll",{defaultValue:"查看全部"})," (",i.agents.length,")"]})]}),(s==="all"||s==="tasks")&&i.tasks.length>0&&t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:e("common:tasks",{defaultValue:"任务"})}),t.jsx("div",{className:"space-y-1",children:(s==="all"?i.tasks.slice(0,8):i.tasks).map(w=>t.jsxs("button",{onClick:()=>vt.navigate(Oe.WORK,{openTask:w.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:[t.jsx(_ie,{status:w.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:w.title}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[w.status," · ",w.priority||""]})]})]},w.id))}),s==="all"&&i.tasks.length>8&&t.jsxs("button",{onClick:()=>a("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:[e("common:showAll",{defaultValue:"查看全部"})," (",i.tasks.length,")"]})]}),(s==="all"||s==="requirements")&&i.requirements.length>0&&t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:e("common:requirements",{defaultValue:"需求"})}),t.jsx("div",{className:"space-y-1",children:(s==="all"?i.requirements.slice(0,8):i.requirements).map(w=>t.jsxs("button",{onClick:()=>vt.navigate(Oe.WORK,{openRequirement:w.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:[t.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center shrink-0 ${w.status==="approved"?"text-green-500 bg-green-500/15":w.status==="pending"?"text-amber-500 bg-amber-500/15":w.status==="rejected"?"text-red-500 bg-red-500/15":"text-fg-tertiary bg-surface-elevated"}`,children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),t.jsx("polyline",{points:"14 2 14 8 20 8"}),t.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),t.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:w.title}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[w.status," · ",w.priority||""]})]})]},w.id))}),s==="all"&&i.requirements.length>8&&t.jsxs("button",{onClick:()=>a("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:[e("common:showAll",{defaultValue:"查看全部"})," (",i.requirements.length,")"]})]}),(s==="all"||s==="projects")&&i.projects.length>0&&t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:e("common:projects",{defaultValue:"项目"})}),t.jsx("div",{className:"space-y-1",children:(s==="all"?i.projects.slice(0,8):i.projects).map(w=>t.jsxs("button",{onClick:()=>vt.navigate(Oe.WORK,{projectId:w.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:[t.jsx("div",{className:"w-8 h-8 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-brand-500",children:t.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"})})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:w.name}),w.description&&t.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:w.description})]})]},w.id))}),s==="all"&&i.projects.length>8&&t.jsxs("button",{onClick:()=>a("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:[e("common:showAll",{defaultValue:"查看全部"})," (",i.projects.length,")"]})]}),(s==="all"||s==="deliverables")&&i.deliverables.length>0&&t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:e("common:deliverables",{defaultValue:"交付物"})}),t.jsx("div",{className:"space-y-1",children:(s==="all"?i.deliverables.slice(0,8):i.deliverables).map(w=>t.jsxs("button",{onClick:()=>vt.navigate(Oe.DELIVERABLES,{openDeliverable:w.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:[t.jsx("div",{className:"w-8 h-8 rounded-lg bg-purple-500/15 flex items-center justify-center shrink-0",children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-purple-500",children:[t.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),t.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:w.title}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[w.type," · ",w.status]})]})]},w.id))}),s==="all"&&i.deliverables.length>8&&t.jsxs("button",{onClick:()=>a("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:[e("common:showAll",{defaultValue:"查看全部"})," (",i.deliverables.length,")"]})]}),(s==="all"||s==="workflows")&&i.workflows.length>0&&t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:e("common:workflows",{defaultValue:"工作流"})}),t.jsx("div",{className:"space-y-1",children:(s==="all"?i.workflows.slice(0,8):i.workflows).map(w=>t.jsxs("button",{onClick:()=>vt.navigate(Oe.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:[t.jsx("div",{className:"w-8 h-8 rounded-lg bg-teal-500/15 flex items-center justify-center shrink-0",children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-teal-500",children:[t.jsx("circle",{cx:"12",cy:"12",r:"3"}),t.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"})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:w.displayName||w.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[w.stepCount," steps · v",w.version]})]})]},w.name))}),s==="all"&&i.workflows.length>8&&t.jsxs("button",{onClick:()=>a("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:[e("common:showAll",{defaultValue:"查看全部"})," (",i.workflows.length,")"]})]})]}),!d&&!m&&t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[t.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:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),t.jsx("p",{className:"text-sm text-fg-tertiary",children:e("common:search")})]})]})]})}function Oie({status:e}){const n=e==="active"||e==="idle"?"bg-green-500":e==="working"||e==="busy"?"bg-blue-500":e==="paused"?"bg-amber-500":"bg-gray-400";return t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${n}`})}function _ie({status:e}){const n=e==="completed"?"text-green-500 bg-green-500/15":e==="in_progress"?"text-blue-500 bg-blue-500/15":e==="pending"?"text-amber-500 bg-amber-500/15":"text-fg-tertiary bg-surface-elevated";return t.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center shrink-0 ${n}`,children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("path",{d:"M9 11l3 3L22 4"}),t.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})})}function l6({d:e,size:n=18}){return t.jsx("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:t.jsx("path",{d:e})})}function zie({currentPage:e,onNavigate:n,authUser:r,collapsed:s,onToggleCollapse:a}){const{t:i}=ft(["nav","common"]);return t.jsxs("aside",{className:"h-dvh bg-surface-secondary flex flex-col shrink-0 overflow-hidden",children:[t.jsx("div",{className:`flex items-center ${s?"px-2 py-3.5 justify-center":"px-4 h-14 justify-between"}`,children:t.jsxs("button",{onClick:a,title:i(s?"sidebar.expandSidebar":"sidebar.collapseSidebar"),className:"flex items-center gap-2.5 min-w-0 group",children:[t.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-8 h-8 rounded-lg shrink-0"}),!s&&t.jsx("span",{className:"text-[15px] font-bold tracking-tight text-fg-primary whitespace-nowrap",children:"Markus"})]})}),t.jsx("nav",{className:`${s?"p-1":"px-3 py-2"} flex-1 overflow-y-auto scrollbar-thin`,children:M$.map((l,d)=>{const u=R$.filter(h=>h.section===l.key&&h.id!==Oe.SETTINGS);if(u.length===0)return null;const m=i(`sections.${l.key}`);return t.jsx("div",{children:t.jsxs("div",{className:d>0?"mt-3":"",children:[!s&&m&&t.jsx("div",{className:"px-3 py-1.5 mb-1 text-[10px] font-semibold text-fg-muted uppercase tracking-[0.1em]",children:m}),s&&d>0&&t.jsx("div",{className:"my-3"}),u.map(h=>{if(h.id===Oe.NOTIFICATIONS)return t.jsx(AT,{sidebarMode:!0,collapsed:s,userId:r?.id,label:i(h.id),iconPath:Gf[h.id],isActive:e===h.id},h.id);const p=e===h.id;return t.jsxs("button",{onClick:()=>n(h.id),title:s?i(h.id):void 0,className:`w-full flex items-center ${s?"flex-col justify-center px-1 py-1.5 gap-0.5":"gap-3 px-3 py-[7px]"} rounded-lg text-[13px] font-medium mb-0.5 transition-colors text-fg-primary ${p?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[t.jsx(l6,{d:Gf[h.id]??"",size:s?16:18}),s?t.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:i(h.id)}):t.jsx("span",{className:"truncate",children:i(h.id)})]},h.id)})]})},l.key)})}),t.jsxs("div",{className:`shrink-0 ${s?"p-1":"px-3 pb-2"} flex items-center ${s?"flex-col":"justify-between"}`,children:[t.jsx("button",{onClick:()=>n(Oe.SETTINGS),title:i(Oe.SETTINGS),className:"flex items-center justify-center w-8 h-8 rounded-lg transition-colors text-fg-secondary hover:bg-surface-overlay/60 hover:text-fg-primary",children:t.jsx(l6,{d:Gf[Oe.SETTINGS],size:16})}),!s&&t.jsxs("span",{className:"text-[10px] text-fg-muted select-none",children:["v","0.8.2"]})]})]})}function $ie({currentPage:e,onNavigate:n,userId:r}){const{t:s}=ft("nav"),[a,i]=g.useState(0),{counts:l}=l8({enabled:!0}),d=g.useMemo(()=>{let m=0;for(const h of Object.values(l))m+=h;return m},[l]),u=g.useCallback(async()=>{try{const m=await ae.notifications.list(r,!1);i(m.unreadCount??m.notifications.filter(h=>!h.read).length)}catch{}},[r]);return g.useEffect(()=>{u();const m=setInterval(u,15e3),h=()=>u();return window.addEventListener("markus:notifications-changed",h),()=>{clearInterval(m),window.removeEventListener("markus:notifications-changed",h)}},[u]),t.jsx("nav",{className:"fixed bottom-0 left-0 right-0 z-50 bg-surface-secondary flex items-stretch h-14 safe-area-bottom",children:I$.map(m=>{const h=m.group.includes(e),p=m.id===Oe.NOTIFICATIONS,b=m.id===Oe.TEAM;return t.jsxs("button",{onClick:()=>n(m.id),className:`flex-1 flex flex-col items-center justify-center gap-0.5 transition-colors ${h?"text-fg-primary":"text-fg-tertiary active:text-fg-secondary"}`,children:[t.jsxs("div",{className:"relative",children:[t.jsx("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:h?2:1.75,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:t.jsx("path",{d:Gf[m.id]})}),p&&a>0&&t.jsx("span",{className:"absolute -top-1.5 -right-2 min-w-[16px] h-4 px-1 flex items-center justify-center bg-red-500 text-white text-[9px] font-bold rounded-full leading-none",children:a>99?"99+":a}),b&&d>0&&t.jsx("span",{className:"absolute -top-1.5 -right-2 min-w-[16px] h-4 px-1 flex items-center justify-center bg-red-500 text-white text-[9px] font-bold rounded-full leading-none",children:d>99?"99+":d})]}),t.jsx("span",{className:`text-[10px] leading-tight ${h?"font-semibold":""}`,children:s(m.id)})]},m.id)})})}const ET=["builder","agents","teams","skills"];function Bie(){const e=localStorage.getItem("markus_nav_storeTab");return e&&(localStorage.removeItem("markus_nav_storeTab"),ET.includes(e))?e:"builder"}function Hie({authUser:e}){const{t:n}=ft(["nav","common"]),r=g.useMemo(()=>[{id:"builder",label:n("nav:builder")},{id:"agents",label:n("nav:tabs.agents")},{id:"teams",label:n("nav:tabs.teams")},{id:"skills",label:n("nav:tabs.skills")}],[n]),[s,a]=g.useState(Bie),i=zl(r,s,a);return g.useEffect(()=>{const l=d=>{const u=d.detail;u.params?.storeTab&&ET.includes(u.params.storeTab)&&a(u.params.storeTab)};return window.addEventListener("markus:navigate",l),()=>window.removeEventListener("markus:navigate",l)},[]),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:i.onTouchStart,onTouchEnd:i.onTouchEnd,children:[t.jsxs("div",{className:"flex items-center shrink-0 overflow-x-auto scrollbar-hide",children:[t.jsx(Ac,{className:"ml-2"}),r.map(l=>t.jsx("button",{onClick:()=>a(l.id),className:`flex-1 min-w-0 px-3 py-2.5 text-xs font-medium text-center whitespace-nowrap transition-colors border-b-2 ${s===l.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:l.label},l.id))]}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s==="builder"&&t.jsx(E8,{}),s==="agents"&&t.jsx(j8,{authUser:e}),s==="teams"&&t.jsx(C8,{}),s==="skills"&&t.jsx(T8,{})]})]})}const c6="usageType",Gb="profile";function Fie({onComplete:e,theme:n,onThemeChange:r,skipProfile:s}){const{t:a}=ft(["onboarding","common"]),[i,l]=g.useState(0),[d,u]=g.useState(""),[m,h]=g.useState(""),[p,b]=g.useState(""),[x,v]=g.useState(""),[k,C]=g.useState(!1),[w,N]=g.useState(""),[j,T]=g.useState(!1),[M,D]=g.useState(null);g.useEffect(()=>{ae.auth.me().then(({user:ge})=>{ge.name&&u(ge.name),ge.email&&h(ge.email),ge.avatarUrl&&D(ge.avatarUrl);const ye=ge.name||ge.email?.split("@")[0]||"";ye&&R(a("usageType.defaultOrgName",{name:ye}))}).catch(()=>{}),ae.hubOrgs.invitations().then(ge=>{ge.invitations?.length>0&&I(ge.invitations)}).catch(()=>{})},[]);const[L,O]=g.useState(null),[P,R]=g.useState(""),[H,q]=g.useState(!1),[U,E]=g.useState(!1),[z,I]=g.useState([]),[_,W]=g.useState(null),[ee,F]=g.useState(null),[K,Z]=g.useState(!0),B=async()=>{if(N(""),!d.trim()){N(a("profile.errors.nameRequired"));return}if(!m.trim()){N(a("profile.errors.emailRequired"));return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(m.trim())){N(a("profile.errors.emailInvalid"));return}if(p&&p.length<6){N(a("profile.errors.passwordTooShort"));return}if(p&&p!==x){N(a("profile.errors.passwordMismatch"));return}C(!0);try{await ae.auth.updateProfile(d.trim(),m.trim()),p&&await ae.auth.changePassword("",p),T(!0)}catch{N(a("profile.errors.saveFailed"))}finally{C(!1)}},J=[{value:"system",label:a("theme.system"),icon:"💻",desc:a("theme.systemDesc")},{value:"light",label:a("theme.light"),icon:"☀️",desc:a("theme.lightDesc")},{value:"dark",label:a("theme.dark"),icon:"🌊",desc:a("theme.darkDesc")},{value:"cyberpunk",label:a("theme.cyberpunk"),icon:"🔮",desc:a("theme.cyberpunkDesc")},{value:"mono",label:a("theme.mono"),icon:"⬛",desc:a("theme.monoDesc")}],Q=[{id:"welcome",title:a("welcome.title"),subtitle:a("welcome.subtitle"),content:t.jsx("p",{className:"text-fg-secondary text-sm leading-relaxed",children:t.jsx(N6,{i18nKey:"welcome.description",ns:"onboarding",components:{strong:t.jsx("strong",{className:"text-fg-primary"})}})})},{id:c6,title:a("usageType.title",{defaultValue:"How will you use Markus?"}),subtitle:a("usageType.subtitle",{defaultValue:"This helps us tailor your experience."}),content:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("button",{onClick:()=>{O("personal"),E(!0)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${L==="personal"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[t.jsx("span",{className:"text-2xl",children:"👤"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:a("usageType.personal",{defaultValue:"Personal"})}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:a("usageType.personalDesc",{defaultValue:"Individual use with your own AI agents."})})]})]}),t.jsxs("button",{onClick:()=>{O("organization"),E(!1)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${L==="organization"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[t.jsx("span",{className:"text-2xl",children:"🏢"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:a("usageType.organization",{defaultValue:"Team & Enterprise"})}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:a("usageType.organizationDesc",{defaultValue:"For teams sharing licenses and collaborating."})})]})]})]}),L==="organization"&&t.jsxs("div",{className:"space-y-4 mt-4",children:[z.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"text-xs text-fg-tertiary font-medium",children:a("usageType.pendingInvitations")}),z.map(ge=>t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 rounded-xl border border-amber-500/20 bg-amber-500/5",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:ge.orgName}),t.jsx("div",{className:"text-[11px] text-fg-tertiary",children:a("usageType.invitedBy",{name:ge.invitedBy})})]}),t.jsx("button",{onClick:async()=>{W(ge.orgId);try{await ae.hubOrgs.acceptInvitation(ge.orgId),F(ge.orgId),E(!0)}catch{}finally{W(null)}},disabled:_===ge.orgId||ee===ge.orgId,className:"px-3 py-1.5 text-xs rounded-lg bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white transition-colors",children:ee===ge.orgId?a("usageType.accepted"):_===ge.orgId?a("usageType.accepting"):a("usageType.acceptAndJoin")})]},ge.orgId)),t.jsx("div",{className:"text-[11px] text-fg-tertiary text-center pt-1",children:a("usageType.orCreateNew")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:a("usageType.orgNameLabel")}),t.jsx("input",{type:"text",value:P,onChange:ge=>{R(ge.target.value),E(!1)},placeholder:a("usageType.orgNamePlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),t.jsx("button",{onClick:async()=>{if(P.trim()){q(!0);try{const ye=(await ae.hubOrgs.mine()).orgs?.[0];ye?.id&&await ae.hubOrgs.update(ye.id,{name:P.trim()}),E(!0)}catch{}finally{q(!1)}}},disabled:H||!P.trim()||U,className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-xl transition-colors",children:a(H?"common:saving":U?"usageType.orgNameSaved":"usageType.setOrgName")})]})]})},{id:Gb,title:a("profile.title"),subtitle:a("profile.subtitle"),content:j?t.jsxs("div",{className:"flex items-center gap-3 bg-green-500/10 border border-green-500/30 rounded-xl p-4",children:[t.jsx("span",{className:"text-green-600 text-lg",children:"✓"}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-green-600",children:a("profile.saved")}),t.jsxs("div",{className:"text-xs text-fg-secondary mt-0.5",children:[d," · ",m]})]})]}):t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"flex justify-center",children:t.jsx(D6,{currentUrl:M,name:d,size:64,targetType:"user"})}),t.jsxs("div",{className:"space-y-1",children:[t.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[a("profile.nameLabel")," ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"text",value:d,onChange:ge=>u(ge.target.value),placeholder:a("profile.namePlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",autoFocus:!0})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[a("profile.emailLabel")," ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"email",value:m,onChange:ge=>h(ge.target.value),placeholder:a("profile.emailPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:a("profile.newPasswordLabel")}),t.jsx("input",{type:"password",value:p,onChange:ge=>b(ge.target.value),placeholder:a("profile.newPasswordPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),p&&t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:a("profile.confirmPasswordLabel")}),t.jsx("input",{type:"password",value:x,onChange:ge=>v(ge.target.value),placeholder:a("profile.confirmPasswordPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),w&&t.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:w}),t.jsx("button",{onClick:()=>{B()},disabled:k||!d.trim()||!m.trim(),className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-xl transition-colors",children:a(k?"common:saving":"profile.saveProfile")})]})},{id:"theme",title:a("theme.title"),subtitle:a("theme.subtitle"),content:t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"grid grid-cols-3 gap-3",children:J.map(ge=>t.jsxs("button",{onClick:()=>r(ge.value),className:`flex flex-col items-center gap-2 rounded-xl border-2 p-5 transition-all ${n===ge.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[t.jsx("span",{className:"text-2xl",children:ge.icon}),t.jsx("span",{className:"text-sm font-medium text-fg-primary",children:ge.label}),t.jsx("span",{className:"text-[11px] text-fg-tertiary leading-tight text-center",children:ge.desc})]},ge.value))}),t.jsxs("label",{className:"flex items-center gap-2.5 p-3 bg-surface-elevated/30 rounded-lg cursor-pointer group",children:[t.jsx("input",{type:"checkbox",checked:K,onChange:ge=>Z(ge.target.checked),className:"accent-brand-500 shrink-0"}),t.jsx("span",{className:"text-[11px] text-fg-tertiary",children:a("done.telemetry")})]})]})}],ne=s?Q.filter(ge=>ge.id!==Gb):Q,te=ne.findIndex(ge=>ge.id===c6),Y=ne.findIndex(ge=>ge.id===Gb),ie=()=>{i===te&&te>=0&&!L||i===te&&L==="organization"&&!U||i===Y&&Y>=0&&!j||(i<ne.length-1?l(i+1):(fetch("/api/settings/telemetry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:K})}).catch(()=>{}),e()))},pe=ne[i];return t.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4",children:t.jsx("div",{className:"w-full max-w-lg",children:t.jsxs("div",{className:"bg-surface-elevated rounded-2xl p-8",children:[t.jsx("div",{className:"flex gap-1.5 mb-8",children:ne.map((ge,ye)=>t.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${ye<=i?"bg-brand-500":"bg-surface-elevated"}`},ye))}),t.jsx("h2",{className:"text-2xl font-bold text-fg-primary",children:pe.title}),t.jsx("p",{className:"text-sm text-fg-secondary mt-1 mb-6",children:pe.subtitle}),pe.content,t.jsxs("div",{className:"flex justify-between mt-8",children:[i>0?t.jsx("button",{onClick:()=>l(i-1),className:"px-4 py-2 text-sm text-fg-secondary hover:text-fg-primary transition-colors",children:a("common:back")}):t.jsx("button",{onClick:e,className:"px-4 py-2 text-sm text-fg-tertiary hover:text-fg-secondary transition-colors",children:a("common:skip")}),t.jsxs("div",{className:"flex items-center gap-3",children:[te>=0&&i===te&&!L&&t.jsx("button",{onClick:()=>{O("personal"),E(!0),l(i+1)},className:"px-4 py-2 text-sm text-fg-tertiary hover:text-fg-secondary transition-colors",children:a("common:skip")}),Y>=0&&i===Y&&!j&&t.jsx("button",{onClick:()=>l(i+1),className:"px-4 py-2 text-sm text-fg-tertiary hover:text-fg-secondary transition-colors",children:a("common:skip")}),t.jsx("button",{onClick:ie,disabled:Y>=0&&i===Y&&!j||te>=0&&i===te&&(!L||L==="organization"&&!U),className:`px-6 py-2.5 text-white text-sm rounded-xl transition-colors ${Y>=0&&i===Y&&!j||te>=0&&i===te&&(!L||L==="organization"&&!U)?"bg-brand-600/40 cursor-not-allowed":"bg-brand-600 hover:bg-brand-500"}`,children:i===ne.length-1?a("getStarted"):a("common:next")})]})]})]})})})}function qie({onLogin:e,hasOwner:n,hasMultipleUsers:r}){const{t:s}=ft("auth"),[a,i]=g.useState(null),[l,d]=g.useState(""),[u,m]=g.useState(!1),[h,p]=g.useState(""),[b,x]=g.useState(""),v=async(w,N=!1)=>{d(""),i(w??"hub");try{await ja(w);const j=si(),T=qh();if(!j||!T){d(s("login.hubUnavailable"));return}const{user:M,needsOnboarding:D}=await ae.auth.hubLogin(j,T);e(M,D??!1,{fromHub:!0})}catch(j){const T=j instanceof Error?j.message:"";if(!T.includes("cancelled")){if(!N&&si())return v0(),v(w,!0);d(T||s("login.hubUnavailable"))}}finally{i(null)}},k=async w=>{if(w.preventDefault(),!(!h.trim()||!b)){d(""),i("local");try{const{user:N,needsOnboarding:j}=await ae.auth.login(h.trim(),b);e(N,j??!1)}catch{d(s("login.invalidCredentials"))}finally{i(null)}}},C=s(n?"login.welcomeBack":"login.getStarted");return t.jsxs("div",{className:"min-h-dvh bg-surface-primary flex flex-col items-center justify-center p-4 relative overflow-hidden",children:[t.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),t.jsxs("div",{className:"w-full max-w-sm relative z-10 flex-1 flex flex-col justify-center",children:[t.jsxs("div",{className:"text-center mb-8",children:[t.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),t.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),t.jsx("div",{className:"text-sm text-fg-tertiary",children:C})]}),t.jsx("div",{className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-4 shadow-2xl shadow-black/30",children:u?t.jsxs(t.Fragment,{children:[t.jsxs("form",{onSubmit:k,className:"space-y-3",children:[t.jsx("div",{className:"space-y-1",children:t.jsx("input",{type:"email",value:h,onChange:w=>p(w.target.value),autoComplete:"email",autoFocus:!0,placeholder:s("login.email"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors placeholder:text-fg-tertiary",required:!0})}),t.jsx("div",{className:"space-y-1",children:t.jsx("input",{type:"password",value:b,onChange:w=>x(w.target.value),autoComplete:"current-password",placeholder:s("login.password"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors placeholder:text-fg-tertiary",required:!0})}),l&&t.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:l}),!r&&t.jsx("p",{className:"text-[11px] text-fg-tertiary",children:s("login.defaultCredentials")}),t.jsx("button",{type:"submit",disabled:a==="local"||!h||!b,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-medium rounded-xl transition-all",children:s(a==="local"?"login.signingIn":"login.signIn")})]}),t.jsx("div",{className:"pt-1 text-center",children:t.jsx("button",{onClick:()=>{m(!1),d("")},className:"text-xs text-fg-tertiary hover:text-fg-secondary transition-colors",children:s("login.backToHub")})})]}):t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:()=>v("google"),disabled:!!a,className:"w-full flex items-center justify-center gap-3 py-2.5 px-4 bg-surface-elevated hover:bg-surface-elevated/80 border border-border-default rounded-xl text-sm text-fg-primary font-medium transition-all disabled:opacity-50",children:[t.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",children:[t.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 01-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z"}),t.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),t.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),t.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),s(a==="google"?"login.connectingHub":"login.withGoogle")]}),t.jsxs("button",{onClick:()=>v("github"),disabled:!!a,className:"w-full flex items-center justify-center gap-3 py-2.5 px-4 bg-surface-elevated hover:bg-surface-elevated/80 border border-border-default rounded-xl text-sm text-fg-primary font-medium transition-all disabled:opacity-50",children:[t.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z"})}),s(a==="github"?"login.connectingHub":"login.withGithub")]}),t.jsxs("button",{onClick:()=>v("email"),disabled:!!a,className:"w-full flex items-center justify-center gap-3 py-2.5 px-4 bg-surface-elevated hover:bg-surface-elevated/80 border border-border-default rounded-xl text-sm text-fg-primary font-medium transition-all disabled:opacity-50",children:[t.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75"})}),s(a==="email"?"login.connectingHub":"login.withEmail")]}),t.jsx("p",{className:"text-center text-[11px] text-fg-tertiary pt-1",children:s("login.terms")}),l&&t.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:l}),t.jsx("div",{className:"pt-1 text-center",children:t.jsx("button",{onClick:()=>m(!0),className:"text-xs text-fg-tertiary hover:text-fg-secondary transition-colors",children:s("login.useLocalAccount")})})]})})]}),t.jsxs("div",{className:"relative z-10 flex flex-wrap items-center justify-center gap-x-5 gap-y-1 py-6 text-[11px] text-fg-tertiary",children:[t.jsx("a",{href:"https://markus.global",target:"_blank",rel:"noopener noreferrer",className:"hover:text-fg-secondary transition-colors",children:"markus.global"}),t.jsx("a",{href:"mailto:business@markus.global",className:"hover:text-fg-secondary transition-colors",children:s("login.contactSales")})]})]})}function Uie({token:e,onComplete:n}){const{t:r}=ft("auth"),[s,a]=g.useState(null),[i,l]=g.useState(""),[d,u]=g.useState(""),[m,h]=g.useState(""),[p,b]=g.useState(!1),[x,v]=g.useState(!1),[k,C]=g.useState(!1);g.useEffect(()=>{ae.auth.inviteInfo(e).then(N=>a(N)).catch(()=>C(!0))},[e]);const w=async N=>{if(N.preventDefault(),h(""),i.length<6){h(r("invite.passwordMinLength"));return}if(i!==d){h(r("invite.passwordsDoNotMatch"));return}b(!0);try{await ae.auth.setup(e,i),v(!0),setTimeout(()=>{window.location.hash="",n()},2e3)}catch{h(r("invite.error"))}finally{b(!1)}};return t.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[t.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),t.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[t.jsxs("div",{className:"text-center mb-8",children:[t.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),t.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),t.jsx("div",{className:"text-sm text-fg-tertiary",children:r("invite.subtitle")})]}),t.jsx("div",{className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-5 shadow-2xl shadow-black/30",children:k?t.jsxs("div",{className:"text-center space-y-3",children:[t.jsx("div",{className:"text-red-500 text-3xl",children:"⚠"}),t.jsx("p",{className:"text-sm text-fg-secondary",children:r("invite.invalidLink")}),t.jsx("button",{onClick:()=>{window.location.hash="",n()},className:"text-sm text-brand-500 hover:text-brand-400",children:r("login.signIn")})]}):x?t.jsxs("div",{className:"text-center space-y-3",children:[t.jsx("div",{className:"text-green-500 text-3xl",children:"✓"}),t.jsx("p",{className:"text-sm text-fg-secondary",children:r("invite.setupComplete")})]}):s?t.jsxs("form",{onSubmit:w,className:"space-y-5",children:[t.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:r("invite.greeting",{name:s.name})}),t.jsx("p",{className:"text-xs text-fg-tertiary text-center",children:s.email}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:r("invite.setPassword")}),t.jsx("input",{type:"password",value:i,onChange:N=>l(N.target.value),autoComplete:"new-password",autoFocus:!0,className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:r("invite.confirmPassword")}),t.jsx("input",{type:"password",value:d,onChange:N=>u(N.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),m&&t.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:m}),t.jsx("button",{type:"submit",disabled:p||!i||!d,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-medium rounded-xl transition-all shadow-md shadow-brand-900/40 hover:shadow-lg hover:shadow-brand-900/50",children:r(p?"invite.settingUp":"invite.setupAccount")})]}):t.jsx("div",{className:"text-center text-fg-tertiary text-sm animate-pulse py-4",children:"Loading…"})})]})]})}function Vie({onComplete:e,isFirstTime:n}){const{t:r}=ft("auth"),[s,a]=g.useState(""),[i,l]=g.useState(""),[d,u]=g.useState(""),[m,h]=g.useState(""),[p,b]=g.useState(!1),x=async v=>{if(v.preventDefault(),h(""),i.length<6){h(r("changePassword.passwordMinLength"));return}if(i!==d){h(r("changePassword.passwordsDoNotMatch"));return}b(!0);try{await ae.auth.changePassword(s,i),e()}catch{h(r("changePassword.failedToChange"))}finally{b(!1)}};return t.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[t.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),t.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[t.jsxs("div",{className:"text-center mb-8",children:[t.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),t.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),t.jsx("div",{className:"text-sm text-fg-tertiary",children:r("login.subtitle")})]}),t.jsxs("form",{onSubmit:x,className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-5 shadow-2xl shadow-black/30",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:r(n?"changePassword.setYourPassword":"changePassword.changePassword")}),n&&t.jsx("p",{className:"text-xs text-amber-600/80 text-center mt-2",children:r("changePassword.defaultPasswordWarning")})]}),!n&&t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:r("changePassword.currentPassword")}),t.jsx("input",{type:"password",value:s,onChange:v=>a(v.target.value),autoComplete:"current-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:r("changePassword.newPassword")}),t.jsx("input",{type:"password",value:i,onChange:v=>l(v.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0,minLength:6})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:r("changePassword.confirmNewPassword")}),t.jsx("input",{type:"password",value:d,onChange:v=>u(v.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),m&&t.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:m}),t.jsx("button",{type:"submit",disabled:p||!i||!d,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-medium rounded-xl transition-colors",children:r(p?"changePassword.saving":n?"changePassword.setPasswordAndContinue":"changePassword.changePassword")})]})]})]})}const lh={agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]},Wie={team:["agents","workflows","tasks","requirements","projects","deliverables"],work:["workflows","projects","requirements","tasks","agents","deliverables"],deliverables:["deliverables","agents","tasks","requirements","projects","workflows"]},Kie=["agents","tasks","requirements","projects","deliverables","workflows"];let d6="",u6="all",m6=lh,f6=!1;function Gie({onClose:e,currentPage:n}){const{t:r}=ft(["common","home","work"]),[s,a]=g.useState(d6),[i,l]=g.useState(u6),[d,u]=g.useState(m6),[m,h]=g.useState(!1),[p,b]=g.useState(f6),[x,v]=g.useState(-1);g.useEffect(()=>{d6=s},[s]),g.useEffect(()=>{u6=i},[i]),g.useEffect(()=>{m6=d},[d]),g.useEffect(()=>{f6=p},[p]);const k=g.useRef(null),C=g.useRef(void 0),w=g.useRef(null),N=g.useRef(null);g.useEffect(()=>{setTimeout(()=>{k.current?.focus(),k.current?.select()},100)},[]);const j=g.useCallback(async U=>{if(!U.trim()){u(lh),b(!1),v(-1);return}h(!0),b(!0),v(-1);const E=U.toLowerCase();try{const[z,I,_,W,ee,F]=await Promise.allSettled([ae.agents.list(),ae.tasks.list({search:U,pageSize:20}),ae.requirements.list(),ae.projects.list(),ae.deliverables.search({q:U,limit:20}),ae.teams.list()]),K=z.status==="fulfilled"?z.value.agents.filter(te=>te.name?.toLowerCase().includes(E)||te.role?.toLowerCase().includes(E)):[],Z=I.status==="fulfilled"?I.value.tasks:[],B=_.status==="fulfilled"?_.value.requirements.filter(te=>te.title?.toLowerCase().includes(E)||te.description?.toLowerCase().includes(E)):[],J=W.status==="fulfilled"?W.value.projects.filter(te=>te.name?.toLowerCase().includes(E)||te.description?.toLowerCase().includes(E)):[],Q=ee.status==="fulfilled"?ee.value.results:[],ne=[];if(F.status==="fulfilled"){const te=await Promise.allSettled(F.value.teams.map(Y=>ae.workflows.list(Y.id)));for(const Y of te)if(Y.status==="fulfilled")for(const ie of Y.value.workflows)(ie.name.toLowerCase().includes(E)||(ie.displayName||"").toLowerCase().includes(E)||ie.description?.toLowerCase().includes(E))&&ne.push(ie)}u({agents:K,tasks:Z,requirements:B,projects:J,deliverables:Q,workflows:ne})}catch{u(lh)}finally{h(!1)}},[]),T=U=>{a(U),C.current&&clearTimeout(C.current),C.current=setTimeout(()=>j(U),400)},M=g.useCallback((U,E)=>{e(),vt.navigate(U,E)},[e]),D=[{id:"all",label:r("common:all",{defaultValue:"全部"})},{id:"agents",label:r("common:agents",{defaultValue:"智能体"})},{id:"tasks",label:r("common:tasks",{defaultValue:"任务"})},{id:"requirements",label:r("common:requirements",{defaultValue:"需求"})},{id:"projects",label:r("common:projects",{defaultValue:"项目"})},{id:"deliverables",label:r("common:deliverables",{defaultValue:"交付物"})},{id:"workflows",label:r("common:workflows",{defaultValue:"工作流"})}],L=g.useMemo(()=>Wie[n||""]||Kie,[n]),O=g.useMemo(()=>{const U=[],E=i==="all"?8:void 0,z=I=>{if(i!=="all"&&i!==I)return;const _=d[I].length;if(I==="workflows"){const W=E?d.workflows.slice(0,E):d.workflows;for(const ee of W)U.push({id:ee.name,type:"workflow",page:Oe.WORK,params:{boardType:"workflows"}})}else{const W=d[I],ee=E?W.slice(0,E):W;for(const F of ee)switch(I){case"agents":U.push({id:F.id,type:"agent",page:Oe.TEAM,params:{agentId:F.id}});break;case"tasks":U.push({id:F.id,type:"task",page:Oe.WORK,params:{openTask:F.id}});break;case"requirements":U.push({id:F.id,type:"requirement",page:Oe.WORK,params:{openRequirement:F.id}});break;case"projects":U.push({id:F.id,type:"project",page:Oe.WORK,params:{projectId:F.id}});break;case"deliverables":U.push({id:F.id,type:"deliverable",page:Oe.DELIVERABLES,params:{openDeliverable:F.id}});break}}E&&_>E&&U.push({id:`more_${I}`,type:"showMore",page:"",expandCategory:I,totalCount:_})};for(const I of L)z(I);return U},[d,i,L]),P=g.useCallback(U=>{if(U.type==="showMore"&&U.expandCategory){l(U.expandCategory),v(-1);return}M(U.page,U.params)},[M]);g.useEffect(()=>{const U=N.current;if(!U||x<0)return;const E=U.querySelector(`[data-idx="${x}"]`);E&&E.scrollIntoView({block:"nearest"})},[x]);const R=g.useCallback(U=>{if(U.key==="Escape"){e();return}if(U.key==="Tab"){U.preventDefault();const I=D.map(ee=>ee.id),_=I.indexOf(i),W=U.shiftKey?_<=0?I.length-1:_-1:_>=I.length-1?0:_+1;l(I[W]),v(-1);return}const E=U.ctrlKey&&U.key==="n"||U.key==="ArrowDown",z=U.ctrlKey&&U.key==="p"||U.key==="ArrowUp";if(E||z){U.preventDefault(),v(I=>{const _=O.length-1;return _<0?-1:E?I>=_?0:I+1:I<=0?_:I-1});return}U.key==="Enter"&&(U.preventDefault(),x>=0&&x<O.length&&P(O[x]))},[e,O,x,P,D,i]);g.useEffect(()=>(document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)),[R]);const H=O.length>0;let q=0;return t.jsx("div",{ref:w,className:"fixed inset-0 bg-black/50 flex items-start justify-center z-50 pt-[8vh]",onClick:U=>{U.target===w.current&&e()},children:t.jsxs("div",{className:"bg-surface-primary border border-border-default rounded-2xl shadow-2xl w-full max-w-3xl max-h-[78vh] flex flex-col overflow-hidden animate-fadeIn",children:[t.jsxs("div",{className:"shrink-0 px-5 pt-4 pb-3 border-b border-border-default space-y-3",children:[t.jsxs("div",{className:"relative",children:[t.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:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),t.jsx("input",{ref:k,value:s,onChange:U=>T(U.target.value),placeholder:r("common:search"),className:"w-full bg-surface-elevated border border-border-default rounded-xl pl-9 pr-9 py-2.5 text-sm text-fg-primary placeholder:text-fg-tertiary focus:border-brand-500 focus:outline-none transition-colors"}),s&&t.jsx("button",{onClick:()=>{a(""),u(lh),b(!1),v(-1),k.current?.focus()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-fg-tertiary hover:text-fg-secondary",children:t.jsxs("svg",{width:"14",height:"14",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"})]})})]}),t.jsx("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:D.map(U=>t.jsx("button",{onClick:()=>{l(U.id),v(-1)},className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${i===U.id?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:U.label},U.id))})]}),t.jsxs("div",{ref:N,className:"flex-1 overflow-y-auto px-5 py-3",children:[m&&t.jsx("div",{className:"flex items-center justify-center py-8",children:t.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:r("common:loading")})}),!m&&p&&!H&&t.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[t.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-2",children:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),t.jsx("p",{className:"text-sm text-fg-tertiary",children:r("common:noResults",{defaultValue:"没有找到相关结果"})})]}),!m&&H&&t.jsx("div",{className:"space-y-4",children:L.map(U=>{if(i!=="all"&&i!==U)return null;const E=i==="all"?8:void 0,z=I=>{const _=q++,W=I==="agents"?d.agents.length:I==="tasks"?d.tasks.length:I==="requirements"?d.requirements.length:I==="projects"?d.projects.length:I==="workflows"?d.workflows.length:d.deliverables.length;return t.jsxs("button",{"data-idx":_,onClick:()=>{l(I),v(-1)},className:`mt-1 w-full text-xs py-1.5 rounded-lg transition-colors ${_===x?"bg-brand-600/15 ring-1 ring-brand-500/40 text-brand-500":"text-brand-500 hover:text-brand-400 hover:bg-surface-overlay"}`,children:[r("common:showAll",{defaultValue:"查看全部"})," (",W,")"]})};return U==="agents"&&d.agents.length>0?t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:r("common:agents",{defaultValue:"智能体"})}),t.jsx("div",{className:"space-y-0.5",children:(E?d.agents.slice(0,E):d.agents).map(I=>{const _=q++;return t.jsxs("button",{"data-idx":_,onClick:()=>M(Oe.TEAM,{agentId:I.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${_===x?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[t.jsx(lr,{name:I.name||"Agent",avatarUrl:I.avatarUrl,size:28}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:I.name}),t.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:I.role||I.status})]}),t.jsx(Yie,{status:I.status})]},I.id)})}),E&&d.agents.length>E&&z("agents")]},"agents"):U==="tasks"&&d.tasks.length>0?t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:r("common:tasks",{defaultValue:"任务"})}),t.jsx("div",{className:"space-y-0.5",children:(E?d.tasks.slice(0,E):d.tasks).map(I=>{const _=q++;return t.jsxs("button",{"data-idx":_,onClick:()=>M(Oe.WORK,{openTask:I.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${_===x?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[t.jsx(Xie,{status:I.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:I.title}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[I.status," · ",I.priority||""]})]})]},I.id)})}),E&&d.tasks.length>E&&z("tasks")]},"tasks"):U==="requirements"&&d.requirements.length>0?t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:r("common:requirements",{defaultValue:"需求"})}),t.jsx("div",{className:"space-y-0.5",children:(E?d.requirements.slice(0,E):d.requirements).map(I=>{const _=q++;return t.jsxs("button",{"data-idx":_,onClick:()=>M(Oe.WORK,{openRequirement:I.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${_===x?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[t.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${I.status==="approved"?"text-green-500 bg-green-500/15":I.status==="pending"?"text-amber-500 bg-amber-500/15":I.status==="rejected"?"text-red-500 bg-red-500/15":"text-fg-tertiary bg-surface-elevated"}`,children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),t.jsx("polyline",{points:"14 2 14 8 20 8"}),t.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),t.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:I.title}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[I.status," · ",I.priority||""]})]})]},I.id)})}),E&&d.requirements.length>E&&z("requirements")]},"requirements"):U==="projects"&&d.projects.length>0?t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:r("common:projects",{defaultValue:"项目"})}),t.jsx("div",{className:"space-y-0.5",children:(E?d.projects.slice(0,E):d.projects).map(I=>{const _=q++;return t.jsxs("button",{"data-idx":_,onClick:()=>M(Oe.WORK,{projectId:I.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${_===x?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[t.jsx("div",{className:"w-7 h-7 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-brand-500",children:t.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"})})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:I.name}),I.description&&t.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:I.description})]})]},I.id)})}),E&&d.projects.length>E&&z("projects")]},"projects"):U==="deliverables"&&d.deliverables.length>0?t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:r("common:deliverables",{defaultValue:"交付物"})}),t.jsx("div",{className:"space-y-0.5",children:(E?d.deliverables.slice(0,E):d.deliverables).map(I=>{const _=q++;return t.jsxs("button",{"data-idx":_,onClick:()=>M(Oe.DELIVERABLES,{openDeliverable:I.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${_===x?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[t.jsx("div",{className:"w-7 h-7 rounded-lg bg-purple-500/15 flex items-center justify-center shrink-0",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-purple-500",children:[t.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),t.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:I.title}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[I.type," · ",I.status]})]})]},I.id)})}),E&&d.deliverables.length>E&&z("deliverables")]},"deliverables"):U==="workflows"&&d.workflows.length>0?t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:r("common:workflows",{defaultValue:"工作流"})}),t.jsx("div",{className:"space-y-0.5",children:(E?d.workflows.slice(0,E):d.workflows).map(I=>{const _=q++;return t.jsxs("button",{"data-idx":_,onClick:()=>M(Oe.WORK,{boardType:"workflows"}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${_===x?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[t.jsx("div",{className:"w-7 h-7 rounded-lg bg-teal-500/15 flex items-center justify-center shrink-0",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-teal-500",children:[t.jsx("circle",{cx:"12",cy:"12",r:"3"}),t.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"})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:I.displayName||I.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[I.stepCount," steps · v",I.version]})]})]},I.name)})}),E&&d.workflows.length>E&&z("workflows")]},"workflows"):null})}),!m&&!p&&t.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[t.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-2",children:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),t.jsx("p",{className:"text-sm text-fg-tertiary",children:r("common:searchHint",{defaultValue:"输入关键词搜索"})})]})]}),t.jsxs("div",{className:"shrink-0 px-5 py-2 border-t border-border-default flex items-center gap-4 text-xs text-fg-tertiary flex-wrap",children:[t.jsxs("span",{children:[t.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:navigator.platform.toUpperCase().includes("MAC")?"Cmd+P":"Ctrl+P"})," ",r("common:toggle",{defaultValue:"唤起/关闭"})]}),t.jsxs("span",{children:[t.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Tab"})," ",r("common:switchTab",{defaultValue:"切换分类"})]}),t.jsxs("span",{children:[t.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"↑↓"})," ",r("common:navigate",{defaultValue:"导航"})]}),t.jsxs("span",{children:[t.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Enter"})," ",r("common:open",{defaultValue:"打开"})]}),t.jsxs("span",{children:[t.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Esc"})," ",r("common:close",{defaultValue:"关闭"})]})]})]})})}function Yie({status:e}){const n=e==="active"||e==="idle"?"bg-green-500":e==="working"||e==="busy"?"bg-blue-500":e==="paused"?"bg-amber-500":"bg-gray-400";return t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${n}`})}function Xie({status:e}){const n=e==="completed"?"text-green-500 bg-green-500/15":e==="in_progress"?"text-blue-500 bg-blue-500/15":e==="pending"?"text-amber-500 bg-amber-500/15":"text-fg-tertiary bg-surface-elevated";return t.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${n}`,children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("path",{d:"M9 11l3 3L22 4"}),t.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})})}const Qie={visibility:"hidden",position:"absolute",inset:0,pointerEvents:"none",zIndex:-1},Zie=g.memo(function({id:n,activePage:r,children:s}){const a=n===r;return t.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",style:a?void 0:Qie,children:s})},(e,n)=>{const r=e.id===e.activePage,s=n.id===n.activePage;return r!==s?!1:s?e.children===n.children:!0}),Yb={};function Jie(){const{t:e}=ft("common"),[n,r]=g.useState(fc),[s,a]=g.useState(()=>!localStorage.getItem("markus_onboarded")),[i,l]=g.useState(!0),d=Os(),u=WX(),m=M0({side:"left",defaultWidth:160,minWidth:140,maxWidth:400,collapsedWidth:64,storageKey:"markus_sidebar"}),[h,p]=g.useState(()=>new Set([fc()])),[b,x]=g.useState("loading"),[v,k]=g.useState(null),[C,w]=g.useState({hasOwner:!1,hasMultipleUsers:!1}),[N,j]=g.useState(!1),[T,M]=g.useState(!1),[D,L]=g.useState(null),[O,P]=g.useState(!1),[R,H]=g.useState(null),[q,U]=g.useState(()=>{const te=localStorage.getItem("markus_update_dismissed");return te||null}),[E,z]=g.useState(null),[I,_]=g.useState(!1),W=g.useCallback(()=>{ae.license.get().then(te=>{if(te.plan==="enterprise"){z(null);return}if(te.usage&&te.limits){const Y=te.limits.maxTeams>0&&te.usage.teams>=te.limits.maxTeams,ie=te.limits.maxToolCallsPerDay>0&&te.usage.toolCallsToday>=te.limits.maxToolCallsPerDay;Y||ie?(z({teams:Y||void 0,toolCalls:ie||void 0}),_(!1)):z(null)}}).catch(()=>{})},[]);g.useEffect(()=>{const te=()=>{document.visibilityState==="visible"&&W()};window.addEventListener("markus:check-license-limits",W),document.addEventListener("visibilitychange",te);const Y=setInterval(W,300*1e3);return()=>{window.removeEventListener("markus:check-license-limits",W),document.removeEventListener("visibilitychange",te),clearInterval(Y)}},[W]);const[ee,F]=g.useState(!1);g.useEffect(()=>{if(d)return;const te=navigator.platform.toUpperCase().includes("MAC"),Y=pe=>{te&&pe.metaKey&&!pe.ctrlKey&&pe.key==="p"?(pe.preventDefault(),F(ge=>!ge)):!te&&pe.ctrlKey&&!pe.metaKey&&pe.key==="p"&&(pe.preventDefault(),F(ge=>!ge))},ie=()=>F(!0);return document.addEventListener("keydown",Y),window.addEventListener("markus:open-search",ie),()=>{document.removeEventListener("keydown",Y),window.removeEventListener("markus:open-search",ie)}},[d]);const K=g.useCallback(te=>{let Y=pc(te);d?Y=E$[Y]??Y:Y===Oe.NOTIFICATIONS&&(Y=Oe.HOME);const ie=fc(),pe=window.location.hash.slice(1);pe!==ie?Yb[ie]=pe:delete Yb[ie];const ge=Y!==Oe.WORK?Yb[Y]:void 0;ge&&ge!==Y?(history.pushState(null,"","#"+Y),history.pushState(null,"","#"+ge)):history.pushState(null,"","#"+Y),window.dispatchEvent(new HashChangeEvent("hashchange")),r(Y),p(ye=>ye.has(Y)?ye:new Set([...ye,Y]))},[d]);g.useEffect(()=>{vt.setHandler(te=>K(te))},[K]);const Z=g.useCallback(()=>{fetch("/api/settings/llm").then(te=>te.ok?te.json():null).then(te=>{if(te?.providers){const Y=Object.values(te.providers).some(ie=>ie.configured);L(Y)}}).catch(()=>{})},[]);g.useEffect(()=>{const te=new URLSearchParams(window.location.search),Y=te.get("install");if(Y&&fc()!==Oe.STORE){const ge=te.get("type"),me=ge&&{agent:"agents",team:"teams",skill:"skills"}[ge]||"agents";localStorage.setItem("markus_nav_installItem",Y),localStorage.setItem("markus_nav_storeTab",me),te.delete("install"),te.delete("type");const re=te.toString();window.history.replaceState(null,"",window.location.pathname+(re?`?${re}`:"")+"#store"),setTimeout(()=>vt.navigate(Oe.STORE,{storeTab:me,installItem:Y}),300)}ae.auth.me().then(({user:ge})=>{x(ge),k(!0),un.connect(ge.id),Z(),ae.health().then(me=>{me.updateAvailable&&me.latestVersion&&H({latestVersion:me.latestVersion,currentVersion:me.version})}).catch(()=>{}),W();const ye=()=>{cc(Ua.builderArtifacts,()=>ae.builder.artifacts.list()),cc(Ua.builderAgents,()=>ae.agents.list()),cc(Ua.builderHubMyItems,()=>Cn.myItems()),cc(Ua.builderInstalled,()=>ae.builder.artifacts.installed()),cc(Ua.hubAgents,()=>Cn.search({type:"agent",limit:50})),cc(Ua.hubTeams,()=>Cn.search({type:"team",limit:50})),cc(Ua.hubSkills,()=>Cn.search({type:"skill",limit:50}))};typeof requestIdleCallback=="function"?requestIdleCallback(ye,{timeout:5e3}):setTimeout(ye,3e3)}).catch(()=>{x(null),ae.auth.status().then(({initialized:ge,hasOwner:ye,hasMultipleUsers:me})=>{k(ge),w({hasOwner:ye,hasMultipleUsers:me})}).catch(()=>k(!0))}),un.connect();const ie=un.on("notification",()=>{window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}),pe=()=>{const ge=fc();r(ge),p(ye=>ye.has(ge)?ye:new Set([...ye,ge]))};return window.addEventListener("hashchange",pe),window.addEventListener("popstate",pe),()=>{ie(),un.disconnect(),window.removeEventListener("hashchange",pe),window.removeEventListener("popstate",pe)}},[]);const B=b!=="loading"&&b!==null?b:void 0,J=g.useMemo(()=>d?{[Oe.HOME]:t.jsx(r4,{authUser:B}),[Oe.TEAM]:t.jsx(Ij,{authUser:B}),[Oe.BUILDER]:t.jsx(Hie,{authUser:B}),[Oe.SETTINGS]:t.jsx(f3,{theme:u.mode,onThemeChange:u.setMode,authUser:B,onLogout:()=>{ae.auth.logout().catch(()=>{}),v0(),x(null)},onUserUpdated:te=>x(te)}),[Oe.WORK]:t.jsx(t6,{authUser:B}),[Oe.DELIVERABLES]:t.jsx(s6,{authUser:B}),[Oe.NOTIFICATIONS]:t.jsx(Lie,{authUser:B}),[Oe.REPORTS]:t.jsx(i6,{authUser:B}),[Oe.SEARCH]:t.jsx(Pie,{})}:{[Oe.HOME]:t.jsx(r4,{authUser:B}),[Oe.TEAM]:t.jsx(Ij,{authUser:B}),[Oe.SETTINGS]:t.jsx(f3,{theme:u.mode,onThemeChange:u.setMode,authUser:B,onLogout:()=>{ae.auth.logout().catch(()=>{}),v0(),x(null)},onUserUpdated:te=>x(te)}),[Oe.STORE]:t.jsx(ZQ,{authUser:B}),[Oe.BUILDER]:t.jsx(E8,{authUser:B}),[Oe.WORK]:t.jsx(t6,{authUser:B}),[Oe.DELIVERABLES]:t.jsx(s6,{authUser:B}),[Oe.REPORTS]:t.jsx(i6,{authUser:B})},[B?.id,B?.role,u.mode,d]);if(b==="loading"||b===null&&v===null)return t.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center",children:t.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:e("loading")})});const ne=(typeof window<"u"?window.location.hash:"").match(/^#invite\?token=([a-f0-9]+)/);return ne?t.jsx(Uie,{token:ne[1],onComplete:()=>{window.location.hash="",localStorage.removeItem("markus_onboarded"),a(!0),j(!0),x("loading"),ae.auth.me().then(te=>x(te.user)).catch(()=>x(null))}}):b===null?t.jsx(qie,{hasOwner:C.hasOwner,hasMultipleUsers:C.hasMultipleUsers,onLogin:(te,Y,ie)=>{x(te),Y?(localStorage.removeItem("markus_onboarded"),a(!0),ie?.fromHub&&j(!0)):localStorage.getItem("markus_onboarded")||(localStorage.setItem("markus_onboarded","1"),a(!1))}}):T?t.jsx(Vie,{onComplete:()=>M(!1),isFirstTime:!0}):s?t.jsx(Fie,{theme:u.mode,onThemeChange:u.setMode,skipProfile:N,onComplete:()=>{localStorage.setItem("markus_onboarded","1"),a(!1),j(!1),Z(),K(Oe.HOME)}}):t.jsxs("div",{className:`flex h-dvh bg-surface-primary text-fg-primary overflow-x-hidden ${d?"flex-col":""}`,children:[!d&&n!==Oe.SETTINGS&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"relative z-40 shrink-0",style:{width:m.width},children:t.jsx(zie,{currentPage:n,onNavigate:te=>{K(te),l(!1)},authUser:b,collapsed:m.collapsed,onToggleCollapse:m.toggle})}),t.jsx("div",{className:`${m.collapsed?"w-0":"w-1.5 cursor-col-resize"} shrink-0 group relative z-10 flex items-center justify-center`,onMouseDown:m.collapsed?void 0:m.onResizeStart,children:!m.collapsed&&t.jsx("div",{className:"w-px h-2/3 border-l border-dashed border-transparent group-hover:border-border-default group-active:border-fg-tertiary transition-colors"})})]}),t.jsxs("div",{className:`flex-1 overflow-hidden flex flex-col min-w-0 ${d&&n!==Oe.SETTINGS&&n!==Oe.SEARCH?"pb-14":""}`,children:[D===!1&&!O&&n!==Oe.SETTINGS&&t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-amber-500/10 border-b border-amber-500/30 text-amber-600 text-sm shrink-0",children:[t.jsx("span",{className:d?"text-xs":"",children:e("llmBanner.message")}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>{window.location.hash="#settings/providers"},className:"px-3 py-1 bg-amber-700/50 hover:bg-amber-700/70 text-white text-xs rounded-lg transition-colors",children:e("llmBanner.goToSettings")}),t.jsx("button",{onClick:()=>P(!0),className:"text-amber-500 hover:text-amber-600 text-xs",children:e("dismiss")})]})]}),R&&q!==R.latestVersion&&t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-brand-500/10 border-b border-brand-500/30 text-brand-400 text-sm shrink-0",children:[t.jsx("span",{className:d?"text-xs":"",children:e("update.available",{latest:R.latestVersion,current:R.currentVersion})}),t.jsxs("span",{className:"flex items-center gap-3 shrink-0",children:[t.jsx("a",{href:"https://markus.global/download",target:"_blank",rel:"noopener noreferrer",className:"text-xs font-medium text-brand-400 hover:text-brand-300 transition-colors",children:e("update.download")}),t.jsx("button",{onClick:()=>{U(R.latestVersion),localStorage.setItem("markus_update_dismissed",R.latestVersion)},className:"text-fg-tertiary hover:text-fg-secondary text-xs shrink-0",children:e("dismiss")})]})]}),E&&!I&&n!==Oe.SETTINGS&&t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-orange-500/10 border-b border-orange-500/30 text-orange-400 text-sm shrink-0",children:[t.jsx("span",{className:d?"text-xs":"",children:E.teams&&E.toolCalls?e("license.limitReachedBoth"):E.teams?e("license.limitReachedTeams"):e("license.limitReachedToolCalls")}),t.jsxs("span",{className:"flex items-center gap-3 shrink-0",children:[t.jsx("button",{onClick:()=>{window.location.hash="settings/account"},className:"px-3 py-1 bg-orange-600/50 hover:bg-orange-600/70 text-white text-xs rounded-lg transition-colors",children:e("license.upgradeLicense")}),t.jsx("button",{onClick:()=>_(!0),className:"text-fg-tertiary hover:text-fg-secondary text-xs shrink-0",children:e("dismiss")})]})]}),t.jsx("main",{className:"flex-1 overflow-hidden flex flex-col relative",children:Object.keys(J).map(te=>h.has(te)?t.jsx(Zie,{id:te,activePage:n,children:J[te]},te):null)})]}),d&&n!==Oe.SETTINGS&&n!==Oe.SEARCH&&t.jsx($ie,{currentPage:n,onNavigate:K,userId:B?.id}),d&&t.jsx(P$,{authUser:B,onNavigate:K}),!d&&ee&&t.jsx(Gie,{onClose:()=>F(!1),currentPage:n})]})}nA.createRoot(document.getElementById("root")).render(t.jsx(g.StrictMode,{children:t.jsx(Jie,{})}));
@@ -11,7 +11,7 @@
11
11
  <script>
12
12
  (function(){var t=localStorage.getItem('markus-theme');if(t==='midnight'){t='dark';try{localStorage.setItem('markus-theme','dark')}catch(e){}}if(t&&t!=='system')document.documentElement.classList.add(t)})();
13
13
  </script>
14
- <script type="module" crossorigin src="/assets/index-Cn92wqYJ.js"></script>
14
+ <script type="module" crossorigin src="/assets/index-CEBWX7wE.js"></script>
15
15
  <link rel="stylesheet" crossorigin href="/assets/index-DVGYGLou.css">
16
16
  </head>
17
17
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markus-global/cli",
3
- "version": "0.8.2-rc.0",
3
+ "version": "0.8.2",
4
4
  "description": "Markus — AI Digital Workforce Platform",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0-or-later",