gridsmith-ui 0.26.0 → 0.27.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.
Files changed (102) hide show
  1. package/CHANGELOG.md +969 -0
  2. package/README.md +21 -5
  3. package/dist/charts.d.ts +2 -2
  4. package/dist/charts.js +58 -43
  5. package/dist/charts.js.map +1 -1
  6. package/dist/chat.js +4 -3
  7. package/dist/chat.js.map +1 -1
  8. package/dist/{chunk-CYN5O567.js → chunk-2CKSSWYG.js} +9 -5
  9. package/dist/chunk-2CKSSWYG.js.map +1 -0
  10. package/dist/chunk-3BRQRKDO.js +1 -0
  11. package/dist/chunk-3BRQRKDO.js.map +1 -1
  12. package/dist/{chunk-RWKCAKN3.js → chunk-5TUVX4B2.js} +6 -5
  13. package/dist/chunk-5TUVX4B2.js.map +1 -0
  14. package/dist/{chunk-X2HEV7FB.js → chunk-64TXZ4L7.js} +23 -33
  15. package/dist/chunk-64TXZ4L7.js.map +1 -0
  16. package/dist/chunk-7Q46JXSK.js +1 -0
  17. package/dist/chunk-7Q46JXSK.js.map +1 -1
  18. package/dist/chunk-CRQ6KCRD.js +1 -0
  19. package/dist/chunk-CRQ6KCRD.js.map +1 -1
  20. package/dist/{chunk-ZYVXV4WC.js → chunk-EKBWWA6P.js} +53 -6
  21. package/dist/chunk-EKBWWA6P.js.map +1 -0
  22. package/dist/chunk-HP7WUZPK.js +1 -0
  23. package/dist/chunk-HP7WUZPK.js.map +1 -1
  24. package/dist/{chunk-MYIJNVTK.js → chunk-IXR4UEF4.js} +5 -4
  25. package/dist/chunk-IXR4UEF4.js.map +1 -0
  26. package/dist/chunk-M2QRNBDQ.js +1 -0
  27. package/dist/chunk-M2QRNBDQ.js.map +1 -1
  28. package/dist/chunk-MD2EFMES.js +1 -0
  29. package/dist/chunk-MD2EFMES.js.map +1 -1
  30. package/dist/chunk-NRHIYS5W.js +1 -0
  31. package/dist/chunk-NRHIYS5W.js.map +1 -1
  32. package/dist/chunk-OTCEJN64.js +1 -0
  33. package/dist/chunk-OTCEJN64.js.map +1 -1
  34. package/dist/chunk-OYNUU346.js +78 -0
  35. package/dist/chunk-OYNUU346.js.map +1 -0
  36. package/dist/{chunk-EX64MN2U.js → chunk-PO65I3MQ.js} +4 -3
  37. package/dist/chunk-PO65I3MQ.js.map +1 -0
  38. package/dist/chunk-QM4SJKWV.js +1 -0
  39. package/dist/chunk-QM4SJKWV.js.map +1 -1
  40. package/dist/{chunk-KWLNEH53.js → chunk-R5NFCEZ3.js} +10 -7
  41. package/dist/chunk-R5NFCEZ3.js.map +1 -0
  42. package/dist/chunk-SFY2KMHG.js +1 -0
  43. package/dist/chunk-SFY2KMHG.js.map +1 -1
  44. package/dist/{chunk-HXVXJUGV.js → chunk-TJEV7YAY.js} +38 -10
  45. package/dist/chunk-TJEV7YAY.js.map +1 -0
  46. package/dist/chunk-WH2FUFAC.js +1 -0
  47. package/dist/chunk-WH2FUFAC.js.map +1 -1
  48. package/dist/chunk-XVB55M3N.js +1 -0
  49. package/dist/chunk-XVB55M3N.js.map +1 -1
  50. package/dist/chunk-ZI3OQDET.js +1 -0
  51. package/dist/chunk-ZI3OQDET.js.map +1 -1
  52. package/dist/data-grid.d.ts +1 -1
  53. package/dist/data-grid.js +5 -3
  54. package/dist/data-grid.js.map +1 -1
  55. package/dist/editor-mentions.js +2 -1
  56. package/dist/editor-mentions.js.map +1 -1
  57. package/dist/editor.js +3 -2
  58. package/dist/editor.js.map +1 -1
  59. package/dist/{feather-VFWLAILO.js → feather-FNBQ74RR.js} +10 -17
  60. package/dist/feather-FNBQ74RR.js.map +1 -0
  61. package/dist/{heroicons-H3Z7DFCF.js → heroicons-DODCSYWD.js} +9 -8
  62. package/dist/heroicons-DODCSYWD.js.map +1 -0
  63. package/dist/icons.d.ts +31 -4
  64. package/dist/icons.js +2 -1
  65. package/dist/icons.js.map +1 -1
  66. package/dist/index.d.ts +418 -65
  67. package/dist/index.js +1893 -838
  68. package/dist/index.js.map +1 -1
  69. package/dist/kanban.js +3 -2
  70. package/dist/kanban.js.map +1 -1
  71. package/dist/{lucide-MR32KM4G.js → lucide-ZWE3EPGP.js} +9 -8
  72. package/dist/lucide-ZWE3EPGP.js.map +1 -0
  73. package/dist/{phosphor-ABQQL5N5.js → phosphor-DIHPA4AJ.js} +9 -8
  74. package/dist/phosphor-DIHPA4AJ.js.map +1 -0
  75. package/dist/resizable.js +7 -5
  76. package/dist/resizable.js.map +1 -1
  77. package/dist/roots.css +25 -7
  78. package/dist/{tabler-ANUSY4D2.js → tabler-D3VYTSGI.js} +9 -8
  79. package/dist/tabler-D3VYTSGI.js.map +1 -0
  80. package/dist/tokens.css +11 -8
  81. package/dist/{use-pagination-BnKOnBdz.d.ts → use-pagination-BxcRlNQG.d.ts} +6 -0
  82. package/dist/utils.d.ts +275 -1
  83. package/dist/utils.js +875 -1
  84. package/dist/utils.js.map +1 -1
  85. package/dist/virtualized.d.ts +1 -1
  86. package/dist/virtualized.js +5 -3
  87. package/dist/virtualized.js.map +1 -1
  88. package/dist-static/tokens.css +11 -8
  89. package/package.json +5 -3
  90. package/dist/chunk-CYN5O567.js.map +0 -1
  91. package/dist/chunk-EX64MN2U.js.map +0 -1
  92. package/dist/chunk-HXVXJUGV.js.map +0 -1
  93. package/dist/chunk-KWLNEH53.js.map +0 -1
  94. package/dist/chunk-MYIJNVTK.js.map +0 -1
  95. package/dist/chunk-RWKCAKN3.js.map +0 -1
  96. package/dist/chunk-X2HEV7FB.js.map +0 -1
  97. package/dist/chunk-ZYVXV4WC.js.map +0 -1
  98. package/dist/feather-VFWLAILO.js.map +0 -1
  99. package/dist/heroicons-H3Z7DFCF.js.map +0 -1
  100. package/dist/lucide-MR32KM4G.js.map +0 -1
  101. package/dist/phosphor-ABQQL5N5.js.map +0 -1
  102. package/dist/tabler-ANUSY4D2.js.map +0 -1
