import { r as e } from "./rolldown-runtime-BZGGJVDF.js";
import { M as t, Mt as n, Ot as r, P as i, Q as a, S as o, _ as s, d as c, g as l, it as u, m as d, p as f } from "./vue.runtime.esm-bundler-DpvJL-nX.js";
import { o as p } from "./dist-CuyhAnuE.js";
import { t as m } from "./useI18n-Jp3X6Q0t.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__ */ o({
	__name: "CountdownBlock",
	props: {
		block: {},
		viewport: {}
	},
	setup(e) {
		let o = e, { t: v } = m(), y = a(Date.now());
		p(() => {
			y.value = Date.now();
		}, 1e3);
		let b = f(() => {
			if (!o.block.targetDate) return null;
			let e = new Date(o.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 o.block.showDays && e.push({
				value: String(S.value.days).padStart(2, "0"),
				label: o.block.labelDays
			}), o.block.showHours && e.push({
				value: String(S.value.hours).padStart(2, "0"),
				label: o.block.labelHours
			}), o.block.showMinutes && e.push({
				value: String(S.value.minutes).padStart(2, "0"),
				label: o.block.labelMinutes
			}), o.block.showSeconds && e.push({
				value: String(S.value.seconds).padStart(2, "0"),
				label: o.block.labelSeconds
			}), e;
		}), w = f(() => ({
			backgroundColor: o.block.backgroundColor,
			fontFamily: o.block.fontFamily || "inherit"
		})), T = f(() => ({
			fontSize: `${o.block.digitFontSize}px`,
			fontWeight: "bold",
			color: o.block.digitColor,
			lineHeight: "1.2"
		})), E = f(() => ({
			fontSize: `${o.block.labelFontSize}px`,
			color: o.block.labelColor,
			marginTop: "4px"
		})), D = f(() => ({
			fontSize: `${o.block.digitFontSize}px`,
			color: o.block.digitColor,
			fontFamily: o.block.fontFamily || "inherit"
		}));
		return (a, o) => e.block.targetDate ? x.value && e.block.hideOnExpiry ? (t(), s("div", g, n(u(v).countdown.hidden), 1)) : x.value ? (t(), s("div", {
			key: 2,
			style: r(w.value),
			class: "tpl:py-4 tpl:text-center"
		}, [d("span", { style: r({
			fontSize: `${e.block.digitFontSize}px`,
			color: e.block.digitColor
		}) }, n(e.block.expiredMessage), 5)], 4)) : (t(), s("div", {
			key: 3,
			style: r(w.value),
			class: "tpl:flex tpl:items-center tpl:justify-center tpl:gap-2 tpl:py-4"
		}, [(t(!0), s(c, null, i(C.value, (i, a) => (t(), s(c, { key: i.label }, [a > 0 ? (t(), s("span", {
			key: 0,
			style: r(D.value),
			class: "tpl:self-start"
		}, n(e.block.separator), 5)) : l("", !0), d("div", _, [d("div", { style: r(T.value) }, n(i.value), 5), d("div", { style: r(E.value) }, n(i.label), 5)])], 64))), 128))], 4)) : (t(), s("div", h, n(u(v).countdown.setDate), 1));
	}
}), y = /* @__PURE__ */ e({ default: () => b }), b = v;
//#endregion
export { y as n, b as t };
