import{b as t,A as r,n as k,e as f}from"./vendor-lit-B2r-dKc0.js";import{a as x}from"./vendor-mini-lit-CpUQub-j.js";import{aD as w,aE as N}from"./app-session-runtime-CeFJDILJ.js";import{f as S}from"./delegate-cards-BbatMXY8.js";import{C as A,X as D,$ as E,aw as M}from"./vendor-lucide-B9Yl1Gez.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 P(s){return s.state?s.state:s.success===!1?"error":"complete"}function T(s){const o=(s.error||"").trim();return!o||/^unknown error\.?$/i.test(o)?null:o}class Q{render(o,v,R,F){const e=v?.details??o,m=f(),g=f();if(!e)return{content:t`<div class="text-xs text-muted-foreground">Compacting…</div>`,isCustom:!1};const n=P(e),c=n==="in-progress",a=n==="error",$=n==="complete",l=c?"inprogress":a?"error":"complete",u=a?E:M,b=c?"Compacting context…":a?"Compaction failed":"Context compacted",C=$?t`<span
					class="ml-1 inline-flex items-center text-green-600 dark:text-green-500"
					data-test="verdict"
					data-verdict="ok"
				>${x(A,"sm")}</span>`:a?t`<span
						class="ml-1 inline-flex items-center text-destructive"
						data-test="verdict"
						data-verdict="fail"
					>${x(D,"sm")}</span>`:r,d=(()=>{if(c){const i=e.startedAt?Date.parse(e.startedAt):NaN;return Number.isFinite(i)?t`<span
					class="text-xs text-muted-foreground tabular-nums"
					title="Elapsed since compaction started"
				><live-timer .startTime=${i} .running=${!0}></live-timer></span>`:r}return typeof e.durationMs=="number"&&Number.isFinite(e.durationMs)?t`<span
					class="text-xs text-muted-foreground tabular-nums"
					title="Total compaction duration"
				>${S(e.durationMs)}</span>`:r})(),p=t`
			<span>${b}</span>
			${C}
		`,y=(()=>{const i=T(e);return i?t`<div class="mt-2 text-sm text-destructive" data-test="error">${i}</div>`:r})(),h=a?t`<details class="mt-2">
					<summary class="cursor-pointer text-xs text-muted-foreground">
						payload
					</summary>
					<pre class="mt-1 overflow-x-auto rounded bg-muted/40 p-2 text-xs">
${JSON.stringify(e,null,2)}</pre>
				</details>`:r;return a?{content:t`
					<div
						data-testid="compaction-summary-card"
						data-state=${n}
						class="rounded-md border border-border bg-card p-3"
					>
						${w(l,u,p,m,g,!0,d===r?void 0:d)}
						<div
							${k(m)}
							class="max-h-[2000px] mt-3 overflow-hidden transition-all duration-300"
						>
							${y} ${h}
						</div>
					</div>
				`,isCustom:!1}:{content:t`
				<div
					data-testid="compaction-summary-card"
					data-state=${n}
					class="rounded-md border border-border bg-card p-3"
				>
					${N(l,u,p,d===r?void 0:d)}
				</div>
			`,isCustom:!1}}}export{Q as CompactionSummaryRenderer};