package/dist/utils.js CHANGED
@@ -1,3 +1,877 @@
1
- export { ACTIVE_RING, FOCUS_RING, FOCUS_WITHIN_RING, GLASS_BACKDROP, GLASS_DROPDOWN, GLASS_OVERLAY, GLASS_SURFACE, HAS_FOCUS_RING, cn } from './chunk-M2QRNBDQ.js';
1
+ import { clsx } from 'clsx';
2
+ import { twMerge } from 'tailwind-merge';
3
+
4
+ // ../../showcase/src/lib/utils.ts
5
+ function cn(...inputs) {
6
+ return twMerge(clsx(inputs));
7
+ }
8
+ var GLASS_BACKDROP = "[backdrop-filter:var(--ds-glass-filter)] [-webkit-backdrop-filter:var(--ds-glass-filter)]";
9
+ var GLASS_SURFACE = `${GLASS_BACKDROP} shadow-[var(--ds-shadow-card),var(--ds-glass-inset)]`;
10
+ var GLASS_OVERLAY = `${GLASS_BACKDROP} shadow-[var(--ds-shadow-modal),var(--ds-glass-inset)]`;
11
+ var GLASS_DROPDOWN = `${GLASS_BACKDROP} shadow-[var(--ds-shadow-dropdown),var(--ds-glass-inset)]`;
12
+ var ACTIVE_RING = "border-[var(--ds-border-focus)] ring-2 ring-[var(--ds-ring-active)]";
13
+ var FOCUS_RING = "focus-visible:outline-none focus-visible:border-[var(--ds-border-focus)] focus-visible:ring-2 focus-visible:ring-[var(--ds-ring-active)]";
14
+ var FOCUS_WITHIN_RING = "focus-within:border-[var(--ds-border-focus)] focus-within:ring-2 focus-within:ring-[var(--ds-ring-active)]";
15
+ var HAS_FOCUS_RING = "has-[:focus-visible]:border-[var(--ds-border-focus)] has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-[var(--ds-ring-active)]";
16
+
17
+ // ../../showcase/src/lib/format-locale.ts
18
+ var last = null;
19
+ var FIXED_FORM = "en";
20
+ function formatLocale() {
21
+ if (typeof document === "undefined") return FIXED_FORM;
22
+ const page = document.documentElement.lang?.trim();
23
+ if (!page) return void 0;
24
+ return localeFor(page, browserLanguages());
25
+ }
26
+ function browserLanguages() {
27
+ if (typeof navigator === "undefined") return [];
28
+ return navigator.languages?.length ? navigator.languages : navigator.language ? [navigator.language] : [];
29
+ }
30
+ function localeFor(page, spoken) {
31
+ const key = `${page}|${spoken.join(",")}`;
32
+ if (last?.key !== key) last = { key, locale: choose(page, spoken) };
33
+ return last.locale;
34
+ }
35
+ function localeChoice(lang, acceptLanguage) {
36
+ const page = lang?.trim() || FIXED_FORM;
37
+ const spoken = acceptedLanguages(acceptLanguage);
38
+ return { lang: page, spoken, hasHeader: !!acceptLanguage, server: localeFor(page, spoken) ?? FIXED_FORM };
39
+ }
40
+ function requestLocale(lang, acceptLanguage) {
41
+ return localeChoice(lang, acceptLanguage).server;
42
+ }
43
+ var MAX_LANGUAGES = 20;
44
+ function acceptedLanguages(header) {
45
+ if (!header) return [];
46
+ const read = [];
47
+ header.split(",").slice(0, MAX_LANGUAGES).forEach((part, at) => {
48
+ const [tag, ...params] = part.trim().split(";");
49
+ const name = tag?.trim();
50
+ if (!name || name === "*") return;
51
+ const qParam = params.map((p) => p.trim()).find((p) => /^q=/i.test(p));
52
+ const q = qParam ? Number(qParam.slice(2)) : 1;
53
+ if (!(q > 0)) return;
54
+ read.push({ tag: name, q, at });
55
+ });
56
+ return read.sort((a, b) => b.q - a.q || a.at - b.at).map((r) => r.tag);
57
+ }
58
+ function writtenIn(tag) {
59
+ try {
60
+ const locale = new Intl.Locale(tag).maximize();
61
+ return `${locale.language}-${locale.script ?? ""}`;
62
+ } catch {
63
+ return null;
64
+ }
65
+ }
66
+ function plainTag(tag) {
67
+ try {
68
+ const locale = new Intl.Locale(tag);
69
+ return [locale.language, locale.script, locale.region].filter(Boolean).join("-");
70
+ } catch {
71
+ return void 0;
72
+ }
73
+ }
74
+ function choose(page, spoken) {
75
+ const language = writtenIn(page);
76
+ if (language === null) return void 0;
77
+ const own = spoken.find((tag) => typeof tag === "string" && writtenIn(tag) === language);
78
+ try {
79
+ return Intl.getCanonicalLocales(own && plainTag(own) || page)[0];
80
+ } catch {
81
+ return void 0;
82
+ }
83
+ }
84
+
85
+ // ../../showcase/src/lib/date-grid.ts
86
+ function dayKey(d) {
87
+ return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
88
+ }
89
+
90
+ // ../../showcase/src/lib/locale-cache.ts
91
+ var caches = /* @__PURE__ */ new Set();
92
+ function localeCache(limit) {
93
+ const map = /* @__PURE__ */ new Map();
94
+ caches.add(map);
95
+ return (key, make) => {
96
+ const hit = map.get(key);
97
+ if (hit !== void 0) {
98
+ map.delete(key);
99
+ map.set(key, hit);
100
+ return hit;
101
+ }
102
+ const made = make();
103
+ map.set(key, made);
104
+ if (map.size > limit) map.delete(map.keys().next().value);
105
+ return made;
106
+ };
107
+ }
108
+
109
+ // ../../showcase/src/lib/recurrence.ts
110
+ var DAY_CODES = ["SU", "MO", "TU", "WE", "TH", "FR", "SA"];
111
+ var FREQS = { DAILY: "daily", WEEKLY: "weekly", MONTHLY: "monthly", YEARLY: "yearly" };
112
+ var KNOWN_PARTS = /* @__PURE__ */ new Set(["FREQ", "INTERVAL", "WKST", "BYDAY", "BYSETPOS", "BYMONTHDAY", "BYMONTH", "UNTIL", "COUNT"]);
113
+ var whole = (text) => text !== void 0 && /^[+-]?\d+$/.test(text) ? Number(text) : null;
114
+ function plainDays(text) {
115
+ const days = text.split(",").map((code) => DAY_CODES.indexOf(code));
116
+ if (days.some((d) => d < 0) || new Set(days).size !== days.length) return null;
117
+ return days.sort((a, b) => a - b);
118
+ }
119
+ function nthDay(byday, setpos) {
120
+ const m = /^([+-]?\d)?(SU|MO|TU|WE|TH|FR|SA)$/.exec(byday);
121
+ if (!m) return null;
122
+ const week = m[1] !== void 0 ? setpos === void 0 ? Number(m[1]) : NaN : whole(setpos);
123
+ if (week === null || ![1, 2, 3, 4, -1].includes(week)) return null;
124
+ return { week, weekday: DAY_CODES.indexOf(m[2]) };
125
+ }
126
+ function parseUntil(text) {
127
+ const m = /^(\d{4})(\d{2})(\d{2})(?:T(\d{2})(\d{2})(\d{2})(Z)?)?$/.exec(text);
128
+ if (!m) return null;
129
+ const [y, mo, d] = [Number(m[1]), Number(m[2]) - 1, Number(m[3])];
130
+ const date = m[4] === void 0 ? new Date(y, mo, d) : m[7] ? new Date(Date.UTC(y, mo, d, Number(m[4]), Number(m[5]), Number(m[6]))) : new Date(y, mo, d, Number(m[4]), Number(m[5]), Number(m[6]));
131
+ return Number.isNaN(date.getTime()) || (m[7] ? date.getUTCMonth() : date.getMonth()) !== mo ? null : date;
132
+ }
133
+ function parseRRule(text) {
134
+ if (typeof text !== "string") return null;
135
+ const body = text.trim().replace(/^RRULE:/i, "");
136
+ if (!body) return null;
137
+ const parts = /* @__PURE__ */ new Map();
138
+ for (const part of body.split(";")) {
139
+ if (!part) continue;
140
+ const at = part.indexOf("=");
141
+ const key = part.slice(0, at).toUpperCase();
142
+ if (at <= 0 || parts.has(key) || !KNOWN_PARTS.has(key)) return null;
143
+ parts.set(key, part.slice(at + 1).toUpperCase());
144
+ }
145
+ const freq = FREQS[parts.get("FREQ") ?? ""];
146
+ if (!freq) return null;
147
+ const rule = { freq };
148
+ if (parts.has("INTERVAL")) {
149
+ const n = whole(parts.get("INTERVAL"));
150
+ if (n === null || n < 1) return null;
151
+ if (n > 1) rule.interval = n;
152
+ }
153
+ if (parts.has("WKST")) {
154
+ const d = DAY_CODES.indexOf(parts.get("WKST"));
155
+ if (d < 0) return null;
156
+ if (d !== 1) rule.weekStart = d;
157
+ }
158
+ if (parts.has("UNTIL") && parts.has("COUNT")) return null;
159
+ if (parts.has("COUNT")) {
160
+ const n = whole(parts.get("COUNT"));
161
+ if (n === null || n < 1) return null;
162
+ rule.count = n;
163
+ }
164
+ if (parts.has("UNTIL")) {
165
+ const until = parseUntil(parts.get("UNTIL"));
166
+ if (!until) return null;
167
+ rule.until = until;
168
+ }
169
+ const byday = parts.get("BYDAY"), setpos = parts.get("BYSETPOS"), monthday = parts.get("BYMONTHDAY"), month = parts.get("BYMONTH");
170
+ if (freq === "daily" || freq === "weekly") {
171
+ if (setpos !== void 0 || monthday !== void 0 || month !== void 0) return null;
172
+ if (byday === void 0) return rule;
173
+ if (freq === "daily" && rule.interval) return null;
174
+ const days = plainDays(byday);
175
+ if (!days) return null;
176
+ return { ...rule, freq: "weekly", weekdays: days };
177
+ }
178
+ if (month !== void 0) {
179
+ const m = whole(month);
180
+ if (freq !== "yearly" || m === null || m < 1 || m > 12) return null;
181
+ rule.month = m;
182
+ }
183
+ if (setpos !== void 0 && byday === void 0) return null;
184
+ if (byday !== void 0) {
185
+ const nth = nthDay(byday, setpos);
186
+ if (!nth || monthday !== void 0) return null;
187
+ rule.nth = nth;
188
+ } else if (monthday !== void 0) {
189
+ const d = whole(monthday);
190
+ if (d === null || !(d === -1 || d >= 1 && d <= 31)) return null;
191
+ rule.day = d;
192
+ }
193
+ if (freq === "yearly" && rule.month === void 0 !== (rule.day === void 0 && rule.nth === void 0)) return null;
194
+ return rule;
195
+ }
196
+ var pad = (n, width = 2) => String(n).padStart(width, "0");
197
+ function toRRule(rule, { allDay = false } = {}) {
198
+ const out = [`FREQ=${rule.freq.toUpperCase()}`];
199
+ if (rule.interval && rule.interval > 1) out.push(`INTERVAL=${rule.interval}`);
200
+ if (rule.month !== void 0) out.push(`BYMONTH=${rule.month}`);
201
+ if (rule.day !== void 0) out.push(`BYMONTHDAY=${rule.day}`);
202
+ const weekStart = rule.weekStart ?? 1;
203
+ if (rule.weekdays?.length) out.push(`BYDAY=${inWeekOrder(rule.weekdays, weekStart).map((d) => DAY_CODES[d]).join(",")}`);
204
+ if (rule.nth) out.push(`BYDAY=${rule.nth.week}${DAY_CODES[rule.nth.weekday]}`);
205
+ if (weekStart !== 1) out.push(`WKST=${DAY_CODES[weekStart]}`);
206
+ if (rule.until) {
207
+ const u = rule.until;
208
+ out.push(allDay ? `UNTIL=${u.getFullYear()}${pad(u.getMonth() + 1)}${pad(u.getDate())}` : `UNTIL=${u.getUTCFullYear()}${pad(u.getUTCMonth() + 1)}${pad(u.getUTCDate())}T${pad(u.getUTCHours())}${pad(u.getUTCMinutes())}${pad(u.getUTCSeconds())}Z`);
209
+ }
210
+ if (rule.count !== void 0) out.push(`COUNT=${rule.count}`);
211
+ return `RRULE:${out.join(";")}`;
212
+ }
213
+ var inWeekOrder = (days, weekStart) => [...days].sort((a, b) => (a - weekStart + 7) % 7 - (b - weekStart + 7) % 7);
214
+ function readRecurrence(value) {
215
+ if (!value) return null;
216
+ if (typeof value === "string") return parseRRule(value);
217
+ if (value.until === void 0 || value.until instanceof Date) return value;
218
+ const until = new Date(value.until);
219
+ return Number.isNaN(until.getTime()) ? null : { ...value, until };
220
+ }
221
+ var daysIn = (year, month) => new Date(year, month + 1, 0).getDate();
222
+ var atDay = (year, month, day, time) => new Date(year, month, day, time.getHours(), time.getMinutes(), time.getSeconds(), time.getMilliseconds());
223
+ var dayIndex = (d) => Math.round(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()) / 864e5);
224
+ var isMidnight = (d) => d.getHours() === 0 && d.getMinutes() === 0 && d.getSeconds() === 0 && d.getMilliseconds() === 0;
225
+ function nthWeekdayOf(year, month, week, weekday) {
226
+ const last2 = daysIn(year, month);
227
+ if (week === -1) return last2 - (new Date(year, month, last2).getDay() - weekday + 7) % 7;
228
+ const day = 1 + (weekday - new Date(year, month, 1).getDay() + 7) % 7 + (week - 1) * 7;
229
+ return day <= last2 ? day : null;
230
+ }
231
+ function nthOf(date) {
232
+ const d = date.getDate();
233
+ return { week: d + 7 > daysIn(date.getFullYear(), date.getMonth()) ? -1 : Math.ceil(d / 7), weekday: date.getDay() };
234
+ }
235
+ function nthChoices(date) {
236
+ const d = date.getDate(), weekday = date.getDay();
237
+ const out = [];
238
+ if (d <= 28) out.push({ week: Math.ceil(d / 7), weekday });
239
+ if (d + 7 > daysIn(date.getFullYear(), date.getMonth())) out.push({ week: -1, weekday });
240
+ return out;
241
+ }
242
+ function weekOnMoved(week, to) {
243
+ const d = to.getDate();
244
+ if (week === -1 && d + 7 > daysIn(to.getFullYear(), to.getMonth())) return -1;
245
+ return d <= 28 ? Math.ceil(d / 7) : -1;
246
+ }
247
+ function withinUntil(at, until) {
248
+ return at <= until || isMidnight(until) && dayIndex(at) === dayIndex(until);
249
+ }
250
+ function* starts(rule, first) {
251
+ const interval = Math.max(1, Math.floor(rule.interval ?? 1));
252
+ const firstDay = dayIndex(first);
253
+ let produced = 0;
254
+ const accept = (d) => {
255
+ if (rule.until && !withinUntil(d, rule.until)) return false;
256
+ return rule.count === void 0 || produced < rule.count;
257
+ };
258
+ if (rule.count !== void 0 && rule.count < 1) return;
259
+ produced++;
260
+ yield first;
261
+ const y0 = first.getFullYear(), m0 = first.getMonth();
262
+ for (let k = 0, empty = 0; k < 146100 && empty < 400 * 12; k++) {
263
+ const dates = [];
264
+ if (rule.freq === "daily") dates.push(atDay(y0, m0, first.getDate() + k * interval, first));
265
+ else if (rule.freq === "weekly") {
266
+ const weekStart = rule.weekStart ?? 1;
267
+ const base = first.getDate() - (first.getDay() - weekStart + 7) % 7 + k * interval * 7;
268
+ for (const wd of inWeekOrder(rule.weekdays?.length ? rule.weekdays : [first.getDay()], weekStart)) dates.push(atDay(y0, m0, base + (wd - weekStart + 7) % 7, first));
269
+ } else {
270
+ const monthsFrom = rule.freq === "monthly" ? k * interval : k * interval * 12;
271
+ const at = new Date(y0, m0 + monthsFrom, 1);
272
+ const year = at.getFullYear(), month = rule.freq === "yearly" && rule.month !== void 0 ? rule.month - 1 : at.getMonth();
273
+ let day;
274
+ if (rule.nth) day = nthWeekdayOf(year, month, rule.nth.week, rule.nth.weekday);
275
+ else if (rule.day === -1) day = daysIn(year, month);
276
+ else day = rule.day ?? first.getDate();
277
+ if (day !== null && day <= daysIn(year, month)) dates.push(atDay(year, month, day, first));
278
+ }
279
+ let any = false;
280
+ for (const d of dates) {
281
+ if (dayIndex(d) <= firstDay) continue;
282
+ if (!accept(d)) return;
283
+ produced++;
284
+ any = true;
285
+ yield d;
286
+ }
287
+ empty = any ? 0 : empty + 1;
288
+ }
289
+ }
290
+ function lengthOf(event) {
291
+ return event.end ? { days: dayIndex(event.end) - dayIndex(event.start), end: event.end } : null;
292
+ }
293
+ function occurrenceAt(event, start) {
294
+ const { repeat: _repeat, exceptions: _exceptions, ...rest } = event;
295
+ const length = lengthOf(event);
296
+ const date = dayKey(start);
297
+ const end = length ? atDay(start.getFullYear(), start.getMonth(), start.getDate() + length.days, length.end) : void 0;
298
+ return { ...rest, id: `${event.id}::${date}`, start, ...end ? { end } : {}, series: { id: event.id, date } };
299
+ }
300
+ function stopOf(event) {
301
+ if (event.allDay) {
302
+ const last2 = event.end ?? event.start;
303
+ return new Date(last2.getFullYear(), last2.getMonth(), last2.getDate() + 1);
304
+ }
305
+ return event.end ?? new Date(event.start.getTime() + 36e5);
306
+ }
307
+ function occurrences(event, from, to) {
308
+ const rule = readRecurrence(event.repeat);
309
+ if (!rule) return event.start < to && stopOf(event) > from ? [event] : [];
310
+ const skip = new Set(event.exceptions ?? []);
311
+ const reach = stopOf(event).getTime() - event.start.getTime();
312
+ const out = [];
313
+ for (const start of starts(rule, event.start)) {
314
+ if (start >= to) break;
315
+ if (start.getTime() + reach + 864e5 <= from.getTime()) continue;
316
+ if (skip.has(dayKey(start))) continue;
317
+ const occurrence = occurrenceAt(event, start);
318
+ if (stopOf(occurrence) > from) out.push(occurrence);
319
+ }
320
+ return out;
321
+ }
322
+ function startsBefore(rule, first, date) {
323
+ let n = 0;
324
+ for (const start of starts(rule, first)) {
325
+ if (dayKey(start) >= date) break;
326
+ n++;
327
+ }
328
+ return n;
329
+ }
330
+ var asWritten = (event, rule) => typeof event.repeat === "string" ? toRRule(rule, { allDay: event.allDay }) : rule;
331
+ var shiftKey = (key, days) => {
332
+ const [y, m, d] = key.split("-").map(Number);
333
+ return dayKey(new Date(y, m - 1, d + days));
334
+ };
335
+ var occurrenceOnDay = (series, date) => {
336
+ const [y, m, d] = date.split("-").map(Number);
337
+ return occurrenceAt(series, atDay(y, m - 1, d, series.start));
338
+ };
339
+ var editedOf = (events, seriesId) => events.filter((e) => e.series?.id === seriesId && e.id !== seriesId);
340
+ function occurrenceOn(series, date, events) {
341
+ const edited = events && editedOf(events, series.id).find((e) => e.series.date === date);
342
+ if (edited) return edited;
343
+ const [y, m, d] = date.split("-").map(Number);
344
+ return occurrences(series, new Date(y, m - 1, d), new Date(y, m - 1, d + 1)).find((o) => "series" in o && o.series?.date === date);
345
+ }
346
+ var editOf = (changes) => {
347
+ if (!changes) return {};
348
+ const { id: _id, repeat: _repeat, exceptions: _exceptions, ...rest } = changes;
349
+ delete rest.series;
350
+ return rest;
351
+ };
352
+ var repeatChanged = (series, changes) => {
353
+ if (!changes || !("repeat" in changes)) return false;
354
+ const given = changes.repeat;
355
+ if (given === series.repeat) return false;
356
+ const a = readRecurrence(given), b = readRecurrence(series.repeat);
357
+ return !(a && b && sameRecurrence(a, b));
358
+ };
359
+ function sameValue(a, b) {
360
+ if (a instanceof Date || b instanceof Date) return a instanceof Date && b instanceof Date && a.getTime() === b.getTime();
361
+ if (a && b && typeof a === "object" && typeof b === "object") return JSON.stringify(a) === JSON.stringify(b);
362
+ return a === b;
363
+ }
364
+ function editFrom(opened, series, changes) {
365
+ const was = opened;
366
+ const edit = {};
367
+ for (const [key, value] of Object.entries(editOf(changes))) if (!sameValue(value, was[key])) edit[key] = value;
368
+ if (repeatChanged(series, changes)) edit.repeat = changes.repeat;
369
+ return edit;
370
+ }
371
+ function moveRule(rule, days, to) {
372
+ const next = { ...rule };
373
+ if (rule.weekdays?.length) next.weekdays = rule.weekdays.map((d) => ((d + days) % 7 + 7) % 7).sort((a, b) => a - b);
374
+ if (rule.freq === "monthly" || rule.freq === "yearly") {
375
+ if (rule.nth) next.nth = { week: weekOnMoved(rule.nth.week, to), weekday: to.getDay() };
376
+ else if (rule.day === -1) {
377
+ if (to.getDate() !== daysIn(to.getFullYear(), to.getMonth())) next.day = to.getDate();
378
+ } else if (rule.day !== void 0) next.day = to.getDate();
379
+ if (rule.freq === "yearly" && rule.month !== void 0) next.month = to.getMonth() + 1;
380
+ }
381
+ return next;
382
+ }
383
+ function onMovedRule(rule, start, days) {
384
+ const endless = { ...rule, until: void 0, count: void 0 };
385
+ return (key) => {
386
+ const shifted = shiftKey(key, days);
387
+ const [y, m, d] = shifted.split("-").map(Number);
388
+ const target = dayIndex(new Date(y, m - 1, d));
389
+ let found = null;
390
+ for (const at of starts(endless, start)) {
391
+ const i = dayIndex(at);
392
+ if (i > target + 7) break;
393
+ if (i >= target - 7 && (!found || Math.abs(i - target) < Math.abs(dayIndex(found) - target))) found = at;
394
+ }
395
+ return found ? dayKey(found) : shifted;
396
+ };
397
+ }
398
+ var sameClock = (a, b) => a.getHours() === b.getHours() && a.getMinutes() === b.getMinutes() && a.getSeconds() === b.getSeconds() && a.getMilliseconds() === b.getMilliseconds();
399
+ var spanOf = (event) => event.end ? dayIndex(event.end) - dayIndex(event.start) : null;
400
+ function changeSeries(series, occurrence, changes) {
401
+ const at = typeof occurrence === "string" ? occurrenceOnDay(series, occurrence) : occurrence;
402
+ const { start: newStart, end: newEnd, ...rest } = editOf(changes);
403
+ const next = { ...series, ...rest };
404
+ const moveBy = (from, to, base) => atDay(base.getFullYear(), base.getMonth(), base.getDate() + dayIndex(to) - dayIndex(from), sameClock(to, from) ? base : to);
405
+ let days = 0;
406
+ if (newStart) {
407
+ days = dayIndex(newStart) - dayIndex(at.start);
408
+ next.start = moveBy(at.start, newStart, series.start);
409
+ }
410
+ if (newEnd) {
411
+ const from = at.end ?? at.start;
412
+ next.end = moveBy(from, newEnd, series.end ?? series.start);
413
+ }
414
+ const rule = readRecurrence(series.repeat);
415
+ let moveKey = (key) => shiftKey(key, days);
416
+ const moveExceptions = () => {
417
+ if (days !== 0 && series.exceptions?.length) next.exceptions = series.exceptions.map(moveKey);
418
+ };
419
+ if (repeatChanged(series, changes)) {
420
+ if (changes.repeat) {
421
+ next.repeat = changes.repeat;
422
+ moveExceptions();
423
+ } else {
424
+ delete next.repeat;
425
+ delete next.exceptions;
426
+ }
427
+ } else if (days !== 0 && rule && newStart) {
428
+ const moved = moveRule(rule, days, newStart);
429
+ next.repeat = asWritten(series, moved);
430
+ if (moved.nth) {
431
+ const from = next.start;
432
+ const anchor = (k) => {
433
+ const at2 = new Date(from.getFullYear() + (moved.freq === "yearly" ? k : 0), (moved.freq === "yearly" && moved.month !== void 0 ? moved.month - 1 : from.getMonth()) + (moved.freq === "monthly" ? k : 0), 1);
434
+ const d = nthWeekdayOf(at2.getFullYear(), at2.getMonth(), moved.nth.week, moved.nth.weekday) ?? nthWeekdayOf(at2.getFullYear(), at2.getMonth(), -1, moved.nth.weekday);
435
+ return atDay(at2.getFullYear(), at2.getMonth(), d, from);
436
+ };
437
+ let first = anchor(0);
438
+ if (dayIndex(first) < dayIndex(from)) first = anchor(1);
439
+ const extra = dayIndex(first) - dayIndex(from);
440
+ if (extra) {
441
+ next.start = first;
442
+ if (next.end) next.end = atDay(next.end.getFullYear(), next.end.getMonth(), next.end.getDate() + extra, next.end);
443
+ }
444
+ }
445
+ moveKey = onMovedRule(moved, next.start, days);
446
+ moveExceptions();
447
+ }
448
+ return { next, moveKey };
449
+ }
450
+ function splitWith(series, date, id, at, changes) {
451
+ const rule = readRecurrence(series.repeat);
452
+ const firstDate = dayKey(series.start);
453
+ if (!rule || date <= firstDate) {
454
+ if (!changes) return { after: series, moveKey: (key) => key };
455
+ const { next: next2, moveKey: moveKey2 } = changeSeries(series, typeof at === "string" ? at <= firstDate ? firstDate : at : at, changes);
456
+ return { after: next2, moveKey: moveKey2 };
457
+ }
458
+ const [y, m, d] = date.split("-").map(Number);
459
+ const first = occurrenceOnDay(series, date);
460
+ const exceptions = series.exceptions ?? [];
461
+ const counted = rule.count !== void 0 ? startsBefore(rule, series.start, date) : 0;
462
+ const beforeRule = { ...rule };
463
+ if (rule.count !== void 0) beforeRule.count = counted;
464
+ else {
465
+ delete beforeRule.until;
466
+ beforeRule.until = series.allDay ? new Date(y, m - 1, d - 1) : new Date(y, m - 1, d - 1, 23, 59, 59);
467
+ }
468
+ const afterRule = { ...rule };
469
+ if (rule.count !== void 0) afterRule.count = rule.count - counted;
470
+ const before = { ...series, repeat: asWritten(series, beforeRule), exceptions: exceptions.filter((x) => x < date) };
471
+ const after = { ...series, id, start: first.start, ...first.end ? { end: first.end } : {}, repeat: asWritten(series, afterRule), exceptions: exceptions.filter((x) => x >= date) };
472
+ if (!changes) return { before, after, moveKey: (key) => key };
473
+ const edit = repeatChanged(series, changes) ? changes : editOf(changes);
474
+ const { next, moveKey } = changeSeries(after, typeof at === "string" ? date : at, edit);
475
+ return { before, after: next, moveKey };
476
+ }
477
+ function detachOccurrence(series, date, id = `${series.id}-${date}`, changes) {
478
+ return {
479
+ series: { ...series, exceptions: [.../* @__PURE__ */ new Set([...series.exceptions ?? [], date])].sort() },
480
+ event: { ...occurrenceOnDay(series, date), ...editOf(changes), id }
481
+ };
482
+ }
483
+ var NOT_FOLLOWED = /* @__PURE__ */ new Set(["id", "series", "start", "end", "repeat", "exceptions"]);
484
+ function follow(edited, was, now) {
485
+ const out = { ...edited };
486
+ const before = was, after = now;
487
+ for (const key of /* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])) {
488
+ if (NOT_FOLLOWED.has(key) || !sameValue(out[key], before[key])) continue;
489
+ if (after[key] === void 0) delete out[key];
490
+ else out[key] = after[key];
491
+ }
492
+ const ownDay = dayIndex(edited.start) !== dayIndex(was.start);
493
+ const ownTimes = !sameClock(edited.start, was.start) || spanOf(edited) !== spanOf(was) || !!edited.end && !!was.end && !sameClock(edited.end, was.end);
494
+ const day = ownDay ? edited.start : now.start;
495
+ const times = ownTimes ? edited : now;
496
+ const start = atDay(day.getFullYear(), day.getMonth(), day.getDate(), times.start);
497
+ out.start = start;
498
+ const span = spanOf(times);
499
+ if (times.end && span !== null) out.end = atDay(start.getFullYear(), start.getMonth(), start.getDate() + span, times.end);
500
+ else delete out.end;
501
+ return out;
502
+ }
503
+ function carry(old, next, linked, moveKey, changed, opened, edit) {
504
+ if (!linked.length) return { next, save: [], remove: [] };
505
+ if (changed) {
506
+ const freed = new Set(linked.map((e) => moveKey(e.series.date)));
507
+ return { next: next.exceptions ? { ...next, exceptions: next.exceptions.filter((x) => !freed.has(x)) } : next, save: [], remove: linked.map((e) => e.id) };
508
+ }
509
+ const save = linked.map((e) => {
510
+ const date = moveKey(e.series.date);
511
+ const followed = follow(e, occurrenceOnDay(old, e.series.date), occurrenceOnDay(next, date));
512
+ return { ...followed, ...e.id === opened?.id ? editOf(edit) : {}, series: { id: next.id, date } };
513
+ });
514
+ return { next, save, remove: [] };
515
+ }
516
+ function findSeries(events, occurrence) {
517
+ const stored = events.find((e) => e.id === occurrence.id);
518
+ const link = (stored ?? occurrence).series;
519
+ const series = link ? events.find((e) => e.id === link.id && readRecurrence(e.repeat) !== null) : void 0;
520
+ return { series, stored, date: link?.date };
521
+ }
522
+ function commit(events, save, remove) {
523
+ const gone = new Set(remove);
524
+ const saved = new Map(save.map((e) => [e.id, e]));
525
+ const had = new Set(events.map((e) => e.id));
526
+ return { events: [...events.filter((e) => !gone.has(e.id)).map((e) => saved.get(e.id) ?? e), ...save.filter((e) => !had.has(e.id))], save, remove };
527
+ }
528
+ function saveOccurrence(events, occurrence, scope, changes, newId) {
529
+ const { series, stored, date } = findSeries(events, occurrence);
530
+ if (!series || date === void 0) return commit(events, stored ? [{ ...stored, ...editOf(changes) }] : [], []);
531
+ const opened = stored ?? occurrenceOnDay(series, date);
532
+ const edit = editFrom(opened, series, changes);
533
+ if (scope === "this") {
534
+ if (stored) return commit(events, [{ ...stored, ...editOf(edit) }], []);
535
+ const { series: kept, event } = detachOccurrence(series, date, newId, edit);
536
+ return commit(events, [kept, event], []);
537
+ }
538
+ const linked = editedOf(events, series.id);
539
+ const changed = repeatChanged(series, edit);
540
+ if (scope === "following" && date > dayKey(series.start)) {
541
+ const { before, after, moveKey: moveKey2 } = splitWith(series, date, newId, opened, edit);
542
+ const carried2 = carry(series, after, linked.filter((e) => e.series.date >= date), moveKey2, changed, stored, edit);
543
+ return commit(events, [...before ? [before] : [], carried2.next, ...carried2.save], carried2.remove);
544
+ }
545
+ const { next, moveKey } = changeSeries(series, opened, edit);
546
+ const carried = carry(series, next, linked, moveKey, changed, stored, edit);
547
+ return commit(events, [carried.next, ...carried.save], carried.remove);
548
+ }
549
+ function deleteOccurrence(events, occurrence, scope) {
550
+ const { series, stored, date } = findSeries(events, occurrence);
551
+ if (!series || date === void 0) return commit(events, [], stored ? [stored.id] : []);
552
+ if (scope === "this") return stored ? commit(events, [], [stored.id]) : commit(events, [detachOccurrence(series, date).series], []);
553
+ const linked = editedOf(events, series.id);
554
+ if (scope === "following" && date > dayKey(series.start)) {
555
+ const { before } = splitWith(series, date, series.id, date);
556
+ return commit(events, before ? [before] : [], linked.filter((e) => e.series.date >= date).map((e) => e.id));
557
+ }
558
+ return commit(events, [], [series.id, ...linked.map((e) => e.id)]);
559
+ }
560
+ function countEdited(events, occurrence) {
561
+ const { series, date } = findSeries(events, occurrence);
562
+ if (!series || date === void 0) return { following: 0, all: 0 };
563
+ const linked = editedOf(events, series.id);
564
+ return { following: date > dayKey(series.start) ? linked.filter((e) => e.series.date >= date).length : linked.length, all: linked.length };
565
+ }
566
+ var formats = localeCache(128);
567
+ function format(options, date, locale) {
568
+ return formats(`${locale ?? ""}|${JSON.stringify(options)}`, () => new Intl.DateTimeFormat(locale, options)).format(date);
569
+ }
570
+ var weekdayName = (d, locale) => format({ weekday: "long" }, new Date(2026, 0, 4 + d), locale);
571
+ var monthName = (m, locale) => format({ month: "long" }, new Date(2026, m - 1, 1), locale);
572
+ var ORDINAL = { 1: "first", 2: "second", 3: "third", 4: "fourth", [-1]: "last" };
573
+ var list = (items) => items.length < 2 ? items.join("") : `${items.slice(0, -1).join(", ")} and ${items[items.length - 1]}`;
574
+ var every = (n, one, many) => n > 1 ? `Every ${n} ${many}` : `Every ${one}`;
575
+ function describeRecurrence(rule, start, locale = formatLocale()) {
576
+ const n = Math.max(1, Math.floor(rule.interval ?? 1));
577
+ const weekStart = rule.weekStart ?? 1;
578
+ let text;
579
+ if (rule.freq === "daily") text = every(n, "day", "days");
580
+ else if (rule.freq === "weekly") {
581
+ const days = inWeekOrder(rule.weekdays?.length ? rule.weekdays : [start.getDay()], weekStart);
582
+ if (days.length === 7) text = every(n, "day", "weeks on every day");
583
+ else if (n === 1 && days.join() === "1,2,3,4,5") text = "Every weekday (Monday to Friday)";
584
+ else text = `${every(n, "week", "weeks")} on ${list(days.map((d) => weekdayName(d, locale)))}`;
585
+ } else {
586
+ const nth = rule.nth ? `the ${ORDINAL[rule.nth.week]} ${weekdayName(rule.nth.weekday, locale)}` : void 0;
587
+ if (rule.freq === "monthly") {
588
+ const on = nth ?? (rule.day === -1 ? "the last day" : `day ${rule.day ?? start.getDate()}`);
589
+ text = `${every(n, "month", "months")} on ${on}`;
590
+ } else {
591
+ const month = rule.month ?? start.getMonth() + 1;
592
+ const on = nth ? `${nth} of ${monthName(month, locale)}` : rule.day === -1 ? `the last day of ${monthName(month, locale)}` : (
593
+ // a leap year, so 29 February reads as itself
594
+ format({ day: "numeric", month: "long" }, new Date(2028, month - 1, rule.day ?? start.getDate()), locale)
595
+ );
596
+ text = `${every(n, "year", "years")} on ${on}`;
597
+ }
598
+ }
599
+ if (rule.until) text += `, until ${format({ day: "numeric", month: "long", year: "numeric" }, rule.until, locale)}`;
600
+ else if (rule.count !== void 0) text += rule.count === 1 ? ", once" : `, ${rule.count} times`;
601
+ return text;
602
+ }
603
+ function recurrencePresets(start, locale = formatLocale()) {
604
+ const rules = [{ freq: "daily" }];
605
+ const weekday = start.getDay();
606
+ if (weekday >= 1 && weekday <= 5) rules.push({ freq: "weekly", weekdays: [1, 2, 3, 4, 5] });
607
+ rules.push({ freq: "weekly" }, ...nthChoices(start).map((nth) => ({ freq: "monthly", nth })), { freq: "monthly" });
608
+ if (start.getDate() === daysIn(start.getFullYear(), start.getMonth())) rules.push({ freq: "monthly", day: -1 });
609
+ rules.push({ freq: "yearly" });
610
+ return rules.map((rule) => ({ rule, label: describeRecurrence(rule, start, locale) }));
611
+ }
612
+ function sameRecurrence(a, b) {
613
+ if (!a || !b) return a === b;
614
+ const norm = (r) => toRRule({ ...r, weekdays: r.weekdays?.length ? [...r.weekdays].sort() : void 0 });
615
+ return norm(a) === norm(b);
616
+ }
617
+
618
+ // ../../showcase/src/lib/time-zones.ts
619
+ function canonicalTimeZone(zone) {
620
+ try {
621
+ return new Intl.DateTimeFormat("en-US", { timeZone: zone }).resolvedOptions().timeZone;
622
+ } catch {
623
+ return zone;
624
+ }
625
+ }
626
+ function timeZoneOffset(zone, at = /* @__PURE__ */ new Date(), locale = formatLocale()) {
627
+ try {
628
+ return new Intl.DateTimeFormat(locale, { timeZone: zone, timeZoneName: "shortOffset" }).formatToParts(at).find((p) => p.type === "timeZoneName")?.value ?? "";
629
+ } catch {
630
+ return "";
631
+ }
632
+ }
633
+
634
+ // ../../showcase/src/lib/time-days.ts
635
+ var TIME_ZOOMS = ["day", "week", "month", "quarter"];
636
+ var DAY_MS = 864e5;
637
+ var DATE_ONLY = /^(\d{4})-(\d{2})-(\d{2})$/;
638
+ var utcDay = (y, m, d) => Math.round(Date.UTC(y, m, d) / DAY_MS);
639
+ function dayOfDate(d) {
640
+ const t = d.getTime();
641
+ if (Number.isNaN(t)) return NaN;
642
+ const day = utcDay(d.getFullYear(), d.getMonth(), d.getDate());
643
+ const first = new Date(t);
644
+ first.setHours(0, 0, 0, 0);
645
+ if (first.getTime() === t) return day;
646
+ const ms = ((d.getHours() * 60 + d.getMinutes()) * 60 + d.getSeconds()) * 1e3 + d.getMilliseconds();
647
+ return day + ms / DAY_MS;
648
+ }
649
+ function dayOf(value) {
650
+ if (typeof value === "number") return Number.isFinite(value) ? value : NaN;
651
+ if (value instanceof Date) return dayOfDate(value);
652
+ if (typeof value !== "string") return NaN;
653
+ const m = DATE_ONLY.exec(value.trim());
654
+ if (!m) return dayOfDate(new Date(value));
655
+ const [y, mo, d] = [Number(m[1]), Number(m[2]) - 1, Number(m[3])];
656
+ const day = utcDay(y, mo, d);
657
+ const back = new Date(day * DAY_MS);
658
+ return back.getUTCFullYear() === y && back.getUTCMonth() === mo && back.getUTCDate() === d ? day : NaN;
659
+ }
660
+ function dateOfDay(day) {
661
+ const whole2 = Math.floor(day);
662
+ const u = new Date(whole2 * DAY_MS);
663
+ return new Date(u.getUTCFullYear(), u.getUTCMonth(), u.getUTCDate(), 0, 0, 0, Math.round((day - whole2) * DAY_MS));
664
+ }
665
+ function isWholeDay(value) {
666
+ return typeof value === "string" ? DATE_ONLY.test(value.trim()) : Number.isInteger(dayOf(value));
667
+ }
668
+ function endDayOf(value) {
669
+ const day = dayOf(value);
670
+ return typeof value !== "number" && isWholeDay(value) ? day + 1 : day;
671
+ }
672
+ function rangeEnd(start, end) {
673
+ return end instanceof Date && !isWholeDay(start) ? dayOf(end) : endDayOf(end);
674
+ }
675
+ var formats2 = localeCache(128);
676
+ function dayFormatter(given, options) {
677
+ const locale = given ?? formatLocale();
678
+ return formats2(`${locale ?? ""}|${JSON.stringify(options)}`, () => new Intl.DateTimeFormat(locale, { ...options, timeZone: "UTC" }));
679
+ }
680
+ function timeExtent(ranges) {
681
+ let start = Infinity;
682
+ let end = -Infinity;
683
+ for (const r of ranges) {
684
+ if (r == null) continue;
685
+ const s = dayOf(r.start);
686
+ const e = r.end == null ? endDayOf(r.start) : rangeEnd(r.start, r.end);
687
+ if (Number.isFinite(s)) start = Math.min(start, s);
688
+ if (Number.isFinite(e)) end = Math.max(end, e);
689
+ }
690
+ return Number.isFinite(start) && Number.isFinite(end) ? { start, end: Math.max(start, end) } : { start: NaN, end: NaN };
691
+ }
692
+ var DAY_WORDS = { day: "numeric", month: "long" };
693
+ var TIME_WORDS = { hour: "2-digit", minute: "2-digit" };
694
+ var SEPARATOR = /\s*[\u2010-\u2015\u2212~\uff5e\u301c-]\s*/;
695
+ var english = (f) => new Intl.Locale(f.resolvedOptions().locale).language === "en";
696
+ function range(f, a, b, to) {
697
+ if (typeof f.formatRangeToParts !== "function") return to === void 0 ? f.formatRange(a, b) : `${f.format(a)}${to}${f.format(b)}`;
698
+ const parts = f.formatRangeToParts(a, b);
699
+ const lastOfStart = parts.map((p) => p.source).lastIndexOf("startRange");
700
+ const firstOfEnd = parts.findIndex((p) => p.source === "endRange");
701
+ if (lastOfStart < 0 || firstOfEnd < 0) return f.format(a);
702
+ if (to === void 0) return parts.map((p) => p.value).join("");
703
+ let joined = false;
704
+ const out = parts.map((p, i) => {
705
+ if (joined || i <= lastOfStart || i >= firstOfEnd || !SEPARATOR.test(p.value)) return p.value;
706
+ joined = true;
707
+ return p.value.replace(SEPARATOR, to);
708
+ });
709
+ if (!joined) out.splice(lastOfStart + 1, 0, to);
710
+ return out.join("");
711
+ }
712
+ function formatDateRange(start, end, words) {
713
+ const { locale, to, day = DAY_WORDS, time = TIME_WORDS } = words ?? {};
714
+ const until = end ?? start;
715
+ const from = dayOf(start);
716
+ const stop = rangeEnd(start, until);
717
+ if (!Number.isFinite(from) || !Number.isFinite(stop)) return "";
718
+ const timed = !isWholeDay(start) || !isWholeDay(until);
719
+ const first = timed ? from : Math.floor(from);
720
+ const last2 = timed ? Math.max(from, stop) : Math.max(first, Math.ceil(stop) - 1);
721
+ const a = new Date(first * DAY_MS);
722
+ const b = new Date(last2 * DAY_MS);
723
+ const years = a.getUTCFullYear() !== b.getUTCFullYear() && day.year === void 0;
724
+ const f = dayFormatter(locale, { ...day, ...years ? { year: "numeric" } : {}, ...timed ? time : {} });
725
+ return first === last2 ? f.format(a) : range(f, a, b, to ?? (english(f) ? " to " : void 0));
726
+ }
727
+
728
+ // ../../showcase/src/lib/chart-categories.ts
729
+ var ENGLISH_MONTHS = [
730
+ "january",
731
+ "february",
732
+ "march",
733
+ "april",
734
+ "may",
735
+ "june",
736
+ "july",
737
+ "august",
738
+ "september",
739
+ "october",
740
+ "november",
741
+ "december",
742
+ "jan",
743
+ "feb",
744
+ "mar",
745
+ "apr",
746
+ "jun",
747
+ "jul",
748
+ "aug",
749
+ "sep",
750
+ "sept",
751
+ "oct",
752
+ "nov",
753
+ "dec"
754
+ ];
755
+ var ENGLISH_WEEKDAYS = [
756
+ "monday",
757
+ "tuesday",
758
+ "wednesday",
759
+ "thursday",
760
+ "friday",
761
+ "saturday",
762
+ "sunday",
763
+ "mon",
764
+ "tue",
765
+ "tues",
766
+ "wed",
767
+ "thu",
768
+ "thur",
769
+ "thurs",
770
+ "fri",
771
+ "sat",
772
+ "sun"
773
+ ];
774
+ var escape = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
775
+ var clean = (s) => s.trim().toLowerCase().replace(/\.$/, "");
776
+ function intlNames(locale, kind) {
777
+ const out = [];
778
+ try {
779
+ for (const width of ["short", "long"]) {
780
+ const fmt = new Intl.DateTimeFormat(locale, kind === "month" ? { month: width, timeZone: "UTC" } : { weekday: width, timeZone: "UTC" });
781
+ const count = kind === "month" ? 12 : 7;
782
+ for (let i = 0; i < count; i++) {
783
+ const date = kind === "month" ? new Date(Date.UTC(2026, i, 15)) : new Date(Date.UTC(2026, 0, 5 + i));
784
+ out.push(clean(fmt.format(date)));
785
+ }
786
+ }
787
+ } catch {
788
+ }
789
+ return out;
790
+ }
791
+ function locales(given) {
792
+ const out = /* @__PURE__ */ new Set(["en"]);
793
+ if (given !== void 0) {
794
+ out.add(given);
795
+ return [...out];
796
+ }
797
+ try {
798
+ out.add(new Intl.DateTimeFormat().resolvedOptions().locale);
799
+ } catch {
800
+ }
801
+ if (typeof navigator !== "undefined" && navigator.language) out.add(navigator.language);
802
+ if (typeof document !== "undefined" && document.documentElement?.lang) out.add(document.documentElement.lang);
803
+ return [...out];
804
+ }
805
+ var cached = null;
806
+ function patterns(given) {
807
+ const tags = locales(given);
808
+ const key = tags.join("|");
809
+ if (cached?.key === key) return cached;
810
+ const months = new Set(ENGLISH_MONTHS);
811
+ const weekdays = new Set(ENGLISH_WEEKDAYS);
812
+ for (const tag of tags) {
813
+ for (const m of intlNames(tag, "month")) if (m) months.add(m);
814
+ for (const d of intlNames(tag, "weekday")) if (d) weekdays.add(d);
815
+ }
816
+ const alt = (set) => [...set].sort((a, b) => b.length - a.length).map(escape).join("|");
817
+ const M = `(?:${alt(months)})\\.?`;
818
+ const D = `(?:${alt(weekdays)})\\.?`;
819
+ const day = String.raw`\d{1,2}(?:st|nd|rd|th|\.)?`;
820
+ const year = String.raw`'?\d{2,4}`;
821
+ const list2 = [
822
+ // dates in digits: 2026-09-21, 21/09, 09/21/2026, 21.09.2026, an ISO date-time
823
+ /^\d{4}[-/.]\d{1,2}(?:[-/.]\d{1,2})?$/,
824
+ /^\d{1,2}[-/.]\d{1,2}(?:[-/.]\d{2,4})?$/,
825
+ /^\d{4}-\d{2}-\d{2}[T ]\d{1,2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?$/,
826
+ // a day and a month in either order, and a month alone or with its year: 16 Sep, 21. Sept., Sept 21, March 2026
827
+ new RegExp(`^${day}\\s*${M}(?:,?\\s+${year})?$`, "iu"),
828
+ new RegExp(`^${M}\\s*${day}(?:,?\\s+${year})?$`, "iu"),
829
+ new RegExp(`^${M}(?:\\s*${year})?$`, "iu"),
830
+ // CJK dates: 9月21日, 2026年9月, 9월 21일
831
+ /^(?:\d{4}年)?\d{1,2}月(?:\d{1,2}日)?$/u,
832
+ /^\d{4}年(?:\d{1,2}月)?$/u,
833
+ /^(?:\d{4}년\s?)?\d{1,2}월(?:\s?\d{1,2}일)?$/u,
834
+ // a quarter or a half: Q3, Q3 2026, Q3 FY26, 2026 Q3, 3Q26, H1 2026
835
+ /^Q[1-4](?:\s*[-/']?\s*(?:FY\s?)?'?\d{2,4})?$/i,
836
+ /^[1-4]Q\s*'?\d{0,4}$/i,
837
+ /^(?:FY\s?)?'?\d{2,4}\s*[-/]?\s*Q[1-4]$/i,
838
+ /^H[12](?:\s*'?\d{2,4})?$/i,
839
+ // a year or a fiscal year: 2026, FY26, FY 2025/26, 2025/26, 2025-2026
840
+ /^(?:19|20)\d{2}$/,
841
+ /^FY\s?'?\d{2,4}(?:\s?[-/]\s?'?\d{2,4})?$/i,
842
+ /^(?:19|20)\d{2}\s?[-/–]\s?(?:(?:19|20)?\d{2})$/,
843
+ // a week: W12, Wk 3, Week 12, Week 12 2026, 2026-W12
844
+ /^(?:W|Wk|Week)\.?\s?\d{1,2}(?:\s*[,/-]?\s*\d{4})?$/i,
845
+ /^\d{4}-?W\d{1,2}(?:-?\d)?$/i,
846
+ // a weekday: Mon, Tuesday, and the runtime and page locales' own
847
+ new RegExp(`^${D}$`, "iu"),
848
+ // a time: 09:00, 9:30 pm, 9am, 14h
849
+ /^\d{1,2}:\d{2}(?::\d{2})?\s?(?:[ap]\.?m\.?)?$/i,
850
+ /^\d{1,2}\s?[ap]\.?m\.?$/i,
851
+ /^\d{1,2}h(?:\d{2})?$/i,
852
+ // a number, a percentage or an amount: 12, -3.5, 1,200, 12%, $5k, €1.2m, 5 €, a bin (10–20, <10, 50+)
853
+ /^[<>≤≥~]?\s?[+\-−]?\s?[$€£¥₹]?\s?\d[\d,. \u00a0\u202f]*(?:\s?(?:k|m|mn|bn|b|t))?\s?(?:%|[$€£¥₹])?\+?$/iu,
854
+ /^[$€£¥₹]?\d[\d,.]*\s?[-–]\s?[$€£¥₹]?\d[\d,.]*\s?(?:k|m|bn|%)?$/iu
855
+ ];
856
+ cached = { key, list: list2 };
857
+ return cached;
858
+ }
859
+ function categoryKind(labels, locale) {
860
+ const { list: list2 } = patterns(locale);
861
+ for (const raw of labels) {
862
+ if (raw == null) continue;
863
+ if (typeof raw === "number") {
864
+ if (Number.isFinite(raw)) continue;
865
+ return "names";
866
+ }
867
+ if (raw instanceof Date) continue;
868
+ const text = String(raw).trim();
869
+ if (!text) continue;
870
+ if (!list2.some((re) => re.test(text))) return "names";
871
+ }
872
+ return "scale";
873
+ }
874
+
875
+ export { ACTIVE_RING, FOCUS_RING, FOCUS_WITHIN_RING, GLASS_BACKDROP, GLASS_DROPDOWN, GLASS_OVERLAY, GLASS_SURFACE, HAS_FOCUS_RING, TIME_ZOOMS, canonicalTimeZone, categoryKind, cn, countEdited, dateOfDay, dayOf, deleteOccurrence, describeRecurrence, endDayOf, formatDateRange, nthOf, occurrenceOn, occurrences, parseRRule, readRecurrence, recurrencePresets, requestLocale, sameRecurrence, saveOccurrence, timeExtent, timeZoneOffset, toRRule };
2
876
  //# sourceMappingURL=utils.js.map
3
877
  //# sourceMappingURL=utils.js.map