import{b as s}from"./vendor-lit-B2r-dKc0.js";function y(e,t,n={}){const a=(o,d,l,r=!0)=>{const i=e===o,p=["flex-1 inline-flex items-center justify-center gap-1.5 px-2 py-2 text-xs font-medium border-b-2 transition-colors select-none whitespace-nowrap",i?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground",r?"cursor-pointer":"opacity-40 cursor-not-allowed"].join(" ");return s`
			<button
				type="button"
				data-testid="view-tab-${o}"
				class=${p}
				?disabled=${!r}
				@click=${()=>{r&&t(o)}}
			>
				<span>${d}</span>
				${typeof l=="number"?s`<span class=${i?"text-[10px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium":"text-[10px] px-1.5 py-0.5 rounded-full bg-secondary text-muted-foreground font-medium"} data-testid="view-tab-count-${o}">${l}</span>`:""}
			</button>
		`};return s`
		<div class="flex border-b border-border shrink-0 overflow-x-auto" role="tablist">
			${a("components","Components",n.components)}
			${a("workflows","Workflows",n.workflows)}
			${a("settings","Settings",void 0)}
		</div>
	`}function b(e){return!e||e.length===0?s`<div class="text-sm text-muted-foreground italic">No components proposed.</div>`:s`
		<div class="wf-list">
			${e.map(t=>c(t))}
		</div>
	`}function c(e){const t=e.commands?Object.entries(e.commands):[],n=e.config?Object.entries(e.config):[],a=t.length===0,o=`comp-${e.name}`,d=[];e.repo&&e.repo!=="."&&d.push(e.repo),e.relative_path&&d.push(e.relative_path);const l=d.join(" / ");return s`
		<details
			id=${o}
			data-testid="component-card-${e.name}"
			class="wf-proposal-workflow"
		>
			<summary class="wf-row" style="list-style:none;">
				<div class="wf-row-info">
					<span class="wf-row-name">${e.name}</span>
					${l?s`<span class="wf-row-desc" style="font-family:var(--font-mono,monospace);">${l}</span>`:""}
				</div>
				<div class="wf-row-badges">
					${a?s`<span class="wf-badge" data-testid="data-only-badge">data-only</span>`:s`<span class="wf-badge">${t.length} cmd${t.length===1?"":"s"}</span>`}
					${e.worktree_setup_command?s`<span class="wf-badge">setup</span>`:""}
					${n.length>0?s`<span class="wf-badge">${n.length} cfg</span>`:""}
				</div>
			</summary>
			<div class="wf-proposal-gates">
				<div class="wf-gate-card" style="padding:10px 12px;display:flex;flex-direction:column;gap:8px;">
					${e.repo?s`
						<div class="flex items-baseline gap-2">
							<span class="text-[11px] text-muted-foreground" style="min-width:110px;">Git repo</span>
							<span class="text-[12px] font-mono">${e.repo==="."?s`<span class="text-muted-foreground">. (project root)</span>`:e.repo}</span>
						</div>
					`:""}
					${e.relative_path?s`
						<div class="flex items-baseline gap-2">
							<span class="text-[11px] text-muted-foreground" style="min-width:110px;">Component path</span>
							<span class="text-[12px] font-mono">${e.relative_path}</span>
						</div>
					`:""}
					${t.length>0?s`
						<div>
							<div class="text-[11px] text-muted-foreground mb-1.5">Commands</div>
							<div class="flex flex-col gap-1.5">
								${t.map(([r,i])=>s`
									<div class="flex items-baseline gap-2" id=${`comp-cmd-${e.name}-${r}`}>
										<span class="text-[11px] px-1.5 py-0.5 rounded bg-primary/10 text-primary font-medium font-mono" style="min-width:60px;text-align:center;flex-shrink:0;">${r}</span>
										<code class="text-[12px] font-mono break-all">${i}</code>
									</div>
								`)}
							</div>
						</div>
					`:""}
					${e.worktree_setup_command?s`
						<div>
							<div class="text-[11px] text-muted-foreground mb-1.5">Worktree setup</div>
							<pre class="text-[11px] m-0 p-2 rounded bg-secondary/40 overflow-x-auto"><code>${e.worktree_setup_command}</code></pre>
						</div>
					`:""}
					<div data-testid="component-config-${e.name}">
						<div class="text-[11px] text-muted-foreground mb-1.5">Config</div>
						${n.length===0?s`<div class="text-[11px] text-muted-foreground italic" data-testid="component-config-empty-${e.name}">No config entries</div>`:s`
								<div class="flex flex-col gap-1.5">
									${n.map(([r,i])=>s`
										<div class="flex items-baseline gap-2" data-testid="component-config-row-${e.name}-${r}">
											<code class="text-[11px] px-1.5 py-0.5 rounded bg-primary/10 text-primary font-medium font-mono" style="flex-shrink:0;">${r}</code>
											<span class="text-[12px] font-mono break-all">${i}</span>
										</div>
									`)}
								</div>
							`}
					</div>
				</div>
			</div>
		</details>
	`}function h(e,t){const n=Object.keys(e);if(n.length===0)return s`<div class="text-sm text-muted-foreground italic">No workflows proposed.</div>`;const a=new Set(t.map(o=>o.name));return s`
		<div class="wf-list">
			${n.map(o=>f(o,e[o],a))}
		</div>
	`}function f(e,t,n){const a=t.gates??[],o=a.reduce((d,l)=>d+(l.verify?.length??0),0);return s`
		<details data-testid="workflow-card-${e}" class="wf-proposal-workflow">
			<summary class="wf-row" style="list-style:none;">
				<div class="wf-row-info">
					<span class="wf-row-name">${t.name??e}</span>
					${t.description?s`<span class="wf-row-desc">${t.description}</span>`:""}
				</div>
				<div class="wf-row-badges">
					<span class="wf-badge">${a.length} gate${a.length===1?"":"s"}</span>
					<span class="wf-badge">${o} step${o===1?"":"s"}</span>
				</div>
			</summary>
			<div class="wf-proposal-gates">${u(a,n)}</div>
		</details>
	`}function m(e){const t=new Map;for(const d of e)t.set(d.id,d);const n=new Set,a=[];let o=e.length+1;for(;t.size>0&&o-- >0;){const d=[];for(const l of t.values())(l.depends_on??[]).every(i=>n.has(i)||!t.has(i)&&!e.some(p=>p.id===i)||n.has(i))&&d.push(l);d.length===0&&d.push(...t.values());for(const l of d)t.delete(l.id),n.add(l.id);a.push(d)}return a}function u(e,t){const n=m(e);let a=0;return s`
		<div class="flex flex-col gap-2">
			${n.map((o,d)=>s`
				<div class="flex flex-col gap-2" data-row-index=${d}>
					${o.map(l=>x(l,t,a++))}
				</div>
			`)}
		</div>
	`}function x(e,t,n){const a=e.depends_on??[],o=e.verify??[],d=new Map;for(const r of o){const i=typeof r.phase=="number"?r.phase:0;d.has(i)||d.set(i,[]),d.get(i).push(r)}const l=Array.from(d.keys()).sort((r,i)=>r-i);return s`
		<details
			data-testid="gate-node-${e.id}"
			data-gate-id=${e.id}
			class="wf-gate-card"
		>
			<summary class="wf-gate-header" style="list-style:none;cursor:pointer;">
				<span class="wf-gate-idx">${n+1}</span>
				<span class="wf-gate-chevron">▸</span>
				<span class="wf-gate-name">${e.name??e.id}</span>
				${e.content?s`<span class="wf-gate-pill">content</span>`:""}
				${a.length>0?s`<span class="wf-gate-pill">← ${a.join(", ")}</span>`:""}
				${o.length>0?s`<span class="wf-gate-pill">${o.length} step${o.length===1?"":"s"}</span>`:""}
			</summary>
			<div class="wf-gate-body">
				<div class="wf-gate-body-inner">
					<div class="text-[11px] font-mono text-muted-foreground">${e.id}</div>
					${e.description?s`<div class="text-[12px] text-muted-foreground">${e.description}</div>`:""}
					${o.length>0?s`
						<div class="flex flex-col gap-2">
							${l.map(r=>s`
								<div class="wf-phase-group">
									<div class="wf-phase-header"><span>Phase ${r}</span></div>
									<div class="wf-phase-body">
										${(d.get(r)??[]).map(i=>v(i,t))}
									</div>
								</div>
							`)}
						</div>
					`:""}
				</div>
			</div>
		</details>
	`}function v(e,t){const n=e.type??"command",a=e.expect==="failure";return s`
		<details class="wf-vstep-card">
			<summary class="wf-vstep-collapsed-header" style="list-style:none;">
				<span class="wf-vstep-chevron">▸</span>
				<span class="wf-vstep-name-label">${e.name||"(unnamed)"}</span>
				<span class="wf-vstep-sep">·</span>
				<span class="wf-vstep-type-label">${n}</span>
				${e.optional?s`<span class="wf-gate-pill">optional</span>`:""}
				${a?s`<span class="wf-gate-pill" style="background:rgb(239 68 68 / 0.15);color:rgb(185 28 28);">must fail</span>`:""}
				<span class="wf-vstep-spacer"></span>
			</summary>
			<div class="wf-vstep-body"><div class="wf-vstep-fields">
				${g(e,n,t)}
			</div></div>
		</details>
	`}function g(e,t,n){if(t==="command"){if(e.component&&e.command){const a=n.has(e.component);return s`
				<div class="text-[11px] text-muted-foreground">Component command</div>
				<div class="text-[12px] font-mono">
					<span class=${a?"text-foreground":"text-amber-600"}>${e.component}</span>
					<span class="text-muted-foreground"> → </span>
					<span class="text-foreground">${e.command}</span>
				</div>
				${a?"":s`<div class="text-[11px] text-amber-600">unknown component</div>`}
			`}return e.run?s`
				<div class="text-[11px] text-muted-foreground">Inline command</div>
				<pre class="text-[11px] p-2 rounded bg-secondary/40 overflow-x-auto m-0"><code>${e.run}</code></pre>
			`:s`<div class="text-[11px] text-muted-foreground italic">No command configured.</div>`}if(t==="llm-review")return s`
			${e.role?s`<div class="text-[11px]"><span class="text-muted-foreground">Role:</span> <span class="font-mono">${e.role}</span></div>`:""}
			${e.prompt?s`<div>
				<div class="text-[11px] text-muted-foreground mb-1">Prompt</div>
				<pre class="text-[11px] p-2 rounded bg-secondary/40 overflow-x-auto whitespace-pre-wrap m-0">${e.prompt}</pre>
			</div>`:s`<div class="text-[11px] text-muted-foreground italic">(default review prompt)</div>`}
		`;if(t==="agent-qa"){const a=e.optionalLabel||e.label;return s`
			${e.role?s`<div class="text-[11px]"><span class="text-muted-foreground">Role:</span> <span class="font-mono">${e.role}</span></div>`:""}
			${a?s`<div class="text-[11px]"><span class="text-muted-foreground">Toggle:</span> ${a}</div>`:""}
			${e.description?s`<div class="text-[11px] text-muted-foreground">${e.description}</div>`:""}
		`}return s``}export{b as componentsView,y as viewTabs,h as workflowsView};
