@aiquants/period-slider 0.2.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 ADDED
@@ -0,0 +1,1770 @@
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 = {
324
+ "blue-rose": {
325
+ macro: "#0284c7",
326
+ macroLight: "#38bdf8",
327
+ micro: "#e11d48",
328
+ microLight: "#fb7185",
329
+ accent: "#0284c7"
330
+ },
331
+ "indigo-amber": {
332
+ macro: "#4f46e5",
333
+ macroLight: "#818cf8",
334
+ micro: "#d97706",
335
+ microLight: "#fbbf24",
336
+ accent: "#4f46e5"
337
+ },
338
+ "teal-emerald": {
339
+ macro: "#0d9488",
340
+ macroLight: "#2dd4bf",
341
+ micro: "#059669",
342
+ microLight: "#34d399",
343
+ accent: "#0d9488"
344
+ },
345
+ "violet-fuchsia": {
346
+ macro: "#7c3aed",
347
+ macroLight: "#a78bfa",
348
+ micro: "#c026d3",
349
+ microLight: "#e879f9",
350
+ accent: "#7c3aed"
351
+ },
352
+ "slate-sky": {
353
+ macro: "#475569",
354
+ macroLight: "#94a3b8",
355
+ micro: "#0284c7",
356
+ microLight: "#38bdf8",
357
+ accent: "#475569"
358
+ },
359
+ monochrome: {
360
+ macro: "#52525b",
361
+ macroLight: "#a1a1aa",
362
+ micro: "#18181b",
363
+ microLight: "#71717a",
364
+ accent: "#27272a"
365
+ }
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) => {
375
+ if (e === "year") return new Date(t, 0, 1);
376
+ if (e === "month") {
377
+ const r = Math.floor(t / 12), l = t % 12;
378
+ return new Date(r, l, 1);
379
+ }
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();
387
+ if (e === t)
388
+ return ue(t, a);
389
+ const r = a.getFullYear(), l = a.getMonth();
390
+ if (e === "year") {
391
+ if (t === "month")
392
+ return new Date(r, 11, 1);
393
+ if (t === "day")
394
+ return new Date(r, 11, 31);
395
+ }
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) => {
408
+ 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;
417
+ }
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) => {
421
+ 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);
437
+ }
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;
445
+ 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];
450
+ }
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;
457
+ switch (e) {
458
+ case "ArrowRight":
459
+ case "ArrowUp":
460
+ u = h;
461
+ break;
462
+ case "ArrowLeft":
463
+ case "ArrowDown":
464
+ u = -h;
465
+ break;
466
+ case "PageUp":
467
+ u = h * 5;
468
+ break;
469
+ case "PageDown":
470
+ u = -h * 5;
471
+ break;
472
+ case "Home":
473
+ m = !0;
474
+ break;
475
+ case "End":
476
+ p = !0;
477
+ break;
478
+ default:
479
+ return null;
480
+ }
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];
484
+ }
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);
501
+ 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
510
+ };
511
+ };
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";
517
+ }
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";
520
+ }
521
+ function an(e, t, a, r, l) {
522
+ 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"];
525
+ }
526
+ 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"];
529
+ }
530
+ const s = Math.max(0, Math.min(1, t));
531
+ return s < r ? [s, r, "macro-low"] : [r, s, "macro-high"];
532
+ }
533
+ function nn(e, t, a, r, l) {
534
+ 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"];
537
+ }
538
+ 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"];
541
+ }
542
+ const s = Math.max(0, Math.min(1, t));
543
+ return s < r ? [s, r, "micro-low"] : [r, s, "micro-high"];
544
+ }
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" }) });
548
+ });
549
+ Tt.displayName = "VernierKnobSvg";
550
+ const rn = (e) => {
551
+ const {
552
+ unit: t,
553
+ minDate: a,
554
+ maxDate: r,
555
+ allowedDates: l,
556
+ 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(
578
+ (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();
582
+ }
583
+ return Me(t, Math.round(i));
584
+ },
585
+ [I, f, t]
586
+ ), N = K(
587
+ (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);
591
+ },
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(() => {
594
+ if (e.mode === "point") {
595
+ const g = N(j);
596
+ return [g, g];
597
+ }
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);
619
+ }, []);
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)
624
+ 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, _]));
627
+ };
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));
631
+ },
632
+ [oe]
633
+ ), $t = K(
634
+ (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));
640
+ }
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));
645
+ },
646
+ [I, s, f, v, M]
647
+ ), At = K(
648
+ (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);
654
+ }
655
+ const D = Math.round(c / 100 * (f.length - 1));
656
+ return Math.max(0, Math.min(f.length - 1, D));
657
+ }
658
+ const g = v + c / 100 * (M - v);
659
+ return Math.round(g);
660
+ },
661
+ [I, s, f, v, M, t]
662
+ ), He = Q(null), [Aa, ra] = De(0), oa = Aa;
663
+ ot(() => {
664
+ const i = He.current;
665
+ 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);
669
+ };
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 : _);
675
+ }
676
+ });
677
+ return g.observe(i), () => g.disconnect();
678
+ }
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));
689
+ },
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(
695
+ (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();
711
+ } else {
712
+ const Ke = Math.round(Te + wt * ht), Je = Math.round(Te + Dt * ht);
713
+ ge = Me(U, Ke), Ce = Me(U, Je);
714
+ }
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);
727
+ } else {
728
+ const tt = Math.round((ge.getTime() - $.startMacroLowDate.getTime()) / 864e5);
729
+ et = Le("day", $.initialMicroLowDate, tt), ut = Le("day", $.initialMicroHighDate, tt);
730
+ }
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));
734
+ } 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));
737
+ }
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();
747
+ } else {
748
+ const Pe = Math.round(he + wt * bt), Xe = Math.round(he + Dt * bt);
749
+ ge = Me(E, Pe), Ce = Me(E, Xe);
750
+ }
751
+ const xt = `${ge.getTime()}_${Ce.getTime()}`;
752
+ xt !== Mt.current && (Mt.current = xt, Qe.onChangeRange?.(ge, Ce), Qe.onChangeRangeTuple?.([ge, Ce]));
753
+ }
754
+ return;
755
+ }
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
+ }
767
+ return;
768
+ }
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($));
773
+ }
774
+ },
775
+ [
776
+ d,
777
+ 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
797
+ ]
798
+ ), sa = K(
799
+ (i) => {
800
+ if (o) {
801
+ Ut.current = null, Mt.current = null, Ot.current = null, at.current = null, Rt(null);
802
+ return;
803
+ }
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);
808
+ },
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);
820
+ };
821
+ }, [da]);
822
+ const zt = K(
823
+ (i, c, g) => {
824
+ St.current = {
825
+ pointerId: i,
826
+ handle: c,
827
+ startPointerPos: g,
828
+ startLowVal: ne,
829
+ startHighVal: ce
830
+ }, Ee.current = c, je(c), c !== "connect" && S(c);
831
+ },
832
+ [ne, ce]
833
+ ), ma = K(
834
+ (i, c, g) => {
835
+ const D = B.current;
836
+ Ot.current = {
837
+ pointerId: i,
838
+ handle: c,
839
+ startPointerRatio: g,
840
+ startMacroLowRatio: ve,
841
+ startMacroHighRatio: Se,
842
+ startMicroLowRatio: Oe,
843
+ startMicroHighRatio: nt,
844
+ 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);
853
+ },
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;
866
+ 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);
875
+ return;
876
+ }
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";
882
+ }
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) {
904
+ case "ArrowRight":
905
+ case "ArrowUp":
906
+ g = 1;
907
+ break;
908
+ case "ArrowLeft":
909
+ case "ArrowDown":
910
+ g = -1;
911
+ break;
912
+ case "PageUp":
913
+ g = 5;
914
+ break;
915
+ case "PageDown":
916
+ g = -5;
917
+ break;
918
+ case "Home":
919
+ D = !0;
920
+ break;
921
+ case "End":
922
+ C = !0;
923
+ break;
924
+ default:
925
+ return;
926
+ }
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
+ };
933
+ 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));
936
+ } 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));
939
+ } 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));
942
+ } 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));
945
+ }
946
+ }, ha = K(
947
+ (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
+ }
960
+ } 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));
964
+ }
965
+ },
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 ? {
980
+ "--ps-tooltip-origin": "100% 50%",
981
+ "--ps-tooltip-tx": "0px",
982
+ "--ps-tooltip-ty": "-50%",
983
+ "--ps-tooltip-rot": "0deg"
984
+ } : {
985
+ "--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 ? {
990
+ "--ps-tooltip-origin": "100% 50%",
991
+ "--ps-tooltip-tx": "0px",
992
+ "--ps-tooltip-ty": "-50%",
993
+ "--ps-tooltip-rot": "0deg"
994
+ } : {
995
+ "--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}%`,
1002
+ top: "auto",
1003
+ left: "0",
1004
+ right: "0"
1005
+ } : {
1006
+ left: `${It}%`,
1007
+ width: `${ba - It}%`,
1008
+ top: "0",
1009
+ 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";
1011
+ return /* @__PURE__ */ le(
1012
+ "div",
1013
+ {
1014
+ 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,
1017
+ "data-unit": t,
1018
+ "data-mode": e.mode,
1019
+ "data-orientation": n ? "vertical" : "horizontal",
1020
+ "data-label-position": p,
1021
+ "data-color-scheme": z,
1022
+ 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(
1035
+ "div",
1036
+ {
1037
+ ref: He,
1038
+ "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 })
1050
+ ] }) }),
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})` })
1052
+ ] }) : /* @__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 })
1056
+ ] }) }),
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})` })
1058
+ ] })),
1059
+ /* @__PURE__ */ T(
1060
+ "div",
1061
+ {
1062
+ "data-testid": "period-slider-connect-macro",
1063
+ className: "period-slider-connect-macro",
1064
+ style: n ? {
1065
+ bottom: `calc(${ve * 100}% - 8px)`,
1066
+ height: `calc(${Math.max(0, (Se - ve) * 100)}% + 16px)`
1067
+ } : {
1068
+ left: `calc(${ve * 100}% - 8px)`,
1069
+ width: `calc(${Math.max(0, (Se - ve) * 100)}% + 16px)`
1070
+ },
1071
+ onPointerDown: lt("macro-connect")
1072
+ }
1073
+ ),
1074
+ /* @__PURE__ */ T(
1075
+ "div",
1076
+ {
1077
+ "data-testid": "period-slider-connect-micro",
1078
+ className: "period-slider-connect-micro",
1079
+ style: n ? {
1080
+ bottom: `calc(${Oe * 100}% - 8px)`,
1081
+ height: `calc(${Math.max(0, (nt - Oe) * 100)}% + 16px)`
1082
+ } : {
1083
+ left: `calc(${Oe * 100}% - 8px)`,
1084
+ width: `calc(${Math.max(0, (nt - Oe) * 100)}% + 16px)`
1085
+ },
1086
+ onPointerDown: lt("micro-connect")
1087
+ }
1088
+ ),
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}`))
1092
+ ] }),
1093
+ /* @__PURE__ */ le(
1094
+ "div",
1095
+ {
1096
+ tabIndex: d ? -1 : 0,
1097
+ role: "slider",
1098
+ "aria-label": e.macroLowerAriaLabel ?? "マクロ開始時期",
1099
+ "aria-disabled": d ? "true" : void 0,
1100
+ "aria-valuemin": Te,
1101
+ "aria-valuemax": Ge,
1102
+ "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
1112
+ } : {
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
1118
+ },
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",
1124
+ "data-handle-type": "macro-low",
1125
+ 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) })
1129
+ ]
1130
+ }
1131
+ ),
1132
+ /* @__PURE__ */ le(
1133
+ "div",
1134
+ {
1135
+ tabIndex: d ? -1 : 0,
1136
+ role: "slider",
1137
+ "aria-label": e.macroUpperAriaLabel ?? "マクロ終了時期",
1138
+ "aria-disabled": d ? "true" : void 0,
1139
+ "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
1151
+ } : {
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
1157
+ },
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",
1163
+ "data-handle-type": "macro-high",
1164
+ 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) })
1168
+ ]
1169
+ }
1170
+ ),
1171
+ /* @__PURE__ */ le(
1172
+ "div",
1173
+ {
1174
+ tabIndex: d ? -1 : 0,
1175
+ 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
1190
+ } : {
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
1196
+ },
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",
1202
+ "data-handle-type": "micro-low",
1203
+ 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) })
1207
+ ]
1208
+ }
1209
+ ),
1210
+ /* @__PURE__ */ le(
1211
+ "div",
1212
+ {
1213
+ tabIndex: d ? -1 : 0,
1214
+ 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
1229
+ } : {
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
1235
+ },
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",
1241
+ "data-handle-type": "micro-high",
1242
+ 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) })
1246
+ ]
1247
+ }
1248
+ )
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}`);
1254
+ }) }),
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(
1258
+ "div",
1259
+ {
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)
1262
+ }
1263
+ )
1264
+ ] }),
1265
+ /* @__PURE__ */ le(
1266
+ "div",
1267
+ {
1268
+ tabIndex: d ? -1 : 0,
1269
+ 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,
1283
+ 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(
1286
+ "div",
1287
+ {
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)
1295
+ }
1296
+ )
1297
+ ]
1298
+ }
1299
+ ),
1300
+ !x && /* @__PURE__ */ le(
1301
+ "div",
1302
+ {
1303
+ tabIndex: d ? -1 : 0,
1304
+ 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,
1318
+ 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(
1321
+ "div",
1322
+ {
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)
1330
+ }
1331
+ )
1332
+ ]
1333
+ }
1334
+ )
1335
+ ] })
1336
+ }
1337
+ ),
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
+ )
1349
+ ]
1350
+ }
1351
+ );
1352
+ }, Gt = (e, t) => {
1353
+ if (e === t) return !0;
1354
+ 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;
1357
+ return !0;
1358
+ }, on = (e, t) => {
1359
+ if (e === t) return !0;
1360
+ 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;
1365
+ 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;
1388
+ }
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);
1417
+ },
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(
1423
+ () => ({
1424
+ value: n[0],
1425
+ onChange: B,
1426
+ minDate: l,
1427
+ maxDate: n[1],
1428
+ unit: t
1429
+ }),
1430
+ [n[0], n[1], B, l, t]
1431
+ ), x = R(
1432
+ () => ({
1433
+ value: n[1],
1434
+ onChange: V,
1435
+ minDate: n[0],
1436
+ maxDate: s,
1437
+ unit: t
1438
+ }),
1439
+ [n[0], n[1], V, s, t]
1440
+ ), oe = R(
1441
+ () => ({
1442
+ ...m,
1443
+ mode: "range",
1444
+ unit: t,
1445
+ range: n,
1446
+ minDate: l,
1447
+ maxDate: s,
1448
+ onChangeRange: O,
1449
+ onChangeRangeTuple: f,
1450
+ onChange: f
1451
+ }),
1452
+ [m, t, n, l, s, O, f]
1453
+ );
1454
+ 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
1466
+ };
1467
+ }
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);
1483
+ },
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(
1489
+ () => ({
1490
+ value: b,
1491
+ onChange: V,
1492
+ minDate: s,
1493
+ maxDate: d,
1494
+ unit: t
1495
+ }),
1496
+ [b, V, s, d, t]
1497
+ ), v = R(
1498
+ () => ({
1499
+ ...p,
1500
+ mode: "point",
1501
+ unit: t,
1502
+ value: b,
1503
+ minDate: s,
1504
+ maxDate: d,
1505
+ onChangePoint: V,
1506
+ onChangeValue: V,
1507
+ onChange: V
1508
+ }),
1509
+ [p, t, b, s, d, V]
1510
+ );
1511
+ return {
1512
+ value: b,
1513
+ setValue: W,
1514
+ shiftValue: O,
1515
+ resetValue: f,
1516
+ selectorProps: I,
1517
+ sliderProps: v
1518
+ };
1519
+ }
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]);
1547
+ },
1548
+ [p, A, n]
1549
+ ), j = K(
1550
+ (L) => {
1551
+ k(L[0], L[1]);
1552
+ },
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]);
1557
+ },
1558
+ [b, W, z, P, F]
1559
+ ), fe = K(
1560
+ (L) => {
1561
+ q(L[0], L[1]);
1562
+ },
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);
1568
+ },
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);
1574
+ },
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);
1580
+ },
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);
1586
+ },
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(
1604
+ () => ({
1605
+ value: v[0],
1606
+ onChange: me,
1607
+ minDate: t,
1608
+ maxDate: v[1],
1609
+ unit: u
1610
+ }),
1611
+ [v, me, t, u]
1612
+ ), Re = R(
1613
+ () => ({
1614
+ value: v[1],
1615
+ onChange: se,
1616
+ minDate: v[0],
1617
+ maxDate: a,
1618
+ unit: u
1619
+ }),
1620
+ [v, se, a, u]
1621
+ ), we = R(
1622
+ () => ({
1623
+ value: x[0],
1624
+ onChange: ee,
1625
+ minDate: v[0],
1626
+ maxDate: x[1],
1627
+ unit: m
1628
+ }),
1629
+ [x, ee, v, m]
1630
+ ), je = R(
1631
+ () => ({
1632
+ value: x[1],
1633
+ onChange: X,
1634
+ minDate: x[0],
1635
+ maxDate: v[1],
1636
+ unit: m
1637
+ }),
1638
+ [x, X, v, m]
1639
+ ), Ee = R(
1640
+ () => ({
1641
+ ...B,
1642
+ 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
1658
+ }),
1659
+ [B, h, u, m, t, a, v, x, k, j, q, fe]
1660
+ );
1661
+ 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
1678
+ };
1679
+ }
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(
1705
+ "button",
1706
+ {
1707
+ type: "button",
1708
+ "aria-label": n,
1709
+ disabled: oe,
1710
+ 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" })
1713
+ }
1714
+ ),
1715
+ /* @__PURE__ */ T(
1716
+ "select",
1717
+ {
1718
+ "aria-label": W,
1719
+ disabled: A,
1720
+ 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));
1724
+ },
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))
1726
+ }
1727
+ ),
1728
+ /* @__PURE__ */ T(
1729
+ "button",
1730
+ {
1731
+ type: "button",
1732
+ "aria-label": b,
1733
+ disabled: N,
1734
+ 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" })
1737
+ }
1738
+ ),
1739
+ l
1740
+ ] });
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);
1744
+ });
1745
+ un.displayName = "YearSelector";
1746
+ 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
1770
+ };