@aiquants/period-slider 0.6.0 → 0.7.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/README.md CHANGED
@@ -42,8 +42,8 @@
42
42
  - レンジドラッグ中につまみが相手側アンカーを超えて上限と下限が入れ替わった際、現在ポインターで操作している側のつまみへアクティブ状態 (`[data-active="true"]`、スケール縮小+ブルーグロー・波紋) がリアルタイムに自動スワップ。
43
43
  - **充実した日付セレクタ**:
44
44
  - `YearSelector`: ドロップダウンと ◀▶ ステッパーで年を選択。
45
- - `MonthSelector`: カレンダー入力 (`variant="date"`, 既定) / ドロップダウン (`variant="dropdown"`) 対応の月セレクタ。
46
- - `DateSelector`: 日付入力 (`variant="date"`, 既定)、単一セレクトボックス (`variant="dropdown"`)、年月日の 3 分割セレクト (`variant="split-dropdown"`) に対応。
45
+ - `MonthSelector`: カレンダー入力 (`variant="date"`, 既定) / ドロップダウン (`variant="dropdown"`) 対応の月セレクタ。連続した境界のほか、実データに存在する月だけを選ばせる離散集合 (`allowedMonths`) に対応。
46
+ - `DateSelector`: 日付入力 (`variant="date"`, 既定)、単一セレクトボックス (`variant="dropdown"`)、年月日の 3 分割セレクト (`variant="split-dropdown"`) に対応。離散集合 (`allowedDates`) にも対応。
47
47
  - **カラーテーマ・メリハリ対比 & ダークモード**:
48
48
  - `colorScheme`: 6 系統のカラーパレット (`"blue-rose"` [既定], `"indigo-amber"`, `"teal-emerald"`, `"violet-fuchsia"`, `"slate-sky"`, `"monochrome"`) をサポート。
49
49
  - ノギス 2 段スケールにおける広域マクロ (青系) と確定ミクロ (赤系) の明確なメリハリ対比、および境界を結ぶ台形プロジェクション光の動的 2 色グラデーション。
@@ -505,7 +505,8 @@ DOM 要素の特定は CSS クラス名ではなく `data-*` 属性で行いま
505
505
  | `DateSelector` | 同上 | `RangeError: DateSelector: "locale" must be a valid BCP 47 language tag (received ...)` |
506
506
  | `MonthSelector` / `YearSelector` | 同上 | ``RangeError: <コンポーネント名>: `locale` must be a valid BCP 47 language tag, received ....`` |
507
507
  | `YearSelector` / `MonthSelector` / `DateSelector` | `value` と `initialDate` が共に未指定 | `RangeError: <コンポーネント名>: either \`value\` (controlled) or \`initialDate\` (uncontrolled) is required; ...` |
508
- | `YearSelector` / `MonthSelector` | 境界の欠落・矛盾、境界外の選択値、Date / 年 Props の不正値 | `RangeError` |
508
+ | `YearSelector` | 境界の欠落・矛盾、Date / 年 Props の不正値 | `RangeError` |
509
+ | `MonthSelector` | 境界の矛盾、`allowedMonths` を伴わない `variant="dropdown"` での境界の欠落、`allowedMonths` の要素が Invalid Date (添字付きで報告)、Date / 年 Props の不正値 | ``RangeError: MonthSelector: `allowedMonths[1]` must be a valid Date, received ....`` 等 |
509
510
  | `DateSelector` | Date / 年 Props の不正値、解決後の範囲が空、バリアントが要求する境界の欠落、`variant="split-dropdown"` への `allowedDates` 指定 | `RangeError` |
510
511
 
511
512
  `DateSelector` は構成そのものの矛盾を優先して報告します。`variant="split-dropdown"` と `allowedDates` の併用は、`value` / `initialDate` の欠落よりも先に判定されます。
