import { r as e } from "./rolldown-runtime-BNuo_Jkg.js";
import { $ as t, F as n, N as r, S as i, _ as a, at as o, ct as s, d as c, g as l, lt as u, m as d, p as f } from "./draggable-Bcb86AsV.js";
import { Mt as p, on as m } from "./features-BnG-dhzy.js";
//#region src/components/blocks/CountdownBlock.vue?vue&type=script&setup=true&lang.ts
var h = {
	key: 0,
	class: "tpl:flex tpl:items-center tpl:justify-center tpl:py-8 tpl:text-sm tpl:text-[var(--tpl-text-dim)]"
}, g = {
	key: 1,
	class: "tpl:flex tpl:items-center tpl:justify-center tpl:py-4 tpl:text-xs tpl:text-[var(--tpl-text-dim)] tpl:opacity-50"
}, _ = { class: "tpl:text-center" }, v = /* @__PURE__ */ i({
	__name: "CountdownBlock",
	props: {
		block: {},
		viewport: {}
	},
	setup(e) {
		let i = e, { t: v } = p(), y = t(Date.now());
		m(() => {
			y.value = Date.now();
		}, 1e3);
		let b = f(() => {
			if (!i.block.targetDate) return null;
			let e = new Date(i.block.targetDate);
			return isNaN(e.getTime()) ? null : e.getTime();
		}), x = f(() => b.value ? y.value >= b.value : !1), S = f(() => {
			if (!b.value || x.value) return {
				days: 0,
				hours: 0,
				minutes: 0,
				seconds: 0
			};
			let e = b.value - y.value, t = Math.floor(e / 1e3);
			return {
				days: Math.floor(t / 86400),
				hours: Math.floor(t % 86400 / 3600),
				minutes: Math.floor(t % 3600 / 60),
				seconds: t % 60
			};
		}), C = f(() => {
			let e = [];
			return i.block.showDays && e.push({
				value: String(S.value.days).padStart(2, "0"),
				label: i.block.labelDays
			}), i.block.showHours && e.push({
				value: String(S.value.hours).padStart(2, "0"),
				label: i.block.labelHours
			}), i.block.showMinutes && e.push({
				value: String(S.value.minutes).padStart(2, "0"),
				label: i.block.labelMinutes
			}), i.block.showSeconds && e.push({
				value: String(S.value.seconds).padStart(2, "0"),
				label: i.block.labelSeconds
			}), e;
		}), w = f(() => ({
			backgroundColor: i.block.backgroundColor,
			fontFamily: i.block.fontFamily || "inherit"
		})), T = f(() => ({
			fontSize: `${i.block.digitFontSize}px`,
			fontWeight: "bold",
			color: i.block.digitColor,
			lineHeight: "1.2"
		})), E = f(() => ({
			fontSize: `${i.block.labelFontSize}px`,
			color: i.block.labelColor,
			marginTop: "4px"
		})), D = f(() => ({
			fontSize: `${i.block.digitFontSize}px`,
			color: i.block.digitColor,
			fontFamily: i.block.fontFamily || "inherit"
		}));
		return (t, i) => e.block.targetDate ? x.value && e.block.hideOnExpiry ? (r(), a("div", g, u(o(v).countdown.hidden), 1)) : x.value ? (r(), a("div", {
			key: 2,
			style: s(w.value),
			class: "tpl:py-4 tpl:text-center"
		}, [d("span", { style: s({
			fontSize: `${e.block.digitFontSize}px`,
			color: e.block.digitColor
		}) }, u(e.block.expiredMessage), 5)], 4)) : (r(), a("div", {
			key: 3,
			style: s(w.value),
			class: "tpl:flex tpl:items-center tpl:justify-center tpl:gap-2 tpl:py-4"
		}, [(r(!0), a(c, null, n(C.value, (t, n) => (r(), a(c, { key: t.label }, [n > 0 ? (r(), a("span", {
			key: 0,
			style: s(D.value),
			class: "tpl:self-start"
		}, u(e.block.separator), 5)) : l("", !0), d("div", _, [d("div", { style: s(T.value) }, u(t.value), 5), d("div", { style: s(E.value) }, u(t.label), 5)])], 64))), 128))], 4)) : (r(), a("div", h, u(o(v).countdown.setDate), 1));
	}
}), y = /* @__PURE__ */ e({ default: () => b }), b = v;
//#endregion
export { y as n, b as t };

//# sourceMappingURL=CountdownBlock-BKg-e3Uo.js.map