@tiaohsun/vue-datepicker
Version:
A Vue 3 datepicker with multi-calendar support, styled with Tailwind CSS
7,474 lines • 262 kB
JavaScript
import { defineComponent as Te, ref as z, computed as T, watch as de, createElementBlock as L, openBlock as A, Fragment as pe, renderList as ge, withDirectives as Re, createCommentVNode as oe, vModelText as We, toDisplayString as ne, nextTick as we, createElementVNode as j, withModifiers as Me, normalizeClass as De, renderSlot as ve, onMounted as Bt, onBeforeUnmount as qt, createVNode as ce, createTextVNode as Ma, unref as V, withKeys as Fe, vModelSelect as wt, createSlots as dt, withCtx as ft, normalizeProps as mt, guardReactiveProps as ht, isMemoSame as jr, createBlock as Jr, useSlots as Kr, toRef as it, onBeforeMount as er, mergeProps as tr, isRef as wa } from "vue";
import ue from "dayjs";
function yt(t) {
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
}
var St = { exports: {} }, Qr = St.exports, Sa;
function Zr() {
return Sa || (Sa = 1, function(t, e) {
(function(a, r) {
t.exports = r();
})(Qr, function() {
var a = "minute", r = /[+-]\d\d(?::?\d\d)?/g, n = /([+-]|\d\d)/g;
return function(o, s, l) {
var u = s.prototype;
l.utc = function(d) {
var h = { date: d, utc: !0, args: arguments };
return new s(h);
}, u.utc = function(d) {
var h = l(this.toDate(), { locale: this.$L, utc: !0 });
return d ? h.add(this.utcOffset(), a) : h;
}, u.local = function() {
return l(this.toDate(), { locale: this.$L, utc: !1 });
};
var i = u.parse;
u.parse = function(d) {
d.utc && (this.$u = !0), this.$utils().u(d.$offset) || (this.$offset = d.$offset), i.call(this, d);
};
var f = u.init;
u.init = function() {
if (this.$u) {
var d = this.$d;
this.$y = d.getUTCFullYear(), this.$M = d.getUTCMonth(), this.$D = d.getUTCDate(), this.$W = d.getUTCDay(), this.$H = d.getUTCHours(), this.$m = d.getUTCMinutes(), this.$s = d.getUTCSeconds(), this.$ms = d.getUTCMilliseconds();
} else f.call(this);
};
var y = u.utcOffset;
u.utcOffset = function(d, h) {
var c = this.$utils().u;
if (c(d)) return this.$u ? 0 : c(this.$offset) ? y.call(this) : this.$offset;
if (typeof d == "string" && (d = function(v) {
v === void 0 && (v = "");
var $ = v.match(r);
if (!$) return null;
var g = ("" + $[0]).match(n) || ["-", 0, 0], p = g[0], D = 60 * +g[1] + +g[2];
return D === 0 ? 0 : p === "+" ? D : -D;
}(d), d === null)) return this;
var w = Math.abs(d) <= 16 ? 60 * d : d;
if (w === 0) return this.utc(h);
var x = this.clone();
if (h) return x.$offset = w, x.$u = !1, x;
var b = this.$u ? this.toDate().getTimezoneOffset() : -1 * this.utcOffset();
return (x = this.local().add(w + b, a)).$offset = w, x.$x.$localOffset = b, x;
};
var m = u.format;
u.format = function(d) {
var h = d || (this.$u ? "YYYY-MM-DDTHH:mm:ss[Z]" : "");
return m.call(this, h);
}, u.valueOf = function() {
var d = this.$utils().u(this.$offset) ? 0 : this.$offset + (this.$x.$localOffset || this.$d.getTimezoneOffset());
return this.$d.valueOf() - 6e4 * d;
}, u.isUTC = function() {
return !!this.$u;
}, u.toISOString = function() {
return this.toDate().toISOString();
}, u.toString = function() {
return this.toDate().toUTCString();
};
var k = u.toDate;
u.toDate = function(d) {
return d === "s" && this.$offset ? l(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate() : k.call(this);
};
var S = u.diff;
u.diff = function(d, h, c) {
if (d && this.$u === d.$u) return S.call(this, d, h, c);
var w = this.local(), x = l(d).local();
return S.call(w, x, h, c);
};
};
});
}(St)), St.exports;
}
var Gr = Zr();
const Xr = /* @__PURE__ */ yt(Gr);
var kt = { exports: {} }, _r = kt.exports, ka;
function en() {
return ka || (ka = 1, function(t, e) {
(function(a, r) {
t.exports = r();
})(_r, function() {
var a = { year: 0, month: 1, day: 2, hour: 3, minute: 4, second: 5 }, r = {};
return function(n, o, s) {
var l, u = function(m, k, S) {
S === void 0 && (S = {});
var d = new Date(m), h = function(c, w) {
w === void 0 && (w = {});
var x = w.timeZoneName || "short", b = c + "|" + x, v = r[b];
return v || (v = new Intl.DateTimeFormat("en-US", { hour12: !1, timeZone: c, year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit", timeZoneName: x }), r[b] = v), v;
}(k, S);
return h.formatToParts(d);
}, i = function(m, k) {
for (var S = u(m, k), d = [], h = 0; h < S.length; h += 1) {
var c = S[h], w = c.type, x = c.value, b = a[w];
b >= 0 && (d[b] = parseInt(x, 10));
}
var v = d[3], $ = v === 24 ? 0 : v, g = d[0] + "-" + d[1] + "-" + d[2] + " " + $ + ":" + d[4] + ":" + d[5] + ":000", p = +m;
return (s.utc(g).valueOf() - (p -= p % 1e3)) / 6e4;
}, f = o.prototype;
f.tz = function(m, k) {
m === void 0 && (m = l);
var S, d = this.utcOffset(), h = this.toDate(), c = h.toLocaleString("en-US", { timeZone: m }), w = Math.round((h - new Date(c)) / 1e3 / 60), x = 15 * -Math.round(h.getTimezoneOffset() / 15) - w;
if (!Number(x)) S = this.utcOffset(0, k);
else if (S = s(c, { locale: this.$L }).$set("millisecond", this.$ms).utcOffset(x, !0), k) {
var b = S.utcOffset();
S = S.add(d - b, "minute");
}
return S.$x.$timezone = m, S;
}, f.offsetName = function(m) {
var k = this.$x.$timezone || s.tz.guess(), S = u(this.valueOf(), k, { timeZoneName: m }).find(function(d) {
return d.type.toLowerCase() === "timezonename";
});
return S && S.value;
};
var y = f.startOf;
f.startOf = function(m, k) {
if (!this.$x || !this.$x.$timezone) return y.call(this, m, k);
var S = s(this.format("YYYY-MM-DD HH:mm:ss:SSS"), { locale: this.$L });
return y.call(S, m, k).tz(this.$x.$timezone, !0);
}, s.tz = function(m, k, S) {
var d = S && k, h = S || k || l, c = i(+s(), h);
if (typeof m != "string") return s(m).tz(h);
var w = function($, g, p) {
var D = $ - 60 * g * 1e3, F = i(D, p);
if (g === F) return [D, g];
var P = i(D -= 60 * (F - g) * 1e3, p);
return F === P ? [D, F] : [$ - 60 * Math.min(F, P) * 1e3, Math.max(F, P)];
}(s.utc(m, d).valueOf(), c, h), x = w[0], b = w[1], v = s(x).utcOffset(b);
return v.$x.$timezone = h, v;
}, s.tz.guess = function() {
return Intl.DateTimeFormat().resolvedOptions().timeZone;
}, s.tz.setDefault = function(m) {
l = m;
};
};
});
}(kt)), kt.exports;
}
var tn = en();
const an = /* @__PURE__ */ yt(tn);
var xt = { exports: {} }, rn = xt.exports, xa;
function nn() {
return xa || (xa = 1, function(t, e) {
(function(a, r) {
t.exports = r();
})(rn, function() {
var a = { LTS: "h:mm:ss A", LT: "h:mm A", L: "MM/DD/YYYY", LL: "MMMM D, YYYY", LLL: "MMMM D, YYYY h:mm A", LLLL: "dddd, MMMM D, YYYY h:mm A" }, r = /(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g, n = /\d/, o = /\d\d/, s = /\d\d?/, l = /\d*[^-_:/,()\s\d]+/, u = {}, i = function(h) {
return (h = +h) + (h > 68 ? 1900 : 2e3);
}, f = function(h) {
return function(c) {
this[h] = +c;
};
}, y = [/[+-]\d\d:?(\d\d)?|Z/, function(h) {
(this.zone || (this.zone = {})).offset = function(c) {
if (!c || c === "Z") return 0;
var w = c.match(/([+-]|\d\d)/g), x = 60 * w[1] + (+w[2] || 0);
return x === 0 ? 0 : w[0] === "+" ? -x : x;
}(h);
}], m = function(h) {
var c = u[h];
return c && (c.indexOf ? c : c.s.concat(c.f));
}, k = function(h, c) {
var w, x = u.meridiem;
if (x) {
for (var b = 1; b <= 24; b += 1) if (h.indexOf(x(b, 0, c)) > -1) {
w = b > 12;
break;
}
} else w = h === (c ? "pm" : "PM");
return w;
}, S = { A: [l, function(h) {
this.afternoon = k(h, !1);
}], a: [l, function(h) {
this.afternoon = k(h, !0);
}], Q: [n, function(h) {
this.month = 3 * (h - 1) + 1;
}], S: [n, function(h) {
this.milliseconds = 100 * +h;
}], SS: [o, function(h) {
this.milliseconds = 10 * +h;
}], SSS: [/\d{3}/, function(h) {
this.milliseconds = +h;
}], s: [s, f("seconds")], ss: [s, f("seconds")], m: [s, f("minutes")], mm: [s, f("minutes")], H: [s, f("hours")], h: [s, f("hours")], HH: [s, f("hours")], hh: [s, f("hours")], D: [s, f("day")], DD: [o, f("day")], Do: [l, function(h) {
var c = u.ordinal, w = h.match(/\d+/);
if (this.day = w[0], c) for (var x = 1; x <= 31; x += 1) c(x).replace(/\[|\]/g, "") === h && (this.day = x);
}], w: [s, f("week")], ww: [o, f("week")], M: [s, f("month")], MM: [o, f("month")], MMM: [l, function(h) {
var c = m("months"), w = (m("monthsShort") || c.map(function(x) {
return x.slice(0, 3);
})).indexOf(h) + 1;
if (w < 1) throw new Error();
this.month = w % 12 || w;
}], MMMM: [l, function(h) {
var c = m("months").indexOf(h) + 1;
if (c < 1) throw new Error();
this.month = c % 12 || c;
}], Y: [/[+-]?\d+/, f("year")], YY: [o, function(h) {
this.year = i(h);
}], YYYY: [/\d{4}/, f("year")], Z: y, ZZ: y };
function d(h) {
var c, w;
c = h, w = u && u.formats;
for (var x = (h = c.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g, function(F, P, J) {
var _ = J && J.toUpperCase();
return P || w[J] || a[J] || w[_].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g, function(K, Z, O) {
return Z || O.slice(1);
});
})).match(r), b = x.length, v = 0; v < b; v += 1) {
var $ = x[v], g = S[$], p = g && g[0], D = g && g[1];
x[v] = D ? { regex: p, parser: D } : $.replace(/^\[|\]$/g, "");
}
return function(F) {
for (var P = {}, J = 0, _ = 0; J < b; J += 1) {
var K = x[J];
if (typeof K == "string") _ += K.length;
else {
var Z = K.regex, O = K.parser, R = F.slice(_), M = Z.exec(R)[0];
O.call(P, M), F = F.replace(M, "");
}
}
return function(H) {
var U = H.afternoon;
if (U !== void 0) {
var X = H.hours;
U ? X < 12 && (H.hours += 12) : X === 12 && (H.hours = 0), delete H.afternoon;
}
}(P), P;
};
}
return function(h, c, w) {
w.p.customParseFormat = !0, h && h.parseTwoDigitYear && (i = h.parseTwoDigitYear);
var x = c.prototype, b = x.parse;
x.parse = function(v) {
var $ = v.date, g = v.utc, p = v.args;
this.$u = g;
var D = p[1];
if (typeof D == "string") {
var F = p[2] === !0, P = p[3] === !0, J = F || P, _ = p[2];
P && (_ = p[2]), u = this.$locale(), !F && _ && (u = w.Ls[_]), this.$d = function(R, M, H, U) {
try {
if (["x", "X"].indexOf(M) > -1) return new Date((M === "X" ? 1e3 : 1) * R);
var X = d(M)(R), ie = X.year, se = X.month, E = X.day, C = X.hours, q = X.minutes, G = X.seconds, Y = X.milliseconds, W = X.zone, ee = X.week, fe = /* @__PURE__ */ new Date(), ye = E || (ie || se ? 1 : fe.getDate()), be = ie || fe.getFullYear(), Ye = 0;
ie && !se || (Ye = se > 0 ? se - 1 : fe.getMonth());
var $e, te = C || 0, B = q || 0, N = G || 0, ae = Y || 0;
return W ? new Date(Date.UTC(be, Ye, ye, te, B, N, ae + 60 * W.offset * 1e3)) : H ? new Date(Date.UTC(be, Ye, ye, te, B, N, ae)) : ($e = new Date(be, Ye, ye, te, B, N, ae), ee && ($e = U($e).week(ee).toDate()), $e);
} catch {
return /* @__PURE__ */ new Date("");
}
}($, D, g, w), this.init(), _ && _ !== !0 && (this.$L = this.locale(_).$L), J && $ != this.format(D) && (this.$d = /* @__PURE__ */ new Date("")), u = {};
} else if (D instanceof Array) for (var K = D.length, Z = 1; Z <= K; Z += 1) {
p[1] = D[Z - 1];
var O = w.apply(this, p);
if (O.isValid()) {
this.$d = O.$d, this.$L = O.$L, this.init();
break;
}
Z === K && (this.$d = /* @__PURE__ */ new Date(""));
}
else b.call(this, v);
};
};
});
}(xt)), xt.exports;
}
var on = nn();
const ar = /* @__PURE__ */ yt(on);
var Tt = { exports: {} }, ln = Tt.exports, Ta;
function sn() {
return Ta || (Ta = 1, function(t, e) {
(function(a, r) {
t.exports = r();
})(ln, function() {
var a = "week", r = "year";
return function(n, o, s) {
var l = o.prototype;
l.week = function(u) {
if (u === void 0 && (u = null), u !== null) return this.add(7 * (u - this.week()), "day");
var i = this.$locale().yearStart || 1;
if (this.month() === 11 && this.date() > 25) {
var f = s(this).startOf(r).add(1, r).date(i), y = s(this).endOf(a);
if (f.isBefore(y)) return 1;
}
var m = s(this).startOf(r).date(i).startOf(a).subtract(1, "millisecond"), k = this.diff(m, a, !0);
return k < 0 ? s(this).startOf("week").week() : Math.ceil(k);
}, l.weeks = function(u) {
return u === void 0 && (u = null), this.week(u);
};
};
});
}(Tt)), Tt.exports;
}
var un = sn();
const cn = /* @__PURE__ */ yt(un);
var Ct = { exports: {} }, dn = Ct.exports, Ca;
function fn() {
return Ca || (Ca = 1, function(t, e) {
(function(a, r) {
t.exports = r();
})(dn, function() {
return function(a, r, n) {
var o = r.prototype, s = function(y) {
return y && (y.indexOf ? y : y.s);
}, l = function(y, m, k, S, d) {
var h = y.name ? y : y.$locale(), c = s(h[m]), w = s(h[k]), x = c || w.map(function(v) {
return v.slice(0, S);
});
if (!d) return x;
var b = h.weekStart;
return x.map(function(v, $) {
return x[($ + (b || 0)) % 7];
});
}, u = function() {
return n.Ls[n.locale()];
}, i = function(y, m) {
return y.formats[m] || function(k) {
return k.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g, function(S, d, h) {
return d || h.slice(1);
});
}(y.formats[m.toUpperCase()]);
}, f = function() {
var y = this;
return { months: function(m) {
return m ? m.format("MMMM") : l(y, "months");
}, monthsShort: function(m) {
return m ? m.format("MMM") : l(y, "monthsShort", "months", 3);
}, firstDayOfWeek: function() {
return y.$locale().weekStart || 0;
}, weekdays: function(m) {
return m ? m.format("dddd") : l(y, "weekdays");
}, weekdaysMin: function(m) {
return m ? m.format("dd") : l(y, "weekdaysMin", "weekdays", 2);
}, weekdaysShort: function(m) {
return m ? m.format("ddd") : l(y, "weekdaysShort", "weekdays", 3);
}, longDateFormat: function(m) {
return i(y.$locale(), m);
}, meridiem: this.$locale().meridiem, ordinal: this.$locale().ordinal };
};
o.localeData = function() {
return f.bind(this)();
}, n.localeData = function() {
var y = u();
return { firstDayOfWeek: function() {
return y.weekStart || 0;
}, weekdays: function() {
return n.weekdays();
}, weekdaysShort: function() {
return n.weekdaysShort();
}, weekdaysMin: function() {
return n.weekdaysMin();
}, months: function() {
return n.months();
}, monthsShort: function() {
return n.monthsShort();
}, longDateFormat: function(m) {
return i(y, m);
}, meridiem: y.meridiem, ordinal: y.ordinal };
}, n.months = function() {
return l(u(), "months");
}, n.monthsShort = function() {
return l(u(), "monthsShort", "months", 3);
}, n.weekdays = function(y) {
return l(u(), "weekdays", null, null, y);
}, n.weekdaysShort = function(y) {
return l(u(), "weekdaysShort", "weekdays", 3, y);
}, n.weekdaysMin = function(y) {
return l(u(), "weekdaysMin", "weekdays", 2, y);
};
};
});
}(Ct)), Ct.exports;
}
var mn = fn();
const hn = /* @__PURE__ */ yt(mn);
ue.extend(ar);
const Ya = {
"en-US": ["MM/DD/YYYY", "M/D/YYYY"],
"en-GB": ["DD/MM/YYYY", "D/M/YYYY"],
"zh-TW": ["YYYY-MM-DD", "YYYY/MM/DD"],
"zh-CN": ["YYYY-MM-DD", "YYYY/MM/DD"]
}, Ra = [
"YYYY-MM-DD",
"YYYY/MM/DD",
"DD/MM/YYYY",
"MM/DD/YYYY",
"DD-MM-YYYY",
"MM-DD-YYYY",
"YY-MM-DD",
"YY/MM/DD"
];
class vn {
locale;
calendar;
preferredFormats;
constructor(e = "zh-TW", a = "gregory") {
this.locale = e, this.calendar = a, this.preferredFormats = [
...Ya[e] || [],
...Ra
];
}
parse(e) {
if (!e || typeof e != "string")
return { success: !1, date: null, format: null, confidence: 0 };
const a = e.trim();
try {
const r = this.tryParseWithPlugins(a);
if (r.success) return r;
for (const n of this.preferredFormats) {
const o = this.tryParseWithFormat(a, n);
if (o.success)
return { ...o, confidence: 0.9 };
}
return this.fallbackParse(a);
} catch (r) {
return console.warn("日期解析失敗:", r), { success: !1, date: null, format: null, confidence: 0 };
}
}
tryParseWithPlugins(e) {
switch (this.calendar) {
case "roc":
const a = new xr();
if (a.canParseInput(e)) {
const r = a.parseInput(e, this.locale);
if (r)
return {
success: !0,
date: r,
format: "roc-plugin",
confidence: 0.95,
calendarSystem: "roc"
};
}
break;
}
return { success: !1, date: null, format: null, confidence: 0 };
}
tryParseWithFormat(e, a) {
try {
const r = ue(e, a, !0);
if (r.isValid())
return {
success: !0,
date: {
year: r.year(),
month: r.month() + 1,
day: r.date(),
hour: r.hour() || 0,
minute: r.minute() || 0,
second: r.second() || 0
},
format: a,
confidence: 1,
calendarSystem: "gregory"
};
} catch {
}
return { success: !1, date: null, format: null, confidence: 0 };
}
fallbackParse(e) {
try {
const a = ue(e);
if (a.isValid())
return {
success: !0,
date: {
year: a.year(),
month: a.month() + 1,
day: a.date(),
hour: a.hour() || 0,
minute: a.minute() || 0,
second: a.second() || 0
},
format: "auto-detected",
confidence: 0.6,
calendarSystem: "gregory"
};
} catch {
}
return { success: !1, date: null, format: null, confidence: 0 };
}
setLocale(e) {
this.locale = e, this.preferredFormats = [
...Ya[e] || [],
...Ra
];
}
setCalendar(e) {
this.calendar = e;
}
}
const ot = new vn();
function yn(t, e = "zh-TW", a = "gregory") {
return e !== ot.locale && ot.setLocale(e), a !== ot.calendar && ot.setCalendar(a), ot.parse(t);
}
function Qe(t, e) {
return t - e * Math.floor(t / e);
}
const rr = 1721426;
function ze(t, e, a, r) {
e = gt(t, e);
let n = e - 1, o = -2;
return a <= 2 ? o = 0 : qe(e) && (o = -1), rr - 1 + 365 * n + Math.floor(n / 4) - Math.floor(n / 100) + Math.floor(n / 400) + Math.floor((367 * a - 362) / 12 + o + r);
}
function qe(t) {
return t % 4 === 0 && (t % 100 !== 0 || t % 400 === 0);
}
function gt(t, e) {
return t === "BC" ? 1 - e : e;
}
function Nt(t) {
let e = "AD";
return t <= 0 && (e = "BC", t = 1 - t), [
e,
t
];
}
const gn = {
standard: [
31,
28,
31,
30,
31,
30,
31,
31,
30,
31,
30,
31
],
leapyear: [
31,
29,
31,
30,
31,
30,
31,
31,
30,
31,
30,
31
]
};
class xe {
fromJulianDay(e) {
let a = e, r = a - rr, n = Math.floor(r / 146097), o = Qe(r, 146097), s = Math.floor(o / 36524), l = Qe(o, 36524), u = Math.floor(l / 1461), i = Qe(l, 1461), f = Math.floor(i / 365), y = n * 400 + s * 100 + u * 4 + f + (s !== 4 && f !== 4 ? 1 : 0), [m, k] = Nt(y), S = a - ze(m, k, 1, 1), d = 2;
a < ze(m, k, 3, 1) ? d = 0 : qe(k) && (d = 1);
let h = Math.floor(((S + d) * 12 + 373) / 367), c = a - ze(m, k, h, 1) + 1;
return new le(m, k, h, c);
}
toJulianDay(e) {
return ze(e.era, e.year, e.month, e.day);
}
getDaysInMonth(e) {
return gn[qe(e.year) ? "leapyear" : "standard"][e.month - 1];
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
getMonthsInYear(e) {
return 12;
}
getDaysInYear(e) {
return qe(e.year) ? 366 : 365;
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
getYearsInEra(e) {
return 9999;
}
getEras() {
return [
"BC",
"AD"
];
}
isInverseEra(e) {
return e.era === "BC";
}
balanceDate(e) {
e.year <= 0 && (e.era = e.era === "BC" ? "AD" : "BC", e.year = 1 - e.year);
}
constructor() {
this.identifier = "gregory";
}
}
const pn = {
"001": 1,
AD: 1,
AE: 6,
AF: 6,
AI: 1,
AL: 1,
AM: 1,
AN: 1,
AR: 1,
AT: 1,
AU: 1,
AX: 1,
AZ: 1,
BA: 1,
BE: 1,
BG: 1,
BH: 6,
BM: 1,
BN: 1,
BY: 1,
CH: 1,
CL: 1,
CM: 1,
CN: 1,
CR: 1,
CY: 1,
CZ: 1,
DE: 1,
DJ: 6,
DK: 1,
DZ: 6,
EC: 1,
EE: 1,
EG: 6,
ES: 1,
FI: 1,
FJ: 1,
FO: 1,
FR: 1,
GB: 1,
GE: 1,
GF: 1,
GP: 1,
GR: 1,
HR: 1,
HU: 1,
IE: 1,
IQ: 6,
IR: 6,
IS: 1,
IT: 1,
JO: 6,
KG: 1,
KW: 6,
KZ: 1,
LB: 1,
LI: 1,
LK: 1,
LT: 1,
LU: 1,
LV: 1,
LY: 6,
MC: 1,
MD: 1,
ME: 1,
MK: 1,
MN: 1,
MQ: 1,
MV: 5,
MY: 1,
NL: 1,
NO: 1,
NZ: 1,
OM: 6,
PL: 1,
QA: 6,
RE: 1,
RO: 1,
RS: 1,
RU: 1,
SD: 6,
SE: 1,
SI: 1,
SK: 1,
SM: 1,
SY: 6,
TJ: 1,
TM: 1,
TR: 1,
UA: 1,
UY: 1,
UZ: 1,
VA: 1,
VN: 1,
XK: 1
};
function $n(t, e) {
var a, r, n, o;
return (o = (n = (a = t.isEqual) === null || a === void 0 ? void 0 : a.call(t, e)) !== null && n !== void 0 ? n : (r = e.isEqual) === null || r === void 0 ? void 0 : r.call(e, t)) !== null && o !== void 0 ? o : t.identifier === e.identifier;
}
function nr(t, e, a) {
let r = t.calendar.toJulianDay(t), n = kn(e), o = Math.ceil(r + 1 - n) % 7;
return o < 0 && (o += 7), o;
}
function Dn(t) {
return Le(Date.now(), t);
}
function bn(t) {
return Yn(Dn(t));
}
function or(t, e) {
return t.calendar.toJulianDay(t) - e.calendar.toJulianDay(e);
}
function Mn(t, e) {
return Ea(t) - Ea(e);
}
function Ea(t) {
return t.hour * 36e5 + t.minute * 6e4 + t.second * 1e3 + t.millisecond;
}
let Wt = null;
function ma() {
return Wt == null && (Wt = new Intl.DateTimeFormat().resolvedOptions().timeZone), Wt;
}
function wn(t) {
return t.subtract({
days: t.day - 1
});
}
const Ia = /* @__PURE__ */ new Map(), jt = /* @__PURE__ */ new Map();
function Sn(t) {
if (Intl.Locale) {
let a = Ia.get(t);
return a || (a = new Intl.Locale(t).maximize().region, a && Ia.set(t, a)), a;
}
let e = t.split("-")[1];
return e === "u" ? void 0 : e;
}
function kn(t) {
let e = jt.get(t);
if (!e) {
if (Intl.Locale) {
let r = new Intl.Locale(t);
if ("getWeekInfo" in r && (e = r.getWeekInfo(), e))
return jt.set(t, e), e.firstDay;
}
let a = Sn(t);
if (t.includes("-fw-")) {
let r = t.split("-fw-")[1].split("-")[0];
r === "mon" ? e = {
firstDay: 1
} : r === "tue" ? e = {
firstDay: 2
} : r === "wed" ? e = {
firstDay: 3
} : r === "thu" ? e = {
firstDay: 4
} : r === "fri" ? e = {
firstDay: 5
} : r === "sat" ? e = {
firstDay: 6
} : e = {
firstDay: 0
};
} else t.includes("-ca-iso8601") ? e = {
firstDay: 1
} : e = {
firstDay: a && pn[a] || 0
};
jt.set(t, e);
}
return e.firstDay;
}
function xn(t, e, a) {
let r = t.calendar.getDaysInMonth(t);
return Math.ceil((nr(wn(t), e) + r) / 7);
}
function tt(t) {
t = Se(t, new xe());
let e = gt(t.era, t.year);
return lr(e, t.month, t.day, t.hour, t.minute, t.second, t.millisecond);
}
function lr(t, e, a, r, n, o, s) {
let l = /* @__PURE__ */ new Date();
return l.setUTCHours(r, n, o, s), l.setUTCFullYear(t, e - 1, a), l.getTime();
}
function Xt(t, e) {
if (e === "UTC") return 0;
if (t > 0 && e === ma()) return new Date(t).getTimezoneOffset() * -6e4;
let { year: a, month: r, day: n, hour: o, minute: s, second: l } = sr(t, e);
return lr(a, r, n, o, s, l, 0) - Math.floor(t / 1e3) * 1e3;
}
const Oa = /* @__PURE__ */ new Map();
function sr(t, e) {
let a = Oa.get(e);
a || (a = new Intl.DateTimeFormat("en-US", {
timeZone: e,
hour12: !1,
era: "short",
year: "numeric",
month: "numeric",
day: "numeric",
hour: "numeric",
minute: "numeric",
second: "numeric"
}), Oa.set(e, a));
let r = a.formatToParts(new Date(t)), n = {};
for (let o of r) o.type !== "literal" && (n[o.type] = o.value);
return {
// Firefox returns B instead of BC... https://bugzilla.mozilla.org/show_bug.cgi?id=1752253
year: n.era === "BC" || n.era === "B" ? -n.year + 1 : +n.year,
month: +n.month,
day: +n.day,
hour: n.hour === "24" ? 0 : +n.hour,
minute: +n.minute,
second: +n.second
};
}
const Va = 864e5;
function Tn(t, e, a, r) {
return (a === r ? [
a
] : [
a,
r
]).filter((o) => Cn(t, e, o));
}
function Cn(t, e, a) {
let r = sr(a, e);
return t.year === r.year && t.month === r.month && t.day === r.day && t.hour === r.hour && t.minute === r.minute && t.second === r.second;
}
function Pe(t, e, a = "compatible") {
let r = at(t);
if (e === "UTC") return tt(r);
if (e === ma() && a === "compatible") {
r = Se(r, new xe());
let u = /* @__PURE__ */ new Date(), i = gt(r.era, r.year);
return u.setFullYear(i, r.month - 1, r.day), u.setHours(r.hour, r.minute, r.second, r.millisecond), u.getTime();
}
let n = tt(r), o = Xt(n - Va, e), s = Xt(n + Va, e), l = Tn(r, e, n - o, n - s);
if (l.length === 1) return l[0];
if (l.length > 1) switch (a) {
// 'compatible' means 'earlier' for "fall back" transitions
case "compatible":
case "earlier":
return l[0];
case "later":
return l[l.length - 1];
case "reject":
throw new RangeError("Multiple possible absolute times found");
}
switch (a) {
case "earlier":
return Math.min(n - o, n - s);
// 'compatible' means 'later' for "spring forward" transitions
case "compatible":
case "later":
return Math.max(n - o, n - s);
case "reject":
throw new RangeError("No such absolute time found");
}
}
function ir(t, e, a = "compatible") {
return new Date(Pe(t, e, a));
}
function Le(t, e) {
let a = Xt(t, e), r = new Date(t + a), n = r.getUTCFullYear(), o = r.getUTCMonth() + 1, s = r.getUTCDate(), l = r.getUTCHours(), u = r.getUTCMinutes(), i = r.getUTCSeconds(), f = r.getUTCMilliseconds();
return new vt(n < 1 ? "BC" : "AD", n < 1 ? -n + 1 : n, o, s, e, a, l, u, i, f);
}
function Yn(t) {
return new le(t.calendar, t.era, t.year, t.month, t.day);
}
function at(t, e) {
let a = 0, r = 0, n = 0, o = 0;
if ("timeZone" in t) ({ hour: a, minute: r, second: n, millisecond: o } = t);
else if ("hour" in t && !e) return t;
return e && ({ hour: a, minute: r, second: n, millisecond: o } = e), new rt(t.calendar, t.era, t.year, t.month, t.day, a, r, n, o);
}
function Se(t, e) {
if ($n(t.calendar, e)) return t;
let a = e.fromJulianDay(t.calendar.toJulianDay(t)), r = t.copy();
return r.calendar = e, r.era = a.era, r.year = a.year, r.month = a.month, r.day = a.day, je(r), r;
}
function Rn(t, e, a) {
if (t instanceof vt)
return t.timeZone === e ? t : In(t, e);
let r = Pe(t, e, a);
return Le(r, e);
}
function En(t) {
let e = tt(t) - t.offset;
return new Date(e);
}
function In(t, e) {
let a = tt(t) - t.offset;
return Se(Le(a, e), t.calendar);
}
const lt = 36e5;
function Ut(t, e) {
let a = t.copy(), r = "hour" in a ? Pn(a, e) : 0;
_t(a, e.years || 0), a.calendar.balanceYearMonth && a.calendar.balanceYearMonth(a, t), a.month += e.months || 0, ea(a), ur(a), a.day += (e.weeks || 0) * 7, a.day += e.days || 0, a.day += r, On(a), a.calendar.balanceDate && a.calendar.balanceDate(a), a.year < 1 && (a.year = 1, a.month = 1, a.day = 1);
let n = a.calendar.getYearsInEra(a);
if (a.year > n) {
var o, s;
let u = (o = (s = a.calendar).isInverseEra) === null || o === void 0 ? void 0 : o.call(s, a);
a.year = n, a.month = u ? 1 : a.calendar.getMonthsInYear(a), a.day = u ? 1 : a.calendar.getDaysInMonth(a);
}
a.month < 1 && (a.month = 1, a.day = 1);
let l = a.calendar.getMonthsInYear(a);
return a.month > l && (a.month = l, a.day = a.calendar.getDaysInMonth(a)), a.day = Math.max(1, Math.min(a.calendar.getDaysInMonth(a), a.day)), a;
}
function _t(t, e) {
var a, r;
!((a = (r = t.calendar).isInverseEra) === null || a === void 0) && a.call(r, t) && (e = -e), t.year += e;
}
function ea(t) {
for (; t.month < 1; )
_t(t, -1), t.month += t.calendar.getMonthsInYear(t);
let e = 0;
for (; t.month > (e = t.calendar.getMonthsInYear(t)); )
t.month -= e, _t(t, 1);
}
function On(t) {
for (; t.day < 1; )
t.month--, ea(t), t.day += t.calendar.getDaysInMonth(t);
for (; t.day > t.calendar.getDaysInMonth(t); )
t.day -= t.calendar.getDaysInMonth(t), t.month++, ea(t);
}
function ur(t) {
t.month = Math.max(1, Math.min(t.calendar.getMonthsInYear(t), t.month)), t.day = Math.max(1, Math.min(t.calendar.getDaysInMonth(t), t.day));
}
function je(t) {
t.calendar.constrainDate && t.calendar.constrainDate(t), t.year = Math.max(1, Math.min(t.calendar.getYearsInEra(t), t.year)), ur(t);
}
function cr(t) {
let e = {};
for (let a in t) typeof t[a] == "number" && (e[a] = -t[a]);
return e;
}
function dr(t, e) {
return Ut(t, cr(e));
}
function ha(t, e) {
let a = t.copy();
return e.era != null && (a.era = e.era), e.year != null && (a.year = e.year), e.month != null && (a.month = e.month), e.day != null && (a.day = e.day), je(a), a;
}
function It(t, e) {
let a = t.copy();
return e.hour != null && (a.hour = e.hour), e.minute != null && (a.minute = e.minute), e.second != null && (a.second = e.second), e.millisecond != null && (a.millisecond = e.millisecond), Fn(a), a;
}
function Vn(t) {
t.second += Math.floor(t.millisecond / 1e3), t.millisecond = $t(t.millisecond, 1e3), t.minute += Math.floor(t.second / 60), t.second = $t(t.second, 60), t.hour += Math.floor(t.minute / 60), t.minute = $t(t.minute, 60);
let e = Math.floor(t.hour / 24);
return t.hour = $t(t.hour, 24), e;
}
function Fn(t) {
t.millisecond = Math.max(0, Math.min(t.millisecond, 1e3)), t.second = Math.max(0, Math.min(t.second, 59)), t.minute = Math.max(0, Math.min(t.minute, 59)), t.hour = Math.max(0, Math.min(t.hour, 23));
}
function $t(t, e) {
let a = t % e;
return a < 0 && (a += e), a;
}
function Pn(t, e) {
return t.hour += e.hours || 0, t.minute += e.minutes || 0, t.second += e.seconds || 0, t.millisecond += e.milliseconds || 0, Vn(t);
}
function va(t, e, a, r) {
let n = t.copy();
switch (e) {
case "era": {
let l = t.calendar.getEras(), u = l.indexOf(t.era);
if (u < 0) throw new Error("Invalid era: " + t.era);
u = He(u, a, 0, l.length - 1, r?.round), n.era = l[u], je(n);
break;
}
case "year":
var o, s;
!((o = (s = n.calendar).isInverseEra) === null || o === void 0) && o.call(s, n) && (a = -a), n.year = He(t.year, a, -1 / 0, 9999, r?.round), n.year === -1 / 0 && (n.year = 1), n.calendar.balanceYearMonth && n.calendar.balanceYearMonth(n, t);
break;
case "month":
n.month = He(t.month, a, 1, t.calendar.getMonthsInYear(t), r?.round);
break;
case "day":
n.day = He(t.day, a, 1, t.calendar.getDaysInMonth(t), r?.round);
break;
default:
throw new Error("Unsupported field " + e);
}
return t.calendar.balanceDate && t.calendar.balanceDate(n), je(n), n;
}
function fr(t, e, a, r) {
let n = t.copy();
switch (e) {
case "hour": {
let o = t.hour, s = 0, l = 23;
if (r?.hourCycle === 12) {
let u = o >= 12;
s = u ? 12 : 0, l = u ? 23 : 11;
}
n.hour = He(o, a, s, l, r?.round);
break;
}
case "minute":
n.minute = He(t.minute, a, 0, 59, r?.round);
break;
case "second":
n.second = He(t.second, a, 0, 59, r?.round);
break;
case "millisecond":
n.millisecond = He(t.millisecond, a, 0, 999, r?.round);
break;
default:
throw new Error("Unsupported field " + e);
}
return n;
}
function He(t, e, a, r, n = !1) {
if (n) {
t += Math.sign(e), t < a && (t = r);
let o = Math.abs(e);
e > 0 ? t = Math.ceil(t / o) * o : t = Math.floor(t / o) * o, t > r && (t = a);
} else
t += e, t < a ? t = r - (a - t - 1) : t > r && (t = a + (t - r - 1));
return t;
}
function mr(t, e) {
let a;
if (e.years != null && e.years !== 0 || e.months != null && e.months !== 0 || e.weeks != null && e.weeks !== 0 || e.days != null && e.days !== 0) {
let n = Ut(at(t), {
years: e.years,
months: e.months,
weeks: e.weeks,
days: e.days
});
a = Pe(n, t.timeZone);
} else
a = tt(t) - t.offset;
a += e.milliseconds || 0, a += (e.seconds || 0) * 1e3, a += (e.minutes || 0) * 6e4, a += (e.hours || 0) * 36e5;
let r = Le(a, t.timeZone);
return Se(r, t.calendar);
}
function An(t, e) {
return mr(t, cr(e));
}
function Ln(t, e, a, r) {
switch (e) {
case "hour": {
let n = 0, o = 23;
if (r?.hourCycle === 12) {
let S = t.hour >= 12;
n = S ? 12 : 0, o = S ? 23 : 11;
}
let s = at(t), l = Se(It(s, {
hour: n
}), new xe()), u = [
Pe(l, t.timeZone, "earlier"),
Pe(l, t.timeZone, "later")
].filter((S) => Le(S, t.timeZone).day === l.day)[0], i = Se(It(s, {
hour: o
}), new xe()), f = [
Pe(i, t.timeZone, "earlier"),
Pe(i, t.timeZone, "later")
].filter((S) => Le(S, t.timeZone).day === i.day).pop(), y = tt(t) - t.offset, m = Math.floor(y / lt), k = y % lt;
return y = He(m, a, Math.floor(u / lt), Math.floor(f / lt), r?.round) * lt + k, Se(Le(y, t.timeZone), t.calendar);
}
case "minute":
case "second":
case "millisecond":
return fr(t, e, a, r);
case "era":
case "year":
case "month":
case "day": {
let n = va(at(t), e, a, r), o = Pe(n, t.timeZone);
return Se(Le(o, t.timeZone), t.calendar);
}
default:
throw new Error("Unsupported field " + e);
}
}
function Hn(t, e, a) {
let r = at(t), n = It(ha(r, e), e);
if (n.compare(r) === 0) return t;
let o = Pe(n, t.timeZone, a);
return Se(Le(o, t.timeZone), t.calendar);
}
function Bn(t) {
return `${String(t.hour).padStart(2, "0")}:${String(t.minute).padStart(2, "0")}:${String(t.second).padStart(2, "0")}${t.millisecond ? String(t.millisecond / 1e3).slice(1) : ""}`;
}
function hr(t) {
let e = Se(t, new xe()), a;
return e.era === "BC" ? a = e.year === 1 ? "0000" : "-" + String(Math.abs(1 - e.year)).padStart(6, "00") : a = String(e.year).padStart(4, "0"), `${a}-${String(e.month).padStart(2, "0")}-${String(e.day).padStart(2, "0")}`;
}
function vr(t) {
return `${hr(t)}T${Bn(t)}`;
}
function qn(t) {
let e = Math.sign(t) < 0 ? "-" : "+";
t = Math.abs(t);
let a = Math.floor(t / 36e5), r = Math.floor(t % 36e5 / 6e4), n = Math.floor(t % 36e5 % 6e4 / 1e3), o = `${e}${String(a).padStart(2, "0")}:${String(r).padStart(2, "0")}`;
return n !== 0 && (o += `:${String(n).padStart(2, "0")}`), o;
}
function Nn(t) {
return `${vr(t)}${qn(t.offset)}[${t.timeZone}]`;
}
function Un(t, e) {
if (e.has(t))
throw new TypeError("Cannot initialize the same private elements twice on an object");
}
function ya(t, e, a) {
Un(t, e), e.set(t, a);
}
function ga(t) {
let e = typeof t[0] == "object" ? t.shift() : new xe(), a;
if (typeof t[0] == "string") a = t.shift();
else {
let s = e.getEras();
a = s[s.length - 1];
}
let r = t.shift(), n = t.shift(), o = t.shift();
return [
e,
a,
r,
n,
o
];
}
var zn = /* @__PURE__ */ new WeakMap();
class le {
/** Returns a copy of this date. */
copy() {
return this.era ? new le(this.calendar, this.era, this.year, this.month, this.day) : new le(this.calendar, this.year, this.month, this.day);
}
/** Returns a new `CalendarDate` with the given duration added to it. */
add(e) {
return Ut(this, e);
}
/** Returns a new `CalendarDate` with the given duration subtracted from it. */
subtract(e) {
return dr(this, e);
}
/** Returns a new `CalendarDate` with the given fields set to the provided values. Other fields will be constrained accordingly. */
set(e) {
return ha(this, e);
}
/**
* Returns a new `CalendarDate` with the given field adjusted by a specified amount.
* When the resulting value reaches the limits of the field, it wraps around.
*/
cycle(e, a, r) {
return va(this, e, a, r);
}
/** Converts the date to a native JavaScript Date object, with the time set to midnight in the given time zone. */
toDate(e) {
return ir(this, e);
}
/** Converts the date to an ISO 8601 formatted string. */
toString() {
return hr(this);
}
/** Compares this date with another. A negative result indicates that this date is before the given one, and a positive date indicates that it is after. */
compare(e) {
return or(this, e);
}
constructor(...e) {
ya(this, zn, {
writable: !0,
value: void 0
});
let [a, r, n, o, s] = ga(e);
this.calendar = a, this.era = r, this.year = n, this.month = o, this.day = s, je(this);
}
}
var Wn = /* @__PURE__ */ new WeakMap();
class rt {
/** Returns a copy of this date. */
copy() {
return this.era ? new rt(this.calendar, this.era, this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond) : new rt(this.calendar, this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond);
}
/** Returns a new `CalendarDateTime` with the given duration added to it. */
add(e) {
return Ut(this, e);
}
/** Returns a new `CalendarDateTime` with the given duration subtracted from it. */
subtract(e) {
return dr(this, e);
}
/** Returns a new `CalendarDateTime` with the given fields set to the provided values. Other fields will be constrained accordingly. */
set(e) {
return ha(It(this, e), e);
}
/**
* Returns a new `CalendarDateTime` with the given field adjusted by a specified amount.
* When the resulting value reaches the limits of the field, it wraps around.
*/
cycle(e, a, r) {
switch (e) {
case "era":
case "year":
case "month":
case "day":
return va(this, e, a, r);
default:
return fr(this, e, a, r);
}
}
/** Converts the date to a native JavaScript Date object in the given time zone. */
toDate(e, a) {
return ir(this, e, a);
}
/** Converts the date to an ISO 8601 formatted string. */
toString() {
return vr(this);
}
/** Compares this date with another. A negative result indicates that this date is before the given one, and a positive date indicates that it is after. */
compare(e) {
let a = or(this, e);
return a === 0 ? Mn(this, at(e)) : a;
}
constructor(...e) {
ya(this, Wn, {
writable: !0,
value: void 0
});
let [a, r, n, o, s] = ga(e);
this.calendar = a, this.era = r, this.year = n, this.month = o, this.day = s, this.hour = e.shift() || 0, this.minute = e.shift() || 0, this.second = e.shift() || 0, this.millisecond = e.shift() || 0, je(this);
}
}
var jn = /* @__PURE__ */ new WeakMap();
class vt {
/** Returns a copy of this date. */
copy() {
return this.era ? new vt(this.calendar, this.era, this.year, this.month, this.day, this.timeZone, this.offset, this.hour, this.minute, this.second, this.millisecond) : new vt(this.calendar, this.year, this.month, this.day, this.timeZone, this.offset, this.hour, this.minute, this.second, this.millisecond);
}
/** Returns a new `ZonedDateTime` with the given duration added to it. */
add(e) {
return mr(this, e);
}
/** Returns a new `ZonedDateTime` with the given duration subtracted from it. */
subtract(e) {
return An(this, e);
}
/** Returns a new `ZonedDateTime` with the given fields set to the provided values. Other fields will be constrained accordingly. */
set(e, a) {
return Hn(this, e, a);
}
/**
* Returns a new `ZonedDateTime` with the given field adjusted by a specified amount.
* When the resulting value reaches the limits of the field, it wraps around.
*/
cycle(e, a, r) {
return Ln(this, e, a, r);
}
/** Converts the date to a native JavaScript Date object. */
toDate() {
return En(this);
}
/** Converts the date to an ISO 8601 formatted string, including the UTC offset and time zone identifier. */
toString() {
return Nn(this);
}
/** Converts the date to an ISO 8601 formatted string in UTC. */
toAbsoluteString() {
return this.toDate().toISOString();
}
/** Compares this date with another. A negative result indicates that this date is before the given one, and a positive date indicates that it is after. */
compare(e) {
return this.toDate().getTime() - Rn(e, this.timeZone).toDate().getTime();
}
constructor(...e) {
ya(this, jn, {
writable: !0,
value: void 0
});
let [a, r, n, o, s] = ga(e), l = e.shift(), u = e.shift();
this.calendar = a, this.era = r, this.year = n, this.month = o, this.day = s, this.timeZone = l, this.offset = u, this.hour = e.shift() || 0, this.minute = e.shift() || 0, this.second = e.shift() || 0, this.millisecond = e.shift() || 0, je(this);
}
}
const Ze = [
[
1868,
9,
8
],
[
1912,
7,
30
],
[
1926,
12,
25
],
[
1989,
1,
8
],
[
2019,
5,
1
]
], Jn = [
[
1912,
7,
29
],
[
1926,
12,
24
],
[
1989,
1,
7
],
[
2019,
4,
30
]
], Yt = [
1867,
1911,
1925,
1988,
2018
], Be = [
"meiji",
"taisho",
"showa",
"heisei",
"reiwa"
];
function Fa(t) {
const e = Ze.findIndex(([a, r, n]) => t.year < a || t.year === a && t.month < r || t.year === a && t.month === r && t.day < n);
return e === -1 ? Ze.length - 1 : e === 0 ? 0 : e - 1;
}
function Jt(t) {
let e = Yt[Be.indexOf(t.era)];
if (!e) throw new Error("Unknown era: " + t.era);
return new le(t.year + e, t.month, t.day);
}
class Kn extends xe {
fromJulianDay(e) {
let a = super.fromJulianDay(e), r = Fa(a);
return new le(this, Be[r], a.year - Yt[r], a.month, a.day);
}
toJulianDay(e) {
return super.toJulianDay(Jt(e));
}
balanceDate(e) {
let a = Jt(e), r = Fa(a);
Be[r] !== e.era && (e.era = Be[r], e.year = a.year - Yt[r]), this.constrainDate(e);
}
constrainDate(e) {
let a = Be.indexOf(e.era), r = Jn[a];
if (r != null) {
let [n, o, s] = r, l = n - Yt[a];
e.year = Math.max(1, Math.min(l, e.year)), e.year === l && (e.month = Math.min(o, e.month), e.month === o && (e.day = Math.min(s, e.day)));
}
if (e.year === 1 && a >= 0) {
let [, n, o] = Ze[a];
e.month = Math.max(n, e.month), e.month === n && (e.day = Math.max(o, e.day));
}
}
getEras() {
return Be;
}
getYearsInEra(e) {
let a = Be.indexOf(e.era), r = Ze[a], n = Ze[a + 1];
if (n == null)
return 9999 - r[0] + 1;
let o = n[0] - r[0];
return (e.month < n[1] || e.month === n[1] && e.day < n[2]) && o++, o;
}
getDaysInMonth(e) {
return super.getDaysInMonth(Jt(e));
}
getMinimumMonthInYear(e) {
let a = Pa(e);
return a ? a[1] : 1;
}
getMinimumDayInMonth(e) {
let a = Pa(e);
return a && e.month === a[1] ? a[2] : 1;
}
constructor(...e) {
super(...e), this.identifier = "japanese";
}
}
function Pa(t) {
if (t.year === 1) {
let e = Be.indexOf(t.era);
return Ze[e];
}
}
const yr = -543;
class Qn extends xe {
fromJulianDay(e) {
let a = super.fromJulianDay(e), r = gt(a.era, a.year);
return new le(this, r - yr, a.month, a.day);
}
toJulianDay(e) {
return super.toJulianDay(Aa(e));
}
getEras() {
return [
"BE"
];
}
getDaysInMonth(e) {
return super.getDaysInMonth(Aa(e));
}
balanceDate() {
}
constructor(...e) {
super(...e), this.identifier = "buddhist";
}
}
function Aa(t) {
let [e, a] = Nt(t.year + yr);
return new le(e, a, t.month, t.day);
}
const Ot = 1911;
function gr(t) {
return t.era === "minguo" ? t.year + Ot : 1 - t.year + Ot;
}
function La(t) {
let e = t - Ot;
return e > 0 ? [
"minguo",
e
] : [
"before_minguo",
1 - e
];
}
class Zn extends xe {
fromJulianDay(e) {
let a = super.fromJulianDay(e), r = gt(a.era, a.year), [n, o] = La(r);
return new le(this, n, o, a.month, a.day);
}
toJulianDay(e) {
return super.toJulianDay(Ha(e));
}
getEras() {
return [
"before_minguo",
"minguo"
];
}
balanceDate(e) {
let [a, r] = La(gr(e));
e.era = a, e.year = r;
}
isInverseEra(e) {
return e.era === "before_minguo";
}
getDaysInMonth(e) {
return super.getDaysInMonth(Ha(e));
}
getYearsInEra(e) {
return e.era === "before_minguo" ? 9999 : 9999 - Ot;
}
constructor(...e) {
super(...e), this.identifier = "roc";
}
}
function Ha(t) {
let [e, a] = Nt(gr(t));
return new le(e, a, t.month, t.day);
}
const Ba = 1948320, qa = [
0,
31,
62,
93,
124,
155,
186,
216,
246,
276,
306,
336
// Esfand
];
class Gn {
fromJulianDay(e) {
let a = e - Ba, r = 1 + Math.floor((33 * a + 3) / 12053), n = 365 * (r - 1) + Math.floor((8 * r + 21) / 33), o = a - n, s = o < 216 ? Math.floor(o / 31) : Math.floor((o - 6) / 30), l = o - qa[s] + 1;
return new le(this, r, s + 1, l);
}
toJulianDay(e) {
let a = Ba - 1 + 365 * (e.year - 1) + Math.floor((8 * e.year + 21) / 33);
return a += qa[e.month - 1], a += e.day, a;
}
getMonthsInYear() {
return 12;
}
getDaysInMonth(e) {
return e.month <= 6 ? 31 : e.month <= 11 || Qe(25 * e.year + 11, 33) < 8 ? 30 : 29;
}
getEras() {
return [
"AP"
];
}
getYearsInEra() {
return 9377;
}
constructor() {
this.identifier = "persian";
}
}
const Kt = 78, Na = 80;
class Xn extends xe {
fromJulianDay(e) {
let a = super.fromJulianDay(e), r = a.year - Kt, n = e - ze(a.era, a.year, 1, 1), o;
n < Na ? (r--, o = qe(a.year - 1) ? 31 : 30, n += o + 155 + 90 + 10) : (o = qe(a.year) ? 31 : 30, n -= Na);
let s, l;
if (n < o)
s = 1, l = n + 1;
else {
let u = n - o;
u < 155 ? (s = Math.floor(u / 31) + 2, l = u % 31 + 1) : (u -= 155, s = Math.floor(u / 30) + 7, l = u % 30 + 1);
}
return new le(this, r, s, l);
}
toJulianDay(e) {
let a = e.year + Kt, [r, n] = Nt(a), o, s;
return qe(n) ? (o = 31, s = ze(r, n, 3, 21)) : (o = 30, s = ze(r, n, 3, 22)), e.month === 1 ? s + e.day - 1 : (s += o + Math.min(e.month - 2, 5) * 31, e.month >= 8 && (s += (e.month - 7) * 30), s += e.day - 1, s);
}
getDaysInMonth(e) {
return e.month === 1 && qe(e.year + Kt) || e.month >= 2 && e.month <= 6 ? 31 : 30;
}
getYearsInEra() {
return 9919;
}
getEras() {
return [
"saka"
];
}
balanceDate() {
}
constructor(...e) {
super(...e), this.identifier = "indian";
}
}
const Vt = 1948440, Ua = 1948439, Ce = 1300, Je = 1600, _n = 460322;
function Ft(t, e, a, r) {
return r + Math.ceil(29.5 * (a - 1)) + (e - 1) * 354 + Math.floor((3 + 11 * e) / 30) + t - 1;
}
function pr(t, e, a) {
let r = Math.floor((30 * (a - e) + 10646) / 10631), n = Math.min(12, Math.ceil((a - (29 + Ft(e, r, 1, 1))) / 29.5) + 1), o = a - Ft(e, r, n, 1) + 1;
return new le(t, r, n, o);
}
function za(t) {
return (14 + 11 * t) % 30 < 11;
}
class pa {
fromJulianDay(e) {
return pr(this, Vt, e);
}
toJulianDay(e) {
return Ft(Vt, e.year, e.month, e.day);
}
getDaysInMonth(e) {
let a = 29 + e.month % 2;
return e.month === 12 && za(e.year) && a++, a;
}
getMonthsInYear() {
return 12;
}
getDaysInYear(e) {
return za(e.year) ? 355 : 354;
}
getYearsInEra() {
return 9665;
}
getEras() {
return [
"AH"
];
}
constructor() {
this.identifier = "islamic-civil";
}
}
class eo extends pa {
fromJulianDay(e) {
return pr(this, Ua, e);
}
toJulianDay(e) {
return Ft(Ua, e.year, e.month, e.day);
}
constructor(...e) {
super(...e), this.identifier = "islamic-tbla";
}
}
const to = "qgpUDckO1AbqBmwDrQpVBakGkgepC9QF2gpcBS0NlQZKB1QLagutBa4ETwoXBYsGpQbVCtYCWwmdBE0KJg2VDawFtgm6AlsKKwWVCsoG6Qr0AnYJtgJWCcoKpAvSC9kF3AJtCU0FpQpSC6ULtAW2CVcFlwJLBaMGUgdlC2oFqworBZUMSg2lDcoF1gpXCasESwmlClILagt1BXYCtwhbBFUFqQW0BdoJ3QRuAjYJqgpUDbIN1QXaAlsJqwRVCkkLZAtxC7QFtQpVCiUNkg7JDtQG6QprCasEkwpJDaQNsg25CroEWworBZUKKgtVC1wFvQQ9Ah0JlQpKC1oLbQW2AjsJmwRVBqkGVAdqC2wFrQpVBSkLkgupC9QF2gpaBasKlQVJB2QHqgu1BbYCVgpNDiULUgtqC60FrgIvCZcESwalBqwG1gpdBZ0ETQoWDZUNqgW1BdoCWwmtBJUFygbkBuoK9QS2AlYJqgpUC9IL2QXqAm0JrQSVCkoLpQuyBbUJ1gSXCkcFkwZJB1ULagVrCisFiwpGDaMNygXWCtsEawJLCaUKUgtpC3UFdgG3CFsCKwVlBbQF2gntBG0BtgimClINqQ3UBdoKWwmrBFMGKQdiB6kLsgW1ClUFJQuSDckO0gbpCmsFqwRVCikNVA2qDbUJugQ7CpsETQqqCtUK2gJdCV4ELgqaDFUNsga5BroEXQotBZUKUguoC7QLuQXaAloJSgukDdEO6AZqC20FNQWVBkoNqA3UDdoGWwWdAisGFQtKC5ULqgWuCi4JjwwnBZUGqgbWCl0FnQI=";
let ta, Ge;
function Rt(t) {
return _n + Ge[t - Ce];
}
function ut(t, e) {
let a = t - Ce, r = 1 << 11 - (e - 1);
return (ta[a] & r) === 0 ? 29 : 30;
}
function Wa(t, e) {
let a = Rt(t);
for (let r = 1; r < e; r++) a += ut(t, r);
return a;
}
function ja(t) {
return Ge[t + 1 - Ce] - Ge[t - Ce];
}
class ao extends pa {
fromJulianDay(e) {
let a = e - Vt, r = Rt(Ce), n = Rt(Je);
if (a < r || a > n) return super.fromJulianDay(e);
{
let o = Ce - 1, s = 1, l = 1;
for (; l > 0; ) {
o++, l = a - Rt(o) + 1;
let u = ja(o);
if (l === u) {
s = 12;
break;
} else if (l < u) {
let i = ut(o, s);
for (s = 1; l > i; )
l -= i, s++, i = ut(o, s);
break;
}
}
return new le(this, o, s, a - Wa(o, s) + 1);
}
}
toJulianDay(e) {
return e.year < Ce || e.year > Je ? super.toJulianDay(e) : Vt + Wa(e.year, e.month) + (e.day - 1);
}
getDaysInMonth(e) {
return e.year < Ce || e.year > Je ? super.getDaysInMonth(e) : ut(e.year, e.month);
}
getDaysInYear(e) {
return e.year < Ce || e.year > Je ? super.getDaysInYear(e) : ja(e.year);
}
constructor() {
if (super(), this.identifier = "islamic-umalqura", ta || (ta = new Uint16Array(Uint8Array.from(atob(to), (e) => e.charCodeAt(0)).buffer)), !Ge) {
Ge = new Uint32Array(Je - Ce + 1);
let e = 0;
for (let a = Ce; a <= Je; a++) {
Ge[a - Ce] = e;
for (let r = 1; r <= 12; r++) e += ut(a, r);
}
}
}
}
const Ja = 347997, $r = 1080, Dr = 24 * $r, ro = 29, no = 12 * $r + 793, oo = ro * Dr + no;
function Ue(t) {
return Qe(t * 7 + 1, 19) < 7;
}
function Et(t) {
let e = Math.floor((235 * t - 234) / 19), a = 12084 + 13753 * e, r = e * 29 + Math.floor(a / 25920);
return Qe(3 * (r + 1), 7) < 3 && (r += 1), r;
}
function lo(t) {
let e = Et(t - 1), a = Et(t);
return Et(t + 1) - a === 356 ? 2 : a - e === 382 ? 1 : 0;
}
function ct(t) {
return Et(t) + lo(t);
}
function br(t) {
return ct(t + 1) - ct(t);
}
function so(t) {
let e = br(t);
switch (e > 380 && (e -= 30), e) {
case 353:
return 0;
// deficient
case 354:
return 1;
// normal
case 355:
return 2;
}
}
function Dt(t, e) {
if (e >= 6 && !Ue(t) && e++, e === 4 || e === 7 || e === 9 || e === 11 || e === 13) return 29;
let a = so(t);
return e === 2 ? a === 2 ? 30 : 29 : e === 3 ? a === 0 ? 29 : 30 : e === 6 ? Ue(t) ? 30 : 0 : 30;
}
class io {
fromJulianDay(e) {
let a = e - Ja, r = a * Dr / oo, n = Math.floor((19 * r + 234) / 235) + 1, o = ct(n), s = Math.floor(a - o);
for (; s < 1; )
n--, o = ct(n), s = Math.floor(a - o);
let l = 1, u = 0;
for (; u < s; )
u += Dt(n, l), l++;
l--, u -= Dt(n, l);
let i = s - u;
return new le(this, n, l, i);
}
toJulianDay(e) {
let a = ct(e.year);
for (let r = 1; r < e.month; r++) a += Dt(e.year, r);
return a + e.day + Ja;
}
getDaysInMonth(e) {
return Dt(e.year, e.month);
}
getMonthsInYear(e) {
return Ue(e.year) ? 13 : 12;
}
getDaysInYear(e) {
return br(e.year);
}
getYearsInEra() {
return 9999;
}
getEras() {
return [
"AM"
];
}
balanceYearMonth(e, a) {
a.year !== e.year && (Ue(a.year) && !Ue(e.year) && a.month > 6 ? e.month-- : !Ue(a.year) && Ue(e.year) && a.month > 6 && e.month++);
}
constructor() {
this.identifier = "hebrew";
}
}
const aa = 1723856, Ka = 1824665, ra = 5500;
function Pt(t, e, a, r) {
return t + 365 * e + Math.floor(e / 4) + 30 * (a - 1) + r - 1;
}
function $a(t, e) {
let a = Math.floor(4 * (e - t) / 1461), r = 1 + Math.floor((e - Pt(t, a, 1, 1)) / 30), n = e + 1 - Pt(t, a, r, 1);
return [
a,
r,
n
];
}
function Mr(t) {
return Math.floor(t % 4 / 3);
}
function wr(t, e) {
return e % 13 !== 0 ? 30 : Mr(t) + 5;
}
class Da {
fromJulianDay(e) {
let [a, r, n] = $a(aa, e), o = "AM";
return a <= 0 && (o = "AA", a += ra), new le(this, o, a, r, n);
}
toJulianDay(e) {
let a = e.year;
return e.era === "AA" && (a -= ra), Pt(aa, a, e.month, e.day);
}
getDaysInMonth(e) {
return wr(e.year, e.month);
}
getMonthsInYear() {
return 13;
}
getDaysInYear(e) {
return 365 + Mr(e.year);
}
getYearsInEra(e) {
return e.era === "AA" ? 9999 : 9991;
}
getEras() {
return [
"AA",
"AM"
];
}
constructor() {
this.identifier = "ethiopic";
}
}
class uo extends Da {
fromJulianDay(e) {
let [a, r, n] = $a(aa, e);
return a += ra, new le(this, "AA", a, r, n);
}
getEras() {
return [
"AA"
];
}
getYearsInEra() {
return 9999;
}
constructor(...e) {
super(...e), this.identifier = "ethioaa";
}
}
class co extends Da {
fromJulianDay(e) {
let [a, r, n] = $a(Ka, e), o = "CE";
return a <= 0 && (o = "BCE", a = 1 - a), new le(this, o, a, r, n);
}
toJulianDay(e) {
let a = e.year;
return e.era === "BCE" && (a = 1 - a), Pt(Ka, a, e.month, e.day);
}
getDaysInMonth(e) {
let a = e.year;
return e.era === "BCE" && (a = 1 - a), wr(a, e.month);
}
isInverseEra(e) {
return e.era === "BCE";
}
balanceDate(e) {
e.year <= 0 && (e.era = e.era === "BCE" ? "CE" : "BCE", e.year = 1 - e.year);
}
getEras() {
return [
"BCE",
"CE"
];
}
getYearsInEra(e) {
return e.era === "BCE" ? 9999 : 9715;
}
constructor(...e) {
super(...e), this.identifier = "coptic";
}
}
function fo(t) {
switch (t) {
case "buddhist":
return new Qn();
case "ethiopic":
return new Da();
case "ethioaa":
return new uo();
case "coptic":
return new co();
case "hebrew":
return new io();
case "indian":
return new Xn();
case "islamic-civil":
return new pa();
case "islamic-tbla":
return new eo();
case "islamic-umalqura":
return new ao();
case "japanese":
return new Kn();
case "persian":
return new Gn();
case "roc":
return new Zn();
case "gregory":
default:
return new xe();
}
}
let Qt = /* @__PURE__ */ new Map();
class At {
/** Formats a date as a string according to the locale and format options passed to the constructor. */
format(e) {
return this.formatter.format(e);
}
/** Formats a date to an array of parts such as separators, numbers, punctuation, and more. */
formatToParts(e) {
return this.formatter.formatToParts(e);
}
/** Formats a date range as a string. */
formatRange(e, a) {
if (typeof this.formatter.formatRange == "function")
return this.formatter.formatRange(e, a);
if (a < e) throw new RangeError("End date must be >= start date");
return `${this.formatter.format(e)} – ${this.formatter.format(a)}`;
}
/** Formats a date range as an array of parts. */
formatRangeToParts(e, a) {
if (typeof this.formatter.formatRangeToParts == "function")
return this.formatter.formatRangeToParts(e, a);
if (a < e) throw new RangeError("End date must be >= start date");
let r = this.formatter.formatToParts(e), n = this.formatter.formatToParts(a);
return [
...r.map((o) => ({
...o,
source: "startRange"
})),
{
type: "literal",
value: " – ",
source: "shared"
},
...n.map((o) => ({
...o,
source: "endRange"
}))
];
}
/** Returns the resolved formatting options based on the values passed to the constructor. */
resolvedOptions() {
let e = this.formatter.resolvedOptions();
return vo() && (this.resolvedHourCycle || (this.resolvedHourCycle = yo(e.locale, this.options)), e.hourCycle = this.resolvedHourCycle, e.hour12 = this.resolvedHourCycle === "h11" || this.resolvedHourCycle === "h12"), e.calendar === "ethiopic-amete-alem" && (e.calendar = "ethioaa"), e;
}
constructor(e, a = {}) {
this.formatter = Sr(e, a), this.options = a;
}
}
const mo = {
true: {
// Only Japanese uses the h11 style for 12 hour time. All others use h12.
ja: "h11"
},
false: {}
};
function Sr(t, e = {}) {
if (typeof e.hour12 == "boolean" && ho()) {
e = {
...e
};
let n = mo[String(e.hour12)][t.split("-")[0]], o = e.hour12 ? "h12" : "h23";
e.hourCycle = n ?? o, delete e.hour12;
}
let a = t + (e ? Object.entries(e).sort((n, o) => n[0] < o[0] ? -1 : 1).join() : "");
if (Qt.has(a)) return Qt.get(a);
let r = new Intl.DateTimeFormat(t, e);
return Qt.set(a, r), r;
}
let Zt = null;
function ho() {
return Zt == null && (Zt = new Intl.DateTimeFormat("en-US", {
hour: "numeric",
hour12: !1
}).format(new Date(2020, 2, 3, 0)) === "24"), Zt;
}
let Gt = null;
function vo() {
return Gt == null && (Gt = new Intl.DateTimeFormat("fr", {
hour: "numeric",
hour12: !1
}).resolvedOptions().hourCycle === "h12"), Gt;
}
function yo(t, e) {
if (!e.timeStyle && !e.hour) return;
t = t.replace(/(-u-)?-nu-[a-zA-Z0-9]+/, ""), t += (t.includes("-u-") ? "" : "-u") + "-nu-latn";
let a = Sr(t, {
...e,
timeZone: void 0
// use local timezone
}), r = parseInt(a.formatToParts(new Date(2020, 2, 3, 0)).find((o) => o.type === "hour").value, 10), n = parseInt(a.formatToParts(new Date(2020, 2, 3, 23)).find((o) => o.type === "hour").value, 10);
if (r === 0 && n === 23) return "h23";
if (r === 24 && n === 23) return "h24";
if (r === 0 && n === 11) return "h11";
if (r === 12 && n === 11) return "h12";
throw new Error("Unexpected hour cycle result");
}
ue.extend(Xr);
ue.extend(an);
ue.extend(ar);
ue.extend(cn);
ue.extend(hn);
function Xe() {
const t = /* @__PURE__ */ new Date();
return {
year: t.getFullYear(),
month: t.getMonth() + 1,
day: t.getDate()
};
}
function go(t) {
try {
const e = ma(), a = bn(e);
if (t.calendar.identifier !== a.calendar.identifier) {
const r = Se(a, t.calendar);
return t.compare(r) === 0;
}
return t.compare(a) === 0;
} catch (e) {
return console.error("Error checking if date is today:", e), !1;
}
}
function Ke() {
const t = /* @__PURE__ */ new Date();
return {
year: t.getFullYear(),
month: t.getMonth() + 1,
day: t.getDate(),
hour: t.getHours(),
minute: t.getMinutes(),
second: t.getSeconds()
};
}
function Ae(t, e, a, r, n, o) {
const s = { year: t, month: e, day: a };
return r !== void 0 && (s.hour = r), n !== void 0 && (s.minute = n), o !== void 0 && (s.second = o), s;
}
function he(t, e = "zh-TW", a = "gregory") {
if (!t) return null;
try {
if (Mo(t))
return t;
if (t instanceof Date && !isNaN(t.getTime()))
return {
year: t.getFullYear(),
month: t.getMonth() + 1,
day: t.getDate(),
hour: t.getHours(),
minute: t.getMinutes(),
second: t.getSeconds()
};
if (typeof t == "string") {
const r = yn(t, e, a);
return r.success ? r.date : null;
}
return null;
} catch (r) {
return console.error("Failed to parse date:", r), null;
}
}
function ke(t, e = "YYYY-MM-DD") {
if (!t) return null;
try {
return ue("2000-01-01 00:00:00").year(t.year).month(t.month - 1).date(t.day).hour(t.hour || 0).minute(t.minute || 0).second(t.second || 0).format(e);
} catch (a) {
return console.error("Failed to format date:", a), null;
}
}
function Lt(t, e = "iso", a = "YYYY-MM-DD", r, n = !1, o = "gregory", s = "zh-TW", l = !1, u = !0) {
if (!t) return null;
try {
switch (e) {
case "iso":
if (n) {
let i;
return u ? i = l ? "YYYY-MM-DDTHH:mm:ss" : "YYYY-MM-DD HH:mm:ss" : i = l ? "YYYY-MM-DDTHH:mm" : "YYYY-MM-DD HH:mm", ke(t, i);
} else
return ke(t, "YYYY-MM-DD");
case "date":
return new Date(
t.year,
t.month - 1,
t.day,
t.hour || 0,
t.minute || 0,
t.second || 0
);
case "object":
return t;
case "custom":
return me.formatOutput(t, a, r, n, o, s);
default:
return console.warn(`不支援的輸出類型: ${e},回退到 ISO 格式`), ke(t, "YYYY-MM-DD");
}
} catch (i) {
return console.error("formatOutput 失敗:", i), t;
}
}
function Ht(t, e) {
const a = t.year * 1e4 + t.month * 100 + t.day, r = e.year * 1e4 + e.month * 100 + e.day;
return a < r ? -1 : a > r ? 1 : 0;
}
function na(t, e) {
const a = new Date(t.year, t.month - 1, t.day);
return a.setDate(a.getDate() + e), {
year: a.getFullYear(),
month: a.getMonth() + 1,
day: a.getDate(),
hour: t.hour,
minute: t.minute,
second: t.second
};
}
function Qa(t, e) {
const a = new Date(t.year, t.month - 1, t.day).getTime(), r = new Date(e.year, e.month - 1, e.day).getTime();
return Math.ceil((r - a) / (1e3 * 60 * 60 * 24));
}
function po() {
const t = Ke(), e = Ae(t.year, t.month, 1, 0, 0, 0), a = t.month === 12 ? 1 : t.month + 1, r = t.month === 12 ? t.year + 1 : t.year, n = Ae(r, a, 1), o = na(n, -1);
return { start: e, end: o };
}
function $o(t, e) {
if (!t || typeof t != "string")
return !1;
try {
const a = kr(t);
let r = !0;
if (e && (r = oa(e)), !a)
return console.warn(`日期格式語義驗證失敗: "${t}"`), !1;
if (e && !r)
return console.warn(`時間格式語義驗證失敗: "${e}"`), !1;
const n = ue("2000-12-31 23:59:59");
let o = !1;
try {
const i = n.format(t);
o = i !== t && i.length > 0;
} catch (i) {
console.warn(`日期格式 dayjs 驗證失敗: "${t}"`, i), o = !1;
}
let s = !0;
if (e)
try {
const i = n.format(e);
s = i !== e && i.length > 0;
} catch (i) {
console.warn(`時間格式 dayjs 驗證失敗: "${e}"`, i), s = !1;
}
let l = !0;
if (e)
try {
const i = `${t} ${e}`, f = n.format(i);
l = f !== i && f.length > 0;
} catch (i) {
console.warn(`組合格式 dayjs 驗證失敗: "${t} ${e}"`, i), l = !1;
}
return o && s && l;
} catch (a) {
return console.error("格式驗證時發生錯誤:", a), !1;
}
}
function kr(t) {
const e = ["YYYY", "YY", "MM", "M", "DD", "D"], a = ["-", "/", ".", " "];
let r = t;
a.forEach((m) => {
r = r.replace(new RegExp(`\\${m}`, "g"), " ");
});
const n = r.split(/\s+/).filter(Boolean);
if (!n.every((m) => e.includes(m))) return !1;
const s = n.some((m) => m === "YYYY" || m === "YY"), l = n.some((m) => m === "MM" || m === "M"), u = n.some((m) => m === "DD" || m === "D"), i = n.filter((m) => m === "YYYY" || m === "YY").length, f = n.filter((m) => m === "MM" || m === "M").length, y = n.filter((m) => m === "DD" || m === "D").length;
return i > 1 || f > 1 || y > 1 ? !1 : s && l && u;
}
function oa(t) {
if (!t || typeof t != "string")
return !1;
const e = [
"HH",
"H",
// 24 小時制
"hh",
"h",
// 12 小時制
"mm",
"m",
// 分鐘
"ss",
"s",
// 秒
"A",
"a"
// AM/PM
], r = t.replace(/[^\w]/g, " ").split(/\s+/).filter(Boolean);
if (!r.every((f) => e.includes(f)))
return !1;
const o = r.some((f) => ["HH", "H"].includes(f)), s = r.some((f) => ["hh", "h"].includes(f)), l = r.some((f) => ["mm", "m"].includes(f));
if (r.some((f) => ["A", "a"].includes(f)), !(o || s) || !l || s && o)
return !1;
const i = e.reduce((f, y) => (f[y] = r.filter((m) => m === y).length, f), {});
return !Object.values(i).some((f) => f > 1);
}
function Do(t) {
return t.replace(/yyyy/g, "YYYY").replace(/yy/g, "YY").replace(/mm/g, "MM").replace(/dd/g, "DD");
}
function bo(t) {
let e = t;
return e = e.replace(/HH/g, "HH").replace(/hh/g, "hh").replace(/MM/g, "mm").replace(/SS/g, "ss").replace(/aa/g, "a").replace(/AA/g, "A"), e;
}
function Mo(t) {
return !t || typeof t != "object" ? !1 : typeof t.year == "number" && typeof t.month == "number" && typeof t.day == "number";
}
class xr {
id = "roc";
yearRange = {
min: 1,
// 民國1年 (1912年)
max: 200
// 民國200年 (2111年)
};
displayName = {
"zh-TW": "民國曆",
"zh-CN": "民国历",
"en-US": "ROC Calendar",
"ja-JP": "中華民国暦",
"ko-KR": "중화민국력"
};
YEAR_OFFSET = 1911;
parseInput(e, a) {
if (!e || typeof e != "string") return null;
const n = e.trim().replace(/^(民國|民国|ROC\s*)/i, "").trim();
if (/[上下]午|時|分|秒|\d{1,2}:\d{2}/.test(n))
return this.parseDateTime(n);
{
if (/\d+年\d+月\d+日/.test(n))
return this.parseDatePart(n);
const s = n.replace(/[年月日時分秒]/g, ""), l = ["-", "/", ".", " "];
for (const u of l) {
const i = this.tryParseWithSeparator(s, u);
if (i) return i;
}
}
return null;
}
/**
* 解析包含日期和時間的字串
*/
parseDateTime(e) {
const a = e.match(/^(\d+年\d+月\d+日)\s*(.*)$/);
if (!a) return null;
const [, r, n] = a;
if (!r) return null;
const o = this.parseDatePart(r);
if (!o) return null;
if (!n) return o;
const s = this.parseTimePart(n);
return s ? {
...o,
...s
} : o;
}
/**
* 解析日期部分 (如: "114年06月18日")
* 統一轉換為公元曆
*/
parseDatePart(e) {
const a = e.match(/(\d+)年(\d+)月(\d+)日/);
if (!a) return null;
const [, r, n, o] = a, s = parseInt(r || "0"), l = parseInt(n || "0"), u = parseInt(o || "0");
return this.validateAndConvertRocDate(s, l, u);
}
/**
* 解析時間部分 (如: "上午 12時00分")
*/
parseTimePart(e) {
if (!e) return null;
const a = e.trim(), r = a.match(/(上午|下午)\s*(\d{1,2})時(\d{2})分(?:(\d{2})秒)?/);
if (r) {
const [, o, s, l, u] = r;
let i = parseInt(s || "0");
const f = parseInt(l || "0"), y = u ? parseInt(u) : 0;
return o === "下午" && i !== 12 ? i += 12 : o === "上午" && i === 12 && (i = 0), i < 0 || i > 23 || f < 0 || f > 59 || y < 0 || y > 59 ? null : { hour: i, minute: f, second: y };
}
const n = a.match(/(\d{1,2}):(\d{2})(?::(\d{2}))?/);
if (n) {
const [, o, s, l] = n, u = parseInt(o || "0"), i = parseInt(s || "0"), f = l ? parseInt(l) : 0;
return u < 0 || u > 23 || i < 0 || i > 59 || f < 0 || f > 59 ? null : { hour: u, minute: i, second: f };
}
return null;
}
canParseInput(e) {
return /^(民國|民国|ROC\s*)/i.test(e.trim());
}
/**
* 使用指定分隔符解析
*/
tryParseWithSeparator(e, a) {
const r = e.split(a).map((l) => l.trim()).filter(Boolean);
if (r.length < 3) return null;
const n = parseInt(r[0] || "0"), o = parseInt(r[1] || "0"), s = parseInt(r[2] || "0");
return this.validateAndConvertRocDate(n, o, s);
}
/**
* 通用的 ROC 日期驗證和轉換方法
*/
validateAndConvertRocDate(e, a, r) {
if (isNaN(e) || isNaN(a) || isNaN(r) || e < this.yearRange.min || e > this.yearRange.max) return null;
const n = e + this.YEAR_OFFSET;
if (a < 1 || a > 12 || r < 1 || r > 31) return null;
const o = `${n}-${a.toString().padStart(2, "0")}-${r.toString().padStart(2, "0")}`, s = ue(o, "YYYY-MM-DD", !0);
return !s.isValid() || s.year() !== n || s.month() + 1 !== a || s.date() !== r ? null : {
year: n,
month: a,
day: r
};
}
/**
* 檢查是否支援特定格式
*/
supportsFormat(e) {
return e.includes("ROC-") || e.includes("民國");
}
/**
* 自定義格式化 - 專注於民國年的特殊格式
*/
format(e, a, r) {
if (!this.supportsFormat(a))
throw new Error(`RocFormatPlugin 不支援格式: ${a}`);
const n = e.hour !== void 0 && e.hour !== null, o = a.split(" "), s = o[0] || a, l = o.slice(1).join(" "), u = this.formatDatePart(e, s, r);
if (l && n) {
const i = this.detectTimeFormat(l), f = this.formatTimePart(e, l, i);
return `${u} ${f}`;
}
return u;
}
/**
* 透過格式字串偵測時間制式
*/
detectTimeFormat(e) {
return !e.includes("A") && !e.includes("a") && !e.includes("hh");
}
/**
* 格式化日期部分
*/
formatDatePart(e, a, r) {
const n = e.year - this.YEAR_OFFSET, o = e.month, s = e.day, l = {
"ROC-YYYY": `民國${n}年`,
"ROC-YYYY-MM-DD": `民國${n}年${o.toString().padStart(2, "0")}月${s.toString().padStart(2, "0")}日`,
"ROC-YYYY/MM/DD": `民國${n}/${o.toString().padStart(2, "0")}/${s.toString().padStart(2, "0")}`,
"ROC-NUM-YYYY-MM-DD": `${n}-${o.toString().padStart(2, "0")}-${s.toString().padStart(2, "0")}`,
"ROC-NUM-YYYY/MM/DD": `${n}/${o.toString().padStart(2, "0")}/${s.toString().padStart(2, "0")}`
};
if (l[a])
return l[a];
const u = new Date(e.year, e.month - 1, e.day);
let i = ue(u).format(a);
if (a.includes("YYYY"))
i = i.replace(e.year.toString(), n.toString());
else if (a.includes("YY")) {
const f = e.year.toString().slice(-2), y = n.toString().slice(-2);
i = i.replace(f, y);
}
return i;
}
/**
* 格式化 ROC 時間
*/
formatTimePart(e, a, r) {
if (!e) return "";
const n = e.hour || 0, o = e.minute || 0, s = e.second || 0, l = this.getFormattedTime(n, o, s, a, r);
return l || this.fallbackToDateJs(e, a, r);
}
/**
* 統一的時間格式化處理
*/
getFormattedTime(e, a, r, n, o) {
if (o) {
const s = {
"HH:mm:ss": () => this.formatBasicTime(e, a, r, !0),
"HH:mm": () => this.formatBasicTime(e, a, 0, !1),
HH時mm分ss秒: () => this.formatChineseTime(e, a, r, !0),
HH時mm分: () => this.formatChineseTime(e, a, 0, !1)
};
if (s[n])
return s[n]();
} else {
const s = {
"hh:mm:ss A": () => this.format12HourTime(e, a, r, !0, "suffix"),
"hh:mm A": () => this.format12HourTime(e, a, 0, !1, "suffix"),
"h:mm A": () => this.format12HourTime(e, a, 0, !1, "suffix", !1),
"A hh:mm:ss": () => this.format12HourTime(e, a, r, !0, "prefix"),
"A hh:mm": () => this.format12HourTime(e, a, 0, !1, "prefix"),
"A HH時mm分ss秒": () => this.format12HourTime(e, a, r, !0, "chinese"),
"A HH時mm分": () => this.format12HourTime(e, a, 0, !1, "chinese")
};
if (s[n])
return s[n]();
}
return null;
}
/**
* 基本時間格式化(24小時制)
*/
formatBasicTime(e, a, r, n) {
const o = e.toString().padStart(2, "0"), s = a.toString().padStart(2, "0");
if (n) {
const l = r.toString().padStart(2, "0");
return `${o}:${s}:${l}`;
}
return `${o}:${s}`;
}
/**
* 中文時間格式化(24小時制)
*/
formatChineseTime(e, a, r, n) {
const o = e.toString().padStart(2, "0"), s = a.toString().padStart(2, "0");
if (n) {
const l = r.toString().padStart(2, "0");
return `${o}時${s}分${l}秒`;
}
return `${o}時${s}分`;
}
/**
* 12小時制時間格式化(統一處理)
*/
format12HourTime(e, a, r, n, o, s = !0) {
const l = e < 12 ? "上午" : "下午", u = e === 0 ? 12 : e > 12 ? e - 12 : e, i = s ? u.toString().padStart(2, "0") : u.toString(), f = a.toString().padStart(2, "0"), y = n ? r.toString().padStart(2, "0") : "";
switch (o) {
case "suffix":
return n ? `${i}:${f}:${y} ${l}` : `${i}:${f} ${l}`;
case "prefix":
return n ? `${l} ${i}:${f}:${y}` : `${l} ${i}:${f}`;
case "chinese":
return n ? `${l} ${i}時${f}分${y}秒` : `${l} ${i}時${f}分`;
default:
return "";
}
}
/**
* 回退到 dayjs 處理
*/
fallbackToDateJs(e, a, r) {
const n = new Date(
e.year,
e.month - 1,
e.day,
e.hour || 0,
e.minute || 0,
e.second || 0
);
if (!n || isNaN(n.getTime())) return "";
let o = ue(n).format(a);
return !r && (a.includes("A") || a.includes("a")) && (o = o.replace(/AM/g, "上午").replace(/PM/g, "下午"), o = o.replace(/am/g, "上午").replace(/pm/g, "下午")), o;
}
}
class me {
/**
* 安全地創建日曆實例
*/
static createSafeCalendar(e) {
try {
return fo(e);
} catch (a) {
return console.warn(`無法創建日曆 ${e},回退到西元曆:`, a), new xe();
}
}
/**
* 安全地進行日曆轉換
*/
static safeToCalendar(e, a) {
try {
return Se(e, a);
} catch (r) {
return console.warn("日曆轉換失敗,返回原始日期:", r), e;
}
}
/**
* 智能轉換:根據是否有時間資訊自動選擇類型
*/
static convertToCalendarDateSmart = (e, a) => e ? e.hour !== void 0 || e.minute !== void 0 || e.second !== void 0 ? this.convertToCalendarDateTime(e, a) : this.convertToCalendarDate(e, a) : null;
/**
* 統一的轉換函數:SimpleDateValue → CalendarDate
*/
static convertToCalendarDate = (e, a) => {
if (!e || e.year <= 0 || e.month <= 0 || e.day <= 0 || e.month > 12 || e.day > 31)
return null;
try {
if (a === "gregory")
return new le(e.year, e.month, e.day);
{
const r = this.createSafeCalendar(a), n = new le(e.year, e.month, e.day);
return this.safeToCalendar(n, r);
}
} catch (r) {
return console.error("轉換為 CalendarDate 失敗:", r), null;
}
};
/**
* 統一的轉換函數:SimpleDateValue → CalendarDateTime (日期+時間)
*/
static convertToCalendarDateTime = (e, a) => {
if (!e) return null;
try {
if (a === "gregory")
return new rt(
e.year,
e.month,
e.day,
e.hour || 0,
e.minute || 0,
e.second || 0
);
{
const r = this.createSafeCalendar(a), n = new rt(
e.year,
e.month,
e.day,
e.hour || 0,
e.minute || 0,
e.second || 0
);
return Se(n, r);
}
} catch (r) {
return console.error("轉換為 CalendarDateTime 失敗:", r), null;
}
};
/**
* 統一的轉換函數:CalendarDate → SimpleDateValue
*/
static convertFromCalendarDate = (e, a) => {
if (!e) return null;
try {
if (e.calendar.identifier === "gregory" || a === "gregory")
return {
year: e.year,
month: e.month,
day: e.day
};
{
const r = this.createSafeCalendar("gregory"), n = this.safeToCalendar(e, r);
return {
year: n.year,
month: n.month,
day: n.day
};
}
} catch (r) {
return console.error("轉換從 CalendarDate 失敗:", r), null;
}
};
/**
* 安全地生成日曆網格
*/
static generateCalendarDays(e, a, r, n, o = 0) {
try {
if (!this.isCalendarSupported(r))
return console.warn(`不支持的日曆系統: ${r}`), [];
const s = this.createSafeCalendar(r), l = new le(e, a, 1), u = r === "gregory" ? l : this.safeToCalendar(l, s), i = xn(u, n) ?? 6, y = (nr(u, n) - o + 7) % 7, m = u.subtract({ days: y }), k = [];
let S = m;
const d = i * 7;
for (let h = 0; h < d; h++)
k.push(S), S = S.add({ days: 1 });
return k;
} catch (s) {
return console.error("生成日曆網格失敗:", s), [];
}
}
/**
* 獲取日曆系統的有效年份範圍 (新版本)
*/
static getCalendarRange(e) {
const a = (/* @__PURE__ */ new Date()).getFullYear();
return {
gregory: { min: 1, max: a + 100 },
japanese: { min: 1868, max: a + 100 },
roc: { min: 1912, max: a + 100 },
buddhist: { min: 544, max: a + 643 },
islamic: { min: 622, max: a + 100 },
persian: { min: 622, max: a + 100 },
hebrew: { min: 1, max: a + 3860 }
}[e] || { min: 1, max: a + 100 };
}
/**
* 轉換西元年到目標日曆系統年份
*/
static convertGregorianYear(e, a) {
if (a === "gregory")
return { localYear: e, isValid: !0 };
try {
const r = new le(e, 1, 1), n = this.createSafeCalendar(a), o = this.safeToCalendar(r, n), s = this.getCalendarRange(a), l = e >= s.min && e <= s.max;
return { localYear: o.year, isValid: l };
} catch (r) {
return console.warn(`年份轉換失敗 ${e} -> ${a}:`, r), { localYear: e, isValid: !1 };
}
}
/**
* 轉換目標日曆年份到西元年
*/
static convertToGregorianYear(e, a) {
if (a === "gregory")
return e;
try {
const r = this.createSafeCalendar(a), n = new le(r, e, 1, 1);
return this.safeToCalendar(n, new xe()).year;
} catch (r) {
return console.warn(`年份轉換失敗 ${e} ${a} -> Gregory:`, r), e;
}
}
/**
* 獲取月份名稱
*/
static getMonthNames(e, a = "gregory") {
try {
const r = new Intl.DateTimeFormat(e, { month: "short" });
return Array.from({ length: 12 }, (n, o) => {
const s = new Date(2e3, o, 1);
return r.format(s);
});
} catch (r) {
return console.warn(`獲取月份名稱失敗 ${a}:`, r), e.startsWith("zh") ? Array.from({ length: 12 }, (n, o) => `${o + 1}月`) : e.startsWith("ja") ? Array.from({ length: 12 }, (n, o) => `${o + 1}月`) : [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
];
}
}
/**
* 獲取日曆系統的顯示名稱
*/
static getCalendarDisplayName(e, a = "zh-TW") {
const r = {
gregory: {
"zh-TW": "西元",
"zh-CN": "西元",
"en-US": "Gregorian",
"ja-JP": "西暦",
"ko-KR": "서력"
},
roc: {
"zh-TW": "民國",
"zh-CN": "民国",
"en-US": "ROC",
"ja-JP": "中華民国",
"ko-KR": "중화민국"
},
buddhist: {
"zh-TW": "佛曆",
"zh-CN": "佛历",
"en-US": "Buddhist",
"ja-JP": "仏暦",
"ko-KR": "불력"
},
japanese: {
"zh-TW": "和曆",
"zh-CN": "和历",
"en-US": "Japanese",
"ja-JP": "和暦",
"ko-KR": "일본력"
},
islamic: {
"zh-TW": "伊斯蘭曆",
"zh-CN": "伊斯兰历",
"en-US": "Islamic",
"ja-JP": "イスラム暦",
"ko-KR": "이슬람력"
},
persian: {
"zh-TW": "波斯曆",
"zh-CN": "波斯历",
"en-US": "Persian",
"ja-JP": "ペルシア暦",
"ko-KR": "페르시아력"
},
hebrew: {
"zh-TW": "希伯來曆",
"zh-CN": "希伯来历",
"en-US": "Hebrew",
"ja-JP": "ヘブライ暦",
"ko-KR": "히브리력"
}
};
return r[e]?.[a] || r[e]?.["en-US"] || e;
}
// ==================================================================== //
/**
* 驗證日期在指定日曆系統中是否有效
*/
static isValidDate(e, a, r, n) {
try {
if (!this.isCalendarSupported(n))
return console.warn(`不支持的日曆系統: ${n}`), !1;
if (e <= 0 || a <= 0 || r <= 0 || a > 12 || r > 31)
return !1;
let o;
if (n === "gregory")
o = new le(e, a, r);
else {
const l = this.createSafeCalendar(n);
o = new le(l, e, a, r);
}
return o.year === e && o.month === a && o.day === r;
} catch (o) {
return console.warn(`日期驗證失敗 ${e}-${a}-${r} in ${n}:`, o), !1;
}
}
/**
* 解析輸入字串為 SimpleDateValue
* 解析含日曆系統的格式,如民國XX年XX月XX日 XX時XX分XX秒
* 執行順序:插件翻譯 → @internationalized/date → dayjs → 回退
* 使用 dateParsingUtils.parseUserDateInput
*/
// static parseInput(input: string, calendar: string = 'gregory', locale: string = 'zh-TW'): SimpleDateValue | null {
// if (!input) return null;
// const result = parseUserDateInput(input, locale, calendar);
// console.log(`解析輸入 "${input}" 為 ${calendar} 日曆系統:`, result);
// if (result.success && result.date) {
// // 如果是非西元曆且解析結果是西元日期,需要進行轉換
// if (calendar !== 'gregory' && result.calendarSystem === 'gregory') {
// // 將西元日期轉換為目標日曆系統的日期
// const gregorianDate = new CalendarDate(result.date.year, result.date.month, result.date.day);
// const targetCalendar = this.createSafeCalendar(calendar);
// const localDate = this.safeToCalendar(gregorianDate, targetCalendar);
// console.log(`轉換日期 ${result.date.year}-${result.date.month}-${result.date.day} 從西元曆到 ${calendar} 成功:`, localDate);
// return {
// year: localDate.year,
// month: localDate.month,
// day: localDate.day
// };
// }
// return result.date;
// }
// return null;
// }
static isCalendarSupported(e) {
return [
"gregory",
"buddhist",
"ethiopic",
"ethioaa",
"coptic",
"hebrew",
"indian",
"islamic-civil",
"islamic-tbla",
"islamic-umalqura",
"japanese",
"persian",
"roc"
].includes(e);
}
/**
* 格式化輸出 - 統一執行順序:插件 → @internationalized/date → dayjs → 基本回退
* 格式化含日曆系統的格式,如民國XX年XX月XX日 XX時XX分XX秒
*/
static formatOutput(e, a = "YYYY-MM-DD", r, n = !1, o = "gregory", s = "zh-TW") {
if (!e) return "";
let l;
if (n && r)
l = `${a} ${r}`;
else if (n) {
const u = e.hour !== void 0 || e.minute !== void 0 || e.second !== void 0;
l = `${a} HH:mm:ss`;
} else
l = a;
try {
switch (o) {
case "gregory":
$o(a, r) || (l = e.hour !== void 0 || e.minute !== void 0 || e.second !== void 0 ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD");
const f = new Date(
e.year,
e.month - 1,
e.day,
e.hour || 0,
e.minute || 0,
e.second || 0
);
return ue(f).format(l);
case "roc":
const y = new xr();
if (y.supportsFormat(l) && y.canParseInput(l))
return y.format(e, l, s);
break;
// 其他日曆插件可以在這裡添加
case "buddhist":
case "japanese":
case "islamic":
case "persian":
case "hebrew":
break;
}
const u = this.convertToCalendarDateSmart(e, o);
if (u) {
const f = e.hour !== void 0 || e.minute !== void 0 || e.second !== void 0, y = {
calendar: o,
year: "numeric",
month: "long",
day: "numeric"
};
return f && (y.hour = "numeric", y.minute = "numeric", e.second !== void 0 && (y.second = "numeric")), new At(s, y).format(u.toDate(Intl.DateTimeFormat().resolvedOptions().timeZone));
}
const i = new Date(
e.year,
e.month - 1,
e.day,
e.hour || 0,
e.minute || 0,
e.second || 0
);
return ue(i).format(l);
} catch (u) {
console.warn("所有格式化方法都失敗,使用基本回退:", u);
let i = `${e.year}-${e.month.toString().padStart(2, "0")}-${e.day.toString().padStart(2, "0")}`;
return (e.hour !== void 0 || e.minute !== void 0 || e.second !== void 0) && (i += ` ${(e.hour || 0).toString().padStart(2, "0")}:${(e.minute || 0).toString().padStart(2, "0")}`, e.second !== void 0 && (i += `:${e.second.toString().padStart(2, "0")}`)), i;
}
}
}
const {
// 轉換核心
convertToCalendarDate: Ws,
convertFromCalendarDate: js,
// 日曆基礎
createSafeCalendar: Js,
safeToCalendar: Ks,
generateCalendarDays: Qs,
// 年份轉換 (YearSelector)
convertGregorianYear: Zs,
convertToGregorianYear: Gs,
getCalendarRange: Xs,
// getCalendarYearRange,
// 顯示相關
getMonthNames: _s,
getCalendarDisplayName: ei,
// 日曆系統輸出輸入轉換
// isValidDate,
// parseInput,
isCalendarSupported: ti,
formatOutput: ai
} = me, _e = (t) => /^\d+$/.test(t), Za = (t) => t % 4 === 0 && t % 100 !== 0 || t % 400 === 0;
let Oe = null;
function wo() {
return Oe || (Oe = document.createElement("span"), Oe.style.visibility = "hidden", Oe.style.position = "absolute", Oe.style.top = "-9999px", Oe.style.left = "-9999px", Oe.style.whiteSpace = "pre", document.body.appendChild(Oe)), Oe;
}
const la = /* @__PURE__ */ new WeakMap();
function So(t, e = "") {
const a = wo(), r = getComputedStyle(t);
return a.style.font = r.font, a.style.fontSize = r.fontSize, a.style.fontWeight = r.fontWeight, a.style.letterSpacing = r.letterSpacing, a.style.padding = r.padding, a.style.border = r.border, a.style.boxSizing = r.boxSizing, a.textContent = t.value || e || "", a.offsetWidth + 4;
}
function st(t) {
const e = t.placeholder || "", a = So(t, e), r = la.get(t) || 0;
t.style.width = `${Math.max(a, r)}px`;
}
const et = {
// 初始設置
mounted(t, e) {
e.value && typeof e.value == "number" && la.set(t, e.value), st(t), t.addEventListener("input", () => st(t)), document.fonts && document.fonts.ready && document.fonts.ready.then(() => st(t));
},
// 處理更新
updated(t, e) {
e.value && typeof e.value == "number" && e.oldValue !== e.value && la.set(t, e.value), st(t);
},
// 為 Vue 3 添加 beforeUnmount
beforeUnmount(t) {
t.removeEventListener("input", () => st(t));
}
}, ko = { class: "date-input-container flex items-center justify-start" }, xo = ["placeholder", "aria-invalid", "aria-errormessage", "id", "disabled"], To = ["placeholder", "aria-invalid", "aria-errormessage", "id", "disabled"], Co = ["placeholder", "aria-invalid", "aria-errormessage", "id", "disabled"], Yo = {
key: 3,
class: "text-gray-400"
}, Ro = /* @__PURE__ */ Te({
__name: "DateInput",
props: {
modelValue: { default: null },
yearPlaceholder: { default: "" },
monthPlaceholder: { default: "" },
dayPlaceholder: { default: "" },
minDate: { default: null },
maxDate: { default: null },
required: { type: Boolean, default: !0 },
separator: { default: "-" },
dateFormat: { default: "YYYY-MM-DD" },
inputId: { default: void 0 },
disabled: { type: Boolean, default: !1 }
},
emits: ["update:modelValue", "validation", "complete"],
setup(t, { expose: e, emit: a }) {
const r = {
mounted: et.mounted,
updated: et.updated,
beforeUnmount: et.beforeUnmount
}, n = t, o = a, s = z(""), l = z(""), u = z(""), i = z({}), f = z({}), y = z(null), m = z(!1), k = z(!1), S = z(null), d = z(/* @__PURE__ */ new Map()), h = (E, C) => {
E && E instanceof HTMLInputElement ? d.value.set(C, E) : d.value.delete(C);
}, c = (E) => d.value.get(E), w = T(() => {
const E = {};
return Object.entries(i.value).forEach(([C, q]) => {
E[C] = q.key;
}), E;
}), x = T(() => Object.keys(i.value).length > 0), b = T(() => Object.values(w.value)), v = T(() => {
const E = n.dateFormat.toUpperCase(), C = [];
return E.split(/[^A-Z]+/).filter(Boolean).forEach((G) => {
G.includes("Y") ? C.push("year") : G.includes("M") ? C.push("month") : G.includes("D") && C.push("day");
}), C.length !== 3 ? (console.warn(`Invalid date format: ${n.dateFormat}, falling back to YYYY-MM-DD`), ["year", "month", "day"]) : C;
}), $ = T(() => {
if (!s.value || !l.value || !u.value)
return null;
const E = s.value.padStart(4, "0"), C = l.value.padStart(2, "0"), q = u.value.padStart(2, "0");
return `${E}-${C}-${q}`;
}), g = T(() => {
if (!$.value) return null;
const E = ue($.value);
return E.isValid() ? E.format(n.dateFormat) : null;
});
de(() => n.modelValue, (E) => {
if (m.value || (m.value = !0), E) {
const C = he(E);
C && (s.value = C.year.toString(), l.value = C.month.toString().padStart(2, "0"), u.value = C.day.toString().padStart(2, "0"));
} else
s.value = "", l.value = "", u.value = "";
E || (S.value = null, k.value = !1);
}, { immediate: !0 });
const p = () => {
if (v.value.length === 0) return;
const E = v.value[0], C = c(E);
if (C && typeof C.focus == "function")
try {
C.focus();
} catch (q) {
console.warn("無法聚焦到輸入框:", q);
}
else
for (const q of v.value) {
const G = c(q);
if (G && typeof G.focus == "function")
try {
G.focus();
break;
} catch (Y) {
console.warn("無法聚焦到輸入框:", Y);
}
}
}, D = (E) => {
const C = c(E);
if (C && typeof C.focus == "function")
try {
C.focus();
} catch (q) {
console.warn(`無法聚焦到 ${E} 輸入框:`, q);
}
}, F = (E, C) => {
const q = c(E);
if (q)
try {
if (typeof q.focus == "function" && q.focus(), typeof q.setSelectionRange == "function") {
const G = C === "end" ? q.value.length : 0;
q.setSelectionRange(G, G);
}
} catch (G) {
console.warn(`無法聚焦或設置游標位置到 ${E} 輸入框:`, G);
}
}, P = (E, C) => {
const q = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
return C === 2 ? Za(E) ? 29 : 28 : q[C] ?? 31;
}, J = (E, C) => {
if (!C) return { valid: !0 };
const q = parseInt(C);
switch (E) {
case "year":
if (C.length < 4) return { valid: !0 };
const G = n.maxDate ? ue(n.maxDate).year() : (/* @__PURE__ */ new Date()).getFullYear() + 50, Y = n.minDate ? ue(n.minDate).year() : 1;
if (!_e(C) || q < Y || q > G)
return { valid: !1, error: { key: "year.outOfRange", params: { min: Y, max: G } } };
if (l.value === "02" && u.value === "29" && !Za(q))
return { valid: !1, error: { key: "year.notLeapYear", params: { year: q } } };
break;
case "month":
if (!_e(C) || q < 1 || q > 12)
return { valid: !1, error: { key: "month.outOfRange" } };
if (u.value && s.value) {
const W = parseInt(s.value), ee = P(W, q);
if (parseInt(u.value) > ee)
return { valid: !1, error: { key: "day.notExistInMonth", params: { month: C, maxDays: ee } } };
}
break;
case "day":
if (!_e(C) || q < 1 || q > 31)
return { valid: !1, error: { key: "day.outOfRange" } };
if (s.value && l.value) {
const W = parseInt(s.value), ee = parseInt(l.value), fe = P(W, ee);
if (q > fe)
return ee === 2 && q === 29 ? { valid: !1, error: { key: "year.notLeapYear", params: { year: W } } } : { valid: !1, error: { key: "day.notExistInMonth", params: { month: l.value, maxDays: fe } } };
}
break;
}
return i.value[E] && (delete i.value[E], delete f.value[E]), { valid: !0 };
}, _ = () => {
if (!m.value) return;
i.value = {}, f.value = {};
const E = J("year", s.value), C = J("month", l.value), q = J("day", u.value);
if (!E.valid && E.error && (i.value.year = E.error, E.error.params && (f.value.year = E.error.params)), !C.valid && C.error && (i.value.month = C.error, C.error.params && (f.value.month = C.error.params)), !q.valid && q.error && (i.value.day = q.error, q.error.params && (f.value.day = q.error.params)), n.required && (s.value || (i.value.year = { key: "year.required" }), l.value || (i.value.month = { key: "month.required" }), u.value || (i.value.day = { key: "day.required" })), $.value && Object.keys(i.value).length === 0) {
const G = ue($.value);
if (!G.isValid())
i.value.day = { key: "day.invalid" };
else if (n.minDate && G.isBefore(ue(n.minDate)))
i.value.day = {
key: "date.beforeMin",
params: { minDate: ue(n.minDate).format(n.dateFormat) }
}, f.value.day = { minDate: ue(n.minDate).format(n.dateFormat) };
else if (n.maxDate && G.isAfter(ue(n.maxDate)))
i.value.day = {
key: "date.afterMax",
params: { maxDate: ue(n.maxDate).format(n.dateFormat) }
}, f.value.day = { maxDate: ue(n.maxDate).format(n.dateFormat) };
else if (g.value) {
o("update:modelValue", g.value);
const Y = g.value;
Y !== S.value && !k.value && (S.value = Y, o("complete", g.value));
}
} else m.value && !s.value && !l.value && !u.value && (o("update:modelValue", null), S.value = null);
o("validation", !x.value, w.value, f.value);
}, K = () => {
s.value = "", l.value = "", u.value = "", i.value = {};
}, Z = (E) => {
const C = v.value.findIndex((G) => G === E), q = C < v.value.length - 1 ? v.value[C + 1] : null;
q ? we(() => {
D(q);
}) : _();
}, O = (E, C, q, G) => {
const Y = C.replace(/\D/g, "");
if (Y.length === 1 && k.value && (k.value = !1), Y.length <= q) {
if (G && Y.length === 1 && parseInt(Y) > G) {
const W = Y.padStart(2, "0");
E === "year" ? s.value = W : E === "month" ? l.value = W : E === "day" && (u.value = W), Z(E);
} else
E === "year" ? s.value = Y : E === "month" ? l.value = Y : E === "day" && (u.value = Y);
Y.length === q && Z(E);
}
}, R = (E) => {
const C = E.target;
O("year", C.value, 4);
}, M = (E) => {
const C = E.target;
O("month", C.value, 2, 1);
}, H = (E) => {
const C = E.target;
O("day", C.value, 2, 3);
}, U = () => {
we(() => {
if (v.value.length === 0) return;
const E = v.value[v.value.length - 1], C = c(E);
if (C && typeof C.focus == "function")
try {
C.focus();
const q = C.value.length;
C.setSelectionRange(q, q);
} catch (q) {
console.warn("無法聚焦到最後一個輸入框:", q);
}
});
}, X = (E, C) => {
const q = E.target, G = v.value.findIndex((ee) => ee === C), Y = G > 0 ? v.value[G - 1] : null, W = G < v.value.length - 1 ? v.value[G + 1] : null;
E.key === "Backspace" && q.value === "" && Y && (E.preventDefault(), k.value = !0, F(Y, "end")), E.key === "ArrowLeft" && q.selectionStart === 0 && Y && (E.preventDefault(), k.value = !0, F(Y, "end")), E.key === "ArrowRight" && q.selectionStart === q.value.length && W && (E.preventDefault(), k.value = !0, F(W, "start")), E.key === "Enter" && _();
}, ie = (E) => {
y.value = E;
}, se = (E) => {
_(), y.value = null;
};
return e({
validate: _,
reset: () => {
K(), o("update:modelValue", null);
},
getErrors: () => ({ ...i.value }),
hasErrors: () => x.value,
errorMessages: () => b.value,
focus: p,
focusLast: U,
setDate: (E) => {
if (E) {
const C = he(E);
C && (s.value = C.year.toString(), l.value = C.month.toString().padStart(2, "0"), u.value = C.day.toString().padStart(2, "0"), _());
} else
K(), o("update:modelValue", null);
},
resetCompletionState: () => {
k.value = !1, S.value = null;
}
}), (E, C) => (A(), L("div", ko, [
(A(!0), L(pe, null, ge(v.value, (q, G) => (A(), L(pe, { key: q }, [
q === "year" ? Re((A(), L("input", {
key: 0,
ref_for: !0,
ref: (Y) => h(Y, "year"),
"onUpdate:modelValue": C[0] || (C[0] = (Y) => s.value = Y),
type: "text",
inputmode: "numeric",
placeholder: t.yearPlaceholder,
maxlength: 4,
class: "date-input text-sm text-center active:bg-vdt-theme-100",
onInput: R,
onKeydown: C[1] || (C[1] = (Y) => X(Y, "year")),
onFocus: C[2] || (C[2] = (Y) => ie("year")),
onBlur: C[3] || (C[3] = (Y) => se()),
"aria-label": "year",
"aria-invalid": !!w.value.year,
"aria-errormessage": w.value.year ? "year-error" : void 0,
id: G === 0 && t.inputId ? t.inputId : void 0,
disabled: t.disabled
}, null, 40, xo)), [
[We, s.value],
[r, 20]
]) : q === "month" ? Re((A(), L("input", {
key: 1,
ref_for: !0,
ref: (Y) => h(Y, "month"),
"onUpdate:modelValue": C[4] || (C[4] = (Y) => l.value = Y),
type: "text",
inputmode: "numeric",
placeholder: t.monthPlaceholder,
maxlength: 2,
class: "date-input text-sm text-center",
onInput: M,
onKeydown: C[5] || (C[5] = (Y) => X(Y, "month")),
onFocus: C[6] || (C[6] = (Y) => ie("month")),
onBlur: C[7] || (C[7] = (Y) => se()),
"aria-label": "month",
"aria-invalid": !!w.value.month,
"aria-errormessage": w.value.month ? "month-error" : void 0,
id: G === 0 && t.inputId ? t.inputId : void 0,
disabled: t.disabled
}, null, 40, To)), [
[We, l.value],
[r, 20]
]) : q === "day" ? Re((A(), L("input", {
key: 2,
ref_for: !0,
ref: (Y) => h(Y, "day"),
"onUpdate:modelValue": C[8] || (C[8] = (Y) => u.value = Y),
type: "text",
inputmode: "numeric",
placeholder: t.dayPlaceholder,
maxlength: 2,
class: "date-input text-sm text-center",
onInput: H,
onKeydown: C[9] || (C[9] = (Y) => X(Y, "day")),
onFocus: C[10] || (C[10] = (Y) => ie("day")),
onBlur: C[11] || (C[11] = (Y) => se()),
"aria-label": "day",
"aria-invalid": !!w.value.day,
"aria-errormessage": w.value.day ? "day-error" : void 0,
id: G === 0 && t.inputId ? t.inputId : void 0,
disabled: t.disabled
}, null, 40, Co)), [
[We, u.value],
[r, 20]
]) : oe("", !0),
G < v.value.length - 1 ? (A(), L("span", Yo, ne(t.separator), 1)) : oe("", !0)
], 64))), 128))
]));
}
}), Ne = (t, e) => {
const a = t.__vccOpts || t;
for (const [r, n] of e)
a[r] = n;
return a;
}, sa = /* @__PURE__ */ Ne(Ro, [["__scopeId", "data-v-28be7475"]]), Eo = { class: "time-input-container flex items-center justify-center" }, Io = ["placeholder", "aria-invalid", "aria-errormessage", "disabled"], Oo = ["placeholder", "aria-invalid", "aria-errormessage", "disabled"], Vo = ["placeholder", "aria-invalid", "aria-errormessage", "disabled"], Fo = /* @__PURE__ */ Te({
__name: "TimeInput",
props: {
modelValue: { default: null },
hourPlaceholder: { default: "HH" },
minutePlaceholder: { default: "MM" },
secondPlaceholder: { default: "SS" },
enableSeconds: { type: Boolean, default: !0 },
use24Hour: { type: Boolean, default: !0 },
required: { type: Boolean, default: !1 },
locale: { default: "zh-TW" },
useLocalizedPeriod: { type: Boolean, default: !1 },
minuteStep: { default: 1 },
disabled: { type: Boolean, default: !1 }
},
emits: ["update:modelValue", "validation", "complete", "navigate-to-date"],
setup(t, { expose: e, emit: a }) {
const r = {
mounted: et.mounted,
updated: et.updated,
beforeUnmount: et.beforeUnmount
}, n = t, o = a, s = z(""), l = z(""), u = z(""), i = z("AM"), f = z({}), y = z({}), m = z(null), k = z(!1), S = z(), d = z(), h = z(), c = T(() => Object.keys(f.value).length > 0), w = T(() => {
const O = {};
return Object.entries(f.value).forEach(([R, M]) => {
O[R] = M.key;
}), O;
}), x = () => {
s.value = "", l.value = "", u.value = "", i.value = "AM";
}, b = T(() => {
if (!n.useLocalizedPeriod) return i.value;
try {
const O = /* @__PURE__ */ new Date();
O.setHours(9, 0, 0);
const R = /* @__PURE__ */ new Date();
R.setHours(15, 0, 0);
const M = new Intl.DateTimeFormat(n.locale, {
hour: "numeric",
hour12: !0
}), H = M.formatToParts(O), U = M.formatToParts(R), X = H.find((se) => se.type === "dayPeriod")?.value || "AM", ie = U.find((se) => se.type === "dayPeriod")?.value || "PM";
return i.value === "AM" ? X : ie;
} catch (O) {
return console.error("Error getting localized period:", O), i.value;
}
}), v = T(() => b.value), $ = T(() => {
if (s.value === "" || l.value === "" || n.enableSeconds && u.value === "")
return null;
let O = parseInt(s.value, 10);
n.use24Hour || (i.value === "PM" && O < 12 ? O += 12 : i.value === "AM" && O === 12 && (O = 0));
const R = O.toString().padStart(2, "0"), M = l.value.padStart(2, "0");
if (n.enableSeconds) {
const H = u.value.padStart(2, "0");
return `${R}:${M}:${H}`;
} else
return `${R}:${M}`;
});
de(() => n.modelValue, (O) => {
if (k.value || (k.value = !0), O) {
const R = O.split(":");
let M = parseInt(R[0] || "0", 10);
const H = (R[1] || "").replace(/\D/g, ""), U = (R[2] || "").replace(/\D/g, "");
n.use24Hour || (M >= 12 ? (i.value = "PM", M = M === 12 ? 12 : M - 12) : (i.value = "AM", M = M === 0 ? 12 : M)), s.value = M.toString().padStart(2, "0"), l.value = H, n.enableSeconds && (u.value = U);
} else
x();
}, { immediate: !0 });
const g = (O, R) => {
if (!R) return { valid: !0 };
const M = parseInt(R);
switch (O) {
case "hour":
const H = n.use24Hour ? 23 : 12, U = n.use24Hour ? 0 : 1;
if (!_e(R) || M < U || M > H)
return { valid: !1, error: { key: "time.hourOutOfRange", params: { min: U, max: H } } };
break;
case "minute":
if (!_e(R) || M < 0 || M > 59)
return { valid: !1, error: { key: "time.minuteOutOfRange", params: { min: 0, max: 59 } } };
if (n.minuteStep > 1 && M % n.minuteStep !== 0)
return { valid: !1, error: { key: "time.minuteStepInvalid", params: { step: n.minuteStep } } };
break;
case "second":
if (!_e(R) || M < 0 || M > 59)
return { valid: !1, error: { key: "time.secondOutOfRange", params: { min: 0, max: 59 } } };
break;
}
return f.value[O] && (delete f.value[O], delete y.value[O]), { valid: !0 };
}, p = () => {
i.value = i.value === "AM" ? "PM" : "AM", D();
}, D = () => {
if (!k.value) return;
f.value = {}, y.value = {};
const O = g("hour", s.value), R = g("minute", l.value), M = n.enableSeconds ? g("second", u.value) : { valid: !0 };
!O.valid && O.error && (f.value.hour = O.error, O.error.params && (y.value.hour = O.error.params)), !R.valid && R.error && (f.value.minute = R.error, R.error.params && (y.value.minute = R.error.params)), !M.valid && M.error && (f.value.second = M.error, M.error.params && (y.value.second = M.error.params)), n.required && (s.value || (f.value.hour = { key: "time.hourRequired" }), l.value || (f.value.minute = { key: "time.minuteRequired" }), n.enableSeconds && !u.value && (f.value.second = { key: "time.secondRequired" })), o("validation", !c.value, w.value, y.value), $.value ? (o("update:modelValue", $.value), o("complete", $.value)) : k.value && o("update:modelValue", null);
}, F = (O) => {
const M = O.target.value.replace(/\D/g, "");
if (M.length <= 2) {
if (s.value = M, !g("hour", M).valid) return;
(M.length === 2 || n.use24Hour && parseInt(M) > 2 || !n.use24Hour && parseInt(M) > 1) && we(() => {
d.value?.focus();
});
}
}, P = (O) => {
const M = O.target.value.replace(/\D/g, "");
if (M.length <= 2) {
if (M.length === 1 && parseInt(M) > 5 ? (l.value = M.padStart(2, "0"), we(() => {
n.enableSeconds && h.value ? h.value.focus() : D();
})) : l.value = M, !g("minute", M).valid) return;
M.length === 2 && we(() => {
n.enableSeconds && h.value ? h.value.focus() : D();
});
}
}, J = (O) => {
const M = O.target.value.replace(/\D/g, "");
if (M.length <= 2) {
if (M.length === 1 && parseInt(M) > 5 ? (u.value = M.padStart(2, "0"), D()) : u.value = M, !g("second", M).valid) return;
M.length === 2 && D();
}
}, _ = (O, R) => {
const M = O.target;
if (O.key === "Backspace" && M.value === "")
switch (R) {
case "hour":
O.preventDefault(), o("navigate-to-date");
break;
case "minute":
O.preventDefault(), S.value?.focus(), S.value?.setSelectionRange(-1, -1);
break;
case "second":
O.preventDefault(), d.value?.focus(), d.value?.setSelectionRange(-1, -1);
break;
}
if (O.key === "ArrowLeft" && M.selectionStart === 0)
switch (R) {
case "hour":
O.preventDefault(), o("navigate-to-date");
break;
case "minute":
O.preventDefault(), S.value?.focus(), S.value?.setSelectionRange(-1, -1);
break;
case "second":
O.preventDefault(), d.value?.focus(), d.value?.setSelectionRange(-1, -1);
break;
}
if (O.key === "ArrowRight" && M.selectionStart === M.value.length)
switch (R) {
case "hour":
O.preventDefault(), d.value?.focus(), d.value?.setSelectionRange(0, 0);
break;
case "minute":
n.enableSeconds && (O.preventDefault(), h.value?.focus(), h.value?.setSelectionRange(0, 0));
break;
}
O.key === "Enter" && D();
}, K = (O) => {
m.value = O;
}, Z = (O) => {
m.value = null, D();
};
return e({
validate: D,
reset: () => {
x(), f.value = {}, y.value = {}, o("update:modelValue", null);
},
getErrors: () => w.value,
hasErrors: c,
setTime: (O) => {
if (O) {
const [R, M, H] = O.split(":");
let U = parseInt(R || "0");
n.use24Hour || (U >= 12 ? (i.value = "PM", U = U === 12 ? 12 : U - 12) : (i.value = "AM", U = U === 0 ? 12 : U)), s.value = U.toString().padStart(2, "0"), l.value = M || "", n.enableSeconds && H && (u.value = H || ""), D();
} else
x(), o("update:modelValue", null);
},
focus: () => {
S.value?.focus();
},
focusLast: () => {
n.enableSeconds && h.value ? (h.value.focus(), h.value.setSelectionRange(0, 0)) : d.value ? (d.value.focus(), d.value.setSelectionRange(0, 0)) : S.value && (S.value.focus(), S.value.setSelectionRange(0, 0));
}
}), (O, R) => (A(), L("div", Eo, [
Re(j("input", {
ref_key: "hourRef",
ref: S,
"onUpdate:modelValue": R[0] || (R[0] = (M) => s.value = M),
type: "text",
inputmode: "numeric",
placeholder: t.hourPlaceholder,
maxlength: 2,
class: "time-input text-sm text-center",
onInput: F,
onKeydown: R[1] || (R[1] = (M) => _(M, "hour")),
onFocus: R[2] || (R[2] = (M) => K("hour")),
onBlur: R[3] || (R[3] = (M) => Z()),
"aria-label": "hour",
"aria-invalid": !!f.value.hour,
"aria-errormessage": f.value.hour ? "hour-error" : void 0,
disabled: t.disabled
}, null, 40, Io), [
[We, s.value],
[r, 20]
]),
R[13] || (R[13] = j("span", { class: "text-gray-400 mx-1" }, ":", -1)),
Re(j("input", {
ref_key: "minuteRef",
ref: d,
"onUpdate:modelValue": R[4] || (R[4] = (M) => l.value = M),
type: "text",
inputmode: "numeric",
placeholder: t.minutePlaceholder,
maxlength: 2,
class: "time-input text-sm text-center",
onInput: P,
onKeydown: R[5] || (R[5] = (M) => _(M, "minute")),
onFocus: R[6] || (R[6] = (M) => K("minute")),
onBlur: R[7] || (R[7] = (M) => Z()),
"aria-label": "minute",
"aria-invalid": !!f.value.minute,
"aria-errormessage": f.value.minute ? "minute-error" : void 0,
disabled: t.disabled
}, null, 40, Oo), [
[We, l.value],
[r, 20]
]),
t.enableSeconds ? (A(), L(pe, { key: 0 }, [
R[12] || (R[12] = j("span", { class: "text-gray-400 mx-1" }, ":", -1)),
Re(j("input", {
ref_key: "secondRef",
ref: h,
"onUpdate:modelValue": R[8] || (R[8] = (M) => u.value = M),
type: "text",
inputmode: "numeric",
placeholder: t.secondPlaceholder,
maxlength: 2,
class: "time-input text-sm text-center",
onInput: J,
onKeydown: R[9] || (R[9] = (M) => _(M, "second")),
onFocus: R[10] || (R[10] = (M) => K("second")),
onBlur: R[11] || (R[11] = (M) => Z()),
"aria-label": "second",
"aria-invalid": !!f.value.second,
"aria-errormessage": f.value.second ? "second-error" : void 0,
disabled: t.disabled
}, null, 40, Vo), [
[We, u.value],
[r, 20]
])
], 64)) : oe("", !0),
t.use24Hour ? oe("", !0) : (A(), L("button", {
key: 1,
type: "button",
class: De(["time-period pl-2 text-sm cursor-pointer", s.value ? "text-vdt-content" : "text-gray-400"]),
onClick: Me(p, ["stop"])
}, ne(v.value), 3))
]));
}
}), ia = /* @__PURE__ */ Ne(Fo, [["__scopeId", "data-v-2ecd63a6"]]), Po = {
error: {
calendar: {
unsupported: "不支援的日曆"
},
date: {
required: "請選擇日期",
invalid: "無效的日期",
outOfRange: "日期超出允許範圍",
beforeMin: "日期不能早於 {minDate}",
afterMax: "日期不能晚於 {maxDate}",
unsupportedFormat: "不支援的日期格式,支援格式: {formats}",
parseError: "日期解析失敗,請檢查日期格式"
},
time: {
required: "請選擇時間",
invalid: "無效的時間",
hourOutOfRange: "小時必須是 {min}-{max} 之間的數字",
minuteOutOfRange: "分鐘必須是 0-59 之間的數字",
secondOutOfRange: "秒鐘必須是 0-59 之間的數字",
hourRequired: "請輸入小時",
minuteRequired: "請輸入分鐘",
secondRequired: "請輸入秒鐘",
minuteStepInvalid: "分鐘必須是 {step} 的倍數"
},
year: {
required: "請輸入年份",
invalid: "年份格式不正確",
outOfRange: "年份必須是 {min}-{max} 之間的數字",
notLeapYear: "{year}年2月沒有29日,不是閏年"
},
month: {
required: "請輸入月份",
invalid: "月份格式不正確",
outOfRange: "月份必須是 1-12 之間的數字"
},
day: {
required: "請輸入日期",
invalid: "日期格式不正確",
outOfRange: "日期必須是 1-31 之間的數字",
notExistInMonth: "{month}月最多只有{maxDays}天"
},
range: {
startRequired: "請選擇開始日期",
endRequired: "請選擇結束日期",
startAfterEnd: "開始日期不能晚於結束日期",
exceedsMaxRange: "選擇範圍不能超過 {maxRange} 天",
belowMinRange: "選擇範圍不能少於 {minRange} 天"
},
format: {
dateFormat: '日期格式不正確: "{original}" 已自動修復為 "{fixed}"',
timeFormat: '時間格式不正確: "{original}" 已自動修復為 "{fixed}"'
}
},
placeholder: {
date: {
year: "年",
month: "月",
day: "日"
},
time: {
hour: "時",
minute: "分",
second: "秒"
},
general: {
selectDate: "請選擇日期",
selectTime: "請選擇時間",
clear: "清除",
time: "時間"
},
range: {
start: "開始日期",
end: "結束日期"
}
},
yearSelector: {
jumpToYear: "跳至年份",
inputYearPlaceholder: "輸入西元年...",
yearRangeInfo: "{calendar}年範圍: {min} - {max}",
noYearsToDisplay: "沒有可顯示的年份",
returnToValidRange: "返回有效範圍"
}
}, Ao = {
error: {
calendar: {
unsupported: "不支持的日历"
},
date: {
required: "请选择日期",
invalid: "无效的日期",
outOfRange: "日期超出允许范围",
beforeMin: "日期不能早于 {minDate}",
afterMax: "日期不能晚于 {maxDate}",
unsupportedFormat: "不支持的日期格式,支持格式: {formats}",
parseError: "日期解析失败,请检查日期格式"
},
time: {
required: "请选择时间",
invalid: "无效的时间",
hourOutOfRange: "小时必须是 {min}-{max} 之间的数字",
minuteOutOfRange: "分钟必须是 0-59 之间的数字",
secondOutOfRange: "秒钟必须是 0-59 之间的数字",
hourRequired: "请输入小时",
minuteRequired: "请输入分钟",
secondRequired: "请输入秒钟",
minuteStepInvalid: "分钟必须是 {step} 的倍数"
},
year: {
required: "请输入年份",
invalid: "年份格式不正确",
outOfRange: "年份必须是 {min}-{max} 之间的数字",
notLeapYear: "{year}年2月没有29日,不是闰年"
},
month: {
required: "请输入月份",
invalid: "月份格式不正确",
outOfRange: "月份必须是 1-12 之间的数字"
},
day: {
required: "请输入日期",
invalid: "日期格式不正确",
outOfRange: "日期必须是 1-31 之间的数字",
notExistInMonth: "{month}月最多只有{maxDays}天"
},
range: {
startRequired: "请选择开始日期",
endRequired: "请选择结束日期",
startAfterEnd: "开始日期不能晚于结束日期",
exceedsMaxRange: "选择范围不能超过 {maxRange} 天",
belowMinRange: "选择范围不能少于 {minRange} 天"
},
format: {
dateFormat: '日期格式不正确: "{original}" 已自动修复为 "{fixed}"',
timeFormat: '时间格式不正确: "{original}" 已自动修复为 "{fixed}"'
}
},
placeholder: {
date: {
year: "年",
month: "月",
day: "日"
},
time: {
hour: "时",
minute: "分",
second: "秒"
},
general: {
selectDate: "请选择日期",
selectTime: "请选择时间",
clear: "清除",
time: "时间"
},
range: {
start: "开始日期",
end: "结束日期"
}
},
yearSelector: {
jumpToYear: "跳至年份",
inputYearPlaceholder: "输入公历年...",
yearRangeInfo: "{calendar}年范围: {min} - {max}",
noYearsToDisplay: "没有可显示的年份",
returnToValidRange: "返回有效范围"
}
}, Lo = {
error: {
calendar: {
unsupported: "Unsupported calendar"
},
date: {
required: "Please select a date",
invalid: "Invalid date",
outOfRange: "Date is out of allowed range",
beforeMin: "Date cannot be before {minDate}",
afterMax: "Date cannot be after {maxDate}",
unsupportedFormat: "Unsupported date format, supported formats: {formats}",
parseError: "Failed to parse date, please check the date format"
},
time: {
required: "Please select a time",
invalid: "Invalid time",
hourOutOfRange: "Hour must be between {min}-{max}",
minuteOutOfRange: "Minute must be between 0-59",
secondOutOfRange: "Second must be between 0-59",
hourRequired: "Please enter hour",
minuteRequired: "Please enter minute",
secondRequired: "Please enter second",
minuteStepInvalid: "Minute must be a multiple of {step}"
},
year: {
required: "Please enter year",
invalid: "Invalid year format",
outOfRange: "Year must be between {min}-{max}",
notLeapYear: "February 29th does not exist in {year}, not a leap year"
},
month: {
required: "Please enter month",
invalid: "Invalid month format",
outOfRange: "Month must be between 1-12"
},
day: {
required: "Please enter day",
invalid: "Invalid day format",
outOfRange: "Day must be between 1-31",
notExistInMonth: "Month {month} has maximum {maxDays} days"
},
range: {
startRequired: "Please select start date",
endRequired: "Please select end date",
startAfterEnd: "Start date cannot be after end date",
exceedsMaxRange: "Selection range cannot exceed {maxRange} days",
belowMinRange: "Selection range cannot be less than {minRange} days"
},
format: {
dateFormat: 'Invalid date format: "{original}" auto-fixed to "{fixed}"',
timeFormat: 'Invalid time format: "{original}" auto-fixed to "{fixed}"'
}
},
placeholder: {
date: {
year: "YYYY",
month: "MM",
day: "DD"
},
time: {
hour: "HH",
minute: "mm",
second: "ss"
},
general: {
selectDate: "Please select a date",
selectTime: "Please select a time",
clear: "Clear",
time: "Time"
},
range: {
start: "Start date",
end: "End date"
}
},
yearSelector: {
jumpToYear: "Jump to Year",
inputYearPlaceholder: "Enter Gregorian year...",
yearRangeInfo: "{calendar} Year Range: {min} - {max}",
noYearsToDisplay: "No years to display",
returnToValidRange: "Return to valid range"
}
}, Ho = {
error: {
calendar: {
unsupported: "サポートされていないカレンダーIDです"
},
date: {
required: "日付を選択してください",
invalid: "無効な日付",
outOfRange: "日付が許可範囲外です",
beforeMin: "日付は {minDate} より前にはできません",
afterMax: "日付は {maxDate} より後にはできません",
unsupportedFormat: "サポートされていない日付形式です。サポート形式: {formats}",
parseError: "日付の解析に失敗しました。日付形式を確認してください"
},
time: {
required: "時刻を選択してください",
invalid: "無効な時刻",
hourOutOfRange: "時間は {min}-{max} の間で入力してください",
minuteOutOfRange: "分は 0-59 の間で入力してください",
secondOutOfRange: "秒は 0-59 の間で入力してください",
hourRequired: "時間を入力してください",
minuteRequired: "分を入力してください",
secondRequired: "秒を入力してください",
minuteStepInvalid: "分は {step} の倍数でなければなりません"
},
year: {
required: "年を入力してください",
invalid: "年の形式が正しくありません",
outOfRange: "年は {min}-{max} の間で入力してください",
notLeapYear: "{year}年2月29日は存在しません(うるう年ではありません)"
},
month: {
required: "月を入力してください",
invalid: "月の形式が正しくありません",
outOfRange: "月は 1-12 の間で入力してください"
},
day: {
required: "日を入力してください",
invalid: "日の形式が正しくありません",
outOfRange: "日は 1-31 の間で入力してください",
notExistInMonth: "{month}月は最大 {maxDays} 日までです"
},
range: {
startRequired: "開始日を選択してください",
endRequired: "終了日を選択してください",
startAfterEnd: "開始日は終了日より後にはできません",
exceedsMaxRange: "選択範囲は {maxRange} 日を超えることはできません",
belowMinRange: "選択範囲は {minRange} 日未満にはできません"
},
format: {
dateFormat: '日付形式が正しくありません: "{original}" を "{fixed}" に自動修正しました',
timeFormat: '時刻形式が正しくありません: "{original}" を "{fixed}" に自動修正しました'
}
},
placeholder: {
date: {
year: "年",
month: "月",
day: "日"
},
time: {
hour: "時",
minute: "分",
second: "秒"
},
general: {
selectDate: "日付を選択してください",
selectTime: "時刻を選択してください",
clear: "クリア",
time: "時刻"
},
range: {
start: "開始日を",
end: "終了日を"
}
},
yearSelector: {
jumpToYear: "年にジャンプ",
inputYearPlaceholder: "西暦年を入力...",
yearRangeInfo: "{calendar}年の範囲: {min} - {max}",
noYearsToDisplay: "表示する年はありません",
returnToValidRange: "有効な範囲に戻る"
}
}, Bo = {
error: {
calendar: {
unsupported: "지원하지 않는 달력 ID입니다"
},
date: {
required: "날짜를 선택해주세요",
invalid: "유효하지 않은 날짜",
outOfRange: "날짜가 허용 범위를 벗어났습니다",
beforeMin: "날짜는 {minDate}보다 이전일 수 없습니다",
afterMax: "날짜는 {maxDate}보다 이후일 수 없습니다",
unsupportedFormat: "지원하지 않는 날짜 형식입니다. 지원 형식: {formats}",
parseError: "날짜를 파싱하는 데 실패했습니다. 날짜 형식을 확인해주세요"
},
time: {
required: "시간을 선택해주세요",
invalid: "유효하지 않은 시간",
hourOutOfRange: "시간은 {min}-{max} 사이의 숫자여야 합니다",
minuteOutOfRange: "분은 0-59 사이의 숫자여야 합니다",
secondOutOfRange: "초는 0-59 사이의 숫자여야 합니다",
hourRequired: "시간을 입력해주세요",
minuteRequired: "분을 입력해주세요",
secondRequired: "초을 입력해주세요",
minuteStepInvalid: "분은 {step}의 배수여야 합니다"
},
year: {
required: "연도를 입력해주세요",
invalid: "연도 형식이 올바르지 않습니다",
outOfRange: "연도는 {min}-{max} 사이의 숫자여야 합니다",
notLeapYear: "{year}년 2월 29일은 존재하지 않습니다 (윤년이 아님)"
},
month: {
required: "월을 입력해주세요",
invalid: "월 형식이 올바르지 않습니다",
outOfRange: "월은 1-12 사이의 숫자여야 합니다"
},
day: {
required: "일을 입력해주세요",
invalid: "일 형식이 올바르지 않습니다",
outOfRange: "일은 1-31 사이의 숫자여야 합니다",
notExistInMonth: "{month}월은 최대 {maxDays}일까지입니다"
},
range: {
startRequired: "시작 날짜를 선택해주세요",
endRequired: "종료 날짜를 선택해주세요",
startAfterEnd: "시작 날짜는 종료 날짜보다 늦을 수 없습니다",
exceedsMaxRange: "선택 범위는 {maxRange}일을 초과할 수 없습니다",
belowMinRange: "선택 범위는 {minRange}일 미만일 수 없습니다"
},
format: {
dateFormat: '날짜 형식이 올바르지 않습니다: "{original}"을(를) "{fixed}"로 자동 수정했습니다',
timeFormat: '시간 형식이 올바르지 않습니다: "{original}"을(를) "{fixed}"로 자동 수정했습니다'
}
},
placeholder: {
date: {
year: "년",
month: "월",
day: "일"
},
time: {
hour: "시",
minute: "분",
second: "초"
},
general: {
selectDate: "날짜를 선택해주세요",
selectTime: "시간을 선택해주세요",
clear: "지우기",
time: "시간"
},
range: {
start: "시작 날짜",
end: "종료 날짜"
}
},
yearSelector: {
jumpToYear: "연도로 이동",
inputYearPlaceholder: "서기 연도를 입력...",
yearRangeInfo: "{calendar}년 범위: {min} - {max}",
noYearsToDisplay: "표시한 연도는 없습니다",
returnToValidRange: "유효한 범위로 이동"
}
}, Ve = {
"zh-TW": Po,
"zh-CN": Ao,
"en-US": Lo,
"ja-JP": Ho,
"ko-KR": Bo
};
function Tr(t, e) {
return t.replace(/\{(\w+)\}/g, (a, r) => e[r]?.toString() || a);
}
class qo {
currentLocale = "zh-TW";
setLocale(e) {
if (!Ve[e]) {
console.warn(`Locale '${e}' not found, falling back to 'zh-TW'`), this.currentLocale = "zh-TW";
return;
}
this.currentLocale = e;
}
// 註冊自定義語言包
registerLocale(e, a) {
Ve[e] = a;
}
// 檢查語言包是否存在
hasLocale(e) {
return !!Ve[e];
}
// 獲取所有可用語言
getAvailableLocales() {
return Object.keys(Ve);
}
getCurrentLocale() {
return this.currentLocale;
}
getMessage(e, a) {
const r = e.split(".");
let n = Ve[this.currentLocale];
for (const o of r)
n = n?.[o];
return typeof n != "string" ? (console.warn(`Missing translation for path: ${e} in locale: ${this.currentLocale}`), e) : a ? Tr(n, a) : n;
}
getErrorMessage(e, a) {
return this.getMessage(`error.${e}`, a);
}
getPlaceholderMessage(e, a) {
return this.getMessage(`placeholder.${e}`, a);
}
// 支援自定義語言包
addCustomMessages(e, a) {
if (!Ve[e]) {
console.warn(`Locale '${e}' not found. Please register it first using registerLocale().`);
return;
}
Ve[e] = {
...Ve[e],
...this.deepMerge(Ve[e], a)
};
}
// addCustomMessages(locale: LocaleKey, messages: Partial<ErrorMessages>): void {
// localeMessages[locale] = {
// ...localeMessages[locale],
// ...this.deepMerge(localeMessages[locale], messages)
// };
// }
/**
* 獲取參數化錯誤訊息
*/
getParameterizedErrorMessage(e, a = {}) {
const r = this.getErrorMessage(e);
return this.interpolateParameters(r, a);
}
/**
* 參數插值
*/
interpolateParameters(e, a = {}) {
return !a || Object.keys(a).length === 0 ? e : e.replace(/\{(\w+)\}/g, (r, n) => {
const o = a[n];
return o == null ? (console.warn(`Missing variable '${n}' for template: "${e}"`), r) : String(o);
});
}
deepMerge(e, a) {
const r = { ...e };
for (const n in a)
a[n] && typeof a[n] == "object" && !Array.isArray(a[n]) ? r[n] = this.deepMerge(r[n] || {}, a[n]) : r[n] = a[n];
return r;
}
}
function pt(t = "en-US", e) {
const a = new qo(), r = z(t);
e && t && a.registerLocale(t, e), a.setLocale(t);
const n = (y, m) => {
r.value = y, m && a.registerLocale(y, m), a.setLocale(y);
}, o = (y, m) => a.getMessage(y, m), s = (y, m) => a.getErrorMessage(y, m), l = (y, m) => a.getPlaceholderMessage(y, m), u = (y, m) => Tr(y, m), i = (y, m) => {
a.registerLocale(y, m);
}, f = (y) => a.hasLocale(y);
return {
currentLocale: T(() => r.value),
setLocale: n,
getMessage: o,
getErrorMessage: s,
getPlaceholderMessage: l,
formatText: u,
registerCustomLocale: i,
hasLocale: f
};
}
const No = {
key: 0,
class: "date-error-message mt-1 text-sm text-red-500"
}, Uo = { key: 0 }, zo = { key: 1 }, Wo = { key: 2 }, Cr = /* @__PURE__ */ Te({
__name: "DateErrorMessage",
props: {
errors: { default: void 0 },
errorParams: { default: () => ({}) },
locale: { default: "zh-TW" },
useI18n: { type: Boolean, default: !0 },
customMessages: { default: () => ({}) },
messageKeyMap: { default: () => ({}) },
debug: { type: Boolean, default: !1 }
},
setup(t, { expose: e }) {
const a = t, { currentLocale: r, setLocale: n, getErrorMessage: o } = pt(a.locale);
de(() => a.locale, (c) => {
c && a.useI18n && n(c);
}, { immediate: !0 });
const s = z({}), l = z({}), u = T(() => ({
...a.customMessages,
...s.value
})), i = T(() => a.errors ? Array.isArray(a.errors) ? a.errors.length > 0 : typeof a.errors == "string" ? a.errors.trim().length > 0 : typeof a.errors == "object" ? Object.values(a.errors).some((c) => c && c.trim().length > 0) : !1 : !1), f = T(() => {
if (!a.errors) return null;
if (typeof a.errors == "string")
return d(a.errors);
if (Array.isArray(a.errors))
return a.errors.map((c, w) => ({
field: `item-${w}`,
message: d(c),
originalKey: c,
params: {}
}));
if (typeof a.errors == "object") {
const c = {};
return Object.entries(a.errors).forEach(([w, x]) => {
if (x) {
l.value[w] = x;
const b = a.errorParams?.[w] || {};
c[w] = d(x, w, b), a.debug && console.log(`Processing error for field "${w}":`, {
original: x,
params: b,
translated: c[w],
field: w,
slotName: k(w)
});
}
}), c;
}
return a.errors;
}), y = T(() => a.errorParams || {});
function m(c) {
return l.value[c];
}
function k(c) {
return `error-${c.replace(/^(date|time|range)\./, "")}`;
}
function S(c) {
return c.startsWith("date.") ? "date" : c.startsWith("time.") ? "time" : c.startsWith("range.") ? "range" : "unknown";
}
function d(c, w, x = {}) {
if (a.debug && console.log(`翻譯訊息: "${c}", field: "${w}", params:`, x), u.value[c])
return u.value[c];
if (!a.useI18n)
return c;
if (/^[a-zA-Z]+\.[a-zA-Z]+$/.test(c))
try {
const $ = o(c, x);
if (a.debug && console.log(`Locale key 翻譯: "${c}" -> "${$}" with params:`, x), $ && $ !== c)
return $;
} catch ($) {
a.debug && console.warn(`Locale key 翻譯失敗: ${c}`, $);
}
const v = a.messageKeyMap[c];
if (v)
try {
const $ = o(v, x);
if (a.debug && console.log(`MessageKeyMap 翻譯: "${c}" -> "${$}" with params:`, x), $ && $ !== v)
return $;
} catch ($) {
a.debug && console.warn(`MessageKeyMap 翻譯失敗: ${v}`, $);
}
return h(c, w, x);
}
function h(c, w, x = {}) {
a.debug && console.log(`smartTranslateError: "${c}", field: "${w}", params:`, x);
const b = {
請選擇日期: "date.required",
請選擇時間: "time.required",
請選擇開始日期: "range.startRequired",
請選擇結束日期: "range.endRequired",
"Please select a date": "date.required",
"Please select a time": "time.required",
"Please select start date": "range.startRequired",
"Please select end date": "range.endRequired"
};
if (b[c])
try {
const p = o(b[c], x);
if (a.debug && console.log(`直接匹配翻譯: "${c}" -> "${p}" with params:`, x), p && p !== b[c])
return p;
} catch (p) {
a.debug && console.warn(`直接匹配翻譯失敗: ${b[c]}`, p);
}
function v(p, D) {
if (/請輸入|please enter|required/i.test(p)) {
if (D?.includes("year") || p.includes("年份")) return "year.required";
if (D?.includes("month") || p.includes("月份")) return "month.required";
if (D?.includes("day") || p.includes("日期")) return "day.required";
if (D?.includes("hour") || p.includes("小時")) return "time.hourRequired";
if (D?.includes("minute") || p.includes("分鐘")) return "time.minuteRequired";
if (D?.includes("second") || p.includes("秒鐘")) return "time.secondRequired";
if (D?.includes("startDate") || p.includes("開始日期")) return "range.startRequired";
if (D?.includes("endDate") || p.includes("結束日期")) return "range.endRequired";
if (D?.includes("time") || p.includes("時間")) return "time.required";
if (D?.includes("date") || p.includes("日期")) return "date.required";
}
return null;
}
const $ = v(c, w);
if ($)
try {
const p = o($, x);
if (a.debug && console.log(`智能匹配翻譯: "${c}" -> "${p}" with params:`, x), p && p !== $)
return p;
} catch (p) {
a.debug && console.warn(`智能匹配翻譯失敗: ${$}`, p);
}
const g = [
{
regex: /(年份|year).*(\d+)-(\d+).*數字/i,
key: "year.outOfRange"
},
{
regex: /(月份|month).*1-12.*數字/i,
key: "month.outOfRange"
},
{
regex: /(日期|day).*1-31.*數字/i,
key: "day.outOfRange"
},
{
regex: /(小時|hour).*(\d+)-(\d+)/i,
key: "time.hourOutOfRange"
},
{
regex: /(分鐘|minute).*0-59/i,
key: "time.minuteOutOfRange"
},
{
regex: /(秒鐘|second).*0-59/i,
key: "time.secondOutOfRange"
},
{
regex: /無效|invalid/i,
key: null,
handler: (p) => p?.includes("year") ? "year.invalid" : p?.includes("month") ? "month.invalid" : p?.includes("day") ? "day.invalid" : p?.includes("time") || p?.includes("hour") || p?.includes("minute") || p?.includes("second") ? "time.invalid" : "date.invalid"
}
];
for (const p of g)
if (p.regex.test(c)) {
const D = p.handler ? p.handler(w) : p.key;
if (D)
try {
const F = o(D, x);
if (a.debug && console.log(`模式匹配翻譯: "${c}" -> "${F}" (key: ${D}) with params:`, x), F && F !== D)
return F;
} catch (F) {
a.debug && console.warn(`模式匹配翻譯失敗: ${D}`, F);
}
}
return a.debug && console.log(`無法翻譯,返回原始訊息: "${c}"`), c;
}
return e({
hasErrors: i,
processedErrors: f,
processedErrorParams: y,
translateMessage: d,
getOriginalKey: m,
getSlotName: k,
getFieldType: S,
setLocale: (c) => {
n(c);
},
addCustomTranslation: (c, w) => {
s.value[c] = w;
},
currentLocale: r
}), (c, w) => i.value ? (A(), L("div", No, [
Array.isArray(f.value) ? (A(), L("div", Uo, [
(A(!0), L(pe, null, ge(f.value, (x, b) => (A(), L("div", { key: b }, [
ve(c.$slots, `error-${x.field}`, {
error: x,
message: x.message,
field: x.field,
errorParams: x.params
}, () => [
j("span", null, ne(x.message), 1)
])
]))), 128))
])) : typeof f.value == "string" ? (A(), L("div", zo, [
ve(c.$slots, "error-single", {
error: f.value,
message: f.value
}, () => [
j("span", null, ne(f.value), 1)
])
])) : typeof f.value == "object" ? (A(), L("div", Wo, [
ve(c.$slots, "error", {
errors: f.value,
errorParams: a.errorParams
}, () => [
(A(!0), L(pe, null, ge(f.value, (x, b) => (A(), L("div", { key: b }, [
ve(c.$slots, k(b), {
field: b,
error: x,
message: x,
originalKey: m(b),
fieldType: S(b),
errorParams: a.errorParams[b] || {}
}, () => [
j("span", null, ne(x), 1)
])
]))), 128))
])
])) : oe("", !0)
])) : oe("", !0);
}
}), jo = {}, Jo = {
xmlns: "http://www.w3.org/2000/svg",
fill: "none",
viewBox: "0 0 24 24",
stroke: "currentColor"
};
function Ko(t, e) {
return A(), L("svg", Jo, [...e[0] || (e[0] = [
j("path", {
"stroke-linecap": "round",
"stroke-linejoin": "round",
"stroke-width": "2",
d: "M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"
}, null, -1)
])]);
}
const Yr = /* @__PURE__ */ Ne(jo, [["render", Ko]]), Qo = {}, Zo = {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 20 20",
fill: "currentColor"
};
function Go(t, e) {
return A(), L("svg", Zo, [...e[0] || (e[0] = [
j("path", {
"fill-rule": "evenodd",
d: "M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z",
"clip-rule": "evenodd"
}, null, -1)
])]);
}
const Rr = /* @__PURE__ */ Ne(Qo, [["render", Go]]), Xo = {}, _o = {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 20 20",
fill: "currentColor"
};
function el(t, e) {
return A(), L("svg", _o, [...e[0] || (e[0] = [
j("path", {
"fill-rule": "evenodd",
d: "M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z",
"clip-rule": "evenodd"
}, null, -1)
])]);
}
const Er = /* @__PURE__ */ Ne(Xo, [["render", el]]), tl = { class: "p-2 flex items-center justify-between border-b border-vdt-outline" }, al = ["disabled"], rl = { class: "text-sm font-medium" }, nl = ["disabled"], ol = {
key: 0,
class: "grid grid-cols-4 gap-1 p-2"
}, ll = ["onClick", "title"], sl = { class: "font-medium" }, il = { key: 0 }, ul = {
key: 0,
class: "text-xs opacity-60 mt-0.5"
}, cl = {
key: 1,
class: "p-4 text-center text-sm text-vdt-content-muted"
}, dl = { class: "mb-2" }, fl = { class: "p-2 border-t border-vdt-outline" }, ml = { class: "text-xs text-gray-400 mb-1" }, hl = ["placeholder", "min", "max"], vl = { class: "text-xs text-vdt-content-muted mt-1" }, yl = /* @__PURE__ */ Te({
__name: "YearSelector",
props: {
selectedYear: {},
showSelector: { type: Boolean },
pageSize: { default: 12 },
calendar: { default: "gregory" },
locale: { default: "zh-TW" }
},
emits: ["year-selected", "update:showSelector"],
setup(t, { expose: e, emit: a }) {
const r = t, n = a, { getMessage: o, formatText: s } = pt(r.locale), l = z(null), u = z(null), i = T(() => me.getCalendarRange(r.calendar)), f = T(() => me.getCalendarDisplayName(r.calendar, r.locale)), y = T(() => r.calendar === "gregory"), m = T(() => r.calendar === "japanese"), k = T(() => $.value[0]), S = T(() => $.value[$.value.length - 1]), d = z(0), h = (M) => {
const H = Math.floor(M / r.pageSize) * r.pageSize;
return Math.max(H, i.value.min);
}, c = () => {
d.value = h(r.selectedYear);
}, w = /* @__PURE__ */ new Map(), x = (M, H) => {
const U = `${M}-${H}`;
if (!w.has(U))
try {
w.set(U, new At(H, { calendar: M, year: "numeric", era: "short" }));
} catch {
w.set(U, new At(H, { year: "numeric" }));
}
return w.get(U);
}, b = (M) => {
const H = {
gregorianYear: M,
displayEra: "",
displayYear: M.toString(),
showReference: !1,
displayWarning: !1
};
if (y.value)
return H;
try {
const U = new le(M, 6, 1), X = me.safeToCalendar(U, me.createSafeCalendar(r.calendar)), se = x(r.calendar, r.locale).formatToParts(X.toDate("UTC"));
H.displayYear = se.find((q) => q.type === "year")?.value || M.toString(), H.displayEra = se.find((q) => q.type === "era")?.value || "";
const E = !!H.displayEra, C = H.displayEra !== M.toString();
(E || C) && (H.showReference = !0, H.referenceYear = M.toString());
} catch {
if (H.displayWarning = !0, H.warningMessage = `無法轉換為${f.value}`, r.calendar === "roc") {
const X = M - 1911;
H.displayYear = X > 0 ? X.toString() : `民國前${Math.abs(X - 1)}年`;
}
}
return H;
}, v = (M) => M >= i.value.min && M <= i.value.max, $ = T(() => {
const M = d.value, H = [];
for (let U = 0; U < r.pageSize; U++) {
const X = M + U;
if (X > i.value.max) break;
X < i.value.min || H.push(b(X));
}
return H;
}), g = T(() => {
const M = $.value;
if (M.length === 0) return "";
const H = M[0], U = M[M.length - 1];
if (!H || !U) return "";
if (y.value)
return `${H.displayYear} - ${U.displayYear}`;
if (H.gregorianYear === U.gregorianYear)
return H.displayYear;
const X = H.displayEra, ie = U.displayEra;
return X && ie && X === ie ? `${X} ${H.displayYear} - ${U.displayYear}` : `${H.displayEra} ${H.displayYear} - ${U.displayEra} ${U.displayYear}`;
}), p = T(() => d.value > i.value.min), D = T(() => d.value + r.pageSize <= i.value.max), F = () => {
p.value && (d.value = Math.max(
d.value - r.pageSize,
i.value.min
));
}, P = () => {
D.value && (d.value = Math.min(
d.value + r.pageSize,
i.value.max
));
}, J = (M) => {
v(M) && (n("year-selected", M), n("update:showSelector", !1));
}, _ = () => {
u.value && (v(u.value) ? (d.value = h(u.value), n("year-selected", u.value), n("update:showSelector", !1), u.value = null) : console.warn(`年份 ${u.value} 超出範圍 ${i.value.min}-${i.value.max}`));
}, K = () => {
const M = Math.max(i.value.min, Math.min((/* @__PURE__ */ new Date()).getFullYear(), i.value.max));
n("year-selected", M);
}, Z = (M) => o(`yearSelector.${M}`);
de([() => r.selectedYear, () => r.calendar], () => {
v(r.selectedYear) && (d.value = h(r.selectedYear));
}, { immediate: !0 });
const R = (M) => {
if (r.showSelector && l.value) {
const H = M.target, U = !!H.closest("[data-year-selector-button]");
!l.value.contains(H) && !U && n("update:showSelector", !1);
}
};
return Bt(() => {
c(), document.addEventListener("mousedown", R);
}), qt(() => {
document.removeEventListener("mousedown", R);
}), e({
getLocalizedText: Z,
formatText: s,
goToSpecificYear: _,
goToValidRange: K
}), (M, H) => t.showSelector ? (A(), L("div", {
key: 0,
ref_key: "yearSelectorRef",
ref: l,
class: "absolute top-full mt-1 right-0 min-w-56 max-h-72 overflow-auto bg-vdt-surface-elevated text-vdt-content border border-vdt-outline rounded-md shadow-lg z-20"
}, [
j("div", tl, [
j("button", {
type: "button",
onClick: F,
class: De(["p-1 hover:bg-vdt-interactive-hover rounded focus:outline-none", { "opacity-50 cursor-not-allowed": !p.value }]),
disabled: !p.value,
"aria-label": "previous year"
}, [
ce(Rr, { class: "h-4 w-4" })
], 10, al),
j("span", rl, [
ve(M.$slots, "year-range-display", {
firstYear: k.value,
lastYear: S.value,
displayText: g.value
}, () => [
Ma(ne(g.value), 1)
], !0)
]),
j("button", {
type: "button",
onClick: P,
class: De(["p-1 hover:bg-vdt-interactive-hover rounded focus:outline-none", { "opacity-50 cursor-not-allowed": !D.value }]),
disabled: !D.value,
"aria-label": "next year"
}, [
ce(Er, { class: "h-4 w-4" })
], 10, nl)
]),
$.value.length > 0 ? (A(), L("div", ol, [
(A(!0), L(pe, null, ge($.value, (U) => (A(), L("button", {
type: "button",
key: U.gregorianYear,
onClick: (X) => J(U.gregorianYear),
class: De([
"p-1 text-xs rounded focus:outline-none focus:ring-1 focus:ring-vdt-theme-500 leading-tight min-h-[2.5rem] flex flex-col justify-center items-center transition duration-200",
t.selectedYear === U.gregorianYear ? "bg-vdt-theme-500 text-white" : "hover:bg-vdt-interactive-hover text-vdt-content",
U.displayWarning ? "ring-1 ring-amber-400" : ""
]),
title: U.warningMessage
}, [
ve(M.$slots, "year-display", {
yearData: U,
isSelected: t.selectedYear === U.gregorianYear
}, () => [
j("div", sl, [
m.value ? (A(), L("div", il, ne(U.displayEra), 1)) : oe("", !0),
Ma(" " + ne(U.displayYear), 1)
]),
U.showReference ? (A(), L("div", ul, ne(U.referenceYear), 1)) : oe("", !0)
], !0)
], 10, ll))), 128))
])) : (A(), L("div", cl, [
ve(M.$slots, "no-years-display", {
calendarRange: i.value,
goToValidRange: K
}, () => [
j("div", dl, ne(Z("noYearsToDisplay")), 1),
j("button", {
type: "button",
onClick: K,
class: "text-xs bg-vdt-theme-100 hover:bg-vdt-theme-200 px-3 py-1 rounded text-vdt-theme-700"
}, ne(Z("returnToValidRange")), 1)
], !0)
])),
j("div", fl, [
ve(M.$slots, "year-input", {
yearInput: u.value,
calendarRange: i.value,
calendarDisplayName: f.value,
goToSpecificYear: _,
getLocalizedText: Z,
formatText: V(s)
}, () => [
j("div", ml, ne(Z("jumpToYear")), 1),
Re(j("input", {
type: "number",
"onUpdate:modelValue": H[0] || (H[0] = (U) => u.value = U),
onKeydown: Fe(_, ["enter"]),
placeholder: Z("inputYearPlaceholder"),
min: i.value.min,
max: i.value.max,
class: "w-full p-1 text-sm border border-vdt-outline bg-vdt-surface text-vdt-content rounded focus:outline-none focus:ring-2 focus:ring-vdt-theme-200 focus-within:ring-vdt-theme-500"
}, null, 40, hl), [
[We, u.value]
]),
j("div", vl, ne(V(s)(Z("yearRangeInfo"), {
calendar: f.value,
min: i.value.min,
max: i.value.max
})), 1)
], !0)
])
], 512)) : oe("", !0);
}
}), gl = /* @__PURE__ */ Ne(yl, [["__scopeId", "data-v-caef7ca5"]]), pl = { class: "flex justify-between items-center mb-4 gap-2" }, $l = ["disabled"], Dl = { class: "grow grid grid-cols-2 gap-2" }, bl = ["value"], Ml = { class: "relative" }, wl = ["disabled"], Sl = /* @__PURE__ */ Te({
__name: "CalendarHeader",
props: {
month: {},
year: {},
locale: { default: "en-US" },
minYear: { default: 1900 },
maxYear: { default: 2100 },
calendar: { default: "gregory" }
},
emits: ["update:month", "update:year"],
setup(t, { emit: e }) {
const a = t, r = e, n = z(a.month), o = z(a.year), s = z(!1), l = T(() => a.calendar || "gregory"), u = T(() => me.getCalendarRange(a.calendar));
de(() => a.month, (b) => {
n.value = b;
}, { immediate: !0 }), de(() => a.year, (b) => {
o.value = b;
}, { immediate: !0 });
const i = T(() => {
if (a.calendar === "gregory")
return o.value.toString();
try {
const b = new le(o.value, 6, 1), v = me.safeToCalendar(
b,
me.createSafeCalendar(a.calendar)
);
return new At(a.locale, {
calendar: a.calendar,
year: "numeric"
}).format(v.toDate("UTC"));
} catch {
return o.value.toString();
}
}), f = T(() => me.getMonthNames(a.locale, a.calendar)), y = T(() => {
let b = o.value, v = n.value - 1;
return v < 1 && (v = 12, b = o.value - 1), b >= u.value.min;
}), m = T(() => {
let b = o.value, v = n.value + 1;
return v > 12 && (v = 1, b = o.value + 1), b <= u.value.max;
}), k = () => {
if (!y.value) return;
let b = n.value - 1, v = o.value;
b < 1 && (b = 12, v -= 1), v >= u.value.min && w(b, v);
}, S = () => {
if (!m.value) return;
let b = n.value + 1, v = o.value;
b > 12 && (b = 1, v += 1), v <= u.value.max && w(b, v);
}, d = () => {
w(n.value, o.value);
}, h = (b) => {
b !== void 0 && (n.value = b), w(n.value, o.value);
}, c = (b) => {
b >= u.value.min && b <= u.value.max && (o.value = b, w(n.value, b));
}, w = (b, v) => {
n.value = b, o.value = v, r("update:month", b), r("update:year", v);
}, x = () => {
s.value = !s.value;
};
return (b, v) => (A(), L("div", pl, [
j("button", {
type: "button",
onClick: k,
class: "p-2 text-vdt-content-secondary hover:bg-vdt-interactive-hover rounded-full focus:outline-none focus:ring-2 focus:ring-vdt-theme-500 disabled:opacity-50 disabled:cursor-not-allowed",
"aria-label": "上個月",
disabled: !y.value
}, [
ce(Rr, { class: "h-5 w-5" })
], 8, $l),
j("div", Dl, [
ve(b.$slots, "month-selector", {
monthNames: f.value,
selectedMonth: n.value,
onMonthChange: h
}, () => [
Re(j("select", {
"onUpdate:modelValue": v[0] || (v[0] = ($) => n.value = $),
onChange: d,
class: "appearance-none bg-none w-full py-1 px-2 border border-vdt-outline bg-vdt-surface text-vdt-content rounded-sm text-sm focus:ring-2 focus:ring-vdt-theme-200 focus:border-vdt-theme-500",
"aria-label": "選擇月份",
role: "combobox"
}, [
(A(!0), L(pe, null, ge(f.value, ($, g) => (A(), L("option", {
key: g,
value: g + 1
}, ne($), 9, bl))), 128))
], 544), [
[wt, n.value]
])
]),
j("div", Ml, [
ve(b.$slots, "year-selector", {
displayYear: i.value,
toggleYearSelector: x,
showYearSelector: s.value
}, () => [
j("button", {
type: "button",
onClick: x,
"data-year-selector-button": "",
class: "inline-flex truncate items-center px-2 py-1 bg-vdt-surface text-vdt-content w-full border border-vdt-outline rounded-sm text-sm focus-within:ring-2 focus-within:border-vdt-theme-500 focus-within:ring-vdt-theme-200",
"aria-label": "選擇年份"
}, ne(i.value), 1)
]),
ce(gl, {
"selected-year": o.value,
"show-selector": s.value,
"onUpdate:showSelector": v[1] || (v[1] = ($) => s.value = $),
calendar: l.value,
locale: t.locale,
onYearSelected: c
}, dt({ _: 2 }, [
ge(b.$slots, ($, g) => ({
name: g,
fn: ft((p) => [
ve(b.$slots, g, mt(ht(p)))
])
}))
]), 1032, ["selected-year", "show-selector", "calendar", "locale"])
])
]),
j("button", {
type: "button",
onClick: S,
class: "p-2 text-vdt-content-secondary hover:bg-vdt-interactive-hover rounded-full focus:outline-none focus:ring-2 focus:ring-vdt-theme-500 disabled:opacity-50 disabled:cursor-not-allowed",
"aria-label": "下個月",
disabled: !m.value
}, [
ce(Er, { class: "h-5 w-5" })
], 8, wl)
]));
}
}), kl = { class: "grid grid-cols-7 mb-2" }, xl = /* @__PURE__ */ Te({
__name: "WeekdayHeader",
props: {
locale: { default: "en-US" },
weekStartsOn: { default: 0 },
calendar: { default: "gregory" }
},
setup(t) {
const e = t, a = T(() => {
const r = new Intl.DateTimeFormat(e.locale, {
weekday: "short",
calendar: e.calendar
}), n = new Date(2023, 0, 1);
return Array.from({ length: 7 }, (o, s) => {
const l = new Date(n);
return l.setDate(n.getDate() + (s + e.weekStartsOn) % 7), r.format(l);
});
});
return (r, n) => (A(), L("div", kl, [
(A(!0), L(pe, null, ge(a.value, (o, s) => (A(), L("div", {
key: s,
class: "text-center text-vdt-content text-sm py-2"
}, ne(o), 1))), 128))
]));
}
}), Tl = { class: "calendar-cell text-center relative" }, Cl = ["disabled", "tabindex", "aria-selected", "aria-disabled", "aria-current", "data-in-current-month"], Yl = /* @__PURE__ */ Te({
__name: "CalendarCell",
props: {
date: {},
currentMonth: {},
selected: { type: Boolean, default: !1 },
disabled: { type: Boolean, default: !1 },
isToday: { type: Boolean, default: !1 },
focusable: { type: Boolean, default: !1 },
selectionMode: { default: "single" },
isRangeStart: { type: Boolean, default: !1 },
isRangeEnd: { type: Boolean, default: !1 },
isInRange: { type: Boolean, default: !1 }
},
emits: ["select", "nav"],
setup(t, { emit: e }) {
const a = t, r = e, n = T(() => a.date.month !== a.currentMonth), o = T(() => {
const l = {};
return l["flex justify-center items-center w-8 h-8 rounded-md mx-auto relative z-10"] = !0, a.disabled ? (l["opacity-40 cursor-not-allowed"] = !0, l["bg-vdt-surface text-vdt-content"] = !0, l) : (a.selectionMode === "range" ? (a.isRangeStart || a.isRangeEnd ? l["bg-vdt-theme-500 text-white"] = !0 : a.isInRange ? l["bg-vdt-outline text-vdt-content"] = !0 : (l["bg-vdt-surface text-vdt-content"] = !0, l["hover:bg-vdt-interactive-hover cursor-pointer"] = !0), a.isToday && !a.isRangeStart && !a.isRangeEnd && !a.isInRange && (l["ring-2 ring-vdt-theme-500"] = !0)) : (a.selected ? l["bg-vdt-theme-500 text-white"] = !0 : (l["bg-vdt-surface text-vdt-content"] = !0, l["hover:bg-vdt-interactive-hover cursor-pointer"] = !0), a.isToday && !a.selected && (l["ring-2 ring-vdt-theme-500"] = !0)), n.value && !a.selected && !a.isRangeStart && !a.isRangeEnd && (l["text-vdt-content-muted"] = !0, l["text-vdt-content"] = !1), l);
}), s = () => {
a.disabled || r("select", a.date);
};
return (l, u) => (A(), L("div", Tl, [
j("button", {
type: "button",
class: De(["calendar-cell-button", o.value]),
disabled: t.disabled,
tabindex: t.focusable ? 0 : -1,
"aria-selected": t.selected || t.isRangeStart || t.isRangeEnd,
"aria-disabled": t.disabled,
"aria-current": t.isToday ? "date" : void 0,
"data-in-current-month": !n.value,
onClick: s,
onKeydown: [
Fe(s, ["enter"]),
Fe(s, ["space"]),
u[0] || (u[0] = Fe((i) => r("nav", "up"), ["up"])),
u[1] || (u[1] = Fe((i) => r("nav", "down"), ["down"])),
u[2] || (u[2] = Fe((i) => r("nav", "left"), ["left"])),
u[3] || (u[3] = Fe((i) => r("nav", "right"), ["right"]))
]
}, ne(t.date.day), 43, Cl)
]));
}
}), Rl = /* @__PURE__ */ Ne(Yl, [["__scopeId", "data-v-9018b2ca"]]), El = { class: "grid grid-cols-7 gap-1" }, Il = /* @__PURE__ */ Te({
__name: "DateGridView",
props: {
year: {},
month: {},
selectedDate: { default: null },
rangeStart: { default: null },
rangeEnd: { default: null },
selectionMode: { default: "single" },
minDate: { default: void 0 },
maxDate: { default: void 0 },
locale: { default: "en-US" },
weekStartsOn: { default: 0 },
calendar: { default: "gregory" }
},
emits: ["select", "range-select", "navigate"],
setup(t, { expose: e, emit: a }) {
const r = t, n = a, o = T(() => r.month), s = T(() => r.year);
T(() => {
const d = Xe();
return `${d.year}-${d.month}-${d.day}`;
});
const l = T(() => me.generateCalendarDays(
r.year,
// 西元年
r.month,
// 西元月
r.calendar,
r.locale,
r.weekStartsOn
)), u = (d) => {
if (!r.rangeStart || !r.rangeEnd) return !1;
try {
return d.compare(r.rangeStart) >= 0 && d.compare(r.rangeEnd) <= 0;
} catch {
return !1;
}
}, i = (d, h) => {
if (!d || !h) return !1;
try {
return d.compare(h) === 0;
} catch {
return !1;
}
}, f = (d) => {
try {
return !!(r.minDate && d.compare(r.minDate) < 0 || r.maxDate && d.compare(r.maxDate) > 0);
} catch {
return !0;
}
}, y = (d) => go(d), m = T(() => l.value.map((d, h) => {
const c = `${d.year}-${d.month}-${d.day}`, w = y(d), x = d.month !== o.value, b = f(d), v = r.selectionMode === "single" && i(d, r.selectedDate), $ = r.selectionMode === "range" && i(d, r.rangeStart), g = r.selectionMode === "range" && i(d, r.rangeEnd), p = r.selectionMode === "range" && u(d) && !$ && !g && !b, D = d.day === 1 && d.month === o.value, F = [
c,
v,
w,
b,
$,
g,
p,
r.selectionMode,
r.calendar
];
return {
key: `${r.calendar}-${s.value}-${o.value}-${c}-${h}`,
memoKey: F,
date: d,
isToday: w,
isSelected: v,
isDisabled: b,
isOutsideMonth: x,
isRangeStart: $,
isRangeEnd: g,
isInRange: p,
isFocusable: D
};
})), k = (d) => {
r.selectionMode === "single" ? n("select", d) : r.selectionMode === "range" && n("range-select", d, null);
}, S = (d) => {
const h = m.value;
if (h.length === 0) return;
const c = h[0], w = h[h.length - 1];
if (!(!c || !w))
switch (d) {
case "left":
c.date.day < 15 && c.date.month !== o.value && n("navigate", "prev-month");
break;
case "right":
w.date.day > 15 && w.date.month !== o.value && n("navigate", "next-month");
break;
}
};
return e({
getCalendarDays: () => l.value,
getCellStates: () => m.value
}), (d, h) => (A(), L("div", El, [
(A(!0), L(pe, null, ge(m.value, (c, w, x, b) => {
const v = c.memoKey;
if (b && b.key === c.key && jr(b, v)) return b;
const $ = (A(), Jr(Rl, {
key: c.key,
date: c.date,
"current-month": o.value,
selected: c.isSelected,
"is-today": c.isToday,
disabled: c.isDisabled,
focusable: c.isFocusable,
"is-range-start": c.isRangeStart,
"is-range-end": c.isRangeEnd,
"is-in-range": c.isInRange,
"selection-mode": t.selectionMode,
onSelect: k,
onNav: S
}, null, 8, ["date", "current-month", "selected", "is-today", "disabled", "focusable", "is-range-start", "is-range-end", "is-in-range", "selection-mode"]));
return $.memo = v, $;
}, h, 0), 128))
]));
}
}), Ol = { key: 0 }, Vl = { class: "flex flex-row items-center justify-between" }, Fl = { class: "text-sm font-medium text-vdt-content uppercase" }, Pl = { class: "flex flex-row items-center gap-1" }, Al = { class: "time-selector-container pt-1" }, Ll = { class: "flex flex-row items-center gap-1" }, Hl = { class: "flex-1" }, Bl = ["value"], ql = { class: "flex-1" }, Nl = ["value"], Ul = {
key: 0,
class: "flex-1"
}, zl = ["value"], Wl = {
key: 1,
class: "flex-shrink-0"
}, jl = { class: "isolate inline-flex rounded-md border border-vdt-outline bg-vdt-surface overflow-hidden" }, Jl = /* @__PURE__ */ Te({
__name: "TimeSelector",
props: {
show: { type: Boolean, default: !0 },
timeValue: { default: null },
enableSeconds: { type: Boolean, default: !0 },
use24Hour: { type: Boolean, default: !1 },
defaultTime: { default: "00:00:00" },
locale: { default: "zh-TW" },
selectionMode: { default: "single" }
},
emits: ["time-change", "today-click"],
setup(t, { expose: e, emit: a }) {
const r = t, n = a, { getPlaceholderMessage: o } = pt(r.locale), s = z(0), l = z(0), u = z(0), i = z("AM"), f = z(!1), y = T(() => r.use24Hour ? Array.from({ length: 24 }, (g, p) => p) : Array.from({ length: 12 }, (g, p) => p + 1)), m = T(() => Array.from({ length: 60 }, (g, p) => p)), k = T(() => Array.from({ length: 60 }, (g, p) => p)), S = T(() => {
let g = s.value;
r.use24Hour || (i.value === "PM" && g < 12 ? g += 12 : i.value === "AM" && g === 12 && (g = 0));
const p = d(g), D = d(l.value);
if (r.enableSeconds) {
const F = d(u.value);
return `${p}:${D}:${F}`;
} else
return `${p}:${D}`;
}), d = (g) => g.toString().padStart(2, "0"), h = (g) => d(g), c = (g) => {
if (!g) return;
const [p, D, F] = g.split(":");
let P = parseInt(p || "0") || 0;
r.use24Hour || (P >= 12 ? (i.value = "PM", P = P === 12 ? 12 : P - 12) : (i.value = "AM", P = P === 0 ? 12 : P)), s.value = P, l.value = parseInt(D || "0") || 0, r.enableSeconds && F && (u.value = parseInt(F) || 0), f.value = !0;
}, w = () => {
c(r.defaultTime);
}, x = (g) => {
i.value = g;
}, b = (g) => {
const p = /* @__PURE__ */ new Date();
return p.setHours(g === "AM" ? 6 : 18, 0, 0, 0), new Intl.DateTimeFormat(r.locale || navigator.language, {
hour12: !0,
hour: "numeric"
}).formatToParts(p).find((J) => J.type === "dayPeriod")?.value || g;
}, v = () => {
const g = /* @__PURE__ */ new Date();
if (r.use24Hour)
s.value = g.getHours();
else {
const p = g.getHours();
i.value = p >= 12 ? "PM" : "AM", s.value = p % 12 || 12;
}
l.value = g.getMinutes(), r.enableSeconds && (u.value = g.getSeconds()), f.value = !0;
}, $ = () => {
n("today-click");
};
return de(() => r.timeValue, (g) => {
g ? c(g) : !f.value && r.show && w();
}, { immediate: !0 }), de(
[s, l, u, i],
() => {
f.value && n("time-change", S.value);
}
), e({
// 獲取當前時間值
getCurrentTime: () => S.value,
// 設置時間
setTime: (g) => c(g),
// 重置為預設時間
resetToDefault: () => w()
}), (g, p) => t.show ? (A(), L("div", Ol, [
p[5] || (p[5] = j("hr", { class: "my-2 border-vdt-outline" }, null, -1)),
j("div", Vl, [
j("label", Fl, ne(V(o)("general.time")) + ": ", 1),
j("div", Pl, [
j("button", {
type: "button",
onClick: v,
class: "px-2 py-1 text-xs transition-colors rounded-sm bg-vdt-outline text-vdt-content hover:bg-vdt-interactive-active cursor-pointer"
}, " Now "),
t.selectionMode === "single" ? (A(), L("button", {
key: 0,
type: "button",
onClick: $,
class: "px-2 py-1 text-xs transition-colors rounded-sm bg-vdt-outline text-vdt-content hover:bg-vdt-interactive-active cursor-pointer"
}, " Today ")) : oe("", !0)
])
]),
j("div", Al, [
j("div", Ll, [
j("div", Hl, [
Re(j("select", {
"onUpdate:modelValue": p[0] || (p[0] = (D) => s.value = D),
class: "appearance-none bg-none w-full py-1 px-2 border border-vdt-outline bg-vdt-surface text-vdt-content rounded-sm text-sm focus:ring-2 focus:ring-vdt-theme-200 focus:border-vdt-theme-500"
}, [
(A(!0), L(pe, null, ge(y.value, (D) => (A(), L("option", {
key: D,
value: D
}, ne(h(D)), 9, Bl))), 128))
], 512), [
[wt, s.value]
])
]),
j("div", ql, [
Re(j("select", {
"onUpdate:modelValue": p[1] || (p[1] = (D) => l.value = D),
class: "appearance-none bg-none w-full py-1 px-2 border border-vdt-outline bg-vdt-surface text-vdt-content rounded-sm text-sm focus:ring-2 focus:ring-vdt-theme-200 focus:border-vdt-theme-500"
}, [
(A(!0), L(pe, null, ge(m.value, (D) => (A(), L("option", {
key: D,
value: D
}, ne(d(D)), 9, Nl))), 128))
], 512), [
[wt, l.value]
])
]),
t.enableSeconds ? (A(), L("div", Ul, [
Re(j("select", {
"onUpdate:modelValue": p[2] || (p[2] = (D) => u.value = D),
class: "appearance-none bg-none w-full py-1 px-2 border border-vdt-outline bg-vdt-surface text-vdt-content rounded-sm text-sm focus:ring-2 focus:ring-vdt-theme-200 focus:border-vdt-theme-500"
}, [
(A(!0), L(pe, null, ge(k.value, (D) => (A(), L("option", {
key: D,
value: D
}, ne(d(D)), 9, zl))), 128))
], 512), [
[wt, u.value]
])
])) : oe("", !0),
t.use24Hour ? oe("", !0) : (A(), L("div", Wl, [
j("div", jl, [
j("button", {
type: "button",
onClick: p[3] || (p[3] = (D) => x("AM")),
class: De(["px-2 py-1 text-sm transition-colors", i.value === "AM" ? "bg-vdt-theme-500 text-white" : "text-vdt-content hover:bg-vdt-interactive-hover"])
}, ne(b("AM")), 3),
j("button", {
type: "button",
onClick: p[4] || (p[4] = (D) => x("PM")),
class: De(["px-2 py-1 text-sm transition-colors", i.value === "PM" ? "bg-vdt-theme-500 text-white" : "text-vdt-content hover:bg-vdt-interactive-hover"])
}, ne(b("PM")), 3)
])
]))
])
])
])) : oe("", !0);
}
}), Kl = { class: "vdt-date-picker calendar-grid w-full max-w-xs rounded-lg shadow p-2" }, ua = /* @__PURE__ */ Te({
__name: "CalendarGrid",
props: {
value: { default: null },
rangeStart: { default: null },
rangeEnd: { default: null },
selectionMode: { default: "single" },
year: { default: void 0 },
month: { default: void 0 },
minDate: { default: void 0 },
maxDate: { default: void 0 },
locale: { default: "en-US" },
weekStartsOn: { default: 0 },
showTimeSelector: { type: Boolean, default: !1 },
timeValue: { default: null },
enableSeconds: { type: Boolean, default: !0 },
use24Hour: { type: Boolean, default: !1 },
defaultTime: { default: "00:00:00" },
calendar: { default: "gregory" }
},
emits: ["select", "time-select", "range-select"],
setup(t, { expose: e, emit: a }) {
const r = t, n = a, o = () => {
if (r.year !== void 0 && r.month !== void 0)
return { year: r.year, month: r.month };
if (r.value)
return { year: r.value.year, month: r.value.month };
if (r.rangeStart)
return { year: r.rangeStart.year, month: r.rangeStart.month };
const g = Xe();
return { year: g.year, month: g.month };
}, { year: s, month: l } = o(), u = z(s), i = z(l), f = z(r.timeValue), y = T(() => me.convertToCalendarDate(r.value, r.calendar)), m = T(() => me.convertToCalendarDate(r.rangeStart, r.calendar)), k = T(() => me.convertToCalendarDate(r.rangeEnd, r.calendar)), S = T(() => me.convertToCalendarDate(r.minDate || null, r.calendar)), d = T(() => me.convertToCalendarDate(r.maxDate || null, r.calendar)), h = T(() => r.minDate?.year || 1900), c = T(() => r.maxDate?.year || 2100), w = T(() => {
if (r.year !== void 0 && r.month !== void 0)
return { year: r.year, month: r.month };
const g = r.selectionMode === "range" ? r.rangeStart : r.value;
return g ? { year: g.year, month: g.month } : { year: u.value, month: i.value };
});
de(w, ({ year: g, month: p }) => {
u.value = g, i.value = p;
}, { immediate: !0 }), de(() => r.timeValue, (g) => {
f.value = g;
}, { immediate: !0 });
const x = (g) => {
if (r.selectionMode === "single") {
const p = me.convertFromCalendarDate(g, r.calendar);
p && (n("select", p, !0), r.showTimeSelector && f.value && n("time-select", f.value));
}
}, b = (g, p) => {
if (r.selectionMode === "range") {
const D = me.convertFromCalendarDate(g, r.calendar), F = me.convertFromCalendarDate(p, r.calendar);
n("range-select", D, F);
}
}, v = (g) => {
f.value = g, n("time-select", g);
}, $ = () => {
if (r.selectionMode === "single") {
const g = Xe();
u.value = g.year, i.value = g.month, n("select", g, !1);
}
};
return e({
// 獲取當前選中的日期(單一模式)
getSelectedDate: () => r.value,
// 獲取當前範圍(範圍模式)
getSelectedRange: () => ({ start: r.rangeStart, end: r.rangeEnd }),
// 設置顯示的月份
setDisplayMonth: (g, p) => {
u.value = g, i.value = p;
},
// 導航到上個月
previousMonth: () => {
i.value === 1 ? (i.value = 12, u.value -= 1) : i.value -= 1;
},
// 導航到下個月
nextMonth: () => {
i.value === 12 ? (i.value = 1, u.value += 1) : i.value += 1;
}
}), (g, p) => (A(), L("div", Kl, [
ce(Sl, {
month: i.value,
"onUpdate:month": p[0] || (p[0] = (D) => i.value = D),
year: u.value,
"onUpdate:year": p[1] || (p[1] = (D) => u.value = D),
locale: t.locale,
"min-year": h.value,
"max-year": c.value,
calendar: t.calendar
}, dt({ _: 2 }, [
ge(g.$slots, (D, F) => ({
name: F,
fn: ft((P) => [
ve(g.$slots, F, mt(ht(P)))
])
}))
]), 1032, ["month", "year", "locale", "min-year", "max-year", "calendar"]),
ce(xl, {
locale: t.locale,
"week-starts-on": t.weekStartsOn,
calendar: t.calendar
}, null, 8, ["locale", "week-starts-on", "calendar"]),
ce(Il, {
year: u.value,
month: i.value,
"selected-date": y.value,
"range-start": m.value,
"range-end": k.value,
"selection-mode": t.selectionMode,
"min-date": S.value,
"max-date": d.value,
locale: t.locale,
"week-starts-on": t.weekStartsOn,
calendar: t.calendar,
onSelect: x,
onRangeSelect: b
}, null, 8, ["year", "month", "selected-date", "range-start", "range-end", "selection-mode", "min-date", "max-date", "locale", "week-starts-on", "calendar"]),
ce(Jl, {
locale: t.locale,
show: t.showTimeSelector,
"time-value": f.value,
"enable-seconds": t.enableSeconds,
"use24-hour": t.use24Hour,
"default-time": t.defaultTime,
selectionMode: t.selectionMode,
onTimeChange: v,
onTodayClick: $
}, null, 8, ["locale", "show", "time-value", "enable-seconds", "use24-hour", "default-time", "selectionMode"])
]));
}
}), Ql = {}, Zl = {
xmlns: "http://www.w3.org/2000/svg",
fill: "none",
viewBox: "0 0 24 24",
"stroke-width": "1.5",
stroke: "currentColor"
};
function Gl(t, e) {
return A(), L("svg", Zl, [...e[0] || (e[0] = [
j("path", {
"stroke-linecap": "round",
"stroke-linejoin": "round",
d: "M6 18L18 6M6 6l12 12"
}, null, -1)
])]);
}
const Ir = /* @__PURE__ */ Ne(Ql, [["render", Gl]]);
function ca(t, e) {
const { dateInputRef: a, timeInputRef: r } = t, { showTime: n, autoFocusTimeAfterDate: o = !0 } = e;
return {
// 基本導航方法
focusFirstInput: () => {
we(() => {
a.value?.focus && a.value.focus();
});
},
focusLastInput: () => {
we(() => {
n && r.value?.focusLast ? r.value.focusLast() : a.value?.focusLast ? a.value.focusLast() : a.value?.focus && a.value.focus();
});
},
// 專門的導航處理
handleNavigateToTime: (y) => {
n && we(() => {
r.value?.focus && r.value.focus();
});
},
handleNavigateToDate: () => {
we(() => {
a.value?.focusLast ? a.value.focusLast() : a.value?.focus && a.value.focus();
});
},
autoFocusTimeAfterDateComplete: (y, m) => {
!n || !o || (m && !y.inputTimeValue.value && (y.inputTimeValue.value = m, y.updateFromInputs()), we(() => {
r.value?.focus && r.value.focus();
}));
}
};
}
function da(t = {}) {
const { required: e = !0, showTime: a = !1, minDate: r, maxDate: n, dateFormat: o = "YYYY-MM-DD" } = t, s = z({}), l = z({}), u = z({}), i = T(() => ({ ...s.value, ...l.value })), f = T(() => ({ ...u.value })), y = T(() => Object.keys(i.value).length > 0), m = (v, $, g = "date", p = {}) => {
["date", "year", "month", "day"].forEach((D) => {
d(`${g}.${D}`), h(`${g}.${D}`);
}), v || Object.entries($).forEach(([D, F]) => {
const P = `${g}.${D}`;
s.value[P] = F, p[D] && (u.value[P] = p[D]);
});
}, k = (v, $, g = "time", p = {}) => (["time", "hour", "minute", "second"].forEach((D) => {
d(`${g}.${D}`), h(`${g}.${D}`);
}), v || Object.entries($).forEach(([D, F]) => {
const P = `${g}.${D}`;
s.value[P] = F, p[D] && (u.value[P] = p[D]);
}), !y.value), S = (v) => {
if (!v) return !1;
if (r) {
const $ = he(r);
if ($ && Ht(v, $) < 0)
return m(!1, {
date: "date.beforeMin"
}, "date", {
date: { minDate: ke($, o) }
}), !1;
}
if (n) {
const $ = he(n);
if ($ && Ht(v, $) > 0)
return m(!1, {
date: "date.afterMax"
}, "date", {
date: { maxDate: ke($, o) }
}), !1;
}
return !0;
}, d = (v) => {
Object.keys(s.value).forEach(($) => {
$.startsWith(v) && delete s.value[$];
});
}, h = (v) => {
Object.keys(u.value).forEach(($) => {
$.startsWith(v) && delete u.value[$];
});
};
return {
// 狀態
errors: s,
formatErrors: l,
mergedErrors: i,
hasErrors: y,
errorParams: u,
mergedErrorParams: f,
// 驗證方法
handleDateValidation: m,
handleTimeValidation: k,
validateDateTime: (v, $) => {
const g = {
isValid: !0,
errors: {}
};
return e && (v || (g.errors.date = "date.required", g.isValid = !1), a && !$ && (g.errors.time = "time.required", g.isValid = !1)), Object.assign(s.value, g.errors), g.isValid && !y.value;
},
validateDateRange: S,
// 錯誤管理
clearFieldErrors: d,
clearFieldParams: h,
clearAllErrors: () => {
s.value = {}, l.value = {}, u.value = {};
},
setFormatError: (v, $) => {
l.value[v] = $;
},
clearFormatError: (v) => {
delete l.value[v];
}
};
}
function fa(t = {}) {
const {
showTime: e = !1,
dateFormat: a = "YYYY-MM-DD",
timeFormat: r = "HH:mm:ss",
outputType: n = "iso",
defaultTime: o,
enableSeconds: s = !0
} = t, l = z(null), u = z(null), i = z(null), f = (g) => {
if (!g || g.hour === void 0) return null;
const p = g.hour.toString().padStart(2, "0"), D = (g.minute || 0).toString().padStart(2, "0");
if (s) {
const F = (g.second || 0).toString().padStart(2, "0");
return `${p}:${D}:${F}`;
} else
return `${p}:${D}`;
}, y = (g, p) => {
if (!g) return null;
const D = he(g);
if (!D) return null;
if (!p && !e)
return Ae(D.year, D.month, D.day);
if (!p)
if (o) {
const K = o.split(":").map(Number), Z = K[0] || 0, O = K[1] || 0, R = K[2] || 0;
return Ae(
D.year,
D.month,
D.day,
Z,
O,
R
);
} else
return Ae(D.year, D.month, D.day);
const F = p.split(":").map(Number), P = F[0] || 0, J = F[1] || 0, _ = F[2] || 0;
return Ae(
D.year,
D.month,
D.day,
P,
J,
_
);
}, m = (g) => {
const p = he(g);
l.value = p, p ? (u.value = ke(p, a), i.value = f(p)) : (u.value = null, i.value = null);
}, k = (g, p) => {
const D = g !== void 0 ? g : u.value, F = p !== void 0 ? p : i.value, P = y(D, F);
return l.value = P, P;
}, S = (g) => {
if (!g) {
l.value = null, u.value = null, i.value = null;
return;
}
if (e && o && (g.hour === void 0 || g.hour === null) && !i.value) {
const p = o.split(":").map(Number), D = p[0] || 0, F = p[1] || 0, P = p[2] || 0, J = Ae(
g.year,
g.month,
g.day,
D,
F,
P
);
l.value = J, i.value = o;
} else
l.value = g, i.value = f(g);
l.value && (u.value = ke(l.value));
}, d = (g) => {
if (!l.value) return null;
const p = g.split(":").map(Number), D = {
...l.value,
hour: p[0] || 0,
minute: p[1] || 0,
second: p[2] || 0
};
return l.value = D, i.value = g, D;
}, h = (g) => {
const p = g !== void 0 ? g : l.value, D = e ? `${a} ${r}` : a;
return Lt(p, n, D);
}, c = () => {
l.value = null, u.value = null, i.value = null;
}, w = T(() => !!(u.value || i.value || l.value)), x = () => e && !i.value && o ? (i.value = o, !0) : !1, b = T(() => !!u.value), v = T(() => !!i.value), $ = T(() => e ? b.value && v.value : b.value);
return {
// 響應式狀態
internalDateTime: l,
inputDateValue: u,
inputTimeValue: i,
// 計算屬性
hasDateValue: b,
hasTimeValue: v,
hasCompleteValue: $,
hasValue: w,
// 主要方法
updateFromInputs: k,
setInternalDateTime: S,
updateTimeOnly: d,
setExternalValue: m,
// updateDateTime,
getFormattedOutput: h,
clearValues: c,
applyDefaultTime: x,
// 輔助方法
getTimeFromDateTime: f,
createDateTimeFromInputs: y
};
}
function Or(t, e, a = {}) {
const { disabled: r, onOutsideClick: n } = a, o = z(!1), s = () => {
r?.value || (o.value = !o.value, o.value && we(() => {
i();
}));
}, l = () => {
r?.value || (o.value = !0, we(() => {
i();
}));
}, u = () => {
o.value = !1;
}, i = () => {
if (!t.value || !e.value) return;
const d = t.value.getBoundingClientRect(), h = e.value, c = {
width: window.innerWidth,
height: window.innerHeight
};
h.style.position = "fixed", h.style.visibility = "hidden", h.style.display = "block";
const w = h.getBoundingClientRect();
let x = d.bottom + 5, b = d.left;
const v = c.height - d.bottom, $ = d.top, g = w.height;
v < g && $ > v && (x = d.top - g - 10);
const p = c.width - d.left, D = w.width;
p < D && (b = Math.max(c.width - D - 10, 10)), b < 10 && (b = 10), b + D > c.width - 10 && (b = c.width - D - 10), h.style.top = `${x}px`, h.style.left = `${b}px`, h.style.zIndex = "50", h.style.visibility = "visible";
}, f = (d) => {
const h = e.value, c = t.value, w = d.target;
o.value && h && !h.contains(w) && c && !c.contains(w) && (u(), n?.());
}, y = (d, h) => {
if (r?.value) return;
const c = d.target;
c.classList.contains("date-input") || c.classList.contains("time-input") || c.closest("input") || c.closest("button") || (d.preventDefault(), h?.());
}, m = (d) => {
if (r?.value) return;
const h = d.target;
h.classList.contains("date-input") || h.classList.contains("time-input") || h.closest("input") || h.closest("button") || d.preventDefault();
}, k = () => {
o.value && i();
}, S = () => {
o.value && i();
};
return Bt(() => {
document.addEventListener("mousedown", f), window.addEventListener("resize", k), window.addEventListener("scroll", S);
}), qt(() => {
document.removeEventListener("mousedown", f), window.removeEventListener("resize", k), window.removeEventListener("scroll", S);
}), {
// 狀態
showCalendar: o,
// 主要方法
toggleCalendar: s,
showCalendarPopup: l,
hideCalendar: u,
updateCalendarPosition: i,
// 事件處理
handleContainerClick: y,
handleContainerMouseDown: m
};
}
function Xl(t = {}) {
const {
customDefaultTime: e = "00:00:00",
enableSeconds: a = !0
} = t, r = (i) => {
if (!i) return !1;
if (!/^([0-1]?[0-9]|2[0-3]):([0-5]?[0-9])(?::([0-5]?[0-9]))?$/.test(i))
return console.warn(`時間格式不正確: ${i},應為 HH:mm:ss 或 HH:mm 格式`), !1;
const y = i.split(":"), m = parseInt(y[0] || "0"), k = parseInt(y[1] || "0"), S = y[2] ? parseInt(y[2] || "0") : 0;
return m < 0 || m > 23 || k < 0 || k > 59 || S < 0 || S > 59 ? (console.warn(`時間值超出範圍: ${i}`), !1) : !0;
}, n = (i, f = a) => {
const y = i.split(":"), m = (y[0] || "0").padStart(2, "0"), k = (y[1] || "0").padStart(2, "0"), S = y[2] ? y[2].padStart(2, "0") : "00";
return f ? `${m}:${k}:${S}` : `${m}:${k}`;
};
return {
// 計算屬性
getValidDefaultTime: T(() => {
if (e && r(e))
return n(e, a);
}),
// 驗證方法
isValidTimeValue: r,
// 格式化方法
formatTimeString: n,
getCurrentTimeString: () => {
const i = /* @__PURE__ */ new Date(), f = i.getHours().toString().padStart(2, "0"), y = i.getMinutes().toString().padStart(2, "0"), m = i.getSeconds().toString().padStart(2, "0");
return a ? `${f}:${y}:${m}` : `${f}:${y}`;
},
parseTimeString: (i) => {
const f = i.split(":");
return {
hours: parseInt(f[0] || "0") || 0,
minutes: parseInt(f[1] || "0") || 0,
seconds: parseInt(f[2] || "0") || 0
};
},
buildTimeString: (i, f, y = 0) => {
const m = i.toString().padStart(2, "0"), k = f.toString().padStart(2, "0"), S = y.toString().padStart(2, "0");
return a ? `${m}:${k}:${S}` : `${m}:${k}`;
}
};
}
function _l(t = {}, e) {
const {
modelValue: a = null,
showTime: r = !1,
required: n = !0,
// disabled = false,
// calendar = 'gregory', // 日曆系統
dateFormat: o = "YYYY-MM-DD",
timeFormat: s = "HH:mm:ss",
// outputType = 'iso',
useStrictISO: l = !1,
customDefaultTime: u,
enableSeconds: i = !0,
autoFocusTimeAfterDate: f = !0,
minDate: y,
maxDate: m
// locale = 'zh-TW'
} = t, { containerRef: k, calendarRef: S, dateInputRef: d, timeInputRef: h } = e, c = T(() => t.calendar?.value || "gregory"), w = T(() => t.locale?.value || "zh-TW"), x = T(() => t.outputType?.value || "iso"), b = T(() => t.disabled?.value ?? !1), v = da({
required: n,
showTime: r,
minDate: y,
maxDate: m,
dateFormat: o
}), $ = fa({
showTime: r,
dateFormat: o,
timeFormat: s,
outputType: x.value,
defaultTime: u,
enableSeconds: i
}), g = ca(
{ dateInputRef: d, timeInputRef: h },
{ showTime: r, autoFocusTimeAfterDate: f }
), p = Or(
k,
S,
{
disabled: b,
onOutsideClick: () => {
}
}
), D = Xl({
customDefaultTime: u,
enableSeconds: i
}), F = T(() => {
const Y = he(y, w.value);
return Y || null;
}), P = T(() => {
const Y = he(m, w.value);
return Y || null;
});
let J = null, _ = null, K = null;
const Z = (Y) => {
J = Y.update || null, _ = Y.change || null, K = Y.validation || null;
}, O = async (Y = $.internalDateTime.value) => {
let W = null;
if (Y) {
const fe = r ? s : void 0;
W = Lt(Y, x.value, o, fe, r, c.value, w.value, l, i);
}
J?.(W), _?.(W);
const ee = !v.hasErrors.value;
K?.(ee, v.mergedErrors.value, v.errorParams.value);
};
de(() => a, (Y) => {
const W = he(Y, w.value, c.value);
Y && !W ? (v.handleDateValidation(!1, { date: "無效的日期格式" }), $.setExternalValue(null)) : W && !v.validateDateRange(W) ? $.setExternalValue(null) : (v.clearFieldErrors("date"), v.clearFieldErrors("invalidInput"), $.setExternalValue(W));
}, { immediate: !0 });
const R = (Y, W, ee = {}) => {
v.handleDateValidation(Y, W, "date", ee), K?.(!v.hasErrors.value, v.mergedErrors.value, v.errorParams.value);
}, M = (Y, W, ee = {}) => {
v.handleTimeValidation(Y, W, "time", ee), K?.(!v.hasErrors.value, v.mergedErrors.value, v.errorParams.value);
}, H = async (Y) => {
$.inputDateValue.value = Y;
const W = $.updateFromInputs();
if (!W) {
v.handleDateValidation(!1, { date: "date.invalid" });
return;
}
v.validateDateRange(W) && (await O(W), ["date", "year", "month", "day"].forEach((ee) => {
v.clearFieldErrors(ee);
}), g.autoFocusTimeAfterDateComplete(
$,
u ? D.getValidDefaultTime.value : void 0
));
}, U = async (Y) => {
$.inputTimeValue.value = Y;
const W = $.updateFromInputs();
await O(W), ["time", "hour", "minute", "second"].forEach((ee) => {
v.clearFieldErrors(ee);
});
}, X = async (Y, W = !0) => {
try {
if (!v.validateDateRange(Y))
return;
$.setInternalDateTime(Y), await O($.internalDateTime.value), ["date", "year", "month", "day"].forEach((ee) => {
v.clearFieldErrors(ee);
}), W && p.hideCalendar();
} catch (ee) {
console.error("處理日曆選擇失敗:", ee);
}
}, ie = async (Y) => {
const W = $.updateTimeOnly(Y);
W && await O(W), ["time", "hour", "minute", "second"].forEach((ee) => {
v.clearFieldErrors(ee);
});
}, se = (Y) => {
p.handleContainerClick(Y, () => {
g.focusFirstInput();
}), p.toggleCalendar();
}, E = () => {
$.clearValues(), v.clearAllErrors(), O(null);
}, C = async () => {
const Y = await d.value?.validate(), W = r ? await h.value?.validate() : !0;
let ee = !0;
$.internalDateTime.value && (ee = me.isValidDate(
$.internalDateTime.value.year,
$.internalDateTime.value.month,
$.internalDateTime.value.day,
"gregory"
// 固定使用西元曆驗證
), ee || v.handleDateValidation(!1, {
date: "date.invalid"
// 簡化錯誤信息
}));
const fe = v.validateDateTime(
$.inputDateValue.value,
$.inputTimeValue.value
), ye = Y && W && ee && fe;
return K?.(ye, v.mergedErrors.value, v.errorParams.value), ye;
}, q = async () => {
const Y = /* @__PURE__ */ new Date(), W = {
year: Y.getFullYear(),
month: Y.getMonth() + 1,
day: Y.getDate(),
hour: Y.getHours(),
minute: Y.getMinutes(),
second: Y.getSeconds()
};
try {
$.setInternalDateTime(W), await O(W), ["date", "year", "month", "day", "time", "hour", "minute", "second"].forEach((ee) => {
v.clearFieldErrors(ee);
});
} catch (ee) {
console.warn("設置當前時間失敗:", ee);
const fe = `${W.year}-${W.month.toString().padStart(2, "0")}-${W.day.toString().padStart(2, "0")}`, ye = r ? `${(W.hour || 0).toString().padStart(2, "0")}:${(W.minute || 0).toString().padStart(2, "0")}:${(W.second || 0).toString().padStart(2, "0")}` : null;
$.inputDateValue.value = fe, r && ye && ($.inputTimeValue.value = ye);
const be = $.updateFromInputs();
await O(be);
}
}, G = () => {
g.focusFirstInput();
};
return {
// 狀態
isDisabled: b,
// 日曆系統相關
calendar: c,
// 從各個 composables 暴露的狀態
...v,
...$,
...p,
// 計算屬性
calendarMinDate: F,
calendarMaxDate: P,
// 預設時間相關
getValidDefaultTime: D.getValidDefaultTime,
// 事件處理方法
setEmitters: Z,
validateDateInput: R,
validateTimeInput: M,
handleDateComplete: H,
handleTimeComplete: U,
handleCalendarSelect: X,
handleTimeSelect: ie,
handleContainerClick: se,
handleContainerMouseDown: p.handleContainerMouseDown,
// 導航方法
handleNavigateToDate: g.handleNavigateToDate,
handleNavigateToTime: g.handleNavigateToTime,
// 主要操作方法
reset: E,
validate: C,
selectNow: q,
focus: G,
// 直接暴露導航方法(用於 defineExpose)
focusFirstInput: g.focusFirstInput,
focusLastInput: g.focusLastInput
};
}
const ba = {
slate: {
50: "oklch(98.4% 0.003 247.858)",
100: "oklch(96.8% 0.007 247.896)",
200: "oklch(92.9% 0.013 255.508)",
300: "oklch(86.9% 0.022 252.894)",
400: "oklch(70.4% 0.04 256.788)",
500: "oklch(55.4% 0.046 257.417)",
600: "oklch(44.6% 0.043 257.281)",
700: "oklch(37.2% 0.044 257.287)",
800: "oklch(27.9% 0.041 260.031)",
900: "oklch(20.8% 0.042 265.755)",
950: "oklch(12.9% 0.042 264.695)"
},
gray: {
50: "oklch(98.5% 0.002 247.839)",
100: "oklch(96.7% 0.003 264.542)",
200: "oklch(92.8% 0.006 264.531)",
300: "oklch(87.2% 0.01 258.338)",
400: "oklch(70.7% 0.022 261.325)",
500: "oklch(55.1% 0.027 264.364)",
600: "oklch(44.6% 0.03 256.802)",
700: "oklch(37.3% 0.034 259.733)",
800: "oklch(27.8% 0.033 256.848)",
900: "oklch(21% 0.034 264.665)",
950: "oklch(13% 0.028 261.692)"
},
zinc: {
50: "oklch(98.5% 0 0)",
100: "oklch(96.7% 0.001 286.375)",
200: "oklch(92% 0.004 286.32)",
300: "oklch(87.1% 0.006 286.286)",
400: "oklch(70.5% 0.015 286.067)",
500: "oklch(55.2% 0.016 285.938)",
600: "oklch(44.2% 0.017 285.786)",
700: "oklch(37% 0.013 285.805)",
800: "oklch(27.4% 0.006 286.033)",
900: "oklch(21% 0.006 285.885)",
950: "oklch(14.1% 0.005 285.823)"
},
neutral: {
50: "oklch(98.5% 0 0)",
100: "oklch(97% 0 0)",
200: "oklch(92.2% 0 0)",
300: "oklch(87% 0 0)",
400: "oklch(70.8% 0 0)",
500: "oklch(55.6% 0 0)",
600: "oklch(43.9% 0 0)",
700: "oklch(37.1% 0 0)",
800: "oklch(26.9% 0 0)",
900: "oklch(20.5% 0 0)",
950: "oklch(14.5% 0 0)"
},
stone: {
50: "oklch(98.5% 0.001 106.423)",
100: "oklch(97% 0.001 106.424)",
200: "oklch(92.3% 0.003 48.717)",
300: "oklch(86.9% 0.005 56.366)",
400: "oklch(70.9% 0.01 56.259)",
500: "oklch(55.3% 0.013 58.071)",
600: "oklch(44.4% 0.011 73.639)",
700: "oklch(37.4% 0.01 67.558)",
800: "oklch(26.8% 0.007 34.298)",
900: "oklch(21.6% 0.006 56.043)",
950: "oklch(14.7% 0.004 49.25)"
},
red: {
50: "oklch(97.1% 0.013 17.38)",
100: "oklch(93.6% 0.032 17.717)",
200: "oklch(88.5% 0.062 18.334)",
300: "oklch(80.8% 0.114 19.571)",
400: "oklch(70.4% 0.191 22.216)",
500: "oklch(63.7% 0.237 25.331)",
600: "oklch(57.7% 0.245 27.325)",
700: "oklch(50.5% 0.213 27.518)",
800: "oklch(44.4% 0.177 26.899)",
900: "oklch(39.6% 0.141 25.723)",
950: "oklch(25.8% 0.092 26.042)"
},
orange: {
50: "oklch(98% 0.016 73.684)",
100: "oklch(95.4% 0.038 75.164)",
200: "oklch(90.1% 0.076 70.697)",
300: "oklch(83.7% 0.128 66.29)",
400: "oklch(75% 0.183 55.934)",
500: "oklch(70.5% 0.213 47.604)",
600: "oklch(64.6% 0.222 41.116)",
700: "oklch(55.3% 0.195 38.402)",
800: "oklch(47% 0.157 37.304)",
900: "oklch(40.8% 0.123 38.172)",
950: "oklch(26.6% 0.079 36.259)"
},
amber: {
50: "oklch(98.7% 0.022 95.277)",
100: "oklch(96.2% 0.059 95.617)",
200: "oklch(92.4% 0.12 95.746)",
300: "oklch(87.9% 0.169 91.605)",
400: "oklch(82.8% 0.189 84.429)",
500: "oklch(76.9% 0.188 70.08)",
600: "oklch(66.6% 0.179 58.318)",
700: "oklch(55.5% 0.163 48.998)",
800: "oklch(47.3% 0.137 46.201)",
900: "oklch(41.4% 0.112 45.904)",
950: "oklch(27.9% 0.077 45.635)"
},
yellow: {
50: "oklch(98.7% 0.026 102.212)",
100: "oklch(97.3% 0.071 103.193)",
200: "oklch(94.5% 0.129 101.54)",
300: "oklch(90.5% 0.182 98.111)",
400: "oklch(85.2% 0.199 91.936)",
500: "oklch(79.5% 0.184 86.047)",
600: "oklch(68.1% 0.162 75.834)",
700: "oklch(55.4% 0.135 66.442)",
800: "oklch(47.6% 0.114 61.907)",
900: "oklch(42.1% 0.095 57.708)",
950: "oklch(28.6% 0.066 53.813)"
},
lime: {
50: "oklch(98.6% 0.031 120.757)",
100: "oklch(96.7% 0.067 122.328)",
200: "oklch(93.8% 0.127 124.321)",
300: "oklch(89.7% 0.196 126.665)",
400: "oklch(84.1% 0.238 128.85)",
500: "oklch(76.8% 0.233 130.85)",
600: "oklch(64.8% 0.2 131.684)",
700: "oklch(53.2% 0.157 131.589)",
800: "oklch(45.3% 0.124 130.933)",
900: "oklch(40.5% 0.101 131.063)",
950: "oklch(27.4% 0.072 132.109)"
},
green: {
50: "oklch(98.2% 0.018 155.826)",
100: "oklch(96.2% 0.044 156.743)",
200: "oklch(92.5% 0.084 155.995)",
300: "oklch(87.1% 0.15 154.449)",
400: "oklch(79.2% 0.209 151.711)",
500: "oklch(72.3% 0.219 149.579)",
600: "oklch(62.7% 0.194 149.214)",
700: "oklch(52.7% 0.154 150.069)",
800: "oklch(44.8% 0.119 151.328)",
900: "oklch(39.3% 0.095 152.535)",
950: "oklch(26.6% 0.065 152.934)"
},
emerald: {
50: "oklch(97.9% 0.021 166.113)",
100: "oklch(95% 0.052 163.051)",
200: "oklch(90.5% 0.093 164.15)",
300: "oklch(84.5% 0.143 164.978)",
400: "oklch(76.5% 0.177 163.223)",
500: "oklch(69.6% 0.17 162.48)",
600: "oklch(59.6% 0.145 163.225)",
700: "oklch(50.8% 0.118 165.612)",
800: "oklch(43.2% 0.095 166.913)",
900: "oklch(37.8% 0.077 168.94)",
950: "oklch(26.2% 0.051 172.552)"
},
teal: {
50: "oklch(98.4% 0.014 180.72)",
100: "oklch(95.3% 0.051 180.801)",
200: "oklch(91% 0.096 180.426)",
300: "oklch(85.5% 0.138 181.071)",
400: "oklch(77.7% 0.152 181.912)",
500: "oklch(70.4% 0.14 182.503)",
600: "oklch(60% 0.118 184.704)",
700: "oklch(51.1% 0.096 186.391)",
800: "oklch(43.7% 0.078 188.216)",
900: "oklch(38.6% 0.063 188.416)",
950: "oklch(27.7% 0.046 192.524)"
},
cyan: {
50: "oklch(98.4% 0.019 200.873)",
100: "oklch(95.6% 0.045 203.388)",
200: "oklch(91.7% 0.08 205.041)",
300: "oklch(86.5% 0.127 207.078)",
400: "oklch(78.9% 0.154 211.53)",
500: "oklch(71.5% 0.143 215.221)",
600: "oklch(60.9% 0.126 221.723)",
700: "oklch(52% 0.105 223.128)",
800: "oklch(45% 0.085 224.283)",
900: "oklch(39.8% 0.07 227.392)",
950: "oklch(30.2% 0.056 229.695)"
},
sky: {
50: "oklch(97.7% 0.013 236.62)",
100: "oklch(95.1% 0.026 236.824)",
200: "oklch(90.1% 0.058 230.902)",
300: "oklch(82.8% 0.111 230.318)",
400: "oklch(74.6% 0.16 232.661)",
500: "oklch(68.5% 0.169 237.323)",
600: "oklch(58.8% 0.158 241.966)",
700: "oklch(50% 0.134 242.749)",
800: "oklch(44.3% 0.11 240.79)",
900: "oklch(39.1% 0.09 240.876)",
950: "oklch(29.3% 0.066 243.157)"
},
blue: {
50: "oklch(97% 0.014 254.604)",
100: "oklch(93.2% 0.032 255.585)",
200: "oklch(88.2% 0.059 254.128)",
300: "oklch(80.9% 0.105 251.813)",
400: "oklch(70.7% 0.165 254.624)",
500: "oklch(62.3% 0.214 259.815)",
600: "oklch(54.6% 0.245 262.881)",
700: "oklch(48.8% 0.243 264.376)",
800: "oklch(42.4% 0.199 265.638)",
900: "oklch(37.9% 0.146 265.522)",
950: "oklch(28.2% 0.091 267.935)"
},
indigo: {
50: "oklch(96.2% 0.018 272.314)",
100: "oklch(93% 0.034 272.788)",
200: "oklch(87% 0.065 274.039)",
300: "oklch(78.5% 0.115 274.713)",
400: "oklch(67.3% 0.182 276.935)",
500: "oklch(58.5% 0.233 277.117)",
600: "oklch(51.1% 0.262 276.966)",
700: "oklch(45.7% 0.24 277.023)",
800: "oklch(39.8% 0.195 277.366)",
900: "oklch(35.9% 0.144 278.697)",
950: "oklch(25.7% 0.09 281.288)"
},
violet: {
50: "oklch(96.9% 0.016 293.756)",
100: "oklch(94.3% 0.029 294.588)",
200: "oklch(89.4% 0.057 293.283)",
300: "oklch(81.1% 0.111 293.571)",
400: "oklch(70.2% 0.183 293.541)",
500: "oklch(60.6% 0.25 292.717)",
600: "oklch(54.1% 0.281 293.009)",
700: "oklch(49.1% 0.27 292.581)",
800: "oklch(43.2% 0.232 292.759)",
900: "oklch(38% 0.189 293.745)",
950: "oklch(28.3% 0.141 291.089)"
},
purple: {
50: "oklch(97.7% 0.014 308.299)",
100: "oklch(94.6% 0.033 307.174)",
200: "oklch(90.2% 0.063 306.703)",
300: "oklch(82.7% 0.119 306.383)",
400: "oklch(71.4% 0.203 305.504)",
500: "oklch(62.7% 0.265 303.9)",
600: "oklch(55.8% 0.288 302.321)",
700: "oklch(49.6% 0.265 301.924)",
800: "oklch(43.8% 0.218 303.724)",
900: "oklch(38.1% 0.176 304.987)",
950: "oklch(29.1% 0.149 302.717)"
},
fuchsia: {
50: "oklch(97.7% 0.017 320.058)",
100: "oklch(95.2% 0.037 318.852)",
200: "oklch(90.3% 0.076 319.62)",
300: "oklch(83.3% 0.145 321.434)",
400: "oklch(74% 0.238 322.16)",
500: "oklch(66.7% 0.295 322.15)",
600: "oklch(59.1% 0.293 322.896)",
700: "oklch(51.8% 0.253 323.949)",
800: "oklch(45.2% 0.211 324.591)",
900: "oklch(40.1% 0.17 325.612)",
950: "oklch(29.3% 0.136 325.661)"
},
pink: {
50: "oklch(97.1% 0.014 343.198)",
100: "oklch(94.8% 0.028 342.258)",
200: "oklch(89.9% 0.061 343.231)",
300: "oklch(82.3% 0.12 346.018)",
400: "oklch(71.8% 0.202 349.761)",
500: "oklch(65.6% 0.241 354.308)",
600: "oklch(59.2% 0.249 0.584)",
700: "oklch(52.5% 0.223 3.958)",
800: "oklch(45.9% 0.187 3.815)",
900: "oklch(40.8% 0.153 2.432)",
950: "oklch(28.4% 0.109 3.907)"
},
rose: {
50: "oklch(96.9% 0.015 12.422)",
100: "oklch(94.1% 0.03 12.58)",
200: "oklch(89.2% 0.058 10.001)",
300: "oklch(81% 0.117 11.638)",
400: "oklch(71.2% 0.194 13.428)",
500: "oklch(64.5% 0.246 16.439)",
600: "oklch(58.6% 0.253 17.585)",
700: "oklch(51.4% 0.222 16.935)",
800: "oklch(45.5% 0.188 13.697)",
900: "oklch(41% 0.159 10.272)",
950: "oklch(27.1% 0.105 12.094)"
}
};
function Ga(t) {
const e = t.match(/oklch\(\s*([0-9.]+)%?\s+([0-9.]+)\s+([0-9.]+)(?:\s*\/\s*([0-9.]+))?\s*\)/);
if (!e) return null;
const a = Number(e[1]), r = Number(e[2]), n = Number(e[3]);
return isNaN(a) || isNaN(r) || isNaN(n) ? null : { lightness: a, chroma: r, hue: n };
}
function es(t) {
t = t.replace(/^#/, ""), t.length === 3 && (t = t.split("").map((n) => n + n).join(""));
const e = parseInt(t.slice(0, 2), 16), a = parseInt(t.slice(2, 4), 16), r = parseInt(t.slice(4, 6), 16);
return {
r: e / 255,
g: a / 255,
b: r / 255
};
}
function ts(t) {
const e = t.match(/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/);
if (e) {
const r = Number(e[1]), n = Number(e[2]), o = Number(e[3]);
return {
r: Math.max(0, Math.min(255, r)) / 255,
g: Math.max(0, Math.min(255, n)) / 255,
b: Math.max(0, Math.min(255, o)) / 255
};
}
const a = t.match(/^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*([0-9]*\.?[0-9]+)\s*\)$/);
if (a) {
const r = Number(a[1]), n = Number(a[2]), o = Number(a[3]);
return {
r: Math.max(0, Math.min(255, r)) / 255,
g: Math.max(0, Math.min(255, n)) / 255,
b: Math.max(0, Math.min(255, o)) / 255
};
}
return null;
}
function Vr(t) {
const { r: e, g: a, b: r } = t, n = e <= 0.04045 ? e / 12.92 : Math.pow((e + 0.055) / 1.055, 2.4), o = a <= 0.04045 ? a / 12.92 : Math.pow((a + 0.055) / 1.055, 2.4), s = r <= 0.04045 ? r / 12.92 : Math.pow((r + 0.055) / 1.055, 2.4), l = 0.4124 * n + 0.3576 * o + 0.1805 * s, u = 0.2126 * n + 0.7152 * o + 0.0722 * s, i = 0.0193 * n + 0.1192 * o + 0.9505 * s, f = 0.95047, y = 1, m = 1.08883, k = l > 8856e-6 ? Math.pow(l / f, 1 / 3) : 7.787 * l / f + 16 / 116, S = u > 8856e-6 ? Math.pow(u / y, 1 / 3) : 7.787 * u / y + 16 / 116, d = i > 8856e-6 ? Math.pow(i / m, 1 / 3) : 7.787 * i / m + 16 / 116, h = 116 * S - 16, c = 500 * (k - S), w = 200 * (S - d);
return { l: h, a: c, b: w };
}
function Fr(t) {
const { l: e, a, b: r } = t, n = Math.sqrt(a * a + r * r);
let o = Math.atan2(r, a) * 180 / Math.PI;
return o < 0 && (o += 360), { l: e, c: n, h: o };
}
function as(t) {
const e = es(t), a = Vr(e), r = Fr(a);
let n = r.h;
return n > 0 && n < 60 && (n = n * 0.7), {
lightness: r.l,
chroma: Math.min(r.c / 150, 0.4),
hue: n
};
}
function rs(t) {
const e = Vr(t), a = Fr(e);
let r = a.h;
return r > 0 && r < 60 && (r = r * 0.7), {
lightness: a.l,
chroma: Math.min(a.c / 150, 0.4),
hue: r
};
}
function ns(t, e) {
const a = Math.min(
Math.abs(t.hue - e.hue),
360 - Math.abs(t.hue - e.hue)
), r = a > 60 ? 30 : 5;
return Math.sqrt(
Math.pow((t.lightness - e.lightness) * 1.5, 2) + Math.pow((t.chroma - e.chroma) * 2, 2) + Math.pow(a / 360 * r, 2) * 100
);
}
function os(t) {
return t.startsWith("oklch(");
}
function ls(t) {
return /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(t);
}
function ss(t) {
return t in ba;
}
function is(t) {
return t.startsWith("rgb(") || t.startsWith("rgba(");
}
function Xa(t) {
const e = "violet";
if (ss(t))
return t;
let a = null;
if (os(t))
a = Ga(t);
else if (ls(t))
a = as(t);
else if (is(t)) {
const o = ts(t);
o && (a = rs(o));
}
if (!a) return e;
let r = e, n = 1 / 0;
for (const [o, s] of Object.entries(ba))
for (const l of ["300", "400", "500", "600", "700"]) {
const u = s[l];
if (!u) continue;
const i = Ga(u);
if (!i) continue;
const f = ns(a, i);
f < n && (n = f, r = o);
}
return r;
}
function us(t) {
return ba[t] || {};
}
class cs {
instances = /* @__PURE__ */ new Map();
mediaQuery = null;
listeners = /* @__PURE__ */ new Map();
constructor() {
this.initializeSystemPreference();
}
/**
* 初始化系統偏好檢測
*/
initializeSystemPreference() {
typeof window < "u" && window.matchMedia && (this.mediaQuery = window.matchMedia("(prefers-color-scheme: dark)"), this.mediaQuery.addEventListener("change", this.handleSystemThemeChange.bind(this)));
}
/**
* 處理系統主題變化
*/
handleSystemThemeChange(e) {
const a = e.matches ? "dark" : "light";
this.instances.forEach((r, n) => {
r.systemPreference = a, r.userPreference === "auto" && this.updateCurrentMode(n);
});
}
/**
* 獲取當前系統偏好
*/
getSystemPreference() {
return this.mediaQuery && this.mediaQuery.matches ? "dark" : "light";
}
/**
* 創建新的主題實例
*/
createInstance(e, a = {}) {
const r = e || this.generateInstanceId(), n = {
currentMode: "light",
userPreference: a.defaultMode || "auto",
systemPreference: this.getSystemPreference(),
color: Xa(a.defaultColor || "violet"),
instanceId: r
};
return this.instances.set(r, n), this.listeners.set(r, []), this.updateCurrentMode(r), typeof document < "u" && setTimeout(() => {
this.applyColorToDOM(r), this.applyModeToDOM(r);
}, 0), r;
}
/**
* 銷毀主題實例
*/
destroyInstance(e) {
this.instances.delete(e), this.listeners.delete(e);
}
/**
* 生成實例 ID
*/
generateInstanceId() {
return `vdt-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
}
/**
* 更新當前模式
*/
updateCurrentMode(e) {
const a = this.instances.get(e);
if (!a) return;
const r = a.currentMode;
a.userPreference === "auto" ? a.currentMode = a.systemPreference : a.currentMode = a.userPreference, r !== a.currentMode && (this.applyModeToDOM(e), this.notifyListeners(e));
}
/**
* 應用模式到特定的 DOM 元素
*/
applyModeToDOM(e) {
if (typeof document > "u") return;
const a = this.instances.get(e);
if (!a) return;
const r = document.querySelector(`[data-vdt-instance="${e}"]`);
if (!r) {
setTimeout(() => this.applyModeToDOM(e), 10);
return;
}
a.userPreference === "auto" ? r.removeAttribute("data-vdt-mode") : r.setAttribute("data-vdt-mode", a.currentMode);
}
/**
* 應用顏色到特定的 DOM 元素
*/
applyColorToDOM(e) {
if (typeof document > "u") return;
const a = this.instances.get(e);
if (!a) return;
const r = document.querySelector(`[data-vdt-instance="${e}"]`);
if (!r) {
setTimeout(() => this.applyColorToDOM(e), 10);
return;
}
const n = us(a.color);
this.checkForUserOverride(r, n) ? Object.keys(n).forEach((s) => {
r.style.removeProperty(`--color-vdt-theme-${s}`);
}) : Object.entries(n).forEach(([s, l]) => {
r.style.setProperty(`--color-vdt-theme-${s}`, l);
});
}
/**
* 檢查用戶是否有 CSS 覆蓋
*/
checkForUserOverride(e, a) {
const r = {};
Object.keys(a).forEach((y) => {
const m = `--color-vdt-theme-${y}`;
r[m] = e.style.getPropertyValue(m), e.style.removeProperty(m);
});
const o = getComputedStyle(e).getPropertyValue("--color-vdt-theme-500").trim();
if (Object.entries(r).forEach(([y, m]) => {
m && e.style.setProperty(y, m);
}), !o) return !1;
const s = "oklch(60.6% 0.25 292.717)", l = a[500], u = this.isOklchEqual(o, s), i = l ? this.isOklchEqual(o, l) : !1;
return !u && !i;
}
/**
* 解析 OKLCH 值為數值以便比較
*/
parseOklchForComparison(e) {
const a = e.match(/oklch\(\s*([0-9.]+)%?\s+([0-9.]+)\s+([0-9.]+)\s*\)/);
return !a || !a[1] || !a[2] || !a[3] ? null : {
l: parseFloat(a[1]),
c: parseFloat(a[2]),
h: parseFloat(a[3])
};
}
/**
* 比較兩個 OKLCH 顏色是否相等(容許小數點誤差)
*/
isOklchEqual(e, a, r = 1e-3) {
const n = this.parseOklchForComparison(e), o = this.parseOklchForComparison(a);
return !n || !o ? e.trim() === a.trim() : Math.abs(n.l - o.l) < r && Math.abs(n.c - o.c) < r && Math.abs(n.h - o.h) < r;
}
/**
* 通知監聽器
*/
notifyListeners(e) {
const a = this.instances.get(e), r = this.listeners.get(e);
a && r && r.forEach((n) => n({ ...a }));
}
/**
* 設置主題模式
*/
setMode(e, a) {
const r = this.instances.get(e);
r && (r.userPreference = a, this.updateCurrentMode(e));
}
/**
* 設置主題顏色
*/
setColor(e, a) {
const r = this.instances.get(e);
if (!r) return;
const n = Xa(a);
r.color = n, this.applyColorToDOM(e), this.notifyListeners(e);
}
/**
* 獲取實例狀態
*/
getState(e) {
const a = this.instances.get(e);
return a ? { ...a } : null;
}
/**
* 獲取主題類別(用於組件)
*/
getThemeClasses(e) {
const a = this.instances.get(e);
return a ? {
// 穩定的通用類名
"vdt-datepicker": !0,
"vdt-themed": !0,
// 主題色相關類名
[`vdt-theme-${a.color}`]: !0,
// 模式相關類名
[`vdt-mode-${a.currentMode}`]: !0,
"vdt-mode-auto": a.userPreference === "auto",
// 實例相關(用於調試,但不應用於 CSS)
[`vdt-instance-${e}`]: !0
} : {};
}
/**
* 獲取容器屬性
*/
getContainerAttributes(e) {
const a = this.instances.get(e);
if (!a) return {};
const r = {
"data-vdt-instance": e,
"data-vdt-theme": a.color,
"data-vdt-mode-preference": a.userPreference
};
return a.userPreference !== "auto" && (r["data-vdt-mode"] = a.currentMode), r;
}
/**
* 強制重新應用主題(用於調試或強制刷新)
*/
reapplyTheme(e) {
this.applyColorToDOM(e), this.applyModeToDOM(e);
}
/**
* 添加監聽器
*/
addListener(e, a) {
const r = this.listeners.get(e);
return r ? (r.push(a), () => {
const n = r.indexOf(a);
n > -1 && r.splice(n, 1);
}) : () => {
};
}
/**
* 銷毀管理器
*/
destroy() {
this.mediaQuery && this.mediaQuery.removeEventListener("change", this.handleSystemThemeChange.bind(this)), this.instances.clear(), this.listeners.clear();
}
}
const Ie = new cs();
function Pr(t = {}) {
const e = z(
Ie.createInstance(t.instanceId, {
defaultColor: t.defaultColor,
defaultMode: t.defaultMode
})
), a = z(
Ie.getState(e.value)
);
let r = null;
const n = T(() => a.value?.currentMode === "dark"), o = T(() => a.value?.currentMode === "light"), s = T(() => a.value?.userPreference === "auto"), l = T(() => a.value?.currentMode || "light"), u = T(() => a.value?.userPreference || "auto"), i = T(() => a.value?.systemPreference || "light"), f = T(() => a.value?.color || "violet"), y = T(() => e.value ? Ie.getThemeClasses(e.value) : {}), m = T(() => e.value ? Ie.getContainerAttributes(e.value) : {}), k = (c) => {
e.value && Ie.setColor(e.value, c);
}, S = (c) => {
e.value && Ie.setMode(e.value, c);
}, d = () => {
if (a.value)
if (a.value.userPreference === "auto") {
const c = a.value.currentMode === "light" ? "dark" : "light";
S(c);
} else {
const c = a.value.currentMode === "light" ? "dark" : "light";
S(c);
}
}, h = T(() => typeof window > "u" ? !1 : window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches !== void 0);
return Bt(async () => {
await we(), a.value = Ie.getState(e.value), r = Ie.addListener(e.value, (c) => {
a.value = c;
}), setTimeout(() => {
Ie.reapplyTheme(e.value);
}, 10);
}), qt(() => {
r && r(), e.value && Ie.destroyInstance(e.value);
}), {
// 響應式狀態
instanceId: e,
themeState: a,
isDark: n,
isLight: o,
isAuto: s,
currentMode: l,
userPreference: u,
systemPreference: i,
currentColor: f,
themeClasses: y,
containerAttributes: m,
supportsColorScheme: h,
// 主要方法
setColor: k,
setMode: S,
toggle: d,
// 便利方法 - 模式設置
setLightMode: () => S("light"),
setDarkMode: () => S("dark"),
setAutoMode: () => S("auto"),
// 便利方法 - 常用顏色設置
setRedTheme: () => k("red"),
setBlueTheme: () => k("blue"),
setGreenTheme: () => k("green"),
setVioletTheme: () => k("violet"),
setPurpleTheme: () => k("purple"),
setIndigoTheme: () => k("indigo"),
setTealTheme: () => k("teal"),
setCyanTheme: () => k("cyan"),
setSkyTheme: () => k("sky"),
setEmeraldTheme: () => k("emerald")
};
}
const ds = ["name", "value"], fs = ["disabled"], ms = { key: 0 }, hs = {
key: 0,
class: "date-placeholder text-vdt-content truncate"
}, vs = {
key: 1,
class: "date-placeholder text-vdt-content-muted truncate"
}, ys = { key: 0 }, _a = /* @__PURE__ */ Te({
__name: "DatePicker",
props: {
modelValue: { default: null },
customDefaultTime: {},
autoFocusTimeAfterDate: { type: Boolean, default: !0 },
placeholderOverrides: { default: () => ({}) },
mode: { default: "auto" },
theme: { default: () => "violet" },
calendar: { default: "gregory" },
locale: { default: "zh-TW" },
customLocaleMessages: { default: void 0 },
outputType: { default: "iso" },
useStrictISO: { type: Boolean, default: !1 },
weekStartsOn: { default: 0 },
minDate: {},
maxDate: {},
dateSeparator: { default: "-" },
dateFormat: { default: "YYYY-MM-DD" },
timeFormat: {},
showTime: { type: Boolean, default: !1 },
enableSeconds: { type: Boolean, default: !0 },
use24Hour: { type: Boolean, default: !0 },
useLocalizedPeriod: { type: Boolean, default: !1 },
disabled: { type: Boolean, default: !1 },
inputEnabled: { type: Boolean, default: !0 },
required: { type: Boolean, default: !1 },
showClearButton: { type: Boolean, default: !0 },
showCalendarIcon: { type: Boolean, default: !0 },
id: { default: void 0 },
name: { default: void 0 },
showErrorMessage: { type: Boolean, default: !0 },
useI18n: { type: Boolean, default: !0 },
customErrorMessages: { default: () => ({}) }
},
emits: ["update:modelValue", "change", "validation"],
setup(t, { expose: e, emit: a }) {
const r = t, { setLocale: n, getPlaceholderMessage: o } = pt(
r.locale,
r.customLocaleMessages
), s = a, l = Kr(), u = T(() => {
const B = {};
return ["no-years-display", "month-selector"].forEach((N) => {
l[N] && (B[N] = l[N]);
}), Object.keys(l).forEach((N) => {
N.startsWith("year-") && (B[N] = l[N]);
}), B;
}), i = z(null), f = z(null), y = z(null), m = z(null), k = T(() => r.timeFormat ? r.timeFormat : r.enableSeconds ? r.use24Hour ? "HH:mm:ss" : "hh:mm:ss A" : r.use24Hour ? "HH:mm" : "hh:mm A"), S = z(r.dateFormat), d = z(k.value), h = z({}), c = _l(
{
modelValue: r.modelValue,
showTime: r.showTime,
required: r.required,
disabled: it(r, "disabled"),
calendar: it(r, "calendar"),
dateFormat: S.value,
timeFormat: d.value,
outputType: it(r, "outputType"),
useStrictISO: r.useStrictISO,
customDefaultTime: r.customDefaultTime,
enableSeconds: r.enableSeconds,
autoFocusTimeAfterDate: r.autoFocusTimeAfterDate,
minDate: r.minDate,
maxDate: r.maxDate,
locale: it(r, "locale")
},
{
containerRef: i,
calendarRef: f,
dateInputRef: y,
timeInputRef: m
}
);
c.setEmitters({
update: (B) => s("update:modelValue", B),
change: (B) => s("change", B),
validation: (B, N, ae) => s("validation", B, N, ae)
});
const {
themeClasses: w,
containerAttributes: x,
setColor: b,
setMode: v,
currentMode: $,
isDark: g,
isLight: p
} = Pr(), D = T(() => {
const B = he(r.minDate, r.locale);
return ke(B);
}), F = T(() => {
const B = he(r.maxDate, r.locale);
return ke(B);
}), P = T(() => S.value), J = T(() => r.calendar === "gregory"), _ = T(() => !!(M.value && M.value.trim())), K = T(() => {
r.locale;
const B = {
selectDate: o("general.selectDate"),
year: o("date.year"),
month: o("date.month"),
day: o("date.day"),
hour: o("time.hour"),
minute: o("time.minute"),
second: o("time.second")
};
return {
selectDate: r.placeholderOverrides?.selectDate || B.selectDate,
// 時間相關
hour: r.placeholderOverrides?.hour || B.hour,
minute: r.placeholderOverrides?.minute || B.minute,
second: r.placeholderOverrides?.second || B.second,
// 日期相關
year: r.placeholderOverrides?.year || B.year,
month: r.placeholderOverrides?.month || B.month,
day: r.placeholderOverrides?.day || B.day
};
}), Z = T(() => ({
...c.mergedErrors.value,
...h.value
})), O = T(() => {
const ae = {
...c.mergedErrorParams?.value || {},
...{}
};
return Object.keys(ae).length > 0 ? ae : {};
}), R = T(() => Object.keys(Z.value).length > 0);
er(() => {
if (!kr(r.dateFormat) && r.calendar === "gregory") {
const B = r.dateFormat, N = Do(r.dateFormat);
h.value.dateFormat = "format.invalid", console.warn(`日期格式 "${B}" 不正確,已自動修復為 "${N}"`), S.value = N;
}
if (r.showTime && !oa(d.value)) {
const B = d.value, N = bo(d.value);
if (oa(N))
h.value.timeFormat = "format.invalid", console.warn(`時間格式 "${B}" 不正確,已自動修復為 "${N}"`), d.value = N;
else {
const ae = k.value;
h.value.timeFormat = "format.invalid", console.warn(`時間格式 "${B}" 不正確,已使用預設格式 "${ae}"`), d.value = ae;
}
}
}), de(() => r.theme, (B) => {
B && b(B);
}, { immediate: !0 }), de(() => r.mode, (B) => {
v(B);
}, { immediate: !0 }), de(() => r.locale, (B) => {
B && n(B, r.customLocaleMessages);
}, { immediate: !0 }), de(() => r.customLocaleMessages, (B) => {
B && r.locale && n(r.locale, B);
}), de([() => r.enableSeconds, () => r.use24Hour, () => r.timeFormat], () => {
r.timeFormat || (d.value = k.value);
}, { immediate: !0 }), de(() => r.calendar, (B) => {
me.isCalendarSupported(B) ? delete h.value.calendar : h.value.calendar = "calendar.unsupported";
}, { immediate: !0 }), e({
// 基本操作
focus: c.focus,
reset: c.reset,
validate: c.validate,
selectNow: c.selectNow,
// 數據獲取
getDateTime: () => c.internalDateTime.value,
setDateTime: (B) => {
c.setExternalValue(B);
},
// 主題控制
setTheme: b,
setDarkMode: () => v("dark"),
setLightMode: () => v("light"),
setAutoMode: () => v("auto"),
getCurrentMode: () => $.value,
isDarkMode: () => g.value,
isLightMode: () => p.value,
// 錯誤相關
getErrors: () => Z.value,
hasErrors: () => R.value
});
const {
// 狀態
inputDateValue: M,
inputTimeValue: H,
showCalendar: U,
internalDateTime: X,
calendarMinDate: ie,
calendarMaxDate: se,
getValidDefaultTime: E,
hasValue: C,
// 事件處理
validateDateInput: q,
validateTimeInput: G,
handleDateComplete: Y,
handleTimeComplete: W,
handleCalendarSelect: ee,
handleTimeSelect: fe,
handleContainerClick: ye,
handleContainerMouseDown: be,
handleNavigateToDate: Ye,
// 日曆控制
toggleCalendar: $e,
// 清除功能
reset: te
} = c;
return (B, N) => (A(), L(pe, null, [
j("div", tr({
class: ["date-picker-wrapper relative w-full min-w-0 justify-self-start", [V(w), t.showTime ? "min-w-[270px]" : "min-w-[150px]"]]
}, V(x), {
ref_key: "containerRef",
ref: i
}), [
t.name ? (A(), L("input", {
key: 0,
type: "hidden",
name: t.name,
value: t.modelValue || ""
}, null, 8, ds)) : oe("", !0),
j("div", {
class: De(["date-picker-container flex w-full items-center px-2 py-1 gap-1 bg-vdt-surface text-vdt-content rounded-sm transition-all duration-200 disabled:opacity-50 disabled:cursor-not-allowed", [{ "border-red-500 ring-2 ring-red-200": R.value }]])
}, [
t.showCalendarIcon ? (A(), L("button", {
key: 0,
type: "button",
class: "date-picker-icon text-gray-400 hover:text-gray-500 transition-colors disabled:cursor-not-allowed disabled:opacity-50 flex-shrink-0",
disabled: t.disabled,
"aria-label": "開啟日曆",
onClick: N[0] || (N[0] = Me((ae) => V($e)?.(), ["stop", "prevent"]))
}, [
ce(Yr, { class: "size-5" })
], 8, fs)) : oe("", !0),
J.value && t.inputEnabled ? (A(), L("div", {
key: 1,
class: De(["flex-1 flex w-full items-center justify-start gap-2", [t.disabled ? "cursor-not-allowed cursor-event-none opacity-50" : ""]]),
onClick: N[3] || (N[3] = Me(
//@ts-ignore
(...ae) => V(ye) && V(ye)(...ae),
["stop"]
)),
onMousedown: N[4] || (N[4] = //@ts-ignore
(...ae) => V(be) && V(be)(...ae))
}, [
j("div", null, [
ce(sa, {
ref_key: "dateInputRef",
ref: y,
modelValue: V(M),
"onUpdate:modelValue": N[1] || (N[1] = (ae) => wa(M) ? M.value = ae : null),
"year-placeholder": K.value.year,
"month-placeholder": K.value.month,
"day-placeholder": K.value.day,
"min-date": D.value,
"max-date": F.value,
required: t.required,
separator: t.dateSeparator,
"date-format": P.value,
"input-id": t.id,
disabled: t.disabled,
onValidation: V(q),
onComplete: V(Y)
}, null, 8, ["modelValue", "year-placeholder", "month-placeholder", "day-placeholder", "min-date", "max-date", "required", "separator", "date-format", "input-id", "disabled", "onValidation", "onComplete"])
]),
t.showTime ? (A(), L("div", ms, [
ce(ia, {
ref_key: "timeInputRef",
ref: m,
modelValue: V(H),
"onUpdate:modelValue": N[2] || (N[2] = (ae) => wa(H) ? H.value = ae : null),
"hour-placeholder": K.value.hour,
"minute-placeholder": K.value.minute,
"second-placeholder": K.value.second,
"enable-seconds": t.enableSeconds,
use24Hour: t.use24Hour,
required: t.required,
locale: t.locale,
useLocalizedPeriod: t.useLocalizedPeriod,
disabled: t.disabled,
onValidation: V(G),
onComplete: V(W),
onNavigateToDate: V(Ye)
}, null, 8, ["modelValue", "hour-placeholder", "minute-placeholder", "second-placeholder", "enable-seconds", "use24Hour", "required", "locale", "useLocalizedPeriod", "disabled", "onValidation", "onComplete", "onNavigateToDate"])
])) : oe("", !0)
], 34)) : (A(), L("button", {
key: 2,
type: "button",
class: De(["flex-1 flex w-full h-full items-center justify-start gap-1", {
"cursor-not-allowed opacity-50": t.disabled
}]),
onClick: N[5] || (N[5] = Me((ae) => !t.disabled && V($e)?.(), ["stop"])),
onKeydown: [
N[6] || (N[6] = Fe(Me((ae) => !t.disabled && V($e)?.(), ["prevent"]), ["enter"])),
N[7] || (N[7] = Fe(Me((ae) => !t.disabled && V($e)?.(), ["prevent"]), ["space"]))
]
}, [
_.value ? (A(), L("span", hs, ne(t.modelValue), 1)) : (A(), L("span", vs, ne(K.value.selectDate), 1))
], 34)),
V(C) && !t.disabled && t.showClearButton ? (A(), L("button", {
key: 3,
type: "button",
class: "date-picker-icon text-gray-400 hover:text-red-500",
"aria-label": "清除日期",
onClick: N[8] || (N[8] = Me(
//@ts-ignore
(...ae) => V(te) && V(te)(...ae),
["stop", "prevent"]
))
}, [
ce(Ir, { class: "size-5" })
])) : oe("", !0)
], 2),
V(U) && !t.disabled ? (A(), L("div", {
key: 1,
ref_key: "calendarRef",
ref: f,
class: "calendar-container absolute mt-1 bg-vdt-surface-elevated border border-vdt-outline rounded-lg shadow-lg z-10",
onClick: N[9] || (N[9] = Me(() => {
}, ["stop"])),
role: "dialog",
"aria-modal": "true",
"aria-label": "date-picker"
}, [
ce(ua, {
value: V(X),
weekStartsOn: t.weekStartsOn,
"min-date": V(ie),
"max-date": V(se),
showTimeSelector: t.showTime,
"time-value": V(H),
use24Hour: t.use24Hour,
"default-time": V(E),
enableSeconds: t.enableSeconds,
locale: t.locale,
calendar: t.calendar,
onSelect: V(ee),
onTimeSelect: V(fe)
}, dt({ _: 2 }, [
ge(u.value, (ae, Ee) => ({
name: Ee,
fn: ft((nt) => [
ve(B.$slots, Ee, mt(ht(nt)))
])
}))
]), 1032, ["value", "weekStartsOn", "min-date", "max-date", "showTimeSelector", "time-value", "use24Hour", "default-time", "enableSeconds", "locale", "calendar", "onSelect", "onTimeSelect"])
], 512)) : oe("", !0)
], 16),
t.showErrorMessage && R.value ? (A(), L("div", ys, [
ve(B.$slots, "error", {
errors: Z.value,
errorParams: O.value,
hasErrors: R.value
}, () => [
ce(Cr, {
errors: Z.value,
locale: t.locale,
"use-i18n": t.useI18n,
"custom-messages": t.customErrorMessages,
errorParams: O.value
}, dt({ _: 2 }, [
ge(B.$slots, (ae, Ee) => ({
name: Ee,
fn: ft((nt) => [
ve(B.$slots, Ee, mt(ht(nt)))
])
}))
]), 1032, ["errors", "locale", "use-i18n", "custom-messages", "errorParams"])
])
])) : oe("", !0)
], 64));
}
}), gs = {
key: 0,
class: "calendar-container flex-1 md:min-w-[280px] min-w-auto"
}, ps = /* @__PURE__ */ Te({
__name: "RangeCalendar",
props: {
rangeStart: { default: null },
rangeEnd: { default: null },
minDate: { default: null },
maxDate: { default: null },
locale: { default: "zh-TW" },
weekStartsOn: { default: 0 },
calendar: { default: "gregory" },
showTimeSelector: { type: Boolean, default: !1 },
startTimeValue: { default: null },
endTimeValue: { default: null },
enableSeconds: { type: Boolean, default: !0 },
use24Hour: { type: Boolean, default: !0 },
monthDisplayMode: { default: "dual" },
initialYear: { default: () => Xe().year },
initialMonth: { default: () => Xe().month }
},
emits: ["range-select", "time-select"],
setup(t, { expose: e, emit: a }) {
const r = t, n = a, o = z({
isSelecting: !1,
tempStart: null,
activeTimeTarget: "start"
}), s = () => {
if (r.rangeStart)
return { year: r.rangeStart.year, month: r.rangeStart.month };
if (r.initialYear && r.initialMonth)
return { year: r.initialYear, month: r.initialMonth };
const b = Xe();
return { year: b.year, month: b.month };
}, { year: l, month: u } = s(), i = z(l), f = z(u), y = T(() => f.value === 12 ? i.value + 1 : i.value), m = T(() => f.value === 12 ? 1 : f.value + 1), k = T(() => r.monthDisplayMode === "single" ? o.value.activeTimeTarget === "start" ? r.startTimeValue : r.endTimeValue : r.startTimeValue), S = T(() => r.endTimeValue), d = T(() => r.monthDisplayMode === "single" ? o.value.activeTimeTarget : "start");
de(() => [r.rangeStart, r.rangeEnd], ([b, v]) => {
b && !r.initialYear && !r.initialMonth && (i.value = b.year, f.value = b.month), r.monthDisplayMode === "single" ? b && v ? (o.value.isSelecting = !1, o.value.tempStart = null, o.value.activeTimeTarget = "start") : b && !v ? (o.value.isSelecting = !0, o.value.tempStart = b, o.value.activeTimeTarget = "end") : (o.value.isSelecting = !1, o.value.tempStart = null, o.value.activeTimeTarget = "start") : b && v ? (o.value.isSelecting = !1, o.value.tempStart = null) : b && !v ? (o.value.isSelecting = !0, o.value.tempStart = b) : (o.value.isSelecting = !1, o.value.tempStart = null);
}, { immediate: !0, deep: !0 });
const h = (b, v) => {
if (!b) {
o.value.isSelecting = !1, o.value.tempStart = null, r.monthDisplayMode === "single" && (o.value.activeTimeTarget = "start"), n("range-select", null, null);
return;
}
if (!o.value.isSelecting)
o.value.isSelecting = !0, o.value.tempStart = b, r.monthDisplayMode === "single" && (o.value.activeTimeTarget = "start"), n("range-select", b, null);
else {
const $ = o.value.tempStart;
if ($ && (b.year !== $.year || b.month !== $.month || b.day !== $.day)) {
o.value.isSelecting = !1, o.value.tempStart = null;
const g = $.year * 1e4 + $.month * 100 + $.day, p = b.year * 1e4 + b.month * 100 + b.day;
g <= p ? n("range-select", $, b) : n("range-select", b, $), r.monthDisplayMode === "single" && (o.value.activeTimeTarget = "end");
} else
o.value.tempStart = b, r.monthDisplayMode === "single" && (o.value.activeTimeTarget = "start"), n("range-select", b, null);
}
}, c = (b, v) => {
n("time-select", b, v);
};
return e({
// 獲取當前顯示的月份
getCurrentDisplay: () => r.monthDisplayMode === "single" ? {
year: i.value,
month: f.value
} : {
left: { year: i.value, month: f.value },
right: { year: y.value, month: m.value }
},
// 設置顯示月份
setDisplayMonth: (b, v) => {
i.value = b, f.value = v;
},
// 重置範圍選擇狀態
resetRangeSelection: () => {
o.value.isSelecting = !1, o.value.tempStart = null, r.monthDisplayMode === "single" && (o.value.activeTimeTarget = "start");
},
// 獲取當前選擇狀態
getSelectionState: () => ({
isSelecting: o.value.isSelecting,
tempStart: o.value.tempStart,
activeTimeTarget: o.value.activeTimeTarget
}),
// 月份導航
previousMonth: () => {
f.value === 1 ? (f.value = 12, i.value -= 1) : f.value -= 1;
},
nextMonth: () => {
f.value === 12 ? (f.value = 1, i.value += 1) : f.value += 1;
},
handleRangeSelect: h
}), (b, v) => (A(), L("div", {
class: De(["range-calendar", [
t.monthDisplayMode === "single" ? "single-month" : "dual-month",
"flex flex-col gap-4",
t.monthDisplayMode === "dual" ? "min-w-auto md:min-w-[570px] md:flex-row" : "min-w-auto max-w-[300px]",
"m-1"
]])
}, [
j("div", {
class: De(["calendar-container flex-1", [
t.monthDisplayMode === "dual" ? "min-w-auto md:min-w-[280px]" : "min-w-auto"
]])
}, [
ce(ua, {
"range-start": t.rangeStart,
"range-end": t.rangeEnd,
"selection-mode": "range",
year: i.value,
month: f.value,
"min-date": t.minDate,
"max-date": t.maxDate,
locale: t.locale,
"week-starts-on": t.weekStartsOn,
calendar: t.calendar,
showTimeSelector: t.showTimeSelector,
"time-value": k.value,
"enable-seconds": t.enableSeconds,
"use24-hour": t.use24Hour,
onRangeSelect: h,
onTimeSelect: v[0] || (v[0] = ($) => c($, d.value))
}, null, 8, ["range-start", "range-end", "year", "month", "min-date", "max-date", "locale", "week-starts-on", "calendar", "showTimeSelector", "time-value", "enable-seconds", "use24-hour"])
], 2),
t.monthDisplayMode === "dual" ? (A(), L("div", gs, [
ce(ua, {
"range-start": t.rangeStart,
"range-end": t.rangeEnd,
"selection-mode": "range",
year: y.value,
month: m.value,
"min-date": t.minDate,
"max-date": t.maxDate,
locale: t.locale,
"week-starts-on": t.weekStartsOn,
calendar: t.calendar,
showTimeSelector: t.showTimeSelector,
"time-value": S.value,
"enable-seconds": t.enableSeconds,
"use24-hour": t.use24Hour,
onRangeSelect: h,
onTimeSelect: v[1] || (v[1] = ($) => c($, "end"))
}, null, 8, ["range-start", "range-end", "year", "month", "min-date", "max-date", "locale", "week-starts-on", "calendar", "showTimeSelector", "time-value", "enable-seconds", "use24-hour"])
])) : oe("", !0)
], 2));
}
}), bt = "00:00:00", Mt = "23:59:59";
function $s(t = {}, e) {
const {
calendar: a = "gregory",
modelValue: r = null,
showTime: n = !1,
required: o = !1,
incomplete: s = !1,
dateFormat: l = "YYYY-MM-DD",
timeFormat: u = "HH:mm:ss",
outputType: i = "iso",
useStrictISO: f = !1,
enableSeconds: y = !1,
minDate: m,
maxDate: k,
maxRange: S,
minRange: d,
locale: h = "zh-TW"
} = t, {
containerRef: c,
calendarRef: w,
startDateInputRef: x,
endDateInputRef: b,
startTimeInputRef: v,
endTimeInputRef: $
} = e, g = T(() => t.disabled?.value ?? !1);
let p = {};
const D = da({
required: o,
showTime: n,
minDate: m,
maxDate: k,
dateFormat: l
}), F = da({
required: o,
showTime: n,
minDate: m,
maxDate: k,
dateFormat: l
}), P = fa({
showTime: n,
dateFormat: l,
timeFormat: u,
outputType: i,
defaultTime: bt,
enableSeconds: y
}), J = fa({
showTime: n,
dateFormat: l,
timeFormat: u,
outputType: i,
defaultTime: Mt,
enableSeconds: y
}), _ = Or(
c,
w,
{ disabled: g }
), K = ca(
{ dateInputRef: x, timeInputRef: v },
{ showTime: n, autoFocusTimeAfterDate: !0 }
), Z = ca(
{ dateInputRef: b, timeInputRef: $ },
{ showTime: n, autoFocusTimeAfterDate: !0 }
), O = T(
() => P.hasValue.value || J.hasValue.value
), R = T(() => {
const I = {
...D.mergedErrors.value,
...F.mergedErrors.value
};
return P.internalDateTime.value && !J.internalDateTime.value && s && (I["range.endRequired"] = "range.endRequired"), I;
}), M = T(() => ({
...D.mergedErrorParams.value,
...F.mergedErrorParams.value
})), H = T(() => Object.keys(R.value).length > 0), U = T(() => {
const I = P.internalDateTime.value, Q = J.internalDateTime.value;
if (!I || !Q || Ht(I, Q) > 0) return !1;
if (S || d) {
const re = Qa(I, Q);
if (S && re > S)
return F.handleDateValidation(!1, {
range: "range.exceedsMaxRange"
}, "endDate", {
range: { maxRange: S, actualDays: re }
}), !1;
if (d && re < d)
return F.handleDateValidation(!1, {
range: "range.belowMinRange"
}, "endDate", {
range: { minRange: d, actualDays: re }
}), !1;
F.clearFieldErrors("range");
}
return !H.value;
}), X = T(() => [
{
label: "今天",
getValue: () => {
const I = Ke();
return {
start: Ae(I.year, I.month, I.day, 0, 0, 0),
end: Ae(I.year, I.month, I.day, 23, 59, 59)
};
}
},
{
label: "最近7天",
getValue: () => ({
start: na(Ke(), -6),
end: Ke()
})
},
{
label: "最近30天",
getValue: () => ({
start: na(Ke(), -29),
end: Ke()
})
},
{
label: "本月",
getValue: po
}
]), ie = T(() => ({
minDate: he(m, h),
maxDate: J.internalDateTime.value || he(k, h)
})), se = T(() => ({
minDate: P.internalDateTime.value || he(m, h),
maxDate: he(k, h)
})), E = T(() => ({
minDate: ie.value.minDate ? ke(ie.value.minDate, l) : null,
maxDate: ie.value.maxDate ? ke(ie.value.maxDate, l) : null
})), C = T(() => ({
minDate: se.value.minDate ? ke(se.value.minDate, l) : null,
maxDate: se.value.maxDate ? ke(se.value.maxDate, l) : null
}));
function q(I, Q) {
const re = Qa(I, Q);
return S && re > S ? {
valid: !1,
error: "range.exceedsMaxRange",
params: { maxRange: S, actualDays: re }
} : d && re < d ? {
valid: !1,
error: "range.belowMinRange",
params: { minRange: d, actualDays: re }
} : { valid: !0 };
}
function G(I) {
!I.error || !I.params || F.handleDateValidation(
!1,
{ range: I.error },
"endDate",
{ range: I.params }
);
}
function Y() {
if (!P.internalDateTime.value || !J.internalDateTime.value) {
p.update?.(null), p.change?.(null);
return;
}
const I = n ? u : void 0, Q = {
start: Lt(
P.internalDateTime.value,
i,
l,
I,
n,
a,
h,
f,
y
),
end: Lt(
J.internalDateTime.value,
i,
l,
I,
n,
a,
h,
f,
y
)
};
p.update?.(Q), p.change?.(Q);
const re = U.value && !H.value;
p.validation?.(re, R.value, M.value);
}
function W(I, Q) {
Q.forEach((re) => I.clearFieldErrors(re));
}
const ee = (I) => {
p = I;
}, fe = (I, Q, re, zr, Wr) => {
re.handleDateValidation(I, Q, zr, Wr), p.validation?.(!H.value, R.value, M.value);
}, ye = (I, Q, re) => {
fe(I, Q, D, "startDate", re);
}, be = (I, Q, re) => {
fe(I, Q, F, "endDate", re);
}, Ye = (I, Q, re = {}) => {
D.handleTimeValidation(I, Q, "startTime", re), p.validation?.(!H.value, R.value);
}, $e = (I, Q, re = {}) => {
F.handleTimeValidation(I, Q, "endTime", re), p.validation?.(!H.value, R.value, M.value);
}, te = (I) => {
P.inputDateValue.value = I;
const Q = P.updateFromInputs();
if (!Q) {
D.handleDateValidation(!1, { date: "date.invalid" });
return;
}
D.validateDateRange(Q) && (K.autoFocusTimeAfterDateComplete(
P,
bt
), Y(), W(D, ["startDate", "date.year", "date.month", "date.day"]), n || Z.focusFirstInput());
}, B = (I) => {
J.inputDateValue.value = I;
const Q = J.updateFromInputs();
if (!Q) {
F.handleDateValidation(!1, { date: "date.invalid" });
return;
}
F.validateDateRange(Q) && (Z.autoFocusTimeAfterDateComplete(
J,
Mt
), Y(), W(F, ["endDate", "date.year", "date.month", "date.day"]));
}, N = (I) => {
P.inputTimeValue.value = I, P.updateFromInputs() && Y(), W(D, ["startTime", "time.hour", "time.minute", "time.second"]);
}, ae = (I) => {
J.inputTimeValue.value = I, J.updateFromInputs() && Y(), W(F, ["endTime", "time.hour", "time.minute", "time.second"]);
}, Ee = (I, Q) => {
I && !Q ? nt(I) : I && Q ? Ar(I, Q) : zt(), Y();
};
function nt(I) {
D.validateDateRange(I) && (P.setInternalDateTime(I), W(D, ["startDate", "date.year", "date.month", "date.day"]), J.clearValues());
}
function Ar(I, Q) {
if (!(!D.validateDateRange(I) || !F.validateDateRange(Q))) {
if (S || d) {
const re = q(I, Q);
if (!re.valid) {
G(re);
return;
}
}
P.setInternalDateTime(I), J.setInternalDateTime(Q), n && (P.inputTimeValue.value || (P.inputTimeValue.value = bt, P.updateFromInputs()), J.inputTimeValue.value || (J.inputTimeValue.value = Mt, J.updateFromInputs())), W(D, ["startDate", "endDate", "range", "date.year", "date.month", "date.day"]), W(F, ["startDate", "endDate", "range", "date.year", "date.month", "date.day"]);
}
}
const Lr = (I, Q) => {
Q === "start" && P.internalDateTime.value && N(I), Q === "end" && J.internalDateTime.value && ae(I);
}, Hr = (I) => {
const Q = I.getValue();
P.setInternalDateTime(Q.start), J.setInternalDateTime(Q.end), n && (P.inputTimeValue.value || (P.inputTimeValue.value = bt, P.updateFromInputs()), J.inputTimeValue.value || (J.inputTimeValue.value = Mt, J.updateFromInputs())), Y();
}, zt = () => {
P.clearValues(), J.clearValues(), D.clearAllErrors(), F.clearAllErrors(), Y();
}, Br = (I) => {
I ? (P.setExternalValue(I.start), J.setExternalValue(I.end)) : zt(), Y();
}, qr = () => (x.value?.validate(), b.value?.validate(), n && (v.value?.validate(), $.value?.validate()), U.value), Nr = (I) => {
_.handleContainerClick(I, () => {
K.focusFirstInput();
});
}, Ur = (I) => {
_.handleContainerClick(I, () => {
Z.focusFirstInput();
});
};
return de(() => r, (I) => {
if (I && (I.start || I.end)) {
const Q = I.start ? he(I.start, h, a) : null, re = I.end ? he(I.end, h, a) : null;
if (I.start && !Q && (console.warn(`Invalid start date provided: ${I.start}`), D.handleDateValidation(!1, { date: "date.invalid" }, "startDate")), I.end && !re && (console.warn(`Invalid end date provided: ${I.end}`), F.handleDateValidation(!1, { date: "date.invalid" }, "endDate")), Q && re && Ht(Q, re) > 0) {
console.warn("Initial date range has start > end, auto-swapping values"), P.setExternalValue(I.end), J.setExternalValue(I.start), setTimeout(() => {
Y();
}, 0);
return;
}
P.setExternalValue(Q ? I.start : null), J.setExternalValue(re ? I.end : null);
} else
P.clearValues(), J.clearValues();
}, { immediate: !0 }), {
// 狀態
isDisabled: g,
startDateConstraints: ie,
endDateConstraints: se,
startDateConstraintsStr: E,
endDateConstraintsStr: C,
// 驗證相關
hasErrors: H,
mergedErrors: R,
mergedErrorParams: M,
isValidRange: U,
// 日期時間值
startDateTime: P,
endDateTime: J,
// 顯示值
hasRangeValue: O,
// 日曆相關
..._,
// 快捷選項
shortcuts: X,
// 事件設置
setEmitters: ee,
// 驗證事件處理
handleStartDateValidation: ye,
handleEndDateValidation: be,
handleStartTimeValidation: Ye,
handleEndTimeValidation: $e,
// 完成事件處理
handleStartDateComplete: te,
handleEndDateComplete: B,
handleStartTimeComplete: N,
handleEndTimeComplete: ae,
// 日曆事件處理
handleCalendarRangeSelect: Ee,
handleTimeSelect: Lr,
// 導航事件處理
handleStartNavigateToDate: K.handleNavigateToDate,
handleEndNavigateToDate: Z.handleNavigateToDate,
// 主要操作
applyShortcut: Hr,
clearRange: zt,
setRange: Br,
validate: qr,
// 導航方法
focusStartDate: Nr,
focusEndDate: Ur
};
}
function Ds() {
const t = z(typeof window < "u" ? window.innerWidth : 0), e = z(typeof window < "u" ? window.innerHeight : 0), a = () => {
t.value = window.innerWidth, e.value = window.innerHeight;
};
return Bt(() => {
a(), window.addEventListener("resize", a);
}), qt(() => {
window.removeEventListener("resize", a);
}), { width: t, height: e };
}
const bs = ["disabled"], Ms = ["disabled"], ws = ["title"], Ss = {
key: 0,
class: "date-placeholder text-vdt-content truncate block"
}, ks = {
key: 1,
class: "date-placeholder text-vdt-content-muted truncate block"
}, xs = {
class: "text-vdt-content-muted text-sm px-1",
"aria-label": "日期範圍分隔符",
"data-testid": "separator"
}, Ts = ["title"], Cs = {
key: 0,
class: "date-placeholder text-vdt-content truncate block"
}, Ys = {
key: 1,
class: "date-placeholder text-vdt-content-muted truncate block"
}, Rs = ["title"], Es = { class: "p-2 space-y-2" }, Is = {
key: 0,
class: "w-full flex flex-col md:flex-row flex-justify-between gap-2"
}, Os = {
key: 0,
"data-testid": "start-time-inputs",
"aria-label": "開始時間輸入區域"
}, Vs = {
key: 0,
"data-testid": "end-time-inputs",
"aria-label": "結束時間輸入區域"
}, Fs = {
key: 1,
"aria-label": "日期範圍快捷選項"
}, Ps = { class: "flex flex-wrap gap-2" }, As = ["aria-label", "data-testid", "onClick"], Ls = { key: 2 }, Hs = { class: "flex flex-wrap gap-2" }, Bs = { class: "calendar-container overflow-auto" }, qs = { key: 0 }, Ns = /* @__PURE__ */ Te({
__name: "DateRange",
props: {
modelValue: { default: null },
monthDisplayMode: {},
placeholderOverrides: { default: () => ({}) },
separator: { default: " ~ " },
showShortcuts: { type: Boolean, default: !0 },
incomplete: { type: Boolean, default: !0 },
maxRange: { default: void 0 },
minRange: { default: void 0 },
mode: { default: "auto" },
theme: { default: () => "violet" },
calendar: { default: "gregory" },
locale: { default: "zh-TW" },
customLocaleMessages: {},
outputType: { default: "iso" },
useStrictISO: { type: Boolean, default: !1 },
weekStartsOn: { default: 0 },
minDate: { default: void 0 },
maxDate: { default: void 0 },
dateSeparator: { default: "-" },
dateFormat: { default: "YYYY-MM-DD" },
timeFormat: {},
showTime: { type: Boolean, default: !1 },
enableSeconds: { type: Boolean, default: !0 },
use24Hour: { type: Boolean, default: !0 },
useLocalizedPeriod: { type: Boolean, default: !1 },
disabled: { type: Boolean, default: !1 },
inputEnabled: { type: Boolean, default: !1 },
required: { type: Boolean, default: !1 },
showClearButton: { type: Boolean, default: !0 },
showCalendarIcon: { type: Boolean, default: !0 },
id: {},
name: {},
showErrorMessage: { type: Boolean, default: !0 },
useI18n: { type: Boolean, default: !0 },
customErrorMessages: { default: () => ({}) }
},
emits: ["update:modelValue", "change", "validation"],
setup(t, { expose: e, emit: a }) {
const r = t, n = a, o = z(null), s = z(null), l = z(null), u = z(null), i = z(null), f = z(null), y = z({}), { width: m } = Ds(), k = T(() => r.monthDisplayMode ? r.monthDisplayMode : m.value < 768 ? "single" : "dual"), S = T(() => r.timeFormat ? r.timeFormat : r.enableSeconds ? r.use24Hour ? "HH:mm:ss" : "hh:mm:ss A" : r.use24Hour ? "HH:mm" : "hh:mm A"), d = $s(
{
calendar: r.calendar,
modelValue: r.modelValue,
showTime: r.showTime,
required: r.required,
disabled: it(r, "disabled"),
dateFormat: r.dateFormat,
timeFormat: S.value,
outputType: r.outputType,
useStrictISO: r.useStrictISO,
enableSeconds: r.enableSeconds,
minDate: r.minDate,
maxDate: r.maxDate,
maxRange: r.maxRange,
minRange: r.minRange,
incomplete: r.incomplete,
locale: r.locale
},
{
containerRef: o,
calendarRef: s,
startDateInputRef: l,
endDateInputRef: u,
startTimeInputRef: i,
endTimeInputRef: f
}
), { setLocale: h, getPlaceholderMessage: c } = pt(r.locale);
d.setEmitters({
update: (te) => n("update:modelValue", te),
change: (te) => n("change", te),
validation: (te, B, N) => n("validation", te, B, N)
});
const {
themeClasses: w,
containerAttributes: x,
setColor: b,
setMode: v
} = Pr(), $ = T(() => {
const te = {
start: c("range.start"),
end: c("range.end"),
year: c("date.year"),
month: c("date.month"),
day: c("date.day"),
hour: c("time.hour"),
minute: c("time.minute"),
second: c("time.second")
};
return {
start: r.placeholderOverrides?.start || te.start,
end: r.placeholderOverrides?.end || te.end,
// 時間相關
hour: r.placeholderOverrides?.hour || te.hour,
minute: r.placeholderOverrides?.minute || te.minute,
second: r.placeholderOverrides?.second || te.second,
// 日期相關
year: r.placeholderOverrides?.year || te.year,
month: r.placeholderOverrides?.month || te.month,
day: r.placeholderOverrides?.day || te.day
};
}), g = T(() => r.dateFormat), p = T(() => ({
...d.mergedErrors.value,
...y.value
})), D = T(() => Object.keys(R.value).length > 0);
de(() => r.theme, (te) => {
te && b(te);
}, { immediate: !0 }), de(() => r.mode, (te) => {
v(te);
}, { immediate: !0 }), de(() => r.locale, (te) => {
te && h(te);
}, { immediate: !0 }), de(() => r.calendar, (te) => {
me.isCalendarSupported(te) ? delete y.value.calendar : y.value.calendar = "calendar.unsupported";
}, { immediate: !0 }), er(() => {
h(r.locale);
}), e({
// 基本操作
reset: d.clearRange,
validate: d.validate,
setRange: d.setRange,
// 聚焦方法
focusStartDate: d.focusStartDate,
focusEndDate: d.focusEndDate,
// 主題控制
setTheme: b,
setDarkMode: () => v("dark"),
setLightMode: () => v("light"),
setAutoMode: () => v("auto"),
// 錯誤相關
getErrors: () => R.value,
hasErrors: () => D.value
});
const {
// 狀態
showCalendar: F,
startDateConstraintsStr: P,
endDateConstraintsStr: J,
shortcuts: _,
startDateTime: K,
endDateTime: Z,
hasRangeValue: O,
mergedErrors: R,
mergedErrorParams: M,
// 事件處理方法
handleStartDateValidation: H,
handleEndDateValidation: U,
handleStartTimeValidation: X,
handleEndTimeValidation: ie,
handleStartDateComplete: se,
handleEndDateComplete: E,
handleStartTimeComplete: C,
handleEndTimeComplete: q,
handleCalendarRangeSelect: G,
handleStartNavigateToDate: Y,
handleEndNavigateToDate: W,
handleTimeSelect: ee,
// 操作方法
toggleCalendar: fe,
applyShortcut: ye,
clearRange: be,
focusStartDate: Ye,
focusEndDate: $e
} = d;
return (te, B) => (A(), L(pe, null, [
j("div", tr({
class: ["date-range-wrapper relative w-full", [V(w), t.showTime ? "min-w-[300px]" : "min-w-[200px]"]]
}, V(x), {
ref_key: "containerRef",
ref: o
}), [
j("div", {
class: De(["date-picker-container flex w-full items-center px-2 py-1 gap-1 rounded-sm transition-all duration-200 bg-vdt-surface text-vdt-content overflow-hidden disabled:opacity-50 disabled:cursor-not-allowed", [{ "border-red-500 ring-2 ring-red-200": D.value }]])
}, [
t.showCalendarIcon ? (A(), L("button", {
key: 0,
type: "button",
"aria-label": "開啟日曆",
class: "date-picker-icon text-gray-400 hover:text-gray-500 transition-colors disabled:cursor-not-allowed disabled:opacity-50 flex-shrink-0",
disabled: t.disabled,
onClick: B[0] || (B[0] = Me((N) => V(fe)?.(), ["stop", "prevent"]))
}, [
ce(Yr, { class: "size-5" })
], 8, bs)) : oe("", !0),
j("button", {
type: "button",
class: "grid grid-cols-[1fr_auto_1fr] gap-1 w-full cursor-pointer transition-colors duration-200 disabled:opacity-50 disabled:cursor-not-allowed",
disabled: t.disabled,
onClick: B[1] || (B[1] = //@ts-ignore
(...N) => V(fe) && V(fe)(...N)),
"aria-label": "選擇日期範圍"
}, [
j("div", {
class: "text-center min-w-0 max-w-[130px] sm:max-w-none",
title: $.value.start,
"aria-label": "開始日期"
}, [
t.modelValue?.start ? (A(), L("span", Ss, ne(t.modelValue?.start), 1)) : (A(), L("span", ks, ne($.value.start), 1))
], 8, ws),
j("div", xs, ne(t.separator), 1),
j("div", {
class: "text-center min-w-0 max-w-[130px] sm:max-w-none",
title: $.value.end,
"aria-label": "結束日期"
}, [
t.modelValue?.end ? (A(), L("span", Cs, ne(t.modelValue?.end), 1)) : (A(), L("span", Ys, ne($.value.end), 1))
], 8, Ts)
], 8, Ms),
V(O) && !t.disabled && t.showClearButton ? (A(), L("button", {
key: 1,
type: "button",
"aria-label": "清除日期",
class: "date-picker-icon text-gray-400 hover:text-red-500 disabled:cursor-not-allowed disabled:opacity-50",
onClick: B[2] || (B[2] = Me(
//@ts-ignore
(...N) => V(be) && V(be)(...N),
["stop"]
)),
title: "清除日期" + (t.showTime ? "時間" : "")
}, [
ce(Ir, { class: "size-5" })
], 8, Rs)) : oe("", !0)
], 2),
V(F) && !t.disabled ? (A(), L("div", {
key: 0,
ref_key: "calendarRef",
ref: s,
class: De(["absolute mt-1 bg-vdt-surface-elevated border border-vdt-outline rounded-lg shadow-lg z-10 overflow-auto", [
// 基本尺寸控制
"max-w-[95vw]",
// 響應式最大高度和滾動
"max-h-[80vh] overflow-auto",
// 小螢幕時確保足夠的邊距
"sm:max-h-[70vh]",
k.value === "single" ? "min-w-[275px]" : "min-w-[275px] md:min-w-[570px]"
]]),
onClick: B[9] || (B[9] = Me(() => {
}, ["stop"])),
role: "dialog",
"aria-modal": "true",
"aria-label": "date-range-picker"
}, [
j("div", Es, [
t.inputEnabled && k.value === "dual" ? (A(), L("div", Is, [
j("div", {
"data-testid": "start-date-inputs",
"aria-label": "開始日期輸入區域",
onClick: B[5] || (B[5] = Me(
//@ts-ignore
(...N) => V(Ye) && V(Ye)(...N),
["stop"]
)),
class: "flex-1 flex w-full items-center px-2 py-1 gap-2 border border-vdt-outline bg-vdt-surface text-vdt-content rounded-sm focus-within:ring-2 focus-within:border-vdt-theme-500 focus-within:ring-vdt-theme-200 transition-all duration-200"
}, [
ce(sa, {
ref_key: "startDateInputRef",
ref: l,
modelValue: V(K).inputDateValue.value,
"onUpdate:modelValue": B[3] || (B[3] = (N) => V(K).inputDateValue.value = N),
"year-placeholder": $.value.year,
"month-placeholder": $.value.month,
"day-placeholder": $.value.day,
"max-date": V(P).maxDate,
"min-date": V(P).minDate,
"date-format": g.value,
onValidation: V(H),
onComplete: V(se)
}, null, 8, ["modelValue", "year-placeholder", "month-placeholder", "day-placeholder", "max-date", "min-date", "date-format", "onValidation", "onComplete"]),
t.showTime ? (A(), L("div", Os, [
ce(ia, {
ref_key: "startTimeInputRef",
ref: i,
modelValue: V(K).inputTimeValue.value,
"onUpdate:modelValue": B[4] || (B[4] = (N) => V(K).inputTimeValue.value = N),
"hour-placeholder": $.value.hour,
"minute-placeholder": $.value.minute,
"second-placeholder": $.value.second,
"enable-seconds": t.enableSeconds,
use24Hour: t.use24Hour,
locale: t.locale,
onValidation: V(X),
onComplete: V(C),
onNavigateToDate: V(Y)
}, null, 8, ["modelValue", "hour-placeholder", "minute-placeholder", "second-placeholder", "enable-seconds", "use24Hour", "locale", "onValidation", "onComplete", "onNavigateToDate"])
])) : oe("", !0)
]),
j("div", {
"data-testid": "end-date-inputs",
"aria-label": "結束日期輸入區域",
onClick: B[8] || (B[8] = Me(
//@ts-ignore
(...N) => V($e) && V($e)(...N),
["stop"]
)),
class: "flex-1 flex w-full items-center gap-2 px-2 py-1 border border-vdt-outline bg-vdt-surface text-vdt-content rounded-sm focus-within:ring-2 focus-within:border-vdt-theme-500 focus-within:ring-vdt-theme-200 transition-all duration-200"
}, [
ce(sa, {
ref_key: "endDateInputRef",
ref: u,
modelValue: V(Z).inputDateValue.value,
"onUpdate:modelValue": B[6] || (B[6] = (N) => V(Z).inputDateValue.value = N),
"year-placeholder": $.value.year,
"month-placeholder": $.value.month,
"day-placeholder": $.value.day,
"min-date": V(J).minDate,
"max-date": V(J).maxDate,
"date-format": g.value,
onValidation: V(U),
onComplete: V(E)
}, null, 8, ["modelValue", "year-placeholder", "month-placeholder", "day-placeholder", "min-date", "max-date", "date-format", "onValidation", "onComplete"]),
t.showTime ? (A(), L("div", Vs, [
ce(ia, {
ref_key: "endTimeInputRef",
ref: f,
modelValue: V(Z).inputTimeValue.value,
"onUpdate:modelValue": B[7] || (B[7] = (N) => V(Z).inputTimeValue.value = N),
"hour-placeholder": $.value.hour,
"minute-placeholder": $.value.minute,
"second-placeholder": $.value.second,
"enable-seconds": t.enableSeconds,
use24Hour: t.use24Hour,
locale: t.locale,
onValidation: V(ie),
onComplete: V(q),
onNavigateToDate: V(W)
}, null, 8, ["modelValue", "hour-placeholder", "minute-placeholder", "second-placeholder", "enable-seconds", "use24Hour", "locale", "onValidation", "onComplete", "onNavigateToDate"])
])) : oe("", !0)
])
])) : oe("", !0),
V(_).length > 0 && t.showShortcuts ? (A(), L("div", Fs, [
j("div", Ps, [
(A(!0), L(pe, null, ge(V(_), (N) => (A(), L("button", {
key: N.label,
type: "button",
"aria-label": `選擇${N.label}範圍`,
"data-testid": `shortcut-${N.label.toLowerCase().replace(/\s+/g, "-")}`,
class: "px-3 py-1 text-xs bg-vdt-outline text-vdt-content hover:bg-vdt-interactive-hover rounded-sm transition-colors",
onClick: (ae) => V(ye)(N)
}, ne(N.label), 9, As))), 128)),
ve(te.$slots, "shortcuts", {
applyShortcut: V(ye),
shortcuts: V(_),
currentRange: t.modelValue
})
])
])) : te.$slots.shortcuts && t.showShortcuts ? (A(), L("div", Ls, [
j("div", Hs, [
ve(te.$slots, "shortcuts", {
applyShortcut: V(ye),
shortcuts: V(_),
currentRange: t.modelValue
})
])
])) : oe("", !0),
j("div", Bs, [
ce(ps, {
"month-display-mode": k.value,
showTimeSelector: t.showTime,
calendar: t.calendar,
"range-start": V(K).internalDateTime.value,
"range-end": V(Z).internalDateTime.value,
"start-time-value": V(K).inputTimeValue.value,
"end-time-value": V(Z).inputTimeValue.value,
locale: t.locale,
"week-starts-on": t.weekStartsOn,
"min-date": V(he)(t.minDate),
"max-date": V(he)(t.maxDate),
"enable-seconds": t.enableSeconds,
"use24-hour": t.use24Hour,
onRangeSelect: V(G),
onTimeSelect: V(ee)
}, null, 8, ["month-display-mode", "showTimeSelector", "calendar", "range-start", "range-end", "start-time-value", "end-time-value", "locale", "week-starts-on", "min-date", "max-date", "enable-seconds", "use24-hour", "onRangeSelect", "onTimeSelect"])
])
])
], 2)) : oe("", !0)
], 16),
t.showErrorMessage && D.value ? (A(), L("div", qs, [
ve(te.$slots, "error", {
errors: p.value,
hasErrors: D.value
}, () => [
ce(Cr, {
errors: V(R),
locale: t.locale,
"use-i18n": t.useI18n,
"custom-messages": t.customErrorMessages,
errorParams: V(M)
}, dt({ _: 2 }, [
ge(te.$slots, (N, ae) => ({
name: ae,
fn: ft((Ee) => [
ve(te.$slots, ae, mt(ht(Ee)))
])
}))
]), 1032, ["errors", "locale", "use-i18n", "custom-messages", "errorParams"])
])
])) : oe("", !0)
], 64));
}
}), ri = {
install(t) {
t.component("VueDatepicker", _a), t.component("DatePicker", _a), t.component("DateRange", Ns);
}
};
export {
_a as DatePicker,
Ns as DateRange,
xr as RocFormatPlugin,
ri as VueDatepicker,
ri as default
};