@@ -707,7 +708,7 @@ export function SelectorsExample() {
707
708
  | `locale` | `string` | `undefined` | 選択肢テキストのロケール (BCP 47 言語タグ)。未指定は 4 桁ゼロ埋めの年、指定時は `Intl.DateTimeFormat` 書式。空文字列・不正タグ・非文字列は `RangeError` |
708
709
  | `unit` | `"year" \| "month" \| "day"` | `undefined` | **不活性 Props**。フックの `SelectorProps` をスプレッドするための受け口で、描画・挙動には一切影響しない |
709
710
 
710
- 下限 (`minYear` または `minDate`) と上限 (`maxYear` または `maxDate`) は共に必須です。選択年が境界外の場合、境界に丸めるのではなく `RangeError` を送出します。
711
+ 下限 (`minYear` または `minDate`) と上限 (`maxYear` または `maxDate`) は共に必須です。境界外の年を保持している間は、境界へ丸めず・`RangeError` も送出せず、その年を選択肢へ 1 件加えてそのまま表示します。このときステッパーは境界へ戻る側だけが有効で、境界外の年が `onChange` へ渡ることはありません。
711
712
 
712
713
  #### `MonthSelector` Props
713
714
 
@@ -718,11 +719,12 @@ export function SelectorsExample() {
718
719
  | `value` | `Date` | `undefined` | 制御時の選択日付 (年月のみ使用)。`initialDate` 未指定時は必須 |
719
720
  | `initialDate` | `Date` | `undefined` | 非制御時の初期選択日付 (年月のみ使用)。`value` 未指定時は必須。`value` 指定時は無視 |
720
721
  | `variant` | `"date" \| "dropdown"` | `"date"` | `"date"`: `<input type="month">`、`"dropdown"`: `YYYY-MM` の `<select>` |
722
+ | `allowedMonths` | `Date[]` | `undefined` | 選択可能な離散月配列。各要素は月頭に切り捨てられ (日の部分は無視)、月単位で重複排除・境界で絞り込まれる。空配列は「選択可能月なし」を意味する。参照比較で再描画を判定するため、利用側でメモ化する |
721
723
  | `minYear` | `number` | `undefined` | 選択可能な最小年 (その年の 1 月)。`minDate` と併用時は厳しい方を採用 |
722
724
  | `maxYear` | `number` | `undefined` | 選択可能な最大年 (その年の 12 月)。`maxDate` と併用時は厳しい方を採用 |
723
725
  | `minDate` | `Date` | `undefined` | 選択可能な最小日付 (月頭に切り捨て)。`minYear` と併用時は厳しい方を採用 |
724
726
  | `maxDate` | `Date` | `undefined` | 選択可能な最大日付 (月頭に切り捨て)。`maxYear` と併用時は厳しい方を採用 |
725
- | `onChange` | `(date: Date, yyyymm: number) => void` | `undefined` | 月変更時コールバック。`date` は該当月 1 日ローカル 0 時、`yyyymm` は `年 * 100 + 月` の整数 |
727
+ | `onChange` | `(date: Date, yyyymm: number) => void` | `undefined` | 選択可能な月が選ばれた時のコールバック。`date` は該当月 1 日ローカル 0 時、`yyyymm` は `年 * 100 + 月` の整数 |
726
728
  | `isWarning` | `boolean` | `false` | 警告枠スタイル (アンバー) の適用フラグ。`variant` を問わず有効 |
727
729
  | `disabled` | `boolean` | `false` | 無効化フラグ。`true` の間は `onChange` を発火しない |
728
730
  | `className` | `string` | `""` | ルート要素の追加 CSS クラス |
@@ -734,7 +736,23 @@ export function SelectorsExample() {
734
736
  | `locale` | `string` | `undefined` | 選択肢テキストのロケール (BCP 47 言語タグ)。未指定は ISO 8601 の `YYYY-MM`、指定時は `Intl.DateTimeFormat` 書式。`<input type="month">` および `<option value>` は常に `yyyy-MM`。空文字列・不正タグ・非文字列は `RangeError` |
735
737
  | `unit` | `"year" \| "month" \| "day"` | `undefined` | **不活性 Props**。フックの `SelectorProps` をスプレッドするための受け口で、描画・挙動には一切影響しない |
736
738
 
737
- `variant="dropdown"` は選択肢生成のため下限と上限の双方が必須です (`variant="date"` では任意)。境界外の直接入力は丸められず破棄され、`onChange` は発火しません。
739
+ 境界要件と挙動:
740
+
741
+ - 選択可能集合は `allowedMonths` (離散) または [`minDate` / `minYear`, `maxDate` / `maxYear`] (連続) が決定します。両方を指定した場合は積 (境界内の許容月のみ) になります。
742
+ - `variant="dropdown"`: `allowedMonths` を指定しない場合、下限と上限の双方が必須です。`allowedMonths` を指定した場合は境界を省略でき、選択肢は許容月だけを降順に並べます (存在しない月を選択肢に挟みません)。
743
+ - `variant="date"`: 境界は任意です。指定した場合は `<input type="month">` の `min` / `max` 属性へ反映されます (`allowedMonths` の最古 / 最新は `min` / `max` に写しません — 宣言した境界だけが属性になります)。
744
+ - ステッパーは連続指定時に ±1 ヶ月、離散指定時に隣接する許容月へ移動し (四半期おきの集合なら 3 ヶ月飛ぶ)、集合の端では `disabled` になります。
745
+ - 選択可能集合外の直接入力 (`input` / `select` の `change`) は丸められず破棄され、`onChange` は発火しません。
746
+ - 境界外・集合外の `value` / `initialDate` は `RangeError` になりません (集合外の表示は下記 DOM 契約の責務です)。
747
+
748
+ DOM 契約: 現在値が選択可能集合の外にある場合、ルート要素に `data-out-of-range="true"` が付与されます。`variant="dropdown"` ではさらに `<select>` の先頭に現在値を表示する選択不可のプレースホルダ `<option value="">` が描画され (このとき `select.value === ""`)、`variant="date"` では `<input type="month">` が保持値をそのまま表示します。
749
+
750
+ ```tsx
751
+ // データに存在する基準年月 (四半期の開始月) だけを選ばせる
752
+ const allowedMonths = useMemo(() => baseMonths.map((yyyymm) => new Date(Math.trunc(yyyymm / 100), (yyyymm % 100) - 1, 1)), [baseMonths])
753
+
754
+ <MonthSelector variant="dropdown" value={currentMonth} allowedMonths={allowedMonths} selectAriaLabel="基準年月" onChange={(_date, yyyymm) => jumpTo(yyyymm)} />
755
+ ```
738
756
 
739
757
  #### `DateSelector` Props
740
758
 
@@ -15,7 +15,7 @@ export interface MonthSelectorProps {
15
15
  value?: Date;
16
16
  /** Initial selected date; required unless `value` is supplied / 選択日付(非制御用・`value` 未指定時は必須) */
17
17
  initialDate?: Date;
18
- /** Callback triggered when month changes / 月変更時コールバック */
18
+ /** Callback triggered when a selectable month is chosen / 選択可能な月が選ばれた時のコールバック */
19
19
  onChange?(date: Date, yyyymm: number): void;
20
20
  /** Child elements / 子要素 */
21
21
  children?: React.ReactNode;
@@ -24,14 +24,16 @@ export interface MonthSelectorProps {
24
24
  * 表示バリエーション: "date" (input[type="month"]) または "dropdown" (select[yyyy-mm])。既定値 "date"
25
25
  */
26
26
  variant?: "date" | "dropdown";
27
- /** Lower bound year (January); combined with `minDate` as the stricter of the two. Required for variant="dropdown" together with `minDate` / 可能範囲の最小年 (1 月起点)。`minDate` とは厳しい方を採用。variant="dropdown" では `minDate` との少なくとも一方が必須 */
27
+ /** Lower bound year (January); combined with `minDate` as the stricter of the two. variant="dropdown" without `allowedMonths` requires this or `minDate` / 可能範囲の最小年 (1 月起点)。`minDate` とは厳しい方を採用。`allowedMonths` 無しの variant="dropdown" では `minDate` との少なくとも一方が必須 */
28
28
  minYear?: number;
29
- /** Upper bound year (December); combined with `maxDate` as the stricter of the two. Required for variant="dropdown" together with `maxDate` / 可能範囲の最大年 (12 月起点)。`maxDate` とは厳しい方を採用。variant="dropdown" では `maxDate` との少なくとも一方が必須 */
29
+ /** Upper bound year (December); combined with `maxDate` as the stricter of the two. variant="dropdown" without `allowedMonths` requires this or `maxDate` / 可能範囲の最大年 (12 月起点)。`maxDate` とは厳しい方を採用。`allowedMonths` 無しの variant="dropdown" では `maxDate` との少なくとも一方が必須 */
30
30
  maxYear?: number;
31
31
  /** Lower bound date (truncated to its month); combined with `minYear` as the stricter of the two / 可能範囲の最小日付 (月単位に切り捨て)。`minYear` とは厳しい方を採用 */
32
32
  minDate?: Date;
33
33
  /** Upper bound date (truncated to its month); combined with `maxYear` as the stricter of the two / 可能範囲の最大日付 (月単位に切り捨て)。`maxYear` とは厳しい方を採用 */
34
34
  maxDate?: Date;
35
+ /** Discrete allowed months (day part ignored), intersected with the bounds; an empty array means nothing is selectable / 選択可能な離散月配列 (日は無視・境界と積を取る・空配列は「選択可能月なし」) */
36
+ allowedMonths?: Date[];
35
37
  /** Warning style flag / 警告枠スタイル適用フラグ */
36
38
  isWarning?: boolean;
37
39
  /** Additional CSS class name / 追加の CSS クラス名 */
@@ -51,7 +53,8 @@ export interface MonthSelectorProps {
51
53
  }
52
54
  /**
53
55
  * Month-resolution selector re-rendering only when a prop its output depends on changes.
54
- * 描画結果が依存する Props の変化時のみ再描画する月単位セレクタ。
56
+ * `allowedMonths` is compared by reference, so consumers memoize the array.
57
+ * 描画結果が依存する Props の変化時のみ再描画する月単位セレクタ。`allowedMonths` は参照比較のため利用側でメモ化。
55
58
  */
56
59
  export declare const MonthSelector: React.MemoExoticComponent<(props: MonthSelectorProps) => React.JSX.Element>;
57
60
  //# sourceMappingURL=MonthSelector.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MonthSelector.d.ts","sourceRoot":"","sources":["../src/MonthSelector.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B;;;;;;;;;;GAUG;AACH,MAAM,WAAW,kBAAkB;IAC/B,8GAA8G;IAC9G,KAAK,CAAC,EAAE,IAAI,CAAA;IACZ,8FAA8F;IAC9F,WAAW,CAAC,EAAE,IAAI,CAAA;IAClB,yDAAyD;IACzD,QAAQ,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3C,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,UAAU,CAAA;IAC7B,kOAAkO;IAClO,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,oOAAoO;IACpO,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,+IAA+I;IAC/I,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,+IAA+I;IAC/I,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,wCAAwC;IACxC,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IAC3B,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,wFAAwF;IACxF,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,gFAAgF;IAChF,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,gFAAgF;IAChF,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,oPAAoP;IACpP,MAAM,CAAC,EAAE,MAAM,CAAA;CAClB;AA8UD;;;GAGG;AACH,eAAO,MAAM,aAAa,oCAzLa,kBAAkB,KAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAmN3E,CAAA"}
1
+ {"version":3,"file":"MonthSelector.d.ts","sourceRoot":"","sources":["../src/MonthSelector.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B;;;;;;;;;;GAUG;AACH,MAAM,WAAW,kBAAkB;IAC/B,8GAA8G;IAC9G,KAAK,CAAC,EAAE,IAAI,CAAA;IACZ,8FAA8F;IAC9F,WAAW,CAAC,EAAE,IAAI,CAAA;IAClB,iFAAiF;IACjF,QAAQ,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3C,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,UAAU,CAAA;IAC7B,oQAAoQ;IACpQ,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,sQAAsQ;IACtQ,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,+IAA+I;IAC/I,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,+IAA+I;IAC/I,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,oKAAoK;IACpK,aAAa,CAAC,EAAE,IAAI,EAAE,CAAA;IACtB,wCAAwC;IACxC,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IAC3B,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,wFAAwF;IACxF,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,gFAAgF;IAChF,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,gFAAgF;IAChF,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,oPAAoP;IACpP,MAAM,CAAC,EAAE,MAAM,CAAA;CAClB;AA+YD;;;;GAIG;AACH,eAAO,MAAM,aAAa,oCAhOa,kBAAkB,KAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CA2P3E,CAAA"}
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react/jsx-runtime"),Le=require("date-fns"),o=require("react"),On={"blue-rose":{macro:"#0284c7",macroLight:"#38bdf8",micro:"#e11d48",microLight:"#fb7185",accent:"#0284c7"},"indigo-amber":{macro:"#4f46e5",macroLight:"#818cf8",micro:"#d97706",microLight:"#fbbf24",accent:"#4f46e5"},"teal-emerald":{macro:"#0d9488",macroLight:"#2dd4bf",micro:"#059669",microLight:"#34d399",accent:"#0d9488"},"violet-fuchsia":{macro:"#7c3aed",macroLight:"#a78bfa",micro:"#c026d3",microLight:"#e879f9",accent:"#7c3aed"},"slate-sky":{macro:"#475569",macroLight:"#94a3b8",micro:"#0284c7",microLight:"#38bdf8",accent:"#475569"},monochrome:{macro:"#52525b",macroLight:"#a1a1aa",micro:"#18181b",microLight:"#71717a",accent:"#27272a"}},it=e=>e instanceof Date&&!Number.isNaN(e.getTime()),he=e=>e instanceof Date?Number.isNaN(e.getTime())?"Invalid Date":e.toISOString():String(e),qe=(e,t)=>{if(!it(t))throw new RangeError(`normalizeDateByUnit: d must be a valid Date (received: ${he(t)})`);const r=new Date(t.getTime());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},q=(e,t)=>{const r=qe(e,t),n=r.getFullYear(),a=r.getMonth()+1,s=r.getDate();if(e==="year")return n;if(e==="month")return n*12+(a-1);const i=new Date(0);return i.setUTCFullYear(n,a-1,s),i.setUTCHours(0,0,0,0),Math.floor(i.getTime()/(1440*60*1e3))},oe=(e,t)=>{const r=new Date(0);if(r.setHours(0,0,0,0),e==="year")return r.setFullYear(t,0,1),r;if(e==="month"){const a=Math.floor(t/12),s=t-a*12;return r.setFullYear(a,s,1),r}const n=new Date(t*24*60*60*1e3);return r.setFullYear(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate()),r},Ie=(e,t,r)=>{if(!it(t))throw new RangeError(`addUnit: d must be a valid Date (received: ${he(t)})`);return e==="year"?Le.addYears(t,r):e==="month"?Le.addMonths(t,r):Le.addDays(t,r)},ot=(e,t,r)=>{if(!it(r))throw new RangeError(`getMacroWindowEndDate: d must be a valid Date (received: ${he(r)})`);if(e===t)return qe(t,r);const n=r.getFullYear(),a=r.getMonth();if(e==="year"){if(t==="month")return new Date(n,11,1);if(t==="day")return new Date(n,11,31)}return e==="month"&&t==="day"?new Date(n,a+1,0):qe(t,r)},ka={year:{year:"numeric"},month:{year:"numeric",month:"2-digit"},day:{year:"numeric",month:"2-digit",day:"2-digit"}},kn=new Map,Pa=(e,t)=>{const r=`${e}\0${t}`,n=kn.get(r);if(n!==void 0)return n;const a=new Intl.DateTimeFormat(t,ka[e]);return kn.set(r,a),a},Ca=(e,t)=>{const r=String(t.getFullYear()).padStart(4,"0");if(e==="year")return r;const n=String(t.getMonth()+1).padStart(2,"0");if(e==="month")return`${r}-${n}`;const a=String(t.getDate()).padStart(2,"0");return`${r}-${n}-${a}`},Oe=(e,t,r,n)=>it(t)?r?r(t):n===void 0?Ca(e,t):Pa(e,n).format(t):"",vt=(e,t,r,n)=>Oe(e,t,r,n),De=(e,t,r)=>{if(!e||e.length===0||e.length===1)return 0;const n=q(r,t);let a=0,s=e.length-1;if(n<=q(r,e[a]))return 0;if(n>=q(r,e[s]))return s;for(;a<=s;){const b=a+s>>1,f=q(r,e[b]);if(f===n)return b;f<n?a=b+1:s=b-1}const i=Math.abs(q(r,e[a])-n),u=Math.abs(q(r,e[s])-n);return i<u?a:s},Vt=(e,t,r,n)=>{if(!Array.isArray(e)||e.length===0)return[];const a=q(t,r),s=q(t,n),i=new Map;for(const u of e){const b=qe(t,u),f=q(t,b);f<a||f>s||i.has(f)||i.set(f,b)}if(i.size===0)throw new RangeError(`getSortedAllowedDates: every allowedDates entry falls outside [minDate, maxDate] (minDate: ${he(r)}, maxDate: ${he(n)}, entries: ${e.length})`);return Array.from(i.keys()).sort((u,b)=>u-b).map(u=>i.get(u))},yr=(e,t,r,n)=>{const a=e.length-1;if(a<=0)return 0;const s=De(e,n,t);if(r==="time"){const i=e[0].getTime(),u=e[a].getTime()-i;return u<=0?0:Math.max(0,Math.min(1,(e[s].getTime()-i)/u))}return s/a},Tr=(e,t,r,n)=>{const a=e.length-1;if(a<=0)return 0;const s=Math.max(0,Math.min(1,n));if(r==="time"){const i=e[0].getTime(),u=e[a].getTime()-i;return u<=0?0:De(e,new Date(i+s*u),t)}return Math.max(0,Math.min(a,Math.round(s*a)))},qr=(e,t,r,n,a,s,i)=>{let u=r,b=n;return i?(u=t,b=t):e==="low"?t>n?(u=n,b=t):u=t:t<r?(b=r,u=t):b=t,[Math.max(a,Math.min(s,u)),Math.max(a,Math.min(s,b))]},Fn=(e,t,r,n,a)=>a?"low":e==="low"?t>n?"high":"low":t<r?"low":"high",Vn=({posDiffPct:e,startLowVal:t,startHighVal:r,rangeMin:n,rangeMax:a,isDiscrete:s,sortedAllowedDates:i,snapMode:u,unit:b})=>{if(s){const V=i.length-1;if(V<=0)return[0,0];const ee=Math.max(0,Math.min(V,Math.round(t))),p=Math.max(ee,Math.min(V,Math.round(r)));if(u==="time"){const Y=i[0].getTime(),U=i[V].getTime(),L=i[ee].getTime(),_=i[p].getTime()-L;let H=L+e*(U-Y),w=H+_;H<Y&&(H=Y,w=Y+_),w>U&&(w=U,H=U-_);const $=De(i,new Date(H),b),N=De(i,new Date(w),b);return[$,Math.max($,N)]}const J=Math.round(e*V);let I=ee+J,te=p+J;return I<0&&(te+=-I,I=0),te>V&&(I-=te-V,te=V),[Math.max(0,Math.min(V,I)),Math.max(0,Math.min(V,te))]}const f=V=>Math.max(n,Math.min(a,V)),P=a-n;if(P<=0)return[f(t),f(r)];const y=Math.round(e*P);let d=t+y,v=r+y;return d<n&&(v+=n-d,d=n),v>a&&(d-=v-a,v=a),[f(d),f(v)]},Un=(e,t,r,n,a,s,i,u)=>{let b=0,f=!1,P=!1;switch(e){case"ArrowRight":case"ArrowUp":b=u;break;case"ArrowLeft":case"ArrowDown":b=-u;break;case"PageUp":b=u*5;break;case"PageDown":b=-u*5;break;case"Home":f=!0;break;case"End":P=!0;break;default:return null}if(i){let v=r;return f?v=a:P?v=s:v=Math.max(a,Math.min(s,r+b)),[v,v]}let y=r,d=n;return t==="low"?f?y=a:P?y=n:y=Math.max(a,Math.min(n,r+b)):f?d=r:P?d=s:d=Math.max(r,Math.min(s,n+b)),[y,d]},Bn=8,zn=2,_n=16,Na=12,Ya=90,Zr=(e,t)=>{const r=t?.estimatedHeightPx??_n,a=Bn+(t?.anchorGapY??zn)+r/2,s=e==="top"?-a:a;return{lowAngleDeg:0,highAngleDeg:0,lowOffsetX:0,highOffsetX:0,lowOffsetY:s,highOffsetY:s,isSlanted:!1,proximity:0}},Qr=(e,t,r,n="top",a)=>{const s=a?.estimatedWidthPx,i=a?.estimatedHeightPx??_n,u=a?.paddingPx??Na,b=a?.maxAngleDeg??Ya,f=Bn+(a?.anchorGapY??zn),P=Zr(n,a);if(!(Number.isFinite(r)&&r>0)||s===void 0||!Number.isFinite(s)||s<=0)return P;const y=Math.max(0,t-e)/100*r,d=s+u;if(y>=d)return P;const v=Math.max(0,Math.min(1,(d-y)/d)),ee=v*v*v*(v*(v*6-15)+10)*b,p=n==="top"?-ee:ee,J=ee*Math.PI/180,I=s/2*Math.abs(Math.sin(J))+i/2*Math.abs(Math.cos(J)),te=f+I,Y=n==="top"?-te:+te,U=s*Math.abs(Math.cos(J))+i*Math.abs(Math.sin(J)),L=Math.max(0,(U+u-y)/2);return{lowAngleDeg:p,highAngleDeg:p,lowOffsetX:-L,highOffsetX:L,lowOffsetY:Y,highOffsetY:Y,isSlanted:v>.001,proximity:v}},Xn=e=>({...e,lowOffsetX:0,highOffsetX:0});function qn(e,t,r,n,a,s,i="macro-top",u=.05,b=!0){const f=i==="macro-top"||i==="macro-left",P=t<=0;if(f&&P||!(f||P)){const v=Math.abs(e-r),V=Math.abs(e-n);return v<=u&&v<=V?"macro-low":V<=u&&V<v?"macro-high":b&&e>=r&&e<=n?"macro-connect":v<V?"macro-low":"macro-high"}const y=Math.abs(e-a),d=Math.abs(e-s);return y<=u&&y<=d?"micro-low":d<=u&&d<y?"micro-high":b&&e>=a&&e<=s?"micro-connect":y<d?"micro-low":"micro-high"}function Kn(e,t,r,n,a){if(e==="macro-connect"){const i=t-r,u=a-n,b=Math.max(0,Math.min(1-u,n+i)),f=b+u;return[b,f,"macro-connect"]}if(e==="macro-low"){const i=Math.max(0,Math.min(1,t));return i>a?[a,i,"macro-high"]:[i,a,"macro-low"]}const s=Math.max(0,Math.min(1,t));return s<n?[s,n,"macro-low"]:[n,s,"macro-high"]}function Wn(e,t,r,n,a){if(e==="micro-connect"){const i=t-r,u=a-n,b=Math.max(0,Math.min(1-u,n+i)),f=b+u;return[b,f,"micro-connect"]}if(e==="micro-low"){const i=Math.max(0,Math.min(1,t));return i>a?[a,i,"micro-high"]:[i,a,"micro-low"]}const s=Math.max(0,Math.min(1,t));return s<n?[s,n,"micro-low"]:[n,s,"micro-high"]}const er=o.memo(({type:e,isTop:t=!0,isVertical:r=!1,isLeft:n=!0})=>{let a,s;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"}`);const i=e==="macro"?"period-slider-knob-path-macro":"period-slider-knob-path-micro";return g.jsx("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:g.jsx("path",{d:a,className:i,shapeRendering:"geometricPrecision",strokeWidth:"1.25"})})});er.displayName="VernierKnobSvg";const Aa=(e,t)=>{if(!it(e))throw new RangeError(`PeriodSlider: minDate is required and must be a valid Date (received: ${he(e)})`);if(!it(t))throw new RangeError(`PeriodSlider: maxDate is required and must be a valid Date (received: ${he(t)})`);if(t.getTime()<=e.getTime())throw new RangeError(`PeriodSlider: maxDate must be strictly later than minDate (minDate: ${he(e)}, maxDate: ${he(t)})`)},kr=(e,t)=>{if(!Array.isArray(t)||t.length!==2)throw new RangeError(`PeriodSlider: ${e} is required and must be a [start, end] Date tuple (received: ${he(t)})`);const[r,n]=t;if(!it(r))throw new RangeError(`PeriodSlider: ${e}[0] must be a valid Date (received: ${he(r)})`);if(!it(n))throw new RangeError(`PeriodSlider: ${e}[1] must be a valid Date (received: ${he(n)})`);if(n.getTime()<r.getTime())throw new RangeError(`PeriodSlider: ${e} must not be inverted (start: ${he(r)}, end: ${he(n)})`)},Ea=(e,t)=>{if(!it(t))throw new RangeError(`PeriodSlider: ${e} must be a valid Date (received: ${he(t)})`)},Ur=(e,t,r,n)=>{if(t.getTime()<r.getTime()||t.getTime()>n.getTime())throw new RangeError(`PeriodSlider: ${e} must lie within [minDate, maxDate] (received: ${he(t)}, minDate: ${he(r)}, maxDate: ${he(n)})`)},Ia=(e,t,r)=>{if(e.mode==="range"){for(const n of["range","defaultRange"]){const a=e[n];a!==void 0&&(kr(n,a),Ur(`${n}[0]`,a[0],t,r),Ur(`${n}[1]`,a[1],t,r))}return}if(e.mode==="point")for(const n of["value","defaultValue"]){const a=e[n];a!==void 0&&(Ea(n,a),Ur(n,a,t,r))}},Ha=(e,t,r)=>{if(kr("macroRange",e),t!==void 0)return kr("microRange",t),t;if(r!==void 0)return kr("defaultMicroRange",r),r;throw new RangeError("PeriodSlider: vernier mode requires a micro selection; supply microRange (controlled) or defaultMicroRange (uncontrolled)")},Sr=(e,t,r,n,a,s,i,u)=>{const b=De(e,n,t),f=De(e,a,t);return i?b:u?f:Math.max(b,Math.min(f,De(e,r,t)+s))},Br=e=>{e.timerId!==null&&clearTimeout(e.timerId),e.timerId=null,e.emit=null},ja=(e,t)=>{try{Intl.DateTimeFormat.supportedLocalesOf([t])}catch{throw new RangeError(`PeriodSlider: ${e} must be a valid BCP 47 language tag (received: ${JSON.stringify(t)})`)}},Ot=()=>{const[e,t]=o.useState(null),r=o.useRef(null),n=o.useCallback(a=>{if(r.current?.disconnect(),r.current=null,a===null){t(null);return}if(typeof ResizeObserver>"u")return;const s=new ResizeObserver(i=>{for(const u of i){const b=u.borderBoxSize?.[0];b!==void 0&&t(f=>f!==null&&Math.abs(f.widthPx-b.inlineSize)<.5&&Math.abs(f.heightPx-b.blockSize)<.5?f:{widthPx:b.inlineSize,heightPx:b.blockSize})}});s.observe(a),r.current=s},[]);return o.useEffect(()=>()=>{r.current?.disconnect(),r.current=null},[]),[n,e]},zr=(e,t)=>{if(!(e===null||t===null))return{estimatedWidthPx:Math.max(e.widthPx,t.widthPx),estimatedHeightPx:Math.max(e.heightPx,t.heightPx)}},Pn=(e,t,r)=>({"--ps-tooltip-tx":`calc(-50% + ${e}px)`,"--ps-tooltip-ty":`${t}px`,"--ps-tooltip-rot":`${r}deg`}),Cn=(e,t,r,n,a,s,i)=>{const u=Zr(n,a);if(!i)return{slant:u,lowStyle:void 0,highStyle:void 0};const b=Qr(e*100,t*100,r,n,a),f=s?Xn(b):b;return{slant:f,lowStyle:Pn(f.lowOffsetX,f.lowOffsetY-u.lowOffsetY,f.lowAngleDeg),highStyle:Pn(f.highOffsetX,f.highOffsetY-u.highOffsetY,f.highAngleDeg)}},Oa={horizontal:{decrease:"◀",increase:"▶"},vertical:{decrease:"▼",increase:"▲"}},Fa={horizontal:{decrease:"period-slider-stepper-prev",increase:"period-slider-stepper-next"},vertical:{decrease:"period-slider-stepper-prev period-slider-stepper-down",increase:"period-slider-stepper-next period-slider-stepper-up"}},Va=e=>{const{unit:t,minDate:r,maxDate:n,allowedDates:a,snapMode:s="index",disabled:i=!1,className:u="",showStepper:b=!0,tooltipStyle:f="always",labelPosition:P="top",autoSlantLabels:y=!0,isVertical:d=!1,hideConnectBar:v=!1,showTicks:V=!1,colorScheme:ee="blue-rose",locale:p,decreaseAriaLabel:J="Decrease",increaseAriaLabel:I="Increase"}=e;Aa(r,n),Ia(e,r,n),p!==void 0&&ja("locale",p);const te=e.mode==="vernier"?Ha(e.macroRange,e.microRange,e.defaultMicroRange):null,Y=On[ee],U=o.useId(),L=o.useRef(e);L.current=e;const _=r.getTime(),H=n.getTime(),w=o.useMemo(()=>Vt(a,t,r,n),[a,t,_,H]),$=w.length>0,{rangeMin:N,rangeMax:O}=o.useMemo(()=>$?{rangeMin:0,rangeMax:w.length-1}:{rangeMin:q(t,r),rangeMax:q(t,n)},[$,w,t,_,H]),k=e.mode==="point",re=o.useCallback(l=>{if($){const c=Math.max(0,Math.min(w.length-1,Math.round(l)));return w[c]}return oe(t,Math.round(l))},[$,w,t]),ye=o.useCallback(l=>{if(l===void 0)return N;const c=qe(t,l);return $?De(w,c,t):q(t,c)},[$,w,t,N]),[Z,ne]=o.useState(()=>te),ie=e.mode!=="vernier"?null:e.microRange!==void 0?e.microRange:Z,me=e.mode==="range"?e.range?.[0]??e.defaultRange?.[0]:e.mode==="vernier"?ie?.[0]:void 0,W=e.mode==="range"?e.range?.[1]??e.defaultRange?.[1]:e.mode==="vernier"?ie?.[1]:void 0,K=e.mode==="point"?e.value??e.defaultValue:void 0,ke=e.mode==="point"?K?.getTime():me?.getTime(),bt=e.mode==="range"?W?.getTime():ke,[He,Re]=o.useMemo(()=>{if(e.mode==="point"){const m=ye(K);return[m,m]}const l=ye(me),c=ye(W);return[Math.min(l,c),Math.max(l,c)]},[e.mode,ke,bt,ye,K,me,W]),fe=e.mode==="point"?e.value!==void 0:e.mode==="range"?e.range!==void 0:e.microRange!==void 0,[j,B]=o.useState(()=>[He,Re]),[G,ge]=o.useState(null),[R,xe]=o.useState(null),Fe=o.useRef(null);Fe.current=R;const[Qe,le]=o.useState("high"),[be,et]=o.useState(null),[Ut,nr]=o.useState(null),se=G?G[0]:fe?He:j[0],ce=G?G[1]:fe?Re:j[1],yt=o.useRef([se,ce]);yt.current=[se,ce];const Q=e.mode==="vernier",wt=e.mode==="vernier"?e.vernierOrientation??(d?"macro-left":"macro-top"):"macro-top",D=wt==="macro-top"||wt==="macro-left",ar=e.mode==="vernier"?e.showVernierProjection??!0:!1,or=e.mode==="vernier"?e.showVernierTicks??!0:!1,Tt=e.mode==="vernier"?e.showHairline??!0:!1,A=Q?e.macroUnit??t:t,x=Q?e.microUnit??t:t,Pr=Q?e.macroIsDiscrete??!1:$,St=Q?e.microIsDiscrete??!1:$,ir=Q?e.macroAllowedDates??a:a,Cr=Q?e.microAllowedDates??a:a,h=Q?e.formatMacroLabel??e.formatLabel:e.formatLabel,C=Q?e.formatMicroLabel??e.formatLabel:e.formatLabel,Pe=e.mode==="vernier"?e.macroRange[0].getTime():void 0,Lt=e.mode==="vernier"?e.macroRange[1].getTime():void 0,Mt=me?.getTime(),tt=W?.getTime(),[Ce,lr]=o.useState(null),lt=o.useRef(null);lt.current=Ce;const[Te,Bt]=o.useState("micro-high"),je=o.useMemo(()=>q(A,r),[_,A]),Rt=o.useMemo(()=>{const l=q(A,n);if(Q&&l<=je)throw new RangeError(`PeriodSlider: macroUnit "${A}" cannot distinguish minDate from maxDate (minDate: ${he(r)}, maxDate: ${he(n)})`);return l},[Q,_,H,je,A]),ve=o.useMemo(()=>Q?Vt(ir,A,r,n):[],[Q,ir,A,_,H]),Ne=o.useMemo(()=>e.mode!=="vernier"?je:q(A,e.macroRange[0]),[e.mode,Pe,je,A]),Ye=o.useMemo(()=>e.mode!=="vernier"?Rt:q(A,e.macroRange[1]),[e.mode,Lt,Rt,A]),sr=o.useMemo(()=>oe(A,Ne),[A,Ne]),cr=o.useMemo(()=>oe(A,Ye),[A,Ye]),Se=o.useMemo(()=>e.mode!=="vernier"?q(x,r):Math.max(q(x,e.macroRange[0]),q(x,r)),[e.mode,Pe,x,_]),Be=o.useMemo(()=>e.mode!=="vernier"?q(x,n):Math.min(q(x,ot(A,x,e.macroRange[1])),q(x,n)),[e.mode,Lt,A,x,H]),ae=o.useMemo(()=>Q?Vt(Cr,x,r,n).filter(c=>{const m=q(x,c);return m>=Se&&m<=Be}):[],[Q,Cr,x,_,H,Se,Be]),$t=Pr&&ve.length>0,We=St&&ae.length>0,we=o.useMemo(()=>ie===null?Se:q(x,ie[0]),[Mt,Se,x,ie]),Me=o.useMemo(()=>ie===null?Be:q(x,ie[1]),[tt,Be,x,ie]),st=o.useMemo(()=>oe(x,we),[x,we]),ct=o.useMemo(()=>oe(x,Me),[x,Me]),zt=Math.max(1,Rt-je),pe=$t?yr(ve,A,s,sr):Math.max(0,Math.min(1,(Ne-je)/zt)),Ae=Math.max(pe,$t?yr(ve,A,s,cr):Math.min(1,(Ye-je)/zt)),_t=Math.max(1,Be-Se),Ve=We?yr(ae,x,s,st):Math.max(0,Math.min(1,(we-Se)/_t)),rt=Math.max(Ve,We?yr(ae,x,s,ct):Math.min(1,(Me-Se)/_t)),Nr=o.useRef({timerId:null,emit:null}),Yr=o.useRef({timerId:null,emit:null}),Ar=o.useRef({timerId:null,emit:null});o.useEffect(()=>{const l=[Nr,Yr,Ar];return()=>{for(const c of l)Br(c.current)}},[]);const kt=o.useCallback((l,c,m)=>{Br(l);const{debounceMs:M}=L.current;if(m||!M||M<=0){c();return}l.emit=c,l.timerId=setTimeout(()=>{l.timerId=null,l.emit=null,c()},M)},[]),Er=o.useCallback(l=>{const c=l.emit;Br(l),c?.()},[]),Pt=o.useCallback(l=>new Date(Math.min(Math.max(l.getTime(),_),H)),[_,H]),Ge=o.useCallback((l,c,m=!1)=>{const[M,S]=yt.current;if((L.current.mode==="point"?l===M:l===M&&c===S)&&Nr.current.timerId===null)return;const z=re(l),E=re(c),X=()=>{const T=L.current;T.mode==="point"?T.onChangePoint?.(z):T.mode==="range"&&T.onChangeRange?.(z,E)};kt(Nr.current,X,m)},[re,kt]),Ct=o.useCallback((l,c,m=!1)=>{if(L.current.mode!=="vernier")return;const M=Pt(l),S=Pt(c);kt(Yr.current,()=>{const F=L.current;F.mode==="vernier"&&F.onChangeMacroRange?.(M,S)},m)},[Pt,kt]),ze=o.useCallback((l,c,m=!1)=>{const M=L.current;if(M.mode!=="vernier")return;const S=Pt(l),F=Pt(c);M.microRange===void 0&&ne([S,F]),kt(Ar.current,()=>{const z=L.current;z.mode==="vernier"&&z.onChangeMicroRange?.(S,F)},m)},[Pt,kt]),ur=o.useCallback(l=>{if($&&s==="time"&&w.length>1){const M=Math.max(0,Math.min(w.length-1,Math.round(l))),S=w[0].getTime(),z=w[w.length-1].getTime()-S;if(z<=0)return 0;const E=w[M].getTime();return Math.max(0,Math.min(100,(E-S)/z*100))}const c=O-N;if(c<=0)return 0;const m=(l-N)/c*100;return Math.max(0,Math.min(100,m))},[$,s,w,N,O]),dr=o.useCallback(l=>{const c=Math.max(0,Math.min(100,l));if($){if(s==="time"&&w.length>1){const S=w[0].getTime(),z=w[w.length-1].getTime()-S,E=S+c/100*z;return De(w,new Date(E),t)}const M=Math.round(c/100*(w.length-1));return Math.max(0,Math.min(w.length-1,M))}const m=N+c/100*(O-N);return Math.round(m)},[$,s,w,N,O,t]),nt=o.useRef(null),[Nt,rn]=o.useState(0),[ra,Xt]=Ot(),[na,nn]=Ot(),[aa,an]=Ot(),[oa,on]=Ot(),[ia,ln]=Ot(),[la,sn]=Ot();o.useEffect(()=>{const l=nt.current;if(!l)return;const c=()=>{const m=l.getBoundingClientRect(),M=d?m.height:m.width;M>0&&rn(S=>Math.abs(S-M)<.5?S:M)};if(c(),typeof ResizeObserver<"u"){const m=new ResizeObserver(M=>{for(const S of M){const F=d?S.contentRect.height:S.contentRect.width;F>0&&rn(z=>Math.abs(z-F)<.5?z:F)}});return m.observe(l),()=>m.disconnect()}return window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[d]);const xt=o.useCallback((l,c,m)=>{const M=d?m.height:m.width;if(!(Number.isFinite(M)&&M>0))return null;const S=d?m.bottom-c:l-m.left;return Number.isFinite(S)?Math.max(0,Math.min(1,S/M)):null},[d]),cn=o.useCallback((l,c)=>{const m=nt.current;if(!m)return null;const M=xt(l,c,m.getBoundingClientRect());return M===null?null:M*100},[xt]),mr=o.useRef(null),Ir=o.useRef(null),Je=o.useRef(null),Hr=o.useRef(null),qt=o.useRef(null),un=o.useCallback(l=>{if(i)return;if(Q){const T=Ir.current;if(!T||l.pointerId!==0&&l.pointerId!==T.pointerId||!nt.current)return;const ue=xt(l.clientX,l.clientY,nt.current.getBoundingClientRect());if(ue===null)return;if(T.handle==="macro-low"||T.handle==="macro-high"||T.handle==="macro-connect"){const[_e,dt,$e]=Kn(T.handle,ue,T.startPointerRatio,T.startMacroLowRatio,T.startMacroHighRatio);$e!==lt.current&&(lt.current=$e,lr($e),Bt($e));let de,Xe;if($t){const ft=Tr(ve,A,s,_e),gt=Math.max(ft,Tr(ve,A,s,dt));de=ve[ft],Xe=ve[gt]}else{const ft=Math.round(je+_e*zt),gt=Math.round(je+dt*zt);de=oe(A,ft),Xe=oe(A,gt)}const Gt=`${de.getTime()}_${Xe.getTime()}`;Gt!==Hr.current&&(Hr.current=Gt,Ct(de,Xe));let at,mt;if(T.handle==="macro-connect"){const ft=qe(x,de),gt=ot(A,x,Xe);let It,Ht;if(A==="year"){const ht=de.getFullYear()-T.startMacroLowDate.getFullYear();It=Ie("year",T.initialMicroLowDate,ht),Ht=Ie("year",T.initialMicroHighDate,ht)}else if(A==="month"){const ht=(de.getFullYear()-T.startMacroLowDate.getFullYear())*12+(de.getMonth()-T.startMacroLowDate.getMonth());It=Ie("month",T.initialMicroLowDate,ht),Ht=Ie("month",T.initialMicroHighDate,ht)}else{const ht=Math.round((de.getTime()-T.startMacroLowDate.getTime())/864e5);It=Ie("day",T.initialMicroLowDate,ht),Ht=Ie("day",T.initialMicroHighDate,ht)}const jt=ft.getTime(),Jt=gt.getTime(),$n=T.initialMicroHighDate.getTime()-T.initialMicroLowDate.getTime();let Zt=It.getTime(),Qt=Ht.getTime();Zt<jt&&(Zt=jt,Qt=Math.min(Jt,Zt+$n)),Qt>Jt&&(Qt=Jt,Zt=Math.max(jt,Qt-$n)),at=qe(x,new Date(Zt)),mt=qe(x,new Date(Qt))}else{const ft=de.getTime(),gt=ot(A,x,Xe).getTime(),It=T.initialMicroLowDate.getTime(),Ht=T.initialMicroHighDate.getTime(),jt=Math.max(ft,Math.min(gt,It)),Jt=Math.max(jt,Math.min(gt,Ht));at=qe(x,new Date(jt)),mt=qe(x,new Date(Jt))}const Rn=`${at.getTime()}_${mt.getTime()}`;Rn!==qt.current&&(qt.current=Rn,ze(at,mt))}else if(T.handle==="micro-low"||T.handle==="micro-high"||T.handle==="micro-connect"){const[_e,dt,$e]=Wn(T.handle,ue,T.startPointerRatio,T.startMicroLowRatio,T.startMicroHighRatio);$e!==lt.current&&(lt.current=$e,lr($e),Bt($e));let de,Xe;if(We){const at=Tr(ae,x,s,_e),mt=Math.max(at,Tr(ae,x,s,dt));de=ae[at],Xe=ae[mt]}else{const at=Math.round(Se+_e*_t),mt=Math.round(Se+dt*_t);de=oe(x,at),Xe=oe(x,mt)}const Gt=`${de.getTime()}_${Xe.getTime()}`;Gt!==qt.current&&(qt.current=Gt,ze(de,Xe))}return}const c=mr.current;if(!c||l.pointerId!==0&&l.pointerId!==c.pointerId||!nt.current)return;const m=nt.current.getBoundingClientRect(),M=d?l.clientY:l.clientX,S=d?m.height:m.width;if(!(Number.isFinite(S)&&S>0))return;if(c.handle==="connect"){const T=d?(c.startPointerPos-M)/S:(M-c.startPointerPos)/S,ue=Vn({posDiffPct:T,startLowVal:c.startLowVal,startHighVal:c.startHighVal,rangeMin:N,rangeMax:O,isDiscrete:$,sortedAllowedDates:w,snapMode:s,unit:t});if(Je.current&&Je.current[0]===ue[0]&&Je.current[1]===ue[1])return;Je.current=ue,ge(ue),Ge(ue[0],ue[1],!1);return}const F=xt(l.clientX,l.clientY,m);if(F===null)return;const z=dr(F*100),[E,X]=qr(c.handle,z,c.startLowVal,c.startHighVal,N,O,k);if((!Je.current||Je.current[0]!==E||Je.current[1]!==X)&&(Je.current=[E,X],ge([E,X]),Ge(E,X,!1)),!k&&(c.handle==="low"||c.handle==="high")){const T=Fn(c.handle,z,c.startLowVal,c.startHighVal,k);Fe.current!==T&&(Fe.current=T,xe(T),le(T))}},[i,Q,d,A,x,$t,We,ve,ae,je,zt,Se,_t,N,O,$,w,s,t,xt,dr,Ge,Ct,ze,k]),dn=o.useCallback(l=>{if(Q){Hr.current=null,qt.current=null,Ir.current=null,lt.current=null,lr(null),Er(Yr.current),Er(Ar.current);return}const c=mr.current;if(!c||l.pointerId!==0&&l.pointerId!==c.pointerId)return;const m=Je.current??G;m&&(Ge(m[0],m[1],!0),B(m)),Je.current=null,ge(null),mr.current=null,Fe.current=null,xe(null)},[Q,G,Ge,Er]),mn=o.useRef(un);mn.current=un;const fn=o.useRef(dn);fn.current=dn;const gn=R!==null||Ce!==null;o.useEffect(()=>{if(!gn)return;const l=m=>mn.current(m),c=m=>fn.current(m);return window.addEventListener("pointermove",l),window.addEventListener("pointerup",c),window.addEventListener("pointercancel",c),()=>{window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",c),window.removeEventListener("pointercancel",c)}},[gn]);const jr=o.useCallback((l,c,m)=>{mr.current={pointerId:l,handle:c,startPointerPos:m,startLowVal:se,startHighVal:ce},Fe.current=c,xe(c),c!=="connect"&&le(c)},[se,ce]),hn=o.useCallback((l,c,m)=>{const M=L.current;M.mode==="vernier"&&(Ir.current={pointerId:l,handle:c,startPointerRatio:m,startMacroLowRatio:pe,startMacroHighRatio:Ae,startMicroLowRatio:Ve,startMicroHighRatio:rt,startMacroLowEnc:Ne,startMacroHighEnc:Ye,startMicroLowEnc:we,startMicroHighEnc:Me,startMacroLowDate:M.macroRange[0],startMacroHighDate:M.macroRange[1],initialMicroLowDate:st,initialMicroHighDate:ct},lt.current=c,lr(c),Bt(c))},[pe,Ae,Ve,rt,Ne,Ye,we,Me,st,ct]),bn=l=>c=>{if(i)return;c.stopPropagation(),c.preventDefault(),le(l);const m=d?c.clientY:c.clientX;jr(c.pointerId,l,m)},wn=l=>()=>{i||Fe.current!==null||le(l)},fr=l=>()=>{i||lt.current!==null||Bt(l)},Yt=l=>c=>{if(i)return;c.stopPropagation(),c.preventDefault();const m=nt.current;if(!m)return;const M=xt(c.clientX,c.clientY,m.getBoundingClientRect());M!==null&&hn(c.pointerId,l,M)},sa=l=>{if(i||v)return;l.stopPropagation(),l.preventDefault();const c=d?l.clientY:l.clientX;jr(l.pointerId,"connect",c)},ca=l=>{if(i)return;if(Q){const E=nt.current;if(!E)return;const X=E.getBoundingClientRect(),T=xt(l.clientX,l.clientY,X);if(T===null)return;const ue=d?l.clientX-(X.left+X.width/2):l.clientY-(X.top+X.height/2),_e=qn(T,ue,pe,Ae,Ve,rt,wt,void 0,!v);hn(l.pointerId,_e,T);return}const c=cn(l.clientX,l.clientY);if(c===null)return;const m=dr(c);let M="low";if(!k){const E=Math.abs(m-se),X=Math.abs(m-ce);E<X?M="low":X<E?M="high":M=m>ce?"high":"low"}le(M);const[S,F]=qr(M,m,se,ce,N,O,k);ge([S,F]),Ge(S,F,!0);const z=d?l.clientY:l.clientX;jr(l.pointerId,M,z)},ua=l=>{if(i||R!==null)return;const c=cn(l.clientX,l.clientY);if(c===null)return;const m=dr(c);et(m),nr(ur(m))},da=()=>{et(null),nr(null)},Mn=l=>c=>{if(i)return;le(l);const m=Un(c.key,l,se,ce,N,O,k,1);m&&(c.preventDefault(),fe||B(m),Ge(m[0],m[1],!0))},gr=(l,c)=>{const m=Math.max(q(x,l),q(x,r)),M=Math.min(q(x,ot(A,x,c)),q(x,n)),S=Math.max(m,Math.min(M,we)),F=Math.max(S,Math.min(M,Me));S===we&&F===Me||ze(oe(x,S),oe(x,F),!0)},hr=l=>c=>{if(i||!Q||e.mode!=="vernier")return;Bt(l);let m=0,M=!1,S=!1;switch(c.key){case"ArrowRight":case"ArrowUp":m=1;break;case"ArrowLeft":case"ArrowDown":m=-1;break;case"PageUp":m=5;break;case"PageDown":m=-5;break;case"Home":M=!0;break;case"End":S=!0;break;default:return}if(c.preventDefault(),l==="macro-low"){const F=oe(A,Ne),z=oe(A,Ye);if($t){const T=Sr(ve,A,F,ve[0],z,m,M,S);if(T===De(ve,F,A))return;const ue=ve[T];Ct(ue,z,!0),gr(ue,z);return}let E;if(M?E=je:S?E=Ye:E=Math.max(je,Math.min(Ye,Ne+m)),E===Ne)return;const X=oe(A,E);Ct(X,z,!0),gr(X,z)}else if(l==="macro-high"){const F=oe(A,Ne),z=oe(A,Ye);if($t){const T=Sr(ve,A,z,F,ve[ve.length-1],m,M,S);if(T===De(ve,z,A))return;const ue=ve[T];Ct(F,ue,!0),gr(F,ue);return}let E;if(M?E=Ne:S?E=Rt:E=Math.max(Ne,Math.min(Rt,Ye+m)),E===Ye)return;const X=oe(A,E);Ct(F,X,!0),gr(F,X)}else if(l==="micro-low"){const F=oe(x,we),z=oe(x,Me);if(We){const X=Sr(ae,x,F,ae[0],z,m,M,S);if(X===De(ae,F,x))return;ze(ae[X],z,!0);return}let E;if(M?E=Se:S?E=Me:E=Math.max(Se,Math.min(Me,we+m)),E===we)return;ze(oe(x,E),z,!0)}else if(l==="micro-high"){const F=oe(x,we),z=oe(x,Me);if(We){const X=Sr(ae,x,z,F,ae[ae.length-1],m,M,S);if(X===De(ae,z,x))return;ze(F,ae[X],!0);return}let E;if(M?E=we:S?E=Be:E=Math.max(we,Math.min(Be,Me+m)),E===Me)return;ze(F,oe(x,E),!0)}},ma=o.useCallback(l=>{const c=L.current;if(!c.disabled)if(c.mode==="point"){const m=Math.max(N,Math.min(O,se+l));fe||B([m,m]),Ge(m,m,!0)}else if(c.mode==="vernier"){if(We){const T=ae.length-1,ue=De(ae,st,x),_e=De(ae,ct,x),dt=_e-ue;let $e=ue+l,de=_e+l;l<0&&$e<0?($e=0,de=Math.min(T,dt)):l>0&&de>T&&(de=T,$e=Math.max(0,T-dt)),($e!==ue||de!==_e)&&ze(ae[$e],ae[de],!0);return}const m=we,M=Me,S=Se,F=Be,z=M-m;let E=m+l,X=M+l;l<0&&E<S?(E=S,X=Math.min(F,E+z)):l>0&&X>F&&(X=F,E=Math.max(S,X-z)),(E!==m||X!==M)&&ze(oe(x,E),oe(x,X),!0)}else{const m=ce-se;let M=se+l,S=ce+l;l<0&&M<N?(M=N,S=Math.min(O,M+m)):l>0&&S>O&&(S=O,M=Math.max(N,S-m)),M<=S&&(fe||B([M,S]),Ge(M,S,!0))}},[se,ce,N,O,fe,Ge,ze,we,Me,Se,Be,x,We,ae,st,ct]),At=ur(se),Et=ur(ce),Or=re(se),Fr=re(ce),Vr=o.useMemo(()=>k?Xt===null?void 0:{estimatedWidthPx:Xt.widthPx,estimatedHeightPx:Xt.heightPx}:zr(Xt,nn),[k,Xt,nn]),br=!k&&se===ce,Ee=o.useMemo(()=>{if(k||!y||d)return Zr(P,Vr);const l=Qr(At,Et,Nt,P,Vr);return br?Xn(l):l},[k,br,y,d,At,Et,Nt,P,Vr]),Kt=R==="low"||R!=="high"&&Qe==="low",Wt=!k&&(R==="high"||R!=="low"&&Qe==="high"),wr=Ne===Ye,Mr=we===Me,fa=wr&&Te!=="macro-low",ga=wr&&Te==="macro-low",ha=Mr&&Te!=="micro-low",ba=Mr&&Te==="micro-low",xn=D?"top":"bottom",vn=D?"bottom":"top",pn=o.useMemo(()=>zr(an,on),[an,on]),Dn=o.useMemo(()=>zr(ln,sn),[ln,sn]),xr=y&&!d,vr=o.useMemo(()=>Cn(pe,Ae,Nt,xn,pn,wr,xr),[pe,Ae,Nt,xn,pn,wr,xr]),pr=o.useMemo(()=>Cn(Ve,rt,Nt,vn,Dn,Mr,xr),[Ve,rt,Nt,vn,Dn,Mr,xr]),wa=o.useMemo(()=>d?{"--ps-tooltip-origin":"100% 50%","--ps-tooltip-tx":"0px","--ps-tooltip-ty":"-50%","--ps-tooltip-rot":"0deg"}:{"--ps-tooltip-origin":"50% 50%","--ps-tooltip-tx":`calc(-50% + ${Ee.lowOffsetX}px)`,"--ps-tooltip-ty":`calc(-50% + ${Ee.lowOffsetY}px)`,"--ps-tooltip-rot":`${Ee.lowAngleDeg}deg`},[d,Ee.lowOffsetX,Ee.lowOffsetY,Ee.lowAngleDeg]),Ma=o.useMemo(()=>d?{"--ps-tooltip-origin":"100% 50%","--ps-tooltip-tx":"0px","--ps-tooltip-ty":"-50%","--ps-tooltip-rot":"0deg"}:{"--ps-tooltip-origin":"50% 50%","--ps-tooltip-tx":`calc(-50% + ${Ee.highOffsetX}px)`,"--ps-tooltip-ty":`calc(-50% + ${Ee.highOffsetY}px)`,"--ps-tooltip-rot":`${Ee.highAngleDeg}deg`},[d,Ee.highOffsetX,Ee.highOffsetY,Ee.highAngleDeg]),Dr=Math.min(At,Et),yn=Math.max(At,Et),xa=d?{bottom:`${Dr}%`,height:`${yn-Dr}%`,top:"auto",left:"0",right:"0"}:{left:`${Dr}%`,width:`${yn-Dr}%`,top:"0",bottom:"0"},va=Math.max(.01,Ae-pe),Tn=Math.max(.06,Math.min(.25,.28*Math.sqrt(va))),pa=d?{bottom:`${At}%`,left:"50%",transform:"translate(-50%, 50%)",zIndex:Kt?40:30}:{left:`${At}%`,top:"50%",transform:"translate(-50%, -50%)",zIndex:Kt?40:30},Da=d?{bottom:`${Et}%`,left:"50%",transform:"translate(-50%, 50%)",zIndex:Wt?40:30}:{left:`${Et}%`,top:"50%",transform:"translate(-50%, -50%)",zIndex:Wt?40:30},ya=d?{bottom:`${Ut}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${Ut}%`,top:"50%",transform:"translate(-50%, -50%)"},Sn=be!==null?re(be):null,Ta=f!=="hover"&&be!==null&&(be===se||!k&&be===ce),Sa=We?q(x,ae[0]):Se,La=We?q(x,ae[ae.length-1]):Be,Ra=i||(Q?we<=Sa:k?se<=N:se<=N&&ce<=N),$a=i||(Q?Me>=La:(k||se>=O)&&ce>=O),ut=i?"cursor-not-allowed opacity-50":"cursor-pointer",Ln=l=>{const c=d?"vertical":"horizontal",m=l==="decrease",M=Fa[c][l];return g.jsx("button",{type:"button",className:`period-slider-stepper-btn relative after:absolute after:inset-[-11px] after:content-[''] ${M} 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 ${ut}`,onClick:()=>ma(m?-1:1),disabled:m?Ra:$a,"aria-label":m?J:I,children:Oa[c][l]})};return g.jsxs("div",{style:e.style,className:`period-slider flex select-none items-center gap-2 ${d?"flex-col":"flex-row"} ${u}`,"data-disabled":i?"true":void 0,"data-unit":t,"data-mode":e.mode,"data-orientation":d?"vertical":"horizontal","data-label-position":P,"data-color-scheme":ee,children:[b&&Ln(d?"increase":"decrease"),g.jsx("div",{ref:nt,"data-testid":"period-slider-track","data-orientation":d?"vertical":"horizontal","data-vernier-orientation":Q?wt:void 0,className:`period-slider-track relative flex-1 touch-none rounded-full bg-slate-200 dark:bg-slate-700 ${d?"h-48 w-2":"h-2 w-full"} ${ut}`,onPointerDown:ca,onPointerMove:ua,onPointerLeave:da,children:Q?g.jsxs(g.Fragment,{children:[ar&&(d?g.jsxs("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:[g.jsx("defs",{children:g.jsxs("linearGradient",{id:U,x1:"0",y1:"0",x2:"1",y2:"0",children:[g.jsx("stop",{offset:"0%",stopColor:D?Y.macro:Y.micro,stopOpacity:"0.28"}),g.jsx("stop",{offset:"100%",stopColor:D?Y.micro:Y.macro,stopOpacity:Tn})]})}),g.jsx("polygon",{points:D?`12,${(1-Ae)*100} 12,${(1-pe)*100} 20,100 20,0`:`12,0 12,100 20,${(1-pe)*100} 20,${(1-Ae)*100}`,fill:`url(#${U})`})]}):g.jsxs("svg",{className:"period-slider-vernier-projection",role:"presentation","aria-hidden":"true",width:"100%",height:"32",viewBox:"0 0 100 32",preserveAspectRatio:"none",children:[g.jsx("defs",{children:g.jsxs("linearGradient",{id:U,x1:"0",y1:"0",x2:"0",y2:"1",children:[g.jsx("stop",{offset:"0%",stopColor:D?Y.macro:Y.micro,stopOpacity:"0.28"}),g.jsx("stop",{offset:"100%",stopColor:D?Y.micro:Y.macro,stopOpacity:Tn})]})}),g.jsx("polygon",{points:D?`${pe*100},12 ${Ae*100},12 100,20 0,20`:`0,12 100,12 ${Ae*100},20 ${pe*100},20`,fill:`url(#${U})`})]})),!v&&g.jsxs(g.Fragment,{children:[g.jsx("div",{"data-testid":"period-slider-connect-macro",className:"period-slider-connect-macro",style:d?{bottom:`calc(${pe*100}% - 8px)`,height:`calc(${Math.max(0,(Ae-pe)*100)}% + 16px)`}:{left:`calc(${pe*100}% - 8px)`,width:`calc(${Math.max(0,(Ae-pe)*100)}% + 16px)`},onPointerDown:Yt("macro-connect")}),g.jsx("div",{"data-testid":"period-slider-connect-micro",className:"period-slider-connect-micro",style:d?{bottom:`calc(${Ve*100}% - 8px)`,height:`calc(${Math.max(0,(rt-Ve)*100)}% + 16px)`}:{left:`calc(${Ve*100}% - 8px)`,width:`calc(${Math.max(0,(rt-Ve)*100)}% + 16px)`},onPointerDown:Yt("micro-connect")})]}),or&&g.jsxs("div",{className:"period-slider-vernier-ticks pointer-events-none absolute inset-0",children:[[.2,.4,.6,.8].map(l=>g.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"macro",className:"period-slider-tick period-slider-tick-macro",style:d?{bottom:`${l*100}%`}:{left:`${l*100}%`}},`macro-tick-${l}`)),[.1,.2,.3,.4,.5,.6,.7,.8,.9].map(l=>g.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"micro",className:"period-slider-tick period-slider-tick-micro",style:d?{bottom:`${l*100}%`}:{left:`${l*100}%`}},`micro-tick-${l}`))]}),g.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":e.macroLowerAriaLabel??"Macro range start","aria-disabled":i?"true":void 0,"aria-valuemin":je,"aria-valuemax":Ye,"aria-valuenow":Ne,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(sr,A):vt(A,sr,h,p),"aria-orientation":d?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${d?"is-vertical":""} group absolute touch-none ${d?D?"after:absolute after:-inset-y-3 after:right-0 after:-left-4":"after:absolute after:-inset-y-3 after:-right-4 after:left-0":D?"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 ${ut}`,style:d?{bottom:`${pe*100}%`,left:D?0:"auto",right:D?"auto":0,transform:D?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:Ce==="macro-low"||Te==="macro-low"?30:15}:{left:`${pe*100}%`,top:D?0:"auto",bottom:D?"auto":0,transform:D?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:Ce==="macro-low"||Te==="macro-low"?30:15},onPointerDown:Yt("macro-low"),onKeyDown:hr("macro-low"),onFocus:fr("macro-low"),"data-active":Ce==="macro-low"?"true":void 0,"data-front":Te==="macro-low"?"true":void 0,"data-vernier-pos":d?D?"left":"right":D?"top":"bottom","data-handle-type":"macro-low",children:[g.jsx(er,{type:"macro",isTop:D,isVertical:d,isLeft:D}),Tt&&g.jsx("div",{className:"period-slider-hairline"}),f!=="hover"&&g.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${f==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":f,"data-duplicate":fa?"true":void 0,"data-slanted":vr.slant.isSlanted?"true":void 0,ref:aa,style:vr.lowStyle,children:Oe(A,sr,h,p)})]}),g.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":e.macroUpperAriaLabel??"Macro range end","aria-disabled":i?"true":void 0,"aria-valuemin":Ne,"aria-valuemax":Rt,"aria-valuenow":Ye,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(cr,A):vt(A,cr,h,p),"aria-orientation":d?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${d?"is-vertical":""} group absolute touch-none ${d?D?"after:absolute after:-inset-y-3 after:right-0 after:-left-4":"after:absolute after:-inset-y-3 after:-right-4 after:left-0":D?"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 ${ut}`,style:d?{bottom:`${Ae*100}%`,left:D?0:"auto",right:D?"auto":0,transform:D?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:Ce==="macro-high"||Te==="macro-high"?30:15}:{left:`${Ae*100}%`,top:D?0:"auto",bottom:D?"auto":0,transform:D?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:Ce==="macro-high"||Te==="macro-high"?30:15},onPointerDown:Yt("macro-high"),onKeyDown:hr("macro-high"),onFocus:fr("macro-high"),"data-active":Ce==="macro-high"?"true":void 0,"data-front":Te==="macro-high"?"true":void 0,"data-vernier-pos":d?D?"left":"right":D?"top":"bottom","data-handle-type":"macro-high",children:[g.jsx(er,{type:"macro",isTop:D,isVertical:d,isLeft:D}),Tt&&g.jsx("div",{className:"period-slider-hairline"}),f!=="hover"&&g.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${f==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":f,"data-duplicate":ga?"true":void 0,"data-slanted":vr.slant.isSlanted?"true":void 0,ref:oa,style:vr.highStyle,children:Oe(A,cr,h,p)})]}),g.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":e.lowerAriaLabel??"Micro range start","aria-disabled":i?"true":void 0,"aria-valuemin":Se,"aria-valuemax":Me,"aria-valuenow":we,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(st,x):vt(x,st,C,p),"aria-orientation":d?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${d?"is-vertical":""} group absolute touch-none ${d?D?"after:absolute after:-inset-y-3 after:-right-4 after:left-0":"after:absolute after:-inset-y-3 after:right-0 after:-left-4":D?"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 ${ut}`,style:d?{bottom:`${Ve*100}%`,left:D?"auto":0,right:D?0:"auto",transform:D?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:Ce==="micro-low"||Te==="micro-low"?30:20}:{left:`${Ve*100}%`,top:D?"auto":0,bottom:D?0:"auto",transform:D?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:Ce==="micro-low"||Te==="micro-low"?30:20},onPointerDown:Yt("micro-low"),onKeyDown:hr("micro-low"),onFocus:fr("micro-low"),"data-active":Ce==="micro-low"?"true":void 0,"data-front":Te==="micro-low"?"true":void 0,"data-vernier-pos":d?D?"right":"left":D?"bottom":"top","data-handle-type":"micro-low",children:[g.jsx(er,{type:"micro",isTop:!D,isVertical:d,isLeft:!D}),Tt&&g.jsx("div",{className:"period-slider-hairline"}),f!=="hover"&&g.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${f==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":f,"data-duplicate":ha?"true":void 0,"data-slanted":pr.slant.isSlanted?"true":void 0,ref:ia,style:pr.lowStyle,children:Oe(x,st,C,p)})]}),g.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":e.upperAriaLabel??"Micro range end","aria-disabled":i?"true":void 0,"aria-valuemin":we,"aria-valuemax":Be,"aria-valuenow":Me,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(ct,x):vt(x,ct,C,p),"aria-orientation":d?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${d?"is-vertical":""} group absolute touch-none ${d?D?"after:absolute after:-inset-y-3 after:-right-4 after:left-0":"after:absolute after:-inset-y-3 after:right-0 after:-left-4":D?"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 ${ut}`,style:d?{bottom:`${rt*100}%`,left:D?"auto":0,right:D?0:"auto",transform:D?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:Ce==="micro-high"||Te==="micro-high"?30:20}:{left:`${rt*100}%`,top:D?"auto":0,bottom:D?0:"auto",transform:D?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:Ce==="micro-high"||Te==="micro-high"?30:20},onPointerDown:Yt("micro-high"),onKeyDown:hr("micro-high"),onFocus:fr("micro-high"),"data-active":Ce==="micro-high"?"true":void 0,"data-front":Te==="micro-high"?"true":void 0,"data-vernier-pos":d?D?"right":"left":D?"bottom":"top","data-handle-type":"micro-high",children:[g.jsx(er,{type:"micro",isTop:!D,isVertical:d,isLeft:!D}),Tt&&g.jsx("div",{className:"period-slider-hairline"}),f!=="hover"&&g.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${f==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":f,"data-duplicate":ba?"true":void 0,"data-slanted":pr.slant.isSlanted?"true":void 0,ref:la,style:pr.highStyle,children:Oe(x,ct,C,p)})]})]}):g.jsxs(g.Fragment,{children:[!v&&g.jsx("div",{"data-testid":"period-slider-connect",className:"period-slider-connect absolute rounded-full",style:xa,onPointerDown:sa}),V&&$&&w.length>1&&g.jsx("div",{className:"period-slider-ticks pointer-events-none absolute inset-0",children:w.map((l,c)=>{const m=q(t,l),M=ur(c),S=d?{bottom:`${M}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${M}%`,top:"50%",transform:"translate(-50%, -50%)"};return g.jsx("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:S},`tick-${m}`)})}),!i&&be!==null&&Ut!==null&&R===null&&Sn&&g.jsxs("div",{"data-testid":"period-slider-hover-guide",className:"period-slider-hover-guide pointer-events-none absolute h-2 w-2",style:ya,children:[g.jsx("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"}),g.jsx("div",{"data-testid":"period-slider-hover-tooltip","data-duplicate":Ta?"true":void 0,className:`period-slider-hover-tooltip ${P==="bottom"&&!d?"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`,children:Oe(t,Sn,e.formatLabel,p)})]}),g.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":k?e.pointAriaLabel??"Selected date":e.lowerAriaLabel??"Range start","aria-disabled":i?"true":void 0,"aria-valuemin":N,"aria-valuemax":k?O:ce,"aria-valuenow":se,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Or,t):vt(t,Or,e.formatLabel,p),"aria-orientation":d?"vertical":"horizontal",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 ${ut}`,style:pa,onPointerDown:bn("low"),onKeyDown:Mn("low"),onFocus:wn("low"),"data-active":R==="low"?"true":void 0,"data-front":Kt?"true":void 0,children:[g.jsx("div",{"data-testid":"period-slider-knob",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)] ${R==="low"?"":"shadow-md"}`}),f!=="hover"&&g.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${f==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":f,"data-label-position":P,"data-slanted":Ee.isSlanted?"true":void 0,"data-front":Kt?"true":void 0,"data-duplicate":br&&!Kt?"true":void 0,ref:ra,style:wa,children:Oe(t,Or,e.formatLabel,p)})]}),!k&&g.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":e.upperAriaLabel??"Range end","aria-disabled":i?"true":void 0,"aria-valuemin":se,"aria-valuemax":O,"aria-valuenow":ce,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Fr,t):vt(t,Fr,e.formatLabel,p),"aria-orientation":d?"vertical":"horizontal",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 ${ut}`,style:Da,onPointerDown:bn("high"),onKeyDown:Mn("high"),onFocus:wn("high"),"data-active":R==="high"?"true":void 0,"data-front":Wt?"true":void 0,children:[g.jsx("div",{"data-testid":"period-slider-knob",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)] ${R==="high"?"":"shadow-md"}`}),f!=="hover"&&g.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${f==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":f,"data-label-position":P,"data-slanted":Ee.isSlanted?"true":void 0,"data-front":Wt?"true":void 0,"data-duplicate":br&&!Wt?"true":void 0,ref:na,style:Ma,children:Oe(t,Fr,e.formatLabel,p)})]})]})}),b&&Ln(d?"decrease":"increase")]})},_r=(e,t)=>{if(e===t)return!0;if(!(e&&t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r].getTime()!==t[r].getTime())return!1;return!0},Gn=(e,t)=>{if(e===t)return!0;if(!(e&&t))return!1;const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(const a of r)if(e[a]!==t[a])return!1;return!0},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||!Gn(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||!_r(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||!_r(e.macroAllowedDates,t.macroAllowedDates)||!_r(e.microAllowedDates,t.microAllowedDates)):!1,Jn=o.memo(Va,Ua);Jn.displayName="PeriodSlider";const Ze=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},tr=(e,t)=>{if(Number.isNaN(t.getTime()))throw new RangeError(`DateSelector: "${e}" must be a valid Date (received ${String(t)})`)},Ba=e=>{if(e!==void 0)try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{throw new RangeError(`DateSelector: "locale" must be a valid BCP 47 language tag (received ${JSON.stringify(e)})`)}},Dt=(e,t,r)=>{const n=new Date(e,t-1,r);return n.setFullYear(e),n.setHours(0,0,0,0),n},Nn=e=>Dt(e,1,1),za=e=>Dt(e,12,31),_a={year:{year:"numeric"},month:{month:"2-digit"},day:{day:"2-digit"}},Xa={year:4,month:2,day:2},qa={year:e=>e.getFullYear(),month:e=>e.getMonth()+1,day:e=>e.getDate()},Yn=new Map,Ka=(e,t)=>{const r=`${e}\0${t}`,n=Yn.get(r);if(n!==void 0)return n;const a=new Intl.DateTimeFormat(t,_a[e]);return Yn.set(r,a),a},Xr=(e,t,r)=>r===void 0?String(qa[e](t)).padStart(Xa[e],"0"):Ka(e,r).format(t),Wa=(e,t,r)=>{const n=t?.getTime()??null,a=r?.getTime()??null,s=new Map;return e.forEach((i,u)=>{tr(`allowedDates[${u}]`,i);const b=Ze(i),f=b.getTime();n!==null&&f<n||a!==null&&f>a||s.has(f)||s.set(f,b)}),Array.from(s.keys()).sort((i,u)=>i-u).map(i=>s.get(i))},Ga=(e,t)=>{const r=[];let n=Ze(e);const a=Ze(t).getTime();for(;n.getTime()<=a;)r.push(n),n=Le.addDays(n,1);return r},An=(e,t)=>{const r=[];for(let n=e.length-1;n>=0;n--)r.push({label:Oe("day",e[n],void 0,t),value:Le.format(e[n],"yyyy-MM-dd")});return r},Ja=e=>{const{value:t,initialDate:r,onChange:n,children:a,minYear:s,maxYear:i,minDate:u,maxDate:b,allowedDates:f,variant:P="date",className:y="",style:d,disabled:v=!1,prevDateAriaLabel:V="Previous day",nextDateAriaLabel:ee="Next day",selectAriaLabel:p="Date",yearAriaLabel:J="Year",monthAriaLabel:I="Month",dayAriaLabel:te="Day",locale:Y,formatYearOption:U,formatMonthOption:L,formatDayOption:_}=e;if(Ba(Y),t!==void 0&&tr("value",t),r!==void 0&&tr("initialDate",r),u!==void 0&&tr("minDate",u),b!==void 0&&tr("maxDate",b),s!==void 0&&!Number.isInteger(s))throw new RangeError(`DateSelector: "minYear" must be an integer year (received ${String(s)})`);if(i!==void 0&&!Number.isInteger(i))throw new RangeError(`DateSelector: "maxYear" must be an integer year (received ${String(i)})`);if(P==="split-dropdown"&&f!==void 0)throw new RangeError('DateSelector: variant="split-dropdown" cannot honour "allowedDates"; use variant="dropdown" or variant="date" for a discrete date set');const H=t??r;if(H===void 0)throw new RangeError("DateSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected date is never inferred from the wall clock.");const[w,$]=o.useState(()=>Ze(H)),N=t!==void 0,O=t?.getTime(),k=o.useMemo(()=>t!==void 0?Ze(t):w,[O,w]),re=u?.getTime(),ye=b?.getTime(),Z=o.useMemo(()=>{const h=u?Ze(u):null,C=s!==void 0?Nn(s):null;return h===null?C:C===null||h.getTime()>=C.getTime()?h:C},[re,s]),ne=o.useMemo(()=>{const h=b?Ze(b):null,C=i!==void 0?za(i):null;return h===null?C:C===null||h.getTime()<=C.getTime()?h:C},[ye,i]),ie=Z?.getTime()??null,me=ne?.getTime()??null;if(Z!==null&&ne!==null&&Z.getTime()>ne.getTime())throw new RangeError(`DateSelector: the resolved range is empty (min ${Le.format(Z,"yyyy-MM-dd")} is after max ${Le.format(ne,"yyyy-MM-dd")})`);if(P!=="date"&&f===void 0&&(Z===null||ne===null))throw new RangeError(`DateSelector: variant="${P}" needs a bounded range; supply minDate/minYear and maxDate/maxYear${P==="dropdown"?' or supply "allowedDates"':""}`);const W=f===void 0?null:f.map(h=>h.getTime()).join(","),K=o.useMemo(()=>f===void 0?null:Wa(f,Z,ne),[W,ie,me]),ke=h=>{const C=h.getTime();return K!==null?K.some(Pe=>Pe.getTime()===C):!(ie!==null&&C<ie||me!==null&&C>me)},bt=H.getTime();o.useEffect(()=>{N||$(Ze(H))},[N,bt]);const He=h=>{if(v)return;const C=Ze(h);ke(C)&&(N||$(C),n?.(C))},Re=k.getTime(),fe=ke(k),j=o.useMemo(()=>{if(K!==null){for(let C=K.length-1;C>=0;C--)if(K[C].getTime()<Re)return K[C];return null}const h=Le.addDays(new Date(Re),-1);return ke(h)?h:null},[K,Re,ie,me]),B=o.useMemo(()=>{if(K!==null){for(const C of K)if(C.getTime()>Re)return C;return null}const h=Le.addDays(new Date(Re),1);return ke(h)?h:null},[K,Re,ie,me]),G=v||j===null,ge=v||B===null,R=()=>{j!==null&&He(j)},xe=()=>{B!==null&&He(B)},Fe=h=>{if(h.target.value){const C=Le.parseISO(h.target.value);Number.isNaN(C.getTime())||He(C)}},Qe=h=>{if(h.target.value){const C=Le.parseISO(h.target.value);Number.isNaN(C.getTime())||He(C)}},le=k.getFullYear(),be=k.getMonth()+1,et=k.getDate(),Ut=o.useMemo(()=>P!=="dropdown"?[]:K!==null?An(K,Y):Z===null||ne===null?[]:An(Ga(Z,ne),Y),[P,K,ie,me,Y]),nr=o.useMemo(()=>{if(P!=="split-dropdown"||Z===null||ne===null)return[];const h=[];for(let C=ne.getFullYear();C>=Z.getFullYear();C--)h.push(C);return h},[P,ie,me]),se=o.useMemo(()=>{if(P!=="split-dropdown"||Z===null||ne===null)return[];const h=Z,C=ne,Pe=le===h.getFullYear()?h.getMonth()+1:1,Lt=le===C.getFullYear()?C.getMonth()+1:12,Mt=[];for(let tt=Pe;tt<=Lt;tt++)Mt.push(tt);return Mt},[P,ie,me,le]),ce=o.useMemo(()=>{if(P!=="split-dropdown"||Z===null||ne===null)return[];const h=Z,C=ne,Pe=le===h.getFullYear()&&be===h.getMonth()+1?h.getDate():1,Lt=le===C.getFullYear()&&be===C.getMonth()+1?C.getDate():Le.getDaysInMonth(new Date(Re)),Mt=[];for(let tt=Pe;tt<=Lt;tt++)Mt.push(tt);return Mt},[P,ie,me,Re,le,be]),yt=(h,C,Pe)=>Pe>Le.getDaysInMonth(Dt(h,C,1))?!1:ke(Dt(h,C,Pe)),Q=(h,C,Pe)=>{yt(h,C,Pe)&&He(Dt(h,C,Pe))},wt=h=>U?U(h):Xr("year",Nn(h),Y),D=h=>L?L(h):Xr("month",Dt(le,h,1),Y),ar=h=>_?_(h):Xr("day",Dt(le,be,h),Y),or=Le.format(k,"yyyy-MM-dd"),Tt=Oe("day",k,void 0,Y),A=Z?Le.format(Z,"yyyy-MM-dd"):void 0,x=ne?Le.format(ne,"yyyy-MM-dd"):void 0,Pr=fe?or:"",St="text-center font-mono text-gray-500 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-400",ir=P==="split-dropdown"?"w-auto":"w-38";return g.jsxs("div",{className:`inline-flex items-center ${ir} ${y}`,style:d,"data-variant":P,"data-out-of-range":fe?void 0:"true",children:[g.jsx("button",{type:"button","aria-label":V,disabled:G,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",onClick:R,children:g.jsx("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"})}),P==="dropdown"?g.jsxs("select",{"aria-label":p,disabled:v,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:Pr,onChange:Qe,children:[fe?null:g.jsx("option",{value:"",disabled:!0,className:St,children:Tt}),Ut.map(h=>g.jsx("option",{value:h.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:h.label},h.value))]}):P==="split-dropdown"?g.jsxs("div",{className:"mx-1 my-auto inline-flex items-center gap-1",children:[g.jsxs("select",{"aria-label":J,disabled:v,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",value:fe?le:"",onChange:h=>Q(Number(h.target.value),be,et),children:[fe?null:g.jsx("option",{value:"",disabled:!0,className:St,children:wt(le)}),nr.map(h=>g.jsx("option",{value:h,disabled:!yt(h,be,et),className:"dark:bg-slate-700 dark:text-slate-100",children:wt(h)},h))]}),g.jsxs("select",{"aria-label":I,disabled:v,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",value:fe?be:"",onChange:h=>Q(le,Number(h.target.value),et),children:[fe?null:g.jsx("option",{value:"",disabled:!0,className:St,children:D(be)}),se.map(h=>g.jsx("option",{value:h,disabled:!yt(le,h,et),className:"dark:bg-slate-700 dark:text-slate-100",children:D(h)},h))]}),g.jsxs("select",{"aria-label":te,disabled:v,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",value:fe?et:"",onChange:h=>Q(le,be,Number(h.target.value)),children:[fe?null:g.jsx("option",{value:"",disabled:!0,className:St,children:ar(et)}),ce.map(h=>g.jsx("option",{value:h,className:"dark:bg-slate-700 dark:text-slate-100",children:ar(h)},h))]})]}):g.jsx("input",{"aria-label":p,disabled:v,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",value:or,min:A,max:x,onChange:Fe,type:"date"}),g.jsx("button",{type:"button","aria-label":ee,disabled:ge,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",onClick:xe,children:g.jsx("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"})}),a]})},Ft=e=>e===void 0?null:Ze(e).getTime(),Zn=o.memo(Ja,(e,t)=>!(Ft(e.value??e.initialDate)!==Ft(t.value??t.initialDate)||Ft(e.minDate)!==Ft(t.minDate)||Ft(e.maxDate)!==Ft(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));Zn.displayName="DateSelector";function Ke(e,t){const r=e+Math.floor(t/12),n=(t%12+12)%12,a=new Date(r,n,1);return a.setFullYear(r),a}function pt(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}`}function Lr(e,t){if(e!==void 0&&(!(e instanceof Date)||Number.isNaN(e.getTime())))throw new RangeError(`MonthSelector: \`${t}\` must be a valid Date, received ${String(e)}.`)}function En(e,t){if(e!==void 0&&!Number.isInteger(e))throw new RangeError(`MonthSelector: \`${t}\` must be an integer year, received ${String(e)}.`)}function Za(e){if(e!==void 0)try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{throw new RangeError(`MonthSelector: \`locale\` must be a valid BCP 47 language tag, received ${JSON.stringify(e)}.`)}}function Qa(e,t){const r=e===void 0?null:Ke(e,0),n=t===void 0?null:Ke(t.getFullYear(),t.getMonth());return r!==null&&n!==null?r>=n?r:n:r!==null?r:n}function eo(e,t){const r=e===void 0?null:Ke(e,11),n=t===void 0?null:Ke(t.getFullYear(),t.getMonth());return r!==null&&n!==null?r<=n?r:n:r!==null?r:n}function Qn(e,t){return{label:Oe("month",e,void 0,t),value:pt(e)}}function to(e,t,r){const n=e.getFullYear()*12+e.getMonth(),a=t.getFullYear()*12+t.getMonth(),s=[];for(let i=a;i>=n;i--)s.push(Qn(Ke(Math.floor(i/12),i%12),r));return s}const ro=e=>{const{value:t,initialDate:r,onChange:n,children:a,variant:s="date",minYear:i,maxYear:u,minDate:b,maxDate:f,isWarning:P=!1,className:y="",style:d,disabled:v=!1,prevMonthAriaLabel:V="Previous month",nextMonthAriaLabel:ee="Next month",selectAriaLabel:p="Month",locale:J}=e;Za(J),Lr(t,"value"),Lr(r,"initialDate"),Lr(b,"minDate"),Lr(f,"maxDate"),En(i,"minYear"),En(u,"maxYear");const I=t??r;if(I===void 0)throw new RangeError("MonthSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected month is never inferred from the wall clock.");const[te,Y]=o.useState(()=>Ke(I.getFullYear(),I.getMonth())),U=t!==void 0,L=o.useMemo(()=>t!==void 0?Ke(t.getFullYear(),t.getMonth()):te,[t?.getTime(),te]),_=b?.getTime(),H=f?.getTime(),w=o.useMemo(()=>Qa(i,b),[i,_]),$=o.useMemo(()=>eo(u,f),[u,H]);if(w!==null&&$!==null&&w>$)throw new RangeError(`MonthSelector: the resolved lower bound ${pt(w)} is after the resolved upper bound ${pt($)}.`);if(s==="dropdown"&&(w===null||$===null))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.');const N=w!==null&&L<w||$!==null&&L>$,O=I.getTime();o.useEffect(()=>{if(U)return;const R=Ke(I.getFullYear(),I.getMonth());Y(xe=>xe.getTime()===R.getTime()?xe:R)},[U,O]);const k=R=>(w===null||R>=w)&&($===null||R<=$),re=R=>{if(v)return;if(!k(R))throw new RangeError(`MonthSelector: refusing to emit ${pt(R)}, which lies outside the declared bounds.`);U||Y(R);const xe=R.getFullYear()*100+(R.getMonth()+1);n?.(R,xe)},ye=o.useMemo(()=>{const R=Ke(L.getFullYear(),L.getMonth()-1);return k(R)?R:null},[L,w?.getTime(),$?.getTime()]),Z=o.useMemo(()=>{const R=Ke(L.getFullYear(),L.getMonth()+1);return k(R)?R:null},[L,w?.getTime(),$?.getTime()]),ne=v||ye===null,ie=v||Z===null,me=()=>{ye!==null&&re(ye)},W=()=>{Z!==null&&re(Z)},K=R=>{if(!R)return;const[xe,Fe]=R.split("-"),Qe=Number(xe),le=Number(Fe)-1;if(!(Number.isInteger(Qe)&&Number.isInteger(le)))return;const be=Ke(Qe,le);k(be)&&re(be)},ke=R=>{K(R.target.value)},bt=R=>{K(R.target.value)},He=pt(L),Re=w?pt(w):void 0,fe=$?pt($):void 0,j=o.useMemo(()=>{if(s!=="dropdown"||w===null||$===null)return[];const R=to(w,$,J);if(!N)return R;const xe=Qn(L,J);return[...R,xe].sort((Fe,Qe)=>Qe.value.localeCompare(Fe.value))},[s,w?.getTime(),$?.getTime(),N,L,J]),B=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",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 ${B}`,ge=`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 ${B}`;return g.jsxs("div",{className:`inline-flex w-38 items-center ${y}`,style:d,children:[g.jsx("button",{type:"button","aria-label":V,disabled:ne,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",onClick:me,children:g.jsx("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"})}),s==="dropdown"?g.jsx("select",{"aria-label":p,disabled:v,className:ge,value:He,onChange:bt,children:j.map(R=>g.jsx("option",{value:R.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:R.label},R.value))}):g.jsx("input",{"aria-label":p,disabled:v,className:G,value:He,min:Re,max:fe,onChange:ke,type:"month"}),g.jsx("button",{type:"button","aria-label":ee,disabled:ie,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",onClick:W,children:g.jsx("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"})}),a]})},ea=o.memo(ro,(e,t)=>{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;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;const i=e.minDate?e.minDate.getFullYear()*12+e.minDate.getMonth():null,u=t.minDate?t.minDate.getFullYear()*12+t.minDate.getMonth():null;if(i!==u)return!1;const b=e.maxDate?e.maxDate.getFullYear()*12+e.maxDate.getMonth():null,f=t.maxDate?t.maxDate.getFullYear()*12+t.maxDate.getMonth():null;return!(b!==f||e.onChange!==t.onChange||e.children!==t.children||e.prevMonthAriaLabel!==t.prevMonthAriaLabel||e.nextMonthAriaLabel!==t.nextMonthAriaLabel||e.selectAriaLabel!==t.selectAriaLabel||e.locale!==t.locale)});ea.displayName="MonthSelector";function rr(e,t,r){if(!(r instanceof Date)||Number.isNaN(r.getTime()))throw new RangeError(`${e}: ${t} is required and must be a valid Date (received: ${String(r)})`)}function en(e,t,r){if(rr(e,"minDate",t),rr(e,"maxDate",r),r.getTime()<=t.getTime())throw new RangeError(`${e}: maxDate must be strictly later than minDate (minDate: ${t.toISOString()}, maxDate: ${r.toISOString()})`)}function Kr(e,t,r){if(!Array.isArray(r)||r.length!==2)throw new RangeError(`${e}: ${t} is required and must be a [lower, upper] Date tuple (received: ${String(r)})`);if(rr(e,`${t}[0]`,r[0]),rr(e,`${t}[1]`,r[1]),r[0].getTime()>r[1].getTime())throw new RangeError(`${e}: ${t} upper must not be earlier than lower (lower: ${r[0].toISOString()}, upper: ${r[1].toISOString()})`)}function Wr(e,t,r,n,a,s){if(r.getTime()<n.getTime()||r.getTime()>a.getTime())throw new RangeError(`${e}: ${t} must lie within ${s} (value: ${r.toISOString()}, lower: ${n.toISOString()}, upper: ${a.toISOString()})`)}function Gr(e,t,r,n,a,s){Wr(e,`${t}[0]`,r[0],n,a,s),Wr(e,`${t}[1]`,r[1],n,a,s)}function Ue(e,t,r){return e<t?t:e>r?r:e}function Rr(e,t,r,n){const a=ot(t,r,n[1]);return[Ue(e[0],n[0],a),Ue(e[1],n[0],a)]}function Jr(e,t,r,n){const a=De(e,r,t)+n;return e[Math.max(0,Math.min(e.length-1,a))]}function tn(e){const t=o.useRef(e),r=t.current,n=e,a=Object.keys(r),s=Object.keys(n);return a.length===s.length&&s.every(u=>Object.is(r[u],n[u]))||(t.current=e),t.current}function no(e){const{unit:t,minDate:r,maxDate:n,initialRange:a,onChangeRange:s,...i}=e;en("usePeriodSliderRange",r,n),Kr("usePeriodSliderRange","initialRange",a),Gr("usePeriodSliderRange","initialRange",a,r,n,"[minDate, maxDate]");const u=tn(i),b=o.useRef(a),[f,P]=o.useState(a);let y=f;const d=[Ue(f[0],r,n),Ue(f[1],r,n)];(d[0]!==f[0]||d[1]!==f[1])&&(y=d,P(d));const v=o.useRef(y);v.current=y;const V=o.useRef({minDate:r,maxDate:n,allowedDates:u.allowedDates});V.current={minDate:r,maxDate:n,allowedDates:u.allowedDates};const ee=o.useRef(s);ee.current=s;const p=o.useCallback(w=>{const{minDate:$,maxDate:N}=V.current,O=Ue(w[0],$,N),k=Ue(w[1],$,N),re=v.current;O.getTime()===re[0].getTime()&&k.getTime()===re[1].getTime()||(v.current=[O,k],P([O,k]),ee.current?.(O,k))},[]),J=o.useCallback(w=>{const $=v.current,N=w.getTime()>$[1].getTime()?w:$[1];p([w,N])},[p]),I=o.useCallback(w=>{const $=v.current,N=w.getTime()<$[0].getTime()?w:$[0];p([N,w])},[p]),te=o.useCallback((w,$)=>{p([w,$])},[p]),Y=o.useCallback(w=>{const{minDate:$,maxDate:N,allowedDates:O}=V.current,k=v.current,re=Vt(O,t,$,N);if(re.length>0){p([Jr(re,t,k[0],w),Jr(re,t,k[1],w)]);return}p([Ie(t,k[0],w),Ie(t,k[1],w)])},[t,p]),U=o.useCallback(()=>{p(b.current)},[p]),L=o.useMemo(()=>({value:y[0],onChange:J,minDate:r,maxDate:y[1],unit:t}),[y[0],y[1],J,r,t]),_=o.useMemo(()=>({value:y[1],onChange:I,minDate:y[0],maxDate:n,unit:t}),[y[0],y[1],I,n,t]),H=o.useMemo(()=>({...u,mode:"range",unit:t,range:y,minDate:r,maxDate:n,onChangeRange:te}),[u,t,y,r,n,te]);return{range:y,lowerDate:y[0],upperDate:y[1],setRange:P,setLowerDate:J,setUpperDate:I,shiftRange:Y,resetRange:U,startSelectorProps:L,endSelectorProps:_,sliderProps:H}}function ao(e){const{unit:t,minDate:r,maxDate:n,initialValue:a,onChangePoint:s,...i}=e;en("usePeriodSliderPoint",r,n),rr("usePeriodSliderPoint","initialValue",a),Wr("usePeriodSliderPoint","initialValue",a,r,n,"[minDate, maxDate]");const u=tn(i),b=o.useRef(a),[f,P]=o.useState(a);let y=f;const d=Ue(f,r,n);d!==f&&(y=d,P(d));const v=o.useRef(y);v.current=y;const V=o.useRef({minDate:r,maxDate:n,allowedDates:u.allowedDates});V.current={minDate:r,maxDate:n,allowedDates:u.allowedDates};const ee=o.useRef(s);ee.current=s;const p=o.useCallback(U=>{const{minDate:L,maxDate:_}=V.current,H=Ue(U,L,_);H.getTime()!==v.current.getTime()&&(v.current=H,P(H),ee.current?.(H))},[]),J=o.useCallback(U=>{const{minDate:L,maxDate:_,allowedDates:H}=V.current,w=Vt(H,t,L,_);if(w.length>0){p(Jr(w,t,v.current,U));return}p(Ie(t,v.current,U))},[t,p]),I=o.useCallback(()=>{p(b.current)},[p]),te=o.useMemo(()=>({value:y,onChange:p,minDate:r,maxDate:n,unit:t}),[y,p,r,n,t]),Y=o.useMemo(()=>({...u,mode:"point",unit:t,value:y,minDate:r,maxDate:n,onChangePoint:p}),[u,t,y,r,n,p]);return{value:y,setValue:P,shiftValue:J,resetValue:I,selectorProps:te,sliderProps:Y}}function oo(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:a,initialMicroRange:s,macroUnit:i=t,microUnit:u=t,onChangeMacroRange:b,onChangeMicroRange:f,...P}=e;en("useVernierSlider",r,n),Kr("useVernierSlider","initialMacroRange",a),Kr("useVernierSlider","initialMicroRange",s),Gr("useVernierSlider","initialMacroRange",a,r,n,"[minDate, maxDate]"),Gr("useVernierSlider","initialMicroRange",s,a[0],ot(i,u,a[1]),"the initial macro window");const y=tn(P),d=o.useRef(a),v=o.useRef(s),[V,ee]=o.useState(a),[p,J]=o.useState(s);let I=V;const te=[Ue(V[0],r,n),Ue(V[1],r,n)];(te[0]!==V[0]||te[1]!==V[1])&&(I=te,ee(te));let Y=p;const U=Rr(p,i,u,I);(U[0]!==p[0]||U[1]!==p[1])&&(Y=U,J(U));const L=o.useRef(I);L.current=I;const _=o.useRef(Y);_.current=Y;const H=o.useRef({minDate:r,maxDate:n});H.current={minDate:r,maxDate:n};const w=o.useRef(b);w.current=b;const $=o.useRef(f);$.current=f;const N=o.useCallback((j,B)=>{const G=L.current,ge=_.current;(j[0].getTime()!==G[0].getTime()||j[1].getTime()!==G[1].getTime())&&(L.current=j,ee(j),w.current?.(j[0],j[1])),(B[0].getTime()!==ge[0].getTime()||B[1].getTime()!==ge[1].getTime())&&(_.current=B,J(B),$.current?.(B[0],B[1]))},[]),O=o.useCallback((j,B)=>{const{minDate:G,maxDate:ge}=H.current,R=[Ue(j,G,ge),Ue(B,G,ge)];N(R,Rr(_.current,i,u,R))},[i,u,N]),k=o.useCallback((j,B)=>{N(L.current,Rr([j,B],i,u,L.current))},[i,u,N]),re=o.useCallback(j=>{const B=L.current[1],G=j>B?j:B;O(j,G)},[O]),ye=o.useCallback(j=>{const B=L.current[0],G=j<B?j:B;O(G,j)},[O]),Z=o.useCallback(j=>{const B=_.current[1],G=j>B?j:B;k(j,G)},[k]),ne=o.useCallback(j=>{const B=_.current[0],G=j<B?j:B;k(G,j)},[k]),ie=o.useCallback(j=>{const{minDate:B,maxDate:G}=H.current,ge=L.current,R=Ie(i,ge[0],j),xe=Ie(i,ge[1],j);R<B||xe>G||O(R,xe)},[i,O]),me=o.useCallback(j=>{const B=L.current,G=_.current,ge=Ie(u,G[0],j),R=Ie(u,G[1],j);ge<B[0]||R>ot(i,u,B[1])||k(ge,R)},[i,u,k]),W=o.useCallback(()=>{const j=d.current;N(j,Rr(v.current,i,u,j))},[i,u,N]),K=o.useMemo(()=>ot(i,u,I[1]),[i,u,I[1]]),ke=o.useMemo(()=>({value:I[0],onChange:re,minDate:r,maxDate:I[1],unit:i}),[I,re,r,i]),bt=o.useMemo(()=>({value:I[1],onChange:ye,minDate:I[0],maxDate:n,unit:i}),[I,ye,n,i]),He=o.useMemo(()=>({value:Y[0],onChange:Z,minDate:I[0],maxDate:Y[1],unit:u}),[Y,Z,I,u]),Re=o.useMemo(()=>({value:Y[1],onChange:ne,minDate:Y[0],maxDate:K,unit:u}),[Y,ne,K,u]),fe=o.useMemo(()=>({...y,mode:"vernier",unit:t,macroUnit:i,microUnit:u,minDate:r,maxDate:n,macroRange:I,microRange:Y,onChangeMacroRange:O,onChangeMicroRange:k}),[y,t,i,u,r,n,I,Y,O,k]);return{macroRange:I,setMacroRange:ee,microRange:Y,setMicroRange:J,setMacroLowerDate:re,setMacroUpperDate:ye,setMicroLowerDate:Z,setMicroUpperDate:ne,shiftMacroRange:ie,shiftMicroRange:me,resetVernier:W,macroStartSelectorProps:ke,macroEndSelectorProps:bt,microStartSelectorProps:He,microEndSelectorProps:Re,sliderProps:fe}}function In(e){const t=new Date(e,0,1);return t.setFullYear(e),t}function $r(e,t){if(e!==void 0&&(!(e instanceof Date)||Number.isNaN(e.getTime())))throw new RangeError(`YearSelector: \`${t}\` must be a valid Date, received ${String(e)}.`)}function Hn(e,t){if(e!==void 0&&!Number.isInteger(e))throw new RangeError(`YearSelector: \`${t}\` must be an integer year, received ${String(e)}.`)}function io(e){if(e!==void 0)try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{throw new RangeError(`YearSelector: \`locale\` must be a valid BCP 47 language tag, received ${JSON.stringify(e)}.`)}}function jn(e,t,r){const n=e===void 0?null:e,a=t===void 0?null:t.getFullYear();return n!==null&&a!==null?r(n,a):n!==null?n:a}const lo=e=>{const{value:t,initialDate:r,onChange:n,children:a,minYear:s,maxYear:i,minDate:u,maxDate:b,className:f="",style:P,disabled:y=!1,prevYearAriaLabel:d="Previous year",nextYearAriaLabel:v="Next year",selectAriaLabel:V="Year",locale:ee}=e;$r(t,"value"),$r(r,"initialDate"),$r(u,"minDate"),$r(b,"maxDate"),Hn(s,"minYear"),Hn(i,"maxYear"),io(ee);const p=t??r;if(p===void 0)throw new RangeError("YearSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected year is never inferred from the wall clock.");const[J,I]=o.useState(()=>p.getFullYear()),te=u?.getTime(),Y=b?.getTime(),U=o.useMemo(()=>jn(s,u,Math.max),[s,te]),L=o.useMemo(()=>jn(i,b,Math.min),[i,Y]);if(U===null||L===null)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.");if(U>L)throw new RangeError(`YearSelector: the resolved lower bound ${U} is after the resolved upper bound ${L}.`);const _=t!==void 0,H=t!==void 0?t.getFullYear():J,w=H<U||H>L,$=p.getTime();o.useEffect(()=>{_||I(p.getFullYear())},[_,$]);const N=W=>W>=U&&W<=L,O=W=>{if(!y){if(!N(W))throw new RangeError(`YearSelector: refusing to emit ${W}, which lies outside the declared bounds ${U}-${L}.`);_||I(W),n?.(In(W),W)}},k=N(H-1)?H-1:null,re=N(H+1)?H+1:null,ye=y||k===null,Z=y||re===null,ne=()=>{k!==null&&O(k)},ie=()=>{re!==null&&O(re)},me=o.useMemo(()=>{const W=[];for(let K=L;K>=U;K--)W.push(K);return w&&(W.push(H),W.sort((K,ke)=>ke-K)),W},[U,L,w,H]);return g.jsxs("div",{className:`inline-flex w-32 items-center ${f}`,style:P,children:[g.jsx("button",{type:"button","aria-label":d,disabled:ye,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",onClick:ne,children:g.jsx("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"})}),g.jsx("select",{"aria-label":V,disabled:y,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",value:H,onChange:W=>{if(!W.target.value)return;const K=Number(W.target.value);Number.isInteger(K)&&O(K)},children:me.map(W=>g.jsx("option",{value:W,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:Oe("year",In(W),void 0,ee)},W))}),g.jsx("button",{type:"button","aria-label":v,disabled:Z,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",onClick:ie,children:g.jsx("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"})}),a]})},ta=o.memo(lo,(e,t)=>{const r=e.value??e.initialDate,n=t.value??t.initialDate,a=r?r.getFullYear():null,s=n?n.getFullYear():null;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)});ta.displayName="YearSelector";exports.COLOR_SCHEME_PALETTES=On;exports.DateSelector=Zn;exports.MonthSelector=ea;exports.PeriodSlider=Jn;exports.YearSelector=ta;exports.addUnit=Ie;exports.areStylesEqual=Gn;exports.calculateConnectDragValues=Vn;exports.calculateHandleDragValues=qr;exports.calculateKeyboardActionValues=Un;exports.calculateLabelSlant=Qr;exports.calculateVernierMacroDrag=Kn;exports.calculateVernierMicroDrag=Wn;exports.decode=oe;exports.encode=q;exports.findNearestDateIndex=De;exports.formatLabel=Oe;exports.formatScreenReaderLabel=vt;exports.getActiveDragHandle=Fn;exports.getMacroWindowEndDate=ot;exports.getSortedAllowedDates=Vt;exports.normalizeDateByUnit=qe;exports.resolveVernierTargetHandle=qn;exports.usePeriodSliderPoint=ao;exports.usePeriodSliderRange=no;exports.useVernierSlider=oo;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react/jsx-runtime"),Re=require("date-fns"),o=require("react"),Fn={"blue-rose":{macro:"#0284c7",macroLight:"#38bdf8",micro:"#e11d48",microLight:"#fb7185",accent:"#0284c7"},"indigo-amber":{macro:"#4f46e5",macroLight:"#818cf8",micro:"#d97706",microLight:"#fbbf24",accent:"#4f46e5"},"teal-emerald":{macro:"#0d9488",macroLight:"#2dd4bf",micro:"#059669",microLight:"#34d399",accent:"#0d9488"},"violet-fuchsia":{macro:"#7c3aed",macroLight:"#a78bfa",micro:"#c026d3",microLight:"#e879f9",accent:"#7c3aed"},"slate-sky":{macro:"#475569",macroLight:"#94a3b8",micro:"#0284c7",microLight:"#38bdf8",accent:"#475569"},monochrome:{macro:"#52525b",macroLight:"#a1a1aa",micro:"#18181b",microLight:"#71717a",accent:"#27272a"}},st=e=>e instanceof Date&&!Number.isNaN(e.getTime()),we=e=>e instanceof Date?Number.isNaN(e.getTime())?"Invalid Date":e.toISOString():String(e),Ke=(e,t)=>{if(!st(t))throw new RangeError(`normalizeDateByUnit: d must be a valid Date (received: ${we(t)})`);const r=new Date(t.getTime());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},G=(e,t)=>{const r=Ke(e,t),n=r.getFullYear(),a=r.getMonth()+1,s=r.getDate();if(e==="year")return n;if(e==="month")return n*12+(a-1);const l=new Date(0);return l.setUTCFullYear(n,a-1,s),l.setUTCHours(0,0,0,0),Math.floor(l.getTime()/(1440*60*1e3))},se=(e,t)=>{const r=new Date(0);if(r.setHours(0,0,0,0),e==="year")return r.setFullYear(t,0,1),r;if(e==="month"){const a=Math.floor(t/12),s=t-a*12;return r.setFullYear(a,s,1),r}const n=new Date(t*24*60*60*1e3);return r.setFullYear(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate()),r},He=(e,t,r)=>{if(!st(t))throw new RangeError(`addUnit: d must be a valid Date (received: ${we(t)})`);return e==="year"?Re.addYears(t,r):e==="month"?Re.addMonths(t,r):Re.addDays(t,r)},lt=(e,t,r)=>{if(!st(r))throw new RangeError(`getMacroWindowEndDate: d must be a valid Date (received: ${we(r)})`);if(e===t)return Ke(t,r);const n=r.getFullYear(),a=r.getMonth();if(e==="year"){if(t==="month")return new Date(n,11,1);if(t==="day")return new Date(n,11,31)}return e==="month"&&t==="day"?new Date(n,a+1,0):Ke(t,r)},ka={year:{year:"numeric"},month:{year:"numeric",month:"2-digit"},day:{year:"numeric",month:"2-digit",day:"2-digit"}},kn=new Map,Pa=(e,t)=>{const r=`${e}\0${t}`,n=kn.get(r);if(n!==void 0)return n;const a=new Intl.DateTimeFormat(t,ka[e]);return kn.set(r,a),a},Ca=(e,t)=>{const r=String(t.getFullYear()).padStart(4,"0");if(e==="year")return r;const n=String(t.getMonth()+1).padStart(2,"0");if(e==="month")return`${r}-${n}`;const a=String(t.getDate()).padStart(2,"0");return`${r}-${n}-${a}`},Ie=(e,t,r,n)=>st(t)?r?r(t):n===void 0?Ca(e,t):Pa(e,n).format(t):"",Dt=(e,t,r,n)=>Ie(e,t,r,n),ye=(e,t,r)=>{if(!e||e.length===0||e.length===1)return 0;const n=G(r,t);let a=0,s=e.length-1;if(n<=G(r,e[a]))return 0;if(n>=G(r,e[s]))return s;for(;a<=s;){const b=a+s>>1,f=G(r,e[b]);if(f===n)return b;f<n?a=b+1:s=b-1}const l=Math.abs(G(r,e[a])-n),u=Math.abs(G(r,e[s])-n);return l<u?a:s},Bt=(e,t,r,n)=>{if(!Array.isArray(e)||e.length===0)return[];const a=G(t,r),s=G(t,n),l=new Map;for(const u of e){const b=Ke(t,u),f=G(t,b);f<a||f>s||l.has(f)||l.set(f,b)}if(l.size===0)throw new RangeError(`getSortedAllowedDates: every allowedDates entry falls outside [minDate, maxDate] (minDate: ${we(r)}, maxDate: ${we(n)}, entries: ${e.length})`);return Array.from(l.keys()).sort((u,b)=>u-b).map(u=>l.get(u))},Tr=(e,t,r,n)=>{const a=e.length-1;if(a<=0)return 0;const s=ye(e,n,t);if(r==="time"){const l=e[0].getTime(),u=e[a].getTime()-l;return u<=0?0:Math.max(0,Math.min(1,(e[s].getTime()-l)/u))}return s/a},Sr=(e,t,r,n)=>{const a=e.length-1;if(a<=0)return 0;const s=Math.max(0,Math.min(1,n));if(r==="time"){const l=e[0].getTime(),u=e[a].getTime()-l;return u<=0?0:ye(e,new Date(l+s*u),t)}return Math.max(0,Math.min(a,Math.round(s*a)))},qr=(e,t,r,n,a,s,l)=>{let u=r,b=n;return l?(u=t,b=t):e==="low"?t>n?(u=n,b=t):u=t:t<r?(b=r,u=t):b=t,[Math.max(a,Math.min(s,u)),Math.max(a,Math.min(s,b))]},Vn=(e,t,r,n,a)=>a?"low":e==="low"?t>n?"high":"low":t<r?"low":"high",Un=({posDiffPct:e,startLowVal:t,startHighVal:r,rangeMin:n,rangeMax:a,isDiscrete:s,sortedAllowedDates:l,snapMode:u,unit:b})=>{if(s){const H=l.length-1;if(H<=0)return[0,0];const te=Math.max(0,Math.min(H,Math.round(t))),T=Math.max(te,Math.min(H,Math.round(r)));if(u==="time"){const Y=l[0].getTime(),B=l[H].getTime(),C=l[te].getTime(),F=l[T].getTime()-C;let O=C+e*(B-Y),x=O+F;O<Y&&(O=Y,x=Y+F),x>B&&(x=B,O=B-F);const P=ye(l,new Date(O),b),v=ye(l,new Date(x),b);return[P,Math.max(P,v)]}const re=Math.round(e*H);let j=te+re,J=T+re;return j<0&&(J+=-j,j=0),J>H&&(j-=J-H,J=H),[Math.max(0,Math.min(H,j)),Math.max(0,Math.min(H,J))]}const f=H=>Math.max(n,Math.min(a,H)),D=a-n;if(D<=0)return[f(t),f(r)];const y=Math.round(e*D);let d=t+y,L=r+y;return d<n&&(L+=n-d,d=n),L>a&&(d-=L-a,L=a),[f(d),f(L)]},Bn=(e,t,r,n,a,s,l,u)=>{let b=0,f=!1,D=!1;switch(e){case"ArrowRight":case"ArrowUp":b=u;break;case"ArrowLeft":case"ArrowDown":b=-u;break;case"PageUp":b=u*5;break;case"PageDown":b=-u*5;break;case"Home":f=!0;break;case"End":D=!0;break;default:return null}if(l){let L=r;return f?L=a:D?L=s:L=Math.max(a,Math.min(s,r+b)),[L,L]}let y=r,d=n;return t==="low"?f?y=a:D?y=n:y=Math.max(a,Math.min(n,r+b)):f?d=r:D?d=s:d=Math.max(r,Math.min(s,n+b)),[y,d]},zn=8,_n=2,Xn=16,Na=12,Ya=90,Zr=(e,t)=>{const r=t?.estimatedHeightPx??Xn,a=zn+(t?.anchorGapY??_n)+r/2,s=e==="top"?-a:a;return{lowAngleDeg:0,highAngleDeg:0,lowOffsetX:0,highOffsetX:0,lowOffsetY:s,highOffsetY:s,isSlanted:!1,proximity:0}},Qr=(e,t,r,n="top",a)=>{const s=a?.estimatedWidthPx,l=a?.estimatedHeightPx??Xn,u=a?.paddingPx??Na,b=a?.maxAngleDeg??Ya,f=zn+(a?.anchorGapY??_n),D=Zr(n,a);if(!(Number.isFinite(r)&&r>0)||s===void 0||!Number.isFinite(s)||s<=0)return D;const y=Math.max(0,t-e)/100*r,d=s+u;if(y>=d)return D;const L=Math.max(0,Math.min(1,(d-y)/d)),te=L*L*L*(L*(L*6-15)+10)*b,T=n==="top"?-te:te,re=te*Math.PI/180,j=s/2*Math.abs(Math.sin(re))+l/2*Math.abs(Math.cos(re)),J=f+j,Y=n==="top"?-J:+J,B=s*Math.abs(Math.cos(re))+l*Math.abs(Math.sin(re)),C=Math.max(0,(B+u-y)/2);return{lowAngleDeg:T,highAngleDeg:T,lowOffsetX:-C,highOffsetX:C,lowOffsetY:Y,highOffsetY:Y,isSlanted:L>.001,proximity:L}},qn=e=>({...e,lowOffsetX:0,highOffsetX:0});function Kn(e,t,r,n,a,s,l="macro-top",u=.05,b=!0){const f=l==="macro-top"||l==="macro-left",D=t<=0;if(f&&D||!(f||D)){const L=Math.abs(e-r),H=Math.abs(e-n);return L<=u&&L<=H?"macro-low":H<=u&&H<L?"macro-high":b&&e>=r&&e<=n?"macro-connect":L<H?"macro-low":"macro-high"}const y=Math.abs(e-a),d=Math.abs(e-s);return y<=u&&y<=d?"micro-low":d<=u&&d<y?"micro-high":b&&e>=a&&e<=s?"micro-connect":y<d?"micro-low":"micro-high"}function Wn(e,t,r,n,a){if(e==="macro-connect"){const l=t-r,u=a-n,b=Math.max(0,Math.min(1-u,n+l)),f=b+u;return[b,f,"macro-connect"]}if(e==="macro-low"){const l=Math.max(0,Math.min(1,t));return l>a?[a,l,"macro-high"]:[l,a,"macro-low"]}const s=Math.max(0,Math.min(1,t));return s<n?[s,n,"macro-low"]:[n,s,"macro-high"]}function Gn(e,t,r,n,a){if(e==="micro-connect"){const l=t-r,u=a-n,b=Math.max(0,Math.min(1-u,n+l)),f=b+u;return[b,f,"micro-connect"]}if(e==="micro-low"){const l=Math.max(0,Math.min(1,t));return l>a?[a,l,"micro-high"]:[l,a,"micro-low"]}const s=Math.max(0,Math.min(1,t));return s<n?[s,n,"micro-low"]:[n,s,"micro-high"]}const rr=o.memo(({type:e,isTop:t=!0,isVertical:r=!1,isLeft:n=!0})=>{let a,s;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"}`);const l=e==="macro"?"period-slider-knob-path-macro":"period-slider-knob-path-micro";return g.jsx("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:g.jsx("path",{d:a,className:l,shapeRendering:"geometricPrecision",strokeWidth:"1.25"})})});rr.displayName="VernierKnobSvg";const Aa=(e,t)=>{if(!st(e))throw new RangeError(`PeriodSlider: minDate is required and must be a valid Date (received: ${we(e)})`);if(!st(t))throw new RangeError(`PeriodSlider: maxDate is required and must be a valid Date (received: ${we(t)})`);if(t.getTime()<=e.getTime())throw new RangeError(`PeriodSlider: maxDate must be strictly later than minDate (minDate: ${we(e)}, maxDate: ${we(t)})`)},kr=(e,t)=>{if(!Array.isArray(t)||t.length!==2)throw new RangeError(`PeriodSlider: ${e} is required and must be a [start, end] Date tuple (received: ${we(t)})`);const[r,n]=t;if(!st(r))throw new RangeError(`PeriodSlider: ${e}[0] must be a valid Date (received: ${we(r)})`);if(!st(n))throw new RangeError(`PeriodSlider: ${e}[1] must be a valid Date (received: ${we(n)})`);if(n.getTime()<r.getTime())throw new RangeError(`PeriodSlider: ${e} must not be inverted (start: ${we(r)}, end: ${we(n)})`)},Ea=(e,t)=>{if(!st(t))throw new RangeError(`PeriodSlider: ${e} must be a valid Date (received: ${we(t)})`)},Ur=(e,t,r,n)=>{if(t.getTime()<r.getTime()||t.getTime()>n.getTime())throw new RangeError(`PeriodSlider: ${e} must lie within [minDate, maxDate] (received: ${we(t)}, minDate: ${we(r)}, maxDate: ${we(n)})`)},Ia=(e,t,r)=>{if(e.mode==="range"){for(const n of["range","defaultRange"]){const a=e[n];a!==void 0&&(kr(n,a),Ur(`${n}[0]`,a[0],t,r),Ur(`${n}[1]`,a[1],t,r))}return}if(e.mode==="point")for(const n of["value","defaultValue"]){const a=e[n];a!==void 0&&(Ea(n,a),Ur(n,a,t,r))}},Ha=(e,t,r)=>{if(kr("macroRange",e),t!==void 0)return kr("microRange",t),t;if(r!==void 0)return kr("defaultMicroRange",r),r;throw new RangeError("PeriodSlider: vernier mode requires a micro selection; supply microRange (controlled) or defaultMicroRange (uncontrolled)")},Lr=(e,t,r,n,a,s,l,u)=>{const b=ye(e,n,t),f=ye(e,a,t);return l?b:u?f:Math.max(b,Math.min(f,ye(e,r,t)+s))},Br=e=>{e.timerId!==null&&clearTimeout(e.timerId),e.timerId=null,e.emit=null},ja=(e,t)=>{try{Intl.DateTimeFormat.supportedLocalesOf([t])}catch{throw new RangeError(`PeriodSlider: ${e} must be a valid BCP 47 language tag (received: ${JSON.stringify(t)})`)}},Vt=()=>{const[e,t]=o.useState(null),r=o.useRef(null),n=o.useCallback(a=>{if(r.current?.disconnect(),r.current=null,a===null){t(null);return}if(typeof ResizeObserver>"u")return;const s=new ResizeObserver(l=>{for(const u of l){const b=u.borderBoxSize?.[0];b!==void 0&&t(f=>f!==null&&Math.abs(f.widthPx-b.inlineSize)<.5&&Math.abs(f.heightPx-b.blockSize)<.5?f:{widthPx:b.inlineSize,heightPx:b.blockSize})}});s.observe(a),r.current=s},[]);return o.useEffect(()=>()=>{r.current?.disconnect(),r.current=null},[]),[n,e]},zr=(e,t)=>{if(!(e===null||t===null))return{estimatedWidthPx:Math.max(e.widthPx,t.widthPx),estimatedHeightPx:Math.max(e.heightPx,t.heightPx)}},Pn=(e,t,r)=>({"--ps-tooltip-tx":`calc(-50% + ${e}px)`,"--ps-tooltip-ty":`${t}px`,"--ps-tooltip-rot":`${r}deg`}),Cn=(e,t,r,n,a,s,l)=>{const u=Zr(n,a);if(!l)return{slant:u,lowStyle:void 0,highStyle:void 0};const b=Qr(e*100,t*100,r,n,a),f=s?qn(b):b;return{slant:f,lowStyle:Pn(f.lowOffsetX,f.lowOffsetY-u.lowOffsetY,f.lowAngleDeg),highStyle:Pn(f.highOffsetX,f.highOffsetY-u.highOffsetY,f.highAngleDeg)}},Oa={horizontal:{decrease:"◀",increase:"▶"},vertical:{decrease:"▼",increase:"▲"}},Fa={horizontal:{decrease:"period-slider-stepper-prev",increase:"period-slider-stepper-next"},vertical:{decrease:"period-slider-stepper-prev period-slider-stepper-down",increase:"period-slider-stepper-next period-slider-stepper-up"}},Va=e=>{const{unit:t,minDate:r,maxDate:n,allowedDates:a,snapMode:s="index",disabled:l=!1,className:u="",showStepper:b=!0,tooltipStyle:f="always",labelPosition:D="top",autoSlantLabels:y=!0,isVertical:d=!1,hideConnectBar:L=!1,showTicks:H=!1,colorScheme:te="blue-rose",locale:T,decreaseAriaLabel:re="Decrease",increaseAriaLabel:j="Increase"}=e;Aa(r,n),Ia(e,r,n),T!==void 0&&ja("locale",T);const J=e.mode==="vernier"?Ha(e.macroRange,e.microRange,e.defaultMicroRange):null,Y=Fn[te],B=o.useId(),C=o.useRef(e);C.current=e;const F=r.getTime(),O=n.getTime(),x=o.useMemo(()=>Bt(a,t,r,n),[a,t,F,O]),P=x.length>0,{rangeMin:v,rangeMax:N}=o.useMemo(()=>P?{rangeMin:0,rangeMax:x.length-1}:{rangeMin:G(t,r),rangeMax:G(t,n)},[P,x,t,F,O]),R=e.mode==="point",ce=o.useCallback(i=>{if(P){const c=Math.max(0,Math.min(x.length-1,Math.round(i)));return x[c]}return se(t,Math.round(i))},[P,x,t]),ne=o.useCallback(i=>{if(i===void 0)return v;const c=Ke(t,i);return P?ye(x,c,t):G(t,c)},[P,x,t,v]),[Q,ae]=o.useState(()=>J),oe=e.mode!=="vernier"?null:e.microRange!==void 0?e.microRange:Q,de=e.mode==="range"?e.range?.[0]??e.defaultRange?.[0]:e.mode==="vernier"?oe?.[0]:void 0,K=e.mode==="range"?e.range?.[1]??e.defaultRange?.[1]:e.mode==="vernier"?oe?.[1]:void 0,W=e.mode==="point"?e.value??e.defaultValue:void 0,Te=e.mode==="point"?W?.getTime():de?.getTime(),Mt=e.mode==="range"?K?.getTime():Te,[Oe,$e]=o.useMemo(()=>{if(e.mode==="point"){const m=ne(W);return[m,m]}const i=ne(de),c=ne(K);return[Math.min(i,c),Math.max(i,c)]},[e.mode,Te,Mt,ne,W,de,K]),be=e.mode==="point"?e.value!==void 0:e.mode==="range"?e.range!==void 0:e.microRange!==void 0,[I,z]=o.useState(()=>[Oe,$e]),[ee,ge]=o.useState(null),[ue,We]=o.useState(null),Ge=o.useRef(null);Ge.current=ue;const[St,me]=o.useState("high"),[Me,Be]=o.useState(null),[xt,_]=o.useState(null),V=ee?ee[0]:be?Oe:I[0],ie=ee?ee[1]:be?$e:I[1],rt=o.useRef([V,ie]);rt.current=[V,ie];const Z=e.mode==="vernier",Je=e.mode==="vernier"?e.vernierOrientation??(d?"macro-left":"macro-top"):"macro-top",p=Je==="macro-top"||Je==="macro-left",or=e.mode==="vernier"?e.showVernierProjection??!0:!1,ir=e.mode==="vernier"?e.showVernierTicks??!0:!1,Lt=e.mode==="vernier"?e.showHairline??!0:!1,A=Z?e.macroUnit??t:t,M=Z?e.microUnit??t:t,Pr=Z?e.macroIsDiscrete??!1:P,Rt=Z?e.microIsDiscrete??!1:P,lr=Z?e.macroAllowedDates??a:a,Cr=Z?e.microAllowedDates??a:a,h=Z?e.formatMacroLabel??e.formatLabel:e.formatLabel,k=Z?e.formatMicroLabel??e.formatLabel:e.formatLabel,Pe=e.mode==="vernier"?e.macroRange[0].getTime():void 0,$t=e.mode==="vernier"?e.macroRange[1].getTime():void 0,vt=de?.getTime(),nt=K?.getTime(),[Ce,sr]=o.useState(null),ct=o.useRef(null);ct.current=Ce;const[Se,zt]=o.useState("micro-high"),je=o.useMemo(()=>G(A,r),[F,A]),kt=o.useMemo(()=>{const i=G(A,n);if(Z&&i<=je)throw new RangeError(`PeriodSlider: macroUnit "${A}" cannot distinguish minDate from maxDate (minDate: ${we(r)}, maxDate: ${we(n)})`);return i},[Z,F,O,je,A]),pe=o.useMemo(()=>Z?Bt(lr,A,r,n):[],[Z,lr,A,F,O]),Ne=o.useMemo(()=>e.mode!=="vernier"?je:G(A,e.macroRange[0]),[e.mode,Pe,je,A]),Ye=o.useMemo(()=>e.mode!=="vernier"?kt:G(A,e.macroRange[1]),[e.mode,$t,kt,A]),cr=o.useMemo(()=>se(A,Ne),[A,Ne]),ur=o.useMemo(()=>se(A,Ye),[A,Ye]),Le=o.useMemo(()=>e.mode!=="vernier"?G(M,r):Math.max(G(M,e.macroRange[0]),G(M,r)),[e.mode,Pe,M,F]),ze=o.useMemo(()=>e.mode!=="vernier"?G(M,n):Math.min(G(M,lt(A,M,e.macroRange[1])),G(M,n)),[e.mode,$t,A,M,O]),le=o.useMemo(()=>Z?Bt(Cr,M,r,n).filter(c=>{const m=G(M,c);return m>=Le&&m<=ze}):[],[Z,Cr,M,F,O,Le,ze]),Pt=Pr&&pe.length>0,Ze=Rt&&le.length>0,xe=o.useMemo(()=>oe===null?Le:G(M,oe[0]),[vt,Le,M,oe]),ve=o.useMemo(()=>oe===null?ze:G(M,oe[1]),[nt,ze,M,oe]),ut=o.useMemo(()=>se(M,xe),[M,xe]),dt=o.useMemo(()=>se(M,ve),[M,ve]),_t=Math.max(1,kt-je),De=Pt?Tr(pe,A,s,cr):Math.max(0,Math.min(1,(Ne-je)/_t)),Ae=Math.max(De,Pt?Tr(pe,A,s,ur):Math.min(1,(Ye-je)/_t)),Xt=Math.max(1,ze-Le),Fe=Ze?Tr(le,M,s,ut):Math.max(0,Math.min(1,(xe-Le)/Xt)),at=Math.max(Fe,Ze?Tr(le,M,s,dt):Math.min(1,(ve-Le)/Xt)),Nr=o.useRef({timerId:null,emit:null}),Yr=o.useRef({timerId:null,emit:null}),Ar=o.useRef({timerId:null,emit:null});o.useEffect(()=>{const i=[Nr,Yr,Ar];return()=>{for(const c of i)Br(c.current)}},[]);const Ct=o.useCallback((i,c,m)=>{Br(i);const{debounceMs:w}=C.current;if(m||!w||w<=0){c();return}i.emit=c,i.timerId=setTimeout(()=>{i.timerId=null,i.emit=null,c()},w)},[]),Er=o.useCallback(i=>{const c=i.emit;Br(i),c?.()},[]),Nt=o.useCallback(i=>new Date(Math.min(Math.max(i.getTime(),F),O)),[F,O]),Qe=o.useCallback((i,c,m=!1)=>{const[w,$]=rt.current;if((C.current.mode==="point"?i===w:i===w&&c===$)&&Nr.current.timerId===null)return;const X=ce(i),E=ce(c),q=()=>{const S=C.current;S.mode==="point"?S.onChangePoint?.(X):S.mode==="range"&&S.onChangeRange?.(X,E)};Ct(Nr.current,q,m)},[ce,Ct]),Yt=o.useCallback((i,c,m=!1)=>{if(C.current.mode!=="vernier")return;const w=Nt(i),$=Nt(c);Ct(Yr.current,()=>{const U=C.current;U.mode==="vernier"&&U.onChangeMacroRange?.(w,$)},m)},[Nt,Ct]),_e=o.useCallback((i,c,m=!1)=>{const w=C.current;if(w.mode!=="vernier")return;const $=Nt(i),U=Nt(c);w.microRange===void 0&&ae([$,U]),Ct(Ar.current,()=>{const X=C.current;X.mode==="vernier"&&X.onChangeMicroRange?.($,U)},m)},[Nt,Ct]),dr=o.useCallback(i=>{if(P&&s==="time"&&x.length>1){const w=Math.max(0,Math.min(x.length-1,Math.round(i))),$=x[0].getTime(),X=x[x.length-1].getTime()-$;if(X<=0)return 0;const E=x[w].getTime();return Math.max(0,Math.min(100,(E-$)/X*100))}const c=N-v;if(c<=0)return 0;const m=(i-v)/c*100;return Math.max(0,Math.min(100,m))},[P,s,x,v,N]),mr=o.useCallback(i=>{const c=Math.max(0,Math.min(100,i));if(P){if(s==="time"&&x.length>1){const $=x[0].getTime(),X=x[x.length-1].getTime()-$,E=$+c/100*X;return ye(x,new Date(E),t)}const w=Math.round(c/100*(x.length-1));return Math.max(0,Math.min(x.length-1,w))}const m=v+c/100*(N-v);return Math.round(m)},[P,s,x,v,N,t]),ot=o.useRef(null),[At,rn]=o.useState(0),[ra,qt]=Vt(),[na,nn]=Vt(),[aa,an]=Vt(),[oa,on]=Vt(),[ia,ln]=Vt(),[la,sn]=Vt();o.useEffect(()=>{const i=ot.current;if(!i)return;const c=()=>{const m=i.getBoundingClientRect(),w=d?m.height:m.width;w>0&&rn($=>Math.abs($-w)<.5?$:w)};if(c(),typeof ResizeObserver<"u"){const m=new ResizeObserver(w=>{for(const $ of w){const U=d?$.contentRect.height:$.contentRect.width;U>0&&rn(X=>Math.abs(X-U)<.5?X:U)}});return m.observe(i),()=>m.disconnect()}return window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[d]);const pt=o.useCallback((i,c,m)=>{const w=d?m.height:m.width;if(!(Number.isFinite(w)&&w>0))return null;const $=d?m.bottom-c:i-m.left;return Number.isFinite($)?Math.max(0,Math.min(1,$/w)):null},[d]),cn=o.useCallback((i,c)=>{const m=ot.current;if(!m)return null;const w=pt(i,c,m.getBoundingClientRect());return w===null?null:w*100},[pt]),fr=o.useRef(null),Ir=o.useRef(null),et=o.useRef(null),Hr=o.useRef(null),Kt=o.useRef(null),un=o.useCallback(i=>{if(l)return;if(Z){const S=Ir.current;if(!S||i.pointerId!==0&&i.pointerId!==S.pointerId||!ot.current)return;const fe=pt(i.clientX,i.clientY,ot.current.getBoundingClientRect());if(fe===null)return;if(S.handle==="macro-low"||S.handle==="macro-high"||S.handle==="macro-connect"){const[Xe,ft,ke]=Wn(S.handle,fe,S.startPointerRatio,S.startMacroLowRatio,S.startMacroHighRatio);ke!==ct.current&&(ct.current=ke,sr(ke),zt(ke));let he,qe;if(Pt){const ht=Sr(pe,A,s,Xe),bt=Math.max(ht,Sr(pe,A,s,ft));he=pe[ht],qe=pe[bt]}else{const ht=Math.round(je+Xe*_t),bt=Math.round(je+ft*_t);he=se(A,ht),qe=se(A,bt)}const Jt=`${he.getTime()}_${qe.getTime()}`;Jt!==Hr.current&&(Hr.current=Jt,Yt(he,qe));let it,gt;if(S.handle==="macro-connect"){const ht=Ke(M,he),bt=lt(A,M,qe);let jt,Ot;if(A==="year"){const wt=he.getFullYear()-S.startMacroLowDate.getFullYear();jt=He("year",S.initialMicroLowDate,wt),Ot=He("year",S.initialMicroHighDate,wt)}else if(A==="month"){const wt=(he.getFullYear()-S.startMacroLowDate.getFullYear())*12+(he.getMonth()-S.startMacroLowDate.getMonth());jt=He("month",S.initialMicroLowDate,wt),Ot=He("month",S.initialMicroHighDate,wt)}else{const wt=Math.round((he.getTime()-S.startMacroLowDate.getTime())/864e5);jt=He("day",S.initialMicroLowDate,wt),Ot=He("day",S.initialMicroHighDate,wt)}const Ft=ht.getTime(),Zt=bt.getTime(),$n=S.initialMicroHighDate.getTime()-S.initialMicroLowDate.getTime();let Qt=jt.getTime(),er=Ot.getTime();Qt<Ft&&(Qt=Ft,er=Math.min(Zt,Qt+$n)),er>Zt&&(er=Zt,Qt=Math.max(Ft,er-$n)),it=Ke(M,new Date(Qt)),gt=Ke(M,new Date(er))}else{const ht=he.getTime(),bt=lt(A,M,qe).getTime(),jt=S.initialMicroLowDate.getTime(),Ot=S.initialMicroHighDate.getTime(),Ft=Math.max(ht,Math.min(bt,jt)),Zt=Math.max(Ft,Math.min(bt,Ot));it=Ke(M,new Date(Ft)),gt=Ke(M,new Date(Zt))}const Rn=`${it.getTime()}_${gt.getTime()}`;Rn!==Kt.current&&(Kt.current=Rn,_e(it,gt))}else if(S.handle==="micro-low"||S.handle==="micro-high"||S.handle==="micro-connect"){const[Xe,ft,ke]=Gn(S.handle,fe,S.startPointerRatio,S.startMicroLowRatio,S.startMicroHighRatio);ke!==ct.current&&(ct.current=ke,sr(ke),zt(ke));let he,qe;if(Ze){const it=Sr(le,M,s,Xe),gt=Math.max(it,Sr(le,M,s,ft));he=le[it],qe=le[gt]}else{const it=Math.round(Le+Xe*Xt),gt=Math.round(Le+ft*Xt);he=se(M,it),qe=se(M,gt)}const Jt=`${he.getTime()}_${qe.getTime()}`;Jt!==Kt.current&&(Kt.current=Jt,_e(he,qe))}return}const c=fr.current;if(!c||i.pointerId!==0&&i.pointerId!==c.pointerId||!ot.current)return;const m=ot.current.getBoundingClientRect(),w=d?i.clientY:i.clientX,$=d?m.height:m.width;if(!(Number.isFinite($)&&$>0))return;if(c.handle==="connect"){const S=d?(c.startPointerPos-w)/$:(w-c.startPointerPos)/$,fe=Un({posDiffPct:S,startLowVal:c.startLowVal,startHighVal:c.startHighVal,rangeMin:v,rangeMax:N,isDiscrete:P,sortedAllowedDates:x,snapMode:s,unit:t});if(et.current&&et.current[0]===fe[0]&&et.current[1]===fe[1])return;et.current=fe,ge(fe),Qe(fe[0],fe[1],!1);return}const U=pt(i.clientX,i.clientY,m);if(U===null)return;const X=mr(U*100),[E,q]=qr(c.handle,X,c.startLowVal,c.startHighVal,v,N,R);if((!et.current||et.current[0]!==E||et.current[1]!==q)&&(et.current=[E,q],ge([E,q]),Qe(E,q,!1)),!R&&(c.handle==="low"||c.handle==="high")){const S=Vn(c.handle,X,c.startLowVal,c.startHighVal,R);Ge.current!==S&&(Ge.current=S,We(S),me(S))}},[l,Z,d,A,M,Pt,Ze,pe,le,je,_t,Le,Xt,v,N,P,x,s,t,pt,mr,Qe,Yt,_e,R]),dn=o.useCallback(i=>{if(Z){Hr.current=null,Kt.current=null,Ir.current=null,ct.current=null,sr(null),Er(Yr.current),Er(Ar.current);return}const c=fr.current;if(!c||i.pointerId!==0&&i.pointerId!==c.pointerId)return;const m=et.current??ee;m&&(Qe(m[0],m[1],!0),z(m)),et.current=null,ge(null),fr.current=null,Ge.current=null,We(null)},[Z,ee,Qe,Er]),mn=o.useRef(un);mn.current=un;const fn=o.useRef(dn);fn.current=dn;const gn=ue!==null||Ce!==null;o.useEffect(()=>{if(!gn)return;const i=m=>mn.current(m),c=m=>fn.current(m);return window.addEventListener("pointermove",i),window.addEventListener("pointerup",c),window.addEventListener("pointercancel",c),()=>{window.removeEventListener("pointermove",i),window.removeEventListener("pointerup",c),window.removeEventListener("pointercancel",c)}},[gn]);const jr=o.useCallback((i,c,m)=>{fr.current={pointerId:i,handle:c,startPointerPos:m,startLowVal:V,startHighVal:ie},Ge.current=c,We(c),c!=="connect"&&me(c)},[V,ie]),hn=o.useCallback((i,c,m)=>{const w=C.current;w.mode==="vernier"&&(Ir.current={pointerId:i,handle:c,startPointerRatio:m,startMacroLowRatio:De,startMacroHighRatio:Ae,startMicroLowRatio:Fe,startMicroHighRatio:at,startMacroLowEnc:Ne,startMacroHighEnc:Ye,startMicroLowEnc:xe,startMicroHighEnc:ve,startMacroLowDate:w.macroRange[0],startMacroHighDate:w.macroRange[1],initialMicroLowDate:ut,initialMicroHighDate:dt},ct.current=c,sr(c),zt(c))},[De,Ae,Fe,at,Ne,Ye,xe,ve,ut,dt]),bn=i=>c=>{if(l)return;c.stopPropagation(),c.preventDefault(),me(i);const m=d?c.clientY:c.clientX;jr(c.pointerId,i,m)},wn=i=>()=>{l||Ge.current!==null||me(i)},gr=i=>()=>{l||ct.current!==null||zt(i)},Et=i=>c=>{if(l)return;c.stopPropagation(),c.preventDefault();const m=ot.current;if(!m)return;const w=pt(c.clientX,c.clientY,m.getBoundingClientRect());w!==null&&hn(c.pointerId,i,w)},sa=i=>{if(l||L)return;i.stopPropagation(),i.preventDefault();const c=d?i.clientY:i.clientX;jr(i.pointerId,"connect",c)},ca=i=>{if(l)return;if(Z){const E=ot.current;if(!E)return;const q=E.getBoundingClientRect(),S=pt(i.clientX,i.clientY,q);if(S===null)return;const fe=d?i.clientX-(q.left+q.width/2):i.clientY-(q.top+q.height/2),Xe=Kn(S,fe,De,Ae,Fe,at,Je,void 0,!L);hn(i.pointerId,Xe,S);return}const c=cn(i.clientX,i.clientY);if(c===null)return;const m=mr(c);let w="low";if(!R){const E=Math.abs(m-V),q=Math.abs(m-ie);E<q?w="low":q<E?w="high":w=m>ie?"high":"low"}me(w);const[$,U]=qr(w,m,V,ie,v,N,R);ge([$,U]),Qe($,U,!0);const X=d?i.clientY:i.clientX;jr(i.pointerId,w,X)},ua=i=>{if(l||ue!==null)return;const c=cn(i.clientX,i.clientY);if(c===null)return;const m=mr(c);Be(m),_(dr(m))},da=()=>{Be(null),_(null)},Mn=i=>c=>{if(l)return;me(i);const m=Bn(c.key,i,V,ie,v,N,R,1);m&&(c.preventDefault(),be||z(m),Qe(m[0],m[1],!0))},hr=(i,c)=>{const m=Math.max(G(M,i),G(M,r)),w=Math.min(G(M,lt(A,M,c)),G(M,n)),$=Math.max(m,Math.min(w,xe)),U=Math.max($,Math.min(w,ve));$===xe&&U===ve||_e(se(M,$),se(M,U),!0)},br=i=>c=>{if(l||!Z||e.mode!=="vernier")return;zt(i);let m=0,w=!1,$=!1;switch(c.key){case"ArrowRight":case"ArrowUp":m=1;break;case"ArrowLeft":case"ArrowDown":m=-1;break;case"PageUp":m=5;break;case"PageDown":m=-5;break;case"Home":w=!0;break;case"End":$=!0;break;default:return}if(c.preventDefault(),i==="macro-low"){const U=se(A,Ne),X=se(A,Ye);if(Pt){const S=Lr(pe,A,U,pe[0],X,m,w,$);if(S===ye(pe,U,A))return;const fe=pe[S];Yt(fe,X,!0),hr(fe,X);return}let E;if(w?E=je:$?E=Ye:E=Math.max(je,Math.min(Ye,Ne+m)),E===Ne)return;const q=se(A,E);Yt(q,X,!0),hr(q,X)}else if(i==="macro-high"){const U=se(A,Ne),X=se(A,Ye);if(Pt){const S=Lr(pe,A,X,U,pe[pe.length-1],m,w,$);if(S===ye(pe,X,A))return;const fe=pe[S];Yt(U,fe,!0),hr(U,fe);return}let E;if(w?E=Ne:$?E=kt:E=Math.max(Ne,Math.min(kt,Ye+m)),E===Ye)return;const q=se(A,E);Yt(U,q,!0),hr(U,q)}else if(i==="micro-low"){const U=se(M,xe),X=se(M,ve);if(Ze){const q=Lr(le,M,U,le[0],X,m,w,$);if(q===ye(le,U,M))return;_e(le[q],X,!0);return}let E;if(w?E=Le:$?E=ve:E=Math.max(Le,Math.min(ve,xe+m)),E===xe)return;_e(se(M,E),X,!0)}else if(i==="micro-high"){const U=se(M,xe),X=se(M,ve);if(Ze){const q=Lr(le,M,X,U,le[le.length-1],m,w,$);if(q===ye(le,X,M))return;_e(U,le[q],!0);return}let E;if(w?E=xe:$?E=ze:E=Math.max(xe,Math.min(ze,ve+m)),E===ve)return;_e(U,se(M,E),!0)}},ma=o.useCallback(i=>{const c=C.current;if(!c.disabled)if(c.mode==="point"){const m=Math.max(v,Math.min(N,V+i));be||z([m,m]),Qe(m,m,!0)}else if(c.mode==="vernier"){if(Ze){const S=le.length-1,fe=ye(le,ut,M),Xe=ye(le,dt,M),ft=Xe-fe;let ke=fe+i,he=Xe+i;i<0&&ke<0?(ke=0,he=Math.min(S,ft)):i>0&&he>S&&(he=S,ke=Math.max(0,S-ft)),(ke!==fe||he!==Xe)&&_e(le[ke],le[he],!0);return}const m=xe,w=ve,$=Le,U=ze,X=w-m;let E=m+i,q=w+i;i<0&&E<$?(E=$,q=Math.min(U,E+X)):i>0&&q>U&&(q=U,E=Math.max($,q-X)),(E!==m||q!==w)&&_e(se(M,E),se(M,q),!0)}else{const m=ie-V;let w=V+i,$=ie+i;i<0&&w<v?(w=v,$=Math.min(N,w+m)):i>0&&$>N&&($=N,w=Math.max(v,$-m)),w<=$&&(be||z([w,$]),Qe(w,$,!0))}},[V,ie,v,N,be,Qe,_e,xe,ve,Le,ze,M,Ze,le,ut,dt]),It=dr(V),Ht=dr(ie),Or=ce(V),Fr=ce(ie),Vr=o.useMemo(()=>R?qt===null?void 0:{estimatedWidthPx:qt.widthPx,estimatedHeightPx:qt.heightPx}:zr(qt,nn),[R,qt,nn]),wr=!R&&V===ie,Ee=o.useMemo(()=>{if(R||!y||d)return Zr(D,Vr);const i=Qr(It,Ht,At,D,Vr);return wr?qn(i):i},[R,wr,y,d,It,Ht,At,D,Vr]),Wt=ue==="low"||ue!=="high"&&St==="low",Gt=!R&&(ue==="high"||ue!=="low"&&St==="high"),Mr=Ne===Ye,xr=xe===ve,fa=Mr&&Se!=="macro-low",ga=Mr&&Se==="macro-low",ha=xr&&Se!=="micro-low",ba=xr&&Se==="micro-low",xn=p?"top":"bottom",vn=p?"bottom":"top",pn=o.useMemo(()=>zr(an,on),[an,on]),Dn=o.useMemo(()=>zr(ln,sn),[ln,sn]),vr=y&&!d,pr=o.useMemo(()=>Cn(De,Ae,At,xn,pn,Mr,vr),[De,Ae,At,xn,pn,Mr,vr]),Dr=o.useMemo(()=>Cn(Fe,at,At,vn,Dn,xr,vr),[Fe,at,At,vn,Dn,xr,vr]),wa=o.useMemo(()=>d?{"--ps-tooltip-origin":"100% 50%","--ps-tooltip-tx":"0px","--ps-tooltip-ty":"-50%","--ps-tooltip-rot":"0deg"}:{"--ps-tooltip-origin":"50% 50%","--ps-tooltip-tx":`calc(-50% + ${Ee.lowOffsetX}px)`,"--ps-tooltip-ty":`calc(-50% + ${Ee.lowOffsetY}px)`,"--ps-tooltip-rot":`${Ee.lowAngleDeg}deg`},[d,Ee.lowOffsetX,Ee.lowOffsetY,Ee.lowAngleDeg]),Ma=o.useMemo(()=>d?{"--ps-tooltip-origin":"100% 50%","--ps-tooltip-tx":"0px","--ps-tooltip-ty":"-50%","--ps-tooltip-rot":"0deg"}:{"--ps-tooltip-origin":"50% 50%","--ps-tooltip-tx":`calc(-50% + ${Ee.highOffsetX}px)`,"--ps-tooltip-ty":`calc(-50% + ${Ee.highOffsetY}px)`,"--ps-tooltip-rot":`${Ee.highAngleDeg}deg`},[d,Ee.highOffsetX,Ee.highOffsetY,Ee.highAngleDeg]),yr=Math.min(It,Ht),yn=Math.max(It,Ht),xa=d?{bottom:`${yr}%`,height:`${yn-yr}%`,top:"auto",left:"0",right:"0"}:{left:`${yr}%`,width:`${yn-yr}%`,top:"0",bottom:"0"},va=Math.max(.01,Ae-De),Tn=Math.max(.06,Math.min(.25,.28*Math.sqrt(va))),pa=d?{bottom:`${It}%`,left:"50%",transform:"translate(-50%, 50%)",zIndex:Wt?40:30}:{left:`${It}%`,top:"50%",transform:"translate(-50%, -50%)",zIndex:Wt?40:30},Da=d?{bottom:`${Ht}%`,left:"50%",transform:"translate(-50%, 50%)",zIndex:Gt?40:30}:{left:`${Ht}%`,top:"50%",transform:"translate(-50%, -50%)",zIndex:Gt?40:30},ya=d?{bottom:`${xt}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${xt}%`,top:"50%",transform:"translate(-50%, -50%)"},Sn=Me!==null?ce(Me):null,Ta=f!=="hover"&&Me!==null&&(Me===V||!R&&Me===ie),Sa=Ze?G(M,le[0]):Le,La=Ze?G(M,le[le.length-1]):ze,Ra=l||(Z?xe<=Sa:R?V<=v:V<=v&&ie<=v),$a=l||(Z?ve>=La:(R||V>=N)&&ie>=N),mt=l?"cursor-not-allowed opacity-50":"cursor-pointer",Ln=i=>{const c=d?"vertical":"horizontal",m=i==="decrease",w=Fa[c][i];return g.jsx("button",{type:"button",className:`period-slider-stepper-btn relative after:absolute after:inset-[-11px] after:content-[''] ${w} 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 ${mt}`,onClick:()=>ma(m?-1:1),disabled:m?Ra:$a,"aria-label":m?re:j,children:Oa[c][i]})};return g.jsxs("div",{style:e.style,className:`period-slider flex select-none items-center gap-2 ${d?"flex-col":"flex-row"} ${u}`,"data-disabled":l?"true":void 0,"data-unit":t,"data-mode":e.mode,"data-orientation":d?"vertical":"horizontal","data-label-position":D,"data-color-scheme":te,children:[b&&Ln(d?"increase":"decrease"),g.jsx("div",{ref:ot,"data-testid":"period-slider-track","data-orientation":d?"vertical":"horizontal","data-vernier-orientation":Z?Je:void 0,className:`period-slider-track relative flex-1 touch-none rounded-full bg-slate-200 dark:bg-slate-700 ${d?"h-48 w-2":"h-2 w-full"} ${mt}`,onPointerDown:ca,onPointerMove:ua,onPointerLeave:da,children:Z?g.jsxs(g.Fragment,{children:[or&&(d?g.jsxs("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:[g.jsx("defs",{children:g.jsxs("linearGradient",{id:B,x1:"0",y1:"0",x2:"1",y2:"0",children:[g.jsx("stop",{offset:"0%",stopColor:p?Y.macro:Y.micro,stopOpacity:"0.28"}),g.jsx("stop",{offset:"100%",stopColor:p?Y.micro:Y.macro,stopOpacity:Tn})]})}),g.jsx("polygon",{points:p?`12,${(1-Ae)*100} 12,${(1-De)*100} 20,100 20,0`:`12,0 12,100 20,${(1-De)*100} 20,${(1-Ae)*100}`,fill:`url(#${B})`})]}):g.jsxs("svg",{className:"period-slider-vernier-projection",role:"presentation","aria-hidden":"true",width:"100%",height:"32",viewBox:"0 0 100 32",preserveAspectRatio:"none",children:[g.jsx("defs",{children:g.jsxs("linearGradient",{id:B,x1:"0",y1:"0",x2:"0",y2:"1",children:[g.jsx("stop",{offset:"0%",stopColor:p?Y.macro:Y.micro,stopOpacity:"0.28"}),g.jsx("stop",{offset:"100%",stopColor:p?Y.micro:Y.macro,stopOpacity:Tn})]})}),g.jsx("polygon",{points:p?`${De*100},12 ${Ae*100},12 100,20 0,20`:`0,12 100,12 ${Ae*100},20 ${De*100},20`,fill:`url(#${B})`})]})),!L&&g.jsxs(g.Fragment,{children:[g.jsx("div",{"data-testid":"period-slider-connect-macro",className:"period-slider-connect-macro",style:d?{bottom:`calc(${De*100}% - 8px)`,height:`calc(${Math.max(0,(Ae-De)*100)}% + 16px)`}:{left:`calc(${De*100}% - 8px)`,width:`calc(${Math.max(0,(Ae-De)*100)}% + 16px)`},onPointerDown:Et("macro-connect")}),g.jsx("div",{"data-testid":"period-slider-connect-micro",className:"period-slider-connect-micro",style:d?{bottom:`calc(${Fe*100}% - 8px)`,height:`calc(${Math.max(0,(at-Fe)*100)}% + 16px)`}:{left:`calc(${Fe*100}% - 8px)`,width:`calc(${Math.max(0,(at-Fe)*100)}% + 16px)`},onPointerDown:Et("micro-connect")})]}),ir&&g.jsxs("div",{className:"period-slider-vernier-ticks pointer-events-none absolute inset-0",children:[[.2,.4,.6,.8].map(i=>g.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"macro",className:"period-slider-tick period-slider-tick-macro",style:d?{bottom:`${i*100}%`}:{left:`${i*100}%`}},`macro-tick-${i}`)),[.1,.2,.3,.4,.5,.6,.7,.8,.9].map(i=>g.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"micro",className:"period-slider-tick period-slider-tick-micro",style:d?{bottom:`${i*100}%`}:{left:`${i*100}%`}},`micro-tick-${i}`))]}),g.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":e.macroLowerAriaLabel??"Macro range start","aria-disabled":l?"true":void 0,"aria-valuemin":je,"aria-valuemax":Ye,"aria-valuenow":Ne,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(cr,A):Dt(A,cr,h,T),"aria-orientation":d?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${d?"is-vertical":""} group absolute touch-none ${d?p?"after:absolute after:-inset-y-3 after:right-0 after:-left-4":"after:absolute after:-inset-y-3 after:-right-4 after:left-0":p?"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 ${mt}`,style:d?{bottom:`${De*100}%`,left:p?0:"auto",right:p?"auto":0,transform:p?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:Ce==="macro-low"||Se==="macro-low"?30:15}:{left:`${De*100}%`,top:p?0:"auto",bottom:p?"auto":0,transform:p?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:Ce==="macro-low"||Se==="macro-low"?30:15},onPointerDown:Et("macro-low"),onKeyDown:br("macro-low"),onFocus:gr("macro-low"),"data-active":Ce==="macro-low"?"true":void 0,"data-front":Se==="macro-low"?"true":void 0,"data-vernier-pos":d?p?"left":"right":p?"top":"bottom","data-handle-type":"macro-low",children:[g.jsx(rr,{type:"macro",isTop:p,isVertical:d,isLeft:p}),Lt&&g.jsx("div",{className:"period-slider-hairline"}),f!=="hover"&&g.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${f==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":f,"data-duplicate":fa?"true":void 0,"data-slanted":pr.slant.isSlanted?"true":void 0,ref:aa,style:pr.lowStyle,children:Ie(A,cr,h,T)})]}),g.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":e.macroUpperAriaLabel??"Macro range end","aria-disabled":l?"true":void 0,"aria-valuemin":Ne,"aria-valuemax":kt,"aria-valuenow":Ye,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(ur,A):Dt(A,ur,h,T),"aria-orientation":d?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${d?"is-vertical":""} group absolute touch-none ${d?p?"after:absolute after:-inset-y-3 after:right-0 after:-left-4":"after:absolute after:-inset-y-3 after:-right-4 after:left-0":p?"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 ${mt}`,style:d?{bottom:`${Ae*100}%`,left:p?0:"auto",right:p?"auto":0,transform:p?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:Ce==="macro-high"||Se==="macro-high"?30:15}:{left:`${Ae*100}%`,top:p?0:"auto",bottom:p?"auto":0,transform:p?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:Ce==="macro-high"||Se==="macro-high"?30:15},onPointerDown:Et("macro-high"),onKeyDown:br("macro-high"),onFocus:gr("macro-high"),"data-active":Ce==="macro-high"?"true":void 0,"data-front":Se==="macro-high"?"true":void 0,"data-vernier-pos":d?p?"left":"right":p?"top":"bottom","data-handle-type":"macro-high",children:[g.jsx(rr,{type:"macro",isTop:p,isVertical:d,isLeft:p}),Lt&&g.jsx("div",{className:"period-slider-hairline"}),f!=="hover"&&g.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${f==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":f,"data-duplicate":ga?"true":void 0,"data-slanted":pr.slant.isSlanted?"true":void 0,ref:oa,style:pr.highStyle,children:Ie(A,ur,h,T)})]}),g.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":e.lowerAriaLabel??"Micro range start","aria-disabled":l?"true":void 0,"aria-valuemin":Le,"aria-valuemax":ve,"aria-valuenow":xe,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(ut,M):Dt(M,ut,k,T),"aria-orientation":d?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${d?"is-vertical":""} group absolute touch-none ${d?p?"after:absolute after:-inset-y-3 after:-right-4 after:left-0":"after:absolute after:-inset-y-3 after:right-0 after:-left-4":p?"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 ${mt}`,style:d?{bottom:`${Fe*100}%`,left:p?"auto":0,right:p?0:"auto",transform:p?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:Ce==="micro-low"||Se==="micro-low"?30:20}:{left:`${Fe*100}%`,top:p?"auto":0,bottom:p?0:"auto",transform:p?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:Ce==="micro-low"||Se==="micro-low"?30:20},onPointerDown:Et("micro-low"),onKeyDown:br("micro-low"),onFocus:gr("micro-low"),"data-active":Ce==="micro-low"?"true":void 0,"data-front":Se==="micro-low"?"true":void 0,"data-vernier-pos":d?p?"right":"left":p?"bottom":"top","data-handle-type":"micro-low",children:[g.jsx(rr,{type:"micro",isTop:!p,isVertical:d,isLeft:!p}),Lt&&g.jsx("div",{className:"period-slider-hairline"}),f!=="hover"&&g.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${f==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":f,"data-duplicate":ha?"true":void 0,"data-slanted":Dr.slant.isSlanted?"true":void 0,ref:ia,style:Dr.lowStyle,children:Ie(M,ut,k,T)})]}),g.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":e.upperAriaLabel??"Micro range end","aria-disabled":l?"true":void 0,"aria-valuemin":xe,"aria-valuemax":ze,"aria-valuenow":ve,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(dt,M):Dt(M,dt,k,T),"aria-orientation":d?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${d?"is-vertical":""} group absolute touch-none ${d?p?"after:absolute after:-inset-y-3 after:-right-4 after:left-0":"after:absolute after:-inset-y-3 after:right-0 after:-left-4":p?"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 ${mt}`,style:d?{bottom:`${at*100}%`,left:p?"auto":0,right:p?0:"auto",transform:p?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:Ce==="micro-high"||Se==="micro-high"?30:20}:{left:`${at*100}%`,top:p?"auto":0,bottom:p?0:"auto",transform:p?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:Ce==="micro-high"||Se==="micro-high"?30:20},onPointerDown:Et("micro-high"),onKeyDown:br("micro-high"),onFocus:gr("micro-high"),"data-active":Ce==="micro-high"?"true":void 0,"data-front":Se==="micro-high"?"true":void 0,"data-vernier-pos":d?p?"right":"left":p?"bottom":"top","data-handle-type":"micro-high",children:[g.jsx(rr,{type:"micro",isTop:!p,isVertical:d,isLeft:!p}),Lt&&g.jsx("div",{className:"period-slider-hairline"}),f!=="hover"&&g.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${f==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":f,"data-duplicate":ba?"true":void 0,"data-slanted":Dr.slant.isSlanted?"true":void 0,ref:la,style:Dr.highStyle,children:Ie(M,dt,k,T)})]})]}):g.jsxs(g.Fragment,{children:[!L&&g.jsx("div",{"data-testid":"period-slider-connect",className:"period-slider-connect absolute rounded-full",style:xa,onPointerDown:sa}),H&&P&&x.length>1&&g.jsx("div",{className:"period-slider-ticks pointer-events-none absolute inset-0",children:x.map((i,c)=>{const m=G(t,i),w=dr(c),$=d?{bottom:`${w}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${w}%`,top:"50%",transform:"translate(-50%, -50%)"};return g.jsx("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:$},`tick-${m}`)})}),!l&&Me!==null&&xt!==null&&ue===null&&Sn&&g.jsxs("div",{"data-testid":"period-slider-hover-guide",className:"period-slider-hover-guide pointer-events-none absolute h-2 w-2",style:ya,children:[g.jsx("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"}),g.jsx("div",{"data-testid":"period-slider-hover-tooltip","data-duplicate":Ta?"true":void 0,className:`period-slider-hover-tooltip ${D==="bottom"&&!d?"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`,children:Ie(t,Sn,e.formatLabel,T)})]}),g.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":R?e.pointAriaLabel??"Selected date":e.lowerAriaLabel??"Range start","aria-disabled":l?"true":void 0,"aria-valuemin":v,"aria-valuemax":R?N:ie,"aria-valuenow":V,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Or,t):Dt(t,Or,e.formatLabel,T),"aria-orientation":d?"vertical":"horizontal",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 ${mt}`,style:pa,onPointerDown:bn("low"),onKeyDown:Mn("low"),onFocus:wn("low"),"data-active":ue==="low"?"true":void 0,"data-front":Wt?"true":void 0,children:[g.jsx("div",{"data-testid":"period-slider-knob",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)] ${ue==="low"?"":"shadow-md"}`}),f!=="hover"&&g.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${f==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":f,"data-label-position":D,"data-slanted":Ee.isSlanted?"true":void 0,"data-front":Wt?"true":void 0,"data-duplicate":wr&&!Wt?"true":void 0,ref:ra,style:wa,children:Ie(t,Or,e.formatLabel,T)})]}),!R&&g.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":e.upperAriaLabel??"Range end","aria-disabled":l?"true":void 0,"aria-valuemin":V,"aria-valuemax":N,"aria-valuenow":ie,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Fr,t):Dt(t,Fr,e.formatLabel,T),"aria-orientation":d?"vertical":"horizontal",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 ${mt}`,style:Da,onPointerDown:bn("high"),onKeyDown:Mn("high"),onFocus:wn("high"),"data-active":ue==="high"?"true":void 0,"data-front":Gt?"true":void 0,children:[g.jsx("div",{"data-testid":"period-slider-knob",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)] ${ue==="high"?"":"shadow-md"}`}),f!=="hover"&&g.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${f==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":f,"data-label-position":D,"data-slanted":Ee.isSlanted?"true":void 0,"data-front":Gt?"true":void 0,"data-duplicate":wr&&!Gt?"true":void 0,ref:na,style:Ma,children:Ie(t,Fr,e.formatLabel,T)})]})]})}),b&&Ln(d?"decrease":"increase")]})},_r=(e,t)=>{if(e===t)return!0;if(!(e&&t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r].getTime()!==t[r].getTime())return!1;return!0},Jn=(e,t)=>{if(e===t)return!0;if(!(e&&t))return!1;const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(const a of r)if(e[a]!==t[a])return!1;return!0},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||!Jn(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||!_r(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||!_r(e.macroAllowedDates,t.macroAllowedDates)||!_r(e.microAllowedDates,t.microAllowedDates)):!1,Zn=o.memo(Va,Ua);Zn.displayName="PeriodSlider";const tt=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},nr=(e,t)=>{if(Number.isNaN(t.getTime()))throw new RangeError(`DateSelector: "${e}" must be a valid Date (received ${String(t)})`)},Ba=e=>{if(e!==void 0)try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{throw new RangeError(`DateSelector: "locale" must be a valid BCP 47 language tag (received ${JSON.stringify(e)})`)}},Tt=(e,t,r)=>{const n=new Date(e,t-1,r);return n.setFullYear(e),n.setHours(0,0,0,0),n},Nn=e=>Tt(e,1,1),za=e=>Tt(e,12,31),_a={year:{year:"numeric"},month:{month:"2-digit"},day:{day:"2-digit"}},Xa={year:4,month:2,day:2},qa={year:e=>e.getFullYear(),month:e=>e.getMonth()+1,day:e=>e.getDate()},Yn=new Map,Ka=(e,t)=>{const r=`${e}\0${t}`,n=Yn.get(r);if(n!==void 0)return n;const a=new Intl.DateTimeFormat(t,_a[e]);return Yn.set(r,a),a},Xr=(e,t,r)=>r===void 0?String(qa[e](t)).padStart(Xa[e],"0"):Ka(e,r).format(t),Wa=(e,t,r)=>{const n=t?.getTime()??null,a=r?.getTime()??null,s=new Map;return e.forEach((l,u)=>{nr(`allowedDates[${u}]`,l);const b=tt(l),f=b.getTime();n!==null&&f<n||a!==null&&f>a||s.has(f)||s.set(f,b)}),Array.from(s.keys()).sort((l,u)=>l-u).map(l=>s.get(l))},Ga=(e,t)=>{const r=[];let n=tt(e);const a=tt(t).getTime();for(;n.getTime()<=a;)r.push(n),n=Re.addDays(n,1);return r},An=(e,t)=>{const r=[];for(let n=e.length-1;n>=0;n--)r.push({label:Ie("day",e[n],void 0,t),value:Re.format(e[n],"yyyy-MM-dd")});return r},Ja=e=>{const{value:t,initialDate:r,onChange:n,children:a,minYear:s,maxYear:l,minDate:u,maxDate:b,allowedDates:f,variant:D="date",className:y="",style:d,disabled:L=!1,prevDateAriaLabel:H="Previous day",nextDateAriaLabel:te="Next day",selectAriaLabel:T="Date",yearAriaLabel:re="Year",monthAriaLabel:j="Month",dayAriaLabel:J="Day",locale:Y,formatYearOption:B,formatMonthOption:C,formatDayOption:F}=e;if(Ba(Y),t!==void 0&&nr("value",t),r!==void 0&&nr("initialDate",r),u!==void 0&&nr("minDate",u),b!==void 0&&nr("maxDate",b),s!==void 0&&!Number.isInteger(s))throw new RangeError(`DateSelector: "minYear" must be an integer year (received ${String(s)})`);if(l!==void 0&&!Number.isInteger(l))throw new RangeError(`DateSelector: "maxYear" must be an integer year (received ${String(l)})`);if(D==="split-dropdown"&&f!==void 0)throw new RangeError('DateSelector: variant="split-dropdown" cannot honour "allowedDates"; use variant="dropdown" or variant="date" for a discrete date set');const O=t??r;if(O===void 0)throw new RangeError("DateSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected date is never inferred from the wall clock.");const[x,P]=o.useState(()=>tt(O)),v=t!==void 0,N=t?.getTime(),R=o.useMemo(()=>t!==void 0?tt(t):x,[N,x]),ce=u?.getTime(),ne=b?.getTime(),Q=o.useMemo(()=>{const h=u?tt(u):null,k=s!==void 0?Nn(s):null;return h===null?k:k===null||h.getTime()>=k.getTime()?h:k},[ce,s]),ae=o.useMemo(()=>{const h=b?tt(b):null,k=l!==void 0?za(l):null;return h===null?k:k===null||h.getTime()<=k.getTime()?h:k},[ne,l]),oe=Q?.getTime()??null,de=ae?.getTime()??null;if(Q!==null&&ae!==null&&Q.getTime()>ae.getTime())throw new RangeError(`DateSelector: the resolved range is empty (min ${Re.format(Q,"yyyy-MM-dd")} is after max ${Re.format(ae,"yyyy-MM-dd")})`);if(D!=="date"&&f===void 0&&(Q===null||ae===null))throw new RangeError(`DateSelector: variant="${D}" needs a bounded range; supply minDate/minYear and maxDate/maxYear${D==="dropdown"?' or supply "allowedDates"':""}`);const K=f===void 0?null:f.map(h=>h.getTime()).join(","),W=o.useMemo(()=>f===void 0?null:Wa(f,Q,ae),[K,oe,de]),Te=h=>{const k=h.getTime();return W!==null?W.some(Pe=>Pe.getTime()===k):!(oe!==null&&k<oe||de!==null&&k>de)},Mt=O.getTime();o.useEffect(()=>{v||P(tt(O))},[v,Mt]);const Oe=h=>{if(L)return;const k=tt(h);Te(k)&&(v||P(k),n?.(k))},$e=R.getTime(),be=Te(R),I=o.useMemo(()=>{if(W!==null){for(let k=W.length-1;k>=0;k--)if(W[k].getTime()<$e)return W[k];return null}const h=Re.addDays(new Date($e),-1);return Te(h)?h:null},[W,$e,oe,de]),z=o.useMemo(()=>{if(W!==null){for(const k of W)if(k.getTime()>$e)return k;return null}const h=Re.addDays(new Date($e),1);return Te(h)?h:null},[W,$e,oe,de]),ee=L||I===null,ge=L||z===null,ue=()=>{I!==null&&Oe(I)},We=()=>{z!==null&&Oe(z)},Ge=h=>{if(h.target.value){const k=Re.parseISO(h.target.value);Number.isNaN(k.getTime())||Oe(k)}},St=h=>{if(h.target.value){const k=Re.parseISO(h.target.value);Number.isNaN(k.getTime())||Oe(k)}},me=R.getFullYear(),Me=R.getMonth()+1,Be=R.getDate(),xt=o.useMemo(()=>D!=="dropdown"?[]:W!==null?An(W,Y):Q===null||ae===null?[]:An(Ga(Q,ae),Y),[D,W,oe,de,Y]),_=o.useMemo(()=>{if(D!=="split-dropdown"||Q===null||ae===null)return[];const h=[];for(let k=ae.getFullYear();k>=Q.getFullYear();k--)h.push(k);return h},[D,oe,de]),V=o.useMemo(()=>{if(D!=="split-dropdown"||Q===null||ae===null)return[];const h=Q,k=ae,Pe=me===h.getFullYear()?h.getMonth()+1:1,$t=me===k.getFullYear()?k.getMonth()+1:12,vt=[];for(let nt=Pe;nt<=$t;nt++)vt.push(nt);return vt},[D,oe,de,me]),ie=o.useMemo(()=>{if(D!=="split-dropdown"||Q===null||ae===null)return[];const h=Q,k=ae,Pe=me===h.getFullYear()&&Me===h.getMonth()+1?h.getDate():1,$t=me===k.getFullYear()&&Me===k.getMonth()+1?k.getDate():Re.getDaysInMonth(new Date($e)),vt=[];for(let nt=Pe;nt<=$t;nt++)vt.push(nt);return vt},[D,oe,de,$e,me,Me]),rt=(h,k,Pe)=>Pe>Re.getDaysInMonth(Tt(h,k,1))?!1:Te(Tt(h,k,Pe)),Z=(h,k,Pe)=>{rt(h,k,Pe)&&Oe(Tt(h,k,Pe))},Je=h=>B?B(h):Xr("year",Nn(h),Y),p=h=>C?C(h):Xr("month",Tt(me,h,1),Y),or=h=>F?F(h):Xr("day",Tt(me,Me,h),Y),ir=Re.format(R,"yyyy-MM-dd"),Lt=Ie("day",R,void 0,Y),A=Q?Re.format(Q,"yyyy-MM-dd"):void 0,M=ae?Re.format(ae,"yyyy-MM-dd"):void 0,Pr=be?ir:"",Rt="text-center font-mono text-gray-500 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-400",lr=D==="split-dropdown"?"w-auto":"w-38";return g.jsxs("div",{className:`inline-flex items-center ${lr} ${y}`,style:d,"data-variant":D,"data-out-of-range":be?void 0:"true",children:[g.jsx("button",{type:"button","aria-label":H,disabled:ee,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",onClick:ue,children:g.jsx("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"})}),D==="dropdown"?g.jsxs("select",{"aria-label":T,disabled:L,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:Pr,onChange:St,children:[be?null:g.jsx("option",{value:"",disabled:!0,className:Rt,children:Lt}),xt.map(h=>g.jsx("option",{value:h.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:h.label},h.value))]}):D==="split-dropdown"?g.jsxs("div",{className:"mx-1 my-auto inline-flex items-center gap-1",children:[g.jsxs("select",{"aria-label":re,disabled:L,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",value:be?me:"",onChange:h=>Z(Number(h.target.value),Me,Be),children:[be?null:g.jsx("option",{value:"",disabled:!0,className:Rt,children:Je(me)}),_.map(h=>g.jsx("option",{value:h,disabled:!rt(h,Me,Be),className:"dark:bg-slate-700 dark:text-slate-100",children:Je(h)},h))]}),g.jsxs("select",{"aria-label":j,disabled:L,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",value:be?Me:"",onChange:h=>Z(me,Number(h.target.value),Be),children:[be?null:g.jsx("option",{value:"",disabled:!0,className:Rt,children:p(Me)}),V.map(h=>g.jsx("option",{value:h,disabled:!rt(me,h,Be),className:"dark:bg-slate-700 dark:text-slate-100",children:p(h)},h))]}),g.jsxs("select",{"aria-label":J,disabled:L,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",value:be?Be:"",onChange:h=>Z(me,Me,Number(h.target.value)),children:[be?null:g.jsx("option",{value:"",disabled:!0,className:Rt,children:or(Be)}),ie.map(h=>g.jsx("option",{value:h,className:"dark:bg-slate-700 dark:text-slate-100",children:or(h)},h))]})]}):g.jsx("input",{"aria-label":T,disabled:L,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",value:ir,min:A,max:M,onChange:Ge,type:"date"}),g.jsx("button",{type:"button","aria-label":te,disabled:ge,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",onClick:We,children:g.jsx("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"})}),a]})},Ut=e=>e===void 0?null:tt(e).getTime(),Qn=o.memo(Ja,(e,t)=>!(Ut(e.value??e.initialDate)!==Ut(t.value??t.initialDate)||Ut(e.minDate)!==Ut(t.minDate)||Ut(e.maxDate)!==Ut(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));Qn.displayName="DateSelector";function Ve(e,t){const r=e+Math.floor(t/12),n=(t%12+12)%12,a=new Date(r,n,1);return a.setFullYear(r),a}function yt(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}`}function tr(e,t){if(e!==void 0&&(!(e instanceof Date)||Number.isNaN(e.getTime())))throw new RangeError(`MonthSelector: \`${t}\` must be a valid Date, received ${String(e)}.`)}function En(e,t){if(e!==void 0&&!Number.isInteger(e))throw new RangeError(`MonthSelector: \`${t}\` must be an integer year, received ${String(e)}.`)}function Za(e){if(e!==void 0)try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{throw new RangeError(`MonthSelector: \`locale\` must be a valid BCP 47 language tag, received ${JSON.stringify(e)}.`)}}function Qa(e,t){const r=e===void 0?null:Ve(e,0),n=t===void 0?null:Ve(t.getFullYear(),t.getMonth());return r!==null&&n!==null?r>=n?r:n:r!==null?r:n}function eo(e,t){const r=e===void 0?null:Ve(e,11),n=t===void 0?null:Ve(t.getFullYear(),t.getMonth());return r!==null&&n!==null?r<=n?r:n:r!==null?r:n}function to(e,t,r){const n=new Map;for(const a of e){const s=Ve(a.getFullYear(),a.getMonth());t!==null&&s<t||r!==null&&s>r||n.has(s.getTime())||n.set(s.getTime(),s)}return Array.from(n.values()).sort((a,s)=>a.getTime()-s.getTime())}function ro(e,t){const r=e.getFullYear()*12+e.getMonth(),n=t.getFullYear()*12+t.getMonth(),a=[];for(let s=r;s<=n;s++)a.push(Ve(Math.floor(s/12),s%12));return a}function In(e,t){const r=[];for(let n=e.length-1;n>=0;n--)r.push({label:Ie("month",e[n],void 0,t),value:yt(e[n])});return r}const no=e=>{const{value:t,initialDate:r,onChange:n,children:a,variant:s="date",minYear:l,maxYear:u,minDate:b,maxDate:f,allowedMonths:D,isWarning:y=!1,className:d="",style:L,disabled:H=!1,prevMonthAriaLabel:te="Previous month",nextMonthAriaLabel:T="Next month",selectAriaLabel:re="Month",locale:j}=e;Za(j),tr(t,"value"),tr(r,"initialDate"),tr(b,"minDate"),tr(f,"maxDate"),En(l,"minYear"),En(u,"maxYear"),D?.forEach((_,V)=>{tr(_,`allowedMonths[${V}]`)});const J=t??r;if(J===void 0)throw new RangeError("MonthSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected month is never inferred from the wall clock.");const[Y,B]=o.useState(()=>Ve(J.getFullYear(),J.getMonth())),C=t!==void 0,F=o.useMemo(()=>t!==void 0?Ve(t.getFullYear(),t.getMonth()):Y,[t?.getTime(),Y]),O=b?.getTime(),x=f?.getTime(),P=o.useMemo(()=>Qa(l,b),[l,O]),v=o.useMemo(()=>eo(u,f),[u,x]),N=P?.getTime()??null,R=v?.getTime()??null;if(P!==null&&v!==null&&P>v)throw new RangeError(`MonthSelector: the resolved lower bound ${yt(P)} is after the resolved upper bound ${yt(v)}.`);if(s==="dropdown"&&D===void 0&&(P===null||v===null))throw new RangeError('MonthSelector: variant="dropdown" requires a lower bound (`minYear` or `minDate`) and an upper bound (`maxYear` or `maxDate`), or `allowedMonths`; the option window is never invented.');const ce=D===void 0?null:D.map(_=>_.getTime()).join(","),ne=o.useMemo(()=>D===void 0?null:to(D,P,v),[ce,N,R]),Q=_=>{const V=_.getTime();return ne!==null?ne.some(ie=>ie.getTime()===V):!(N!==null&&V<N||R!==null&&V>R)},ae=J.getTime();o.useEffect(()=>{if(C)return;const _=Ve(J.getFullYear(),J.getMonth());B(V=>V.getTime()===_.getTime()?V:_)},[C,ae]);const oe=_=>{if(H)return;if(!Q(_))throw new RangeError(`MonthSelector: refusing to emit ${yt(_)}, which lies outside the selectable months.`);C||B(_);const V=_.getFullYear()*100+(_.getMonth()+1);n?.(_,V)},de=F.getTime(),K=Q(F),W=o.useMemo(()=>{if(ne!==null){for(let V=ne.length-1;V>=0;V--)if(ne[V].getTime()<de)return ne[V];return null}const _=Ve(F.getFullYear(),F.getMonth()-1);return Q(_)?_:null},[ne,de,N,R]),Te=o.useMemo(()=>{if(ne!==null){for(const V of ne)if(V.getTime()>de)return V;return null}const _=Ve(F.getFullYear(),F.getMonth()+1);return Q(_)?_:null},[ne,de,N,R]),Mt=H||W===null,Oe=H||Te===null,$e=()=>{W!==null&&oe(W)},be=()=>{Te!==null&&oe(Te)},I=_=>{if(!_)return;const[V,ie]=_.split("-"),rt=Number(V),Z=Number(ie)-1;if(!(Number.isInteger(rt)&&Number.isInteger(Z)))return;const Je=Ve(rt,Z);Q(Je)&&oe(Je)},z=_=>{I(_.target.value)},ee=_=>{I(_.target.value)},ge=yt(F),ue=Ie("month",F,void 0,j),We=P?yt(P):void 0,Ge=v?yt(v):void 0,St=o.useMemo(()=>s!=="dropdown"?[]:ne!==null?In(ne,j):P===null||v===null?[]:In(ro(P,v),j),[s,ne,N,R,j]),me=K?ge:"",Me=y?"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",Be=`mx-1 my-auto w-28 rounded-md border py-0.5 px-1 text-xs dark:placeholder:text-gray-400 disabled:opacity-50 ${Me}`,xt=`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 ${Me}`;return g.jsxs("div",{className:`inline-flex w-38 items-center ${d}`,style:L,"data-out-of-range":K?void 0:"true",children:[g.jsx("button",{type:"button","aria-label":te,disabled:Mt,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",onClick:$e,children:g.jsx("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"})}),s==="dropdown"?g.jsxs("select",{"aria-label":re,disabled:H,className:xt,value:me,onChange:ee,children:[K?null:g.jsx("option",{value:"",disabled:!0,className:"text-center font-mono text-gray-500 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-400",children:ue}),St.map(_=>g.jsx("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))]}):g.jsx("input",{"aria-label":re,disabled:H,className:Be,value:ge,min:We,max:Ge,onChange:z,type:"month"}),g.jsx("button",{type:"button","aria-label":T,disabled:Oe,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",onClick:be,children:g.jsx("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"})}),a]})},ea=o.memo(no,(e,t)=>{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;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;const l=e.minDate?e.minDate.getFullYear()*12+e.minDate.getMonth():null,u=t.minDate?t.minDate.getFullYear()*12+t.minDate.getMonth():null;if(l!==u)return!1;const b=e.maxDate?e.maxDate.getFullYear()*12+e.maxDate.getMonth():null,f=t.maxDate?t.maxDate.getFullYear()*12+t.maxDate.getMonth():null;return!(b!==f||e.allowedMonths!==t.allowedMonths||e.onChange!==t.onChange||e.children!==t.children||e.prevMonthAriaLabel!==t.prevMonthAriaLabel||e.nextMonthAriaLabel!==t.nextMonthAriaLabel||e.selectAriaLabel!==t.selectAriaLabel||e.locale!==t.locale)});ea.displayName="MonthSelector";function ar(e,t,r){if(!(r instanceof Date)||Number.isNaN(r.getTime()))throw new RangeError(`${e}: ${t} is required and must be a valid Date (received: ${String(r)})`)}function en(e,t,r){if(ar(e,"minDate",t),ar(e,"maxDate",r),r.getTime()<=t.getTime())throw new RangeError(`${e}: maxDate must be strictly later than minDate (minDate: ${t.toISOString()}, maxDate: ${r.toISOString()})`)}function Kr(e,t,r){if(!Array.isArray(r)||r.length!==2)throw new RangeError(`${e}: ${t} is required and must be a [lower, upper] Date tuple (received: ${String(r)})`);if(ar(e,`${t}[0]`,r[0]),ar(e,`${t}[1]`,r[1]),r[0].getTime()>r[1].getTime())throw new RangeError(`${e}: ${t} upper must not be earlier than lower (lower: ${r[0].toISOString()}, upper: ${r[1].toISOString()})`)}function Wr(e,t,r,n,a,s){if(r.getTime()<n.getTime()||r.getTime()>a.getTime())throw new RangeError(`${e}: ${t} must lie within ${s} (value: ${r.toISOString()}, lower: ${n.toISOString()}, upper: ${a.toISOString()})`)}function Gr(e,t,r,n,a,s){Wr(e,`${t}[0]`,r[0],n,a,s),Wr(e,`${t}[1]`,r[1],n,a,s)}function Ue(e,t,r){return e<t?t:e>r?r:e}function Rr(e,t,r,n){const a=lt(t,r,n[1]);return[Ue(e[0],n[0],a),Ue(e[1],n[0],a)]}function Jr(e,t,r,n){const a=ye(e,r,t)+n;return e[Math.max(0,Math.min(e.length-1,a))]}function tn(e){const t=o.useRef(e),r=t.current,n=e,a=Object.keys(r),s=Object.keys(n);return a.length===s.length&&s.every(u=>Object.is(r[u],n[u]))||(t.current=e),t.current}function ao(e){const{unit:t,minDate:r,maxDate:n,initialRange:a,onChangeRange:s,...l}=e;en("usePeriodSliderRange",r,n),Kr("usePeriodSliderRange","initialRange",a),Gr("usePeriodSliderRange","initialRange",a,r,n,"[minDate, maxDate]");const u=tn(l),b=o.useRef(a),[f,D]=o.useState(a);let y=f;const d=[Ue(f[0],r,n),Ue(f[1],r,n)];(d[0]!==f[0]||d[1]!==f[1])&&(y=d,D(d));const L=o.useRef(y);L.current=y;const H=o.useRef({minDate:r,maxDate:n,allowedDates:u.allowedDates});H.current={minDate:r,maxDate:n,allowedDates:u.allowedDates};const te=o.useRef(s);te.current=s;const T=o.useCallback(x=>{const{minDate:P,maxDate:v}=H.current,N=Ue(x[0],P,v),R=Ue(x[1],P,v),ce=L.current;N.getTime()===ce[0].getTime()&&R.getTime()===ce[1].getTime()||(L.current=[N,R],D([N,R]),te.current?.(N,R))},[]),re=o.useCallback(x=>{const P=L.current,v=x.getTime()>P[1].getTime()?x:P[1];T([x,v])},[T]),j=o.useCallback(x=>{const P=L.current,v=x.getTime()<P[0].getTime()?x:P[0];T([v,x])},[T]),J=o.useCallback((x,P)=>{T([x,P])},[T]),Y=o.useCallback(x=>{const{minDate:P,maxDate:v,allowedDates:N}=H.current,R=L.current,ce=Bt(N,t,P,v);if(ce.length>0){T([Jr(ce,t,R[0],x),Jr(ce,t,R[1],x)]);return}T([He(t,R[0],x),He(t,R[1],x)])},[t,T]),B=o.useCallback(()=>{T(b.current)},[T]),C=o.useMemo(()=>({value:y[0],onChange:re,minDate:r,maxDate:y[1],unit:t}),[y[0],y[1],re,r,t]),F=o.useMemo(()=>({value:y[1],onChange:j,minDate:y[0],maxDate:n,unit:t}),[y[0],y[1],j,n,t]),O=o.useMemo(()=>({...u,mode:"range",unit:t,range:y,minDate:r,maxDate:n,onChangeRange:J}),[u,t,y,r,n,J]);return{range:y,lowerDate:y[0],upperDate:y[1],setRange:D,setLowerDate:re,setUpperDate:j,shiftRange:Y,resetRange:B,startSelectorProps:C,endSelectorProps:F,sliderProps:O}}function oo(e){const{unit:t,minDate:r,maxDate:n,initialValue:a,onChangePoint:s,...l}=e;en("usePeriodSliderPoint",r,n),ar("usePeriodSliderPoint","initialValue",a),Wr("usePeriodSliderPoint","initialValue",a,r,n,"[minDate, maxDate]");const u=tn(l),b=o.useRef(a),[f,D]=o.useState(a);let y=f;const d=Ue(f,r,n);d!==f&&(y=d,D(d));const L=o.useRef(y);L.current=y;const H=o.useRef({minDate:r,maxDate:n,allowedDates:u.allowedDates});H.current={minDate:r,maxDate:n,allowedDates:u.allowedDates};const te=o.useRef(s);te.current=s;const T=o.useCallback(B=>{const{minDate:C,maxDate:F}=H.current,O=Ue(B,C,F);O.getTime()!==L.current.getTime()&&(L.current=O,D(O),te.current?.(O))},[]),re=o.useCallback(B=>{const{minDate:C,maxDate:F,allowedDates:O}=H.current,x=Bt(O,t,C,F);if(x.length>0){T(Jr(x,t,L.current,B));return}T(He(t,L.current,B))},[t,T]),j=o.useCallback(()=>{T(b.current)},[T]),J=o.useMemo(()=>({value:y,onChange:T,minDate:r,maxDate:n,unit:t}),[y,T,r,n,t]),Y=o.useMemo(()=>({...u,mode:"point",unit:t,value:y,minDate:r,maxDate:n,onChangePoint:T}),[u,t,y,r,n,T]);return{value:y,setValue:D,shiftValue:re,resetValue:j,selectorProps:J,sliderProps:Y}}function io(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:a,initialMicroRange:s,macroUnit:l=t,microUnit:u=t,onChangeMacroRange:b,onChangeMicroRange:f,...D}=e;en("useVernierSlider",r,n),Kr("useVernierSlider","initialMacroRange",a),Kr("useVernierSlider","initialMicroRange",s),Gr("useVernierSlider","initialMacroRange",a,r,n,"[minDate, maxDate]"),Gr("useVernierSlider","initialMicroRange",s,a[0],lt(l,u,a[1]),"the initial macro window");const y=tn(D),d=o.useRef(a),L=o.useRef(s),[H,te]=o.useState(a),[T,re]=o.useState(s);let j=H;const J=[Ue(H[0],r,n),Ue(H[1],r,n)];(J[0]!==H[0]||J[1]!==H[1])&&(j=J,te(J));let Y=T;const B=Rr(T,l,u,j);(B[0]!==T[0]||B[1]!==T[1])&&(Y=B,re(B));const C=o.useRef(j);C.current=j;const F=o.useRef(Y);F.current=Y;const O=o.useRef({minDate:r,maxDate:n});O.current={minDate:r,maxDate:n};const x=o.useRef(b);x.current=b;const P=o.useRef(f);P.current=f;const v=o.useCallback((I,z)=>{const ee=C.current,ge=F.current;(I[0].getTime()!==ee[0].getTime()||I[1].getTime()!==ee[1].getTime())&&(C.current=I,te(I),x.current?.(I[0],I[1])),(z[0].getTime()!==ge[0].getTime()||z[1].getTime()!==ge[1].getTime())&&(F.current=z,re(z),P.current?.(z[0],z[1]))},[]),N=o.useCallback((I,z)=>{const{minDate:ee,maxDate:ge}=O.current,ue=[Ue(I,ee,ge),Ue(z,ee,ge)];v(ue,Rr(F.current,l,u,ue))},[l,u,v]),R=o.useCallback((I,z)=>{v(C.current,Rr([I,z],l,u,C.current))},[l,u,v]),ce=o.useCallback(I=>{const z=C.current[1],ee=I>z?I:z;N(I,ee)},[N]),ne=o.useCallback(I=>{const z=C.current[0],ee=I<z?I:z;N(ee,I)},[N]),Q=o.useCallback(I=>{const z=F.current[1],ee=I>z?I:z;R(I,ee)},[R]),ae=o.useCallback(I=>{const z=F.current[0],ee=I<z?I:z;R(ee,I)},[R]),oe=o.useCallback(I=>{const{minDate:z,maxDate:ee}=O.current,ge=C.current,ue=He(l,ge[0],I),We=He(l,ge[1],I);ue<z||We>ee||N(ue,We)},[l,N]),de=o.useCallback(I=>{const z=C.current,ee=F.current,ge=He(u,ee[0],I),ue=He(u,ee[1],I);ge<z[0]||ue>lt(l,u,z[1])||R(ge,ue)},[l,u,R]),K=o.useCallback(()=>{const I=d.current;v(I,Rr(L.current,l,u,I))},[l,u,v]),W=o.useMemo(()=>lt(l,u,j[1]),[l,u,j[1]]),Te=o.useMemo(()=>({value:j[0],onChange:ce,minDate:r,maxDate:j[1],unit:l}),[j,ce,r,l]),Mt=o.useMemo(()=>({value:j[1],onChange:ne,minDate:j[0],maxDate:n,unit:l}),[j,ne,n,l]),Oe=o.useMemo(()=>({value:Y[0],onChange:Q,minDate:j[0],maxDate:Y[1],unit:u}),[Y,Q,j,u]),$e=o.useMemo(()=>({value:Y[1],onChange:ae,minDate:Y[0],maxDate:W,unit:u}),[Y,ae,W,u]),be=o.useMemo(()=>({...y,mode:"vernier",unit:t,macroUnit:l,microUnit:u,minDate:r,maxDate:n,macroRange:j,microRange:Y,onChangeMacroRange:N,onChangeMicroRange:R}),[y,t,l,u,r,n,j,Y,N,R]);return{macroRange:j,setMacroRange:te,microRange:Y,setMicroRange:re,setMacroLowerDate:ce,setMacroUpperDate:ne,setMicroLowerDate:Q,setMicroUpperDate:ae,shiftMacroRange:oe,shiftMicroRange:de,resetVernier:K,macroStartSelectorProps:Te,macroEndSelectorProps:Mt,microStartSelectorProps:Oe,microEndSelectorProps:$e,sliderProps:be}}function Hn(e){const t=new Date(e,0,1);return t.setFullYear(e),t}function $r(e,t){if(e!==void 0&&(!(e instanceof Date)||Number.isNaN(e.getTime())))throw new RangeError(`YearSelector: \`${t}\` must be a valid Date, received ${String(e)}.`)}function jn(e,t){if(e!==void 0&&!Number.isInteger(e))throw new RangeError(`YearSelector: \`${t}\` must be an integer year, received ${String(e)}.`)}function lo(e){if(e!==void 0)try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{throw new RangeError(`YearSelector: \`locale\` must be a valid BCP 47 language tag, received ${JSON.stringify(e)}.`)}}function On(e,t,r){const n=e===void 0?null:e,a=t===void 0?null:t.getFullYear();return n!==null&&a!==null?r(n,a):n!==null?n:a}const so=e=>{const{value:t,initialDate:r,onChange:n,children:a,minYear:s,maxYear:l,minDate:u,maxDate:b,className:f="",style:D,disabled:y=!1,prevYearAriaLabel:d="Previous year",nextYearAriaLabel:L="Next year",selectAriaLabel:H="Year",locale:te}=e;$r(t,"value"),$r(r,"initialDate"),$r(u,"minDate"),$r(b,"maxDate"),jn(s,"minYear"),jn(l,"maxYear"),lo(te);const T=t??r;if(T===void 0)throw new RangeError("YearSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected year is never inferred from the wall clock.");const[re,j]=o.useState(()=>T.getFullYear()),J=u?.getTime(),Y=b?.getTime(),B=o.useMemo(()=>On(s,u,Math.max),[s,J]),C=o.useMemo(()=>On(l,b,Math.min),[l,Y]);if(B===null||C===null)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.");if(B>C)throw new RangeError(`YearSelector: the resolved lower bound ${B} is after the resolved upper bound ${C}.`);const F=t!==void 0,O=t!==void 0?t.getFullYear():re,x=O<B||O>C,P=T.getTime();o.useEffect(()=>{F||j(T.getFullYear())},[F,P]);const v=K=>K>=B&&K<=C,N=K=>{if(!y){if(!v(K))throw new RangeError(`YearSelector: refusing to emit ${K}, which lies outside the declared bounds ${B}-${C}.`);F||j(K),n?.(Hn(K),K)}},R=v(O-1)?O-1:null,ce=v(O+1)?O+1:null,ne=y||R===null,Q=y||ce===null,ae=()=>{R!==null&&N(R)},oe=()=>{ce!==null&&N(ce)},de=o.useMemo(()=>{const K=[];for(let W=C;W>=B;W--)K.push(W);return x&&(K.push(O),K.sort((W,Te)=>Te-W)),K},[B,C,x,O]);return g.jsxs("div",{className:`inline-flex w-32 items-center ${f}`,style:D,children:[g.jsx("button",{type:"button","aria-label":d,disabled:ne,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",onClick:ae,children:g.jsx("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"})}),g.jsx("select",{"aria-label":H,disabled:y,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",value:O,onChange:K=>{if(!K.target.value)return;const W=Number(K.target.value);Number.isInteger(W)&&N(W)},children:de.map(K=>g.jsx("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:Ie("year",Hn(K),void 0,te)},K))}),g.jsx("button",{type:"button","aria-label":L,disabled:Q,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",onClick:oe,children:g.jsx("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"})}),a]})},ta=o.memo(so,(e,t)=>{const r=e.value??e.initialDate,n=t.value??t.initialDate,a=r?r.getFullYear():null,s=n?n.getFullYear():null;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)});ta.displayName="YearSelector";exports.COLOR_SCHEME_PALETTES=Fn;exports.DateSelector=Qn;exports.MonthSelector=ea;exports.PeriodSlider=Zn;exports.YearSelector=ta;exports.addUnit=He;exports.areStylesEqual=Jn;exports.calculateConnectDragValues=Un;exports.calculateHandleDragValues=qr;exports.calculateKeyboardActionValues=Bn;exports.calculateLabelSlant=Qr;exports.calculateVernierMacroDrag=Wn;exports.calculateVernierMicroDrag=Gn;exports.decode=se;exports.encode=G;exports.findNearestDateIndex=ye;exports.formatLabel=Ie;exports.formatScreenReaderLabel=Dt;exports.getActiveDragHandle=Vn;exports.getMacroWindowEndDate=lt;exports.getSortedAllowedDates=Bt;exports.normalizeDateByUnit=Ke;exports.resolveVernierTargetHandle=Kn;exports.usePeriodSliderPoint=oo;exports.usePeriodSliderRange=ao;exports.useVernierSlider=io;