import{b as e,n as I,e as M}from"./vendor-lit-BtHfzs80.js";import{au as C,aw as m,ax as k,av as D}from"./index-rvuS68Al.js";import{a as E}from"./vendor-mini-lit-Cx886NBU.js";import{aA as h,aB as y,aC as v,aD as L,aE as S,Z as T}from"./vendor-lucide-DBEJLfdn.js";import"./vendor-marked-_iteVaMm.js";import"./vendor-sortable-B1o3v0Qs.js";function $(t){const s=t?.content?.filter(o=>o.type==="text").map(o=>o.text).join(`
`)||"";let n=null;try{n=JSON.parse(s)}catch{}return{text:s,data:n}}function g(t,s=60){return t?t.length>s?t.slice(0,s)+"…":t:""}function A(t){return!t||typeof t!="string"?"":t.length>8?t.slice(0,8):t}function _(t){if(!t||typeof t!="number")return"";const s=Math.max(0,Date.now()-t),n=Math.floor(s/1e3);if(n<60)return"now";const o=Math.floor(n/60);if(o<60)return`${o}m`;const a=Math.floor(o/60);if(a<24)return`${a}h`;const r=Math.floor(a/24);return r<30?`${r}d`:`${Math.floor(r/30)}mo`}function w(t){const n={pending:"bg-blue-500/20 text-blue-600 dark:text-blue-400",completed:"bg-green-500/20 text-green-600 dark:text-green-400",failed:"bg-red-500/20 text-red-600 dark:text-red-400",cancelled:"bg-muted text-muted-foreground line-through"}[t]||"bg-muted text-muted-foreground";return e`<span class="px-1.5 py-0.5 rounded text-xs font-medium ${n}">${t}</span>`}function j(t){const s=t?.type||"";let n="",o=null;switch(s){case"trigger":n="trigger",o=T;break;case"manual_api":n="api",o=S;break;case"manual_ui":n="ui",o=L;break;default:return e``}return e`
		<span class="inline-flex items-center gap-1 text-xs text-muted-foreground">
			<span class="inline-block">${E(o,"sm")}</span>
			${n}
		</span>
	`}function B(t){const s=A(t);return s?e`<span class="font-mono text-xs text-muted-foreground">${s}</span>`:e``}function F(t){return e`
		<div class="flex items-center gap-2 text-xs py-0.5 min-w-0">
			${w(t.state||"pending")}
			${j(t.source)}
			<span class="font-medium truncate flex-1 min-w-0">${g(t.title||"Untitled",60)}</span>
			${t.createdAt?e`<span class="text-xs text-muted-foreground shrink-0">${_(t.createdAt)}</span>`:""}
			${B(t.id)}
		</div>
	`}class P{render(s,n,o){const a=C(n,o),r=s?.state||"pending";if(!n)return{content:e`<div>${m(a,v,e`Listing inbox <span class="text-xs text-muted-foreground">(${r})</span>…`)}</div>`,isCustom:!1};const{data:i,text:c}=$(n);if(n.isError){const l=k(n);return{content:e`<div>
					${m(a,v,l?"Aborted inbox list":"Inbox list failed")}
					<div class="mt-1 text-xs ${l?"text-amber-600 dark:text-amber-400":"text-destructive"}">${c}</div>
				</div>`,isCustom:!1}}const d=i?.entries||(Array.isArray(i)?i:[]);if(d.length===0)return{content:e`<div>${m(a,v,e`No ${r} entries`)}</div>`,isCustom:!1};const x=new Map;for(const l of d)x.set(l.state||"pending",(x.get(l.state||"pending")||0)+1);const u=Array.from(x.entries()).map(([l,R])=>`${R} ${l}`).join(", "),f=M(),p=M(),b=`${d.length} inbox ${d.length===1?"entry":"entries"}`;return{content:e`<div>
				${D(a,v,e`${b} <span class="text-xs text-muted-foreground ml-1">(${u})</span>`,f,p,!1)}
				<div ${I(f)} class="max-h-0 overflow-hidden transition-all duration-300">
					<div class="mt-2 space-y-1">${d.map(F)}</div>
				</div>
			</div>`,isCustom:!1}}}class X{render(s,n,o){const a=C(n,o),r=A(s?.entry_id);if(!n)return{content:e`<div>${m(a,h,e`Completing <span class="font-mono text-xs">${r}</span>…`)}</div>`,isCustom:!1};if(n.isError){const{text:x}=$(n),u=k(n),f=u?e`Aborted completing <span class="font-mono text-xs">${r}</span>`:e`Failed to complete <span class="font-mono text-xs">${r}</span>`,p=u?"text-amber-600 dark:text-amber-400":"text-destructive";return{content:e`<div>
					${m(a,h,f)}
					<div class="mt-1 text-xs ${p}">${x}</div>
				</div>`,isCustom:!1}}const{data:i}=$(n),c=i?.title?g(i.title,50):"",d=s?.summary||i?.result;return{content:e`<div>
				${m(a,h,e`Completed <span class="font-mono text-xs">${r}</span>
						${c?e`<span class="font-medium text-xs">${c}</span>`:""}
						${w("completed")}`)}
				${d?e`<div class="mt-1 text-xs text-muted-foreground">${g(d,240)}</div>`:""}
			</div>`,isCustom:!1}}}class q{render(s,n,o){const a=C(n,o),r=A(s?.entry_id),i=s?.outcome||"";if(!n)return{content:e`<div>${m(a,y,e`Dismissing <span class="font-mono text-xs">${r}</span>${i?e` <span class="text-xs text-muted-foreground">(${i})</span>`:""}…`)}</div>`,isCustom:!1};if(n.isError){const{text:f}=$(n),p=k(n),b=p?e`Aborted dismissing <span class="font-mono text-xs">${r}</span>`:e`Failed to dismiss <span class="font-mono text-xs">${r}</span>`,l=p?"text-amber-600 dark:text-amber-400":"text-destructive";return{content:e`<div>
					${m(a,y,b)}
					<div class="mt-1 text-xs ${l}">${f}</div>
				</div>`,isCustom:!1}}const{data:c}=$(n),d=c?.title?g(c.title,50):"",x=c?.state||i||"failed",u=s?.reason||c?.error;return{content:e`<div>
				${m(a,y,e`Dismissed <span class="font-mono text-xs">${r}</span>
						${d?e`<span class="font-medium text-xs">${d}</span>`:""}
						${w(x)}`)}
				${u?e`<div class="mt-1 text-xs text-muted-foreground">${g(u,240)}</div>`:""}
			</div>`,isCustom:!1}}}export{X as InboxCompleteRenderer,q as InboxDismissRenderer,P as InboxListRenderer};
