@bereasoftware/time-guard 2.4.0 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,45 +1,52 @@
1
- /*! time-guard v2.4.0 | (c) 2026 Berea-Soft | MIT License | https://github.com/Berea-Soft/time-guard */
1
+ /*! time-guard v2.4.1 | (c) 2026 Berea-Soft | MIT License | https://github.com/Berea-Soft/time-guard */
2
2
  import "@js-temporal/polyfill";
3
3
  //#region src/adapters/temporal.adapter.ts
4
- var e = null;
5
- function t() {
4
+ var e = null, t = !1;
5
+ function n() {
6
6
  if (e) return e;
7
- let t = globalThis.Temporal;
8
- if (!t) throw Error("Temporal API not loaded. Make sure @js-temporal/polyfill is imported in your app.");
9
- return e = t, t;
7
+ let n = globalThis.Temporal;
8
+ if (!n) {
9
+ if (!t && typeof globalThis.require == "function") try {
10
+ globalThis.require("@js-temporal/polyfill"), t = !0;
11
+ let n = globalThis.Temporal;
12
+ if (n) return e = n, n;
13
+ } catch {}
14
+ throw Error("Temporal API not loaded. Make sure @js-temporal/polyfill is imported in your app.");
15
+ }
16
+ return e = n, n;
10
17
  }
11
- var n = class {
18
+ var r = class {
12
19
  static parseToPlainDateTime(e) {
13
- let n = t();
20
+ let t = n();
14
21
  return this.isPlainDateTime(e) ? e : this.isZonedDateTime(e) ? e.toPlainDateTime() : this.isPlainDate(e) ? e.toPlainDateTime({
15
22
  hour: 0,
16
23
  minute: 0,
17
24
  second: 0,
18
25
  millisecond: 0
19
- }) : this.isPlainTime(e) ? n.Now.plainDateTimeISO().with(e) : typeof e == "object" && e && "getTime" in e && typeof e.getTime == "function" ? this.fromDate(e) : typeof e == "number" ? this.fromUnix(e) : typeof e == "string" ? this.parseISOString(e) : typeof e == "object" && e ? this.fromObject(e) : n.Now.plainDateTimeISO();
26
+ }) : this.isPlainTime(e) ? t.Now.plainDateTimeISO().with(e) : typeof e == "object" && e && "getTime" in e && typeof e.getTime == "function" ? this.fromDate(e) : typeof e == "number" ? this.fromUnix(e) : typeof e == "string" ? this.parseISOString(e) : typeof e == "object" && e ? this.fromObject(e) : t.Now.plainDateTimeISO();
20
27
  }
21
28
  static fromDate(e) {
22
- let n = t(), [r, i] = e.toISOString().split("T");
23
- return n.PlainDateTime.from(r + "T" + i.slice(0, -1));
29
+ let t = n(), [r, i] = e.toISOString().split("T");
30
+ return t.PlainDateTime.from(r + "T" + i.slice(0, -1));
24
31
  }
25
32
  static fromUnix(e) {
26
33
  return this.fromDate(new Date(e));
27
34
  }
28
35
  static parseISOString(e) {
29
- let n = t();
36
+ let t = n();
30
37
  try {
31
38
  if (e.includes("T") || / \d{2}:\d{2}/.test(e)) {
32
- let t = e.replace(" ", "T");
33
- return n.PlainDateTime.from(t);
39
+ let n = e.replace(" ", "T");
40
+ return t.PlainDateTime.from(n);
34
41
  }
35
- return n.PlainDate.from(e).toPlainDateTime({ hour: 0 });
42
+ return t.PlainDate.from(e).toPlainDateTime({ hour: 0 });
36
43
  } catch {
37
- return n.Now.plainDateTimeISO();
44
+ return t.Now.plainDateTimeISO();
38
45
  }
39
46
  }
40
47
  static fromObject(e) {
41
- let n = t(), r = e.year || n.Now.plainDateISO().year, i = e.month || 1, a = e.day || 1, o = e.hour || 0, s = e.minute || 0, c = e.second || 0, l = e.millisecond || 0;
42
- return n.PlainDateTime.from({
48
+ let t = n(), r = e.year || t.Now.plainDateISO().year, i = e.month || 1, a = e.day || 1, o = e.hour || 0, s = e.minute || 0, c = e.second || 0, l = e.millisecond || 0;
49
+ return t.PlainDateTime.from({
43
50
  year: r,
44
51
  month: i,
45
52
  day: a,
@@ -76,18 +83,18 @@ var n = class {
76
83
  return typeof e == "object" && !!e && "hour" in e && !("year" in e);
77
84
  }
78
85
  static now() {
79
- return t().Now.plainDateTimeISO();
86
+ return n().Now.plainDateTimeISO();
80
87
  }
81
88
  static nowInTimezone(e) {
82
- return t().Now.zonedDateTimeISO(e);
89
+ return n().Now.zonedDateTimeISO(e);
83
90
  }
84
- static compare(e, n) {
85
- let r = t();
86
- if (r.PlainDateTime && typeof r.PlainDateTime.compare == "function") return r.PlainDateTime.compare(e, n);
87
- let i = e.toString(), a = n.toString();
91
+ static compare(e, t) {
92
+ let r = n();
93
+ if (r.PlainDateTime && typeof r.PlainDateTime.compare == "function") return r.PlainDateTime.compare(e, t);
94
+ let i = e.toString(), a = t.toString();
88
95
  return i < a ? -1 : +(i > a);
89
96
  }
90
- }, r = {
97
+ }, i = {
91
98
  name: "en",
92
99
  months: [
93
100
  "January",
@@ -155,7 +162,7 @@ var n = class {
155
162
  datetime: "YYYY-MM-DD HH:mm:ss",
156
163
  rfc2822: "ddd, DD MMM YYYY HH:mm:ss Z"
157
164
  }
158
- }, i = {
165
+ }, a = {
159
166
  name: "es",
160
167
  months: [
161
168
  "Enero",
@@ -223,7 +230,7 @@ var n = class {
223
230
  datetime: "DD/MM/YYYY HH:mm:ss",
224
231
  rfc2822: "ddd, DD MMM YYYY HH:mm:ss Z"
225
232
  }
226
- }, a = class e {
233
+ }, o = class e {
227
234
  static instance;
228
235
  locales = /* @__PURE__ */ new Map();
229
236
  currentLocale = "en";
@@ -231,14 +238,14 @@ var n = class {
231
238
  return e.instance ||= new e(), e.instance;
232
239
  }
233
240
  constructor() {
234
- this.locales.set("en", r), this.locales.set("es", i);
241
+ this.locales.set("en", i), this.locales.set("es", a);
235
242
  }
236
243
  setLocale(e, t) {
237
244
  t && this.locales.set(e.toLowerCase(), t), this.currentLocale = e.toLowerCase();
238
245
  }
239
246
  getLocale(e) {
240
247
  let t = (e || this.currentLocale).toLowerCase();
241
- return this.locales.get(t) || this.locales.get("en") || r;
248
+ return this.locales.get(t) || this.locales.get("en") || i;
242
249
  }
243
250
  listLocales() {
244
251
  return Array.from(this.locales.keys());
@@ -251,10 +258,10 @@ var n = class {
251
258
  this.locales.set(e.toLowerCase(), t);
252
259
  });
253
260
  }
254
- }, o = class {
261
+ }, s = class {
255
262
  localeManager;
256
263
  constructor() {
257
- this.localeManager = a.getInstance();
264
+ this.localeManager = o.getInstance();
258
265
  }
259
266
  format(e, t, n) {
260
267
  let r = this.localeManager.getLocale(n), i = [], a = t.replace(/\[([^\]]+)\]/g, (e, t) => (i.push(t), `~${i.length - 1}~`));
@@ -313,7 +320,7 @@ var n = class {
313
320
  let r = this.getPreset(t);
314
321
  return this.format(e, r, n);
315
322
  }
316
- }, s = {
323
+ }, c = {
317
324
  en: {
318
325
  year: ["year", "years"],
319
326
  month: ["month", "months"],
@@ -344,7 +351,7 @@ var n = class {
344
351
  second: ["seconde", "secondes"],
345
352
  millisecond: ["milliseconde", "millisecondes"]
346
353
  }
347
- }, c = {
354
+ }, l = {
348
355
  en: "and",
349
356
  es: "y",
350
357
  fr: "et",
@@ -352,19 +359,19 @@ var n = class {
352
359
  it: "e",
353
360
  pt: "e"
354
361
  };
355
- function l(e, t, n) {
356
- return ((s[t] || s.en)[e] || [e, e + "s"])[n === 1 ? 0 : 1];
362
+ function u(e, t, n) {
363
+ return ((c[t] || c.en)[e] || [e, e + "s"])[n === 1 ? 0 : 1];
357
364
  }
358
- function u(e) {
359
- return c[e] || "and";
365
+ function d(e) {
366
+ return l[e] || "and";
360
367
  }
361
- function d(e, t) {
368
+ function f(e, t) {
362
369
  if (e.length === 0) return "";
363
370
  if (e.length === 1) return e[0];
364
- let n = u(t);
371
+ let n = d(t);
365
372
  return e.length === 2 ? `${e[0]} ${n} ${e[1]}` : e.slice(0, -1).join(", ") + ` ${n} ${e[e.length - 1]}`;
366
373
  }
367
- function f(e) {
374
+ function p(e) {
368
375
  return {
369
376
  en: "0 seconds",
370
377
  es: "0 segundos",
@@ -373,7 +380,7 @@ function f(e) {
373
380
  }
374
381
  //#endregion
375
382
  //#region src/plugins/manager.ts
376
- var p = class e {
383
+ var m = class e {
377
384
  static instance;
378
385
  plugins = /* @__PURE__ */ new Map();
379
386
  static getInstance() {
@@ -413,7 +420,7 @@ var p = class e {
413
420
  throw console.error(`Failed to register plugin "${e.name}":`, t), Error(`Failed to register plugin "${e.name}": ${t instanceof Error ? t.message : String(t)}`);
414
421
  }
415
422
  }
416
- }, m = " days", h = 1e3, g = h * 60, _ = g * 60, v = _ * 24, y = v * 7, b = 365.25, x = b / 12 * v, S = b * v, C = class {
423
+ }, h = " days", g = 1e3, _ = g * 60, v = _ * 60, y = v * 24, b = y * 7, x = 365.25, S = x / 12 * y, C = x * y, w = class {
417
424
  _value;
418
425
  _tg1;
419
426
  _tg2;
@@ -431,9 +438,9 @@ var p = class e {
431
438
  }
432
439
  format(e) {
433
440
  let t = e || this._locale;
434
- if (!this._breakdownData) return `${Math.abs(this._tg1.diff(this._tg2, "day"))}${m}`;
441
+ if (!this._breakdownData) return `${Math.abs(this._tg1.diff(this._tg2, "day"))}${h}`;
435
442
  let n = [], r = this._breakdownData;
436
- return r.years !== 0 && n.push(`${r.years} ${l("year", t, r.years)}`), r.months !== 0 && n.push(`${r.months} ${l("month", t, r.months)}`), r.weeks !== 0 && n.push(`${r.weeks} ${l("week", t, r.weeks)}`), r.days !== 0 && n.push(`${r.days} ${l("day", t, r.days)}`), r.hours !== 0 && n.push(`${r.hours} ${l("hour", t, r.hours)}`), r.minutes !== 0 && n.push(`${r.minutes} ${l("minute", t, r.minutes)}`), r.seconds !== 0 && n.push(`${r.seconds} ${l("second", t, r.seconds)}`), n.length === 0 ? f(t) : d(n, t);
443
+ return r.years !== 0 && n.push(`${r.years} ${u("year", t, r.years)}`), r.months !== 0 && n.push(`${r.months} ${u("month", t, r.months)}`), r.weeks !== 0 && n.push(`${r.weeks} ${u("week", t, r.weeks)}`), r.days !== 0 && n.push(`${r.days} ${u("day", t, r.days)}`), r.hours !== 0 && n.push(`${r.hours} ${u("hour", t, r.hours)}`), r.minutes !== 0 && n.push(`${r.minutes} ${u("minute", t, r.minutes)}`), r.seconds !== 0 && n.push(`${r.seconds} ${u("second", t, r.seconds)}`), n.length === 0 ? p(t) : f(n, t);
437
444
  }
438
445
  getMode() {
439
446
  return this._mode;
@@ -447,7 +454,7 @@ var p = class e {
447
454
  toJSON() {
448
455
  return this._value;
449
456
  }
450
- }, w = class {
457
+ }, T = class {
451
458
  years;
452
459
  months;
453
460
  weeks;
@@ -513,22 +520,22 @@ var p = class e {
513
520
  return `${e.value} ${this.pluralizeUnit(e.unit, e.value, t)}`;
514
521
  }
515
522
  }
516
- return d(i.map((e) => {
517
- let n = l(e.unit, t, e.value);
523
+ return f(i.map((e) => {
524
+ let n = u(e.unit, t, e.value);
518
525
  return `${e.value} ${n}`;
519
526
  }), t);
520
527
  }
521
528
  total(e) {
522
529
  let t = 0;
523
- switch (t += this.years * S, t += this.months * x, t += this.weeks * y, t += this.days * v, t += this.hours * _, t += this.minutes * g, t += this.seconds * h, t += this.milliseconds, e) {
530
+ switch (t += this.years * C, t += this.months * S, t += this.weeks * b, t += this.days * y, t += this.hours * v, t += this.minutes * _, t += this.seconds * g, t += this.milliseconds, e) {
524
531
  case "millisecond": return t;
525
- case "second": return t / h;
526
- case "minute": return t / g;
527
- case "hour": return t / _;
528
- case "day": return t / v;
529
- case "week": return t / y;
530
- case "month": return t / x;
531
- case "year": return t / S;
532
+ case "second": return t / g;
533
+ case "minute": return t / _;
534
+ case "hour": return t / v;
535
+ case "day": return t / y;
536
+ case "week": return t / b;
537
+ case "month": return t / S;
538
+ case "year": return t / C;
532
539
  case "microsecond": return t * 1e3;
533
540
  case "nanosecond": return t * 1e6;
534
541
  default: throw Error(`Unsupported unit: ${e}`);
@@ -594,16 +601,16 @@ var p = class e {
594
601
  return e.push(`Total: ${t || "0"}`), e;
595
602
  }
596
603
  pluralizeUnit(e, t, n) {
597
- return l(e, n, t);
604
+ return u(e, n, t);
598
605
  }
599
- }, T = class {
606
+ }, E = class {
600
607
  _start;
601
608
  _end;
602
609
  constructor(e, t) {
603
610
  this._start = e, this._end = t;
604
611
  }
605
612
  toDuration() {
606
- return E.between(this._start, this._end);
613
+ return D.between(this._start, this._end);
607
614
  }
608
615
  inMonths() {
609
616
  return this.toDuration().total("month");
@@ -614,7 +621,7 @@ var p = class e {
614
621
  in(e) {
615
622
  return this.toDuration().total(e);
616
623
  }
617
- }, E = class e {
624
+ }, D = class e {
618
625
  temporal;
619
626
  config;
620
627
  formatterInstance;
@@ -644,11 +651,11 @@ var p = class e {
644
651
  };
645
652
  }
646
653
  constructor(e, t) {
647
- if (this.formatterInstance = new o(), this.config = {
654
+ if (this.formatterInstance = new s(), this.config = {
648
655
  locale: t?.locale || "en",
649
656
  timezone: t?.timezone || "UTC",
650
657
  strict: t?.strict ?? !1
651
- }, this.temporal = n.parseToPlainDateTime(e), this.config.timezone && this.config.timezone !== "UTC") try {
658
+ }, this.temporal = r.parseToPlainDateTime(e), this.config.timezone && this.config.timezone !== "UTC") try {
652
659
  this.temporal = this.temporal.toZonedDateTime(this.config.timezone);
653
660
  } catch {}
654
661
  }
@@ -663,23 +670,23 @@ var p = class e {
663
670
  return r.temporal = t, r;
664
671
  }
665
672
  static between(e, t) {
666
- let r = n.toPlainDateTime(e.temporal), i = n.toPlainDateTime(t.temporal), [a, o] = n.compare(r, i) <= 0 ? [e, t] : [t, e];
673
+ let n = r.toPlainDateTime(e.temporal), i = r.toPlainDateTime(t.temporal), [a, o] = r.compare(n, i) <= 0 ? [e, t] : [t, e];
667
674
  return a.until(o);
668
675
  }
669
676
  static range(t, n) {
670
- return new T(t instanceof e ? t : new e(t), n instanceof e ? n : new e(n));
677
+ return new E(t instanceof e ? t : new e(t), n instanceof e ? n : new e(n));
671
678
  }
672
679
  toTemporal() {
673
680
  return this.temporal;
674
681
  }
675
682
  toDate() {
676
- return n.toDate(this.temporal);
683
+ return r.toDate(this.temporal);
677
684
  }
678
685
  toISOString() {
679
- return n.toISOString(this.temporal);
686
+ return r.toISOString(this.temporal);
680
687
  }
681
688
  valueOf() {
682
- return n.toUnix(this.temporal);
689
+ return r.toUnix(this.temporal);
683
690
  }
684
691
  unix() {
685
692
  return Math.floor(this.valueOf() / 1e3);
@@ -700,12 +707,12 @@ var p = class e {
700
707
  let t = this.clone();
701
708
  t.config.timezone = e;
702
709
  try {
703
- t.temporal = n.toPlainDateTime(t.temporal).toZonedDateTime(e);
710
+ t.temporal = r.toPlainDateTime(t.temporal).toZonedDateTime(e);
704
711
  } catch {}
705
712
  return t;
706
713
  }
707
714
  format(e) {
708
- let t = n.toPlainDateTime(this.temporal), r = [
715
+ let t = r.toPlainDateTime(this.temporal), n = [
709
716
  "iso",
710
717
  "date",
711
718
  "time",
@@ -714,10 +721,10 @@ var p = class e {
714
721
  "rfc3339",
715
722
  "utc"
716
723
  ].includes(e) ? this.formatterInstance.getPreset(e) : e;
717
- return this.formatterInstance.format(t, r, this.config.locale);
724
+ return this.formatterInstance.format(t, n, this.config.locale);
718
725
  }
719
726
  get(e) {
720
- let t = n.toPlainDateTime(this.temporal);
727
+ let t = r.toPlainDateTime(this.temporal);
721
728
  return e === "week" ? t.weekOfYear : t[{
722
729
  year: "year",
723
730
  month: "month",
@@ -732,10 +739,10 @@ var p = class e {
732
739
  }[e]];
733
740
  }
734
741
  add(t) {
735
- let r = n.toPlainDateTime(this.temporal), i = {};
742
+ let n = r.toPlainDateTime(this.temporal), i = {};
736
743
  return Object.entries(t).forEach(([e, t]) => {
737
744
  t !== void 0 && t !== 0 && (i[e + "s"] = t);
738
- }), r = r.add(i), e.fromTemporal(r, this.config);
745
+ }), n = n.add(i), e.fromTemporal(n, this.config);
739
746
  }
740
747
  subtract(e) {
741
748
  let t = {};
@@ -744,7 +751,7 @@ var p = class e {
744
751
  }), this.add(t);
745
752
  }
746
753
  diff(e, t) {
747
- let r = n.toPlainDateTime(this.temporal), i = n.toPlainDateTime(e.temporal), a = {
754
+ let n = r.toPlainDateTime(this.temporal), i = r.toPlainDateTime(e.temporal), a = {
748
755
  year: "years",
749
756
  month: "months",
750
757
  week: "weeks",
@@ -757,23 +764,23 @@ var p = class e {
757
764
  nanosecond: "nanoseconds"
758
765
  };
759
766
  if (typeof t == "string") {
760
- let e = t, n = a[e], o = r.since(i, { smallestUnit: e });
761
- return Math.round(o[n] || 0);
767
+ let e = t, r = a[e], o = n.since(i, { smallestUnit: e });
768
+ return Math.round(o[r] || 0);
762
769
  }
763
770
  let o = t || {}, s = o.mode || "exact", c = o.unit || "millisecond", l = o.locale || this.config.locale;
764
771
  if (s === "exact") {
765
- let n = a[c], o = r.since(i, { smallestUnit: c }), u = Math.round(o[n] || 0);
772
+ let r = a[c], o = n.since(i, { smallestUnit: c }), u = Math.round(o[r] || 0);
766
773
  if (t === void 0 || typeof t == "object") {
767
774
  let t = (o.years || 0) * 365.25 * 24 * 60 * 60 * 1e3 + (o.months || 0) * 30.44 * 24 * 60 * 60 * 1e3 + (o.weeks || 0) * 7 * 24 * 60 * 60 * 1e3 + (o.days || 0) * 24 * 60 * 60 * 1e3 + (o.hours || 0) * 60 * 60 * 1e3 + (o.minutes || 0) * 60 * 1e3 + (o.seconds || 0) * 1e3 + (o.milliseconds || 0);
768
- return new C(Math.round(t), this, e, s, void 0, l);
775
+ return new w(Math.round(t), this, e, s, void 0, l);
769
776
  }
770
777
  return u;
771
778
  }
772
779
  if (s === "calendar") {
773
- let t = r.since(i, {
780
+ let t = n.since(i, {
774
781
  largestUnit: "month",
775
782
  smallestUnit: "millisecond"
776
- }), n = {
783
+ }), r = {
777
784
  years: Math.floor(t.years || 0),
778
785
  months: Math.floor(t.months || 0),
779
786
  weeks: Math.floor(t.weeks || 0),
@@ -783,46 +790,46 @@ var p = class e {
783
790
  seconds: Math.floor(t.seconds || 0),
784
791
  milliseconds: Math.floor(t.milliseconds || 0)
785
792
  }, a = (t.years || 0) * 365.25 * 24 * 60 * 60 * 1e3 + (t.months || 0) * 30.44 * 24 * 60 * 60 * 1e3 + (t.weeks || 0) * 7 * 24 * 60 * 60 * 1e3 + (t.days || 0) * 24 * 60 * 60 * 1e3 + (t.hours || 0) * 60 * 60 * 1e3 + (t.minutes || 0) * 60 * 1e3 + (t.seconds || 0) * 1e3 + (t.milliseconds || 0);
786
- return new C(Math.round(a), this, e, s, n, l);
793
+ return new w(Math.round(a), this, e, s, r, l);
787
794
  }
788
- let u = r.since(i, { smallestUnit: "millisecond" }), d = (u.years || 0) * 365.25 * 24 * 60 * 60 * 1e3 + (u.months || 0) * 30.44 * 24 * 60 * 60 * 1e3 + (u.weeks || 0) * 7 * 24 * 60 * 60 * 1e3 + (u.days || 0) * 24 * 60 * 60 * 1e3 + (u.hours || 0) * 60 * 60 * 1e3 + (u.minutes || 0) * 60 * 1e3 + (u.seconds || 0) * 1e3 + (u.milliseconds || 0);
789
- return new C(Math.round(d), this, e, s, void 0, l);
795
+ let u = n.since(i, { smallestUnit: "millisecond" }), d = (u.years || 0) * 365.25 * 24 * 60 * 60 * 1e3 + (u.months || 0) * 30.44 * 24 * 60 * 60 * 1e3 + (u.weeks || 0) * 7 * 24 * 60 * 60 * 1e3 + (u.days || 0) * 24 * 60 * 60 * 1e3 + (u.hours || 0) * 60 * 60 * 1e3 + (u.minutes || 0) * 60 * 1e3 + (u.seconds || 0) * 1e3 + (u.milliseconds || 0);
796
+ return new w(Math.round(d), this, e, s, void 0, l);
790
797
  }
791
798
  isBefore(e) {
792
- let t = n.toPlainDateTime(this.temporal), r = n.toPlainDateTime(e.temporal);
793
- return n.compare(t, r) < 0;
799
+ let t = r.toPlainDateTime(this.temporal), n = r.toPlainDateTime(e.temporal);
800
+ return r.compare(t, n) < 0;
794
801
  }
795
802
  isAfter(e) {
796
- let t = n.toPlainDateTime(this.temporal), r = n.toPlainDateTime(e.temporal);
797
- return n.compare(t, r) > 0;
803
+ let t = r.toPlainDateTime(this.temporal), n = r.toPlainDateTime(e.temporal);
804
+ return r.compare(t, n) > 0;
798
805
  }
799
806
  isSame(e, t) {
800
- if (!t) return n.compare(n.toPlainDateTime(this.temporal), n.toPlainDateTime(e.temporal)) === 0;
801
- let r = n.toPlainDateTime(this.temporal), i = n.toPlainDateTime(e.temporal);
807
+ if (!t) return r.compare(r.toPlainDateTime(this.temporal), r.toPlainDateTime(e.temporal)) === 0;
808
+ let n = r.toPlainDateTime(this.temporal), i = r.toPlainDateTime(e.temporal);
802
809
  switch (t) {
803
- case "year": return r.year === i.year;
804
- case "month": return r.year === i.year && r.month === i.month;
805
- case "day": return r.year === i.year && r.month === i.month && r.day === i.day;
806
- case "hour": return r.year === i.year && r.month === i.month && r.day === i.day && r.hour === i.hour;
807
- case "minute": return r.year === i.year && r.month === i.month && r.day === i.day && r.hour === i.hour && r.minute === i.minute;
808
- case "second": return r.year === i.year && r.month === i.month && r.day === i.day && r.hour === i.hour && r.minute === i.minute && r.second === i.second;
810
+ case "year": return n.year === i.year;
811
+ case "month": return n.year === i.year && n.month === i.month;
812
+ case "day": return n.year === i.year && n.month === i.month && n.day === i.day;
813
+ case "hour": return n.year === i.year && n.month === i.month && n.day === i.day && n.hour === i.hour;
814
+ case "minute": return n.year === i.year && n.month === i.month && n.day === i.day && n.hour === i.hour && n.minute === i.minute;
815
+ case "second": return n.year === i.year && n.month === i.month && n.day === i.day && n.hour === i.hour && n.minute === i.minute && n.second === i.second;
809
816
  default: return !1;
810
817
  }
811
818
  }
812
- isBetween(e, t, r, i = "[]") {
813
- let a = n.toPlainDateTime(this.temporal), o = n.toPlainDateTime(e.temporal), s = n.toPlainDateTime(t.temporal), c = !0, l = !0;
814
- if (r) {
815
- let e = this.clone().startOf(r), t = this.clone().endOf(r), i = n.toPlainDateTime(e.temporal), a = n.toPlainDateTime(t.temporal);
816
- c = n.compare(i, o) >= 0, l = n.compare(a, s) <= 0;
817
- } else c = n.compare(a, o) >= 0, l = n.compare(a, s) <= 0;
819
+ isBetween(e, t, n, i = "[]") {
820
+ let a = r.toPlainDateTime(this.temporal), o = r.toPlainDateTime(e.temporal), s = r.toPlainDateTime(t.temporal), c = !0, l = !0;
821
+ if (n) {
822
+ let e = this.clone().startOf(n), t = this.clone().endOf(n), i = r.toPlainDateTime(e.temporal), a = r.toPlainDateTime(t.temporal);
823
+ c = r.compare(i, o) >= 0, l = r.compare(a, s) <= 0;
824
+ } else c = r.compare(a, o) >= 0, l = r.compare(a, s) <= 0;
818
825
  let u = i[0] === "[", d = i[1] === "]";
819
- return (u ? c : n.compare(a, o) > 0) && (d ? l : n.compare(a, s) < 0);
826
+ return (u ? c : r.compare(a, o) > 0) && (d ? l : r.compare(a, s) < 0);
820
827
  }
821
828
  clone() {
822
829
  return new e(this.toDate(), this.config);
823
830
  }
824
831
  startOf(t) {
825
- let r = n.toPlainDateTime(this.temporal), i = {};
832
+ let n = r.toPlainDateTime(this.temporal), i = {};
826
833
  switch (t) {
827
834
  case "year":
828
835
  i.month = 1, i.day = 1, i.hour = 0, i.minute = 0, i.second = 0, i.millisecond = 0;
@@ -844,63 +851,63 @@ var p = class e {
844
851
  i.millisecond = 0;
845
852
  break;
846
853
  }
847
- let a = r.with(i);
854
+ let a = n.with(i);
848
855
  return e.fromTemporal(a, this.config);
849
856
  }
850
857
  endOf(e) {
851
858
  return this.startOf(e).add({ [e]: 1 }).subtract({ millisecond: 1 });
852
859
  }
853
860
  set(t) {
854
- let r = n.toPlainDateTime(this.temporal).with(t);
855
- return e.fromTemporal(r, this.config);
861
+ let n = r.toPlainDateTime(this.temporal).with(t);
862
+ return e.fromTemporal(n, this.config);
856
863
  }
857
864
  year() {
858
- return n.toPlainDateTime(this.temporal).year;
865
+ return r.toPlainDateTime(this.temporal).year;
859
866
  }
860
867
  month() {
861
- return n.toPlainDateTime(this.temporal).month;
868
+ return r.toPlainDateTime(this.temporal).month;
862
869
  }
863
870
  day() {
864
- return n.toPlainDateTime(this.temporal).day;
871
+ return r.toPlainDateTime(this.temporal).day;
865
872
  }
866
873
  hour() {
867
- return n.toPlainDateTime(this.temporal).hour;
874
+ return r.toPlainDateTime(this.temporal).hour;
868
875
  }
869
876
  minute() {
870
- return n.toPlainDateTime(this.temporal).minute;
877
+ return r.toPlainDateTime(this.temporal).minute;
871
878
  }
872
879
  second() {
873
- return n.toPlainDateTime(this.temporal).second;
880
+ return r.toPlainDateTime(this.temporal).second;
874
881
  }
875
882
  millisecond() {
876
- return n.toPlainDateTime(this.temporal).millisecond;
883
+ return r.toPlainDateTime(this.temporal).millisecond;
877
884
  }
878
885
  dayOfWeek() {
879
- return n.toPlainDateTime(this.temporal).dayOfWeek;
886
+ return r.toPlainDateTime(this.temporal).dayOfWeek;
880
887
  }
881
888
  dayOfYear() {
882
- return n.toPlainDateTime(this.temporal).dayOfYear;
889
+ return r.toPlainDateTime(this.temporal).dayOfYear;
883
890
  }
884
891
  weekOfYear() {
885
- return n.toPlainDateTime(this.temporal).weekOfYear;
892
+ return r.toPlainDateTime(this.temporal).weekOfYear;
886
893
  }
887
894
  daysInMonth() {
888
- return n.toPlainDateTime(this.temporal).add({ months: 1 }).with({ day: 1 }).subtract({ days: 1 }).day;
895
+ return r.toPlainDateTime(this.temporal).add({ months: 1 }).with({ day: 1 }).subtract({ days: 1 }).day;
889
896
  }
890
897
  daysInYear() {
891
898
  let t = this.year();
892
899
  return e.isLeapYearValue(t) ? 366 : 365;
893
900
  }
894
901
  inLeapYear() {
895
- let t = n.toPlainDateTime(this.temporal);
902
+ let t = r.toPlainDateTime(this.temporal);
896
903
  return e.isLeapYearValue(t.year);
897
904
  }
898
- until(t, r) {
899
- let i = n.toPlainDateTime(this.temporal), a = n.toPlainDateTime(t.temporal), o = performance.now();
905
+ until(t, n) {
906
+ let i = r.toPlainDateTime(this.temporal), a = r.toPlainDateTime(t.temporal), o = performance.now();
900
907
  try {
901
908
  let t = {};
902
- r?.largestUnit && (t.largestUnit = r.largestUnit), r?.smallestUnit && (t.smallestUnit = r.smallestUnit);
903
- let n = a.since(i, Object.keys(t).length > 0 ? t : void 0), s = e.toDurationParts(n), c = i.year, l = a.year, u = [];
909
+ n?.largestUnit && (t.largestUnit = n.largestUnit), n?.smallestUnit && (t.smallestUnit = n.smallestUnit);
910
+ let r = a.since(i, Object.keys(t).length > 0 ? t : void 0), s = e.toDurationParts(r), c = i.year, l = a.year, u = [];
904
911
  for (let t = c; t <= l; t++) {
905
912
  let n = e.isLeapYearValue(t);
906
913
  u.push({
@@ -910,7 +917,7 @@ var p = class e {
910
917
  });
911
918
  }
912
919
  let d = this.generateUntilSteps(i, a, s, u), f = performance.now() - o;
913
- return new w(s, this.config.locale, {
920
+ return new T(s, this.config.locale, {
914
921
  startDate: i.toString(),
915
922
  endDate: a.toString(),
916
923
  steps: d,
@@ -919,7 +926,7 @@ var p = class e {
919
926
  calculationTimeMs: f
920
927
  });
921
928
  } catch {
922
- return new w(e.ZERO_DURATION, this.config.locale, {
929
+ return new T(e.ZERO_DURATION, this.config.locale, {
923
930
  startDate: i.toString(),
924
931
  endDate: a.toString(),
925
932
  steps: ["Calculation failed, returning zero duration"],
@@ -940,7 +947,7 @@ var p = class e {
940
947
  return a.push(`Total: approximately ${s.toFixed(2)} days`), a;
941
948
  }
942
949
  round(e = {}) {
943
- let { smallestUnit: t = "millisecond", roundingMode: r = "halfExpand" } = e, i = n.toPlainDateTime(this.temporal), a = {
950
+ let { smallestUnit: t = "millisecond", roundingMode: n = "halfExpand" } = e, i = r.toPlainDateTime(this.temporal), a = {
944
951
  year: i.year,
945
952
  month: i.month,
946
953
  day: i.day,
@@ -980,12 +987,12 @@ var p = class e {
980
987
  case "expand": return t > 0;
981
988
  default: return t >= 5;
982
989
  }
983
- })(r, a[o[s + 1]]) && (u += 1), c[l] = u;
990
+ })(n, a[o[s + 1]]) && (u += 1), c[l] = u;
984
991
  for (let e = s + 1; e < o.length; e++) c[o[e]] = 0;
985
992
  return this.set(c);
986
993
  }
987
994
  toPlainDate() {
988
- let e = n.toPlainDateTime(this.temporal);
995
+ let e = r.toPlainDateTime(this.temporal);
989
996
  return {
990
997
  year: e.year,
991
998
  month: e.month,
@@ -994,7 +1001,7 @@ var p = class e {
994
1001
  };
995
1002
  }
996
1003
  toPlainTime() {
997
- let e = n.toPlainDateTime(this.temporal);
1004
+ let e = r.toPlainDateTime(this.temporal);
998
1005
  return {
999
1006
  hour: e.hour,
1000
1007
  minute: e.minute,
@@ -1032,12 +1039,12 @@ var p = class e {
1032
1039
  endOfDay() {
1033
1040
  return this.endOf("day");
1034
1041
  }
1035
- since(t, r) {
1036
- let i = n.toPlainDateTime(this.temporal), a = n.toPlainDateTime(t.temporal), o = performance.now();
1042
+ since(t, n) {
1043
+ let i = r.toPlainDateTime(this.temporal), a = r.toPlainDateTime(t.temporal), o = performance.now();
1037
1044
  try {
1038
1045
  let t = {};
1039
- r?.largestUnit && (t.largestUnit = r.largestUnit), r?.smallestUnit && (t.smallestUnit = r.smallestUnit);
1040
- let n = i.since(a, Object.keys(t).length > 0 ? t : void 0), s = e.toDurationParts(n), c = a.year, l = i.year, u = [];
1046
+ n?.largestUnit && (t.largestUnit = n.largestUnit), n?.smallestUnit && (t.smallestUnit = n.smallestUnit);
1047
+ let r = i.since(a, Object.keys(t).length > 0 ? t : void 0), s = e.toDurationParts(r), c = a.year, l = i.year, u = [];
1041
1048
  for (let t = c; t <= l; t++) {
1042
1049
  let n = e.isLeapYearValue(t);
1043
1050
  u.push({
@@ -1047,7 +1054,7 @@ var p = class e {
1047
1054
  });
1048
1055
  }
1049
1056
  let d = this.generateUntilSteps(a, i, s, u), f = performance.now() - o;
1050
- return new w(s, this.config.locale, {
1057
+ return new T(s, this.config.locale, {
1051
1058
  startDate: a.toString(),
1052
1059
  endDate: i.toString(),
1053
1060
  steps: d,
@@ -1056,7 +1063,7 @@ var p = class e {
1056
1063
  calculationTimeMs: f
1057
1064
  });
1058
1065
  } catch {
1059
- return new w(e.ZERO_DURATION, this.config.locale, {
1066
+ return new T(e.ZERO_DURATION, this.config.locale, {
1060
1067
  startDate: a.toString(),
1061
1068
  endDate: i.toString(),
1062
1069
  steps: ["Calculation failed, returning zero duration"],
@@ -1087,7 +1094,7 @@ var p = class e {
1087
1094
  isYesterday() {
1088
1095
  return this.isSame(e.now().subtract({ day: 1 }), "day");
1089
1096
  }
1090
- }, D = {
1097
+ }, O = {
1091
1098
  en: {
1092
1099
  name: "en",
1093
1100
  months: [
@@ -1364,7 +1371,7 @@ var p = class e {
1364
1371
  rfc2822: "ddd, DD MMM YYYY HH:mm:ss Z"
1365
1372
  }
1366
1373
  }
1367
- }, O = {
1374
+ }, k = {
1368
1375
  es: {
1369
1376
  name: "es",
1370
1377
  months: [
@@ -1572,7 +1579,7 @@ var p = class e {
1572
1579
  rfc2822: "ddd, DD MMM YYYY HH:mm:ss Z"
1573
1580
  }
1574
1581
  }
1575
- }, k = {
1582
+ }, A = {
1576
1583
  fr: {
1577
1584
  name: "fr",
1578
1585
  months: [
@@ -1918,7 +1925,7 @@ var p = class e {
1918
1925
  rfc2822: "ddd, DD MMM YYYY HH:mm:ss Z"
1919
1926
  }
1920
1927
  }
1921
- }, A = {
1928
+ }, j = {
1922
1929
  ru: {
1923
1930
  name: "ru",
1924
1931
  months: [
@@ -2195,7 +2202,7 @@ var p = class e {
2195
2202
  rfc2822: "ddd, DD MMM YYYY HH:mm:ss Z"
2196
2203
  }
2197
2204
  }
2198
- }, j = {
2205
+ }, ee = {
2199
2206
  sv: {
2200
2207
  name: "sv",
2201
2208
  months: [
@@ -2472,7 +2479,7 @@ var p = class e {
2472
2479
  rfc2822: "ddd, DD MMM YYYY HH:mm:ss Z"
2473
2480
  }
2474
2481
  }
2475
- }, M = {
2482
+ }, te = {
2476
2483
  ja: {
2477
2484
  name: "ja",
2478
2485
  months: [
@@ -2956,7 +2963,7 @@ var p = class e {
2956
2963
  rfc2822: "ddd, DD MMM YYYY HH:mm:ss Z"
2957
2964
  }
2958
2965
  }
2959
- }, ee = {
2966
+ }, M = {
2960
2967
  de: {
2961
2968
  name: "de",
2962
2969
  months: [
@@ -3857,13 +3864,13 @@ var p = class e {
3857
3864
  }
3858
3865
  }
3859
3866
  }, F = {
3860
- ...D,
3861
3867
  ...O,
3862
3868
  ...k,
3863
3869
  ...A,
3864
3870
  ...j,
3865
- ...M,
3866
3871
  ...ee,
3872
+ ...te,
3873
+ ...M,
3867
3874
  ...N,
3868
3875
  ...P
3869
3876
  };
@@ -4555,7 +4562,7 @@ var R = 40, z = class {
4555
4562
  fromMilliseconds: (e) => Z.fromMilliseconds(e)
4556
4563
  };
4557
4564
  }
4558
- }, te = new Q(), $ = class {
4565
+ }, ne = new Q(), $ = class {
4559
4566
  name = "advanced-format";
4560
4567
  version = "1.0.0";
4561
4568
  install(e) {
@@ -4682,15 +4689,15 @@ var R = 40, z = class {
4682
4689
  return "Coordinated Universal Time";
4683
4690
  }
4684
4691
  }
4685
- }, ne = new $();
4692
+ }, re = new $();
4686
4693
  //#endregion
4687
4694
  //#region src/index.ts
4688
- function re(e, t) {
4689
- return new E(e, t);
4695
+ function ie(e, t) {
4696
+ return new D(e, t);
4690
4697
  }
4691
- var ie = "2.4.0";
4692
- a.getInstance().loadLocales(F);
4698
+ var ae = "2.4.1";
4699
+ o.getInstance().loadLocales(F);
4693
4700
  //#endregion
4694
- export { F as ALL_LOCALES, $ as AdvancedFormatPlugin, K as BuddhistCalendar, B as CalendarManager, W as ChineseCalendar, o as DateFormatter, Z as Duration, Q as DurationPlugin, w as DurationResult, r as EN_LOCALE, i as ES_LOCALE, z as GregorianCalendar, U as HebrewCalendar, H as IslamicCalendar, G as JapaneseCalendar, R as LOCALES_COUNT, a as LocaleManager, p as PluginManager, Y as RelativeTimePlugin, n as TemporalAdapter, E as TimeGuard, T as TimeRange, ne as advancedFormatPlugin, V as calendarManager, te as durationPlugin, L as getAvailableLocales, I as registerAllLocales, X as relativeTimePlugin, re as timeGuard, ie as version };
4701
+ export { F as ALL_LOCALES, $ as AdvancedFormatPlugin, K as BuddhistCalendar, B as CalendarManager, W as ChineseCalendar, s as DateFormatter, Z as Duration, Q as DurationPlugin, T as DurationResult, i as EN_LOCALE, a as ES_LOCALE, z as GregorianCalendar, U as HebrewCalendar, H as IslamicCalendar, G as JapaneseCalendar, R as LOCALES_COUNT, o as LocaleManager, m as PluginManager, Y as RelativeTimePlugin, r as TemporalAdapter, D as TimeGuard, E as TimeRange, re as advancedFormatPlugin, V as calendarManager, ne as durationPlugin, L as getAvailableLocales, I as registerAllLocales, X as relativeTimePlugin, ie as timeGuard, ae as version };
4695
4702
 
4696
4703
  //# sourceMappingURL=time-guard.es.js.map