import { T as __toESM, b as require_react, t as require_jsx_runtime } from "../index.js";
import { a as waLink, i as isClinicOpen, n as DOCTORS, r as TREATMENTS, t as CLINIC } from "./clinic-CiEEmMP0.js";
//#region node_modules/react-icons/lib/iconContext.mjs
var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
var DefaultContext = {
	color: void 0,
	size: void 0,
	className: void 0,
	style: void 0,
	attr: void 0
};
var IconContext = import_react.createContext && /* @__PURE__ */ import_react.createContext(DefaultContext);
//#endregion
//#region node_modules/react-icons/lib/iconBase.mjs
var _excluded = [
	"attr",
	"size",
	"title"
];
function _objectWithoutProperties(e, t) {
	if (null == e) return {};
	var o, r, i = _objectWithoutPropertiesLoose(e, t);
	if (Object.getOwnPropertySymbols) {
		var n = Object.getOwnPropertySymbols(e);
		for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
	}
	return i;
}
function _objectWithoutPropertiesLoose(r, e) {
	if (null == r) return {};
	var t = {};
	for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
		if (-1 !== e.indexOf(n)) continue;
		t[n] = r[n];
	}
	return t;
}
function _extends() {
	return _extends = Object.assign ? Object.assign.bind() : function(n) {
		for (var e = 1; e < arguments.length; e++) {
			var t = arguments[e];
			for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
		}
		return n;
	}, _extends.apply(null, arguments);
}
function ownKeys(e, r) {
	var t = Object.keys(e);
	if (Object.getOwnPropertySymbols) {
		var o = Object.getOwnPropertySymbols(e);
		r && (o = o.filter(function(r) {
			return Object.getOwnPropertyDescriptor(e, r).enumerable;
		})), t.push.apply(t, o);
	}
	return t;
}
function _objectSpread(e) {
	for (var r = 1; r < arguments.length; r++) {
		var t = null != arguments[r] ? arguments[r] : {};
		r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
			_defineProperty(e, r, t[r]);
		}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
			Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
		});
	}
	return e;
}
function _defineProperty(e, r, t) {
	return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
		value: t,
		enumerable: !0,
		configurable: !0,
		writable: !0
	}) : e[r] = t, e;
}
function _toPropertyKey(t) {
	var i = _toPrimitive(t, "string");
	return "symbol" == typeof i ? i : i + "";
}
function _toPrimitive(t, r) {
	if ("object" != typeof t || !t) return t;
	var e = t[Symbol.toPrimitive];
	if (void 0 !== e) {
		var i = e.call(t, r || "default");
		if ("object" != typeof i) return i;
		throw new TypeError("@@toPrimitive must return a primitive value.");
	}
	return ("string" === r ? String : Number)(t);
}
function Tree2Element(tree) {
	return tree && tree.map((node, i) => /* @__PURE__ */ import_react.createElement(node.tag, _objectSpread({ key: i }, node.attr), Tree2Element(node.child)));
}
function GenIcon(data) {
	return (props) => /* @__PURE__ */ import_react.createElement(IconBase, _extends({ attr: _objectSpread({}, data.attr) }, props), Tree2Element(data.child));
}
function IconBase(props) {
	var elem = (conf) => {
		var attr = props.attr, size = props.size, title = props.title, svgProps = _objectWithoutProperties(props, _excluded);
		var computedSize = size || conf.size || "1em";
		var className;
		if (conf.className) className = conf.className;
		if (props.className) className = (className ? className + " " : "") + props.className;
		return /* @__PURE__ */ import_react.createElement("svg", _extends({
			stroke: "currentColor",
			fill: "currentColor",
			strokeWidth: "0"
		}, conf.attr, attr, svgProps, {
			className,
			style: _objectSpread(_objectSpread({ color: props.color || conf.color }, conf.style), props.style),
			height: computedSize,
			width: computedSize,
			xmlns: "http://www.w3.org/2000/svg"
		}), title && /* @__PURE__ */ import_react.createElement("title", null, title), props.children);
	};
	return IconContext !== void 0 ? /* @__PURE__ */ import_react.createElement(IconContext.Consumer, null, (conf) => elem(conf)) : elem(DefaultContext);
}
//#endregion
//#region node_modules/react-icons/fa/index.mjs
function FaWhatsapp(props) {
	return GenIcon({
		"tag": "svg",
		"attr": { "viewBox": "0 0 448 512" },
		"child": [{
			"tag": "path",
			"attr": { "d": "M380.9 97.1C339 55.1 283.2 32 223.9 32c-122.4 0-222 99.6-222 222 0 39.1 10.2 77.3 29.6 111L0 480l117.7-30.9c32.4 17.7 68.9 27 106.1 27h.1c122.3 0 224.1-99.6 224.1-222 0-59.3-25.2-115-67.1-157zm-157 341.6c-33.2 0-65.7-8.9-94-25.7l-6.7-4-69.8 18.3L72 359.2l-4.4-7c-18.5-29.4-28.2-63.3-28.2-98.2 0-101.7 82.8-184.5 184.6-184.5 49.3 0 95.6 19.2 130.4 54.1 34.8 34.9 56.2 81.2 56.1 130.5 0 101.8-84.9 184.6-186.6 184.6zm101.2-138.2c-5.5-2.8-32.8-16.2-37.9-18-5.1-1.9-8.8-2.8-12.5 2.8-3.7 5.6-14.3 18-17.6 21.8-3.2 3.7-6.5 4.2-12 1.4-32.6-16.3-54-29.1-75.5-66-5.7-9.8 5.7-9.1 16.3-30.3 1.8-3.7.9-6.9-.5-9.7-1.4-2.8-12.5-30.1-17.1-41.2-4.5-10.8-9.1-9.3-12.5-9.5-3.2-.2-6.9-.2-10.6-.2-3.7 0-9.7 1.4-14.8 6.9-5.1 5.6-19.4 19-19.4 46.3 0 27.3 19.9 53.7 22.6 57.4 2.8 3.7 39.1 59.7 94.8 83.8 35.2 15.2 49 16.5 66.6 13.9 10.7-1.6 32.8-13.4 37.4-26.4 4.6-13 4.6-24.1 3.2-26.4-1.3-2.5-5-3.9-10.5-6.6z" },
			"child": []
		}]
	})(props);
}
//#endregion
//#region node_modules/react-icons/fi/index.mjs
function FiSun(props) {
	return GenIcon({
		"tag": "svg",
		"attr": {
			"viewBox": "0 0 24 24",
			"fill": "none",
			"stroke": "currentColor",
			"strokeWidth": "2",
			"strokeLinecap": "round",
			"strokeLinejoin": "round"
		},
		"child": [
			{
				"tag": "circle",
				"attr": {
					"cx": "12",
					"cy": "12",
					"r": "5"
				},
				"child": []
			},
			{
				"tag": "line",
				"attr": {
					"x1": "12",
					"y1": "1",
					"x2": "12",
					"y2": "3"
				},
				"child": []
			},
			{
				"tag": "line",
				"attr": {
					"x1": "12",
					"y1": "21",
					"x2": "12",
					"y2": "23"
				},
				"child": []
			},
			{
				"tag": "line",
				"attr": {
					"x1": "4.22",
					"y1": "4.22",
					"x2": "5.64",
					"y2": "5.64"
				},
				"child": []
			},
			{
				"tag": "line",
				"attr": {
					"x1": "18.36",
					"y1": "18.36",
					"x2": "19.78",
					"y2": "19.78"
				},
				"child": []
			},
			{
				"tag": "line",
				"attr": {
					"x1": "1",
					"y1": "12",
					"x2": "3",
					"y2": "12"
				},
				"child": []
			},
			{
				"tag": "line",
				"attr": {
					"x1": "21",
					"y1": "12",
					"x2": "23",
					"y2": "12"
				},
				"child": []
			},
			{
				"tag": "line",
				"attr": {
					"x1": "4.22",
					"y1": "19.78",
					"x2": "5.64",
					"y2": "18.36"
				},
				"child": []
			},
			{
				"tag": "line",
				"attr": {
					"x1": "18.36",
					"y1": "5.64",
					"x2": "19.78",
					"y2": "4.22"
				},
				"child": []
			}
		]
	})(props);
}
function FiMoon(props) {
	return GenIcon({
		"tag": "svg",
		"attr": {
			"viewBox": "0 0 24 24",
			"fill": "none",
			"stroke": "currentColor",
			"strokeWidth": "2",
			"strokeLinecap": "round",
			"strokeLinejoin": "round"
		},
		"child": [{
			"tag": "path",
			"attr": { "d": "M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" },
			"child": []
		}]
	})(props);
}
//#endregion
//#region components/GlobalActions.tsx
var import_jsx_runtime = require_jsx_runtime();
var empty = {
	treatment: "",
	doctor: "No preference",
	date: "",
	time: "",
	name: "",
	phone: "",
	email: "",
	message: ""
};
function GlobalActions() {
	const [book, setBook] = (0, import_react.useState)(false), [step, setStep] = (0, import_react.useState)(1), [data, setData] = (0, import_react.useState)(empty), [cookie, setCookie] = (0, import_react.useState)(true), [wa, setWa] = (0, import_react.useState)(false), [showWa, setShowWa] = (0, import_react.useState)(false), [theme, setTheme] = (0, import_react.useState)("light"), [toast, setToast] = (0, import_react.useState)(""), [consent, setConsent] = (0, import_react.useState)(false);
	(0, import_react.useEffect)(() => {
		queueMicrotask(() => {
			const saved = localStorage.getItem("lumea-booking");
			if (saved) setData({
				...empty,
				...JSON.parse(saved)
			});
			setCookie(!localStorage.getItem("lumea-cookie"));
			const savedTheme = localStorage.getItem("lumea-theme");
			const t = savedTheme === "light" || savedTheme === "dark" ? savedTheme : window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
			setTheme(t);
			document.documentElement.dataset.theme = t;
			document.documentElement.style.colorScheme = t;
		});
		const onScroll = () => setShowWa(scrollY > 400);
		addEventListener("scroll", onScroll, { passive: true });
		const click = (e) => {
			const el = e.target.closest("[data-book]");
			if (el) {
				e.preventDefault();
				const tr = el.dataset.treatment || "", doctor = el.dataset.doctor || "";
				setData((d) => ({
					...d,
					treatment: tr || d.treatment,
					doctor: doctor || d.doctor
				}));
				setBook(true);
			}
		};
		document.addEventListener("click", click);
		return () => {
			removeEventListener("scroll", onScroll);
			document.removeEventListener("click", click);
		};
	}, []);
	(0, import_react.useEffect)(() => {
		document.body.style.overflow = book ? "hidden" : "";
		const esc = (e) => e.key === "Escape" && setBook(false);
		addEventListener("keydown", esc);
		return () => {
			document.body.style.overflow = "";
			removeEventListener("keydown", esc);
		};
	}, [book]);
	(0, import_react.useEffect)(() => localStorage.setItem("lumea-booking", JSON.stringify(data)), [data]);
	const slots = (0, import_react.useMemo)(() => [
		"09:00",
		"09:30",
		"10:00",
		"10:30",
		"11:00",
		"12:00",
		"14:00",
		"15:30",
		"17:00",
		"18:30"
	], []);
	const minDate = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
	const invalidDate = data.date && (/* @__PURE__ */ new Date(`${data.date}T12:00`)).getDay() === CLINIC.hours.weeklyOff;
	const next = () => {
		if (step === 1 && !data.treatment) return setToast("Please select a treatment");
		if (step === 3 && (!data.date || !data.time || invalidDate)) return setToast("Please choose an available date and time");
		if (step === 4 && (!data.name || data.phone.replace(/\D/g, "").length < 10 || !data.email.includes("@"))) return setToast("Please complete valid contact details");
		setToast("");
		setStep((s) => Math.min(5, s + 1));
	};
	const confirm = () => {
		if (!consent) return setToast("Please accept the consent checkbox");
		const ref = `LD-${(/* @__PURE__ */ new Date()).toISOString().slice(2, 10).replace(/-/g, "")}-${Math.random().toString(36).slice(2, 6).toUpperCase()}`;
		localStorage.removeItem("lumea-booking");
		location.href = `/thank-you?ref=${ref}&date=${data.date}&time=${data.time}&treatment=${encodeURIComponent(data.treatment)}&name=${encodeURIComponent(data.name)}`;
	};
	const close = () => {
		setBook(false);
		setStep(1);
	};
	const toggleTheme = () => {
		const n = theme === "light" ? "dark" : "light";
		setTheme(n);
		localStorage.setItem("lumea-theme", n);
		document.documentElement.dataset.theme = n;
		document.documentElement.style.colorScheme = n;
	};
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
		/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
			className: "theme-toggle",
			onClick: toggleTheme,
			"aria-label": theme === "light" ? "Switch to dark mode" : "Switch to light mode",
			title: theme === "light" ? "Dark mode" : "Light mode",
			"aria-pressed": theme === "dark",
			children: theme === "light" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FiMoon, {
				size: 20,
				"aria-hidden": "true"
			}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FiSun, {
				size: 20,
				"aria-hidden": "true"
			})
		}),
		/* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
			className: `wa-float ${showWa ? "show" : ""}`,
			href: waLink("Hello Luméa Dental, I would like to know more."),
			target: "_blank",
			rel: "noreferrer",
			onClick: (e) => {
				e.preventDefault();
				setWa((v) => !v);
			},
			"aria-label": "Chat on WhatsApp",
			title: "Chat on WhatsApp",
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FaWhatsapp, {
				size: 30,
				"aria-hidden": "true"
			})
		}),
		wa && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("aside", {
			className: "wa-panel",
			children: [
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
					onClick: () => setWa(false),
					"aria-label": "Close",
					children: "×"
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: "How can we help?" }),
				[
					"Book an appointment",
					"Treatment prices",
					"Clinic timings",
					"Emergency dental care"
				].map((x) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("a", {
					href: waLink(`Hello Luméa Dental, ${x.toLowerCase()}.`),
					target: "_blank",
					rel: "noreferrer",
					children: [x, " →"]
				}, x))
			]
		}),
		/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
			className: "mobile-actions",
			children: [
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
					href: `tel:${CLINIC.phoneRaw}`,
					children: "Call"
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
					href: waLink("Hello Luméa Dental"),
					children: "WhatsApp"
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
					"data-book": true,
					children: "Book"
				})
			]
		}),
		cookie && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
			className: "cookie",
			children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "We use essential storage to remember your booking draft and preferences." }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
				onClick: () => {
					localStorage.setItem("lumea-cookie", "1");
					setCookie(false);
				},
				children: "Accept"
			})]
		}),
		toast && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
			className: "toast",
			role: "status",
			children: toast
		}),
		book && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
			className: "modal-backdrop",
			onMouseDown: (e) => e.target === e.currentTarget && close(),
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
				className: "booking-modal",
				role: "dialog",
				"aria-modal": "true",
				"aria-label": "Book an appointment",
				children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
						className: "modal-close",
						onClick: close,
						"aria-label": "Close booking",
						children: "×"
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("small", { children: [
						"STEP ",
						step,
						" OF 5"
					] }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
						className: "booking-progress",
						children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", { style: { width: `${step * 20}%` } })
					}),
					step === 1 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: "Choose your treatment" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
						className: "choice-grid",
						children: TREATMENTS.map((t) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
							className: data.treatment === t.title ? "selected" : "",
							onClick: () => setData({
								...data,
								treatment: t.title
							}),
							children: t.title
						}, t.slug))
					})] }),
					step === 2 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: "Choose your doctor" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
						className: "choice-grid",
						children: ["No preference", ...DOCTORS.map((d) => d.name)].map((d) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
							className: data.doctor === d ? "selected" : "",
							onClick: () => setData({
								...data,
								doctor: d
							}),
							children: d
						}, d))
					})] }),
					step === 3 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: "Select date & time" }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: ["Date", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
							type: "date",
							min: minDate,
							value: data.date,
							onChange: (e) => setData({
								...data,
								date: e.target.value
							})
						})] }),
						invalidDate && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
							className: "field-error",
							children: "Clinic is closed on Sundays."
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
							className: "slot-grid",
							children: slots.map((s) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
								className: data.time === s ? "selected" : "",
								disabled: invalidDate ? true : false,
								onClick: () => setData({
									...data,
									time: s
								}),
								children: s
							}, s))
						})
					] }),
					step === 4 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: "Your details" }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
						className: "form-grid",
						children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: ["Full name", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
								value: data.name,
								onChange: (e) => setData({
									...data,
									name: e.target.value
								})
							})] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: ["Phone", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
								inputMode: "tel",
								value: data.phone,
								onChange: (e) => setData({
									...data,
									phone: e.target.value
								})
							})] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: ["Email", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
								type: "email",
								value: data.email,
								onChange: (e) => setData({
									...data,
									email: e.target.value
								})
							})] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: ["Message", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", {
								value: data.message,
								onChange: (e) => setData({
									...data,
									message: e.target.value
								})
							})] })
						]
					})] }),
					step === 5 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: "Review your visit" }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
							className: "booking-summary",
							children: [
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Treatment" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: data.treatment })] }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Doctor" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: data.doctor })] }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "When" }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("b", { children: [
									data.date,
									" · ",
									data.time
								] })] }),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Patient" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: data.name })] })
							]
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
							className: "consent",
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
								type: "checkbox",
								checked: consent,
								onChange: (e) => setConsent(e.target.checked)
							}), " I consent to being contacted about this appointment."]
						})
					] }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
						className: "modal-actions",
						children: [step > 1 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
							onClick: () => setStep((s) => s - 1),
							children: "Back"
						}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
							className: "modal-primary",
							onClick: step === 5 ? confirm : next,
							children: step === 5 ? "Confirm appointment" : "Continue"
						})]
					})
				]
			})
		}),
		/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
			className: `open-indicator ${isClinicOpen() ? "open" : "closed"}`,
			children: isClinicOpen() ? "Open now" : "Closed now"
		})
	] });
}
//#endregion
export { GlobalActions as default };
