import { t as e } from "./rolldown-runtime-CAFD8bLK.js";
import { A as t, M as n, X as r, b as i, d as a, f as o, h as s, l as c, m as l, ot as u, rt as d, st as f } from "./vue.runtime.esm-bundler-Bxqkjqhc.js";
import { o as p } from "./dist-BzRLLpfq.js";
import { t as m } from "./useI18n-CWX9ZTCW.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 } = m(), y = r(Date.now());
		p(() => {
			y.value = Date.now();
		}, 1e3);
		let b = a(() => {
			if (!i.block.targetDate) return null;
			let e = new Date(i.block.targetDate);
			return isNaN(e.getTime()) ? null : e.getTime();
		}), x = a(() => b.value ? y.value >= b.value : !1), S = a(() => {
			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 = a(() => {
			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 = a(() => ({
			backgroundColor: i.block.backgroundColor,
			fontFamily: i.block.fontFamily || "inherit"
		})), T = a(() => ({
			fontSize: `${i.block.digitFontSize}px`,
			fontWeight: "bold",
			color: i.block.digitColor,
			lineHeight: "1.2"
		})), E = a(() => ({
			fontSize: `${i.block.labelFontSize}px`,
			color: i.block.labelColor,
			marginTop: "4px"
		})), D = a(() => ({
			fontSize: `${i.block.digitFontSize}px`,
			color: i.block.digitColor,
			fontFamily: i.block.fontFamily || "inherit"
		}));
		return (r, i) => e.block.targetDate ? x.value && e.block.hideOnExpiry ? (t(), s("div", g, f(d(v).countdown.hidden), 1)) : x.value ? (t(), s("div", {
			key: 2,
			style: u(w.value),
			class: "tpl:py-4 tpl:text-center"
		}, [o("span", { style: u({
			fontSize: `${e.block.digitFontSize}px`,
			color: e.block.digitColor
		}) }, f(e.block.expiredMessage), 5)], 4)) : (t(), s("div", {
			key: 3,
			style: u(w.value),
			class: "tpl:flex tpl:items-center tpl:justify-center tpl:gap-2 tpl:py-4"
		}, [(t(!0), s(c, null, n(C.value, (n, r) => (t(), s(c, { key: n.label }, [r > 0 ? (t(), s("span", {
			key: 0,
			style: u(D.value),
			class: "tpl:self-start"
		}, f(e.block.separator), 5)) : l("", !0), o("div", _, [o("div", { style: u(T.value) }, f(n.value), 5), o("div", { style: u(E.value) }, f(n.label), 5)])], 64))), 128))], 4)) : (t(), s("div", h, f(d(v).countdown.setDate), 1));
	}
}), y = /* @__PURE__ */ e({ default: () => b }), b = v;
//#endregion
export { y as n, b as t };
