import { dt as spread_props, g as bind_props, h as attributes, k as escape_html, m as attr_style, p as attr_class, pt as stringify, tt as props_id, w as derived, y as clsx$1 } from "./events-Bhh2w-5S.js";
import { a as resolve, r as goto } from "./client-bZcBshMs.js";
import { $ as createBitsAttrs, K as attachRef, Q as cn, V as Spinner, X as boxWith, a as Card_content, c as Card_title, dt as mergeProps, et as createId, i as Card, n as Button, o as Card_description, s as Card_header } from "./error-DYeUQ7mQ.js";
//#region .svelte-kit/adapter-bun/chunks/project-loader.js
var progressAttrs = createBitsAttrs({
	component: "progress",
	parts: ["root"]
});
var ProgressRootState = class ProgressRootState {
	static create(opts) {
		return new ProgressRootState(opts);
	}
	opts;
	attachment;
	constructor(opts) {
		this.opts = opts;
		this.attachment = attachRef(this.opts.ref);
	}
	#props = derived(() => ({
		role: "progressbar",
		value: this.opts.value.current,
		"aria-valuemin": this.opts.min.current,
		"aria-valuemax": this.opts.max.current,
		"aria-valuenow": this.opts.value.current === null ? void 0 : this.opts.value.current,
		"data-value": this.opts.value.current === null ? void 0 : this.opts.value.current,
		"data-state": getProgressDataState(this.opts.value.current, this.opts.max.current),
		"data-max": this.opts.max.current,
		"data-min": this.opts.min.current,
		"data-indeterminate": this.opts.value.current === null ? "" : void 0,
		[progressAttrs.root]: "",
		...this.attachment
	}));
	get props() {
		return this.#props();
	}
	set props($$value) {
		return this.#props($$value);
	}
};
function getProgressDataState(value, max) {
	if (value === null) return "indeterminate";
	return value === max ? "loaded" : "loading";
}
function Progress$1($$renderer, $$props) {
	$$renderer.component(($$renderer) => {
		const uid = props_id($$renderer);
		let { child, children, value = 0, max = 100, min = 0, id = createId(uid), ref = null, $$slots, $$events, ...restProps } = $$props;
		const rootState = ProgressRootState.create({
			value: boxWith(() => value),
			max: boxWith(() => max),
			min: boxWith(() => min),
			id: boxWith(() => id),
			ref: boxWith(() => ref, (v) => ref = v)
		});
		const mergedProps = derived(() => mergeProps(restProps, rootState.props));
		if (child) {
			$$renderer.push("<!--[0-->");
			child($$renderer, { props: mergedProps() });
			$$renderer.push(`<!---->`);
		} else {
			$$renderer.push("<!--[-1-->");
			$$renderer.push(`<div${attributes({ ...mergedProps() })}>`);
			children?.($$renderer);
			$$renderer.push(`<!----></div>`);
		}
		$$renderer.push(`<!--]-->`);
		bind_props($$props, { ref });
	});
}
function Project_spinner($$renderer, $$props) {
	$$renderer.component(($$renderer) => {
		Card($$renderer, {
			class: "flex flex-col items-center p-6 animate-spin scale-150",
			children: ($$renderer) => {
				Card_header($$renderer, {
					class: "flex flex-col items-center text-center",
					children: ($$renderer) => {
						Spinner($$renderer, {});
						$$renderer.push(`<!----> `);
						Card_title($$renderer, {
							children: ($$renderer) => {
								$$renderer.push(`<!---->Project loading...`);
							},
							$$slots: { default: true }
						});
						$$renderer.push(`<!----> `);
						Card_description($$renderer, {
							children: ($$renderer) => {
								$$renderer.push(`<!---->Retrieving save`);
							},
							$$slots: { default: true }
						});
						$$renderer.push(`<!---->`);
					},
					$$slots: { default: true }
				});
				$$renderer.push(`<!----> `);
				Card_content($$renderer, {
					class: "mt-4",
					children: ($$renderer) => {
						Button($$renderer, {
							variant: "outline",
							size: "sm",
							onclick: () => {
								goto(resolve("/"));
							},
							children: ($$renderer) => {
								$$renderer.push(`<!---->Cancel`);
							},
							$$slots: { default: true }
						});
					},
					$$slots: { default: true }
				});
				$$renderer.push(`<!---->`);
			},
			$$slots: { default: true }
		});
	});
}
function Full_page_project_spinner($$renderer) {
	$$renderer.push(`<div class="w-screen h-screen flex items-center justify-center">`);
	Project_spinner($$renderer, {});
	$$renderer.push(`<!----></div>`);
}
function Progress($$renderer, $$props) {
	$$renderer.component(($$renderer) => {
		let { ref = null, class: className, max = 100, value, $$slots, $$events, ...restProps } = $$props;
		let $$settled = true;
		let $$inner_renderer;
		function $$render_inner($$renderer) {
			if (Progress$1) {
				$$renderer.push("<!--[-->");
				Progress$1($$renderer, spread_props([
					{
						"data-slot": "progress",
						class: cn("bg-muted h-1 rounded-full relative flex w-full items-center overflow-x-hidden", className),
						value,
						max
					},
					restProps,
					{
						get ref() {
							return ref;
						},
						set ref($$value) {
							ref = $$value;
							$$settled = false;
						},
						children: ($$renderer) => {
							$$renderer.push(`<div data-slot="progress-indicator" class="bg-primary size-full flex-1 transition-all"${attr_style(`transform: translateX(-${stringify(100 - 100 * (value ?? 0) / (max ?? 1))}%)`)}></div>`);
						},
						$$slots: { default: true }
					}
				]));
				$$renderer.push("<!--]-->");
			} else {
				$$renderer.push("<!--[!-->");
				$$renderer.push("<!--]-->");
			}
		}
		do {
			$$settled = true;
			$$inner_renderer = $$renderer.copy();
			$$render_inner($$inner_renderer);
		} while (!$$settled);
		$$renderer.subsume($$inner_renderer);
		bind_props($$props, { ref });
	});
}
function Progress_bar($$renderer, $$props) {
	$$renderer.component(($$renderer) => {
		let { title, promises, show = void 0, callback } = $$props;
		let total = 0;
		let completed = 0;
		$$renderer.push(`<div aria-hidden="true"${attr_class(clsx$1(show ? "fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4" : "hidden"))}><div class="bg-black outline outline-neutral-900 rounded-xl p-6 w-full max-w-sm shadow-2xl flex flex-col"><span id="project-title" class="text-2xl font-bold mb-8 text-center">${escape_html(title)}</span> `);
		Progress($$renderer, { value: completed / total * 100 });
		$$renderer.push(`<!----></div></div>`);
		bind_props($$props, { show });
	});
}
//#endregion
export { Progress_bar as n, Full_page_project_spinner as t };

//# sourceMappingURL=project-loader-DaQVgPID.js.map