import{b as e,n as f,e as D}from"./vendor-lit-B2r-dKc0.js";import{aC as E,aE as w,aD as g}from"./app-session-runtime-CeFJDILJ.js";import{a as H,s as r,b as L,f as O,r as T,c as j}from"./delegate-cards-BbatMXY8.js";import{B as l}from"./vendor-lucide-B9Yl1Gez.js";import"./vendor-mini-lit-CpUQub-j.js";import"./vendor-marked-_iteVaMm.js";import"./app-review-C3CmcSYC.js";import"./app-panel-workspace-C3XDRCgE.js";import"./app-routing-C_r2pdnC.js";import"./app-message-reducer-wATqnZGf.js";import"./vendor-sortable-B1o3v0Qs.js";import"./app-inbox-CaZD85aD.js";import"./app-pr-walkthrough-WipZACSB.js";function I(d){return d&&d.content?.filter(s=>s.type==="text").map(s=>s.text).join(`
`)||""}class W{render(s,a,x){const i=E(a,x),o=D(),c=D(),u=a?.details;if(!a){if(s?.parallel&&s.parallel.length>0)return{content:e`
						<div>
							${w(i,l,`Delegating to ${s.parallel.length} agents`)}
							<div class="mt-2 space-y-1">
								${s.parallel.map(m=>H(r(m.instructions)))}
							</div>
						</div>
					`,isCustom:!1};const n=s?.instructions?r(s.instructions):"task";return{content:e`
					<div>
						${w(i,l,e`Delegating to agent — <span class="font-mono text-xs">${n}</span>`)}
					</div>
				`,isCustom:!1}}if(u?.delegates&&u.delegates.length>0){const n=u.delegates,m=n.every(t=>t.status==="completed");if(n.length===1){const t=n[0],p=s?.instructions||t.instructions;return{content:e`
						<div>
							${g(i,l,e`Delegated — <span class="font-mono text-xs">${r(p)}</span>
									<span class="${L(t.status)} text-xs ml-1">(${O(t.durationMs)})</span>
									${T(t.sessionId)}`,o,c,!1)}
							<div ${f(o)} class="max-h-0 overflow-hidden transition-all duration-300">
								<div class="mt-2 text-sm whitespace-pre-wrap text-muted-foreground">${I(a)}</div>
							</div>
						</div>
					`,isCustom:!1}}const v=n.filter(t=>t.status==="completed").length,$=n.filter(t=>t.status!=="completed"&&t.status!=="running"&&t.status!=="starting").length,k=e`Delegated to ${n.length} agents —
				${m?e`<span class="text-green-500 text-xs ml-1">all completed</span>`:$>0?e`<span class="text-xs ml-1"><span class="text-green-500">${v} done</span>, <span class="text-destructive">${$} failed</span></span>`:e`<span class="text-xs text-muted-foreground ml-1">${v}/${n.length} completed</span>`}`,b=s?.parallel||[],M=x&&n.some(t=>t.status==="running"),h=n.map((t,p)=>{const B=b[p]?.instructions||t.instructions;return{id:t.id,sessionId:t.sessionId,name:r(B),status:t.status,durationMs:t.durationMs}}),C=M||h.some(t=>t.sessionId);return{content:e`
					<div>
						${g(i,l,k,o,c,C)}
						<div ${f(o)} class="${C?"max-h-[2000px] mt-3":"max-h-0"} overflow-hidden transition-all duration-300">
							${j(h)}
						</div>
					</div>
				`,isCustom:!1}}const y=I(a),R=s?.instructions?r(s.instructions):"task";return{content:e`
				<div>
					${g(i,l,e`Delegated — <span class="font-mono text-xs">${R}</span>`,o,c,!1)}
					<div ${f(o)} class="max-h-0 overflow-hidden transition-all duration-300">
						<div class="mt-2 text-sm whitespace-pre-wrap text-muted-foreground">${y}</div>
					</div>
				</div>
			`,isCustom:!1}}}export{W as DelegateRenderer};
