import { n as _sfc_main$2, t as _sfc_main$1 } from "./TextInput-DZTdLzEa.js";
import { A as _sfc_main$6, bt as _sfc_main$3, ut as _sfc_main$4, xt as AuthenticationCard_default, yt as _sfc_main$5 } from "../ssr.js";
import { Head, Link, useForm, usePage } from "@inertiajs/vue3";
import { Fragment, createBlock, createCommentVNode, createTextVNode, createVNode, onMounted, onUnmounted, openBlock, ref, toDisplayString, unref, useSSRContext, withCtx, withModifiers } from "vue";
import { ssrInterpolate, ssrRenderAttr, ssrRenderComponent } from "vue/server-renderer";
//#region resources/js/Pages/Auth/Login.vue
var _sfc_main = {
	__name: "Login",
	__ssrInlineRender: true,
	props: {
		demo: Boolean,
		status: String,
		canResetPassword: Boolean,
		captcha_src: String
	},
	setup(__props) {
		const page = usePage();
		const scriptEl = ref(null);
		const props = __props;
		const form = useForm({
			username: props.demo ? "super" : "",
			password: props.demo ? "password" : "",
			remember: false,
			captcha: ""
		});
		onMounted(() => {
			if (page.props.settings.captcha_provider == "recaptcha") {
				const recaptchaScript = document.createElement("script");
				recaptchaScript.setAttribute("src", "https://www.google.com/recaptcha/api.js?render=" + page.props.settings.captcha_site_key);
				scriptEl.value = document.head.appendChild(recaptchaScript);
			} else if (page.props.settings.captcha_provider == "turnstile") {
				const turnstileScript = document.createElement("script");
				turnstileScript.setAttribute("src", "https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit");
				turnstileScript.onload = () => {
					turnstile.render("#cf-widget", {
						sitekey: page.props.settings.captcha_site_key,
						theme: localStorage.getItem("theme") == "dark" ? "dark" : localStorage.getItem("theme") == "light" ? "light" : "auto",
						callback: function(token) {
							form.captcha = token;
						}
					});
				};
				scriptEl.value = document.head.appendChild(turnstileScript);
			}
		});
		onUnmounted(() => {
			if (scriptEl.value) {
				document.head.removeChild(scriptEl.value);
				document.getElementsByClassName("grecaptcha-badge").item(0)?.remove();
			}
		});
		const submit = () => {
			form.post(route("login"), { onFinish: () => form.reset("password") });
		};
		const handle = () => {
			grecaptcha.ready(function() {
				grecaptcha.execute(page.props.settings.captcha_site_key, { action: "submit" }).then(function(token) {
					form.captcha = token;
					submit();
				});
			});
		};
		return (_ctx, _push, _parent, _attrs) => {
			_push(`<!--[-->`);
			_push(ssrRenderComponent(unref(Head), { title: _ctx.$t("Log in") }, null, _parent));
			_push(ssrRenderComponent(AuthenticationCard_default, null, {
				logo: withCtx((_, _push, _parent, _scopeId) => {
					if (_push) _push(ssrRenderComponent(_sfc_main$3, null, null, _parent, _scopeId));
					else return [createVNode(_sfc_main$3)];
				}),
				default: withCtx((_, _push, _parent, _scopeId) => {
					if (_push) {
						if (__props.status) _push(`<div class="mb-4 text-sm font-medium text-green-600 dark:text-green-400"${_scopeId}>${ssrInterpolate(__props.status)}</div>`);
						else _push(`<!---->`);
						_push(`<form${_scopeId}><div${_scopeId}>`);
						_push(ssrRenderComponent(_sfc_main$4, {
							for: "username",
							value: _ctx.$t("Username")
						}, null, _parent, _scopeId));
						_push(ssrRenderComponent(_sfc_main$1, {
							id: "username",
							modelValue: unref(form).username,
							"onUpdate:modelValue": ($event) => unref(form).username = $event,
							type: "text",
							class: "mt-1 block w-full",
							required: "",
							autofocus: "",
							autocomplete: "username"
						}, null, _parent, _scopeId));
						_push(ssrRenderComponent(_sfc_main$2, {
							class: "mt-2",
							message: unref(form).errors.username
						}, null, _parent, _scopeId));
						_push(`</div><div class="mt-4"${_scopeId}>`);
						_push(ssrRenderComponent(_sfc_main$4, {
							for: "password",
							value: _ctx.$t("Password")
						}, null, _parent, _scopeId));
						_push(ssrRenderComponent(_sfc_main$1, {
							required: "",
							id: "password",
							type: "password",
							modelValue: unref(form).password,
							"onUpdate:modelValue": ($event) => unref(form).password = $event,
							class: "mt-1 block w-full",
							autocomplete: "current-password"
						}, null, _parent, _scopeId));
						_push(ssrRenderComponent(_sfc_main$2, {
							class: "mt-2",
							message: unref(form).errors.password
						}, null, _parent, _scopeId));
						_push(`</div>`);
						if (_ctx.$page.props.settings.captcha_provider) {
							_push(`<!--[-->`);
							if (_ctx.$page.props.settings.captcha_provider == "recaptcha") _push(ssrRenderComponent(_sfc_main$2, {
								class: "mt-2",
								message: unref(form).errors.captcha
							}, null, _parent, _scopeId));
							else _push(`<!---->`);
							if (_ctx.$page.props.settings.captcha_provider == "turnstile") _push(`<div id="cf-widget" class="mt-4" wire:ignore${_scopeId}></div>`);
							else _push(`<!---->`);
							if (_ctx.$page.props.settings.captcha_provider == "local") {
								_push(`<div class="mt-4"${_scopeId}>`);
								_push(ssrRenderComponent(_sfc_main$4, {
									for: "captcha",
									value: _ctx.$t("Captcha")
								}, null, _parent, _scopeId));
								_push(`<div class="flex items-end justify-start gap-4"${_scopeId}>`);
								_push(ssrRenderComponent(_sfc_main$1, {
									id: "captcha",
									modelValue: unref(form).captcha,
									"onUpdate:modelValue": ($event) => unref(form).captcha = $event,
									type: "text",
									class: "mt-1 block w-full",
									required: "",
									autocomplete: "captcha"
								}, null, _parent, _scopeId));
								_push(`<img${ssrRenderAttr("src", __props.captcha_src)} alt="" class="mb-px h-10 rounded-md p-px shadow-xs"${_scopeId}></div>`);
								_push(ssrRenderComponent(_sfc_main$2, {
									class: "mt-2",
									message: unref(form).errors.captcha
								}, null, _parent, _scopeId));
								_push(`</div>`);
							} else _push(`<!---->`);
							_push(`<!--]-->`);
						} else _push(`<!---->`);
						_push(`<div class="mt-4 block"${_scopeId}><label class="inline-flex items-center"${_scopeId}>`);
						_push(ssrRenderComponent(_sfc_main$5, {
							checked: unref(form).remember,
							"onUpdate:checked": ($event) => unref(form).remember = $event,
							name: "remember"
						}, null, _parent, _scopeId));
						_push(`<span class="ms-2 text-sm text-gray-600 dark:text-gray-400"${_scopeId}>${ssrInterpolate(_ctx.$t("Remember me"))}</span></label></div><div class="mt-4 flex items-center justify-end"${_scopeId}>`);
						if (__props.canResetPassword) _push(ssrRenderComponent(unref(Link), {
							href: _ctx.route("password.request"),
							class: "rounded-md text-sm text-gray-600 underline decoration-dotted underline-offset-8 hover:text-gray-900 hover:decoration-solid dark:text-gray-400 dark:hover:text-gray-100"
						}, {
							default: withCtx((_, _push, _parent, _scopeId) => {
								if (_push) _push(`${ssrInterpolate(_ctx.$t("Forgot your password?"))}`);
								else return [createTextVNode(toDisplayString(_ctx.$t("Forgot your password?")), 1)];
							}),
							_: 1
						}, _parent, _scopeId));
						else _push(`<!---->`);
						if (unref(page).props.settings.captcha_provider == "recaptcha") _push(ssrRenderComponent(_sfc_main$6, {
							class: ["ms-4", { "opacity-25": unref(form).processing }],
							type: "button",
							onClick: handle,
							loading: unref(form).processing
						}, {
							default: withCtx((_, _push, _parent, _scopeId) => {
								if (_push) _push(`${ssrInterpolate(_ctx.$t("Log in"))}`);
								else return [createTextVNode(toDisplayString(_ctx.$t("Log in")), 1)];
							}),
							_: 1
						}, _parent, _scopeId));
						else _push(ssrRenderComponent(_sfc_main$6, {
							class: ["ms-4", { "opacity-25": unref(form).processing }],
							loading: unref(form).processing
						}, {
							default: withCtx((_, _push, _parent, _scopeId) => {
								if (_push) _push(`${ssrInterpolate(_ctx.$t("Log in"))}`);
								else return [createTextVNode(toDisplayString(_ctx.$t("Log in")), 1)];
							}),
							_: 1
						}, _parent, _scopeId));
						_push(`</div></form>`);
					} else return [__props.status ? (openBlock(), createBlock("div", {
						key: 0,
						class: "mb-4 text-sm font-medium text-green-600 dark:text-green-400"
					}, toDisplayString(__props.status), 1)) : createCommentVNode("", true), createVNode("form", { onSubmit: withModifiers(submit, ["prevent"]) }, [
						createVNode("div", null, [
							createVNode(_sfc_main$4, {
								for: "username",
								value: _ctx.$t("Username")
							}, null, 8, ["value"]),
							createVNode(_sfc_main$1, {
								id: "username",
								modelValue: unref(form).username,
								"onUpdate:modelValue": ($event) => unref(form).username = $event,
								type: "text",
								class: "mt-1 block w-full",
								required: "",
								autofocus: "",
								autocomplete: "username"
							}, null, 8, ["modelValue", "onUpdate:modelValue"]),
							createVNode(_sfc_main$2, {
								class: "mt-2",
								message: unref(form).errors.username
							}, null, 8, ["message"])
						]),
						createVNode("div", { class: "mt-4" }, [
							createVNode(_sfc_main$4, {
								for: "password",
								value: _ctx.$t("Password")
							}, null, 8, ["value"]),
							createVNode(_sfc_main$1, {
								required: "",
								id: "password",
								type: "password",
								modelValue: unref(form).password,
								"onUpdate:modelValue": ($event) => unref(form).password = $event,
								class: "mt-1 block w-full",
								autocomplete: "current-password"
							}, null, 8, ["modelValue", "onUpdate:modelValue"]),
							createVNode(_sfc_main$2, {
								class: "mt-2",
								message: unref(form).errors.password
							}, null, 8, ["message"])
						]),
						_ctx.$page.props.settings.captcha_provider ? (openBlock(), createBlock(Fragment, { key: 0 }, [
							_ctx.$page.props.settings.captcha_provider == "recaptcha" ? (openBlock(), createBlock(_sfc_main$2, {
								key: 0,
								class: "mt-2",
								message: unref(form).errors.captcha
							}, null, 8, ["message"])) : createCommentVNode("", true),
							_ctx.$page.props.settings.captcha_provider == "turnstile" ? (openBlock(), createBlock("div", {
								key: 1,
								id: "cf-widget",
								class: "mt-4",
								"wire:ignore": ""
							})) : createCommentVNode("", true),
							_ctx.$page.props.settings.captcha_provider == "local" ? (openBlock(), createBlock("div", {
								key: 2,
								class: "mt-4"
							}, [
								createVNode(_sfc_main$4, {
									for: "captcha",
									value: _ctx.$t("Captcha")
								}, null, 8, ["value"]),
								createVNode("div", { class: "flex items-end justify-start gap-4" }, [createVNode(_sfc_main$1, {
									id: "captcha",
									modelValue: unref(form).captcha,
									"onUpdate:modelValue": ($event) => unref(form).captcha = $event,
									type: "text",
									class: "mt-1 block w-full",
									required: "",
									autocomplete: "captcha"
								}, null, 8, ["modelValue", "onUpdate:modelValue"]), createVNode("img", {
									src: __props.captcha_src,
									alt: "",
									class: "mb-px h-10 rounded-md p-px shadow-xs"
								}, null, 8, ["src"])]),
								createVNode(_sfc_main$2, {
									class: "mt-2",
									message: unref(form).errors.captcha
								}, null, 8, ["message"])
							])) : createCommentVNode("", true)
						], 64)) : createCommentVNode("", true),
						createVNode("div", { class: "mt-4 block" }, [createVNode("label", { class: "inline-flex items-center" }, [createVNode(_sfc_main$5, {
							checked: unref(form).remember,
							"onUpdate:checked": ($event) => unref(form).remember = $event,
							name: "remember"
						}, null, 8, ["checked", "onUpdate:checked"]), createVNode("span", { class: "ms-2 text-sm text-gray-600 dark:text-gray-400" }, toDisplayString(_ctx.$t("Remember me")), 1)])]),
						createVNode("div", { class: "mt-4 flex items-center justify-end" }, [__props.canResetPassword ? (openBlock(), createBlock(unref(Link), {
							key: 0,
							href: _ctx.route("password.request"),
							class: "rounded-md text-sm text-gray-600 underline decoration-dotted underline-offset-8 hover:text-gray-900 hover:decoration-solid dark:text-gray-400 dark:hover:text-gray-100"
						}, {
							default: withCtx(() => [createTextVNode(toDisplayString(_ctx.$t("Forgot your password?")), 1)]),
							_: 1
						}, 8, ["href"])) : createCommentVNode("", true), unref(page).props.settings.captcha_provider == "recaptcha" ? (openBlock(), createBlock(_sfc_main$6, {
							key: 1,
							class: ["ms-4", { "opacity-25": unref(form).processing }],
							type: "button",
							onClick: handle,
							loading: unref(form).processing
						}, {
							default: withCtx(() => [createTextVNode(toDisplayString(_ctx.$t("Log in")), 1)]),
							_: 1
						}, 8, ["class", "loading"])) : (openBlock(), createBlock(_sfc_main$6, {
							key: 2,
							class: ["ms-4", { "opacity-25": unref(form).processing }],
							loading: unref(form).processing
						}, {
							default: withCtx(() => [createTextVNode(toDisplayString(_ctx.$t("Log in")), 1)]),
							_: 1
						}, 8, ["class", "loading"]))])
					], 32)];
				}),
				_: 1
			}, _parent));
			_push(`<!--]-->`);
		};
	}
};
var _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
	const ssrContext = useSSRContext();
	(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("resources/js/Pages/Auth/Login.vue");
	return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
//#endregion
export { _sfc_main as default };
