UNPKG

@tiaohsun/vue-datepicker

Version:

A Vue 3 datepicker with multi-calendar support, styled with Tailwind CSS

7,419 lines 260 kB
import { defineComponent as Ce, ref as W, computed as C, watch as de, createElementBlock as L, openBlock as A, Fragment as De, renderList as $e, withDirectives as Ee, createCommentVNode as ce, vModelText as We, toDisplayString as oe, nextTick as we, createElementVNode as _, withModifiers as Se, normalizeClass as ge, renderSlot as pe, onMounted as Ht, onBeforeUnmount as Bt, createVNode as ue, createTextVNode as ba, unref as V, withKeys as Fe, vModelSelect as Mt, createSlots as ct, withCtx as dt, normalizeProps as ft, guardReactiveProps as mt, isMemoSame as jr, createBlock as _r, useSlots as Jr, toRef as zt, onBeforeMount as Xa, mergeProps as er, isRef as Ma } from "vue";
import ie from "dayjs";
function vt(r) {
  return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
}
var St = { exports: {} }, Kr = St.exports, Sa;
function Qr() {
  return Sa || (Sa = 1, function(r, e) {
    (function(t, a) {
      r.exports = a();
    })(Kr, function() {
      var t = "minute", a = /[+-]\d\d(?::?\d\d)?/g, n = /([+-]|\d\d)/g;
      return function(o, l, s) {
        var u = l.prototype;
        s.utc = function(f) {
          var p = { date: f, utc: !0, args: arguments };
          return new l(p);
        }, u.utc = function(f) {
          var p = s(this.toDate(), { locale: this.$L, utc: !0 });
          return f ? p.add(this.utcOffset(), t) : p;
        }, u.local = function() {
          return s(this.toDate(), { locale: this.$L, utc: !1 });
        };
        var i = u.parse;
        u.parse = function(f) {
          f.utc && (this.$u = !0), this.$utils().u(f.$offset) || (this.$offset = f.$offset), i.call(this, f);
        };
        var m = u.init;
        u.init = function() {
          if (this.$u) {
            var f = this.$d;
            this.$y = f.getUTCFullYear(), this.$M = f.getUTCMonth(), this.$D = f.getUTCDate(), this.$W = f.getUTCDay(), this.$H = f.getUTCHours(), this.$m = f.getUTCMinutes(), this.$s = f.getUTCSeconds(), this.$ms = f.getUTCMilliseconds();
          } else m.call(this);
        };
        var g = u.utcOffset;
        u.utcOffset = function(f, p) {
          var d = this.$utils().u;
          if (d(f)) return this.$u ? 0 : d(this.$offset) ? g.call(this) : this.$offset;
          if (typeof f == "string" && (f = function(b) {
            b === void 0 && (b = "");
            var $ = b.match(a);
            if (!$) return null;
            var c = ("" + $[0]).match(n) || ["-", 0, 0], y = c[0], D = 60 * +c[1] + +c[2];
            return D === 0 ? 0 : y === "+" ? D : -D;
          }(f), f === null)) return this;
          var S = Math.abs(f) <= 16 ? 60 * f : f, w = this;
          if (p) return w.$offset = S, w.$u = f === 0, w;
          if (f !== 0) {
            var h = this.$u ? this.toDate().getTimezoneOffset() : -1 * this.utcOffset();
            (w = this.local().add(S + h, t)).$offset = S, w.$x.$localOffset = h;
          } else w = this.utc();
          return w;
        };
        var v = u.format;
        u.format = function(f) {
          var p = f || (this.$u ? "YYYY-MM-DDTHH:mm:ss[Z]" : "");
          return v.call(this, p);
        }, u.valueOf = function() {
          var f = this.$utils().u(this.$offset) ? 0 : this.$offset + (this.$x.$localOffset || this.$d.getTimezoneOffset());
          return this.$d.valueOf() - 6e4 * f;
        }, 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(f) {
          return f === "s" && this.$offset ? s(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate() : k.call(this);
        };
        var T = u.diff;
        u.diff = function(f, p, d) {
          if (f && this.$u === f.$u) return T.call(this, f, p, d);
          var S = this.local(), w = s(f).local();
          return T.call(S, w, p, d);
        };
      };
    });
  }(St)), St.exports;
}
var Zr = Qr();
const Gr = /* @__PURE__ */ vt(Zr);
var wt = { exports: {} }, Xr = wt.exports, wa;
function en() {
  return wa || (wa = 1, function(r, e) {
    (function(t, a) {
      r.exports = a();
    })(Xr, function() {
      var t = { year: 0, month: 1, day: 2, hour: 3, minute: 4, second: 5 }, a = {};
      return function(n, o, l) {
        var s, u = function(v, k, T) {
          T === void 0 && (T = {});
          var f = new Date(v), p = function(d, S) {
            S === void 0 && (S = {});
            var w = S.timeZoneName || "short", h = d + "|" + w, b = a[h];
            return b || (b = new Intl.DateTimeFormat("en-US", { hour12: !1, timeZone: d, year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit", timeZoneName: w }), a[h] = b), b;
          }(k, T);
          return p.formatToParts(f);
        }, i = function(v, k) {
          for (var T = u(v, k), f = [], p = 0; p < T.length; p += 1) {
            var d = T[p], S = d.type, w = d.value, h = t[S];
            h >= 0 && (f[h] = parseInt(w, 10));
          }
          var b = f[3], $ = b === 24 ? 0 : b, c = f[0] + "-" + f[1] + "-" + f[2] + " " + $ + ":" + f[4] + ":" + f[5] + ":000", y = +v;
          return (l.utc(c).valueOf() - (y -= y % 1e3)) / 6e4;
        }, m = o.prototype;
        m.tz = function(v, k) {
          v === void 0 && (v = s);
          var T, f = this.utcOffset(), p = this.toDate(), d = p.toLocaleString("en-US", { timeZone: v }), S = Math.round((p - new Date(d)) / 1e3 / 60), w = 15 * -Math.round(p.getTimezoneOffset() / 15) - S;
          if (!Number(w)) T = this.utcOffset(0, k);
          else if (T = l(d, { locale: this.$L }).$set("millisecond", this.$ms).utcOffset(w, !0), k) {
            var h = T.utcOffset();
            T = T.add(f - h, "minute");
          }
          return T.$x.$timezone = v, T;
        }, m.offsetName = function(v) {
          var k = this.$x.$timezone || l.tz.guess(), T = u(this.valueOf(), k, { timeZoneName: v }).find(function(f) {
            return f.type.toLowerCase() === "timezonename";
          });
          return T && T.value;
        };
        var g = m.startOf;
        m.startOf = function(v, k) {
          if (!this.$x || !this.$x.$timezone) return g.call(this, v, k);
          var T = l(this.format("YYYY-MM-DD HH:mm:ss:SSS"), { locale: this.$L });
          return g.call(T, v, k).tz(this.$x.$timezone, !0);
        }, l.tz = function(v, k, T) {
          var f = T && k, p = T || k || s, d = i(+l(), p);
          if (typeof v != "string") return l(v).tz(p);
          var S = function($, c, y) {
            var D = $ - 60 * c * 1e3, P = i(D, y);
            if (c === P) return [D, c];
            var z = i(D -= 60 * (P - c) * 1e3, y);
            return P === z ? [D, P] : [$ - 60 * Math.min(P, z) * 1e3, Math.max(P, z)];
          }(l.utc(v, f).valueOf(), d, p), w = S[0], h = S[1], b = l(w).utcOffset(h);
          return b.$x.$timezone = p, b;
        }, l.tz.guess = function() {
          return Intl.DateTimeFormat().resolvedOptions().timeZone;
        }, l.tz.setDefault = function(v) {
          s = v;
        };
      };
    });
  }(wt)), wt.exports;
}
var tn = en();
const an = /* @__PURE__ */ vt(tn);
var kt = { exports: {} }, rn = kt.exports, ka;
function nn() {
  return ka || (ka = 1, function(r, e) {
    (function(t, a) {
      r.exports = a();
    })(rn, function() {
      var t = { 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" }, a = /(\[[^[]*\])|([-_:/.,()\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/, l = /\d\d?/, s = /\d*[^-_:/,()\s\d]+/, u = {}, i = function(p) {
        return (p = +p) + (p > 68 ? 1900 : 2e3);
      }, m = function(p) {
        return function(d) {
          this[p] = +d;
        };
      }, g = [/[+-]\d\d:?(\d\d)?|Z/, function(p) {
        (this.zone || (this.zone = {})).offset = function(d) {
          if (!d || d === "Z") return 0;
          var S = d.match(/([+-]|\d\d)/g), w = 60 * S[1] + (+S[2] || 0);
          return w === 0 ? 0 : S[0] === "+" ? -w : w;
        }(p);
      }], v = function(p) {
        var d = u[p];
        return d && (d.indexOf ? d : d.s.concat(d.f));
      }, k = function(p, d) {
        var S, w = u.meridiem;
        if (w) {
          for (var h = 1; h <= 24; h += 1) if (p.indexOf(w(h, 0, d)) > -1) {
            S = h > 12;
            break;
          }
        } else S = p === (d ? "pm" : "PM");
        return S;
      }, T = { A: [s, function(p) {
        this.afternoon = k(p, !1);
      }], a: [s, function(p) {
        this.afternoon = k(p, !0);
      }], Q: [n, function(p) {
        this.month = 3 * (p - 1) + 1;
      }], S: [n, function(p) {
        this.milliseconds = 100 * +p;
      }], SS: [o, function(p) {
        this.milliseconds = 10 * +p;
      }], SSS: [/\d{3}/, function(p) {
        this.milliseconds = +p;
      }], s: [l, m("seconds")], ss: [l, m("seconds")], m: [l, m("minutes")], mm: [l, m("minutes")], H: [l, m("hours")], h: [l, m("hours")], HH: [l, m("hours")], hh: [l, m("hours")], D: [l, m("day")], DD: [o, m("day")], Do: [s, function(p) {
        var d = u.ordinal, S = p.match(/\d+/);
        if (this.day = S[0], d) for (var w = 1; w <= 31; w += 1) d(w).replace(/\[|\]/g, "") === p && (this.day = w);
      }], w: [l, m("week")], ww: [o, m("week")], M: [l, m("month")], MM: [o, m("month")], MMM: [s, function(p) {
        var d = v("months"), S = (v("monthsShort") || d.map(function(w) {
          return w.slice(0, 3);
        })).indexOf(p) + 1;
        if (S < 1) throw new Error();
        this.month = S % 12 || S;
      }], MMMM: [s, function(p) {
        var d = v("months").indexOf(p) + 1;
        if (d < 1) throw new Error();
        this.month = d % 12 || d;
      }], Y: [/[+-]?\d+/, m("year")], YY: [o, function(p) {
        this.year = i(p);
      }], YYYY: [/\d{4}/, m("year")], Z: g, ZZ: g };
      function f(p) {
        var d, S;
        d = p, S = u && u.formats;
        for (var w = (p = d.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g, function(P, z, J) {
          var j = J && J.toUpperCase();
          return z || S[J] || t[J] || S[j].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g, function(X, Z, I) {
            return Z || I.slice(1);
          });
        })).match(a), h = w.length, b = 0; b < h; b += 1) {
          var $ = w[b], c = T[$], y = c && c[0], D = c && c[1];
          w[b] = D ? { regex: y, parser: D } : $.replace(/^\[|\]$/g, "");
        }
        return function(P) {
          for (var z = {}, J = 0, j = 0; J < h; J += 1) {
            var X = w[J];
            if (typeof X == "string") j += X.length;
            else {
              var Z = X.regex, I = X.parser, E = P.slice(j), M = Z.exec(E)[0];
              I.call(z, M), P = P.replace(M, "");
            }
          }
          return function(H) {
            var q = H.afternoon;
            if (q !== void 0) {
              var ee = H.hours;
              q ? ee < 12 && (H.hours += 12) : ee === 12 && (H.hours = 0), delete H.afternoon;
            }
          }(z), z;
        };
      }
      return function(p, d, S) {
        S.p.customParseFormat = !0, p && p.parseTwoDigitYear && (i = p.parseTwoDigitYear);
        var w = d.prototype, h = w.parse;
        w.parse = function(b) {
          var $ = b.date, c = b.utc, y = b.args;
          this.$u = c;
          var D = y[1];
          if (typeof D == "string") {
            var P = y[2] === !0, z = y[3] === !0, J = P || z, j = y[2];
            z && (j = y[2]), u = this.$locale(), !P && j && (u = S.Ls[j]), this.$d = function(E, M, H, q) {
              try {
                if (["x", "X"].indexOf(M) > -1) return new Date((M === "X" ? 1e3 : 1) * E);
                var ee = f(M)(E), me = ee.year, se = ee.month, R = ee.day, Y = ee.hours, B = ee.minutes, te = ee.seconds, Q = ee.milliseconds, N = ee.zone, K = ee.week, ae = /* @__PURE__ */ new Date(), he = R || (me || se ? 1 : ae.getDate()), ye = me || ae.getFullYear(), Me = 0;
                me && !se || (Me = se > 0 ? se - 1 : ae.getMonth());
                var be, F = Y || 0, x = B || 0, U = te || 0, re = Q || 0;
                return N ? new Date(Date.UTC(ye, Me, he, F, x, U, re + 60 * N.offset * 1e3)) : H ? new Date(Date.UTC(ye, Me, he, F, x, U, re)) : (be = new Date(ye, Me, he, F, x, U, re), K && (be = q(be).week(K).toDate()), be);
              } catch {
                return /* @__PURE__ */ new Date("");
              }
            }($, D, c, S), this.init(), j && j !== !0 && (this.$L = this.locale(j).$L), J && $ != this.format(D) && (this.$d = /* @__PURE__ */ new Date("")), u = {};
          } else if (D instanceof Array) for (var X = D.length, Z = 1; Z <= X; Z += 1) {
            y[1] = D[Z - 1];
            var I = S.apply(this, y);
            if (I.isValid()) {
              this.$d = I.$d, this.$L = I.$L, this.init();
              break;
            }
            Z === X && (this.$d = /* @__PURE__ */ new Date(""));
          }
          else h.call(this, b);
        };
      };
    });
  }(kt)), kt.exports;
}
var on = nn();
const tr = /* @__PURE__ */ vt(on);
var Tt = { exports: {} }, ln = Tt.exports, Ta;
function sn() {
  return Ta || (Ta = 1, function(r, e) {
    (function(t, a) {
      r.exports = a();
    })(ln, function() {
      var t = "week", a = "year";
      return function(n, o, l) {
        var s = o.prototype;
        s.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 m = l(this).startOf(a).add(1, a).date(i), g = l(this).endOf(t);
            if (m.isBefore(g)) return 1;
          }
          var v = l(this).startOf(a).date(i).startOf(t).subtract(1, "millisecond"), k = this.diff(v, t, !0);
          return k < 0 ? l(this).startOf("week").week() : Math.ceil(k);
        }, s.weeks = function(u) {
          return u === void 0 && (u = null), this.week(u);
        };
      };
    });
  }(Tt)), Tt.exports;
}
var un = sn();
const cn = /* @__PURE__ */ vt(un);
var xt = { exports: {} }, dn = xt.exports, xa;
function fn() {
  return xa || (xa = 1, function(r, e) {
    (function(t, a) {
      r.exports = a();
    })(dn, function() {
      return function(t, a, n) {
        var o = a.prototype, l = function(g) {
          return g && (g.indexOf ? g : g.s);
        }, s = function(g, v, k, T, f) {
          var p = g.name ? g : g.$locale(), d = l(p[v]), S = l(p[k]), w = d || S.map(function(b) {
            return b.slice(0, T);
          });
          if (!f) return w;
          var h = p.weekStart;
          return w.map(function(b, $) {
            return w[($ + (h || 0)) % 7];
          });
        }, u = function() {
          return n.Ls[n.locale()];
        }, i = function(g, v) {
          return g.formats[v] || function(k) {
            return k.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g, function(T, f, p) {
              return f || p.slice(1);
            });
          }(g.formats[v.toUpperCase()]);
        }, m = function() {
          var g = this;
          return { months: function(v) {
            return v ? v.format("MMMM") : s(g, "months");
          }, monthsShort: function(v) {
            return v ? v.format("MMM") : s(g, "monthsShort", "months", 3);
          }, firstDayOfWeek: function() {
            return g.$locale().weekStart || 0;
          }, weekdays: function(v) {
            return v ? v.format("dddd") : s(g, "weekdays");
          }, weekdaysMin: function(v) {
            return v ? v.format("dd") : s(g, "weekdaysMin", "weekdays", 2);
          }, weekdaysShort: function(v) {
            return v ? v.format("ddd") : s(g, "weekdaysShort", "weekdays", 3);
          }, longDateFormat: function(v) {
            return i(g.$locale(), v);
          }, meridiem: this.$locale().meridiem, ordinal: this.$locale().ordinal };
        };
        o.localeData = function() {
          return m.bind(this)();
        }, n.localeData = function() {
          var g = u();
          return { firstDayOfWeek: function() {
            return g.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(v) {
            return i(g, v);
          }, meridiem: g.meridiem, ordinal: g.ordinal };
        }, n.months = function() {
          return s(u(), "months");
        }, n.monthsShort = function() {
          return s(u(), "monthsShort", "months", 3);
        }, n.weekdays = function(g) {
          return s(u(), "weekdays", null, null, g);
        }, n.weekdaysShort = function(g) {
          return s(u(), "weekdaysShort", "weekdays", 3, g);
        }, n.weekdaysMin = function(g) {
          return s(u(), "weekdaysMin", "weekdays", 2, g);
        };
      };
    });
  }(xt)), xt.exports;
}
var mn = fn();
const hn = /* @__PURE__ */ vt(mn);
ie.extend(tr);
const Ca = {
  "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"]
}, Ya = [
  "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", t = "gregory") {
    this.locale = e, this.calendar = t, this.preferredFormats = [
      ...Ca[e] || [],
      ...Ya
    ];
  }
  parse(e) {
    if (!e || typeof e != "string")
      return { success: !1, date: null, format: null, confidence: 0 };
    const t = e.trim();
    try {
      const a = this.tryParseWithPlugins(t);
      if (a.success) return a;
      for (const n of this.preferredFormats) {
        const o = this.tryParseWithFormat(t, n);
        if (o.success)
          return { ...o, confidence: 0.9 };
      }
      return this.fallbackParse(t);
    } catch (a) {
      return console.warn("日期解析失敗:", a), { success: !1, date: null, format: null, confidence: 0 };
    }
  }
  tryParseWithPlugins(e) {
    switch (this.calendar) {
      case "roc":
        const t = new kr();
        if (t.canParseInput(e)) {
          const a = t.parseInput(e, this.locale);
          if (a)
            return {
              success: !0,
              date: a,
              format: "roc-plugin",
              confidence: 0.95,
              calendarSystem: "roc"
            };
        }
        break;
    }
    return { success: !1, date: null, format: null, confidence: 0 };
  }
  tryParseWithFormat(e, t) {
    try {
      const a = ie(e, t, !0);
      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: t,
          confidence: 1,
          calendarSystem: "gregory"
        };
    } catch {
    }
    return { success: !1, date: null, format: null, confidence: 0 };
  }
  fallbackParse(e) {
    try {
      const t = ie(e);
      if (t.isValid())
        return {
          success: !0,
          date: {
            year: t.year(),
            month: t.month() + 1,
            day: t.date(),
            hour: t.hour() || 0,
            minute: t.minute() || 0,
            second: t.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 = [
      ...Ca[e] || [],
      ...Ya
    ];
  }
  setCalendar(e) {
    this.calendar = e;
  }
}
const ot = new vn();
function pn(r, e = "zh-TW", t = "gregory") {
  return e !== ot.locale && ot.setLocale(e), t !== ot.calendar && ot.setCalendar(t), ot.parse(r);
}
function Ke(r, e) {
  return r - e * Math.floor(r / e);
}
const ar = 1721426;
function ze(r, e, t, a) {
  e = pt(r, e);
  let n = e - 1, o = -2;
  return t <= 2 ? o = 0 : qe(e) && (o = -1), ar - 1 + 365 * n + Math.floor(n / 4) - Math.floor(n / 100) + Math.floor(n / 400) + Math.floor((367 * t - 362) / 12 + o + a);
}
function qe(r) {
  return r % 4 === 0 && (r % 100 !== 0 || r % 400 === 0);
}
function pt(r, e) {
  return r === "BC" ? 1 - e : e;
}
function qt(r) {
  let e = "AD";
  return r <= 0 && (e = "BC", r = 1 - r), [
    e,
    r
  ];
}
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 t = e, a = t - ar, n = Math.floor(a / 146097), o = Ke(a, 146097), l = Math.floor(o / 36524), s = Ke(o, 36524), u = Math.floor(s / 1461), i = Ke(s, 1461), m = Math.floor(i / 365), g = n * 400 + l * 100 + u * 4 + m + (l !== 4 && m !== 4 ? 1 : 0), [v, k] = qt(g), T = t - ze(v, k, 1, 1), f = 2;
    t < ze(v, k, 3, 1) ? f = 0 : qe(k) && (f = 1);
    let p = Math.floor(((T + f) * 12 + 373) / 367), d = t - ze(v, k, p, 1) + 1;
    return new le(v, k, p, d);
  }
  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 yn = {
  "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(r, e) {
  var t, a, n, o;
  return (o = (n = (t = r.isEqual) === null || t === void 0 ? void 0 : t.call(r, e)) !== null && n !== void 0 ? n : (a = e.isEqual) === null || a === void 0 ? void 0 : a.call(e, r)) !== null && o !== void 0 ? o : r.identifier === e.identifier;
}
function rr(r, e, t) {
  let a = r.calendar.toJulianDay(r), n = kn(e), o = Math.ceil(a + 1 - n) % 7;
  return o < 0 && (o += 7), o;
}
function Dn(r) {
  return Le(Date.now(), r);
}
function bn(r) {
  return Yn(Dn(r));
}
function nr(r, e) {
  return r.calendar.toJulianDay(r) - e.calendar.toJulianDay(e);
}
function Mn(r, e) {
  return Ra(r) - Ra(e);
}
function Ra(r) {
  return r.hour * 36e5 + r.minute * 6e4 + r.second * 1e3 + r.millisecond;
}
let Wt = null;
function fa() {
  return Wt == null && (Wt = new Intl.DateTimeFormat().resolvedOptions().timeZone), Wt;
}
function Sn(r) {
  return r.subtract({
    days: r.day - 1
  });
}
const Ea = /* @__PURE__ */ new Map();
function wn(r) {
  if (Intl.Locale) {
    let t = Ea.get(r);
    return t || (t = new Intl.Locale(r).maximize().region, t && Ea.set(r, t)), t;
  }
  let e = r.split("-")[1];
  return e === "u" ? void 0 : e;
}
function kn(r) {
  let e = wn(r);
  return e && yn[e] || 0;
}
function Tn(r, e, t) {
  let a = r.calendar.getDaysInMonth(r);
  return Math.ceil((rr(Sn(r), e) + a) / 7);
}
function tt(r) {
  r = ke(r, new xe());
  let e = pt(r.era, r.year);
  return or(e, r.month, r.day, r.hour, r.minute, r.second, r.millisecond);
}
function or(r, e, t, a, n, o, l) {
  let s = /* @__PURE__ */ new Date();
  return s.setUTCHours(a, n, o, l), s.setUTCFullYear(r, e - 1, t), s.getTime();
}
function Zt(r, e) {
  if (e === "UTC") return 0;
  if (r > 0 && e === fa()) return new Date(r).getTimezoneOffset() * -6e4;
  let { year: t, month: a, day: n, hour: o, minute: l, second: s } = lr(r, e);
  return or(t, a, n, o, l, s, 0) - Math.floor(r / 1e3) * 1e3;
}
const Ia = /* @__PURE__ */ new Map();
function lr(r, e) {
  let t = Ia.get(e);
  t || (t = new Intl.DateTimeFormat("en-US", {
    timeZone: e,
    hour12: !1,
    era: "short",
    year: "numeric",
    month: "numeric",
    day: "numeric",
    hour: "numeric",
    minute: "numeric",
    second: "numeric"
  }), Ia.set(e, t));
  let a = t.formatToParts(new Date(r)), n = {};
  for (let o of a) 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 Oa = 864e5;
function xn(r, e, t, a) {
  return (t === a ? [
    t
  ] : [
    t,
    a
  ]).filter((o) => Cn(r, e, o));
}
function Cn(r, e, t) {
  let a = lr(t, e);
  return r.year === a.year && r.month === a.month && r.day === a.day && r.hour === a.hour && r.minute === a.minute && r.second === a.second;
}
function Pe(r, e, t = "compatible") {
  let a = at(r);
  if (e === "UTC") return tt(a);
  if (e === fa() && t === "compatible") {
    a = ke(a, new xe());
    let u = /* @__PURE__ */ new Date(), i = pt(a.era, a.year);
    return u.setFullYear(i, a.month - 1, a.day), u.setHours(a.hour, a.minute, a.second, a.millisecond), u.getTime();
  }
  let n = tt(a), o = Zt(n - Oa, e), l = Zt(n + Oa, e), s = xn(a, e, n - o, n - l);
  if (s.length === 1) return s[0];
  if (s.length > 1) switch (t) {
    // 'compatible' means 'earlier' for "fall back" transitions
    case "compatible":
    case "earlier":
      return s[0];
    case "later":
      return s[s.length - 1];
    case "reject":
      throw new RangeError("Multiple possible absolute times found");
  }
  switch (t) {
    case "earlier":
      return Math.min(n - o, n - l);
    // 'compatible' means 'later' for "spring forward" transitions
    case "compatible":
    case "later":
      return Math.max(n - o, n - l);
    case "reject":
      throw new RangeError("No such absolute time found");
  }
}
function sr(r, e, t = "compatible") {
  return new Date(Pe(r, e, t));
}
function Le(r, e) {
  let t = Zt(r, e), a = new Date(r + t), n = a.getUTCFullYear(), o = a.getUTCMonth() + 1, l = a.getUTCDate(), s = a.getUTCHours(), u = a.getUTCMinutes(), i = a.getUTCSeconds(), m = a.getUTCMilliseconds();
  return new ht(n < 1 ? "BC" : "AD", n < 1 ? -n + 1 : n, o, l, e, t, s, u, i, m);
}
function Yn(r) {
  return new le(r.calendar, r.era, r.year, r.month, r.day);
}
function at(r, e) {
  let t = 0, a = 0, n = 0, o = 0;
  if ("timeZone" in r) ({ hour: t, minute: a, second: n, millisecond: o } = r);
  else if ("hour" in r && !e) return r;
  return e && ({ hour: t, minute: a, second: n, millisecond: o } = e), new rt(r.calendar, r.era, r.year, r.month, r.day, t, a, n, o);
}
function ke(r, e) {
  if ($n(r.calendar, e)) return r;
  let t = e.fromJulianDay(r.calendar.toJulianDay(r)), a = r.copy();
  return a.calendar = e, a.era = t.era, a.year = t.year, a.month = t.month, a.day = t.day, je(a), a;
}
function Rn(r, e, t) {
  if (r instanceof ht)
    return r.timeZone === e ? r : In(r, e);
  let a = Pe(r, e, t);
  return Le(a, e);
}
function En(r) {
  let e = tt(r) - r.offset;
  return new Date(e);
}
function In(r, e) {
  let t = tt(r) - r.offset;
  return ke(Le(t, e), r.calendar);
}
const lt = 36e5;
function Ut(r, e) {
  let t = r.copy(), a = "hour" in t ? Pn(t, e) : 0;
  Gt(t, e.years || 0), t.calendar.balanceYearMonth && t.calendar.balanceYearMonth(t, r), t.month += e.months || 0, Xt(t), ir(t), t.day += (e.weeks || 0) * 7, t.day += e.days || 0, t.day += a, On(t), t.calendar.balanceDate && t.calendar.balanceDate(t), t.year < 1 && (t.year = 1, t.month = 1, t.day = 1);
  let n = t.calendar.getYearsInEra(t);
  if (t.year > n) {
    var o, l;
    let u = (o = (l = t.calendar).isInverseEra) === null || o === void 0 ? void 0 : o.call(l, t);
    t.year = n, t.month = u ? 1 : t.calendar.getMonthsInYear(t), t.day = u ? 1 : t.calendar.getDaysInMonth(t);
  }
  t.month < 1 && (t.month = 1, t.day = 1);
  let s = t.calendar.getMonthsInYear(t);
  return t.month > s && (t.month = s, t.day = t.calendar.getDaysInMonth(t)), t.day = Math.max(1, Math.min(t.calendar.getDaysInMonth(t), t.day)), t;
}
function Gt(r, e) {
  var t, a;
  !((t = (a = r.calendar).isInverseEra) === null || t === void 0) && t.call(a, r) && (e = -e), r.year += e;
}
function Xt(r) {
  for (; r.month < 1; )
    Gt(r, -1), r.month += r.calendar.getMonthsInYear(r);
  let e = 0;
  for (; r.month > (e = r.calendar.getMonthsInYear(r)); )
    r.month -= e, Gt(r, 1);
}
function On(r) {
  for (; r.day < 1; )
    r.month--, Xt(r), r.day += r.calendar.getDaysInMonth(r);
  for (; r.day > r.calendar.getDaysInMonth(r); )
    r.day -= r.calendar.getDaysInMonth(r), r.month++, Xt(r);
}
function ir(r) {
  r.month = Math.max(1, Math.min(r.calendar.getMonthsInYear(r), r.month)), r.day = Math.max(1, Math.min(r.calendar.getDaysInMonth(r), r.day));
}
function je(r) {
  r.calendar.constrainDate && r.calendar.constrainDate(r), r.year = Math.max(1, Math.min(r.calendar.getYearsInEra(r), r.year)), ir(r);
}
function ur(r) {
  let e = {};
  for (let t in r) typeof r[t] == "number" && (e[t] = -r[t]);
  return e;
}
function cr(r, e) {
  return Ut(r, ur(e));
}
function ma(r, e) {
  let t = r.copy();
  return e.era != null && (t.era = e.era), e.year != null && (t.year = e.year), e.month != null && (t.month = e.month), e.day != null && (t.day = e.day), je(t), t;
}
function Et(r, e) {
  let t = r.copy();
  return e.hour != null && (t.hour = e.hour), e.minute != null && (t.minute = e.minute), e.second != null && (t.second = e.second), e.millisecond != null && (t.millisecond = e.millisecond), Fn(t), t;
}
function Vn(r) {
  r.second += Math.floor(r.millisecond / 1e3), r.millisecond = yt(r.millisecond, 1e3), r.minute += Math.floor(r.second / 60), r.second = yt(r.second, 60), r.hour += Math.floor(r.minute / 60), r.minute = yt(r.minute, 60);
  let e = Math.floor(r.hour / 24);
  return r.hour = yt(r.hour, 24), e;
}
function Fn(r) {
  r.millisecond = Math.max(0, Math.min(r.millisecond, 1e3)), r.second = Math.max(0, Math.min(r.second, 59)), r.minute = Math.max(0, Math.min(r.minute, 59)), r.hour = Math.max(0, Math.min(r.hour, 23));
}
function yt(r, e) {
  let t = r % e;
  return t < 0 && (t += e), t;
}
function Pn(r, e) {
  return r.hour += e.hours || 0, r.minute += e.minutes || 0, r.second += e.seconds || 0, r.millisecond += e.milliseconds || 0, Vn(r);
}
function ha(r, e, t, a) {
  let n = r.copy();
  switch (e) {
    case "era": {
      let s = r.calendar.getEras(), u = s.indexOf(r.era);
      if (u < 0) throw new Error("Invalid era: " + r.era);
      u = He(u, t, 0, s.length - 1, a?.round), n.era = s[u], je(n);
      break;
    }
    case "year":
      var o, l;
      !((o = (l = n.calendar).isInverseEra) === null || o === void 0) && o.call(l, n) && (t = -t), n.year = He(r.year, t, -1 / 0, 9999, a?.round), n.year === -1 / 0 && (n.year = 1), n.calendar.balanceYearMonth && n.calendar.balanceYearMonth(n, r);
      break;
    case "month":
      n.month = He(r.month, t, 1, r.calendar.getMonthsInYear(r), a?.round);
      break;
    case "day":
      n.day = He(r.day, t, 1, r.calendar.getDaysInMonth(r), a?.round);
      break;
    default:
      throw new Error("Unsupported field " + e);
  }
  return r.calendar.balanceDate && r.calendar.balanceDate(n), je(n), n;
}
function dr(r, e, t, a) {
  let n = r.copy();
  switch (e) {
    case "hour": {
      let o = r.hour, l = 0, s = 23;
      if (a?.hourCycle === 12) {
        let u = o >= 12;
        l = u ? 12 : 0, s = u ? 23 : 11;
      }
      n.hour = He(o, t, l, s, a?.round);
      break;
    }
    case "minute":
      n.minute = He(r.minute, t, 0, 59, a?.round);
      break;
    case "second":
      n.second = He(r.second, t, 0, 59, a?.round);
      break;
    case "millisecond":
      n.millisecond = He(r.millisecond, t, 0, 999, a?.round);
      break;
    default:
      throw new Error("Unsupported field " + e);
  }
  return n;
}
function He(r, e, t, a, n = !1) {
  if (n) {
    r += Math.sign(e), r < t && (r = a);
    let o = Math.abs(e);
    e > 0 ? r = Math.ceil(r / o) * o : r = Math.floor(r / o) * o, r > a && (r = t);
  } else
    r += e, r < t ? r = a - (t - r - 1) : r > a && (r = t + (r - a - 1));
  return r;
}
function fr(r, e) {
  let t;
  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(r), {
      years: e.years,
      months: e.months,
      weeks: e.weeks,
      days: e.days
    });
    t = Pe(n, r.timeZone);
  } else
    t = tt(r) - r.offset;
  t += e.milliseconds || 0, t += (e.seconds || 0) * 1e3, t += (e.minutes || 0) * 6e4, t += (e.hours || 0) * 36e5;
  let a = Le(t, r.timeZone);
  return ke(a, r.calendar);
}
function An(r, e) {
  return fr(r, ur(e));
}
function Ln(r, e, t, a) {
  switch (e) {
    case "hour": {
      let n = 0, o = 23;
      if (a?.hourCycle === 12) {
        let T = r.hour >= 12;
        n = T ? 12 : 0, o = T ? 23 : 11;
      }
      let l = at(r), s = ke(Et(l, {
        hour: n
      }), new xe()), u = [
        Pe(s, r.timeZone, "earlier"),
        Pe(s, r.timeZone, "later")
      ].filter((T) => Le(T, r.timeZone).day === s.day)[0], i = ke(Et(l, {
        hour: o
      }), new xe()), m = [
        Pe(i, r.timeZone, "earlier"),
        Pe(i, r.timeZone, "later")
      ].filter((T) => Le(T, r.timeZone).day === i.day).pop(), g = tt(r) - r.offset, v = Math.floor(g / lt), k = g % lt;
      return g = He(v, t, Math.floor(u / lt), Math.floor(m / lt), a?.round) * lt + k, ke(Le(g, r.timeZone), r.calendar);
    }
    case "minute":
    case "second":
    case "millisecond":
      return dr(r, e, t, a);
    case "era":
    case "year":
    case "month":
    case "day": {
      let n = ha(at(r), e, t, a), o = Pe(n, r.timeZone);
      return ke(Le(o, r.timeZone), r.calendar);
    }
    default:
      throw new Error("Unsupported field " + e);
  }
}
function Hn(r, e, t) {
  let a = at(r), n = Et(ma(a, e), e);
  if (n.compare(a) === 0) return r;
  let o = Pe(n, r.timeZone, t);
  return ke(Le(o, r.timeZone), r.calendar);
}
function Bn(r) {
  return `${String(r.hour).padStart(2, "0")}:${String(r.minute).padStart(2, "0")}:${String(r.second).padStart(2, "0")}${r.millisecond ? String(r.millisecond / 1e3).slice(1) : ""}`;
}
function mr(r) {
  let e = ke(r, new xe()), t;
  return e.era === "BC" ? t = e.year === 1 ? "0000" : "-" + String(Math.abs(1 - e.year)).padStart(6, "00") : t = String(e.year).padStart(4, "0"), `${t}-${String(e.month).padStart(2, "0")}-${String(e.day).padStart(2, "0")}`;
}
function hr(r) {
  return `${mr(r)}T${Bn(r)}`;
}
function qn(r) {
  let e = Math.sign(r) < 0 ? "-" : "+";
  r = Math.abs(r);
  let t = Math.floor(r / 36e5), a = r % 36e5 / 6e4;
  return `${e}${String(t).padStart(2, "0")}:${String(a).padStart(2, "0")}`;
}
function Un(r) {
  return `${hr(r)}${qn(r.offset)}[${r.timeZone}]`;
}
function Nn(r, e) {
  if (e.has(r))
    throw new TypeError("Cannot initialize the same private elements twice on an object");
}
function va(r, e, t) {
  Nn(r, e), e.set(r, t);
}
function pa(r) {
  let e = typeof r[0] == "object" ? r.shift() : new xe(), t;
  if (typeof r[0] == "string") t = r.shift();
  else {
    let l = e.getEras();
    t = l[l.length - 1];
  }
  let a = r.shift(), n = r.shift(), o = r.shift();
  return [
    e,
    t,
    a,
    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 cr(this, e);
  }
  /** Returns a new `CalendarDate` with the given fields set to the provided values. Other fields will be constrained accordingly. */
  set(e) {
    return ma(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, t, a) {
    return ha(this, e, t, a);
  }
  /** Converts the date to a native JavaScript Date object, with the time set to midnight in the given time zone. */
  toDate(e) {
    return sr(this, e);
  }
  /** Converts the date to an ISO 8601 formatted string. */
  toString() {
    return mr(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 nr(this, e);
  }
  constructor(...e) {
    va(this, zn, {
      writable: !0,
      value: void 0
    });
    let [t, a, n, o, l] = pa(e);
    this.calendar = t, this.era = a, this.year = n, this.month = o, this.day = l, 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 cr(this, e);
  }
  /** Returns a new `CalendarDateTime` with the given fields set to the provided values. Other fields will be constrained accordingly. */
  set(e) {
    return ma(Et(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, t, a) {
    switch (e) {
      case "era":
      case "year":
      case "month":
      case "day":
        return ha(this, e, t, a);
      default:
        return dr(this, e, t, a);
    }
  }
  /** Converts the date to a native JavaScript Date object in the given time zone. */
  toDate(e, t) {
    return sr(this, e, t);
  }
  /** 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) {
    let t = nr(this, e);
    return t === 0 ? Mn(this, at(e)) : t;
  }
  constructor(...e) {
    va(this, Wn, {
      writable: !0,
      value: void 0
    });
    let [t, a, n, o, l] = pa(e);
    this.calendar = t, this.era = a, this.year = n, this.month = o, this.day = l, 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 ht {
  /** Returns a copy of this date. */
  copy() {
    return this.era ? new ht(this.calendar, this.era, this.year, this.month, this.day, this.timeZone, this.offset, this.hour, this.minute, this.second, this.millisecond) : new ht(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 fr(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, t) {
    return Hn(this, e, t);
  }
  /**
  * 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, t, a) {
    return Ln(this, e, t, a);
  }
  /** 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 Un(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) {
    va(this, jn, {
      writable: !0,
      value: void 0
    });
    let [t, a, n, o, l] = pa(e), s = e.shift(), u = e.shift();
    this.calendar = t, this.era = a, this.year = n, this.month = o, this.day = l, this.timeZone = s, 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 Qe = [
  [
    1868,
    9,
    8
  ],
  [
    1912,
    7,
    30
  ],
  [
    1926,
    12,
    25
  ],
  [
    1989,
    1,
    8
  ],
  [
    2019,
    5,
    1
  ]
], _n = [
  [
    1912,
    7,
    29
  ],
  [
    1926,
    12,
    24
  ],
  [
    1989,
    1,
    7
  ],
  [
    2019,
    4,
    30
  ]
], Ct = [
  1867,
  1911,
  1925,
  1988,
  2018
], Be = [
  "meiji",
  "taisho",
  "showa",
  "heisei",
  "reiwa"
];
function Va(r) {
  const e = Qe.findIndex(([t, a, n]) => r.year < t || r.year === t && r.month < a || r.year === t && r.month === a && r.day < n);
  return e === -1 ? Qe.length - 1 : e === 0 ? 0 : e - 1;
}
function jt(r) {
  let e = Ct[Be.indexOf(r.era)];
  if (!e) throw new Error("Unknown era: " + r.era);
  return new le(r.year + e, r.month, r.day);
}
class Jn extends xe {
  fromJulianDay(e) {
    let t = super.fromJulianDay(e), a = Va(t);
    return new le(this, Be[a], t.year - Ct[a], t.month, t.day);
  }
  toJulianDay(e) {
    return super.toJulianDay(jt(e));
  }
  balanceDate(e) {
    let t = jt(e), a = Va(t);
    Be[a] !== e.era && (e.era = Be[a], e.year = t.year - Ct[a]), this.constrainDate(e);
  }
  constrainDate(e) {
    let t = Be.indexOf(e.era), a = _n[t];
    if (a != null) {
      let [n, o, l] = a, s = n - Ct[t];
      e.year = Math.max(1, Math.min(s, e.year)), e.year === s && (e.month = Math.min(o, e.month), e.month === o && (e.day = Math.min(l, e.day)));
    }
    if (e.year === 1 && t >= 0) {
      let [, n, o] = Qe[t];
      e.month = Math.max(n, e.month), e.month === n && (e.day = Math.max(o, e.day));
    }
  }
  getEras() {
    return Be;
  }
  getYearsInEra(e) {
    let t = Be.indexOf(e.era), a = Qe[t], n = Qe[t + 1];
    if (n == null)
      return 9999 - a[0] + 1;
    let o = n[0] - a[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 t = Fa(e);
    return t ? t[1] : 1;
  }
  getMinimumDayInMonth(e) {
    let t = Fa(e);
    return t && e.month === t[1] ? t[2] : 1;
  }
  constructor(...e) {
    super(...e), this.identifier = "japanese";
  }
}
function Fa(r) {
  if (r.year === 1) {
    let e = Be.indexOf(r.era);
    return Qe[e];
  }
}
const vr = -543;
class Kn extends xe {
  fromJulianDay(e) {
    let t = super.fromJulianDay(e), a = pt(t.era, t.year);
    return new le(this, a - vr, t.month, t.day);
  }
  toJulianDay(e) {
    return super.toJulianDay(Pa(e));
  }
  getEras() {
    return [
      "BE"
    ];
  }
  getDaysInMonth(e) {
    return super.getDaysInMonth(Pa(e));
  }
  balanceDate() {
  }
  constructor(...e) {
    super(...e), this.identifier = "buddhist";
  }
}
function Pa(r) {
  let [e, t] = qt(r.year + vr);
  return new le(e, t, r.month, r.day);
}
const It = 1911;
function pr(r) {
  return r.era === "minguo" ? r.year + It : 1 - r.year + It;
}
function Aa(r) {
  let e = r - It;
  return e > 0 ? [
    "minguo",
    e
  ] : [
    "before_minguo",
    1 - e
  ];
}
class Qn extends xe {
  fromJulianDay(e) {
    let t = super.fromJulianDay(e), a = pt(t.era, t.year), [n, o] = Aa(a);
    return new le(this, n, o, t.month, t.day);
  }
  toJulianDay(e) {
    return super.toJulianDay(La(e));
  }
  getEras() {
    return [
      "before_minguo",
      "minguo"
    ];
  }
  balanceDate(e) {
    let [t, a] = Aa(pr(e));
    e.era = t, e.year = a;
  }
  isInverseEra(e) {
    return e.era === "before_minguo";
  }
  getDaysInMonth(e) {
    return super.getDaysInMonth(La(e));
  }
  getYearsInEra(e) {
    return e.era === "before_minguo" ? 9999 : 9999 - It;
  }
  constructor(...e) {
    super(...e), this.identifier = "roc";
  }
}
function La(r) {
  let [e, t] = qt(pr(r));
  return new le(e, t, r.month, r.day);
}
const Ha = 1948320, Ba = [
  0,
  31,
  62,
  93,
  124,
  155,
  186,
  216,
  246,
  276,
  306,
  336
  // Esfand
];
class Zn {
  fromJulianDay(e) {
    let t = e - Ha, a = 1 + Math.floor((33 * t + 3) / 12053), n = 365 * (a - 1) + Math.floor((8 * a + 21) / 33), o = t - n, l = o < 216 ? Math.floor(o / 31) : Math.floor((o - 6) / 30), s = o - Ba[l] + 1;
    return new le(this, a, l + 1, s);
  }
  toJulianDay(e) {
    let t = Ha - 1 + 365 * (e.year - 1) + Math.floor((8 * e.year + 21) / 33);
    return t += Ba[e.month - 1], t += e.day, t;
  }
  getMonthsInYear() {
    return 12;
  }
  getDaysInMonth(e) {
    return e.month <= 6 ? 31 : e.month <= 11 || Ke(25 * e.year + 11, 33) < 8 ? 30 : 29;
  }
  getEras() {
    return [
      "AP"
    ];
  }
  getYearsInEra() {
    return 9377;
  }
  constructor() {
    this.identifier = "persian";
  }
}
const _t = 78, qa = 80;
class Gn extends xe {
  fromJulianDay(e) {
    let t = super.fromJulianDay(e), a = t.year - _t, n = e - ze(t.era, t.year, 1, 1), o;
    n < qa ? (a--, o = qe(t.year - 1) ? 31 : 30, n += o + 155 + 90 + 10) : (o = qe(t.year) ? 31 : 30, n -= qa);
    let l, s;
    if (n < o)
      l = 1, s = n + 1;
    else {
      let u = n - o;
      u < 155 ? (l = Math.floor(u / 31) + 2, s = u % 31 + 1) : (u -= 155, l = Math.floor(u / 30) + 7, s = u % 30 + 1);
    }
    return new le(this, a, l, s);
  }
  toJulianDay(e) {
    let t = e.year + _t, [a, n] = qt(t), o, l;
    return qe(n) ? (o = 31, l = ze(a, n, 3, 21)) : (o = 30, l = ze(a, n, 3, 22)), e.month === 1 ? l + e.day - 1 : (l += o + Math.min(e.month - 2, 5) * 31, e.month >= 8 && (l += (e.month - 7) * 30), l += e.day - 1, l);
  }
  getDaysInMonth(e) {
    return e.month === 1 && qe(e.year + _t) || e.month >= 2 && e.month <= 6 ? 31 : 30;
  }
  getYearsInEra() {
    return 9919;
  }
  getEras() {
    return [
      "saka"
    ];
  }
  balanceDate() {
  }
  constructor(...e) {
    super(...e), this.identifier = "indian";
  }
}
const Ot = 1948440, Ua = 1948439, Ye = 1300, _e = 1600, Xn = 460322;
function Vt(r, e, t, a) {
  return a + Math.ceil(29.5 * (t - 1)) + (e - 1) * 354 + Math.floor((3 + 11 * e) / 30) + r - 1;
}
function gr(r, e, t) {
  let a = Math.floor((30 * (t - e) + 10646) / 10631), n = Math.min(12, Math.ceil((t - (29 + Vt(e, a, 1, 1))) / 29.5) + 1), o = t - Vt(e, a, n, 1) + 1;
  return new le(r, a, n, o);
}
function Na(r) {
  return (14 + 11 * r) % 30 < 11;
}
class ga {
  fromJulianDay(e) {
    return gr(this, Ot, e);
  }
  toJulianDay(e) {
    return Vt(Ot, e.year, e.month, e.day);
  }
  getDaysInMonth(e) {
    let t = 29 + e.month % 2;
    return e.month === 12 && Na(e.year) && t++, t;
  }
  getMonthsInYear() {
    return 12;
  }
  getDaysInYear(e) {
    return Na(e.year) ? 355 : 354;
  }
  getYearsInEra() {
    return 9665;
  }
  getEras() {
    return [
      "AH"
    ];
  }
  constructor() {
    this.identifier = "islamic-civil";
  }
}
class eo extends ga {
  fromJulianDay(e) {
    return gr(this, Ua, e);
  }
  toJulianDay(e) {
    return Vt(Ua, e.year, e.month, e.day);
  }
  constructor(...e) {
    super(...e), this.identifier = "islamic-tbla";
  }
}
const to = "qgpUDckO1AbqBmwDrQpVBakGkgepC9QF2gpcBS0NlQZKB1QLagutBa4ETwoXBYsGpQbVCtYCWwmdBE0KJg2VDawFtgm6AlsKKwWVCsoG6Qr0AnYJtgJWCcoKpAvSC9kF3AJtCU0FpQpSC6ULtAW2CVcFlwJLBaMGUgdlC2oFqworBZUMSg2lDcoF1gpXCasESwmlClILagt1BXYCtwhbBFUFqQW0BdoJ3QRuAjYJqgpUDbIN1QXaAlsJqwRVCkkLZAtxC7QFtQpVCiUNkg7JDtQG6QprCasEkwpJDaQNsg25CroEWworBZUKKgtVC1wFvQQ9Ah0JlQpKC1oLbQW2AjsJmwRVBqkGVAdqC2wFrQpVBSkLkgupC9QF2gpaBasKlQVJB2QHqgu1BbYCVgpNDiULUgtqC60FrgIvCZcESwalBqwG1gpdBZ0ETQoWDZUNqgW1BdoCWwmtBJUFygbkBuoK9QS2AlYJqgpUC9IL2QXqAm0JrQSVCkoLpQuyBbUJ1gSXCkcFkwZJB1ULagVrCisFiwpGDaMNygXWCtsEawJLCaUKUgtpC3UFdgG3CFsCKwVlBbQF2gntBG0BtgimClINqQ3UBdoKWwmrBFMGKQdiB6kLsgW1ClUFJQuSDckO0gbpCmsFqwRVCikNVA2qDbUJugQ7CpsETQqqCtUK2gJdCV4ELgqaDFUNsga5BroEXQotBZUKUguoC7QLuQXaAloJSgukDdEO6AZqC20FNQWVBkoNqA3UDdoGWwWdAisGFQtKC5ULqgWuCi4JjwwnBZUGqgbWCl0FnQI=";
let ea, Ze;
function Yt(r) {
  return Xn + Ze[r - Ye];
}
function it(r, e) {
  let t = r - Ye, a = 1 << 11 - (e - 1);
  return (ea[t] & a) === 0 ? 29 : 30;
}
function za(r, e) {
  let t = Yt(r);
  for (let a = 1; a < e; a++) t += it(r, a);
  return t;
}
function Wa(r) {
  return Ze[r + 1 - Ye] - Ze[r - Ye];
}
class ao extends ga {
  fromJulianDay(e) {
    let t = e - Ot, a = Yt(Ye), n = Yt(_e);
    if (t < a || t > n) return super.fromJulianDay(e);
    {
      let o = Ye - 1, l = 1, s = 1;
      for (; s > 0; ) {
        o++, s = t - Yt(o) + 1;
        let u = Wa(o);
        if (s === u) {
          l = 12;
          break;
        } else if (s < u) {
          let i = it(o, l);
          for (l = 1; s > i; )
            s -= i, l++, i = it(o, l);
          break;
        }
      }
      return new le(this, o, l, t - za(o, l) + 1);
    }
  }
  toJulianDay(e) {
    return e.year < Ye || e.year > _e ? super.toJulianDay(e) : Ot + za(e.year, e.month) + (e.day - 1);
  }
  getDaysInMonth(e) {
    return e.year < Ye || e.year > _e ? super.getDaysInMonth(e) : it(e.year, e.month);
  }
  getDaysInYear(e) {
    return e.year < Ye || e.year > _e ? super.getDaysInYear(e) : Wa(e.year);
  }
  constructor() {
    if (super(), this.identifier = "islamic-umalqura", ea || (ea = new Uint16Array(Uint8Array.from(atob(to), (e) => e.charCodeAt(0)).buffer)), !Ze) {
      Ze = new Uint32Array(_e - Ye + 1);
      let e = 0;
      for (let t = Ye; t <= _e; t++) {
        Ze[t - Ye] = e;
        for (let a = 1; a <= 12; a++) e += it(t, a);
      }
    }
  }
}
const ja = 347997, yr = 1080, $r = 24 * yr, ro = 29, no = 12 * yr + 793, oo = ro * $r + no;
function Ne(r) {
  return Ke(r * 7 + 1, 19) < 7;
}
function Rt(r) {
  let e = Math.floor((235 * r - 234) / 19), t = 12084 + 13753 * e, a = e * 29 + Math.floor(t / 25920);
  return Ke(3 * (a + 1), 7) < 3 && (a += 1), a;
}
function lo(r) {
  let e = Rt(r - 1), t = Rt(r);
  return Rt(r + 1) - t === 356 ? 2 : t - e === 382 ? 1 : 0;
}
function ut(r) {
  return Rt(r) + lo(r);
}
function Dr(r) {
  return ut(r + 1) - ut(r);
}
function so(r) {
  let e = Dr(r);
  switch (e > 380 && (e -= 30), e) {
    case 353:
      return 0;
    // deficient
    case 354:
      return 1;
    // normal
    case 355:
      return 2;
  }
}
function $t(r, e) {
  if (e >= 6 && !Ne(r) && e++, e === 4 || e === 7 || e === 9 || e === 11 || e === 13) return 29;
  let t = so(r);
  return e === 2 ? t === 2 ? 30 : 29 : e === 3 ? t === 0 ? 29 : 30 : e === 6 ? Ne(r) ? 30 : 0 : 30;
}
class io {
  fromJulianDay(e) {
    let t = e - ja, a = t * $r / oo, n = Math.floor((19 * a + 234) / 235) + 1, o = ut(n), l = Math.floor(t - o);
    for (; l < 1; )
      n--, o = ut(n), l = Math.floor(t - o);
    let s = 1, u = 0;
    for (; u < l; )
      u += $t(n, s), s++;
    s--, u -= $t(n, s);
    let i = l - u;
    return new le(this, n, s, i);
  }
  toJulianDay(e) {
    let t = ut(e.year);
    for (let a = 1; a < e.month; a++) t += $t(e.year, a);
    return t + e.day + ja;
  }
  getDaysInMonth(e) {
    return $t(e.year, e.month);
  }
  getMonthsInYear(e) {
    return Ne(e.year) ? 13 : 12;
  }
  getDaysInYear(e) {
    return Dr(e.year);
  }
  getYearsInEra() {
    return 9999;
  }
  getEras() {
    return [
      "AM"
    ];
  }
  balanceYearMonth(e, t) {
    t.year !== e.year && (Ne(t.year) && !Ne(e.year) && t.month > 6 ? e.month-- : !Ne(t.year) && Ne(e.year) && t.month > 6 && e.month++);
  }
  constructor() {
    this.identifier = "hebrew";
  }
}
const ta = 1723856, _a = 1824665, aa = 5500;
function Ft(r, e, t, a) {
  return r + 365 * e + Math.floor(e / 4) + 30 * (t - 1) + a - 1;
}
function ya(r, e) {
  let t = Math.floor(4 * (e - r) / 1461), a = 1 + Math.floor((e - Ft(r, t, 1, 1)) / 30), n = e + 1 - Ft(r, t, a, 1);
  return [
    t,
    a,
    n
  ];
}
function br(r) {
  return Math.floor(r % 4 / 3);
}
function Mr(r, e) {
  return e % 13 !== 0 ? 30 : br(r) + 5;
}
class $a {
  fromJulianDay(e) {
    let [t, a, n] = ya(ta, e), o = "AM";
    return t <= 0 && (o = "AA", t += aa), new le(this, o, t, a, n);
  }
  toJulianDay(e) {
    let t = e.year;
    return e.era === "AA" && (t -= aa), Ft(ta, t, e.month, e.day);
  }
  getDaysInMonth(e) {
    return Mr(e.year, e.month);
  }
  getMonthsInYear() {
    return 13;
  }
  getDaysInYear(e) {
    return 365 + br(e.year);
  }
  getYearsInEra(e) {
    return e.era === "AA" ? 9999 : 9991;
  }
  getEras() {
    return [
      "AA",
      "AM"
    ];
  }
  constructor() {
    this.identifier = "ethiopic";
  }
}
class uo extends $a {
  fromJulianDay(e) {
    let [t, a, n] = ya(ta, e);
    return t += aa, new le(this, "AA", t, a, n);
  }
  getEras() {
    return [
      "AA"
    ];
  }
  getYearsInEra() {
    return 9999;
  }
  constructor(...e) {
    super(...e), this.identifier = "ethioaa";
  }
}
class co extends $a {
  fromJulianDay(e) {
    let [t, a, n] = ya(_a, e), o = "CE";
    return t <= 0 && (o = "BCE", t = 1 - t), new le(this, o, t, a, n);
  }
  toJulianDay(e) {
    let t = e.year;
    return e.era === "BCE" && (t = 1 - t), Ft(_a, t, e.month, e.day);
  }
  getDaysInMonth(e) {
    let t = e.year;
    return e.era === "BCE" && (t = 1 - t), Mr(t, 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(r) {
  switch (r) {
    case "buddhist":
      return new Kn();
    case "ethiopic":
      return new $a();
    case "ethioaa":
      return new uo();
    case "coptic":
      return new co();
    case "hebrew":
      return new io();
    case "indian":
      return new Gn();
    case "islamic-civil":
      return new ga();
    case "islamic-tbla":
      return new eo();
    case "islamic-umalqura":
      return new ao();
    case "japanese":
      return new Jn();
    case "persian":
      return new Zn();
    case "roc":
      return new Qn();
    case "gregory":
    default:
      return new xe();
  }
}
let Jt = /* @__PURE__ */ new Map();
class Pt {
  /** 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, t) {
    if (typeof this.formatter.formatRange == "function")
      return this.formatter.formatRange(e, t);
    if (t < e) throw new RangeError("End date must be >= start date");
    return `${this.formatter.format(e)} – ${this.formatter.format(t)}`;
  }
  /** Formats a date range as an array of parts. */
  formatRangeToParts(e, t) {
    if (typeof this.formatter.formatRangeToParts == "function")
      return this.formatter.formatRangeToParts(e, t);
    if (t < e) throw new RangeError("End date must be >= start date");
    let a = this.formatter.formatToParts(e), n = this.formatter.formatToParts(t);
    return [
      ...a.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 = po(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, t = {}) {
    this.formatter = Sr(e, t), this.options = t;
  }
}
const mo = {
  true: {
    // Only Japanese uses the h11 style for 12 hour time. All others use h12.
    ja: "h11"
  },
  false: {}
};
function Sr(r, e = {}) {
  if (typeof e.hour12 == "boolean" && ho()) {
    e = {
      ...e
    };
    let n = mo[String(e.hour12)][r.split("-")[0]], o = e.hour12 ? "h12" : "h23";
    e.hourCycle = n ?? o, delete e.hour12;
  }
  let t = r + (e ? Object.entries(e).sort((n, o) => n[0] < o[0] ? -1 : 1).join() : "");
  if (Jt.has(t)) return Jt.get(t);
  let a = new Intl.DateTimeFormat(r, e);
  return Jt.set(t, a), a;
}
let Kt = null;
function ho() {
  return Kt == null && (Kt = new Intl.DateTimeFormat("en-US", {
    hour: "numeric",
    hour12: !1
  }).format(new Date(2020, 2, 3, 0)) === "24"), Kt;
}
let Qt = null;
function vo() {
  return Qt == null && (Qt = new Intl.DateTimeFormat("fr", {
    hour: "numeric",
    hour12: !1
  }).resolvedOptions().hourCycle === "h12"), Qt;
}
function po(r, e) {
  if (!e.timeStyle && !e.hour) return;
  r = r.replace(/(-u-)?-nu-[a-zA-Z0-9]+/, ""), r += (r.includes("-u-") ? "" : "-u") + "-nu-latn";
  let t = Sr(r, {
    ...e,
    timeZone: void 0
    // use local timezone
  }), a = parseInt(t.formatToParts(new Date(2020, 2, 3, 0)).find((o) => o.type === "hour").value, 10), n = parseInt(t.formatToParts(new Date(2020, 2, 3, 23)).find((o) => o.type === "hour").value, 10);
  if (a === 0 && n === 23) return "h23";
  if (a === 24 && n === 23) return "h24";
  if (a === 0 && n === 11) return "h11";
  if (a === 12 && n === 11) return "h12";
  throw new Error("Unexpected hour cycle result");
}
ie.extend(Gr);
ie.extend(an);
ie.extend(tr);
ie.extend(cn);
ie.extend(hn);
function Ge() {
  const r = /* @__PURE__ */ new Date();
  return {
    year: r.getFullYear(),
    month: r.getMonth() + 1,
    day: r.getDate()
  };
}
function go(r) {
  try {
    const e = fa(), t = bn(e);
    if (r.calendar.identifier !== t.calendar.identifier) {
      const a = ke(t, r.calendar);
      return r.compare(a) === 0;
    }
    return r.compare(t) === 0;
  } catch (e) {
    return console.error("Error checking if date is today:", e), !1;
  }
}
function Je() {
  const r = /* @__PURE__ */ new Date();
  return {
    year: r.getFullYear(),
    month: r.getMonth() + 1,
    day: r.getDate(),
    hour: r.getHours(),
    minute: r.getMinutes(),
    second: r.getSeconds()
  };
}
function Ae(r, e, t, a, n, o) {
  const l = { year: r, month: e, day: t };
  return a !== void 0 && (l.hour = a), n !== void 0 && (l.minute = n), o !== void 0 && (l.second = o), l;
}
function ve(r, e = "zh-TW", t = "gregory") {
  if (!r) return null;
  try {
    if (Mo(r))
      return r;
    if (r instanceof Date && !isNaN(r.getTime()))
      return {
        year: r.getFullYear(),
        month: r.getMonth() + 1,
        day: r.getDate(),
        hour: r.getHours(),
        minute: r.getMinutes(),
        second: r.getSeconds()
      };
    if (typeof r == "string") {
      const a = pn(r, e, t);
      return a.success ? a.date : null;
    }
    return null;
  } catch (a) {
    return console.error("Failed to parse date:", a), null;
  }
}
function Te(r, e = "YYYY-MM-DD") {
  if (!r) return null;
  try {
    return ie("2000-01-01 00:00:00").year(r.year).month(r.month - 1).date(r.day).hour(r.hour || 0).minute(r.minute || 0).second(r.second || 0).format(e);
  } catch (t) {
    return console.error("Failed to format date:", t), null;
  }
}
function At(r, e = "iso", t = "YYYY-MM-DD", a, n = !1, o = "gregory", l = "zh-TW", s = !1, u = !0) {
  if (!r) return null;
  try {
    switch (e) {
      case "iso":
        if (n) {
          let i;
          return u ? i = s ? "YYYY-MM-DDTHH:mm:ss" : "YYYY-MM-DD HH:mm:ss" : i = s ? "YYYY-MM-DDTHH:mm" : "YYYY-MM-DD HH:mm", Te(r, i);
        } else
          return Te(r, "YYYY-MM-DD");
      case "date":
        return new Date(
          r.year,
          r.month - 1,
          r.day,
          r.hour || 0,
          r.minute || 0,
          r.second || 0
        );
      case "object":
        return r;
      case "custom":
        return fe.formatOutput(r, t, a, n, o, l);
      default:
        return console.warn(`不支援的輸出類型: ${e},回退到 ISO 格式`), Te(r, "YYYY-MM-DD");
    }
  } catch (i) {
    return console.error("formatOutput 失敗:", i), r;
  }
}
function Lt(r, e) {
  const t = r.year * 1e4 + r.month * 100 + r.day, a = e.year * 1e4 + e.month * 100 + e.day;
  return t < a ? -1 : t > a ? 1 : 0;
}
function ra(r, e) {
  const t = new Date(r.year, r.month - 1, r.day);
  return t.setDate(t.getDate() + e), {
    year: t.getFullYear(),
    month: t.getMonth() + 1,
    day: t.getDate(),
    hour: r.hour,
    minute: r.minute,
    second: r.second
  };
}
function Ja(r, e) {
  const t = new Date(r.year, r.month - 1, r.day).getTime(), a = new Date(e.year, e.month - 1, e.day).getTime();
  return Math.ceil((a - t) / (1e3 * 60 * 60 * 24));
}
function yo() {
  const r = Je(), e = Ae(r.year, r.month, 1, 0, 0, 0), t = r.month === 12 ? 1 : r.month + 1, a = r.month === 12 ? r.year + 1 : r.year, n = Ae(a, t, 1), o = ra(n, -1);
  return { start: e, end: o };
}
function $o(r, e) {
  if (!r || typeof r != "string")
    return !1;
  try {
    const t = wr(r);
    let a = !0;
    if (e && (a = na(e)), !t)
      return console.warn(`日期格式語義驗證失敗: "${r}"`), !1;
    if (e && !a)
      return console.warn(`時間格式語義驗證失敗: "${e}"`), !1;
    const n = ie("2000-12-31 23:59:59");
    let o = !1;
    try {
      const i = n.format(r);
      o = i !== r && i.length > 0;
    } catch (i) {
      console.warn(`日期格式 dayjs 驗證失敗: "${r}"`, i), o = !1;
    }
    let l = !0;
    if (e)
      try {
        const i = n.format(e);
        l = i !== e && i.length > 0;
      } catch (i) {
        console.warn(`時間格式 dayjs 驗證失敗: "${e}"`, i), l = !1;
      }
    let s = !0;
    if (e)
      try {
        const i = `${r} ${e}`, m = n.format(i);
        s = m !== i && m.length > 0;
      } catch (i) {
        console.warn(`組合格式 dayjs 驗證失敗: "${r} ${e}"`, i), s = !1;
      }
    return o && l && s;
  } catch (t) {
    return console.error("格式驗證時發生錯誤:", t), !1;
  }
}
function wr(r) {
  const e = ["YYYY", "YY", "MM", "M", "DD", "D"], t = ["-", "/", ".", " "];
  let a = r;
  t.forEach((v) => {
    a = a.replace(new RegExp(`\\${v}`, "g"), " ");
  });
  const n = a.split(/\s+/).filter(Boolean);
  if (!n.every((v) => e.includes(v))) return !1;
  const l = n.some((v) => v === "YYYY" || v === "YY"), s = n.some((v) => v === "MM" || v === "M"), u = n.some((v) => v === "DD" || v === "D"), i = n.filter((v) => v === "YYYY" || v === "YY").length, m = n.filter((v) => v === "MM" || v === "M").length, g = n.filter((v) => v === "DD" || v === "D").length;
  return i > 1 || m > 1 || g > 1 ? !1 : l && s && u;
}
function na(r) {
  if (!r || typeof r != "string")
    return !1;
  const e = [
    "HH",
    "H",
    // 24 小時制
    "hh",
    "h",
    // 12 小時制
    "mm",
    "m",
    // 分鐘
    "ss",
    "s",
    // 秒
    "A",
    "a"
    // AM/PM
  ], a = r.replace(/[^\w]/g, " ").split(/\s+/).filter(Boolean);
  if (!a.every((m) => e.includes(m)))
    return !1;
  const o = a.some((m) => ["HH", "H"].includes(m)), l = a.some((m) => ["hh", "h"].includes(m)), s = a.some((m) => ["mm", "m"].includes(m));
  if (a.some((m) => ["A", "a"].includes(m)), !(o || l) || !s || l && o)
    return !1;
  const i = e.reduce((m, g) => (m[g] = a.filter((v) => v === g).length, m), {});
  return !Object.values(i).some((m) => m > 1);
}
function Do(r) {
  return r.replace(/yyyy/g, "YYYY").replace(/yy/g, "YY").replace(/mm/g, "MM").replace(/dd/g, "DD");
}
function bo(r) {
  let e = r;
  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(r) {
  return !r || typeof r != "object" ? !1 : typeof r.year == "number" && typeof r.month == "number" && typeof r.day == "number";
}
class kr {
  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, t) {
    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 l = n.replace(/[年月日時分秒]/g, ""), s = ["-", "/", ".", " "];
      for (const u of s) {
        const i = this.tryParseWithSeparator(l, u);
        if (i) return i;
      }
    }
    return null;
  }
  /**
   * 解析包含日期和時間的字串
   */
  parseDateTime(e) {
    const t = e.match(/^(\d+年\d+月\d+日)\s*(.*)$/);
    if (!t) return null;
    const [, a, n] = t, o = this.parseDatePart(a);
    if (!o) return null;
    const l = this.parseTimePart(n);
    return l ? {
      ...o,
      ...l
    } : o;
  }
  /**
   * 解析日期部分 (如: "114年06月18日")
   * 統一轉換為公元曆
   */
  parseDatePart(e) {
    const t = e.match(/(\d+)年(\d+)月(\d+)日/);
    if (!t) return null;
    const [, a, n, o] = t, l = parseInt(a), s = parseInt(n), u = parseInt(o);
    return this.validateAndConvertRocDate(l, s, u);
  }
  /**
   * 解析時間部分 (如: "上午 12時00分")
   */
  parseTimePart(e) {
    if (!e) return null;
    const t = e.trim(), a = t.match(/(上午|下午)\s*(\d{1,2})時(\d{2})分(?:(\d{2})秒)?/);
    if (a) {
      const [, o, l, s, u] = a;
      let i = parseInt(l);
      const m = parseInt(s), g = u ? parseInt(u) : 0;
      return o === "下午" && i !== 12 ? i += 12 : o === "上午" && i === 12 && (i = 0), i < 0 || i > 23 || m < 0 || m > 59 || g < 0 || g > 59 ? null : { hour: i, minute: m, second: g };
    }
    const n = t.match(/(\d{1,2}):(\d{2})(?::(\d{2}))?/);
    if (n) {
      const [, o, l, s] = n, u = parseInt(o), i = parseInt(l), m = s ? parseInt(s) : 0;
      return u < 0 || u > 23 || i < 0 || i > 59 || m < 0 || m > 59 ? null : { hour: u, minute: i, second: m };
    }
    return null;
  }
  canParseInput(e) {
    return /^(民國|民国|ROC\s*)/i.test(e.trim());
  }
  /**
   * 使用指定分隔符解析
   */
  tryParseWithSeparator(e, t) {
    const a = e.split(t).map((s) => s.trim()).filter(Boolean);
    if (a.length < 3) return null;
    const n = parseInt(a[0]), o = parseInt(a[1]), l = parseInt(a[2]);
    return this.validateAndConvertRocDate(n, o, l);
  }
  /**
  * 通用的 ROC 日期驗證和轉換方法
  */
  validateAndConvertRocDate(e, t, a) {
    if (isNaN(e) || isNaN(t) || isNaN(a) || e < this.yearRange.min || e > this.yearRange.max) return null;
    const n = e + this.YEAR_OFFSET;
    if (t < 1 || t > 12 || a < 1 || a > 31) return null;
    const o = `${n}-${t.toString().padStart(2, "0")}-${a.toString().padStart(2, "0")}`, l = ie(o, "YYYY-MM-DD", !0);
    return !l.isValid() || l.year() !== n || l.month() + 1 !== t || l.date() !== a ? null : {
      year: n,
      month: t,
      day: a
    };
  }
  /**
   * 檢查是否支援特定格式
   */
  supportsFormat(e) {
    return e.includes("ROC-") || e.includes("民國");
  }
  /**
   * 自定義格式化 - 專注於民國年的特殊格式
   */
  format(e, t, a) {
    if (!this.supportsFormat(t))
      throw new Error(`RocFormatPlugin 不支援格式: ${t}`);
    const n = e.hour !== void 0 && e.hour !== null, o = t.split(" "), l = o[0], s = o.slice(1).join(" "), u = this.formatDatePart(e, l, a);
    if (s && n) {
      const i = this.detectTimeFormat(s), m = this.formatTimePart(e, s, i);
      return `${u} ${m}`;
    }
    return u;
  }
  /**
   * 透過格式字串偵測時間制式
   */
  detectTimeFormat(e) {
    return !e.includes("A") && !e.includes("a") && !e.includes("hh");
  }
  /**
   * 格式化日期部分
   */
  formatDatePart(e, t, a) {
    const n = e.year - this.YEAR_OFFSET, o = e.month, l = e.day, s = {
      "ROC-YYYY": `民國${n}年`,
      "ROC-YYYY-MM-DD": `民國${n}年${o.toString().padStart(2, "0")}月${l.toString().padStart(2, "0")}日`,
      "ROC-YYYY/MM/DD": `民國${n}/${o.toString().padStart(2, "0")}/${l.toString().padStart(2, "0")}`,
      "ROC-NUM-YYYY-MM-DD": `${n}-${o.toString().padStart(2, "0")}-${l.toString().padStart(2, "0")}`,
      "ROC-NUM-YYYY/MM/DD": `${n}/${o.toString().padStart(2, "0")}/${l.toString().padStart(2, "0")}`
    };
    if (s[t])
      return s[t];
    const u = new Date(e.year, e.month - 1, e.day);
    let i = ie(u).format(t);
    if (t.includes("YYYY"))
      i = i.replace(e.year.toString(), n.toString());
    else if (t.includes("YY")) {
      const m = e.year.toString().slice(-2), g = n.toString().slice(-2);
      i = i.replace(m, g);
    }
    return i;
  }
  /**
   * 格式化 ROC 時間
   */
  formatTimePart(e, t, a) {
    if (!e) return "";
    const n = e.hour || 0, o = e.minute || 0, l = e.second || 0, s = this.getFormattedTime(n, o, l, t, a);
    return s || this.fallbackToDateJs(e, t, a);
  }
  /**
   * 統一的時間格式化處理
   */
  getFormattedTime(e, t, a, n, o) {
    if (o) {
      const l = {
        "HH:mm:ss": () => this.formatBasicTime(e, t, a, !0),
        "HH:mm": () => this.formatBasicTime(e, t, 0, !1),
        HH時mm分ss秒: () => this.formatChineseTime(e, t, a, !0),
        HH時mm分: () => this.formatChineseTime(e, t, 0, !1)
      };
      if (l[n])
        return l[n]();
    } else {
      const l = {
        "hh:mm:ss A": () => this.format12HourTime(e, t, a, !0, "suffix"),
        "hh:mm A": () => this.format12HourTime(e, t, 0, !1, "suffix"),
        "h:mm A": () => this.format12HourTime(e, t, 0, !1, "suffix", !1),
        "A hh:mm:ss": () => this.format12HourTime(e, t, a, !0, "prefix"),
        "A hh:mm": () => this.format12HourTime(e, t, 0, !1, "prefix"),
        "A HH時mm分ss秒": () => this.format12HourTime(e, t, a, !0, "chinese"),
        "A HH時mm分": () => this.format12HourTime(e, t, 0, !1, "chinese")
      };
      if (l[n])
        return l[n]();
    }
    return null;
  }
  /**
   * 基本時間格式化(24小時制)
   */
  formatBasicTime(e, t, a, n) {
    const o = e.toString().padStart(2, "0"), l = t.toString().padStart(2, "0");
    if (n) {
      const s = a.toString().padStart(2, "0");
      return `${o}:${l}:${s}`;
    }
    return `${o}:${l}`;
  }
  /**
   * 中文時間格式化(24小時制)
   */
  formatChineseTime(e, t, a, n) {
    const o = e.toString().padStart(2, "0"), l = t.toString().padStart(2, "0");
    if (n) {
      const s = a.toString().padStart(2, "0");
      return `${o}時${l}分${s}秒`;
    }
    return `${o}時${l}分`;
  }
  /**
   * 12小時制時間格式化(統一處理)
   */
  format12HourTime(e, t, a, n, o, l = !0) {
    const s = e < 12 ? "上午" : "下午", u = e === 0 ? 12 : e > 12 ? e - 12 : e, i = l ? u.toString().padStart(2, "0") : u.toString(), m = t.toString().padStart(2, "0"), g = n ? a.toString().padStart(2, "0") : "";
    switch (o) {
      case "suffix":
        return n ? `${i}:${m}:${g} ${s}` : `${i}:${m} ${s}`;
      case "prefix":
        return n ? `${s} ${i}:${m}:${g}` : `${s} ${i}:${m}`;
      case "chinese":
        return n ? `${s} ${i}時${m}分${g}秒` : `${s} ${i}時${m}分`;
      default:
        return "";
    }
  }
  /**
  * 回退到 dayjs 處理
  */
  fallbackToDateJs(e, t, a) {
    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 = ie(n).format(t);
    return !a && (t.includes("A") || t.includes("a")) && (o = o.replace(/AM/g, "上午").replace(/PM/g, "下午"), o = o.replace(/am/g, "上午").replace(/pm/g, "下午")), o;
  }
}
class fe {
  /**
   * 安全地創建日曆實例
   */
  static createSafeCalendar(e) {
    try {
      return fo(e);
    } catch (t) {
      return console.warn(`無法創建日曆 ${e},回退到西元曆:`, t), new xe();
    }
  }
  /**
   * 安全地進行日曆轉換
   */
  static safeToCalendar(e, t) {
    try {
      return ke(e, t);
    } catch (a) {
      return console.warn("日曆轉換失敗,返回原始日期:", a), e;
    }
  }
  /**
   * 智能轉換:根據是否有時間資訊自動選擇類型
   */
  static convertToCalendarDateSmart = (e, t) => e ? e.hour !== void 0 || e.minute !== void 0 || e.second !== void 0 ? this.convertToCalendarDateTime(e, t) : this.convertToCalendarDate(e, t) : null;
  /**
   * 統一的轉換函數:SimpleDateValue → CalendarDate
   */
  static convertToCalendarDate = (e, t) => {
    if (!e || e.year <= 0 || e.month <= 0 || e.day <= 0 || e.month > 12 || e.day > 31)
      return null;
    try {
      if (t === "gregory")
        return new le(e.year, e.month, e.day);
      {
        const a = this.createSafeCalendar(t), n = new le(e.year, e.month, e.day);
        return this.safeToCalendar(n, a);
      }
    } catch (a) {
      return console.error("轉換為 CalendarDate 失敗:", a), null;
    }
  };
  /**
   * 統一的轉換函數:SimpleDateValue → CalendarDateTime (日期+時間)
   */
  static convertToCalendarDateTime = (e, t) => {
    if (!e) return null;
    try {
      if (t === "gregory")
        return new rt(
          e.year,
          e.month,
          e.day,
          e.hour || 0,
          e.minute || 0,
          e.second || 0
        );
      {
        const a = this.createSafeCalendar(t), n = new rt(
          e.year,
          e.month,
          e.day,
          e.hour || 0,
          e.minute || 0,
          e.second || 0
        );
        return ke(n, a);
      }
    } catch (a) {
      return console.error("轉換為 CalendarDateTime 失敗:", a), null;
    }
  };
  /**
   * 統一的轉換函數:CalendarDate → SimpleDateValue
   */
  static convertFromCalendarDate = (e, t) => {
    if (!e) return null;
    try {
      if (e.calendar.identifier === "gregory" || t === "gregory")
        return {
          year: e.year,
          month: e.month,
          day: e.day
        };
      {
        const a = this.createSafeCalendar("gregory"), n = this.safeToCalendar(e, a);
        return {
          year: n.year,
          month: n.month,
          day: n.day
        };
      }
    } catch (a) {
      return console.error("轉換從 CalendarDate 失敗:", a), null;
    }
  };
  /**
   * 安全地生成日曆網格
   */
  static generateCalendarDays(e, t, a, n, o = 0) {
    try {
      if (!this.isCalendarSupported(a))
        return console.warn(`不支持的日曆系統: ${a}`), [];
      const l = this.createSafeCalendar(a), s = new le(e, t, 1), u = a === "gregory" ? s : this.safeToCalendar(s, l), i = Tn(u, n) ?? 6, g = (rr(u, n) - o + 7) % 7, v = u.subtract({ days: g }), k = [];
      let T = v;
      const f = i * 7;
      for (let p = 0; p < f; p++)
        k.push(T), T = T.add({ days: 1 });
      return k;
    } catch (l) {
      return console.error("生成日曆網格失敗:", l), [];
    }
  }
  /**
   * 獲取日曆系統的有效年份範圍 (新版本)
   */
  static getCalendarRange(e) {
    const t = (/* @__PURE__ */ new Date()).getFullYear();
    return {
      gregory: { min: 1, max: t + 100 },
      japanese: { min: 1868, max: t + 100 },
      roc: { min: 1912, max: t + 100 },
      buddhist: { min: 544, max: t + 643 },
      islamic: { min: 622, max: t + 100 },
      persian: { min: 622, max: t + 100 },
      hebrew: { min: 1, max: t + 3860 }
    }[e] || { min: 1, max: t + 100 };
  }
  /**
   * 轉換西元年到目標日曆系統年份
   */
  static convertGregorianYear(e, t) {
    if (t === "gregory")
      return { localYear: e, isValid: !0 };
    try {
      const a = new le(e, 1, 1), n = this.createSafeCalendar(t), o = this.safeToCalendar(a, n), l = this.getCalendarRange(t), s = e >= l.min && e <= l.max;
      return { localYear: o.year, isValid: s };
    } catch (a) {
      return console.warn(`年份轉換失敗 ${e} -> ${t}:`, a), { localYear: e, isValid: !1 };
    }
  }
  /**
   * 轉換目標日曆年份到西元年
   */
  static convertToGregorianYear(e, t) {
    if (t === "gregory")
      return e;
    try {
      const a = this.createSafeCalendar(t), n = new le(a, e, 1, 1);
      return this.safeToCalendar(n, new xe()).year;
    } catch (a) {
      return console.warn(`年份轉換失敗 ${e} ${t} -> Gregory:`, a), e;
    }
  }
  /**
   * 獲取月份名稱
   */
  static getMonthNames(e, t = "gregory") {
    try {
      const a = new Intl.DateTimeFormat(e, { month: "short" });
      return Array.from({ length: 12 }, (n, o) => {
        const l = new Date(2e3, o, 1);
        return a.format(l);
      });
    } catch (a) {
      return console.warn(`獲取月份名稱失敗 ${t}:`, a), 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, t = "zh-TW") {
    const a = {
      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 a[e]?.[t] || a[e]?.["en-US"] || e;
  }
  // ==================================================================== //
  /**
   * 驗證日期在指定日曆系統中是否有效
   */
  static isValidDate(e, t, a, n) {
    try {
      if (!this.isCalendarSupported(n))
        return console.warn(`不支持的日曆系統: ${n}`), !1;
      if (e <= 0 || t <= 0 || a <= 0 || t > 12 || a > 31)
        return !1;
      let o;
      if (n === "gregory")
        o = new le(e, t, a);
      else {
        const s = this.createSafeCalendar(n);
        o = new le(s, e, t, a);
      }
      return o.year === e && o.month === t && o.day === a;
    } catch (o) {
      return console.warn(`日期驗證失敗 ${e}-${t}-${a} 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, t = "YYYY-MM-DD", a, n = !1, o = "gregory", l = "zh-TW") {
    if (!e) return "";
    let s;
    if (n && a)
      s = `${t} ${a}`;
    else if (n) {
      const u = e.hour !== void 0 || e.minute !== void 0 || e.second !== void 0;
      s = `${t} HH:mm:ss`;
    } else
      s = t;
    try {
      switch (o) {
        case "gregory":
          $o(t, a) || (s = e.hour !== void 0 || e.minute !== void 0 || e.second !== void 0 ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD");
          const m = new Date(
            e.year,
            e.month - 1,
            e.day,
            e.hour || 0,
            e.minute || 0,
            e.second || 0
          );
          return ie(m).format(s);
        case "roc":
          const g = new kr();
          if (g.supportsFormat(s) && g.canParseInput(s))
            return g.format(e, s, l);
          break;
        // 其他日曆插件可以在這裡添加
        case "buddhist":
        case "japanese":
        case "islamic":
        case "persian":
        case "hebrew":
          break;
      }
      const u = this.convertToCalendarDateSmart(e, o);
      if (u) {
        const m = e.hour !== void 0 || e.minute !== void 0 || e.second !== void 0, g = {
          calendar: o,
          year: "numeric",
          month: "long",
          day: "numeric"
        };
        return m && (g.hour = "numeric", g.minute = "numeric", e.second !== void 0 && (g.second = "numeric")), new Pt(l, g).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 ie(i).format(s);
    } 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: zs,
  convertFromCalendarDate: Ws,
  // 日曆基礎
  createSafeCalendar: js,
  safeToCalendar: _s,
  generateCalendarDays: Js,
  // 年份轉換 (YearSelector)
  convertGregorianYear: Ks,
  convertToGregorianYear: Qs,
  getCalendarRange: Zs,
  // getCalendarYearRange,
  // 顯示相關
  getMonthNames: Gs,
  getCalendarDisplayName: Xs,
  // 日曆系統輸出輸入轉換
  // isValidDate,
  // parseInput,
  isCalendarSupported: ei,
  formatOutput: ti
} = fe, Xe = (r) => /^\d+$/.test(r), Ka = (r) => r % 4 === 0 && r % 100 !== 0 || r % 400 === 0;
let Oe = null;
function So() {
  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 oa = /* @__PURE__ */ new WeakMap();
function wo(r, e = "") {
  const t = So(), a = getComputedStyle(r);
  return t.style.font = a.font, t.style.fontSize = a.fontSize, t.style.fontWeight = a.fontWeight, t.style.letterSpacing = a.letterSpacing, t.style.padding = a.padding, t.style.border = a.border, t.style.boxSizing = a.boxSizing, t.textContent = r.value || e || "", t.offsetWidth + 4;
}
function st(r) {
  const e = r.placeholder || "", t = wo(r, e), a = oa.get(r) || 0;
  r.style.width = `${Math.max(t, a)}px`;
}
const et = {
  // 初始設置
  mounted(r, e) {
    e.value && typeof e.value == "number" && oa.set(r, e.value), st(r), r.addEventListener("input", () => st(r)), document.fonts && document.fonts.ready && document.fonts.ready.then(() => st(r));
  },
  // 處理更新
  updated(r, e) {
    e.value && typeof e.value == "number" && e.oldValue !== e.value && oa.set(r, e.value), st(r);
  },
  // 為 Vue 3 添加 beforeUnmount
  beforeUnmount(r) {
    r.removeEventListener("input", () => st(r));
  }
}, ko = { class: "date-input-container flex items-center justify-start" }, To = ["placeholder", "aria-invalid", "aria-errormessage"], xo = ["placeholder", "aria-invalid", "aria-errormessage"], Co = ["placeholder", "aria-invalid", "aria-errormessage"], Yo = {
  key: 3,
  class: "text-gray-400"
}, Ro = /* @__PURE__ */ Ce({
  __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" }
  },
  emits: ["update:modelValue", "validation", "complete"],
  setup(r, { expose: e, emit: t }) {
    const a = {
      mounted: et.mounted,
      updated: et.updated,
      beforeUnmount: et.beforeUnmount
    }, n = r, o = t, l = W(""), s = W(""), u = W(""), i = W({}), m = W({}), g = W(null), v = W(!1), k = W(!1), T = W(null), f = W(/* @__PURE__ */ new Map()), p = (R, Y) => {
      R && R instanceof HTMLInputElement ? f.value.set(Y, R) : f.value.delete(Y);
    }, d = (R) => f.value.get(R), S = C(() => {
      const R = {};
      return Object.entries(i.value).forEach(([Y, B]) => {
        R[Y] = B.key;
      }), R;
    }), w = C(() => Object.keys(i.value).length > 0), h = C(() => Object.values(S.value)), b = C(() => {
      const R = n.dateFormat.toUpperCase(), Y = [];
      return R.split(/[^A-Z]+/).filter(Boolean).forEach((te) => {
        te.includes("Y") ? Y.push("year") : te.includes("M") ? Y.push("month") : te.includes("D") && Y.push("day");
      }), Y.length !== 3 ? (console.warn(`Invalid date format: ${n.dateFormat}, falling back to YYYY-MM-DD`), ["year", "month", "day"]) : Y;
    }), $ = C(() => {
      if (!l.value || !s.value || !u.value)
        return null;
      const R = l.value.padStart(4, "0"), Y = s.value.padStart(2, "0"), B = u.value.padStart(2, "0");
      return `${R}-${Y}-${B}`;
    }), c = C(() => {
      if (!$.value) return null;
      const R = ie($.value);
      return R.isValid() ? R.format(n.dateFormat) : null;
    });
    de(() => n.modelValue, (R) => {
      if (v.value || (v.value = !0), R) {
        const Y = ve(R);
        Y && (l.value = Y.year.toString(), s.value = Y.month.toString().padStart(2, "0"), u.value = Y.day.toString().padStart(2, "0"));
      } else
        l.value = "", s.value = "", u.value = "";
      R || (T.value = null, k.value = !1);
    }, { immediate: !0 });
    const y = () => {
      if (b.value.length === 0) return;
      const R = b.value[0], Y = d(R);
      if (Y && typeof Y.focus == "function")
        try {
          Y.focus();
        } catch (B) {
          console.warn("無法聚焦到輸入框:", B);
        }
      else
        for (const B of b.value) {
          const te = d(B);
          if (te && typeof te.focus == "function")
            try {
              te.focus();
              break;
            } catch (Q) {
              console.warn("無法聚焦到輸入框:", Q);
            }
        }
    }, D = (R) => {
      const Y = d(R);
      if (Y && typeof Y.focus == "function")
        try {
          Y.focus();
        } catch (B) {
          console.warn(`無法聚焦到 ${R} 輸入框:`, B);
        }
    }, P = (R, Y) => {
      const B = d(R);
      if (B)
        try {
          if (typeof B.focus == "function" && B.focus(), typeof B.setSelectionRange == "function") {
            const te = Y === "end" ? B.value.length : 0;
            B.setSelectionRange(te, te);
          }
        } catch (te) {
          console.warn(`無法聚焦或設置游標位置到 ${R} 輸入框:`, te);
        }
    }, z = (R, Y) => {
      const B = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
      return Y === 2 ? Ka(R) ? 29 : 28 : B[Y];
    }, J = (R, Y) => {
      if (!Y) return { valid: !0 };
      const B = parseInt(Y);
      switch (R) {
        case "year":
          if (Y.length < 4) return { valid: !0 };
          const te = n.maxDate ? ie(n.maxDate).year() : (/* @__PURE__ */ new Date()).getFullYear() + 50, Q = n.minDate ? ie(n.minDate).year() : 1;
          if (!Xe(Y) || B < Q || B > te)
            return { valid: !1, error: { key: "year.outOfRange", params: { min: Q, max: te } } };
          if (s.value === "02" && u.value === "29" && !Ka(B))
            return { valid: !1, error: { key: "year.notLeapYear", params: { year: B } } };
          break;
        case "month":
          if (!Xe(Y) || B < 1 || B > 12)
            return { valid: !1, error: { key: "month.outOfRange" } };
          if (u.value && l.value) {
            const N = parseInt(l.value), K = z(N, B);
            if (parseInt(u.value) > K)
              return { valid: !1, error: { key: "day.notExistInMonth", params: { month: Y, maxDays: K } } };
          }
          break;
        case "day":
          if (!Xe(Y) || B < 1 || B > 31)
            return { valid: !1, error: { key: "day.outOfRange" } };
          if (l.value && s.value) {
            const N = parseInt(l.value), K = parseInt(s.value), ae = z(N, K);
            if (B > ae)
              return K === 2 && B === 29 ? { valid: !1, error: { key: "year.notLeapYear", params: { year: N } } } : { valid: !1, error: { key: "day.notExistInMonth", params: { month: s.value, maxDays: ae } } };
          }
          break;
      }
      return i.value[R] && (delete i.value[R], delete m.value[R]), { valid: !0 };
    }, j = () => {
      if (!v.value) return;
      i.value = {}, m.value = {};
      const R = J("year", l.value), Y = J("month", s.value), B = J("day", u.value);
      if (!R.valid && R.error && (i.value.year = R.error, R.error.params && (m.value.year = R.error.params)), !Y.valid && Y.error && (i.value.month = Y.error, Y.error.params && (m.value.month = Y.error.params)), !B.valid && B.error && (i.value.day = B.error, B.error.params && (m.value.day = B.error.params)), n.required && (l.value || (i.value.year = { key: "year.required" }), s.value || (i.value.month = { key: "month.required" }), u.value || (i.value.day = { key: "day.required" })), $.value && Object.keys(i.value).length === 0) {
        const te = ie($.value);
        if (!te.isValid())
          i.value.day = { key: "day.invalid" };
        else if (n.minDate && te.isBefore(ie(n.minDate)))
          i.value.day = {
            key: "date.beforeMin",
            params: { minDate: ie(n.minDate).format(n.dateFormat) }
          }, m.value.day = { minDate: ie(n.minDate).format(n.dateFormat) };
        else if (n.maxDate && te.isAfter(ie(n.maxDate)))
          i.value.day = {
            key: "date.afterMax",
            params: { maxDate: ie(n.maxDate).format(n.dateFormat) }
          }, m.value.day = { maxDate: ie(n.maxDate).format(n.dateFormat) };
        else if (c.value) {
          o("update:modelValue", c.value);
          const Q = c.value;
          Q !== T.value && !k.value && (T.value = Q, o("complete", c.value));
        }
      } else v.value && !l.value && !s.value && !u.value && (o("update:modelValue", null), T.value = null);
      o("validation", !w.value, S.value, m.value);
    }, X = () => {
      l.value = "", s.value = "", u.value = "", i.value = {};
    }, Z = (R) => {
      const Y = b.value.findIndex((te) => te === R), B = Y < b.value.length - 1 ? b.value[Y + 1] : null;
      B ? we(() => {
        D(B);
      }) : j();
    }, I = (R, Y, B, te) => {
      const Q = Y.replace(/\D/g, "");
      if (Q.length === 1 && k.value && (k.value = !1), Q.length <= B) {
        if (te && Q.length === 1 && parseInt(Q) > te) {
          const N = Q.padStart(2, "0");
          R === "year" ? l.value = N : R === "month" ? s.value = N : R === "day" && (u.value = N), Z(R);
        } else
          R === "year" ? l.value = Q : R === "month" ? s.value = Q : R === "day" && (u.value = Q);
        Q.length === B && Z(R);
      }
    }, E = (R) => {
      const Y = R.target;
      I("year", Y.value, 4);
    }, M = (R) => {
      const Y = R.target;
      I("month", Y.value, 2, 1);
    }, H = (R) => {
      const Y = R.target;
      I("day", Y.value, 2, 3);
    }, q = () => {
      we(() => {
        if (b.value.length === 0) return;
        const R = b.value[b.value.length - 1], Y = d(R);
        if (Y && typeof Y.focus == "function")
          try {
            Y.focus();
            const B = Y.value.length;
            Y.setSelectionRange(B, B);
          } catch (B) {
            console.warn("無法聚焦到最後一個輸入框:", B);
          }
      });
    }, ee = (R, Y) => {
      const B = R.target, te = b.value.findIndex((K) => K === Y), Q = te > 0 ? b.value[te - 1] : null, N = te < b.value.length - 1 ? b.value[te + 1] : null;
      R.key === "Backspace" && B.value === "" && Q && (R.preventDefault(), k.value = !0, P(Q, "end")), R.key === "ArrowLeft" && B.selectionStart === 0 && Q && (R.preventDefault(), k.value = !0, P(Q, "end")), R.key === "ArrowRight" && B.selectionStart === B.value.length && N && (R.preventDefault(), k.value = !0, P(N, "start")), R.key === "Enter" && j();
    }, me = (R) => {
      g.value = R;
    }, se = (R) => {
      j(), g.value = null;
    };
    return e({
      validate: j,
      reset: () => {
        X(), o("update:modelValue", null);
      },
      getErrors: () => ({ ...i.value }),
      hasErrors: () => w.value,
      errorMessages: () => h.value,
      focus: y,
      focusLast: q,
      setDate: (R) => {
        if (R) {
          const Y = ve(R);
          Y && (l.value = Y.year.toString(), s.value = Y.month.toString().padStart(2, "0"), u.value = Y.day.toString().padStart(2, "0"), j());
        } else
          X(), o("update:modelValue", null);
      },
      resetCompletionState: () => {
        k.value = !1, T.value = null;
      }
    }), (R, Y) => (A(), L("div", ko, [
      (A(!0), L(De, null, $e(b.value, (B, te) => (A(), L(De, { key: B }, [
        B === "year" ? Ee((A(), L("input", {
          key: 0,
          ref_for: !0,
          ref: (Q) => p(Q, "year"),
          "onUpdate:modelValue": Y[0] || (Y[0] = (Q) => l.value = Q),
          type: "text",
          inputmode: "numeric",
          placeholder: R.yearPlaceholder,
          maxlength: 4,
          class: "date-input text-sm text-center active:bg-vdt-theme-100",
          onInput: E,
          onKeydown: Y[1] || (Y[1] = (Q) => ee(Q, "year")),
          onFocus: Y[2] || (Y[2] = (Q) => me("year")),
          onBlur: Y[3] || (Y[3] = (Q) => se()),
          "aria-label": "year",
          "aria-invalid": !!S.value.year,
          "aria-errormessage": S.value.year ? "year-error" : void 0
        }, null, 40, To)), [
          [We, l.value],
          [a, 20]
        ]) : B === "month" ? Ee((A(), L("input", {
          key: 1,
          ref_for: !0,
          ref: (Q) => p(Q, "month"),
          "onUpdate:modelValue": Y[4] || (Y[4] = (Q) => s.value = Q),
          type: "text",
          inputmode: "numeric",
          placeholder: R.monthPlaceholder,
          maxlength: 2,
          class: "date-input text-sm text-center",
          onInput: M,
          onKeydown: Y[5] || (Y[5] = (Q) => ee(Q, "month")),
          onFocus: Y[6] || (Y[6] = (Q) => me("month")),
          onBlur: Y[7] || (Y[7] = (Q) => se()),
          "aria-label": "month",
          "aria-invalid": !!S.value.month,
          "aria-errormessage": S.value.month ? "month-error" : void 0
        }, null, 40, xo)), [
          [We, s.value],
          [a, 20]
        ]) : B === "day" ? Ee((A(), L("input", {
          key: 2,
          ref_for: !0,
          ref: (Q) => p(Q, "day"),
          "onUpdate:modelValue": Y[8] || (Y[8] = (Q) => u.value = Q),
          type: "text",
          inputmode: "numeric",
          placeholder: R.dayPlaceholder,
          maxlength: 2,
          class: "date-input text-sm text-center",
          onInput: H,
          onKeydown: Y[9] || (Y[9] = (Q) => ee(Q, "day")),
          onFocus: Y[10] || (Y[10] = (Q) => me("day")),
          onBlur: Y[11] || (Y[11] = (Q) => se()),
          "aria-label": "day",
          "aria-invalid": !!S.value.day,
          "aria-errormessage": S.value.day ? "day-error" : void 0
        }, null, 40, Co)), [
          [We, u.value],
          [a, 20]
        ]) : ce("", !0),
        te < b.value.length - 1 ? (A(), L("span", Yo, oe(R.separator), 1)) : ce("", !0)
      ], 64))), 128))
    ]));
  }
}), Ue = (r, e) => {
  const t = r.__vccOpts || r;
  for (const [a, n] of e)
    t[a] = n;
  return t;
}, la = /* @__PURE__ */ Ue(Ro, [["__scopeId", "data-v-917a492c"]]), Eo = { class: "time-input-container flex items-center justify-center" }, Io = ["placeholder", "aria-invalid", "aria-errormessage"], Oo = ["placeholder", "aria-invalid", "aria-errormessage"], Vo = ["placeholder", "aria-invalid", "aria-errormessage"], Fo = /* @__PURE__ */ Ce({
  __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 }
  },
  emits: ["update:modelValue", "validation", "complete", "navigate-to-date"],
  setup(r, { expose: e, emit: t }) {
    const a = {
      mounted: et.mounted,
      updated: et.updated,
      beforeUnmount: et.beforeUnmount
    }, n = r, o = t, l = W(""), s = W(""), u = W(""), i = W("AM"), m = W({}), g = W({}), v = W(null), k = W(!1), T = W(), f = W(), p = W(), d = C(() => Object.keys(m.value).length > 0), S = C(() => {
      const I = {};
      return Object.entries(m.value).forEach(([E, M]) => {
        I[E] = M.key;
      }), I;
    }), w = () => {
      l.value = "", s.value = "", u.value = "", i.value = "AM";
    }, h = C(() => {
      if (!n.useLocalizedPeriod) return i.value;
      try {
        const I = /* @__PURE__ */ new Date();
        I.setHours(9, 0, 0);
        const E = /* @__PURE__ */ new Date();
        E.setHours(15, 0, 0);
        const M = new Intl.DateTimeFormat(n.locale, {
          hour: "numeric",
          hour12: !0
        }), H = M.formatToParts(I), q = M.formatToParts(E), ee = H.find((se) => se.type === "dayPeriod")?.value || "AM", me = q.find((se) => se.type === "dayPeriod")?.value || "PM";
        return i.value === "AM" ? ee : me;
      } catch (I) {
        return console.error("Error getting localized period:", I), i.value;
      }
    }), b = C(() => h.value), $ = C(() => {
      if (l.value === "" || s.value === "" || n.enableSeconds && u.value === "")
        return null;
      let I = parseInt(l.value, 10);
      n.use24Hour || (i.value === "PM" && I < 12 ? I += 12 : i.value === "AM" && I === 12 && (I = 0));
      const E = I.toString().padStart(2, "0"), M = s.value.padStart(2, "0");
      if (n.enableSeconds) {
        const H = u.value.padStart(2, "0");
        return `${E}:${M}:${H}`;
      } else
        return `${E}:${M}`;
    });
    de(() => n.modelValue, (I) => {
      if (k.value || (k.value = !0), I) {
        const E = I.split(":");
        let M = parseInt(E[0] || "0", 10);
        const H = (E[1] || "").replace(/\D/g, ""), q = (E[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)), l.value = M.toString().padStart(2, "0"), s.value = H, n.enableSeconds && (u.value = q);
      } else
        w();
    }, { immediate: !0 });
    const c = (I, E) => {
      if (!E) return { valid: !0 };
      const M = parseInt(E);
      switch (I) {
        case "hour":
          const H = n.use24Hour ? 23 : 12, q = n.use24Hour ? 0 : 1;
          if (!Xe(E) || M < q || M > H)
            return { valid: !1, error: { key: "time.hourOutOfRange", params: { min: q, max: H } } };
          break;
        case "minute":
          if (!Xe(E) || 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 (!Xe(E) || M < 0 || M > 59)
            return { valid: !1, error: { key: "time.secondOutOfRange", params: { min: 0, max: 59 } } };
          break;
      }
      return m.value[I] && (delete m.value[I], delete g.value[I]), { valid: !0 };
    }, y = () => {
      i.value = i.value === "AM" ? "PM" : "AM", D();
    }, D = () => {
      if (!k.value) return;
      m.value = {}, g.value = {};
      const I = c("hour", l.value), E = c("minute", s.value), M = n.enableSeconds ? c("second", u.value) : { valid: !0 };
      !I.valid && I.error && (m.value.hour = I.error, I.error.params && (g.value.hour = I.error.params)), !E.valid && E.error && (m.value.minute = E.error, E.error.params && (g.value.minute = E.error.params)), !M.valid && M.error && (m.value.second = M.error, M.error.params && (g.value.second = M.error.params)), n.required && (l.value || (m.value.hour = { key: "time.hourRequired" }), s.value || (m.value.minute = { key: "time.minuteRequired" }), n.enableSeconds && !u.value && (m.value.second = { key: "time.secondRequired" })), o("validation", !d.value, S.value, g.value), $.value ? (o("update:modelValue", $.value), o("complete", $.value)) : k.value && o("update:modelValue", null);
    }, P = (I) => {
      const M = I.target.value.replace(/\D/g, "");
      if (M.length <= 2) {
        if (l.value = M, !c("hour", M).valid) return;
        (M.length === 2 || n.use24Hour && parseInt(M) > 2 || !n.use24Hour && parseInt(M) > 1) && we(() => {
          f.value?.focus();
        });
      }
    }, z = (I) => {
      const M = I.target.value.replace(/\D/g, "");
      if (M.length <= 2) {
        if (M.length === 1 && parseInt(M) > 5 ? (s.value = M.padStart(2, "0"), we(() => {
          n.enableSeconds && p.value ? p.value.focus() : D();
        })) : s.value = M, !c("minute", M).valid) return;
        M.length === 2 && we(() => {
          n.enableSeconds && p.value ? p.value.focus() : D();
        });
      }
    }, J = (I) => {
      const M = I.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, !c("second", M).valid) return;
        M.length === 2 && D();
      }
    }, j = (I, E) => {
      const M = I.target;
      if (I.key === "Backspace" && M.value === "")
        switch (E) {
          case "hour":
            I.preventDefault(), o("navigate-to-date");
            break;
          case "minute":
            I.preventDefault(), T.value?.focus(), T.value?.setSelectionRange(-1, -1);
            break;
          case "second":
            I.preventDefault(), f.value?.focus(), f.value?.setSelectionRange(-1, -1);
            break;
        }
      if (I.key === "ArrowLeft" && M.selectionStart === 0)
        switch (E) {
          case "hour":
            I.preventDefault(), o("navigate-to-date");
            break;
          case "minute":
            I.preventDefault(), T.value?.focus(), T.value?.setSelectionRange(-1, -1);
            break;
          case "second":
            I.preventDefault(), f.value?.focus(), f.value?.setSelectionRange(-1, -1);
            break;
        }
      if (I.key === "ArrowRight" && M.selectionStart === M.value.length)
        switch (E) {
          case "hour":
            I.preventDefault(), f.value?.focus(), f.value?.setSelectionRange(0, 0);
            break;
          case "minute":
            n.enableSeconds && (I.preventDefault(), p.value?.focus(), p.value?.setSelectionRange(0, 0));
            break;
        }
      I.key === "Enter" && D();
    }, X = (I) => {
      v.value = I;
    }, Z = (I) => {
      v.value = null, D();
    };
    return e({
      validate: D,
      reset: () => {
        w(), m.value = {}, g.value = {}, o("update:modelValue", null);
      },
      getErrors: () => S.value,
      hasErrors: d,
      setTime: (I) => {
        if (I) {
          const [E, M, H] = I.split(":");
          let q = parseInt(E);
          n.use24Hour || (q >= 12 ? (i.value = "PM", q = q === 12 ? 12 : q - 12) : (i.value = "AM", q = q === 0 ? 12 : q)), l.value = q.toString().padStart(2, "0"), s.value = M, n.enableSeconds && H && (u.value = H), D();
        } else
          w(), o("update:modelValue", null);
      },
      focus: () => {
        T.value?.focus();
      },
      focusLast: () => {
        n.enableSeconds && p.value ? (p.value.focus(), p.value.setSelectionRange(0, 0)) : f.value ? (f.value.focus(), f.value.setSelectionRange(0, 0)) : T.value && (T.value.focus(), T.value.setSelectionRange(0, 0));
      }
    }), (I, E) => (A(), L("div", Eo, [
      Ee(_("input", {
        ref_key: "hourRef",
        ref: T,
        "onUpdate:modelValue": E[0] || (E[0] = (M) => l.value = M),
        type: "text",
        inputmode: "numeric",
        placeholder: I.hourPlaceholder,
        maxlength: 2,
        class: "time-input text-sm text-center",
        onInput: P,
        onKeydown: E[1] || (E[1] = (M) => j(M, "hour")),
        onFocus: E[2] || (E[2] = (M) => X("hour")),
        onBlur: E[3] || (E[3] = (M) => Z()),
        "aria-label": "hour",
        "aria-invalid": !!m.value.hour,
        "aria-errormessage": m.value.hour ? "hour-error" : void 0
      }, null, 40, Io), [
        [We, l.value],
        [a, 20]
      ]),
      E[13] || (E[13] = _("span", { class: "text-gray-400 mx-1" }, ":", -1)),
      Ee(_("input", {
        ref_key: "minuteRef",
        ref: f,
        "onUpdate:modelValue": E[4] || (E[4] = (M) => s.value = M),
        type: "text",
        inputmode: "numeric",
        placeholder: I.minutePlaceholder,
        maxlength: 2,
        class: "time-input text-sm text-center",
        onInput: z,
        onKeydown: E[5] || (E[5] = (M) => j(M, "minute")),
        onFocus: E[6] || (E[6] = (M) => X("minute")),
        onBlur: E[7] || (E[7] = (M) => Z()),
        "aria-label": "minute",
        "aria-invalid": !!m.value.minute,
        "aria-errormessage": m.value.minute ? "minute-error" : void 0
      }, null, 40, Oo), [
        [We, s.value],
        [a, 20]
      ]),
      I.enableSeconds ? (A(), L(De, { key: 0 }, [
        E[12] || (E[12] = _("span", { class: "text-gray-400 mx-1" }, ":", -1)),
        Ee(_("input", {
          ref_key: "secondRef",
          ref: p,
          "onUpdate:modelValue": E[8] || (E[8] = (M) => u.value = M),
          type: "text",
          inputmode: "numeric",
          placeholder: I.secondPlaceholder,
          maxlength: 2,
          class: "time-input text-sm text-center",
          onInput: J,
          onKeydown: E[9] || (E[9] = (M) => j(M, "second")),
          onFocus: E[10] || (E[10] = (M) => X("second")),
          onBlur: E[11] || (E[11] = (M) => Z()),
          "aria-label": "second",
          "aria-invalid": !!m.value.second,
          "aria-errormessage": m.value.second ? "second-error" : void 0
        }, null, 40, Vo), [
          [We, u.value],
          [a, 20]
        ])
      ], 64)) : ce("", !0),
      I.use24Hour ? ce("", !0) : (A(), L("button", {
        key: 1,
        type: "button",
        class: ge(["time-period pl-2 text-sm cursor-pointer", l.value ? "text-vdt-content" : "text-gray-400"]),
        onClick: Se(y, ["stop"])
      }, oe(b.value), 3))
    ]));
  }
}), sa = /* @__PURE__ */ Ue(Fo, [["__scopeId", "data-v-fb3720c7"]]), 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(r, e) {
  return r.replace(/\{(\w+)\}/g, (t, a) => e[a]?.toString() || t);
}
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, t) {
    Ve[e] = t;
  }
  // 檢查語言包是否存在
  hasLocale(e) {
    return !!Ve[e];
  }
  // 獲取所有可用語言
  getAvailableLocales() {
    return Object.keys(Ve);
  }
  getCurrentLocale() {
    return this.currentLocale;
  }
  getMessage(e, t) {
    const a = e.split(".");
    let n = Ve[this.currentLocale];
    for (const o of a)
      n = n?.[o];
    return typeof n != "string" ? (console.warn(`Missing translation for path: ${e} in locale: ${this.currentLocale}`), e) : t ? Tr(n, t) : n;
  }
  getErrorMessage(e, t) {
    return this.getMessage(`error.${e}`, t);
  }
  getPlaceholderMessage(e, t) {
    return this.getMessage(`placeholder.${e}`, t);
  }
  // 支援自定義語言包
  addCustomMessages(e, t) {
    if (!Ve[e]) {
      console.warn(`Locale '${e}' not found. Please register it first using registerLocale().`);
      return;
    }
    Ve[e] = {
      ...Ve[e],
      ...this.deepMerge(Ve[e], t)
    };
  }
  // addCustomMessages(locale: LocaleKey, messages: Partial<ErrorMessages>): void {
  //     localeMessages[locale] = {
  //         ...localeMessages[locale],
  //         ...this.deepMerge(localeMessages[locale], messages)
  //     };
  // }
  /**
   * 獲取參數化錯誤訊息
   */
  getParameterizedErrorMessage(e, t = {}) {
    const a = this.getErrorMessage(e);
    return this.interpolateParameters(a, t);
  }
  /**
   * 參數插值
   */
  interpolateParameters(e, t = {}) {
    return !t || Object.keys(t).length === 0 ? e : e.replace(/\{(\w+)\}/g, (a, n) => {
      const o = t[n];
      return o == null ? (console.warn(`Missing variable '${n}' for template: "${e}"`), a) : String(o);
    });
  }
  deepMerge(e, t) {
    const a = { ...e };
    for (const n in t)
      t[n] && typeof t[n] == "object" && !Array.isArray(t[n]) ? a[n] = this.deepMerge(a[n] || {}, t[n]) : a[n] = t[n];
    return a;
  }
}
function gt(r = "en-US", e) {
  const t = new qo(), a = W(r);
  e && r && t.registerLocale(r, e), t.setLocale(r);
  const n = (g, v) => {
    a.value = g, v && t.registerLocale(g, v), t.setLocale(g);
  }, o = (g, v) => t.getMessage(g, v), l = (g, v) => t.getErrorMessage(g, v), s = (g, v) => t.getPlaceholderMessage(g, v), u = (g, v) => Tr(g, v), i = (g, v) => {
    t.registerLocale(g, v);
  }, m = (g) => t.hasLocale(g);
  return {
    currentLocale: C(() => a.value),
    setLocale: n,
    getMessage: o,
    getErrorMessage: l,
    getPlaceholderMessage: s,
    formatText: u,
    registerCustomLocale: i,
    hasLocale: m
  };
}
const Uo = {
  key: 0,
  class: "date-error-message mt-1 text-sm text-red-500"
}, No = { key: 0 }, zo = { key: 1 }, Wo = { key: 2 }, xr = /* @__PURE__ */ Ce({
  __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(r, { expose: e }) {
    const t = r, { currentLocale: a, setLocale: n, getErrorMessage: o } = gt(t.locale);
    de(() => t.locale, (d) => {
      d && t.useI18n && n(d);
    }, { immediate: !0 });
    const l = W({}), s = W({}), u = C(() => ({
      ...t.customMessages,
      ...l.value
    })), i = C(() => t.errors ? Array.isArray(t.errors) ? t.errors.length > 0 : typeof t.errors == "string" ? t.errors.trim().length > 0 : typeof t.errors == "object" ? Object.values(t.errors).some((d) => d && d.trim().length > 0) : !1 : !1), m = C(() => {
      if (!t.errors) return null;
      if (typeof t.errors == "string")
        return f(t.errors);
      if (Array.isArray(t.errors))
        return t.errors.map((d, S) => ({
          field: `item-${S}`,
          message: f(d),
          originalKey: d,
          params: {}
        }));
      if (typeof t.errors == "object") {
        const d = {};
        return Object.entries(t.errors).forEach(([S, w]) => {
          if (w) {
            s.value[S] = w;
            const h = t.errorParams?.[S] || {};
            d[S] = f(w, S, h), t.debug && console.log(`Processing error for field "${S}":`, {
              original: w,
              params: h,
              translated: d[S],
              field: S,
              slotName: k(S)
            });
          }
        }), d;
      }
      return t.errors;
    }), g = C(() => t.errorParams || {});
    function v(d) {
      return s.value[d];
    }
    function k(d) {
      return `error-${d.replace(/^(date|time|range)\./, "")}`;
    }
    function T(d) {
      return d.startsWith("date.") ? "date" : d.startsWith("time.") ? "time" : d.startsWith("range.") ? "range" : "unknown";
    }
    function f(d, S, w = {}) {
      if (t.debug && console.log(`翻譯訊息: "${d}", field: "${S}", params:`, w), u.value[d])
        return u.value[d];
      if (!t.useI18n)
        return d;
      if (/^[a-zA-Z]+\.[a-zA-Z]+$/.test(d))
        try {
          const $ = o(d, w);
          if (t.debug && console.log(`Locale key 翻譯: "${d}" -> "${$}" with params:`, w), $ && $ !== d)
            return $;
        } catch ($) {
          t.debug && console.warn(`Locale key 翻譯失敗: ${d}`, $);
        }
      const b = t.messageKeyMap[d];
      if (b)
        try {
          const $ = o(b, w);
          if (t.debug && console.log(`MessageKeyMap 翻譯: "${d}" -> "${$}" with params:`, w), $ && $ !== b)
            return $;
        } catch ($) {
          t.debug && console.warn(`MessageKeyMap 翻譯失敗: ${b}`, $);
        }
      return p(d, S, w);
    }
    function p(d, S, w = {}) {
      t.debug && console.log(`smartTranslateError: "${d}", field: "${S}", params:`, w);
      const h = {
        請選擇日期: "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 (h[d])
        try {
          const y = o(h[d], w);
          if (t.debug && console.log(`直接匹配翻譯: "${d}" -> "${y}" with params:`, w), y && y !== h[d])
            return y;
        } catch (y) {
          t.debug && console.warn(`直接匹配翻譯失敗: ${h[d]}`, y);
        }
      function b(y, D) {
        if (/請輸入|please enter|required/i.test(y)) {
          if (D?.includes("year") || y.includes("年份")) return "year.required";
          if (D?.includes("month") || y.includes("月份")) return "month.required";
          if (D?.includes("day") || y.includes("日期")) return "day.required";
          if (D?.includes("hour") || y.includes("小時")) return "time.hourRequired";
          if (D?.includes("minute") || y.includes("分鐘")) return "time.minuteRequired";
          if (D?.includes("second") || y.includes("秒鐘")) return "time.secondRequired";
          if (D?.includes("startDate") || y.includes("開始日期")) return "range.startRequired";
          if (D?.includes("endDate") || y.includes("結束日期")) return "range.endRequired";
          if (D?.includes("time") || y.includes("時間")) return "time.required";
          if (D?.includes("date") || y.includes("日期")) return "date.required";
        }
        return null;
      }
      const $ = b(d, S);
      if ($)
        try {
          const y = o($, w);
          if (t.debug && console.log(`智能匹配翻譯: "${d}" -> "${y}" with params:`, w), y && y !== $)
            return y;
        } catch (y) {
          t.debug && console.warn(`智能匹配翻譯失敗: ${$}`, y);
        }
      const c = [
        {
          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: (y) => y?.includes("year") ? "year.invalid" : y?.includes("month") ? "month.invalid" : y?.includes("day") ? "day.invalid" : y?.includes("time") || y?.includes("hour") || y?.includes("minute") || y?.includes("second") ? "time.invalid" : "date.invalid"
        }
      ];
      for (const y of c)
        if (y.regex.test(d)) {
          const D = y.handler ? y.handler(S) : y.key;
          if (D)
            try {
              const P = o(D, w);
              if (t.debug && console.log(`模式匹配翻譯: "${d}" -> "${P}" (key: ${D}) with params:`, w), P && P !== D)
                return P;
            } catch (P) {
              t.debug && console.warn(`模式匹配翻譯失敗: ${D}`, P);
            }
        }
      return t.debug && console.log(`無法翻譯,返回原始訊息: "${d}"`), d;
    }
    return e({
      hasErrors: i,
      processedErrors: m,
      processedErrorParams: g,
      translateMessage: f,
      getOriginalKey: v,
      getSlotName: k,
      getFieldType: T,
      setLocale: (d) => {
        n(d);
      },
      addCustomTranslation: (d, S) => {
        l.value[d] = S;
      },
      currentLocale: a
    }), (d, S) => i.value ? (A(), L("div", Uo, [
      Array.isArray(m.value) ? (A(), L("div", No, [
        (A(!0), L(De, null, $e(m.value, (w, h) => (A(), L("div", { key: h }, [
          pe(d.$slots, `error-${w.field}`, {
            error: w,
            message: w.message,
            field: w.field,
            errorParams: w.params
          }, () => [
            _("span", null, oe(w.message), 1)
          ])
        ]))), 128))
      ])) : typeof m.value == "string" ? (A(), L("div", zo, [
        pe(d.$slots, "error-single", {
          error: m.value,
          message: m.value
        }, () => [
          _("span", null, oe(m.value), 1)
        ])
      ])) : typeof m.value == "object" ? (A(), L("div", Wo, [
        pe(d.$slots, "error", {
          errors: m.value,
          errorParams: t.errorParams
        }, () => [
          (A(!0), L(De, null, $e(m.value, (w, h) => (A(), L("div", { key: h }, [
            pe(d.$slots, k(h), {
              field: h,
              error: w,
              message: w,
              originalKey: v(h),
              fieldType: T(h),
              errorParams: t.errorParams[h] || {}
            }, () => [
              _("span", null, oe(w), 1)
            ])
          ]))), 128))
        ])
      ])) : ce("", !0)
    ])) : ce("", !0);
  }
}), jo = {}, _o = {
  xmlns: "http://www.w3.org/2000/svg",
  fill: "none",
  viewBox: "0 0 24 24",
  stroke: "currentColor"
};
function Jo(r, e) {
  return A(), L("svg", _o, e[0] || (e[0] = [
    _("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 Cr = /* @__PURE__ */ Ue(jo, [["render", Jo]]), Ko = {}, Qo = {
  xmlns: "http://www.w3.org/2000/svg",
  viewBox: "0 0 20 20",
  fill: "currentColor"
};
function Zo(r, e) {
  return A(), L("svg", Qo, e[0] || (e[0] = [
    _("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 Yr = /* @__PURE__ */ Ue(Ko, [["render", Zo]]), Go = {}, Xo = {
  xmlns: "http://www.w3.org/2000/svg",
  viewBox: "0 0 20 20",
  fill: "currentColor"
};
function el(r, e) {
  return A(), L("svg", Xo, e[0] || (e[0] = [
    _("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 Rr = /* @__PURE__ */ Ue(Go, [["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" }, pl = /* @__PURE__ */ Ce({
  __name: "YearSelector",
  props: {
    selectedYear: {},
    showSelector: { type: Boolean },
    pageSize: { default: 12 },
    calendar: { default: "gregory" },
    locale: { default: "zh-TW" }
  },
  emits: ["year-selected", "update:showSelector"],
  setup(r, { expose: e, emit: t }) {
    const a = r, n = t, { getMessage: o, formatText: l } = gt(a.locale), s = W(null), u = W(null), i = C(() => fe.getCalendarRange(a.calendar)), m = C(() => fe.getCalendarDisplayName(a.calendar, a.locale)), g = C(() => a.calendar === "gregory"), v = C(() => a.calendar === "japanese"), k = C(() => $.value[0]), T = C(() => $.value[$.value.length - 1]), f = W(0), p = (M) => {
      const H = Math.floor(M / a.pageSize) * a.pageSize;
      return Math.max(H, i.value.min);
    }, d = () => {
      f.value = p(a.selectedYear);
    }, S = /* @__PURE__ */ new Map(), w = (M, H) => {
      const q = `${M}-${H}`;
      if (!S.has(q))
        try {
          S.set(q, new Pt(H, { calendar: M, year: "numeric", era: "short" }));
        } catch {
          S.set(q, new Pt(H, { year: "numeric" }));
        }
      return S.get(q);
    }, h = (M) => {
      const H = {
        gregorianYear: M,
        displayEra: "",
        displayYear: M.toString(),
        showReference: !1,
        displayWarning: !1
      };
      if (g.value)
        return H;
      try {
        const q = new le(M, 6, 1), ee = fe.safeToCalendar(q, fe.createSafeCalendar(a.calendar)), se = w(a.calendar, a.locale).formatToParts(ee.toDate("UTC"));
        H.displayYear = se.find((B) => B.type === "year")?.value || M.toString(), H.displayEra = se.find((B) => B.type === "era")?.value || "";
        const R = !!H.displayEra, Y = H.displayEra !== M.toString();
        (R || Y) && (H.showReference = !0, H.referenceYear = M.toString());
      } catch {
        if (H.displayWarning = !0, H.warningMessage = `無法轉換為${m.value}`, a.calendar === "roc") {
          const ee = M - 1911;
          H.displayYear = ee > 0 ? ee.toString() : `民國前${Math.abs(ee - 1)}年`;
        }
      }
      return H;
    }, b = (M) => M >= i.value.min && M <= i.value.max, $ = C(() => {
      const M = f.value, H = [];
      for (let q = 0; q < a.pageSize; q++) {
        const ee = M + q;
        if (ee > i.value.max) break;
        ee < i.value.min || H.push(h(ee));
      }
      return H;
    }), c = C(() => {
      const M = $.value;
      if (M.length === 0) return "";
      const H = M[0], q = M[M.length - 1];
      if (g.value)
        return `${H.displayYear} - ${q.displayYear}`;
      if (H.gregorianYear === q.gregorianYear)
        return H.displayYear;
      const ee = H.displayEra, me = q.displayEra;
      return ee && me && ee === me ? `${ee} ${H.displayYear} - ${q.displayYear}` : `${H.displayEra} ${H.displayYear} - ${q.displayEra} ${q.displayYear}`;
    }), y = C(() => f.value > i.value.min), D = C(() => f.value + a.pageSize <= i.value.max), P = () => {
      y.value && (f.value = Math.max(
        f.value - a.pageSize,
        i.value.min
      ));
    }, z = () => {
      D.value && (f.value = Math.min(
        f.value + a.pageSize,
        i.value.max
      ));
    }, J = (M) => {
      b(M) && (n("year-selected", M), n("update:showSelector", !1));
    }, j = () => {
      u.value && (b(u.value) ? (f.value = p(u.value), n("year-selected", u.value), n("update:showSelector", !1), u.value = null) : console.warn(`年份 ${u.value} 超出範圍 ${i.value.min}-${i.value.max}`));
    }, X = () => {
      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([() => a.selectedYear, () => a.calendar], () => {
      b(a.selectedYear) && (f.value = p(a.selectedYear));
    }, { immediate: !0 });
    const E = (M) => {
      if (a.showSelector && s.value) {
        const H = M.target, q = !!H.closest("[data-year-selector-button]");
        !s.value.contains(H) && !q && n("update:showSelector", !1);
      }
    };
    return Ht(() => {
      d(), document.addEventListener("mousedown", E);
    }), Bt(() => {
      document.removeEventListener("mousedown", E);
    }), e({
      getLocalizedText: Z,
      formatText: l,
      goToSpecificYear: j,
      goToValidRange: X
    }), (M, H) => M.showSelector ? (A(), L("div", {
      key: 0,
      ref_key: "yearSelectorRef",
      ref: s,
      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"
    }, [
      _("div", tl, [
        _("button", {
          type: "button",
          onClick: P,
          class: ge(["p-1 hover:bg-vdt-interactive-hover rounded focus:outline-none", { "opacity-50 cursor-not-allowed": !y.value }]),
          disabled: !y.value,
          "aria-label": "previous year"
        }, [
          ue(Yr, { class: "h-4 w-4" })
        ], 10, al),
        _("span", rl, [
          pe(M.$slots, "year-range-display", {
            firstYear: k.value,
            lastYear: T.value,
            displayText: c.value
          }, () => [
            ba(oe(c.value), 1)
          ], !0)
        ]),
        _("button", {
          type: "button",
          onClick: z,
          class: ge(["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"
        }, [
          ue(Rr, { class: "h-4 w-4" })
        ], 10, nl)
      ]),
      $.value.length > 0 ? (A(), L("div", ol, [
        (A(!0), L(De, null, $e($.value, (q) => (A(), L("button", {
          type: "button",
          key: q.gregorianYear,
          onClick: (ee) => J(q.gregorianYear),
          class: ge([
            "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",
            M.selectedYear === q.gregorianYear ? "bg-vdt-theme-500 text-white" : "hover:bg-vdt-interactive-hover text-vdt-content",
            q.displayWarning ? "ring-1 ring-amber-400" : ""
          ]),
          title: q.warningMessage
        }, [
          pe(M.$slots, "year-display", {
            yearData: q,
            isSelected: M.selectedYear === q.gregorianYear
          }, () => [
            _("div", sl, [
              v.value ? (A(), L("div", il, oe(q.displayEra), 1)) : ce("", !0),
              ba(" " + oe(q.displayYear), 1)
            ]),
            q.showReference ? (A(), L("div", ul, oe(q.referenceYear), 1)) : ce("", !0)
          ], !0)
        ], 10, ll))), 128))
      ])) : (A(), L("div", cl, [
        pe(M.$slots, "no-years-display", {
          calendarRange: i.value,
          goToValidRange: X
        }, () => [
          _("div", dl, oe(Z("noYearsToDisplay")), 1),
          _("button", {
            type: "button",
            onClick: X,
            class: "text-xs bg-vdt-theme-100 hover:bg-vdt-theme-200 px-3 py-1 rounded text-vdt-theme-700"
          }, oe(Z("returnToValidRange")), 1)
        ], !0)
      ])),
      _("div", fl, [
        pe(M.$slots, "year-input", {
          yearInput: u.value,
          calendarRange: i.value,
          calendarDisplayName: m.value,
          goToSpecificYear: j,
          getLocalizedText: Z,
          formatText: V(l)
        }, () => [
          _("div", ml, oe(Z("jumpToYear")), 1),
          Ee(_("input", {
            type: "number",
            "onUpdate:modelValue": H[0] || (H[0] = (q) => u.value = q),
            onKeydown: Fe(j, ["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]
          ]),
          _("div", vl, oe(V(l)(Z("yearRangeInfo"), {
            calendar: m.value,
            min: i.value.min,
            max: i.value.max
          })), 1)
        ], !0)
      ])
    ], 512)) : ce("", !0);
  }
}), gl = /* @__PURE__ */ Ue(pl, [["__scopeId", "data-v-f14c8987"]]), yl = { 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" }, Sl = ["disabled"], wl = /* @__PURE__ */ Ce({
  __name: "CalendarHeader",
  props: {
    month: {},
    year: {},
    locale: { default: "en-US" },
    minYear: { default: 1900 },
    maxYear: { default: 2100 },
    calendar: { default: "gregory" }
  },
  emits: ["update:month", "update:year"],
  setup(r, { emit: e }) {
    const t = r, a = e, n = W(t.month), o = W(t.year), l = W(!1), s = C(() => t.calendar || "gregory"), u = C(() => fe.getCalendarRange(t.calendar));
    de(() => t.month, (h) => {
      n.value = h;
    }, { immediate: !0 }), de(() => t.year, (h) => {
      o.value = h;
    }, { immediate: !0 });
    const i = C(() => {
      if (t.calendar === "gregory")
        return o.value.toString();
      try {
        const h = new le(o.value, 6, 1), b = fe.safeToCalendar(
          h,
          fe.createSafeCalendar(t.calendar)
        );
        return new Pt(t.locale, {
          calendar: t.calendar,
          year: "numeric"
        }).format(b.toDate("UTC"));
      } catch {
        return o.value.toString();
      }
    }), m = C(() => fe.getMonthNames(t.locale, t.calendar)), g = C(() => {
      let h = o.value, b = n.value - 1;
      return b < 1 && (b = 12, h = o.value - 1), h >= u.value.min;
    }), v = C(() => {
      let h = o.value, b = n.value + 1;
      return b > 12 && (b = 1, h = o.value + 1), h <= u.value.max;
    }), k = () => {
      if (!g.value) return;
      let h = n.value - 1, b = o.value;
      h < 1 && (h = 12, b -= 1), b >= u.value.min && S(h, b);
    }, T = () => {
      if (!v.value) return;
      let h = n.value + 1, b = o.value;
      h > 12 && (h = 1, b += 1), b <= u.value.max && S(h, b);
    }, f = () => {
      S(n.value, o.value);
    }, p = (h) => {
      h !== void 0 && (n.value = h), S(n.value, o.value);
    }, d = (h) => {
      h >= u.value.min && h <= u.value.max && (o.value = h, S(n.value, h));
    }, S = (h, b) => {
      n.value = h, o.value = b, a("update:month", h), a("update:year", b);
    }, w = () => {
      l.value = !l.value;
    };
    return (h, b) => (A(), L("div", yl, [
      _("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: !g.value
      }, [
        ue(Yr, { class: "h-5 w-5" })
      ], 8, $l),
      _("div", Dl, [
        pe(h.$slots, "month-selector", {
          monthNames: m.value,
          selectedMonth: n.value,
          onMonthChange: p
        }, () => [
          Ee(_("select", {
            "onUpdate:modelValue": b[0] || (b[0] = ($) => n.value = $),
            onChange: f,
            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(De, null, $e(m.value, ($, c) => (A(), L("option", {
              key: c,
              value: c + 1
            }, oe($), 9, bl))), 128))
          ], 544), [
            [Mt, n.value]
          ])
        ]),
        _("div", Ml, [
          pe(h.$slots, "year-selector", {
            displayYear: i.value,
            toggleYearSelector: w,
            showYearSelector: l.value
          }, () => [
            _("button", {
              type: "button",
              onClick: w,
              "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": "選擇年份"
            }, oe(i.value), 1)
          ]),
          ue(gl, {
            "selected-year": o.value,
            "show-selector": l.value,
            "onUpdate:showSelector": b[1] || (b[1] = ($) => l.value = $),
            calendar: s.value,
            locale: h.locale,
            onYearSelected: d
          }, ct({ _: 2 }, [
            $e(h.$slots, ($, c) => ({
              name: c,
              fn: dt((y) => [
                pe(h.$slots, c, ft(mt(y)))
              ])
            }))
          ]), 1032, ["selected-year", "show-selector", "calendar", "locale"])
        ])
      ]),
      _("button", {
        type: "button",
        onClick: T,
        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: !v.value
      }, [
        ue(Rr, { class: "h-5 w-5" })
      ], 8, Sl)
    ]));
  }
}), kl = { class: "grid grid-cols-7 mb-2" }, Tl = /* @__PURE__ */ Ce({
  __name: "WeekdayHeader",
  props: {
    locale: { default: "en-US" },
    weekStartsOn: { default: 0 },
    calendar: { default: "gregory" }
  },
  setup(r) {
    const e = r, t = C(() => {
      const a = new Intl.DateTimeFormat(e.locale, {
        weekday: "short",
        calendar: e.calendar
      }), n = new Date(2023, 0, 1);
      return Array.from({ length: 7 }, (o, l) => {
        const s = new Date(n);
        return s.setDate(n.getDate() + (l + e.weekStartsOn) % 7), a.format(s);
      });
    });
    return (a, n) => (A(), L("div", kl, [
      (A(!0), L(De, null, $e(t.value, (o, l) => (A(), L("div", {
        key: l,
        class: "text-center text-vdt-content text-sm py-2"
      }, oe(o), 1))), 128))
    ]));
  }
}), xl = { class: "calendar-cell text-center relative" }, Cl = ["disabled", "tabindex", "aria-selected", "aria-disabled", "aria-current", "data-in-current-month"], Yl = /* @__PURE__ */ Ce({
  __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(r, { emit: e }) {
    const t = r, a = e, n = C(() => t.date.month !== t.currentMonth), o = C(() => {
      const s = {};
      return s["flex justify-center items-center w-8 h-8 rounded-md mx-auto relative z-10"] = !0, t.disabled ? (s["opacity-40 cursor-not-allowed"] = !0, s["bg-vdt-surface text-vdt-content"] = !0, s) : (t.selectionMode === "range" ? (t.isRangeStart || t.isRangeEnd ? s["bg-vdt-theme-500 text-white"] = !0 : t.isInRange ? s["bg-vdt-outline text-vdt-content"] = !0 : (s["bg-vdt-surface text-vdt-content"] = !0, s["hover:bg-vdt-interactive-hover cursor-pointer"] = !0), t.isToday && !t.isRangeStart && !t.isRangeEnd && !t.isInRange && (s["ring-2 ring-vdt-theme-500"] = !0)) : (t.selected ? s["bg-vdt-theme-500 text-white"] = !0 : (s["bg-vdt-surface text-vdt-content"] = !0, s["hover:bg-vdt-interactive-hover cursor-pointer"] = !0), t.isToday && !t.selected && (s["ring-2 ring-vdt-theme-500"] = !0)), n.value && !t.selected && !t.isRangeStart && !t.isRangeEnd && (s["text-vdt-content-muted"] = !0, s["text-vdt-content"] = !1), s);
    }), l = () => {
      t.disabled || a("select", t.date);
    };
    return (s, u) => (A(), L("div", xl, [
      _("button", {
        type: "button",
        class: ge(["calendar-cell-button", o.value]),
        disabled: s.disabled,
        tabindex: s.focusable ? 0 : -1,
        "aria-selected": s.selected || s.isRangeStart || s.isRangeEnd,
        "aria-disabled": s.disabled,
        "aria-current": s.isToday ? "date" : void 0,
        "data-in-current-month": !n.value,
        onClick: l,
        onKeydown: [
          Fe(l, ["enter"]),
          Fe(l, ["space"]),
          u[0] || (u[0] = Fe((i) => a("nav", "up"), ["up"])),
          u[1] || (u[1] = Fe((i) => a("nav", "down"), ["down"])),
          u[2] || (u[2] = Fe((i) => a("nav", "left"), ["left"])),
          u[3] || (u[3] = Fe((i) => a("nav", "right"), ["right"]))
        ]
      }, oe(s.date.day), 43, Cl)
    ]));
  }
}), Rl = /* @__PURE__ */ Ue(Yl, [["__scopeId", "data-v-9018b2ca"]]), El = { class: "grid grid-cols-7 gap-1" }, Il = /* @__PURE__ */ Ce({
  __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(r, { expose: e, emit: t }) {
    const a = r, n = t, o = C(() => a.month), l = C(() => a.year);
    C(() => {
      const f = Ge();
      return `${f.year}-${f.month}-${f.day}`;
    });
    const s = C(() => fe.generateCalendarDays(
      a.year,
      // 西元年
      a.month,
      // 西元月
      a.calendar,
      a.locale,
      a.weekStartsOn
    )), u = (f) => {
      if (!a.rangeStart || !a.rangeEnd) return !1;
      try {
        return f.compare(a.rangeStart) >= 0 && f.compare(a.rangeEnd) <= 0;
      } catch {
        return !1;
      }
    }, i = (f, p) => {
      if (!f || !p) return !1;
      try {
        return f.compare(p) === 0;
      } catch {
        return !1;
      }
    }, m = (f) => {
      try {
        return !!(a.minDate && f.compare(a.minDate) < 0 || a.maxDate && f.compare(a.maxDate) > 0);
      } catch {
        return !0;
      }
    }, g = (f) => go(f), v = C(() => s.value.map((f, p) => {
      const d = `${f.year}-${f.month}-${f.day}`, S = g(f), w = f.month !== o.value, h = m(f), b = a.selectionMode === "single" && i(f, a.selectedDate), $ = a.selectionMode === "range" && i(f, a.rangeStart), c = a.selectionMode === "range" && i(f, a.rangeEnd), y = a.selectionMode === "range" && u(f) && !$ && !c && !h, D = f.day === 1 && f.month === o.value, P = [
        d,
        b,
        S,
        h,
        $,
        c,
        y,
        a.selectionMode,
        a.calendar
      ];
      return {
        key: `${a.calendar}-${l.value}-${o.value}-${d}-${p}`,
        memoKey: P,
        date: f,
        isToday: S,
        isSelected: b,
        isDisabled: h,
        isOutsideMonth: w,
        isRangeStart: $,
        isRangeEnd: c,
        isInRange: y,
        isFocusable: D
      };
    })), k = (f) => {
      a.selectionMode === "single" ? n("select", f) : a.selectionMode === "range" && n("range-select", f, null);
    }, T = (f) => {
      const p = v.value;
      if (p.length === 0) return;
      const d = p[0], S = p[p.length - 1];
      switch (f) {
        case "left":
          d.date.day < 15 && d.date.month !== o.value && n("navigate", "prev-month");
          break;
        case "right":
          S.date.day > 15 && S.date.month !== o.value && n("navigate", "next-month");
          break;
      }
    };
    return e({
      getCalendarDays: () => s.value,
      getCellStates: () => v.value
    }), (f, p) => (A(), L("div", El, [
      (A(!0), L(De, null, $e(v.value, (d, S, w, h) => {
        const b = d.memoKey;
        if (h && h.key === d.key && jr(h, b)) return h;
        const $ = (A(), _r(Rl, {
          key: d.key,
          date: d.date,
          "current-month": o.value,
          selected: d.isSelected,
          "is-today": d.isToday,
          disabled: d.isDisabled,
          focusable: d.isFocusable,
          "is-range-start": d.isRangeStart,
          "is-range-end": d.isRangeEnd,
          "is-in-range": d.isInRange,
          "selection-mode": f.selectionMode,
          onSelect: k,
          onNav: T
        }, null, 8, ["date", "current-month", "selected", "is-today", "disabled", "focusable", "is-range-start", "is-range-end", "is-in-range", "selection-mode"]));
        return $.memo = b, $;
      }, p, 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" }, Ul = ["value"], Nl = {
  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" }, _l = /* @__PURE__ */ Ce({
  __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(r, { expose: e, emit: t }) {
    const a = r, n = t, { getPlaceholderMessage: o } = gt(a.locale), l = W(0), s = W(0), u = W(0), i = W("AM"), m = W(!1), g = C(() => a.use24Hour ? Array.from({ length: 24 }, (c, y) => y) : Array.from({ length: 12 }, (c, y) => y + 1)), v = C(() => Array.from({ length: 60 }, (c, y) => y)), k = C(() => Array.from({ length: 60 }, (c, y) => y)), T = C(() => {
      let c = l.value;
      a.use24Hour || (i.value === "PM" && c < 12 ? c += 12 : i.value === "AM" && c === 12 && (c = 0));
      const y = f(c), D = f(s.value);
      if (a.enableSeconds) {
        const P = f(u.value);
        return `${y}:${D}:${P}`;
      } else
        return `${y}:${D}`;
    }), f = (c) => c.toString().padStart(2, "0"), p = (c) => f(c), d = (c) => {
      if (!c) return;
      const [y, D, P] = c.split(":");
      let z = parseInt(y) || 0;
      a.use24Hour || (z >= 12 ? (i.value = "PM", z = z === 12 ? 12 : z - 12) : (i.value = "AM", z = z === 0 ? 12 : z)), l.value = z, s.value = parseInt(D) || 0, a.enableSeconds && P && (u.value = parseInt(P) || 0), m.value = !0;
    }, S = () => {
      d(a.defaultTime);
    }, w = (c) => {
      i.value = c;
    }, h = (c) => {
      const y = /* @__PURE__ */ new Date();
      return y.setHours(c === "AM" ? 6 : 18, 0, 0, 0), new Intl.DateTimeFormat(a.locale || navigator.language, {
        hour12: !0,
        hour: "numeric"
      }).formatToParts(y).find((J) => J.type === "dayPeriod")?.value || c;
    }, b = () => {
      const c = /* @__PURE__ */ new Date();
      if (a.use24Hour)
        l.value = c.getHours();
      else {
        const y = c.getHours();
        i.value = y >= 12 ? "PM" : "AM", l.value = y % 12 || 12;
      }
      s.value = c.getMinutes(), a.enableSeconds && (u.value = c.getSeconds()), m.value = !0;
    }, $ = () => {
      n("today-click");
    };
    return de(() => a.timeValue, (c) => {
      c ? d(c) : !m.value && a.show && S();
    }, { immediate: !0 }), de(
      [l, s, u, i],
      () => {
        m.value && n("time-change", T.value);
      }
    ), e({
      // 獲取當前時間值
      getCurrentTime: () => T.value,
      // 設置時間
      setTime: (c) => d(c),
      // 重置為預設時間
      resetToDefault: () => S()
    }), (c, y) => c.show ? (A(), L("div", Ol, [
      y[5] || (y[5] = _("hr", { class: "my-2 border-vdt-outline" }, null, -1)),
      _("div", Vl, [
        _("label", Fl, oe(V(o)("general.time")) + ": ", 1),
        _("div", Pl, [
          _("button", {
            type: "button",
            onClick: b,
            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 "),
          c.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 ")) : ce("", !0)
        ])
      ]),
      _("div", Al, [
        _("div", Ll, [
          _("div", Hl, [
            Ee(_("select", {
              "onUpdate:modelValue": y[0] || (y[0] = (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(De, null, $e(g.value, (D) => (A(), L("option", {
                key: D,
                value: D
              }, oe(p(D)), 9, Bl))), 128))
            ], 512), [
              [Mt, l.value]
            ])
          ]),
          _("div", ql, [
            Ee(_("select", {
              "onUpdate:modelValue": y[1] || (y[1] = (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(De, null, $e(v.value, (D) => (A(), L("option", {
                key: D,
                value: D
              }, oe(f(D)), 9, Ul))), 128))
            ], 512), [
              [Mt, s.value]
            ])
          ]),
          c.enableSeconds ? (A(), L("div", Nl, [
            Ee(_("select", {
              "onUpdate:modelValue": y[2] || (y[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(De, null, $e(k.value, (D) => (A(), L("option", {
                key: D,
                value: D
              }, oe(f(D)), 9, zl))), 128))
            ], 512), [
              [Mt, u.value]
            ])
          ])) : ce("", !0),
          c.use24Hour ? ce("", !0) : (A(), L("div", Wl, [
            _("div", jl, [
              _("button", {
                type: "button",
                onClick: y[3] || (y[3] = (D) => w("AM")),
                class: ge(["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"])
              }, oe(h("AM")), 3),
              _("button", {
                type: "button",
                onClick: y[4] || (y[4] = (D) => w("PM")),
                class: ge(["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"])
              }, oe(h("PM")), 3)
            ])
          ]))
        ])
      ])
    ])) : ce("", !0);
  }
}), Jl = { class: "vdt-date-picker calendar-grid w-full max-w-xs rounded-lg shadow p-2" }, ia = /* @__PURE__ */ Ce({
  __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(r, { expose: e, emit: t }) {
    const a = r, n = t, o = () => {
      if (a.year !== void 0 && a.month !== void 0)
        return { year: a.year, month: a.month };
      if (a.value)
        return { year: a.value.year, month: a.value.month };
      if (a.rangeStart)
        return { year: a.rangeStart.year, month: a.rangeStart.month };
      const c = Ge();
      return { year: c.year, month: c.month };
    }, { year: l, month: s } = o(), u = W(l), i = W(s), m = W(a.timeValue), g = C(() => fe.convertToCalendarDate(a.value, a.calendar)), v = C(() => fe.convertToCalendarDate(a.rangeStart, a.calendar)), k = C(() => fe.convertToCalendarDate(a.rangeEnd, a.calendar)), T = C(() => fe.convertToCalendarDate(a.minDate || null, a.calendar)), f = C(() => fe.convertToCalendarDate(a.maxDate || null, a.calendar)), p = C(() => a.minDate?.year || 1900), d = C(() => a.maxDate?.year || 2100), S = C(() => {
      if (a.year !== void 0 && a.month !== void 0)
        return { year: a.year, month: a.month };
      const c = a.selectionMode === "range" ? a.rangeStart : a.value;
      return c ? { year: c.year, month: c.month } : { year: u.value, month: i.value };
    });
    de(S, ({ year: c, month: y }) => {
      u.value = c, i.value = y;
    }, { immediate: !0 }), de(() => a.timeValue, (c) => {
      m.value = c;
    }, { immediate: !0 });
    const w = (c) => {
      if (a.selectionMode === "single") {
        const y = fe.convertFromCalendarDate(c, a.calendar);
        y && (n("select", y, !0), a.showTimeSelector && m.value && n("time-select", m.value));
      }
    }, h = (c, y) => {
      if (a.selectionMode === "range") {
        const D = fe.convertFromCalendarDate(c, a.calendar), P = fe.convertFromCalendarDate(y, a.calendar);
        n("range-select", D, P);
      }
    }, b = (c) => {
      m.value = c, n("time-select", c);
    }, $ = () => {
      if (a.selectionMode === "single") {
        const c = Ge();
        u.value = c.year, i.value = c.month, n("select", c, !1);
      }
    };
    return e({
      // 獲取當前選中的日期(單一模式)
      getSelectedDate: () => a.value,
      // 獲取當前範圍(範圍模式)
      getSelectedRange: () => ({ start: a.rangeStart, end: a.rangeEnd }),
      // 設置顯示的月份
      setDisplayMonth: (c, y) => {
        u.value = c, i.value = y;
      },
      // 導航到上個月
      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;
      }
    }), (c, y) => (A(), L("div", Jl, [
      ue(wl, {
        month: i.value,
        "onUpdate:month": y[0] || (y[0] = (D) => i.value = D),
        year: u.value,
        "onUpdate:year": y[1] || (y[1] = (D) => u.value = D),
        locale: c.locale,
        "min-year": p.value,
        "max-year": d.value,
        calendar: c.calendar
      }, ct({ _: 2 }, [
        $e(c.$slots, (D, P) => ({
          name: P,
          fn: dt((z) => [
            pe(c.$slots, P, ft(mt(z)))
          ])
        }))
      ]), 1032, ["month", "year", "locale", "min-year", "max-year", "calendar"]),
      ue(Tl, {
        locale: c.locale,
        "week-starts-on": c.weekStartsOn,
        calendar: c.calendar
      }, null, 8, ["locale", "week-starts-on", "calendar"]),
      ue(Il, {
        year: u.value,
        month: i.value,
        "selected-date": g.value,
        "range-start": v.value,
        "range-end": k.value,
        "selection-mode": c.selectionMode,
        "min-date": T.value,
        "max-date": f.value,
        locale: c.locale,
        "week-starts-on": c.weekStartsOn,
        calendar: c.calendar,
        onSelect: w,
        onRangeSelect: h
      }, null, 8, ["year", "month", "selected-date", "range-start", "range-end", "selection-mode", "min-date", "max-date", "locale", "week-starts-on", "calendar"]),
      ue(_l, {
        locale: c.locale,
        show: c.showTimeSelector,
        "time-value": m.value,
        "enable-seconds": c.enableSeconds,
        "use24-hour": c.use24Hour,
        "default-time": c.defaultTime,
        selectionMode: c.selectionMode,
        onTimeChange: b,
        onTodayClick: $
      }, null, 8, ["locale", "show", "time-value", "enable-seconds", "use24-hour", "default-time", "selectionMode"])
    ]));
  }
}), Kl = {}, Ql = {
  xmlns: "http://www.w3.org/2000/svg",
  fill: "none",
  viewBox: "0 0 24 24",
  "stroke-width": "1.5",
  stroke: "currentColor"
};
function Zl(r, e) {
  return A(), L("svg", Ql, e[0] || (e[0] = [
    _("path", {
      "stroke-linecap": "round",
      "stroke-linejoin": "round",
      d: "M6 18L18 6M6 6l12 12"
    }, null, -1)
  ]));
}
const Er = /* @__PURE__ */ Ue(Kl, [["render", Zl]]);
function ua(r, e) {
  const { dateInputRef: t, timeInputRef: a } = r, { showTime: n, autoFocusTimeAfterDate: o = !0 } = e;
  return {
    // 基本導航方法
    focusFirstInput: () => {
      we(() => {
        t.value?.focus && t.value.focus();
      });
    },
    focusLastInput: () => {
      we(() => {
        n && a.value?.focusLast ? a.value.focusLast() : t.value?.focusLast ? t.value.focusLast() : t.value?.focus && t.value.focus();
      });
    },
    // 專門的導航處理
    handleNavigateToTime: (g) => {
      n && we(() => {
        a.value?.focus && a.value.focus();
      });
    },
    handleNavigateToDate: () => {
      we(() => {
        t.value?.focusLast ? t.value.focusLast() : t.value?.focus && t.value.focus();
      });
    },
    autoFocusTimeAfterDateComplete: (g, v) => {
      !n || !o || (v && !g.inputTimeValue.value && (g.inputTimeValue.value = v, g.updateFromInputs()), we(() => {
        a.value?.focus && a.value.focus();
      }));
    }
  };
}
function ca(r = {}) {
  const { required: e = !0, showTime: t = !1, minDate: a, maxDate: n, dateFormat: o = "YYYY-MM-DD" } = r, l = W({}), s = W({}), u = W({}), i = C(() => ({ ...l.value, ...s.value })), m = C(() => ({ ...u.value })), g = C(() => Object.keys(i.value).length > 0), v = (b, $, c = "date", y = {}) => {
    ["date", "year", "month", "day"].forEach((D) => {
      f(`${c}.${D}`), p(`${c}.${D}`);
    }), b || Object.entries($).forEach(([D, P]) => {
      const z = `${c}.${D}`;
      l.value[z] = P, y[D] && (u.value[z] = y[D]);
    });
  }, k = (b, $, c = "time", y = {}) => (["time", "hour", "minute", "second"].forEach((D) => {
    f(`${c}.${D}`), p(`${c}.${D}`);
  }), b || Object.entries($).forEach(([D, P]) => {
    const z = `${c}.${D}`;
    l.value[z] = P, y[D] && (u.value[z] = y[D]);
  }), !g.value), T = (b) => {
    if (!b) return !1;
    if (a) {
      const $ = ve(a);
      if ($ && Lt(b, $) < 0)
        return v(!1, {
          date: "date.beforeMin"
        }, "date", {
          date: { minDate: Te($, o) }
        }), !1;
    }
    if (n) {
      const $ = ve(n);
      if ($ && Lt(b, $) > 0)
        return v(!1, {
          date: "date.afterMax"
        }, "date", {
          date: { maxDate: Te($, o) }
        }), !1;
    }
    return !0;
  }, f = (b) => {
    Object.keys(l.value).forEach(($) => {
      $.startsWith(b) && delete l.value[$];
    });
  }, p = (b) => {
    Object.keys(u.value).forEach(($) => {
      $.startsWith(b) && delete u.value[$];
    });
  };
  return {
    // 狀態
    errors: l,
    formatErrors: s,
    mergedErrors: i,
    hasErrors: g,
    errorParams: u,
    mergedErrorParams: m,
    // 驗證方法
    handleDateValidation: v,
    handleTimeValidation: k,
    validateDateTime: (b, $) => {
      const c = {
        isValid: !0,
        errors: {}
      };
      return e && (b || (c.errors.date = "date.required", c.isValid = !1), t && !$ && (c.errors.time = "time.required", c.isValid = !1)), Object.assign(l.value, c.errors), c.isValid && !g.value;
    },
    validateDateRange: T,
    // 錯誤管理
    clearFieldErrors: f,
    clearFieldParams: p,
    clearAllErrors: () => {
      l.value = {}, s.value = {}, u.value = {};
    },
    setFormatError: (b, $) => {
      s.value[b] = $;
    },
    clearFormatError: (b) => {
      delete s.value[b];
    }
  };
}
function da(r = {}) {
  const {
    showTime: e = !1,
    dateFormat: t = "YYYY-MM-DD",
    timeFormat: a = "HH:mm:ss",
    outputType: n = "iso",
    defaultTime: o,
    enableSeconds: l = !0
  } = r, s = W(null), u = W(null), i = W(null), m = (c) => {
    if (!c || c.hour === void 0) return null;
    const y = c.hour.toString().padStart(2, "0"), D = (c.minute || 0).toString().padStart(2, "0");
    if (l) {
      const P = (c.second || 0).toString().padStart(2, "0");
      return `${y}:${D}:${P}`;
    } else
      return `${y}:${D}`;
  }, g = (c, y) => {
    if (!c) return null;
    const D = ve(c);
    if (!D) return null;
    if (!y && !e)
      return Ae(D.year, D.month, D.day);
    if (!y)
      if (o) {
        const X = o.split(":").map(Number), Z = X[0] || 0, I = X[1] || 0, E = X[2] || 0;
        return Ae(
          D.year,
          D.month,
          D.day,
          Z,
          I,
          E
        );
      } else
        return Ae(D.year, D.month, D.day);
    const P = y.split(":").map(Number), z = P[0] || 0, J = P[1] || 0, j = P[2] || 0;
    return Ae(
      D.year,
      D.month,
      D.day,
      z,
      J,
      j
    );
  }, v = (c) => {
    const y = ve(c);
    s.value = y, y ? (u.value = Te(y, t), i.value = m(y)) : (u.value = null, i.value = null);
  }, k = (c, y) => {
    const D = c !== void 0 ? c : u.value, P = y !== void 0 ? y : i.value, z = g(D, P);
    return s.value = z, z;
  }, T = (c) => {
    if (!c) {
      s.value = null, u.value = null, i.value = null;
      return;
    }
    if (e && o && (c.hour === void 0 || c.hour === null) && !i.value) {
      const y = o.split(":").map(Number), D = y[0] || 0, P = y[1] || 0, z = y[2] || 0, J = Ae(
        c.year,
        c.month,
        c.day,
        D,
        P,
        z
      );
      s.value = J, i.value = o;
    } else
      s.value = c, i.value = m(c);
    s.value && (u.value = Te(s.value));
  }, f = (c) => {
    if (!s.value) return null;
    const y = c.split(":").map(Number), D = {
      ...s.value,
      hour: y[0] || 0,
      minute: y[1] || 0,
      second: y[2] || 0
    };
    return s.value = D, i.value = c, D;
  }, p = (c) => {
    const y = c !== void 0 ? c : s.value, D = e ? `${t} ${a}` : t;
    return At(y, n, D);
  }, d = () => {
    s.value = null, u.value = null, i.value = null;
  }, S = C(() => !!(u.value || i.value || s.value)), w = () => e && !i.value && o ? (i.value = o, !0) : !1, h = C(() => !!u.value), b = C(() => !!i.value), $ = C(() => e ? h.value && b.value : h.value);
  return {
    // 響應式狀態
    internalDateTime: s,
    inputDateValue: u,
    inputTimeValue: i,
    // 計算屬性
    hasDateValue: h,
    hasTimeValue: b,
    hasCompleteValue: $,
    hasValue: S,
    // 主要方法
    updateFromInputs: k,
    setInternalDateTime: T,
    updateTimeOnly: f,
    setExternalValue: v,
    // updateDateTime,
    getFormattedOutput: p,
    clearValues: d,
    applyDefaultTime: w,
    // 輔助方法
    getTimeFromDateTime: m,
    createDateTimeFromInputs: g
  };
}
function Ir(r, e, t = {}) {
  const { disabled: a, onOutsideClick: n } = t, o = W(!1), l = () => {
    a?.value || (o.value = !o.value, o.value && we(() => {
      i();
    }));
  }, s = () => {
    a?.value || (o.value = !0, we(() => {
      i();
    }));
  }, u = () => {
    o.value = !1;
  }, i = () => {
    if (!r.value || !e.value) return;
    const f = r.value.getBoundingClientRect(), p = e.value, d = {
      width: window.innerWidth,
      height: window.innerHeight
    };
    p.style.position = "absolute", p.style.visibility = "hidden", p.style.display = "block";
    const S = p.getBoundingClientRect();
    let w = f.height + 5, h = 0;
    const b = d.height - f.bottom, $ = f.top, c = S.height;
    b < c && $ > b && (w = -c - 5);
    const y = d.width - f.left, D = S.width;
    y < D && (h = Math.max(-(D - y + 10), -f.left + 10)), f.left + h < 0 && (h = -f.left + 10), p.style.top = `${w}px`, p.style.left = `${h}px`, p.style.zIndex = "50", p.style.visibility = "visible";
  }, m = (f) => {
    const p = e.value, d = r.value, S = f.target;
    o.value && p && !p.contains(S) && d && !d.contains(S) && (u(), n?.());
  }, g = (f, p) => {
    if (a?.value) return;
    const d = f.target;
    d.classList.contains("date-input") || d.classList.contains("time-input") || d.closest("input") || d.closest("button") || (f.preventDefault(), p?.());
  }, v = (f) => {
    if (a?.value) return;
    const p = f.target;
    p.classList.contains("date-input") || p.classList.contains("time-input") || p.closest("input") || p.closest("button") || f.preventDefault();
  }, k = () => {
    o.value && i();
  }, T = () => {
    o.value && i();
  };
  return Ht(() => {
    document.addEventListener("mousedown", m), window.addEventListener("resize", k), window.addEventListener("scroll", T);
  }), Bt(() => {
    document.removeEventListener("mousedown", m), window.removeEventListener("resize", k), window.removeEventListener("scroll", T);
  }), {
    // 狀態
    showCalendar: o,
    // 主要方法
    toggleCalendar: l,
    showCalendarPopup: s,
    hideCalendar: u,
    updateCalendarPosition: i,
    // 事件處理
    handleContainerClick: g,
    handleContainerMouseDown: v
  };
}
function Gl(r = {}) {
  const {
    customDefaultTime: e = "00:00:00",
    enableSeconds: t = !0
  } = r, a = (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 g = i.split(":"), v = parseInt(g[0]), k = parseInt(g[1]), T = g[2] ? parseInt(g[2]) : 0;
    return v < 0 || v > 23 || k < 0 || k > 59 || T < 0 || T > 59 ? (console.warn(`時間值超出範圍: ${i}`), !1) : !0;
  }, n = (i, m = t) => {
    const g = i.split(":"), v = g[0].padStart(2, "0"), k = g[1].padStart(2, "0"), T = g[2] ? g[2].padStart(2, "0") : "00";
    return m ? `${v}:${k}:${T}` : `${v}:${k}`;
  };
  return {
    // 計算屬性
    getValidDefaultTime: C(() => {
      if (e && a(e))
        return n(e, t);
    }),
    // 驗證方法
    isValidTimeValue: a,
    // 格式化方法
    formatTimeString: n,
    getCurrentTimeString: () => {
      const i = /* @__PURE__ */ new Date(), m = i.getHours().toString().padStart(2, "0"), g = i.getMinutes().toString().padStart(2, "0"), v = i.getSeconds().toString().padStart(2, "0");
      return t ? `${m}:${g}:${v}` : `${m}:${g}`;
    },
    parseTimeString: (i) => {
      const m = i.split(":");
      return {
        hours: parseInt(m[0]) || 0,
        minutes: parseInt(m[1]) || 0,
        seconds: parseInt(m[2]) || 0
      };
    },
    buildTimeString: (i, m, g = 0) => {
      const v = i.toString().padStart(2, "0"), k = m.toString().padStart(2, "0"), T = g.toString().padStart(2, "0");
      return t ? `${v}:${k}:${T}` : `${v}:${k}`;
    }
  };
}
function Xl(r = {}, e) {
  const {
    modelValue: t = null,
    showTime: a = !1,
    required: n = !0,
    disabled: o = !1,
    // calendar = 'gregory',          // 日曆系統
    dateFormat: l = "YYYY-MM-DD",
    timeFormat: s = "HH:mm:ss",
    // outputType = 'iso',
    useStrictISO: u = !1,
    customDefaultTime: i,
    enableSeconds: m = !0,
    autoFocusTimeAfterDate: g = !0,
    minDate: v,
    maxDate: k
    // locale = 'zh-TW'
  } = r, { containerRef: T, calendarRef: f, dateInputRef: p, timeInputRef: d } = e, S = C(() => r.calendar?.value || "gregory"), w = C(() => r.locale?.value || "zh-TW"), h = C(() => r.outputType?.value || "iso"), b = W(o), $ = ca({
    required: n,
    showTime: a,
    minDate: v,
    maxDate: k,
    dateFormat: l
  }), c = da({
    showTime: a,
    dateFormat: l,
    timeFormat: s,
    outputType: h.value,
    defaultTime: i,
    enableSeconds: m
  }), y = ua(
    { dateInputRef: p, timeInputRef: d },
    { showTime: a, autoFocusTimeAfterDate: g }
  ), D = Ir(
    T,
    f,
    {
      disabled: b,
      onOutsideClick: () => {
      }
    }
  ), P = Gl({
    customDefaultTime: i,
    enableSeconds: m
  }), z = C(() => {
    const N = ve(v, w.value);
    return N || null;
  }), J = C(() => {
    const N = ve(k, w.value);
    return N || null;
  });
  let j = null, X = null, Z = null;
  const I = (N) => {
    j = N.update || null, X = N.change || null, Z = N.validation || null;
  }, E = async (N = c.internalDateTime.value) => {
    let K = null;
    if (N) {
      const he = a ? s : void 0;
      K = At(N, h.value, l, he, a, S.value, w.value, u, m);
    }
    j?.(K), X?.(K);
    const ae = !$.hasErrors.value;
    Z?.(ae, $.mergedErrors.value, $.errorParams.value);
  };
  de(() => t, (N) => {
    const K = ve(N, w.value, S.value);
    N && !K ? ($.handleDateValidation(!1, { date: "無效的日期格式" }), c.setExternalValue(null)) : K && !$.validateDateRange(K) ? c.setExternalValue(null) : ($.clearFieldErrors("date"), $.clearFieldErrors("invalidInput"), c.setExternalValue(K));
  }, { immediate: !0 });
  const M = (N, K, ae = {}) => {
    $.handleDateValidation(N, K, "date", ae), Z?.(!$.hasErrors.value, $.mergedErrors.value, $.errorParams.value);
  }, H = (N, K, ae = {}) => {
    $.handleTimeValidation(N, K, "time", ae), Z?.(!$.hasErrors.value, $.mergedErrors.value, $.errorParams.value);
  }, q = async (N) => {
    c.inputDateValue.value = N;
    const K = c.updateFromInputs();
    if (!K) {
      $.handleDateValidation(!1, { date: "date.invalid" });
      return;
    }
    $.validateDateRange(K) && (await E(K), ["date", "year", "month", "day"].forEach((ae) => {
      $.clearFieldErrors(ae);
    }), y.autoFocusTimeAfterDateComplete(
      c,
      i ? P.getValidDefaultTime.value : void 0
    ));
  }, ee = async (N) => {
    c.inputTimeValue.value = N;
    const K = c.updateFromInputs();
    await E(K), ["time", "hour", "minute", "second"].forEach((ae) => {
      $.clearFieldErrors(ae);
    });
  }, me = async (N, K = !0) => {
    try {
      if (!$.validateDateRange(N))
        return;
      c.setInternalDateTime(N), await E(c.internalDateTime.value), ["date", "year", "month", "day"].forEach((ae) => {
        $.clearFieldErrors(ae);
      }), K && D.hideCalendar();
    } catch (ae) {
      console.error("處理日曆選擇失敗:", ae);
    }
  }, se = async (N) => {
    const K = c.updateTimeOnly(N);
    K && await E(K), ["time", "hour", "minute", "second"].forEach((ae) => {
      $.clearFieldErrors(ae);
    });
  }, R = (N) => {
    D.handleContainerClick(N, () => {
      y.focusFirstInput();
    }), D.toggleCalendar();
  }, Y = () => {
    c.clearValues(), $.clearAllErrors(), E(null);
  }, B = async () => {
    const N = await p.value?.validate(), K = a ? await d.value?.validate() : !0;
    let ae = !0;
    c.internalDateTime.value && (ae = fe.isValidDate(
      c.internalDateTime.value.year,
      c.internalDateTime.value.month,
      c.internalDateTime.value.day,
      "gregory"
      // 固定使用西元曆驗證
    ), ae || $.handleDateValidation(!1, {
      date: "date.invalid"
      // 簡化錯誤信息
    }));
    const he = $.validateDateTime(
      c.inputDateValue.value,
      c.inputTimeValue.value
    ), ye = N && K && ae && he;
    return Z?.(ye, $.mergedErrors.value, $.errorParams.value), ye;
  }, te = async () => {
    const N = /* @__PURE__ */ new Date(), K = {
      year: N.getFullYear(),
      month: N.getMonth() + 1,
      day: N.getDate(),
      hour: N.getHours(),
      minute: N.getMinutes(),
      second: N.getSeconds()
    };
    try {
      c.setInternalDateTime(K), await E(K), ["date", "year", "month", "day", "time", "hour", "minute", "second"].forEach((ae) => {
        $.clearFieldErrors(ae);
      });
    } catch (ae) {
      console.warn("設置當前時間失敗:", ae);
      const he = `${K.year}-${K.month.toString().padStart(2, "0")}-${K.day.toString().padStart(2, "0")}`, ye = a ? `${(K.hour || 0).toString().padStart(2, "0")}:${(K.minute || 0).toString().padStart(2, "0")}:${(K.second || 0).toString().padStart(2, "0")}` : null;
      c.inputDateValue.value = he, a && ye && (c.inputTimeValue.value = ye);
      const Me = c.updateFromInputs();
      await E(Me);
    }
  }, Q = () => {
    y.focusFirstInput();
  };
  return {
    // 狀態
    isDisabled: b,
    // 日曆系統相關
    calendar: S,
    // 從各個 composables 暴露的狀態
    ...$,
    ...c,
    ...D,
    // 計算屬性
    calendarMinDate: z,
    calendarMaxDate: J,
    // 預設時間相關
    getValidDefaultTime: P.getValidDefaultTime,
    // 事件處理方法
    setEmitters: I,
    validateDateInput: M,
    validateTimeInput: H,
    handleDateComplete: q,
    handleTimeComplete: ee,
    handleCalendarSelect: me,
    handleTimeSelect: se,
    handleContainerClick: R,
    handleContainerMouseDown: D.handleContainerMouseDown,
    // 導航方法
    handleNavigateToDate: y.handleNavigateToDate,
    handleNavigateToTime: y.handleNavigateToTime,
    // 主要操作方法
    reset: Y,
    validate: B,
    selectNow: te,
    focus: Q,
    // 直接暴露導航方法(用於 defineExpose)
    focusFirstInput: y.focusFirstInput,
    focusLastInput: y.focusLastInput
  };
}
const Da = {
  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 Qa(r) {
  const e = r.match(/oklch\(\s*([0-9.]+)%?\s+([0-9.]+)\s+([0-9.]+)(?:\s*\/\s*([0-9.]+))?\s*\)/);
  if (!e) return null;
  const [t, a, n, o] = e.map(Number);
  return { lightness: a, chroma: n, hue: o };
}
function es(r) {
  r = r.replace(/^#/, ""), r.length === 3 && (r = r.split("").map((n) => n + n).join(""));
  const e = parseInt(r.slice(0, 2), 16), t = parseInt(r.slice(2, 4), 16), a = parseInt(r.slice(4, 6), 16);
  return {
    r: e / 255,
    g: t / 255,
    b: a / 255
  };
}
function ts(r) {
  const e = r.match(/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/);
  if (e) {
    const [a, n, o, l] = e.map(Number);
    return {
      r: Math.max(0, Math.min(255, n)) / 255,
      g: Math.max(0, Math.min(255, o)) / 255,
      b: Math.max(0, Math.min(255, l)) / 255
    };
  }
  const t = r.match(/^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*([0-9]*\.?[0-9]+)\s*\)$/);
  if (t) {
    const [a, n, o, l] = t.map(Number);
    return {
      r: Math.max(0, Math.min(255, n)) / 255,
      g: Math.max(0, Math.min(255, o)) / 255,
      b: Math.max(0, Math.min(255, l)) / 255
    };
  }
  return null;
}
function Or(r) {
  const { r: e, g: t, b: a } = r, n = e <= 0.04045 ? e / 12.92 : Math.pow((e + 0.055) / 1.055, 2.4), o = t <= 0.04045 ? t / 12.92 : Math.pow((t + 0.055) / 1.055, 2.4), l = a <= 0.04045 ? a / 12.92 : Math.pow((a + 0.055) / 1.055, 2.4), s = 0.4124 * n + 0.3576 * o + 0.1805 * l, u = 0.2126 * n + 0.7152 * o + 0.0722 * l, i = 0.0193 * n + 0.1192 * o + 0.9505 * l, m = 0.95047, g = 1, v = 1.08883, k = s > 8856e-6 ? Math.pow(s / m, 1 / 3) : 7.787 * s / m + 16 / 116, T = u > 8856e-6 ? Math.pow(u / g, 1 / 3) : 7.787 * u / g + 16 / 116, f = i > 8856e-6 ? Math.pow(i / v, 1 / 3) : 7.787 * i / v + 16 / 116, p = 116 * T - 16, d = 500 * (k - T), S = 200 * (T - f);
  return { l: p, a: d, b: S };
}
function Vr(r) {
  const { l: e, a: t, b: a } = r, n = Math.sqrt(t * t + a * a);
  let o = Math.atan2(a, t) * 180 / Math.PI;
  return o < 0 && (o += 360), { l: e, c: n, h: o };
}
function as(r) {
  const e = es(r), t = Or(e), a = Vr(t);
  let n = a.h;
  return n > 0 && n < 60 && (n = n * 0.7), {
    lightness: a.l,
    chroma: Math.min(a.c / 150, 0.4),
    hue: n
  };
}
function rs(r) {
  const e = Or(r), t = Vr(e);
  let a = t.h;
  return a > 0 && a < 60 && (a = a * 0.7), {
    lightness: t.l,
    chroma: Math.min(t.c / 150, 0.4),
    hue: a
  };
}
function ns(r, e) {
  const t = Math.min(
    Math.abs(r.hue - e.hue),
    360 - Math.abs(r.hue - e.hue)
  ), a = t > 60 ? 30 : 5;
  return Math.sqrt(
    Math.pow((r.lightness - e.lightness) * 1.5, 2) + Math.pow((r.chroma - e.chroma) * 2, 2) + Math.pow(t / 360 * a, 2) * 100
  );
}
function os(r) {
  return r.startsWith("oklch(");
}
function ls(r) {
  return /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(r);
}
function ss(r) {
  return r in Da;
}
function is(r) {
  return r.startsWith("rgb(") || r.startsWith("rgba(");
}
function Za(r) {
  const e = "violet";
  if (ss(r))
    return r;
  let t = null;
  if (os(r))
    t = Qa(r);
  else if (ls(r))
    t = as(r);
  else if (is(r)) {
    const o = ts(r);
    o && (t = rs(o));
  }
  if (!t) return e;
  let a = e, n = 1 / 0;
  for (const [o, l] of Object.entries(Da))
    for (const s of ["300", "400", "500", "600", "700"]) {
      const u = l[s];
      if (!u) continue;
      const i = Qa(u);
      if (!i) continue;
      const m = ns(t, i);
      m < n && (n = m, a = o);
    }
  return a;
}
function us(r) {
  return Da[r] || {};
}
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 t = e.matches ? "dark" : "light";
    this.instances.forEach((a, n) => {
      a.systemPreference = t, a.userPreference === "auto" && this.updateCurrentMode(n);
    });
  }
  /**
   * 獲取當前系統偏好
   */
  getSystemPreference() {
    return this.mediaQuery && this.mediaQuery.matches ? "dark" : "light";
  }
  /**
   * 創建新的主題實例
   */
  createInstance(e, t = {}) {
    const a = e || this.generateInstanceId(), n = {
      currentMode: "light",
      userPreference: t.defaultMode || "auto",
      systemPreference: this.getSystemPreference(),
      color: Za(t.defaultColor || "violet"),
      instanceId: a
    };
    return this.instances.set(a, n), this.listeners.set(a, []), this.updateCurrentMode(a), typeof document < "u" && setTimeout(() => {
      this.applyColorToDOM(a), this.applyModeToDOM(a);
    }, 0), a;
  }
  /**
   * 銷毀主題實例
   */
  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 t = this.instances.get(e);
    if (!t) return;
    const a = t.currentMode;
    t.userPreference === "auto" ? t.currentMode = t.systemPreference : t.currentMode = t.userPreference, a !== t.currentMode && (this.applyModeToDOM(e), this.notifyListeners(e));
  }
  /**
   * 應用模式到特定的 DOM 元素
   */
  applyModeToDOM(e) {
    if (typeof document > "u") return;
    const t = this.instances.get(e);
    if (!t) return;
    const a = document.querySelector(`[data-vdt-instance="${e}"]`);
    if (!a) {
      setTimeout(() => this.applyModeToDOM(e), 10);
      return;
    }
    t.userPreference === "auto" ? a.removeAttribute("data-vdt-mode") : a.setAttribute("data-vdt-mode", t.currentMode);
  }
  /**
   * 應用顏色到特定的 DOM 元素
   */
  applyColorToDOM(e) {
    if (typeof document > "u") return;
    const t = this.instances.get(e);
    if (!t) return;
    const a = document.querySelector(`[data-vdt-instance="${e}"]`);
    if (!a) {
      setTimeout(() => this.applyColorToDOM(e), 10);
      return;
    }
    const n = us(t.color);
    this.checkForUserOverride(a, n) ? Object.keys(n).forEach((l) => {
      a.style.removeProperty(`--color-vdt-theme-${l}`);
    }) : Object.entries(n).forEach(([l, s]) => {
      a.style.setProperty(`--color-vdt-theme-${l}`, s);
    });
  }
  /**
   * 檢查用戶是否有 CSS 覆蓋
   */
  checkForUserOverride(e, t) {
    const a = {};
    Object.keys(t).forEach((g) => {
      const v = `--color-vdt-theme-${g}`;
      a[v] = e.style.getPropertyValue(v), e.style.removeProperty(v);
    });
    const o = getComputedStyle(e).getPropertyValue("--color-vdt-theme-500").trim();
    if (Object.entries(a).forEach(([g, v]) => {
      v && e.style.setProperty(g, v);
    }), !o) return !1;
    const l = "oklch(60.6% 0.25 292.717)", s = t[500], u = this.isOklchEqual(o, l), i = this.isOklchEqual(o, s);
    return !u && !i;
  }
  /**
   * 解析 OKLCH 值為數值以便比較
   */
  parseOklchForComparison(e) {
    const t = e.match(/oklch\(\s*([0-9.]+)%?\s+([0-9.]+)\s+([0-9.]+)\s*\)/);
    return t ? {
      l: parseFloat(t[1]),
      c: parseFloat(t[2]),
      h: parseFloat(t[3])
    } : null;
  }
  /**
   * 比較兩個 OKLCH 顏色是否相等(容許小數點誤差)
   */
  isOklchEqual(e, t, a = 1e-3) {
    const n = this.parseOklchForComparison(e), o = this.parseOklchForComparison(t);
    return !n || !o ? e.trim() === t.trim() : Math.abs(n.l - o.l) < a && Math.abs(n.c - o.c) < a && Math.abs(n.h - o.h) < a;
  }
  /**
   * 通知監聽器
   */
  notifyListeners(e) {
    const t = this.instances.get(e), a = this.listeners.get(e);
    t && a && a.forEach((n) => n({ ...t }));
  }
  /**
   * 設置主題模式
   */
  setMode(e, t) {
    const a = this.instances.get(e);
    a && (a.userPreference = t, this.updateCurrentMode(e));
  }
  /**
   * 設置主題顏色
   */
  setColor(e, t) {
    const a = this.instances.get(e);
    if (!a) return;
    const n = Za(t);
    a.color = n, this.applyColorToDOM(e), this.notifyListeners(e);
  }
  /**
   * 獲取實例狀態
   */
  getState(e) {
    const t = this.instances.get(e);
    return t ? { ...t } : null;
  }
  /**
   * 獲取主題類別(用於組件)
   */
  getThemeClasses(e) {
    const t = this.instances.get(e);
    return t ? {
      // 穩定的通用類名
      "vdt-datepicker": !0,
      "vdt-themed": !0,
      // 主題色相關類名
      [`vdt-theme-${t.color}`]: !0,
      // 模式相關類名
      [`vdt-mode-${t.currentMode}`]: !0,
      "vdt-mode-auto": t.userPreference === "auto",
      // 實例相關(用於調試,但不應用於 CSS)
      [`vdt-instance-${e}`]: !0
    } : {};
  }
  /**
   * 獲取容器屬性
   */
  getContainerAttributes(e) {
    const t = this.instances.get(e);
    if (!t) return {};
    const a = {
      "data-vdt-instance": e,
      "data-vdt-theme": t.color,
      "data-vdt-mode-preference": t.userPreference
    };
    return t.userPreference !== "auto" && (a["data-vdt-mode"] = t.currentMode), a;
  }
  /**
   * 強制重新應用主題(用於調試或強制刷新)
   */
  reapplyTheme(e) {
    this.applyColorToDOM(e), this.applyModeToDOM(e);
  }
  /**
   * 添加監聽器
   */
  addListener(e, t) {
    const a = this.listeners.get(e);
    return a ? (a.push(t), () => {
      const n = a.indexOf(t);
      n > -1 && a.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 Fr(r = {}) {
  const e = W(
    Ie.createInstance(r.instanceId, {
      defaultColor: r.defaultColor,
      defaultMode: r.defaultMode
    })
  ), t = W(
    Ie.getState(e.value)
  );
  let a = null;
  const n = C(() => t.value?.currentMode === "dark"), o = C(() => t.value?.currentMode === "light"), l = C(() => t.value?.userPreference === "auto"), s = C(() => t.value?.currentMode || "light"), u = C(() => t.value?.userPreference || "auto"), i = C(() => t.value?.systemPreference || "light"), m = C(() => t.value?.color || "violet"), g = C(() => e.value ? Ie.getThemeClasses(e.value) : {}), v = C(() => e.value ? Ie.getContainerAttributes(e.value) : {}), k = (d) => {
    e.value && Ie.setColor(e.value, d);
  }, T = (d) => {
    e.value && Ie.setMode(e.value, d);
  }, f = () => {
    if (t.value)
      if (t.value.userPreference === "auto") {
        const d = t.value.currentMode === "light" ? "dark" : "light";
        T(d);
      } else {
        const d = t.value.currentMode === "light" ? "dark" : "light";
        T(d);
      }
  }, p = C(() => typeof window > "u" ? !1 : window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches !== void 0);
  return Ht(async () => {
    await we(), t.value = Ie.getState(e.value), a = Ie.addListener(e.value, (d) => {
      t.value = d;
    }), setTimeout(() => {
      Ie.reapplyTheme(e.value);
    }, 10);
  }), Bt(() => {
    a && a(), e.value && Ie.destroyInstance(e.value);
  }), {
    // 響應式狀態
    instanceId: e,
    themeState: t,
    isDark: n,
    isLight: o,
    isAuto: l,
    currentMode: s,
    userPreference: u,
    systemPreference: i,
    currentColor: m,
    themeClasses: g,
    containerAttributes: v,
    supportsColorScheme: p,
    // 主要方法
    setColor: k,
    setMode: T,
    toggle: f,
    // 便利方法 - 模式設置
    setLightMode: () => T("light"),
    setDarkMode: () => T("dark"),
    setAutoMode: () => T("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 = { key: 0 }, fs = {
  key: 0,
  class: "date-placeholder text-vdt-content truncate"
}, ms = {
  key: 1,
  class: "date-placeholder text-vdt-content-muted truncate"
}, hs = ["disabled"], vs = { key: 0 }, Ga = /* @__PURE__ */ Ce({
  __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 },
    showErrorMessage: { type: Boolean, default: !0 },
    useI18n: { type: Boolean, default: !0 },
    customErrorMessages: { default: () => ({}) }
  },
  emits: ["update:modelValue", "change", "validation"],
  setup(r, { expose: e, emit: t }) {
    const a = r, { setLocale: n, getPlaceholderMessage: o } = gt(
      a.locale,
      a.customLocaleMessages
    ), l = t, s = Jr(), u = C(() => {
      const x = {};
      return ["no-years-display", "month-selector"].forEach((U) => {
        s[U] && (x[U] = s[U]);
      }), Object.keys(s).forEach((U) => {
        U.startsWith("year-") && (x[U] = s[U]);
      }), x;
    }), i = W(null), m = W(null), g = W(null), v = W(null), k = C(() => a.timeFormat ? a.timeFormat : a.enableSeconds ? a.use24Hour ? "HH:mm:ss" : "hh:mm:ss A" : a.use24Hour ? "HH:mm" : "hh:mm A"), T = W(a.dateFormat), f = W(k.value), p = W({}), d = Xl(
      {
        modelValue: a.modelValue,
        showTime: a.showTime,
        required: a.required,
        disabled: a.disabled,
        calendar: zt(a, "calendar"),
        dateFormat: T.value,
        timeFormat: f.value,
        outputType: zt(a, "outputType"),
        useStrictISO: a.useStrictISO,
        customDefaultTime: a.customDefaultTime,
        enableSeconds: a.enableSeconds,
        autoFocusTimeAfterDate: a.autoFocusTimeAfterDate,
        minDate: a.minDate,
        maxDate: a.maxDate,
        locale: zt(a, "locale")
      },
      {
        containerRef: i,
        calendarRef: m,
        dateInputRef: g,
        timeInputRef: v
      }
    );
    d.setEmitters({
      update: (x) => l("update:modelValue", x),
      change: (x) => l("change", x),
      validation: (x, U, re) => l("validation", x, U, re)
    });
    const {
      themeClasses: S,
      containerAttributes: w,
      setColor: h,
      setMode: b,
      currentMode: $,
      isDark: c,
      isLight: y
    } = Fr(), D = C(() => {
      const x = ve(a.minDate, a.locale);
      return Te(x);
    }), P = C(() => {
      const x = ve(a.maxDate, a.locale);
      return Te(x);
    }), z = C(() => T.value), J = C(() => a.calendar === "gregory"), j = C(() => !!(M.value && M.value.trim())), X = C(() => {
      a.locale;
      const x = {
        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: a.placeholderOverrides?.selectDate || x.selectDate,
        // 時間相關
        hour: a.placeholderOverrides?.hour || x.hour,
        minute: a.placeholderOverrides?.minute || x.minute,
        second: a.placeholderOverrides?.second || x.second,
        // 日期相關
        year: a.placeholderOverrides?.year || x.year,
        month: a.placeholderOverrides?.month || x.month,
        day: a.placeholderOverrides?.day || x.day
      };
    }), Z = C(() => ({
      ...d.mergedErrors.value,
      ...p.value
    })), I = C(() => {
      const re = {
        ...d.mergedErrorParams?.value || {},
        ...{}
      };
      return Object.keys(re).length > 0 ? re : {};
    }), E = C(() => Object.keys(Z.value).length > 0);
    Xa(() => {
      if (!wr(a.dateFormat) && a.calendar === "gregory") {
        const x = a.dateFormat, U = Do(a.dateFormat);
        p.value.dateFormat = "format.invalid", console.warn(`日期格式 "${x}" 不正確,已自動修復為 "${U}"`), T.value = U;
      }
      if (a.showTime && !na(f.value)) {
        const x = f.value, U = bo(f.value);
        if (na(U))
          p.value.timeFormat = "format.invalid", console.warn(`時間格式 "${x}" 不正確,已自動修復為 "${U}"`), f.value = U;
        else {
          const re = k.value;
          p.value.timeFormat = "format.invalid", console.warn(`時間格式 "${x}" 不正確,已使用預設格式 "${re}"`), f.value = re;
        }
      }
    }), de(() => a.theme, (x) => {
      x && h(x);
    }, { immediate: !0 }), de(() => a.mode, (x) => {
      b(x);
    }, { immediate: !0 }), de(() => a.locale, (x) => {
      x && n(x, a.customLocaleMessages);
    }, { immediate: !0 }), de(() => a.customLocaleMessages, (x) => {
      x && a.locale && n(a.locale, x);
    }), de([() => a.enableSeconds, () => a.use24Hour, () => a.timeFormat], () => {
      a.timeFormat || (f.value = k.value);
    }, { immediate: !0 }), de(() => a.calendar, (x) => {
      fe.isCalendarSupported(x) ? delete p.value.calendar : p.value.calendar = "calendar.unsupported";
    }, { immediate: !0 }), e({
      // 基本操作
      focus: d.focus,
      reset: d.reset,
      validate: d.validate,
      selectNow: d.selectNow,
      // 數據獲取
      getDateTime: () => d.internalDateTime.value,
      setDateTime: (x) => {
        d.setExternalValue(x);
      },
      // 主題控制
      setTheme: h,
      setDarkMode: () => b("dark"),
      setLightMode: () => b("light"),
      setAutoMode: () => b("auto"),
      getCurrentMode: () => $.value,
      isDarkMode: () => c.value,
      isLightMode: () => y.value,
      // 錯誤相關
      getErrors: () => Z.value,
      hasErrors: () => E.value
    });
    const {
      // 狀態
      inputDateValue: M,
      inputTimeValue: H,
      showCalendar: q,
      internalDateTime: ee,
      calendarMinDate: me,
      calendarMaxDate: se,
      getValidDefaultTime: R,
      hasValue: Y,
      // 事件處理
      validateDateInput: B,
      validateTimeInput: te,
      handleDateComplete: Q,
      handleTimeComplete: N,
      handleCalendarSelect: K,
      handleTimeSelect: ae,
      handleContainerClick: he,
      handleContainerMouseDown: ye,
      handleNavigateToDate: Me,
      // 日曆控制
      toggleCalendar: be,
      // 清除功能
      reset: F
    } = d;
    return (x, U) => (A(), L(De, null, [
      _("div", er({
        class: ["date-picker-wrapper relative w-full", [V(S), x.showTime ? "min-w-[300px]" : "min-w-[150px]"]]
      }, V(w), {
        ref_key: "containerRef",
        ref: i
      }), [
        _("div", {
          class: ge(["date-picker-container flex w-full items-center px-2 py-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": E.value }]])
        }, [
          J.value && x.inputEnabled ? (A(), L("div", {
            key: 0,
            class: ge(["flex w-full items-center justify-start gap-2", [x.disabled ? "cursor-not-allowed cursor-event-none opacity-50" : ""]]),
            onClick: U[2] || (U[2] = Se(
              //@ts-ignore
              (...re) => V(he) && V(he)(...re),
              ["stop"]
            )),
            onMousedown: U[3] || (U[3] = //@ts-ignore
            (...re) => V(ye) && V(ye)(...re))
          }, [
            _("div", null, [
              ue(la, {
                ref_key: "dateInputRef",
                ref: g,
                modelValue: V(M),
                "onUpdate:modelValue": U[0] || (U[0] = (re) => Ma(M) ? M.value = re : null),
                "year-placeholder": X.value.year,
                "month-placeholder": X.value.month,
                "day-placeholder": X.value.day,
                "min-date": D.value,
                "max-date": P.value,
                required: x.required,
                separator: x.dateSeparator,
                "date-format": z.value,
                onValidation: V(B),
                onComplete: V(Q)
              }, null, 8, ["modelValue", "year-placeholder", "month-placeholder", "day-placeholder", "min-date", "max-date", "required", "separator", "date-format", "onValidation", "onComplete"])
            ]),
            x.showTime ? (A(), L("div", ds, [
              ue(sa, {
                ref_key: "timeInputRef",
                ref: v,
                modelValue: V(H),
                "onUpdate:modelValue": U[1] || (U[1] = (re) => Ma(H) ? H.value = re : null),
                "hour-placeholder": X.value.hour,
                "minute-placeholder": X.value.minute,
                "second-placeholder": X.value.second,
                "enable-seconds": x.enableSeconds,
                use24Hour: x.use24Hour,
                required: x.required,
                locale: x.locale,
                useLocalizedPeriod: x.useLocalizedPeriod,
                onValidation: V(te),
                onComplete: V(N),
                onNavigateToDate: V(Me)
              }, null, 8, ["modelValue", "hour-placeholder", "minute-placeholder", "second-placeholder", "enable-seconds", "use24Hour", "required", "locale", "useLocalizedPeriod", "onValidation", "onComplete", "onNavigateToDate"])
            ])) : ce("", !0)
          ], 34)) : (A(), L("button", {
            key: 1,
            type: "button",
            class: ge(["flex w-full h-full items-center justify-start gap-1", {
              "cursor-not-allowed opacity-50": x.disabled
            }]),
            onClick: U[4] || (U[4] = Se((re) => !x.disabled && V(be)?.(), ["stop"])),
            onKeydown: [
              U[5] || (U[5] = Fe(Se((re) => !x.disabled && V(be)?.(), ["prevent"]), ["enter"])),
              U[6] || (U[6] = Fe(Se((re) => !x.disabled && V(be)?.(), ["prevent"]), ["space"]))
            ]
          }, [
            j.value ? (A(), L("span", fs, oe(x.modelValue), 1)) : (A(), L("span", ms, oe(X.value.selectDate), 1))
          ], 34)),
          _("div", {
            class: ge(["date-picker-icon-container relative group cursor-pointer", { "cursor-not-allowed": x.disabled }])
          }, [
            _("button", {
              type: "button",
              class: ge(["date-picker-icon text-gray-400 hover:text-gray-600 transition-colors disabled:cursor-not-allowed", { "group-hover:opacity-0": V(Y) && !x.disabled && x.showClearButton }]),
              disabled: x.disabled,
              "aria-label": "開啟日曆",
              onClick: U[7] || (U[7] = Se((re) => V(be)?.(), ["stop", "prevent"]))
            }, [
              ue(Cr, { class: "h-5 w-5" })
            ], 10, hs),
            V(Y) && !x.disabled && x.showClearButton ? (A(), L("button", {
              key: 0,
              type: "button",
              class: "date-picker-icon absolute inset-0 text-gray-400 hover:text-red-500 opacity-0 group-hover:opacity-100",
              "aria-label": "清除日期",
              onClick: U[8] || (U[8] = Se(
                //@ts-ignore
                (...re) => V(F) && V(F)(...re),
                ["stop", "prevent"]
              ))
            }, [
              ue(Er, { class: "h-4 w-4" })
            ])) : ce("", !0)
          ], 2)
        ], 2),
        V(q) && !x.disabled ? (A(), L("div", {
          key: 0,
          ref_key: "calendarRef",
          ref: m,
          class: "calendar-container absolute mt-1 bg-vdt-surface-elevated border border-vdt-outline rounded-lg shadow-lg z-10",
          onClick: U[9] || (U[9] = Se(() => {
          }, ["stop"])),
          role: "dialog",
          "aria-modal": "true",
          "aria-label": "date-picker"
        }, [
          ue(ia, {
            value: V(ee),
            weekStartsOn: x.weekStartsOn,
            "min-date": V(me),
            "max-date": V(se),
            showTimeSelector: x.showTime,
            "time-value": V(H),
            use24Hour: x.use24Hour,
            "default-time": V(R),
            enableSeconds: x.enableSeconds,
            locale: x.locale,
            calendar: x.calendar,
            onSelect: V(K),
            onTimeSelect: V(ae)
          }, ct({ _: 2 }, [
            $e(u.value, (re, Re) => ({
              name: Re,
              fn: dt((nt) => [
                pe(x.$slots, Re, ft(mt(nt)))
              ])
            }))
          ]), 1032, ["value", "weekStartsOn", "min-date", "max-date", "showTimeSelector", "time-value", "use24Hour", "default-time", "enableSeconds", "locale", "calendar", "onSelect", "onTimeSelect"])
        ], 512)) : ce("", !0)
      ], 16),
      x.showErrorMessage && E.value ? (A(), L("div", vs, [
        pe(x.$slots, "error", {
          errors: Z.value,
          errorParams: I.value,
          hasErrors: E.value
        }, () => [
          ue(xr, {
            errors: Z.value,
            locale: x.locale,
            "use-i18n": x.useI18n,
            "custom-messages": x.customErrorMessages,
            errorParams: I.value
          }, ct({ _: 2 }, [
            $e(x.$slots, (re, Re) => ({
              name: Re,
              fn: dt((nt) => [
                pe(x.$slots, Re, ft(mt(nt)))
              ])
            }))
          ]), 1032, ["errors", "locale", "use-i18n", "custom-messages", "errorParams"])
        ])
      ])) : ce("", !0)
    ], 64));
  }
}), ps = {
  key: 0,
  class: "calendar-container flex-1 md:min-w-[280px] min-w-auto"
}, gs = /* @__PURE__ */ Ce({
  __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: () => Ge().year },
    initialMonth: { default: () => Ge().month }
  },
  emits: ["range-select", "time-select"],
  setup(r, { expose: e, emit: t }) {
    const a = r, n = t, o = W({
      isSelecting: !1,
      tempStart: null,
      activeTimeTarget: "start"
    }), l = () => {
      if (a.rangeStart)
        return { year: a.rangeStart.year, month: a.rangeStart.month };
      if (a.initialYear && a.initialMonth)
        return { year: a.initialYear, month: a.initialMonth };
      const h = Ge();
      return { year: h.year, month: h.month };
    }, { year: s, month: u } = l(), i = W(s), m = W(u), g = C(() => m.value === 12 ? i.value + 1 : i.value), v = C(() => m.value === 12 ? 1 : m.value + 1), k = C(() => a.monthDisplayMode === "single" ? o.value.activeTimeTarget === "start" ? a.startTimeValue : a.endTimeValue : a.startTimeValue), T = C(() => a.endTimeValue), f = C(() => a.monthDisplayMode === "single" ? o.value.activeTimeTarget : "start");
    de(() => [a.rangeStart, a.rangeEnd], ([h, b]) => {
      h && !a.initialYear && !a.initialMonth && (i.value = h.year, m.value = h.month), a.monthDisplayMode === "single" ? h && b ? (o.value.isSelecting = !1, o.value.tempStart = null, o.value.activeTimeTarget = "start") : h && !b ? (o.value.isSelecting = !0, o.value.tempStart = h, o.value.activeTimeTarget = "end") : (o.value.isSelecting = !1, o.value.tempStart = null, o.value.activeTimeTarget = "start") : h && b ? (o.value.isSelecting = !1, o.value.tempStart = null) : h && !b ? (o.value.isSelecting = !0, o.value.tempStart = h) : (o.value.isSelecting = !1, o.value.tempStart = null);
    }, { immediate: !0, deep: !0 });
    const p = (h, b) => {
      if (!h) {
        o.value.isSelecting = !1, o.value.tempStart = null, a.monthDisplayMode === "single" && (o.value.activeTimeTarget = "start"), n("range-select", null, null);
        return;
      }
      if (!o.value.isSelecting)
        o.value.isSelecting = !0, o.value.tempStart = h, a.monthDisplayMode === "single" && (o.value.activeTimeTarget = "start"), n("range-select", h, null);
      else {
        const $ = o.value.tempStart;
        if ($ && (h.year !== $.year || h.month !== $.month || h.day !== $.day)) {
          o.value.isSelecting = !1, o.value.tempStart = null;
          const c = $.year * 1e4 + $.month * 100 + $.day, y = h.year * 1e4 + h.month * 100 + h.day;
          c <= y ? n("range-select", $, h) : n("range-select", h, $), a.monthDisplayMode === "single" && (o.value.activeTimeTarget = "end");
        } else
          o.value.tempStart = h, a.monthDisplayMode === "single" && (o.value.activeTimeTarget = "start"), n("range-select", h, null);
      }
    }, d = (h, b) => {
      n("time-select", h, b);
    };
    return e({
      // 獲取當前顯示的月份
      getCurrentDisplay: () => a.monthDisplayMode === "single" ? {
        year: i.value,
        month: m.value
      } : {
        left: { year: i.value, month: m.value },
        right: { year: g.value, month: v.value }
      },
      // 設置顯示月份
      setDisplayMonth: (h, b) => {
        i.value = h, m.value = b;
      },
      // 重置範圍選擇狀態
      resetRangeSelection: () => {
        o.value.isSelecting = !1, o.value.tempStart = null, a.monthDisplayMode === "single" && (o.value.activeTimeTarget = "start");
      },
      // 獲取當前選擇狀態
      getSelectionState: () => ({
        isSelecting: o.value.isSelecting,
        tempStart: o.value.tempStart,
        activeTimeTarget: o.value.activeTimeTarget
      }),
      // 月份導航
      previousMonth: () => {
        m.value === 1 ? (m.value = 12, i.value -= 1) : m.value -= 1;
      },
      nextMonth: () => {
        m.value === 12 ? (m.value = 1, i.value += 1) : m.value += 1;
      },
      handleRangeSelect: p
    }), (h, b) => (A(), L("div", {
      class: ge(["range-calendar", [
        h.monthDisplayMode === "single" ? "single-month" : "dual-month",
        "flex flex-col gap-4",
        h.monthDisplayMode === "dual" ? "min-w-auto md:min-w-[570px] md:flex-row" : "min-w-auto max-w-[300px]",
        "m-1"
      ]])
    }, [
      _("div", {
        class: ge(["calendar-container flex-1", [
          h.monthDisplayMode === "dual" ? "min-w-auto md:min-w-[280px]" : "min-w-auto"
        ]])
      }, [
        ue(ia, {
          "range-start": h.rangeStart,
          "range-end": h.rangeEnd,
          "selection-mode": "range",
          year: i.value,
          month: m.value,
          "min-date": h.minDate,
          "max-date": h.maxDate,
          locale: h.locale,
          "week-starts-on": h.weekStartsOn,
          calendar: h.calendar,
          showTimeSelector: h.showTimeSelector,
          "time-value": k.value,
          "enable-seconds": h.enableSeconds,
          "use24-hour": h.use24Hour,
          onRangeSelect: p,
          onTimeSelect: b[0] || (b[0] = ($) => d($, f.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),
      h.monthDisplayMode === "dual" ? (A(), L("div", ps, [
        ue(ia, {
          "range-start": h.rangeStart,
          "range-end": h.rangeEnd,
          "selection-mode": "range",
          year: g.value,
          month: v.value,
          "min-date": h.minDate,
          "max-date": h.maxDate,
          locale: h.locale,
          "week-starts-on": h.weekStartsOn,
          calendar: h.calendar,
          showTimeSelector: h.showTimeSelector,
          "time-value": T.value,
          "enable-seconds": h.enableSeconds,
          "use24-hour": h.use24Hour,
          onRangeSelect: p,
          onTimeSelect: b[1] || (b[1] = ($) => d($, "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"])
      ])) : ce("", !0)
    ], 2));
  }
}), Dt = "00:00:00", bt = "23:59:59";
function ys(r = {}, e) {
  const {
    calendar: t = "gregory",
    modelValue: a = null,
    showTime: n = !1,
    required: o = !1,
    disabled: l = !1,
    incomplete: s = !1,
    dateFormat: u = "YYYY-MM-DD",
    timeFormat: i = "HH:mm:ss",
    outputType: m = "iso",
    useStrictISO: g = !1,
    enableSeconds: v = !1,
    minDate: k,
    maxDate: T,
    maxRange: f,
    minRange: p,
    locale: d = "zh-TW"
  } = r, {
    containerRef: S,
    calendarRef: w,
    startDateInputRef: h,
    endDateInputRef: b,
    startTimeInputRef: $,
    endTimeInputRef: c
  } = e, y = W(l);
  let D = {};
  const P = ca({
    required: o,
    showTime: n,
    minDate: k,
    maxDate: T,
    dateFormat: u
  }), z = ca({
    required: o,
    showTime: n,
    minDate: k,
    maxDate: T,
    dateFormat: u
  }), J = da({
    showTime: n,
    dateFormat: u,
    timeFormat: i,
    outputType: m,
    defaultTime: Dt,
    enableSeconds: v
  }), j = da({
    showTime: n,
    dateFormat: u,
    timeFormat: i,
    outputType: m,
    defaultTime: bt,
    enableSeconds: v
  }), X = Ir(
    S,
    w,
    { disabled: y }
  ), Z = ua(
    { dateInputRef: h, timeInputRef: $ },
    { showTime: n, autoFocusTimeAfterDate: !0 }
  ), I = ua(
    { dateInputRef: b, timeInputRef: c },
    { showTime: n, autoFocusTimeAfterDate: !0 }
  ), E = C(
    () => J.hasValue.value || j.hasValue.value
  ), M = C(() => {
    const O = {
      ...P.mergedErrors.value,
      ...z.mergedErrors.value
    };
    return J.internalDateTime.value && !j.internalDateTime.value && s && (O["range.endRequired"] = "range.endRequired"), O;
  }), H = C(() => ({
    ...P.mergedErrorParams.value,
    ...z.mergedErrorParams.value
  })), q = C(() => Object.keys(M.value).length > 0), ee = C(() => {
    const O = J.internalDateTime.value, G = j.internalDateTime.value;
    if (!O || !G || Lt(O, G) > 0) return !1;
    if (f || p) {
      const ne = Ja(O, G);
      if (f && ne > f)
        return z.handleDateValidation(!1, {
          range: "range.exceedsMaxRange"
        }, "endDate", {
          range: { maxRange: f, actualDays: ne }
        }), !1;
      if (p && ne < p)
        return z.handleDateValidation(!1, {
          range: "range.belowMinRange"
        }, "endDate", {
          range: { minRange: p, actualDays: ne }
        }), !1;
      z.clearFieldErrors("range");
    }
    return !q.value;
  }), me = C(() => [
    {
      label: "今天",
      getValue: () => {
        const O = Je();
        return {
          start: Ae(O.year, O.month, O.day, 0, 0, 0),
          end: Ae(O.year, O.month, O.day, 23, 59, 59)
        };
      }
    },
    {
      label: "最近7天",
      getValue: () => ({
        start: ra(Je(), -6),
        end: Je()
      })
    },
    {
      label: "最近30天",
      getValue: () => ({
        start: ra(Je(), -29),
        end: Je()
      })
    },
    {
      label: "本月",
      getValue: yo
    }
  ]), se = C(() => ({
    minDate: ve(k, d),
    maxDate: j.internalDateTime.value || ve(T, d)
  })), R = C(() => ({
    minDate: J.internalDateTime.value || ve(k, d),
    maxDate: ve(T, d)
  })), Y = C(() => ({
    minDate: se.value.minDate ? Te(se.value.minDate, u) : null,
    maxDate: se.value.maxDate ? Te(se.value.maxDate, u) : null
  })), B = C(() => ({
    minDate: R.value.minDate ? Te(R.value.minDate, u) : null,
    maxDate: R.value.maxDate ? Te(R.value.maxDate, u) : null
  }));
  function te(O, G) {
    const ne = Ja(O, G);
    return f && ne > f ? {
      valid: !1,
      error: "range.exceedsMaxRange",
      params: { maxRange: f, actualDays: ne }
    } : p && ne < p ? {
      valid: !1,
      error: "range.belowMinRange",
      params: { minRange: p, actualDays: ne }
    } : { valid: !0 };
  }
  function Q(O) {
    !O.error || !O.params || z.handleDateValidation(
      !1,
      { range: O.error },
      "endDate",
      { range: O.params }
    );
  }
  function N() {
    if (!J.internalDateTime.value || !j.internalDateTime.value) {
      D.update?.(null), D.change?.(null);
      return;
    }
    const O = n ? i : void 0, G = {
      start: At(
        J.internalDateTime.value,
        m,
        u,
        O,
        n,
        t,
        d,
        g,
        v
      ),
      end: At(
        j.internalDateTime.value,
        m,
        u,
        O,
        n,
        t,
        d,
        g,
        v
      )
    };
    D.update?.(G), D.change?.(G);
    const ne = ee.value && !q.value;
    D.validation?.(ne, M.value, H.value);
  }
  function K(O, G) {
    G.forEach((ne) => O.clearFieldErrors(ne));
  }
  const ae = (O) => {
    D = O;
  }, he = (O, G, ne, zr, Wr) => {
    ne.handleDateValidation(O, G, zr, Wr), D.validation?.(!q.value, M.value, H.value);
  }, ye = (O, G, ne) => {
    he(O, G, P, "startDate", ne);
  }, Me = (O, G, ne) => {
    he(O, G, z, "endDate", ne);
  }, be = (O, G, ne = {}) => {
    P.handleTimeValidation(O, G, "startTime", ne), D.validation?.(!q.value, M.value);
  }, F = (O, G, ne = {}) => {
    z.handleTimeValidation(O, G, "endTime", ne), D.validation?.(!q.value, M.value, H.value);
  }, x = (O) => {
    J.inputDateValue.value = O;
    const G = J.updateFromInputs();
    if (!G) {
      P.handleDateValidation(!1, { date: "date.invalid" });
      return;
    }
    P.validateDateRange(G) && (Z.autoFocusTimeAfterDateComplete(
      J,
      Dt
    ), N(), K(P, ["startDate", "date.year", "date.month", "date.day"]), n || I.focusFirstInput());
  }, U = (O) => {
    j.inputDateValue.value = O;
    const G = j.updateFromInputs();
    if (!G) {
      z.handleDateValidation(!1, { date: "date.invalid" });
      return;
    }
    z.validateDateRange(G) && (I.autoFocusTimeAfterDateComplete(
      j,
      bt
    ), N(), K(z, ["endDate", "date.year", "date.month", "date.day"]));
  }, re = (O) => {
    J.inputTimeValue.value = O, J.updateFromInputs() && N(), K(P, ["startTime", "time.hour", "time.minute", "time.second"]);
  }, Re = (O) => {
    j.inputTimeValue.value = O, j.updateFromInputs() && N(), K(z, ["endTime", "time.hour", "time.minute", "time.second"]);
  }, nt = (O, G) => {
    O && !G ? Pr(O) : O && G ? Ar(O, G) : Nt(), N();
  };
  function Pr(O) {
    P.validateDateRange(O) && (J.setInternalDateTime(O), K(P, ["startDate", "date.year", "date.month", "date.day"]), j.clearValues());
  }
  function Ar(O, G) {
    if (!(!P.validateDateRange(O) || !z.validateDateRange(G))) {
      if (f || p) {
        const ne = te(O, G);
        if (!ne.valid) {
          Q(ne);
          return;
        }
      }
      J.setInternalDateTime(O), j.setInternalDateTime(G), n && (J.inputTimeValue.value || (J.inputTimeValue.value = Dt, J.updateFromInputs()), j.inputTimeValue.value || (j.inputTimeValue.value = bt, j.updateFromInputs())), K(P, ["startDate", "endDate", "range", "date.year", "date.month", "date.day"]), K(z, ["startDate", "endDate", "range", "date.year", "date.month", "date.day"]);
    }
  }
  const Lr = (O, G) => {
    G === "start" && J.internalDateTime.value && re(O), G === "end" && j.internalDateTime.value && Re(O);
  }, Hr = (O) => {
    const G = O.getValue();
    J.setInternalDateTime(G.start), j.setInternalDateTime(G.end), n && (J.inputTimeValue.value || (J.inputTimeValue.value = Dt, J.updateFromInputs()), j.inputTimeValue.value || (j.inputTimeValue.value = bt, j.updateFromInputs())), N();
  }, Nt = () => {
    J.clearValues(), j.clearValues(), P.clearAllErrors(), z.clearAllErrors(), N();
  }, Br = (O) => {
    O ? (J.setExternalValue(O.start), j.setExternalValue(O.end)) : Nt(), N();
  }, qr = () => (h.value?.validate(), b.value?.validate(), n && ($.value?.validate(), c.value?.validate()), ee.value), Ur = (O) => {
    X.handleContainerClick(O, () => {
      Z.focusFirstInput();
    });
  }, Nr = (O) => {
    X.handleContainerClick(O, () => {
      I.focusFirstInput();
    });
  };
  return de(() => a, (O) => {
    if (O && (O.start || O.end)) {
      const G = O.start ? ve(O.start, d, t) : null, ne = O.end ? ve(O.end, d, t) : null;
      if (O.start && !G && (console.warn(`Invalid start date provided: ${O.start}`), P.handleDateValidation(!1, { date: "date.invalid" }, "startDate")), O.end && !ne && (console.warn(`Invalid end date provided: ${O.end}`), z.handleDateValidation(!1, { date: "date.invalid" }, "endDate")), G && ne && Lt(G, ne) > 0) {
        console.warn("Initial date range has start > end, auto-swapping values"), J.setExternalValue(O.end), j.setExternalValue(O.start), setTimeout(() => {
          N();
        }, 0);
        return;
      }
      J.setExternalValue(G ? O.start : null), j.setExternalValue(ne ? O.end : null);
    } else
      J.clearValues(), j.clearValues();
  }, { immediate: !0 }), {
    // 狀態
    isDisabled: y,
    startDateConstraints: se,
    endDateConstraints: R,
    startDateConstraintsStr: Y,
    endDateConstraintsStr: B,
    // 驗證相關
    hasErrors: q,
    mergedErrors: M,
    mergedErrorParams: H,
    isValidRange: ee,
    // 日期時間值
    startDateTime: J,
    endDateTime: j,
    // 顯示值
    hasRangeValue: E,
    // 日曆相關
    ...X,
    // 快捷選項
    shortcuts: me,
    // 事件設置
    setEmitters: ae,
    // 驗證事件處理
    handleStartDateValidation: ye,
    handleEndDateValidation: Me,
    handleStartTimeValidation: be,
    handleEndTimeValidation: F,
    // 完成事件處理
    handleStartDateComplete: x,
    handleEndDateComplete: U,
    handleStartTimeComplete: re,
    handleEndTimeComplete: Re,
    // 日曆事件處理
    handleCalendarRangeSelect: nt,
    handleTimeSelect: Lr,
    // 導航事件處理
    handleStartNavigateToDate: Z.handleNavigateToDate,
    handleEndNavigateToDate: I.handleNavigateToDate,
    // 主要操作
    applyShortcut: Hr,
    clearRange: Nt,
    setRange: Br,
    validate: qr,
    // 導航方法
    focusStartDate: Ur,
    focusEndDate: Nr
  };
}
function $s() {
  const r = W(typeof window < "u" ? window.innerWidth : 0), e = W(typeof window < "u" ? window.innerHeight : 0), t = () => {
    r.value = window.innerWidth, e.value = window.innerHeight;
  };
  return Ht(() => {
    t(), window.addEventListener("resize", t);
  }), Bt(() => {
    window.removeEventListener("resize", t);
  }), { width: r, height: e };
}
const Ds = ["disabled"], bs = ["title"], Ms = {
  key: 0,
  class: "date-placeholder text-vdt-content truncate block"
}, Ss = {
  key: 1,
  class: "date-placeholder text-vdt-content-muted truncate block"
}, ws = {
  class: "text-vdt-content-muted text-sm px-1",
  "aria-label": "日期範圍分隔符",
  "data-testid": "separator"
}, ks = ["title"], Ts = {
  key: 0,
  class: "date-placeholder text-vdt-content truncate block"
}, xs = {
  key: 1,
  class: "date-placeholder text-vdt-content-muted truncate block"
}, Cs = ["disabled"], Ys = ["title"], Rs = { class: "p-2 space-y-2" }, Es = {
  key: 0,
  class: "w-full flex flex-col md:flex-row flex-justify-between gap-2"
}, Is = {
  key: 0,
  "data-testid": "start-time-inputs",
  "aria-label": "開始時間輸入區域"
}, Os = {
  key: 0,
  "data-testid": "end-time-inputs",
  "aria-label": "結束時間輸入區域"
}, Vs = {
  key: 1,
  "aria-label": "日期範圍快捷選項"
}, Fs = { class: "flex flex-wrap gap-2" }, Ps = ["aria-label", "data-testid", "onClick"], As = { key: 2 }, Ls = { class: "flex flex-wrap gap-2" }, Hs = { class: "calendar-container overflow-auto" }, Bs = { key: 0 }, qs = /* @__PURE__ */ Ce({
  __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 },
    showErrorMessage: { type: Boolean, default: !0 },
    useI18n: { type: Boolean, default: !0 },
    customErrorMessages: { default: () => ({}) }
  },
  emits: ["update:modelValue", "change", "validation"],
  setup(r, { expose: e, emit: t }) {
    const a = r, n = t, o = W(null), l = W(null), s = W(null), u = W(null), i = W(null), m = W(null), g = W({}), { width: v } = $s(), k = C(() => a.monthDisplayMode ? a.monthDisplayMode : v.value < 768 ? "single" : "dual"), T = C(() => a.timeFormat ? a.timeFormat : a.enableSeconds ? a.use24Hour ? "HH:mm:ss" : "hh:mm:ss A" : a.use24Hour ? "HH:mm" : "hh:mm A"), f = ys(
      {
        calendar: a.calendar,
        modelValue: a.modelValue,
        showTime: a.showTime,
        required: a.required,
        disabled: a.disabled,
        dateFormat: a.dateFormat,
        timeFormat: T.value,
        outputType: a.outputType,
        useStrictISO: a.useStrictISO,
        enableSeconds: a.enableSeconds,
        minDate: a.minDate,
        maxDate: a.maxDate,
        maxRange: a.maxRange,
        minRange: a.minRange,
        incomplete: a.incomplete,
        locale: a.locale
      },
      {
        containerRef: o,
        calendarRef: l,
        startDateInputRef: s,
        endDateInputRef: u,
        startTimeInputRef: i,
        endTimeInputRef: m
      }
    ), { setLocale: p, getPlaceholderMessage: d } = gt(a.locale);
    f.setEmitters({
      update: (F) => n("update:modelValue", F),
      change: (F) => n("change", F),
      validation: (F, x, U) => n("validation", F, x, U)
    });
    const {
      themeClasses: S,
      containerAttributes: w,
      setColor: h,
      setMode: b
    } = Fr(), $ = C(() => {
      const F = {
        start: d("range.start"),
        end: d("range.end"),
        year: d("date.year"),
        month: d("date.month"),
        day: d("date.day"),
        hour: d("time.hour"),
        minute: d("time.minute"),
        second: d("time.second")
      };
      return {
        start: a.placeholderOverrides?.start || F.start,
        end: a.placeholderOverrides?.end || F.end,
        // 時間相關
        hour: a.placeholderOverrides?.hour || F.hour,
        minute: a.placeholderOverrides?.minute || F.minute,
        second: a.placeholderOverrides?.second || F.second,
        // 日期相關
        year: a.placeholderOverrides?.year || F.year,
        month: a.placeholderOverrides?.month || F.month,
        day: a.placeholderOverrides?.day || F.day
      };
    }), c = C(() => a.dateFormat), y = C(() => ({
      ...f.mergedErrors.value,
      ...g.value
    })), D = C(() => Object.keys(E.value).length > 0);
    de(() => a.theme, (F) => {
      F && h(F);
    }, { immediate: !0 }), de(() => a.mode, (F) => {
      b(F);
    }, { immediate: !0 }), de(() => a.locale, (F) => {
      F && p(F);
    }, { immediate: !0 }), de(() => a.calendar, (F) => {
      fe.isCalendarSupported(F) ? delete g.value.calendar : g.value.calendar = "calendar.unsupported";
    }, { immediate: !0 }), Xa(() => {
      p(a.locale);
    }), e({
      // 基本操作
      reset: f.clearRange,
      validate: f.validate,
      setRange: f.setRange,
      // 聚焦方法
      focusStartDate: f.focusStartDate,
      focusEndDate: f.focusEndDate,
      // 主題控制
      setTheme: h,
      setDarkMode: () => b("dark"),
      setLightMode: () => b("light"),
      setAutoMode: () => b("auto"),
      // 錯誤相關
      getErrors: () => E.value,
      hasErrors: () => D.value
    });
    const {
      // 狀態
      showCalendar: P,
      startDateConstraintsStr: z,
      endDateConstraintsStr: J,
      shortcuts: j,
      startDateTime: X,
      endDateTime: Z,
      hasRangeValue: I,
      mergedErrors: E,
      mergedErrorParams: M,
      // 事件處理方法
      handleStartDateValidation: H,
      handleEndDateValidation: q,
      handleStartTimeValidation: ee,
      handleEndTimeValidation: me,
      handleStartDateComplete: se,
      handleEndDateComplete: R,
      handleStartTimeComplete: Y,
      handleEndTimeComplete: B,
      handleCalendarRangeSelect: te,
      handleStartNavigateToDate: Q,
      handleEndNavigateToDate: N,
      handleTimeSelect: K,
      // 操作方法
      toggleCalendar: ae,
      applyShortcut: he,
      clearRange: ye,
      focusStartDate: Me,
      focusEndDate: be
    } = f;
    return (F, x) => (A(), L(De, null, [
      _("div", er({
        class: ["date-range-wrapper relative w-full", [V(S), F.showTime ? "min-w-[300px]" : "min-w-[200px]"]]
      }, V(w), {
        ref_key: "containerRef",
        ref: o
      }), [
        _("div", {
          class: ge(["date-picker-container flex w-full items-center px-2 py-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 }]])
        }, [
          _("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: F.disabled,
            onClick: x[0] || (x[0] = //@ts-ignore
            (...U) => V(ae) && V(ae)(...U)),
            "aria-label": "選擇日期範圍"
          }, [
            _("div", {
              class: "text-center min-w-0 max-w-[130px] sm:max-w-none",
              title: $.value.start,
              "aria-label": "開始日期"
            }, [
              F.modelValue?.start ? (A(), L("span", Ms, oe(F.modelValue?.start), 1)) : (A(), L("span", Ss, oe($.value.start), 1))
            ], 8, bs),
            _("div", ws, oe(F.separator), 1),
            _("div", {
              class: "text-center min-w-0 max-w-[130px] sm:max-w-none",
              title: $.value.end,
              "aria-label": "結束日期"
            }, [
              F.modelValue?.end ? (A(), L("span", Ts, oe(F.modelValue?.end), 1)) : (A(), L("span", xs, oe($.value.end), 1))
            ], 8, ks)
          ], 8, Ds),
          _("div", {
            class: ge(["date-picker-icon-container relative group cursor-pointer flex justify-center items-center flex-shrink-0", { "cursor-not-allowed": F.disabled }])
          }, [
            _("button", {
              type: "button",
              "aria-label": "開啟日曆",
              class: ge(["date-picker-icon text-gray-400 hover:text-gray-600 transition-colors disabled:cursor-not-allowed", { "group-hover:opacity-0": V(I) && !F.disabled && F.showClearButton }]),
              disabled: F.disabled,
              onClick: x[1] || (x[1] = Se((U) => V(ae)?.(), ["stop", "prevent"]))
            }, [
              ue(Cr, { class: "h-5 w-5" })
            ], 10, Cs),
            V(I) && !F.disabled && F.showClearButton ? (A(), L("button", {
              key: 0,
              type: "button",
              "aria-label": "清除日期",
              class: "date-picker-icon absolute inset-0 text-gray-400 hover:text-red-500 opacity-0 group-hover:opacity-100",
              onClick: x[2] || (x[2] = Se(
                //@ts-ignore
                (...U) => V(ye) && V(ye)(...U),
                ["stop"]
              )),
              title: "清除日期" + (F.showTime ? "時間" : "")
            }, [
              ue(Er, { class: "h-4 w-4" })
            ], 8, Ys)) : ce("", !0)
          ], 2)
        ], 2),
        V(P) && !F.disabled ? (A(), L("div", {
          key: 0,
          ref_key: "calendarRef",
          ref: l,
          class: ge(["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: x[9] || (x[9] = Se(() => {
          }, ["stop"])),
          role: "dialog",
          "aria-modal": "true",
          "aria-label": "date-range-picker"
        }, [
          _("div", Rs, [
            F.inputEnabled && k.value === "dual" ? (A(), L("div", Es, [
              _("div", {
                "data-testid": "start-date-inputs",
                "aria-label": "開始日期輸入區域",
                onClick: x[5] || (x[5] = Se(
                  //@ts-ignore
                  (...U) => V(Me) && V(Me)(...U),
                  ["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"
              }, [
                ue(la, {
                  ref_key: "startDateInputRef",
                  ref: s,
                  modelValue: V(X).inputDateValue.value,
                  "onUpdate:modelValue": x[3] || (x[3] = (U) => V(X).inputDateValue.value = U),
                  "year-placeholder": $.value.year,
                  "month-placeholder": $.value.month,
                  "day-placeholder": $.value.day,
                  "max-date": V(z).maxDate,
                  "min-date": V(z).minDate,
                  "date-format": c.value,
                  onValidation: V(H),
                  onComplete: V(se)
                }, null, 8, ["modelValue", "year-placeholder", "month-placeholder", "day-placeholder", "max-date", "min-date", "date-format", "onValidation", "onComplete"]),
                F.showTime ? (A(), L("div", Is, [
                  ue(sa, {
                    ref_key: "startTimeInputRef",
                    ref: i,
                    modelValue: V(X).inputTimeValue.value,
                    "onUpdate:modelValue": x[4] || (x[4] = (U) => V(X).inputTimeValue.value = U),
                    "hour-placeholder": $.value.hour,
                    "minute-placeholder": $.value.minute,
                    "second-placeholder": $.value.second,
                    "enable-seconds": F.enableSeconds,
                    use24Hour: F.use24Hour,
                    locale: F.locale,
                    onValidation: V(ee),
                    onComplete: V(Y),
                    onNavigateToDate: V(Q)
                  }, null, 8, ["modelValue", "hour-placeholder", "minute-placeholder", "second-placeholder", "enable-seconds", "use24Hour", "locale", "onValidation", "onComplete", "onNavigateToDate"])
                ])) : ce("", !0)
              ]),
              _("div", {
                "data-testid": "end-date-inputs",
                "aria-label": "結束日期輸入區域",
                onClick: x[8] || (x[8] = Se(
                  //@ts-ignore
                  (...U) => V(be) && V(be)(...U),
                  ["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"
              }, [
                ue(la, {
                  ref_key: "endDateInputRef",
                  ref: u,
                  modelValue: V(Z).inputDateValue.value,
                  "onUpdate:modelValue": x[6] || (x[6] = (U) => V(Z).inputDateValue.value = U),
                  "year-placeholder": $.value.year,
                  "month-placeholder": $.value.month,
                  "day-placeholder": $.value.day,
                  "min-date": V(J).minDate,
                  "max-date": V(J).maxDate,
                  "date-format": c.value,
                  onValidation: V(q),
                  onComplete: V(R)
                }, null, 8, ["modelValue", "year-placeholder", "month-placeholder", "day-placeholder", "min-date", "max-date", "date-format", "onValidation", "onComplete"]),
                F.showTime ? (A(), L("div", Os, [
                  ue(sa, {
                    ref_key: "endTimeInputRef",
                    ref: m,
                    modelValue: V(Z).inputTimeValue.value,
                    "onUpdate:modelValue": x[7] || (x[7] = (U) => V(Z).inputTimeValue.value = U),
                    "hour-placeholder": $.value.hour,
                    "minute-placeholder": $.value.minute,
                    "second-placeholder": $.value.second,
                    "enable-seconds": F.enableSeconds,
                    use24Hour: F.use24Hour,
                    locale: F.locale,
                    onValidation: V(me),
                    onComplete: V(B),
                    onNavigateToDate: V(N)
                  }, null, 8, ["modelValue", "hour-placeholder", "minute-placeholder", "second-placeholder", "enable-seconds", "use24Hour", "locale", "onValidation", "onComplete", "onNavigateToDate"])
                ])) : ce("", !0)
              ])
            ])) : ce("", !0),
            V(j).length > 0 && F.showShortcuts ? (A(), L("div", Vs, [
              _("div", Fs, [
                (A(!0), L(De, null, $e(V(j), (U) => (A(), L("button", {
                  key: U.label,
                  type: "button",
                  "aria-label": `選擇${U.label}範圍`,
                  "data-testid": `shortcut-${U.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: (re) => V(he)(U)
                }, oe(U.label), 9, Ps))), 128)),
                pe(F.$slots, "shortcuts", {
                  applyShortcut: V(he),
                  shortcuts: V(j),
                  currentRange: F.modelValue
                })
              ])
            ])) : F.$slots.shortcuts && F.showShortcuts ? (A(), L("div", As, [
              _("div", Ls, [
                pe(F.$slots, "shortcuts", {
                  applyShortcut: V(he),
                  shortcuts: V(j),
                  currentRange: F.modelValue
                })
              ])
            ])) : ce("", !0),
            _("div", Hs, [
              ue(gs, {
                "month-display-mode": k.value,
                showTimeSelector: F.showTime,
                calendar: F.calendar,
                "range-start": V(X).internalDateTime.value,
                "range-end": V(Z).internalDateTime.value,
                "start-time-value": V(X).inputTimeValue.value,
                "end-time-value": V(Z).inputTimeValue.value,
                locale: F.locale,
                "week-starts-on": F.weekStartsOn,
                "min-date": V(ve)(F.minDate),
                "max-date": V(ve)(F.maxDate),
                "enable-seconds": F.enableSeconds,
                "use24-hour": F.use24Hour,
                onRangeSelect: V(te),
                onTimeSelect: V(K)
              }, 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)) : ce("", !0)
      ], 16),
      F.showErrorMessage && D.value ? (A(), L("div", Bs, [
        pe(F.$slots, "error", {
          errors: y.value,
          hasErrors: D.value
        }, () => [
          ue(xr, {
            errors: V(E),
            locale: F.locale,
            "use-i18n": F.useI18n,
            "custom-messages": F.customErrorMessages,
            errorParams: V(M)
          }, ct({ _: 2 }, [
            $e(F.$slots, (U, re) => ({
              name: re,
              fn: dt((Re) => [
                pe(F.$slots, re, ft(mt(Re)))
              ])
            }))
          ]), 1032, ["errors", "locale", "use-i18n", "custom-messages", "errorParams"])
        ])
      ])) : ce("", !0)
    ], 64));
  }
}), ai = {
  install(r) {
    r.component("VueDatepicker", Ga), r.component("DatePicker", Ga), r.component("DateRange", qs);
  }
};
export {
  Ga as DatePicker,
  qs as DateRange,
  kr as RocFormatPlugin,
  ai as VueDatepicker,
  ai as default
};