@aiquants/period-slider 0.2.0 → 0.4.0

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.
package/dist/index.js CHANGED
@@ -1,326 +1,7 @@
1
- import { jsxs as le, jsx as T, Fragment as Ta } from "react/jsx-runtime";
2
- import { addDays as Wt, getDaysInMonth as Na, format as Nt, parseISO as Ca } from "date-fns";
3
- import { memo as Ct, useState as De, useMemo as R, useEffect as ot, useId as Xa, useRef as Q, useCallback as K } from "react";
4
- function Ka(e, t, a, r) {
5
- if (r && r.length > 0)
6
- return r.filter((n) => n && !Number.isNaN(n.getTime())).map((n) => {
7
- const b = new Date(n);
8
- return b.setHours(0, 0, 0, 0), b;
9
- }).sort((n, b) => b.getTime() - n.getTime()).map((n) => {
10
- const b = Nt(n, "yyyy-MM-dd");
11
- return { label: b, value: b };
12
- });
13
- const l = e.getFullYear(), s = t ?? new Date(l - 1, 0, 1), d = a ?? new Date(l + 1, 11, 31), h = new Date(Math.min(s.getTime(), e.getTime()));
14
- h.setHours(0, 0, 0, 0);
15
- const u = new Date(Math.max(d.getTime(), e.getTime()));
16
- u.setHours(0, 0, 0, 0);
17
- const m = [];
18
- let p = u;
19
- for (; p >= h; ) {
20
- const A = Nt(p, "yyyy-MM-dd");
21
- m.push({ label: A, value: A }), p = Wt(p, -1);
22
- }
23
- return m;
24
- }
25
- const ja = (e) => {
26
- const { value: t, initialDate: a, onChange: r, children: l, minYear: s, maxYear: d, minDate: h, maxDate: u, allowedDates: m, variant: p = "dropdown", className: A = "", style: n, disabled: b = !1, prevDateAriaLabel: W = "前日", nextDateAriaLabel: z = "翌日", selectAriaLabel: P = "年月日" } = e, F = t ?? a, [B, V] = De(() => {
27
- const o = new Date(F ?? /* @__PURE__ */ new Date());
28
- return o.setHours(0, 0, 0, 0), o;
29
- }), O = t !== void 0, f = R(() => {
30
- if (O) {
31
- if (t && !Number.isNaN(t.getTime())) {
32
- const H = new Date(t);
33
- return H.setHours(0, 0, 0, 0), H;
34
- }
35
- const o = /* @__PURE__ */ new Date();
36
- return o.setHours(0, 0, 0, 0), o;
37
- }
38
- return B;
39
- }, [O, t?.getTime(), B]), I = h?.getTime(), v = u?.getTime(), M = R(() => {
40
- if (h) {
41
- const o = new Date(h);
42
- return o.setHours(0, 0, 0, 0), o;
43
- }
44
- if (s !== void 0) {
45
- const o = new Date(s, 0, 1);
46
- return o.setFullYear(s), o.setHours(0, 0, 0, 0), o;
47
- }
48
- return null;
49
- }, [I, s]), x = R(() => {
50
- if (u) {
51
- const o = new Date(u);
52
- return o.setHours(0, 0, 0, 0), o;
53
- }
54
- if (d !== void 0) {
55
- const o = new Date(d, 11, 31);
56
- return o.setFullYear(d), o.setHours(0, 0, 0, 0), o;
57
- }
58
- return null;
59
- }, [v, d]), oe = F?.getTime();
60
- ot(() => {
61
- if (!O && F && !Number.isNaN(F.getTime())) {
62
- const o = new Date(F);
63
- o.setHours(0, 0, 0, 0), V(o);
64
- }
65
- }, [O, oe]);
66
- const N = (o) => {
67
- if (b) return;
68
- let H = new Date(o);
69
- H.setHours(0, 0, 0, 0), M && H < M && (H = new Date(M)), x && H > x && (H = new Date(x)), O || V(H), r?.(H);
70
- }, G = R(() => Wt(f, -1), [f]), k = R(() => Wt(f, 1), [f]), j = b || M !== null && G < M, q = b || x !== null && k > x, fe = () => N(G), me = () => N(k), se = (o) => {
71
- if (o.target.value) {
72
- const H = Ca(o.target.value);
73
- Number.isNaN(H.getTime()) || N(H);
74
- }
75
- }, ee = (o) => {
76
- if (o.target.value) {
77
- const H = Ca(o.target.value);
78
- Number.isNaN(H.getTime()) || N(H);
79
- }
80
- }, X = f.getFullYear(), de = f.getMonth() + 1, Ve = f.getDate(), xe = M?.getTime() ?? null, Ye = x?.getTime() ?? null, Re = f.getTime(), we = R(() => {
81
- if (m && m.length > 0)
82
- return m.map((ke) => ke.getTime()).join(",");
83
- const o = xe ?? new Date(X - 1, 0, 1).getTime(), H = Ye ?? new Date(X + 1, 11, 31).getTime(), w = Math.min(o, Re), pe = Math.max(H, Re);
84
- return `${w}_${pe}`;
85
- }, [m, xe, Ye, Re, X]), je = R(() => p !== "dropdown" ? [] : Ka(f, M, x, m), [p, we, f]), Ee = R(() => {
86
- if (p !== "split-dropdown") return [];
87
- const o = M ? M.getFullYear() : X - 10, H = x ? x.getFullYear() : X + 1, w = Math.min(o, X), pe = Math.max(H, X), ke = [];
88
- for (let Ie = pe; Ie >= w; Ie--)
89
- ke.push(Ie);
90
- return ke;
91
- }, [p, M, x, X]), L = R(() => {
92
- if (p !== "split-dropdown") return [];
93
- let o = 1, H = 12;
94
- M && X === M.getFullYear() && (o = M.getMonth() + 1), x && X === x.getFullYear() && (H = x.getMonth() + 1);
95
- const w = [];
96
- for (let pe = o; pe <= H; pe++)
97
- w.push(pe);
98
- return w;
99
- }, [p, M, x, X]), S = R(() => {
100
- if (p !== "split-dropdown") return [];
101
- const o = Na(f);
102
- let H = 1, w = o;
103
- M && X === M.getFullYear() && de === M.getMonth() + 1 && (H = M.getDate()), x && X === x.getFullYear() && de === x.getMonth() + 1 && (w = x.getDate());
104
- const pe = [];
105
- for (let ke = H; ke <= w; ke++)
106
- pe.push(ke);
107
- return pe;
108
- }, [p, M, x, f, X, de]), Z = (o, H, w) => {
109
- const pe = Na(new Date(o, H - 1, 1)), ke = Math.min(w, pe), Ie = new Date(o, H - 1, ke);
110
- Ie.setFullYear(o), N(Ie);
111
- }, ae = Nt(f, "yyyy-MM-dd"), Y = M ? Nt(M, "yyyy-MM-dd") : void 0, ie = x ? Nt(x, "yyyy-MM-dd") : void 0;
112
- return /* @__PURE__ */ le("div", { className: `inline-flex items-center ${p === "split-dropdown" ? "w-auto" : "w-38"} ${A}`, style: n, children: [
113
- /* @__PURE__ */ T(
114
- "button",
115
- {
116
- type: "button",
117
- "aria-label": W,
118
- disabled: j,
119
- className: "relative my-auto inline-flex h-5 w-4 cursor-pointer items-center justify-center rounded p-0 after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 disabled:opacity-40",
120
- onClick: fe,
121
- children: /* @__PURE__ */ T("span", { className: "h-0 w-0 border-y-[6px] border-y-transparent border-r-[6px] border-r-slate-500 border-solid hover:border-r-slate-700 dark:border-r-slate-400 dark:hover:border-r-slate-200" })
122
- }
123
- ),
124
- p === "dropdown" ? /* @__PURE__ */ T("select", { "aria-label": P, disabled: b, className: "mx-1 my-auto w-28 appearance-none rounded-md border border-gray-300 bg-gray-100 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums [text-align-last:center] [text-align:center] focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500", value: ae, onChange: ee, children: je.map((o) => /* @__PURE__ */ T("option", { value: o.value, className: "text-center font-mono text-gray-900 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-100", children: o.label }, o.value)) }) : p === "split-dropdown" ? /* @__PURE__ */ le("div", { className: "mx-1 my-auto inline-flex items-center gap-1", children: [
125
- /* @__PURE__ */ T(
126
- "select",
127
- {
128
- "aria-label": "年",
129
- disabled: b,
130
- className: "rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100",
131
- value: X,
132
- onChange: (o) => Z(Number(o.target.value), de, Ve),
133
- children: Ee.map((o) => /* @__PURE__ */ le("option", { value: o, className: "dark:bg-slate-700 dark:text-slate-100", children: [
134
- o,
135
- "年"
136
- ] }, o))
137
- }
138
- ),
139
- /* @__PURE__ */ T(
140
- "select",
141
- {
142
- "aria-label": "月",
143
- disabled: b,
144
- className: "rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100",
145
- value: de,
146
- onChange: (o) => Z(X, Number(o.target.value), Ve),
147
- children: L.map((o) => /* @__PURE__ */ le("option", { value: o, className: "dark:bg-slate-700 dark:text-slate-100", children: [
148
- String(o).padStart(2, "0"),
149
- "月"
150
- ] }, o))
151
- }
152
- ),
153
- /* @__PURE__ */ T(
154
- "select",
155
- {
156
- "aria-label": "日",
157
- disabled: b,
158
- className: "rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100",
159
- value: Ve,
160
- onChange: (o) => Z(X, de, Number(o.target.value)),
161
- children: S.map((o) => /* @__PURE__ */ le("option", { value: o, className: "dark:bg-slate-700 dark:text-slate-100", children: [
162
- String(o).padStart(2, "0"),
163
- "日"
164
- ] }, o))
165
- }
166
- )
167
- ] }) : /* @__PURE__ */ T(
168
- "input",
169
- {
170
- "aria-label": P,
171
- disabled: b,
172
- className: "mx-1 my-auto w-28 rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-gray-900 text-xs focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500 dark:placeholder:text-gray-400",
173
- value: ae,
174
- min: Y,
175
- max: ie,
176
- onChange: se,
177
- type: "date"
178
- }
179
- ),
180
- /* @__PURE__ */ T(
181
- "button",
182
- {
183
- type: "button",
184
- "aria-label": z,
185
- disabled: q,
186
- className: "relative my-auto inline-flex h-5 w-4 cursor-pointer items-center justify-center rounded p-0 after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 disabled:opacity-40",
187
- onClick: me,
188
- children: /* @__PURE__ */ T("span", { className: "h-0 w-0 border-y-[6px] border-y-transparent border-l-[6px] border-l-slate-500 border-solid hover:border-l-slate-700 dark:border-l-slate-400 dark:hover:border-l-slate-200" })
189
- }
190
- ),
191
- l
192
- ] });
193
- }, _a = Ct(ja, (e, t) => {
194
- const a = e.value ?? e.initialDate, r = t.value ?? t.initialDate, l = a && !Number.isNaN(a.getTime()) ? a.getFullYear() * 1e4 + (a.getMonth() + 1) * 100 + a.getDate() : null, s = r && !Number.isNaN(r.getTime()) ? r.getFullYear() * 1e4 + (r.getMonth() + 1) * 100 + r.getDate() : null;
195
- if (l !== s || e.variant !== t.variant || e.disabled !== t.disabled || e.className !== t.className || e.style !== t.style || e.minYear !== t.minYear || e.maxYear !== t.maxYear) return !1;
196
- const d = e.minDate && !Number.isNaN(e.minDate.getTime()) ? e.minDate.getFullYear() * 1e4 + (e.minDate.getMonth() + 1) * 100 + e.minDate.getDate() : null, h = t.minDate && !Number.isNaN(t.minDate.getTime()) ? t.minDate.getFullYear() * 1e4 + (t.minDate.getMonth() + 1) * 100 + t.minDate.getDate() : null;
197
- if (d !== h) return !1;
198
- const u = e.maxDate && !Number.isNaN(e.maxDate.getTime()) ? e.maxDate.getFullYear() * 1e4 + (e.maxDate.getMonth() + 1) * 100 + e.maxDate.getDate() : null, m = t.maxDate && !Number.isNaN(t.maxDate.getTime()) ? t.maxDate.getFullYear() * 1e4 + (t.maxDate.getMonth() + 1) * 100 + t.maxDate.getDate() : null;
199
- return !(u !== m || e.onChange !== t.onChange || e.allowedDates !== t.allowedDates || e.children !== t.children || e.prevDateAriaLabel !== t.prevDateAriaLabel || e.nextDateAriaLabel !== t.nextDateAriaLabel || e.selectAriaLabel !== t.selectAriaLabel);
200
- });
201
- _a.displayName = "DateSelector";
202
- function Ga(e, t, a, r, l) {
203
- const s = e.getFullYear(), d = t ?? (r ? r.getFullYear() : s - 5), h = a ?? (l ? l.getFullYear() : s + 5), u = Math.min(d, s), m = Math.max(h, s), p = r ? new Date(r.getFullYear(), r.getMonth(), 1).getTime() : null, A = l ? new Date(l.getFullYear(), l.getMonth(), 1).getTime() : null, n = [];
204
- for (let b = m; b >= u; b--)
205
- for (let W = 12; W >= 1; W--) {
206
- const z = new Date(b, W - 1, 1);
207
- z.setFullYear(b);
208
- const P = z.getTime();
209
- if (p !== null && P < p || A !== null && P > A) continue;
210
- const F = String(W).padStart(2, "0"), B = `${b}-${F}`;
211
- n.push({ label: B, value: B });
212
- }
213
- return n;
214
- }
215
- const Wa = (e) => {
216
- const { value: t, initialDate: a, onChange: r, children: l, variant: s = "date", minYear: d, maxYear: h, minDate: u, maxDate: m, isWarning: p = !1, className: A = "", style: n, disabled: b = !1, prevMonthAriaLabel: W = "前月", nextMonthAriaLabel: z = "翌月", selectAriaLabel: P = "年月" } = e, F = t ?? a, [B, V] = De(() => {
217
- const Y = F ?? /* @__PURE__ */ new Date(), ie = new Date(Y.getFullYear(), Y.getMonth(), 1);
218
- return ie.setFullYear(Y.getFullYear()), ie;
219
- }), O = t !== void 0, f = R(() => {
220
- if (O) {
221
- if (t && !Number.isNaN(t.getTime())) {
222
- const Y = new Date(t.getFullYear(), t.getMonth(), 1);
223
- return Y.setFullYear(t.getFullYear()), Y;
224
- }
225
- return /* @__PURE__ */ new Date();
226
- }
227
- return B;
228
- }, [O, t?.getTime(), B]), I = u?.getTime(), v = m?.getTime(), M = R(() => {
229
- if (u) {
230
- const Y = new Date(u.getFullYear(), u.getMonth(), 1);
231
- return Y.setFullYear(u.getFullYear()), Y;
232
- }
233
- if (d !== void 0) {
234
- const Y = new Date(d, 0, 1);
235
- return Y.setFullYear(d), Y;
236
- }
237
- return null;
238
- }, [I, d]), x = R(() => {
239
- if (m) {
240
- const Y = new Date(m.getFullYear(), m.getMonth(), 1);
241
- return Y.setFullYear(m.getFullYear()), Y;
242
- }
243
- if (h !== void 0) {
244
- const Y = new Date(h, 11, 1);
245
- return Y.setFullYear(h), Y;
246
- }
247
- return null;
248
- }, [v, h]), oe = F?.getTime();
249
- ot(() => {
250
- if (!O && F && !Number.isNaN(F.getTime())) {
251
- const Y = new Date(F.getFullYear(), F.getMonth(), 1);
252
- Y.setFullYear(F.getFullYear()), V(Y);
253
- }
254
- }, [O, oe]);
255
- const N = (Y) => {
256
- if (b) return;
257
- let ie = Y;
258
- M && ie < M && (ie = new Date(M)), x && ie > x && (ie = new Date(x)), O || V(ie);
259
- const ne = ie.getFullYear() * 100 + (ie.getMonth() + 1);
260
- r?.(ie, ne);
261
- }, G = R(() => {
262
- const Y = new Date(f.getFullYear(), f.getMonth() - 1, 1);
263
- return Y.setFullYear(f.getMonth() === 0 ? f.getFullYear() - 1 : f.getFullYear()), Y;
264
- }, [f]), k = R(() => {
265
- const Y = new Date(f.getFullYear(), f.getMonth() + 1, 1);
266
- return Y.setFullYear(f.getMonth() === 11 ? f.getFullYear() + 1 : f.getFullYear()), Y;
267
- }, [f]), j = b || M !== null && G < M, q = b || x !== null && k > x, fe = () => {
268
- N(G);
269
- }, me = () => {
270
- N(k);
271
- }, se = (Y) => {
272
- const ie = Y.target.value;
273
- if (!ie) return;
274
- const [ne, ce] = ie.split("-"), o = Number(ne), H = Number(ce) - 1;
275
- if (!(Number.isNaN(o) || Number.isNaN(H))) {
276
- const w = new Date(o, H, 1);
277
- w.setFullYear(o), N(w);
278
- }
279
- }, ee = (Y) => {
280
- const ie = Y.target.value;
281
- if (!ie) return;
282
- const [ne, ce] = ie.split("-"), o = Number(ne), H = Number(ce) - 1;
283
- if (!(Number.isNaN(o) || Number.isNaN(H))) {
284
- const w = new Date(o, H, 1);
285
- w.setFullYear(o), N(w);
286
- }
287
- }, X = `${f.getFullYear()}-${String(f.getMonth() + 1).padStart(2, "0")}`, de = M ? `${M.getFullYear()}-${String(M.getMonth() + 1).padStart(2, "0")}` : void 0, Ve = x ? `${x.getFullYear()}-${String(x.getMonth() + 1).padStart(2, "0")}` : void 0, xe = f.getFullYear(), Ye = d ?? (u ? u.getFullYear() : xe - 5), Re = h ?? (m ? m.getFullYear() : xe + 5), we = Math.min(Ye, xe), je = Math.max(Re, xe), Ee = `${we}_${je}_${I ?? "none"}_${v ?? "none"}`, L = R(() => s !== "dropdown" ? [] : Ga(f, d, h, u, m), [s, Ee, f]), S = p ? "border-amber-300 bg-amber-50 text-amber-900 focus:border-amber-500 focus:ring-amber-500 dark:border-amber-900/50 dark:bg-amber-950/20 dark:text-amber-200" : "border-gray-300 bg-gray-100 text-gray-900 focus:border-blue-500 focus:ring-blue-500 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500", Z = `mx-1 my-auto w-28 rounded-md border py-0.5 px-1 text-xs dark:placeholder:text-gray-400 disabled:opacity-50 ${S}`, ae = `mx-1 my-auto w-28 appearance-none rounded-md border px-1 py-0.5 text-center font-mono text-xs tabular-nums [text-align-last:center] [text-align:center] focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 ${S}`;
288
- return /* @__PURE__ */ le("div", { className: `inline-flex w-38 items-center ${A}`, style: n, children: [
289
- /* @__PURE__ */ T(
290
- "button",
291
- {
292
- type: "button",
293
- "aria-label": W,
294
- disabled: j,
295
- className: "relative my-auto inline-flex h-5 w-4 cursor-pointer items-center justify-center rounded p-0 after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 disabled:opacity-40",
296
- onClick: fe,
297
- children: /* @__PURE__ */ T("span", { className: "h-0 w-0 border-y-[6px] border-y-transparent border-r-[6px] border-r-slate-500 border-solid hover:border-r-slate-700 dark:border-r-slate-400 dark:hover:border-r-slate-200" })
298
- }
299
- ),
300
- s === "dropdown" ? /* @__PURE__ */ T("select", { "aria-label": P, disabled: b, className: ae, value: X, onChange: ee, children: L.map((Y) => /* @__PURE__ */ T("option", { value: Y.value, className: "text-center font-mono text-gray-900 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-100", children: Y.label }, Y.value)) }) : /* @__PURE__ */ T("input", { "aria-label": P, disabled: b, className: Z, value: X, min: de, max: Ve, onChange: se, type: "month" }),
301
- /* @__PURE__ */ T(
302
- "button",
303
- {
304
- type: "button",
305
- "aria-label": z,
306
- disabled: q,
307
- className: "relative my-auto inline-flex h-5 w-4 cursor-pointer items-center justify-center rounded p-0 after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 disabled:opacity-40",
308
- onClick: me,
309
- children: /* @__PURE__ */ T("span", { className: "h-0 w-0 border-y-[6px] border-y-transparent border-l-[6px] border-l-slate-500 border-solid hover:border-l-slate-700 dark:border-l-slate-400 dark:hover:border-l-slate-200" })
310
- }
311
- ),
312
- l
313
- ] });
314
- }, qa = Ct(Wa, (e, t) => {
315
- const a = e.value ?? e.initialDate, r = t.value ?? t.initialDate, l = a && !Number.isNaN(a.getTime()) ? a.getFullYear() * 12 + a.getMonth() : null, s = r && !Number.isNaN(r.getTime()) ? r.getFullYear() * 12 + r.getMonth() : null;
316
- if (l !== s || e.variant !== t.variant || e.disabled !== t.disabled || e.className !== t.className || e.style !== t.style || e.isWarning !== t.isWarning || e.minYear !== t.minYear || e.maxYear !== t.maxYear) return !1;
317
- const d = e.minDate ? e.minDate.getFullYear() * 12 + e.minDate.getMonth() : null, h = t.minDate ? t.minDate.getFullYear() * 12 + t.minDate.getMonth() : null;
318
- if (d !== h) return !1;
319
- const u = e.maxDate ? e.maxDate.getFullYear() * 12 + e.maxDate.getMonth() : null, m = t.maxDate ? t.maxDate.getFullYear() * 12 + t.maxDate.getMonth() : null;
320
- return !(u !== m || e.onChange !== t.onChange || e.children !== t.children || e.prevMonthAriaLabel !== t.prevMonthAriaLabel || e.nextMonthAriaLabel !== t.nextMonthAriaLabel || e.selectAriaLabel !== t.selectAriaLabel);
321
- });
322
- qa.displayName = "MonthSelector";
323
- const La = {
1
+ import { jsx as w, jsxs as le, Fragment as ln } from "react/jsx-runtime";
2
+ import { addYears as Un, addMonths as Bn, addDays as Dr, format as Ht, getDaysInMonth as sn, parseISO as cn } from "date-fns";
3
+ import { memo as tr, useId as zn, useRef as j, useMemo as Y, useCallback as U, useState as he, useEffect as xt } from "react";
4
+ const _n = {
324
5
  "blue-rose": {
325
6
  macro: "#0284c7",
326
7
  macroLight: "#38bdf8",
@@ -363,970 +44,1127 @@ const La = {
363
44
  microLight: "#71717a",
364
45
  accent: "#27272a"
365
46
  }
366
- }, ue = (e, t) => {
367
- if (!t || Number.isNaN(t.getTime())) return /* @__PURE__ */ new Date();
368
- const a = new Date(t.getTime());
369
- return e === "year" ? (a.setMonth(0, 1), a.setHours(0, 0, 0, 0)) : (e === "month" && a.setDate(1), a.setHours(0, 0, 0, 0)), a;
370
- }, te = (e, t) => {
371
- if (!t || Number.isNaN(t.getTime())) return 0;
372
- const a = ue(e, t), r = a.getFullYear(), l = a.getMonth() + 1, s = a.getDate();
373
- return e === "year" ? r : e === "month" ? r * 12 + (l - 1) : Math.floor(Date.UTC(r, l - 1, s) / (1440 * 60 * 1e3));
374
- }, Me = (e, t) => {
47
+ }, dt = (e) => e instanceof Date && !Number.isNaN(e.getTime()), ve = (e) => e instanceof Date ? Number.isNaN(e.getTime()) ? "Invalid Date" : e.toISOString() : String(e), We = (e, t) => {
48
+ if (!dt(t)) throw new RangeError(`normalizeDateByUnit: d must be a valid Date (received: ${ve(t)})`);
49
+ const r = new Date(t.getTime());
50
+ return e === "year" ? (r.setMonth(0, 1), r.setHours(0, 0, 0, 0)) : (e === "month" && r.setDate(1), r.setHours(0, 0, 0, 0)), r;
51
+ }, re = (e, t) => {
52
+ const r = We(e, t), n = r.getFullYear(), a = r.getMonth() + 1, s = r.getDate();
53
+ return e === "year" ? n : e === "month" ? n * 12 + (a - 1) : Math.floor(Date.UTC(n, a - 1, s) / (1440 * 60 * 1e3));
54
+ }, ce = (e, t) => {
375
55
  if (e === "year") return new Date(t, 0, 1);
376
56
  if (e === "month") {
377
- const r = Math.floor(t / 12), l = t % 12;
378
- return new Date(r, l, 1);
57
+ const n = Math.floor(t / 12), a = t % 12;
58
+ return new Date(n, a, 1);
379
59
  }
380
- const a = new Date(t * 24 * 60 * 60 * 1e3);
381
- return new Date(a.getUTCFullYear(), a.getUTCMonth(), a.getUTCDate());
382
- }, Le = (e, t, a) => {
383
- const r = new Date(t.getTime());
384
- return e === "year" ? r.setFullYear(r.getFullYear() + a) : e === "month" ? r.setMonth(r.getMonth() + a) : r.setDate(r.getDate() + a), r;
385
- }, jt = (e, t, a) => {
386
- if (!a || Number.isNaN(a.getTime())) return /* @__PURE__ */ new Date();
60
+ const r = new Date(t * 24 * 60 * 60 * 1e3);
61
+ return new Date(r.getUTCFullYear(), r.getUTCMonth(), r.getUTCDate());
62
+ }, ke = (e, t, r) => {
63
+ if (!dt(t)) throw new RangeError(`addUnit: d must be a valid Date (received: ${ve(t)})`);
64
+ return e === "year" ? Un(t, r) : e === "month" ? Bn(t, r) : Dr(t, r);
65
+ }, yt = (e, t, r) => {
66
+ if (!dt(r)) throw new RangeError(`getMacroWindowEndDate: d must be a valid Date (received: ${ve(r)})`);
387
67
  if (e === t)
388
- return ue(t, a);
389
- const r = a.getFullYear(), l = a.getMonth();
68
+ return We(t, r);
69
+ const n = r.getFullYear(), a = r.getMonth();
390
70
  if (e === "year") {
391
71
  if (t === "month")
392
- return new Date(r, 11, 1);
72
+ return new Date(n, 11, 1);
393
73
  if (t === "day")
394
- return new Date(r, 11, 31);
74
+ return new Date(n, 11, 31);
395
75
  }
396
- return e === "month" && t === "day" ? new Date(r, l + 1, 0) : ue(t, a);
397
- }, rt = (e, t, a) => {
398
- if (!t || Number.isNaN(t.getTime())) return "";
399
- if (a) return a(t);
400
- const r = t.getFullYear(), l = String(t.getMonth() + 1).padStart(2, "0"), s = String(t.getDate()).padStart(2, "0");
401
- return e === "year" ? `${r}年` : e === "month" ? `${r}年${l}月` : `${r}年${l}月${s}日`;
402
- }, mt = (e, t, a) => {
403
- if (!t || Number.isNaN(t.getTime())) return "";
404
- if (a) return a(t);
405
- const r = t.getFullYear(), l = t.getMonth() + 1, s = t.getDate();
406
- return e === "year" ? `${r}年` : e === "month" ? `${r}年 ${l}月` : `${r}年 ${l}月 ${s}日`;
407
- }, Ya = (e, t, a) => {
76
+ return e === "month" && t === "day" ? new Date(n, a + 1, 0) : We(t, r);
77
+ }, Xn = {
78
+ year: { year: "numeric" },
79
+ month: { year: "numeric", month: "2-digit" },
80
+ day: { year: "numeric", month: "2-digit", day: "2-digit" }
81
+ }, un = /* @__PURE__ */ new Map(), Kn = (e, t) => {
82
+ const r = `${e}\0${t}`, n = un.get(r);
83
+ if (n !== void 0) return n;
84
+ const a = new Intl.DateTimeFormat(t, Xn[e]);
85
+ return un.set(r, a), a;
86
+ }, qn = (e, t) => {
87
+ const r = String(t.getFullYear()).padStart(4, "0");
88
+ if (e === "year") return r;
89
+ const n = String(t.getMonth() + 1).padStart(2, "0");
90
+ if (e === "month") return `${r}-${n}`;
91
+ const a = String(t.getDate()).padStart(2, "0");
92
+ return `${r}-${n}-${a}`;
93
+ }, Ae = (e, t, r, n) => dt(t) ? r ? r(t) : n === void 0 ? qn(e, t) : Kn(e, n).format(t) : "", Et = (e, t, r, n) => Ae(e, t, r, n), ut = (e, t, r) => {
408
94
  if (!e || e.length === 0 || e.length === 1) return 0;
409
- const r = te(a, t);
410
- let l = 0, s = e.length - 1;
411
- if (r <= te(a, e[l])) return 0;
412
- if (r >= te(a, e[s])) return s;
413
- for (; l <= s; ) {
414
- const u = l + s >> 1, m = te(a, e[u]);
415
- if (m === r) return u;
416
- m < r ? l = u + 1 : s = u - 1;
95
+ const n = re(r, t);
96
+ let a = 0, s = e.length - 1;
97
+ if (n <= re(r, e[a])) return 0;
98
+ if (n >= re(r, e[s])) return s;
99
+ for (; a <= s; ) {
100
+ const g = a + s >> 1, h = re(r, e[g]);
101
+ if (h === n) return g;
102
+ h < n ? a = g + 1 : s = g - 1;
417
103
  }
418
- const d = Math.abs(te(a, e[l]) - r), h = Math.abs(te(a, e[s]) - r);
419
- return d < h ? l : s;
420
- }, _t = (e, t, a, r) => {
104
+ const o = Math.abs(re(r, e[a]) - n), d = Math.abs(re(r, e[s]) - n);
105
+ return o < d ? a : s;
106
+ }, Qt = (e, t, r, n) => {
421
107
  if (!Array.isArray(e) || e.length === 0) return [];
422
- const l = e.filter((u) => u && !Number.isNaN(u.getTime())).map((u) => ue(t, u));
423
- if (l.length === 0) return [];
424
- const s = /* @__PURE__ */ new Map();
425
- for (const u of l) {
426
- const m = te(t, u);
427
- s.has(m) || s.set(m, u);
428
- }
429
- let h = Array.from(s.keys()).sort((u, m) => u - m).map((u) => s.get(u)).filter((u) => u !== void 0);
430
- if (a && !Number.isNaN(a.getTime())) {
431
- const u = te(t, a);
432
- h = h.filter((m) => te(t, m) >= u);
433
- }
434
- if (r && !Number.isNaN(r.getTime())) {
435
- const u = te(t, r);
436
- h = h.filter((m) => te(t, m) <= u);
108
+ const a = re(t, r), s = re(t, n), o = /* @__PURE__ */ new Map();
109
+ for (const d of e) {
110
+ const g = We(t, d), h = re(t, g);
111
+ h < a || h > s || o.has(h) || o.set(h, g);
437
112
  }
438
- return h;
439
- }, Ra = (e, t, a, r, l, s, d) => {
440
- let h = a, u = r;
441
- return d ? (h = t, u = t) : e === "low" ? t > r ? (h = r, u = t) : h = t : t < a ? (u = a, h = t) : u = t, [Math.max(l, Math.min(s, h)), Math.max(l, Math.min(s, u))];
442
- }, Za = (e, t, a, r, l) => l ? "low" : e === "low" ? t > r ? "high" : "low" : t < a ? "low" : "high", Ja = (e, t, a, r, l, s, d) => {
443
- const h = l - r;
444
- if (h <= 0) return null;
113
+ if (o.size === 0)
114
+ throw new RangeError(`getSortedAllowedDates: every allowedDates entry falls outside [minDate, maxDate] (minDate: ${ve(r)}, maxDate: ${ve(n)}, entries: ${e.length})`);
115
+ return Array.from(o.keys()).sort((d, g) => d - g).map((d) => o.get(d));
116
+ }, dn = (e, t, r, n, a, s, o) => {
117
+ let d = r, g = n;
118
+ return o ? (d = t, g = t) : e === "low" ? t > n ? (d = n, g = t) : d = t : t < r ? (g = r, d = t) : g = t, [Math.max(a, Math.min(s, d)), Math.max(a, Math.min(s, g))];
119
+ }, jn = (e, t, r, n, a) => a ? "low" : e === "low" ? t > n ? "high" : "low" : t < r ? "low" : "high", Gn = ({ posDiffPct: e, startLowVal: t, startHighVal: r, rangeMin: n, rangeMax: a, isDiscrete: s, sortedAllowedDates: o, snapMode: d, unit: g }) => {
445
120
  if (s) {
446
- const A = Math.round(e * (d.length - 1));
447
- if (A === 0) return null;
448
- let n = t + A, b = a + A;
449
- return n < 0 && (b += -n, n = 0), b > d.length - 1 && (n -= b - (d.length - 1), b = d.length - 1), n = Math.max(0, Math.min(d.length - 1, n)), b = Math.max(0, Math.min(d.length - 1, b)), [n, b];
121
+ const _ = o.length - 1;
122
+ if (_ <= 0) return [0, 0];
123
+ const Z = Math.max(0, Math.min(_, Math.round(t))), D = Math.max(Z, Math.min(_, Math.round(r)));
124
+ if (d === "time") {
125
+ const A = o[0].getTime(), O = o[_].getTime(), y = o[Z].getTime(), B = o[D].getTime() - y;
126
+ let E = y + e * (O - A), m = E + B;
127
+ E < A && (E = A, m = A + B), m > O && (m = O, E = O - B);
128
+ const L = ut(o, new Date(E), g), S = ut(o, new Date(m), g);
129
+ return [L, Math.max(L, S)];
130
+ }
131
+ const W = Math.round(e * _);
132
+ let C = Z + W, Q = D + W;
133
+ return C < 0 && (Q += -C, C = 0), Q > _ && (C -= Q - _, Q = _), [Math.max(0, Math.min(_, C)), Math.max(0, Math.min(_, Q))];
450
134
  }
451
- const u = Math.round(e * h);
452
- if (u === 0) return null;
453
- let m = t + u, p = a + u;
454
- return m < r && (p += r - m, m = r), p > l && (m -= p - l, p = l), m = Math.max(r, Math.min(l, m)), p = Math.max(r, Math.min(l, p)), [m, p];
455
- }, Qa = (e, t, a, r, l, s, d, h) => {
456
- let u = 0, m = !1, p = !1;
135
+ const h = (_) => Math.max(n, Math.min(a, _)), M = a - n;
136
+ if (M <= 0) return [h(t), h(r)];
137
+ const x = Math.round(e * M);
138
+ let c = t + x, p = r + x;
139
+ return c < n && (p += n - c, c = n), p > a && (c -= p - a, p = a), [h(c), h(p)];
140
+ }, Wn = (e, t, r, n, a, s, o, d) => {
141
+ let g = 0, h = !1, M = !1;
457
142
  switch (e) {
458
143
  case "ArrowRight":
459
144
  case "ArrowUp":
460
- u = h;
145
+ g = d;
461
146
  break;
462
147
  case "ArrowLeft":
463
148
  case "ArrowDown":
464
- u = -h;
149
+ g = -d;
465
150
  break;
466
151
  case "PageUp":
467
- u = h * 5;
152
+ g = d * 5;
468
153
  break;
469
154
  case "PageDown":
470
- u = -h * 5;
155
+ g = -d * 5;
471
156
  break;
472
157
  case "Home":
473
- m = !0;
158
+ h = !0;
474
159
  break;
475
160
  case "End":
476
- p = !0;
161
+ M = !0;
477
162
  break;
478
163
  default:
479
164
  return null;
480
165
  }
481
- if (d) {
482
- let b = a;
483
- return m ? b = l : p ? b = s : b = Math.max(l, Math.min(s, a + u)), [b, b];
166
+ if (o) {
167
+ let p = r;
168
+ return h ? p = a : M ? p = s : p = Math.max(a, Math.min(s, r + g)), [p, p];
484
169
  }
485
- let A = a, n = r;
486
- return t === "low" ? m ? A = l : p ? A = r : A = Math.max(l, Math.min(r, a + u)) : m ? n = a : p ? n = s : n = Math.max(a, Math.min(s, r + u)), [A, n];
487
- }, en = (e, t, a, r = "top", l = "day", s) => {
488
- const d = a > 0 ? a : 400, h = Math.max(0, t - e) / 100 * d, u = l === "year" ? 48 : l === "month" ? 68 : 90, m = s?.estimatedWidthPx ?? u, p = s?.estimatedHeightPx ?? 16, A = s?.paddingPx ?? 12, n = s?.maxAngleDeg ?? 90, b = 8, W = s?.anchorGapY !== void 0 ? s.anchorGapY : 2, z = b + W, P = z + p / 2, F = r === "top" ? -P : P, B = m + A;
489
- if (h >= B)
490
- return {
491
- lowAngleDeg: 0,
492
- highAngleDeg: 0,
493
- lowOffsetX: 0,
494
- highOffsetX: 0,
495
- lowOffsetY: F,
496
- highOffsetY: F,
497
- isSlanted: !1,
498
- proximity: 0
499
- };
500
- const V = Math.max(0, Math.min(1, (B - h) / B)), O = V * V * V * (V * (V * 6 - 15) + 10), f = O * n, I = r === "top" ? -f : f, v = f * Math.PI / 180, M = m / 2 * Math.abs(Math.sin(v)) + p / 2 * Math.abs(Math.cos(v)), x = z + M, oe = r === "top" ? -x : +x, G = p + 4, k = Math.max(0, G - h), j = O * (k / 2);
170
+ let x = r, c = n;
171
+ return t === "low" ? h ? x = a : M ? x = n : x = Math.max(a, Math.min(n, r + g)) : h ? c = r : M ? c = s : c = Math.max(r, Math.min(s, n + g)), [x, c];
172
+ }, Dn = 8, Mn = 2, xn = 16, Jn = 12, Zn = 90, yn = (e, t) => {
173
+ const r = t?.estimatedHeightPx ?? xn, a = Dn + (t?.anchorGapY ?? Mn) + r / 2, s = e === "top" ? -a : a;
174
+ return {
175
+ lowAngleDeg: 0,
176
+ highAngleDeg: 0,
177
+ lowOffsetX: 0,
178
+ highOffsetX: 0,
179
+ lowOffsetY: s,
180
+ highOffsetY: s,
181
+ isSlanted: !1,
182
+ proximity: 0
183
+ };
184
+ }, Qn = (e, t, r, n = "top", a) => {
185
+ const s = a?.estimatedWidthPx, o = a?.estimatedHeightPx ?? xn, d = a?.paddingPx ?? Jn, g = a?.maxAngleDeg ?? Zn, h = Dn + (a?.anchorGapY ?? Mn), M = yn(n, a);
186
+ if (!(Number.isFinite(r) && r > 0) || s === void 0 || !Number.isFinite(s) || s <= 0) return M;
187
+ const x = Math.max(0, t - e) / 100 * r, c = s + d;
188
+ if (x >= c) return M;
189
+ const p = Math.max(0, Math.min(1, (c - x) / c)), Z = p * p * p * (p * (p * 6 - 15) + 10) * g, D = n === "top" ? -Z : Z, W = Z * Math.PI / 180, C = s / 2 * Math.abs(Math.sin(W)) + o / 2 * Math.abs(Math.cos(W)), Q = h + C, A = n === "top" ? -Q : +Q, O = s * Math.abs(Math.cos(W)) + o * Math.abs(Math.sin(W)), y = Math.max(0, (O + d - x) / 2);
501
190
  return {
502
- lowAngleDeg: I,
503
- highAngleDeg: I,
504
- lowOffsetX: -j,
505
- highOffsetX: j,
506
- lowOffsetY: oe,
507
- highOffsetY: oe,
508
- isSlanted: V > 1e-3,
509
- proximity: V
191
+ lowAngleDeg: D,
192
+ highAngleDeg: D,
193
+ lowOffsetX: -y,
194
+ highOffsetX: y,
195
+ lowOffsetY: A,
196
+ highOffsetY: A,
197
+ isSlanted: p > 1e-3,
198
+ proximity: p
510
199
  };
511
200
  };
512
- function tn(e, t, a, r, l, s, d = "macro-top", h = 0.05) {
513
- const u = d === "macro-top" || d === "macro-left", m = t <= 0;
514
- if (u && m || !(u || m)) {
515
- const n = Math.abs(e - a), b = Math.abs(e - r);
516
- return n <= h && n <= b ? "macro-low" : b <= h && b < n ? "macro-high" : e >= a && e <= r ? "macro-connect" : n < b ? "macro-low" : "macro-high";
201
+ function ea(e, t, r, n, a, s, o = "macro-top", d = 0.05) {
202
+ const g = o === "macro-top" || o === "macro-left", h = t <= 0;
203
+ if (g && h || !(g || h)) {
204
+ const c = Math.abs(e - r), p = Math.abs(e - n);
205
+ return c <= d && c <= p ? "macro-low" : p <= d && p < c ? "macro-high" : e >= r && e <= n ? "macro-connect" : c < p ? "macro-low" : "macro-high";
517
206
  }
518
- const p = Math.abs(e - l), A = Math.abs(e - s);
519
- return p <= h && p <= A ? "micro-low" : A <= h && A < p ? "micro-high" : e >= l && e <= s ? "micro-connect" : p < A ? "micro-low" : "micro-high";
207
+ const M = Math.abs(e - a), x = Math.abs(e - s);
208
+ return M <= d && M <= x ? "micro-low" : x <= d && x < M ? "micro-high" : e >= a && e <= s ? "micro-connect" : M < x ? "micro-low" : "micro-high";
520
209
  }
521
- function an(e, t, a, r, l) {
210
+ function ta(e, t, r, n, a) {
522
211
  if (e === "macro-connect") {
523
- const d = t - a, h = l - r, u = Math.max(0, Math.min(1 - h, r + d)), m = u + h;
524
- return [u, m, "macro-connect"];
212
+ const o = t - r, d = a - n, g = Math.max(0, Math.min(1 - d, n + o)), h = g + d;
213
+ return [g, h, "macro-connect"];
525
214
  }
526
215
  if (e === "macro-low") {
527
- const d = Math.max(0, Math.min(1, t));
528
- return d > l ? [l, d, "macro-high"] : [d, l, "macro-low"];
216
+ const o = Math.max(0, Math.min(1, t));
217
+ return o > a ? [a, o, "macro-high"] : [o, a, "macro-low"];
529
218
  }
530
219
  const s = Math.max(0, Math.min(1, t));
531
- return s < r ? [s, r, "macro-low"] : [r, s, "macro-high"];
220
+ return s < n ? [s, n, "macro-low"] : [n, s, "macro-high"];
532
221
  }
533
- function nn(e, t, a, r, l) {
222
+ function ra(e, t, r, n, a) {
534
223
  if (e === "micro-connect") {
535
- const d = t - a, h = l - r, u = Math.max(0, Math.min(1 - h, r + d)), m = u + h;
536
- return [u, m, "micro-connect"];
224
+ const o = t - r, d = a - n, g = Math.max(0, Math.min(1 - d, n + o)), h = g + d;
225
+ return [g, h, "micro-connect"];
537
226
  }
538
227
  if (e === "micro-low") {
539
- const d = Math.max(0, Math.min(1, t));
540
- return d > l ? [l, d, "micro-high"] : [d, l, "micro-low"];
228
+ const o = Math.max(0, Math.min(1, t));
229
+ return o > a ? [a, o, "micro-high"] : [o, a, "micro-low"];
541
230
  }
542
231
  const s = Math.max(0, Math.min(1, t));
543
- return s < r ? [s, r, "micro-low"] : [r, s, "micro-high"];
232
+ return s < n ? [s, n, "micro-low"] : [n, s, "micro-high"];
544
233
  }
545
- const Tt = Ct(({ type: e, isTop: t = !0, isVertical: a = !1, isLeft: r = !0 }) => {
546
- let l, s;
547
- return a ? (l = r ? "M 7.375 0.625 A 7.375 7.375 0 0 0 7.375 15.375 Z" : "M 0.625 0.625 A 7.375 7.375 0 0 1 0.625 15.375 Z", s = `period-slider-knob period-slider-knob-svg is-vertical ${r ? "is-semicircle-left" : "is-semicircle-right"}`) : (l = t ? "M 0.625 7.375 A 7.375 7.375 0 0 1 15.375 7.375 Z" : "M 0.625 0.625 A 7.375 7.375 0 0 0 15.375 0.625 Z", s = `period-slider-knob period-slider-knob-svg ${t ? "is-semicircle-top" : "is-semicircle-bottom"}`), /* @__PURE__ */ T("svg", { className: s, width: a ? "8" : "16", height: a ? "16" : "8", viewBox: a ? "0 0 8 16" : "0 0 16 8", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", children: /* @__PURE__ */ T("path", { d: l, className: e === "macro" ? "period-slider-knob-path-macro" : "period-slider-knob-path-micro", shapeRendering: "geometricPrecision", strokeWidth: "1.25" }) });
234
+ const Jt = tr(({ type: e, isTop: t = !0, isVertical: r = !1, isLeft: n = !0 }) => {
235
+ let a, s;
236
+ return r ? (a = n ? "M 7.375 0.625 A 7.375 7.375 0 0 0 7.375 15.375 Z" : "M 0.625 0.625 A 7.375 7.375 0 0 1 0.625 15.375 Z", s = `period-slider-knob period-slider-knob-svg is-vertical ${n ? "is-semicircle-left" : "is-semicircle-right"}`) : (a = t ? "M 0.625 7.375 A 7.375 7.375 0 0 1 15.375 7.375 Z" : "M 0.625 0.625 A 7.375 7.375 0 0 0 15.375 0.625 Z", s = `period-slider-knob period-slider-knob-svg ${t ? "is-semicircle-top" : "is-semicircle-bottom"}`), /* @__PURE__ */ w("svg", { className: s, width: r ? "8" : "16", height: r ? "16" : "8", viewBox: r ? "0 0 8 16" : "0 0 16 8", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", children: /* @__PURE__ */ w("path", { d: a, className: e === "macro" ? "period-slider-knob-path-macro" : "period-slider-knob-path-micro", shapeRendering: "geometricPrecision", strokeWidth: "1.25" }) });
548
237
  });
549
- Tt.displayName = "VernierKnobSvg";
550
- const rn = (e) => {
238
+ Jt.displayName = "VernierKnobSvg";
239
+ const na = (e, t) => {
240
+ if (!dt(e)) throw new RangeError(`PeriodSlider: minDate is required and must be a valid Date (received: ${ve(e)})`);
241
+ if (!dt(t)) throw new RangeError(`PeriodSlider: maxDate is required and must be a valid Date (received: ${ve(t)})`);
242
+ if (t.getTime() <= e.getTime())
243
+ throw new RangeError(`PeriodSlider: maxDate must be strictly later than minDate (minDate: ${ve(e)}, maxDate: ${ve(t)})`);
244
+ }, Ar = (e, t) => {
245
+ if (!Array.isArray(t) || t.length !== 2)
246
+ throw new RangeError(`PeriodSlider: ${e} is required and must be a [start, end] Date tuple (received: ${ve(t)})`);
247
+ const [r, n] = t;
248
+ if (!dt(r)) throw new RangeError(`PeriodSlider: ${e}[0] must be a valid Date (received: ${ve(r)})`);
249
+ if (!dt(n)) throw new RangeError(`PeriodSlider: ${e}[1] must be a valid Date (received: ${ve(n)})`);
250
+ if (n.getTime() < r.getTime())
251
+ throw new RangeError(`PeriodSlider: ${e} must not be inverted (start: ${ve(r)}, end: ${ve(n)})`);
252
+ }, aa = (e, t, r) => {
253
+ if (Ar("macroRange", e), t !== void 0)
254
+ return Ar("microRange", t), t;
255
+ if (r !== void 0)
256
+ return Ar("defaultMicroRange", r), r;
257
+ throw new RangeError("PeriodSlider: vernier mode requires a micro selection; supply microRange (controlled) or defaultMicroRange (uncontrolled)");
258
+ }, br = (e, t, r, n, a, s, o, d) => {
259
+ const g = ut(e, n, t), h = ut(e, a, t);
260
+ if (o) return e[g];
261
+ if (d) return e[h];
262
+ const M = Math.max(g, Math.min(h, ut(e, r, t) + s));
263
+ return e[M];
264
+ }, Cr = (e) => {
265
+ e.timerId !== null && clearTimeout(e.timerId), e.timerId = null, e.emit = null;
266
+ }, oa = (e, t) => {
267
+ try {
268
+ Intl.DateTimeFormat.supportedLocalesOf([t]);
269
+ } catch {
270
+ throw new RangeError(`PeriodSlider: ${e} must be a valid BCP 47 language tag (received: ${JSON.stringify(t)})`);
271
+ }
272
+ }, mn = () => {
273
+ const [e, t] = he(null), r = j(null), n = U((a) => {
274
+ if (r.current?.disconnect(), r.current = null, a === null) {
275
+ t(null);
276
+ return;
277
+ }
278
+ if (typeof ResizeObserver > "u") return;
279
+ const s = new ResizeObserver((o) => {
280
+ for (const d of o) {
281
+ const g = d.borderBoxSize?.[0];
282
+ g !== void 0 && t((h) => h !== null && Math.abs(h.widthPx - g.inlineSize) < 0.5 && Math.abs(h.heightPx - g.blockSize) < 0.5 ? h : { widthPx: g.inlineSize, heightPx: g.blockSize });
283
+ }
284
+ });
285
+ s.observe(a), r.current = s;
286
+ }, []);
287
+ return xt(
288
+ () => () => {
289
+ r.current?.disconnect(), r.current = null;
290
+ },
291
+ []
292
+ ), [n, e];
293
+ }, ia = {
294
+ horizontal: { decrease: "◀", increase: "▶" },
295
+ vertical: { decrease: "▼", increase: "▲" }
296
+ }, la = {
297
+ horizontal: { decrease: "period-slider-stepper-prev", increase: "period-slider-stepper-next" },
298
+ vertical: { decrease: "period-slider-stepper-prev period-slider-stepper-down", increase: "period-slider-stepper-next period-slider-stepper-up" }
299
+ }, sa = (e) => {
551
300
  const {
552
301
  unit: t,
553
- minDate: a,
554
- maxDate: r,
555
- allowedDates: l,
302
+ minDate: r,
303
+ maxDate: n,
304
+ allowedDates: a,
556
305
  snapMode: s = "index",
557
- disabled: d = !1,
558
- className: h = "",
559
- showStepper: u = !0,
560
- tooltipStyle: m = "always",
561
- labelPosition: p = "top",
562
- autoSlantLabels: A = !0,
563
- isVertical: n = !1,
564
- hideConnectBar: b = !1,
565
- showTicks: W = !1,
566
- colorScheme: z = "blue-rose"
567
- } = e, P = La[z] ?? La["blue-rose"], F = Xa(), B = Q(e);
568
- B.current = e;
569
- const V = a?.getTime(), O = r?.getTime(), f = R(() => _t(l, t, a, r), [l, t, V, O]), I = f.length > 0, { rangeMin: v, rangeMax: M } = R(() => {
570
- if (I)
571
- return { rangeMin: 0, rangeMax: f.length - 1 };
572
- const i = ue(t, a ?? new Date(2020, 0, 1));
573
- let c = ue(t, r ?? new Date(2030, 0, 1));
574
- const g = te(t, i);
575
- let D = te(t, c);
576
- return D <= g && (c = Le(t, i, 1), D = te(t, c)), { rangeMin: g, rangeMax: D };
577
- }, [I, f, t, V, O]), x = e.mode === "point", oe = K(
306
+ disabled: o = !1,
307
+ className: d = "",
308
+ showStepper: g = !0,
309
+ tooltipStyle: h = "always",
310
+ labelPosition: M = "top",
311
+ autoSlantLabels: x = !0,
312
+ isVertical: c = !1,
313
+ hideConnectBar: p = !1,
314
+ showTicks: _ = !1,
315
+ colorScheme: Z = "blue-rose",
316
+ locale: D,
317
+ decreaseAriaLabel: W = "Decrease",
318
+ increaseAriaLabel: C = "Increase"
319
+ } = e;
320
+ na(r, n), D !== void 0 && oa("locale", D);
321
+ const Q = e.mode === "vernier" ? aa(e.macroRange, e.microRange, e.defaultMicroRange) : null, A = _n[Z], O = zn(), y = j(e);
322
+ y.current = e;
323
+ const B = r.getTime(), E = n.getTime(), m = Y(() => Qt(a, t, r, n), [a, t, B, E]), L = m.length > 0, { rangeMin: S, rangeMax: H } = Y(() => L ? { rangeMin: 0, rangeMax: m.length - 1 } : { rangeMin: re(t, r), rangeMax: re(t, n) }, [L, m, t, B, E]), P = e.mode === "point", ne = U(
578
324
  (i) => {
579
- if (I) {
580
- const c = Math.max(0, Math.min(f.length - 1, Math.round(i)));
581
- return f[c] ?? /* @__PURE__ */ new Date();
325
+ if (L) {
326
+ const l = Math.max(0, Math.min(m.length - 1, Math.round(i)));
327
+ return m[l];
582
328
  }
583
- return Me(t, Math.round(i));
329
+ return ce(t, Math.round(i));
584
330
  },
585
- [I, f, t]
586
- ), N = K(
331
+ [L, m, t]
332
+ ), K = U(
587
333
  (i) => {
588
- if (!i || Number.isNaN(i.getTime())) return v;
589
- const c = ue(t, i);
590
- return I ? Ya(f, c, t) : te(t, c);
334
+ if (i === void 0) return S;
335
+ const l = We(t, i);
336
+ return L ? ut(m, l, t) : re(t, l);
591
337
  },
592
- [I, f, t, v]
593
- ), G = e.mode === "range" ? e.range ? e.range[0] : e.lowerDate ?? e.defaultRange?.[0] ?? e.initialRange?.[0] ?? e.defaultLowerDate ?? e.initialLowerDate : e.mode === "vernier" ? e.microRange ? e.microRange[0] : e.lowerDate ?? e.defaultMicroRange?.[0] ?? e.initialMicroRange?.[0] ?? e.defaultLowerDate ?? e.initialLowerDate : void 0, k = e.mode === "range" ? e.range ? e.range[1] : e.upperDate ?? e.defaultRange?.[1] ?? e.initialRange?.[1] ?? e.defaultUpperDate ?? e.initialUpperDate : e.mode === "vernier" ? e.microRange ? e.microRange[1] : e.upperDate ?? e.defaultMicroRange?.[1] ?? e.initialMicroRange?.[1] ?? e.defaultUpperDate ?? e.initialUpperDate : void 0, j = e.mode === "point" ? e.value ?? e.valueDate ?? e.defaultValue ?? e.initialDate : void 0, q = G ?? (I ? f[0] : Me(t, v)), fe = k ?? (I ? f[f.length - 1] : Me(t, M)), me = e.mode === "point" ? j?.getTime() : G?.getTime(), se = e.mode === "range" ? k?.getTime() : me, [ee, X] = R(() => {
338
+ [L, m, t, S]
339
+ ), [X, te] = he(() => Q), ae = e.mode !== "vernier" ? null : e.microRange !== void 0 ? e.microRange : X, me = e.mode === "range" ? e.range?.[0] ?? e.defaultRange?.[0] : e.mode === "vernier" ? ae?.[0] : void 0, ze = e.mode === "range" ? e.range?.[1] ?? e.defaultRange?.[1] : e.mode === "vernier" ? ae?.[1] : void 0, oe = e.mode === "point" ? e.value ?? e.defaultValue : void 0, Ze = e.mode === "point" ? oe?.getTime() : me?.getTime(), mt = e.mode === "range" ? ze?.getTime() : Ze, [Se, pe] = Y(() => {
594
340
  if (e.mode === "point") {
595
- const g = N(j);
596
- return [g, g];
341
+ const u = K(oe);
342
+ return [u, u];
597
343
  }
598
- const i = N(G), c = N(k);
599
- return [Math.min(i, c), Math.max(i, c)];
600
- }, [e.mode, me, se, N, j, G, k]), de = e.mode === "point" ? e.value !== void 0 || e.valueDate !== void 0 : e.mode === "range" ? e.range !== void 0 || e.lowerDate !== void 0 || e.upperDate !== void 0 : e.microRange !== void 0 || e.lowerDate !== void 0 || e.upperDate !== void 0, [Ve, xe] = De(() => [ee, X]);
601
- ot(() => {
602
- de && xe([ee, X]);
603
- }, [de, ee, X]);
604
- const [Ye, Re] = De(null), [we, je] = De(null), Ee = Q(null);
605
- Ee.current = we;
606
- const [L, S] = De("high"), [Z, ae] = De(null), [Y, ie] = De(null), ne = Ye ? Ye[0] : de ? ee : Ve[0], ce = Ye ? Ye[1] : de ? X : Ve[1], o = e.mode === "vernier", H = e.mode === "vernier" ? e.vernierOrientation ?? (n ? "macro-left" : "macro-top") : "macro-top", w = H === "macro-top" || H === "macro-left", pe = e.mode === "vernier" ? e.showVernierProjection ?? !0 : !1, ke = e.mode === "vernier" ? e.showVernierTicks ?? !0 : !1, Ie = e.mode === "vernier" ? e.showHairline ?? !0 : !1, U = o ? e.macroUnit ?? t : t, E = o ? e.microUnit ?? t : t, Zt = o ? e.macroIsDiscrete ?? !1 : I, Jt = o ? e.microIsDiscrete ?? !1 : I, Qt = o ? e.macroAllowedDates ?? l : l, ea = o ? e.microAllowedDates ?? l : l, Lt = o ? e.formatMacroLabel ?? e.formatLabel : e.formatLabel, Yt = o ? e.formatMicroLabel ?? e.formatLabel : e.formatLabel, ta = o && e.macroRange ? e.macroRange[0]?.getTime() : void 0, aa = o && e.macroRange ? e.macroRange[1]?.getTime() : void 0, ka = e.mode !== "point" ? e.lowerDate?.getTime() : void 0, $a = e.mode !== "point" ? e.upperDate?.getTime() : void 0, [ye, Rt] = De(null), at = Q(null);
607
- at.current = ye;
608
- const [$e, kt] = De("micro-high"), Te = R(() => o ? te(U, ue(U, a ?? new Date(2020, 0, 1))) : 0, [o, V, U, a]), it = R(() => {
609
- if (!o) return 1;
610
- const i = ue(U, r ?? new Date(2030, 0, 1)), c = te(U, i);
611
- return c <= Te ? Te + 1 : c;
612
- }, [o, O, Te, U, r]), gt = R(() => o ? _t(Qt, U, a, r) : [], [o, Qt, U, a, r]), ft = R(() => o ? _t(ea, E, a, r) : [], [o, ea, E, a, r]), _e = R(() => o && e.macroRange ? te(U, ue(U, e.macroRange[0])) : Te, [o, ta, Te, U]), Ge = R(() => o && e.macroRange ? te(U, ue(U, e.macroRange[1])) : it, [o, aa, it, U]), he = R(() => o && e.macroRange ? te(E, ue(E, e.macroRange[0])) : 0, [o, ta, E]), We = R(() => {
613
- if (!(o && e.macroRange)) return 1;
614
- const i = jt(U, E, e.macroRange[1]), c = te(E, ue(E, i));
615
- return c <= he ? he + 1 : c;
616
- }, [o, aa, he, U, E]), Ae = R(() => o && G ? te(E, ue(E, G)) : he, [o, ka, he, E, G]), Fe = R(() => o && k ? te(E, ue(E, k)) : We, [o, $a, We, E, k]), ht = Math.max(1, it - Te), ve = Math.max(0, Math.min(1, (_e - Te) / ht)), Se = Math.max(ve, Math.min(1, (Ge - Te) / ht)), bt = Math.max(1, We - he), Oe = Math.max(0, Math.min(1, (Ae - he) / bt)), nt = Math.max(Oe, Math.min(1, (Fe - he) / bt)), Ue = Q(null);
617
- ot(() => () => {
618
- Ue.current && clearTimeout(Ue.current);
344
+ const i = K(me), l = K(ze);
345
+ return [Math.min(i, l), Math.max(i, l)];
346
+ }, [e.mode, Ze, mt, K, oe, me, ze]), ue = e.mode === "point" ? e.value !== void 0 : e.mode === "range" ? e.range !== void 0 : e.microRange !== void 0, [I, F] = he(() => [Se, pe]), [G, de] = he(null), [$, be] = he(null), Ee = j(null);
347
+ Ee.current = $;
348
+ const [Qe, se] = he("high"), [De, ft] = he(null), [Ft, rr] = he(null), fe = G ? G[0] : ue ? Se : I[0], ge = G ? G[1] : ue ? pe : I[1], J = e.mode === "vernier", gt = e.mode === "vernier" ? e.vernierOrientation ?? (c ? "macro-left" : "macro-top") : "macro-top", T = gt === "macro-top" || gt === "macro-left", nr = e.mode === "vernier" ? e.showVernierProjection ?? !0 : !1, ar = e.mode === "vernier" ? e.showVernierTicks ?? !0 : !1, Tt = e.mode === "vernier" ? e.showHairline ?? !0 : !1, z = J ? e.macroUnit ?? t : t, N = J ? e.microUnit ?? t : t, Vt = J ? e.macroIsDiscrete ?? !1 : L, it = J ? e.microIsDiscrete ?? !1 : L, Mr = J ? e.macroAllowedDates ?? a : a, xr = J ? e.microAllowedDates ?? a : a, f = J ? e.formatMacroLabel ?? e.formatLabel : e.formatLabel, k = J ? e.formatMicroLabel ?? e.formatLabel : e.formatLabel, Ie = e.mode === "vernier" ? e.macroRange[0].getTime() : void 0, Lt = e.mode === "vernier" ? e.macroRange[1].getTime() : void 0, ht = me?.getTime(), et = ze?.getTime(), [Le, or] = he(null), bt = j(null);
349
+ bt.current = Le;
350
+ const [Pe, ir] = he("micro-high"), $e = Y(() => re(z, r), [B, z]), Rt = Y(() => {
351
+ const i = re(z, n);
352
+ if (J && i <= $e)
353
+ throw new RangeError(`PeriodSlider: macroUnit "${z}" cannot distinguish minDate from maxDate (minDate: ${ve(r)}, maxDate: ${ve(n)})`);
354
+ return i;
355
+ }, [J, B, E, $e, z]), He = Y(() => J ? Qt(Mr, z, r, n) : [], [J, Mr, z, B, E]), _e = Y(() => e.mode !== "vernier" ? $e : re(z, e.macroRange[0]), [e.mode, Ie, $e, z]), Xe = Y(() => e.mode !== "vernier" ? Rt : re(z, e.macroRange[1]), [e.mode, Lt, Rt, z]), we = Y(() => e.mode !== "vernier" ? re(N, r) : Math.max(re(N, e.macroRange[0]), re(N, r)), [e.mode, Ie, N, B]), Oe = Y(() => e.mode !== "vernier" ? re(N, n) : Math.min(re(N, yt(z, N, e.macroRange[1])), re(N, n)), [e.mode, Lt, z, N, E]), Fe = Y(() => J ? Qt(xr, N, r, n).filter((l) => {
356
+ const u = re(N, l);
357
+ return u >= we && u <= Oe;
358
+ }) : [], [J, xr, N, B, E, we, Oe]), Me = Y(() => ae === null ? we : re(N, ae[0]), [ht, we, N, ae]), xe = Y(() => ae === null ? Oe : re(N, ae[1]), [et, Oe, N, ae]), Ut = Y(() => ce(N, Me), [N, Me]), Bt = Y(() => ce(N, xe), [N, xe]), zt = Math.max(1, Rt - $e), ye = Math.max(0, Math.min(1, (_e - $e) / zt)), Ne = Math.max(ye, Math.min(1, (Xe - $e) / zt)), _t = Math.max(1, Oe - we), Ke = Math.max(0, Math.min(1, (Me - we) / _t)), wt = Math.max(Ke, Math.min(1, (xe - we) / _t)), yr = j({ timerId: null, emit: null }), Tr = j({ timerId: null, emit: null }), Lr = j({ timerId: null, emit: null });
359
+ xt(() => {
360
+ const i = [yr, Tr, Lr];
361
+ return () => {
362
+ for (const l of i)
363
+ Cr(l.current);
364
+ };
619
365
  }, []);
620
- const na = Q(null), ze = K(
621
- (i, c, g = !1) => {
622
- const D = B.current, C = oe(i), _ = oe(c), re = D.mode === "point" ? `${C.getTime()}` : `${C.getTime()}-${_.getTime()}`;
623
- if (re === na.current && !Ue.current)
366
+ const St = U((i, l, u) => {
367
+ Cr(i);
368
+ const { debounceMs: b } = y.current;
369
+ if (u || !b || b <= 0) {
370
+ l();
371
+ return;
372
+ }
373
+ i.emit = l, i.timerId = setTimeout(() => {
374
+ i.timerId = null, i.emit = null, l();
375
+ }, b);
376
+ }, []), Rr = U((i) => {
377
+ const l = i.emit;
378
+ Cr(i), l?.();
379
+ }, []), $t = U((i) => new Date(Math.min(Math.max(i.getTime(), B), E)), [B, E]), zr = j(null), qe = U(
380
+ (i, l, u = !1) => {
381
+ const b = ne(i), R = ne(l), ee = y.current.mode === "point" ? `${b.getTime()}` : `${b.getTime()}-${R.getTime()}`;
382
+ if (ee === zr.current && yr.current.timerId === null)
624
383
  return;
625
- const y = () => {
626
- na.current = re, D.mode === "point" ? (D.onChangePoint?.(C), D.onChangeValue?.(C), D.onChange?.(C)) : D.mode === "range" ? (D.onChangeRange?.(C, _), D.onChangeRangeTuple?.([C, _]), D.onChange?.([C, _])) : D.mode === "vernier" && (D.onChangeRange?.(C, _), D.onChangeRangeTuple?.([C, _]), D.onChangeMicroRange?.(C, _), D.onChangeMicroRangeTuple?.([C, _]), D.onChangeMicro?.([C, _]));
384
+ const ie = () => {
385
+ zr.current = ee;
386
+ const V = y.current;
387
+ V.mode === "point" ? V.onChangePoint?.(b) : V.mode === "range" && V.onChangeRange?.(b, R);
627
388
  };
628
- g || !D.debounceMs || D.debounceMs === 0 ? (Ue.current && (clearTimeout(Ue.current), Ue.current = null), y()) : (Ue.current && clearTimeout(Ue.current), Ue.current = setTimeout(() => {
629
- y(), Ue.current = null;
630
- }, D.debounceMs));
389
+ St(yr.current, ie, u);
390
+ },
391
+ [ne, St]
392
+ ), kt = U(
393
+ (i, l, u = !1) => {
394
+ if (y.current.mode !== "vernier") return;
395
+ const b = $t(i), R = $t(l);
396
+ St(
397
+ Tr.current,
398
+ () => {
399
+ const ee = y.current;
400
+ ee.mode === "vernier" && ee.onChangeMacroRange?.(b, R);
401
+ },
402
+ u
403
+ );
404
+ },
405
+ [$t, St]
406
+ ), tt = U(
407
+ (i, l, u = !1) => {
408
+ const b = y.current;
409
+ if (b.mode !== "vernier") return;
410
+ const R = $t(i), ee = $t(l);
411
+ b.microRange === void 0 && te([R, ee]), St(
412
+ Lr.current,
413
+ () => {
414
+ const ie = y.current;
415
+ ie.mode === "vernier" && ie.onChangeMicroRange?.(R, ee);
416
+ },
417
+ u
418
+ );
631
419
  },
632
- [oe]
633
- ), $t = K(
420
+ [$t, St]
421
+ ), lr = U(
634
422
  (i) => {
635
- if (I && s === "time" && f.length > 1) {
636
- const D = Math.max(0, Math.min(f.length - 1, Math.round(i))), C = f[0].getTime(), re = f[f.length - 1].getTime() - C;
637
- if (re <= 0) return 0;
638
- const y = f[D].getTime();
639
- return Math.max(0, Math.min(100, (y - C) / re * 100));
423
+ if (L && s === "time" && m.length > 1) {
424
+ const b = Math.max(0, Math.min(m.length - 1, Math.round(i))), R = m[0].getTime(), ie = m[m.length - 1].getTime() - R;
425
+ if (ie <= 0) return 0;
426
+ const V = m[b].getTime();
427
+ return Math.max(0, Math.min(100, (V - R) / ie * 100));
640
428
  }
641
- const c = M - v;
642
- if (c <= 0) return 0;
643
- const g = (i - v) / c * 100;
644
- return Math.max(0, Math.min(100, g));
429
+ const l = H - S;
430
+ if (l <= 0) return 0;
431
+ const u = (i - S) / l * 100;
432
+ return Math.max(0, Math.min(100, u));
645
433
  },
646
- [I, s, f, v, M]
647
- ), At = K(
434
+ [L, s, m, S, H]
435
+ ), sr = U(
648
436
  (i) => {
649
- const c = Math.max(0, Math.min(100, i));
650
- if (I) {
651
- if (s === "time" && f.length > 1) {
652
- const C = f[0].getTime(), re = f[f.length - 1].getTime() - C, y = C + c / 100 * re;
653
- return Ya(f, new Date(y), t);
437
+ const l = Math.max(0, Math.min(100, i));
438
+ if (L) {
439
+ if (s === "time" && m.length > 1) {
440
+ const R = m[0].getTime(), ie = m[m.length - 1].getTime() - R, V = R + l / 100 * ie;
441
+ return ut(m, new Date(V), t);
654
442
  }
655
- const D = Math.round(c / 100 * (f.length - 1));
656
- return Math.max(0, Math.min(f.length - 1, D));
443
+ const b = Math.round(l / 100 * (m.length - 1));
444
+ return Math.max(0, Math.min(m.length - 1, b));
657
445
  }
658
- const g = v + c / 100 * (M - v);
659
- return Math.round(g);
446
+ const u = S + l / 100 * (H - S);
447
+ return Math.round(u);
660
448
  },
661
- [I, s, f, v, M, t]
662
- ), He = Q(null), [Aa, ra] = De(0), oa = Aa;
663
- ot(() => {
664
- const i = He.current;
449
+ [L, s, m, S, H, t]
450
+ ), rt = j(null), [_r, Xr] = he(0), [Ln, vt] = mn(), [Rn, cr] = mn();
451
+ xt(() => {
452
+ const i = rt.current;
665
453
  if (!i) return;
666
- const c = () => {
667
- const g = i.getBoundingClientRect(), D = n ? g.height : g.width;
668
- D > 0 && ra((C) => Math.abs(C - D) < 0.5 ? C : D);
454
+ const l = () => {
455
+ const u = i.getBoundingClientRect(), b = c ? u.height : u.width;
456
+ b > 0 && Xr((R) => Math.abs(R - b) < 0.5 ? R : b);
669
457
  };
670
- if (c(), typeof ResizeObserver < "u") {
671
- const g = new ResizeObserver((D) => {
672
- for (const C of D) {
673
- const _ = n ? C.contentRect.height : C.contentRect.width;
674
- _ > 0 && ra((re) => Math.abs(re - _) < 0.5 ? re : _);
458
+ if (l(), typeof ResizeObserver < "u") {
459
+ const u = new ResizeObserver((b) => {
460
+ for (const R of b) {
461
+ const ee = c ? R.contentRect.height : R.contentRect.width;
462
+ ee > 0 && Xr((ie) => Math.abs(ie - ee) < 0.5 ? ie : ee);
675
463
  }
676
464
  });
677
- return g.observe(i), () => g.disconnect();
465
+ return u.observe(i), () => u.disconnect();
678
466
  }
679
- return window.addEventListener("resize", c), () => window.removeEventListener("resize", c);
680
- }, [n]);
681
- const ia = K(
682
- (i, c, g) => {
683
- if (n) {
684
- const _ = g.height > 0 ? g.height : 100, re = g.bottom - c;
685
- return Math.max(0, Math.min(100, re / _ * 100));
686
- }
687
- const D = g.width > 0 ? g.width : 100, C = i - g.left;
688
- return Math.max(0, Math.min(100, C / D * 100));
467
+ return window.addEventListener("resize", l), () => window.removeEventListener("resize", l);
468
+ }, [c]);
469
+ const pt = U(
470
+ (i, l, u) => {
471
+ const b = c ? u.height : u.width;
472
+ if (!(Number.isFinite(b) && b > 0)) return null;
473
+ const R = c ? u.bottom - l : i - u.left;
474
+ return Number.isFinite(R) ? Math.max(0, Math.min(1, R / b)) : null;
689
475
  },
690
- [n]
691
- ), Ft = K(
692
- (i, c) => He.current ? ia(i, c, He.current.getBoundingClientRect()) : 0,
693
- [ia]
694
- ), St = Q(null), Ot = Q(null), Be = Q(null), Ut = Q(null), Mt = Q(null), la = K(
476
+ [c]
477
+ ), Kr = U(
478
+ (i, l) => {
479
+ const u = rt.current;
480
+ if (!u) return null;
481
+ const b = pt(i, l, u.getBoundingClientRect());
482
+ return b === null ? null : b * 100;
483
+ },
484
+ [pt]
485
+ ), ur = j(null), Sr = j(null), je = j(null), $r = j(null), Xt = j(null), qr = U(
695
486
  (i) => {
696
- if (d) return;
697
- if (o) {
698
- const $ = Ot.current;
699
- if (!$ || i.pointerId !== 0 && i.pointerId !== $.pointerId || !He.current) return;
700
- const be = He.current.getBoundingClientRect(), Kt = n ? be.height : be.width;
701
- if (Kt <= 0) return;
702
- const va = n ? i.clientY : i.clientX, pa = Math.max(0, Math.min(1, n ? (be.bottom - va) / Kt : (va - be.left) / Kt)), Qe = B.current;
703
- if (!Qe) return;
704
- if ($.handle === "macro-low" || $.handle === "macro-high" || $.handle === "macro-connect") {
705
- const [wt, Dt, Ze] = an($.handle, pa, $.startPointerRatio, $.startMacroLowRatio, $.startMacroHighRatio);
706
- Ze !== at.current && (at.current = Ze, Rt(Ze), kt(Ze));
707
- let ge, Ce;
708
- if (Zt && gt.length > 0) {
709
- const Ke = gt.length - 1, Je = Math.max(0, Math.min(Ke, Math.round(wt * Ke))), et = Math.max(Je, Math.min(Ke, Math.round(Dt * Ke)));
710
- ge = gt[Je] ?? /* @__PURE__ */ new Date(), Ce = gt[et] ?? /* @__PURE__ */ new Date();
487
+ if (o) return;
488
+ if (J) {
489
+ const v = Sr.current;
490
+ if (!v || i.pointerId !== 0 && i.pointerId !== v.pointerId || !rt.current) return;
491
+ const Ye = pt(i.clientX, i.clientY, rt.current.getBoundingClientRect());
492
+ if (Ye === null) return;
493
+ if (v.handle === "macro-low" || v.handle === "macro-high" || v.handle === "macro-connect") {
494
+ const [Dt, Kt, nt] = ta(v.handle, Ye, v.startPointerRatio, v.startMacroLowRatio, v.startMacroHighRatio);
495
+ nt !== bt.current && (bt.current = nt, or(nt), ir(nt));
496
+ let Te, Ve;
497
+ if (Vt && He.length > 0) {
498
+ const Ge = He.length - 1, ot = Math.max(0, Math.min(Ge, Math.round(Dt * Ge))), st = Math.max(ot, Math.min(Ge, Math.round(Kt * Ge)));
499
+ Te = He[ot], Ve = He[st];
711
500
  } else {
712
- const Ke = Math.round(Te + wt * ht), Je = Math.round(Te + Dt * ht);
713
- ge = Me(U, Ke), Ce = Me(U, Je);
501
+ const Ge = Math.round($e + Dt * zt), ot = Math.round($e + Kt * zt);
502
+ Te = ce(z, Ge), Ve = ce(z, ot);
714
503
  }
715
- const xt = `${ge.getTime()}_${Ce.getTime()}`;
716
- xt !== Ut.current && (Ut.current = xt, Qe.onChangeMacroRange?.(ge, Ce), Qe.onChangeMacroRangeTuple?.([ge, Ce]), Qe.onChangeMacro?.([ge, Ce]));
717
- let Pe, Xe;
718
- if ($.handle === "macro-connect") {
719
- const Ke = ue(E, ge), Je = jt(U, E, Ce);
720
- let et, ut;
721
- if (U === "year") {
722
- const tt = ge.getFullYear() - $.startMacroLowDate.getFullYear();
723
- et = Le("year", $.initialMicroLowDate, tt), ut = Le("year", $.initialMicroHighDate, tt);
724
- } else if (U === "month") {
725
- const tt = (ge.getFullYear() - $.startMacroLowDate.getFullYear()) * 12 + (ge.getMonth() - $.startMacroLowDate.getMonth());
726
- et = Le("month", $.initialMicroLowDate, tt), ut = Le("month", $.initialMicroHighDate, tt);
504
+ const qt = `${Te.getTime()}_${Ve.getTime()}`;
505
+ qt !== $r.current && ($r.current = qt, kt(Te, Ve));
506
+ let Ue, at;
507
+ if (v.handle === "macro-connect") {
508
+ const Ge = We(N, Te), ot = yt(z, N, Ve);
509
+ let st, At;
510
+ if (z === "year") {
511
+ const ct = Te.getFullYear() - v.startMacroLowDate.getFullYear();
512
+ st = ke("year", v.initialMicroLowDate, ct), At = ke("year", v.initialMicroHighDate, ct);
513
+ } else if (z === "month") {
514
+ const ct = (Te.getFullYear() - v.startMacroLowDate.getFullYear()) * 12 + (Te.getMonth() - v.startMacroLowDate.getMonth());
515
+ st = ke("month", v.initialMicroLowDate, ct), At = ke("month", v.initialMicroHighDate, ct);
727
516
  } else {
728
- const tt = Math.round((ge.getTime() - $.startMacroLowDate.getTime()) / 864e5);
729
- et = Le("day", $.initialMicroLowDate, tt), ut = Le("day", $.initialMicroHighDate, tt);
517
+ const ct = Math.round((Te.getTime() - v.startMacroLowDate.getTime()) / 864e5);
518
+ st = ke("day", v.initialMicroLowDate, ct), At = ke("day", v.initialMicroHighDate, ct);
730
519
  }
731
- const dt = Ke.getTime(), vt = Je.getTime(), ya = $.initialMicroHighDate.getTime() - $.initialMicroLowDate.getTime();
732
- let pt = et.getTime(), yt = ut.getTime();
733
- pt < dt && (pt = dt, yt = Math.min(vt, pt + ya)), yt > vt && (yt = vt, pt = Math.max(dt, yt - ya)), Pe = ue(E, new Date(pt)), Xe = ue(E, new Date(yt));
520
+ const Ct = Ge.getTime(), jt = ot.getTime(), on = v.initialMicroHighDate.getTime() - v.initialMicroLowDate.getTime();
521
+ let Gt = st.getTime(), Wt = At.getTime();
522
+ Gt < Ct && (Gt = Ct, Wt = Math.min(jt, Gt + on)), Wt > jt && (Wt = jt, Gt = Math.max(Ct, Wt - on)), Ue = We(N, new Date(Gt)), at = We(N, new Date(Wt));
734
523
  } else {
735
- const Ke = ge.getTime(), Je = jt(U, E, Ce).getTime(), et = $.initialMicroLowDate.getTime(), ut = $.initialMicroHighDate.getTime(), dt = Math.max(Ke, Math.min(Je, et)), vt = Math.max(dt, Math.min(Je, ut));
736
- Pe = ue(E, new Date(dt)), Xe = ue(E, new Date(vt));
524
+ const Ge = Te.getTime(), ot = yt(z, N, Ve).getTime(), st = v.initialMicroLowDate.getTime(), At = v.initialMicroHighDate.getTime(), Ct = Math.max(Ge, Math.min(ot, st)), jt = Math.max(Ct, Math.min(ot, At));
525
+ Ue = We(N, new Date(Ct)), at = We(N, new Date(jt));
737
526
  }
738
- const Vt = `${Pe.getTime()}_${Xe.getTime()}`;
739
- Vt !== Mt.current && (Mt.current = Vt, Qe.onChangeRange?.(Pe, Xe), Qe.onChangeRangeTuple?.([Pe, Xe]));
740
- } else if ($.handle === "micro-low" || $.handle === "micro-high" || $.handle === "micro-connect") {
741
- const [wt, Dt, Ze] = nn($.handle, pa, $.startPointerRatio, $.startMicroLowRatio, $.startMicroHighRatio);
742
- Ze !== at.current && (at.current = Ze, Rt(Ze), kt(Ze));
743
- let ge, Ce;
744
- if (Jt && ft.length > 0) {
745
- const Pe = ft.length - 1, Xe = Math.max(0, Math.min(Pe, Math.round(wt * Pe))), Vt = Math.max(Xe, Math.min(Pe, Math.round(Dt * Pe)));
746
- ge = ft[Xe] ?? /* @__PURE__ */ new Date(), Ce = ft[Vt] ?? /* @__PURE__ */ new Date();
527
+ const hr = `${Ue.getTime()}_${at.getTime()}`;
528
+ hr !== Xt.current && (Xt.current = hr, tt(Ue, at));
529
+ } else if (v.handle === "micro-low" || v.handle === "micro-high" || v.handle === "micro-connect") {
530
+ const [Dt, Kt, nt] = ra(v.handle, Ye, v.startPointerRatio, v.startMicroLowRatio, v.startMicroHighRatio);
531
+ nt !== bt.current && (bt.current = nt, or(nt), ir(nt));
532
+ let Te, Ve;
533
+ if (it && Fe.length > 0) {
534
+ const Ue = Fe.length - 1, at = Math.max(0, Math.min(Ue, Math.round(Dt * Ue))), hr = Math.max(at, Math.min(Ue, Math.round(Kt * Ue)));
535
+ Te = Fe[at], Ve = Fe[hr];
747
536
  } else {
748
- const Pe = Math.round(he + wt * bt), Xe = Math.round(he + Dt * bt);
749
- ge = Me(E, Pe), Ce = Me(E, Xe);
537
+ const Ue = Math.round(we + Dt * _t), at = Math.round(we + Kt * _t);
538
+ Te = ce(N, Ue), Ve = ce(N, at);
750
539
  }
751
- const xt = `${ge.getTime()}_${Ce.getTime()}`;
752
- xt !== Mt.current && (Mt.current = xt, Qe.onChangeRange?.(ge, Ce), Qe.onChangeRangeTuple?.([ge, Ce]));
540
+ const qt = `${Te.getTime()}_${Ve.getTime()}`;
541
+ qt !== Xt.current && (Xt.current = qt, tt(Te, Ve));
753
542
  }
754
543
  return;
755
544
  }
756
- const c = St.current;
757
- if (!c || i.pointerId !== 0 && i.pointerId !== c.pointerId || !He.current) return;
758
- const g = He.current.getBoundingClientRect(), D = n ? i.clientY : i.clientX, C = n ? g.height : g.width;
759
- if (C <= 0) return;
760
- if (c.handle === "connect") {
761
- const $ = n ? (c.startPointerPos - D) / C : (D - c.startPointerPos) / C, be = Ja($, c.startLowVal, c.startHighVal, v, M, I, f);
762
- if (be) {
763
- if (Be.current && Be.current[0] === be[0] && Be.current[1] === be[1])
764
- return;
765
- Be.current = be, Re(be), ze(be[0], be[1], !1);
766
- }
545
+ const l = ur.current;
546
+ if (!l || i.pointerId !== 0 && i.pointerId !== l.pointerId || !rt.current) return;
547
+ const u = rt.current.getBoundingClientRect(), b = c ? i.clientY : i.clientX, R = c ? u.height : u.width;
548
+ if (!(Number.isFinite(R) && R > 0)) return;
549
+ if (l.handle === "connect") {
550
+ const v = c ? (l.startPointerPos - b) / R : (b - l.startPointerPos) / R, Ye = Gn({
551
+ posDiffPct: v,
552
+ startLowVal: l.startLowVal,
553
+ startHighVal: l.startHighVal,
554
+ rangeMin: S,
555
+ rangeMax: H,
556
+ isDiscrete: L,
557
+ sortedAllowedDates: m,
558
+ snapMode: s,
559
+ unit: t
560
+ });
561
+ if (je.current && je.current[0] === Ye[0] && je.current[1] === Ye[1])
562
+ return;
563
+ je.current = Ye, de(Ye), qe(Ye[0], Ye[1], !1);
767
564
  return;
768
565
  }
769
- const _ = Ft(i.clientX, i.clientY), re = At(_), [y, J] = Ra(c.handle, re, c.startLowVal, c.startHighVal, v, M, x);
770
- if ((!Be.current || Be.current[0] !== y || Be.current[1] !== J) && (Be.current = [y, J], Re([y, J]), ze(y, J, !1)), !x && (c.handle === "low" || c.handle === "high")) {
771
- const $ = Za(c.handle, re, c.startLowVal, c.startHighVal, x);
772
- Ee.current !== $ && (Ee.current = $, je($), S($));
566
+ const ee = pt(i.clientX, i.clientY, u);
567
+ if (ee === null) return;
568
+ const ie = sr(ee * 100), [V, q] = dn(l.handle, ie, l.startLowVal, l.startHighVal, S, H, P);
569
+ if ((!je.current || je.current[0] !== V || je.current[1] !== q) && (je.current = [V, q], de([V, q]), qe(V, q, !1)), !P && (l.handle === "low" || l.handle === "high")) {
570
+ const v = jn(l.handle, ie, l.startLowVal, l.startHighVal, P);
571
+ Ee.current !== v && (Ee.current = v, be(v), se(v));
773
572
  }
774
573
  },
775
574
  [
776
- d,
777
575
  o,
778
- n,
779
- U,
780
- E,
781
- Zt,
782
- Jt,
783
- gt,
784
- ft,
785
- Te,
786
- ht,
787
- he,
788
- bt,
789
- v,
790
- M,
791
- I,
792
- f,
793
- Ft,
794
- At,
795
- ze,
796
- x
576
+ J,
577
+ c,
578
+ z,
579
+ N,
580
+ Vt,
581
+ it,
582
+ He,
583
+ Fe,
584
+ $e,
585
+ zt,
586
+ we,
587
+ _t,
588
+ S,
589
+ H,
590
+ L,
591
+ m,
592
+ s,
593
+ t,
594
+ pt,
595
+ sr,
596
+ qe,
597
+ kt,
598
+ tt,
599
+ P
797
600
  ]
798
- ), sa = K(
601
+ ), jr = U(
799
602
  (i) => {
800
- if (o) {
801
- Ut.current = null, Mt.current = null, Ot.current = null, at.current = null, Rt(null);
603
+ if (J) {
604
+ $r.current = null, Xt.current = null, Sr.current = null, bt.current = null, or(null), Rr(Tr.current), Rr(Lr.current);
802
605
  return;
803
606
  }
804
- const c = St.current;
805
- if (!c || i.pointerId !== 0 && i.pointerId !== c.pointerId) return;
806
- const g = Be.current ?? Ye;
807
- g && (ze(g[0], g[1], !0), xe(g)), Be.current = null, Re(null), St.current = null, Ee.current = null, je(null);
607
+ const l = ur.current;
608
+ if (!l || i.pointerId !== 0 && i.pointerId !== l.pointerId) return;
609
+ const u = je.current ?? G;
610
+ u && (qe(u[0], u[1], !0), F(u)), je.current = null, de(null), ur.current = null, Ee.current = null, be(null);
808
611
  },
809
- [o, Ye, ze]
810
- ), ca = Q(la);
811
- ca.current = la;
812
- const ua = Q(sa);
813
- ua.current = sa;
814
- const da = we !== null || ye !== null;
815
- ot(() => {
816
- if (!da) return;
817
- const i = (g) => ca.current(g), c = (g) => ua.current(g);
818
- return window.addEventListener("pointermove", i), window.addEventListener("pointerup", c), window.addEventListener("pointercancel", c), () => {
819
- window.removeEventListener("pointermove", i), window.removeEventListener("pointerup", c), window.removeEventListener("pointercancel", c);
612
+ [J, G, qe, Rr]
613
+ ), Gr = j(qr);
614
+ Gr.current = qr;
615
+ const Wr = j(jr);
616
+ Wr.current = jr;
617
+ const Jr = $ !== null || Le !== null;
618
+ xt(() => {
619
+ if (!Jr) return;
620
+ const i = (u) => Gr.current(u), l = (u) => Wr.current(u);
621
+ return window.addEventListener("pointermove", i), window.addEventListener("pointerup", l), window.addEventListener("pointercancel", l), () => {
622
+ window.removeEventListener("pointermove", i), window.removeEventListener("pointerup", l), window.removeEventListener("pointercancel", l);
820
623
  };
821
- }, [da]);
822
- const zt = K(
823
- (i, c, g) => {
824
- St.current = {
624
+ }, [Jr]);
625
+ const kr = U(
626
+ (i, l, u) => {
627
+ ur.current = {
825
628
  pointerId: i,
826
- handle: c,
827
- startPointerPos: g,
828
- startLowVal: ne,
829
- startHighVal: ce
830
- }, Ee.current = c, je(c), c !== "connect" && S(c);
629
+ handle: l,
630
+ startPointerPos: u,
631
+ startLowVal: fe,
632
+ startHighVal: ge
633
+ }, Ee.current = l, be(l), l !== "connect" && se(l);
831
634
  },
832
- [ne, ce]
833
- ), ma = K(
834
- (i, c, g) => {
835
- const D = B.current;
836
- Ot.current = {
635
+ [fe, ge]
636
+ ), Zr = U(
637
+ (i, l, u) => {
638
+ const b = y.current;
639
+ b.mode === "vernier" && (Sr.current = {
837
640
  pointerId: i,
838
- handle: c,
839
- startPointerRatio: g,
840
- startMacroLowRatio: ve,
841
- startMacroHighRatio: Se,
842
- startMicroLowRatio: Oe,
843
- startMicroHighRatio: nt,
641
+ handle: l,
642
+ startPointerRatio: u,
643
+ startMacroLowRatio: ye,
644
+ startMacroHighRatio: Ne,
645
+ startMicroLowRatio: Ke,
646
+ startMicroHighRatio: wt,
844
647
  startMacroLowEnc: _e,
845
- startMacroHighEnc: Ge,
846
- startMicroLowEnc: Ae,
847
- startMicroHighEnc: Fe,
848
- startMacroLowDate: D.macroRange[0],
849
- startMacroHighDate: D.macroRange[1],
850
- initialMicroLowDate: q,
851
- initialMicroHighDate: fe
852
- }, at.current = c, Rt(c), kt(c);
648
+ startMacroHighEnc: Xe,
649
+ startMicroLowEnc: Me,
650
+ startMicroHighEnc: xe,
651
+ startMacroLowDate: b.macroRange[0],
652
+ startMacroHighDate: b.macroRange[1],
653
+ initialMicroLowDate: Ut,
654
+ initialMicroHighDate: Bt
655
+ }, bt.current = l, or(l), ir(l));
853
656
  },
854
- [ve, Se, Oe, nt, _e, Ge, Ae, Fe]
855
- ), ga = (i) => (c) => {
856
- if (d) return;
857
- c.stopPropagation(), c.preventDefault(), S(i);
858
- const g = n ? c.clientY : c.clientX;
859
- zt(c.pointerId, i, g);
860
- }, lt = (i) => (c) => {
861
- if (d || (c.stopPropagation(), c.preventDefault(), !He.current)) return;
862
- const g = He.current.getBoundingClientRect(), D = n ? Math.max(0, Math.min(1, (g.bottom - c.clientY) / (g.height > 0 ? g.height : 100))) : Math.max(0, Math.min(1, (c.clientX - g.left) / (g.width > 0 ? g.width : 100)));
863
- ma(c.pointerId, i, D);
864
- }, Fa = (i) => {
865
- if (d || b) return;
657
+ [ye, Ne, Ke, wt, _e, Xe, Me, xe, Ut, Bt]
658
+ ), Qr = (i) => (l) => {
659
+ if (o) return;
660
+ l.stopPropagation(), l.preventDefault(), se(i);
661
+ const u = c ? l.clientY : l.clientX;
662
+ kr(l.pointerId, i, u);
663
+ }, Pt = (i) => (l) => {
664
+ if (o) return;
665
+ l.stopPropagation(), l.preventDefault();
666
+ const u = rt.current;
667
+ if (!u) return;
668
+ const b = pt(l.clientX, l.clientY, u.getBoundingClientRect());
669
+ b !== null && Zr(l.pointerId, i, b);
670
+ }, Sn = (i) => {
671
+ if (o || p) return;
866
672
  i.stopPropagation(), i.preventDefault();
867
- const c = n ? i.clientY : i.clientX;
868
- zt(i.pointerId, "connect", c);
869
- }, Sa = (i) => {
870
- if (d) return;
871
- if (o) {
872
- if (!He.current) return;
873
- const y = He.current.getBoundingClientRect(), J = n ? Math.max(0, Math.min(1, (y.bottom - i.clientY) / (y.height > 0 ? y.height : 100))) : Math.max(0, Math.min(1, (i.clientX - y.left) / (y.width > 0 ? y.width : 100))), $ = n ? i.clientX - (y.left + y.width / 2) : i.clientY - (y.top + y.height / 2), be = tn(J, $, ve, Se, Oe, nt, H);
874
- ma(i.pointerId, be, J);
673
+ const l = c ? i.clientY : i.clientX;
674
+ kr(i.pointerId, "connect", l);
675
+ }, $n = (i) => {
676
+ if (o) return;
677
+ if (J) {
678
+ const V = rt.current;
679
+ if (!V) return;
680
+ const q = V.getBoundingClientRect(), v = pt(i.clientX, i.clientY, q);
681
+ if (v === null) return;
682
+ const Ye = c ? i.clientX - (q.left + q.width / 2) : i.clientY - (q.top + q.height / 2), Dt = ea(v, Ye, ye, Ne, Ke, wt, gt);
683
+ Zr(i.pointerId, Dt, v);
875
684
  return;
876
685
  }
877
- const c = Ft(i.clientX, i.clientY), g = At(c);
878
- let D = "low";
879
- if (!x) {
880
- const y = Math.abs(g - ne), J = Math.abs(g - ce);
881
- y < J ? D = "low" : J < y ? D = "high" : D = g > ce ? "high" : "low";
686
+ const l = Kr(i.clientX, i.clientY);
687
+ if (l === null) return;
688
+ const u = sr(l);
689
+ let b = "low";
690
+ if (!P) {
691
+ const V = Math.abs(u - fe), q = Math.abs(u - ge);
692
+ V < q ? b = "low" : q < V ? b = "high" : b = u > ge ? "high" : "low";
882
693
  }
883
- S(D);
884
- const [C, _] = Ra(D, g, ne, ce, v, M, x);
885
- Re([C, _]), ze(C, _, !0);
886
- const re = n ? i.clientY : i.clientX;
887
- zt(i.pointerId, D, re);
888
- }, Ha = (i) => {
889
- if (d || we !== null) return;
890
- const c = Ft(i.clientX, i.clientY), g = At(c);
891
- ae(g), ie($t(g));
892
- }, Pa = () => {
893
- ae(null), ie(null);
894
- }, fa = (i) => (c) => {
895
- if (d) return;
896
- S(i);
897
- const g = Qa(c.key, i, ne, ce, v, M, x, 1);
898
- g && (c.preventDefault(), de || xe(g), ze(g[0], g[1], !0));
899
- }, Ht = (i) => (c) => {
900
- if (d || !o || e.mode !== "vernier") return;
901
- kt(i);
902
- let g = 0, D = !1, C = !1;
903
- switch (c.key) {
694
+ se(b);
695
+ const [R, ee] = dn(b, u, fe, ge, S, H, P);
696
+ de([R, ee]), qe(R, ee, !0);
697
+ const ie = c ? i.clientY : i.clientX;
698
+ kr(i.pointerId, b, ie);
699
+ }, kn = (i) => {
700
+ if (o || $ !== null) return;
701
+ const l = Kr(i.clientX, i.clientY);
702
+ if (l === null) return;
703
+ const u = sr(l);
704
+ ft(u), rr(lr(u));
705
+ }, Pn = () => {
706
+ ft(null), rr(null);
707
+ }, en = (i) => (l) => {
708
+ if (o) return;
709
+ se(i);
710
+ const u = Wn(l.key, i, fe, ge, S, H, P, 1);
711
+ u && (l.preventDefault(), ue || F(u), qe(u[0], u[1], !0));
712
+ }, dr = (i) => (l) => {
713
+ if (o || !J || e.mode !== "vernier") return;
714
+ ir(i);
715
+ let u = 0, b = !1, R = !1;
716
+ switch (l.key) {
904
717
  case "ArrowRight":
905
718
  case "ArrowUp":
906
- g = 1;
719
+ u = 1;
907
720
  break;
908
721
  case "ArrowLeft":
909
722
  case "ArrowDown":
910
- g = -1;
723
+ u = -1;
911
724
  break;
912
725
  case "PageUp":
913
- g = 5;
726
+ u = 5;
914
727
  break;
915
728
  case "PageDown":
916
- g = -5;
729
+ u = -5;
917
730
  break;
918
731
  case "Home":
919
- D = !0;
732
+ b = !0;
920
733
  break;
921
734
  case "End":
922
- C = !0;
735
+ R = !0;
923
736
  break;
924
737
  default:
925
738
  return;
926
739
  }
927
- c.preventDefault();
928
- const _ = (y, J) => {
929
- e.onChangeMacroRange?.(y, J), e.onChangeMacroRangeTuple?.([y, J]), e.onChangeMacro?.([y, J]);
930
- }, re = (y, J) => {
931
- e.onChangeRange?.(y, J), e.onChangeRangeTuple?.([y, J]), e.onChangeMicroRange?.(y, J), e.onChangeMicroRangeTuple?.([y, J]), e.onChangeMicro?.([y, J]);
932
- };
740
+ l.preventDefault();
741
+ const ee = Vt && He.length > 0, ie = it && Fe.length > 0;
933
742
  if (i === "macro-low") {
934
- let y;
935
- D ? y = Te : C ? y = Ge : y = Math.max(Te, Math.min(Ge, _e + g)), _(Me(U, y), Me(U, Ge));
743
+ const V = ce(z, _e), q = ce(z, Xe);
744
+ if (ee) {
745
+ kt(br(He, z, V, He[0], q, u, b, R), q, !0);
746
+ return;
747
+ }
748
+ let v;
749
+ b ? v = $e : R ? v = Xe : v = Math.max($e, Math.min(Xe, _e + u)), kt(ce(z, v), q, !0);
936
750
  } else if (i === "macro-high") {
937
- let y;
938
- D ? y = _e : C ? y = it : y = Math.max(_e, Math.min(it, Ge + g)), _(Me(U, _e), Me(U, y));
751
+ const V = ce(z, _e), q = ce(z, Xe);
752
+ if (ee) {
753
+ kt(V, br(He, z, q, V, He[He.length - 1], u, b, R), !0);
754
+ return;
755
+ }
756
+ let v;
757
+ b ? v = _e : R ? v = Rt : v = Math.max(_e, Math.min(Rt, Xe + u)), kt(V, ce(z, v), !0);
939
758
  } else if (i === "micro-low") {
940
- let y;
941
- D ? y = he : C ? y = Fe : y = Math.max(he, Math.min(Fe, Ae + g)), re(Me(E, y), Me(E, Fe));
759
+ const V = ce(N, Me), q = ce(N, xe);
760
+ if (ie) {
761
+ tt(br(Fe, N, V, Fe[0], q, u, b, R), q, !0);
762
+ return;
763
+ }
764
+ let v;
765
+ b ? v = we : R ? v = xe : v = Math.max(we, Math.min(xe, Me + u)), tt(ce(N, v), q, !0);
942
766
  } else if (i === "micro-high") {
943
- let y;
944
- D ? y = Ae : C ? y = We : y = Math.max(Ae, Math.min(We, Fe + g)), re(Me(E, Ae), Me(E, y));
767
+ const V = ce(N, Me), q = ce(N, xe);
768
+ if (ie) {
769
+ tt(V, br(Fe, N, q, V, Fe[Fe.length - 1], u, b, R), !0);
770
+ return;
771
+ }
772
+ let v;
773
+ b ? v = Me : R ? v = Oe : v = Math.max(Me, Math.min(Oe, xe + u)), tt(V, ce(N, v), !0);
945
774
  }
946
- }, ha = K(
775
+ }, Nn = U(
947
776
  (i) => {
948
- const c = B.current;
949
- if (!c.disabled)
950
- if (c.mode === "point") {
951
- const g = Math.max(v, Math.min(M, ne + i));
952
- de || xe([g, g]), ze(g, g, !0);
953
- } else if (c.mode === "vernier") {
954
- const g = Ae, D = Fe, C = he, _ = We, re = D - g;
955
- let y = g + i, J = D + i;
956
- if (i < 0 && y < C ? (y = C, J = Math.min(_, y + re)) : i > 0 && J > _ && (J = _, y = Math.max(C, J - re)), y !== g || J !== D) {
957
- const $ = Me(E, y), be = Me(E, J);
958
- c.onChangeRange?.($, be), c.onChangeRangeTuple?.([$, be]);
959
- }
777
+ const l = y.current;
778
+ if (!l.disabled)
779
+ if (l.mode === "point") {
780
+ const u = Math.max(S, Math.min(H, fe + i));
781
+ ue || F([u, u]), qe(u, u, !0);
782
+ } else if (l.mode === "vernier") {
783
+ const u = Me, b = xe, R = we, ee = Oe, ie = b - u;
784
+ let V = u + i, q = b + i;
785
+ i < 0 && V < R ? (V = R, q = Math.min(ee, V + ie)) : i > 0 && q > ee && (q = ee, V = Math.max(R, q - ie)), (V !== u || q !== b) && tt(ce(N, V), ce(N, q), !0);
960
786
  } else {
961
- const g = ce - ne;
962
- let D = ne + i, C = ce + i;
963
- i < 0 && D < v ? (D = v, C = Math.min(M, D + g)) : i > 0 && C > M && (C = M, D = Math.max(v, C - g)), D <= C && (de || xe([D, C]), ze(D, C, !0));
787
+ const u = ge - fe;
788
+ let b = fe + i, R = ge + i;
789
+ i < 0 && b < S ? (b = S, R = Math.min(H, b + u)) : i > 0 && R > H && (R = H, b = Math.max(S, R - u)), b <= R && (ue || F([b, R]), qe(b, R, !0));
964
790
  }
965
791
  },
966
- [ne, ce, v, M, de, ze, Ae, Fe, he, We, E]
967
- ), st = $t(ne), ct = $t(ce), Bt = oe(ne), Xt = oe(ce), Ne = R(() => {
968
- const i = p === "top" ? -18 : 18;
969
- return x || !A || n ? {
970
- lowAngleDeg: 0,
971
- highAngleDeg: 0,
972
- lowOffsetX: 0,
973
- highOffsetX: 0,
974
- lowOffsetY: i,
975
- highOffsetY: i,
976
- isSlanted: !1,
977
- proximity: 0
978
- } : en(st, ct, oa, p, t);
979
- }, [x, A, n, st, ct, oa, p, t]), Pt = we === "low" || we !== "high" && L === "low", Et = !x && (we === "high" || we !== "low" && L === "high"), Ea = R(() => n ? {
792
+ [fe, ge, S, H, ue, qe, tt, Me, xe, we, Oe, N]
793
+ ), Nt = lr(fe), Yt = lr(ge), Pr = ne(fe), Nr = ne(ge), Yr = Y(() => {
794
+ if (P) return vt === null ? void 0 : { estimatedWidthPx: vt.widthPx, estimatedHeightPx: vt.heightPx };
795
+ if (!(vt === null || cr === null))
796
+ return {
797
+ estimatedWidthPx: Math.max(vt.widthPx, cr.widthPx),
798
+ estimatedHeightPx: Math.max(vt.heightPx, cr.heightPx)
799
+ };
800
+ }, [P, vt, cr]), Re = Y(() => P || !x || c ? yn(M, Yr) : Qn(Nt, Yt, _r, M, Yr), [P, x, c, Nt, Yt, _r, M, Yr]), mr = $ === "low" || $ !== "high" && Qe === "low", fr = !P && ($ === "high" || $ !== "low" && Qe === "high"), Yn = Y(() => c ? {
980
801
  "--ps-tooltip-origin": "100% 50%",
981
802
  "--ps-tooltip-tx": "0px",
982
803
  "--ps-tooltip-ty": "-50%",
983
804
  "--ps-tooltip-rot": "0deg"
984
805
  } : {
985
806
  "--ps-tooltip-origin": "50% 50%",
986
- "--ps-tooltip-tx": `calc(-50% + ${Ne.lowOffsetX}px)`,
987
- "--ps-tooltip-ty": `calc(-50% + ${Ne.lowOffsetY}px)`,
988
- "--ps-tooltip-rot": `${Ne.lowAngleDeg}deg`
989
- }, [n, Ne.lowOffsetX, Ne.lowOffsetY, Ne.lowAngleDeg]), Ia = R(() => n ? {
807
+ "--ps-tooltip-tx": `calc(-50% + ${Re.lowOffsetX}px)`,
808
+ "--ps-tooltip-ty": `calc(-50% + ${Re.lowOffsetY}px)`,
809
+ "--ps-tooltip-rot": `${Re.lowAngleDeg}deg`
810
+ }, [c, Re.lowOffsetX, Re.lowOffsetY, Re.lowAngleDeg]), An = Y(() => c ? {
990
811
  "--ps-tooltip-origin": "100% 50%",
991
812
  "--ps-tooltip-tx": "0px",
992
813
  "--ps-tooltip-ty": "-50%",
993
814
  "--ps-tooltip-rot": "0deg"
994
815
  } : {
995
816
  "--ps-tooltip-origin": "50% 50%",
996
- "--ps-tooltip-tx": `calc(-50% + ${Ne.highOffsetX}px)`,
997
- "--ps-tooltip-ty": `calc(-50% + ${Ne.highOffsetY}px)`,
998
- "--ps-tooltip-rot": `${Ne.highAngleDeg}deg`
999
- }, [n, Ne.highOffsetX, Ne.highOffsetY, Ne.highAngleDeg]), It = Math.min(st, ct), ba = Math.max(st, ct), Va = n ? {
1000
- bottom: `${It}%`,
1001
- height: `${ba - It}%`,
817
+ "--ps-tooltip-tx": `calc(-50% + ${Re.highOffsetX}px)`,
818
+ "--ps-tooltip-ty": `calc(-50% + ${Re.highOffsetY}px)`,
819
+ "--ps-tooltip-rot": `${Re.highAngleDeg}deg`
820
+ }, [c, Re.highOffsetX, Re.highOffsetY, Re.highAngleDeg]), gr = Math.min(Nt, Yt), tn = Math.max(Nt, Yt), Cn = c ? {
821
+ bottom: `${gr}%`,
822
+ height: `${tn - gr}%`,
1002
823
  top: "auto",
1003
824
  left: "0",
1004
825
  right: "0"
1005
826
  } : {
1006
- left: `${It}%`,
1007
- width: `${ba - It}%`,
827
+ left: `${gr}%`,
828
+ width: `${tn - gr}%`,
1008
829
  top: "0",
1009
830
  bottom: "0"
1010
- }, Oa = Math.max(0.01, Se - ve), Ma = Math.max(0.06, Math.min(0.25, 0.28 * Math.sqrt(Oa))), Ua = n ? { bottom: `${st}%`, left: "50%", transform: "translate(-50%, 50%)", zIndex: Pt ? 40 : 30 } : { left: `${st}%`, top: "50%", transform: "translate(-50%, -50%)", zIndex: Pt ? 40 : 30 }, za = n ? { bottom: `${ct}%`, left: "50%", transform: "translate(-50%, 50%)", zIndex: Et ? 40 : 30 } : { left: `${ct}%`, top: "50%", transform: "translate(-50%, -50%)", zIndex: Et ? 40 : 30 }, Ba = n ? { bottom: `${Y}%`, left: "50%", transform: "translate(-50%, 50%)" } : { left: `${Y}%`, top: "50%", transform: "translate(-50%, -50%)" }, wa = Z !== null ? oe(Z) : null, Da = d || (o ? Ae <= he : x ? ne <= v : ne <= v && ce <= v), xa = d || (o ? Fe >= We : (x || ne >= M) && ce >= M), qe = d ? "cursor-not-allowed opacity-50" : "cursor-pointer";
831
+ }, En = Math.max(0.01, Ne - ye), rn = Math.max(0.06, Math.min(0.25, 0.28 * Math.sqrt(En))), In = c ? { bottom: `${Nt}%`, left: "50%", transform: "translate(-50%, 50%)", zIndex: mr ? 40 : 30 } : { left: `${Nt}%`, top: "50%", transform: "translate(-50%, -50%)", zIndex: mr ? 40 : 30 }, Hn = c ? { bottom: `${Yt}%`, left: "50%", transform: "translate(-50%, 50%)", zIndex: fr ? 40 : 30 } : { left: `${Yt}%`, top: "50%", transform: "translate(-50%, -50%)", zIndex: fr ? 40 : 30 }, On = c ? { bottom: `${Ft}%`, left: "50%", transform: "translate(-50%, 50%)" } : { left: `${Ft}%`, top: "50%", transform: "translate(-50%, -50%)" }, nn = De !== null ? ne(De) : null, Fn = o || (J ? Me <= we : P ? fe <= S : fe <= S && ge <= S), Vn = o || (J ? xe >= Oe : (P || fe >= H) && ge >= H), lt = o ? "cursor-not-allowed opacity-50" : "cursor-pointer", an = (i) => {
832
+ const l = c ? "vertical" : "horizontal", u = i === "decrease", b = la[l][i];
833
+ return /* @__PURE__ */ w(
834
+ "button",
835
+ {
836
+ type: "button",
837
+ className: `period-slider-stepper-btn relative after:absolute after:inset-[-11px] after:content-[''] ${b} flex h-6 w-6 shrink-0 items-center justify-center rounded-md border border-slate-300 bg-white font-bold text-[10px] text-slate-700 leading-none shadow-2xs transition-all hover:bg-slate-100 hover:text-indigo-600 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 active:scale-95 disabled:cursor-not-allowed disabled:opacity-30 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-200 dark:hover:bg-slate-700 ${lt}`,
838
+ onClick: () => Nn(u ? -1 : 1),
839
+ disabled: u ? Fn : Vn,
840
+ "aria-label": u ? W : C,
841
+ children: ia[l][i]
842
+ }
843
+ );
844
+ };
1011
845
  return /* @__PURE__ */ le(
1012
846
  "div",
1013
847
  {
1014
848
  style: e.style,
1015
- className: `period-slider flex select-none items-center gap-2 ${n ? "flex-col" : "flex-row"} ${h}`,
1016
- "data-disabled": d ? "true" : void 0,
849
+ className: `period-slider flex select-none items-center gap-2 ${c ? "flex-col" : "flex-row"} ${d}`,
850
+ "data-disabled": o ? "true" : void 0,
1017
851
  "data-unit": t,
1018
852
  "data-mode": e.mode,
1019
- "data-orientation": n ? "vertical" : "horizontal",
1020
- "data-label-position": p,
1021
- "data-color-scheme": z,
853
+ "data-orientation": c ? "vertical" : "horizontal",
854
+ "data-label-position": M,
855
+ "data-color-scheme": Z,
1022
856
  children: [
1023
- u && /* @__PURE__ */ T(
1024
- "button",
1025
- {
1026
- type: "button",
1027
- className: `period-slider-stepper-btn relative after:absolute after:inset-[-10px] after:content-[''] ${n ? "period-slider-stepper-next period-slider-stepper-up" : "period-slider-stepper-prev"} flex h-6 w-6 shrink-0 items-center justify-center rounded-md border border-slate-300 bg-white font-bold text-[10px] text-slate-700 leading-none shadow-2xs transition-all hover:bg-slate-100 hover:text-indigo-600 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 active:scale-95 disabled:cursor-not-allowed disabled:opacity-30 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-200 dark:hover:bg-slate-700 ${qe}`,
1028
- onClick: () => ha(n ? 1 : -1),
1029
- disabled: n ? xa : Da,
1030
- "aria-label": n ? "1つ後へ" : "1つ前へ",
1031
- children: n ? "▲" : "◀"
1032
- }
1033
- ),
1034
- /* @__PURE__ */ T(
857
+ g && an(c ? "increase" : "decrease"),
858
+ /* @__PURE__ */ w(
1035
859
  "div",
1036
860
  {
1037
- ref: He,
861
+ ref: rt,
1038
862
  "data-testid": "period-slider-track",
1039
- "data-orientation": n ? "vertical" : "horizontal",
1040
- "data-vernier-orientation": o ? H : void 0,
1041
- className: `period-slider-track relative flex-1 touch-none rounded-full bg-slate-200 dark:bg-slate-700 ${n ? "h-48 w-2" : "h-2 w-full"} ${qe}`,
1042
- onPointerDown: Sa,
1043
- onPointerMove: Ha,
1044
- onPointerLeave: Pa,
1045
- children: o ? /* @__PURE__ */ le(Ta, { children: [
1046
- pe && (n ? /* @__PURE__ */ le("svg", { className: "period-slider-vernier-projection is-vertical", role: "presentation", "aria-hidden": "true", width: "32", height: "100%", viewBox: "0 0 32 100", preserveAspectRatio: "none", children: [
1047
- /* @__PURE__ */ T("defs", { children: /* @__PURE__ */ le("linearGradient", { id: F, x1: "0", y1: "0", x2: "1", y2: "0", children: [
1048
- /* @__PURE__ */ T("stop", { offset: "0%", stopColor: w ? P.macro : P.micro, stopOpacity: "0.28" }),
1049
- /* @__PURE__ */ T("stop", { offset: "100%", stopColor: w ? P.micro : P.macro, stopOpacity: Ma })
863
+ "data-orientation": c ? "vertical" : "horizontal",
864
+ "data-vernier-orientation": J ? gt : void 0,
865
+ className: `period-slider-track relative flex-1 touch-none rounded-full bg-slate-200 dark:bg-slate-700 ${c ? "h-48 w-2" : "h-2 w-full"} ${lt}`,
866
+ onPointerDown: $n,
867
+ onPointerMove: kn,
868
+ onPointerLeave: Pn,
869
+ children: J ? /* @__PURE__ */ le(ln, { children: [
870
+ nr && (c ? /* @__PURE__ */ le("svg", { className: "period-slider-vernier-projection is-vertical", role: "presentation", "aria-hidden": "true", width: "32", height: "100%", viewBox: "0 0 32 100", preserveAspectRatio: "none", children: [
871
+ /* @__PURE__ */ w("defs", { children: /* @__PURE__ */ le("linearGradient", { id: O, x1: "0", y1: "0", x2: "1", y2: "0", children: [
872
+ /* @__PURE__ */ w("stop", { offset: "0%", stopColor: T ? A.macro : A.micro, stopOpacity: "0.28" }),
873
+ /* @__PURE__ */ w("stop", { offset: "100%", stopColor: T ? A.micro : A.macro, stopOpacity: rn })
1050
874
  ] }) }),
1051
- /* @__PURE__ */ T("polygon", { points: w ? `12,${(1 - Se) * 100} 12,${(1 - ve) * 100} 20,100 20,0` : `12,0 12,100 20,${(1 - ve) * 100} 20,${(1 - Se) * 100}`, fill: `url(#${F})` })
875
+ /* @__PURE__ */ w("polygon", { points: T ? `12,${(1 - Ne) * 100} 12,${(1 - ye) * 100} 20,100 20,0` : `12,0 12,100 20,${(1 - ye) * 100} 20,${(1 - Ne) * 100}`, fill: `url(#${O})` })
1052
876
  ] }) : /* @__PURE__ */ le("svg", { className: "period-slider-vernier-projection", role: "presentation", "aria-hidden": "true", width: "100%", height: "32", viewBox: "0 0 100 32", preserveAspectRatio: "none", children: [
1053
- /* @__PURE__ */ T("defs", { children: /* @__PURE__ */ le("linearGradient", { id: F, x1: "0", y1: "0", x2: "0", y2: "1", children: [
1054
- /* @__PURE__ */ T("stop", { offset: "0%", stopColor: w ? P.macro : P.micro, stopOpacity: "0.28" }),
1055
- /* @__PURE__ */ T("stop", { offset: "100%", stopColor: w ? P.micro : P.macro, stopOpacity: Ma })
877
+ /* @__PURE__ */ w("defs", { children: /* @__PURE__ */ le("linearGradient", { id: O, x1: "0", y1: "0", x2: "0", y2: "1", children: [
878
+ /* @__PURE__ */ w("stop", { offset: "0%", stopColor: T ? A.macro : A.micro, stopOpacity: "0.28" }),
879
+ /* @__PURE__ */ w("stop", { offset: "100%", stopColor: T ? A.micro : A.macro, stopOpacity: rn })
1056
880
  ] }) }),
1057
- /* @__PURE__ */ T("polygon", { points: w ? `${ve * 100},12 ${Se * 100},12 100,20 0,20` : `0,12 100,12 ${Se * 100},20 ${ve * 100},20`, fill: `url(#${F})` })
881
+ /* @__PURE__ */ w("polygon", { points: T ? `${ye * 100},12 ${Ne * 100},12 100,20 0,20` : `0,12 100,12 ${Ne * 100},20 ${ye * 100},20`, fill: `url(#${O})` })
1058
882
  ] })),
1059
- /* @__PURE__ */ T(
883
+ /* @__PURE__ */ w(
1060
884
  "div",
1061
885
  {
1062
886
  "data-testid": "period-slider-connect-macro",
1063
887
  className: "period-slider-connect-macro",
1064
- style: n ? {
1065
- bottom: `calc(${ve * 100}% - 8px)`,
1066
- height: `calc(${Math.max(0, (Se - ve) * 100)}% + 16px)`
888
+ style: c ? {
889
+ bottom: `calc(${ye * 100}% - 8px)`,
890
+ height: `calc(${Math.max(0, (Ne - ye) * 100)}% + 16px)`
1067
891
  } : {
1068
- left: `calc(${ve * 100}% - 8px)`,
1069
- width: `calc(${Math.max(0, (Se - ve) * 100)}% + 16px)`
892
+ left: `calc(${ye * 100}% - 8px)`,
893
+ width: `calc(${Math.max(0, (Ne - ye) * 100)}% + 16px)`
1070
894
  },
1071
- onPointerDown: lt("macro-connect")
895
+ onPointerDown: Pt("macro-connect")
1072
896
  }
1073
897
  ),
1074
- /* @__PURE__ */ T(
898
+ /* @__PURE__ */ w(
1075
899
  "div",
1076
900
  {
1077
901
  "data-testid": "period-slider-connect-micro",
1078
902
  className: "period-slider-connect-micro",
1079
- style: n ? {
1080
- bottom: `calc(${Oe * 100}% - 8px)`,
1081
- height: `calc(${Math.max(0, (nt - Oe) * 100)}% + 16px)`
903
+ style: c ? {
904
+ bottom: `calc(${Ke * 100}% - 8px)`,
905
+ height: `calc(${Math.max(0, (wt - Ke) * 100)}% + 16px)`
1082
906
  } : {
1083
- left: `calc(${Oe * 100}% - 8px)`,
1084
- width: `calc(${Math.max(0, (nt - Oe) * 100)}% + 16px)`
907
+ left: `calc(${Ke * 100}% - 8px)`,
908
+ width: `calc(${Math.max(0, (wt - Ke) * 100)}% + 16px)`
1085
909
  },
1086
- onPointerDown: lt("micro-connect")
910
+ onPointerDown: Pt("micro-connect")
1087
911
  }
1088
912
  ),
1089
- ke && /* @__PURE__ */ le("div", { className: "period-slider-vernier-ticks pointer-events-none absolute inset-0", children: [
1090
- [0.2, 0.4, 0.6, 0.8].map((i) => /* @__PURE__ */ T("div", { className: "period-slider-tick period-slider-tick-macro", style: n ? { bottom: `${i * 100}%` } : { left: `${i * 100}%` } }, `macro-tick-${i}`)),
1091
- [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9].map((i) => /* @__PURE__ */ T("div", { className: "period-slider-tick period-slider-tick-micro", style: n ? { bottom: `${i * 100}%` } : { left: `${i * 100}%` } }, `micro-tick-${i}`))
913
+ ar && /* @__PURE__ */ le("div", { className: "period-slider-vernier-ticks pointer-events-none absolute inset-0", children: [
914
+ [0.2, 0.4, 0.6, 0.8].map((i) => /* @__PURE__ */ w("div", { "data-testid": "period-slider-tick", "data-tick-scale": "macro", className: "period-slider-tick period-slider-tick-macro", style: c ? { bottom: `${i * 100}%` } : { left: `${i * 100}%` } }, `macro-tick-${i}`)),
915
+ [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9].map((i) => /* @__PURE__ */ w("div", { "data-testid": "period-slider-tick", "data-tick-scale": "micro", className: "period-slider-tick period-slider-tick-micro", style: c ? { bottom: `${i * 100}%` } : { left: `${i * 100}%` } }, `micro-tick-${i}`))
1092
916
  ] }),
1093
917
  /* @__PURE__ */ le(
1094
918
  "div",
1095
919
  {
1096
- tabIndex: d ? -1 : 0,
920
+ tabIndex: o ? -1 : 0,
1097
921
  role: "slider",
1098
- "aria-label": e.macroLowerAriaLabel ?? "マクロ開始時期",
1099
- "aria-disabled": d ? "true" : void 0,
1100
- "aria-valuemin": Te,
1101
- "aria-valuemax": Ge,
922
+ "aria-label": e.macroLowerAriaLabel ?? "Macro range start",
923
+ "aria-disabled": o ? "true" : void 0,
924
+ "aria-valuemin": $e,
925
+ "aria-valuemax": Xe,
1102
926
  "aria-valuenow": _e,
1103
- "aria-valuetext": e.formatAriaValueText ? e.formatAriaValueText(e.macroRange[0], U) : mt(U, e.macroRange[0], Lt),
1104
- "aria-orientation": n ? "vertical" : "horizontal",
1105
- className: `period-slider-handle period-slider-handle-vernier ${n ? "is-vertical" : ""} group absolute touch-none ${n ? w ? "after:absolute after:-inset-y-3 after:right-0 after:-left-3" : "after:absolute after:-inset-y-3 after:-right-3 after:left-0" : w ? "after:absolute after:-inset-x-3 after:-top-3 after:bottom-0" : "after:absolute after:-inset-x-3 after:top-0 after:-bottom-3"} after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 ${qe}`,
1106
- style: n ? {
1107
- bottom: `${ve * 100}%`,
1108
- left: w ? 0 : "auto",
1109
- right: w ? "auto" : 0,
1110
- transform: w ? "translate(-100%, 50%)" : "translate(100%, 50%)",
1111
- zIndex: ye === "macro-low" || $e === "macro-low" ? 30 : 15
927
+ "aria-valuetext": e.formatAriaValueText ? e.formatAriaValueText(e.macroRange[0], z) : Et(z, e.macroRange[0], f, D),
928
+ "aria-orientation": c ? "vertical" : "horizontal",
929
+ className: `period-slider-handle period-slider-handle-vernier ${c ? "is-vertical" : ""} group absolute touch-none ${c ? T ? "after:absolute after:-inset-y-3 after:right-0 after:-left-4" : "after:absolute after:-inset-y-3 after:-right-4 after:left-0" : T ? "after:absolute after:-inset-x-3 after:-top-4 after:bottom-0" : "after:absolute after:-inset-x-3 after:top-0 after:-bottom-4"} after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 ${lt}`,
930
+ style: c ? {
931
+ bottom: `${ye * 100}%`,
932
+ left: T ? 0 : "auto",
933
+ right: T ? "auto" : 0,
934
+ transform: T ? "translate(-100%, 50%)" : "translate(100%, 50%)",
935
+ zIndex: Le === "macro-low" || Pe === "macro-low" ? 30 : 15
1112
936
  } : {
1113
- left: `${ve * 100}%`,
1114
- top: w ? 0 : "auto",
1115
- bottom: w ? "auto" : 0,
1116
- transform: w ? "translate(-50%, -100%)" : "translate(-50%, 100%)",
1117
- zIndex: ye === "macro-low" || $e === "macro-low" ? 30 : 15
937
+ left: `${ye * 100}%`,
938
+ top: T ? 0 : "auto",
939
+ bottom: T ? "auto" : 0,
940
+ transform: T ? "translate(-50%, -100%)" : "translate(-50%, 100%)",
941
+ zIndex: Le === "macro-low" || Pe === "macro-low" ? 30 : 15
1118
942
  },
1119
- onPointerDown: lt("macro-low"),
1120
- onKeyDown: Ht("macro-low"),
1121
- "data-active": ye === "macro-low" ? "true" : void 0,
1122
- "data-front": $e === "macro-low" ? "true" : void 0,
1123
- "data-vernier-pos": n ? w ? "left" : "right" : w ? "top" : "bottom",
943
+ onPointerDown: Pt("macro-low"),
944
+ onKeyDown: dr("macro-low"),
945
+ "data-active": Le === "macro-low" ? "true" : void 0,
946
+ "data-front": Pe === "macro-low" ? "true" : void 0,
947
+ "data-vernier-pos": c ? T ? "left" : "right" : T ? "top" : "bottom",
1124
948
  "data-handle-type": "macro-low",
1125
949
  children: [
1126
- /* @__PURE__ */ T(Tt, { type: "macro", isTop: w, isVertical: n, isLeft: w }),
1127
- Ie && /* @__PURE__ */ T("div", { className: "period-slider-hairline" }),
1128
- /* @__PURE__ */ T("div", { className: "period-slider-tooltip absolute whitespace-nowrap rounded bg-slate-900 px-2 py-0.5 font-medium text-white text-xs shadow-md dark:bg-slate-800", children: rt(U, e.macroRange[0], Lt) })
950
+ /* @__PURE__ */ w(Jt, { type: "macro", isTop: T, isVertical: c, isLeft: T }),
951
+ Tt && /* @__PURE__ */ w("div", { className: "period-slider-hairline" }),
952
+ /* @__PURE__ */ w("div", { className: "period-slider-tooltip absolute whitespace-nowrap rounded bg-slate-900 px-2 py-0.5 font-medium text-white text-xs shadow-md dark:bg-slate-800", children: Ae(z, e.macroRange[0], f, D) })
1129
953
  ]
1130
954
  }
1131
955
  ),
1132
956
  /* @__PURE__ */ le(
1133
957
  "div",
1134
958
  {
1135
- tabIndex: d ? -1 : 0,
959
+ tabIndex: o ? -1 : 0,
1136
960
  role: "slider",
1137
- "aria-label": e.macroUpperAriaLabel ?? "マクロ終了時期",
1138
- "aria-disabled": d ? "true" : void 0,
961
+ "aria-label": e.macroUpperAriaLabel ?? "Macro range end",
962
+ "aria-disabled": o ? "true" : void 0,
1139
963
  "aria-valuemin": _e,
1140
- "aria-valuemax": it,
1141
- "aria-valuenow": Ge,
1142
- "aria-valuetext": e.formatAriaValueText ? e.formatAriaValueText(e.macroRange[1], U) : mt(U, e.macroRange[1], Lt),
1143
- "aria-orientation": n ? "vertical" : "horizontal",
1144
- className: `period-slider-handle period-slider-handle-vernier ${n ? "is-vertical" : ""} group absolute touch-none ${n ? w ? "after:absolute after:-inset-y-3 after:right-0 after:-left-3" : "after:absolute after:-inset-y-3 after:-right-3 after:left-0" : w ? "after:absolute after:-inset-x-3 after:-top-3 after:bottom-0" : "after:absolute after:-inset-x-3 after:top-0 after:-bottom-3"} after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 ${qe}`,
1145
- style: n ? {
1146
- bottom: `${Se * 100}%`,
1147
- left: w ? 0 : "auto",
1148
- right: w ? "auto" : 0,
1149
- transform: w ? "translate(-100%, 50%)" : "translate(100%, 50%)",
1150
- zIndex: ye === "macro-high" || $e === "macro-high" ? 30 : 15
964
+ "aria-valuemax": Rt,
965
+ "aria-valuenow": Xe,
966
+ "aria-valuetext": e.formatAriaValueText ? e.formatAriaValueText(e.macroRange[1], z) : Et(z, e.macroRange[1], f, D),
967
+ "aria-orientation": c ? "vertical" : "horizontal",
968
+ className: `period-slider-handle period-slider-handle-vernier ${c ? "is-vertical" : ""} group absolute touch-none ${c ? T ? "after:absolute after:-inset-y-3 after:right-0 after:-left-4" : "after:absolute after:-inset-y-3 after:-right-4 after:left-0" : T ? "after:absolute after:-inset-x-3 after:-top-4 after:bottom-0" : "after:absolute after:-inset-x-3 after:top-0 after:-bottom-4"} after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 ${lt}`,
969
+ style: c ? {
970
+ bottom: `${Ne * 100}%`,
971
+ left: T ? 0 : "auto",
972
+ right: T ? "auto" : 0,
973
+ transform: T ? "translate(-100%, 50%)" : "translate(100%, 50%)",
974
+ zIndex: Le === "macro-high" || Pe === "macro-high" ? 30 : 15
1151
975
  } : {
1152
- left: `${Se * 100}%`,
1153
- top: w ? 0 : "auto",
1154
- bottom: w ? "auto" : 0,
1155
- transform: w ? "translate(-50%, -100%)" : "translate(-50%, 100%)",
1156
- zIndex: ye === "macro-high" || $e === "macro-high" ? 30 : 15
976
+ left: `${Ne * 100}%`,
977
+ top: T ? 0 : "auto",
978
+ bottom: T ? "auto" : 0,
979
+ transform: T ? "translate(-50%, -100%)" : "translate(-50%, 100%)",
980
+ zIndex: Le === "macro-high" || Pe === "macro-high" ? 30 : 15
1157
981
  },
1158
- onPointerDown: lt("macro-high"),
1159
- onKeyDown: Ht("macro-high"),
1160
- "data-active": ye === "macro-high" ? "true" : void 0,
1161
- "data-front": $e === "macro-high" ? "true" : void 0,
1162
- "data-vernier-pos": n ? w ? "left" : "right" : w ? "top" : "bottom",
982
+ onPointerDown: Pt("macro-high"),
983
+ onKeyDown: dr("macro-high"),
984
+ "data-active": Le === "macro-high" ? "true" : void 0,
985
+ "data-front": Pe === "macro-high" ? "true" : void 0,
986
+ "data-vernier-pos": c ? T ? "left" : "right" : T ? "top" : "bottom",
1163
987
  "data-handle-type": "macro-high",
1164
988
  children: [
1165
- /* @__PURE__ */ T(Tt, { type: "macro", isTop: w, isVertical: n, isLeft: w }),
1166
- Ie && /* @__PURE__ */ T("div", { className: "period-slider-hairline" }),
1167
- /* @__PURE__ */ T("div", { className: "period-slider-tooltip absolute whitespace-nowrap rounded bg-slate-900 px-2 py-0.5 font-medium text-white text-xs shadow-md dark:bg-slate-800", children: rt(U, e.macroRange[1], Lt) })
989
+ /* @__PURE__ */ w(Jt, { type: "macro", isTop: T, isVertical: c, isLeft: T }),
990
+ Tt && /* @__PURE__ */ w("div", { className: "period-slider-hairline" }),
991
+ /* @__PURE__ */ w("div", { className: "period-slider-tooltip absolute whitespace-nowrap rounded bg-slate-900 px-2 py-0.5 font-medium text-white text-xs shadow-md dark:bg-slate-800", children: Ae(z, e.macroRange[1], f, D) })
1168
992
  ]
1169
993
  }
1170
994
  ),
1171
995
  /* @__PURE__ */ le(
1172
996
  "div",
1173
997
  {
1174
- tabIndex: d ? -1 : 0,
998
+ tabIndex: o ? -1 : 0,
1175
999
  role: "slider",
1176
- "aria-label": e.lowerAriaLabel ?? "ミクロ開始時期",
1177
- "aria-disabled": d ? "true" : void 0,
1178
- "aria-valuemin": he,
1179
- "aria-valuemax": Fe,
1180
- "aria-valuenow": Ae,
1181
- "aria-valuetext": e.formatAriaValueText ? e.formatAriaValueText(q, E) : mt(E, q, Yt),
1182
- "aria-orientation": n ? "vertical" : "horizontal",
1183
- className: `period-slider-handle period-slider-handle-vernier ${n ? "is-vertical" : ""} group absolute touch-none ${n ? w ? "after:absolute after:-inset-y-3 after:-right-3 after:left-0" : "after:absolute after:-inset-y-3 after:right-0 after:-left-3" : w ? "after:absolute after:-inset-x-3 after:top-0 after:-bottom-3" : "after:absolute after:-inset-x-3 after:-top-3 after:bottom-0"} after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 ${qe}`,
1184
- style: n ? {
1185
- bottom: `${Oe * 100}%`,
1186
- left: w ? "auto" : 0,
1187
- right: w ? 0 : "auto",
1188
- transform: w ? "translate(100%, 50%)" : "translate(-100%, 50%)",
1189
- zIndex: ye === "micro-low" || $e === "micro-low" ? 30 : 20
1000
+ "aria-label": e.lowerAriaLabel ?? "Micro range start",
1001
+ "aria-disabled": o ? "true" : void 0,
1002
+ "aria-valuemin": we,
1003
+ "aria-valuemax": xe,
1004
+ "aria-valuenow": Me,
1005
+ "aria-valuetext": e.formatAriaValueText ? e.formatAriaValueText(Ut, N) : Et(N, Ut, k, D),
1006
+ "aria-orientation": c ? "vertical" : "horizontal",
1007
+ className: `period-slider-handle period-slider-handle-vernier ${c ? "is-vertical" : ""} group absolute touch-none ${c ? T ? "after:absolute after:-inset-y-3 after:-right-4 after:left-0" : "after:absolute after:-inset-y-3 after:right-0 after:-left-4" : T ? "after:absolute after:-inset-x-3 after:top-0 after:-bottom-4" : "after:absolute after:-inset-x-3 after:-top-4 after:bottom-0"} after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 ${lt}`,
1008
+ style: c ? {
1009
+ bottom: `${Ke * 100}%`,
1010
+ left: T ? "auto" : 0,
1011
+ right: T ? 0 : "auto",
1012
+ transform: T ? "translate(100%, 50%)" : "translate(-100%, 50%)",
1013
+ zIndex: Le === "micro-low" || Pe === "micro-low" ? 30 : 20
1190
1014
  } : {
1191
- left: `${Oe * 100}%`,
1192
- top: w ? "auto" : 0,
1193
- bottom: w ? 0 : "auto",
1194
- transform: w ? "translate(-50%, 100%)" : "translate(-50%, -100%)",
1195
- zIndex: ye === "micro-low" || $e === "micro-low" ? 30 : 20
1015
+ left: `${Ke * 100}%`,
1016
+ top: T ? "auto" : 0,
1017
+ bottom: T ? 0 : "auto",
1018
+ transform: T ? "translate(-50%, 100%)" : "translate(-50%, -100%)",
1019
+ zIndex: Le === "micro-low" || Pe === "micro-low" ? 30 : 20
1196
1020
  },
1197
- onPointerDown: lt("micro-low"),
1198
- onKeyDown: Ht("micro-low"),
1199
- "data-active": ye === "micro-low" ? "true" : void 0,
1200
- "data-front": $e === "micro-low" ? "true" : void 0,
1201
- "data-vernier-pos": n ? w ? "right" : "left" : w ? "bottom" : "top",
1021
+ onPointerDown: Pt("micro-low"),
1022
+ onKeyDown: dr("micro-low"),
1023
+ "data-active": Le === "micro-low" ? "true" : void 0,
1024
+ "data-front": Pe === "micro-low" ? "true" : void 0,
1025
+ "data-vernier-pos": c ? T ? "right" : "left" : T ? "bottom" : "top",
1202
1026
  "data-handle-type": "micro-low",
1203
1027
  children: [
1204
- /* @__PURE__ */ T(Tt, { type: "micro", isTop: !w, isVertical: n, isLeft: !w }),
1205
- Ie && /* @__PURE__ */ T("div", { className: "period-slider-hairline" }),
1206
- /* @__PURE__ */ T("div", { className: "period-slider-tooltip absolute whitespace-nowrap rounded bg-slate-900 px-2 py-0.5 font-medium text-white text-xs shadow-md dark:bg-slate-800", children: rt(E, q, Yt) })
1028
+ /* @__PURE__ */ w(Jt, { type: "micro", isTop: !T, isVertical: c, isLeft: !T }),
1029
+ Tt && /* @__PURE__ */ w("div", { className: "period-slider-hairline" }),
1030
+ /* @__PURE__ */ w("div", { className: "period-slider-tooltip absolute whitespace-nowrap rounded bg-slate-900 px-2 py-0.5 font-medium text-white text-xs shadow-md dark:bg-slate-800", children: Ae(N, Ut, k, D) })
1207
1031
  ]
1208
1032
  }
1209
1033
  ),
1210
1034
  /* @__PURE__ */ le(
1211
1035
  "div",
1212
1036
  {
1213
- tabIndex: d ? -1 : 0,
1037
+ tabIndex: o ? -1 : 0,
1214
1038
  role: "slider",
1215
- "aria-label": e.upperAriaLabel ?? "ミクロ終了時期",
1216
- "aria-disabled": d ? "true" : void 0,
1217
- "aria-valuemin": Ae,
1218
- "aria-valuemax": We,
1219
- "aria-valuenow": Fe,
1220
- "aria-valuetext": e.formatAriaValueText ? e.formatAriaValueText(fe, E) : mt(E, fe, Yt),
1221
- "aria-orientation": n ? "vertical" : "horizontal",
1222
- className: `period-slider-handle period-slider-handle-vernier ${n ? "is-vertical" : ""} group absolute touch-none ${n ? w ? "after:absolute after:-inset-y-3 after:-right-3 after:left-0" : "after:absolute after:-inset-y-3 after:right-0 after:-left-3" : w ? "after:absolute after:-inset-x-3 after:top-0 after:-bottom-3" : "after:absolute after:-inset-x-3 after:-top-3 after:bottom-0"} after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 ${qe}`,
1223
- style: n ? {
1224
- bottom: `${nt * 100}%`,
1225
- left: w ? "auto" : 0,
1226
- right: w ? 0 : "auto",
1227
- transform: w ? "translate(100%, 50%)" : "translate(-100%, 50%)",
1228
- zIndex: ye === "micro-high" || $e === "micro-high" ? 30 : 20
1039
+ "aria-label": e.upperAriaLabel ?? "Micro range end",
1040
+ "aria-disabled": o ? "true" : void 0,
1041
+ "aria-valuemin": Me,
1042
+ "aria-valuemax": Oe,
1043
+ "aria-valuenow": xe,
1044
+ "aria-valuetext": e.formatAriaValueText ? e.formatAriaValueText(Bt, N) : Et(N, Bt, k, D),
1045
+ "aria-orientation": c ? "vertical" : "horizontal",
1046
+ className: `period-slider-handle period-slider-handle-vernier ${c ? "is-vertical" : ""} group absolute touch-none ${c ? T ? "after:absolute after:-inset-y-3 after:-right-4 after:left-0" : "after:absolute after:-inset-y-3 after:right-0 after:-left-4" : T ? "after:absolute after:-inset-x-3 after:top-0 after:-bottom-4" : "after:absolute after:-inset-x-3 after:-top-4 after:bottom-0"} after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 ${lt}`,
1047
+ style: c ? {
1048
+ bottom: `${wt * 100}%`,
1049
+ left: T ? "auto" : 0,
1050
+ right: T ? 0 : "auto",
1051
+ transform: T ? "translate(100%, 50%)" : "translate(-100%, 50%)",
1052
+ zIndex: Le === "micro-high" || Pe === "micro-high" ? 30 : 20
1229
1053
  } : {
1230
- left: `${nt * 100}%`,
1231
- top: w ? "auto" : 0,
1232
- bottom: w ? 0 : "auto",
1233
- transform: w ? "translate(-50%, 100%)" : "translate(-50%, -100%)",
1234
- zIndex: ye === "micro-high" || $e === "micro-high" ? 30 : 20
1054
+ left: `${wt * 100}%`,
1055
+ top: T ? "auto" : 0,
1056
+ bottom: T ? 0 : "auto",
1057
+ transform: T ? "translate(-50%, 100%)" : "translate(-50%, -100%)",
1058
+ zIndex: Le === "micro-high" || Pe === "micro-high" ? 30 : 20
1235
1059
  },
1236
- onPointerDown: lt("micro-high"),
1237
- onKeyDown: Ht("micro-high"),
1238
- "data-active": ye === "micro-high" ? "true" : void 0,
1239
- "data-front": $e === "micro-high" ? "true" : void 0,
1240
- "data-vernier-pos": n ? w ? "right" : "left" : w ? "bottom" : "top",
1060
+ onPointerDown: Pt("micro-high"),
1061
+ onKeyDown: dr("micro-high"),
1062
+ "data-active": Le === "micro-high" ? "true" : void 0,
1063
+ "data-front": Pe === "micro-high" ? "true" : void 0,
1064
+ "data-vernier-pos": c ? T ? "right" : "left" : T ? "bottom" : "top",
1241
1065
  "data-handle-type": "micro-high",
1242
1066
  children: [
1243
- /* @__PURE__ */ T(Tt, { type: "micro", isTop: !w, isVertical: n, isLeft: !w }),
1244
- Ie && /* @__PURE__ */ T("div", { className: "period-slider-hairline" }),
1245
- /* @__PURE__ */ T("div", { className: "period-slider-tooltip absolute whitespace-nowrap rounded bg-slate-900 px-2 py-0.5 font-medium text-white text-xs shadow-md dark:bg-slate-800", children: rt(E, fe, Yt) })
1067
+ /* @__PURE__ */ w(Jt, { type: "micro", isTop: !T, isVertical: c, isLeft: !T }),
1068
+ Tt && /* @__PURE__ */ w("div", { className: "period-slider-hairline" }),
1069
+ /* @__PURE__ */ w("div", { className: "period-slider-tooltip absolute whitespace-nowrap rounded bg-slate-900 px-2 py-0.5 font-medium text-white text-xs shadow-md dark:bg-slate-800", children: Ae(N, Bt, k, D) })
1246
1070
  ]
1247
1071
  }
1248
1072
  )
1249
- ] }) : /* @__PURE__ */ le(Ta, { children: [
1250
- !b && /* @__PURE__ */ T("div", { "data-testid": "period-slider-connect", className: "period-slider-connect absolute rounded-full bg-blue-500 hover:bg-blue-600 dark:bg-blue-400", style: Va, onPointerDown: Fa }),
1251
- W && I && f.length > 1 && /* @__PURE__ */ T("div", { className: "period-slider-ticks pointer-events-none absolute inset-0", children: f.map((i) => {
1252
- const c = te(t, i), g = f.findIndex((_) => te(t, _) === c), D = $t(g), C = n ? { bottom: `${D}%`, left: "50%", transform: "translate(-50%, 50%)" } : { left: `${D}%`, top: "50%", transform: "translate(-50%, -50%)" };
1253
- return /* @__PURE__ */ T("div", { className: "period-slider-tick absolute h-1.5 w-1.5 rounded-full bg-slate-400/60 dark:bg-slate-500/60", style: C }, `tick-${c}`);
1073
+ ] }) : /* @__PURE__ */ le(ln, { children: [
1074
+ !p && /* @__PURE__ */ w("div", { "data-testid": "period-slider-connect", className: "period-slider-connect absolute rounded-full", style: Cn, onPointerDown: Sn }),
1075
+ _ && L && m.length > 1 && /* @__PURE__ */ w("div", { className: "period-slider-ticks pointer-events-none absolute inset-0", children: m.map((i, l) => {
1076
+ const u = re(t, i), b = lr(l), R = c ? { bottom: `${b}%`, left: "50%", transform: "translate(-50%, 50%)" } : { left: `${b}%`, top: "50%", transform: "translate(-50%, -50%)" };
1077
+ return /* @__PURE__ */ w("div", { "data-testid": "period-slider-tick", className: "period-slider-tick absolute h-1.5 w-1.5 rounded-full bg-slate-400/60 dark:bg-slate-500/60", style: R }, `tick-${u}`);
1254
1078
  }) }),
1255
- !d && Z !== null && Y !== null && we === null && wa && /* @__PURE__ */ le("div", { "data-testid": "period-slider-hover-guide", className: "period-slider-hover-guide pointer-events-none absolute z-20 h-2 w-2", style: Ba, children: [
1256
- /* @__PURE__ */ T("div", { className: "period-slider-hover-dot h-full w-full rounded-full border border-white/80 bg-sky-400/80 shadow-[0_0_6px_#38bdf8] dark:border-slate-800 dark:bg-sky-300/80" }),
1257
- /* @__PURE__ */ T(
1079
+ !o && De !== null && Ft !== null && $ === null && nn && /* @__PURE__ */ le("div", { "data-testid": "period-slider-hover-guide", className: "period-slider-hover-guide pointer-events-none absolute z-20 h-2 w-2", style: On, children: [
1080
+ /* @__PURE__ */ w("div", { "data-testid": "period-slider-hover-dot", className: "period-slider-hover-dot h-full w-full rounded-full border border-white/80 bg-[var(--aqps-accent-light)] shadow-[0_0_6px_var(--aqps-accent-glow)] dark:border-slate-800" }),
1081
+ /* @__PURE__ */ w(
1258
1082
  "div",
1259
1083
  {
1260
- className: `period-slider-hover-tooltip ${p === "bottom" && !n ? "period-slider-hover-tooltip-bottom" : ""} rounded bg-slate-800/90 px-2 py-0.5 font-medium text-white text-xs shadow-lg backdrop-blur-xs dark:bg-slate-900/90`,
1261
- children: rt(t, wa, e.formatLabel)
1084
+ className: `period-slider-hover-tooltip ${M === "bottom" && !c ? "period-slider-hover-tooltip-bottom" : ""} rounded bg-slate-800/90 px-2 py-0.5 font-medium text-white text-xs shadow-lg backdrop-blur-xs dark:bg-slate-900/90`,
1085
+ children: Ae(t, nn, e.formatLabel, D)
1262
1086
  }
1263
1087
  )
1264
1088
  ] }),
1265
1089
  /* @__PURE__ */ le(
1266
1090
  "div",
1267
1091
  {
1268
- tabIndex: d ? -1 : 0,
1092
+ tabIndex: o ? -1 : 0,
1269
1093
  role: "slider",
1270
- "aria-label": x ? e.pointAriaLabel ?? "選択時期" : e.lowerAriaLabel ?? "開始時期",
1271
- "aria-disabled": d ? "true" : void 0,
1272
- "aria-valuemin": v,
1273
- "aria-valuemax": x ? M : ce,
1274
- "aria-valuenow": ne,
1275
- "aria-valuetext": e.formatAriaValueText ? e.formatAriaValueText(Bt, t) : mt(t, Bt, e.formatLabel),
1276
- "aria-orientation": n ? "vertical" : "horizontal",
1277
- className: `period-slider-handle group absolute h-4 w-4 touch-none after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:outline-none ${qe}`,
1278
- style: Ua,
1279
- onPointerDown: ga("low"),
1280
- onKeyDown: fa("low"),
1281
- "data-active": we === "low" ? "true" : void 0,
1282
- "data-front": Pt ? "true" : void 0,
1094
+ "aria-label": P ? e.pointAriaLabel ?? "Selected date" : e.lowerAriaLabel ?? "Range start",
1095
+ "aria-disabled": o ? "true" : void 0,
1096
+ "aria-valuemin": S,
1097
+ "aria-valuemax": P ? H : ge,
1098
+ "aria-valuenow": fe,
1099
+ "aria-valuetext": e.formatAriaValueText ? e.formatAriaValueText(Pr, t) : Et(t, Pr, e.formatLabel, D),
1100
+ "aria-orientation": c ? "vertical" : "horizontal",
1101
+ className: `period-slider-handle group absolute h-4 w-4 touch-none after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:outline-none ${lt}`,
1102
+ style: In,
1103
+ onPointerDown: Qr("low"),
1104
+ onKeyDown: en("low"),
1105
+ "data-active": $ === "low" ? "true" : void 0,
1106
+ "data-front": mr ? "true" : void 0,
1283
1107
  children: [
1284
- /* @__PURE__ */ T("div", { className: "period-slider-knob h-full w-full rounded-full border-2 border-white bg-blue-600 shadow-md group-focus-visible:ring-2 group-focus-visible:ring-blue-600 group-focus-visible:ring-offset-2 dark:border-slate-800 dark:bg-blue-400" }),
1285
- m !== "hover" && /* @__PURE__ */ T(
1108
+ /* @__PURE__ */ w(
1109
+ "div",
1110
+ {
1111
+ "data-testid": "period-slider-knob",
1112
+ className: `period-slider-knob h-full w-full rounded-full border-2 border-white bg-[var(--aqps-accent-color)] group-focus-visible:ring-2 group-focus-visible:ring-blue-600 group-focus-visible:ring-offset-2 dark:border-slate-800 dark:bg-[var(--aqps-accent-light)] ${$ === "low" ? "" : "shadow-md"}`
1113
+ }
1114
+ ),
1115
+ h !== "hover" && /* @__PURE__ */ w(
1286
1116
  "div",
1287
1117
  {
1288
- className: `period-slider-tooltip absolute whitespace-nowrap rounded bg-slate-900 px-2 py-0.5 font-medium text-white text-xs shadow-md dark:bg-slate-800 ${m === "balloon" ? "period-slider-tooltip-balloon" : ""}`,
1289
- "data-tooltip-style": m,
1290
- "data-label-position": p,
1291
- "data-slanted": Ne.isSlanted ? "true" : void 0,
1292
- "data-front": Pt ? "true" : void 0,
1293
- style: Ea,
1294
- children: rt(t, Bt, e.formatLabel)
1118
+ className: `period-slider-tooltip absolute whitespace-nowrap rounded bg-slate-900 px-2 py-0.5 font-medium text-white text-xs shadow-md dark:bg-slate-800 ${h === "balloon" ? "period-slider-tooltip-balloon" : ""}`,
1119
+ "data-tooltip-style": h,
1120
+ "data-label-position": M,
1121
+ "data-slanted": Re.isSlanted ? "true" : void 0,
1122
+ "data-front": mr ? "true" : void 0,
1123
+ ref: Ln,
1124
+ style: Yn,
1125
+ children: Ae(t, Pr, e.formatLabel, D)
1295
1126
  }
1296
1127
  )
1297
1128
  ]
1298
1129
  }
1299
1130
  ),
1300
- !x && /* @__PURE__ */ le(
1131
+ !P && /* @__PURE__ */ le(
1301
1132
  "div",
1302
1133
  {
1303
- tabIndex: d ? -1 : 0,
1134
+ tabIndex: o ? -1 : 0,
1304
1135
  role: "slider",
1305
- "aria-label": e.upperAriaLabel ?? "終了時期",
1306
- "aria-disabled": d ? "true" : void 0,
1307
- "aria-valuemin": ne,
1308
- "aria-valuemax": M,
1309
- "aria-valuenow": ce,
1310
- "aria-valuetext": e.formatAriaValueText ? e.formatAriaValueText(Xt, t) : mt(t, Xt, e.formatLabel),
1311
- "aria-orientation": n ? "vertical" : "horizontal",
1312
- className: `period-slider-handle group absolute h-4 w-4 touch-none after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:outline-none ${qe}`,
1313
- style: za,
1314
- onPointerDown: ga("high"),
1315
- onKeyDown: fa("high"),
1316
- "data-active": we === "high" ? "true" : void 0,
1317
- "data-front": Et ? "true" : void 0,
1136
+ "aria-label": e.upperAriaLabel ?? "Range end",
1137
+ "aria-disabled": o ? "true" : void 0,
1138
+ "aria-valuemin": fe,
1139
+ "aria-valuemax": H,
1140
+ "aria-valuenow": ge,
1141
+ "aria-valuetext": e.formatAriaValueText ? e.formatAriaValueText(Nr, t) : Et(t, Nr, e.formatLabel, D),
1142
+ "aria-orientation": c ? "vertical" : "horizontal",
1143
+ className: `period-slider-handle group absolute h-4 w-4 touch-none after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:outline-none ${lt}`,
1144
+ style: Hn,
1145
+ onPointerDown: Qr("high"),
1146
+ onKeyDown: en("high"),
1147
+ "data-active": $ === "high" ? "true" : void 0,
1148
+ "data-front": fr ? "true" : void 0,
1318
1149
  children: [
1319
- /* @__PURE__ */ T("div", { className: "period-slider-knob h-full w-full rounded-full border-2 border-white bg-blue-600 shadow-md group-focus-visible:ring-2 group-focus-visible:ring-blue-600 group-focus-visible:ring-offset-2 dark:border-slate-800 dark:bg-blue-400" }),
1320
- m !== "hover" && /* @__PURE__ */ T(
1150
+ /* @__PURE__ */ w(
1321
1151
  "div",
1322
1152
  {
1323
- className: `period-slider-tooltip absolute whitespace-nowrap rounded bg-slate-900 px-2 py-0.5 font-medium text-white text-xs shadow-md dark:bg-slate-800 ${m === "balloon" ? "period-slider-tooltip-balloon" : ""}`,
1324
- "data-tooltip-style": m,
1325
- "data-label-position": p,
1326
- "data-slanted": Ne.isSlanted ? "true" : void 0,
1327
- "data-front": Et ? "true" : void 0,
1328
- style: Ia,
1329
- children: rt(t, Xt, e.formatLabel)
1153
+ "data-testid": "period-slider-knob",
1154
+ className: `period-slider-knob h-full w-full rounded-full border-2 border-white bg-[var(--aqps-accent-color)] group-focus-visible:ring-2 group-focus-visible:ring-blue-600 group-focus-visible:ring-offset-2 dark:border-slate-800 dark:bg-[var(--aqps-accent-light)] ${$ === "high" ? "" : "shadow-md"}`
1155
+ }
1156
+ ),
1157
+ h !== "hover" && /* @__PURE__ */ w(
1158
+ "div",
1159
+ {
1160
+ className: `period-slider-tooltip absolute whitespace-nowrap rounded bg-slate-900 px-2 py-0.5 font-medium text-white text-xs shadow-md dark:bg-slate-800 ${h === "balloon" ? "period-slider-tooltip-balloon" : ""}`,
1161
+ "data-tooltip-style": h,
1162
+ "data-label-position": M,
1163
+ "data-slanted": Re.isSlanted ? "true" : void 0,
1164
+ "data-front": fr ? "true" : void 0,
1165
+ ref: Rn,
1166
+ style: An,
1167
+ children: Ae(t, Nr, e.formatLabel, D)
1330
1168
  }
1331
1169
  )
1332
1170
  ]
@@ -1335,436 +1173,858 @@ const rn = (e) => {
1335
1173
  ] })
1336
1174
  }
1337
1175
  ),
1338
- u && /* @__PURE__ */ T(
1339
- "button",
1340
- {
1341
- type: "button",
1342
- className: `period-slider-stepper-btn relative after:absolute after:inset-[-10px] after:content-[''] ${n ? "period-slider-stepper-prev period-slider-stepper-down" : "period-slider-stepper-next"} flex h-6 w-6 shrink-0 items-center justify-center rounded-md border border-slate-300 bg-white font-bold text-[10px] text-slate-700 leading-none shadow-2xs transition-all hover:bg-slate-100 hover:text-indigo-600 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 active:scale-95 disabled:cursor-not-allowed disabled:opacity-30 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-200 dark:hover:bg-slate-700 ${qe}`,
1343
- onClick: () => ha(n ? -1 : 1),
1344
- disabled: n ? Da : xa,
1345
- "aria-label": n ? "1つ前へ" : "1つ後へ",
1346
- children: n ? "▼" : "▶"
1347
- }
1348
- )
1176
+ g && an(c ? "decrease" : "increase")
1349
1177
  ]
1350
1178
  }
1351
1179
  );
1352
- }, Gt = (e, t) => {
1180
+ }, Er = (e, t) => {
1353
1181
  if (e === t) return !0;
1354
1182
  if (!(e && t) || e.length !== t.length) return !1;
1355
- for (let a = 0; a < e.length; a++)
1356
- if (e[a].getTime() !== t[a].getTime()) return !1;
1183
+ for (let r = 0; r < e.length; r++)
1184
+ if (e[r].getTime() !== t[r].getTime()) return !1;
1357
1185
  return !0;
1358
- }, on = (e, t) => {
1186
+ }, ca = (e, t) => {
1359
1187
  if (e === t) return !0;
1360
1188
  if (!(e && t)) return !1;
1361
- const a = Object.keys(e), r = Object.keys(t);
1362
- if (a.length !== r.length) return !1;
1363
- for (const l of a)
1364
- if (e[l] !== t[l]) return !1;
1189
+ const r = Object.keys(e), n = Object.keys(t);
1190
+ if (r.length !== n.length) return !1;
1191
+ for (const a of r)
1192
+ if (e[a] !== t[a]) return !1;
1365
1193
  return !0;
1366
- }, ln = (e, t) => {
1367
- if (e === t) return !0;
1368
- if (e.mode !== t.mode || e.unit !== t.unit || (e.minDate?.getTime() ?? null) !== (t.minDate?.getTime() ?? null) || (e.maxDate?.getTime() ?? null) !== (t.maxDate?.getTime() ?? null) || e.labelPosition !== t.labelPosition || e.autoSlantLabels !== t.autoSlantLabels || e.preventCollisionSlant !== t.preventCollisionSlant || e.isVertical !== t.isVertical || e.hideConnectBar !== t.hideConnectBar || e.showTicks !== t.showTicks || e.disabled !== t.disabled || e.showStepper !== t.showStepper || e.debounceMs !== t.debounceMs || e.tooltipStyle !== t.tooltipStyle || e.colorScheme !== t.colorScheme || e.className !== t.className || !on(e.style, t.style) || e.snapMode !== t.snapMode || e.formatLabel !== t.formatLabel || e.lowerAriaLabel !== t.lowerAriaLabel || e.upperAriaLabel !== t.upperAriaLabel || e.pointAriaLabel !== t.pointAriaLabel || e.macroLowerAriaLabel !== t.macroLowerAriaLabel || e.macroUpperAriaLabel !== t.macroUpperAriaLabel || e.formatAriaValueText !== t.formatAriaValueText || !Gt(e.allowedDates, t.allowedDates)) return !1;
1369
- if (e.mode === "point" && t.mode === "point") {
1370
- const a = e.value?.getTime() ?? e.valueDate?.getTime() ?? null, r = t.value?.getTime() ?? t.valueDate?.getTime() ?? null;
1371
- return !(a !== r || e.onChangePoint !== t.onChangePoint || e.onChangeValue !== t.onChangeValue || e.onChange !== t.onChange);
1372
- }
1373
- if (e.mode === "range" && t.mode === "range") {
1374
- const a = e.range?.[0]?.getTime() ?? e.lowerDate?.getTime() ?? null, r = e.range?.[1]?.getTime() ?? e.upperDate?.getTime() ?? null, l = t.range?.[0]?.getTime() ?? t.lowerDate?.getTime() ?? null, s = t.range?.[1]?.getTime() ?? t.upperDate?.getTime() ?? null;
1375
- return !(a !== l || r !== s || e.onChangeRange !== t.onChangeRange || e.onChangeRangeTuple !== t.onChangeRangeTuple || e.onChange !== t.onChange);
1376
- }
1377
- if (e.mode === "vernier" && t.mode === "vernier") {
1378
- const a = e.microRange?.[0]?.getTime() ?? e.lowerDate?.getTime() ?? null, r = e.microRange?.[1]?.getTime() ?? e.upperDate?.getTime() ?? null, l = t.microRange?.[0]?.getTime() ?? t.lowerDate?.getTime() ?? null, s = t.microRange?.[1]?.getTime() ?? t.upperDate?.getTime() ?? null;
1379
- if (a !== l || r !== s) return !1;
1380
- const d = e.macroRange?.[0]?.getTime() ?? null, h = e.macroRange?.[1]?.getTime() ?? null, u = t.macroRange?.[0]?.getTime() ?? null, m = t.macroRange?.[1]?.getTime() ?? null;
1381
- return !(d !== u || h !== m || e.vernierOrientation !== t.vernierOrientation || e.showVernierProjection !== t.showVernierProjection || e.showVernierTicks !== t.showVernierTicks || e.showHairline !== t.showHairline || e.adaptiveExpand !== t.adaptiveExpand || e.macroUnit !== t.macroUnit || e.microUnit !== t.microUnit || e.macroIsDiscrete !== t.macroIsDiscrete || e.microIsDiscrete !== t.microIsDiscrete || e.formatMacroLabel !== t.formatMacroLabel || e.formatMicroLabel !== t.formatMicroLabel || e.onChangeRange !== t.onChangeRange || e.onChangeRangeTuple !== t.onChangeRangeTuple || e.onChangeMicroRange !== t.onChangeMicroRange || e.onChangeMicroRangeTuple !== t.onChangeMicroRangeTuple || e.onChangeMicro !== t.onChangeMicro || e.onChangeMacroRange !== t.onChangeMacroRange || e.onChangeMacroRangeTuple !== t.onChangeMacroRangeTuple || e.onChangeMacro !== t.onChangeMacro || !Gt(e.macroAllowedDates, t.macroAllowedDates) || !Gt(e.microAllowedDates, t.microAllowedDates));
1382
- }
1383
- return !1;
1384
- }, sn = Ct(rn, ln);
1385
- sn.displayName = "PeriodSlider";
1386
- function qt(e, t, a) {
1387
- return t && e < t ? t : a && e > a ? a : e;
1194
+ }, ua = (e, t) => e === t ? !0 : e.mode !== t.mode || e.unit !== t.unit || e.minDate.getTime() !== t.minDate.getTime() || e.maxDate.getTime() !== t.maxDate.getTime() || e.labelPosition !== t.labelPosition || e.autoSlantLabels !== t.autoSlantLabels || e.isVertical !== t.isVertical || e.hideConnectBar !== t.hideConnectBar || e.showTicks !== t.showTicks || e.disabled !== t.disabled || e.showStepper !== t.showStepper || e.debounceMs !== t.debounceMs || e.tooltipStyle !== t.tooltipStyle || e.colorScheme !== t.colorScheme || e.className !== t.className || !ca(e.style, t.style) || e.snapMode !== t.snapMode || e.formatLabel !== t.formatLabel || e.locale !== t.locale || e.lowerAriaLabel !== t.lowerAriaLabel || e.upperAriaLabel !== t.upperAriaLabel || e.pointAriaLabel !== t.pointAriaLabel || e.macroLowerAriaLabel !== t.macroLowerAriaLabel || e.macroUpperAriaLabel !== t.macroUpperAriaLabel || e.decreaseAriaLabel !== t.decreaseAriaLabel || e.increaseAriaLabel !== t.increaseAriaLabel || e.formatAriaValueText !== t.formatAriaValueText || !Er(e.allowedDates, t.allowedDates) ? !1 : e.mode === "point" && t.mode === "point" ? !((e.value?.getTime() ?? null) !== (t.value?.getTime() ?? null) || (e.defaultValue?.getTime() ?? null) !== (t.defaultValue?.getTime() ?? null) || e.onChangePoint !== t.onChangePoint) : e.mode === "range" && t.mode === "range" ? !((e.range?.[0]?.getTime() ?? null) !== (t.range?.[0]?.getTime() ?? null) || (e.range?.[1]?.getTime() ?? null) !== (t.range?.[1]?.getTime() ?? null) || (e.defaultRange?.[0]?.getTime() ?? null) !== (t.defaultRange?.[0]?.getTime() ?? null) || (e.defaultRange?.[1]?.getTime() ?? null) !== (t.defaultRange?.[1]?.getTime() ?? null) || e.onChangeRange !== t.onChangeRange) : e.mode === "vernier" && t.mode === "vernier" ? !((e.microRange?.[0]?.getTime() ?? null) !== (t.microRange?.[0]?.getTime() ?? null) || (e.microRange?.[1]?.getTime() ?? null) !== (t.microRange?.[1]?.getTime() ?? null) || (e.defaultMicroRange?.[0]?.getTime() ?? null) !== (t.defaultMicroRange?.[0]?.getTime() ?? null) || (e.defaultMicroRange?.[1]?.getTime() ?? null) !== (t.defaultMicroRange?.[1]?.getTime() ?? null) || e.macroRange[0].getTime() !== t.macroRange[0].getTime() || e.macroRange[1].getTime() !== t.macroRange[1].getTime() || e.vernierOrientation !== t.vernierOrientation || e.showVernierProjection !== t.showVernierProjection || e.showVernierTicks !== t.showVernierTicks || e.showHairline !== t.showHairline || e.macroUnit !== t.macroUnit || e.microUnit !== t.microUnit || e.macroIsDiscrete !== t.macroIsDiscrete || e.microIsDiscrete !== t.microIsDiscrete || e.formatMacroLabel !== t.formatMacroLabel || e.formatMicroLabel !== t.formatMicroLabel || e.onChangeMicroRange !== t.onChangeMicroRange || e.onChangeMacroRange !== t.onChangeMacroRange || !Er(e.macroAllowedDates, t.macroAllowedDates) || !Er(e.microAllowedDates, t.microAllowedDates)) : !1, da = tr(sa, ua);
1195
+ da.displayName = "PeriodSlider";
1196
+ const Je = (e) => {
1197
+ const t = new Date(e);
1198
+ return t.setHours(0, 0, 0, 0), t;
1199
+ }, Zt = (e, t) => {
1200
+ if (Number.isNaN(t.getTime()))
1201
+ throw new RangeError(`DateSelector: "${e}" must be a valid Date (received ${String(t)})`);
1202
+ }, ma = (e) => {
1203
+ if (e !== void 0)
1204
+ try {
1205
+ Intl.DateTimeFormat.supportedLocalesOf([e]);
1206
+ } catch {
1207
+ throw new RangeError(`DateSelector: "locale" must be a valid BCP 47 language tag (received ${JSON.stringify(e)})`);
1208
+ }
1209
+ }, Ot = (e, t, r) => {
1210
+ const n = new Date(e, t - 1, r);
1211
+ return n.setFullYear(e), n.setHours(0, 0, 0, 0), n;
1212
+ }, fn = (e) => Ot(e, 1, 1), fa = (e) => Ot(e, 12, 31), ga = {
1213
+ year: { year: "numeric" },
1214
+ month: { month: "2-digit" },
1215
+ day: { day: "2-digit" }
1216
+ }, ha = {
1217
+ year: 4,
1218
+ month: 2,
1219
+ day: 2
1220
+ }, ba = {
1221
+ year: (e) => e.getFullYear(),
1222
+ month: (e) => e.getMonth() + 1,
1223
+ day: (e) => e.getDate()
1224
+ }, gn = /* @__PURE__ */ new Map(), wa = (e, t) => {
1225
+ const r = `${e}\0${t}`, n = gn.get(r);
1226
+ if (n !== void 0) return n;
1227
+ const a = new Intl.DateTimeFormat(t, ga[e]);
1228
+ return gn.set(r, a), a;
1229
+ }, Ir = (e, t, r) => r === void 0 ? String(ba[e](t)).padStart(ha[e], "0") : wa(e, r).format(t), va = (e, t, r) => {
1230
+ const n = t?.getTime() ?? null, a = r?.getTime() ?? null, s = /* @__PURE__ */ new Map();
1231
+ return e.forEach((o, d) => {
1232
+ Zt(`allowedDates[${d}]`, o);
1233
+ const g = Je(o), h = g.getTime();
1234
+ n !== null && h < n || a !== null && h > a || s.has(h) || s.set(h, g);
1235
+ }), Array.from(s.keys()).sort((o, d) => o - d).map((o) => s.get(o));
1236
+ }, pa = (e, t) => {
1237
+ const r = [];
1238
+ let n = Je(e);
1239
+ const a = Je(t).getTime();
1240
+ for (; n.getTime() <= a; )
1241
+ r.push(n), n = Dr(n, 1);
1242
+ return r;
1243
+ }, hn = (e, t) => {
1244
+ const r = [];
1245
+ for (let n = e.length - 1; n >= 0; n--)
1246
+ r.push({ label: Ae("day", e[n], void 0, t), value: Ht(e[n], "yyyy-MM-dd") });
1247
+ return r;
1248
+ }, Da = (e) => {
1249
+ const {
1250
+ value: t,
1251
+ initialDate: r,
1252
+ onChange: n,
1253
+ children: a,
1254
+ minYear: s,
1255
+ maxYear: o,
1256
+ minDate: d,
1257
+ maxDate: g,
1258
+ allowedDates: h,
1259
+ variant: M = "date",
1260
+ className: x = "",
1261
+ style: c,
1262
+ disabled: p = !1,
1263
+ prevDateAriaLabel: _ = "Previous day",
1264
+ nextDateAriaLabel: Z = "Next day",
1265
+ selectAriaLabel: D = "Date",
1266
+ yearAriaLabel: W = "Year",
1267
+ monthAriaLabel: C = "Month",
1268
+ dayAriaLabel: Q = "Day",
1269
+ locale: A,
1270
+ formatYearOption: O,
1271
+ formatMonthOption: y,
1272
+ formatDayOption: B
1273
+ } = e;
1274
+ if (ma(A), t !== void 0 && Zt("value", t), r !== void 0 && Zt("initialDate", r), d !== void 0 && Zt("minDate", d), g !== void 0 && Zt("maxDate", g), s !== void 0 && !Number.isInteger(s))
1275
+ throw new RangeError(`DateSelector: "minYear" must be an integer year (received ${String(s)})`);
1276
+ if (o !== void 0 && !Number.isInteger(o))
1277
+ throw new RangeError(`DateSelector: "maxYear" must be an integer year (received ${String(o)})`);
1278
+ if (M === "split-dropdown" && h !== void 0)
1279
+ throw new RangeError('DateSelector: variant="split-dropdown" cannot honour "allowedDates"; use variant="dropdown" or variant="date" for a discrete date set');
1280
+ const E = t ?? r;
1281
+ if (E === void 0)
1282
+ throw new RangeError("DateSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected date is never inferred from the wall clock.");
1283
+ const [m, L] = he(() => Je(E)), S = t !== void 0, H = t?.getTime(), P = Y(() => t !== void 0 ? Je(t) : m, [H, m]), ne = d?.getTime(), K = g?.getTime(), X = Y(() => {
1284
+ const f = d ? Je(d) : null, k = s !== void 0 ? fn(s) : null;
1285
+ return f === null ? k : k === null || f.getTime() >= k.getTime() ? f : k;
1286
+ }, [ne, s]), te = Y(() => {
1287
+ const f = g ? Je(g) : null, k = o !== void 0 ? fa(o) : null;
1288
+ return f === null ? k : k === null || f.getTime() <= k.getTime() ? f : k;
1289
+ }, [K, o]), ae = X?.getTime() ?? null, me = te?.getTime() ?? null;
1290
+ if (X !== null && te !== null && X.getTime() > te.getTime())
1291
+ throw new RangeError(`DateSelector: the resolved range is empty (min ${Ht(X, "yyyy-MM-dd")} is after max ${Ht(te, "yyyy-MM-dd")})`);
1292
+ if (M !== "date" && h === void 0 && (X === null || te === null))
1293
+ throw new RangeError(`DateSelector: variant="${M}" needs a bounded range; supply minDate/minYear and maxDate/maxYear${M === "dropdown" ? ' or supply "allowedDates"' : ""}`);
1294
+ const ze = h === void 0 ? null : h.map((f) => f.getTime()).join(","), oe = Y(() => h === void 0 ? null : va(h, X, te), [ze, ae, me]), Ze = (f) => {
1295
+ const k = f.getTime();
1296
+ return oe !== null ? oe.some((Ie) => Ie.getTime() === k) : !(ae !== null && k < ae || me !== null && k > me);
1297
+ }, mt = E.getTime();
1298
+ xt(() => {
1299
+ S || L(Je(E));
1300
+ }, [S, mt]);
1301
+ const Se = (f) => {
1302
+ if (p) return;
1303
+ const k = Je(f);
1304
+ Ze(k) && (S || L(k), n?.(k));
1305
+ }, pe = P.getTime(), ue = Ze(P), I = Y(() => {
1306
+ if (oe !== null) {
1307
+ for (let k = oe.length - 1; k >= 0; k--)
1308
+ if (oe[k].getTime() < pe) return oe[k];
1309
+ return null;
1310
+ }
1311
+ const f = Dr(new Date(pe), -1);
1312
+ return ae !== null && f.getTime() < ae ? null : f;
1313
+ }, [oe, pe, ae]), F = Y(() => {
1314
+ if (oe !== null) {
1315
+ for (const k of oe)
1316
+ if (k.getTime() > pe) return k;
1317
+ return null;
1318
+ }
1319
+ const f = Dr(new Date(pe), 1);
1320
+ return me !== null && f.getTime() > me ? null : f;
1321
+ }, [oe, pe, me]), G = p || I === null, de = p || F === null, $ = () => {
1322
+ I !== null && Se(I);
1323
+ }, be = () => {
1324
+ F !== null && Se(F);
1325
+ }, Ee = (f) => {
1326
+ if (f.target.value) {
1327
+ const k = cn(f.target.value);
1328
+ Number.isNaN(k.getTime()) || Se(k);
1329
+ }
1330
+ }, Qe = (f) => {
1331
+ if (f.target.value) {
1332
+ const k = cn(f.target.value);
1333
+ Number.isNaN(k.getTime()) || Se(k);
1334
+ }
1335
+ }, se = P.getFullYear(), De = P.getMonth() + 1, ft = P.getDate(), Ft = Y(() => M !== "dropdown" ? [] : oe !== null ? hn(oe, A) : X === null || te === null ? [] : hn(pa(X, te), A), [M, oe, ae, me, A]), rr = Y(() => {
1336
+ if (M !== "split-dropdown" || X === null || te === null) return [];
1337
+ const f = [];
1338
+ for (let k = te.getFullYear(); k >= X.getFullYear(); k--)
1339
+ f.push(k);
1340
+ return f;
1341
+ }, [M, ae, me]), fe = Y(() => {
1342
+ if (M !== "split-dropdown" || X === null || te === null) return [];
1343
+ const f = X, k = te, Ie = se === f.getFullYear() ? f.getMonth() + 1 : 1, Lt = se === k.getFullYear() ? k.getMonth() + 1 : 12, ht = [];
1344
+ for (let et = Ie; et <= Lt; et++)
1345
+ ht.push(et);
1346
+ return ht;
1347
+ }, [M, ae, me, se]), ge = Y(() => {
1348
+ if (M !== "split-dropdown" || X === null || te === null) return [];
1349
+ const f = X, k = te, Ie = se === f.getFullYear() && De === f.getMonth() + 1 ? f.getDate() : 1, Lt = se === k.getFullYear() && De === k.getMonth() + 1 ? k.getDate() : sn(new Date(pe)), ht = [];
1350
+ for (let et = Ie; et <= Lt; et++)
1351
+ ht.push(et);
1352
+ return ht;
1353
+ }, [M, ae, me, pe, se, De]), J = (f, k, Ie) => {
1354
+ Ie > sn(Ot(f, k, 1)) || Se(Ot(f, k, Ie));
1355
+ }, gt = (f) => O ? O(f) : Ir("year", fn(f), A), T = (f) => y ? y(f) : Ir("month", Ot(se, f, 1), A), nr = (f) => B ? B(f) : Ir("day", Ot(se, De, f), A), ar = Ht(P, "yyyy-MM-dd"), Tt = Ae("day", P, void 0, A), z = X ? Ht(X, "yyyy-MM-dd") : void 0, N = te ? Ht(te, "yyyy-MM-dd") : void 0, Vt = ue ? ar : "", it = "text-center font-mono text-gray-500 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-400";
1356
+ return /* @__PURE__ */ le("div", { className: `inline-flex items-center ${M === "split-dropdown" ? "w-auto" : "w-38"} ${x}`, style: c, "data-variant": M, "data-out-of-range": ue ? void 0 : "true", children: [
1357
+ /* @__PURE__ */ w(
1358
+ "button",
1359
+ {
1360
+ type: "button",
1361
+ "aria-label": _,
1362
+ disabled: G,
1363
+ className: "relative my-auto inline-flex h-5 w-4 cursor-pointer items-center justify-center rounded p-0 after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 disabled:opacity-40",
1364
+ onClick: $,
1365
+ children: /* @__PURE__ */ w("span", { className: "h-0 w-0 border-y-[6px] border-y-transparent border-r-[6px] border-r-slate-500 border-solid hover:border-r-slate-700 dark:border-r-slate-400 dark:hover:border-r-slate-200" })
1366
+ }
1367
+ ),
1368
+ M === "dropdown" ? /* @__PURE__ */ le("select", { "aria-label": D, disabled: p, className: "mx-1 my-auto w-28 appearance-none rounded-md border border-gray-300 bg-gray-100 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums [text-align-last:center] [text-align:center] focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500", value: Vt, onChange: Qe, children: [
1369
+ ue ? null : /* @__PURE__ */ w("option", { value: "", disabled: !0, className: it, children: Tt }),
1370
+ Ft.map((f) => /* @__PURE__ */ w("option", { value: f.value, className: "text-center font-mono text-gray-900 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-100", children: f.label }, f.value))
1371
+ ] }) : M === "split-dropdown" ? /* @__PURE__ */ le("div", { className: "mx-1 my-auto inline-flex items-center gap-1", children: [
1372
+ /* @__PURE__ */ le(
1373
+ "select",
1374
+ {
1375
+ "aria-label": W,
1376
+ disabled: p,
1377
+ className: "rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100",
1378
+ value: ue ? se : "",
1379
+ onChange: (f) => J(Number(f.target.value), De, ft),
1380
+ children: [
1381
+ ue ? null : /* @__PURE__ */ w("option", { value: "", disabled: !0, className: it, children: gt(se) }),
1382
+ rr.map((f) => /* @__PURE__ */ w("option", { value: f, className: "dark:bg-slate-700 dark:text-slate-100", children: gt(f) }, f))
1383
+ ]
1384
+ }
1385
+ ),
1386
+ /* @__PURE__ */ le(
1387
+ "select",
1388
+ {
1389
+ "aria-label": C,
1390
+ disabled: p,
1391
+ className: "rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100",
1392
+ value: ue ? De : "",
1393
+ onChange: (f) => J(se, Number(f.target.value), ft),
1394
+ children: [
1395
+ ue ? null : /* @__PURE__ */ w("option", { value: "", disabled: !0, className: it, children: T(De) }),
1396
+ fe.map((f) => /* @__PURE__ */ w("option", { value: f, className: "dark:bg-slate-700 dark:text-slate-100", children: T(f) }, f))
1397
+ ]
1398
+ }
1399
+ ),
1400
+ /* @__PURE__ */ le(
1401
+ "select",
1402
+ {
1403
+ "aria-label": Q,
1404
+ disabled: p,
1405
+ className: "rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100",
1406
+ value: ue ? ft : "",
1407
+ onChange: (f) => J(se, De, Number(f.target.value)),
1408
+ children: [
1409
+ ue ? null : /* @__PURE__ */ w("option", { value: "", disabled: !0, className: it, children: nr(ft) }),
1410
+ ge.map((f) => /* @__PURE__ */ w("option", { value: f, className: "dark:bg-slate-700 dark:text-slate-100", children: nr(f) }, f))
1411
+ ]
1412
+ }
1413
+ )
1414
+ ] }) : /* @__PURE__ */ w(
1415
+ "input",
1416
+ {
1417
+ "aria-label": D,
1418
+ disabled: p,
1419
+ className: "mx-1 my-auto w-28 rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-gray-900 text-xs focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500 dark:placeholder:text-gray-400",
1420
+ value: ar,
1421
+ min: z,
1422
+ max: N,
1423
+ onChange: Ee,
1424
+ type: "date"
1425
+ }
1426
+ ),
1427
+ /* @__PURE__ */ w(
1428
+ "button",
1429
+ {
1430
+ type: "button",
1431
+ "aria-label": Z,
1432
+ disabled: de,
1433
+ className: "relative my-auto inline-flex h-5 w-4 cursor-pointer items-center justify-center rounded p-0 after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 disabled:opacity-40",
1434
+ onClick: be,
1435
+ children: /* @__PURE__ */ w("span", { className: "h-0 w-0 border-y-[6px] border-y-transparent border-l-[6px] border-l-slate-500 border-solid hover:border-l-slate-700 dark:border-l-slate-400 dark:hover:border-l-slate-200" })
1436
+ }
1437
+ ),
1438
+ a
1439
+ ] });
1440
+ }, It = (e) => e === void 0 ? null : Je(e).getTime(), Ma = tr(Da, (e, t) => !(It(e.value ?? e.initialDate) !== It(t.value ?? t.initialDate) || It(e.minDate) !== It(t.minDate) || It(e.maxDate) !== It(t.maxDate) || e.variant !== t.variant || e.disabled !== t.disabled || e.className !== t.className || e.style !== t.style || e.minYear !== t.minYear || e.maxYear !== t.maxYear || e.onChange !== t.onChange || e.allowedDates !== t.allowedDates || e.children !== t.children || e.prevDateAriaLabel !== t.prevDateAriaLabel || e.nextDateAriaLabel !== t.nextDateAriaLabel || e.selectAriaLabel !== t.selectAriaLabel || e.yearAriaLabel !== t.yearAriaLabel || e.monthAriaLabel !== t.monthAriaLabel || e.dayAriaLabel !== t.dayAriaLabel || e.locale !== t.locale || e.formatYearOption !== t.formatYearOption || e.formatMonthOption !== t.formatMonthOption || e.formatDayOption !== t.formatDayOption));
1441
+ Ma.displayName = "DateSelector";
1442
+ function Be(e, t) {
1443
+ const r = e + Math.floor(t / 12), n = (t % 12 + 12) % 12, a = new Date(r, n, 1);
1444
+ return a.setFullYear(r), a;
1445
+ }
1446
+ function Mt(e) {
1447
+ return `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}`;
1448
+ }
1449
+ function wr(e, t) {
1450
+ if (e !== void 0 && (!(e instanceof Date) || Number.isNaN(e.getTime())))
1451
+ throw new RangeError(`MonthSelector: \`${t}\` must be a valid Date, received ${String(e)}.`);
1452
+ }
1453
+ function bn(e, t) {
1454
+ if (e !== void 0 && !Number.isInteger(e))
1455
+ throw new RangeError(`MonthSelector: \`${t}\` must be an integer year, received ${String(e)}.`);
1456
+ }
1457
+ function xa(e) {
1458
+ if (e !== void 0)
1459
+ try {
1460
+ Intl.DateTimeFormat.supportedLocalesOf([e]);
1461
+ } catch {
1462
+ throw new RangeError(`MonthSelector: \`locale\` must be a valid BCP 47 language tag, received ${JSON.stringify(e)}.`);
1463
+ }
1464
+ }
1465
+ function ya(e, t) {
1466
+ const r = e === void 0 ? null : Be(e, 0), n = t === void 0 ? null : Be(t.getFullYear(), t.getMonth());
1467
+ return r !== null && n !== null ? r >= n ? r : n : r !== null ? r : n;
1468
+ }
1469
+ function Ta(e, t) {
1470
+ const r = e === void 0 ? null : Be(e, 11), n = t === void 0 ? null : Be(t.getFullYear(), t.getMonth());
1471
+ return r !== null && n !== null ? r <= n ? r : n : r !== null ? r : n;
1472
+ }
1473
+ function Tn(e, t) {
1474
+ return { label: Ae("month", e, void 0, t), value: Mt(e) };
1475
+ }
1476
+ function La(e, t, r) {
1477
+ const n = e.getFullYear() * 12 + e.getMonth(), a = t.getFullYear() * 12 + t.getMonth(), s = [];
1478
+ for (let o = a; o >= n; o--)
1479
+ s.push(Tn(Be(Math.floor(o / 12), o % 12), r));
1480
+ return s;
1481
+ }
1482
+ const Ra = (e) => {
1483
+ const {
1484
+ value: t,
1485
+ initialDate: r,
1486
+ onChange: n,
1487
+ children: a,
1488
+ variant: s = "date",
1489
+ minYear: o,
1490
+ maxYear: d,
1491
+ minDate: g,
1492
+ maxDate: h,
1493
+ isWarning: M = !1,
1494
+ className: x = "",
1495
+ style: c,
1496
+ disabled: p = !1,
1497
+ prevMonthAriaLabel: _ = "Previous month",
1498
+ nextMonthAriaLabel: Z = "Next month",
1499
+ selectAriaLabel: D = "Month",
1500
+ locale: W
1501
+ } = e;
1502
+ xa(W), wr(t, "value"), wr(r, "initialDate"), wr(g, "minDate"), wr(h, "maxDate"), bn(o, "minYear"), bn(d, "maxYear");
1503
+ const C = t ?? r;
1504
+ if (C === void 0)
1505
+ throw new RangeError("MonthSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected month is never inferred from the wall clock.");
1506
+ const [Q, A] = he(() => Be(C.getFullYear(), C.getMonth())), O = t !== void 0, y = Y(() => t !== void 0 ? Be(t.getFullYear(), t.getMonth()) : Q, [t?.getTime(), Q]), B = g?.getTime(), E = h?.getTime(), m = Y(() => ya(o, g), [o, B]), L = Y(() => Ta(d, h), [d, E]);
1507
+ if (m !== null && L !== null && m > L)
1508
+ throw new RangeError(`MonthSelector: the resolved lower bound ${Mt(m)} is after the resolved upper bound ${Mt(L)}.`);
1509
+ if (s === "dropdown" && (m === null || L === null))
1510
+ throw new RangeError('MonthSelector: variant="dropdown" requires a lower bound (`minYear` or `minDate`) and an upper bound (`maxYear` or `maxDate`); the option window is never invented.');
1511
+ const S = m !== null && y < m || L !== null && y > L, H = C.getTime();
1512
+ xt(() => {
1513
+ if (O) return;
1514
+ const $ = Be(C.getFullYear(), C.getMonth());
1515
+ A((be) => be.getTime() === $.getTime() ? be : $);
1516
+ }, [O, H]);
1517
+ const P = ($) => (m === null || $ >= m) && (L === null || $ <= L), ne = ($) => {
1518
+ if (p) return;
1519
+ if (!P($))
1520
+ throw new RangeError(`MonthSelector: refusing to emit ${Mt($)}, which lies outside the declared bounds.`);
1521
+ O || A($);
1522
+ const be = $.getFullYear() * 100 + ($.getMonth() + 1);
1523
+ n?.($, be);
1524
+ }, K = Y(() => Be(y.getFullYear(), y.getMonth() - 1), [y]), X = Y(() => Be(y.getFullYear(), y.getMonth() + 1), [y]), te = p || m !== null && K < m, ae = p || L !== null && X > L, me = () => {
1525
+ ne(K);
1526
+ }, ze = () => {
1527
+ ne(X);
1528
+ }, oe = ($) => {
1529
+ if (!$) return;
1530
+ const [be, Ee] = $.split("-"), Qe = Number(be), se = Number(Ee) - 1;
1531
+ if (!(Number.isInteger(Qe) && Number.isInteger(se))) return;
1532
+ const De = Be(Qe, se);
1533
+ P(De) && ne(De);
1534
+ }, Ze = ($) => {
1535
+ oe($.target.value);
1536
+ }, mt = ($) => {
1537
+ oe($.target.value);
1538
+ }, Se = Mt(y), pe = m ? Mt(m) : void 0, ue = L ? Mt(L) : void 0, I = Y(() => {
1539
+ if (s !== "dropdown" || m === null || L === null) return [];
1540
+ const $ = La(m, L, W);
1541
+ if (!S) return $;
1542
+ const be = Tn(y, W);
1543
+ return [...$, be].sort((Ee, Qe) => Qe.value.localeCompare(Ee.value));
1544
+ }, [s, m?.getTime(), L?.getTime(), S, y, W]), F = M ? "border-amber-300 bg-amber-50 text-amber-900 focus:border-amber-500 focus:ring-amber-500 dark:border-amber-900/50 dark:bg-amber-950/20 dark:text-amber-200" : "border-gray-300 bg-gray-100 text-gray-900 focus:border-blue-500 focus:ring-blue-500 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500", G = `mx-1 my-auto w-28 rounded-md border py-0.5 px-1 text-xs dark:placeholder:text-gray-400 disabled:opacity-50 ${F}`, de = `mx-1 my-auto w-28 appearance-none rounded-md border px-1 py-0.5 text-center font-mono text-xs tabular-nums [text-align-last:center] [text-align:center] disabled:opacity-50 ${F}`;
1545
+ return /* @__PURE__ */ le("div", { className: `inline-flex w-38 items-center ${x}`, style: c, children: [
1546
+ /* @__PURE__ */ w(
1547
+ "button",
1548
+ {
1549
+ type: "button",
1550
+ "aria-label": _,
1551
+ disabled: te,
1552
+ className: "relative my-auto inline-flex h-5 w-4 cursor-pointer items-center justify-center rounded p-0 after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 disabled:opacity-40",
1553
+ onClick: me,
1554
+ children: /* @__PURE__ */ w("span", { className: "h-0 w-0 border-y-[6px] border-y-transparent border-r-[6px] border-r-slate-500 border-solid hover:border-r-slate-700 dark:border-r-slate-400 dark:hover:border-r-slate-200" })
1555
+ }
1556
+ ),
1557
+ s === "dropdown" ? /* @__PURE__ */ w("select", { "aria-label": D, disabled: p, className: de, value: Se, onChange: mt, children: I.map(($) => /* @__PURE__ */ w("option", { value: $.value, className: "text-center font-mono text-gray-900 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-100", children: $.label }, $.value)) }) : /* @__PURE__ */ w("input", { "aria-label": D, disabled: p, className: G, value: Se, min: pe, max: ue, onChange: Ze, type: "month" }),
1558
+ /* @__PURE__ */ w(
1559
+ "button",
1560
+ {
1561
+ type: "button",
1562
+ "aria-label": Z,
1563
+ disabled: ae,
1564
+ className: "relative my-auto inline-flex h-5 w-4 cursor-pointer items-center justify-center rounded p-0 after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 disabled:opacity-40",
1565
+ onClick: ze,
1566
+ children: /* @__PURE__ */ w("span", { className: "h-0 w-0 border-y-[6px] border-y-transparent border-l-[6px] border-l-slate-500 border-solid hover:border-l-slate-700 dark:border-l-slate-400 dark:hover:border-l-slate-200" })
1567
+ }
1568
+ ),
1569
+ a
1570
+ ] });
1571
+ }, Sa = tr(Ra, (e, t) => {
1572
+ const r = e.value ?? e.initialDate, n = t.value ?? t.initialDate, a = r ? r.getFullYear() * 12 + r.getMonth() : null, s = n ? n.getFullYear() * 12 + n.getMonth() : null;
1573
+ if (a !== s || e.variant !== t.variant || e.disabled !== t.disabled || e.className !== t.className || e.style !== t.style || e.isWarning !== t.isWarning || e.minYear !== t.minYear || e.maxYear !== t.maxYear) return !1;
1574
+ const o = e.minDate ? e.minDate.getFullYear() * 12 + e.minDate.getMonth() : null, d = t.minDate ? t.minDate.getFullYear() * 12 + t.minDate.getMonth() : null;
1575
+ if (o !== d) return !1;
1576
+ const g = e.maxDate ? e.maxDate.getFullYear() * 12 + e.maxDate.getMonth() : null, h = t.maxDate ? t.maxDate.getFullYear() * 12 + t.maxDate.getMonth() : null;
1577
+ return !(g !== h || e.onChange !== t.onChange || e.children !== t.children || e.prevMonthAriaLabel !== t.prevMonthAriaLabel || e.nextMonthAriaLabel !== t.nextMonthAriaLabel || e.selectAriaLabel !== t.selectAriaLabel || e.locale !== t.locale);
1578
+ });
1579
+ Sa.displayName = "MonthSelector";
1580
+ function er(e, t, r) {
1581
+ if (!(r instanceof Date) || Number.isNaN(r.getTime()))
1582
+ throw new RangeError(`${e}: ${t} is required and must be a valid Date (received: ${String(r)})`);
1583
+ }
1584
+ function Ur(e, t, r) {
1585
+ if (er(e, "minDate", t), er(e, "maxDate", r), r.getTime() <= t.getTime())
1586
+ throw new RangeError(`${e}: maxDate must be strictly later than minDate (minDate: ${t.toISOString()}, maxDate: ${r.toISOString()})`);
1587
+ }
1588
+ function Hr(e, t, r) {
1589
+ if (!Array.isArray(r) || r.length !== 2)
1590
+ throw new RangeError(`${e}: ${t} is required and must be a [lower, upper] Date tuple (received: ${String(r)})`);
1591
+ if (er(e, `${t}[0]`, r[0]), er(e, `${t}[1]`, r[1]), r[0].getTime() > r[1].getTime())
1592
+ throw new RangeError(`${e}: ${t} upper must not be earlier than lower (lower: ${r[0].toISOString()}, upper: ${r[1].toISOString()})`);
1593
+ }
1594
+ function Or(e, t, r, n, a, s) {
1595
+ if (r.getTime() < n.getTime() || r.getTime() > a.getTime())
1596
+ throw new RangeError(`${e}: ${t} must lie within ${s} (value: ${r.toISOString()}, lower: ${n.toISOString()}, upper: ${a.toISOString()})`);
1597
+ }
1598
+ function Fr(e, t, r, n, a, s) {
1599
+ Or(e, `${t}[0]`, r[0], n, a, s), Or(e, `${t}[1]`, r[1], n, a, s);
1600
+ }
1601
+ function Ce(e, t, r) {
1602
+ return e < t ? t : e > r ? r : e;
1603
+ }
1604
+ function vr(e, t, r, n) {
1605
+ const a = yt(t, r, n[1]);
1606
+ return [Ce(e[0], n[0], a), Ce(e[1], n[0], a)];
1607
+ }
1608
+ function Vr(e, t, r, n) {
1609
+ const a = ut(e, r, t) + n;
1610
+ return e[Math.max(0, Math.min(e.length - 1, a))];
1611
+ }
1612
+ function Br(e) {
1613
+ const t = j(e), r = t.current, n = e, a = Object.keys(r), s = Object.keys(n);
1614
+ return a.length === s.length && s.every((d) => Object.is(r[d], n[d])) || (t.current = e), t.current;
1388
1615
  }
1389
- function fn(e) {
1390
- const { unit: t, initialRange: a, defaultRange: r, minDate: l, maxDate: s, onChangeRange: d, onChangeRangeTuple: h, onChange: u, ...m } = e, p = a ?? r ?? [l ?? /* @__PURE__ */ new Date(), s ?? /* @__PURE__ */ new Date()], A = Q(p), [n, b] = De(p), W = Q(n);
1391
- W.current = n;
1392
- const z = Q(d);
1393
- z.current = d;
1394
- const P = Q(h);
1395
- P.current = h;
1396
- const F = Q(u);
1397
- F.current = u;
1398
- const B = K((N) => {
1399
- let k = W.current[1];
1400
- N.getTime() > k.getTime() && (k = N);
1401
- const j = [N, k];
1402
- b(j), z.current?.(j[0], j[1]), P.current?.(j), F.current?.(j);
1403
- }, []), V = K((N) => {
1404
- let k = W.current[0];
1405
- N.getTime() < k.getTime() && (k = N);
1406
- const j = [k, N];
1407
- b(j), z.current?.(j[0], j[1]), P.current?.(j), F.current?.(j);
1408
- }, []), O = K((N, G) => {
1409
- const k = [N, G];
1410
- b(k), z.current?.(N, G), P.current?.(k), F.current?.(k);
1411
- }, []), f = K((N) => {
1412
- b(N), z.current?.(N[0], N[1]), P.current?.(N), F.current?.(N);
1413
- }, []), I = K(
1414
- (N) => {
1415
- const G = W.current, k = Le(t, G[0], N), j = Le(t, G[1], N), q = qt(k, l, s), fe = qt(j, l, s), me = [q, fe];
1416
- b(me), z.current?.(me[0], me[1]), P.current?.(me), F.current?.(me);
1616
+ function Ca(e) {
1617
+ const { unit: t, minDate: r, maxDate: n, initialRange: a, onChangeRange: s, ...o } = e;
1618
+ Ur("usePeriodSliderRange", r, n), Hr("usePeriodSliderRange", "initialRange", a), Fr("usePeriodSliderRange", "initialRange", a, r, n, "[minDate, maxDate]");
1619
+ const d = Br(o), g = j(a), [h, M] = he(a);
1620
+ let x = h;
1621
+ const c = [Ce(h[0], r, n), Ce(h[1], r, n)];
1622
+ (c[0] !== h[0] || c[1] !== h[1]) && (x = c, M(c));
1623
+ const p = j(x);
1624
+ p.current = x;
1625
+ const _ = j({ minDate: r, maxDate: n, allowedDates: d.allowedDates });
1626
+ _.current = { minDate: r, maxDate: n, allowedDates: d.allowedDates };
1627
+ const Z = j(s);
1628
+ Z.current = s;
1629
+ const D = U((m) => {
1630
+ const { minDate: L, maxDate: S } = _.current, H = Ce(m[0], L, S), P = Ce(m[1], L, S), ne = p.current;
1631
+ H.getTime() === ne[0].getTime() && P.getTime() === ne[1].getTime() || (p.current = [H, P], M([H, P]), Z.current?.(H, P));
1632
+ }, []), W = U(
1633
+ (m) => {
1634
+ const L = p.current, S = m.getTime() > L[1].getTime() ? m : L[1];
1635
+ D([m, S]);
1417
1636
  },
1418
- [t, l, s]
1419
- ), v = K(() => {
1420
- const N = A.current;
1421
- b(N), z.current?.(N[0], N[1]), P.current?.(N), F.current?.(N);
1422
- }, []), M = R(
1637
+ [D]
1638
+ ), C = U(
1639
+ (m) => {
1640
+ const L = p.current, S = m.getTime() < L[0].getTime() ? m : L[0];
1641
+ D([S, m]);
1642
+ },
1643
+ [D]
1644
+ ), Q = U(
1645
+ (m, L) => {
1646
+ D([m, L]);
1647
+ },
1648
+ [D]
1649
+ ), A = U(
1650
+ (m) => {
1651
+ const { minDate: L, maxDate: S, allowedDates: H } = _.current, P = p.current, ne = Qt(H, t, L, S);
1652
+ if (ne.length > 0) {
1653
+ D([Vr(ne, t, P[0], m), Vr(ne, t, P[1], m)]);
1654
+ return;
1655
+ }
1656
+ D([ke(t, P[0], m), ke(t, P[1], m)]);
1657
+ },
1658
+ [t, D]
1659
+ ), O = U(() => {
1660
+ D(g.current);
1661
+ }, [D]), y = Y(
1423
1662
  () => ({
1424
- value: n[0],
1425
- onChange: B,
1426
- minDate: l,
1427
- maxDate: n[1],
1663
+ value: x[0],
1664
+ onChange: W,
1665
+ minDate: r,
1666
+ maxDate: x[1],
1428
1667
  unit: t
1429
1668
  }),
1430
- [n[0], n[1], B, l, t]
1431
- ), x = R(
1669
+ [x[0], x[1], W, r, t]
1670
+ ), B = Y(
1432
1671
  () => ({
1433
- value: n[1],
1434
- onChange: V,
1435
- minDate: n[0],
1436
- maxDate: s,
1672
+ value: x[1],
1673
+ onChange: C,
1674
+ minDate: x[0],
1675
+ maxDate: n,
1437
1676
  unit: t
1438
1677
  }),
1439
- [n[0], n[1], V, s, t]
1440
- ), oe = R(
1678
+ [x[0], x[1], C, n, t]
1679
+ ), E = Y(
1441
1680
  () => ({
1442
- ...m,
1681
+ ...d,
1443
1682
  mode: "range",
1444
1683
  unit: t,
1445
- range: n,
1446
- minDate: l,
1447
- maxDate: s,
1448
- onChangeRange: O,
1449
- onChangeRangeTuple: f,
1450
- onChange: f
1684
+ range: x,
1685
+ minDate: r,
1686
+ maxDate: n,
1687
+ onChangeRange: Q
1451
1688
  }),
1452
- [m, t, n, l, s, O, f]
1689
+ [d, t, x, r, n, Q]
1453
1690
  );
1454
1691
  return {
1455
- range: n,
1456
- lowerDate: n[0],
1457
- upperDate: n[1],
1458
- setRange: b,
1459
- setLowerDate: B,
1460
- setUpperDate: V,
1461
- shiftRange: I,
1462
- resetRange: v,
1463
- startSelectorProps: M,
1464
- endSelectorProps: x,
1465
- sliderProps: oe
1692
+ range: x,
1693
+ lowerDate: x[0],
1694
+ upperDate: x[1],
1695
+ setRange: M,
1696
+ setLowerDate: W,
1697
+ setUpperDate: C,
1698
+ shiftRange: A,
1699
+ resetRange: O,
1700
+ startSelectorProps: y,
1701
+ endSelectorProps: B,
1702
+ sliderProps: E
1466
1703
  };
1467
1704
  }
1468
- function hn(e) {
1469
- const { unit: t, initialValue: a, initialDate: r, defaultValue: l, minDate: s, maxDate: d, onChangePoint: h, onChangeValue: u, onChange: m, ...p } = e, A = a ?? r ?? l ?? s ?? /* @__PURE__ */ new Date(), n = Q(A), [b, W] = De(A), z = Q(b);
1470
- z.current = b;
1471
- const P = Q(h);
1472
- P.current = h;
1473
- const F = Q(u);
1474
- F.current = u;
1475
- const B = Q(m);
1476
- B.current = m;
1477
- const V = K((M) => {
1478
- W(M), P.current?.(M), F.current?.(M), B.current?.(M);
1479
- }, []), O = K(
1480
- (M) => {
1481
- const x = z.current, oe = Le(t, x, M), N = qt(oe, s, d);
1482
- W(N), P.current?.(N), F.current?.(N), B.current?.(N);
1705
+ function Ea(e) {
1706
+ const { unit: t, minDate: r, maxDate: n, initialValue: a, onChangePoint: s, ...o } = e;
1707
+ Ur("usePeriodSliderPoint", r, n), er("usePeriodSliderPoint", "initialValue", a), Or("usePeriodSliderPoint", "initialValue", a, r, n, "[minDate, maxDate]");
1708
+ const d = Br(o), g = j(a), [h, M] = he(a);
1709
+ let x = h;
1710
+ const c = Ce(h, r, n);
1711
+ c !== h && (x = c, M(c));
1712
+ const p = j(x);
1713
+ p.current = x;
1714
+ const _ = j({ minDate: r, maxDate: n, allowedDates: d.allowedDates });
1715
+ _.current = { minDate: r, maxDate: n, allowedDates: d.allowedDates };
1716
+ const Z = j(s);
1717
+ Z.current = s;
1718
+ const D = U((O) => {
1719
+ const { minDate: y, maxDate: B } = _.current, E = Ce(O, y, B);
1720
+ E.getTime() !== p.current.getTime() && (p.current = E, M(E), Z.current?.(E));
1721
+ }, []), W = U(
1722
+ (O) => {
1723
+ const { minDate: y, maxDate: B, allowedDates: E } = _.current, m = Qt(E, t, y, B);
1724
+ if (m.length > 0) {
1725
+ D(Vr(m, t, p.current, O));
1726
+ return;
1727
+ }
1728
+ D(ke(t, p.current, O));
1483
1729
  },
1484
- [t, s, d]
1485
- ), f = K(() => {
1486
- const M = n.current;
1487
- W(M), P.current?.(M), F.current?.(M), B.current?.(M);
1488
- }, []), I = R(
1730
+ [t, D]
1731
+ ), C = U(() => {
1732
+ D(g.current);
1733
+ }, [D]), Q = Y(
1489
1734
  () => ({
1490
- value: b,
1491
- onChange: V,
1492
- minDate: s,
1493
- maxDate: d,
1735
+ value: x,
1736
+ onChange: D,
1737
+ minDate: r,
1738
+ maxDate: n,
1494
1739
  unit: t
1495
1740
  }),
1496
- [b, V, s, d, t]
1497
- ), v = R(
1741
+ [x, D, r, n, t]
1742
+ ), A = Y(
1498
1743
  () => ({
1499
- ...p,
1744
+ ...d,
1500
1745
  mode: "point",
1501
1746
  unit: t,
1502
- value: b,
1503
- minDate: s,
1504
- maxDate: d,
1505
- onChangePoint: V,
1506
- onChangeValue: V,
1507
- onChange: V
1747
+ value: x,
1748
+ minDate: r,
1749
+ maxDate: n,
1750
+ onChangePoint: D
1508
1751
  }),
1509
- [p, t, b, s, d, V]
1752
+ [d, t, x, r, n, D]
1510
1753
  );
1511
1754
  return {
1512
- value: b,
1513
- setValue: W,
1514
- shiftValue: O,
1515
- resetValue: f,
1516
- selectorProps: I,
1517
- sliderProps: v
1755
+ value: x,
1756
+ setValue: M,
1757
+ shiftValue: W,
1758
+ resetValue: C,
1759
+ selectorProps: Q,
1760
+ sliderProps: A
1518
1761
  };
1519
1762
  }
1520
- function bn(e) {
1521
- const {
1522
- minDate: t,
1523
- maxDate: a,
1524
- initialMacroRange: r,
1525
- defaultMacroRange: l,
1526
- initialMicroRange: s,
1527
- defaultMicroRange: d,
1528
- unit: h = "month",
1529
- macroUnit: u = h,
1530
- microUnit: m = h,
1531
- onChangeMacroRange: p,
1532
- onChangeMacroRangeTuple: A,
1533
- onChangeMacro: n,
1534
- onChangeRange: b,
1535
- onChangeRangeTuple: W,
1536
- onChangeMicroRange: z,
1537
- onChangeMicroRangeTuple: P,
1538
- onChangeMicro: F,
1539
- ...B
1540
- } = e, V = r ?? l ?? [t, a], O = s ?? d ?? V, f = Q(V), I = Q(O), [v, M] = De(V), [x, oe] = De(O), N = Q(v);
1541
- N.current = v;
1542
- const G = Q(x);
1543
- G.current = x;
1544
- const k = K(
1545
- (L, S) => {
1546
- M([L, S]), p?.(L, S), A?.([L, S]), n?.([L, S]);
1763
+ function Ia(e) {
1764
+ const { unit: t, minDate: r, maxDate: n, initialMacroRange: a, initialMicroRange: s, macroUnit: o = t, microUnit: d = t, onChangeMacroRange: g, onChangeMicroRange: h, ...M } = e;
1765
+ Ur("useVernierSlider", r, n), Hr("useVernierSlider", "initialMacroRange", a), Hr("useVernierSlider", "initialMicroRange", s), Fr("useVernierSlider", "initialMacroRange", a, r, n, "[minDate, maxDate]"), Fr("useVernierSlider", "initialMicroRange", s, a[0], yt(o, d, a[1]), "the initial macro window");
1766
+ const x = Br(M), c = j(a), p = j(s), [_, Z] = he(a), [D, W] = he(s);
1767
+ let C = _;
1768
+ const Q = [Ce(_[0], r, n), Ce(_[1], r, n)];
1769
+ (Q[0] !== _[0] || Q[1] !== _[1]) && (C = Q, Z(Q));
1770
+ let A = D;
1771
+ const O = vr(D, o, d, C);
1772
+ (O[0] !== D[0] || O[1] !== D[1]) && (A = O, W(O));
1773
+ const y = j(C);
1774
+ y.current = C;
1775
+ const B = j(A);
1776
+ B.current = A;
1777
+ const E = j({ minDate: r, maxDate: n });
1778
+ E.current = { minDate: r, maxDate: n };
1779
+ const m = j(g);
1780
+ m.current = g;
1781
+ const L = j(h);
1782
+ L.current = h;
1783
+ const S = U((I, F) => {
1784
+ const G = y.current, de = B.current;
1785
+ (I[0].getTime() !== G[0].getTime() || I[1].getTime() !== G[1].getTime()) && (y.current = I, Z(I), m.current?.(I[0], I[1])), (F[0].getTime() !== de[0].getTime() || F[1].getTime() !== de[1].getTime()) && (B.current = F, W(F), L.current?.(F[0], F[1]));
1786
+ }, []), H = U(
1787
+ (I, F) => {
1788
+ const { minDate: G, maxDate: de } = E.current, $ = [Ce(I, G, de), Ce(F, G, de)];
1789
+ S($, vr(B.current, o, d, $));
1547
1790
  },
1548
- [p, A, n]
1549
- ), j = K(
1550
- (L) => {
1551
- k(L[0], L[1]);
1791
+ [o, d, S]
1792
+ ), P = U(
1793
+ (I, F) => {
1794
+ S(y.current, vr([I, F], o, d, y.current));
1552
1795
  },
1553
- [k]
1554
- ), q = K(
1555
- (L, S) => {
1556
- oe([L, S]), b?.(L, S), W?.([L, S]), z?.(L, S), P?.([L, S]), F?.([L, S]);
1796
+ [o, d, S]
1797
+ ), ne = U(
1798
+ (I) => {
1799
+ const F = y.current[1], G = I > F ? I : F;
1800
+ H(I, G);
1557
1801
  },
1558
- [b, W, z, P, F]
1559
- ), fe = K(
1560
- (L) => {
1561
- q(L[0], L[1]);
1802
+ [H]
1803
+ ), K = U(
1804
+ (I) => {
1805
+ const F = y.current[0], G = I < F ? I : F;
1806
+ H(G, I);
1562
1807
  },
1563
- [q]
1564
- ), me = K(
1565
- (L) => {
1566
- const S = N.current[1], Z = L < t ? t : L, ae = L > S ? L : S;
1567
- k(Z, ae);
1808
+ [H]
1809
+ ), X = U(
1810
+ (I) => {
1811
+ const F = B.current[1], G = I > F ? I : F;
1812
+ P(I, G);
1568
1813
  },
1569
- [t, k]
1570
- ), se = K(
1571
- (L) => {
1572
- const S = N.current[0], Z = L > a ? a : L, ae = L < S ? L : S;
1573
- k(ae, Z);
1814
+ [P]
1815
+ ), te = U(
1816
+ (I) => {
1817
+ const F = B.current[0], G = I < F ? I : F;
1818
+ P(G, I);
1574
1819
  },
1575
- [a, k]
1576
- ), ee = K(
1577
- (L) => {
1578
- const S = N.current, Z = G.current, ae = L < S[0] ? S[0] : L, Y = L > Z[1] ? L : Z[1];
1579
- q(ae, Y);
1820
+ [P]
1821
+ ), ae = U(
1822
+ (I) => {
1823
+ const { minDate: F, maxDate: G } = E.current, de = y.current, $ = ke(o, de[0], I), be = ke(o, de[1], I);
1824
+ $ < F || be > G || H($, be);
1580
1825
  },
1581
- [q]
1582
- ), X = K(
1583
- (L) => {
1584
- const S = N.current, Z = G.current, ae = L > S[1] ? S[1] : L, Y = L < Z[0] ? L : Z[0];
1585
- q(Y, ae);
1826
+ [o, H]
1827
+ ), me = U(
1828
+ (I) => {
1829
+ const F = y.current, G = B.current, de = ke(d, G[0], I), $ = ke(d, G[1], I);
1830
+ de < F[0] || $ > yt(o, d, F[1]) || P(de, $);
1586
1831
  },
1587
- [q]
1588
- ), de = K(
1589
- (L) => {
1590
- const S = N.current, Z = Le(u, S[0], L), ae = Le(u, S[1], L);
1591
- Z < t || ae > a || k(Z, ae);
1592
- },
1593
- [u, t, a, k]
1594
- ), Ve = K(
1595
- (L) => {
1596
- const S = N.current, Z = G.current, ae = Le(m, Z[0], L), Y = Le(m, Z[1], L);
1597
- ae < S[0] || Y > S[1] || q(ae, Y);
1598
- },
1599
- [m, q]
1600
- ), xe = K(() => {
1601
- const [L, S] = f.current, [Z, ae] = I.current;
1602
- k(L, S), q(Z, ae);
1603
- }, [k, q]), Ye = R(
1832
+ [o, d, P]
1833
+ ), ze = U(() => {
1834
+ const I = c.current;
1835
+ S(I, vr(p.current, o, d, I));
1836
+ }, [o, d, S]), oe = Y(() => yt(o, d, C[1]), [o, d, C[1]]), Ze = Y(
1604
1837
  () => ({
1605
- value: v[0],
1606
- onChange: me,
1607
- minDate: t,
1608
- maxDate: v[1],
1609
- unit: u
1838
+ value: C[0],
1839
+ onChange: ne,
1840
+ minDate: r,
1841
+ maxDate: C[1],
1842
+ unit: o
1610
1843
  }),
1611
- [v, me, t, u]
1612
- ), Re = R(
1844
+ [C, ne, r, o]
1845
+ ), mt = Y(
1613
1846
  () => ({
1614
- value: v[1],
1615
- onChange: se,
1616
- minDate: v[0],
1617
- maxDate: a,
1618
- unit: u
1847
+ value: C[1],
1848
+ onChange: K,
1849
+ minDate: C[0],
1850
+ maxDate: n,
1851
+ unit: o
1619
1852
  }),
1620
- [v, se, a, u]
1621
- ), we = R(
1853
+ [C, K, n, o]
1854
+ ), Se = Y(
1622
1855
  () => ({
1623
- value: x[0],
1624
- onChange: ee,
1625
- minDate: v[0],
1626
- maxDate: x[1],
1627
- unit: m
1856
+ value: A[0],
1857
+ onChange: X,
1858
+ minDate: C[0],
1859
+ maxDate: A[1],
1860
+ unit: d
1628
1861
  }),
1629
- [x, ee, v, m]
1630
- ), je = R(
1862
+ [A, X, C, d]
1863
+ ), pe = Y(
1631
1864
  () => ({
1632
- value: x[1],
1633
- onChange: X,
1634
- minDate: x[0],
1635
- maxDate: v[1],
1636
- unit: m
1865
+ value: A[1],
1866
+ onChange: te,
1867
+ minDate: A[0],
1868
+ maxDate: oe,
1869
+ unit: d
1637
1870
  }),
1638
- [x, X, v, m]
1639
- ), Ee = R(
1871
+ [A, te, oe, d]
1872
+ ), ue = Y(
1640
1873
  () => ({
1641
- ...B,
1874
+ ...x,
1642
1875
  mode: "vernier",
1643
- unit: h,
1644
- macroUnit: u,
1645
- microUnit: m,
1646
- minDate: t,
1647
- maxDate: a,
1648
- macroRange: v,
1649
- microRange: x,
1650
- onChangeMacroRange: k,
1651
- onChangeMacroRangeTuple: j,
1652
- onChangeMacro: j,
1653
- onChangeRange: q,
1654
- onChangeRangeTuple: fe,
1655
- onChangeMicroRange: q,
1656
- onChangeMicroRangeTuple: fe,
1657
- onChangeMicro: fe
1876
+ unit: t,
1877
+ macroUnit: o,
1878
+ microUnit: d,
1879
+ minDate: r,
1880
+ maxDate: n,
1881
+ macroRange: C,
1882
+ microRange: A,
1883
+ onChangeMacroRange: H,
1884
+ onChangeMicroRange: P
1658
1885
  }),
1659
- [B, h, u, m, t, a, v, x, k, j, q, fe]
1886
+ [x, t, o, d, r, n, C, A, H, P]
1660
1887
  );
1661
1888
  return {
1662
- macroRange: v,
1663
- setMacroRange: M,
1664
- microRange: x,
1665
- setMicroRange: oe,
1666
- setMacroLowerDate: me,
1667
- setMacroUpperDate: se,
1668
- setMicroLowerDate: ee,
1669
- setMicroUpperDate: X,
1670
- shiftMacroRange: de,
1671
- shiftMicroRange: Ve,
1672
- resetVernier: xe,
1673
- macroStartSelectorProps: Ye,
1674
- macroEndSelectorProps: Re,
1675
- microStartSelectorProps: we,
1676
- microEndSelectorProps: je,
1677
- sliderProps: Ee
1889
+ macroRange: C,
1890
+ setMacroRange: Z,
1891
+ microRange: A,
1892
+ setMicroRange: W,
1893
+ setMacroLowerDate: ne,
1894
+ setMacroUpperDate: K,
1895
+ setMicroLowerDate: X,
1896
+ setMicroUpperDate: te,
1897
+ shiftMacroRange: ae,
1898
+ shiftMicroRange: me,
1899
+ resetVernier: ze,
1900
+ macroStartSelectorProps: Ze,
1901
+ macroEndSelectorProps: mt,
1902
+ microStartSelectorProps: Se,
1903
+ microEndSelectorProps: pe,
1904
+ sliderProps: ue
1678
1905
  };
1679
1906
  }
1680
- const cn = (e) => {
1681
- const { value: t, initialDate: a, onChange: r, children: l, minYear: s, maxYear: d, minDate: h, maxDate: u, className: m = "", style: p, disabled: A = !1, prevYearAriaLabel: n = "前年", nextYearAriaLabel: b = "翌年", selectAriaLabel: W = "会計年" } = e, z = t ?? a, [P, F] = De(() => (z ?? /* @__PURE__ */ new Date()).getFullYear()), B = h?.getTime(), V = u?.getTime(), O = R(() => {
1682
- if (s !== void 0) return s;
1683
- if (h) return h.getFullYear();
1684
- }, [s, B]), f = R(() => {
1685
- if (d !== void 0) return d;
1686
- if (u) return u.getFullYear();
1687
- }, [d, V]), I = t !== void 0, v = I ? t && !Number.isNaN(t.getTime()) ? t.getFullYear() : O ?? (/* @__PURE__ */ new Date()).getFullYear() : P, M = z?.getTime();
1688
- ot(() => {
1689
- !I && z && !Number.isNaN(z.getTime()) && F(z.getFullYear());
1690
- }, [I, M]);
1691
- const x = (se) => {
1692
- if (A) return;
1693
- let ee = se;
1694
- O !== void 0 && ee < O && (ee = O), f !== void 0 && ee > f && (ee = f), I || F(ee);
1695
- const X = new Date(ee, 0, 1);
1696
- X.setFullYear(ee), r?.(X, ee);
1697
- }, oe = A || O !== void 0 && v - 1 < O, N = A || f !== void 0 && v + 1 > f, G = O ?? Math.min(v - 10, v), k = f ?? Math.max(v + 1, v), j = Math.min(G, v), q = Math.max(k, v), fe = `${j}_${q}`, me = R(() => {
1698
- const se = [];
1699
- for (let ee = q; ee >= j; ee--)
1700
- se.push(ee);
1701
- return se;
1702
- }, [fe]);
1703
- return /* @__PURE__ */ le("div", { className: `inline-flex w-32 items-center ${m}`, style: p, children: [
1704
- /* @__PURE__ */ T(
1907
+ function wn(e) {
1908
+ const t = new Date(e, 0, 1);
1909
+ return t.setFullYear(e), t;
1910
+ }
1911
+ function pr(e, t) {
1912
+ if (e !== void 0 && (!(e instanceof Date) || Number.isNaN(e.getTime())))
1913
+ throw new RangeError(`YearSelector: \`${t}\` must be a valid Date, received ${String(e)}.`);
1914
+ }
1915
+ function vn(e, t) {
1916
+ if (e !== void 0 && !Number.isInteger(e))
1917
+ throw new RangeError(`YearSelector: \`${t}\` must be an integer year, received ${String(e)}.`);
1918
+ }
1919
+ function $a(e) {
1920
+ if (e !== void 0)
1921
+ try {
1922
+ Intl.DateTimeFormat.supportedLocalesOf([e]);
1923
+ } catch {
1924
+ throw new RangeError(`YearSelector: \`locale\` must be a valid BCP 47 language tag, received ${JSON.stringify(e)}.`);
1925
+ }
1926
+ }
1927
+ function pn(e, t, r) {
1928
+ const n = e === void 0 ? null : e, a = t === void 0 ? null : t.getFullYear();
1929
+ return n !== null && a !== null ? r(n, a) : n !== null ? n : a;
1930
+ }
1931
+ const ka = (e) => {
1932
+ const { value: t, initialDate: r, onChange: n, children: a, minYear: s, maxYear: o, minDate: d, maxDate: g, className: h = "", style: M, disabled: x = !1, prevYearAriaLabel: c = "Previous year", nextYearAriaLabel: p = "Next year", selectAriaLabel: _ = "Year", locale: Z } = e;
1933
+ pr(t, "value"), pr(r, "initialDate"), pr(d, "minDate"), pr(g, "maxDate"), vn(s, "minYear"), vn(o, "maxYear"), $a(Z);
1934
+ const D = t ?? r;
1935
+ if (D === void 0)
1936
+ throw new RangeError("YearSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected year is never inferred from the wall clock.");
1937
+ const [W, C] = he(() => D.getFullYear()), Q = d?.getTime(), A = g?.getTime(), O = Y(() => pn(s, d, Math.max), [s, Q]), y = Y(() => pn(o, g, Math.min), [o, A]);
1938
+ if (O === null || y === null)
1939
+ throw new RangeError("YearSelector: a lower bound (`minYear` or `minDate`) and an upper bound (`maxYear` or `maxDate`) are both required; the year option list is never invented.");
1940
+ if (O > y)
1941
+ throw new RangeError(`YearSelector: the resolved lower bound ${O} is after the resolved upper bound ${y}.`);
1942
+ const B = t !== void 0, E = t !== void 0 ? t.getFullYear() : W, m = E < O || E > y, L = D.getTime();
1943
+ xt(() => {
1944
+ B || C(D.getFullYear());
1945
+ }, [B, L]);
1946
+ const S = (K) => {
1947
+ if (!x) {
1948
+ if (K < O || K > y)
1949
+ throw new RangeError(`YearSelector: refusing to emit ${K}, which lies outside the declared bounds ${O}-${y}.`);
1950
+ B || C(K), n?.(wn(K), K);
1951
+ }
1952
+ }, H = x || E - 1 < O, P = x || E + 1 > y, ne = Y(() => {
1953
+ const K = [];
1954
+ for (let X = y; X >= O; X--)
1955
+ K.push(X);
1956
+ return m && (K.push(E), K.sort((X, te) => te - X)), K;
1957
+ }, [O, y, m, E]);
1958
+ return /* @__PURE__ */ le("div", { className: `inline-flex w-32 items-center ${h}`, style: M, children: [
1959
+ /* @__PURE__ */ w(
1705
1960
  "button",
1706
1961
  {
1707
1962
  type: "button",
1708
- "aria-label": n,
1709
- disabled: oe,
1963
+ "aria-label": c,
1964
+ disabled: H,
1710
1965
  className: "relative my-auto inline-flex h-5 w-4 cursor-pointer items-center justify-center rounded p-0 after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 disabled:opacity-40",
1711
- onClick: () => x(v - 1),
1712
- children: /* @__PURE__ */ T("span", { className: "h-0 w-0 border-y-[6px] border-y-transparent border-r-[6px] border-r-slate-500 border-solid hover:border-r-slate-700 dark:border-r-slate-400 dark:hover:border-r-slate-200" })
1966
+ onClick: () => S(E - 1),
1967
+ children: /* @__PURE__ */ w("span", { className: "h-0 w-0 border-y-[6px] border-y-transparent border-r-[6px] border-r-slate-500 border-solid hover:border-r-slate-700 dark:border-r-slate-400 dark:hover:border-r-slate-200" })
1713
1968
  }
1714
1969
  ),
1715
- /* @__PURE__ */ T(
1970
+ /* @__PURE__ */ w(
1716
1971
  "select",
1717
1972
  {
1718
- "aria-label": W,
1719
- disabled: A,
1973
+ "aria-label": _,
1974
+ disabled: x,
1720
1975
  className: "mx-1 my-auto w-18 appearance-none rounded-md border border-gray-300 bg-gray-100 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums [text-align-last:center] [text-align:center] focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500",
1721
- value: v,
1722
- onChange: (se) => {
1723
- se.target.value && x(Number(se.target.value));
1976
+ value: E,
1977
+ onChange: (K) => {
1978
+ if (!K.target.value) return;
1979
+ const X = Number(K.target.value);
1980
+ Number.isInteger(X) && S(X);
1724
1981
  },
1725
- children: me.map((se) => /* @__PURE__ */ T("option", { value: se, className: "text-center font-mono text-gray-900 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-100", children: se }, se))
1982
+ children: ne.map((K) => /* @__PURE__ */ w("option", { value: K, className: "text-center font-mono text-gray-900 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-100", children: Ae("year", wn(K), void 0, Z) }, K))
1726
1983
  }
1727
1984
  ),
1728
- /* @__PURE__ */ T(
1985
+ /* @__PURE__ */ w(
1729
1986
  "button",
1730
1987
  {
1731
1988
  type: "button",
1732
- "aria-label": b,
1733
- disabled: N,
1989
+ "aria-label": p,
1990
+ disabled: P,
1734
1991
  className: "relative my-auto inline-flex h-5 w-4 cursor-pointer items-center justify-center rounded p-0 after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 disabled:opacity-40",
1735
- onClick: () => x(v + 1),
1736
- children: /* @__PURE__ */ T("span", { className: "h-0 w-0 border-y-[6px] border-y-transparent border-l-[6px] border-l-slate-500 border-solid hover:border-l-slate-700 dark:border-l-slate-400 dark:hover:border-l-slate-200" })
1992
+ onClick: () => S(E + 1),
1993
+ children: /* @__PURE__ */ w("span", { className: "h-0 w-0 border-y-[6px] border-y-transparent border-l-[6px] border-l-slate-500 border-solid hover:border-l-slate-700 dark:border-l-slate-400 dark:hover:border-l-slate-200" })
1737
1994
  }
1738
1995
  ),
1739
- l
1996
+ a
1740
1997
  ] });
1741
- }, un = Ct(cn, (e, t) => {
1742
- const a = e.value ?? e.initialDate, r = t.value ?? t.initialDate, l = a && !Number.isNaN(a.getTime()) ? a.getFullYear() : null, s = r && !Number.isNaN(r.getTime()) ? r.getFullYear() : null;
1743
- return !(l !== s || e.disabled !== t.disabled || e.className !== t.className || e.style !== t.style || e.minYear !== t.minYear || e.maxYear !== t.maxYear || e.minDate?.getFullYear() !== t.minDate?.getFullYear() || e.maxDate?.getFullYear() !== t.maxDate?.getFullYear() || e.onChange !== t.onChange || e.children !== t.children || e.prevYearAriaLabel !== t.prevYearAriaLabel || e.nextYearAriaLabel !== t.nextYearAriaLabel || e.selectAriaLabel !== t.selectAriaLabel);
1998
+ }, Pa = tr(ka, (e, t) => {
1999
+ const r = e.value ?? e.initialDate, n = t.value ?? t.initialDate, a = r ? r.getFullYear() : null, s = n ? n.getFullYear() : null;
2000
+ return !(a !== s || e.disabled !== t.disabled || e.className !== t.className || e.style !== t.style || e.minYear !== t.minYear || e.maxYear !== t.maxYear || e.minDate?.getFullYear() !== t.minDate?.getFullYear() || e.maxDate?.getFullYear() !== t.maxDate?.getFullYear() || e.onChange !== t.onChange || e.children !== t.children || e.prevYearAriaLabel !== t.prevYearAriaLabel || e.nextYearAriaLabel !== t.nextYearAriaLabel || e.selectAriaLabel !== t.selectAriaLabel || e.locale !== t.locale);
1744
2001
  });
1745
- un.displayName = "YearSelector";
2002
+ Pa.displayName = "YearSelector";
1746
2003
  export {
1747
- La as COLOR_SCHEME_PALETTES,
1748
- _a as DateSelector,
1749
- qa as MonthSelector,
1750
- sn as PeriodSlider,
1751
- un as YearSelector,
1752
- Le as addUnit,
1753
- Ja as calculateConnectDragValues,
1754
- Ra as calculateHandleDragValues,
1755
- Qa as calculateKeyboardActionValues,
1756
- en as calculateLabelSlant,
1757
- an as calculateVernierMacroDrag,
1758
- Me as decode,
1759
- te as encode,
1760
- Ya as findNearestDateIndex,
1761
- rt as formatLabel,
1762
- mt as formatScreenReaderLabel,
1763
- jt as getMacroWindowEndDate,
1764
- _t as getSortedAllowedDates,
1765
- ue as normalizeDateByUnit,
1766
- tn as resolveVernierTargetHandle,
1767
- hn as usePeriodSliderPoint,
1768
- fn as usePeriodSliderRange,
1769
- bn as useVernierSlider
2004
+ _n as COLOR_SCHEME_PALETTES,
2005
+ Ma as DateSelector,
2006
+ Sa as MonthSelector,
2007
+ da as PeriodSlider,
2008
+ Pa as YearSelector,
2009
+ ke as addUnit,
2010
+ ca as areStylesEqual,
2011
+ Gn as calculateConnectDragValues,
2012
+ dn as calculateHandleDragValues,
2013
+ Wn as calculateKeyboardActionValues,
2014
+ Qn as calculateLabelSlant,
2015
+ ta as calculateVernierMacroDrag,
2016
+ ra as calculateVernierMicroDrag,
2017
+ ce as decode,
2018
+ re as encode,
2019
+ ut as findNearestDateIndex,
2020
+ Ae as formatLabel,
2021
+ Et as formatScreenReaderLabel,
2022
+ jn as getActiveDragHandle,
2023
+ yt as getMacroWindowEndDate,
2024
+ Qt as getSortedAllowedDates,
2025
+ We as normalizeDateByUnit,
2026
+ ea as resolveVernierTargetHandle,
2027
+ Ea as usePeriodSliderPoint,
2028
+ Ca as usePeriodSliderRange,
2029
+ Ia as useVernierSlider
1770
2030
  };