impact-nova 1.7.34 → 1.7.37

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,193 +1,193 @@
1
1
  import { jsxs as Y, jsx as c } from "react/jsx-runtime";
2
- import * as d from "react";
3
- import { ChevronLeftIcon as ye, ChevronRightIcon as Ne } from "lucide-react";
4
- import { getDefaultClassNames as Be, DayPicker as Fe } from "react-day-picker";
5
- import { cn as u } from "../../lib/utils.js";
6
- import { Button as I } from "./button.js";
7
- import "./button-variants.js";
8
- import ue from "./select/select.js";
9
- import { FISCAL_PATTERNS as Ke, resolveWeekSelection as We } from "../../lib/fiscal-calendar.js";
10
- import { getIntlLocale as qe, getDateFnsLocale as Ge } from "../../i18n/getDateFnsLocale.js";
11
- import { useImpactNovaI18n as Je } from "../../i18n/ImpactNovaI18nContext.js";
12
- const de = d.createContext(0);
13
- function ot({
14
- className: le,
15
- classNames: J,
2
+ import * as u from "react";
3
+ import { ChevronLeftIcon as Ne, ChevronRightIcon as Se } from "lucide-react";
4
+ import { getDefaultClassNames as Te, DayPicker as We } from "react-day-picker";
5
+ import { cn as d } from "../../lib/utils.js";
6
+ import { Button as R } from "./button.js";
7
+ import de from "./select/select.js";
8
+ import { FISCAL_PATTERNS as qe, resolveWeekSelection as Ge } from "../../lib/fiscal-calendar.js";
9
+ import { getIntlLocale as Je, getDateFnsLocale as Qe } from "../../i18n/getDateFnsLocale.js";
10
+ import { useImpactNovaI18n as Xe } from "../../i18n/ImpactNovaI18nContext.js";
11
+ const me = u.createContext(0);
12
+ function it({
13
+ className: oe,
14
+ classNames: Q,
16
15
  showOutsideDays: y = !1,
17
- captionLayout: Q = "dropdown",
18
- buttonVariant: B = "ghost",
19
- formatters: X,
16
+ captionLayout: X = "dropdown",
17
+ buttonVariant: T = "ghost",
18
+ formatters: Z,
20
19
  components: Ce,
21
- showFooter: b = !0,
22
- onApply: Z,
23
- onCancel: me,
24
- onClear: ge,
25
- mode: F = "single",
26
- selected: D,
20
+ showFooter: x = !0,
21
+ disableApply: _e = !1,
22
+ onApply: V,
23
+ onCancel: ge,
24
+ onClear: he,
25
+ mode: W = "single",
26
+ selected: p,
27
27
  onSelect: U,
28
28
  // Week picker props
29
29
  pickerType: m = "date",
30
- weekMode: p = "single",
31
- selectedWeeks: C,
32
- onWeekSelect: k,
30
+ weekMode: v = "single",
31
+ selectedWeeks: S,
32
+ onWeekSelect: M,
33
33
  calendarType: P = "calendar",
34
- fiscalMode: V = "basic",
35
- selectionMode: oe = "week",
34
+ fiscalMode: ee = "basic",
35
+ selectionMode: le = "week",
36
36
  fiscalMonthPattern: ie,
37
- fiscalYearStartMonth: he = 1,
38
- weekStartsOn: K = 1,
37
+ fiscalYearStartMonth: xe = 1,
38
+ weekStartsOn: q = 1,
39
39
  // Default Monday
40
40
  // Month picker props
41
41
  monthMode: w = "single",
42
42
  selectedMonths: N,
43
43
  onMonthSelect: _,
44
- month: T,
45
- defaultMonth: xe,
46
- onMonthChange: Se,
47
- startMonth: _e,
48
- endMonth: Ye,
49
- ...ee
44
+ month: B,
45
+ defaultMonth: be,
46
+ onMonthChange: Ae,
47
+ startMonth: Ye,
48
+ endMonth: Me,
49
+ ...K
50
50
  }) {
51
- const { locale: te, t: x } = Je(), W = d.useMemo(() => qe(te), [te]), ke = d.useMemo(() => Ge(te), [te]), be = d.useMemo(
51
+ const { locale: te, t: b } = Xe(), G = u.useMemo(() => Je(te), [te]), ke = u.useMemo(() => Qe(te), [te]), De = u.useMemo(
52
52
  () => Array.from(
53
53
  { length: 12 },
54
- (e, n) => new Date(2024, n, 1).toLocaleString(W, { month: "long" })
54
+ (e, r) => new Date(2024, r, 1).toLocaleString(G, { month: "long" })
55
55
  ),
56
- [W]
57
- ), Ae = d.useMemo(
56
+ [G]
57
+ ), je = u.useMemo(
58
58
  () => Array.from(
59
59
  { length: 12 },
60
- (e, n) => new Date(2024, n, 1).toLocaleString(W, { month: "short" })
60
+ (e, r) => new Date(2024, r, 1).toLocaleString(G, { month: "short" })
61
61
  ),
62
- [W]
63
- ), ne = d.useMemo(() => {
62
+ [G]
63
+ ), ne = u.useMemo(() => {
64
64
  if (P === "fiscal") {
65
65
  if (ie) return ie;
66
- if (V === "advanced") return Ke["4-4-5"];
66
+ if (ee === "advanced") return qe["4-4-5"];
67
67
  }
68
- }, [P, V, ie]), v = Be(), Me = d.useMemo(() => new Date(1900, 0, 1), []), je = d.useMemo(() => new Date(2100, 11, 31), []), R = _e || Me, L = Ye || je, [q, re] = d.useState(D), [A, ve] = d.useState(() => {
69
- if (T) return T;
70
- if (xe) return xe;
71
- if (D) {
72
- if (Array.isArray(D))
73
- return D[0] || /* @__PURE__ */ new Date();
74
- if (D instanceof Date)
75
- return D;
76
- if ("from" in D && D.from)
77
- return D.from;
68
+ }, [P, ee, ie]), D = Te(), ze = u.useMemo(() => new Date(1900, 0, 1), []), Ee = u.useMemo(() => new Date(2100, 11, 31), []), O = Ye || ze, L = Me || Ee, [H, re] = u.useState(p), [k, ve] = u.useState(() => {
69
+ if (B) return B;
70
+ if (be) return be;
71
+ if (p) {
72
+ if (Array.isArray(p))
73
+ return p[0] || /* @__PURE__ */ new Date();
74
+ if (p instanceof Date)
75
+ return p;
76
+ if ("from" in p && p.from)
77
+ return p.from;
78
78
  }
79
79
  return /* @__PURE__ */ new Date();
80
80
  });
81
- d.useEffect(() => {
82
- T && (ve(T), pe(T.getFullYear()));
83
- }, [T]);
84
- const [$, ae] = d.useState(C), [M, se] = d.useState(N), [ze, pe] = d.useState(A.getFullYear());
85
- d.useEffect(() => {
86
- re(D), ae(C), se(N);
87
- }, [D, C, N]);
88
- const O = (e) => {
89
- ve(e), pe(e.getFullYear()), Se?.(e);
90
- }, ce = d.useCallback((e) => {
91
- let n;
92
- return e instanceof Date ? n = e : n = e.days.find((t) => !t.outside)?.date || e.days[0]?.date || /* @__PURE__ */ new Date(), We(n, {
81
+ u.useEffect(() => {
82
+ B && (ve(B), pe(B.getFullYear()));
83
+ }, [B]);
84
+ const [j, ae] = u.useState(S), [A, se] = u.useState(N), [Ie, pe] = u.useState(k.getFullYear());
85
+ u.useEffect(() => {
86
+ re(p), ae(S), se(N);
87
+ }, [p, S, N]);
88
+ const $ = (e) => {
89
+ ve(e), pe(e.getFullYear()), Ae?.(e);
90
+ }, ce = u.useCallback((e) => {
91
+ let r;
92
+ return e instanceof Date ? r = e : r = e.days.find((t) => !t.outside)?.date || e.days[0]?.date || /* @__PURE__ */ new Date(), Ge(r, {
93
93
  calendarType: P,
94
- fiscalMode: V,
95
- selectionMode: oe,
94
+ fiscalMode: ee,
95
+ selectionMode: le,
96
96
  fiscalMonthPattern: ne,
97
- fiscalYearStartMonth: he,
98
- weekStartsOn: K
97
+ fiscalYearStartMonth: xe,
98
+ weekStartsOn: q
99
99
  });
100
- }, [P, V, oe, ne, he, K]), fe = d.useCallback((e) => {
101
- const n = (t, a) => t.year === a.year && t.month === a.month && t.weekOfMonth === a.weekOfMonth;
102
- if (b)
100
+ }, [P, ee, le, ne, xe, q]), fe = u.useCallback((e) => {
101
+ const r = (t, s) => t.year === s.year && t.month === s.month && t.weekOfMonth === s.weekOfMonth;
102
+ if (x)
103
103
  ae((t) => {
104
- let a;
105
- if (p === "single")
106
- a = e;
107
- else if (p === "multiple") {
108
- const r = t || [];
109
- a = r.some((l) => n(l, e)) ? r.filter((l) => !n(l, e)) : [...r, e];
110
- } else if (p === "range") {
111
- const r = t;
112
- if (!r?.from || r.to)
113
- a = { from: e };
104
+ let s;
105
+ if (v === "single")
106
+ s = e;
107
+ else if (v === "multiple") {
108
+ const n = t || [];
109
+ s = n.some((o) => r(o, e)) ? n.filter((o) => !r(o, e)) : [...n, e];
110
+ } else if (v === "range") {
111
+ const n = t;
112
+ if (!n?.from || n.to)
113
+ s = { from: e };
114
114
  else {
115
- const s = { from: r.from, to: e };
116
- e.startDate < r.from.startDate && (s.from = e, s.to = r.from), a = s;
115
+ const a = { from: n.from, to: e };
116
+ e.startDate < n.from.startDate && (a.from = e, a.to = n.from), s = a;
117
117
  }
118
118
  }
119
- return k?.(a), a;
119
+ return M?.(s), s;
120
120
  });
121
- else if (p === "single")
122
- k?.(e);
123
- else if (p === "multiple") {
124
- const t = C || [], r = t.some((s) => n(s, e)) ? t.filter((s) => !n(s, e)) : [...t, e];
125
- k?.(r.length > 0 ? r : void 0);
126
- } else if (p === "range") {
127
- const t = C;
121
+ else if (v === "single")
122
+ M?.(e);
123
+ else if (v === "multiple") {
124
+ const t = S || [], n = t.some((a) => r(a, e)) ? t.filter((a) => !r(a, e)) : [...t, e];
125
+ M?.(n.length > 0 ? n : void 0);
126
+ } else if (v === "range") {
127
+ const t = S;
128
128
  if (!t?.from || t.to)
129
- k?.({ from: e });
129
+ M?.({ from: e });
130
130
  else {
131
- const a = { from: t.from, to: e };
132
- e.startDate < t.from.startDate && (a.from = e, a.to = t.from), k?.(a);
131
+ const s = { from: t.from, to: e };
132
+ e.startDate < t.from.startDate && (s.from = e, s.to = t.from), M?.(s);
133
133
  }
134
134
  }
135
- }, [p, b, C, k]), Ee = d.useCallback((e, n) => {
136
- const t = { year: e, month: n }, a = (r, s) => r.year === s.year && r.month === s.month;
137
- if (b)
138
- se((r) => {
139
- let s;
135
+ }, [v, x, S, M]), Re = u.useCallback((e, r) => {
136
+ const t = { year: e, month: r }, s = (n, a) => n.year === a.year && n.month === a.month;
137
+ if (x)
138
+ se((n) => {
139
+ let a;
140
140
  if (w === "single")
141
- s = t;
141
+ a = t;
142
142
  else if (w === "multiple") {
143
- const l = r || [];
144
- s = l.some((f) => a(f, t)) ? l.filter((f) => !a(f, t)) : [...l, t];
143
+ const o = n || [];
144
+ a = o.some((f) => s(f, t)) ? o.filter((f) => !s(f, t)) : [...o, t];
145
145
  } else if (w === "range") {
146
- const l = r;
147
- if (!l?.from || l.to)
148
- s = { from: t };
146
+ const o = n;
147
+ if (!o?.from || o.to)
148
+ a = { from: t };
149
149
  else {
150
- const o = new Date(l.from.year, l.from.month, 1);
151
- new Date(t.year, t.month, 1) < o ? s = { from: t, to: l.from } : s = { from: l.from, to: t };
150
+ const l = new Date(o.from.year, o.from.month, 1);
151
+ new Date(t.year, t.month, 1) < l ? a = { from: t, to: o.from } : a = { from: o.from, to: t };
152
152
  }
153
153
  }
154
- return _?.(s), s;
154
+ return _?.(a), a;
155
155
  });
156
156
  else if (w === "single")
157
157
  _?.(t);
158
158
  else if (w === "multiple") {
159
- const r = N || [], l = r.some((o) => a(o, t)) ? r.filter((o) => !a(o, t)) : [...r, t];
160
- _?.(l.length > 0 ? l : void 0);
159
+ const n = N || [], o = n.some((l) => s(l, t)) ? n.filter((l) => !s(l, t)) : [...n, t];
160
+ _?.(o.length > 0 ? o : void 0);
161
161
  } else if (w === "range") {
162
- const r = N;
163
- if (!r?.from || r.to)
162
+ const n = N;
163
+ if (!n?.from || n.to)
164
164
  _?.({ from: t });
165
165
  else {
166
- const s = new Date(r.from.year, r.from.month, 1);
167
- new Date(t.year, t.month, 1) < s ? _?.({ from: t, to: r.from }) : _?.({ from: r.from, to: t });
166
+ const a = new Date(n.from.year, n.from.month, 1);
167
+ new Date(t.year, t.month, 1) < a ? _?.({ from: t, to: n.from }) : _?.({ from: n.from, to: t });
168
168
  }
169
169
  }
170
- }, [w, b, N, _]), De = d.useCallback(() => {
171
- const e = R.getFullYear(), n = L.getFullYear(), t = [];
172
- for (let a = e; a <= n; a++)
173
- t.push({ label: a.toString(), value: a.toString() });
170
+ }, [w, x, N, _]), we = u.useCallback(() => {
171
+ const e = O.getFullYear(), r = L.getFullYear(), t = [];
172
+ for (let s = e; s <= r; s++)
173
+ t.push({ label: s.toString(), value: s.toString() });
174
174
  return t;
175
- }, [R, L]), Ie = d.useCallback((e) => be.map((t, a) => ({
175
+ }, [O, L]), Pe = u.useCallback((e) => De.map((t, s) => ({
176
176
  label: t,
177
- value: a.toString()
178
- })).filter((t, a) => {
179
- const r = new Date(e, a, 1);
180
- return !(R && r < new Date(R.getFullYear(), R.getMonth(), 1) || L && r > new Date(L.getFullYear(), L.getMonth(), 1));
181
- }), [R, L, be]), G = d.useMemo(() => {
177
+ value: s.toString()
178
+ })).filter((t, s) => {
179
+ const n = new Date(e, s, 1);
180
+ return !(O && n < new Date(O.getFullYear(), O.getMonth(), 1) || L && n > new Date(L.getFullYear(), L.getMonth(), 1));
181
+ }), [O, L, De]), J = u.useMemo(() => {
182
182
  if (m !== "week") return;
183
- const e = b ? $ : C;
183
+ const e = x ? j : S;
184
184
  if (!e) return;
185
- const n = [], t = (a) => {
186
- let r = new Date(a.startDate);
187
- r.setHours(0, 0, 0, 0);
188
- const s = new Date(a.endDate);
189
- for (s.setHours(0, 0, 0, 0); r <= s; )
190
- n.push(new Date(r)), r.setDate(r.getDate() + 1);
185
+ const r = [], t = (s) => {
186
+ let n = new Date(s.startDate);
187
+ n.setHours(0, 0, 0, 0);
188
+ const a = new Date(s.endDate);
189
+ for (a.setHours(0, 0, 0, 0); n <= a; )
190
+ r.push(new Date(n)), n.setDate(n.getDate() + 1);
191
191
  };
192
192
  if (Array.isArray(e))
193
193
  e.forEach(t);
@@ -196,168 +196,221 @@ function ot({
196
196
  if (!e.to)
197
197
  t(e.from);
198
198
  else {
199
- let a = new Date(e.from.startDate);
200
- a.setHours(0, 0, 0, 0);
201
- const r = new Date(e.to.endDate);
202
- for (r.setHours(0, 0, 0, 0); a <= r; )
203
- n.push(new Date(a)), a.setDate(a.getDate() + 1);
199
+ let s = new Date(e.from.startDate);
200
+ s.setHours(0, 0, 0, 0);
201
+ const n = new Date(e.to.endDate);
202
+ for (n.setHours(0, 0, 0, 0); s <= n; )
203
+ r.push(new Date(s)), s.setDate(s.getDate() + 1);
204
204
  }
205
205
  } else
206
206
  t(e);
207
- return n;
208
- }, [m, b, $, C]), Pe = d.useMemo(() => {
209
- if (m !== "week" || !G || G.length === 0)
207
+ return r;
208
+ }, [m, x, j, S]), Oe = u.useMemo(() => {
209
+ if (m !== "week" || !J || J.length === 0)
210
210
  return { range_start: [], range_middle: [], range_end: [] };
211
- const e = [...G].sort((i, g) => i.getTime() - g.getTime()), n = [], t = [], a = [], r = b ? $ : C, s = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set();
212
- p === "multiple" && Array.isArray(r) && r.forEach((i) => {
211
+ const e = [...J].sort((i, g) => i.getTime() - g.getTime()), r = [], t = [], s = [], n = x ? j : S, a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set();
212
+ v === "multiple" && Array.isArray(n) && n.forEach((i) => {
213
213
  const g = i.startDate.toISOString().split("T")[0], h = i.endDate.toISOString().split("T")[0];
214
- s.add(g), l.add(h);
214
+ a.add(g), o.add(h);
215
215
  });
216
- const o = (i, g) => {
216
+ const l = (i, g) => {
217
217
  if (g === 0) return !1;
218
218
  const h = e[g - 1];
219
219
  return i.getTime() - h.getTime() <= 1440 * 60 * 1e3;
220
220
  }, f = (i, g) => g === e.length - 1 ? !1 : e[g + 1].getTime() - i.getTime() <= 1440 * 60 * 1e3;
221
221
  return e.forEach((i, g) => {
222
- const h = i.toISOString().split("T")[0], j = s.has(h), S = l.has(h), z = o(i, g), E = f(i, g);
223
- p === "multiple" ? j ? n.push(i) : S ? a.push(i) : t.push(i) : !z && !E ? (n.push(i), a.push(i)) : z ? E ? t.push(i) : a.push(i) : n.push(i);
222
+ const h = i.toISOString().split("T")[0], z = a.has(h), C = o.has(h), E = l(i, g), I = f(i, g);
223
+ v === "multiple" ? z ? r.push(i) : C ? s.push(i) : t.push(i) : !E && !I ? (r.push(i), s.push(i)) : E ? I ? t.push(i) : s.push(i) : r.push(i);
224
224
  }), {
225
- range_start: n,
225
+ range_start: r,
226
226
  range_middle: t,
227
- range_end: a
227
+ range_end: s
228
228
  };
229
- }, [m, G, p, b, $, C]), Re = d.useCallback((e) => {
229
+ }, [m, J, v, x, j, S]), Le = u.useCallback((e) => {
230
230
  if (m === "week" && e) {
231
- const n = Array.isArray(e) ? e[e.length - 1] : e instanceof Date ? e : void 0;
232
- if (n) {
233
- const t = ce(n);
231
+ const r = Array.isArray(e) ? e[e.length - 1] : e instanceof Date ? e : void 0;
232
+ if (r) {
233
+ const t = ce(r);
234
234
  fe(t);
235
235
  return;
236
236
  }
237
237
  }
238
- b && re(e), U?.(e);
239
- }, [b, U, m, ce, fe]), Le = d.useCallback(() => {
240
- m === "week" ? (k?.($), Z?.($)) : m === "month" ? (_?.(M), Z?.(M)) : (U?.(q), Z?.(q));
241
- }, [q, $, M, U, k, _, Z, m]), $e = d.useCallback(() => {
242
- m === "week" ? ae(C) : m === "month" ? se(N) : re(D), me?.();
243
- }, [D, C, N, me, m]), Oe = d.useCallback(() => {
244
- m === "week" ? (ae(void 0), b || k?.(void 0)) : m === "month" ? (se(void 0), b || _?.(void 0)) : (re(void 0), b || U?.(void 0)), ge?.();
245
- }, [b, U, k, _, ge, m]), Ue = d.useCallback((e, n) => {
246
- const t = b ? M : N;
238
+ x && re(e), U?.(e);
239
+ }, [x, U, m, ce, fe]), $e = u.useCallback(() => {
240
+ m === "week" ? (M?.(j), V?.(j)) : m === "month" ? (_?.(A), V?.(A)) : (U?.(H), V?.(H));
241
+ }, [H, j, A, U, M, _, V, m]), Ue = u.useCallback(() => {
242
+ m === "week" ? ae(S) : m === "month" ? se(N) : re(p), ge?.();
243
+ }, [p, S, N, ge, m]), He = u.useCallback(() => {
244
+ m === "week" ? (ae(void 0), x || M?.(void 0)) : m === "month" ? (se(void 0), x || _?.(void 0)) : (re(void 0), x || U?.(void 0)), he?.();
245
+ }, [x, U, M, _, he, m]), Fe = u.useCallback((e, r) => {
246
+ const t = x ? A : N;
247
247
  if (!t) return !1;
248
248
  if (Array.isArray(t))
249
- return t.some((a) => a.year === e && a.month === n);
249
+ return t.some((s) => s.year === e && s.month === r);
250
250
  if ("from" in t) {
251
- const a = t, r = a.from, s = a.to;
252
- if (!r && !s) return !1;
253
- const l = new Date(e, n, 1).getTime();
254
- if (!r) return s ? l === new Date(s.year, s.month, 1).getTime() : !1;
255
- const o = new Date(r.year, r.month, 1).getTime();
256
- if (!s) return l === o;
257
- const f = new Date(s.year, s.month, 1).getTime();
258
- return l >= o && l <= f;
251
+ const s = t, n = s.from, a = s.to;
252
+ if (!n && !a) return !1;
253
+ const o = new Date(e, r, 1).getTime();
254
+ if (!n) return a ? o === new Date(a.year, a.month, 1).getTime() : !1;
255
+ const l = new Date(n.year, n.month, 1).getTime();
256
+ if (!a) return o === l;
257
+ const f = new Date(a.year, a.month, 1).getTime();
258
+ return o >= l && o <= f;
259
259
  } else {
260
- const a = t;
261
- return a.year === e && a.month === n;
260
+ const s = t;
261
+ return s.year === e && s.month === r;
262
262
  }
263
- }, [b, M, N]), He = d.useCallback((e, n) => {
264
- const t = b ? M : N;
263
+ }, [x, A, N]), Be = u.useCallback((e, r) => {
264
+ const t = x ? A : N;
265
265
  if (!t || !("from" in t)) return { isStart: !1, isEnd: !1, isMiddle: !1 };
266
- const a = t, r = a.from, s = a.to;
267
- if (!r && !s) return { isStart: !1, isEnd: !1, isMiddle: !1 };
268
- const l = new Date(e, n, 1).getTime();
269
- if (!r) return { isStart: !1, isEnd: s ? l === new Date(s.year, s.month, 1).getTime() : !1, isMiddle: !1 };
270
- const o = new Date(r.year, r.month, 1).getTime();
271
- if (!s) return { isStart: l === o, isEnd: !1, isMiddle: !1 };
272
- const f = new Date(s.year, s.month, 1).getTime();
266
+ const s = t, n = s.from, a = s.to;
267
+ if (!n && !a) return { isStart: !1, isEnd: !1, isMiddle: !1 };
268
+ const o = new Date(e, r, 1).getTime();
269
+ if (!n) return { isStart: !1, isEnd: a ? o === new Date(a.year, a.month, 1).getTime() : !1, isMiddle: !1 };
270
+ const l = new Date(n.year, n.month, 1).getTime();
271
+ if (!a) return { isStart: o === l, isEnd: !1, isMiddle: !1 };
272
+ const f = new Date(a.year, a.month, 1).getTime();
273
273
  return {
274
- isStart: l === o,
275
- isEnd: l === f,
276
- isMiddle: l > o && l < f
274
+ isStart: o === l,
275
+ isEnd: o === f,
276
+ isMiddle: o > l && o < f
277
277
  };
278
- }, [b, M, N]), Te = d.useCallback((e, n) => {
279
- const t = ee.disabled;
278
+ }, [x, A, N]), ue = u.useCallback((e, r) => {
279
+ const t = K.disabled;
280
280
  if (!t) return !1;
281
- const a = new Date(e, n, 1, 0, 0, 0, 0), r = new Date(e, n + 1, 0, 23, 59, 59, 999);
281
+ const s = new Date(e, r, 1, 0, 0, 0, 0), n = new Date(e, r + 1, 0, 23, 59, 59, 999);
282
282
  if (t.before) {
283
- const s = new Date(t.before);
284
- if (s.setHours(0, 0, 0, 0), r < s) return !0;
283
+ const a = new Date(t.before);
284
+ if (a.setHours(0, 0, 0, 0), n < a) return !0;
285
285
  }
286
286
  if (t.after) {
287
- const s = new Date(t.after);
288
- if (s.setHours(23, 59, 59, 999), a > s) return !0;
287
+ const a = new Date(t.after);
288
+ if (a.setHours(23, 59, 59, 999), s > a) return !0;
289
+ }
290
+ return !1;
291
+ }, [K.disabled]), Ke = u.useMemo(() => {
292
+ if (!x) return !1;
293
+ const e = K.disabled;
294
+ if (!e) return !1;
295
+ const r = e.before, t = e.after, s = (n) => {
296
+ const a = new Date(n.getFullYear(), n.getMonth(), n.getDate());
297
+ if (r) {
298
+ const o = new Date(r.getFullYear(), r.getMonth(), r.getDate());
299
+ if (a < o) return !0;
300
+ }
301
+ if (t) {
302
+ const o = new Date(t.getFullYear(), t.getMonth(), t.getDate());
303
+ if (a > o) return !0;
304
+ }
305
+ return !1;
306
+ };
307
+ if (m === "month") {
308
+ const n = A;
309
+ if (!n) return !1;
310
+ const a = (o) => ue(o.year, o.month);
311
+ if (Array.isArray(n))
312
+ return n.some(a);
313
+ if ("from" in n) {
314
+ const o = n;
315
+ return !!(o.from && a(o.from) || o.to && a(o.to));
316
+ } else
317
+ return a(n);
318
+ }
319
+ if (m === "week") {
320
+ const n = j;
321
+ if (!n) return !1;
322
+ const a = (o) => s(o.startDate) || s(o.endDate);
323
+ if (Array.isArray(n))
324
+ return n.some(a);
325
+ if ("from" in n) {
326
+ const o = n;
327
+ return !!(o.from && a(o.from) || o.to && a(o.to));
328
+ } else
329
+ return a(n);
330
+ }
331
+ if (m === "date") {
332
+ const n = H;
333
+ if (!n) return !1;
334
+ if (Array.isArray(n))
335
+ return n.some(s);
336
+ if (n instanceof Date)
337
+ return s(n);
338
+ if ("from" in n) {
339
+ const a = n;
340
+ return !!(a.from && s(a.from) || a.to && s(a.to));
341
+ }
289
342
  }
290
343
  return !1;
291
- }, [ee.disabled]), we = ({ yearOffset: e = 0 }) => {
292
- const n = ze + e;
344
+ }, [m, x, K.disabled, H, j, A, ue]), ye = ({ yearOffset: e = 0 }) => {
345
+ const r = Ie + e;
293
346
  return /* @__PURE__ */ Y("div", { className: "flex flex-col gap-4 p-3 min-w-[280px]", children: [
294
347
  /* @__PURE__ */ Y("div", { className: "flex items-center justify-between", children: [
295
348
  e === 0 && /* @__PURE__ */ c(
296
- I,
349
+ R,
297
350
  {
298
351
  variant: "ghost",
299
352
  size: "icon",
300
353
  className: "h-7 w-7",
301
- "aria-label": x("calendar.previousYear"),
302
- title: x("calendar.previousYear"),
303
- disabled: n <= R.getFullYear(),
304
- onClick: () => O(new Date(n - 1, A.getMonth(), 1)),
305
- children: /* @__PURE__ */ c(ye, { className: "h-4 w-4" })
354
+ "aria-label": b("calendar.previousYear"),
355
+ title: b("calendar.previousYear"),
356
+ disabled: r <= O.getFullYear(),
357
+ onClick: () => $(new Date(r - 1, k.getMonth(), 1)),
358
+ children: /* @__PURE__ */ c(Ne, { className: "h-4 w-4" })
306
359
  }
307
360
  ),
308
361
  /* @__PURE__ */ c("div", { className: "flex-1 flex justify-center items-center", children: /* @__PURE__ */ c(
309
- ue,
362
+ de,
310
363
  {
311
- value: { label: n.toString(), value: n.toString() },
364
+ value: { label: r.toString(), value: r.toString() },
312
365
  onChange: (t) => {
313
366
  if (t && "value" in t) {
314
- const a = parseInt(t.value) - e;
315
- O(new Date(a, A.getMonth(), 1));
367
+ const s = parseInt(t.value) - e;
368
+ $(new Date(s, k.getMonth(), 1));
316
369
  }
317
370
  },
318
371
  scrollToSelectedOnOpen: !0,
319
- options: De(),
372
+ options: we(),
320
373
  parentClassName: "flex justify-center items-center",
321
374
  className: "w-[200px]",
322
375
  menuWidth: "140px"
323
376
  }
324
377
  ) }),
325
378
  (w === "single" || e === 1) && /* @__PURE__ */ c(
326
- I,
379
+ R,
327
380
  {
328
381
  variant: "ghost",
329
382
  size: "icon",
330
383
  className: "h-7 w-7",
331
- "aria-label": x("calendar.nextYear"),
332
- title: x("calendar.nextYear"),
333
- disabled: n >= L.getFullYear(),
334
- onClick: () => O(new Date(n + 1, A.getMonth(), 1)),
335
- children: /* @__PURE__ */ c(Ne, { className: "h-4 w-4" })
384
+ "aria-label": b("calendar.nextYear"),
385
+ title: b("calendar.nextYear"),
386
+ disabled: r >= L.getFullYear(),
387
+ onClick: () => $(new Date(r + 1, k.getMonth(), 1)),
388
+ children: /* @__PURE__ */ c(Se, { className: "h-4 w-4" })
336
389
  }
337
390
  )
338
391
  ] }),
339
- /* @__PURE__ */ c("div", { className: "grid grid-cols-4 gap-y-4 gap-x-0", children: Ae.map((t, a) => {
340
- const r = Ue(n, a), { isStart: s, isEnd: l, isMiddle: o } = He(n, a), f = w === "range", i = b ? M : N, g = i && "to" in i && !!i.to, h = Te(n, a);
392
+ /* @__PURE__ */ c("div", { className: "grid grid-cols-4 gap-y-4 gap-x-0", children: je.map((t, s) => {
393
+ const n = Fe(r, s), { isStart: a, isEnd: o, isMiddle: l } = Be(r, s), f = w === "range", i = x ? A : N, g = i && "to" in i && !!i.to, h = ue(r, s);
341
394
  return /* @__PURE__ */ Y("div", { className: "relative flex items-center justify-center h-10 w-full group", children: [
342
- f && g && (o || s || l) && !h && /* @__PURE__ */ c("div", { className: u(
395
+ f && g && (l || a || o) && !h && /* @__PURE__ */ c("div", { className: d(
343
396
  "absolute inset-y-0 inset-x-0 bg-accent",
344
- s && "rounded-l-full left-1/2 -ml-5",
345
- l && "rounded-r-full right-1/2 -mr-5",
346
- o && "inset-x-0",
347
- s && l && "rounded-full inset-x-2"
397
+ a && "rounded-l-full left-1/2 -ml-5",
398
+ o && "rounded-r-full right-1/2 -mr-5",
399
+ l && "inset-x-0",
400
+ a && o && "rounded-full inset-x-2"
348
401
  ) }),
349
402
  /* @__PURE__ */ c(
350
- I,
403
+ R,
351
404
  {
352
405
  variant: "ghost",
353
- onClick: () => Ee(n, a),
406
+ onClick: () => Re(r, s),
354
407
  disabled: h,
355
- className: u(
408
+ className: d(
356
409
  "relative z-10 w-10 h-10 p-0 text-sm font-normal rounded-lg transition-all",
357
- r && !f && !h && "bg-brand text-brand-foreground hover:bg-brand/90 hover:text-brand-foreground",
358
- f && (s || l) && !h && "bg-brand text-brand-foreground hover:bg-brand/90 hover:text-brand-foreground rounded-lg",
359
- !r && !h && "hover:bg-accent hover:text-accent-foreground border border-transparent hover:border-brand",
360
- o && !h && "text-accent-foreground",
410
+ n && !f && !h && "bg-brand text-brand-foreground hover:bg-brand/90 hover:text-brand-foreground",
411
+ f && (a || o) && !h && "bg-brand text-brand-foreground hover:bg-brand/90 hover:text-brand-foreground rounded-lg",
412
+ !n && !h && "hover:bg-accent hover:text-accent-foreground border border-transparent hover:border-brand",
413
+ l && !h && "text-accent-foreground",
361
414
  h && "text-content-muted opacity-50 cursor-not-allowed"
362
415
  ),
363
416
  children: t
@@ -369,423 +422,424 @@ function ot({
369
422
  };
370
423
  return /* @__PURE__ */ Y("div", { className: "flex flex-col ", "data-component": "calendar", children: [
371
424
  m === "month" ? /* @__PURE__ */ Y("div", { className: "flex flex-col md:flex-row", children: [
372
- /* @__PURE__ */ c(we, { yearOffset: 0 }),
425
+ /* @__PURE__ */ c(ye, { yearOffset: 0 }),
373
426
  (w === "range" || w === "multiple") && /* @__PURE__ */ Y("div", { className: "flex flex-row gap-0", children: [
374
427
  /* @__PURE__ */ c("div", { className: "w-[1px] bg-stroke-hairline my-4" }),
375
- /* @__PURE__ */ c(we, { yearOffset: 1 })
428
+ /* @__PURE__ */ c(ye, { yearOffset: 1 })
376
429
  ] })
377
430
  ] }) : (
378
431
  // @ts-ignore: TS mismatch due to dynamic union types.
379
432
  // FIX: Split rendering into separate `DayPicker` calls for 'single' | 'multiple' | 'range' to strictly match discriminated unions.
380
433
  /* @__PURE__ */ c(
381
- Fe,
434
+ We,
382
435
  {
383
- mode: m === "week" ? "multiple" : F,
384
- selected: m === "week" ? G : b ? q : D,
385
- onSelect: Re,
386
- month: A,
387
- onMonthChange: O,
436
+ mode: m === "week" ? "multiple" : W,
437
+ selected: m === "week" ? J : x ? H : p,
438
+ onSelect: Le,
439
+ month: k,
440
+ onMonthChange: $,
388
441
  showOutsideDays: P === "fiscal" ? !0 : y,
389
- weekStartsOn: K,
390
- modifiers: m === "week" ? Pe : void 0,
442
+ weekStartsOn: q,
443
+ modifiers: m === "week" ? Oe : void 0,
391
444
  locale: ke,
392
- className: u(
445
+ className: d(
393
446
  "bg-canvas group/calendar p-2 [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",
394
447
  String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
395
448
  String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
396
- le
449
+ oe
397
450
  ),
398
- captionLayout: Q,
399
- startMonth: R,
451
+ captionLayout: X,
452
+ startMonth: O,
400
453
  endMonth: L,
401
- disabled: ee.disabled,
402
- numberOfMonths: F === "range" || F === "multiple" || p === "range" || p === "multiple" ? 2 : 1,
454
+ disabled: K.disabled,
455
+ numberOfMonths: W === "range" || W === "multiple" || v === "range" || v === "multiple" ? 2 : 1,
403
456
  showWeekNumber: !0,
404
457
  formatters: {
405
- formatMonthDropdown: (e) => e.toLocaleString(W, { month: "short" }),
406
- formatWeekNumber: (e) => x("calendar.weekNumber", { number: e }),
407
- ...X
458
+ formatMonthDropdown: (e) => e.toLocaleString(G, { month: "short" }),
459
+ formatWeekNumber: (e) => b("calendar.weekNumber", { number: e }),
460
+ ...Z
408
461
  },
409
462
  classNames: {
410
- root: u("w-fit", v.root),
411
- months: u(
463
+ root: d("w-fit", D.root),
464
+ months: d(
412
465
  "relative flex flex-col gap-2 md:flex-row",
413
- v.months
466
+ D.months
414
467
  ),
415
- month: u(
468
+ month: d(
416
469
  "flex flex-1 min-w-[252px] flex-col gap-2 relative after:absolute after:top-[5.5rem] after:bottom-0 after:left-[30px] after:w-[1px] after:bg-stroke-hairline",
417
- v.month
470
+ D.month
418
471
  ),
419
- nav: u(
472
+ nav: d(
420
473
  "absolute inset-x-0 top-[2px] h-[--cell-size] flex w-full items-center justify-between px-2 gap-1",
421
- v.nav
474
+ D.nav
422
475
  ),
423
- button_previous: u(
476
+ button_previous: d(
424
477
  "h-7 w-7 select-none p-0 z-10 aria-disabled:opacity-50 flex items-center justify-center relative",
425
- v.button_previous
478
+ D.button_previous
426
479
  ),
427
- button_next: u(
480
+ button_next: d(
428
481
  "h-7 w-7 select-none p-0 z-10 aria-disabled:opacity-50 flex items-center justify-center relative",
429
- v.button_next
482
+ D.button_next
430
483
  ),
431
- month_caption: u(
484
+ month_caption: d(
432
485
  "flex h-[--cell-size] w-full items-center justify-center px-[--cell-size] relative ",
433
- v.month_caption
486
+ D.month_caption
434
487
  ),
435
- dropdowns: u(
488
+ dropdowns: d(
436
489
  "flex h-[--cell-size] gap-1 items-center justify-center text-sm font-medium relative ",
437
- v.dropdowns
490
+ D.dropdowns
438
491
  ),
439
- caption_label: u(
492
+ caption_label: d(
440
493
  "select-none font-medium text-sm",
441
- v.caption_label
494
+ D.caption_label
442
495
  ),
443
496
  table: "w-full border-collapse",
444
- weekdays: u("flex w-full relative after:absolute after:bottom-0 after:right-0 after:h-[1px] after:bg-stroke-hairline after:left-[30px]", v.weekdays),
445
- weekday: u(
497
+ weekdays: d("flex w-full relative after:absolute after:bottom-0 after:right-0 after:h-[1px] after:bg-stroke-hairline after:left-[30px]", D.weekdays),
498
+ weekday: d(
446
499
  "flex-1 select-none rounded-md font-normal text-center",
447
500
  "text-[11px] text-content-muted pb-2",
448
501
  "[&:nth-child(2)]:pl-2",
449
- v.weekday
502
+ D.weekday
450
503
  ),
451
- week: u("mt-1 flex w-full items-stretch group/week", v.week),
452
- week_number_header: u(
504
+ week: d("mt-1 flex w-full items-stretch group/week", D.week),
505
+ week_number_header: d(
453
506
  "select-none font-normal text-center h-[30px] flex items-center justify-center",
454
507
  "text-[11px] text-content-muted w-[30px] flex-shrink-0",
455
- v.week_number_header
508
+ D.week_number_header
456
509
  ),
457
- week_number: u(
510
+ week_number: d(
458
511
  "select-none flex items-center justify-center h-[30px]",
459
512
  "text-[11px] text-content-muted w-[30px] flex-shrink-0 transition-colors",
460
513
  m === "week" && "group-hover/week:bg-accent group-hover/week:rounded-l-lg",
461
- v.week_number
514
+ D.week_number
462
515
  ),
463
- day: u(
516
+ day: d(
464
517
  "group/day relative select-none p-0 text-center flex-1 h-[30px] flex items-center justify-center [&:nth-child(2)]:pl-2 rdp-day",
465
518
  m === "week" && "group-hover/week:bg-accent [&:nth-child(2)]:group-hover/week:rounded-l-full [&:nth-child(8)]:group-hover/week:rounded-r-full",
466
519
  m === "week" && "[&.rdp-selected:nth-child(2)]:rounded-l-full [&.rdp-selected:nth-child(8)]:rounded-r-full",
467
- J?.day
520
+ Q?.day
468
521
  ),
469
- range_start: u(
522
+ range_start: d(
470
523
  "bg-accent rounded-l-full",
471
- v.range_start
524
+ D.range_start
472
525
  ),
473
- range_middle: u("bg-accent rounded-none", v.range_middle),
474
- range_end: u("bg-accent rounded-r-full", v.range_end),
475
- today: u(
526
+ range_middle: d("bg-accent rounded-none", D.range_middle),
527
+ range_end: d("bg-accent rounded-r-full", D.range_end),
528
+ today: d(
476
529
  "text-brand",
477
- v.today
530
+ D.today
478
531
  ),
479
- outside: u(
532
+ outside: d(
480
533
  P === "fiscal" || y ? "text-content-muted opacity-50" : "invisible",
481
- v.outside
534
+ D.outside
482
535
  ),
483
- disabled: u(
536
+ disabled: d(
484
537
  "text-content-muted opacity-50",
485
- v.disabled
538
+ D.disabled
486
539
  ),
487
- hidden: u("invisible", v.hidden),
488
- ...J
540
+ hidden: d("invisible", D.hidden),
541
+ ...Q
489
542
  },
490
543
  components: {
491
- Root: ({ className: e, rootRef: n, ...t }) => /* @__PURE__ */ c(
544
+ Root: ({ className: e, rootRef: r, ...t }) => /* @__PURE__ */ c(
492
545
  "div",
493
546
  {
494
547
  "data-slot": "calendar",
495
- ref: n,
496
- className: u(e),
548
+ ref: r,
549
+ className: d(e),
497
550
  ...t
498
551
  }
499
552
  ),
500
- Chevron: ({ className: e, orientation: n, ...t }) => n === "left" ? /* @__PURE__ */ c(ye, { className: u("size-4 text-content", e), ...t }) : n === "right" ? /* @__PURE__ */ c(
501
- Ne,
553
+ Chevron: ({ className: e, orientation: r, ...t }) => r === "left" ? /* @__PURE__ */ c(Ne, { className: d("size-4 text-content", e), ...t }) : r === "right" ? /* @__PURE__ */ c(
554
+ Se,
502
555
  {
503
- className: u("size-4 text-content", e),
556
+ className: d("size-4 text-content", e),
504
557
  ...t
505
558
  }
506
559
  ) : /* @__PURE__ */ c("span", {}),
507
560
  PreviousMonthButton: (e) => /* @__PURE__ */ c(
508
- I,
561
+ R,
509
562
  {
510
- variant: B,
563
+ variant: T,
511
564
  size: "icon",
512
565
  className: "h-7 w-7",
513
- "aria-label": x("calendar.previousMonth"),
514
- title: x("calendar.previousMonth"),
566
+ "aria-label": b("calendar.previousMonth"),
567
+ title: b("calendar.previousMonth"),
515
568
  ...e
516
569
  }
517
570
  ),
518
571
  NextMonthButton: (e) => /* @__PURE__ */ c(
519
- I,
572
+ R,
520
573
  {
521
- variant: B,
574
+ variant: T,
522
575
  size: "icon",
523
576
  className: "h-7 w-7",
524
- "aria-label": x("calendar.nextMonth"),
525
- title: x("calendar.nextMonth"),
577
+ "aria-label": b("calendar.nextMonth"),
578
+ title: b("calendar.nextMonth"),
526
579
  ...e
527
580
  }
528
581
  ),
529
- MonthCaption: ({ displayIndex: e, ...n }) => /* @__PURE__ */ c(de.Provider, { value: e, children: /* @__PURE__ */ c("div", { ...n }) }),
582
+ MonthCaption: ({ displayIndex: e, ...r }) => /* @__PURE__ */ c(me.Provider, { value: e, children: /* @__PURE__ */ c("div", { ...r }) }),
530
583
  MonthsDropdown: ({ value: e }) => {
531
- const n = d.useContext(de), t = n > 0, r = new Date(A.getFullYear(), A.getMonth() + n, 1).getFullYear(), s = Ie(r);
584
+ const r = u.useContext(me), t = r > 0, n = new Date(k.getFullYear(), k.getMonth() + r, 1).getFullYear(), a = Pe(n);
532
585
  return /* @__PURE__ */ c(
533
- ue,
586
+ de,
534
587
  {
535
- value: s.find((l) => l.value === e?.toString()),
536
- onChange: (l) => {
537
- if (l && "value" in l) {
538
- const o = parseInt(l.value);
588
+ value: a.find((o) => o.value === e?.toString()),
589
+ onChange: (o) => {
590
+ if (o && "value" in o) {
591
+ const l = parseInt(o.value);
539
592
  if (t) {
540
- const f = new Date(r, o - 1, 1);
541
- O(f);
593
+ const f = new Date(n, l - 1, 1);
594
+ $(f);
542
595
  } else {
543
- const f = new Date(r, o, 1);
544
- O(f);
596
+ const f = new Date(n, l, 1);
597
+ $(f);
545
598
  }
546
599
  }
547
600
  },
548
601
  scrollToSelectedOnOpen: !0,
549
- options: s,
602
+ options: a,
550
603
  className: "w-[95px]",
551
604
  menuWidth: "140px",
552
605
  isSearchable: !0,
553
606
  isClearable: !1,
554
- placeholder: x("calendar.monthPlaceholder")
607
+ placeholder: b("calendar.monthPlaceholder")
555
608
  }
556
609
  );
557
610
  },
558
611
  YearsDropdown: ({ value: e }) => {
559
- const t = d.useContext(de) > 0, a = De();
612
+ const t = u.useContext(me) > 0, s = we();
560
613
  return /* @__PURE__ */ c(
561
- ue,
614
+ de,
562
615
  {
563
- value: a.find((r) => r.value === e?.toString()),
564
- onChange: (r) => {
565
- if (r && "value" in r) {
566
- const s = parseInt(r.value);
616
+ value: s.find((n) => n.value === e?.toString()),
617
+ onChange: (n) => {
618
+ if (n && "value" in n) {
619
+ const a = parseInt(n.value);
567
620
  if (t) {
568
- const l = new Date(A.getFullYear(), A.getMonth() + 1, 1).getMonth(), o = new Date(s, l - 1, 1);
569
- O(o);
621
+ const o = new Date(k.getFullYear(), k.getMonth() + 1, 1).getMonth(), l = new Date(a, o - 1, 1);
622
+ $(l);
570
623
  } else {
571
- const l = new Date(s, A.getMonth(), 1);
572
- O(l);
624
+ const o = new Date(a, k.getMonth(), 1);
625
+ $(o);
573
626
  }
574
627
  }
575
628
  },
576
629
  scrollToSelectedOnOpen: !0,
577
- options: a,
630
+ options: s,
578
631
  className: "w-[76px]",
579
632
  menuWidth: "140px",
580
633
  isSearchable: !0,
581
634
  isClearable: !1,
582
- placeholder: x("calendar.yearPlaceholder")
635
+ placeholder: b("calendar.yearPlaceholder")
583
636
  }
584
637
  );
585
638
  },
586
639
  DayButton: (e) => /* @__PURE__ */ c(
587
- Qe,
640
+ Ze,
588
641
  {
589
642
  ...e,
590
643
  pickerType: m
591
644
  }
592
645
  ),
593
- WeekNumber: ({ week: e, ...n }) => {
594
- const t = e.days.find((E) => !E.outside)?.date;
646
+ WeekNumber: ({ week: e, ...r }) => {
647
+ const t = e.days.find((I) => !I.outside)?.date;
595
648
  if (!t)
596
- return /* @__PURE__ */ c("td", { ...n, className: u("select-none flex items-center justify-center h-8 text-[11px] text-content-muted w-8 flex-shrink-0 rdp-week_number", n.className), children: /* @__PURE__ */ c("div", { className: "flex size-[--cell-size] items-center justify-center text-center" }) });
597
- const a = t.getFullYear(), r = t.getMonth(), o = (new Date(a, r, 1).getDay() + 7 - K) % 7, f = new Date(a, r, 1 - o), i = new Date(t), h = (t.getDay() + 7 - K) % 7;
649
+ return /* @__PURE__ */ c("td", { ...r, className: d("select-none flex items-center justify-center h-8 text-[11px] text-content-muted w-8 flex-shrink-0 rdp-week_number", r.className), children: /* @__PURE__ */ c("div", { className: "flex size-[--cell-size] items-center justify-center text-center" }) });
650
+ const s = t.getFullYear(), n = t.getMonth(), l = (new Date(s, n, 1).getDay() + 7 - q) % 7, f = new Date(s, n, 1 - l), i = new Date(t), h = (t.getDay() + 7 - q) % 7;
598
651
  i.setDate(t.getDate() - h);
599
- const S = Math.round((i.getTime() - f.getTime()) / (10080 * 60 * 1e3)) + 1, z = x("calendar.weekLabel", { number: S });
652
+ const C = Math.round((i.getTime() - f.getTime()) / (10080 * 60 * 1e3)) + 1, E = b("calendar.weekLabel", { number: C });
600
653
  if (m === "week") {
601
- const E = () => {
654
+ const I = () => {
602
655
  t && fe(ce(t));
603
656
  };
604
657
  return /* @__PURE__ */ c(
605
658
  "td",
606
659
  {
607
- "aria-label": z,
608
- "data-week-index": S,
609
- "data-week-number": S,
660
+ "aria-label": E,
661
+ "data-week-index": C,
662
+ "data-week-number": C,
610
663
  tabIndex: 0,
611
664
  role: "button",
612
- className: u(
665
+ className: d(
613
666
  "select-none flex items-center justify-center h-[30px] w-[30px] flex-shrink-0 rdp-week_number cursor-pointer hover:bg-accent hover:text-accent-foreground group-hover/week:bg-accent group-hover/week:rounded-l-lg rounded-lg transition-colors"
614
667
  ),
615
- onClick: (H) => {
616
- H.preventDefault(), H.stopPropagation(), E();
668
+ onClick: (F) => {
669
+ F.preventDefault(), F.stopPropagation(), I();
617
670
  },
618
- onKeyDown: (H) => {
619
- (H.key === "Enter" || H.key === " ") && (H.preventDefault(), H.stopPropagation(), E());
671
+ onKeyDown: (F) => {
672
+ (F.key === "Enter" || F.key === " ") && (F.preventDefault(), F.stopPropagation(), I());
620
673
  },
621
- children: /* @__PURE__ */ c("div", { className: "flex h-8 w-full items-center justify-center text-center text-[11px] text-content-muted", children: x("calendar.weekNumber", { number: S }) })
674
+ children: /* @__PURE__ */ c("div", { className: "flex h-8 w-full items-center justify-center text-center text-[11px] text-content-muted", children: b("calendar.weekNumber", { number: C }) })
622
675
  }
623
676
  );
624
677
  }
625
678
  return /* @__PURE__ */ c(
626
679
  "td",
627
680
  {
628
- ...n,
629
- "aria-label": z,
630
- className: u(
681
+ ...r,
682
+ "aria-label": E,
683
+ className: d(
631
684
  "select-none flex items-center justify-center h-[30px] text-[11px] text-content-muted w-[30px] flex-shrink-0 rdp-week_number",
632
- n.className
685
+ r.className
633
686
  ),
634
687
  scope: "row",
635
688
  role: "rowheader",
636
- children: /* @__PURE__ */ c("div", { className: "flex h-8 w-full items-center justify-center text-center", children: x("calendar.weekNumber", { number: S }) })
689
+ children: /* @__PURE__ */ c("div", { className: "flex h-8 w-full items-center justify-center text-center", children: b("calendar.weekNumber", { number: C }) })
637
690
  }
638
691
  );
639
692
  },
640
693
  ...Ce
641
694
  },
642
- ...ee
695
+ ...K
643
696
  }
644
697
  )
645
698
  ),
646
- b && /* @__PURE__ */ Y("div", { className: u("flex items-center gap-2 border-t pt-3 p-3", m === "month" && w !== "single" || F === "range" || p === "range" || p === "multiple" ? "justify-between" : "justify-end"), children: [
647
- F === "range" && m === "date" && /* @__PURE__ */ Y("div", { className: "flex flex-row items-center gap-1 text-content-tertiary text-xs leading-[18px] font-medium", children: [
699
+ x && /* @__PURE__ */ Y("div", { className: d("flex items-center gap-2 border-t pt-3 p-3", m === "month" && w !== "single" || W === "range" || v === "range" || v === "multiple" ? "justify-between" : "justify-end"), children: [
700
+ W === "range" && m === "date" && /* @__PURE__ */ Y("div", { className: "flex flex-row items-center gap-1 text-content-tertiary text-xs leading-[18px] font-medium", children: [
648
701
  "Selected:",
649
702
  /* @__PURE__ */ c("span", { className: "text-content font-semibold", children: (() => {
650
- const e = q;
703
+ const e = H;
651
704
  if (e?.from && e?.to) {
652
- const n = Math.abs(e.to.getTime() - e.from.getTime()), t = Math.ceil(n / (1e3 * 60 * 60 * 24)) + 1;
705
+ const r = Math.abs(e.to.getTime() - e.from.getTime()), t = Math.ceil(r / (1e3 * 60 * 60 * 24)) + 1;
653
706
  return `${t} day${t !== 1 ? "s" : ""}`;
654
707
  }
655
708
  return "0 days";
656
709
  })() })
657
710
  ] }),
658
- m === "week" && (p === "range" || p === "multiple") && /* @__PURE__ */ Y("div", { className: "flex flex-row items-center gap-1 text-content-tertiary text-xs leading-[18px] font-medium", children: [
711
+ m === "week" && (v === "range" || v === "multiple") && /* @__PURE__ */ Y("div", { className: "flex flex-row items-center gap-1 text-content-tertiary text-xs leading-[18px] font-medium", children: [
659
712
  "Selected:",
660
713
  /* @__PURE__ */ c("span", { className: "text-content font-semibold", children: (() => {
661
- const e = $;
714
+ const e = j;
662
715
  if (!e) return "0 weeks";
663
- const n = (o) => Date.UTC(o.getFullYear(), o.getMonth(), o.getDate()), t = (o) => {
664
- const f = Math.floor(o / 7), i = o % 7, g = [];
716
+ const r = (l) => Date.UTC(l.getFullYear(), l.getMonth(), l.getDate()), t = (l) => {
717
+ const f = Math.floor(l / 7), i = l % 7, g = [];
665
718
  return f > 0 && g.push(`${f} week${f !== 1 ? "s" : ""}`), (i > 0 || f === 0) && g.push(`${i} day${i !== 1 ? "s" : ""}`), g.join(" ");
666
- }, a = P === "fiscal" && oe === "fiscalMonth", r = P === "fiscal", s = a ? "fiscal month" : r ? "fiscal week" : "week", l = a ? "fiscal months" : r ? "fiscal weeks" : "weeks";
719
+ }, s = P === "fiscal" && le === "fiscalMonth", n = P === "fiscal", a = s ? "fiscal month" : n ? "fiscal week" : "week", o = s ? "fiscal months" : n ? "fiscal weeks" : "weeks";
667
720
  if (Array.isArray(e))
668
- if (r || a) {
669
- const o = e.length;
670
- return `${o} ${o !== 1 ? l : s}`;
721
+ if (n || s) {
722
+ const l = e.length;
723
+ return `${l} ${l !== 1 ? o : a}`;
671
724
  } else {
672
- let o = 0;
725
+ let l = 0;
673
726
  return e.forEach((f) => {
674
- const i = n(f.startDate), g = n(f.endDate);
675
- o += Math.round((g - i) / (1e3 * 60 * 60 * 24)) + 1;
676
- }), t(o);
727
+ const i = r(f.startDate), g = r(f.endDate);
728
+ l += Math.round((g - i) / (1e3 * 60 * 60 * 24)) + 1;
729
+ }), t(l);
677
730
  }
678
731
  else if ("from" in e) {
679
- const { from: o, to: f } = e;
680
- if (a) {
681
- if (!f) return `1 ${s}`;
682
- const i = n(o.startDate), g = n(f.endDate), h = Math.round(Math.abs(g - i) / (1e3 * 60 * 60 * 24)) + 1, j = ne ? ne.reduce((z, E) => z + E, 0) / 12 : 4.33, S = Math.max(1, Math.round(h / (j * 7)));
683
- return `${S} ${S !== 1 ? l : s}`;
684
- } else if (r) {
685
- if (!f) return `1 ${s}`;
686
- const i = n(o.startDate), g = n(f.endDate), h = Math.round((g - i) / (10080 * 60 * 1e3)), j = h > 0 ? h : 1;
687
- return `${j} ${j !== 1 ? l : s}`;
732
+ const { from: l, to: f } = e;
733
+ if (s) {
734
+ if (!f) return `1 ${a}`;
735
+ const i = r(l.startDate), g = r(f.endDate), h = Math.round(Math.abs(g - i) / (1e3 * 60 * 60 * 24)) + 1, z = ne ? ne.reduce((E, I) => E + I, 0) / 12 : 4.33, C = Math.max(1, Math.round(h / (z * 7)));
736
+ return `${C} ${C !== 1 ? o : a}`;
737
+ } else if (n) {
738
+ if (!f) return `1 ${a}`;
739
+ const i = r(l.startDate), g = r(f.endDate), h = Math.round((g - i) / (10080 * 60 * 1e3)), z = h > 0 ? h : 1;
740
+ return `${z} ${z !== 1 ? o : a}`;
688
741
  } else {
689
742
  if (!f) {
690
- const j = n(o.startDate), S = n(o.endDate), z = Math.round((S - j) / (1e3 * 60 * 60 * 24)) + 1;
691
- return t(z);
743
+ const z = r(l.startDate), C = r(l.endDate), E = Math.round((C - z) / (1e3 * 60 * 60 * 24)) + 1;
744
+ return t(E);
692
745
  }
693
- const i = n(o.startDate), g = n(f.endDate), h = Math.round(Math.abs(g - i) / (1e3 * 60 * 60 * 24)) + 1;
746
+ const i = r(l.startDate), g = r(f.endDate), h = Math.round(Math.abs(g - i) / (1e3 * 60 * 60 * 24)) + 1;
694
747
  return t(h);
695
748
  }
696
749
  } else
697
- return `1 ${s}`;
750
+ return `1 ${a}`;
698
751
  })() })
699
752
  ] }),
700
753
  m === "month" && (w === "range" || w === "multiple") && /* @__PURE__ */ Y("div", { className: "flex flex-row items-center gap-1 text-content-tertiary text-xs leading-[18px] font-medium", children: [
701
754
  "Selected:",
702
755
  /* @__PURE__ */ c("span", { className: "text-content font-semibold", children: (() => {
703
- const e = M;
756
+ const e = A;
704
757
  if (!e) return "0 months";
705
758
  if (Array.isArray(e)) {
706
- const n = e.length;
707
- return n === 1 ? x("calendar.monthRange") : x("calendar.monthRangePlural", { count: n });
759
+ const r = e.length;
760
+ return r === 1 ? b("calendar.monthRange") : b("calendar.monthRangePlural", { count: r });
708
761
  } else if ("from" in e) {
709
- const n = e;
710
- if (!n.from || !n.to) return x("calendar.monthRange");
711
- const t = new Date(n.from.year, n.from.month, 1), a = new Date(n.to.year, n.to.month, 1), r = (a.getFullYear() - t.getFullYear()) * 12 + (a.getMonth() - t.getMonth()) + 1;
712
- return r === 1 ? x("calendar.monthRange") : x("calendar.monthRangePlural", { count: r });
762
+ const r = e;
763
+ if (!r.from || !r.to) return b("calendar.monthRange");
764
+ const t = new Date(r.from.year, r.from.month, 1), s = new Date(r.to.year, r.to.month, 1), n = (s.getFullYear() - t.getFullYear()) * 12 + (s.getMonth() - t.getMonth()) + 1;
765
+ return n === 1 ? b("calendar.monthRange") : b("calendar.monthRangePlural", { count: n });
713
766
  } else
714
- return x("calendar.monthRange");
767
+ return b("calendar.monthRange");
715
768
  })() })
716
769
  ] }),
717
770
  /* @__PURE__ */ Y("div", { className: "flex items-center gap-2", children: [
718
771
  /* @__PURE__ */ c(
719
- I,
772
+ R,
720
773
  {
721
774
  variant: "link",
722
775
  size: "sm",
723
- onClick: Oe,
724
- children: x("calendar.clear")
776
+ onClick: He,
777
+ children: b("calendar.clear")
725
778
  }
726
779
  ),
727
780
  /* @__PURE__ */ c(
728
- I,
781
+ R,
729
782
  {
730
783
  variant: "outline",
731
784
  size: "sm",
732
- onClick: $e,
733
- children: x("calendar.cancel")
785
+ onClick: Ue,
786
+ children: b("calendar.cancel")
734
787
  }
735
788
  ),
736
789
  /* @__PURE__ */ c(
737
- I,
790
+ R,
738
791
  {
739
792
  variant: "default",
740
793
  size: "sm",
741
- onClick: Le,
742
- children: x("calendar.apply")
794
+ onClick: $e,
795
+ disabled: _e || Ke,
796
+ children: b("calendar.apply")
743
797
  }
744
798
  )
745
799
  ] })
746
800
  ] })
747
801
  ] });
748
802
  }
749
- function Qe({
750
- className: le,
751
- day: J,
803
+ function Ze({
804
+ className: oe,
805
+ day: Q,
752
806
  modifiers: y,
753
- pickerType: Q,
754
- ...B
807
+ pickerType: X,
808
+ ...T
755
809
  }) {
756
- const X = d.useRef(null);
757
- return d.useEffect(() => {
758
- y.focused && X.current?.focus();
810
+ const Z = u.useRef(null);
811
+ return u.useEffect(() => {
812
+ y.focused && Z.current?.focus();
759
813
  }, [y.focused]), /* @__PURE__ */ c(
760
- I,
814
+ R,
761
815
  {
762
- ref: X,
816
+ ref: Z,
763
817
  variant: "ghost",
764
818
  size: "sm",
765
- "data-day": J.date.toLocaleDateString(),
819
+ "data-day": Q.date.toLocaleDateString(),
766
820
  "data-selected-single": y.selected && !y.range_start && !y.range_end && !y.range_middle,
767
821
  "data-range-start": y.range_start,
768
822
  "data-range-end": y.range_end,
769
823
  "data-range-middle": y.range_middle,
770
- className: u(
824
+ className: d(
771
825
  "gap-2 whitespace-nowrap focus-visible:ring-1 focus-visible:ring-focus-ring disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 px-3 rounded-lg flex items-center justify-center font-normal transition-colors w-5 h-5 border border-transparent focus-visible:outline-none text-sm rdp-day rdp-day_button",
772
826
  // Hover styling
773
- Q !== "week" && "hover:bg-accent hover:text-accent-foreground hover:border-brand",
774
- Q === "week" && "hover:bg-transparent hover:text-inherit hover:border-transparent",
827
+ X !== "week" && "hover:bg-accent hover:text-accent-foreground hover:border-brand",
828
+ X === "week" && "hover:bg-transparent hover:text-inherit hover:border-transparent",
775
829
  // Selection state
776
830
  "data-[selected-single=true]:bg-brand data-[selected-single=true]:text-brand-foreground data-[selected-single=true]:rounded-lg data-[selected-single=true]:border-transparent",
777
831
  "data-[range-start=true]:bg-brand data-[range-start=true]:text-brand-foreground data-[range-start=true]:rounded-lg data-[range-start=true]:border-transparent",
778
832
  "data-[range-end=true]:bg-brand data-[range-end=true]:text-brand-foreground data-[range-end=true]:rounded-lg data-[range-end=true]:border-transparent",
779
833
  "data-[range-middle=true]:text-accent-foreground data-[range-middle=true]:rounded-none",
780
- le
834
+ oe
781
835
  ),
782
836
  "data-component": "calendar-day",
783
- ...B,
784
- disabled: B.disabled || y.disabled
837
+ ...T,
838
+ disabled: T.disabled || y.disabled
785
839
  }
786
840
  );
787
841
  }
788
842
  export {
789
- ot as Calendar,
790
- Qe as CalendarDayButton
843
+ it as Calendar,
844
+ Ze as CalendarDayButton
791
845
  };