import { x as head, c as escape_html, e as ensure_array_like, b as attr_class, g as derived } from './dev-BNpEUZI3.js';
import 'node:module';
import { B as Badge, C as Card } from './Tabs-DzG6Bn9a.js';
import { a as Select, I as Input, B as Button } from './ui-DR8zOSpC.js';

//#region src/routes/setup/+page.svelte
function _page($$renderer, $$props) {
	$$renderer.component(($$renderer) => {
		/** Persisted per-section snapshot. */
		/** Was this section completed at least once? */
		/** Final summary line returned by the wizard / credentials API. */
		/** Epoch ms of the last successful completion. */
		const SECTIONS = [{
			id: "llm",
			title: "LLM provider + API key",
			blurb: "Connect at least one LLM provider so CLEO can dispatch agents. The key is written to the unified credential pool — never to config."
		}, {
			id: "project-conventions",
			title: "Project conventions",
			blurb: "Pick the strictness preset that will gate this project. Affects lint, type-check, and test gating defaults."
		}];
		let activeSection = "llm";
		let sectionState = {
			llm: {
				completed: false,
				summary: "",
				completedAt: null
			},
			"project-conventions": {
				completed: false,
				summary: "",
				completedAt: null
			}
		};
		let llmProvider = "anthropic";
		let llmLabel = "default";
		let llmApiKey = "";
		let llmSubmitting = false;
		const PROVIDER_OPTIONS = [
			{
				value: "anthropic",
				label: "Anthropic"
			},
			{
				value: "openai",
				label: "OpenAI"
			},
			{
				value: "gemini",
				label: "Gemini"
			},
			{
				value: "moonshot",
				label: "Moonshot"
			},
			{
				value: "openrouter",
				label: "OpenRouter"
			},
			{
				value: "bedrock",
				label: "AWS Bedrock"
			},
			{
				value: "deepseek",
				label: "DeepSeek"
			},
			{
				value: "xai",
				label: "xAI"
			},
			{
				value: "groq",
				label: "Groq"
			},
			{
				value: "kimi-code",
				label: "Kimi Code"
			},
			{
				value: "ollama",
				label: "Ollama"
			}
		];
		const completedCount = derived(() => SECTIONS.filter((s) => sectionState[s.id].completed).length);
		let $$settled = true;
		let $$inner_renderer;
		function $$render_inner($$renderer) {
			head("g40i6i", $$renderer, ($$renderer) => {
				$$renderer.title(($$renderer) => {
					$$renderer.push(`<title>Setup — CLEO Studio</title>`);
				});
			});
			$$renderer.push(`<section class="setup-page svelte-g40i6i"><header class="page-header svelte-g40i6i"><div><h1 class="svelte-g40i6i">Setup CLEO</h1> <p class="muted svelte-g40i6i">Walk through each section to wire CLEO for this project. Sections persist independently —
        leave and resume at any step.</p></div> `);
			Badge($$renderer, {
				tone: completedCount() === SECTIONS.length ? "success" : "info",
				children: ($$renderer) => {
					$$renderer.push(`<!---->${escape_html(completedCount())} / ${escape_html(SECTIONS.length)} complete`);
				}});
			$$renderer.push(`<!----></header> <ol class="step-rail svelte-g40i6i" aria-label="Setup sections"><!--[-->`);
			const each_array = ensure_array_like(SECTIONS);
			for (let idx = 0, $$length = each_array.length; idx < $$length; idx++) {
				let section = each_array[idx];
				const state = sectionState[section.id];
				$$renderer.push(`<li><button type="button"${attr_class("step-pill svelte-g40i6i", void 0, {
					"active": activeSection === section.id,
					"done": state.completed
				})}><span class="step-num svelte-g40i6i">${escape_html(idx + 1)}</span> <span class="step-title svelte-g40i6i">${escape_html(section.title)}</span> `);
				if (state.completed) {
					$$renderer.push("<!--[0-->");
					Badge($$renderer, {
						tone: "success",
						size: "sm",
						children: ($$renderer) => {
							$$renderer.push(`<!---->done`);
						}});
				} else $$renderer.push("<!--[-1-->");
				$$renderer.push(`<!--]--></button></li>`);
			}
			$$renderer.push(`<!--]--></ol> `);
			{
				$$renderer.push("<!--[0-->");
				{
					function header($$renderer) {
						$$renderer.push(`<h2 class="section-title svelte-g40i6i">1. ${escape_html(SECTIONS[0]?.title ?? "LLM provider + API key")}</h2>`);
					}
					Card($$renderer, {
						padding: "cozy",
						header,
						children: ($$renderer) => {
							$$renderer.push(`<p class="muted svelte-g40i6i">${escape_html(SECTIONS[0]?.blurb)}</p> `);
							$$renderer.push("<!--[-1-->");
							$$renderer.push(`<!--]--> <form class="setup-form svelte-g40i6i">`);
							Select($$renderer, {
								label: "Provider",
								name: "provider",
								options: PROVIDER_OPTIONS,
								get value() {
									return llmProvider;
								},
								set value($$value) {
									llmProvider = $$value;
									$$settled = false;
								}
							});
							$$renderer.push(`<!----> `);
							Input($$renderer, {
								label: "Credential label",
								name: "label",
								placeholder: "default",
								description: "A short name so you can identify this key in the pool (e.g. 'work-pri').",
								get value() {
									return llmLabel;
								},
								set value($$value) {
									llmLabel = $$value;
									$$settled = false;
								}
							});
							$$renderer.push(`<!----> `);
							Input($$renderer, {
								label: "API key",
								name: "apiKey",
								type: "password",
								placeholder: "paste your provider API key",
								required: true,
								description: "Submitted to POST /api/credentials. Stored at 0600 in ~/.cleo/llm-credentials.json; the API never echoes the value back.",
								get value() {
									return llmApiKey;
								},
								set value($$value) {
									llmApiKey = $$value;
									$$settled = false;
								}
							});
							$$renderer.push(`<!----> `);
							$$renderer.push("<!--[-1-->");
							$$renderer.push(`<!--]--> <div class="form-actions svelte-g40i6i">`);
							Button($$renderer, {
								type: "submit",
								loading: llmSubmitting,
								disabled: llmSubmitting,
								children: ($$renderer) => {
									$$renderer.push(`<!---->Save credential`);
								}});
							$$renderer.push(`<!----></div></form>`);
						}});
				}
			}
			$$renderer.push(`<!--]--> `);
			if (completedCount() === SECTIONS.length) {
				$$renderer.push("<!--[0-->");
				Card($$renderer, {
					padding: "cozy",
					children: ($$renderer) => {
						$$renderer.push(`<div class="completion-banner svelte-g40i6i" role="status">`);
						Badge($$renderer, {
							tone: "success",
							children: ($$renderer) => {
								$$renderer.push(`<!---->All set`);
							}});
						$$renderer.push(`<!----> <span>Both required sections are complete. You can now dispatch tasks — or jump to <a href="/keys">/keys</a> to add more credentials.</span></div>`);
					}});
			} else $$renderer.push("<!--[-1-->");
			$$renderer.push(`<!--]--></section>`);
		}
		do {
			$$settled = true;
			$$inner_renderer = $$renderer.copy();
			$$render_inner($$inner_renderer);
		} while (!$$settled);
		$$renderer.subsume($$inner_renderer);
	});
}

export { _page as default };
//# sourceMappingURL=_page.svelte-DUWbZjC7.js.map
