import { a as usePage, i as useForm, n as head_default, o as vue_exports, s as router } from "../ssr.js";
import { n as server_renderer_exports, t } from "./i18n-CXLOYfyq.js";
import { t as AdminLayout_default } from "./AdminLayout-DJaJT5Cr.js";
//#region resources/js/Pages/Admin/Invites.vue?vue&type=script&setup=true&lang.ts
var field = "mt-1 w-full rounded-lg border-line bg-appbg text-ink placeholder:text-ink-muted focus:border-primary focus:ring-primary text-sm";
var Invites_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ (0, vue_exports.defineComponent)({
	__name: "Invites",
	__ssrInlineRender: true,
	props: {
		inviteOnly: { type: Boolean },
		membersEnabled: { type: Boolean },
		registerBase: {},
		invites: {}
	},
	setup(__props) {
		const props = __props;
		const page = usePage();
		const status = (0, vue_exports.computed)(() => page.props.flash?.status);
		const only = (0, vue_exports.ref)(props.inviteOnly);
		function toggleOnly() {
			router.post("/admin/invites/only", { invite_only: only.value }, { preserveScroll: true });
		}
		const members = (0, vue_exports.ref)(props.membersEnabled);
		function toggleMembers() {
			router.post("/admin/invites/members", { members_enabled: members.value }, { preserveScroll: true });
		}
		const form = useForm({
			note: "",
			email: "",
			max_uses: 1,
			expires_days: null
		});
		function create() {
			form.post("/admin/invites", {
				preserveScroll: true,
				onSuccess: () => form.reset()
			});
		}
		function revoke(id) {
			if (confirm(t("Revoke this invite? Its link will stop working."))) router.delete(`/admin/invites/${id}`, { preserveScroll: true });
		}
		const copied = (0, vue_exports.ref)(null);
		function copyLink(inv) {
			navigator.clipboard?.writeText(props.registerBase + inv.code);
			copied.value = inv.id;
			setTimeout(() => copied.value = null, 1500);
		}
		return (_ctx, _push, _parent, _attrs) => {
			_push(`<!--[-->`);
			_push((0, server_renderer_exports.ssrRenderComponent)((0, vue_exports.unref)(head_default), { title: (0, vue_exports.unref)(t)("Admin · Invites") }, null, _parent));
			_push((0, server_renderer_exports.ssrRenderComponent)(AdminLayout_default, null, {
				title: (0, vue_exports.withCtx)((_, _push, _parent, _scopeId) => {
					if (_push) _push(`${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Invites"))}`);
					else return [(0, vue_exports.createTextVNode)((0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Invites")), 1)];
				}),
				subtitle: (0, vue_exports.withCtx)((_, _push, _parent, _scopeId) => {
					if (_push) _push(`${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Invite codes & invite-only registration"))}`);
					else return [(0, vue_exports.createTextVNode)((0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Invite codes & invite-only registration")), 1)];
				}),
				default: (0, vue_exports.withCtx)((_, _push, _parent, _scopeId) => {
					if (_push) {
						if (status.value) _push(`<div class="mb-5 rounded-xl border border-emerald-500/30 bg-emerald-500/10 px-4 py-3 text-sm text-emerald-300"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)(status.value)}</div>`);
						else _push(`<!---->`);
						_push(`<div class="grid gap-6 lg:grid-cols-[1fr_1.4fr]"${_scopeId}><div class="space-y-6"${_scopeId}><section class="rounded-2xl border border-line bg-surface p-5"${_scopeId}><h3 class="mb-1 text-sm font-bold text-ink"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Registration mode"))}</h3><p class="mb-3 text-xs text-ink-muted"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("When invite-only is on, new members must enter a valid invite code to sign up."))}</p><label class="flex items-center gap-2 text-sm text-ink-2"${_scopeId}><input${(0, server_renderer_exports.ssrIncludeBooleanAttr)(Array.isArray(only.value) ? (0, server_renderer_exports.ssrLooseContain)(only.value, null) : only.value) ? " checked" : ""} type="checkbox" class="rounded border-line text-primary focus:ring-primary"${_scopeId}> ${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Invite-only registration"))}</label><label class="mt-3 flex items-center gap-2 text-sm text-ink-2"${_scopeId}><input${(0, server_renderer_exports.ssrIncludeBooleanAttr)(Array.isArray(members.value) ? (0, server_renderer_exports.ssrLooseContain)(members.value, null) : members.value) ? " checked" : ""} type="checkbox" class="rounded border-line text-primary focus:ring-primary"${_scopeId}> ${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Let members invite their friends"))}</label><p class="mt-1 text-xs text-ink-muted"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Adds an “Invite friends” page with a personal referral link and email invites."))}</p></section><section class="rounded-2xl border border-line bg-surface p-5"${_scopeId}><h3 class="mb-3 text-sm font-bold text-ink"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Create an invite"))}</h3><label class="block text-xs font-semibold text-ink-2"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Note"))} <span class="font-normal text-ink-muted"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("(optional)"))}</span></label><input${(0, server_renderer_exports.ssrRenderAttr)("value", (0, vue_exports.unref)(form).note)} class="${(0, server_renderer_exports.ssrRenderClass)(field)}"${(0, server_renderer_exports.ssrRenderAttr)("placeholder", (0, vue_exports.unref)(t)("e.g. Beta testers"))}${_scopeId}><label class="mt-3 block text-xs font-semibold text-ink-2"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Reserve for email"))} <span class="font-normal text-ink-muted"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("(optional)"))}</span></label><input${(0, server_renderer_exports.ssrRenderAttr)("value", (0, vue_exports.unref)(form).email)} type="email" class="${(0, server_renderer_exports.ssrRenderClass)(field)}" placeholder="friend@example.com"${_scopeId}><div class="mt-3 grid grid-cols-2 gap-3"${_scopeId}><div${_scopeId}><label class="block text-xs font-semibold text-ink-2"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Max uses"))}</label><input${(0, server_renderer_exports.ssrRenderAttr)("value", (0, vue_exports.unref)(form).max_uses)} type="number" min="1" class="${(0, server_renderer_exports.ssrRenderClass)(field)}"${_scopeId}></div><div${_scopeId}><label class="block text-xs font-semibold text-ink-2"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Expires in (days)"))}</label><input${(0, server_renderer_exports.ssrRenderAttr)("value", (0, vue_exports.unref)(form).expires_days)} type="number" min="1" class="${(0, server_renderer_exports.ssrRenderClass)(field)}"${(0, server_renderer_exports.ssrRenderAttr)("placeholder", (0, vue_exports.unref)(t)("never"))}${_scopeId}></div></div><button class="mt-4 rounded-lg bg-primary px-4 py-2 text-sm font-semibold text-white hover:bg-primary-600"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Create invite"))}</button></section></div><section class="rounded-2xl border border-line bg-surface p-5"${_scopeId}><h3 class="mb-3 text-sm font-bold text-ink"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Invites"))}</h3>`);
						if (!__props.invites.length) _push(`<div class="text-sm text-ink-muted"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("No invites yet."))}</div>`);
						else {
							_push(`<ul class="divide-y divide-line"${_scopeId}><!--[-->`);
							(0, server_renderer_exports.ssrRenderList)(__props.invites, (inv) => {
								_push(`<li class="flex items-center gap-3 py-3"${_scopeId}><div class="min-w-0 flex-1"${_scopeId}><div class="flex items-center gap-2"${_scopeId}><code class="rounded bg-appbg px-2 py-0.5 text-sm font-bold text-ink select-all"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)(inv.code)}</code>`);
								if (!inv.usable) _push(`<span class="rounded-full bg-red-500/15 px-2 py-0.5 text-[10px] font-bold uppercase text-red-300"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("used up"))}</span>`);
								else _push(`<!---->`);
								_push(`</div><div class="mt-0.5 truncate text-xs text-ink-muted"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("{used}/{max} used", {
									used: inv.uses,
									max: inv.maxUses
								}))}`);
								if (inv.note) _push(`<span${_scopeId}> · ${(0, server_renderer_exports.ssrInterpolate)(inv.note)}</span>`);
								else _push(`<!---->`);
								if (inv.email) _push(`<span${_scopeId}> · ${(0, server_renderer_exports.ssrInterpolate)(inv.email)}</span>`);
								else _push(`<!---->`);
								if (inv.expiresAt) _push(`<span${_scopeId}> · ${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("expires {when}", { when: inv.expiresAt }))}</span>`);
								else _push(`<!---->`);
								_push(`</div></div><button class="rounded-lg bg-surface-2 px-2.5 py-1.5 text-xs font-semibold text-ink hover:bg-appbg"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)(copied.value === inv.id ? (0, vue_exports.unref)(t)("Copied!") : (0, vue_exports.unref)(t)("Copy link"))}</button><button class="rounded-lg px-2.5 py-1.5 text-xs font-semibold text-red-400 hover:bg-red-500/10"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Revoke"))}</button></li>`);
							});
							_push(`<!--]--></ul>`);
						}
						_push(`</section></div>`);
					} else return [status.value ? ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("div", {
						key: 0,
						class: "mb-5 rounded-xl border border-emerald-500/30 bg-emerald-500/10 px-4 py-3 text-sm text-emerald-300"
					}, (0, vue_exports.toDisplayString)(status.value), 1)) : (0, vue_exports.createCommentVNode)("", true), (0, vue_exports.createVNode)("div", { class: "grid gap-6 lg:grid-cols-[1fr_1.4fr]" }, [(0, vue_exports.createVNode)("div", { class: "space-y-6" }, [(0, vue_exports.createVNode)("section", { class: "rounded-2xl border border-line bg-surface p-5" }, [
						(0, vue_exports.createVNode)("h3", { class: "mb-1 text-sm font-bold text-ink" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Registration mode")), 1),
						(0, vue_exports.createVNode)("p", { class: "mb-3 text-xs text-ink-muted" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("When invite-only is on, new members must enter a valid invite code to sign up.")), 1),
						(0, vue_exports.createVNode)("label", { class: "flex items-center gap-2 text-sm text-ink-2" }, [(0, vue_exports.withDirectives)((0, vue_exports.createVNode)("input", {
							"onUpdate:modelValue": ($event) => only.value = $event,
							type: "checkbox",
							class: "rounded border-line text-primary focus:ring-primary",
							onChange: toggleOnly
						}, null, 40, ["onUpdate:modelValue"]), [[vue_exports.vModelCheckbox, only.value]]), (0, vue_exports.createTextVNode)(" " + (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Invite-only registration")), 1)]),
						(0, vue_exports.createVNode)("label", { class: "mt-3 flex items-center gap-2 text-sm text-ink-2" }, [(0, vue_exports.withDirectives)((0, vue_exports.createVNode)("input", {
							"onUpdate:modelValue": ($event) => members.value = $event,
							type: "checkbox",
							class: "rounded border-line text-primary focus:ring-primary",
							onChange: toggleMembers
						}, null, 40, ["onUpdate:modelValue"]), [[vue_exports.vModelCheckbox, members.value]]), (0, vue_exports.createTextVNode)(" " + (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Let members invite their friends")), 1)]),
						(0, vue_exports.createVNode)("p", { class: "mt-1 text-xs text-ink-muted" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Adds an “Invite friends” page with a personal referral link and email invites.")), 1)
					]), (0, vue_exports.createVNode)("section", { class: "rounded-2xl border border-line bg-surface p-5" }, [
						(0, vue_exports.createVNode)("h3", { class: "mb-3 text-sm font-bold text-ink" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Create an invite")), 1),
						(0, vue_exports.createVNode)("label", { class: "block text-xs font-semibold text-ink-2" }, [(0, vue_exports.createTextVNode)((0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Note")) + " ", 1), (0, vue_exports.createVNode)("span", { class: "font-normal text-ink-muted" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("(optional)")), 1)]),
						(0, vue_exports.withDirectives)((0, vue_exports.createVNode)("input", {
							"onUpdate:modelValue": ($event) => (0, vue_exports.unref)(form).note = $event,
							class: field,
							placeholder: (0, vue_exports.unref)(t)("e.g. Beta testers")
						}, null, 8, ["onUpdate:modelValue", "placeholder"]), [[vue_exports.vModelText, (0, vue_exports.unref)(form).note]]),
						(0, vue_exports.createVNode)("label", { class: "mt-3 block text-xs font-semibold text-ink-2" }, [(0, vue_exports.createTextVNode)((0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Reserve for email")) + " ", 1), (0, vue_exports.createVNode)("span", { class: "font-normal text-ink-muted" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("(optional)")), 1)]),
						(0, vue_exports.withDirectives)((0, vue_exports.createVNode)("input", {
							"onUpdate:modelValue": ($event) => (0, vue_exports.unref)(form).email = $event,
							type: "email",
							class: field,
							placeholder: "friend@example.com"
						}, null, 8, ["onUpdate:modelValue"]), [[vue_exports.vModelText, (0, vue_exports.unref)(form).email]]),
						(0, vue_exports.createVNode)("div", { class: "mt-3 grid grid-cols-2 gap-3" }, [(0, vue_exports.createVNode)("div", null, [(0, vue_exports.createVNode)("label", { class: "block text-xs font-semibold text-ink-2" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Max uses")), 1), (0, vue_exports.withDirectives)((0, vue_exports.createVNode)("input", {
							"onUpdate:modelValue": ($event) => (0, vue_exports.unref)(form).max_uses = $event,
							type: "number",
							min: "1",
							class: field
						}, null, 8, ["onUpdate:modelValue"]), [[
							vue_exports.vModelText,
							(0, vue_exports.unref)(form).max_uses,
							void 0,
							{ number: true }
						]])]), (0, vue_exports.createVNode)("div", null, [(0, vue_exports.createVNode)("label", { class: "block text-xs font-semibold text-ink-2" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Expires in (days)")), 1), (0, vue_exports.withDirectives)((0, vue_exports.createVNode)("input", {
							"onUpdate:modelValue": ($event) => (0, vue_exports.unref)(form).expires_days = $event,
							type: "number",
							min: "1",
							class: field,
							placeholder: (0, vue_exports.unref)(t)("never")
						}, null, 8, ["onUpdate:modelValue", "placeholder"]), [[
							vue_exports.vModelText,
							(0, vue_exports.unref)(form).expires_days,
							void 0,
							{ number: true }
						]])])]),
						(0, vue_exports.createVNode)("button", {
							class: "mt-4 rounded-lg bg-primary px-4 py-2 text-sm font-semibold text-white hover:bg-primary-600",
							onClick: create
						}, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Create invite")), 1)
					])]), (0, vue_exports.createVNode)("section", { class: "rounded-2xl border border-line bg-surface p-5" }, [(0, vue_exports.createVNode)("h3", { class: "mb-3 text-sm font-bold text-ink" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Invites")), 1), !__props.invites.length ? ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("div", {
						key: 0,
						class: "text-sm text-ink-muted"
					}, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("No invites yet.")), 1)) : ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("ul", {
						key: 1,
						class: "divide-y divide-line"
					}, [((0, vue_exports.openBlock)(true), (0, vue_exports.createBlock)(vue_exports.Fragment, null, (0, vue_exports.renderList)(__props.invites, (inv) => {
						return (0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("li", {
							key: inv.id,
							class: "flex items-center gap-3 py-3"
						}, [
							(0, vue_exports.createVNode)("div", { class: "min-w-0 flex-1" }, [(0, vue_exports.createVNode)("div", { class: "flex items-center gap-2" }, [(0, vue_exports.createVNode)("code", { class: "rounded bg-appbg px-2 py-0.5 text-sm font-bold text-ink select-all" }, (0, vue_exports.toDisplayString)(inv.code), 1), !inv.usable ? ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("span", {
								key: 0,
								class: "rounded-full bg-red-500/15 px-2 py-0.5 text-[10px] font-bold uppercase text-red-300"
							}, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("used up")), 1)) : (0, vue_exports.createCommentVNode)("", true)]), (0, vue_exports.createVNode)("div", { class: "mt-0.5 truncate text-xs text-ink-muted" }, [
								(0, vue_exports.createTextVNode)((0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("{used}/{max} used", {
									used: inv.uses,
									max: inv.maxUses
								})), 1),
								inv.note ? ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("span", { key: 0 }, " · " + (0, vue_exports.toDisplayString)(inv.note), 1)) : (0, vue_exports.createCommentVNode)("", true),
								inv.email ? ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("span", { key: 1 }, " · " + (0, vue_exports.toDisplayString)(inv.email), 1)) : (0, vue_exports.createCommentVNode)("", true),
								inv.expiresAt ? ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("span", { key: 2 }, " · " + (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("expires {when}", { when: inv.expiresAt })), 1)) : (0, vue_exports.createCommentVNode)("", true)
							])]),
							(0, vue_exports.createVNode)("button", {
								class: "rounded-lg bg-surface-2 px-2.5 py-1.5 text-xs font-semibold text-ink hover:bg-appbg",
								onClick: ($event) => copyLink(inv)
							}, (0, vue_exports.toDisplayString)(copied.value === inv.id ? (0, vue_exports.unref)(t)("Copied!") : (0, vue_exports.unref)(t)("Copy link")), 9, ["onClick"]),
							(0, vue_exports.createVNode)("button", {
								class: "rounded-lg px-2.5 py-1.5 text-xs font-semibold text-red-400 hover:bg-red-500/10",
								onClick: ($event) => revoke(inv.id)
							}, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Revoke")), 9, ["onClick"])
						]);
					}), 128))]))])])];
				}),
				_: 1
			}, _parent));
			_push(`<!--]-->`);
		};
	}
});
//#endregion
//#region resources/js/Pages/Admin/Invites.vue
var _sfc_setup = Invites_vue_vue_type_script_setup_true_lang_default.setup;
Invites_vue_vue_type_script_setup_true_lang_default.setup = (props, ctx) => {
	const ssrContext = (0, vue_exports.useSSRContext)();
	(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("resources/js/Pages/Admin/Invites.vue");
	return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
var Invites_default = Invites_vue_vue_type_script_setup_true_lang_default;
//#endregion
export { Invites_default as default };
