@bfrs/agentic-components 0.7.8 → 0.8.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.
@@ -1,47 +1,47 @@
1
- const f = "Custom", D = 864e5, l = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], i = ["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"], M = ["S", "M", "T", "W", "T", "F", "S"];
2
- function o(t) {
1
+ const Y = "Custom", S = 864e5, T = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], d = ["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"], A = ["S", "M", "T", "W", "T", "F", "S"];
2
+ function r(t) {
3
3
  return new Date(t.getFullYear(), t.getMonth(), t.getDate());
4
4
  }
5
- function a(t, e) {
6
- const n = o(t);
5
+ function o(t, e) {
6
+ const n = r(t);
7
7
  return n.setDate(n.getDate() + e), n;
8
8
  }
9
- function u(t, e) {
10
- const n = Date.UTC(t.getFullYear(), t.getMonth(), t.getDate()), r = Date.UTC(e.getFullYear(), e.getMonth(), e.getDate());
11
- return n === r ? 0 : n < r ? -1 : 1;
9
+ function s(t, e) {
10
+ const n = Date.UTC(t.getFullYear(), t.getMonth(), t.getDate()), a = Date.UTC(e.getFullYear(), e.getMonth(), e.getDate());
11
+ return n === a ? 0 : n < a ? -1 : 1;
12
12
  }
13
- function h(t, e) {
14
- const n = Date.UTC(t.getFullYear(), t.getMonth(), t.getDate()), r = Date.UTC(e.getFullYear(), e.getMonth(), e.getDate());
15
- return Math.round(Math.abs(n - r) / 864e5);
13
+ function i(t, e) {
14
+ const n = Date.UTC(t.getFullYear(), t.getMonth(), t.getDate()), a = Date.UTC(e.getFullYear(), e.getMonth(), e.getDate());
15
+ return Math.round(Math.abs(n - a) / 864e5);
16
16
  }
17
- function m(t, e) {
18
- return !!(e && u(t, e) === 0);
17
+ function R(t, e) {
18
+ return !!(e && s(t, e) === 0);
19
19
  }
20
- function d(t, e) {
20
+ function F(t, e) {
21
21
  return new Date(t, e + 1, 0).getDate();
22
22
  }
23
- function c(t, e, n) {
24
- const r = new Date(t, e + n, 1);
25
- return { year: r.getFullYear(), month: r.getMonth() };
23
+ function m(t, e, n) {
24
+ const a = new Date(t, e + n, 1);
25
+ return { year: a.getFullYear(), month: a.getMonth() };
26
26
  }
27
- function y(t, e) {
28
- const n = o(t), r = o(e);
29
- return u(n, r) <= 0 ? { from: n, to: r } : { from: r, to: n };
27
+ function N(t, e) {
28
+ const n = r(t), a = r(e);
29
+ return s(n, a) <= 0 ? { from: n, to: a } : { from: a, to: n };
30
30
  }
31
- function T(t) {
31
+ function w(t) {
32
32
  return `${String(t.getDate()).padStart(2, "0")}/${String(t.getMonth() + 1).padStart(2, "0")}/${t.getFullYear()}`;
33
33
  }
34
34
  function g(t) {
35
- const e = o(/* @__PURE__ */ new Date());
35
+ const e = r(/* @__PURE__ */ new Date());
36
36
  switch (t) {
37
37
  case "Today":
38
38
  return { from: e, to: e };
39
39
  case "Yesterday":
40
- return { from: a(e, -1), to: a(e, -1) };
40
+ return { from: o(e, -1), to: o(e, -1) };
41
41
  case "Last 7 days":
42
- return { from: a(e, -6), to: e };
42
+ return { from: o(e, -6), to: e };
43
43
  case "Last 30 days":
44
- return { from: a(e, -29), to: e };
44
+ return { from: o(e, -29), to: e };
45
45
  case "This Month":
46
46
  return { from: new Date(e.getFullYear(), e.getMonth(), 1), to: e };
47
47
  case "Last Month":
@@ -53,7 +53,36 @@ function g(t) {
53
53
  return { from: e, to: e };
54
54
  }
55
55
  }
56
- const Y = [
56
+ const f = "last30Days", D = "lastOneYear", l = 2015;
57
+ function h() {
58
+ const t = (/* @__PURE__ */ new Date()).getFullYear(), e = [
59
+ { value: f, label: "Last 30 days" },
60
+ { value: D, label: "Last one year" }
61
+ ];
62
+ for (let n = t - 1; n >= l; n--)
63
+ e.push({ value: String(n), label: String(n) });
64
+ return e;
65
+ }
66
+ const O = h();
67
+ function y() {
68
+ const t = r(/* @__PURE__ */ new Date());
69
+ return { min: o(t, -364), max: t };
70
+ }
71
+ function _(t) {
72
+ if (t === f) {
73
+ const n = r(/* @__PURE__ */ new Date());
74
+ return { min: o(n, -29), max: n };
75
+ }
76
+ if (t === D)
77
+ return y();
78
+ const e = Number(t);
79
+ return { min: new Date(e, 0, 1), max: new Date(e, 11, 31) };
80
+ }
81
+ function p(t, e = {}) {
82
+ const n = e.minDate && s(r(e.minDate), t.min) > 0 ? r(e.minDate) : r(t.min), a = e.maxDate && s(r(e.maxDate), t.max) < 0 ? r(e.maxDate) : r(t.max), c = s(a, n) < 0 ? n : a;
83
+ return { from: e.maxRangeDays && i(c, n) + 1 > e.maxRangeDays ? o(c, -(e.maxRangeDays - 1)) : n, to: c };
84
+ }
85
+ const E = [
57
86
  "Today",
58
87
  "Yesterday",
59
88
  "Last 7 days",
@@ -65,47 +94,55 @@ const Y = [
65
94
  label: t,
66
95
  getRange: () => g(t)
67
96
  }));
68
- function F(t) {
97
+ function x(t) {
69
98
  return t.from instanceof Date && t.to instanceof Date;
70
99
  }
71
- function s(t) {
100
+ function u(t) {
72
101
  if (t instanceof Date) return Number.isNaN(t.getTime()) ? void 0 : t;
73
102
  if (typeof t == "string" || typeof t == "number") {
74
103
  const e = new Date(t);
75
104
  return Number.isNaN(e.getTime()) ? void 0 : e;
76
105
  }
77
106
  }
78
- function S(t) {
79
- return { ...t, from: s(t.from), to: s(t.to) };
107
+ function L(t) {
108
+ return { ...t, from: u(t.from), to: u(t.to) };
80
109
  }
81
- function N(t, e) {
110
+ function C(t, e) {
82
111
  const n = t.from ?? /* @__PURE__ */ new Date();
83
- return e === 2 && !t.from ? c(n.getFullYear(), n.getMonth(), -1) : { year: n.getFullYear(), month: n.getMonth() };
112
+ return e === 2 && !t.from ? m(n.getFullYear(), n.getMonth(), -1) : { year: n.getFullYear(), month: n.getMonth() };
84
113
  }
85
- function A(t, e) {
114
+ function U(t, e) {
86
115
  var n;
87
- return (n = t.find((r) => r.id === e)) == null ? void 0 : n.label;
116
+ return (n = t.find((a) => a.id === e)) == null ? void 0 : n.label;
88
117
  }
89
118
  export {
90
- f as CUSTOM_PRESET_ID,
91
- M as DAY_HEADS,
92
- D as DAY_MS,
93
- l as MONTH_NAMES,
94
- i as SHORT_MONTH_NAMES,
95
- a as addDays,
96
- S as coerceDateRangeValue,
97
- u as compareDay,
98
- d as daysInMonth,
99
- Y as defaultDateRangePresets,
100
- T as defaultFormatDate,
101
- h as differenceInCalendarDays,
102
- N as getInitialCalendar,
103
- A as getPresetLabel,
104
- F as hasCompleteRange,
105
- y as normalizeRange,
119
+ l as BASE_YEAR,
120
+ Y as CUSTOM_PRESET_ID,
121
+ A as DAY_HEADS,
122
+ S as DAY_MS,
123
+ T as MONTH_NAMES,
124
+ d as SHORT_MONTH_NAMES,
125
+ f as YEAR_LAST_30_DAYS,
126
+ D as YEAR_LAST_ONE,
127
+ O as YEAR_OPTIONS,
128
+ o as addDays,
129
+ h as buildYearOptions,
130
+ p as clampYearRange,
131
+ L as coerceDateRangeValue,
132
+ s as compareDay,
133
+ y as computeLastOneYearRange,
134
+ _ as computeYearRange,
135
+ F as daysInMonth,
136
+ E as defaultDateRangePresets,
137
+ w as defaultFormatDate,
138
+ i as differenceInCalendarDays,
139
+ C as getInitialCalendar,
140
+ U as getPresetLabel,
141
+ x as hasCompleteRange,
142
+ N as normalizeRange,
106
143
  g as presetToRange,
107
- m as sameDay,
108
- c as shiftMonth,
109
- o as startOfDay
144
+ R as sameDay,
145
+ m as shiftMonth,
146
+ r as startOfDay
110
147
  };
111
148
  //# sourceMappingURL=DateRangePicker.utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DateRangePicker.utils.js","sources":["../../../../src/components/filters/DateRangePicker/DateRangePicker.utils.ts"],"sourcesContent":["import type { DateRangePreset, DateRangePresetId, DateRangeValue } from \"./DateRangePicker.types\";\n\nexport const CUSTOM_PRESET_ID = \"Custom\";\nexport const DAY_MS = 24 * 60 * 60 * 1000;\nexport const MONTH_NAMES = [\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"];\nexport const SHORT_MONTH_NAMES = [\"JAN\", \"FEB\", \"MAR\", \"APR\", \"MAY\", \"JUN\", \"JUL\", \"AUG\", \"SEP\", \"OCT\", \"NOV\", \"DEC\"];\nexport const DAY_HEADS = [\"S\", \"M\", \"T\", \"W\", \"T\", \"F\", \"S\"];\n\nexport function startOfDay(date: Date): Date {\n return new Date(date.getFullYear(), date.getMonth(), date.getDate());\n}\n\nexport function addDays(date: Date, days: number): Date {\n const next = startOfDay(date);\n next.setDate(next.getDate() + days);\n return next;\n}\n\nexport function compareDay(a: Date, b: Date): number {\n const left = Date.UTC(a.getFullYear(), a.getMonth(), a.getDate());\n const right = Date.UTC(b.getFullYear(), b.getMonth(), b.getDate());\n return left === right ? 0 : left < right ? -1 : 1;\n}\n\nexport function differenceInCalendarDays(a: Date, b: Date): number {\n const left = Date.UTC(a.getFullYear(), a.getMonth(), a.getDate());\n const right = Date.UTC(b.getFullYear(), b.getMonth(), b.getDate());\n return Math.round(Math.abs(left - right) / DAY_MS);\n}\n\nexport function sameDay(a: Date, b?: Date): boolean {\n return Boolean(b && compareDay(a, b) === 0);\n}\n\nexport function daysInMonth(year: number, month: number): number {\n return new Date(year, month + 1, 0).getDate();\n}\n\nexport function shiftMonth(year: number, month: number, delta: number): { year: number; month: number } {\n const shifted = new Date(year, month + delta, 1);\n return { year: shifted.getFullYear(), month: shifted.getMonth() };\n}\n\nexport function normalizeRange(from: Date, to: Date): { from: Date; to: Date } {\n const start = startOfDay(from);\n const end = startOfDay(to);\n return compareDay(start, end) <= 0 ? { from: start, to: end } : { from: end, to: start };\n}\n\nexport function defaultFormatDate(date: Date): string {\n return `${String(date.getDate()).padStart(2, \"0\")}/${String(date.getMonth() + 1).padStart(2, \"0\")}/${date.getFullYear()}`;\n}\n\nexport function presetToRange(preset: DateRangePresetId): { from: Date; to: Date } {\n const today = startOfDay(new Date());\n\n switch (preset) {\n case \"Today\":\n return { from: today, to: today };\n case \"Yesterday\":\n return { from: addDays(today, -1), to: addDays(today, -1) };\n case \"Last 7 days\":\n return { from: addDays(today, -6), to: today };\n case \"Last 30 days\":\n return { from: addDays(today, -29), to: today };\n case \"This Month\":\n return { from: new Date(today.getFullYear(), today.getMonth(), 1), to: today };\n case \"Last Month\":\n return {\n from: new Date(today.getFullYear(), today.getMonth() - 1, 1),\n to: new Date(today.getFullYear(), today.getMonth(), 0)\n };\n default:\n return { from: today, to: today };\n }\n}\n\nexport const defaultDateRangePresets: DateRangePreset[] = [\n \"Today\",\n \"Yesterday\",\n \"Last 7 days\",\n \"Last 30 days\",\n \"This Month\",\n \"Last Month\"\n].map((id) => ({\n id,\n label: id,\n getRange: () => presetToRange(id)\n}));\n\nexport function hasCompleteRange(value: DateRangeValue): value is DateRangeValue & { from: Date; to: Date } {\n return value.from instanceof Date && value.to instanceof Date;\n}\n\nfunction toDateOrUndefined(input: unknown): Date | undefined {\n if (input instanceof Date) return Number.isNaN(input.getTime()) ? undefined : input;\n if (typeof input === \"string\" || typeof input === \"number\") {\n const parsed = new Date(input);\n return Number.isNaN(parsed.getTime()) ? undefined : parsed;\n }\n return undefined;\n}\n\n/**\n * Normalizes an incoming value so `from`/`to` are always real `Date` objects (or\n * `undefined`). Consumers commonly hydrate the value/defaultValue from\n * JSON/API/storage where dates arrive as ISO strings or timestamps; without this\n * the picker crashes on `getFullYear` and never recognizes the range as filled\n * (so the trigger's filled border never lights up).\n */\nexport function coerceDateRangeValue(value: DateRangeValue): DateRangeValue {\n return { ...value, from: toDateOrUndefined(value.from), to: toDateOrUndefined(value.to) };\n}\n\nexport function getInitialCalendar(value: DateRangeValue, months: 1 | 2) {\n const base = value.from ?? new Date();\n return months === 2 && !value.from ? shiftMonth(base.getFullYear(), base.getMonth(), -1) : { year: base.getFullYear(), month: base.getMonth() };\n}\n\nexport function getPresetLabel(presets: DateRangePreset[], presetId?: string) {\n return presets.find((preset) => preset.id === presetId)?.label;\n}\n\n"],"names":["CUSTOM_PRESET_ID","DAY_MS","MONTH_NAMES","SHORT_MONTH_NAMES","DAY_HEADS","startOfDay","date","addDays","days","next","compareDay","a","b","left","right","differenceInCalendarDays","sameDay","daysInMonth","year","month","shiftMonth","delta","shifted","normalizeRange","from","to","start","end","defaultFormatDate","presetToRange","preset","today","defaultDateRangePresets","id","hasCompleteRange","value","toDateOrUndefined","input","parsed","coerceDateRangeValue","getInitialCalendar","months","base","getPresetLabel","presets","presetId","_a"],"mappings":"AAEO,MAAMA,IAAmB,UACnBC,IAAS,OACTC,IAAc,CAAC,WAAW,YAAY,SAAS,SAAS,OAAO,QAAQ,QAAQ,UAAU,aAAa,WAAW,YAAY,UAAU,GACvIC,IAAoB,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK,GACvGC,IAAY,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,GAAG;AAEpD,SAASC,EAAWC,GAAkB;AAC3C,SAAO,IAAI,KAAKA,EAAK,YAAA,GAAeA,EAAK,SAAA,GAAYA,EAAK,SAAS;AACrE;AAEO,SAASC,EAAQD,GAAYE,GAAoB;AACtD,QAAMC,IAAOJ,EAAWC,CAAI;AAC5B,SAAAG,EAAK,QAAQA,EAAK,QAAA,IAAYD,CAAI,GAC3BC;AACT;AAEO,SAASC,EAAWC,GAASC,GAAiB;AACnD,QAAMC,IAAO,KAAK,IAAIF,EAAE,eAAeA,EAAE,SAAA,GAAYA,EAAE,QAAA,CAAS,GAC1DG,IAAQ,KAAK,IAAIF,EAAE,eAAeA,EAAE,SAAA,GAAYA,EAAE,QAAA,CAAS;AACjE,SAAOC,MAASC,IAAQ,IAAID,IAAOC,IAAQ,KAAK;AAClD;AAEO,SAASC,EAAyBJ,GAASC,GAAiB;AACjE,QAAMC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,IAAIC,EAAkBD,EAAM,EAAE,EAAA;AACxF;AAEO,SAASK,EAAmBL,GAAuBM,GAAe;AACvE,QAAMC,IAAOP,EAAM,QAAQ,oBAAI,KAAA;AAC/B,SAAOM,MAAW,KAAK,CAACN,EAAM,OAAOf,EAAWsB,EAAK,YAAA,GAAeA,EAAK,SAAA,GAAY,EAAE,IAAI,EAAE,MAAMA,EAAK,eAAe,OAAOA,EAAK,WAAS;AAC9I;AAEO,SAASC,EAAeC,GAA4BC,GAAmB;AArHvE,MAAAC;AAsHL,UAAOA,IAAAF,EAAQ,KAAK,CAACd,MAAWA,EAAO,OAAOe,CAAQ,MAA/C,gBAAAC,EAAkD;AAC3D;"}
1
+ {"version":3,"file":"DateRangePicker.utils.js","sources":["../../../../src/components/filters/DateRangePicker/DateRangePicker.utils.ts"],"sourcesContent":["import type { DateRangePreset, DateRangePresetId, DateRangeValue } from \"./DateRangePicker.types\";\n\nexport const CUSTOM_PRESET_ID = \"Custom\";\nexport const DAY_MS = 24 * 60 * 60 * 1000;\nexport const MONTH_NAMES = [\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"];\nexport const SHORT_MONTH_NAMES = [\"JAN\", \"FEB\", \"MAR\", \"APR\", \"MAY\", \"JUN\", \"JUL\", \"AUG\", \"SEP\", \"OCT\", \"NOV\", \"DEC\"];\nexport const DAY_HEADS = [\"S\", \"M\", \"T\", \"W\", \"T\", \"F\", \"S\"];\n\nexport function startOfDay(date: Date): Date {\n return new Date(date.getFullYear(), date.getMonth(), date.getDate());\n}\n\nexport function addDays(date: Date, days: number): Date {\n const next = startOfDay(date);\n next.setDate(next.getDate() + days);\n return next;\n}\n\nexport function compareDay(a: Date, b: Date): number {\n const left = Date.UTC(a.getFullYear(), a.getMonth(), a.getDate());\n const right = Date.UTC(b.getFullYear(), b.getMonth(), b.getDate());\n return left === right ? 0 : left < right ? -1 : 1;\n}\n\nexport function differenceInCalendarDays(a: Date, b: Date): number {\n const left = Date.UTC(a.getFullYear(), a.getMonth(), a.getDate());\n const right = Date.UTC(b.getFullYear(), b.getMonth(), b.getDate());\n return Math.round(Math.abs(left - right) / DAY_MS);\n}\n\nexport function sameDay(a: Date, b?: Date): boolean {\n return Boolean(b && compareDay(a, b) === 0);\n}\n\nexport function daysInMonth(year: number, month: number): number {\n return new Date(year, month + 1, 0).getDate();\n}\n\nexport function shiftMonth(year: number, month: number, delta: number): { year: number; month: number } {\n const shifted = new Date(year, month + delta, 1);\n return { year: shifted.getFullYear(), month: shifted.getMonth() };\n}\n\nexport function normalizeRange(from: Date, to: Date): { from: Date; to: Date } {\n const start = startOfDay(from);\n const end = startOfDay(to);\n return compareDay(start, end) <= 0 ? { from: start, to: end } : { from: end, to: start };\n}\n\nexport function defaultFormatDate(date: Date): string {\n return `${String(date.getDate()).padStart(2, \"0\")}/${String(date.getMonth() + 1).padStart(2, \"0\")}/${date.getFullYear()}`;\n}\n\nexport function presetToRange(preset: DateRangePresetId): { from: Date; to: Date } {\n const today = startOfDay(new Date());\n\n switch (preset) {\n case \"Today\":\n return { from: today, to: today };\n case \"Yesterday\":\n return { from: addDays(today, -1), to: addDays(today, -1) };\n case \"Last 7 days\":\n return { from: addDays(today, -6), to: today };\n case \"Last 30 days\":\n return { from: addDays(today, -29), to: today };\n case \"This Month\":\n return { from: new Date(today.getFullYear(), today.getMonth(), 1), to: today };\n case \"Last Month\":\n return {\n from: new Date(today.getFullYear(), today.getMonth() - 1, 1),\n to: new Date(today.getFullYear(), today.getMonth(), 0)\n };\n default:\n return { from: today, to: today };\n }\n}\n\nexport const YEAR_LAST_30_DAYS = \"last30Days\";\nexport const YEAR_LAST_ONE = \"lastOneYear\";\nexport const BASE_YEAR = 2015;\n\nexport function buildYearOptions() {\n // The current year is still in progress, so it isn't a coherent discrete\n // year to pick — \"Last 30 days\"/\"Last one year\" already cover it. Matches\n // the sync logic below, which only maps a committed range onto a literal\n // year option when that year is fully in the past (< currentYear).\n const current = new Date().getFullYear();\n const years: { value: string; label: string }[] = [\n { value: YEAR_LAST_30_DAYS, label: \"Last 30 days\" },\n { value: YEAR_LAST_ONE, label: \"Last one year\" }\n ];\n for (let y = current - 1; y >= BASE_YEAR; y--) {\n years.push({ value: String(y), label: String(y) });\n }\n return years;\n}\n\nexport const YEAR_OPTIONS = buildYearOptions();\n\nconst DAYS_IN_ONE_YEAR = 365;\n\nexport function computeLastOneYearRange(): { min: Date; max: Date } {\n const today = startOfDay(new Date());\n // 365 days INCLUSIVE of today, matching the \"Last 30 days\" option right above\n // it (addDays(today, -29) = 30 days). The previous version stepped back a year\n // AND a month — `new Date(getFullYear() - 1, getMonth() - 1, 1)` — producing a\n // ~397-day span that blew past the 365-day cap consumers pass as maxRangeDays.\n return { min: addDays(today, -(DAYS_IN_ONE_YEAR - 1)), max: today };\n}\n\nexport function computeYearRange(yearValue: string): { min: Date; max: Date } {\n if (yearValue === YEAR_LAST_30_DAYS) {\n const today = startOfDay(new Date());\n return { min: addDays(today, -29), max: today };\n }\n if (yearValue === YEAR_LAST_ONE) {\n return computeLastOneYearRange();\n }\n const y = Number(yearValue);\n return { min: new Date(y, 0, 1), max: new Date(y, 11, 31) };\n}\n\n\n/**\n * Constrains a year-dropdown range to the picker's allowed window and its\n * maxRangeDays cap. A year option is a shortcut, not an escape hatch — it has to\n * satisfy the same limits a hand-picked range does. Trims from the START so the\n * most recent day of the chosen option is preserved.\n */\nexport function clampYearRange(\n range: { min: Date; max: Date },\n bounds: { minDate?: Date; maxDate?: Date; maxRangeDays?: number } = {}\n): { from: Date; to: Date } {\n // The chosen option's own span IS the window — the picker derives its\n // navigable bounds from it. Only an explicit minDate/maxDate prop can narrow\n // it further. (Do NOT clamp against the picker's current effective bounds:\n // those are derived from the previously selected year, so switching options\n // would trap the new range inside the old one.)\n const lower =\n bounds.minDate && compareDay(startOfDay(bounds.minDate), range.min) > 0 ? startOfDay(bounds.minDate) : startOfDay(range.min);\n const upper =\n bounds.maxDate && compareDay(startOfDay(bounds.maxDate), range.max) < 0 ? startOfDay(bounds.maxDate) : startOfDay(range.max);\n const to = compareDay(upper, lower) < 0 ? lower : upper;\n\n // Trim from the START so the most recent day of the option is preserved.\n const from =\n bounds.maxRangeDays && differenceInCalendarDays(to, lower) + 1 > bounds.maxRangeDays\n ? addDays(to, -(bounds.maxRangeDays - 1))\n : lower;\n\n return { from, to };\n}\n\nexport const defaultDateRangePresets: DateRangePreset[] = [\n \"Today\",\n \"Yesterday\",\n \"Last 7 days\",\n \"Last 30 days\",\n \"This Month\",\n \"Last Month\"\n].map((id) => ({\n id,\n label: id,\n getRange: () => presetToRange(id)\n}));\n\nexport function hasCompleteRange(value: DateRangeValue): value is DateRangeValue & { from: Date; to: Date } {\n return value.from instanceof Date && value.to instanceof Date;\n}\n\nfunction toDateOrUndefined(input: unknown): Date | undefined {\n if (input instanceof Date) return Number.isNaN(input.getTime()) ? undefined : input;\n if (typeof input === \"string\" || typeof input === \"number\") {\n const parsed = new Date(input);\n return Number.isNaN(parsed.getTime()) ? undefined : parsed;\n }\n return undefined;\n}\n\n/**\n * Normalizes an incoming value so `from`/`to` are always real `Date` objects (or\n * `undefined`). Consumers commonly hydrate the value/defaultValue from\n * JSON/API/storage where dates arrive as ISO strings or timestamps; without this\n * the picker crashes on `getFullYear` and never recognizes the range as filled\n * (so the trigger's filled border never lights up).\n */\nexport function coerceDateRangeValue(value: DateRangeValue): DateRangeValue {\n return { ...value, from: toDateOrUndefined(value.from), to: toDateOrUndefined(value.to) };\n}\n\nexport function getInitialCalendar(value: DateRangeValue, months: 1 | 2) {\n const base = value.from ?? new Date();\n return months === 2 && !value.from ? shiftMonth(base.getFullYear(), base.getMonth(), -1) : { year: base.getFullYear(), month: base.getMonth() };\n}\n\nexport function getPresetLabel(presets: DateRangePreset[], presetId?: string) {\n return presets.find((preset) => preset.id === presetId)?.label;\n}\n\n"],"names":["CUSTOM_PRESET_ID","DAY_MS","MONTH_NAMES","SHORT_MONTH_NAMES","DAY_HEADS","startOfDay","date","addDays","days","next","compareDay","a","b","left","right","differenceInCalendarDays","sameDay","daysInMonth","year","month","shiftMonth","delta","shifted","normalizeRange","from","to","start","end","defaultFormatDate","presetToRange","preset","today","YEAR_LAST_30_DAYS","YEAR_LAST_ONE","BASE_YEAR","buildYearOptions","current","years","y","YEAR_OPTIONS","computeLastOneYearRange","computeYearRange","yearValue","clampYearRange","range","bounds","lower","upper","defaultDateRangePresets","id","hasCompleteRange","value","toDateOrUndefined","input","parsed","coerceDateRangeValue","getInitialCalendar","months","base","getPresetLabel","presets","presetId","_a"],"mappings":"AAEO,MAAMA,IAAmB,UACnBC,IAAS,OACTC,IAAc,CAAC,WAAW,YAAY,SAAS,SAAS,OAAO,QAAQ,QAAQ,UAAU,aAAa,WAAW,YAAY,UAAU,GACvIC,IAAoB,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK,GACvGC,IAAY,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,GAAG;AAEpD,SAASC,EAAWC,GAAkB;AAC3C,SAAO,IAAI,KAAKA,EAAK,YAAA,GAAeA,EAAK,SAAA,GAAYA,EAAK,SAAS;AACrE;AAEO,SAASC,EAAQD,GAAYE,GAAoB;AACtD,QAAMC,IAAOJ,EAAWC,CAAI;AAC5B,SAAAG,EAAK,QAAQA,EAAK,QAAA,IAAYD,CAAI,GAC3BC;AACT;AAEO,SAASC,EAAWC,GAASC,GAAiB;AACnD,QAAMC,IAAO,KAAK,IAAIF,EAAE,eAAeA,EAAE,SAAA,GAAYA,EAAE,QAAA,CAAS,GAC1DG,IAAQ,KAAK,IAAIF,EAAE,eAAeA,EAAE,SAAA,GAAYA,EAAE,QAAA,CAAS;AACjE,SAAOC,MAASC,IAAQ,IAAID,IAAOC,IAAQ,KAAK;AAClD;AAEO,SAASC,EAAyBJ,GAASC,GAAiB;AACjE,QAAMC,IAAO,KAAK,IAAIF,EAAE,eAAeA,EAAE,SAAA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