import { LogService as e } from "../internal/services/log.service.js";
import { typeSSR as t } from "../internal/controllers/type-ssr.controller.js";
import { useStyles as n } from "../internal/styles/index.js";
import { __decorate as r } from "../_virtual/_@oxc-project_runtime@0.133.0/helpers/esm/decorate.js";
import i from "./format-datetime.js";
import { LitElement as a, html as o } from "lit";
import { property as s } from "lit/decorators/property.js";
//#region src/format-datetime/format-datetime.ts
var c = class extends a {
	static {
		this.styles = n([i]);
	}
	static {
		this.metadata = {
			tag: "nve-format-datetime",
			version: "2.0.2"
		};
	}
	get #e() {
		return this.date ?? this.textContent?.trim() ?? "";
	}
	get #t() {
		return this.locale ?? (globalThis.document?.documentElement?.lang || void 0);
	}
	get #n() {
		let t = this.#e;
		if (!t) return "";
		let n = this.#s(t);
		if (!n) return t;
		try {
			return new Intl.DateTimeFormat(this.#t, this.#r).format(n);
		} catch (n) {
			return e.warn(`format-datetime: ${n.message}`), t;
		}
	}
	get #r() {
		return this.#i ? this.#a : this.#o;
	}
	get #i() {
		return this.dateStyle !== void 0 || this.timeStyle !== void 0;
	}
	get #a() {
		let e = {};
		return this.dateStyle && (e.dateStyle = this.dateStyle), this.timeStyle && (e.timeStyle = this.timeStyle), this.timeZone && (e.timeZone = this.timeZone), e;
	}
	get #o() {
		let e = {};
		return this.weekday && (e.weekday = this.weekday), this.year && (e.year = this.year), this.month && (e.month = this.month), this.day && (e.day = this.day), this.hour && (e.hour = this.hour), this.minute && (e.minute = this.minute), this.second && (e.second = this.second), this.timeZoneName && (e.timeZoneName = this.timeZoneName), this.timeZone && (e.timeZone = this.timeZone), e;
	}
	#s(t) {
		let n = new Date(t);
		return isNaN(n.getTime()) ? (e.warn(`format-datetime: invalid date value "${t}"`), null) : n;
	}
	render() {
		return o`<time internal-host datetime="${this.#e}">${this.#n}<slot @slotchange="${this.#c}" hidden></slot></time>`;
	}
	#c() {
		this.requestUpdate();
	}
};
r([s({ type: String })], c.prototype, "date", void 0), r([s({ type: String })], c.prototype, "locale", void 0), r([s({ type: String })], c.prototype, "weekday", void 0), r([s({ type: String })], c.prototype, "year", void 0), r([s({ type: String })], c.prototype, "month", void 0), r([s({ type: String })], c.prototype, "day", void 0), r([s({ type: String })], c.prototype, "hour", void 0), r([s({ type: String })], c.prototype, "minute", void 0), r([s({ type: String })], c.prototype, "second", void 0), r([s({
	type: String,
	attribute: "date-style"
})], c.prototype, "dateStyle", void 0), r([s({
	type: String,
	attribute: "time-style"
})], c.prototype, "timeStyle", void 0), r([s({
	type: String,
	attribute: "time-zone-name"
})], c.prototype, "timeZoneName", void 0), r([s({
	type: String,
	attribute: "time-zone"
})], c.prototype, "timeZone", void 0), c = r([t()], c);
//#endregion
export { c as FormatDatetime };

//# sourceMappingURL=format-datetime2.js.map